@pairdraw/core 0.21.0 → 0.22.0

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 (626) 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/index.d.ts +2 -1
  18. package/dist/canvas/index.js +2 -1
  19. package/dist/canvas/layout-grids.d.ts +5 -2
  20. package/dist/canvas/layout-grids.d.ts.map +1 -1
  21. package/dist/canvas/layout-grids.js +7 -2
  22. package/dist/canvas/layout-grids.js.map +1 -1
  23. package/dist/canvas/noise/render.d.ts +17 -4
  24. package/dist/canvas/noise/render.d.ts.map +1 -1
  25. package/dist/canvas/noise/render.js +21 -6
  26. package/dist/canvas/noise/render.js.map +1 -1
  27. package/dist/canvas/noise/shader.d.ts +4 -4
  28. package/dist/canvas/noise/shader.d.ts.map +1 -1
  29. package/dist/canvas/noise/shader.js +5 -6
  30. package/dist/canvas/noise/shader.js.map +1 -1
  31. package/dist/canvas/overlays/annotations.d.ts +19 -0
  32. package/dist/canvas/overlays/annotations.d.ts.map +1 -0
  33. package/dist/canvas/overlays/annotations.js +110 -0
  34. package/dist/canvas/overlays/annotations.js.map +1 -0
  35. package/dist/canvas/overlays/auto-layout-hover.d.ts +11 -1
  36. package/dist/canvas/overlays/auto-layout-hover.d.ts.map +1 -1
  37. package/dist/canvas/overlays/auto-layout-hover.js +25 -1
  38. package/dist/canvas/overlays/auto-layout-hover.js.map +1 -1
  39. package/dist/canvas/overlays/feedback.js +1 -1
  40. package/dist/canvas/overlays/feedback.js.map +1 -1
  41. package/dist/canvas/overlays/index.d.ts +2 -2
  42. package/dist/canvas/overlays/index.js +2 -2
  43. package/dist/canvas/overlays/measurement.d.ts +7 -1
  44. package/dist/canvas/overlays/measurement.d.ts.map +1 -1
  45. package/dist/canvas/overlays/measurement.js +42 -4
  46. package/dist/canvas/overlays/measurement.js.map +1 -1
  47. package/dist/canvas/overlays/presence.d.ts.map +1 -1
  48. package/dist/canvas/overlays/presence.js +21 -24
  49. package/dist/canvas/overlays/presence.js.map +1 -1
  50. package/dist/canvas/renderer/colors.d.ts +7 -1
  51. package/dist/canvas/renderer/colors.d.ts.map +1 -1
  52. package/dist/canvas/renderer/colors.js +9 -1
  53. package/dist/canvas/renderer/colors.js.map +1 -1
  54. package/dist/canvas/renderer/document-surface.d.ts +15 -6
  55. package/dist/canvas/renderer/document-surface.d.ts.map +1 -1
  56. package/dist/canvas/renderer/document-surface.js +1 -0
  57. package/dist/canvas/renderer/document-surface.js.map +1 -1
  58. package/dist/canvas/renderer/lifecycle.d.ts.map +1 -1
  59. package/dist/canvas/renderer/lifecycle.js +2 -2
  60. package/dist/canvas/renderer/lifecycle.js.map +1 -1
  61. package/dist/canvas/renderer/methods.d.ts +1 -0
  62. package/dist/canvas/renderer/methods.d.ts.map +1 -1
  63. package/dist/canvas/renderer/methods.js +4 -1
  64. package/dist/canvas/renderer/methods.js.map +1 -1
  65. package/dist/canvas/renderer/overlay-pass.d.ts.map +1 -1
  66. package/dist/canvas/renderer/overlay-pass.js +6 -1
  67. package/dist/canvas/renderer/overlay-pass.js.map +1 -1
  68. package/dist/canvas/renderer/pipeline.d.ts.map +1 -1
  69. package/dist/canvas/renderer/pipeline.js +7 -0
  70. package/dist/canvas/renderer/pipeline.js.map +1 -1
  71. package/dist/canvas/renderer/types.d.ts +10 -0
  72. package/dist/canvas/renderer/types.d.ts.map +1 -1
  73. package/dist/canvas/renderer.d.ts +10 -2
  74. package/dist/canvas/renderer.d.ts.map +1 -1
  75. package/dist/canvas/renderer.js +15 -3
  76. package/dist/canvas/renderer.js.map +1 -1
  77. package/dist/canvas/scene.d.ts.map +1 -1
  78. package/dist/canvas/scene.js +9 -9
  79. package/dist/canvas/scene.js.map +1 -1
  80. package/dist/canvas/shaders/compile.d.ts +3 -1
  81. package/dist/canvas/shaders/compile.d.ts.map +1 -1
  82. package/dist/canvas/shaders/compile.js +12 -3
  83. package/dist/canvas/shaders/compile.js.map +1 -1
  84. package/dist/canvas/shaders/draw.d.ts.map +1 -1
  85. package/dist/canvas/shaders/draw.js +10 -3
  86. package/dist/canvas/shaders/draw.js.map +1 -1
  87. package/dist/canvas/shaders/effect.d.ts.map +1 -1
  88. package/dist/canvas/shaders/effect.js +6 -16
  89. package/dist/canvas/shaders/effect.js.map +1 -1
  90. package/dist/clipboard/pairdraw.d.ts.map +1 -1
  91. package/dist/clipboard/pairdraw.js +1 -0
  92. package/dist/clipboard/pairdraw.js.map +1 -1
  93. package/dist/editor/bridges/clipboard.d.ts +2 -0
  94. package/dist/editor/bridges/clipboard.d.ts.map +1 -1
  95. package/dist/editor/bridges/clipboard.js +1 -0
  96. package/dist/editor/bridges/clipboard.js.map +1 -1
  97. package/dist/editor/bridges/components.d.ts +14 -7
  98. package/dist/editor/bridges/components.d.ts.map +1 -1
  99. package/dist/editor/bridges/components.js +6 -0
  100. package/dist/editor/bridges/components.js.map +1 -1
  101. package/dist/editor/bridges/structure.d.ts +1 -1
  102. package/dist/editor/bridges/structure.d.ts.map +1 -1
  103. package/dist/editor/bridges/undo.d.ts +1 -1
  104. package/dist/editor/clipboard/code.d.ts +32 -0
  105. package/dist/editor/clipboard/code.d.ts.map +1 -0
  106. package/dist/editor/clipboard/code.js +30 -0
  107. package/dist/editor/clipboard/code.js.map +1 -0
  108. package/dist/editor/clipboard/export.js +2 -2
  109. package/dist/editor/clipboard/export.js.map +1 -1
  110. package/dist/editor/clipboard/paste/dependencies.d.ts +14 -0
  111. package/dist/editor/clipboard/paste/dependencies.d.ts.map +1 -0
  112. package/dist/editor/clipboard/paste/dependencies.js +0 -0
  113. package/dist/editor/clipboard/paste/run.d.ts +14 -0
  114. package/dist/editor/clipboard/paste/run.d.ts.map +1 -0
  115. package/dist/editor/clipboard/paste/run.js +47 -0
  116. package/dist/editor/clipboard/paste/run.js.map +1 -0
  117. package/dist/editor/clipboard/styled.d.ts +2 -8
  118. package/dist/editor/clipboard/styled.d.ts.map +1 -1
  119. package/dist/editor/clipboard/styled.js +2 -32
  120. package/dist/editor/clipboard/styled.js.map +1 -1
  121. package/dist/editor/clipboard.d.ts +2 -0
  122. package/dist/editor/clipboard.d.ts.map +1 -1
  123. package/dist/editor/clipboard.js +34 -0
  124. package/dist/editor/clipboard.js.map +1 -1
  125. package/dist/editor/components/instances.d.ts +5 -0
  126. package/dist/editor/components/instances.d.ts.map +1 -1
  127. package/dist/editor/components/instances.js +69 -4
  128. package/dist/editor/components/instances.js.map +1 -1
  129. package/dist/editor/components/slots/index.d.ts.map +1 -1
  130. package/dist/editor/components/slots/index.js +7 -0
  131. package/dist/editor/components/slots/index.js.map +1 -1
  132. package/dist/editor/components.d.ts +6 -0
  133. package/dist/editor/components.d.ts.map +1 -1
  134. package/dist/editor/components.js +14 -2
  135. package/dist/editor/components.js.map +1 -1
  136. package/dist/editor/create.d.ts +30 -3
  137. package/dist/editor/create.d.ts.map +1 -1
  138. package/dist/editor/create.js +11 -2
  139. package/dist/editor/create.js.map +1 -1
  140. package/dist/editor/design-tokens.d.ts +1 -1
  141. package/dist/editor/design-tokens.d.ts.map +1 -1
  142. package/dist/editor/design-tokens.js +4 -18
  143. package/dist/editor/design-tokens.js.map +1 -1
  144. package/dist/editor/image-edit.d.ts.map +1 -1
  145. package/dist/editor/image-edit.js +1 -2
  146. package/dist/editor/image-edit.js.map +1 -1
  147. package/dist/editor/index.d.ts +4 -4
  148. package/dist/editor/index.js +1 -1
  149. package/dist/editor/layout-mode.d.ts +3 -1
  150. package/dist/editor/layout-mode.d.ts.map +1 -1
  151. package/dist/editor/layout-mode.js +97 -2
  152. package/dist/editor/layout-mode.js.map +1 -1
  153. package/dist/editor/nodes.d.ts +2 -0
  154. package/dist/editor/nodes.d.ts.map +1 -1
  155. package/dist/editor/nodes.js +22 -7
  156. package/dist/editor/nodes.js.map +1 -1
  157. package/dist/editor/read-only/actions.js +6 -0
  158. package/dist/editor/read-only/actions.js.map +1 -1
  159. package/dist/editor/selection/overlays.d.ts +1 -0
  160. package/dist/editor/selection/overlays.d.ts.map +1 -1
  161. package/dist/editor/selection/overlays.js +7 -0
  162. package/dist/editor/selection/overlays.js.map +1 -1
  163. package/dist/editor/selection/read.d.ts +8 -0
  164. package/dist/editor/selection.d.ts +9 -0
  165. package/dist/editor/selection.d.ts.map +1 -1
  166. package/dist/editor/state/shared.js +1 -0
  167. package/dist/editor/state/shared.js.map +1 -1
  168. package/dist/editor/state/view.d.ts.map +1 -1
  169. package/dist/editor/state/view.js +2 -0
  170. package/dist/editor/state/view.js.map +1 -1
  171. package/dist/editor/structure/boolean.d.ts +1 -1
  172. package/dist/editor/structure/boolean.d.ts.map +1 -1
  173. package/dist/editor/structure/boolean.js +20 -1
  174. package/dist/editor/structure/boolean.js.map +1 -1
  175. package/dist/editor/structure/container-wrap.d.ts +8 -2
  176. package/dist/editor/structure/container-wrap.d.ts.map +1 -1
  177. package/dist/editor/structure/container-wrap.js +17 -5
  178. package/dist/editor/structure/container-wrap.js.map +1 -1
  179. package/dist/editor/structure/flatten.d.ts.map +1 -1
  180. package/dist/editor/structure/flatten.js +8 -7
  181. package/dist/editor/structure/flatten.js.map +1 -1
  182. package/dist/editor/structure/group/ungroup.d.ts.map +1 -1
  183. package/dist/editor/structure/group/ungroup.js +2 -0
  184. package/dist/editor/structure/group/ungroup.js.map +1 -1
  185. package/dist/editor/structure/outline-stroke.d.ts.map +1 -1
  186. package/dist/editor/structure/outline-stroke.js +5 -0
  187. package/dist/editor/structure/outline-stroke.js.map +1 -1
  188. package/dist/editor/structure.d.ts +1 -1
  189. package/dist/editor/structure.d.ts.map +1 -1
  190. package/dist/editor/styles.d.ts +26 -0
  191. package/dist/editor/styles.d.ts.map +1 -0
  192. package/dist/editor/styles.js +127 -0
  193. package/dist/editor/styles.js.map +1 -0
  194. package/dist/editor/text/selection-style.d.ts +1 -0
  195. package/dist/editor/text/selection-style.d.ts.map +1 -1
  196. package/dist/editor/text/selection-style.js +10 -2
  197. package/dist/editor/text/selection-style.js.map +1 -1
  198. package/dist/editor/tool-registry.d.ts.map +1 -1
  199. package/dist/editor/tool-registry.js +6 -0
  200. package/dist/editor/tool-registry.js.map +1 -1
  201. package/dist/editor/types.d.ts +14 -2
  202. package/dist/editor/types.d.ts.map +1 -1
  203. package/dist/editor/variable-bindings.d.ts.map +1 -1
  204. package/dist/editor/variable-bindings.js +6 -1
  205. package/dist/editor/variable-bindings.js.map +1 -1
  206. package/dist/figma-api/accessors/basic.d.ts.map +1 -1
  207. package/dist/figma-api/accessors/basic.js +22 -1
  208. package/dist/figma-api/accessors/basic.js.map +1 -1
  209. package/dist/figma-api/accessors/shape.js +1 -1
  210. package/dist/figma-api/accessors/text/index.js +1 -1
  211. package/dist/figma-api/accessors/text/ranges.js +1 -1
  212. package/dist/figma-api/accessors/text/references.js +1 -1
  213. package/dist/figma-api/accessors/variables.js +1 -1
  214. package/dist/figma-api/accessors/vector.d.ts.map +1 -1
  215. package/dist/figma-api/accessors/vector.js +8 -22
  216. package/dist/figma-api/accessors/vector.js.map +1 -1
  217. package/dist/figma-api/accessors/visual.js +1 -1
  218. package/dist/figma-api/compatibility.d.ts +1 -1
  219. package/dist/figma-api/compatibility.d.ts.map +1 -1
  220. package/dist/figma-api/component-scope.d.ts +14 -0
  221. package/dist/figma-api/component-scope.d.ts.map +1 -0
  222. package/dist/figma-api/component-scope.js +28 -0
  223. package/dist/figma-api/component-scope.js.map +1 -0
  224. package/dist/figma-api/components.d.ts.map +1 -1
  225. package/dist/figma-api/components.js +26 -2
  226. package/dist/figma-api/components.js.map +1 -1
  227. package/dist/figma-api/flatten.js +3 -3
  228. package/dist/figma-api/flatten.js.map +1 -1
  229. package/dist/figma-api/index.d.ts +77 -6
  230. package/dist/figma-api/index.d.ts.map +1 -1
  231. package/dist/figma-api/index.js +188 -2
  232. package/dist/figma-api/index.js.map +1 -1
  233. package/dist/figma-api/node-types.d.ts +2 -1
  234. package/dist/figma-api/node-types.d.ts.map +1 -1
  235. package/dist/figma-api/overrides.d.ts +26 -1
  236. package/dist/figma-api/overrides.d.ts.map +1 -1
  237. package/dist/figma-api/overrides.js +157 -10
  238. package/dist/figma-api/overrides.js.map +1 -1
  239. package/dist/figma-api/proxy.d.ts +2 -0
  240. package/dist/figma-api/proxy.d.ts.map +1 -1
  241. package/dist/figma-api/proxy.js +10 -2
  242. package/dist/figma-api/proxy.js.map +1 -1
  243. package/dist/figma-api/reactions.d.ts +61 -5
  244. package/dist/figma-api/reactions.d.ts.map +1 -1
  245. package/dist/figma-api/reactions.js +144 -11
  246. package/dist/figma-api/reactions.js.map +1 -1
  247. package/dist/figma-api/shape-with-text.js +1 -1
  248. package/dist/figma-api/slots.d.ts +3 -1
  249. package/dist/figma-api/slots.d.ts.map +1 -1
  250. package/dist/figma-api/slots.js +9 -8
  251. package/dist/figma-api/slots.js.map +1 -1
  252. package/dist/index.d.ts +4 -4
  253. package/dist/index.js +1 -1
  254. package/dist/io/formats/code/detect.d.ts +23 -0
  255. package/dist/io/formats/code/detect.d.ts.map +1 -0
  256. package/dist/io/formats/code/detect.js +46 -0
  257. package/dist/io/formats/code/detect.js.map +1 -0
  258. package/dist/io/formats/code/index.d.ts +5 -0
  259. package/dist/io/formats/code/index.js +5 -0
  260. package/dist/io/formats/code/read.d.ts +45 -0
  261. package/dist/io/formats/code/read.d.ts.map +1 -0
  262. package/dist/io/formats/code/read.js +86 -0
  263. package/dist/io/formats/code/read.js.map +1 -0
  264. package/dist/io/formats/code/stylesheet.d.ts +13 -0
  265. package/dist/io/formats/code/stylesheet.d.ts.map +1 -0
  266. package/dist/io/formats/code/stylesheet.js +21 -0
  267. package/dist/io/formats/code/stylesheet.js.map +1 -0
  268. package/dist/io/formats/code/tokens.d.ts +18 -0
  269. package/dist/io/formats/code/tokens.d.ts.map +1 -0
  270. package/dist/io/formats/code/tokens.js +135 -0
  271. package/dist/io/formats/code/tokens.js.map +1 -0
  272. package/dist/io/formats/design-tokens/apply.d.ts +7 -3
  273. package/dist/io/formats/design-tokens/apply.d.ts.map +1 -1
  274. package/dist/io/formats/design-tokens/apply.js.map +1 -1
  275. package/dist/io/formats/drawio/warnings.d.ts +17 -2
  276. package/dist/io/formats/drawio/warnings.d.ts.map +1 -1
  277. package/dist/io/formats/drawio/warnings.js +14 -7
  278. package/dist/io/formats/drawio/warnings.js.map +1 -1
  279. package/dist/io/formats/fig/export/patch/fields.js +5 -0
  280. package/dist/io/formats/fig/export/patch/fields.js.map +1 -1
  281. package/dist/io/formats/fig/export/patch/index.d.ts.map +1 -1
  282. package/dist/io/formats/fig/export/patch/index.js +20 -20
  283. package/dist/io/formats/fig/export/patch/index.js.map +1 -1
  284. package/dist/io/formats/fig/export/setup.d.ts.map +1 -1
  285. package/dist/io/formats/fig/export/setup.js +5 -1
  286. package/dist/io/formats/fig/export/setup.js.map +1 -1
  287. package/dist/io/formats/fig/index.d.ts +3 -2
  288. package/dist/io/formats/fig/index.js +2 -2
  289. package/dist/io/formats/fig/read.d.ts.map +1 -1
  290. package/dist/io/formats/fig/read.js +5 -2
  291. package/dist/io/formats/fig/read.js.map +1 -1
  292. package/dist/io/formats/html/index.d.ts +1 -0
  293. package/dist/io/formats/html/index.d.ts.map +1 -1
  294. package/dist/io/formats/html/index.js +5 -3
  295. package/dist/io/formats/html/index.js.map +1 -1
  296. package/dist/io/formats/html/layers.d.ts +3 -1
  297. package/dist/io/formats/html/layers.d.ts.map +1 -1
  298. package/dist/io/formats/html/layers.js +6 -1
  299. package/dist/io/formats/html/layers.js.map +1 -1
  300. package/dist/io/formats/pdf/export.d.ts.map +1 -1
  301. package/dist/io/formats/pdf/export.js +7 -3
  302. package/dist/io/formats/pdf/export.js.map +1 -1
  303. package/dist/io/formats/pdf/plan.d.ts +3 -0
  304. package/dist/io/formats/pdf/plan.d.ts.map +1 -1
  305. package/dist/io/formats/pdf/plan.js +60 -36
  306. package/dist/io/formats/pdf/plan.js.map +1 -1
  307. package/dist/io/formats/pen/index.d.ts.map +1 -1
  308. package/dist/io/formats/pen/index.js +13 -4
  309. package/dist/io/formats/pen/index.js.map +1 -1
  310. package/dist/io/formats/raster/headless.d.ts.map +1 -1
  311. package/dist/io/formats/raster/headless.js +3 -2
  312. package/dist/io/formats/raster/headless.js.map +1 -1
  313. package/dist/io/formats/raster/index.d.ts +2 -2
  314. package/dist/io/formats/raster/index.js +2 -2
  315. package/dist/io/formats/raster/render.d.ts +10 -2
  316. package/dist/io/formats/raster/render.d.ts.map +1 -1
  317. package/dist/io/formats/raster/render.js +35 -9
  318. package/dist/io/formats/raster/render.js.map +1 -1
  319. package/dist/io/formats/svg/defs.d.ts.map +1 -1
  320. package/dist/io/formats/svg/defs.js +19 -1
  321. package/dist/io/formats/svg/defs.js.map +1 -1
  322. package/dist/io/formats/svg/export.d.ts +5 -2
  323. package/dist/io/formats/svg/export.d.ts.map +1 -1
  324. package/dist/io/formats/svg/export.js +59 -10
  325. package/dist/io/formats/svg/export.js.map +1 -1
  326. package/dist/io/formats/svg/index.d.ts +2 -2
  327. package/dist/io/formats/svg/index.js +2 -2
  328. package/dist/io/formats/svg/text/layout.d.ts.map +1 -1
  329. package/dist/io/formats/svg/text/layout.js +4 -2
  330. package/dist/io/formats/svg/text/layout.js.map +1 -1
  331. package/dist/io/formats/video/record.d.ts.map +1 -1
  332. package/dist/io/formats/video/record.js +24 -9
  333. package/dist/io/formats/video/record.js.map +1 -1
  334. package/dist/io/formats.d.ts.map +1 -1
  335. package/dist/io/formats.js +30 -17
  336. package/dist/io/formats.js.map +1 -1
  337. package/dist/io/index.d.ts +2 -2
  338. package/dist/io/types.d.ts +11 -2
  339. package/dist/io/types.d.ts.map +1 -1
  340. package/dist/kiwi/fig/population/client.d.ts.map +1 -1
  341. package/dist/kiwi/fig/population/client.js +2 -1
  342. package/dist/kiwi/fig/population/client.js.map +1 -1
  343. package/dist/kiwi/fig/session/document-state.d.ts +46 -2
  344. package/dist/kiwi/fig/session/document-state.d.ts.map +1 -1
  345. package/dist/kiwi/fig/session/document-state.js +113 -5
  346. package/dist/kiwi/fig/session/document-state.js.map +1 -1
  347. package/dist/kiwi/fig/session/options.d.ts +4 -0
  348. package/dist/kiwi/fig/session/options.d.ts.map +1 -1
  349. package/dist/kiwi/fig/session/options.js.map +1 -1
  350. package/dist/layout/apply.d.ts.map +1 -1
  351. package/dist/layout/apply.js +8 -4
  352. package/dist/layout/apply.js.map +1 -1
  353. package/dist/layout/auto-layout-handles.js +1 -1
  354. package/dist/layout/auto-layout-handles.js.map +1 -1
  355. package/dist/layout/axis-sizing.d.ts.map +1 -1
  356. package/dist/layout/axis-sizing.js +1 -1
  357. package/dist/layout/axis-sizing.js.map +1 -1
  358. package/dist/layout/derived.d.ts.map +1 -1
  359. package/dist/layout/derived.js +1 -1
  360. package/dist/layout/derived.js.map +1 -1
  361. package/dist/layout/effective-generated-text.js +1 -1
  362. package/dist/layout/effective-generated-text.js.map +1 -1
  363. package/dist/layout/grid.d.ts +3 -1
  364. package/dist/layout/grid.d.ts.map +1 -1
  365. package/dist/layout/grid.js +57 -16
  366. package/dist/layout/grid.js.map +1 -1
  367. package/dist/layout.d.ts +1 -1
  368. package/dist/layout.js +6 -5
  369. package/dist/layout.js.map +1 -1
  370. package/dist/node/fs.d.ts.map +1 -1
  371. package/dist/node/fs.js +28 -7
  372. package/dist/node/fs.js.map +1 -1
  373. package/dist/prototype/easing.d.ts +13 -5
  374. package/dist/prototype/easing.d.ts.map +1 -1
  375. package/dist/prototype/easing.js +46 -6
  376. package/dist/prototype/easing.js.map +1 -1
  377. package/dist/prototype/scenes.d.ts +31 -0
  378. package/dist/prototype/scenes.d.ts.map +1 -1
  379. package/dist/prototype/scenes.js +220 -31
  380. package/dist/prototype/scenes.js.map +1 -1
  381. package/dist/prototype/session.d.ts.map +1 -1
  382. package/dist/prototype/session.js +1 -0
  383. package/dist/prototype/session.js.map +1 -1
  384. package/dist/prototype/smart-animate/animation.d.ts +2 -1
  385. package/dist/prototype/smart-animate/animation.d.ts.map +1 -1
  386. package/dist/prototype/smart-animate/animation.js +2 -2
  387. package/dist/prototype/smart-animate/animation.js.map +1 -1
  388. package/dist/prototype/timeline.d.ts +10 -1
  389. package/dist/prototype/timeline.d.ts.map +1 -1
  390. package/dist/prototype/timeline.js +69 -23
  391. package/dist/prototype/timeline.js.map +1 -1
  392. package/dist/prototype/variables.d.ts +23 -0
  393. package/dist/prototype/variables.d.ts.map +1 -0
  394. package/dist/prototype/variables.js +237 -0
  395. package/dist/prototype/variables.js.map +1 -0
  396. package/dist/rpc/read-commands.d.ts +5 -0
  397. package/dist/rpc/read-commands.d.ts.map +1 -1
  398. package/dist/rpc/read-commands.js +4 -1
  399. package/dist/rpc/read-commands.js.map +1 -1
  400. package/dist/text/character-style.d.ts +8 -1
  401. package/dist/text/character-style.d.ts.map +1 -1
  402. package/dist/text/character-style.js +39 -1
  403. package/dist/text/character-style.js.map +1 -1
  404. package/dist/text/index.d.ts +2 -2
  405. package/dist/text/index.js +2 -2
  406. package/dist/tools/create/basic.js +3 -4
  407. package/dist/tools/create/basic.js.map +1 -1
  408. package/dist/tools/create/behaviours.js +1 -1
  409. package/dist/tools/create/code.d.ts +6 -0
  410. package/dist/tools/create/code.d.ts.map +1 -0
  411. package/dist/tools/create/code.js +68 -0
  412. package/dist/tools/create/code.js.map +1 -0
  413. package/dist/tools/create/html.d.ts.map +1 -1
  414. package/dist/tools/create/html.js +9 -57
  415. package/dist/tools/create/html.js.map +1 -1
  416. package/dist/tools/create/icons.js +1 -1
  417. package/dist/tools/create/inputs.d.ts +11 -0
  418. package/dist/tools/create/inputs.d.ts.map +1 -0
  419. package/dist/tools/create/inputs.js +15 -0
  420. package/dist/tools/create/inputs.js.map +1 -0
  421. package/dist/tools/create/mermaid.d.ts.map +1 -1
  422. package/dist/tools/create/mermaid.js +5 -6
  423. package/dist/tools/create/mermaid.js.map +1 -1
  424. package/dist/tools/create/place.d.ts +30 -0
  425. package/dist/tools/create/place.d.ts.map +1 -0
  426. package/dist/tools/create/place.js +70 -0
  427. package/dist/tools/create/place.js.map +1 -0
  428. package/dist/tools/create/render.js +1 -1
  429. package/dist/tools/create/svg.js +1 -1
  430. package/dist/tools/create/vector.js +1 -1
  431. package/dist/tools/create.d.ts +2 -1
  432. package/dist/tools/create.js +2 -1
  433. package/dist/tools/css/gradient.d.ts +28 -0
  434. package/dist/tools/css/gradient.d.ts.map +1 -0
  435. package/dist/tools/css/gradient.js +118 -0
  436. package/dist/tools/css/gradient.js.map +1 -0
  437. package/dist/tools/image-ai/generate.js +1 -1
  438. package/dist/tools/modify/geometry.js +5 -5
  439. package/dist/tools/modify/geometry.js.map +1 -1
  440. package/dist/tools/modify/layout.d.ts.map +1 -1
  441. package/dist/tools/modify/layout.js +7 -1
  442. package/dist/tools/modify/layout.js.map +1 -1
  443. package/dist/tools/modify/matching.js +1 -1
  444. package/dist/tools/modify/overrides.d.ts +6 -0
  445. package/dist/tools/modify/overrides.d.ts.map +1 -0
  446. package/dist/tools/modify/overrides.js +27 -0
  447. package/dist/tools/modify/overrides.js.map +1 -0
  448. package/dist/tools/modify/paint.d.ts.map +1 -1
  449. package/dist/tools/modify/paint.js +84 -39
  450. package/dist/tools/modify/paint.js.map +1 -1
  451. package/dist/tools/modify/text.d.ts +2 -1
  452. package/dist/tools/modify/text.d.ts.map +1 -1
  453. package/dist/tools/modify/text.js +79 -8
  454. package/dist/tools/modify/text.js.map +1 -1
  455. package/dist/tools/modify/update.d.ts.map +1 -1
  456. package/dist/tools/modify/update.js +18 -2
  457. package/dist/tools/modify/update.js.map +1 -1
  458. package/dist/tools/modify.d.ts +3 -2
  459. package/dist/tools/modify.js +3 -2
  460. package/dist/tools/read/css.d.ts.map +1 -1
  461. package/dist/tools/read/css.js +29 -12
  462. package/dist/tools/read/css.js.map +1 -1
  463. package/dist/tools/read/libraries.js +1 -1
  464. package/dist/tools/read/nodes.d.ts.map +1 -1
  465. package/dist/tools/read/nodes.js +19 -5
  466. package/dist/tools/read/nodes.js.map +1 -1
  467. package/dist/tools/registry/extended.d.ts.map +1 -1
  468. package/dist/tools/registry/extended.js +6 -1
  469. package/dist/tools/registry/extended.js.map +1 -1
  470. package/dist/tools/text-range.d.ts +11 -0
  471. package/dist/tools/text-range.d.ts.map +1 -0
  472. package/dist/tools/text-range.js +26 -0
  473. package/dist/tools/text-range.js.map +1 -0
  474. package/dist/tools/variables/bindings.js +1 -1
  475. package/dist/tools/variables/bindings.js.map +1 -1
  476. package/dist/tools/variables/unbind.js +1 -1
  477. package/dist/tools/variables/unbind.js.map +1 -1
  478. package/dist/tools/vector/path.d.ts.map +1 -1
  479. package/dist/tools/vector/path.js +7 -21
  480. package/dist/tools/vector/path.js.map +1 -1
  481. package/dist/vector/rebase.d.ts +17 -0
  482. package/dist/vector/rebase.d.ts.map +1 -0
  483. package/dist/vector/rebase.js +32 -0
  484. package/dist/vector/rebase.js.map +1 -0
  485. package/package.json +14 -9
  486. package/src/canvas/boolean.ts +12 -1
  487. package/src/canvas/color-space.ts +73 -0
  488. package/src/canvas/fills.ts +130 -83
  489. package/src/canvas/flatten.ts +92 -7
  490. package/src/canvas/index.ts +9 -0
  491. package/src/canvas/layout-grids.ts +15 -2
  492. package/src/canvas/noise/render.ts +35 -7
  493. package/src/canvas/noise/shader.ts +8 -10
  494. package/src/canvas/overlays/annotations.ts +117 -0
  495. package/src/canvas/overlays/auto-layout-hover.ts +41 -1
  496. package/src/canvas/overlays/feedback.ts +7 -2
  497. package/src/canvas/overlays/index.ts +1 -1
  498. package/src/canvas/overlays/measurement.ts +49 -3
  499. package/src/canvas/overlays/presence.ts +35 -32
  500. package/src/canvas/renderer/colors.ts +14 -0
  501. package/src/canvas/renderer/document-surface.ts +16 -6
  502. package/src/canvas/renderer/lifecycle.ts +2 -2
  503. package/src/canvas/renderer/methods.ts +4 -0
  504. package/src/canvas/renderer/overlay-pass.ts +4 -0
  505. package/src/canvas/renderer/pipeline.ts +8 -0
  506. package/src/canvas/renderer/types.ts +8 -0
  507. package/src/canvas/renderer.ts +21 -2
  508. package/src/canvas/scene.ts +15 -7
  509. package/src/canvas/shaders/compile.ts +14 -3
  510. package/src/canvas/shaders/draw.ts +11 -4
  511. package/src/canvas/shaders/effect.ts +6 -18
  512. package/src/clipboard/pairdraw.ts +1 -0
  513. package/src/editor/bridges/clipboard.ts +1 -0
  514. package/src/editor/bridges/components.ts +10 -0
  515. package/src/editor/clipboard/code.ts +50 -0
  516. package/src/editor/clipboard/export.ts +2 -2
  517. package/src/editor/clipboard/paste/dependencies.ts +18 -0
  518. package/src/editor/clipboard/paste/run.ts +64 -0
  519. package/src/editor/clipboard/styled.ts +4 -52
  520. package/src/editor/clipboard.ts +40 -0
  521. package/src/editor/components/instances.ts +92 -4
  522. package/src/editor/components/slots/index.ts +7 -0
  523. package/src/editor/components.ts +16 -2
  524. package/src/editor/create.ts +15 -1
  525. package/src/editor/design-tokens.ts +3 -23
  526. package/src/editor/image-edit.ts +5 -2
  527. package/src/editor/index.ts +1 -0
  528. package/src/editor/layout-mode.ts +131 -3
  529. package/src/editor/nodes.ts +30 -5
  530. package/src/editor/read-only/actions.ts +6 -0
  531. package/src/editor/selection/overlays.ts +8 -0
  532. package/src/editor/state/shared.ts +1 -0
  533. package/src/editor/state/view.ts +2 -0
  534. package/src/editor/structure/boolean.ts +29 -1
  535. package/src/editor/structure/container-wrap.ts +20 -4
  536. package/src/editor/structure/flatten.ts +15 -8
  537. package/src/editor/structure/group/ungroup.ts +2 -0
  538. package/src/editor/structure/outline-stroke.ts +5 -0
  539. package/src/editor/styles.ts +203 -0
  540. package/src/editor/text/selection-style.ts +18 -1
  541. package/src/editor/tool-registry.ts +2 -0
  542. package/src/editor/types.ts +14 -0
  543. package/src/editor/variable-bindings.ts +11 -0
  544. package/src/figma-api/accessors/basic.ts +33 -1
  545. package/src/figma-api/accessors/vector.ts +6 -13
  546. package/src/figma-api/compatibility.ts +1 -0
  547. package/src/figma-api/component-scope.ts +36 -0
  548. package/src/figma-api/components.ts +24 -0
  549. package/src/figma-api/flatten.ts +7 -3
  550. package/src/figma-api/index.ts +302 -6
  551. package/src/figma-api/node-types.ts +1 -0
  552. package/src/figma-api/overrides.ts +192 -5
  553. package/src/figma-api/proxy.ts +16 -1
  554. package/src/figma-api/reactions.ts +163 -12
  555. package/src/figma-api/slots.ts +10 -9
  556. package/src/io/formats/code/detect.ts +67 -0
  557. package/src/io/formats/code/index.ts +17 -0
  558. package/src/io/formats/code/read.ts +143 -0
  559. package/src/io/formats/code/stylesheet.ts +24 -0
  560. package/src/io/formats/code/tokens.ts +159 -0
  561. package/src/io/formats/design-tokens/apply.ts +3 -2
  562. package/src/io/formats/drawio/warnings.ts +27 -8
  563. package/src/io/formats/fig/export/patch/fields.ts +11 -0
  564. package/src/io/formats/fig/export/patch/index.ts +23 -19
  565. package/src/io/formats/fig/export/setup.ts +8 -1
  566. package/src/io/formats/fig/index.ts +6 -0
  567. package/src/io/formats/fig/read.ts +11 -2
  568. package/src/io/formats/html/index.ts +9 -3
  569. package/src/io/formats/html/layers.ts +7 -0
  570. package/src/io/formats/pdf/export.ts +19 -7
  571. package/src/io/formats/pdf/plan.ts +71 -32
  572. package/src/io/formats/pen/index.ts +14 -6
  573. package/src/io/formats/raster/headless.ts +3 -1
  574. package/src/io/formats/raster/index.ts +2 -0
  575. package/src/io/formats/raster/render.ts +49 -9
  576. package/src/io/formats/svg/defs.ts +27 -1
  577. package/src/io/formats/svg/export.ts +75 -13
  578. package/src/io/formats/svg/index.ts +1 -0
  579. package/src/io/formats/svg/text/layout.ts +5 -3
  580. package/src/io/formats/video/record.ts +33 -9
  581. package/src/io/formats.ts +45 -19
  582. package/src/io/index.ts +1 -0
  583. package/src/io/types.ts +10 -0
  584. package/src/kiwi/fig/population/client.ts +6 -1
  585. package/src/kiwi/fig/session/document-state.ts +195 -5
  586. package/src/kiwi/fig/session/options.ts +2 -0
  587. package/src/layout/apply.ts +12 -4
  588. package/src/layout/auto-layout-handles.ts +1 -1
  589. package/src/layout/axis-sizing.ts +3 -1
  590. package/src/layout/derived.ts +3 -1
  591. package/src/layout/effective-generated-text.ts +1 -1
  592. package/src/layout/grid.ts +91 -21
  593. package/src/layout.ts +16 -3
  594. package/src/node/fs.ts +32 -7
  595. package/src/prototype/easing.ts +79 -7
  596. package/src/prototype/scenes.ts +244 -15
  597. package/src/prototype/session.ts +1 -0
  598. package/src/prototype/smart-animate/animation.ts +4 -3
  599. package/src/prototype/timeline.ts +118 -26
  600. package/src/prototype/variables.ts +189 -0
  601. package/src/rpc/read-commands.ts +19 -1
  602. package/src/text/character-style.ts +47 -0
  603. package/src/text/index.ts +1 -1
  604. package/src/tools/create/basic.ts +2 -3
  605. package/src/tools/create/code.ts +85 -0
  606. package/src/tools/create/html.ts +9 -46
  607. package/src/tools/create/inputs.ts +12 -0
  608. package/src/tools/create/mermaid.ts +6 -6
  609. package/src/tools/create/place.ts +80 -0
  610. package/src/tools/create.ts +1 -0
  611. package/src/tools/css/gradient.ts +147 -0
  612. package/src/tools/modify/geometry.ts +5 -5
  613. package/src/tools/modify/layout.ts +19 -0
  614. package/src/tools/modify/overrides.ts +35 -0
  615. package/src/tools/modify/paint.ts +124 -54
  616. package/src/tools/modify/text.ts +91 -7
  617. package/src/tools/modify/update.ts +23 -2
  618. package/src/tools/modify.ts +9 -1
  619. package/src/tools/read/css.ts +46 -12
  620. package/src/tools/read/nodes.ts +26 -4
  621. package/src/tools/registry/extended.ts +6 -0
  622. package/src/tools/text-range.ts +29 -0
  623. package/src/tools/variables/bindings.ts +4 -1
  624. package/src/tools/variables/unbind.ts +4 -1
  625. package/src/tools/vector/path.ts +11 -13
  626. package/src/vector/rebase.ts +33 -0
@@ -1 +1 @@
1
- {"version":3,"file":"export.js","names":[],"sources":["../../../../src/io/formats/svg/export.ts"],"sourcesContent":["import type {\n ColorProfile,\n Fill,\n SceneGraph,\n SceneNode,\n Stroke,\n VectorNetwork\n} from '@pairdraw/scene-graph'\nimport type { RenderColorSpace } from '@pairdraw/scene-graph/color'\n\nimport { normalizeDashPattern } from '#core/canvas/strokes'\nimport { lineStrokePath } from '#core/canvas/strokes/line'\nimport { fittedDashPattern } from '#core/canvas/strokes/sides'\nimport { computeContentBounds } from '#core/io/formats/raster'\n\nimport {\n nextDefId,\n formatSolidColor,\n resolveFill,\n solidFillOpacity,\n SVG_STROKE_CAP,\n SVG_STROKE_JOIN,\n SVG_BLEND_MODE\n} from './defs'\nimport { createFilterDef } from './effects'\nimport {\n round,\n geometryBlobToSVGPath,\n makePolygonPoints,\n roundedPolygonPath,\n hasRadius,\n hasSmoothCorners,\n boxOutlinePath,\n arcPath,\n shapeWithTextOutlinePath\n} from './paths'\n\nexport { geometryBlobToSVGPath, nodeOutlinePath, type OutlineNode } from './paths'\n\nimport { looseSegments, regionSVGPaths } from '@pairdraw/scene-graph/vector-network'\n\nimport type { BooleanPathResolver } from '#core/io/formats/boolean-path'\n\nimport { arrowHeadElements, openPathElements, vectorArrowHeads } from './arrows'\nimport type { SVGExportContext, SVGFontAlias } from './defs'\nimport { svg, renderSVGNode } from './node'\nimport type { SVGNode } from './node'\nimport { alignedStroke, alignedStrokeElement, shapeWithTextDetailElements } from './strokes'\nimport { renderTextNode } from './text/export'\nimport type { SVGTextLayout } from './text/lines'\n\n// --- Node rendering ---\n\n/**\n * A vector network's paths: its regions as they are traced, and its open segments as the canvas\n * strokes them, rounded and pulled back under their heads.\n */\nfunction networkElements(\n node: SceneNode,\n network: VectorNetwork,\n common: Record<string, string | number | undefined>\n): SVGNode[] {\n const regions = regionSVGPaths(network).map((d) => svg('path', { d, ...common }))\n if (looseSegments(network).length === 0) return regions\n return [...regions, ...openPathElements(node, network, common, looseSegments)]\n}\n\n/** Paints one path's fill stack; a blended fill draws its stroke as a separate path. */\nfunction vectorFillElements(\n attrs: Record<string, string | number | undefined>,\n visibleFills: Fill[],\n strokeAttrs: Record<string, string | number | undefined>,\n common: Record<string, string | number | undefined>,\n node: SceneNode,\n ctx: SVGExportContext\n): SVGNode[] {\n const elements: SVGNode[] = []\n for (const [index, fill] of visibleFills.entries()) {\n const fillAttr = resolveFill(fill, node, ctx)\n if (!fillAttr) continue\n const style = paintBlendStyle(fill)\n const last = index === visibleFills.length - 1\n const splitStroke = style !== undefined && last && common.stroke !== 'none'\n const stroke = last && !splitStroke ? common.stroke : 'none'\n elements.push(\n svg('path', {\n ...attrs,\n fill: fillAttr,\n 'fill-opacity': solidFillOpacity(fill, ctx.colorSpace),\n style,\n stroke\n })\n )\n if (splitStroke) {\n elements.push(\n svg('path', {\n d: attrs.d,\n 'fill-rule': attrs['fill-rule'],\n fill: 'none',\n ...strokeAttrs\n })\n )\n }\n }\n return elements\n}\n\nfunction vectorShapeElements(\n node: SceneNode,\n common: Record<string, string | number | undefined>,\n strokeAttrs: Record<string, string | number | undefined>,\n ctx: SVGExportContext,\n fallbackFills?: Fill[]\n): SVGNode[] {\n const elements: SVGNode[] = []\n if (node.fillGeometry.length > 0) {\n for (const geo of node.fillGeometry) {\n const d = geometryBlobToSVGPath(geo.commandsBlob)\n if (!d) continue\n const attrs = {\n d,\n 'fill-rule': geo.windingRule === 'EVENODD' ? 'evenodd' : undefined,\n ...common\n }\n const pathFills = geo.fills?.length ? geo.fills : fallbackFills\n if (!pathFills) {\n elements.push(svg('path', attrs))\n continue\n }\n const visibleFills = pathFills.filter((fill) => fill.visible)\n if (visibleFills.length === 0) {\n elements.push(svg('path', { ...attrs, fill: 'none' }))\n continue\n }\n elements.push(...vectorFillElements(attrs, visibleFills, strokeAttrs, common, node, ctx))\n }\n } else if (node.vectorNetwork) {\n elements.push(...networkElements(node, node.vectorNetwork, common))\n }\n elements.push(...vectorStrokeTail(node, strokeAttrs))\n return withVectorFallback(elements, node, common)\n}\n\n/** The empty vector's fallback shape, after both paints have contributed their elements. */\nfunction withVectorFallback(\n elements: SVGNode[],\n node: SceneNode,\n common: Record<string, string | number | undefined>\n): SVGNode[] {\n return elements.length > 0\n ? elements\n : [svg('rect', { width: round(node.width), height: round(node.height), ...common })]\n}\n\n/** The stored stroke geometry and arrowheads both vector paints share after their outlines. */\nfunction vectorStrokeTail(\n node: SceneNode,\n strokeAttrs: Record<string, string | number | undefined>\n): SVGNode[] {\n const elements: SVGNode[] = []\n if (node.strokeGeometry.length > 0 && strokeAttrs.stroke && strokeAttrs.stroke !== 'none') {\n for (const geo of node.strokeGeometry) {\n const d = geometryBlobToSVGPath(geo.commandsBlob)\n if (d) {\n elements.push(\n svg('path', {\n d,\n fill: strokeAttrs.stroke,\n 'fill-opacity': strokeAttrs['stroke-opacity'],\n stroke: 'none'\n })\n )\n }\n }\n }\n if (node.vectorNetwork) elements.push(...vectorArrowHeads(node, node.vectorNetwork, strokeAttrs))\n return elements\n}\n\n/** A vector layer's outlines as strokes alone, for a second stroke over the painted fills. */\nfunction vectorStrokeElements(\n node: SceneNode,\n strokeAttrs: Record<string, string | number | undefined>\n): SVGNode[] {\n const elements: SVGNode[] = []\n const common: Record<string, string | number | undefined> = { fill: 'none', ...strokeAttrs }\n if (node.fillGeometry.length > 0) {\n for (const geo of node.fillGeometry) {\n const d = geometryBlobToSVGPath(geo.commandsBlob)\n if (d) {\n elements.push(\n svg('path', {\n d,\n 'fill-rule': geo.windingRule === 'EVENODD' ? 'evenodd' : undefined,\n ...common\n })\n )\n }\n }\n } else if (node.vectorNetwork) {\n elements.push(...networkElements(node, node.vectorNetwork, common))\n }\n elements.push(...vectorStrokeTail(node, strokeAttrs))\n return withVectorFallback(elements, node, common)\n}\n\n/** A line's dashes stretched along it as the canvas lays them, half a dash at each end. */\nfunction lineDashAttrs(stroke: Stroke | undefined, length: number) {\n const fitted = fittedDashPattern(length, normalizeDashPattern(stroke?.dashPattern))\n if (!fitted) return {}\n return {\n 'stroke-dasharray': fitted.intervals.map((size) => round(size)).join(' '),\n 'stroke-dashoffset': round(fitted.offset)\n }\n}\n\nfunction nodeShapeElements(\n node: SceneNode,\n fillAttr: string | null,\n fillOpacity: number | undefined,\n strokeAttrs: Record<string, string | number | undefined>,\n ctx: SVGExportContext,\n stroke?: Stroke\n): SVGNode[] {\n const common: Record<string, string | number | undefined> = {\n fill: fillAttr ?? 'none',\n 'fill-opacity': fillOpacity,\n ...strokeAttrs\n }\n\n switch (node.type) {\n case 'ELLIPSE': {\n if (node.arcData) {\n return [svg('path', { d: arcPath(node), ...common })]\n }\n return [\n svg('ellipse', {\n cx: round(node.width / 2),\n cy: round(node.height / 2),\n rx: round(node.width / 2),\n ry: round(node.height / 2),\n ...common\n })\n ]\n }\n\n case 'LINE': {\n // Where the canvas strokes it: to one side of the line, with its caps inside its length.\n const lineStroke = stroke ?? node.strokes.find((item) => item.visible)\n const {\n network,\n from: start,\n to: end\n } = lineStrokePath(node, lineStroke?.weight ?? 0, lineStroke?.cap ?? node.strokeCap)\n return [\n svg('line', {\n x1: round(start.x),\n y1: round(start.y),\n x2: round(end.x),\n y2: round(end.y),\n fill: 'none',\n ...strokeAttrs,\n ...lineDashAttrs(lineStroke, Math.hypot(end.x - start.x, end.y - start.y))\n }),\n ...arrowHeadElements(node, network, lineStroke, strokeAttrs)\n ]\n }\n\n case 'STAR':\n case 'POLYGON':\n return node.cornerRadius > 0\n ? [svg('path', { d: roundedPolygonPath(node), ...common })]\n : [svg('polygon', { points: makePolygonPoints(node), ...common })]\n\n case 'VECTOR':\n return vectorShapeElements(node, common, strokeAttrs, ctx)\n\n case 'SHAPE_WITH_TEXT':\n return shapeWithTextElements(node, common, strokeAttrs, ctx)\n\n default:\n return [boxOutlineElement(node, common)]\n }\n}\n\n/**\n * A box layer's outline as one element: a rect, a rect with `rx`/`ry` for one radius, or the\n * shared box path for independent or smoothed corners, so fills and clips follow the same edge.\n */\nfunction boxOutlineElement(\n node: SceneNode,\n attrs: Record<string, string | number | undefined>\n): SVGNode {\n const width = round(node.width)\n const height = round(node.height)\n if (!hasRadius(node)) return svg('rect', { width, height, ...attrs })\n if (node.independentCorners || hasSmoothCorners(node)) {\n return svg('path', { d: boxOutlinePath(node), ...attrs })\n }\n // SVG clamps rx and ry to their own sides; the canvas keeps a too-large radius circular.\n const radius = round(Math.min(node.cornerRadius, node.width / 2, node.height / 2))\n return svg('rect', { width, height, rx: radius, ry: radius, ...attrs })\n}\n\n/**\n * A FigJam shape's outline, and its inner lines, such as a database's front rim, stroked as the\n * canvas strokes them: at the stroke's own weight, ending where the outline does.\n */\nfunction shapeWithTextElements(\n node: SceneNode,\n common: Record<string, string | number | undefined>,\n strokeAttrs: Record<string, string | number | undefined>,\n ctx: SVGExportContext\n): SVGNode[] {\n return [\n svg('path', { d: shapeWithTextOutlinePath(node), ...common }),\n ...shapeWithTextDetailElements(node, strokeAttrs, ctx)\n ]\n}\n\n// --- Main recursive renderer ---\n\nfunction buildTransformAttr(node: SceneNode): string | undefined {\n const transforms: string[] = []\n if (node.x !== 0 || node.y !== 0) transforms.push(`translate(${round(node.x)}, ${round(node.y)})`)\n if (node.rotation !== 0) {\n transforms.push(\n `rotate(${round(node.rotation)}, ${round(node.width / 2)}, ${round(node.height / 2)})`\n )\n }\n if (node.flipX || node.flipY) {\n const tx = node.flipX ? node.width : 0\n const ty = node.flipY ? node.height : 0\n const sx = node.flipX ? -1 : 1\n const sy = node.flipY ? -1 : 1\n transforms.push(`translate(${round(tx)}, ${round(ty)}) scale(${sx}, ${sy})`)\n }\n return transforms.length > 0 ? transforms.join(' ') : undefined\n}\n\nfunction buildGroupAttrs(\n node: SceneNode,\n ctx: SVGExportContext\n): { attrs: Record<string, string | number | undefined>; clipId?: string } {\n const attrs: Record<string, string | number | undefined> = {}\n\n const transform = buildTransformAttr(node)\n if (transform) attrs.transform = transform\n\n if (node.opacity < 1) attrs.opacity = round(node.opacity)\n\n const blend = SVG_BLEND_MODE[node.blendMode]\n if (blend && blend !== 'normal' && node.blendMode !== 'PASS_THROUGH') {\n attrs.style = `mix-blend-mode: ${blend}`\n }\n\n const filterDef = createFilterDef(node, ctx)\n if (filterDef) {\n ctx.defs.push(filterDef.node)\n attrs.filter = `url(#${filterDef.id})`\n }\n\n let clipId: string | undefined\n if (node.clipsContent && node.childIds.length > 0) {\n clipId = nextDefId(ctx, 'clip')\n ctx.defs.push(svg('clipPath', { id: clipId }, boxOutlineElement(node, {})))\n }\n\n return { attrs, clipId }\n}\n\nfunction buildSVGStrokeAttrs(\n stroke: Stroke,\n node: SceneNode,\n ctx: SVGExportContext\n): Record<string, string | number | undefined> {\n const cap = stroke.cap ?? node.strokeCap\n const attrs: Record<string, string | number | undefined> = {\n // Opacity 1 keeps the color opaque. Display P3 must not also keep color alpha here, or a\n // viewer multiplies it by stroke-opacity; the canvas paints stroke.opacity alone.\n stroke:\n stroke.type === 'SOLID'\n ? formatSolidColor(stroke.color, 1, ctx.colorSpace, ctx.documentColorSpace)\n : (resolveFill(stroke, node, ctx) ??\n formatSolidColor(stroke.color, 1, ctx.colorSpace, ctx.documentColorSpace)),\n 'stroke-width': round(stroke.weight)\n }\n if (stroke.opacity < 1) attrs['stroke-opacity'] = round(stroke.opacity)\n if (cap !== 'NONE') attrs['stroke-linecap'] = SVG_STROKE_CAP[cap] ?? 'butt'\n if (stroke.join && stroke.join !== 'MITER') {\n attrs['stroke-linejoin'] = SVG_STROKE_JOIN[stroke.join] ?? 'miter'\n }\n if (stroke.dashPattern && stroke.dashPattern.length > 0) {\n attrs['stroke-dasharray'] = stroke.dashPattern.map((n) => round(n)).join(' ')\n }\n return attrs\n}\n\n/** The blend CSS a paint adds, when the canvas would not composite it source-over. */\nfunction paintBlendStyle(fill: Fill | undefined): string | undefined {\n const blend = fill?.blendMode ? SVG_BLEND_MODE[fill.blendMode] : undefined\n return blend && blend !== 'normal' ? `mix-blend-mode: ${blend}` : undefined\n}\n\n/** Adds a paint's blend mode to the elements that draw it. */\nfunction withPaintBlend(elements: SVGNode[], fill: Fill | undefined): SVGNode[] {\n const style = paintBlendStyle(fill)\n if (style) for (const element of elements) element.attrs.style = style\n return elements\n}\n\n/**\n * Draws the fill and the stroke as separate elements when the fill blends, so the stroke keeps the\n * source-over canvas gives it instead of inheriting the fill's blend mode.\n */\nfunction shapeWithPaint(\n node: SceneNode,\n fillAttr: string | null,\n fillOpacity: number | undefined,\n strokeAttrs: Record<string, string | number | undefined>,\n fill: Fill | undefined,\n ctx: SVGExportContext\n): SVGNode[] {\n const blends = paintBlendStyle(fill) !== undefined\n if (!blends || !strokeAttrs.stroke) {\n return withPaintBlend(nodeShapeElements(node, fillAttr, fillOpacity, strokeAttrs, ctx), fill)\n }\n return [\n ...withPaintBlend(nodeShapeElements(node, fillAttr, fillOpacity, {}, ctx), fill),\n ...nodeShapeElements(node, null, undefined, strokeAttrs, ctx)\n ]\n}\n\nfunction hasPathLevelFills(node: SceneNode): boolean {\n return node.type === 'VECTOR' && node.fillGeometry.some((geometry) => geometry.fills?.length)\n}\n\n/** One stroke at its own weight over the fills: a centred one on the outline, an aligned one around it. */\nfunction strokeElements(\n node: SceneNode,\n stroke: Stroke,\n strokeAttrs: Record<string, string | number | undefined>,\n ctx: SVGExportContext\n): SVGNode[] {\n const aligned = hasPathLevelFills(node) ? null : alignedStroke(node, stroke)\n if (aligned) {\n return [\n ...alignedStrokeElement(node, aligned, strokeAttrs, ctx),\n ...(node.type === 'SHAPE_WITH_TEXT'\n ? shapeWithTextDetailElements(node, strokeAttrs, ctx)\n : [])\n ]\n }\n if (node.type === 'VECTOR') return vectorStrokeElements(node, strokeAttrs)\n return nodeShapeElements(node, null, undefined, strokeAttrs, ctx, stroke)\n}\n\n/**\n * The fills and the strokes over them. The first stroke joins the fill's own element as before;\n * every later visible stroke is drawn in layer order, without painting the fill again.\n */\nfunction buildShapeChildren(\n node: SceneNode,\n visibleFills: Fill[],\n fillAttr: string | null,\n fillOpacity: number | undefined,\n strokeAttrs: Record<string, string | number | undefined>[],\n visibleStrokes: Stroke[],\n ctx: SVGExportContext\n): SVGNode[] {\n if (visibleStrokes.length === 0) {\n return fillAndStrokeElements(node, visibleFills, fillAttr, fillOpacity, {}, 0, ctx)\n }\n const first = visibleStrokes[0]\n const firstAttrs = strokeAttrs[0]\n const elements = alignedStroke(node, first)\n ? // The fill goes as it is, and the stroke over it inside or outside the outline.\n [\n ...fillAndStrokeElements(node, visibleFills, fillAttr, fillOpacity, {}, 0, ctx),\n ...strokeElements(node, first, firstAttrs, ctx)\n ]\n : fillAndStrokeElements(\n node,\n visibleFills,\n fillAttr,\n fillOpacity,\n firstAttrs,\n visibleStrokes.length,\n ctx\n )\n for (let index = 1; index < visibleStrokes.length; index++) {\n elements.push(...strokeElements(node, visibleStrokes[index], strokeAttrs[index], ctx))\n }\n return elements\n}\n\nfunction fillAndStrokeElements(\n node: SceneNode,\n visibleFills: Fill[],\n fillAttr: string | null,\n fillOpacity: number | undefined,\n strokeAttrs: Record<string, string | number | undefined>,\n visibleStrokeCount: number,\n ctx: SVGExportContext\n): SVGNode[] {\n if (hasPathLevelFills(node)) {\n return vectorShapeElements(\n node,\n { fill: fillAttr ?? 'none', 'fill-opacity': fillOpacity, ...strokeAttrs },\n strokeAttrs,\n ctx,\n visibleFills\n )\n }\n\n if (visibleFills.length > 1) {\n const elements: SVGNode[] = []\n for (const fill of visibleFills) {\n const ref = resolveFill(fill, node, ctx)\n if (ref) {\n elements.push(\n ...shapeWithPaint(\n node,\n ref,\n solidFillOpacity(fill, ctx.colorSpace),\n fill === visibleFills[visibleFills.length - 1] ? strokeAttrs : {},\n fill,\n ctx\n )\n )\n }\n }\n return elements\n }\n\n const hasFillOrStroke = fillAttr || visibleStrokeCount > 0\n if (hasFillOrStroke && !isGroupLike(node)) {\n return shapeWithPaint(\n node,\n fillAttr,\n fillOpacity,\n strokeAttrs,\n visibleFills.length === 1 ? visibleFills[0] : undefined,\n ctx\n )\n }\n\n return []\n}\n\n/** The paint CSS `color` sets, for a tinted icon path. */\nconst CURRENT_COLOR = 'currentColor'\n\n/** A paint's SVG color and, for an sRGB solid, the `fill-opacity` beside it. */\nfunction exportedFill(\n fill: Fill | undefined,\n node: SceneNode,\n ctx: SVGExportContext\n): { color: string | null; opacity: number | undefined } {\n if (!fill) return { color: null, opacity: undefined }\n return {\n color: resolveFill(fill, node, ctx),\n opacity: solidFillOpacity(fill, ctx.colorSpace)\n }\n}\n\n/**\n * A mask layer's definition: an alpha or luminance `<mask>`, or a `<clipPath>` for an outline\n * mask. The rendered layer carries its own position, opacity, and filters into the mask.\n */\nfunction maskWire(\n mask: SceneNode,\n ctx: SVGExportContext\n): { attribute: 'mask' | 'clip-path'; id: string } {\n const content = renderNode(mask, ctx)\n if (mask.maskType === 'VECTOR') {\n const id = nextDefId(ctx, 'clip')\n ctx.defs.push(svg('clipPath', { id, clipPathUnits: 'userSpaceOnUse' }, content ?? undefined))\n return { attribute: 'clip-path', id }\n }\n const id = nextDefId(ctx, 'mask')\n const attrs: Record<string, string | number | undefined> = {\n id,\n maskContentUnits: 'userSpaceOnUse'\n }\n if (mask.maskType === 'ALPHA') attrs['mask-type'] = 'alpha'\n ctx.defs.push(svg('mask', attrs, content ?? undefined))\n return { attribute: 'mask', id }\n}\n\n/**\n * The children as the canvas draws them: a run of visible masks masks the siblings that follow\n * it, until the next mask, and the mask layers themselves never draw on their own.\n */\nfunction maskedChildNodes(childNodes: SceneNode[], ctx: SVGExportContext): SVGNode[] {\n const content: SVGNode[] = []\n let masks: Array<{ attribute: 'mask' | 'clip-path'; id: string }> = []\n let afterMask = false\n for (const child of childNodes) {\n if (child.visible && child.isMask) {\n const wire = maskWire(child, ctx)\n masks = afterMask ? [...masks, wire] : [wire]\n afterMask = true\n continue\n }\n const rendered = renderNode(child, ctx)\n afterMask = false\n if (!rendered) continue\n let wrapped = rendered\n for (const wire of masks) wrapped = svg('g', { [wire.attribute]: `url(#${wire.id})` }, wrapped)\n content.push(wrapped)\n }\n return content\n}\n\n/** A boolean's live result path in the paints its fills and strokes give it. */\nfunction booleanPathElements(\n node: SceneNode,\n d: string,\n visibleFills: Fill[],\n fillAttr: string | null,\n fillOpacity: number | undefined,\n strokeAttrs: Array<Record<string, string | number | undefined>>,\n visibleStrokes: Stroke[],\n ctx: SVGExportContext\n): SVGNode[] {\n const common = { d, 'fill-rule': 'evenodd' as const }\n // A centred first stroke joins the fill element, as a shape's does; every later stroke, and\n // every inside or outside stroke, is drawn over the result outline on its own. An unset\n // alignment strokes the centred way, as `alignedStroke` treats it.\n const centered = (stroke: Stroke): boolean =>\n stroke.align !== 'INSIDE' && stroke.align !== 'OUTSIDE'\n const firstJoins = visibleStrokes.length > 0 && centered(visibleStrokes[0])\n const joined = firstJoins ? strokeAttrs[0] : {}\n const elements =\n visibleFills.length <= 1\n ? [\n svg('path', {\n ...common,\n fill: fillAttr ?? 'none',\n 'fill-opacity': fillOpacity,\n ...joined\n })\n ]\n : visibleFills.map((fill, index) =>\n svg('path', {\n ...common,\n fill: resolveFill(fill, node, ctx) ?? 'none',\n 'fill-opacity': solidFillOpacity(fill, ctx.colorSpace),\n ...(index === visibleFills.length - 1 ? joined : {})\n })\n )\n\n for (let index = firstJoins ? 1 : 0; index < visibleStrokes.length; index++) {\n const stroke = visibleStrokes[index]\n const attrs = strokeAttrs[index]\n elements.push(\n ...(centered(stroke)\n ? [svg('path', { d, fill: 'none', ...attrs })]\n : alignedStrokeElement(node, stroke, attrs, ctx, d))\n )\n }\n return elements\n}\n\n/** A boolean made in Pairdraw draws its computed result path instead of its operands. */\nfunction renderBooleanNode(\n node: SceneNode,\n ctx: SVGExportContext,\n paint: {\n groupAttrs: Record<string, string | number | undefined>\n visibleFills: Fill[]\n fillAttr: string | null\n fillOpacity: number | undefined\n strokeAttrs: Array<Record<string, string | number | undefined>>\n visibleStrokes: Stroke[]\n }\n): SVGNode | null {\n if (node.type !== 'BOOLEAN_OPERATION' || node.fillGeometry.length > 0 || !ctx.booleanPath) {\n return null\n }\n const d = ctx.booleanPath(ctx.graph, node)\n if (!d) return null\n return svg(\n 'g',\n paint.groupAttrs,\n ...booleanPathElements(\n node,\n d,\n paint.visibleFills,\n paint.fillAttr,\n paint.fillOpacity,\n paint.strokeAttrs,\n paint.visibleStrokes,\n ctx\n )\n )\n}\n\nfunction renderNode(node: SceneNode, ctx: SVGExportContext): SVGNode | null {\n if (!node.visible) return null\n\n const { attrs: groupAttrs, clipId } = buildGroupAttrs(node, ctx)\n\n if (node.type === 'TEXT') {\n const fill = exportedFill(\n node.fills.find((f) => f.visible),\n node,\n ctx\n )\n return svg('g', groupAttrs, renderTextNode(node, fill.color, ctx, fill.opacity))\n }\n\n const visibleFills = node.fills.filter((f) => f.visible)\n const visibleStrokes = node.strokes.filter((s) => s.visible)\n const tint = ctx.tint?.(node) ?? []\n const ownFill = visibleFills.length > 0 && !hasPathLevelFills(node) ? visibleFills[0] : undefined\n const fill = exportedFill(ownFill, node, ctx)\n const tintedFill = fill.color !== null && tint.includes('fill')\n const fillAttr = tintedFill ? CURRENT_COLOR : fill.color\n // `currentColor` has no alpha. Display P3 normally bakes solid opacity into the color, which a\n // tint throws away, so a tinted solid keeps `fill-opacity` in every color space.\n const fillOpacity = ownFill ? solidFillOpacity(ownFill, ctx.colorSpace, tintedFill) : fill.opacity\n const strokeAttrs = visibleStrokes.map((stroke) => {\n const attrs = buildSVGStrokeAttrs(stroke, node, ctx)\n return tint.includes('stroke') ? { ...attrs, stroke: CURRENT_COLOR } : attrs\n })\n\n const booleanDrawn = renderBooleanNode(node, ctx, {\n groupAttrs,\n visibleFills,\n fillAttr,\n fillOpacity,\n strokeAttrs,\n visibleStrokes\n })\n if (booleanDrawn) return booleanDrawn\n\n const children: (SVGNode | null)[] = buildShapeChildren(\n node,\n visibleFills,\n fillAttr,\n fillOpacity,\n strokeAttrs,\n visibleStrokes,\n ctx\n )\n\n const childContent = maskedChildNodes(ctx.graph.getChildren(node.id), ctx)\n\n if (clipId && childContent.length > 0) {\n children.push(svg('g', { 'clip-path': `url(#${clipId})` }, ...childContent))\n } else {\n children.push(...childContent)\n }\n\n const validChildren = children.filter((c): c is SVGNode => c !== null)\n\n if (validChildren.length === 0 && Object.keys(groupAttrs).length === 0) {\n return null\n }\n\n if (validChildren.length === 1 && Object.keys(groupAttrs).length === 0) {\n return validChildren[0]\n }\n\n return svg('g', groupAttrs, ...validChildren)\n}\n\nfunction isGroupLike(node: SceneNode): boolean {\n return node.type === 'GROUP'\n}\n\n// --- Public API ---\n\nexport interface SVGExportOptions {\n /** Include XML declaration (default: true) */\n xmlDeclaration?: boolean\n /** Target export color space (default: srgb) */\n colorSpace?: 'srgb' | 'display-p3'\n /** The document's color profile; colors stored in it convert into `colorSpace`. */\n documentColorSpace?: ColorProfile\n /**\n * Line breaks of text nodes as the editor laid them out, wraps included. Without them, only\n * explicit newlines start a new baseline, which renderers that do not wrap SVG text keep.\n */\n textLayout?: SVGTextLayout\n /**\n * A family to name a font face by instead of its own, such as the one a PDF embeds the face's\n * file under. Text in an aliased face is written in that family at normal weight and style.\n */\n fontAlias?: SVGFontAlias\n /**\n * The live result path of a boolean operation made in Pairdraw, which stores none. Left out,\n * such a boolean draws its box and its operands, as an archive-less reader sees it.\n */\n booleanPath?: BooleanPathResolver\n}\n\nexport function renderNodesToSVG(\n graph: SceneGraph,\n _pageId: string,\n nodeIds: string[],\n options: SVGExportOptions = {}\n): string | null {\n const bounds = computeContentBounds(graph, nodeIds)\n if (!bounds) return null\n\n const { minX, minY, maxX, maxY } = bounds\n const width = round(maxX - minX)\n const height = round(maxY - minY)\n\n const ctx: SVGExportContext = {\n defs: [],\n defIdCounter: 0,\n graph,\n colorSpace: options.colorSpace ?? 'srgb',\n documentColorSpace: options.documentColorSpace ?? graph.documentColorSpace,\n textLayout: options.textLayout,\n fontAlias: options.fontAlias,\n booleanPath: options.booleanPath\n }\n\n const contentNodes: SVGNode[] = []\n\n for (const id of nodeIds) {\n const node = graph.getNode(id)\n if (!node?.visible) continue\n\n const abs = graph.getAbsolutePosition(id)\n const offsetX = abs.x - minX\n const offsetY = abs.y - minY\n\n const needsOffset = offsetX !== node.x || offsetY !== node.y\n const clone = needsOffset ? { ...node, x: round(offsetX), y: round(offsetY) } : node\n\n const rendered = renderNode(clone, ctx)\n if (rendered) contentNodes.push(rendered)\n }\n\n if (contentNodes.length === 0) return null\n\n const rootChildren: (SVGNode | string)[] = []\n if (ctx.defs.length > 0) {\n rootChildren.push(svg('defs', {}, ...ctx.defs))\n }\n rootChildren.push(...contentNodes)\n\n const root = svg(\n 'svg',\n {\n xmlns: 'http://www.w3.org/2000/svg',\n 'xmlns:xlink': 'http://www.w3.org/1999/xlink',\n width,\n height,\n viewBox: `0 0 ${width} ${height}`\n },\n ...(rootChildren as SVGNode[])\n )\n\n const svgStr = renderSVGNode(root)\n const xmlDecl = options.xmlDeclaration !== false ? '<?xml version=\"1.0\" encoding=\"UTF-8\"?>\\n' : ''\n return xmlDecl + svgStr\n}\n\n/**\n * One layer as an `<svg>` element sized to its box, for inlining in HTML where the box already\n * places, rotates, and fades it: the drawing starts at the layer's origin without its rotation\n * or opacity, and keeps its flips.\n */\nexport function renderNodeSVGElement(\n graph: SceneGraph,\n node: SceneNode,\n {\n idPrefix,\n colorSpace = 'srgb',\n documentColorSpace,\n tint,\n booleanPath\n }: Pick<SVGExportContext, 'tint' | 'booleanPath'> & {\n idPrefix: string\n colorSpace?: RenderColorSpace\n documentColorSpace?: ColorProfile\n }\n): SVGNode | null {\n const ctx: SVGExportContext = {\n defs: [],\n defIdCounter: 0,\n graph,\n colorSpace,\n documentColorSpace: documentColorSpace ?? graph.documentColorSpace,\n idPrefix,\n tint,\n booleanPath\n }\n const drawn = renderNode({ ...node, x: 0, y: 0, rotation: 0, opacity: 1 }, ctx)\n if (!drawn) return null\n // A straight line has no height or width, but its stroke still needs a viewport to draw in.\n const width = Math.max(1, round(node.width))\n const height = Math.max(1, round(node.height))\n return svg(\n 'svg',\n { width, height, viewBox: `0 0 ${width} ${height}` },\n ctx.defs.length > 0 ? svg('defs', {}, ...ctx.defs) : null,\n drawn\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAyDA,SAAS,gBACP,MACA,SACA,QACW;CACX,MAAM,UAAU,eAAe,OAAO,CAAC,CAAC,KAAK,MAAM,IAAI,QAAQ;EAAE;EAAG,GAAG;CAAO,CAAC,CAAC;CAChF,IAAI,cAAc,OAAO,CAAC,CAAC,WAAW,GAAG,OAAO;CAChD,OAAO,CAAC,GAAG,SAAS,GAAG,iBAAiB,MAAM,SAAS,QAAQ,aAAa,CAAC;AAC/E;;AAGA,SAAS,mBACP,OACA,cACA,aACA,QACA,MACA,KACW;CACX,MAAM,WAAsB,CAAC;CAC7B,KAAK,MAAM,CAAC,OAAO,SAAS,aAAa,QAAQ,GAAG;EAClD,MAAM,WAAW,YAAY,MAAM,MAAM,GAAG;EAC5C,IAAI,CAAC,UAAU;EACf,MAAM,QAAQ,gBAAgB,IAAI;EAClC,MAAM,OAAO,UAAU,aAAa,SAAS;EAC7C,MAAM,cAAc,UAAU,KAAA,KAAa,QAAQ,OAAO,WAAW;EACrE,MAAM,SAAS,QAAQ,CAAC,cAAc,OAAO,SAAS;EACtD,SAAS,KACP,IAAI,QAAQ;GACV,GAAG;GACH,MAAM;GACN,gBAAgB,iBAAiB,MAAM,IAAI,UAAU;GACrD;GACA;EACF,CAAC,CACH;EACA,IAAI,aACF,SAAS,KACP,IAAI,QAAQ;GACV,GAAG,MAAM;GACT,aAAa,MAAM;GACnB,MAAM;GACN,GAAG;EACL,CAAC,CACH;CAEJ;CACA,OAAO;AACT;AAEA,SAAS,oBACP,MACA,QACA,aACA,KACA,eACW;CACX,MAAM,WAAsB,CAAC;CAC7B,IAAI,KAAK,aA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,GAAG,YAAY;CAEjC,MAAM,OAAO,IACX,OACA;EACE,OAAO;EACP,eAAe;EACf;EACA;EACA,SAAS,OAAO,MAAM,GAAG;CAC3B,GACA,GAAI,YACN;CAEA,MAAM,SAAS,cAAc,IAAI;CAEjC,QADgB,QAAQ,mBAAmB,QAAQ,iDAA6C,MAC/E;AACnB;;;;;;AAOA,SAAgB,qBACd,OACA,MACA,EACE,UACA,aAAa,QACb,oBACA,MACA,eAMc;CAChB,MAAM,MAAwB;EAC5B,MAAM,CAAC;EACP,cAAc;EACd;EACA;EACA,oBAAoB,sBAAsB,MAAM;EAChD;EACA;EACA;CACF;CACA,MAAM,QAAQ,WAAW;EAAE,GAAG;EAAM,GAAG;EAAG,GAAG;EAAG,UAAU;EAAG,SAAS;CAAE,GAAG,GAAG;CAC9E,IAAI,CAAC,OAAO,OAAO;CAEnB,MAAM,QAAQ,KAAK,IAAI,GAAG,MAAM,KAAK,KAAK,CAAC;CAC3C,MAAM,SAAS,KAAK,IAAI,GAAG,MAAM,KAAK,MAAM,CAAC;CAC7C,OAAO,IACL,OACA;EAAE;EAAO;EAAQ,SAAS,OAAO,MAAM,GAAG;CAAS,GACnD,IAAI,KAAK,SAAS,IAAI,IAAI,QAAQ,CAAC,GAAG,GAAG,IAAI,IAAI,IAAI,MACrD,KACF;AACF"}
1
+ {"version":3,"file":"export.js","names":[],"sources":["../../../../src/io/formats/svg/export.ts"],"sourcesContent":["import type {\n ColorProfile,\n Fill,\n SceneGraph,\n SceneNode,\n Stroke,\n VectorNetwork\n} from '@pairdraw/scene-graph'\nimport type { RenderColorSpace } from '@pairdraw/scene-graph/color'\nimport type { VisualBounds } from '@pairdraw/scene-graph/geometry'\n\nimport { normalizeDashPattern } from '#core/canvas/strokes'\nimport { lineStrokePath } from '#core/canvas/strokes/line'\nimport { fittedDashPattern } from '#core/canvas/strokes/sides'\nimport { computeContentBounds, sliceRegion } from '#core/io/formats/raster'\n\nimport {\n nextDefId,\n formatSolidColor,\n resolveFill,\n solidFillOpacity,\n SVG_STROKE_CAP,\n SVG_STROKE_JOIN,\n SVG_BLEND_MODE\n} from './defs'\nimport { createFilterDef } from './effects'\nimport {\n round,\n geometryBlobToSVGPath,\n makePolygonPoints,\n roundedPolygonPath,\n hasRadius,\n hasSmoothCorners,\n boxOutlinePath,\n arcPath,\n shapeWithTextOutlinePath\n} from './paths'\n\nexport { geometryBlobToSVGPath, nodeOutlinePath, type OutlineNode } from './paths'\n\nimport { looseSegments, regionSVGPaths } from '@pairdraw/scene-graph/vector-network'\n\nimport type { BooleanPathResolver } from '#core/io/formats/boolean-path'\n\nimport { arrowHeadElements, openPathElements, vectorArrowHeads } from './arrows'\nimport type { SVGExportContext, SVGFontAlias } from './defs'\nimport { svg, renderSVGNode } from './node'\nimport type { SVGNode } from './node'\nimport { alignedStroke, alignedStrokeElement, shapeWithTextDetailElements } from './strokes'\nimport { renderTextNode } from './text/export'\nimport type { SVGTextLayout } from './text/lines'\n\n// --- Node rendering ---\n\n/**\n * A vector network's paths: its regions as they are traced, and its open segments as the canvas\n * strokes them, rounded and pulled back under their heads.\n */\nfunction networkElements(\n node: SceneNode,\n network: VectorNetwork,\n common: Record<string, string | number | undefined>\n): SVGNode[] {\n const regions = regionSVGPaths(network).map((d) => svg('path', { d, ...common }))\n if (looseSegments(network).length === 0) return regions\n return [...regions, ...openPathElements(node, network, common, looseSegments)]\n}\n\n/** Paints one path's fill stack; a blended fill draws its stroke as a separate path. */\nfunction vectorFillElements(\n attrs: Record<string, string | number | undefined>,\n visibleFills: Fill[],\n strokeAttrs: Record<string, string | number | undefined>,\n common: Record<string, string | number | undefined>,\n node: SceneNode,\n ctx: SVGExportContext\n): SVGNode[] {\n const elements: SVGNode[] = []\n for (const [index, fill] of visibleFills.entries()) {\n const fillAttr = resolveFill(fill, node, ctx)\n if (!fillAttr) continue\n const style = paintBlendStyle(fill)\n const last = index === visibleFills.length - 1\n const splitStroke = style !== undefined && last && common.stroke !== 'none'\n const stroke = last && !splitStroke ? common.stroke : 'none'\n elements.push(\n svg('path', {\n ...attrs,\n fill: fillAttr,\n 'fill-opacity': solidFillOpacity(fill, ctx.colorSpace),\n style,\n stroke\n })\n )\n if (splitStroke) {\n elements.push(\n svg('path', {\n d: attrs.d,\n 'fill-rule': attrs['fill-rule'],\n fill: 'none',\n ...strokeAttrs\n })\n )\n }\n }\n return elements\n}\n\nfunction vectorShapeElements(\n node: SceneNode,\n common: Record<string, string | number | undefined>,\n strokeAttrs: Record<string, string | number | undefined>,\n ctx: SVGExportContext,\n fallbackFills?: Fill[]\n): SVGNode[] {\n const elements: SVGNode[] = []\n if (node.fillGeometry.length > 0) {\n for (const geo of node.fillGeometry) {\n const d = geometryBlobToSVGPath(geo.commandsBlob)\n if (!d) continue\n const attrs = {\n d,\n 'fill-rule': geo.windingRule === 'EVENODD' ? 'evenodd' : undefined,\n ...common\n }\n const pathFills = geo.fills?.length ? geo.fills : fallbackFills\n if (!pathFills) {\n elements.push(svg('path', attrs))\n continue\n }\n const visibleFills = pathFills.filter((fill) => fill.visible)\n if (visibleFills.length === 0) {\n elements.push(svg('path', { ...attrs, fill: 'none' }))\n continue\n }\n elements.push(...vectorFillElements(attrs, visibleFills, strokeAttrs, common, node, ctx))\n }\n } else if (node.vectorNetwork) {\n elements.push(...networkElements(node, node.vectorNetwork, common))\n }\n elements.push(...vectorStrokeTail(node, strokeAttrs))\n return withVectorFallback(elements, node, common)\n}\n\n/** The empty vector's fallback shape, after both paints have contributed their elements. */\nfunction withVectorFallback(\n elements: SVGNode[],\n node: SceneNode,\n common: Record<string, string | number | undefined>\n): SVGNode[] {\n return elements.length > 0\n ? elements\n : [svg('rect', { width: round(node.width), height: round(node.height), ...common })]\n}\n\n/** The stored stroke geometry and arrowheads both vector paints share after their outlines. */\nfunction vectorStrokeTail(\n node: SceneNode,\n strokeAttrs: Record<string, string | number | undefined>\n): SVGNode[] {\n const elements: SVGNode[] = []\n if (node.strokeGeometry.length > 0 && strokeAttrs.stroke && strokeAttrs.stroke !== 'none') {\n for (const geo of node.strokeGeometry) {\n const d = geometryBlobToSVGPath(geo.commandsBlob)\n if (d) {\n elements.push(\n svg('path', {\n d,\n fill: strokeAttrs.stroke,\n 'fill-opacity': strokeAttrs['stroke-opacity'],\n stroke: 'none'\n })\n )\n }\n }\n }\n if (node.vectorNetwork) elements.push(...vectorArrowHeads(node, node.vectorNetwork, strokeAttrs))\n return elements\n}\n\n/** A vector layer's outlines as strokes alone, for a second stroke over the painted fills. */\nfunction vectorStrokeElements(\n node: SceneNode,\n strokeAttrs: Record<string, string | number | undefined>\n): SVGNode[] {\n const elements: SVGNode[] = []\n const common: Record<string, string | number | undefined> = { fill: 'none', ...strokeAttrs }\n if (node.fillGeometry.length > 0) {\n for (const geo of node.fillGeometry) {\n const d = geometryBlobToSVGPath(geo.commandsBlob)\n if (d) {\n elements.push(\n svg('path', {\n d,\n 'fill-rule': geo.windingRule === 'EVENODD' ? 'evenodd' : undefined,\n ...common\n })\n )\n }\n }\n } else if (node.vectorNetwork) {\n elements.push(...networkElements(node, node.vectorNetwork, common))\n }\n elements.push(...vectorStrokeTail(node, strokeAttrs))\n return withVectorFallback(elements, node, common)\n}\n\n/** A line's dashes stretched along it as the canvas lays them, half a dash at each end. */\nfunction lineDashAttrs(stroke: Stroke | undefined, length: number) {\n const fitted = fittedDashPattern(length, normalizeDashPattern(stroke?.dashPattern))\n if (!fitted) return {}\n return {\n 'stroke-dasharray': fitted.intervals.map((size) => round(size)).join(' '),\n 'stroke-dashoffset': round(fitted.offset)\n }\n}\n\nfunction nodeShapeElements(\n node: SceneNode,\n fillAttr: string | null,\n fillOpacity: number | undefined,\n strokeAttrs: Record<string, string | number | undefined>,\n ctx: SVGExportContext,\n stroke?: Stroke\n): SVGNode[] {\n const common: Record<string, string | number | undefined> = {\n fill: fillAttr ?? 'none',\n 'fill-opacity': fillOpacity,\n ...strokeAttrs\n }\n\n switch (node.type) {\n case 'ELLIPSE': {\n if (node.arcData) {\n return [svg('path', { d: arcPath(node), ...common })]\n }\n return [\n svg('ellipse', {\n cx: round(node.width / 2),\n cy: round(node.height / 2),\n rx: round(node.width / 2),\n ry: round(node.height / 2),\n ...common\n })\n ]\n }\n\n case 'LINE': {\n // Where the canvas strokes it: to one side of the line, with its caps inside its length.\n const lineStroke = stroke ?? node.strokes.find((item) => item.visible)\n const {\n network,\n from: start,\n to: end\n } = lineStrokePath(node, lineStroke?.weight ?? 0, lineStroke?.cap ?? node.strokeCap)\n return [\n svg('line', {\n x1: round(start.x),\n y1: round(start.y),\n x2: round(end.x),\n y2: round(end.y),\n fill: 'none',\n ...strokeAttrs,\n ...lineDashAttrs(lineStroke, Math.hypot(end.x - start.x, end.y - start.y))\n }),\n ...arrowHeadElements(node, network, lineStroke, strokeAttrs)\n ]\n }\n\n case 'STAR':\n case 'POLYGON':\n return node.cornerRadius > 0\n ? [svg('path', { d: roundedPolygonPath(node), ...common })]\n : [svg('polygon', { points: makePolygonPoints(node), ...common })]\n\n case 'VECTOR':\n return vectorShapeElements(node, common, strokeAttrs, ctx)\n\n case 'SHAPE_WITH_TEXT':\n return shapeWithTextElements(node, common, strokeAttrs, ctx)\n\n default:\n return [boxOutlineElement(node, common)]\n }\n}\n\n/**\n * A box layer's outline as one element: a rect, a rect with `rx`/`ry` for one radius, or the\n * shared box path for independent or smoothed corners, so fills and clips follow the same edge.\n */\nfunction boxOutlineElement(\n node: SceneNode,\n attrs: Record<string, string | number | undefined>\n): SVGNode {\n const width = round(node.width)\n const height = round(node.height)\n if (!hasRadius(node)) return svg('rect', { width, height, ...attrs })\n if (node.independentCorners || hasSmoothCorners(node)) {\n return svg('path', { d: boxOutlinePath(node), ...attrs })\n }\n // SVG clamps rx and ry to their own sides; the canvas keeps a too-large radius circular.\n const radius = round(Math.min(node.cornerRadius, node.width / 2, node.height / 2))\n return svg('rect', { width, height, rx: radius, ry: radius, ...attrs })\n}\n\n/**\n * A FigJam shape's outline, and its inner lines, such as a database's front rim, stroked as the\n * canvas strokes them: at the stroke's own weight, ending where the outline does.\n */\nfunction shapeWithTextElements(\n node: SceneNode,\n common: Record<string, string | number | undefined>,\n strokeAttrs: Record<string, string | number | undefined>,\n ctx: SVGExportContext\n): SVGNode[] {\n return [\n svg('path', { d: shapeWithTextOutlinePath(node), ...common }),\n ...shapeWithTextDetailElements(node, strokeAttrs, ctx)\n ]\n}\n\n// --- Main recursive renderer ---\n\nfunction buildTransformAttr(node: SceneNode): string | undefined {\n const transforms: string[] = []\n if (node.x !== 0 || node.y !== 0) transforms.push(`translate(${round(node.x)}, ${round(node.y)})`)\n if (node.rotation !== 0) {\n transforms.push(\n `rotate(${round(node.rotation)}, ${round(node.width / 2)}, ${round(node.height / 2)})`\n )\n }\n if (node.flipX || node.flipY) {\n const tx = node.flipX ? node.width : 0\n const ty = node.flipY ? node.height : 0\n const sx = node.flipX ? -1 : 1\n const sy = node.flipY ? -1 : 1\n transforms.push(`translate(${round(tx)}, ${round(ty)}) scale(${sx}, ${sy})`)\n }\n return transforms.length > 0 ? transforms.join(' ') : undefined\n}\n\nfunction buildGroupAttrs(\n node: SceneNode,\n ctx: SVGExportContext\n): { attrs: Record<string, string | number | undefined>; clipId?: string } {\n const attrs: Record<string, string | number | undefined> = {}\n\n const transform = buildTransformAttr(node)\n if (transform) attrs.transform = transform\n\n if (node.opacity < 1) attrs.opacity = round(node.opacity)\n\n const blend = SVG_BLEND_MODE[node.blendMode]\n if (blend && blend !== 'normal' && node.blendMode !== 'PASS_THROUGH') {\n attrs.style = `mix-blend-mode: ${blend}`\n }\n\n const filterDef = createFilterDef(node, ctx)\n if (filterDef) {\n ctx.defs.push(filterDef.node)\n attrs.filter = `url(#${filterDef.id})`\n }\n\n let clipId: string | undefined\n if (node.clipsContent && node.childIds.length > 0) {\n clipId = nextDefId(ctx, 'clip')\n ctx.defs.push(svg('clipPath', { id: clipId }, boxOutlineElement(node, {})))\n }\n\n return { attrs, clipId }\n}\n\nfunction buildSVGStrokeAttrs(\n stroke: Stroke,\n node: SceneNode,\n ctx: SVGExportContext\n): Record<string, string | number | undefined> {\n const cap = stroke.cap ?? node.strokeCap\n const attrs: Record<string, string | number | undefined> = {\n // Opacity 1 keeps the color opaque. Display P3 must not also keep color alpha here, or a\n // viewer multiplies it by stroke-opacity; the canvas paints stroke.opacity alone.\n stroke:\n stroke.type === 'SOLID'\n ? formatSolidColor(stroke.color, 1, ctx.colorSpace, ctx.documentColorSpace)\n : (resolveFill(stroke, node, ctx) ??\n formatSolidColor(stroke.color, 1, ctx.colorSpace, ctx.documentColorSpace)),\n 'stroke-width': round(stroke.weight)\n }\n if (stroke.opacity < 1) attrs['stroke-opacity'] = round(stroke.opacity)\n if (cap !== 'NONE') attrs['stroke-linecap'] = SVG_STROKE_CAP[cap] ?? 'butt'\n if (stroke.join && stroke.join !== 'MITER') {\n attrs['stroke-linejoin'] = SVG_STROKE_JOIN[stroke.join] ?? 'miter'\n }\n if (stroke.dashPattern && stroke.dashPattern.length > 0) {\n attrs['stroke-dasharray'] = stroke.dashPattern.map((n) => round(n)).join(' ')\n }\n return attrs\n}\n\n/** The blend CSS a paint adds, when the canvas would not composite it source-over. */\nfunction paintBlendStyle(fill: Fill | undefined): string | undefined {\n const blend = fill?.blendMode ? SVG_BLEND_MODE[fill.blendMode] : undefined\n return blend && blend !== 'normal' ? `mix-blend-mode: ${blend}` : undefined\n}\n\n/** Adds a paint's blend mode to the elements that draw it. */\nfunction withPaintBlend(elements: SVGNode[], fill: Fill | undefined): SVGNode[] {\n const style = paintBlendStyle(fill)\n if (style) for (const element of elements) element.attrs.style = style\n return elements\n}\n\n/**\n * Draws the fill and the stroke as separate elements when the fill blends, so the stroke keeps the\n * source-over canvas gives it instead of inheriting the fill's blend mode.\n */\nfunction shapeWithPaint(\n node: SceneNode,\n fillAttr: string | null,\n fillOpacity: number | undefined,\n strokeAttrs: Record<string, string | number | undefined>,\n fill: Fill | undefined,\n ctx: SVGExportContext\n): SVGNode[] {\n const blends = paintBlendStyle(fill) !== undefined\n if (!blends || !strokeAttrs.stroke) {\n return withPaintBlend(nodeShapeElements(node, fillAttr, fillOpacity, strokeAttrs, ctx), fill)\n }\n return [\n ...withPaintBlend(nodeShapeElements(node, fillAttr, fillOpacity, {}, ctx), fill),\n ...nodeShapeElements(node, null, undefined, strokeAttrs, ctx)\n ]\n}\n\nfunction hasPathLevelFills(node: SceneNode): boolean {\n return node.type === 'VECTOR' && node.fillGeometry.some((geometry) => geometry.fills?.length)\n}\n\n/** One stroke at its own weight over the fills: a centred one on the outline, an aligned one around it. */\nfunction strokeElements(\n node: SceneNode,\n stroke: Stroke,\n strokeAttrs: Record<string, string | number | undefined>,\n ctx: SVGExportContext\n): SVGNode[] {\n const aligned = hasPathLevelFills(node) ? null : alignedStroke(node, stroke)\n if (aligned) {\n return [\n ...alignedStrokeElement(node, aligned, strokeAttrs, ctx),\n ...(node.type === 'SHAPE_WITH_TEXT'\n ? shapeWithTextDetailElements(node, strokeAttrs, ctx)\n : [])\n ]\n }\n if (node.type === 'VECTOR') return vectorStrokeElements(node, strokeAttrs)\n return nodeShapeElements(node, null, undefined, strokeAttrs, ctx, stroke)\n}\n\n/**\n * The fills and the strokes over them. The first stroke joins the fill's own element as before;\n * every later visible stroke is drawn in layer order, without painting the fill again.\n */\nfunction buildShapeChildren(\n node: SceneNode,\n visibleFills: Fill[],\n fillAttr: string | null,\n fillOpacity: number | undefined,\n strokeAttrs: Record<string, string | number | undefined>[],\n visibleStrokes: Stroke[],\n ctx: SVGExportContext\n): SVGNode[] {\n if (visibleStrokes.length === 0) {\n return fillAndStrokeElements(node, visibleFills, fillAttr, fillOpacity, {}, 0, ctx)\n }\n const first = visibleStrokes[0]\n const firstAttrs = strokeAttrs[0]\n const elements = alignedStroke(node, first)\n ? // The fill goes as it is, and the stroke over it inside or outside the outline.\n [\n ...fillAndStrokeElements(node, visibleFills, fillAttr, fillOpacity, {}, 0, ctx),\n ...strokeElements(node, first, firstAttrs, ctx)\n ]\n : fillAndStrokeElements(\n node,\n visibleFills,\n fillAttr,\n fillOpacity,\n firstAttrs,\n visibleStrokes.length,\n ctx\n )\n for (let index = 1; index < visibleStrokes.length; index++) {\n elements.push(...strokeElements(node, visibleStrokes[index], strokeAttrs[index], ctx))\n }\n return elements\n}\n\nfunction fillAndStrokeElements(\n node: SceneNode,\n visibleFills: Fill[],\n fillAttr: string | null,\n fillOpacity: number | undefined,\n strokeAttrs: Record<string, string | number | undefined>,\n visibleStrokeCount: number,\n ctx: SVGExportContext\n): SVGNode[] {\n if (hasPathLevelFills(node)) {\n return vectorShapeElements(\n node,\n { fill: fillAttr ?? 'none', 'fill-opacity': fillOpacity, ...strokeAttrs },\n strokeAttrs,\n ctx,\n visibleFills\n )\n }\n\n if (visibleFills.length > 1) {\n const elements: SVGNode[] = []\n for (const fill of visibleFills) {\n const ref = resolveFill(fill, node, ctx)\n if (ref) {\n elements.push(\n ...shapeWithPaint(\n node,\n ref,\n solidFillOpacity(fill, ctx.colorSpace),\n fill === visibleFills[visibleFills.length - 1] ? strokeAttrs : {},\n fill,\n ctx\n )\n )\n }\n }\n return elements\n }\n\n const hasFillOrStroke = fillAttr || visibleStrokeCount > 0\n if (hasFillOrStroke && !isGroupLike(node)) {\n return shapeWithPaint(\n node,\n fillAttr,\n fillOpacity,\n strokeAttrs,\n visibleFills.length === 1 ? visibleFills[0] : undefined,\n ctx\n )\n }\n\n return []\n}\n\n/** The paint CSS `color` sets, for a tinted icon path. */\nconst CURRENT_COLOR = 'currentColor'\n\n/** A paint's SVG color and, for an sRGB solid, the `fill-opacity` beside it. */\nfunction exportedFill(\n fill: Fill | undefined,\n node: SceneNode,\n ctx: SVGExportContext\n): { color: string | null; opacity: number | undefined } {\n if (!fill) return { color: null, opacity: undefined }\n return {\n color: resolveFill(fill, node, ctx),\n opacity: solidFillOpacity(fill, ctx.colorSpace)\n }\n}\n\n/**\n * A mask layer's definition: an alpha or luminance `<mask>`, or a `<clipPath>` for an outline\n * mask. The rendered layer carries its own position, opacity, and filters into the mask.\n */\nfunction maskWire(\n mask: SceneNode,\n ctx: SVGExportContext\n): { attribute: 'mask' | 'clip-path'; id: string } {\n const content = renderNode(mask, ctx)\n if (mask.maskType === 'VECTOR') {\n const id = nextDefId(ctx, 'clip')\n ctx.defs.push(svg('clipPath', { id, clipPathUnits: 'userSpaceOnUse' }, content ?? undefined))\n return { attribute: 'clip-path', id }\n }\n const id = nextDefId(ctx, 'mask')\n const attrs: Record<string, string | number | undefined> = {\n id,\n maskContentUnits: 'userSpaceOnUse'\n }\n if (mask.maskType === 'ALPHA') attrs['mask-type'] = 'alpha'\n ctx.defs.push(svg('mask', attrs, content ?? undefined))\n return { attribute: 'mask', id }\n}\n\n/**\n * The children as the canvas draws them: a run of visible masks masks the siblings that follow\n * it, until the next mask, and the mask layers themselves never draw on their own.\n */\nfunction maskedChildNodes(childNodes: SceneNode[], ctx: SVGExportContext): SVGNode[] {\n const content: SVGNode[] = []\n let masks: Array<{ attribute: 'mask' | 'clip-path'; id: string }> = []\n let afterMask = false\n for (const child of childNodes) {\n if (child.visible && child.isMask) {\n const wire = maskWire(child, ctx)\n masks = afterMask ? [...masks, wire] : [wire]\n afterMask = true\n continue\n }\n const rendered = renderNode(child, ctx)\n afterMask = false\n if (!rendered) continue\n let wrapped = rendered\n for (const wire of masks) wrapped = svg('g', { [wire.attribute]: `url(#${wire.id})` }, wrapped)\n content.push(wrapped)\n }\n return content\n}\n\n/** A boolean's live result path in the paints its fills and strokes give it. */\nfunction booleanPathElements(\n node: SceneNode,\n d: string,\n visibleFills: Fill[],\n fillAttr: string | null,\n fillOpacity: number | undefined,\n strokeAttrs: Array<Record<string, string | number | undefined>>,\n visibleStrokes: Stroke[],\n ctx: SVGExportContext\n): SVGNode[] {\n const common = { d, 'fill-rule': 'evenodd' as const }\n // A centred first stroke joins the fill element, as a shape's does; every later stroke, and\n // every inside or outside stroke, is drawn over the result outline on its own. An unset\n // alignment strokes the centred way, as `alignedStroke` treats it.\n const centered = (stroke: Stroke): boolean =>\n stroke.align !== 'INSIDE' && stroke.align !== 'OUTSIDE'\n const firstJoins = visibleStrokes.length > 0 && centered(visibleStrokes[0])\n const joined = firstJoins ? strokeAttrs[0] : {}\n const elements =\n visibleFills.length <= 1\n ? [\n svg('path', {\n ...common,\n fill: fillAttr ?? 'none',\n 'fill-opacity': fillOpacity,\n ...joined\n })\n ]\n : visibleFills.map((fill, index) =>\n svg('path', {\n ...common,\n fill: resolveFill(fill, node, ctx) ?? 'none',\n 'fill-opacity': solidFillOpacity(fill, ctx.colorSpace),\n ...(index === visibleFills.length - 1 ? joined : {})\n })\n )\n\n for (let index = firstJoins ? 1 : 0; index < visibleStrokes.length; index++) {\n const stroke = visibleStrokes[index]\n const attrs = strokeAttrs[index]\n elements.push(\n ...(centered(stroke)\n ? [svg('path', { d, fill: 'none', ...attrs })]\n : alignedStrokeElement(node, stroke, attrs, ctx, d))\n )\n }\n return elements\n}\n\n/** A boolean made in Pairdraw draws its computed result path instead of its operands. */\nfunction renderBooleanNode(\n node: SceneNode,\n ctx: SVGExportContext,\n paint: {\n groupAttrs: Record<string, string | number | undefined>\n visibleFills: Fill[]\n fillAttr: string | null\n fillOpacity: number | undefined\n strokeAttrs: Array<Record<string, string | number | undefined>>\n visibleStrokes: Stroke[]\n }\n): SVGNode | null {\n if (node.type !== 'BOOLEAN_OPERATION' || node.fillGeometry.length > 0 || !ctx.booleanPath) {\n return null\n }\n const d = ctx.booleanPath(ctx.graph, node)\n if (!d) return null\n return svg(\n 'g',\n paint.groupAttrs,\n ...booleanPathElements(\n node,\n d,\n paint.visibleFills,\n paint.fillAttr,\n paint.fillOpacity,\n paint.strokeAttrs,\n paint.visibleStrokes,\n ctx\n )\n )\n}\n\nfunction renderNode(node: SceneNode, ctx: SVGExportContext): SVGNode | null {\n if (!node.visible || node.type === 'SLICE') return null\n\n const { attrs: groupAttrs, clipId } = buildGroupAttrs(node, ctx)\n\n if (node.type === 'TEXT') {\n const fill = exportedFill(\n node.fills.find((f) => f.visible),\n node,\n ctx\n )\n return svg('g', groupAttrs, renderTextNode(node, fill.color, ctx, fill.opacity))\n }\n\n const visibleFills = node.fills.filter((f) => f.visible)\n const visibleStrokes = node.strokes.filter((s) => s.visible)\n const tint = ctx.tint?.(node) ?? []\n const ownFill = visibleFills.length > 0 && !hasPathLevelFills(node) ? visibleFills[0] : undefined\n const fill = exportedFill(ownFill, node, ctx)\n const tintedFill = fill.color !== null && tint.includes('fill')\n const fillAttr = tintedFill ? CURRENT_COLOR : fill.color\n // `currentColor` has no alpha. Display P3 normally bakes solid opacity into the color, which a\n // tint throws away, so a tinted solid keeps `fill-opacity` in every color space.\n const fillOpacity = ownFill ? solidFillOpacity(ownFill, ctx.colorSpace, tintedFill) : fill.opacity\n const strokeAttrs = visibleStrokes.map((stroke) => {\n const attrs = buildSVGStrokeAttrs(stroke, node, ctx)\n return tint.includes('stroke') ? { ...attrs, stroke: CURRENT_COLOR } : attrs\n })\n\n const booleanDrawn = renderBooleanNode(node, ctx, {\n groupAttrs,\n visibleFills,\n fillAttr,\n fillOpacity,\n strokeAttrs,\n visibleStrokes\n })\n if (booleanDrawn) return booleanDrawn\n\n const children: (SVGNode | null)[] = buildShapeChildren(\n node,\n visibleFills,\n fillAttr,\n fillOpacity,\n strokeAttrs,\n visibleStrokes,\n ctx\n )\n\n const childContent = maskedChildNodes(ctx.graph.getChildren(node.id), ctx)\n\n if (clipId && childContent.length > 0) {\n children.push(svg('g', { 'clip-path': `url(#${clipId})` }, ...childContent))\n } else {\n children.push(...childContent)\n }\n\n const validChildren = children.filter((c): c is SVGNode => c !== null)\n\n if (validChildren.length === 0 && Object.keys(groupAttrs).length === 0) {\n return null\n }\n\n if (validChildren.length === 1 && Object.keys(groupAttrs).length === 0) {\n return validChildren[0]\n }\n\n return svg('g', groupAttrs, ...validChildren)\n}\n\nfunction isGroupLike(node: SceneNode): boolean {\n return node.type === 'GROUP'\n}\n\n// --- Public API ---\n\nexport interface SVGExportOptions {\n /** Include XML declaration (default: true) */\n xmlDeclaration?: boolean\n /** Target export color space (default: srgb) */\n colorSpace?: 'srgb' | 'display-p3'\n /** The document's color profile; colors stored in it convert into `colorSpace`. */\n documentColorSpace?: ColorProfile\n /**\n * Line breaks of text nodes as the editor laid them out, wraps included. Without them, only\n * explicit newlines start a new baseline, which renderers that do not wrap SVG text keep.\n */\n textLayout?: SVGTextLayout\n /**\n * A family to name a font face by instead of its own, such as the one a PDF embeds the face's\n * file under. Text in an aliased face is written in that family at normal weight and style.\n */\n fontAlias?: SVGFontAlias\n /**\n * The live result path of a boolean operation made in Pairdraw, which stores none. Left out,\n * such a boolean draws its box and its operands, as an archive-less reader sees it.\n */\n booleanPath?: BooleanPathResolver\n}\n\nfunction svgExportContext(graph: SceneGraph, options: SVGExportOptions): SVGExportContext {\n return {\n defs: [],\n defIdCounter: 0,\n graph,\n colorSpace: options.colorSpace ?? 'srgb',\n documentColorSpace: options.documentColorSpace ?? graph.documentColorSpace,\n textLayout: options.textLayout,\n fontAlias: options.fontAlias,\n booleanPath: options.booleanPath\n }\n}\n\n/** The slice's box, and the page content under it, clipped: a slice has no vector geometry of its own. */\nexport function renderRegionSVG(\n graph: SceneGraph,\n pageId: string,\n bounds: VisualBounds,\n options: SVGExportOptions = {}\n): string | null {\n const page = graph.getNode(pageId)\n if (!page) return null\n const { minX, minY, maxX, maxY } = bounds\n const width = round(maxX - minX)\n const height = round(maxY - minY)\n if (width <= 0 || height <= 0) return null\n const ctx = svgExportContext(graph, options)\n const contentNodes: SVGNode[] = []\n for (const id of page.childIds) {\n const node = graph.getNode(id)\n if (!node?.visible || node.type === 'SLICE') continue\n const abs = graph.getAbsolutePosition(id)\n const offsetX = abs.x - minX\n const offsetY = abs.y - minY\n const rendered = renderNode(\n offsetX !== node.x || offsetY !== node.y\n ? { ...node, x: round(offsetX), y: round(offsetY) }\n : node,\n ctx\n )\n if (rendered) contentNodes.push(rendered)\n }\n if (contentNodes.length === 0) return null\n const clipId = nextDefId(ctx, 'slice')\n ctx.defs.push(\n svg(\n 'clipPath',\n { id: clipId, clipPathUnits: 'userSpaceOnUse' },\n svg('rect', { x: 0, y: 0, width, height })\n )\n )\n const root = svg(\n 'svg',\n {\n xmlns: 'http://www.w3.org/2000/svg',\n 'xmlns:xlink': 'http://www.w3.org/1999/xlink',\n width,\n height,\n viewBox: `0 0 ${width} ${height}`\n },\n svg('defs', {}, ...ctx.defs),\n svg('g', { 'clip-path': `url(#${clipId})` }, ...contentNodes)\n )\n const svgStr = renderSVGNode(root)\n const xmlDecl = options.xmlDeclaration !== false ? '<?xml version=\"1.0\" encoding=\"UTF-8\"?>\\n' : ''\n return xmlDecl + svgStr\n}\n\nexport function renderNodesToSVG(\n graph: SceneGraph,\n pageId: string,\n nodeIds: string[],\n options: SVGExportOptions = {}\n): string | null {\n const box = sliceRegion(graph, nodeIds)\n if (box) return renderRegionSVG(graph, pageId, box, options)\n const bounds = computeContentBounds(graph, nodeIds)\n if (!bounds) return null\n\n const { minX, minY, maxX, maxY } = bounds\n const width = round(maxX - minX)\n const height = round(maxY - minY)\n\n const ctx = svgExportContext(graph, options)\n\n const contentNodes: SVGNode[] = []\n\n for (const id of nodeIds) {\n const node = graph.getNode(id)\n if (!node?.visible) continue\n\n const abs = graph.getAbsolutePosition(id)\n const offsetX = abs.x - minX\n const offsetY = abs.y - minY\n\n const needsOffset = offsetX !== node.x || offsetY !== node.y\n const clone = needsOffset ? { ...node, x: round(offsetX), y: round(offsetY) } : node\n\n const rendered = renderNode(clone, ctx)\n if (rendered) contentNodes.push(rendered)\n }\n\n if (contentNodes.length === 0) return null\n\n const rootChildren: (SVGNode | string)[] = []\n if (ctx.defs.length > 0) {\n rootChildren.push(svg('defs', {}, ...ctx.defs))\n }\n rootChildren.push(...contentNodes)\n\n const root = svg(\n 'svg',\n {\n xmlns: 'http://www.w3.org/2000/svg',\n 'xmlns:xlink': 'http://www.w3.org/1999/xlink',\n width,\n height,\n viewBox: `0 0 ${width} ${height}`\n },\n ...(rootChildren as SVGNode[])\n )\n\n const svgStr = renderSVGNode(root)\n const xmlDecl = options.xmlDeclaration !== false ? '<?xml version=\"1.0\" encoding=\"UTF-8\"?>\\n' : ''\n return xmlDecl + svgStr\n}\n\n/**\n * One layer as an `<svg>` element sized to its box, for inlining in HTML where the box already\n * places, rotates, and fades it: the drawing starts at the layer's origin without its rotation\n * or opacity, and keeps its flips.\n */\nexport function renderNodeSVGElement(\n graph: SceneGraph,\n node: SceneNode,\n {\n idPrefix,\n colorSpace = 'srgb',\n documentColorSpace,\n tint,\n booleanPath\n }: Pick<SVGExportContext, 'tint' | 'booleanPath'> & {\n idPrefix: string\n colorSpace?: RenderColorSpace\n documentColorSpace?: ColorProfile\n }\n): SVGNode | null {\n const ctx: SVGExportContext = {\n defs: [],\n defIdCounter: 0,\n graph,\n colorSpace,\n documentColorSpace: documentColorSpace ?? graph.documentColorSpace,\n idPrefix,\n tint,\n booleanPath\n }\n const drawn = renderNode({ ...node, x: 0, y: 0, rotation: 0, opacity: 1 }, ctx)\n if (!drawn) return null\n // A straight line has no height or width, but its stroke still needs a viewport to draw in.\n const width = Math.max(1, round(node.width))\n const height = Math.max(1, round(node.height))\n return svg(\n 'svg',\n { width, height, viewBox: `0 0 ${width} ${height}` },\n ctx.defs.length > 0 ? svg('defs', {}, ...ctx.defs) : null,\n drawn\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AA0DA,SAAS,gBACP,MACA,SACA,QACW;CACX,MAAM,UAAU,eAAe,OAAO,CAAC,CAAC,KAAK,MAAM,IAAI,QAAQ;EAAE;EAAG,GAAG;CAAO,CAAC,CAAC;CAChF,IAAI,cAAc,OAAO,CAAC,CAAC,WAAW,GAAG,OAAO;CAChD,OAAO,CAAC,GAAG,SAAS,GAAG,iBAAiB,MAAM,SAAS,QAAQ,aAAa,CAAC;AAC/E;;AAGA,SAAS,mBACP,OACA,cACA,aACA,QACA,MACA,KACW;CACX,MAAM,WAAsB,CAAC;CAC7B,KAAK,MAAM,CAAC,OAAO,SAAS,aAAa,QAAQ,GAAG;EAClD,MAAM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AG;EAAG,GAAG;EAAG,UAAU;EAAG,SAAS;CAAE,GAAG,GAAG;CAC9E,IAAI,CAAC,OAAO,OAAO;CAEnB,MAAM,QAAQ,KAAK,IAAI,GAAG,MAAM,KAAK,KAAK,CAAC;CAC3C,MAAM,SAAS,KAAK,IAAI,GAAG,MAAM,KAAK,MAAM,CAAC;CAC7C,OAAO,IACL,OACA;EAAE;EAAO;EAAQ,SAAS,OAAO,MAAM,GAAG;CAAS,GACnD,IAAI,KAAK,SAAS,IAAI,IAAI,QAAQ,CAAC,GAAG,GAAG,IAAI,IAAI,IAAI,MACrD,KACF;AACF"}
@@ -2,8 +2,8 @@ import { OutlineNode, geometryBlobToSVGPath, nodeOutlinePath } from "./paths.js"
2
2
  import { SVGNode, renderSVGNode, svg } from "./node.js";
3
3
  import { SVGCharacterEdges, SVGFallbackFace, SVGTextLayout, SVGTextLine } from "./text/lines.js";
4
4
  import { SVGFontAlias, SVGFontRequest } from "./defs.js";
5
- import { SVGExportOptions, renderNodesToSVG } from "./export.js";
5
+ import { SVGExportOptions, renderNodesToSVG, renderRegionSVG } from "./export.js";
6
6
  import { SVGImportData, SVGImportOptions, createSVGNodes, createSVGNodesFromImport, prepareSVGImport } from "./import.js";
7
7
  import { isSVGMarkup } from "./metadata.js";
8
8
  import { svgImportFonts } from "./text/import.js";
9
- export { type OutlineNode, type SVGCharacterEdges, type SVGExportOptions, type SVGFallbackFace, type SVGFontAlias, type SVGFontRequest, type SVGImportData, type SVGImportOptions, type SVGNode, type SVGTextLayout, type SVGTextLine, createSVGNodes, createSVGNodesFromImport, geometryBlobToSVGPath, isSVGMarkup, nodeOutlinePath, prepareSVGImport, renderNodesToSVG, renderSVGNode, svg, svgImportFonts };
9
+ export { type OutlineNode, type SVGCharacterEdges, type SVGExportOptions, type SVGFallbackFace, type SVGFontAlias, type SVGFontRequest, type SVGImportData, type SVGImportOptions, type SVGNode, type SVGTextLayout, type SVGTextLine, createSVGNodes, createSVGNodesFromImport, geometryBlobToSVGPath, isSVGMarkup, nodeOutlinePath, prepareSVGImport, renderNodesToSVG, renderRegionSVG, renderSVGNode, svg, svgImportFonts };
@@ -1,7 +1,7 @@
1
1
  import { isSVGMarkup } from "./metadata.js";
2
2
  import { renderSVGNode, svg } from "./node.js";
3
3
  import { geometryBlobToSVGPath, nodeOutlinePath } from "./paths.js";
4
- import { renderNodesToSVG } from "./export.js";
4
+ import { renderNodesToSVG, renderRegionSVG } from "./export.js";
5
5
  import { svgImportFonts } from "./text/import.js";
6
6
  import { createSVGNodes, createSVGNodesFromImport, prepareSVGImport } from "./import.js";
7
- export { createSVGNodes, createSVGNodesFromImport, geometryBlobToSVGPath, isSVGMarkup, nodeOutlinePath, prepareSVGImport, renderNodesToSVG, renderSVGNode, svg, svgImportFonts };
7
+ export { createSVGNodes, createSVGNodesFromImport, geometryBlobToSVGPath, isSVGMarkup, nodeOutlinePath, prepareSVGImport, renderNodesToSVG, renderRegionSVG, renderSVGNode, svg, svgImportFonts };
@@ -1 +1 @@
1
- {"version":3,"file":"layout.d.ts","names":[],"sources":["../../../../../src/io/formats/svg/text/layout.ts"],"mappings":";;;;;;;;;;;iBAgBsB,wBACpB,OAAO,YACP,gBACA,mBACA,UAAS,kBACT,YAAY,WACZ,WAAW,eACV"}
1
+ {"version":3,"file":"layout.d.ts","names":[],"sources":["../../../../../src/io/formats/svg/text/layout.ts"],"mappings":";;;;;;;;;;;iBAiBsB,wBACpB,OAAO,YACP,gBACA,mBACA,UAAS,kBACT,YAAY,WACZ,WAAW,eACV"}
@@ -1,3 +1,4 @@
1
+ import { sliceRegion } from "../../raster/render.js";
1
2
  import { resolveFontReadiness } from "../../../../text/prepare.js";
2
3
  import { renderNodesToSVG } from "../export.js";
3
4
  import { withPDFTextLayout } from "../../pdf/prepare.js";
@@ -10,8 +11,9 @@ import { bakeAdjustedImages, hasAdjustedImagePaints } from "../../raster/adjuste
10
11
  * the pattern embeds the adjusted pixels.
11
12
  */
12
13
  async function renderNodesToLaidOutSVG(graph, pageId, nodeIds, options = {}, canvasKit, renderer) {
13
- await resolveFontReadiness(graph, nodeIds);
14
- const baked = hasAdjustedImagePaints(graph, nodeIds) ? await bakeAdjustedImages(graph, nodeIds, canvasKit, renderer) : graph;
14
+ const prepareIds = sliceRegion(graph, nodeIds) ? graph.getNode(pageId)?.childIds ?? [] : nodeIds;
15
+ await resolveFontReadiness(graph, prepareIds);
16
+ const baked = hasAdjustedImagePaints(graph, prepareIds) ? await bakeAdjustedImages(graph, prepareIds, canvasKit, renderer) : graph;
15
17
  return withPDFTextLayout(async (textLayout) => renderNodesToSVG(baked, pageId, nodeIds, {
16
18
  textLayout,
17
19
  ...options
@@ -1 +1 @@
1
- {"version":3,"file":"layout.js","names":[],"sources":["../../../../../src/io/formats/svg/text/layout.ts"],"sourcesContent":["import type { CanvasKit } from 'canvaskit-wasm'\n\nimport type { SceneGraph } from '@pairdraw/scene-graph'\n\nimport type { SkiaRenderer } from '#core/canvas/renderer'\nimport { withPDFTextLayout } from '#core/io/formats/pdf/prepare'\nimport { bakeAdjustedImages, hasAdjustedImagePaints } from '#core/io/formats/raster/adjusted-images'\nimport { renderNodesToSVG, type SVGExportOptions } from '#core/io/formats/svg/export'\nimport { resolveFontReadiness } from '#core/text/prepare'\n\n/**\n * Layers as SVG with their text set as the canvas sets it: the fonts it draws with loaded, each\n * line on the baseline the canvas gives it, and wrapped paragraphs kept wrapped, as PDF export\n * sets them. An image paint with adjustments is baked to the PNG the raster pipeline draws, so\n * the pattern embeds the adjusted pixels.\n */\nexport async function renderNodesToLaidOutSVG(\n graph: SceneGraph,\n pageId: string,\n nodeIds: string[],\n options: SVGExportOptions = {},\n canvasKit?: CanvasKit,\n renderer?: SkiaRenderer\n): Promise<string | null> {\n await resolveFontReadiness(graph, nodeIds)\n const baked = hasAdjustedImagePaints(graph, nodeIds)\n ? await bakeAdjustedImages(graph, nodeIds, canvasKit, renderer)\n : graph\n return withPDFTextLayout(async (textLayout) =>\n renderNodesToSVG(baked, pageId, nodeIds, { textLayout, ...options })\n )\n}\n"],"mappings":";;;;;;;;;;;AAgBA,eAAsB,wBACpB,OACA,QACA,SACA,UAA4B,CAAC,GAC7B,WACA,UACwB;CACxB,MAAM,qBAAqB,OAAO,OAAO;CACzC,MAAM,QAAQ,uBAAuB,OAAO,OAAO,IAC/C,MAAM,mBAAmB,OAAO,SAAS,WAAW,QAAQ,IAC5D;CACJ,OAAO,kBAAkB,OAAO,eAC9B,iBAAiB,OAAO,QAAQ,SAAS;EAAE;EAAY,GAAG;CAAQ,CAAC,CACrE;AACF"}
1
+ {"version":3,"file":"layout.js","names":[],"sources":["../../../../../src/io/formats/svg/text/layout.ts"],"sourcesContent":["import type { CanvasKit } from 'canvaskit-wasm'\n\nimport type { SceneGraph } from '@pairdraw/scene-graph'\n\nimport type { SkiaRenderer } from '#core/canvas/renderer'\nimport { withPDFTextLayout } from '#core/io/formats/pdf/prepare'\nimport { sliceRegion } from '#core/io/formats/raster'\nimport { bakeAdjustedImages, hasAdjustedImagePaints } from '#core/io/formats/raster/adjusted-images'\nimport { renderNodesToSVG, type SVGExportOptions } from '#core/io/formats/svg/export'\nimport { resolveFontReadiness } from '#core/text/prepare'\n\n/**\n * Layers as SVG with their text set as the canvas sets it: the fonts it draws with loaded, each\n * line on the baseline the canvas gives it, and wrapped paragraphs kept wrapped, as PDF export\n * sets them. An image paint with adjustments is baked to the PNG the raster pipeline draws, so\n * the pattern embeds the adjusted pixels.\n */\nexport async function renderNodesToLaidOutSVG(\n graph: SceneGraph,\n pageId: string,\n nodeIds: string[],\n options: SVGExportOptions = {},\n canvasKit?: CanvasKit,\n renderer?: SkiaRenderer\n): Promise<string | null> {\n const prepareIds = sliceRegion(graph, nodeIds) ? (graph.getNode(pageId)?.childIds ?? []) : nodeIds\n await resolveFontReadiness(graph, prepareIds)\n const baked = hasAdjustedImagePaints(graph, prepareIds)\n ? await bakeAdjustedImages(graph, prepareIds, canvasKit, renderer)\n : graph\n return withPDFTextLayout(async (textLayout) =>\n renderNodesToSVG(baked, pageId, nodeIds, { textLayout, ...options })\n )\n}\n"],"mappings":";;;;;;;;;;;;AAiBA,eAAsB,wBACpB,OACA,QACA,SACA,UAA4B,CAAC,GAC7B,WACA,UACwB;CACxB,MAAM,aAAa,YAAY,OAAO,OAAO,IAAK,MAAM,QAAQ,MAAM,CAAC,EAAE,YAAY,CAAC,IAAK;CAC3F,MAAM,qBAAqB,OAAO,UAAU;CAC5C,MAAM,QAAQ,uBAAuB,OAAO,UAAU,IAClD,MAAM,mBAAmB,OAAO,YAAY,WAAW,QAAQ,IAC/D;CACJ,OAAO,kBAAkB,OAAO,eAC9B,iBAAiB,OAAO,QAAQ,SAAS;EAAE;EAAY,GAAG;CAAQ,CAAC,CACrE;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"record.d.ts","names":[],"sources":["../../../../src/io/formats/video/record.ts"],"mappings":";;;;;;;;;;;KAuBY,eACV,iBACA,eACA,QAAQ,eACL,QAAQ;UAEI;EACf;EACA;EACA;EACA,SAAS;EACT,cAAc,cAAc;;EAE5B;;UAGe;EACf,OAAO;EACP;;;;;;;;;iBAkJoB,gBACpB,OAAO,YACP,UAAU,UACV,QAAQ,aACR,MAAM,WACN,SAAS,gBACR,QAAQ"}
1
+ {"version":3,"file":"record.d.ts","names":[],"sources":["../../../../src/io/formats/video/record.ts"],"mappings":";;;;;;;;;;;KAuBY,eACV,iBACA,eACA,QAAQ,eACL,QAAQ;UAEI;EACf;EACA;EACA;EACA,SAAS;EACT,cAAc,cAAc;;EAE5B;;UAGe;EACf,OAAO;EACP;;;;;;;;;iBAqKoB,gBACpB,OAAO,YACP,UAAU,UACV,QAAQ,aACR,MAAM,WACN,SAAS,gBACR,QAAQ"}
@@ -38,6 +38,17 @@ function createScreens(graph, timeline, render, width, height) {
38
38
  const startId = firstSegment?.kind === "hold" ? firstSegment.session.frameId : null;
39
39
  const background = getPageColor(startId ? pageOf(graph, startId) : void 0);
40
40
  const cache = /* @__PURE__ */ new Map();
41
+ const graphTokens = /* @__PURE__ */ new WeakMap();
42
+ let nextGraphToken = 1;
43
+ function graphToken(source) {
44
+ if (!source) return "0";
45
+ let token = graphTokens.get(source);
46
+ if (token === void 0) {
47
+ token = nextGraphToken++;
48
+ graphTokens.set(source, token);
49
+ }
50
+ return String(token);
51
+ }
41
52
  async function drawFrame(target, frameId, scale, at, source = graph) {
42
53
  const image = await render(frameId, scale, source === graph ? void 0 : source);
43
54
  const node = source.getNode(frameId);
@@ -66,7 +77,7 @@ function createScreens(graph, timeline, render, width, height) {
66
77
  if (session.overlays.length > 0) dim(target, OVERLAY_SCRIM);
67
78
  for (const overlayId of session.overlays) {
68
79
  const overlay = graph.getAbsoluteBounds(overlayId);
69
- await drawFrame(target, overlayId, scale, overlayOrigin(fitted, overlay.width * scale, overlay.height * scale, timeline.overlayPositions[overlayId] ?? "CENTER"));
80
+ await drawFrame(target, overlayId, scale, overlayOrigin(fitted, overlay.width * scale, overlay.height * scale, timeline.overlayPositions[overlayId] ?? "CENTER"), base);
70
81
  }
71
82
  return target;
72
83
  }
@@ -75,30 +86,34 @@ function createScreens(graph, timeline, render, width, height) {
75
86
  async function animated(segment, progress) {
76
87
  if (animating?.segment !== segment) {
77
88
  const from = {
78
- graph,
89
+ graph: segment.fromGraph ?? graph,
79
90
  rootId: shownFrame(segment.from)
80
91
  };
81
92
  const to = {
82
- graph,
93
+ graph: segment.toGraph ?? graph,
83
94
  rootId: segment.to.frameId
84
95
  };
85
96
  animating = {
86
97
  segment,
87
- animation: createSmartAnimation(from, to, segment.easing)
98
+ animation: createSmartAnimation(from, to, segment.easing, {
99
+ curve: segment.easingCurve,
100
+ spring: segment.easingSpring,
101
+ duration: segment.fadeMs / 1e3
102
+ })
88
103
  };
89
104
  }
90
105
  animating.animation.seek(progress);
91
106
  return compose(segment.to, animating.animation.graph);
92
107
  }
93
- async function screen(session) {
94
- const key = sessionDrawKey(session);
108
+ async function screen(session, source) {
109
+ const key = `${sessionDrawKey(session)}#${graphToken(source)}`;
95
110
  const cached = cache.get(key);
96
111
  if (cached) {
97
112
  cache.delete(key);
98
113
  cache.set(key, cached);
99
114
  return cached;
100
115
  }
101
- const drawn = await compose(session);
116
+ const drawn = await compose(session, source);
102
117
  cache.set(key, drawn);
103
118
  for (const old of cache.keys()) {
104
119
  if (cache.size <= CACHED_SCREENS) break;
@@ -128,9 +143,9 @@ async function recordPrototype(graph, timeline, render, sink, options) {
128
143
  const last = index === frameCount - 1 && !timeline.loops;
129
144
  const shown = frameAt(timeline, last ? timeline.durationMs : index * frameMs);
130
145
  let image;
131
- if ("session" in shown) image = await screen(shown.session);
146
+ if ("session" in shown) image = await screen(shown.session, shown.graph);
132
147
  else if ("smart" in shown) image = await animated(shown.smart, shown.progress);
133
- else image = crossfade(await screen(shown.from), await screen(shown.to), shown.mix);
148
+ else image = crossfade(await screen(shown.from, shown.fromGraph), await screen(shown.to, shown.toGraph), shown.mix);
134
149
  await sink.add(image, index * frameMs, frameMs);
135
150
  if (options.maxBytes !== void 0 && sink.byteLength > options.maxBytes) throw new Error(`The video passed ${Math.round(options.maxBytes / 1024 / 1024)} MB; lower the size or frame rate`);
136
151
  options.onProgress?.(index + 1, frameCount);
@@ -1 +1 @@
1
- {"version":3,"file":"record.js","names":[],"sources":["../../../../src/io/formats/video/record.ts"],"sourcesContent":["import type { PrototypeOverlayPositionType, SceneGraph } from '@pairdraw/scene-graph'\nimport type { Rect, Vector } from '@pairdraw/scene-graph/primitives'\n\nimport { getPageColor } from '#core/figma-api/page-backgrounds'\nimport { computeContentBounds, type RGBAImage } from '#core/io/formats/raster'\nimport {\n createSmartAnimation,\n frameAt,\n sessionDrawKey,\n shownFrame,\n type PlaySession,\n type SmartAnimation,\n type Timeline,\n type TimelineSmartSegment\n} from '#core/prototype'\n\nimport { crossfade, dim, drawOver, filledImage } from './composite'\nimport type { VideoSink } from './sink'\n\n/**\n * Draws one top-level frame at `scale` as pixels, or null when it cannot be drawn: from the\n * document, or from `graph`, a Smart animate's copy of the frame posed at one moment.\n */\nexport type RenderFrame = (\n frameId: string,\n scale: number,\n graph?: SceneGraph\n) => Promise<RGBAImage | null>\n\nexport interface RecordOptions {\n width: number\n height: number\n fps: number\n signal?: AbortSignal\n onProgress?: (done: number, total: number) => void\n /** The most bytes the file may grow to before recording stops. */\n maxBytes?: number\n}\n\nexport interface RecordResult {\n bytes: Uint8Array\n frameCount: number\n}\n\n/** How dark the screen under an open overlay is drawn, as the player's scrim. */\nconst OVERLAY_SCRIM = 0.4\n/** Screens kept drawn at once: the two of a crossfade and the one after it. */\nconst CACHED_SCREENS = 3\n/** Frames recorded between yields to the event loop, so the app keeps drawing. */\nconst FRAMES_PER_YIELD = 4\n\n/** Where an overlay starts along one axis of the screen: its start, its end, or centred. */\nfunction alignOnAxis(start: number, size: number, overlay: number, edge: string): number {\n if (edge === 'TOP' || edge === 'LEFT') return start\n if (edge === 'BOTTOM' || edge === 'RIGHT') return start + size - overlay\n return start + (size - overlay) / 2\n}\n\n/** Where an overlay of `width`×`height` sits on the screen `base`, as Figma positions overlays. */\nfunction overlayOrigin(\n base: Rect,\n width: number,\n height: number,\n position: PrototypeOverlayPositionType\n): Vector {\n const [vertical, horizontal] = position === 'CENTER' ? ['CENTER', 'CENTER'] : position.split('_')\n return {\n x: alignOnAxis(base.x, base.width, width, horizontal),\n y: alignOnAxis(base.y, base.height, height, vertical)\n }\n}\n\nfunction pageOf(graph: SceneGraph, frameId: string) {\n const parentId = graph.getNode(frameId)?.parentId\n return parentId ? graph.getNode(parentId) : undefined\n}\n\n/**\n * Draws the screens a timeline shows, each composited once onto a `width`×`height` canvas the\n * color of the page, the base frame fitted and centred as the player fits it, overlays over a scrim.\n */\nfunction createScreens(\n graph: SceneGraph,\n timeline: Timeline,\n render: RenderFrame,\n width: number,\n height: number\n) {\n const firstSegment = timeline.segments.at(0)\n const startId = firstSegment?.kind === 'hold' ? firstSegment.session.frameId : null\n const background = getPageColor(startId ? pageOf(graph, startId) : undefined)\n const cache = new Map<string, RGBAImage>()\n\n async function drawFrame(\n target: RGBAImage,\n frameId: string,\n scale: number,\n at: Vector,\n source = graph\n ) {\n const image = await render(frameId, scale, source === graph ? undefined : source)\n const node = source.getNode(frameId)\n if (!image || !node) throw new Error(`'${node?.name ?? frameId}' could not be drawn`)\n const box = source.getAbsoluteBounds(frameId)\n // A shadow or a layer past the frame's edge widens what is drawn; the frame stays in place.\n const content = computeContentBounds(source, [frameId]) ?? {\n minX: box.x,\n minY: box.y,\n maxX: box.x + box.width,\n maxY: box.y + box.height\n }\n drawOver(\n target,\n image,\n Math.round(at.x + (content.minX - box.x) * scale),\n Math.round(at.y + (content.minY - box.y) * scale)\n )\n }\n\n /** The screen `session` shows, its base frame drawn from `base` when given. */\n async function compose(session: PlaySession, base?: SceneGraph): Promise<RGBAImage> {\n const target = filledImage(width, height, background)\n const box = graph.getAbsoluteBounds(session.frameId)\n const scale = Math.min(width / box.width, height / box.height)\n const fitted: Rect = {\n x: (width - box.width * scale) / 2,\n y: (height - box.height * scale) / 2,\n width: box.width * scale,\n height: box.height * scale\n }\n await drawFrame(target, session.frameId, scale, fitted, base)\n if (session.overlays.length > 0) dim(target, OVERLAY_SCRIM)\n for (const overlayId of session.overlays) {\n const overlay = graph.getAbsoluteBounds(overlayId)\n const origin = overlayOrigin(\n fitted,\n overlay.width * scale,\n overlay.height * scale,\n timeline.overlayPositions[overlayId] ?? 'CENTER'\n )\n await drawFrame(target, overlayId, scale, origin)\n }\n return target\n }\n\n // The Smart animate being recorded, made once and posed for each of its frames.\n let animating: { segment: TimelineSmartSegment; animation: SmartAnimation } | null = null\n\n /** A Smart animate `progress` of the way through its time, drawn from its posed copy. */\n async function animated(segment: TimelineSmartSegment, progress: number): Promise<RGBAImage> {\n if (animating?.segment !== segment) {\n const from = { graph, rootId: shownFrame(segment.from) }\n const to = { graph, rootId: segment.to.frameId }\n animating = { segment, animation: createSmartAnimation(from, to, segment.easing) }\n }\n animating.animation.seek(progress)\n return compose(segment.to, animating.animation.graph)\n }\n\n async function screen(session: PlaySession): Promise<RGBAImage> {\n const key = sessionDrawKey(session)\n const cached = cache.get(key)\n if (cached) {\n // Most recently used last, so the oldest screen is the one dropped.\n cache.delete(key)\n cache.set(key, cached)\n return cached\n }\n const drawn = await compose(session)\n cache.set(key, drawn)\n for (const old of cache.keys()) {\n if (cache.size <= CACHED_SCREENS) break\n cache.delete(old)\n }\n return drawn\n }\n\n return { screen, animated }\n}\n\n/**\n * Records a planned timeline frame by frame at `fps` into `sink` and returns the file. Each screen\n * is drawn once and reused while it holds, so a held screen reaches the sink as the same image; a\n * crossfade blends its two screens per frame, and a Smart animate draws its animation posed at\n * each frame, as the player poses it. Cancelling through `signal` stops before the next\n * frame, and passing `maxBytes` stops with an error naming the limit.\n */\nexport async function recordPrototype(\n graph: SceneGraph,\n timeline: Timeline,\n render: RenderFrame,\n sink: VideoSink,\n options: RecordOptions\n): Promise<RecordResult> {\n const { screen, animated } = createScreens(graph, timeline, render, options.width, options.height)\n const frameMs = 1000 / options.fps\n const frameCount = Math.max(1, Math.round(timeline.durationMs / frameMs))\n try {\n for (let index = 0; index < frameCount; index++) {\n options.signal?.throwIfAborted()\n // A clip that does not loop ends on its last screen, even one the flow leaves no time.\n const last = index === frameCount - 1 && !timeline.loops\n const shown = frameAt(timeline, last ? timeline.durationMs : index * frameMs)\n let image: RGBAImage\n if ('session' in shown) image = await screen(shown.session)\n else if ('smart' in shown) image = await animated(shown.smart, shown.progress)\n else image = crossfade(await screen(shown.from), await screen(shown.to), shown.mix)\n await sink.add(image, index * frameMs, frameMs)\n if (options.maxBytes !== undefined && sink.byteLength > options.maxBytes) {\n throw new Error(\n `The video passed ${Math.round(options.maxBytes / 1024 / 1024)} MB; lower the size or frame rate`\n )\n }\n options.onProgress?.(index + 1, frameCount)\n if ((index + 1) % FRAMES_PER_YIELD === 0) {\n await new Promise<void>((resolve) => {\n setTimeout(resolve, 0)\n })\n }\n }\n options.signal?.throwIfAborted()\n return { bytes: await sink.finish(), frameCount }\n } catch (error) {\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AAS,OAAO;GAC9C,IAAI,QAAQ,aAAa,KAAA,KAAa,KAAK,aAAa,QAAQ,UAC9D,MAAM,IAAI,MACR,oBAAoB,KAAK,MAAM,QAAQ,WAAW,OAAO,IAAI,EAAE,kCACjE;GAEF,QAAQ,aAAa,QAAQ,GAAG,UAAU;GAC1C,KAAK,QAAQ,KAAK,qBAAqB,GACrC,MAAM,IAAI,SAAe,YAAY;IACnC,WAAW,SAAS,CAAC;GACvB,CAAC;EAEL;EACA,QAAQ,QAAQ,eAAe;EAC/B,OAAO;GAAE,OAAO,MAAM,KAAK,OAAO;GAAG;EAAW;CAClD,SAAS,OAAO;EACd,MAAM,KAAK,OAAO;EAClB,MAAM;CACR;AACF"}
1
+ {"version":3,"file":"record.js","names":[],"sources":["../../../../src/io/formats/video/record.ts"],"sourcesContent":["import type { PrototypeOverlayPositionType, SceneGraph } from '@pairdraw/scene-graph'\nimport type { Rect, Vector } from '@pairdraw/scene-graph/primitives'\n\nimport { getPageColor } from '#core/figma-api/page-backgrounds'\nimport { computeContentBounds, type RGBAImage } from '#core/io/formats/raster'\nimport {\n createSmartAnimation,\n frameAt,\n sessionDrawKey,\n shownFrame,\n type PlaySession,\n type SmartAnimation,\n type Timeline,\n type TimelineSmartSegment\n} from '#core/prototype'\n\nimport { crossfade, dim, drawOver, filledImage } from './composite'\nimport type { VideoSink } from './sink'\n\n/**\n * Draws one top-level frame at `scale` as pixels, or null when it cannot be drawn: from the\n * document, or from `graph`, a Smart animate's copy of the frame posed at one moment.\n */\nexport type RenderFrame = (\n frameId: string,\n scale: number,\n graph?: SceneGraph\n) => Promise<RGBAImage | null>\n\nexport interface RecordOptions {\n width: number\n height: number\n fps: number\n signal?: AbortSignal\n onProgress?: (done: number, total: number) => void\n /** The most bytes the file may grow to before recording stops. */\n maxBytes?: number\n}\n\nexport interface RecordResult {\n bytes: Uint8Array\n frameCount: number\n}\n\n/** How dark the screen under an open overlay is drawn, as the player's scrim. */\nconst OVERLAY_SCRIM = 0.4\n/** Screens kept drawn at once: the two of a crossfade and the one after it. */\nconst CACHED_SCREENS = 3\n/** Frames recorded between yields to the event loop, so the app keeps drawing. */\nconst FRAMES_PER_YIELD = 4\n\n/** Where an overlay starts along one axis of the screen: its start, its end, or centred. */\nfunction alignOnAxis(start: number, size: number, overlay: number, edge: string): number {\n if (edge === 'TOP' || edge === 'LEFT') return start\n if (edge === 'BOTTOM' || edge === 'RIGHT') return start + size - overlay\n return start + (size - overlay) / 2\n}\n\n/** Where an overlay of `width`×`height` sits on the screen `base`, as Figma positions overlays. */\nfunction overlayOrigin(\n base: Rect,\n width: number,\n height: number,\n position: PrototypeOverlayPositionType\n): Vector {\n const [vertical, horizontal] = position === 'CENTER' ? ['CENTER', 'CENTER'] : position.split('_')\n return {\n x: alignOnAxis(base.x, base.width, width, horizontal),\n y: alignOnAxis(base.y, base.height, height, vertical)\n }\n}\n\nfunction pageOf(graph: SceneGraph, frameId: string) {\n const parentId = graph.getNode(frameId)?.parentId\n return parentId ? graph.getNode(parentId) : undefined\n}\n\n/**\n * Draws the screens a timeline shows, each composited once onto a `width`×`height` canvas the\n * color of the page, the base frame fitted and centred as the player fits it, overlays over a scrim.\n */\nfunction createScreens(\n graph: SceneGraph,\n timeline: Timeline,\n render: RenderFrame,\n width: number,\n height: number\n) {\n const firstSegment = timeline.segments.at(0)\n const startId = firstSegment?.kind === 'hold' ? firstSegment.session.frameId : null\n const background = getPageColor(startId ? pageOf(graph, startId) : undefined)\n const cache = new Map<string, RGBAImage>()\n // A graph is one moment of play's variable state; screens showing another state are drawn again.\n const graphTokens = new WeakMap<SceneGraph, number>()\n let nextGraphToken = 1\n function graphToken(source: SceneGraph | undefined): string {\n if (!source) return '0'\n let token = graphTokens.get(source)\n if (token === undefined) {\n token = nextGraphToken++\n graphTokens.set(source, token)\n }\n return String(token)\n }\n\n async function drawFrame(\n target: RGBAImage,\n frameId: string,\n scale: number,\n at: Vector,\n source = graph\n ) {\n const image = await render(frameId, scale, source === graph ? undefined : source)\n const node = source.getNode(frameId)\n if (!image || !node) throw new Error(`'${node?.name ?? frameId}' could not be drawn`)\n const box = source.getAbsoluteBounds(frameId)\n // A shadow or a layer past the frame's edge widens what is drawn; the frame stays in place.\n const content = computeContentBounds(source, [frameId]) ?? {\n minX: box.x,\n minY: box.y,\n maxX: box.x + box.width,\n maxY: box.y + box.height\n }\n drawOver(\n target,\n image,\n Math.round(at.x + (content.minX - box.x) * scale),\n Math.round(at.y + (content.minY - box.y) * scale)\n )\n }\n\n /** The screen `session` shows, its base frame drawn from `base` when given. */\n async function compose(session: PlaySession, base?: SceneGraph): Promise<RGBAImage> {\n const target = filledImage(width, height, background)\n const box = graph.getAbsoluteBounds(session.frameId)\n const scale = Math.min(width / box.width, height / box.height)\n const fitted: Rect = {\n x: (width - box.width * scale) / 2,\n y: (height - box.height * scale) / 2,\n width: box.width * scale,\n height: box.height * scale\n }\n await drawFrame(target, session.frameId, scale, fitted, base)\n if (session.overlays.length > 0) dim(target, OVERLAY_SCRIM)\n for (const overlayId of session.overlays) {\n const overlay = graph.getAbsoluteBounds(overlayId)\n const origin = overlayOrigin(\n fitted,\n overlay.width * scale,\n overlay.height * scale,\n timeline.overlayPositions[overlayId] ?? 'CENTER'\n )\n await drawFrame(target, overlayId, scale, origin, base)\n }\n return target\n }\n\n // The Smart animate being recorded, made once and posed for each of its frames.\n let animating: { segment: TimelineSmartSegment; animation: SmartAnimation } | null = null\n\n /** A Smart animate `progress` of the way through its time, drawn from its posed copy. */\n async function animated(segment: TimelineSmartSegment, progress: number): Promise<RGBAImage> {\n if (animating?.segment !== segment) {\n const from = { graph: segment.fromGraph ?? graph, rootId: shownFrame(segment.from) }\n const to = { graph: segment.toGraph ?? graph, rootId: segment.to.frameId }\n animating = {\n segment,\n animation: createSmartAnimation(from, to, segment.easing, {\n curve: segment.easingCurve,\n spring: segment.easingSpring,\n duration: segment.fadeMs / 1000\n })\n }\n }\n animating.animation.seek(progress)\n return compose(segment.to, animating.animation.graph)\n }\n\n async function screen(session: PlaySession, source?: SceneGraph): Promise<RGBAImage> {\n const key = `${sessionDrawKey(session)}#${graphToken(source)}`\n const cached = cache.get(key)\n if (cached) {\n // Most recently used last, so the oldest screen is the one dropped.\n cache.delete(key)\n cache.set(key, cached)\n return cached\n }\n const drawn = await compose(session, source)\n cache.set(key, drawn)\n for (const old of cache.keys()) {\n if (cache.size <= CACHED_SCREENS) break\n cache.delete(old)\n }\n return drawn\n }\n\n return { screen, animated }\n}\n\n/**\n * Records a planned timeline frame by frame at `fps` into `sink` and returns the file. Each screen\n * is drawn once and reused while it holds, so a held screen reaches the sink as the same image; a\n * crossfade blends its two screens per frame, and a Smart animate draws its animation posed at\n * each frame, as the player poses it. Cancelling through `signal` stops before the next\n * frame, and passing `maxBytes` stops with an error naming the limit.\n */\nexport async function recordPrototype(\n graph: SceneGraph,\n timeline: Timeline,\n render: RenderFrame,\n sink: VideoSink,\n options: RecordOptions\n): Promise<RecordResult> {\n const { screen, animated } = createScreens(graph, timeline, render, options.width, options.height)\n const frameMs = 1000 / options.fps\n const frameCount = Math.max(1, Math.round(timeline.durationMs / frameMs))\n try {\n for (let index = 0; index < frameCount; index++) {\n options.signal?.throwIfAborted()\n // A clip that does not loop ends on its last screen, even one the flow leaves no time.\n const last = index === frameCount - 1 && !timeline.loops\n const shown = frameAt(timeline, last ? timeline.durationMs : index * frameMs)\n let image: RGBAImage\n if ('session' in shown) image = await screen(shown.session, shown.graph)\n else if ('smart' in shown) image = await animated(shown.smart, shown.progress)\n else\n image = crossfade(\n await screen(shown.from, shown.fromGraph),\n await screen(shown.to, shown.toGraph),\n shown.mix\n )\n await sink.add(image, index * frameMs, frameMs)\n if (options.maxBytes !== undefined && sink.byteLength > options.maxBytes) {\n throw new Error(\n `The video passed ${Math.round(options.maxBytes / 1024 / 1024)} MB; lower the size or frame rate`\n )\n }\n options.onProgress?.(index + 1, frameCount)\n if ((index + 1) % FRAMES_PER_YIELD === 0) {\n await new Promise<void>((resolve) => {\n setTimeout(resolve, 0)\n })\n }\n }\n options.signal?.throwIfAborted()\n return { bytes: await sink.finish(), frameCount }\n } catch (error) {\n await sink.cancel()\n throw error\n }\n}\n"],"mappings":";;;;;;;;AA6CA,MAAM,gBAAgB;;AAEtB,MAAM,iBAAiB;;AAEvB,MAAM,mBAAmB;;AAGzB,SAAS,YAAY,OAAe,MAAc,SAAiB,MAAsB;CACvF,IAAI,SAAS,SAAS,SAAS,QAAQ,OAAO;CAC9C,IAAI,SAAS,YAAY,SAAS,SAAS,OAAO,QAAQ,OAAO;CACjE,OAAO,SAAS,OAAO,WAAW;AACpC;;AAGA,SAAS,cACP,MACA,OACA,QACA,UACQ;CACR,MAAM,CAAC,UAAU,cAAc,aAAa,WAAW,CAAC,UAAU,QAAQ,IAAI,SAAS,MAAM,GAAG;CAChG,OAAO;EACL,GAAG,YAAY,KAAK,GAAG,KAAK,OAAO,OAAO,UAAU;EACpD,GAAG,YAAY,KAAK,GAAG,KAAK,QAAQ,QAAQ,QAAQ;CACtD;AACF;AAEA,SAAS,OAAO,OAAmB,SAAiB;CAClD,MAAM,WAAW,MAAM,QAAQ,OAAO,CAAC,EAAE;CACzC,OAAO,WAAW,MAAM,QAAQ,QAAQ,IAAI,KAAA;AAC9C;;;;;AAMA,SAAS,cACP,OACA,UACA,QACA,OACA,QACA;CACA,MAAM,eAAe,SAAS,SAAS,GAAG,CAAC;CAC3C,MAAM,UAAU,cAAc,SAAS,SAAS,aAAa,QAAQ,UAAU;CAC/E,MAAM,aAAa,aAAa,UAAU,OAAO,OAAO,OAAO,IAAI,KAAA,CAAS;CAC5E,MAAM,wBAAQ,IAAI,IAAuB;CAEzC,MAAM,8BAAc,IAAI,QAA4B;CACpD,IAAI,iBAAiB;CACrB,SAAS,WAAW,QAAwC;EAC1D,IAAI,CAAC,QAAQ,OAAO;EACpB,IAAI,QAAQ,YAAY,IAAI,MAAM;EAClC,IAAI,UAAU,KAAA,GAAW;GACvB,QAAQ;GACR,YAAY,IAAI,QAAQ,KAAK;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;cAkCnB,8BAAkB,wBAAA,wBAAA,2BAAA,4BAAA,wBAAA,wBAAA,yBAAA,wBAAA,wBAAA,yBAAA,wBAAA,iCAAA;KAgBnB,4BAA4B"}
1
+ {"version":3,"file":"formats.d.ts","names":[],"sources":["../../src/io/formats.ts"],"mappings":";;;;;cA6Ka,qBAAqB,SAAS,OAAO;cAKrC,WAAW;cA8DX,cAAc;cA2Dd,eAAe;cA8Cf,WAAS;cACT,WAAS;cACT,YAAU;cAEV,WAAW;cAkFX,WAAW;cA6CX,YAAY;cA2BZ,WAAW;cAqDX,YAAY;cA+BZ,mBAAmB;cAkCnB,8BAAkB,wBAAA,wBAAA,2BAAA,4BAAA,wBAAA,wBAAA,yBAAA,wBAAA,wBAAA,yBAAA,wBAAA,iCAAA;KAgBnB,4BAA4B"}
@@ -1,5 +1,5 @@
1
1
  import { extractExportGraph, findPageId } from "./subgraph.js";
2
- import { renderNodesToImage } from "./formats/raster/render.js";
2
+ import { renderNodesToImage, sliceRegion } from "./formats/raster/render.js";
3
3
  import { headlessRenderNodes } from "./formats/raster/headless.js";
4
4
  import { layoutAuthoredNodes } from "../layout.js";
5
5
  import { parseFigFile } from "./formats/fig/read.js";
@@ -29,13 +29,17 @@ function ensureSingleNode(target) {
29
29
  if (target.scope === "selection" && target.nodeIds.length === 1) return target.nodeIds[0];
30
30
  return null;
31
31
  }
32
+ /** A page's top-level layers that draw: a slice names an export region, not page content. */
33
+ function drawingPageChildren(graph, page) {
34
+ return page.childIds.filter((id) => graph.getNode(id)?.type !== "SLICE");
35
+ }
32
36
  function resolveExportNodes(request) {
33
37
  switch (request.target.scope) {
34
38
  case "document": {
35
39
  const page = request.graph.getPages()[0];
36
40
  return {
37
41
  pageId: page.id,
38
- nodeIds: page.childIds
42
+ nodeIds: drawingPageChildren(request.graph, page)
39
43
  };
40
44
  }
41
45
  case "page": {
@@ -43,7 +47,7 @@ function resolveExportNodes(request) {
43
47
  if (!page) return null;
44
48
  return {
45
49
  pageId: page.id,
46
- nodeIds: page.childIds
50
+ nodeIds: drawingPageChildren(request.graph, page)
47
51
  };
48
52
  }
49
53
  case "selection": {
@@ -70,19 +74,14 @@ function resolveExportNodes(request) {
70
74
  async function renderRaster(request, options, context) {
71
75
  const target = resolveExportNodes(request);
72
76
  if (!target) return null;
73
- const scale = options.scale ?? 1;
74
- if (context?.canvasKit && context.renderer) return renderNodesToImage(context.canvasKit, context.renderer, request.graph, target.pageId, target.nodeIds, {
75
- scale,
77
+ const renderOptions = {
78
+ scale: options.scale ?? 1,
76
79
  format: options.format,
77
80
  quality: options.quality,
78
81
  trimTransparent: request.target.scope === "page" || request.target.scope === "document"
79
- });
80
- return headlessRenderNodes(request.graph, target.pageId, target.nodeIds, {
81
- scale,
82
- format: options.format,
83
- quality: options.quality,
84
- trimTransparent: request.target.scope === "page" || request.target.scope === "document"
85
- });
82
+ };
83
+ if (context?.canvasKit && context.renderer) return renderNodesToImage(context.canvasKit, context.renderer, request.graph, target.pageId, target.nodeIds, renderOptions);
84
+ return headlessRenderNodes(request.graph, target.pageId, target.nodeIds, renderOptions, context?.canvasKit);
86
85
  }
87
86
  function rasterFormat(format) {
88
87
  const extension = format.toLowerCase();
@@ -255,14 +254,20 @@ const mermaidFormat = {
255
254
  async function writeDrawIO(graph, target) {
256
255
  const { writeDrawIOFile } = await import("@pairdraw/drawio");
257
256
  const { sceneGraphToDrawIO } = await import("./formats/drawio/index.js");
258
- const { drawioDroppedWarnings } = await import("./formats/drawio/warnings.js");
259
- return {
257
+ const { drawioWriteWarnings, drawioWriteWarningText } = await import("./formats/drawio/warnings.js");
258
+ const warningDetails = drawioWriteWarnings(graph);
259
+ const written = {
260
260
  format: "drawio",
261
261
  mimeType: "application/vnd.jgraph.mxfile",
262
262
  extension: "drawio",
263
263
  data: writeDrawIOFile(sceneGraphToDrawIO(graph, target)),
264
- encoding: "utf8",
265
- warnings: drawioDroppedWarnings(graph)
264
+ encoding: "utf8"
265
+ };
266
+ if (warningDetails.length === 0) return written;
267
+ return {
268
+ ...written,
269
+ warnings: warningDetails.map(drawioWriteWarningText),
270
+ warningDetails
266
271
  };
267
272
  }
268
273
  const pngFormat = rasterFormat("PNG");
@@ -327,6 +332,14 @@ async function pdfPageSpecs(request, options) {
327
332
  }
328
333
  const target = resolveExportNodes(request);
329
334
  if (!target) throw new Error("Nothing to export");
335
+ if (sliceRegion(request.graph, target.nodeIds)) {
336
+ const { planPDFPages } = await import("./formats/pdf/plan.js");
337
+ return planPDFPages(request.graph, {
338
+ mode: "single",
339
+ ids: target.nodeIds,
340
+ currentPageId: target.pageId
341
+ });
342
+ }
330
343
  return [target];
331
344
  }
332
345
  const pdfFormat = {