@wireweave/core 3.1.0-beta.1 → 3.1.0-beta.2
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 +1718 -983
- package/dist/index.d.cts +16 -4
- package/dist/index.d.ts +16 -4
- package/dist/index.js +1712 -983
- 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 +572 -40
- package/dist/renderer.d.cts +49 -2
- package/dist/renderer.d.ts +49 -2
- package/dist/renderer.js +570 -40
- 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 +1 -1
package/dist/renderer.cjs
CHANGED
|
@@ -21,6 +21,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var renderer_exports = {};
|
|
22
22
|
__export(renderer_exports, {
|
|
23
23
|
HtmlRenderer: () => HtmlRenderer,
|
|
24
|
+
buildSiteModel: () => buildSiteModel,
|
|
24
25
|
createHtmlRenderer: () => createHtmlRenderer,
|
|
25
26
|
darkTheme: () => darkTheme,
|
|
26
27
|
defaultTheme: () => defaultTheme,
|
|
@@ -34,6 +35,7 @@ __export(renderer_exports, {
|
|
|
34
35
|
renderCanvas: () => renderCanvas,
|
|
35
36
|
renderIconSvg: () => renderIconSvg,
|
|
36
37
|
renderPage: () => renderPage,
|
|
38
|
+
renderSite: () => renderSite,
|
|
37
39
|
renderToHtml: () => renderToHtml,
|
|
38
40
|
renderToSvg: () => renderToSvg,
|
|
39
41
|
renderUnknownIconSvg: () => renderUnknownIconSvg,
|
|
@@ -41,6 +43,30 @@ __export(renderer_exports, {
|
|
|
41
43
|
});
|
|
42
44
|
module.exports = __toCommonJS(renderer_exports);
|
|
43
45
|
|
|
46
|
+
// src/ast/guards.ts
|
|
47
|
+
function hasChildren(node) {
|
|
48
|
+
return "children" in node && Array.isArray(node.children);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// src/ast/utils.ts
|
|
52
|
+
function walk(node, callback, parent, depth = 0) {
|
|
53
|
+
const result = callback(node, parent, depth);
|
|
54
|
+
if (result === false) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
if (hasChildren(node)) {
|
|
58
|
+
for (const child of node.children) {
|
|
59
|
+
walk(child, callback, node, depth + 1);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function documentPages(document) {
|
|
64
|
+
return document.children.filter((child) => child.type === "Page");
|
|
65
|
+
}
|
|
66
|
+
function documentDefinitions(document) {
|
|
67
|
+
return document.children.filter((child) => child.type === "Layout");
|
|
68
|
+
}
|
|
69
|
+
|
|
44
70
|
// src/renderer/types.ts
|
|
45
71
|
var defaultTheme = {
|
|
46
72
|
colors: {
|
|
@@ -1995,7 +2021,8 @@ var DEFAULT_OPTIONS = {
|
|
|
1995
2021
|
includeStyles: true,
|
|
1996
2022
|
minify: false,
|
|
1997
2023
|
classPrefix: "wf",
|
|
1998
|
-
sourceAnchors: false
|
|
2024
|
+
sourceAnchors: false,
|
|
2025
|
+
idScope: ""
|
|
1999
2026
|
};
|
|
2000
2027
|
var BaseRenderer = class {
|
|
2001
2028
|
context;
|
|
@@ -2034,7 +2061,7 @@ var BaseRenderer = class {
|
|
|
2034
2061
|
* Render a complete wireframe document
|
|
2035
2062
|
*/
|
|
2036
2063
|
renderDocument(document) {
|
|
2037
|
-
const pages = document.
|
|
2064
|
+
const pages = documentPages(document).map((page) => this.renderPage(page)).join(this.context.options.minify ? "" : "\n");
|
|
2038
2065
|
return pages;
|
|
2039
2066
|
}
|
|
2040
2067
|
/**
|
|
@@ -2075,6 +2102,10 @@ var BaseRenderer = class {
|
|
|
2075
2102
|
};
|
|
2076
2103
|
return text.replace(/[&<>"']/g, (char) => escapeMap[char] || char);
|
|
2077
2104
|
}
|
|
2105
|
+
/** Return the DOM id for an authored id under this renderer's scope. */
|
|
2106
|
+
scopedId(id) {
|
|
2107
|
+
return this.context.options.idScope + id;
|
|
2108
|
+
}
|
|
2078
2109
|
/**
|
|
2079
2110
|
* Build a CSS class string from an array of class names
|
|
2080
2111
|
*/
|
|
@@ -2084,9 +2115,9 @@ var BaseRenderer = class {
|
|
|
2084
2115
|
/**
|
|
2085
2116
|
* Build HTML attributes string
|
|
2086
2117
|
*/
|
|
2087
|
-
buildAttrsString(
|
|
2118
|
+
buildAttrsString(attrs2) {
|
|
2088
2119
|
const parts = [];
|
|
2089
|
-
for (const [key, value] of Object.entries(
|
|
2120
|
+
for (const [key, value] of Object.entries(attrs2)) {
|
|
2090
2121
|
if (value === void 0 || value === false) {
|
|
2091
2122
|
continue;
|
|
2092
2123
|
}
|
|
@@ -2196,7 +2227,7 @@ function formatAnchorLoc(loc) {
|
|
|
2196
2227
|
return `${loc.start.offset}-${loc.end.offset}`;
|
|
2197
2228
|
}
|
|
2198
2229
|
function walkAnchorPaths(doc, visit, pageIndexBase = 0) {
|
|
2199
|
-
doc.
|
|
2230
|
+
documentPages(doc).forEach((page, i) => {
|
|
2200
2231
|
visitAnchorNode(page, String(pageIndexBase + i), visit);
|
|
2201
2232
|
});
|
|
2202
2233
|
}
|
|
@@ -2407,7 +2438,7 @@ function renderModal(node, ctx) {
|
|
|
2407
2438
|
const classes = ctx.buildClassString([`${ctx.prefix}-modal`, ...ctx.getCommonClasses(node)]);
|
|
2408
2439
|
const styles = ctx.buildCommonStyles(node);
|
|
2409
2440
|
const styleAttr = styles ? ` style="${styles}"` : "";
|
|
2410
|
-
const idAttr = node.id ? ` id="${ctx.escapeHtml(node.id)}"` : "";
|
|
2441
|
+
const idAttr = node.id ? ` id="${ctx.escapeHtml(ctx.scopedId(node.id))}"` : "";
|
|
2411
2442
|
const title = node.title ? `<h2 class="${ctx.prefix}-title">${ctx.escapeHtml(node.title)}</h2>
|
|
2412
2443
|
` : "";
|
|
2413
2444
|
const children = ctx.renderChildren(node.children);
|
|
@@ -2426,7 +2457,7 @@ function renderDrawer(node, ctx) {
|
|
|
2426
2457
|
]);
|
|
2427
2458
|
const styles = ctx.buildCommonStyles(node);
|
|
2428
2459
|
const styleAttr = styles ? ` style="${styles}"` : "";
|
|
2429
|
-
const idAttr = node.id ? ` id="${ctx.escapeHtml(node.id)}"` : "";
|
|
2460
|
+
const idAttr = node.id ? ` id="${ctx.escapeHtml(ctx.scopedId(node.id))}"` : "";
|
|
2430
2461
|
const title = node.title ? `<h2 class="${ctx.prefix}-title">${ctx.escapeHtml(node.title)}</h2>
|
|
2431
2462
|
` : "";
|
|
2432
2463
|
const children = ctx.renderChildren(node.children);
|
|
@@ -2510,7 +2541,7 @@ function renderLink(node, ctx) {
|
|
|
2510
2541
|
const classes = ctx.buildClassString([`${ctx.prefix}-link`, ...ctx.getCommonClasses(node)]);
|
|
2511
2542
|
const styles = ctx.buildCommonStyles(node);
|
|
2512
2543
|
const styleAttr = styles ? ` style="${styles}"` : "";
|
|
2513
|
-
const
|
|
2544
|
+
const attrs2 = {
|
|
2514
2545
|
class: classes,
|
|
2515
2546
|
href: node.href || node.navigate || "#",
|
|
2516
2547
|
// Interactive attributes
|
|
@@ -2520,10 +2551,10 @@ function renderLink(node, ctx) {
|
|
|
2520
2551
|
"data-action": node.action
|
|
2521
2552
|
};
|
|
2522
2553
|
if (node.external) {
|
|
2523
|
-
|
|
2524
|
-
|
|
2554
|
+
attrs2.target = "_blank";
|
|
2555
|
+
attrs2.rel = "noopener noreferrer";
|
|
2525
2556
|
}
|
|
2526
|
-
return `<a${ctx.buildAttrsString(
|
|
2557
|
+
return `<a${ctx.buildAttrsString(attrs2)}${styleAttr}>${ctx.escapeHtml(node.content)}</a>`;
|
|
2527
2558
|
}
|
|
2528
2559
|
|
|
2529
2560
|
// src/icons/lucide-icons.ts
|
|
@@ -48945,8 +48976,8 @@ function getIconData(name) {
|
|
|
48945
48976
|
return void 0;
|
|
48946
48977
|
}
|
|
48947
48978
|
function renderIconSvg(data, _size = 24, strokeWidth = 2, className = "", styleAttr = "") {
|
|
48948
|
-
const elements = data.map(([tag,
|
|
48949
|
-
const attrStr = Object.entries(
|
|
48979
|
+
const elements = data.map(([tag, attrs2]) => {
|
|
48980
|
+
const attrStr = Object.entries(attrs2).map(([key, value]) => `${key}="${value}"`).join(" ");
|
|
48950
48981
|
return `<${tag} ${attrStr} />`;
|
|
48951
48982
|
}).join("");
|
|
48952
48983
|
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 +49011,7 @@ function renderButton(node, ctx) {
|
|
|
48980
49011
|
const combinedStyles = baseStyles && sizeStyle ? `${baseStyles}; ${sizeStyle}` : baseStyles || sizeStyle;
|
|
48981
49012
|
const styleAttr = combinedStyles ? ` style="${combinedStyles}"` : "";
|
|
48982
49013
|
const accessibleName = node.aria ?? node["aria-label"];
|
|
48983
|
-
const
|
|
49014
|
+
const attrs2 = {
|
|
48984
49015
|
class: classes,
|
|
48985
49016
|
disabled: node.disabled,
|
|
48986
49017
|
"aria-label": accessibleName,
|
|
@@ -49002,7 +49033,7 @@ function renderButton(node, ctx) {
|
|
|
49002
49033
|
}
|
|
49003
49034
|
const loading = node.loading ? `<span class="${ctx.prefix}-spinner ${ctx.prefix}-spinner-sm"></span>` : "";
|
|
49004
49035
|
const content = isIconOnly ? "" : ctx.escapeHtml(node.content);
|
|
49005
|
-
return `<button${ctx.buildAttrsString(
|
|
49036
|
+
return `<button${ctx.buildAttrsString(attrs2)}${styleAttr}>${loading}${icon}${content}</button>`;
|
|
49006
49037
|
}
|
|
49007
49038
|
|
|
49008
49039
|
// src/renderer/html/renderers/feedback.ts
|
|
@@ -49065,7 +49096,7 @@ function renderInput(node, ctx) {
|
|
|
49065
49096
|
]);
|
|
49066
49097
|
const styles = ctx.buildCommonStyles(node);
|
|
49067
49098
|
const styleAttr = styles ? ` style="${styles}"` : "";
|
|
49068
|
-
const
|
|
49099
|
+
const attrs2 = {
|
|
49069
49100
|
class: inputClasses,
|
|
49070
49101
|
type: node.inputType || "text",
|
|
49071
49102
|
placeholder: node.placeholder,
|
|
@@ -49074,7 +49105,7 @@ function renderInput(node, ctx) {
|
|
|
49074
49105
|
required: node.required,
|
|
49075
49106
|
readonly: node.readonly
|
|
49076
49107
|
};
|
|
49077
|
-
const inputElement = `<input${ctx.buildAttrsString(
|
|
49108
|
+
const inputElement = `<input${ctx.buildAttrsString(attrs2)} />`;
|
|
49078
49109
|
if (node.icon) {
|
|
49079
49110
|
const iconData = getIconData(node.icon);
|
|
49080
49111
|
let iconHtml;
|
|
@@ -49092,7 +49123,7 @@ ${wrapper}`;
|
|
|
49092
49123
|
}
|
|
49093
49124
|
return wrapper;
|
|
49094
49125
|
}
|
|
49095
|
-
const input = `<input${ctx.buildAttrsString(
|
|
49126
|
+
const input = `<input${ctx.buildAttrsString(attrs2)}${styleAttr} />`;
|
|
49096
49127
|
const shouldShowLabel2 = node.label && !(node.label === "Label" && node.placeholder);
|
|
49097
49128
|
if (shouldShowLabel2) {
|
|
49098
49129
|
return `<label class="${ctx.prefix}-input-label">${ctx.escapeHtml(node.label)}</label>
|
|
@@ -49104,14 +49135,14 @@ function renderTextarea(node, ctx) {
|
|
|
49104
49135
|
const classes = ctx.buildClassString([`${ctx.prefix}-input`, ...ctx.getCommonClasses(node)]);
|
|
49105
49136
|
const styles = ctx.buildCommonStyles(node);
|
|
49106
49137
|
const styleAttr = styles ? ` style="${styles}"` : "";
|
|
49107
|
-
const
|
|
49138
|
+
const attrs2 = {
|
|
49108
49139
|
class: classes,
|
|
49109
49140
|
placeholder: node.placeholder,
|
|
49110
49141
|
disabled: node.disabled,
|
|
49111
49142
|
required: node.required,
|
|
49112
49143
|
rows: node.rows?.toString()
|
|
49113
49144
|
};
|
|
49114
|
-
const textarea = `<textarea${ctx.buildAttrsString(
|
|
49145
|
+
const textarea = `<textarea${ctx.buildAttrsString(attrs2)}${styleAttr}>${ctx.escapeHtml(node.value || "")}</textarea>`;
|
|
49115
49146
|
if (node.label) {
|
|
49116
49147
|
return `<label class="${ctx.prefix}-input-label">${ctx.escapeHtml(node.label)}</label>
|
|
49117
49148
|
${textarea}`;
|
|
@@ -49122,7 +49153,7 @@ function renderSelect(node, ctx) {
|
|
|
49122
49153
|
const classes = ctx.buildClassString([`${ctx.prefix}-input`, ...ctx.getCommonClasses(node)]);
|
|
49123
49154
|
const styles = ctx.buildCommonStyles(node);
|
|
49124
49155
|
const styleAttr = styles ? ` style="${styles}"` : "";
|
|
49125
|
-
const
|
|
49156
|
+
const attrs2 = {
|
|
49126
49157
|
class: classes,
|
|
49127
49158
|
disabled: node.disabled,
|
|
49128
49159
|
required: node.required
|
|
@@ -49139,7 +49170,7 @@ function renderSelect(node, ctx) {
|
|
|
49139
49170
|
const placeholderSelected = hasSelectedValue ? "" : ' selected="selected"';
|
|
49140
49171
|
const placeholder = node.placeholder ? `<option value="" disabled="disabled"${placeholderSelected}>${ctx.escapeHtml(node.placeholder)}</option>
|
|
49141
49172
|
` : "";
|
|
49142
|
-
const select = `<select${ctx.buildAttrsString(
|
|
49173
|
+
const select = `<select${ctx.buildAttrsString(attrs2)}${styleAttr}>
|
|
49143
49174
|
${placeholder}${options}
|
|
49144
49175
|
</select>`;
|
|
49145
49176
|
if (node.label) {
|
|
@@ -49151,12 +49182,12 @@ ${select}`;
|
|
|
49151
49182
|
function renderCheckbox(node, ctx) {
|
|
49152
49183
|
const styles = ctx.buildCommonStyles(node);
|
|
49153
49184
|
const styleAttr = styles ? ` style="${styles}"` : "";
|
|
49154
|
-
const
|
|
49185
|
+
const attrs2 = {
|
|
49155
49186
|
type: "checkbox",
|
|
49156
49187
|
checked: node.checked,
|
|
49157
49188
|
disabled: node.disabled
|
|
49158
49189
|
};
|
|
49159
|
-
const checkbox = `<input${ctx.buildAttrsString(
|
|
49190
|
+
const checkbox = `<input${ctx.buildAttrsString(attrs2)} />`;
|
|
49160
49191
|
if (node.label) {
|
|
49161
49192
|
return `<label class="${ctx.prefix}-checkbox"${styleAttr}>${checkbox}<span>${ctx.escapeHtml(node.label)}</span></label>`;
|
|
49162
49193
|
}
|
|
@@ -49165,13 +49196,13 @@ function renderCheckbox(node, ctx) {
|
|
|
49165
49196
|
function renderRadio(node, ctx) {
|
|
49166
49197
|
const styles = ctx.buildCommonStyles(node);
|
|
49167
49198
|
const styleAttr = styles ? ` style="${styles}"` : "";
|
|
49168
|
-
const
|
|
49199
|
+
const attrs2 = {
|
|
49169
49200
|
type: "radio",
|
|
49170
49201
|
name: node.name,
|
|
49171
49202
|
checked: node.checked,
|
|
49172
49203
|
disabled: node.disabled
|
|
49173
49204
|
};
|
|
49174
|
-
const radio = `<input${ctx.buildAttrsString(
|
|
49205
|
+
const radio = `<input${ctx.buildAttrsString(attrs2)} />`;
|
|
49175
49206
|
if (node.label) {
|
|
49176
49207
|
return `<label class="${ctx.prefix}-radio"${styleAttr}>${radio}<span>${ctx.escapeHtml(node.label)}</span></label>`;
|
|
49177
49208
|
}
|
|
@@ -49181,13 +49212,13 @@ function renderSwitch(node, ctx) {
|
|
|
49181
49212
|
const classes = ctx.buildClassString([`${ctx.prefix}-switch`, ...ctx.getCommonClasses(node)]);
|
|
49182
49213
|
const styles = ctx.buildCommonStyles(node);
|
|
49183
49214
|
const styleAttr = styles ? ` style="${styles}"` : "";
|
|
49184
|
-
const
|
|
49215
|
+
const attrs2 = {
|
|
49185
49216
|
type: "checkbox",
|
|
49186
49217
|
role: "switch",
|
|
49187
49218
|
checked: node.checked,
|
|
49188
49219
|
disabled: node.disabled
|
|
49189
49220
|
};
|
|
49190
|
-
const switchEl = `<input${ctx.buildAttrsString(
|
|
49221
|
+
const switchEl = `<input${ctx.buildAttrsString(attrs2)} />`;
|
|
49191
49222
|
if (node.label) {
|
|
49192
49223
|
return `<label class="${classes}"${styleAttr}>${switchEl} ${ctx.escapeHtml(node.label)}</label>`;
|
|
49193
49224
|
}
|
|
@@ -49197,7 +49228,7 @@ function renderSlider(node, ctx) {
|
|
|
49197
49228
|
const classes = ctx.buildClassString([`${ctx.prefix}-slider`, ...ctx.getCommonClasses(node)]);
|
|
49198
49229
|
const styles = ctx.buildCommonStyles(node);
|
|
49199
49230
|
const styleAttr = styles ? ` style="${styles}"` : "";
|
|
49200
|
-
const
|
|
49231
|
+
const attrs2 = {
|
|
49201
49232
|
class: classes,
|
|
49202
49233
|
type: "range",
|
|
49203
49234
|
min: node.min?.toString(),
|
|
@@ -49206,7 +49237,7 @@ function renderSlider(node, ctx) {
|
|
|
49206
49237
|
value: node.value?.toString(),
|
|
49207
49238
|
disabled: node.disabled
|
|
49208
49239
|
};
|
|
49209
|
-
const slider = `<input${ctx.buildAttrsString(
|
|
49240
|
+
const slider = `<input${ctx.buildAttrsString(attrs2)}${styleAttr} />`;
|
|
49210
49241
|
if (node.label) {
|
|
49211
49242
|
return `<label class="${ctx.prefix}-input-label">${ctx.escapeHtml(node.label)}</label>
|
|
49212
49243
|
${slider}`;
|
|
@@ -49228,14 +49259,14 @@ function renderImage(node, ctx) {
|
|
|
49228
49259
|
const styles = ctx.buildCommonStyles(node);
|
|
49229
49260
|
const styleAttr = styles ? ` style="${styles}"` : "";
|
|
49230
49261
|
if (node.src) {
|
|
49231
|
-
const
|
|
49262
|
+
const attrs2 = {
|
|
49232
49263
|
class: classes,
|
|
49233
49264
|
src: node.src,
|
|
49234
49265
|
alt: node.alt || "Image",
|
|
49235
49266
|
...buildInteractiveAttrs2(node)
|
|
49236
49267
|
};
|
|
49237
49268
|
const imgStyleAttr = styles ? `; ${styles}` : "";
|
|
49238
|
-
return `<img${ctx.buildAttrsString(
|
|
49269
|
+
return `<img${ctx.buildAttrsString(attrs2)}${imgStyleAttr ? ` style="${imgStyleAttr.slice(2)}"` : ""} />`;
|
|
49239
49270
|
}
|
|
49240
49271
|
const label = node.alt || "Image";
|
|
49241
49272
|
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>`;
|
|
@@ -49755,8 +49786,8 @@ function renderAnnotationItem(node, ctx) {
|
|
|
49755
49786
|
|
|
49756
49787
|
// src/renderer/html/index.ts
|
|
49757
49788
|
function injectAnchorAttrs(html, path, loc) {
|
|
49758
|
-
const
|
|
49759
|
-
return html.replace(/<([a-zA-Z][a-zA-Z0-9-]*)/, (match) => `${match}${
|
|
49789
|
+
const attrs2 = loc ? ` ${ANCHOR_PATH_ATTR}="${path}" ${ANCHOR_LOC_ATTR}="${formatAnchorLoc(loc)}"` : ` ${ANCHOR_PATH_ATTR}="${path}"`;
|
|
49790
|
+
return html.replace(/<([a-zA-Z][a-zA-Z0-9-]*)/, (match) => `${match}${attrs2}`);
|
|
49760
49791
|
}
|
|
49761
49792
|
var SPACING_TOKENS = {
|
|
49762
49793
|
0: "0px",
|
|
@@ -49811,6 +49842,8 @@ var HtmlRenderer = class extends BaseRenderer {
|
|
|
49811
49842
|
* index in the anchor scheme.
|
|
49812
49843
|
*/
|
|
49813
49844
|
pageIndexBase;
|
|
49845
|
+
/** Content supplied by a site renderer for the next layout slot. */
|
|
49846
|
+
slotContent = null;
|
|
49814
49847
|
constructor(options = {}, pageIndexBase = 0) {
|
|
49815
49848
|
super(options);
|
|
49816
49849
|
this.pageIndexBase = pageIndexBase;
|
|
@@ -49837,6 +49870,7 @@ var HtmlRenderer = class extends BaseRenderer {
|
|
|
49837
49870
|
return {
|
|
49838
49871
|
prefix: this.prefix,
|
|
49839
49872
|
escapeHtml: this.escapeHtml.bind(this),
|
|
49873
|
+
scopedId: this.scopedId.bind(this),
|
|
49840
49874
|
buildClassString: this.buildClassString.bind(this),
|
|
49841
49875
|
buildAttrsString: this.buildAttrsString.bind(this),
|
|
49842
49876
|
buildCommonStyles: this.buildCommonStyles.bind(this),
|
|
@@ -49914,6 +49948,7 @@ var HtmlRenderer = class extends BaseRenderer {
|
|
|
49914
49948
|
Breadcrumb: (node) => this.renderBreadcrumb(node),
|
|
49915
49949
|
// Other
|
|
49916
49950
|
Divider: (node) => this.renderDivider(node),
|
|
49951
|
+
Slot: () => this.renderSlot(),
|
|
49917
49952
|
// Annotation nodes
|
|
49918
49953
|
Marker: (node) => this.renderMarker(node),
|
|
49919
49954
|
Annotations: (node) => this.renderAnnotations(node),
|
|
@@ -49990,6 +50025,25 @@ ${annotationsContent}
|
|
|
49990
50025
|
}
|
|
49991
50026
|
return html;
|
|
49992
50027
|
}
|
|
50028
|
+
/** Render the first slot with the supplied page content, if any. */
|
|
50029
|
+
renderSlot() {
|
|
50030
|
+
const content = this.slotContent;
|
|
50031
|
+
this.slotContent = null;
|
|
50032
|
+
const open = `<div class="${this.prefix}-slot">`;
|
|
50033
|
+
return content === null ? `${open}</div>` : `${open}
|
|
50034
|
+
${content}
|
|
50035
|
+
</div>`;
|
|
50036
|
+
}
|
|
50037
|
+
/** Render nodes without adding a page frame, optionally filling a slot. */
|
|
50038
|
+
renderFragment(nodes, slotContent = null) {
|
|
50039
|
+
const previous = this.slotContent;
|
|
50040
|
+
this.slotContent = slotContent;
|
|
50041
|
+
try {
|
|
50042
|
+
return this.renderChildren(nodes);
|
|
50043
|
+
} finally {
|
|
50044
|
+
this.slotContent = previous;
|
|
50045
|
+
}
|
|
50046
|
+
}
|
|
49993
50047
|
/**
|
|
49994
50048
|
* Render children nodes
|
|
49995
50049
|
*/
|
|
@@ -50430,7 +50484,8 @@ function renderCanvas(doc, options = {}) {
|
|
|
50430
50484
|
const includeStyles = options.includeStyles !== false;
|
|
50431
50485
|
const theme = options.theme === "dark" ? darkTheme : defaultTheme;
|
|
50432
50486
|
const css = includeStyles ? generateStyles(theme, prefix) : "";
|
|
50433
|
-
|
|
50487
|
+
const pages = documentPages(doc);
|
|
50488
|
+
if (pages.length === 0) {
|
|
50434
50489
|
return {
|
|
50435
50490
|
html: `<div class="${prefix}-canvas" data-empty="true"></div>`,
|
|
50436
50491
|
css,
|
|
@@ -50438,7 +50493,7 @@ function renderCanvas(doc, options = {}) {
|
|
|
50438
50493
|
height: 0
|
|
50439
50494
|
};
|
|
50440
50495
|
}
|
|
50441
|
-
const { placed, width, height } = layoutCanvas(
|
|
50496
|
+
const { placed, width, height } = layoutCanvas(pages, gap);
|
|
50442
50497
|
const boards = placed.map((p, pageIndex) => {
|
|
50443
50498
|
const pageRenderer = new HtmlRenderer({ ...options, includeStyles: false }, pageIndex);
|
|
50444
50499
|
const { html: pageHtml } = pageRenderer.render({
|
|
@@ -50466,9 +50521,484 @@ function escapeAttr(s) {
|
|
|
50466
50521
|
return s.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<");
|
|
50467
50522
|
}
|
|
50468
50523
|
|
|
50524
|
+
// src/renderer/site/model.ts
|
|
50525
|
+
function pageId(page) {
|
|
50526
|
+
const id = page.id?.trim();
|
|
50527
|
+
return id && id.length > 0 ? id : void 0;
|
|
50528
|
+
}
|
|
50529
|
+
function pageTitle(page) {
|
|
50530
|
+
const title = page.title?.trim();
|
|
50531
|
+
return title && title.length > 0 ? title : void 0;
|
|
50532
|
+
}
|
|
50533
|
+
function hasSlot(layout) {
|
|
50534
|
+
for (const child of layout.children) {
|
|
50535
|
+
let found = false;
|
|
50536
|
+
walk(child, (node) => {
|
|
50537
|
+
if (node.type === "Slot") found = true;
|
|
50538
|
+
return !found;
|
|
50539
|
+
});
|
|
50540
|
+
if (found) return true;
|
|
50541
|
+
}
|
|
50542
|
+
return false;
|
|
50543
|
+
}
|
|
50544
|
+
function layoutsByName(doc) {
|
|
50545
|
+
const layouts = /* @__PURE__ */ new Map();
|
|
50546
|
+
for (const definition of documentDefinitions(doc)) {
|
|
50547
|
+
const name = definition.name.trim();
|
|
50548
|
+
if (name.length > 0 && !layouts.has(name)) layouts.set(name, definition);
|
|
50549
|
+
}
|
|
50550
|
+
return layouts;
|
|
50551
|
+
}
|
|
50552
|
+
function resolveShell(page, layouts) {
|
|
50553
|
+
const uses = page.uses?.trim();
|
|
50554
|
+
if (!uses) return void 0;
|
|
50555
|
+
const layout = layouts.get(uses);
|
|
50556
|
+
if (!layout) return { miss: { uses, reason: "unknown-layout" } };
|
|
50557
|
+
if (!hasSlot(layout)) return { miss: { uses, reason: "slotless-layout" } };
|
|
50558
|
+
return { layout, name: uses };
|
|
50559
|
+
}
|
|
50560
|
+
function buildSiteModel(doc) {
|
|
50561
|
+
const screens = documentPages(doc).map((page, index) => ({ index, page }));
|
|
50562
|
+
const layouts = layoutsByName(doc);
|
|
50563
|
+
const shells = [];
|
|
50564
|
+
const shellByName = /* @__PURE__ */ new Map();
|
|
50565
|
+
for (const screen of screens) {
|
|
50566
|
+
const resolved = resolveShell(screen.page, layouts);
|
|
50567
|
+
if (!resolved) continue;
|
|
50568
|
+
if ("miss" in resolved) {
|
|
50569
|
+
screen.miss = resolved.miss;
|
|
50570
|
+
continue;
|
|
50571
|
+
}
|
|
50572
|
+
let shell = shellByName.get(resolved.name);
|
|
50573
|
+
if (!shell) {
|
|
50574
|
+
const { width, height } = resolvePageDimensions(screen.page);
|
|
50575
|
+
shell = { name: resolved.name, layout: resolved.layout, screens: [], width, height };
|
|
50576
|
+
shellByName.set(resolved.name, shell);
|
|
50577
|
+
shells.push(shell);
|
|
50578
|
+
}
|
|
50579
|
+
shell.screens.push(screen);
|
|
50580
|
+
screen.shell = shell.name;
|
|
50581
|
+
}
|
|
50582
|
+
const names = /* @__PURE__ */ new Map();
|
|
50583
|
+
for (const screen of screens) {
|
|
50584
|
+
const title = pageTitle(screen.page);
|
|
50585
|
+
if (title !== void 0 && !names.has(title)) names.set(title, screen.index);
|
|
50586
|
+
}
|
|
50587
|
+
for (const screen of screens) {
|
|
50588
|
+
const id = pageId(screen.page);
|
|
50589
|
+
if (id === void 0) continue;
|
|
50590
|
+
const owner = names.get(id);
|
|
50591
|
+
if (owner === void 0 || pageId(screens[owner].page) !== id) {
|
|
50592
|
+
names.set(id, screen.index);
|
|
50593
|
+
}
|
|
50594
|
+
}
|
|
50595
|
+
for (const screen of screens) {
|
|
50596
|
+
screen.name = [pageId(screen.page), pageTitle(screen.page)].find(
|
|
50597
|
+
(name) => name !== void 0 && names.get(name) === screen.index
|
|
50598
|
+
);
|
|
50599
|
+
}
|
|
50600
|
+
return { screens, shells, names, entry: screens.length > 0 ? 0 : -1 };
|
|
50601
|
+
}
|
|
50602
|
+
|
|
50603
|
+
// src/renderer/site/styles.ts
|
|
50604
|
+
function generateSiteStyles(prefix) {
|
|
50605
|
+
return `
|
|
50606
|
+
/* ===== Site composition (renderSite) ===== */
|
|
50607
|
+
|
|
50608
|
+
.${prefix}-site {
|
|
50609
|
+
display: flex;
|
|
50610
|
+
justify-content: center;
|
|
50611
|
+
align-items: flex-start;
|
|
50612
|
+
}
|
|
50613
|
+
|
|
50614
|
+
.${prefix}-site > .${prefix}-shell,
|
|
50615
|
+
.${prefix}-site > .${prefix}-screen {
|
|
50616
|
+
display: none;
|
|
50617
|
+
}
|
|
50618
|
+
|
|
50619
|
+
.${prefix}-site > .${prefix}-shell.${prefix}-on {
|
|
50620
|
+
display: flex;
|
|
50621
|
+
flex-direction: column;
|
|
50622
|
+
}
|
|
50623
|
+
|
|
50624
|
+
.${prefix}-site > .${prefix}-screen.${prefix}-on {
|
|
50625
|
+
display: block;
|
|
50626
|
+
}
|
|
50627
|
+
|
|
50628
|
+
.${prefix}-site .${prefix}-page {
|
|
50629
|
+
overflow: auto !important;
|
|
50630
|
+
}
|
|
50631
|
+
|
|
50632
|
+
.${prefix}-site .${prefix}-slot {
|
|
50633
|
+
display: flex;
|
|
50634
|
+
flex-direction: column;
|
|
50635
|
+
flex: 1;
|
|
50636
|
+
min-height: 0;
|
|
50637
|
+
}
|
|
50638
|
+
|
|
50639
|
+
.${prefix}-site .${prefix}-slot > .${prefix}-screen {
|
|
50640
|
+
display: none;
|
|
50641
|
+
}
|
|
50642
|
+
|
|
50643
|
+
.${prefix}-site .${prefix}-slot > .${prefix}-screen.${prefix}-on {
|
|
50644
|
+
display: flex;
|
|
50645
|
+
flex-direction: column;
|
|
50646
|
+
flex: 1;
|
|
50647
|
+
min-height: 0;
|
|
50648
|
+
}
|
|
50649
|
+
|
|
50650
|
+
.${prefix}-site .${prefix}-screen > .${prefix}-col {
|
|
50651
|
+
flex: 1;
|
|
50652
|
+
min-height: 0;
|
|
50653
|
+
}
|
|
50654
|
+
|
|
50655
|
+
.${prefix}-site .${prefix}-closed {
|
|
50656
|
+
display: none;
|
|
50657
|
+
}
|
|
50658
|
+
`;
|
|
50659
|
+
}
|
|
50660
|
+
|
|
50661
|
+
// src/renderer/site/runtime.ts
|
|
50662
|
+
var ID_SCOPE_ATTR = "data-id-scope";
|
|
50663
|
+
function embedJson(value) {
|
|
50664
|
+
return JSON.stringify(value).replace(/</g, "\\u003C");
|
|
50665
|
+
}
|
|
50666
|
+
function siteRuntime(registry, prefix) {
|
|
50667
|
+
return `(function () {
|
|
50668
|
+
'use strict';
|
|
50669
|
+
var P = ${embedJson(prefix)};
|
|
50670
|
+
var R = ${embedJson(registry)};
|
|
50671
|
+
var ON = P + '-on';
|
|
50672
|
+
var CLOSED = P + '-closed';
|
|
50673
|
+
var NAV_ACTIVE = P + '-nav-link-active';
|
|
50674
|
+
var site = document.querySelector('.' + P + '-site');
|
|
50675
|
+
if (!site) return;
|
|
50676
|
+
|
|
50677
|
+
var screens = {};
|
|
50678
|
+
var order = [];
|
|
50679
|
+
var shellOf = {};
|
|
50680
|
+
var hosts = site.querySelectorAll('[data-screen]');
|
|
50681
|
+
|
|
50682
|
+
function shellFor(node) {
|
|
50683
|
+
var el = node.parentNode;
|
|
50684
|
+
while (el && el !== site) {
|
|
50685
|
+
if (el.classList && el.classList.contains(P + '-shell')) return el;
|
|
50686
|
+
el = el.parentNode;
|
|
50687
|
+
}
|
|
50688
|
+
return null;
|
|
50689
|
+
}
|
|
50690
|
+
|
|
50691
|
+
for (var i = 0; i < hosts.length; i++) {
|
|
50692
|
+
var key = hosts[i].getAttribute('data-screen');
|
|
50693
|
+
if (!Object.prototype.hasOwnProperty.call(screens, key)) {
|
|
50694
|
+
screens[key] = hosts[i];
|
|
50695
|
+
order.push(key);
|
|
50696
|
+
shellOf[key] = shellFor(hosts[i]);
|
|
50697
|
+
}
|
|
50698
|
+
}
|
|
50699
|
+
var shells = site.querySelectorAll('.' + P + '-shell');
|
|
50700
|
+
|
|
50701
|
+
function isChrome(el) {
|
|
50702
|
+
return !(el.closest && el.closest('[data-screen]'));
|
|
50703
|
+
}
|
|
50704
|
+
|
|
50705
|
+
function scopeOf(el) {
|
|
50706
|
+
return (el && el.getAttribute(${embedJson(ID_SCOPE_ATTR)})) || '';
|
|
50707
|
+
}
|
|
50708
|
+
|
|
50709
|
+
function idSelector(id) {
|
|
50710
|
+
return '[id="' + String(id).replace(/["\\\\]/g, '\\\\$&') + '"]';
|
|
50711
|
+
}
|
|
50712
|
+
|
|
50713
|
+
function resolve(target) {
|
|
50714
|
+
if (target === null || target === undefined) return null;
|
|
50715
|
+
var name = String(target).trim();
|
|
50716
|
+
if (name === '') return null;
|
|
50717
|
+
if (Object.prototype.hasOwnProperty.call(R.names, name)) return String(R.names[name]);
|
|
50718
|
+
return Object.prototype.hasOwnProperty.call(screens, name) ? name : null;
|
|
50719
|
+
}
|
|
50720
|
+
|
|
50721
|
+
function overlayFor(key, id) {
|
|
50722
|
+
if (!id) return null;
|
|
50723
|
+
var screen = screens[key];
|
|
50724
|
+
if (screen) {
|
|
50725
|
+
var own = screen.querySelector(idSelector(scopeOf(screen) + id));
|
|
50726
|
+
if (own) return own;
|
|
50727
|
+
}
|
|
50728
|
+
var shell = shellOf[key];
|
|
50729
|
+
if (shell) {
|
|
50730
|
+
var candidates = shell.querySelectorAll(idSelector(scopeOf(shell) + id));
|
|
50731
|
+
for (var i = 0; i < candidates.length; i++) {
|
|
50732
|
+
if (isChrome(candidates[i])) return candidates[i];
|
|
50733
|
+
}
|
|
50734
|
+
}
|
|
50735
|
+
return null;
|
|
50736
|
+
}
|
|
50737
|
+
|
|
50738
|
+
function triggersFor(key) {
|
|
50739
|
+
var selector = '[data-opens],[data-toggles]';
|
|
50740
|
+
var found = [];
|
|
50741
|
+
var screen = screens[key];
|
|
50742
|
+
var i;
|
|
50743
|
+
if (screen) {
|
|
50744
|
+
var own = screen.querySelectorAll(selector);
|
|
50745
|
+
for (i = 0; i < own.length; i++) found.push(own[i]);
|
|
50746
|
+
}
|
|
50747
|
+
var shell = shellOf[key];
|
|
50748
|
+
if (shell) {
|
|
50749
|
+
var chrome = shell.querySelectorAll(selector);
|
|
50750
|
+
for (i = 0; i < chrome.length; i++) {
|
|
50751
|
+
if (isChrome(chrome[i])) found.push(chrome[i]);
|
|
50752
|
+
}
|
|
50753
|
+
}
|
|
50754
|
+
return found;
|
|
50755
|
+
}
|
|
50756
|
+
|
|
50757
|
+
function closeOverlays(key) {
|
|
50758
|
+
var triggers = triggersFor(key);
|
|
50759
|
+
for (var i = 0; i < triggers.length; i++) {
|
|
50760
|
+
var id = triggers[i].getAttribute('data-opens') || triggers[i].getAttribute('data-toggles');
|
|
50761
|
+
var overlay = overlayFor(key, id);
|
|
50762
|
+
if (overlay) overlay.classList.add(CLOSED);
|
|
50763
|
+
}
|
|
50764
|
+
}
|
|
50765
|
+
|
|
50766
|
+
function markActive(key) {
|
|
50767
|
+
for (var i = 0; i < shells.length; i++) {
|
|
50768
|
+
var links = shells[i].querySelectorAll('[data-navigate]');
|
|
50769
|
+
for (var j = 0; j < links.length; j++) {
|
|
50770
|
+
if (!isChrome(links[j])) continue;
|
|
50771
|
+
if (resolve(links[j].getAttribute('data-navigate')) === key) {
|
|
50772
|
+
links[j].classList.add(NAV_ACTIVE);
|
|
50773
|
+
} else {
|
|
50774
|
+
links[j].classList.remove(NAV_ACTIVE);
|
|
50775
|
+
}
|
|
50776
|
+
}
|
|
50777
|
+
}
|
|
50778
|
+
}
|
|
50779
|
+
|
|
50780
|
+
var current = null;
|
|
50781
|
+
function show(key, writeFragment) {
|
|
50782
|
+
var screen = screens[key];
|
|
50783
|
+
if (!screen) return false;
|
|
50784
|
+
for (var i = 0; i < order.length; i++) {
|
|
50785
|
+
screens[order[i]].classList.toggle(ON, order[i] === key);
|
|
50786
|
+
}
|
|
50787
|
+
var shell = shellOf[key];
|
|
50788
|
+
for (var s = 0; s < shells.length; s++) shells[s].classList.toggle(ON, shells[s] === shell);
|
|
50789
|
+
site.setAttribute('data-current-screen', key);
|
|
50790
|
+
current = key;
|
|
50791
|
+
closeOverlays(key);
|
|
50792
|
+
markActive(key);
|
|
50793
|
+
if (writeFragment) {
|
|
50794
|
+
var fragment = R.fragments[Number(key)] || key;
|
|
50795
|
+
if (location.hash.slice(1) !== fragment) location.hash = fragment;
|
|
50796
|
+
}
|
|
50797
|
+
return true;
|
|
50798
|
+
}
|
|
50799
|
+
|
|
50800
|
+
function fromFragment() {
|
|
50801
|
+
var raw = location.hash.slice(1);
|
|
50802
|
+
if (raw === '') return null;
|
|
50803
|
+
try { raw = decodeURIComponent(raw); } catch (e) { /* keep the raw fragment */ }
|
|
50804
|
+
return resolve(raw);
|
|
50805
|
+
}
|
|
50806
|
+
|
|
50807
|
+
document.addEventListener('click', function (event) {
|
|
50808
|
+
var target = event.target;
|
|
50809
|
+
var mover = target.closest ? target.closest('[data-navigate]') : null;
|
|
50810
|
+
if (mover) {
|
|
50811
|
+
var destination = resolve(mover.getAttribute('data-navigate'));
|
|
50812
|
+
if (destination !== null) {
|
|
50813
|
+
event.preventDefault();
|
|
50814
|
+
show(destination, true);
|
|
50815
|
+
return;
|
|
50816
|
+
}
|
|
50817
|
+
}
|
|
50818
|
+
|
|
50819
|
+
var opener = target.closest ? target.closest('[data-opens]') : null;
|
|
50820
|
+
if (opener) {
|
|
50821
|
+
var opened = overlayFor(current, opener.getAttribute('data-opens'));
|
|
50822
|
+
if (opened) {
|
|
50823
|
+
event.preventDefault();
|
|
50824
|
+
opened.classList.remove(CLOSED);
|
|
50825
|
+
return;
|
|
50826
|
+
}
|
|
50827
|
+
}
|
|
50828
|
+
|
|
50829
|
+
var toggler = target.closest ? target.closest('[data-toggles]') : null;
|
|
50830
|
+
if (toggler) {
|
|
50831
|
+
var toggled = overlayFor(current, toggler.getAttribute('data-toggles'));
|
|
50832
|
+
if (toggled) {
|
|
50833
|
+
event.preventDefault();
|
|
50834
|
+
toggled.classList.toggle(CLOSED);
|
|
50835
|
+
return;
|
|
50836
|
+
}
|
|
50837
|
+
}
|
|
50838
|
+
|
|
50839
|
+
var actor = target.closest ? target.closest('[data-action]') : null;
|
|
50840
|
+
if (actor) {
|
|
50841
|
+
var action = (actor.getAttribute('data-action') || '').trim();
|
|
50842
|
+
if (action === 'close' || action === 'back') {
|
|
50843
|
+
event.preventDefault();
|
|
50844
|
+
closeOverlays(current);
|
|
50845
|
+
return;
|
|
50846
|
+
}
|
|
50847
|
+
}
|
|
50848
|
+
|
|
50849
|
+
if (target.classList && target.classList.contains(P + '-modal-backdrop')) {
|
|
50850
|
+
target.classList.add(CLOSED);
|
|
50851
|
+
}
|
|
50852
|
+
var link = target.closest ? target.closest('a[href]') : null;
|
|
50853
|
+
if (link && link.getAttribute('href') === '#') event.preventDefault();
|
|
50854
|
+
});
|
|
50855
|
+
|
|
50856
|
+
document.addEventListener('keydown', function (event) {
|
|
50857
|
+
if (event.key === 'Escape' && current !== null) closeOverlays(current);
|
|
50858
|
+
});
|
|
50859
|
+
window.addEventListener('hashchange', function () {
|
|
50860
|
+
var key = fromFragment();
|
|
50861
|
+
if (key !== null) show(key, false);
|
|
50862
|
+
});
|
|
50863
|
+
|
|
50864
|
+
var start = fromFragment();
|
|
50865
|
+
if (start === null) start = String(R.entry);
|
|
50866
|
+
if (!show(start, false)) show(String(R.entry), false);
|
|
50867
|
+
})();`;
|
|
50868
|
+
}
|
|
50869
|
+
|
|
50870
|
+
// src/renderer/site/index.ts
|
|
50871
|
+
var DEFAULT_PREFIX2 = "wf";
|
|
50872
|
+
var screenScope = (index) => `s${index}-`;
|
|
50873
|
+
var shellScope = (index) => `l${index}-`;
|
|
50874
|
+
function escapeAttr2(value) {
|
|
50875
|
+
return value.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
50876
|
+
}
|
|
50877
|
+
function escapeText(value) {
|
|
50878
|
+
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
50879
|
+
}
|
|
50880
|
+
function attrs(pairs) {
|
|
50881
|
+
return pairs.filter((pair) => pair[1] !== void 0).map(([name, value]) => ` ${name}="${escapeAttr2(value)}"`).join("");
|
|
50882
|
+
}
|
|
50883
|
+
function renderHostedScreen(screen, shell, make, prefix) {
|
|
50884
|
+
const { width, height } = resolvePageDimensions(screen.page);
|
|
50885
|
+
const conflict = width !== shell.width || height !== shell.height ? `${width}x${height}` : void 0;
|
|
50886
|
+
const scope = screenScope(screen.index);
|
|
50887
|
+
const marks = attrs([
|
|
50888
|
+
["data-screen", String(screen.index)],
|
|
50889
|
+
["data-screen-name", screen.name],
|
|
50890
|
+
[ID_SCOPE_ATTR, scope],
|
|
50891
|
+
["data-wf-viewport-conflict", conflict]
|
|
50892
|
+
]);
|
|
50893
|
+
const content = make(scope).renderFragment(screen.page.children);
|
|
50894
|
+
return `<div class="${prefix}-screen"${marks}>
|
|
50895
|
+
${content}
|
|
50896
|
+
</div>`;
|
|
50897
|
+
}
|
|
50898
|
+
function renderStandaloneScreen(screen, make, prefix) {
|
|
50899
|
+
const scope = screenScope(screen.index);
|
|
50900
|
+
const marks = attrs([
|
|
50901
|
+
["data-screen", String(screen.index)],
|
|
50902
|
+
["data-screen-name", screen.name],
|
|
50903
|
+
[ID_SCOPE_ATTR, scope],
|
|
50904
|
+
["data-wf-uses-unresolved", screen.miss?.uses],
|
|
50905
|
+
["data-wf-uses-reason", screen.miss?.reason]
|
|
50906
|
+
]);
|
|
50907
|
+
const page = make(scope).render({ type: "Document", children: [screen.page] }).html;
|
|
50908
|
+
return `<div class="${prefix}-screen"${marks}>
|
|
50909
|
+
${page}
|
|
50910
|
+
</div>`;
|
|
50911
|
+
}
|
|
50912
|
+
function renderShell(shell, index, make, prefix) {
|
|
50913
|
+
const hosted = shell.screens.map((screen) => renderHostedScreen(screen, shell, make, prefix)).join("\n");
|
|
50914
|
+
const scope = shellScope(index);
|
|
50915
|
+
const style = `position: relative; width: ${shell.width}px; height: ${shell.height}px; overflow: hidden`;
|
|
50916
|
+
const marks = attrs([
|
|
50917
|
+
["data-layout", shell.name],
|
|
50918
|
+
[ID_SCOPE_ATTR, scope],
|
|
50919
|
+
["data-viewport-width", String(shell.width)],
|
|
50920
|
+
["data-viewport-height", String(shell.height)]
|
|
50921
|
+
]);
|
|
50922
|
+
const body = make(scope).renderFragment(shell.layout.children, hosted);
|
|
50923
|
+
return `<div class="${prefix}-page ${prefix}-shell" style="${style}"${marks}>
|
|
50924
|
+
${body}
|
|
50925
|
+
</div>`;
|
|
50926
|
+
}
|
|
50927
|
+
function resolveEntry(model, options) {
|
|
50928
|
+
const fallback = Math.max(model.entry, 0);
|
|
50929
|
+
const requested = options.entry?.trim();
|
|
50930
|
+
if (!requested) return { index: fallback };
|
|
50931
|
+
const index = model.names.get(requested);
|
|
50932
|
+
return index === void 0 ? { index: fallback, unresolved: requested } : { index };
|
|
50933
|
+
}
|
|
50934
|
+
function resolveTitle(model, options, entry) {
|
|
50935
|
+
if (options.title !== void 0) return options.title;
|
|
50936
|
+
const title = model.screens[entry]?.page.title?.trim();
|
|
50937
|
+
return title || "Wireframe";
|
|
50938
|
+
}
|
|
50939
|
+
function renderSite(document, options = {}) {
|
|
50940
|
+
const prefix = options.classPrefix ?? DEFAULT_PREFIX2;
|
|
50941
|
+
const model = buildSiteModel(document);
|
|
50942
|
+
const make = (idScope) => new HtmlRenderer({
|
|
50943
|
+
theme: options.theme,
|
|
50944
|
+
classPrefix: prefix,
|
|
50945
|
+
background: options.background,
|
|
50946
|
+
includeStyles: false,
|
|
50947
|
+
idScope
|
|
50948
|
+
});
|
|
50949
|
+
const shells = model.shells.map((shell, index) => renderShell(shell, index, make, prefix)).join("\n");
|
|
50950
|
+
const standalone = model.screens.filter((screen) => screen.shell === void 0).map((screen) => renderStandaloneScreen(screen, make, prefix)).join("\n");
|
|
50951
|
+
const entry = resolveEntry(model, options);
|
|
50952
|
+
const theme = options.theme === "dark" ? darkTheme : defaultTheme;
|
|
50953
|
+
const css = generateStyles(theme, prefix) + generateSiteStyles(prefix);
|
|
50954
|
+
const runtime = siteRuntime(
|
|
50955
|
+
{
|
|
50956
|
+
names: Object.fromEntries(model.names),
|
|
50957
|
+
fragments: model.screens.map((screen) => screen.name ?? String(screen.index)),
|
|
50958
|
+
entry: entry.index
|
|
50959
|
+
},
|
|
50960
|
+
prefix
|
|
50961
|
+
);
|
|
50962
|
+
const body = [shells, standalone].filter((part) => part.length > 0).join("\n");
|
|
50963
|
+
const siteAttrs = attrs([
|
|
50964
|
+
["data-screen-count", String(model.screens.length)],
|
|
50965
|
+
["data-shell-count", String(model.shells.length)],
|
|
50966
|
+
["data-wf-entry-unresolved", entry.unresolved]
|
|
50967
|
+
]);
|
|
50968
|
+
return `<!DOCTYPE html>
|
|
50969
|
+
<html lang="en">
|
|
50970
|
+
<head>
|
|
50971
|
+
<meta charset="UTF-8">
|
|
50972
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
50973
|
+
<title>${escapeText(resolveTitle(model, options, entry.index))}</title>
|
|
50974
|
+
<style>
|
|
50975
|
+
html, body {
|
|
50976
|
+
margin: 0;
|
|
50977
|
+
padding: 0;
|
|
50978
|
+
min-height: 100vh;
|
|
50979
|
+
background: #f4f4f5;
|
|
50980
|
+
}
|
|
50981
|
+
body {
|
|
50982
|
+
padding: 24px;
|
|
50983
|
+
box-sizing: border-box;
|
|
50984
|
+
}
|
|
50985
|
+
${css}
|
|
50986
|
+
</style>
|
|
50987
|
+
</head>
|
|
50988
|
+
<body>
|
|
50989
|
+
<div class="${prefix}-site"${siteAttrs}>
|
|
50990
|
+
${body}
|
|
50991
|
+
</div>
|
|
50992
|
+
<script>
|
|
50993
|
+
${runtime}
|
|
50994
|
+
</script>
|
|
50995
|
+
</body>
|
|
50996
|
+
</html>`;
|
|
50997
|
+
}
|
|
50998
|
+
|
|
50469
50999
|
// src/renderer/index.ts
|
|
50470
51000
|
function render(document, options = {}) {
|
|
50471
|
-
const isMultiPage = document.
|
|
51001
|
+
const isMultiPage = documentPages(document).length > 1;
|
|
50472
51002
|
if (isMultiPage) {
|
|
50473
51003
|
const result = renderCanvas(document, options);
|
|
50474
51004
|
return { html: result.html, css: result.css };
|
|
@@ -50479,7 +51009,7 @@ function render(document, options = {}) {
|
|
|
50479
51009
|
function renderToHtml(document, options = {}) {
|
|
50480
51010
|
const { html, css } = render(document, options);
|
|
50481
51011
|
const prefix = options.classPrefix ?? "wf";
|
|
50482
|
-
const isMultiPage = document.
|
|
51012
|
+
const isMultiPage = documentPages(document).length > 1;
|
|
50483
51013
|
const bodyAlign = isMultiPage ? "justify-content: flex-start;\n align-items: flex-start;" : "justify-content: center;\n align-items: center;";
|
|
50484
51014
|
return `<!DOCTYPE html>
|
|
50485
51015
|
<html lang="en">
|
|
@@ -50518,7 +51048,7 @@ ${html}
|
|
|
50518
51048
|
</html>`;
|
|
50519
51049
|
}
|
|
50520
51050
|
function renderToSvg(document, options = {}) {
|
|
50521
|
-
const isMultiPage = document.
|
|
51051
|
+
const isMultiPage = documentPages(document).length > 1;
|
|
50522
51052
|
let width = options.width ?? 800;
|
|
50523
51053
|
let height = options.height ?? 600;
|
|
50524
51054
|
let html;
|
|
@@ -50534,7 +51064,7 @@ function renderToSvg(document, options = {}) {
|
|
|
50534
51064
|
html = canvas.html;
|
|
50535
51065
|
css = canvas.css;
|
|
50536
51066
|
} else {
|
|
50537
|
-
const firstPage = document
|
|
51067
|
+
const firstPage = documentPages(document)[0];
|
|
50538
51068
|
if (firstPage && options.width === void 0 && options.height === void 0) {
|
|
50539
51069
|
const dims = resolvePageDimensions(firstPage);
|
|
50540
51070
|
width = dims.width;
|
|
@@ -50571,6 +51101,7 @@ ${css}
|
|
|
50571
51101
|
// Annotate the CommonJS export names for ESM import in node:
|
|
50572
51102
|
0 && (module.exports = {
|
|
50573
51103
|
HtmlRenderer,
|
|
51104
|
+
buildSiteModel,
|
|
50574
51105
|
createHtmlRenderer,
|
|
50575
51106
|
darkTheme,
|
|
50576
51107
|
defaultTheme,
|
|
@@ -50584,6 +51115,7 @@ ${css}
|
|
|
50584
51115
|
renderCanvas,
|
|
50585
51116
|
renderIconSvg,
|
|
50586
51117
|
renderPage,
|
|
51118
|
+
renderSite,
|
|
50587
51119
|
renderToHtml,
|
|
50588
51120
|
renderToSvg,
|
|
50589
51121
|
renderUnknownIconSvg,
|