@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.js CHANGED
@@ -2,6 +2,15 @@
2
2
  function hasChildren(node) {
3
3
  return "children" in node && Array.isArray(node.children);
4
4
  }
5
+ function isDropdownNode(node) {
6
+ return node.type === "Dropdown";
7
+ }
8
+ function isNavNode(node) {
9
+ return node.type === "Nav";
10
+ }
11
+ function isBreadcrumbNode(node) {
12
+ return node.type === "Breadcrumb";
13
+ }
5
14
 
6
15
  // src/ast/utils.ts
7
16
  function walk(node, callback, parent, depth = 0) {
@@ -1423,7 +1432,17 @@ function generateDividerStyles(prefix = "wf") {
1423
1432
  }
1424
1433
 
1425
1434
  // src/renderer/styles/annotation.ts
1426
- function generateAnnotationStyles(_theme, prefix) {
1435
+ function generateAnnotationStyles(_theme, prefix, annotationStyle = "legacy") {
1436
+ const neutral = annotationStyle === "neutral";
1437
+ const markerBackground = neutral ? "#000000" : "#3b82f6";
1438
+ const markerBorder = neutral ? "#000000" : "#2563eb";
1439
+ const markerColor = neutral ? "#FFFFFF" : "white";
1440
+ const panelBackground = neutral ? "#FAFAFA" : "#fafafa";
1441
+ const panelBorder = neutral ? "#888888" : "#d1d5db";
1442
+ const headerColor = neutral ? "#666666" : "#6b7280";
1443
+ const headerBorder = neutral ? "#CCCCCC" : "#e5e7eb";
1444
+ const titleColor = neutral ? "#333333" : "#374151";
1445
+ const contentColor = neutral ? "#666666" : "#6b7280";
1427
1446
  return `/* Annotation Components */
1428
1447
 
1429
1448
  /* Marker - Number marker for referencing */
@@ -1434,9 +1453,9 @@ function generateAnnotationStyles(_theme, prefix) {
1434
1453
  width: 20px;
1435
1454
  height: 20px;
1436
1455
  border-radius: 50%;
1437
- background: #3b82f6;
1438
- border: 2px solid #2563eb;
1439
- color: white;
1456
+ background: ${markerBackground};
1457
+ border: 2px solid ${markerBorder};
1458
+ color: ${markerColor};
1440
1459
  font-size: 11px;
1441
1460
  font-weight: 600;
1442
1461
  line-height: 1;
@@ -1452,8 +1471,8 @@ function generateAnnotationStyles(_theme, prefix) {
1452
1471
  /* Annotations Panel - Documentation container */
1453
1472
  .${prefix}-annotations {
1454
1473
  margin-top: 16px;
1455
- background: #fafafa;
1456
- border: 2px dashed #d1d5db;
1474
+ background: ${panelBackground};
1475
+ border: 2px dashed ${panelBorder};
1457
1476
  border-radius: 8px;
1458
1477
  padding: 16px;
1459
1478
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
@@ -1465,10 +1484,10 @@ function generateAnnotationStyles(_theme, prefix) {
1465
1484
  gap: 8px;
1466
1485
  font-weight: 600;
1467
1486
  font-size: 14px;
1468
- color: #6b7280;
1487
+ color: ${headerColor};
1469
1488
  margin-bottom: 16px;
1470
1489
  padding-bottom: 8px;
1471
- border-bottom: 1px solid #e5e7eb;
1490
+ border-bottom: 1px solid ${headerBorder};
1472
1491
  }
1473
1492
 
1474
1493
  .${prefix}-annotations-icon {
@@ -1501,8 +1520,8 @@ function generateAnnotationStyles(_theme, prefix) {
1501
1520
  width: 18px;
1502
1521
  height: 18px;
1503
1522
  border-radius: 50%;
1504
- background: #3b82f6;
1505
- color: white;
1523
+ background: ${markerBackground};
1524
+ color: ${markerColor};
1506
1525
  font-size: 10px;
1507
1526
  font-weight: 600;
1508
1527
  flex-shrink: 0;
@@ -1511,13 +1530,13 @@ function generateAnnotationStyles(_theme, prefix) {
1511
1530
  .${prefix}-annotation-item-title {
1512
1531
  font-weight: 500;
1513
1532
  font-size: 13px;
1514
- color: #374151;
1533
+ color: ${titleColor};
1515
1534
  }
1516
1535
 
1517
1536
  .${prefix}-annotation-item-content {
1518
1537
  padding-left: 26px;
1519
1538
  font-size: 12px;
1520
- color: #6b7280;
1539
+ color: ${contentColor};
1521
1540
  line-height: 1.5;
1522
1541
  }
1523
1542
 
@@ -1525,12 +1544,12 @@ function generateAnnotationStyles(_theme, prefix) {
1525
1544
  .${prefix}-annotation-item-content .${prefix}-text {
1526
1545
  margin: 0;
1527
1546
  font-size: 12px;
1528
- color: #6b7280;
1547
+ color: ${contentColor};
1529
1548
  }`;
1530
1549
  }
1531
1550
 
1532
1551
  // src/renderer/styles-components.ts
1533
- function generateComponentStyles(_theme, prefix = "wf") {
1552
+ function generateComponentStyles(_theme, prefix = "wf", annotationStyle = "legacy") {
1534
1553
  const parts = [
1535
1554
  generateContainerStyles(prefix),
1536
1555
  generateTextStyles(prefix),
@@ -1544,13 +1563,13 @@ function generateComponentStyles(_theme, prefix = "wf") {
1544
1563
  generateSemanticMarkerStyles(_theme, prefix),
1545
1564
  generateAccessibilityStyles(prefix),
1546
1565
  generateDividerStyles(prefix),
1547
- generateAnnotationStyles(_theme, prefix)
1566
+ generateAnnotationStyles(_theme, prefix, annotationStyle)
1548
1567
  ];
1549
1568
  return parts.join("\n\n");
1550
1569
  }
1551
1570
 
1552
1571
  // src/renderer/styles.ts
1553
- function generateStyles(theme, prefix = "wf") {
1572
+ function generateStyles(theme, prefix = "wf", annotationStyle = "legacy") {
1554
1573
  const parts = [
1555
1574
  generateCssVariables(theme, prefix),
1556
1575
  generateBaseStyles(prefix),
@@ -1559,7 +1578,7 @@ function generateStyles(theme, prefix = "wf") {
1559
1578
  generateFlexClasses(prefix),
1560
1579
  generateSizeClasses(prefix),
1561
1580
  generateLayoutClasses(prefix),
1562
- generateComponentStyles(theme, prefix)
1581
+ generateComponentStyles(theme, prefix, annotationStyle)
1563
1582
  ];
1564
1583
  return parts.join("\n\n");
1565
1584
  }
@@ -1976,6 +1995,7 @@ var DEFAULT_OPTIONS = {
1976
1995
  includeStyles: true,
1977
1996
  minify: false,
1978
1997
  classPrefix: "wf",
1998
+ annotationStyle: "legacy",
1979
1999
  sourceAnchors: false,
1980
2000
  idScope: ""
1981
2001
  };
@@ -2006,7 +2026,11 @@ var BaseRenderer = class {
2006
2026
  */
2007
2027
  render(document) {
2008
2028
  const html = this.renderDocument(document);
2009
- const css = this.context.options.includeStyles ? generateStyles(this.context.theme, this.context.options.classPrefix) : "";
2029
+ const css = this.context.options.includeStyles ? generateStyles(
2030
+ this.context.theme,
2031
+ this.context.options.classPrefix,
2032
+ this.context.options.annotationStyle
2033
+ ) : "";
2010
2034
  return {
2011
2035
  html: this.context.options.minify ? this.minifyHtml(html) : html,
2012
2036
  css: this.context.options.minify ? this.minifyCss(css) : css
@@ -2198,6 +2222,1234 @@ function buildAnchorPathMap(doc, pageIndexBase = 0) {
2198
2222
  return map;
2199
2223
  }
2200
2224
 
2225
+ // src/spec/attributes.ts
2226
+ var ATTRIBUTE_SPECS = [
2227
+ // ============================================
2228
+ // Spacing Attributes
2229
+ // ============================================
2230
+ { name: "p", type: "number", description: "Padding (all sides)" },
2231
+ { name: "px", type: "number", description: "Horizontal padding" },
2232
+ { name: "py", type: "number", description: "Vertical padding" },
2233
+ { name: "pt", type: "number", description: "Top padding" },
2234
+ { name: "pr", type: "number", description: "Right padding" },
2235
+ { name: "pb", type: "number", description: "Bottom padding" },
2236
+ { name: "pl", type: "number", description: "Left padding" },
2237
+ { name: "m", type: "number", description: "Margin (all sides)" },
2238
+ { name: "mx", type: "string", description: 'Horizontal margin (number or "auto")' },
2239
+ { name: "my", type: "number", description: "Vertical margin" },
2240
+ { name: "mt", type: "number", description: "Top margin" },
2241
+ { name: "mr", type: "number", description: "Right margin" },
2242
+ { name: "mb", type: "number", description: "Bottom margin" },
2243
+ { name: "ml", type: "number", description: "Left margin" },
2244
+ { name: "gap", type: "number", description: "Gap between children" },
2245
+ // ============================================
2246
+ // Size Attributes
2247
+ // ============================================
2248
+ { name: "w", type: "string", description: 'Width (number, "full", "auto", "screen", "fit")' },
2249
+ { name: "h", type: "string", description: 'Height (number, "full", "auto", "screen")' },
2250
+ { name: "width", type: "number", description: "Width in pixels (page only)" },
2251
+ { name: "height", type: "number", description: "Height in pixels (page only)" },
2252
+ { name: "minW", type: "number", description: "Minimum width" },
2253
+ { name: "maxW", type: "number", description: "Maximum width" },
2254
+ { name: "minH", type: "number", description: "Minimum height" },
2255
+ { name: "maxH", type: "number", description: "Maximum height" },
2256
+ // ============================================
2257
+ // Flex/Grid Layout Attributes
2258
+ // ============================================
2259
+ { name: "flex", type: "boolean", description: "Enable flexbox" },
2260
+ {
2261
+ name: "direction",
2262
+ type: "enum",
2263
+ values: ["row", "column", "row-reverse", "column-reverse"],
2264
+ description: "Flex direction"
2265
+ },
2266
+ {
2267
+ name: "justify",
2268
+ type: "enum",
2269
+ values: ["start", "center", "end", "between", "around", "evenly"],
2270
+ description: "Main axis alignment"
2271
+ },
2272
+ {
2273
+ name: "align",
2274
+ type: "enum",
2275
+ values: ["start", "center", "end", "stretch", "baseline"],
2276
+ description: "Cross axis alignment"
2277
+ },
2278
+ { name: "wrap", type: "boolean", description: "Enable flex wrap" },
2279
+ { name: "span", type: "number", description: "Grid column span (1-12)" },
2280
+ { name: "sm", type: "number", description: "Responsive span at 576px+" },
2281
+ { name: "md", type: "number", description: "Responsive span at 768px+" },
2282
+ { name: "lg", type: "number", description: "Responsive span at 992px+" },
2283
+ { name: "xl", type: "number", description: "Responsive span at 1200px+" },
2284
+ { name: "order", type: "number", description: "Flex order" },
2285
+ // ============================================
2286
+ // Position Attributes
2287
+ // ============================================
2288
+ { name: "x", type: "number", description: "Horizontal position" },
2289
+ { name: "y", type: "number", description: "Vertical position" },
2290
+ {
2291
+ name: "position",
2292
+ type: "enum",
2293
+ values: [
2294
+ "left",
2295
+ "right",
2296
+ "top",
2297
+ "bottom",
2298
+ "top-left",
2299
+ "top-center",
2300
+ "top-right",
2301
+ "bottom-left",
2302
+ "bottom-center",
2303
+ "bottom-right"
2304
+ ],
2305
+ description: "Position preset"
2306
+ },
2307
+ // ============================================
2308
+ // Visual Attributes
2309
+ // ============================================
2310
+ { name: "border", type: "boolean", description: "Show border" },
2311
+ { name: "rounded", type: "boolean", description: "Apply border radius" },
2312
+ {
2313
+ name: "shadow",
2314
+ type: "enum",
2315
+ values: ["none", "sm", "md", "lg", "xl"],
2316
+ description: "Box shadow"
2317
+ },
2318
+ {
2319
+ name: "bg",
2320
+ type: "enum",
2321
+ values: ["muted", "primary", "secondary"],
2322
+ description: "Background variant"
2323
+ },
2324
+ // ============================================
2325
+ // Text Attributes
2326
+ // ============================================
2327
+ {
2328
+ name: "size",
2329
+ type: "enum",
2330
+ values: ["xs", "sm", "base", "md", "lg", "xl", "2xl", "3xl"],
2331
+ description: "Size preset"
2332
+ },
2333
+ {
2334
+ name: "weight",
2335
+ type: "enum",
2336
+ values: ["normal", "medium", "semibold", "bold"],
2337
+ description: "Font weight"
2338
+ },
2339
+ { name: "level", type: "number", description: "Heading level (1-6)" },
2340
+ { name: "muted", type: "boolean", description: "Muted/dimmed style" },
2341
+ { name: "bold", type: "boolean", description: "Bold text" },
2342
+ // ============================================
2343
+ // Button Variant Attributes
2344
+ // ============================================
2345
+ { name: "primary", type: "boolean", description: "Primary style" },
2346
+ { name: "secondary", type: "boolean", description: "Secondary style" },
2347
+ { name: "outline", type: "boolean", description: "Outline style" },
2348
+ { name: "ghost", type: "boolean", description: "Ghost/transparent style" },
2349
+ { name: "danger", type: "boolean", description: "Danger/destructive style" },
2350
+ // ============================================
2351
+ // Status Variant Attributes
2352
+ // ============================================
2353
+ {
2354
+ name: "variant",
2355
+ type: "enum",
2356
+ values: ["default", "primary", "secondary", "success", "warning", "danger", "info"],
2357
+ description: "Status variant"
2358
+ },
2359
+ // ============================================
2360
+ // Form Attributes
2361
+ // ============================================
2362
+ {
2363
+ name: "inputType",
2364
+ type: "enum",
2365
+ values: ["text", "email", "password", "number", "tel", "url", "search", "date"],
2366
+ description: "Input field type"
2367
+ },
2368
+ { name: "placeholder", type: "string", description: "Placeholder text" },
2369
+ { name: "value", type: "string", description: "Default value" },
2370
+ { name: "label", type: "string", description: "Field label" },
2371
+ { name: "name", type: "string", description: "Form field name" },
2372
+ { name: "required", type: "boolean", description: "Required field" },
2373
+ { name: "disabled", type: "boolean", description: "Disabled state" },
2374
+ { name: "readonly", type: "boolean", description: "Read-only state" },
2375
+ { name: "checked", type: "boolean", description: "Checked state" },
2376
+ { name: "loading", type: "boolean", description: "Loading state" },
2377
+ { name: "rows", type: "number", description: "Textarea rows" },
2378
+ { name: "min", type: "number", description: "Minimum value" },
2379
+ { name: "max", type: "number", description: "Maximum value" },
2380
+ { name: "step", type: "number", description: "Step increment" },
2381
+ // ============================================
2382
+ // Content Attributes
2383
+ // ============================================
2384
+ { name: "title", type: "string", description: "Title text" },
2385
+ { name: "src", type: "string", description: "Source URL" },
2386
+ { name: "alt", type: "string", description: "Alt text" },
2387
+ { name: "href", type: "string", description: "Link URL" },
2388
+ { name: "icon", type: "string", description: "Icon name" },
2389
+ { name: "external", type: "boolean", description: "External link" },
2390
+ // ============================================
2391
+ // Accessibility Attributes
2392
+ // ============================================
2393
+ {
2394
+ name: "aria",
2395
+ type: "string",
2396
+ description: "Accessible name, rendered as aria-label (e.g. icon-only button)"
2397
+ },
2398
+ {
2399
+ name: "aria-label",
2400
+ type: "string",
2401
+ description: "Accessible name (synonym for aria), rendered as aria-label"
2402
+ },
2403
+ // ============================================
2404
+ // State Attributes
2405
+ // ============================================
2406
+ { name: "active", type: "number", description: "Active index" },
2407
+ { name: "expanded", type: "boolean", description: "Expanded state" },
2408
+ { name: "centered", type: "boolean", description: "Center content" },
2409
+ { name: "vertical", type: "boolean", description: "Vertical orientation" },
2410
+ { name: "scroll", type: "boolean", description: "Enable scrolling" },
2411
+ // ============================================
2412
+ // Feedback Attributes
2413
+ // ============================================
2414
+ { name: "dismissible", type: "boolean", description: "Can be dismissed" },
2415
+ { name: "indeterminate", type: "boolean", description: "Indeterminate state" },
2416
+ { name: "pill", type: "boolean", description: "Pill/rounded style" },
2417
+ // ============================================
2418
+ // Data Attributes
2419
+ // ============================================
2420
+ { name: "striped", type: "boolean", description: "Striped rows" },
2421
+ { name: "bordered", type: "boolean", description: "Full borders" },
2422
+ { name: "hover", type: "boolean", description: "Hover effect" },
2423
+ { name: "ordered", type: "boolean", description: "Ordered list" },
2424
+ { name: "none", type: "boolean", description: "No list markers" },
2425
+ // ============================================
2426
+ // Page/Viewport Attributes
2427
+ // ============================================
2428
+ { name: "viewport", type: "string", description: 'Viewport size (e.g., "1440x900")' },
2429
+ { name: "device", type: "string", description: "Device preset" },
2430
+ { name: "id", type: "string", description: "Stable identifier for a page or overlay" },
2431
+ { name: "uses", type: "string", description: "Name of the layout a page is drawn inside" },
2432
+ { name: "navigate", type: "string", description: "Screen id, title, or URL to navigate to" },
2433
+ { name: "opens", type: "string", description: "Overlay id to open" },
2434
+ { name: "toggles", type: "string", description: "Overlay id to toggle" },
2435
+ { name: "action", type: "string", description: "Named legacy interaction action" },
2436
+ {
2437
+ name: "on",
2438
+ type: "object",
2439
+ description: "Typed click event with an optional equality guard and ordered effects"
2440
+ },
2441
+ {
2442
+ name: "visibleWhen",
2443
+ type: "object",
2444
+ description: "Equality guard controlling whether this branch is visible"
2445
+ },
2446
+ {
2447
+ name: "enabledWhen",
2448
+ type: "object",
2449
+ description: "Equality guard controlling whether this control is enabled"
2450
+ },
2451
+ {
2452
+ name: "states",
2453
+ type: "object[]",
2454
+ description: "Typed application state declarations owned by a page or shared layout"
2455
+ }
2456
+ ];
2457
+ var VALID_ATTRIBUTE_NAMES = new Set(
2458
+ ATTRIBUTE_SPECS.map((attr) => attr.name)
2459
+ );
2460
+ var ATTRIBUTE_MAP = new Map(
2461
+ ATTRIBUTE_SPECS.map((attr) => [attr.name, attr])
2462
+ );
2463
+ var COMMON_ATTRIBUTES = [
2464
+ // Spacing
2465
+ "p",
2466
+ "px",
2467
+ "py",
2468
+ "pt",
2469
+ "pr",
2470
+ "pb",
2471
+ "pl",
2472
+ "m",
2473
+ "mx",
2474
+ "my",
2475
+ "mt",
2476
+ "mr",
2477
+ "mb",
2478
+ "ml",
2479
+ "gap",
2480
+ // Size
2481
+ "w",
2482
+ "h",
2483
+ "minW",
2484
+ "maxW",
2485
+ "minH",
2486
+ "maxH",
2487
+ // Flex
2488
+ "flex",
2489
+ "direction",
2490
+ "justify",
2491
+ "align",
2492
+ "wrap",
2493
+ // Grid
2494
+ "span",
2495
+ // Position
2496
+ "x",
2497
+ "y",
2498
+ // State-controlled outcomes
2499
+ "visibleWhen",
2500
+ "enabledWhen"
2501
+ ];
2502
+ var INTERACTIVE_ATTRIBUTES = [
2503
+ "navigate",
2504
+ "opens",
2505
+ "toggles",
2506
+ "action",
2507
+ "on"
2508
+ ];
2509
+
2510
+ // src/spec/components.ts
2511
+ var COMPONENT_SPECS = [
2512
+ // ============================================
2513
+ // Layout Components
2514
+ // ============================================
2515
+ {
2516
+ name: "page",
2517
+ nodeType: "Page",
2518
+ category: "layout",
2519
+ attributes: [
2520
+ ...COMMON_ATTRIBUTES,
2521
+ "title",
2522
+ "width",
2523
+ "height",
2524
+ "viewport",
2525
+ "device",
2526
+ "centered",
2527
+ "id",
2528
+ "uses",
2529
+ "states"
2530
+ ],
2531
+ hasChildren: true,
2532
+ description: "Root container for a wireframe page"
2533
+ },
2534
+ {
2535
+ name: "layout",
2536
+ nodeType: "Layout",
2537
+ category: "layout",
2538
+ attributes: ["states"],
2539
+ hasChildren: true,
2540
+ description: "Named page shell containing a slot for page content"
2541
+ },
2542
+ {
2543
+ name: "component",
2544
+ nodeType: "Component",
2545
+ category: "layout",
2546
+ attributes: [],
2547
+ hasChildren: true,
2548
+ description: "Named reusable component definition with typed inputs and slots"
2549
+ },
2550
+ {
2551
+ name: "use",
2552
+ nodeType: "ComponentUse",
2553
+ category: "layout",
2554
+ attributes: [],
2555
+ hasChildren: true,
2556
+ description: "Explicit reusable component invocation with named inputs and fills"
2557
+ },
2558
+ {
2559
+ name: "slot",
2560
+ nodeType: "Slot",
2561
+ category: "layout",
2562
+ attributes: [],
2563
+ hasChildren: false,
2564
+ description: "Position where a layout hosts page content"
2565
+ },
2566
+ {
2567
+ name: "header",
2568
+ nodeType: "Header",
2569
+ category: "layout",
2570
+ attributes: [...COMMON_ATTRIBUTES, "border"],
2571
+ hasChildren: true,
2572
+ description: "Page header section"
2573
+ },
2574
+ {
2575
+ name: "main",
2576
+ nodeType: "Main",
2577
+ category: "layout",
2578
+ attributes: [...COMMON_ATTRIBUTES, "scroll"],
2579
+ hasChildren: true,
2580
+ description: "Main content section"
2581
+ },
2582
+ {
2583
+ name: "footer",
2584
+ nodeType: "Footer",
2585
+ category: "layout",
2586
+ attributes: [...COMMON_ATTRIBUTES, "border"],
2587
+ hasChildren: true,
2588
+ description: "Page footer section"
2589
+ },
2590
+ {
2591
+ name: "sidebar",
2592
+ nodeType: "Sidebar",
2593
+ category: "layout",
2594
+ attributes: [...COMMON_ATTRIBUTES, "position", "border", "bg"],
2595
+ hasChildren: true,
2596
+ description: "Side navigation or content area"
2597
+ },
2598
+ {
2599
+ name: "section",
2600
+ nodeType: "Section",
2601
+ category: "layout",
2602
+ attributes: [...COMMON_ATTRIBUTES, "title", "expanded"],
2603
+ hasChildren: true,
2604
+ description: "Grouped content section"
2605
+ },
2606
+ // ============================================
2607
+ // Grid Components
2608
+ // ============================================
2609
+ {
2610
+ name: "row",
2611
+ nodeType: "Row",
2612
+ category: "grid",
2613
+ attributes: [...COMMON_ATTRIBUTES, "border", "bg"],
2614
+ hasChildren: true,
2615
+ description: "Horizontal flex container"
2616
+ },
2617
+ {
2618
+ name: "col",
2619
+ nodeType: "Col",
2620
+ category: "grid",
2621
+ attributes: [...COMMON_ATTRIBUTES, "sm", "md", "lg", "xl", "order", "border", "bg", "scroll"],
2622
+ hasChildren: true,
2623
+ description: "Vertical flex container or grid column"
2624
+ },
2625
+ {
2626
+ name: "stack",
2627
+ nodeType: "Stack",
2628
+ category: "grid",
2629
+ attributes: [...COMMON_ATTRIBUTES, "border", "bg"],
2630
+ hasChildren: true,
2631
+ description: "Vertical stack that only takes content height"
2632
+ },
2633
+ {
2634
+ name: "relative",
2635
+ nodeType: "Relative",
2636
+ category: "grid",
2637
+ attributes: [...COMMON_ATTRIBUTES],
2638
+ hasChildren: true,
2639
+ description: "Container for overlaying elements with absolute positioning"
2640
+ },
2641
+ // ============================================
2642
+ // Container Components
2643
+ // ============================================
2644
+ {
2645
+ name: "card",
2646
+ nodeType: "Card",
2647
+ category: "container",
2648
+ attributes: [
2649
+ ...COMMON_ATTRIBUTES,
2650
+ ...INTERACTIVE_ATTRIBUTES,
2651
+ "title",
2652
+ "shadow",
2653
+ "border",
2654
+ "rounded"
2655
+ ],
2656
+ hasChildren: true,
2657
+ description: "Card container with optional title"
2658
+ },
2659
+ {
2660
+ name: "modal",
2661
+ nodeType: "Modal",
2662
+ category: "container",
2663
+ attributes: [...COMMON_ATTRIBUTES, "title", "id"],
2664
+ hasChildren: true,
2665
+ description: "Modal dialog overlay"
2666
+ },
2667
+ {
2668
+ name: "drawer",
2669
+ nodeType: "Drawer",
2670
+ category: "container",
2671
+ attributes: [...COMMON_ATTRIBUTES, "title", "position", "id"],
2672
+ hasChildren: true,
2673
+ description: "Slide-in drawer panel"
2674
+ },
2675
+ {
2676
+ name: "accordion",
2677
+ nodeType: "Accordion",
2678
+ category: "container",
2679
+ attributes: [...COMMON_ATTRIBUTES, "title"],
2680
+ hasChildren: true,
2681
+ description: "Collapsible sections container"
2682
+ },
2683
+ // ============================================
2684
+ // Text Components
2685
+ // ============================================
2686
+ {
2687
+ name: "text",
2688
+ nodeType: "Text",
2689
+ category: "text",
2690
+ attributes: [...COMMON_ATTRIBUTES, "size", "weight", "muted", "bold"],
2691
+ hasChildren: false,
2692
+ description: "Text content"
2693
+ },
2694
+ {
2695
+ name: "title",
2696
+ nodeType: "Title",
2697
+ category: "text",
2698
+ attributes: [...COMMON_ATTRIBUTES, "level", "size"],
2699
+ hasChildren: false,
2700
+ description: "Heading element (h1-h6)"
2701
+ },
2702
+ {
2703
+ name: "link",
2704
+ nodeType: "Link",
2705
+ category: "text",
2706
+ attributes: [...COMMON_ATTRIBUTES, ...INTERACTIVE_ATTRIBUTES, "href", "external"],
2707
+ hasChildren: false,
2708
+ description: "Hyperlink text"
2709
+ },
2710
+ // ============================================
2711
+ // Input Components
2712
+ // ============================================
2713
+ {
2714
+ name: "input",
2715
+ nodeType: "Input",
2716
+ category: "input",
2717
+ attributes: [
2718
+ ...COMMON_ATTRIBUTES,
2719
+ ...INTERACTIVE_ATTRIBUTES,
2720
+ "label",
2721
+ "inputType",
2722
+ "placeholder",
2723
+ "value",
2724
+ "disabled",
2725
+ "required",
2726
+ "readonly",
2727
+ "icon",
2728
+ "size",
2729
+ "rounded"
2730
+ ],
2731
+ hasChildren: false,
2732
+ description: "Text input field"
2733
+ },
2734
+ {
2735
+ name: "textarea",
2736
+ nodeType: "Textarea",
2737
+ category: "input",
2738
+ attributes: [
2739
+ ...COMMON_ATTRIBUTES,
2740
+ "label",
2741
+ "placeholder",
2742
+ "value",
2743
+ "rows",
2744
+ "disabled",
2745
+ "required"
2746
+ ],
2747
+ hasChildren: false,
2748
+ description: "Multi-line text input"
2749
+ },
2750
+ {
2751
+ name: "select",
2752
+ nodeType: "Select",
2753
+ category: "input",
2754
+ attributes: [...COMMON_ATTRIBUTES, "label", "placeholder", "value", "disabled", "required"],
2755
+ hasChildren: false,
2756
+ description: "Dropdown select"
2757
+ },
2758
+ {
2759
+ name: "checkbox",
2760
+ nodeType: "Checkbox",
2761
+ category: "input",
2762
+ attributes: [...COMMON_ATTRIBUTES, "label", "checked", "disabled"],
2763
+ hasChildren: false,
2764
+ description: "Checkbox input"
2765
+ },
2766
+ {
2767
+ name: "radio",
2768
+ nodeType: "Radio",
2769
+ category: "input",
2770
+ attributes: [...COMMON_ATTRIBUTES, "label", "name", "checked", "disabled"],
2771
+ hasChildren: false,
2772
+ description: "Radio button input"
2773
+ },
2774
+ {
2775
+ name: "switch",
2776
+ nodeType: "Switch",
2777
+ category: "input",
2778
+ attributes: [...COMMON_ATTRIBUTES, "label", "checked", "disabled"],
2779
+ hasChildren: false,
2780
+ description: "Toggle switch"
2781
+ },
2782
+ {
2783
+ name: "slider",
2784
+ nodeType: "Slider",
2785
+ category: "input",
2786
+ attributes: [...COMMON_ATTRIBUTES, "label", "min", "max", "value", "step", "disabled"],
2787
+ hasChildren: false,
2788
+ description: "Range slider"
2789
+ },
2790
+ {
2791
+ name: "button",
2792
+ nodeType: "Button",
2793
+ category: "input",
2794
+ attributes: [
2795
+ ...COMMON_ATTRIBUTES,
2796
+ ...INTERACTIVE_ATTRIBUTES,
2797
+ "primary",
2798
+ "secondary",
2799
+ "outline",
2800
+ "ghost",
2801
+ "danger",
2802
+ "size",
2803
+ "icon",
2804
+ "disabled",
2805
+ "loading",
2806
+ // Accessibility: give icon-only buttons an accessible name / tooltip
2807
+ "aria",
2808
+ "aria-label",
2809
+ "title"
2810
+ ],
2811
+ hasChildren: false,
2812
+ description: "Clickable button"
2813
+ },
2814
+ // ============================================
2815
+ // Display Components
2816
+ // ============================================
2817
+ {
2818
+ name: "image",
2819
+ nodeType: "Image",
2820
+ category: "display",
2821
+ attributes: [...COMMON_ATTRIBUTES, ...INTERACTIVE_ATTRIBUTES, "src", "alt"],
2822
+ hasChildren: false,
2823
+ description: "Image placeholder"
2824
+ },
2825
+ {
2826
+ name: "placeholder",
2827
+ nodeType: "Placeholder",
2828
+ category: "display",
2829
+ attributes: [...COMMON_ATTRIBUTES, "label"],
2830
+ hasChildren: true,
2831
+ description: "Generic placeholder"
2832
+ },
2833
+ {
2834
+ name: "avatar",
2835
+ nodeType: "Avatar",
2836
+ category: "display",
2837
+ attributes: [...COMMON_ATTRIBUTES, ...INTERACTIVE_ATTRIBUTES, "name", "src", "size"],
2838
+ hasChildren: false,
2839
+ description: "User avatar"
2840
+ },
2841
+ {
2842
+ name: "badge",
2843
+ nodeType: "Badge",
2844
+ category: "display",
2845
+ attributes: [
2846
+ ...COMMON_ATTRIBUTES,
2847
+ ...INTERACTIVE_ATTRIBUTES,
2848
+ "variant",
2849
+ "pill",
2850
+ "icon",
2851
+ "size",
2852
+ "anchor"
2853
+ ],
2854
+ hasChildren: false,
2855
+ description: "Status badge"
2856
+ },
2857
+ {
2858
+ name: "icon",
2859
+ nodeType: "Icon",
2860
+ category: "display",
2861
+ attributes: [...COMMON_ATTRIBUTES, ...INTERACTIVE_ATTRIBUTES, "name", "size", "muted"],
2862
+ hasChildren: false,
2863
+ description: "Lucide icon"
2864
+ },
2865
+ // ============================================
2866
+ // Data Components
2867
+ // ============================================
2868
+ {
2869
+ name: "table",
2870
+ nodeType: "Table",
2871
+ category: "data",
2872
+ attributes: [...COMMON_ATTRIBUTES, "striped", "bordered", "hover"],
2873
+ hasChildren: false,
2874
+ description: "Data table"
2875
+ },
2876
+ {
2877
+ name: "list",
2878
+ nodeType: "List",
2879
+ category: "data",
2880
+ attributes: [...COMMON_ATTRIBUTES, "ordered", "none"],
2881
+ hasChildren: false,
2882
+ description: "List of items"
2883
+ },
2884
+ // ============================================
2885
+ // Feedback Components
2886
+ // ============================================
2887
+ {
2888
+ name: "alert",
2889
+ nodeType: "Alert",
2890
+ category: "feedback",
2891
+ attributes: [...COMMON_ATTRIBUTES, "variant", "dismissible", "icon"],
2892
+ hasChildren: false,
2893
+ description: "Alert message"
2894
+ },
2895
+ {
2896
+ name: "toast",
2897
+ nodeType: "Toast",
2898
+ category: "feedback",
2899
+ attributes: [...COMMON_ATTRIBUTES, "position", "variant"],
2900
+ hasChildren: false,
2901
+ description: "Toast notification"
2902
+ },
2903
+ {
2904
+ name: "progress",
2905
+ nodeType: "Progress",
2906
+ category: "feedback",
2907
+ attributes: [...COMMON_ATTRIBUTES, "value", "max", "label", "indeterminate"],
2908
+ hasChildren: false,
2909
+ description: "Progress bar"
2910
+ },
2911
+ {
2912
+ name: "spinner",
2913
+ nodeType: "Spinner",
2914
+ category: "feedback",
2915
+ attributes: [...COMMON_ATTRIBUTES, "label", "size"],
2916
+ hasChildren: false,
2917
+ description: "Loading spinner"
2918
+ },
2919
+ // ============================================
2920
+ // Overlay Components
2921
+ // ============================================
2922
+ {
2923
+ name: "tooltip",
2924
+ nodeType: "Tooltip",
2925
+ category: "overlay",
2926
+ attributes: [...COMMON_ATTRIBUTES, "position"],
2927
+ hasChildren: false,
2928
+ description: "Tooltip on hover"
2929
+ },
2930
+ {
2931
+ name: "popover",
2932
+ nodeType: "Popover",
2933
+ category: "overlay",
2934
+ attributes: [...COMMON_ATTRIBUTES, "title"],
2935
+ hasChildren: true,
2936
+ description: "Popover panel"
2937
+ },
2938
+ {
2939
+ name: "dropdown",
2940
+ nodeType: "Dropdown",
2941
+ category: "overlay",
2942
+ attributes: [...COMMON_ATTRIBUTES],
2943
+ hasChildren: false,
2944
+ description: "Dropdown menu"
2945
+ },
2946
+ // ============================================
2947
+ // Navigation Components
2948
+ // ============================================
2949
+ {
2950
+ name: "nav",
2951
+ nodeType: "Nav",
2952
+ category: "navigation",
2953
+ attributes: [...COMMON_ATTRIBUTES, "vertical"],
2954
+ hasChildren: false,
2955
+ description: "Navigation menu"
2956
+ },
2957
+ {
2958
+ name: "tabs",
2959
+ nodeType: "Tabs",
2960
+ category: "navigation",
2961
+ attributes: [...COMMON_ATTRIBUTES, "active"],
2962
+ hasChildren: true,
2963
+ description: "Tab navigation"
2964
+ },
2965
+ {
2966
+ name: "breadcrumb",
2967
+ nodeType: "Breadcrumb",
2968
+ category: "navigation",
2969
+ attributes: [...COMMON_ATTRIBUTES],
2970
+ hasChildren: false,
2971
+ description: "Breadcrumb navigation"
2972
+ },
2973
+ // ============================================
2974
+ // Divider Component
2975
+ // ============================================
2976
+ {
2977
+ name: "divider",
2978
+ nodeType: "Divider",
2979
+ category: "layout",
2980
+ attributes: [...COMMON_ATTRIBUTES, "vertical"],
2981
+ hasChildren: false,
2982
+ description: "Horizontal separator"
2983
+ },
2984
+ // ============================================
2985
+ // Annotation Components
2986
+ // ============================================
2987
+ {
2988
+ name: "marker",
2989
+ nodeType: "Marker",
2990
+ category: "annotation",
2991
+ attributes: [...COMMON_ATTRIBUTES, "color", "anchor"],
2992
+ hasChildren: false,
2993
+ description: "Number marker for referencing in annotations"
2994
+ },
2995
+ {
2996
+ name: "annotations",
2997
+ nodeType: "Annotations",
2998
+ category: "annotation",
2999
+ attributes: [...COMMON_ATTRIBUTES, "title"],
3000
+ hasChildren: true,
3001
+ description: "Documentation panel for screen specifications"
3002
+ },
3003
+ {
3004
+ name: "item",
3005
+ nodeType: "AnnotationItem",
3006
+ category: "annotation",
3007
+ attributes: [],
3008
+ hasChildren: true,
3009
+ description: "Individual annotation entry with marker number and title"
3010
+ }
3011
+ ];
3012
+ var VALID_COMPONENT_NAMES = new Set(
3013
+ COMPONENT_SPECS.map((comp) => comp.name)
3014
+ );
3015
+ var COMPONENT_MAP = new Map(
3016
+ COMPONENT_SPECS.map((comp) => [comp.name, comp])
3017
+ );
3018
+ var NODE_TYPE_MAP = new Map(
3019
+ COMPONENT_SPECS.map((comp) => [comp.nodeType, comp])
3020
+ );
3021
+
3022
+ // src/extract/node-info.ts
3023
+ var INTERACTION_KINDS = ["navigate", "opens", "toggles", "action"];
3024
+ function categoryOf(node) {
3025
+ return NODE_TYPE_MAP.get(node.type)?.category;
3026
+ }
3027
+ function getLabel(node) {
3028
+ if ("label" in node && typeof node.label === "string") return node.label;
3029
+ if ("name" in node && typeof node.name === "string") return node.name;
3030
+ if ("title" in node && typeof node.title === "string") return node.title;
3031
+ return void 0;
3032
+ }
3033
+ function getContent(node) {
3034
+ if ("content" in node && typeof node.content === "string") return node.content;
3035
+ return void 0;
3036
+ }
3037
+ function getInteractiveLabel(node) {
3038
+ return getContent(node) ?? getLabel(node);
3039
+ }
3040
+ function interactionsOf(props) {
3041
+ const out = [];
3042
+ for (const kind of INTERACTION_KINDS) {
3043
+ const target = props[kind];
3044
+ if (typeof target === "string" && target.length > 0) {
3045
+ out.push({ kind, target });
3046
+ }
3047
+ }
3048
+ return out;
3049
+ }
3050
+ function getInteractions(node) {
3051
+ return interactionsOf(node);
3052
+ }
3053
+ function getItemInteractionSources(node) {
3054
+ const out = [];
3055
+ let index = 0;
3056
+ const emit = (label, props) => {
3057
+ const item = { props, container: node.type, itemIndex: index };
3058
+ if (label !== void 0) item.itemLabel = label;
3059
+ out.push(item);
3060
+ index += 1;
3061
+ };
3062
+ if (isNavNode(node)) {
3063
+ for (const it of node.items) {
3064
+ if (typeof it === "string") {
3065
+ index += 1;
3066
+ continue;
3067
+ }
3068
+ emit(it.label, it);
3069
+ }
3070
+ for (const child of node.children) {
3071
+ if (child.type === "item") {
3072
+ emit(child.label, child);
3073
+ } else if (child.type === "group") {
3074
+ for (const groupItem of child.items) {
3075
+ if (groupItem.type === "item") emit(groupItem.label, groupItem);
3076
+ }
3077
+ }
3078
+ }
3079
+ } else if (isDropdownNode(node)) {
3080
+ for (const it of node.items) {
3081
+ if (!("label" in it)) {
3082
+ index += 1;
3083
+ continue;
3084
+ }
3085
+ emit(it.label, it);
3086
+ }
3087
+ } else if (isBreadcrumbNode(node)) {
3088
+ for (const it of node.items) {
3089
+ if (typeof it === "string") {
3090
+ index += 1;
3091
+ continue;
3092
+ }
3093
+ emit(it.label, it);
3094
+ }
3095
+ }
3096
+ return out;
3097
+ }
3098
+
3099
+ // src/renderer/page-renderer.ts
3100
+ function renderPage(page, options = {}) {
3101
+ const renderer = new HtmlRenderer(options);
3102
+ const { html, css } = renderer.render({
3103
+ type: "Document",
3104
+ children: [page]
3105
+ });
3106
+ const { width, height } = resolvePageDimensions(page);
3107
+ return { html, css, width, height };
3108
+ }
3109
+ function resolvePageDimensions(page) {
3110
+ const pageAny = page;
3111
+ const explicitW = page.w ?? pageAny.width;
3112
+ const explicitH = page.h ?? pageAny.height;
3113
+ if (typeof explicitW === "number" && typeof explicitH === "number") {
3114
+ return { width: explicitW, height: explicitH };
3115
+ }
3116
+ const viewport = resolveViewport(page.viewport, page.device);
3117
+ return { width: viewport.width, height: viewport.height };
3118
+ }
3119
+
3120
+ // src/renderer/site/model.ts
3121
+ function pageId(page) {
3122
+ const id = page.id?.trim();
3123
+ return id && id.length > 0 ? id : void 0;
3124
+ }
3125
+ function pageTitle(page) {
3126
+ const title = page.title?.trim();
3127
+ return title && title.length > 0 ? title : void 0;
3128
+ }
3129
+ function hasSlot(layout) {
3130
+ for (const child of layout.children) {
3131
+ let found = false;
3132
+ walk(child, (node) => {
3133
+ if (node.type === "Slot") found = true;
3134
+ return !found;
3135
+ });
3136
+ if (found) return true;
3137
+ }
3138
+ return false;
3139
+ }
3140
+ function layoutsByName(doc) {
3141
+ const layouts = /* @__PURE__ */ new Map();
3142
+ for (const definition of documentDefinitions(doc)) {
3143
+ if (definition.type !== "Layout") continue;
3144
+ const name = definition.name.trim();
3145
+ if (name.length > 0 && !layouts.has(name)) layouts.set(name, definition);
3146
+ }
3147
+ return layouts;
3148
+ }
3149
+ function resolveShell(page, layouts) {
3150
+ const uses = page.uses?.trim();
3151
+ if (!uses) return void 0;
3152
+ const layout = layouts.get(uses);
3153
+ if (!layout) return { miss: { uses, reason: "unknown-layout" } };
3154
+ if (!hasSlot(layout)) return { miss: { uses, reason: "slotless-layout" } };
3155
+ return { layout, name: uses };
3156
+ }
3157
+ function buildSiteModel(doc) {
3158
+ const screens = documentPages(doc).map((page, index) => ({ index, page }));
3159
+ const layouts = layoutsByName(doc);
3160
+ const shells = [];
3161
+ const shellByName = /* @__PURE__ */ new Map();
3162
+ for (const screen of screens) {
3163
+ const resolved = resolveShell(screen.page, layouts);
3164
+ if (!resolved) continue;
3165
+ if ("miss" in resolved) {
3166
+ screen.miss = resolved.miss;
3167
+ continue;
3168
+ }
3169
+ let shell = shellByName.get(resolved.name);
3170
+ if (!shell) {
3171
+ const { width, height } = resolvePageDimensions(screen.page);
3172
+ shell = { name: resolved.name, layout: resolved.layout, screens: [], width, height };
3173
+ shellByName.set(resolved.name, shell);
3174
+ shells.push(shell);
3175
+ }
3176
+ shell.screens.push(screen);
3177
+ screen.shell = shell.name;
3178
+ }
3179
+ const names = /* @__PURE__ */ new Map();
3180
+ for (const screen of screens) {
3181
+ const title = pageTitle(screen.page);
3182
+ if (title !== void 0 && !names.has(title)) names.set(title, screen.index);
3183
+ }
3184
+ for (const screen of screens) {
3185
+ const id = pageId(screen.page);
3186
+ if (id === void 0) continue;
3187
+ const owner = names.get(id);
3188
+ if (owner === void 0 || pageId(screens[owner].page) !== id) {
3189
+ names.set(id, screen.index);
3190
+ }
3191
+ }
3192
+ for (const screen of screens) {
3193
+ screen.name = [pageId(screen.page), pageTitle(screen.page)].find(
3194
+ (name) => name !== void 0 && names.get(name) === screen.index
3195
+ );
3196
+ }
3197
+ return { screens, shells, names, entry: screens.length > 0 ? 0 : -1 };
3198
+ }
3199
+
3200
+ // src/interaction/model.ts
3201
+ function isRecord(value) {
3202
+ return typeof value === "object" && value !== null && !Array.isArray(value);
3203
+ }
3204
+ function isStateValue(value) {
3205
+ return typeof value === "string" || typeof value === "number" || typeof value === "boolean";
3206
+ }
3207
+ function valueMatches(type, value) {
3208
+ return typeof value === type;
3209
+ }
3210
+ function normalizeStateGuard(value) {
3211
+ if (!isRecord(value) || typeof value.state !== "string" || !isStateValue(value.equals)) {
3212
+ return void 0;
3213
+ }
3214
+ const state = value.state.trim();
3215
+ return state.length > 0 ? { state, equals: value.equals } : void 0;
3216
+ }
3217
+ function normalizeEffect(value) {
3218
+ if (!isRecord(value) || typeof value.kind !== "string") return void 0;
3219
+ switch (value.kind) {
3220
+ case "navigate":
3221
+ case "open":
3222
+ case "close": {
3223
+ if (typeof value.target !== "string" || value.target.trim().length === 0) return void 0;
3224
+ return { kind: value.kind, target: value.target.trim() };
3225
+ }
3226
+ case "set": {
3227
+ if (typeof value.state !== "string" || value.state.trim().length === 0 || !isStateValue(value.value)) {
3228
+ return void 0;
3229
+ }
3230
+ return { kind: "set", state: value.state.trim(), value: value.value };
3231
+ }
3232
+ case "reset":
3233
+ case "toggle": {
3234
+ if (typeof value.state !== "string" || value.state.trim().length === 0) return void 0;
3235
+ return { kind: value.kind, state: value.state.trim() };
3236
+ }
3237
+ default:
3238
+ return void 0;
3239
+ }
3240
+ }
3241
+ function normalizeInteractionHandlers(value) {
3242
+ const candidates = Array.isArray(value) ? value : [value];
3243
+ const handlers = [];
3244
+ for (const candidate of candidates) {
3245
+ if (!isRecord(candidate) || candidate.event !== "click") continue;
3246
+ const effects = Array.isArray(candidate.effects) ? candidate.effects.map(normalizeEffect) : [normalizeEffect(candidate.effects)];
3247
+ if (effects.length === 0 || effects.some((effect) => effect === void 0)) continue;
3248
+ const handler = {
3249
+ event: "click",
3250
+ effects
3251
+ };
3252
+ if (candidate.guard !== void 0) {
3253
+ const guard = normalizeStateGuard(candidate.guard);
3254
+ if (guard === void 0) continue;
3255
+ handler.guard = guard;
3256
+ }
3257
+ handlers.push(handler);
3258
+ }
3259
+ return handlers;
3260
+ }
3261
+ function interactionSignature(handler) {
3262
+ return JSON.stringify(handler);
3263
+ }
3264
+ function legacyHandler(kind, target) {
3265
+ switch (kind) {
3266
+ case "navigate":
3267
+ return { event: "click", effects: [{ kind: "navigate", target: target.trim() }] };
3268
+ case "opens":
3269
+ return { event: "click", effects: [{ kind: "open", target: target.trim() }] };
3270
+ case "toggles":
3271
+ return { event: "click", effects: [{ kind: "toggle-overlay", target: target.trim() }] };
3272
+ case "action":
3273
+ return { event: "click", effects: [{ kind: "legacy-action", action: target.trim() }] };
3274
+ }
3275
+ }
3276
+ function normalizeStateDeclaration(value) {
3277
+ if (!isRecord(value) || typeof value.name !== "string" || value.valueType !== "string" && value.valueType !== "number" && value.valueType !== "boolean" || !isStateValue(value.initial)) {
3278
+ return void 0;
3279
+ }
3280
+ const name = value.name.trim();
3281
+ if (name.length === 0 || !valueMatches(value.valueType, value.initial)) return void 0;
3282
+ return { name, valueType: value.valueType, initial: value.initial };
3283
+ }
3284
+ function collectStates(doc, diagnostics) {
3285
+ const states = [];
3286
+ const names = /* @__PURE__ */ new Set();
3287
+ for (const owner of doc.children) {
3288
+ if (owner.type !== "Page" && owner.type !== "Layout") continue;
3289
+ const raw = owner.states;
3290
+ if (raw === void 0) continue;
3291
+ if (!Array.isArray(raw)) {
3292
+ diagnostics.push({
3293
+ code: "invalid-state-declaration",
3294
+ message: "states must be an array of typed state declarations",
3295
+ ...owner.loc ? { loc: owner.loc } : {}
3296
+ });
3297
+ continue;
3298
+ }
3299
+ for (const candidate of raw) {
3300
+ const state = normalizeStateDeclaration(candidate);
3301
+ if (state === void 0) {
3302
+ diagnostics.push({
3303
+ code: "invalid-state-declaration",
3304
+ message: "state declarations require name, valueType, and a matching scalar initial value",
3305
+ ...owner.loc ? { loc: owner.loc } : {}
3306
+ });
3307
+ continue;
3308
+ }
3309
+ if (names.has(state.name)) {
3310
+ diagnostics.push({
3311
+ code: "duplicate-state-declaration",
3312
+ message: `state ${JSON.stringify(state.name)} was already declared; first declaration wins`,
3313
+ ...owner.loc ? { loc: owner.loc } : {}
3314
+ });
3315
+ continue;
3316
+ }
3317
+ names.add(state.name);
3318
+ states.push(state);
3319
+ }
3320
+ }
3321
+ return states;
3322
+ }
3323
+ function sourcesIn(nodes) {
3324
+ const sources = [];
3325
+ for (const child of nodes) {
3326
+ walk(child, (node) => {
3327
+ if (categoryOf(node) === void 0) return;
3328
+ const trigger = { nodeType: node.type };
3329
+ const label = getInteractiveLabel(node);
3330
+ if (label !== void 0) trigger.label = label;
3331
+ if (node.loc) trigger.loc = node.loc;
3332
+ sources.push({ props: node, trigger });
3333
+ for (const item of getItemInteractionSources(node)) {
3334
+ const itemTrigger = {
3335
+ nodeType: item.container,
3336
+ item: { index: item.itemIndex }
3337
+ };
3338
+ if (item.itemLabel !== void 0) itemTrigger.label = item.itemLabel;
3339
+ if (node.loc) itemTrigger.loc = node.loc;
3340
+ sources.push({ props: item.props, trigger: itemTrigger });
3341
+ }
3342
+ });
3343
+ }
3344
+ return sources;
3345
+ }
3346
+ function collectInteractions(doc) {
3347
+ const diagnostics = [];
3348
+ const states = collectStates(doc, diagnostics);
3349
+ const interactions = [];
3350
+ const site = buildSiteModel(doc);
3351
+ const layouts = new Map(site.shells.map((shell) => [shell.name, shell.layout]));
3352
+ const add = (screenIndex, source, triggerSource) => {
3353
+ const legacy = getInteractions(triggerSource.props).map(({ kind, target }) => ({
3354
+ kind,
3355
+ handler: legacyHandler(kind, target)
3356
+ }));
3357
+ const typed = normalizeInteractionHandlers(triggerSource.props.on);
3358
+ if (triggerSource.props.on !== void 0 && typed.length === 0) {
3359
+ diagnostics.push({
3360
+ code: "invalid-interaction-handler",
3361
+ message: "on requires event=click, an optional equality guard, and valid ordered effects",
3362
+ screenIndex,
3363
+ source,
3364
+ ...triggerSource.trigger.loc ? { loc: triggerSource.trigger.loc } : {}
3365
+ });
3366
+ }
3367
+ for (const entry of [...legacy, ...typed.map((handler) => ({ handler, kind: void 0 }))]) {
3368
+ const { handler } = entry;
3369
+ for (const effect of handler.effects) {
3370
+ if (effect.kind === "legacy-action" && effect.action !== "close" && effect.action !== "back") {
3371
+ diagnostics.push({
3372
+ code: "unknown-legacy-action",
3373
+ message: `legacy action ${JSON.stringify(effect.action)} is inert in the generated runtime`,
3374
+ screenIndex,
3375
+ source,
3376
+ ...triggerSource.trigger.loc ? { loc: triggerSource.trigger.loc } : {}
3377
+ });
3378
+ }
3379
+ }
3380
+ const interaction = {
3381
+ screenIndex,
3382
+ source,
3383
+ signature: interactionSignature(handler),
3384
+ handler,
3385
+ trigger: triggerSource.trigger
3386
+ };
3387
+ if (entry.kind !== void 0) interaction.legacyKind = entry.kind;
3388
+ interactions.push(interaction);
3389
+ }
3390
+ };
3391
+ for (const screen of site.screens) {
3392
+ for (const source of sourcesIn(screen.page.children)) add(screen.index, "screen", source);
3393
+ if (screen.shell !== void 0) {
3394
+ const layout = layouts.get(screen.shell);
3395
+ if (layout !== void 0) {
3396
+ for (const source of sourcesIn(layout.children)) add(screen.index, "layout", source);
3397
+ }
3398
+ }
3399
+ }
3400
+ return { states, interactions, diagnostics };
3401
+ }
3402
+
3403
+ // src/interaction/target.ts
3404
+ function isUrlTarget(target) {
3405
+ if (target === void 0) return false;
3406
+ const value = target.trim();
3407
+ if (value.length === 0 || /\s/.test(value)) return false;
3408
+ if (value.startsWith("/") || value.startsWith("#") || value.startsWith("?")) return true;
3409
+ return /^[A-Za-z][A-Za-z0-9+.-]*:/.test(value);
3410
+ }
3411
+
3412
+ // src/renderer/html/interactive.ts
3413
+ var EXTERNAL_NAVIGATE_ATTR = "data-navigate-external";
3414
+ var TYPED_INTERACTION_ATTR = "data-wf-on";
3415
+ var VISIBLE_GUARD_ATTR = "data-wf-visible-when";
3416
+ var ENABLED_GUARD_ATTR = "data-wf-enabled-when";
3417
+ var INERT_HREF = "#";
3418
+ function guardedOutcomeAttrs(node) {
3419
+ const visible = normalizeStateGuard(node.visibleWhen);
3420
+ const enabled = normalizeStateGuard(node.enabledWhen);
3421
+ return {
3422
+ [VISIBLE_GUARD_ATTR]: visible === void 0 ? void 0 : JSON.stringify(visible),
3423
+ [ENABLED_GUARD_ATTR]: enabled === void 0 ? void 0 : JSON.stringify(enabled)
3424
+ };
3425
+ }
3426
+ function interactiveAttrs(node) {
3427
+ const handlers = normalizeInteractionHandlers(node.on);
3428
+ return {
3429
+ "data-navigate": node.navigate,
3430
+ [EXTERNAL_NAVIGATE_ATTR]: isUrlTarget(node.navigate) ? true : void 0,
3431
+ "data-opens": node.opens,
3432
+ "data-toggles": node.toggles,
3433
+ "data-action": node.action,
3434
+ [TYPED_INTERACTION_ATTR]: handlers.length === 0 ? void 0 : JSON.stringify(handlers.map((handler) => interactionSignature(handler))),
3435
+ ...guardedOutcomeAttrs(node)
3436
+ };
3437
+ }
3438
+ function anchorIntent(node) {
3439
+ const attrs2 = interactiveAttrs(node);
3440
+ if (node.href) return { href: node.href, attrs: attrs2 };
3441
+ if (isUrlTarget(node.navigate)) {
3442
+ return {
3443
+ href: node.navigate.trim(),
3444
+ attrs: { ...attrs2, "data-navigate": void 0, [EXTERNAL_NAVIGATE_ATTR]: void 0 }
3445
+ };
3446
+ }
3447
+ return { href: INERT_HREF, attrs: attrs2 };
3448
+ }
3449
+ function nonAnchorIntent(node) {
3450
+ return interactiveAttrs(node);
3451
+ }
3452
+
2201
3453
  // src/renderer/html/components.ts
2202
3454
  function buildClassString(classes) {
2203
3455
  return classes.filter(Boolean).join(" ");
@@ -2434,45 +3686,6 @@ ${children}
2434
3686
  </div>`;
2435
3687
  }
2436
3688
 
2437
- // src/interaction/target.ts
2438
- function isUrlTarget(target) {
2439
- if (target === void 0) return false;
2440
- const value = target.trim();
2441
- if (value.length === 0 || /\s/.test(value)) return false;
2442
- if (value.startsWith("/") || value.startsWith("#") || value.startsWith("?")) return true;
2443
- return /^[A-Za-z][A-Za-z0-9+.-]*:/.test(value);
2444
- }
2445
-
2446
- // src/renderer/html/interactive.ts
2447
- var EXTERNAL_NAVIGATE_ATTR = "data-navigate-external";
2448
- function interactiveAttrs(node) {
2449
- return {
2450
- "data-navigate": node.navigate,
2451
- [EXTERNAL_NAVIGATE_ATTR]: isUrlTarget(node.navigate) ? true : void 0,
2452
- "data-opens": node.opens,
2453
- "data-toggles": node.toggles,
2454
- "data-action": node.action
2455
- };
2456
- }
2457
- function anchorIntent(node) {
2458
- const attrs2 = interactiveAttrs(node);
2459
- if (node.href) return { href: node.href, attrs: attrs2 };
2460
- if (isUrlTarget(node.navigate)) {
2461
- return {
2462
- href: node.navigate.trim(),
2463
- attrs: {
2464
- ...attrs2,
2465
- "data-navigate": void 0,
2466
- [EXTERNAL_NAVIGATE_ATTR]: void 0
2467
- }
2468
- };
2469
- }
2470
- return { href: "#", attrs: attrs2 };
2471
- }
2472
- function nonAnchorIntent(node) {
2473
- return interactiveAttrs(node);
2474
- }
2475
-
2476
3689
  // src/renderer/html/renderers/text.ts
2477
3690
  function isValueWithUnit2(value) {
2478
3691
  return typeof value === "object" && value !== null && "value" in value && "unit" in value;
@@ -49670,6 +50883,12 @@ var MARKER_COLORS = {
49670
50883
  purple: { bg: "#a855f7", border: "#9333ea" },
49671
50884
  orange: { bg: "#f97316", border: "#ea580c" }
49672
50885
  };
50886
+ var NEUTRAL_MARKER_STYLE = { bg: "#000000", border: "#000000", foreground: "#FFFFFF" };
50887
+ function markerStyle(color, annotationStyle) {
50888
+ if (annotationStyle === "neutral") return NEUTRAL_MARKER_STYLE;
50889
+ const legacy = MARKER_COLORS[color ?? "blue"] ?? MARKER_COLORS.blue;
50890
+ return { ...legacy, foreground: "white" };
50891
+ }
49673
50892
  function getAnchorStyles(anchor) {
49674
50893
  if (!anchor) return "";
49675
50894
  const styles = ["position: absolute"];
@@ -49705,8 +50924,7 @@ function getAnchorStyles(anchor) {
49705
50924
  return styles.join("; ");
49706
50925
  }
49707
50926
  function renderMarker(node, ctx) {
49708
- const color = node.color || "blue";
49709
- const colorConfig = MARKER_COLORS[color] || MARKER_COLORS.blue;
50927
+ const color = markerStyle(node.color, ctx.annotationStyle);
49710
50928
  const baseStyles = [
49711
50929
  "display: inline-flex",
49712
50930
  "align-items: center",
@@ -49714,9 +50932,9 @@ function renderMarker(node, ctx) {
49714
50932
  "width: 20px",
49715
50933
  "height: 20px",
49716
50934
  "border-radius: 50%",
49717
- `background: ${colorConfig.bg}`,
49718
- `border: 2px solid ${colorConfig.border}`,
49719
- "color: white",
50935
+ `background: ${color.bg}`,
50936
+ `border: 2px solid ${color.border}`,
50937
+ `color: ${color.foreground}`,
49720
50938
  "font-size: 11px",
49721
50939
  "font-weight: 600",
49722
50940
  "line-height: 1",
@@ -49747,8 +50965,8 @@ function renderAnnotations(node, ctx) {
49747
50965
  </aside>`;
49748
50966
  }
49749
50967
  function renderAnnotationItem(node, ctx) {
49750
- const color = MARKER_COLORS.blue;
49751
- const markerStyle = [
50968
+ const color = markerStyle("blue", ctx.annotationStyle);
50969
+ const inlineStyle = [
49752
50970
  "display: inline-flex",
49753
50971
  "align-items: center",
49754
50972
  "justify-content: center",
@@ -49756,7 +50974,7 @@ function renderAnnotationItem(node, ctx) {
49756
50974
  "height: 18px",
49757
50975
  "border-radius: 50%",
49758
50976
  `background: ${color.bg}`,
49759
- "color: white",
50977
+ `color: ${color.foreground}`,
49760
50978
  "font-size: 10px",
49761
50979
  "font-weight: 600",
49762
50980
  "flex-shrink: 0"
@@ -49765,7 +50983,7 @@ function renderAnnotationItem(node, ctx) {
49765
50983
  const content = children.length > 0 ? ctx.renderChildren(children) : "";
49766
50984
  return `<div class="${ctx.prefix}-annotation-item">
49767
50985
  <div class="${ctx.prefix}-annotation-item-header">
49768
- <span class="${ctx.prefix}-annotation-marker" style="${markerStyle}">${node.number}</span>
50986
+ <span class="${ctx.prefix}-annotation-marker" style="${inlineStyle}">${node.number}</span>
49769
50987
  <span class="${ctx.prefix}-annotation-item-title">${ctx.escapeHtml(node.title)}</span>
49770
50988
  </div>
49771
50989
  ${content ? `<div class="${ctx.prefix}-annotation-item-content">${content}</div>` : ""}
@@ -49857,6 +51075,7 @@ var HtmlRenderer = class extends BaseRenderer {
49857
51075
  getRenderContext() {
49858
51076
  return {
49859
51077
  prefix: this.prefix,
51078
+ annotationStyle: this.context.options.annotationStyle,
49860
51079
  escapeHtml: this.escapeHtml.bind(this),
49861
51080
  scopedId: this.scopedId.bind(this),
49862
51081
  buildClassString: this.buildClassString.bind(this),
@@ -49937,6 +51156,7 @@ var HtmlRenderer = class extends BaseRenderer {
49937
51156
  // Other
49938
51157
  Divider: (node) => this.renderDivider(node),
49939
51158
  Slot: () => this.renderSlot(),
51159
+ ComponentUse: (node) => this.renderComponentUse(node),
49940
51160
  // Annotation nodes
49941
51161
  Marker: (node) => this.renderMarker(node),
49942
51162
  Annotations: (node) => this.renderAnnotations(node),
@@ -50004,7 +51224,17 @@ ${annotationsContent}
50004
51224
  */
50005
51225
  renderNode(node) {
50006
51226
  const renderer = this.nodeRenderers[node.type];
50007
- const html = renderer ? renderer(node) : `<!-- Unknown node type: ${node.type} -->`;
51227
+ let html = renderer ? renderer(node) : `<!-- Unknown node type: ${node.type} -->`;
51228
+ const rootOpeningTag = /^<[a-zA-Z][a-zA-Z0-9-]*\b[^>]*>/.exec(html)?.[0] ?? "";
51229
+ const intentAttrs = Object.fromEntries(
51230
+ Object.entries(interactiveAttrs(node)).filter(
51231
+ ([name, value]) => name.startsWith("data-wf-") && value !== void 0 && !rootOpeningTag.includes(` ${name}=`)
51232
+ )
51233
+ );
51234
+ const intentAttrString = this.buildAttrsString(intentAttrs);
51235
+ if (rootOpeningTag.length > 0 && intentAttrString.length > 0) {
51236
+ html = html.replace(/^<([a-zA-Z][a-zA-Z0-9-]*)/, (match) => `${match}${intentAttrString}`);
51237
+ }
50008
51238
  if (this.pathMap && node.type !== "Page") {
50009
51239
  const path = this.pathMap.get(node);
50010
51240
  if (path !== void 0) {
@@ -50020,6 +51250,18 @@ ${annotationsContent}
50020
51250
  const open = `<div class="${this.prefix}-slot">`;
50021
51251
  return content === null ? `${open}</div>` : `${open}
50022
51252
  ${content}
51253
+ </div>`;
51254
+ }
51255
+ /** Render one linked component invocation with its stable instance marker. */
51256
+ renderComponentUse(node) {
51257
+ const component = this.escapeHtml(node.name);
51258
+ if (node.children === void 0 || node.instanceId === void 0) {
51259
+ return `<div class="${this.prefix}-component-instance" data-wf-component="${component}" data-wf-component-unresolved style="display: contents"></div>`;
51260
+ }
51261
+ const instanceId = this.escapeHtml(node.instanceId);
51262
+ const content = this.renderChildren(node.children);
51263
+ return `<div class="${this.prefix}-component-instance" data-wf-component="${component}" data-wf-instance="${instanceId}" style="display: contents">
51264
+ ${content}
50023
51265
  </div>`;
50024
51266
  }
50025
51267
  /** Render nodes without adding a page frame, optionally filling a slot. */
@@ -50422,27 +51664,6 @@ function createHtmlRenderer(options) {
50422
51664
  return new HtmlRenderer(options);
50423
51665
  }
50424
51666
 
50425
- // src/renderer/page-renderer.ts
50426
- function renderPage(page, options = {}) {
50427
- const renderer = new HtmlRenderer(options);
50428
- const { html, css } = renderer.render({
50429
- type: "Document",
50430
- children: [page]
50431
- });
50432
- const { width, height } = resolvePageDimensions(page);
50433
- return { html, css, width, height };
50434
- }
50435
- function resolvePageDimensions(page) {
50436
- const pageAny = page;
50437
- const explicitW = page.w ?? pageAny.width;
50438
- const explicitH = page.h ?? pageAny.height;
50439
- if (typeof explicitW === "number" && typeof explicitH === "number") {
50440
- return { width: explicitW, height: explicitH };
50441
- }
50442
- const viewport = resolveViewport(page.viewport, page.device);
50443
- return { width: viewport.width, height: viewport.height };
50444
- }
50445
-
50446
51667
  // src/renderer/canvas-renderer.ts
50447
51668
  var DEFAULT_GAP = 64;
50448
51669
  var DEFAULT_PREFIX = "wf";
@@ -50471,7 +51692,7 @@ function renderCanvas(doc, options = {}) {
50471
51692
  const prefix = options.classPrefix ?? DEFAULT_PREFIX;
50472
51693
  const includeStyles = options.includeStyles !== false;
50473
51694
  const theme = options.theme === "dark" ? darkTheme : defaultTheme;
50474
- const css = includeStyles ? generateStyles(theme, prefix) : "";
51695
+ const css = includeStyles ? generateStyles(theme, prefix, options.annotationStyle) : "";
50475
51696
  const pages = documentPages(doc);
50476
51697
  if (pages.length === 0) {
50477
51698
  return {
@@ -50509,85 +51730,6 @@ function escapeAttr(s) {
50509
51730
  return s.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;");
50510
51731
  }
50511
51732
 
50512
- // src/renderer/site/model.ts
50513
- function pageId(page) {
50514
- const id = page.id?.trim();
50515
- return id && id.length > 0 ? id : void 0;
50516
- }
50517
- function pageTitle(page) {
50518
- const title = page.title?.trim();
50519
- return title && title.length > 0 ? title : void 0;
50520
- }
50521
- function hasSlot(layout) {
50522
- for (const child of layout.children) {
50523
- let found = false;
50524
- walk(child, (node) => {
50525
- if (node.type === "Slot") found = true;
50526
- return !found;
50527
- });
50528
- if (found) return true;
50529
- }
50530
- return false;
50531
- }
50532
- function layoutsByName(doc) {
50533
- const layouts = /* @__PURE__ */ new Map();
50534
- for (const definition of documentDefinitions(doc)) {
50535
- const name = definition.name.trim();
50536
- if (name.length > 0 && !layouts.has(name)) layouts.set(name, definition);
50537
- }
50538
- return layouts;
50539
- }
50540
- function resolveShell(page, layouts) {
50541
- const uses = page.uses?.trim();
50542
- if (!uses) return void 0;
50543
- const layout = layouts.get(uses);
50544
- if (!layout) return { miss: { uses, reason: "unknown-layout" } };
50545
- if (!hasSlot(layout)) return { miss: { uses, reason: "slotless-layout" } };
50546
- return { layout, name: uses };
50547
- }
50548
- function buildSiteModel(doc) {
50549
- const screens = documentPages(doc).map((page, index) => ({ index, page }));
50550
- const layouts = layoutsByName(doc);
50551
- const shells = [];
50552
- const shellByName = /* @__PURE__ */ new Map();
50553
- for (const screen of screens) {
50554
- const resolved = resolveShell(screen.page, layouts);
50555
- if (!resolved) continue;
50556
- if ("miss" in resolved) {
50557
- screen.miss = resolved.miss;
50558
- continue;
50559
- }
50560
- let shell = shellByName.get(resolved.name);
50561
- if (!shell) {
50562
- const { width, height } = resolvePageDimensions(screen.page);
50563
- shell = { name: resolved.name, layout: resolved.layout, screens: [], width, height };
50564
- shellByName.set(resolved.name, shell);
50565
- shells.push(shell);
50566
- }
50567
- shell.screens.push(screen);
50568
- screen.shell = shell.name;
50569
- }
50570
- const names = /* @__PURE__ */ new Map();
50571
- for (const screen of screens) {
50572
- const title = pageTitle(screen.page);
50573
- if (title !== void 0 && !names.has(title)) names.set(title, screen.index);
50574
- }
50575
- for (const screen of screens) {
50576
- const id = pageId(screen.page);
50577
- if (id === void 0) continue;
50578
- const owner = names.get(id);
50579
- if (owner === void 0 || pageId(screens[owner].page) !== id) {
50580
- names.set(id, screen.index);
50581
- }
50582
- }
50583
- for (const screen of screens) {
50584
- screen.name = [pageId(screen.page), pageTitle(screen.page)].find(
50585
- (name) => name !== void 0 && names.get(name) === screen.index
50586
- );
50587
- }
50588
- return { screens, shells, names, entry: screens.length > 0 ? 0 : -1 };
50589
- }
50590
-
50591
51733
  // src/renderer/site/styles.ts
50592
51734
  function generateSiteStyles(prefix) {
50593
51735
  return `
@@ -50685,6 +51827,61 @@ function siteRuntime(registry, prefix) {
50685
51827
  }
50686
51828
  }
50687
51829
  var shells = site.querySelectorAll('.' + P + '-shell');
51830
+ var state = {};
51831
+ var initial = {};
51832
+ var stateTypes = {};
51833
+ for (var st = 0; st < R.states.length; st++) {
51834
+ var declaration = R.states[st];
51835
+ state[declaration.name] = declaration.initial;
51836
+ initial[declaration.name] = declaration.initial;
51837
+ stateTypes[declaration.name] = declaration.valueType;
51838
+ }
51839
+
51840
+ function diagnostic(code, detail) {
51841
+ site.setAttribute('data-wf-runtime-diagnostic', code + ':' + detail);
51842
+ }
51843
+
51844
+ function hasState(name) {
51845
+ return Object.prototype.hasOwnProperty.call(state, name);
51846
+ }
51847
+
51848
+ function guardPasses(guard) {
51849
+ return !guard || (hasState(guard.state) && state[guard.state] === guard.equals);
51850
+ }
51851
+
51852
+ function valueMatches(name, value) {
51853
+ return hasState(name) && typeof value === stateTypes[name];
51854
+ }
51855
+
51856
+ function parseJson(value, fallback) {
51857
+ if (!value) return fallback;
51858
+ try { return JSON.parse(value); } catch (e) { return fallback; }
51859
+ }
51860
+
51861
+ function handlerId(signature) {
51862
+ for (var i = 0; i < R.handlers.length; i++) {
51863
+ if (JSON.stringify(R.handlers[i]) === signature) return i;
51864
+ }
51865
+ return -1;
51866
+ }
51867
+
51868
+ function contains(ids, id) {
51869
+ for (var i = 0; i < ids.length; i++) if (ids[i] === id) return true;
51870
+ return false;
51871
+ }
51872
+
51873
+ function shellHandlersFor(key) {
51874
+ var shell = shellOf[key];
51875
+ if (!shell) return [];
51876
+ return R.shellHandlers[shell.getAttribute('data-layout')] || [];
51877
+ }
51878
+
51879
+ function interactionFor(key, element, signature) {
51880
+ var id = handlerId(signature);
51881
+ if (id < 0) return null;
51882
+ var ids = isChrome(element) ? shellHandlersFor(key) : R.screenHandlers[String(key)] || [];
51883
+ return contains(ids, id) ? R.handlers[id] : null;
51884
+ }
50688
51885
 
50689
51886
  function isChrome(el) {
50690
51887
  return !(el.closest && el.closest('[data-screen]'));
@@ -50751,6 +51948,60 @@ function siteRuntime(registry, prefix) {
50751
51948
  }
50752
51949
  }
50753
51950
 
51951
+ function initOverlays() {
51952
+ for (var i = 0; i < order.length; i++) closeOverlays(order[i]);
51953
+ }
51954
+
51955
+ function applyOutcomes() {
51956
+ var visible = site.querySelectorAll('[' + ${embedJson(VISIBLE_GUARD_ATTR)} + ']');
51957
+ for (var i = 0; i < visible.length; i++) {
51958
+ var visibleGuard = parseJson(visible[i].getAttribute(${embedJson(VISIBLE_GUARD_ATTR)}), null);
51959
+ if (guardPasses(visibleGuard)) visible[i].removeAttribute('hidden');
51960
+ else visible[i].setAttribute('hidden', 'hidden');
51961
+ }
51962
+
51963
+ var enabled = site.querySelectorAll('[' + ${embedJson(ENABLED_GUARD_ATTR)} + ']');
51964
+ for (var j = 0; j < enabled.length; j++) {
51965
+ var enabledGuard = parseJson(enabled[j].getAttribute(${embedJson(ENABLED_GUARD_ATTR)}), null);
51966
+ if (guardPasses(enabledGuard)) {
51967
+ enabled[j].removeAttribute('disabled');
51968
+ enabled[j].removeAttribute('aria-disabled');
51969
+ } else {
51970
+ enabled[j].setAttribute('disabled', 'disabled');
51971
+ enabled[j].setAttribute('aria-disabled', 'true');
51972
+ }
51973
+ }
51974
+ }
51975
+
51976
+ function applyEffects(handler) {
51977
+ for (var i = 0; i < handler.effects.length; i++) {
51978
+ var effect = handler.effects[i];
51979
+ if (effect.kind === 'navigate') {
51980
+ var route = resolve(effect.target);
51981
+ if (route !== null) show(route, true);
51982
+ else diagnostic('unknown-route', effect.target);
51983
+ } else if (effect.kind === 'set') {
51984
+ if (valueMatches(effect.state, effect.value)) state[effect.state] = effect.value;
51985
+ else diagnostic('invalid-set', effect.state);
51986
+ } else if (effect.kind === 'reset') {
51987
+ if (hasState(effect.state)) state[effect.state] = initial[effect.state];
51988
+ else diagnostic('unknown-state', effect.state);
51989
+ } else if (effect.kind === 'toggle') {
51990
+ if (stateTypes[effect.state] === 'boolean') state[effect.state] = !state[effect.state];
51991
+ else diagnostic('invalid-toggle', effect.state);
51992
+ } else if (effect.kind === 'open') {
51993
+ var opened = overlayFor(current, effect.target);
51994
+ if (opened) opened.classList.remove(CLOSED);
51995
+ else diagnostic('unknown-overlay', effect.target);
51996
+ } else if (effect.kind === 'close') {
51997
+ var closed = overlayFor(current, effect.target);
51998
+ if (closed) closed.classList.add(CLOSED);
51999
+ else diagnostic('unknown-overlay', effect.target);
52000
+ }
52001
+ }
52002
+ applyOutcomes();
52003
+ }
52004
+
50754
52005
  function markActive(key) {
50755
52006
  for (var i = 0; i < shells.length; i++) {
50756
52007
  var links = shells[i].querySelectorAll('[data-navigate]');
@@ -50778,6 +52029,7 @@ function siteRuntime(registry, prefix) {
50778
52029
  current = key;
50779
52030
  closeOverlays(key);
50780
52031
  markActive(key);
52032
+ applyOutcomes();
50781
52033
  if (writeFragment) {
50782
52034
  var fragment = R.fragments[Number(key)] || key;
50783
52035
  if (location.hash.slice(1) !== fragment) location.hash = fragment;
@@ -50794,6 +52046,22 @@ function siteRuntime(registry, prefix) {
50794
52046
 
50795
52047
  document.addEventListener('click', function (event) {
50796
52048
  var target = event.target;
52049
+ var typed = target.closest ? target.closest('[' + ${embedJson(TYPED_INTERACTION_ATTR)} + ']') : null;
52050
+ if (typed) {
52051
+ var signatures = parseJson(typed.getAttribute(${embedJson(TYPED_INTERACTION_ATTR)}), []);
52052
+ var matched = false;
52053
+ for (var typedIndex = 0; typedIndex < signatures.length; typedIndex++) {
52054
+ var normalized = interactionFor(current, typed, signatures[typedIndex]);
52055
+ if (!normalized) continue;
52056
+ matched = true;
52057
+ if (guardPasses(normalized.guard)) applyEffects(normalized);
52058
+ }
52059
+ if (matched) {
52060
+ event.preventDefault();
52061
+ return;
52062
+ }
52063
+ }
52064
+
50797
52065
  var mover = target.closest ? target.closest('[data-navigate]') : null;
50798
52066
  if (mover) {
50799
52067
  var destination = resolve(mover.getAttribute('data-navigate'));
@@ -50832,6 +52100,7 @@ function siteRuntime(registry, prefix) {
50832
52100
  closeOverlays(current);
50833
52101
  return;
50834
52102
  }
52103
+ if (action !== '') diagnostic('unknown-action', action);
50835
52104
  }
50836
52105
 
50837
52106
  if (target.classList && target.classList.contains(P + '-modal-backdrop')) {
@@ -50849,6 +52118,7 @@ function siteRuntime(registry, prefix) {
50849
52118
  if (key !== null) show(key, false);
50850
52119
  });
50851
52120
 
52121
+ initOverlays();
50852
52122
  var start = fromFragment();
50853
52123
  if (start === null) start = String(R.entry);
50854
52124
  if (!show(start, false)) show(String(R.entry), false);
@@ -50924,13 +52194,43 @@ function resolveTitle(model, options, entry) {
50924
52194
  const title = model.screens[entry]?.page.title?.trim();
50925
52195
  return title || "Wireframe";
50926
52196
  }
52197
+ function compactRuntimeInteractions(model, interactions) {
52198
+ const handlers = [];
52199
+ const handlerIds = /* @__PURE__ */ new Map();
52200
+ const screenHandlers = {};
52201
+ const shellHandlers = {};
52202
+ const intern = (signature, handler) => {
52203
+ const existing = handlerIds.get(signature);
52204
+ if (existing !== void 0) return existing;
52205
+ const id = handlers.length;
52206
+ handlerIds.set(signature, id);
52207
+ handlers.push(handler);
52208
+ return id;
52209
+ };
52210
+ const add = (owner, key, id) => {
52211
+ const ids = owner[key] ?? (owner[key] = []);
52212
+ if (!ids.includes(id)) ids.push(id);
52213
+ };
52214
+ for (const interaction of interactions) {
52215
+ const id = intern(interaction.signature, interaction.handler);
52216
+ if (interaction.source === "screen") {
52217
+ add(screenHandlers, String(interaction.screenIndex), id);
52218
+ continue;
52219
+ }
52220
+ const shell = model.screens[interaction.screenIndex]?.shell;
52221
+ if (shell !== void 0) add(shellHandlers, shell, id);
52222
+ }
52223
+ return { handlers, screenHandlers, shellHandlers };
52224
+ }
50927
52225
  function renderSite(document, options = {}) {
50928
52226
  const prefix = options.classPrefix ?? DEFAULT_PREFIX2;
50929
52227
  const model = buildSiteModel(document);
52228
+ const interactionModel = collectInteractions(document);
50930
52229
  const make = (idScope) => new HtmlRenderer({
50931
52230
  theme: options.theme,
50932
52231
  classPrefix: prefix,
50933
52232
  background: options.background,
52233
+ annotationStyle: options.annotationStyle,
50934
52234
  includeStyles: false,
50935
52235
  idScope
50936
52236
  });
@@ -50938,12 +52238,16 @@ function renderSite(document, options = {}) {
50938
52238
  const standalone = model.screens.filter((screen) => screen.shell === void 0).map((screen) => renderStandaloneScreen(screen, make, prefix)).join("\n");
50939
52239
  const entry = resolveEntry(model, options);
50940
52240
  const theme = options.theme === "dark" ? darkTheme : defaultTheme;
50941
- const css = generateStyles(theme, prefix) + generateSiteStyles(prefix);
52241
+ const css = generateStyles(theme, prefix, options.annotationStyle) + generateSiteStyles(prefix);
52242
+ const runtimeInteractions = compactRuntimeInteractions(model, interactionModel.interactions);
50942
52243
  const runtime = siteRuntime(
50943
52244
  {
50944
52245
  names: Object.fromEntries(model.names),
50945
52246
  fragments: model.screens.map((screen) => screen.name ?? String(screen.index)),
50946
- entry: entry.index
52247
+ entry: entry.index,
52248
+ states: interactionModel.states,
52249
+ ...runtimeInteractions,
52250
+ diagnostics: interactionModel.diagnostics
50947
52251
  },
50948
52252
  prefix
50949
52253
  );
@@ -50951,7 +52255,8 @@ function renderSite(document, options = {}) {
50951
52255
  const siteAttrs = attrs([
50952
52256
  ["data-screen-count", String(model.screens.length)],
50953
52257
  ["data-shell-count", String(model.shells.length)],
50954
- ["data-wf-entry-unresolved", entry.unresolved]
52258
+ ["data-wf-entry-unresolved", entry.unresolved],
52259
+ ["data-wf-diagnostic-count", String(interactionModel.diagnostics.length)]
50955
52260
  ]);
50956
52261
  return `<!DOCTYPE html>
50957
52262
  <html lang="en">