@wireweave/core 3.1.0-beta.0 → 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/renderer.js CHANGED
@@ -1,3 +1,27 @@
1
+ // src/ast/guards.ts
2
+ function hasChildren(node) {
3
+ return "children" in node && Array.isArray(node.children);
4
+ }
5
+
6
+ // src/ast/utils.ts
7
+ function walk(node, callback, parent, depth = 0) {
8
+ const result = callback(node, parent, depth);
9
+ if (result === false) {
10
+ return;
11
+ }
12
+ if (hasChildren(node)) {
13
+ for (const child of node.children) {
14
+ walk(child, callback, node, depth + 1);
15
+ }
16
+ }
17
+ }
18
+ function documentPages(document) {
19
+ return document.children.filter((child) => child.type === "Page");
20
+ }
21
+ function documentDefinitions(document) {
22
+ return document.children.filter((child) => child.type === "Layout");
23
+ }
24
+
1
25
  // src/renderer/types.ts
2
26
  var defaultTheme = {
3
27
  colors: {
@@ -115,8 +139,14 @@ function generateContainerStyles(prefix) {
115
139
  font-weight: 600;
116
140
  }
117
141
 
142
+ /* Board-scoped: absolute (not fixed) so the drawer pins to its own page /
143
+ canvas board \u2014 the nearest positioned ancestor (.wf-page is position:relative,
144
+ .wf-canvas-board is position:absolute) \u2014 instead of the browser viewport.
145
+ Matches the modal backdrop's scoping and keeps the fixed-layout invariant:
146
+ with position:fixed a drawer in a multi-page canvas escapes to the viewport
147
+ top-left, overlapping other boards (see no-responsive.md). */
118
148
  .${prefix}-drawer {
119
- position: fixed;
149
+ position: absolute;
120
150
  background: var(--${prefix}-bg);
121
151
  border: 1px solid var(--${prefix}-border);
122
152
  box-shadow: var(--${prefix}-shadow-xl);
@@ -1945,7 +1975,9 @@ var DEFAULT_OPTIONS = {
1945
1975
  scale: 1,
1946
1976
  includeStyles: true,
1947
1977
  minify: false,
1948
- classPrefix: "wf"
1978
+ classPrefix: "wf",
1979
+ sourceAnchors: false,
1980
+ idScope: ""
1949
1981
  };
1950
1982
  var BaseRenderer = class {
1951
1983
  context;
@@ -1984,7 +2016,7 @@ var BaseRenderer = class {
1984
2016
  * Render a complete wireframe document
1985
2017
  */
1986
2018
  renderDocument(document) {
1987
- const pages = document.children.map((page) => this.renderPage(page)).join(this.context.options.minify ? "" : "\n");
2019
+ const pages = documentPages(document).map((page) => this.renderPage(page)).join(this.context.options.minify ? "" : "\n");
1988
2020
  return pages;
1989
2021
  }
1990
2022
  /**
@@ -2025,6 +2057,10 @@ var BaseRenderer = class {
2025
2057
  };
2026
2058
  return text.replace(/[&<>"']/g, (char) => escapeMap[char] || char);
2027
2059
  }
2060
+ /** Return the DOM id for an authored id under this renderer's scope. */
2061
+ scopedId(id) {
2062
+ return this.context.options.idScope + id;
2063
+ }
2028
2064
  /**
2029
2065
  * Build a CSS class string from an array of class names
2030
2066
  */
@@ -2034,9 +2070,9 @@ var BaseRenderer = class {
2034
2070
  /**
2035
2071
  * Build HTML attributes string
2036
2072
  */
2037
- buildAttrsString(attrs) {
2073
+ buildAttrsString(attrs2) {
2038
2074
  const parts = [];
2039
- for (const [key, value] of Object.entries(attrs)) {
2075
+ for (const [key, value] of Object.entries(attrs2)) {
2040
2076
  if (value === void 0 || value === false) {
2041
2077
  continue;
2042
2078
  }
@@ -2116,6 +2152,52 @@ function resolveViewport(viewport, device) {
2116
2152
  return DEFAULT_VIEWPORT;
2117
2153
  }
2118
2154
 
2155
+ // src/ast/anchor-path.ts
2156
+ var ANCHOR_PATH_ATTR = "data-wf-path";
2157
+ var ANCHOR_LOC_ATTR = "data-wf-loc";
2158
+ var ANCHOR_CONTAINER_TYPES = /* @__PURE__ */ new Set([
2159
+ "Page",
2160
+ "Header",
2161
+ "Main",
2162
+ "Footer",
2163
+ "Sidebar",
2164
+ "Section",
2165
+ "Row",
2166
+ "Col",
2167
+ "Stack",
2168
+ "Relative",
2169
+ "Card",
2170
+ "Modal",
2171
+ "Drawer",
2172
+ "Accordion",
2173
+ "Tooltip",
2174
+ "Popover"
2175
+ ]);
2176
+ function anchorChildNodes(node) {
2177
+ if (!ANCHOR_CONTAINER_TYPES.has(node.type)) return [];
2178
+ const children = node.children;
2179
+ return Array.isArray(children) ? children : [];
2180
+ }
2181
+ function formatAnchorLoc(loc) {
2182
+ return `${loc.start.offset}-${loc.end.offset}`;
2183
+ }
2184
+ function walkAnchorPaths(doc, visit, pageIndexBase = 0) {
2185
+ documentPages(doc).forEach((page, i) => {
2186
+ visitAnchorNode(page, String(pageIndexBase + i), visit);
2187
+ });
2188
+ }
2189
+ function visitAnchorNode(node, path, visit) {
2190
+ visit(node, path);
2191
+ anchorChildNodes(node).forEach((child, i) => {
2192
+ visitAnchorNode(child, `${path}.${i}`, visit);
2193
+ });
2194
+ }
2195
+ function buildAnchorPathMap(doc, pageIndexBase = 0) {
2196
+ const map = /* @__PURE__ */ new Map();
2197
+ walkAnchorPaths(doc, (node, path) => map.set(node, path), pageIndexBase);
2198
+ return map;
2199
+ }
2200
+
2119
2201
  // src/renderer/html/components.ts
2120
2202
  function buildClassString(classes) {
2121
2203
  return classes.filter(Boolean).join(" ");
@@ -2311,7 +2393,7 @@ function renderModal(node, ctx) {
2311
2393
  const classes = ctx.buildClassString([`${ctx.prefix}-modal`, ...ctx.getCommonClasses(node)]);
2312
2394
  const styles = ctx.buildCommonStyles(node);
2313
2395
  const styleAttr = styles ? ` style="${styles}"` : "";
2314
- const idAttr = node.id ? ` id="${ctx.escapeHtml(node.id)}"` : "";
2396
+ const idAttr = node.id ? ` id="${ctx.escapeHtml(ctx.scopedId(node.id))}"` : "";
2315
2397
  const title = node.title ? `<h2 class="${ctx.prefix}-title">${ctx.escapeHtml(node.title)}</h2>
2316
2398
  ` : "";
2317
2399
  const children = ctx.renderChildren(node.children);
@@ -2330,7 +2412,7 @@ function renderDrawer(node, ctx) {
2330
2412
  ]);
2331
2413
  const styles = ctx.buildCommonStyles(node);
2332
2414
  const styleAttr = styles ? ` style="${styles}"` : "";
2333
- const idAttr = node.id ? ` id="${ctx.escapeHtml(node.id)}"` : "";
2415
+ const idAttr = node.id ? ` id="${ctx.escapeHtml(ctx.scopedId(node.id))}"` : "";
2334
2416
  const title = node.title ? `<h2 class="${ctx.prefix}-title">${ctx.escapeHtml(node.title)}</h2>
2335
2417
  ` : "";
2336
2418
  const children = ctx.renderChildren(node.children);
@@ -2414,7 +2496,7 @@ function renderLink(node, ctx) {
2414
2496
  const classes = ctx.buildClassString([`${ctx.prefix}-link`, ...ctx.getCommonClasses(node)]);
2415
2497
  const styles = ctx.buildCommonStyles(node);
2416
2498
  const styleAttr = styles ? ` style="${styles}"` : "";
2417
- const attrs = {
2499
+ const attrs2 = {
2418
2500
  class: classes,
2419
2501
  href: node.href || node.navigate || "#",
2420
2502
  // Interactive attributes
@@ -2424,10 +2506,10 @@ function renderLink(node, ctx) {
2424
2506
  "data-action": node.action
2425
2507
  };
2426
2508
  if (node.external) {
2427
- attrs.target = "_blank";
2428
- attrs.rel = "noopener noreferrer";
2509
+ attrs2.target = "_blank";
2510
+ attrs2.rel = "noopener noreferrer";
2429
2511
  }
2430
- return `<a${ctx.buildAttrsString(attrs)}${styleAttr}>${ctx.escapeHtml(node.content)}</a>`;
2512
+ return `<a${ctx.buildAttrsString(attrs2)}${styleAttr}>${ctx.escapeHtml(node.content)}</a>`;
2431
2513
  }
2432
2514
 
2433
2515
  // src/icons/lucide-icons.ts
@@ -48822,8 +48904,13 @@ var iconAliases = {
48822
48904
  close: "x",
48823
48905
  menu: "menu",
48824
48906
  hamburger: "menu",
48825
- dots: "more-horizontal",
48826
- "dots-vertical": "more-vertical",
48907
+ // Lucide renamed the overflow/kebab-menu glyphs to `ellipsis` /
48908
+ // `ellipsis-vertical`; map the legacy `more-*` names (and the `dots-*`
48909
+ // shorthands) onto the real keys so none of them dead-end.
48910
+ "more-horizontal": "ellipsis",
48911
+ "more-vertical": "ellipsis-vertical",
48912
+ dots: "ellipsis",
48913
+ "dots-vertical": "ellipsis-vertical",
48827
48914
  cog: "settings",
48828
48915
  gear: "settings"
48829
48916
  };
@@ -48844,12 +48931,18 @@ function getIconData(name) {
48844
48931
  return void 0;
48845
48932
  }
48846
48933
  function renderIconSvg(data, _size = 24, strokeWidth = 2, className = "", styleAttr = "") {
48847
- const elements = data.map(([tag, attrs]) => {
48848
- const attrStr = Object.entries(attrs).map(([key, value]) => `${key}="${value}"`).join(" ");
48934
+ const elements = data.map(([tag, attrs2]) => {
48935
+ const attrStr = Object.entries(attrs2).map(([key, value]) => `${key}="${value}"`).join(" ");
48849
48936
  return `<${tag} ${attrStr} />`;
48850
48937
  }).join("");
48851
48938
  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>`;
48852
48939
  }
48940
+ function renderUnknownIconSvg(className = "", size = 24, styleAttr = "") {
48941
+ return `<svg class="${className}" width="${size}" height="${size}" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"${styleAttr}>
48942
+ <circle cx="12" cy="12" r="10" stroke="currentColor" stroke-width="2" stroke-dasharray="4 2" fill="none" opacity="0.5"/>
48943
+ <text x="12" y="16" text-anchor="middle" font-size="10" fill="currentColor" opacity="0.7">?</text>
48944
+ </svg>`;
48945
+ }
48853
48946
 
48854
48947
  // src/renderer/html/renderers/button.ts
48855
48948
  function renderButton(node, ctx) {
@@ -48872,9 +48965,12 @@ function renderButton(node, ctx) {
48872
48965
  const sizeStyle = sizeResolved.style || "";
48873
48966
  const combinedStyles = baseStyles && sizeStyle ? `${baseStyles}; ${sizeStyle}` : baseStyles || sizeStyle;
48874
48967
  const styleAttr = combinedStyles ? ` style="${combinedStyles}"` : "";
48875
- const attrs = {
48968
+ const accessibleName = node.aria ?? node["aria-label"];
48969
+ const attrs2 = {
48876
48970
  class: classes,
48877
48971
  disabled: node.disabled,
48972
+ "aria-label": accessibleName,
48973
+ title: node.title,
48878
48974
  // Interactive attributes
48879
48975
  "data-navigate": node.navigate,
48880
48976
  "data-opens": node.opens,
@@ -48887,12 +48983,12 @@ function renderButton(node, ctx) {
48887
48983
  if (iconData) {
48888
48984
  icon = renderIconSvg(iconData, 16, 2, `${ctx.prefix}-icon`);
48889
48985
  } else {
48890
- icon = `<span class="${ctx.prefix}-icon">[${ctx.escapeHtml(node.icon)}]</span>`;
48986
+ icon = `<span class="${ctx.prefix}-icon" title="Unknown icon: ${ctx.escapeHtml(node.icon)}">${renderUnknownIconSvg(`${ctx.prefix}-icon`, 16)}</span>`;
48891
48987
  }
48892
48988
  }
48893
48989
  const loading = node.loading ? `<span class="${ctx.prefix}-spinner ${ctx.prefix}-spinner-sm"></span>` : "";
48894
48990
  const content = isIconOnly ? "" : ctx.escapeHtml(node.content);
48895
- return `<button${ctx.buildAttrsString(attrs)}${styleAttr}>${loading}${icon}${content}</button>`;
48991
+ return `<button${ctx.buildAttrsString(attrs2)}${styleAttr}>${loading}${icon}${content}</button>`;
48896
48992
  }
48897
48993
 
48898
48994
  // src/renderer/html/renderers/feedback.ts
@@ -48955,7 +49051,7 @@ function renderInput(node, ctx) {
48955
49051
  ]);
48956
49052
  const styles = ctx.buildCommonStyles(node);
48957
49053
  const styleAttr = styles ? ` style="${styles}"` : "";
48958
- const attrs = {
49054
+ const attrs2 = {
48959
49055
  class: inputClasses,
48960
49056
  type: node.inputType || "text",
48961
49057
  placeholder: node.placeholder,
@@ -48964,14 +49060,14 @@ function renderInput(node, ctx) {
48964
49060
  required: node.required,
48965
49061
  readonly: node.readonly
48966
49062
  };
48967
- const inputElement = `<input${ctx.buildAttrsString(attrs)} />`;
49063
+ const inputElement = `<input${ctx.buildAttrsString(attrs2)} />`;
48968
49064
  if (node.icon) {
48969
49065
  const iconData = getIconData(node.icon);
48970
49066
  let iconHtml;
48971
49067
  if (iconData) {
48972
49068
  iconHtml = renderIconSvg(iconData, 16, 2, `${ctx.prefix}-input-icon`);
48973
49069
  } else {
48974
- iconHtml = `<span class="${ctx.prefix}-input-icon">[${ctx.escapeHtml(node.icon)}]</span>`;
49070
+ iconHtml = `<span class="${ctx.prefix}-input-icon" title="Unknown icon: ${ctx.escapeHtml(node.icon)}">${renderUnknownIconSvg(`${ctx.prefix}-input-icon`, 16)}</span>`;
48975
49071
  }
48976
49072
  const wrapperClasses = ctx.buildClassString([`${ctx.prefix}-input-wrapper`]);
48977
49073
  const wrapper = `<div class="${wrapperClasses}"${styleAttr}>${iconHtml}${inputElement}</div>`;
@@ -48982,7 +49078,7 @@ ${wrapper}`;
48982
49078
  }
48983
49079
  return wrapper;
48984
49080
  }
48985
- const input = `<input${ctx.buildAttrsString(attrs)}${styleAttr} />`;
49081
+ const input = `<input${ctx.buildAttrsString(attrs2)}${styleAttr} />`;
48986
49082
  const shouldShowLabel2 = node.label && !(node.label === "Label" && node.placeholder);
48987
49083
  if (shouldShowLabel2) {
48988
49084
  return `<label class="${ctx.prefix}-input-label">${ctx.escapeHtml(node.label)}</label>
@@ -48994,14 +49090,14 @@ function renderTextarea(node, ctx) {
48994
49090
  const classes = ctx.buildClassString([`${ctx.prefix}-input`, ...ctx.getCommonClasses(node)]);
48995
49091
  const styles = ctx.buildCommonStyles(node);
48996
49092
  const styleAttr = styles ? ` style="${styles}"` : "";
48997
- const attrs = {
49093
+ const attrs2 = {
48998
49094
  class: classes,
48999
49095
  placeholder: node.placeholder,
49000
49096
  disabled: node.disabled,
49001
49097
  required: node.required,
49002
49098
  rows: node.rows?.toString()
49003
49099
  };
49004
- const textarea = `<textarea${ctx.buildAttrsString(attrs)}${styleAttr}>${ctx.escapeHtml(node.value || "")}</textarea>`;
49100
+ const textarea = `<textarea${ctx.buildAttrsString(attrs2)}${styleAttr}>${ctx.escapeHtml(node.value || "")}</textarea>`;
49005
49101
  if (node.label) {
49006
49102
  return `<label class="${ctx.prefix}-input-label">${ctx.escapeHtml(node.label)}</label>
49007
49103
  ${textarea}`;
@@ -49012,7 +49108,7 @@ function renderSelect(node, ctx) {
49012
49108
  const classes = ctx.buildClassString([`${ctx.prefix}-input`, ...ctx.getCommonClasses(node)]);
49013
49109
  const styles = ctx.buildCommonStyles(node);
49014
49110
  const styleAttr = styles ? ` style="${styles}"` : "";
49015
- const attrs = {
49111
+ const attrs2 = {
49016
49112
  class: classes,
49017
49113
  disabled: node.disabled,
49018
49114
  required: node.required
@@ -49029,7 +49125,7 @@ function renderSelect(node, ctx) {
49029
49125
  const placeholderSelected = hasSelectedValue ? "" : ' selected="selected"';
49030
49126
  const placeholder = node.placeholder ? `<option value="" disabled="disabled"${placeholderSelected}>${ctx.escapeHtml(node.placeholder)}</option>
49031
49127
  ` : "";
49032
- const select = `<select${ctx.buildAttrsString(attrs)}${styleAttr}>
49128
+ const select = `<select${ctx.buildAttrsString(attrs2)}${styleAttr}>
49033
49129
  ${placeholder}${options}
49034
49130
  </select>`;
49035
49131
  if (node.label) {
@@ -49041,12 +49137,12 @@ ${select}`;
49041
49137
  function renderCheckbox(node, ctx) {
49042
49138
  const styles = ctx.buildCommonStyles(node);
49043
49139
  const styleAttr = styles ? ` style="${styles}"` : "";
49044
- const attrs = {
49140
+ const attrs2 = {
49045
49141
  type: "checkbox",
49046
49142
  checked: node.checked,
49047
49143
  disabled: node.disabled
49048
49144
  };
49049
- const checkbox = `<input${ctx.buildAttrsString(attrs)} />`;
49145
+ const checkbox = `<input${ctx.buildAttrsString(attrs2)} />`;
49050
49146
  if (node.label) {
49051
49147
  return `<label class="${ctx.prefix}-checkbox"${styleAttr}>${checkbox}<span>${ctx.escapeHtml(node.label)}</span></label>`;
49052
49148
  }
@@ -49055,13 +49151,13 @@ function renderCheckbox(node, ctx) {
49055
49151
  function renderRadio(node, ctx) {
49056
49152
  const styles = ctx.buildCommonStyles(node);
49057
49153
  const styleAttr = styles ? ` style="${styles}"` : "";
49058
- const attrs = {
49154
+ const attrs2 = {
49059
49155
  type: "radio",
49060
49156
  name: node.name,
49061
49157
  checked: node.checked,
49062
49158
  disabled: node.disabled
49063
49159
  };
49064
- const radio = `<input${ctx.buildAttrsString(attrs)} />`;
49160
+ const radio = `<input${ctx.buildAttrsString(attrs2)} />`;
49065
49161
  if (node.label) {
49066
49162
  return `<label class="${ctx.prefix}-radio"${styleAttr}>${radio}<span>${ctx.escapeHtml(node.label)}</span></label>`;
49067
49163
  }
@@ -49071,13 +49167,13 @@ function renderSwitch(node, ctx) {
49071
49167
  const classes = ctx.buildClassString([`${ctx.prefix}-switch`, ...ctx.getCommonClasses(node)]);
49072
49168
  const styles = ctx.buildCommonStyles(node);
49073
49169
  const styleAttr = styles ? ` style="${styles}"` : "";
49074
- const attrs = {
49170
+ const attrs2 = {
49075
49171
  type: "checkbox",
49076
49172
  role: "switch",
49077
49173
  checked: node.checked,
49078
49174
  disabled: node.disabled
49079
49175
  };
49080
- const switchEl = `<input${ctx.buildAttrsString(attrs)} />`;
49176
+ const switchEl = `<input${ctx.buildAttrsString(attrs2)} />`;
49081
49177
  if (node.label) {
49082
49178
  return `<label class="${classes}"${styleAttr}>${switchEl} ${ctx.escapeHtml(node.label)}</label>`;
49083
49179
  }
@@ -49087,7 +49183,7 @@ function renderSlider(node, ctx) {
49087
49183
  const classes = ctx.buildClassString([`${ctx.prefix}-slider`, ...ctx.getCommonClasses(node)]);
49088
49184
  const styles = ctx.buildCommonStyles(node);
49089
49185
  const styleAttr = styles ? ` style="${styles}"` : "";
49090
- const attrs = {
49186
+ const attrs2 = {
49091
49187
  class: classes,
49092
49188
  type: "range",
49093
49189
  min: node.min?.toString(),
@@ -49096,7 +49192,7 @@ function renderSlider(node, ctx) {
49096
49192
  value: node.value?.toString(),
49097
49193
  disabled: node.disabled
49098
49194
  };
49099
- const slider = `<input${ctx.buildAttrsString(attrs)}${styleAttr} />`;
49195
+ const slider = `<input${ctx.buildAttrsString(attrs2)}${styleAttr} />`;
49100
49196
  if (node.label) {
49101
49197
  return `<label class="${ctx.prefix}-input-label">${ctx.escapeHtml(node.label)}</label>
49102
49198
  ${slider}`;
@@ -49118,14 +49214,14 @@ function renderImage(node, ctx) {
49118
49214
  const styles = ctx.buildCommonStyles(node);
49119
49215
  const styleAttr = styles ? ` style="${styles}"` : "";
49120
49216
  if (node.src) {
49121
- const attrs = {
49217
+ const attrs2 = {
49122
49218
  class: classes,
49123
49219
  src: node.src,
49124
49220
  alt: node.alt || "Image",
49125
49221
  ...buildInteractiveAttrs2(node)
49126
49222
  };
49127
49223
  const imgStyleAttr = styles ? `; ${styles}` : "";
49128
- return `<img${ctx.buildAttrsString(attrs)}${imgStyleAttr ? ` style="${imgStyleAttr.slice(2)}"` : ""} />`;
49224
+ return `<img${ctx.buildAttrsString(attrs2)}${imgStyleAttr ? ` style="${imgStyleAttr.slice(2)}"` : ""} />`;
49129
49225
  }
49130
49226
  const label = node.alt || "Image";
49131
49227
  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>`;
@@ -49236,10 +49332,10 @@ function renderIcon(node, ctx) {
49236
49332
  }
49237
49333
  const size = sizeResolved.style?.match(/(\d+)px/)?.[1] || "24";
49238
49334
  const sizeNum = parseInt(size, 10);
49239
- const placeholderSvg = `<svg class="${ctx.prefix}-icon ${sizeResolved.className || ""}" width="${sizeNum}" height="${sizeNum}" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
49240
- <circle cx="12" cy="12" r="10" stroke="currentColor" stroke-width="2" stroke-dasharray="4 2" fill="none" opacity="0.5"/>
49241
- <text x="12" y="16" text-anchor="middle" font-size="10" fill="currentColor" opacity="0.7">?</text>
49242
- </svg>`;
49335
+ const placeholderSvg = renderUnknownIconSvg(
49336
+ `${ctx.prefix}-icon ${sizeResolved.className || ""}`,
49337
+ sizeNum
49338
+ );
49243
49339
  const wrapperStyleAttr = baseStyles ? ` style="${baseStyles}"` : "";
49244
49340
  return `<span class="${wrapperClasses}"${wrapperStyleAttr}${interactiveAttrStr} aria-hidden="true" title="Unknown icon: ${ctx.escapeHtml(node.name)}">${placeholderSvg}</span>`;
49245
49341
  }
@@ -49644,6 +49740,10 @@ function renderAnnotationItem(node, ctx) {
49644
49740
  }
49645
49741
 
49646
49742
  // src/renderer/html/index.ts
49743
+ function injectAnchorAttrs(html, path, loc) {
49744
+ const attrs2 = loc ? ` ${ANCHOR_PATH_ATTR}="${path}" ${ANCHOR_LOC_ATTR}="${formatAnchorLoc(loc)}"` : ` ${ANCHOR_PATH_ATTR}="${path}"`;
49745
+ return html.replace(/<([a-zA-Z][a-zA-Z0-9-]*)/, (match) => `${match}${attrs2}`);
49746
+ }
49647
49747
  var SPACING_TOKENS = {
49648
49748
  0: "0px",
49649
49749
  1: "4px",
@@ -49686,10 +49786,38 @@ var HtmlRenderer = class extends BaseRenderer {
49686
49786
  * Node type to renderer method mapping
49687
49787
  */
49688
49788
  nodeRenderers;
49689
- constructor(options = {}) {
49789
+ /**
49790
+ * Node → anchor-path map for the document currently being rendered. Non-null
49791
+ * only while rendering with `sourceAnchors` enabled.
49792
+ */
49793
+ pathMap = null;
49794
+ /**
49795
+ * Base index added to page anchor paths. Non-zero when a page is rendered in
49796
+ * isolation (canvas per-page composition) but must keep its true document
49797
+ * index in the anchor scheme.
49798
+ */
49799
+ pageIndexBase;
49800
+ /** Content supplied by a site renderer for the next layout slot. */
49801
+ slotContent = null;
49802
+ constructor(options = {}, pageIndexBase = 0) {
49690
49803
  super(options);
49804
+ this.pageIndexBase = pageIndexBase;
49691
49805
  this.nodeRenderers = this.createNodeRenderers();
49692
49806
  }
49807
+ /**
49808
+ * Render a document, building the anchor-path map first when anchors are
49809
+ * enabled so `renderNode` / `renderPage` can inject each node's path.
49810
+ */
49811
+ render(document) {
49812
+ if (this.context.options.sourceAnchors) {
49813
+ this.pathMap = buildAnchorPathMap(document, this.pageIndexBase);
49814
+ }
49815
+ try {
49816
+ return super.render(document);
49817
+ } finally {
49818
+ this.pathMap = null;
49819
+ }
49820
+ }
49693
49821
  /**
49694
49822
  * Get render context for external renderer functions
49695
49823
  */
@@ -49697,6 +49825,7 @@ var HtmlRenderer = class extends BaseRenderer {
49697
49825
  return {
49698
49826
  prefix: this.prefix,
49699
49827
  escapeHtml: this.escapeHtml.bind(this),
49828
+ scopedId: this.scopedId.bind(this),
49700
49829
  buildClassString: this.buildClassString.bind(this),
49701
49830
  buildAttrsString: this.buildAttrsString.bind(this),
49702
49831
  buildCommonStyles: this.buildCommonStyles.bind(this),
@@ -49774,6 +49903,7 @@ var HtmlRenderer = class extends BaseRenderer {
49774
49903
  Breadcrumb: (node) => this.renderBreadcrumb(node),
49775
49904
  // Other
49776
49905
  Divider: (node) => this.renderDivider(node),
49906
+ Slot: () => this.renderSlot(),
49777
49907
  // Annotation nodes
49778
49908
  Marker: (node) => this.renderMarker(node),
49779
49909
  Annotations: (node) => this.renderAnnotations(node),
@@ -49818,9 +49948,15 @@ var HtmlRenderer = class extends BaseRenderer {
49818
49948
  }
49819
49949
  const combinedStyle = commonStyles ? `${viewportStyle}; ${commonStyles}` : viewportStyle;
49820
49950
  const dataAttrs = `data-viewport-width="${viewport.width}" data-viewport-height="${viewport.height}" data-viewport-label="${viewport.label}"`;
49821
- const pageDiv = `<div class="${classes}" style="${combinedStyle}" ${dataAttrs}>
49951
+ let pageDiv = `<div class="${classes}" style="${combinedStyle}" ${dataAttrs}>
49822
49952
  ${title}${uiContent}
49823
49953
  </div>`;
49954
+ if (this.pathMap) {
49955
+ const path = this.pathMap.get(node);
49956
+ if (path !== void 0) {
49957
+ pageDiv = injectAnchorAttrs(pageDiv, path, node.loc);
49958
+ }
49959
+ }
49824
49960
  if (annotationChildren.length > 0) {
49825
49961
  const annotationsContent = this.renderChildren(annotationChildren);
49826
49962
  return `<div class="${this.prefix}-page-wrapper" style="width: ${viewport.width}px">
@@ -49835,10 +49971,33 @@ ${annotationsContent}
49835
49971
  */
49836
49972
  renderNode(node) {
49837
49973
  const renderer = this.nodeRenderers[node.type];
49838
- if (renderer) {
49839
- return renderer(node);
49974
+ const html = renderer ? renderer(node) : `<!-- Unknown node type: ${node.type} -->`;
49975
+ if (this.pathMap && node.type !== "Page") {
49976
+ const path = this.pathMap.get(node);
49977
+ if (path !== void 0) {
49978
+ return injectAnchorAttrs(html, path, node.loc);
49979
+ }
49980
+ }
49981
+ return html;
49982
+ }
49983
+ /** Render the first slot with the supplied page content, if any. */
49984
+ renderSlot() {
49985
+ const content = this.slotContent;
49986
+ this.slotContent = null;
49987
+ const open = `<div class="${this.prefix}-slot">`;
49988
+ return content === null ? `${open}</div>` : `${open}
49989
+ ${content}
49990
+ </div>`;
49991
+ }
49992
+ /** Render nodes without adding a page frame, optionally filling a slot. */
49993
+ renderFragment(nodes, slotContent = null) {
49994
+ const previous = this.slotContent;
49995
+ this.slotContent = slotContent;
49996
+ try {
49997
+ return this.renderChildren(nodes);
49998
+ } finally {
49999
+ this.slotContent = previous;
49840
50000
  }
49841
- return `<!-- Unknown node type: ${node.type} -->`;
49842
50001
  }
49843
50002
  /**
49844
50003
  * Render children nodes
@@ -50280,7 +50439,8 @@ function renderCanvas(doc, options = {}) {
50280
50439
  const includeStyles = options.includeStyles !== false;
50281
50440
  const theme = options.theme === "dark" ? darkTheme : defaultTheme;
50282
50441
  const css = includeStyles ? generateStyles(theme, prefix) : "";
50283
- if (doc.children.length === 0) {
50442
+ const pages = documentPages(doc);
50443
+ if (pages.length === 0) {
50284
50444
  return {
50285
50445
  html: `<div class="${prefix}-canvas" data-empty="true"></div>`,
50286
50446
  css,
@@ -50288,9 +50448,9 @@ function renderCanvas(doc, options = {}) {
50288
50448
  height: 0
50289
50449
  };
50290
50450
  }
50291
- const { placed, width, height } = layoutCanvas(doc.children, gap);
50292
- const pageRenderer = new HtmlRenderer({ ...options, includeStyles: false });
50293
- const boards = placed.map((p) => {
50451
+ const { placed, width, height } = layoutCanvas(pages, gap);
50452
+ const boards = placed.map((p, pageIndex) => {
50453
+ const pageRenderer = new HtmlRenderer({ ...options, includeStyles: false }, pageIndex);
50294
50454
  const { html: pageHtml } = pageRenderer.render({
50295
50455
  type: "Document",
50296
50456
  children: [p.page]
@@ -50316,9 +50476,484 @@ function escapeAttr(s) {
50316
50476
  return s.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;");
50317
50477
  }
50318
50478
 
50479
+ // src/renderer/site/model.ts
50480
+ function pageId(page) {
50481
+ const id = page.id?.trim();
50482
+ return id && id.length > 0 ? id : void 0;
50483
+ }
50484
+ function pageTitle(page) {
50485
+ const title = page.title?.trim();
50486
+ return title && title.length > 0 ? title : void 0;
50487
+ }
50488
+ function hasSlot(layout) {
50489
+ for (const child of layout.children) {
50490
+ let found = false;
50491
+ walk(child, (node) => {
50492
+ if (node.type === "Slot") found = true;
50493
+ return !found;
50494
+ });
50495
+ if (found) return true;
50496
+ }
50497
+ return false;
50498
+ }
50499
+ function layoutsByName(doc) {
50500
+ const layouts = /* @__PURE__ */ new Map();
50501
+ for (const definition of documentDefinitions(doc)) {
50502
+ const name = definition.name.trim();
50503
+ if (name.length > 0 && !layouts.has(name)) layouts.set(name, definition);
50504
+ }
50505
+ return layouts;
50506
+ }
50507
+ function resolveShell(page, layouts) {
50508
+ const uses = page.uses?.trim();
50509
+ if (!uses) return void 0;
50510
+ const layout = layouts.get(uses);
50511
+ if (!layout) return { miss: { uses, reason: "unknown-layout" } };
50512
+ if (!hasSlot(layout)) return { miss: { uses, reason: "slotless-layout" } };
50513
+ return { layout, name: uses };
50514
+ }
50515
+ function buildSiteModel(doc) {
50516
+ const screens = documentPages(doc).map((page, index) => ({ index, page }));
50517
+ const layouts = layoutsByName(doc);
50518
+ const shells = [];
50519
+ const shellByName = /* @__PURE__ */ new Map();
50520
+ for (const screen of screens) {
50521
+ const resolved = resolveShell(screen.page, layouts);
50522
+ if (!resolved) continue;
50523
+ if ("miss" in resolved) {
50524
+ screen.miss = resolved.miss;
50525
+ continue;
50526
+ }
50527
+ let shell = shellByName.get(resolved.name);
50528
+ if (!shell) {
50529
+ const { width, height } = resolvePageDimensions(screen.page);
50530
+ shell = { name: resolved.name, layout: resolved.layout, screens: [], width, height };
50531
+ shellByName.set(resolved.name, shell);
50532
+ shells.push(shell);
50533
+ }
50534
+ shell.screens.push(screen);
50535
+ screen.shell = shell.name;
50536
+ }
50537
+ const names = /* @__PURE__ */ new Map();
50538
+ for (const screen of screens) {
50539
+ const title = pageTitle(screen.page);
50540
+ if (title !== void 0 && !names.has(title)) names.set(title, screen.index);
50541
+ }
50542
+ for (const screen of screens) {
50543
+ const id = pageId(screen.page);
50544
+ if (id === void 0) continue;
50545
+ const owner = names.get(id);
50546
+ if (owner === void 0 || pageId(screens[owner].page) !== id) {
50547
+ names.set(id, screen.index);
50548
+ }
50549
+ }
50550
+ for (const screen of screens) {
50551
+ screen.name = [pageId(screen.page), pageTitle(screen.page)].find(
50552
+ (name) => name !== void 0 && names.get(name) === screen.index
50553
+ );
50554
+ }
50555
+ return { screens, shells, names, entry: screens.length > 0 ? 0 : -1 };
50556
+ }
50557
+
50558
+ // src/renderer/site/styles.ts
50559
+ function generateSiteStyles(prefix) {
50560
+ return `
50561
+ /* ===== Site composition (renderSite) ===== */
50562
+
50563
+ .${prefix}-site {
50564
+ display: flex;
50565
+ justify-content: center;
50566
+ align-items: flex-start;
50567
+ }
50568
+
50569
+ .${prefix}-site > .${prefix}-shell,
50570
+ .${prefix}-site > .${prefix}-screen {
50571
+ display: none;
50572
+ }
50573
+
50574
+ .${prefix}-site > .${prefix}-shell.${prefix}-on {
50575
+ display: flex;
50576
+ flex-direction: column;
50577
+ }
50578
+
50579
+ .${prefix}-site > .${prefix}-screen.${prefix}-on {
50580
+ display: block;
50581
+ }
50582
+
50583
+ .${prefix}-site .${prefix}-page {
50584
+ overflow: auto !important;
50585
+ }
50586
+
50587
+ .${prefix}-site .${prefix}-slot {
50588
+ display: flex;
50589
+ flex-direction: column;
50590
+ flex: 1;
50591
+ min-height: 0;
50592
+ }
50593
+
50594
+ .${prefix}-site .${prefix}-slot > .${prefix}-screen {
50595
+ display: none;
50596
+ }
50597
+
50598
+ .${prefix}-site .${prefix}-slot > .${prefix}-screen.${prefix}-on {
50599
+ display: flex;
50600
+ flex-direction: column;
50601
+ flex: 1;
50602
+ min-height: 0;
50603
+ }
50604
+
50605
+ .${prefix}-site .${prefix}-screen > .${prefix}-col {
50606
+ flex: 1;
50607
+ min-height: 0;
50608
+ }
50609
+
50610
+ .${prefix}-site .${prefix}-closed {
50611
+ display: none;
50612
+ }
50613
+ `;
50614
+ }
50615
+
50616
+ // src/renderer/site/runtime.ts
50617
+ var ID_SCOPE_ATTR = "data-id-scope";
50618
+ function embedJson(value) {
50619
+ return JSON.stringify(value).replace(/</g, "\\u003C");
50620
+ }
50621
+ function siteRuntime(registry, prefix) {
50622
+ return `(function () {
50623
+ 'use strict';
50624
+ var P = ${embedJson(prefix)};
50625
+ var R = ${embedJson(registry)};
50626
+ var ON = P + '-on';
50627
+ var CLOSED = P + '-closed';
50628
+ var NAV_ACTIVE = P + '-nav-link-active';
50629
+ var site = document.querySelector('.' + P + '-site');
50630
+ if (!site) return;
50631
+
50632
+ var screens = {};
50633
+ var order = [];
50634
+ var shellOf = {};
50635
+ var hosts = site.querySelectorAll('[data-screen]');
50636
+
50637
+ function shellFor(node) {
50638
+ var el = node.parentNode;
50639
+ while (el && el !== site) {
50640
+ if (el.classList && el.classList.contains(P + '-shell')) return el;
50641
+ el = el.parentNode;
50642
+ }
50643
+ return null;
50644
+ }
50645
+
50646
+ for (var i = 0; i < hosts.length; i++) {
50647
+ var key = hosts[i].getAttribute('data-screen');
50648
+ if (!Object.prototype.hasOwnProperty.call(screens, key)) {
50649
+ screens[key] = hosts[i];
50650
+ order.push(key);
50651
+ shellOf[key] = shellFor(hosts[i]);
50652
+ }
50653
+ }
50654
+ var shells = site.querySelectorAll('.' + P + '-shell');
50655
+
50656
+ function isChrome(el) {
50657
+ return !(el.closest && el.closest('[data-screen]'));
50658
+ }
50659
+
50660
+ function scopeOf(el) {
50661
+ return (el && el.getAttribute(${embedJson(ID_SCOPE_ATTR)})) || '';
50662
+ }
50663
+
50664
+ function idSelector(id) {
50665
+ return '[id="' + String(id).replace(/["\\\\]/g, '\\\\$&') + '"]';
50666
+ }
50667
+
50668
+ function resolve(target) {
50669
+ if (target === null || target === undefined) return null;
50670
+ var name = String(target).trim();
50671
+ if (name === '') return null;
50672
+ if (Object.prototype.hasOwnProperty.call(R.names, name)) return String(R.names[name]);
50673
+ return Object.prototype.hasOwnProperty.call(screens, name) ? name : null;
50674
+ }
50675
+
50676
+ function overlayFor(key, id) {
50677
+ if (!id) return null;
50678
+ var screen = screens[key];
50679
+ if (screen) {
50680
+ var own = screen.querySelector(idSelector(scopeOf(screen) + id));
50681
+ if (own) return own;
50682
+ }
50683
+ var shell = shellOf[key];
50684
+ if (shell) {
50685
+ var candidates = shell.querySelectorAll(idSelector(scopeOf(shell) + id));
50686
+ for (var i = 0; i < candidates.length; i++) {
50687
+ if (isChrome(candidates[i])) return candidates[i];
50688
+ }
50689
+ }
50690
+ return null;
50691
+ }
50692
+
50693
+ function triggersFor(key) {
50694
+ var selector = '[data-opens],[data-toggles]';
50695
+ var found = [];
50696
+ var screen = screens[key];
50697
+ var i;
50698
+ if (screen) {
50699
+ var own = screen.querySelectorAll(selector);
50700
+ for (i = 0; i < own.length; i++) found.push(own[i]);
50701
+ }
50702
+ var shell = shellOf[key];
50703
+ if (shell) {
50704
+ var chrome = shell.querySelectorAll(selector);
50705
+ for (i = 0; i < chrome.length; i++) {
50706
+ if (isChrome(chrome[i])) found.push(chrome[i]);
50707
+ }
50708
+ }
50709
+ return found;
50710
+ }
50711
+
50712
+ function closeOverlays(key) {
50713
+ var triggers = triggersFor(key);
50714
+ for (var i = 0; i < triggers.length; i++) {
50715
+ var id = triggers[i].getAttribute('data-opens') || triggers[i].getAttribute('data-toggles');
50716
+ var overlay = overlayFor(key, id);
50717
+ if (overlay) overlay.classList.add(CLOSED);
50718
+ }
50719
+ }
50720
+
50721
+ function markActive(key) {
50722
+ for (var i = 0; i < shells.length; i++) {
50723
+ var links = shells[i].querySelectorAll('[data-navigate]');
50724
+ for (var j = 0; j < links.length; j++) {
50725
+ if (!isChrome(links[j])) continue;
50726
+ if (resolve(links[j].getAttribute('data-navigate')) === key) {
50727
+ links[j].classList.add(NAV_ACTIVE);
50728
+ } else {
50729
+ links[j].classList.remove(NAV_ACTIVE);
50730
+ }
50731
+ }
50732
+ }
50733
+ }
50734
+
50735
+ var current = null;
50736
+ function show(key, writeFragment) {
50737
+ var screen = screens[key];
50738
+ if (!screen) return false;
50739
+ for (var i = 0; i < order.length; i++) {
50740
+ screens[order[i]].classList.toggle(ON, order[i] === key);
50741
+ }
50742
+ var shell = shellOf[key];
50743
+ for (var s = 0; s < shells.length; s++) shells[s].classList.toggle(ON, shells[s] === shell);
50744
+ site.setAttribute('data-current-screen', key);
50745
+ current = key;
50746
+ closeOverlays(key);
50747
+ markActive(key);
50748
+ if (writeFragment) {
50749
+ var fragment = R.fragments[Number(key)] || key;
50750
+ if (location.hash.slice(1) !== fragment) location.hash = fragment;
50751
+ }
50752
+ return true;
50753
+ }
50754
+
50755
+ function fromFragment() {
50756
+ var raw = location.hash.slice(1);
50757
+ if (raw === '') return null;
50758
+ try { raw = decodeURIComponent(raw); } catch (e) { /* keep the raw fragment */ }
50759
+ return resolve(raw);
50760
+ }
50761
+
50762
+ document.addEventListener('click', function (event) {
50763
+ var target = event.target;
50764
+ var mover = target.closest ? target.closest('[data-navigate]') : null;
50765
+ if (mover) {
50766
+ var destination = resolve(mover.getAttribute('data-navigate'));
50767
+ if (destination !== null) {
50768
+ event.preventDefault();
50769
+ show(destination, true);
50770
+ return;
50771
+ }
50772
+ }
50773
+
50774
+ var opener = target.closest ? target.closest('[data-opens]') : null;
50775
+ if (opener) {
50776
+ var opened = overlayFor(current, opener.getAttribute('data-opens'));
50777
+ if (opened) {
50778
+ event.preventDefault();
50779
+ opened.classList.remove(CLOSED);
50780
+ return;
50781
+ }
50782
+ }
50783
+
50784
+ var toggler = target.closest ? target.closest('[data-toggles]') : null;
50785
+ if (toggler) {
50786
+ var toggled = overlayFor(current, toggler.getAttribute('data-toggles'));
50787
+ if (toggled) {
50788
+ event.preventDefault();
50789
+ toggled.classList.toggle(CLOSED);
50790
+ return;
50791
+ }
50792
+ }
50793
+
50794
+ var actor = target.closest ? target.closest('[data-action]') : null;
50795
+ if (actor) {
50796
+ var action = (actor.getAttribute('data-action') || '').trim();
50797
+ if (action === 'close' || action === 'back') {
50798
+ event.preventDefault();
50799
+ closeOverlays(current);
50800
+ return;
50801
+ }
50802
+ }
50803
+
50804
+ if (target.classList && target.classList.contains(P + '-modal-backdrop')) {
50805
+ target.classList.add(CLOSED);
50806
+ }
50807
+ var link = target.closest ? target.closest('a[href]') : null;
50808
+ if (link && link.getAttribute('href') === '#') event.preventDefault();
50809
+ });
50810
+
50811
+ document.addEventListener('keydown', function (event) {
50812
+ if (event.key === 'Escape' && current !== null) closeOverlays(current);
50813
+ });
50814
+ window.addEventListener('hashchange', function () {
50815
+ var key = fromFragment();
50816
+ if (key !== null) show(key, false);
50817
+ });
50818
+
50819
+ var start = fromFragment();
50820
+ if (start === null) start = String(R.entry);
50821
+ if (!show(start, false)) show(String(R.entry), false);
50822
+ })();`;
50823
+ }
50824
+
50825
+ // src/renderer/site/index.ts
50826
+ var DEFAULT_PREFIX2 = "wf";
50827
+ var screenScope = (index) => `s${index}-`;
50828
+ var shellScope = (index) => `l${index}-`;
50829
+ function escapeAttr2(value) {
50830
+ return value.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
50831
+ }
50832
+ function escapeText(value) {
50833
+ return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
50834
+ }
50835
+ function attrs(pairs) {
50836
+ return pairs.filter((pair) => pair[1] !== void 0).map(([name, value]) => ` ${name}="${escapeAttr2(value)}"`).join("");
50837
+ }
50838
+ function renderHostedScreen(screen, shell, make, prefix) {
50839
+ const { width, height } = resolvePageDimensions(screen.page);
50840
+ const conflict = width !== shell.width || height !== shell.height ? `${width}x${height}` : void 0;
50841
+ const scope = screenScope(screen.index);
50842
+ const marks = attrs([
50843
+ ["data-screen", String(screen.index)],
50844
+ ["data-screen-name", screen.name],
50845
+ [ID_SCOPE_ATTR, scope],
50846
+ ["data-wf-viewport-conflict", conflict]
50847
+ ]);
50848
+ const content = make(scope).renderFragment(screen.page.children);
50849
+ return `<div class="${prefix}-screen"${marks}>
50850
+ ${content}
50851
+ </div>`;
50852
+ }
50853
+ function renderStandaloneScreen(screen, make, prefix) {
50854
+ const scope = screenScope(screen.index);
50855
+ const marks = attrs([
50856
+ ["data-screen", String(screen.index)],
50857
+ ["data-screen-name", screen.name],
50858
+ [ID_SCOPE_ATTR, scope],
50859
+ ["data-wf-uses-unresolved", screen.miss?.uses],
50860
+ ["data-wf-uses-reason", screen.miss?.reason]
50861
+ ]);
50862
+ const page = make(scope).render({ type: "Document", children: [screen.page] }).html;
50863
+ return `<div class="${prefix}-screen"${marks}>
50864
+ ${page}
50865
+ </div>`;
50866
+ }
50867
+ function renderShell(shell, index, make, prefix) {
50868
+ const hosted = shell.screens.map((screen) => renderHostedScreen(screen, shell, make, prefix)).join("\n");
50869
+ const scope = shellScope(index);
50870
+ const style = `position: relative; width: ${shell.width}px; height: ${shell.height}px; overflow: hidden`;
50871
+ const marks = attrs([
50872
+ ["data-layout", shell.name],
50873
+ [ID_SCOPE_ATTR, scope],
50874
+ ["data-viewport-width", String(shell.width)],
50875
+ ["data-viewport-height", String(shell.height)]
50876
+ ]);
50877
+ const body = make(scope).renderFragment(shell.layout.children, hosted);
50878
+ return `<div class="${prefix}-page ${prefix}-shell" style="${style}"${marks}>
50879
+ ${body}
50880
+ </div>`;
50881
+ }
50882
+ function resolveEntry(model, options) {
50883
+ const fallback = Math.max(model.entry, 0);
50884
+ const requested = options.entry?.trim();
50885
+ if (!requested) return { index: fallback };
50886
+ const index = model.names.get(requested);
50887
+ return index === void 0 ? { index: fallback, unresolved: requested } : { index };
50888
+ }
50889
+ function resolveTitle(model, options, entry) {
50890
+ if (options.title !== void 0) return options.title;
50891
+ const title = model.screens[entry]?.page.title?.trim();
50892
+ return title || "Wireframe";
50893
+ }
50894
+ function renderSite(document, options = {}) {
50895
+ const prefix = options.classPrefix ?? DEFAULT_PREFIX2;
50896
+ const model = buildSiteModel(document);
50897
+ const make = (idScope) => new HtmlRenderer({
50898
+ theme: options.theme,
50899
+ classPrefix: prefix,
50900
+ background: options.background,
50901
+ includeStyles: false,
50902
+ idScope
50903
+ });
50904
+ const shells = model.shells.map((shell, index) => renderShell(shell, index, make, prefix)).join("\n");
50905
+ const standalone = model.screens.filter((screen) => screen.shell === void 0).map((screen) => renderStandaloneScreen(screen, make, prefix)).join("\n");
50906
+ const entry = resolveEntry(model, options);
50907
+ const theme = options.theme === "dark" ? darkTheme : defaultTheme;
50908
+ const css = generateStyles(theme, prefix) + generateSiteStyles(prefix);
50909
+ const runtime = siteRuntime(
50910
+ {
50911
+ names: Object.fromEntries(model.names),
50912
+ fragments: model.screens.map((screen) => screen.name ?? String(screen.index)),
50913
+ entry: entry.index
50914
+ },
50915
+ prefix
50916
+ );
50917
+ const body = [shells, standalone].filter((part) => part.length > 0).join("\n");
50918
+ const siteAttrs = attrs([
50919
+ ["data-screen-count", String(model.screens.length)],
50920
+ ["data-shell-count", String(model.shells.length)],
50921
+ ["data-wf-entry-unresolved", entry.unresolved]
50922
+ ]);
50923
+ return `<!DOCTYPE html>
50924
+ <html lang="en">
50925
+ <head>
50926
+ <meta charset="UTF-8">
50927
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
50928
+ <title>${escapeText(resolveTitle(model, options, entry.index))}</title>
50929
+ <style>
50930
+ html, body {
50931
+ margin: 0;
50932
+ padding: 0;
50933
+ min-height: 100vh;
50934
+ background: #f4f4f5;
50935
+ }
50936
+ body {
50937
+ padding: 24px;
50938
+ box-sizing: border-box;
50939
+ }
50940
+ ${css}
50941
+ </style>
50942
+ </head>
50943
+ <body>
50944
+ <div class="${prefix}-site"${siteAttrs}>
50945
+ ${body}
50946
+ </div>
50947
+ <script>
50948
+ ${runtime}
50949
+ </script>
50950
+ </body>
50951
+ </html>`;
50952
+ }
50953
+
50319
50954
  // src/renderer/index.ts
50320
50955
  function render(document, options = {}) {
50321
- const isMultiPage = document.children.length > 1;
50956
+ const isMultiPage = documentPages(document).length > 1;
50322
50957
  if (isMultiPage) {
50323
50958
  const result = renderCanvas(document, options);
50324
50959
  return { html: result.html, css: result.css };
@@ -50328,7 +50963,8 @@ function render(document, options = {}) {
50328
50963
  }
50329
50964
  function renderToHtml(document, options = {}) {
50330
50965
  const { html, css } = render(document, options);
50331
- const isMultiPage = document.children.length > 1;
50966
+ const prefix = options.classPrefix ?? "wf";
50967
+ const isMultiPage = documentPages(document).length > 1;
50332
50968
  const bodyAlign = isMultiPage ? "justify-content: flex-start;\n align-items: flex-start;" : "justify-content: center;\n align-items: center;";
50333
50969
  return `<!DOCTYPE html>
50334
50970
  <html lang="en">
@@ -50350,6 +50986,14 @@ body {
50350
50986
  padding: 24px;
50351
50987
  box-sizing: border-box;
50352
50988
  }
50989
+ /* Fixed-layout invariant: the multi-page canvas is a flex item of <body> and
50990
+ must keep its intrinsic size when the viewport is narrower than the canvas.
50991
+ Without flex-shrink:0 the flex item shrinks and the boards reflow \u2014 the same
50992
+ defect class as .wf-page (see no-responsive.md). Single pages already carry
50993
+ flex-shrink:0 via generateStyles; the canvas wrapper needs it here. */
50994
+ .${prefix}-canvas {
50995
+ flex-shrink: 0;
50996
+ }
50353
50997
  ${css}
50354
50998
  </style>
50355
50999
  </head>
@@ -50359,7 +51003,7 @@ ${html}
50359
51003
  </html>`;
50360
51004
  }
50361
51005
  function renderToSvg(document, options = {}) {
50362
- const isMultiPage = document.children.length > 1;
51006
+ const isMultiPage = documentPages(document).length > 1;
50363
51007
  let width = options.width ?? 800;
50364
51008
  let height = options.height ?? 600;
50365
51009
  let html;
@@ -50375,7 +51019,7 @@ function renderToSvg(document, options = {}) {
50375
51019
  html = canvas.html;
50376
51020
  css = canvas.css;
50377
51021
  } else {
50378
- const firstPage = document.children[0];
51022
+ const firstPage = documentPages(document)[0];
50379
51023
  if (firstPage && options.width === void 0 && options.height === void 0) {
50380
51024
  const dims = resolvePageDimensions(firstPage);
50381
51025
  width = dims.width;
@@ -50411,6 +51055,7 @@ ${css}
50411
51055
  }
50412
51056
  export {
50413
51057
  HtmlRenderer,
51058
+ buildSiteModel,
50414
51059
  createHtmlRenderer,
50415
51060
  darkTheme,
50416
51061
  defaultTheme,
@@ -50424,8 +51069,10 @@ export {
50424
51069
  renderCanvas,
50425
51070
  renderIconSvg,
50426
51071
  renderPage,
51072
+ renderSite,
50427
51073
  renderToHtml,
50428
51074
  renderToSvg,
51075
+ renderUnknownIconSvg,
50429
51076
  resolvePageDimensions
50430
51077
  };
50431
51078
  /**