@wireweave/core 4.0.0-beta.12 → 4.0.0-beta.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app.cjs +51 -31
- package/dist/app.d.cts +5 -145
- package/dist/app.d.ts +5 -145
- package/dist/app.js +2 -31
- package/dist/{chunk-QOS4IC75.js → chunk-2Y3GKARZ.js} +16 -1354
- package/dist/chunk-3RWGG5EC.js +296 -342
- package/dist/chunk-4DDV6Z2X.js +389 -0
- package/dist/chunk-ETV4XYOV.cjs +4 -6
- package/dist/chunk-IMUVIIJR.cjs +317 -354
- package/dist/chunk-LA5LKIEL.cjs +396 -0
- package/dist/chunk-MD6MNOEQ.cjs +121 -142
- package/dist/chunk-NV6UV5ID.cjs +2145 -0
- package/dist/chunk-PKBMQBKP.js +1 -3
- package/dist/{chunk-7VTK6LHL.cjs → chunk-SAN6CJEE.cjs} +96 -1421
- package/dist/chunk-TQSOLTMZ.js +2132 -0
- package/dist/chunk-V3HVWC7C.js +1 -32
- package/dist/chunk-XYACLXXF.js +4 -132
- package/dist/chunk-ZPHNXJRY.cjs +158 -180
- package/dist/index-BD_4rXH-.d.cts +1031 -0
- package/dist/{index-Br7pNaf3.d.cts → index-BEnsO2kE.d.ts} +144 -2
- package/dist/{index-G906GEtg.d.cts → index-BlNYFaZd.d.cts} +2 -2
- package/dist/{index-CghCKUPx.d.ts → index-Cx4-VXVS.d.ts} +2 -2
- package/dist/{index-Da_B3eoM.d.ts → index-YSIzfhOd.d.cts} +144 -2
- package/dist/index-g9yV20xb.d.ts +1031 -0
- package/dist/index.cjs +939 -429
- package/dist/index.d.cts +16 -193
- package/dist/index.d.ts +16 -193
- package/dist/index.js +210 -396
- package/dist/interaction.cjs +26 -17
- package/dist/interaction.d.cts +2 -2
- package/dist/interaction.d.ts +2 -2
- package/dist/interaction.js +1 -17
- package/dist/parser.cjs +38 -21
- package/dist/parser.d.cts +3 -3
- package/dist/parser.d.ts +3 -3
- package/dist/parser.js +1 -21
- package/dist/renderer.cjs +124 -68
- package/dist/renderer.d.cts +4 -756
- package/dist/renderer.d.ts +4 -756
- package/dist/renderer.js +3 -68
- package/dist/spec.cjs +94 -49
- package/dist/spec.js +1 -49
- package/dist/{types-vhPCZpAW.d.cts → types-CGRi1k2N.d.cts} +1 -1
- package/dist/{types-vhPCZpAW.d.ts → types-CGRi1k2N.d.ts} +1 -1
- package/dist/{v4-types-Baz9yqAS.d.cts → v4-types-2ORUg6To.d.cts} +1 -1
- package/dist/{v4-types-Baz9yqAS.d.ts → v4-types-2ORUg6To.d.ts} +1 -1
- package/package.json +21 -23
- package/dist/chunk-4TMDPWPR.cjs +0 -196
- package/dist/chunk-5DGRIQDU.cjs +0 -842
- package/dist/chunk-JJWAFHSV.js +0 -842
- package/dist/chunk-R5WBZWBC.js +0 -196
- package/dist/chunk-WV724EAW.js +0 -0
- package/dist/chunk-XENFKHRC.cjs +0 -1
package/dist/index.js
CHANGED
|
@@ -1,194 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} from
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
createAppBundle,
|
|
13
|
-
createAppComponentInstanceId,
|
|
14
|
-
createAppNodeId,
|
|
15
|
-
createRuntime,
|
|
16
|
-
linkAndCompileApp,
|
|
17
|
-
linkApp,
|
|
18
|
-
parameterReferenceName,
|
|
19
|
-
reduceEvent,
|
|
20
|
-
renderSite as renderSite2,
|
|
21
|
-
resetRuntime
|
|
22
|
-
} from "./chunk-QOS4IC75.js";
|
|
23
|
-
import {
|
|
24
|
-
V4ParseError,
|
|
25
|
-
getErrors,
|
|
26
|
-
getV4SourceSpan,
|
|
27
|
-
isValid,
|
|
28
|
-
parse,
|
|
29
|
-
parseV4,
|
|
30
|
-
tryParse,
|
|
31
|
-
tryParseV4
|
|
32
|
-
} from "./chunk-3RWGG5EC.js";
|
|
33
|
-
import {
|
|
34
|
-
expandVariants,
|
|
35
|
-
renderSite
|
|
36
|
-
} from "./chunk-JJWAFHSV.js";
|
|
37
|
-
import "./chunk-WV724EAW.js";
|
|
38
|
-
import {
|
|
39
|
-
ANCHOR_LOC_ATTR,
|
|
40
|
-
ANCHOR_PATH_ATTR,
|
|
41
|
-
ENABLED_GUARD_ATTR,
|
|
42
|
-
EXTERNAL_NAVIGATE_ATTR,
|
|
43
|
-
HtmlRenderer,
|
|
44
|
-
INERT_HREF,
|
|
45
|
-
INTERACTIVE_ATTR_NAMES,
|
|
46
|
-
REPEAT_EXPANSION_BUDGET,
|
|
47
|
-
RepeatBudgetError,
|
|
48
|
-
TYPED_INTERACTION_ATTR,
|
|
49
|
-
VISIBLE_GUARD_ATTR,
|
|
50
|
-
anchorChildNodes,
|
|
51
|
-
anchorIntent,
|
|
52
|
-
buildSiteModel,
|
|
53
|
-
categoryOf,
|
|
54
|
-
cloneNode,
|
|
55
|
-
collectInteractions,
|
|
56
|
-
contains,
|
|
57
|
-
countNodes,
|
|
58
|
-
createHtmlRenderer,
|
|
59
|
-
darkTheme,
|
|
60
|
-
defaultTheme,
|
|
61
|
-
documentDefinitions,
|
|
62
|
-
documentPages,
|
|
63
|
-
expandRepeats,
|
|
64
|
-
filterUnscopedPages,
|
|
65
|
-
filterVariantScope,
|
|
66
|
-
find,
|
|
67
|
-
findAll,
|
|
68
|
-
findByType,
|
|
69
|
-
generateComponentStyles,
|
|
70
|
-
generateStyles,
|
|
71
|
-
getAncestors,
|
|
72
|
-
getContent,
|
|
73
|
-
getIconData,
|
|
74
|
-
getInteractions,
|
|
75
|
-
getInteractiveLabel,
|
|
76
|
-
getItemInteractions,
|
|
77
|
-
getLabel,
|
|
78
|
-
getMaxDepth,
|
|
79
|
-
getNodeTypes,
|
|
80
|
-
getTheme,
|
|
81
|
-
guardedOutcomeAttrs,
|
|
82
|
-
hasChildren,
|
|
83
|
-
interactionSignature,
|
|
84
|
-
interactiveAttrs,
|
|
85
|
-
isAccordionNode,
|
|
86
|
-
isAlertNode,
|
|
87
|
-
isAvatarNode,
|
|
88
|
-
isBadgeNode,
|
|
89
|
-
isBreadcrumbNode,
|
|
90
|
-
isButtonNode,
|
|
91
|
-
isCardNode,
|
|
92
|
-
isCheckboxNode,
|
|
93
|
-
isColNode,
|
|
94
|
-
isComponentDefinitionNode,
|
|
95
|
-
isComponentUseNode,
|
|
96
|
-
isContainerComponentNode,
|
|
97
|
-
isContainerNode,
|
|
98
|
-
isDataNode,
|
|
99
|
-
isDefinitionNode,
|
|
100
|
-
isDisplayNode,
|
|
101
|
-
isDividerNode,
|
|
102
|
-
isDrawerNode,
|
|
103
|
-
isDropdownNode,
|
|
104
|
-
isFeedbackNode,
|
|
105
|
-
isFooterNode,
|
|
106
|
-
isGridNode,
|
|
107
|
-
isHeaderNode,
|
|
108
|
-
isIconNode,
|
|
109
|
-
isImageNode,
|
|
110
|
-
isInputComponentNode,
|
|
111
|
-
isInputNode,
|
|
112
|
-
isLayoutDefinitionNode,
|
|
113
|
-
isLayoutNode,
|
|
114
|
-
isLeafNode,
|
|
115
|
-
isLinkNode,
|
|
116
|
-
isListNode,
|
|
117
|
-
isMainNode,
|
|
118
|
-
isModalNode,
|
|
119
|
-
isNavNode,
|
|
120
|
-
isNavigationNode,
|
|
121
|
-
isNodeType,
|
|
122
|
-
isOverlayNode,
|
|
123
|
-
isPageNode,
|
|
124
|
-
isPlaceholderNode,
|
|
125
|
-
isPopoverNode,
|
|
126
|
-
isProgressNode,
|
|
127
|
-
isRadioNode,
|
|
128
|
-
isRowNode,
|
|
129
|
-
isSectionNode,
|
|
130
|
-
isSelectNode,
|
|
131
|
-
isSidebarNode,
|
|
132
|
-
isSliderNode,
|
|
133
|
-
isSlotNode,
|
|
134
|
-
isSpinnerNode,
|
|
135
|
-
isSwitchNode,
|
|
136
|
-
isTableNode,
|
|
137
|
-
isTabsNode,
|
|
138
|
-
isTextContentNode,
|
|
139
|
-
isTextNode,
|
|
140
|
-
isTextareaNode,
|
|
141
|
-
isTitleNode,
|
|
142
|
-
isToastNode,
|
|
143
|
-
isTooltipNode,
|
|
144
|
-
isUrlTarget,
|
|
145
|
-
lucideIcons,
|
|
146
|
-
mapNodes,
|
|
147
|
-
normalizeInteractionHandlers,
|
|
148
|
-
normalizeStateGuard,
|
|
149
|
-
renderIconSvg,
|
|
150
|
-
renderPage,
|
|
151
|
-
renderUnknownIconSvg,
|
|
152
|
-
resolveAnchorPath,
|
|
153
|
-
resolvePageDimensions,
|
|
154
|
-
variantScope,
|
|
155
|
-
walk,
|
|
156
|
-
walkAnchorPaths,
|
|
157
|
-
walkDocument
|
|
158
|
-
} from "./chunk-XYACLXXF.js";
|
|
159
|
-
import {
|
|
160
|
-
ATTRIBUTE_MAP,
|
|
161
|
-
ATTRIBUTE_OVERRIDES,
|
|
162
|
-
ATTRIBUTE_SPECS,
|
|
163
|
-
BLOCK_NODE_SPECS,
|
|
164
|
-
BOX_ATTRIBUTES,
|
|
165
|
-
COMPONENT_MAP,
|
|
166
|
-
COMPONENT_NAMES,
|
|
167
|
-
COMPONENT_SPECS,
|
|
168
|
-
COMPONENT_SPEC_BY_NAME,
|
|
169
|
-
CONTAINER_ATTRIBUTES,
|
|
170
|
-
DEFAULT_VIEWPORT,
|
|
171
|
-
DEVICE_PRESETS,
|
|
172
|
-
ELEMENT_NODE_TYPE_MAP,
|
|
173
|
-
GRAMMAR_BLOCK_NODE_TYPES,
|
|
174
|
-
GRAMMAR_CHILD_KEYWORDS,
|
|
175
|
-
GRAMMAR_ELEMENTS,
|
|
176
|
-
INTERACTIVE_ATTRIBUTES,
|
|
177
|
-
LUCIDE_ICON_NAMES,
|
|
178
|
-
NODE_TYPE_MAP,
|
|
179
|
-
VALID_ATTRIBUTE_NAMES,
|
|
180
|
-
VALID_COMPONENT_NAMES,
|
|
181
|
-
attributeFor,
|
|
182
|
-
calculateViewportScale,
|
|
183
|
-
getDevicePresets,
|
|
184
|
-
getValidAttributes,
|
|
185
|
-
isValidAttribute,
|
|
186
|
-
isValidDevicePreset,
|
|
187
|
-
parseViewportString,
|
|
188
|
-
resolveViewport,
|
|
189
|
-
wrapInPreviewContainer
|
|
190
|
-
} from "./chunk-V3HVWC7C.js";
|
|
191
|
-
import "./chunk-PKBMQBKP.js";
|
|
1
|
+
export { exportLinkedAppToSvg, layoutCanvas, render, renderCanvas, renderToHtml, renderToSvg } from './chunk-4DDV6Z2X.js';
|
|
2
|
+
import { collectParameterReferences } from './chunk-2Y3GKARZ.js';
|
|
3
|
+
export { advanceClock, collectParameterReferences, compileApp, createAppComponentInstanceId, createAppNodeId, createRuntime, linkAndCompileApp, linkApp, parameterReferenceName, reduceEvent, renderSite as renderAppSite, resetRuntime } from './chunk-2Y3GKARZ.js';
|
|
4
|
+
import { getLinkedAppData, failed, diagnostic, freeze, jcs } from './chunk-TQSOLTMZ.js';
|
|
5
|
+
export { createAppBundle, expandVariants, renderSite } from './chunk-TQSOLTMZ.js';
|
|
6
|
+
import { parse, digestV4 } from './chunk-3RWGG5EC.js';
|
|
7
|
+
export { V4ParseError, getErrors, getV4SourceSpan, isValid, parse, parseV4, tryParse, tryParseV4 } from './chunk-3RWGG5EC.js';
|
|
8
|
+
import { documentPages, walk, categoryOf, getLabel, getContent, isInputComponentNode, getInteractiveLabel, getInteractions, getItemInteractions, buildSiteModel, collectInteractions, walkAnchorPaths, resolveAnchorPath, anchorChildNodes, isUrlTarget, variantScope } from './chunk-XYACLXXF.js';
|
|
9
|
+
export { ANCHOR_LOC_ATTR, ANCHOR_PATH_ATTR, ENABLED_GUARD_ATTR, EXTERNAL_NAVIGATE_ATTR, HtmlRenderer, INERT_HREF, INTERACTIVE_ATTR_NAMES, REPEAT_EXPANSION_BUDGET, RepeatBudgetError, TYPED_INTERACTION_ATTR, VISIBLE_GUARD_ATTR, anchorIntent, buildSiteModel, cloneNode, collectInteractions, contains, countNodes, createHtmlRenderer, darkTheme, defaultTheme, documentDefinitions, documentPages, expandRepeats, filterUnscopedPages, filterVariantScope, find, findAll, findByType, generateComponentStyles, generateStyles, getAncestors, getIconData, getMaxDepth, getNodeTypes, getTheme, guardedOutcomeAttrs, hasChildren, interactionSignature, interactiveAttrs, 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, lucideIcons, mapNodes, normalizeInteractionHandlers, normalizeStateGuard, renderIconSvg, renderPage, renderUnknownIconSvg, resolvePageDimensions, variantScope, walk, walkDocument } from './chunk-XYACLXXF.js';
|
|
10
|
+
import { GRAMMAR_CHILD_KEYWORDS, NODE_TYPE_MAP, VALID_ATTRIBUTE_NAMES } from './chunk-V3HVWC7C.js';
|
|
11
|
+
export { ATTRIBUTE_MAP, ATTRIBUTE_OVERRIDES, ATTRIBUTE_SPECS, BLOCK_NODE_SPECS, BOX_ATTRIBUTES, COMPONENT_MAP, COMPONENT_NAMES, COMPONENT_SPECS, COMPONENT_SPEC_BY_NAME, CONTAINER_ATTRIBUTES, DEFAULT_VIEWPORT, DEVICE_PRESETS, ELEMENT_NODE_TYPE_MAP, GRAMMAR_BLOCK_NODE_TYPES, GRAMMAR_CHILD_KEYWORDS, GRAMMAR_ELEMENTS, INTERACTIVE_ATTRIBUTES, LUCIDE_ICON_NAMES, NODE_TYPE_MAP, VALID_ATTRIBUTE_NAMES, VALID_COMPONENT_NAMES, attributeFor, calculateViewportScale, getDevicePresets, getValidAttributes, isValidAttribute, isValidDevicePreset, parseViewportString, resolveViewport, wrapInPreviewContainer } from './chunk-V3HVWC7C.js';
|
|
192
12
|
|
|
193
13
|
// src/printer/values.ts
|
|
194
14
|
var IDENTIFIER_RE = /^[a-zA-Z_][a-zA-Z0-9_-]*$/;
|
|
@@ -1530,6 +1350,189 @@ function importFromJson(json) {
|
|
|
1530
1350
|
return json.pages;
|
|
1531
1351
|
}
|
|
1532
1352
|
|
|
1353
|
+
// src/export/v4-figma.ts
|
|
1354
|
+
function routeKey(route) {
|
|
1355
|
+
var _a;
|
|
1356
|
+
return `${route.namespace}/${route.id}/${(_a = route.variant) != null ? _a : ""}`;
|
|
1357
|
+
}
|
|
1358
|
+
function scalar(value) {
|
|
1359
|
+
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean")
|
|
1360
|
+
return String(value);
|
|
1361
|
+
return "";
|
|
1362
|
+
}
|
|
1363
|
+
function validateProfile(profile) {
|
|
1364
|
+
if (profile === null || typeof profile !== "object") return null;
|
|
1365
|
+
const value = profile;
|
|
1366
|
+
if (value.id !== "wireweave-figma-mapping-v1" || value.target !== "figma-plugin-json-v1")
|
|
1367
|
+
return null;
|
|
1368
|
+
const screens = value.screens === void 0 ? "selected" : value.screens;
|
|
1369
|
+
if (screens !== "selected" && screens !== "all") return null;
|
|
1370
|
+
const board = value.board;
|
|
1371
|
+
if (board !== void 0 && (board === null || typeof board !== "object" || typeof board.namespace !== "string" || typeof board.id !== "string" || board.variant !== void 0 && typeof board.variant !== "string"))
|
|
1372
|
+
return null;
|
|
1373
|
+
return {
|
|
1374
|
+
id: "wireweave-figma-mapping-v1",
|
|
1375
|
+
target: "figma-plugin-json-v1",
|
|
1376
|
+
...board === void 0 ? {} : { board },
|
|
1377
|
+
screens
|
|
1378
|
+
};
|
|
1379
|
+
}
|
|
1380
|
+
function figmaType(kind) {
|
|
1381
|
+
if (["text", "title", "link", "badge", "marker"].includes(kind)) return "TEXT";
|
|
1382
|
+
if (["image", "placeholder", "divider", "icon", "avatar"].includes(kind)) return "RECTANGLE";
|
|
1383
|
+
return "FRAME";
|
|
1384
|
+
}
|
|
1385
|
+
function metadata(source) {
|
|
1386
|
+
return {
|
|
1387
|
+
identity: source.identity,
|
|
1388
|
+
moduleId: source.moduleId,
|
|
1389
|
+
source: source.source,
|
|
1390
|
+
invocationSources: source.invocationSources,
|
|
1391
|
+
requirementRefs: source.requirementRefs,
|
|
1392
|
+
obligationRefs: source.obligationRefs,
|
|
1393
|
+
operationIds: source.operationIds
|
|
1394
|
+
};
|
|
1395
|
+
}
|
|
1396
|
+
function semanticId(renderedId) {
|
|
1397
|
+
return `wf-${digestV4(renderedId).slice("sha256:".length)}`;
|
|
1398
|
+
}
|
|
1399
|
+
function nodeLabel(node) {
|
|
1400
|
+
var _a, _b;
|
|
1401
|
+
return scalar((_b = (_a = node.node.label) != null ? _a : node.node.attributes.label) != null ? _b : node.node.attributes.aria) || node.node.kind;
|
|
1402
|
+
}
|
|
1403
|
+
function nodeToFigma(node, sources, mappings) {
|
|
1404
|
+
const source = sources.get(node.renderedId);
|
|
1405
|
+
if (source === void 0) throw new TypeError(`Missing linked source map for ${node.renderedId}`);
|
|
1406
|
+
const id = semanticId(node.renderedId);
|
|
1407
|
+
mappings.push({ renderedId: node.renderedId, figmaId: id, identity: source.identity, source });
|
|
1408
|
+
const type = figmaType(node.node.kind);
|
|
1409
|
+
const attributes = node.node.attributes;
|
|
1410
|
+
const result = {
|
|
1411
|
+
id,
|
|
1412
|
+
name: nodeLabel(node),
|
|
1413
|
+
type,
|
|
1414
|
+
visible: true,
|
|
1415
|
+
wireweaveType: node.node.kind,
|
|
1416
|
+
wireweaveMetadata: metadata(source),
|
|
1417
|
+
...Object.keys(attributes).length === 0 ? {} : { wireweaveAttributes: attributes }
|
|
1418
|
+
};
|
|
1419
|
+
if (type === "TEXT") {
|
|
1420
|
+
result.textStyle = {
|
|
1421
|
+
fontSize: 16,
|
|
1422
|
+
fontWeight: node.node.kind === "title" ? 600 : 400,
|
|
1423
|
+
textAlignHorizontal: "LEFT",
|
|
1424
|
+
characters: nodeLabel(node)
|
|
1425
|
+
};
|
|
1426
|
+
} else if (type === "RECTANGLE") {
|
|
1427
|
+
result.size = { width: 200, height: node.node.kind === "divider" ? 1 : 120 };
|
|
1428
|
+
result.fills = [{ type: "SOLID", color: { r: 0.96, g: 0.96, b: 0.96, a: 1 } }];
|
|
1429
|
+
} else {
|
|
1430
|
+
result.autoLayout = {
|
|
1431
|
+
layoutMode: node.node.kind === "row" ? "HORIZONTAL" : "VERTICAL",
|
|
1432
|
+
layoutSizingHorizontal: "FILL",
|
|
1433
|
+
layoutSizingVertical: "HUG",
|
|
1434
|
+
primaryAxisAlignItems: "MIN",
|
|
1435
|
+
counterAxisAlignItems: "STRETCH",
|
|
1436
|
+
paddingTop: 8,
|
|
1437
|
+
paddingRight: 8,
|
|
1438
|
+
paddingBottom: 8,
|
|
1439
|
+
paddingLeft: 8,
|
|
1440
|
+
itemSpacing: 8,
|
|
1441
|
+
layoutWrap: "NO_WRAP"
|
|
1442
|
+
};
|
|
1443
|
+
result.size = { width: 1440, height: 1 };
|
|
1444
|
+
}
|
|
1445
|
+
if (node.children.length > 0)
|
|
1446
|
+
result.children = node.children.map((child) => nodeToFigma(child, sources, mappings));
|
|
1447
|
+
return result;
|
|
1448
|
+
}
|
|
1449
|
+
function screenRoots(data, screen) {
|
|
1450
|
+
var _a;
|
|
1451
|
+
const shell = screen.shell === void 0 ? void 0 : data.shells.find((item) => item.owner.key === screen.shell);
|
|
1452
|
+
return [...(_a = shell == null ? void 0 : shell.children) != null ? _a : [], ...screen.children];
|
|
1453
|
+
}
|
|
1454
|
+
function interactionLosses(sources) {
|
|
1455
|
+
return sources.flatMap(
|
|
1456
|
+
(source) => source.operationIds.map((operationId) => ({
|
|
1457
|
+
code: "WW_EXPORT_FIGMA_INTERACTION",
|
|
1458
|
+
kind: "interaction",
|
|
1459
|
+
message: "Figma mapping preserves operation identity but cannot execute runtime semantics.",
|
|
1460
|
+
renderedId: source.renderedId,
|
|
1461
|
+
operationId,
|
|
1462
|
+
source,
|
|
1463
|
+
details: { target: "figma-plugin-json-v1" }
|
|
1464
|
+
}))
|
|
1465
|
+
);
|
|
1466
|
+
}
|
|
1467
|
+
function exportLinkedAppToFigma(linked, profile) {
|
|
1468
|
+
var _a;
|
|
1469
|
+
const data = getLinkedAppData(linked);
|
|
1470
|
+
if (data === void 0)
|
|
1471
|
+
return failed([diagnostic("WW_SCHEMA", "app.untrusted-linked-model", void 0, {}, "compile")]);
|
|
1472
|
+
const valid = validateProfile(profile);
|
|
1473
|
+
if (valid === null)
|
|
1474
|
+
return failed([
|
|
1475
|
+
diagnostic("WW_EXPORT_PROFILE", "export.invalid-figma-profile", void 0, {}, "compile")
|
|
1476
|
+
]);
|
|
1477
|
+
const screens = data.screens.slice().sort((a, b) => routeKey(a.route).localeCompare(routeKey(b.route)));
|
|
1478
|
+
const target = (_a = valid.board) != null ? _a : data.bundle.entry;
|
|
1479
|
+
const selected = valid.screens === "all" ? screens : screens.filter((screen) => routeKey(screen.route) === routeKey(target));
|
|
1480
|
+
if (selected.length === 0)
|
|
1481
|
+
return failed([
|
|
1482
|
+
diagnostic("WW_EXPORT_BOARD", "export.board-not-found", void 0, {}, "compile")
|
|
1483
|
+
]);
|
|
1484
|
+
const renderedIds = /* @__PURE__ */ new Set();
|
|
1485
|
+
for (const screen of selected) {
|
|
1486
|
+
const pending = screenRoots(data, screen);
|
|
1487
|
+
while (pending.length > 0) {
|
|
1488
|
+
const node = pending.shift();
|
|
1489
|
+
renderedIds.add(node.renderedId);
|
|
1490
|
+
pending.unshift(...node.children);
|
|
1491
|
+
}
|
|
1492
|
+
}
|
|
1493
|
+
const sourceMap = data.sourceMap.filter((entry) => renderedIds.has(entry.renderedId)).slice().sort((a, b) => a.renderedId.localeCompare(b.renderedId));
|
|
1494
|
+
const sourceById = new Map(sourceMap.map((entry) => [entry.renderedId, entry]));
|
|
1495
|
+
const mappings = [];
|
|
1496
|
+
const document = {
|
|
1497
|
+
id: `document-${digestV4(linked.digest).slice("sha256:".length)}`,
|
|
1498
|
+
name: data.bundle.id,
|
|
1499
|
+
type: "DOCUMENT",
|
|
1500
|
+
visible: true,
|
|
1501
|
+
children: selected.map((screen) => ({
|
|
1502
|
+
id: `canvas-${digestV4(routeKey(screen.route)).slice("sha256:".length)}`,
|
|
1503
|
+
name: routeKey(screen.route),
|
|
1504
|
+
type: "CANVAS",
|
|
1505
|
+
visible: true,
|
|
1506
|
+
children: screenRoots(data, screen).map((node) => nodeToFigma(node, sourceById, mappings))
|
|
1507
|
+
}))
|
|
1508
|
+
};
|
|
1509
|
+
mappings.sort((a, b) => a.renderedId.localeCompare(b.renderedId));
|
|
1510
|
+
const lossReport = interactionLosses(sourceMap);
|
|
1511
|
+
const diagnostics = lossReport.length ? [
|
|
1512
|
+
{
|
|
1513
|
+
severity: "warning",
|
|
1514
|
+
code: "WW_EXPORT_FIGMA_INTERACTION",
|
|
1515
|
+
message: "Runtime operations are preserved as metadata and recorded in lossReport.",
|
|
1516
|
+
details: { count: lossReport.length }
|
|
1517
|
+
}
|
|
1518
|
+
] : [];
|
|
1519
|
+
const artifact = freeze({
|
|
1520
|
+
kind: "FigmaMappingArtifact",
|
|
1521
|
+
version: "4.0.0",
|
|
1522
|
+
format: "figma",
|
|
1523
|
+
target: valid.target,
|
|
1524
|
+
appId: data.bundle.id,
|
|
1525
|
+
linkedDigest: linked.digest,
|
|
1526
|
+
profileDigest: digestV4(jcs(valid)),
|
|
1527
|
+
document,
|
|
1528
|
+
mappings,
|
|
1529
|
+
sourceMap,
|
|
1530
|
+
lossReport,
|
|
1531
|
+
diagnostics
|
|
1532
|
+
});
|
|
1533
|
+
return { ok: true, value: artifact, diagnostics: [] };
|
|
1534
|
+
}
|
|
1535
|
+
|
|
1533
1536
|
// src/export/figma.ts
|
|
1534
1537
|
var SPACING_SCALE = {
|
|
1535
1538
|
0: 0,
|
|
@@ -1753,13 +1756,13 @@ function extractStrokes(node) {
|
|
|
1753
1756
|
strokeWeight: 1
|
|
1754
1757
|
};
|
|
1755
1758
|
}
|
|
1756
|
-
function
|
|
1757
|
-
const
|
|
1759
|
+
function nodeToFigma2(node) {
|
|
1760
|
+
const figmaType2 = mapToFigmaType(node.type);
|
|
1758
1761
|
const content = getNodeContent(node);
|
|
1759
1762
|
const figmaNode = {
|
|
1760
1763
|
id: generateFigmaId(),
|
|
1761
1764
|
name: content || node.type,
|
|
1762
|
-
type:
|
|
1765
|
+
type: figmaType2,
|
|
1763
1766
|
visible: true,
|
|
1764
1767
|
wireweaveType: node.type.toLowerCase()
|
|
1765
1768
|
};
|
|
@@ -1767,7 +1770,7 @@ function nodeToFigma(node) {
|
|
|
1767
1770
|
if (Object.keys(attrs).length > 0) {
|
|
1768
1771
|
figmaNode.wireweaveAttributes = attrs;
|
|
1769
1772
|
}
|
|
1770
|
-
if (
|
|
1773
|
+
if (figmaType2 === "FRAME") {
|
|
1771
1774
|
figmaNode.autoLayout = extractAutoLayout(node);
|
|
1772
1775
|
figmaNode.size = extractSize(node);
|
|
1773
1776
|
const fills = extractFills(node);
|
|
@@ -1780,12 +1783,12 @@ function nodeToFigma(node) {
|
|
|
1780
1783
|
if (node.type.toLowerCase() === "card") {
|
|
1781
1784
|
figmaNode.cornerRadius = 8;
|
|
1782
1785
|
}
|
|
1783
|
-
} else if (
|
|
1786
|
+
} else if (figmaType2 === "TEXT") {
|
|
1784
1787
|
figmaNode.textStyle = extractTextStyle(node);
|
|
1785
1788
|
if (getAttr(node, "muted")) {
|
|
1786
1789
|
figmaNode.fills = [{ type: "SOLID", color: COLORS.textMuted }];
|
|
1787
1790
|
}
|
|
1788
|
-
} else if (
|
|
1791
|
+
} else if (figmaType2 === "RECTANGLE") {
|
|
1789
1792
|
figmaNode.size = extractSize(node, 200, 150);
|
|
1790
1793
|
const fills = extractFills(node);
|
|
1791
1794
|
if (fills) {
|
|
@@ -1798,7 +1801,7 @@ function nodeToFigma(node) {
|
|
|
1798
1801
|
const children = [];
|
|
1799
1802
|
for (const child of node.children) {
|
|
1800
1803
|
if (child && typeof child === "object" && "type" in child) {
|
|
1801
|
-
children.push(
|
|
1804
|
+
children.push(nodeToFigma2(child));
|
|
1802
1805
|
}
|
|
1803
1806
|
}
|
|
1804
1807
|
if (children.length > 0) {
|
|
@@ -1807,7 +1810,10 @@ function nodeToFigma(node) {
|
|
|
1807
1810
|
}
|
|
1808
1811
|
return figmaNode;
|
|
1809
1812
|
}
|
|
1810
|
-
function exportToFigma(doc) {
|
|
1813
|
+
function exportToFigma(doc, profile) {
|
|
1814
|
+
if ("kind" in doc && doc.kind === "LinkedApp")
|
|
1815
|
+
return exportLinkedAppToFigma(doc, profile);
|
|
1816
|
+
const legacyDocument = doc;
|
|
1811
1817
|
resetFigmaIdCounter();
|
|
1812
1818
|
const documentNode = {
|
|
1813
1819
|
id: generateFigmaId(),
|
|
@@ -1816,12 +1822,11 @@ function exportToFigma(doc) {
|
|
|
1816
1822
|
visible: true,
|
|
1817
1823
|
children: []
|
|
1818
1824
|
};
|
|
1819
|
-
for (const page of documentPages(
|
|
1820
|
-
;
|
|
1821
|
-
documentNode.children.push(nodeToFigma(page));
|
|
1825
|
+
for (const page of documentPages(legacyDocument)) {
|
|
1826
|
+
documentNode.children.push(nodeToFigma2(page));
|
|
1822
1827
|
}
|
|
1823
1828
|
const componentMappings = {};
|
|
1824
|
-
const types = getComponentTypes(
|
|
1829
|
+
const types = getComponentTypes(legacyDocument);
|
|
1825
1830
|
for (const type of types) {
|
|
1826
1831
|
componentMappings[type] = mapToFigmaType(type);
|
|
1827
1832
|
}
|
|
@@ -2540,196 +2545,5 @@ function buildDomTreeNode(node, path) {
|
|
|
2540
2545
|
if (label !== void 0) treeNode.label = label;
|
|
2541
2546
|
return treeNode;
|
|
2542
2547
|
}
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
ANCHOR_PATH_ATTR,
|
|
2546
|
-
ATTRIBUTE_MAP,
|
|
2547
|
-
ATTRIBUTE_OVERRIDES,
|
|
2548
|
-
ATTRIBUTE_SPECS,
|
|
2549
|
-
BLOCK_NODE_SPECS,
|
|
2550
|
-
BOX_ATTRIBUTES,
|
|
2551
|
-
COMPONENT_MAP,
|
|
2552
|
-
COMPONENT_NAMES,
|
|
2553
|
-
COMPONENT_SPECS,
|
|
2554
|
-
COMPONENT_SPEC_BY_NAME,
|
|
2555
|
-
CONTAINER_ATTRIBUTES,
|
|
2556
|
-
DEFAULT_VIEWPORT,
|
|
2557
|
-
DEVICE_PRESETS,
|
|
2558
|
-
ELEMENT_NODE_TYPE_MAP,
|
|
2559
|
-
ENABLED_GUARD_ATTR,
|
|
2560
|
-
EXTERNAL_NAVIGATE_ATTR,
|
|
2561
|
-
GRAMMAR_BLOCK_NODE_TYPES,
|
|
2562
|
-
GRAMMAR_CHILD_KEYWORDS,
|
|
2563
|
-
GRAMMAR_ELEMENTS,
|
|
2564
|
-
HtmlRenderer,
|
|
2565
|
-
INERT_HREF,
|
|
2566
|
-
INTERACTIVE_ATTRIBUTES,
|
|
2567
|
-
INTERACTIVE_ATTR_NAMES,
|
|
2568
|
-
LUCIDE_ICON_NAMES,
|
|
2569
|
-
NODE_TYPE_MAP,
|
|
2570
|
-
REPEAT_EXPANSION_BUDGET,
|
|
2571
|
-
RepeatBudgetError,
|
|
2572
|
-
TYPED_INTERACTION_ATTR,
|
|
2573
|
-
V4ParseError,
|
|
2574
|
-
VALID_ATTRIBUTE_NAMES,
|
|
2575
|
-
VALID_COMPONENT_NAMES,
|
|
2576
|
-
VISIBLE_GUARD_ATTR,
|
|
2577
|
-
advanceClock,
|
|
2578
|
-
analyze,
|
|
2579
|
-
anchorIntent,
|
|
2580
|
-
areIdentical,
|
|
2581
|
-
attributeFor,
|
|
2582
|
-
buildAnchorIndex,
|
|
2583
|
-
buildDomTree,
|
|
2584
|
-
buildSiteModel,
|
|
2585
|
-
calculateViewportScale,
|
|
2586
|
-
cloneNode,
|
|
2587
|
-
collectInteractions,
|
|
2588
|
-
collectParameterReferences,
|
|
2589
|
-
compileApp,
|
|
2590
|
-
contains,
|
|
2591
|
-
countNodes,
|
|
2592
|
-
createAppBundle,
|
|
2593
|
-
createAppComponentInstanceId,
|
|
2594
|
-
createAppNodeId,
|
|
2595
|
-
createHtmlRenderer,
|
|
2596
|
-
createRuntime,
|
|
2597
|
-
darkTheme,
|
|
2598
|
-
defaultTheme,
|
|
2599
|
-
diff,
|
|
2600
|
-
documentDefinitions,
|
|
2601
|
-
documentPages,
|
|
2602
|
-
expandRepeats,
|
|
2603
|
-
expandVariants,
|
|
2604
|
-
exportToFigma,
|
|
2605
|
-
exportToFigmaString,
|
|
2606
|
-
exportToJson,
|
|
2607
|
-
exportToJsonString,
|
|
2608
|
-
extractAllScreenFields,
|
|
2609
|
-
extractScreenFields,
|
|
2610
|
-
extractScreenTransitions,
|
|
2611
|
-
filterUnscopedPages,
|
|
2612
|
-
filterVariantScope,
|
|
2613
|
-
find,
|
|
2614
|
-
findAll,
|
|
2615
|
-
findByType,
|
|
2616
|
-
formatWireframeCode,
|
|
2617
|
-
generateComponentStyles,
|
|
2618
|
-
generateStyles,
|
|
2619
|
-
getAncestors,
|
|
2620
|
-
getChangeSummary,
|
|
2621
|
-
getDevicePresets,
|
|
2622
|
-
getErrors,
|
|
2623
|
-
getIconData,
|
|
2624
|
-
getMaxDepth,
|
|
2625
|
-
getNodeSource,
|
|
2626
|
-
getNodeTypes,
|
|
2627
|
-
getPageSource,
|
|
2628
|
-
getTheme,
|
|
2629
|
-
getV4SourceSpan,
|
|
2630
|
-
getValidAttributes,
|
|
2631
|
-
getValidationErrors,
|
|
2632
|
-
guardedOutcomeAttrs,
|
|
2633
|
-
hasChildren,
|
|
2634
|
-
importFromJson,
|
|
2635
|
-
interactionSignature,
|
|
2636
|
-
interactiveAttrs,
|
|
2637
|
-
isAccordionNode,
|
|
2638
|
-
isAlertNode,
|
|
2639
|
-
isAvatarNode,
|
|
2640
|
-
isBadgeNode,
|
|
2641
|
-
isBreadcrumbNode,
|
|
2642
|
-
isButtonNode,
|
|
2643
|
-
isCardNode,
|
|
2644
|
-
isCheckboxNode,
|
|
2645
|
-
isColNode,
|
|
2646
|
-
isComponentDefinitionNode,
|
|
2647
|
-
isComponentUseNode,
|
|
2648
|
-
isContainerComponentNode,
|
|
2649
|
-
isContainerNode,
|
|
2650
|
-
isDataNode,
|
|
2651
|
-
isDefinitionNode,
|
|
2652
|
-
isDisplayNode,
|
|
2653
|
-
isDividerNode,
|
|
2654
|
-
isDrawerNode,
|
|
2655
|
-
isDropdownNode,
|
|
2656
|
-
isFeedbackNode,
|
|
2657
|
-
isFooterNode,
|
|
2658
|
-
isGridNode,
|
|
2659
|
-
isHeaderNode,
|
|
2660
|
-
isIconNode,
|
|
2661
|
-
isImageNode,
|
|
2662
|
-
isInputComponentNode,
|
|
2663
|
-
isInputNode,
|
|
2664
|
-
isLayoutDefinitionNode,
|
|
2665
|
-
isLayoutNode,
|
|
2666
|
-
isLeafNode,
|
|
2667
|
-
isLinkNode,
|
|
2668
|
-
isListNode,
|
|
2669
|
-
isMainNode,
|
|
2670
|
-
isModalNode,
|
|
2671
|
-
isNavNode,
|
|
2672
|
-
isNavigationNode,
|
|
2673
|
-
isNodeType,
|
|
2674
|
-
isOverlayNode,
|
|
2675
|
-
isPageNode,
|
|
2676
|
-
isPlaceholderNode,
|
|
2677
|
-
isPopoverNode,
|
|
2678
|
-
isProgressNode,
|
|
2679
|
-
isRadioNode,
|
|
2680
|
-
isRowNode,
|
|
2681
|
-
isSectionNode,
|
|
2682
|
-
isSelectNode,
|
|
2683
|
-
isSidebarNode,
|
|
2684
|
-
isSliderNode,
|
|
2685
|
-
isSlotNode,
|
|
2686
|
-
isSpinnerNode,
|
|
2687
|
-
isSwitchNode,
|
|
2688
|
-
isTableNode,
|
|
2689
|
-
isTabsNode,
|
|
2690
|
-
isTextContentNode,
|
|
2691
|
-
isTextNode,
|
|
2692
|
-
isTextareaNode,
|
|
2693
|
-
isTitleNode,
|
|
2694
|
-
isToastNode,
|
|
2695
|
-
isTooltipNode,
|
|
2696
|
-
isUrlTarget,
|
|
2697
|
-
isValid,
|
|
2698
|
-
isValidAst,
|
|
2699
|
-
isValidAttribute,
|
|
2700
|
-
isValidDevicePreset,
|
|
2701
|
-
layoutCanvas,
|
|
2702
|
-
linkAndCompileApp,
|
|
2703
|
-
linkApp,
|
|
2704
|
-
lucideIcons,
|
|
2705
|
-
mapNodes,
|
|
2706
|
-
normalizeInteractionHandlers,
|
|
2707
|
-
normalizeStateGuard,
|
|
2708
|
-
parameterReferenceName,
|
|
2709
|
-
parse,
|
|
2710
|
-
parseV4,
|
|
2711
|
-
parseViewportString,
|
|
2712
|
-
printWireframe,
|
|
2713
|
-
reduceEvent,
|
|
2714
|
-
render,
|
|
2715
|
-
renderSite2 as renderAppSite,
|
|
2716
|
-
renderCanvas,
|
|
2717
|
-
renderIconSvg,
|
|
2718
|
-
renderPage,
|
|
2719
|
-
renderSite,
|
|
2720
|
-
renderToHtml,
|
|
2721
|
-
renderToSvg,
|
|
2722
|
-
renderUnknownIconSvg,
|
|
2723
|
-
resetFigmaIdCounter,
|
|
2724
|
-
resetRuntime,
|
|
2725
|
-
resolveAnchor,
|
|
2726
|
-
resolvePageDimensions,
|
|
2727
|
-
resolveViewport,
|
|
2728
|
-
tryParse,
|
|
2729
|
-
tryParseV4,
|
|
2730
|
-
validate,
|
|
2731
|
-
variantScope,
|
|
2732
|
-
walk,
|
|
2733
|
-
walkDocument,
|
|
2734
|
-
wrapInPreviewContainer
|
|
2735
|
-
};
|
|
2548
|
+
|
|
2549
|
+
export { analyze, areIdentical, buildAnchorIndex, buildDomTree, diff, exportLinkedAppToFigma, exportToFigma, exportToFigmaString, exportToJson, exportToJsonString, extractAllScreenFields, extractScreenFields, extractScreenTransitions, formatWireframeCode, getChangeSummary, getNodeSource, getPageSource, getValidationErrors, importFromJson, isValidAst, printWireframe, resetFigmaIdCounter, resolveAnchor, validate };
|
package/dist/interaction.cjs
CHANGED
|
@@ -1,17 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkZPHNXJRY_cjs = require('./chunk-ZPHNXJRY.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "collectInteractions", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () { return chunkZPHNXJRY_cjs.collectInteractions; }
|
|
10
|
+
});
|
|
11
|
+
Object.defineProperty(exports, "interactionSignature", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () { return chunkZPHNXJRY_cjs.interactionSignature; }
|
|
14
|
+
});
|
|
15
|
+
Object.defineProperty(exports, "isUrlTarget", {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () { return chunkZPHNXJRY_cjs.isUrlTarget; }
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports, "normalizeInteractionHandlers", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () { return chunkZPHNXJRY_cjs.normalizeInteractionHandlers; }
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports, "normalizeStateGuard", {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
get: function () { return chunkZPHNXJRY_cjs.normalizeStateGuard; }
|
|
26
|
+
});
|