Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
design_ir.hpp
Go to the documentation of this file.
1#pragma once
2
12
14
15#include <cmath>
16#include <cstddef>
17#include <cstdint>
18#include <filesystem>
19#include <memory>
20#include <string>
21#include <string_view>
22#include <vector>
23#include <optional>
24#include <map>
25#include <unordered_map>
26#include <variant>
27
28namespace pulp::view {
29
30// ── Design source types ─────────────────────────────────────────────────
31//
32// DesignSource is part of the IR model: DesignIR::source is a DesignSource
33// by value, so the enum must be defined here (foundational) to keep the
34// header dependency graph acyclic. The string<->enum helper functions live
35// in design_sources.hpp alongside the source adapters.
36
37enum class DesignSource {
42 claude, // Anthropic Claude Design — manual HTML/zip export, no Anthropic API
43 designmd, // Google DESIGN.md (Apache-2.0) — YAML frontmatter + Markdown body
44 jsx, // Single-file React JSX instrument — compiled via esbuild + bundled React/ReactDOM
45 figma_plugin, // Pulp's "Design for Pulp" Figma plugin export envelope
46 html, // Generic runnable HTML evaluated by the isolated browser lane
47 preconverted_svg // Validated SVG + control-map sidecar; no source conversion
48};
49
50// ── Normalized Intermediate Representation ──────────────────────────────
51
53enum class LayoutDirection { row, column };
54
59
61enum class SizingMode { fixed, hug, fill };
62
69 float offset_x = 0.0f;
70 float offset_y = 0.0f;
71 float blur = 0.0f;
72 float spread = 0.0f;
73 std::string color;
74 bool inset = false;
75 std::string raw;
76};
77
79struct IRStyle {
80 std::optional<std::string> background_color;
81 std::optional<std::string> background_gradient; // linear-gradient(...)
82 std::optional<std::string> background_image; // url(...), data:..., or none
83 std::optional<std::string> background_repeat;
84 std::optional<std::string> background_position;
85 // CSS background-size keyword ("cover", "contain", "auto"). Figma IMAGE
86 // fill scale modes lower here on frame-shaped nodes (FILL → cover,
87 // FIT → contain, TILE → auto + background_repeat: repeat). Stored on the
88 // View via set_background_size and emitted by every codegen; raster
89 // background-image paint honoring is the same deferred slot as
90 // background_repeat (View::style_extras).
91 std::optional<std::string> background_size;
92 // CSS background-origin ("padding-box", "border-box", "content-box"),
93 // possibly a per-layer list. It decides the box a repeating background
94 // tile is sized and positioned in; absent means the CSS initial value,
95 // padding-box.
96 std::optional<std::string> background_origin;
97 // CSS object-fit for image-shaped nodes ("fill", "contain", "cover",
98 // "none", "scale-down"). Figma IMAGE fill scale modes lower here when the
99 // fill becomes a dedicated image node (FILL → cover, FIT → contain);
100 // ImageView::paint honors it, so this is a rendered property, not a
101 // storage-only slot.
102 std::optional<std::string> object_fit;
103 std::optional<std::string> color; // text color
104 std::optional<float> opacity;
105 // CSS mix-blend-mode keyword (e.g. "multiply", "screen", "color-dodge").
106 // Normalized to the lowercase-hyphen CSS spelling at parse time; the
107 // engine's View::set_mix_blend_mode + setMixBlendMode bridge consume it.
108 std::optional<std::string> mix_blend_mode;
109 std::optional<float> border_radius;
110 std::optional<std::string> border; // e.g. "1px solid #333"
111 std::optional<std::string> border_color;
112 std::optional<float> border_width;
113 std::optional<std::string> border_style;
114 std::optional<std::string> border_top_color;
115 std::optional<std::string> border_right_color;
116 std::optional<std::string> border_bottom_color;
117 std::optional<std::string> border_left_color;
118 std::optional<float> border_top_width;
119 std::optional<float> border_right_width;
120 std::optional<float> border_bottom_width;
121 std::optional<float> border_left_width;
122 std::optional<float> border_top_left_radius;
123 std::optional<float> border_top_right_radius;
124 std::optional<float> border_bottom_right_radius;
125 std::optional<float> border_bottom_left_radius;
126 std::vector<IRBoxShadow> box_shadow; // ordered CSS shadow layers
127 std::optional<std::string> filter; // e.g. "blur(4px)"
128 std::optional<std::string> backdrop_filter;
129 // CSS clip-path / mask. The engine (View::set_clip_path / set_mask /
130 // set_mask_image / set_mask_size) + the setClipPath/setMask* bridge
131 // consume these; sources that carry them — and Figma mask
132 // layers once the extractor emits a clip-path — survive the IR.
133 std::optional<std::string> clip_path;
134 // The clip an importer resolved for THIS node, in the node's own
135 // coordinate space (origin at its top-left, same space as `clip_path`).
136 //
137 // Carried per node rather than inherited from a clipping parent, because
138 // CSS clips along the containing-block chain while a tree clips by
139 // parentage, and the two disagree in both directions: an absolutely
140 // positioned node can escape an `overflow: hidden` ancestor it sits inside,
141 // and a node moved to a new parent must keep the clip its old one gave it.
142 // A rectangle attached to the node travels with the node, so re-parenting
143 // cannot change what it clips. The engine (View::set_ancestor_clip_rect)
144 // applies it to the node's OWN ink only — every descendant carries its own.
145 //
146 // The corner radii belong to the clip, not to the node: CSS clips overflow
147 // to the clipper's ROUNDED padding box, so a square-cornered child inside a
148 // rounded card is cut to the card's curve. Without them a rounded card whose
149 // media area is a plain rectangle paints that rectangle square into the
150 // corner, and the card reads as unrounded even though its own border curves.
151 // A radius applies only where the clip's corner is still the clipper's own —
152 // a corner cut by a second, tighter clipper is square, so the resolver drops
153 // the radius there rather than rounding a corner nothing rounded.
154 struct ClipRect {
155 float x = 0, y = 0, width = 0, height = 0;
156 float radius_tl = 0, radius_tr = 0, radius_br = 0, radius_bl = 0;
157 };
158 std::optional<ClipRect> clip_rect;
159 std::optional<std::string> mask; // `mask` shorthand
160 std::optional<std::string> mask_image;
161 std::optional<std::string> mask_size;
162 std::optional<std::string> font_family;
163 std::optional<float> font_size;
164 std::optional<int> font_weight;
165 std::optional<std::string> font_style; // normal, italic
166 std::optional<std::string> text_align;
167 // Vertical alignment of text within its design-reserved slot: "top",
168 // "middle", "bottom" (Figma textAlignVertical, normalized). When set it is
169 // design authority: codegen honors it instead of the tall-slot centering
170 // heuristic (which remains the fallback for sources that never say).
171 std::optional<std::string> vertical_align;
172 std::optional<float> letter_spacing;
173 std::optional<float> line_height;
174 std::optional<std::string> text_transform;
175 std::optional<std::string> text_decoration;
176 std::optional<std::string> white_space;
177 std::optional<std::string> text_overflow;
178 std::optional<std::string> overflow; // hidden, scroll, auto
179 std::optional<std::string> cursor;
189 std::optional<std::string> pointer_events; // auto, none
190 std::optional<std::string> position; // absolute, relative
191 std::optional<float> top, left, right, bottom;
192 std::optional<int> z_index;
193 std::optional<std::string> transform; // rotate, scale, etc.
194 std::optional<float> width, height;
195 std::optional<float> min_width, min_height;
196 std::optional<float> max_width, max_height;
197 // The asset's true visual extent in logical px when it bleeds past the
198 // layout box (figma-plugin `render_bounds`: drop shadows, glow, oversized
199 // chrome like the silver-knob graphic). w/h = rendered size, dx/dy = offset
200 // of the render origin relative to the layout box (negative = extends
201 // left/up). When present + larger than width/height, the importer sizes the
202 // image to render_bounds and offsets by dx/dy instead of squashing it.
203 struct RenderBounds { float w = 0, h = 0, dx = 0, dy = 0; };
204 std::optional<RenderBounds> render_bounds;
205};
206
208struct IRLayout {
209 std::optional<std::string> display; // flex, grid, none
211 float gap = 0.0f;
212 std::optional<float> row_gap;
213 std::optional<float> column_gap;
214 float padding_top = 0.0f;
215 float padding_right = 0.0f;
216 float padding_bottom = 0.0f;
217 float padding_left = 0.0f;
218 std::optional<float> margin_top;
219 std::optional<float> margin_right;
220 std::optional<float> margin_bottom;
221 std::optional<float> margin_left;
224 std::optional<std::string> align_self;
225 std::optional<std::string> align_content;
226 bool wrap = false;
227 std::optional<float> flex_grow;
228 std::optional<float> flex_shrink;
229 std::optional<std::string> flex_basis;
230 std::optional<int> order;
231 std::optional<float> aspect_ratio;
232 std::optional<std::string> overflow_x;
233 std::optional<std::string> overflow_y;
236 // Figma-style resize CONSTRAINTS, normalized to a small token set and mapped
237 // onto flex/position at codegen (margin:auto / flex-grow / align-self), never
238 // a new layout primitive. Horizontal: left | right | center | scale |
239 // stretch (pin both edges). Vertical: top | bottom | center | scale |
240 // stretch. Empty = unconstrained (the flex default, anchored start).
241 std::optional<std::string> h_constraint;
242 std::optional<std::string> v_constraint;
243 // CSS Grid. Pulp's engine has a native grid layout (LayoutMode::grid via the
244 // createGrid/setGrid bridge); design-import lowers a grid container here
245 // instead of flattening it to flex. Container tracks are raw CSS track lists
246 // ("1fr 1fr", "100px auto"); auto_flow is "row"/"column"(+ " dense").
247 // grid_column/grid_row are per-item placements ("1 / 3", "2"); span/named
248 // lines are deferred (left to the flex fallback). display=="grid" OR a
249 // template present is the grid signal.
250 std::optional<std::string> grid_template_columns;
251 std::optional<std::string> grid_template_rows;
252 std::optional<std::string> grid_auto_flow;
253 std::optional<std::string> grid_column; // item placement (column line/span)
254 std::optional<std::string> grid_row; // item placement (row line/span)
255};
256
258enum class AudioWidgetType {
259 none, // Not an audio widget
266 // An on/off. It is a member of THIS enum rather than a node type because
267 // this enum is what both consumers of a lowered control key off: the native
268 // materializer reaches its widget kind through kind_from_audio(), and the
269 // script emitter reaches its factory and its parameter binding through
270 // widget_type_name(). A toggle expressed any other way binds on one path
271 // and renders inert on the other.
273 // A choice between named alternatives, drawn as ONE control: a shared
274 // track with N labelled segments and exactly one lit. Not N adjacent
275 // toggles — a row of independent switches can show two lit at once and
276 // reads as several controls that happen to touch.
278 // A count the player reads as a number — voices, octaves, retrigger. A
279 // knob can carry one, and reads badly doing it: the value that matters is
280 // the integer, and a dial asks the eye to infer it from an angle.
282};
283
292inline float selector_segment_value(int index, int count) {
293 if (count <= 1) return 0.0f;
294 const int clamped = index < 0 ? 0 : (index >= count ? count - 1 : index);
295 return static_cast<float>(clamped) / static_cast<float>(count - 1);
296}
297
303inline float stepper_normalized_value(double plain, double min, double max) {
304 if (max <= min) return 0.0f;
305 const double span = max - min;
306 const double clamped = plain < min ? min : (plain > max ? max : plain);
307 return static_cast<float>((clamped - min) / span);
308}
309
310inline double stepper_plain_value(float normalized, double min, double max,
311 double step) {
312 if (max <= min) return min;
313 const double raw = min + static_cast<double>(normalized) * (max - min);
314 if (step <= 0.0) return raw;
315 // Snap to the step GRID measured from `min`, so a range that does not start
316 // at zero still lands on the values the author declared.
317 const double snapped = min + std::round((raw - min) / step) * step;
318 return snapped < min ? min : (snapped > max ? max : snapped);
319}
320
321inline int selector_segment_index(float value, int count) {
322 if (count <= 1) return 0;
323 if (!std::isfinite(value)) return 0;
324 const float scaled = value * static_cast<float>(count - 1);
325 const int nearest = static_cast<int>(scaled + 0.5f);
326 return nearest < 0 ? 0 : (nearest >= count ? count - 1 : nearest);
327}
328
331inline bool toggle_on_from_normalized(double value) {
332 return std::isfinite(value) && value >= 0.5;
333}
334
335struct IRNode;
336
345
346// ── Additive identity fields on IRNode ────────────────────────────────────
347// The TS-side @pulp/import-ir package already defines the canonical shape.
348// These fields are deliberately additive; IRStyle/IRLayout migration to
349// TS-style paint/text/layout is tracked separately.
350//
351// stable_anchor_id is the key the tweaks layer (pulp-tweaks.json) uses to
352// match user edits back to nodes across re-imports. Computed by the
353// anchor strategies in <pulp/view/anchor_strategy.hpp> (mirror of
354// packages/pulp-import-ir/src/anchors.ts).
355//
356// provenance + confidence let the inspector (and downstream tooling) know
357// where a node came from and how confident the adapter was — critical
358// for surfacing "this was sampled from an image, not a literal" in the
359// future Lock-to-source UI.
360
364enum class IRConfidence {
365 pass, // Adapter fully understood the source node
366 diverge, // Adapter produced something close-but-not-equivalent
367 not_impl // Adapter does not know how to lower this node yet
368};
369
372 std::string adapter; // e.g. "figma", "stitch-html", "claude-design-html"
373 std::string version; // adapter version string ("1.0.0" or schema rev)
374 std::string source_uri; // source identifier (file path, URL, MCP handle)
375};
376
398 float left = 0.0f;
399 float top = 0.0f;
400 float width = 0.0f;
401 float height = 0.0f;
402 int start = 0;
403 int length = 0;
404};
405
415 float width = 0.0f;
419 std::string resolved_face;
422 std::optional<LineMetrics> line_metrics;
423};
424
425struct IRTextRun {
426 int start = 0;
427 int end = 0;
428 std::optional<float> font_size;
429 std::optional<int> font_weight;
430 std::optional<std::string> font_family;
431 std::optional<std::string> font_style; // "italic" / "oblique ..." / "normal"
432 std::optional<std::string> color;
433 std::optional<float> letter_spacing;
434 std::optional<std::string> text_decoration; // "underline" / "line-through"
435};
436
438// ── Faithful-vector import (Plan B) ──────────────────────────────────────────
439// How a node should be rendered. `normal` is the existing widget/sprite
440// materialization. `faithful_svg` means: render this node's own SVG export
441// (svg_asset_id) pixel-faithfully via DesignFrameView, and overlay native
442// interaction from `interactive_elements` (source-side semantics — NOT guessed
443// from the SVG). `faithful_capture` is the browser-evaluated HTML lane: render
444// the captured raster named by capture_asset_id while separately carrying the
445// browser's evidence-ranked semantic report. Keeping it distinct from a normal
446// image makes the fidelity/interaction boundary explicit and prevents a
447// screenshot-backed import from masquerading as a fully-native reconstruction.
448// Per-node so faithful-vector, browser-capture, and native nodes can coexist.
454
455// The kind of an interactive overlay on a faithful_svg node. Deliberately
456// separate from AudioWidgetType (which is audio-parameter specific); this models
457// design-interaction semantics.
458//
459// Two materialization mechanisms (see DesignFrameView):
460// - `knob` is SVG-PATCH: its needle path is rotated in the SVG and re-rendered
461// (pixel-perfect, uses cx/cy/hit_radius/svg_patch_d/default_value).
462// - `fader` is SVG-PATCH like `knob` but TRANSLATES its thumb (svg_patch_d) by
463// value along the track box [x,y,w,h] (orientation follows the track shape).
464// - `toggle` is a click-to-flip control over the box [x,y,w,h]; with
465// svg_patch_d set it is a SWITCH whose moving dot is that path.
466// - `dropdown` / `text_field` / `tab_group` / `stepper` are NATIVE-OVERLAY: an
467// opaque child widget (ComboBox / TextEditor / tab group / < > stepper) is
468// positioned over the element's `rect` and replaces that baked SVG region
469// with a live control.
470// Every value here maps 1:1 to a DesignFrameElement::Kind in to_frame_elements()
471// (design_import_native_common.cpp); the runtime already backs all of them.
479 // A `< >` stepper: a header value cycled by prev/next chevrons (the design's
480 // section-header preset selectors — named "Dropdown" but carrying a `< >`
481 // pair, not a down-chevron). Uses `options` + `selected_index` like a
482 // dropdown, but steps through them in place instead of opening a popup.
484 // `swap` is a swap-link button: clicking its rect activates `target_frame`
485 // (a mode/page switch the design wires up).
487 // `action` is a command button: clicking its rect fires the named `action`
488 // (e.g. "octave_up") — the consumer maps the id to its own state. It does not
489 // light, emit notes, or swap frames.
491 // `xy_pad` is SVG-patch like `fader` but 2D: dragging in its rect [x,y,w,h]
492 // moves the puck (svg_patch_d). `default_value` is the X (0→left, 1→right),
493 // `default_value_y` the Y (0→top, 1→bottom).
495 // `value_label` is a live read-only text overlay painted over its rect (the
496 // design's baked readout). `text` is the initial string; `value_left_align`
497 // left-aligns it (for a "LABEL <value>" readout that grows rightward).
499 // `custom` is a registered native control: the materializer maps
500 // it to DesignFrameElement::Kind::custom, whose overlay is built by the
501 // factory registered under `factory_id` (+ opaque `custom_props`). Unmapped
502 // factory → inert render + an import diagnostic (never a silent knob).
504};
505
506// One source-identified interactive element overlaid on a faithful_svg render.
507// Coordinates are in the SVG's own space. The importer fills this from the
508// source (Figma node ids/names/properties), so behavior is real, not inferred.
511
512 // ── knob (SVG-patch) ────────────────────────────────────────────────
513 float cx = 0.0f;
514 float cy = 0.0f;
515 float hit_radius = 0.0f;
518 std::string svg_patch_d;
519 float default_value = 0.5f;
520
524 bool flash = false;
525
526 // ── overlay controls (dropdown / text_field / tab_group) ─────────────
529 float x = 0.0f;
530 float y = 0.0f;
531 float w = 0.0f;
532 float h = 0.0f;
535 std::vector<std::string> options;
539 std::string placeholder;
543 std::string bg_color;
544
545 // ── swap / action / xy_pad / value_label ─────────────────────────────
548 int target_frame = -1;
551 std::string action;
554 std::string text;
557 bool value_left_align = false;
560 float default_value_y = 0.5f;
561
567 std::string label;
568
578 std::string param_key;
579
580 // ── Import report (resolution provenance) ────────────────────────────
581 // Carried from the importer (where all three signals — geometry/affordance,
582 // name/token, component identity — exist) THROUGH to the host materialize
583 // boundary, so a low-confidence or conflicted control is SEEN ("this might be
584 // wrong") instead of discovered in the DAW. The resolution LOGIC that fills
585 // these lives in the importer; this struct carries it to materialization.
592 float confidence_score = 1.0f;
596 std::vector<std::string> conflict_signals;
599 bool verification_pass = true;
600
601 // ── custom (registered control) ──────────────────────────────────────
604 std::string factory_id;
607 std::string custom_props;
608
611 std::optional<std::string> source_node_id;
612};
613
614struct IRNode {
615 std::string type; // "frame", "text", "image", "button", "input", "slider"
616 std::string name;
617 std::string text_content; // For text nodes
618 std::vector<IRTextRun> text_runs; // Per-range style overrides (mixed text)
621 std::vector<IRTextLineBox> text_line_boxes;
624 std::optional<IRTextLayoutBasis> text_layout_basis;
628 std::string audio_label; // Label for audio widgets (e.g. "Gain")
629 float audio_min = 0.0f;
630 float audio_max = 1.0f;
631 float audio_default = 0.5f;
632 // True when the source explicitly carried a min/max range (vs the 0..1
633 // defaults). Lets the codegen reconstruct the value/range display stack only
634 // for widgets that actually declared a range.
635 bool has_audio_range = false;
636 std::vector<IRNode> children;
637 std::unordered_map<std::string, std::string> attributes; // Extra metadata
638
639 // ── Additive identity fields ─────────────────────────────────────────
642 std::optional<std::string> stable_anchor_id;
645 std::optional<std::string> anchor_strategy;
648 std::optional<std::string> source_node_id;
651 std::optional<std::string> source_adapter;
652 std::optional<std::string> source_version;
654 std::optional<IRProvenance> provenance;
656 std::optional<IRConfidence> confidence;
659 std::optional<std::string> raw_source;
660
661 // ── Faithful-vector import ───────────────────────────────────────────
669 std::optional<std::string> svg_asset_id;
673 std::optional<std::string> capture_asset_id;
676 std::vector<IRInteractiveElement> interactive_elements;
691 std::vector<IRNode> alternate_frames;
692};
693
699
713
723
725 std::string asset_id; // stable handle used by nodes
726 std::string original_uri; // as authored
727 std::vector<std::string> original_uri_aliases; // equivalent authored refs
728 std::optional<std::string> local_path;
729 std::string content_hash; // sha256 of resolved bytes; empty if unresolved
730 std::string mime;
731 std::optional<int> width;
732 std::optional<int> height;
733 std::optional<std::string> font_family;
734 std::optional<std::string> license;
735 std::optional<std::string> source_url;
736 std::vector<ImportDiagnostic> diagnostics;
737};
738
740 std::vector<IRAssetRef> assets;
741 int version = 1;
742
743 const IRAssetRef* resolve(std::string_view asset_id) const {
744 if (asset_id.empty())
745 return nullptr;
746 for (const auto& asset : assets) {
747 if (asset.asset_id == asset_id)
748 return &asset;
749 }
750 return nullptr;
751 }
752};
753
764 std::string family; // CSS family name nodes reference via font_family
765 std::string style; // "Regular", "Italic", … (informational)
766 int weight = 400; // 100–900; the lower bound of a weight range
767 std::string asset_id; // → asset_manifest entry holding the .ttf/.otf/.woff2
768 std::string resolved_path; // absolute fs path, stamped by the CLI asset-resolution pass
769 std::string font_style; // CSS font-style descriptor; empty when not captured
770 int weight_max = 0; // upper bound of a font-weight range; 0 for one weight
771 std::string unicode_range; // CSS unicode-range descriptor, verbatim; empty = every code point
772};
773
775 std::string source_id;
776 std::string source_collection;
777 std::string source_mode;
778 std::string source_adapter;
779};
780
782struct IRTokens {
783 std::unordered_map<std::string, std::string> colors; // name → "#hex"
784 std::unordered_map<std::string, float> dimensions; // name → px value
785 std::unordered_map<std::string, std::string> strings; // name → string
786 // Keyed by canonical token path (for example "colors.primary").
787 std::unordered_map<std::string, IRTokenIdentity> source_identity;
788};
789
791struct DesignIR {
792 int version = 1;
796 std::vector<IRFontAsset> font_family_assets; // bundled fonts (#43a/#43b)
797 std::vector<ImportDiagnostic> diagnostics;
799 std::string source_file;
800 std::string capture_method;
802 std::string fallback_reason;
803 std::string source_adapter;
804 std::string source_version;
805 std::string imported_at;
806};
807
809 int version = 0; // 0 preserves DesignIR::version
810 bool include_tokens = true;
813};
814
818 std::filesystem::path cache_directory;
819 std::filesystem::path base_directory;
820 std::string base_url;
821 std::unordered_map<std::string, std::string> expected_hash_by_uri;
822};
823
824} // namespace pulp::view
Hover-cursor tracking for platform window hosts.
Definition fwd.hpp:27
NodeRenderMode
A single node in the normalized design IR.
Definition design_ir.hpp:449
@ faithful_capture
Definition design_ir.hpp:452
@ faithful_svg
Definition design_ir.hpp:451
@ normal
Definition design_ir.hpp:450
@ none
Definition appearance_defects.hpp:53
IRConfidence
Confidence the adapter has that a node was lowered correctly.
Definition design_ir.hpp:364
@ pass
Definition design_ir.hpp:365
@ diverge
Definition design_ir.hpp:366
@ not_impl
Definition design_ir.hpp:367
bool toggle_on_from_normalized(double value)
The single threshold used by every toggle import/binding path.
Definition design_ir.hpp:331
AudioWidgetType
Audio widget type detected from naming conventions or annotations.
Definition design_ir.hpp:258
@ fader
Definition design_ir.hpp:261
@ none
Definition design_ir.hpp:259
@ toggle
Definition design_ir.hpp:272
@ selector
Definition design_ir.hpp:277
@ stepper
Definition design_ir.hpp:281
@ spectrum
Definition design_ir.hpp:265
@ waveform
Definition design_ir.hpp:264
@ knob
Definition design_ir.hpp:260
@ xy_pad
Definition design_ir.hpp:263
double stepper_plain_value(float normalized, double min, double max, double step)
Definition design_ir.hpp:310
DesignSource
Definition design_ir.hpp:37
@ jsx
Definition design_ir.hpp:44
@ figma_plugin
Definition design_ir.hpp:45
@ figma
Definition design_ir.hpp:38
@ claude
Definition design_ir.hpp:42
@ v0
Definition design_ir.hpp:40
@ stitch
Definition design_ir.hpp:39
@ pencil
Definition design_ir.hpp:41
@ designmd
Definition design_ir.hpp:43
@ preconverted_svg
Definition design_ir.hpp:47
@ html
Definition design_ir.hpp:46
@ value
the widget's primary value (Knob, Fader, RangeSlider, Toggle, ProgressBar)
Definition binding_diagnostics.hpp:19
@ meter
a Meter's level
Definition binding_diagnostics.hpp:20
float stepper_normalized_value(double plain, double min, double max)
A stepper's plain value (voices, octaves) against the normalized parameter behind it.
Definition design_ir.hpp:303
LayoutDirection
Layout direction for flex containers.
Definition design_ir.hpp:53
@ column
Definition design_ir.hpp:53
@ row
Definition design_ir.hpp:53
ImportDiagnosticKind
Definition design_ir.hpp:700
@ snapshot_semantics_warning
Definition design_ir.hpp:708
@ legacy_field_shortcut
Definition design_ir.hpp:709
@ unresolved_asset
Definition design_ir.hpp:707
@ capture_partial
Definition design_ir.hpp:710
@ unknown
Definition design_ir.hpp:701
@ unsupported_property
Definition design_ir.hpp:702
@ unsupported_node
A whole node family the producer could not represent — skipped (SLICE, FigJam/Slides families) or emi...
Definition design_ir.hpp:706
@ fallback_used
Definition design_ir.hpp:711
SizingMode
Sizing mode for an IR node dimension.
Definition design_ir.hpp:61
@ fill
Definition design_ir.hpp:61
@ hug
Definition design_ir.hpp:61
@ fixed
Definition design_ir.hpp:61
InteractiveElementKind
Definition design_ir.hpp:472
@ action
Definition design_ir.hpp:490
@ custom
Definition design_ir.hpp:503
@ dropdown
Definition design_ir.hpp:476
@ knob
Definition design_ir.hpp:473
@ text_field
Definition design_ir.hpp:477
@ value_label
Definition design_ir.hpp:498
@ swap
Definition design_ir.hpp:486
@ tab_group
Definition design_ir.hpp:478
int selector_segment_index(float value, int count)
Definition design_ir.hpp:321
WidgetPromotionSignal
Heuristic signals that a parsed frame is interactive enough to promote from a static frame to a butto...
Definition design_ir.hpp:339
@ aria_role_button
Definition design_ir.hpp:342
@ cursor_pointer
Definition design_ir.hpp:343
@ onclick_attribute
Definition design_ir.hpp:341
LayoutAlign
Alignment values for flex containers.
Definition design_ir.hpp:56
@ flex_start
Definition design_ir.hpp:57
@ flex_end
Definition design_ir.hpp:57
@ stretch
Definition design_ir.hpp:57
@ space_around
Definition design_ir.hpp:57
@ center
Definition design_ir.hpp:57
@ space_between
Definition design_ir.hpp:57
float selector_segment_value(int index, int count)
The value a segmented selector writes for segment index of count, and the segment a parameter value s...
Definition design_ir.hpp:292
ImportDiagnosticSeverity
Definition design_ir.hpp:694
@ warning
Definition design_ir.hpp:696
@ info
Definition design_ir.hpp:695
@ error
Definition design_ir.hpp:697
Complete design IR document.
Definition design_ir.hpp:791
std::string source_file
Definition design_ir.hpp:799
int version
Definition design_ir.hpp:792
std::string fallback_reason
Definition design_ir.hpp:802
std::string source_adapter
Definition design_ir.hpp:803
IRNode root
Definition design_ir.hpp:793
DesignSource source
Definition design_ir.hpp:798
IRTokens tokens
Definition design_ir.hpp:794
std::string imported_at
Definition design_ir.hpp:805
IRAssetManifest asset_manifest
Definition design_ir.hpp:795
std::string capture_method
Definition design_ir.hpp:800
std::string source_version
Definition design_ir.hpp:804
std::vector< IRFontAsset > font_family_assets
Definition design_ir.hpp:796
std::vector< ImportDiagnostic > diagnostics
Definition design_ir.hpp:797
int settle_rounds
Definition design_ir.hpp:801
Definition design_ir.hpp:815
std::filesystem::path base_directory
Definition design_ir.hpp:819
std::unordered_map< std::string, std::string > expected_hash_by_uri
Definition design_ir.hpp:821
int network_timeout_ms
Definition design_ir.hpp:817
std::string base_url
Definition design_ir.hpp:820
std::filesystem::path cache_directory
Definition design_ir.hpp:818
bool allow_network_fetch
Definition design_ir.hpp:816
Definition design_ir.hpp:808
bool include_source_metadata
Definition design_ir.hpp:811
int version
Definition design_ir.hpp:809
bool include_asset_manifest
Definition design_ir.hpp:812
bool include_tokens
Definition design_ir.hpp:810
Definition design_ir.hpp:739
std::vector< IRAssetRef > assets
Definition design_ir.hpp:740
const IRAssetRef * resolve(std::string_view asset_id) const
Definition design_ir.hpp:743
int version
Definition design_ir.hpp:741
Definition design_ir.hpp:724
std::string asset_id
Definition design_ir.hpp:725
std::optional< std::string > license
Definition design_ir.hpp:734
std::optional< int > width
Definition design_ir.hpp:731
std::optional< std::string > font_family
Definition design_ir.hpp:733
std::vector< std::string > original_uri_aliases
Definition design_ir.hpp:727
std::vector< ImportDiagnostic > diagnostics
Definition design_ir.hpp:736
std::string mime
Definition design_ir.hpp:730
std::string content_hash
Definition design_ir.hpp:729
std::string original_uri
Definition design_ir.hpp:726
std::optional< int > height
Definition design_ir.hpp:732
std::optional< std::string > local_path
Definition design_ir.hpp:728
std::optional< std::string > source_url
Definition design_ir.hpp:735
A single CSS box-shadow layer.
Definition design_ir.hpp:68
float spread
Definition design_ir.hpp:72
std::string raw
original layer text, for lossless round-trip
Definition design_ir.hpp:75
std::string color
raw CSS color token ("#rrggbbaa" or "rgba(...)")
Definition design_ir.hpp:73
bool inset
Definition design_ir.hpp:74
float offset_y
Definition design_ir.hpp:70
float offset_x
Definition design_ir.hpp:69
float blur
Definition design_ir.hpp:71
A bundled (non-system) font shipped with the design (figma-plugin #43a: envelope font_family_assets[]...
Definition design_ir.hpp:763
std::string unicode_range
Definition design_ir.hpp:771
std::string family
Definition design_ir.hpp:764
int weight_max
Definition design_ir.hpp:770
std::string style
Definition design_ir.hpp:765
std::string font_style
Definition design_ir.hpp:769
std::string resolved_path
Definition design_ir.hpp:768
std::string asset_id
Definition design_ir.hpp:767
int weight
Definition design_ir.hpp:766
Definition design_ir.hpp:509
int target_frame
swap only: the frame index to activate when clicked (-1 = unset).
Definition design_ir.hpp:548
std::string label
Human-readable name for the control, taken from the design's own caption text (e.g.
Definition design_ir.hpp:567
float h
Definition design_ir.hpp:532
InteractiveElementKind kind
Definition design_ir.hpp:510
float hit_radius
click-target radius, SVG coords
Definition design_ir.hpp:515
float cy
Definition design_ir.hpp:514
bool verification_pass
Whether render-level verification (overlay covers its node region, type doesn't visually contradict t...
Definition design_ir.hpp:599
bool flash
toggle only: press-flash command button (sample next/prev/random, dice) — lights on press,...
Definition design_ir.hpp:524
float w
Definition design_ir.hpp:531
std::string factory_id
kind==custom only: the id the native overlay factory is registered under (register_design_control_fac...
Definition design_ir.hpp:604
float cx
pivot / hit center, SVG coords
Definition design_ir.hpp:513
float confidence_score
Confidence the resolved kind is correct, 0..1. 1.0 = unset/legacy path.
Definition design_ir.hpp:592
int selected_index
dropdown / tab_group: which option/tab is selected initially.
Definition design_ir.hpp:537
float default_value_y
xy_pad only: initial normalized Y (0=top, 1=bottom).
Definition design_ir.hpp:560
std::string param_key
Host-parameter binding key for this control, e.g.
Definition design_ir.hpp:578
std::string svg_patch_d
Knob: the d of its needle path in the SVG (the patch target a drag rotates around (cx,...
Definition design_ir.hpp:518
std::string bg_color
text_field: the design's own field background ("#RRGGBB"), so the overlay matches it exactly and the ...
Definition design_ir.hpp:543
std::optional< std::string > source_node_id
Figma node id — provenance for the inspector's Wiring lens (maps a live control back to its source no...
Definition design_ir.hpp:611
float default_value
0..1
Definition design_ir.hpp:519
std::vector< std::string > options
dropdown: the selectable options.
Definition design_ir.hpp:535
std::string custom_props
kind==custom only: opaque props handed to the factory (typically JSON).
Definition design_ir.hpp:607
std::string text
value_label only: the initial readout string painted over the rect.
Definition design_ir.hpp:554
std::string action
action only: the command id fired on click (e.g.
Definition design_ir.hpp:551
bool value_left_align
value_label only: left-align the readout (for a "LABEL <value>" overlay whose value grows rightward).
Definition design_ir.hpp:557
std::string placeholder
text_field: placeholder text shown until focused/typed.
Definition design_ir.hpp:539
std::vector< std::string > conflict_signals
Cross-signal conflicts detected at import (e.g.
Definition design_ir.hpp:596
int resolution_rung
Which ladder rung resolved this control's interaction.
Definition design_ir.hpp:590
float x
Element bounding box in SVG coords — where the native overlay widget is positioned (via DesignFrameVi...
Definition design_ir.hpp:529
float y
Definition design_ir.hpp:530
Layout properties for an IR container node.
Definition design_ir.hpp:208
std::optional< std::string > overflow_x
Definition design_ir.hpp:232
std::optional< std::string > grid_auto_flow
Definition design_ir.hpp:252
float padding_top
Definition design_ir.hpp:214
std::optional< float > flex_shrink
Definition design_ir.hpp:228
std::optional< std::string > grid_template_rows
Definition design_ir.hpp:251
LayoutAlign align
Definition design_ir.hpp:223
std::optional< std::string > grid_row
Definition design_ir.hpp:254
std::optional< std::string > overflow_y
Definition design_ir.hpp:233
std::optional< float > aspect_ratio
Definition design_ir.hpp:231
float gap
Definition design_ir.hpp:211
std::optional< std::string > align_self
Definition design_ir.hpp:224
std::optional< float > flex_grow
Definition design_ir.hpp:227
std::optional< std::string > flex_basis
Definition design_ir.hpp:229
std::optional< std::string > grid_template_columns
Definition design_ir.hpp:250
std::optional< float > margin_right
Definition design_ir.hpp:219
std::optional< std::string > v_constraint
Definition design_ir.hpp:242
LayoutAlign justify
Definition design_ir.hpp:222
std::optional< int > order
Definition design_ir.hpp:230
float padding_bottom
Definition design_ir.hpp:216
std::optional< float > column_gap
Definition design_ir.hpp:213
std::optional< std::string > align_content
Definition design_ir.hpp:225
float padding_right
Definition design_ir.hpp:215
float padding_left
Definition design_ir.hpp:217
LayoutDirection direction
Definition design_ir.hpp:210
std::optional< std::string > h_constraint
Definition design_ir.hpp:241
SizingMode height_mode
Definition design_ir.hpp:235
bool wrap
Definition design_ir.hpp:226
std::optional< float > margin_left
Definition design_ir.hpp:221
std::optional< float > row_gap
Definition design_ir.hpp:212
std::optional< float > margin_bottom
Definition design_ir.hpp:220
SizingMode width_mode
Definition design_ir.hpp:234
std::optional< std::string > display
Definition design_ir.hpp:209
std::optional< float > margin_top
Definition design_ir.hpp:218
std::optional< std::string > grid_column
Definition design_ir.hpp:253
Definition design_ir.hpp:614
float audio_default
Definition design_ir.hpp:631
std::optional< std::string > stable_anchor_id
Stable anchor for the tweaks layer.
Definition design_ir.hpp:642
std::optional< std::string > source_version
Definition design_ir.hpp:652
std::string name
Definition design_ir.hpp:616
std::optional< std::string > capture_asset_id
Asset id (into IRAssetManifest) of the browser screenshot backing when render_mode == faithful_captur...
Definition design_ir.hpp:673
std::string text_content
Definition design_ir.hpp:617
std::optional< IRConfidence > confidence
Adapter's confidence in this node's lowering.
Definition design_ir.hpp:656
std::unordered_map< std::string, std::string > attributes
Definition design_ir.hpp:637
std::string type
Definition design_ir.hpp:615
std::optional< std::string > svg_asset_id
Asset id (into IRAssetManifest) of this node's SVG export, when render_mode == faithful_svg.
Definition design_ir.hpp:669
std::optional< std::string > raw_source
Verbatim source slice for this node (debugging + AST-patch fallback).
Definition design_ir.hpp:659
float audio_min
Definition design_ir.hpp:629
std::optional< IRTextLayoutBasis > text_layout_basis
The conditions text_line_boxes was captured under.
Definition design_ir.hpp:624
IRLayout layout
Definition design_ir.hpp:626
IRStyle style
Definition design_ir.hpp:625
NodeRenderMode render_mode
How this node materializes.
Definition design_ir.hpp:666
std::vector< IRTextRun > text_runs
Definition design_ir.hpp:618
std::string audio_label
Definition design_ir.hpp:628
bool has_audio_range
Definition design_ir.hpp:635
float audio_max
Definition design_ir.hpp:630
std::vector< IRTextLineBox > text_line_boxes
Chrome's own line breaking for text_content, cached.
Definition design_ir.hpp:621
std::vector< IRInteractiveElement > interactive_elements
Source-identified interactive overlays for a faithful_svg render.
Definition design_ir.hpp:676
std::optional< std::string > source_node_id
Source-side native ID (e.g.
Definition design_ir.hpp:648
AudioWidgetType audio_widget
Definition design_ir.hpp:627
std::optional< IRProvenance > provenance
Adapter provenance — typically set on the root node by each parser.
Definition design_ir.hpp:654
std::optional< std::string > anchor_strategy
Strategy used to produce stable_anchor_id: "adapter", "content-hash", or "path".
Definition design_ir.hpp:645
std::optional< std::string > source_adapter
Canonical adapter provenance fields.
Definition design_ir.hpp:651
std::vector< IRNode > children
Definition design_ir.hpp:636
std::vector< IRNode > alternate_frames
Alternate states of a faithful_svg node (multi-state capture).
Definition design_ir.hpp:691
Adapter-side provenance: who lowered this node, from what source.
Definition design_ir.hpp:371
std::string source_uri
Definition design_ir.hpp:374
std::string version
Definition design_ir.hpp:373
std::string adapter
Definition design_ir.hpp:372
Definition design_ir.hpp:154
float height
Definition design_ir.hpp:155
float radius_br
Definition design_ir.hpp:156
float radius_tr
Definition design_ir.hpp:156
float radius_tl
Definition design_ir.hpp:156
float x
Definition design_ir.hpp:155
float y
Definition design_ir.hpp:155
float width
Definition design_ir.hpp:155
float radius_bl
Definition design_ir.hpp:156
Definition design_ir.hpp:203
float w
Definition design_ir.hpp:203
float dx
Definition design_ir.hpp:203
float h
Definition design_ir.hpp:203
float dy
Definition design_ir.hpp:203
Style properties for an IR node.
Definition design_ir.hpp:79
std::vector< IRBoxShadow > box_shadow
Definition design_ir.hpp:126
std::optional< float > height
Definition design_ir.hpp:194
std::optional< float > border_right_width
Definition design_ir.hpp:119
std::optional< std::string > background_color
Definition design_ir.hpp:80
std::optional< std::string > background_size
Definition design_ir.hpp:91
std::optional< std::string > background_gradient
Definition design_ir.hpp:81
std::optional< float > border_top_width
Definition design_ir.hpp:118
std::optional< std::string > mask
Definition design_ir.hpp:159
std::optional< float > border_bottom_width
Definition design_ir.hpp:120
std::optional< float > border_bottom_left_radius
Definition design_ir.hpp:125
std::optional< std::string > backdrop_filter
Definition design_ir.hpp:128
std::optional< RenderBounds > render_bounds
Definition design_ir.hpp:204
std::optional< float > opacity
Definition design_ir.hpp:104
std::optional< std::string > mix_blend_mode
Definition design_ir.hpp:108
std::optional< float > border_left_width
Definition design_ir.hpp:121
std::optional< float > line_height
Definition design_ir.hpp:173
std::optional< float > left
Definition design_ir.hpp:191
std::optional< float > bottom
Definition design_ir.hpp:191
std::optional< int > z_index
Definition design_ir.hpp:192
std::optional< std::string > text_transform
Definition design_ir.hpp:174
std::optional< float > border_bottom_right_radius
Definition design_ir.hpp:124
std::optional< float > min_width
Definition design_ir.hpp:195
std::optional< std::string > background_repeat
Definition design_ir.hpp:83
std::optional< std::string > filter
Definition design_ir.hpp:127
std::optional< float > top
Definition design_ir.hpp:191
std::optional< float > right
Definition design_ir.hpp:191
std::optional< float > max_width
Definition design_ir.hpp:196
std::optional< std::string > cursor
Definition design_ir.hpp:179
std::optional< std::string > background_image
Definition design_ir.hpp:82
std::optional< std::string > pointer_events
CSS pointer-events.
Definition design_ir.hpp:189
std::optional< std::string > text_decoration
Definition design_ir.hpp:175
std::optional< std::string > border_color
Definition design_ir.hpp:111
std::optional< std::string > object_fit
Definition design_ir.hpp:102
std::optional< std::string > border_right_color
Definition design_ir.hpp:115
std::optional< std::string > overflow
Definition design_ir.hpp:178
std::optional< std::string > transform
Definition design_ir.hpp:193
std::optional< std::string > clip_path
Definition design_ir.hpp:133
std::optional< float > border_top_right_radius
Definition design_ir.hpp:123
std::optional< std::string > color
Definition design_ir.hpp:103
std::optional< float > border_width
Definition design_ir.hpp:112
std::optional< std::string > border_left_color
Definition design_ir.hpp:117
std::optional< std::string > position
Definition design_ir.hpp:190
std::optional< std::string > background_position
Definition design_ir.hpp:84
std::optional< std::string > border_style
Definition design_ir.hpp:113
std::optional< float > border_top_left_radius
Definition design_ir.hpp:122
std::optional< std::string > border_bottom_color
Definition design_ir.hpp:116
std::optional< float > letter_spacing
Definition design_ir.hpp:172
std::optional< float > min_height
Definition design_ir.hpp:195
std::optional< ClipRect > clip_rect
Definition design_ir.hpp:158
std::optional< std::string > white_space
Definition design_ir.hpp:176
std::optional< std::string > text_align
Definition design_ir.hpp:166
std::optional< std::string > text_overflow
Definition design_ir.hpp:177
std::optional< float > width
Definition design_ir.hpp:194
std::optional< std::string > mask_size
Definition design_ir.hpp:161
std::optional< float > max_height
Definition design_ir.hpp:196
std::optional< std::string > vertical_align
Definition design_ir.hpp:171
std::optional< float > border_radius
Definition design_ir.hpp:109
std::optional< std::string > border_top_color
Definition design_ir.hpp:114
std::optional< int > font_weight
Definition design_ir.hpp:164
std::optional< std::string > font_family
Definition design_ir.hpp:162
std::optional< std::string > mask_image
Definition design_ir.hpp:160
std::optional< std::string > border
Definition design_ir.hpp:110
std::optional< float > font_size
Definition design_ir.hpp:163
std::optional< std::string > font_style
Definition design_ir.hpp:165
std::optional< std::string > background_origin
Definition design_ir.hpp:96
What the cached line boxes above were laid out AGAINST.
Definition design_ir.hpp:413
std::string resolved_face
The face Blink actually shaped with — a PostScript name, not the requested family.
Definition design_ir.hpp:419
std::optional< LineMetrics > line_metrics
The primary font's line metrics Chrome laid the lines out with, when the capture measured them (see d...
Definition design_ir.hpp:422
float width
The container width Chrome broke the text at.
Definition design_ir.hpp:415
One styled character range inside a text node.
Definition design_ir.hpp:397
float height
Definition design_ir.hpp:401
float top
Definition design_ir.hpp:399
int start
Definition design_ir.hpp:402
int length
Definition design_ir.hpp:403
float width
Definition design_ir.hpp:400
float left
Definition design_ir.hpp:398
Definition design_ir.hpp:425
std::optional< float > font_size
Definition design_ir.hpp:428
std::optional< float > letter_spacing
Definition design_ir.hpp:433
std::optional< std::string > font_family
Definition design_ir.hpp:430
int start
Definition design_ir.hpp:426
std::optional< std::string > font_style
Definition design_ir.hpp:431
int end
Definition design_ir.hpp:427
std::optional< std::string > color
Definition design_ir.hpp:432
std::optional< int > font_weight
Definition design_ir.hpp:429
std::optional< std::string > text_decoration
Definition design_ir.hpp:434
Definition design_ir.hpp:774
std::string source_id
Definition design_ir.hpp:775
std::string source_collection
Definition design_ir.hpp:776
std::string source_adapter
Definition design_ir.hpp:778
std::string source_mode
Definition design_ir.hpp:777
Design token collection (W3C-compatible).
Definition design_ir.hpp:782
std::unordered_map< std::string, float > dimensions
Definition design_ir.hpp:784
std::unordered_map< std::string, std::string > colors
Definition design_ir.hpp:783
std::unordered_map< std::string, IRTokenIdentity > source_identity
Definition design_ir.hpp:787
std::unordered_map< std::string, std::string > strings
Definition design_ir.hpp:785
Definition design_ir.hpp:714
std::string code
Definition design_ir.hpp:716
ImportDiagnosticSeverity severity
Definition design_ir.hpp:715
std::string path
Definition design_ir.hpp:717
std::string message
Definition design_ir.hpp:718
std::optional< std::string > anchor_id
Definition design_ir.hpp:720
std::optional< std::string > property
Definition design_ir.hpp:721
ImportDiagnosticKind kind
Definition design_ir.hpp:719