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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (986) hide show
  1. package/dist/arrow-caps.d.ts +14 -17
  2. package/dist/arrow-caps.d.ts.map +1 -1
  3. package/dist/arrow-caps.js +1 -2
  4. package/dist/asset-keys.d.ts +5 -8
  5. package/dist/asset-keys.d.ts.map +1 -1
  6. package/dist/asset-keys.js +2 -3
  7. package/dist/behaviours/index.d.ts +6 -4
  8. package/dist/behaviours/index.js +6 -4
  9. package/dist/behaviours/kinds.d.ts +38 -15
  10. package/dist/behaviours/kinds.d.ts.map +1 -1
  11. package/dist/behaviours/kinds.js +134 -12
  12. package/dist/behaviours/kinds.js.map +1 -1
  13. package/dist/behaviours/layers.d.ts +3 -6
  14. package/dist/behaviours/layers.d.ts.map +1 -1
  15. package/dist/behaviours/layers.js +1 -2
  16. package/dist/behaviours/listing.d.ts +58 -0
  17. package/dist/behaviours/listing.d.ts.map +1 -0
  18. package/dist/behaviours/listing.js +98 -0
  19. package/dist/behaviours/listing.js.map +1 -0
  20. package/dist/behaviours/model.d.ts +19 -16
  21. package/dist/behaviours/model.d.ts.map +1 -1
  22. package/dist/behaviours/model.js +14 -6
  23. package/dist/behaviours/model.js.map +1 -1
  24. package/dist/behaviours/schema.d.ts +150 -17
  25. package/dist/behaviours/schema.d.ts.map +1 -1
  26. package/dist/behaviours/schema.js +19 -5
  27. package/dist/behaviours/schema.js.map +1 -1
  28. package/dist/behaviours/spec.d.ts +3 -6
  29. package/dist/behaviours/spec.d.ts.map +1 -1
  30. package/dist/behaviours/spec.js +7 -4
  31. package/dist/behaviours/spec.js.map +1 -1
  32. package/dist/behaviours/transition.d.ts +20 -0
  33. package/dist/behaviours/transition.d.ts.map +1 -0
  34. package/dist/behaviours/transition.js +35 -0
  35. package/dist/behaviours/transition.js.map +1 -0
  36. package/dist/bindings.js +2 -3
  37. package/dist/blur.d.ts +35 -0
  38. package/dist/blur.d.ts.map +1 -0
  39. package/dist/blur.js +69 -0
  40. package/dist/blur.js.map +1 -0
  41. package/dist/buffered-events.d.ts +3 -6
  42. package/dist/buffered-events.d.ts.map +1 -1
  43. package/dist/buffered-events.js +1 -2
  44. package/dist/buffered-events.js.map +1 -1
  45. package/dist/checkpoint.d.ts +3 -6
  46. package/dist/checkpoint.d.ts.map +1 -1
  47. package/dist/checkpoint.js +4 -3
  48. package/dist/checkpoint.js.map +1 -1
  49. package/dist/clipping.d.ts +4 -7
  50. package/dist/clipping.d.ts.map +1 -1
  51. package/dist/clipping.js +4 -16
  52. package/dist/clipping.js.map +1 -1
  53. package/dist/color/contrast.d.ts +4 -7
  54. package/dist/color/contrast.d.ts.map +1 -1
  55. package/dist/color/contrast.js +2 -3
  56. package/dist/color/index.d.ts +21 -20
  57. package/dist/color/index.d.ts.map +1 -1
  58. package/dist/color/index.js +16 -27
  59. package/dist/color/index.js.map +1 -1
  60. package/dist/color/management.d.ts +50 -25
  61. package/dist/color/management.d.ts.map +1 -1
  62. package/dist/color/management.js +155 -151
  63. package/dist/color/management.js.map +1 -1
  64. package/dist/color/normalize.d.ts +1 -4
  65. package/dist/color/normalize.d.ts.map +1 -1
  66. package/dist/color/normalize.js +1 -2
  67. package/dist/color/okhcl.d.ts +36 -21
  68. package/dist/color/okhcl.d.ts.map +1 -1
  69. package/dist/color/okhcl.js +57 -42
  70. package/dist/color/okhcl.js.map +1 -1
  71. package/dist/color/schema.d.ts +6 -4
  72. package/dist/color/schema.d.ts.map +1 -1
  73. package/dist/color/schema.js +12 -4
  74. package/dist/color/schema.js.map +1 -1
  75. package/dist/comments/document.d.ts +3 -6
  76. package/dist/comments/document.d.ts.map +1 -1
  77. package/dist/comments/document.js +1 -2
  78. package/dist/comments/index.js +2 -2
  79. package/dist/comments/list.d.ts +5 -8
  80. package/dist/comments/list.d.ts.map +1 -1
  81. package/dist/comments/list.js +1 -2
  82. package/dist/comments/merge.d.ts +2 -5
  83. package/dist/comments/merge.d.ts.map +1 -1
  84. package/dist/comments/merge.js +1 -2
  85. package/dist/comments/schema.d.ts +2 -5
  86. package/dist/comments/schema.d.ts.map +1 -1
  87. package/dist/comments/schema.js +1 -2
  88. package/dist/comments/threads.d.ts +16 -19
  89. package/dist/comments/threads.d.ts.map +1 -1
  90. package/dist/comments/threads.js +8 -3
  91. package/dist/comments/threads.js.map +1 -1
  92. package/dist/components/exposure.d.ts +4 -7
  93. package/dist/components/exposure.d.ts.map +1 -1
  94. package/dist/components/exposure.js +1 -2
  95. package/dist/components/properties.d.ts +13 -16
  96. package/dist/components/properties.d.ts.map +1 -1
  97. package/dist/components/properties.js +3 -4
  98. package/dist/components/variants.d.ts +5 -8
  99. package/dist/components/variants.d.ts.map +1 -1
  100. package/dist/components/variants.js +1 -2
  101. package/dist/connectors/controls.d.ts +6 -9
  102. package/dist/connectors/controls.d.ts.map +1 -1
  103. package/dist/connectors/controls.js +2 -3
  104. package/dist/connectors/create.d.ts +3 -6
  105. package/dist/connectors/create.d.ts.map +1 -1
  106. package/dist/connectors/create.js +2 -3
  107. package/dist/connectors/elbow.js +0 -1
  108. package/dist/connectors/gaps.d.ts +1 -4
  109. package/dist/connectors/gaps.d.ts.map +1 -1
  110. package/dist/connectors/gaps.js +1 -2
  111. package/dist/connectors/hit.d.ts +1 -4
  112. package/dist/connectors/hit.d.ts.map +1 -1
  113. package/dist/connectors/hit.js +3 -4
  114. package/dist/connectors/index.d.ts +3 -3
  115. package/dist/connectors/index.js +6 -6
  116. package/dist/connectors/label.d.ts +4 -7
  117. package/dist/connectors/label.d.ts.map +1 -1
  118. package/dist/connectors/label.js +1 -2
  119. package/dist/connectors/layout.d.ts +8 -10
  120. package/dist/connectors/layout.d.ts.map +1 -1
  121. package/dist/connectors/layout.js +12 -10
  122. package/dist/connectors/layout.js.map +1 -1
  123. package/dist/connectors/pieces.d.ts +2 -5
  124. package/dist/connectors/pieces.d.ts.map +1 -1
  125. package/dist/connectors/pieces.js +3 -4
  126. package/dist/connectors/pieces.js.map +1 -1
  127. package/dist/connectors/route.d.ts +2 -5
  128. package/dist/connectors/route.d.ts.map +1 -1
  129. package/dist/connectors/route.js +4 -5
  130. package/dist/connectors/sides.d.ts +3 -6
  131. package/dist/connectors/sides.d.ts.map +1 -1
  132. package/dist/connectors/sides.js +2 -3
  133. package/dist/connectors/sublayers.d.ts +21 -24
  134. package/dist/connectors/sublayers.d.ts.map +1 -1
  135. package/dist/connectors/sublayers.js +3 -3
  136. package/dist/connectors/sublayers.js.map +1 -1
  137. package/dist/constants.d.ts +13 -16
  138. package/dist/constants.d.ts.map +1 -1
  139. package/dist/constants.js +1 -2
  140. package/dist/constraints.d.ts +6 -8
  141. package/dist/constraints.d.ts.map +1 -1
  142. package/dist/constraints.js +3 -3
  143. package/dist/constraints.js.map +1 -1
  144. package/dist/coordinate.d.ts +27 -29
  145. package/dist/coordinate.d.ts.map +1 -1
  146. package/dist/coordinate.js +19 -38
  147. package/dist/coordinate.js.map +1 -1
  148. package/dist/copy.d.ts +36 -24
  149. package/dist/copy.d.ts.map +1 -1
  150. package/dist/copy.js +33 -4
  151. package/dist/copy.js.map +1 -1
  152. package/dist/corners.d.ts +9 -9
  153. package/dist/corners.d.ts.map +1 -1
  154. package/dist/corners.js +4 -3
  155. package/dist/corners.js.map +1 -1
  156. package/dist/css/blend.d.ts +1 -4
  157. package/dist/css/blend.d.ts.map +1 -1
  158. package/dist/css/blend.js +1 -2
  159. package/dist/css/grid.d.ts +1 -4
  160. package/dist/css/grid.d.ts.map +1 -1
  161. package/dist/css/grid.js +3 -4
  162. package/dist/css/index.d.ts +2 -1
  163. package/dist/css/index.js +3 -2
  164. package/dist/css/layout.d.ts +7 -10
  165. package/dist/css/layout.d.ts.map +1 -1
  166. package/dist/css/layout.js +2 -3
  167. package/dist/css/motion.d.ts +9 -0
  168. package/dist/css/motion.d.ts.map +1 -0
  169. package/dist/css/motion.js +59 -0
  170. package/dist/css/motion.js.map +1 -0
  171. package/dist/css/shadows.d.ts +4 -6
  172. package/dist/css/shadows.d.ts.map +1 -1
  173. package/dist/css/shadows.js +9 -9
  174. package/dist/css/shadows.js.map +1 -1
  175. package/dist/css/text.d.ts +8 -11
  176. package/dist/css/text.d.ts.map +1 -1
  177. package/dist/css/text.js +1 -2
  178. package/dist/css/transform.d.ts +6 -9
  179. package/dist/css/transform.d.ts.map +1 -1
  180. package/dist/css/transform.js +2 -3
  181. package/dist/css/values.d.ts +11 -13
  182. package/dist/css/values.d.ts.map +1 -1
  183. package/dist/css/values.js +5 -6
  184. package/dist/css/values.js.map +1 -1
  185. package/dist/cubic.d.ts +11 -5
  186. package/dist/cubic.d.ts.map +1 -1
  187. package/dist/cubic.js +71 -3
  188. package/dist/cubic.js.map +1 -1
  189. package/dist/events.js +1 -2
  190. package/dist/export-format.d.ts +5 -8
  191. package/dist/export-format.d.ts.map +1 -1
  192. package/dist/export-format.js +4 -3
  193. package/dist/export-format.js.map +1 -1
  194. package/dist/export-scale.d.ts +4 -7
  195. package/dist/export-scale.d.ts.map +1 -1
  196. package/dist/export-scale.js +1 -2
  197. package/dist/fields/appearance.d.ts +3 -6
  198. package/dist/fields/appearance.d.ts.map +1 -1
  199. package/dist/fields/appearance.js +1 -2
  200. package/dist/fields/geometry.d.ts +2 -5
  201. package/dist/fields/geometry.d.ts.map +1 -1
  202. package/dist/fields/geometry.js +1 -2
  203. package/dist/fields/index.d.ts +2 -2
  204. package/dist/fields/index.js +3 -3
  205. package/dist/fields/layout.d.ts +5 -6
  206. package/dist/fields/layout.d.ts.map +1 -1
  207. package/dist/fields/layout.js +10 -3
  208. package/dist/fields/layout.js.map +1 -1
  209. package/dist/fields/text.d.ts +5 -8
  210. package/dist/fields/text.d.ts.map +1 -1
  211. package/dist/fields/text.js +1 -2
  212. package/dist/fig-compression.d.ts +3 -6
  213. package/dist/fig-compression.d.ts.map +1 -1
  214. package/dist/fig-compression.js +1 -2
  215. package/dist/figjam/index.js +1 -1
  216. package/dist/figjam/palette.d.ts +21 -23
  217. package/dist/figjam/palette.d.ts.map +1 -1
  218. package/dist/figjam/palette.js +3 -4
  219. package/dist/figjam/text.d.ts +10 -13
  220. package/dist/figjam/text.d.ts.map +1 -1
  221. package/dist/figjam/text.js +1 -2
  222. package/dist/font-style.d.ts +18 -18
  223. package/dist/font-style.d.ts.map +1 -1
  224. package/dist/font-style.js +12 -8
  225. package/dist/font-style.js.map +1 -1
  226. package/dist/generated/index.d.ts +35 -15
  227. package/dist/generated/index.d.ts.map +1 -1
  228. package/dist/generated/index.js +50 -12
  229. package/dist/generated/index.js.map +1 -1
  230. package/dist/generated/kind.d.ts +17 -6
  231. package/dist/generated/kind.d.ts.map +1 -1
  232. package/dist/generated/shape-with-text.d.ts +10 -13
  233. package/dist/generated/shape-with-text.d.ts.map +1 -1
  234. package/dist/generated/shape-with-text.js +3 -3
  235. package/dist/generated/shape-with-text.js.map +1 -1
  236. package/dist/generated/spec.d.ts +45 -0
  237. package/dist/generated/spec.d.ts.map +1 -0
  238. package/dist/generated/spec.js +281 -0
  239. package/dist/generated/spec.js.map +1 -0
  240. package/dist/generated/sticky.d.ts +23 -26
  241. package/dist/generated/sticky.d.ts.map +1 -1
  242. package/dist/generated/sticky.js +4 -4
  243. package/dist/generated/sticky.js.map +1 -1
  244. package/dist/geometry.d.ts +47 -68
  245. package/dist/geometry.d.ts.map +1 -1
  246. package/dist/geometry.js +53 -77
  247. package/dist/geometry.js.map +1 -1
  248. package/dist/gradient.d.ts +15 -18
  249. package/dist/gradient.d.ts.map +1 -1
  250. package/dist/gradient.js +1 -2
  251. package/dist/graph.d.ts +33 -11
  252. package/dist/graph.d.ts.map +1 -1
  253. package/dist/graph.js +85 -28
  254. package/dist/graph.js.map +1 -1
  255. package/dist/group-bounds.d.ts +15 -14
  256. package/dist/group-bounds.d.ts.map +1 -1
  257. package/dist/group-bounds.js +41 -12
  258. package/dist/group-bounds.js.map +1 -1
  259. package/dist/guides.d.ts +5 -8
  260. package/dist/guides.d.ts.map +1 -1
  261. package/dist/guides.js +2 -3
  262. package/dist/hit-test.d.ts +20 -12
  263. package/dist/hit-test.d.ts.map +1 -1
  264. package/dist/hit-test.js +69 -38
  265. package/dist/hit-test.js.map +1 -1
  266. package/dist/icons/fit.d.ts +2 -4
  267. package/dist/icons/fit.d.ts.map +1 -1
  268. package/dist/icons/fit.js +1 -2
  269. package/dist/icons/glyph.d.ts +3 -5
  270. package/dist/icons/glyph.d.ts.map +1 -1
  271. package/dist/icons/glyph.js +3 -4
  272. package/dist/icons/index.d.ts +1 -1
  273. package/dist/icons/index.js +2 -2
  274. package/dist/icons/model.d.ts +8 -11
  275. package/dist/icons/model.d.ts.map +1 -1
  276. package/dist/icons/model.js +1 -2
  277. package/dist/icons/schema.d.ts +8 -11
  278. package/dist/icons/schema.d.ts.map +1 -1
  279. package/dist/icons/schema.js +1 -2
  280. package/dist/ids.d.ts +2 -5
  281. package/dist/ids.d.ts.map +1 -1
  282. package/dist/ids.js +3 -4
  283. package/dist/images.d.ts +20 -21
  284. package/dist/images.d.ts.map +1 -1
  285. package/dist/images.js +7 -6
  286. package/dist/images.js.map +1 -1
  287. package/dist/index.d.ts +2 -2
  288. package/dist/index.js +3 -3
  289. package/dist/instances/assignments.js +1 -2
  290. package/dist/instances/content-marks.js +98 -0
  291. package/dist/instances/content-marks.js.map +1 -0
  292. package/dist/instances/content-size.js +2 -3
  293. package/dist/instances/copies.js +2 -3
  294. package/dist/instances/cycles.d.ts +3 -6
  295. package/dist/instances/cycles.d.ts.map +1 -1
  296. package/dist/instances/cycles.js +1 -2
  297. package/dist/instances/deleted.d.ts +23 -0
  298. package/dist/instances/deleted.d.ts.map +1 -0
  299. package/dist/instances/deleted.js +82 -0
  300. package/dist/instances/deleted.js.map +1 -0
  301. package/dist/instances/fields.d.ts +5 -8
  302. package/dist/instances/fields.d.ts.map +1 -1
  303. package/dist/instances/fields.js +11 -7
  304. package/dist/instances/fields.js.map +1 -1
  305. package/dist/instances/index.d.ts +21 -20
  306. package/dist/instances/index.d.ts.map +1 -1
  307. package/dist/instances/index.js +116 -20
  308. package/dist/instances/index.js.map +1 -1
  309. package/dist/instances/kept-overrides.js +4 -5
  310. package/dist/instances/lookup.d.ts +17 -0
  311. package/dist/instances/lookup.d.ts.map +1 -0
  312. package/dist/instances/lookup.js +48 -0
  313. package/dist/instances/lookup.js.map +1 -0
  314. package/dist/instances/main-component.d.ts +2 -5
  315. package/dist/instances/main-component.d.ts.map +1 -1
  316. package/dist/instances/main-component.js +1 -2
  317. package/dist/instances/matching.js +1 -2
  318. package/dist/instances/overrides.d.ts +23 -26
  319. package/dist/instances/overrides.d.ts.map +1 -1
  320. package/dist/instances/overrides.js +1 -2
  321. package/dist/instances/placement.js +3 -4
  322. package/dist/instances/protection.js +3 -4
  323. package/dist/instances/source-walk.js +1 -2
  324. package/dist/instances/swap.js +7 -8
  325. package/dist/instances/sync.js +91 -18
  326. package/dist/instances/sync.js.map +1 -1
  327. package/dist/instances/vector-geometry.js +2 -3
  328. package/dist/layout/aspect-ratio.d.ts +7 -9
  329. package/dist/layout/aspect-ratio.d.ts.map +1 -1
  330. package/dist/layout/aspect-ratio.js +1 -2
  331. package/dist/layout/flow.d.ts +13 -0
  332. package/dist/layout/flow.d.ts.map +1 -0
  333. package/dist/layout/flow.js +35 -0
  334. package/dist/layout/flow.js.map +1 -0
  335. package/dist/layout/guides.d.ts +13 -16
  336. package/dist/layout/guides.d.ts.map +1 -1
  337. package/dist/layout/guides.js +4 -5
  338. package/dist/layout/guides.js.map +1 -1
  339. package/dist/layout/index.d.ts +6 -4
  340. package/dist/layout/index.js +7 -5
  341. package/dist/layout/keywords.d.ts +7 -9
  342. package/dist/layout/keywords.d.ts.map +1 -1
  343. package/dist/layout/keywords.js +8 -3
  344. package/dist/layout/keywords.js.map +1 -1
  345. package/dist/layout/limits.d.ts +13 -16
  346. package/dist/layout/limits.d.ts.map +1 -1
  347. package/dist/layout/limits.js +1 -2
  348. package/dist/layout/sizing.d.ts +18 -12
  349. package/dist/layout/sizing.d.ts.map +1 -1
  350. package/dist/layout/sizing.js +18 -3
  351. package/dist/layout/sizing.js.map +1 -1
  352. package/dist/layout/spacing.d.ts +7 -4
  353. package/dist/layout/spacing.d.ts.map +1 -1
  354. package/dist/layout/spacing.js +11 -3
  355. package/dist/layout/spacing.js.map +1 -1
  356. package/dist/layout/stacking.d.ts +8 -0
  357. package/dist/layout/stacking.d.ts.map +1 -0
  358. package/dist/layout/stacking.js +12 -0
  359. package/dist/layout/stacking.js.map +1 -0
  360. package/dist/layout/strokes.d.ts +1 -4
  361. package/dist/layout/strokes.d.ts.map +1 -1
  362. package/dist/layout/strokes.js +1 -2
  363. package/dist/layout/writes.js +1 -2
  364. package/dist/layout/writes.js.map +1 -1
  365. package/dist/masks.d.ts +4 -7
  366. package/dist/masks.d.ts.map +1 -1
  367. package/dist/masks.js +1 -2
  368. package/dist/matrix.d.ts +3 -4
  369. package/dist/matrix.d.ts.map +1 -1
  370. package/dist/matrix.js +11 -3
  371. package/dist/matrix.js.map +1 -1
  372. package/dist/mesh/geometry.d.ts +80 -0
  373. package/dist/mesh/geometry.d.ts.map +1 -0
  374. package/dist/mesh/geometry.js +430 -0
  375. package/dist/mesh/geometry.js.map +1 -0
  376. package/dist/mesh/index.d.ts +4 -0
  377. package/dist/mesh/index.js +4 -0
  378. package/dist/mesh/model.d.ts +25 -0
  379. package/dist/mesh/model.d.ts.map +1 -0
  380. package/dist/mesh/model.js +39 -0
  381. package/dist/mesh/model.js.map +1 -0
  382. package/dist/mesh/schema.d.ts +188 -0
  383. package/dist/mesh/schema.d.ts.map +1 -0
  384. package/dist/mesh/schema.js +55 -0
  385. package/dist/mesh/schema.js.map +1 -0
  386. package/dist/motion/apply.d.ts +42 -0
  387. package/dist/motion/apply.d.ts.map +1 -0
  388. package/dist/motion/apply.js +98 -0
  389. package/dist/motion/apply.js.map +1 -0
  390. package/dist/motion/edit.d.ts +53 -0
  391. package/dist/motion/edit.d.ts.map +1 -0
  392. package/dist/motion/edit.js +125 -0
  393. package/dist/motion/edit.js.map +1 -0
  394. package/dist/motion/effects.js +86 -0
  395. package/dist/motion/effects.js.map +1 -0
  396. package/dist/motion/evaluate.d.ts +33 -0
  397. package/dist/motion/evaluate.d.ts.map +1 -0
  398. package/dist/motion/evaluate.js +160 -0
  399. package/dist/motion/evaluate.js.map +1 -0
  400. package/dist/motion/fields.d.ts +69 -0
  401. package/dist/motion/fields.d.ts.map +1 -0
  402. package/dist/motion/fields.js +132 -0
  403. package/dist/motion/fields.js.map +1 -0
  404. package/dist/motion/index.d.ts +16 -0
  405. package/dist/motion/index.js +15 -0
  406. package/dist/motion/keyable.d.ts +32 -0
  407. package/dist/motion/keyable.d.ts.map +1 -0
  408. package/dist/motion/keyable.js +120 -0
  409. package/dist/motion/keyable.js.map +1 -0
  410. package/dist/motion/outline.d.ts +35 -0
  411. package/dist/motion/outline.d.ts.map +1 -0
  412. package/dist/motion/outline.js +59 -0
  413. package/dist/motion/outline.js.map +1 -0
  414. package/dist/motion/presets/index.d.ts +20 -0
  415. package/dist/motion/presets/index.d.ts.map +1 -0
  416. package/dist/motion/presets/index.js +166 -0
  417. package/dist/motion/presets/index.js.map +1 -0
  418. package/dist/motion/presets/settings.d.ts +43 -0
  419. package/dist/motion/presets/settings.d.ts.map +1 -0
  420. package/dist/motion/presets/settings.js +254 -0
  421. package/dist/motion/presets/settings.js.map +1 -0
  422. package/dist/motion/presets/stagger.d.ts +69 -0
  423. package/dist/motion/presets/stagger.d.ts.map +1 -0
  424. package/dist/motion/presets/stagger.js +185 -0
  425. package/dist/motion/presets/stagger.js.map +1 -0
  426. package/dist/motion/schema.d.ts +185 -0
  427. package/dist/motion/schema.d.ts.map +1 -0
  428. package/dist/motion/schema.js +62 -0
  429. package/dist/motion/schema.js.map +1 -0
  430. package/dist/motion/segment.d.ts +25 -0
  431. package/dist/motion/segment.d.ts.map +1 -0
  432. package/dist/motion/segment.js +73 -0
  433. package/dist/motion/segment.js.map +1 -0
  434. package/dist/motion/spec.d.ts +26 -0
  435. package/dist/motion/spec.d.ts.map +1 -0
  436. package/dist/motion/spec.js +175 -0
  437. package/dist/motion/spec.js.map +1 -0
  438. package/dist/motion/timeline.d.ts +16 -0
  439. package/dist/motion/timeline.d.ts.map +1 -0
  440. package/dist/motion/timeline.js +53 -0
  441. package/dist/motion/timeline.js.map +1 -0
  442. package/dist/motion/types.d.ts +49 -0
  443. package/dist/motion/types.d.ts.map +1 -0
  444. package/dist/motion/variables.d.ts +9 -0
  445. package/dist/motion/variables.d.ts.map +1 -0
  446. package/dist/motion/variables.js +25 -0
  447. package/dist/motion/variables.js.map +1 -0
  448. package/dist/mutation-impact.d.ts +9 -10
  449. package/dist/mutation-impact.d.ts.map +1 -1
  450. package/dist/mutation-impact.js +19 -9
  451. package/dist/mutation-impact.js.map +1 -1
  452. package/dist/node-defaults.d.ts +15 -14
  453. package/dist/node-defaults.d.ts.map +1 -1
  454. package/dist/node-defaults.js +153 -55
  455. package/dist/node-defaults.js.map +1 -1
  456. package/dist/order-keys.d.ts +8 -9
  457. package/dist/order-keys.d.ts.map +1 -1
  458. package/dist/order-keys.js +10 -2
  459. package/dist/order-keys.js.map +1 -1
  460. package/dist/outline/flatten.d.ts +3 -6
  461. package/dist/outline/flatten.d.ts.map +1 -1
  462. package/dist/outline/flatten.js +3 -4
  463. package/dist/outline/heads.js +1 -2
  464. package/dist/outline/hit.d.ts +2 -5
  465. package/dist/outline/hit.d.ts.map +1 -1
  466. package/dist/outline/hit.js +5 -6
  467. package/dist/outline/index.js +3 -3
  468. package/dist/outline/point.d.ts +4 -7
  469. package/dist/outline/point.d.ts.map +1 -1
  470. package/dist/outline/point.js +2 -3
  471. package/dist/outline/shapes.d.ts +4 -7
  472. package/dist/outline/shapes.d.ts.map +1 -1
  473. package/dist/outline/shapes.js +2 -3
  474. package/dist/paints/index.d.ts +5 -3
  475. package/dist/paints/index.js +5 -3
  476. package/dist/paints/pattern.d.ts +6 -5
  477. package/dist/paints/pattern.d.ts.map +1 -1
  478. package/dist/paints/pattern.js +34 -3
  479. package/dist/paints/pattern.js.map +1 -1
  480. package/dist/paints/schema.d.ts +4 -7
  481. package/dist/paints/schema.d.ts.map +1 -1
  482. package/dist/paints/schema.js +3 -4
  483. package/dist/paints/shows.d.ts +4 -4
  484. package/dist/paints/shows.d.ts.map +1 -1
  485. package/dist/paints/shows.js +9 -3
  486. package/dist/paints/shows.js.map +1 -1
  487. package/dist/paints/solid.d.ts +8 -0
  488. package/dist/paints/solid.d.ts.map +1 -0
  489. package/dist/paints/solid.js +17 -0
  490. package/dist/paints/solid.js.map +1 -0
  491. package/dist/paints/stills.d.ts +74 -0
  492. package/dist/paints/stills.d.ts.map +1 -0
  493. package/dist/paints/stills.js +117 -0
  494. package/dist/paints/stills.js.map +1 -0
  495. package/dist/parse-path.d.ts +12 -9
  496. package/dist/parse-path.d.ts.map +1 -1
  497. package/dist/parse-path.js +13 -3
  498. package/dist/parse-path.js.map +1 -1
  499. package/dist/paths/arc.d.ts +6 -9
  500. package/dist/paths/arc.d.ts.map +1 -1
  501. package/dist/paths/arc.js +1 -2
  502. package/dist/paths/index.d.ts +1 -1
  503. package/dist/paths/index.js +1 -1
  504. package/dist/paths/network.d.ts +13 -16
  505. package/dist/paths/network.d.ts.map +1 -1
  506. package/dist/paths/network.js +1 -2
  507. package/dist/paths/sink.d.ts +5 -8
  508. package/dist/paths/sink.d.ts.map +1 -1
  509. package/dist/paths/sink.js +1 -2
  510. package/dist/paths/smooth-corners.d.ts +3 -6
  511. package/dist/paths/smooth-corners.d.ts.map +1 -1
  512. package/dist/paths/smooth-corners.js +1 -2
  513. package/dist/plugin-data/field.d.ts +15 -18
  514. package/dist/plugin-data/field.d.ts.map +1 -1
  515. package/dist/plugin-data/field.js +3 -2
  516. package/dist/plugin-data/field.js.map +1 -1
  517. package/dist/plugin-data/fields.d.ts +104 -11
  518. package/dist/plugin-data/fields.d.ts.map +1 -1
  519. package/dist/plugin-data/fields.js +43 -13
  520. package/dist/plugin-data/fields.js.map +1 -1
  521. package/dist/plugin-data/index.d.ts +2 -2
  522. package/dist/plugin-data/index.js +2 -2
  523. package/dist/polygon.d.ts +8 -8
  524. package/dist/polygon.d.ts.map +1 -1
  525. package/dist/polygon.js +7 -7
  526. package/dist/polygon.js.map +1 -1
  527. package/dist/preview.d.ts +3 -5
  528. package/dist/preview.d.ts.map +1 -1
  529. package/dist/preview.js +2 -3
  530. package/dist/primitives/index.d.ts +7 -9
  531. package/dist/primitives/index.d.ts.map +1 -1
  532. package/dist/primitives/index.js +1 -2
  533. package/dist/primitives/schema.d.ts +3 -6
  534. package/dist/primitives/schema.d.ts.map +1 -1
  535. package/dist/primitives/schema.js +1 -2
  536. package/dist/resize.d.ts +19 -14
  537. package/dist/resize.d.ts.map +1 -1
  538. package/dist/resize.js +38 -8
  539. package/dist/resize.js.map +1 -1
  540. package/dist/scaling/index.d.ts +2 -2
  541. package/dist/scaling/index.js +2 -2
  542. package/dist/scaling/node.d.ts +2 -4
  543. package/dist/scaling/node.d.ts.map +1 -1
  544. package/dist/scaling/node.js +30 -11
  545. package/dist/scaling/node.js.map +1 -1
  546. package/dist/scaling/snapshot.d.ts +5 -8
  547. package/dist/scaling/snapshot.d.ts.map +1 -1
  548. package/dist/scaling/snapshot.js +1 -2
  549. package/dist/scaling/tree.d.ts +6 -9
  550. package/dist/scaling/tree.d.ts.map +1 -1
  551. package/dist/scaling/tree.js +2 -3
  552. package/dist/shaders/index.d.ts +2 -3
  553. package/dist/shaders/index.js +2 -3
  554. package/dist/shaders/model.d.ts +54 -21
  555. package/dist/shaders/model.d.ts.map +1 -1
  556. package/dist/shaders/model.js +103 -35
  557. package/dist/shaders/model.js.map +1 -1
  558. package/dist/shaders/schema.d.ts +16 -9
  559. package/dist/shaders/schema.d.ts.map +1 -1
  560. package/dist/shaders/schema.js +12 -3
  561. package/dist/shaders/schema.js.map +1 -1
  562. package/dist/shape-with-text/document.js +264 -0
  563. package/dist/shape-with-text/document.js.map +1 -0
  564. package/dist/shape-with-text/fit.d.ts +6 -9
  565. package/dist/shape-with-text/fit.d.ts.map +1 -1
  566. package/dist/shape-with-text/fit.js +1 -2
  567. package/dist/shape-with-text/geometry.d.ts +16 -7
  568. package/dist/shape-with-text/geometry.d.ts.map +1 -1
  569. package/dist/shape-with-text/geometry.js +105 -46
  570. package/dist/shape-with-text/geometry.js.map +1 -1
  571. package/dist/shape-with-text/index.d.ts +2 -2
  572. package/dist/shape-with-text/index.js +3 -3
  573. package/dist/shape-with-text/kinds.d.ts +4 -7
  574. package/dist/shape-with-text/kinds.d.ts.map +1 -1
  575. package/dist/shape-with-text/kinds.js +1 -2
  576. package/dist/shared-style-index.d.ts +19 -0
  577. package/dist/shared-style-index.d.ts.map +1 -0
  578. package/dist/shared-style-index.js +71 -0
  579. package/dist/shared-style-index.js.map +1 -0
  580. package/dist/shared-styles.d.ts +18 -20
  581. package/dist/shared-styles.d.ts.map +1 -1
  582. package/dist/shared-styles.js +20 -12
  583. package/dist/shared-styles.js.map +1 -1
  584. package/dist/slides/drop.d.ts +29 -0
  585. package/dist/slides/drop.d.ts.map +1 -0
  586. package/dist/slides/drop.js +80 -0
  587. package/dist/slides/drop.js.map +1 -0
  588. package/dist/slides/index.d.ts +56 -0
  589. package/dist/slides/index.d.ts.map +1 -0
  590. package/dist/slides/index.js +137 -0
  591. package/dist/slides/index.js.map +1 -0
  592. package/dist/slides/motion.d.ts +71 -0
  593. package/dist/slides/motion.d.ts.map +1 -0
  594. package/dist/slides/motion.js +167 -0
  595. package/dist/slides/motion.js.map +1 -0
  596. package/dist/slides/playback.d.ts +62 -0
  597. package/dist/slides/playback.d.ts.map +1 -0
  598. package/dist/slides/playback.js +220 -0
  599. package/dist/slides/playback.js.map +1 -0
  600. package/dist/slides/types.d.ts +59 -0
  601. package/dist/slides/types.d.ts.map +1 -0
  602. package/dist/slides/types.js +38 -0
  603. package/dist/slides/types.js.map +1 -0
  604. package/dist/slots/authoring.d.ts +6 -9
  605. package/dist/slots/authoring.d.ts.map +1 -1
  606. package/dist/slots/authoring.js +2 -3
  607. package/dist/slots/content.d.ts +5 -8
  608. package/dist/slots/content.d.ts.map +1 -1
  609. package/dist/slots/content.js +4 -5
  610. package/dist/slots/frames.d.ts +7 -9
  611. package/dist/slots/frames.d.ts.map +1 -1
  612. package/dist/slots/frames.js +3 -4
  613. package/dist/slots/frames.js.map +1 -1
  614. package/dist/slots/index.js +1 -1
  615. package/dist/slots/limits.d.ts +4 -7
  616. package/dist/slots/limits.d.ts.map +1 -1
  617. package/dist/slots/limits.js +1 -2
  618. package/dist/snap.d.ts +4 -7
  619. package/dist/snap.d.ts.map +1 -1
  620. package/dist/snap.js +7 -8
  621. package/dist/source-metadata.d.ts +1 -4
  622. package/dist/source-metadata.d.ts.map +1 -1
  623. package/dist/source-metadata.js +1 -2
  624. package/dist/specs/index.d.ts +3 -0
  625. package/dist/specs/index.js +3 -0
  626. package/dist/specs/model.d.ts +20 -0
  627. package/dist/specs/model.d.ts.map +1 -0
  628. package/dist/specs/model.js +32 -0
  629. package/dist/specs/model.js.map +1 -0
  630. package/dist/specs/schema.d.ts +24 -0
  631. package/dist/specs/schema.d.ts.map +1 -0
  632. package/dist/specs/schema.js +32 -0
  633. package/dist/specs/schema.js.map +1 -0
  634. package/dist/statuses/impact.d.ts +2 -5
  635. package/dist/statuses/impact.d.ts.map +1 -1
  636. package/dist/statuses/impact.js +2 -3
  637. package/dist/statuses/index.d.ts +1 -1
  638. package/dist/statuses/index.js +2 -2
  639. package/dist/statuses/node.d.ts +4 -7
  640. package/dist/statuses/node.d.ts.map +1 -1
  641. package/dist/statuses/node.js +1 -2
  642. package/dist/statuses/schema.d.ts +7 -9
  643. package/dist/statuses/schema.d.ts.map +1 -1
  644. package/dist/statuses/schema.js +1 -2
  645. package/dist/statuses/workflow.d.ts +9 -12
  646. package/dist/statuses/workflow.d.ts.map +1 -1
  647. package/dist/statuses/workflow.js +2 -3
  648. package/dist/strokes.d.ts +8 -10
  649. package/dist/strokes.d.ts.map +1 -1
  650. package/dist/strokes.js +2 -3
  651. package/dist/text/auto-resize.d.ts +4 -6
  652. package/dist/text/auto-resize.d.ts.map +1 -1
  653. package/dist/text/auto-resize.js +1 -2
  654. package/dist/text/direction.d.ts +10 -10
  655. package/dist/text/direction.d.ts.map +1 -1
  656. package/dist/text/direction.js +13 -14
  657. package/dist/text/direction.js.map +1 -1
  658. package/dist/text/index.d.ts +3 -2
  659. package/dist/text/index.js +6 -5
  660. package/dist/text/lengths.d.ts +9 -12
  661. package/dist/text/lengths.d.ts.map +1 -1
  662. package/dist/text/lengths.js +1 -2
  663. package/dist/text/lists.d.ts +17 -13
  664. package/dist/text/lists.d.ts.map +1 -1
  665. package/dist/text/lists.js +15 -4
  666. package/dist/text/lists.js.map +1 -1
  667. package/dist/text/name.d.ts +19 -0
  668. package/dist/text/name.d.ts.map +1 -0
  669. package/dist/text/name.js +37 -0
  670. package/dist/text/name.js.map +1 -0
  671. package/dist/text/overflow.d.ts +5 -7
  672. package/dist/text/overflow.d.ts.map +1 -1
  673. package/dist/text/overflow.js +1 -2
  674. package/dist/text/paragraphs.d.ts +20 -23
  675. package/dist/text/paragraphs.d.ts.map +1 -1
  676. package/dist/text/paragraphs.js +8 -5
  677. package/dist/text/paragraphs.js.map +1 -1
  678. package/dist/text/path.js +1 -2
  679. package/dist/text/picture.d.ts +3 -6
  680. package/dist/text/picture.d.ts.map +1 -1
  681. package/dist/text/picture.js +2 -3
  682. package/dist/text/references.d.ts +3 -6
  683. package/dist/text/references.d.ts.map +1 -1
  684. package/dist/text/references.js +2 -4
  685. package/dist/text/references.js.map +1 -1
  686. package/dist/text/runs.d.ts +6 -9
  687. package/dist/text/runs.d.ts.map +1 -1
  688. package/dist/text/runs.js +1 -2
  689. package/dist/text/schema.d.ts +1 -4
  690. package/dist/text/schema.d.ts.map +1 -1
  691. package/dist/text/schema.js +1 -2
  692. package/dist/thumbnail.d.ts +20 -0
  693. package/dist/thumbnail.d.ts.map +1 -0
  694. package/dist/thumbnail.js +46 -0
  695. package/dist/thumbnail.js.map +1 -0
  696. package/dist/transfer/apply.d.ts +2 -5
  697. package/dist/transfer/apply.d.ts.map +1 -1
  698. package/dist/transfer/apply.js +16 -6
  699. package/dist/transfer/apply.js.map +1 -1
  700. package/dist/transfer/copied.d.ts +11 -9
  701. package/dist/transfer/copied.d.ts.map +1 -1
  702. package/dist/transfer/copied.js +5 -6
  703. package/dist/transfer/copied.js.map +1 -1
  704. package/dist/transfer/dependencies.d.ts +10 -10
  705. package/dist/transfer/dependencies.d.ts.map +1 -1
  706. package/dist/transfer/dependencies.js +21 -10
  707. package/dist/transfer/dependencies.js.map +1 -1
  708. package/dist/transfer/history.d.ts +1 -4
  709. package/dist/transfer/history.d.ts.map +1 -1
  710. package/dist/transfer/history.js +3 -2
  711. package/dist/transfer/history.js.map +1 -1
  712. package/dist/transfer/identity.js +19 -5
  713. package/dist/transfer/identity.js.map +1 -1
  714. package/dist/transfer/index.d.ts +5 -4
  715. package/dist/transfer/index.js +6 -5
  716. package/dist/transfer/library.d.ts +43 -0
  717. package/dist/transfer/library.d.ts.map +1 -0
  718. package/dist/transfer/library.js +122 -0
  719. package/dist/transfer/library.js.map +1 -0
  720. package/dist/transfer/nodes.d.ts +2 -5
  721. package/dist/transfer/nodes.d.ts.map +1 -1
  722. package/dist/transfer/nodes.js +15 -4
  723. package/dist/transfer/nodes.js.map +1 -1
  724. package/dist/transfer/plan.d.ts +11 -5
  725. package/dist/transfer/plan.d.ts.map +1 -1
  726. package/dist/transfer/plan.js +52 -8
  727. package/dist/transfer/plan.js.map +1 -1
  728. package/dist/transfer/references.js +1 -2
  729. package/dist/transfer/remove.d.ts +1 -4
  730. package/dist/transfer/remove.d.ts.map +1 -1
  731. package/dist/transfer/remove.js +8 -3
  732. package/dist/transfer/remove.js.map +1 -1
  733. package/dist/transfer/resources.d.ts +2 -5
  734. package/dist/transfer/resources.d.ts.map +1 -1
  735. package/dist/transfer/resources.js +3 -4
  736. package/dist/transfer/validation.js +9 -6
  737. package/dist/transfer/validation.js.map +1 -1
  738. package/dist/transfer/variables.d.ts +3 -6
  739. package/dist/transfer/variables.d.ts.map +1 -1
  740. package/dist/transfer/variables.js +4 -4
  741. package/dist/transfer/variables.js.map +1 -1
  742. package/dist/types.d.ts +261 -134
  743. package/dist/types.d.ts.map +1 -1
  744. package/dist/types.js +47 -3
  745. package/dist/types.js.map +1 -1
  746. package/dist/undo.d.ts +5 -8
  747. package/dist/undo.d.ts.map +1 -1
  748. package/dist/undo.js +9 -3
  749. package/dist/undo.js.map +1 -1
  750. package/dist/variables/bindings.d.ts +29 -25
  751. package/dist/variables/bindings.d.ts.map +1 -1
  752. package/dist/variables/bindings.js +184 -55
  753. package/dist/variables/bindings.js.map +1 -1
  754. package/dist/variables/corners.d.ts +1 -4
  755. package/dist/variables/corners.d.ts.map +1 -1
  756. package/dist/variables/corners.js +1 -2
  757. package/dist/variables/easing.d.ts +53 -0
  758. package/dist/variables/easing.d.ts.map +1 -0
  759. package/dist/variables/easing.js +321 -0
  760. package/dist/variables/easing.js.map +1 -0
  761. package/dist/variables/fields.d.ts +21 -14
  762. package/dist/variables/fields.d.ts.map +1 -1
  763. package/dist/variables/fields.js +24 -6
  764. package/dist/variables/fields.js.map +1 -1
  765. package/dist/variables/formula/check.d.ts +2 -5
  766. package/dist/variables/formula/check.d.ts.map +1 -1
  767. package/dist/variables/formula/check.js +2 -3
  768. package/dist/variables/formula/evaluate.d.ts +1 -4
  769. package/dist/variables/formula/evaluate.d.ts.map +1 -1
  770. package/dist/variables/formula/evaluate.js +3 -4
  771. package/dist/variables/formula/index.d.ts +8 -8
  772. package/dist/variables/formula/index.d.ts.map +1 -1
  773. package/dist/variables/formula/index.js +29 -13
  774. package/dist/variables/formula/index.js.map +1 -1
  775. package/dist/variables/formula/parse.js +5 -6
  776. package/dist/variables/formula/print.d.ts +2 -5
  777. package/dist/variables/formula/print.d.ts.map +1 -1
  778. package/dist/variables/formula/print.js +4 -5
  779. package/dist/variables/formula/schema.d.ts +2 -5
  780. package/dist/variables/formula/schema.d.ts.map +1 -1
  781. package/dist/variables/formula/schema.js +6 -7
  782. package/dist/variables/formula/signatures.d.ts +4 -7
  783. package/dist/variables/formula/signatures.d.ts.map +1 -1
  784. package/dist/variables/formula/signatures.js +1 -2
  785. package/dist/variables/formula/signatures.js.map +1 -1
  786. package/dist/variables/formula/tokens.d.ts +5 -8
  787. package/dist/variables/formula/tokens.d.ts.map +1 -1
  788. package/dist/variables/formula/tokens.js +1 -2
  789. package/dist/variables/formula/tree.d.ts +8 -11
  790. package/dist/variables/formula/tree.d.ts.map +1 -1
  791. package/dist/variables/formula/tree.js +1 -2
  792. package/dist/variables/formula/tree.js.map +1 -1
  793. package/dist/variables/index.d.ts +42 -27
  794. package/dist/variables/index.d.ts.map +1 -1
  795. package/dist/variables/index.js +78 -29
  796. package/dist/variables/index.js.map +1 -1
  797. package/dist/variables/lookup.d.ts +11 -7
  798. package/dist/variables/lookup.d.ts.map +1 -1
  799. package/dist/variables/lookup.js +25 -4
  800. package/dist/variables/lookup.js.map +1 -1
  801. package/dist/variables/motion.d.ts +43 -0
  802. package/dist/variables/motion.d.ts.map +1 -0
  803. package/dist/variables/motion.js +106 -0
  804. package/dist/variables/motion.js.map +1 -0
  805. package/dist/variables/paints.d.ts +25 -19
  806. package/dist/variables/paints.d.ts.map +1 -1
  807. package/dist/variables/paints.js +28 -15
  808. package/dist/variables/paints.js.map +1 -1
  809. package/dist/variables/resolution.d.ts +22 -19
  810. package/dist/variables/resolution.d.ts.map +1 -1
  811. package/dist/variables/resolution.js +23 -14
  812. package/dist/variables/resolution.js.map +1 -1
  813. package/dist/variables/schema.d.ts +62 -7
  814. package/dist/variables/schema.d.ts.map +1 -1
  815. package/dist/variables/schema.js +39 -5
  816. package/dist/variables/schema.js.map +1 -1
  817. package/dist/variables/style-bindings.d.ts +21 -0
  818. package/dist/variables/style-bindings.d.ts.map +1 -0
  819. package/dist/variables/style-bindings.js +82 -0
  820. package/dist/variables/style-bindings.js.map +1 -0
  821. package/dist/variables/subtree.js +1 -2
  822. package/dist/variables/text.d.ts +2 -5
  823. package/dist/variables/text.d.ts.map +1 -1
  824. package/dist/variables/text.js +3 -4
  825. package/dist/variables/token.d.ts +5 -8
  826. package/dist/variables/token.d.ts.map +1 -1
  827. package/dist/variables/token.js +1 -2
  828. package/dist/variables/units.js +3 -5
  829. package/dist/variables/units.js.map +1 -1
  830. package/dist/variables/value.d.ts +4 -7
  831. package/dist/variables/value.d.ts.map +1 -1
  832. package/dist/variables/value.js +4 -5
  833. package/dist/variant-name.d.ts +2 -5
  834. package/dist/variant-name.d.ts.map +1 -1
  835. package/dist/variant-name.js +1 -2
  836. package/dist/variant-properties.d.ts +4 -7
  837. package/dist/variant-properties.d.ts.map +1 -1
  838. package/dist/variant-properties.js +2 -3
  839. package/dist/vector-network.d.ts +17 -20
  840. package/dist/vector-network.d.ts.map +1 -1
  841. package/dist/vector-network.js +4 -5
  842. package/package.json +42 -5
  843. package/src/behaviours/index.ts +2 -0
  844. package/src/behaviours/kinds.ts +108 -2
  845. package/src/behaviours/listing.ts +142 -0
  846. package/src/behaviours/model.ts +23 -2
  847. package/src/behaviours/schema.ts +19 -2
  848. package/src/behaviours/spec.ts +5 -0
  849. package/src/behaviours/transition.ts +46 -0
  850. package/src/blur.ts +88 -0
  851. package/src/checkpoint.ts +2 -0
  852. package/src/clipping.ts +3 -4
  853. package/src/color/index.ts +15 -24
  854. package/src/color/management.ts +144 -168
  855. package/src/color/okhcl.ts +62 -43
  856. package/src/color/schema.ts +13 -0
  857. package/src/comments/threads.ts +8 -1
  858. package/src/connectors/layout.ts +10 -3
  859. package/src/connectors/sublayers.ts +2 -1
  860. package/src/constraints.ts +2 -1
  861. package/src/coordinate.ts +17 -25
  862. package/src/copy.ts +38 -0
  863. package/src/corners.ts +3 -0
  864. package/src/css/index.ts +1 -0
  865. package/src/css/motion.ts +51 -0
  866. package/src/css/shadows.ts +7 -6
  867. package/src/css/values.ts +7 -3
  868. package/src/cubic.ts +57 -1
  869. package/src/export-format.ts +11 -1
  870. package/src/fields/layout.ts +9 -0
  871. package/src/font-style.ts +20 -7
  872. package/src/generated/index.ts +58 -9
  873. package/src/generated/kind.ts +16 -2
  874. package/src/generated/shape-with-text.ts +1 -0
  875. package/src/generated/spec.ts +243 -0
  876. package/src/generated/sticky.ts +2 -1
  877. package/src/geometry.ts +52 -89
  878. package/src/graph.ts +93 -15
  879. package/src/group-bounds.ts +54 -13
  880. package/src/hit-test.ts +78 -33
  881. package/src/images.ts +4 -1
  882. package/src/instances/content-marks.ts +124 -0
  883. package/src/instances/deleted.ts +115 -0
  884. package/src/instances/fields.ts +9 -3
  885. package/src/instances/index.ts +165 -17
  886. package/src/instances/lookup.ts +61 -0
  887. package/src/instances/sync.ts +108 -11
  888. package/src/layout/flow.ts +36 -0
  889. package/src/layout/index.ts +2 -0
  890. package/src/layout/keywords.ts +7 -1
  891. package/src/layout/sizing.ts +30 -0
  892. package/src/layout/spacing.ts +12 -0
  893. package/src/layout/stacking.ts +14 -0
  894. package/src/matrix.ts +11 -1
  895. package/src/mesh/geometry.ts +422 -0
  896. package/src/mesh/index.ts +3 -0
  897. package/src/mesh/model.ts +50 -0
  898. package/src/mesh/schema.ts +81 -0
  899. package/src/motion/apply.ts +156 -0
  900. package/src/motion/edit.ts +148 -0
  901. package/src/motion/effects.ts +166 -0
  902. package/src/motion/evaluate.ts +181 -0
  903. package/src/motion/fields.ts +136 -0
  904. package/src/motion/index.ts +13 -0
  905. package/src/motion/keyable.ts +141 -0
  906. package/src/motion/outline.ts +72 -0
  907. package/src/motion/presets/index.ts +257 -0
  908. package/src/motion/presets/settings.ts +221 -0
  909. package/src/motion/presets/stagger.ts +242 -0
  910. package/src/motion/schema.ts +66 -0
  911. package/src/motion/segment.ts +83 -0
  912. package/src/motion/spec.ts +225 -0
  913. package/src/motion/timeline.ts +48 -0
  914. package/src/motion/types.ts +45 -0
  915. package/src/motion/variables.ts +33 -0
  916. package/src/mutation-impact.ts +23 -7
  917. package/src/node-defaults.ts +152 -53
  918. package/src/order-keys.ts +16 -2
  919. package/src/paints/index.ts +2 -0
  920. package/src/paints/pattern.ts +55 -0
  921. package/src/paints/shows.ts +9 -0
  922. package/src/paints/solid.ts +10 -0
  923. package/src/paints/stills.ts +186 -0
  924. package/src/parse-path.ts +15 -0
  925. package/src/plugin-data/field.ts +3 -0
  926. package/src/plugin-data/fields.ts +54 -4
  927. package/src/polygon.ts +6 -4
  928. package/src/resize.ts +32 -20
  929. package/src/scaling/index.ts +1 -1
  930. package/src/scaling/node.ts +43 -6
  931. package/src/shaders/index.ts +0 -1
  932. package/src/shaders/model.ts +133 -45
  933. package/src/shaders/schema.ts +13 -1
  934. package/src/shape-with-text/document.ts +170 -0
  935. package/src/shape-with-text/geometry.ts +98 -29
  936. package/src/shared-style-index.ts +106 -0
  937. package/src/shared-styles.ts +21 -14
  938. package/src/slides/drop.ts +94 -0
  939. package/src/slides/index.ts +133 -0
  940. package/src/slides/motion.ts +203 -0
  941. package/src/slides/playback.ts +242 -0
  942. package/src/slides/types.ts +94 -0
  943. package/src/slots/frames.ts +2 -3
  944. package/src/specs/index.ts +2 -0
  945. package/src/specs/model.ts +40 -0
  946. package/src/specs/schema.ts +43 -0
  947. package/src/text/direction.ts +13 -23
  948. package/src/text/index.ts +1 -0
  949. package/src/text/lists.ts +20 -7
  950. package/src/text/name.ts +39 -0
  951. package/src/text/paragraphs.ts +10 -3
  952. package/src/text/references.ts +3 -3
  953. package/src/thumbnail.ts +52 -0
  954. package/src/transfer/apply.ts +16 -3
  955. package/src/transfer/copied.ts +7 -2
  956. package/src/transfer/dependencies.ts +27 -12
  957. package/src/transfer/history.ts +2 -0
  958. package/src/transfer/identity.ts +34 -2
  959. package/src/transfer/index.ts +6 -0
  960. package/src/transfer/library.ts +177 -0
  961. package/src/transfer/nodes.ts +28 -0
  962. package/src/transfer/plan.ts +96 -10
  963. package/src/transfer/remove.ts +6 -2
  964. package/src/transfer/validation.ts +15 -7
  965. package/src/transfer/variables.ts +8 -2
  966. package/src/types.ts +182 -15
  967. package/src/undo.ts +10 -1
  968. package/src/variables/bindings.ts +292 -51
  969. package/src/variables/easing.ts +281 -0
  970. package/src/variables/fields.ts +30 -3
  971. package/src/variables/formula/index.ts +33 -14
  972. package/src/variables/formula/signatures.ts +6 -2
  973. package/src/variables/formula/tree.ts +3 -3
  974. package/src/variables/index.ts +90 -37
  975. package/src/variables/lookup.ts +25 -2
  976. package/src/variables/motion.ts +151 -0
  977. package/src/variables/paints.ts +29 -7
  978. package/src/variables/resolution.ts +26 -6
  979. package/src/variables/schema.ts +41 -0
  980. package/src/variables/style-bindings.ts +137 -0
  981. package/src/variables/units.ts +2 -3
  982. package/dist/shaders/still.d.ts +0 -18
  983. package/dist/shaders/still.d.ts.map +0 -1
  984. package/dist/shaders/still.js +0 -36
  985. package/dist/shaders/still.js.map +0 -1
  986. package/src/shaders/still.ts +0 -41
@@ -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,MAAM,WACN,OAAO,KAAK,wBACZ,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA8CT,iBAAi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A8CT,iBAAiB,KAAK;;;;;wBAMX,wBACd,MAAM,WACN,OAAO,MACP,aAAa,OACZ;wBAca,kBAAkB,QAAQ;;;;;;;wBAU1B,2BACd,MAAM,WACN,OAAO,KAAK,yBACX;;;;;iBAgBc;EACf,MAAM;EACN,QAAQ;;EAER,OAAO;;EAEP,aAAa;;EAEb;;EAEA,eAAe;;wBAGD,mBACd,MAAM,WACN,OAAO,KAAK,oCACX;iBA4Bc;;EAEf;;EAEA,SAAS;;;;;EAKT;;;YAwBU,iBAAiB,KAC3B;;;;;;;;;wBAYc,qBACd,WAAW,oBACX,MAAM,MACN,IAAI,QAEF,WACA,OACA,eACC,uBACF;;;;;wBAqCa,iBACd,WAAW,oBACX,QAAQ,QACR,gBACC;;wBAMa,mBAAmB,WAAW,oBAAoB,YAAY,aAAa;;;;;;;wBAa3E,oBACd,WAAW,oBACX,MAAM,MACN,IAAI,OACH;;;;;;wBAoCa,kBACd,WAAW,oBACX,OAAO,QACP;EACG;EAAW;EAAW"}
@@ -1,6 +1,7 @@
1
+ import { transformedRectBounds, unionVisualBounds, visualBoundsToRect } from "./geometry.js";
1
2
  import Matrix from "./matrix.js";
2
3
  import { FITTED_CONTAINER_TYPES } from "./node-defaults.js";
3
- //#region src/coordinate.ts
4
+ // src/coordinate.ts
4
5
  function getWorldMatrix(node, graph) {
5
6
  const chain = [];
6
7
  let current = node;
@@ -16,45 +17,16 @@ function getWorldMatrix(node, graph) {
16
17
  }
17
18
  return matrix;
18
19
  }
19
- /** Axis-aligned box around interleaved `x, y` points; empty input gives an empty box at the origin. */
20
- function boundsOfPoints(points) {
21
- if (points.length === 0) return {
20
+ function localBox(node) {
21
+ return {
22
22
  x: 0,
23
23
  y: 0,
24
- width: 0,
25
- height: 0
26
- };
27
- let minX = Infinity;
28
- let minY = Infinity;
29
- let maxX = -Infinity;
30
- let maxY = -Infinity;
31
- for (let i = 0; i < points.length; i += 2) {
32
- minX = Math.min(minX, points[i]);
33
- minY = Math.min(minY, points[i + 1]);
34
- maxX = Math.max(maxX, points[i]);
35
- maxY = Math.max(maxY, points[i + 1]);
36
- }
37
- return {
38
- x: minX,
39
- y: minY,
40
- width: maxX - minX,
41
- height: maxY - minY
24
+ width: node.width,
25
+ height: node.height
42
26
  };
43
27
  }
44
- function cornersOf(node) {
45
- return [
46
- 0,
47
- 0,
48
- node.width,
49
- 0,
50
- node.width,
51
- node.height,
52
- 0,
53
- node.height
54
- ];
55
- }
56
28
  function getAxisAlignedWorldBounds(node, graph) {
57
- return boundsOfPoints(Matrix.mapPoints(getWorldMatrix(node, graph), cornersOf(node)));
29
+ return visualBoundsToRect(transformedRectBounds(getWorldMatrix(node, graph), localBox(node)));
58
30
  }
59
31
  /** World matrix of a parent; the document root and a missing parent are the identity. */
60
32
  function getParentWorldMatrix(parent, graph) {
@@ -69,7 +41,17 @@ function getParentWorldMatrix(parent, graph) {
69
41
  */
70
42
  function getAxisAlignedBoundsInParent(nodes, parentId, graph) {
71
43
  const toParent = Matrix.invert(getParentWorldMatrix(graph.getNode(parentId), graph)) ?? Matrix.identity();
72
- return boundsOfPoints(nodes.flatMap((node) => Matrix.mapPoints(Matrix.multiply(toParent, getWorldMatrix(node, graph)), cornersOf(node))));
44
+ let bounds = null;
45
+ for (const node of nodes) {
46
+ const matrix = Matrix.multiply(toParent, getWorldMatrix(node, graph));
47
+ bounds = unionVisualBounds(bounds, transformedRectBounds(matrix, localBox(node)));
48
+ }
49
+ return bounds ? visualBoundsToRect(bounds) : {
50
+ x: 0,
51
+ y: 0,
52
+ width: 0,
53
+ height: 0
54
+ };
73
55
  }
74
56
  function getAbsolutePosition(node, graph) {
75
57
  const matrix = getWorldMatrix(node, graph);
@@ -145,7 +127,7 @@ function getNodeLocalMatrix(n, position = n) {
145
127
  return matrix;
146
128
  }
147
129
  function getNodeWorldBounds(node) {
148
- return boundsOfPoints(Matrix.mapPoints(getNodeLocalMatrix(node), cornersOf(node)));
130
+ return visualBoundsToRect(transformedRectBounds(getNodeLocalMatrix(node), localBox(node)));
149
131
  }
150
132
  /**
151
133
  * World-space positions of the 8 selection handles. `localRect` overrides the
@@ -479,7 +461,6 @@ function placeRotatedAbout(placement, pivot, degrees) {
479
461
  rotation
480
462
  };
481
463
  }
482
- //#endregion
483
464
  export { canvasDeltaInLayer, getAbsolutePosition, getAbsolutePositionFull, getAbsoluteRotation, getAxisAlignedBoundsInParent, getAxisAlignedWorldBounds, getNodeLocalMatrix, getNodeRotationOrigin, getNodeWorldBounds, getParentToContainerMatrix, getParentWorldMatrix, getWorldHandles, getWorldMatrix, isTranslationOnly, localTransformFromWorld, placeInResizedBounds, placeInResizedFrame, placeRotatedAbout, placeScaledAbout, selectionPlacement };
484
465
 
485
466
  //# 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\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;EACn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],"sources":["../src/coordinate.ts"],"sourcesContent":["import {\n transformedRectBounds,\n unionVisualBounds,\n visualBoundsToRect,\n type VisualBounds\n} from './geometry'\nimport 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\nfunction localBox(node: Pick<SceneNode, 'width' | 'height'>): Rect {\n return { x: 0, y: 0, width: node.width, height: node.height }\n}\n\nexport function getAxisAlignedWorldBounds(node: SceneNode, graph: Pick<SceneGraph, 'getNode'>) {\n return visualBoundsToRect(transformedRectBounds(getWorldMatrix(node, graph), localBox(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 let bounds: VisualBounds | null = null\n for (const node of nodes) {\n const matrix = Matrix.multiply(toParent, getWorldMatrix(node, graph))\n bounds = unionVisualBounds(bounds, transformedRectBounds(matrix, localBox(node)))\n }\n return bounds ? visualBoundsToRect(bounds) : { x: 0, y: 0, width: 0, height: 0 }\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: NodePlacement) {\n return visualBoundsToRect(transformedRectBounds(getNodeLocalMatrix(node), localBox(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":";;;;AAYA,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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AO,MAAO;CAC1D,OAAO;EAAE,GAAG,mBAAmB;GAAE,GAAG;GAAM;EAAS,GAAG,eAAe,MAAM;EAAG;CAAS;AACzF"}
package/dist/copy.d.ts CHANGED
@@ -1,40 +1,54 @@
1
+ /**
2
+ * Typed shallow-copy helpers for Fill, Stroke, Effect, and StyleRun.
3
+ *
4
+ * These replace `structuredClone` for known scene-graph array types,
5
+ * avoiding the ~24× overhead of the generic deep-clone algorithm.
6
+ * Each helper spreads the top-level object and any nested objects
7
+ * (color, offset, gradientStops, dashPattern, style) to ensure
8
+ * no shared references between source and copy.
9
+ */
10
+ import { Color } from "./primitives/index.js";
1
11
  import { ConnectorEndpoint, DerivedTextGlyph, Effect, Fill, GeometryPath, LayoutGrid, SceneNode, Stroke, StyleRun, VectorNetwork, VectorRegion } from "./types.js";
2
- //#region src/copy.d.ts
3
12
  /** Generic over the paint shape so a stroke keeps its own fields while the paint deep-copies. */
4
- declare function copyFill<T extends Fill>(f: T): T;
5
- declare function copyStroke(s: Stroke): Stroke;
6
- declare function copyEffect(e: Effect): Effect;
7
- declare function copyStyleRun(r: StyleRun): StyleRun;
13
+ export declare function copyFill<T extends Fill>(f: T): T;
14
+ export declare function copyStroke(s: Stroke): Stroke;
15
+ export declare function copyEffect(e: Effect): Effect;
16
+ export declare function copyStyleRun(r: StyleRun): StyleRun;
8
17
  /** Record immutable lineage for an internal deep copy without sharing mutable values. */
9
- declare function markCopySource<T extends object>(source: T, copy: T): T;
18
+ export declare function markCopySource<T extends object>(source: T, copy: T): T;
10
19
  /** Compare internal deep copies in O(1) without traversing large paint or text payloads. */
11
- declare function hasSameCopySource(left: object, right: object): boolean;
12
- declare function copyFills(fills: Fill[]): Fill[];
13
- declare function copyStrokes(strokes: Stroke[]): Stroke[];
14
- declare function copyEffects(effects: Effect[]): Effect[];
15
- declare function copyLayoutGrids(grids: LayoutGrid[]): LayoutGrid[];
16
- declare function copyStyleRuns(runs: StyleRun[]): StyleRun[];
20
+ export declare function hasSameCopySource(left: object, right: object): boolean;
21
+ export declare function copyFills(fills: Fill[]): Fill[];
22
+ export declare function copyStrokes(strokes: Stroke[]): Stroke[];
23
+ export declare function copyEffects(effects: Effect[]): Effect[];
24
+ /**
25
+ * Copies of `effects` with every color they hold passed through `map`: each effect's own and a
26
+ * duotone noise's second color. `map` is told where each sits, `0` or `0.noise` for the first.
27
+ */
28
+ export declare function mapEffectColors(effects: Effect[], map: (color: Color, slot: string) => Color): Effect[];
29
+ export declare function copyLayoutGrids(grids: LayoutGrid[]): LayoutGrid[];
30
+ export declare function copyStyleRuns(runs: StyleRun[]): StyleRun[];
17
31
  /** A region, with new loops when given, keeping its own paints and fill style. */
18
- declare function copyVectorRegion(region: VectorRegion, loops?: number[][]): VectorRegion;
32
+ export declare function copyVectorRegion(region: VectorRegion, loops?: number[][]): VectorRegion;
19
33
  /** Deep-copy a VectorNetwork, stripping any Vue Proxy wrappers. */
20
- declare function cloneVectorNetwork(vn: VectorNetwork): VectorNetwork;
21
- declare function copyGeometryPaths(paths: GeometryPath[]): GeometryPath[];
34
+ export declare function cloneVectorNetwork(vn: VectorNetwork): VectorNetwork;
35
+ export declare function copyGeometryPaths(paths: GeometryPath[]): GeometryPath[];
22
36
  /**
23
37
  * Affine-transform every coordinate pair in a path command blob (returns a
24
38
  * copy): (x, y) → (m00·x + m01·y + tx, m10·x + m11·y + ty).
25
39
  * Command layout: 1=move/2=line (1 pair), 3=quad (2 pairs), 4=cubic (3 pairs)
26
40
  * — font-glyph blobs are quad-heavy, so skipping command 3 desyncs the walk.
27
41
  */
28
- declare function transformGeometryBlob(blob: Uint8Array, m00: number, m01: number, m10: number, m11: number, tx?: number, ty?: number): Uint8Array;
29
- declare function transformGeometryPaths(paths: GeometryPath[], m00: number, m01: number, m10: number, m11: number, tx?: number, ty?: number): GeometryPath[];
42
+ export declare function transformGeometryBlob(blob: Uint8Array, m00: number, m01: number, m10: number, m11: number, tx?: number, ty?: number): Uint8Array;
43
+ export declare function transformGeometryPaths(paths: GeometryPath[], m00: number, m01: number, m10: number, m11: number, tx?: number, ty?: number): GeometryPath[];
30
44
  /**
31
45
  * Scale path command blob coordinates by (sx, sy).
32
46
  * Identity scale returns a deep copy (same as copyGeometryPaths).
33
47
  */
34
- declare function scaleGeometryPaths(paths: GeometryPath[], sx: number, sy: number): GeometryPath[];
48
+ export declare function scaleGeometryPaths(paths: GeometryPath[], sx: number, sy: number): GeometryPath[];
35
49
  /** Deep-copy path-text glyphs (fresh commandsBlob buffers). */
36
- declare function copyDerivedGlyphs(glyphs: DerivedTextGlyph[] | null): DerivedTextGlyph[] | null;
37
- declare function copyConnectorEndpoint(endpoint: ConnectorEndpoint): ConnectorEndpoint;
50
+ export declare function copyDerivedGlyphs(glyphs: DerivedTextGlyph[] | null): DerivedTextGlyph[] | null;
51
+ export declare function copyConnectorEndpoint(endpoint: ConnectorEndpoint): ConnectorEndpoint;
38
52
  /**
39
53
  * Build the init props for a deep-copy clone of `src`.
40
54
  * Shares logic between SceneGraph.cloneTree and instance child cloning.
@@ -42,8 +56,6 @@ declare function copyConnectorEndpoint(endpoint: ConnectorEndpoint): ConnectorEn
42
56
  * would otherwise share by reference. When adding a mutable SceneNode field,
43
57
  * add its copy behavior here or document why sharing is intentional.
44
58
  */
45
- type NodeCloneMode = 'deep' | 'fig-import';
46
- declare function cloneNodeProps(src: SceneNode, componentId: string | null, mode?: NodeCloneMode): Partial<SceneNode>;
47
- //#endregion
48
- export { NodeCloneMode, cloneNodeProps, cloneVectorNetwork, copyConnectorEndpoint, copyDerivedGlyphs, copyEffect, copyEffects, copyFill, copyFills, copyGeometryPaths, copyLayoutGrids, copyStroke, copyStrokes, copyStyleRun, copyStyleRuns, copyVectorRegion, hasSameCopySource, markCopySource, scaleGeometryPaths, transformGeometryBlob, transformGeometryPaths };
59
+ export type NodeCloneMode = 'deep' | 'fig-import';
60
+ export declare function cloneNodeProps(src: SceneNode, componentId: string | null, mode?: NodeCloneMode): Partial<SceneNode>;
49
61
  //# sourceMappingURL=copy.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"copy.d.ts","names":[],"sources":["../src/copy.ts"],"mappings":";;;iBAiCgB,SAAS,UAAU,MAAM,GAAG,IAAI;iBAWhC,WAAW,GAAG,SAAS;iBAQvB,WAAW,GAAG,SAAS;iBAevB,aAAa,GAAG,WAAW;;iBA2B3B,eAAe,kBAAkB,QAAQ,GAAG,MAAM,IAAI;;iBAMtD,kBAAkB,cAAc;iBAKhC,UAAU,OAAO,SAAS;iBAI1B,YAAY,SAAS,WAAW;iBAIhC,YAAY,SAAS,WAAW;iBAIhC,gBAAgB,OAAO,eAAe;iBAItC,cAAc,MAAM,aAAa;;iBAKjC,iBACd,QAAQ,cACR,qBACC;;iBAQa,mBAAmB,IAAI,gBAAgB;iBAYvC,kBAAkB,OAAO,iBAAiB;;;;;;;iBAU1C,sBACd,MAAM,YACN,aACA,aACA,aACA,aACA,aACA,cACC;iBAca,uBACd,OAAO,gBACP,aACA,aACA,aACA,aACA,aACA,cACC;;;;;iBAWa,mBAAmB,OAAO,gBAAgB,YAAY,aAAa;;iBAmCnE,kBAAkB,QAAQ,4BAA4B;iBAatD,sBAAsB,UAAU,oBAAoB;;;;;;;;KAiBxD;iBAUI,eACd,KAAK,WACL,4BACA,OAAM,gBACL,QAAQ"}
1
+ {"version":3,"file":"copy.d.ts","names":[],"sources":["../src/copy.ts"],"mappings":";;;;;;;;;;;;wBAmCgB,SAAS,UAAU,MAAM,GAAG,IAAI;wBAkBhC,WAAW,GAAG,SAAS;wBAQvB,WAAW,GAAG,SAAS;wBAiBvB,aAAa,GAAG,WAAW;;wBA2B3B,eAAe,kBAAkB,QAAQ,GAAG,MAAM,IAAI;;wBAMtD,kBAAkB,cAAc;wBAKhC,UAAU,OAAO,SAAS;wBAI1B,YAAY,SAAS,WAAW;wBAIhC,YAAY,SAAS,WAAW;;;;;wBAQhC,gBACd,SAAS,UACT,MAAM,OAAO,OAAO,iBAAiB,QACpC;wBAaa,gBAAgB,OAAO,eAAe;wBAItC,cAAc,MAAM,aAAa;;wBAKjC,iBACd,QAAQ,cACR,qBACC;;wBAQa,mBAAmB,IAAI,gBAAgB;wBAYvC,kBAAkB,OAAO,iBAAiB;;;;;;;wBAU1C,sBACd,MAAM,YACN,aACA,aACA,aACA,aACA,aACA,cACC;wBAca,uBACd,OAAO,gBACP,aACA,aACA,aACA,aACA,aACA,cACC;;;;;wBAWa,mBAAmB,OAAO,gBAAgB,YAAY,aAAa;;wBAmCnE,kBAAkB,QAAQ,4BAA4B;wBAatD,sBAAsB,UAAU,oBAAoB;;;;;;;;YAiBxD;wBAUI,eACd,KAAK,WACL,4BACA,OAAM,gBACL,QAAQ"}
package/dist/copy.js CHANGED
@@ -1,7 +1,7 @@
1
+ import { readGeometryBlob } from "./geometry.js";
1
2
  import { cloneInstanceOverrideState } from "./instances/overrides.js";
2
3
  import { createDefaultSourceMetadata } from "./node-defaults.js";
3
- import { readGeometryBlob } from "./geometry.js";
4
- //#region src/copy.ts
4
+ // src/copy.ts
5
5
  /**
6
6
  * Typed shallow-copy helpers for Fill, Stroke, Effect, and StyleRun.
7
7
  *
@@ -23,8 +23,13 @@ function copyFill(f) {
23
23
  if (f.filters) copy.filters = { ...f.filters };
24
24
  if (f.patternSpacing) copy.patternSpacing = { ...f.patternSpacing };
25
25
  if (f.noiseSize) copy.noiseSize = { ...f.noiseSize };
26
+ copyFigmaShaderFields(f, copy);
26
27
  return copy;
27
28
  }
29
+ function copyFigmaShaderFields(source, copy) {
30
+ if (source.customEffectAssetRef) copy.customEffectAssetRef = { ...source.customEffectAssetRef };
31
+ if (source.componentPropAssignments) copy.componentPropAssignments = structuredClone(source.componentPropAssignments);
32
+ }
28
33
  function copyStroke(s) {
29
34
  const copy = copyFill(s);
30
35
  if (s.dashPattern) copy.dashPattern = [...s.dashPattern];
@@ -39,6 +44,8 @@ function copyEffect(e) {
39
44
  if (e.glass) copy.glass = { ...e.glass };
40
45
  if (e.noise) copy.noise = structuredClone(e.noise);
41
46
  if (e.texture) copy.texture = structuredClone(e.texture);
47
+ if (e.shader) copy.shader = { ...e.shader };
48
+ copyFigmaShaderFields(e, copy);
42
49
  if (e.progressive) copy.progressive = {
43
50
  startRadius: e.progressive.startRadius,
44
51
  startOffset: { ...e.progressive.startOffset },
@@ -83,6 +90,23 @@ function copyStrokes(strokes) {
83
90
  function copyEffects(effects) {
84
91
  return effects.map(copyEffect);
85
92
  }
93
+ /**
94
+ * Copies of `effects` with every color they hold passed through `map`: each effect's own and a
95
+ * duotone noise's second color. `map` is told where each sits, `0` or `0.noise` for the first.
96
+ */
97
+ function mapEffectColors(effects, map) {
98
+ return copyEffects(effects).map((effect, index) => {
99
+ const next = {
100
+ ...effect,
101
+ color: map(effect.color, `${index}`)
102
+ };
103
+ if (effect.noise?.secondaryColor) next.noise = {
104
+ ...effect.noise,
105
+ secondaryColor: map(effect.noise.secondaryColor, `${index}.noise`)
106
+ };
107
+ return next;
108
+ });
109
+ }
86
110
  function copyLayoutGrids(grids) {
87
111
  return grids.map((grid) => ({
88
112
  ...grid,
@@ -250,6 +274,7 @@ function cloneNodeProps(src, componentId, mode = "deep") {
250
274
  pluginData: copySpread(src.pluginData),
251
275
  pluginRelaunchData: copySpread(src.pluginRelaunchData),
252
276
  exportSettings: copySpread(src.exportSettings),
277
+ deletedFrom: [],
253
278
  status: componentId === null ? src.status : null,
254
279
  componentPropertyValues: { ...src.componentPropertyValues },
255
280
  derivedLayout: src.derivedLayout ? { ...src.derivedLayout } : null,
@@ -261,6 +286,11 @@ function cloneNodeProps(src, componentId, mode = "deep") {
261
286
  textPathBox: src.textPathBox ? { ...src.textPathBox } : null,
262
287
  gridPosition: src.gridPosition ? { ...src.gridPosition } : null,
263
288
  targetAspectRatio: src.targetAspectRatio ? { ...src.targetAspectRatio } : null,
289
+ slide: structuredClone(src.slide),
290
+ animation: structuredClone(src.animation),
291
+ keyframeTracks: structuredClone(src.keyframeTracks),
292
+ timeline: structuredClone(src.timeline),
293
+ motionPresets: structuredClone(src.motionPresets),
264
294
  connectorStart: src.connectorStart ? copyConnectorEndpoint(src.connectorStart) : null,
265
295
  connectorEnd: src.connectorEnd ? copyConnectorEndpoint(src.connectorEnd) : null,
266
296
  connectorControlPoints: structuredClone(src.connectorControlPoints),
@@ -268,7 +298,6 @@ function cloneNodeProps(src, componentId, mode = "deep") {
268
298
  connectorLabelPosition: src.connectorLabelPosition ? { ...src.connectorLabelPosition } : null
269
299
  };
270
300
  }
271
- //#endregion
272
- export { cloneNodeProps, cloneVectorNetwork, copyConnectorEndpoint, copyDerivedGlyphs, copyEffect, copyEffects, copyFill, copyFills, copyGeometryPaths, copyLayoutGrids, copyStroke, copyStrokes, copyStyleRun, copyStyleRuns, copyVectorRegion, hasSameCopySource, markCopySource, scaleGeometryPaths, transformGeometryBlob, transformGeometryPaths };
301
+ export { cloneNodeProps, cloneVectorNetwork, copyConnectorEndpoint, copyDerivedGlyphs, copyEffect, copyEffects, copyFill, copyFills, copyGeometryPaths, copyLayoutGrids, copyStroke, copyStrokes, copyStyleRun, copyStyleRuns, copyVectorRegion, hasSameCopySource, mapEffectColors, markCopySource, scaleGeometryPaths, transformGeometryBlob, transformGeometryPaths };
273
302
 
274
303
  //# sourceMappingURL=copy.js.map
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.filters) copy.filters = { ...f.filters }\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.noise) copy.noise = structuredClone(e.noise)\n if (e.texture) copy.texture = structuredClone(e.texture)\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}\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,gBA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,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 { Color } from './primitives'\nimport type {\n ArcData,\n ComponentPropertyDefinition,\n ConnectorEndpoint,\n Effect,\n DerivedTextGlyph,\n FigmaShaderFields,\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.filters) copy.filters = { ...f.filters }\n if (f.patternSpacing) copy.patternSpacing = { ...f.patternSpacing }\n if (f.noiseSize) copy.noiseSize = { ...f.noiseSize }\n copyFigmaShaderFields(f, copy)\n return copy\n}\n\nfunction copyFigmaShaderFields(source: FigmaShaderFields, copy: FigmaShaderFields): void {\n if (source.customEffectAssetRef) copy.customEffectAssetRef = { ...source.customEffectAssetRef }\n if (source.componentPropAssignments)\n copy.componentPropAssignments = structuredClone(source.componentPropAssignments)\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.noise) copy.noise = structuredClone(e.noise)\n if (e.texture) copy.texture = structuredClone(e.texture)\n if (e.shader) copy.shader = { ...e.shader }\n copyFigmaShaderFields(e, copy)\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\n/**\n * Copies of `effects` with every color they hold passed through `map`: each effect's own and a\n * duotone noise's second color. `map` is told where each sits, `0` or `0.noise` for the first.\n */\nexport function mapEffectColors(\n effects: Effect[],\n map: (color: Color, slot: string) => Color\n): Effect[] {\n return copyEffects(effects).map((effect, index) => {\n const next = { ...effect, color: map(effect.color, `${index}`) }\n if (effect.noise?.secondaryColor) {\n next.noise = {\n ...effect.noise,\n secondaryColor: map(effect.noise.secondaryColor, `${index}.noise`)\n }\n }\n return next\n })\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 // A copy is a live layer, even of a main component kept for its instances.\n deletedFrom: [],\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 slide: structuredClone(src.slide),\n animation: structuredClone(src.animation),\n keyframeTracks: structuredClone(src.keyframeTracks),\n timeline: structuredClone(src.timeline),\n motionPresets: structuredClone(src.motionPresets),\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":";;;;;;;;;;;;;;AAmCA,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,SAAS,KAAK,UAAU,EAAE,GAAG,EAAE,QAAQ;CAC7C,IAAI,EAAE,gBAAgB,KAAK,iBAAiB,EAAE,GAAG,EAAE,eAAe;CAClE,IAAI,EAAE,WAAW,KAAK,YAAY,EAAE,GAAG,EAAE,UAAU;CACnD,sBAAsB,GAAG,IAAI;CAC7B,OAAO;AACT;AAEA,SAAS,sBAAsB,QAA2B,MAA+B;CACvF,IAAI,OAAO,sBAAsB,KAAK,uBAAuB,EAAE,GAAG,OAAO,qBAAqB;CAC9F,IAAI,OAAO,0BACT,KAAK,2BAA2B,gBAAgB,O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Q,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,OAAO,gBAAgB,IAAI,KAAK;EAChC,WAAW,gBAAgB,IAAI,SAAS;EACxC,gBAAgB,gBAAgB,IAAI,cAAc;EAClD,UAAU,gBAAgB,IAAI,QAAQ;EACtC,eAAe,gBAAgB,IAAI,aAAa;EAChD,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"}
package/dist/corners.d.ts CHANGED
@@ -1,22 +1,22 @@
1
1
  import { SceneNode } from "./types.js";
2
- //#region src/corners.d.ts
2
+ /** The radius a pill takes: round at the ends at any size a layer reaches. */
3
+ export declare const PILL_RADIUS = 9999;
3
4
  /** A rectangle's corner radii, clockwise from the top left. */
4
- type CornerRadii = [topLeft: number, topRight: number, bottomRight: number, bottomLeft: number];
5
+ export type CornerRadii = [topLeft: number, topRight: number, bottomRight: number, bottomLeft: number];
5
6
  type CornerNode = Pick<SceneNode, 'width' | 'height' | 'cornerRadius' | 'independentCorners' | 'topLeftRadius' | 'topRightRadius' | 'bottomRightRadius' | 'bottomLeftRadius'>;
6
7
  /** The radii a layer asks for, clockwise from the top left, none below zero. */
7
- declare function cornerRadii(node: Omit<CornerNode, 'width' | 'height'>): CornerRadii;
8
+ export declare function cornerRadii(node: Omit<CornerNode, 'width' | 'height'>): CornerRadii;
8
9
  /**
9
10
  * The radii a `width` × `height` box draws. An edge whose two corners ask for more than its length
10
11
  * scales them by its length over their sum, and each corner takes the tighter of its two edges'
11
12
  * scales (Figma desktop, live: 90, 30, 0, 60 in a 100 × 100 box draw 60, 25, 0, 40).
12
13
  */
13
- declare function fittedCornerRadii(width: number, height: number, radii: CornerRadii): CornerRadii;
14
+ export declare function fittedCornerRadii(width: number, height: number, radii: CornerRadii): CornerRadii;
14
15
  /** The radii a layer's corners draw at, fitted to its box. */
15
- declare function nodeCornerRadii(node: CornerNode): CornerRadii;
16
+ export declare function nodeCornerRadii(node: CornerNode): CornerRadii;
16
17
  /** Whether a layer rounds any corner. */
17
- declare function nodeHasRadius(node: Pick<SceneNode, 'cornerRadius' | 'independentCorners' | 'topLeftRadius' | 'topRightRadius' | 'bottomRightRadius' | 'bottomLeftRadius'>): boolean;
18
+ export declare function nodeHasRadius(node: Pick<SceneNode, 'cornerRadius' | 'independentCorners' | 'topLeftRadius' | 'topRightRadius' | 'bottomRightRadius' | 'bottomLeftRadius'>): boolean;
18
19
  /** Whether a layer smooths a corner it rounds. */
19
- declare function nodeHasSmoothCorners(node: Parameters<typeof nodeHasRadius>[0] & Pick<SceneNode, 'cornerSmoothing'>): boolean;
20
- //#endregion
21
- export { CornerRadii, cornerRadii, fittedCornerRadii, nodeCornerRadii, nodeHasRadius, nodeHasSmoothCorners };
20
+ export declare function nodeHasSmoothCorners(node: Parameters<typeof nodeHasRadius>[0] & Pick<SceneNode, 'cornerSmoothing'>): boolean;
21
+ export {};
22
22
  //# sourceMappingURL=corners.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"corners.d.ts","names":[],"sources":["../src/corners.ts"],"mappings":";;;KAGY,eACV,iBACA,kBACA,qBACA;KAGG,aAAa,KAChB;;iBAYc,YAAY,MAAM,KAAK,kCAAkC;;;;;;iBAYzD,kBAAkB,eAAe,gBAAgB,OAAO,cAAc;;iBAiBtE,gBAAgB,MAAM,aAAa;;iBAKnC,cACd,MAAM,KACJ;;iBAoBY,qBACd,MAAM,kBAAkB,oBAAoB,KAAK"}
1
+ {"version":3,"file":"corners.d.ts","names":[],"sources":["../src/corners.ts"],"mappings":";;qBAGa;;YAGD,eACV,iBACA,kBACA,qBACA;KAGG,aAAa,KAChB;;wBAYc,YAAY,MAAM,KAAK,kCAAkC;;;;;;wBAYzD,kBAAkB,eAAe,gBAAgB,OAAO,cAAc;;wBAiBtE,gBAAgB,MAAM,aAAa;;wBAKnC,cACd,MAAM,KACJ;;wBAoBY,qBACd,MAAM,kBAAkB,oBAAoB,KAAK"}
package/dist/corners.js CHANGED
@@ -1,4 +1,6 @@
1
- //#region src/corners.ts
1
+ // src/corners.ts
2
+ /** The radius a pill takes: round at the ends at any size a layer reaches. */
3
+ const PILL_RADIUS = 9999;
2
4
  /** The radii a layer asks for, clockwise from the top left, none below zero. */
3
5
  function cornerRadii(node) {
4
6
  return (node.independentCorners ? [
@@ -46,7 +48,6 @@ function nodeHasSmoothCorners(node) {
46
48
  if (node.independentCorners) return node.topLeftRadius > 0 || node.topRightRadius > 0 || node.bottomRightRadius > 0 || node.bottomLeftRadius > 0;
47
49
  return node.cornerRadius > 0;
48
50
  }
49
- //#endregion
50
- export { cornerRadii, fittedCornerRadii, nodeCornerRadii, nodeHasRadius, nodeHasSmoothCorners };
51
+ export { PILL_RADIUS, cornerRadii, fittedCornerRadii, nodeCornerRadii, nodeHasRadius, nodeHasSmoothCorners };
51
52
 
52
53
  //# sourceMappingURL=corners.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"corners.js","names":[],"sources":["../src/corners.ts"],"sourcesContent":["import type { SceneNode } from './types'\n\n/** A rectangle's corner radii, clockwise from the top left. */\nexport type CornerRadii = [\n topLeft: number,\n topRight: number,\n bottomRight: number,\n bottomLeft: number\n]\n\ntype CornerNode = Pick<\n SceneNode,\n | 'width'\n | 'height'\n | 'cornerRadius'\n | 'independentCorners'\n | 'topLeftRadius'\n | 'topRightRadius'\n | 'bottomRightRadius'\n | 'bottomLeftRadius'\n>\n\n/** The radii a layer asks for, clockwise from the top left, none below zero. */\nexport function cornerRadii(node: Omit<CornerNode, 'width' | 'height'>): CornerRadii {\n const radii: CornerRadii = node.independentCorners\n ? [node.topLeftRadius, node.topRightRadius, node.bottomRightRadius, node.bottomLeftRadius]\n : [node.cornerRadius, node.cornerRadius, node.cornerRadius, node.cornerRadius]\n return radii.map((radius) => Math.max(0, radius)) as CornerRadii\n}\n\n/**\n * The radii a `width` × `height` box draws. An edge whose two corners ask for more than its length\n * scales them by its length over their sum, and each corner takes the tighter of its two edges'\n * scales (Figma desktop, live: 90, 30, 0, 60 in a 100 × 100 box draw 60, 25, 0, 40).\n */\nexport function fittedCornerRadii(width: number, height: number, radii: CornerRadii): CornerRadii {\n const [topLeft, topRight, bottomRight, bottomLeft] = radii\n const scale = (length: number, a: number, b: number) =>\n a + b > length ? Math.max(0, length) / (a + b) : 1\n const top = scale(width, topLeft, topRight)\n const right = scale(height, topRight, bottomRight)\n const bottom = scale(width, bottomRight, bottomLeft)\n const left = scale(height, bottomLeft, topLeft)\n return [\n topLeft * Math.min(top, left),\n topRight * Math.min(top, right),\n bottomRight * Math.min(right, bottom),\n bottomLeft * Math.min(bottom, left)\n ]\n}\n\n/** The radii a layer's corners draw at, fitted to its box. */\nexport function nodeCornerRadii(node: CornerNode): CornerRadii {\n return fittedCornerRadii(node.width, node.height, cornerRadii(node))\n}\n\n/** Whether a layer rounds any corner. */\nexport function nodeHasRadius(\n node: Pick<\n SceneNode,\n | 'cornerRadius'\n | 'independentCorners'\n | 'topLeftRadius'\n | 'topRightRadius'\n | 'bottomRightRadius'\n | 'bottomLeftRadius'\n >\n): boolean {\n return (\n node.cornerRadius > 0 ||\n (node.independentCorners &&\n (node.topLeftRadius > 0 ||\n node.topRightRadius > 0 ||\n node.bottomRightRadius > 0 ||\n node.bottomLeftRadius > 0))\n )\n}\n\n/** Whether a layer smooths a corner it rounds. */\nexport function nodeHasSmoothCorners(\n node: Parameters<typeof nodeHasRadius>[0] & Pick<SceneNode, 'cornerSmoothing'>\n): boolean {\n if (!(node.cornerSmoothing > 0)) return false\n if (node.independentCorners) {\n return (\n node.topLeftRadius > 0 ||\n node.topRightRadius > 0 ||\n node.bottomRightRadius > 0 ||\n node.bottomLeftRadius > 0\n )\n }\n return node.cornerRadius > 0\n}\n"],"mappings":";;AAuBA,SAAgB,YAAY,MAAyD;CAInF,QAH2B,KAAK,qBAC5B;EAAC,KAAK;EAAe,KAAK;EAAgB,KAAK;EAAmB,KAAK;CAAgB,IACvF;EAAC,KAAK;EAAc,KAAK;EAAc,KAAK;EAAc,KAAK;CAAY,EAAA,CAClE,KAAK,WAAW,KAAK,IAAI,GAAG,MAAM,CAAC;AAClD;;;;;;AAOA,SAAgB,kBAAkB,OAAe,QAAgB,OAAiC;CAChG,MAAM,CAAC,SAAS,UAAU,aAAa,cAAc;CACrD,MAAM,SAAS,QAAgB,GAAW,MACxC,IAAI,IAAI,SAAS,KAAK,IAAI,GAAG,MAAM,KAAK,IAAI,KAAK;CACnD,MAAM,MAAM,MAAM,OAAO,SAAS,QAAQ;CAC1C,MAAM,QAAQ,MAAM,QAAQ,UAAU,WAAW;CACjD,MAAM,SAAS,MAAM,OAAO,aAAa,UAAU;CACnD,MAAM,OAAO,MAAM,QAAQ,YAAY,OAAO;CAC9C,OAAO;EACL,UAAU,KAAK,IAAI,KAAK,IAAI;EAC5B,WAAW,KAAK,IAAI,KAAK,KAAK;EAC9B,cAAc,KAAK,IAAI,OAAO,MAAM;EACpC,aAAa,KAAK,IAAI,QAAQ,IAAI;CACpC;AACF;;AAGA,SAAgB,gBAAgB,MAA+B;CAC7D,OAAO,kBAAkB,KAAK,OAAO,KAAK,QAAQ,YAAY,IAAI,CAAC;AACrE;;AAGA,SAAgB,cACd,MASS;CACT,OACE,KAAK,eAAe,KACnB,KAAK,uBACH,KAAK,gBAAgB,KACpB,KAAK,iBAAiB,KACtB,KAAK,oBAAoB,KACzB,KAAK,mBAAmB;AAEhC;;AAGA,SAAgB,qBACd,MACS;CACT,IAAI,EAAE,KAAK,kBAAkB,IAAI,OAAO;CACxC,IAAI,KAAK,oBACP,OACE,KAAK,gBAAgB,KACrB,KAAK,iBAAiB,KACtB,KAAK,oBAAoB,KACzB,KAAK,mBAAmB;CAG5B,OAAO,KAAK,eAAe;AAC7B"}
1
+ {"version":3,"file":"corners.js","names":[],"sources":["../src/corners.ts"],"sourcesContent":["import type { SceneNode } from './types'\n\n/** The radius a pill takes: round at the ends at any size a layer reaches. */\nexport const PILL_RADIUS = 9999\n\n/** A rectangle's corner radii, clockwise from the top left. */\nexport type CornerRadii = [\n topLeft: number,\n topRight: number,\n bottomRight: number,\n bottomLeft: number\n]\n\ntype CornerNode = Pick<\n SceneNode,\n | 'width'\n | 'height'\n | 'cornerRadius'\n | 'independentCorners'\n | 'topLeftRadius'\n | 'topRightRadius'\n | 'bottomRightRadius'\n | 'bottomLeftRadius'\n>\n\n/** The radii a layer asks for, clockwise from the top left, none below zero. */\nexport function cornerRadii(node: Omit<CornerNode, 'width' | 'height'>): CornerRadii {\n const radii: CornerRadii = node.independentCorners\n ? [node.topLeftRadius, node.topRightRadius, node.bottomRightRadius, node.bottomLeftRadius]\n : [node.cornerRadius, node.cornerRadius, node.cornerRadius, node.cornerRadius]\n return radii.map((radius) => Math.max(0, radius)) as CornerRadii\n}\n\n/**\n * The radii a `width` × `height` box draws. An edge whose two corners ask for more than its length\n * scales them by its length over their sum, and each corner takes the tighter of its two edges'\n * scales (Figma desktop, live: 90, 30, 0, 60 in a 100 × 100 box draw 60, 25, 0, 40).\n */\nexport function fittedCornerRadii(width: number, height: number, radii: CornerRadii): CornerRadii {\n const [topLeft, topRight, bottomRight, bottomLeft] = radii\n const scale = (length: number, a: number, b: number) =>\n a + b > length ? Math.max(0, length) / (a + b) : 1\n const top = scale(width, topLeft, topRight)\n const right = scale(height, topRight, bottomRight)\n const bottom = scale(width, bottomRight, bottomLeft)\n const left = scale(height, bottomLeft, topLeft)\n return [\n topLeft * Math.min(top, left),\n topRight * Math.min(top, right),\n bottomRight * Math.min(right, bottom),\n bottomLeft * Math.min(bottom, left)\n ]\n}\n\n/** The radii a layer's corners draw at, fitted to its box. */\nexport function nodeCornerRadii(node: CornerNode): CornerRadii {\n return fittedCornerRadii(node.width, node.height, cornerRadii(node))\n}\n\n/** Whether a layer rounds any corner. */\nexport function nodeHasRadius(\n node: Pick<\n SceneNode,\n | 'cornerRadius'\n | 'independentCorners'\n | 'topLeftRadius'\n | 'topRightRadius'\n | 'bottomRightRadius'\n | 'bottomLeftRadius'\n >\n): boolean {\n return (\n node.cornerRadius > 0 ||\n (node.independentCorners &&\n (node.topLeftRadius > 0 ||\n node.topRightRadius > 0 ||\n node.bottomRightRadius > 0 ||\n node.bottomLeftRadius > 0))\n )\n}\n\n/** Whether a layer smooths a corner it rounds. */\nexport function nodeHasSmoothCorners(\n node: Parameters<typeof nodeHasRadius>[0] & Pick<SceneNode, 'cornerSmoothing'>\n): boolean {\n if (!(node.cornerSmoothing > 0)) return false\n if (node.independentCorners) {\n return (\n node.topLeftRadius > 0 ||\n node.topRightRadius > 0 ||\n node.bottomRightRadius > 0 ||\n node.bottomLeftRadius > 0\n )\n }\n return node.cornerRadius > 0\n}\n"],"mappings":";;AAGA,MAAa,cAAc;;AAuB3B,SAAgB,YAAY,MAAyD;CAInF,QAH2B,KAAK,qBAC5B;EAAC,KAAK;EAAe,KAA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