@wireweave/core 3.1.0-beta.0 → 3.1.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +13421 -7417
- package/dist/index.d.cts +733 -116
- package/dist/index.d.ts +733 -116
- package/dist/index.js +13370 -7416
- package/dist/parser.cjs +2191 -972
- package/dist/parser.d.cts +1 -1
- package/dist/parser.d.ts +1 -1
- package/dist/parser.js +2191 -972
- package/dist/renderer.cjs +7168 -4406
- package/dist/renderer.d.cts +470 -10
- package/dist/renderer.d.ts +470 -10
- package/dist/renderer.js +7156 -4406
- package/dist/spec.cjs +2890 -0
- package/dist/spec.d.cts +372 -0
- package/dist/spec.d.ts +372 -0
- package/dist/spec.js +2842 -0
- package/dist/{types-C1kQ4VAF.d.cts → types-vhPCZpAW.d.cts} +307 -27
- package/dist/{types-C1kQ4VAF.d.ts → types-vhPCZpAW.d.ts} +307 -27
- package/package.json +55 -13
package/dist/renderer.d.cts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { be as WireframeDocument, h as AnyNode, as as PageNode, H as ComponentUseNode, aa as LayoutDefinitionNode, a8 as InteractiveProps, Y as GuardedOutcomeProps } from './types-vhPCZpAW.cjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Renderer type definitions for wireweave
|
|
5
5
|
*
|
|
6
6
|
* Provides types for rendering options, themes, and context
|
|
7
7
|
*/
|
|
8
|
+
/** Annotation presentation used by the renderer. */
|
|
9
|
+
type AnnotationStyle = 'legacy' | 'neutral';
|
|
8
10
|
interface RenderOptions {
|
|
9
11
|
/** Theme variant */
|
|
10
12
|
theme?: 'light' | 'dark';
|
|
@@ -18,6 +20,39 @@ interface RenderOptions {
|
|
|
18
20
|
classPrefix?: string;
|
|
19
21
|
/** Background color (e.g., '#ffffff', 'transparent') */
|
|
20
22
|
background?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Annotation presentation. Defaults to `legacy` so existing render output
|
|
25
|
+
* stays unchanged; use `neutral` for deterministic grayscale annotations.
|
|
26
|
+
*/
|
|
27
|
+
annotationStyle?: AnnotationStyle;
|
|
28
|
+
/**
|
|
29
|
+
* Emit source-anchor attributes (`data-wf-path` / `data-wf-loc`) on each
|
|
30
|
+
* rendered component element, enabling DOM ↔ AST ↔ source mapping. Default
|
|
31
|
+
* `false` — output is byte-identical to non-anchored rendering when off.
|
|
32
|
+
*/
|
|
33
|
+
sourceAnchors?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Prefix prepended to every DOM `id` this render emits.
|
|
36
|
+
*
|
|
37
|
+
* An authored `id` is unique inside the page that declares it and nowhere
|
|
38
|
+
* else, which is all a page needs while it is a document of its own. Compose
|
|
39
|
+
* several pages into one document and that stops being true: two screens
|
|
40
|
+
* declaring `confirm` produce two elements with the same id, and a duplicate
|
|
41
|
+
* id is not a rendering bug — the picture is right — but it is a lie told to
|
|
42
|
+
* every reader of the DOM. Devtools resolve it to the first match, the
|
|
43
|
+
* accessibility tree treats `aria-*` references as pointing at one element,
|
|
44
|
+
* and any external tool doing `#confirm` gets an arbitrary one of them.
|
|
45
|
+
*
|
|
46
|
+
* Default `''` — no prefix, so output is byte-identical to unscoped
|
|
47
|
+
* rendering when unset, which is what every existing entry point does.
|
|
48
|
+
* `renderSite` sets it per screen and per shell, because it is the one
|
|
49
|
+
* renderer that puts pages of different origin in the same document.
|
|
50
|
+
*
|
|
51
|
+
* Authored intent is not rewritten: the interaction attributes that point at
|
|
52
|
+
* an overlay keep the name their author wrote, and their consumer composes
|
|
53
|
+
* the scope back on. The prefix belongs to identity, not to intent.
|
|
54
|
+
*/
|
|
55
|
+
idScope?: string;
|
|
21
56
|
}
|
|
22
57
|
interface RenderResult {
|
|
23
58
|
/** Rendered HTML content */
|
|
@@ -152,7 +187,12 @@ declare abstract class BaseRenderer {
|
|
|
152
187
|
*/
|
|
153
188
|
render(document: WireframeDocument): RenderResult;
|
|
154
189
|
/**
|
|
155
|
-
* Render a complete wireframe document
|
|
190
|
+
* Render a complete wireframe document.
|
|
191
|
+
*
|
|
192
|
+
* Only pages are drawn. A document's top level also holds `layout` and
|
|
193
|
+
* `component` definitions, which are reusable fragments a page refers to —
|
|
194
|
+
* drawing one would put a screen on the canvas that the author never wrote a
|
|
195
|
+
* page for, and would do it the moment the reuse feature was used at all.
|
|
156
196
|
*/
|
|
157
197
|
protected renderDocument(document: WireframeDocument): string;
|
|
158
198
|
/**
|
|
@@ -179,6 +219,20 @@ declare abstract class BaseRenderer {
|
|
|
179
219
|
* Escape HTML special characters
|
|
180
220
|
*/
|
|
181
221
|
protected escapeHtml(text: string): string;
|
|
222
|
+
/**
|
|
223
|
+
* The DOM id an authored id becomes under this render's `idScope`.
|
|
224
|
+
*
|
|
225
|
+
* One function so that "what is the id in the document" has one answer. A
|
|
226
|
+
* renderer that prefixed at some emission sites and not others would produce
|
|
227
|
+
* a document where `#confirm` resolves for one element and `#s0-confirm` for
|
|
228
|
+
* another, which is worse than either convention alone.
|
|
229
|
+
*
|
|
230
|
+
* Only identity is prefixed. The interaction attributes that point at an
|
|
231
|
+
* overlay still carry the name their author wrote — they are spelled in one
|
|
232
|
+
* file (`html/interactive.ts`) and read by whoever consumes them, which
|
|
233
|
+
* composes the scope back on. See `RenderOptions.idScope`.
|
|
234
|
+
*/
|
|
235
|
+
protected scopedId(id: string): string;
|
|
182
236
|
/**
|
|
183
237
|
* Build a CSS class string from an array of class names
|
|
184
238
|
*/
|
|
@@ -213,7 +267,30 @@ declare class HtmlRenderer extends BaseRenderer {
|
|
|
213
267
|
* Node type to renderer method mapping
|
|
214
268
|
*/
|
|
215
269
|
private readonly nodeRenderers;
|
|
216
|
-
|
|
270
|
+
/**
|
|
271
|
+
* Node → anchor-path map for the document currently being rendered. Non-null
|
|
272
|
+
* only while rendering with `sourceAnchors` enabled.
|
|
273
|
+
*/
|
|
274
|
+
private pathMap;
|
|
275
|
+
/**
|
|
276
|
+
* Base index added to page anchor paths. Non-zero when a page is rendered in
|
|
277
|
+
* isolation (canvas per-page composition) but must keep its true document
|
|
278
|
+
* index in the anchor scheme.
|
|
279
|
+
*/
|
|
280
|
+
private readonly pageIndexBase;
|
|
281
|
+
/**
|
|
282
|
+
* HTML the next `slot` renders, or `null` when there is none to place.
|
|
283
|
+
*
|
|
284
|
+
* Set for the duration of one `renderFragment` call and consumed by the first
|
|
285
|
+
* slot reached, so it never leaks into an unrelated render.
|
|
286
|
+
*/
|
|
287
|
+
private slotContent;
|
|
288
|
+
constructor(options?: RenderOptions, pageIndexBase?: number);
|
|
289
|
+
/**
|
|
290
|
+
* Render a document, building the anchor-path map first when anchors are
|
|
291
|
+
* enabled so `renderNode` / `renderPage` can inject each node's path.
|
|
292
|
+
*/
|
|
293
|
+
render(document: WireframeDocument): RenderResult;
|
|
217
294
|
/**
|
|
218
295
|
* Get render context for external renderer functions
|
|
219
296
|
*/
|
|
@@ -234,6 +311,45 @@ declare class HtmlRenderer extends BaseRenderer {
|
|
|
234
311
|
* Render any AST node
|
|
235
312
|
*/
|
|
236
313
|
protected renderNode(node: AnyNode): string;
|
|
314
|
+
/**
|
|
315
|
+
* Render the `slot` of a layout — the position a page's content is placed at.
|
|
316
|
+
*
|
|
317
|
+
* The element is always emitted, filled or not. A layout is a shell, and a
|
|
318
|
+
* shell keeps its shape whether or not something is currently inside it;
|
|
319
|
+
* collapsing the slot away when empty would make the frame reflow between an
|
|
320
|
+
* isolated render of the layout and a composed one.
|
|
321
|
+
*/
|
|
322
|
+
protected renderSlot(): string;
|
|
323
|
+
/**
|
|
324
|
+
* Render one linked component invocation with its stable instance marker.
|
|
325
|
+
*
|
|
326
|
+
* The wrapper is identified by `data-` attributes and carries no class. It
|
|
327
|
+
* declares `display: contents`, so by construction it has no box of its own
|
|
328
|
+
* and its children lay out as though it were not there — which is the whole
|
|
329
|
+
* point: an invocation must not disturb the layout of what it expands to.
|
|
330
|
+
* A class is the hook a stylesheet paints a box through, and any rule that
|
|
331
|
+
* gave this one a box would defeat `display: contents`; there is therefore
|
|
332
|
+
* no style it could ever legitimately carry. It emitted
|
|
333
|
+
* `${this.prefix}-component-instance` regardless, which no rule in the
|
|
334
|
+
* generated CSS defined and nothing read — a class the markup advertises as
|
|
335
|
+
* styleable while the stylesheet leaves it undefined. Identity that exists
|
|
336
|
+
* to be *queried* rather than *painted* belongs in `data-`, alongside the
|
|
337
|
+
* `data-wf-component` / `data-wf-instance` pair already carrying it.
|
|
338
|
+
*/
|
|
339
|
+
protected renderComponentUse(node: ComponentUseNode): string;
|
|
340
|
+
/**
|
|
341
|
+
* Render a list of nodes with no page frame around them.
|
|
342
|
+
*
|
|
343
|
+
* The frame — viewport size, background, the CSS reset every component
|
|
344
|
+
* depends on — belongs to whatever is composing these nodes. `renderSite`
|
|
345
|
+
* uses this twice per shell: once for the layout's own markup, where
|
|
346
|
+
* `slotContent` is the screens that live in it, and once per screen for that
|
|
347
|
+
* page's body.
|
|
348
|
+
*
|
|
349
|
+
* @param nodes - Nodes to render, in order
|
|
350
|
+
* @param slotContent - HTML placed inside the first `slot` encountered
|
|
351
|
+
*/
|
|
352
|
+
renderFragment(nodes: AnyNode[], slotContent?: string | null): string;
|
|
237
353
|
/**
|
|
238
354
|
* Render children nodes
|
|
239
355
|
*/
|
|
@@ -354,7 +470,7 @@ declare function createHtmlRenderer(options?: RenderOptions): HtmlRenderer;
|
|
|
354
470
|
* @param prefix - CSS class prefix (default: 'wf')
|
|
355
471
|
* @returns Complete CSS string
|
|
356
472
|
*/
|
|
357
|
-
declare function generateStyles(theme: ThemeConfig, prefix?: string): string;
|
|
473
|
+
declare function generateStyles(theme: ThemeConfig, prefix?: string, annotationStyle?: AnnotationStyle): string;
|
|
358
474
|
|
|
359
475
|
/**
|
|
360
476
|
* Component-specific CSS styles for wireweave
|
|
@@ -368,7 +484,7 @@ declare function generateStyles(theme: ThemeConfig, prefix?: string): string;
|
|
|
368
484
|
/**
|
|
369
485
|
* Generate all component-specific CSS styles
|
|
370
486
|
*/
|
|
371
|
-
declare function generateComponentStyles(_theme: ThemeConfig, prefix?: string): string;
|
|
487
|
+
declare function generateComponentStyles(_theme: ThemeConfig, prefix?: string, annotationStyle?: AnnotationStyle): string;
|
|
372
488
|
|
|
373
489
|
/**
|
|
374
490
|
* Page renderer — single-Page primitive.
|
|
@@ -455,12 +571,325 @@ declare function layoutCanvas(pages: PageNode[], gap?: number): {
|
|
|
455
571
|
declare function renderCanvas(doc: WireframeDocument, options?: CanvasOptions): CanvasRenderResult;
|
|
456
572
|
|
|
457
573
|
/**
|
|
458
|
-
*
|
|
574
|
+
* The screen model behind `renderSite` — which pages become screens, which
|
|
575
|
+
* shell each one is drawn inside, and what names address it.
|
|
576
|
+
*
|
|
577
|
+
* Nothing here renders. It answers three questions the site renderer and its
|
|
578
|
+
* inline runtime both need the *same* answer to, so the answer is computed once
|
|
579
|
+
* and handed to both.
|
|
580
|
+
*
|
|
581
|
+
* ## Totality
|
|
582
|
+
*
|
|
583
|
+
* A wireframe document can name a layout that does not exist, declare two pages
|
|
584
|
+
* with the same `id`, or use a layout with no `slot`. None of those is a parse
|
|
585
|
+
* error (see the note on `WireframeDocument`), so none of them may stop a
|
|
586
|
+
* render either: every function here is total. Where a document is ambiguous
|
|
587
|
+
* the rule is always **first-wins in document order** — the same rule
|
|
588
|
+
* `extract/transitions.ts` already applies to titles — and the loser is not
|
|
589
|
+
* dropped silently: it is rendered with a `data-wf-*` marker naming what went
|
|
590
|
+
* unmet, so a reader of the output can see it and `validation/` can report it
|
|
591
|
+
* with a source location.
|
|
592
|
+
*/
|
|
593
|
+
|
|
594
|
+
/** Why a page that declared `uses=` is not composed into a shell after all. */
|
|
595
|
+
type ShellMiss =
|
|
596
|
+
/** No `layout` in the document carries that name. */
|
|
597
|
+
'unknown-layout'
|
|
598
|
+
/** The layout exists but has no `slot`, so it has nowhere to put a page. */
|
|
599
|
+
| 'slotless-layout';
|
|
600
|
+
/** One page, as a screen of the composed document. */
|
|
601
|
+
interface SiteScreen {
|
|
602
|
+
/** Position in `documentPages(doc)`. This is the screen's DOM key. */
|
|
603
|
+
index: number;
|
|
604
|
+
page: PageNode;
|
|
605
|
+
/**
|
|
606
|
+
* The variant this screen draws, when its page came from a `variants=` list.
|
|
607
|
+
*
|
|
608
|
+
* Read off the page rather than derived here: `expandVariants` has already
|
|
609
|
+
* turned one variant-bearing page into one page per variant by the time a
|
|
610
|
+
* model is built, so each of those pages is a screen like any other and this
|
|
611
|
+
* only records which one it is.
|
|
612
|
+
*/
|
|
613
|
+
variant?: string;
|
|
614
|
+
/** Name of the shell this screen is composed into, when it has one. */
|
|
615
|
+
shell?: string;
|
|
616
|
+
/** Set when `uses=` was declared and could not be honoured. */
|
|
617
|
+
miss?: {
|
|
618
|
+
uses: string;
|
|
619
|
+
reason: ShellMiss;
|
|
620
|
+
};
|
|
621
|
+
/**
|
|
622
|
+
* The public name this screen *owns* — the name that resolves to it.
|
|
623
|
+
*
|
|
624
|
+
* Absent when the page declared no name, and also when every name it declared
|
|
625
|
+
* is already owned by an earlier page. A screen without a name is still
|
|
626
|
+
* reachable: its index addresses it.
|
|
627
|
+
*/
|
|
628
|
+
name?: string;
|
|
629
|
+
}
|
|
630
|
+
/** One layout, emitted once, hosting every screen that uses it. */
|
|
631
|
+
interface SiteShell {
|
|
632
|
+
/** The `layout <name>` identifier, which `uses=` addresses. */
|
|
633
|
+
name: string;
|
|
634
|
+
layout: LayoutDefinitionNode;
|
|
635
|
+
/** Screens composed into this shell, in document order. */
|
|
636
|
+
screens: SiteScreen[];
|
|
637
|
+
/**
|
|
638
|
+
* Frame size of the shell, resolved from its first screen's page.
|
|
639
|
+
*
|
|
640
|
+
* A layout has no viewport of its own — it is the pages that declare one — so
|
|
641
|
+
* the first page to use it fixes the frame. A later page resolving to a
|
|
642
|
+
* different size is a conflict the author has to settle; it is marked on that
|
|
643
|
+
* screen rather than resized, because silently stretching one page's frame to
|
|
644
|
+
* another's is the kind of change that is invisible until a screenshot.
|
|
645
|
+
*/
|
|
646
|
+
width: number;
|
|
647
|
+
height: number;
|
|
648
|
+
}
|
|
649
|
+
interface SiteModel {
|
|
650
|
+
screens: SiteScreen[];
|
|
651
|
+
/** Shells in first-use order — the order pages first reference them. */
|
|
652
|
+
shells: SiteShell[];
|
|
653
|
+
/**
|
|
654
|
+
* Every name that addresses a screen → that screen's index.
|
|
655
|
+
*
|
|
656
|
+
* Built exactly like `extract/transitions.ts` resolves `navigate`: the `id`
|
|
657
|
+
* namespace is consulted before the `title` namespace, and within each
|
|
658
|
+
* namespace the first page in document order wins. A `navigate` target and a
|
|
659
|
+
* URL fragment therefore land on the same screen the transition graph says
|
|
660
|
+
* they do — one resolution rule, two consumers.
|
|
661
|
+
*/
|
|
662
|
+
names: Map<string, number>;
|
|
663
|
+
/** Screen shown when no fragment selects one. `-1` for a document with no pages. */
|
|
664
|
+
entry: number;
|
|
665
|
+
}
|
|
666
|
+
/**
|
|
667
|
+
* Derive the screen model of a document.
|
|
668
|
+
*
|
|
669
|
+
* Pure and deterministic: same document in, same model out, whatever the
|
|
670
|
+
* document contains.
|
|
671
|
+
*/
|
|
672
|
+
declare function buildSiteModel(doc: WireframeDocument): SiteModel;
|
|
673
|
+
|
|
674
|
+
/**
|
|
675
|
+
* `renderSite` — a whole wireframe document as one navigable HTML file.
|
|
676
|
+
*
|
|
677
|
+
* The other renderers answer "what does this screen look like". This one
|
|
678
|
+
* answers "what does this product look like": every page of a document, the
|
|
679
|
+
* shells they share, and the moves between them, in a single file with no
|
|
680
|
+
* server, no build step and no dependencies. Open it and click.
|
|
681
|
+
*
|
|
682
|
+
* ## What makes it one document rather than N concatenated
|
|
683
|
+
*
|
|
684
|
+
* Three things exist once, however many screens there are:
|
|
685
|
+
*
|
|
686
|
+
* - **the stylesheet** — component styles are generated per document, not per
|
|
687
|
+
* page, so N screens cost one copy instead of N;
|
|
688
|
+
* - **the runtime** — one inline script drives every screen;
|
|
689
|
+
* - **each layout** — a `layout` referenced by `uses=` is emitted once, and
|
|
690
|
+
* every page using it is hosted inside that one copy at the `slot` position.
|
|
691
|
+
*
|
|
692
|
+
* The third is the one that has to be structural. Emitting a copy of the shell
|
|
693
|
+
* per screen and hiding all but one with CSS produces the same picture while
|
|
694
|
+
* keeping every byte the shared shell exists to remove; the shell is therefore
|
|
695
|
+
* shared in the DOM, and only screens are switched.
|
|
696
|
+
*
|
|
697
|
+
* ## Ids under composition
|
|
698
|
+
*
|
|
699
|
+
* An authored `id` is unique inside the page that declares it. Once several
|
|
700
|
+
* pages share a document that guarantee is gone, so every screen and every
|
|
701
|
+
* shell renders under an id scope of its own and the runtime composes the scope
|
|
702
|
+
* with the authored name when it looks an overlay up. Two screens can both
|
|
703
|
+
* declare `confirm` and each opens its own.
|
|
704
|
+
*
|
|
705
|
+
* ## What is left alone
|
|
706
|
+
*
|
|
707
|
+
* A page with no `uses=` renders exactly as `renderPage` renders it, frame and
|
|
708
|
+
* all, as its own screen. That is the whole corpus today, so composition is
|
|
709
|
+
* something a document opts into and nothing changes shape without being asked.
|
|
710
|
+
*
|
|
711
|
+
* `render` / `renderToHtml` / `renderCanvas` / `renderToSvg` are untouched:
|
|
712
|
+
* `renderSite` is a fifth entry point beside them, not a mode of them.
|
|
713
|
+
*/
|
|
714
|
+
|
|
715
|
+
/**
|
|
716
|
+
* Options for {@link renderSite}.
|
|
717
|
+
*
|
|
718
|
+
* A subset of {@link RenderOptions}: `includeStyles` is meaningless for a
|
|
719
|
+
* standalone document that has nowhere else to get its styles from, and
|
|
720
|
+
* `sourceAnchors` is omitted because an anchor path names a node's position
|
|
721
|
+
* under one page — a shell belongs to every page that uses it and has no single
|
|
722
|
+
* such position, so the scheme has nothing true to say about it.
|
|
723
|
+
*/
|
|
724
|
+
interface SiteOptions extends Pick<RenderOptions, 'theme' | 'classPrefix' | 'background' | 'annotationStyle'> {
|
|
725
|
+
/** `<title>` of the produced document. Defaults to the entry page's title. */
|
|
726
|
+
title?: string;
|
|
727
|
+
/**
|
|
728
|
+
* The screen shown when the URL carries no fragment.
|
|
729
|
+
*
|
|
730
|
+
* Named the way everything else names a screen — an `id` or a `title`, put
|
|
731
|
+
* through {@link SiteModel.names}, so a caller writes the same string here
|
|
732
|
+
* that it would write in a `navigate=` and lands on the same page. Taking an
|
|
733
|
+
* index instead would make the option depend on document order, which is the
|
|
734
|
+
* one thing a caller holding a screen name does not know.
|
|
735
|
+
*
|
|
736
|
+
* Defaults to the first page in document order. A name that addresses no
|
|
737
|
+
* screen leaves that default in place and is marked on the site container as
|
|
738
|
+
* `data-wf-entry-unresolved`, the way an unmet `uses=` is marked on its
|
|
739
|
+
* screen: the request stays visible in the artefact instead of disappearing
|
|
740
|
+
* between the call and the HTML.
|
|
741
|
+
*/
|
|
742
|
+
entry?: string;
|
|
743
|
+
}
|
|
744
|
+
/**
|
|
745
|
+
* Render a whole document as one navigable, self-contained HTML file.
|
|
746
|
+
*
|
|
747
|
+
* @param document - Parsed wireframe document
|
|
748
|
+
* @param options - Site render options
|
|
749
|
+
* @returns A complete HTML document, ready to write to disk and open
|
|
750
|
+
*/
|
|
751
|
+
declare function renderSite(document: WireframeDocument, options?: SiteOptions): string;
|
|
752
|
+
|
|
753
|
+
/**
|
|
754
|
+
* Interaction intent → HTML attributes.
|
|
755
|
+
*
|
|
756
|
+
* `navigate` / `opens` / `toggles` / `action` are the declared interaction
|
|
757
|
+
* intent of a wireframe element (see {@link InteractiveProps}). They are the
|
|
758
|
+
* only structural link between screens, so every consumer of rendered
|
|
759
|
+
* output — the studio runtime, the transition graph, a prototype harness —
|
|
760
|
+
* finds them by these four `data-*` names.
|
|
761
|
+
*
|
|
762
|
+
* This module is their single owner. The attribute names are written down
|
|
763
|
+
* exactly once, here; renderers ask for the record and never spell the names
|
|
764
|
+
* themselves. Before this existed the block was copy-pasted into five
|
|
765
|
+
* renderers, and the sixth (`navigation.ts`) simply never got a copy — nav,
|
|
766
|
+
* tab and breadcrumb items parsed their interaction intent and then dropped it
|
|
767
|
+
* on the floor, which is the failure mode this module exists to make
|
|
768
|
+
* impossible to repeat.
|
|
769
|
+
*
|
|
770
|
+
* `__tests__/renderer-interactive.test.ts` enforces the single-owner property:
|
|
771
|
+
* it fails if any other file under `src/renderer/` spells one of these names.
|
|
772
|
+
*/
|
|
773
|
+
|
|
774
|
+
/** The `data-*` attribute name carrying each interaction kind. */
|
|
775
|
+
declare const INTERACTIVE_ATTR_NAMES: readonly ["data-navigate", "data-opens", "data-toggles", "data-action"];
|
|
776
|
+
/** Internal: the shape of {@link InteractiveAttrs}'s keys. Consumers use that. */
|
|
777
|
+
type InteractiveAttrName = (typeof INTERACTIVE_ATTR_NAMES)[number];
|
|
778
|
+
/**
|
|
779
|
+
* Marks a `data-navigate` whose target is a URL rather than a page name.
|
|
780
|
+
*
|
|
781
|
+
* Only elements that are not anchors ever carry it: an anchor puts a URL in its
|
|
782
|
+
* `href` and emits no `data-navigate` at all, so there is nothing left to
|
|
783
|
+
* qualify. A button or a current-page `<span>` has no `href` to move the target
|
|
784
|
+
* into, so the URL travels in the data attribute — and without this marker every
|
|
785
|
+
* consumer would have to re-derive, from the string, the thing the renderer
|
|
786
|
+
* already worked out.
|
|
787
|
+
*
|
|
788
|
+
* That re-derivation is the point. {@link isUrlTarget} is a TypeScript predicate;
|
|
789
|
+
* the site runtime is generated JavaScript. A second copy of the rule over there
|
|
790
|
+
* is a drift surface by construction, and the two copies disagreeing means the
|
|
791
|
+
* runtime starts hunting for a screen named `https://…`. So the judgment is made
|
|
792
|
+
* once, here, at render time, and shipped as a fact the runtime only reads.
|
|
793
|
+
*
|
|
794
|
+
* The single-owner gate in `__tests__/renderer-interactive.test.ts` covers this
|
|
795
|
+
* name for free: it contains `data-navigate`, so any other file under
|
|
796
|
+
* `src/renderer/` that spells it is already an offender.
|
|
797
|
+
*/
|
|
798
|
+
declare const EXTERNAL_NAVIGATE_ATTR = "data-navigate-external";
|
|
799
|
+
/** Typed runtime markers, owned beside the legacy interaction attributes. */
|
|
800
|
+
declare const TYPED_INTERACTION_ATTR = "data-wf-on";
|
|
801
|
+
declare const VISIBLE_GUARD_ATTR = "data-wf-visible-when";
|
|
802
|
+
declare const ENABLED_GUARD_ATTR = "data-wf-enabled-when";
|
|
803
|
+
/**
|
|
804
|
+
* The `href` an anchor gets when it has no destination of its own.
|
|
805
|
+
*
|
|
806
|
+
* An anchor must have an `href` to be a link — focusable, keyboard-activatable,
|
|
807
|
+
* announced as a link — but a wireframe anchor usually has nowhere to go: its
|
|
808
|
+
* intent, if any, travels as `data-navigate` and names a screen, not a URL.
|
|
809
|
+
* `#` is the standard inert stand-in, and it is a *statement by the renderer*:
|
|
810
|
+
* this element's `href` carries no destination.
|
|
811
|
+
*
|
|
812
|
+
* It is exported because the site runtime needs to read that statement back.
|
|
813
|
+
* The browser's default action for `#` is a same-document navigation, and inside
|
|
814
|
+
* the `srcdoc` frame consumers mount the wireframe in, `#` resolves against the
|
|
815
|
+
* *embedder's* URL — so an unhandled click walks the frame out of the wireframe
|
|
816
|
+
* and loads the host app inside it. Measured on a 20-screen demo: 44 such
|
|
817
|
+
* anchors, frame URL `about:srcdoc` → `<host page>#`, host assets refetched.
|
|
818
|
+
*
|
|
819
|
+
* The runtime must therefore distinguish "inert" from "a real link the author
|
|
820
|
+
* asked for", and re-deriving that from the string over there is the drift
|
|
821
|
+
* surface {@link EXTERNAL_NAVIGATE_ATTR} exists to avoid. So the value is owned
|
|
822
|
+
* here and embedded into the generated script, like the attribute names.
|
|
823
|
+
*/
|
|
824
|
+
declare const INERT_HREF = "#";
|
|
825
|
+
/**
|
|
826
|
+
* Attribute record for one element; absent intents stay `undefined`.
|
|
827
|
+
*
|
|
828
|
+
* The marker is boolean because it carries no value of its own — it qualifies
|
|
829
|
+
* the target next to it. `buildAttrsString` renders `true` as `name="name"`,
|
|
830
|
+
* which is the form that survives the XML parsing of an SVG `foreignObject`.
|
|
831
|
+
*/
|
|
832
|
+
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>;
|
|
833
|
+
/** Guard attributes accepted by ordinary nodes that do not carry events. */
|
|
834
|
+
declare function guardedOutcomeAttrs(node: Partial<GuardedOutcomeProps>): Record<typeof VISIBLE_GUARD_ATTR | typeof ENABLED_GUARD_ATTR, string | undefined>;
|
|
835
|
+
/**
|
|
836
|
+
* The interaction attributes of any node carrying {@link InteractiveProps}.
|
|
837
|
+
*
|
|
838
|
+
* The result is spread into a renderer's attribute record, or passed straight
|
|
839
|
+
* to `buildAttrsString` — which drops `undefined` entries, so an element with
|
|
840
|
+
* no declared intent emits nothing at all.
|
|
841
|
+
*
|
|
842
|
+
* Emission order is fixed (navigate, opens, toggles, action) so that rendered
|
|
843
|
+
* HTML stays byte-stable across runs; the marker sits next to the target it
|
|
844
|
+
* qualifies.
|
|
845
|
+
*/
|
|
846
|
+
declare function interactiveAttrs(node: Partial<InteractiveProps>): InteractiveAttrs;
|
|
847
|
+
/**
|
|
848
|
+
* The `href` and interaction attributes of an element rendered as an `<a>`.
|
|
849
|
+
*
|
|
850
|
+
* An anchor is the one element with two channels that can carry a destination,
|
|
851
|
+
* so it is the one element where they can contradict each other — and it is the
|
|
852
|
+
* only place the choice between them has to be made. Both halves of that choice
|
|
853
|
+
* are decided here so a renderer never has to know the rule:
|
|
854
|
+
*
|
|
855
|
+
* - An authored `href` is the anchor and is left exactly as written.
|
|
856
|
+
* - Otherwise a URL-shaped `navigate` (see {@link isUrlTarget}) becomes the
|
|
857
|
+
* `href`, and no `data-navigate` goes out beside it. A URL is not a screen:
|
|
858
|
+
* emitting both would hand a consumer two destinations for one element and
|
|
859
|
+
* send a runtime hunting for a screen named `https://…`.
|
|
860
|
+
* - Otherwise the `navigate` target names a page. The anchor stays inert `#` —
|
|
861
|
+
* `href="교환소 지도"` is a broken relative link — and the intent travels as
|
|
862
|
+
* `data-navigate` for the consumer that knows what pages are.
|
|
863
|
+
*
|
|
864
|
+
* When an `href` *and* a URL-shaped `navigate` are both authored, both are
|
|
865
|
+
* emitted unchanged: the element already has its destination, and quietly
|
|
866
|
+
* dropping the second one would hide a contradiction only the author can settle.
|
|
867
|
+
* Naming that conflict belongs to validation, not to rendering.
|
|
868
|
+
*
|
|
869
|
+
* Elements that are not anchors keep {@link interactiveAttrs}: with no `href` to
|
|
870
|
+
* move it into, a URL-shaped target has only the data attribute to travel in,
|
|
871
|
+
* and dropping it there would discard what the author wrote. Those are the
|
|
872
|
+
* elements {@link EXTERNAL_NAVIGATE_ATTR} exists for.
|
|
873
|
+
*/
|
|
874
|
+
declare function anchorIntent(node: Partial<InteractiveProps> & {
|
|
875
|
+
href?: string;
|
|
876
|
+
}): {
|
|
877
|
+
href: string;
|
|
878
|
+
attrs: InteractiveAttrs;
|
|
879
|
+
};
|
|
880
|
+
|
|
881
|
+
/**
|
|
882
|
+
* GENERATED FILE -- DO NOT EDIT.
|
|
459
883
|
*
|
|
460
|
-
*
|
|
461
|
-
*
|
|
884
|
+
* The icon dataset, generated from the installed `lucide` package by
|
|
885
|
+
* `scripts/generate-icons.mjs` (`pnpm build:icons`). Names kept beyond what
|
|
886
|
+
* lucide ships come from `scripts/icon-overrides.mjs`; add them there, never
|
|
887
|
+
* here, or the next regeneration deletes them.
|
|
462
888
|
*
|
|
463
|
-
* Total icons:
|
|
889
|
+
* Total icons: 1667
|
|
890
|
+
*
|
|
891
|
+
* The lookup, alias and rendering code that consumes this lives in
|
|
892
|
+
* `./lucide-icons.ts` and is hand-written.
|
|
464
893
|
*
|
|
465
894
|
* @license ISC License
|
|
466
895
|
*
|
|
@@ -477,12 +906,43 @@ declare function renderCanvas(doc: WireframeDocument, options?: CanvasOptions):
|
|
|
477
906
|
type IconElement = [string, Record<string, string>];
|
|
478
907
|
type IconData = IconElement[];
|
|
479
908
|
declare const lucideIcons: Record<string, IconData>;
|
|
909
|
+
|
|
910
|
+
/**
|
|
911
|
+
* Icon lookup and SVG rendering.
|
|
912
|
+
*
|
|
913
|
+
* HAND-WRITTEN. The dataset this reads is generated -- see
|
|
914
|
+
* `./lucide-icons.generated.ts` and `scripts/generate-icons.mjs`. The two were
|
|
915
|
+
* a single file until the split: it carried an "Auto-generated ... Do not edit
|
|
916
|
+
* manually" header while the alias table, the alias branches in `getIconData`,
|
|
917
|
+
* the `renderIconSvg` signature and all of `renderUnknownIconSvg` below were
|
|
918
|
+
* added by hand, so running the generator would have destroyed working code
|
|
919
|
+
* that four renderers import. Data and code now have one owner each.
|
|
920
|
+
*
|
|
921
|
+
* The dataset's exports are re-exported here so `src/index.ts` can keep
|
|
922
|
+
* re-exporting this module and the public surface is unchanged.
|
|
923
|
+
*/
|
|
924
|
+
|
|
925
|
+
/**
|
|
926
|
+
* Get icon data by name.
|
|
927
|
+
*
|
|
928
|
+
* Resolution order is exact key, then alias, then camelCase folded to
|
|
929
|
+
* kebab-case, then that folded name through the aliases. A name that survives
|
|
930
|
+
* all four is not drawable, and the caller renders the placeholder below.
|
|
931
|
+
*/
|
|
480
932
|
declare function getIconData(name: string): IconData | undefined;
|
|
481
933
|
/**
|
|
482
934
|
* Render icon data to SVG string
|
|
483
935
|
*/
|
|
484
936
|
declare function renderIconSvg(data: IconData, _size?: number, // size is now controlled by CSS, this param is kept for API compatibility
|
|
485
937
|
strokeWidth?: number, className?: string, styleAttr?: string): string;
|
|
938
|
+
/**
|
|
939
|
+
* Render the canonical "unknown icon" placeholder SVG — a dashed circle with a
|
|
940
|
+
* `?` glyph. Shared by every renderer (icon node, button, input) so an
|
|
941
|
+
* unresolved icon name always produces the SAME visual placeholder and never
|
|
942
|
+
* leaks the raw DSL name as literal text. Callers add a
|
|
943
|
+
* `title="Unknown icon: <name>"` on the wrapping element for hover context.
|
|
944
|
+
*/
|
|
945
|
+
declare function renderUnknownIconSvg(className?: string, size?: number, styleAttr?: string): string;
|
|
486
946
|
|
|
487
947
|
/**
|
|
488
948
|
* Renderer module for wireweave
|
|
@@ -528,4 +988,4 @@ declare function renderToHtml(document: WireframeDocument, options?: RenderOptio
|
|
|
528
988
|
*/
|
|
529
989
|
declare function renderToSvg(document: WireframeDocument, options?: SvgRenderOptions): SvgRenderResult;
|
|
530
990
|
|
|
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 };
|
|
991
|
+
export { type AnnotationStyle, type CanvasOptions, type CanvasRenderResult, ENABLED_GUARD_ATTR, EXTERNAL_NAVIGATE_ATTR, HtmlRenderer, INERT_HREF, INTERACTIVE_ATTR_NAMES, type IconData, type IconElement, type InteractiveAttrs, type PageRenderResult, type PlacedPage, type RenderContext, type RenderOptions, type RenderResult, type ShellMiss, type SiteModel, type SiteOptions, type SiteScreen, type SiteShell, type SvgRenderOptions, type SvgRenderResult, TYPED_INTERACTION_ATTR, type ThemeColors, type ThemeConfig, VISIBLE_GUARD_ATTR, anchorIntent, buildSiteModel, createHtmlRenderer, darkTheme, defaultTheme, generateComponentStyles, generateStyles, getIconData, getTheme, guardedOutcomeAttrs, interactiveAttrs, layoutCanvas, lucideIcons, render, renderCanvas, renderIconSvg, renderPage, renderSite, renderToHtml, renderToSvg, renderUnknownIconSvg, resolvePageDimensions };
|