@wireweave/core 3.0.1-beta.0 → 3.1.0-beta.1
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/README.md +80 -417
- package/dist/index.cjs +1010 -28
- package/dist/index.d.cts +370 -4
- package/dist/index.d.ts +370 -4
- package/dist/index.js +997 -28
- package/dist/parser.d.cts +1 -1
- package/dist/parser.d.ts +1 -1
- package/dist/renderer.cjs +139 -20
- package/dist/renderer.d.cts +33 -3
- package/dist/renderer.d.ts +33 -3
- package/dist/renderer.js +138 -20
- package/dist/{types-hEr_afgw.d.cts → types-BDbXDhTp.d.cts} +14 -1
- package/dist/{types-hEr_afgw.d.ts → types-BDbXDhTp.d.ts} +14 -1
- package/package.json +21 -21
package/dist/parser.d.cts
CHANGED
package/dist/parser.d.ts
CHANGED
package/dist/renderer.cjs
CHANGED
|
@@ -36,6 +36,7 @@ __export(renderer_exports, {
|
|
|
36
36
|
renderPage: () => renderPage,
|
|
37
37
|
renderToHtml: () => renderToHtml,
|
|
38
38
|
renderToSvg: () => renderToSvg,
|
|
39
|
+
renderUnknownIconSvg: () => renderUnknownIconSvg,
|
|
39
40
|
resolvePageDimensions: () => resolvePageDimensions
|
|
40
41
|
});
|
|
41
42
|
module.exports = __toCommonJS(renderer_exports);
|
|
@@ -157,8 +158,14 @@ function generateContainerStyles(prefix) {
|
|
|
157
158
|
font-weight: 600;
|
|
158
159
|
}
|
|
159
160
|
|
|
161
|
+
/* Board-scoped: absolute (not fixed) so the drawer pins to its own page /
|
|
162
|
+
canvas board \u2014 the nearest positioned ancestor (.wf-page is position:relative,
|
|
163
|
+
.wf-canvas-board is position:absolute) \u2014 instead of the browser viewport.
|
|
164
|
+
Matches the modal backdrop's scoping and keeps the fixed-layout invariant:
|
|
165
|
+
with position:fixed a drawer in a multi-page canvas escapes to the viewport
|
|
166
|
+
top-left, overlapping other boards (see no-responsive.md). */
|
|
160
167
|
.${prefix}-drawer {
|
|
161
|
-
position:
|
|
168
|
+
position: absolute;
|
|
162
169
|
background: var(--${prefix}-bg);
|
|
163
170
|
border: 1px solid var(--${prefix}-border);
|
|
164
171
|
box-shadow: var(--${prefix}-shadow-xl);
|
|
@@ -1987,7 +1994,8 @@ var DEFAULT_OPTIONS = {
|
|
|
1987
1994
|
scale: 1,
|
|
1988
1995
|
includeStyles: true,
|
|
1989
1996
|
minify: false,
|
|
1990
|
-
classPrefix: "wf"
|
|
1997
|
+
classPrefix: "wf",
|
|
1998
|
+
sourceAnchors: false
|
|
1991
1999
|
};
|
|
1992
2000
|
var BaseRenderer = class {
|
|
1993
2001
|
context;
|
|
@@ -2158,6 +2166,52 @@ function resolveViewport(viewport, device) {
|
|
|
2158
2166
|
return DEFAULT_VIEWPORT;
|
|
2159
2167
|
}
|
|
2160
2168
|
|
|
2169
|
+
// src/ast/anchor-path.ts
|
|
2170
|
+
var ANCHOR_PATH_ATTR = "data-wf-path";
|
|
2171
|
+
var ANCHOR_LOC_ATTR = "data-wf-loc";
|
|
2172
|
+
var ANCHOR_CONTAINER_TYPES = /* @__PURE__ */ new Set([
|
|
2173
|
+
"Page",
|
|
2174
|
+
"Header",
|
|
2175
|
+
"Main",
|
|
2176
|
+
"Footer",
|
|
2177
|
+
"Sidebar",
|
|
2178
|
+
"Section",
|
|
2179
|
+
"Row",
|
|
2180
|
+
"Col",
|
|
2181
|
+
"Stack",
|
|
2182
|
+
"Relative",
|
|
2183
|
+
"Card",
|
|
2184
|
+
"Modal",
|
|
2185
|
+
"Drawer",
|
|
2186
|
+
"Accordion",
|
|
2187
|
+
"Tooltip",
|
|
2188
|
+
"Popover"
|
|
2189
|
+
]);
|
|
2190
|
+
function anchorChildNodes(node) {
|
|
2191
|
+
if (!ANCHOR_CONTAINER_TYPES.has(node.type)) return [];
|
|
2192
|
+
const children = node.children;
|
|
2193
|
+
return Array.isArray(children) ? children : [];
|
|
2194
|
+
}
|
|
2195
|
+
function formatAnchorLoc(loc) {
|
|
2196
|
+
return `${loc.start.offset}-${loc.end.offset}`;
|
|
2197
|
+
}
|
|
2198
|
+
function walkAnchorPaths(doc, visit, pageIndexBase = 0) {
|
|
2199
|
+
doc.children.forEach((page, i) => {
|
|
2200
|
+
visitAnchorNode(page, String(pageIndexBase + i), visit);
|
|
2201
|
+
});
|
|
2202
|
+
}
|
|
2203
|
+
function visitAnchorNode(node, path, visit) {
|
|
2204
|
+
visit(node, path);
|
|
2205
|
+
anchorChildNodes(node).forEach((child, i) => {
|
|
2206
|
+
visitAnchorNode(child, `${path}.${i}`, visit);
|
|
2207
|
+
});
|
|
2208
|
+
}
|
|
2209
|
+
function buildAnchorPathMap(doc, pageIndexBase = 0) {
|
|
2210
|
+
const map = /* @__PURE__ */ new Map();
|
|
2211
|
+
walkAnchorPaths(doc, (node, path) => map.set(node, path), pageIndexBase);
|
|
2212
|
+
return map;
|
|
2213
|
+
}
|
|
2214
|
+
|
|
2161
2215
|
// src/renderer/html/components.ts
|
|
2162
2216
|
function buildClassString(classes) {
|
|
2163
2217
|
return classes.filter(Boolean).join(" ");
|
|
@@ -48864,8 +48918,13 @@ var iconAliases = {
|
|
|
48864
48918
|
close: "x",
|
|
48865
48919
|
menu: "menu",
|
|
48866
48920
|
hamburger: "menu",
|
|
48867
|
-
|
|
48868
|
-
|
|
48921
|
+
// Lucide renamed the overflow/kebab-menu glyphs to `ellipsis` /
|
|
48922
|
+
// `ellipsis-vertical`; map the legacy `more-*` names (and the `dots-*`
|
|
48923
|
+
// shorthands) onto the real keys so none of them dead-end.
|
|
48924
|
+
"more-horizontal": "ellipsis",
|
|
48925
|
+
"more-vertical": "ellipsis-vertical",
|
|
48926
|
+
dots: "ellipsis",
|
|
48927
|
+
"dots-vertical": "ellipsis-vertical",
|
|
48869
48928
|
cog: "settings",
|
|
48870
48929
|
gear: "settings"
|
|
48871
48930
|
};
|
|
@@ -48892,6 +48951,12 @@ function renderIconSvg(data, _size = 24, strokeWidth = 2, className = "", styleA
|
|
|
48892
48951
|
}).join("");
|
|
48893
48952
|
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>`;
|
|
48894
48953
|
}
|
|
48954
|
+
function renderUnknownIconSvg(className = "", size = 24, styleAttr = "") {
|
|
48955
|
+
return `<svg class="${className}" width="${size}" height="${size}" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"${styleAttr}>
|
|
48956
|
+
<circle cx="12" cy="12" r="10" stroke="currentColor" stroke-width="2" stroke-dasharray="4 2" fill="none" opacity="0.5"/>
|
|
48957
|
+
<text x="12" y="16" text-anchor="middle" font-size="10" fill="currentColor" opacity="0.7">?</text>
|
|
48958
|
+
</svg>`;
|
|
48959
|
+
}
|
|
48895
48960
|
|
|
48896
48961
|
// src/renderer/html/renderers/button.ts
|
|
48897
48962
|
function renderButton(node, ctx) {
|
|
@@ -48914,9 +48979,12 @@ function renderButton(node, ctx) {
|
|
|
48914
48979
|
const sizeStyle = sizeResolved.style || "";
|
|
48915
48980
|
const combinedStyles = baseStyles && sizeStyle ? `${baseStyles}; ${sizeStyle}` : baseStyles || sizeStyle;
|
|
48916
48981
|
const styleAttr = combinedStyles ? ` style="${combinedStyles}"` : "";
|
|
48982
|
+
const accessibleName = node.aria ?? node["aria-label"];
|
|
48917
48983
|
const attrs = {
|
|
48918
48984
|
class: classes,
|
|
48919
48985
|
disabled: node.disabled,
|
|
48986
|
+
"aria-label": accessibleName,
|
|
48987
|
+
title: node.title,
|
|
48920
48988
|
// Interactive attributes
|
|
48921
48989
|
"data-navigate": node.navigate,
|
|
48922
48990
|
"data-opens": node.opens,
|
|
@@ -48929,7 +48997,7 @@ function renderButton(node, ctx) {
|
|
|
48929
48997
|
if (iconData) {
|
|
48930
48998
|
icon = renderIconSvg(iconData, 16, 2, `${ctx.prefix}-icon`);
|
|
48931
48999
|
} else {
|
|
48932
|
-
icon = `<span class="${ctx.prefix}-icon"
|
|
49000
|
+
icon = `<span class="${ctx.prefix}-icon" title="Unknown icon: ${ctx.escapeHtml(node.icon)}">${renderUnknownIconSvg(`${ctx.prefix}-icon`, 16)}</span>`;
|
|
48933
49001
|
}
|
|
48934
49002
|
}
|
|
48935
49003
|
const loading = node.loading ? `<span class="${ctx.prefix}-spinner ${ctx.prefix}-spinner-sm"></span>` : "";
|
|
@@ -49013,7 +49081,7 @@ function renderInput(node, ctx) {
|
|
|
49013
49081
|
if (iconData) {
|
|
49014
49082
|
iconHtml = renderIconSvg(iconData, 16, 2, `${ctx.prefix}-input-icon`);
|
|
49015
49083
|
} else {
|
|
49016
|
-
iconHtml = `<span class="${ctx.prefix}-input-icon"
|
|
49084
|
+
iconHtml = `<span class="${ctx.prefix}-input-icon" title="Unknown icon: ${ctx.escapeHtml(node.icon)}">${renderUnknownIconSvg(`${ctx.prefix}-input-icon`, 16)}</span>`;
|
|
49017
49085
|
}
|
|
49018
49086
|
const wrapperClasses = ctx.buildClassString([`${ctx.prefix}-input-wrapper`]);
|
|
49019
49087
|
const wrapper = `<div class="${wrapperClasses}"${styleAttr}>${iconHtml}${inputElement}</div>`;
|
|
@@ -49278,10 +49346,10 @@ function renderIcon(node, ctx) {
|
|
|
49278
49346
|
}
|
|
49279
49347
|
const size = sizeResolved.style?.match(/(\d+)px/)?.[1] || "24";
|
|
49280
49348
|
const sizeNum = parseInt(size, 10);
|
|
49281
|
-
const placeholderSvg =
|
|
49282
|
-
|
|
49283
|
-
|
|
49284
|
-
|
|
49349
|
+
const placeholderSvg = renderUnknownIconSvg(
|
|
49350
|
+
`${ctx.prefix}-icon ${sizeResolved.className || ""}`,
|
|
49351
|
+
sizeNum
|
|
49352
|
+
);
|
|
49285
49353
|
const wrapperStyleAttr = baseStyles ? ` style="${baseStyles}"` : "";
|
|
49286
49354
|
return `<span class="${wrapperClasses}"${wrapperStyleAttr}${interactiveAttrStr} aria-hidden="true" title="Unknown icon: ${ctx.escapeHtml(node.name)}">${placeholderSvg}</span>`;
|
|
49287
49355
|
}
|
|
@@ -49686,6 +49754,10 @@ function renderAnnotationItem(node, ctx) {
|
|
|
49686
49754
|
}
|
|
49687
49755
|
|
|
49688
49756
|
// src/renderer/html/index.ts
|
|
49757
|
+
function injectAnchorAttrs(html, path, loc) {
|
|
49758
|
+
const attrs = loc ? ` ${ANCHOR_PATH_ATTR}="${path}" ${ANCHOR_LOC_ATTR}="${formatAnchorLoc(loc)}"` : ` ${ANCHOR_PATH_ATTR}="${path}"`;
|
|
49759
|
+
return html.replace(/<([a-zA-Z][a-zA-Z0-9-]*)/, (match) => `${match}${attrs}`);
|
|
49760
|
+
}
|
|
49689
49761
|
var SPACING_TOKENS = {
|
|
49690
49762
|
0: "0px",
|
|
49691
49763
|
1: "4px",
|
|
@@ -49728,10 +49800,36 @@ var HtmlRenderer = class extends BaseRenderer {
|
|
|
49728
49800
|
* Node type to renderer method mapping
|
|
49729
49801
|
*/
|
|
49730
49802
|
nodeRenderers;
|
|
49731
|
-
|
|
49803
|
+
/**
|
|
49804
|
+
* Node → anchor-path map for the document currently being rendered. Non-null
|
|
49805
|
+
* only while rendering with `sourceAnchors` enabled.
|
|
49806
|
+
*/
|
|
49807
|
+
pathMap = null;
|
|
49808
|
+
/**
|
|
49809
|
+
* Base index added to page anchor paths. Non-zero when a page is rendered in
|
|
49810
|
+
* isolation (canvas per-page composition) but must keep its true document
|
|
49811
|
+
* index in the anchor scheme.
|
|
49812
|
+
*/
|
|
49813
|
+
pageIndexBase;
|
|
49814
|
+
constructor(options = {}, pageIndexBase = 0) {
|
|
49732
49815
|
super(options);
|
|
49816
|
+
this.pageIndexBase = pageIndexBase;
|
|
49733
49817
|
this.nodeRenderers = this.createNodeRenderers();
|
|
49734
49818
|
}
|
|
49819
|
+
/**
|
|
49820
|
+
* Render a document, building the anchor-path map first when anchors are
|
|
49821
|
+
* enabled so `renderNode` / `renderPage` can inject each node's path.
|
|
49822
|
+
*/
|
|
49823
|
+
render(document) {
|
|
49824
|
+
if (this.context.options.sourceAnchors) {
|
|
49825
|
+
this.pathMap = buildAnchorPathMap(document, this.pageIndexBase);
|
|
49826
|
+
}
|
|
49827
|
+
try {
|
|
49828
|
+
return super.render(document);
|
|
49829
|
+
} finally {
|
|
49830
|
+
this.pathMap = null;
|
|
49831
|
+
}
|
|
49832
|
+
}
|
|
49735
49833
|
/**
|
|
49736
49834
|
* Get render context for external renderer functions
|
|
49737
49835
|
*/
|
|
@@ -49860,9 +49958,15 @@ var HtmlRenderer = class extends BaseRenderer {
|
|
|
49860
49958
|
}
|
|
49861
49959
|
const combinedStyle = commonStyles ? `${viewportStyle}; ${commonStyles}` : viewportStyle;
|
|
49862
49960
|
const dataAttrs = `data-viewport-width="${viewport.width}" data-viewport-height="${viewport.height}" data-viewport-label="${viewport.label}"`;
|
|
49863
|
-
|
|
49961
|
+
let pageDiv = `<div class="${classes}" style="${combinedStyle}" ${dataAttrs}>
|
|
49864
49962
|
${title}${uiContent}
|
|
49865
49963
|
</div>`;
|
|
49964
|
+
if (this.pathMap) {
|
|
49965
|
+
const path = this.pathMap.get(node);
|
|
49966
|
+
if (path !== void 0) {
|
|
49967
|
+
pageDiv = injectAnchorAttrs(pageDiv, path, node.loc);
|
|
49968
|
+
}
|
|
49969
|
+
}
|
|
49866
49970
|
if (annotationChildren.length > 0) {
|
|
49867
49971
|
const annotationsContent = this.renderChildren(annotationChildren);
|
|
49868
49972
|
return `<div class="${this.prefix}-page-wrapper" style="width: ${viewport.width}px">
|
|
@@ -49877,10 +49981,14 @@ ${annotationsContent}
|
|
|
49877
49981
|
*/
|
|
49878
49982
|
renderNode(node) {
|
|
49879
49983
|
const renderer = this.nodeRenderers[node.type];
|
|
49880
|
-
|
|
49881
|
-
|
|
49984
|
+
const html = renderer ? renderer(node) : `<!-- Unknown node type: ${node.type} -->`;
|
|
49985
|
+
if (this.pathMap && node.type !== "Page") {
|
|
49986
|
+
const path = this.pathMap.get(node);
|
|
49987
|
+
if (path !== void 0) {
|
|
49988
|
+
return injectAnchorAttrs(html, path, node.loc);
|
|
49989
|
+
}
|
|
49882
49990
|
}
|
|
49883
|
-
return
|
|
49991
|
+
return html;
|
|
49884
49992
|
}
|
|
49885
49993
|
/**
|
|
49886
49994
|
* Render children nodes
|
|
@@ -50331,8 +50439,8 @@ function renderCanvas(doc, options = {}) {
|
|
|
50331
50439
|
};
|
|
50332
50440
|
}
|
|
50333
50441
|
const { placed, width, height } = layoutCanvas(doc.children, gap);
|
|
50334
|
-
const
|
|
50335
|
-
|
|
50442
|
+
const boards = placed.map((p, pageIndex) => {
|
|
50443
|
+
const pageRenderer = new HtmlRenderer({ ...options, includeStyles: false }, pageIndex);
|
|
50336
50444
|
const { html: pageHtml } = pageRenderer.render({
|
|
50337
50445
|
type: "Document",
|
|
50338
50446
|
children: [p.page]
|
|
@@ -50370,6 +50478,9 @@ function render(document, options = {}) {
|
|
|
50370
50478
|
}
|
|
50371
50479
|
function renderToHtml(document, options = {}) {
|
|
50372
50480
|
const { html, css } = render(document, options);
|
|
50481
|
+
const prefix = options.classPrefix ?? "wf";
|
|
50482
|
+
const isMultiPage = document.children.length > 1;
|
|
50483
|
+
const bodyAlign = isMultiPage ? "justify-content: flex-start;\n align-items: flex-start;" : "justify-content: center;\n align-items: center;";
|
|
50373
50484
|
return `<!DOCTYPE html>
|
|
50374
50485
|
<html lang="en">
|
|
50375
50486
|
<head>
|
|
@@ -50377,7 +50488,7 @@ function renderToHtml(document, options = {}) {
|
|
|
50377
50488
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
50378
50489
|
<title>Wireframe</title>
|
|
50379
50490
|
<style>
|
|
50380
|
-
/*
|
|
50491
|
+
/* Viewport framing: center a single page, anchor a multi-page canvas top-left */
|
|
50381
50492
|
html, body {
|
|
50382
50493
|
margin: 0;
|
|
50383
50494
|
padding: 0;
|
|
@@ -50386,11 +50497,18 @@ html, body {
|
|
|
50386
50497
|
}
|
|
50387
50498
|
body {
|
|
50388
50499
|
display: flex;
|
|
50389
|
-
|
|
50390
|
-
align-items: center;
|
|
50500
|
+
${bodyAlign}
|
|
50391
50501
|
padding: 24px;
|
|
50392
50502
|
box-sizing: border-box;
|
|
50393
50503
|
}
|
|
50504
|
+
/* Fixed-layout invariant: the multi-page canvas is a flex item of <body> and
|
|
50505
|
+
must keep its intrinsic size when the viewport is narrower than the canvas.
|
|
50506
|
+
Without flex-shrink:0 the flex item shrinks and the boards reflow \u2014 the same
|
|
50507
|
+
defect class as .wf-page (see no-responsive.md). Single pages already carry
|
|
50508
|
+
flex-shrink:0 via generateStyles; the canvas wrapper needs it here. */
|
|
50509
|
+
.${prefix}-canvas {
|
|
50510
|
+
flex-shrink: 0;
|
|
50511
|
+
}
|
|
50394
50512
|
${css}
|
|
50395
50513
|
</style>
|
|
50396
50514
|
</head>
|
|
@@ -50468,6 +50586,7 @@ ${css}
|
|
|
50468
50586
|
renderPage,
|
|
50469
50587
|
renderToHtml,
|
|
50470
50588
|
renderToSvg,
|
|
50589
|
+
renderUnknownIconSvg,
|
|
50471
50590
|
resolvePageDimensions
|
|
50472
50591
|
});
|
|
50473
50592
|
/**
|
package/dist/renderer.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { aZ as WireframeDocument, h as AnyNode, aj as PageNode } from './types-BDbXDhTp.cjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Renderer type definitions for wireweave
|
|
@@ -18,6 +18,12 @@ interface RenderOptions {
|
|
|
18
18
|
classPrefix?: string;
|
|
19
19
|
/** Background color (e.g., '#ffffff', 'transparent') */
|
|
20
20
|
background?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Emit source-anchor attributes (`data-wf-path` / `data-wf-loc`) on each
|
|
23
|
+
* rendered component element, enabling DOM ↔ AST ↔ source mapping. Default
|
|
24
|
+
* `false` — output is byte-identical to non-anchored rendering when off.
|
|
25
|
+
*/
|
|
26
|
+
sourceAnchors?: boolean;
|
|
21
27
|
}
|
|
22
28
|
interface RenderResult {
|
|
23
29
|
/** Rendered HTML content */
|
|
@@ -213,7 +219,23 @@ declare class HtmlRenderer extends BaseRenderer {
|
|
|
213
219
|
* Node type to renderer method mapping
|
|
214
220
|
*/
|
|
215
221
|
private readonly nodeRenderers;
|
|
216
|
-
|
|
222
|
+
/**
|
|
223
|
+
* Node → anchor-path map for the document currently being rendered. Non-null
|
|
224
|
+
* only while rendering with `sourceAnchors` enabled.
|
|
225
|
+
*/
|
|
226
|
+
private pathMap;
|
|
227
|
+
/**
|
|
228
|
+
* Base index added to page anchor paths. Non-zero when a page is rendered in
|
|
229
|
+
* isolation (canvas per-page composition) but must keep its true document
|
|
230
|
+
* index in the anchor scheme.
|
|
231
|
+
*/
|
|
232
|
+
private readonly pageIndexBase;
|
|
233
|
+
constructor(options?: RenderOptions, pageIndexBase?: number);
|
|
234
|
+
/**
|
|
235
|
+
* Render a document, building the anchor-path map first when anchors are
|
|
236
|
+
* enabled so `renderNode` / `renderPage` can inject each node's path.
|
|
237
|
+
*/
|
|
238
|
+
render(document: WireframeDocument): RenderResult;
|
|
217
239
|
/**
|
|
218
240
|
* Get render context for external renderer functions
|
|
219
241
|
*/
|
|
@@ -483,6 +505,14 @@ declare function getIconData(name: string): IconData | undefined;
|
|
|
483
505
|
*/
|
|
484
506
|
declare function renderIconSvg(data: IconData, _size?: number, // size is now controlled by CSS, this param is kept for API compatibility
|
|
485
507
|
strokeWidth?: number, className?: string, styleAttr?: string): string;
|
|
508
|
+
/**
|
|
509
|
+
* Render the canonical "unknown icon" placeholder SVG — a dashed circle with a
|
|
510
|
+
* `?` glyph. Shared by every renderer (icon node, button, input) so an
|
|
511
|
+
* unresolved icon name always produces the SAME visual placeholder and never
|
|
512
|
+
* leaks the raw DSL name as literal text. Callers add a
|
|
513
|
+
* `title="Unknown icon: <name>"` on the wrapping element for hover context.
|
|
514
|
+
*/
|
|
515
|
+
declare function renderUnknownIconSvg(className?: string, size?: number, styleAttr?: string): string;
|
|
486
516
|
|
|
487
517
|
/**
|
|
488
518
|
* Renderer module for wireweave
|
|
@@ -528,4 +558,4 @@ declare function renderToHtml(document: WireframeDocument, options?: RenderOptio
|
|
|
528
558
|
*/
|
|
529
559
|
declare function renderToSvg(document: WireframeDocument, options?: SvgRenderOptions): SvgRenderResult;
|
|
530
560
|
|
|
531
|
-
export { type CanvasOptions, type CanvasRenderResult, HtmlRenderer, type IconData, type IconElement, type PageRenderResult, type PlacedPage, type RenderContext, type RenderOptions, type RenderResult, type SvgRenderOptions, type SvgRenderResult, type ThemeColors, type ThemeConfig, createHtmlRenderer, darkTheme, defaultTheme, generateComponentStyles, generateStyles, getIconData, getTheme, layoutCanvas, lucideIcons, render, renderCanvas, renderIconSvg, renderPage, renderToHtml, renderToSvg, resolvePageDimensions };
|
|
561
|
+
export { type CanvasOptions, type CanvasRenderResult, HtmlRenderer, type IconData, type IconElement, type PageRenderResult, type PlacedPage, type RenderContext, type RenderOptions, type RenderResult, type SvgRenderOptions, type SvgRenderResult, type ThemeColors, type ThemeConfig, createHtmlRenderer, darkTheme, defaultTheme, generateComponentStyles, generateStyles, getIconData, getTheme, layoutCanvas, lucideIcons, render, renderCanvas, renderIconSvg, renderPage, renderToHtml, renderToSvg, renderUnknownIconSvg, resolvePageDimensions };
|
package/dist/renderer.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { aZ as WireframeDocument, h as AnyNode, aj as PageNode } from './types-BDbXDhTp.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Renderer type definitions for wireweave
|
|
@@ -18,6 +18,12 @@ interface RenderOptions {
|
|
|
18
18
|
classPrefix?: string;
|
|
19
19
|
/** Background color (e.g., '#ffffff', 'transparent') */
|
|
20
20
|
background?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Emit source-anchor attributes (`data-wf-path` / `data-wf-loc`) on each
|
|
23
|
+
* rendered component element, enabling DOM ↔ AST ↔ source mapping. Default
|
|
24
|
+
* `false` — output is byte-identical to non-anchored rendering when off.
|
|
25
|
+
*/
|
|
26
|
+
sourceAnchors?: boolean;
|
|
21
27
|
}
|
|
22
28
|
interface RenderResult {
|
|
23
29
|
/** Rendered HTML content */
|
|
@@ -213,7 +219,23 @@ declare class HtmlRenderer extends BaseRenderer {
|
|
|
213
219
|
* Node type to renderer method mapping
|
|
214
220
|
*/
|
|
215
221
|
private readonly nodeRenderers;
|
|
216
|
-
|
|
222
|
+
/**
|
|
223
|
+
* Node → anchor-path map for the document currently being rendered. Non-null
|
|
224
|
+
* only while rendering with `sourceAnchors` enabled.
|
|
225
|
+
*/
|
|
226
|
+
private pathMap;
|
|
227
|
+
/**
|
|
228
|
+
* Base index added to page anchor paths. Non-zero when a page is rendered in
|
|
229
|
+
* isolation (canvas per-page composition) but must keep its true document
|
|
230
|
+
* index in the anchor scheme.
|
|
231
|
+
*/
|
|
232
|
+
private readonly pageIndexBase;
|
|
233
|
+
constructor(options?: RenderOptions, pageIndexBase?: number);
|
|
234
|
+
/**
|
|
235
|
+
* Render a document, building the anchor-path map first when anchors are
|
|
236
|
+
* enabled so `renderNode` / `renderPage` can inject each node's path.
|
|
237
|
+
*/
|
|
238
|
+
render(document: WireframeDocument): RenderResult;
|
|
217
239
|
/**
|
|
218
240
|
* Get render context for external renderer functions
|
|
219
241
|
*/
|
|
@@ -483,6 +505,14 @@ declare function getIconData(name: string): IconData | undefined;
|
|
|
483
505
|
*/
|
|
484
506
|
declare function renderIconSvg(data: IconData, _size?: number, // size is now controlled by CSS, this param is kept for API compatibility
|
|
485
507
|
strokeWidth?: number, className?: string, styleAttr?: string): string;
|
|
508
|
+
/**
|
|
509
|
+
* Render the canonical "unknown icon" placeholder SVG — a dashed circle with a
|
|
510
|
+
* `?` glyph. Shared by every renderer (icon node, button, input) so an
|
|
511
|
+
* unresolved icon name always produces the SAME visual placeholder and never
|
|
512
|
+
* leaks the raw DSL name as literal text. Callers add a
|
|
513
|
+
* `title="Unknown icon: <name>"` on the wrapping element for hover context.
|
|
514
|
+
*/
|
|
515
|
+
declare function renderUnknownIconSvg(className?: string, size?: number, styleAttr?: string): string;
|
|
486
516
|
|
|
487
517
|
/**
|
|
488
518
|
* Renderer module for wireweave
|
|
@@ -528,4 +558,4 @@ declare function renderToHtml(document: WireframeDocument, options?: RenderOptio
|
|
|
528
558
|
*/
|
|
529
559
|
declare function renderToSvg(document: WireframeDocument, options?: SvgRenderOptions): SvgRenderResult;
|
|
530
560
|
|
|
531
|
-
export { type CanvasOptions, type CanvasRenderResult, HtmlRenderer, type IconData, type IconElement, type PageRenderResult, type PlacedPage, type RenderContext, type RenderOptions, type RenderResult, type SvgRenderOptions, type SvgRenderResult, type ThemeColors, type ThemeConfig, createHtmlRenderer, darkTheme, defaultTheme, generateComponentStyles, generateStyles, getIconData, getTheme, layoutCanvas, lucideIcons, render, renderCanvas, renderIconSvg, renderPage, renderToHtml, renderToSvg, resolvePageDimensions };
|
|
561
|
+
export { type CanvasOptions, type CanvasRenderResult, HtmlRenderer, type IconData, type IconElement, type PageRenderResult, type PlacedPage, type RenderContext, type RenderOptions, type RenderResult, type SvgRenderOptions, type SvgRenderResult, type ThemeColors, type ThemeConfig, createHtmlRenderer, darkTheme, defaultTheme, generateComponentStyles, generateStyles, getIconData, getTheme, layoutCanvas, lucideIcons, render, renderCanvas, renderIconSvg, renderPage, renderToHtml, renderToSvg, renderUnknownIconSvg, resolvePageDimensions };
|