@wireweave/core 3.0.1-beta.0 → 3.1.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { A as AnyNode, a as AccordionNode, b as AlertNode, c as AvatarNode, B as BadgeNode, d as BreadcrumbNode, e as ButtonNode, C as CardNode, f as CheckboxNode, g as ColNode, h as ContainerComponentNode, i as ContainerNode, D as DataNode, j as DisplayNode, k as DividerComponentNode, l as DrawerNode, m as DropdownNode, F as FeedbackNode, n as FooterNode, G as GridNode, H as HeaderNode, I as IconNode, o as ImageNode, p as InputComponentNode, q as InputNode, L as LayoutNode, r as LeafNode, s as LinkNode, t as ListNode, M as MainNode, u as ModalNode, N as NavNode, v as NavigationNode, w as NodeType, O as OverlayNode, P as PageNode, x as PlaceholderNode, y as PopoverNode, z as ProgressNode, R as RadioNode, E as RowNode, S as SectionNode, J as SelectNode, K as SidebarNode, Q as SliderNode, T as SpinnerNode, U as SwitchNode, V as TableNode, W as TabsNode, X as TextContentNode, Y as TextNode, Z as TextareaNode, _ as TitleNode, $ as ToastNode, a0 as TooltipNode, a1 as WireframeDocument } from './types-hEr_afgw.js';
2
- export { a2 as AlertVariant, a3 as AlignValue, a4 as AnchorPosition, a5 as AnnotationItemNode, a6 as AnnotationNode, a7 as AnnotationsNode, a8 as AppearanceProps, a9 as AvatarSize, aa as AvatarSizeToken, ab as BadgeSize, ac as BadgeSizeToken, ad as BadgeVariant, ae as BaseNode, af as BreadcrumbItem, ag as ButtonSize, ah as ButtonSizeToken, ai as ButtonVariant, aj as CommonProps, ak as DirectionValue, al as DividerNode, am as DrawerPosition, an as DropdownItemNode, ao as FlexProps, ap as GridProps, aq as HeightValue, ar as IconSize, as as IconSizeToken, at as InputType, au as InteractiveProps, av as JustifyValue, aw as ListItemNode, ax as MarkerColor, ay as MarkerNode, az as NavBlockItem, aA as NavChild, aB as NavDivider, aC as NavGroupNode, aD as NavItem, aE as Position, aF as PositionProps, aG as RelativeNode, aH as SelectOption, aI as ShadowValue, aJ as SizeProps, aK as SourceLocation, aL as SpacingProps, aM as SpacingValue, aN as SpinnerSize, aO as SpinnerSizeToken, aP as StackNode, aQ as TabNode, aR as TextAlign, aS as TextSize, aT as TextSizeToken, aU as TextWeight, aV as TitleLevel, aW as ToastPosition, aX as TooltipPosition, aY as ValueWithUnit, aZ as WidthValue } from './types-hEr_afgw.js';
1
+ import { h as AnyNode, A as AccordionNode, a as AlertNode, j as AvatarNode, B as BadgeNode, r as BreadcrumbNode, s as ButtonNode, C as CardNode, w as CheckboxNode, x as ColNode, z as ContainerComponentNode, D as ContainerNode, E as DataNode, G as DisplayNode, H as DividerComponentNode, J as DrawerNode, M as DropdownNode, N as FeedbackNode, P as FooterNode, Q as GridNode, S as HeaderNode, U as IconNode, X as ImageNode, Y as InputComponentNode, Z as InputNode, a1 as LayoutNode, a2 as LeafNode, a3 as LinkNode, a5 as ListNode, a6 as MainNode, a9 as ModalNode, af as NavNode, ag as NavigationNode, ah as NodeType, ai as OverlayNode, aj as PageNode, ak as PlaceholderNode, al as PopoverNode, ao as ProgressNode, ap as RadioNode, ar as RowNode, as as SectionNode, at as SelectNode, aw as SidebarNode, ay as SliderNode, aC as SpinnerNode, aG as SwitchNode, aI as TableNode, aJ as TabsNode, aL as TextContentNode, aM as TextNode, aQ as TextareaNode, aS as TitleNode, aT as ToastNode, aV as TooltipNode, aZ as WireframeDocument, az as SourceLocation, _ as InputType } from './types-BDbXDhTp.js';
2
+ export { b as AlertVariant, c as AlignValue, d as AnchorPosition, e as AnnotationItemNode, f as AnnotationNode, g as AnnotationsNode, i as AppearanceProps, k as AvatarSize, l as AvatarSizeToken, m as BadgeSize, n as BadgeSizeToken, o as BadgeVariant, p as BaseNode, q as BreadcrumbItem, t as ButtonSize, u as ButtonSizeToken, v as ButtonVariant, y as CommonProps, F as DirectionValue, I as DividerNode, K as DrawerPosition, L as DropdownItemNode, O as FlexProps, R as GridProps, T as HeightValue, V as IconSize, W as IconSizeToken, $ as InteractiveProps, a0 as JustifyValue, a4 as ListItemNode, a7 as MarkerColor, a8 as MarkerNode, aa as NavBlockItem, ab as NavChild, ac as NavDivider, ad as NavGroupNode, ae as NavItem, am as Position, an as PositionProps, aq as RelativeNode, au as SelectOption, av as ShadowValue, ax as SizeProps, aA as SpacingProps, aB as SpacingValue, aD as SpinnerSize, aE as SpinnerSizeToken, aF as StackNode, aH as TabNode, aK as TextAlign, aN as TextSize, aO as TextSizeToken, aP as TextWeight, aR as TitleLevel, aU as ToastPosition, aW as TooltipPosition, aX as ValueWithUnit, aY as WidthValue } from './types-BDbXDhTp.js';
3
3
  export { ExpectedToken, ParseError, ParseErrorInfo, ParseOptions, ParseResult, getErrors, isValid, parse, tryParse } from './parser.js';
4
- export { CanvasOptions, CanvasRenderResult, HtmlRenderer, IconData, IconElement, PageRenderResult, PlacedPage, RenderContext, RenderOptions, RenderResult, SvgRenderOptions, SvgRenderResult, ThemeColors, ThemeConfig, createHtmlRenderer, darkTheme, defaultTheme, generateComponentStyles, generateStyles, getIconData, getTheme, layoutCanvas, lucideIcons, render, renderCanvas, renderIconSvg, renderPage, renderToHtml, renderToSvg, resolvePageDimensions } from './renderer.js';
4
+ export { CanvasOptions, CanvasRenderResult, HtmlRenderer, IconData, IconElement, PageRenderResult, PlacedPage, RenderContext, RenderOptions, RenderResult, SvgRenderOptions, SvgRenderResult, ThemeColors, ThemeConfig, createHtmlRenderer, darkTheme, defaultTheme, generateComponentStyles, generateStyles, getIconData, getTheme, layoutCanvas, lucideIcons, render, renderCanvas, renderIconSvg, renderPage, renderToHtml, renderToSvg, renderUnknownIconSvg, resolvePageDimensions } from './renderer.js';
5
5
 
6
6
  /**
7
7
  * Type guards for wireweave AST
@@ -176,6 +176,42 @@ declare function contains(node: AnyNode, target: AnyNode): boolean;
176
176
  */
177
177
  declare function getNodeTypes(node: AnyNode): Set<NodeType>;
178
178
 
179
+ /**
180
+ * Node/document-level canonical `.wf` printing.
181
+ *
182
+ * See `src/printer/index.ts` for the canonical-form rules and the documented
183
+ * non-round-trippable cases. Every branch here mirrors one element rule in
184
+ * `src/grammar/wireframe.peggy`; printed output is always valid parser input.
185
+ */
186
+
187
+ /**
188
+ * Print a parsed {@link WireframeDocument} to canonical `.wf` DSL text.
189
+ *
190
+ * The output is deterministic (a pure function of the AST structure), is
191
+ * always valid `parse` input, and satisfies the round-trip laws documented in
192
+ * `src/printer/index.ts`. An empty document prints as an empty string;
193
+ * otherwise the text ends with exactly one trailing newline.
194
+ *
195
+ * @public
196
+ * @example
197
+ * ```ts
198
+ * const doc = parse('page "Login" { button "Sign in" primary }')
199
+ * const canonical = printWireframe(doc)
200
+ * // 'page "Login" {\n button "Sign in" primary\n}\n'
201
+ * ```
202
+ */
203
+ declare function printWireframe(doc: WireframeDocument): string;
204
+ /**
205
+ * Parse `.wf` source and reprint it in canonical form.
206
+ *
207
+ * Comments are discarded (the parser drops them before the AST). Reformatting
208
+ * already-canonical text is the identity.
209
+ *
210
+ * @public
211
+ * @throws {ParseError} When `source` contains syntax errors.
212
+ */
213
+ declare function formatWireframeCode(source: string): string;
214
+
179
215
  /**
180
216
  * Device viewport presets for wireweave
181
217
  *
@@ -945,4 +981,334 @@ interface AnalysisOptions {
945
981
  */
946
982
  declare function analyze(doc: WireframeDocument, options?: AnalysisOptions): AnalysisResult;
947
983
 
948
- export { ATTRIBUTE_MAP, ATTRIBUTE_SPECS, type AccessibilityMetrics, AccordionNode, AlertNode, type AnalysisOptions, type AnalysisResult, AnyNode, type AttributeChange, type AttributeSpec, type AttributeValueType, AvatarNode, BadgeNode, BreadcrumbNode, ButtonNode, COMMON_ATTRIBUTES, COMPONENT_MAP, COMPONENT_SPECS, CardNode, CheckboxNode, ColNode, type ComplexityMetrics, type ComponentCategory, type ComponentSpec, type ComponentStats, ContainerComponentNode, ContainerNode, type ContentAnalysis, DEFAULT_VIEWPORT, DEVICE_PRESETS, DataNode, type DiffChangeType, type DiffOptions, type DiffResult, type DiffSummary, DisplayNode, DividerComponentNode, DrawerNode, DropdownNode, type ExportOptions, FeedbackNode, type FigmaAutoLayout, type FigmaColor, type FigmaCounterAxisAlign, type FigmaExportResult, type FigmaLayoutMode, type FigmaNode, type FigmaNodeType, type FigmaPrimaryAxisAlign, type FigmaSize, type FigmaSizingMode, type FigmaSolidFill, type FigmaStroke, type FigmaTextAlign, type FigmaTextStyle, FooterNode, GridNode, HeaderNode, IconNode, ImageNode, InputComponentNode, InputNode, type JsonExportResult, type JsonNode, type LayoutAnalysis, LayoutNode, LeafNode, LinkNode, ListNode, MainNode, ModalNode, NODE_TYPE_MAP, NavNode, NavigationNode, type NodeChange, type NodePredicate, NodeType, OverlayNode, PageNode, PlaceholderNode, PopoverNode, type PreviewWrapperOptions, ProgressNode, RadioNode, RowNode, SectionNode, SelectNode, SidebarNode, SliderNode, SpinnerNode, SwitchNode, TableNode, TabsNode, TextContentNode, TextNode, TextareaNode, TitleNode, ToastNode, TooltipNode, type TreeMetrics, VALID_ATTRIBUTE_NAMES, VALID_COMPONENT_NAMES, type ValidationError, type ValidationOptions, type ValidationResult, type ViewportSize, type WalkCallback, WireframeDocument, analyze, areIdentical, calculateViewportScale, cloneNode, contains, countNodes, diff, exportToFigma, exportToFigmaString, exportToJson, exportToJsonString, find, findAll, findByType, getAncestors, getChangeSummary, getDevicePresets, getMaxDepth, getNodeTypes, getValidAttributes, getValidationErrors, hasChildren, importFromJson, isAccordionNode, isAlertNode, isAvatarNode, isBadgeNode, isBreadcrumbNode, isButtonNode, isCardNode, isCheckboxNode, isColNode, isContainerComponentNode, isContainerNode, isDataNode, isDisplayNode, isDividerNode, isDrawerNode, isDropdownNode, isFeedbackNode, isFooterNode, isGridNode, isHeaderNode, isIconNode, isImageNode, isInputComponentNode, isInputNode, isLayoutNode, isLeafNode, isLinkNode, isListNode, isMainNode, isModalNode, isNavNode, isNavigationNode, isNodeType, isOverlayNode, isPageNode, isPlaceholderNode, isPopoverNode, isProgressNode, isRadioNode, isRowNode, isSectionNode, isSelectNode, isSidebarNode, isSliderNode, isSpinnerNode, isSwitchNode, isTableNode, isTabsNode, isTextContentNode, isTextNode, isTextareaNode, isTitleNode, isToastNode, isTooltipNode, isValidAst, isValidAttribute, isValidDevicePreset, mapNodes, parseViewportString, resetFigmaIdCounter, resolveViewport, validate, walk, walkDocument, wrapInPreviewContainer };
984
+ /**
985
+ * Types for the deterministic extraction module.
986
+ *
987
+ * These shapes mirror the SSOT (single-source-of-truth) Screen skeleton slots —
988
+ * title / UI 요소·입력 필드 / 표시 데이터 / 전이 — so a downstream SSOT authoring
989
+ * step can map a parsed `WireframeDocument` onto Screen nodes without any prose
990
+ * generation. Everything here is derived structurally from the AST; there is no
991
+ * heuristic text synthesis.
992
+ */
993
+
994
+ /**
995
+ * The kind of interaction an interactive node triggers, taken directly from the
996
+ * DSL `InteractiveProps` (`navigate` / `opens` / `toggles` / `action`).
997
+ */
998
+ type InteractionKind = 'navigate' | 'opens' | 'toggles' | 'action';
999
+ /**
1000
+ * A meaningful UI node on a screen (any real AST component node below the page).
1001
+ */
1002
+ interface ScreenElement {
1003
+ nodeType: NodeType;
1004
+ category: ComponentCategory;
1005
+ /** Short caption: form label, card/section title, avatar/icon name, etc. */
1006
+ label?: string;
1007
+ /** Textual body for content-bearing nodes (text/title/link/button/badge…). */
1008
+ content?: string;
1009
+ loc?: SourceLocation;
1010
+ }
1011
+ /**
1012
+ * A form input field (the 7 `InputComponentNode` types — excludes Button, which
1013
+ * the spec files under the `input` category but is an action, not a field).
1014
+ */
1015
+ interface ScreenInput {
1016
+ nodeType: NodeType;
1017
+ label?: string;
1018
+ /** Present on `Input` only. */
1019
+ inputType?: InputType;
1020
+ placeholder?: string;
1021
+ required?: boolean;
1022
+ disabled?: boolean;
1023
+ /** Present on `Select` — option labels, normalised to strings. */
1024
+ options?: string[];
1025
+ loc?: SourceLocation;
1026
+ }
1027
+ /**
1028
+ * A display / data / text node — the read-only "표시 데이터" of a screen.
1029
+ */
1030
+ interface ScreenDisplay {
1031
+ nodeType: NodeType;
1032
+ category: ComponentCategory;
1033
+ content?: string;
1034
+ label?: string;
1035
+ loc?: SourceLocation;
1036
+ }
1037
+ /**
1038
+ * A single interaction emitted by a node. A node carrying more than one
1039
+ * `InteractiveProps` (e.g. `navigate` + `action`) yields one entry per prop, in
1040
+ * a fixed order (navigate, opens, toggles, action).
1041
+ */
1042
+ interface ScreenAction {
1043
+ nodeType: NodeType;
1044
+ label?: string;
1045
+ kind: InteractionKind;
1046
+ /** The raw target string as written in the DSL. */
1047
+ target: string;
1048
+ /**
1049
+ * Present when the action is a menu item inside a nav/dropdown/breadcrumb
1050
+ * container rather than a component node. `nodeType` is then the container's
1051
+ * type, `label` is the item's label, and `index` is its position within the
1052
+ * container's flattened item list.
1053
+ */
1054
+ item?: {
1055
+ index: number;
1056
+ };
1057
+ /** The container node's location for item-level actions; items carry no `loc`. */
1058
+ loc?: SourceLocation;
1059
+ }
1060
+ /**
1061
+ * Per-screen derived counts and boolean rollups.
1062
+ */
1063
+ interface ScreenFieldsSummary {
1064
+ /** Total meaningful component nodes below the page. */
1065
+ total: number;
1066
+ /** Count of nodes per component category. */
1067
+ byCategory: Record<ComponentCategory, number>;
1068
+ inputCount: number;
1069
+ displayCount: number;
1070
+ actionCount: number;
1071
+ /** At least one form input field is present. */
1072
+ hasForm: boolean;
1073
+ /** At least one navigation-category node (nav/tabs/breadcrumb) is present. */
1074
+ hasNavigation: boolean;
1075
+ /** At least one overlay container (modal/drawer/popover/tooltip/dropdown). */
1076
+ hasOverlay: boolean;
1077
+ }
1078
+ /**
1079
+ * The full structured field set extracted from one page.
1080
+ */
1081
+ interface ScreenFields {
1082
+ title?: string;
1083
+ viewport?: string | number;
1084
+ device?: string;
1085
+ elements: ScreenElement[];
1086
+ inputs: ScreenInput[];
1087
+ displayData: ScreenDisplay[];
1088
+ actions: ScreenAction[];
1089
+ summary: ScreenFieldsSummary;
1090
+ loc?: SourceLocation;
1091
+ }
1092
+ /**
1093
+ * A node in the screen-transition graph.
1094
+ */
1095
+ interface TransitionScreen {
1096
+ title?: string;
1097
+ index: number;
1098
+ loc?: SourceLocation;
1099
+ }
1100
+ /**
1101
+ * A resolved or dangling transition trigger.
1102
+ */
1103
+ interface TransitionEdge {
1104
+ from: {
1105
+ pageIndex: number;
1106
+ title?: string;
1107
+ };
1108
+ /**
1109
+ * The destination page for a resolved `navigate` edge. Always `null` for
1110
+ * `opens` / `toggles` / `action`, which are intra-page or opaque and never
1111
+ * cross a page boundary.
1112
+ */
1113
+ to: {
1114
+ pageIndex: number;
1115
+ title?: string;
1116
+ } | null;
1117
+ /** The raw target string as written in the DSL. */
1118
+ target: string;
1119
+ kind: InteractionKind;
1120
+ /**
1121
+ * What fired the transition. For a component node, `nodeType` is that node's
1122
+ * type. For a menu item inside a nav/dropdown/breadcrumb, `nodeType` is the
1123
+ * container's type, `label` is the item's label, and `item.index` is the
1124
+ * item's position within the container — the presence of `item` marks an
1125
+ * item-level trigger.
1126
+ */
1127
+ trigger: {
1128
+ nodeType: NodeType;
1129
+ label?: string;
1130
+ loc?: SourceLocation;
1131
+ item?: {
1132
+ index: number;
1133
+ };
1134
+ };
1135
+ /**
1136
+ * Whether `target` resolved to a concrete destination for its kind:
1137
+ * - `navigate`: a page whose title matches `target`.
1138
+ * - `opens` / `toggles`: a `Modal` / `Drawer` with `id === target` in the
1139
+ * source page.
1140
+ * - `action`: always `false` (an opaque handler id has no structural target).
1141
+ */
1142
+ resolved: boolean;
1143
+ }
1144
+ /**
1145
+ * The screen-transition graph derived from a whole document.
1146
+ */
1147
+ interface ScreenTransitionGraph {
1148
+ screens: TransitionScreen[];
1149
+ edges: TransitionEdge[];
1150
+ /**
1151
+ * The subset of `navigate` edges whose target matched no page title
1152
+ * (`resolved === false`, `to === null`). Intra-page `opens` / `toggles` and
1153
+ * opaque `action` edges are not page transitions and never appear here.
1154
+ */
1155
+ dangling: TransitionEdge[];
1156
+ }
1157
+
1158
+ /**
1159
+ * E3 — Screen field extraction.
1160
+ *
1161
+ * `extractScreenFields(page)` walks a single parsed page and structures its
1162
+ * contents into the SSOT Screen skeleton slots (title / UI 요소·입력 필드 /
1163
+ * 표시 데이터 / 전이). Purely deterministic — no prose generation.
1164
+ */
1165
+
1166
+ /**
1167
+ * Extract the structured field set from a single page.
1168
+ *
1169
+ * Iterates every real component node below the page (the page node itself is
1170
+ * excluded), classifying each by its {@link ComponentCategory}. Pseudo-nodes
1171
+ * that are not real AST components (e.g. nav block `item` / `group` entries)
1172
+ * are skipped.
1173
+ */
1174
+ declare function extractScreenFields(page: PageNode): ScreenFields;
1175
+ /**
1176
+ * Extract {@link ScreenFields} for every page in a document, in document order.
1177
+ */
1178
+ declare function extractAllScreenFields(doc: WireframeDocument): ScreenFields[];
1179
+
1180
+ /**
1181
+ * E1 — Screen transition graph derivation.
1182
+ *
1183
+ * `extractScreenTransitions(doc)` derives the page-to-page navigation graph from
1184
+ * every interactive node in a multi-page document. Purely deterministic.
1185
+ *
1186
+ * ## Trigger sources
1187
+ *
1188
+ * A transition can be fired by a component node (a `Button`, `Link`, `Card`…)
1189
+ * or by a **menu item** inside a nav / dropdown / breadcrumb container. Nav
1190
+ * menus are the primary transition source in a multi-screen wireframe, so both
1191
+ * `nav ["…"]` array items and `nav { item … group { item … } }` block items
1192
+ * (including grouped items), plus dropdown and breadcrumb items, are extracted.
1193
+ * Item triggers carry the container's type in `trigger.nodeType` and the item's
1194
+ * position in `trigger.item.index`. `Tabs` items are plain strings without
1195
+ * `InteractiveProps` and contribute no transition; their panel content is
1196
+ * reached by normal node traversal.
1197
+ *
1198
+ * ## Resolution semantics
1199
+ *
1200
+ * - **`navigate`** is a page transition. Its target resolves to a page when the
1201
+ * target string, trimmed, exactly matches a page `title` (case-sensitive). On
1202
+ * duplicate titles the first page in document order wins. URL-style targets
1203
+ * (`navigate="/dashboard"`) do not match a title and are reported as
1204
+ * {@link ScreenTransitionGraph.dangling | dangling}. This mirrors the DSL,
1205
+ * where `navigate` is documented as a "URL or page" target.
1206
+ * - **`opens` / `toggles`** target an overlay *within the source page*, not
1207
+ * another page, so their `to` is always `null`. They resolve when a `Modal`
1208
+ * or `Drawer` in the same page has `id === target` (the only nodes that carry
1209
+ * an `id`). Being intra-page, they never appear in `dangling`.
1210
+ * - **`action`** is an opaque handler id with no structural destination:
1211
+ * `to === null`, `resolved === false`, and it is not `dangling`.
1212
+ *
1213
+ * Item `href` is a raw anchor, not a declared `navigate` intent, and is
1214
+ * excluded — consistent with node-level extraction.
1215
+ */
1216
+
1217
+ /**
1218
+ * Derive the screen-transition graph for a whole document.
1219
+ */
1220
+ declare function extractScreenTransitions(doc: WireframeDocument): ScreenTransitionGraph;
1221
+
1222
+ /**
1223
+ * Deterministic source-anchor path scheme.
1224
+ *
1225
+ * A single implementation of "which node sits at which path" that BOTH the
1226
+ * renderer's anchor injection and the extract module's anchor index share, so
1227
+ * the DOM attributes and the AST index can never drift apart.
1228
+ *
1229
+ * ## Path scheme
1230
+ *
1231
+ * A path is a dot-joined chain of zero-based indices whose first segment is the
1232
+ * page's index in the document (`0`, `1`, …) and whose remaining segments are
1233
+ * child ordinals within {@link anchorChildNodes}. Example: page `0`, its 3rd
1234
+ * child's 2nd child → `0.2.1`.
1235
+ *
1236
+ * ## Anchor children
1237
+ *
1238
+ * Only the structural container types whose HTML renderer dispatches their
1239
+ * `AnyNode[]` `children` back through `renderNode` are descended into. This is
1240
+ * the exact set that receives an anchor attribute during rendering; leaf and
1241
+ * custom-traversal nodes (Table cells, List items, Nav/Tabs/Breadcrumb entries,
1242
+ * Annotation items) are not part of the anchor tree. Keeping the walk in lock
1243
+ * step with `renderNode` dispatch is what makes the anchor count in the HTML
1244
+ * equal to the size of the index for any document.
1245
+ */
1246
+
1247
+ /** DOM attribute carrying a node's page-relative index path. */
1248
+ declare const ANCHOR_PATH_ATTR = "data-wf-path";
1249
+ /** DOM attribute carrying a node's source offset range (`start-end`). */
1250
+ declare const ANCHOR_LOC_ATTR = "data-wf-loc";
1251
+
1252
+ /**
1253
+ * DOM ↔ AST ↔ source mapping.
1254
+ *
1255
+ * The rendered HTML carries `data-wf-path` / `data-wf-loc` anchors (opt-in via
1256
+ * the renderer's `sourceAnchors` option). This module is the inverse: it turns
1257
+ * an anchor path back into its AST node and its DSL source slice, so a host
1258
+ * (dashboard editor) can implement "click a rendered element → select its
1259
+ * source" and "render a DOM-tree panel" without re-parsing.
1260
+ *
1261
+ * The path scheme is shared with the renderer (`ast/anchor-path`), so an index
1262
+ * built here is guaranteed to line up with the anchors the renderer emitted.
1263
+ */
1264
+
1265
+ /** An entry in the anchor index: a node, its path, and its source location. */
1266
+ interface AnchorEntry {
1267
+ path: string;
1268
+ node: AnyNode;
1269
+ loc?: SourceLocation;
1270
+ }
1271
+ /** A slice of the original DSL source, both raw and trimmed. */
1272
+ interface SourceSlice {
1273
+ /** The exact substring spanned by the node/page location. */
1274
+ text: string;
1275
+ /** `text` with surrounding whitespace removed. */
1276
+ trimmed: string;
1277
+ loc: SourceLocation;
1278
+ }
1279
+ /** A node in the panel-ready DOM tree, mirroring the anchored render tree. */
1280
+ interface DomTreeNode {
1281
+ path: string;
1282
+ nodeType: NodeType;
1283
+ category?: ComponentCategory;
1284
+ label?: string;
1285
+ children: DomTreeNode[];
1286
+ }
1287
+ /**
1288
+ * Build a `path → { node, loc }` index for every anchored node in the document.
1289
+ * The keys are exactly the `data-wf-path` values the renderer emits.
1290
+ */
1291
+ declare function buildAnchorIndex(doc: WireframeDocument, pageIndexBase?: number): Map<string, AnchorEntry>;
1292
+ /**
1293
+ * Resolve an anchor path (a `data-wf-path` value) to its AST node, or
1294
+ * `undefined` if the path is malformed or out of range.
1295
+ */
1296
+ declare function resolveAnchor(doc: WireframeDocument, path: string, pageIndexBase?: number): AnyNode | undefined;
1297
+ /**
1298
+ * The DSL source slice for a page, by its document index. `undefined` if the
1299
+ * index is out of range or the page carries no location (unparsed input).
1300
+ */
1301
+ declare function getPageSource(source: string, doc: WireframeDocument, pageIndex: number): SourceSlice | undefined;
1302
+ /**
1303
+ * The DSL source slice for any anchored node, by its path. `undefined` if the
1304
+ * path does not resolve or the node carries no location.
1305
+ */
1306
+ declare function getNodeSource(source: string, doc: WireframeDocument, path: string, pageIndexBase?: number): SourceSlice | undefined;
1307
+ /**
1308
+ * Build a panel-ready DOM tree — one root per page — mirroring the anchored
1309
+ * render tree. Each node carries its anchor path so a host can cross-highlight
1310
+ * between the tree panel and the rendered canvas.
1311
+ */
1312
+ declare function buildDomTree(doc: WireframeDocument, pageIndexBase?: number): DomTreeNode[];
1313
+
1314
+ export { ANCHOR_LOC_ATTR, ANCHOR_PATH_ATTR, ATTRIBUTE_MAP, ATTRIBUTE_SPECS, type AccessibilityMetrics, AccordionNode, AlertNode, type AnalysisOptions, type AnalysisResult, type AnchorEntry, AnyNode, type AttributeChange, type AttributeSpec, type AttributeValueType, AvatarNode, BadgeNode, BreadcrumbNode, ButtonNode, COMMON_ATTRIBUTES, COMPONENT_MAP, COMPONENT_SPECS, CardNode, CheckboxNode, ColNode, type ComplexityMetrics, type ComponentCategory, type ComponentSpec, type ComponentStats, ContainerComponentNode, ContainerNode, type ContentAnalysis, DEFAULT_VIEWPORT, DEVICE_PRESETS, DataNode, type DiffChangeType, type DiffOptions, type DiffResult, type DiffSummary, DisplayNode, DividerComponentNode, type DomTreeNode, DrawerNode, DropdownNode, type ExportOptions, FeedbackNode, type FigmaAutoLayout, type FigmaColor, type FigmaCounterAxisAlign, type FigmaExportResult, type FigmaLayoutMode, type FigmaNode, type FigmaNodeType, type FigmaPrimaryAxisAlign, type FigmaSize, type FigmaSizingMode, type FigmaSolidFill, type FigmaStroke, type FigmaTextAlign, type FigmaTextStyle, FooterNode, GridNode, HeaderNode, IconNode, ImageNode, InputComponentNode, InputNode, InputType, type InteractionKind, type JsonExportResult, type JsonNode, type LayoutAnalysis, LayoutNode, LeafNode, LinkNode, ListNode, MainNode, ModalNode, NODE_TYPE_MAP, NavNode, NavigationNode, type NodeChange, type NodePredicate, NodeType, OverlayNode, PageNode, PlaceholderNode, PopoverNode, type PreviewWrapperOptions, ProgressNode, RadioNode, RowNode, type ScreenAction, type ScreenDisplay, type ScreenElement, type ScreenFields, type ScreenFieldsSummary, type ScreenInput, type ScreenTransitionGraph, SectionNode, SelectNode, SidebarNode, SliderNode, SourceLocation, type SourceSlice, SpinnerNode, SwitchNode, TableNode, TabsNode, TextContentNode, TextNode, TextareaNode, TitleNode, ToastNode, TooltipNode, type TransitionEdge, type TransitionScreen, type TreeMetrics, VALID_ATTRIBUTE_NAMES, VALID_COMPONENT_NAMES, type ValidationError, type ValidationOptions, type ValidationResult, type ViewportSize, type WalkCallback, WireframeDocument, analyze, areIdentical, buildAnchorIndex, buildDomTree, calculateViewportScale, cloneNode, contains, countNodes, diff, exportToFigma, exportToFigmaString, exportToJson, exportToJsonString, extractAllScreenFields, extractScreenFields, extractScreenTransitions, find, findAll, findByType, formatWireframeCode, getAncestors, getChangeSummary, getDevicePresets, getMaxDepth, getNodeSource, getNodeTypes, getPageSource, getValidAttributes, getValidationErrors, hasChildren, importFromJson, isAccordionNode, isAlertNode, isAvatarNode, isBadgeNode, isBreadcrumbNode, isButtonNode, isCardNode, isCheckboxNode, isColNode, isContainerComponentNode, isContainerNode, isDataNode, isDisplayNode, isDividerNode, isDrawerNode, isDropdownNode, isFeedbackNode, isFooterNode, isGridNode, isHeaderNode, isIconNode, isImageNode, isInputComponentNode, isInputNode, isLayoutNode, isLeafNode, isLinkNode, isListNode, isMainNode, isModalNode, isNavNode, isNavigationNode, isNodeType, isOverlayNode, isPageNode, isPlaceholderNode, isPopoverNode, isProgressNode, isRadioNode, isRowNode, isSectionNode, isSelectNode, isSidebarNode, isSliderNode, isSpinnerNode, isSwitchNode, isTableNode, isTabsNode, isTextContentNode, isTextNode, isTextareaNode, isTitleNode, isToastNode, isTooltipNode, isValidAst, isValidAttribute, isValidDevicePreset, mapNodes, parseViewportString, printWireframe, resetFigmaIdCounter, resolveAnchor, resolveViewport, validate, walk, walkDocument, wrapInPreviewContainer };