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

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 (423) hide show
  1. package/dist/behaviours/index.d.ts +3 -2
  2. package/dist/behaviours/index.js +2 -1
  3. package/dist/behaviours/kinds.d.ts.map +1 -1
  4. package/dist/behaviours/kinds.js +15 -8
  5. package/dist/behaviours/kinds.js.map +1 -1
  6. package/dist/behaviours/model.d.ts +2 -2
  7. package/dist/behaviours/model.d.ts.map +1 -1
  8. package/dist/behaviours/model.js.map +1 -1
  9. package/dist/behaviours/schema.d.ts +136 -1
  10. package/dist/behaviours/schema.d.ts.map +1 -1
  11. package/dist/behaviours/schema.js +17 -2
  12. package/dist/behaviours/schema.js.map +1 -1
  13. package/dist/behaviours/spec.d.ts.map +1 -1
  14. package/dist/behaviours/spec.js +4 -0
  15. package/dist/behaviours/spec.js.map +1 -1
  16. package/dist/behaviours/transition.d.ts +23 -0
  17. package/dist/behaviours/transition.d.ts.map +1 -0
  18. package/dist/behaviours/transition.js +36 -0
  19. package/dist/behaviours/transition.js.map +1 -0
  20. package/dist/checkpoint.d.ts.map +1 -1
  21. package/dist/checkpoint.js +2 -0
  22. package/dist/checkpoint.js.map +1 -1
  23. package/dist/color/index.d.ts +12 -9
  24. package/dist/color/index.d.ts.map +1 -1
  25. package/dist/color/index.js +15 -25
  26. package/dist/color/index.js.map +1 -1
  27. package/dist/color/management.d.ts +51 -23
  28. package/dist/color/management.d.ts.map +1 -1
  29. package/dist/color/management.js +154 -149
  30. package/dist/color/management.js.map +1 -1
  31. package/dist/color/okhcl.d.ts +28 -10
  32. package/dist/color/okhcl.d.ts.map +1 -1
  33. package/dist/color/okhcl.js +56 -40
  34. package/dist/color/okhcl.js.map +1 -1
  35. package/dist/color/schema.d.ts +6 -1
  36. package/dist/color/schema.d.ts.map +1 -1
  37. package/dist/color/schema.js +10 -1
  38. package/dist/color/schema.js.map +1 -1
  39. package/dist/constraints.d.ts.map +1 -1
  40. package/dist/constraints.js +2 -1
  41. package/dist/constraints.js.map +1 -1
  42. package/dist/copy.d.ts +7 -1
  43. package/dist/copy.d.ts.map +1 -1
  44. package/dist/copy.js +22 -1
  45. package/dist/copy.js.map +1 -1
  46. package/dist/corners.d.ts +3 -1
  47. package/dist/corners.d.ts.map +1 -1
  48. package/dist/corners.js +3 -1
  49. package/dist/corners.js.map +1 -1
  50. package/dist/css/grid.js +1 -1
  51. package/dist/css/index.d.ts +2 -1
  52. package/dist/css/index.js +3 -2
  53. package/dist/css/motion.d.ts +12 -0
  54. package/dist/css/motion.d.ts.map +1 -0
  55. package/dist/css/motion.js +60 -0
  56. package/dist/css/motion.js.map +1 -0
  57. package/dist/css/shadows.d.ts +4 -3
  58. package/dist/css/shadows.d.ts.map +1 -1
  59. package/dist/css/shadows.js +7 -6
  60. package/dist/css/shadows.js.map +1 -1
  61. package/dist/css/values.d.ts +3 -2
  62. package/dist/css/values.d.ts.map +1 -1
  63. package/dist/css/values.js +4 -4
  64. package/dist/css/values.js.map +1 -1
  65. package/dist/fields/index.d.ts +2 -2
  66. package/dist/fields/index.js +2 -2
  67. package/dist/fields/layout.d.ts +3 -1
  68. package/dist/fields/layout.d.ts.map +1 -1
  69. package/dist/fields/layout.js +9 -1
  70. package/dist/fields/layout.js.map +1 -1
  71. package/dist/figjam/palette.js +1 -1
  72. package/dist/font-style.d.ts.map +1 -1
  73. package/dist/font-style.js +7 -3
  74. package/dist/font-style.js.map +1 -1
  75. package/dist/generated/index.d.ts +6 -2
  76. package/dist/generated/index.d.ts.map +1 -1
  77. package/dist/generated/index.js +14 -4
  78. package/dist/generated/index.js.map +1 -1
  79. package/dist/geometry.d.ts +6 -1
  80. package/dist/geometry.d.ts.map +1 -1
  81. package/dist/geometry.js +10 -2
  82. package/dist/geometry.js.map +1 -1
  83. package/dist/graph.d.ts +29 -4
  84. package/dist/graph.d.ts.map +1 -1
  85. package/dist/graph.js +59 -9
  86. package/dist/graph.js.map +1 -1
  87. package/dist/group-bounds.d.ts +5 -2
  88. package/dist/group-bounds.d.ts.map +1 -1
  89. package/dist/group-bounds.js +38 -8
  90. package/dist/group-bounds.js.map +1 -1
  91. package/dist/hit-test.d.ts.map +1 -1
  92. package/dist/hit-test.js +19 -8
  93. package/dist/hit-test.js.map +1 -1
  94. package/dist/index.d.ts +2 -2
  95. package/dist/index.js +2 -2
  96. package/dist/instances/content-size.js +1 -1
  97. package/dist/instances/fields.d.ts +2 -2
  98. package/dist/instances/fields.d.ts.map +1 -1
  99. package/dist/instances/fields.js +2 -0
  100. package/dist/instances/fields.js.map +1 -1
  101. package/dist/instances/index.d.ts.map +1 -1
  102. package/dist/instances/index.js +50 -11
  103. package/dist/instances/index.js.map +1 -1
  104. package/dist/instances/sync.js +67 -7
  105. package/dist/instances/sync.js.map +1 -1
  106. package/dist/layout/flow.d.ts +16 -0
  107. package/dist/layout/flow.d.ts.map +1 -0
  108. package/dist/layout/flow.js +34 -0
  109. package/dist/layout/flow.js.map +1 -0
  110. package/dist/layout/index.d.ts +4 -3
  111. package/dist/layout/index.js +4 -3
  112. package/dist/layout/keywords.d.ts.map +1 -1
  113. package/dist/layout/keywords.js +7 -1
  114. package/dist/layout/keywords.js.map +1 -1
  115. package/dist/layout/sizing.d.ts +9 -1
  116. package/dist/layout/sizing.d.ts.map +1 -1
  117. package/dist/layout/sizing.js +17 -1
  118. package/dist/layout/sizing.js.map +1 -1
  119. package/dist/layout/spacing.d.ts +7 -1
  120. package/dist/layout/spacing.d.ts.map +1 -1
  121. package/dist/layout/spacing.js +10 -1
  122. package/dist/layout/spacing.js.map +1 -1
  123. package/dist/mesh/geometry.d.ts +83 -0
  124. package/dist/mesh/geometry.d.ts.map +1 -0
  125. package/dist/mesh/geometry.js +441 -0
  126. package/dist/mesh/geometry.js.map +1 -0
  127. package/dist/mesh/index.d.ts +4 -0
  128. package/dist/mesh/index.js +4 -0
  129. package/dist/mesh/model.d.ts +28 -0
  130. package/dist/mesh/model.d.ts.map +1 -0
  131. package/dist/mesh/model.js +40 -0
  132. package/dist/mesh/model.js.map +1 -0
  133. package/dist/mesh/schema.d.ts +191 -0
  134. package/dist/mesh/schema.d.ts.map +1 -0
  135. package/dist/mesh/schema.js +56 -0
  136. package/dist/mesh/schema.js.map +1 -0
  137. package/dist/mutation-impact.d.ts +2 -0
  138. package/dist/mutation-impact.d.ts.map +1 -1
  139. package/dist/mutation-impact.js +18 -7
  140. package/dist/mutation-impact.js.map +1 -1
  141. package/dist/node-defaults.d.ts +3 -1
  142. package/dist/node-defaults.d.ts.map +1 -1
  143. package/dist/node-defaults.js +22 -6
  144. package/dist/node-defaults.js.map +1 -1
  145. package/dist/paints/index.d.ts +5 -3
  146. package/dist/paints/index.js +5 -3
  147. package/dist/paints/pattern.d.ts +5 -1
  148. package/dist/paints/pattern.d.ts.map +1 -1
  149. package/dist/paints/pattern.js +33 -1
  150. package/dist/paints/pattern.js.map +1 -1
  151. package/dist/paints/shows.d.ts +4 -1
  152. package/dist/paints/shows.d.ts.map +1 -1
  153. package/dist/paints/shows.js +8 -1
  154. package/dist/paints/shows.js.map +1 -1
  155. package/dist/paints/solid.d.ts +11 -0
  156. package/dist/paints/solid.d.ts.map +1 -0
  157. package/dist/paints/solid.js +18 -0
  158. package/dist/paints/solid.js.map +1 -0
  159. package/dist/paints/stills.d.ts +74 -0
  160. package/dist/paints/stills.d.ts.map +1 -0
  161. package/dist/paints/stills.js +113 -0
  162. package/dist/paints/stills.js.map +1 -0
  163. package/dist/plugin-data/field.d.ts.map +1 -1
  164. package/dist/plugin-data/field.js +2 -0
  165. package/dist/plugin-data/field.js.map +1 -1
  166. package/dist/plugin-data/fields.d.ts +67 -0
  167. package/dist/plugin-data/fields.d.ts.map +1 -1
  168. package/dist/plugin-data/fields.js +12 -7
  169. package/dist/plugin-data/fields.js.map +1 -1
  170. package/dist/resize.d.ts +10 -3
  171. package/dist/resize.d.ts.map +1 -1
  172. package/dist/resize.js +34 -3
  173. package/dist/resize.js.map +1 -1
  174. package/dist/scaling/index.d.ts +2 -2
  175. package/dist/scaling/index.js +2 -2
  176. package/dist/scaling/node.d.ts +2 -1
  177. package/dist/scaling/node.d.ts.map +1 -1
  178. package/dist/scaling/node.js +27 -7
  179. package/dist/scaling/node.js.map +1 -1
  180. package/dist/shaders/index.d.ts +2 -3
  181. package/dist/shaders/index.js +2 -3
  182. package/dist/shaders/model.d.ts +3 -11
  183. package/dist/shaders/model.d.ts.map +1 -1
  184. package/dist/shaders/model.js +13 -36
  185. package/dist/shaders/model.js.map +1 -1
  186. package/dist/shaders/schema.d.ts +1 -1
  187. package/dist/shaders/schema.js +1 -1
  188. package/dist/shaders/schema.js.map +1 -1
  189. package/dist/shape-with-text/document.js +276 -0
  190. package/dist/shape-with-text/document.js.map +1 -0
  191. package/dist/shape-with-text/geometry.d.ts +13 -1
  192. package/dist/shape-with-text/geometry.d.ts.map +1 -1
  193. package/dist/shape-with-text/geometry.js +103 -41
  194. package/dist/shape-with-text/geometry.js.map +1 -1
  195. package/dist/shape-with-text/index.d.ts +2 -2
  196. package/dist/shape-with-text/index.js +2 -2
  197. package/dist/shared-style-index.d.ts +21 -0
  198. package/dist/shared-style-index.d.ts.map +1 -0
  199. package/dist/shared-style-index.js +72 -0
  200. package/dist/shared-style-index.js.map +1 -0
  201. package/dist/shared-styles.d.ts +3 -3
  202. package/dist/shared-styles.d.ts.map +1 -1
  203. package/dist/shared-styles.js +16 -7
  204. package/dist/shared-styles.js.map +1 -1
  205. package/dist/slides/drop.d.ts +32 -0
  206. package/dist/slides/drop.d.ts.map +1 -0
  207. package/dist/slides/drop.js +81 -0
  208. package/dist/slides/drop.js.map +1 -0
  209. package/dist/slides/index.d.ts +56 -0
  210. package/dist/slides/index.d.ts.map +1 -0
  211. package/dist/slides/index.js +134 -0
  212. package/dist/slides/index.js.map +1 -0
  213. package/dist/slides/motion.d.ts +55 -0
  214. package/dist/slides/motion.d.ts.map +1 -0
  215. package/dist/slides/motion.js +142 -0
  216. package/dist/slides/motion.js.map +1 -0
  217. package/dist/slides/playback.d.ts +59 -0
  218. package/dist/slides/playback.d.ts.map +1 -0
  219. package/dist/slides/playback.js +188 -0
  220. package/dist/slides/playback.js.map +1 -0
  221. package/dist/slides/types.d.ts +62 -0
  222. package/dist/slides/types.d.ts.map +1 -0
  223. package/dist/slides/types.js +39 -0
  224. package/dist/slides/types.js.map +1 -0
  225. package/dist/statuses/workflow.js +1 -1
  226. package/dist/text/direction.d.ts +6 -3
  227. package/dist/text/direction.d.ts.map +1 -1
  228. package/dist/text/direction.js +12 -12
  229. package/dist/text/direction.js.map +1 -1
  230. package/dist/text/index.d.ts +2 -1
  231. package/dist/text/index.js +3 -2
  232. package/dist/text/name.d.ts +22 -0
  233. package/dist/text/name.d.ts.map +1 -0
  234. package/dist/text/name.js +38 -0
  235. package/dist/text/name.js.map +1 -0
  236. package/dist/text/references.d.ts.map +1 -1
  237. package/dist/text/references.js +1 -2
  238. package/dist/text/references.js.map +1 -1
  239. package/dist/thumbnail.d.ts +23 -0
  240. package/dist/thumbnail.d.ts.map +1 -0
  241. package/dist/thumbnail.js +47 -0
  242. package/dist/thumbnail.js.map +1 -0
  243. package/dist/transfer/apply.d.ts.map +1 -1
  244. package/dist/transfer/apply.js +14 -3
  245. package/dist/transfer/apply.js.map +1 -1
  246. package/dist/transfer/copied.d.ts +6 -1
  247. package/dist/transfer/copied.d.ts.map +1 -1
  248. package/dist/transfer/copied.js +2 -2
  249. package/dist/transfer/copied.js.map +1 -1
  250. package/dist/transfer/dependencies.d.ts +4 -1
  251. package/dist/transfer/dependencies.d.ts.map +1 -1
  252. package/dist/transfer/dependencies.js +10 -1
  253. package/dist/transfer/dependencies.js.map +1 -1
  254. package/dist/transfer/history.js +2 -0
  255. package/dist/transfer/history.js.map +1 -1
  256. package/dist/transfer/identity.js +18 -3
  257. package/dist/transfer/identity.js.map +1 -1
  258. package/dist/transfer/index.d.ts +2 -1
  259. package/dist/transfer/index.js +4 -3
  260. package/dist/transfer/library.d.ts +45 -0
  261. package/dist/transfer/library.d.ts.map +1 -0
  262. package/dist/transfer/library.js +102 -0
  263. package/dist/transfer/library.js.map +1 -0
  264. package/dist/transfer/nodes.d.ts.map +1 -1
  265. package/dist/transfer/nodes.js +9 -0
  266. package/dist/transfer/nodes.js.map +1 -1
  267. package/dist/transfer/plan.d.ts +9 -0
  268. package/dist/transfer/plan.d.ts.map +1 -1
  269. package/dist/transfer/plan.js +51 -6
  270. package/dist/transfer/plan.js.map +1 -1
  271. package/dist/transfer/remove.js +7 -1
  272. package/dist/transfer/remove.js.map +1 -1
  273. package/dist/transfer/validation.js +8 -4
  274. package/dist/transfer/validation.js.map +1 -1
  275. package/dist/transfer/variables.d.ts.map +1 -1
  276. package/dist/transfer/variables.js +2 -1
  277. package/dist/transfer/variables.js.map +1 -1
  278. package/dist/types.d.ts +90 -12
  279. package/dist/types.d.ts.map +1 -1
  280. package/dist/types.js +33 -1
  281. package/dist/types.js.map +1 -1
  282. package/dist/variables/bindings.d.ts +11 -6
  283. package/dist/variables/bindings.d.ts.map +1 -1
  284. package/dist/variables/bindings.js +162 -38
  285. package/dist/variables/bindings.js.map +1 -1
  286. package/dist/variables/easing.d.ts +48 -0
  287. package/dist/variables/easing.d.ts.map +1 -0
  288. package/dist/variables/easing.js +321 -0
  289. package/dist/variables/easing.js.map +1 -0
  290. package/dist/variables/formula/index.d.ts +4 -2
  291. package/dist/variables/formula/index.d.ts.map +1 -1
  292. package/dist/variables/formula/index.js +26 -9
  293. package/dist/variables/formula/index.js.map +1 -1
  294. package/dist/variables/formula/parse.js +1 -1
  295. package/dist/variables/formula/schema.js +1 -1
  296. package/dist/variables/formula/signatures.d.ts +2 -2
  297. package/dist/variables/formula/signatures.d.ts.map +1 -1
  298. package/dist/variables/formula/signatures.js.map +1 -1
  299. package/dist/variables/formula/tree.d.ts +2 -2
  300. package/dist/variables/formula/tree.d.ts.map +1 -1
  301. package/dist/variables/formula/tree.js.map +1 -1
  302. package/dist/variables/index.d.ts +22 -5
  303. package/dist/variables/index.d.ts.map +1 -1
  304. package/dist/variables/index.js +67 -17
  305. package/dist/variables/index.js.map +1 -1
  306. package/dist/variables/lookup.js +1 -1
  307. package/dist/variables/lookup.js.map +1 -1
  308. package/dist/variables/motion.d.ts +46 -0
  309. package/dist/variables/motion.d.ts.map +1 -0
  310. package/dist/variables/motion.js +107 -0
  311. package/dist/variables/motion.js.map +1 -0
  312. package/dist/variables/paints.d.ts +10 -2
  313. package/dist/variables/paints.d.ts.map +1 -1
  314. package/dist/variables/paints.js +24 -10
  315. package/dist/variables/paints.js.map +1 -1
  316. package/dist/variables/resolution.d.ts.map +1 -1
  317. package/dist/variables/resolution.js +10 -9
  318. package/dist/variables/resolution.js.map +1 -1
  319. package/dist/variables/schema.d.ts +59 -1
  320. package/dist/variables/schema.d.ts.map +1 -1
  321. package/dist/variables/schema.js +36 -1
  322. package/dist/variables/schema.js.map +1 -1
  323. package/dist/variables/style-bindings.d.ts +23 -0
  324. package/dist/variables/style-bindings.d.ts.map +1 -0
  325. package/dist/variables/style-bindings.js +83 -0
  326. package/dist/variables/style-bindings.js.map +1 -0
  327. package/package.json +21 -2
  328. package/src/behaviours/index.ts +1 -0
  329. package/src/behaviours/kinds.ts +5 -1
  330. package/src/behaviours/model.ts +2 -2
  331. package/src/behaviours/schema.ts +19 -2
  332. package/src/behaviours/spec.ts +5 -0
  333. package/src/behaviours/transition.ts +46 -0
  334. package/src/checkpoint.ts +2 -0
  335. package/src/color/index.ts +15 -24
  336. package/src/color/management.ts +144 -168
  337. package/src/color/okhcl.ts +62 -43
  338. package/src/color/schema.ts +13 -0
  339. package/src/constraints.ts +2 -1
  340. package/src/copy.ts +29 -0
  341. package/src/corners.ts +3 -0
  342. package/src/css/index.ts +1 -0
  343. package/src/css/motion.ts +51 -0
  344. package/src/css/shadows.ts +7 -6
  345. package/src/css/values.ts +7 -3
  346. package/src/fields/layout.ts +9 -0
  347. package/src/font-style.ts +8 -3
  348. package/src/generated/index.ts +15 -3
  349. package/src/geometry.ts +13 -1
  350. package/src/graph.ts +72 -9
  351. package/src/group-bounds.ts +54 -13
  352. package/src/hit-test.ts +13 -8
  353. package/src/instances/fields.ts +2 -0
  354. package/src/instances/index.ts +71 -12
  355. package/src/instances/sync.ts +93 -11
  356. package/src/layout/flow.ts +34 -0
  357. package/src/layout/index.ts +1 -0
  358. package/src/layout/keywords.ts +7 -1
  359. package/src/layout/sizing.ts +30 -0
  360. package/src/layout/spacing.ts +12 -0
  361. package/src/mesh/geometry.ts +433 -0
  362. package/src/mesh/index.ts +3 -0
  363. package/src/mesh/model.ts +50 -0
  364. package/src/mesh/schema.ts +81 -0
  365. package/src/mutation-impact.ts +23 -7
  366. package/src/node-defaults.ts +22 -5
  367. package/src/paints/index.ts +2 -0
  368. package/src/paints/pattern.ts +55 -0
  369. package/src/paints/shows.ts +9 -0
  370. package/src/paints/solid.ts +10 -0
  371. package/src/paints/stills.ts +182 -0
  372. package/src/plugin-data/field.ts +3 -0
  373. package/src/plugin-data/fields.ts +15 -2
  374. package/src/resize.ts +32 -20
  375. package/src/scaling/index.ts +1 -1
  376. package/src/scaling/node.ts +43 -6
  377. package/src/shaders/index.ts +0 -1
  378. package/src/shaders/model.ts +19 -49
  379. package/src/shaders/schema.ts +1 -1
  380. package/src/shape-with-text/document.ts +175 -0
  381. package/src/shape-with-text/geometry.ts +99 -27
  382. package/src/shared-style-index.ts +106 -0
  383. package/src/shared-styles.ts +21 -14
  384. package/src/slides/drop.ts +94 -0
  385. package/src/slides/index.ts +125 -0
  386. package/src/slides/motion.ts +169 -0
  387. package/src/slides/playback.ts +200 -0
  388. package/src/slides/types.ts +94 -0
  389. package/src/text/direction.ts +13 -23
  390. package/src/text/index.ts +1 -0
  391. package/src/text/name.ts +39 -0
  392. package/src/text/references.ts +3 -3
  393. package/src/thumbnail.ts +52 -0
  394. package/src/transfer/apply.ts +16 -3
  395. package/src/transfer/copied.ts +7 -2
  396. package/src/transfer/dependencies.ts +10 -1
  397. package/src/transfer/history.ts +2 -0
  398. package/src/transfer/identity.ts +34 -2
  399. package/src/transfer/index.ts +6 -0
  400. package/src/transfer/library.ts +153 -0
  401. package/src/transfer/nodes.ts +20 -0
  402. package/src/transfer/plan.ts +96 -10
  403. package/src/transfer/remove.ts +6 -2
  404. package/src/transfer/validation.ts +15 -7
  405. package/src/transfer/variables.ts +8 -2
  406. package/src/types.ts +114 -10
  407. package/src/variables/bindings.ts +260 -36
  408. package/src/variables/easing.ts +282 -0
  409. package/src/variables/formula/index.ts +33 -14
  410. package/src/variables/formula/signatures.ts +6 -2
  411. package/src/variables/formula/tree.ts +3 -3
  412. package/src/variables/index.ts +90 -37
  413. package/src/variables/lookup.ts +1 -1
  414. package/src/variables/motion.ts +151 -0
  415. package/src/variables/paints.ts +29 -7
  416. package/src/variables/resolution.ts +11 -5
  417. package/src/variables/schema.ts +41 -0
  418. package/src/variables/style-bindings.ts +137 -0
  419. package/dist/shaders/still.d.ts +0 -18
  420. package/dist/shaders/still.d.ts.map +0 -1
  421. package/dist/shaders/still.js +0 -36
  422. package/dist/shaders/still.js.map +0 -1
  423. package/src/shaders/still.ts +0 -41
@@ -1 +1 @@
1
- {"version":3,"file":"fields.d.ts","names":[],"sources":["../../src/plugin-data/fields.ts"],"mappings":";;;;;;;UAsHiB;EACf,OAAO;EACP,cAAc;IAAiB;IAAa;;;;;;;;cAuCjC;;iBAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAkFG,kBAAkB,kBAAkB,oBAAoB"}
1
+ {"version":3,"file":"fields.d.ts","names":[],"sources":["../../src/plugin-data/fields.ts"],"mappings":";;;;;;;UAwHiB;EACf,OAAO;EACP,cAAc;IAAiB;IAAa;;;;;;;;cAuCjC;;iBAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA6FG,kBAAkB,kBAAkB,oBAAoB"}
@@ -1,3 +1,5 @@
1
+ import { exportColorProfileSchema } from "../color/schema.js";
2
+ import { MODE_ATTRIBUTE_PATTERN, TOKEN_UNITS } from "../types.js";
1
3
  import { jsonPluginDataField, textPluginDataField, withoutPluginData } from "./field.js";
2
4
  import { behaviourSchema } from "../behaviours/schema.js";
3
5
  import { commentThreadsSchema } from "../comments/schema.js";
@@ -5,9 +7,9 @@ import { isExportFormatId } from "../export-format.js";
5
7
  import { clampExportScale } from "../export-scale.js";
6
8
  import { FIG_COMPRESSIONS } from "../fig-compression.js";
7
9
  import { iconSchema, iconTintSchema } from "../icons/schema.js";
10
+ import { meshPaintSchema } from "../mesh/schema.js";
8
11
  import { shaderPaintSchema } from "../shaders/schema.js";
9
12
  import { nodeStatusSchema, statusWorkflowSchema } from "../statuses/schema.js";
10
- import { MODE_ATTRIBUTE_PATTERN, TOKEN_UNITS } from "../types.js";
11
13
  import * as v from "valibot";
12
14
  //#region src/plugin-data/fields.ts
13
15
  const DIRECTIONS = [
@@ -34,11 +36,7 @@ const exportSettingsSchema = v.array(v.pipe(v.object({
34
36
  })),
35
37
  contentsOnly: v.optional(v.boolean()),
36
38
  useAbsoluteBounds: v.optional(v.boolean()),
37
- colorProfile: v.optional(v.picklist([
38
- "DOCUMENT",
39
- "SRGB",
40
- "DISPLAY_P3_V4"
41
- ])),
39
+ colorProfile: v.optional(exportColorProfileSchema),
42
40
  svgOutlineText: v.optional(v.boolean()),
43
41
  svgIdAttribute: v.optional(v.boolean()),
44
42
  svgSimplifyStroke: v.optional(v.boolean())
@@ -130,6 +128,11 @@ const OPEN_PENCIL_PLUGIN_DATA = {
130
128
  enabledLibraries: jsonPluginDataField("enabledLibraries", "bookkeeping", enabledLibrariesSchema),
131
129
  /** The library this document publishes as, on the DOCUMENT node. */
132
130
  sourceLibraryPublication: jsonPluginDataField("sourceLibraryPublication", "bookkeeping", sourceLibraryPublicationSchema),
131
+ /**
132
+ * The layer chosen as the document's thumbnail, on the DOCUMENT node. Figma keeps its own
133
+ * choice outside the file, so a `.fig` carries only this one.
134
+ */
135
+ thumbnail: jsonPluginDataField("thumbnail", "bookkeeping", v.pipe(v.string(), v.nonEmpty(), v.maxLength(64))),
133
136
  /** Canvas comment threads, deleted ones included, on the DOCUMENT node. */
134
137
  comments: jsonPluginDataField("comments", "bookkeeping", commentThreadsSchema),
135
138
  /** The statuses layers can be in, on the DOCUMENT node. */
@@ -155,7 +158,9 @@ const OPEN_PENCIL_PLUGIN_DATA = {
155
158
  /** Which of an icon path's paints its icon's color sets, on each path the source drew in it. */
156
159
  iconTint: jsonPluginDataField("iconTint", "content", iconTintSchema),
157
160
  /** One entry per paint that draws a shader, matched to its image paint by the frame's hash. */
158
- shader: jsonPluginDataField("shader", "content", shaderPaintSchema)
161
+ shader: jsonPluginDataField("shader", "content", shaderPaintSchema),
162
+ /** One entry per paint that draws a mesh gradient, matched to its image paint by the frame's hash. */
163
+ mesh: jsonPluginDataField("mesh", "content", meshPaintSchema)
159
164
  };
160
165
  const NOT_CONTENT = Object.values(OPEN_PENCIL_PLUGIN_DATA).filter((field) => field.role !== "content");
161
166
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"fields.js","names":[],"sources":["../../src/plugin-data/fields.ts"],"sourcesContent":["import * as v from 'valibot'\n\nimport { behaviourSchema } from '../behaviours/schema'\nimport type { OkHCLPayload } from '../color/okhcl'\nimport { commentThreadsSchema } from '../comments/schema'\nimport { isExportFormatId, type ExportFormatId } from '../export-format'\nimport { clampExportScale } from '../export-scale'\nimport { FIG_COMPRESSIONS } from '../fig-compression'\nimport { iconSchema, iconTintSchema } from '../icons/schema'\nimport type { Rect } from '../primitives'\nimport { shaderPaintSchema } from '../shaders/schema'\nimport { nodeStatusSchema, statusWorkflowSchema } from '../statuses/schema'\nimport {\n MODE_ATTRIBUTE_PATTERN,\n TOKEN_UNITS,\n type EnabledLibraryBinding,\n type ExportSetting,\n type LayoutDirection,\n type LibraryAssetSource,\n type PluginDataEntry,\n type SourceLibraryPublication,\n type TextDirection,\n type TokenUnit\n} from '../types'\nimport {\n jsonPluginDataField,\n textPluginDataField,\n withoutPluginData,\n type PluginDataKey\n} from './field'\n\nconst DIRECTIONS = ['AUTO', 'LTR', 'RTL'] as const satisfies readonly (\n | TextDirection\n | LayoutDirection\n)[]\n\nconst textPathBoxSchema: v.GenericSchema<unknown, Rect> = v.pipe(\n v.object({ x: v.number(), y: v.number(), width: v.number(), height: v.number() }),\n v.check(\n ({ x, y, width, height }) => Number.isFinite(x + y + width + height) && width > 0 && height > 0\n )\n)\n\n/** String-valued entries of a JSON object; other entries are dropped, not rejected. */\nconst boundVariablesSchema = v.pipe(\n v.custom<Record<string, unknown>>(\n (value) => typeof value === 'object' && value !== null && !Array.isArray(value)\n ),\n v.transform((value) =>\n Object.fromEntries(\n Object.entries(value).filter(\n (entry): entry is [string, string] => typeof entry[1] === 'string'\n )\n )\n )\n)\n\n/** Every entry must be valid, or the whole value is ignored in favour of native settings. */\nconst exportSettingsSchema: v.GenericSchema<unknown, ExportSetting[]> = v.array(\n v.pipe(\n v.object({\n scale: v.pipe(v.number(), v.finite()),\n format: v.custom<ExportFormatId>(isExportFormatId),\n suffix: v.optional(v.string()),\n size: v.optional(\n v.object({\n type: v.picklist(['WIDTH', 'HEIGHT']),\n value: v.pipe(v.number(), v.finite())\n })\n ),\n contentsOnly: v.optional(v.boolean()),\n useAbsoluteBounds: v.optional(v.boolean()),\n colorProfile: v.optional(v.picklist(['DOCUMENT', 'SRGB', 'DISPLAY_P3_V4'])),\n svgOutlineText: v.optional(v.boolean()),\n svgIdAttribute: v.optional(v.boolean()),\n svgSimplifyStroke: v.optional(v.boolean())\n }),\n // Clamp at the file boundary: imported plugin data may carry a scale the UI never produces.\n v.transform((setting) => ({ ...setting, scale: clampExportScale(setting.scale) }))\n )\n)\n\nconst librarySourceSchema: v.GenericSchema<unknown, LibraryAssetSource> = v.pipe(\n v.object({\n identity: v.object({ libraryId: v.string(), assetKey: v.string(), revisionId: v.string() }),\n sourceNodeId: v.optional(v.unknown()),\n readOnly: v.optional(v.unknown())\n }),\n v.transform(({ identity, sourceNodeId, readOnly }) => ({\n identity,\n sourceNodeId: typeof sourceNodeId === 'string' ? sourceNodeId : null,\n readOnly: readOnly === true\n }))\n)\n\nconst enabledLibrarySchema = v.object({\n libraryId: v.string(),\n revisionId: v.string(),\n enabled: v.optional(v.unknown())\n})\n\n/** Invalid entries are skipped one by one, so one bad binding keeps the others. */\nconst enabledLibrariesSchema: v.GenericSchema<unknown, EnabledLibraryBinding[]> = v.pipe(\n v.array(v.unknown()),\n v.transform((items) =>\n items.flatMap((item) => {\n const parsed = v.safeParse(enabledLibrarySchema, item)\n if (!parsed.success) return []\n const { libraryId, revisionId, enabled } = parsed.output\n return [{ libraryId, revisionId, enabled: enabled === true }]\n })\n )\n)\n\n// Shape only. Whether a string is valid CSS is checked where it is written into a stylesheet.\nconst cssTextSchema = v.pipe(v.string(), v.trim(), v.nonEmpty(), v.maxLength(1000))\n\n/** Token fields Figma has no slot for, with mode ids as the file spells them. */\nexport interface StoredToken {\n unit?: TokenUnit\n expressions?: Record<string, { css: string; resolved?: number }>\n}\n\nconst tokenSchema: v.GenericSchema<unknown, StoredToken> = v.object({\n unit: v.optional(v.picklist(TOKEN_UNITS)),\n expressions: v.optional(\n v.record(\n v.string(),\n v.object({ css: cssTextSchema, resolved: v.optional(v.pipe(v.number(), v.finite())) })\n )\n )\n})\n\nconst okhclSchema: v.GenericSchema<unknown, OkHCLPayload> = v.object({\n version: v.literal(1),\n kind: v.picklist(['fill', 'stroke']),\n index: v.number(),\n color: v.object({\n h: v.number(),\n c: v.number(),\n l: v.number(),\n a: v.fallback(v.optional(v.number()), undefined)\n })\n})\n\nconst sourceLibraryPublicationSchema: v.GenericSchema<unknown, SourceLibraryPublication> = v.object(\n {\n libraryId: v.string(),\n revisionId: v.string(),\n name: v.string(),\n catalogSource: v.optional(v.string())\n }\n)\n\n/**\n * Every plugin-data entry OpenPencil writes under {@link OPEN_PENCIL_PLUGIN_ID}: state Figma's\n * format has no field for. Add a key here, never as a string elsewhere, so reading and writing\n * it share one schema.\n */\nexport const OPEN_PENCIL_PLUGIN_DATA = {\n /** A text node's direction, on TEXT nodes. */\n textDirection: textPluginDataField('textDirection', 'format', DIRECTIONS),\n /** An auto-layout frame's direction. */\n layoutDirection: textPluginDataField('layoutDirection', 'format', DIRECTIONS),\n /** Marks a component set Figma would read as a plain frame. */\n nodeType: textPluginDataField('nodeType', 'format', ['COMPONENT_SET']),\n /** Variable bindings by field path, including those Figma cannot store natively. */\n boundVariables: jsonPluginDataField('boundVariables', 'format', boundVariablesSchema),\n exportSettings: jsonPluginDataField('exportSettings', 'format', exportSettingsSchema),\n /** The node-local rect a TEXT_PATH layout maps onto, which Kiwi has no field for. */\n textPathBox: jsonPluginDataField('textPathBox', 'format', textPathBoxSchema),\n /** The library asset a node was inserted from. */\n librarySource: jsonPluginDataField('librarySource', 'bookkeeping', librarySourceSchema),\n /** The library source layer a library definition's layer copies, on every definition layer. */\n libraryLayer: jsonPluginDataField(\n 'libraryLayer',\n 'bookkeeping',\n v.pipe(v.string(), v.nonEmpty(), v.maxLength(1024))\n ),\n /**\n * The document root's id, on the DOCUMENT node, whose own GUID is always Figma's `0:0`; the\n * root keeps it across a save as every layer keeps its GUID.\n */\n documentId: jsonPluginDataField(\n 'documentId',\n 'bookkeeping',\n v.pipe(v.string(), v.nonEmpty(), v.maxLength(64))\n ),\n /** Libraries enabled for the document, on the DOCUMENT node. */\n enabledLibraries: jsonPluginDataField('enabledLibraries', 'bookkeeping', enabledLibrariesSchema),\n /** The library this document publishes as, on the DOCUMENT node. */\n sourceLibraryPublication: jsonPluginDataField(\n 'sourceLibraryPublication',\n 'bookkeeping',\n sourceLibraryPublicationSchema\n ),\n /** Canvas comment threads, deleted ones included, on the DOCUMENT node. */\n comments: jsonPluginDataField('comments', 'bookkeeping', commentThreadsSchema),\n /** The statuses layers can be in, on the DOCUMENT node. */\n statuses: jsonPluginDataField('statuses', 'bookkeeping', statusWorkflowSchema),\n /** How tightly the document's `.fig` data is compressed, on the DOCUMENT node. */\n figCompression: textPluginDataField('figCompression', 'bookkeeping', FIG_COMPRESSIONS),\n /** A layer's status, any state of the workflow; Figma's `sectionStatusInfo` knows only two. */\n status: jsonPluginDataField('status', 'format', nodeStatusSchema),\n /** Unit and CSS expressions, on each VARIABLE. */\n token: jsonPluginDataField('token', 'format', tokenSchema),\n /** Mode conditions by mode id, on each VARIABLE_SET. */\n modeConditions: jsonPluginDataField(\n 'modeConditions',\n 'format',\n v.record(v.string(), cssTextSchema)\n ),\n /** The attribute that switches manual modes, on each VARIABLE_SET. */\n modeAttribute: jsonPluginDataField(\n 'modeAttribute',\n 'format',\n v.pipe(v.string(), v.trim(), v.maxLength(100), v.regex(MODE_ATTRIBUTE_PATTERN))\n ),\n /** The library mode each mode of a copied collection came from, by the file's mode id. */\n libraryModes: jsonPluginDataField('libraryModes', 'format', v.record(v.string(), v.string())),\n /** One entry per paint picked in OkHCL, so the picker reopens on the same coordinates. */\n okhcl: jsonPluginDataField('okhcl', 'content', okhclSchema),\n /** How a main component or component set behaves as a control in preview. */\n behaviour: jsonPluginDataField('behaviour', 'content', behaviourSchema),\n /** The icon a frame draws, such as `lucide:home`, on the frame its paths are in. */\n icon: jsonPluginDataField('icon', 'content', iconSchema),\n /** Which of an icon path's paints its icon's color sets, on each path the source drew in it. */\n iconTint: jsonPluginDataField('iconTint', 'content', iconTintSchema),\n /** One entry per paint that draws a shader, matched to its image paint by the frame's hash. */\n shader: jsonPluginDataField('shader', 'content', shaderPaintSchema)\n} satisfies Record<string, PluginDataKey>\n\nconst NOT_CONTENT = Object.values(OPEN_PENCIL_PLUGIN_DATA).filter(\n (field) => field.role !== 'content'\n)\n\n/**\n * A node's plugin data that is part of its content, in a stable order: OpenPencil's content\n * fields and every other plugin's entries, which the node carries wherever it goes. Format\n * copies of node fields and bookkeeping are left out.\n */\nexport function contentPluginData(entries: readonly PluginDataEntry[]): PluginDataEntry[] {\n return withoutPluginData(entries, NOT_CONTENT).sort(\n (a, b) => a.pluginId.localeCompare(b.pluginId) || a.key.localeCompare(b.key)\n )\n}\n"],"mappings":";;;;;;;;;;;;AA+BA,MAAM,aAAa;CAAC;CAAQ;CAAO;AAAK;AAKxC,MAAM,oBAAoD,EAAE,KAC1D,EAAE,OAAO;CAAE,GAAG,EAAE,OAAO;CAAG,GAAG,EAAE,OAAO;CAAG,OAAO,EAAE,OAAO;CAAG,QAAQ,EAAE,OAAO;AAAE,CAAC,GAChF,EAAE,OACC,EAAE,GAAG,GAAG,OAAO,aAAa,OAAO,SAAS,IAAI,IAAI,QAAQ,MAAM,KAAK,QAAQ,KAAK,SAAS,CAChG,CACF;;AAGA,MAAM,uBAAuB,EAAE,KAC7B,EAAE,QACC,UAAU,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK,CAChF,GACA,EAAE,WAAW,UACX,OAAO,YACL,OAAO,QAAQ,KAAK,CAAC,CAAC,QACnB,UAAqC,OAAO,MAAM,OAAO,QAC5D,CACF,CACF,CACF;;AAGA,MAAM,uBAAkE,EAAE,MACxE,EAAE,KACA,EAAE,OAAO;CACP,OAAO,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC;CACpC,QAAQ,EAAE,OAAuB,gBAAgB;CACjD,QAAQ,EAAE,SAAS,EAAE,OAAO,CAAC;CAC7B,MAAM,EAAE,SACN,EAAE,OAAO;EACP,MAAM,EAAE,SAAS,CAAC,SAAS,QAAQ,CAAC;EACpC,OAAO,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC;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Ac,EAAE,QAAQ,KAAK,EAAE,IAAI,cAAc,EAAE,GAAG,CAC7E;AACF"}
1
+ {"version":3,"file":"fields.js","names":[],"sources":["../../src/plugin-data/fields.ts"],"sourcesContent":["import * as v from 'valibot'\n\nimport { behaviourSchema } from '../behaviours/schema'\nimport type { OkHCLPayload } from '../color/okhcl'\nimport { exportColorProfileSchema } from '../color/schema'\nimport { commentThreadsSchema } from '../comments/schema'\nimport { isExportFormatId, type ExportFormatId } from '../export-format'\nimport { clampExportScale } from '../export-scale'\nimport { FIG_COMPRESSIONS } from '../fig-compression'\nimport { iconSchema, iconTintSchema } from '../icons/schema'\nimport { meshPaintSchema } from '../mesh/schema'\nimport type { Rect } from '../primitives'\nimport { shaderPaintSchema } from '../shaders/schema'\nimport { nodeStatusSchema, statusWorkflowSchema } from '../statuses/schema'\nimport {\n MODE_ATTRIBUTE_PATTERN,\n TOKEN_UNITS,\n type EnabledLibraryBinding,\n type ExportSetting,\n type LayoutDirection,\n type LibraryAssetSource,\n type PluginDataEntry,\n type SourceLibraryPublication,\n type TextDirection,\n type TokenUnit\n} from '../types'\nimport {\n jsonPluginDataField,\n textPluginDataField,\n withoutPluginData,\n type PluginDataKey\n} from './field'\n\nconst DIRECTIONS = ['AUTO', 'LTR', 'RTL'] as const satisfies readonly (\n | TextDirection\n | LayoutDirection\n)[]\n\nconst textPathBoxSchema: v.GenericSchema<unknown, Rect> = v.pipe(\n v.object({ x: v.number(), y: v.number(), width: v.number(), height: v.number() }),\n v.check(\n ({ x, y, width, height }) => Number.isFinite(x + y + width + height) && width > 0 && height > 0\n )\n)\n\n/** String-valued entries of a JSON object; other entries are dropped, not rejected. */\nconst boundVariablesSchema = v.pipe(\n v.custom<Record<string, unknown>>(\n (value) => typeof value === 'object' && value !== null && !Array.isArray(value)\n ),\n v.transform((value) =>\n Object.fromEntries(\n Object.entries(value).filter(\n (entry): entry is [string, string] => typeof entry[1] === 'string'\n )\n )\n )\n)\n\n/** Every entry must be valid, or the whole value is ignored in favour of native settings. */\nconst exportSettingsSchema: v.GenericSchema<unknown, ExportSetting[]> = v.array(\n v.pipe(\n v.object({\n scale: v.pipe(v.number(), v.finite()),\n format: v.custom<ExportFormatId>(isExportFormatId),\n suffix: v.optional(v.string()),\n size: v.optional(\n v.object({\n type: v.picklist(['WIDTH', 'HEIGHT']),\n value: v.pipe(v.number(), v.finite())\n })\n ),\n contentsOnly: v.optional(v.boolean()),\n useAbsoluteBounds: v.optional(v.boolean()),\n colorProfile: v.optional(exportColorProfileSchema),\n svgOutlineText: v.optional(v.boolean()),\n svgIdAttribute: v.optional(v.boolean()),\n svgSimplifyStroke: v.optional(v.boolean())\n }),\n // Clamp at the file boundary: imported plugin data may carry a scale the UI never produces.\n v.transform((setting) => ({ ...setting, scale: clampExportScale(setting.scale) }))\n )\n)\n\nconst librarySourceSchema: v.GenericSchema<unknown, LibraryAssetSource> = v.pipe(\n v.object({\n identity: v.object({ libraryId: v.string(), assetKey: v.string(), revisionId: v.string() }),\n sourceNodeId: v.optional(v.unknown()),\n readOnly: v.optional(v.unknown())\n }),\n v.transform(({ identity, sourceNodeId, readOnly }) => ({\n identity,\n sourceNodeId: typeof sourceNodeId === 'string' ? sourceNodeId : null,\n readOnly: readOnly === true\n }))\n)\n\nconst enabledLibrarySchema = v.object({\n libraryId: v.string(),\n revisionId: v.string(),\n enabled: v.optional(v.unknown())\n})\n\n/** Invalid entries are skipped one by one, so one bad binding keeps the others. */\nconst enabledLibrariesSchema: v.GenericSchema<unknown, EnabledLibraryBinding[]> = v.pipe(\n v.array(v.unknown()),\n v.transform((items) =>\n items.flatMap((item) => {\n const parsed = v.safeParse(enabledLibrarySchema, item)\n if (!parsed.success) return []\n const { libraryId, revisionId, enabled } = parsed.output\n return [{ libraryId, revisionId, enabled: enabled === true }]\n })\n )\n)\n\n// Shape only. Whether a string is valid CSS is checked where it is written into a stylesheet.\nconst cssTextSchema = v.pipe(v.string(), v.trim(), v.nonEmpty(), v.maxLength(1000))\n\n/** Token fields Figma has no slot for, with mode ids as the file spells them. */\nexport interface StoredToken {\n unit?: TokenUnit\n expressions?: Record<string, { css: string; resolved?: number }>\n}\n\nconst tokenSchema: v.GenericSchema<unknown, StoredToken> = v.object({\n unit: v.optional(v.picklist(TOKEN_UNITS)),\n expressions: v.optional(\n v.record(\n v.string(),\n v.object({ css: cssTextSchema, resolved: v.optional(v.pipe(v.number(), v.finite())) })\n )\n )\n})\n\nconst okhclSchema: v.GenericSchema<unknown, OkHCLPayload> = v.object({\n version: v.literal(1),\n kind: v.picklist(['fill', 'stroke']),\n index: v.number(),\n color: v.object({\n h: v.number(),\n c: v.number(),\n l: v.number(),\n a: v.fallback(v.optional(v.number()), undefined)\n })\n})\n\nconst sourceLibraryPublicationSchema: v.GenericSchema<unknown, SourceLibraryPublication> = v.object(\n {\n libraryId: v.string(),\n revisionId: v.string(),\n name: v.string(),\n catalogSource: v.optional(v.string())\n }\n)\n\n/**\n * Every plugin-data entry OpenPencil writes under {@link OPEN_PENCIL_PLUGIN_ID}: state Figma's\n * format has no field for. Add a key here, never as a string elsewhere, so reading and writing\n * it share one schema.\n */\nexport const OPEN_PENCIL_PLUGIN_DATA = {\n /** A text node's direction, on TEXT nodes. */\n textDirection: textPluginDataField('textDirection', 'format', DIRECTIONS),\n /** An auto-layout frame's direction. */\n layoutDirection: textPluginDataField('layoutDirection', 'format', DIRECTIONS),\n /** Marks a component set Figma would read as a plain frame. */\n nodeType: textPluginDataField('nodeType', 'format', ['COMPONENT_SET']),\n /** Variable bindings by field path, including those Figma cannot store natively. */\n boundVariables: jsonPluginDataField('boundVariables', 'format', boundVariablesSchema),\n exportSettings: jsonPluginDataField('exportSettings', 'format', exportSettingsSchema),\n /** The node-local rect a TEXT_PATH layout maps onto, which Kiwi has no field for. */\n textPathBox: jsonPluginDataField('textPathBox', 'format', textPathBoxSchema),\n /** The library asset a node was inserted from. */\n librarySource: jsonPluginDataField('librarySource', 'bookkeeping', librarySourceSchema),\n /** The library source layer a library definition's layer copies, on every definition layer. */\n libraryLayer: jsonPluginDataField(\n 'libraryLayer',\n 'bookkeeping',\n v.pipe(v.string(), v.nonEmpty(), v.maxLength(1024))\n ),\n /**\n * The document root's id, on the DOCUMENT node, whose own GUID is always Figma's `0:0`; the\n * root keeps it across a save as every layer keeps its GUID.\n */\n documentId: jsonPluginDataField(\n 'documentId',\n 'bookkeeping',\n v.pipe(v.string(), v.nonEmpty(), v.maxLength(64))\n ),\n /** Libraries enabled for the document, on the DOCUMENT node. */\n enabledLibraries: jsonPluginDataField('enabledLibraries', 'bookkeeping', enabledLibrariesSchema),\n /** The library this document publishes as, on the DOCUMENT node. */\n sourceLibraryPublication: jsonPluginDataField(\n 'sourceLibraryPublication',\n 'bookkeeping',\n sourceLibraryPublicationSchema\n ),\n /**\n * The layer chosen as the document's thumbnail, on the DOCUMENT node. Figma keeps its own\n * choice outside the file, so a `.fig` carries only this one.\n */\n thumbnail: jsonPluginDataField(\n 'thumbnail',\n 'bookkeeping',\n v.pipe(v.string(), v.nonEmpty(), v.maxLength(64))\n ),\n /** Canvas comment threads, deleted ones included, on the DOCUMENT node. */\n comments: jsonPluginDataField('comments', 'bookkeeping', commentThreadsSchema),\n /** The statuses layers can be in, on the DOCUMENT node. */\n statuses: jsonPluginDataField('statuses', 'bookkeeping', statusWorkflowSchema),\n /** How tightly the document's `.fig` data is compressed, on the DOCUMENT node. */\n figCompression: textPluginDataField('figCompression', 'bookkeeping', FIG_COMPRESSIONS),\n /** A layer's status, any state of the workflow; Figma's `sectionStatusInfo` knows only two. */\n status: jsonPluginDataField('status', 'format', nodeStatusSchema),\n /** Unit and CSS expressions, on each VARIABLE. */\n token: jsonPluginDataField('token', 'format', tokenSchema),\n /** Mode conditions by mode id, on each VARIABLE_SET. */\n modeConditions: jsonPluginDataField(\n 'modeConditions',\n 'format',\n v.record(v.string(), cssTextSchema)\n ),\n /** The attribute that switches manual modes, on each VARIABLE_SET. */\n modeAttribute: jsonPluginDataField(\n 'modeAttribute',\n 'format',\n v.pipe(v.string(), v.trim(), v.maxLength(100), v.regex(MODE_ATTRIBUTE_PATTERN))\n ),\n /** The library mode each mode of a copied collection came from, by the file's mode id. */\n libraryModes: jsonPluginDataField('libraryModes', 'format', v.record(v.string(), v.string())),\n /** One entry per paint picked in OkHCL, so the picker reopens on the same coordinates. */\n okhcl: jsonPluginDataField('okhcl', 'content', okhclSchema),\n /** How a main component or component set behaves as a control in preview. */\n behaviour: jsonPluginDataField('behaviour', 'content', behaviourSchema),\n /** The icon a frame draws, such as `lucide:home`, on the frame its paths are in. */\n icon: jsonPluginDataField('icon', 'content', iconSchema),\n /** Which of an icon path's paints its icon's color sets, on each path the source drew in it. */\n iconTint: jsonPluginDataField('iconTint', 'content', iconTintSchema),\n /** One entry per paint that draws a shader, matched to its image paint by the frame's hash. */\n shader: jsonPluginDataField('shader', 'content', shaderPaintSchema),\n /** One entry per paint that draws a mesh gradient, matched to its image paint by the frame's hash. */\n mesh: jsonPluginDataField('mesh', 'content', meshPaintSchema)\n} satisfies Record<string, PluginDataKey>\n\nconst NOT_CONTENT = Object.values(OPEN_PENCIL_PLUGIN_DATA).filter(\n (field) => field.role !== 'content'\n)\n\n/**\n * A node's plugin data that is part of its content, in a stable order: OpenPencil's content\n * fields and every other plugin's entries, which the node carries wherever it goes. Format\n * copies of node fields and bookkeeping are left out.\n */\nexport function contentPluginData(entries: readonly PluginDataEntry[]): PluginDataEntry[] {\n return withoutPluginData(entries, NOT_CONTENT).sort(\n (a, b) => a.pluginId.localeCompare(b.pluginId) || a.key.localeCompare(b.key)\n )\n}\n"],"mappings":";;;;;;;;;;;;;;AAiCA,MAAM,aAAa;CAAC;CAAQ;CAAO;AAAK;AAKxC,MAAM,oBAAoD,EAAE,KAC1D,EAAE,OAAO;CAAE,GAAG,EAAE,OAAO;CAAG,GAAG,EAAE,OAAO;CAAG,OAAO,EAAE,OAAO;CAAG,QAAQ,EAAE,OAAO;AAAE,CAAC,GAChF,EAAE,OACC,EAAE,GAAG,GAAG,OAA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U,WAAW;;CAEzD,gBAAgB,oBACd,kBACA,UACA,EAAE,OAAO,EAAE,OAAO,GAAG,aAAa,CACpC;;CAEA,eAAe,oBACb,iBACA,UACA,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,KAAK,GAAG,EAAE,UAAU,GAAG,GAAG,EAAE,MAAM,sBAAsB,CAAC,CAChF;;CAEA,cAAc,oBAAoB,gBAAgB,UAAU,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,CAAC;;CAE5F,OAAO,oBAAoB,SAAS,WAAW,WAAW;;CAE1D,WAAW,oBAAoB,aAAa,WAAW,eAAe;;CAEtE,MAAM,oBAAoB,QAAQ,WAAW,UAAU;;CAEvD,UAAU,oBAAoB,YAAY,WAAW,cAAc;;CAEnE,QAAQ,oBAAoB,UAAU,WAAW,iBAAiB;;CAElE,MAAM,oBAAoB,QAAQ,WAAW,eAAe;AAC9D;AAEA,MAAM,cAAc,OAAO,OAAO,uBAAuB,CAAC,CAAC,QACxD,UAAU,MAAM,SAAS,SAC5B;;;;;;AAOA,SAAgB,kBAAkB,SAAwD;CACxF,OAAO,kBAAkB,SAAS,WAAW,CAAC,CAAC,MAC5C,GAAG,MAAM,EAAE,SAAS,cAAc,EAAE,QAAQ,KAAK,EAAE,IAAI,cAAc,EAAE,GAAG,CAC7E;AACF"}
package/dist/resize.d.ts CHANGED
@@ -7,7 +7,8 @@ import { ConstraintType, SceneNode, VectorNetwork } from "./types.js";
7
7
  * geometry that must scale with the node, and textPathBox is the layout box the
8
8
  * glyphs were reflowed against.
9
9
  */
10
- type ResizeSnapshot = Pick<SceneNode, 'type' | 'x' | 'y' | 'width' | 'height' | 'flipX' | 'flipY' | 'vectorNetwork' | 'fillGeometry' | 'strokeGeometry' | 'derivedTextGlyphs' | 'strokes' | 'textPathData' | 'textPathBox'>;
10
+ declare const RESIZE_SNAPSHOT_FIELDS: readonly ["type", "x", "y", "width", "height", "flipX", "flipY", "vectorNetwork", "fillGeometry", "strokeGeometry", "derivedTextGlyphs", "strokes", "textPathData", "textPathBox"];
11
+ type ResizeSnapshot = Pick<SceneNode, (typeof RESIZE_SNAPSHOT_FIELDS)[number]>;
11
12
  interface ResizeGraph {
12
13
  readonly rootId: string;
13
14
  getNode(id: string): SceneNode | undefined;
@@ -35,7 +36,13 @@ declare function createResizeSnapshot(node: SceneNode): ResizeSnapshot;
35
36
  * OUTSIDE outlines look massively thick (DomeSticker resize bug).
36
37
  */
37
38
  declare function scaledGeometryChanges(orig: Pick<ResizeSnapshot, 'type' | 'vectorNetwork' | 'fillGeometry' | 'strokeGeometry' | 'derivedTextGlyphs' | 'strokes' | 'textPathData' | 'textPathBox'>, origWidth: number, origHeight: number, width: number, height: number): Partial<SceneNode>;
38
- declare function collectResizeDescendants(graph: ResizeGraph, rootId: string): Map<string, ResizeSnapshot> | null;
39
+ /**
40
+ * A node's resize state holding its own geometry rather than copies of it. It stays the state the
41
+ * resize began from only while nothing edits that geometry in place, as a resize plan does not:
42
+ * it writes new paths and outlines.
43
+ */
44
+ declare function sharedResizeSnapshot(node: SceneNode): ResizeSnapshot;
45
+ declare function collectResizeDescendants(graph: ResizeGraph, rootId: string, snapshot?: (node: SceneNode) => ResizeSnapshot): Map<string, ResizeSnapshot> | null;
39
46
  /**
40
47
  * The flips a child takes when its constraints place it from `from`, written only where they
41
48
  * differ from the ones it has now, so a drag that crosses back undoes its own turn.
@@ -48,5 +55,5 @@ type Size = Pick<Rect, 'width' | 'height'>;
48
55
  */
49
56
  declare function computeConstrainedResizeChanges(graph: ResizeGraph, rootId: string, rootBefore: Size, rootAfter: Size, originals: ReadonlyMap<string, ResizeSnapshot>): Map<string, Partial<SceneNode>>;
50
57
  //#endregion
51
- export { ConstrainedRect, ResizeSnapshot, collectResizeDescendants, computeConstrainedResizeChanges, constrainedChildRect, createResizeSnapshot, flipChanges, resizedChildRect, scaleVectorNetworkForResize, scaledChildRect, scaledGeometryChanges };
58
+ export { ConstrainedRect, ResizeSnapshot, collectResizeDescendants, computeConstrainedResizeChanges, constrainedChildRect, createResizeSnapshot, flipChanges, resizedChildRect, scaleVectorNetworkForResize, scaledChildRect, scaledGeometryChanges, sharedResizeSnapshot };
52
59
  //# sourceMappingURL=resize.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"resize.d.ts","names":[],"sources":["../src/resize.ts"],"mappings":";;;;;;;;;KAwBY,iBAAiB,KAC3B;UAiBQ;WACC;EACT,QAAQ,aAAa;;;KAeX,kBAAkB;EAAS;EAAkB;;;iBAkDzC,iBACd,QAAQ,MACR,MAAM,KAAK,2BACX,YAAY,gBACZ,UAAU,iBACT;;;;;iBA4Ba,qBACd,OAAO,MACP,cAAc,KAAK,2BACnB,aAAa,KAAK,2BAClB,YAAY,gBACZ,UAAU,gBACV,8BACC;iBAca,gBACd,OAAO,MACP,cAAc,KAAK,2BACnB,aAAa,KAAK,4BACjB;iBASa,4BACd,eAAe,sBACf,uBACA,wBACA,eACA,iBACC;;iBA6Ba,qBAAqB,MAAM,YAAY;;;;;;;iBAoDvC,sBACd,MAAM,KACJ,kJAUF,mBACA,oBACA,eACA,iBACC,QAAQ;iBAoFK,yBACd,OAAO,aACP,iBACC,YAAY;;;;;iBAwBC,YACd,MAAM,KAAK,+BACX,SAAS,KAAK,+BACd,kBACA,mBACC,QAAQ,KAAK;KASX,OAAO,KAAK;;;;;iBAmJD,gCACd,OAAO,aACP,gBACA,YAAY,MACZ,WAAW,MACX,WAAW,oBAAoB,kBAC9B,YAAY,QAAQ"}
1
+ {"version":3,"file":"resize.d.ts","names":[],"sources":["../src/resize.ts"],"mappings":";;;;;;;;;cA0BM;KAiBM,iBAAiB,KAAK,mBAAmB;UAC3C;WACC;EACT,QAAQ,aAAa;;;KAeX,kBAAkB;EAAS;EAAkB;;;iBAkDzC,iBACd,QAAQ,MACR,MAAM,KAAK,2BACX,YAAY,gBACZ,UAAU,iBACT;;;;;iBA4Ba,qBACd,OAAO,MACP,cAAc,KAAK,2BACnB,aAAa,KAAK,2BAClB,YAAY,gBACZ,UAAU,gBACV,8BACC;iBAca,gBACd,OAAO,MACP,cAAc,KAAK,2BACnB,aAAa,KAAK,4BACjB;iBASa,4BACd,eAAe,sBACf,uBACA,wBACA,eACA,iBACC;;iBA6Ba,qBAAqB,MAAM,YAAY;;;;;;;iBAoDvC,sBACd,MAAM,KACJ,kJAUF,mBACA,oBACA,eACA,iBACC,QAAQ;;;;;;iBAyFK,qBAAqB,MAAM,YAAY;iBAIvC,yBACd,OAAO,aACP,gBACA,YAAW,MAAM,cAAc,iBAC9B,YAAY;;;;;iBAwBC,YACd,MAAM,KAAK,+BACX,SAAS,KAAK,+BACd,kBACA,mBACC,QAAQ,KAAK;KASX,OAAO,KAAK;;;;;iBAmJD,gCACd,OAAO,aACP,gBACA,YAAY,MACZ,WAAW,MACX,WAAW,oBAAoB,kBAC9B,YAAY,QAAQ"}
package/dist/resize.js CHANGED
@@ -6,8 +6,31 @@ import { CONSTRAINT_PARENT_TYPES } from "./constraints.js";
6
6
  import { groupFitChanges } from "./group-bounds.js";
7
7
  import { enforcedAspectRatio } from "./layout/aspect-ratio.js";
8
8
  import { followsPath } from "./text/path.js";
9
+ import { pick } from "es-toolkit/object";
9
10
  //#region src/resize.ts
10
11
  /**
12
+ * Drag-start state a live resize re-scales from. Path text needs more than the
13
+ * layout rect: its OUTSIDE stroke silhouettes and glyph outlines are baked
14
+ * geometry that must scale with the node, and textPathBox is the layout box the
15
+ * glyphs were reflowed against.
16
+ */
17
+ const RESIZE_SNAPSHOT_FIELDS = [
18
+ "type",
19
+ "x",
20
+ "y",
21
+ "width",
22
+ "height",
23
+ "flipX",
24
+ "flipY",
25
+ "vectorNetwork",
26
+ "fillGeometry",
27
+ "strokeGeometry",
28
+ "derivedTextGlyphs",
29
+ "strokes",
30
+ "textPathData",
31
+ "textPathBox"
32
+ ];
33
+ /**
11
34
  * Containers whose resize moves their children: the constraint parents, and groups and booleans,
12
35
  * which scale theirs.
13
36
  */
@@ -253,7 +276,15 @@ function constrainedGeometryChanges(orig, current, box) {
253
276
  if (scalesGeometry(orig, box)) return scaledGeometryChanges(orig, orig.width, orig.height, box.width, box.height);
254
277
  return scalesGeometry(orig, current) ? snapshotGeometry(orig) : {};
255
278
  }
256
- function collectResizeDescendants(graph, rootId) {
279
+ /**
280
+ * A node's resize state holding its own geometry rather than copies of it. It stays the state the
281
+ * resize began from only while nothing edits that geometry in place, as a resize plan does not:
282
+ * it writes new paths and outlines.
283
+ */
284
+ function sharedResizeSnapshot(node) {
285
+ return pick(node, RESIZE_SNAPSHOT_FIELDS);
286
+ }
287
+ function collectResizeDescendants(graph, rootId, snapshot = createResizeSnapshot) {
257
288
  const root = graph.getNode(rootId);
258
289
  if (!root || !CONSTRAINT_CONTAINER_TYPES.has(root.type)) return null;
259
290
  const snapshots = /* @__PURE__ */ new Map();
@@ -263,7 +294,7 @@ function collectResizeDescendants(graph, rootId) {
263
294
  for (const childId of parent.childIds) {
264
295
  const child = graph.getNode(childId);
265
296
  if (!child) continue;
266
- snapshots.set(childId, createResizeSnapshot(child));
297
+ snapshots.set(childId, snapshot(child));
267
298
  collect(childId);
268
299
  }
269
300
  };
@@ -416,6 +447,6 @@ function computeConstrainedResizeChanges(graph, rootId, rootBefore, rootAfter, o
416
447
  return plan.changes;
417
448
  }
418
449
  //#endregion
419
- export { collectResizeDescendants, computeConstrainedResizeChanges, constrainedChildRect, createResizeSnapshot, flipChanges, resizedChildRect, scaleVectorNetworkForResize, scaledChildRect, scaledGeometryChanges };
450
+ export { collectResizeDescendants, computeConstrainedResizeChanges, constrainedChildRect, createResizeSnapshot, flipChanges, resizedChildRect, scaleVectorNetworkForResize, scaledChildRect, scaledGeometryChanges, sharedResizeSnapshot };
420
451
 
421
452
  //# sourceMappingURL=resize.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"resize.js","names":[],"sources":["../src/resize.ts"],"sourcesContent":["import { CONSTRAINT_PARENT_TYPES } from './constraints'\nimport { getNodeLocalMatrix } from './coordinate'\nimport {\n cloneVectorNetwork,\n copyDerivedGlyphs,\n copyGeometryPaths,\n copyStroke,\n copyStrokes,\n scaleGeometryPaths\n} from './copy'\nimport { groupFitChanges } from './group-bounds'\nimport { enforcedAspectRatio } from './layout/aspect-ratio'\nimport Matrix, { type Mat3 } from './matrix'\nimport { FITTED_CONTAINER_TYPES } from './node-defaults'\nimport type { Rect } from './primitives'\nimport { followsPath } from './text/path'\nimport type { ConstraintType, DerivedTextGlyph, SceneNode, Stroke, VectorNetwork } from './types'\n\n/**\n * Drag-start state a live resize re-scales from. Path text needs more than the\n * layout rect: its OUTSIDE stroke silhouettes and glyph outlines are baked\n * geometry that must scale with the node, and textPathBox is the layout box the\n * glyphs were reflowed against.\n */\nexport type ResizeSnapshot = Pick<\n SceneNode,\n | 'type'\n | 'x'\n | 'y'\n | 'width'\n | 'height'\n | 'flipX'\n | 'flipY'\n | 'vectorNetwork'\n | 'fillGeometry'\n | 'strokeGeometry'\n | 'derivedTextGlyphs'\n | 'strokes'\n | 'textPathData'\n | 'textPathBox'\n>\n\ninterface ResizeGraph {\n readonly rootId: string\n getNode(id: string): SceneNode | undefined\n}\n\n/**\n * Containers whose resize moves their children: the constraint parents, and groups and booleans,\n * which scale theirs.\n */\nconst CONSTRAINT_CONTAINER_TYPES = new Set<SceneNode['type']>([\n ...CONSTRAINT_PARENT_TYPES,\n ...FITTED_CONTAINER_TYPES\n])\n\ntype AxisPlacement = { position: number; size: number; flipped?: boolean }\n\n/** A child's box after its parent resizes, and the axes on which it turned over. */\nexport type ConstrainedRect = Rect & { flipsX?: boolean; flipsY?: boolean }\n\n/**\n * Where a constraint places a child on one axis when its parent goes from `parentBefore` to\n * `parentAfter`, as Figma does (live-measured, #1060, #1816): Right and Left & right move or grow\n * it by the change in the parent's size rounded to whole pixels, Center by the change in its\n * rounded half, and Scale by the exact ratio. The child's own box is never rounded, so a resize\n * to the same size changes nothing. Left & right that would leave no size keeps the axis as it\n * was; past zero, the child turns over and its box runs back from the edge it was pinned to, as\n * the layer is mirrored in Figma.\n */\nfunction constrainedAxis(\n position: number,\n size: number,\n parentBefore: number,\n parentAfter: number,\n constraint: ConstraintType\n): AxisPlacement {\n const delta = Math.round(parentAfter) - Math.round(parentBefore)\n if (constraint === 'MAX') return { position: position + delta, size }\n if (constraint === 'CENTER') {\n return { position: position + Math.round(parentAfter / 2) - Math.round(parentBefore / 2), size }\n }\n if (constraint === 'STRETCH') {\n const stretched = size + delta\n if (stretched === 0) return { position, size }\n if (stretched > 0) return { position, size: stretched }\n return { position: position + stretched, size: -stretched, flipped: true }\n }\n if (constraint === 'SCALE' && parentBefore > 0) {\n const scale = parentAfter / parentBefore\n return { position: position * scale, size: size * scale }\n }\n return { position, size }\n}\n\nconst FLEXIBLE_CONSTRAINTS: ReadonlySet<ConstraintType> = new Set(['STRETCH', 'SCALE'])\n\n/** The axis at `size`, keeping the edge or centre its constraint pins where it was placed. */\nfunction resizedInPlace(\n placed: AxisPlacement,\n size: number,\n constraint: ConstraintType\n): AxisPlacement {\n if (constraint === 'MAX') return { position: placed.position + placed.size - size, size }\n if (constraint === 'CENTER') return { position: placed.position + (placed.size - size) / 2, size }\n return { position: placed.position, size }\n}\n\n/** Keep a placed box's constrained edges or center when its content determines its size. */\nexport function resizedChildRect(\n placed: Rect,\n size: Pick<Rect, 'width' | 'height'>,\n horizontal: ConstraintType,\n vertical: ConstraintType\n): Rect {\n const x = resizedInPlace({ position: placed.x, size: placed.width }, size.width, horizontal)\n const y = resizedInPlace({ position: placed.y, size: placed.height }, size.height, vertical)\n return { x: x.position, y: y.position, width: x.size, height: y.size }\n}\n\n/**\n * A locked aspect ratio holds when exactly one axis follows the parent, as in Figma: that axis\n * sizes the other. With both axes following the parent, or neither, the ratio gives way.\n */\nfunction keepLockedRatio(\n x: AxisPlacement,\n y: AxisPlacement,\n horizontal: ConstraintType,\n vertical: ConstraintType,\n aspectRatio: number | null\n): { x: AxisPlacement; y: AxisPlacement } {\n const flexibleX = FLEXIBLE_CONSTRAINTS.has(horizontal)\n if (aspectRatio === null || flexibleX === FLEXIBLE_CONSTRAINTS.has(vertical)) return { x, y }\n return flexibleX\n ? { x, y: resizedInPlace(y, x.size / aspectRatio, vertical) }\n : { x: resizedInPlace(x, y.size * aspectRatio, horizontal), y }\n}\n\n/**\n * A child's box after its parent resizes, by a handle, `resize()`, layout, or an instance taking\n * another size than its component, keeping a locked aspect ratio as Figma does.\n */\nexport function constrainedChildRect(\n child: Rect,\n parentBefore: Pick<Rect, 'width' | 'height'>,\n parentAfter: Pick<Rect, 'width' | 'height'>,\n horizontal: ConstraintType,\n vertical: ConstraintType,\n aspectRatio: number | null = null\n): ConstrainedRect {\n const { x, y } = keepLockedRatio(\n constrainedAxis(child.x, child.width, parentBefore.width, parentAfter.width, horizontal),\n constrainedAxis(child.y, child.height, parentBefore.height, parentAfter.height, vertical),\n horizontal,\n vertical,\n aspectRatio\n )\n const rect: ConstrainedRect = { x: x.position, y: y.position, width: x.size, height: y.size }\n if (x.flipped) rect.flipsX = true\n if (y.flipped) rect.flipsY = true\n return rect\n}\n\nexport function scaledChildRect(\n child: Rect,\n parentBefore: Pick<Rect, 'width' | 'height'>,\n parentAfter: Pick<Rect, 'width' | 'height'>\n): Rect {\n return constrainedChildRect(child, parentBefore, parentAfter, 'SCALE', 'SCALE')\n}\n\n/** How much a side grows; a flat side, as a straight line's, has nothing to scale along it. */\nfunction sideScale(original: number, size: number): number {\n return original > 0 ? size / original : 1\n}\n\nexport function scaleVectorNetworkForResize(\n vectorNetwork: VectorNetwork | null,\n originalWidth: number,\n originalHeight: number,\n width: number,\n height: number\n): VectorNetwork | null {\n if (!vectorNetwork || (originalWidth <= 0 && originalHeight <= 0)) return null\n\n const scaleX = sideScale(originalWidth, width)\n const scaleY = sideScale(originalHeight, height)\n if (scaleX === 1 && scaleY === 1) return null\n\n return {\n vertices: vectorNetwork.vertices.map((vertex) => ({\n ...vertex,\n x: vertex.x * scaleX,\n y: vertex.y * scaleY\n })),\n segments: vectorNetwork.segments.map((segment) => ({\n ...segment,\n tangentStart: {\n x: segment.tangentStart.x * scaleX,\n y: segment.tangentStart.y * scaleY\n },\n tangentEnd: {\n x: segment.tangentEnd.x * scaleX,\n y: segment.tangentEnd.y * scaleY\n }\n })),\n regions: vectorNetwork.regions\n }\n}\n\n/** Snapshot one node's resize-relevant state (rect + geometry that must scale with it). */\nexport function createResizeSnapshot(node: SceneNode): ResizeSnapshot {\n return {\n type: node.type,\n x: node.x,\n y: node.y,\n width: node.width,\n height: node.height,\n flipX: node.flipX,\n flipY: node.flipY,\n vectorNetwork: node.vectorNetwork ? cloneVectorNetwork(node.vectorNetwork) : null,\n fillGeometry: copyGeometryPaths(node.fillGeometry),\n strokeGeometry: copyGeometryPaths(node.strokeGeometry),\n derivedTextGlyphs: copyDerivedGlyphs(node.derivedTextGlyphs),\n strokes: copyStrokes(node.strokes),\n textPathData: node.textPathData ? structuredClone(node.textPathData) : null,\n textPathBox: node.textPathBox ? { ...node.textPathBox } : null\n }\n}\n\nfunction scaleDerivedGlyphs(\n glyphs: DerivedTextGlyph[] | null,\n sx: number,\n sy: number\n): DerivedTextGlyph[] | null {\n if (!glyphs?.length) return glyphs\n return glyphs.map((g) => ({\n ...g,\n x: g.x * sx,\n y: g.y * sy,\n scaleX: (g.scaleX ?? 1) * sx,\n scaleY: (g.scaleY ?? 1) * sy,\n commandsBlob: new Uint8Array(g.commandsBlob)\n }))\n}\n\nfunction hasPath(orig: Pick<ResizeSnapshot, 'vectorNetwork'>): boolean {\n return (orig.vectorNetwork?.segments.length ?? 0) > 0\n}\n\nfunction scaleStrokes(strokes: Stroke[], sx: number, sy: number): Stroke[] {\n if (strokes.length === 0) return strokes\n // Weight is a scalar; average scale is the usual 2D → 1D compromise.\n const weightScale = (Math.abs(sx) + Math.abs(sy)) / 2\n return strokes.map((s) => ({ ...copyStroke(s), weight: s.weight * weightScale }))\n}\n\n/**\n * All geometry that must track a width/height change. Historically only\n * vectorNetwork + fillGeometry were updated — path-text strokeGeometry and\n * glyphs stayed at the pre-resize size, so shrinking a sticker made the white\n * OUTSIDE outlines look massively thick (DomeSticker resize bug).\n */\nexport function scaledGeometryChanges(\n orig: Pick<\n ResizeSnapshot,\n | 'type'\n | 'vectorNetwork'\n | 'fillGeometry'\n | 'strokeGeometry'\n | 'derivedTextGlyphs'\n | 'strokes'\n | 'textPathData'\n | 'textPathBox'\n >,\n origWidth: number,\n origHeight: number,\n width: number,\n height: number\n): Partial<SceneNode> {\n if (origWidth <= 0 && origHeight <= 0) return {}\n // A straight line's other side still scales.\n const sx = sideScale(origWidth, width)\n const sy = sideScale(origHeight, height)\n if (sx === 1 && sy === 1) return {}\n\n const changes: Partial<SceneNode> = {}\n const resizedVN = scaleVectorNetworkForResize(\n orig.vectorNetwork,\n origWidth,\n origHeight,\n width,\n height\n )\n if (resizedVN) changes.vectorNetwork = resizedVN\n\n if (orig.fillGeometry.length > 0) {\n changes.fillGeometry = scaleGeometryPaths(orig.fillGeometry, sx, sy)\n }\n // A stroke keeps its weight through a resize, as in Figma, so a saved stroke outline goes where\n // the stroke can be drawn again at its weight: from a path, or from a shape's own outline.\n // Text and a vector with only its outline keep scaling the outline, which is all they have.\n const outlineOnly = orig.type === 'TEXT' || (orig.type === 'VECTOR' && !hasPath(orig))\n if (orig.strokeGeometry.length > 0) {\n changes.strokeGeometry = outlineOnly ? scaleGeometryPaths(orig.strokeGeometry, sx, sy) : []\n }\n // Path text scales with its path, including baked path text that kept only rotated glyphs;\n // other text reflows in the new box, so its glyphs are dropped.\n const pathText = followsPath(orig)\n if (pathText) {\n changes.derivedTextGlyphs = scaleDerivedGlyphs(orig.derivedTextGlyphs, sx, sy)\n // Keep the layout/selection box in sync with the scaled glyphs. reflow\n // overrides this when it applies; this covers the fallback where reflow\n // returns null (no path data) so the box doesn't carry a stale size.\n if (orig.textPathBox) {\n changes.textPathBox = {\n x: orig.textPathBox.x * sx,\n y: orig.textPathBox.y * sy,\n width: orig.textPathBox.width * sx,\n height: orig.textPathBox.height * sy\n }\n }\n }\n // Glyphs scaled as a picture take their strokes along; any other stroke keeps its weight, as\n // Figma reports it, even where only a scaled outline can draw it.\n if (orig.strokes.length > 0 && pathText) {\n changes.strokes = scaleStrokes(orig.strokes, sx, sy)\n }\n return changes\n}\n\n/** Copies of the geometry a resize may change, as the snapshot held it before the resize. */\nfunction snapshotGeometry(orig: ResizeSnapshot): Partial<SceneNode> {\n return {\n vectorNetwork: orig.vectorNetwork ? cloneVectorNetwork(orig.vectorNetwork) : null,\n fillGeometry: copyGeometryPaths(orig.fillGeometry),\n strokeGeometry: copyGeometryPaths(orig.strokeGeometry),\n derivedTextGlyphs: copyDerivedGlyphs(orig.derivedTextGlyphs),\n strokes: copyStrokes(orig.strokes),\n textPathBox: orig.textPathBox ? { ...orig.textPathBox } : null\n }\n}\n\n/** Whether a box of `size` scales the snapshot's geometry, a flat side left out. */\nfunction scalesGeometry(orig: ResizeSnapshot, size: Pick<Rect, 'width' | 'height'>): boolean {\n return sideScale(orig.width, size.width) !== 1 || sideScale(orig.height, size.height) !== 1\n}\n\n/**\n * A child's geometry for its constrained `box`, scaled from the snapshot. At a box that scales\n * nothing, after an earlier frame of the same drag scaled it, the child takes its snapshot\n * geometry again, as nothing else would undo that scaling.\n */\nfunction constrainedGeometryChanges(\n orig: ResizeSnapshot,\n current: Pick<SceneNode, 'width' | 'height'>,\n box: Pick<Rect, 'width' | 'height'>\n): Partial<SceneNode> {\n if (scalesGeometry(orig, box))\n return scaledGeometryChanges(orig, orig.width, orig.height, box.width, box.height)\n return scalesGeometry(orig, current) ? snapshotGeometry(orig) : {}\n}\n\nexport function collectResizeDescendants(\n graph: ResizeGraph,\n rootId: string\n): Map<string, ResizeSnapshot> | null {\n const root = graph.getNode(rootId)\n if (!root || !CONSTRAINT_CONTAINER_TYPES.has(root.type)) return null\n const snapshots = new Map<string, ResizeSnapshot>()\n\n const collect = (parentId: string) => {\n const parent = graph.getNode(parentId)\n if (!parent) return\n for (const childId of parent.childIds) {\n const child = graph.getNode(childId)\n if (!child) continue\n snapshots.set(childId, createResizeSnapshot(child))\n collect(childId)\n }\n }\n\n collect(rootId)\n return snapshots.size > 0 ? snapshots : null\n}\n\n/**\n * The flips a child takes when its constraints place it from `from`, written only where they\n * differ from the ones it has now, so a drag that crosses back undoes its own turn.\n */\nexport function flipChanges(\n from: Pick<SceneNode, 'flipX' | 'flipY'>,\n current: Pick<SceneNode, 'flipX' | 'flipY'>,\n flipsX = false,\n flipsY = false\n): Partial<Pick<SceneNode, 'flipX' | 'flipY'>> {\n const changes: Partial<Pick<SceneNode, 'flipX' | 'flipY'>> = {}\n const flipX = from.flipX !== flipsX\n const flipY = from.flipY !== flipsY\n if (flipX !== current.flipX) changes.flipX = flipX\n if (flipY !== current.flipY) changes.flipY = flipY\n return changes\n}\n\ntype Size = Pick<Rect, 'width' | 'height'>\n\n/** One constrained resize: the graph, where each layer was when it began, and what it changes. */\ninterface ResizePlan {\n graph: ResizeGraph\n originals: ReadonlyMap<string, ResizeSnapshot>\n changes: Map<string, Partial<SceneNode>>\n}\n\n/** The layer as the resize found it, or as the resize leaves it with its changes so far. */\nfunction startOf(plan: ResizePlan, id: string): SceneNode | undefined {\n const node = plan.graph.getNode(id)\n const original = plan.originals.get(id)\n return node && original ? { ...node, ...original } : node\n}\n\nfunction plannedOf(plan: ResizePlan, id: string): SceneNode | undefined {\n const node = startOf(plan, id)\n const changes = plan.changes.get(id)\n return node && changes ? { ...node, ...changes } : node\n}\n\nfunction mergeChanges(plan: ResizePlan, id: string, changes: Partial<SceneNode>) {\n plan.changes.set(id, { ...plan.changes.get(id), ...changes })\n}\n\n/** Writes where a layer's constraints put it, then places its own children. */\nfunction placeConstrained(\n plan: ResizePlan,\n child: SceneNode,\n original: ResizeSnapshot,\n rect: ConstrainedRect,\n toParent: Mat3 | null\n) {\n const { flipsX, flipsY, ...box } = rect\n const position = toParent ? Matrix.mapPoint(toParent, box) : box\n plan.changes.set(child.id, {\n ...box,\n ...position,\n ...flipChanges(original, child, flipsX, flipsY),\n ...constrainedGeometryChanges(original, child, box)\n })\n // The final pass sees layout containers after layout has resolved HUG/FILL sizing.\n placeChildren(plan, child.id, original, child.layoutMode === 'NONE' ? box : child)\n}\n\n/**\n * Places the layers in a group or boolean whose frame resized. The group owns no constraints: each\n * layer in it keeps its place in the frame by its own, through nested groups, and the groups then\n * fit around them, as in Figma (live, #1835). A layer is placed in the frame's space and written\n * back in its group's.\n */\nfunction placeGroupedLayers(\n plan: ResizePlan,\n group: SceneNode,\n toFrame: Mat3,\n frameBefore: Size,\n frameAfter: Size\n) {\n for (const childId of group.childIds) {\n const child = plan.graph.getNode(childId)\n const original = plan.originals.get(childId)\n const start = startOf(plan, childId)\n if (!child || !original || !start) continue\n if (FITTED_CONTAINER_TYPES.has(child.type)) {\n const inner = Matrix.multiply(toFrame, getNodeLocalMatrix(start))\n placeGroupedLayers(plan, start, inner, frameBefore, frameAfter)\n continue\n }\n const inFrame = Matrix.mapPoint(toFrame, original)\n const rect = constrainedChildRect(\n { ...inFrame, width: original.width, height: original.height },\n frameBefore,\n frameAfter,\n child.horizontalConstraint,\n child.verticalConstraint,\n enforcedAspectRatio(child)\n )\n placeConstrained(plan, child, original, rect, Matrix.invert(toFrame))\n }\n fitPlannedGroup(plan, group.id)\n}\n\nconst PLACEMENT_KEYS = ['x', 'y', 'width', 'height'] as const\n\n/**\n * Fits a group to its layers where the resize put them, when any of them moved: a boolean's box\n * is its result's, which only the renderer measures, so one whose operands stay keeps its box. A\n * drag places from the start each time, so the group's box is always written.\n */\nfunction fitPlannedGroup(plan: ResizePlan, groupId: string) {\n const group = plannedOf(plan, groupId)\n if (!group) return\n const { x, y, width, height } = group\n mergeChanges(plan, groupId, { x, y, width, height })\n const moved = group.childIds.some((id) => {\n const start = startOf(plan, id)\n const planned = plannedOf(plan, id)\n return start && planned && PLACEMENT_KEYS.some((key) => start[key] !== planned[key])\n })\n if (!moved) return\n const reader = { rootId: plan.graph.rootId, getNode: (id: string) => plannedOf(plan, id) }\n const children = group.childIds.flatMap((id) => reader.getNode(id) ?? [])\n const fit = groupFitChanges(reader, group, children)\n for (const [id, changes] of fit ?? []) mergeChanges(plan, id, changes)\n}\n\n/**\n * Places the children of a layer that went from `parentBefore` to `parentAfter`: a frame's by their\n * constraints, the layers in its groups and booleans by theirs, a group's or boolean's own scaled.\n */\nfunction placeChildren(plan: ResizePlan, parentId: string, parentBefore: Size, parentAfter: Size) {\n const parent = plan.graph.getNode(parentId)\n if (!parent) return\n const scalesChildren = FITTED_CONTAINER_TYPES.has(parent.type)\n for (const childId of parent.childIds) {\n const original = plan.originals.get(childId)\n const child = plan.graph.getNode(childId)\n if (!original || !child) continue\n const isInFlow = parent.layoutMode !== 'NONE' && child.layoutPositioning !== 'ABSOLUTE'\n if (isInFlow) {\n placeChildren(plan, childId, original, child)\n continue\n }\n if (!scalesChildren && FITTED_CONTAINER_TYPES.has(child.type)) {\n const start = { ...child, ...original }\n placeGroupedLayers(plan, start, getNodeLocalMatrix(start), parentBefore, parentAfter)\n continue\n }\n const rect: ConstrainedRect = scalesChildren\n ? scaledChildRect(original, parentBefore, parentAfter)\n : constrainedChildRect(\n original,\n parentBefore,\n parentAfter,\n child.horizontalConstraint,\n child.verticalConstraint,\n enforcedAspectRatio(child)\n )\n placeConstrained(plan, child, original, rect, null)\n }\n}\n\n/**\n * Where the descendants of a layer go when it resizes from `rootBefore` to `rootAfter`, from the\n * places `originals` recorded.\n */\nexport function computeConstrainedResizeChanges(\n graph: ResizeGraph,\n rootId: string,\n rootBefore: Size,\n rootAfter: Size,\n originals: ReadonlyMap<string, ResizeSnapshot>\n): Map<string, Partial<SceneNode>> {\n const plan: ResizePlan = { graph, originals, changes: new Map() }\n placeChildren(plan, rootId, rootBefore, rootAfter)\n return plan.changes\n}\n"],"mappings":";;;;;;;;;;;;;AAmDA,MAAM,6CAA6B,IAAI,IAAuB,CAC5D,GAAG,yBACH,GAAG,sBACL,CAAC;;;;;;;;;;AAgBD,SAAS,gBACP,UACA,MACA,cACA,aACA,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IAAI,CAAC,QAAQ;CACb,MAAM,iBAAiB,uBAAuB,IAAI,OAAO,IAAI;CAC7D,KAAK,MAAM,WAAW,OAAO,UAAU;EACrC,MAAM,WAAW,KAAK,UAAU,IAAI,OAAO;EAC3C,MAAM,QAAQ,KAAK,MAAM,QAAQ,OAAO;EACxC,IAAI,CAAC,YAAY,CAAC,OAAO;EAEzB,IADiB,OAAO,eAAe,UAAU,MAAM,sBAAsB,YAC/D;GACZ,cAAc,MAAM,SAAS,UAAU,KAAK;GAC5C;EACF;EACA,IAAI,CAAC,kBAAkB,uBAAuB,IAAI,MAAM,IAAI,GAAG;GAC7D,MAAM,QAAQ;IAAE,GAAG;IAAO,GAAG;GAAS;GACtC,mBAAmB,MAAM,OAAO,mBAAmB,KAAK,GAAG,cAAc,WAAW;GACpF;EACF;EAWA,iBAAiB,MAAM,OAAO,UAVA,iBAC1B,gBAAgB,UAAU,cAAc,WAAW,IACnD,qBACE,UACA,cACA,aACA,MAAM,sBACN,MAAM,oBACN,oBAAoB,KAAK,CAC3B,GAC0C,IAAI;CACpD;AACF;;;;;AAMA,SAAgB,gCACd,OACA,QACA,YACA,WACA,WACiC;CACjC,MAAM,OAAmB;EAAE;EAAO;EAAW,yBAAS,IAAI,IAAI;CAAE;CAChE,cAAc,MAAM,QAAQ,YAAY,SAAS;CACjD,OAAO,KAAK;AACd"}
1
+ {"version":3,"file":"resize.js","names":[],"sources":["../src/resize.ts"],"sourcesContent":["import { pick } from 'es-toolkit/object'\n\nimport { CONSTRAINT_PARENT_TYPES } from './constraints'\nimport { getNodeLocalMatrix } from './coordinate'\nimport {\n cloneVectorNetwork,\n copyDerivedGlyphs,\n copyGeometryPaths,\n copyStroke,\n copyStrokes,\n scaleGeometryPaths\n} from './copy'\nimport { groupFitChanges } from './group-bounds'\nimport { enforcedAspectRatio } from './layout/aspect-ratio'\nimport Matrix, { type Mat3 } from './matrix'\nimport { FITTED_CONTAINER_TYPES } from './node-defaults'\nimport type { Rect } from './primitives'\nimport { followsPath } from './text/path'\nimport type { ConstraintType, DerivedTextGlyph, SceneNode, Stroke, VectorNetwork } from './types'\n\n/**\n * Drag-start state a live resize re-scales from. Path text needs more than the\n * layout rect: its OUTSIDE stroke silhouettes and glyph outlines are baked\n * geometry that must scale with the node, and textPathBox is the layout box the\n * glyphs were reflowed against.\n */\nconst RESIZE_SNAPSHOT_FIELDS = [\n 'type',\n 'x',\n 'y',\n 'width',\n 'height',\n 'flipX',\n 'flipY',\n 'vectorNetwork',\n 'fillGeometry',\n 'strokeGeometry',\n 'derivedTextGlyphs',\n 'strokes',\n 'textPathData',\n 'textPathBox'\n] as const satisfies readonly (keyof SceneNode)[]\n\nexport type ResizeSnapshot = Pick<SceneNode, (typeof RESIZE_SNAPSHOT_FIELDS)[number]>\ninterface ResizeGraph {\n readonly rootId: string\n getNode(id: string): SceneNode | undefined\n}\n\n/**\n * Containers whose resize moves their children: the constraint parents, and groups and booleans,\n * which scale theirs.\n */\nconst CONSTRAINT_CONTAINER_TYPES = new Set<SceneNode['type']>([\n ...CONSTRAINT_PARENT_TYPES,\n ...FITTED_CONTAINER_TYPES\n])\n\ntype AxisPlacement = { position: number; size: number; flipped?: boolean }\n\n/** A child's box after its parent resizes, and the axes on which it turned over. */\nexport type ConstrainedRect = Rect & { flipsX?: boolean; flipsY?: boolean }\n\n/**\n * Where a constraint places a child on one axis when its parent goes from `parentBefore` to\n * `parentAfter`, as Figma does (live-measured, #1060, #1816): Right and Left & right move or grow\n * it by the change in the parent's size rounded to whole pixels, Center by the change in its\n * rounded half, and Scale by the exact ratio. The child's own box is never rounded, so a resize\n * to the same size changes nothing. Left & right that would leave no size keeps the axis as it\n * was; past zero, the child turns over and its box runs back from the edge it was pinned to, as\n * the layer is mirrored in Figma.\n */\nfunction constrainedAxis(\n position: number,\n size: number,\n parentBefore: number,\n parentAfter: number,\n constraint: ConstraintType\n): AxisPlacement {\n const delta = Math.round(parentAfter) - Math.round(parentBefore)\n if (constraint === 'MAX') return { position: position + delta, size }\n if (constraint === 'CENTER') {\n return { position: position + Math.round(parentAfter / 2) - Math.round(parentBefore / 2), size }\n }\n if (constraint === 'STRETCH') {\n const stretched = size + delta\n if (stretched === 0) return { position, size }\n if (stretched > 0) return { position, size: stretched }\n return { position: position + stretched, size: -stretched, flipped: true }\n }\n if (constraint === 'SCALE' && parentBefore > 0) {\n const scale = parentAfter / parentBefore\n return { position: position * scale, size: size * scale }\n }\n return { position, size }\n}\n\nconst FLEXIBLE_CONSTRAINTS: ReadonlySet<ConstraintType> = new Set(['STRETCH', 'SCALE'])\n\n/** The axis at `size`, keeping the edge or centre its constraint pins where it was placed. */\nfunction resizedInPlace(\n placed: AxisPlacement,\n size: number,\n constraint: ConstraintType\n): AxisPlacement {\n if (constraint === 'MAX') return { position: placed.position + placed.size - size, size }\n if (constraint === 'CENTER') return { position: placed.position + (placed.size - size) / 2, size }\n return { position: placed.position, size }\n}\n\n/** Keep a placed box's constrained edges or center when its content determines its size. */\nexport function resizedChildRect(\n placed: Rect,\n size: Pick<Rect, 'width' | 'height'>,\n horizontal: ConstraintType,\n vertical: ConstraintType\n): Rect {\n const x = resizedInPlace({ position: placed.x, size: placed.width }, size.width, horizontal)\n const y = resizedInPlace({ position: placed.y, size: placed.height }, size.height, vertical)\n return { x: x.position, y: y.position, width: x.size, height: y.size }\n}\n\n/**\n * A locked aspect ratio holds when exactly one axis follows the parent, as in Figma: that axis\n * sizes the other. With both axes following the parent, or neither, the ratio gives way.\n */\nfunction keepLockedRatio(\n x: AxisPlacement,\n y: AxisPlacement,\n horizontal: ConstraintType,\n vertical: ConstraintType,\n aspectRatio: number | null\n): { x: AxisPlacement; y: AxisPlacement } {\n const flexibleX = FLEXIBLE_CONSTRAINTS.has(horizontal)\n if (aspectRatio === null || flexibleX === FLEXIBLE_CONSTRAINTS.has(vertical)) return { x, y }\n return flexibleX\n ? { x, y: resizedInPlace(y, x.size / aspectRatio, vertical) }\n : { x: resizedInPlace(x, y.size * aspectRatio, horizontal), y }\n}\n\n/**\n * A child's box after its parent resizes, by a handle, `resize()`, layout, or an instance taking\n * another size than its component, keeping a locked aspect ratio as Figma does.\n */\nexport function constrainedChildRect(\n child: Rect,\n parentBefore: Pick<Rect, 'width' | 'height'>,\n parentAfter: Pick<Rect, 'width' | 'height'>,\n horizontal: ConstraintType,\n vertical: ConstraintType,\n aspectRatio: number | null = null\n): ConstrainedRect {\n const { x, y } = keepLockedRatio(\n constrainedAxis(child.x, child.width, parentBefore.width, parentAfter.width, horizontal),\n constrainedAxis(child.y, child.height, parentBefore.height, parentAfter.height, vertical),\n horizontal,\n vertical,\n aspectRatio\n )\n const rect: ConstrainedRect = { x: x.position, y: y.position, width: x.size, height: y.size }\n if (x.flipped) rect.flipsX = true\n if (y.flipped) rect.flipsY = true\n return rect\n}\n\nexport function scaledChildRect(\n child: Rect,\n parentBefore: Pick<Rect, 'width' | 'height'>,\n parentAfter: Pick<Rect, 'width' | 'height'>\n): Rect {\n return constrainedChildRect(child, parentBefore, parentAfter, 'SCALE', 'SCALE')\n}\n\n/** How much a side grows; a flat side, as a straight line's, has nothing to scale along it. */\nfunction sideScale(original: number, size: number): number {\n return original > 0 ? size / original : 1\n}\n\nexport function scaleVectorNetworkForResize(\n vectorNetwork: VectorNetwork | null,\n originalWidth: number,\n originalHeight: number,\n width: number,\n height: number\n): VectorNetwork | null {\n if (!vectorNetwork || (originalWidth <= 0 && originalHeight <= 0)) return null\n\n const scaleX = sideScale(originalWidth, width)\n const scaleY = sideScale(originalHeight, height)\n if (scaleX === 1 && scaleY === 1) return null\n\n return {\n vertices: vectorNetwork.vertices.map((vertex) => ({\n ...vertex,\n x: vertex.x * scaleX,\n y: vertex.y * scaleY\n })),\n segments: vectorNetwork.segments.map((segment) => ({\n ...segment,\n tangentStart: {\n x: segment.tangentStart.x * scaleX,\n y: segment.tangentStart.y * scaleY\n },\n tangentEnd: {\n x: segment.tangentEnd.x * scaleX,\n y: segment.tangentEnd.y * scaleY\n }\n })),\n regions: vectorNetwork.regions\n }\n}\n\n/** Snapshot one node's resize-relevant state (rect + geometry that must scale with it). */\nexport function createResizeSnapshot(node: SceneNode): ResizeSnapshot {\n return {\n type: node.type,\n x: node.x,\n y: node.y,\n width: node.width,\n height: node.height,\n flipX: node.flipX,\n flipY: node.flipY,\n vectorNetwork: node.vectorNetwork ? cloneVectorNetwork(node.vectorNetwork) : null,\n fillGeometry: copyGeometryPaths(node.fillGeometry),\n strokeGeometry: copyGeometryPaths(node.strokeGeometry),\n derivedTextGlyphs: copyDerivedGlyphs(node.derivedTextGlyphs),\n strokes: copyStrokes(node.strokes),\n textPathData: node.textPathData ? structuredClone(node.textPathData) : null,\n textPathBox: node.textPathBox ? { ...node.textPathBox } : null\n }\n}\n\nfunction scaleDerivedGlyphs(\n glyphs: DerivedTextGlyph[] | null,\n sx: number,\n sy: number\n): DerivedTextGlyph[] | null {\n if (!glyphs?.length) return glyphs\n return glyphs.map((g) => ({\n ...g,\n x: g.x * sx,\n y: g.y * sy,\n scaleX: (g.scaleX ?? 1) * sx,\n scaleY: (g.scaleY ?? 1) * sy,\n commandsBlob: new Uint8Array(g.commandsBlob)\n }))\n}\n\nfunction hasPath(orig: Pick<ResizeSnapshot, 'vectorNetwork'>): boolean {\n return (orig.vectorNetwork?.segments.length ?? 0) > 0\n}\n\nfunction scaleStrokes(strokes: Stroke[], sx: number, sy: number): Stroke[] {\n if (strokes.length === 0) return strokes\n // Weight is a scalar; average scale is the usual 2D → 1D compromise.\n const weightScale = (Math.abs(sx) + Math.abs(sy)) / 2\n return strokes.map((s) => ({ ...copyStroke(s), weight: s.weight * weightScale }))\n}\n\n/**\n * All geometry that must track a width/height change. Historically only\n * vectorNetwork + fillGeometry were updated — path-text strokeGeometry and\n * glyphs stayed at the pre-resize size, so shrinking a sticker made the white\n * OUTSIDE outlines look massively thick (DomeSticker resize bug).\n */\nexport function scaledGeometryChanges(\n orig: Pick<\n ResizeSnapshot,\n | 'type'\n | 'vectorNetwork'\n | 'fillGeometry'\n | 'strokeGeometry'\n | 'derivedTextGlyphs'\n | 'strokes'\n | 'textPathData'\n | 'textPathBox'\n >,\n origWidth: number,\n origHeight: number,\n width: number,\n height: number\n): Partial<SceneNode> {\n if (origWidth <= 0 && origHeight <= 0) return {}\n // A straight line's other side still scales.\n const sx = sideScale(origWidth, width)\n const sy = sideScale(origHeight, height)\n if (sx === 1 && sy === 1) return {}\n\n const changes: Partial<SceneNode> = {}\n const resizedVN = scaleVectorNetworkForResize(\n orig.vectorNetwork,\n origWidth,\n origHeight,\n width,\n height\n )\n if (resizedVN) changes.vectorNetwork = resizedVN\n\n if (orig.fillGeometry.length > 0) {\n changes.fillGeometry = scaleGeometryPaths(orig.fillGeometry, sx, sy)\n }\n // A stroke keeps its weight through a resize, as in Figma, so a saved stroke outline goes where\n // the stroke can be drawn again at its weight: from a path, or from a shape's own outline.\n // Text and a vector with only its outline keep scaling the outline, which is all they have.\n const outlineOnly = orig.type === 'TEXT' || (orig.type === 'VECTOR' && !hasPath(orig))\n if (orig.strokeGeometry.length > 0) {\n changes.strokeGeometry = outlineOnly ? scaleGeometryPaths(orig.strokeGeometry, sx, sy) : []\n }\n // Path text scales with its path, including baked path text that kept only rotated glyphs;\n // other text reflows in the new box, so its glyphs are dropped.\n const pathText = followsPath(orig)\n if (pathText) {\n changes.derivedTextGlyphs = scaleDerivedGlyphs(orig.derivedTextGlyphs, sx, sy)\n // Keep the layout/selection box in sync with the scaled glyphs. reflow\n // overrides this when it applies; this covers the fallback where reflow\n // returns null (no path data) so the box doesn't carry a stale size.\n if (orig.textPathBox) {\n changes.textPathBox = {\n x: orig.textPathBox.x * sx,\n y: orig.textPathBox.y * sy,\n width: orig.textPathBox.width * sx,\n height: orig.textPathBox.height * sy\n }\n }\n }\n // Glyphs scaled as a picture take their strokes along; any other stroke keeps its weight, as\n // Figma reports it, even where only a scaled outline can draw it.\n if (orig.strokes.length > 0 && pathText) {\n changes.strokes = scaleStrokes(orig.strokes, sx, sy)\n }\n return changes\n}\n\n/** Copies of the geometry a resize may change, as the snapshot held it before the resize. */\nfunction snapshotGeometry(orig: ResizeSnapshot): Partial<SceneNode> {\n return {\n vectorNetwork: orig.vectorNetwork ? cloneVectorNetwork(orig.vectorNetwork) : null,\n fillGeometry: copyGeometryPaths(orig.fillGeometry),\n strokeGeometry: copyGeometryPaths(orig.strokeGeometry),\n derivedTextGlyphs: copyDerivedGlyphs(orig.derivedTextGlyphs),\n strokes: copyStrokes(orig.strokes),\n textPathBox: orig.textPathBox ? { ...orig.textPathBox } : null\n }\n}\n\n/** Whether a box of `size` scales the snapshot's geometry, a flat side left out. */\nfunction scalesGeometry(orig: ResizeSnapshot, size: Pick<Rect, 'width' | 'height'>): boolean {\n return sideScale(orig.width, size.width) !== 1 || sideScale(orig.height, size.height) !== 1\n}\n\n/**\n * A child's geometry for its constrained `box`, scaled from the snapshot. At a box that scales\n * nothing, after an earlier frame of the same drag scaled it, the child takes its snapshot\n * geometry again, as nothing else would undo that scaling.\n */\nfunction constrainedGeometryChanges(\n orig: ResizeSnapshot,\n current: Pick<SceneNode, 'width' | 'height'>,\n box: Pick<Rect, 'width' | 'height'>\n): Partial<SceneNode> {\n if (scalesGeometry(orig, box))\n return scaledGeometryChanges(orig, orig.width, orig.height, box.width, box.height)\n return scalesGeometry(orig, current) ? snapshotGeometry(orig) : {}\n}\n\n/**\n * A node's resize state holding its own geometry rather than copies of it. It stays the state the\n * resize began from only while nothing edits that geometry in place, as a resize plan does not:\n * it writes new paths and outlines.\n */\nexport function sharedResizeSnapshot(node: SceneNode): ResizeSnapshot {\n return pick(node, RESIZE_SNAPSHOT_FIELDS)\n}\n\nexport function collectResizeDescendants(\n graph: ResizeGraph,\n rootId: string,\n snapshot: (node: SceneNode) => ResizeSnapshot = createResizeSnapshot\n): Map<string, ResizeSnapshot> | null {\n const root = graph.getNode(rootId)\n if (!root || !CONSTRAINT_CONTAINER_TYPES.has(root.type)) return null\n const snapshots = new Map<string, ResizeSnapshot>()\n\n const collect = (parentId: string) => {\n const parent = graph.getNode(parentId)\n if (!parent) return\n for (const childId of parent.childIds) {\n const child = graph.getNode(childId)\n if (!child) continue\n snapshots.set(childId, snapshot(child))\n collect(childId)\n }\n }\n\n collect(rootId)\n return snapshots.size > 0 ? snapshots : null\n}\n\n/**\n * The flips a child takes when its constraints place it from `from`, written only where they\n * differ from the ones it has now, so a drag that crosses back undoes its own turn.\n */\nexport function flipChanges(\n from: Pick<SceneNode, 'flipX' | 'flipY'>,\n current: Pick<SceneNode, 'flipX' | 'flipY'>,\n flipsX = false,\n flipsY = false\n): Partial<Pick<SceneNode, 'flipX' | 'flipY'>> {\n const changes: Partial<Pick<SceneNode, 'flipX' | 'flipY'>> = {}\n const flipX = from.flipX !== flipsX\n const flipY = from.flipY !== flipsY\n if (flipX !== current.flipX) changes.flipX = flipX\n if (flipY !== current.flipY) changes.flipY = flipY\n return changes\n}\n\ntype Size = Pick<Rect, 'width' | 'height'>\n\n/** One constrained resize: the graph, where each layer was when it began, and what it changes. */\ninterface ResizePlan {\n graph: ResizeGraph\n originals: ReadonlyMap<string, ResizeSnapshot>\n changes: Map<string, Partial<SceneNode>>\n}\n\n/** The layer as the resize found it, or as the resize leaves it with its changes so far. */\nfunction startOf(plan: ResizePlan, id: string): SceneNode | undefined {\n const node = plan.graph.getNode(id)\n const original = plan.originals.get(id)\n return node && original ? { ...node, ...original } : node\n}\n\nfunction plannedOf(plan: ResizePlan, id: string): SceneNode | undefined {\n const node = startOf(plan, id)\n const changes = plan.changes.get(id)\n return node && changes ? { ...node, ...changes } : node\n}\n\nfunction mergeChanges(plan: ResizePlan, id: string, changes: Partial<SceneNode>) {\n plan.changes.set(id, { ...plan.changes.get(id), ...changes })\n}\n\n/** Writes where a layer's constraints put it, then places its own children. */\nfunction placeConstrained(\n plan: ResizePlan,\n child: SceneNode,\n original: ResizeSnapshot,\n rect: ConstrainedRect,\n toParent: Mat3 | null\n) {\n const { flipsX, flipsY, ...box } = rect\n const position = toParent ? Matrix.mapPoint(toParent, box) : box\n plan.changes.set(child.id, {\n ...box,\n ...position,\n ...flipChanges(original, child, flipsX, flipsY),\n ...constrainedGeometryChanges(original, child, box)\n })\n // The final pass sees layout containers after layout has resolved HUG/FILL sizing.\n placeChildren(plan, child.id, original, child.layoutMode === 'NONE' ? box : child)\n}\n\n/**\n * Places the layers in a group or boolean whose frame resized. The group owns no constraints: each\n * layer in it keeps its place in the frame by its own, through nested groups, and the groups then\n * fit around them, as in Figma (live, #1835). A layer is placed in the frame's space and written\n * back in its group's.\n */\nfunction placeGroupedLayers(\n plan: ResizePlan,\n group: SceneNode,\n toFrame: Mat3,\n frameBefore: Size,\n frameAfter: Size\n) {\n for (const childId of group.childIds) {\n const child = plan.graph.getNode(childId)\n const original = plan.originals.get(childId)\n const start = startOf(plan, childId)\n if (!child || !original || !start) continue\n if (FITTED_CONTAINER_TYPES.has(child.type)) {\n const inner = Matrix.multiply(toFrame, getNodeLocalMatrix(start))\n placeGroupedLayers(plan, start, inner, frameBefore, frameAfter)\n continue\n }\n const inFrame = Matrix.mapPoint(toFrame, original)\n const rect = constrainedChildRect(\n { ...inFrame, width: original.width, height: original.height },\n frameBefore,\n frameAfter,\n child.horizontalConstraint,\n child.verticalConstraint,\n enforcedAspectRatio(child)\n )\n placeConstrained(plan, child, original, rect, Matrix.invert(toFrame))\n }\n fitPlannedGroup(plan, group.id)\n}\n\nconst PLACEMENT_KEYS = ['x', 'y', 'width', 'height'] as const\n\n/**\n * Fits a group to its layers where the resize put them, when any of them moved: a boolean's box\n * is its result's, which only the renderer measures, so one whose operands stay keeps its box. A\n * drag places from the start each time, so the group's box is always written.\n */\nfunction fitPlannedGroup(plan: ResizePlan, groupId: string) {\n const group = plannedOf(plan, groupId)\n if (!group) return\n const { x, y, width, height } = group\n mergeChanges(plan, groupId, { x, y, width, height })\n const moved = group.childIds.some((id) => {\n const start = startOf(plan, id)\n const planned = plannedOf(plan, id)\n return start && planned && PLACEMENT_KEYS.some((key) => start[key] !== planned[key])\n })\n if (!moved) return\n const reader = { rootId: plan.graph.rootId, getNode: (id: string) => plannedOf(plan, id) }\n const children = group.childIds.flatMap((id) => reader.getNode(id) ?? [])\n const fit = groupFitChanges(reader, group, children)\n for (const [id, changes] of fit ?? []) mergeChanges(plan, id, changes)\n}\n\n/**\n * Places the children of a layer that went from `parentBefore` to `parentAfter`: a frame's by their\n * constraints, the layers in its groups and booleans by theirs, a group's or boolean's own scaled.\n */\nfunction placeChildren(plan: ResizePlan, parentId: string, parentBefore: Size, parentAfter: Size) {\n const parent = plan.graph.getNode(parentId)\n if (!parent) return\n const scalesChildren = FITTED_CONTAINER_TYPES.has(parent.type)\n for (const childId of parent.childIds) {\n const original = plan.originals.get(childId)\n const child = plan.graph.getNode(childId)\n if (!original || !child) continue\n const isInFlow = parent.layoutMode !== 'NONE' && child.layoutPositioning !== 'ABSOLUTE'\n if (isInFlow) {\n placeChildren(plan, childId, original, child)\n continue\n }\n if (!scalesChildren && FITTED_CONTAINER_TYPES.has(child.type)) {\n const start = { ...child, ...original }\n placeGroupedLayers(plan, start, getNodeLocalMatrix(start), parentBefore, parentAfter)\n continue\n }\n const rect: ConstrainedRect = scalesChildren\n ? scaledChildRect(original, parentBefore, parentAfter)\n : constrainedChildRect(\n original,\n parentBefore,\n parentAfter,\n child.horizontalConstraint,\n child.verticalConstraint,\n enforcedAspectRatio(child)\n )\n placeConstrained(plan, child, original, rect, null)\n }\n}\n\n/**\n * Where the descendants of a layer go when it resizes from `rootBefore` to `rootAfter`, from the\n * places `originals` recorded.\n */\nexport function computeConstrainedResizeChanges(\n graph: ResizeGraph,\n rootId: string,\n rootBefore: Size,\n rootAfter: Size,\n originals: ReadonlyMap<string, ResizeSnapshot>\n): Map<string, Partial<SceneNode>> {\n const plan: ResizePlan = { graph, originals, changes: new Map() }\n placeChildren(plan, rootId, rootBefore, rootAfter)\n return plan.changes\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA0BA,MAAM,yBAAyB;CAC7B;CACA;CACA;CACA;CACA;CACA;CACA;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K,CAAC,CAAC;CACxE,MAAM,MAAM,gBAAgB,QAAQ,OAAO,QAAQ;CACnD,KAAK,MAAM,CAAC,IAAI,YAAY,OAAO,CAAC,GAAG,aAAa,MAAM,IAAI,OAAO;AACvE;;;;;AAMA,SAAS,cAAc,MAAkB,UAAkB,cAAoB,aAAmB;CAChG,MAAM,SAAS,KAAK,MAAM,QAAQ,QAAQ;CAC1C,IAAI,CAAC,QAAQ;CACb,MAAM,iBAAiB,uBAAuB,IAAI,OAAO,IAAI;CAC7D,KAAK,MAAM,WAAW,OAAO,UAAU;EACrC,MAAM,WAAW,KAAK,UAAU,IAAI,OAAO;EAC3C,MAAM,QAAQ,KAAK,MAAM,QAAQ,OAAO;EACxC,IAAI,CAAC,YAAY,CAAC,OAAO;EAEzB,IADiB,OAAO,eAAe,UAAU,MAAM,sBAAsB,YAC/D;GACZ,cAAc,MAAM,SAAS,UAAU,KAAK;GAC5C;EACF;EACA,IAAI,CAAC,kBAAkB,uBAAuB,IAAI,MAAM,IAAI,GAAG;GAC7D,MAAM,QAAQ;IAAE,GAAG;IAAO,GAAG;GAAS;GACtC,mBAAmB,MAAM,OAAO,mBAAmB,KAAK,GAAG,cAAc,WAAW;GACpF;EACF;EAWA,iBAAiB,MAAM,OAAO,UAVA,iBAC1B,gBAAgB,UAAU,cAAc,WAAW,IACnD,qBACE,UACA,cACA,aACA,MAAM,sBACN,MAAM,oBACN,oBAAoB,KAAK,CAC3B,GAC0C,IAAI;CACpD;AACF;;;;;AAMA,SAAgB,gCACd,OACA,QACA,YACA,WACA,WACiC;CACjC,MAAM,OAAmB;EAAE;EAAO;EAAW,yBAAS,IAAI,IAAI;CAAE;CAChE,cAAc,MAAM,QAAQ,YAAY,SAAS;CACjD,OAAO,KAAK;AACd"}
@@ -1,4 +1,4 @@
1
- import { scaleNodeChanges } from "./node.js";
1
+ import { scaleNodeChanges, scaledTextStyleLengths } from "./node.js";
2
2
  import { MIN_RESCALE, RescaleOptions, rescaleNodeChanges, rescaleNodeTree, rescaleTargets, scaleRoots } from "./tree.js";
3
3
  import { ScaleSnapshot, scaledSnapshotChanges, snapshotScale } from "./snapshot.js";
4
- export { MIN_RESCALE, type RescaleOptions, type ScaleSnapshot, rescaleNodeChanges, rescaleNodeTree, rescaleTargets, scaleNodeChanges, scaleRoots, scaledSnapshotChanges, snapshotScale };
4
+ export { MIN_RESCALE, type RescaleOptions, type ScaleSnapshot, rescaleNodeChanges, rescaleNodeTree, rescaleTargets, scaleNodeChanges, scaleRoots, scaledSnapshotChanges, scaledTextStyleLengths, snapshotScale };
@@ -1,4 +1,4 @@
1
- import { scaleNodeChanges } from "./node.js";
1
+ import { scaleNodeChanges, scaledTextStyleLengths } from "./node.js";
2
2
  import { MIN_RESCALE, rescaleNodeChanges, rescaleNodeTree, rescaleTargets, scaleRoots } from "./tree.js";
3
3
  import { scaledSnapshotChanges, snapshotScale } from "./snapshot.js";
4
- export { MIN_RESCALE, rescaleNodeChanges, rescaleNodeTree, rescaleTargets, scaleNodeChanges, scaleRoots, scaledSnapshotChanges, snapshotScale };
4
+ export { MIN_RESCALE, rescaleNodeChanges, rescaleNodeTree, rescaleTargets, scaleNodeChanges, scaleRoots, scaledSnapshotChanges, scaledTextStyleLengths, snapshotScale };
@@ -1,6 +1,7 @@
1
1
  import { SceneNode } from "../types.js";
2
2
  //#region src/scaling/node.d.ts
3
+ declare function scaledTextStyleLengths<Values extends object>(values: Values, scale: number): Values;
3
4
  declare function scaleNodeChanges(node: SceneNode, scale: number, scalePosition: boolean): Partial<SceneNode>;
4
5
  //#endregion
5
- export { scaleNodeChanges };
6
+ export { scaleNodeChanges, scaledTextStyleLengths };
6
7
  //# sourceMappingURL=node.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"node.d.ts","names":[],"sources":["../../src/scaling/node.ts"],"mappings":";;iBAiJgB,iBACd,MAAM,WACN,eACA,yBACC,QAAQ"}
1
+ {"version":3,"file":"node.d.ts","names":[],"sources":["../../src/scaling/node.ts"],"mappings":";;iBAuFgB,uBAAuB,uBACrC,QAAQ,QACR,gBACC;iBAiGa,iBACd,MAAM,WACN,eACA,yBACC,QAAQ"}
@@ -2,6 +2,7 @@ import { scaledTextLength } from "../text/lengths.js";
2
2
  import { cloneVectorNetwork, copyDerivedGlyphs, scaleGeometryPaths } from "../copy.js";
3
3
  import { followsPath } from "../text/path.js";
4
4
  import { TEXT_PARAGRAPH_SPACING_FIELDS } from "../text/paragraphs.js";
5
+ import { pick } from "es-toolkit/object";
5
6
  //#region src/scaling/node.ts
6
7
  function scaledOptional(value, scale) {
7
8
  return value == null ? null : value * scale;
@@ -43,6 +44,30 @@ function scaledFills(fills, scale) {
43
44
  } : void 0
44
45
  }));
45
46
  }
47
+ const TEXT_STYLE_LENGTH_FIELDS = [
48
+ "fontSize",
49
+ "lineHeight",
50
+ "letterSpacing",
51
+ "paragraphSpacing",
52
+ "paragraphIndent",
53
+ "listSpacing"
54
+ ];
55
+ const TEXT_STYLE_LENGTHS = new Set(TEXT_STYLE_LENGTH_FIELDS);
56
+ function isTextStyleLength(field) {
57
+ return TEXT_STYLE_LENGTHS.has(field);
58
+ }
59
+ function isTextLength(value) {
60
+ return typeof value === "object" && value !== null && "unit" in value && "value" in value;
61
+ }
62
+ function lengthAtScale(value, scale) {
63
+ if (typeof value === "number") return value * scale;
64
+ return isTextLength(value) ? scaledTextLength(value, scale) : value;
65
+ }
66
+ function scaledTextStyleLengths(values, scale) {
67
+ const scaled = { ...values };
68
+ for (const [field, value] of Object.entries(values)) if (isTextStyleLength(field)) Object.assign(scaled, { [field]: lengthAtScale(value, scale) });
69
+ return scaled;
70
+ }
46
71
  function scaledStyleRuns(styleRuns, scale) {
47
72
  return styleRuns.map((run) => ({
48
73
  ...structuredClone(run),
@@ -130,15 +155,10 @@ function scaleNodeChanges(node, scale, scalePosition) {
130
155
  topRightRadius: node.topRightRadius * scale,
131
156
  bottomRightRadius: node.bottomRightRadius * scale,
132
157
  bottomLeftRadius: node.bottomLeftRadius * scale,
133
- fontSize: node.fontSize * scale,
134
- letterSpacing: scaledTextLength(node.letterSpacing, scale),
135
- lineHeight: node.lineHeight && scaledTextLength(node.lineHeight, scale),
158
+ ...scaledTextStyleLengths(pick(node, TEXT_STYLE_LENGTH_FIELDS), scale),
136
159
  textDecorationThickness: scaledOptional(node.textDecorationThickness, scale),
137
160
  textUnderlineOffset: scaledOptional(node.textUnderlineOffset, scale),
138
161
  styleRuns: scaledStyleRuns(node.styleRuns, scale),
139
- listSpacing: node.listSpacing * scale,
140
- paragraphSpacing: node.paragraphSpacing * scale,
141
- paragraphIndent: node.paragraphIndent * scale,
142
162
  textParagraphs: scaledParagraphStyles(node.textParagraphs, scale),
143
163
  derivedTextHeight: scaledOptional(node.derivedTextHeight, scale),
144
164
  itemSpacing: node.itemSpacing * scale,
@@ -169,6 +189,6 @@ function scaleNodeChanges(node, scale, scalePosition) {
169
189
  };
170
190
  }
171
191
  //#endregion
172
- export { scaleNodeChanges };
192
+ export { isTextStyleLength, scaleNodeChanges, scaledTextStyleLengths };
173
193
 
174
194
  //# sourceMappingURL=node.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"node.js","names":[],"sources":["../../src/scaling/node.ts"],"sourcesContent":["import { cloneVectorNetwork, copyDerivedGlyphs, scaleGeometryPaths } from '../copy'\nimport { scaledTextLength } from '../text/lengths'\nimport { TEXT_PARAGRAPH_SPACING_FIELDS } from '../text/paragraphs'\nimport { followsPath } from '../text/path'\nimport {\n type Effect,\n type Fill,\n type GridTrack,\n type LayoutGrid,\n type SceneNode,\n type Stroke,\n type StyleRun,\n type TextParagraphStyle\n} from '../types'\n\nfunction scaledOptional(value: number | null, scale: number): number | null {\n return value == null ? null : value * scale\n}\n\nfunction scaledStrokes(strokes: readonly Stroke[], scale: number): Stroke[] {\n return strokes.map((stroke) => ({\n ...structuredClone(stroke),\n weight: stroke.weight * scale,\n dashPattern: stroke.dashPattern?.map((value) => value * scale)\n }))\n}\n\nfunction scaledEffects(effects: readonly Effect[], scale: number): Effect[] {\n return effects.map((effect) => ({\n ...structuredClone(effect),\n offset: { x: effect.offset.x * scale, y: effect.offset.y * scale },\n radius: effect.radius * scale,\n spread: effect.spread * scale,\n ...(effect.progressive\n ? {\n progressive: {\n ...structuredClone(effect.progressive),\n startRadius: effect.progressive.startRadius * scale\n }\n }\n : {})\n }))\n}\n\nfunction scaledFills(fills: readonly Fill[], scale: number): Fill[] {\n return fills.map((fill) => ({\n ...structuredClone(fill),\n scale: fill.scale == null ? undefined : fill.scale * scale,\n spacing: fill.spacing == null ? undefined : fill.spacing * scale,\n patternSpacing: fill.patternSpacing\n ? { x: fill.patternSpacing.x * scale, y: fill.patternSpacing.y * scale }\n : undefined,\n noiseSize: fill.noiseSize\n ? { x: fill.noiseSize.x * scale, y: fill.noiseSize.y * scale }\n : undefined\n }))\n}\n\nfunction scaledStyleRuns(styleRuns: readonly StyleRun[], scale: number): StyleRun[] {\n return styleRuns.map((run) => ({\n ...structuredClone(run),\n style: {\n ...structuredClone(run.style),\n fontSize: run.style.fontSize == null ? undefined : run.style.fontSize * scale,\n letterSpacing: run.style.letterSpacing && scaledTextLength(run.style.letterSpacing, scale),\n lineHeight: run.style.lineHeight && scaledTextLength(run.style.lineHeight, scale),\n textDecorationThickness: scaledOptional(run.style.textDecorationThickness ?? null, scale),\n textUnderlineOffset: scaledOptional(run.style.textUnderlineOffset ?? null, scale)\n }\n }))\n}\n\nfunction scaledParagraphStyles(\n paragraphs: readonly TextParagraphStyle[],\n scale: number\n): TextParagraphStyle[] {\n return paragraphs.map((style) => {\n const scaled = { ...style }\n for (const field of TEXT_PARAGRAPH_SPACING_FIELDS) {\n const value = style[field]\n if (value !== undefined) scaled[field] = value * scale\n }\n return scaled\n })\n}\n\nfunction scaledLayoutGrids(grids: readonly LayoutGrid[], scale: number): LayoutGrid[] {\n return grids.map((grid) => ({\n ...structuredClone(grid),\n offset: grid.offset == null ? undefined : grid.offset * scale,\n sectionSize: grid.sectionSize == null ? undefined : grid.sectionSize * scale,\n gutterSize: grid.gutterSize == null ? undefined : grid.gutterSize * scale\n }))\n}\n\nfunction scaledGridTracks(tracks: readonly GridTrack[], scale: number): GridTrack[] {\n return tracks.map((track) => ({\n ...track,\n value: track.sizing === 'FIXED' ? track.value * scale : track.value\n }))\n}\n\nfunction scaledVectorNetwork(node: SceneNode, scale: number): SceneNode['vectorNetwork'] {\n if (!node.vectorNetwork) return null\n const network = cloneVectorNetwork(node.vectorNetwork)\n for (const vertex of network.vertices) {\n vertex.x *= scale\n vertex.y *= scale\n }\n for (const segment of network.segments) {\n segment.tangentStart.x *= scale\n segment.tangentStart.y *= scale\n segment.tangentEnd.x *= scale\n segment.tangentEnd.y *= scale\n }\n // A region's own paints scale as the layer's do.\n for (const region of network.regions) {\n if (region.fills) region.fills = scaledFills(region.fills, scale)\n }\n return network\n}\n\nfunction scaledPathText(node: SceneNode, scale: number): Partial<SceneNode> {\n if (!node.textPathData && !followsPath(node)) {\n return {}\n }\n const box = node.textPathBox\n return {\n derivedTextGlyphs:\n copyDerivedGlyphs(node.derivedTextGlyphs)?.map((glyph) => ({\n ...glyph,\n x: glyph.x * scale,\n y: glyph.y * scale,\n fontSize: glyph.fontSize * scale,\n ...(glyph.advance === undefined ? {} : { advance: glyph.advance * scale })\n })) ?? null,\n textPathBox: box && {\n x: box.x * scale,\n y: box.y * scale,\n width: box.width * scale,\n height: box.height * scale\n }\n }\n}\n\nexport function scaleNodeChanges(\n node: SceneNode,\n scale: number,\n scalePosition: boolean\n): Partial<SceneNode> {\n return {\n x: scalePosition ? node.x * scale : node.x,\n y: scalePosition ? node.y * scale : node.y,\n width: node.width * scale,\n height: node.height * scale,\n minWidth: scaledOptional(node.minWidth, scale),\n maxWidth: scaledOptional(node.maxWidth, scale),\n minHeight: scaledOptional(node.minHeight, scale),\n maxHeight: scaledOptional(node.maxHeight, scale),\n cornerRadius: node.cornerRadius * scale,\n topLeftRadius: node.topLeftRadius * scale,\n topRightRadius: node.topRightRadius * scale,\n bottomRightRadius: node.bottomRightRadius * scale,\n bottomLeftRadius: node.bottomLeftRadius * scale,\n fontSize: node.fontSize * scale,\n letterSpacing: scaledTextLength(node.letterSpacing, scale),\n lineHeight: node.lineHeight && scaledTextLength(node.lineHeight, scale),\n textDecorationThickness: scaledOptional(node.textDecorationThickness, scale),\n textUnderlineOffset: scaledOptional(node.textUnderlineOffset, scale),\n styleRuns: scaledStyleRuns(node.styleRuns, scale),\n listSpacing: node.listSpacing * scale,\n paragraphSpacing: node.paragraphSpacing * scale,\n paragraphIndent: node.paragraphIndent * scale,\n textParagraphs: scaledParagraphStyles(node.textParagraphs, scale),\n derivedTextHeight: scaledOptional(node.derivedTextHeight, scale),\n itemSpacing: node.itemSpacing * scale,\n counterAxisSpacing: node.counterAxisSpacing === null ? null : node.counterAxisSpacing * scale,\n paddingTop: node.paddingTop * scale,\n paddingRight: node.paddingRight * scale,\n paddingBottom: node.paddingBottom * scale,\n paddingLeft: node.paddingLeft * scale,\n gridColumnGap: node.gridColumnGap * scale,\n gridRowGap: node.gridRowGap * scale,\n gridTemplateColumns: scaledGridTracks(node.gridTemplateColumns, scale),\n gridTemplateRows: scaledGridTracks(node.gridTemplateRows, scale),\n strokes: scaledStrokes(node.strokes, scale),\n strokeWeight: node.strokeWeight * scale,\n dashPattern: node.dashPattern.map((value) => value * scale),\n borderTopWeight: node.borderTopWeight * scale,\n borderRightWeight: node.borderRightWeight * scale,\n borderBottomWeight: node.borderBottomWeight * scale,\n borderLeftWeight: node.borderLeftWeight * scale,\n strokeMiterLimit: node.strokeMiterLimit,\n effects: scaledEffects(node.effects, scale),\n fills: scaledFills(node.fills, scale),\n layoutGrids: scaledLayoutGrids(node.layoutGrids, scale),\n vectorNetwork: scaledVectorNetwork(node, scale),\n fillGeometry: scaleGeometryPaths(node.fillGeometry, scale, scale),\n strokeGeometry: scaleGeometryPaths(node.strokeGeometry, scale, scale),\n ...scaledPathText(node, scale)\n }\n}\n"],"mappings":";;;;;AAeA,SAAS,eAAe,OAAsB,OAA8B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e,KAAK,yBAAyB,KAAK;EAC3E,qBAAqB,eAAe,KAAK,qBAAqB,KAAK;EACnE,WAAW,gBAAgB,KAAK,WAAW,KAAK;EAChD,aAAa,KAAK,cAAc;EAChC,kBAAkB,KAAK,mBAAmB;EAC1C,iBAAiB,KAAK,kBAAkB;EACxC,gBAAgB,sBAAsB,KAAK,gBAAgB,KAAK;EAChE,mBAAmB,eAAe,KAAK,mBAAmB,KAAK;EAC/D,aAAa,KAAK,cAAc;EAChC,oBAAoB,KAAK,uBAAuB,OAAO,OAAO,KAAK,qBAAqB;EACxF,YAAY,KAAK,aAAa;EAC9B,cAAc,KAAK,eAAe;EAClC,eAAe,KAAK,gBAAgB;EACpC,aAAa,KAAK,cAAc;EAChC,eAAe,KAAK,gBAAgB;EACpC,YAAY,KAAK,aAAa;EAC9B,qBAAqB,iBAAiB,KAAK,qBAAqB,KAAK;EACrE,kBAAkB,iBAAiB,KAAK,kBAAkB,KAAK;EAC/D,SAAS,cAAc,KAAK,SAAS,KAAK;EAC1C,cAAc,KAAK,eAAe;EAClC,aAAa,KAAK,YAAY,KAAK,UAAU,QAAQ,KAAK;EAC1D,iBAAiB,KAAK,kBAAkB;EACxC,mBAAmB,KAAK,oBAAoB;EAC5C,oBAAoB,KAAK,qBAAqB;EAC9C,kBAAkB,KAAK,mBAAmB;EAC1C,kBAAkB,KAAK;EACvB,SAAS,cAAc,KAAK,SAAS,KAAK;EAC1C,OAAO,YAAY,KAAK,OAAO,KAAK;EACpC,aAAa,kBAAkB,KAAK,aAAa,KAAK;EACtD,eAAe,oBAAoB,MAAM,KAAK;EAC9C,cAAc,mBAAmB,KAAK,cAAc,OAAO,KAAK;EAChE,gBAAgB,mBAAmB,KAAK,gBAAgB,OAAO,KAAK;EACpE,GAAG,eAAe,MAAM,KAAK;CAC/B;AACF"}
1
+ {"version":3,"file":"node.js","names":[],"sources":["../../src/scaling/node.ts"],"sourcesContent":["import { pick } from 'es-toolkit/object'\n\nimport { cloneVectorNetwork, copyDerivedGlyphs, scaleGeometryPaths } from '../copy'\nimport { scaledTextLength } from '../text/lengths'\nimport { TEXT_PARAGRAPH_SPACING_FIELDS } from '../text/paragraphs'\nimport { followsPath } from '../text/path'\nimport {\n type Effect,\n type Fill,\n type GridTrack,\n type LayoutGrid,\n type SceneNode,\n type Stroke,\n type StyleRun,\n type TextLength,\n type TextParagraphStyle\n} from '../types'\n\nfunction scaledOptional(value: number | null, scale: number): number | null {\n return value == null ? null : value * scale\n}\n\nfunction scaledStrokes(strokes: readonly Stroke[], scale: number): Stroke[] {\n return strokes.map((stroke) => ({\n ...structuredClone(stroke),\n weight: stroke.weight * scale,\n dashPattern: stroke.dashPattern?.map((value) => value * scale)\n }))\n}\n\nfunction scaledEffects(effects: readonly Effect[], scale: number): Effect[] {\n return effects.map((effect) => ({\n ...structuredClone(effect),\n offset: { x: effect.offset.x * scale, y: effect.offset.y * scale },\n radius: effect.radius * scale,\n spread: effect.spread * scale,\n ...(effect.progressive\n ? {\n progressive: {\n ...structuredClone(effect.progressive),\n startRadius: effect.progressive.startRadius * scale\n }\n }\n : {})\n }))\n}\n\nfunction scaledFills(fills: readonly Fill[], scale: number): Fill[] {\n return fills.map((fill) => ({\n ...structuredClone(fill),\n scale: fill.scale == null ? undefined : fill.scale * scale,\n spacing: fill.spacing == null ? undefined : fill.spacing * scale,\n patternSpacing: fill.patternSpacing\n ? { x: fill.patternSpacing.x * scale, y: fill.patternSpacing.y * scale }\n : undefined,\n noiseSize: fill.noiseSize\n ? { x: fill.noiseSize.x * scale, y: fill.noiseSize.y * scale }\n : undefined\n }))\n}\n\nconst TEXT_STYLE_LENGTH_FIELDS = [\n 'fontSize',\n 'lineHeight',\n 'letterSpacing',\n 'paragraphSpacing',\n 'paragraphIndent',\n 'listSpacing'\n] as const satisfies readonly (keyof SceneNode)[]\n\nconst TEXT_STYLE_LENGTHS: ReadonlySet<string> = new Set(TEXT_STYLE_LENGTH_FIELDS)\n\nexport function isTextStyleLength(field: string): boolean {\n return TEXT_STYLE_LENGTHS.has(field)\n}\n\nfunction isTextLength(value: unknown): value is TextLength {\n return typeof value === 'object' && value !== null && 'unit' in value && 'value' in value\n}\n\nfunction lengthAtScale(value: unknown, scale: number): unknown {\n if (typeof value === 'number') {\n return value * scale\n }\n return isTextLength(value) ? scaledTextLength(value, scale) : value\n}\n\nexport function scaledTextStyleLengths<Values extends object>(\n values: Values,\n scale: number\n): Values {\n const scaled = { ...values }\n for (const [field, value] of Object.entries(values)) {\n if (isTextStyleLength(field)) {\n Object.assign(scaled, { [field]: lengthAtScale(value, scale) })\n }\n }\n return scaled\n}\n\nfunction scaledStyleRuns(styleRuns: readonly StyleRun[], scale: number): StyleRun[] {\n return styleRuns.map((run) => ({\n ...structuredClone(run),\n style: {\n ...structuredClone(run.style),\n fontSize: run.style.fontSize == null ? undefined : run.style.fontSize * scale,\n letterSpacing: run.style.letterSpacing && scaledTextLength(run.style.letterSpacing, scale),\n lineHeight: run.style.lineHeight && scaledTextLength(run.style.lineHeight, scale),\n textDecorationThickness: scaledOptional(run.style.textDecorationThickness ?? null, scale),\n textUnderlineOffset: scaledOptional(run.style.textUnderlineOffset ?? null, scale)\n }\n }))\n}\n\nfunction scaledParagraphStyles(\n paragraphs: readonly TextParagraphStyle[],\n scale: number\n): TextParagraphStyle[] {\n return paragraphs.map((style) => {\n const scaled = { ...style }\n for (const field of TEXT_PARAGRAPH_SPACING_FIELDS) {\n const value = style[field]\n if (value !== undefined) scaled[field] = value * scale\n }\n return scaled\n })\n}\n\nfunction scaledLayoutGrids(grids: readonly LayoutGrid[], scale: number): LayoutGrid[] {\n return grids.map((grid) => ({\n ...structuredClone(grid),\n offset: grid.offset == null ? undefined : grid.offset * scale,\n sectionSize: grid.sectionSize == null ? undefined : grid.sectionSize * scale,\n gutterSize: grid.gutterSize == null ? undefined : grid.gutterSize * scale\n }))\n}\n\nfunction scaledGridTracks(tracks: readonly GridTrack[], scale: number): GridTrack[] {\n return tracks.map((track) => ({\n ...track,\n value: track.sizing === 'FIXED' ? track.value * scale : track.value\n }))\n}\n\nfunction scaledVectorNetwork(node: SceneNode, scale: number): SceneNode['vectorNetwork'] {\n if (!node.vectorNetwork) return null\n const network = cloneVectorNetwork(node.vectorNetwork)\n for (const vertex of network.vertices) {\n vertex.x *= scale\n vertex.y *= scale\n }\n for (const segment of network.segments) {\n segment.tangentStart.x *= scale\n segment.tangentStart.y *= scale\n segment.tangentEnd.x *= scale\n segment.tangentEnd.y *= scale\n }\n // A region's own paints scale as the layer's do.\n for (const region of network.regions) {\n if (region.fills) region.fills = scaledFills(region.fills, scale)\n }\n return network\n}\n\nfunction scaledPathText(node: SceneNode, scale: number): Partial<SceneNode> {\n if (!node.textPathData && !followsPath(node)) {\n return {}\n }\n const box = node.textPathBox\n return {\n derivedTextGlyphs:\n copyDerivedGlyphs(node.derivedTextGlyphs)?.map((glyph) => ({\n ...glyph,\n x: glyph.x * scale,\n y: glyph.y * scale,\n fontSize: glyph.fontSize * scale,\n ...(glyph.advance === undefined ? {} : { advance: glyph.advance * scale })\n })) ?? null,\n textPathBox: box && {\n x: box.x * scale,\n y: box.y * scale,\n width: box.width * scale,\n height: box.height * scale\n }\n }\n}\n\nexport function scaleNodeChanges(\n node: SceneNode,\n scale: number,\n scalePosition: boolean\n): Partial<SceneNode> {\n return {\n x: scalePosition ? node.x * scale : node.x,\n y: scalePosition ? node.y * scale : node.y,\n width: node.width * scale,\n height: node.height * scale,\n minWidth: scaledOptional(node.minWidth, scale),\n maxWidth: scaledOptional(node.maxWidth, scale),\n minHeight: scaledOptional(node.minHeight, scale),\n maxHeight: scaledOptional(node.maxHeight, scale),\n cornerRadius: node.cornerRadius * scale,\n topLeftRadius: node.topLeftRadius * scale,\n topRightRadius: node.topRightRadius * scale,\n bottomRightRadius: node.bottomRightRadius * scale,\n bottomLeftRadius: node.bottomLeftRadius * scale,\n ...scaledTextStyleLengths(pick(node, TEXT_STYLE_LENGTH_FIELDS), scale),\n textDecorationThickness: scaledOptional(node.textDecorationThickness, scale),\n textUnderlineOffset: scaledOptional(node.textUnderlineOffset, scale),\n styleRuns: scaledStyleRuns(node.styleRuns, scale),\n textParagraphs: scaledParagraphStyles(node.textParagraphs, scale),\n derivedTextHeight: scaledOptional(node.derivedTextHeight, scale),\n itemSpacing: node.itemSpacing * scale,\n counterAxisSpacing: node.counterAxisSpacing === null ? null : node.counterAxisSpacing * scale,\n paddingTop: node.paddingTop * scale,\n paddingRight: node.paddingRight * scale,\n paddingBottom: node.paddingBottom * scale,\n paddingLeft: node.paddingLeft * scale,\n gridColumnGap: node.gridColumnGap * scale,\n gridRowGap: node.gridRowGap * scale,\n gridTemplateColumns: scaledGridTracks(node.gridTemplateColumns, scale),\n gridTemplateRows: scaledGridTracks(node.gridTemplateRows, scale),\n strokes: scaledStrokes(node.strokes, scale),\n strokeWeight: node.strokeWeight * scale,\n dashPattern: node.dashPattern.map((value) => value * scale),\n borderTopWeight: node.borderTopWeight * scale,\n borderRightWeight: node.borderRightWeight * scale,\n borderBottomWeight: node.borderBottomWeight * scale,\n borderLeftWeight: node.borderLeftWeight * scale,\n strokeMiterLimit: node.strokeMiterLimit,\n effects: scaledEffects(node.effects, scale),\n fills: scaledFills(node.fills, scale),\n layoutGrids: scaledLayoutGrids(node.layoutGrids, scale),\n vectorNetwork: scaledVectorNetwork(node, scale),\n fillGeometry: scaleGeometryPaths(node.fillGeometry, scale, scale),\n strokeGeometry: scaleGeometryPaths(node.strokeGeometry, scale, scale),\n ...scaledPathText(node, scale)\n }\n}\n"],"mappings":";;;;;;AAkBA,SAAS,eAAe,OAAsB,OAA8B;CAC1E,OAAO,SAAS,OAAO,OAAO,QAAQ;AACxC;AAEA,SAAS,cAAc,SAA4B,OAAyB;CAC1E,OAAO,QAAQ,KAAK,YAAY;EAC9B,GAAG,gBAAgB,MAAM;EACzB,QAAQ,OAAO,SAAS;EACxB,aAAa,OAAO,aAAa,KAAK,UAAU,QAAQ,KAAK;CAC/D,EAAE;AACJ;AAEA,SAAS,cAAc,SA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AAc,mBAAmB,KAAK,cAAc,OAAO,KAAK;EAChE,gBAAgB,mBAAmB,KAAK,gBAAgB,OAAO,KAAK;EACpE,GAAG,eAAe,MAAM,KAAK;CAC/B;AACF"}
@@ -1,4 +1,3 @@
1
1
  import { ShaderComponent, ShaderPaint, ShaderPreset, shaderPaintSchema, shaderPresetSchema } from "./schema.js";
2
- import { createShaderPaint, hasShaderPaint, isShaderFrameCurrent, readShaderPaints, shaderOfPaint, shaderPresetKey, withShaderPaints } from "./model.js";
3
- import { ShaderFrameEncoding, shaderFrameEncoding, shaderFramePixels } from "./still.js";
4
- export { ShaderComponent, ShaderFrameEncoding, ShaderPaint, ShaderPreset, createShaderPaint, hasShaderPaint, isShaderFrameCurrent, readShaderPaints, shaderFrameEncoding, shaderFramePixels, shaderOfPaint, shaderPaintSchema, shaderPresetKey, shaderPresetSchema, withShaderPaints };
2
+ import { createShaderPaint, hasShaderPaint, isShaderFrameCurrent, readShaderPaints, shaderOfPaint, withShaderPaints } from "./model.js";
3
+ export { ShaderComponent, ShaderPaint, ShaderPreset, createShaderPaint, hasShaderPaint, isShaderFrameCurrent, readShaderPaints, shaderOfPaint, shaderPaintSchema, shaderPresetSchema, withShaderPaints };
@@ -1,4 +1,3 @@
1
1
  import { shaderPaintSchema, shaderPresetSchema } from "./schema.js";
2
- import { createShaderPaint, hasShaderPaint, isShaderFrameCurrent, readShaderPaints, shaderOfPaint, shaderPresetKey, withShaderPaints } from "./model.js";
3
- import { shaderFrameEncoding, shaderFramePixels } from "./still.js";
4
- export { createShaderPaint, hasShaderPaint, isShaderFrameCurrent, readShaderPaints, shaderFrameEncoding, shaderFramePixels, shaderOfPaint, shaderPaintSchema, shaderPresetKey, shaderPresetSchema, withShaderPaints };
2
+ import { createShaderPaint, hasShaderPaint, isShaderFrameCurrent, readShaderPaints, shaderOfPaint, withShaderPaints } from "./model.js";
3
+ export { createShaderPaint, hasShaderPaint, isShaderFrameCurrent, readShaderPaints, shaderOfPaint, shaderPaintSchema, shaderPresetSchema, withShaderPaints };
@@ -18,24 +18,16 @@ declare function hasShaderPaint(node: ShaderNode): boolean;
18
18
  * stroke of `paints` still shows, so removing or replacing a paint leaves no entry behind.
19
19
  */
20
20
  declare function withShaderPaints(node: Pick<SceneNode, 'pluginData'>, paints: readonly Fill[], shaders?: readonly ShaderPaint[]): SceneNode['pluginData'];
21
- /**
22
- * A new paint that draws `preset`, and the shader entry it shows. Its image names a frame not yet
23
- * rendered, unique to this paint, so no other paint's entry claims it until the frame is drawn.
24
- */
21
+ /** A new paint that draws `preset`, and the shader entry it shows (`createStillPaint`). */
25
22
  declare function createShaderPaint(preset: ShaderPreset): {
26
23
  paint: Fill;
27
24
  shader: ShaderPaint;
28
25
  };
29
- /** A short key that tells one preset from another, which a rendered frame records. */
30
- declare function shaderPresetKey(preset: ShaderPreset): string;
31
- /**
32
- * Whether a shader's frame was rendered for its preset at the size `node` has now, so undoing a
33
- * preset change after reopening the document does not keep a frame of the newer preset.
34
- */
26
+ /** Whether a shader's frame was rendered for its preset at the size `node` has now. */
35
27
  declare function isShaderFrameCurrent(shader: ShaderPaint, size: {
36
28
  width: number;
37
29
  height: number;
38
30
  }): boolean;
39
31
  //#endregion
40
- export { createShaderPaint, hasShaderPaint, isShaderFrameCurrent, readShaderPaints, shaderOfPaint, shaderPresetKey, withShaderPaints };
32
+ export { createShaderPaint, hasShaderPaint, isShaderFrameCurrent, readShaderPaints, shaderOfPaint, withShaderPaints };
41
33
  //# sourceMappingURL=model.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"model.d.ts","names":[],"sources":["../../src/shaders/model.ts"],"mappings":";;;;KAaK,aAAa,KAAK;;iBAGP,iBAAiB,MAAM,KAAK,2BAA2B;;;;;;iBASvD,cACd,MAAM,KAAK,0BACX,OAAO,OACN;;iBAMa,eAAe,MAAM;;;;;iBAQrB,iBACd,MAAM,KAAK,0BACX,iBAAiB,QACjB,mBAAkB,gBACjB;;;;;iBAea,kBAAkB,QAAQ;EACxC,OAAO;EACP,QAAQ;;;iBAiBM,gBAAgB,QAAQ;;;;;iBAQxB,qBACd,QAAQ,aACR;EAAQ;EAAe"}
1
+ {"version":3,"file":"model.d.ts","names":[],"sources":["../../src/shaders/model.ts"],"mappings":";;;;KAaK,aAAa,KAAK;;iBAGP,iBAAiB,MAAM,KAAK,2BAA2B;;;;;;iBASvD,cACd,MAAM,KAAK,0BACX,OAAO,OACN;;iBAKa,eAAe,MAAM;;;;;iBAQrB,iBACd,MAAM,KAAK,0BACX,iBAAiB,QACjB,mBAAkB,gBACjB;;iBAKa,kBAAkB,QAAQ;EACxC,OAAO;EACP,QAAQ;;;iBAOM,qBACd,QAAQ,aACR;EAAQ;EAAe"}