@pairdraw/core 0.21.1 → 0.22.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 (601) hide show
  1. package/dist/canvas/boolean.d.ts +6 -1
  2. package/dist/canvas/boolean.d.ts.map +1 -1
  3. package/dist/canvas/boolean.js +10 -2
  4. package/dist/canvas/boolean.js.map +1 -1
  5. package/dist/canvas/color-space.d.ts +45 -0
  6. package/dist/canvas/color-space.d.ts.map +1 -0
  7. package/dist/canvas/color-space.js +39 -0
  8. package/dist/canvas/color-space.js.map +1 -0
  9. package/dist/canvas/fills.d.ts +10 -10
  10. package/dist/canvas/fills.d.ts.map +1 -1
  11. package/dist/canvas/fills.js +116 -62
  12. package/dist/canvas/fills.js.map +1 -1
  13. package/dist/canvas/flatten.d.ts +11 -3
  14. package/dist/canvas/flatten.d.ts.map +1 -1
  15. package/dist/canvas/flatten.js +62 -4
  16. package/dist/canvas/flatten.js.map +1 -1
  17. package/dist/canvas/images/previews.d.ts +1 -1
  18. package/dist/canvas/index.d.ts +2 -1
  19. package/dist/canvas/index.js +2 -1
  20. package/dist/canvas/layout-grids.d.ts +5 -2
  21. package/dist/canvas/layout-grids.d.ts.map +1 -1
  22. package/dist/canvas/layout-grids.js +7 -2
  23. package/dist/canvas/layout-grids.js.map +1 -1
  24. package/dist/canvas/noise/render.d.ts +17 -4
  25. package/dist/canvas/noise/render.d.ts.map +1 -1
  26. package/dist/canvas/noise/render.js +21 -6
  27. package/dist/canvas/noise/render.js.map +1 -1
  28. package/dist/canvas/noise/shader.d.ts +4 -4
  29. package/dist/canvas/noise/shader.d.ts.map +1 -1
  30. package/dist/canvas/noise/shader.js +5 -6
  31. package/dist/canvas/noise/shader.js.map +1 -1
  32. package/dist/canvas/overlays/annotations.d.ts +19 -0
  33. package/dist/canvas/overlays/annotations.d.ts.map +1 -0
  34. package/dist/canvas/overlays/annotations.js +110 -0
  35. package/dist/canvas/overlays/annotations.js.map +1 -0
  36. package/dist/canvas/overlays/auto-layout-hover.d.ts +11 -1
  37. package/dist/canvas/overlays/auto-layout-hover.d.ts.map +1 -1
  38. package/dist/canvas/overlays/auto-layout-hover.js +25 -1
  39. package/dist/canvas/overlays/auto-layout-hover.js.map +1 -1
  40. package/dist/canvas/overlays/feedback.js +1 -1
  41. package/dist/canvas/overlays/feedback.js.map +1 -1
  42. package/dist/canvas/overlays/index.d.ts +2 -2
  43. package/dist/canvas/overlays/index.js +2 -2
  44. package/dist/canvas/overlays/measurement.d.ts +7 -1
  45. package/dist/canvas/overlays/measurement.d.ts.map +1 -1
  46. package/dist/canvas/overlays/measurement.js +42 -4
  47. package/dist/canvas/overlays/measurement.js.map +1 -1
  48. package/dist/canvas/overlays/presence.d.ts.map +1 -1
  49. package/dist/canvas/overlays/presence.js +21 -24
  50. package/dist/canvas/overlays/presence.js.map +1 -1
  51. package/dist/canvas/renderer/colors.d.ts +7 -1
  52. package/dist/canvas/renderer/colors.d.ts.map +1 -1
  53. package/dist/canvas/renderer/colors.js +9 -1
  54. package/dist/canvas/renderer/colors.js.map +1 -1
  55. package/dist/canvas/renderer/document-surface.d.ts +15 -6
  56. package/dist/canvas/renderer/document-surface.d.ts.map +1 -1
  57. package/dist/canvas/renderer/document-surface.js +1 -0
  58. package/dist/canvas/renderer/document-surface.js.map +1 -1
  59. package/dist/canvas/renderer/lifecycle.d.ts.map +1 -1
  60. package/dist/canvas/renderer/lifecycle.js +2 -2
  61. package/dist/canvas/renderer/lifecycle.js.map +1 -1
  62. package/dist/canvas/renderer/methods.d.ts +1 -0
  63. package/dist/canvas/renderer/methods.d.ts.map +1 -1
  64. package/dist/canvas/renderer/methods.js +4 -1
  65. package/dist/canvas/renderer/methods.js.map +1 -1
  66. package/dist/canvas/renderer/overlay-pass.d.ts.map +1 -1
  67. package/dist/canvas/renderer/overlay-pass.js +6 -1
  68. package/dist/canvas/renderer/overlay-pass.js.map +1 -1
  69. package/dist/canvas/renderer/pipeline.d.ts.map +1 -1
  70. package/dist/canvas/renderer/pipeline.js +7 -0
  71. package/dist/canvas/renderer/pipeline.js.map +1 -1
  72. package/dist/canvas/renderer/types.d.ts +10 -0
  73. package/dist/canvas/renderer/types.d.ts.map +1 -1
  74. package/dist/canvas/renderer.d.ts +10 -2
  75. package/dist/canvas/renderer.d.ts.map +1 -1
  76. package/dist/canvas/renderer.js +15 -3
  77. package/dist/canvas/renderer.js.map +1 -1
  78. package/dist/canvas/scene.d.ts.map +1 -1
  79. package/dist/canvas/scene.js +9 -9
  80. package/dist/canvas/scene.js.map +1 -1
  81. package/dist/clipboard/pairdraw.d.ts.map +1 -1
  82. package/dist/clipboard/pairdraw.js +1 -0
  83. package/dist/clipboard/pairdraw.js.map +1 -1
  84. package/dist/editor/bridges/clipboard.d.ts +2 -0
  85. package/dist/editor/bridges/clipboard.d.ts.map +1 -1
  86. package/dist/editor/bridges/clipboard.js +1 -0
  87. package/dist/editor/bridges/clipboard.js.map +1 -1
  88. package/dist/editor/bridges/components.d.ts +14 -7
  89. package/dist/editor/bridges/components.d.ts.map +1 -1
  90. package/dist/editor/bridges/components.js +6 -0
  91. package/dist/editor/bridges/components.js.map +1 -1
  92. package/dist/editor/bridges/structure.d.ts +1 -1
  93. package/dist/editor/bridges/structure.d.ts.map +1 -1
  94. package/dist/editor/bridges/undo.d.ts +1 -1
  95. package/dist/editor/clipboard/code.d.ts +32 -0
  96. package/dist/editor/clipboard/code.d.ts.map +1 -0
  97. package/dist/editor/clipboard/code.js +30 -0
  98. package/dist/editor/clipboard/code.js.map +1 -0
  99. package/dist/editor/clipboard/paste/dependencies.d.ts +14 -0
  100. package/dist/editor/clipboard/paste/dependencies.d.ts.map +1 -0
  101. package/dist/editor/clipboard/paste/dependencies.js +0 -0
  102. package/dist/editor/clipboard/paste/run.d.ts +14 -0
  103. package/dist/editor/clipboard/paste/run.d.ts.map +1 -0
  104. package/dist/editor/clipboard/paste/run.js +47 -0
  105. package/dist/editor/clipboard/paste/run.js.map +1 -0
  106. package/dist/editor/clipboard/styled.d.ts +2 -8
  107. package/dist/editor/clipboard/styled.d.ts.map +1 -1
  108. package/dist/editor/clipboard/styled.js +2 -32
  109. package/dist/editor/clipboard/styled.js.map +1 -1
  110. package/dist/editor/clipboard.d.ts +2 -0
  111. package/dist/editor/clipboard.d.ts.map +1 -1
  112. package/dist/editor/clipboard.js +34 -0
  113. package/dist/editor/clipboard.js.map +1 -1
  114. package/dist/editor/components/instances.d.ts +5 -0
  115. package/dist/editor/components/instances.d.ts.map +1 -1
  116. package/dist/editor/components/instances.js +69 -4
  117. package/dist/editor/components/instances.js.map +1 -1
  118. package/dist/editor/components/slots/index.d.ts.map +1 -1
  119. package/dist/editor/components/slots/index.js +7 -0
  120. package/dist/editor/components/slots/index.js.map +1 -1
  121. package/dist/editor/components.d.ts +6 -0
  122. package/dist/editor/components.d.ts.map +1 -1
  123. package/dist/editor/components.js +14 -2
  124. package/dist/editor/components.js.map +1 -1
  125. package/dist/editor/create.d.ts +30 -3
  126. package/dist/editor/create.d.ts.map +1 -1
  127. package/dist/editor/create.js +11 -2
  128. package/dist/editor/create.js.map +1 -1
  129. package/dist/editor/design-tokens.d.ts +1 -1
  130. package/dist/editor/design-tokens.d.ts.map +1 -1
  131. package/dist/editor/design-tokens.js +4 -18
  132. package/dist/editor/design-tokens.js.map +1 -1
  133. package/dist/editor/image-edit.d.ts.map +1 -1
  134. package/dist/editor/image-edit.js +1 -2
  135. package/dist/editor/image-edit.js.map +1 -1
  136. package/dist/editor/index.d.ts +4 -4
  137. package/dist/editor/index.js +1 -1
  138. package/dist/editor/layout-mode.d.ts +3 -1
  139. package/dist/editor/layout-mode.d.ts.map +1 -1
  140. package/dist/editor/layout-mode.js +97 -2
  141. package/dist/editor/layout-mode.js.map +1 -1
  142. package/dist/editor/nodes.d.ts +2 -0
  143. package/dist/editor/nodes.d.ts.map +1 -1
  144. package/dist/editor/nodes.js +22 -7
  145. package/dist/editor/nodes.js.map +1 -1
  146. package/dist/editor/read-only/actions.js +6 -0
  147. package/dist/editor/read-only/actions.js.map +1 -1
  148. package/dist/editor/selection/overlays.d.ts +1 -0
  149. package/dist/editor/selection/overlays.d.ts.map +1 -1
  150. package/dist/editor/selection/overlays.js +7 -0
  151. package/dist/editor/selection/overlays.js.map +1 -1
  152. package/dist/editor/selection/read.d.ts +8 -0
  153. package/dist/editor/selection.d.ts +9 -0
  154. package/dist/editor/selection.d.ts.map +1 -1
  155. package/dist/editor/state/shared.js +1 -0
  156. package/dist/editor/state/shared.js.map +1 -1
  157. package/dist/editor/state/view.d.ts.map +1 -1
  158. package/dist/editor/state/view.js +2 -0
  159. package/dist/editor/state/view.js.map +1 -1
  160. package/dist/editor/structure/boolean.d.ts +1 -1
  161. package/dist/editor/structure/boolean.d.ts.map +1 -1
  162. package/dist/editor/structure/boolean.js +20 -1
  163. package/dist/editor/structure/boolean.js.map +1 -1
  164. package/dist/editor/structure/container-wrap.d.ts +8 -2
  165. package/dist/editor/structure/container-wrap.d.ts.map +1 -1
  166. package/dist/editor/structure/container-wrap.js +17 -5
  167. package/dist/editor/structure/container-wrap.js.map +1 -1
  168. package/dist/editor/structure/flatten.d.ts.map +1 -1
  169. package/dist/editor/structure/flatten.js +8 -7
  170. package/dist/editor/structure/flatten.js.map +1 -1
  171. package/dist/editor/structure/group/ungroup.d.ts.map +1 -1
  172. package/dist/editor/structure/group/ungroup.js +2 -0
  173. package/dist/editor/structure/group/ungroup.js.map +1 -1
  174. package/dist/editor/structure/outline-stroke.d.ts.map +1 -1
  175. package/dist/editor/structure/outline-stroke.js +5 -0
  176. package/dist/editor/structure/outline-stroke.js.map +1 -1
  177. package/dist/editor/structure.d.ts +1 -1
  178. package/dist/editor/structure.d.ts.map +1 -1
  179. package/dist/editor/styles.d.ts +26 -0
  180. package/dist/editor/styles.d.ts.map +1 -0
  181. package/dist/editor/styles.js +127 -0
  182. package/dist/editor/styles.js.map +1 -0
  183. package/dist/editor/text/selection-style.d.ts +1 -0
  184. package/dist/editor/text/selection-style.d.ts.map +1 -1
  185. package/dist/editor/text/selection-style.js +10 -2
  186. package/dist/editor/text/selection-style.js.map +1 -1
  187. package/dist/editor/tool-registry.d.ts.map +1 -1
  188. package/dist/editor/tool-registry.js +6 -0
  189. package/dist/editor/tool-registry.js.map +1 -1
  190. package/dist/editor/types.d.ts +14 -2
  191. package/dist/editor/types.d.ts.map +1 -1
  192. package/dist/editor/variable-bindings.d.ts.map +1 -1
  193. package/dist/editor/variable-bindings.js +6 -1
  194. package/dist/editor/variable-bindings.js.map +1 -1
  195. package/dist/figma-api/accessors/basic.d.ts.map +1 -1
  196. package/dist/figma-api/accessors/basic.js +22 -1
  197. package/dist/figma-api/accessors/basic.js.map +1 -1
  198. package/dist/figma-api/accessors/shape.js +1 -1
  199. package/dist/figma-api/accessors/text/index.js +1 -1
  200. package/dist/figma-api/accessors/text/ranges.js +1 -1
  201. package/dist/figma-api/accessors/text/references.js +1 -1
  202. package/dist/figma-api/accessors/variables.js +1 -1
  203. package/dist/figma-api/accessors/vector.d.ts.map +1 -1
  204. package/dist/figma-api/accessors/vector.js +8 -22
  205. package/dist/figma-api/accessors/vector.js.map +1 -1
  206. package/dist/figma-api/accessors/visual.js +1 -1
  207. package/dist/figma-api/compatibility.d.ts +1 -1
  208. package/dist/figma-api/compatibility.d.ts.map +1 -1
  209. package/dist/figma-api/component-scope.d.ts +14 -0
  210. package/dist/figma-api/component-scope.d.ts.map +1 -0
  211. package/dist/figma-api/component-scope.js +28 -0
  212. package/dist/figma-api/component-scope.js.map +1 -0
  213. package/dist/figma-api/components.d.ts.map +1 -1
  214. package/dist/figma-api/components.js +26 -2
  215. package/dist/figma-api/components.js.map +1 -1
  216. package/dist/figma-api/flatten.js +3 -3
  217. package/dist/figma-api/flatten.js.map +1 -1
  218. package/dist/figma-api/index.d.ts +77 -6
  219. package/dist/figma-api/index.d.ts.map +1 -1
  220. package/dist/figma-api/index.js +188 -2
  221. package/dist/figma-api/index.js.map +1 -1
  222. package/dist/figma-api/node-types.d.ts +2 -1
  223. package/dist/figma-api/node-types.d.ts.map +1 -1
  224. package/dist/figma-api/overrides.d.ts +26 -1
  225. package/dist/figma-api/overrides.d.ts.map +1 -1
  226. package/dist/figma-api/overrides.js +157 -10
  227. package/dist/figma-api/overrides.js.map +1 -1
  228. package/dist/figma-api/proxy.d.ts +2 -0
  229. package/dist/figma-api/proxy.d.ts.map +1 -1
  230. package/dist/figma-api/proxy.js +10 -2
  231. package/dist/figma-api/proxy.js.map +1 -1
  232. package/dist/figma-api/reactions.d.ts +65 -9
  233. package/dist/figma-api/reactions.d.ts.map +1 -1
  234. package/dist/figma-api/reactions.js +144 -11
  235. package/dist/figma-api/reactions.js.map +1 -1
  236. package/dist/figma-api/shape-with-text.js +1 -1
  237. package/dist/figma-api/slots.d.ts +3 -1
  238. package/dist/figma-api/slots.d.ts.map +1 -1
  239. package/dist/figma-api/slots.js +9 -8
  240. package/dist/figma-api/slots.js.map +1 -1
  241. package/dist/index.d.ts +4 -4
  242. package/dist/index.js +1 -1
  243. package/dist/io/formats/code/detect.d.ts +23 -0
  244. package/dist/io/formats/code/detect.d.ts.map +1 -0
  245. package/dist/io/formats/code/detect.js +46 -0
  246. package/dist/io/formats/code/detect.js.map +1 -0
  247. package/dist/io/formats/code/index.d.ts +5 -0
  248. package/dist/io/formats/code/index.js +5 -0
  249. package/dist/io/formats/code/read.d.ts +45 -0
  250. package/dist/io/formats/code/read.d.ts.map +1 -0
  251. package/dist/io/formats/code/read.js +86 -0
  252. package/dist/io/formats/code/read.js.map +1 -0
  253. package/dist/io/formats/code/stylesheet.d.ts +13 -0
  254. package/dist/io/formats/code/stylesheet.d.ts.map +1 -0
  255. package/dist/io/formats/code/stylesheet.js +21 -0
  256. package/dist/io/formats/code/stylesheet.js.map +1 -0
  257. package/dist/io/formats/code/tokens.d.ts +18 -0
  258. package/dist/io/formats/code/tokens.d.ts.map +1 -0
  259. package/dist/io/formats/code/tokens.js +135 -0
  260. package/dist/io/formats/code/tokens.js.map +1 -0
  261. package/dist/io/formats/design-tokens/apply.d.ts +7 -3
  262. package/dist/io/formats/design-tokens/apply.d.ts.map +1 -1
  263. package/dist/io/formats/design-tokens/apply.js.map +1 -1
  264. package/dist/io/formats/fig/export/patch/fields.js +5 -0
  265. package/dist/io/formats/fig/export/patch/fields.js.map +1 -1
  266. package/dist/io/formats/fig/export/patch/index.d.ts.map +1 -1
  267. package/dist/io/formats/fig/export/patch/index.js +20 -20
  268. package/dist/io/formats/fig/export/patch/index.js.map +1 -1
  269. package/dist/io/formats/fig/export/setup.d.ts.map +1 -1
  270. package/dist/io/formats/fig/export/setup.js +5 -1
  271. package/dist/io/formats/fig/export/setup.js.map +1 -1
  272. package/dist/io/formats/fig/index.d.ts +3 -2
  273. package/dist/io/formats/fig/index.js +2 -2
  274. package/dist/io/formats/fig/read.d.ts.map +1 -1
  275. package/dist/io/formats/fig/read.js +5 -2
  276. package/dist/io/formats/fig/read.js.map +1 -1
  277. package/dist/io/formats/html/layers.d.ts +3 -1
  278. package/dist/io/formats/html/layers.d.ts.map +1 -1
  279. package/dist/io/formats/html/layers.js +6 -1
  280. package/dist/io/formats/html/layers.js.map +1 -1
  281. package/dist/io/formats/pdf/export.d.ts.map +1 -1
  282. package/dist/io/formats/pdf/export.js +7 -3
  283. package/dist/io/formats/pdf/export.js.map +1 -1
  284. package/dist/io/formats/pdf/plan.d.ts +3 -0
  285. package/dist/io/formats/pdf/plan.d.ts.map +1 -1
  286. package/dist/io/formats/pdf/plan.js +60 -36
  287. package/dist/io/formats/pdf/plan.js.map +1 -1
  288. package/dist/io/formats/raster/headless.d.ts.map +1 -1
  289. package/dist/io/formats/raster/headless.js +3 -2
  290. package/dist/io/formats/raster/headless.js.map +1 -1
  291. package/dist/io/formats/raster/index.d.ts +2 -2
  292. package/dist/io/formats/raster/index.js +2 -2
  293. package/dist/io/formats/raster/render.d.ts +10 -2
  294. package/dist/io/formats/raster/render.d.ts.map +1 -1
  295. package/dist/io/formats/raster/render.js +35 -9
  296. package/dist/io/formats/raster/render.js.map +1 -1
  297. package/dist/io/formats/svg/defs.d.ts.map +1 -1
  298. package/dist/io/formats/svg/defs.js +19 -1
  299. package/dist/io/formats/svg/defs.js.map +1 -1
  300. package/dist/io/formats/svg/export.d.ts +5 -2
  301. package/dist/io/formats/svg/export.d.ts.map +1 -1
  302. package/dist/io/formats/svg/export.js +59 -10
  303. package/dist/io/formats/svg/export.js.map +1 -1
  304. package/dist/io/formats/svg/index.d.ts +2 -2
  305. package/dist/io/formats/svg/index.js +2 -2
  306. package/dist/io/formats/svg/text/layout.d.ts.map +1 -1
  307. package/dist/io/formats/svg/text/layout.js +4 -2
  308. package/dist/io/formats/svg/text/layout.js.map +1 -1
  309. package/dist/io/formats/video/record.d.ts.map +1 -1
  310. package/dist/io/formats/video/record.js +24 -9
  311. package/dist/io/formats/video/record.js.map +1 -1
  312. package/dist/io/formats.d.ts.map +1 -1
  313. package/dist/io/formats.js +20 -13
  314. package/dist/io/formats.js.map +1 -1
  315. package/dist/kiwi/fig/population/client.d.ts.map +1 -1
  316. package/dist/kiwi/fig/population/client.js +2 -1
  317. package/dist/kiwi/fig/population/client.js.map +1 -1
  318. package/dist/kiwi/fig/session/document-state.d.ts +46 -2
  319. package/dist/kiwi/fig/session/document-state.d.ts.map +1 -1
  320. package/dist/kiwi/fig/session/document-state.js +113 -5
  321. package/dist/kiwi/fig/session/document-state.js.map +1 -1
  322. package/dist/kiwi/fig/session/options.d.ts +4 -0
  323. package/dist/kiwi/fig/session/options.d.ts.map +1 -1
  324. package/dist/kiwi/fig/session/options.js.map +1 -1
  325. package/dist/layout/apply.d.ts.map +1 -1
  326. package/dist/layout/apply.js +8 -4
  327. package/dist/layout/apply.js.map +1 -1
  328. package/dist/layout/auto-layout-handles.js +1 -1
  329. package/dist/layout/auto-layout-handles.js.map +1 -1
  330. package/dist/layout/axis-sizing.d.ts.map +1 -1
  331. package/dist/layout/axis-sizing.js +1 -1
  332. package/dist/layout/axis-sizing.js.map +1 -1
  333. package/dist/layout/derived.d.ts.map +1 -1
  334. package/dist/layout/derived.js +1 -1
  335. package/dist/layout/derived.js.map +1 -1
  336. package/dist/layout/effective-generated-text.js +1 -1
  337. package/dist/layout/effective-generated-text.js.map +1 -1
  338. package/dist/layout/grid.d.ts +3 -1
  339. package/dist/layout/grid.d.ts.map +1 -1
  340. package/dist/layout/grid.js +57 -16
  341. package/dist/layout/grid.js.map +1 -1
  342. package/dist/layout.d.ts +1 -1
  343. package/dist/layout.js +6 -5
  344. package/dist/layout.js.map +1 -1
  345. package/dist/node/fs.d.ts.map +1 -1
  346. package/dist/node/fs.js +28 -7
  347. package/dist/node/fs.js.map +1 -1
  348. package/dist/prototype/easing.d.ts +13 -5
  349. package/dist/prototype/easing.d.ts.map +1 -1
  350. package/dist/prototype/easing.js +46 -6
  351. package/dist/prototype/easing.js.map +1 -1
  352. package/dist/prototype/scenes.d.ts +31 -0
  353. package/dist/prototype/scenes.d.ts.map +1 -1
  354. package/dist/prototype/scenes.js +220 -31
  355. package/dist/prototype/scenes.js.map +1 -1
  356. package/dist/prototype/session.d.ts.map +1 -1
  357. package/dist/prototype/session.js +1 -0
  358. package/dist/prototype/session.js.map +1 -1
  359. package/dist/prototype/smart-animate/animation.d.ts +2 -1
  360. package/dist/prototype/smart-animate/animation.d.ts.map +1 -1
  361. package/dist/prototype/smart-animate/animation.js +2 -2
  362. package/dist/prototype/smart-animate/animation.js.map +1 -1
  363. package/dist/prototype/timeline.d.ts +10 -1
  364. package/dist/prototype/timeline.d.ts.map +1 -1
  365. package/dist/prototype/timeline.js +69 -23
  366. package/dist/prototype/timeline.js.map +1 -1
  367. package/dist/prototype/variables.d.ts +23 -0
  368. package/dist/prototype/variables.d.ts.map +1 -0
  369. package/dist/prototype/variables.js +237 -0
  370. package/dist/prototype/variables.js.map +1 -0
  371. package/dist/rpc/read-commands.d.ts +5 -0
  372. package/dist/rpc/read-commands.d.ts.map +1 -1
  373. package/dist/rpc/read-commands.js +4 -1
  374. package/dist/rpc/read-commands.js.map +1 -1
  375. package/dist/text/character-style.d.ts +8 -1
  376. package/dist/text/character-style.d.ts.map +1 -1
  377. package/dist/text/character-style.js +39 -1
  378. package/dist/text/character-style.js.map +1 -1
  379. package/dist/text/font/batch.d.ts +26 -0
  380. package/dist/text/font/batch.d.ts.map +1 -0
  381. package/dist/text/font/batch.js +31 -0
  382. package/dist/text/font/batch.js.map +1 -0
  383. package/dist/text/font/manager.d.ts.map +1 -1
  384. package/dist/text/font/manager.js +14 -1
  385. package/dist/text/font/manager.js.map +1 -1
  386. package/dist/text/index.d.ts +3 -2
  387. package/dist/text/index.js +3 -2
  388. package/dist/tools/create/basic.js +3 -4
  389. package/dist/tools/create/basic.js.map +1 -1
  390. package/dist/tools/create/behaviours.js +1 -1
  391. package/dist/tools/create/code.d.ts +6 -0
  392. package/dist/tools/create/code.d.ts.map +1 -0
  393. package/dist/tools/create/code.js +68 -0
  394. package/dist/tools/create/code.js.map +1 -0
  395. package/dist/tools/create/html.d.ts.map +1 -1
  396. package/dist/tools/create/html.js +9 -57
  397. package/dist/tools/create/html.js.map +1 -1
  398. package/dist/tools/create/icons.js +1 -1
  399. package/dist/tools/create/inputs.d.ts +11 -0
  400. package/dist/tools/create/inputs.d.ts.map +1 -0
  401. package/dist/tools/create/inputs.js +15 -0
  402. package/dist/tools/create/inputs.js.map +1 -0
  403. package/dist/tools/create/mermaid.d.ts.map +1 -1
  404. package/dist/tools/create/mermaid.js +5 -6
  405. package/dist/tools/create/mermaid.js.map +1 -1
  406. package/dist/tools/create/place.d.ts +30 -0
  407. package/dist/tools/create/place.d.ts.map +1 -0
  408. package/dist/tools/create/place.js +70 -0
  409. package/dist/tools/create/place.js.map +1 -0
  410. package/dist/tools/create/render.js +1 -1
  411. package/dist/tools/create/svg.js +1 -1
  412. package/dist/tools/create/vector.js +1 -1
  413. package/dist/tools/create.d.ts +2 -1
  414. package/dist/tools/create.js +2 -1
  415. package/dist/tools/css/gradient.d.ts +28 -0
  416. package/dist/tools/css/gradient.d.ts.map +1 -0
  417. package/dist/tools/css/gradient.js +118 -0
  418. package/dist/tools/css/gradient.js.map +1 -0
  419. package/dist/tools/image-ai/generate.js +1 -1
  420. package/dist/tools/modify/geometry.js +5 -5
  421. package/dist/tools/modify/geometry.js.map +1 -1
  422. package/dist/tools/modify/layout.d.ts.map +1 -1
  423. package/dist/tools/modify/layout.js +7 -1
  424. package/dist/tools/modify/layout.js.map +1 -1
  425. package/dist/tools/modify/matching.js +1 -1
  426. package/dist/tools/modify/overrides.d.ts +6 -0
  427. package/dist/tools/modify/overrides.d.ts.map +1 -0
  428. package/dist/tools/modify/overrides.js +27 -0
  429. package/dist/tools/modify/overrides.js.map +1 -0
  430. package/dist/tools/modify/paint.d.ts.map +1 -1
  431. package/dist/tools/modify/paint.js +84 -39
  432. package/dist/tools/modify/paint.js.map +1 -1
  433. package/dist/tools/modify/text.d.ts +2 -1
  434. package/dist/tools/modify/text.d.ts.map +1 -1
  435. package/dist/tools/modify/text.js +79 -8
  436. package/dist/tools/modify/text.js.map +1 -1
  437. package/dist/tools/modify/update.d.ts.map +1 -1
  438. package/dist/tools/modify/update.js +18 -2
  439. package/dist/tools/modify/update.js.map +1 -1
  440. package/dist/tools/modify.d.ts +3 -2
  441. package/dist/tools/modify.js +3 -2
  442. package/dist/tools/read/css.d.ts.map +1 -1
  443. package/dist/tools/read/css.js +29 -12
  444. package/dist/tools/read/css.js.map +1 -1
  445. package/dist/tools/read/libraries.js +1 -1
  446. package/dist/tools/read/nodes.d.ts.map +1 -1
  447. package/dist/tools/read/nodes.js +19 -5
  448. package/dist/tools/read/nodes.js.map +1 -1
  449. package/dist/tools/registry/extended.d.ts.map +1 -1
  450. package/dist/tools/registry/extended.js +6 -1
  451. package/dist/tools/registry/extended.js.map +1 -1
  452. package/dist/tools/text-range.d.ts +11 -0
  453. package/dist/tools/text-range.d.ts.map +1 -0
  454. package/dist/tools/text-range.js +26 -0
  455. package/dist/tools/text-range.js.map +1 -0
  456. package/dist/tools/variables/bindings.js +1 -1
  457. package/dist/tools/variables/bindings.js.map +1 -1
  458. package/dist/tools/variables/unbind.js +1 -1
  459. package/dist/tools/variables/unbind.js.map +1 -1
  460. package/dist/tools/vector/path.d.ts.map +1 -1
  461. package/dist/tools/vector/path.js +7 -21
  462. package/dist/tools/vector/path.js.map +1 -1
  463. package/dist/vector/rebase.d.ts +17 -0
  464. package/dist/vector/rebase.d.ts.map +1 -0
  465. package/dist/vector/rebase.js +32 -0
  466. package/dist/vector/rebase.js.map +1 -0
  467. package/package.json +14 -9
  468. package/src/canvas/boolean.ts +12 -1
  469. package/src/canvas/color-space.ts +73 -0
  470. package/src/canvas/fills.ts +130 -83
  471. package/src/canvas/flatten.ts +92 -7
  472. package/src/canvas/index.ts +9 -0
  473. package/src/canvas/layout-grids.ts +15 -2
  474. package/src/canvas/noise/render.ts +35 -7
  475. package/src/canvas/noise/shader.ts +8 -10
  476. package/src/canvas/overlays/annotations.ts +117 -0
  477. package/src/canvas/overlays/auto-layout-hover.ts +41 -1
  478. package/src/canvas/overlays/feedback.ts +7 -2
  479. package/src/canvas/overlays/index.ts +1 -1
  480. package/src/canvas/overlays/measurement.ts +49 -3
  481. package/src/canvas/overlays/presence.ts +35 -32
  482. package/src/canvas/renderer/colors.ts +14 -0
  483. package/src/canvas/renderer/document-surface.ts +16 -6
  484. package/src/canvas/renderer/lifecycle.ts +2 -2
  485. package/src/canvas/renderer/methods.ts +4 -0
  486. package/src/canvas/renderer/overlay-pass.ts +4 -0
  487. package/src/canvas/renderer/pipeline.ts +8 -0
  488. package/src/canvas/renderer/types.ts +8 -0
  489. package/src/canvas/renderer.ts +21 -2
  490. package/src/canvas/scene.ts +15 -7
  491. package/src/clipboard/pairdraw.ts +1 -0
  492. package/src/editor/bridges/clipboard.ts +1 -0
  493. package/src/editor/bridges/components.ts +10 -0
  494. package/src/editor/clipboard/code.ts +50 -0
  495. package/src/editor/clipboard/paste/dependencies.ts +18 -0
  496. package/src/editor/clipboard/paste/run.ts +64 -0
  497. package/src/editor/clipboard/styled.ts +4 -52
  498. package/src/editor/clipboard.ts +40 -0
  499. package/src/editor/components/instances.ts +92 -4
  500. package/src/editor/components/slots/index.ts +7 -0
  501. package/src/editor/components.ts +16 -2
  502. package/src/editor/create.ts +15 -1
  503. package/src/editor/design-tokens.ts +3 -23
  504. package/src/editor/image-edit.ts +5 -2
  505. package/src/editor/index.ts +1 -0
  506. package/src/editor/layout-mode.ts +131 -3
  507. package/src/editor/nodes.ts +30 -5
  508. package/src/editor/read-only/actions.ts +6 -0
  509. package/src/editor/selection/overlays.ts +8 -0
  510. package/src/editor/state/shared.ts +1 -0
  511. package/src/editor/state/view.ts +2 -0
  512. package/src/editor/structure/boolean.ts +29 -1
  513. package/src/editor/structure/container-wrap.ts +20 -4
  514. package/src/editor/structure/flatten.ts +15 -8
  515. package/src/editor/structure/group/ungroup.ts +2 -0
  516. package/src/editor/structure/outline-stroke.ts +5 -0
  517. package/src/editor/styles.ts +203 -0
  518. package/src/editor/text/selection-style.ts +18 -1
  519. package/src/editor/tool-registry.ts +2 -0
  520. package/src/editor/types.ts +14 -0
  521. package/src/editor/variable-bindings.ts +11 -0
  522. package/src/figma-api/accessors/basic.ts +33 -1
  523. package/src/figma-api/accessors/vector.ts +6 -13
  524. package/src/figma-api/compatibility.ts +1 -0
  525. package/src/figma-api/component-scope.ts +36 -0
  526. package/src/figma-api/components.ts +24 -0
  527. package/src/figma-api/flatten.ts +7 -3
  528. package/src/figma-api/index.ts +302 -6
  529. package/src/figma-api/node-types.ts +1 -0
  530. package/src/figma-api/overrides.ts +192 -5
  531. package/src/figma-api/proxy.ts +16 -1
  532. package/src/figma-api/reactions.ts +163 -12
  533. package/src/figma-api/slots.ts +10 -9
  534. package/src/io/formats/code/detect.ts +67 -0
  535. package/src/io/formats/code/index.ts +17 -0
  536. package/src/io/formats/code/read.ts +143 -0
  537. package/src/io/formats/code/stylesheet.ts +24 -0
  538. package/src/io/formats/code/tokens.ts +159 -0
  539. package/src/io/formats/design-tokens/apply.ts +3 -2
  540. package/src/io/formats/fig/export/patch/fields.ts +11 -0
  541. package/src/io/formats/fig/export/patch/index.ts +23 -19
  542. package/src/io/formats/fig/export/setup.ts +8 -1
  543. package/src/io/formats/fig/index.ts +6 -0
  544. package/src/io/formats/fig/read.ts +11 -2
  545. package/src/io/formats/html/layers.ts +7 -0
  546. package/src/io/formats/pdf/export.ts +19 -7
  547. package/src/io/formats/pdf/plan.ts +71 -32
  548. package/src/io/formats/raster/headless.ts +3 -1
  549. package/src/io/formats/raster/index.ts +2 -0
  550. package/src/io/formats/raster/render.ts +49 -9
  551. package/src/io/formats/svg/defs.ts +27 -1
  552. package/src/io/formats/svg/export.ts +75 -13
  553. package/src/io/formats/svg/index.ts +1 -0
  554. package/src/io/formats/svg/text/layout.ts +5 -3
  555. package/src/io/formats/video/record.ts +33 -9
  556. package/src/io/formats.ts +35 -15
  557. package/src/kiwi/fig/population/client.ts +6 -1
  558. package/src/kiwi/fig/session/document-state.ts +195 -5
  559. package/src/kiwi/fig/session/options.ts +2 -0
  560. package/src/layout/apply.ts +12 -4
  561. package/src/layout/auto-layout-handles.ts +1 -1
  562. package/src/layout/axis-sizing.ts +3 -1
  563. package/src/layout/derived.ts +3 -1
  564. package/src/layout/effective-generated-text.ts +1 -1
  565. package/src/layout/grid.ts +91 -21
  566. package/src/layout.ts +16 -3
  567. package/src/node/fs.ts +32 -7
  568. package/src/prototype/easing.ts +79 -7
  569. package/src/prototype/scenes.ts +244 -15
  570. package/src/prototype/session.ts +1 -0
  571. package/src/prototype/smart-animate/animation.ts +4 -3
  572. package/src/prototype/timeline.ts +118 -26
  573. package/src/prototype/variables.ts +189 -0
  574. package/src/rpc/read-commands.ts +19 -1
  575. package/src/text/character-style.ts +47 -0
  576. package/src/text/font/batch.ts +58 -0
  577. package/src/text/font/manager.ts +17 -1
  578. package/src/text/index.ts +2 -1
  579. package/src/tools/create/basic.ts +2 -3
  580. package/src/tools/create/code.ts +85 -0
  581. package/src/tools/create/html.ts +9 -46
  582. package/src/tools/create/inputs.ts +12 -0
  583. package/src/tools/create/mermaid.ts +6 -6
  584. package/src/tools/create/place.ts +80 -0
  585. package/src/tools/create.ts +1 -0
  586. package/src/tools/css/gradient.ts +147 -0
  587. package/src/tools/modify/geometry.ts +5 -5
  588. package/src/tools/modify/layout.ts +19 -0
  589. package/src/tools/modify/overrides.ts +35 -0
  590. package/src/tools/modify/paint.ts +124 -54
  591. package/src/tools/modify/text.ts +91 -7
  592. package/src/tools/modify/update.ts +23 -2
  593. package/src/tools/modify.ts +9 -1
  594. package/src/tools/read/css.ts +46 -12
  595. package/src/tools/read/nodes.ts +26 -4
  596. package/src/tools/registry/extended.ts +6 -0
  597. package/src/tools/text-range.ts +29 -0
  598. package/src/tools/variables/bindings.ts +4 -1
  599. package/src/tools/variables/unbind.ts +4 -1
  600. package/src/tools/vector/path.ts +11 -13
  601. package/src/vector/rebase.ts +33 -0
@@ -1 +1 @@
1
- {"version":3,"file":"layout.js","names":[],"sources":["../src/layout.ts"],"sourcesContent":["import {\n Direction,\n Display,\n Gutter,\n MeasureMode,\n Overflow,\n type Node as YogaNode\n} from 'yoga-layout'\n\nimport { resolveNodeLayoutDirection } from '@pairdraw/scene-graph/text/direction'\n\nimport { applyYogaLayout } from './layout/apply'\nimport {\n asFlatLeaf,\n asLaidOutIn,\n fillKeepsSizeInHuggingParent,\n heldHugAxis,\n ownAxisSizing,\n setCrossAxisSizing,\n setMainAxisSizing\n} from './layout/axis-sizing'\nimport { keepsSavedFrameSize, keepsSavedLayout, usesDetachedDerivedLayout } from './layout/derived'\nimport { applyEffectiveGeneratedTextLayout } from './layout/effective-generated-text'\nimport { insertFlowBox, setFlexFlow, setFlowEdges } from './layout/flow-edges'\nimport { buildGridTree, createGridChildNode, gridTracksForAxis } from './layout/grid'\nimport { sizeAutoResizingText } from './layout/text-auto-resize'\nexport { sizeAutoResizingText } from './layout/text-auto-resize'\nexport * from './layout/auto-layout-handles'\nexport {\n estimateTextSize,\n getTextMeasurer,\n installTextMeasurer,\n measureTextForLayout,\n setTextMeasurer,\n type TextMeasurer\n} from './layout/text-measurement'\nimport type { LayoutSizing, SceneGraph, SceneNode } from '@pairdraw/scene-graph'\nimport { connectorSublayers, layoutConnector } from '@pairdraw/scene-graph/connectors'\nimport { enforcedAspectRatio, layoutSizing } from '@pairdraw/scene-graph/layout'\n\nimport { fitShapeWithTextFrame } from './layout/shape-with-text'\nimport {\n applyContentInsets,\n applyStrokeMargins,\n contentInsetsSize,\n strokeRoom\n} from './layout/strokes'\nimport {\n autoWidthWrapWidth,\n estimateTextSize,\n getTextMeasurer,\n measureAutoWidthText,\n measureTextForLayout\n} from './layout/text-measurement'\nimport {\n applyMinMaxConstraints,\n applyLockedAspectRatio,\n configureAbsoluteChild,\n configureNonTextLeaf,\n createYogaNode,\n freeYogaTree,\n mapAlignSelf,\n mapGridTrack,\n parentStretchedAxis\n} from './layout/yoga-helpers'\n\nexport function computeLayout(graph: SceneGraph, frameId: string): void {\n graph.withLayoutMutations(() => computeLayoutInternal(graph, frameId))\n}\n\n/**\n * The deepest chain of auto-layout frames one layout pass may build. Yoga lays a tree out by\n * recursing in its WebAssembly stack, which overruns at about 150 nested frames here; that throws\n * an out-of-bounds memory error and leaves the shared Yoga instance unusable for every later\n * layout. Refusing the pass before the call keeps the editor working.\n */\nconst MAX_LAYOUT_DEPTH = 128\n\nfunction computeLayoutInternal(graph: SceneGraph, frameId: string): void {\n const frame = graph.getNode(frameId)\n if (!frame || frame.layoutMode === 'NONE') return\n // A shape with text takes its size from its label before laying the label out in it.\n fitShapeWithTextFrame(graph, frame)\n\n const rootDirection = resolveComputedLayoutDirection(graph, frame)\n const yogaDirection = rootDirection === 'RTL' ? Direction.RTL : Direction.LTR\n // The tree is freed on every path, a refused pass included: Yoga's nodes are WebAssembly memory\n // the caller owns, so a throw must not leave them behind.\n let yogaRoot: YogaNode | null = null\n try {\n yogaRoot =\n frame.layoutMode === 'GRID'\n ? buildGridTree(graph, frame, rootDirection)\n : buildYogaTree(graph, frame, rootDirection)\n yogaRoot.calculateLayout(undefined, undefined, yogaDirection)\n applyYogaLayout(graph, frame, yogaRoot, computeLayoutInternal)\n } finally {\n if (yogaRoot) freeYogaTree(yogaRoot)\n }\n}\nfunction resolveComputedLayoutDirection(\n graph: SceneGraph,\n node: Pick<SceneNode, 'layoutDirection' | 'parentId'>\n): 'LTR' | 'RTL' {\n const parent = node.parentId ? graph.getNode(node.parentId) : null\n const inheritedDirection = parent ? resolveComputedLayoutDirection(graph, parent) : 'LTR'\n return resolveNodeLayoutDirection(node, inheritedDirection)\n}\n\nexport function computeAllLayouts(graph: SceneGraph, scopeId?: string): void {\n graph.withLayoutMutations(() => {\n const rootId = scopeId ?? graph.rootId\n const visited = new Set<string>()\n computeLayoutsBottomUp(graph, rootId, visited)\n if (applyEffectiveGeneratedTextLayout(graph, rootId)) {\n computeLayoutsBottomUp(graph, rootId, new Set())\n }\n routeUnroutedConnectors(graph, rootId)\n })\n}\n\n/**\n * Routes each connector that has no route yet, as one read from a file that saved none, once its\n * label is measured, as FigJam routes such a connector when it opens. A saved route is kept.\n */\nexport function routeUnroutedConnectors(graph: SceneGraph, rootId: string): void {\n for (const { node } of graph.flattenTree(rootId)) {\n if (node.type !== 'CONNECTOR') continue\n const line = connectorSublayers(graph, node)?.line\n if (!line || (line.vectorNetwork?.vertices.length ?? 0) > 0) continue\n sizeAutoResizingText(graph, node.id)\n layoutConnector(graph, node)\n }\n}\n\n/**\n * Gives content an author wrote, such as design JSX, HTML, or a `.pen` file, the sizes and\n * positions its layout implies, which the source does not store, measuring its text first.\n * Documents that store their geometry, such as `.fig` files, keep theirs and do not come here.\n */\nexport function layoutAuthoredNodes(graph: SceneGraph, rootIds: Iterable<string>): void {\n const roots = [...rootIds]\n const pageIds = new Set<string>()\n let outsidePages = false\n for (const id of roots) {\n sizeAutoResizingText(graph, id)\n const page = graph.pageOf(id)\n if (page !== null) pageIds.add(page)\n else outsidePages = true\n }\n const layout = () => {\n if (outsidePages) computeAllLayouts(graph)\n else for (const pageId of pageIds) computeAllLayouts(graph, pageId)\n }\n layout()\n // Layout gives wrapping text its width, which its height follows.\n if (roots.map((id) => sizeAutoResizingText(graph, id, true)).some(Boolean)) layout()\n // Connectors authored with the layers they join route once those layers are in place.\n for (const id of roots) {\n for (const { node } of graph.flattenTree(id)) {\n if (node.type === 'CONNECTOR') layoutConnector(graph, node)\n }\n }\n}\n\nfunction computeLayoutsBottomUp(graph: SceneGraph, nodeId: string, visited: Set<string>): void {\n const node = graph.getNode(nodeId)\n if (!node || visited.has(nodeId)) return\n visited.add(nodeId)\n\n for (const childId of node.childIds) {\n computeLayoutsBottomUp(graph, childId, visited)\n }\n\n if (node.layoutMode !== 'NONE' && !preservesImportedInstanceLayout(node)) {\n computeLayout(graph, nodeId)\n }\n}\n\nfunction preservesImportedInstanceLayout(node: SceneNode): boolean {\n return node.type === 'INSTANCE' && node.source.format === 'fig'\n}\n\nfunction buildYogaTree(\n graph: SceneGraph,\n frame: SceneNode,\n inheritedDirection: 'LTR' | 'RTL'\n): YogaNode {\n const root = createYogaNode()\n const direction = resolveNodeLayoutDirection(frame, inheritedDirection)\n const insets = keepsSavedFrameSize(graph, frame) ? null : contentInsetsSize(frame)\n const width = insets ? Math.max(frame.width, insets.width) : frame.width\n const height = insets ? Math.max(frame.height, insets.height) : frame.height\n\n if (frame.primaryAxisSizing === 'FIXED') {\n if (frame.layoutMode === 'HORIZONTAL') root.setWidth(width)\n else root.setHeight(height)\n }\n if (frame.counterAxisSizing === 'FIXED') {\n if (frame.layoutMode === 'HORIZONTAL') root.setHeight(height)\n else root.setWidth(width)\n }\n // Laid out on its own, a frame its parent stretches keeps the size the parent gave it on\n // that axis, so its content aligns within that size rather than within a hug.\n const stretchedAxis = parentStretchedAxis(graph, frame)\n if (stretchedAxis === 'width') root.setWidth(width)\n if (stretchedAxis === 'height') root.setHeight(height)\n const heldAxis = heldHugAxis(graph, frame)\n if (heldAxis === 'width') root.setWidth(width)\n if (heldAxis === 'height') root.setHeight(height)\n\n configureFlexContainer(root, frame, direction)\n\n try {\n insertFlexChildren(root, frame, graph, direction, 1)\n } catch (error) {\n // The depth check refuses a chain while the tree is half built; every node made so far hangs\n // from the root, which has no other holder.\n freeYogaTree(root)\n throw error\n }\n\n return root\n}\n\nfunction configureFlexContainer(\n yogaNode: YogaNode,\n node: SceneNode,\n direction: Exclude<SceneNode['layoutDirection'], 'AUTO'>\n): void {\n yogaNode.setDirection(direction === 'RTL' ? Direction.RTL : Direction.LTR)\n setFlexFlow(yogaNode, node)\n if (node.clipsContent) yogaNode.setOverflow(Overflow.Hidden)\n applyContentInsets(yogaNode, node)\n\n applyMinMaxConstraints(yogaNode, node)\n}\n\n/**\n * A grid child's box in its flex parent: grow takes the free space, a fixed size is stored, and\n * an axis the grid hugs takes its tracks' size there, as configureAsGrid lays it out.\n */\nfunction applyGridChildBox(yogaChild: YogaNode, child: SceneNode, parent: SceneNode): void {\n const isParentRow = parent.layoutMode === 'HORIZONTAL'\n const selfOverride = child.layoutAlignSelf !== 'AUTO'\n const stretchCross = selfOverride\n ? child.layoutAlignSelf === 'STRETCH'\n : parent.counterAxisAlign === 'STRETCH'\n const hugWidth = ownAxisSizing(child, 'width') === 'HUG'\n const hugHeight = ownAxisSizing(child, 'height') === 'HUG'\n if (child.layoutGrow > 0) {\n yogaChild.setFlexGrow(child.layoutGrow)\n yogaChild.setFlexShrink(1)\n yogaChild.setFlexBasis(0)\n if (stretchCross) return\n if (isParentRow) {\n if (!hugHeight) yogaChild.setHeight(child.height)\n } else if (!hugWidth) {\n yogaChild.setWidth(child.width)\n }\n return\n }\n if (isParentRow) {\n if (!hugWidth) yogaChild.setWidth(child.width)\n if (!stretchCross && !hugHeight) yogaChild.setHeight(child.height)\n return\n }\n if (child.gridTemplateRows.length > 0 && !hugHeight) yogaChild.setHeight(child.height)\n if (!stretchCross && !hugWidth) yogaChild.setWidth(child.width)\n}\n\nfunction configureChildAsGrid(\n yogaChild: YogaNode,\n child: SceneNode,\n parent: SceneNode,\n graph: SceneGraph,\n inheritedDirection: 'LTR' | 'RTL'\n): void {\n const direction = resolveNodeLayoutDirection(child, inheritedDirection)\n yogaChild.setDisplay(Display.Grid)\n yogaChild.setDirection(direction === 'RTL' ? Direction.RTL : Direction.LTR)\n\n if (child.gridTemplateColumns.length > 0) {\n yogaChild.setGridTemplateColumns(gridTracksForAxis(child, 'width').map(mapGridTrack))\n }\n if (child.gridTemplateRows.length > 0) {\n yogaChild.setGridTemplateRows(gridTracksForAxis(child, 'height').map(mapGridTrack))\n }\n\n yogaChild.setGap(Gutter.Column, child.gridColumnGap)\n yogaChild.setGap(Gutter.Row, child.gridRowGap)\n\n applyContentInsets(yogaChild, child)\n applyGridChildBox(yogaChild, child, parent)\n\n const selfAlign = mapAlignSelf(child.layoutAlignSelf)\n if (selfAlign != null) yogaChild.setAlignSelf(selfAlign)\n\n applyLockedAspectRatio(yogaChild, child, parent)\n applyMinMaxConstraints(yogaChild, child)\n\n const grandchildren = graph.getChildren(child.id)\n for (const gc of grandchildren) {\n if (gc.layoutPositioning === 'ABSOLUTE') {\n const yogaGC = createYogaNode()\n configureAbsoluteChild(yogaGC, gc)\n yogaChild.insertChild(yogaGC, yogaChild.getChildCount())\n } else {\n const yogaGC = createGridChildNode(graph, gc)\n applyStrokeMargins(yogaGC, gc, child)\n yogaChild.insertChild(yogaGC, yogaChild.getChildCount())\n }\n }\n}\n\nfunction sizesFitParent(\n parent: SceneNode,\n children: readonly SceneNode[],\n sizes: Array<number | undefined>,\n axis: 'width' | 'height'\n): boolean {\n if (sizes.some((size) => size === undefined)) return false\n const padding =\n (axis === 'width'\n ? parent.paddingLeft + parent.paddingRight\n : parent.paddingTop + parent.paddingBottom) + strokeRoom(parent, children, axis)\n const gap =\n parent.primaryAxisAlign === 'SPACE_BETWEEN'\n ? 0\n : parent.itemSpacing * Math.max(0, children.length - 1)\n const available = axis === 'width' ? parent.width : parent.height\n const total = sizes.reduce<number>((sum, size) => sum + (size ?? 0), padding + gap)\n return Math.abs(total - available) < 0.001\n}\n\nfunction derivedMainAxisFitsParent(\n graph: SceneGraph,\n parent: SceneNode,\n child: SceneNode,\n axis: 'width' | 'height'\n): boolean {\n if (!keepsSavedLayout(graph, parent)) return false\n const children = graph\n .getChildren(parent.id)\n .filter((candidate) => candidate.visible && candidate.layoutPositioning !== 'ABSOLUTE')\n if (children.length === 0) return false\n\n const sizes = children.map((candidate) => candidate.derivedLayout?.[axis])\n return sizesFitParent(parent, children, sizes, axis) && child.derivedLayout?.[axis] !== undefined\n}\n\nfunction configureAutoLayoutChildSizing(\n yogaChild: YogaNode,\n child: SceneNode,\n parent: SceneNode,\n graph: SceneGraph,\n widthSizing: LayoutSizing,\n heightSizing: LayoutSizing\n): void {\n const isParentRow = parent.layoutMode === 'HORIZONTAL'\n const fixedDerivedMainAxis = isParentRow\n ? derivedMainAxisFitsParent(graph, parent, child, 'width')\n : derivedMainAxisFitsParent(graph, parent, child, 'height')\n\n if (isParentRow) {\n if (fixedDerivedMainAxis) yogaChild.setWidth(child.derivedLayout?.width ?? child.width)\n else setMainAxisSizing(yogaChild, 'width', widthSizing, child.width, child.layoutGrow)\n const keepsSize = fillKeepsSizeInHuggingParent(child, parent, 'height')\n setCrossAxisSizing(yogaChild, 'height', heightSizing, child.height, keepsSize)\n return\n }\n\n const keepsSize = fillKeepsSizeInHuggingParent(child, parent, 'width')\n setCrossAxisSizing(yogaChild, 'width', widthSizing, child.width, keepsSize)\n if (fixedDerivedMainAxis) yogaChild.setHeight(child.derivedLayout?.height ?? child.height)\n else setMainAxisSizing(yogaChild, 'height', heightSizing, child.height, child.layoutGrow)\n}\n\n/**\n * Whether the parent's pass places this child from the size it holds: neither its content nor the\n * parent decides its size, so its own cells keep their places while the parent moves it.\n */\nfunction placesFromSize(\n child: SceneNode,\n parent: SceneNode,\n widthSizing: LayoutSizing,\n heightSizing: LayoutSizing\n): boolean {\n return (\n widthSizing === 'FIXED' &&\n heightSizing === 'FIXED' &&\n child.layoutGrow === 0 &&\n parent.counterAxisAlign !== 'BASELINE' &&\n child.layoutAlignSelf !== 'BASELINE' &&\n enforcedAspectRatio(child) === null &&\n child.minWidth === null &&\n child.maxWidth === null &&\n child.minHeight === null &&\n child.maxHeight === null\n )\n}\n\n/**\n * Refuses a chain deeper than Yoga can lay out, for the subtrees a pass places from their size and\n * does not build: the same refusal, without the Yoga nodes.\n */\nfunction assertLayoutDepth(graph: SceneGraph, frame: SceneNode, depth: number): void {\n if (depth > MAX_LAYOUT_DEPTH) {\n throw new RangeError(\n `Layers nest more than ${MAX_LAYOUT_DEPTH} auto-layout frames deep, which the layout engine cannot lay out.`\n )\n }\n for (const child of graph.getChildren(frame.id)) {\n if (child.layoutMode === 'NONE' || !child.visible) continue\n if (child.layoutPositioning === 'ABSOLUTE') continue\n assertLayoutDepth(graph, child, depth + 1)\n }\n}\n\nfunction configureChildAsAutoLayout(\n yogaChild: YogaNode,\n child: SceneNode,\n parent: SceneNode,\n graph: SceneGraph,\n inheritedDirection: 'LTR' | 'RTL',\n depth: number\n): void {\n if (depth > MAX_LAYOUT_DEPTH) {\n throw new RangeError(\n `Layers nest more than ${MAX_LAYOUT_DEPTH} auto-layout frames deep, which the layout engine cannot lay out.`\n )\n }\n const direction = resolveNodeLayoutDirection(child, inheritedDirection)\n const widthSizing = layoutSizing(graph, child, 'HORIZONTAL')\n const heightSizing = layoutSizing(graph, child, 'VERTICAL')\n\n configureAutoLayoutChildSizing(yogaChild, child, parent, graph, widthSizing, heightSizing)\n\n const selfAlign = mapAlignSelf(child.layoutAlignSelf)\n if (selfAlign != null) yogaChild.setAlignSelf(selfAlign)\n applyLockedAspectRatio(yogaChild, child, parent)\n\n if (usesDetachedDerivedLayout(graph, child)) {\n // The imported size is what the child's own hug produced, whether or not it also fills.\n const derived = child.derivedLayout\n if (ownAxisSizing(child, 'width') === 'HUG') yogaChild.setWidth(derived?.width ?? child.width)\n if (ownAxisSizing(child, 'height') === 'HUG') {\n yogaChild.setHeight(derived?.height ?? child.height)\n }\n applyMinMaxConstraints(yogaChild, child)\n return\n }\n\n if (placesFromSize(child, parent, widthSizing, heightSizing)) {\n assertLayoutDepth(graph, child, depth + 1)\n return\n }\n\n configureFlexContainer(yogaChild, child, direction)\n const heldAxis = heldHugAxis(graph, child)\n if (heldAxis === 'width' && widthSizing === 'HUG') yogaChild.setWidth(child.width)\n if (heldAxis === 'height' && heightSizing === 'HUG') yogaChild.setHeight(child.height)\n\n insertFlexChildren(yogaChild, child, graph, direction, depth + 1)\n}\n\n/** Puts a frame's children into its Yoga node, through the flow box a negative edge needs. */\nfunction insertFlexChildren(\n yogaParent: YogaNode,\n parent: SceneNode,\n graph: SceneGraph,\n direction: 'LTR' | 'RTL',\n depth: number\n): void {\n const box = insertFlowBox(yogaParent, parent)\n const flow: YogaNode[] = []\n for (const child of graph\n .getChildren(parent.id)\n .map((node) => asLaidOutIn(graph, node, parent))) {\n const yogaChild = createYogaNode()\n // Attached before it is configured, so a child the depth check refuses still hangs from the\n // root and is freed with it rather than left in WebAssembly memory.\n box.insertChild(yogaChild, box.getChildCount())\n\n if (child.layoutPositioning === 'ABSOLUTE') {\n configureAbsoluteChild(yogaChild, child)\n } else if (!child.visible) {\n yogaChild.setDisplay(Display.None)\n } else {\n if (child.layoutMode === 'GRID') {\n configureChildAsGrid(yogaChild, child, parent, graph, direction)\n } else if (child.layoutMode !== 'NONE') {\n configureChildAsAutoLayout(yogaChild, child, parent, graph, direction, depth)\n } else {\n configureChildAsLeaf(yogaChild, child, parent, graph)\n }\n flow.push(yogaChild)\n }\n applyStrokeMargins(yogaChild, child, parent)\n }\n setFlowEdges(yogaParent, box, parent, flow, direction)\n}\n\nfunction derivedGrowingLeafFitsParent(\n graph: SceneGraph,\n parent: SceneNode,\n child: SceneNode,\n axis: 'width' | 'height'\n): boolean {\n if (child.type !== 'TEXT' || child.layoutGrow <= 0 || child.derivedLayout?.[axis] === undefined) {\n return false\n }\n const children = graph\n .getChildren(parent.id)\n .filter((candidate) => candidate.visible && candidate.layoutPositioning !== 'ABSOLUTE')\n const sizes = children.map((candidate) => {\n if (candidate.layoutGrow > 0) return candidate.derivedLayout?.[axis]\n return axis === 'width' ? candidate.width : candidate.height\n })\n return sizesFitParent(parent, children, sizes, axis)\n}\n\n/**\n * Fill text shares its parent's main axis like a fill frame: it grows and shrinks from a zero\n * basis, so its stored width (100px for new text) never decides its share. Returns whether\n * it fills the row's width, where its stored width must not constrain it either.\n */\nfunction configureGrowingText(\n yogaChild: YogaNode,\n child: SceneNode,\n parent: SceneNode,\n fixedDerivedMainAxis: boolean\n): boolean {\n if (child.layoutGrow <= 0 || fixedDerivedMainAxis) return false\n yogaChild.setFlexGrow(child.layoutGrow)\n yogaChild.setFlexShrink(1)\n yogaChild.setFlexBasis(0)\n return parent.layoutMode === 'HORIZONTAL'\n}\n\nfunction configureTextLeafWithoutMeasurer(\n yogaChild: YogaNode,\n child: SceneNode,\n parent: SceneNode,\n fixedDerivedMainAxis: boolean\n): void {\n const hasStoredSize =\n child.width > 0 && child.height > 0 && !(child.width === 100 && child.height === 100)\n\n if (child.textAutoResize === 'WIDTH_AND_HEIGHT') {\n if (hasStoredSize) {\n yogaChild.setWidth(child.width)\n yogaChild.setHeight(child.height)\n } else {\n const estimated = estimateTextSize(child)\n yogaChild.setWidth(estimated.width)\n yogaChild.setHeight(estimated.height)\n }\n return\n }\n if (child.textAutoResize !== 'HEIGHT') {\n // A truncating text keeps the box it has, as Figma clips it to that box.\n if (child.width > 0 && child.height > 0) {\n yogaChild.setWidth(child.width)\n yogaChild.setHeight(child.height)\n }\n return\n }\n\n const growsWidth = configureGrowingText(yogaChild, child, parent, fixedDerivedMainAxis)\n const isRow = parent.layoutMode === 'HORIZONTAL'\n const measurementWidth = fixedDerivedMainAxis\n ? (child.derivedLayout?.width ?? child.width)\n : child.width\n const stretches =\n child.layoutAlignSelf === 'STRETCH' ||\n (child.layoutAlignSelf === 'AUTO' && parent.counterAxisAlign === 'STRETCH')\n if (!(!isRow && stretches) && !fixedDerivedMainAxis && !growsWidth) {\n yogaChild.setWidth(child.width)\n }\n if (hasStoredSize) yogaChild.setHeight(child.height)\n else yogaChild.setHeight(estimateTextSize(child, measurementWidth).height)\n}\n\nfunction configureChildAsLeaf(\n yogaChild: YogaNode,\n node: SceneNode,\n parent: SceneNode,\n graph: SceneGraph\n): void {\n const child = asFlatLeaf(node, parent)\n const isRow = parent.layoutMode === 'HORIZONTAL'\n const selfOverride = child.layoutAlignSelf !== 'AUTO'\n const stretchCross = selfOverride\n ? child.layoutAlignSelf === 'STRETCH'\n : parent.counterAxisAlign === 'STRETCH'\n\n const isText = child.type === 'TEXT'\n const textMeasurer = getTextMeasurer()\n // A truncating or fixed text keeps its box, so Yoga measures only text that grows.\n const needsMeasureFunc = isText && textMeasurer && growsText(child)\n\n const fixedDerivedMainAxis = isRow\n ? derivedGrowingLeafFitsParent(graph, parent, child, 'width')\n : derivedGrowingLeafFitsParent(graph, parent, child, 'height')\n\n if (fixedDerivedMainAxis) {\n if (isRow) yogaChild.setWidth(child.derivedLayout?.width ?? child.width)\n else yogaChild.setHeight(child.derivedLayout?.height ?? child.height)\n }\n\n if (needsMeasureFunc) {\n configureTextLeaf(yogaChild, child, parent, fixedDerivedMainAxis)\n } else if (isText && !textMeasurer && child.textAutoResize !== 'NONE') {\n configureTextLeafWithoutMeasurer(yogaChild, child, parent, fixedDerivedMainAxis)\n } else {\n configureNonTextLeaf(yogaChild, child, isRow, stretchCross)\n // Fixed text still contributes its box to a HUG cross axis. Without\n // an intrinsic minimum, stretch collapses the text to its siblings.\n if (isText && stretchCross && parent.counterAxisSizing === 'HUG') {\n if (isRow) yogaChild.setMinHeight(child.height)\n else yogaChild.setMinWidth(child.width)\n }\n }\n\n const selfAlign = mapAlignSelf(child.layoutAlignSelf)\n if (selfAlign != null) yogaChild.setAlignSelf(selfAlign)\n\n applyLockedAspectRatio(yogaChild, child, parent)\n applyMinMaxConstraints(yogaChild, child)\n}\n\n/** Whether layout measures a text to size it, which only the two growing modes need. */\nfunction growsText(node: SceneNode): boolean {\n return node.textAutoResize === 'WIDTH_AND_HEIGHT' || node.textAutoResize === 'HEIGHT'\n}\n\nfunction configureTextLeaf(\n yogaChild: YogaNode,\n child: SceneNode,\n parent: SceneNode,\n fixedDerivedMainAxis = false\n): void {\n const autoResize = child.textAutoResize\n const isRow = parent.layoutMode === 'HORIZONTAL'\n const growsWidth = configureGrowingText(yogaChild, child, parent, fixedDerivedMainAxis)\n const stretchesCross =\n child.layoutAlignSelf === 'STRETCH' ||\n (child.layoutAlignSelf === 'AUTO' && parent.counterAxisAlign === 'STRETCH')\n // Layout sets the width of text that grows along a row or stretches across a column.\n const fillsWidth = (!isRow && stretchesCross) || growsWidth\n\n const cache = new Map<number, { width: number; height: number }>()\n const UNCONSTRAINED_KEY = -1\n\n if (autoResize === 'WIDTH_AND_HEIGHT') {\n const importedSize = child.derivedLayout\n if (importedSize?.width !== undefined && importedSize.height !== undefined) {\n yogaChild.setWidth(child.width)\n yogaChild.setHeight(child.height)\n return\n }\n\n // Auto-width text keeps each line whole, as Figma's does, in a parent narrower than the text;\n // only a width that layout or a max width sets wraps it.\n const wraps = fillsWidth || child.maxWidth != null\n yogaChild.setMeasureFunc((width, widthMode, _height, _heightMode) => {\n const maxW = wraps && widthMode !== MeasureMode.Undefined ? width : undefined\n const cacheKey = maxW === undefined ? UNCONSTRAINED_KEY : Math.round(maxW)\n const cached = cache.get(cacheKey)\n if (cached) return cached\n\n const result = measureAutoWidthText(child, maxW ?? autoWidthWrapWidth(child))\n cache.set(cacheKey, result)\n return result\n })\n } else if (autoResize === 'HEIGHT') {\n const fixedWidth = fixedDerivedMainAxis\n ? (child.derivedLayout?.width ?? child.width)\n : child.width\n // Let Yoga stretch or grow fill-width text instead of fixing its stored width.\n if (child.layoutGrow <= 0 && !fillsWidth) {\n yogaChild.setWidth(fixedWidth)\n }\n yogaChild.setMeasureFunc((width, widthMode, _height, _heightMode) => {\n let constraintW = fixedWidth\n if (fillsWidth) {\n if (widthMode !== MeasureMode.Undefined) constraintW = width\n } else if (widthMode !== MeasureMode.Undefined) {\n constraintW = Math.min(width, fixedWidth || width)\n }\n const cacheKey = Math.round(constraintW)\n const cached = cache.get(cacheKey)\n if (cached) return cached\n\n if (constraintW === child.width && (child.derivedTextGlyphs?.length ?? 0) > 0) {\n return { width: constraintW, height: child.height }\n }\n const result = { width: constraintW, height: measureTextForLayout(child, constraintW).height }\n cache.set(cacheKey, result)\n return result\n })\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAkEA,SAAgB,cAAc,OAAmB,SAAuB;CACtE,MAAM,0BAA0B,sBAAsB,OAAO,OAAO,CAAC;AACvE;;;;;;;AAQA,MAAM,mBAAmB;AAEzB,SAAS,sBAAsB,OAAmB,SAAuB;CACvE,MAAM,QAAQ,MAAM,QAAQ,OAAO;CACnC,IAAI,CAAC,SAAS,MAAM,eAAe,QAAQ;CAE3C,sBAAsB,OAAO,KAAK;CAElC,MAAM,gBAAgB,+BAA+B,OAAO,KAAK;CACjE,MAAM,gBAAgB,kBAAkB,QAAQ,UAAU,MAAM,UAAU;CAG1E,IAAI,WAA4B;CAChC,IAAI;EACF,WACE,MAAM,eAAe,SACjB,cAAc,OAAO,OAAO,aAAa,IACzC,cAAc,OAAO,OAAO,aAAa;EAC/C,SAAS,gBAAgB,KAAA,GAAW,KAAA,GAAW,aAAa;EAC5D,gBAAgB,OAAO,OAAO,UAAU,qBAAqB;CAC/D,UAAU;EACR,IAAI,UAAU,aAAa,QAAQ;CACrC;AACF;AACA,SAAS,+BACP,OACA,MACe;CACf,MAAM,SAAS,KAAK,WAAW,MAAM,QAAQ,KAAK,QAAQ,IAAI;CAC9D,MAAM,qBAAqB,SAAS,+BAA+B,OAAO,MAAM,IAAI;CACpF,OAAO,2BAA2B,MAAM,kBAAkB;AAC5D;AAEA,SAAgB,kBAAkB,OAAmB,SAAwB;CAC3E,MAAM,0BAA0B;EAC9B,MAAM,SAAS,WAAW,MAAM;E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MAAM,IAAI,UAAU,MAAM;GAC1B,OAAO;EACT,CAAC;CACH;AACF"}
1
+ {"version":3,"file":"layout.js","names":[],"sources":["../src/layout.ts"],"sourcesContent":["import {\n Direction,\n Display,\n Gutter,\n MeasureMode,\n Overflow,\n type Node as YogaNode\n} from 'yoga-layout'\n\nimport { resolveNodeLayoutDirection } from '@pairdraw/scene-graph/text/direction'\n\nimport { applyYogaLayout } from './layout/apply'\nimport {\n asFlatLeaf,\n asLaidOutIn,\n fillKeepsSizeInHuggingParent,\n heldHugAxis,\n ownAxisSizing,\n setCrossAxisSizing,\n setMainAxisSizing\n} from './layout/axis-sizing'\nimport { keepsSavedFrameSize, keepsSavedLayout, usesDetachedDerivedLayout } from './layout/derived'\nimport { applyEffectiveGeneratedTextLayout } from './layout/effective-generated-text'\nimport { insertFlowBox, setFlexFlow, setFlowEdges } from './layout/flow-edges'\nimport { buildGridTree, createGridChildNode, gridTracksForAxis } from './layout/grid'\nimport { sizeAutoResizingText } from './layout/text-auto-resize'\nexport { sizeAutoResizingText } from './layout/text-auto-resize'\nexport * from './layout/auto-layout-handles'\nexport {\n estimateTextSize,\n getTextMeasurer,\n installTextMeasurer,\n measureTextForLayout,\n setTextMeasurer,\n type TextMeasurer\n} from './layout/text-measurement'\nimport type { LayoutSizing, SceneGraph, SceneNode } from '@pairdraw/scene-graph'\nimport { connectorSublayers, layoutConnector } from '@pairdraw/scene-graph/connectors'\nimport { enforcedAspectRatio, layoutSizing } from '@pairdraw/scene-graph/layout'\n\nimport { fitShapeWithTextFrame } from './layout/shape-with-text'\nimport {\n applyContentInsets,\n applyStrokeMargins,\n contentInsetsSize,\n strokeRoom\n} from './layout/strokes'\nimport {\n autoWidthWrapWidth,\n estimateTextSize,\n getTextMeasurer,\n measureAutoWidthText,\n measureTextForLayout\n} from './layout/text-measurement'\nimport {\n applyMinMaxConstraints,\n applyLockedAspectRatio,\n configureAbsoluteChild,\n configureNonTextLeaf,\n createYogaNode,\n freeYogaTree,\n mapAlignSelf,\n mapGridTrack,\n parentStretchedAxis\n} from './layout/yoga-helpers'\n\nexport function computeLayout(graph: SceneGraph, frameId: string): void {\n graph.withLayoutMutations(() => computeLayoutInternal(graph, frameId))\n}\n\n/**\n * The deepest chain of auto-layout frames one layout pass may build. Yoga lays a tree out by\n * recursing in its WebAssembly stack, which overruns at about 150 nested frames here; that throws\n * an out-of-bounds memory error and leaves the shared Yoga instance unusable for every later\n * layout. Refusing the pass before the call keeps the editor working.\n */\nconst MAX_LAYOUT_DEPTH = 128\n\nfunction computeLayoutInternal(graph: SceneGraph, frameId: string): void {\n const frame = graph.getNode(frameId)\n if (!frame || frame.layoutMode === 'NONE') return\n // A shape with text takes its size from its label before laying the label out in it.\n fitShapeWithTextFrame(graph, frame)\n\n const rootDirection = resolveComputedLayoutDirection(graph, frame)\n const yogaDirection = rootDirection === 'RTL' ? Direction.RTL : Direction.LTR\n // The tree is freed on every path, a refused pass included: Yoga's nodes are WebAssembly memory\n // the caller owns, so a throw must not leave them behind.\n let yogaRoot: YogaNode | null = null\n try {\n yogaRoot =\n frame.layoutMode === 'GRID'\n ? buildGridTree(graph, frame, rootDirection)\n : buildYogaTree(graph, frame, rootDirection)\n yogaRoot.calculateLayout(undefined, undefined, yogaDirection)\n applyYogaLayout(graph, frame, yogaRoot, computeLayoutInternal)\n } finally {\n if (yogaRoot) freeYogaTree(yogaRoot)\n }\n}\nfunction resolveComputedLayoutDirection(\n graph: SceneGraph,\n node: Pick<SceneNode, 'layoutDirection' | 'parentId'>\n): 'LTR' | 'RTL' {\n const parent = node.parentId ? graph.getNode(node.parentId) : null\n const inheritedDirection = parent ? resolveComputedLayoutDirection(graph, parent) : 'LTR'\n return resolveNodeLayoutDirection(node, inheritedDirection)\n}\n\nexport function computeAllLayouts(graph: SceneGraph, scopeId?: string): void {\n graph.withLayoutMutations(() => {\n const rootId = scopeId ?? graph.rootId\n const visited = new Set<string>()\n computeLayoutsBottomUp(graph, rootId, visited)\n if (applyEffectiveGeneratedTextLayout(graph, rootId)) {\n computeLayoutsBottomUp(graph, rootId, new Set())\n }\n routeUnroutedConnectors(graph, rootId)\n })\n}\n\n/**\n * Routes each connector that has no route yet, as one read from a file that saved none, once its\n * label is measured, as FigJam routes such a connector when it opens. A saved route is kept.\n */\nexport function routeUnroutedConnectors(graph: SceneGraph, rootId: string): void {\n for (const { node } of graph.flattenTree(rootId)) {\n if (node.type !== 'CONNECTOR') continue\n const line = connectorSublayers(graph, node)?.line\n if (!line || (line.vectorNetwork?.vertices.length ?? 0) > 0) continue\n sizeAutoResizingText(graph, node.id)\n layoutConnector(graph, node)\n }\n}\n\n/**\n * Gives content an author wrote, such as design JSX, HTML, or a `.pen` file, the sizes and\n * positions its layout implies, which the source does not store, measuring its text first.\n * Documents that store their geometry, such as `.fig` files, keep theirs and do not come here.\n */\nexport function layoutAuthoredNodes(graph: SceneGraph, rootIds: Iterable<string>): void {\n const roots = [...rootIds]\n const pageIds = new Set<string>()\n let outsidePages = false\n for (const id of roots) {\n sizeAutoResizingText(graph, id)\n const page = graph.pageOf(id)\n if (page !== null) pageIds.add(page)\n else outsidePages = true\n }\n const layout = () => {\n if (outsidePages) computeAllLayouts(graph)\n else for (const pageId of pageIds) computeAllLayouts(graph, pageId)\n }\n layout()\n // Layout gives wrapping text its width, which its height follows.\n if (roots.map((id) => sizeAutoResizingText(graph, id, true)).some(Boolean)) layout()\n // Connectors authored with the layers they join route once those layers are in place.\n for (const id of roots) {\n for (const { node } of graph.flattenTree(id)) {\n if (node.type === 'CONNECTOR') layoutConnector(graph, node)\n }\n }\n}\n\nfunction computeLayoutsBottomUp(graph: SceneGraph, nodeId: string, visited: Set<string>): void {\n const node = graph.getNode(nodeId)\n if (!node || visited.has(nodeId)) return\n visited.add(nodeId)\n\n for (const childId of node.childIds) {\n computeLayoutsBottomUp(graph, childId, visited)\n }\n\n if (node.layoutMode !== 'NONE' && !preservesImportedInstanceLayout(node)) {\n computeLayout(graph, nodeId)\n }\n}\n\nfunction preservesImportedInstanceLayout(node: SceneNode): boolean {\n return node.type === 'INSTANCE' && node.source.format === 'fig'\n}\n\nfunction buildYogaTree(\n graph: SceneGraph,\n frame: SceneNode,\n inheritedDirection: 'LTR' | 'RTL'\n): YogaNode {\n const root = createYogaNode()\n const direction = resolveNodeLayoutDirection(frame, inheritedDirection)\n const insets = keepsSavedFrameSize(graph, frame) ? null : contentInsetsSize(frame)\n const width = insets ? Math.max(frame.width, insets.width) : frame.width\n const height = insets ? Math.max(frame.height, insets.height) : frame.height\n\n if (frame.primaryAxisSizing === 'FIXED') {\n if (frame.layoutMode === 'HORIZONTAL') root.setWidth(width)\n else root.setHeight(height)\n }\n if (frame.counterAxisSizing === 'FIXED') {\n if (frame.layoutMode === 'HORIZONTAL') root.setHeight(height)\n else root.setWidth(width)\n }\n // Laid out on its own, a frame its parent stretches keeps the size the parent gave it on\n // that axis, so its content aligns within that size rather than within a hug.\n const stretchedAxis = parentStretchedAxis(graph, frame)\n if (stretchedAxis === 'width') root.setWidth(width)\n if (stretchedAxis === 'height') root.setHeight(height)\n const heldAxis = heldHugAxis(graph, frame)\n if (heldAxis === 'width') root.setWidth(width)\n if (heldAxis === 'height') root.setHeight(height)\n\n configureFlexContainer(root, frame, direction)\n\n try {\n insertFlexChildren(root, frame, graph, direction, 1)\n } catch (error) {\n // The depth check refuses a chain while the tree is half built; every node made so far hangs\n // from the root, which has no other holder.\n freeYogaTree(root)\n throw error\n }\n\n return root\n}\n\nfunction configureFlexContainer(\n yogaNode: YogaNode,\n node: SceneNode,\n direction: Exclude<SceneNode['layoutDirection'], 'AUTO'>\n): void {\n yogaNode.setDirection(direction === 'RTL' ? Direction.RTL : Direction.LTR)\n setFlexFlow(yogaNode, node)\n if (node.clipsContent) yogaNode.setOverflow(Overflow.Hidden)\n applyContentInsets(yogaNode, node)\n\n applyMinMaxConstraints(yogaNode, node)\n}\n\n/**\n * A grid child's box in its flex parent: grow takes the free space, a fixed size is stored, and\n * an axis the grid hugs takes its tracks' size there, as configureAsGrid lays it out.\n */\nfunction applyGridChildBox(yogaChild: YogaNode, child: SceneNode, parent: SceneNode): void {\n const isParentRow = parent.layoutMode === 'HORIZONTAL'\n const selfOverride = child.layoutAlignSelf !== 'AUTO'\n const stretchCross = selfOverride\n ? child.layoutAlignSelf === 'STRETCH'\n : parent.counterAxisAlign === 'STRETCH'\n const hugWidth = ownAxisSizing(child, 'width') === 'HUG'\n const hugHeight = ownAxisSizing(child, 'height') === 'HUG'\n if (child.layoutGrow > 0) {\n yogaChild.setFlexGrow(child.layoutGrow)\n yogaChild.setFlexShrink(1)\n yogaChild.setFlexBasis(0)\n if (stretchCross) return\n if (isParentRow) {\n if (!hugHeight) yogaChild.setHeight(child.height)\n } else if (!hugWidth) {\n yogaChild.setWidth(child.width)\n }\n return\n }\n if (isParentRow) {\n if (!hugWidth) yogaChild.setWidth(child.width)\n if (!stretchCross && !hugHeight) yogaChild.setHeight(child.height)\n return\n }\n if (child.gridTemplateRows.length > 0 && !hugHeight) yogaChild.setHeight(child.height)\n if (!stretchCross && !hugWidth) yogaChild.setWidth(child.width)\n}\n\nfunction configureChildAsGrid(\n yogaChild: YogaNode,\n child: SceneNode,\n parent: SceneNode,\n graph: SceneGraph,\n inheritedDirection: 'LTR' | 'RTL'\n): void {\n const direction = resolveNodeLayoutDirection(child, inheritedDirection)\n yogaChild.setDisplay(Display.Grid)\n yogaChild.setDirection(direction === 'RTL' ? Direction.RTL : Direction.LTR)\n\n if (child.gridTemplateColumns.length > 0) {\n yogaChild.setGridTemplateColumns(gridTracksForAxis(child, 'width').map(mapGridTrack))\n }\n if (child.gridTemplateRows.length > 0) {\n yogaChild.setGridTemplateRows(gridTracksForAxis(child, 'height').map(mapGridTrack))\n }\n\n yogaChild.setGap(Gutter.Column, child.gridColumnGap)\n yogaChild.setGap(Gutter.Row, child.gridRowGap)\n\n applyContentInsets(yogaChild, child)\n applyGridChildBox(yogaChild, child, parent)\n\n const selfAlign = mapAlignSelf(child.layoutAlignSelf)\n if (selfAlign != null) yogaChild.setAlignSelf(selfAlign)\n\n applyLockedAspectRatio(yogaChild, child, parent)\n applyMinMaxConstraints(yogaChild, child)\n\n const grandchildren = graph.getChildren(child.id).filter((gc) => gc.type !== 'SLICE')\n for (const gc of grandchildren) {\n if (gc.layoutPositioning === 'ABSOLUTE') {\n const yogaGC = createYogaNode()\n configureAbsoluteChild(yogaGC, gc)\n yogaChild.insertChild(yogaGC, yogaChild.getChildCount())\n } else {\n const yogaGC = createGridChildNode(graph, gc)\n applyStrokeMargins(yogaGC, gc, child)\n yogaChild.insertChild(yogaGC, yogaChild.getChildCount())\n }\n }\n}\n\nfunction sizesFitParent(\n parent: SceneNode,\n children: readonly SceneNode[],\n sizes: Array<number | undefined>,\n axis: 'width' | 'height'\n): boolean {\n if (sizes.some((size) => size === undefined)) return false\n const padding =\n (axis === 'width'\n ? parent.paddingLeft + parent.paddingRight\n : parent.paddingTop + parent.paddingBottom) + strokeRoom(parent, children, axis)\n const gap =\n parent.primaryAxisAlign === 'SPACE_BETWEEN'\n ? 0\n : parent.itemSpacing * Math.max(0, children.length - 1)\n const available = axis === 'width' ? parent.width : parent.height\n const total = sizes.reduce<number>((sum, size) => sum + (size ?? 0), padding + gap)\n return Math.abs(total - available) < 0.001\n}\n\nfunction derivedMainAxisFitsParent(\n graph: SceneGraph,\n parent: SceneNode,\n child: SceneNode,\n axis: 'width' | 'height'\n): boolean {\n if (!keepsSavedLayout(graph, parent)) return false\n const children = graph\n .getChildren(parent.id)\n .filter(\n (candidate) =>\n candidate.visible &&\n candidate.type !== 'SLICE' &&\n candidate.layoutPositioning !== 'ABSOLUTE'\n )\n if (children.length === 0) return false\n\n const sizes = children.map((candidate) => candidate.derivedLayout?.[axis])\n return sizesFitParent(parent, children, sizes, axis) && child.derivedLayout?.[axis] !== undefined\n}\n\nfunction configureAutoLayoutChildSizing(\n yogaChild: YogaNode,\n child: SceneNode,\n parent: SceneNode,\n graph: SceneGraph,\n widthSizing: LayoutSizing,\n heightSizing: LayoutSizing\n): void {\n const isParentRow = parent.layoutMode === 'HORIZONTAL'\n const fixedDerivedMainAxis = isParentRow\n ? derivedMainAxisFitsParent(graph, parent, child, 'width')\n : derivedMainAxisFitsParent(graph, parent, child, 'height')\n\n if (isParentRow) {\n if (fixedDerivedMainAxis) yogaChild.setWidth(child.derivedLayout?.width ?? child.width)\n else setMainAxisSizing(yogaChild, 'width', widthSizing, child.width, child.layoutGrow)\n const keepsSize = fillKeepsSizeInHuggingParent(child, parent, 'height')\n setCrossAxisSizing(yogaChild, 'height', heightSizing, child.height, keepsSize)\n return\n }\n\n const keepsSize = fillKeepsSizeInHuggingParent(child, parent, 'width')\n setCrossAxisSizing(yogaChild, 'width', widthSizing, child.width, keepsSize)\n if (fixedDerivedMainAxis) yogaChild.setHeight(child.derivedLayout?.height ?? child.height)\n else setMainAxisSizing(yogaChild, 'height', heightSizing, child.height, child.layoutGrow)\n}\n\n/**\n * Whether the parent's pass places this child from the size it holds: neither its content nor the\n * parent decides its size, so its own cells keep their places while the parent moves it.\n */\nfunction placesFromSize(\n child: SceneNode,\n parent: SceneNode,\n widthSizing: LayoutSizing,\n heightSizing: LayoutSizing\n): boolean {\n return (\n widthSizing === 'FIXED' &&\n heightSizing === 'FIXED' &&\n child.layoutGrow === 0 &&\n parent.counterAxisAlign !== 'BASELINE' &&\n child.layoutAlignSelf !== 'BASELINE' &&\n enforcedAspectRatio(child) === null &&\n child.minWidth === null &&\n child.maxWidth === null &&\n child.minHeight === null &&\n child.maxHeight === null\n )\n}\n\n/**\n * Refuses a chain deeper than Yoga can lay out, for the subtrees a pass places from their size and\n * does not build: the same refusal, without the Yoga nodes.\n */\nfunction assertLayoutDepth(graph: SceneGraph, frame: SceneNode, depth: number): void {\n if (depth > MAX_LAYOUT_DEPTH) {\n throw new RangeError(\n `Layers nest more than ${MAX_LAYOUT_DEPTH} auto-layout frames deep, which the layout engine cannot lay out.`\n )\n }\n for (const child of graph.getChildren(frame.id)) {\n if (child.layoutMode === 'NONE' || !child.visible) continue\n if (child.layoutPositioning === 'ABSOLUTE') continue\n assertLayoutDepth(graph, child, depth + 1)\n }\n}\n\nfunction configureChildAsAutoLayout(\n yogaChild: YogaNode,\n child: SceneNode,\n parent: SceneNode,\n graph: SceneGraph,\n inheritedDirection: 'LTR' | 'RTL',\n depth: number\n): void {\n if (depth > MAX_LAYOUT_DEPTH) {\n throw new RangeError(\n `Layers nest more than ${MAX_LAYOUT_DEPTH} auto-layout frames deep, which the layout engine cannot lay out.`\n )\n }\n const direction = resolveNodeLayoutDirection(child, inheritedDirection)\n const widthSizing = layoutSizing(graph, child, 'HORIZONTAL')\n const heightSizing = layoutSizing(graph, child, 'VERTICAL')\n\n configureAutoLayoutChildSizing(yogaChild, child, parent, graph, widthSizing, heightSizing)\n\n const selfAlign = mapAlignSelf(child.layoutAlignSelf)\n if (selfAlign != null) yogaChild.setAlignSelf(selfAlign)\n applyLockedAspectRatio(yogaChild, child, parent)\n\n if (usesDetachedDerivedLayout(graph, child)) {\n // The imported size is what the child's own hug produced, whether or not it also fills.\n const derived = child.derivedLayout\n if (ownAxisSizing(child, 'width') === 'HUG') yogaChild.setWidth(derived?.width ?? child.width)\n if (ownAxisSizing(child, 'height') === 'HUG') {\n yogaChild.setHeight(derived?.height ?? child.height)\n }\n applyMinMaxConstraints(yogaChild, child)\n return\n }\n\n if (placesFromSize(child, parent, widthSizing, heightSizing)) {\n assertLayoutDepth(graph, child, depth + 1)\n return\n }\n\n configureFlexContainer(yogaChild, child, direction)\n const heldAxis = heldHugAxis(graph, child)\n if (heldAxis === 'width' && widthSizing === 'HUG') yogaChild.setWidth(child.width)\n if (heldAxis === 'height' && heightSizing === 'HUG') yogaChild.setHeight(child.height)\n\n insertFlexChildren(yogaChild, child, graph, direction, depth + 1)\n}\n\n/** Puts a frame's children into its Yoga node, through the flow box a negative edge needs. */\nfunction insertFlexChildren(\n yogaParent: YogaNode,\n parent: SceneNode,\n graph: SceneGraph,\n direction: 'LTR' | 'RTL',\n depth: number\n): void {\n const box = insertFlowBox(yogaParent, parent)\n const flow: YogaNode[] = []\n for (const child of graph\n .getChildren(parent.id)\n .map((node) => asLaidOutIn(graph, node, parent))) {\n // A slice is an export region, not an auto-layout child: SliceNode does not extend\n // AutoLayoutChildrenMixin, so it takes no gap, order, or stretch.\n if (child.type === 'SLICE') continue\n const yogaChild = createYogaNode()\n // Attached before it is configured, so a child the depth check refuses still hangs from the\n // root and is freed with it rather than left in WebAssembly memory.\n box.insertChild(yogaChild, box.getChildCount())\n\n if (child.layoutPositioning === 'ABSOLUTE') {\n configureAbsoluteChild(yogaChild, child)\n } else if (!child.visible) {\n yogaChild.setDisplay(Display.None)\n } else {\n if (child.layoutMode === 'GRID') {\n configureChildAsGrid(yogaChild, child, parent, graph, direction)\n } else if (child.layoutMode !== 'NONE') {\n configureChildAsAutoLayout(yogaChild, child, parent, graph, direction, depth)\n } else {\n configureChildAsLeaf(yogaChild, child, parent, graph)\n }\n flow.push(yogaChild)\n }\n applyStrokeMargins(yogaChild, child, parent)\n }\n setFlowEdges(yogaParent, box, parent, flow, direction)\n}\n\nfunction derivedGrowingLeafFitsParent(\n graph: SceneGraph,\n parent: SceneNode,\n child: SceneNode,\n axis: 'width' | 'height'\n): boolean {\n if (child.type !== 'TEXT' || child.layoutGrow <= 0 || child.derivedLayout?.[axis] === undefined) {\n return false\n }\n const children = graph\n .getChildren(parent.id)\n .filter(\n (candidate) =>\n candidate.visible &&\n candidate.type !== 'SLICE' &&\n candidate.layoutPositioning !== 'ABSOLUTE'\n )\n const sizes = children.map((candidate) => {\n if (candidate.layoutGrow > 0) return candidate.derivedLayout?.[axis]\n return axis === 'width' ? candidate.width : candidate.height\n })\n return sizesFitParent(parent, children, sizes, axis)\n}\n\n/**\n * Fill text shares its parent's main axis like a fill frame: it grows and shrinks from a zero\n * basis, so its stored width (100px for new text) never decides its share. Returns whether\n * it fills the row's width, where its stored width must not constrain it either.\n */\nfunction configureGrowingText(\n yogaChild: YogaNode,\n child: SceneNode,\n parent: SceneNode,\n fixedDerivedMainAxis: boolean\n): boolean {\n if (child.layoutGrow <= 0 || fixedDerivedMainAxis) return false\n yogaChild.setFlexGrow(child.layoutGrow)\n yogaChild.setFlexShrink(1)\n yogaChild.setFlexBasis(0)\n return parent.layoutMode === 'HORIZONTAL'\n}\n\nfunction configureTextLeafWithoutMeasurer(\n yogaChild: YogaNode,\n child: SceneNode,\n parent: SceneNode,\n fixedDerivedMainAxis: boolean\n): void {\n const hasStoredSize =\n child.width > 0 && child.height > 0 && !(child.width === 100 && child.height === 100)\n\n if (child.textAutoResize === 'WIDTH_AND_HEIGHT') {\n if (hasStoredSize) {\n yogaChild.setWidth(child.width)\n yogaChild.setHeight(child.height)\n } else {\n const estimated = estimateTextSize(child)\n yogaChild.setWidth(estimated.width)\n yogaChild.setHeight(estimated.height)\n }\n return\n }\n if (child.textAutoResize !== 'HEIGHT') {\n // A truncating text keeps the box it has, as Figma clips it to that box.\n if (child.width > 0 && child.height > 0) {\n yogaChild.setWidth(child.width)\n yogaChild.setHeight(child.height)\n }\n return\n }\n\n const growsWidth = configureGrowingText(yogaChild, child, parent, fixedDerivedMainAxis)\n const isRow = parent.layoutMode === 'HORIZONTAL'\n const measurementWidth = fixedDerivedMainAxis\n ? (child.derivedLayout?.width ?? child.width)\n : child.width\n const stretches =\n child.layoutAlignSelf === 'STRETCH' ||\n (child.layoutAlignSelf === 'AUTO' && parent.counterAxisAlign === 'STRETCH')\n if (!(!isRow && stretches) && !fixedDerivedMainAxis && !growsWidth) {\n yogaChild.setWidth(child.width)\n }\n if (hasStoredSize) yogaChild.setHeight(child.height)\n else yogaChild.setHeight(estimateTextSize(child, measurementWidth).height)\n}\n\nfunction configureChildAsLeaf(\n yogaChild: YogaNode,\n node: SceneNode,\n parent: SceneNode,\n graph: SceneGraph\n): void {\n const child = asFlatLeaf(node, parent)\n const isRow = parent.layoutMode === 'HORIZONTAL'\n const selfOverride = child.layoutAlignSelf !== 'AUTO'\n const stretchCross = selfOverride\n ? child.layoutAlignSelf === 'STRETCH'\n : parent.counterAxisAlign === 'STRETCH'\n\n const isText = child.type === 'TEXT'\n const textMeasurer = getTextMeasurer()\n // A truncating or fixed text keeps its box, so Yoga measures only text that grows.\n const needsMeasureFunc = isText && textMeasurer && growsText(child)\n\n const fixedDerivedMainAxis = isRow\n ? derivedGrowingLeafFitsParent(graph, parent, child, 'width')\n : derivedGrowingLeafFitsParent(graph, parent, child, 'height')\n\n if (fixedDerivedMainAxis) {\n if (isRow) yogaChild.setWidth(child.derivedLayout?.width ?? child.width)\n else yogaChild.setHeight(child.derivedLayout?.height ?? child.height)\n }\n\n if (needsMeasureFunc) {\n configureTextLeaf(yogaChild, child, parent, fixedDerivedMainAxis)\n } else if (isText && !textMeasurer && child.textAutoResize !== 'NONE') {\n configureTextLeafWithoutMeasurer(yogaChild, child, parent, fixedDerivedMainAxis)\n } else {\n configureNonTextLeaf(yogaChild, child, isRow, stretchCross)\n // Fixed text still contributes its box to a HUG cross axis. Without\n // an intrinsic minimum, stretch collapses the text to its siblings.\n if (isText && stretchCross && parent.counterAxisSizing === 'HUG') {\n if (isRow) yogaChild.setMinHeight(child.height)\n else yogaChild.setMinWidth(child.width)\n }\n }\n\n const selfAlign = mapAlignSelf(child.layoutAlignSelf)\n if (selfAlign != null) yogaChild.setAlignSelf(selfAlign)\n\n applyLockedAspectRatio(yogaChild, child, parent)\n applyMinMaxConstraints(yogaChild, child)\n}\n\n/** Whether layout measures a text to size it, which only the two growing modes need. */\nfunction growsText(node: SceneNode): boolean {\n return node.textAutoResize === 'WIDTH_AND_HEIGHT' || node.textAutoResize === 'HEIGHT'\n}\n\nfunction configureTextLeaf(\n yogaChild: YogaNode,\n child: SceneNode,\n parent: SceneNode,\n fixedDerivedMainAxis = false\n): void {\n const autoResize = child.textAutoResize\n const isRow = parent.layoutMode === 'HORIZONTAL'\n const growsWidth = configureGrowingText(yogaChild, child, parent, fixedDerivedMainAxis)\n const stretchesCross =\n child.layoutAlignSelf === 'STRETCH' ||\n (child.layoutAlignSelf === 'AUTO' && parent.counterAxisAlign === 'STRETCH')\n // Layout sets the width of text that grows along a row or stretches across a column.\n const fillsWidth = (!isRow && stretchesCross) || growsWidth\n\n const cache = new Map<number, { width: number; height: number }>()\n const UNCONSTRAINED_KEY = -1\n\n if (autoResize === 'WIDTH_AND_HEIGHT') {\n const importedSize = child.derivedLayout\n if (importedSize?.width !== undefined && importedSize.height !== undefined) {\n yogaChild.setWidth(child.width)\n yogaChild.setHeight(child.height)\n return\n }\n\n // Auto-width text keeps each line whole, as Figma's does, in a parent narrower than the text;\n // only a width that layout or a max width sets wraps it.\n const wraps = fillsWidth || child.maxWidth != null\n yogaChild.setMeasureFunc((width, widthMode, _height, _heightMode) => {\n const maxW = wraps && widthMode !== MeasureMode.Undefined ? width : undefined\n const cacheKey = maxW === undefined ? UNCONSTRAINED_KEY : Math.round(maxW)\n const cached = cache.get(cacheKey)\n if (cached) return cached\n\n const result = measureAutoWidthText(child, maxW ?? autoWidthWrapWidth(child))\n cache.set(cacheKey, result)\n return result\n })\n } else if (autoResize === 'HEIGHT') {\n const fixedWidth = fixedDerivedMainAxis\n ? (child.derivedLayout?.width ?? child.width)\n : child.width\n // Let Yoga stretch or grow fill-width text instead of fixing its stored width.\n if (child.layoutGrow <= 0 && !fillsWidth) {\n yogaChild.setWidth(fixedWidth)\n }\n yogaChild.setMeasureFunc((width, widthMode, _height, _heightMode) => {\n let constraintW = fixedWidth\n if (fillsWidth) {\n if (widthMode !== MeasureMode.Undefined) constraintW = width\n } else if (widthMode !== MeasureMode.Undefined) {\n constraintW = Math.min(width, fixedWidth || width)\n }\n const cacheKey = Math.round(constraintW)\n const cached = cache.get(cacheKey)\n if (cached) return cached\n\n if (constraintW === child.width && (child.derivedTextGlyphs?.length ?? 0) > 0) {\n return { width: constraintW, height: child.height }\n }\n const result = { width: constraintW, height: measureTextForLayout(child, constraintW).height }\n cache.set(cacheKey, result)\n return result\n })\n }\n}\n"],"mappings":";;;;;;;;;;;;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.d.ts","names":[],"sources":["../../src/node/fs.ts"],"mappings":";UAKiB;;EAEf;;;;;;EAMA;;;;;;;iBAuDoB,gBACpB,cACA,eAAe,YACf,UAAS,qBACR"}
package/dist/node/fs.js CHANGED
@@ -1,17 +1,38 @@
1
1
  import { randomHex } from "@pairdraw/scene-graph/random";
2
- import { chmod, lstat, open, realpath, rename, unlink, writeFile } from "node:fs/promises";
3
- import { basename, dirname, join } from "node:path";
2
+ import { chmod, lstat, open, readlink, realpath, rename, unlink, writeFile } from "node:fs/promises";
3
+ import { basename, dirname, isAbsolute, join } from "node:path";
4
4
  //#region src/node/fs.ts
5
5
  function hasCode(error, ...codes) {
6
6
  return error instanceof Error && "code" in error && codes.includes(String(error.code));
7
7
  }
8
+ /** How many links one path may cross; the system limit is 40 on Linux. */
9
+ const MAX_LINK_HOPS = 40;
10
+ /**
11
+ * The file `follow` writes: the link's final target. `realpath` resolves a chain that exists; a
12
+ * dangling link is followed by its own text so writing it creates the target, as `writeFile` does,
13
+ * instead of replacing the link with a regular file.
14
+ */
8
15
  async function resolveTarget(path) {
9
- try {
10
- return await realpath(path);
11
- } catch (error) {
12
- if (hasCode(error, "ENOENT")) return path;
13
- throw error;
16
+ let current = path;
17
+ for (let hops = 0; hops < MAX_LINK_HOPS; hops += 1) {
18
+ try {
19
+ return await realpath(current);
20
+ } catch (error) {
21
+ if (!hasCode(error, "ENOENT")) throw error;
22
+ }
23
+ let link;
24
+ try {
25
+ if (!(await lstat(current)).isSymbolicLink()) return current;
26
+ link = await readlink(current);
27
+ } catch (error) {
28
+ if (hasCode(error, "ENOENT")) return current;
29
+ throw error;
30
+ }
31
+ current = isAbsolute(link) ? link : join(dirname(current), link);
14
32
  }
33
+ const error = /* @__PURE__ */ new Error(`Too many symbolic links at ${path}`);
34
+ error.code = "ELOOP";
35
+ throw error;
15
36
  }
16
37
  /** The mode of the regular file at `path`, which a symlink or a missing file does not have. */
17
38
  async function fileMode(path) {
@@ -1 +1 @@
1
- {"version":3,"file":"fs.js","names":[],"sources":["../../src/node/fs.ts"],"sourcesContent":["import { chmod, lstat, open, realpath, rename, unlink, writeFile } from 'node:fs/promises'\nimport { basename, dirname, join } from 'node:path'\n\nimport { randomHex } from '@pairdraw/scene-graph/random'\n\nexport interface AtomicWriteOptions {\n /** The file's mode; an existing file otherwise keeps its own, and a new one gets the default. */\n mode?: number\n /**\n * What a symlink at `path` gets. `replace`, the default, puts the new file where the link was,\n * as a rename does, so a file kept under a root is never written outside it through a planted\n * link. `follow` writes the file the link points at, as a document saved in place should.\n */\n symlink?: 'follow' | 'replace'\n}\n\nfunction hasCode(error: unknown, ...codes: string[]): boolean {\n return error instanceof Error && 'code' in error && codes.includes(String(error.code))\n}\n\nasync function resolveTarget(path: string): Promise<string> {\n try {\n return await realpath(path)\n } catch (error) {\n if (hasCode(error, 'ENOENT')) return path\n throw error\n }\n}\n\n/** The mode of the regular file at `path`, which a symlink or a missing file does not have. */\nasync function fileMode(path: string): Promise<number | undefined> {\n try {\n const stats = await lstat(path)\n return stats.isFile() ? stats.mode & 0o7777 : undefined\n } catch (error) {\n if (hasCode(error, 'ENOENT')) return undefined\n throw error\n }\n}\n\n/**\n * Writes `data` to `path` all at once: into a new file beside it, which then replaces it, so a\n * reader never sees half a file and a failed write leaves the old one. An existing file in a\n * directory that takes no new files is written in place, as it could be before.\n */\nexport async function writeFileAtomic(\n path: string,\n data: string | Uint8Array,\n options: AtomicWriteOptions = {}\n): Promise<void> {\n const target = options.symlink === 'follow' ? await resolveTarget(path) : path\n const existing = await fileMode(target)\n const mode = options.mode ?? existing\n const temporary = join(dirname(target), `.${basename(target)}.${randomHex(8)}.tmp`)\n let handle\n try {\n handle = await open(temporary, 'wx', mode ?? 0o666)\n } catch (error) {\n if (existing === undefined || !hasCode(error, 'EACCES', 'EPERM')) throw error\n await writeFile(target, data)\n return\n }\n try {\n try {\n await handle.writeFile(data)\n // The mode `open` takes is masked by the umask; the file keeps the one it had.\n if (mode !== undefined) await chmod(temporary, mode)\n await handle.sync()\n } finally {\n await handle.close()\n }\n await rename(temporary, target)\n } catch (error) {\n await unlink(temporary).catch(() => undefined)\n throw error\n }\n}\n"],"mappings":";;;;AAgBA,SAAS,QAAQ,OAAgB,GAAG,OAA0B;CAC5D,OAAO,iBAAiB,SAAS,UAAU,SAAS,MAAM,SAAS,OAAO,MAAM,IAAI,CAAC;AACvF;AAEA,eAAe,cAAc,MAA+B;CAC1D,IAAI;EACF,OAAO,MAAM,SAAS,IAAI;CAC5B,SAAS,OAAO;EACd,IAAI,QAAQ,OAAO,QAAQ,GAAG,OAAO;EACrC,MAAM;CACR;AACF;;AAGA,eAAe,SAAS,MAA2C;CACjE,IAAI;EACF,MAAM,QAAQ,MAAM,MAAM,IAAI;EAC9B,OAAO,MAAM,OAAO,IAAI,MAAM,OAAO,OAAS,KAAA;CAChD,SAAS,OAAO;EACd,IAAI,QAAQ,OAAO,QAAQ,GAAG,OAAO,KAAA;EACrC,MAAM;CACR;AACF;;;;;;AAOA,eAAsB,gBACpB,MACA,MACA,UAA8B,CAAC,GAChB;CACf,MAAM,SAAS,QAAQ,YAAY,WAAW,MAAM,cAAc,IAAI,IAAI;CAC1E,MAAM,WAAW,MAAM,SAAS,MAAM;CACtC,MAAM,OAAO,QAAQ,QAAQ;CAC7B,MAAM,YAAY,KAAK,QAAQ,MAAM,GAAG,IAAI,SAAS,MAAM,EAAE,GAAG,UAAU,CAAC,EAAE,KAAK;CAClF,IAAI;CACJ,IAAI;EACF,SAAS,MAAM,KAAK,WAAW,MAAM,QAAQ,GAAK;CACpD,SAAS,OAAO;EACd,IAAI,aAAa,KAAA,KAAa,CAAC,QAAQ,OAAO,UAAU,OAAO,GAAG,MAAM;EACxE,MAAM,UAAU,QAAQ,IAAI;EAC5B;CACF;CACA,IAAI;EACF,IAAI;GACF,MAAM,OAAO,UAAU,IAAI;GAE3B,IAAI,SAAS,KAAA,GAAW,MAAM,MAAM,WAAW,IAAI;GACnD,MAAM,OAAO,KAAK;EACpB,UAAU;GACR,MAAM,OAAO,MAAM;EACrB;EACA,MAAM,OAAO,WAAW,MAAM;CAChC,SAAS,OAAO;EACd,MAAM,OAAO,SAAS,CAAC,CAAC,YAAY,KAAA,CAAS;EAC7C,MAAM;CACR;AACF"}
1
+ {"version":3,"file":"fs.js","names":[],"sources":["../../src/node/fs.ts"],"sourcesContent":["import { chmod, lstat, open, readlink, realpath, rename, unlink, writeFile } from 'node:fs/promises'\nimport { basename, dirname, isAbsolute, join } from 'node:path'\n\nimport { randomHex } from '@pairdraw/scene-graph/random'\n\nexport interface AtomicWriteOptions {\n /** The file's mode; an existing file otherwise keeps its own, and a new one gets the default. */\n mode?: number\n /**\n * What a symlink at `path` gets. `replace`, the default, puts the new file where the link was,\n * as a rename does, so a file kept under a root is never written outside it through a planted\n * link. `follow` writes the file the link points at, as a document saved in place should.\n */\n symlink?: 'follow' | 'replace'\n}\n\nfunction hasCode(error: unknown, ...codes: string[]): boolean {\n return error instanceof Error && 'code' in error && codes.includes(String(error.code))\n}\n\n/** How many links one path may cross; the system limit is 40 on Linux. */\nconst MAX_LINK_HOPS = 40\n\n/**\n * The file `follow` writes: the link's final target. `realpath` resolves a chain that exists; a\n * dangling link is followed by its own text so writing it creates the target, as `writeFile` does,\n * instead of replacing the link with a regular file.\n */\nasync function resolveTarget(path: string): Promise<string> {\n let current = path\n for (let hops = 0; hops < MAX_LINK_HOPS; hops += 1) {\n try {\n return await realpath(current)\n } catch (error) {\n if (!hasCode(error, 'ENOENT')) throw error\n }\n let link: string\n try {\n const stats = await lstat(current)\n if (!stats.isSymbolicLink()) return current\n link = await readlink(current)\n } catch (error) {\n if (hasCode(error, 'ENOENT')) return current\n throw error\n }\n current = isAbsolute(link) ? link : join(dirname(current), link)\n }\n const error = new Error(`Too many symbolic links at ${path}`) as NodeJS.ErrnoException\n error.code = 'ELOOP'\n throw error\n}\n\n/** The mode of the regular file at `path`, which a symlink or a missing file does not have. */\nasync function fileMode(path: string): Promise<number | undefined> {\n try {\n const stats = await lstat(path)\n return stats.isFile() ? stats.mode & 0o7777 : undefined\n } catch (error) {\n if (hasCode(error, 'ENOENT')) return undefined\n throw error\n }\n}\n\n/**\n * Writes `data` to `path` all at once: into a new file beside it, which then replaces it, so a\n * reader never sees half a file and a failed write leaves the old one. An existing file in a\n * directory that takes no new files is written in place, as it could be before.\n */\nexport async function writeFileAtomic(\n path: string,\n data: string | Uint8Array,\n options: AtomicWriteOptions = {}\n): Promise<void> {\n const target = options.symlink === 'follow' ? await resolveTarget(path) : path\n const existing = await fileMode(target)\n const mode = options.mode ?? existing\n const temporary = join(dirname(target), `.${basename(target)}.${randomHex(8)}.tmp`)\n let handle\n try {\n handle = await open(temporary, 'wx', mode ?? 0o666)\n } catch (error) {\n if (existing === undefined || !hasCode(error, 'EACCES', 'EPERM')) throw error\n // As `writeFile` would: this branch keeps its old behaviour for a directory that takes no new\n // files, so unlike the rename above it follows a link swapped in since the resolve.\n await writeFile(target, data)\n return\n }\n try {\n try {\n await handle.writeFile(data)\n // The mode `open` takes is masked by the umask; the file keeps the one it had.\n if (mode !== undefined) await chmod(temporary, mode)\n await handle.sync()\n } finally {\n await handle.close()\n }\n await rename(temporary, target)\n } catch (error) {\n await unlink(temporary).catch(() => undefined)\n throw error\n }\n}\n"],"mappings":";;;;AAgBA,SAAS,QAAQ,OAAgB,GAAG,OAA0B;CAC5D,OAAO,iBAAiB,SAAS,UAAU,SAAS,MAAM,SAAS,OAAO,MAAM,IAAI,CAAC;AACvF;;AAGA,MAAM,gBAAgB;;;;;;AAOtB,eAAe,cAAc,MAA+B;CAC1D,IAAI,UAAU;CACd,KAAK,IAAI,OAAO,GAAG,OAAO,eAAe,QAAQ,GAAG;EAClD,IAAI;GACF,OAAO,MAAM,SAAS,OAAO;EAC/B,SAAS,OAAO;GACd,IAAI,CAAC,QAAQ,OAAO,QAAQ,GAAG,MAAM;EACvC;EACA,IAAI;EACJ,IAAI;GAEF,IAAI,EAAC,MADe,MAAM,OAAO,EAAA,CACtB,eAAe,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AAC,YAAY,KAAA,CAAS;EAC7C,MAAM;CACR;AACF"}
@@ -1,13 +1,21 @@
1
- import { PrototypeEasingType } from "@pairdraw/scene-graph";
1
+ import { PrototypeCubicBezier, PrototypeEasingType, PrototypeSpring } from "@pairdraw/scene-graph";
2
2
  //#region src/prototype/easing.d.ts
3
+ /** How a transition's easing plays: its type and the data a custom type needs. */
4
+ interface EasingPlayback {
5
+ curve?: PrototypeCubicBezier;
6
+ spring?: PrototypeSpring;
7
+ /** The transition's length in seconds; a spring settles over it. */
8
+ duration?: number;
9
+ }
3
10
  /**
4
11
  * How far along a transition eased by `easing` is at `progress` of its time, from 0 to 1; no
5
12
  * easing eases as Figma's default does. The player and a recording both read it, so they move
6
- * alike.
13
+ * alike. A spring plays its damped-oscillator solution over the transition's own duration, which
14
+ * Figma exposes beside the spring in the transition panel.
7
15
  */
8
- declare function easingAt(easing: PrototypeEasingType | undefined, progress: number): number;
16
+ declare function easingAt(easing: PrototypeEasingType | undefined, progress: number, playback?: EasingPlayback): number;
9
17
  /** `easing` as a CSS timing function, for a transition the browser animates. */
10
- declare function easingCSS(easing: PrototypeEasingType | undefined): string;
18
+ declare function easingCSS(easing: PrototypeEasingType | undefined, curve?: PrototypeCubicBezier): string;
11
19
  //#endregion
12
- export { easingAt, easingCSS };
20
+ export { EasingPlayback, easingAt, easingCSS };
13
21
  //# sourceMappingURL=easing.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"easing.d.ts","names":[],"sources":["../../src/prototype/easing.ts"],"mappings":";;;;;;;iBAegB,SAAS,QAAQ,iCAAiC;;iBAiBlD,UAAU,QAAQ"}
1
+ {"version":3,"file":"easing.d.ts","names":[],"sources":["../../src/prototype/easing.ts"],"mappings":";;;UAmBiB;EACf,QAAQ;EACR,SAAS;;EAET;;;;;;;;iBAkCc,SACd,QAAQ,iCACR,kBACA,WAAU;;iBA+BI,UACd,QAAQ,iCACR,QAAQ"}
@@ -1,19 +1,52 @@
1
- import { DEFAULT_PROTOTYPE_EASING, PROTOTYPE_EASING_CURVES } from "@pairdraw/scene-graph/constants";
1
+ import { DEFAULT_PROTOTYPE_EASING, PROTOTYPE_EASING_CURVES, PROTOTYPE_SPRING_PRESETS } from "@pairdraw/scene-graph/constants";
2
2
  //#region src/prototype/easing.ts
3
3
  /** Bisection steps that solve a curve's x for its t; 32 halvings are far below a pixel. */
4
4
  const BISECTION_STEPS = 32;
5
5
  function bezier(t, p1, p2) {
6
6
  return 3 * (1 - t) * (1 - t) * t * p1 + 3 * (1 - t) * t * t * p2 + t * t * t;
7
7
  }
8
+ function springAt(spring, progress, duration) {
9
+ const time = progress * duration;
10
+ const { mass, stiffness, damping, initialVelocity } = spring;
11
+ if (mass <= 0 || stiffness <= 0) return progress;
12
+ const omega = Math.sqrt(stiffness / mass);
13
+ const zeta = damping / (2 * Math.sqrt(stiffness * mass));
14
+ if (zeta < 1) {
15
+ const damped = omega * Math.sqrt(1 - zeta * zeta);
16
+ return 1 - Math.exp(-zeta * omega * time) * (Math.cos(damped * time) + (zeta * omega + initialVelocity) / damped * Math.sin(damped * time));
17
+ }
18
+ if (zeta === 1) return 1 - Math.exp(-omega * time) * (1 + (omega + initialVelocity) * time);
19
+ const root = omega * Math.sqrt(zeta * zeta - 1);
20
+ const r1 = -zeta * omega + root;
21
+ const r2 = -zeta * omega - root;
22
+ const e1 = Math.exp(r1 * time);
23
+ const e2 = Math.exp(r2 * time);
24
+ return 1 + (r2 * e1 - r1 * e2) / (r1 - r2) + initialVelocity * (e1 - e2) / (r1 - r2);
25
+ }
8
26
  /**
9
27
  * How far along a transition eased by `easing` is at `progress` of its time, from 0 to 1; no
10
28
  * easing eases as Figma's default does. The player and a recording both read it, so they move
11
- * alike.
29
+ * alike. A spring plays its damped-oscillator solution over the transition's own duration, which
30
+ * Figma exposes beside the spring in the transition panel.
12
31
  */
13
- function easingAt(easing, progress) {
32
+ function easingAt(easing, progress, playback = {}) {
14
33
  if (progress <= 0) return 0;
15
34
  if (progress >= 1) return 1;
16
- const [x1, y1, x2, y2] = PROTOTYPE_EASING_CURVES[easing ?? DEFAULT_PROTOTYPE_EASING];
35
+ const type = easing ?? DEFAULT_PROTOTYPE_EASING;
36
+ if (type === "CUSTOM_SPRING" || type in PROTOTYPE_SPRING_PRESETS) return springAt(type === "CUSTOM_SPRING" ? playback.spring ?? PROTOTYPE_SPRING_PRESETS.GENTLE : PROTOTYPE_SPRING_PRESETS[type], progress, playback.duration ?? .45);
37
+ const curve = type === "CUSTOM_CUBIC_BEZIER" && playback.curve ? playback.curve : void 0;
38
+ const DEFAULT_CURVE = PROTOTYPE_EASING_CURVES[DEFAULT_PROTOTYPE_EASING] ?? [
39
+ 0,
40
+ 0,
41
+ .58,
42
+ 1
43
+ ];
44
+ const [x1, y1, x2, y2] = curve ? [
45
+ curve.x1,
46
+ curve.y1,
47
+ curve.x2,
48
+ curve.y2
49
+ ] : PROTOTYPE_EASING_CURVES[type] ?? DEFAULT_CURVE;
17
50
  if (x1 === y1 && x2 === y2) return progress;
18
51
  let low = 0;
19
52
  let high = 1;
@@ -25,8 +58,15 @@ function easingAt(easing, progress) {
25
58
  return bezier((low + high) / 2, y1, y2);
26
59
  }
27
60
  /** `easing` as a CSS timing function, for a transition the browser animates. */
28
- function easingCSS(easing) {
29
- const [x1, y1, x2, y2] = PROTOTYPE_EASING_CURVES[easing ?? DEFAULT_PROTOTYPE_EASING];
61
+ function easingCSS(easing, curve) {
62
+ if (easing === "CUSTOM_CUBIC_BEZIER" && curve) return `cubic-bezier(${curve.x1}, ${curve.y1}, ${curve.x2}, ${curve.y2})`;
63
+ if (easing === "CUSTOM_SPRING" || easing !== void 0 && easing in PROTOTYPE_SPRING_PRESETS) return "ease-out";
64
+ const [x1, y1, x2, y2] = PROTOTYPE_EASING_CURVES[easing ?? DEFAULT_PROTOTYPE_EASING] ?? PROTOTYPE_EASING_CURVES[DEFAULT_PROTOTYPE_EASING] ?? [
65
+ 0,
66
+ 0,
67
+ .58,
68
+ 1
69
+ ];
30
70
  if (x1 === y1 && x2 === y2) return "linear";
31
71
  return `cubic-bezier(${x1}, ${y1}, ${x2}, ${y2})`;
32
72
  }
@@ -1 +1 @@
1
- {"version":3,"file":"easing.js","names":[],"sources":["../../src/prototype/easing.ts"],"sourcesContent":["import type { PrototypeEasingType } from '@pairdraw/scene-graph'\nimport { DEFAULT_PROTOTYPE_EASING, PROTOTYPE_EASING_CURVES } from '@pairdraw/scene-graph/constants'\n\n/** Bisection steps that solve a curve's x for its t; 32 halvings are far below a pixel. */\nconst BISECTION_STEPS = 32\n\nfunction bezier(t: number, p1: number, p2: number): number {\n return 3 * (1 - t) * (1 - t) * t * p1 + 3 * (1 - t) * t * t * p2 + t * t * t\n}\n\n/**\n * How far along a transition eased by `easing` is at `progress` of its time, from 0 to 1; no\n * easing eases as Figma's default does. The player and a recording both read it, so they move\n * alike.\n */\nexport function easingAt(easing: PrototypeEasingType | undefined, progress: number): number {\n if (progress <= 0) return 0\n if (progress >= 1) return 1\n const [x1, y1, x2, y2] = PROTOTYPE_EASING_CURVES[easing ?? DEFAULT_PROTOTYPE_EASING]\n if (x1 === y1 && x2 === y2) return progress\n // x(t) rises monotonically, so bisection finds the t whose x is `progress`.\n let low = 0\n let high = 1\n for (let index = 0; index < BISECTION_STEPS; index++) {\n const middle = (low + high) / 2\n if (bezier(middle, x1, x2) < progress) low = middle\n else high = middle\n }\n return bezier((low + high) / 2, y1, y2)\n}\n\n/** `easing` as a CSS timing function, for a transition the browser animates. */\nexport function easingCSS(easing: PrototypeEasingType | undefined): string {\n const [x1, y1, x2, y2] = PROTOTYPE_EASING_CURVES[easing ?? DEFAULT_PROTOTYPE_EASING]\n if (x1 === y1 && x2 === y2) return 'linear'\n return `cubic-bezier(${x1}, ${y1}, ${x2}, ${y2})`\n}\n"],"mappings":";;;AAIA,MAAM,kBAAkB;AAExB,SAAS,OAAO,GAAW,IAAY,IAAoB;CACzD,OAAO,KAAK,IAAI,MAAM,IAAI,KAAK,IAAI,KAAK,KAAK,IAAI,KAAK,IAAI,IAAI,KAAK,IAAI,IAAI;AAC7E;;;;;;AAOA,SAAgB,SAAS,QAAyC,UAA0B;CAC1F,IAAI,YAAY,GAAG,OAAO;CAC1B,IAAI,YAAY,GAAG,OAAO;CAC1B,MAAM,CAAC,IAAI,IAAI,IAAI,MAAM,wBAAwB,UAAU;CAC3D,IAAI,OAAO,MAAM,OAAO,IAAI,OAAO;CAEnC,IAAI,MAAM;CACV,IAAI,OAAO;CACX,KAAK,IAAI,QAAQ,GAAG,QAAQ,iBAAiB,SAAS;EACpD,MAAM,UAAU,MAAM,QAAQ;EAC9B,IAAI,OAAO,QAAQ,IAAI,EAAE,IAAI,UAAU,MAAM;OACxC,OAAO;CACd;CACA,OAAO,QAAQ,MAAM,QAAQ,GAAG,IAAI,EAAE;AACxC;;AAGA,SAAgB,UAAU,QAAiD;CACzE,MAAM,CAAC,IAAI,IAAI,IAAI,MAAM,wBAAwB,UAAU;CAC3D,IAAI,OAAO,MAAM,OAAO,IAAI,OAAO;CACnC,OAAO,gBAAgB,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG;AACjD"}
1
+ {"version":3,"file":"easing.js","names":[],"sources":["../../src/prototype/easing.ts"],"sourcesContent":["import type {\n PrototypeCubicBezier,\n PrototypeEasingType,\n PrototypeSpring\n} from '@pairdraw/scene-graph'\nimport {\n DEFAULT_PROTOTYPE_EASING,\n PROTOTYPE_EASING_CURVES,\n PROTOTYPE_SPRING_PRESETS\n} from '@pairdraw/scene-graph/constants'\n\n/** Bisection steps that solve a curve's x for its t; 32 halvings are far below a pixel. */\nconst BISECTION_STEPS = 32\n\nfunction bezier(t: number, p1: number, p2: number): number {\n return 3 * (1 - t) * (1 - t) * t * p1 + 3 * (1 - t) * t * t * p2 + t * t * t\n}\n\n/** How a transition's easing plays: its type and the data a custom type needs. */\nexport interface EasingPlayback {\n curve?: PrototypeCubicBezier\n spring?: PrototypeSpring\n /** The transition's length in seconds; a spring settles over it. */\n duration?: number\n}\n\nfunction springAt(spring: PrototypeSpring, progress: number, duration: number): number {\n const time = progress * duration\n const { mass, stiffness, damping, initialVelocity } = spring\n if (mass <= 0 || stiffness <= 0) return progress\n const omega = Math.sqrt(stiffness / mass)\n const zeta = damping / (2 * Math.sqrt(stiffness * mass))\n if (zeta < 1) {\n const damped = omega * Math.sqrt(1 - zeta * zeta)\n return (\n 1 -\n Math.exp(-zeta * omega * time) *\n (Math.cos(damped * time) +\n ((zeta * omega + initialVelocity) / damped) * Math.sin(damped * time))\n )\n }\n if (zeta === 1) return 1 - Math.exp(-omega * time) * (1 + (omega + initialVelocity) * time)\n // Overdamped: two real roots, not the critical-damping approximation.\n const root = omega * Math.sqrt(zeta * zeta - 1)\n const r1 = -zeta * omega + root\n const r2 = -zeta * omega - root\n const e1 = Math.exp(r1 * time)\n const e2 = Math.exp(r2 * time)\n return 1 + (r2 * e1 - r1 * e2) / (r1 - r2) + (initialVelocity * (e1 - e2)) / (r1 - r2)\n}\n\n/**\n * How far along a transition eased by `easing` is at `progress` of its time, from 0 to 1; no\n * easing eases as Figma's default does. The player and a recording both read it, so they move\n * alike. A spring plays its damped-oscillator solution over the transition's own duration, which\n * Figma exposes beside the spring in the transition panel.\n */\nexport function easingAt(\n easing: PrototypeEasingType | undefined,\n progress: number,\n playback: EasingPlayback = {}\n): number {\n if (progress <= 0) return 0\n if (progress >= 1) return 1\n const type = easing ?? DEFAULT_PROTOTYPE_EASING\n if (type === 'CUSTOM_SPRING' || type in PROTOTYPE_SPRING_PRESETS) {\n const spring =\n type === 'CUSTOM_SPRING'\n ? (playback.spring ?? PROTOTYPE_SPRING_PRESETS.GENTLE)\n : PROTOTYPE_SPRING_PRESETS[type as keyof typeof PROTOTYPE_SPRING_PRESETS]\n return springAt(spring, progress, playback.duration ?? 0.45)\n }\n const curve = type === 'CUSTOM_CUBIC_BEZIER' && playback.curve ? playback.curve : undefined\n const DEFAULT_CURVE =\n PROTOTYPE_EASING_CURVES[DEFAULT_PROTOTYPE_EASING] ?? ([0, 0, 0.58, 1] as const)\n const [x1, y1, x2, y2] = curve\n ? [curve.x1, curve.y1, curve.x2, curve.y2]\n : (PROTOTYPE_EASING_CURVES[type] ?? DEFAULT_CURVE)\n if (x1 === y1 && x2 === y2) return progress\n // x(t) rises monotonically, so bisection finds the t whose x is `progress`.\n let low = 0\n let high = 1\n for (let index = 0; index < BISECTION_STEPS; index++) {\n const middle = (low + high) / 2\n if (bezier(middle, x1, x2) < progress) low = middle\n else high = middle\n }\n return bezier((low + high) / 2, y1, y2)\n}\n\n/** `easing` as a CSS timing function, for a transition the browser animates. */\nexport function easingCSS(\n easing: PrototypeEasingType | undefined,\n curve?: PrototypeCubicBezier\n): string {\n if (easing === 'CUSTOM_CUBIC_BEZIER' && curve)\n return `cubic-bezier(${curve.x1}, ${curve.y1}, ${curve.x2}, ${curve.y2})`\n // The app baseline predates CSS `linear()` (Chrome 111, Safari 16.4), so a spring dissolve\n // snapshot eases out instead of sampling the physical curve; documented on the roadmap.\n if (easing === 'CUSTOM_SPRING' || (easing !== undefined && easing in PROTOTYPE_SPRING_PRESETS))\n return 'ease-out'\n const points =\n PROTOTYPE_EASING_CURVES[easing ?? DEFAULT_PROTOTYPE_EASING] ??\n PROTOTYPE_EASING_CURVES[DEFAULT_PROTOTYPE_EASING] ??\n ([0, 0, 0.58, 1] as const)\n const [x1, y1, x2, y2] = points\n if (x1 === y1 && x2 === y2) return 'linear'\n return `cubic-bezier(${x1}, ${y1}, ${x2}, ${y2})`\n}\n"],"mappings":";;;AAYA,MAAM,kBAAkB;AAExB,SAAS,OAAO,GAAW,IAAY,IAAoB;CACzD,OAAO,KAAK,IAAI,MAAM,IAAI,KAAK,IAAI,KAAK,KAAK,IAAI,KAAK,IAAI,IAAI,KAAK,IAAI,IAAI;AAC7E;AAUA,SAAS,SAAS,QAAyB,UAAkB,UAA0B;CACrF,MAAM,OAAO,WAAW;CACxB,MAAM,EAAE,MAAM,WAAW,SAAS,oBAAoB;CACtD,IAAI,QAAQ,KAA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,MAAM;EAAI,MAAM;CAAE,IACtC,wBAAwB,SAAS;CACtC,IAAI,OAAO,MAAM,OAAO,IAAI,OAAO;CAEnC,IAAI,MAAM;CACV,IAAI,OAAO;CACX,KAAK,IAAI,QAAQ,GAAG,QAAQ,iBAAiB,SAAS;EACpD,MAAM,UAAU,MAAM,QAAQ;EAC9B,IAAI,OAAO,QAAQ,IAAI,EAAE,IAAI,UAAU,MAAM;OACxC,OAAO;CACd;CACA,OAAO,QAAQ,MAAM,QAAQ,GAAG,IAAI,EAAE;AACxC;;AAGA,SAAgB,UACd,QACA,OACQ;CACR,IAAI,WAAW,yBAAyB,OACtC,OAAO,gBAAgB,MAAM,GAAG,IAAI,MAAM,GAAG,IAAI,MAAM,GAAG,IAAI,MAAM,GAAG;CAGzE,IAAI,WAAW,mBAAoB,WAAW,KAAA,KAAa,UAAU,0BACnE,OAAO;CAKT,MAAM,CAAC,IAAI,IAAI,IAAI,MAHjB,wBAAwB,UAAU,6BAClC,wBAAwB,6BACvB;EAAC;EAAG;EAAG;EAAM;CAAC;CAEjB,IAAI,OAAO,MAAM,OAAO,IAAI,OAAO;CACnC,OAAO,gBAAgB,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG;AACjD"}
@@ -36,6 +36,12 @@ interface PlayStep {
36
36
  * the player to run over the transition's duration; the copy shows the change at once.
37
37
  */
38
38
  animation?: SmartAnimation;
39
+ /** Why a variable action could not run; the player shows it instead of guessing a value. */
40
+ variablesRefused?: string;
41
+ /** The action actually run, after a Conditional picked a branch. */
42
+ action?: PrototypeAction;
43
+ /** Whether play's variable values changed, so a frame showing them must be drawn again. */
44
+ repaint?: boolean;
39
45
  }
40
46
  /**
41
47
  * The frames play changed, each kept as a private copy so the document never changes. Frames move
@@ -45,6 +51,31 @@ interface PlayStep {
45
51
  interface PlayScenes {
46
52
  /** The graph play reads a top-level frame from: its copy once changed, else the document. */
47
53
  graphFor(rootId: string): SceneGraph;
54
+ /**
55
+ * A fresh copy of `rootId` with the session's variable values and modes applied, for a caller
56
+ * that must keep the state it sees after play moves on (a video's earlier frames).
57
+ */
58
+ cloneGraphFor(rootId: string): SceneGraph;
59
+ /**
60
+ * The action a Conditional would run now, resolving nested conditionals; a condition this build
61
+ * cannot evaluate is refused with its reason.
62
+ */
63
+ resolve(action: PrototypeAction, rootId?: string): {
64
+ action: PrototypeAction;
65
+ } | {
66
+ refused: string;
67
+ };
68
+ /**
69
+ * The actions of the first matching Conditional branch, or `[action]` for any other action; a
70
+ * condition this build cannot evaluate is refused with its reason.
71
+ */
72
+ resolveBranch(action: PrototypeAction, rootId?: string): {
73
+ actions: readonly PrototypeAction[];
74
+ } | {
75
+ refused: string;
76
+ };
77
+ /** Whether this session has changed a variable's value or a collection's mode. */
78
+ hasVariables(): boolean;
48
79
  /** The changed frames the canvas draws from their copies, by frame id. */
49
80
  readonly views: ReadonlyMap<string, PlaySceneView>;
50
81
  /** How far play scrolled each frame that scrolls, by frame id. */
@@ -1 +1 @@
1
- {"version":3,"file":"scenes.d.ts","names":[],"sources":["../../src/prototype/scenes.ts"],"mappings":";;;;;;;;;cA8Ba;;;;;;UAOI;EACf;;EAEA;EACA;EACA,QAAQ;EACR;;;;;;;UAQe;EACf,SAAS;EACT,SAAS;EACT,WAAW;EACX,SAAS;;;;;EAKT,YAAY;;;;;;;UAQG;;EAEf,SAAS,iBAAiB;;WAEjB,OAAO,oBAAoB;;WAE3B,QAAQ,oBAAoB;;;;;EAKrC,SAAS,gBAAgB,yBAAyB,YAAY,aAAa;;EAE3E,UAAU,YAAY,QAAQ;;EAE9B,IAAI,SAAS,aAAa,OAAO,WAAW,kBAAkB;;;;;EAK9D,OAAO,SAAS,aAAa,QAAQ,aAAa;;;;;EAKlD,iBAAiB,iBAAiB;;;;;EAKlC,OAAO,SAAS;EAChB;;iBAGc,iBACd,mBAAmB,YACnB,iBACC"}
1
+ {"version":3,"file":"scenes.d.ts","names":[],"sources":["../../src/prototype/scenes.ts"],"mappings":";;;;;;;;;cAmCa;;;;;;UAOI;EACf;;EAEA;EACA;EACA,QAAQ;EACR;;;;;;;UAQe;EACf,SAAS;EACT,SAAS;EACT,WAAW;EACX,SAAS;;;;;EAKT,YAAY;;EAEZ;;EAEA,SAAS;;EAET;;;;;;;UAQe;;EAEf,SAAS,iBAAiB;;;;;EAK1B,cAAc,iBAAiB;;;;;EAK/B,QACE,QAAQ,iBACR;IACG,QAAQ;;IAAsB;;;;;;EAKnC,cACE,QAAQ,iBACR;IACG,kBAAkB;;IAAwB;;;EAE/C;;WAES,OAAO,oBAAoB;;WAE3B,QAAQ,oBAAoB;;;;;EAKrC,SAAS,gBAAgB,yBAAyB,YAAY,aAAa;;EAE3E,UAAU,YAAY,QAAQ;;EAE9B,IAAI,SAAS,aAAa,OAAO,WAAW,kBAAkB;;;;;EAK9D,OAAO,SAAS,aAAa,QAAQ,aAAa;;;;;EAKlD,iBAAiB,iBAAiB;;;;;EAKlC,OAAO,SAAS;EAChB;;iBAGc,iBACd,mBAAmB,YACnB,iBACC"}