@open-pencil/scene-graph 0.17.0-beta.2 → 0.17.0-beta.4

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 (244) hide show
  1. package/dist/asset-keys.d.ts +11 -1
  2. package/dist/asset-keys.d.ts.map +1 -1
  3. package/dist/asset-keys.js +16 -1
  4. package/dist/asset-keys.js.map +1 -1
  5. package/dist/checkpoint.d.ts +3 -3
  6. package/dist/checkpoint.d.ts.map +1 -1
  7. package/dist/checkpoint.js +53 -23
  8. package/dist/checkpoint.js.map +1 -1
  9. package/dist/components/index.d.ts +2 -2
  10. package/dist/components/index.js +2 -2
  11. package/dist/components/properties.d.ts +6 -1
  12. package/dist/components/properties.d.ts.map +1 -1
  13. package/dist/components/properties.js +9 -1
  14. package/dist/components/properties.js.map +1 -1
  15. package/dist/constants.d.ts +6 -1
  16. package/dist/constants.d.ts.map +1 -1
  17. package/dist/constants.js +17 -1
  18. package/dist/constants.js.map +1 -1
  19. package/dist/constraints.d.ts +25 -0
  20. package/dist/constraints.d.ts.map +1 -0
  21. package/dist/constraints.js +51 -0
  22. package/dist/constraints.js.map +1 -0
  23. package/dist/coordinate.d.ts +64 -1
  24. package/dist/coordinate.d.ts.map +1 -1
  25. package/dist/coordinate.js +217 -1
  26. package/dist/coordinate.js.map +1 -1
  27. package/dist/copy.d.ts.map +1 -1
  28. package/dist/copy.js +8 -1
  29. package/dist/copy.js.map +1 -1
  30. package/dist/css/index.d.ts +3 -2
  31. package/dist/css/index.js +3 -2
  32. package/dist/css/text.d.ts +28 -1
  33. package/dist/css/text.d.ts.map +1 -1
  34. package/dist/css/text.js +84 -17
  35. package/dist/css/text.js.map +1 -1
  36. package/dist/css/transform.d.ts +34 -0
  37. package/dist/css/transform.d.ts.map +1 -0
  38. package/dist/css/transform.js +320 -0
  39. package/dist/css/transform.js.map +1 -0
  40. package/dist/css/values.d.ts.map +1 -1
  41. package/dist/css/values.js +11 -1
  42. package/dist/css/values.js.map +1 -1
  43. package/dist/figjam/palette.d.ts +1 -1
  44. package/dist/figjam/palette.js +1 -1
  45. package/dist/figjam/palette.js.map +1 -1
  46. package/dist/geometry.d.ts +8 -1
  47. package/dist/geometry.d.ts.map +1 -1
  48. package/dist/geometry.js +19 -8
  49. package/dist/geometry.js.map +1 -1
  50. package/dist/graph.d.ts +48 -12
  51. package/dist/graph.d.ts.map +1 -1
  52. package/dist/graph.js +110 -24
  53. package/dist/graph.js.map +1 -1
  54. package/dist/group-bounds.d.ts +14 -4
  55. package/dist/group-bounds.d.ts.map +1 -1
  56. package/dist/group-bounds.js +76 -11
  57. package/dist/group-bounds.js.map +1 -1
  58. package/dist/hit-test.d.ts +5 -0
  59. package/dist/hit-test.d.ts.map +1 -1
  60. package/dist/hit-test.js +18 -12
  61. package/dist/hit-test.js.map +1 -1
  62. package/dist/images.d.ts +27 -3
  63. package/dist/images.d.ts.map +1 -1
  64. package/dist/images.js +57 -3
  65. package/dist/images.js.map +1 -1
  66. package/dist/index.d.ts +2 -2
  67. package/dist/instances/index.d.ts.map +1 -1
  68. package/dist/instances/index.js +3 -0
  69. package/dist/instances/index.js.map +1 -1
  70. package/dist/instances/placement.js +55 -12
  71. package/dist/instances/placement.js.map +1 -1
  72. package/dist/instances/swap.js +3 -0
  73. package/dist/instances/swap.js.map +1 -1
  74. package/dist/instances/sync.js +34 -13
  75. package/dist/instances/sync.js.map +1 -1
  76. package/dist/node-defaults.d.ts.map +1 -1
  77. package/dist/node-defaults.js +1 -0
  78. package/dist/node-defaults.js.map +1 -1
  79. package/dist/order-keys.d.ts +3 -1
  80. package/dist/order-keys.d.ts.map +1 -1
  81. package/dist/order-keys.js +6 -1
  82. package/dist/order-keys.js.map +1 -1
  83. package/dist/plugin-data/fields.d.ts +2 -0
  84. package/dist/plugin-data/fields.d.ts.map +1 -1
  85. package/dist/plugin-data/fields.js +2 -0
  86. package/dist/plugin-data/fields.js.map +1 -1
  87. package/dist/resize.d.ts +22 -11
  88. package/dist/resize.d.ts.map +1 -1
  89. package/dist/resize.js +227 -93
  90. package/dist/resize.js.map +1 -1
  91. package/dist/scaling/index.d.ts +3 -2
  92. package/dist/scaling/index.js +3 -2
  93. package/dist/scaling/node.d.ts.map +1 -1
  94. package/dist/scaling/node.js +5 -1
  95. package/dist/scaling/node.js.map +1 -1
  96. package/dist/scaling/snapshot.d.ts +25 -0
  97. package/dist/scaling/snapshot.d.ts.map +1 -0
  98. package/dist/scaling/snapshot.js +39 -0
  99. package/dist/scaling/snapshot.js.map +1 -0
  100. package/dist/scaling/tree.d.ts +24 -2
  101. package/dist/scaling/tree.d.ts.map +1 -1
  102. package/dist/scaling/tree.js +37 -14
  103. package/dist/scaling/tree.js.map +1 -1
  104. package/dist/shaders/model.d.ts.map +1 -1
  105. package/dist/shaders/model.js +2 -1
  106. package/dist/shaders/model.js.map +1 -1
  107. package/dist/shared-styles.d.ts +3 -1
  108. package/dist/shared-styles.d.ts.map +1 -1
  109. package/dist/shared-styles.js +7 -1
  110. package/dist/shared-styles.js.map +1 -1
  111. package/dist/slots/authoring.d.ts +3 -2
  112. package/dist/slots/authoring.d.ts.map +1 -1
  113. package/dist/slots/authoring.js +5 -3
  114. package/dist/slots/authoring.js.map +1 -1
  115. package/dist/slots/content.d.ts.map +1 -1
  116. package/dist/slots/content.js +4 -1
  117. package/dist/slots/content.js.map +1 -1
  118. package/dist/text/direction.d.ts +3 -1
  119. package/dist/text/direction.d.ts.map +1 -1
  120. package/dist/text/direction.js +5 -1
  121. package/dist/text/direction.js.map +1 -1
  122. package/dist/transfer/apply.d.ts.map +1 -1
  123. package/dist/transfer/apply.js +1 -6
  124. package/dist/transfer/apply.js.map +1 -1
  125. package/dist/transfer/copied.d.ts +35 -3
  126. package/dist/transfer/copied.d.ts.map +1 -1
  127. package/dist/transfer/copied.js +44 -13
  128. package/dist/transfer/copied.js.map +1 -1
  129. package/dist/transfer/dependencies.d.ts +38 -0
  130. package/dist/transfer/dependencies.d.ts.map +1 -0
  131. package/dist/transfer/dependencies.js +100 -0
  132. package/dist/transfer/dependencies.js.map +1 -0
  133. package/dist/transfer/history.js +0 -1
  134. package/dist/transfer/history.js.map +1 -1
  135. package/dist/transfer/index.d.ts +5 -3
  136. package/dist/transfer/index.js +5 -3
  137. package/dist/transfer/nodes.d.ts.map +1 -1
  138. package/dist/transfer/nodes.js +7 -14
  139. package/dist/transfer/nodes.js.map +1 -1
  140. package/dist/transfer/plan.d.ts +0 -1
  141. package/dist/transfer/plan.js +3 -5
  142. package/dist/transfer/plan.js.map +1 -1
  143. package/dist/transfer/remove.js +5 -2
  144. package/dist/transfer/remove.js.map +1 -1
  145. package/dist/transfer/resources.d.ts +21 -0
  146. package/dist/transfer/resources.d.ts.map +1 -0
  147. package/dist/transfer/resources.js +38 -0
  148. package/dist/transfer/resources.js.map +1 -0
  149. package/dist/transfer/variables.d.ts +8 -1
  150. package/dist/transfer/variables.d.ts.map +1 -1
  151. package/dist/transfer/variables.js +24 -1
  152. package/dist/transfer/variables.js.map +1 -1
  153. package/dist/types.d.ts +47 -2
  154. package/dist/types.d.ts.map +1 -1
  155. package/dist/types.js.map +1 -1
  156. package/dist/undo.d.ts +28 -3
  157. package/dist/undo.d.ts.map +1 -1
  158. package/dist/undo.js +24 -7
  159. package/dist/undo.js.map +1 -1
  160. package/dist/variables/bindings.d.ts +17 -14
  161. package/dist/variables/bindings.d.ts.map +1 -1
  162. package/dist/variables/bindings.js +30 -72
  163. package/dist/variables/bindings.js.map +1 -1
  164. package/dist/variables/fields.d.ts +1 -1
  165. package/dist/variables/fields.js +1 -1
  166. package/dist/variables/fields.js.map +1 -1
  167. package/dist/variables/formula/check.d.ts +1 -1
  168. package/dist/variables/formula/index.d.ts +2 -2
  169. package/dist/variables/formula/index.js +1 -1
  170. package/dist/variables/formula/index.js.map +1 -1
  171. package/dist/variables/formula/print.d.ts +1 -1
  172. package/dist/variables/formula/signatures.js +1 -1
  173. package/dist/variables/index.d.ts +6 -6
  174. package/dist/variables/index.d.ts.map +1 -1
  175. package/dist/variables/index.js +40 -24
  176. package/dist/variables/index.js.map +1 -1
  177. package/dist/variables/paints.d.ts +57 -0
  178. package/dist/variables/paints.d.ts.map +1 -0
  179. package/dist/variables/paints.js +231 -0
  180. package/dist/variables/paints.js.map +1 -0
  181. package/dist/variables/resolution.d.ts +14 -11
  182. package/dist/variables/resolution.d.ts.map +1 -1
  183. package/dist/variables/resolution.js +36 -17
  184. package/dist/variables/resolution.js.map +1 -1
  185. package/dist/variables/subtree.js +17 -0
  186. package/dist/variables/subtree.js.map +1 -0
  187. package/dist/vector-network.d.ts.map +1 -1
  188. package/dist/vector-network.js +2 -8
  189. package/dist/vector-network.js.map +1 -1
  190. package/package.json +8 -1
  191. package/src/asset-keys.ts +20 -0
  192. package/src/checkpoint.ts +87 -32
  193. package/src/components/properties.ts +9 -0
  194. package/src/constants.ts +17 -0
  195. package/src/constraints.ts +60 -0
  196. package/src/coordinate.ts +220 -0
  197. package/src/copy.ts +9 -4
  198. package/src/css/index.ts +17 -1
  199. package/src/css/text.ts +85 -17
  200. package/src/css/transform.ts +266 -0
  201. package/src/css/values.ts +8 -0
  202. package/src/figjam/palette.ts +1 -1
  203. package/src/geometry.ts +20 -9
  204. package/src/graph.ts +128 -42
  205. package/src/group-bounds.ts +84 -17
  206. package/src/hit-test.ts +30 -14
  207. package/src/images.ts +71 -3
  208. package/src/instances/index.ts +4 -0
  209. package/src/instances/placement.ts +63 -10
  210. package/src/instances/swap.ts +5 -0
  211. package/src/instances/sync.ts +48 -21
  212. package/src/node-defaults.ts +1 -0
  213. package/src/order-keys.ts +6 -0
  214. package/src/plugin-data/fields.ts +6 -0
  215. package/src/resize.ts +267 -119
  216. package/src/scaling/index.ts +9 -1
  217. package/src/scaling/node.ts +9 -1
  218. package/src/scaling/snapshot.ts +51 -0
  219. package/src/scaling/tree.ts +63 -19
  220. package/src/shaders/model.ts +2 -3
  221. package/src/shared-styles.ts +8 -0
  222. package/src/slots/authoring.ts +5 -3
  223. package/src/slots/content.ts +4 -1
  224. package/src/text/direction.ts +5 -0
  225. package/src/transfer/apply.ts +1 -13
  226. package/src/transfer/copied.ts +83 -15
  227. package/src/transfer/dependencies.ts +126 -0
  228. package/src/transfer/history.ts +0 -6
  229. package/src/transfer/index.ts +20 -2
  230. package/src/transfer/nodes.ts +10 -26
  231. package/src/transfer/plan.ts +3 -11
  232. package/src/transfer/remove.ts +5 -2
  233. package/src/transfer/resources.ts +54 -0
  234. package/src/transfer/variables.ts +34 -0
  235. package/src/types.ts +55 -1
  236. package/src/undo.ts +48 -10
  237. package/src/variables/bindings.ts +44 -91
  238. package/src/variables/fields.ts +1 -1
  239. package/src/variables/formula/index.ts +3 -1
  240. package/src/variables/index.ts +56 -38
  241. package/src/variables/paints.ts +296 -0
  242. package/src/variables/resolution.ts +39 -28
  243. package/src/variables/subtree.ts +15 -0
  244. package/src/vector-network.ts +4 -2
@@ -0,0 +1,51 @@
1
+ import { FITTED_CONTAINER_TYPES } from "./node-defaults.js";
2
+ //#region src/constraints.ts
3
+ /** Containers whose children keep their place by their own constraints when they resize. */
4
+ const CONSTRAINT_PARENT_TYPES = /* @__PURE__ */ new Set([
5
+ "FRAME",
6
+ "COMPONENT",
7
+ "COMPONENT_SET",
8
+ "INSTANCE"
9
+ ]);
10
+ /**
11
+ * The frame, component, or instance whose resize moves `node` by its constraints: its parent, or,
12
+ * for a layer in groups and booleans, the frame around the outermost of them, as in Figma (live,
13
+ * #1835). Null when nothing places it by constraints: on a page or in a section, or in an auto
14
+ * layout flow.
15
+ */
16
+ function constraintFrame(graph, node) {
17
+ let layer = node;
18
+ const parent = node.parentId ? graph.closest(node.parentId, (ancestor) => {
19
+ if (!FITTED_CONTAINER_TYPES.has(ancestor.type)) return true;
20
+ layer = ancestor;
21
+ return false;
22
+ }) : void 0;
23
+ if (!parent || !CONSTRAINT_PARENT_TYPES.has(parent.type)) return null;
24
+ if (parent.layoutMode !== "NONE" && layer.layoutPositioning !== "ABSOLUTE") return null;
25
+ return parent;
26
+ }
27
+ /** Whether `node` has constraints the Design panel offers and the canvas shows. */
28
+ function isConstraintEligible(graph, node) {
29
+ return constraintFrame(graph, node) !== null;
30
+ }
31
+ /**
32
+ * The layers whose constraints `node` stands for. A group or boolean has none of its own: it shows
33
+ * and sets those of the layers in it, through nested groups and booleans, as in Figma.
34
+ */
35
+ function constraintLayers(graph, node) {
36
+ if (!FITTED_CONTAINER_TYPES.has(node.type)) return [node];
37
+ return node.childIds.flatMap((id) => {
38
+ const child = graph.getNode(id);
39
+ return child ? constraintLayers(graph, child) : [];
40
+ });
41
+ }
42
+ /** The constraint the layers share on one axis, or null when they differ or there are none. */
43
+ function sharedConstraint(layers, key) {
44
+ const first = layers.at(0)?.[key];
45
+ if (first === void 0) return null;
46
+ return layers.every((layer) => layer[key] === first) ? first : null;
47
+ }
48
+ //#endregion
49
+ export { CONSTRAINT_PARENT_TYPES, constraintFrame, constraintLayers, isConstraintEligible, sharedConstraint };
50
+
51
+ //# sourceMappingURL=constraints.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constraints.js","names":[],"sources":["../src/constraints.ts"],"sourcesContent":["import type { SceneGraph } from './graph'\nimport { FITTED_CONTAINER_TYPES } from './node-defaults'\nimport type { ConstraintType, SceneNode } from './types'\n\ntype ConstraintGraph = Pick<SceneGraph, 'getNode' | 'closest'>\n\n/** Containers whose children keep their place by their own constraints when they resize. */\nexport const CONSTRAINT_PARENT_TYPES: ReadonlySet<SceneNode['type']> = new Set<SceneNode['type']>([\n 'FRAME',\n 'COMPONENT',\n 'COMPONENT_SET',\n 'INSTANCE'\n])\n\n/**\n * The frame, component, or instance whose resize moves `node` by its constraints: its parent, or,\n * for a layer in groups and booleans, the frame around the outermost of them, as in Figma (live,\n * #1835). Null when nothing places it by constraints: on a page or in a section, or in an auto\n * layout flow.\n */\nexport function constraintFrame(graph: ConstraintGraph, node: SceneNode): SceneNode | null {\n let layer = node\n const parent = node.parentId\n ? graph.closest(node.parentId, (ancestor) => {\n if (!FITTED_CONTAINER_TYPES.has(ancestor.type)) return true\n layer = ancestor\n return false\n })\n : undefined\n if (!parent || !CONSTRAINT_PARENT_TYPES.has(parent.type)) return null\n if (parent.layoutMode !== 'NONE' && layer.layoutPositioning !== 'ABSOLUTE') return null\n return parent\n}\n\n/** Whether `node` has constraints the Design panel offers and the canvas shows. */\nexport function isConstraintEligible(graph: ConstraintGraph, node: SceneNode): boolean {\n return constraintFrame(graph, node) !== null\n}\n\n/**\n * The layers whose constraints `node` stands for. A group or boolean has none of its own: it shows\n * and sets those of the layers in it, through nested groups and booleans, as in Figma.\n */\nexport function constraintLayers(graph: ConstraintGraph, node: SceneNode): SceneNode[] {\n if (!FITTED_CONTAINER_TYPES.has(node.type)) return [node]\n return node.childIds.flatMap((id) => {\n const child = graph.getNode(id)\n return child ? constraintLayers(graph, child) : []\n })\n}\n\n/** The constraint the layers share on one axis, or null when they differ or there are none. */\nexport function sharedConstraint(\n layers: readonly SceneNode[],\n key: 'horizontalConstraint' | 'verticalConstraint'\n): ConstraintType | null {\n const first = layers.at(0)?.[key]\n if (first === undefined) return null\n return layers.every((layer) => layer[key] === first) ? first : null\n}\n"],"mappings":";;;AAOA,MAAa,0CAA0D,IAAI,IAAuB;CAChG;CACA;CACA;CACA;AACF,CAAC;;;;;;;AAQD,SAAgB,gBAAgB,OAAwB,MAAmC;CACzF,IAAI,QAAQ;CACZ,MAAM,SAAS,KAAK,WAChB,MAAM,QAAQ,KAAK,WAAW,aAAa;EACzC,IAAI,CAAC,uBAAuB,IAAI,SAAS,IAAI,GAAG,OAAO;EACvD,QAAQ;EACR,OAAO;CACT,CAAC,IACD,KAAA;CACJ,IAAI,CAAC,UAAU,CAAC,wBAAwB,IAAI,OAAO,IAAI,GAAG,OAAO;CACjE,IAAI,OAAO,eAAe,UAAU,MAAM,sBAAsB,YAAY,OAAO;CACnF,OAAO;AACT;;AAGA,SAAgB,qBAAqB,OAAwB,MAA0B;CACrF,OAAO,gBAAgB,OAAO,IAAI,MAAM;AAC1C;;;;;AAMA,SAAgB,iBAAiB,OAAwB,MAA8B;CACrF,IAAI,CAAC,uBAAuB,IAAI,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI;CACxD,OAAO,KAAK,SAAS,SAAS,OAAO;EACnC,MAAM,QAAQ,MAAM,QAAQ,EAAE;EAC9B,OAAO,QAAQ,iBAAiB,OAAO,KAAK,IAAI,CAAC;CACnD,CAAC;AACH;;AAGA,SAAgB,iBACd,QACA,KACuB;CACvB,MAAM,QAAQ,OAAO,GAAG,CAAC,CAAC,GAAG;CAC7B,IAAI,UAAU,KAAA,GAAW,OAAO;CAChC,OAAO,OAAO,OAAO,UAAU,MAAM,SAAS,KAAK,IAAI,QAAQ;AACjE"}
@@ -89,6 +89,69 @@ declare function isTranslationOnly(matrix: Mat3): boolean;
89
89
  * not a group.
90
90
  */
91
91
  declare function getParentToContainerMatrix(node: SceneNode, graph: Pick<SceneGraph, 'getNode'>): Mat3;
92
+ /**
93
+ * A selected layer's place in a multi-selection's canvas bounds, taken when a resize starts so
94
+ * every step re-places the layer from where it began rather than from its previewed state.
95
+ */
96
+ interface SelectionPlacement {
97
+ node: SceneNode;
98
+ center: Vector;
99
+ /** Draws the layer from its own (0,0)…(width,height) on the canvas. */
100
+ world: Mat3;
101
+ /** Draws the layer's parent on the canvas. */
102
+ parentWorld: Mat3;
103
+ /** -1 when the layer is drawn mirrored, so its rotation turns the other way on the canvas. */
104
+ direction: 1 | -1;
105
+ /** Maps canvas points into the layer's parent's space, or null when it cannot be inverted. */
106
+ parentInverse: Mat3 | null;
107
+ }
108
+ declare function selectionPlacement(node: SceneNode, graph: Pick<SceneGraph, 'getNode' | 'rootId'>): SelectionPlacement;
109
+ interface ResizedBoundsOptions {
110
+ /** The layer is locked to its ratio: it scales evenly instead of stretching. */
111
+ keepRatio?: boolean;
112
+ /** Adjusts a locked layer's sizes, such as to whole pixels. */
113
+ round?: (size: number) => number;
114
+ /**
115
+ * Lands an upright layer's edges on whole pixels from the box's top-left corner, as Figma places
116
+ * the layers of a selection a handle resizes while Snap to pixel grid is on.
117
+ */
118
+ wholeEdges?: boolean;
119
+ }
120
+ /** Where a layer sits in its parent and how large it is, with its angle and flips. */
121
+ type LayerPlacement = Pick<SceneNode, 'x' | 'y' | 'width' | 'height' | 'rotation' | 'flipX' | 'flipY'>;
122
+ /**
123
+ * Where a layer lands, in its parent's space, when a multi-selection's canvas box `from` is
124
+ * resized to `to`. Figma scales the layer's whole transform with the box, which skews a rotated
125
+ * layer under an uneven scale. A layer here cannot skew, so it takes what Figma then reports for
126
+ * it, and what a `.fig` file of that result opens as: its top-left corner and x axis where the
127
+ * scale puts them, its width and height the scaled lengths of its own axes, and its y axis square
128
+ * to its x axis. An even scale, or a layer upright in the box, comes out exactly as in Figma.
129
+ */
130
+ declare function placeInResizedBounds(placement: SelectionPlacement, from: Rect, to: Rect, { keepRatio, round, wholeEdges }?: ResizedBoundsOptions): LayerPlacement;
131
+ /**
132
+ * Where a layer lands, in its parent's space, when it scales evenly by `scale` about a canvas
133
+ * point, as Figma's Scale tool scales it: its angle and flips stay, and the point stays put.
134
+ */
135
+ declare function placeScaledAbout(placement: SelectionPlacement, anchor: Vector, scale: number): LayerPlacement;
136
+ /** A canvas pointer movement along the layer's own axes, as its handles measure it. */
137
+ declare function canvasDeltaInLayer(placement: SelectionPlacement, dx: number, dy: number): Vector;
138
+ /**
139
+ * Where a layer lands when one of its handles resizes it in its own frame, from `from` to `to`,
140
+ * both its box in its parent's axes as an upright layer would have it. `to` is signed: a handle
141
+ * dragged past the opposite edge gives a negative size and mirrors the layer, as Figma flips it.
142
+ * The edges the handle leaves stay where they are on the canvas, whatever the layer's angle.
143
+ */
144
+ declare function placeInResizedFrame(placement: SelectionPlacement, from: Rect, to: Rect): LayerPlacement;
145
+ /**
146
+ * Where a layer lands, in its parent's space, when a multi-selection turns `degrees` about a
147
+ * canvas pivot, as Figma rotates a selection about its bounds' center: the layer's center swings
148
+ * around the pivot and the layer itself turns by the same angle on the canvas.
149
+ */
150
+ declare function placeRotatedAbout(placement: SelectionPlacement, pivot: Vector, degrees: number): {
151
+ x: number;
152
+ y: number;
153
+ rotation: number;
154
+ };
92
155
  //#endregion
93
- export { NodePlacement, getAbsolutePosition, getAbsolutePositionFull, getAbsoluteRotation, getAxisAlignedBoundsInParent, getAxisAlignedWorldBounds, getNodeLocalMatrix, getNodeRotationOrigin, getNodeWorldBounds, getParentToContainerMatrix, getParentWorldMatrix, getWorldHandles, getWorldMatrix, isTranslationOnly, localTransformFromWorld };
156
+ export { LayerPlacement, NodePlacement, ResizedBoundsOptions, SelectionPlacement, canvasDeltaInLayer, getAbsolutePosition, getAbsolutePositionFull, getAbsoluteRotation, getAxisAlignedBoundsInParent, getAxisAlignedWorldBounds, getNodeLocalMatrix, getNodeRotationOrigin, getNodeWorldBounds, getParentToContainerMatrix, getParentWorldMatrix, getWorldHandles, getWorldMatrix, isTranslationOnly, localTransformFromWorld, placeInResizedBounds, placeInResizedFrame, placeRotatedAbout, placeScaledAbout, selectionPlacement };
94
157
  //# sourceMappingURL=coordinate.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"coordinate.d.ts","names":[],"sources":["../src/coordinate.ts"],"mappings":";;;;;iBAMgB,eAAe,MAAM,WAAW,OAAO,KAAK,yBAAyB;iBAwCrE,0BAA0B,MAAM,WAAW,OAAO,KAAK,yBAAsB;;iBAK7E,qBACd,QAAQ,uBACR,OAAO,KAAK,oCACX;;;;;;;iBAWa,6BACd,gBAAgB,aAChB,kBACA,OAAO,KAAK,oCACX;iBASa,oBAAoB,MAAM,WAAW,OAAO,aAAa;iBASzD,oBAAoB,MAAM,WAAW,OAAO;iBAW5C,wBAAwB,MAAM,WAAW,OAAO;;;;;;;;;;;;iBA2DhD,sBAAsB,MAAM,KAAK,0CAA0C;;KAK/E,gBAAgB,KAC1B;;iBAKc,mBAAmB,GAAG,eAAe,WAAU,SAAU;iBAczD,mBAAmB,MAAM,YAAS;;;;;;;;iBAWlC,gBACd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AEF,WACA,OACA,eACC,uBACF;;;;;iBAqCa,iBACd,WAAW,oBACX,QAAQ,QACR,gBACC;;iBAMa,mBAAmB,WAAW,oBAAoB,YAAY,aAAa;;;;;;;iBAa3E,oBACd,WAAW,oBACX,MAAM,MACN,IAAI,OACH;;;;;;iBAoCa,kBACd,WAAW,oBACX,OAAO,QACP;EACG;EAAW;EAAW"}
@@ -263,7 +263,223 @@ function getParentToContainerMatrix(node, graph) {
263
263
  for (let parent = node.parentId ? graph.getNode(node.parentId) : void 0; parent && FITTED_CONTAINER_TYPES.has(parent.type); parent = parent.parentId ? graph.getNode(parent.parentId) : void 0) matrix = Matrix.multiply(getNodeLocalMatrix(parent), matrix);
264
264
  return matrix;
265
265
  }
266
+ function selectionPlacement(node, graph) {
267
+ const world = getWorldMatrix(node, graph);
268
+ const [cx, cy] = Matrix.mapPoints(world, [node.width / 2, node.height / 2]);
269
+ const parentWorld = getParentWorldMatrix(node.parentId ? graph.getNode(node.parentId) : void 0, graph);
270
+ return {
271
+ node: { ...node },
272
+ center: {
273
+ x: cx,
274
+ y: cy
275
+ },
276
+ world,
277
+ parentWorld,
278
+ direction: world[0] * world[4] - world[1] * world[3] < 0 ? -1 : 1,
279
+ parentInverse: Matrix.invert(parentWorld)
280
+ };
281
+ }
282
+ /** The position, in its parent's space, that puts `node`'s center at a canvas point. */
283
+ function positionCenteredAt(node, parentInverse, center) {
284
+ const [px, py] = parentInverse ? Matrix.mapPoints(parentInverse, [center.x, center.y]) : [center.x, center.y];
285
+ const [qx, qy] = Matrix.mapPoints(getNodeLocalMatrix(node, {
286
+ x: 0,
287
+ y: 0
288
+ }), [node.width / 2, node.height / 2]);
289
+ return {
290
+ x: px - qx,
291
+ y: py - qy
292
+ };
293
+ }
294
+ /** Within floating-point noise of each other. */
295
+ const sameEdge = (a, b) => Math.abs(a - b) < 1e-6;
296
+ /**
297
+ * `from`..`to` on the canvas with both ends a whole number of pixels from the box's `start`. An end
298
+ * on the box's own edge stays there, so a box that snapped to a fractional guide keeps its layers on
299
+ * it; a span of no length, such as a level line's height, stays at none.
300
+ */
301
+ function wholeSpan(box, from, to) {
302
+ const land = (edge) => sameEdge(edge, box.end) ? box.end : box.start + Math.round(edge - box.start);
303
+ const start = land(from);
304
+ if (sameEdge(from, to)) return {
305
+ start,
306
+ size: 0
307
+ };
308
+ return {
309
+ start,
310
+ size: Math.max(1, land(to) - start)
311
+ };
312
+ }
313
+ /**
314
+ * Where a layer lands, in its parent's space, when a multi-selection's canvas box `from` is
315
+ * resized to `to`. Figma scales the layer's whole transform with the box, which skews a rotated
316
+ * layer under an uneven scale. A layer here cannot skew, so it takes what Figma then reports for
317
+ * it, and what a `.fig` file of that result opens as: its top-left corner and x axis where the
318
+ * scale puts them, its width and height the scaled lengths of its own axes, and its y axis square
319
+ * to its x axis. An even scale, or a layer upright in the box, comes out exactly as in Figma.
320
+ */
321
+ function placeInResizedBounds(placement, from, to, { keepRatio = false, round = (size) => size, wholeEdges = false } = {}) {
322
+ const { node, world, parentWorld } = placement;
323
+ const scaleX = from.width > 0 ? to.width / from.width : 1;
324
+ const scaleY = from.height > 0 ? to.height / from.height : 1;
325
+ const scale = Matrix.multiply(Matrix.translated(to.x - from.x * scaleX, to.y - from.y * scaleY), Matrix.scaled(scaleX, scaleY));
326
+ const [a, b, tx, c, d, ty] = Matrix.multiply(scale, world);
327
+ const xLength = Math.hypot(a, c);
328
+ const yLength = Math.hypot(b, d);
329
+ const even = Math.sqrt(Math.abs(scaleX * scaleY));
330
+ let width = keepRatio ? round(node.width * even) : node.width * xLength;
331
+ let height = keepRatio ? round(node.height * even) : node.height * yLength;
332
+ const ux = xLength > 0 ? a / xLength : 1;
333
+ const uy = xLength > 0 ? c / xLength : 0;
334
+ const mirrored = a * d - b * c < 0 ? -1 : 1;
335
+ let [left, top] = [tx, ty];
336
+ if (wholeEdges && !keepRatio && Math.abs(uy) < 1e-9 && ux > 0 && mirrored > 0) {
337
+ const across = wholeSpan({
338
+ start: to.x,
339
+ end: to.x + to.width
340
+ }, tx, tx + width);
341
+ const down = wholeSpan({
342
+ start: to.y,
343
+ end: to.y + to.height
344
+ }, ty, ty + height);
345
+ [left, width, top, height] = [
346
+ across.start,
347
+ across.size,
348
+ down.start,
349
+ down.size
350
+ ];
351
+ }
352
+ const squared = [
353
+ ux,
354
+ -uy * mirrored,
355
+ left,
356
+ uy,
357
+ ux * mirrored,
358
+ top,
359
+ 0,
360
+ 0,
361
+ 1
362
+ ];
363
+ const { x, y, rotation, flipX, flipY } = localTransformFromWorld({
364
+ ...node,
365
+ width,
366
+ height
367
+ }, squared, parentWorld) ?? node;
368
+ return {
369
+ x,
370
+ y,
371
+ width,
372
+ height,
373
+ rotation,
374
+ flipX,
375
+ flipY
376
+ };
377
+ }
378
+ /**
379
+ * Where a layer lands, in its parent's space, when it scales evenly by `scale` about a canvas
380
+ * point, as Figma's Scale tool scales it: its angle and flips stay, and the point stays put.
381
+ */
382
+ function placeScaledAbout(placement, anchor, scale) {
383
+ const from = {
384
+ x: anchor.x,
385
+ y: anchor.y,
386
+ width: 1,
387
+ height: 1
388
+ };
389
+ return placeInResizedBounds(placement, from, {
390
+ ...from,
391
+ width: scale,
392
+ height: scale
393
+ });
394
+ }
395
+ /** A canvas pointer movement along the layer's own axes, as its handles measure it. */
396
+ function canvasDeltaInLayer(placement, dx, dy) {
397
+ const [a, b, , c, d] = placement.world;
398
+ const det = a * d - b * c;
399
+ if (det === 0) return {
400
+ x: dx,
401
+ y: dy
402
+ };
403
+ return {
404
+ x: (d * dx - b * dy) / det,
405
+ y: (a * dy - c * dx) / det
406
+ };
407
+ }
408
+ /**
409
+ * Where a layer lands when one of its handles resizes it in its own frame, from `from` to `to`,
410
+ * both its box in its parent's axes as an upright layer would have it. `to` is signed: a handle
411
+ * dragged past the opposite edge gives a negative size and mirrors the layer, as Figma flips it.
412
+ * The edges the handle leaves stay where they are on the canvas, whatever the layer's angle.
413
+ */
414
+ function placeInResizedFrame(placement, from, to) {
415
+ const { node, world, parentWorld } = placement;
416
+ const width = Math.abs(to.width);
417
+ const height = Math.abs(to.height);
418
+ const mirrorX = to.width < 0;
419
+ const mirrorY = to.height < 0;
420
+ if (!(node.rotation !== 0 || node.flipX || node.flipY) && !mirrorX && !mirrorY) return {
421
+ x: to.x,
422
+ y: to.y,
423
+ width,
424
+ height,
425
+ rotation: 0,
426
+ flipX: false,
427
+ flipY: false
428
+ };
429
+ const placed = Matrix.multiply(Matrix.multiply(world, Matrix.translated(to.x - from.x, to.y - from.y)), Matrix.scaled(mirrorX ? -1 : 1, mirrorY ? -1 : 1));
430
+ const local = localTransformFromWorld({
431
+ ...node,
432
+ width,
433
+ height
434
+ }, placed, parentWorld);
435
+ if (!local) return {
436
+ ...to,
437
+ width,
438
+ height,
439
+ rotation: node.rotation,
440
+ flipX: node.flipX,
441
+ flipY: node.flipY
442
+ };
443
+ return mirrorX || mirrorY ? {
444
+ ...local,
445
+ width,
446
+ height
447
+ } : {
448
+ x: local.x,
449
+ y: local.y,
450
+ width,
451
+ height,
452
+ rotation: node.rotation,
453
+ flipX: node.flipX,
454
+ flipY: node.flipY
455
+ };
456
+ }
457
+ /**
458
+ * Where a layer lands, in its parent's space, when a multi-selection turns `degrees` about a
459
+ * canvas pivot, as Figma rotates a selection about its bounds' center: the layer's center swings
460
+ * around the pivot and the layer itself turns by the same angle on the canvas.
461
+ */
462
+ function placeRotatedAbout(placement, pivot, degrees) {
463
+ const { node, center, direction, parentInverse } = placement;
464
+ const radians = degrees * Math.PI / 180;
465
+ const cos = Math.cos(radians);
466
+ const sin = Math.sin(radians);
467
+ const dx = center.x - pivot.x;
468
+ const dy = center.y - pivot.y;
469
+ const target = {
470
+ x: pivot.x + dx * cos - dy * sin,
471
+ y: pivot.y + dx * sin + dy * cos
472
+ };
473
+ const rotation = ((node.rotation + degrees * direction + 180) % 360 + 360) % 360 - 180;
474
+ return {
475
+ ...positionCenteredAt({
476
+ ...node,
477
+ rotation
478
+ }, parentInverse, target),
479
+ rotation
480
+ };
481
+ }
266
482
  //#endregion
267
- export { getAbsolutePosition, getAbsolutePositionFull, getAbsoluteRotation, getAxisAlignedBoundsInParent, getAxisAlignedWorldBounds, getNodeLocalMatrix, getNodeRotationOrigin, getNodeWorldBounds, getParentToContainerMatrix, getParentWorldMatrix, getWorldHandles, getWorldMatrix, isTranslationOnly, localTransformFromWorld };
483
+ export { canvasDeltaInLayer, getAbsolutePosition, getAbsolutePositionFull, getAbsoluteRotation, getAxisAlignedBoundsInParent, getAxisAlignedWorldBounds, getNodeLocalMatrix, getNodeRotationOrigin, getNodeWorldBounds, getParentToContainerMatrix, getParentWorldMatrix, getWorldHandles, getWorldMatrix, isTranslationOnly, localTransformFromWorld, placeInResizedBounds, placeInResizedFrame, placeRotatedAbout, placeScaledAbout, selectionPlacement };
268
484
 
269
485
  //# sourceMappingURL=coordinate.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"coordinate.js","names":[],"sources":["../src/coordinate.ts"],"sourcesContent":["import type { SceneGraph } from './graph'\nimport Matrix, { type Mat3 } from './matrix'\nimport { FITTED_CONTAINER_TYPES } from './node-defaults'\nimport type { Rect, Vector } from './primitives'\nimport type { SceneNode } from './types'\n\nexport function getWorldMatrix(node: SceneNode, graph: Pick<SceneGraph, 'getNode'>): Mat3 {\n const chain: SceneNode[] = []\n let current: SceneNode | undefined = node\n\n while (current) {\n chain.unshift(current)\n if (!current.parentId) break\n current = graph.getNode(current.parentId)\n }\n\n let matrix = Matrix.identity()\n\n for (const n of chain) {\n const local = getNodeLocalMatrix(n)\n matrix = Matrix.multiply(matrix, local)\n }\n\n return matrix\n}\n\n/** Axis-aligned box around interleaved `x, y` points; empty input gives an empty box at the origin. */\nfunction boundsOfPoints(points: readonly number[]): Rect {\n if (points.length === 0) return { x: 0, y: 0, width: 0, height: 0 }\n let minX = Infinity\n let minY = Infinity\n let maxX = -Infinity\n let maxY = -Infinity\n for (let i = 0; i < points.length; i += 2) {\n minX = Math.min(minX, points[i])\n minY = Math.min(minY, points[i + 1])\n maxX = Math.max(maxX, points[i])\n maxY = Math.max(maxY, points[i + 1])\n }\n return { x: minX, y: minY, width: maxX - minX, height: maxY - minY }\n}\n\nfunction cornersOf(node: Pick<SceneNode, 'width' | 'height'>): number[] {\n return [0, 0, node.width, 0, node.width, node.height, 0, node.height]\n}\n\nexport function getAxisAlignedWorldBounds(node: SceneNode, graph: Pick<SceneGraph, 'getNode'>) {\n return boundsOfPoints(Matrix.mapPoints(getWorldMatrix(node, graph), cornersOf(node)))\n}\n\n/** World matrix of a parent; the document root and a missing parent are the identity. */\nexport function getParentWorldMatrix(\n parent: SceneNode | undefined,\n graph: Pick<SceneGraph, 'getNode' | 'rootId'>\n): Mat3 {\n if (!parent || parent.id === graph.rootId) return Matrix.identity()\n return getWorldMatrix(parent, graph)\n}\n\n/**\n * Axis-aligned box of `nodes` in `parentId`'s own axes: where a group, frame, or boolean operation\n * made from them sits. Each node's corners are mapped through the parent's inverse world matrix,\n * so a rotated or flipped parent gets a box in its own axes and the nodes keep their drawn places\n * once they move into the container.\n */\nexport function getAxisAlignedBoundsInParent(\n nodes: readonly SceneNode[],\n parentId: string,\n graph: Pick<SceneGraph, 'getNode' | 'rootId'>\n): Rect {\n const toParent =\n Matrix.invert(getParentWorldMatrix(graph.getNode(parentId), graph)) ?? Matrix.identity()\n const points = nodes.flatMap((node) =>\n Matrix.mapPoints(Matrix.multiply(toParent, getWorldMatrix(node, graph)), cornersOf(node))\n )\n return boundsOfPoints(points)\n}\n\nexport function getAbsolutePosition(node: SceneNode, graph: SceneGraph): Vector {\n const matrix = getWorldMatrix(node, graph)\n const p = Matrix.mapPoints(matrix, [0, 0])\n\n return {\n x: p[0],\n y: p[1]\n }\n}\nexport function getAbsoluteRotation(node: SceneNode, graph: SceneGraph): number {\n const matrix = getWorldMatrix(node, graph)\n const a = matrix[0]\n const b = matrix[1]\n const angle = Math.atan2(b, a)\n let deg = (angle * 180) / Math.PI\n deg = (deg + 360) % 360\n\n return deg\n}\n\nexport function getAbsolutePositionFull(node: SceneNode, graph: SceneGraph) {\n const matrix = getWorldMatrix(node, graph)\n\n const origin = Matrix.mapPoints(matrix, [0, 0])\n const x = origin[0]\n const y = origin[1]\n\n const pts = Matrix.mapPoints(matrix, [\n 0,\n 0,\n node.width,\n 0,\n node.width,\n node.height,\n 0,\n node.height\n ])\n\n const [x1, y1, x2, y2, x3, y3, x4, y4] = pts\n\n const minX = Math.min(x1, x2, x3, x4)\n const maxX = Math.max(x1, x2, x3, x4)\n const minY = Math.min(y1, y2, y3, y4)\n const maxY = Math.max(y1, y2, y3, y4)\n\n const width = maxX - minX\n const height = maxY - minY\n\n let angle = Math.atan2(matrix[3], matrix[0])\n\n const det = matrix[0] * matrix[4] - matrix[1] * matrix[3]\n if (det < 0) {\n angle = -angle\n }\n\n const rotation = angle * (180 / Math.PI)\n\n const center = Matrix.mapPoints(matrix, [node.width / 2, node.height / 2])\n\n const centerX = center[0]\n const centerY = center[1]\n\n return {\n x,\n y,\n\n // AABB\n boundX: minX,\n boundY: minY,\n width,\n height,\n\n rotation,\n\n centerX,\n centerY\n }\n}\n/** Lines retain their origin pivot; other shapes rotate around their center. */\nexport function getNodeRotationOrigin(node: Pick<SceneNode, 'type' | 'width' | 'height'>): Vector {\n return node.type === 'LINE' ? { x: 0, y: 0 } : { x: node.width / 2, y: node.height / 2 }\n}\n\n/** What places a layer in its parent: its position, size, reflection, turn, and pivot. */\nexport type NodePlacement = Pick<\n SceneNode,\n 'type' | 'x' | 'y' | 'width' | 'height' | 'rotation' | 'flipX' | 'flipY'\n>\n\n/** Position can be applied separately by renderers before setting up local opacity layers. */\nexport function getNodeLocalMatrix(n: NodePlacement, position: Vector = n) {\n let matrix = Matrix.translated(position.x, position.y)\n if (n.flipX || n.flipY) {\n matrix = Matrix.multiply(\n matrix,\n Matrix.scaled(n.flipX ? -1 : 1, n.flipY ? -1 : 1, n.width / 2, n.height / 2)\n )\n }\n if (n.rotation) {\n const pivot = getNodeRotationOrigin(n)\n matrix = Matrix.multiply(matrix, Matrix.rotated((n.rotation * Math.PI) / 180, pivot.x, pivot.y))\n }\n return matrix\n}\nexport function getNodeWorldBounds(node: SceneNode) {\n return boundsOfPoints(Matrix.mapPoints(getNodeLocalMatrix(node), cornersOf(node)))\n}\n\n/**\n * World-space positions of the 8 selection handles. `localRect` overrides the\n * node-local box the handles sit on — text-on-path draws its handles on the\n * glyph-fitted path box, not node bounds, so its hit-test must pass that box\n * or the visible handles are ~25px off and unclickable. Defaults to full node\n * bounds.\n */\nexport function getWorldHandles(\n node: SceneNode,\n graph: Pick<SceneGraph, 'getNode'>,\n localRect?: Rect\n) {\n const matrix = getWorldMatrix(node, graph)\n\n const x0 = localRect?.x ?? 0\n const y0 = localRect?.y ?? 0\n const w = localRect?.width ?? node.width\n const h = localRect?.height ?? node.height\n const mx = x0 + w / 2\n const my = y0 + h / 2\n const x1 = x0 + w\n const y1 = y0 + h\n\n const localPts = [\n x0,\n y0, // nw\n mx,\n y0, // n\n x1,\n y0, // ne\n x1,\n my, // e\n x1,\n y1, // se\n mx,\n y1, // s\n x0,\n y1, // sw\n x0,\n my // w\n ]\n\n const pts = Matrix.mapPoints(matrix, localPts)\n\n return {\n nw: { x: pts[0], y: pts[1] },\n n: { x: pts[2], y: pts[3] },\n ne: { x: pts[4], y: pts[5] },\n e: { x: pts[6], y: pts[7] },\n se: { x: pts[8], y: pts[9] },\n s: { x: pts[10], y: pts[11] },\n sw: { x: pts[12], y: pts[13] },\n w: { x: pts[14], y: pts[15] }\n }\n}\n\ntype LocalTransform = Pick<SceneNode, 'x' | 'y' | 'rotation' | 'flipX' | 'flipY'>\n\n/**\n * Local transform that draws `node` with the given world matrix once it sits under a parent\n * whose world matrix is `parentWorld`. Keeps the node's own `flipX` when the matrix allows it.\n */\nexport function localTransformFromWorld(\n node: SceneNode,\n world: Mat3,\n parentWorld: Mat3\n): LocalTransform | null {\n const parentInverse = Matrix.invert(parentWorld)\n if (!parentInverse) return null\n const local = Matrix.multiply(parentInverse, world)\n const [a, b, , c, d] = local\n const sx = node.flipX ? -1 : 1\n const sy = a * d - b * c < 0 ? -sx : sx\n let rotation = (Math.atan2(sy * c, sx * a) * 180) / Math.PI\n if (Math.abs(rotation) < 1e-9) rotation = 0\n const transform = { rotation, flipX: sx < 0, flipY: sy < 0 }\n const origin = getNodeLocalMatrix({ ...node, ...transform }, { x: 0, y: 0 })\n return { ...transform, x: local[2] - origin[2], y: local[5] - origin[5] }\n}\n\nexport function isTranslationOnly(matrix: Mat3): boolean {\n return matrix[0] === 1 && matrix[1] === 0 && matrix[3] === 0 && matrix[4] === 1\n}\n\n/**\n * Maps a node's parent space into its container's: through the groups and booleans around it,\n * which set no coordinate space of their own. Figma's plugin API reports `x`, `y`, and\n * `relativeTransform` of their children in the container's space. The identity when the parent is\n * not a group.\n */\nexport function getParentToContainerMatrix(\n node: SceneNode,\n graph: Pick<SceneGraph, 'getNode'>\n): Mat3 {\n let matrix = Matrix.identity()\n for (\n let parent = node.parentId ? graph.getNode(node.parentId) : undefined;\n parent && FITTED_CONTAINER_TYPES.has(parent.type);\n parent = parent.parentId ? graph.getNode(parent.parentId) : undefined\n ) {\n matrix = Matrix.multiply(getNodeLocalMatrix(parent), matrix)\n }\n return matrix\n}\n"],"mappings":";;;AAMA,SAAgB,eAAe,MAAiB,OAA0C;CACxF,MAAM,QAAqB,CAAC;CAC5B,IAAI,UAAiC;CAErC,OAAO,SAAS;EACd,MAAM,QAAQ,OAAO;EACrB,IAAI,CAAC,QAAQ,UAAU;EACvB,UAAU,MAAM,QAAQ,QAAQ,QAAQ;CAC1C;CAEA,IAAI,SAAS,OAAO,SAAS;CAE7B,KAAK,MAAM,KAAK,OAAO;EACrB,MAAM,QAAQ,mBAAmB,CAAC;EAClC,SAAS,OAAO,SAAS,QAAQ,KAAK;CACxC;CAEA,OAAO;AACT;;AAGA,SAAS,eAAe,QAAiC;CACvD,IAAI,OAAO,WAAW,GAAG,OAAO;EAAE,GAAG;EAAG,GAAG;EAAG,OAAO;EAAG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ACd,MACA,OACM;CACN,IAAI,SAAS,OAAO,SAAS;CAC7B,KACE,IAAI,SAAS,KAAK,WAAW,MAAM,QAAQ,KAAK,QAAQ,IAAI,KAAA,GAC5D,UAAU,uBAAuB,IAAI,OAAO,IAAI,GAChD,SAAS,OAAO,WAAW,MAAM,QAAQ,OAAO,QAAQ,IAAI,KAAA,GAE5D,SAAS,OAAO,SAAS,mBAAmB,MAAM,GAAG,MAAM;CAE7D,OAAO;AACT"}
1
+ {"version":3,"file":"coordinate.js","names":[],"sources":["../src/coordinate.ts"],"sourcesContent":["import type { SceneGraph } from './graph'\nimport Matrix, { type Mat3 } from './matrix'\nimport { FITTED_CONTAINER_TYPES } from './node-defaults'\nimport type { Rect, Vector } from './primitives'\nimport type { SceneNode } from './types'\n\nexport function getWorldMatrix(node: SceneNode, graph: Pick<SceneGraph, 'getNode'>): Mat3 {\n const chain: SceneNode[] = []\n let current: SceneNode | undefined = node\n\n while (current) {\n chain.unshift(current)\n if (!current.parentId) break\n current = graph.getNode(current.parentId)\n }\n\n let matrix = Matrix.identity()\n\n for (const n of chain) {\n const local = getNodeLocalMatrix(n)\n matrix = Matrix.multiply(matrix, local)\n }\n\n return matrix\n}\n\n/** Axis-aligned box around interleaved `x, y` points; empty input gives an empty box at the origin. */\nfunction boundsOfPoints(points: readonly number[]): Rect {\n if (points.length === 0) return { x: 0, y: 0, width: 0, height: 0 }\n let minX = Infinity\n let minY = Infinity\n let maxX = -Infinity\n let maxY = -Infinity\n for (let i = 0; i < points.length; i += 2) {\n minX = Math.min(minX, points[i])\n minY = Math.min(minY, points[i + 1])\n maxX = Math.max(maxX, points[i])\n maxY = Math.max(maxY, points[i + 1])\n }\n return { x: minX, y: minY, width: maxX - minX, height: maxY - minY }\n}\n\nfunction cornersOf(node: Pick<SceneNode, 'width' | 'height'>): number[] {\n return [0, 0, node.width, 0, node.width, node.height, 0, node.height]\n}\n\nexport function getAxisAlignedWorldBounds(node: SceneNode, graph: Pick<SceneGraph, 'getNode'>) {\n return boundsOfPoints(Matrix.mapPoints(getWorldMatrix(node, graph), cornersOf(node)))\n}\n\n/** World matrix of a parent; the document root and a missing parent are the identity. */\nexport function getParentWorldMatrix(\n parent: SceneNode | undefined,\n graph: Pick<SceneGraph, 'getNode' | 'rootId'>\n): Mat3 {\n if (!parent || parent.id === graph.rootId) return Matrix.identity()\n return getWorldMatrix(parent, graph)\n}\n\n/**\n * Axis-aligned box of `nodes` in `parentId`'s own axes: where a group, frame, or boolean operation\n * made from them sits. Each node's corners are mapped through the parent's inverse world matrix,\n * so a rotated or flipped parent gets a box in its own axes and the nodes keep their drawn places\n * once they move into the container.\n */\nexport function getAxisAlignedBoundsInParent(\n nodes: readonly SceneNode[],\n parentId: string,\n graph: Pick<SceneGraph, 'getNode' | 'rootId'>\n): Rect {\n const toParent =\n Matrix.invert(getParentWorldMatrix(graph.getNode(parentId), graph)) ?? Matrix.identity()\n const points = nodes.flatMap((node) =>\n Matrix.mapPoints(Matrix.multiply(toParent, getWorldMatrix(node, graph)), cornersOf(node))\n )\n return boundsOfPoints(points)\n}\n\nexport function getAbsolutePosition(node: SceneNode, graph: SceneGraph): Vector {\n const matrix = getWorldMatrix(node, graph)\n const p = Matrix.mapPoints(matrix, [0, 0])\n\n return {\n x: p[0],\n y: p[1]\n }\n}\nexport function getAbsoluteRotation(node: SceneNode, graph: SceneGraph): number {\n const matrix = getWorldMatrix(node, graph)\n const a = matrix[0]\n const b = matrix[1]\n const angle = Math.atan2(b, a)\n let deg = (angle * 180) / Math.PI\n deg = (deg + 360) % 360\n\n return deg\n}\n\nexport function getAbsolutePositionFull(node: SceneNode, graph: SceneGraph) {\n const matrix = getWorldMatrix(node, graph)\n\n const origin = Matrix.mapPoints(matrix, [0, 0])\n const x = origin[0]\n const y = origin[1]\n\n const pts = Matrix.mapPoints(matrix, [\n 0,\n 0,\n node.width,\n 0,\n node.width,\n node.height,\n 0,\n node.height\n ])\n\n const [x1, y1, x2, y2, x3, y3, x4, y4] = pts\n\n const minX = Math.min(x1, x2, x3, x4)\n const maxX = Math.max(x1, x2, x3, x4)\n const minY = Math.min(y1, y2, y3, y4)\n const maxY = Math.max(y1, y2, y3, y4)\n\n const width = maxX - minX\n const height = maxY - minY\n\n let angle = Math.atan2(matrix[3], matrix[0])\n\n const det = matrix[0] * matrix[4] - matrix[1] * matrix[3]\n if (det < 0) {\n angle = -angle\n }\n\n const rotation = angle * (180 / Math.PI)\n\n const center = Matrix.mapPoints(matrix, [node.width / 2, node.height / 2])\n\n const centerX = center[0]\n const centerY = center[1]\n\n return {\n x,\n y,\n\n // AABB\n boundX: minX,\n boundY: minY,\n width,\n height,\n\n rotation,\n\n centerX,\n centerY\n }\n}\n/** Lines retain their origin pivot; other shapes rotate around their center. */\nexport function getNodeRotationOrigin(node: Pick<SceneNode, 'type' | 'width' | 'height'>): Vector {\n return node.type === 'LINE' ? { x: 0, y: 0 } : { x: node.width / 2, y: node.height / 2 }\n}\n\n/** What places a layer in its parent: its position, size, reflection, turn, and pivot. */\nexport type NodePlacement = Pick<\n SceneNode,\n 'type' | 'x' | 'y' | 'width' | 'height' | 'rotation' | 'flipX' | 'flipY'\n>\n\n/** Position can be applied separately by renderers before setting up local opacity layers. */\nexport function getNodeLocalMatrix(n: NodePlacement, position: Vector = n) {\n let matrix = Matrix.translated(position.x, position.y)\n if (n.flipX || n.flipY) {\n matrix = Matrix.multiply(\n matrix,\n Matrix.scaled(n.flipX ? -1 : 1, n.flipY ? -1 : 1, n.width / 2, n.height / 2)\n )\n }\n if (n.rotation) {\n const pivot = getNodeRotationOrigin(n)\n matrix = Matrix.multiply(matrix, Matrix.rotated((n.rotation * Math.PI) / 180, pivot.x, pivot.y))\n }\n return matrix\n}\nexport function getNodeWorldBounds(node: SceneNode) {\n return boundsOfPoints(Matrix.mapPoints(getNodeLocalMatrix(node), cornersOf(node)))\n}\n\n/**\n * World-space positions of the 8 selection handles. `localRect` overrides the\n * node-local box the handles sit on — text-on-path draws its handles on the\n * glyph-fitted path box, not node bounds, so its hit-test must pass that box\n * or the visible handles are ~25px off and unclickable. Defaults to full node\n * bounds.\n */\nexport function getWorldHandles(\n node: SceneNode,\n graph: Pick<SceneGraph, 'getNode'>,\n localRect?: Rect\n) {\n const matrix = getWorldMatrix(node, graph)\n\n const x0 = localRect?.x ?? 0\n const y0 = localRect?.y ?? 0\n const w = localRect?.width ?? node.width\n const h = localRect?.height ?? node.height\n const mx = x0 + w / 2\n const my = y0 + h / 2\n const x1 = x0 + w\n const y1 = y0 + h\n\n const localPts = [\n x0,\n y0, // nw\n mx,\n y0, // n\n x1,\n y0, // ne\n x1,\n my, // e\n x1,\n y1, // se\n mx,\n y1, // s\n x0,\n y1, // sw\n x0,\n my // w\n ]\n\n const pts = Matrix.mapPoints(matrix, localPts)\n\n return {\n nw: { x: pts[0], y: pts[1] },\n n: { x: pts[2], y: pts[3] },\n ne: { x: pts[4], y: pts[5] },\n e: { x: pts[6], y: pts[7] },\n se: { x: pts[8], y: pts[9] },\n s: { x: pts[10], y: pts[11] },\n sw: { x: pts[12], y: pts[13] },\n w: { x: pts[14], y: pts[15] }\n }\n}\n\ntype LocalTransform = Pick<SceneNode, 'x' | 'y' | 'rotation' | 'flipX' | 'flipY'>\n\n/**\n * Local transform that draws `node` with the given world matrix once it sits under a parent\n * whose world matrix is `parentWorld`. Keeps the node's own `flipX` when the matrix allows it.\n */\nexport function localTransformFromWorld(\n node: SceneNode,\n world: Mat3,\n parentWorld: Mat3\n): LocalTransform | null {\n const parentInverse = Matrix.invert(parentWorld)\n if (!parentInverse) return null\n const local = Matrix.multiply(parentInverse, world)\n const [a, b, , c, d] = local\n const sx = node.flipX ? -1 : 1\n const sy = a * d - b * c < 0 ? -sx : sx\n let rotation = (Math.atan2(sy * c, sx * a) * 180) / Math.PI\n if (Math.abs(rotation) < 1e-9) rotation = 0\n const transform = { rotation, flipX: sx < 0, flipY: sy < 0 }\n const origin = getNodeLocalMatrix({ ...node, ...transform }, { x: 0, y: 0 })\n return { ...transform, x: local[2] - origin[2], y: local[5] - origin[5] }\n}\n\nexport function isTranslationOnly(matrix: Mat3): boolean {\n return matrix[0] === 1 && matrix[1] === 0 && matrix[3] === 0 && matrix[4] === 1\n}\n\n/**\n * Maps a node's parent space into its container's: through the groups and booleans around it,\n * which set no coordinate space of their own. Figma's plugin API reports `x`, `y`, and\n * `relativeTransform` of their children in the container's space. The identity when the parent is\n * not a group.\n */\nexport function getParentToContainerMatrix(\n node: SceneNode,\n graph: Pick<SceneGraph, 'getNode'>\n): Mat3 {\n let matrix = Matrix.identity()\n for (\n let parent = node.parentId ? graph.getNode(node.parentId) : undefined;\n parent && FITTED_CONTAINER_TYPES.has(parent.type);\n parent = parent.parentId ? graph.getNode(parent.parentId) : undefined\n ) {\n matrix = Matrix.multiply(getNodeLocalMatrix(parent), matrix)\n }\n return matrix\n}\n\n/**\n * A selected layer's place in a multi-selection's canvas bounds, taken when a resize starts so\n * every step re-places the layer from where it began rather than from its previewed state.\n */\nexport interface SelectionPlacement {\n node: SceneNode\n center: Vector\n /** Draws the layer from its own (0,0)…(width,height) on the canvas. */\n world: Mat3\n /** Draws the layer's parent on the canvas. */\n parentWorld: Mat3\n /** -1 when the layer is drawn mirrored, so its rotation turns the other way on the canvas. */\n direction: 1 | -1\n /** Maps canvas points into the layer's parent's space, or null when it cannot be inverted. */\n parentInverse: Mat3 | null\n}\n\nexport function selectionPlacement(\n node: SceneNode,\n graph: Pick<SceneGraph, 'getNode' | 'rootId'>\n): SelectionPlacement {\n const world = getWorldMatrix(node, graph)\n const [cx, cy] = Matrix.mapPoints(world, [node.width / 2, node.height / 2])\n const parent = node.parentId ? graph.getNode(node.parentId) : undefined\n const parentWorld = getParentWorldMatrix(parent, graph)\n return {\n node: { ...node },\n center: { x: cx, y: cy },\n world,\n parentWorld,\n direction: world[0] * world[4] - world[1] * world[3] < 0 ? -1 : 1,\n parentInverse: Matrix.invert(parentWorld)\n }\n}\n\n/** The position, in its parent's space, that puts `node`'s center at a canvas point. */\nfunction positionCenteredAt(node: SceneNode, parentInverse: Mat3 | null, center: Vector): Vector {\n const [px, py] = parentInverse\n ? Matrix.mapPoints(parentInverse, [center.x, center.y])\n : [center.x, center.y]\n // The local matrix translates last, so the layer's center at the origin gives the offset.\n const [qx, qy] = Matrix.mapPoints(getNodeLocalMatrix(node, { x: 0, y: 0 }), [\n node.width / 2,\n node.height / 2\n ])\n return { x: px - qx, y: py - qy }\n}\n\nexport interface ResizedBoundsOptions {\n /** The layer is locked to its ratio: it scales evenly instead of stretching. */\n keepRatio?: boolean\n /** Adjusts a locked layer's sizes, such as to whole pixels. */\n round?: (size: number) => number\n /**\n * Lands an upright layer's edges on whole pixels from the box's top-left corner, as Figma places\n * the layers of a selection a handle resizes while Snap to pixel grid is on.\n */\n wholeEdges?: boolean\n}\n\n/** Within floating-point noise of each other. */\nconst sameEdge = (a: number, b: number) => Math.abs(a - b) < 1e-6\n\n/**\n * `from`..`to` on the canvas with both ends a whole number of pixels from the box's `start`. An end\n * on the box's own edge stays there, so a box that snapped to a fractional guide keeps its layers on\n * it; a span of no length, such as a level line's height, stays at none.\n */\nfunction wholeSpan(\n box: { start: number; end: number },\n from: number,\n to: number\n): { start: number; size: number } {\n const land = (edge: number) =>\n sameEdge(edge, box.end) ? box.end : box.start + Math.round(edge - box.start)\n const start = land(from)\n if (sameEdge(from, to)) return { start, size: 0 }\n return { start, size: Math.max(1, land(to) - start) }\n}\n\n/** Where a layer sits in its parent and how large it is, with its angle and flips. */\nexport type LayerPlacement = Pick<\n SceneNode,\n 'x' | 'y' | 'width' | 'height' | 'rotation' | 'flipX' | 'flipY'\n>\n\n/**\n * Where a layer lands, in its parent's space, when a multi-selection's canvas box `from` is\n * resized to `to`. Figma scales the layer's whole transform with the box, which skews a rotated\n * layer under an uneven scale. A layer here cannot skew, so it takes what Figma then reports for\n * it, and what a `.fig` file of that result opens as: its top-left corner and x axis where the\n * scale puts them, its width and height the scaled lengths of its own axes, and its y axis square\n * to its x axis. An even scale, or a layer upright in the box, comes out exactly as in Figma.\n */\nexport function placeInResizedBounds(\n placement: SelectionPlacement,\n from: Rect,\n to: Rect,\n {\n keepRatio = false,\n round = (size: number) => size,\n wholeEdges = false\n }: ResizedBoundsOptions = {}\n): LayerPlacement {\n const { node, world, parentWorld } = placement\n const scaleX = from.width > 0 ? to.width / from.width : 1\n const scaleY = from.height > 0 ? to.height / from.height : 1\n const scale = Matrix.multiply(\n Matrix.translated(to.x - from.x * scaleX, to.y - from.y * scaleY),\n Matrix.scaled(scaleX, scaleY)\n )\n const [a, b, tx, c, d, ty] = Matrix.multiply(scale, world)\n // The scaled axes: x along the first column, y along the second.\n const xLength = Math.hypot(a, c)\n const yLength = Math.hypot(b, d)\n // A layer locked to its ratio scales evenly, by the mean of the box's scales, as in Figma.\n const even = Math.sqrt(Math.abs(scaleX * scaleY))\n let width = keepRatio ? round(node.width * even) : node.width * xLength\n let height = keepRatio ? round(node.height * even) : node.height * yLength\n const ux = xLength > 0 ? a / xLength : 1\n const uy = xLength > 0 ? c / xLength : 0\n const mirrored = a * d - b * c < 0 ? -1 : 1\n let [left, top] = [tx, ty]\n const upright = Math.abs(uy) < 1e-9 && ux > 0 && mirrored > 0\n if (wholeEdges && !keepRatio && upright) {\n const across = wholeSpan({ start: to.x, end: to.x + to.width }, tx, tx + width)\n const down = wholeSpan({ start: to.y, end: to.y + to.height }, ty, ty + height)\n ;[left, width, top, height] = [across.start, across.size, down.start, down.size]\n }\n const squared: Mat3 = [ux, -uy * mirrored, left, uy, ux * mirrored, top, 0, 0, 1]\n const sized = { ...node, width, height }\n const { x, y, rotation, flipX, flipY } =\n localTransformFromWorld(sized, squared, parentWorld) ?? node\n return { x, y, width, height, rotation, flipX, flipY }\n}\n\n/**\n * Where a layer lands, in its parent's space, when it scales evenly by `scale` about a canvas\n * point, as Figma's Scale tool scales it: its angle and flips stay, and the point stays put.\n */\nexport function placeScaledAbout(\n placement: SelectionPlacement,\n anchor: Vector,\n scale: number\n): LayerPlacement {\n const from = { x: anchor.x, y: anchor.y, width: 1, height: 1 }\n return placeInResizedBounds(placement, from, { ...from, width: scale, height: scale })\n}\n\n/** A canvas pointer movement along the layer's own axes, as its handles measure it. */\nexport function canvasDeltaInLayer(placement: SelectionPlacement, dx: number, dy: number): Vector {\n const [a, b, , c, d] = placement.world\n const det = a * d - b * c\n if (det === 0) return { x: dx, y: dy }\n return { x: (d * dx - b * dy) / det, y: (a * dy - c * dx) / det }\n}\n\n/**\n * Where a layer lands when one of its handles resizes it in its own frame, from `from` to `to`,\n * both its box in its parent's axes as an upright layer would have it. `to` is signed: a handle\n * dragged past the opposite edge gives a negative size and mirrors the layer, as Figma flips it.\n * The edges the handle leaves stay where they are on the canvas, whatever the layer's angle.\n */\nexport function placeInResizedFrame(\n placement: SelectionPlacement,\n from: Rect,\n to: Rect\n): LayerPlacement {\n const { node, world, parentWorld } = placement\n const width = Math.abs(to.width)\n const height = Math.abs(to.height)\n const mirrorX = to.width < 0\n const mirrorY = to.height < 0\n const turned = node.rotation !== 0 || node.flipX || node.flipY\n if (!turned && !mirrorX && !mirrorY) {\n return { x: to.x, y: to.y, width, height, rotation: 0, flipX: false, flipY: false }\n }\n const placed = Matrix.multiply(\n Matrix.multiply(world, Matrix.translated(to.x - from.x, to.y - from.y)),\n Matrix.scaled(mirrorX ? -1 : 1, mirrorY ? -1 : 1)\n )\n const local = localTransformFromWorld({ ...node, width, height }, placed, parentWorld)\n if (!local)\n return { ...to, width, height, rotation: node.rotation, flipX: node.flipX, flipY: node.flipY }\n // Unmirrored, the angle and flips stay exactly as they were; only the position follows.\n return mirrorX || mirrorY\n ? { ...local, width, height }\n : {\n x: local.x,\n y: local.y,\n width,\n height,\n rotation: node.rotation,\n flipX: node.flipX,\n flipY: node.flipY\n }\n}\n\n/**\n * Where a layer lands, in its parent's space, when a multi-selection turns `degrees` about a\n * canvas pivot, as Figma rotates a selection about its bounds' center: the layer's center swings\n * around the pivot and the layer itself turns by the same angle on the canvas.\n */\nexport function placeRotatedAbout(\n placement: SelectionPlacement,\n pivot: Vector,\n degrees: number\n): { x: number; y: number; rotation: number } {\n const { node, center, direction, parentInverse } = placement\n const radians = (degrees * Math.PI) / 180\n const cos = Math.cos(radians)\n const sin = Math.sin(radians)\n const dx = center.x - pivot.x\n const dy = center.y - pivot.y\n const target = { x: pivot.x + dx * cos - dy * sin, y: pivot.y + dx * sin + dy * cos }\n const turned = node.rotation + degrees * direction\n const rotation = ((((turned + 180) % 360) + 360) % 360) - 180\n return { ...positionCenteredAt({ ...node, rotation }, parentInverse, target), rotation }\n}\n"],"mappings":";;;AAMA,SAAgB,eAAe,MAAiB,OAA0C;CACxF,MAAM,QAAqB,CAAC;CAC5B,IAAI,UAAiC;CAErC,OAAO,SAAS;EACd,MAAM,QAAQ,OAAO;EACrB,IAAI,CAAC,QAAQ,UAAU;EACvB,UAAU,MAAM,QAAQ,QAAQ,QAAQ;CAC1C;CAEA,IAAI,SAAS,OAAO,SAAS;CAE7B,KAAK,MAAM,KAAK,OAAO;EACrB,MAAM,QAAQ,mBAAmB,CAAC;EAClC,SAAS,OAAO,SAAS,QAAQ,KAAK;CACxC;CAEA,OAAO;AACT;;AAGA,SAAS,eAAe,QAAiC;CACvD,IAAI,OAAO,WAAW,GAAG,OAAO;EAAE,GAAG;EAAG,GAAG;EAAG,OAAO;EAAG,QAAQ;CAAE;CAClE,IAAI,OAAO;CACX,IAAI,OAAO;CACX,IAAI,OAAO;CACX,IAAI,OAAO;CACX,KAAK,IAAI,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK,GAAG;EACzC,OAAO,KAAK,IAAI,MAAM,OAAO,EAAE;EAC/B,OAAO,KAAK,IAAI,MAAM,OAAO,IAAI,EAAE;EACnC,OAAO,KAAK,IAAI,MAAM,OAAO,EAAE;EAC/B,OAAO,KAAK,IAAI,MAAM,OAAO,IAAI,EAAE;CACrC;CACA,OAAO;EAAE,GAAG;EAAM,GAAG;EAAM,OAAO,OAAO;EAAM,QAAQ,OAAO;CAAK;AACrE;AAEA,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AAkB,QAAQ,4BAA4B;iBAatD,sBAAsB,UAAU,oBAAoB;;;;;;;;KAiBxD;iBAUI,eACd,KAAK,WACL,4BACA,OAAM,gBACL,QAAQ"}
package/dist/copy.js CHANGED
@@ -30,11 +30,18 @@ function copyStroke(s) {
30
30
  return copy;
31
31
  }
32
32
  function copyEffect(e) {
33
- return {
33
+ const copy = {
34
34
  ...e,
35
35
  color: { ...e.color },
36
36
  offset: { ...e.offset }
37
37
  };
38
+ if (e.glass) copy.glass = { ...e.glass };
39
+ if (e.progressive) copy.progressive = {
40
+ startRadius: e.progressive.startRadius,
41
+ startOffset: { ...e.progressive.startOffset },
42
+ endOffset: { ...e.progressive.endOffset }
43
+ };
44
+ return copy;
38
45
  }
39
46
  function copyStyleRun(r) {
40
47
  const copy = {
package/dist/copy.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"copy.js","names":[],"sources":["../src/copy.ts"],"sourcesContent":["/**\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 { readGeometryBlob } from './geometry'\nimport { cloneInstanceOverrideState } from './instances/overrides'\nimport { createDefaultSourceMetadata } from './node-defaults'\nimport type {\n ArcData,\n ComponentPropertyDefinition,\n ConnectorEndpoint,\n Effect,\n DerivedTextGlyph,\n Fill,\n GeometryPath,\n GradientStop,\n LayoutGrid,\n SceneNode,\n Stroke,\n StyleRun,\n VectorNetwork,\n VectorRegion\n} from './types'\n\n// --- Individual copy functions ---\n\n/** Generic over the paint shape so a stroke keeps its own fields while the paint deep-copies. */\nexport function copyFill<T extends Fill>(f: T): T {\n const copy: T = { ...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 = copyFill(s)\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 const copy: StyleRun = {\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 if (r.style.hyperlink) copy.style.hyperlink = { ...r.style.hyperlink }\n if (r.style.lineHeight) copy.style.lineHeight = { ...r.style.lineHeight }\n if (r.style.letterSpacing) copy.style.letterSpacing = { ...r.style.letterSpacing }\n if (r.style.boundVariables) copy.style.boundVariables = { ...r.style.boundVariables }\n return copy\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\n/** A region, with new loops when given, keeping its own paints and fill style. */\nexport function copyVectorRegion(\n region: VectorRegion,\n loops = region.loops.map((loop) => [...loop])\n): VectorRegion {\n const copy: VectorRegion = { windingRule: region.windingRule, loops }\n if (region.fills) copy.fills = copyFills(region.fills)\n if (region.fillStyleId) copy.fillStyleId = region.fillStyleId\n return copy\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) => copyVectorRegion(r))\n }\n}\n\nexport function copyGeometryPaths(paths: GeometryPath[]): GeometryPath[] {\n return paths.map((p) => ({ windingRule: p.windingRule, commandsBlob: p.commandsBlob.slice() }))\n}\n\n/**\n * Affine-transform every coordinate pair in a path command blob (returns a\n * copy): (x, y) → (m00·x + m01·y + tx, m10·x + m11·y + ty).\n * Command layout: 1=move/2=line (1 pair), 3=quad (2 pairs), 4=cubic (3 pairs)\n * — font-glyph blobs are quad-heavy, so skipping command 3 desyncs the walk.\n */\nexport function transformGeometryBlob(\n blob: Uint8Array,\n m00: number,\n m01: number,\n m10: number,\n m11: number,\n tx = 0,\n ty = 0\n): Uint8Array {\n const out = blob.slice()\n const view = new DataView(out.buffer, out.byteOffset, out.byteLength)\n readGeometryBlob(out, (_, coords, offset) => {\n for (let i = 0; i < coords.length; i += 2) {\n const x = coords[i]\n const y = coords[i + 1]\n view.setFloat32(offset + i * 4, m00 * x + m01 * y + tx, true)\n view.setFloat32(offset + i * 4 + 4, m10 * x + m11 * y + ty, true)\n }\n })\n return out\n}\n\nexport function transformGeometryPaths(\n paths: GeometryPath[],\n m00: number,\n m01: number,\n m10: number,\n m11: number,\n tx = 0,\n ty = 0\n): GeometryPath[] {\n return paths.map((g) => ({\n windingRule: g.windingRule,\n commandsBlob: transformGeometryBlob(g.commandsBlob, m00, m01, m10, m11, tx, ty)\n }))\n}\n\n/**\n * Scale path command blob coordinates by (sx, sy).\n * Identity scale returns a deep copy (same as copyGeometryPaths).\n */\nexport function scaleGeometryPaths(paths: GeometryPath[], sx: number, sy: number): GeometryPath[] {\n if (sx === 1 && sy === 1) return copyGeometryPaths(paths)\n return transformGeometryPaths(paths, sx, 0, 0, sy)\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 slotSettings: d.slotSettings ? { ...d.slotSettings } : undefined\n })) ?? []\n )\n}\n\n/** Deep-copy path-text glyphs (fresh commandsBlob buffers). */\nexport function copyDerivedGlyphs(glyphs: DerivedTextGlyph[] | null): DerivedTextGlyph[] | null {\n return glyphs\n ? glyphs.map((g) => ({\n ...g,\n commandsBlob: new Uint8Array(g.commandsBlob),\n ...(g.emojiCodePoints ? { emojiCodePoints: [...g.emojiCodePoints] } : {})\n }))\n : null\n}\n\n// --- Complex structure copy functions ---\n// These replace structuredClone for known types, avoiding its ~24× overhead.\n\nexport function copyConnectorEndpoint(endpoint: ConnectorEndpoint): ConnectorEndpoint {\n return { ...endpoint, position: { ...endpoint.position } }\n}\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\n/** A text's line height and letter spacing, copied so a clone never shares them. */\nfunction copyTextLengths(src: SceneNode): Pick<SceneNode, 'lineHeight' | 'letterSpacing'> {\n return {\n lineHeight: src.lineHeight && { ...src.lineHeight },\n letterSpacing: { ...src.letterSpacing }\n }\n}\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 variableBindingScales: { ...src.variableBindingScales },\n variableAssignmentScales: { ...src.variableAssignmentScales },\n variableModes: { ...src.variableModes },\n instanceOverrides: cloneInstanceOverrideState(src.instanceOverrides),\n componentPropertyAssignments: { ...src.componentPropertyAssignments },\n\n componentPropertyValues: { ...src.componentPropertyValues }\n }\n }\n return {\n ...rest,\n ...(componentId !== null ? { componentId } : {}),\n boundVariables: { ...src.boundVariables },\n variableBindingScales: { ...src.variableBindingScales },\n variableAssignmentScales: { ...src.variableAssignmentScales },\n variableModes: { ...src.variableModes },\n instanceOverrides: cloneInstanceOverrideState(src.instanceOverrides),\n fills: copyOpt(src.fills, (value) => markCopySource(value, copyFills(value))),\n\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 guides: copyOpt(src.guides, (guides) => guides.map((guide) => ({ ...guide }))),\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 ...copyTextLengths(src),\n fontFeatures: copyOpt(src.fontFeatures, (a) => a.map((v) => ({ ...v }))),\n textParagraphs: copyOpt(src.textParagraphs, (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 // Generated instance descendants have no status of their own.\n status: componentId === null ? src.status : null,\n componentPropertyValues: { ...src.componentPropertyValues },\n derivedLayout: src.derivedLayout ? { ...src.derivedLayout } : 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 derivedTextGlyphs: src.derivedTextGlyphs\n ? markCopySource(src.derivedTextGlyphs, copyDerivedGlyphs(src.derivedTextGlyphs) ?? [])\n : null,\n textPathData: src.textPathData ? structuredClone(src.textPathData) : null,\n textPathBox: src.textPathBox ? { ...src.textPathBox } : null,\n gridPosition: src.gridPosition ? { ...src.gridPosition } : null,\n targetAspectRatio: src.targetAspectRatio ? { ...src.targetAspectRatio } : null,\n connectorStart: src.connectorStart ? copyConnectorEndpoint(src.connectorStart) : null,\n connectorEnd: src.connectorEnd ? copyConnectorEndpoint(src.connectorEnd) : null,\n connectorControlPoints: structuredClone(src.connectorControlPoints),\n connectorCurveHandles: structuredClone(src.connectorCurveHandles),\n connectorLabelPosition: src.connectorLabelPosition ? { ...src.connectorLabelPosition } : null\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAiCA,SAAgB,SAAyB,GAAS;CAChD,MAAM,OAAU;EAAE,GAAG;EAAG,OAAO,EAAE,GAAG,EAAE,MAAM;CAAE;CAC9C,IAAI,EAAE,eAAe,KAAK,gBAAgB,EAAE,cAAc,IAAI,gBAAgB;CAC9E,IAAI,EAAE,mBAAmB,KAAK,oBAAoB,EAAE,GAAG,EAAE,kBAAkB;CAC3E,IAAI,EAAE,gBAAgB,KAAK,iBAAiB,EAAE,GAAG,EAAE,eAAe;CAClE,IAAI,EAAE,gBAAgB,KAAK,iBAAiB,EAAE,GAAG,EAAE,eAAe;CAClE,IAAI,EAAE,WAAW,KAAK,YAAY,EAAE,GAAG,EAAE,UAAU;CACnD,OAAO;AACT;AAEA,SAAgB,WAAW,GAAmB;CAC5C,MAAM,OAAO,SAAS,CAAC;CACvB,IAAI,EAAE,aACJ,KAAK,cAAc,CAAC,GAAG,EAAE,WAAW;CAEtC,OAAO;AACT;AAEA,SAAgB,WAAW,GAAmB;CAC5C,OAAO;EACL,GAAG;EACH,OAAO,EAAE,GAAG,EAAE,MAAM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vE,8BAA8B,EAAE,GAAG,IAAI,6BAA6B;EACpE,aAAa,WAAW,IAAI,WAAW;EACvC,kBAAkB,WAAW,IAAI,gBAAgB;EACjD,YAAY,WAAW,IAAI,UAAU;EACrC,oBAAoB,WAAW,IAAI,kBAAkB;EACrD,gBAAgB,WAAW,IAAI,cAAc;EAE7C,QAAQ,gBAAgB,OAAO,IAAI,SAAS;EAC5C,yBAAyB,EAAE,GAAG,IAAI,wBAAwB;EAC1D,eAAe,IAAI,gBAAgB,EAAE,GAAG,IAAI,cAAc,IAAI;EAC9D,SAAS,IAAI,UAAU,YAAY,IAAI,OAAO,IAAI;EAClD,eAAe,IAAI,gBAAgB,mBAAmB,IAAI,aAAa,IAAI;EAC3E,aAAa,IAAI,cAAc,IAAI,WAAW,IAAI,WAAW,IAAI;EACjE,mBAAmB,IAAI,oBACnB,eAAe,IAAI,mBAAmB,kBAAkB,IAAI,iBAAiB,KAAK,CAAC,CAAC,IACpF;EACJ,cAAc,IAAI,eAAe,gBAAgB,IAAI,YAAY,IAAI;EACrE,aAAa,IAAI,cAAc,EAAE,GAAG,IAAI,YAAY,IAAI;EACxD,cAAc,IAAI,eAAe,EAAE,GAAG,IAAI,aAAa,IAAI;EAC3D,mBAAmB,IAAI,oBAAoB,EAAE,GAAG,IAAI,kBAAkB,IAAI;EAC1E,gBAAgB,IAAI,iBAAiB,sBAAsB,IAAI,cAAc,IAAI;EACjF,cAAc,IAAI,eAAe,sBAAsB,IAAI,YAAY,IAAI;EAC3E,wBAAwB,gBAAgB,IAAI,sBAAsB;EAClE,uBAAuB,gBAAgB,IAAI,qBAAqB;EAChE,wBAAwB,IAAI,yBAAyB,EAAE,GAAG,IAAI,uBAAuB,IAAI;CAC3F;AACF"}
1
+ {"version":3,"file":"copy.js","names":[],"sources":["../src/copy.ts"],"sourcesContent":["/**\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 { readGeometryBlob } from './geometry'\nimport { cloneInstanceOverrideState } from './instances/overrides'\nimport { createDefaultSourceMetadata } from './node-defaults'\nimport type {\n ArcData,\n ComponentPropertyDefinition,\n ConnectorEndpoint,\n Effect,\n DerivedTextGlyph,\n Fill,\n GeometryPath,\n GradientStop,\n LayoutGrid,\n SceneNode,\n Stroke,\n StyleRun,\n VectorNetwork,\n VectorRegion\n} from './types'\n\n// --- Individual copy functions ---\n\n/** Generic over the paint shape so a stroke keeps its own fields while the paint deep-copies. */\nexport function copyFill<T extends Fill>(f: T): T {\n const copy: T = { ...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 = copyFill(s)\n if (s.dashPattern) {\n copy.dashPattern = [...s.dashPattern]\n }\n return copy\n}\n\nexport function copyEffect(e: Effect): Effect {\n const copy: Effect = { ...e, color: { ...e.color }, offset: { ...e.offset } }\n if (e.glass) copy.glass = { ...e.glass }\n if (e.progressive) {\n copy.progressive = {\n startRadius: e.progressive.startRadius,\n startOffset: { ...e.progressive.startOffset },\n endOffset: { ...e.progressive.endOffset }\n }\n }\n return copy\n}\n\nexport function copyStyleRun(r: StyleRun): StyleRun {\n const copy: StyleRun = {\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 if (r.style.hyperlink) copy.style.hyperlink = { ...r.style.hyperlink }\n if (r.style.lineHeight) copy.style.lineHeight = { ...r.style.lineHeight }\n if (r.style.letterSpacing) copy.style.letterSpacing = { ...r.style.letterSpacing }\n if (r.style.boundVariables) copy.style.boundVariables = { ...r.style.boundVariables }\n return copy\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\n/** A region, with new loops when given, keeping its own paints and fill style. */\nexport function copyVectorRegion(\n region: VectorRegion,\n loops = region.loops.map((loop) => [...loop])\n): VectorRegion {\n const copy: VectorRegion = { windingRule: region.windingRule, loops }\n if (region.fills) copy.fills = copyFills(region.fills)\n if (region.fillStyleId) copy.fillStyleId = region.fillStyleId\n return copy\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) => copyVectorRegion(r))\n }\n}\n\nexport function copyGeometryPaths(paths: GeometryPath[]): GeometryPath[] {\n return paths.map((p) => ({ windingRule: p.windingRule, commandsBlob: p.commandsBlob.slice() }))\n}\n\n/**\n * Affine-transform every coordinate pair in a path command blob (returns a\n * copy): (x, y) → (m00·x + m01·y + tx, m10·x + m11·y + ty).\n * Command layout: 1=move/2=line (1 pair), 3=quad (2 pairs), 4=cubic (3 pairs)\n * — font-glyph blobs are quad-heavy, so skipping command 3 desyncs the walk.\n */\nexport function transformGeometryBlob(\n blob: Uint8Array,\n m00: number,\n m01: number,\n m10: number,\n m11: number,\n tx = 0,\n ty = 0\n): Uint8Array {\n const out = blob.slice()\n const view = new DataView(out.buffer, out.byteOffset, out.byteLength)\n readGeometryBlob(out, (_, coords, offset) => {\n for (let i = 0; i < coords.length; i += 2) {\n const x = coords[i]\n const y = coords[i + 1]\n view.setFloat32(offset + i * 4, m00 * x + m01 * y + tx, true)\n view.setFloat32(offset + i * 4 + 4, m10 * x + m11 * y + ty, true)\n }\n })\n return out\n}\n\nexport function transformGeometryPaths(\n paths: GeometryPath[],\n m00: number,\n m01: number,\n m10: number,\n m11: number,\n tx = 0,\n ty = 0\n): GeometryPath[] {\n return paths.map((g) => ({\n windingRule: g.windingRule,\n commandsBlob: transformGeometryBlob(g.commandsBlob, m00, m01, m10, m11, tx, ty)\n }))\n}\n\n/**\n * Scale path command blob coordinates by (sx, sy).\n * Identity scale returns a deep copy (same as copyGeometryPaths).\n */\nexport function scaleGeometryPaths(paths: GeometryPath[], sx: number, sy: number): GeometryPath[] {\n if (sx === 1 && sy === 1) return copyGeometryPaths(paths)\n return transformGeometryPaths(paths, sx, 0, 0, sy)\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 slotSettings: d.slotSettings ? { ...d.slotSettings } : undefined\n })) ?? []\n )\n}\n\n/** Deep-copy path-text glyphs (fresh commandsBlob buffers). */\nexport function copyDerivedGlyphs(glyphs: DerivedTextGlyph[] | null): DerivedTextGlyph[] | null {\n return glyphs\n ? glyphs.map((g) => ({\n ...g,\n commandsBlob: new Uint8Array(g.commandsBlob),\n ...(g.emojiCodePoints ? { emojiCodePoints: [...g.emojiCodePoints] } : {})\n }))\n : null\n}\n\n// --- Complex structure copy functions ---\n// These replace structuredClone for known types, avoiding its ~24× overhead.\n\nexport function copyConnectorEndpoint(endpoint: ConnectorEndpoint): ConnectorEndpoint {\n return { ...endpoint, position: { ...endpoint.position } }\n}\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\n/** A text's line height and letter spacing, copied so a clone never shares them. */\nfunction copyTextLengths(src: SceneNode): Pick<SceneNode, 'lineHeight' | 'letterSpacing'> {\n return {\n lineHeight: src.lineHeight && { ...src.lineHeight },\n letterSpacing: { ...src.letterSpacing }\n }\n}\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 variableBindingScales: { ...src.variableBindingScales },\n variableAssignmentScales: { ...src.variableAssignmentScales },\n variableModes: { ...src.variableModes },\n instanceOverrides: cloneInstanceOverrideState(src.instanceOverrides),\n componentPropertyAssignments: { ...src.componentPropertyAssignments },\n\n componentPropertyValues: { ...src.componentPropertyValues }\n }\n }\n return {\n ...rest,\n ...(componentId !== null ? { componentId } : {}),\n boundVariables: { ...src.boundVariables },\n variableBindingScales: { ...src.variableBindingScales },\n variableAssignmentScales: { ...src.variableAssignmentScales },\n variableModes: { ...src.variableModes },\n instanceOverrides: cloneInstanceOverrideState(src.instanceOverrides),\n fills: copyOpt(src.fills, (value) => markCopySource(value, copyFills(value))),\n\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 guides: copyOpt(src.guides, (guides) => guides.map((guide) => ({ ...guide }))),\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 ...copyTextLengths(src),\n fontFeatures: copyOpt(src.fontFeatures, (a) => a.map((v) => ({ ...v }))),\n textParagraphs: copyOpt(src.textParagraphs, (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 // Generated instance descendants have no status of their own.\n status: componentId === null ? src.status : null,\n componentPropertyValues: { ...src.componentPropertyValues },\n derivedLayout: src.derivedLayout ? { ...src.derivedLayout } : 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 derivedTextGlyphs: src.derivedTextGlyphs\n ? markCopySource(src.derivedTextGlyphs, copyDerivedGlyphs(src.derivedTextGlyphs) ?? [])\n : null,\n textPathData: src.textPathData ? structuredClone(src.textPathData) : null,\n textPathBox: src.textPathBox ? { ...src.textPathBox } : null,\n gridPosition: src.gridPosition ? { ...src.gridPosition } : null,\n targetAspectRatio: src.targetAspectRatio ? { ...src.targetAspectRatio } : null,\n connectorStart: src.connectorStart ? copyConnectorEndpoint(src.connectorStart) : null,\n connectorEnd: src.connectorEnd ? copyConnectorEndpoint(src.connectorEnd) : null,\n connectorControlPoints: structuredClone(src.connectorControlPoints),\n connectorCurveHandles: structuredClone(src.connectorCurveHandles),\n connectorLabelPosition: src.connectorLabelPosition ? { ...src.connectorLabelPosition } : null\n }\n}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BAAgB,EAAE,GAAG,IAAI,cAAc,IAAI;EAC9D,SAAS,IAAI,UAAU,YAAY,IAAI,OAAO,IAAI;EAClD,eAAe,IAAI,gBAAgB,mBAAmB,IAAI,aAAa,IAAI;EAC3E,aAAa,IAAI,cAAc,IAAI,WAAW,IAAI,WAAW,IAAI;EACjE,mBAAmB,IAAI,oBACnB,eAAe,IAAI,mBAAmB,kBAAkB,IAAI,iBAAiB,KAAK,CAAC,CAAC,IACpF;EACJ,cAAc,IAAI,eAAe,gBAAgB,IAAI,YAAY,IAAI;EACrE,aAAa,IAAI,cAAc,EAAE,GAAG,IAAI,YAAY,IAAI;EACxD,cAAc,IAAI,eAAe,EAAE,GAAG,IAAI,aAAa,IAAI;EAC3D,mBAAmB,IAAI,oBAAoB,EAAE,GAAG,IAAI,kBAAkB,IAAI;EAC1E,gBAAgB,IAAI,iBAAiB,sBAAsB,IAAI,cAAc,IAAI;EACjF,cAAc,IAAI,eAAe,sBAAsB,IAAI,YAAY,IAAI;EAC3E,wBAAwB,gBAAgB,IAAI,sBAAsB;EAClE,uBAAuB,gBAAgB,IAAI,qBAAqB;EAChE,wBAAwB,IAAI,yBAAyB,EAAE,GAAG,IAAI,uBAAuB,IAAI;CAC3F;AACF"}
@@ -2,6 +2,7 @@ import { CSS_BLEND_MODE } from "./blend.js";
2
2
  import { parseCSSGridTracks } from "./grid.js";
3
3
  import { parseCSSAlignItems, parseCSSAlignSelf, parseCSSFlexDirection, parseCSSJustifyContent } from "./layout.js";
4
4
  import { parseCSSShadows } from "./shadows.js";
5
- import { parseCSSFontFamily, parseCSSLetterSpacing, parseCSSLineHeight } from "./text.js";
5
+ import { CSSFontFamily, CSS_GENERIC_FONT_FAMILIES, cssFontFamilyName, parseCSSFontFamilies, parseCSSFontFamily, parseCSSLetterSpacing, parseCSSLineHeight, resolveCSSFontFamily } from "./text.js";
6
+ import { CSSTransformBox, CSSTransformStyle, parseCSSTransform, parseCSSTransformOrigin, parseCSSTransforms } from "./transform.js";
6
7
  import { parseCSSColor, parseCSSNumber, splitCSSValue } from "./values.js";
7
- export { CSS_BLEND_MODE, parseCSSAlignItems, parseCSSAlignSelf, parseCSSColor, parseCSSFlexDirection, parseCSSFontFamily, parseCSSGridTracks, parseCSSJustifyContent, parseCSSLetterSpacing, parseCSSLineHeight, parseCSSNumber, parseCSSShadows, splitCSSValue };
8
+ export { type CSSFontFamily, type CSSTransformBox, type CSSTransformStyle, CSS_BLEND_MODE, CSS_GENERIC_FONT_FAMILIES, cssFontFamilyName, parseCSSAlignItems, parseCSSAlignSelf, parseCSSColor, parseCSSFlexDirection, parseCSSFontFamilies, parseCSSFontFamily, parseCSSGridTracks, parseCSSJustifyContent, parseCSSLetterSpacing, parseCSSLineHeight, parseCSSNumber, parseCSSShadows, parseCSSTransform, parseCSSTransformOrigin, parseCSSTransforms, resolveCSSFontFamily, splitCSSValue };
package/dist/css/index.js CHANGED
@@ -3,5 +3,6 @@ import { parseCSSColor, parseCSSNumber, splitCSSValue } from "./values.js";
3
3
  import { parseCSSGridTracks } from "./grid.js";
4
4
  import { parseCSSAlignItems, parseCSSAlignSelf, parseCSSFlexDirection, parseCSSJustifyContent } from "./layout.js";
5
5
  import { parseCSSShadows } from "./shadows.js";
6
- import { parseCSSFontFamily, parseCSSLetterSpacing, parseCSSLineHeight } from "./text.js";
7
- export { CSS_BLEND_MODE, parseCSSAlignItems, parseCSSAlignSelf, parseCSSColor, parseCSSFlexDirection, parseCSSFontFamily, parseCSSGridTracks, parseCSSJustifyContent, parseCSSLetterSpacing, parseCSSLineHeight, parseCSSNumber, parseCSSShadows, splitCSSValue };
6
+ import { CSS_GENERIC_FONT_FAMILIES, cssFontFamilyName, parseCSSFontFamilies, parseCSSFontFamily, parseCSSLetterSpacing, parseCSSLineHeight, resolveCSSFontFamily } from "./text.js";
7
+ import { parseCSSTransform, parseCSSTransformOrigin, parseCSSTransforms } from "./transform.js";
8
+ export { CSS_BLEND_MODE, CSS_GENERIC_FONT_FAMILIES, cssFontFamilyName, parseCSSAlignItems, parseCSSAlignSelf, parseCSSColor, parseCSSFlexDirection, parseCSSFontFamilies, parseCSSFontFamily, parseCSSGridTracks, parseCSSJustifyContent, parseCSSLetterSpacing, parseCSSLineHeight, parseCSSNumber, parseCSSShadows, parseCSSTransform, parseCSSTransformOrigin, parseCSSTransforms, resolveCSSFontFamily, splitCSSValue };