Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
lock_to_source.hpp File Reference

Lock-to-source support for generated JS/TSX import artifacts. More...

#include <pulp/view/design_import.hpp>
#include <optional>
#include <string>
#include <vector>

Go to the source code of this file.

Classes

struct  pulp::view::LockToSourceTweak
 A single tweak to promote into source. More...
struct  pulp::view::LockResult
 Result of locking one tweak into a generated source string. More...
struct  pulp::view::ReparentToSourceEdit
 A single structural reparent to promote into source: move the element anchored by child_anchor_id to become a child of the element anchored by new_parent_anchor_id. More...

Namespaces

namespace  pulp
namespace  pulp::view
 Hover-cursor tracking for platform window hosts.

Enumerations

enum class  pulp::view::LockStatus {
  pulp::view::rewritten , pulp::view::inserted , pulp::view::already_current , pulp::view::anchor_not_found ,
  pulp::view::unsupported_property
}
 Outcome status for a single lock attempt. More...

Functions

std::optional< std::string > pulp::view::lock_property_to_style_name (const std::string &property_path)
 Map a dotted tweak property_path (paint.backgroundColor, style.width, layout.padding, …) to the camelCase CSS property name the web-compat codegen emits as el.style.
LockResult pulp::view::lock_tweak_into_source (const std::string &source, const LockToSourceTweak &tweak)
 Locate the element anchored by tweak.anchor_id in a generated web-compat JS/TSX source string and rewrite (or insert) the style assignment for tweak.property_path so it carries tweak.value.
std::vector< LockResult > pulp::view::lock_tweaks_into_source (const std::string &source, const std::vector< LockToSourceTweak > &tweaks)
 Lock several tweaks into the same source in one pass.
LockResult pulp::view::reparent_in_source (const std::string &source, const ReparentToSourceEdit &edit)
 Rewrite the dragged element's appendChild receiver so the generated source wires it under the new parent.
bool pulp::view::is_generated_source (const std::string &source)
 Heuristic guard for the generated-file boundary.

Detailed Description

Lock-to-source support for generated JS/TSX import artifacts.

The inspector's direct-manipulation edits land in a tweaks layer (pulp-tweaks.json, keyed by stable_anchor_id). "Lock to source" is the explicit, opt-in promotion of a tweak back into the authored source so the change is permanent and survives a fresh re-import.

Path A handles the generated import target: when pulp import-design lowered a design into web-compat JS/TSX, that text is owned by the user and carries machine-traceable provenance:

  • a // @pulp-anchor <id> trail comment before every element (emitted by generate_pulp_js when include_comments is on), and
  • a setAnchor(<var>._id, '<id>') call binding the live widget.

Locking a tweak means: locate the element block for anchor_id, then rewrite (or insert) the el.style.<prop> assignment that corresponds to the tweak's dotted property_path so the generated file now reflects the tweaked value. After a successful lock the tweak-store entry can be retired — the value is baked into the source.

Scope discipline: this path only handles generated import artifacts. Live-runtime JSX patching (jsx_lock.hpp) and DESIGN.md token export (token_lock.hpp) are separate mechanisms.

The engine is pure text in / text out — no filesystem I/O — so it is trivially unit-testable and the CLI / inspector layers own the read-confirm-write loop and the @generated-boundary guard.