@wireweave/core 4.0.0-beta.13 → 4.0.0-beta.14
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/app.cjs +16 -15
- package/dist/app.d.cts +4 -144
- package/dist/app.d.ts +4 -144
- package/dist/app.js +2 -1
- package/dist/{chunk-FS6A6EJ4.js → chunk-2Y3GKARZ.js} +3 -1312
- package/dist/chunk-4DDV6Z2X.js +389 -0
- package/dist/chunk-LA5LKIEL.cjs +396 -0
- package/dist/chunk-NV6UV5ID.cjs +2145 -0
- package/dist/{chunk-4UZBGIGJ.cjs → chunk-SAN6CJEE.cjs} +60 -1370
- package/dist/chunk-TQSOLTMZ.js +2132 -0
- package/dist/index-BD_4rXH-.d.cts +1031 -0
- package/dist/{index-BGU_4N4W.d.ts → index-BEnsO2kE.d.ts} +143 -1
- package/dist/{index-DyXaMSgd.d.cts → index-YSIzfhOd.d.cts} +143 -1
- package/dist/index-g9yV20xb.d.ts +1031 -0
- package/dist/index.cjs +235 -44
- package/dist/index.d.cts +11 -188
- package/dist/index.d.ts +11 -188
- package/dist/index.js +204 -17
- package/dist/renderer.cjs +8 -8
- package/dist/renderer.d.cts +4 -756
- package/dist/renderer.d.ts +4 -756
- package/dist/renderer.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-4TMDPWPR.cjs +0 -186
- package/dist/chunk-5DGRIQDU.cjs +0 -824
- package/dist/chunk-JJWAFHSV.js +0 -821
- package/dist/chunk-R5WBZWBC.js +0 -180
|
@@ -0,0 +1,1031 @@
|
|
|
1
|
+
import { P as PageNode, L as LayoutDefinitionNode, W as WireframeDocument, A as AnyNode, C as ComponentUseNode, I as InteractiveProps, G as GuardedOutcomeProps } from './types-CGRi1k2N.js';
|
|
2
|
+
import { D as Diagnostic, S as SourceMapEntry, L as LinkedIdentity, a as ScreenReference, A as AppResult, b as LinkedApp, R as RenderContext, c as RenderOptions, T as ThemeConfig, d as RenderResult, e as AnnotationStyle, P as PageRenderResult, C as CanvasOptions, f as CanvasRenderResult, g as SvgRenderOptions, h as SvgRenderResult } from './index-BEnsO2kE.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The screen model behind `renderSite` — which pages become screens, which
|
|
6
|
+
* shell each one is drawn inside, and what names address it.
|
|
7
|
+
*
|
|
8
|
+
* Nothing here renders. It answers three questions the site renderer and its
|
|
9
|
+
* inline runtime both need the *same* answer to, so the answer is computed once
|
|
10
|
+
* and handed to both.
|
|
11
|
+
*
|
|
12
|
+
* ## Totality
|
|
13
|
+
*
|
|
14
|
+
* A wireframe document can name a layout that does not exist, declare two pages
|
|
15
|
+
* with the same `id`, or use a layout with no `slot`. None of those is a parse
|
|
16
|
+
* error (see the note on `WireframeDocument`), so none of them may stop a
|
|
17
|
+
* render either: every function here is total. Where a document is ambiguous
|
|
18
|
+
* the rule is always **first-wins in document order** — the same rule
|
|
19
|
+
* `extract/transitions.ts` already applies to titles — and the loser is not
|
|
20
|
+
* dropped silently: it is rendered with a `data-wf-*` marker naming what went
|
|
21
|
+
* unmet, so a reader of the output can see it and `validation/` can report it
|
|
22
|
+
* with a source location.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/** Why a page that declared `uses=` is not composed into a shell after all. */
|
|
26
|
+
type ShellMiss =
|
|
27
|
+
/** No `layout` in the document carries that name. */
|
|
28
|
+
'unknown-layout'
|
|
29
|
+
/** The layout exists but has no `slot`, so it has nowhere to put a page. */
|
|
30
|
+
| 'slotless-layout';
|
|
31
|
+
/** One page, as a screen of the composed document. */
|
|
32
|
+
interface SiteScreen {
|
|
33
|
+
/** Position in `documentPages(doc)`. This is the screen's DOM key. */
|
|
34
|
+
index: number;
|
|
35
|
+
page: PageNode;
|
|
36
|
+
/**
|
|
37
|
+
* The variant this screen draws, when its page came from a `variants=` list.
|
|
38
|
+
*
|
|
39
|
+
* Read off the page rather than derived here: `expandVariants` has already
|
|
40
|
+
* turned one variant-bearing page into one page per variant by the time a
|
|
41
|
+
* model is built, so each of those pages is a screen like any other and this
|
|
42
|
+
* only records which one it is.
|
|
43
|
+
*/
|
|
44
|
+
variant?: string;
|
|
45
|
+
/** Name of the shell this screen is composed into, when it has one. */
|
|
46
|
+
shell?: string;
|
|
47
|
+
/** Set when `uses=` was declared and could not be honoured. */
|
|
48
|
+
miss?: {
|
|
49
|
+
uses: string;
|
|
50
|
+
reason: ShellMiss;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* The public name this screen *owns* — the name that resolves to it.
|
|
54
|
+
*
|
|
55
|
+
* Absent when the page declared no name, and also when every name it declared
|
|
56
|
+
* is already owned by an earlier page. A screen without a name is still
|
|
57
|
+
* reachable: its index addresses it.
|
|
58
|
+
*/
|
|
59
|
+
name?: string;
|
|
60
|
+
}
|
|
61
|
+
/** One layout, emitted once, hosting every screen that uses it. */
|
|
62
|
+
interface SiteShell {
|
|
63
|
+
/** The `layout <name>` identifier, which `uses=` addresses. */
|
|
64
|
+
name: string;
|
|
65
|
+
layout: LayoutDefinitionNode;
|
|
66
|
+
/** Screens composed into this shell, in document order. */
|
|
67
|
+
screens: SiteScreen[];
|
|
68
|
+
/**
|
|
69
|
+
* Frame size of the shell, resolved from its first screen's page.
|
|
70
|
+
*
|
|
71
|
+
* A layout has no viewport of its own — it is the pages that declare one — so
|
|
72
|
+
* the first page to use it fixes the frame. A later page resolving to a
|
|
73
|
+
* different size is a conflict the author has to settle; it is marked on that
|
|
74
|
+
* screen rather than resized, because silently stretching one page's frame to
|
|
75
|
+
* another's is the kind of change that is invisible until a screenshot.
|
|
76
|
+
*/
|
|
77
|
+
width: number;
|
|
78
|
+
height: number;
|
|
79
|
+
}
|
|
80
|
+
interface SiteModel {
|
|
81
|
+
screens: SiteScreen[];
|
|
82
|
+
/** Shells in first-use order — the order pages first reference them. */
|
|
83
|
+
shells: SiteShell[];
|
|
84
|
+
/**
|
|
85
|
+
* Every name that addresses a screen → that screen's index.
|
|
86
|
+
*
|
|
87
|
+
* Built exactly like `extract/transitions.ts` resolves `navigate`: the `id`
|
|
88
|
+
* namespace is consulted before the `title` namespace, and within each
|
|
89
|
+
* namespace the first page in document order wins. A `navigate` target and a
|
|
90
|
+
* URL fragment therefore land on the same screen the transition graph says
|
|
91
|
+
* they do — one resolution rule, two consumers.
|
|
92
|
+
*/
|
|
93
|
+
names: Map<string, number>;
|
|
94
|
+
/** Screen shown when no fragment selects one. `-1` for a document with no pages. */
|
|
95
|
+
entry: number;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Derive the screen model of a document.
|
|
99
|
+
*
|
|
100
|
+
* Pure and deterministic: same document in, same model out, whatever the
|
|
101
|
+
* document contains.
|
|
102
|
+
*/
|
|
103
|
+
declare function buildSiteModel(doc: WireframeDocument): SiteModel;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Export Types
|
|
107
|
+
*
|
|
108
|
+
* Types for exporting wireframes to various formats.
|
|
109
|
+
*/
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Simplified JSON node structure
|
|
113
|
+
*/
|
|
114
|
+
interface JsonNode {
|
|
115
|
+
/** Node type (e.g., 'page', 'button', 'input') */
|
|
116
|
+
type: string;
|
|
117
|
+
/** Node content or label */
|
|
118
|
+
content?: string;
|
|
119
|
+
/** Node attributes */
|
|
120
|
+
attributes: Record<string, unknown>;
|
|
121
|
+
/** Child nodes */
|
|
122
|
+
children: JsonNode[];
|
|
123
|
+
/** Source location (optional) */
|
|
124
|
+
location?: {
|
|
125
|
+
line: number;
|
|
126
|
+
column: number;
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* JSON export result
|
|
131
|
+
*/
|
|
132
|
+
interface JsonExportResult {
|
|
133
|
+
/** Export format version */
|
|
134
|
+
version: string;
|
|
135
|
+
/** Export format */
|
|
136
|
+
format: 'json';
|
|
137
|
+
/** Exported pages */
|
|
138
|
+
pages: JsonNode[];
|
|
139
|
+
/** Metadata */
|
|
140
|
+
metadata: {
|
|
141
|
+
exportedAt: string;
|
|
142
|
+
sourceFormat: 'wireweave';
|
|
143
|
+
nodeCount: number;
|
|
144
|
+
componentTypes: string[];
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Figma node types that we can map to
|
|
149
|
+
*/
|
|
150
|
+
type FigmaNodeType = 'DOCUMENT' | 'CANVAS' | 'FRAME' | 'GROUP' | 'TEXT' | 'RECTANGLE' | 'INSTANCE' | 'COMPONENT';
|
|
151
|
+
/**
|
|
152
|
+
* Figma Auto Layout mode
|
|
153
|
+
*/
|
|
154
|
+
type FigmaLayoutMode = 'NONE' | 'HORIZONTAL' | 'VERTICAL';
|
|
155
|
+
/**
|
|
156
|
+
* Figma sizing mode for Auto Layout
|
|
157
|
+
*/
|
|
158
|
+
type FigmaSizingMode = 'FIXED' | 'HUG' | 'FILL';
|
|
159
|
+
/**
|
|
160
|
+
* Figma primary axis alignment (justify)
|
|
161
|
+
*/
|
|
162
|
+
type FigmaPrimaryAxisAlign = 'MIN' | 'CENTER' | 'MAX' | 'SPACE_BETWEEN';
|
|
163
|
+
/**
|
|
164
|
+
* Figma counter axis alignment (align)
|
|
165
|
+
*/
|
|
166
|
+
type FigmaCounterAxisAlign = 'MIN' | 'CENTER' | 'MAX' | 'STRETCH' | 'BASELINE';
|
|
167
|
+
/**
|
|
168
|
+
* Figma text alignment
|
|
169
|
+
*/
|
|
170
|
+
type FigmaTextAlign = 'LEFT' | 'CENTER' | 'RIGHT' | 'JUSTIFIED';
|
|
171
|
+
/**
|
|
172
|
+
* Figma color (RGBA, 0-1 range)
|
|
173
|
+
*/
|
|
174
|
+
interface FigmaColor {
|
|
175
|
+
r: number;
|
|
176
|
+
g: number;
|
|
177
|
+
b: number;
|
|
178
|
+
a: number;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Figma solid fill
|
|
182
|
+
*/
|
|
183
|
+
interface FigmaSolidFill {
|
|
184
|
+
type: 'SOLID';
|
|
185
|
+
color: FigmaColor;
|
|
186
|
+
opacity?: number;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Figma stroke
|
|
190
|
+
*/
|
|
191
|
+
interface FigmaStroke {
|
|
192
|
+
type: 'SOLID';
|
|
193
|
+
color: FigmaColor;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Figma Auto Layout properties
|
|
197
|
+
*/
|
|
198
|
+
interface FigmaAutoLayout {
|
|
199
|
+
layoutMode: FigmaLayoutMode;
|
|
200
|
+
layoutSizingHorizontal: FigmaSizingMode;
|
|
201
|
+
layoutSizingVertical: FigmaSizingMode;
|
|
202
|
+
primaryAxisAlignItems: FigmaPrimaryAxisAlign;
|
|
203
|
+
counterAxisAlignItems: FigmaCounterAxisAlign;
|
|
204
|
+
paddingTop: number;
|
|
205
|
+
paddingRight: number;
|
|
206
|
+
paddingBottom: number;
|
|
207
|
+
paddingLeft: number;
|
|
208
|
+
itemSpacing: number;
|
|
209
|
+
layoutWrap?: 'NO_WRAP' | 'WRAP';
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Figma size properties
|
|
213
|
+
*/
|
|
214
|
+
interface FigmaSize {
|
|
215
|
+
width: number;
|
|
216
|
+
height: number;
|
|
217
|
+
minWidth?: number;
|
|
218
|
+
maxWidth?: number;
|
|
219
|
+
minHeight?: number;
|
|
220
|
+
maxHeight?: number;
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Figma text properties
|
|
224
|
+
*/
|
|
225
|
+
interface FigmaTextStyle {
|
|
226
|
+
fontSize: number;
|
|
227
|
+
fontWeight: number;
|
|
228
|
+
textAlignHorizontal: FigmaTextAlign;
|
|
229
|
+
characters: string;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Figma-compatible node structure
|
|
233
|
+
* Based on Figma's Plugin API structure
|
|
234
|
+
*/
|
|
235
|
+
interface FigmaNode {
|
|
236
|
+
/** Unique identifier */
|
|
237
|
+
id: string;
|
|
238
|
+
/** Node name */
|
|
239
|
+
name: string;
|
|
240
|
+
/** Node type */
|
|
241
|
+
type: FigmaNodeType;
|
|
242
|
+
/** Visibility */
|
|
243
|
+
visible: boolean;
|
|
244
|
+
/** Original Wireweave type */
|
|
245
|
+
wireweaveType?: string;
|
|
246
|
+
/** Original Wireweave attributes */
|
|
247
|
+
wireweaveAttributes?: Record<string, unknown>;
|
|
248
|
+
/** Child nodes */
|
|
249
|
+
children?: FigmaNode[];
|
|
250
|
+
/** Auto Layout properties (for FRAME) */
|
|
251
|
+
autoLayout?: FigmaAutoLayout;
|
|
252
|
+
/** Size properties */
|
|
253
|
+
size?: FigmaSize;
|
|
254
|
+
/** Text properties (for TEXT) */
|
|
255
|
+
textStyle?: FigmaTextStyle;
|
|
256
|
+
/** Background fills */
|
|
257
|
+
fills?: FigmaSolidFill[];
|
|
258
|
+
/** Border strokes */
|
|
259
|
+
strokes?: FigmaStroke[];
|
|
260
|
+
/** Stroke weight */
|
|
261
|
+
strokeWeight?: number;
|
|
262
|
+
/** Corner radius */
|
|
263
|
+
cornerRadius?: number;
|
|
264
|
+
/** v4 semantic provenance. Omitted by the legacy exporter. */
|
|
265
|
+
wireweaveMetadata?: FigmaWireweaveMetadata;
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Figma export result
|
|
269
|
+
*/
|
|
270
|
+
interface FigmaExportResult {
|
|
271
|
+
/** Export format version */
|
|
272
|
+
version: string;
|
|
273
|
+
/** Export format */
|
|
274
|
+
format: 'figma';
|
|
275
|
+
/** Document structure */
|
|
276
|
+
document: FigmaNode;
|
|
277
|
+
/** Component mappings for reference */
|
|
278
|
+
componentMappings: Record<string, string>;
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Export options
|
|
282
|
+
*/
|
|
283
|
+
interface ExportOptions {
|
|
284
|
+
/** Include source locations */
|
|
285
|
+
includeLocations?: boolean;
|
|
286
|
+
/** Pretty print JSON (with indentation) */
|
|
287
|
+
prettyPrint?: boolean;
|
|
288
|
+
/** Include empty attributes */
|
|
289
|
+
includeEmptyAttributes?: boolean;
|
|
290
|
+
}
|
|
291
|
+
/** A static export profile is part of the exported artifact identity. */
|
|
292
|
+
interface V4SvgProfile {
|
|
293
|
+
readonly id: 'wireweave-static-svg-v1';
|
|
294
|
+
readonly board?: ScreenReference;
|
|
295
|
+
readonly screens?: 'selected' | 'all';
|
|
296
|
+
readonly width?: number;
|
|
297
|
+
readonly height?: number;
|
|
298
|
+
readonly gap?: number;
|
|
299
|
+
readonly background?: string;
|
|
300
|
+
}
|
|
301
|
+
/** Figma mapping profiles describe a local mapping document, never a server write. */
|
|
302
|
+
interface FigmaMappingProfile {
|
|
303
|
+
readonly id: 'wireweave-figma-mapping-v1';
|
|
304
|
+
readonly board?: ScreenReference;
|
|
305
|
+
readonly screens?: 'selected' | 'all';
|
|
306
|
+
readonly target: 'figma-plugin-json-v1';
|
|
307
|
+
}
|
|
308
|
+
interface V4ExportDiagnostic {
|
|
309
|
+
readonly severity: 'warning' | 'info';
|
|
310
|
+
readonly code: string;
|
|
311
|
+
readonly message: string;
|
|
312
|
+
readonly renderedId?: string;
|
|
313
|
+
readonly details?: Record<string, unknown>;
|
|
314
|
+
}
|
|
315
|
+
interface ExportLoss {
|
|
316
|
+
readonly code: string;
|
|
317
|
+
readonly kind: 'interaction' | 'asset' | 'layout' | 'semantic';
|
|
318
|
+
readonly message: string;
|
|
319
|
+
readonly renderedId: string;
|
|
320
|
+
readonly operationId?: string;
|
|
321
|
+
readonly source?: SourceMapEntry;
|
|
322
|
+
readonly details?: Record<string, unknown>;
|
|
323
|
+
}
|
|
324
|
+
interface V4SvgManifest {
|
|
325
|
+
readonly schemaVersion: '1.0.0';
|
|
326
|
+
readonly exporter: 'wireweave-static-svg-v1';
|
|
327
|
+
readonly appId: string;
|
|
328
|
+
readonly linkedDigest: string;
|
|
329
|
+
readonly profileDigest: string;
|
|
330
|
+
readonly boardRoutes: readonly ScreenReference[];
|
|
331
|
+
readonly sourceMap: readonly SourceMapEntry[];
|
|
332
|
+
readonly lossReport: readonly ExportLoss[];
|
|
333
|
+
}
|
|
334
|
+
interface V4SvgArtifact {
|
|
335
|
+
readonly kind: 'V4SvgArtifact';
|
|
336
|
+
readonly mediaType: 'image/svg+xml';
|
|
337
|
+
readonly svg: string;
|
|
338
|
+
readonly width: number;
|
|
339
|
+
readonly height: number;
|
|
340
|
+
readonly digest: string;
|
|
341
|
+
readonly manifest: V4SvgManifest;
|
|
342
|
+
readonly diagnostics: readonly V4ExportDiagnostic[];
|
|
343
|
+
}
|
|
344
|
+
interface FigmaWireweaveMetadata {
|
|
345
|
+
readonly identity: LinkedIdentity;
|
|
346
|
+
readonly moduleId: string;
|
|
347
|
+
readonly source: SourceMapEntry['source'];
|
|
348
|
+
readonly invocationSources: SourceMapEntry['invocationSources'];
|
|
349
|
+
readonly requirementRefs: readonly string[];
|
|
350
|
+
readonly obligationRefs: readonly string[];
|
|
351
|
+
readonly operationIds: readonly string[];
|
|
352
|
+
}
|
|
353
|
+
interface FigmaSemanticMapping {
|
|
354
|
+
readonly renderedId: string;
|
|
355
|
+
readonly figmaId: string;
|
|
356
|
+
readonly identity: LinkedIdentity;
|
|
357
|
+
readonly source: SourceMapEntry;
|
|
358
|
+
}
|
|
359
|
+
interface FigmaMappingArtifact {
|
|
360
|
+
readonly kind: 'FigmaMappingArtifact';
|
|
361
|
+
readonly version: '4.0.0';
|
|
362
|
+
readonly format: 'figma';
|
|
363
|
+
readonly target: FigmaMappingProfile['target'];
|
|
364
|
+
readonly appId: string;
|
|
365
|
+
readonly linkedDigest: string;
|
|
366
|
+
readonly profileDigest: string;
|
|
367
|
+
readonly document: FigmaNode;
|
|
368
|
+
readonly mappings: readonly FigmaSemanticMapping[];
|
|
369
|
+
readonly sourceMap: readonly SourceMapEntry[];
|
|
370
|
+
readonly lossReport: readonly ExportLoss[];
|
|
371
|
+
readonly diagnostics: readonly V4ExportDiagnostic[];
|
|
372
|
+
}
|
|
373
|
+
type V4SvgExportResult = AppResult<V4SvgArtifact>;
|
|
374
|
+
type FigmaMappingExportResult = AppResult<FigmaMappingArtifact>;
|
|
375
|
+
/** Public input marker used by the v4 overloads. */
|
|
376
|
+
type V4LinkedExportInput = LinkedApp;
|
|
377
|
+
/** Keep the diagnostic type visible to adapter authors without duplicating it. */
|
|
378
|
+
type CoreExportDiagnostic = Diagnostic;
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* Base HTML Renderer for wireweave
|
|
382
|
+
*
|
|
383
|
+
* Provides abstract base class for HTML rendering with theme support
|
|
384
|
+
*/
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* Abstract base renderer class
|
|
388
|
+
*
|
|
389
|
+
* Provides core infrastructure for HTML rendering:
|
|
390
|
+
* - Theme management
|
|
391
|
+
* - Indentation and formatting
|
|
392
|
+
* - Depth tracking for nested elements
|
|
393
|
+
*/
|
|
394
|
+
declare abstract class BaseRenderer {
|
|
395
|
+
protected context: RenderContext;
|
|
396
|
+
constructor(options?: RenderOptions);
|
|
397
|
+
/**
|
|
398
|
+
* Build theme configuration based on options
|
|
399
|
+
* Note: background option is NOT applied to theme.colors.background
|
|
400
|
+
* It's only used for page background in renderPage() to avoid affecting
|
|
401
|
+
* component colors that use var(--wf-bg)
|
|
402
|
+
*/
|
|
403
|
+
protected buildTheme(options: RenderOptions): ThemeConfig;
|
|
404
|
+
/**
|
|
405
|
+
* Render a wireframe document to HTML and CSS
|
|
406
|
+
*/
|
|
407
|
+
render(document: WireframeDocument): RenderResult;
|
|
408
|
+
/**
|
|
409
|
+
* Render a complete wireframe document.
|
|
410
|
+
*
|
|
411
|
+
* Only pages are drawn. A document's top level also holds `layout` and
|
|
412
|
+
* `component` definitions, which are reusable fragments a page refers to —
|
|
413
|
+
* drawing one would put a screen on the canvas that the author never wrote a
|
|
414
|
+
* page for, and would do it the moment the reuse feature was used at all.
|
|
415
|
+
*/
|
|
416
|
+
protected renderDocument(document: WireframeDocument): string;
|
|
417
|
+
/**
|
|
418
|
+
* Render a page node (to be implemented by subclasses)
|
|
419
|
+
*/
|
|
420
|
+
protected abstract renderPage(node: AnyNode): string;
|
|
421
|
+
/**
|
|
422
|
+
* Render any AST node (to be implemented by subclasses)
|
|
423
|
+
*/
|
|
424
|
+
protected abstract renderNode(node: AnyNode): string;
|
|
425
|
+
/**
|
|
426
|
+
* Get the CSS class prefix
|
|
427
|
+
*/
|
|
428
|
+
protected get prefix(): string;
|
|
429
|
+
/**
|
|
430
|
+
* Add indentation based on current depth
|
|
431
|
+
*/
|
|
432
|
+
protected indent(content: string): string;
|
|
433
|
+
/**
|
|
434
|
+
* Execute a function with increased depth
|
|
435
|
+
*/
|
|
436
|
+
protected withDepth<T>(fn: () => T): T;
|
|
437
|
+
/**
|
|
438
|
+
* Escape HTML special characters
|
|
439
|
+
*/
|
|
440
|
+
protected escapeHtml(text: string): string;
|
|
441
|
+
/**
|
|
442
|
+
* The DOM id an authored id becomes under this render's `idScope`.
|
|
443
|
+
*
|
|
444
|
+
* One function so that "what is the id in the document" has one answer. A
|
|
445
|
+
* renderer that prefixed at some emission sites and not others would produce
|
|
446
|
+
* a document where `#confirm` resolves for one element and `#s0-confirm` for
|
|
447
|
+
* another, which is worse than either convention alone.
|
|
448
|
+
*
|
|
449
|
+
* Only identity is prefixed. The interaction attributes that point at an
|
|
450
|
+
* overlay still carry the name their author wrote — they are spelled in one
|
|
451
|
+
* file (`html/interactive.ts`) and read by whoever consumes them, which
|
|
452
|
+
* composes the scope back on. See `RenderOptions.idScope`.
|
|
453
|
+
*/
|
|
454
|
+
protected scopedId(id: string): string;
|
|
455
|
+
/**
|
|
456
|
+
* Build a CSS class string from an array of class names
|
|
457
|
+
*/
|
|
458
|
+
protected buildClassString(classes: (string | undefined | false)[]): string;
|
|
459
|
+
/**
|
|
460
|
+
* Build HTML attributes string
|
|
461
|
+
*/
|
|
462
|
+
protected buildAttrsString(attrs: Record<string, string | undefined | boolean>): string;
|
|
463
|
+
/**
|
|
464
|
+
* Simple HTML minification
|
|
465
|
+
*/
|
|
466
|
+
private minifyHtml;
|
|
467
|
+
/**
|
|
468
|
+
* Simple CSS minification
|
|
469
|
+
*/
|
|
470
|
+
private minifyCss;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
/**
|
|
474
|
+
* HTML Renderer for wireweave
|
|
475
|
+
*
|
|
476
|
+
* Converts AST nodes to HTML output
|
|
477
|
+
*/
|
|
478
|
+
|
|
479
|
+
/**
|
|
480
|
+
* HTML Renderer class
|
|
481
|
+
*
|
|
482
|
+
* Renders wireframe AST to semantic HTML with utility classes
|
|
483
|
+
*/
|
|
484
|
+
declare class HtmlRenderer extends BaseRenderer {
|
|
485
|
+
/**
|
|
486
|
+
* Node type to renderer method mapping
|
|
487
|
+
*/
|
|
488
|
+
private readonly nodeRenderers;
|
|
489
|
+
/**
|
|
490
|
+
* Node → anchor-path map for the document currently being rendered. Non-null
|
|
491
|
+
* only while rendering with `sourceAnchors` enabled.
|
|
492
|
+
*/
|
|
493
|
+
private pathMap;
|
|
494
|
+
/**
|
|
495
|
+
* Base index added to page anchor paths. Non-zero when a page is rendered in
|
|
496
|
+
* isolation (canvas per-page composition) but must keep its true document
|
|
497
|
+
* index in the anchor scheme.
|
|
498
|
+
*/
|
|
499
|
+
private readonly pageIndexBase;
|
|
500
|
+
/**
|
|
501
|
+
* HTML the next `slot` renders, or `null` when there is none to place.
|
|
502
|
+
*
|
|
503
|
+
* Set for the duration of one `renderFragment` call and consumed by the first
|
|
504
|
+
* slot reached, so it never leaks into an unrelated render.
|
|
505
|
+
*/
|
|
506
|
+
private slotContent;
|
|
507
|
+
constructor(options?: RenderOptions, pageIndexBase?: number);
|
|
508
|
+
/**
|
|
509
|
+
* Render a document, building the anchor-path map first when anchors are
|
|
510
|
+
* enabled so `renderNode` / `renderPage` can inject each node's path.
|
|
511
|
+
*/
|
|
512
|
+
render(document: WireframeDocument): RenderResult;
|
|
513
|
+
/**
|
|
514
|
+
* Get render context for external renderer functions
|
|
515
|
+
*/
|
|
516
|
+
private getRenderContext;
|
|
517
|
+
/**
|
|
518
|
+
* Get grid render context (extends RenderContext with buildColStyles)
|
|
519
|
+
*/
|
|
520
|
+
private getGridRenderContext;
|
|
521
|
+
/**
|
|
522
|
+
* Create the node renderer mapping
|
|
523
|
+
*/
|
|
524
|
+
private createNodeRenderers;
|
|
525
|
+
/**
|
|
526
|
+
* Render a page node
|
|
527
|
+
*/
|
|
528
|
+
protected renderPage(node: PageNode): string;
|
|
529
|
+
/**
|
|
530
|
+
* Render any AST node
|
|
531
|
+
*/
|
|
532
|
+
protected renderNode(node: AnyNode): string;
|
|
533
|
+
/**
|
|
534
|
+
* Render the `slot` of a layout — the position a page's content is placed at.
|
|
535
|
+
*
|
|
536
|
+
* The element is always emitted, filled or not. A layout is a shell, and a
|
|
537
|
+
* shell keeps its shape whether or not something is currently inside it;
|
|
538
|
+
* collapsing the slot away when empty would make the frame reflow between an
|
|
539
|
+
* isolated render of the layout and a composed one.
|
|
540
|
+
*/
|
|
541
|
+
protected renderSlot(): string;
|
|
542
|
+
/**
|
|
543
|
+
* Render one linked component invocation with its stable instance marker.
|
|
544
|
+
*
|
|
545
|
+
* The wrapper is identified by `data-` attributes and carries no class. It
|
|
546
|
+
* declares `display: contents`, so by construction it has no box of its own
|
|
547
|
+
* and its children lay out as though it were not there — which is the whole
|
|
548
|
+
* point: an invocation must not disturb the layout of what it expands to.
|
|
549
|
+
* A class is the hook a stylesheet paints a box through, and any rule that
|
|
550
|
+
* gave this one a box would defeat `display: contents`; there is therefore
|
|
551
|
+
* no style it could ever legitimately carry. It emitted
|
|
552
|
+
* `${this.prefix}-component-instance` regardless, which no rule in the
|
|
553
|
+
* generated CSS defined and nothing read — a class the markup advertises as
|
|
554
|
+
* styleable while the stylesheet leaves it undefined. Identity that exists
|
|
555
|
+
* to be *queried* rather than *painted* belongs in `data-`, alongside the
|
|
556
|
+
* `data-wf-component` / `data-wf-instance` pair already carrying it.
|
|
557
|
+
*/
|
|
558
|
+
protected renderComponentUse(node: ComponentUseNode): string;
|
|
559
|
+
/**
|
|
560
|
+
* Render a list of nodes with no page frame around them.
|
|
561
|
+
*
|
|
562
|
+
* The frame — viewport size, background, the CSS reset every component
|
|
563
|
+
* depends on — belongs to whatever is composing these nodes. `renderSite`
|
|
564
|
+
* uses this twice per shell: once for the layout's own markup, where
|
|
565
|
+
* `slotContent` is the screens that live in it, and once per screen for that
|
|
566
|
+
* page's body.
|
|
567
|
+
*
|
|
568
|
+
* @param nodes - Nodes to render, in order
|
|
569
|
+
* @param slotContent - HTML placed inside the first `slot` encountered
|
|
570
|
+
*/
|
|
571
|
+
renderFragment(nodes: AnyNode[], slotContent?: string | null): string;
|
|
572
|
+
/**
|
|
573
|
+
* Render children nodes
|
|
574
|
+
*/
|
|
575
|
+
protected renderChildren(children: AnyNode[]): string;
|
|
576
|
+
/**
|
|
577
|
+
* Get common CSS classes from props
|
|
578
|
+
* Uses Omit to exclude 'align' since TextNode/TitleNode have incompatible align types
|
|
579
|
+
*
|
|
580
|
+
* All numeric values are handled by buildCommonStyles as inline px values.
|
|
581
|
+
* CSS classes are only used for keyword values (full, auto, screen, fit, etc.)
|
|
582
|
+
*/
|
|
583
|
+
private getCommonClasses;
|
|
584
|
+
private renderHeader;
|
|
585
|
+
private renderMain;
|
|
586
|
+
private renderFooter;
|
|
587
|
+
private renderSidebar;
|
|
588
|
+
private renderSection;
|
|
589
|
+
private renderRow;
|
|
590
|
+
private renderCol;
|
|
591
|
+
private renderStack;
|
|
592
|
+
private renderRelative;
|
|
593
|
+
/**
|
|
594
|
+
* Build common inline styles for all values
|
|
595
|
+
*
|
|
596
|
+
* Position values (x, y) for absolute positioning:
|
|
597
|
+
* - When x or y is specified, element gets position: absolute
|
|
598
|
+
* - x → left, y → top
|
|
599
|
+
*
|
|
600
|
+
* Spacing values (p, m, gap) use token system:
|
|
601
|
+
* - number: spacing token (e.g., p=4 → padding: 16px from token table)
|
|
602
|
+
* - ValueWithUnit: direct CSS value (e.g., p=16px → padding: 16px)
|
|
603
|
+
*
|
|
604
|
+
* Size values (w, h, minW, maxW, minH, maxH) use direct px:
|
|
605
|
+
* - number: direct px value (e.g., w=400 → width: 400px)
|
|
606
|
+
* - ValueWithUnit: direct CSS value (e.g., w=50% → width: 50%)
|
|
607
|
+
*
|
|
608
|
+
* Token table: 0=0px, 1=4px, 2=8px, 3=12px, 4=16px, 5=20px, 6=24px, 8=32px, etc.
|
|
609
|
+
*
|
|
610
|
+
* Uses Omit to exclude 'align' since TextNode/TitleNode have incompatible align types
|
|
611
|
+
*/
|
|
612
|
+
private buildCommonStyles;
|
|
613
|
+
/**
|
|
614
|
+
* Build position styles (absolute positioning)
|
|
615
|
+
*/
|
|
616
|
+
private buildPositionStyles;
|
|
617
|
+
/**
|
|
618
|
+
* Build size styles (width, height, min/max)
|
|
619
|
+
*/
|
|
620
|
+
private buildSizeStyles;
|
|
621
|
+
/**
|
|
622
|
+
* Build padding styles (p, px, py, pt, pr, pb, pl)
|
|
623
|
+
*/
|
|
624
|
+
private buildPaddingStyles;
|
|
625
|
+
/**
|
|
626
|
+
* Build margin styles (m, mx, my, mt, mr, mb, ml)
|
|
627
|
+
*/
|
|
628
|
+
private buildMarginStyles;
|
|
629
|
+
/**
|
|
630
|
+
* Build gap styles
|
|
631
|
+
*/
|
|
632
|
+
private buildGapStyles;
|
|
633
|
+
/**
|
|
634
|
+
* Build inline styles for Col node (extends common styles with order)
|
|
635
|
+
*/
|
|
636
|
+
private buildColStyles;
|
|
637
|
+
private renderCard;
|
|
638
|
+
private renderModal;
|
|
639
|
+
private renderDrawer;
|
|
640
|
+
private renderAccordion;
|
|
641
|
+
private renderText;
|
|
642
|
+
private renderTitle;
|
|
643
|
+
private renderLink;
|
|
644
|
+
private renderInput;
|
|
645
|
+
private renderTextarea;
|
|
646
|
+
private renderSelect;
|
|
647
|
+
private renderCheckbox;
|
|
648
|
+
private renderRadio;
|
|
649
|
+
private renderSwitch;
|
|
650
|
+
private renderSlider;
|
|
651
|
+
private renderButton;
|
|
652
|
+
private renderImage;
|
|
653
|
+
private renderPlaceholder;
|
|
654
|
+
private renderAvatar;
|
|
655
|
+
private renderBadge;
|
|
656
|
+
private renderIcon;
|
|
657
|
+
private renderTable;
|
|
658
|
+
private renderList;
|
|
659
|
+
private renderAlert;
|
|
660
|
+
private renderToast;
|
|
661
|
+
private renderProgress;
|
|
662
|
+
private renderSpinner;
|
|
663
|
+
private renderTooltip;
|
|
664
|
+
private renderPopover;
|
|
665
|
+
private renderDropdown;
|
|
666
|
+
private renderNav;
|
|
667
|
+
private renderTabs;
|
|
668
|
+
private renderBreadcrumb;
|
|
669
|
+
private renderDivider;
|
|
670
|
+
private renderMarker;
|
|
671
|
+
private renderAnnotations;
|
|
672
|
+
private renderAnnotationItem;
|
|
673
|
+
}
|
|
674
|
+
/**
|
|
675
|
+
* Create a new HTML renderer instance
|
|
676
|
+
*/
|
|
677
|
+
declare function createHtmlRenderer(options?: RenderOptions): HtmlRenderer;
|
|
678
|
+
|
|
679
|
+
/**
|
|
680
|
+
* CSS Style Generator for wireweave
|
|
681
|
+
*
|
|
682
|
+
* Generates CSS classes for grid, spacing, and flex utilities
|
|
683
|
+
*/
|
|
684
|
+
|
|
685
|
+
/**
|
|
686
|
+
* Generate all CSS styles for wireframe rendering
|
|
687
|
+
*
|
|
688
|
+
* @param theme - Theme configuration
|
|
689
|
+
* @param prefix - CSS class prefix (default: 'wf')
|
|
690
|
+
* @returns Complete CSS string
|
|
691
|
+
*/
|
|
692
|
+
declare function generateStyles(theme: ThemeConfig, prefix?: string, annotationStyle?: AnnotationStyle): string;
|
|
693
|
+
|
|
694
|
+
/**
|
|
695
|
+
* Component-specific CSS styles for wireweave
|
|
696
|
+
*
|
|
697
|
+
* Detailed styles for all UI components with:
|
|
698
|
+
* - Wireframe aesthetic (black/white/gray)
|
|
699
|
+
* - Accessibility considerations
|
|
700
|
+
* - Responsive design
|
|
701
|
+
*/
|
|
702
|
+
|
|
703
|
+
/**
|
|
704
|
+
* Generate all component-specific CSS styles
|
|
705
|
+
*/
|
|
706
|
+
declare function generateComponentStyles(_theme: ThemeConfig, prefix?: string, annotationStyle?: AnnotationStyle): string;
|
|
707
|
+
|
|
708
|
+
/**
|
|
709
|
+
* Page renderer — single-Page primitive.
|
|
710
|
+
*
|
|
711
|
+
* `renderPage` is the *pure* unit of this renderer: its output depends only
|
|
712
|
+
* on the page itself, never on sibling pages or canvas-level options. This
|
|
713
|
+
* is what export pipelines (1 page = 1 file) consume, and it is also the
|
|
714
|
+
* building block `renderCanvas` composes when laying multiple pages out.
|
|
715
|
+
*/
|
|
716
|
+
|
|
717
|
+
/**
|
|
718
|
+
* Render a single page to self-contained HTML + CSS.
|
|
719
|
+
*
|
|
720
|
+
* The page's HTML output is identical to what `render(document)` produces
|
|
721
|
+
* for a document containing only this page — we route through `HtmlRenderer`
|
|
722
|
+
* so the existing renderer pipeline (themes, prefix, indentation, minify)
|
|
723
|
+
* applies uniformly.
|
|
724
|
+
*/
|
|
725
|
+
declare function renderPage(page: PageNode, options?: RenderOptions): PageRenderResult;
|
|
726
|
+
/**
|
|
727
|
+
* Resolve a page's pixel dimensions from explicit `w`/`h` or viewport/device.
|
|
728
|
+
*
|
|
729
|
+
* Mirrors the precedence used inside `HtmlRenderer.renderPage`:
|
|
730
|
+
* 1. Explicit numeric `w` and `h` both set → use them.
|
|
731
|
+
* 2. Otherwise resolve via viewport string / device preset.
|
|
732
|
+
*
|
|
733
|
+
* Non-numeric `w`/`h` (e.g. keyword `'full'` or `ValueWithUnit`) fall through
|
|
734
|
+
* to the viewport — those are layout-internal hints, not canvas dimensions.
|
|
735
|
+
*/
|
|
736
|
+
declare function resolvePageDimensions(page: PageNode): {
|
|
737
|
+
width: number;
|
|
738
|
+
height: number;
|
|
739
|
+
};
|
|
740
|
+
|
|
741
|
+
/**
|
|
742
|
+
* Canvas renderer — multi-page composition.
|
|
743
|
+
*
|
|
744
|
+
* `renderCanvas` lays out one or more pages on a single bounded canvas. The
|
|
745
|
+
* DSL stays page-centric — coordinates come from each page's optional
|
|
746
|
+
* `at(x, y)` attribute (resolved into `Page.x` / `Page.y` by the parser).
|
|
747
|
+
* Pages without coordinates auto-flow horizontally with `gap` between them.
|
|
748
|
+
*
|
|
749
|
+
* Output is intentionally minimal: a bounded `<div class="wf-canvas">` of the
|
|
750
|
+
* exact layout extent, containing absolutely-positioned `<div class="wf-canvas-board">`
|
|
751
|
+
* wrappers around each page's HTML. No chrome, no decoration, no grid, no
|
|
752
|
+
* labels. Hosts (dashboard editor, markdown plugin, VSCode preview) wrap this
|
|
753
|
+
* output in their own viewport / grid / pan-zoom layers.
|
|
754
|
+
*
|
|
755
|
+
* `layoutCanvas` is exposed as a pure utility so hosts that want to compose
|
|
756
|
+
* the canvas DOM themselves can reuse the placement math.
|
|
757
|
+
*/
|
|
758
|
+
|
|
759
|
+
interface PlacedPage {
|
|
760
|
+
page: PageNode;
|
|
761
|
+
x: number;
|
|
762
|
+
y: number;
|
|
763
|
+
w: number;
|
|
764
|
+
h: number;
|
|
765
|
+
}
|
|
766
|
+
/**
|
|
767
|
+
* Compute each page's position on the canvas and the bounding canvas size.
|
|
768
|
+
*
|
|
769
|
+
* Per-page mode:
|
|
770
|
+
* - `Page.x` / `Page.y` set → placed at exactly those coordinates.
|
|
771
|
+
* - Either missing → auto-flow: continues from the running cursor in a
|
|
772
|
+
* single horizontal row, advancing by `width + gap` after each
|
|
773
|
+
* auto-placed page. The cursor is unaffected by explicitly-placed pages.
|
|
774
|
+
*
|
|
775
|
+
* Mixed documents are allowed (ux-rules will warn) but explicit pages may
|
|
776
|
+
* overlap auto pages — that is the author's responsibility.
|
|
777
|
+
*/
|
|
778
|
+
declare function layoutCanvas(pages: PageNode[], gap?: number): {
|
|
779
|
+
placed: PlacedPage[];
|
|
780
|
+
width: number;
|
|
781
|
+
height: number;
|
|
782
|
+
};
|
|
783
|
+
/**
|
|
784
|
+
* Render a multi-page document to a single bounded canvas of HTML + CSS.
|
|
785
|
+
*
|
|
786
|
+
* Output: `<div class="wf-canvas" style="width:Wpx; height:Hpx; position:relative">`
|
|
787
|
+
* containing one `<div class="wf-canvas-board">` per page, absolutely
|
|
788
|
+
* positioned at the layout coordinates.
|
|
789
|
+
*/
|
|
790
|
+
declare function renderCanvas(doc: WireframeDocument, options?: CanvasOptions): CanvasRenderResult;
|
|
791
|
+
|
|
792
|
+
/**
|
|
793
|
+
* Interaction intent → HTML attributes.
|
|
794
|
+
*
|
|
795
|
+
* `navigate` / `opens` / `toggles` / `action` are the declared interaction
|
|
796
|
+
* intent of a wireframe element (see {@link InteractiveProps}). They are the
|
|
797
|
+
* only structural link between screens, so every consumer of rendered
|
|
798
|
+
* output — the studio runtime, the transition graph, a prototype harness —
|
|
799
|
+
* finds them by these four `data-*` names.
|
|
800
|
+
*
|
|
801
|
+
* This module is their single owner. The attribute names are written down
|
|
802
|
+
* exactly once, here; renderers ask for the record and never spell the names
|
|
803
|
+
* themselves. Before this existed the block was copy-pasted into five
|
|
804
|
+
* renderers, and the sixth (`navigation.ts`) simply never got a copy — nav,
|
|
805
|
+
* tab and breadcrumb items parsed their interaction intent and then dropped it
|
|
806
|
+
* on the floor, which is the failure mode this module exists to make
|
|
807
|
+
* impossible to repeat.
|
|
808
|
+
*
|
|
809
|
+
* `__tests__/renderer-interactive.test.ts` enforces the single-owner property:
|
|
810
|
+
* it fails if any other file under `src/renderer/` spells one of these names.
|
|
811
|
+
*/
|
|
812
|
+
|
|
813
|
+
/** The `data-*` attribute name carrying each interaction kind. */
|
|
814
|
+
declare const INTERACTIVE_ATTR_NAMES: readonly ["data-navigate", "data-opens", "data-toggles", "data-action"];
|
|
815
|
+
/** Internal: the shape of {@link InteractiveAttrs}'s keys. Consumers use that. */
|
|
816
|
+
type InteractiveAttrName = (typeof INTERACTIVE_ATTR_NAMES)[number];
|
|
817
|
+
/**
|
|
818
|
+
* Marks a `data-navigate` whose target is a URL rather than a page name.
|
|
819
|
+
*
|
|
820
|
+
* Only elements that are not anchors ever carry it: an anchor puts a URL in its
|
|
821
|
+
* `href` and emits no `data-navigate` at all, so there is nothing left to
|
|
822
|
+
* qualify. A button or a current-page `<span>` has no `href` to move the target
|
|
823
|
+
* into, so the URL travels in the data attribute — and without this marker every
|
|
824
|
+
* consumer would have to re-derive, from the string, the thing the renderer
|
|
825
|
+
* already worked out.
|
|
826
|
+
*
|
|
827
|
+
* That re-derivation is the point. {@link isUrlTarget} is a TypeScript predicate;
|
|
828
|
+
* the site runtime is generated JavaScript. A second copy of the rule over there
|
|
829
|
+
* is a drift surface by construction, and the two copies disagreeing means the
|
|
830
|
+
* runtime starts hunting for a screen named `https://…`. So the judgment is made
|
|
831
|
+
* once, here, at render time, and shipped as a fact the runtime only reads.
|
|
832
|
+
*
|
|
833
|
+
* The single-owner gate in `__tests__/renderer-interactive.test.ts` covers this
|
|
834
|
+
* name for free: it contains `data-navigate`, so any other file under
|
|
835
|
+
* `src/renderer/` that spells it is already an offender.
|
|
836
|
+
*/
|
|
837
|
+
declare const EXTERNAL_NAVIGATE_ATTR = "data-navigate-external";
|
|
838
|
+
/** Typed runtime markers, owned beside the legacy interaction attributes. */
|
|
839
|
+
declare const TYPED_INTERACTION_ATTR = "data-wf-on";
|
|
840
|
+
declare const VISIBLE_GUARD_ATTR = "data-wf-visible-when";
|
|
841
|
+
declare const ENABLED_GUARD_ATTR = "data-wf-enabled-when";
|
|
842
|
+
/**
|
|
843
|
+
* The `href` an anchor gets when it has no destination of its own.
|
|
844
|
+
*
|
|
845
|
+
* An anchor must have an `href` to be a link — focusable, keyboard-activatable,
|
|
846
|
+
* announced as a link — but a wireframe anchor usually has nowhere to go: its
|
|
847
|
+
* intent, if any, travels as `data-navigate` and names a screen, not a URL.
|
|
848
|
+
* `#` is the standard inert stand-in, and it is a *statement by the renderer*:
|
|
849
|
+
* this element's `href` carries no destination.
|
|
850
|
+
*
|
|
851
|
+
* It is exported because the site runtime needs to read that statement back.
|
|
852
|
+
* The browser's default action for `#` is a same-document navigation, and inside
|
|
853
|
+
* the `srcdoc` frame consumers mount the wireframe in, `#` resolves against the
|
|
854
|
+
* *embedder's* URL — so an unhandled click walks the frame out of the wireframe
|
|
855
|
+
* and loads the host app inside it. Measured on a 20-screen demo: 44 such
|
|
856
|
+
* anchors, frame URL `about:srcdoc` → `<host page>#`, host assets refetched.
|
|
857
|
+
*
|
|
858
|
+
* The runtime must therefore distinguish "inert" from "a real link the author
|
|
859
|
+
* asked for", and re-deriving that from the string over there is the drift
|
|
860
|
+
* surface {@link EXTERNAL_NAVIGATE_ATTR} exists to avoid. So the value is owned
|
|
861
|
+
* here and embedded into the generated script, like the attribute names.
|
|
862
|
+
*/
|
|
863
|
+
declare const INERT_HREF = "#";
|
|
864
|
+
/**
|
|
865
|
+
* Attribute record for one element; absent intents stay `undefined`.
|
|
866
|
+
*
|
|
867
|
+
* The marker is boolean because it carries no value of its own — it qualifies
|
|
868
|
+
* the target next to it. `buildAttrsString` renders `true` as `name="name"`,
|
|
869
|
+
* which is the form that survives the XML parsing of an SVG `foreignObject`.
|
|
870
|
+
*/
|
|
871
|
+
type InteractiveAttrs = Record<InteractiveAttrName, string | undefined> & Record<typeof EXTERNAL_NAVIGATE_ATTR, true | undefined> & Record<typeof TYPED_INTERACTION_ATTR | typeof VISIBLE_GUARD_ATTR | typeof ENABLED_GUARD_ATTR, string | undefined>;
|
|
872
|
+
/** Guard attributes accepted by ordinary nodes that do not carry events. */
|
|
873
|
+
declare function guardedOutcomeAttrs(node: Partial<GuardedOutcomeProps>): Record<typeof VISIBLE_GUARD_ATTR | typeof ENABLED_GUARD_ATTR, string | undefined>;
|
|
874
|
+
/**
|
|
875
|
+
* The interaction attributes of any node carrying {@link InteractiveProps}.
|
|
876
|
+
*
|
|
877
|
+
* The result is spread into a renderer's attribute record, or passed straight
|
|
878
|
+
* to `buildAttrsString` — which drops `undefined` entries, so an element with
|
|
879
|
+
* no declared intent emits nothing at all.
|
|
880
|
+
*
|
|
881
|
+
* Emission order is fixed (navigate, opens, toggles, action) so that rendered
|
|
882
|
+
* HTML stays byte-stable across runs; the marker sits next to the target it
|
|
883
|
+
* qualifies.
|
|
884
|
+
*/
|
|
885
|
+
declare function interactiveAttrs(node: Partial<InteractiveProps>): InteractiveAttrs;
|
|
886
|
+
/**
|
|
887
|
+
* The `href` and interaction attributes of an element rendered as an `<a>`.
|
|
888
|
+
*
|
|
889
|
+
* An anchor is the one element with two channels that can carry a destination,
|
|
890
|
+
* so it is the one element where they can contradict each other — and it is the
|
|
891
|
+
* only place the choice between them has to be made. Both halves of that choice
|
|
892
|
+
* are decided here so a renderer never has to know the rule:
|
|
893
|
+
*
|
|
894
|
+
* - An authored `href` is the anchor and is left exactly as written.
|
|
895
|
+
* - Otherwise a URL-shaped `navigate` (see {@link isUrlTarget}) becomes the
|
|
896
|
+
* `href`, and no `data-navigate` goes out beside it. A URL is not a screen:
|
|
897
|
+
* emitting both would hand a consumer two destinations for one element and
|
|
898
|
+
* send a runtime hunting for a screen named `https://…`.
|
|
899
|
+
* - Otherwise the `navigate` target names a page. The anchor stays inert `#` —
|
|
900
|
+
* `href="교환소 지도"` is a broken relative link — and the intent travels as
|
|
901
|
+
* `data-navigate` for the consumer that knows what pages are.
|
|
902
|
+
*
|
|
903
|
+
* When an `href` *and* a URL-shaped `navigate` are both authored, both are
|
|
904
|
+
* emitted unchanged: the element already has its destination, and quietly
|
|
905
|
+
* dropping the second one would hide a contradiction only the author can settle.
|
|
906
|
+
* Naming that conflict belongs to validation, not to rendering.
|
|
907
|
+
*
|
|
908
|
+
* Elements that are not anchors keep {@link interactiveAttrs}: with no `href` to
|
|
909
|
+
* move it into, a URL-shaped target has only the data attribute to travel in,
|
|
910
|
+
* and dropping it there would discard what the author wrote. Those are the
|
|
911
|
+
* elements {@link EXTERNAL_NAVIGATE_ATTR} exists for.
|
|
912
|
+
*/
|
|
913
|
+
declare function anchorIntent(node: Partial<InteractiveProps> & {
|
|
914
|
+
href?: string;
|
|
915
|
+
}): {
|
|
916
|
+
href: string;
|
|
917
|
+
attrs: InteractiveAttrs;
|
|
918
|
+
};
|
|
919
|
+
|
|
920
|
+
/**
|
|
921
|
+
* GENERATED FILE -- DO NOT EDIT.
|
|
922
|
+
*
|
|
923
|
+
* The icon dataset, generated from the installed `lucide` package by
|
|
924
|
+
* `scripts/generate-icons.mjs` (`pnpm build:icons`). Names kept beyond what
|
|
925
|
+
* lucide ships come from `scripts/icon-overrides.mjs`; add them there, never
|
|
926
|
+
* here, or the next regeneration deletes them.
|
|
927
|
+
*
|
|
928
|
+
* Total icons: 1667
|
|
929
|
+
*
|
|
930
|
+
* The lookup, alias and rendering code that consumes this lives in
|
|
931
|
+
* `./lucide-icons.ts` and is hand-written.
|
|
932
|
+
*
|
|
933
|
+
* @license ISC License
|
|
934
|
+
*
|
|
935
|
+
* Copyright (c) for portions of Lucide are held by Cole Bemis 2013-2023
|
|
936
|
+
* as part of Feather (MIT). All other copyright (c) for Lucide are held
|
|
937
|
+
* by Lucide Contributors 2025.
|
|
938
|
+
*
|
|
939
|
+
* Permission to use, copy, modify, and/or distribute this software for any
|
|
940
|
+
* purpose with or without fee is hereby granted, provided that the above
|
|
941
|
+
* copyright notice and this permission notice appear in all copies.
|
|
942
|
+
*
|
|
943
|
+
* @see https://lucide.dev
|
|
944
|
+
*/
|
|
945
|
+
type IconElement = [string, Record<string, string>];
|
|
946
|
+
type IconData = IconElement[];
|
|
947
|
+
declare const lucideIcons: Record<string, IconData>;
|
|
948
|
+
|
|
949
|
+
/**
|
|
950
|
+
* Icon lookup and SVG rendering.
|
|
951
|
+
*
|
|
952
|
+
* HAND-WRITTEN. The dataset this reads is generated -- see
|
|
953
|
+
* `./lucide-icons.generated.ts` and `scripts/generate-icons.mjs`. The two were
|
|
954
|
+
* a single file until the split: it carried an "Auto-generated ... Do not edit
|
|
955
|
+
* manually" header while the alias table, the alias branches in `getIconData`,
|
|
956
|
+
* the `renderIconSvg` signature and all of `renderUnknownIconSvg` below were
|
|
957
|
+
* added by hand, so running the generator would have destroyed working code
|
|
958
|
+
* that four renderers import. Data and code now have one owner each.
|
|
959
|
+
*
|
|
960
|
+
* The dataset's exports are re-exported here so `src/index.ts` can keep
|
|
961
|
+
* re-exporting this module and the public surface is unchanged.
|
|
962
|
+
*/
|
|
963
|
+
|
|
964
|
+
/**
|
|
965
|
+
* Get icon data by name.
|
|
966
|
+
*
|
|
967
|
+
* Resolution order is exact key, then alias, then camelCase folded to
|
|
968
|
+
* kebab-case, then that folded name through the aliases. A name that survives
|
|
969
|
+
* all four is not drawable, and the caller renders the placeholder below.
|
|
970
|
+
*/
|
|
971
|
+
declare function getIconData(name: string): IconData | undefined;
|
|
972
|
+
/**
|
|
973
|
+
* Render icon data to SVG string
|
|
974
|
+
*/
|
|
975
|
+
declare function renderIconSvg(data: IconData, _size?: number, // size is now controlled by CSS, this param is kept for API compatibility
|
|
976
|
+
strokeWidth?: number, className?: string, styleAttr?: string): string;
|
|
977
|
+
/**
|
|
978
|
+
* Render the canonical "unknown icon" placeholder SVG — a dashed circle with a
|
|
979
|
+
* `?` glyph. Shared by every renderer (icon node, button, input) so an
|
|
980
|
+
* unresolved icon name always produces the SAME visual placeholder and never
|
|
981
|
+
* leaks the raw DSL name as literal text. Callers add a
|
|
982
|
+
* `title="Unknown icon: <name>"` on the wrapping element for hover context.
|
|
983
|
+
*/
|
|
984
|
+
declare function renderUnknownIconSvg(className?: string, size?: number, styleAttr?: string): string;
|
|
985
|
+
|
|
986
|
+
/**
|
|
987
|
+
* Renderer module for wireweave
|
|
988
|
+
*
|
|
989
|
+
* Provides render functions to convert AST to HTML/CSS and SVG
|
|
990
|
+
*/
|
|
991
|
+
|
|
992
|
+
/**
|
|
993
|
+
* Render AST to HTML and CSS.
|
|
994
|
+
*
|
|
995
|
+
* Two modes, decided automatically by page count:
|
|
996
|
+
* 1. Multiple pages → canvas mode (bounded layout, absolutely-positioned
|
|
997
|
+
* boards). Hosts wrap this in their own viewport / grid / pan-zoom layer.
|
|
998
|
+
* 2. Single page → legacy mode (page only, no canvas wrapper) for
|
|
999
|
+
* backward compatibility with single-page consumers (markdown-plugin,
|
|
1000
|
+
* dashboard previews, vscode-extension).
|
|
1001
|
+
*
|
|
1002
|
+
* Use `renderPage(page)` for explicit single-page export, or
|
|
1003
|
+
* `renderCanvas(doc)` for explicit multi-page composition.
|
|
1004
|
+
*/
|
|
1005
|
+
declare function render(document: WireframeDocument, options?: RenderOptions | CanvasOptions): RenderResult;
|
|
1006
|
+
/**
|
|
1007
|
+
* Render AST to standalone HTML with embedded CSS
|
|
1008
|
+
*
|
|
1009
|
+
* @param document - Parsed wireframe document
|
|
1010
|
+
* @param options - Render options
|
|
1011
|
+
* @returns Complete HTML document string
|
|
1012
|
+
*/
|
|
1013
|
+
declare function renderToHtml(document: WireframeDocument, options?: RenderOptions): string;
|
|
1014
|
+
/**
|
|
1015
|
+
* Render AST to SVG using foreignObject with HTML+CSS
|
|
1016
|
+
*
|
|
1017
|
+
* This approach embeds HTML+CSS inside SVG using foreignObject,
|
|
1018
|
+
* which allows CSS flexbox/grid layouts to work properly.
|
|
1019
|
+
*
|
|
1020
|
+
* Multi-page documents are auto-rendered as a bounded canvas, with the
|
|
1021
|
+
* SVG viewBox sized to the canvas bounding box. Single-page documents
|
|
1022
|
+
* keep their legacy single-page sizing.
|
|
1023
|
+
*
|
|
1024
|
+
* @param document - Parsed wireframe document
|
|
1025
|
+
* @param options - SVG render options
|
|
1026
|
+
* @returns Object containing SVG string and dimensions
|
|
1027
|
+
*/
|
|
1028
|
+
declare function renderToSvg(document: WireframeDocument, options?: SvgRenderOptions): SvgRenderResult;
|
|
1029
|
+
declare function renderToSvg(document: LinkedApp, options: V4SvgProfile): V4SvgExportResult;
|
|
1030
|
+
|
|
1031
|
+
export { layoutCanvas as $, type InteractiveAttrs as A, type SiteModel as B, type CoreExportDiagnostic as C, type SiteScreen as D, type ExportOptions as E, type FigmaExportResult as F, type SiteShell as G, HtmlRenderer as H, INERT_HREF as I, type JsonExportResult as J, type V4ExportDiagnostic as K, type V4LinkedExportInput as L, type V4SvgArtifact as M, type V4SvgManifest as N, VISIBLE_GUARD_ATTR as O, type PlacedPage as P, anchorIntent as Q, buildSiteModel as R, type ShellMiss as S, TYPED_INTERACTION_ATTR as T, createHtmlRenderer as U, type V4SvgProfile as V, generateComponentStyles as W, generateStyles as X, getIconData as Y, guardedOutcomeAttrs as Z, interactiveAttrs as _, type JsonNode as a, lucideIcons as a0, render as a1, renderCanvas as a2, renderIconSvg as a3, renderPage as a4, renderToHtml as a5, renderToSvg as a6, renderUnknownIconSvg as a7, resolvePageDimensions as a8, type FigmaMappingProfile as b, type FigmaMappingExportResult as c, type V4SvgExportResult as d, ENABLED_GUARD_ATTR as e, EXTERNAL_NAVIGATE_ATTR as f, type ExportLoss as g, type FigmaAutoLayout as h, type FigmaColor as i, type FigmaCounterAxisAlign as j, type FigmaLayoutMode as k, type FigmaMappingArtifact as l, type FigmaNode as m, type FigmaNodeType as n, type FigmaPrimaryAxisAlign as o, type FigmaSemanticMapping as p, type FigmaSize as q, type FigmaSizingMode as r, type FigmaSolidFill as s, type FigmaStroke as t, type FigmaTextAlign as u, type FigmaTextStyle as v, type FigmaWireweaveMetadata as w, INTERACTIVE_ATTR_NAMES as x, type IconData as y, type IconElement as z };
|