@open-pencil/scene-graph 0.15.1 → 0.16.0-beta.2

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.
Files changed (234) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1 -1
  3. package/dist/chunks/behaviours/kinds.js +273 -0
  4. package/dist/chunks/behaviours/kinds.js.map +1 -0
  5. package/dist/chunks/behaviours/layers.js +607 -0
  6. package/dist/chunks/behaviours/layers.js.map +1 -0
  7. package/dist/chunks/behaviours/spec.js +181 -0
  8. package/dist/chunks/behaviours/spec.js.map +1 -0
  9. package/dist/chunks/buffered-events.js +57 -0
  10. package/dist/chunks/buffered-events.js.map +1 -0
  11. package/dist/chunks/color/contrast.js +57 -0
  12. package/dist/chunks/color/contrast.js.map +1 -0
  13. package/dist/chunks/{components/properties.js → color/index.js} +577 -522
  14. package/dist/chunks/color/index.js.map +1 -0
  15. package/dist/chunks/comments/document.js +32 -0
  16. package/dist/chunks/comments/document.js.map +1 -0
  17. package/dist/chunks/comments/list.js +182 -0
  18. package/dist/chunks/comments/list.js.map +1 -0
  19. package/dist/chunks/comments/merge.js +58 -0
  20. package/dist/chunks/comments/merge.js.map +1 -0
  21. package/dist/chunks/components/exposure.js +2291 -0
  22. package/dist/chunks/components/exposure.js.map +1 -0
  23. package/dist/chunks/components/variants.js +32 -0
  24. package/dist/chunks/components/variants.js.map +1 -0
  25. package/dist/chunks/coordinate.js +93 -55
  26. package/dist/chunks/coordinate.js.map +1 -1
  27. package/dist/chunks/css/grid.js +94 -0
  28. package/dist/chunks/css/grid.js.map +1 -0
  29. package/dist/chunks/css/index.js +160 -0
  30. package/dist/chunks/css/index.js.map +1 -0
  31. package/dist/chunks/fields/geometry.js +14 -0
  32. package/dist/chunks/fields/geometry.js.map +1 -0
  33. package/dist/chunks/group-bounds.js +104 -0
  34. package/dist/chunks/group-bounds.js.map +1 -0
  35. package/dist/chunks/icons/glyph.js +147 -0
  36. package/dist/chunks/icons/glyph.js.map +1 -0
  37. package/dist/chunks/index.js +1724 -663
  38. package/dist/chunks/index.js.map +1 -1
  39. package/dist/color.d.ts +72 -0
  40. package/dist/color.d.ts.map +1 -0
  41. package/dist/color.js +3 -0
  42. package/dist/constants.d.ts +2 -2
  43. package/dist/constants.js +2 -2
  44. package/dist/constants2.d.ts +3 -1
  45. package/dist/constants2.d.ts.map +1 -1
  46. package/dist/coordinate.d.ts +2 -448
  47. package/dist/coordinate.js +2 -2
  48. package/dist/copy.d.ts +1 -1
  49. package/dist/copy.js +1 -1
  50. package/dist/css.d.ts +39 -0
  51. package/dist/css.d.ts.map +1 -0
  52. package/dist/css.js +3 -0
  53. package/dist/geometry.d.ts +1 -1
  54. package/dist/geometry.js +1 -1
  55. package/dist/gradient.d.ts +51 -0
  56. package/dist/gradient.d.ts.map +1 -0
  57. package/dist/gradient.js +132 -0
  58. package/dist/gradient.js.map +1 -0
  59. package/dist/guides.d.ts +2 -2
  60. package/dist/guides.js +39 -0
  61. package/dist/guides.js.map +1 -0
  62. package/dist/hit-test.d.ts +2 -9
  63. package/dist/hit-test.js +176 -34
  64. package/dist/hit-test.js.map +1 -1
  65. package/dist/index.d.ts +4 -8
  66. package/dist/index.js +19 -5
  67. package/dist/instances.d.ts +2 -2
  68. package/dist/instances.js +2 -2
  69. package/dist/layout.d.ts +2 -0
  70. package/dist/layout.js +4 -0
  71. package/dist/node-defaults.d.ts +2 -8
  72. package/dist/node-defaults.js +2 -2
  73. package/dist/order-keys.d.ts +39 -0
  74. package/dist/order-keys.d.ts.map +1 -0
  75. package/dist/order-keys.js +136 -0
  76. package/dist/order-keys.js.map +1 -0
  77. package/dist/parse-path.d.ts +7 -1
  78. package/dist/parse-path.d.ts.map +1 -1
  79. package/dist/parse-path.js +6 -2
  80. package/dist/parse-path.js.map +1 -1
  81. package/dist/polygon.d.ts +53 -0
  82. package/dist/polygon.d.ts.map +1 -0
  83. package/dist/polygon.js +205 -0
  84. package/dist/polygon.js.map +1 -0
  85. package/dist/preview.d.ts +1 -1
  86. package/dist/random.d.ts +7 -0
  87. package/dist/random.d.ts.map +1 -0
  88. package/dist/random.js +2 -0
  89. package/dist/resize.d.ts +11 -2
  90. package/dist/resize.d.ts.map +1 -1
  91. package/dist/resize.js +2 -184
  92. package/dist/snap.d.ts +1 -1
  93. package/dist/text-direction.d.ts +13 -0
  94. package/dist/text-direction.d.ts.map +1 -0
  95. package/dist/text-direction.js +31 -0
  96. package/dist/text-direction.js.map +1 -0
  97. package/dist/text-picture.d.ts +1 -1
  98. package/dist/text-picture.d.ts.map +1 -1
  99. package/dist/text.d.ts +2 -0
  100. package/dist/text.js +3 -0
  101. package/dist/types.d.ts +2121 -15
  102. package/dist/types.d.ts.map +1 -1
  103. package/dist/types.js +2 -1
  104. package/dist/types2.d.ts +2 -2
  105. package/dist/undo.d.ts +2 -2
  106. package/dist/undo.js +2 -2
  107. package/dist/undo2.d.ts +29 -1
  108. package/dist/undo2.d.ts.map +1 -1
  109. package/dist/variables.d.ts +2 -29
  110. package/dist/variables.js +2 -2
  111. package/dist/variant-properties.d.ts +9 -1
  112. package/dist/variant-properties.d.ts.map +1 -1
  113. package/dist/variant-properties.js +36 -1
  114. package/dist/variant-properties.js.map +1 -1
  115. package/dist/vector-network.d.ts +1 -1
  116. package/dist/vector-network.js +1 -1
  117. package/package.json +60 -9
  118. package/src/behaviours/kinds.ts +185 -0
  119. package/src/behaviours/layers.ts +51 -0
  120. package/src/behaviours/model.ts +192 -0
  121. package/src/behaviours/schema.ts +58 -0
  122. package/src/behaviours/spec.ts +223 -0
  123. package/src/buffered-events.ts +64 -0
  124. package/src/color/contrast.ts +31 -0
  125. package/src/color/index.ts +88 -0
  126. package/src/color/management.ts +210 -0
  127. package/src/color/normalize.ts +7 -0
  128. package/src/color/okhcl.ts +201 -0
  129. package/src/comments/document.ts +51 -0
  130. package/src/comments/list.ts +52 -0
  131. package/src/comments/merge.ts +63 -0
  132. package/src/comments/threads.ts +156 -0
  133. package/src/components/exposure.ts +61 -0
  134. package/src/components/properties.ts +18 -15
  135. package/src/components/variants.ts +53 -0
  136. package/src/constants.ts +2 -0
  137. package/src/coordinate.ts +100 -43
  138. package/src/copy.ts +17 -6
  139. package/src/css/grid.ts +70 -0
  140. package/src/css/index.ts +9 -0
  141. package/src/css/layout.ts +53 -0
  142. package/src/css/shadows.ts +68 -0
  143. package/src/css/values.ts +42 -0
  144. package/src/export-format.ts +12 -0
  145. package/src/fields/geometry.ts +11 -0
  146. package/src/fields/text.ts +35 -0
  147. package/src/gradient.ts +166 -0
  148. package/src/group-bounds.ts +131 -0
  149. package/src/guides.ts +39 -0
  150. package/src/hit-test.ts +262 -46
  151. package/src/icons/glyph.ts +128 -0
  152. package/src/icons/model.ts +54 -0
  153. package/src/icons/schema.ts +18 -0
  154. package/src/index.ts +347 -57
  155. package/src/instance-overrides.ts +27 -0
  156. package/src/instances/content-size.ts +58 -0
  157. package/src/instances/copies.ts +239 -0
  158. package/src/instances/cycles.ts +73 -0
  159. package/src/instances/fields.ts +143 -0
  160. package/src/instances/main-component.ts +19 -0
  161. package/src/instances/placement.ts +29 -0
  162. package/src/instances/source-walk.ts +41 -0
  163. package/src/instances/sync.ts +600 -0
  164. package/src/instances/vector-geometry.ts +81 -0
  165. package/src/instances.ts +125 -330
  166. package/src/layout/aspect-ratio.ts +51 -0
  167. package/src/{layout-guides.ts → layout/guides.ts} +41 -12
  168. package/src/layout/index.ts +4 -0
  169. package/src/layout/keywords.ts +73 -0
  170. package/src/layout/sizing.ts +196 -0
  171. package/src/mutation-impact.ts +25 -10
  172. package/src/node-defaults.ts +50 -2
  173. package/src/order-keys.ts +162 -0
  174. package/src/parse-path.ts +10 -2
  175. package/src/plugin-data/field.ts +131 -0
  176. package/src/plugin-data/fields.ts +246 -0
  177. package/src/polygon.ts +211 -0
  178. package/src/preview.ts +1 -1
  179. package/src/random.ts +28 -0
  180. package/src/resize.ts +99 -12
  181. package/src/scaling/index.ts +2 -0
  182. package/src/scaling/node.ts +164 -0
  183. package/src/scaling/tree.ts +50 -0
  184. package/src/shaders/model.ts +98 -0
  185. package/src/shaders/schema.ts +48 -0
  186. package/src/shared-styles.ts +5 -2
  187. package/src/slots/authoring.ts +101 -0
  188. package/src/slots/content.ts +124 -0
  189. package/src/slots/frames.ts +160 -0
  190. package/src/slots/limits.ts +49 -0
  191. package/src/text/direction.ts +55 -0
  192. package/src/text/index.ts +3 -0
  193. package/src/text/lists.ts +138 -0
  194. package/src/text/paragraphs.ts +241 -0
  195. package/src/{text-picture.ts → text/picture.ts} +21 -29
  196. package/src/text/references.ts +50 -0
  197. package/src/transfer/apply.ts +84 -0
  198. package/src/transfer/history.ts +49 -0
  199. package/src/transfer/identity.ts +16 -0
  200. package/src/transfer/index.ts +6 -0
  201. package/src/transfer/nodes.ts +120 -0
  202. package/src/transfer/plan.ts +130 -0
  203. package/src/transfer/references.ts +9 -0
  204. package/src/transfer/remove.ts +39 -0
  205. package/src/transfer/validation.ts +59 -0
  206. package/src/transfer/variables.ts +82 -0
  207. package/src/types.ts +257 -13
  208. package/src/undo.ts +54 -2
  209. package/src/variables/bindings.ts +224 -0
  210. package/src/variables/fields.ts +43 -0
  211. package/src/variables/token.ts +14 -0
  212. package/src/variables/units.ts +15 -0
  213. package/src/variables.ts +118 -69
  214. package/src/variant-properties.ts +50 -0
  215. package/dist/chunks/components/properties.js.map +0 -1
  216. package/dist/chunks/export-scale.js +0 -19
  217. package/dist/chunks/export-scale.js.map +0 -1
  218. package/dist/coordinate.d.ts.map +0 -1
  219. package/dist/coordinate2.d.ts +0 -2
  220. package/dist/guides2.d.ts +0 -11
  221. package/dist/guides2.d.ts.map +0 -1
  222. package/dist/hit-test.d.ts.map +0 -1
  223. package/dist/layout-guides.d.ts +0 -2
  224. package/dist/layout-guides.js +0 -2
  225. package/dist/layout-guides2.d.ts +0 -16
  226. package/dist/layout-guides2.d.ts.map +0 -1
  227. package/dist/node-defaults.d.ts.map +0 -1
  228. package/dist/preview2.d.ts +0 -12
  229. package/dist/preview2.d.ts.map +0 -1
  230. package/dist/resize.js.map +0 -1
  231. package/dist/variables.d.ts.map +0 -1
  232. package/dist/vector-network2.d.ts +0 -32
  233. package/dist/vector-network2.d.ts.map +0 -1
  234. package/src/instance-overrides.test.ts +0 -67
@@ -1,104 +1,8 @@
1
1
  import { arrowCapOverflow } from "../../arrow-caps.js";
2
+ import { BLACK, DEFAULT_FONT_FAMILY } from "./contrast.js";
3
+ import { OPEN_PENCIL_PLUGIN_DATA, readAllPluginData, withAllPluginData } from "../behaviours/layers.js";
2
4
  import { isEqual } from "es-toolkit/predicate";
3
- //#region src/instance-overrides.ts
4
- function createInstanceOverrideState() {
5
- return {
6
- self: /* @__PURE__ */ new Map(),
7
- descendants: /* @__PURE__ */ new Map()
8
- };
9
- }
10
- function serializeOverrideValue(value) {
11
- return value === void 0 ? { defined: false } : {
12
- defined: true,
13
- value
14
- };
15
- }
16
- function deserializeOverrideValue(value) {
17
- if (!value || typeof value !== "object" || Array.isArray(value)) return {
18
- valid: false,
19
- value: void 0
20
- };
21
- if (!("defined" in value) || typeof value.defined !== "boolean") return {
22
- valid: false,
23
- value: void 0
24
- };
25
- if (value.defined) return "value" in value ? {
26
- valid: true,
27
- value: value["value"]
28
- } : {
29
- valid: false,
30
- value: void 0
31
- };
32
- return {
33
- valid: true,
34
- value: void 0
35
- };
36
- }
37
- function deserializeEntries(value) {
38
- const result = /* @__PURE__ */ new Map();
39
- if (!Array.isArray(value)) return result;
40
- for (const entry of value) {
41
- if (!Array.isArray(entry) || entry.length !== 2 || typeof entry[0] !== "string") continue;
42
- const decoded = deserializeOverrideValue(entry[1]);
43
- if (decoded.valid) result.set(entry[0], decoded.value);
44
- }
45
- return result;
46
- }
47
- function serializeInstanceOverrideState(state) {
48
- return {
49
- self: [...state.self].map(([field, value]) => [field, serializeOverrideValue(value)]),
50
- descendants: [...state.descendants].map(([nodeId, fields]) => [nodeId, [...fields].map(([field, value]) => [field, serializeOverrideValue(value)])])
51
- };
52
- }
53
- function deserializeInstanceOverrideState(state) {
54
- if (!state || typeof state !== "object" || Array.isArray(state)) return createInstanceOverrideState();
55
- const self = "self" in state ? deserializeEntries(state.self) : /* @__PURE__ */ new Map();
56
- const descendants = /* @__PURE__ */ new Map();
57
- if ("descendants" in state && Array.isArray(state.descendants)) for (const entry of state.descendants) {
58
- if (!Array.isArray(entry) || entry.length !== 2 || typeof entry[0] !== "string") continue;
59
- descendants.set(entry[0], deserializeEntries(entry[1]));
60
- }
61
- return {
62
- self,
63
- descendants
64
- };
65
- }
66
- function cloneInstanceOverrideState(state) {
67
- return {
68
- self: new Map([...state.self].map(([field, value]) => [field, structuredClone(value)])),
69
- descendants: new Map([...state.descendants].map(([id, fields]) => [id, new Map([...fields].map(([field, value]) => [field, structuredClone(value)]))]))
70
- };
71
- }
72
- function getInstanceOverride(state, instanceId, nodeId, field) {
73
- return nodeId === instanceId ? state.self.get(field) : state.descendants.get(nodeId)?.get(field);
74
- }
75
- function hasInstanceOverride$1(state, instanceId, nodeId, field) {
76
- return (nodeId === instanceId ? state.self : state.descendants.get(nodeId))?.has(field) ?? false;
77
- }
78
- function setInstanceOverride(state, instanceId, nodeId, field, value = true) {
79
- if (nodeId === instanceId) {
80
- state.self.set(field, value);
81
- return;
82
- }
83
- const fields = state.descendants.get(nodeId) ?? /* @__PURE__ */ new Map();
84
- fields.set(field, value);
85
- state.descendants.set(nodeId, fields);
86
- }
87
- function deleteInstanceOverride(state, instanceId, nodeId, field) {
88
- const fields = nodeId === instanceId ? state.self : state.descendants.get(nodeId);
89
- if (!fields?.delete(field)) return false;
90
- if (nodeId !== instanceId && fields.size === 0) state.descendants.delete(nodeId);
91
- return true;
92
- }
93
- function clearInstanceOverrides(state) {
94
- state.self.clear();
95
- state.descendants.clear();
96
- }
97
- function forEachInstanceOverride(state, callback) {
98
- for (const [field, value] of state.self) callback("", field, value);
99
- for (const [nodeId, fields] of state.descendants) for (const [field, value] of fields) callback(nodeId, field, value);
100
- }
101
- //#endregion
5
+ import { converter, differenceEuclidean, formatCss, formatHex, formatHex8, formatRgb, inGamut, parse, toGamut } from "culori";
102
6
  //#region src/geometry.ts
103
7
  function degToRad(degrees) {
104
8
  return degrees * Math.PI / 180;
@@ -533,21 +437,124 @@ function clipBoundsToPolygon(bounds, clipCorners) {
533
437
  } : null;
534
438
  }
535
439
  //#endregion
536
- //#region src/constants.ts
537
- const BLACK = {
538
- r: 0,
539
- g: 0,
540
- b: 0,
541
- a: 1
542
- };
543
- const TRANSPARENT = {
544
- r: 0,
545
- g: 0,
546
- b: 0,
547
- a: 0
548
- };
549
- const DEFAULT_FONT_FAMILY = "Inter";
550
- const DEFAULT_STROKE_MITER_LIMIT = 4;
440
+ //#region src/instance-overrides.ts
441
+ function createInstanceOverrideState() {
442
+ return {
443
+ self: /* @__PURE__ */ new Map(),
444
+ descendants: /* @__PURE__ */ new Map()
445
+ };
446
+ }
447
+ function serializeOverrideValue(value) {
448
+ return value === void 0 ? { defined: false } : {
449
+ defined: true,
450
+ value
451
+ };
452
+ }
453
+ function deserializeOverrideValue(value) {
454
+ if (!value || typeof value !== "object" || Array.isArray(value)) return {
455
+ valid: false,
456
+ value: void 0
457
+ };
458
+ if (!("defined" in value) || typeof value.defined !== "boolean") return {
459
+ valid: false,
460
+ value: void 0
461
+ };
462
+ if (value.defined) return "value" in value ? {
463
+ valid: true,
464
+ value: value["value"]
465
+ } : {
466
+ valid: false,
467
+ value: void 0
468
+ };
469
+ return {
470
+ valid: true,
471
+ value: void 0
472
+ };
473
+ }
474
+ function deserializeEntries(value) {
475
+ const result = /* @__PURE__ */ new Map();
476
+ if (!Array.isArray(value)) return result;
477
+ for (const entry of value) {
478
+ if (!Array.isArray(entry) || entry.length !== 2 || typeof entry[0] !== "string") continue;
479
+ const decoded = deserializeOverrideValue(entry[1]);
480
+ if (decoded.valid) result.set(entry[0], decoded.value);
481
+ }
482
+ return result;
483
+ }
484
+ function serializeInstanceOverrideState(state) {
485
+ return {
486
+ self: [...state.self].map(([field, value]) => [field, serializeOverrideValue(value)]),
487
+ descendants: [...state.descendants].map(([nodeId, fields]) => [nodeId, [...fields].map(([field, value]) => [field, serializeOverrideValue(value)])])
488
+ };
489
+ }
490
+ function deserializeInstanceOverrideState(state) {
491
+ if (!state || typeof state !== "object" || Array.isArray(state)) return createInstanceOverrideState();
492
+ const self = "self" in state ? deserializeEntries(state.self) : /* @__PURE__ */ new Map();
493
+ const descendants = /* @__PURE__ */ new Map();
494
+ if ("descendants" in state && Array.isArray(state.descendants)) for (const entry of state.descendants) {
495
+ if (!Array.isArray(entry) || entry.length !== 2 || typeof entry[0] !== "string") continue;
496
+ descendants.set(entry[0], deserializeEntries(entry[1]));
497
+ }
498
+ return {
499
+ self,
500
+ descendants
501
+ };
502
+ }
503
+ function cloneInstanceOverrideState(state) {
504
+ return {
505
+ self: new Map([...state.self].map(([field, value]) => [field, structuredClone(value)])),
506
+ descendants: new Map([...state.descendants].map(([id, fields]) => [id, new Map([...fields].map(([field, value]) => [field, structuredClone(value)]))]))
507
+ };
508
+ }
509
+ /** Remap runtime identities only; ordinary strings and source-format payloads stay opaque. */
510
+ function remapInstanceOverrideState(state, references) {
511
+ const remapValue = (field, value) => {
512
+ if (typeof value !== "string") return structuredClone(value);
513
+ if (field === "componentId" || field === "sourceComponentId") return references.node(value);
514
+ if (field.startsWith("boundVariables/")) return references.variable(value);
515
+ return value;
516
+ };
517
+ const fields = (entries) => new Map([...entries].map(([field, value]) => [field, remapValue(field, value)]));
518
+ const descendants = /* @__PURE__ */ new Map();
519
+ for (const [id, entries] of state.descendants) {
520
+ const mapped = references.node(id);
521
+ if (descendants.has(mapped)) throw new Error(`Duplicate remapped override target ${mapped}`);
522
+ descendants.set(mapped, fields(entries));
523
+ }
524
+ return {
525
+ self: fields(state.self),
526
+ descendants
527
+ };
528
+ }
529
+ function getInstanceOverride(state, instanceId, nodeId, field) {
530
+ return nodeId === instanceId ? state.self.get(field) : state.descendants.get(nodeId)?.get(field);
531
+ }
532
+ function hasInstanceOverride(state, instanceId, nodeId, field) {
533
+ return (nodeId === instanceId ? state.self : state.descendants.get(nodeId))?.has(field) ?? false;
534
+ }
535
+ function setInstanceOverride(state, instanceId, nodeId, field, value = true) {
536
+ if (nodeId === instanceId) {
537
+ state.self.set(field, value);
538
+ return;
539
+ }
540
+ const fields = state.descendants.get(nodeId) ?? /* @__PURE__ */ new Map();
541
+ fields.set(field, value);
542
+ state.descendants.set(nodeId, fields);
543
+ }
544
+ function deleteInstanceOverride(state, instanceId, nodeId, field) {
545
+ const fields = nodeId === instanceId ? state.self : state.descendants.get(nodeId);
546
+ if (!fields?.delete(field)) return false;
547
+ if (nodeId !== instanceId && fields.size === 0) state.descendants.delete(nodeId);
548
+ return true;
549
+ }
550
+ function clearInstanceOverrides(state) {
551
+ state.self.clear();
552
+ state.descendants.clear();
553
+ }
554
+ function forEachInstanceOverride(state, callback) {
555
+ for (const [field, value] of state.self) callback("", field, value);
556
+ for (const [nodeId, fields] of state.descendants) for (const [field, value] of fields) callback(nodeId, field, value);
557
+ }
551
558
  //#endregion
552
559
  //#region src/node-defaults.ts
553
560
  function createDefaultSourceMetadata() {
@@ -569,6 +576,22 @@ function createDefaultSourceMetadata() {
569
576
  }
570
577
  };
571
578
  }
579
+ /** Where Figma aligns a new node's strokes: centered on lines and vectors, outside text, else inside. */
580
+ function defaultStrokeAlign(type) {
581
+ if (type === "LINE" || type === "VECTOR") return "CENTER";
582
+ return type === "TEXT" ? "OUTSIDE" : "INSIDE";
583
+ }
584
+ /**
585
+ * Weight and alignment a stroke added to `node` takes: its first stroke's, or what the node keeps
586
+ * with none. Adding a stroke from the panel and from the plugin API both go through here.
587
+ */
588
+ function newStrokeGeometry(node) {
589
+ const first = node.strokes.at(0);
590
+ return {
591
+ weight: first?.weight ?? node.strokeWeight,
592
+ align: first?.align ?? node.strokeAlign
593
+ };
594
+ }
572
595
  function createDefaultNode(generateId, type, overrides = {}) {
573
596
  return {
574
597
  id: generateId(),
@@ -653,6 +676,11 @@ function createDefaultNode(generateId, type, overrides = {}) {
653
676
  textDecorationSkipInk: true,
654
677
  textUnderlineOffset: null,
655
678
  maxLines: null,
679
+ textParagraphs: [],
680
+ listSpacing: 0,
681
+ paragraphSpacing: 0,
682
+ paragraphIndent: 0,
683
+ hangingList: false,
656
684
  styleRuns: [],
657
685
  fontVariations: [],
658
686
  fontFeatures: [],
@@ -666,11 +694,14 @@ function createDefaultNode(generateId, type, overrides = {}) {
666
694
  borderBottomWeight: 0,
667
695
  borderLeftWeight: 0,
668
696
  independentStrokeWeights: false,
697
+ strokeWeight: 1,
698
+ strokeAlign: defaultStrokeAlign(type),
669
699
  strokeMiterLimit: 4,
670
700
  minWidth: null,
671
701
  maxWidth: null,
672
702
  minHeight: null,
673
703
  maxHeight: null,
704
+ targetAspectRatio: null,
674
705
  isMask: false,
675
706
  maskType: "ALPHA",
676
707
  maskIsOutline: false,
@@ -702,10 +733,14 @@ function createDefaultNode(generateId, type, overrides = {}) {
702
733
  librarySource: null,
703
734
  isPublishable: false,
704
735
  isSymbolPublishable: false,
736
+ isExposedInstance: false,
705
737
  symbolDescription: "",
706
738
  symbolLinks: [],
707
739
  variantPropSpecs: [],
708
740
  boundVariables: {},
741
+ variableBindingScales: {},
742
+ variableAssignmentScales: {},
743
+ componentScale: 1,
709
744
  variableModes: {},
710
745
  exportSettings: [],
711
746
  pluginData: [],
@@ -717,9 +752,12 @@ function createDefaultNode(generateId, type, overrides = {}) {
717
752
  derivedTextGlyphs: null,
718
753
  textPathData: null,
719
754
  textPathBox: null,
755
+ booleanOperation: void 0,
720
756
  ...overrides
721
757
  };
722
758
  }
759
+ /** Containers whose bounds follow their children and that set no coordinate space, as in Figma. */
760
+ const FITTED_CONTAINER_TYPES = /* @__PURE__ */ new Set(["GROUP", "BOOLEAN_OPERATION"]);
723
761
  const CONTAINER_TYPES = /* @__PURE__ */ new Set([
724
762
  "CANVAS",
725
763
  "FRAME",
@@ -942,6 +980,7 @@ function normalizeVectorNetwork(vn) {
942
980
  }
943
981
  //#endregion
944
982
  //#region src/copy.ts
983
+ /** Generic over the paint shape so a stroke keeps its own fields while the paint deep-copies. */
945
984
  function copyFill(f) {
946
985
  const copy = {
947
986
  ...f,
@@ -955,10 +994,7 @@ function copyFill(f) {
955
994
  return copy;
956
995
  }
957
996
  function copyStroke(s) {
958
- const copy = {
959
- ...s,
960
- color: { ...s.color }
961
- };
997
+ const copy = copyFill(s);
962
998
  if (s.dashPattern) copy.dashPattern = [...s.dashPattern];
963
999
  return copy;
964
1000
  }
@@ -970,7 +1006,7 @@ function copyEffect(e) {
970
1006
  };
971
1007
  }
972
1008
  function copyStyleRun(r) {
973
- return {
1009
+ const copy = {
974
1010
  ...r,
975
1011
  style: {
976
1012
  ...r.style,
@@ -980,6 +1016,9 @@ function copyStyleRun(r) {
980
1016
  fontFeatures: r.style.fontFeatures ? r.style.fontFeatures.map((v) => ({ ...v })) : void 0
981
1017
  }
982
1018
  };
1019
+ if (r.style.hyperlink) copy.style.hyperlink = { ...r.style.hyperlink };
1020
+ if (r.style.boundVariables) copy.style.boundVariables = { ...r.style.boundVariables };
1021
+ return copy;
983
1022
  }
984
1023
  const internalCopySources = /* @__PURE__ */ new WeakMap();
985
1024
  /** Record immutable lineage for an internal deep copy without sharing mutable values. */
@@ -1075,7 +1114,8 @@ function copyPropertyDefs(defs) {
1075
1114
  return defs?.map((d) => ({
1076
1115
  ...d,
1077
1116
  variantOptions: d.variantOptions ? [...d.variantOptions] : void 0,
1078
- preferredValues: d.preferredValues ? [...d.preferredValues] : void 0
1117
+ preferredValues: d.preferredValues ? [...d.preferredValues] : void 0,
1118
+ slotSettings: d.slotSettings ? { ...d.slotSettings } : void 0
1079
1119
  })) ?? [];
1080
1120
  }
1081
1121
  /** Deep-copy path-text glyphs (fresh commandsBlob buffers). */
@@ -1099,6 +1139,8 @@ function cloneNodeProps(src, componentId, mode = "deep") {
1099
1139
  ...componentId !== null ? { componentId } : {},
1100
1140
  source: createDefaultSourceMetadata(),
1101
1141
  boundVariables: { ...src.boundVariables },
1142
+ variableBindingScales: { ...src.variableBindingScales },
1143
+ variableAssignmentScales: { ...src.variableAssignmentScales },
1102
1144
  variableModes: { ...src.variableModes },
1103
1145
  instanceOverrides: cloneInstanceOverrideState(src.instanceOverrides),
1104
1146
  componentPropertyAssignments: { ...src.componentPropertyAssignments },
@@ -1108,6 +1150,8 @@ function cloneNodeProps(src, componentId, mode = "deep") {
1108
1150
  ...rest,
1109
1151
  ...componentId !== null ? { componentId } : {},
1110
1152
  boundVariables: { ...src.boundVariables },
1153
+ variableBindingScales: { ...src.variableBindingScales },
1154
+ variableAssignmentScales: { ...src.variableAssignmentScales },
1111
1155
  variableModes: { ...src.variableModes },
1112
1156
  instanceOverrides: cloneInstanceOverrideState(src.instanceOverrides),
1113
1157
  fills: copyOpt(src.fills, (value) => markCopySource(value, copyFills(value))),
@@ -1120,6 +1164,7 @@ function cloneNodeProps(src, componentId, mode = "deep") {
1120
1164
  dashPattern: copyOpt(src.dashPattern, (a) => [...a]),
1121
1165
  fontVariations: copyOpt(src.fontVariations, (a) => a.map((v) => ({ ...v }))),
1122
1166
  fontFeatures: copyOpt(src.fontFeatures, (a) => a.map((v) => ({ ...v }))),
1167
+ textParagraphs: copyOpt(src.textParagraphs, (a) => a.map((v) => ({ ...v }))),
1123
1168
  textDecorationFills: copyOpt(src.textDecorationFills, copyFills),
1124
1169
  fillGeometry: copyOpt(src.fillGeometry, copyGeometryPaths),
1125
1170
  strokeGeometry: copyOpt(src.strokeGeometry, copyGeometryPaths),
@@ -1141,431 +1186,441 @@ function cloneNodeProps(src, componentId, mode = "deep") {
1141
1186
  derivedTextGlyphs: src.derivedTextGlyphs ? markCopySource(src.derivedTextGlyphs, copyDerivedGlyphs(src.derivedTextGlyphs) ?? []) : null,
1142
1187
  textPathData: src.textPathData ? structuredClone(src.textPathData) : null,
1143
1188
  textPathBox: src.textPathBox ? { ...src.textPathBox } : null,
1144
- gridPosition: src.gridPosition ? { ...src.gridPosition } : null
1189
+ gridPosition: src.gridPosition ? { ...src.gridPosition } : null,
1190
+ targetAspectRatio: src.targetAspectRatio ? { ...src.targetAspectRatio } : null
1145
1191
  };
1146
1192
  }
1147
1193
  //#endregion
1148
- //#region src/instances.ts
1149
- const INSTANCE_SYNC_TEXT_PROPS = [
1150
- "name",
1151
- "text",
1152
- "fontSize",
1153
- "fontWeight",
1154
- "fontFamily",
1155
- "textDirection"
1156
- ];
1157
- const INSTANCE_SYNC_PROPS = [
1158
- "width",
1159
- "height",
1160
- "minWidth",
1161
- "maxWidth",
1162
- "minHeight",
1163
- "maxHeight",
1164
- "fills",
1165
- "strokes",
1166
- "effects",
1167
- "opacity",
1168
- "cornerRadius",
1169
- "topLeftRadius",
1170
- "topRightRadius",
1171
- "bottomRightRadius",
1172
- "bottomLeftRadius",
1173
- "independentCorners",
1174
- "layoutMode",
1175
- "layoutDirection",
1176
- "layoutWrap",
1177
- "primaryAxisAlign",
1178
- "counterAxisAlign",
1179
- "primaryAxisSizing",
1180
- "counterAxisSizing",
1181
- "itemSpacing",
1182
- "counterAxisSpacing",
1183
- "paddingTop",
1184
- "paddingRight",
1185
- "paddingBottom",
1186
- "paddingLeft",
1187
- "gridTemplateColumns",
1188
- "gridTemplateRows",
1189
- "gridColumnGap",
1190
- "gridRowGap",
1191
- "gridPosition",
1192
- "clipsContent",
1193
- "independentStrokeWeights",
1194
- "borderTopWeight",
1195
- "borderRightWeight",
1196
- "borderBottomWeight",
1197
- "borderLeftWeight",
1198
- "boundVariables",
1199
- "variableModes"
1200
- ];
1201
- const INSTANCE_SYNC_FIELDS = [...INSTANCE_SYNC_PROPS, ...INSTANCE_SYNC_TEXT_PROPS];
1202
- function setSceneProp(target, key, value) {
1203
- target[key] = value;
1204
- }
1205
- function copyProp(target, source, key) {
1206
- if (key === "fills") setSceneProp(target, key, copyFills(source.fills));
1207
- else if (key === "strokes") setSceneProp(target, key, copyStrokes(source.strokes));
1208
- else if (key === "effects") setSceneProp(target, key, copyEffects(source.effects));
1209
- else if (key === "styleRuns") setSceneProp(target, key, copyStyleRuns(source.styleRuns));
1210
- else if (key === "boundVariables") setSceneProp(target, key, { ...source.boundVariables });
1211
- else if (key === "variableModes") setSceneProp(target, key, { ...source.variableModes });
1212
- else if (key === "gridPosition") setSceneProp(target, key, source.gridPosition ? { ...source.gridPosition } : null);
1213
- else {
1214
- const value = source[key];
1215
- setSceneProp(target, key, Array.isArray(value) ? structuredClone(value) : value);
1216
- }
1194
+ //#region src/color/normalize.ts
1195
+ function normalizeColor(color) {
1196
+ if (!color) return { ...BLACK };
1197
+ return {
1198
+ r: color.r ?? 0,
1199
+ g: color.g ?? 0,
1200
+ b: color.b ?? 0,
1201
+ a: color.a ?? 1
1202
+ };
1217
1203
  }
1218
- function cloneChildrenWithMapping(graph, sourceParentId, destParentId, mode = "deep") {
1219
- if (sourceParentId === destParentId || graph.isDescendant(destParentId, sourceParentId)) return;
1220
- const sourceParent = graph.nodes.get(sourceParentId);
1221
- if (!sourceParent) return;
1222
- for (const childId of sourceParent.childIds) {
1223
- const src = graph.nodes.get(childId);
1224
- if (!src) continue;
1225
- const clone = graph.createNode(src.type, destParentId, cloneNodeProps(src, childId, mode));
1226
- if (src.childIds.length > 0) cloneChildrenWithMapping(graph, childId, clone.id, mode);
1227
- }
1204
+ //#endregion
1205
+ //#region src/color/okhcl.ts
1206
+ const toRGB$2 = converter("rgb");
1207
+ const toP3$1 = converter("p3");
1208
+ const toOkHCL = converter("oklch");
1209
+ const toDisplayableRGB$1 = toGamut("rgb", "oklch");
1210
+ const toDisplayableP3$1 = toGamut("p3", "oklch");
1211
+ function clampUnit(value) {
1212
+ if (value < 0) return 0;
1213
+ if (value > 1) return 1;
1214
+ return value;
1215
+ }
1216
+ function normalizeHue(value) {
1217
+ const hue = value % 360;
1218
+ return hue < 0 ? hue + 360 : hue;
1219
+ }
1220
+ function normalizeOkHCLColor(color) {
1221
+ return {
1222
+ h: normalizeHue(color.h),
1223
+ c: Math.max(0, color.c),
1224
+ l: clampUnit(color.l),
1225
+ a: clampUnit(color.a ?? 1)
1226
+ };
1228
1227
  }
1229
- function linkMatchedChild(overrides, instParentId, instChild, compChildId) {
1230
- if (instChild.type === "INSTANCE") setInstanceOverride(overrides, instParentId, instChild.id, "sourceComponentId", compChildId);
1231
- else instChild.componentId = compChildId;
1232
- }
1233
- function matchFallbackChildren(graph, compParent, instParent, instParentId, overrides, instChildMap, usedInstChildIds) {
1234
- const fallbackByType = /* @__PURE__ */ new Map();
1235
- const remainingCandidateCount = /* @__PURE__ */ new Map();
1236
- const unmatchedComponentCount = /* @__PURE__ */ new Map();
1237
- for (const compChildId of compParent.childIds) {
1238
- if (instChildMap.has(compChildId)) continue;
1239
- const child = graph.nodes.get(compChildId);
1240
- if (child) unmatchedComponentCount.set(child.type, (unmatchedComponentCount.get(child.type) ?? 0) + 1);
1241
- }
1242
- for (const childId of instParent.childIds) {
1243
- const child = graph.nodes.get(childId);
1244
- if (!child || usedInstChildIds.has(child.id)) continue;
1245
- remainingCandidateCount.set(child.type, (remainingCandidateCount.get(child.type) ?? 0) + 1);
1246
- let byName = fallbackByType.get(child.type);
1247
- if (!byName) {
1248
- byName = /* @__PURE__ */ new Map();
1249
- fallbackByType.set(child.type, byName);
1250
- }
1251
- const queue = byName.get(child.name);
1252
- if (queue) queue.push(child);
1253
- else byName.set(child.name, [child]);
1254
- }
1255
- for (const compChildId of compParent.childIds) {
1256
- if (instChildMap.has(compChildId)) continue;
1257
- const compChild = graph.nodes.get(compChildId);
1258
- if (!compChild) continue;
1259
- const candidatesByName = fallbackByType.get(compChild.type);
1260
- const candidateCount = remainingCandidateCount.get(compChild.type) ?? 0;
1261
- if (candidateCount > (unmatchedComponentCount.get(compChild.type) ?? 0)) continue;
1262
- const match = candidatesByName?.get(compChild.name)?.shift();
1263
- if (!match) continue;
1264
- remainingCandidateCount.set(compChild.type, candidateCount - 1);
1265
- instChildMap.set(compChildId, match);
1266
- usedInstChildIds.add(match.id);
1267
- linkMatchedChild(overrides, instParentId, match, compChildId);
1228
+ /** Coordinates in `colorSpace`, so callers can store colours in the document's profile. */
1229
+ function okhclToRGBA(color, colorSpace = "srgb") {
1230
+ const normalized = normalizeOkHCLColor(color);
1231
+ const oklch = {
1232
+ mode: "oklch",
1233
+ l: normalized.l,
1234
+ c: normalized.c,
1235
+ h: normalized.h,
1236
+ alpha: normalized.a
1237
+ };
1238
+ if (colorSpace === "display-p3") {
1239
+ const p3 = toP3$1(toDisplayableP3$1(oklch));
1240
+ return normalizeColor({
1241
+ r: p3.r,
1242
+ g: p3.g,
1243
+ b: p3.b,
1244
+ a: p3.alpha ?? normalized.a
1245
+ });
1268
1246
  }
1247
+ const rgb = toRGB$2(toDisplayableRGB$1(oklch));
1248
+ return normalizeColor({
1249
+ r: rgb.r,
1250
+ g: rgb.g,
1251
+ b: rgb.b,
1252
+ a: rgb.alpha ?? normalized.a
1253
+ });
1269
1254
  }
1270
- function sortInstanceChildren(graph, instParent, instParentId, compChildOrder, overrides) {
1271
- const orderMap = /* @__PURE__ */ new Map();
1272
- for (let i = 0; i < compChildOrder.length; i++) orderMap.set(compChildOrder[i], i);
1273
- const ranks = /* @__PURE__ */ new Map();
1274
- for (let index = 0; index < instParent.childIds.length; index++) {
1275
- const childId = instParent.childIds[index];
1276
- const node = graph.nodes.get(childId);
1277
- const source = node ? getInstanceOverride(overrides, instParentId, node.id, "sourceComponentId") : void 0;
1278
- const mapped = typeof source === "string" ? source : node?.componentId;
1279
- const componentIndex = mapped ? orderMap.get(mapped) : void 0;
1280
- ranks.set(childId, componentIndex ?? compChildOrder.length + index);
1281
- }
1282
- instParent.childIds.sort((left, right) => (ranks.get(left) ?? 0) - (ranks.get(right) ?? 0));
1283
- }
1284
- /** True when syncing `compParentId` into `instParentId` would form a cycle. */
1285
- function isCyclicSync(graph, compParentId, instParentId) {
1286
- return compParentId === instParentId || graph.isDescendant(instParentId, compParentId);
1287
- }
1288
- function syncChildren(graph, compParentId, instParentId, overrides) {
1289
- if (isCyclicSync(graph, compParentId, instParentId)) return;
1290
- const compParent = graph.nodes.get(compParentId);
1291
- const instParent = graph.nodes.get(instParentId);
1292
- if (!compParent || !instParent) return;
1293
- const instChildMap = /* @__PURE__ */ new Map();
1294
- const usedInstChildIds = /* @__PURE__ */ new Set();
1295
- const compChildIdSet = new Set(compParent.childIds);
1296
- for (const childId of instParent.childIds) {
1297
- const child = graph.nodes.get(childId);
1298
- if (!child) continue;
1299
- const sourceComponentId = getInstanceOverride(overrides, instParentId, child.id, "sourceComponentId");
1300
- const mappedComponentId = typeof sourceComponentId === "string" ? sourceComponentId : child.componentId;
1301
- if (mappedComponentId && compChildIdSet.has(mappedComponentId)) {
1302
- instChildMap.set(mappedComponentId, child);
1303
- usedInstChildIds.add(child.id);
1304
- }
1305
- }
1306
- matchFallbackChildren(graph, compParent, instParent, instParentId, overrides, instChildMap, usedInstChildIds);
1307
- for (const compChildId of compParent.childIds) if (!instChildMap.has(compChildId)) {
1308
- const src = graph.nodes.get(compChildId);
1309
- if (!src) continue;
1310
- const clone = graph.createNode(src.type, instParentId, cloneNodeProps(src, compChildId));
1311
- if (src.childIds.length > 0) cloneChildrenWithMapping(graph, compChildId, clone.id);
1312
- instChildMap.set(compChildId, clone);
1313
- usedInstChildIds.add(clone.id);
1314
- }
1315
- for (const compChildId of compParent.childIds) {
1316
- const compChild = graph.nodes.get(compChildId);
1317
- const instChild = instChildMap.get(compChildId);
1318
- if (!compChild || !instChild) continue;
1319
- for (const key of INSTANCE_SYNC_FIELDS) {
1320
- if (hasInstanceOverride$1(overrides, instParentId, instChild.id, key)) continue;
1321
- copyProp(instChild, compChild, key);
1322
- }
1323
- if (compChild.childIds.length > 0 && !hasInstanceOverride$1(overrides, instParentId, instChild.id, "componentId")) syncChildren(graph, compChildId, instChild.id, overrides);
1324
- }
1325
- sortInstanceChildren(graph, instParent, instParentId, compParent.childIds, overrides);
1326
- }
1327
- function copyInstanceComponentProps(component) {
1328
- const props = {};
1329
- for (const key of INSTANCE_SYNC_PROPS) copyProp(props, component, key);
1330
- return props;
1331
- }
1332
- function createInstance(graph, componentId, parentId, overrides = {}) {
1333
- const component = graph.nodes.get(componentId);
1334
- if (component?.type !== "COMPONENT") return null;
1335
- const props = {
1336
- ...copyInstanceComponentProps(component),
1337
- name: component.name,
1338
- componentId
1255
+ /** Reads `color` as coordinates in `colorSpace`, the inverse of {@link okhclToRGBA}. */
1256
+ function rgbaToOkHCL(color, colorSpace = "srgb") {
1257
+ const oklch = toOkHCL(colorSpace === "display-p3" ? {
1258
+ mode: "p3",
1259
+ r: color.r,
1260
+ g: color.g,
1261
+ b: color.b,
1262
+ alpha: color.a
1263
+ } : {
1264
+ mode: "rgb",
1265
+ r: color.r,
1266
+ g: color.g,
1267
+ b: color.b,
1268
+ alpha: color.a
1269
+ });
1270
+ return normalizeOkHCLColor({
1271
+ h: oklch.h ?? 0,
1272
+ c: oklch.c,
1273
+ l: oklch.l,
1274
+ a: oklch.alpha ?? color.a
1275
+ });
1276
+ }
1277
+ function serializeOkHCLPayload(payload) {
1278
+ return OPEN_PENCIL_PLUGIN_DATA.okhcl.encode(payload);
1279
+ }
1280
+ function parseOkHCLPayload(value) {
1281
+ return OPEN_PENCIL_PLUGIN_DATA.okhcl.decode(value) ?? null;
1282
+ }
1283
+ function createOkHCLPayload(kind, index, color) {
1284
+ return {
1285
+ version: 1,
1286
+ kind,
1287
+ index,
1288
+ color: normalizeOkHCLColor(color)
1339
1289
  };
1340
- const instance = graph.createNode("INSTANCE", parentId, {
1341
- ...props,
1342
- ...overrides
1290
+ }
1291
+ /** The node's plugin data with the payload for one paint replaced, or removed without `color`. */
1292
+ function withOkHCLPayload(node, kind, index, color) {
1293
+ const payloads = getNodeOkHCLPayloads(node).filter((payload) => payload.kind !== kind || payload.index !== index);
1294
+ if (color) payloads.push(createOkHCLPayload(kind, index, color));
1295
+ return withAllPluginData(node.pluginData, OPEN_PENCIL_PLUGIN_DATA.okhcl, payloads);
1296
+ }
1297
+ function setNodeFillOkHCL(node, index, color, colorSpace = "srgb") {
1298
+ const fills = node.fills.map(copyFill);
1299
+ if (index < 0 || index >= fills.length) throw new Error(`Fill ${index} not found`);
1300
+ const fill = fills[index];
1301
+ const rgba = okhclToRGBA(color, colorSpace);
1302
+ fills[index] = {
1303
+ ...fill,
1304
+ color: rgba,
1305
+ opacity: rgba.a
1306
+ };
1307
+ return {
1308
+ fills,
1309
+ pluginData: withOkHCLPayload(node, "fill", index, color)
1310
+ };
1311
+ }
1312
+ function setNodeStrokeOkHCL(node, index, color, colorSpace = "srgb") {
1313
+ const strokes = node.strokes.map(copyStroke);
1314
+ if (index < 0 || index >= strokes.length) throw new Error(`Stroke ${index} not found`);
1315
+ const stroke = strokes[index];
1316
+ const rgba = okhclToRGBA(color, colorSpace);
1317
+ strokes[index] = {
1318
+ ...stroke,
1319
+ color: rgba,
1320
+ opacity: rgba.a
1321
+ };
1322
+ return {
1323
+ strokes,
1324
+ pluginData: withOkHCLPayload(node, "stroke", index, color)
1325
+ };
1326
+ }
1327
+ function clearNodeFillOkHCL(node, index) {
1328
+ return { pluginData: withOkHCLPayload(node, "fill", index) };
1329
+ }
1330
+ function clearNodeStrokeOkHCL(node, index) {
1331
+ return { pluginData: withOkHCLPayload(node, "stroke", index) };
1332
+ }
1333
+ function getNodeOkHCLPayloads(node) {
1334
+ return readAllPluginData(node.pluginData, OPEN_PENCIL_PLUGIN_DATA.okhcl);
1335
+ }
1336
+ function getFillOkHCL(node, index) {
1337
+ return getNodeOkHCLPayloads(node).find((payload) => payload.kind === "fill" && payload.index === index) ?? null;
1338
+ }
1339
+ function getStrokeOkHCL(node, index) {
1340
+ return getNodeOkHCLPayloads(node).find((payload) => payload.kind === "stroke" && payload.index === index) ?? null;
1341
+ }
1342
+ //#endregion
1343
+ //#region src/color/management.ts
1344
+ const DEFAULT_COLOR_SPACE = "srgb";
1345
+ const toRGB$1 = converter("rgb");
1346
+ const toP3 = converter("p3");
1347
+ const toDisplayableRGB = toGamut("rgb", "oklch");
1348
+ const toDisplayableP3 = toGamut("p3", "oklch");
1349
+ const isDisplayableRGB = inGamut("rgb");
1350
+ const isDisplayableP3 = inGamut("p3");
1351
+ function normalizeOkLCH(color) {
1352
+ const hue = color.h % 360;
1353
+ return {
1354
+ mode: "oklch",
1355
+ l: Math.max(0, Math.min(1, color.l)),
1356
+ c: Math.max(0, color.c),
1357
+ h: hue < 0 ? hue + 360 : hue,
1358
+ alpha: Math.max(0, Math.min(1, color.a ?? 1))
1359
+ };
1360
+ }
1361
+ /**
1362
+ * Numbers are stored in the document's profile, so painting into a surface with a different
1363
+ * profile has to convert them. Same profile means no work, which is the common case.
1364
+ */
1365
+ function convertComponents(color, from, to) {
1366
+ if (from === to) return color;
1367
+ const source = from === "display-p3" ? {
1368
+ mode: "p3",
1369
+ r: color.r,
1370
+ g: color.g,
1371
+ b: color.b,
1372
+ alpha: color.a
1373
+ } : {
1374
+ mode: "rgb",
1375
+ r: color.r,
1376
+ g: color.g,
1377
+ b: color.b,
1378
+ alpha: color.a
1379
+ };
1380
+ const converted = to === "display-p3" ? toP3(source) : toRGB$1(source);
1381
+ return normalizeColor({
1382
+ r: converted.r,
1383
+ g: converted.g,
1384
+ b: converted.b,
1385
+ a: converted.alpha ?? color.a
1386
+ });
1387
+ }
1388
+ function isOutsideGamut(color, space) {
1389
+ if (space === "display-p3") return !isDisplayableP3({
1390
+ mode: "p3",
1391
+ r: color.r,
1392
+ g: color.g,
1393
+ b: color.b,
1394
+ alpha: color.a
1395
+ });
1396
+ return !isDisplayableRGB({
1397
+ mode: "rgb",
1398
+ r: color.r,
1399
+ g: color.g,
1400
+ b: color.b,
1401
+ alpha: color.a
1343
1402
  });
1344
- cloneChildrenWithMapping(graph, component.id, instance.id);
1345
- return instance;
1346
- }
1347
- function populateInstanceChildren(graph, instanceId, componentId, mode = "deep") {
1348
- const instance = graph.nodes.get(instanceId);
1349
- const component = graph.nodes.get(componentId);
1350
- if (!instance || !component || instance.type !== "INSTANCE") return;
1351
- cloneChildrenWithMapping(graph, componentId, instanceId, mode);
1352
- }
1353
- function swapInstanceComponent(graph, instanceId, componentId) {
1354
- const instance = graph.nodes.get(instanceId);
1355
- const component = graph.nodes.get(componentId);
1356
- if (!instance || component?.type !== "COMPONENT" || instance.type !== "INSTANCE") return;
1357
- const previousComponent = instance.componentId ? graph.nodes.get(instance.componentId) : void 0;
1358
- const updates = { componentId };
1359
- for (const key of INSTANCE_SYNC_PROPS) {
1360
- if (hasInstanceOverride$1(instance.instanceOverrides, instance.id, instance.id, key)) continue;
1361
- copyProp(updates, component, key);
1362
- }
1363
- if (!previousComponent || instance.name === previousComponent.name) updates.name = component.name;
1364
- const childIds = Array.from(instance.childIds);
1365
- for (const childId of childIds) graph.deleteNode(childId);
1366
- graph.updateNode(instanceId, updates);
1367
- cloneChildrenWithMapping(graph, componentId, instanceId);
1368
- }
1369
- const syncingComponentsByGraph = /* @__PURE__ */ new WeakMap();
1370
- function syncInstances(graph, componentId) {
1371
- const component = graph.nodes.get(componentId);
1372
- if (component?.type !== "COMPONENT") return;
1373
- let syncing = syncingComponentsByGraph.get(graph);
1374
- if (!syncing) {
1375
- syncing = /* @__PURE__ */ new Set();
1376
- syncingComponentsByGraph.set(graph, syncing);
1377
- }
1378
- if (syncing.has(componentId)) return;
1379
- syncing.add(componentId);
1380
- try {
1381
- for (const instance of getInstances(graph, componentId)) {
1382
- for (const key of INSTANCE_SYNC_PROPS) {
1383
- if (hasInstanceOverride$1(instance.instanceOverrides, instance.id, instance.id, key)) continue;
1384
- copyProp(instance, component, key);
1385
- }
1386
- syncChildren(graph, component.id, instance.id, instance.instanceOverrides);
1387
- }
1388
- } finally {
1389
- syncing.delete(componentId);
1390
- }
1391
1403
  }
1392
- function detachInstance(graph, instanceId) {
1393
- const node = graph.nodes.get(instanceId);
1394
- if (node?.type !== "INSTANCE") return;
1395
- if (node.componentId) graph.instanceIndex.get(node.componentId)?.delete(instanceId);
1396
- node.type = "FRAME";
1397
- node.componentId = null;
1398
- clearInstanceOverrides(node.instanceOverrides);
1399
- }
1400
- function getMainComponent(graph, instanceId) {
1401
- const node = graph.nodes.get(instanceId);
1402
- if (!node?.componentId) return void 0;
1403
- return graph.nodes.get(node.componentId);
1404
- }
1405
- function getInstances(graph, componentId) {
1406
- const ids = graph.instanceIndex.get(componentId);
1407
- if (!ids) return [];
1408
- const instances = [];
1409
- for (const id of ids) {
1410
- const node = graph.nodes.get(id);
1411
- if (node) instances.push(node);
1404
+ function resolveTargetSpace(options) {
1405
+ return options?.colorSpace ?? options?.documentColorSpace ?? DEFAULT_COLOR_SPACE;
1406
+ }
1407
+ function formatCSSForTarget(color, targetSpace) {
1408
+ if (targetSpace === "display-p3") {
1409
+ const p3 = toP3({
1410
+ mode: "rgb",
1411
+ r: color.r,
1412
+ g: color.g,
1413
+ b: color.b,
1414
+ alpha: color.a
1415
+ });
1416
+ return formatCss({
1417
+ mode: "p3",
1418
+ r: p3.r,
1419
+ g: p3.g,
1420
+ b: p3.b,
1421
+ alpha: p3.alpha ?? color.a
1422
+ });
1412
1423
  }
1413
- return instances;
1414
- }
1415
- /** Nearest INSTANCE at or above `nodeId` — self, parent, grandparent, etc. */
1416
- function findInstanceAncestor(graph, nodeId) {
1417
- let current = graph.nodes.get(nodeId);
1418
- while (current) {
1419
- if (current.type === "INSTANCE") return current;
1420
- current = current.parentId ? graph.nodes.get(current.parentId) : void 0;
1424
+ return formatRgb({
1425
+ mode: "rgb",
1426
+ r: color.r,
1427
+ g: color.g,
1428
+ b: color.b,
1429
+ alpha: color.a
1430
+ });
1431
+ }
1432
+ function resolveOkHCLForPreview(color, options) {
1433
+ const oklch = normalizeOkLCH(color);
1434
+ const targetSpace = resolveTargetSpace(options);
1435
+ if (targetSpace === "display-p3") {
1436
+ const clipped = !isDisplayableP3(oklch);
1437
+ const p3 = toP3(toDisplayableP3(oklch));
1438
+ return {
1439
+ color: normalizeColor({
1440
+ r: p3.r,
1441
+ g: p3.g,
1442
+ b: p3.b,
1443
+ a: p3.alpha ?? oklch.alpha
1444
+ }),
1445
+ cssColor: formatCss({
1446
+ mode: "p3",
1447
+ r: p3.r,
1448
+ g: p3.g,
1449
+ b: p3.b,
1450
+ alpha: p3.alpha ?? oklch.alpha
1451
+ }),
1452
+ sourceSpace: "oklch",
1453
+ targetSpace,
1454
+ clipped
1455
+ };
1421
1456
  }
1457
+ const clipped = !isDisplayableRGB(oklch);
1458
+ const rgb = toRGB$1(toDisplayableRGB(oklch));
1459
+ const resolved = normalizeColor({
1460
+ r: rgb.r,
1461
+ g: rgb.g,
1462
+ b: rgb.b,
1463
+ a: rgb.alpha ?? oklch.alpha
1464
+ });
1465
+ return {
1466
+ color: resolved,
1467
+ cssColor: formatRgb({
1468
+ mode: "rgb",
1469
+ r: resolved.r,
1470
+ g: resolved.g,
1471
+ b: resolved.b,
1472
+ alpha: resolved.a
1473
+ }),
1474
+ sourceSpace: "oklch",
1475
+ targetSpace,
1476
+ clipped
1477
+ };
1422
1478
  }
1423
1479
  /**
1424
- * True when a node field is protected from instance synchronization.
1480
+ * A CSS color in any space, mapped into sRGB the way CSS maps out-of-gamut colors: by reducing
1481
+ * chroma in OKLCH, so a Display P3 red becomes the nearest sRGB red, not a clipped one. A missing
1482
+ * (`none`) component reads as zero. Null when `input` is not a color.
1425
1483
  */
1426
- function hasInstanceOverride(graph, nodeId, field) {
1427
- const instance = findInstanceAncestor(graph, nodeId);
1428
- if (!instance) return false;
1429
- return hasInstanceOverride$1(instance.instanceOverrides, instance.id, nodeId, field);
1430
- }
1431
- function recordInstanceOverrideValue(graph, nodeId, field, value) {
1432
- const instance = findInstanceAncestor(graph, nodeId);
1433
- if (!instance) return;
1434
- setInstanceOverride(instance.instanceOverrides, instance.id, nodeId, field, value);
1435
- graph.updateNode(instance.id, { instanceOverrides: instance.instanceOverrides });
1436
- }
1437
- function recordInstanceOverride(graph, nodeId, fields) {
1438
- const instance = findInstanceAncestor(graph, nodeId);
1439
- if (!instance) return;
1440
- const relevant = [...fields].filter((field) => INSTANCE_SYNC_FIELDS.includes(field));
1441
- if (relevant.length === 0) return;
1442
- for (const field of relevant) setInstanceOverride(instance.instanceOverrides, instance.id, nodeId, field);
1443
- graph.updateNode(instance.id, { instanceOverrides: instance.instanceOverrides });
1484
+ function parseDisplayableColor(input) {
1485
+ const parsed = parse(input);
1486
+ if (!parsed) return null;
1487
+ const rgb = isDisplayableRGB(parsed) ? toRGB$1(parsed) : toDisplayableRGB(parsed);
1488
+ return normalizeColor({
1489
+ r: rgb.r,
1490
+ g: rgb.g,
1491
+ b: rgb.b,
1492
+ a: parsed.alpha
1493
+ });
1494
+ }
1495
+ function resolveRGBAForPreview(color, options) {
1496
+ const documentColorSpace = options?.documentColorSpace ?? DEFAULT_COLOR_SPACE;
1497
+ const targetSpace = options?.colorSpace ?? documentColorSpace;
1498
+ const resolved = convertComponents(normalizeColor(color), documentColorSpace, targetSpace);
1499
+ return {
1500
+ color: resolved,
1501
+ cssColor: formatCSSForTarget(resolved, targetSpace),
1502
+ sourceSpace: "srgb",
1503
+ targetSpace,
1504
+ clipped: targetSpace !== documentColorSpace && isOutsideGamut(resolved, targetSpace)
1505
+ };
1506
+ }
1507
+ function resolveNodeFillColor(fill, fillIndex, node, options) {
1508
+ const okhcl = getFillOkHCL(node, fillIndex)?.color;
1509
+ if (okhcl) return resolveOkHCLForPreview(okhcl, options);
1510
+ return resolveRGBAForPreview(fill.color, options);
1511
+ }
1512
+ function resolveNodeStrokeColor(stroke, strokeIndex, node, options) {
1513
+ const okhcl = getStrokeOkHCL(node, strokeIndex)?.color;
1514
+ if (okhcl) return resolveOkHCLForPreview(okhcl, options);
1515
+ return resolveRGBAForPreview(stroke.color, options);
1516
+ }
1517
+ function colorToDisplayCSS(color, options) {
1518
+ return resolveRGBAForPreview(color, options).cssColor;
1519
+ }
1520
+ function getDefaultRenderColorSpace() {
1521
+ return DEFAULT_COLOR_SPACE;
1444
1522
  }
1445
1523
  //#endregion
1446
- //#region src/components/properties.ts
1447
- function componentPropertyOwners(graph, instance) {
1448
- if (instance.type !== "INSTANCE" || !instance.componentId) return [];
1449
- const component = graph.getNode(instance.componentId);
1450
- if (!component) return [];
1451
- const parent = component.parentId ? graph.getNode(component.parentId) : null;
1452
- return parent?.type === "COMPONENT_SET" ? [parent, component] : [component];
1453
- }
1454
- function componentPropertyDefinitions(graph, instance) {
1455
- const definitions = /* @__PURE__ */ new Map();
1456
- for (const owner of componentPropertyOwners(graph, instance)) for (const definition of owner.componentPropertyDefinitions) if (!definitions.has(definition.id)) definitions.set(definition.id, definition);
1457
- return [...definitions.values()];
1458
- }
1459
- function resolveComponentPropertyValue(graph, value) {
1460
- const direct = graph.getNode(value);
1461
- if (direct?.type === "COMPONENT") return direct;
1462
- if (direct?.type === "COMPONENT_SET") {
1463
- const componentId = direct.childIds.find((id) => graph.getNode(id)?.type === "COMPONENT");
1464
- return componentId ? graph.getNode(componentId) ?? null : null;
1465
- }
1466
- for (const node of graph.getAllNodes()) if (node.type === "COMPONENT" && (node.componentKey === value || node.sourceLibraryKey === value || node.source.id === value)) return node;
1467
- return null;
1524
+ //#region src/color/index.ts
1525
+ const toRGB = converter("rgb");
1526
+ /** A CSS color, or null when `input` is not one. */
1527
+ function tryParseColor(input) {
1528
+ const parsed = parse(input);
1529
+ if (!parsed) return null;
1530
+ const rgb = toRGB(parsed);
1531
+ return {
1532
+ r: rgb.r,
1533
+ g: rgb.g,
1534
+ b: rgb.b,
1535
+ a: parsed.alpha ?? 1
1536
+ };
1468
1537
  }
1469
- function findComponentPropertyTarget(graph, instance, propertyId) {
1470
- return findComponentPropertyTargets(graph, instance, propertyId)[0] ?? null;
1471
- }
1472
- function findComponentPropertyTargets(graph, instance, propertyId) {
1473
- if (instance.type !== "INSTANCE" || !instance.componentId) return [];
1474
- const component = graph.getNode(instance.componentId);
1475
- if (!component) return [];
1476
- const targets = [];
1477
- const visit = (sourceParent, instanceParent) => {
1478
- for (const [index, childId] of sourceParent.childIds.entries()) {
1479
- const source = graph.getNode(childId);
1480
- const targetId = instanceParent.childIds[index];
1481
- const target = targetId ? graph.getNode(targetId) : void 0;
1482
- if (!source || !target) continue;
1483
- const reference = source.componentPropertyReferences.find((candidate) => candidate.propertyId === propertyId);
1484
- if (reference) targets.push({
1485
- node: target,
1486
- field: reference.field,
1487
- source
1488
- });
1489
- visit(source, target);
1490
- }
1538
+ /** A CSS color, or black when `input` is not one. */
1539
+ function parseColor(input) {
1540
+ return tryParseColor(input) ?? { ...BLACK };
1541
+ }
1542
+ function colorToHex(color) {
1543
+ return formatHex({
1544
+ mode: "rgb",
1545
+ r: color.r,
1546
+ g: color.g,
1547
+ b: color.b
1548
+ }).toUpperCase();
1549
+ }
1550
+ function colorToHex8(color, alpha) {
1551
+ const a = alpha ?? color.a;
1552
+ if (a >= 1) return colorToHex(color);
1553
+ return formatHex8({
1554
+ mode: "rgb",
1555
+ r: color.r,
1556
+ g: color.g,
1557
+ b: color.b,
1558
+ alpha: a
1559
+ }).toUpperCase();
1560
+ }
1561
+ function colorToHexRaw(color) {
1562
+ return colorToHex(color).slice(1);
1563
+ }
1564
+ function colorToRgba255(color) {
1565
+ return {
1566
+ r: Math.round(color.r * 255),
1567
+ g: Math.round(color.g * 255),
1568
+ b: Math.round(color.b * 255),
1569
+ a: color.a
1491
1570
  };
1492
- visit(component, instance);
1493
- return targets;
1494
- }
1495
- function applyTextProperty(graph, owner, targets, value) {
1496
- for (const item of targets) {
1497
- if (item.field !== "TEXT" || item.node.type !== "TEXT") continue;
1498
- graph.updateNode(item.node.id, { text: value });
1499
- if (findInstanceAncestor(graph, item.node.id)) setInstanceOverride(owner.instanceOverrides, owner.id, item.node.id, "text", value);
1500
- }
1501
1571
  }
1502
- function applyBooleanProperty(graph, owner, targets, value) {
1503
- for (const item of targets) {
1504
- if (item.field !== "VISIBLE") continue;
1505
- const instance = findInstanceAncestor(graph, item.node.id);
1506
- graph.updateNode(item.node.id, { visible: value === "true" });
1507
- if (instance) setInstanceOverride(owner.instanceOverrides, owner.id, item.node.id, "visible", value === "true");
1508
- }
1572
+ function colorToCSS(color) {
1573
+ return formatRgb({
1574
+ mode: "rgb",
1575
+ r: color.r,
1576
+ g: color.g,
1577
+ b: color.b,
1578
+ alpha: color.a
1579
+ });
1509
1580
  }
1510
- function applyInstanceSwapProperty(graph, owner, targets, target) {
1511
- for (const item of targets) {
1512
- if (item.field !== "INSTANCE_SWAP" || item.node.type !== "INSTANCE") continue;
1513
- graph.swapInstanceComponent(item.node.id, target.id);
1514
- setInstanceOverride(owner.instanceOverrides, owner.id, item.node.id, "name", target.name);
1515
- setInstanceOverride(owner.instanceOverrides, owner.id, item.node.id, "componentId", target.id);
1516
- setInstanceOverride(owner.instanceOverrides, owner.id, item.node.id, "sourceComponentId", item.source.id);
1517
- graph.updateNode(owner.id, { instanceOverrides: owner.instanceOverrides });
1518
- }
1581
+ function colorToCSSCompact(color) {
1582
+ const { r, g, b } = colorToRgba255(color);
1583
+ const a = Number(color.a.toFixed(3));
1584
+ if (a >= 1) return `rgb(${r},${g},${b})`;
1585
+ return `rgba(${r},${g},${b},${a})`;
1519
1586
  }
1520
- function applyComponentPropertyValue(graph, instanceId, definition, value) {
1521
- const instance = graph.getNode(instanceId);
1522
- if (instance?.type !== "INSTANCE") return null;
1523
- if (definition.type === "VARIANT") return null;
1524
- const targets = findComponentPropertyTargets(graph, instance, definition.id);
1525
- const target = definition.type === "INSTANCE_SWAP" ? resolveComponentPropertyValue(graph, value) : null;
1526
- if (definition.type === "INSTANCE_SWAP" && !target) return null;
1527
- if (definition.type === "TEXT") applyTextProperty(graph, instance, targets, value);
1528
- else if (definition.type === "BOOLEAN") applyBooleanProperty(graph, instance, targets, value);
1529
- else if (target) applyInstanceSwapProperty(graph, instance, targets, target);
1530
- graph.updateNode(instance.id, { componentPropertyAssignments: {
1531
- ...instance.componentPropertyAssignments,
1532
- [definition.id]: definition.type === "INSTANCE_SWAP" && target ? target.id : value
1533
- } });
1534
- return definition.type === "INSTANCE_SWAP" ? target : instance;
1535
- }
1536
- function componentSubtree(graph, componentId) {
1537
- const component = graph.getNode(componentId);
1538
- if (!component) return [];
1539
- const nodes = [component];
1540
- const visit = (node) => {
1541
- for (const child of graph.getChildren(node.id)) {
1542
- nodes.push(child);
1543
- visit(child);
1544
- }
1587
+ function rgba255ToColor(r, g, b, a = 1) {
1588
+ return {
1589
+ r: r / 255,
1590
+ g: g / 255,
1591
+ b: b / 255,
1592
+ a
1545
1593
  };
1546
- visit(component);
1547
- return nodes;
1548
- }
1549
- function componentInstances(graph, componentId) {
1550
- return [...graph.getAllNodes()].filter((node) => node.type === "INSTANCE" && node.componentId === componentId);
1551
- }
1552
- function removePropertyFromNode(graph, node, propertyId) {
1553
- if (node.componentPropertyReferences.some((reference) => reference.propertyId === propertyId)) graph.updateNode(node.id, { componentPropertyReferences: node.componentPropertyReferences.filter((reference) => reference.propertyId !== propertyId) });
1554
- if (node.type === "INSTANCE" && propertyId in node.componentPropertyAssignments) graph.updateNode(node.id, { componentPropertyAssignments: Object.fromEntries(Object.entries(node.componentPropertyAssignments).filter(([id]) => id !== propertyId)) });
1555
- }
1556
- function removeComponentProperty(graph, ownerId, propertyId) {
1557
- const owner = graph.getNode(ownerId);
1558
- if (!owner || owner.type !== "COMPONENT" && owner.type !== "COMPONENT_SET") return false;
1559
- graph.updateNode(owner.id, { componentPropertyDefinitions: owner.componentPropertyDefinitions.filter((definition) => definition.id !== propertyId) });
1560
- const nodes = [
1561
- ...componentSubtree(graph, owner.id),
1562
- ...componentInstances(graph, owner.id),
1563
- ...owner.type === "COMPONENT_SET" ? owner.childIds.flatMap((id) => [...componentSubtree(graph, id), ...componentInstances(graph, id)]) : []
1564
- ];
1565
- for (const node of nodes) removePropertyFromNode(graph, node, propertyId);
1566
- return true;
1594
+ }
1595
+ function colorToFill(color) {
1596
+ const rgba = typeof color === "string" ? parseColor(color) : color;
1597
+ return {
1598
+ type: "SOLID",
1599
+ color: {
1600
+ r: rgba.r,
1601
+ g: rgba.g,
1602
+ b: rgba.b,
1603
+ a: rgba.a
1604
+ },
1605
+ opacity: rgba.a,
1606
+ visible: true
1607
+ };
1608
+ }
1609
+ const euclideanRGB255 = differenceEuclidean("rgb");
1610
+ function colorDistance(c1, c2) {
1611
+ return euclideanRGB255({
1612
+ mode: "rgb",
1613
+ r: c1.r,
1614
+ g: c1.g,
1615
+ b: c1.b
1616
+ }, {
1617
+ mode: "rgb",
1618
+ r: c2.r,
1619
+ g: c2.g,
1620
+ b: c2.b
1621
+ }) * 255;
1567
1622
  }
1568
1623
  //#endregion
1569
- export { BLACK, CONTAINER_TYPES, DEFAULT_FONT_FAMILY, DEFAULT_STROKE_MITER_LIMIT, INSTANCE_SYNC_FIELDS, INSTANCE_SYNC_PROPS, INSTANCE_SYNC_TEXT_PROPS, TRANSPARENT, applyComponentPropertyValue, clearInstanceOverrides, clipBoundsToPolygon, clipPolygon, cloneInstanceOverrideState, cloneNodeProps, cloneVectorNetwork, componentPropertyDefinitions, componentPropertyOwners, computeAbsoluteBounds, computeBounds, computeDescendantVisualBounds, computeVisualBounds, copyDerivedGlyphs, copyEffect, copyEffects, copyFill, copyFills, copyGeometryPaths, copyInstanceComponentProps, copyLayoutGrids, copyStroke, copyStrokes, copyStyleRun, copyStyleRuns, createDefaultNode, createDefaultSourceMetadata, createInstance, createInstanceOverrideState, degToRad, deleteInstanceOverride, deserializeInstanceOverrideState, detachInstance, effectOverflow, findComponentPropertyTarget, findComponentPropertyTargets, findInstanceAncestor, forEachInstanceOverride, geometryBlobBounds, geometryCommandCoordCount, getInstanceOverride, getInstances, getMainComponent, hasInstanceOverride, hasSameCopySource, intersectVisualBounds, markCopySource, mergeVectorNetworks, nodeVisualBounds, normalizeVectorNetwork, polygonVertices, populateInstanceChildren, radToDeg, recordInstanceOverride, recordInstanceOverrideValue, removeComponentProperty, resolveComponentPropertyValue, rotatePoint, rotatedBBox, rotatedCorners, scaleGeometryPaths, serializeInstanceOverrideState, setInstanceOverride, strokeOverflow, swapInstanceComponent, syncInstances, transformGeometryBlob, transformGeometryPaths, transformVectorNetwork, unionVisualBounds, validateVectorNetwork, vectorNetworksEqual };
1624
+ export { CONTAINER_TYPES, FITTED_CONTAINER_TYPES, clearInstanceOverrides, clearNodeFillOkHCL, clearNodeStrokeOkHCL, clipBoundsToPolygon, clipPolygon, cloneInstanceOverrideState, cloneNodeProps, cloneVectorNetwork, colorDistance, colorToCSS, colorToCSSCompact, colorToDisplayCSS, colorToFill, colorToHex, colorToHex8, colorToHexRaw, colorToRgba255, computeAbsoluteBounds, computeBounds, computeDescendantVisualBounds, computeVisualBounds, copyDerivedGlyphs, copyEffect, copyEffects, copyFill, copyFills, copyGeometryPaths, copyLayoutGrids, copyStroke, copyStrokes, copyStyleRun, copyStyleRuns, createDefaultNode, createDefaultSourceMetadata, createInstanceOverrideState, defaultStrokeAlign, degToRad, deleteInstanceOverride, deserializeInstanceOverrideState, effectOverflow, forEachInstanceOverride, geometryBlobBounds, geometryCommandCoordCount, getDefaultRenderColorSpace, getFillOkHCL, getInstanceOverride, getNodeOkHCLPayloads, getStrokeOkHCL, hasInstanceOverride, hasSameCopySource, intersectVisualBounds, markCopySource, mergeVectorNetworks, newStrokeGeometry, nodeVisualBounds, normalizeColor, normalizeVectorNetwork, okhclToRGBA, parseColor, parseDisplayableColor, parseOkHCLPayload, polygonVertices, radToDeg, remapInstanceOverrideState, resolveNodeFillColor, resolveNodeStrokeColor, resolveOkHCLForPreview, resolveRGBAForPreview, rgba255ToColor, rgbaToOkHCL, rotatePoint, rotatedBBox, rotatedCorners, scaleGeometryPaths, serializeInstanceOverrideState, serializeOkHCLPayload, setInstanceOverride, setNodeFillOkHCL, setNodeStrokeOkHCL, strokeOverflow, transformGeometryBlob, transformGeometryPaths, transformVectorNetwork, tryParseColor, unionVisualBounds, validateVectorNetwork, vectorNetworksEqual };
1570
1625
 
1571
- //# sourceMappingURL=properties.js.map
1626
+ //# sourceMappingURL=index.js.map