@open-pencil/scene-graph 0.14.0 → 0.15.0
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/arrow-caps.d.ts +44 -0
- package/dist/arrow-caps.d.ts.map +1 -0
- package/dist/arrow-caps.js +131 -0
- package/dist/arrow-caps.js.map +1 -0
- package/dist/chunks/checkpoint.js +78 -0
- package/dist/chunks/checkpoint.js.map +1 -0
- package/dist/chunks/components/properties.js +1571 -0
- package/dist/chunks/components/properties.js.map +1 -0
- package/dist/chunks/coordinate.js +87 -33
- package/dist/chunks/coordinate.js.map +1 -1
- package/dist/chunks/font-style.js +2 -1
- package/dist/chunks/font-style.js.map +1 -1
- package/dist/chunks/index.js +1283 -0
- package/dist/chunks/index.js.map +1 -0
- package/dist/constants.js +1 -18
- package/dist/constants2.d.ts +0 -1
- package/dist/constants2.d.ts.map +1 -1
- package/dist/coordinate.d.ts +107 -11
- package/dist/coordinate.d.ts.map +1 -1
- package/dist/coordinate.js +2 -2
- package/dist/coordinate2.d.ts +2 -2
- package/dist/copy.d.ts +2 -2
- package/dist/copy.js +2 -2
- package/dist/geometry.d.ts +2 -2
- package/dist/geometry.js +2 -431
- package/dist/guides.d.ts +2 -0
- package/dist/guides.js +0 -0
- package/dist/guides2.d.ts +11 -0
- package/dist/guides2.d.ts.map +1 -0
- package/dist/hit-test.d.ts +1 -2
- package/dist/hit-test.d.ts.map +1 -1
- package/dist/hit-test.js +26 -14
- package/dist/hit-test.js.map +1 -1
- package/dist/images.js +0 -1
- package/dist/images.js.map +1 -1
- package/dist/images2.d.ts.map +1 -1
- package/dist/index.d.ts +5 -3
- package/dist/index.js +5 -6
- package/dist/instances.d.ts +2 -2
- package/dist/instances.js +2 -2
- package/dist/layout-guides.d.ts +2 -0
- package/dist/layout-guides.js +2 -0
- package/dist/layout-guides2.d.ts +16 -0
- package/dist/layout-guides2.d.ts.map +1 -0
- package/dist/matrix2.d.ts +0 -1
- package/dist/matrix2.d.ts.map +1 -1
- package/dist/node-defaults.d.ts +1 -2
- package/dist/node-defaults.d.ts.map +1 -1
- package/dist/node-defaults.js +1 -1
- package/dist/parse-path.d.ts +1 -2
- package/dist/parse-path.d.ts.map +1 -1
- package/dist/parse-path.js.map +1 -1
- package/dist/preview.d.ts +2 -12
- package/dist/preview.js +1 -1
- package/dist/preview2.d.ts +12 -0
- package/dist/preview2.d.ts.map +1 -0
- package/dist/primitives2.d.ts.map +1 -1
- package/dist/resize.d.ts +18 -4
- package/dist/resize.d.ts.map +1 -1
- package/dist/resize.js +70 -22
- package/dist/resize.js.map +1 -1
- package/dist/snap.js +1 -1
- package/dist/source-metadata.d.ts +1 -2
- package/dist/source-metadata.d.ts.map +1 -1
- package/dist/source-metadata.js +1 -1
- package/dist/text-picture.d.ts +13 -2
- package/dist/text-picture.d.ts.map +1 -1
- package/dist/text-picture.js +2 -2
- package/dist/types.d.ts +499 -2
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +1 -1296
- package/dist/types2.d.ts +2 -430
- package/dist/undo.js +1 -1
- package/dist/undo2.d.ts +5 -0
- package/dist/undo2.d.ts.map +1 -1
- package/dist/variables.d.ts +1 -2
- package/dist/variables.d.ts.map +1 -1
- package/dist/variables.js +1 -1
- package/dist/variant-name.d.ts.map +1 -1
- package/dist/variant-properties.d.ts +10 -0
- package/dist/variant-properties.d.ts.map +1 -0
- package/dist/variant-properties.js +39 -0
- package/dist/variant-properties.js.map +1 -0
- package/dist/vector-network.js +1 -1
- package/dist/vector-network2.d.ts +1 -2
- package/dist/vector-network2.d.ts.map +1 -1
- package/package.json +40 -15
- package/src/arrow-caps.ts +146 -0
- package/src/bindings.ts +20 -0
- package/src/checkpoint.ts +123 -0
- package/src/components/properties.ts +238 -0
- package/src/constants.ts +6 -0
- package/src/coordinate.ts +226 -0
- package/src/copy.ts +294 -0
- package/src/events.ts +21 -0
- package/src/export-scale.ts +16 -0
- package/src/font-style.ts +77 -0
- package/src/geometry.ts +530 -0
- package/src/guides.ts +8 -0
- package/src/hit-test.ts +205 -0
- package/src/images.ts +34 -0
- package/src/index.ts +686 -0
- package/src/instance-overrides.test.ts +67 -0
- package/src/instance-overrides.ts +152 -0
- package/src/instances.ts +480 -0
- package/src/layout-guides.ts +103 -0
- package/src/matrix.ts +116 -0
- package/src/mutation-impact.ts +70 -0
- package/src/node-defaults.ts +186 -0
- package/src/parse-path.ts +191 -0
- package/src/preview.ts +80 -0
- package/src/primitives.ts +42 -0
- package/src/resize.ts +302 -0
- package/src/shared-styles.ts +73 -0
- package/src/snap.ts +129 -0
- package/src/source-metadata.ts +8 -0
- package/src/text-picture.ts +65 -0
- package/src/types.ts +635 -0
- package/src/undo.ts +171 -0
- package/src/variables.ts +399 -0
- package/src/variant-name.ts +15 -0
- package/src/variant-properties.ts +48 -0
- package/src/vector-network.ts +293 -0
- package/dist/chunks/copy.js +0 -576
- package/dist/chunks/copy.js.map +0 -1
- package/dist/constants.js.map +0 -1
- package/dist/geometry.js.map +0 -1
- package/dist/preview.d.ts.map +0 -1
- package/dist/types.js.map +0 -1
- package/dist/types2.d.ts.map +0 -1
package/dist/chunks/copy.js
DELETED
|
@@ -1,576 +0,0 @@
|
|
|
1
|
-
import { BLACK, DEFAULT_FONT_FAMILY } from "../constants.js";
|
|
2
|
-
import { isEqual } from "es-toolkit/predicate";
|
|
3
|
-
//#region src/node-defaults.ts
|
|
4
|
-
function createDefaultSourceMetadata() {
|
|
5
|
-
return {
|
|
6
|
-
format: null,
|
|
7
|
-
id: null,
|
|
8
|
-
orderKey: null,
|
|
9
|
-
editedFields: [],
|
|
10
|
-
fig: {
|
|
11
|
-
rawSize: null,
|
|
12
|
-
rawTransform: null,
|
|
13
|
-
rawNodeFields: {},
|
|
14
|
-
layout: null,
|
|
15
|
-
symbolOverrides: [],
|
|
16
|
-
componentPropAssignments: [],
|
|
17
|
-
derivedSymbolData: [],
|
|
18
|
-
derivedSymbolDataLayoutVersion: null,
|
|
19
|
-
uniformScaleFactor: null
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
function createDefaultNode(generateId, type, overrides = {}) {
|
|
24
|
-
return {
|
|
25
|
-
id: generateId(),
|
|
26
|
-
type,
|
|
27
|
-
name: type.charAt(0) + type.slice(1).toLowerCase(),
|
|
28
|
-
parentId: null,
|
|
29
|
-
childIds: [],
|
|
30
|
-
x: 0,
|
|
31
|
-
y: 0,
|
|
32
|
-
width: 100,
|
|
33
|
-
height: 100,
|
|
34
|
-
rotation: 0,
|
|
35
|
-
source: createDefaultSourceMetadata(),
|
|
36
|
-
figmaDerivedLayout: null,
|
|
37
|
-
fills: type === "TEXT" ? [{
|
|
38
|
-
type: "SOLID",
|
|
39
|
-
color: BLACK,
|
|
40
|
-
opacity: 1,
|
|
41
|
-
visible: true
|
|
42
|
-
}] : [],
|
|
43
|
-
strokes: [],
|
|
44
|
-
effects: [],
|
|
45
|
-
layoutGrids: [],
|
|
46
|
-
fillStyleId: null,
|
|
47
|
-
strokeStyleId: null,
|
|
48
|
-
textStyleId: null,
|
|
49
|
-
effectStyleId: null,
|
|
50
|
-
gridStyleId: null,
|
|
51
|
-
sharedStyleType: null,
|
|
52
|
-
opacity: 1,
|
|
53
|
-
cornerRadius: 0,
|
|
54
|
-
topLeftRadius: 0,
|
|
55
|
-
topRightRadius: 0,
|
|
56
|
-
bottomRightRadius: 0,
|
|
57
|
-
bottomLeftRadius: 0,
|
|
58
|
-
independentCorners: false,
|
|
59
|
-
cornerSmoothing: 0,
|
|
60
|
-
visible: true,
|
|
61
|
-
locked: false,
|
|
62
|
-
clipsContent: false,
|
|
63
|
-
text: "",
|
|
64
|
-
fontSize: 14,
|
|
65
|
-
fontFamily: DEFAULT_FONT_FAMILY,
|
|
66
|
-
fontWeight: 400,
|
|
67
|
-
italic: false,
|
|
68
|
-
textAlignHorizontal: "LEFT",
|
|
69
|
-
textDirection: "AUTO",
|
|
70
|
-
textLanguage: null,
|
|
71
|
-
leadingTrim: "NONE",
|
|
72
|
-
lineHeight: null,
|
|
73
|
-
letterSpacing: 0,
|
|
74
|
-
layoutMode: "NONE",
|
|
75
|
-
layoutDirection: "AUTO",
|
|
76
|
-
layoutWrap: "NO_WRAP",
|
|
77
|
-
primaryAxisAlign: "MIN",
|
|
78
|
-
counterAxisAlign: "MIN",
|
|
79
|
-
primaryAxisSizing: "FIXED",
|
|
80
|
-
counterAxisSizing: "FIXED",
|
|
81
|
-
itemSpacing: 0,
|
|
82
|
-
counterAxisSpacing: 0,
|
|
83
|
-
paddingTop: 0,
|
|
84
|
-
paddingRight: 0,
|
|
85
|
-
paddingBottom: 0,
|
|
86
|
-
paddingLeft: 0,
|
|
87
|
-
blendMode: "PASS_THROUGH",
|
|
88
|
-
layoutPositioning: "AUTO",
|
|
89
|
-
layoutGrow: 0,
|
|
90
|
-
layoutAlignSelf: "AUTO",
|
|
91
|
-
vectorNetwork: null,
|
|
92
|
-
handleMirroring: "NONE",
|
|
93
|
-
fillGeometry: [],
|
|
94
|
-
strokeGeometry: [],
|
|
95
|
-
arcData: null,
|
|
96
|
-
textAlignVertical: "TOP",
|
|
97
|
-
textAutoResize: "NONE",
|
|
98
|
-
textCase: "ORIGINAL",
|
|
99
|
-
textDecoration: "NONE",
|
|
100
|
-
textDecorationStyle: "SOLID",
|
|
101
|
-
textDecorationThickness: null,
|
|
102
|
-
textDecorationFills: [],
|
|
103
|
-
textDecorationSkipInk: true,
|
|
104
|
-
textUnderlineOffset: null,
|
|
105
|
-
maxLines: null,
|
|
106
|
-
styleRuns: [],
|
|
107
|
-
fontVariations: [],
|
|
108
|
-
fontFeatures: [],
|
|
109
|
-
horizontalConstraint: "MIN",
|
|
110
|
-
verticalConstraint: "MIN",
|
|
111
|
-
strokeCap: "NONE",
|
|
112
|
-
strokeJoin: "MITER",
|
|
113
|
-
dashPattern: [],
|
|
114
|
-
borderTopWeight: 0,
|
|
115
|
-
borderRightWeight: 0,
|
|
116
|
-
borderBottomWeight: 0,
|
|
117
|
-
borderLeftWeight: 0,
|
|
118
|
-
independentStrokeWeights: false,
|
|
119
|
-
strokeMiterLimit: 4,
|
|
120
|
-
minWidth: null,
|
|
121
|
-
maxWidth: null,
|
|
122
|
-
minHeight: null,
|
|
123
|
-
maxHeight: null,
|
|
124
|
-
isMask: false,
|
|
125
|
-
maskType: "ALPHA",
|
|
126
|
-
maskIsOutline: false,
|
|
127
|
-
gridTemplateColumns: [],
|
|
128
|
-
gridTemplateRows: [],
|
|
129
|
-
gridColumnGap: 0,
|
|
130
|
-
gridRowGap: 0,
|
|
131
|
-
gridPosition: null,
|
|
132
|
-
counterAxisAlignContent: "AUTO",
|
|
133
|
-
itemReverseZIndex: false,
|
|
134
|
-
strokesIncludedInLayout: false,
|
|
135
|
-
expanded: true,
|
|
136
|
-
textTruncation: "DISABLED",
|
|
137
|
-
autoRename: true,
|
|
138
|
-
pointCount: 5,
|
|
139
|
-
starInnerRadius: .38,
|
|
140
|
-
componentId: null,
|
|
141
|
-
overrides: {},
|
|
142
|
-
componentPropertyDefinitions: [],
|
|
143
|
-
componentPropertyReferences: [],
|
|
144
|
-
componentPropertyAssignments: {},
|
|
145
|
-
componentPropertyValues: {},
|
|
146
|
-
componentKey: null,
|
|
147
|
-
sourceLibraryKey: null,
|
|
148
|
-
publishId: null,
|
|
149
|
-
overrideKey: null,
|
|
150
|
-
sharedSymbolVersion: null,
|
|
151
|
-
publishedVersion: null,
|
|
152
|
-
isPublishable: false,
|
|
153
|
-
isSymbolPublishable: false,
|
|
154
|
-
symbolDescription: "",
|
|
155
|
-
symbolLinks: [],
|
|
156
|
-
variantPropSpecs: [],
|
|
157
|
-
boundVariables: {},
|
|
158
|
-
variableModes: {},
|
|
159
|
-
exportSettings: [],
|
|
160
|
-
pluginData: [],
|
|
161
|
-
pluginRelaunchData: [],
|
|
162
|
-
internalOnly: false,
|
|
163
|
-
flipX: false,
|
|
164
|
-
flipY: false,
|
|
165
|
-
textPicture: null,
|
|
166
|
-
figmaDerivedTextGlyphs: null,
|
|
167
|
-
...overrides
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
|
-
const CONTAINER_TYPES = /* @__PURE__ */ new Set([
|
|
171
|
-
"CANVAS",
|
|
172
|
-
"FRAME",
|
|
173
|
-
"GROUP",
|
|
174
|
-
"BOOLEAN_OPERATION",
|
|
175
|
-
"SECTION",
|
|
176
|
-
"COMPONENT",
|
|
177
|
-
"COMPONENT_SET",
|
|
178
|
-
"INSTANCE"
|
|
179
|
-
]);
|
|
180
|
-
//#endregion
|
|
181
|
-
//#region src/vector-network.ts
|
|
182
|
-
/** Concatenate vector networks while preserving independent geometry. */
|
|
183
|
-
function mergeVectorNetworks(networks) {
|
|
184
|
-
const vertices = [];
|
|
185
|
-
const segments = [];
|
|
186
|
-
const regions = [];
|
|
187
|
-
let vertexOffset = 0;
|
|
188
|
-
let segmentOffset = 0;
|
|
189
|
-
for (const network of networks) {
|
|
190
|
-
for (const vertex of network.vertices) vertices.push({ ...vertex });
|
|
191
|
-
for (const segment of network.segments) segments.push({
|
|
192
|
-
...segment,
|
|
193
|
-
start: segment.start + vertexOffset,
|
|
194
|
-
end: segment.end + vertexOffset,
|
|
195
|
-
tangentStart: { ...segment.tangentStart },
|
|
196
|
-
tangentEnd: { ...segment.tangentEnd }
|
|
197
|
-
});
|
|
198
|
-
for (const region of network.regions) {
|
|
199
|
-
const loops = [];
|
|
200
|
-
for (const loop of region.loops) {
|
|
201
|
-
const shifted = [];
|
|
202
|
-
for (const segmentIndex of loop) shifted.push(segmentIndex + segmentOffset);
|
|
203
|
-
loops.push(shifted);
|
|
204
|
-
}
|
|
205
|
-
regions.push({
|
|
206
|
-
windingRule: region.windingRule,
|
|
207
|
-
loops
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
vertexOffset += network.vertices.length;
|
|
211
|
-
segmentOffset += network.segments.length;
|
|
212
|
-
}
|
|
213
|
-
return {
|
|
214
|
-
vertices,
|
|
215
|
-
segments,
|
|
216
|
-
regions
|
|
217
|
-
};
|
|
218
|
-
}
|
|
219
|
-
/**
|
|
220
|
-
* Map a VectorNetwork through an affine matrix: vertices as points,
|
|
221
|
-
* tangents as direction vectors (linear part only, no translation).
|
|
222
|
-
* Returns a deep copy; the input is not mutated.
|
|
223
|
-
*/
|
|
224
|
-
function transformVectorNetwork(m, vn) {
|
|
225
|
-
const mapVector = (v) => ({
|
|
226
|
-
x: m[0] * v.x + m[1] * v.y,
|
|
227
|
-
y: m[3] * v.x + m[4] * v.y
|
|
228
|
-
});
|
|
229
|
-
return {
|
|
230
|
-
vertices: vn.vertices.map((v) => ({
|
|
231
|
-
...v,
|
|
232
|
-
x: m[0] * v.x + m[1] * v.y + m[2],
|
|
233
|
-
y: m[3] * v.x + m[4] * v.y + m[5]
|
|
234
|
-
})),
|
|
235
|
-
segments: vn.segments.map((s) => ({
|
|
236
|
-
...s,
|
|
237
|
-
tangentStart: mapVector(s.tangentStart),
|
|
238
|
-
tangentEnd: mapVector(s.tangentEnd)
|
|
239
|
-
})),
|
|
240
|
-
regions: vn.regions.map((r) => ({
|
|
241
|
-
windingRule: r.windingRule,
|
|
242
|
-
loops: r.loops.map((l) => [...l])
|
|
243
|
-
}))
|
|
244
|
-
};
|
|
245
|
-
}
|
|
246
|
-
/** Structural equality of two VectorNetworks (order-sensitive, exact values). */
|
|
247
|
-
function vectorNetworksEqual(a, b) {
|
|
248
|
-
return isEqual(a.vertices, b.vertices) && isEqual(a.segments, b.segments) && isEqual(a.regions, b.regions);
|
|
249
|
-
}
|
|
250
|
-
/** Deep-copy a VectorNetwork, stripping any Vue Proxy wrappers. */
|
|
251
|
-
function cloneVectorNetwork(vn) {
|
|
252
|
-
return {
|
|
253
|
-
vertices: vn.vertices.map((v) => ({ ...v })),
|
|
254
|
-
segments: vn.segments.map((s) => ({
|
|
255
|
-
...s,
|
|
256
|
-
tangentStart: { ...s.tangentStart },
|
|
257
|
-
tangentEnd: { ...s.tangentEnd }
|
|
258
|
-
})),
|
|
259
|
-
regions: vn.regions.map((r) => ({
|
|
260
|
-
windingRule: r.windingRule,
|
|
261
|
-
loops: r.loops.map((l) => [...l])
|
|
262
|
-
}))
|
|
263
|
-
};
|
|
264
|
-
}
|
|
265
|
-
/**
|
|
266
|
-
* Validate a VectorNetwork structure, returning an array of error messages.
|
|
267
|
-
* Empty array means the network is valid.
|
|
268
|
-
*/
|
|
269
|
-
function validateVectorNetwork(value) {
|
|
270
|
-
if (!isRecord(value)) return ["network must be an object"];
|
|
271
|
-
if (!Array.isArray(value.vertices)) return ["vertices must be an array"];
|
|
272
|
-
if (!Array.isArray(value.segments)) return ["segments must be an array"];
|
|
273
|
-
const errors = [];
|
|
274
|
-
validateVertices(value.vertices, errors);
|
|
275
|
-
validateSegments(value.segments, value.vertices.length, errors);
|
|
276
|
-
const typedSegments = value.segments.filter(isSegmentRecord);
|
|
277
|
-
if (value.regions !== void 0) if (Array.isArray(value.regions)) validateRegions(value.regions, value.segments.length, typedSegments.length === value.segments.length ? typedSegments : null, errors);
|
|
278
|
-
else errors.push("regions must be an array when provided");
|
|
279
|
-
return errors;
|
|
280
|
-
}
|
|
281
|
-
function validateVertices(vertices, errors) {
|
|
282
|
-
for (let index = 0; index < vertices.length; index++) if (!isFiniteVector(vertices[index])) errors.push(`vertex[${index}]: x and y must be finite numbers`);
|
|
283
|
-
}
|
|
284
|
-
function validateSegments(segments, vertexCount, errors) {
|
|
285
|
-
for (let index = 0; index < segments.length; index++) {
|
|
286
|
-
const segment = segments[index];
|
|
287
|
-
if (!isRecord(segment)) {
|
|
288
|
-
errors.push(`segment[${index}] must be an object`);
|
|
289
|
-
continue;
|
|
290
|
-
}
|
|
291
|
-
if (!isInteger(segment.start) || !isInteger(segment.end)) {
|
|
292
|
-
errors.push(`segment[${index}]: start and end must be integers`);
|
|
293
|
-
continue;
|
|
294
|
-
}
|
|
295
|
-
if (segment.start < 0 || segment.start >= vertexCount) errors.push(`segment[${index}]: start index ${segment.start} out of range`);
|
|
296
|
-
if (segment.end < 0 || segment.end >= vertexCount) errors.push(`segment[${index}]: end index ${segment.end} out of range`);
|
|
297
|
-
validateSegmentTangents(segment, index, errors);
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
function validateSegmentTangents(segment, index, errors) {
|
|
301
|
-
for (const tangentKey of ["tangentStart", "tangentEnd"]) {
|
|
302
|
-
const tangent = segment[tangentKey];
|
|
303
|
-
if (tangent !== void 0 && !isFiniteVector(tangent)) errors.push(`segment[${index}]: ${tangentKey} must contain finite x and y numbers`);
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
function validateRegions(regions, segmentCount, segments, errors) {
|
|
307
|
-
for (let regionIndex = 0; regionIndex < regions.length; regionIndex++) {
|
|
308
|
-
const region = regions[regionIndex];
|
|
309
|
-
if (!isRecord(region) || !Array.isArray(region.loops)) {
|
|
310
|
-
errors.push(`region[${regionIndex}]: loops must be an array`);
|
|
311
|
-
continue;
|
|
312
|
-
}
|
|
313
|
-
if (region.windingRule !== "NONZERO" && region.windingRule !== "EVENODD") errors.push(`region[${regionIndex}]: windingRule must be NONZERO or EVENODD`);
|
|
314
|
-
if (region.loops.length === 0) errors.push(`region[${regionIndex}]: loops must contain at least one loop`);
|
|
315
|
-
validateRegionLoops(region.loops, regionIndex, segmentCount, segments, errors);
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
function validateRegionLoops(loops, regionIndex, segmentCount, segments, errors) {
|
|
319
|
-
for (let loopIndex = 0; loopIndex < loops.length; loopIndex++) {
|
|
320
|
-
const loop = loops[loopIndex];
|
|
321
|
-
if (!Array.isArray(loop)) {
|
|
322
|
-
errors.push(`region[${regionIndex}].loop[${loopIndex}] must be an array`);
|
|
323
|
-
continue;
|
|
324
|
-
}
|
|
325
|
-
if (loop.length === 0) {
|
|
326
|
-
errors.push(`region[${regionIndex}].loop[${loopIndex}] must contain at least one segment`);
|
|
327
|
-
continue;
|
|
328
|
-
}
|
|
329
|
-
const segmentIndices = [];
|
|
330
|
-
for (const segmentIndex of loop) if (!isInteger(segmentIndex) || segmentIndex < 0 || segmentIndex >= segmentCount) errors.push(`region[${regionIndex}].loop[${loopIndex}]: segment index ${String(segmentIndex)} out of range`);
|
|
331
|
-
else segmentIndices.push(segmentIndex);
|
|
332
|
-
if (segmentIndices.length !== loop.length) continue;
|
|
333
|
-
if (new Set(segmentIndices).size !== segmentIndices.length) {
|
|
334
|
-
errors.push(`region[${regionIndex}].loop[${loopIndex}] must not repeat segments`);
|
|
335
|
-
continue;
|
|
336
|
-
}
|
|
337
|
-
if (segments && !formsContinuousChain(segmentIndices, segments)) errors.push(`region[${regionIndex}].loop[${loopIndex}] segments must form a continuous chain`);
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
function formsContinuousChain(indices, segments) {
|
|
341
|
-
if (indices.length <= 1) return true;
|
|
342
|
-
const first = segments[indices[0]];
|
|
343
|
-
return followsChain(indices, segments, first.end) || followsChain(indices, segments, first.start);
|
|
344
|
-
}
|
|
345
|
-
function followsChain(indices, segments, initialEnd) {
|
|
346
|
-
let current = initialEnd;
|
|
347
|
-
for (let index = 1; index < indices.length; index++) {
|
|
348
|
-
const segment = segments[indices[index]];
|
|
349
|
-
if (segment.start === current) current = segment.end;
|
|
350
|
-
else if (segment.end === current) current = segment.start;
|
|
351
|
-
else return false;
|
|
352
|
-
}
|
|
353
|
-
return true;
|
|
354
|
-
}
|
|
355
|
-
function isSegmentRecord(value) {
|
|
356
|
-
return isRecord(value) && isInteger(value.start) && isInteger(value.end);
|
|
357
|
-
}
|
|
358
|
-
function isFiniteVector(value) {
|
|
359
|
-
return isRecord(value) && typeof value.x === "number" && Number.isFinite(value.x) && typeof value.y === "number" && Number.isFinite(value.y);
|
|
360
|
-
}
|
|
361
|
-
function isInteger(value) {
|
|
362
|
-
return typeof value === "number" && Number.isInteger(value);
|
|
363
|
-
}
|
|
364
|
-
function isRecord(value) {
|
|
365
|
-
return typeof value === "object" && value !== null;
|
|
366
|
-
}
|
|
367
|
-
/**
|
|
368
|
-
* Ensure every segment has tangentStart/tangentEnd and a regions array.
|
|
369
|
-
* Missing tangents default to {x:0, y:0} (straight line segments).
|
|
370
|
-
* Use at system boundaries where input may come from JSON/MCP.
|
|
371
|
-
*/
|
|
372
|
-
function normalizeVectorNetwork(vn) {
|
|
373
|
-
const ZERO = {
|
|
374
|
-
x: 0,
|
|
375
|
-
y: 0
|
|
376
|
-
};
|
|
377
|
-
return {
|
|
378
|
-
vertices: vn.vertices,
|
|
379
|
-
segments: vn.segments.map((s) => ({
|
|
380
|
-
start: s.start,
|
|
381
|
-
end: s.end,
|
|
382
|
-
tangentStart: s.tangentStart ?? { ...ZERO },
|
|
383
|
-
tangentEnd: s.tangentEnd ?? { ...ZERO }
|
|
384
|
-
})),
|
|
385
|
-
regions: vn.regions ?? []
|
|
386
|
-
};
|
|
387
|
-
}
|
|
388
|
-
//#endregion
|
|
389
|
-
//#region src/copy.ts
|
|
390
|
-
function copyFill(f) {
|
|
391
|
-
const copy = {
|
|
392
|
-
...f,
|
|
393
|
-
color: { ...f.color }
|
|
394
|
-
};
|
|
395
|
-
if (f.gradientStops) copy.gradientStops = f.gradientStops.map(copyGradientStop);
|
|
396
|
-
if (f.gradientTransform) copy.gradientTransform = { ...f.gradientTransform };
|
|
397
|
-
if (f.imageTransform) copy.imageTransform = { ...f.imageTransform };
|
|
398
|
-
if (f.patternSpacing) copy.patternSpacing = { ...f.patternSpacing };
|
|
399
|
-
if (f.noiseSize) copy.noiseSize = { ...f.noiseSize };
|
|
400
|
-
return copy;
|
|
401
|
-
}
|
|
402
|
-
function copyStroke(s) {
|
|
403
|
-
const copy = {
|
|
404
|
-
...s,
|
|
405
|
-
color: { ...s.color }
|
|
406
|
-
};
|
|
407
|
-
if (s.dashPattern) copy.dashPattern = [...s.dashPattern];
|
|
408
|
-
return copy;
|
|
409
|
-
}
|
|
410
|
-
function copyEffect(e) {
|
|
411
|
-
return {
|
|
412
|
-
...e,
|
|
413
|
-
color: { ...e.color },
|
|
414
|
-
offset: { ...e.offset }
|
|
415
|
-
};
|
|
416
|
-
}
|
|
417
|
-
function copyStyleRun(r) {
|
|
418
|
-
return {
|
|
419
|
-
...r,
|
|
420
|
-
style: {
|
|
421
|
-
...r.style,
|
|
422
|
-
fills: r.style.fills ? r.style.fills.map(copyFill) : void 0,
|
|
423
|
-
textDecorationFills: r.style.textDecorationFills ? r.style.textDecorationFills.map(copyFill) : void 0,
|
|
424
|
-
fontVariations: r.style.fontVariations ? r.style.fontVariations.map((v) => ({ ...v })) : void 0,
|
|
425
|
-
fontFeatures: r.style.fontFeatures ? r.style.fontFeatures.map((v) => ({ ...v })) : void 0
|
|
426
|
-
}
|
|
427
|
-
};
|
|
428
|
-
}
|
|
429
|
-
const internalCopySources = /* @__PURE__ */ new WeakMap();
|
|
430
|
-
/** Record immutable lineage for an internal deep copy without sharing mutable values. */
|
|
431
|
-
function markCopySource(source, copy) {
|
|
432
|
-
internalCopySources.set(copy, internalCopySources.get(source) ?? source);
|
|
433
|
-
return copy;
|
|
434
|
-
}
|
|
435
|
-
/** Compare internal deep copies in O(1) without traversing large paint or text payloads. */
|
|
436
|
-
function hasSameCopySource(left, right) {
|
|
437
|
-
if (left === right) return true;
|
|
438
|
-
return (internalCopySources.get(left) ?? left) === (internalCopySources.get(right) ?? right);
|
|
439
|
-
}
|
|
440
|
-
function copyFills(fills) {
|
|
441
|
-
return fills.map(copyFill);
|
|
442
|
-
}
|
|
443
|
-
function copyStrokes(strokes) {
|
|
444
|
-
return strokes.map(copyStroke);
|
|
445
|
-
}
|
|
446
|
-
function copyEffects(effects) {
|
|
447
|
-
return effects.map(copyEffect);
|
|
448
|
-
}
|
|
449
|
-
function copyLayoutGrids(grids) {
|
|
450
|
-
return grids.map((grid) => ({
|
|
451
|
-
...grid,
|
|
452
|
-
color: grid.color ? { ...grid.color } : void 0
|
|
453
|
-
}));
|
|
454
|
-
}
|
|
455
|
-
function copyStyleRuns(runs) {
|
|
456
|
-
return runs.map(copyStyleRun);
|
|
457
|
-
}
|
|
458
|
-
function copyGeometryPaths(paths) {
|
|
459
|
-
return paths.map((p) => ({
|
|
460
|
-
windingRule: p.windingRule,
|
|
461
|
-
commandsBlob: p.commandsBlob.slice(),
|
|
462
|
-
fills: p.fills ? copyFills(p.fills) : void 0
|
|
463
|
-
}));
|
|
464
|
-
}
|
|
465
|
-
/** Scale geometry path coordinates while preserving independent path fills. */
|
|
466
|
-
function scaleGeometryPaths(paths, scaleX, scaleY) {
|
|
467
|
-
const copies = copyGeometryPaths(paths);
|
|
468
|
-
if (scaleX === 1 && scaleY === 1) return copies;
|
|
469
|
-
for (const path of copies) {
|
|
470
|
-
const view = new DataView(path.commandsBlob.buffer, path.commandsBlob.byteOffset, path.commandsBlob.byteLength);
|
|
471
|
-
let offset = 0;
|
|
472
|
-
while (offset < path.commandsBlob.length) {
|
|
473
|
-
const command = path.commandsBlob[offset];
|
|
474
|
-
offset += 1;
|
|
475
|
-
if (command === 0) continue;
|
|
476
|
-
let coordinateCount = 0;
|
|
477
|
-
if (command === 1 || command === 2) coordinateCount = 1;
|
|
478
|
-
else if (command === 3) coordinateCount = 2;
|
|
479
|
-
else if (command === 4) coordinateCount = 3;
|
|
480
|
-
if (coordinateCount === 0 || offset + coordinateCount * 8 > path.commandsBlob.length) break;
|
|
481
|
-
for (let index = 0; index < coordinateCount; index++) {
|
|
482
|
-
view.setFloat32(offset, view.getFloat32(offset, true) * scaleX, true);
|
|
483
|
-
view.setFloat32(offset + 4, view.getFloat32(offset + 4, true) * scaleY, true);
|
|
484
|
-
offset += 8;
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
|
-
return copies;
|
|
489
|
-
}
|
|
490
|
-
/** Copy an optional array: non-empty → mapped, empty → [], undefined → undefined. */
|
|
491
|
-
function copyOpt(arr, fn) {
|
|
492
|
-
if (arr === void 0) return void 0;
|
|
493
|
-
return arr.length > 0 ? fn(arr) : [];
|
|
494
|
-
}
|
|
495
|
-
function copyGradientStop(gs) {
|
|
496
|
-
return {
|
|
497
|
-
color: { ...gs.color },
|
|
498
|
-
position: gs.position
|
|
499
|
-
};
|
|
500
|
-
}
|
|
501
|
-
function copySpread(arr) {
|
|
502
|
-
return arr?.map((item) => ({ ...item })) ?? [];
|
|
503
|
-
}
|
|
504
|
-
function copyPropertyDefs(defs) {
|
|
505
|
-
return defs?.map((d) => ({
|
|
506
|
-
...d,
|
|
507
|
-
variantOptions: d.variantOptions ? [...d.variantOptions] : void 0,
|
|
508
|
-
preferredValues: d.preferredValues ? [...d.preferredValues] : void 0
|
|
509
|
-
})) ?? [];
|
|
510
|
-
}
|
|
511
|
-
function copyGlyphs(glyphs) {
|
|
512
|
-
return glyphs ? glyphs.map((g) => ({
|
|
513
|
-
...g,
|
|
514
|
-
commandsBlob: new Uint8Array(g.commandsBlob)
|
|
515
|
-
})) : null;
|
|
516
|
-
}
|
|
517
|
-
function copyArcData(a) {
|
|
518
|
-
return {
|
|
519
|
-
startingAngle: a.startingAngle,
|
|
520
|
-
endingAngle: a.endingAngle,
|
|
521
|
-
innerRadius: a.innerRadius
|
|
522
|
-
};
|
|
523
|
-
}
|
|
524
|
-
function cloneNodeProps(src, componentId, mode = "deep") {
|
|
525
|
-
const { id: _, parentId: _p, childIds: _c, ...rest } = src;
|
|
526
|
-
if (mode === "fig-import") return {
|
|
527
|
-
...rest,
|
|
528
|
-
...componentId !== null ? { componentId } : {},
|
|
529
|
-
source: createDefaultSourceMetadata(),
|
|
530
|
-
boundVariables: { ...src.boundVariables },
|
|
531
|
-
variableModes: { ...src.variableModes },
|
|
532
|
-
overrides: Object.keys(src.overrides).length > 0 ? structuredClone(src.overrides) : {},
|
|
533
|
-
componentPropertyAssignments: { ...src.componentPropertyAssignments },
|
|
534
|
-
componentPropertyValues: { ...src.componentPropertyValues }
|
|
535
|
-
};
|
|
536
|
-
return {
|
|
537
|
-
...rest,
|
|
538
|
-
...componentId !== null ? { componentId } : {},
|
|
539
|
-
boundVariables: { ...src.boundVariables },
|
|
540
|
-
variableModes: { ...src.variableModes },
|
|
541
|
-
overrides: Object.keys(src.overrides).length > 0 ? structuredClone(src.overrides) : {},
|
|
542
|
-
fills: copyOpt(src.fills, (value) => markCopySource(value, copyFills(value))),
|
|
543
|
-
strokes: copyOpt(src.strokes, (value) => markCopySource(value, copyStrokes(value))),
|
|
544
|
-
effects: copyOpt(src.effects, (value) => markCopySource(value, copyEffects(value))),
|
|
545
|
-
layoutGrids: copyOpt(src.layoutGrids, copyLayoutGrids),
|
|
546
|
-
styleRuns: copyOpt(src.styleRuns, (value) => markCopySource(value, copyStyleRuns(value))),
|
|
547
|
-
source: componentId === null ? structuredClone(src.source) : createDefaultSourceMetadata(),
|
|
548
|
-
dashPattern: copyOpt(src.dashPattern, (a) => [...a]),
|
|
549
|
-
fontVariations: copyOpt(src.fontVariations, (a) => a.map((v) => ({ ...v }))),
|
|
550
|
-
fontFeatures: copyOpt(src.fontFeatures, (a) => a.map((v) => ({ ...v }))),
|
|
551
|
-
textDecorationFills: copyOpt(src.textDecorationFills, copyFills),
|
|
552
|
-
fillGeometry: copyOpt(src.fillGeometry, copyGeometryPaths),
|
|
553
|
-
strokeGeometry: copyOpt(src.strokeGeometry, copyGeometryPaths),
|
|
554
|
-
gridTemplateColumns: copySpread(src.gridTemplateColumns),
|
|
555
|
-
gridTemplateRows: copySpread(src.gridTemplateRows),
|
|
556
|
-
componentPropertyDefinitions: copyPropertyDefs(src.componentPropertyDefinitions),
|
|
557
|
-
componentPropertyReferences: copySpread(src.componentPropertyReferences),
|
|
558
|
-
componentPropertyAssignments: { ...src.componentPropertyAssignments },
|
|
559
|
-
symbolLinks: copySpread(src.symbolLinks),
|
|
560
|
-
variantPropSpecs: copySpread(src.variantPropSpecs),
|
|
561
|
-
pluginData: copySpread(src.pluginData),
|
|
562
|
-
pluginRelaunchData: copySpread(src.pluginRelaunchData),
|
|
563
|
-
exportSettings: copySpread(src.exportSettings),
|
|
564
|
-
componentPropertyValues: { ...src.componentPropertyValues },
|
|
565
|
-
figmaDerivedLayout: src.figmaDerivedLayout ? { ...src.figmaDerivedLayout } : null,
|
|
566
|
-
arcData: src.arcData ? copyArcData(src.arcData) : null,
|
|
567
|
-
vectorNetwork: src.vectorNetwork ? cloneVectorNetwork(src.vectorNetwork) : null,
|
|
568
|
-
textPicture: src.textPicture ? new Uint8Array(src.textPicture) : null,
|
|
569
|
-
figmaDerivedTextGlyphs: src.figmaDerivedTextGlyphs ? markCopySource(src.figmaDerivedTextGlyphs, copyGlyphs(src.figmaDerivedTextGlyphs) ?? []) : null,
|
|
570
|
-
gridPosition: src.gridPosition ? { ...src.gridPosition } : null
|
|
571
|
-
};
|
|
572
|
-
}
|
|
573
|
-
//#endregion
|
|
574
|
-
export { CONTAINER_TYPES, cloneNodeProps, cloneVectorNetwork, copyEffect, copyEffects, copyFill, copyFills, copyGeometryPaths, copyLayoutGrids, copyStroke, copyStrokes, copyStyleRun, copyStyleRuns, createDefaultNode, createDefaultSourceMetadata, hasSameCopySource, markCopySource, mergeVectorNetworks, normalizeVectorNetwork, scaleGeometryPaths, transformVectorNetwork, validateVectorNetwork, vectorNetworksEqual };
|
|
575
|
-
|
|
576
|
-
//# sourceMappingURL=copy.js.map
|
package/dist/chunks/copy.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"copy.js","names":[],"sources":["../../src/node-defaults.ts","../../src/vector-network.ts","../../src/copy.ts"],"sourcesContent":["import { BLACK, DEFAULT_FONT_FAMILY, DEFAULT_STROKE_MITER_LIMIT } from './constants'\nimport type { NodeType, SceneNode, SourceMetadata } from './types'\n\nexport function createDefaultSourceMetadata(): SourceMetadata {\n return {\n format: null,\n id: null,\n orderKey: null,\n editedFields: [],\n fig: {\n rawSize: null,\n rawTransform: null,\n rawNodeFields: {},\n layout: null,\n symbolOverrides: [],\n componentPropAssignments: [],\n derivedSymbolData: [],\n derivedSymbolDataLayoutVersion: null,\n uniformScaleFactor: null\n }\n }\n}\n\nexport function createDefaultNode(\n generateId: () => string,\n type: NodeType,\n overrides: Partial<SceneNode> = {}\n): SceneNode {\n return {\n id: generateId(),\n type,\n name: type.charAt(0) + type.slice(1).toLowerCase(),\n parentId: null,\n childIds: [],\n x: 0,\n y: 0,\n width: 100,\n height: 100,\n rotation: 0,\n source: createDefaultSourceMetadata(),\n figmaDerivedLayout: null,\n fills:\n type === 'TEXT' ? [{ type: 'SOLID' as const, color: BLACK, opacity: 1, visible: true }] : [],\n strokes: [],\n effects: [],\n layoutGrids: [],\n fillStyleId: null,\n strokeStyleId: null,\n textStyleId: null,\n effectStyleId: null,\n gridStyleId: null,\n sharedStyleType: null,\n opacity: 1,\n cornerRadius: 0,\n topLeftRadius: 0,\n topRightRadius: 0,\n bottomRightRadius: 0,\n bottomLeftRadius: 0,\n independentCorners: false,\n cornerSmoothing: 0,\n visible: true,\n locked: false,\n clipsContent: false,\n text: '',\n fontSize: 14,\n fontFamily: DEFAULT_FONT_FAMILY,\n fontWeight: 400,\n italic: false,\n textAlignHorizontal: 'LEFT',\n textDirection: 'AUTO',\n textLanguage: null,\n leadingTrim: 'NONE',\n lineHeight: null,\n letterSpacing: 0,\n layoutMode: 'NONE',\n layoutDirection: 'AUTO',\n layoutWrap: 'NO_WRAP',\n primaryAxisAlign: 'MIN',\n counterAxisAlign: 'MIN',\n primaryAxisSizing: 'FIXED',\n counterAxisSizing: 'FIXED',\n itemSpacing: 0,\n counterAxisSpacing: 0,\n paddingTop: 0,\n paddingRight: 0,\n paddingBottom: 0,\n paddingLeft: 0,\n blendMode: 'PASS_THROUGH',\n layoutPositioning: 'AUTO',\n layoutGrow: 0,\n layoutAlignSelf: 'AUTO',\n vectorNetwork: null,\n handleMirroring: 'NONE',\n fillGeometry: [],\n strokeGeometry: [],\n arcData: null,\n textAlignVertical: 'TOP',\n textAutoResize: 'NONE',\n textCase: 'ORIGINAL',\n textDecoration: 'NONE',\n textDecorationStyle: 'SOLID',\n textDecorationThickness: null,\n textDecorationFills: [],\n textDecorationSkipInk: true,\n textUnderlineOffset: null,\n maxLines: null,\n styleRuns: [],\n fontVariations: [],\n fontFeatures: [],\n horizontalConstraint: 'MIN',\n verticalConstraint: 'MIN',\n strokeCap: 'NONE',\n strokeJoin: 'MITER',\n dashPattern: [],\n borderTopWeight: 0,\n borderRightWeight: 0,\n borderBottomWeight: 0,\n borderLeftWeight: 0,\n independentStrokeWeights: false,\n strokeMiterLimit: DEFAULT_STROKE_MITER_LIMIT,\n minWidth: null,\n maxWidth: null,\n minHeight: null,\n maxHeight: null,\n isMask: false,\n maskType: 'ALPHA',\n maskIsOutline: false,\n gridTemplateColumns: [],\n gridTemplateRows: [],\n gridColumnGap: 0,\n gridRowGap: 0,\n gridPosition: null,\n counterAxisAlignContent: 'AUTO',\n itemReverseZIndex: false,\n strokesIncludedInLayout: false,\n expanded: true,\n textTruncation: 'DISABLED',\n autoRename: true,\n pointCount: 5,\n starInnerRadius: 0.38,\n componentId: null,\n overrides: {},\n componentPropertyDefinitions: [],\n componentPropertyReferences: [],\n componentPropertyAssignments: {},\n componentPropertyValues: {},\n componentKey: null,\n sourceLibraryKey: null,\n publishId: null,\n overrideKey: null,\n sharedSymbolVersion: null,\n publishedVersion: null,\n isPublishable: false,\n isSymbolPublishable: false,\n symbolDescription: '',\n symbolLinks: [],\n variantPropSpecs: [],\n boundVariables: {},\n variableModes: {},\n exportSettings: [],\n pluginData: [],\n pluginRelaunchData: [],\n internalOnly: false,\n flipX: false,\n flipY: false,\n textPicture: null,\n figmaDerivedTextGlyphs: null,\n ...overrides\n }\n}\n\nexport const CONTAINER_TYPES = new Set<NodeType>([\n 'CANVAS',\n 'FRAME',\n 'GROUP',\n 'BOOLEAN_OPERATION',\n 'SECTION',\n 'COMPONENT',\n 'COMPONENT_SET',\n 'INSTANCE'\n])\n","import { isEqual } from 'es-toolkit/predicate'\n\nimport type { Mat3 } from './matrix'\nimport type { Vector } from './primitives'\nimport type { VectorNetwork, VectorSegment } from './types'\n\n/** Concatenate vector networks while preserving independent geometry. */\nexport function mergeVectorNetworks(networks: readonly VectorNetwork[]): VectorNetwork {\n const vertices: VectorNetwork['vertices'] = []\n const segments: VectorNetwork['segments'] = []\n const regions: VectorNetwork['regions'] = []\n let vertexOffset = 0\n let segmentOffset = 0\n\n for (const network of networks) {\n for (const vertex of network.vertices) vertices.push({ ...vertex })\n for (const segment of network.segments) {\n segments.push({\n ...segment,\n start: segment.start + vertexOffset,\n end: segment.end + vertexOffset,\n tangentStart: { ...segment.tangentStart },\n tangentEnd: { ...segment.tangentEnd }\n })\n }\n for (const region of network.regions) {\n const loops: number[][] = []\n for (const loop of region.loops) {\n const shifted: number[] = []\n for (const segmentIndex of loop) shifted.push(segmentIndex + segmentOffset)\n loops.push(shifted)\n }\n regions.push({ windingRule: region.windingRule, loops })\n }\n vertexOffset += network.vertices.length\n segmentOffset += network.segments.length\n }\n\n return { vertices, segments, regions }\n}\n\n/**\n * Map a VectorNetwork through an affine matrix: vertices as points,\n * tangents as direction vectors (linear part only, no translation).\n * Returns a deep copy; the input is not mutated.\n */\nexport function transformVectorNetwork(m: Mat3, vn: VectorNetwork): VectorNetwork {\n const mapVector = (v: Vector): Vector => ({\n x: m[0] * v.x + m[1] * v.y,\n y: m[3] * v.x + m[4] * v.y\n })\n return {\n vertices: vn.vertices.map((v) => ({\n ...v,\n x: m[0] * v.x + m[1] * v.y + m[2],\n y: m[3] * v.x + m[4] * v.y + m[5]\n })),\n segments: vn.segments.map((s) => ({\n ...s,\n tangentStart: mapVector(s.tangentStart),\n tangentEnd: mapVector(s.tangentEnd)\n })),\n regions: vn.regions.map((r) => ({\n windingRule: r.windingRule,\n loops: r.loops.map((l) => [...l])\n }))\n }\n}\n\n/** Structural equality of two VectorNetworks (order-sensitive, exact values). */\nexport function vectorNetworksEqual(a: VectorNetwork, b: VectorNetwork): boolean {\n return (\n isEqual(a.vertices, b.vertices) &&\n isEqual(a.segments, b.segments) &&\n isEqual(a.regions, b.regions)\n )\n}\n\n/** Deep-copy a VectorNetwork, stripping any Vue Proxy wrappers. */\nexport function cloneVectorNetwork(vn: VectorNetwork): VectorNetwork {\n return {\n vertices: vn.vertices.map((v) => ({ ...v })),\n segments: vn.segments.map((s) => ({\n ...s,\n tangentStart: { ...s.tangentStart },\n tangentEnd: { ...s.tangentEnd }\n })),\n regions: vn.regions.map((r) => ({\n windingRule: r.windingRule,\n loops: r.loops.map((l) => [...l])\n }))\n }\n}\n\n/**\n * Validate a VectorNetwork structure, returning an array of error messages.\n * Empty array means the network is valid.\n */\nexport function validateVectorNetwork(value: unknown): string[] {\n if (!isRecord(value)) return ['network must be an object']\n if (!Array.isArray(value.vertices)) return ['vertices must be an array']\n if (!Array.isArray(value.segments)) return ['segments must be an array']\n\n const errors: string[] = []\n validateVertices(value.vertices, errors)\n validateSegments(value.segments, value.vertices.length, errors)\n const typedSegments = value.segments.filter(isSegmentRecord)\n if (value.regions !== undefined) {\n if (Array.isArray(value.regions)) {\n validateRegions(\n value.regions,\n value.segments.length,\n typedSegments.length === value.segments.length ? typedSegments : null,\n errors\n )\n } else {\n errors.push('regions must be an array when provided')\n }\n }\n return errors\n}\n\nfunction validateVertices(vertices: unknown[], errors: string[]): void {\n for (let index = 0; index < vertices.length; index++) {\n if (!isFiniteVector(vertices[index])) {\n errors.push(`vertex[${index}]: x and y must be finite numbers`)\n }\n }\n}\n\nfunction validateSegments(segments: unknown[], vertexCount: number, errors: string[]): void {\n for (let index = 0; index < segments.length; index++) {\n const segment = segments[index]\n if (!isRecord(segment)) {\n errors.push(`segment[${index}] must be an object`)\n continue\n }\n if (!isInteger(segment.start) || !isInteger(segment.end)) {\n errors.push(`segment[${index}]: start and end must be integers`)\n continue\n }\n if (segment.start < 0 || segment.start >= vertexCount) {\n errors.push(`segment[${index}]: start index ${segment.start} out of range`)\n }\n if (segment.end < 0 || segment.end >= vertexCount) {\n errors.push(`segment[${index}]: end index ${segment.end} out of range`)\n }\n validateSegmentTangents(segment, index, errors)\n }\n}\n\nfunction validateSegmentTangents(\n segment: Record<string, unknown>,\n index: number,\n errors: string[]\n): void {\n for (const tangentKey of ['tangentStart', 'tangentEnd'] as const) {\n const tangent = segment[tangentKey]\n if (tangent !== undefined && !isFiniteVector(tangent)) {\n errors.push(`segment[${index}]: ${tangentKey} must contain finite x and y numbers`)\n }\n }\n}\n\nfunction validateRegions(\n regions: unknown[],\n segmentCount: number,\n segments: Array<Record<'start' | 'end', number>> | null,\n errors: string[]\n): void {\n for (let regionIndex = 0; regionIndex < regions.length; regionIndex++) {\n const region = regions[regionIndex]\n if (!isRecord(region) || !Array.isArray(region.loops)) {\n errors.push(`region[${regionIndex}]: loops must be an array`)\n continue\n }\n if (region.windingRule !== 'NONZERO' && region.windingRule !== 'EVENODD') {\n errors.push(`region[${regionIndex}]: windingRule must be NONZERO or EVENODD`)\n }\n if (region.loops.length === 0) {\n errors.push(`region[${regionIndex}]: loops must contain at least one loop`)\n }\n validateRegionLoops(region.loops, regionIndex, segmentCount, segments, errors)\n }\n}\n\nfunction validateRegionLoops(\n loops: unknown[],\n regionIndex: number,\n segmentCount: number,\n segments: Array<Record<'start' | 'end', number>> | null,\n errors: string[]\n): void {\n for (let loopIndex = 0; loopIndex < loops.length; loopIndex++) {\n const loop = loops[loopIndex]\n if (!Array.isArray(loop)) {\n errors.push(`region[${regionIndex}].loop[${loopIndex}] must be an array`)\n continue\n }\n if (loop.length === 0) {\n errors.push(`region[${regionIndex}].loop[${loopIndex}] must contain at least one segment`)\n continue\n }\n\n const segmentIndices: number[] = []\n for (const segmentIndex of loop) {\n if (!isInteger(segmentIndex) || segmentIndex < 0 || segmentIndex >= segmentCount) {\n errors.push(\n `region[${regionIndex}].loop[${loopIndex}]: segment index ${String(segmentIndex)} out of range`\n )\n } else {\n segmentIndices.push(segmentIndex)\n }\n }\n if (segmentIndices.length !== loop.length) continue\n if (new Set(segmentIndices).size !== segmentIndices.length) {\n errors.push(`region[${regionIndex}].loop[${loopIndex}] must not repeat segments`)\n continue\n }\n if (segments && !formsContinuousChain(segmentIndices, segments)) {\n errors.push(`region[${regionIndex}].loop[${loopIndex}] segments must form a continuous chain`)\n }\n }\n}\n\nfunction formsContinuousChain(\n indices: number[],\n segments: Array<Record<'start' | 'end', number>>\n): boolean {\n if (indices.length <= 1) return true\n const first = segments[indices[0]]\n return followsChain(indices, segments, first.end) || followsChain(indices, segments, first.start)\n}\n\nfunction followsChain(\n indices: number[],\n segments: Array<Record<'start' | 'end', number>>,\n initialEnd: number\n): boolean {\n let current = initialEnd\n for (let index = 1; index < indices.length; index++) {\n const segment = segments[indices[index]]\n if (segment.start === current) current = segment.end\n else if (segment.end === current) current = segment.start\n else return false\n }\n return true\n}\n\nfunction isSegmentRecord(value: unknown): value is Record<'start' | 'end', number> {\n return isRecord(value) && isInteger(value.start) && isInteger(value.end)\n}\n\nfunction isFiniteVector(value: unknown): value is Vector {\n return (\n isRecord(value) &&\n typeof value.x === 'number' &&\n Number.isFinite(value.x) &&\n typeof value.y === 'number' &&\n Number.isFinite(value.y)\n )\n}\n\nfunction isInteger(value: unknown): value is number {\n return typeof value === 'number' && Number.isInteger(value)\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null\n}\n\nexport type NormalizableVectorNetwork = Omit<VectorNetwork, 'regions'> & {\n regions?: VectorNetwork['regions']\n}\n\n/**\n * Ensure every segment has tangentStart/tangentEnd and a regions array.\n * Missing tangents default to {x:0, y:0} (straight line segments).\n * Use at system boundaries where input may come from JSON/MCP.\n */\nexport function normalizeVectorNetwork(vn: NormalizableVectorNetwork): VectorNetwork {\n const ZERO: Vector = { x: 0, y: 0 }\n return {\n vertices: vn.vertices,\n segments: vn.segments.map((s) => ({\n start: s.start,\n end: s.end,\n tangentStart: (s as Partial<VectorSegment>).tangentStart ?? { ...ZERO },\n tangentEnd: (s as Partial<VectorSegment>).tangentEnd ?? { ...ZERO }\n })),\n regions: vn.regions ?? []\n }\n}\n","/**\n * Typed shallow-copy helpers for Fill, Stroke, Effect, and StyleRun.\n *\n * These replace `structuredClone` for known scene-graph array types,\n * avoiding the ~24× overhead of the generic deep-clone algorithm.\n * Each helper spreads the top-level object and any nested objects\n * (color, offset, gradientStops, dashPattern, style) to ensure\n * no shared references between source and copy.\n */\n\nimport type {\n ArcData,\n ComponentPropertyDefinition,\n Effect,\n FigmaDerivedTextGlyph,\n Fill,\n GeometryPath,\n GradientStop,\n LayoutGrid,\n SceneNode,\n Stroke,\n StyleRun\n} from './'\nimport { createDefaultSourceMetadata } from './node-defaults'\nimport { cloneVectorNetwork } from './vector-network'\n\n// --- Individual copy functions ---\n\nexport function copyFill(f: Fill): Fill {\n const copy: Fill = { ...f, color: { ...f.color } }\n if (f.gradientStops) copy.gradientStops = f.gradientStops.map(copyGradientStop)\n if (f.gradientTransform) copy.gradientTransform = { ...f.gradientTransform }\n if (f.imageTransform) copy.imageTransform = { ...f.imageTransform }\n if (f.patternSpacing) copy.patternSpacing = { ...f.patternSpacing }\n if (f.noiseSize) copy.noiseSize = { ...f.noiseSize }\n return copy\n}\n\nexport function copyStroke(s: Stroke): Stroke {\n const copy: Stroke = { ...s, color: { ...s.color } }\n if (s.dashPattern) {\n copy.dashPattern = [...s.dashPattern]\n }\n return copy\n}\n\nexport function copyEffect(e: Effect): Effect {\n return {\n ...e,\n color: { ...e.color },\n offset: { ...e.offset }\n }\n}\n\nexport function copyStyleRun(r: StyleRun): StyleRun {\n return {\n ...r,\n style: {\n ...r.style,\n fills: r.style.fills ? r.style.fills.map(copyFill) : undefined,\n textDecorationFills: r.style.textDecorationFills\n ? r.style.textDecorationFills.map(copyFill)\n : undefined,\n fontVariations: r.style.fontVariations\n ? r.style.fontVariations.map((v) => ({ ...v }))\n : undefined,\n fontFeatures: r.style.fontFeatures ? r.style.fontFeatures.map((v) => ({ ...v })) : undefined\n }\n }\n}\n\n// --- Array copy functions ---\n\nconst internalCopySources = new WeakMap<object, object>()\n\n/** Record immutable lineage for an internal deep copy without sharing mutable values. */\nexport function markCopySource<T extends object>(source: T, copy: T): T {\n internalCopySources.set(copy, internalCopySources.get(source) ?? source)\n return copy\n}\n\n/** Compare internal deep copies in O(1) without traversing large paint or text payloads. */\nexport function hasSameCopySource(left: object, right: object): boolean {\n if (left === right) return true\n return (internalCopySources.get(left) ?? left) === (internalCopySources.get(right) ?? right)\n}\n\nexport function copyFills(fills: Fill[]): Fill[] {\n return fills.map(copyFill)\n}\n\nexport function copyStrokes(strokes: Stroke[]): Stroke[] {\n return strokes.map(copyStroke)\n}\n\nexport function copyEffects(effects: Effect[]): Effect[] {\n return effects.map(copyEffect)\n}\n\nexport function copyLayoutGrids(grids: LayoutGrid[]): LayoutGrid[] {\n return grids.map((grid) => ({ ...grid, color: grid.color ? { ...grid.color } : undefined }))\n}\n\nexport function copyStyleRuns(runs: StyleRun[]): StyleRun[] {\n return runs.map(copyStyleRun)\n}\n\nexport function copyGeometryPaths(paths: GeometryPath[]): GeometryPath[] {\n return paths.map((p) => ({\n windingRule: p.windingRule,\n commandsBlob: p.commandsBlob.slice(),\n fills: p.fills ? copyFills(p.fills) : undefined\n }))\n}\n\n/** Scale geometry path coordinates while preserving independent path fills. */\nexport function scaleGeometryPaths(paths: GeometryPath[], scaleX: number, scaleY: number) {\n const copies = copyGeometryPaths(paths)\n if (scaleX === 1 && scaleY === 1) return copies\n\n for (const path of copies) {\n const view = new DataView(\n path.commandsBlob.buffer,\n path.commandsBlob.byteOffset,\n path.commandsBlob.byteLength\n )\n let offset = 0\n while (offset < path.commandsBlob.length) {\n const command = path.commandsBlob[offset]\n offset += 1\n if (command === 0) continue\n\n let coordinateCount = 0\n if (command === 1 || command === 2) coordinateCount = 1\n else if (command === 3) coordinateCount = 2\n else if (command === 4) coordinateCount = 3\n if (coordinateCount === 0 || offset + coordinateCount * 8 > path.commandsBlob.length) break\n for (let index = 0; index < coordinateCount; index++) {\n view.setFloat32(offset, view.getFloat32(offset, true) * scaleX, true)\n view.setFloat32(offset + 4, view.getFloat32(offset + 4, true) * scaleY, true)\n offset += 8\n }\n }\n }\n return copies\n}\n\n// --- Internal helpers ---\n\n/** Copy an optional array: non-empty → mapped, empty → [], undefined → undefined. */\nfunction copyOpt<T, U>(arr: T[] | undefined, fn: (arr: T[]) => U[]): U[] | undefined {\n if (arr === undefined) return undefined\n return arr.length > 0 ? fn(arr) : []\n}\n\nfunction copyGradientStop(gs: GradientStop): GradientStop {\n return { color: { ...gs.color }, position: gs.position }\n}\n\nfunction copySpread<T extends object>(arr: T[] | undefined): T[] {\n return arr?.map((item) => ({ ...item })) ?? []\n}\n\nfunction copyPropertyDefs(\n defs: ComponentPropertyDefinition[] | undefined\n): ComponentPropertyDefinition[] {\n return (\n defs?.map((d) => ({\n ...d,\n variantOptions: d.variantOptions ? [...d.variantOptions] : undefined,\n preferredValues: d.preferredValues ? [...d.preferredValues] : undefined\n })) ?? []\n )\n}\n\nfunction copyGlyphs(glyphs: FigmaDerivedTextGlyph[] | null): FigmaDerivedTextGlyph[] | null {\n return glyphs ? glyphs.map((g) => ({ ...g, commandsBlob: new Uint8Array(g.commandsBlob) })) : null\n}\n\n// --- Complex structure copy functions ---\n// These replace structuredClone for known types, avoiding its ~24× overhead.\n\nfunction copyArcData(a: ArcData): ArcData {\n return { startingAngle: a.startingAngle, endingAngle: a.endingAngle, innerRadius: a.innerRadius }\n}\n\n// --- Deep-copy clone props ---\n\n/**\n * Build the init props for a deep-copy clone of `src`.\n * Shares logic between SceneGraph.cloneTree and instance child cloning.\n * Explicitly deep-copies all mutable object/array fields that `...rest`\n * would otherwise share by reference. When adding a mutable SceneNode field,\n * add its copy behavior here or document why sharing is intentional.\n */\nexport type NodeCloneMode = 'deep' | 'fig-import'\n\nexport function cloneNodeProps(\n src: SceneNode,\n componentId: string | null,\n mode: NodeCloneMode = 'deep'\n): Partial<SceneNode> {\n const { id: _, parentId: _p, childIds: _c, ...rest } = src\n if (mode === 'fig-import') {\n return {\n ...rest,\n ...(componentId !== null ? { componentId } : {}),\n source: createDefaultSourceMetadata(),\n boundVariables: { ...src.boundVariables },\n variableModes: { ...src.variableModes },\n overrides: Object.keys(src.overrides).length > 0 ? structuredClone(src.overrides) : {},\n componentPropertyAssignments: { ...src.componentPropertyAssignments },\n componentPropertyValues: { ...src.componentPropertyValues }\n }\n }\n return {\n ...rest,\n ...(componentId !== null ? { componentId } : {}),\n boundVariables: { ...src.boundVariables },\n variableModes: { ...src.variableModes },\n overrides: Object.keys(src.overrides).length > 0 ? structuredClone(src.overrides) : {},\n fills: copyOpt(src.fills, (value) => markCopySource(value, copyFills(value))),\n strokes: copyOpt(src.strokes, (value) => markCopySource(value, copyStrokes(value))),\n effects: copyOpt(src.effects, (value) => markCopySource(value, copyEffects(value))),\n layoutGrids: copyOpt(src.layoutGrids, copyLayoutGrids),\n styleRuns: copyOpt(src.styleRuns, (value) => markCopySource(value, copyStyleRuns(value))),\n // Generated instance descendants have no independent Figma provenance. Retaining the source\n // component's opaque raw payload here duplicates megabytes of metadata per instance.\n source: componentId === null ? structuredClone(src.source) : createDefaultSourceMetadata(),\n dashPattern: copyOpt(src.dashPattern, (a) => [...a]),\n fontVariations: copyOpt(src.fontVariations, (a) => a.map((v) => ({ ...v }))),\n fontFeatures: copyOpt(src.fontFeatures, (a) => a.map((v) => ({ ...v }))),\n textDecorationFills: copyOpt(src.textDecorationFills, copyFills),\n fillGeometry: copyOpt(src.fillGeometry, copyGeometryPaths),\n strokeGeometry: copyOpt(src.strokeGeometry, copyGeometryPaths),\n gridTemplateColumns: copySpread(src.gridTemplateColumns),\n gridTemplateRows: copySpread(src.gridTemplateRows),\n componentPropertyDefinitions: copyPropertyDefs(src.componentPropertyDefinitions),\n componentPropertyReferences: copySpread(src.componentPropertyReferences),\n componentPropertyAssignments: { ...src.componentPropertyAssignments },\n symbolLinks: copySpread(src.symbolLinks),\n variantPropSpecs: copySpread(src.variantPropSpecs),\n pluginData: copySpread(src.pluginData),\n pluginRelaunchData: copySpread(src.pluginRelaunchData),\n exportSettings: copySpread(src.exportSettings),\n componentPropertyValues: { ...src.componentPropertyValues },\n figmaDerivedLayout: src.figmaDerivedLayout ? { ...src.figmaDerivedLayout } : null,\n arcData: src.arcData ? copyArcData(src.arcData) : null,\n vectorNetwork: src.vectorNetwork ? cloneVectorNetwork(src.vectorNetwork) : null,\n textPicture: src.textPicture ? new Uint8Array(src.textPicture) : null,\n figmaDerivedTextGlyphs: src.figmaDerivedTextGlyphs\n ? markCopySource(src.figmaDerivedTextGlyphs, copyGlyphs(src.figmaDerivedTextGlyphs) ?? [])\n : null,\n gridPosition: src.gridPosition ? { ...src.gridPosition } : null\n }\n}\n"],"mappings":";;;AAGA,SAAgB,8BAA8C;CAC5D,OAAO;EACL,QAAQ;EACR,IAAI;EACJ,UAAU;EACV,cAAc,CAAC;EACf,KAAK;GACH,SAAS;GACT,cAAc;GACd,eAAe,CAAC;GAChB,QAAQ;GACR,iBAAiB,CAAC;GAClB,0BAA0B,CAAC;GAC3B,mBAAmB,CAAC;GACpB,gCAAgC;GAChC,oBAAoB;EACtB;CACF;AACF;AAEA,SAAgB,kBACd,YACA,MACA,YAAgC,CAAC,GACtB;CACX,OAAO;EACL,IAAI,WAAW;EACf;EACA,MAAM,KAAK,OAAO,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,YAAY;EACjD,UAAU;EACV,UAAU,CAAC;EACX,GAAG;EACH,GAAG;EACH,OAAO;EACP,QAAQ;EACR,UAAU;EACV,QAAQ,4BAA4B;EACpC,oBAAoB;EACpB,OACE,SAAS,SAAS,CAAC;GAAE,MAAM;GAAkB,OAAO;GAAO,SAAS;GAAG,SAAS;EAAK,CAAC,IAAI,CAAC;EAC7F,SAAS,CAAC;EACV,SAAS,CAAC;EACV,aAAa,CAAC;EACd,aAAa;EACb,eAAe;EACf,aAAa;EACb,eAAe;EACf,aAAa;EACb,iBAAiB;EACjB,SAAS;EACT,cAAc;EACd,eAAe;EACf,gBAAgB;EAChB,mBAAmB;EACnB,kBAAkB;EAClB,oBAAoB;EACpB,iBAAiB;EACjB,SAAS;EACT,QAAQ;EACR,cAAc;EACd,MAAM;EACN,U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
-
{"version":3,"file":"constants.js","names":[],"sources":["../src/constants.ts"],"sourcesContent":["import type { Color } from './primitives'\n\nexport const BLACK: Color = { r: 0, g: 0, b: 0, a: 1 }\nexport const TRANSPARENT: Color = { r: 0, g: 0, b: 0, a: 0 }\nexport const DEFAULT_FONT_FAMILY = 'Inter'\nexport const DEFAULT_STROKE_MITER_LIMIT = 4\n"],"mappings":";AAEA,MAAa,QAAe;CAAE,GAAG;CAAG,GAAG;CAAG,GAAG;CAAG,GAAG;AAAE;AACrD,MAAa,cAAqB;CAAE,GAAG;CAAG,GAAG;CAAG,GAAG;CAAG,GAAG;AAAE;AAC3D,MAAa,sBAAsB;AACnC,MAAa,6BAA6B"}
|