@wireweave/core 3.1.0-beta.2 → 3.1.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +6934 -4571
- package/dist/index.d.cts +307 -13
- package/dist/index.d.ts +307 -13
- package/dist/index.js +6919 -4571
- package/dist/parser.cjs +1896 -927
- package/dist/parser.d.cts +1 -1
- package/dist/parser.d.ts +1 -1
- package/dist/parser.js +1896 -927
- package/dist/renderer.cjs +1506 -166
- package/dist/renderer.d.cts +103 -5
- package/dist/renderer.d.ts +103 -5
- package/dist/renderer.js +1505 -166
- package/dist/{types-BDaNyWMR.d.cts → types-Bb3NSNUs.d.cts} +89 -7
- package/dist/{types-BDaNyWMR.d.ts → types-Bb3NSNUs.d.ts} +89 -7
- package/package.json +4 -2
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:
|
|
1438
|
-
border: 2px solid
|
|
1439
|
-
color:
|
|
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:
|
|
1456
|
-
border: 2px dashed
|
|
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:
|
|
1487
|
+
color: ${headerColor};
|
|
1469
1488
|
margin-bottom: 16px;
|
|
1470
1489
|
padding-bottom: 8px;
|
|
1471
|
-
border-bottom: 1px solid
|
|
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:
|
|
1505
|
-
color:
|
|
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:
|
|
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:
|
|
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:
|
|
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(
|
|
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(" ");
|
|
@@ -2380,8 +3632,8 @@ function renderCard(node, ctx) {
|
|
|
2380
3632
|
]);
|
|
2381
3633
|
const styles = ctx.buildCommonStyles(node);
|
|
2382
3634
|
const styleAttr = styles ? ` style="${styles}"` : "";
|
|
2383
|
-
const
|
|
2384
|
-
const interactiveAttrStr = ctx.buildAttrsString(
|
|
3635
|
+
const interactiveAttrs2 = buildInteractiveAttrs(node);
|
|
3636
|
+
const interactiveAttrStr = ctx.buildAttrsString(interactiveAttrs2);
|
|
2385
3637
|
const title = node.title ? `<h3 class="${ctx.prefix}-title">${ctx.escapeHtml(node.title)}</h3>
|
|
2386
3638
|
` : "";
|
|
2387
3639
|
const children = ctx.renderChildren(node.children);
|
|
@@ -2496,14 +3748,11 @@ function renderLink(node, ctx) {
|
|
|
2496
3748
|
const classes = ctx.buildClassString([`${ctx.prefix}-link`, ...ctx.getCommonClasses(node)]);
|
|
2497
3749
|
const styles = ctx.buildCommonStyles(node);
|
|
2498
3750
|
const styleAttr = styles ? ` style="${styles}"` : "";
|
|
3751
|
+
const { href, attrs: intentAttrs } = anchorIntent(node);
|
|
2499
3752
|
const attrs2 = {
|
|
2500
3753
|
class: classes,
|
|
2501
|
-
href
|
|
2502
|
-
|
|
2503
|
-
"data-navigate": node.navigate,
|
|
2504
|
-
"data-opens": node.opens,
|
|
2505
|
-
"data-toggles": node.toggles,
|
|
2506
|
-
"data-action": node.action
|
|
3754
|
+
href,
|
|
3755
|
+
...intentAttrs
|
|
2507
3756
|
};
|
|
2508
3757
|
if (node.external) {
|
|
2509
3758
|
attrs2.target = "_blank";
|
|
@@ -49225,8 +50474,8 @@ function renderImage(node, ctx) {
|
|
|
49225
50474
|
}
|
|
49226
50475
|
const label = node.alt || "Image";
|
|
49227
50476
|
const icon = `<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21 15 16 10 5 21"/></svg>`;
|
|
49228
|
-
const
|
|
49229
|
-
const interactiveAttrStr = ctx.buildAttrsString(
|
|
50477
|
+
const interactiveAttrs2 = buildInteractiveAttrs2(node);
|
|
50478
|
+
const interactiveAttrStr = ctx.buildAttrsString(interactiveAttrs2);
|
|
49230
50479
|
return `<div class="${classes}"${styleAttr}${interactiveAttrStr} role="img" aria-label="${ctx.escapeHtml(label)}">${icon}<span>${ctx.escapeHtml(label)}</span></div>`;
|
|
49231
50480
|
}
|
|
49232
50481
|
function renderPlaceholder(node, ctx) {
|
|
@@ -49269,13 +50518,13 @@ function renderAvatar(node, ctx) {
|
|
|
49269
50518
|
content = "?";
|
|
49270
50519
|
}
|
|
49271
50520
|
}
|
|
49272
|
-
const
|
|
49273
|
-
const interactiveAttrStr = ctx.buildAttrsString(
|
|
50521
|
+
const interactiveAttrs2 = buildInteractiveAttrs2(node);
|
|
50522
|
+
const interactiveAttrStr = ctx.buildAttrsString(interactiveAttrs2);
|
|
49274
50523
|
return `<div class="${classes}"${styleAttr}${interactiveAttrStr} role="img" aria-label="${ctx.escapeHtml(node.name || "Avatar")}">${content}</div>`;
|
|
49275
50524
|
}
|
|
49276
50525
|
function renderBadge(node, ctx) {
|
|
49277
|
-
const
|
|
49278
|
-
const interactiveAttrStr = ctx.buildAttrsString(
|
|
50526
|
+
const interactiveAttrs2 = buildInteractiveAttrs2(node);
|
|
50527
|
+
const interactiveAttrStr = ctx.buildAttrsString(interactiveAttrs2);
|
|
49279
50528
|
const sizeResolved = resolveSizeValue(node.size, "badge", ctx.prefix);
|
|
49280
50529
|
if (node.icon) {
|
|
49281
50530
|
const iconData = getIconData(node.icon);
|
|
@@ -49314,8 +50563,8 @@ function renderBadge(node, ctx) {
|
|
|
49314
50563
|
}
|
|
49315
50564
|
function renderIcon(node, ctx) {
|
|
49316
50565
|
const iconData = getIconData(node.name);
|
|
49317
|
-
const
|
|
49318
|
-
const interactiveAttrStr = ctx.buildAttrsString(
|
|
50566
|
+
const interactiveAttrs2 = buildInteractiveAttrs2(node);
|
|
50567
|
+
const interactiveAttrStr = ctx.buildAttrsString(interactiveAttrs2);
|
|
49319
50568
|
const sizeResolved = resolveSizeValue(node.size, "icon", ctx.prefix);
|
|
49320
50569
|
const wrapperClasses = ctx.buildClassString([
|
|
49321
50570
|
`${ctx.prefix}-icon-wrapper`,
|
|
@@ -49382,18 +50631,13 @@ function renderDropdown(node, ctx) {
|
|
|
49382
50631
|
dropdownItem.danger ? `${ctx.prefix}-dropdown-item-danger` : void 0,
|
|
49383
50632
|
dropdownItem.disabled ? `${ctx.prefix}-dropdown-item-disabled` : void 0
|
|
49384
50633
|
]);
|
|
49385
|
-
const interactiveAttrs = {
|
|
49386
|
-
"data-navigate": dropdownItem.navigate,
|
|
49387
|
-
"data-opens": dropdownItem.opens,
|
|
49388
|
-
"data-toggles": dropdownItem.toggles,
|
|
49389
|
-
"data-action": dropdownItem.action
|
|
49390
|
-
};
|
|
49391
|
-
const interactiveAttrStr = ctx.buildAttrsString(interactiveAttrs);
|
|
49392
50634
|
const disabledAttr = dropdownItem.disabled ? ' disabled="disabled"' : "";
|
|
49393
50635
|
if (dropdownItem.href || dropdownItem.navigate) {
|
|
49394
|
-
const href
|
|
49395
|
-
|
|
50636
|
+
const { href, attrs: attrs2 } = anchorIntent(dropdownItem);
|
|
50637
|
+
const anchorAttrStr = ctx.buildAttrsString(attrs2);
|
|
50638
|
+
return `<a class="${itemClasses}" href="${ctx.escapeHtml(href)}"${anchorAttrStr}>${ctx.escapeHtml(dropdownItem.label)}</a>`;
|
|
49396
50639
|
}
|
|
50640
|
+
const interactiveAttrStr = ctx.buildAttrsString(nonAnchorIntent(dropdownItem));
|
|
49397
50641
|
return `<button class="${itemClasses}"${disabledAttr}${interactiveAttrStr}>${ctx.escapeHtml(dropdownItem.label)}</button>`;
|
|
49398
50642
|
}).join("\n");
|
|
49399
50643
|
return `<div class="${classes}"${styleAttr}>
|
|
@@ -49412,7 +50656,9 @@ function renderNavItem(item, ctx) {
|
|
|
49412
50656
|
item.disabled ? `${ctx.prefix}-nav-link-disabled` : void 0
|
|
49413
50657
|
]);
|
|
49414
50658
|
const iconHtml = item.icon ? renderIconHtml(item.icon, ctx.prefix) + " " : "";
|
|
49415
|
-
|
|
50659
|
+
const { href, attrs: attrs2 } = anchorIntent(item);
|
|
50660
|
+
const intentAttrs = ctx.buildAttrsString(attrs2);
|
|
50661
|
+
return `<a class="${linkClasses}" href="${ctx.escapeHtml(href)}"${intentAttrs}>${iconHtml}${ctx.escapeHtml(item.label)}</a>`;
|
|
49416
50662
|
}
|
|
49417
50663
|
function renderNavChildren(children, ctx) {
|
|
49418
50664
|
return children.map((child) => {
|
|
@@ -49455,13 +50701,7 @@ ${content}
|
|
|
49455
50701
|
if (typeof item === "string") {
|
|
49456
50702
|
return `<a class="${ctx.prefix}-nav-link" href="#">${ctx.escapeHtml(item)}</a>`;
|
|
49457
50703
|
}
|
|
49458
|
-
|
|
49459
|
-
`${ctx.prefix}-nav-link`,
|
|
49460
|
-
item.active ? `${ctx.prefix}-nav-link-active` : void 0,
|
|
49461
|
-
item.disabled ? `${ctx.prefix}-nav-link-disabled` : void 0
|
|
49462
|
-
]);
|
|
49463
|
-
const iconHtml = item.icon ? renderIconHtml(item.icon, ctx.prefix) + " " : "";
|
|
49464
|
-
return `<a class="${linkClasses}" href="${item.href || "#"}">${iconHtml}${ctx.escapeHtml(item.label)}</a>`;
|
|
50704
|
+
return renderNavItem(item, ctx);
|
|
49465
50705
|
}).join("\n");
|
|
49466
50706
|
return `<nav class="${classes}"${styleAttr}>
|
|
49467
50707
|
${items}
|
|
@@ -49492,7 +50732,13 @@ function renderBreadcrumb(node, ctx) {
|
|
|
49492
50732
|
if (typeof item === "string") {
|
|
49493
50733
|
return isLast ? `<span class="${ctx.prefix}-breadcrumb-item" aria-current="page">${ctx.escapeHtml(item)}</span>` : `<a class="${ctx.prefix}-breadcrumb-item" href="#">${ctx.escapeHtml(item)}</a>`;
|
|
49494
50734
|
}
|
|
49495
|
-
|
|
50735
|
+
if (isLast) {
|
|
50736
|
+
const intentAttrs2 = ctx.buildAttrsString(nonAnchorIntent(item));
|
|
50737
|
+
return `<span class="${ctx.prefix}-breadcrumb-item" aria-current="page"${intentAttrs2}>${ctx.escapeHtml(item.label)}</span>`;
|
|
50738
|
+
}
|
|
50739
|
+
const { href, attrs: attrs2 } = anchorIntent(item);
|
|
50740
|
+
const intentAttrs = ctx.buildAttrsString(attrs2);
|
|
50741
|
+
return `<a class="${ctx.prefix}-breadcrumb-item" href="${ctx.escapeHtml(href)}"${intentAttrs}>${ctx.escapeHtml(item.label)}</a>`;
|
|
49496
50742
|
}).join(separator);
|
|
49497
50743
|
return `<nav class="${classes}"${styleAttr} aria-label="Breadcrumb">${items}</nav>`;
|
|
49498
50744
|
}
|
|
@@ -49637,6 +50883,12 @@ var MARKER_COLORS = {
|
|
|
49637
50883
|
purple: { bg: "#a855f7", border: "#9333ea" },
|
|
49638
50884
|
orange: { bg: "#f97316", border: "#ea580c" }
|
|
49639
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
|
+
}
|
|
49640
50892
|
function getAnchorStyles(anchor) {
|
|
49641
50893
|
if (!anchor) return "";
|
|
49642
50894
|
const styles = ["position: absolute"];
|
|
@@ -49672,8 +50924,7 @@ function getAnchorStyles(anchor) {
|
|
|
49672
50924
|
return styles.join("; ");
|
|
49673
50925
|
}
|
|
49674
50926
|
function renderMarker(node, ctx) {
|
|
49675
|
-
const color = node.color
|
|
49676
|
-
const colorConfig = MARKER_COLORS[color] || MARKER_COLORS.blue;
|
|
50927
|
+
const color = markerStyle(node.color, ctx.annotationStyle);
|
|
49677
50928
|
const baseStyles = [
|
|
49678
50929
|
"display: inline-flex",
|
|
49679
50930
|
"align-items: center",
|
|
@@ -49681,9 +50932,9 @@ function renderMarker(node, ctx) {
|
|
|
49681
50932
|
"width: 20px",
|
|
49682
50933
|
"height: 20px",
|
|
49683
50934
|
"border-radius: 50%",
|
|
49684
|
-
`background: ${
|
|
49685
|
-
`border: 2px solid ${
|
|
49686
|
-
|
|
50935
|
+
`background: ${color.bg}`,
|
|
50936
|
+
`border: 2px solid ${color.border}`,
|
|
50937
|
+
`color: ${color.foreground}`,
|
|
49687
50938
|
"font-size: 11px",
|
|
49688
50939
|
"font-weight: 600",
|
|
49689
50940
|
"line-height: 1",
|
|
@@ -49714,8 +50965,8 @@ function renderAnnotations(node, ctx) {
|
|
|
49714
50965
|
</aside>`;
|
|
49715
50966
|
}
|
|
49716
50967
|
function renderAnnotationItem(node, ctx) {
|
|
49717
|
-
const color =
|
|
49718
|
-
const
|
|
50968
|
+
const color = markerStyle("blue", ctx.annotationStyle);
|
|
50969
|
+
const inlineStyle = [
|
|
49719
50970
|
"display: inline-flex",
|
|
49720
50971
|
"align-items: center",
|
|
49721
50972
|
"justify-content: center",
|
|
@@ -49723,7 +50974,7 @@ function renderAnnotationItem(node, ctx) {
|
|
|
49723
50974
|
"height: 18px",
|
|
49724
50975
|
"border-radius: 50%",
|
|
49725
50976
|
`background: ${color.bg}`,
|
|
49726
|
-
|
|
50977
|
+
`color: ${color.foreground}`,
|
|
49727
50978
|
"font-size: 10px",
|
|
49728
50979
|
"font-weight: 600",
|
|
49729
50980
|
"flex-shrink: 0"
|
|
@@ -49732,7 +50983,7 @@ function renderAnnotationItem(node, ctx) {
|
|
|
49732
50983
|
const content = children.length > 0 ? ctx.renderChildren(children) : "";
|
|
49733
50984
|
return `<div class="${ctx.prefix}-annotation-item">
|
|
49734
50985
|
<div class="${ctx.prefix}-annotation-item-header">
|
|
49735
|
-
<span class="${ctx.prefix}-annotation-marker" style="${
|
|
50986
|
+
<span class="${ctx.prefix}-annotation-marker" style="${inlineStyle}">${node.number}</span>
|
|
49736
50987
|
<span class="${ctx.prefix}-annotation-item-title">${ctx.escapeHtml(node.title)}</span>
|
|
49737
50988
|
</div>
|
|
49738
50989
|
${content ? `<div class="${ctx.prefix}-annotation-item-content">${content}</div>` : ""}
|
|
@@ -49824,6 +51075,7 @@ var HtmlRenderer = class extends BaseRenderer {
|
|
|
49824
51075
|
getRenderContext() {
|
|
49825
51076
|
return {
|
|
49826
51077
|
prefix: this.prefix,
|
|
51078
|
+
annotationStyle: this.context.options.annotationStyle,
|
|
49827
51079
|
escapeHtml: this.escapeHtml.bind(this),
|
|
49828
51080
|
scopedId: this.scopedId.bind(this),
|
|
49829
51081
|
buildClassString: this.buildClassString.bind(this),
|
|
@@ -49904,6 +51156,7 @@ var HtmlRenderer = class extends BaseRenderer {
|
|
|
49904
51156
|
// Other
|
|
49905
51157
|
Divider: (node) => this.renderDivider(node),
|
|
49906
51158
|
Slot: () => this.renderSlot(),
|
|
51159
|
+
ComponentUse: (node) => this.renderComponentUse(node),
|
|
49907
51160
|
// Annotation nodes
|
|
49908
51161
|
Marker: (node) => this.renderMarker(node),
|
|
49909
51162
|
Annotations: (node) => this.renderAnnotations(node),
|
|
@@ -49971,7 +51224,17 @@ ${annotationsContent}
|
|
|
49971
51224
|
*/
|
|
49972
51225
|
renderNode(node) {
|
|
49973
51226
|
const renderer = this.nodeRenderers[node.type];
|
|
49974
|
-
|
|
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
|
+
}
|
|
49975
51238
|
if (this.pathMap && node.type !== "Page") {
|
|
49976
51239
|
const path = this.pathMap.get(node);
|
|
49977
51240
|
if (path !== void 0) {
|
|
@@ -49987,6 +51250,18 @@ ${annotationsContent}
|
|
|
49987
51250
|
const open = `<div class="${this.prefix}-slot">`;
|
|
49988
51251
|
return content === null ? `${open}</div>` : `${open}
|
|
49989
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}
|
|
49990
51265
|
</div>`;
|
|
49991
51266
|
}
|
|
49992
51267
|
/** Render nodes without adding a page frame, optionally filling a slot. */
|
|
@@ -50389,27 +51664,6 @@ function createHtmlRenderer(options) {
|
|
|
50389
51664
|
return new HtmlRenderer(options);
|
|
50390
51665
|
}
|
|
50391
51666
|
|
|
50392
|
-
// src/renderer/page-renderer.ts
|
|
50393
|
-
function renderPage(page, options = {}) {
|
|
50394
|
-
const renderer = new HtmlRenderer(options);
|
|
50395
|
-
const { html, css } = renderer.render({
|
|
50396
|
-
type: "Document",
|
|
50397
|
-
children: [page]
|
|
50398
|
-
});
|
|
50399
|
-
const { width, height } = resolvePageDimensions(page);
|
|
50400
|
-
return { html, css, width, height };
|
|
50401
|
-
}
|
|
50402
|
-
function resolvePageDimensions(page) {
|
|
50403
|
-
const pageAny = page;
|
|
50404
|
-
const explicitW = page.w ?? pageAny.width;
|
|
50405
|
-
const explicitH = page.h ?? pageAny.height;
|
|
50406
|
-
if (typeof explicitW === "number" && typeof explicitH === "number") {
|
|
50407
|
-
return { width: explicitW, height: explicitH };
|
|
50408
|
-
}
|
|
50409
|
-
const viewport = resolveViewport(page.viewport, page.device);
|
|
50410
|
-
return { width: viewport.width, height: viewport.height };
|
|
50411
|
-
}
|
|
50412
|
-
|
|
50413
51667
|
// src/renderer/canvas-renderer.ts
|
|
50414
51668
|
var DEFAULT_GAP = 64;
|
|
50415
51669
|
var DEFAULT_PREFIX = "wf";
|
|
@@ -50438,7 +51692,7 @@ function renderCanvas(doc, options = {}) {
|
|
|
50438
51692
|
const prefix = options.classPrefix ?? DEFAULT_PREFIX;
|
|
50439
51693
|
const includeStyles = options.includeStyles !== false;
|
|
50440
51694
|
const theme = options.theme === "dark" ? darkTheme : defaultTheme;
|
|
50441
|
-
const css = includeStyles ? generateStyles(theme, prefix) : "";
|
|
51695
|
+
const css = includeStyles ? generateStyles(theme, prefix, options.annotationStyle) : "";
|
|
50442
51696
|
const pages = documentPages(doc);
|
|
50443
51697
|
if (pages.length === 0) {
|
|
50444
51698
|
return {
|
|
@@ -50476,85 +51730,6 @@ function escapeAttr(s) {
|
|
|
50476
51730
|
return s.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<");
|
|
50477
51731
|
}
|
|
50478
51732
|
|
|
50479
|
-
// src/renderer/site/model.ts
|
|
50480
|
-
function pageId(page) {
|
|
50481
|
-
const id = page.id?.trim();
|
|
50482
|
-
return id && id.length > 0 ? id : void 0;
|
|
50483
|
-
}
|
|
50484
|
-
function pageTitle(page) {
|
|
50485
|
-
const title = page.title?.trim();
|
|
50486
|
-
return title && title.length > 0 ? title : void 0;
|
|
50487
|
-
}
|
|
50488
|
-
function hasSlot(layout) {
|
|
50489
|
-
for (const child of layout.children) {
|
|
50490
|
-
let found = false;
|
|
50491
|
-
walk(child, (node) => {
|
|
50492
|
-
if (node.type === "Slot") found = true;
|
|
50493
|
-
return !found;
|
|
50494
|
-
});
|
|
50495
|
-
if (found) return true;
|
|
50496
|
-
}
|
|
50497
|
-
return false;
|
|
50498
|
-
}
|
|
50499
|
-
function layoutsByName(doc) {
|
|
50500
|
-
const layouts = /* @__PURE__ */ new Map();
|
|
50501
|
-
for (const definition of documentDefinitions(doc)) {
|
|
50502
|
-
const name = definition.name.trim();
|
|
50503
|
-
if (name.length > 0 && !layouts.has(name)) layouts.set(name, definition);
|
|
50504
|
-
}
|
|
50505
|
-
return layouts;
|
|
50506
|
-
}
|
|
50507
|
-
function resolveShell(page, layouts) {
|
|
50508
|
-
const uses = page.uses?.trim();
|
|
50509
|
-
if (!uses) return void 0;
|
|
50510
|
-
const layout = layouts.get(uses);
|
|
50511
|
-
if (!layout) return { miss: { uses, reason: "unknown-layout" } };
|
|
50512
|
-
if (!hasSlot(layout)) return { miss: { uses, reason: "slotless-layout" } };
|
|
50513
|
-
return { layout, name: uses };
|
|
50514
|
-
}
|
|
50515
|
-
function buildSiteModel(doc) {
|
|
50516
|
-
const screens = documentPages(doc).map((page, index) => ({ index, page }));
|
|
50517
|
-
const layouts = layoutsByName(doc);
|
|
50518
|
-
const shells = [];
|
|
50519
|
-
const shellByName = /* @__PURE__ */ new Map();
|
|
50520
|
-
for (const screen of screens) {
|
|
50521
|
-
const resolved = resolveShell(screen.page, layouts);
|
|
50522
|
-
if (!resolved) continue;
|
|
50523
|
-
if ("miss" in resolved) {
|
|
50524
|
-
screen.miss = resolved.miss;
|
|
50525
|
-
continue;
|
|
50526
|
-
}
|
|
50527
|
-
let shell = shellByName.get(resolved.name);
|
|
50528
|
-
if (!shell) {
|
|
50529
|
-
const { width, height } = resolvePageDimensions(screen.page);
|
|
50530
|
-
shell = { name: resolved.name, layout: resolved.layout, screens: [], width, height };
|
|
50531
|
-
shellByName.set(resolved.name, shell);
|
|
50532
|
-
shells.push(shell);
|
|
50533
|
-
}
|
|
50534
|
-
shell.screens.push(screen);
|
|
50535
|
-
screen.shell = shell.name;
|
|
50536
|
-
}
|
|
50537
|
-
const names = /* @__PURE__ */ new Map();
|
|
50538
|
-
for (const screen of screens) {
|
|
50539
|
-
const title = pageTitle(screen.page);
|
|
50540
|
-
if (title !== void 0 && !names.has(title)) names.set(title, screen.index);
|
|
50541
|
-
}
|
|
50542
|
-
for (const screen of screens) {
|
|
50543
|
-
const id = pageId(screen.page);
|
|
50544
|
-
if (id === void 0) continue;
|
|
50545
|
-
const owner = names.get(id);
|
|
50546
|
-
if (owner === void 0 || pageId(screens[owner].page) !== id) {
|
|
50547
|
-
names.set(id, screen.index);
|
|
50548
|
-
}
|
|
50549
|
-
}
|
|
50550
|
-
for (const screen of screens) {
|
|
50551
|
-
screen.name = [pageId(screen.page), pageTitle(screen.page)].find(
|
|
50552
|
-
(name) => name !== void 0 && names.get(name) === screen.index
|
|
50553
|
-
);
|
|
50554
|
-
}
|
|
50555
|
-
return { screens, shells, names, entry: screens.length > 0 ? 0 : -1 };
|
|
50556
|
-
}
|
|
50557
|
-
|
|
50558
51733
|
// src/renderer/site/styles.ts
|
|
50559
51734
|
function generateSiteStyles(prefix) {
|
|
50560
51735
|
return `
|
|
@@ -50652,6 +51827,61 @@ function siteRuntime(registry, prefix) {
|
|
|
50652
51827
|
}
|
|
50653
51828
|
}
|
|
50654
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
|
+
}
|
|
50655
51885
|
|
|
50656
51886
|
function isChrome(el) {
|
|
50657
51887
|
return !(el.closest && el.closest('[data-screen]'));
|
|
@@ -50718,6 +51948,60 @@ function siteRuntime(registry, prefix) {
|
|
|
50718
51948
|
}
|
|
50719
51949
|
}
|
|
50720
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
|
+
|
|
50721
52005
|
function markActive(key) {
|
|
50722
52006
|
for (var i = 0; i < shells.length; i++) {
|
|
50723
52007
|
var links = shells[i].querySelectorAll('[data-navigate]');
|
|
@@ -50745,6 +52029,7 @@ function siteRuntime(registry, prefix) {
|
|
|
50745
52029
|
current = key;
|
|
50746
52030
|
closeOverlays(key);
|
|
50747
52031
|
markActive(key);
|
|
52032
|
+
applyOutcomes();
|
|
50748
52033
|
if (writeFragment) {
|
|
50749
52034
|
var fragment = R.fragments[Number(key)] || key;
|
|
50750
52035
|
if (location.hash.slice(1) !== fragment) location.hash = fragment;
|
|
@@ -50761,6 +52046,22 @@ function siteRuntime(registry, prefix) {
|
|
|
50761
52046
|
|
|
50762
52047
|
document.addEventListener('click', function (event) {
|
|
50763
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
|
+
|
|
50764
52065
|
var mover = target.closest ? target.closest('[data-navigate]') : null;
|
|
50765
52066
|
if (mover) {
|
|
50766
52067
|
var destination = resolve(mover.getAttribute('data-navigate'));
|
|
@@ -50799,6 +52100,7 @@ function siteRuntime(registry, prefix) {
|
|
|
50799
52100
|
closeOverlays(current);
|
|
50800
52101
|
return;
|
|
50801
52102
|
}
|
|
52103
|
+
if (action !== '') diagnostic('unknown-action', action);
|
|
50802
52104
|
}
|
|
50803
52105
|
|
|
50804
52106
|
if (target.classList && target.classList.contains(P + '-modal-backdrop')) {
|
|
@@ -50816,6 +52118,7 @@ function siteRuntime(registry, prefix) {
|
|
|
50816
52118
|
if (key !== null) show(key, false);
|
|
50817
52119
|
});
|
|
50818
52120
|
|
|
52121
|
+
initOverlays();
|
|
50819
52122
|
var start = fromFragment();
|
|
50820
52123
|
if (start === null) start = String(R.entry);
|
|
50821
52124
|
if (!show(start, false)) show(String(R.entry), false);
|
|
@@ -50891,13 +52194,43 @@ function resolveTitle(model, options, entry) {
|
|
|
50891
52194
|
const title = model.screens[entry]?.page.title?.trim();
|
|
50892
52195
|
return title || "Wireframe";
|
|
50893
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
|
+
}
|
|
50894
52225
|
function renderSite(document, options = {}) {
|
|
50895
52226
|
const prefix = options.classPrefix ?? DEFAULT_PREFIX2;
|
|
50896
52227
|
const model = buildSiteModel(document);
|
|
52228
|
+
const interactionModel = collectInteractions(document);
|
|
50897
52229
|
const make = (idScope) => new HtmlRenderer({
|
|
50898
52230
|
theme: options.theme,
|
|
50899
52231
|
classPrefix: prefix,
|
|
50900
52232
|
background: options.background,
|
|
52233
|
+
annotationStyle: options.annotationStyle,
|
|
50901
52234
|
includeStyles: false,
|
|
50902
52235
|
idScope
|
|
50903
52236
|
});
|
|
@@ -50905,12 +52238,16 @@ function renderSite(document, options = {}) {
|
|
|
50905
52238
|
const standalone = model.screens.filter((screen) => screen.shell === void 0).map((screen) => renderStandaloneScreen(screen, make, prefix)).join("\n");
|
|
50906
52239
|
const entry = resolveEntry(model, options);
|
|
50907
52240
|
const theme = options.theme === "dark" ? darkTheme : defaultTheme;
|
|
50908
|
-
const css = generateStyles(theme, prefix) + generateSiteStyles(prefix);
|
|
52241
|
+
const css = generateStyles(theme, prefix, options.annotationStyle) + generateSiteStyles(prefix);
|
|
52242
|
+
const runtimeInteractions = compactRuntimeInteractions(model, interactionModel.interactions);
|
|
50909
52243
|
const runtime = siteRuntime(
|
|
50910
52244
|
{
|
|
50911
52245
|
names: Object.fromEntries(model.names),
|
|
50912
52246
|
fragments: model.screens.map((screen) => screen.name ?? String(screen.index)),
|
|
50913
|
-
entry: entry.index
|
|
52247
|
+
entry: entry.index,
|
|
52248
|
+
states: interactionModel.states,
|
|
52249
|
+
...runtimeInteractions,
|
|
52250
|
+
diagnostics: interactionModel.diagnostics
|
|
50914
52251
|
},
|
|
50915
52252
|
prefix
|
|
50916
52253
|
);
|
|
@@ -50918,7 +52255,8 @@ function renderSite(document, options = {}) {
|
|
|
50918
52255
|
const siteAttrs = attrs([
|
|
50919
52256
|
["data-screen-count", String(model.screens.length)],
|
|
50920
52257
|
["data-shell-count", String(model.shells.length)],
|
|
50921
|
-
["data-wf-entry-unresolved", entry.unresolved]
|
|
52258
|
+
["data-wf-entry-unresolved", entry.unresolved],
|
|
52259
|
+
["data-wf-diagnostic-count", String(interactionModel.diagnostics.length)]
|
|
50922
52260
|
]);
|
|
50923
52261
|
return `<!DOCTYPE html>
|
|
50924
52262
|
<html lang="en">
|
|
@@ -51055,6 +52393,7 @@ ${css}
|
|
|
51055
52393
|
}
|
|
51056
52394
|
export {
|
|
51057
52395
|
HtmlRenderer,
|
|
52396
|
+
anchorIntent,
|
|
51058
52397
|
buildSiteModel,
|
|
51059
52398
|
createHtmlRenderer,
|
|
51060
52399
|
darkTheme,
|