@wireweave/core 3.1.0-beta.2 → 3.1.0-beta.4

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/renderer.cjs CHANGED
@@ -21,6 +21,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  var renderer_exports = {};
22
22
  __export(renderer_exports, {
23
23
  HtmlRenderer: () => HtmlRenderer,
24
+ anchorIntent: () => anchorIntent,
24
25
  buildSiteModel: () => buildSiteModel,
25
26
  createHtmlRenderer: () => createHtmlRenderer,
26
27
  darkTheme: () => darkTheme,
@@ -47,6 +48,15 @@ module.exports = __toCommonJS(renderer_exports);
47
48
  function hasChildren(node) {
48
49
  return "children" in node && Array.isArray(node.children);
49
50
  }
51
+ function isDropdownNode(node) {
52
+ return node.type === "Dropdown";
53
+ }
54
+ function isNavNode(node) {
55
+ return node.type === "Nav";
56
+ }
57
+ function isBreadcrumbNode(node) {
58
+ return node.type === "Breadcrumb";
59
+ }
50
60
 
51
61
  // src/ast/utils.ts
52
62
  function walk(node, callback, parent, depth = 0) {
@@ -1468,7 +1478,17 @@ function generateDividerStyles(prefix = "wf") {
1468
1478
  }
1469
1479
 
1470
1480
  // src/renderer/styles/annotation.ts
1471
- function generateAnnotationStyles(_theme, prefix) {
1481
+ function generateAnnotationStyles(_theme, prefix, annotationStyle = "legacy") {
1482
+ const neutral = annotationStyle === "neutral";
1483
+ const markerBackground = neutral ? "#000000" : "#3b82f6";
1484
+ const markerBorder = neutral ? "#000000" : "#2563eb";
1485
+ const markerColor = neutral ? "#FFFFFF" : "white";
1486
+ const panelBackground = neutral ? "#FAFAFA" : "#fafafa";
1487
+ const panelBorder = neutral ? "#888888" : "#d1d5db";
1488
+ const headerColor = neutral ? "#666666" : "#6b7280";
1489
+ const headerBorder = neutral ? "#CCCCCC" : "#e5e7eb";
1490
+ const titleColor = neutral ? "#333333" : "#374151";
1491
+ const contentColor = neutral ? "#666666" : "#6b7280";
1472
1492
  return `/* Annotation Components */
1473
1493
 
1474
1494
  /* Marker - Number marker for referencing */
@@ -1479,9 +1499,9 @@ function generateAnnotationStyles(_theme, prefix) {
1479
1499
  width: 20px;
1480
1500
  height: 20px;
1481
1501
  border-radius: 50%;
1482
- background: #3b82f6;
1483
- border: 2px solid #2563eb;
1484
- color: white;
1502
+ background: ${markerBackground};
1503
+ border: 2px solid ${markerBorder};
1504
+ color: ${markerColor};
1485
1505
  font-size: 11px;
1486
1506
  font-weight: 600;
1487
1507
  line-height: 1;
@@ -1497,8 +1517,8 @@ function generateAnnotationStyles(_theme, prefix) {
1497
1517
  /* Annotations Panel - Documentation container */
1498
1518
  .${prefix}-annotations {
1499
1519
  margin-top: 16px;
1500
- background: #fafafa;
1501
- border: 2px dashed #d1d5db;
1520
+ background: ${panelBackground};
1521
+ border: 2px dashed ${panelBorder};
1502
1522
  border-radius: 8px;
1503
1523
  padding: 16px;
1504
1524
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
@@ -1510,10 +1530,10 @@ function generateAnnotationStyles(_theme, prefix) {
1510
1530
  gap: 8px;
1511
1531
  font-weight: 600;
1512
1532
  font-size: 14px;
1513
- color: #6b7280;
1533
+ color: ${headerColor};
1514
1534
  margin-bottom: 16px;
1515
1535
  padding-bottom: 8px;
1516
- border-bottom: 1px solid #e5e7eb;
1536
+ border-bottom: 1px solid ${headerBorder};
1517
1537
  }
1518
1538
 
1519
1539
  .${prefix}-annotations-icon {
@@ -1546,8 +1566,8 @@ function generateAnnotationStyles(_theme, prefix) {
1546
1566
  width: 18px;
1547
1567
  height: 18px;
1548
1568
  border-radius: 50%;
1549
- background: #3b82f6;
1550
- color: white;
1569
+ background: ${markerBackground};
1570
+ color: ${markerColor};
1551
1571
  font-size: 10px;
1552
1572
  font-weight: 600;
1553
1573
  flex-shrink: 0;
@@ -1556,13 +1576,13 @@ function generateAnnotationStyles(_theme, prefix) {
1556
1576
  .${prefix}-annotation-item-title {
1557
1577
  font-weight: 500;
1558
1578
  font-size: 13px;
1559
- color: #374151;
1579
+ color: ${titleColor};
1560
1580
  }
1561
1581
 
1562
1582
  .${prefix}-annotation-item-content {
1563
1583
  padding-left: 26px;
1564
1584
  font-size: 12px;
1565
- color: #6b7280;
1585
+ color: ${contentColor};
1566
1586
  line-height: 1.5;
1567
1587
  }
1568
1588
 
@@ -1570,12 +1590,12 @@ function generateAnnotationStyles(_theme, prefix) {
1570
1590
  .${prefix}-annotation-item-content .${prefix}-text {
1571
1591
  margin: 0;
1572
1592
  font-size: 12px;
1573
- color: #6b7280;
1593
+ color: ${contentColor};
1574
1594
  }`;
1575
1595
  }
1576
1596
 
1577
1597
  // src/renderer/styles-components.ts
1578
- function generateComponentStyles(_theme, prefix = "wf") {
1598
+ function generateComponentStyles(_theme, prefix = "wf", annotationStyle = "legacy") {
1579
1599
  const parts = [
1580
1600
  generateContainerStyles(prefix),
1581
1601
  generateTextStyles(prefix),
@@ -1589,13 +1609,13 @@ function generateComponentStyles(_theme, prefix = "wf") {
1589
1609
  generateSemanticMarkerStyles(_theme, prefix),
1590
1610
  generateAccessibilityStyles(prefix),
1591
1611
  generateDividerStyles(prefix),
1592
- generateAnnotationStyles(_theme, prefix)
1612
+ generateAnnotationStyles(_theme, prefix, annotationStyle)
1593
1613
  ];
1594
1614
  return parts.join("\n\n");
1595
1615
  }
1596
1616
 
1597
1617
  // src/renderer/styles.ts
1598
- function generateStyles(theme, prefix = "wf") {
1618
+ function generateStyles(theme, prefix = "wf", annotationStyle = "legacy") {
1599
1619
  const parts = [
1600
1620
  generateCssVariables(theme, prefix),
1601
1621
  generateBaseStyles(prefix),
@@ -1604,7 +1624,7 @@ function generateStyles(theme, prefix = "wf") {
1604
1624
  generateFlexClasses(prefix),
1605
1625
  generateSizeClasses(prefix),
1606
1626
  generateLayoutClasses(prefix),
1607
- generateComponentStyles(theme, prefix)
1627
+ generateComponentStyles(theme, prefix, annotationStyle)
1608
1628
  ];
1609
1629
  return parts.join("\n\n");
1610
1630
  }
@@ -2021,6 +2041,7 @@ var DEFAULT_OPTIONS = {
2021
2041
  includeStyles: true,
2022
2042
  minify: false,
2023
2043
  classPrefix: "wf",
2044
+ annotationStyle: "legacy",
2024
2045
  sourceAnchors: false,
2025
2046
  idScope: ""
2026
2047
  };
@@ -2051,7 +2072,11 @@ var BaseRenderer = class {
2051
2072
  */
2052
2073
  render(document) {
2053
2074
  const html = this.renderDocument(document);
2054
- const css = this.context.options.includeStyles ? generateStyles(this.context.theme, this.context.options.classPrefix) : "";
2075
+ const css = this.context.options.includeStyles ? generateStyles(
2076
+ this.context.theme,
2077
+ this.context.options.classPrefix,
2078
+ this.context.options.annotationStyle
2079
+ ) : "";
2055
2080
  return {
2056
2081
  html: this.context.options.minify ? this.minifyHtml(html) : html,
2057
2082
  css: this.context.options.minify ? this.minifyCss(css) : css
@@ -2243,6 +2268,1234 @@ function buildAnchorPathMap(doc, pageIndexBase = 0) {
2243
2268
  return map;
2244
2269
  }
2245
2270
 
2271
+ // src/spec/attributes.ts
2272
+ var ATTRIBUTE_SPECS = [
2273
+ // ============================================
2274
+ // Spacing Attributes
2275
+ // ============================================
2276
+ { name: "p", type: "number", description: "Padding (all sides)" },
2277
+ { name: "px", type: "number", description: "Horizontal padding" },
2278
+ { name: "py", type: "number", description: "Vertical padding" },
2279
+ { name: "pt", type: "number", description: "Top padding" },
2280
+ { name: "pr", type: "number", description: "Right padding" },
2281
+ { name: "pb", type: "number", description: "Bottom padding" },
2282
+ { name: "pl", type: "number", description: "Left padding" },
2283
+ { name: "m", type: "number", description: "Margin (all sides)" },
2284
+ { name: "mx", type: "string", description: 'Horizontal margin (number or "auto")' },
2285
+ { name: "my", type: "number", description: "Vertical margin" },
2286
+ { name: "mt", type: "number", description: "Top margin" },
2287
+ { name: "mr", type: "number", description: "Right margin" },
2288
+ { name: "mb", type: "number", description: "Bottom margin" },
2289
+ { name: "ml", type: "number", description: "Left margin" },
2290
+ { name: "gap", type: "number", description: "Gap between children" },
2291
+ // ============================================
2292
+ // Size Attributes
2293
+ // ============================================
2294
+ { name: "w", type: "string", description: 'Width (number, "full", "auto", "screen", "fit")' },
2295
+ { name: "h", type: "string", description: 'Height (number, "full", "auto", "screen")' },
2296
+ { name: "width", type: "number", description: "Width in pixels (page only)" },
2297
+ { name: "height", type: "number", description: "Height in pixels (page only)" },
2298
+ { name: "minW", type: "number", description: "Minimum width" },
2299
+ { name: "maxW", type: "number", description: "Maximum width" },
2300
+ { name: "minH", type: "number", description: "Minimum height" },
2301
+ { name: "maxH", type: "number", description: "Maximum height" },
2302
+ // ============================================
2303
+ // Flex/Grid Layout Attributes
2304
+ // ============================================
2305
+ { name: "flex", type: "boolean", description: "Enable flexbox" },
2306
+ {
2307
+ name: "direction",
2308
+ type: "enum",
2309
+ values: ["row", "column", "row-reverse", "column-reverse"],
2310
+ description: "Flex direction"
2311
+ },
2312
+ {
2313
+ name: "justify",
2314
+ type: "enum",
2315
+ values: ["start", "center", "end", "between", "around", "evenly"],
2316
+ description: "Main axis alignment"
2317
+ },
2318
+ {
2319
+ name: "align",
2320
+ type: "enum",
2321
+ values: ["start", "center", "end", "stretch", "baseline"],
2322
+ description: "Cross axis alignment"
2323
+ },
2324
+ { name: "wrap", type: "boolean", description: "Enable flex wrap" },
2325
+ { name: "span", type: "number", description: "Grid column span (1-12)" },
2326
+ { name: "sm", type: "number", description: "Responsive span at 576px+" },
2327
+ { name: "md", type: "number", description: "Responsive span at 768px+" },
2328
+ { name: "lg", type: "number", description: "Responsive span at 992px+" },
2329
+ { name: "xl", type: "number", description: "Responsive span at 1200px+" },
2330
+ { name: "order", type: "number", description: "Flex order" },
2331
+ // ============================================
2332
+ // Position Attributes
2333
+ // ============================================
2334
+ { name: "x", type: "number", description: "Horizontal position" },
2335
+ { name: "y", type: "number", description: "Vertical position" },
2336
+ {
2337
+ name: "position",
2338
+ type: "enum",
2339
+ values: [
2340
+ "left",
2341
+ "right",
2342
+ "top",
2343
+ "bottom",
2344
+ "top-left",
2345
+ "top-center",
2346
+ "top-right",
2347
+ "bottom-left",
2348
+ "bottom-center",
2349
+ "bottom-right"
2350
+ ],
2351
+ description: "Position preset"
2352
+ },
2353
+ // ============================================
2354
+ // Visual Attributes
2355
+ // ============================================
2356
+ { name: "border", type: "boolean", description: "Show border" },
2357
+ { name: "rounded", type: "boolean", description: "Apply border radius" },
2358
+ {
2359
+ name: "shadow",
2360
+ type: "enum",
2361
+ values: ["none", "sm", "md", "lg", "xl"],
2362
+ description: "Box shadow"
2363
+ },
2364
+ {
2365
+ name: "bg",
2366
+ type: "enum",
2367
+ values: ["muted", "primary", "secondary"],
2368
+ description: "Background variant"
2369
+ },
2370
+ // ============================================
2371
+ // Text Attributes
2372
+ // ============================================
2373
+ {
2374
+ name: "size",
2375
+ type: "enum",
2376
+ values: ["xs", "sm", "base", "md", "lg", "xl", "2xl", "3xl"],
2377
+ description: "Size preset"
2378
+ },
2379
+ {
2380
+ name: "weight",
2381
+ type: "enum",
2382
+ values: ["normal", "medium", "semibold", "bold"],
2383
+ description: "Font weight"
2384
+ },
2385
+ { name: "level", type: "number", description: "Heading level (1-6)" },
2386
+ { name: "muted", type: "boolean", description: "Muted/dimmed style" },
2387
+ { name: "bold", type: "boolean", description: "Bold text" },
2388
+ // ============================================
2389
+ // Button Variant Attributes
2390
+ // ============================================
2391
+ { name: "primary", type: "boolean", description: "Primary style" },
2392
+ { name: "secondary", type: "boolean", description: "Secondary style" },
2393
+ { name: "outline", type: "boolean", description: "Outline style" },
2394
+ { name: "ghost", type: "boolean", description: "Ghost/transparent style" },
2395
+ { name: "danger", type: "boolean", description: "Danger/destructive style" },
2396
+ // ============================================
2397
+ // Status Variant Attributes
2398
+ // ============================================
2399
+ {
2400
+ name: "variant",
2401
+ type: "enum",
2402
+ values: ["default", "primary", "secondary", "success", "warning", "danger", "info"],
2403
+ description: "Status variant"
2404
+ },
2405
+ // ============================================
2406
+ // Form Attributes
2407
+ // ============================================
2408
+ {
2409
+ name: "inputType",
2410
+ type: "enum",
2411
+ values: ["text", "email", "password", "number", "tel", "url", "search", "date"],
2412
+ description: "Input field type"
2413
+ },
2414
+ { name: "placeholder", type: "string", description: "Placeholder text" },
2415
+ { name: "value", type: "string", description: "Default value" },
2416
+ { name: "label", type: "string", description: "Field label" },
2417
+ { name: "name", type: "string", description: "Form field name" },
2418
+ { name: "required", type: "boolean", description: "Required field" },
2419
+ { name: "disabled", type: "boolean", description: "Disabled state" },
2420
+ { name: "readonly", type: "boolean", description: "Read-only state" },
2421
+ { name: "checked", type: "boolean", description: "Checked state" },
2422
+ { name: "loading", type: "boolean", description: "Loading state" },
2423
+ { name: "rows", type: "number", description: "Textarea rows" },
2424
+ { name: "min", type: "number", description: "Minimum value" },
2425
+ { name: "max", type: "number", description: "Maximum value" },
2426
+ { name: "step", type: "number", description: "Step increment" },
2427
+ // ============================================
2428
+ // Content Attributes
2429
+ // ============================================
2430
+ { name: "title", type: "string", description: "Title text" },
2431
+ { name: "src", type: "string", description: "Source URL" },
2432
+ { name: "alt", type: "string", description: "Alt text" },
2433
+ { name: "href", type: "string", description: "Link URL" },
2434
+ { name: "icon", type: "string", description: "Icon name" },
2435
+ { name: "external", type: "boolean", description: "External link" },
2436
+ // ============================================
2437
+ // Accessibility Attributes
2438
+ // ============================================
2439
+ {
2440
+ name: "aria",
2441
+ type: "string",
2442
+ description: "Accessible name, rendered as aria-label (e.g. icon-only button)"
2443
+ },
2444
+ {
2445
+ name: "aria-label",
2446
+ type: "string",
2447
+ description: "Accessible name (synonym for aria), rendered as aria-label"
2448
+ },
2449
+ // ============================================
2450
+ // State Attributes
2451
+ // ============================================
2452
+ { name: "active", type: "number", description: "Active index" },
2453
+ { name: "expanded", type: "boolean", description: "Expanded state" },
2454
+ { name: "centered", type: "boolean", description: "Center content" },
2455
+ { name: "vertical", type: "boolean", description: "Vertical orientation" },
2456
+ { name: "scroll", type: "boolean", description: "Enable scrolling" },
2457
+ // ============================================
2458
+ // Feedback Attributes
2459
+ // ============================================
2460
+ { name: "dismissible", type: "boolean", description: "Can be dismissed" },
2461
+ { name: "indeterminate", type: "boolean", description: "Indeterminate state" },
2462
+ { name: "pill", type: "boolean", description: "Pill/rounded style" },
2463
+ // ============================================
2464
+ // Data Attributes
2465
+ // ============================================
2466
+ { name: "striped", type: "boolean", description: "Striped rows" },
2467
+ { name: "bordered", type: "boolean", description: "Full borders" },
2468
+ { name: "hover", type: "boolean", description: "Hover effect" },
2469
+ { name: "ordered", type: "boolean", description: "Ordered list" },
2470
+ { name: "none", type: "boolean", description: "No list markers" },
2471
+ // ============================================
2472
+ // Page/Viewport Attributes
2473
+ // ============================================
2474
+ { name: "viewport", type: "string", description: 'Viewport size (e.g., "1440x900")' },
2475
+ { name: "device", type: "string", description: "Device preset" },
2476
+ { name: "id", type: "string", description: "Stable identifier for a page or overlay" },
2477
+ { name: "uses", type: "string", description: "Name of the layout a page is drawn inside" },
2478
+ { name: "navigate", type: "string", description: "Screen id, title, or URL to navigate to" },
2479
+ { name: "opens", type: "string", description: "Overlay id to open" },
2480
+ { name: "toggles", type: "string", description: "Overlay id to toggle" },
2481
+ { name: "action", type: "string", description: "Named legacy interaction action" },
2482
+ {
2483
+ name: "on",
2484
+ type: "object",
2485
+ description: "Typed click event with an optional equality guard and ordered effects"
2486
+ },
2487
+ {
2488
+ name: "visibleWhen",
2489
+ type: "object",
2490
+ description: "Equality guard controlling whether this branch is visible"
2491
+ },
2492
+ {
2493
+ name: "enabledWhen",
2494
+ type: "object",
2495
+ description: "Equality guard controlling whether this control is enabled"
2496
+ },
2497
+ {
2498
+ name: "states",
2499
+ type: "object[]",
2500
+ description: "Typed application state declarations owned by a page or shared layout"
2501
+ }
2502
+ ];
2503
+ var VALID_ATTRIBUTE_NAMES = new Set(
2504
+ ATTRIBUTE_SPECS.map((attr) => attr.name)
2505
+ );
2506
+ var ATTRIBUTE_MAP = new Map(
2507
+ ATTRIBUTE_SPECS.map((attr) => [attr.name, attr])
2508
+ );
2509
+ var COMMON_ATTRIBUTES = [
2510
+ // Spacing
2511
+ "p",
2512
+ "px",
2513
+ "py",
2514
+ "pt",
2515
+ "pr",
2516
+ "pb",
2517
+ "pl",
2518
+ "m",
2519
+ "mx",
2520
+ "my",
2521
+ "mt",
2522
+ "mr",
2523
+ "mb",
2524
+ "ml",
2525
+ "gap",
2526
+ // Size
2527
+ "w",
2528
+ "h",
2529
+ "minW",
2530
+ "maxW",
2531
+ "minH",
2532
+ "maxH",
2533
+ // Flex
2534
+ "flex",
2535
+ "direction",
2536
+ "justify",
2537
+ "align",
2538
+ "wrap",
2539
+ // Grid
2540
+ "span",
2541
+ // Position
2542
+ "x",
2543
+ "y",
2544
+ // State-controlled outcomes
2545
+ "visibleWhen",
2546
+ "enabledWhen"
2547
+ ];
2548
+ var INTERACTIVE_ATTRIBUTES = [
2549
+ "navigate",
2550
+ "opens",
2551
+ "toggles",
2552
+ "action",
2553
+ "on"
2554
+ ];
2555
+
2556
+ // src/spec/components.ts
2557
+ var COMPONENT_SPECS = [
2558
+ // ============================================
2559
+ // Layout Components
2560
+ // ============================================
2561
+ {
2562
+ name: "page",
2563
+ nodeType: "Page",
2564
+ category: "layout",
2565
+ attributes: [
2566
+ ...COMMON_ATTRIBUTES,
2567
+ "title",
2568
+ "width",
2569
+ "height",
2570
+ "viewport",
2571
+ "device",
2572
+ "centered",
2573
+ "id",
2574
+ "uses",
2575
+ "states"
2576
+ ],
2577
+ hasChildren: true,
2578
+ description: "Root container for a wireframe page"
2579
+ },
2580
+ {
2581
+ name: "layout",
2582
+ nodeType: "Layout",
2583
+ category: "layout",
2584
+ attributes: ["states"],
2585
+ hasChildren: true,
2586
+ description: "Named page shell containing a slot for page content"
2587
+ },
2588
+ {
2589
+ name: "component",
2590
+ nodeType: "Component",
2591
+ category: "layout",
2592
+ attributes: [],
2593
+ hasChildren: true,
2594
+ description: "Named reusable component definition with typed inputs and slots"
2595
+ },
2596
+ {
2597
+ name: "use",
2598
+ nodeType: "ComponentUse",
2599
+ category: "layout",
2600
+ attributes: [],
2601
+ hasChildren: true,
2602
+ description: "Explicit reusable component invocation with named inputs and fills"
2603
+ },
2604
+ {
2605
+ name: "slot",
2606
+ nodeType: "Slot",
2607
+ category: "layout",
2608
+ attributes: [],
2609
+ hasChildren: false,
2610
+ description: "Position where a layout hosts page content"
2611
+ },
2612
+ {
2613
+ name: "header",
2614
+ nodeType: "Header",
2615
+ category: "layout",
2616
+ attributes: [...COMMON_ATTRIBUTES, "border"],
2617
+ hasChildren: true,
2618
+ description: "Page header section"
2619
+ },
2620
+ {
2621
+ name: "main",
2622
+ nodeType: "Main",
2623
+ category: "layout",
2624
+ attributes: [...COMMON_ATTRIBUTES, "scroll"],
2625
+ hasChildren: true,
2626
+ description: "Main content section"
2627
+ },
2628
+ {
2629
+ name: "footer",
2630
+ nodeType: "Footer",
2631
+ category: "layout",
2632
+ attributes: [...COMMON_ATTRIBUTES, "border"],
2633
+ hasChildren: true,
2634
+ description: "Page footer section"
2635
+ },
2636
+ {
2637
+ name: "sidebar",
2638
+ nodeType: "Sidebar",
2639
+ category: "layout",
2640
+ attributes: [...COMMON_ATTRIBUTES, "position", "border", "bg"],
2641
+ hasChildren: true,
2642
+ description: "Side navigation or content area"
2643
+ },
2644
+ {
2645
+ name: "section",
2646
+ nodeType: "Section",
2647
+ category: "layout",
2648
+ attributes: [...COMMON_ATTRIBUTES, "title", "expanded"],
2649
+ hasChildren: true,
2650
+ description: "Grouped content section"
2651
+ },
2652
+ // ============================================
2653
+ // Grid Components
2654
+ // ============================================
2655
+ {
2656
+ name: "row",
2657
+ nodeType: "Row",
2658
+ category: "grid",
2659
+ attributes: [...COMMON_ATTRIBUTES, "border", "bg"],
2660
+ hasChildren: true,
2661
+ description: "Horizontal flex container"
2662
+ },
2663
+ {
2664
+ name: "col",
2665
+ nodeType: "Col",
2666
+ category: "grid",
2667
+ attributes: [...COMMON_ATTRIBUTES, "sm", "md", "lg", "xl", "order", "border", "bg", "scroll"],
2668
+ hasChildren: true,
2669
+ description: "Vertical flex container or grid column"
2670
+ },
2671
+ {
2672
+ name: "stack",
2673
+ nodeType: "Stack",
2674
+ category: "grid",
2675
+ attributes: [...COMMON_ATTRIBUTES, "border", "bg"],
2676
+ hasChildren: true,
2677
+ description: "Vertical stack that only takes content height"
2678
+ },
2679
+ {
2680
+ name: "relative",
2681
+ nodeType: "Relative",
2682
+ category: "grid",
2683
+ attributes: [...COMMON_ATTRIBUTES],
2684
+ hasChildren: true,
2685
+ description: "Container for overlaying elements with absolute positioning"
2686
+ },
2687
+ // ============================================
2688
+ // Container Components
2689
+ // ============================================
2690
+ {
2691
+ name: "card",
2692
+ nodeType: "Card",
2693
+ category: "container",
2694
+ attributes: [
2695
+ ...COMMON_ATTRIBUTES,
2696
+ ...INTERACTIVE_ATTRIBUTES,
2697
+ "title",
2698
+ "shadow",
2699
+ "border",
2700
+ "rounded"
2701
+ ],
2702
+ hasChildren: true,
2703
+ description: "Card container with optional title"
2704
+ },
2705
+ {
2706
+ name: "modal",
2707
+ nodeType: "Modal",
2708
+ category: "container",
2709
+ attributes: [...COMMON_ATTRIBUTES, "title", "id"],
2710
+ hasChildren: true,
2711
+ description: "Modal dialog overlay"
2712
+ },
2713
+ {
2714
+ name: "drawer",
2715
+ nodeType: "Drawer",
2716
+ category: "container",
2717
+ attributes: [...COMMON_ATTRIBUTES, "title", "position", "id"],
2718
+ hasChildren: true,
2719
+ description: "Slide-in drawer panel"
2720
+ },
2721
+ {
2722
+ name: "accordion",
2723
+ nodeType: "Accordion",
2724
+ category: "container",
2725
+ attributes: [...COMMON_ATTRIBUTES, "title"],
2726
+ hasChildren: true,
2727
+ description: "Collapsible sections container"
2728
+ },
2729
+ // ============================================
2730
+ // Text Components
2731
+ // ============================================
2732
+ {
2733
+ name: "text",
2734
+ nodeType: "Text",
2735
+ category: "text",
2736
+ attributes: [...COMMON_ATTRIBUTES, "size", "weight", "muted", "bold"],
2737
+ hasChildren: false,
2738
+ description: "Text content"
2739
+ },
2740
+ {
2741
+ name: "title",
2742
+ nodeType: "Title",
2743
+ category: "text",
2744
+ attributes: [...COMMON_ATTRIBUTES, "level", "size"],
2745
+ hasChildren: false,
2746
+ description: "Heading element (h1-h6)"
2747
+ },
2748
+ {
2749
+ name: "link",
2750
+ nodeType: "Link",
2751
+ category: "text",
2752
+ attributes: [...COMMON_ATTRIBUTES, ...INTERACTIVE_ATTRIBUTES, "href", "external"],
2753
+ hasChildren: false,
2754
+ description: "Hyperlink text"
2755
+ },
2756
+ // ============================================
2757
+ // Input Components
2758
+ // ============================================
2759
+ {
2760
+ name: "input",
2761
+ nodeType: "Input",
2762
+ category: "input",
2763
+ attributes: [
2764
+ ...COMMON_ATTRIBUTES,
2765
+ ...INTERACTIVE_ATTRIBUTES,
2766
+ "label",
2767
+ "inputType",
2768
+ "placeholder",
2769
+ "value",
2770
+ "disabled",
2771
+ "required",
2772
+ "readonly",
2773
+ "icon",
2774
+ "size",
2775
+ "rounded"
2776
+ ],
2777
+ hasChildren: false,
2778
+ description: "Text input field"
2779
+ },
2780
+ {
2781
+ name: "textarea",
2782
+ nodeType: "Textarea",
2783
+ category: "input",
2784
+ attributes: [
2785
+ ...COMMON_ATTRIBUTES,
2786
+ "label",
2787
+ "placeholder",
2788
+ "value",
2789
+ "rows",
2790
+ "disabled",
2791
+ "required"
2792
+ ],
2793
+ hasChildren: false,
2794
+ description: "Multi-line text input"
2795
+ },
2796
+ {
2797
+ name: "select",
2798
+ nodeType: "Select",
2799
+ category: "input",
2800
+ attributes: [...COMMON_ATTRIBUTES, "label", "placeholder", "value", "disabled", "required"],
2801
+ hasChildren: false,
2802
+ description: "Dropdown select"
2803
+ },
2804
+ {
2805
+ name: "checkbox",
2806
+ nodeType: "Checkbox",
2807
+ category: "input",
2808
+ attributes: [...COMMON_ATTRIBUTES, "label", "checked", "disabled"],
2809
+ hasChildren: false,
2810
+ description: "Checkbox input"
2811
+ },
2812
+ {
2813
+ name: "radio",
2814
+ nodeType: "Radio",
2815
+ category: "input",
2816
+ attributes: [...COMMON_ATTRIBUTES, "label", "name", "checked", "disabled"],
2817
+ hasChildren: false,
2818
+ description: "Radio button input"
2819
+ },
2820
+ {
2821
+ name: "switch",
2822
+ nodeType: "Switch",
2823
+ category: "input",
2824
+ attributes: [...COMMON_ATTRIBUTES, "label", "checked", "disabled"],
2825
+ hasChildren: false,
2826
+ description: "Toggle switch"
2827
+ },
2828
+ {
2829
+ name: "slider",
2830
+ nodeType: "Slider",
2831
+ category: "input",
2832
+ attributes: [...COMMON_ATTRIBUTES, "label", "min", "max", "value", "step", "disabled"],
2833
+ hasChildren: false,
2834
+ description: "Range slider"
2835
+ },
2836
+ {
2837
+ name: "button",
2838
+ nodeType: "Button",
2839
+ category: "input",
2840
+ attributes: [
2841
+ ...COMMON_ATTRIBUTES,
2842
+ ...INTERACTIVE_ATTRIBUTES,
2843
+ "primary",
2844
+ "secondary",
2845
+ "outline",
2846
+ "ghost",
2847
+ "danger",
2848
+ "size",
2849
+ "icon",
2850
+ "disabled",
2851
+ "loading",
2852
+ // Accessibility: give icon-only buttons an accessible name / tooltip
2853
+ "aria",
2854
+ "aria-label",
2855
+ "title"
2856
+ ],
2857
+ hasChildren: false,
2858
+ description: "Clickable button"
2859
+ },
2860
+ // ============================================
2861
+ // Display Components
2862
+ // ============================================
2863
+ {
2864
+ name: "image",
2865
+ nodeType: "Image",
2866
+ category: "display",
2867
+ attributes: [...COMMON_ATTRIBUTES, ...INTERACTIVE_ATTRIBUTES, "src", "alt"],
2868
+ hasChildren: false,
2869
+ description: "Image placeholder"
2870
+ },
2871
+ {
2872
+ name: "placeholder",
2873
+ nodeType: "Placeholder",
2874
+ category: "display",
2875
+ attributes: [...COMMON_ATTRIBUTES, "label"],
2876
+ hasChildren: true,
2877
+ description: "Generic placeholder"
2878
+ },
2879
+ {
2880
+ name: "avatar",
2881
+ nodeType: "Avatar",
2882
+ category: "display",
2883
+ attributes: [...COMMON_ATTRIBUTES, ...INTERACTIVE_ATTRIBUTES, "name", "src", "size"],
2884
+ hasChildren: false,
2885
+ description: "User avatar"
2886
+ },
2887
+ {
2888
+ name: "badge",
2889
+ nodeType: "Badge",
2890
+ category: "display",
2891
+ attributes: [
2892
+ ...COMMON_ATTRIBUTES,
2893
+ ...INTERACTIVE_ATTRIBUTES,
2894
+ "variant",
2895
+ "pill",
2896
+ "icon",
2897
+ "size",
2898
+ "anchor"
2899
+ ],
2900
+ hasChildren: false,
2901
+ description: "Status badge"
2902
+ },
2903
+ {
2904
+ name: "icon",
2905
+ nodeType: "Icon",
2906
+ category: "display",
2907
+ attributes: [...COMMON_ATTRIBUTES, ...INTERACTIVE_ATTRIBUTES, "name", "size", "muted"],
2908
+ hasChildren: false,
2909
+ description: "Lucide icon"
2910
+ },
2911
+ // ============================================
2912
+ // Data Components
2913
+ // ============================================
2914
+ {
2915
+ name: "table",
2916
+ nodeType: "Table",
2917
+ category: "data",
2918
+ attributes: [...COMMON_ATTRIBUTES, "striped", "bordered", "hover"],
2919
+ hasChildren: false,
2920
+ description: "Data table"
2921
+ },
2922
+ {
2923
+ name: "list",
2924
+ nodeType: "List",
2925
+ category: "data",
2926
+ attributes: [...COMMON_ATTRIBUTES, "ordered", "none"],
2927
+ hasChildren: false,
2928
+ description: "List of items"
2929
+ },
2930
+ // ============================================
2931
+ // Feedback Components
2932
+ // ============================================
2933
+ {
2934
+ name: "alert",
2935
+ nodeType: "Alert",
2936
+ category: "feedback",
2937
+ attributes: [...COMMON_ATTRIBUTES, "variant", "dismissible", "icon"],
2938
+ hasChildren: false,
2939
+ description: "Alert message"
2940
+ },
2941
+ {
2942
+ name: "toast",
2943
+ nodeType: "Toast",
2944
+ category: "feedback",
2945
+ attributes: [...COMMON_ATTRIBUTES, "position", "variant"],
2946
+ hasChildren: false,
2947
+ description: "Toast notification"
2948
+ },
2949
+ {
2950
+ name: "progress",
2951
+ nodeType: "Progress",
2952
+ category: "feedback",
2953
+ attributes: [...COMMON_ATTRIBUTES, "value", "max", "label", "indeterminate"],
2954
+ hasChildren: false,
2955
+ description: "Progress bar"
2956
+ },
2957
+ {
2958
+ name: "spinner",
2959
+ nodeType: "Spinner",
2960
+ category: "feedback",
2961
+ attributes: [...COMMON_ATTRIBUTES, "label", "size"],
2962
+ hasChildren: false,
2963
+ description: "Loading spinner"
2964
+ },
2965
+ // ============================================
2966
+ // Overlay Components
2967
+ // ============================================
2968
+ {
2969
+ name: "tooltip",
2970
+ nodeType: "Tooltip",
2971
+ category: "overlay",
2972
+ attributes: [...COMMON_ATTRIBUTES, "position"],
2973
+ hasChildren: false,
2974
+ description: "Tooltip on hover"
2975
+ },
2976
+ {
2977
+ name: "popover",
2978
+ nodeType: "Popover",
2979
+ category: "overlay",
2980
+ attributes: [...COMMON_ATTRIBUTES, "title"],
2981
+ hasChildren: true,
2982
+ description: "Popover panel"
2983
+ },
2984
+ {
2985
+ name: "dropdown",
2986
+ nodeType: "Dropdown",
2987
+ category: "overlay",
2988
+ attributes: [...COMMON_ATTRIBUTES],
2989
+ hasChildren: false,
2990
+ description: "Dropdown menu"
2991
+ },
2992
+ // ============================================
2993
+ // Navigation Components
2994
+ // ============================================
2995
+ {
2996
+ name: "nav",
2997
+ nodeType: "Nav",
2998
+ category: "navigation",
2999
+ attributes: [...COMMON_ATTRIBUTES, "vertical"],
3000
+ hasChildren: false,
3001
+ description: "Navigation menu"
3002
+ },
3003
+ {
3004
+ name: "tabs",
3005
+ nodeType: "Tabs",
3006
+ category: "navigation",
3007
+ attributes: [...COMMON_ATTRIBUTES, "active"],
3008
+ hasChildren: true,
3009
+ description: "Tab navigation"
3010
+ },
3011
+ {
3012
+ name: "breadcrumb",
3013
+ nodeType: "Breadcrumb",
3014
+ category: "navigation",
3015
+ attributes: [...COMMON_ATTRIBUTES],
3016
+ hasChildren: false,
3017
+ description: "Breadcrumb navigation"
3018
+ },
3019
+ // ============================================
3020
+ // Divider Component
3021
+ // ============================================
3022
+ {
3023
+ name: "divider",
3024
+ nodeType: "Divider",
3025
+ category: "layout",
3026
+ attributes: [...COMMON_ATTRIBUTES, "vertical"],
3027
+ hasChildren: false,
3028
+ description: "Horizontal separator"
3029
+ },
3030
+ // ============================================
3031
+ // Annotation Components
3032
+ // ============================================
3033
+ {
3034
+ name: "marker",
3035
+ nodeType: "Marker",
3036
+ category: "annotation",
3037
+ attributes: [...COMMON_ATTRIBUTES, "color", "anchor"],
3038
+ hasChildren: false,
3039
+ description: "Number marker for referencing in annotations"
3040
+ },
3041
+ {
3042
+ name: "annotations",
3043
+ nodeType: "Annotations",
3044
+ category: "annotation",
3045
+ attributes: [...COMMON_ATTRIBUTES, "title"],
3046
+ hasChildren: true,
3047
+ description: "Documentation panel for screen specifications"
3048
+ },
3049
+ {
3050
+ name: "item",
3051
+ nodeType: "AnnotationItem",
3052
+ category: "annotation",
3053
+ attributes: [],
3054
+ hasChildren: true,
3055
+ description: "Individual annotation entry with marker number and title"
3056
+ }
3057
+ ];
3058
+ var VALID_COMPONENT_NAMES = new Set(
3059
+ COMPONENT_SPECS.map((comp) => comp.name)
3060
+ );
3061
+ var COMPONENT_MAP = new Map(
3062
+ COMPONENT_SPECS.map((comp) => [comp.name, comp])
3063
+ );
3064
+ var NODE_TYPE_MAP = new Map(
3065
+ COMPONENT_SPECS.map((comp) => [comp.nodeType, comp])
3066
+ );
3067
+
3068
+ // src/extract/node-info.ts
3069
+ var INTERACTION_KINDS = ["navigate", "opens", "toggles", "action"];
3070
+ function categoryOf(node) {
3071
+ return NODE_TYPE_MAP.get(node.type)?.category;
3072
+ }
3073
+ function getLabel(node) {
3074
+ if ("label" in node && typeof node.label === "string") return node.label;
3075
+ if ("name" in node && typeof node.name === "string") return node.name;
3076
+ if ("title" in node && typeof node.title === "string") return node.title;
3077
+ return void 0;
3078
+ }
3079
+ function getContent(node) {
3080
+ if ("content" in node && typeof node.content === "string") return node.content;
3081
+ return void 0;
3082
+ }
3083
+ function getInteractiveLabel(node) {
3084
+ return getContent(node) ?? getLabel(node);
3085
+ }
3086
+ function interactionsOf(props) {
3087
+ const out = [];
3088
+ for (const kind of INTERACTION_KINDS) {
3089
+ const target = props[kind];
3090
+ if (typeof target === "string" && target.length > 0) {
3091
+ out.push({ kind, target });
3092
+ }
3093
+ }
3094
+ return out;
3095
+ }
3096
+ function getInteractions(node) {
3097
+ return interactionsOf(node);
3098
+ }
3099
+ function getItemInteractionSources(node) {
3100
+ const out = [];
3101
+ let index = 0;
3102
+ const emit = (label, props) => {
3103
+ const item = { props, container: node.type, itemIndex: index };
3104
+ if (label !== void 0) item.itemLabel = label;
3105
+ out.push(item);
3106
+ index += 1;
3107
+ };
3108
+ if (isNavNode(node)) {
3109
+ for (const it of node.items) {
3110
+ if (typeof it === "string") {
3111
+ index += 1;
3112
+ continue;
3113
+ }
3114
+ emit(it.label, it);
3115
+ }
3116
+ for (const child of node.children) {
3117
+ if (child.type === "item") {
3118
+ emit(child.label, child);
3119
+ } else if (child.type === "group") {
3120
+ for (const groupItem of child.items) {
3121
+ if (groupItem.type === "item") emit(groupItem.label, groupItem);
3122
+ }
3123
+ }
3124
+ }
3125
+ } else if (isDropdownNode(node)) {
3126
+ for (const it of node.items) {
3127
+ if (!("label" in it)) {
3128
+ index += 1;
3129
+ continue;
3130
+ }
3131
+ emit(it.label, it);
3132
+ }
3133
+ } else if (isBreadcrumbNode(node)) {
3134
+ for (const it of node.items) {
3135
+ if (typeof it === "string") {
3136
+ index += 1;
3137
+ continue;
3138
+ }
3139
+ emit(it.label, it);
3140
+ }
3141
+ }
3142
+ return out;
3143
+ }
3144
+
3145
+ // src/renderer/page-renderer.ts
3146
+ function renderPage(page, options = {}) {
3147
+ const renderer = new HtmlRenderer(options);
3148
+ const { html, css } = renderer.render({
3149
+ type: "Document",
3150
+ children: [page]
3151
+ });
3152
+ const { width, height } = resolvePageDimensions(page);
3153
+ return { html, css, width, height };
3154
+ }
3155
+ function resolvePageDimensions(page) {
3156
+ const pageAny = page;
3157
+ const explicitW = page.w ?? pageAny.width;
3158
+ const explicitH = page.h ?? pageAny.height;
3159
+ if (typeof explicitW === "number" && typeof explicitH === "number") {
3160
+ return { width: explicitW, height: explicitH };
3161
+ }
3162
+ const viewport = resolveViewport(page.viewport, page.device);
3163
+ return { width: viewport.width, height: viewport.height };
3164
+ }
3165
+
3166
+ // src/renderer/site/model.ts
3167
+ function pageId(page) {
3168
+ const id = page.id?.trim();
3169
+ return id && id.length > 0 ? id : void 0;
3170
+ }
3171
+ function pageTitle(page) {
3172
+ const title = page.title?.trim();
3173
+ return title && title.length > 0 ? title : void 0;
3174
+ }
3175
+ function hasSlot(layout) {
3176
+ for (const child of layout.children) {
3177
+ let found = false;
3178
+ walk(child, (node) => {
3179
+ if (node.type === "Slot") found = true;
3180
+ return !found;
3181
+ });
3182
+ if (found) return true;
3183
+ }
3184
+ return false;
3185
+ }
3186
+ function layoutsByName(doc) {
3187
+ const layouts = /* @__PURE__ */ new Map();
3188
+ for (const definition of documentDefinitions(doc)) {
3189
+ if (definition.type !== "Layout") continue;
3190
+ const name = definition.name.trim();
3191
+ if (name.length > 0 && !layouts.has(name)) layouts.set(name, definition);
3192
+ }
3193
+ return layouts;
3194
+ }
3195
+ function resolveShell(page, layouts) {
3196
+ const uses = page.uses?.trim();
3197
+ if (!uses) return void 0;
3198
+ const layout = layouts.get(uses);
3199
+ if (!layout) return { miss: { uses, reason: "unknown-layout" } };
3200
+ if (!hasSlot(layout)) return { miss: { uses, reason: "slotless-layout" } };
3201
+ return { layout, name: uses };
3202
+ }
3203
+ function buildSiteModel(doc) {
3204
+ const screens = documentPages(doc).map((page, index) => ({ index, page }));
3205
+ const layouts = layoutsByName(doc);
3206
+ const shells = [];
3207
+ const shellByName = /* @__PURE__ */ new Map();
3208
+ for (const screen of screens) {
3209
+ const resolved = resolveShell(screen.page, layouts);
3210
+ if (!resolved) continue;
3211
+ if ("miss" in resolved) {
3212
+ screen.miss = resolved.miss;
3213
+ continue;
3214
+ }
3215
+ let shell = shellByName.get(resolved.name);
3216
+ if (!shell) {
3217
+ const { width, height } = resolvePageDimensions(screen.page);
3218
+ shell = { name: resolved.name, layout: resolved.layout, screens: [], width, height };
3219
+ shellByName.set(resolved.name, shell);
3220
+ shells.push(shell);
3221
+ }
3222
+ shell.screens.push(screen);
3223
+ screen.shell = shell.name;
3224
+ }
3225
+ const names = /* @__PURE__ */ new Map();
3226
+ for (const screen of screens) {
3227
+ const title = pageTitle(screen.page);
3228
+ if (title !== void 0 && !names.has(title)) names.set(title, screen.index);
3229
+ }
3230
+ for (const screen of screens) {
3231
+ const id = pageId(screen.page);
3232
+ if (id === void 0) continue;
3233
+ const owner = names.get(id);
3234
+ if (owner === void 0 || pageId(screens[owner].page) !== id) {
3235
+ names.set(id, screen.index);
3236
+ }
3237
+ }
3238
+ for (const screen of screens) {
3239
+ screen.name = [pageId(screen.page), pageTitle(screen.page)].find(
3240
+ (name) => name !== void 0 && names.get(name) === screen.index
3241
+ );
3242
+ }
3243
+ return { screens, shells, names, entry: screens.length > 0 ? 0 : -1 };
3244
+ }
3245
+
3246
+ // src/interaction/model.ts
3247
+ function isRecord(value) {
3248
+ return typeof value === "object" && value !== null && !Array.isArray(value);
3249
+ }
3250
+ function isStateValue(value) {
3251
+ return typeof value === "string" || typeof value === "number" || typeof value === "boolean";
3252
+ }
3253
+ function valueMatches(type, value) {
3254
+ return typeof value === type;
3255
+ }
3256
+ function normalizeStateGuard(value) {
3257
+ if (!isRecord(value) || typeof value.state !== "string" || !isStateValue(value.equals)) {
3258
+ return void 0;
3259
+ }
3260
+ const state = value.state.trim();
3261
+ return state.length > 0 ? { state, equals: value.equals } : void 0;
3262
+ }
3263
+ function normalizeEffect(value) {
3264
+ if (!isRecord(value) || typeof value.kind !== "string") return void 0;
3265
+ switch (value.kind) {
3266
+ case "navigate":
3267
+ case "open":
3268
+ case "close": {
3269
+ if (typeof value.target !== "string" || value.target.trim().length === 0) return void 0;
3270
+ return { kind: value.kind, target: value.target.trim() };
3271
+ }
3272
+ case "set": {
3273
+ if (typeof value.state !== "string" || value.state.trim().length === 0 || !isStateValue(value.value)) {
3274
+ return void 0;
3275
+ }
3276
+ return { kind: "set", state: value.state.trim(), value: value.value };
3277
+ }
3278
+ case "reset":
3279
+ case "toggle": {
3280
+ if (typeof value.state !== "string" || value.state.trim().length === 0) return void 0;
3281
+ return { kind: value.kind, state: value.state.trim() };
3282
+ }
3283
+ default:
3284
+ return void 0;
3285
+ }
3286
+ }
3287
+ function normalizeInteractionHandlers(value) {
3288
+ const candidates = Array.isArray(value) ? value : [value];
3289
+ const handlers = [];
3290
+ for (const candidate of candidates) {
3291
+ if (!isRecord(candidate) || candidate.event !== "click") continue;
3292
+ const effects = Array.isArray(candidate.effects) ? candidate.effects.map(normalizeEffect) : [normalizeEffect(candidate.effects)];
3293
+ if (effects.length === 0 || effects.some((effect) => effect === void 0)) continue;
3294
+ const handler = {
3295
+ event: "click",
3296
+ effects
3297
+ };
3298
+ if (candidate.guard !== void 0) {
3299
+ const guard = normalizeStateGuard(candidate.guard);
3300
+ if (guard === void 0) continue;
3301
+ handler.guard = guard;
3302
+ }
3303
+ handlers.push(handler);
3304
+ }
3305
+ return handlers;
3306
+ }
3307
+ function interactionSignature(handler) {
3308
+ return JSON.stringify(handler);
3309
+ }
3310
+ function legacyHandler(kind, target) {
3311
+ switch (kind) {
3312
+ case "navigate":
3313
+ return { event: "click", effects: [{ kind: "navigate", target: target.trim() }] };
3314
+ case "opens":
3315
+ return { event: "click", effects: [{ kind: "open", target: target.trim() }] };
3316
+ case "toggles":
3317
+ return { event: "click", effects: [{ kind: "toggle-overlay", target: target.trim() }] };
3318
+ case "action":
3319
+ return { event: "click", effects: [{ kind: "legacy-action", action: target.trim() }] };
3320
+ }
3321
+ }
3322
+ function normalizeStateDeclaration(value) {
3323
+ if (!isRecord(value) || typeof value.name !== "string" || value.valueType !== "string" && value.valueType !== "number" && value.valueType !== "boolean" || !isStateValue(value.initial)) {
3324
+ return void 0;
3325
+ }
3326
+ const name = value.name.trim();
3327
+ if (name.length === 0 || !valueMatches(value.valueType, value.initial)) return void 0;
3328
+ return { name, valueType: value.valueType, initial: value.initial };
3329
+ }
3330
+ function collectStates(doc, diagnostics) {
3331
+ const states = [];
3332
+ const names = /* @__PURE__ */ new Set();
3333
+ for (const owner of doc.children) {
3334
+ if (owner.type !== "Page" && owner.type !== "Layout") continue;
3335
+ const raw = owner.states;
3336
+ if (raw === void 0) continue;
3337
+ if (!Array.isArray(raw)) {
3338
+ diagnostics.push({
3339
+ code: "invalid-state-declaration",
3340
+ message: "states must be an array of typed state declarations",
3341
+ ...owner.loc ? { loc: owner.loc } : {}
3342
+ });
3343
+ continue;
3344
+ }
3345
+ for (const candidate of raw) {
3346
+ const state = normalizeStateDeclaration(candidate);
3347
+ if (state === void 0) {
3348
+ diagnostics.push({
3349
+ code: "invalid-state-declaration",
3350
+ message: "state declarations require name, valueType, and a matching scalar initial value",
3351
+ ...owner.loc ? { loc: owner.loc } : {}
3352
+ });
3353
+ continue;
3354
+ }
3355
+ if (names.has(state.name)) {
3356
+ diagnostics.push({
3357
+ code: "duplicate-state-declaration",
3358
+ message: `state ${JSON.stringify(state.name)} was already declared; first declaration wins`,
3359
+ ...owner.loc ? { loc: owner.loc } : {}
3360
+ });
3361
+ continue;
3362
+ }
3363
+ names.add(state.name);
3364
+ states.push(state);
3365
+ }
3366
+ }
3367
+ return states;
3368
+ }
3369
+ function sourcesIn(nodes) {
3370
+ const sources = [];
3371
+ for (const child of nodes) {
3372
+ walk(child, (node) => {
3373
+ if (categoryOf(node) === void 0) return;
3374
+ const trigger = { nodeType: node.type };
3375
+ const label = getInteractiveLabel(node);
3376
+ if (label !== void 0) trigger.label = label;
3377
+ if (node.loc) trigger.loc = node.loc;
3378
+ sources.push({ props: node, trigger });
3379
+ for (const item of getItemInteractionSources(node)) {
3380
+ const itemTrigger = {
3381
+ nodeType: item.container,
3382
+ item: { index: item.itemIndex }
3383
+ };
3384
+ if (item.itemLabel !== void 0) itemTrigger.label = item.itemLabel;
3385
+ if (node.loc) itemTrigger.loc = node.loc;
3386
+ sources.push({ props: item.props, trigger: itemTrigger });
3387
+ }
3388
+ });
3389
+ }
3390
+ return sources;
3391
+ }
3392
+ function collectInteractions(doc) {
3393
+ const diagnostics = [];
3394
+ const states = collectStates(doc, diagnostics);
3395
+ const interactions = [];
3396
+ const site = buildSiteModel(doc);
3397
+ const layouts = new Map(site.shells.map((shell) => [shell.name, shell.layout]));
3398
+ const add = (screenIndex, source, triggerSource) => {
3399
+ const legacy = getInteractions(triggerSource.props).map(({ kind, target }) => ({
3400
+ kind,
3401
+ handler: legacyHandler(kind, target)
3402
+ }));
3403
+ const typed = normalizeInteractionHandlers(triggerSource.props.on);
3404
+ if (triggerSource.props.on !== void 0 && typed.length === 0) {
3405
+ diagnostics.push({
3406
+ code: "invalid-interaction-handler",
3407
+ message: "on requires event=click, an optional equality guard, and valid ordered effects",
3408
+ screenIndex,
3409
+ source,
3410
+ ...triggerSource.trigger.loc ? { loc: triggerSource.trigger.loc } : {}
3411
+ });
3412
+ }
3413
+ for (const entry of [...legacy, ...typed.map((handler) => ({ handler, kind: void 0 }))]) {
3414
+ const { handler } = entry;
3415
+ for (const effect of handler.effects) {
3416
+ if (effect.kind === "legacy-action" && effect.action !== "close" && effect.action !== "back") {
3417
+ diagnostics.push({
3418
+ code: "unknown-legacy-action",
3419
+ message: `legacy action ${JSON.stringify(effect.action)} is inert in the generated runtime`,
3420
+ screenIndex,
3421
+ source,
3422
+ ...triggerSource.trigger.loc ? { loc: triggerSource.trigger.loc } : {}
3423
+ });
3424
+ }
3425
+ }
3426
+ const interaction = {
3427
+ screenIndex,
3428
+ source,
3429
+ signature: interactionSignature(handler),
3430
+ handler,
3431
+ trigger: triggerSource.trigger
3432
+ };
3433
+ if (entry.kind !== void 0) interaction.legacyKind = entry.kind;
3434
+ interactions.push(interaction);
3435
+ }
3436
+ };
3437
+ for (const screen of site.screens) {
3438
+ for (const source of sourcesIn(screen.page.children)) add(screen.index, "screen", source);
3439
+ if (screen.shell !== void 0) {
3440
+ const layout = layouts.get(screen.shell);
3441
+ if (layout !== void 0) {
3442
+ for (const source of sourcesIn(layout.children)) add(screen.index, "layout", source);
3443
+ }
3444
+ }
3445
+ }
3446
+ return { states, interactions, diagnostics };
3447
+ }
3448
+
3449
+ // src/interaction/target.ts
3450
+ function isUrlTarget(target) {
3451
+ if (target === void 0) return false;
3452
+ const value = target.trim();
3453
+ if (value.length === 0 || /\s/.test(value)) return false;
3454
+ if (value.startsWith("/") || value.startsWith("#") || value.startsWith("?")) return true;
3455
+ return /^[A-Za-z][A-Za-z0-9+.-]*:/.test(value);
3456
+ }
3457
+
3458
+ // src/renderer/html/interactive.ts
3459
+ var EXTERNAL_NAVIGATE_ATTR = "data-navigate-external";
3460
+ var TYPED_INTERACTION_ATTR = "data-wf-on";
3461
+ var VISIBLE_GUARD_ATTR = "data-wf-visible-when";
3462
+ var ENABLED_GUARD_ATTR = "data-wf-enabled-when";
3463
+ var INERT_HREF = "#";
3464
+ function guardedOutcomeAttrs(node) {
3465
+ const visible = normalizeStateGuard(node.visibleWhen);
3466
+ const enabled = normalizeStateGuard(node.enabledWhen);
3467
+ return {
3468
+ [VISIBLE_GUARD_ATTR]: visible === void 0 ? void 0 : JSON.stringify(visible),
3469
+ [ENABLED_GUARD_ATTR]: enabled === void 0 ? void 0 : JSON.stringify(enabled)
3470
+ };
3471
+ }
3472
+ function interactiveAttrs(node) {
3473
+ const handlers = normalizeInteractionHandlers(node.on);
3474
+ return {
3475
+ "data-navigate": node.navigate,
3476
+ [EXTERNAL_NAVIGATE_ATTR]: isUrlTarget(node.navigate) ? true : void 0,
3477
+ "data-opens": node.opens,
3478
+ "data-toggles": node.toggles,
3479
+ "data-action": node.action,
3480
+ [TYPED_INTERACTION_ATTR]: handlers.length === 0 ? void 0 : JSON.stringify(handlers.map((handler) => interactionSignature(handler))),
3481
+ ...guardedOutcomeAttrs(node)
3482
+ };
3483
+ }
3484
+ function anchorIntent(node) {
3485
+ const attrs2 = interactiveAttrs(node);
3486
+ if (node.href) return { href: node.href, attrs: attrs2 };
3487
+ if (isUrlTarget(node.navigate)) {
3488
+ return {
3489
+ href: node.navigate.trim(),
3490
+ attrs: { ...attrs2, "data-navigate": void 0, [EXTERNAL_NAVIGATE_ATTR]: void 0 }
3491
+ };
3492
+ }
3493
+ return { href: INERT_HREF, attrs: attrs2 };
3494
+ }
3495
+ function nonAnchorIntent(node) {
3496
+ return interactiveAttrs(node);
3497
+ }
3498
+
2246
3499
  // src/renderer/html/components.ts
2247
3500
  function buildClassString(classes) {
2248
3501
  return classes.filter(Boolean).join(" ");
@@ -2425,8 +3678,8 @@ function renderCard(node, ctx) {
2425
3678
  ]);
2426
3679
  const styles = ctx.buildCommonStyles(node);
2427
3680
  const styleAttr = styles ? ` style="${styles}"` : "";
2428
- const interactiveAttrs = buildInteractiveAttrs(node);
2429
- const interactiveAttrStr = ctx.buildAttrsString(interactiveAttrs);
3681
+ const interactiveAttrs2 = buildInteractiveAttrs(node);
3682
+ const interactiveAttrStr = ctx.buildAttrsString(interactiveAttrs2);
2430
3683
  const title = node.title ? `<h3 class="${ctx.prefix}-title">${ctx.escapeHtml(node.title)}</h3>
2431
3684
  ` : "";
2432
3685
  const children = ctx.renderChildren(node.children);
@@ -2541,14 +3794,11 @@ function renderLink(node, ctx) {
2541
3794
  const classes = ctx.buildClassString([`${ctx.prefix}-link`, ...ctx.getCommonClasses(node)]);
2542
3795
  const styles = ctx.buildCommonStyles(node);
2543
3796
  const styleAttr = styles ? ` style="${styles}"` : "";
3797
+ const { href, attrs: intentAttrs } = anchorIntent(node);
2544
3798
  const attrs2 = {
2545
3799
  class: classes,
2546
- href: node.href || node.navigate || "#",
2547
- // Interactive attributes
2548
- "data-navigate": node.navigate,
2549
- "data-opens": node.opens,
2550
- "data-toggles": node.toggles,
2551
- "data-action": node.action
3800
+ href,
3801
+ ...intentAttrs
2552
3802
  };
2553
3803
  if (node.external) {
2554
3804
  attrs2.target = "_blank";
@@ -49270,8 +50520,8 @@ function renderImage(node, ctx) {
49270
50520
  }
49271
50521
  const label = node.alt || "Image";
49272
50522
  const icon = `<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21 15 16 10 5 21"/></svg>`;
49273
- const interactiveAttrs = buildInteractiveAttrs2(node);
49274
- const interactiveAttrStr = ctx.buildAttrsString(interactiveAttrs);
50523
+ const interactiveAttrs2 = buildInteractiveAttrs2(node);
50524
+ const interactiveAttrStr = ctx.buildAttrsString(interactiveAttrs2);
49275
50525
  return `<div class="${classes}"${styleAttr}${interactiveAttrStr} role="img" aria-label="${ctx.escapeHtml(label)}">${icon}<span>${ctx.escapeHtml(label)}</span></div>`;
49276
50526
  }
49277
50527
  function renderPlaceholder(node, ctx) {
@@ -49314,13 +50564,13 @@ function renderAvatar(node, ctx) {
49314
50564
  content = "?";
49315
50565
  }
49316
50566
  }
49317
- const interactiveAttrs = buildInteractiveAttrs2(node);
49318
- const interactiveAttrStr = ctx.buildAttrsString(interactiveAttrs);
50567
+ const interactiveAttrs2 = buildInteractiveAttrs2(node);
50568
+ const interactiveAttrStr = ctx.buildAttrsString(interactiveAttrs2);
49319
50569
  return `<div class="${classes}"${styleAttr}${interactiveAttrStr} role="img" aria-label="${ctx.escapeHtml(node.name || "Avatar")}">${content}</div>`;
49320
50570
  }
49321
50571
  function renderBadge(node, ctx) {
49322
- const interactiveAttrs = buildInteractiveAttrs2(node);
49323
- const interactiveAttrStr = ctx.buildAttrsString(interactiveAttrs);
50572
+ const interactiveAttrs2 = buildInteractiveAttrs2(node);
50573
+ const interactiveAttrStr = ctx.buildAttrsString(interactiveAttrs2);
49324
50574
  const sizeResolved = resolveSizeValue(node.size, "badge", ctx.prefix);
49325
50575
  if (node.icon) {
49326
50576
  const iconData = getIconData(node.icon);
@@ -49359,8 +50609,8 @@ function renderBadge(node, ctx) {
49359
50609
  }
49360
50610
  function renderIcon(node, ctx) {
49361
50611
  const iconData = getIconData(node.name);
49362
- const interactiveAttrs = buildInteractiveAttrs2(node);
49363
- const interactiveAttrStr = ctx.buildAttrsString(interactiveAttrs);
50612
+ const interactiveAttrs2 = buildInteractiveAttrs2(node);
50613
+ const interactiveAttrStr = ctx.buildAttrsString(interactiveAttrs2);
49364
50614
  const sizeResolved = resolveSizeValue(node.size, "icon", ctx.prefix);
49365
50615
  const wrapperClasses = ctx.buildClassString([
49366
50616
  `${ctx.prefix}-icon-wrapper`,
@@ -49427,18 +50677,13 @@ function renderDropdown(node, ctx) {
49427
50677
  dropdownItem.danger ? `${ctx.prefix}-dropdown-item-danger` : void 0,
49428
50678
  dropdownItem.disabled ? `${ctx.prefix}-dropdown-item-disabled` : void 0
49429
50679
  ]);
49430
- const interactiveAttrs = {
49431
- "data-navigate": dropdownItem.navigate,
49432
- "data-opens": dropdownItem.opens,
49433
- "data-toggles": dropdownItem.toggles,
49434
- "data-action": dropdownItem.action
49435
- };
49436
- const interactiveAttrStr = ctx.buildAttrsString(interactiveAttrs);
49437
50680
  const disabledAttr = dropdownItem.disabled ? ' disabled="disabled"' : "";
49438
50681
  if (dropdownItem.href || dropdownItem.navigate) {
49439
- const href = dropdownItem.href || dropdownItem.navigate || "#";
49440
- return `<a class="${itemClasses}" href="${ctx.escapeHtml(href)}"${interactiveAttrStr}>${ctx.escapeHtml(dropdownItem.label)}</a>`;
50682
+ const { href, attrs: attrs2 } = anchorIntent(dropdownItem);
50683
+ const anchorAttrStr = ctx.buildAttrsString(attrs2);
50684
+ return `<a class="${itemClasses}" href="${ctx.escapeHtml(href)}"${anchorAttrStr}>${ctx.escapeHtml(dropdownItem.label)}</a>`;
49441
50685
  }
50686
+ const interactiveAttrStr = ctx.buildAttrsString(nonAnchorIntent(dropdownItem));
49442
50687
  return `<button class="${itemClasses}"${disabledAttr}${interactiveAttrStr}>${ctx.escapeHtml(dropdownItem.label)}</button>`;
49443
50688
  }).join("\n");
49444
50689
  return `<div class="${classes}"${styleAttr}>
@@ -49457,7 +50702,9 @@ function renderNavItem(item, ctx) {
49457
50702
  item.disabled ? `${ctx.prefix}-nav-link-disabled` : void 0
49458
50703
  ]);
49459
50704
  const iconHtml = item.icon ? renderIconHtml(item.icon, ctx.prefix) + " " : "";
49460
- return `<a class="${linkClasses}" href="${item.href || "#"}">${iconHtml}${ctx.escapeHtml(item.label)}</a>`;
50705
+ const { href, attrs: attrs2 } = anchorIntent(item);
50706
+ const intentAttrs = ctx.buildAttrsString(attrs2);
50707
+ return `<a class="${linkClasses}" href="${ctx.escapeHtml(href)}"${intentAttrs}>${iconHtml}${ctx.escapeHtml(item.label)}</a>`;
49461
50708
  }
49462
50709
  function renderNavChildren(children, ctx) {
49463
50710
  return children.map((child) => {
@@ -49500,13 +50747,7 @@ ${content}
49500
50747
  if (typeof item === "string") {
49501
50748
  return `<a class="${ctx.prefix}-nav-link" href="#">${ctx.escapeHtml(item)}</a>`;
49502
50749
  }
49503
- const linkClasses = ctx.buildClassString([
49504
- `${ctx.prefix}-nav-link`,
49505
- item.active ? `${ctx.prefix}-nav-link-active` : void 0,
49506
- item.disabled ? `${ctx.prefix}-nav-link-disabled` : void 0
49507
- ]);
49508
- const iconHtml = item.icon ? renderIconHtml(item.icon, ctx.prefix) + " " : "";
49509
- return `<a class="${linkClasses}" href="${item.href || "#"}">${iconHtml}${ctx.escapeHtml(item.label)}</a>`;
50750
+ return renderNavItem(item, ctx);
49510
50751
  }).join("\n");
49511
50752
  return `<nav class="${classes}"${styleAttr}>
49512
50753
  ${items}
@@ -49537,7 +50778,13 @@ function renderBreadcrumb(node, ctx) {
49537
50778
  if (typeof item === "string") {
49538
50779
  return isLast ? `<span class="${ctx.prefix}-breadcrumb-item" aria-current="page">${ctx.escapeHtml(item)}</span>` : `<a class="${ctx.prefix}-breadcrumb-item" href="#">${ctx.escapeHtml(item)}</a>`;
49539
50780
  }
49540
- return isLast ? `<span class="${ctx.prefix}-breadcrumb-item" aria-current="page">${ctx.escapeHtml(item.label)}</span>` : `<a class="${ctx.prefix}-breadcrumb-item" href="${item.href || "#"}">${ctx.escapeHtml(item.label)}</a>`;
50781
+ if (isLast) {
50782
+ const intentAttrs2 = ctx.buildAttrsString(nonAnchorIntent(item));
50783
+ return `<span class="${ctx.prefix}-breadcrumb-item" aria-current="page"${intentAttrs2}>${ctx.escapeHtml(item.label)}</span>`;
50784
+ }
50785
+ const { href, attrs: attrs2 } = anchorIntent(item);
50786
+ const intentAttrs = ctx.buildAttrsString(attrs2);
50787
+ return `<a class="${ctx.prefix}-breadcrumb-item" href="${ctx.escapeHtml(href)}"${intentAttrs}>${ctx.escapeHtml(item.label)}</a>`;
49541
50788
  }).join(separator);
49542
50789
  return `<nav class="${classes}"${styleAttr} aria-label="Breadcrumb">${items}</nav>`;
49543
50790
  }
@@ -49682,6 +50929,12 @@ var MARKER_COLORS = {
49682
50929
  purple: { bg: "#a855f7", border: "#9333ea" },
49683
50930
  orange: { bg: "#f97316", border: "#ea580c" }
49684
50931
  };
50932
+ var NEUTRAL_MARKER_STYLE = { bg: "#000000", border: "#000000", foreground: "#FFFFFF" };
50933
+ function markerStyle(color, annotationStyle) {
50934
+ if (annotationStyle === "neutral") return NEUTRAL_MARKER_STYLE;
50935
+ const legacy = MARKER_COLORS[color ?? "blue"] ?? MARKER_COLORS.blue;
50936
+ return { ...legacy, foreground: "white" };
50937
+ }
49685
50938
  function getAnchorStyles(anchor) {
49686
50939
  if (!anchor) return "";
49687
50940
  const styles = ["position: absolute"];
@@ -49717,8 +50970,7 @@ function getAnchorStyles(anchor) {
49717
50970
  return styles.join("; ");
49718
50971
  }
49719
50972
  function renderMarker(node, ctx) {
49720
- const color = node.color || "blue";
49721
- const colorConfig = MARKER_COLORS[color] || MARKER_COLORS.blue;
50973
+ const color = markerStyle(node.color, ctx.annotationStyle);
49722
50974
  const baseStyles = [
49723
50975
  "display: inline-flex",
49724
50976
  "align-items: center",
@@ -49726,9 +50978,9 @@ function renderMarker(node, ctx) {
49726
50978
  "width: 20px",
49727
50979
  "height: 20px",
49728
50980
  "border-radius: 50%",
49729
- `background: ${colorConfig.bg}`,
49730
- `border: 2px solid ${colorConfig.border}`,
49731
- "color: white",
50981
+ `background: ${color.bg}`,
50982
+ `border: 2px solid ${color.border}`,
50983
+ `color: ${color.foreground}`,
49732
50984
  "font-size: 11px",
49733
50985
  "font-weight: 600",
49734
50986
  "line-height: 1",
@@ -49759,8 +51011,8 @@ function renderAnnotations(node, ctx) {
49759
51011
  </aside>`;
49760
51012
  }
49761
51013
  function renderAnnotationItem(node, ctx) {
49762
- const color = MARKER_COLORS.blue;
49763
- const markerStyle = [
51014
+ const color = markerStyle("blue", ctx.annotationStyle);
51015
+ const inlineStyle = [
49764
51016
  "display: inline-flex",
49765
51017
  "align-items: center",
49766
51018
  "justify-content: center",
@@ -49768,7 +51020,7 @@ function renderAnnotationItem(node, ctx) {
49768
51020
  "height: 18px",
49769
51021
  "border-radius: 50%",
49770
51022
  `background: ${color.bg}`,
49771
- "color: white",
51023
+ `color: ${color.foreground}`,
49772
51024
  "font-size: 10px",
49773
51025
  "font-weight: 600",
49774
51026
  "flex-shrink: 0"
@@ -49777,7 +51029,7 @@ function renderAnnotationItem(node, ctx) {
49777
51029
  const content = children.length > 0 ? ctx.renderChildren(children) : "";
49778
51030
  return `<div class="${ctx.prefix}-annotation-item">
49779
51031
  <div class="${ctx.prefix}-annotation-item-header">
49780
- <span class="${ctx.prefix}-annotation-marker" style="${markerStyle}">${node.number}</span>
51032
+ <span class="${ctx.prefix}-annotation-marker" style="${inlineStyle}">${node.number}</span>
49781
51033
  <span class="${ctx.prefix}-annotation-item-title">${ctx.escapeHtml(node.title)}</span>
49782
51034
  </div>
49783
51035
  ${content ? `<div class="${ctx.prefix}-annotation-item-content">${content}</div>` : ""}
@@ -49869,6 +51121,7 @@ var HtmlRenderer = class extends BaseRenderer {
49869
51121
  getRenderContext() {
49870
51122
  return {
49871
51123
  prefix: this.prefix,
51124
+ annotationStyle: this.context.options.annotationStyle,
49872
51125
  escapeHtml: this.escapeHtml.bind(this),
49873
51126
  scopedId: this.scopedId.bind(this),
49874
51127
  buildClassString: this.buildClassString.bind(this),
@@ -49949,6 +51202,7 @@ var HtmlRenderer = class extends BaseRenderer {
49949
51202
  // Other
49950
51203
  Divider: (node) => this.renderDivider(node),
49951
51204
  Slot: () => this.renderSlot(),
51205
+ ComponentUse: (node) => this.renderComponentUse(node),
49952
51206
  // Annotation nodes
49953
51207
  Marker: (node) => this.renderMarker(node),
49954
51208
  Annotations: (node) => this.renderAnnotations(node),
@@ -50016,7 +51270,17 @@ ${annotationsContent}
50016
51270
  */
50017
51271
  renderNode(node) {
50018
51272
  const renderer = this.nodeRenderers[node.type];
50019
- const html = renderer ? renderer(node) : `<!-- Unknown node type: ${node.type} -->`;
51273
+ let html = renderer ? renderer(node) : `<!-- Unknown node type: ${node.type} -->`;
51274
+ const rootOpeningTag = /^<[a-zA-Z][a-zA-Z0-9-]*\b[^>]*>/.exec(html)?.[0] ?? "";
51275
+ const intentAttrs = Object.fromEntries(
51276
+ Object.entries(interactiveAttrs(node)).filter(
51277
+ ([name, value]) => name.startsWith("data-wf-") && value !== void 0 && !rootOpeningTag.includes(` ${name}=`)
51278
+ )
51279
+ );
51280
+ const intentAttrString = this.buildAttrsString(intentAttrs);
51281
+ if (rootOpeningTag.length > 0 && intentAttrString.length > 0) {
51282
+ html = html.replace(/^<([a-zA-Z][a-zA-Z0-9-]*)/, (match) => `${match}${intentAttrString}`);
51283
+ }
50020
51284
  if (this.pathMap && node.type !== "Page") {
50021
51285
  const path = this.pathMap.get(node);
50022
51286
  if (path !== void 0) {
@@ -50032,6 +51296,18 @@ ${annotationsContent}
50032
51296
  const open = `<div class="${this.prefix}-slot">`;
50033
51297
  return content === null ? `${open}</div>` : `${open}
50034
51298
  ${content}
51299
+ </div>`;
51300
+ }
51301
+ /** Render one linked component invocation with its stable instance marker. */
51302
+ renderComponentUse(node) {
51303
+ const component = this.escapeHtml(node.name);
51304
+ if (node.children === void 0 || node.instanceId === void 0) {
51305
+ return `<div class="${this.prefix}-component-instance" data-wf-component="${component}" data-wf-component-unresolved style="display: contents"></div>`;
51306
+ }
51307
+ const instanceId = this.escapeHtml(node.instanceId);
51308
+ const content = this.renderChildren(node.children);
51309
+ return `<div class="${this.prefix}-component-instance" data-wf-component="${component}" data-wf-instance="${instanceId}" style="display: contents">
51310
+ ${content}
50035
51311
  </div>`;
50036
51312
  }
50037
51313
  /** Render nodes without adding a page frame, optionally filling a slot. */
@@ -50434,27 +51710,6 @@ function createHtmlRenderer(options) {
50434
51710
  return new HtmlRenderer(options);
50435
51711
  }
50436
51712
 
50437
- // src/renderer/page-renderer.ts
50438
- function renderPage(page, options = {}) {
50439
- const renderer = new HtmlRenderer(options);
50440
- const { html, css } = renderer.render({
50441
- type: "Document",
50442
- children: [page]
50443
- });
50444
- const { width, height } = resolvePageDimensions(page);
50445
- return { html, css, width, height };
50446
- }
50447
- function resolvePageDimensions(page) {
50448
- const pageAny = page;
50449
- const explicitW = page.w ?? pageAny.width;
50450
- const explicitH = page.h ?? pageAny.height;
50451
- if (typeof explicitW === "number" && typeof explicitH === "number") {
50452
- return { width: explicitW, height: explicitH };
50453
- }
50454
- const viewport = resolveViewport(page.viewport, page.device);
50455
- return { width: viewport.width, height: viewport.height };
50456
- }
50457
-
50458
51713
  // src/renderer/canvas-renderer.ts
50459
51714
  var DEFAULT_GAP = 64;
50460
51715
  var DEFAULT_PREFIX = "wf";
@@ -50483,7 +51738,7 @@ function renderCanvas(doc, options = {}) {
50483
51738
  const prefix = options.classPrefix ?? DEFAULT_PREFIX;
50484
51739
  const includeStyles = options.includeStyles !== false;
50485
51740
  const theme = options.theme === "dark" ? darkTheme : defaultTheme;
50486
- const css = includeStyles ? generateStyles(theme, prefix) : "";
51741
+ const css = includeStyles ? generateStyles(theme, prefix, options.annotationStyle) : "";
50487
51742
  const pages = documentPages(doc);
50488
51743
  if (pages.length === 0) {
50489
51744
  return {
@@ -50521,85 +51776,6 @@ function escapeAttr(s) {
50521
51776
  return s.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;");
50522
51777
  }
50523
51778
 
50524
- // src/renderer/site/model.ts
50525
- function pageId(page) {
50526
- const id = page.id?.trim();
50527
- return id && id.length > 0 ? id : void 0;
50528
- }
50529
- function pageTitle(page) {
50530
- const title = page.title?.trim();
50531
- return title && title.length > 0 ? title : void 0;
50532
- }
50533
- function hasSlot(layout) {
50534
- for (const child of layout.children) {
50535
- let found = false;
50536
- walk(child, (node) => {
50537
- if (node.type === "Slot") found = true;
50538
- return !found;
50539
- });
50540
- if (found) return true;
50541
- }
50542
- return false;
50543
- }
50544
- function layoutsByName(doc) {
50545
- const layouts = /* @__PURE__ */ new Map();
50546
- for (const definition of documentDefinitions(doc)) {
50547
- const name = definition.name.trim();
50548
- if (name.length > 0 && !layouts.has(name)) layouts.set(name, definition);
50549
- }
50550
- return layouts;
50551
- }
50552
- function resolveShell(page, layouts) {
50553
- const uses = page.uses?.trim();
50554
- if (!uses) return void 0;
50555
- const layout = layouts.get(uses);
50556
- if (!layout) return { miss: { uses, reason: "unknown-layout" } };
50557
- if (!hasSlot(layout)) return { miss: { uses, reason: "slotless-layout" } };
50558
- return { layout, name: uses };
50559
- }
50560
- function buildSiteModel(doc) {
50561
- const screens = documentPages(doc).map((page, index) => ({ index, page }));
50562
- const layouts = layoutsByName(doc);
50563
- const shells = [];
50564
- const shellByName = /* @__PURE__ */ new Map();
50565
- for (const screen of screens) {
50566
- const resolved = resolveShell(screen.page, layouts);
50567
- if (!resolved) continue;
50568
- if ("miss" in resolved) {
50569
- screen.miss = resolved.miss;
50570
- continue;
50571
- }
50572
- let shell = shellByName.get(resolved.name);
50573
- if (!shell) {
50574
- const { width, height } = resolvePageDimensions(screen.page);
50575
- shell = { name: resolved.name, layout: resolved.layout, screens: [], width, height };
50576
- shellByName.set(resolved.name, shell);
50577
- shells.push(shell);
50578
- }
50579
- shell.screens.push(screen);
50580
- screen.shell = shell.name;
50581
- }
50582
- const names = /* @__PURE__ */ new Map();
50583
- for (const screen of screens) {
50584
- const title = pageTitle(screen.page);
50585
- if (title !== void 0 && !names.has(title)) names.set(title, screen.index);
50586
- }
50587
- for (const screen of screens) {
50588
- const id = pageId(screen.page);
50589
- if (id === void 0) continue;
50590
- const owner = names.get(id);
50591
- if (owner === void 0 || pageId(screens[owner].page) !== id) {
50592
- names.set(id, screen.index);
50593
- }
50594
- }
50595
- for (const screen of screens) {
50596
- screen.name = [pageId(screen.page), pageTitle(screen.page)].find(
50597
- (name) => name !== void 0 && names.get(name) === screen.index
50598
- );
50599
- }
50600
- return { screens, shells, names, entry: screens.length > 0 ? 0 : -1 };
50601
- }
50602
-
50603
51779
  // src/renderer/site/styles.ts
50604
51780
  function generateSiteStyles(prefix) {
50605
51781
  return `
@@ -50697,6 +51873,61 @@ function siteRuntime(registry, prefix) {
50697
51873
  }
50698
51874
  }
50699
51875
  var shells = site.querySelectorAll('.' + P + '-shell');
51876
+ var state = {};
51877
+ var initial = {};
51878
+ var stateTypes = {};
51879
+ for (var st = 0; st < R.states.length; st++) {
51880
+ var declaration = R.states[st];
51881
+ state[declaration.name] = declaration.initial;
51882
+ initial[declaration.name] = declaration.initial;
51883
+ stateTypes[declaration.name] = declaration.valueType;
51884
+ }
51885
+
51886
+ function diagnostic(code, detail) {
51887
+ site.setAttribute('data-wf-runtime-diagnostic', code + ':' + detail);
51888
+ }
51889
+
51890
+ function hasState(name) {
51891
+ return Object.prototype.hasOwnProperty.call(state, name);
51892
+ }
51893
+
51894
+ function guardPasses(guard) {
51895
+ return !guard || (hasState(guard.state) && state[guard.state] === guard.equals);
51896
+ }
51897
+
51898
+ function valueMatches(name, value) {
51899
+ return hasState(name) && typeof value === stateTypes[name];
51900
+ }
51901
+
51902
+ function parseJson(value, fallback) {
51903
+ if (!value) return fallback;
51904
+ try { return JSON.parse(value); } catch (e) { return fallback; }
51905
+ }
51906
+
51907
+ function handlerId(signature) {
51908
+ for (var i = 0; i < R.handlers.length; i++) {
51909
+ if (JSON.stringify(R.handlers[i]) === signature) return i;
51910
+ }
51911
+ return -1;
51912
+ }
51913
+
51914
+ function contains(ids, id) {
51915
+ for (var i = 0; i < ids.length; i++) if (ids[i] === id) return true;
51916
+ return false;
51917
+ }
51918
+
51919
+ function shellHandlersFor(key) {
51920
+ var shell = shellOf[key];
51921
+ if (!shell) return [];
51922
+ return R.shellHandlers[shell.getAttribute('data-layout')] || [];
51923
+ }
51924
+
51925
+ function interactionFor(key, element, signature) {
51926
+ var id = handlerId(signature);
51927
+ if (id < 0) return null;
51928
+ var ids = isChrome(element) ? shellHandlersFor(key) : R.screenHandlers[String(key)] || [];
51929
+ return contains(ids, id) ? R.handlers[id] : null;
51930
+ }
50700
51931
 
50701
51932
  function isChrome(el) {
50702
51933
  return !(el.closest && el.closest('[data-screen]'));
@@ -50763,6 +51994,60 @@ function siteRuntime(registry, prefix) {
50763
51994
  }
50764
51995
  }
50765
51996
 
51997
+ function initOverlays() {
51998
+ for (var i = 0; i < order.length; i++) closeOverlays(order[i]);
51999
+ }
52000
+
52001
+ function applyOutcomes() {
52002
+ var visible = site.querySelectorAll('[' + ${embedJson(VISIBLE_GUARD_ATTR)} + ']');
52003
+ for (var i = 0; i < visible.length; i++) {
52004
+ var visibleGuard = parseJson(visible[i].getAttribute(${embedJson(VISIBLE_GUARD_ATTR)}), null);
52005
+ if (guardPasses(visibleGuard)) visible[i].removeAttribute('hidden');
52006
+ else visible[i].setAttribute('hidden', 'hidden');
52007
+ }
52008
+
52009
+ var enabled = site.querySelectorAll('[' + ${embedJson(ENABLED_GUARD_ATTR)} + ']');
52010
+ for (var j = 0; j < enabled.length; j++) {
52011
+ var enabledGuard = parseJson(enabled[j].getAttribute(${embedJson(ENABLED_GUARD_ATTR)}), null);
52012
+ if (guardPasses(enabledGuard)) {
52013
+ enabled[j].removeAttribute('disabled');
52014
+ enabled[j].removeAttribute('aria-disabled');
52015
+ } else {
52016
+ enabled[j].setAttribute('disabled', 'disabled');
52017
+ enabled[j].setAttribute('aria-disabled', 'true');
52018
+ }
52019
+ }
52020
+ }
52021
+
52022
+ function applyEffects(handler) {
52023
+ for (var i = 0; i < handler.effects.length; i++) {
52024
+ var effect = handler.effects[i];
52025
+ if (effect.kind === 'navigate') {
52026
+ var route = resolve(effect.target);
52027
+ if (route !== null) show(route, true);
52028
+ else diagnostic('unknown-route', effect.target);
52029
+ } else if (effect.kind === 'set') {
52030
+ if (valueMatches(effect.state, effect.value)) state[effect.state] = effect.value;
52031
+ else diagnostic('invalid-set', effect.state);
52032
+ } else if (effect.kind === 'reset') {
52033
+ if (hasState(effect.state)) state[effect.state] = initial[effect.state];
52034
+ else diagnostic('unknown-state', effect.state);
52035
+ } else if (effect.kind === 'toggle') {
52036
+ if (stateTypes[effect.state] === 'boolean') state[effect.state] = !state[effect.state];
52037
+ else diagnostic('invalid-toggle', effect.state);
52038
+ } else if (effect.kind === 'open') {
52039
+ var opened = overlayFor(current, effect.target);
52040
+ if (opened) opened.classList.remove(CLOSED);
52041
+ else diagnostic('unknown-overlay', effect.target);
52042
+ } else if (effect.kind === 'close') {
52043
+ var closed = overlayFor(current, effect.target);
52044
+ if (closed) closed.classList.add(CLOSED);
52045
+ else diagnostic('unknown-overlay', effect.target);
52046
+ }
52047
+ }
52048
+ applyOutcomes();
52049
+ }
52050
+
50766
52051
  function markActive(key) {
50767
52052
  for (var i = 0; i < shells.length; i++) {
50768
52053
  var links = shells[i].querySelectorAll('[data-navigate]');
@@ -50790,6 +52075,7 @@ function siteRuntime(registry, prefix) {
50790
52075
  current = key;
50791
52076
  closeOverlays(key);
50792
52077
  markActive(key);
52078
+ applyOutcomes();
50793
52079
  if (writeFragment) {
50794
52080
  var fragment = R.fragments[Number(key)] || key;
50795
52081
  if (location.hash.slice(1) !== fragment) location.hash = fragment;
@@ -50806,6 +52092,22 @@ function siteRuntime(registry, prefix) {
50806
52092
 
50807
52093
  document.addEventListener('click', function (event) {
50808
52094
  var target = event.target;
52095
+ var typed = target.closest ? target.closest('[' + ${embedJson(TYPED_INTERACTION_ATTR)} + ']') : null;
52096
+ if (typed) {
52097
+ var signatures = parseJson(typed.getAttribute(${embedJson(TYPED_INTERACTION_ATTR)}), []);
52098
+ var matched = false;
52099
+ for (var typedIndex = 0; typedIndex < signatures.length; typedIndex++) {
52100
+ var normalized = interactionFor(current, typed, signatures[typedIndex]);
52101
+ if (!normalized) continue;
52102
+ matched = true;
52103
+ if (guardPasses(normalized.guard)) applyEffects(normalized);
52104
+ }
52105
+ if (matched) {
52106
+ event.preventDefault();
52107
+ return;
52108
+ }
52109
+ }
52110
+
50809
52111
  var mover = target.closest ? target.closest('[data-navigate]') : null;
50810
52112
  if (mover) {
50811
52113
  var destination = resolve(mover.getAttribute('data-navigate'));
@@ -50844,6 +52146,7 @@ function siteRuntime(registry, prefix) {
50844
52146
  closeOverlays(current);
50845
52147
  return;
50846
52148
  }
52149
+ if (action !== '') diagnostic('unknown-action', action);
50847
52150
  }
50848
52151
 
50849
52152
  if (target.classList && target.classList.contains(P + '-modal-backdrop')) {
@@ -50861,6 +52164,7 @@ function siteRuntime(registry, prefix) {
50861
52164
  if (key !== null) show(key, false);
50862
52165
  });
50863
52166
 
52167
+ initOverlays();
50864
52168
  var start = fromFragment();
50865
52169
  if (start === null) start = String(R.entry);
50866
52170
  if (!show(start, false)) show(String(R.entry), false);
@@ -50936,13 +52240,43 @@ function resolveTitle(model, options, entry) {
50936
52240
  const title = model.screens[entry]?.page.title?.trim();
50937
52241
  return title || "Wireframe";
50938
52242
  }
52243
+ function compactRuntimeInteractions(model, interactions) {
52244
+ const handlers = [];
52245
+ const handlerIds = /* @__PURE__ */ new Map();
52246
+ const screenHandlers = {};
52247
+ const shellHandlers = {};
52248
+ const intern = (signature, handler) => {
52249
+ const existing = handlerIds.get(signature);
52250
+ if (existing !== void 0) return existing;
52251
+ const id = handlers.length;
52252
+ handlerIds.set(signature, id);
52253
+ handlers.push(handler);
52254
+ return id;
52255
+ };
52256
+ const add = (owner, key, id) => {
52257
+ const ids = owner[key] ?? (owner[key] = []);
52258
+ if (!ids.includes(id)) ids.push(id);
52259
+ };
52260
+ for (const interaction of interactions) {
52261
+ const id = intern(interaction.signature, interaction.handler);
52262
+ if (interaction.source === "screen") {
52263
+ add(screenHandlers, String(interaction.screenIndex), id);
52264
+ continue;
52265
+ }
52266
+ const shell = model.screens[interaction.screenIndex]?.shell;
52267
+ if (shell !== void 0) add(shellHandlers, shell, id);
52268
+ }
52269
+ return { handlers, screenHandlers, shellHandlers };
52270
+ }
50939
52271
  function renderSite(document, options = {}) {
50940
52272
  const prefix = options.classPrefix ?? DEFAULT_PREFIX2;
50941
52273
  const model = buildSiteModel(document);
52274
+ const interactionModel = collectInteractions(document);
50942
52275
  const make = (idScope) => new HtmlRenderer({
50943
52276
  theme: options.theme,
50944
52277
  classPrefix: prefix,
50945
52278
  background: options.background,
52279
+ annotationStyle: options.annotationStyle,
50946
52280
  includeStyles: false,
50947
52281
  idScope
50948
52282
  });
@@ -50950,12 +52284,16 @@ function renderSite(document, options = {}) {
50950
52284
  const standalone = model.screens.filter((screen) => screen.shell === void 0).map((screen) => renderStandaloneScreen(screen, make, prefix)).join("\n");
50951
52285
  const entry = resolveEntry(model, options);
50952
52286
  const theme = options.theme === "dark" ? darkTheme : defaultTheme;
50953
- const css = generateStyles(theme, prefix) + generateSiteStyles(prefix);
52287
+ const css = generateStyles(theme, prefix, options.annotationStyle) + generateSiteStyles(prefix);
52288
+ const runtimeInteractions = compactRuntimeInteractions(model, interactionModel.interactions);
50954
52289
  const runtime = siteRuntime(
50955
52290
  {
50956
52291
  names: Object.fromEntries(model.names),
50957
52292
  fragments: model.screens.map((screen) => screen.name ?? String(screen.index)),
50958
- entry: entry.index
52293
+ entry: entry.index,
52294
+ states: interactionModel.states,
52295
+ ...runtimeInteractions,
52296
+ diagnostics: interactionModel.diagnostics
50959
52297
  },
50960
52298
  prefix
50961
52299
  );
@@ -50963,7 +52301,8 @@ function renderSite(document, options = {}) {
50963
52301
  const siteAttrs = attrs([
50964
52302
  ["data-screen-count", String(model.screens.length)],
50965
52303
  ["data-shell-count", String(model.shells.length)],
50966
- ["data-wf-entry-unresolved", entry.unresolved]
52304
+ ["data-wf-entry-unresolved", entry.unresolved],
52305
+ ["data-wf-diagnostic-count", String(interactionModel.diagnostics.length)]
50967
52306
  ]);
50968
52307
  return `<!DOCTYPE html>
50969
52308
  <html lang="en">
@@ -51101,6 +52440,7 @@ ${css}
51101
52440
  // Annotate the CommonJS export names for ESM import in node:
51102
52441
  0 && (module.exports = {
51103
52442
  HtmlRenderer,
52443
+ anchorIntent,
51104
52444
  buildSiteModel,
51105
52445
  createHtmlRenderer,
51106
52446
  darkTheme,