@wireweave/core 3.1.0-beta.1 → 3.1.0-beta.3
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 +1795 -1018
- package/dist/index.d.cts +34 -12
- package/dist/index.d.ts +34 -12
- package/dist/index.js +1788 -1018
- package/dist/parser.cjs +1003 -845
- package/dist/parser.d.cts +1 -1
- package/dist/parser.d.ts +1 -1
- package/dist/parser.js +1003 -845
- package/dist/renderer.cjs +641 -74
- package/dist/renderer.d.cts +79 -2
- package/dist/renderer.d.ts +79 -2
- package/dist/renderer.js +638 -74
- package/dist/{types-BDbXDhTp.d.cts → types-BDaNyWMR.d.cts} +28 -6
- package/dist/{types-BDbXDhTp.d.ts → types-BDaNyWMR.d.ts} +28 -6
- package/package.json +2 -2
package/dist/renderer.cjs
CHANGED
|
@@ -21,6 +21,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var renderer_exports = {};
|
|
22
22
|
__export(renderer_exports, {
|
|
23
23
|
HtmlRenderer: () => HtmlRenderer,
|
|
24
|
+
anchorIntent: () => anchorIntent,
|
|
25
|
+
buildSiteModel: () => buildSiteModel,
|
|
24
26
|
createHtmlRenderer: () => createHtmlRenderer,
|
|
25
27
|
darkTheme: () => darkTheme,
|
|
26
28
|
defaultTheme: () => defaultTheme,
|
|
@@ -34,6 +36,7 @@ __export(renderer_exports, {
|
|
|
34
36
|
renderCanvas: () => renderCanvas,
|
|
35
37
|
renderIconSvg: () => renderIconSvg,
|
|
36
38
|
renderPage: () => renderPage,
|
|
39
|
+
renderSite: () => renderSite,
|
|
37
40
|
renderToHtml: () => renderToHtml,
|
|
38
41
|
renderToSvg: () => renderToSvg,
|
|
39
42
|
renderUnknownIconSvg: () => renderUnknownIconSvg,
|
|
@@ -41,6 +44,30 @@ __export(renderer_exports, {
|
|
|
41
44
|
});
|
|
42
45
|
module.exports = __toCommonJS(renderer_exports);
|
|
43
46
|
|
|
47
|
+
// src/ast/guards.ts
|
|
48
|
+
function hasChildren(node) {
|
|
49
|
+
return "children" in node && Array.isArray(node.children);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// src/ast/utils.ts
|
|
53
|
+
function walk(node, callback, parent, depth = 0) {
|
|
54
|
+
const result = callback(node, parent, depth);
|
|
55
|
+
if (result === false) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (hasChildren(node)) {
|
|
59
|
+
for (const child of node.children) {
|
|
60
|
+
walk(child, callback, node, depth + 1);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function documentPages(document) {
|
|
65
|
+
return document.children.filter((child) => child.type === "Page");
|
|
66
|
+
}
|
|
67
|
+
function documentDefinitions(document) {
|
|
68
|
+
return document.children.filter((child) => child.type === "Layout");
|
|
69
|
+
}
|
|
70
|
+
|
|
44
71
|
// src/renderer/types.ts
|
|
45
72
|
var defaultTheme = {
|
|
46
73
|
colors: {
|
|
@@ -1995,7 +2022,8 @@ var DEFAULT_OPTIONS = {
|
|
|
1995
2022
|
includeStyles: true,
|
|
1996
2023
|
minify: false,
|
|
1997
2024
|
classPrefix: "wf",
|
|
1998
|
-
sourceAnchors: false
|
|
2025
|
+
sourceAnchors: false,
|
|
2026
|
+
idScope: ""
|
|
1999
2027
|
};
|
|
2000
2028
|
var BaseRenderer = class {
|
|
2001
2029
|
context;
|
|
@@ -2034,7 +2062,7 @@ var BaseRenderer = class {
|
|
|
2034
2062
|
* Render a complete wireframe document
|
|
2035
2063
|
*/
|
|
2036
2064
|
renderDocument(document) {
|
|
2037
|
-
const pages = document.
|
|
2065
|
+
const pages = documentPages(document).map((page) => this.renderPage(page)).join(this.context.options.minify ? "" : "\n");
|
|
2038
2066
|
return pages;
|
|
2039
2067
|
}
|
|
2040
2068
|
/**
|
|
@@ -2075,6 +2103,10 @@ var BaseRenderer = class {
|
|
|
2075
2103
|
};
|
|
2076
2104
|
return text.replace(/[&<>"']/g, (char) => escapeMap[char] || char);
|
|
2077
2105
|
}
|
|
2106
|
+
/** Return the DOM id for an authored id under this renderer's scope. */
|
|
2107
|
+
scopedId(id) {
|
|
2108
|
+
return this.context.options.idScope + id;
|
|
2109
|
+
}
|
|
2078
2110
|
/**
|
|
2079
2111
|
* Build a CSS class string from an array of class names
|
|
2080
2112
|
*/
|
|
@@ -2084,9 +2116,9 @@ var BaseRenderer = class {
|
|
|
2084
2116
|
/**
|
|
2085
2117
|
* Build HTML attributes string
|
|
2086
2118
|
*/
|
|
2087
|
-
buildAttrsString(
|
|
2119
|
+
buildAttrsString(attrs2) {
|
|
2088
2120
|
const parts = [];
|
|
2089
|
-
for (const [key, value] of Object.entries(
|
|
2121
|
+
for (const [key, value] of Object.entries(attrs2)) {
|
|
2090
2122
|
if (value === void 0 || value === false) {
|
|
2091
2123
|
continue;
|
|
2092
2124
|
}
|
|
@@ -2196,7 +2228,7 @@ function formatAnchorLoc(loc) {
|
|
|
2196
2228
|
return `${loc.start.offset}-${loc.end.offset}`;
|
|
2197
2229
|
}
|
|
2198
2230
|
function walkAnchorPaths(doc, visit, pageIndexBase = 0) {
|
|
2199
|
-
doc.
|
|
2231
|
+
documentPages(doc).forEach((page, i) => {
|
|
2200
2232
|
visitAnchorNode(page, String(pageIndexBase + i), visit);
|
|
2201
2233
|
});
|
|
2202
2234
|
}
|
|
@@ -2394,8 +2426,8 @@ function renderCard(node, ctx) {
|
|
|
2394
2426
|
]);
|
|
2395
2427
|
const styles = ctx.buildCommonStyles(node);
|
|
2396
2428
|
const styleAttr = styles ? ` style="${styles}"` : "";
|
|
2397
|
-
const
|
|
2398
|
-
const interactiveAttrStr = ctx.buildAttrsString(
|
|
2429
|
+
const interactiveAttrs2 = buildInteractiveAttrs(node);
|
|
2430
|
+
const interactiveAttrStr = ctx.buildAttrsString(interactiveAttrs2);
|
|
2399
2431
|
const title = node.title ? `<h3 class="${ctx.prefix}-title">${ctx.escapeHtml(node.title)}</h3>
|
|
2400
2432
|
` : "";
|
|
2401
2433
|
const children = ctx.renderChildren(node.children);
|
|
@@ -2407,7 +2439,7 @@ function renderModal(node, ctx) {
|
|
|
2407
2439
|
const classes = ctx.buildClassString([`${ctx.prefix}-modal`, ...ctx.getCommonClasses(node)]);
|
|
2408
2440
|
const styles = ctx.buildCommonStyles(node);
|
|
2409
2441
|
const styleAttr = styles ? ` style="${styles}"` : "";
|
|
2410
|
-
const idAttr = node.id ? ` id="${ctx.escapeHtml(node.id)}"` : "";
|
|
2442
|
+
const idAttr = node.id ? ` id="${ctx.escapeHtml(ctx.scopedId(node.id))}"` : "";
|
|
2411
2443
|
const title = node.title ? `<h2 class="${ctx.prefix}-title">${ctx.escapeHtml(node.title)}</h2>
|
|
2412
2444
|
` : "";
|
|
2413
2445
|
const children = ctx.renderChildren(node.children);
|
|
@@ -2426,7 +2458,7 @@ function renderDrawer(node, ctx) {
|
|
|
2426
2458
|
]);
|
|
2427
2459
|
const styles = ctx.buildCommonStyles(node);
|
|
2428
2460
|
const styleAttr = styles ? ` style="${styles}"` : "";
|
|
2429
|
-
const idAttr = node.id ? ` id="${ctx.escapeHtml(node.id)}"` : "";
|
|
2461
|
+
const idAttr = node.id ? ` id="${ctx.escapeHtml(ctx.scopedId(node.id))}"` : "";
|
|
2430
2462
|
const title = node.title ? `<h2 class="${ctx.prefix}-title">${ctx.escapeHtml(node.title)}</h2>
|
|
2431
2463
|
` : "";
|
|
2432
2464
|
const children = ctx.renderChildren(node.children);
|
|
@@ -2448,6 +2480,45 @@ ${children}
|
|
|
2448
2480
|
</div>`;
|
|
2449
2481
|
}
|
|
2450
2482
|
|
|
2483
|
+
// src/interaction/target.ts
|
|
2484
|
+
function isUrlTarget(target) {
|
|
2485
|
+
if (target === void 0) return false;
|
|
2486
|
+
const value = target.trim();
|
|
2487
|
+
if (value.length === 0 || /\s/.test(value)) return false;
|
|
2488
|
+
if (value.startsWith("/") || value.startsWith("#") || value.startsWith("?")) return true;
|
|
2489
|
+
return /^[A-Za-z][A-Za-z0-9+.-]*:/.test(value);
|
|
2490
|
+
}
|
|
2491
|
+
|
|
2492
|
+
// src/renderer/html/interactive.ts
|
|
2493
|
+
var EXTERNAL_NAVIGATE_ATTR = "data-navigate-external";
|
|
2494
|
+
function interactiveAttrs(node) {
|
|
2495
|
+
return {
|
|
2496
|
+
"data-navigate": node.navigate,
|
|
2497
|
+
[EXTERNAL_NAVIGATE_ATTR]: isUrlTarget(node.navigate) ? true : void 0,
|
|
2498
|
+
"data-opens": node.opens,
|
|
2499
|
+
"data-toggles": node.toggles,
|
|
2500
|
+
"data-action": node.action
|
|
2501
|
+
};
|
|
2502
|
+
}
|
|
2503
|
+
function anchorIntent(node) {
|
|
2504
|
+
const attrs2 = interactiveAttrs(node);
|
|
2505
|
+
if (node.href) return { href: node.href, attrs: attrs2 };
|
|
2506
|
+
if (isUrlTarget(node.navigate)) {
|
|
2507
|
+
return {
|
|
2508
|
+
href: node.navigate.trim(),
|
|
2509
|
+
attrs: {
|
|
2510
|
+
...attrs2,
|
|
2511
|
+
"data-navigate": void 0,
|
|
2512
|
+
[EXTERNAL_NAVIGATE_ATTR]: void 0
|
|
2513
|
+
}
|
|
2514
|
+
};
|
|
2515
|
+
}
|
|
2516
|
+
return { href: "#", attrs: attrs2 };
|
|
2517
|
+
}
|
|
2518
|
+
function nonAnchorIntent(node) {
|
|
2519
|
+
return interactiveAttrs(node);
|
|
2520
|
+
}
|
|
2521
|
+
|
|
2451
2522
|
// src/renderer/html/renderers/text.ts
|
|
2452
2523
|
function isValueWithUnit2(value) {
|
|
2453
2524
|
return typeof value === "object" && value !== null && "value" in value && "unit" in value;
|
|
@@ -2510,20 +2581,17 @@ function renderLink(node, ctx) {
|
|
|
2510
2581
|
const classes = ctx.buildClassString([`${ctx.prefix}-link`, ...ctx.getCommonClasses(node)]);
|
|
2511
2582
|
const styles = ctx.buildCommonStyles(node);
|
|
2512
2583
|
const styleAttr = styles ? ` style="${styles}"` : "";
|
|
2513
|
-
const attrs =
|
|
2584
|
+
const { href, attrs: intentAttrs } = anchorIntent(node);
|
|
2585
|
+
const attrs2 = {
|
|
2514
2586
|
class: classes,
|
|
2515
|
-
href
|
|
2516
|
-
|
|
2517
|
-
"data-navigate": node.navigate,
|
|
2518
|
-
"data-opens": node.opens,
|
|
2519
|
-
"data-toggles": node.toggles,
|
|
2520
|
-
"data-action": node.action
|
|
2587
|
+
href,
|
|
2588
|
+
...intentAttrs
|
|
2521
2589
|
};
|
|
2522
2590
|
if (node.external) {
|
|
2523
|
-
|
|
2524
|
-
|
|
2591
|
+
attrs2.target = "_blank";
|
|
2592
|
+
attrs2.rel = "noopener noreferrer";
|
|
2525
2593
|
}
|
|
2526
|
-
return `<a${ctx.buildAttrsString(
|
|
2594
|
+
return `<a${ctx.buildAttrsString(attrs2)}${styleAttr}>${ctx.escapeHtml(node.content)}</a>`;
|
|
2527
2595
|
}
|
|
2528
2596
|
|
|
2529
2597
|
// src/icons/lucide-icons.ts
|
|
@@ -48945,8 +49013,8 @@ function getIconData(name) {
|
|
|
48945
49013
|
return void 0;
|
|
48946
49014
|
}
|
|
48947
49015
|
function renderIconSvg(data, _size = 24, strokeWidth = 2, className = "", styleAttr = "") {
|
|
48948
|
-
const elements = data.map(([tag,
|
|
48949
|
-
const attrStr = Object.entries(
|
|
49016
|
+
const elements = data.map(([tag, attrs2]) => {
|
|
49017
|
+
const attrStr = Object.entries(attrs2).map(([key, value]) => `${key}="${value}"`).join(" ");
|
|
48950
49018
|
return `<${tag} ${attrStr} />`;
|
|
48951
49019
|
}).join("");
|
|
48952
49020
|
return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="${strokeWidth}" stroke-linecap="round" stroke-linejoin="round" class="${className}"${styleAttr}>${elements}</svg>`;
|
|
@@ -48980,7 +49048,7 @@ function renderButton(node, ctx) {
|
|
|
48980
49048
|
const combinedStyles = baseStyles && sizeStyle ? `${baseStyles}; ${sizeStyle}` : baseStyles || sizeStyle;
|
|
48981
49049
|
const styleAttr = combinedStyles ? ` style="${combinedStyles}"` : "";
|
|
48982
49050
|
const accessibleName = node.aria ?? node["aria-label"];
|
|
48983
|
-
const
|
|
49051
|
+
const attrs2 = {
|
|
48984
49052
|
class: classes,
|
|
48985
49053
|
disabled: node.disabled,
|
|
48986
49054
|
"aria-label": accessibleName,
|
|
@@ -49002,7 +49070,7 @@ function renderButton(node, ctx) {
|
|
|
49002
49070
|
}
|
|
49003
49071
|
const loading = node.loading ? `<span class="${ctx.prefix}-spinner ${ctx.prefix}-spinner-sm"></span>` : "";
|
|
49004
49072
|
const content = isIconOnly ? "" : ctx.escapeHtml(node.content);
|
|
49005
|
-
return `<button${ctx.buildAttrsString(
|
|
49073
|
+
return `<button${ctx.buildAttrsString(attrs2)}${styleAttr}>${loading}${icon}${content}</button>`;
|
|
49006
49074
|
}
|
|
49007
49075
|
|
|
49008
49076
|
// src/renderer/html/renderers/feedback.ts
|
|
@@ -49065,7 +49133,7 @@ function renderInput(node, ctx) {
|
|
|
49065
49133
|
]);
|
|
49066
49134
|
const styles = ctx.buildCommonStyles(node);
|
|
49067
49135
|
const styleAttr = styles ? ` style="${styles}"` : "";
|
|
49068
|
-
const
|
|
49136
|
+
const attrs2 = {
|
|
49069
49137
|
class: inputClasses,
|
|
49070
49138
|
type: node.inputType || "text",
|
|
49071
49139
|
placeholder: node.placeholder,
|
|
@@ -49074,7 +49142,7 @@ function renderInput(node, ctx) {
|
|
|
49074
49142
|
required: node.required,
|
|
49075
49143
|
readonly: node.readonly
|
|
49076
49144
|
};
|
|
49077
|
-
const inputElement = `<input${ctx.buildAttrsString(
|
|
49145
|
+
const inputElement = `<input${ctx.buildAttrsString(attrs2)} />`;
|
|
49078
49146
|
if (node.icon) {
|
|
49079
49147
|
const iconData = getIconData(node.icon);
|
|
49080
49148
|
let iconHtml;
|
|
@@ -49092,7 +49160,7 @@ ${wrapper}`;
|
|
|
49092
49160
|
}
|
|
49093
49161
|
return wrapper;
|
|
49094
49162
|
}
|
|
49095
|
-
const input = `<input${ctx.buildAttrsString(
|
|
49163
|
+
const input = `<input${ctx.buildAttrsString(attrs2)}${styleAttr} />`;
|
|
49096
49164
|
const shouldShowLabel2 = node.label && !(node.label === "Label" && node.placeholder);
|
|
49097
49165
|
if (shouldShowLabel2) {
|
|
49098
49166
|
return `<label class="${ctx.prefix}-input-label">${ctx.escapeHtml(node.label)}</label>
|
|
@@ -49104,14 +49172,14 @@ function renderTextarea(node, ctx) {
|
|
|
49104
49172
|
const classes = ctx.buildClassString([`${ctx.prefix}-input`, ...ctx.getCommonClasses(node)]);
|
|
49105
49173
|
const styles = ctx.buildCommonStyles(node);
|
|
49106
49174
|
const styleAttr = styles ? ` style="${styles}"` : "";
|
|
49107
|
-
const
|
|
49175
|
+
const attrs2 = {
|
|
49108
49176
|
class: classes,
|
|
49109
49177
|
placeholder: node.placeholder,
|
|
49110
49178
|
disabled: node.disabled,
|
|
49111
49179
|
required: node.required,
|
|
49112
49180
|
rows: node.rows?.toString()
|
|
49113
49181
|
};
|
|
49114
|
-
const textarea = `<textarea${ctx.buildAttrsString(
|
|
49182
|
+
const textarea = `<textarea${ctx.buildAttrsString(attrs2)}${styleAttr}>${ctx.escapeHtml(node.value || "")}</textarea>`;
|
|
49115
49183
|
if (node.label) {
|
|
49116
49184
|
return `<label class="${ctx.prefix}-input-label">${ctx.escapeHtml(node.label)}</label>
|
|
49117
49185
|
${textarea}`;
|
|
@@ -49122,7 +49190,7 @@ function renderSelect(node, ctx) {
|
|
|
49122
49190
|
const classes = ctx.buildClassString([`${ctx.prefix}-input`, ...ctx.getCommonClasses(node)]);
|
|
49123
49191
|
const styles = ctx.buildCommonStyles(node);
|
|
49124
49192
|
const styleAttr = styles ? ` style="${styles}"` : "";
|
|
49125
|
-
const
|
|
49193
|
+
const attrs2 = {
|
|
49126
49194
|
class: classes,
|
|
49127
49195
|
disabled: node.disabled,
|
|
49128
49196
|
required: node.required
|
|
@@ -49139,7 +49207,7 @@ function renderSelect(node, ctx) {
|
|
|
49139
49207
|
const placeholderSelected = hasSelectedValue ? "" : ' selected="selected"';
|
|
49140
49208
|
const placeholder = node.placeholder ? `<option value="" disabled="disabled"${placeholderSelected}>${ctx.escapeHtml(node.placeholder)}</option>
|
|
49141
49209
|
` : "";
|
|
49142
|
-
const select = `<select${ctx.buildAttrsString(
|
|
49210
|
+
const select = `<select${ctx.buildAttrsString(attrs2)}${styleAttr}>
|
|
49143
49211
|
${placeholder}${options}
|
|
49144
49212
|
</select>`;
|
|
49145
49213
|
if (node.label) {
|
|
@@ -49151,12 +49219,12 @@ ${select}`;
|
|
|
49151
49219
|
function renderCheckbox(node, ctx) {
|
|
49152
49220
|
const styles = ctx.buildCommonStyles(node);
|
|
49153
49221
|
const styleAttr = styles ? ` style="${styles}"` : "";
|
|
49154
|
-
const
|
|
49222
|
+
const attrs2 = {
|
|
49155
49223
|
type: "checkbox",
|
|
49156
49224
|
checked: node.checked,
|
|
49157
49225
|
disabled: node.disabled
|
|
49158
49226
|
};
|
|
49159
|
-
const checkbox = `<input${ctx.buildAttrsString(
|
|
49227
|
+
const checkbox = `<input${ctx.buildAttrsString(attrs2)} />`;
|
|
49160
49228
|
if (node.label) {
|
|
49161
49229
|
return `<label class="${ctx.prefix}-checkbox"${styleAttr}>${checkbox}<span>${ctx.escapeHtml(node.label)}</span></label>`;
|
|
49162
49230
|
}
|
|
@@ -49165,13 +49233,13 @@ function renderCheckbox(node, ctx) {
|
|
|
49165
49233
|
function renderRadio(node, ctx) {
|
|
49166
49234
|
const styles = ctx.buildCommonStyles(node);
|
|
49167
49235
|
const styleAttr = styles ? ` style="${styles}"` : "";
|
|
49168
|
-
const
|
|
49236
|
+
const attrs2 = {
|
|
49169
49237
|
type: "radio",
|
|
49170
49238
|
name: node.name,
|
|
49171
49239
|
checked: node.checked,
|
|
49172
49240
|
disabled: node.disabled
|
|
49173
49241
|
};
|
|
49174
|
-
const radio = `<input${ctx.buildAttrsString(
|
|
49242
|
+
const radio = `<input${ctx.buildAttrsString(attrs2)} />`;
|
|
49175
49243
|
if (node.label) {
|
|
49176
49244
|
return `<label class="${ctx.prefix}-radio"${styleAttr}>${radio}<span>${ctx.escapeHtml(node.label)}</span></label>`;
|
|
49177
49245
|
}
|
|
@@ -49181,13 +49249,13 @@ function renderSwitch(node, ctx) {
|
|
|
49181
49249
|
const classes = ctx.buildClassString([`${ctx.prefix}-switch`, ...ctx.getCommonClasses(node)]);
|
|
49182
49250
|
const styles = ctx.buildCommonStyles(node);
|
|
49183
49251
|
const styleAttr = styles ? ` style="${styles}"` : "";
|
|
49184
|
-
const
|
|
49252
|
+
const attrs2 = {
|
|
49185
49253
|
type: "checkbox",
|
|
49186
49254
|
role: "switch",
|
|
49187
49255
|
checked: node.checked,
|
|
49188
49256
|
disabled: node.disabled
|
|
49189
49257
|
};
|
|
49190
|
-
const switchEl = `<input${ctx.buildAttrsString(
|
|
49258
|
+
const switchEl = `<input${ctx.buildAttrsString(attrs2)} />`;
|
|
49191
49259
|
if (node.label) {
|
|
49192
49260
|
return `<label class="${classes}"${styleAttr}>${switchEl} ${ctx.escapeHtml(node.label)}</label>`;
|
|
49193
49261
|
}
|
|
@@ -49197,7 +49265,7 @@ function renderSlider(node, ctx) {
|
|
|
49197
49265
|
const classes = ctx.buildClassString([`${ctx.prefix}-slider`, ...ctx.getCommonClasses(node)]);
|
|
49198
49266
|
const styles = ctx.buildCommonStyles(node);
|
|
49199
49267
|
const styleAttr = styles ? ` style="${styles}"` : "";
|
|
49200
|
-
const
|
|
49268
|
+
const attrs2 = {
|
|
49201
49269
|
class: classes,
|
|
49202
49270
|
type: "range",
|
|
49203
49271
|
min: node.min?.toString(),
|
|
@@ -49206,7 +49274,7 @@ function renderSlider(node, ctx) {
|
|
|
49206
49274
|
value: node.value?.toString(),
|
|
49207
49275
|
disabled: node.disabled
|
|
49208
49276
|
};
|
|
49209
|
-
const slider = `<input${ctx.buildAttrsString(
|
|
49277
|
+
const slider = `<input${ctx.buildAttrsString(attrs2)}${styleAttr} />`;
|
|
49210
49278
|
if (node.label) {
|
|
49211
49279
|
return `<label class="${ctx.prefix}-input-label">${ctx.escapeHtml(node.label)}</label>
|
|
49212
49280
|
${slider}`;
|
|
@@ -49228,19 +49296,19 @@ function renderImage(node, ctx) {
|
|
|
49228
49296
|
const styles = ctx.buildCommonStyles(node);
|
|
49229
49297
|
const styleAttr = styles ? ` style="${styles}"` : "";
|
|
49230
49298
|
if (node.src) {
|
|
49231
|
-
const
|
|
49299
|
+
const attrs2 = {
|
|
49232
49300
|
class: classes,
|
|
49233
49301
|
src: node.src,
|
|
49234
49302
|
alt: node.alt || "Image",
|
|
49235
49303
|
...buildInteractiveAttrs2(node)
|
|
49236
49304
|
};
|
|
49237
49305
|
const imgStyleAttr = styles ? `; ${styles}` : "";
|
|
49238
|
-
return `<img${ctx.buildAttrsString(
|
|
49306
|
+
return `<img${ctx.buildAttrsString(attrs2)}${imgStyleAttr ? ` style="${imgStyleAttr.slice(2)}"` : ""} />`;
|
|
49239
49307
|
}
|
|
49240
49308
|
const label = node.alt || "Image";
|
|
49241
49309
|
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>`;
|
|
49242
|
-
const
|
|
49243
|
-
const interactiveAttrStr = ctx.buildAttrsString(
|
|
49310
|
+
const interactiveAttrs2 = buildInteractiveAttrs2(node);
|
|
49311
|
+
const interactiveAttrStr = ctx.buildAttrsString(interactiveAttrs2);
|
|
49244
49312
|
return `<div class="${classes}"${styleAttr}${interactiveAttrStr} role="img" aria-label="${ctx.escapeHtml(label)}">${icon}<span>${ctx.escapeHtml(label)}</span></div>`;
|
|
49245
49313
|
}
|
|
49246
49314
|
function renderPlaceholder(node, ctx) {
|
|
@@ -49283,13 +49351,13 @@ function renderAvatar(node, ctx) {
|
|
|
49283
49351
|
content = "?";
|
|
49284
49352
|
}
|
|
49285
49353
|
}
|
|
49286
|
-
const
|
|
49287
|
-
const interactiveAttrStr = ctx.buildAttrsString(
|
|
49354
|
+
const interactiveAttrs2 = buildInteractiveAttrs2(node);
|
|
49355
|
+
const interactiveAttrStr = ctx.buildAttrsString(interactiveAttrs2);
|
|
49288
49356
|
return `<div class="${classes}"${styleAttr}${interactiveAttrStr} role="img" aria-label="${ctx.escapeHtml(node.name || "Avatar")}">${content}</div>`;
|
|
49289
49357
|
}
|
|
49290
49358
|
function renderBadge(node, ctx) {
|
|
49291
|
-
const
|
|
49292
|
-
const interactiveAttrStr = ctx.buildAttrsString(
|
|
49359
|
+
const interactiveAttrs2 = buildInteractiveAttrs2(node);
|
|
49360
|
+
const interactiveAttrStr = ctx.buildAttrsString(interactiveAttrs2);
|
|
49293
49361
|
const sizeResolved = resolveSizeValue(node.size, "badge", ctx.prefix);
|
|
49294
49362
|
if (node.icon) {
|
|
49295
49363
|
const iconData = getIconData(node.icon);
|
|
@@ -49328,8 +49396,8 @@ function renderBadge(node, ctx) {
|
|
|
49328
49396
|
}
|
|
49329
49397
|
function renderIcon(node, ctx) {
|
|
49330
49398
|
const iconData = getIconData(node.name);
|
|
49331
|
-
const
|
|
49332
|
-
const interactiveAttrStr = ctx.buildAttrsString(
|
|
49399
|
+
const interactiveAttrs2 = buildInteractiveAttrs2(node);
|
|
49400
|
+
const interactiveAttrStr = ctx.buildAttrsString(interactiveAttrs2);
|
|
49333
49401
|
const sizeResolved = resolveSizeValue(node.size, "icon", ctx.prefix);
|
|
49334
49402
|
const wrapperClasses = ctx.buildClassString([
|
|
49335
49403
|
`${ctx.prefix}-icon-wrapper`,
|
|
@@ -49396,18 +49464,13 @@ function renderDropdown(node, ctx) {
|
|
|
49396
49464
|
dropdownItem.danger ? `${ctx.prefix}-dropdown-item-danger` : void 0,
|
|
49397
49465
|
dropdownItem.disabled ? `${ctx.prefix}-dropdown-item-disabled` : void 0
|
|
49398
49466
|
]);
|
|
49399
|
-
const interactiveAttrs = {
|
|
49400
|
-
"data-navigate": dropdownItem.navigate,
|
|
49401
|
-
"data-opens": dropdownItem.opens,
|
|
49402
|
-
"data-toggles": dropdownItem.toggles,
|
|
49403
|
-
"data-action": dropdownItem.action
|
|
49404
|
-
};
|
|
49405
|
-
const interactiveAttrStr = ctx.buildAttrsString(interactiveAttrs);
|
|
49406
49467
|
const disabledAttr = dropdownItem.disabled ? ' disabled="disabled"' : "";
|
|
49407
49468
|
if (dropdownItem.href || dropdownItem.navigate) {
|
|
49408
|
-
const href
|
|
49409
|
-
|
|
49469
|
+
const { href, attrs: attrs2 } = anchorIntent(dropdownItem);
|
|
49470
|
+
const anchorAttrStr = ctx.buildAttrsString(attrs2);
|
|
49471
|
+
return `<a class="${itemClasses}" href="${ctx.escapeHtml(href)}"${anchorAttrStr}>${ctx.escapeHtml(dropdownItem.label)}</a>`;
|
|
49410
49472
|
}
|
|
49473
|
+
const interactiveAttrStr = ctx.buildAttrsString(nonAnchorIntent(dropdownItem));
|
|
49411
49474
|
return `<button class="${itemClasses}"${disabledAttr}${interactiveAttrStr}>${ctx.escapeHtml(dropdownItem.label)}</button>`;
|
|
49412
49475
|
}).join("\n");
|
|
49413
49476
|
return `<div class="${classes}"${styleAttr}>
|
|
@@ -49426,7 +49489,9 @@ function renderNavItem(item, ctx) {
|
|
|
49426
49489
|
item.disabled ? `${ctx.prefix}-nav-link-disabled` : void 0
|
|
49427
49490
|
]);
|
|
49428
49491
|
const iconHtml = item.icon ? renderIconHtml(item.icon, ctx.prefix) + " " : "";
|
|
49429
|
-
|
|
49492
|
+
const { href, attrs: attrs2 } = anchorIntent(item);
|
|
49493
|
+
const intentAttrs = ctx.buildAttrsString(attrs2);
|
|
49494
|
+
return `<a class="${linkClasses}" href="${ctx.escapeHtml(href)}"${intentAttrs}>${iconHtml}${ctx.escapeHtml(item.label)}</a>`;
|
|
49430
49495
|
}
|
|
49431
49496
|
function renderNavChildren(children, ctx) {
|
|
49432
49497
|
return children.map((child) => {
|
|
@@ -49469,13 +49534,7 @@ ${content}
|
|
|
49469
49534
|
if (typeof item === "string") {
|
|
49470
49535
|
return `<a class="${ctx.prefix}-nav-link" href="#">${ctx.escapeHtml(item)}</a>`;
|
|
49471
49536
|
}
|
|
49472
|
-
|
|
49473
|
-
`${ctx.prefix}-nav-link`,
|
|
49474
|
-
item.active ? `${ctx.prefix}-nav-link-active` : void 0,
|
|
49475
|
-
item.disabled ? `${ctx.prefix}-nav-link-disabled` : void 0
|
|
49476
|
-
]);
|
|
49477
|
-
const iconHtml = item.icon ? renderIconHtml(item.icon, ctx.prefix) + " " : "";
|
|
49478
|
-
return `<a class="${linkClasses}" href="${item.href || "#"}">${iconHtml}${ctx.escapeHtml(item.label)}</a>`;
|
|
49537
|
+
return renderNavItem(item, ctx);
|
|
49479
49538
|
}).join("\n");
|
|
49480
49539
|
return `<nav class="${classes}"${styleAttr}>
|
|
49481
49540
|
${items}
|
|
@@ -49506,7 +49565,13 @@ function renderBreadcrumb(node, ctx) {
|
|
|
49506
49565
|
if (typeof item === "string") {
|
|
49507
49566
|
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>`;
|
|
49508
49567
|
}
|
|
49509
|
-
|
|
49568
|
+
if (isLast) {
|
|
49569
|
+
const intentAttrs2 = ctx.buildAttrsString(nonAnchorIntent(item));
|
|
49570
|
+
return `<span class="${ctx.prefix}-breadcrumb-item" aria-current="page"${intentAttrs2}>${ctx.escapeHtml(item.label)}</span>`;
|
|
49571
|
+
}
|
|
49572
|
+
const { href, attrs: attrs2 } = anchorIntent(item);
|
|
49573
|
+
const intentAttrs = ctx.buildAttrsString(attrs2);
|
|
49574
|
+
return `<a class="${ctx.prefix}-breadcrumb-item" href="${ctx.escapeHtml(href)}"${intentAttrs}>${ctx.escapeHtml(item.label)}</a>`;
|
|
49510
49575
|
}).join(separator);
|
|
49511
49576
|
return `<nav class="${classes}"${styleAttr} aria-label="Breadcrumb">${items}</nav>`;
|
|
49512
49577
|
}
|
|
@@ -49755,8 +49820,8 @@ function renderAnnotationItem(node, ctx) {
|
|
|
49755
49820
|
|
|
49756
49821
|
// src/renderer/html/index.ts
|
|
49757
49822
|
function injectAnchorAttrs(html, path, loc) {
|
|
49758
|
-
const
|
|
49759
|
-
return html.replace(/<([a-zA-Z][a-zA-Z0-9-]*)/, (match) => `${match}${
|
|
49823
|
+
const attrs2 = loc ? ` ${ANCHOR_PATH_ATTR}="${path}" ${ANCHOR_LOC_ATTR}="${formatAnchorLoc(loc)}"` : ` ${ANCHOR_PATH_ATTR}="${path}"`;
|
|
49824
|
+
return html.replace(/<([a-zA-Z][a-zA-Z0-9-]*)/, (match) => `${match}${attrs2}`);
|
|
49760
49825
|
}
|
|
49761
49826
|
var SPACING_TOKENS = {
|
|
49762
49827
|
0: "0px",
|
|
@@ -49811,6 +49876,8 @@ var HtmlRenderer = class extends BaseRenderer {
|
|
|
49811
49876
|
* index in the anchor scheme.
|
|
49812
49877
|
*/
|
|
49813
49878
|
pageIndexBase;
|
|
49879
|
+
/** Content supplied by a site renderer for the next layout slot. */
|
|
49880
|
+
slotContent = null;
|
|
49814
49881
|
constructor(options = {}, pageIndexBase = 0) {
|
|
49815
49882
|
super(options);
|
|
49816
49883
|
this.pageIndexBase = pageIndexBase;
|
|
@@ -49837,6 +49904,7 @@ var HtmlRenderer = class extends BaseRenderer {
|
|
|
49837
49904
|
return {
|
|
49838
49905
|
prefix: this.prefix,
|
|
49839
49906
|
escapeHtml: this.escapeHtml.bind(this),
|
|
49907
|
+
scopedId: this.scopedId.bind(this),
|
|
49840
49908
|
buildClassString: this.buildClassString.bind(this),
|
|
49841
49909
|
buildAttrsString: this.buildAttrsString.bind(this),
|
|
49842
49910
|
buildCommonStyles: this.buildCommonStyles.bind(this),
|
|
@@ -49914,6 +49982,7 @@ var HtmlRenderer = class extends BaseRenderer {
|
|
|
49914
49982
|
Breadcrumb: (node) => this.renderBreadcrumb(node),
|
|
49915
49983
|
// Other
|
|
49916
49984
|
Divider: (node) => this.renderDivider(node),
|
|
49985
|
+
Slot: () => this.renderSlot(),
|
|
49917
49986
|
// Annotation nodes
|
|
49918
49987
|
Marker: (node) => this.renderMarker(node),
|
|
49919
49988
|
Annotations: (node) => this.renderAnnotations(node),
|
|
@@ -49990,6 +50059,25 @@ ${annotationsContent}
|
|
|
49990
50059
|
}
|
|
49991
50060
|
return html;
|
|
49992
50061
|
}
|
|
50062
|
+
/** Render the first slot with the supplied page content, if any. */
|
|
50063
|
+
renderSlot() {
|
|
50064
|
+
const content = this.slotContent;
|
|
50065
|
+
this.slotContent = null;
|
|
50066
|
+
const open = `<div class="${this.prefix}-slot">`;
|
|
50067
|
+
return content === null ? `${open}</div>` : `${open}
|
|
50068
|
+
${content}
|
|
50069
|
+
</div>`;
|
|
50070
|
+
}
|
|
50071
|
+
/** Render nodes without adding a page frame, optionally filling a slot. */
|
|
50072
|
+
renderFragment(nodes, slotContent = null) {
|
|
50073
|
+
const previous = this.slotContent;
|
|
50074
|
+
this.slotContent = slotContent;
|
|
50075
|
+
try {
|
|
50076
|
+
return this.renderChildren(nodes);
|
|
50077
|
+
} finally {
|
|
50078
|
+
this.slotContent = previous;
|
|
50079
|
+
}
|
|
50080
|
+
}
|
|
49993
50081
|
/**
|
|
49994
50082
|
* Render children nodes
|
|
49995
50083
|
*/
|
|
@@ -50430,7 +50518,8 @@ function renderCanvas(doc, options = {}) {
|
|
|
50430
50518
|
const includeStyles = options.includeStyles !== false;
|
|
50431
50519
|
const theme = options.theme === "dark" ? darkTheme : defaultTheme;
|
|
50432
50520
|
const css = includeStyles ? generateStyles(theme, prefix) : "";
|
|
50433
|
-
|
|
50521
|
+
const pages = documentPages(doc);
|
|
50522
|
+
if (pages.length === 0) {
|
|
50434
50523
|
return {
|
|
50435
50524
|
html: `<div class="${prefix}-canvas" data-empty="true"></div>`,
|
|
50436
50525
|
css,
|
|
@@ -50438,7 +50527,7 @@ function renderCanvas(doc, options = {}) {
|
|
|
50438
50527
|
height: 0
|
|
50439
50528
|
};
|
|
50440
50529
|
}
|
|
50441
|
-
const { placed, width, height } = layoutCanvas(
|
|
50530
|
+
const { placed, width, height } = layoutCanvas(pages, gap);
|
|
50442
50531
|
const boards = placed.map((p, pageIndex) => {
|
|
50443
50532
|
const pageRenderer = new HtmlRenderer({ ...options, includeStyles: false }, pageIndex);
|
|
50444
50533
|
const { html: pageHtml } = pageRenderer.render({
|
|
@@ -50466,9 +50555,484 @@ function escapeAttr(s) {
|
|
|
50466
50555
|
return s.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<");
|
|
50467
50556
|
}
|
|
50468
50557
|
|
|
50558
|
+
// src/renderer/site/model.ts
|
|
50559
|
+
function pageId(page) {
|
|
50560
|
+
const id = page.id?.trim();
|
|
50561
|
+
return id && id.length > 0 ? id : void 0;
|
|
50562
|
+
}
|
|
50563
|
+
function pageTitle(page) {
|
|
50564
|
+
const title = page.title?.trim();
|
|
50565
|
+
return title && title.length > 0 ? title : void 0;
|
|
50566
|
+
}
|
|
50567
|
+
function hasSlot(layout) {
|
|
50568
|
+
for (const child of layout.children) {
|
|
50569
|
+
let found = false;
|
|
50570
|
+
walk(child, (node) => {
|
|
50571
|
+
if (node.type === "Slot") found = true;
|
|
50572
|
+
return !found;
|
|
50573
|
+
});
|
|
50574
|
+
if (found) return true;
|
|
50575
|
+
}
|
|
50576
|
+
return false;
|
|
50577
|
+
}
|
|
50578
|
+
function layoutsByName(doc) {
|
|
50579
|
+
const layouts = /* @__PURE__ */ new Map();
|
|
50580
|
+
for (const definition of documentDefinitions(doc)) {
|
|
50581
|
+
const name = definition.name.trim();
|
|
50582
|
+
if (name.length > 0 && !layouts.has(name)) layouts.set(name, definition);
|
|
50583
|
+
}
|
|
50584
|
+
return layouts;
|
|
50585
|
+
}
|
|
50586
|
+
function resolveShell(page, layouts) {
|
|
50587
|
+
const uses = page.uses?.trim();
|
|
50588
|
+
if (!uses) return void 0;
|
|
50589
|
+
const layout = layouts.get(uses);
|
|
50590
|
+
if (!layout) return { miss: { uses, reason: "unknown-layout" } };
|
|
50591
|
+
if (!hasSlot(layout)) return { miss: { uses, reason: "slotless-layout" } };
|
|
50592
|
+
return { layout, name: uses };
|
|
50593
|
+
}
|
|
50594
|
+
function buildSiteModel(doc) {
|
|
50595
|
+
const screens = documentPages(doc).map((page, index) => ({ index, page }));
|
|
50596
|
+
const layouts = layoutsByName(doc);
|
|
50597
|
+
const shells = [];
|
|
50598
|
+
const shellByName = /* @__PURE__ */ new Map();
|
|
50599
|
+
for (const screen of screens) {
|
|
50600
|
+
const resolved = resolveShell(screen.page, layouts);
|
|
50601
|
+
if (!resolved) continue;
|
|
50602
|
+
if ("miss" in resolved) {
|
|
50603
|
+
screen.miss = resolved.miss;
|
|
50604
|
+
continue;
|
|
50605
|
+
}
|
|
50606
|
+
let shell = shellByName.get(resolved.name);
|
|
50607
|
+
if (!shell) {
|
|
50608
|
+
const { width, height } = resolvePageDimensions(screen.page);
|
|
50609
|
+
shell = { name: resolved.name, layout: resolved.layout, screens: [], width, height };
|
|
50610
|
+
shellByName.set(resolved.name, shell);
|
|
50611
|
+
shells.push(shell);
|
|
50612
|
+
}
|
|
50613
|
+
shell.screens.push(screen);
|
|
50614
|
+
screen.shell = shell.name;
|
|
50615
|
+
}
|
|
50616
|
+
const names = /* @__PURE__ */ new Map();
|
|
50617
|
+
for (const screen of screens) {
|
|
50618
|
+
const title = pageTitle(screen.page);
|
|
50619
|
+
if (title !== void 0 && !names.has(title)) names.set(title, screen.index);
|
|
50620
|
+
}
|
|
50621
|
+
for (const screen of screens) {
|
|
50622
|
+
const id = pageId(screen.page);
|
|
50623
|
+
if (id === void 0) continue;
|
|
50624
|
+
const owner = names.get(id);
|
|
50625
|
+
if (owner === void 0 || pageId(screens[owner].page) !== id) {
|
|
50626
|
+
names.set(id, screen.index);
|
|
50627
|
+
}
|
|
50628
|
+
}
|
|
50629
|
+
for (const screen of screens) {
|
|
50630
|
+
screen.name = [pageId(screen.page), pageTitle(screen.page)].find(
|
|
50631
|
+
(name) => name !== void 0 && names.get(name) === screen.index
|
|
50632
|
+
);
|
|
50633
|
+
}
|
|
50634
|
+
return { screens, shells, names, entry: screens.length > 0 ? 0 : -1 };
|
|
50635
|
+
}
|
|
50636
|
+
|
|
50637
|
+
// src/renderer/site/styles.ts
|
|
50638
|
+
function generateSiteStyles(prefix) {
|
|
50639
|
+
return `
|
|
50640
|
+
/* ===== Site composition (renderSite) ===== */
|
|
50641
|
+
|
|
50642
|
+
.${prefix}-site {
|
|
50643
|
+
display: flex;
|
|
50644
|
+
justify-content: center;
|
|
50645
|
+
align-items: flex-start;
|
|
50646
|
+
}
|
|
50647
|
+
|
|
50648
|
+
.${prefix}-site > .${prefix}-shell,
|
|
50649
|
+
.${prefix}-site > .${prefix}-screen {
|
|
50650
|
+
display: none;
|
|
50651
|
+
}
|
|
50652
|
+
|
|
50653
|
+
.${prefix}-site > .${prefix}-shell.${prefix}-on {
|
|
50654
|
+
display: flex;
|
|
50655
|
+
flex-direction: column;
|
|
50656
|
+
}
|
|
50657
|
+
|
|
50658
|
+
.${prefix}-site > .${prefix}-screen.${prefix}-on {
|
|
50659
|
+
display: block;
|
|
50660
|
+
}
|
|
50661
|
+
|
|
50662
|
+
.${prefix}-site .${prefix}-page {
|
|
50663
|
+
overflow: auto !important;
|
|
50664
|
+
}
|
|
50665
|
+
|
|
50666
|
+
.${prefix}-site .${prefix}-slot {
|
|
50667
|
+
display: flex;
|
|
50668
|
+
flex-direction: column;
|
|
50669
|
+
flex: 1;
|
|
50670
|
+
min-height: 0;
|
|
50671
|
+
}
|
|
50672
|
+
|
|
50673
|
+
.${prefix}-site .${prefix}-slot > .${prefix}-screen {
|
|
50674
|
+
display: none;
|
|
50675
|
+
}
|
|
50676
|
+
|
|
50677
|
+
.${prefix}-site .${prefix}-slot > .${prefix}-screen.${prefix}-on {
|
|
50678
|
+
display: flex;
|
|
50679
|
+
flex-direction: column;
|
|
50680
|
+
flex: 1;
|
|
50681
|
+
min-height: 0;
|
|
50682
|
+
}
|
|
50683
|
+
|
|
50684
|
+
.${prefix}-site .${prefix}-screen > .${prefix}-col {
|
|
50685
|
+
flex: 1;
|
|
50686
|
+
min-height: 0;
|
|
50687
|
+
}
|
|
50688
|
+
|
|
50689
|
+
.${prefix}-site .${prefix}-closed {
|
|
50690
|
+
display: none;
|
|
50691
|
+
}
|
|
50692
|
+
`;
|
|
50693
|
+
}
|
|
50694
|
+
|
|
50695
|
+
// src/renderer/site/runtime.ts
|
|
50696
|
+
var ID_SCOPE_ATTR = "data-id-scope";
|
|
50697
|
+
function embedJson(value) {
|
|
50698
|
+
return JSON.stringify(value).replace(/</g, "\\u003C");
|
|
50699
|
+
}
|
|
50700
|
+
function siteRuntime(registry, prefix) {
|
|
50701
|
+
return `(function () {
|
|
50702
|
+
'use strict';
|
|
50703
|
+
var P = ${embedJson(prefix)};
|
|
50704
|
+
var R = ${embedJson(registry)};
|
|
50705
|
+
var ON = P + '-on';
|
|
50706
|
+
var CLOSED = P + '-closed';
|
|
50707
|
+
var NAV_ACTIVE = P + '-nav-link-active';
|
|
50708
|
+
var site = document.querySelector('.' + P + '-site');
|
|
50709
|
+
if (!site) return;
|
|
50710
|
+
|
|
50711
|
+
var screens = {};
|
|
50712
|
+
var order = [];
|
|
50713
|
+
var shellOf = {};
|
|
50714
|
+
var hosts = site.querySelectorAll('[data-screen]');
|
|
50715
|
+
|
|
50716
|
+
function shellFor(node) {
|
|
50717
|
+
var el = node.parentNode;
|
|
50718
|
+
while (el && el !== site) {
|
|
50719
|
+
if (el.classList && el.classList.contains(P + '-shell')) return el;
|
|
50720
|
+
el = el.parentNode;
|
|
50721
|
+
}
|
|
50722
|
+
return null;
|
|
50723
|
+
}
|
|
50724
|
+
|
|
50725
|
+
for (var i = 0; i < hosts.length; i++) {
|
|
50726
|
+
var key = hosts[i].getAttribute('data-screen');
|
|
50727
|
+
if (!Object.prototype.hasOwnProperty.call(screens, key)) {
|
|
50728
|
+
screens[key] = hosts[i];
|
|
50729
|
+
order.push(key);
|
|
50730
|
+
shellOf[key] = shellFor(hosts[i]);
|
|
50731
|
+
}
|
|
50732
|
+
}
|
|
50733
|
+
var shells = site.querySelectorAll('.' + P + '-shell');
|
|
50734
|
+
|
|
50735
|
+
function isChrome(el) {
|
|
50736
|
+
return !(el.closest && el.closest('[data-screen]'));
|
|
50737
|
+
}
|
|
50738
|
+
|
|
50739
|
+
function scopeOf(el) {
|
|
50740
|
+
return (el && el.getAttribute(${embedJson(ID_SCOPE_ATTR)})) || '';
|
|
50741
|
+
}
|
|
50742
|
+
|
|
50743
|
+
function idSelector(id) {
|
|
50744
|
+
return '[id="' + String(id).replace(/["\\\\]/g, '\\\\$&') + '"]';
|
|
50745
|
+
}
|
|
50746
|
+
|
|
50747
|
+
function resolve(target) {
|
|
50748
|
+
if (target === null || target === undefined) return null;
|
|
50749
|
+
var name = String(target).trim();
|
|
50750
|
+
if (name === '') return null;
|
|
50751
|
+
if (Object.prototype.hasOwnProperty.call(R.names, name)) return String(R.names[name]);
|
|
50752
|
+
return Object.prototype.hasOwnProperty.call(screens, name) ? name : null;
|
|
50753
|
+
}
|
|
50754
|
+
|
|
50755
|
+
function overlayFor(key, id) {
|
|
50756
|
+
if (!id) return null;
|
|
50757
|
+
var screen = screens[key];
|
|
50758
|
+
if (screen) {
|
|
50759
|
+
var own = screen.querySelector(idSelector(scopeOf(screen) + id));
|
|
50760
|
+
if (own) return own;
|
|
50761
|
+
}
|
|
50762
|
+
var shell = shellOf[key];
|
|
50763
|
+
if (shell) {
|
|
50764
|
+
var candidates = shell.querySelectorAll(idSelector(scopeOf(shell) + id));
|
|
50765
|
+
for (var i = 0; i < candidates.length; i++) {
|
|
50766
|
+
if (isChrome(candidates[i])) return candidates[i];
|
|
50767
|
+
}
|
|
50768
|
+
}
|
|
50769
|
+
return null;
|
|
50770
|
+
}
|
|
50771
|
+
|
|
50772
|
+
function triggersFor(key) {
|
|
50773
|
+
var selector = '[data-opens],[data-toggles]';
|
|
50774
|
+
var found = [];
|
|
50775
|
+
var screen = screens[key];
|
|
50776
|
+
var i;
|
|
50777
|
+
if (screen) {
|
|
50778
|
+
var own = screen.querySelectorAll(selector);
|
|
50779
|
+
for (i = 0; i < own.length; i++) found.push(own[i]);
|
|
50780
|
+
}
|
|
50781
|
+
var shell = shellOf[key];
|
|
50782
|
+
if (shell) {
|
|
50783
|
+
var chrome = shell.querySelectorAll(selector);
|
|
50784
|
+
for (i = 0; i < chrome.length; i++) {
|
|
50785
|
+
if (isChrome(chrome[i])) found.push(chrome[i]);
|
|
50786
|
+
}
|
|
50787
|
+
}
|
|
50788
|
+
return found;
|
|
50789
|
+
}
|
|
50790
|
+
|
|
50791
|
+
function closeOverlays(key) {
|
|
50792
|
+
var triggers = triggersFor(key);
|
|
50793
|
+
for (var i = 0; i < triggers.length; i++) {
|
|
50794
|
+
var id = triggers[i].getAttribute('data-opens') || triggers[i].getAttribute('data-toggles');
|
|
50795
|
+
var overlay = overlayFor(key, id);
|
|
50796
|
+
if (overlay) overlay.classList.add(CLOSED);
|
|
50797
|
+
}
|
|
50798
|
+
}
|
|
50799
|
+
|
|
50800
|
+
function markActive(key) {
|
|
50801
|
+
for (var i = 0; i < shells.length; i++) {
|
|
50802
|
+
var links = shells[i].querySelectorAll('[data-navigate]');
|
|
50803
|
+
for (var j = 0; j < links.length; j++) {
|
|
50804
|
+
if (!isChrome(links[j])) continue;
|
|
50805
|
+
if (resolve(links[j].getAttribute('data-navigate')) === key) {
|
|
50806
|
+
links[j].classList.add(NAV_ACTIVE);
|
|
50807
|
+
} else {
|
|
50808
|
+
links[j].classList.remove(NAV_ACTIVE);
|
|
50809
|
+
}
|
|
50810
|
+
}
|
|
50811
|
+
}
|
|
50812
|
+
}
|
|
50813
|
+
|
|
50814
|
+
var current = null;
|
|
50815
|
+
function show(key, writeFragment) {
|
|
50816
|
+
var screen = screens[key];
|
|
50817
|
+
if (!screen) return false;
|
|
50818
|
+
for (var i = 0; i < order.length; i++) {
|
|
50819
|
+
screens[order[i]].classList.toggle(ON, order[i] === key);
|
|
50820
|
+
}
|
|
50821
|
+
var shell = shellOf[key];
|
|
50822
|
+
for (var s = 0; s < shells.length; s++) shells[s].classList.toggle(ON, shells[s] === shell);
|
|
50823
|
+
site.setAttribute('data-current-screen', key);
|
|
50824
|
+
current = key;
|
|
50825
|
+
closeOverlays(key);
|
|
50826
|
+
markActive(key);
|
|
50827
|
+
if (writeFragment) {
|
|
50828
|
+
var fragment = R.fragments[Number(key)] || key;
|
|
50829
|
+
if (location.hash.slice(1) !== fragment) location.hash = fragment;
|
|
50830
|
+
}
|
|
50831
|
+
return true;
|
|
50832
|
+
}
|
|
50833
|
+
|
|
50834
|
+
function fromFragment() {
|
|
50835
|
+
var raw = location.hash.slice(1);
|
|
50836
|
+
if (raw === '') return null;
|
|
50837
|
+
try { raw = decodeURIComponent(raw); } catch (e) { /* keep the raw fragment */ }
|
|
50838
|
+
return resolve(raw);
|
|
50839
|
+
}
|
|
50840
|
+
|
|
50841
|
+
document.addEventListener('click', function (event) {
|
|
50842
|
+
var target = event.target;
|
|
50843
|
+
var mover = target.closest ? target.closest('[data-navigate]') : null;
|
|
50844
|
+
if (mover) {
|
|
50845
|
+
var destination = resolve(mover.getAttribute('data-navigate'));
|
|
50846
|
+
if (destination !== null) {
|
|
50847
|
+
event.preventDefault();
|
|
50848
|
+
show(destination, true);
|
|
50849
|
+
return;
|
|
50850
|
+
}
|
|
50851
|
+
}
|
|
50852
|
+
|
|
50853
|
+
var opener = target.closest ? target.closest('[data-opens]') : null;
|
|
50854
|
+
if (opener) {
|
|
50855
|
+
var opened = overlayFor(current, opener.getAttribute('data-opens'));
|
|
50856
|
+
if (opened) {
|
|
50857
|
+
event.preventDefault();
|
|
50858
|
+
opened.classList.remove(CLOSED);
|
|
50859
|
+
return;
|
|
50860
|
+
}
|
|
50861
|
+
}
|
|
50862
|
+
|
|
50863
|
+
var toggler = target.closest ? target.closest('[data-toggles]') : null;
|
|
50864
|
+
if (toggler) {
|
|
50865
|
+
var toggled = overlayFor(current, toggler.getAttribute('data-toggles'));
|
|
50866
|
+
if (toggled) {
|
|
50867
|
+
event.preventDefault();
|
|
50868
|
+
toggled.classList.toggle(CLOSED);
|
|
50869
|
+
return;
|
|
50870
|
+
}
|
|
50871
|
+
}
|
|
50872
|
+
|
|
50873
|
+
var actor = target.closest ? target.closest('[data-action]') : null;
|
|
50874
|
+
if (actor) {
|
|
50875
|
+
var action = (actor.getAttribute('data-action') || '').trim();
|
|
50876
|
+
if (action === 'close' || action === 'back') {
|
|
50877
|
+
event.preventDefault();
|
|
50878
|
+
closeOverlays(current);
|
|
50879
|
+
return;
|
|
50880
|
+
}
|
|
50881
|
+
}
|
|
50882
|
+
|
|
50883
|
+
if (target.classList && target.classList.contains(P + '-modal-backdrop')) {
|
|
50884
|
+
target.classList.add(CLOSED);
|
|
50885
|
+
}
|
|
50886
|
+
var link = target.closest ? target.closest('a[href]') : null;
|
|
50887
|
+
if (link && link.getAttribute('href') === '#') event.preventDefault();
|
|
50888
|
+
});
|
|
50889
|
+
|
|
50890
|
+
document.addEventListener('keydown', function (event) {
|
|
50891
|
+
if (event.key === 'Escape' && current !== null) closeOverlays(current);
|
|
50892
|
+
});
|
|
50893
|
+
window.addEventListener('hashchange', function () {
|
|
50894
|
+
var key = fromFragment();
|
|
50895
|
+
if (key !== null) show(key, false);
|
|
50896
|
+
});
|
|
50897
|
+
|
|
50898
|
+
var start = fromFragment();
|
|
50899
|
+
if (start === null) start = String(R.entry);
|
|
50900
|
+
if (!show(start, false)) show(String(R.entry), false);
|
|
50901
|
+
})();`;
|
|
50902
|
+
}
|
|
50903
|
+
|
|
50904
|
+
// src/renderer/site/index.ts
|
|
50905
|
+
var DEFAULT_PREFIX2 = "wf";
|
|
50906
|
+
var screenScope = (index) => `s${index}-`;
|
|
50907
|
+
var shellScope = (index) => `l${index}-`;
|
|
50908
|
+
function escapeAttr2(value) {
|
|
50909
|
+
return value.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
50910
|
+
}
|
|
50911
|
+
function escapeText(value) {
|
|
50912
|
+
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
50913
|
+
}
|
|
50914
|
+
function attrs(pairs) {
|
|
50915
|
+
return pairs.filter((pair) => pair[1] !== void 0).map(([name, value]) => ` ${name}="${escapeAttr2(value)}"`).join("");
|
|
50916
|
+
}
|
|
50917
|
+
function renderHostedScreen(screen, shell, make, prefix) {
|
|
50918
|
+
const { width, height } = resolvePageDimensions(screen.page);
|
|
50919
|
+
const conflict = width !== shell.width || height !== shell.height ? `${width}x${height}` : void 0;
|
|
50920
|
+
const scope = screenScope(screen.index);
|
|
50921
|
+
const marks = attrs([
|
|
50922
|
+
["data-screen", String(screen.index)],
|
|
50923
|
+
["data-screen-name", screen.name],
|
|
50924
|
+
[ID_SCOPE_ATTR, scope],
|
|
50925
|
+
["data-wf-viewport-conflict", conflict]
|
|
50926
|
+
]);
|
|
50927
|
+
const content = make(scope).renderFragment(screen.page.children);
|
|
50928
|
+
return `<div class="${prefix}-screen"${marks}>
|
|
50929
|
+
${content}
|
|
50930
|
+
</div>`;
|
|
50931
|
+
}
|
|
50932
|
+
function renderStandaloneScreen(screen, make, prefix) {
|
|
50933
|
+
const scope = screenScope(screen.index);
|
|
50934
|
+
const marks = attrs([
|
|
50935
|
+
["data-screen", String(screen.index)],
|
|
50936
|
+
["data-screen-name", screen.name],
|
|
50937
|
+
[ID_SCOPE_ATTR, scope],
|
|
50938
|
+
["data-wf-uses-unresolved", screen.miss?.uses],
|
|
50939
|
+
["data-wf-uses-reason", screen.miss?.reason]
|
|
50940
|
+
]);
|
|
50941
|
+
const page = make(scope).render({ type: "Document", children: [screen.page] }).html;
|
|
50942
|
+
return `<div class="${prefix}-screen"${marks}>
|
|
50943
|
+
${page}
|
|
50944
|
+
</div>`;
|
|
50945
|
+
}
|
|
50946
|
+
function renderShell(shell, index, make, prefix) {
|
|
50947
|
+
const hosted = shell.screens.map((screen) => renderHostedScreen(screen, shell, make, prefix)).join("\n");
|
|
50948
|
+
const scope = shellScope(index);
|
|
50949
|
+
const style = `position: relative; width: ${shell.width}px; height: ${shell.height}px; overflow: hidden`;
|
|
50950
|
+
const marks = attrs([
|
|
50951
|
+
["data-layout", shell.name],
|
|
50952
|
+
[ID_SCOPE_ATTR, scope],
|
|
50953
|
+
["data-viewport-width", String(shell.width)],
|
|
50954
|
+
["data-viewport-height", String(shell.height)]
|
|
50955
|
+
]);
|
|
50956
|
+
const body = make(scope).renderFragment(shell.layout.children, hosted);
|
|
50957
|
+
return `<div class="${prefix}-page ${prefix}-shell" style="${style}"${marks}>
|
|
50958
|
+
${body}
|
|
50959
|
+
</div>`;
|
|
50960
|
+
}
|
|
50961
|
+
function resolveEntry(model, options) {
|
|
50962
|
+
const fallback = Math.max(model.entry, 0);
|
|
50963
|
+
const requested = options.entry?.trim();
|
|
50964
|
+
if (!requested) return { index: fallback };
|
|
50965
|
+
const index = model.names.get(requested);
|
|
50966
|
+
return index === void 0 ? { index: fallback, unresolved: requested } : { index };
|
|
50967
|
+
}
|
|
50968
|
+
function resolveTitle(model, options, entry) {
|
|
50969
|
+
if (options.title !== void 0) return options.title;
|
|
50970
|
+
const title = model.screens[entry]?.page.title?.trim();
|
|
50971
|
+
return title || "Wireframe";
|
|
50972
|
+
}
|
|
50973
|
+
function renderSite(document, options = {}) {
|
|
50974
|
+
const prefix = options.classPrefix ?? DEFAULT_PREFIX2;
|
|
50975
|
+
const model = buildSiteModel(document);
|
|
50976
|
+
const make = (idScope) => new HtmlRenderer({
|
|
50977
|
+
theme: options.theme,
|
|
50978
|
+
classPrefix: prefix,
|
|
50979
|
+
background: options.background,
|
|
50980
|
+
includeStyles: false,
|
|
50981
|
+
idScope
|
|
50982
|
+
});
|
|
50983
|
+
const shells = model.shells.map((shell, index) => renderShell(shell, index, make, prefix)).join("\n");
|
|
50984
|
+
const standalone = model.screens.filter((screen) => screen.shell === void 0).map((screen) => renderStandaloneScreen(screen, make, prefix)).join("\n");
|
|
50985
|
+
const entry = resolveEntry(model, options);
|
|
50986
|
+
const theme = options.theme === "dark" ? darkTheme : defaultTheme;
|
|
50987
|
+
const css = generateStyles(theme, prefix) + generateSiteStyles(prefix);
|
|
50988
|
+
const runtime = siteRuntime(
|
|
50989
|
+
{
|
|
50990
|
+
names: Object.fromEntries(model.names),
|
|
50991
|
+
fragments: model.screens.map((screen) => screen.name ?? String(screen.index)),
|
|
50992
|
+
entry: entry.index
|
|
50993
|
+
},
|
|
50994
|
+
prefix
|
|
50995
|
+
);
|
|
50996
|
+
const body = [shells, standalone].filter((part) => part.length > 0).join("\n");
|
|
50997
|
+
const siteAttrs = attrs([
|
|
50998
|
+
["data-screen-count", String(model.screens.length)],
|
|
50999
|
+
["data-shell-count", String(model.shells.length)],
|
|
51000
|
+
["data-wf-entry-unresolved", entry.unresolved]
|
|
51001
|
+
]);
|
|
51002
|
+
return `<!DOCTYPE html>
|
|
51003
|
+
<html lang="en">
|
|
51004
|
+
<head>
|
|
51005
|
+
<meta charset="UTF-8">
|
|
51006
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
51007
|
+
<title>${escapeText(resolveTitle(model, options, entry.index))}</title>
|
|
51008
|
+
<style>
|
|
51009
|
+
html, body {
|
|
51010
|
+
margin: 0;
|
|
51011
|
+
padding: 0;
|
|
51012
|
+
min-height: 100vh;
|
|
51013
|
+
background: #f4f4f5;
|
|
51014
|
+
}
|
|
51015
|
+
body {
|
|
51016
|
+
padding: 24px;
|
|
51017
|
+
box-sizing: border-box;
|
|
51018
|
+
}
|
|
51019
|
+
${css}
|
|
51020
|
+
</style>
|
|
51021
|
+
</head>
|
|
51022
|
+
<body>
|
|
51023
|
+
<div class="${prefix}-site"${siteAttrs}>
|
|
51024
|
+
${body}
|
|
51025
|
+
</div>
|
|
51026
|
+
<script>
|
|
51027
|
+
${runtime}
|
|
51028
|
+
</script>
|
|
51029
|
+
</body>
|
|
51030
|
+
</html>`;
|
|
51031
|
+
}
|
|
51032
|
+
|
|
50469
51033
|
// src/renderer/index.ts
|
|
50470
51034
|
function render(document, options = {}) {
|
|
50471
|
-
const isMultiPage = document.
|
|
51035
|
+
const isMultiPage = documentPages(document).length > 1;
|
|
50472
51036
|
if (isMultiPage) {
|
|
50473
51037
|
const result = renderCanvas(document, options);
|
|
50474
51038
|
return { html: result.html, css: result.css };
|
|
@@ -50479,7 +51043,7 @@ function render(document, options = {}) {
|
|
|
50479
51043
|
function renderToHtml(document, options = {}) {
|
|
50480
51044
|
const { html, css } = render(document, options);
|
|
50481
51045
|
const prefix = options.classPrefix ?? "wf";
|
|
50482
|
-
const isMultiPage = document.
|
|
51046
|
+
const isMultiPage = documentPages(document).length > 1;
|
|
50483
51047
|
const bodyAlign = isMultiPage ? "justify-content: flex-start;\n align-items: flex-start;" : "justify-content: center;\n align-items: center;";
|
|
50484
51048
|
return `<!DOCTYPE html>
|
|
50485
51049
|
<html lang="en">
|
|
@@ -50518,7 +51082,7 @@ ${html}
|
|
|
50518
51082
|
</html>`;
|
|
50519
51083
|
}
|
|
50520
51084
|
function renderToSvg(document, options = {}) {
|
|
50521
|
-
const isMultiPage = document.
|
|
51085
|
+
const isMultiPage = documentPages(document).length > 1;
|
|
50522
51086
|
let width = options.width ?? 800;
|
|
50523
51087
|
let height = options.height ?? 600;
|
|
50524
51088
|
let html;
|
|
@@ -50534,7 +51098,7 @@ function renderToSvg(document, options = {}) {
|
|
|
50534
51098
|
html = canvas.html;
|
|
50535
51099
|
css = canvas.css;
|
|
50536
51100
|
} else {
|
|
50537
|
-
const firstPage = document
|
|
51101
|
+
const firstPage = documentPages(document)[0];
|
|
50538
51102
|
if (firstPage && options.width === void 0 && options.height === void 0) {
|
|
50539
51103
|
const dims = resolvePageDimensions(firstPage);
|
|
50540
51104
|
width = dims.width;
|
|
@@ -50571,6 +51135,8 @@ ${css}
|
|
|
50571
51135
|
// Annotate the CommonJS export names for ESM import in node:
|
|
50572
51136
|
0 && (module.exports = {
|
|
50573
51137
|
HtmlRenderer,
|
|
51138
|
+
anchorIntent,
|
|
51139
|
+
buildSiteModel,
|
|
50574
51140
|
createHtmlRenderer,
|
|
50575
51141
|
darkTheme,
|
|
50576
51142
|
defaultTheme,
|
|
@@ -50584,6 +51150,7 @@ ${css}
|
|
|
50584
51150
|
renderCanvas,
|
|
50585
51151
|
renderIconSvg,
|
|
50586
51152
|
renderPage,
|
|
51153
|
+
renderSite,
|
|
50587
51154
|
renderToHtml,
|
|
50588
51155
|
renderToSvg,
|
|
50589
51156
|
renderUnknownIconSvg,
|