@open-pencil/scene-graph 0.16.0 → 0.17.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 (885) hide show
  1. package/dist/arrow-caps.d.ts +35 -14
  2. package/dist/arrow-caps.d.ts.map +1 -1
  3. package/dist/arrow-caps.js +286 -55
  4. package/dist/arrow-caps.js.map +1 -1
  5. package/dist/asset-keys.d.ts +17 -0
  6. package/dist/asset-keys.d.ts.map +1 -0
  7. package/dist/asset-keys.js.map +1 -0
  8. package/dist/behaviours/index.d.ts +6 -0
  9. package/dist/behaviours/index.js +6 -0
  10. package/dist/behaviours/kinds.d.ts +62 -0
  11. package/dist/behaviours/kinds.d.ts.map +1 -0
  12. package/dist/{chunks/behaviours → behaviours}/kinds.js +76 -75
  13. package/dist/behaviours/kinds.js.map +1 -0
  14. package/dist/behaviours/layers.d.ts +16 -0
  15. package/dist/behaviours/layers.d.ts.map +1 -0
  16. package/dist/behaviours/layers.js +43 -0
  17. package/dist/behaviours/layers.js.map +1 -0
  18. package/dist/behaviours/model.d.ts +48 -0
  19. package/dist/behaviours/model.d.ts.map +1 -0
  20. package/dist/behaviours/model.js +156 -0
  21. package/dist/behaviours/model.js.map +1 -0
  22. package/dist/behaviours/schema.d.ts +228 -0
  23. package/dist/behaviours/schema.d.ts.map +1 -0
  24. package/dist/behaviours/schema.js +86 -0
  25. package/dist/behaviours/schema.js.map +1 -0
  26. package/dist/behaviours/spec.d.ts +26 -0
  27. package/dist/behaviours/spec.d.ts.map +1 -0
  28. package/dist/{chunks/behaviours → behaviours}/spec.js +6 -29
  29. package/dist/behaviours/spec.js.map +1 -0
  30. package/dist/bindings.js +26 -0
  31. package/dist/bindings.js.map +1 -0
  32. package/dist/buffered-events.d.ts +21 -0
  33. package/dist/buffered-events.d.ts.map +1 -0
  34. package/dist/buffered-events.js.map +1 -0
  35. package/dist/checkpoint.d.ts +42 -0
  36. package/dist/checkpoint.d.ts.map +1 -0
  37. package/dist/checkpoint.js +249 -0
  38. package/dist/checkpoint.js.map +1 -0
  39. package/dist/clipping.d.ts +31 -0
  40. package/dist/clipping.d.ts.map +1 -0
  41. package/dist/clipping.js +125 -0
  42. package/dist/clipping.js.map +1 -0
  43. package/dist/color/contrast.d.ts +17 -0
  44. package/dist/color/contrast.d.ts.map +1 -0
  45. package/dist/{chunks/color → color}/contrast.js +2 -24
  46. package/dist/color/contrast.js.map +1 -0
  47. package/dist/color/index.d.ts +38 -0
  48. package/dist/color/index.d.ts.map +1 -0
  49. package/dist/color/index.js +110 -0
  50. package/dist/color/index.js.map +1 -0
  51. package/dist/color/management.d.ts +32 -0
  52. package/dist/color/management.d.ts.map +1 -0
  53. package/dist/color/management.js +187 -0
  54. package/dist/color/management.js.map +1 -0
  55. package/dist/color/normalize.d.ts +6 -0
  56. package/dist/color/normalize.d.ts.map +1 -0
  57. package/dist/color/normalize.js +15 -0
  58. package/dist/color/normalize.js.map +1 -0
  59. package/dist/color/okhcl.d.ts +33 -0
  60. package/dist/color/okhcl.d.ts.map +1 -0
  61. package/dist/color/okhcl.js +146 -0
  62. package/dist/color/okhcl.js.map +1 -0
  63. package/dist/color/schema.d.ts +11 -0
  64. package/dist/color/schema.d.ts.map +1 -0
  65. package/dist/color/schema.js +13 -0
  66. package/dist/color/schema.js.map +1 -0
  67. package/dist/comments/document.d.ts +23 -0
  68. package/dist/comments/document.d.ts.map +1 -0
  69. package/dist/{chunks/comments → comments}/document.js +2 -1
  70. package/dist/comments/document.js.map +1 -0
  71. package/dist/comments/index.d.ts +6 -0
  72. package/dist/comments/index.js +6 -0
  73. package/dist/comments/list.d.ts +25 -0
  74. package/dist/comments/list.d.ts.map +1 -0
  75. package/dist/comments/list.js +33 -0
  76. package/dist/comments/list.js.map +1 -0
  77. package/dist/comments/merge.d.ts +16 -0
  78. package/dist/comments/merge.d.ts.map +1 -0
  79. package/dist/{chunks/comments → comments}/merge.js +1 -1
  80. package/dist/comments/merge.js.map +1 -0
  81. package/dist/comments/schema.d.ts +8 -0
  82. package/dist/comments/schema.d.ts.map +1 -0
  83. package/dist/comments/schema.js +50 -0
  84. package/dist/comments/schema.js.map +1 -0
  85. package/dist/comments/threads.d.ts +59 -0
  86. package/dist/comments/threads.d.ts.map +1 -0
  87. package/dist/{chunks/comments/list.js → comments/threads.js} +3 -53
  88. package/dist/comments/threads.js.map +1 -0
  89. package/dist/components/exposure.d.ts +24 -0
  90. package/dist/components/exposure.d.ts.map +1 -0
  91. package/dist/components/exposure.js +51 -0
  92. package/dist/components/exposure.js.map +1 -0
  93. package/dist/components/index.d.ts +4 -0
  94. package/dist/components/index.js +4 -0
  95. package/dist/components/properties.d.ts +32 -0
  96. package/dist/components/properties.d.ts.map +1 -0
  97. package/dist/components/properties.js +180 -0
  98. package/dist/components/properties.js.map +1 -0
  99. package/dist/components/variants.d.ts +33 -0
  100. package/dist/components/variants.d.ts.map +1 -0
  101. package/dist/components/variants.js +58 -0
  102. package/dist/components/variants.js.map +1 -0
  103. package/dist/connectors/controls.d.ts +34 -0
  104. package/dist/connectors/controls.d.ts.map +1 -0
  105. package/dist/connectors/controls.js +196 -0
  106. package/dist/connectors/controls.js.map +1 -0
  107. package/dist/connectors/create.d.ts +23 -0
  108. package/dist/connectors/create.d.ts.map +1 -0
  109. package/dist/connectors/create.js +33 -0
  110. package/dist/connectors/create.js.map +1 -0
  111. package/dist/connectors/elbow.js +191 -0
  112. package/dist/connectors/elbow.js.map +1 -0
  113. package/dist/connectors/gaps.d.ts +10 -0
  114. package/dist/connectors/gaps.d.ts.map +1 -0
  115. package/dist/connectors/gaps.js +86 -0
  116. package/dist/connectors/gaps.js.map +1 -0
  117. package/dist/connectors/hit.d.ts +11 -0
  118. package/dist/connectors/hit.d.ts.map +1 -0
  119. package/dist/connectors/hit.js +47 -0
  120. package/dist/connectors/hit.js.map +1 -0
  121. package/dist/connectors/index.d.ts +11 -0
  122. package/dist/connectors/index.js +11 -0
  123. package/dist/connectors/label.d.ts +32 -0
  124. package/dist/connectors/label.d.ts.map +1 -0
  125. package/dist/connectors/label.js +213 -0
  126. package/dist/connectors/label.js.map +1 -0
  127. package/dist/connectors/layout.d.ts +46 -0
  128. package/dist/connectors/layout.d.ts.map +1 -0
  129. package/dist/connectors/layout.js +234 -0
  130. package/dist/connectors/layout.js.map +1 -0
  131. package/dist/connectors/pieces.d.ts +22 -0
  132. package/dist/connectors/pieces.d.ts.map +1 -0
  133. package/dist/connectors/pieces.js +156 -0
  134. package/dist/connectors/pieces.js.map +1 -0
  135. package/dist/connectors/route.d.ts +23 -0
  136. package/dist/connectors/route.d.ts.map +1 -0
  137. package/dist/connectors/route.js +107 -0
  138. package/dist/connectors/route.js.map +1 -0
  139. package/dist/connectors/sides.d.ts +23 -0
  140. package/dist/connectors/sides.d.ts.map +1 -0
  141. package/dist/connectors/sides.js +98 -0
  142. package/dist/connectors/sides.js.map +1 -0
  143. package/dist/connectors/sublayers.d.ts +76 -0
  144. package/dist/connectors/sublayers.d.ts.map +1 -0
  145. package/dist/connectors/sublayers.js +208 -0
  146. package/dist/connectors/sublayers.js.map +1 -0
  147. package/dist/constants.d.ts +11 -2
  148. package/dist/constants.d.ts.map +1 -0
  149. package/dist/constants.js +25 -1
  150. package/dist/constants.js.map +1 -0
  151. package/dist/coordinate.d.ts +94 -2
  152. package/dist/coordinate.d.ts.map +1 -0
  153. package/dist/coordinate.js +268 -1
  154. package/dist/coordinate.js.map +1 -0
  155. package/dist/copy.d.ts +49 -2
  156. package/dist/copy.d.ts.map +1 -0
  157. package/dist/copy.js +264 -2
  158. package/dist/copy.js.map +1 -0
  159. package/dist/css/blend.d.ts +11 -0
  160. package/dist/css/blend.d.ts.map +1 -0
  161. package/dist/css/blend.js +30 -0
  162. package/dist/css/blend.js.map +1 -0
  163. package/dist/css/grid.d.ts +7 -0
  164. package/dist/css/grid.d.ts.map +1 -0
  165. package/dist/{chunks/css → css}/grid.js +2 -33
  166. package/dist/css/grid.js.map +1 -0
  167. package/dist/css/index.d.ts +7 -0
  168. package/dist/css/index.js +7 -0
  169. package/dist/css/layout.d.ts +17 -0
  170. package/dist/css/layout.d.ts.map +1 -0
  171. package/dist/css/layout.js +45 -0
  172. package/dist/css/layout.js.map +1 -0
  173. package/dist/css/shadows.d.ts +10 -0
  174. package/dist/css/shadows.d.ts.map +1 -0
  175. package/dist/css/shadows.js +64 -0
  176. package/dist/css/shadows.js.map +1 -0
  177. package/dist/css/text.d.ts +22 -0
  178. package/dist/css/text.d.ts.map +1 -0
  179. package/dist/css/text.js +76 -0
  180. package/dist/css/text.js.map +1 -0
  181. package/dist/css/values.d.ts +14 -0
  182. package/dist/css/values.d.ts.map +1 -0
  183. package/dist/css/values.js +36 -0
  184. package/dist/css/values.js.map +1 -0
  185. package/dist/cubic.d.ts +7 -0
  186. package/dist/cubic.d.ts.map +1 -0
  187. package/dist/cubic.js +17 -0
  188. package/dist/cubic.js.map +1 -0
  189. package/dist/events.js.map +1 -0
  190. package/dist/export-format.d.ts +25 -0
  191. package/dist/export-format.d.ts.map +1 -0
  192. package/dist/export-format.js +47 -0
  193. package/dist/export-format.js.map +1 -0
  194. package/dist/export-scale.d.ts +14 -0
  195. package/dist/export-scale.d.ts.map +1 -0
  196. package/dist/export-scale.js +19 -0
  197. package/dist/export-scale.js.map +1 -0
  198. package/dist/fields/appearance.d.ts +9 -0
  199. package/dist/fields/appearance.d.ts.map +1 -0
  200. package/dist/fields/appearance.js +36 -0
  201. package/dist/fields/appearance.js.map +1 -0
  202. package/dist/fields/geometry.d.ts +7 -0
  203. package/dist/fields/geometry.d.ts.map +1 -0
  204. package/dist/fields/geometry.js.map +1 -0
  205. package/dist/fields/index.d.ts +5 -0
  206. package/dist/fields/index.js +5 -0
  207. package/dist/fields/layout.d.ts +10 -0
  208. package/dist/fields/layout.d.ts.map +1 -0
  209. package/dist/fields/layout.js +49 -0
  210. package/dist/fields/layout.js.map +1 -0
  211. package/dist/fields/text.d.ts +11 -0
  212. package/dist/fields/text.d.ts.map +1 -0
  213. package/dist/fields/text.js +64 -0
  214. package/dist/fields/text.js.map +1 -0
  215. package/dist/fig-compression.d.ts +11 -0
  216. package/dist/fig-compression.d.ts.map +1 -0
  217. package/dist/fig-compression.js +15 -0
  218. package/dist/fig-compression.js.map +1 -0
  219. package/dist/figjam/index.d.ts +3 -0
  220. package/dist/figjam/index.js +3 -0
  221. package/dist/figjam/palette.d.ts +270 -0
  222. package/dist/figjam/palette.d.ts.map +1 -0
  223. package/dist/figjam/palette.js +439 -0
  224. package/dist/figjam/palette.js.map +1 -0
  225. package/dist/figjam/text.d.ts +70 -0
  226. package/dist/figjam/text.d.ts.map +1 -0
  227. package/dist/figjam/text.js +95 -0
  228. package/dist/figjam/text.js.map +1 -0
  229. package/dist/font-style.d.ts +46 -0
  230. package/dist/font-style.d.ts.map +1 -0
  231. package/dist/font-style.js +127 -0
  232. package/dist/font-style.js.map +1 -0
  233. package/dist/generated/index.d.ts +44 -0
  234. package/dist/generated/index.d.ts.map +1 -0
  235. package/dist/generated/index.js +58 -0
  236. package/dist/generated/index.js.map +1 -0
  237. package/dist/generated/kind.d.ts +27 -0
  238. package/dist/generated/kind.d.ts.map +1 -0
  239. package/dist/generated/shape-with-text.d.ts +43 -0
  240. package/dist/generated/shape-with-text.d.ts.map +1 -0
  241. package/dist/generated/shape-with-text.js +135 -0
  242. package/dist/generated/shape-with-text.js.map +1 -0
  243. package/dist/generated/sticky.d.ts +128 -0
  244. package/dist/generated/sticky.d.ts.map +1 -0
  245. package/dist/generated/sticky.js +233 -0
  246. package/dist/generated/sticky.js.map +1 -0
  247. package/dist/geometry.d.ts +89 -2
  248. package/dist/geometry.d.ts.map +1 -0
  249. package/dist/geometry.js +306 -2
  250. package/dist/geometry.js.map +1 -0
  251. package/dist/gradient.d.ts +9 -2
  252. package/dist/gradient.d.ts.map +1 -1
  253. package/dist/gradient.js +13 -1
  254. package/dist/gradient.js.map +1 -1
  255. package/dist/graph.d.ts +178 -0
  256. package/dist/graph.d.ts.map +1 -0
  257. package/dist/graph.js +625 -0
  258. package/dist/graph.js.map +1 -0
  259. package/dist/group-bounds.d.ts +42 -0
  260. package/dist/group-bounds.d.ts.map +1 -0
  261. package/dist/{chunks/group-bounds.js → group-bounds.js} +56 -14
  262. package/dist/group-bounds.js.map +1 -0
  263. package/dist/guides.d.ts +21 -2
  264. package/dist/guides.d.ts.map +1 -0
  265. package/dist/guides.js +5 -1
  266. package/dist/guides.js.map +1 -1
  267. package/dist/hit-test.d.ts +48 -2
  268. package/dist/hit-test.d.ts.map +1 -0
  269. package/dist/hit-test.js +75 -57
  270. package/dist/hit-test.js.map +1 -1
  271. package/dist/icons/glyph.d.ts +22 -0
  272. package/dist/icons/glyph.d.ts.map +1 -0
  273. package/dist/{chunks/icons → icons}/glyph.js +2 -40
  274. package/dist/icons/glyph.js.map +1 -0
  275. package/dist/icons/index.d.ts +4 -0
  276. package/dist/icons/index.js +4 -0
  277. package/dist/icons/model.d.ts +29 -0
  278. package/dist/icons/model.d.ts.map +1 -0
  279. package/dist/icons/model.js +51 -0
  280. package/dist/icons/model.js.map +1 -0
  281. package/dist/icons/schema.d.ts +31 -0
  282. package/dist/icons/schema.d.ts.map +1 -0
  283. package/dist/icons/schema.js +28 -0
  284. package/dist/icons/schema.js.map +1 -0
  285. package/dist/ids.d.ts +12 -0
  286. package/dist/ids.d.ts.map +1 -0
  287. package/dist/ids.js +31 -0
  288. package/dist/ids.js.map +1 -0
  289. package/dist/images.d.ts +39 -2
  290. package/dist/images.d.ts.map +1 -0
  291. package/dist/images.js +67 -9
  292. package/dist/images.js.map +1 -1
  293. package/dist/index.d.ts +5 -7
  294. package/dist/index.js +5 -23
  295. package/dist/instances/assignments.js +89 -0
  296. package/dist/instances/assignments.js.map +1 -0
  297. package/dist/instances/content-size.js +60 -0
  298. package/dist/instances/content-size.js.map +1 -0
  299. package/dist/instances/copies.js +161 -0
  300. package/dist/instances/copies.js.map +1 -0
  301. package/dist/instances/cycles.d.ts +20 -0
  302. package/dist/instances/cycles.d.ts.map +1 -0
  303. package/dist/instances/cycles.js +53 -0
  304. package/dist/instances/cycles.js.map +1 -0
  305. package/dist/instances/fields.d.ts +18 -0
  306. package/dist/instances/fields.d.ts.map +1 -0
  307. package/dist/instances/fields.js +90 -0
  308. package/dist/instances/fields.js.map +1 -0
  309. package/dist/instances/index.d.ts +38 -0
  310. package/dist/instances/index.d.ts.map +1 -0
  311. package/dist/instances/index.js +180 -0
  312. package/dist/instances/index.js.map +1 -0
  313. package/dist/instances/kept-overrides.js +204 -0
  314. package/dist/instances/kept-overrides.js.map +1 -0
  315. package/dist/instances/main-component.d.ts +13 -0
  316. package/dist/instances/main-component.d.ts.map +1 -0
  317. package/dist/instances/main-component.js +50 -0
  318. package/dist/instances/main-component.js.map +1 -0
  319. package/dist/instances/overrides.d.ts +51 -0
  320. package/dist/instances/overrides.d.ts.map +1 -0
  321. package/dist/instances/overrides.js +158 -0
  322. package/dist/instances/overrides.js.map +1 -0
  323. package/dist/instances/placement.js +30 -0
  324. package/dist/instances/placement.js.map +1 -0
  325. package/dist/instances/source-walk.js +31 -0
  326. package/dist/instances/source-walk.js.map +1 -0
  327. package/dist/instances/swap.js +288 -0
  328. package/dist/instances/swap.js.map +1 -0
  329. package/dist/instances/sync.js +327 -0
  330. package/dist/instances/sync.js.map +1 -0
  331. package/dist/instances/vector-geometry.js +70 -0
  332. package/dist/instances/vector-geometry.js.map +1 -0
  333. package/dist/layout/aspect-ratio.d.ts +27 -0
  334. package/dist/layout/aspect-ratio.d.ts.map +1 -0
  335. package/dist/layout/aspect-ratio.js +45 -0
  336. package/dist/layout/aspect-ratio.js.map +1 -0
  337. package/dist/layout/guides.d.ts +25 -0
  338. package/dist/layout/guides.d.ts.map +1 -0
  339. package/dist/layout/guides.js +105 -0
  340. package/dist/layout/guides.js.map +1 -0
  341. package/dist/layout/index.d.ts +5 -0
  342. package/dist/{layout.js → layout/index.js} +4 -3
  343. package/dist/layout/keywords.d.ts +26 -0
  344. package/dist/layout/keywords.d.ts.map +1 -0
  345. package/dist/layout/keywords.js +59 -0
  346. package/dist/layout/keywords.js.map +1 -0
  347. package/dist/layout/sizing.d.ts +40 -0
  348. package/dist/layout/sizing.d.ts.map +1 -0
  349. package/dist/layout/sizing.js +122 -0
  350. package/dist/layout/sizing.js.map +1 -0
  351. package/dist/layout/writes.js +55 -0
  352. package/dist/layout/writes.js.map +1 -0
  353. package/dist/matrix.d.ts +16 -2
  354. package/dist/matrix.d.ts.map +1 -0
  355. package/dist/matrix.js +119 -1
  356. package/dist/matrix.js.map +1 -0
  357. package/dist/mutation-impact.d.ts +23 -0
  358. package/dist/mutation-impact.d.ts.map +1 -0
  359. package/dist/mutation-impact.js +67 -0
  360. package/dist/mutation-impact.js.map +1 -0
  361. package/dist/node-defaults.d.ts +22 -2
  362. package/dist/node-defaults.d.ts.map +1 -0
  363. package/dist/node-defaults.js +254 -2
  364. package/dist/node-defaults.js.map +1 -0
  365. package/dist/outline/flatten.d.ts +15 -0
  366. package/dist/outline/flatten.d.ts.map +1 -0
  367. package/dist/outline/flatten.js +189 -0
  368. package/dist/outline/flatten.js.map +1 -0
  369. package/dist/outline/heads.js +34 -0
  370. package/dist/outline/heads.js.map +1 -0
  371. package/dist/outline/hit.d.ts +21 -0
  372. package/dist/outline/hit.d.ts.map +1 -0
  373. package/dist/outline/hit.js +276 -0
  374. package/dist/outline/hit.js.map +1 -0
  375. package/dist/outline/index.d.ts +5 -0
  376. package/dist/outline/index.js +5 -0
  377. package/dist/outline/point.d.ts +16 -0
  378. package/dist/outline/point.d.ts.map +1 -0
  379. package/dist/outline/point.js +42 -0
  380. package/dist/outline/point.js.map +1 -0
  381. package/dist/outline/shapes.d.ts +35 -0
  382. package/dist/outline/shapes.d.ts.map +1 -0
  383. package/dist/outline/shapes.js +181 -0
  384. package/dist/outline/shapes.js.map +1 -0
  385. package/dist/paints/index.d.ts +2 -0
  386. package/dist/paints/index.js +2 -0
  387. package/dist/paints/schema.d.ts +77 -0
  388. package/dist/paints/schema.d.ts.map +1 -0
  389. package/dist/paints/schema.js +56 -0
  390. package/dist/paints/schema.js.map +1 -0
  391. package/dist/parse-path.d.ts +9 -1
  392. package/dist/parse-path.d.ts.map +1 -1
  393. package/dist/parse-path.js +39 -2
  394. package/dist/parse-path.js.map +1 -1
  395. package/dist/plugin-data/field.d.ts +47 -0
  396. package/dist/plugin-data/field.d.ts.map +1 -0
  397. package/dist/plugin-data/field.js +73 -0
  398. package/dist/plugin-data/field.js.map +1 -0
  399. package/dist/plugin-data/fields.d.ts +143 -0
  400. package/dist/plugin-data/fields.d.ts.map +1 -0
  401. package/dist/plugin-data/fields.js +168 -0
  402. package/dist/plugin-data/fields.js.map +1 -0
  403. package/dist/plugin-data/index.d.ts +3 -0
  404. package/dist/plugin-data/index.js +3 -0
  405. package/dist/polygon.d.ts +4 -2
  406. package/dist/polygon.d.ts.map +1 -1
  407. package/dist/polygon.js +17 -2
  408. package/dist/polygon.js.map +1 -1
  409. package/dist/preview.d.ts +12 -2
  410. package/dist/preview.d.ts.map +1 -0
  411. package/dist/preview.js +62 -1
  412. package/dist/preview.js.map +1 -0
  413. package/dist/{primitives2.d.ts → primitives/index.d.ts} +4 -3
  414. package/dist/primitives/index.d.ts.map +1 -0
  415. package/dist/primitives/index.js +2 -0
  416. package/dist/primitives/schema.d.ts +18 -0
  417. package/dist/primitives/schema.d.ts.map +1 -0
  418. package/dist/primitives/schema.js +19 -0
  419. package/dist/primitives/schema.js.map +1 -0
  420. package/dist/random.js +24 -1
  421. package/dist/random.js.map +1 -0
  422. package/dist/resize.d.ts +6 -4
  423. package/dist/resize.d.ts.map +1 -1
  424. package/dist/resize.js +287 -2
  425. package/dist/resize.js.map +1 -0
  426. package/dist/scaling/index.d.ts +3 -0
  427. package/dist/scaling/index.js +3 -0
  428. package/dist/scaling/node.d.ts +6 -0
  429. package/dist/scaling/node.d.ts.map +1 -0
  430. package/dist/scaling/node.js +148 -0
  431. package/dist/scaling/node.js.map +1 -0
  432. package/dist/scaling/tree.d.ts +7 -0
  433. package/dist/scaling/tree.d.ts.map +1 -0
  434. package/dist/scaling/tree.js +47 -0
  435. package/dist/scaling/tree.js.map +1 -0
  436. package/dist/shaders/index.d.ts +4 -0
  437. package/dist/shaders/index.js +4 -0
  438. package/dist/shaders/model.d.ts +41 -0
  439. package/dist/shaders/model.d.ts.map +1 -0
  440. package/dist/shaders/model.js +71 -0
  441. package/dist/shaders/model.js.map +1 -0
  442. package/dist/shaders/schema.d.ts +41 -0
  443. package/dist/shaders/schema.d.ts.map +1 -0
  444. package/dist/shaders/schema.js +36 -0
  445. package/dist/shaders/schema.js.map +1 -0
  446. package/dist/shaders/still.d.ts +18 -0
  447. package/dist/shaders/still.d.ts.map +1 -0
  448. package/dist/shaders/still.js +36 -0
  449. package/dist/shaders/still.js.map +1 -0
  450. package/dist/shape-with-text/fit.d.ts +28 -0
  451. package/dist/shape-with-text/fit.d.ts.map +1 -0
  452. package/dist/shape-with-text/fit.js +271 -0
  453. package/dist/shape-with-text/fit.js.map +1 -0
  454. package/dist/shape-with-text/geometry.d.ts +20 -0
  455. package/dist/shape-with-text/geometry.d.ts.map +1 -0
  456. package/dist/shape-with-text/geometry.js +539 -0
  457. package/dist/shape-with-text/geometry.js.map +1 -0
  458. package/dist/shape-with-text/index.d.ts +4 -0
  459. package/dist/shape-with-text/index.js +4 -0
  460. package/dist/shape-with-text/kinds.d.ts +20 -0
  461. package/dist/shape-with-text/kinds.d.ts.map +1 -0
  462. package/dist/shape-with-text/kinds.js +86 -0
  463. package/dist/shape-with-text/kinds.js.map +1 -0
  464. package/dist/shared-styles.d.ts +51 -0
  465. package/dist/shared-styles.d.ts.map +1 -0
  466. package/dist/shared-styles.js +186 -0
  467. package/dist/shared-styles.js.map +1 -0
  468. package/dist/slots/authoring.d.ts +27 -0
  469. package/dist/slots/authoring.d.ts.map +1 -0
  470. package/dist/slots/authoring.js +77 -0
  471. package/dist/slots/authoring.js.map +1 -0
  472. package/dist/slots/content.d.ts +41 -0
  473. package/dist/slots/content.d.ts.map +1 -0
  474. package/dist/slots/content.js +105 -0
  475. package/dist/slots/content.js.map +1 -0
  476. package/dist/slots/frames.d.ts +40 -0
  477. package/dist/slots/frames.d.ts.map +1 -0
  478. package/dist/slots/frames.js +118 -0
  479. package/dist/slots/frames.js.map +1 -0
  480. package/dist/slots/index.d.ts +5 -0
  481. package/dist/slots/index.js +5 -0
  482. package/dist/slots/limits.d.ts +14 -0
  483. package/dist/slots/limits.d.ts.map +1 -0
  484. package/dist/slots/limits.js +28 -0
  485. package/dist/slots/limits.js.map +1 -0
  486. package/dist/snap.d.ts +21 -2
  487. package/dist/snap.d.ts.map +1 -0
  488. package/dist/snap.js +109 -1
  489. package/dist/snap.js.map +1 -0
  490. package/dist/source-metadata.js +10 -1
  491. package/dist/source-metadata.js.map +1 -0
  492. package/dist/statuses/impact.d.ts +18 -0
  493. package/dist/statuses/impact.d.ts.map +1 -0
  494. package/dist/statuses/impact.js +33 -0
  495. package/dist/statuses/impact.js.map +1 -0
  496. package/dist/statuses/index.d.ts +5 -0
  497. package/dist/statuses/index.js +5 -0
  498. package/dist/statuses/node.d.ts +22 -0
  499. package/dist/statuses/node.d.ts.map +1 -0
  500. package/dist/statuses/node.js +47 -0
  501. package/dist/statuses/node.js.map +1 -0
  502. package/dist/statuses/schema.d.ts +59 -0
  503. package/dist/statuses/schema.d.ts.map +1 -0
  504. package/dist/statuses/schema.js +27 -0
  505. package/dist/statuses/schema.js.map +1 -0
  506. package/dist/statuses/workflow.d.ts +120 -0
  507. package/dist/statuses/workflow.d.ts.map +1 -0
  508. package/dist/statuses/workflow.js +135 -0
  509. package/dist/statuses/workflow.js.map +1 -0
  510. package/dist/{text-direction.d.ts → text/direction.d.ts} +2 -2
  511. package/dist/text/direction.d.ts.map +1 -0
  512. package/dist/{text-direction.js → text/direction.js} +1 -1
  513. package/dist/text/direction.js.map +1 -0
  514. package/dist/text/index.d.ts +7 -0
  515. package/dist/text/index.js +7 -0
  516. package/dist/text/lengths.d.ts +24 -0
  517. package/dist/text/lengths.d.ts.map +1 -0
  518. package/dist/text/lengths.js +49 -0
  519. package/dist/text/lengths.js.map +1 -0
  520. package/dist/text/lists.d.ts +44 -0
  521. package/dist/text/lists.d.ts.map +1 -0
  522. package/dist/text/lists.js +100 -0
  523. package/dist/text/lists.js.map +1 -0
  524. package/dist/text/overflow.d.ts +11 -0
  525. package/dist/text/overflow.d.ts.map +1 -0
  526. package/dist/text/overflow.js +13 -0
  527. package/dist/text/overflow.js.map +1 -0
  528. package/dist/text/paragraphs.d.ts +62 -0
  529. package/dist/text/paragraphs.d.ts.map +1 -0
  530. package/dist/text/paragraphs.js +166 -0
  531. package/dist/text/paragraphs.js.map +1 -0
  532. package/dist/{text-picture.d.ts → text/picture.d.ts} +3 -4
  533. package/dist/text/picture.d.ts.map +1 -0
  534. package/dist/text/picture.js +38 -0
  535. package/dist/text/picture.js.map +1 -0
  536. package/dist/text/references.d.ts +21 -0
  537. package/dist/text/references.d.ts.map +1 -0
  538. package/dist/text/references.js +43 -0
  539. package/dist/text/references.js.map +1 -0
  540. package/dist/text/schema.d.ts +10 -0
  541. package/dist/text/schema.d.ts.map +1 -0
  542. package/dist/text/schema.js +11 -0
  543. package/dist/text/schema.js.map +1 -0
  544. package/dist/transfer/apply.d.ts +9 -0
  545. package/dist/transfer/apply.d.ts.map +1 -0
  546. package/dist/transfer/apply.js +65 -0
  547. package/dist/transfer/apply.js.map +1 -0
  548. package/dist/transfer/copied.d.ts +14 -0
  549. package/dist/transfer/copied.d.ts.map +1 -0
  550. package/dist/transfer/copied.js +52 -0
  551. package/dist/transfer/copied.js.map +1 -0
  552. package/dist/transfer/history.d.ts +8 -0
  553. package/dist/transfer/history.d.ts.map +1 -0
  554. package/dist/transfer/history.js +32 -0
  555. package/dist/transfer/history.js.map +1 -0
  556. package/dist/transfer/identity.js +12 -0
  557. package/dist/transfer/identity.js.map +1 -0
  558. package/dist/transfer/index.d.ts +8 -0
  559. package/dist/transfer/index.js +8 -0
  560. package/dist/transfer/nodes.d.ts +14 -0
  561. package/dist/transfer/nodes.d.ts.map +1 -0
  562. package/dist/transfer/nodes.js +78 -0
  563. package/dist/transfer/nodes.js.map +1 -0
  564. package/dist/transfer/plan.d.ts +29 -0
  565. package/dist/transfer/plan.d.ts.map +1 -0
  566. package/dist/transfer/plan.js +106 -0
  567. package/dist/transfer/plan.js.map +1 -0
  568. package/dist/transfer/references.js +10 -0
  569. package/dist/transfer/references.js.map +1 -0
  570. package/dist/transfer/remove.d.ts +8 -0
  571. package/dist/transfer/remove.d.ts.map +1 -0
  572. package/dist/transfer/remove.js +34 -0
  573. package/dist/transfer/remove.js.map +1 -0
  574. package/dist/transfer/validation.js +39 -0
  575. package/dist/transfer/validation.js.map +1 -0
  576. package/dist/transfer/variables.d.ts +15 -0
  577. package/dist/transfer/variables.d.ts.map +1 -0
  578. package/dist/transfer/variables.js +52 -0
  579. package/dist/transfer/variables.js.map +1 -0
  580. package/dist/types.d.ts +195 -2007
  581. package/dist/types.d.ts.map +1 -1
  582. package/dist/types.js +89 -2
  583. package/dist/types.js.map +1 -0
  584. package/dist/undo.d.ts +93 -2
  585. package/dist/undo.d.ts.map +1 -0
  586. package/dist/undo.js +235 -1
  587. package/dist/undo.js.map +1 -0
  588. package/dist/variables/bindings.d.ts +83 -0
  589. package/dist/variables/bindings.d.ts.map +1 -0
  590. package/dist/variables/bindings.js +314 -0
  591. package/dist/variables/bindings.js.map +1 -0
  592. package/dist/variables/corners.d.ts +12 -0
  593. package/dist/variables/corners.d.ts.map +1 -0
  594. package/dist/variables/corners.js +38 -0
  595. package/dist/variables/corners.js.map +1 -0
  596. package/dist/variables/fields.d.ts +43 -0
  597. package/dist/variables/fields.d.ts.map +1 -0
  598. package/dist/variables/fields.js +104 -0
  599. package/dist/variables/fields.js.map +1 -0
  600. package/dist/variables/formula/check.d.ts +14 -0
  601. package/dist/variables/formula/check.d.ts.map +1 -0
  602. package/dist/variables/formula/check.js +73 -0
  603. package/dist/variables/formula/check.js.map +1 -0
  604. package/dist/variables/formula/evaluate.d.ts +7 -0
  605. package/dist/variables/formula/evaluate.d.ts.map +1 -0
  606. package/dist/variables/formula/evaluate.js +30 -0
  607. package/dist/variables/formula/evaluate.js.map +1 -0
  608. package/dist/variables/formula/index.d.ts +21 -0
  609. package/dist/variables/formula/index.d.ts.map +1 -0
  610. package/dist/variables/formula/index.js +77 -0
  611. package/dist/variables/formula/index.js.map +1 -0
  612. package/dist/variables/formula/parse.js +141 -0
  613. package/dist/variables/formula/parse.js.map +1 -0
  614. package/dist/variables/formula/print.d.ts +25 -0
  615. package/dist/variables/formula/print.d.ts.map +1 -0
  616. package/dist/variables/formula/print.js +105 -0
  617. package/dist/variables/formula/print.js.map +1 -0
  618. package/dist/variables/formula/schema.d.ts +7 -0
  619. package/dist/variables/formula/schema.d.ts.map +1 -0
  620. package/dist/variables/formula/schema.js +62 -0
  621. package/dist/variables/formula/schema.js.map +1 -0
  622. package/dist/variables/formula/signatures.d.ts +9 -0
  623. package/dist/variables/formula/signatures.d.ts.map +1 -0
  624. package/dist/variables/formula/signatures.js +238 -0
  625. package/dist/variables/formula/signatures.js.map +1 -0
  626. package/dist/variables/formula/tokens.d.ts +26 -0
  627. package/dist/variables/formula/tokens.d.ts.map +1 -0
  628. package/dist/variables/formula/tokens.js +82 -0
  629. package/dist/variables/formula/tokens.js.map +1 -0
  630. package/dist/variables/formula/tree.d.ts +22 -0
  631. package/dist/variables/formula/tree.d.ts.map +1 -0
  632. package/dist/variables/formula/tree.js +35 -0
  633. package/dist/variables/formula/tree.js.map +1 -0
  634. package/dist/variables/index.d.ts +41 -0
  635. package/dist/variables/index.d.ts.map +1 -0
  636. package/dist/variables/index.js +238 -0
  637. package/dist/variables/index.js.map +1 -0
  638. package/dist/variables/resolution.d.ts +39 -0
  639. package/dist/variables/resolution.d.ts.map +1 -0
  640. package/dist/variables/resolution.js +154 -0
  641. package/dist/variables/resolution.js.map +1 -0
  642. package/dist/variables/schema.d.ts +40 -0
  643. package/dist/variables/schema.d.ts.map +1 -0
  644. package/dist/variables/schema.js +32 -0
  645. package/dist/variables/schema.js.map +1 -0
  646. package/dist/variables/text.d.ts +16 -0
  647. package/dist/variables/text.d.ts.map +1 -0
  648. package/dist/variables/text.js +49 -0
  649. package/dist/variables/text.js.map +1 -0
  650. package/dist/variables/token.d.ts +18 -0
  651. package/dist/variables/token.d.ts.map +1 -0
  652. package/dist/variables/token.js +39 -0
  653. package/dist/variables/token.js.map +1 -0
  654. package/dist/variables/units.js +19 -0
  655. package/dist/variables/units.js.map +1 -0
  656. package/dist/variables/value.d.ts +12 -0
  657. package/dist/variables/value.d.ts.map +1 -0
  658. package/dist/variables/value.js +70 -0
  659. package/dist/variables/value.js.map +1 -0
  660. package/dist/vector-network.d.ts +65 -2
  661. package/dist/vector-network.d.ts.map +1 -0
  662. package/dist/vector-network.js +375 -2
  663. package/dist/vector-network.js.map +1 -0
  664. package/package.json +303 -137
  665. package/src/arrow-caps.ts +279 -62
  666. package/src/behaviours/index.ts +5 -0
  667. package/src/behaviours/kinds.ts +51 -34
  668. package/src/behaviours/layers.ts +5 -3
  669. package/src/behaviours/model.ts +25 -22
  670. package/src/behaviours/schema.ts +64 -13
  671. package/src/behaviours/spec.ts +11 -50
  672. package/src/bindings.ts +11 -2
  673. package/src/checkpoint.ts +252 -5
  674. package/src/clipping.ts +112 -0
  675. package/src/color/index.ts +1 -0
  676. package/src/color/schema.ts +10 -0
  677. package/src/comments/document.ts +1 -1
  678. package/src/comments/index.ts +5 -0
  679. package/src/comments/schema.ts +51 -0
  680. package/src/comments/threads.ts +1 -1
  681. package/src/components/exposure.ts +1 -1
  682. package/src/components/index.ts +8 -0
  683. package/src/components/properties.ts +94 -4
  684. package/src/components/variants.ts +52 -31
  685. package/src/connectors/controls.ts +229 -0
  686. package/src/connectors/create.ts +48 -0
  687. package/src/connectors/elbow.ts +235 -0
  688. package/src/connectors/gaps.ts +72 -0
  689. package/src/connectors/hit.ts +49 -0
  690. package/src/connectors/index.ts +28 -0
  691. package/src/connectors/label.ts +238 -0
  692. package/src/connectors/layout.ts +280 -0
  693. package/src/connectors/pieces.ts +141 -0
  694. package/src/connectors/route.ts +148 -0
  695. package/src/connectors/sides.ts +94 -0
  696. package/src/connectors/sublayers.ts +203 -0
  697. package/src/coordinate.ts +10 -3
  698. package/src/copy.ts +71 -31
  699. package/src/css/blend.ts +27 -0
  700. package/src/css/index.ts +2 -0
  701. package/src/css/text.ts +84 -0
  702. package/src/cubic.ts +14 -0
  703. package/src/export-format.ts +30 -1
  704. package/src/fields/appearance.ts +35 -0
  705. package/src/fields/index.ts +4 -0
  706. package/src/fields/layout.ts +48 -0
  707. package/src/fields/text.ts +32 -1
  708. package/src/fig-compression.ts +9 -0
  709. package/src/figjam/index.ts +2 -0
  710. package/src/figjam/palette.ts +473 -0
  711. package/src/figjam/text.ts +83 -0
  712. package/src/font-style.ts +58 -14
  713. package/src/generated/index.ts +76 -0
  714. package/src/generated/kind.ts +24 -0
  715. package/src/generated/shape-with-text.ts +157 -0
  716. package/src/generated/sticky.ts +213 -0
  717. package/src/geometry.ts +102 -312
  718. package/src/gradient.ts +14 -0
  719. package/src/graph.ts +849 -0
  720. package/src/group-bounds.ts +59 -12
  721. package/src/guides.ts +6 -1
  722. package/src/hit-test.ts +118 -74
  723. package/src/icons/index.ts +3 -0
  724. package/src/icons/model.ts +9 -0
  725. package/src/icons/schema.ts +19 -3
  726. package/src/ids.ts +34 -0
  727. package/src/images.ts +71 -8
  728. package/src/index.ts +2 -976
  729. package/src/instances/assignments.ts +116 -0
  730. package/src/instances/content-size.ts +23 -2
  731. package/src/instances/copies.ts +7 -10
  732. package/src/instances/cycles.ts +1 -1
  733. package/src/instances/fields.ts +47 -92
  734. package/src/{instances.ts → instances/index.ts} +69 -44
  735. package/src/instances/kept-overrides.ts +280 -0
  736. package/src/instances/main-component.ts +55 -1
  737. package/src/{instance-overrides.ts → instances/overrides.ts} +58 -2
  738. package/src/instances/placement.ts +1 -1
  739. package/src/instances/source-walk.ts +3 -9
  740. package/src/instances/swap.ts +451 -0
  741. package/src/instances/sync.ts +166 -177
  742. package/src/instances/vector-geometry.ts +3 -3
  743. package/src/layout/aspect-ratio.ts +1 -1
  744. package/src/layout/sizing.ts +1 -1
  745. package/src/layout/writes.ts +59 -0
  746. package/src/matrix.ts +1 -1
  747. package/src/mutation-impact.ts +1 -1
  748. package/src/node-defaults.ts +43 -3
  749. package/src/outline/flatten.ts +190 -0
  750. package/src/outline/heads.ts +52 -0
  751. package/src/outline/hit.ts +369 -0
  752. package/src/outline/index.ts +4 -0
  753. package/src/outline/point.ts +59 -0
  754. package/src/outline/shapes.ts +207 -0
  755. package/src/paints/index.ts +1 -0
  756. package/src/paints/schema.ts +67 -0
  757. package/src/parse-path.ts +49 -4
  758. package/src/plugin-data/fields.ts +69 -77
  759. package/src/plugin-data/index.ts +2 -0
  760. package/src/polygon.ts +17 -0
  761. package/src/preview.ts +1 -1
  762. package/src/{primitives.ts → primitives/index.ts} +2 -0
  763. package/src/primitives/schema.ts +14 -0
  764. package/src/resize.ts +32 -6
  765. package/src/scaling/node.ts +10 -6
  766. package/src/scaling/tree.ts +2 -1
  767. package/src/shaders/index.ts +3 -0
  768. package/src/shaders/schema.ts +3 -3
  769. package/src/shape-with-text/fit.ts +154 -0
  770. package/src/shape-with-text/geometry.ts +496 -0
  771. package/src/shape-with-text/index.ts +10 -0
  772. package/src/shape-with-text/kinds.ts +86 -0
  773. package/src/shared-styles.ts +169 -17
  774. package/src/slots/authoring.ts +1 -1
  775. package/src/slots/content.ts +10 -5
  776. package/src/slots/frames.ts +12 -10
  777. package/src/slots/index.ts +4 -0
  778. package/src/slots/limits.ts +1 -1
  779. package/src/snap.ts +3 -1
  780. package/src/statuses/impact.ts +38 -0
  781. package/src/statuses/index.ts +4 -0
  782. package/src/statuses/node.ts +63 -0
  783. package/src/statuses/schema.ts +39 -0
  784. package/src/statuses/workflow.ts +121 -0
  785. package/src/text/index.ts +3 -0
  786. package/src/text/lengths.ts +44 -0
  787. package/src/text/overflow.ts +12 -0
  788. package/src/text/picture.ts +0 -4
  789. package/src/text/schema.ts +7 -0
  790. package/src/transfer/apply.ts +1 -1
  791. package/src/transfer/copied.ts +72 -0
  792. package/src/transfer/history.ts +1 -1
  793. package/src/transfer/index.ts +1 -0
  794. package/src/transfer/nodes.ts +18 -19
  795. package/src/transfer/plan.ts +1 -1
  796. package/src/transfer/remove.ts +1 -1
  797. package/src/transfer/validation.ts +1 -1
  798. package/src/transfer/variables.ts +7 -6
  799. package/src/types.ts +246 -13
  800. package/src/undo.ts +64 -2
  801. package/src/variables/bindings.ts +166 -66
  802. package/src/variables/corners.ts +39 -0
  803. package/src/variables/fields.ts +83 -0
  804. package/src/variables/formula/check.ts +99 -0
  805. package/src/variables/formula/evaluate.ts +33 -0
  806. package/src/variables/formula/index.ts +129 -0
  807. package/src/variables/formula/parse.ts +160 -0
  808. package/src/variables/formula/print.ts +167 -0
  809. package/src/variables/formula/schema.ts +77 -0
  810. package/src/variables/formula/signatures.ts +266 -0
  811. package/src/variables/formula/tokens.ts +114 -0
  812. package/src/variables/formula/tree.ts +53 -0
  813. package/src/{variables.ts → variables/index.ts} +86 -146
  814. package/src/variables/resolution.ts +293 -0
  815. package/src/variables/schema.ts +31 -0
  816. package/src/variables/text.ts +51 -0
  817. package/src/variables/token.ts +27 -1
  818. package/src/variables/value.ts +92 -0
  819. package/src/vector-network.ts +263 -22
  820. package/dist/chunks/asset-keys.js.map +0 -1
  821. package/dist/chunks/behaviours/kinds.js.map +0 -1
  822. package/dist/chunks/behaviours/layers.js +0 -611
  823. package/dist/chunks/behaviours/layers.js.map +0 -1
  824. package/dist/chunks/behaviours/spec.js.map +0 -1
  825. package/dist/chunks/bindings.js +0 -18
  826. package/dist/chunks/bindings.js.map +0 -1
  827. package/dist/chunks/buffered-events.js.map +0 -1
  828. package/dist/chunks/checkpoint.js +0 -78
  829. package/dist/chunks/checkpoint.js.map +0 -1
  830. package/dist/chunks/color/contrast.js.map +0 -1
  831. package/dist/chunks/color/index.js +0 -1662
  832. package/dist/chunks/color/index.js.map +0 -1
  833. package/dist/chunks/comments/document.js.map +0 -1
  834. package/dist/chunks/comments/list.js.map +0 -1
  835. package/dist/chunks/comments/merge.js.map +0 -1
  836. package/dist/chunks/components/exposure.js +0 -2291
  837. package/dist/chunks/components/exposure.js.map +0 -1
  838. package/dist/chunks/components/variants.js +0 -32
  839. package/dist/chunks/components/variants.js.map +0 -1
  840. package/dist/chunks/coordinate.js +0 -385
  841. package/dist/chunks/coordinate.js.map +0 -1
  842. package/dist/chunks/css/grid.js.map +0 -1
  843. package/dist/chunks/css/index.js +0 -160
  844. package/dist/chunks/css/index.js.map +0 -1
  845. package/dist/chunks/events.js.map +0 -1
  846. package/dist/chunks/fields/geometry.js.map +0 -1
  847. package/dist/chunks/font-style.js +0 -96
  848. package/dist/chunks/font-style.js.map +0 -1
  849. package/dist/chunks/group-bounds.js.map +0 -1
  850. package/dist/chunks/icons/glyph.js.map +0 -1
  851. package/dist/chunks/index.js +0 -2430
  852. package/dist/chunks/index.js.map +0 -1
  853. package/dist/color.d.ts +0 -78
  854. package/dist/color.d.ts.map +0 -1
  855. package/dist/color.js +0 -3
  856. package/dist/constants2.d.ts +0 -11
  857. package/dist/constants2.d.ts.map +0 -1
  858. package/dist/css.d.ts +0 -39
  859. package/dist/css.d.ts.map +0 -1
  860. package/dist/css.js +0 -3
  861. package/dist/images2.d.ts +0 -16
  862. package/dist/images2.d.ts.map +0 -1
  863. package/dist/instances.d.ts +0 -2
  864. package/dist/instances.js +0 -2
  865. package/dist/layout.d.ts +0 -2
  866. package/dist/matrix2.d.ts +0 -16
  867. package/dist/matrix2.d.ts.map +0 -1
  868. package/dist/primitives.d.ts +0 -2
  869. package/dist/primitives.js +0 -0
  870. package/dist/primitives2.d.ts.map +0 -1
  871. package/dist/text-direction.d.ts.map +0 -1
  872. package/dist/text-direction.js.map +0 -1
  873. package/dist/text-picture.d.ts.map +0 -1
  874. package/dist/text-picture.js +0 -2
  875. package/dist/text.d.ts +0 -2
  876. package/dist/text.js +0 -3
  877. package/dist/types2.d.ts +0 -2
  878. package/dist/undo2.d.ts +0 -73
  879. package/dist/undo2.d.ts.map +0 -1
  880. package/dist/variables.d.ts +0 -2
  881. package/dist/variables.js +0 -2
  882. /package/dist/{chunks/asset-keys.js → asset-keys.js} +0 -0
  883. /package/dist/{chunks/buffered-events.js → buffered-events.js} +0 -0
  884. /package/dist/{chunks/events.js → events.js} +0 -0
  885. /package/dist/{chunks/fields → fields}/geometry.js +0 -0
@@ -1,1662 +0,0 @@
1
- import { arrowCapOverflow } from "../../arrow-caps.js";
2
- import { BLACK, DEFAULT_FONT_FAMILY } from "./contrast.js";
3
- import { OPEN_PENCIL_PLUGIN_DATA, readAllPluginData, withAllPluginData } from "../behaviours/layers.js";
4
- import { isEqual } from "es-toolkit/predicate";
5
- import { converter, differenceEuclidean, formatCss, formatHex, formatHex8, formatRgb, inGamut, parse, toGamut } from "culori";
6
- //#region src/geometry.ts
7
- function degToRad(degrees) {
8
- return degrees * Math.PI / 180;
9
- }
10
- function radToDeg(radians) {
11
- return radians * 180 / Math.PI;
12
- }
13
- function rotatePoint(px, py, cx, cy, rad) {
14
- const cos = Math.cos(rad);
15
- const sin = Math.sin(rad);
16
- return {
17
- x: cx + (px - cx) * cos - (py - cy) * sin,
18
- y: cy + (px - cx) * sin + (py - cy) * cos
19
- };
20
- }
21
- function rotatedCorners(cx, cy, hw, hh, rotationDeg) {
22
- const rad = degToRad(rotationDeg);
23
- const cos = Math.cos(rad);
24
- const sin = Math.sin(rad);
25
- return [
26
- {
27
- x: cx + -hw * cos - -hh * sin,
28
- y: cy + -hw * sin + -hh * cos
29
- },
30
- {
31
- x: cx + hw * cos - -hh * sin,
32
- y: cy + hw * sin + -hh * cos
33
- },
34
- {
35
- x: cx + hw * cos - hh * sin,
36
- y: cy + hw * sin + hh * cos
37
- },
38
- {
39
- x: cx + -hw * cos - hh * sin,
40
- y: cy + -hw * sin + hh * cos
41
- }
42
- ];
43
- }
44
- function rotatedBBox(x, y, w, h, rotationDeg) {
45
- if (rotationDeg === 0) return {
46
- left: x,
47
- right: x + w,
48
- top: y,
49
- bottom: y + h,
50
- centerX: x + w / 2,
51
- centerY: y + h / 2
52
- };
53
- const corners = rotatedCorners(x + w / 2, y + h / 2, w / 2, h / 2, rotationDeg);
54
- let left = Infinity, right = -Infinity, top = Infinity, bottom = -Infinity;
55
- for (const c of corners) {
56
- left = Math.min(left, c.x);
57
- right = Math.max(right, c.x);
58
- top = Math.min(top, c.y);
59
- bottom = Math.max(bottom, c.y);
60
- }
61
- return {
62
- left,
63
- right,
64
- top,
65
- bottom,
66
- centerX: (left + right) / 2,
67
- centerY: (top + bottom) / 2
68
- };
69
- }
70
- function createBoundsAccumulator() {
71
- return {
72
- minX: Infinity,
73
- minY: Infinity,
74
- maxX: -Infinity,
75
- maxY: -Infinity
76
- };
77
- }
78
- function includePoint(bounds, x, y) {
79
- bounds.minX = Math.min(bounds.minX, x);
80
- bounds.minY = Math.min(bounds.minY, y);
81
- bounds.maxX = Math.max(bounds.maxX, x);
82
- bounds.maxY = Math.max(bounds.maxY, y);
83
- }
84
- function includeRect(bounds, rect) {
85
- includePoint(bounds, rect.x, rect.y);
86
- includePoint(bounds, rect.x + rect.width, rect.y + rect.height);
87
- }
88
- function boundsToRect(bounds) {
89
- return bounds.minX === Infinity ? {
90
- x: 0,
91
- y: 0,
92
- width: 0,
93
- height: 0
94
- } : {
95
- x: bounds.minX,
96
- y: bounds.minY,
97
- width: bounds.maxX - bounds.minX,
98
- height: bounds.maxY - bounds.minY
99
- };
100
- }
101
- function computeBounds(items) {
102
- const bounds = createBoundsAccumulator();
103
- for (const item of items) includeRect(bounds, item);
104
- return boundsToRect(bounds);
105
- }
106
- function polygonVertices(node) {
107
- const cx = node.width / 2;
108
- const cy = node.height / 2;
109
- const rx = node.width / 2;
110
- const ry = node.height / 2;
111
- const pointCount = Math.max(3, node.pointCount);
112
- const isStar = node.type === "STAR";
113
- const innerRatio = isStar ? node.starInnerRadius : 1;
114
- const totalPoints = isStar ? pointCount * 2 : pointCount;
115
- const angleOffset = -Math.PI / 2;
116
- return Array.from({ length: totalPoints }, (_, index) => {
117
- const angle = angleOffset + 2 * Math.PI * index / totalPoints;
118
- const radius = isStar && index % 2 === 1 ? innerRatio : 1;
119
- return {
120
- x: cx + rx * radius * Math.cos(angle),
121
- y: cy + ry * radius * Math.sin(angle)
122
- };
123
- });
124
- }
125
- function strokeOverflow(strokes, fallbackCap, network, corners) {
126
- let overflow = 0;
127
- for (const stroke of strokes ?? []) {
128
- if (!stroke.visible) continue;
129
- let extra = 0;
130
- if (stroke.align === "OUTSIDE") extra = stroke.weight;
131
- else if (stroke.align === "CENTER") extra = stroke.weight / 2;
132
- const miter = network ? miterRatio(network, stroke.join ?? corners?.strokeJoin, corners?.strokeMiterLimit) : 1;
133
- overflow = Math.max(overflow, extra * miter);
134
- }
135
- return Math.max(overflow, arrowCapOverflow(strokes, fallbackCap, network));
136
- }
137
- /** The direction a segment leaves `vertex` in, along its handle when it has one. */
138
- function leaving(network, index, vertex) {
139
- const segment = network.segments[index];
140
- const atStart = segment.start === vertex;
141
- const handle = atStart ? segment.tangentStart : segment.tangentEnd;
142
- if (handle.x !== 0 || handle.y !== 0) return handle;
143
- const from = network.vertices[vertex];
144
- const to = network.vertices[atStart ? segment.end : segment.start];
145
- return {
146
- x: to.x - from.x,
147
- y: to.y - from.y
148
- };
149
- }
150
- /**
151
- * How far past half the stroke the sharpest mitered corner reaches, as a multiple: a corner of
152
- * angle θ mitres out to 1/sin(θ/2), unless that passes the miter limit and it bevels instead.
153
- * Corners are the vertices exactly two segments meet at, as the stroke joins them.
154
- */
155
- function miterRatio(network, join, limit = 4) {
156
- const meeting = /* @__PURE__ */ new Map();
157
- for (const [index, segment] of network.segments.entries()) for (const vertex of /* @__PURE__ */ new Set([segment.start, segment.end])) meeting.set(vertex, [...meeting.get(vertex) ?? [], index]);
158
- let ratio = 1;
159
- for (const [vertex, indices] of meeting) {
160
- if (indices.length !== 2) continue;
161
- if ((network.vertices[vertex].strokeJoin ?? join ?? "MITER") !== "MITER") continue;
162
- const a = leaving(network, indices[0], vertex);
163
- const b = leaving(network, indices[1], vertex);
164
- const lengths = Math.hypot(a.x, a.y) * Math.hypot(b.x, b.y);
165
- if (lengths === 0) continue;
166
- const angle = Math.acos(Math.max(-1, Math.min(1, (a.x * b.x + a.y * b.y) / lengths)));
167
- const miter = 1 / Math.sin(angle / 2);
168
- if (miter <= limit) ratio = Math.max(ratio, miter);
169
- }
170
- return ratio;
171
- }
172
- function effectOverflow(effects) {
173
- let left = 0;
174
- let right = 0;
175
- let top = 0;
176
- let bottom = 0;
177
- for (const effect of effects ?? []) {
178
- if (!effect.visible) continue;
179
- if (effect.type !== "DROP_SHADOW" && effect.type !== "LAYER_BLUR" && effect.type !== "FOREGROUND_BLUR") continue;
180
- const blurSpread = effect.radius + effect.spread;
181
- left = Math.max(left, blurSpread + Math.max(0, -effect.offset.x));
182
- right = Math.max(right, blurSpread + Math.max(0, effect.offset.x));
183
- top = Math.max(top, blurSpread + Math.max(0, -effect.offset.y));
184
- bottom = Math.max(bottom, blurSpread + Math.max(0, effect.offset.y));
185
- }
186
- return {
187
- left,
188
- right,
189
- top,
190
- bottom
191
- };
192
- }
193
- function computeAbsoluteBounds(nodes, getAbsolutePosition) {
194
- const bounds = createBoundsAccumulator();
195
- for (const n of nodes) {
196
- const abs = getAbsolutePosition(n.id);
197
- includeRect(bounds, {
198
- x: abs.x,
199
- y: abs.y,
200
- width: n.width,
201
- height: n.height
202
- });
203
- }
204
- return boundsToRect(bounds);
205
- }
206
- function computeVisualBounds(nodes, getAbsolutePosition) {
207
- const bounds = createBoundsAccumulator();
208
- for (const n of nodes) {
209
- const abs = getAbsolutePosition(n.id);
210
- const bbox = rotatedBBox(abs.x, abs.y, n.width, n.height, n.rotation ?? 0);
211
- const stroke = strokeOverflow(n.strokes, n.strokeCap, n.vectorNetwork, n);
212
- const effects = effectOverflow(n.effects);
213
- includePoint(bounds, bbox.left - stroke - effects.left, bbox.top - stroke - effects.top);
214
- includePoint(bounds, bbox.right + stroke + effects.right, bbox.bottom + stroke + effects.bottom);
215
- }
216
- return boundsToRect(bounds);
217
- }
218
- function unionVisualBounds(a, b) {
219
- if (!a) return b;
220
- if (!b) return a;
221
- return {
222
- minX: Math.min(a.minX, b.minX),
223
- minY: Math.min(a.minY, b.minY),
224
- maxX: Math.max(a.maxX, b.maxX),
225
- maxY: Math.max(a.maxY, b.maxY)
226
- };
227
- }
228
- function intersectVisualBounds(a, b) {
229
- const minX = Math.max(a.minX, b.minX);
230
- const minY = Math.max(a.minY, b.minY);
231
- const maxX = Math.min(a.maxX, b.maxX);
232
- const maxY = Math.min(a.maxY, b.maxY);
233
- return minX < maxX && minY < maxY ? {
234
- minX,
235
- minY,
236
- maxX,
237
- maxY
238
- } : null;
239
- }
240
- /**
241
- * Coordinate pairs per path blob command: 0=close, 1=move, 2=line,
242
- * 3=quad (glyph-derived blobs are quad-heavy), 4=cubic. Unknown → null so
243
- * walkers stop instead of desyncing into coordinate bytes.
244
- */
245
- function geometryCommandCoordCount(command) {
246
- if (command === 0) return 0;
247
- if (command === 1 || command === 2) return 1;
248
- if (command === 3) return 2;
249
- if (command === 4) return 3;
250
- return null;
251
- }
252
- function geometryBlobBounds(paths) {
253
- const bounds = createBoundsAccumulator();
254
- for (const path of paths) {
255
- const blob = path.commandsBlob;
256
- const dv = new DataView(blob.buffer, blob.byteOffset, blob.byteLength);
257
- let offset = 0;
258
- while (offset < blob.length) {
259
- const command = blob[offset++];
260
- const coords = geometryCommandCoordCount(command);
261
- if (coords == null) break;
262
- for (let i = 0; i < coords; i++) {
263
- if (offset + 8 > blob.length) break;
264
- includePoint(bounds, dv.getFloat32(offset, true), dv.getFloat32(offset + 4, true));
265
- offset += 8;
266
- }
267
- }
268
- }
269
- return bounds.minX === Infinity ? null : boundsToRect(bounds);
270
- }
271
- function transformLocalPoint(node, point) {
272
- let x = node.flipX ? node.width - point.x : point.x;
273
- let y = node.flipY ? node.height - point.y : point.y;
274
- const rotation = node.rotation ?? 0;
275
- if (rotation !== 0) {
276
- const rotated = rotatePoint(x, y, node.width / 2, node.height / 2, degToRad(rotation));
277
- x = rotated.x;
278
- y = rotated.y;
279
- }
280
- return {
281
- x,
282
- y
283
- };
284
- }
285
- function transformedLocalBounds(node, local, abs) {
286
- const points = [
287
- {
288
- x: local.x,
289
- y: local.y
290
- },
291
- {
292
- x: local.x + local.width,
293
- y: local.y
294
- },
295
- {
296
- x: local.x + local.width,
297
- y: local.y + local.height
298
- },
299
- {
300
- x: local.x,
301
- y: local.y + local.height
302
- }
303
- ].map((point) => transformLocalPoint(node, point));
304
- return {
305
- minX: abs.x + Math.min(...points.map((point) => point.x)),
306
- minY: abs.y + Math.min(...points.map((point) => point.y)),
307
- maxX: abs.x + Math.max(...points.map((point) => point.x)),
308
- maxY: abs.y + Math.max(...points.map((point) => point.y))
309
- };
310
- }
311
- function nodeVisualBounds(node, getAbsolutePosition) {
312
- const abs = getAbsolutePosition(node.id);
313
- const base = computeVisualBounds([node], getAbsolutePosition);
314
- let bounds = {
315
- minX: base.x,
316
- minY: base.y,
317
- maxX: base.x + base.width,
318
- maxY: base.y + base.height
319
- };
320
- const hasNonInsideStroke = node.strokes?.some((stroke) => stroke.visible && stroke.align !== "INSIDE");
321
- const localGeometry = geometryBlobBounds([...node.fillGeometry ?? [], ...hasNonInsideStroke ? node.strokeGeometry ?? [] : []]);
322
- if (localGeometry) bounds = unionVisualBounds(bounds, transformedLocalBounds(node, localGeometry, abs)) ?? bounds;
323
- if (node.type === "TEXT" && node.textDecoration && node.textDecoration !== "NONE") {
324
- const fontSize = node.fontSize ?? 14;
325
- const underlineOffset = node.textUnderlineOffset ?? fontSize * .18;
326
- const thickness = node.textDecorationThickness ?? Math.max(1, fontSize / 16);
327
- bounds.maxY += underlineOffset + thickness + fontSize * .35;
328
- }
329
- return bounds;
330
- }
331
- function collectDescendantVisualBounds(nodeId, getNode, getAbsolutePosition, clip = null) {
332
- const node = getNode(nodeId);
333
- if (!node?.visible) return null;
334
- const own = nodeVisualBounds(node, getAbsolutePosition);
335
- let bounds = clip ? intersectVisualBounds(own, clip) : own;
336
- const isClippableContainer = node.type === "FRAME" || node.type === "COMPONENT" || node.type === "INSTANCE";
337
- let childClip = clip;
338
- if (isClippableContainer && node.clipsContent) {
339
- const abs = getAbsolutePosition(node.id);
340
- const nodeClip = {
341
- minX: abs.x,
342
- minY: abs.y,
343
- maxX: abs.x + node.width,
344
- maxY: abs.y + node.height
345
- };
346
- childClip = childClip ? intersectVisualBounds(childClip, nodeClip) : nodeClip;
347
- if (!childClip) return bounds;
348
- }
349
- for (const childId of node.childIds ?? []) bounds = unionVisualBounds(bounds, collectDescendantVisualBounds(childId, getNode, getAbsolutePosition, childClip));
350
- return bounds;
351
- }
352
- function computeDescendantVisualBounds(nodeIds, getNode, getAbsolutePosition) {
353
- let bounds = null;
354
- for (const nodeId of nodeIds) bounds = unionVisualBounds(bounds, collectDescendantVisualBounds(nodeId, getNode, getAbsolutePosition));
355
- return bounds;
356
- }
357
- function crossProduct(a, b, p) {
358
- return (b.x - a.x) * (p.y - a.y) - (b.y - a.y) * (p.x - a.x);
359
- }
360
- function lineSegmentIntersect(p1, p2, p3, p4) {
361
- const dx1 = p2.x - p1.x;
362
- const dy1 = p2.y - p1.y;
363
- const dx2 = p4.x - p3.x;
364
- const dy2 = p4.y - p3.y;
365
- const denom = dx1 * dy2 - dy1 * dx2;
366
- if (denom === 0) return p1;
367
- const t = ((p3.x - p1.x) * dy2 - (p3.y - p1.y) * dx2) / denom;
368
- return {
369
- x: p1.x + t * dx1,
370
- y: p1.y + t * dy1
371
- };
372
- }
373
- function clipHalfPlane(polygon, a, b, wantPositive) {
374
- const output = [];
375
- const isInside = (p) => {
376
- const cross = crossProduct(a, b, p);
377
- return wantPositive ? cross >= 0 : cross <= 0;
378
- };
379
- for (let i = 0; i < polygon.length; i++) {
380
- const curr = polygon[i];
381
- const prev = polygon[i === 0 ? polygon.length - 1 : i - 1];
382
- const currInside = isInside(curr);
383
- const prevInside = isInside(prev);
384
- if (currInside) {
385
- if (!prevInside) output.push(lineSegmentIntersect(prev, curr, a, b));
386
- output.push(curr);
387
- } else if (prevInside) output.push(lineSegmentIntersect(prev, curr, a, b));
388
- }
389
- return output;
390
- }
391
- /**
392
- * Clip a subject polygon against a convex polygon (e.g. the 4 canvas-space
393
- * corners of a rotated clipping ancestor).
394
- *
395
- * Uses Sutherland–Hodgman polygon clipping with centroid-based interior
396
- * detection, making it robust to either winding order of the clip polygon.
397
- * Returns the clipped polygon, or null if the subject is fully outside the
398
- * clip polygon. When `clipCorners` has fewer than 3 points the subject is
399
- * returned unchanged (no clipping).
400
- *
401
- * Preserving the polygon (rather than collapsing to an AABB) lets callers
402
- * chain multiple clips without reintroducing corners removed by an inner clip.
403
- */
404
- function clipPolygon(subject, clipCorners) {
405
- if (clipCorners.length < 3) return subject;
406
- let cx = 0;
407
- let cy = 0;
408
- for (const c of clipCorners) {
409
- cx += c.x;
410
- cy += c.y;
411
- }
412
- cx /= clipCorners.length;
413
- cy /= clipCorners.length;
414
- let polygon = subject;
415
- for (let i = 0; i < clipCorners.length; i++) {
416
- if (polygon.length === 0) return null;
417
- const a = clipCorners[i];
418
- const b = clipCorners[(i + 1) % clipCorners.length];
419
- const centroidCross = crossProduct(a, b, {
420
- x: cx,
421
- y: cy
422
- });
423
- polygon = clipHalfPlane(polygon, a, b, centroidCross >= 0);
424
- }
425
- return polygon.length === 0 ? null : polygon;
426
- }
427
- /**
428
- * Clip an axis-aligned VisualBounds rectangle against a convex polygon
429
- * (e.g. the 4 canvas-space corners of a rotated clipping ancestor).
430
- *
431
- * Returns the AABB of the intersection, or null if the bounds are fully
432
- * outside the clip polygon. Delegates to {@link clipPolygon}.
433
- *
434
- * For a non-rotated clip (axis-aligned corners) the result is identical
435
- * to `intersectVisualBounds`.
436
- */
437
- function clipBoundsToPolygon(bounds, clipCorners) {
438
- if (clipCorners.length < 3) return bounds;
439
- const polygon = clipPolygon([
440
- {
441
- x: bounds.minX,
442
- y: bounds.minY
443
- },
444
- {
445
- x: bounds.maxX,
446
- y: bounds.minY
447
- },
448
- {
449
- x: bounds.maxX,
450
- y: bounds.maxY
451
- },
452
- {
453
- x: bounds.minX,
454
- y: bounds.maxY
455
- }
456
- ], clipCorners);
457
- if (!polygon) return null;
458
- let minX = Infinity;
459
- let minY = Infinity;
460
- let maxX = -Infinity;
461
- let maxY = -Infinity;
462
- for (const p of polygon) {
463
- if (p.x < minX) minX = p.x;
464
- if (p.y < minY) minY = p.y;
465
- if (p.x > maxX) maxX = p.x;
466
- if (p.y > maxY) maxY = p.y;
467
- }
468
- return minX < maxX && minY < maxY ? {
469
- minX,
470
- minY,
471
- maxX,
472
- maxY
473
- } : null;
474
- }
475
- //#endregion
476
- //#region src/instance-overrides.ts
477
- function createInstanceOverrideState() {
478
- return {
479
- self: /* @__PURE__ */ new Map(),
480
- descendants: /* @__PURE__ */ new Map()
481
- };
482
- }
483
- function serializeOverrideValue(value) {
484
- return value === void 0 ? { defined: false } : {
485
- defined: true,
486
- value
487
- };
488
- }
489
- function deserializeOverrideValue(value) {
490
- if (!value || typeof value !== "object" || Array.isArray(value)) return {
491
- valid: false,
492
- value: void 0
493
- };
494
- if (!("defined" in value) || typeof value.defined !== "boolean") return {
495
- valid: false,
496
- value: void 0
497
- };
498
- if (value.defined) return "value" in value ? {
499
- valid: true,
500
- value: value["value"]
501
- } : {
502
- valid: false,
503
- value: void 0
504
- };
505
- return {
506
- valid: true,
507
- value: void 0
508
- };
509
- }
510
- function deserializeEntries(value) {
511
- const result = /* @__PURE__ */ new Map();
512
- if (!Array.isArray(value)) return result;
513
- for (const entry of value) {
514
- if (!Array.isArray(entry) || entry.length !== 2 || typeof entry[0] !== "string") continue;
515
- const decoded = deserializeOverrideValue(entry[1]);
516
- if (decoded.valid) result.set(entry[0], decoded.value);
517
- }
518
- return result;
519
- }
520
- function serializeInstanceOverrideState(state) {
521
- return {
522
- self: [...state.self].map(([field, value]) => [field, serializeOverrideValue(value)]),
523
- descendants: [...state.descendants].map(([nodeId, fields]) => [nodeId, [...fields].map(([field, value]) => [field, serializeOverrideValue(value)])])
524
- };
525
- }
526
- function deserializeInstanceOverrideState(state) {
527
- if (!state || typeof state !== "object" || Array.isArray(state)) return createInstanceOverrideState();
528
- const self = "self" in state ? deserializeEntries(state.self) : /* @__PURE__ */ new Map();
529
- const descendants = /* @__PURE__ */ new Map();
530
- if ("descendants" in state && Array.isArray(state.descendants)) for (const entry of state.descendants) {
531
- if (!Array.isArray(entry) || entry.length !== 2 || typeof entry[0] !== "string") continue;
532
- descendants.set(entry[0], deserializeEntries(entry[1]));
533
- }
534
- return {
535
- self,
536
- descendants
537
- };
538
- }
539
- function cloneInstanceOverrideState(state) {
540
- return {
541
- self: new Map([...state.self].map(([field, value]) => [field, structuredClone(value)])),
542
- descendants: new Map([...state.descendants].map(([id, fields]) => [id, new Map([...fields].map(([field, value]) => [field, structuredClone(value)]))]))
543
- };
544
- }
545
- /** Remap runtime identities only; ordinary strings and source-format payloads stay opaque. */
546
- function remapInstanceOverrideState(state, references) {
547
- const remapValue = (field, value) => {
548
- if (typeof value !== "string") return structuredClone(value);
549
- if (field === "componentId" || field === "sourceComponentId") return references.node(value);
550
- if (field.startsWith("boundVariables/")) return references.variable(value);
551
- return value;
552
- };
553
- const fields = (entries) => new Map([...entries].map(([field, value]) => [field, remapValue(field, value)]));
554
- const descendants = /* @__PURE__ */ new Map();
555
- for (const [id, entries] of state.descendants) {
556
- const mapped = references.node(id);
557
- if (descendants.has(mapped)) throw new Error(`Duplicate remapped override target ${mapped}`);
558
- descendants.set(mapped, fields(entries));
559
- }
560
- return {
561
- self: fields(state.self),
562
- descendants
563
- };
564
- }
565
- function getInstanceOverride(state, instanceId, nodeId, field) {
566
- return nodeId === instanceId ? state.self.get(field) : state.descendants.get(nodeId)?.get(field);
567
- }
568
- function hasInstanceOverride(state, instanceId, nodeId, field) {
569
- return (nodeId === instanceId ? state.self : state.descendants.get(nodeId))?.has(field) ?? false;
570
- }
571
- function setInstanceOverride(state, instanceId, nodeId, field, value = true) {
572
- if (nodeId === instanceId) {
573
- state.self.set(field, value);
574
- return;
575
- }
576
- const fields = state.descendants.get(nodeId) ?? /* @__PURE__ */ new Map();
577
- fields.set(field, value);
578
- state.descendants.set(nodeId, fields);
579
- }
580
- function deleteInstanceOverride(state, instanceId, nodeId, field) {
581
- const fields = nodeId === instanceId ? state.self : state.descendants.get(nodeId);
582
- if (!fields?.delete(field)) return false;
583
- if (nodeId !== instanceId && fields.size === 0) state.descendants.delete(nodeId);
584
- return true;
585
- }
586
- function clearInstanceOverrides(state) {
587
- state.self.clear();
588
- state.descendants.clear();
589
- }
590
- function forEachInstanceOverride(state, callback) {
591
- for (const [field, value] of state.self) callback("", field, value);
592
- for (const [nodeId, fields] of state.descendants) for (const [field, value] of fields) callback(nodeId, field, value);
593
- }
594
- //#endregion
595
- //#region src/node-defaults.ts
596
- function createDefaultSourceMetadata() {
597
- return {
598
- format: null,
599
- id: null,
600
- orderKey: null,
601
- editedFields: [],
602
- fig: {
603
- rawSize: null,
604
- rawTransform: null,
605
- rawNodeFields: {},
606
- layout: null,
607
- symbolOverrides: [],
608
- componentPropAssignments: [],
609
- derivedSymbolData: [],
610
- derivedSymbolDataLayoutVersion: null,
611
- uniformScaleFactor: null
612
- }
613
- };
614
- }
615
- /** Where Figma aligns a new node's strokes: centered on lines and vectors, outside text, else inside. */
616
- function defaultStrokeAlign(type) {
617
- if (type === "LINE" || type === "VECTOR") return "CENTER";
618
- return type === "TEXT" ? "OUTSIDE" : "INSIDE";
619
- }
620
- /**
621
- * Weight and alignment a stroke added to `node` takes: its first stroke's, or what the node keeps
622
- * with none. Adding a stroke from the panel and from the plugin API both go through here.
623
- */
624
- function newStrokeGeometry(node) {
625
- const first = node.strokes.at(0);
626
- return {
627
- weight: first?.weight ?? node.strokeWeight,
628
- align: first?.align ?? node.strokeAlign
629
- };
630
- }
631
- function createDefaultNode(generateId, type, overrides = {}) {
632
- return {
633
- id: generateId(),
634
- type,
635
- name: type.charAt(0) + type.slice(1).toLowerCase(),
636
- parentId: null,
637
- childIds: [],
638
- x: 0,
639
- y: 0,
640
- width: 100,
641
- height: 100,
642
- rotation: 0,
643
- source: createDefaultSourceMetadata(),
644
- derivedLayout: null,
645
- fills: type === "TEXT" ? [{
646
- type: "SOLID",
647
- color: BLACK,
648
- opacity: 1,
649
- visible: true
650
- }] : [],
651
- strokes: [],
652
- effects: [],
653
- layoutGrids: [],
654
- guides: [],
655
- fillStyleId: null,
656
- strokeStyleId: null,
657
- textStyleId: null,
658
- effectStyleId: null,
659
- gridStyleId: null,
660
- sharedStyleType: null,
661
- opacity: 1,
662
- cornerRadius: 0,
663
- topLeftRadius: 0,
664
- topRightRadius: 0,
665
- bottomRightRadius: 0,
666
- bottomLeftRadius: 0,
667
- independentCorners: false,
668
- cornerSmoothing: 0,
669
- visible: true,
670
- locked: false,
671
- clipsContent: false,
672
- text: "",
673
- fontSize: 14,
674
- fontFamily: DEFAULT_FONT_FAMILY,
675
- fontWeight: 400,
676
- italic: false,
677
- textAlignHorizontal: "LEFT",
678
- textDirection: "AUTO",
679
- textLanguage: null,
680
- leadingTrim: "NONE",
681
- lineHeight: null,
682
- letterSpacing: 0,
683
- layoutMode: "NONE",
684
- layoutDirection: "AUTO",
685
- layoutWrap: "NO_WRAP",
686
- primaryAxisAlign: "MIN",
687
- counterAxisAlign: "MIN",
688
- primaryAxisSizing: "FIXED",
689
- counterAxisSizing: "FIXED",
690
- itemSpacing: 0,
691
- counterAxisSpacing: 0,
692
- paddingTop: 0,
693
- paddingRight: 0,
694
- paddingBottom: 0,
695
- paddingLeft: 0,
696
- blendMode: "PASS_THROUGH",
697
- layoutPositioning: "AUTO",
698
- layoutGrow: 0,
699
- layoutAlignSelf: "AUTO",
700
- vectorNetwork: null,
701
- handleMirroring: "NONE",
702
- fillGeometry: [],
703
- strokeGeometry: [],
704
- arcData: null,
705
- textAlignVertical: "TOP",
706
- textAutoResize: "NONE",
707
- textCase: "ORIGINAL",
708
- textDecoration: "NONE",
709
- textDecorationStyle: "SOLID",
710
- textDecorationThickness: null,
711
- textDecorationFills: [],
712
- textDecorationSkipInk: true,
713
- textUnderlineOffset: null,
714
- maxLines: null,
715
- textParagraphs: [],
716
- listSpacing: 0,
717
- paragraphSpacing: 0,
718
- paragraphIndent: 0,
719
- hangingList: false,
720
- styleRuns: [],
721
- fontVariations: [],
722
- fontFeatures: [],
723
- horizontalConstraint: "MIN",
724
- verticalConstraint: "MIN",
725
- strokeCap: "NONE",
726
- strokeJoin: "MITER",
727
- dashPattern: [],
728
- borderTopWeight: 0,
729
- borderRightWeight: 0,
730
- borderBottomWeight: 0,
731
- borderLeftWeight: 0,
732
- independentStrokeWeights: false,
733
- strokeWeight: 1,
734
- strokeAlign: defaultStrokeAlign(type),
735
- strokeMiterLimit: 4,
736
- minWidth: null,
737
- maxWidth: null,
738
- minHeight: null,
739
- maxHeight: null,
740
- targetAspectRatio: null,
741
- isMask: false,
742
- maskType: "ALPHA",
743
- maskIsOutline: false,
744
- gridTemplateColumns: [],
745
- gridTemplateRows: [],
746
- gridColumnGap: 0,
747
- gridRowGap: 0,
748
- gridPosition: null,
749
- counterAxisAlignContent: "AUTO",
750
- itemReverseZIndex: false,
751
- strokesIncludedInLayout: false,
752
- expanded: true,
753
- textTruncation: "DISABLED",
754
- autoRename: true,
755
- pointCount: 5,
756
- starInnerRadius: .38,
757
- componentId: null,
758
- instanceOverrides: createInstanceOverrideState(),
759
- componentPropertyDefinitions: [],
760
- componentPropertyReferences: [],
761
- componentPropertyAssignments: {},
762
- componentPropertyValues: {},
763
- componentKey: null,
764
- sourceLibraryKey: null,
765
- publishId: null,
766
- overrideKey: null,
767
- sharedSymbolVersion: null,
768
- publishedVersion: null,
769
- librarySource: null,
770
- isPublishable: false,
771
- isSymbolPublishable: false,
772
- isExposedInstance: false,
773
- symbolDescription: "",
774
- symbolLinks: [],
775
- variantPropSpecs: [],
776
- boundVariables: {},
777
- variableBindingScales: {},
778
- variableAssignmentScales: {},
779
- componentScale: 1,
780
- variableModes: {},
781
- exportSettings: [],
782
- pluginData: [],
783
- pluginRelaunchData: [],
784
- internalOnly: false,
785
- flipX: false,
786
- flipY: false,
787
- textPicture: null,
788
- derivedTextGlyphs: null,
789
- textPathData: null,
790
- textPathBox: null,
791
- booleanOperation: void 0,
792
- ...overrides
793
- };
794
- }
795
- /** Containers whose bounds follow their children and that set no coordinate space, as in Figma. */
796
- const FITTED_CONTAINER_TYPES = /* @__PURE__ */ new Set(["GROUP", "BOOLEAN_OPERATION"]);
797
- const CONTAINER_TYPES = /* @__PURE__ */ new Set([
798
- "CANVAS",
799
- "FRAME",
800
- "GROUP",
801
- "BOOLEAN_OPERATION",
802
- "SECTION",
803
- "COMPONENT",
804
- "COMPONENT_SET",
805
- "INSTANCE"
806
- ]);
807
- //#endregion
808
- //#region src/vector-network.ts
809
- /** Concatenate vector networks while preserving independent geometry. */
810
- function mergeVectorNetworks(networks) {
811
- const vertices = [];
812
- const segments = [];
813
- const regions = [];
814
- let vertexOffset = 0;
815
- let segmentOffset = 0;
816
- for (const network of networks) {
817
- for (const vertex of network.vertices) vertices.push({ ...vertex });
818
- for (const segment of network.segments) segments.push({
819
- ...segment,
820
- start: segment.start + vertexOffset,
821
- end: segment.end + vertexOffset,
822
- tangentStart: { ...segment.tangentStart },
823
- tangentEnd: { ...segment.tangentEnd }
824
- });
825
- for (const region of network.regions) {
826
- const loops = [];
827
- for (const loop of region.loops) {
828
- const shifted = [];
829
- for (const segmentIndex of loop) shifted.push(segmentIndex + segmentOffset);
830
- loops.push(shifted);
831
- }
832
- regions.push({
833
- windingRule: region.windingRule,
834
- loops
835
- });
836
- }
837
- vertexOffset += network.vertices.length;
838
- segmentOffset += network.segments.length;
839
- }
840
- return {
841
- vertices,
842
- segments,
843
- regions
844
- };
845
- }
846
- /**
847
- * Map a VectorNetwork through an affine matrix: vertices as points,
848
- * tangents as direction vectors (linear part only, no translation).
849
- * Returns a deep copy; the input is not mutated.
850
- */
851
- function transformVectorNetwork(m, vn) {
852
- const mapVector = (v) => ({
853
- x: m[0] * v.x + m[1] * v.y,
854
- y: m[3] * v.x + m[4] * v.y
855
- });
856
- return {
857
- vertices: vn.vertices.map((v) => ({
858
- ...v,
859
- x: m[0] * v.x + m[1] * v.y + m[2],
860
- y: m[3] * v.x + m[4] * v.y + m[5]
861
- })),
862
- segments: vn.segments.map((s) => ({
863
- ...s,
864
- tangentStart: mapVector(s.tangentStart),
865
- tangentEnd: mapVector(s.tangentEnd)
866
- })),
867
- regions: vn.regions.map((r) => ({
868
- windingRule: r.windingRule,
869
- loops: r.loops.map((l) => [...l])
870
- }))
871
- };
872
- }
873
- /** Structural equality of two VectorNetworks (order-sensitive, exact values). */
874
- function vectorNetworksEqual(a, b) {
875
- return isEqual(a.vertices, b.vertices) && isEqual(a.segments, b.segments) && isEqual(a.regions, b.regions);
876
- }
877
- /** Deep-copy a VectorNetwork, stripping any Vue Proxy wrappers. */
878
- function cloneVectorNetwork(vn) {
879
- return {
880
- vertices: vn.vertices.map((v) => ({ ...v })),
881
- segments: vn.segments.map((s) => ({
882
- ...s,
883
- tangentStart: { ...s.tangentStart },
884
- tangentEnd: { ...s.tangentEnd }
885
- })),
886
- regions: vn.regions.map((r) => ({
887
- windingRule: r.windingRule,
888
- loops: r.loops.map((l) => [...l])
889
- }))
890
- };
891
- }
892
- /**
893
- * Validate a VectorNetwork structure, returning an array of error messages.
894
- * Empty array means the network is valid.
895
- */
896
- function validateVectorNetwork(value) {
897
- if (!isRecord(value)) return ["network must be an object"];
898
- if (!Array.isArray(value.vertices)) return ["vertices must be an array"];
899
- if (!Array.isArray(value.segments)) return ["segments must be an array"];
900
- const errors = [];
901
- validateVertices(value.vertices, errors);
902
- validateSegments(value.segments, value.vertices.length, errors);
903
- const typedSegments = value.segments.filter(isSegmentRecord);
904
- if (value.regions !== void 0) {
905
- if (Array.isArray(value.regions)) validateRegions(value.regions, value.segments.length, typedSegments.length === value.segments.length ? typedSegments : null, errors);
906
- else errors.push("regions must be an array when provided");
907
- }
908
- return errors;
909
- }
910
- function validateVertices(vertices, errors) {
911
- for (let index = 0; index < vertices.length; index++) if (!isFiniteVector(vertices[index])) errors.push(`vertex[${index}]: x and y must be finite numbers`);
912
- }
913
- function validateSegments(segments, vertexCount, errors) {
914
- for (let index = 0; index < segments.length; index++) {
915
- const segment = segments[index];
916
- if (!isRecord(segment)) {
917
- errors.push(`segment[${index}] must be an object`);
918
- continue;
919
- }
920
- if (!isInteger(segment.start) || !isInteger(segment.end)) {
921
- errors.push(`segment[${index}]: start and end must be integers`);
922
- continue;
923
- }
924
- if (segment.start < 0 || segment.start >= vertexCount) errors.push(`segment[${index}]: start index ${segment.start} out of range`);
925
- if (segment.end < 0 || segment.end >= vertexCount) errors.push(`segment[${index}]: end index ${segment.end} out of range`);
926
- validateSegmentTangents(segment, index, errors);
927
- }
928
- }
929
- function validateSegmentTangents(segment, index, errors) {
930
- for (const tangentKey of ["tangentStart", "tangentEnd"]) {
931
- const tangent = segment[tangentKey];
932
- if (tangent !== void 0 && !isFiniteVector(tangent)) errors.push(`segment[${index}]: ${tangentKey} must contain finite x and y numbers`);
933
- }
934
- }
935
- function validateRegions(regions, segmentCount, segments, errors) {
936
- for (let regionIndex = 0; regionIndex < regions.length; regionIndex++) {
937
- const region = regions[regionIndex];
938
- if (!isRecord(region) || !Array.isArray(region.loops)) {
939
- errors.push(`region[${regionIndex}]: loops must be an array`);
940
- continue;
941
- }
942
- if (region.windingRule !== "NONZERO" && region.windingRule !== "EVENODD") errors.push(`region[${regionIndex}]: windingRule must be NONZERO or EVENODD`);
943
- if (region.loops.length === 0) errors.push(`region[${regionIndex}]: loops must contain at least one loop`);
944
- validateRegionLoops(region.loops, regionIndex, segmentCount, segments, errors);
945
- }
946
- }
947
- function validateRegionLoops(loops, regionIndex, segmentCount, segments, errors) {
948
- for (let loopIndex = 0; loopIndex < loops.length; loopIndex++) {
949
- const loop = loops[loopIndex];
950
- if (!Array.isArray(loop)) {
951
- errors.push(`region[${regionIndex}].loop[${loopIndex}] must be an array`);
952
- continue;
953
- }
954
- if (loop.length === 0) {
955
- errors.push(`region[${regionIndex}].loop[${loopIndex}] must contain at least one segment`);
956
- continue;
957
- }
958
- const segmentIndices = [];
959
- for (const segmentIndex of loop) if (!isInteger(segmentIndex) || segmentIndex < 0 || segmentIndex >= segmentCount) errors.push(`region[${regionIndex}].loop[${loopIndex}]: segment index ${String(segmentIndex)} out of range`);
960
- else segmentIndices.push(segmentIndex);
961
- if (segmentIndices.length !== loop.length) continue;
962
- if (new Set(segmentIndices).size !== segmentIndices.length) {
963
- errors.push(`region[${regionIndex}].loop[${loopIndex}] must not repeat segments`);
964
- continue;
965
- }
966
- if (segments && !formsContinuousChain(segmentIndices, segments)) errors.push(`region[${regionIndex}].loop[${loopIndex}] segments must form a continuous chain`);
967
- }
968
- }
969
- function formsContinuousChain(indices, segments) {
970
- if (indices.length <= 1) return true;
971
- const first = segments[indices[0]];
972
- return followsChain(indices, segments, first.end) || followsChain(indices, segments, first.start);
973
- }
974
- function followsChain(indices, segments, initialEnd) {
975
- let current = initialEnd;
976
- for (let index = 1; index < indices.length; index++) {
977
- const segment = segments[indices[index]];
978
- if (segment.start === current) current = segment.end;
979
- else if (segment.end === current) current = segment.start;
980
- else return false;
981
- }
982
- return true;
983
- }
984
- function isSegmentRecord(value) {
985
- return isRecord(value) && isInteger(value.start) && isInteger(value.end);
986
- }
987
- function isFiniteVector(value) {
988
- return isRecord(value) && typeof value.x === "number" && Number.isFinite(value.x) && typeof value.y === "number" && Number.isFinite(value.y);
989
- }
990
- function isInteger(value) {
991
- return typeof value === "number" && Number.isInteger(value);
992
- }
993
- function isRecord(value) {
994
- return typeof value === "object" && value !== null;
995
- }
996
- /**
997
- * Ensure every segment has tangentStart/tangentEnd and a regions array.
998
- * Missing tangents default to {x:0, y:0} (straight line segments).
999
- * Use at system boundaries where input may come from JSON/MCP.
1000
- */
1001
- function normalizeVectorNetwork(vn) {
1002
- const ZERO = {
1003
- x: 0,
1004
- y: 0
1005
- };
1006
- return {
1007
- vertices: vn.vertices,
1008
- segments: vn.segments.map((s) => ({
1009
- start: s.start,
1010
- end: s.end,
1011
- tangentStart: s.tangentStart ?? { ...ZERO },
1012
- tangentEnd: s.tangentEnd ?? { ...ZERO }
1013
- })),
1014
- regions: vn.regions ?? []
1015
- };
1016
- }
1017
- //#endregion
1018
- //#region src/copy.ts
1019
- /** Generic over the paint shape so a stroke keeps its own fields while the paint deep-copies. */
1020
- function copyFill(f) {
1021
- const copy = {
1022
- ...f,
1023
- color: { ...f.color }
1024
- };
1025
- if (f.gradientStops) copy.gradientStops = f.gradientStops.map(copyGradientStop);
1026
- if (f.gradientTransform) copy.gradientTransform = { ...f.gradientTransform };
1027
- if (f.imageTransform) copy.imageTransform = { ...f.imageTransform };
1028
- if (f.patternSpacing) copy.patternSpacing = { ...f.patternSpacing };
1029
- if (f.noiseSize) copy.noiseSize = { ...f.noiseSize };
1030
- return copy;
1031
- }
1032
- function copyStroke(s) {
1033
- const copy = copyFill(s);
1034
- if (s.dashPattern) copy.dashPattern = [...s.dashPattern];
1035
- return copy;
1036
- }
1037
- function copyEffect(e) {
1038
- return {
1039
- ...e,
1040
- color: { ...e.color },
1041
- offset: { ...e.offset }
1042
- };
1043
- }
1044
- function copyStyleRun(r) {
1045
- const copy = {
1046
- ...r,
1047
- style: {
1048
- ...r.style,
1049
- fills: r.style.fills ? r.style.fills.map(copyFill) : void 0,
1050
- textDecorationFills: r.style.textDecorationFills ? r.style.textDecorationFills.map(copyFill) : void 0,
1051
- fontVariations: r.style.fontVariations ? r.style.fontVariations.map((v) => ({ ...v })) : void 0,
1052
- fontFeatures: r.style.fontFeatures ? r.style.fontFeatures.map((v) => ({ ...v })) : void 0
1053
- }
1054
- };
1055
- if (r.style.hyperlink) copy.style.hyperlink = { ...r.style.hyperlink };
1056
- if (r.style.boundVariables) copy.style.boundVariables = { ...r.style.boundVariables };
1057
- return copy;
1058
- }
1059
- const internalCopySources = /* @__PURE__ */ new WeakMap();
1060
- /** Record immutable lineage for an internal deep copy without sharing mutable values. */
1061
- function markCopySource(source, copy) {
1062
- internalCopySources.set(copy, internalCopySources.get(source) ?? source);
1063
- return copy;
1064
- }
1065
- /** Compare internal deep copies in O(1) without traversing large paint or text payloads. */
1066
- function hasSameCopySource(left, right) {
1067
- if (left === right) return true;
1068
- return (internalCopySources.get(left) ?? left) === (internalCopySources.get(right) ?? right);
1069
- }
1070
- function copyFills(fills) {
1071
- return fills.map(copyFill);
1072
- }
1073
- function copyStrokes(strokes) {
1074
- return strokes.map(copyStroke);
1075
- }
1076
- function copyEffects(effects) {
1077
- return effects.map(copyEffect);
1078
- }
1079
- function copyLayoutGrids(grids) {
1080
- return grids.map((grid) => ({
1081
- ...grid,
1082
- color: grid.color ? { ...grid.color } : void 0
1083
- }));
1084
- }
1085
- function copyStyleRuns(runs) {
1086
- return runs.map(copyStyleRun);
1087
- }
1088
- /** Keep path-level fills across copy/scale/transform (resize snapshots). */
1089
- function withPathPaintMeta(path, commandsBlob) {
1090
- return {
1091
- windingRule: path.windingRule,
1092
- commandsBlob,
1093
- ...path.fills ? { fills: copyFills(path.fills) } : {}
1094
- };
1095
- }
1096
- function copyGeometryPaths(paths) {
1097
- return paths.map((p) => withPathPaintMeta(p, p.commandsBlob.slice()));
1098
- }
1099
- /**
1100
- * Affine-transform every coordinate pair in a path command blob (returns a
1101
- * copy): (x, y) → (m00·x + m01·y + tx, m10·x + m11·y + ty).
1102
- * Command layout: 1=move/2=line (1 pair), 3=quad (2 pairs), 4=cubic (3 pairs)
1103
- * — font-glyph blobs are quad-heavy, so skipping command 3 desyncs the walk.
1104
- */
1105
- function transformGeometryBlob(blob, m00, m01, m10, m11, tx = 0, ty = 0) {
1106
- const out = blob.slice();
1107
- const dv = new DataView(out.buffer, out.byteOffset, out.byteLength);
1108
- let offset = 0;
1109
- while (offset < out.length) {
1110
- const command = out[offset++];
1111
- const coords = geometryCommandCoordCount(command);
1112
- if (coords == null) break;
1113
- for (let i = 0; i < coords; i++) {
1114
- if (offset + 8 > out.length) break;
1115
- const x = dv.getFloat32(offset, true);
1116
- const y = dv.getFloat32(offset + 4, true);
1117
- dv.setFloat32(offset, m00 * x + m01 * y + tx, true);
1118
- dv.setFloat32(offset + 4, m10 * x + m11 * y + ty, true);
1119
- offset += 8;
1120
- }
1121
- }
1122
- return out;
1123
- }
1124
- function transformGeometryPaths(paths, m00, m01, m10, m11, tx = 0, ty = 0) {
1125
- return paths.map((g) => withPathPaintMeta(g, transformGeometryBlob(g.commandsBlob, m00, m01, m10, m11, tx, ty)));
1126
- }
1127
- /**
1128
- * Scale path command blob coordinates by (sx, sy).
1129
- * Identity scale returns a deep copy (same as copyGeometryPaths).
1130
- */
1131
- function scaleGeometryPaths(paths, sx, sy) {
1132
- if (sx === 1 && sy === 1) return copyGeometryPaths(paths);
1133
- return transformGeometryPaths(paths, sx, 0, 0, sy);
1134
- }
1135
- /** Copy an optional array: non-empty → mapped, empty → [], undefined → undefined. */
1136
- function copyOpt(arr, fn) {
1137
- if (arr === void 0) return void 0;
1138
- return arr.length > 0 ? fn(arr) : [];
1139
- }
1140
- function copyGradientStop(gs) {
1141
- return {
1142
- color: { ...gs.color },
1143
- position: gs.position
1144
- };
1145
- }
1146
- function copySpread(arr) {
1147
- return arr?.map((item) => ({ ...item })) ?? [];
1148
- }
1149
- function copyPropertyDefs(defs) {
1150
- return defs?.map((d) => ({
1151
- ...d,
1152
- variantOptions: d.variantOptions ? [...d.variantOptions] : void 0,
1153
- preferredValues: d.preferredValues ? [...d.preferredValues] : void 0,
1154
- slotSettings: d.slotSettings ? { ...d.slotSettings } : void 0
1155
- })) ?? [];
1156
- }
1157
- /** Deep-copy path-text glyphs (fresh commandsBlob buffers). */
1158
- function copyDerivedGlyphs(glyphs) {
1159
- return glyphs ? glyphs.map((g) => ({
1160
- ...g,
1161
- commandsBlob: new Uint8Array(g.commandsBlob)
1162
- })) : null;
1163
- }
1164
- function copyArcData(a) {
1165
- return {
1166
- startingAngle: a.startingAngle,
1167
- endingAngle: a.endingAngle,
1168
- innerRadius: a.innerRadius
1169
- };
1170
- }
1171
- function cloneNodeProps(src, componentId, mode = "deep") {
1172
- const { id: _, parentId: _p, childIds: _c, ...rest } = src;
1173
- if (mode === "fig-import") return {
1174
- ...rest,
1175
- ...componentId !== null ? { componentId } : {},
1176
- source: createDefaultSourceMetadata(),
1177
- boundVariables: { ...src.boundVariables },
1178
- variableBindingScales: { ...src.variableBindingScales },
1179
- variableAssignmentScales: { ...src.variableAssignmentScales },
1180
- variableModes: { ...src.variableModes },
1181
- instanceOverrides: cloneInstanceOverrideState(src.instanceOverrides),
1182
- componentPropertyAssignments: { ...src.componentPropertyAssignments },
1183
- componentPropertyValues: { ...src.componentPropertyValues }
1184
- };
1185
- return {
1186
- ...rest,
1187
- ...componentId !== null ? { componentId } : {},
1188
- boundVariables: { ...src.boundVariables },
1189
- variableBindingScales: { ...src.variableBindingScales },
1190
- variableAssignmentScales: { ...src.variableAssignmentScales },
1191
- variableModes: { ...src.variableModes },
1192
- instanceOverrides: cloneInstanceOverrideState(src.instanceOverrides),
1193
- fills: copyOpt(src.fills, (value) => markCopySource(value, copyFills(value))),
1194
- strokes: copyOpt(src.strokes, (value) => markCopySource(value, copyStrokes(value))),
1195
- effects: copyOpt(src.effects, (value) => markCopySource(value, copyEffects(value))),
1196
- layoutGrids: copyOpt(src.layoutGrids, copyLayoutGrids),
1197
- guides: copyOpt(src.guides, (guides) => guides.map((guide) => ({ ...guide }))),
1198
- styleRuns: copyOpt(src.styleRuns, (value) => markCopySource(value, copyStyleRuns(value))),
1199
- source: componentId === null ? structuredClone(src.source) : createDefaultSourceMetadata(),
1200
- dashPattern: copyOpt(src.dashPattern, (a) => [...a]),
1201
- fontVariations: copyOpt(src.fontVariations, (a) => a.map((v) => ({ ...v }))),
1202
- fontFeatures: copyOpt(src.fontFeatures, (a) => a.map((v) => ({ ...v }))),
1203
- textParagraphs: copyOpt(src.textParagraphs, (a) => a.map((v) => ({ ...v }))),
1204
- textDecorationFills: copyOpt(src.textDecorationFills, copyFills),
1205
- fillGeometry: copyOpt(src.fillGeometry, copyGeometryPaths),
1206
- strokeGeometry: copyOpt(src.strokeGeometry, copyGeometryPaths),
1207
- gridTemplateColumns: copySpread(src.gridTemplateColumns),
1208
- gridTemplateRows: copySpread(src.gridTemplateRows),
1209
- componentPropertyDefinitions: copyPropertyDefs(src.componentPropertyDefinitions),
1210
- componentPropertyReferences: copySpread(src.componentPropertyReferences),
1211
- componentPropertyAssignments: { ...src.componentPropertyAssignments },
1212
- symbolLinks: copySpread(src.symbolLinks),
1213
- variantPropSpecs: copySpread(src.variantPropSpecs),
1214
- pluginData: copySpread(src.pluginData),
1215
- pluginRelaunchData: copySpread(src.pluginRelaunchData),
1216
- exportSettings: copySpread(src.exportSettings),
1217
- componentPropertyValues: { ...src.componentPropertyValues },
1218
- derivedLayout: src.derivedLayout ? { ...src.derivedLayout } : null,
1219
- arcData: src.arcData ? copyArcData(src.arcData) : null,
1220
- vectorNetwork: src.vectorNetwork ? cloneVectorNetwork(src.vectorNetwork) : null,
1221
- textPicture: src.textPicture ? new Uint8Array(src.textPicture) : null,
1222
- derivedTextGlyphs: src.derivedTextGlyphs ? markCopySource(src.derivedTextGlyphs, copyDerivedGlyphs(src.derivedTextGlyphs) ?? []) : null,
1223
- textPathData: src.textPathData ? structuredClone(src.textPathData) : null,
1224
- textPathBox: src.textPathBox ? { ...src.textPathBox } : null,
1225
- gridPosition: src.gridPosition ? { ...src.gridPosition } : null,
1226
- targetAspectRatio: src.targetAspectRatio ? { ...src.targetAspectRatio } : null
1227
- };
1228
- }
1229
- //#endregion
1230
- //#region src/color/normalize.ts
1231
- function normalizeColor(color) {
1232
- if (!color) return { ...BLACK };
1233
- return {
1234
- r: color.r ?? 0,
1235
- g: color.g ?? 0,
1236
- b: color.b ?? 0,
1237
- a: color.a ?? 1
1238
- };
1239
- }
1240
- //#endregion
1241
- //#region src/color/okhcl.ts
1242
- const toRGB$2 = converter("rgb");
1243
- const toP3$1 = converter("p3");
1244
- const toOkHCL = converter("oklch");
1245
- const toDisplayableRGB$1 = toGamut("rgb", "oklch");
1246
- const toDisplayableP3$1 = toGamut("p3", "oklch");
1247
- function clampUnit(value) {
1248
- if (value < 0) return 0;
1249
- if (value > 1) return 1;
1250
- return value;
1251
- }
1252
- function normalizeHue(value) {
1253
- const hue = value % 360;
1254
- return hue < 0 ? hue + 360 : hue;
1255
- }
1256
- function normalizeOkHCLColor(color) {
1257
- return {
1258
- h: normalizeHue(color.h),
1259
- c: Math.max(0, color.c),
1260
- l: clampUnit(color.l),
1261
- a: clampUnit(color.a ?? 1)
1262
- };
1263
- }
1264
- /** Coordinates in `colorSpace`, so callers can store colours in the document's profile. */
1265
- function okhclToRGBA(color, colorSpace = "srgb") {
1266
- const normalized = normalizeOkHCLColor(color);
1267
- const oklch = {
1268
- mode: "oklch",
1269
- l: normalized.l,
1270
- c: normalized.c,
1271
- h: normalized.h,
1272
- alpha: normalized.a
1273
- };
1274
- if (colorSpace === "display-p3") {
1275
- const p3 = toP3$1(toDisplayableP3$1(oklch));
1276
- return normalizeColor({
1277
- r: p3.r,
1278
- g: p3.g,
1279
- b: p3.b,
1280
- a: p3.alpha ?? normalized.a
1281
- });
1282
- }
1283
- const rgb = toRGB$2(toDisplayableRGB$1(oklch));
1284
- return normalizeColor({
1285
- r: rgb.r,
1286
- g: rgb.g,
1287
- b: rgb.b,
1288
- a: rgb.alpha ?? normalized.a
1289
- });
1290
- }
1291
- /** Reads `color` as coordinates in `colorSpace`, the inverse of {@link okhclToRGBA}. */
1292
- function rgbaToOkHCL(color, colorSpace = "srgb") {
1293
- const oklch = toOkHCL(colorSpace === "display-p3" ? {
1294
- mode: "p3",
1295
- r: color.r,
1296
- g: color.g,
1297
- b: color.b,
1298
- alpha: color.a
1299
- } : {
1300
- mode: "rgb",
1301
- r: color.r,
1302
- g: color.g,
1303
- b: color.b,
1304
- alpha: color.a
1305
- });
1306
- return normalizeOkHCLColor({
1307
- h: oklch.h ?? 0,
1308
- c: oklch.c,
1309
- l: oklch.l,
1310
- a: oklch.alpha ?? color.a
1311
- });
1312
- }
1313
- function serializeOkHCLPayload(payload) {
1314
- return OPEN_PENCIL_PLUGIN_DATA.okhcl.encode(payload);
1315
- }
1316
- function parseOkHCLPayload(value) {
1317
- return OPEN_PENCIL_PLUGIN_DATA.okhcl.decode(value) ?? null;
1318
- }
1319
- function createOkHCLPayload(kind, index, color) {
1320
- return {
1321
- version: 1,
1322
- kind,
1323
- index,
1324
- color: normalizeOkHCLColor(color)
1325
- };
1326
- }
1327
- /** The node's plugin data with the payload for one paint replaced, or removed without `color`. */
1328
- function withOkHCLPayload(node, kind, index, color) {
1329
- const payloads = getNodeOkHCLPayloads(node).filter((payload) => payload.kind !== kind || payload.index !== index);
1330
- if (color) payloads.push(createOkHCLPayload(kind, index, color));
1331
- return withAllPluginData(node.pluginData, OPEN_PENCIL_PLUGIN_DATA.okhcl, payloads);
1332
- }
1333
- function setNodeFillOkHCL(node, index, color, colorSpace = "srgb") {
1334
- const fills = node.fills.map(copyFill);
1335
- if (index < 0 || index >= fills.length) throw new Error(`Fill ${index} not found`);
1336
- const fill = fills[index];
1337
- const rgba = okhclToRGBA(color, colorSpace);
1338
- fills[index] = {
1339
- ...fill,
1340
- color: rgba,
1341
- opacity: rgba.a
1342
- };
1343
- return {
1344
- fills,
1345
- pluginData: withOkHCLPayload(node, "fill", index, color)
1346
- };
1347
- }
1348
- function setNodeStrokeOkHCL(node, index, color, colorSpace = "srgb") {
1349
- const strokes = node.strokes.map(copyStroke);
1350
- if (index < 0 || index >= strokes.length) throw new Error(`Stroke ${index} not found`);
1351
- const stroke = strokes[index];
1352
- const rgba = okhclToRGBA(color, colorSpace);
1353
- strokes[index] = {
1354
- ...stroke,
1355
- color: rgba,
1356
- opacity: rgba.a
1357
- };
1358
- return {
1359
- strokes,
1360
- pluginData: withOkHCLPayload(node, "stroke", index, color)
1361
- };
1362
- }
1363
- function clearNodeFillOkHCL(node, index) {
1364
- return { pluginData: withOkHCLPayload(node, "fill", index) };
1365
- }
1366
- function clearNodeStrokeOkHCL(node, index) {
1367
- return { pluginData: withOkHCLPayload(node, "stroke", index) };
1368
- }
1369
- function getNodeOkHCLPayloads(node) {
1370
- return readAllPluginData(node.pluginData, OPEN_PENCIL_PLUGIN_DATA.okhcl);
1371
- }
1372
- function getFillOkHCL(node, index) {
1373
- return getNodeOkHCLPayloads(node).find((payload) => payload.kind === "fill" && payload.index === index) ?? null;
1374
- }
1375
- function getStrokeOkHCL(node, index) {
1376
- return getNodeOkHCLPayloads(node).find((payload) => payload.kind === "stroke" && payload.index === index) ?? null;
1377
- }
1378
- //#endregion
1379
- //#region src/color/management.ts
1380
- const DEFAULT_COLOR_SPACE = "srgb";
1381
- const toRGB$1 = converter("rgb");
1382
- const toP3 = converter("p3");
1383
- const toDisplayableRGB = toGamut("rgb", "oklch");
1384
- const toDisplayableP3 = toGamut("p3", "oklch");
1385
- const isDisplayableRGB = inGamut("rgb");
1386
- const isDisplayableP3 = inGamut("p3");
1387
- function normalizeOkLCH(color) {
1388
- const hue = color.h % 360;
1389
- return {
1390
- mode: "oklch",
1391
- l: Math.max(0, Math.min(1, color.l)),
1392
- c: Math.max(0, color.c),
1393
- h: hue < 0 ? hue + 360 : hue,
1394
- alpha: Math.max(0, Math.min(1, color.a ?? 1))
1395
- };
1396
- }
1397
- /**
1398
- * Numbers are stored in the document's profile, so painting into a surface with a different
1399
- * profile has to convert them. Same profile means no work, which is the common case.
1400
- */
1401
- function convertComponents(color, from, to) {
1402
- if (from === to) return color;
1403
- const source = from === "display-p3" ? {
1404
- mode: "p3",
1405
- r: color.r,
1406
- g: color.g,
1407
- b: color.b,
1408
- alpha: color.a
1409
- } : {
1410
- mode: "rgb",
1411
- r: color.r,
1412
- g: color.g,
1413
- b: color.b,
1414
- alpha: color.a
1415
- };
1416
- const converted = to === "display-p3" ? toP3(source) : toRGB$1(source);
1417
- return normalizeColor({
1418
- r: converted.r,
1419
- g: converted.g,
1420
- b: converted.b,
1421
- a: converted.alpha ?? color.a
1422
- });
1423
- }
1424
- function isOutsideGamut(color, space) {
1425
- if (space === "display-p3") return !isDisplayableP3({
1426
- mode: "p3",
1427
- r: color.r,
1428
- g: color.g,
1429
- b: color.b,
1430
- alpha: color.a
1431
- });
1432
- return !isDisplayableRGB({
1433
- mode: "rgb",
1434
- r: color.r,
1435
- g: color.g,
1436
- b: color.b,
1437
- alpha: color.a
1438
- });
1439
- }
1440
- function resolveTargetSpace(options) {
1441
- return options?.colorSpace ?? options?.documentColorSpace ?? DEFAULT_COLOR_SPACE;
1442
- }
1443
- function formatCSSForTarget(color, targetSpace) {
1444
- if (targetSpace === "display-p3") {
1445
- const p3 = toP3({
1446
- mode: "rgb",
1447
- r: color.r,
1448
- g: color.g,
1449
- b: color.b,
1450
- alpha: color.a
1451
- });
1452
- return formatCss({
1453
- mode: "p3",
1454
- r: p3.r,
1455
- g: p3.g,
1456
- b: p3.b,
1457
- alpha: p3.alpha ?? color.a
1458
- });
1459
- }
1460
- return formatRgb({
1461
- mode: "rgb",
1462
- r: color.r,
1463
- g: color.g,
1464
- b: color.b,
1465
- alpha: color.a
1466
- });
1467
- }
1468
- function resolveOkHCLForPreview(color, options) {
1469
- const oklch = normalizeOkLCH(color);
1470
- const targetSpace = resolveTargetSpace(options);
1471
- if (targetSpace === "display-p3") {
1472
- const clipped = !isDisplayableP3(oklch);
1473
- const p3 = toP3(toDisplayableP3(oklch));
1474
- return {
1475
- color: normalizeColor({
1476
- r: p3.r,
1477
- g: p3.g,
1478
- b: p3.b,
1479
- a: p3.alpha ?? oklch.alpha
1480
- }),
1481
- cssColor: formatCss({
1482
- mode: "p3",
1483
- r: p3.r,
1484
- g: p3.g,
1485
- b: p3.b,
1486
- alpha: p3.alpha ?? oklch.alpha
1487
- }),
1488
- sourceSpace: "oklch",
1489
- targetSpace,
1490
- clipped
1491
- };
1492
- }
1493
- const clipped = !isDisplayableRGB(oklch);
1494
- const rgb = toRGB$1(toDisplayableRGB(oklch));
1495
- const resolved = normalizeColor({
1496
- r: rgb.r,
1497
- g: rgb.g,
1498
- b: rgb.b,
1499
- a: rgb.alpha ?? oklch.alpha
1500
- });
1501
- return {
1502
- color: resolved,
1503
- cssColor: formatRgb({
1504
- mode: "rgb",
1505
- r: resolved.r,
1506
- g: resolved.g,
1507
- b: resolved.b,
1508
- alpha: resolved.a
1509
- }),
1510
- sourceSpace: "oklch",
1511
- targetSpace,
1512
- clipped
1513
- };
1514
- }
1515
- /**
1516
- * A CSS color in any space, mapped into sRGB the way CSS maps out-of-gamut colors: by reducing
1517
- * chroma in OKLCH, so a Display P3 red becomes the nearest sRGB red, not a clipped one. A missing
1518
- * (`none`) component reads as zero. Null when `input` is not a color.
1519
- */
1520
- function parseDisplayableColor(input) {
1521
- const parsed = parse(input);
1522
- if (!parsed) return null;
1523
- const rgb = isDisplayableRGB(parsed) ? toRGB$1(parsed) : toDisplayableRGB(parsed);
1524
- return normalizeColor({
1525
- r: rgb.r,
1526
- g: rgb.g,
1527
- b: rgb.b,
1528
- a: parsed.alpha
1529
- });
1530
- }
1531
- function resolveRGBAForPreview(color, options) {
1532
- const documentColorSpace = options?.documentColorSpace ?? DEFAULT_COLOR_SPACE;
1533
- const targetSpace = options?.colorSpace ?? documentColorSpace;
1534
- const resolved = convertComponents(normalizeColor(color), documentColorSpace, targetSpace);
1535
- return {
1536
- color: resolved,
1537
- cssColor: formatCSSForTarget(resolved, targetSpace),
1538
- sourceSpace: "srgb",
1539
- targetSpace,
1540
- clipped: targetSpace !== documentColorSpace && isOutsideGamut(resolved, targetSpace)
1541
- };
1542
- }
1543
- function resolveNodeFillColor(fill, fillIndex, node, options) {
1544
- const okhcl = getFillOkHCL(node, fillIndex)?.color;
1545
- if (okhcl) return resolveOkHCLForPreview(okhcl, options);
1546
- return resolveRGBAForPreview(fill.color, options);
1547
- }
1548
- function resolveNodeStrokeColor(stroke, strokeIndex, node, options) {
1549
- const okhcl = getStrokeOkHCL(node, strokeIndex)?.color;
1550
- if (okhcl) return resolveOkHCLForPreview(okhcl, options);
1551
- return resolveRGBAForPreview(stroke.color, options);
1552
- }
1553
- function colorToDisplayCSS(color, options) {
1554
- return resolveRGBAForPreview(color, options).cssColor;
1555
- }
1556
- function getDefaultRenderColorSpace() {
1557
- return DEFAULT_COLOR_SPACE;
1558
- }
1559
- //#endregion
1560
- //#region src/color/index.ts
1561
- const toRGB = converter("rgb");
1562
- /** A CSS color, or null when `input` is not one. */
1563
- function tryParseColor(input) {
1564
- const parsed = parse(input);
1565
- if (!parsed) return null;
1566
- const rgb = toRGB(parsed);
1567
- return {
1568
- r: rgb.r,
1569
- g: rgb.g,
1570
- b: rgb.b,
1571
- a: parsed.alpha ?? 1
1572
- };
1573
- }
1574
- /** A CSS color, or black when `input` is not one. */
1575
- function parseColor(input) {
1576
- return tryParseColor(input) ?? { ...BLACK };
1577
- }
1578
- function colorToHex(color) {
1579
- return formatHex({
1580
- mode: "rgb",
1581
- r: color.r,
1582
- g: color.g,
1583
- b: color.b
1584
- }).toUpperCase();
1585
- }
1586
- function colorToHex8(color, alpha) {
1587
- const a = alpha ?? color.a;
1588
- if (a >= 1) return colorToHex(color);
1589
- return formatHex8({
1590
- mode: "rgb",
1591
- r: color.r,
1592
- g: color.g,
1593
- b: color.b,
1594
- alpha: a
1595
- }).toUpperCase();
1596
- }
1597
- function colorToHexRaw(color) {
1598
- return colorToHex(color).slice(1);
1599
- }
1600
- function colorToRgba255(color) {
1601
- return {
1602
- r: Math.round(color.r * 255),
1603
- g: Math.round(color.g * 255),
1604
- b: Math.round(color.b * 255),
1605
- a: color.a
1606
- };
1607
- }
1608
- function colorToCSS(color) {
1609
- return formatRgb({
1610
- mode: "rgb",
1611
- r: color.r,
1612
- g: color.g,
1613
- b: color.b,
1614
- alpha: color.a
1615
- });
1616
- }
1617
- function colorToCSSCompact(color) {
1618
- const { r, g, b } = colorToRgba255(color);
1619
- const a = Number(color.a.toFixed(3));
1620
- if (a >= 1) return `rgb(${r},${g},${b})`;
1621
- return `rgba(${r},${g},${b},${a})`;
1622
- }
1623
- function rgba255ToColor(r, g, b, a = 1) {
1624
- return {
1625
- r: r / 255,
1626
- g: g / 255,
1627
- b: b / 255,
1628
- a
1629
- };
1630
- }
1631
- function colorToFill(color) {
1632
- const rgba = typeof color === "string" ? parseColor(color) : color;
1633
- return {
1634
- type: "SOLID",
1635
- color: {
1636
- r: rgba.r,
1637
- g: rgba.g,
1638
- b: rgba.b,
1639
- a: rgba.a
1640
- },
1641
- opacity: rgba.a,
1642
- visible: true
1643
- };
1644
- }
1645
- const euclideanRGB255 = differenceEuclidean("rgb");
1646
- function colorDistance(c1, c2) {
1647
- return euclideanRGB255({
1648
- mode: "rgb",
1649
- r: c1.r,
1650
- g: c1.g,
1651
- b: c1.b
1652
- }, {
1653
- mode: "rgb",
1654
- r: c2.r,
1655
- g: c2.g,
1656
- b: c2.b
1657
- }) * 255;
1658
- }
1659
- //#endregion
1660
- export { CONTAINER_TYPES, FITTED_CONTAINER_TYPES, clearInstanceOverrides, clearNodeFillOkHCL, clearNodeStrokeOkHCL, clipBoundsToPolygon, clipPolygon, cloneInstanceOverrideState, cloneNodeProps, cloneVectorNetwork, colorDistance, colorToCSS, colorToCSSCompact, colorToDisplayCSS, colorToFill, colorToHex, colorToHex8, colorToHexRaw, colorToRgba255, computeAbsoluteBounds, computeBounds, computeDescendantVisualBounds, computeVisualBounds, copyDerivedGlyphs, copyEffect, copyEffects, copyFill, copyFills, copyGeometryPaths, copyLayoutGrids, copyStroke, copyStrokes, copyStyleRun, copyStyleRuns, createDefaultNode, createDefaultSourceMetadata, createInstanceOverrideState, defaultStrokeAlign, degToRad, deleteInstanceOverride, deserializeInstanceOverrideState, effectOverflow, forEachInstanceOverride, geometryBlobBounds, geometryCommandCoordCount, getDefaultRenderColorSpace, getFillOkHCL, getInstanceOverride, getNodeOkHCLPayloads, getStrokeOkHCL, hasInstanceOverride, hasSameCopySource, intersectVisualBounds, markCopySource, mergeVectorNetworks, newStrokeGeometry, nodeVisualBounds, normalizeColor, normalizeVectorNetwork, okhclToRGBA, parseColor, parseDisplayableColor, parseOkHCLPayload, polygonVertices, radToDeg, remapInstanceOverrideState, resolveNodeFillColor, resolveNodeStrokeColor, resolveOkHCLForPreview, resolveRGBAForPreview, rgba255ToColor, rgbaToOkHCL, rotatePoint, rotatedBBox, rotatedCorners, scaleGeometryPaths, serializeInstanceOverrideState, serializeOkHCLPayload, setInstanceOverride, setNodeFillOkHCL, setNodeStrokeOkHCL, strokeOverflow, transformGeometryBlob, transformGeometryPaths, transformVectorNetwork, tryParseColor, unionVisualBounds, validateVectorNetwork, vectorNetworksEqual };
1661
-
1662
- //# sourceMappingURL=index.js.map