@wireweave/core 3.1.0-beta.8 → 3.1.0-beta.9
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 +187 -3
- package/dist/index.d.cts +104 -3
- package/dist/index.d.ts +104 -3
- package/dist/index.js +184 -3
- package/dist/parser.d.cts +1 -1
- package/dist/parser.d.ts +1 -1
- package/dist/renderer.cjs +123 -3
- package/dist/renderer.d.cts +1 -1
- package/dist/renderer.d.ts +1 -1
- package/dist/renderer.js +123 -3
- package/dist/spec.cjs +21 -1
- package/dist/spec.js +21 -1
- package/dist/{types-DfiCKOPE.d.cts → types-vhPCZpAW.d.cts} +34 -2
- package/dist/{types-DfiCKOPE.d.ts → types-vhPCZpAW.d.ts} +34 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -83,6 +83,8 @@ __export(src_exports, {
|
|
|
83
83
|
extractAllScreenFields: () => extractAllScreenFields,
|
|
84
84
|
extractScreenFields: () => extractScreenFields,
|
|
85
85
|
extractScreenTransitions: () => extractScreenTransitions,
|
|
86
|
+
filterUnscopedPages: () => filterUnscopedPages,
|
|
87
|
+
filterVariantScope: () => filterVariantScope,
|
|
86
88
|
find: () => find,
|
|
87
89
|
findAll: () => findAll,
|
|
88
90
|
findByType: () => findByType,
|
|
@@ -195,6 +197,7 @@ __export(src_exports, {
|
|
|
195
197
|
resolveViewport: () => resolveViewport,
|
|
196
198
|
tryParse: () => tryParse,
|
|
197
199
|
validate: () => validate,
|
|
200
|
+
variantScope: () => variantScope,
|
|
198
201
|
walk: () => walk,
|
|
199
202
|
walkDocument: () => walkDocument,
|
|
200
203
|
wrapInPreviewContainer: () => wrapInPreviewContainer
|
|
@@ -635,6 +638,102 @@ function expandRepeats(document) {
|
|
|
635
638
|
};
|
|
636
639
|
}
|
|
637
640
|
|
|
641
|
+
// src/ast/filter-variant-scope.ts
|
|
642
|
+
function variantScope(node) {
|
|
643
|
+
const declared = node.when;
|
|
644
|
+
if (declared === void 0) return void 0;
|
|
645
|
+
const raw = Array.isArray(declared) ? declared : [declared];
|
|
646
|
+
const seen = /* @__PURE__ */ new Set();
|
|
647
|
+
const names = [];
|
|
648
|
+
for (const item of raw) {
|
|
649
|
+
if (typeof item !== "string") continue;
|
|
650
|
+
const name = item.trim();
|
|
651
|
+
if (name.length === 0 || seen.has(name)) continue;
|
|
652
|
+
seen.add(name);
|
|
653
|
+
names.push(name);
|
|
654
|
+
}
|
|
655
|
+
return names;
|
|
656
|
+
}
|
|
657
|
+
function childList(value) {
|
|
658
|
+
const children = value?.children;
|
|
659
|
+
return Array.isArray(children) ? children : void 0;
|
|
660
|
+
}
|
|
661
|
+
function asNode(value) {
|
|
662
|
+
return value !== null && typeof value === "object" && "type" in value ? value : void 0;
|
|
663
|
+
}
|
|
664
|
+
function filterChildList(children, variant) {
|
|
665
|
+
return children.flatMap((child) => {
|
|
666
|
+
const node = asNode(child);
|
|
667
|
+
if (node === void 0) return [child];
|
|
668
|
+
const kept = filterNode(node, variant);
|
|
669
|
+
return kept === void 0 ? [] : [kept];
|
|
670
|
+
});
|
|
671
|
+
}
|
|
672
|
+
function containsScope(node) {
|
|
673
|
+
if (node.when !== void 0) return true;
|
|
674
|
+
for (const child of childList(node) ?? []) {
|
|
675
|
+
const nested = asNode(child);
|
|
676
|
+
if (nested !== void 0 && containsScope(nested)) return true;
|
|
677
|
+
}
|
|
678
|
+
const fills = node.fills;
|
|
679
|
+
if (Array.isArray(fills)) {
|
|
680
|
+
for (const fill of fills) {
|
|
681
|
+
for (const child of childList(fill) ?? []) {
|
|
682
|
+
const nested = asNode(child);
|
|
683
|
+
if (nested !== void 0 && containsScope(nested)) return true;
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
return false;
|
|
688
|
+
}
|
|
689
|
+
function filterNode(node, variant) {
|
|
690
|
+
const scope = variantScope(node);
|
|
691
|
+
if (scope !== void 0) {
|
|
692
|
+
if (variant === void 0 || !scope.includes(variant)) return void 0;
|
|
693
|
+
}
|
|
694
|
+
const nested = containsScope(node);
|
|
695
|
+
if (scope === void 0 && !nested) return node;
|
|
696
|
+
const result = {};
|
|
697
|
+
for (const [key, value] of Object.entries(node)) {
|
|
698
|
+
if (key === "when") continue;
|
|
699
|
+
result[key] = value;
|
|
700
|
+
}
|
|
701
|
+
const children = childList(node);
|
|
702
|
+
if (children !== void 0) {
|
|
703
|
+
result.children = filterChildList(children, variant);
|
|
704
|
+
}
|
|
705
|
+
const fills = node.fills;
|
|
706
|
+
if (Array.isArray(fills)) {
|
|
707
|
+
result.fills = fills.map((fill) => {
|
|
708
|
+
const fillChildren = childList(fill);
|
|
709
|
+
if (fillChildren === void 0) return fill;
|
|
710
|
+
return {
|
|
711
|
+
...fill,
|
|
712
|
+
children: filterChildList(fillChildren, variant)
|
|
713
|
+
};
|
|
714
|
+
});
|
|
715
|
+
}
|
|
716
|
+
return result;
|
|
717
|
+
}
|
|
718
|
+
function filterVariantScope(children, variant) {
|
|
719
|
+
if (!children.some((child) => containsScope(child))) return children;
|
|
720
|
+
return children.flatMap((child) => {
|
|
721
|
+
const kept = filterNode(child, variant);
|
|
722
|
+
return kept === void 0 ? [] : [kept];
|
|
723
|
+
});
|
|
724
|
+
}
|
|
725
|
+
function filterUnscopedPages(document) {
|
|
726
|
+
let changed = false;
|
|
727
|
+
const children = document.children.map((child) => {
|
|
728
|
+
if (child.type !== "Page" || child.variant !== void 0) return child;
|
|
729
|
+
const filtered = filterVariantScope(child.children, void 0);
|
|
730
|
+
if (filtered === child.children) return child;
|
|
731
|
+
changed = true;
|
|
732
|
+
return { ...child, children: filtered };
|
|
733
|
+
});
|
|
734
|
+
return changed ? { ...document, children } : document;
|
|
735
|
+
}
|
|
736
|
+
|
|
638
737
|
// src/ast/expand-variants.ts
|
|
639
738
|
function cloneNode3(value) {
|
|
640
739
|
if (Array.isArray(value)) return value.map(cloneNode3);
|
|
@@ -664,18 +763,22 @@ function hasVariants(document) {
|
|
|
664
763
|
return document.children.some((child) => child.type === "Page" && variantNames(child).length > 0);
|
|
665
764
|
}
|
|
666
765
|
function expandVariants(document) {
|
|
667
|
-
if (!hasVariants(document)) return document;
|
|
766
|
+
if (!hasVariants(document)) return filterUnscopedPages(document);
|
|
668
767
|
return {
|
|
669
768
|
...document,
|
|
670
769
|
children: document.children.flatMap((child) => {
|
|
671
770
|
if (child.type !== "Page") return [child];
|
|
672
771
|
const names = variantNames(child);
|
|
673
|
-
if (names.length === 0)
|
|
772
|
+
if (names.length === 0) {
|
|
773
|
+
const filtered = filterVariantScope(child.children, void 0);
|
|
774
|
+
return [filtered === child.children ? child : { ...child, children: filtered }];
|
|
775
|
+
}
|
|
674
776
|
return names.map((variant, position) => {
|
|
675
777
|
const clone = cloneNode3(child);
|
|
676
778
|
delete clone.variants;
|
|
677
779
|
clone.variant = variant;
|
|
678
780
|
if (position > 0) delete clone.states;
|
|
781
|
+
clone.children = filterVariantScope(clone.children, variant);
|
|
679
782
|
return clone;
|
|
680
783
|
});
|
|
681
784
|
})
|
|
@@ -13373,6 +13476,11 @@ var ATTRIBUTE_SPECS = [
|
|
|
13373
13476
|
type: "string[]",
|
|
13374
13477
|
description: "Named state variants of this page \u2014 each one renders the page again as a screen of its own"
|
|
13375
13478
|
},
|
|
13479
|
+
{
|
|
13480
|
+
name: "when",
|
|
13481
|
+
type: "string[]",
|
|
13482
|
+
description: "Variant boards this element is drawn on \u2014 when=loading, or when=[loading, empty] for both"
|
|
13483
|
+
},
|
|
13376
13484
|
{
|
|
13377
13485
|
name: "id",
|
|
13378
13486
|
type: "string",
|
|
@@ -13418,6 +13526,13 @@ var BOX_ATTRIBUTES = [
|
|
|
13418
13526
|
// Guarded runtime outcomes
|
|
13419
13527
|
"visibleWhen",
|
|
13420
13528
|
"enabledWhen",
|
|
13529
|
+
// Build-time variant scope. Listed beside the guards because it reads like
|
|
13530
|
+
// them and is deliberately not one of them: a guard leaves the element in the
|
|
13531
|
+
// markup for the runtime to toggle, `when` decides whether the element is in
|
|
13532
|
+
// that board's markup at all. Every element takes it for the same reason
|
|
13533
|
+
// every element takes a guard — which boards a piece of a screen belongs to
|
|
13534
|
+
// is a property of the piece, not of what kind of piece it is.
|
|
13535
|
+
"when",
|
|
13421
13536
|
// Spacing
|
|
13422
13537
|
"p",
|
|
13423
13538
|
"px",
|
|
@@ -13480,7 +13595,15 @@ var COMPONENT_METADATA = {
|
|
|
13480
13595
|
// board that path renders *into* — nothing emits the attribute for it and
|
|
13481
13596
|
// nothing would toggle it, so declaring it would let an author write a
|
|
13482
13597
|
// guard on a page, pass `validate()`, and have the value silently dropped.
|
|
13483
|
-
|
|
13598
|
+
// `when` is filtered out alongside the guards, for a reason of its own: a
|
|
13599
|
+
// page *is* a board, so scoping one to a variant would be a board saying
|
|
13600
|
+
// which board it is drawn on. The axis a page declares is `variants`, and
|
|
13601
|
+
// `when` names positions along it — the two sit at different levels and a
|
|
13602
|
+
// page carrying both would be asking `expandVariants` to filter a page
|
|
13603
|
+
// against a name it is itself the source of.
|
|
13604
|
+
...BOX_ATTRIBUTES.filter(
|
|
13605
|
+
(name) => name !== "visibleWhen" && name !== "enabledWhen" && name !== "when"
|
|
13606
|
+
),
|
|
13484
13607
|
...CONTAINER_ATTRIBUTES,
|
|
13485
13608
|
"id",
|
|
13486
13609
|
"title",
|
|
@@ -63712,6 +63835,63 @@ function checkDuplicateDeclarations(ast, addError) {
|
|
|
63712
63835
|
}
|
|
63713
63836
|
return true;
|
|
63714
63837
|
}
|
|
63838
|
+
function checkVariantScopes(ast, addError) {
|
|
63839
|
+
const children = ast.children ?? [];
|
|
63840
|
+
for (let index = 0; index < children.length; index++) {
|
|
63841
|
+
const page = children[index];
|
|
63842
|
+
if (page?.type !== "Page") continue;
|
|
63843
|
+
const declared = new Set(
|
|
63844
|
+
(Array.isArray(page.variants) ? page.variants : []).filter((name) => typeof name === "string").map((name) => name.trim()).filter((name) => name.length > 0)
|
|
63845
|
+
);
|
|
63846
|
+
const visit = (node, path, inherited) => {
|
|
63847
|
+
const scope = variantScope(node);
|
|
63848
|
+
let reachable = inherited;
|
|
63849
|
+
if (scope !== void 0) {
|
|
63850
|
+
const unknown = scope.filter((name) => !declared.has(name));
|
|
63851
|
+
if (unknown.length > 0) {
|
|
63852
|
+
const message = declared.size === 0 ? `Unknown variant ${unknown.map((n) => `"${n}"`).join(", ")} in when= \u2014 this page declares no variants=, so the element is drawn on no board` : `Unknown variant ${unknown.map((n) => `"${n}"`).join(", ")} in when= \u2014 this page declares [${[...declared].join(", ")}]`;
|
|
63853
|
+
if (!addError({
|
|
63854
|
+
message,
|
|
63855
|
+
path,
|
|
63856
|
+
nodeType: node.type,
|
|
63857
|
+
attribute: "when",
|
|
63858
|
+
location: node.loc ? { line: node.loc.start.line, column: node.loc.start.column } : void 0
|
|
63859
|
+
})) {
|
|
63860
|
+
return false;
|
|
63861
|
+
}
|
|
63862
|
+
}
|
|
63863
|
+
const named = new Set(scope.filter((name) => declared.has(name)));
|
|
63864
|
+
reachable = inherited === void 0 ? named : new Set([...named].filter((n) => inherited.has(n)));
|
|
63865
|
+
if (unknown.length === 0 && inherited !== void 0 && reachable.size === 0) {
|
|
63866
|
+
if (!addError({
|
|
63867
|
+
message: `Contradictory when= [${scope.join(", ")}] \u2014 an enclosing element is scoped to [${[...inherited].join(", ")}], so no board draws both and this element is never rendered`,
|
|
63868
|
+
path,
|
|
63869
|
+
nodeType: node.type,
|
|
63870
|
+
attribute: "when",
|
|
63871
|
+
location: node.loc ? { line: node.loc.start.line, column: node.loc.start.column } : void 0
|
|
63872
|
+
})) {
|
|
63873
|
+
return false;
|
|
63874
|
+
}
|
|
63875
|
+
}
|
|
63876
|
+
}
|
|
63877
|
+
const kids = "children" in node && Array.isArray(node.children) ? node.children : [];
|
|
63878
|
+
for (let i = 0; i < kids.length; i++) {
|
|
63879
|
+
const child = kids[i];
|
|
63880
|
+
if (child && typeof child === "object" && "type" in child) {
|
|
63881
|
+
if (!visit(child, `${path}.children[${i}]`, reachable)) return false;
|
|
63882
|
+
}
|
|
63883
|
+
}
|
|
63884
|
+
return true;
|
|
63885
|
+
};
|
|
63886
|
+
for (let i = 0; i < page.children.length; i++) {
|
|
63887
|
+
const child = page.children[i];
|
|
63888
|
+
if (child && typeof child === "object" && "type" in child) {
|
|
63889
|
+
if (!visit(child, `pages[${index}].children[${i}]`, void 0)) return false;
|
|
63890
|
+
}
|
|
63891
|
+
}
|
|
63892
|
+
}
|
|
63893
|
+
return true;
|
|
63894
|
+
}
|
|
63715
63895
|
function checkDuplicateElementIds(ast, addError) {
|
|
63716
63896
|
const CONTEXT_OF = {
|
|
63717
63897
|
Page: "page",
|
|
@@ -63992,6 +64172,7 @@ function validate(ast, options = {}) {
|
|
|
63992
64172
|
}
|
|
63993
64173
|
if (shouldContinue) shouldContinue = checkComponentContracts(ast, addError);
|
|
63994
64174
|
if (shouldContinue) shouldContinue = checkDuplicateDeclarations(ast, addError);
|
|
64175
|
+
if (shouldContinue) shouldContinue = checkVariantScopes(ast, addError);
|
|
63995
64176
|
if (shouldContinue) checkDuplicateElementIds(ast, addError);
|
|
63996
64177
|
const valid = errors.length === 0;
|
|
63997
64178
|
return {
|
|
@@ -66022,6 +66203,8 @@ function linkAndCompileApp(manifest, modules, options = {}) {
|
|
|
66022
66203
|
extractAllScreenFields,
|
|
66023
66204
|
extractScreenFields,
|
|
66024
66205
|
extractScreenTransitions,
|
|
66206
|
+
filterUnscopedPages,
|
|
66207
|
+
filterVariantScope,
|
|
66025
66208
|
find,
|
|
66026
66209
|
findAll,
|
|
66027
66210
|
findByType,
|
|
@@ -66134,6 +66317,7 @@ function linkAndCompileApp(manifest, modules, options = {}) {
|
|
|
66134
66317
|
resolveViewport,
|
|
66135
66318
|
tryParse,
|
|
66136
66319
|
validate,
|
|
66320
|
+
variantScope,
|
|
66137
66321
|
walk,
|
|
66138
66322
|
walkDocument,
|
|
66139
66323
|
wrapInPreviewContainer
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { h as AnyNode, A as AccordionNode, a as AlertNode, j as AvatarNode, B as BadgeNode, r as BreadcrumbNode, s as ButtonNode, C as CardNode, w as CheckboxNode, x as ColNode, z as ComponentDefinitionNode, H as ComponentUseNode, I as ContainerComponentNode, J as ContainerNode, K as DataNode, L as DefinitionNode, N as DisplayNode, O as DividerComponentNode, P as DrawerNode, S as DropdownNode, T as FeedbackNode, V as FooterNode, W as GridNode, Z as HeaderNode, $ as IconNode, a2 as ImageNode, a3 as InputComponentNode, a4 as InputNode, aa as LayoutDefinitionNode, ab as LayoutNode, ac as LeafNode, ad as LinkNode, af as ListNode, ag as MainNode, aj as ModalNode, ao as NavNode, ap as NavigationNode, aq as NodeType, ar as OverlayNode, as as PageNode, at as PlaceholderNode, au as PopoverNode, ax as ProgressNode, ay as RadioNode, aB as RowNode, aC as SectionNode, aD as SelectNode, aG as SidebarNode, aI as SliderNode, aJ as SlotNode, aN as SpinnerNode, aV as SwitchNode, aX as TableNode, aY as TabsNode, a_ as TextContentNode, a$ as TextNode, b3 as TextareaNode, b5 as TitleNode, b6 as ToastNode, b8 as TooltipNode,
|
|
2
|
-
export { b as AlertVariant, c as AlignValue, d as AnchorPosition, e as AnnotationItemNode, f as AnnotationNode, g as AnnotationsNode, i as AppearanceProps, k as AvatarSize, l as AvatarSizeToken, m as BadgeSize, n as BadgeSizeToken, o as BadgeVariant, p as BaseNode, q as BreadcrumbItem, t as ButtonSize, u as ButtonSizeToken, v as ButtonVariant, y as CommonProps, D as ComponentInputValue, E as ComponentParameter, F as ComponentParameterType, G as ComponentSlotFill, M as DirectionValue, Q as DrawerPosition, R as DropdownItemNode, U as FlexProps, X as GridProps, Y as GuardedOutcomeProps, _ as HeightValue, a0 as IconSize, a1 as IconSizeToken, a7 as InteractionHandler, a8 as InteractiveProps, a9 as JustifyValue, ae as ListItemNode, ah as MarkerColor, ai as MarkerNode, ak as NavBlockItem, al as NavChild, am as NavGroupNode, an as NavItem, av as Position, aw as PositionProps, az as RelativeNode, aA as RepeatNode, aE as SelectOption, aF as ShadowValue, aH as SizeProps, aL as SpacingProps, aM as SpacingValue, aO as SpinnerSize, aP as SpinnerSizeToken, aQ as StackNode, aT as StateValue, aU as StateValueType, aW as TabNode, aZ as TextAlign, b0 as TextSize, b1 as TextSizeToken, b2 as TextWeight, b4 as TitleLevel, b7 as ToastPosition, b9 as TooltipPosition, ba as TopLevelNode, bb as ValueWithUnit, bc as WidthValue } from './types-
|
|
1
|
+
import { h as AnyNode, A as AccordionNode, a as AlertNode, j as AvatarNode, B as BadgeNode, r as BreadcrumbNode, s as ButtonNode, C as CardNode, w as CheckboxNode, x as ColNode, z as ComponentDefinitionNode, H as ComponentUseNode, I as ContainerComponentNode, J as ContainerNode, K as DataNode, L as DefinitionNode, N as DisplayNode, O as DividerComponentNode, P as DrawerNode, S as DropdownNode, T as FeedbackNode, V as FooterNode, W as GridNode, Z as HeaderNode, $ as IconNode, a2 as ImageNode, a3 as InputComponentNode, a4 as InputNode, aa as LayoutDefinitionNode, ab as LayoutNode, ac as LeafNode, ad as LinkNode, af as ListNode, ag as MainNode, aj as ModalNode, ao as NavNode, ap as NavigationNode, aq as NodeType, ar as OverlayNode, as as PageNode, at as PlaceholderNode, au as PopoverNode, ax as ProgressNode, ay as RadioNode, aB as RowNode, aC as SectionNode, aD as SelectNode, aG as SidebarNode, aI as SliderNode, aJ as SlotNode, aN as SpinnerNode, aV as SwitchNode, aX as TableNode, aY as TabsNode, a_ as TextContentNode, a$ as TextNode, b3 as TextareaNode, b5 as TitleNode, b6 as ToastNode, b8 as TooltipNode, be as WireframeDocument, aK as SourceLocation, aR as StateDeclaration, aS as StateGuard, a6 as InteractionEffect, a5 as InputType } from './types-vhPCZpAW.cjs';
|
|
2
|
+
export { b as AlertVariant, c as AlignValue, d as AnchorPosition, e as AnnotationItemNode, f as AnnotationNode, g as AnnotationsNode, i as AppearanceProps, k as AvatarSize, l as AvatarSizeToken, m as BadgeSize, n as BadgeSizeToken, o as BadgeVariant, p as BaseNode, q as BreadcrumbItem, t as ButtonSize, u as ButtonSizeToken, v as ButtonVariant, y as CommonProps, D as ComponentInputValue, E as ComponentParameter, F as ComponentParameterType, G as ComponentSlotFill, M as DirectionValue, Q as DrawerPosition, R as DropdownItemNode, U as FlexProps, X as GridProps, Y as GuardedOutcomeProps, _ as HeightValue, a0 as IconSize, a1 as IconSizeToken, a7 as InteractionHandler, a8 as InteractiveProps, a9 as JustifyValue, ae as ListItemNode, ah as MarkerColor, ai as MarkerNode, ak as NavBlockItem, al as NavChild, am as NavGroupNode, an as NavItem, av as Position, aw as PositionProps, az as RelativeNode, aA as RepeatNode, aE as SelectOption, aF as ShadowValue, aH as SizeProps, aL as SpacingProps, aM as SpacingValue, aO as SpinnerSize, aP as SpinnerSizeToken, aQ as StackNode, aT as StateValue, aU as StateValueType, aW as TabNode, aZ as TextAlign, b0 as TextSize, b1 as TextSizeToken, b2 as TextWeight, b4 as TitleLevel, b7 as ToastPosition, b9 as TooltipPosition, ba as TopLevelNode, bb as ValueWithUnit, bc as VariantScopedProps, bd as WidthValue } from './types-vhPCZpAW.cjs';
|
|
3
3
|
export { ExpectedToken, ParseError, ParseErrorInfo, ParseOptions, ParseResult, getErrors, isValid, parse, tryParse } from './parser.cjs';
|
|
4
4
|
import { SiteOptions } from './renderer.cjs';
|
|
5
5
|
export { AnnotationStyle, CanvasOptions, CanvasRenderResult, ENABLED_GUARD_ATTR, EXTERNAL_NAVIGATE_ATTR, HtmlRenderer, INERT_HREF, INTERACTIVE_ATTR_NAMES, IconData, IconElement, InteractiveAttrs, PageRenderResult, PlacedPage, RenderContext, RenderOptions, RenderResult, ShellMiss, SiteModel, SiteScreen, SiteShell, SvgRenderOptions, SvgRenderResult, TYPED_INTERACTION_ATTR, ThemeColors, 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 } from './renderer.cjs';
|
|
@@ -393,6 +393,107 @@ declare function expandRepeats(document: WireframeDocument): WireframeDocument;
|
|
|
393
393
|
*/
|
|
394
394
|
declare function expandVariants(document: WireframeDocument): WireframeDocument;
|
|
395
395
|
|
|
396
|
+
/**
|
|
397
|
+
* `when=` filtering — dropping the elements a board does not draw.
|
|
398
|
+
*
|
|
399
|
+
* ## What `when` says, and why it is not a guard
|
|
400
|
+
*
|
|
401
|
+
* `visibleWhen` already answers "should this be on screen right now": the
|
|
402
|
+
* element is rendered onto every board, carries `data-wf-visible-when`, and the
|
|
403
|
+
* site runtime shows and hides it as state changes. `when` answers a different
|
|
404
|
+
* question — *which boards is this element part of at all* — and it answers it
|
|
405
|
+
* before anything renders. An element scoped to `loading` is not hidden on the
|
|
406
|
+
* `ready` board; it is absent from it, so no state change can bring it back and
|
|
407
|
+
* nothing in that board's markup refers to it.
|
|
408
|
+
*
|
|
409
|
+
* The two are therefore orthogonal, not alternatives, and this pass is careful
|
|
410
|
+
* to leave guards alone: it deletes `when` from the nodes it keeps and touches
|
|
411
|
+
* no other property, so `when=ready visibleWhen={…}` survives as a guard on the
|
|
412
|
+
* ready board. Collapsing them would lose the case the feature exists for.
|
|
413
|
+
*
|
|
414
|
+
* ## Why disjunction is the point
|
|
415
|
+
*
|
|
416
|
+
* A guard compares one state to one value, so a block belonging to two
|
|
417
|
+
* conditions could only be written twice. That is not a stylistic cost: the two
|
|
418
|
+
* copies are edited separately and drift, and a reviewer reading the sheet
|
|
419
|
+
* cannot tell whether a difference between them is intentional. `when=[loading,
|
|
420
|
+
* empty]` is the same block, authored once, drawn on both boards — the header
|
|
421
|
+
* shared by three states is one header, and it stays one.
|
|
422
|
+
*
|
|
423
|
+
* ## Why it runs inside variant expansion
|
|
424
|
+
*
|
|
425
|
+
* Filtering needs to know which board it is filtering *for*, and that fact
|
|
426
|
+
* exists only after `expandVariants` has turned one authored page into one page
|
|
427
|
+
* per name and stamped each with `page.variant`. Running as a separate pass
|
|
428
|
+
* afterwards would have to rediscover the same association by walking the
|
|
429
|
+
* document again; running before expansion would have no board to ask about.
|
|
430
|
+
* So the board is filtered at the moment it is cloned, while the name is in
|
|
431
|
+
* hand — see `expand-variants.ts`.
|
|
432
|
+
*
|
|
433
|
+
* ## The rule, stated once
|
|
434
|
+
*
|
|
435
|
+
* An element is drawn on a board **iff its `when` set contains that board's
|
|
436
|
+
* variant**. Everything else follows from that one sentence rather than from a
|
|
437
|
+
* list of cases:
|
|
438
|
+
*
|
|
439
|
+
* - No `when` at all → drawn on every board. This is what keeps every document
|
|
440
|
+
* written before the attribute existed rendering byte-for-byte as it did.
|
|
441
|
+
* - A board with no variant (a page that declared no `variants=`) matches no
|
|
442
|
+
* name, so *any* `when` filters the element out. That is the honest reading
|
|
443
|
+
* rather than a convenient one: the element declares membership in a board
|
|
444
|
+
* this page never declared, and drawing it anyway would make `when` mean
|
|
445
|
+
* "sometimes nothing", which is the silently-dropped-value failure the spec
|
|
446
|
+
* gates exist to prevent. `validate()` reports the same document, so the
|
|
447
|
+
* author is told rather than left to discover an empty board.
|
|
448
|
+
* - A parent that is filtered out takes its children with it, whatever they
|
|
449
|
+
* say. A child scoped to `ready` inside a parent scoped to `loading` cannot
|
|
450
|
+
* be drawn on either board — there is no board where both are present — and
|
|
451
|
+
* the contradiction is reported by `validate()` rather than resolved here.
|
|
452
|
+
*/
|
|
453
|
+
|
|
454
|
+
/**
|
|
455
|
+
* The variant names an element declares, trimmed, blanks and duplicates dropped.
|
|
456
|
+
*
|
|
457
|
+
* Both spellings collapse to the same set, because `when=loading` and
|
|
458
|
+
* `when=[loading]` denote the same membership and nothing downstream should
|
|
459
|
+
* have to know which the author typed.
|
|
460
|
+
*
|
|
461
|
+
* A `when` that is present but names nothing — `when=[]`, or a blank string —
|
|
462
|
+
* yields an empty set, which matches no board. It is deliberately not treated
|
|
463
|
+
* as "no `when`": the author wrote the attribute, and answering an empty list
|
|
464
|
+
* with "every board" would make the emptiest possible scope the widest one.
|
|
465
|
+
*/
|
|
466
|
+
declare function variantScope(node: AnyNode): string[] | undefined;
|
|
467
|
+
/**
|
|
468
|
+
* Drop from `children` everything not drawn on `variant`'s board.
|
|
469
|
+
*
|
|
470
|
+
* Identity-preserving: a subtree carrying no `when` anywhere is returned as the
|
|
471
|
+
* same array, so a board of a document that uses no scoping costs one scan.
|
|
472
|
+
*
|
|
473
|
+
* @param children - The board's children, already cloned by variant expansion
|
|
474
|
+
* @param variant - The board's variant name, or `undefined` for an unnamed board
|
|
475
|
+
* @returns The children this board draws
|
|
476
|
+
* @internal
|
|
477
|
+
*/
|
|
478
|
+
declare function filterVariantScope(children: AnyNode[], variant: string | undefined): AnyNode[];
|
|
479
|
+
/**
|
|
480
|
+
* Apply `when` filtering to every page of a document that expansion did not.
|
|
481
|
+
*
|
|
482
|
+
* Variant-bearing pages are filtered as they are cloned, inside
|
|
483
|
+
* `expandVariants`, because that is where the board's name exists. This covers
|
|
484
|
+
* the rest: a page that declared no `variants=` is still a board, an unnamed
|
|
485
|
+
* one, and an element scoped to a name it never declared is not drawn on it.
|
|
486
|
+
*
|
|
487
|
+
* Layout and component definitions are filtered through the pages that use
|
|
488
|
+
* them, not here — a definition has no board of its own, and scoping inside one
|
|
489
|
+
* resolves against whichever page pulled it in.
|
|
490
|
+
*
|
|
491
|
+
* @param document - A document whose variant-bearing pages are already expanded
|
|
492
|
+
* @returns The document with unnamed boards filtered
|
|
493
|
+
* @internal
|
|
494
|
+
*/
|
|
495
|
+
declare function filterUnscopedPages(document: WireframeDocument): WireframeDocument;
|
|
496
|
+
|
|
396
497
|
/**
|
|
397
498
|
* Node/document-level canonical `.wf` printing.
|
|
398
499
|
*
|
|
@@ -1807,4 +1908,4 @@ declare function compileApp(document: AppDocument, options?: CompileAppOptions):
|
|
|
1807
1908
|
*/
|
|
1808
1909
|
declare function linkAndCompileApp(manifest: AppManifest, modules: readonly AppModuleInput[], options?: CompileAppOptions): AppCompileResult;
|
|
1809
1910
|
|
|
1810
|
-
export { ANCHOR_LOC_ATTR, ANCHOR_PATH_ATTR, type AccessibilityMetrics, AccordionNode, AlertNode, type AnalysisOptions, type AnalysisResult, type AnchorEntry, AnyNode, type AppCompileResult, type AppComponentInput, type AppComponentInstanceId, type AppDefinitionKind, type AppDocument, type AppLayoutInput, type AppLinkDiagnostic, type AppLinkDiagnosticCode, type AppLinkResult, type AppManifest, type AppManifestModule, type AppModuleInput, type AppNodeId, type AppNodeKind, type AppReferenceInput, type AppScreenInput, type AppSourceMapEntry, type AppSourceSpan, type AttributeChange, AvatarNode, BadgeNode, BreadcrumbNode, ButtonNode, CardNode, CheckboxNode, ColNode, type CompileAppOptions, type ComplexityMetrics, ComponentCategory, ComponentDefinitionNode, type ComponentParameterReference, type ComponentStats, ComponentUseNode, ContainerComponentNode, ContainerNode, type ContentAnalysis, DEFAULT_VIEWPORT, DEVICE_PRESETS, DataNode, DefinitionNode, type DiffChangeType, type DiffOptions, type DiffResult, type DiffSummary, DisplayNode, DividerComponentNode, type DomTreeNode, DrawerNode, DropdownNode, type ExportOptions, FeedbackNode, type FigmaAutoLayout, type FigmaColor, type FigmaCounterAxisAlign, type FigmaExportResult, type FigmaLayoutMode, type FigmaNode, type FigmaNodeType, type FigmaPrimaryAxisAlign, type FigmaSize, type FigmaSizingMode, type FigmaSolidFill, type FigmaStroke, type FigmaTextAlign, type FigmaTextStyle, FooterNode, GridNode, HeaderNode, IconNode, ImageNode, InputComponentNode, InputNode, InputType, type InteractionDiagnostic, type InteractionDiagnosticCode, InteractionEffect, type InteractionKind, type InteractionModel, type JsonExportResult, type JsonNode, type LayoutAnalysis, LayoutDefinitionNode, LayoutNode, LeafNode, LinkNode, ListNode, MainNode, ModalNode, NavNode, NavigationNode, type NodeChange, type NodePredicate, NodeType, type NormalizedInteraction, type NormalizedInteractionEffect, type NormalizedInteractionHandler, OverlayNode, PageNode, PlaceholderNode, PopoverNode, type PreviewWrapperOptions, ProgressNode, REPEAT_EXPANSION_BUDGET, RadioNode, RepeatBudgetError, type ResolvedAppComponent, type ResolvedAppLayout, type ResolvedAppModule, type ResolvedAppReference, type ResolvedAppScreen, RowNode, type ScreenAction, type ScreenDisplay, type ScreenElement, type ScreenFields, type ScreenFieldsSummary, type ScreenInput, type ScreenTransitionGraph, SectionNode, SelectNode, SidebarNode, SiteOptions, SliderNode, SlotNode, SourceLocation, type SourceSlice, SpinnerNode, StateDeclaration, StateGuard, SwitchNode, TableNode, TabsNode, TextContentNode, TextNode, TextareaNode, TitleNode, ToastNode, TooltipNode, type TransitionEdge, type TransitionScreen, type TreeMetrics, type ValidationError, type ValidationOptions, type ValidationResult, type ViewportSize, type WalkCallback, WireframeDocument, analyze, areIdentical, buildAnchorIndex, buildDomTree, calculateViewportScale, cloneNode, collectInteractions, collectParameterReferences, compileApp, contains, countNodes, createAppComponentInstanceId, createAppNodeId, diff, documentDefinitions, documentPages, expandRepeats, expandVariants, exportToFigma, exportToFigmaString, exportToJson, exportToJsonString, extractAllScreenFields, extractScreenFields, extractScreenTransitions, find, findAll, findByType, formatWireframeCode, getAncestors, getChangeSummary, getDevicePresets, getMaxDepth, getNodeSource, getNodeTypes, getPageSource, getValidationErrors, hasChildren, importFromJson, interactionSignature, isAccordionNode, isAlertNode, isAvatarNode, isBadgeNode, isBreadcrumbNode, isButtonNode, isCardNode, isCheckboxNode, isColNode, isComponentDefinitionNode, isComponentUseNode, isContainerComponentNode, isContainerNode, isDataNode, isDefinitionNode, isDisplayNode, isDividerNode, isDrawerNode, isDropdownNode, isFeedbackNode, isFooterNode, isGridNode, isHeaderNode, isIconNode, isImageNode, isInputComponentNode, isInputNode, isLayoutDefinitionNode, isLayoutNode, isLeafNode, isLinkNode, isListNode, isMainNode, isModalNode, isNavNode, isNavigationNode, isNodeType, isOverlayNode, isPageNode, isPlaceholderNode, isPopoverNode, isProgressNode, isRadioNode, isRowNode, isSectionNode, isSelectNode, isSidebarNode, isSliderNode, isSlotNode, isSpinnerNode, isSwitchNode, isTableNode, isTabsNode, isTextContentNode, isTextNode, isTextareaNode, isTitleNode, isToastNode, isTooltipNode, isUrlTarget, isValidAst, isValidDevicePreset, linkAndCompileApp, linkApp, mapNodes, normalizeInteractionHandlers, normalizeStateGuard, parameterReferenceName, parseViewportString, printWireframe, resetFigmaIdCounter, resolveAnchor, resolveViewport, validate, walk, walkDocument, wrapInPreviewContainer };
|
|
1911
|
+
export { ANCHOR_LOC_ATTR, ANCHOR_PATH_ATTR, type AccessibilityMetrics, AccordionNode, AlertNode, type AnalysisOptions, type AnalysisResult, type AnchorEntry, AnyNode, type AppCompileResult, type AppComponentInput, type AppComponentInstanceId, type AppDefinitionKind, type AppDocument, type AppLayoutInput, type AppLinkDiagnostic, type AppLinkDiagnosticCode, type AppLinkResult, type AppManifest, type AppManifestModule, type AppModuleInput, type AppNodeId, type AppNodeKind, type AppReferenceInput, type AppScreenInput, type AppSourceMapEntry, type AppSourceSpan, type AttributeChange, AvatarNode, BadgeNode, BreadcrumbNode, ButtonNode, CardNode, CheckboxNode, ColNode, type CompileAppOptions, type ComplexityMetrics, ComponentCategory, ComponentDefinitionNode, type ComponentParameterReference, type ComponentStats, ComponentUseNode, ContainerComponentNode, ContainerNode, type ContentAnalysis, DEFAULT_VIEWPORT, DEVICE_PRESETS, DataNode, DefinitionNode, type DiffChangeType, type DiffOptions, type DiffResult, type DiffSummary, DisplayNode, DividerComponentNode, type DomTreeNode, DrawerNode, DropdownNode, type ExportOptions, FeedbackNode, type FigmaAutoLayout, type FigmaColor, type FigmaCounterAxisAlign, type FigmaExportResult, type FigmaLayoutMode, type FigmaNode, type FigmaNodeType, type FigmaPrimaryAxisAlign, type FigmaSize, type FigmaSizingMode, type FigmaSolidFill, type FigmaStroke, type FigmaTextAlign, type FigmaTextStyle, FooterNode, GridNode, HeaderNode, IconNode, ImageNode, InputComponentNode, InputNode, InputType, type InteractionDiagnostic, type InteractionDiagnosticCode, InteractionEffect, type InteractionKind, type InteractionModel, type JsonExportResult, type JsonNode, type LayoutAnalysis, LayoutDefinitionNode, LayoutNode, LeafNode, LinkNode, ListNode, MainNode, ModalNode, NavNode, NavigationNode, type NodeChange, type NodePredicate, NodeType, type NormalizedInteraction, type NormalizedInteractionEffect, type NormalizedInteractionHandler, OverlayNode, PageNode, PlaceholderNode, PopoverNode, type PreviewWrapperOptions, ProgressNode, REPEAT_EXPANSION_BUDGET, RadioNode, RepeatBudgetError, type ResolvedAppComponent, type ResolvedAppLayout, type ResolvedAppModule, type ResolvedAppReference, type ResolvedAppScreen, RowNode, type ScreenAction, type ScreenDisplay, type ScreenElement, type ScreenFields, type ScreenFieldsSummary, type ScreenInput, type ScreenTransitionGraph, SectionNode, SelectNode, SidebarNode, SiteOptions, SliderNode, SlotNode, SourceLocation, type SourceSlice, SpinnerNode, StateDeclaration, StateGuard, SwitchNode, TableNode, TabsNode, TextContentNode, TextNode, TextareaNode, TitleNode, ToastNode, TooltipNode, type TransitionEdge, type TransitionScreen, type TreeMetrics, type ValidationError, type ValidationOptions, type ValidationResult, type ViewportSize, type WalkCallback, WireframeDocument, analyze, areIdentical, buildAnchorIndex, buildDomTree, calculateViewportScale, cloneNode, collectInteractions, collectParameterReferences, compileApp, contains, countNodes, createAppComponentInstanceId, createAppNodeId, diff, documentDefinitions, documentPages, expandRepeats, expandVariants, exportToFigma, exportToFigmaString, exportToJson, exportToJsonString, extractAllScreenFields, extractScreenFields, extractScreenTransitions, filterUnscopedPages, filterVariantScope, find, findAll, findByType, formatWireframeCode, getAncestors, getChangeSummary, getDevicePresets, getMaxDepth, getNodeSource, getNodeTypes, getPageSource, getValidationErrors, hasChildren, importFromJson, interactionSignature, isAccordionNode, isAlertNode, isAvatarNode, isBadgeNode, isBreadcrumbNode, isButtonNode, isCardNode, isCheckboxNode, isColNode, isComponentDefinitionNode, isComponentUseNode, isContainerComponentNode, isContainerNode, isDataNode, isDefinitionNode, isDisplayNode, isDividerNode, isDrawerNode, isDropdownNode, isFeedbackNode, isFooterNode, isGridNode, isHeaderNode, isIconNode, isImageNode, isInputComponentNode, isInputNode, isLayoutDefinitionNode, isLayoutNode, isLeafNode, isLinkNode, isListNode, isMainNode, isModalNode, isNavNode, isNavigationNode, isNodeType, isOverlayNode, isPageNode, isPlaceholderNode, isPopoverNode, isProgressNode, isRadioNode, isRowNode, isSectionNode, isSelectNode, isSidebarNode, isSliderNode, isSlotNode, isSpinnerNode, isSwitchNode, isTableNode, isTabsNode, isTextContentNode, isTextNode, isTextareaNode, isTitleNode, isToastNode, isTooltipNode, isUrlTarget, isValidAst, isValidDevicePreset, linkAndCompileApp, linkApp, mapNodes, normalizeInteractionHandlers, normalizeStateGuard, parameterReferenceName, parseViewportString, printWireframe, resetFigmaIdCounter, resolveAnchor, resolveViewport, validate, variantScope, walk, walkDocument, wrapInPreviewContainer };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { h as AnyNode, A as AccordionNode, a as AlertNode, j as AvatarNode, B as BadgeNode, r as BreadcrumbNode, s as ButtonNode, C as CardNode, w as CheckboxNode, x as ColNode, z as ComponentDefinitionNode, H as ComponentUseNode, I as ContainerComponentNode, J as ContainerNode, K as DataNode, L as DefinitionNode, N as DisplayNode, O as DividerComponentNode, P as DrawerNode, S as DropdownNode, T as FeedbackNode, V as FooterNode, W as GridNode, Z as HeaderNode, $ as IconNode, a2 as ImageNode, a3 as InputComponentNode, a4 as InputNode, aa as LayoutDefinitionNode, ab as LayoutNode, ac as LeafNode, ad as LinkNode, af as ListNode, ag as MainNode, aj as ModalNode, ao as NavNode, ap as NavigationNode, aq as NodeType, ar as OverlayNode, as as PageNode, at as PlaceholderNode, au as PopoverNode, ax as ProgressNode, ay as RadioNode, aB as RowNode, aC as SectionNode, aD as SelectNode, aG as SidebarNode, aI as SliderNode, aJ as SlotNode, aN as SpinnerNode, aV as SwitchNode, aX as TableNode, aY as TabsNode, a_ as TextContentNode, a$ as TextNode, b3 as TextareaNode, b5 as TitleNode, b6 as ToastNode, b8 as TooltipNode,
|
|
2
|
-
export { b as AlertVariant, c as AlignValue, d as AnchorPosition, e as AnnotationItemNode, f as AnnotationNode, g as AnnotationsNode, i as AppearanceProps, k as AvatarSize, l as AvatarSizeToken, m as BadgeSize, n as BadgeSizeToken, o as BadgeVariant, p as BaseNode, q as BreadcrumbItem, t as ButtonSize, u as ButtonSizeToken, v as ButtonVariant, y as CommonProps, D as ComponentInputValue, E as ComponentParameter, F as ComponentParameterType, G as ComponentSlotFill, M as DirectionValue, Q as DrawerPosition, R as DropdownItemNode, U as FlexProps, X as GridProps, Y as GuardedOutcomeProps, _ as HeightValue, a0 as IconSize, a1 as IconSizeToken, a7 as InteractionHandler, a8 as InteractiveProps, a9 as JustifyValue, ae as ListItemNode, ah as MarkerColor, ai as MarkerNode, ak as NavBlockItem, al as NavChild, am as NavGroupNode, an as NavItem, av as Position, aw as PositionProps, az as RelativeNode, aA as RepeatNode, aE as SelectOption, aF as ShadowValue, aH as SizeProps, aL as SpacingProps, aM as SpacingValue, aO as SpinnerSize, aP as SpinnerSizeToken, aQ as StackNode, aT as StateValue, aU as StateValueType, aW as TabNode, aZ as TextAlign, b0 as TextSize, b1 as TextSizeToken, b2 as TextWeight, b4 as TitleLevel, b7 as ToastPosition, b9 as TooltipPosition, ba as TopLevelNode, bb as ValueWithUnit, bc as WidthValue } from './types-
|
|
1
|
+
import { h as AnyNode, A as AccordionNode, a as AlertNode, j as AvatarNode, B as BadgeNode, r as BreadcrumbNode, s as ButtonNode, C as CardNode, w as CheckboxNode, x as ColNode, z as ComponentDefinitionNode, H as ComponentUseNode, I as ContainerComponentNode, J as ContainerNode, K as DataNode, L as DefinitionNode, N as DisplayNode, O as DividerComponentNode, P as DrawerNode, S as DropdownNode, T as FeedbackNode, V as FooterNode, W as GridNode, Z as HeaderNode, $ as IconNode, a2 as ImageNode, a3 as InputComponentNode, a4 as InputNode, aa as LayoutDefinitionNode, ab as LayoutNode, ac as LeafNode, ad as LinkNode, af as ListNode, ag as MainNode, aj as ModalNode, ao as NavNode, ap as NavigationNode, aq as NodeType, ar as OverlayNode, as as PageNode, at as PlaceholderNode, au as PopoverNode, ax as ProgressNode, ay as RadioNode, aB as RowNode, aC as SectionNode, aD as SelectNode, aG as SidebarNode, aI as SliderNode, aJ as SlotNode, aN as SpinnerNode, aV as SwitchNode, aX as TableNode, aY as TabsNode, a_ as TextContentNode, a$ as TextNode, b3 as TextareaNode, b5 as TitleNode, b6 as ToastNode, b8 as TooltipNode, be as WireframeDocument, aK as SourceLocation, aR as StateDeclaration, aS as StateGuard, a6 as InteractionEffect, a5 as InputType } from './types-vhPCZpAW.js';
|
|
2
|
+
export { b as AlertVariant, c as AlignValue, d as AnchorPosition, e as AnnotationItemNode, f as AnnotationNode, g as AnnotationsNode, i as AppearanceProps, k as AvatarSize, l as AvatarSizeToken, m as BadgeSize, n as BadgeSizeToken, o as BadgeVariant, p as BaseNode, q as BreadcrumbItem, t as ButtonSize, u as ButtonSizeToken, v as ButtonVariant, y as CommonProps, D as ComponentInputValue, E as ComponentParameter, F as ComponentParameterType, G as ComponentSlotFill, M as DirectionValue, Q as DrawerPosition, R as DropdownItemNode, U as FlexProps, X as GridProps, Y as GuardedOutcomeProps, _ as HeightValue, a0 as IconSize, a1 as IconSizeToken, a7 as InteractionHandler, a8 as InteractiveProps, a9 as JustifyValue, ae as ListItemNode, ah as MarkerColor, ai as MarkerNode, ak as NavBlockItem, al as NavChild, am as NavGroupNode, an as NavItem, av as Position, aw as PositionProps, az as RelativeNode, aA as RepeatNode, aE as SelectOption, aF as ShadowValue, aH as SizeProps, aL as SpacingProps, aM as SpacingValue, aO as SpinnerSize, aP as SpinnerSizeToken, aQ as StackNode, aT as StateValue, aU as StateValueType, aW as TabNode, aZ as TextAlign, b0 as TextSize, b1 as TextSizeToken, b2 as TextWeight, b4 as TitleLevel, b7 as ToastPosition, b9 as TooltipPosition, ba as TopLevelNode, bb as ValueWithUnit, bc as VariantScopedProps, bd as WidthValue } from './types-vhPCZpAW.js';
|
|
3
3
|
export { ExpectedToken, ParseError, ParseErrorInfo, ParseOptions, ParseResult, getErrors, isValid, parse, tryParse } from './parser.js';
|
|
4
4
|
import { SiteOptions } from './renderer.js';
|
|
5
5
|
export { AnnotationStyle, CanvasOptions, CanvasRenderResult, ENABLED_GUARD_ATTR, EXTERNAL_NAVIGATE_ATTR, HtmlRenderer, INERT_HREF, INTERACTIVE_ATTR_NAMES, IconData, IconElement, InteractiveAttrs, PageRenderResult, PlacedPage, RenderContext, RenderOptions, RenderResult, ShellMiss, SiteModel, SiteScreen, SiteShell, SvgRenderOptions, SvgRenderResult, TYPED_INTERACTION_ATTR, ThemeColors, 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 } from './renderer.js';
|
|
@@ -393,6 +393,107 @@ declare function expandRepeats(document: WireframeDocument): WireframeDocument;
|
|
|
393
393
|
*/
|
|
394
394
|
declare function expandVariants(document: WireframeDocument): WireframeDocument;
|
|
395
395
|
|
|
396
|
+
/**
|
|
397
|
+
* `when=` filtering — dropping the elements a board does not draw.
|
|
398
|
+
*
|
|
399
|
+
* ## What `when` says, and why it is not a guard
|
|
400
|
+
*
|
|
401
|
+
* `visibleWhen` already answers "should this be on screen right now": the
|
|
402
|
+
* element is rendered onto every board, carries `data-wf-visible-when`, and the
|
|
403
|
+
* site runtime shows and hides it as state changes. `when` answers a different
|
|
404
|
+
* question — *which boards is this element part of at all* — and it answers it
|
|
405
|
+
* before anything renders. An element scoped to `loading` is not hidden on the
|
|
406
|
+
* `ready` board; it is absent from it, so no state change can bring it back and
|
|
407
|
+
* nothing in that board's markup refers to it.
|
|
408
|
+
*
|
|
409
|
+
* The two are therefore orthogonal, not alternatives, and this pass is careful
|
|
410
|
+
* to leave guards alone: it deletes `when` from the nodes it keeps and touches
|
|
411
|
+
* no other property, so `when=ready visibleWhen={…}` survives as a guard on the
|
|
412
|
+
* ready board. Collapsing them would lose the case the feature exists for.
|
|
413
|
+
*
|
|
414
|
+
* ## Why disjunction is the point
|
|
415
|
+
*
|
|
416
|
+
* A guard compares one state to one value, so a block belonging to two
|
|
417
|
+
* conditions could only be written twice. That is not a stylistic cost: the two
|
|
418
|
+
* copies are edited separately and drift, and a reviewer reading the sheet
|
|
419
|
+
* cannot tell whether a difference between them is intentional. `when=[loading,
|
|
420
|
+
* empty]` is the same block, authored once, drawn on both boards — the header
|
|
421
|
+
* shared by three states is one header, and it stays one.
|
|
422
|
+
*
|
|
423
|
+
* ## Why it runs inside variant expansion
|
|
424
|
+
*
|
|
425
|
+
* Filtering needs to know which board it is filtering *for*, and that fact
|
|
426
|
+
* exists only after `expandVariants` has turned one authored page into one page
|
|
427
|
+
* per name and stamped each with `page.variant`. Running as a separate pass
|
|
428
|
+
* afterwards would have to rediscover the same association by walking the
|
|
429
|
+
* document again; running before expansion would have no board to ask about.
|
|
430
|
+
* So the board is filtered at the moment it is cloned, while the name is in
|
|
431
|
+
* hand — see `expand-variants.ts`.
|
|
432
|
+
*
|
|
433
|
+
* ## The rule, stated once
|
|
434
|
+
*
|
|
435
|
+
* An element is drawn on a board **iff its `when` set contains that board's
|
|
436
|
+
* variant**. Everything else follows from that one sentence rather than from a
|
|
437
|
+
* list of cases:
|
|
438
|
+
*
|
|
439
|
+
* - No `when` at all → drawn on every board. This is what keeps every document
|
|
440
|
+
* written before the attribute existed rendering byte-for-byte as it did.
|
|
441
|
+
* - A board with no variant (a page that declared no `variants=`) matches no
|
|
442
|
+
* name, so *any* `when` filters the element out. That is the honest reading
|
|
443
|
+
* rather than a convenient one: the element declares membership in a board
|
|
444
|
+
* this page never declared, and drawing it anyway would make `when` mean
|
|
445
|
+
* "sometimes nothing", which is the silently-dropped-value failure the spec
|
|
446
|
+
* gates exist to prevent. `validate()` reports the same document, so the
|
|
447
|
+
* author is told rather than left to discover an empty board.
|
|
448
|
+
* - A parent that is filtered out takes its children with it, whatever they
|
|
449
|
+
* say. A child scoped to `ready` inside a parent scoped to `loading` cannot
|
|
450
|
+
* be drawn on either board — there is no board where both are present — and
|
|
451
|
+
* the contradiction is reported by `validate()` rather than resolved here.
|
|
452
|
+
*/
|
|
453
|
+
|
|
454
|
+
/**
|
|
455
|
+
* The variant names an element declares, trimmed, blanks and duplicates dropped.
|
|
456
|
+
*
|
|
457
|
+
* Both spellings collapse to the same set, because `when=loading` and
|
|
458
|
+
* `when=[loading]` denote the same membership and nothing downstream should
|
|
459
|
+
* have to know which the author typed.
|
|
460
|
+
*
|
|
461
|
+
* A `when` that is present but names nothing — `when=[]`, or a blank string —
|
|
462
|
+
* yields an empty set, which matches no board. It is deliberately not treated
|
|
463
|
+
* as "no `when`": the author wrote the attribute, and answering an empty list
|
|
464
|
+
* with "every board" would make the emptiest possible scope the widest one.
|
|
465
|
+
*/
|
|
466
|
+
declare function variantScope(node: AnyNode): string[] | undefined;
|
|
467
|
+
/**
|
|
468
|
+
* Drop from `children` everything not drawn on `variant`'s board.
|
|
469
|
+
*
|
|
470
|
+
* Identity-preserving: a subtree carrying no `when` anywhere is returned as the
|
|
471
|
+
* same array, so a board of a document that uses no scoping costs one scan.
|
|
472
|
+
*
|
|
473
|
+
* @param children - The board's children, already cloned by variant expansion
|
|
474
|
+
* @param variant - The board's variant name, or `undefined` for an unnamed board
|
|
475
|
+
* @returns The children this board draws
|
|
476
|
+
* @internal
|
|
477
|
+
*/
|
|
478
|
+
declare function filterVariantScope(children: AnyNode[], variant: string | undefined): AnyNode[];
|
|
479
|
+
/**
|
|
480
|
+
* Apply `when` filtering to every page of a document that expansion did not.
|
|
481
|
+
*
|
|
482
|
+
* Variant-bearing pages are filtered as they are cloned, inside
|
|
483
|
+
* `expandVariants`, because that is where the board's name exists. This covers
|
|
484
|
+
* the rest: a page that declared no `variants=` is still a board, an unnamed
|
|
485
|
+
* one, and an element scoped to a name it never declared is not drawn on it.
|
|
486
|
+
*
|
|
487
|
+
* Layout and component definitions are filtered through the pages that use
|
|
488
|
+
* them, not here — a definition has no board of its own, and scoping inside one
|
|
489
|
+
* resolves against whichever page pulled it in.
|
|
490
|
+
*
|
|
491
|
+
* @param document - A document whose variant-bearing pages are already expanded
|
|
492
|
+
* @returns The document with unnamed boards filtered
|
|
493
|
+
* @internal
|
|
494
|
+
*/
|
|
495
|
+
declare function filterUnscopedPages(document: WireframeDocument): WireframeDocument;
|
|
496
|
+
|
|
396
497
|
/**
|
|
397
498
|
* Node/document-level canonical `.wf` printing.
|
|
398
499
|
*
|
|
@@ -1807,4 +1908,4 @@ declare function compileApp(document: AppDocument, options?: CompileAppOptions):
|
|
|
1807
1908
|
*/
|
|
1808
1909
|
declare function linkAndCompileApp(manifest: AppManifest, modules: readonly AppModuleInput[], options?: CompileAppOptions): AppCompileResult;
|
|
1809
1910
|
|
|
1810
|
-
export { ANCHOR_LOC_ATTR, ANCHOR_PATH_ATTR, type AccessibilityMetrics, AccordionNode, AlertNode, type AnalysisOptions, type AnalysisResult, type AnchorEntry, AnyNode, type AppCompileResult, type AppComponentInput, type AppComponentInstanceId, type AppDefinitionKind, type AppDocument, type AppLayoutInput, type AppLinkDiagnostic, type AppLinkDiagnosticCode, type AppLinkResult, type AppManifest, type AppManifestModule, type AppModuleInput, type AppNodeId, type AppNodeKind, type AppReferenceInput, type AppScreenInput, type AppSourceMapEntry, type AppSourceSpan, type AttributeChange, AvatarNode, BadgeNode, BreadcrumbNode, ButtonNode, CardNode, CheckboxNode, ColNode, type CompileAppOptions, type ComplexityMetrics, ComponentCategory, ComponentDefinitionNode, type ComponentParameterReference, type ComponentStats, ComponentUseNode, ContainerComponentNode, ContainerNode, type ContentAnalysis, DEFAULT_VIEWPORT, DEVICE_PRESETS, DataNode, DefinitionNode, type DiffChangeType, type DiffOptions, type DiffResult, type DiffSummary, DisplayNode, DividerComponentNode, type DomTreeNode, DrawerNode, DropdownNode, type ExportOptions, FeedbackNode, type FigmaAutoLayout, type FigmaColor, type FigmaCounterAxisAlign, type FigmaExportResult, type FigmaLayoutMode, type FigmaNode, type FigmaNodeType, type FigmaPrimaryAxisAlign, type FigmaSize, type FigmaSizingMode, type FigmaSolidFill, type FigmaStroke, type FigmaTextAlign, type FigmaTextStyle, FooterNode, GridNode, HeaderNode, IconNode, ImageNode, InputComponentNode, InputNode, InputType, type InteractionDiagnostic, type InteractionDiagnosticCode, InteractionEffect, type InteractionKind, type InteractionModel, type JsonExportResult, type JsonNode, type LayoutAnalysis, LayoutDefinitionNode, LayoutNode, LeafNode, LinkNode, ListNode, MainNode, ModalNode, NavNode, NavigationNode, type NodeChange, type NodePredicate, NodeType, type NormalizedInteraction, type NormalizedInteractionEffect, type NormalizedInteractionHandler, OverlayNode, PageNode, PlaceholderNode, PopoverNode, type PreviewWrapperOptions, ProgressNode, REPEAT_EXPANSION_BUDGET, RadioNode, RepeatBudgetError, type ResolvedAppComponent, type ResolvedAppLayout, type ResolvedAppModule, type ResolvedAppReference, type ResolvedAppScreen, RowNode, type ScreenAction, type ScreenDisplay, type ScreenElement, type ScreenFields, type ScreenFieldsSummary, type ScreenInput, type ScreenTransitionGraph, SectionNode, SelectNode, SidebarNode, SiteOptions, SliderNode, SlotNode, SourceLocation, type SourceSlice, SpinnerNode, StateDeclaration, StateGuard, SwitchNode, TableNode, TabsNode, TextContentNode, TextNode, TextareaNode, TitleNode, ToastNode, TooltipNode, type TransitionEdge, type TransitionScreen, type TreeMetrics, type ValidationError, type ValidationOptions, type ValidationResult, type ViewportSize, type WalkCallback, WireframeDocument, analyze, areIdentical, buildAnchorIndex, buildDomTree, calculateViewportScale, cloneNode, collectInteractions, collectParameterReferences, compileApp, contains, countNodes, createAppComponentInstanceId, createAppNodeId, diff, documentDefinitions, documentPages, expandRepeats, expandVariants, exportToFigma, exportToFigmaString, exportToJson, exportToJsonString, extractAllScreenFields, extractScreenFields, extractScreenTransitions, find, findAll, findByType, formatWireframeCode, getAncestors, getChangeSummary, getDevicePresets, getMaxDepth, getNodeSource, getNodeTypes, getPageSource, getValidationErrors, hasChildren, importFromJson, interactionSignature, isAccordionNode, isAlertNode, isAvatarNode, isBadgeNode, isBreadcrumbNode, isButtonNode, isCardNode, isCheckboxNode, isColNode, isComponentDefinitionNode, isComponentUseNode, isContainerComponentNode, isContainerNode, isDataNode, isDefinitionNode, isDisplayNode, isDividerNode, isDrawerNode, isDropdownNode, isFeedbackNode, isFooterNode, isGridNode, isHeaderNode, isIconNode, isImageNode, isInputComponentNode, isInputNode, isLayoutDefinitionNode, isLayoutNode, isLeafNode, isLinkNode, isListNode, isMainNode, isModalNode, isNavNode, isNavigationNode, isNodeType, isOverlayNode, isPageNode, isPlaceholderNode, isPopoverNode, isProgressNode, isRadioNode, isRowNode, isSectionNode, isSelectNode, isSidebarNode, isSliderNode, isSlotNode, isSpinnerNode, isSwitchNode, isTableNode, isTabsNode, isTextContentNode, isTextNode, isTextareaNode, isTitleNode, isToastNode, isTooltipNode, isUrlTarget, isValidAst, isValidDevicePreset, linkAndCompileApp, linkApp, mapNodes, normalizeInteractionHandlers, normalizeStateGuard, parameterReferenceName, parseViewportString, printWireframe, resetFigmaIdCounter, resolveAnchor, resolveViewport, validate, walk, walkDocument, wrapInPreviewContainer };
|
|
1911
|
+
export { ANCHOR_LOC_ATTR, ANCHOR_PATH_ATTR, type AccessibilityMetrics, AccordionNode, AlertNode, type AnalysisOptions, type AnalysisResult, type AnchorEntry, AnyNode, type AppCompileResult, type AppComponentInput, type AppComponentInstanceId, type AppDefinitionKind, type AppDocument, type AppLayoutInput, type AppLinkDiagnostic, type AppLinkDiagnosticCode, type AppLinkResult, type AppManifest, type AppManifestModule, type AppModuleInput, type AppNodeId, type AppNodeKind, type AppReferenceInput, type AppScreenInput, type AppSourceMapEntry, type AppSourceSpan, type AttributeChange, AvatarNode, BadgeNode, BreadcrumbNode, ButtonNode, CardNode, CheckboxNode, ColNode, type CompileAppOptions, type ComplexityMetrics, ComponentCategory, ComponentDefinitionNode, type ComponentParameterReference, type ComponentStats, ComponentUseNode, ContainerComponentNode, ContainerNode, type ContentAnalysis, DEFAULT_VIEWPORT, DEVICE_PRESETS, DataNode, DefinitionNode, type DiffChangeType, type DiffOptions, type DiffResult, type DiffSummary, DisplayNode, DividerComponentNode, type DomTreeNode, DrawerNode, DropdownNode, type ExportOptions, FeedbackNode, type FigmaAutoLayout, type FigmaColor, type FigmaCounterAxisAlign, type FigmaExportResult, type FigmaLayoutMode, type FigmaNode, type FigmaNodeType, type FigmaPrimaryAxisAlign, type FigmaSize, type FigmaSizingMode, type FigmaSolidFill, type FigmaStroke, type FigmaTextAlign, type FigmaTextStyle, FooterNode, GridNode, HeaderNode, IconNode, ImageNode, InputComponentNode, InputNode, InputType, type InteractionDiagnostic, type InteractionDiagnosticCode, InteractionEffect, type InteractionKind, type InteractionModel, type JsonExportResult, type JsonNode, type LayoutAnalysis, LayoutDefinitionNode, LayoutNode, LeafNode, LinkNode, ListNode, MainNode, ModalNode, NavNode, NavigationNode, type NodeChange, type NodePredicate, NodeType, type NormalizedInteraction, type NormalizedInteractionEffect, type NormalizedInteractionHandler, OverlayNode, PageNode, PlaceholderNode, PopoverNode, type PreviewWrapperOptions, ProgressNode, REPEAT_EXPANSION_BUDGET, RadioNode, RepeatBudgetError, type ResolvedAppComponent, type ResolvedAppLayout, type ResolvedAppModule, type ResolvedAppReference, type ResolvedAppScreen, RowNode, type ScreenAction, type ScreenDisplay, type ScreenElement, type ScreenFields, type ScreenFieldsSummary, type ScreenInput, type ScreenTransitionGraph, SectionNode, SelectNode, SidebarNode, SiteOptions, SliderNode, SlotNode, SourceLocation, type SourceSlice, SpinnerNode, StateDeclaration, StateGuard, SwitchNode, TableNode, TabsNode, TextContentNode, TextNode, TextareaNode, TitleNode, ToastNode, TooltipNode, type TransitionEdge, type TransitionScreen, type TreeMetrics, type ValidationError, type ValidationOptions, type ValidationResult, type ViewportSize, type WalkCallback, WireframeDocument, analyze, areIdentical, buildAnchorIndex, buildDomTree, calculateViewportScale, cloneNode, collectInteractions, collectParameterReferences, compileApp, contains, countNodes, createAppComponentInstanceId, createAppNodeId, diff, documentDefinitions, documentPages, expandRepeats, expandVariants, exportToFigma, exportToFigmaString, exportToJson, exportToJsonString, extractAllScreenFields, extractScreenFields, extractScreenTransitions, filterUnscopedPages, filterVariantScope, find, findAll, findByType, formatWireframeCode, getAncestors, getChangeSummary, getDevicePresets, getMaxDepth, getNodeSource, getNodeTypes, getPageSource, getValidationErrors, hasChildren, importFromJson, interactionSignature, isAccordionNode, isAlertNode, isAvatarNode, isBadgeNode, isBreadcrumbNode, isButtonNode, isCardNode, isCheckboxNode, isColNode, isComponentDefinitionNode, isComponentUseNode, isContainerComponentNode, isContainerNode, isDataNode, isDefinitionNode, isDisplayNode, isDividerNode, isDrawerNode, isDropdownNode, isFeedbackNode, isFooterNode, isGridNode, isHeaderNode, isIconNode, isImageNode, isInputComponentNode, isInputNode, isLayoutDefinitionNode, isLayoutNode, isLeafNode, isLinkNode, isListNode, isMainNode, isModalNode, isNavNode, isNavigationNode, isNodeType, isOverlayNode, isPageNode, isPlaceholderNode, isPopoverNode, isProgressNode, isRadioNode, isRowNode, isSectionNode, isSelectNode, isSidebarNode, isSliderNode, isSlotNode, isSpinnerNode, isSwitchNode, isTableNode, isTabsNode, isTextContentNode, isTextNode, isTextareaNode, isTitleNode, isToastNode, isTooltipNode, isUrlTarget, isValidAst, isValidDevicePreset, linkAndCompileApp, linkApp, mapNodes, normalizeInteractionHandlers, normalizeStateGuard, parameterReferenceName, parseViewportString, printWireframe, resetFigmaIdCounter, resolveAnchor, resolveViewport, validate, variantScope, walk, walkDocument, wrapInPreviewContainer };
|