@wireweave/core 3.1.0-beta.3 → 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
@@ -48,6 +48,15 @@ module.exports = __toCommonJS(renderer_exports);
48
48
  function hasChildren(node) {
49
49
  return "children" in node && Array.isArray(node.children);
50
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
+ }
51
60
 
52
61
  // src/ast/utils.ts
53
62
  function walk(node, callback, parent, depth = 0) {
@@ -1469,7 +1478,17 @@ function generateDividerStyles(prefix = "wf") {
1469
1478
  }
1470
1479
 
1471
1480
  // src/renderer/styles/annotation.ts
1472
- 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";
1473
1492
  return `/* Annotation Components */
1474
1493
 
1475
1494
  /* Marker - Number marker for referencing */
@@ -1480,9 +1499,9 @@ function generateAnnotationStyles(_theme, prefix) {
1480
1499
  width: 20px;
1481
1500
  height: 20px;
1482
1501
  border-radius: 50%;
1483
- background: #3b82f6;
1484
- border: 2px solid #2563eb;
1485
- color: white;
1502
+ background: ${markerBackground};
1503
+ border: 2px solid ${markerBorder};
1504
+ color: ${markerColor};
1486
1505
  font-size: 11px;
1487
1506
  font-weight: 600;
1488
1507
  line-height: 1;
@@ -1498,8 +1517,8 @@ function generateAnnotationStyles(_theme, prefix) {
1498
1517
  /* Annotations Panel - Documentation container */
1499
1518
  .${prefix}-annotations {
1500
1519
  margin-top: 16px;
1501
- background: #fafafa;
1502
- border: 2px dashed #d1d5db;
1520
+ background: ${panelBackground};
1521
+ border: 2px dashed ${panelBorder};
1503
1522
  border-radius: 8px;
1504
1523
  padding: 16px;
1505
1524
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
@@ -1511,10 +1530,10 @@ function generateAnnotationStyles(_theme, prefix) {
1511
1530
  gap: 8px;
1512
1531
  font-weight: 600;
1513
1532
  font-size: 14px;
1514
- color: #6b7280;
1533
+ color: ${headerColor};
1515
1534
  margin-bottom: 16px;
1516
1535
  padding-bottom: 8px;
1517
- border-bottom: 1px solid #e5e7eb;
1536
+ border-bottom: 1px solid ${headerBorder};
1518
1537
  }
1519
1538
 
1520
1539
  .${prefix}-annotations-icon {
@@ -1547,8 +1566,8 @@ function generateAnnotationStyles(_theme, prefix) {
1547
1566
  width: 18px;
1548
1567
  height: 18px;
1549
1568
  border-radius: 50%;
1550
- background: #3b82f6;
1551
- color: white;
1569
+ background: ${markerBackground};
1570
+ color: ${markerColor};
1552
1571
  font-size: 10px;
1553
1572
  font-weight: 600;
1554
1573
  flex-shrink: 0;
@@ -1557,13 +1576,13 @@ function generateAnnotationStyles(_theme, prefix) {
1557
1576
  .${prefix}-annotation-item-title {
1558
1577
  font-weight: 500;
1559
1578
  font-size: 13px;
1560
- color: #374151;
1579
+ color: ${titleColor};
1561
1580
  }
1562
1581
 
1563
1582
  .${prefix}-annotation-item-content {
1564
1583
  padding-left: 26px;
1565
1584
  font-size: 12px;
1566
- color: #6b7280;
1585
+ color: ${contentColor};
1567
1586
  line-height: 1.5;
1568
1587
  }
1569
1588
 
@@ -1571,12 +1590,12 @@ function generateAnnotationStyles(_theme, prefix) {
1571
1590
  .${prefix}-annotation-item-content .${prefix}-text {
1572
1591
  margin: 0;
1573
1592
  font-size: 12px;
1574
- color: #6b7280;
1593
+ color: ${contentColor};
1575
1594
  }`;
1576
1595
  }
1577
1596
 
1578
1597
  // src/renderer/styles-components.ts
1579
- function generateComponentStyles(_theme, prefix = "wf") {
1598
+ function generateComponentStyles(_theme, prefix = "wf", annotationStyle = "legacy") {
1580
1599
  const parts = [
1581
1600
  generateContainerStyles(prefix),
1582
1601
  generateTextStyles(prefix),
@@ -1590,13 +1609,13 @@ function generateComponentStyles(_theme, prefix = "wf") {
1590
1609
  generateSemanticMarkerStyles(_theme, prefix),
1591
1610
  generateAccessibilityStyles(prefix),
1592
1611
  generateDividerStyles(prefix),
1593
- generateAnnotationStyles(_theme, prefix)
1612
+ generateAnnotationStyles(_theme, prefix, annotationStyle)
1594
1613
  ];
1595
1614
  return parts.join("\n\n");
1596
1615
  }
1597
1616
 
1598
1617
  // src/renderer/styles.ts
1599
- function generateStyles(theme, prefix = "wf") {
1618
+ function generateStyles(theme, prefix = "wf", annotationStyle = "legacy") {
1600
1619
  const parts = [
1601
1620
  generateCssVariables(theme, prefix),
1602
1621
  generateBaseStyles(prefix),
@@ -1605,7 +1624,7 @@ function generateStyles(theme, prefix = "wf") {
1605
1624
  generateFlexClasses(prefix),
1606
1625
  generateSizeClasses(prefix),
1607
1626
  generateLayoutClasses(prefix),
1608
- generateComponentStyles(theme, prefix)
1627
+ generateComponentStyles(theme, prefix, annotationStyle)
1609
1628
  ];
1610
1629
  return parts.join("\n\n");
1611
1630
  }
@@ -2022,6 +2041,7 @@ var DEFAULT_OPTIONS = {
2022
2041
  includeStyles: true,
2023
2042
  minify: false,
2024
2043
  classPrefix: "wf",
2044
+ annotationStyle: "legacy",
2025
2045
  sourceAnchors: false,
2026
2046
  idScope: ""
2027
2047
  };
@@ -2052,7 +2072,11 @@ var BaseRenderer = class {
2052
2072
  */
2053
2073
  render(document) {
2054
2074
  const html = this.renderDocument(document);
2055
- 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
+ ) : "";
2056
2080
  return {
2057
2081
  html: this.context.options.minify ? this.minifyHtml(html) : html,
2058
2082
  css: this.context.options.minify ? this.minifyCss(css) : css
@@ -2244,6 +2268,1234 @@ function buildAnchorPathMap(doc, pageIndexBase = 0) {
2244
2268
  return map;
2245
2269
  }
2246
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
+
2247
3499
  // src/renderer/html/components.ts
2248
3500
  function buildClassString(classes) {
2249
3501
  return classes.filter(Boolean).join(" ");
@@ -2480,45 +3732,6 @@ ${children}
2480
3732
  </div>`;
2481
3733
  }
2482
3734
 
2483
- // src/interaction/target.ts
2484
- function isUrlTarget(target) {
2485
- if (target === void 0) return false;
2486
- const value = target.trim();
2487
- if (value.length === 0 || /\s/.test(value)) return false;
2488
- if (value.startsWith("/") || value.startsWith("#") || value.startsWith("?")) return true;
2489
- return /^[A-Za-z][A-Za-z0-9+.-]*:/.test(value);
2490
- }
2491
-
2492
- // src/renderer/html/interactive.ts
2493
- var EXTERNAL_NAVIGATE_ATTR = "data-navigate-external";
2494
- function interactiveAttrs(node) {
2495
- return {
2496
- "data-navigate": node.navigate,
2497
- [EXTERNAL_NAVIGATE_ATTR]: isUrlTarget(node.navigate) ? true : void 0,
2498
- "data-opens": node.opens,
2499
- "data-toggles": node.toggles,
2500
- "data-action": node.action
2501
- };
2502
- }
2503
- function anchorIntent(node) {
2504
- const attrs2 = interactiveAttrs(node);
2505
- if (node.href) return { href: node.href, attrs: attrs2 };
2506
- if (isUrlTarget(node.navigate)) {
2507
- return {
2508
- href: node.navigate.trim(),
2509
- attrs: {
2510
- ...attrs2,
2511
- "data-navigate": void 0,
2512
- [EXTERNAL_NAVIGATE_ATTR]: void 0
2513
- }
2514
- };
2515
- }
2516
- return { href: "#", attrs: attrs2 };
2517
- }
2518
- function nonAnchorIntent(node) {
2519
- return interactiveAttrs(node);
2520
- }
2521
-
2522
3735
  // src/renderer/html/renderers/text.ts
2523
3736
  function isValueWithUnit2(value) {
2524
3737
  return typeof value === "object" && value !== null && "value" in value && "unit" in value;
@@ -49716,6 +50929,12 @@ var MARKER_COLORS = {
49716
50929
  purple: { bg: "#a855f7", border: "#9333ea" },
49717
50930
  orange: { bg: "#f97316", border: "#ea580c" }
49718
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
+ }
49719
50938
  function getAnchorStyles(anchor) {
49720
50939
  if (!anchor) return "";
49721
50940
  const styles = ["position: absolute"];
@@ -49751,8 +50970,7 @@ function getAnchorStyles(anchor) {
49751
50970
  return styles.join("; ");
49752
50971
  }
49753
50972
  function renderMarker(node, ctx) {
49754
- const color = node.color || "blue";
49755
- const colorConfig = MARKER_COLORS[color] || MARKER_COLORS.blue;
50973
+ const color = markerStyle(node.color, ctx.annotationStyle);
49756
50974
  const baseStyles = [
49757
50975
  "display: inline-flex",
49758
50976
  "align-items: center",
@@ -49760,9 +50978,9 @@ function renderMarker(node, ctx) {
49760
50978
  "width: 20px",
49761
50979
  "height: 20px",
49762
50980
  "border-radius: 50%",
49763
- `background: ${colorConfig.bg}`,
49764
- `border: 2px solid ${colorConfig.border}`,
49765
- "color: white",
50981
+ `background: ${color.bg}`,
50982
+ `border: 2px solid ${color.border}`,
50983
+ `color: ${color.foreground}`,
49766
50984
  "font-size: 11px",
49767
50985
  "font-weight: 600",
49768
50986
  "line-height: 1",
@@ -49793,8 +51011,8 @@ function renderAnnotations(node, ctx) {
49793
51011
  </aside>`;
49794
51012
  }
49795
51013
  function renderAnnotationItem(node, ctx) {
49796
- const color = MARKER_COLORS.blue;
49797
- const markerStyle = [
51014
+ const color = markerStyle("blue", ctx.annotationStyle);
51015
+ const inlineStyle = [
49798
51016
  "display: inline-flex",
49799
51017
  "align-items: center",
49800
51018
  "justify-content: center",
@@ -49802,7 +51020,7 @@ function renderAnnotationItem(node, ctx) {
49802
51020
  "height: 18px",
49803
51021
  "border-radius: 50%",
49804
51022
  `background: ${color.bg}`,
49805
- "color: white",
51023
+ `color: ${color.foreground}`,
49806
51024
  "font-size: 10px",
49807
51025
  "font-weight: 600",
49808
51026
  "flex-shrink: 0"
@@ -49811,7 +51029,7 @@ function renderAnnotationItem(node, ctx) {
49811
51029
  const content = children.length > 0 ? ctx.renderChildren(children) : "";
49812
51030
  return `<div class="${ctx.prefix}-annotation-item">
49813
51031
  <div class="${ctx.prefix}-annotation-item-header">
49814
- <span class="${ctx.prefix}-annotation-marker" style="${markerStyle}">${node.number}</span>
51032
+ <span class="${ctx.prefix}-annotation-marker" style="${inlineStyle}">${node.number}</span>
49815
51033
  <span class="${ctx.prefix}-annotation-item-title">${ctx.escapeHtml(node.title)}</span>
49816
51034
  </div>
49817
51035
  ${content ? `<div class="${ctx.prefix}-annotation-item-content">${content}</div>` : ""}
@@ -49903,6 +51121,7 @@ var HtmlRenderer = class extends BaseRenderer {
49903
51121
  getRenderContext() {
49904
51122
  return {
49905
51123
  prefix: this.prefix,
51124
+ annotationStyle: this.context.options.annotationStyle,
49906
51125
  escapeHtml: this.escapeHtml.bind(this),
49907
51126
  scopedId: this.scopedId.bind(this),
49908
51127
  buildClassString: this.buildClassString.bind(this),
@@ -49983,6 +51202,7 @@ var HtmlRenderer = class extends BaseRenderer {
49983
51202
  // Other
49984
51203
  Divider: (node) => this.renderDivider(node),
49985
51204
  Slot: () => this.renderSlot(),
51205
+ ComponentUse: (node) => this.renderComponentUse(node),
49986
51206
  // Annotation nodes
49987
51207
  Marker: (node) => this.renderMarker(node),
49988
51208
  Annotations: (node) => this.renderAnnotations(node),
@@ -50050,7 +51270,17 @@ ${annotationsContent}
50050
51270
  */
50051
51271
  renderNode(node) {
50052
51272
  const renderer = this.nodeRenderers[node.type];
50053
- 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
+ }
50054
51284
  if (this.pathMap && node.type !== "Page") {
50055
51285
  const path = this.pathMap.get(node);
50056
51286
  if (path !== void 0) {
@@ -50066,6 +51296,18 @@ ${annotationsContent}
50066
51296
  const open = `<div class="${this.prefix}-slot">`;
50067
51297
  return content === null ? `${open}</div>` : `${open}
50068
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}
50069
51311
  </div>`;
50070
51312
  }
50071
51313
  /** Render nodes without adding a page frame, optionally filling a slot. */
@@ -50468,27 +51710,6 @@ function createHtmlRenderer(options) {
50468
51710
  return new HtmlRenderer(options);
50469
51711
  }
50470
51712
 
50471
- // src/renderer/page-renderer.ts
50472
- function renderPage(page, options = {}) {
50473
- const renderer = new HtmlRenderer(options);
50474
- const { html, css } = renderer.render({
50475
- type: "Document",
50476
- children: [page]
50477
- });
50478
- const { width, height } = resolvePageDimensions(page);
50479
- return { html, css, width, height };
50480
- }
50481
- function resolvePageDimensions(page) {
50482
- const pageAny = page;
50483
- const explicitW = page.w ?? pageAny.width;
50484
- const explicitH = page.h ?? pageAny.height;
50485
- if (typeof explicitW === "number" && typeof explicitH === "number") {
50486
- return { width: explicitW, height: explicitH };
50487
- }
50488
- const viewport = resolveViewport(page.viewport, page.device);
50489
- return { width: viewport.width, height: viewport.height };
50490
- }
50491
-
50492
51713
  // src/renderer/canvas-renderer.ts
50493
51714
  var DEFAULT_GAP = 64;
50494
51715
  var DEFAULT_PREFIX = "wf";
@@ -50517,7 +51738,7 @@ function renderCanvas(doc, options = {}) {
50517
51738
  const prefix = options.classPrefix ?? DEFAULT_PREFIX;
50518
51739
  const includeStyles = options.includeStyles !== false;
50519
51740
  const theme = options.theme === "dark" ? darkTheme : defaultTheme;
50520
- const css = includeStyles ? generateStyles(theme, prefix) : "";
51741
+ const css = includeStyles ? generateStyles(theme, prefix, options.annotationStyle) : "";
50521
51742
  const pages = documentPages(doc);
50522
51743
  if (pages.length === 0) {
50523
51744
  return {
@@ -50555,85 +51776,6 @@ function escapeAttr(s) {
50555
51776
  return s.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;");
50556
51777
  }
50557
51778
 
50558
- // src/renderer/site/model.ts
50559
- function pageId(page) {
50560
- const id = page.id?.trim();
50561
- return id && id.length > 0 ? id : void 0;
50562
- }
50563
- function pageTitle(page) {
50564
- const title = page.title?.trim();
50565
- return title && title.length > 0 ? title : void 0;
50566
- }
50567
- function hasSlot(layout) {
50568
- for (const child of layout.children) {
50569
- let found = false;
50570
- walk(child, (node) => {
50571
- if (node.type === "Slot") found = true;
50572
- return !found;
50573
- });
50574
- if (found) return true;
50575
- }
50576
- return false;
50577
- }
50578
- function layoutsByName(doc) {
50579
- const layouts = /* @__PURE__ */ new Map();
50580
- for (const definition of documentDefinitions(doc)) {
50581
- const name = definition.name.trim();
50582
- if (name.length > 0 && !layouts.has(name)) layouts.set(name, definition);
50583
- }
50584
- return layouts;
50585
- }
50586
- function resolveShell(page, layouts) {
50587
- const uses = page.uses?.trim();
50588
- if (!uses) return void 0;
50589
- const layout = layouts.get(uses);
50590
- if (!layout) return { miss: { uses, reason: "unknown-layout" } };
50591
- if (!hasSlot(layout)) return { miss: { uses, reason: "slotless-layout" } };
50592
- return { layout, name: uses };
50593
- }
50594
- function buildSiteModel(doc) {
50595
- const screens = documentPages(doc).map((page, index) => ({ index, page }));
50596
- const layouts = layoutsByName(doc);
50597
- const shells = [];
50598
- const shellByName = /* @__PURE__ */ new Map();
50599
- for (const screen of screens) {
50600
- const resolved = resolveShell(screen.page, layouts);
50601
- if (!resolved) continue;
50602
- if ("miss" in resolved) {
50603
- screen.miss = resolved.miss;
50604
- continue;
50605
- }
50606
- let shell = shellByName.get(resolved.name);
50607
- if (!shell) {
50608
- const { width, height } = resolvePageDimensions(screen.page);
50609
- shell = { name: resolved.name, layout: resolved.layout, screens: [], width, height };
50610
- shellByName.set(resolved.name, shell);
50611
- shells.push(shell);
50612
- }
50613
- shell.screens.push(screen);
50614
- screen.shell = shell.name;
50615
- }
50616
- const names = /* @__PURE__ */ new Map();
50617
- for (const screen of screens) {
50618
- const title = pageTitle(screen.page);
50619
- if (title !== void 0 && !names.has(title)) names.set(title, screen.index);
50620
- }
50621
- for (const screen of screens) {
50622
- const id = pageId(screen.page);
50623
- if (id === void 0) continue;
50624
- const owner = names.get(id);
50625
- if (owner === void 0 || pageId(screens[owner].page) !== id) {
50626
- names.set(id, screen.index);
50627
- }
50628
- }
50629
- for (const screen of screens) {
50630
- screen.name = [pageId(screen.page), pageTitle(screen.page)].find(
50631
- (name) => name !== void 0 && names.get(name) === screen.index
50632
- );
50633
- }
50634
- return { screens, shells, names, entry: screens.length > 0 ? 0 : -1 };
50635
- }
50636
-
50637
51779
  // src/renderer/site/styles.ts
50638
51780
  function generateSiteStyles(prefix) {
50639
51781
  return `
@@ -50731,6 +51873,61 @@ function siteRuntime(registry, prefix) {
50731
51873
  }
50732
51874
  }
50733
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
+ }
50734
51931
 
50735
51932
  function isChrome(el) {
50736
51933
  return !(el.closest && el.closest('[data-screen]'));
@@ -50797,6 +51994,60 @@ function siteRuntime(registry, prefix) {
50797
51994
  }
50798
51995
  }
50799
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
+
50800
52051
  function markActive(key) {
50801
52052
  for (var i = 0; i < shells.length; i++) {
50802
52053
  var links = shells[i].querySelectorAll('[data-navigate]');
@@ -50824,6 +52075,7 @@ function siteRuntime(registry, prefix) {
50824
52075
  current = key;
50825
52076
  closeOverlays(key);
50826
52077
  markActive(key);
52078
+ applyOutcomes();
50827
52079
  if (writeFragment) {
50828
52080
  var fragment = R.fragments[Number(key)] || key;
50829
52081
  if (location.hash.slice(1) !== fragment) location.hash = fragment;
@@ -50840,6 +52092,22 @@ function siteRuntime(registry, prefix) {
50840
52092
 
50841
52093
  document.addEventListener('click', function (event) {
50842
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
+
50843
52111
  var mover = target.closest ? target.closest('[data-navigate]') : null;
50844
52112
  if (mover) {
50845
52113
  var destination = resolve(mover.getAttribute('data-navigate'));
@@ -50878,6 +52146,7 @@ function siteRuntime(registry, prefix) {
50878
52146
  closeOverlays(current);
50879
52147
  return;
50880
52148
  }
52149
+ if (action !== '') diagnostic('unknown-action', action);
50881
52150
  }
50882
52151
 
50883
52152
  if (target.classList && target.classList.contains(P + '-modal-backdrop')) {
@@ -50895,6 +52164,7 @@ function siteRuntime(registry, prefix) {
50895
52164
  if (key !== null) show(key, false);
50896
52165
  });
50897
52166
 
52167
+ initOverlays();
50898
52168
  var start = fromFragment();
50899
52169
  if (start === null) start = String(R.entry);
50900
52170
  if (!show(start, false)) show(String(R.entry), false);
@@ -50970,13 +52240,43 @@ function resolveTitle(model, options, entry) {
50970
52240
  const title = model.screens[entry]?.page.title?.trim();
50971
52241
  return title || "Wireframe";
50972
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
+ }
50973
52271
  function renderSite(document, options = {}) {
50974
52272
  const prefix = options.classPrefix ?? DEFAULT_PREFIX2;
50975
52273
  const model = buildSiteModel(document);
52274
+ const interactionModel = collectInteractions(document);
50976
52275
  const make = (idScope) => new HtmlRenderer({
50977
52276
  theme: options.theme,
50978
52277
  classPrefix: prefix,
50979
52278
  background: options.background,
52279
+ annotationStyle: options.annotationStyle,
50980
52280
  includeStyles: false,
50981
52281
  idScope
50982
52282
  });
@@ -50984,12 +52284,16 @@ function renderSite(document, options = {}) {
50984
52284
  const standalone = model.screens.filter((screen) => screen.shell === void 0).map((screen) => renderStandaloneScreen(screen, make, prefix)).join("\n");
50985
52285
  const entry = resolveEntry(model, options);
50986
52286
  const theme = options.theme === "dark" ? darkTheme : defaultTheme;
50987
- const css = generateStyles(theme, prefix) + generateSiteStyles(prefix);
52287
+ const css = generateStyles(theme, prefix, options.annotationStyle) + generateSiteStyles(prefix);
52288
+ const runtimeInteractions = compactRuntimeInteractions(model, interactionModel.interactions);
50988
52289
  const runtime = siteRuntime(
50989
52290
  {
50990
52291
  names: Object.fromEntries(model.names),
50991
52292
  fragments: model.screens.map((screen) => screen.name ?? String(screen.index)),
50992
- entry: entry.index
52293
+ entry: entry.index,
52294
+ states: interactionModel.states,
52295
+ ...runtimeInteractions,
52296
+ diagnostics: interactionModel.diagnostics
50993
52297
  },
50994
52298
  prefix
50995
52299
  );
@@ -50997,7 +52301,8 @@ function renderSite(document, options = {}) {
50997
52301
  const siteAttrs = attrs([
50998
52302
  ["data-screen-count", String(model.screens.length)],
50999
52303
  ["data-shell-count", String(model.shells.length)],
51000
- ["data-wf-entry-unresolved", entry.unresolved]
52304
+ ["data-wf-entry-unresolved", entry.unresolved],
52305
+ ["data-wf-diagnostic-count", String(interactionModel.diagnostics.length)]
51001
52306
  ]);
51002
52307
  return `<!DOCTYPE html>
51003
52308
  <html lang="en">