@pairdraw/core 0.19.2 → 0.20.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 (847) hide show
  1. package/dist/ai/providers.d.ts +6 -0
  2. package/dist/ai/providers.d.ts.map +1 -1
  3. package/dist/ai/providers.js.map +1 -1
  4. package/dist/cache/resource.d.ts +8 -1
  5. package/dist/cache/resource.d.ts.map +1 -1
  6. package/dist/cache/resource.js +18 -0
  7. package/dist/cache/resource.js.map +1 -1
  8. package/dist/canvas/effects.d.ts +6 -4
  9. package/dist/canvas/effects.d.ts.map +1 -1
  10. package/dist/canvas/effects.js +37 -34
  11. package/dist/canvas/effects.js.map +1 -1
  12. package/dist/canvas/fills.d.ts.map +1 -1
  13. package/dist/canvas/fills.js +12 -8
  14. package/dist/canvas/fills.js.map +1 -1
  15. package/dist/canvas/images/adjustments.d.ts +18 -0
  16. package/dist/canvas/images/adjustments.d.ts.map +1 -0
  17. package/dist/canvas/images/adjustments.js +184 -0
  18. package/dist/canvas/images/adjustments.js.map +1 -0
  19. package/dist/canvas/images/sampling.d.ts +13 -0
  20. package/dist/canvas/images/sampling.d.ts.map +1 -0
  21. package/dist/canvas/images/sampling.js +49 -0
  22. package/dist/canvas/images/sampling.js.map +1 -0
  23. package/dist/canvas/index.d.ts +2 -2
  24. package/dist/canvas/masks.d.ts +1 -1
  25. package/dist/canvas/masks.d.ts.map +1 -1
  26. package/dist/canvas/masks.js.map +1 -1
  27. package/dist/canvas/noise/render.d.ts +15 -0
  28. package/dist/canvas/noise/render.d.ts.map +1 -0
  29. package/dist/canvas/noise/render.js +56 -0
  30. package/dist/canvas/noise/render.js.map +1 -0
  31. package/dist/canvas/noise/shader.d.ts +43 -0
  32. package/dist/canvas/noise/shader.d.ts.map +1 -0
  33. package/dist/canvas/noise/shader.js +161 -0
  34. package/dist/canvas/noise/shader.js.map +1 -0
  35. package/dist/canvas/noise/table.d.ts +13 -0
  36. package/dist/canvas/noise/table.d.ts.map +1 -0
  37. package/dist/canvas/noise/table.js +408 -0
  38. package/dist/canvas/noise/table.js.map +1 -0
  39. package/dist/canvas/noise/tile.d.ts +22 -0
  40. package/dist/canvas/noise/tile.d.ts.map +1 -0
  41. package/dist/canvas/noise/tile.js +73 -0
  42. package/dist/canvas/noise/tile.js.map +1 -0
  43. package/dist/canvas/outline-stroke.js +1 -1
  44. package/dist/canvas/overlays/auto-layout-hover.d.ts.map +1 -1
  45. package/dist/canvas/overlays/auto-layout-hover.js +31 -71
  46. package/dist/canvas/overlays/auto-layout-hover.js.map +1 -1
  47. package/dist/canvas/renderer/chunks/index.d.ts +1 -1
  48. package/dist/canvas/renderer/lifecycle.d.ts.map +1 -1
  49. package/dist/canvas/renderer/lifecycle.js +6 -0
  50. package/dist/canvas/renderer/lifecycle.js.map +1 -1
  51. package/dist/canvas/renderer/pipeline.d.ts.map +1 -1
  52. package/dist/canvas/renderer/pipeline.js +13 -1
  53. package/dist/canvas/renderer/pipeline.js.map +1 -1
  54. package/dist/canvas/renderer/play-scenes.d.ts +13 -0
  55. package/dist/canvas/renderer/play-scenes.d.ts.map +1 -0
  56. package/dist/canvas/renderer/play-scenes.js +40 -0
  57. package/dist/canvas/renderer/play-scenes.js.map +1 -0
  58. package/dist/canvas/renderer/tiles/cache.d.ts +19 -1
  59. package/dist/canvas/renderer/tiles/cache.d.ts.map +1 -1
  60. package/dist/canvas/renderer/tiles/cache.js +32 -1
  61. package/dist/canvas/renderer/tiles/cache.js.map +1 -1
  62. package/dist/canvas/renderer/tiles/controller.d.ts +11 -0
  63. package/dist/canvas/renderer/tiles/controller.d.ts.map +1 -1
  64. package/dist/canvas/renderer/tiles/controller.js +18 -1
  65. package/dist/canvas/renderer/tiles/controller.js.map +1 -1
  66. package/dist/canvas/renderer/tiles/index.d.ts +2 -2
  67. package/dist/canvas/renderer/tiles/planner.d.ts +1 -1
  68. package/dist/canvas/renderer/types.d.ts +18 -3
  69. package/dist/canvas/renderer/types.d.ts.map +1 -1
  70. package/dist/canvas/renderer/visual-bounds.d.ts +1 -1
  71. package/dist/canvas/renderer/visual-bounds.js +1 -1
  72. package/dist/canvas/renderer.d.ts +22 -2
  73. package/dist/canvas/renderer.d.ts.map +1 -1
  74. package/dist/canvas/renderer.js +29 -1
  75. package/dist/canvas/renderer.js.map +1 -1
  76. package/dist/canvas/scene.d.ts +2 -1
  77. package/dist/canvas/scene.d.ts.map +1 -1
  78. package/dist/canvas/scene.js +41 -9
  79. package/dist/canvas/scene.js.map +1 -1
  80. package/dist/canvas/shadows/silhouette.js +1 -1
  81. package/dist/canvas/texture.d.ts +20 -0
  82. package/dist/canvas/texture.d.ts.map +1 -0
  83. package/dist/canvas/texture.js +100 -0
  84. package/dist/canvas/texture.js.map +1 -0
  85. package/dist/clipboard.js +16 -5
  86. package/dist/clipboard.js.map +1 -1
  87. package/dist/constants.d.ts +5 -1
  88. package/dist/constants.d.ts.map +1 -1
  89. package/dist/constants.js +5 -1
  90. package/dist/constants.js.map +1 -1
  91. package/dist/design-jsx/renderer.d.ts.map +1 -1
  92. package/dist/design-memory/check.d.ts +90 -0
  93. package/dist/design-memory/check.d.ts.map +1 -0
  94. package/dist/design-memory/check.js +281 -0
  95. package/dist/design-memory/check.js.map +1 -0
  96. package/dist/design-memory/describe.d.ts +37 -0
  97. package/dist/design-memory/describe.d.ts.map +1 -0
  98. package/dist/design-memory/describe.js +52 -0
  99. package/dist/design-memory/describe.js.map +1 -0
  100. package/dist/design-memory/distil.d.ts +22 -0
  101. package/dist/design-memory/distil.d.ts.map +1 -0
  102. package/dist/design-memory/distil.js +54 -0
  103. package/dist/design-memory/distil.js.map +1 -0
  104. package/dist/design-memory/document.d.ts +12 -0
  105. package/dist/design-memory/document.d.ts.map +1 -0
  106. package/dist/design-memory/document.js +64 -0
  107. package/dist/design-memory/document.js.map +1 -0
  108. package/dist/design-memory/guard.d.ts +48 -0
  109. package/dist/design-memory/guard.d.ts.map +1 -0
  110. package/dist/design-memory/guard.js +105 -0
  111. package/dist/design-memory/guard.js.map +1 -0
  112. package/dist/design-memory/index.d.ts +9 -0
  113. package/dist/design-memory/index.js +9 -0
  114. package/dist/design-memory/refusal.d.ts +32 -0
  115. package/dist/design-memory/refusal.d.ts.map +1 -0
  116. package/dist/design-memory/refusal.js +68 -0
  117. package/dist/design-memory/refusal.js.map +1 -0
  118. package/dist/design-memory/rules.d.ts +63 -0
  119. package/dist/design-memory/rules.d.ts.map +1 -0
  120. package/dist/design-memory/rules.js +224 -0
  121. package/dist/design-memory/rules.js.map +1 -0
  122. package/dist/design-memory/values.d.ts +28 -0
  123. package/dist/design-memory/values.d.ts.map +1 -0
  124. package/dist/design-memory/values.js +160 -0
  125. package/dist/design-memory/values.js.map +1 -0
  126. package/dist/editor/alignment.js +1 -1
  127. package/dist/editor/bridges/components.d.ts +2 -0
  128. package/dist/editor/bridges/components.d.ts.map +1 -1
  129. package/dist/editor/bridges/components.js +2 -0
  130. package/dist/editor/bridges/components.js.map +1 -1
  131. package/dist/editor/bridges/undo.d.ts +1 -1
  132. package/dist/editor/clipboard/assets.js +1 -1
  133. package/dist/editor/clipboard/export.d.ts.map +1 -1
  134. package/dist/editor/clipboard/export.js +16 -2
  135. package/dist/editor/clipboard/export.js.map +1 -1
  136. package/dist/editor/clipboard/placement.d.ts +1 -1
  137. package/dist/editor/clipboard/placement.js +1 -1
  138. package/dist/editor/components/instances.d.ts +2 -0
  139. package/dist/editor/components/instances.d.ts.map +1 -1
  140. package/dist/editor/components/instances.js +22 -1
  141. package/dist/editor/components/instances.js.map +1 -1
  142. package/dist/editor/components.d.ts +2 -0
  143. package/dist/editor/components.d.ts.map +1 -1
  144. package/dist/editor/connectors/attach.js +1 -1
  145. package/dist/editor/create.d.ts +27 -3
  146. package/dist/editor/create.d.ts.map +1 -1
  147. package/dist/editor/create.js +16 -60
  148. package/dist/editor/create.js.map +1 -1
  149. package/dist/editor/design-memory.d.ts +11 -0
  150. package/dist/editor/design-memory.d.ts.map +1 -0
  151. package/dist/editor/design-memory.js +40 -0
  152. package/dist/editor/design-memory.js.map +1 -0
  153. package/dist/editor/design-tokens.d.ts +4 -0
  154. package/dist/editor/design-tokens.d.ts.map +1 -1
  155. package/dist/editor/design-tokens.js +30 -1
  156. package/dist/editor/design-tokens.js.map +1 -1
  157. package/dist/editor/document-colors.d.ts +23 -0
  158. package/dist/editor/document-colors.d.ts.map +1 -0
  159. package/dist/editor/document-colors.js +53 -0
  160. package/dist/editor/document-colors.js.map +1 -0
  161. package/dist/editor/eyedropper.d.ts +47 -0
  162. package/dist/editor/eyedropper.d.ts.map +1 -0
  163. package/dist/editor/eyedropper.js +168 -0
  164. package/dist/editor/eyedropper.js.map +1 -0
  165. package/dist/editor/fonts.d.ts +9 -0
  166. package/dist/editor/fonts.d.ts.map +1 -0
  167. package/dist/editor/fonts.js +14 -0
  168. package/dist/editor/fonts.js.map +1 -0
  169. package/dist/editor/history/atomic-tool.d.ts +9 -2
  170. package/dist/editor/history/atomic-tool.d.ts.map +1 -1
  171. package/dist/editor/history/atomic-tool.js +6 -0
  172. package/dist/editor/history/atomic-tool.js.map +1 -1
  173. package/dist/editor/history/capture.d.ts +13 -0
  174. package/dist/editor/history/capture.d.ts.map +1 -0
  175. package/dist/editor/history/capture.js +28 -0
  176. package/dist/editor/history/capture.js.map +1 -0
  177. package/dist/editor/history/document-change.d.ts.map +1 -1
  178. package/dist/editor/history/document-change.js +2 -22
  179. package/dist/editor/history/document-change.js.map +1 -1
  180. package/dist/editor/history/edit.d.ts +7 -0
  181. package/dist/editor/history/edit.d.ts.map +1 -1
  182. package/dist/editor/history/edit.js +4 -2
  183. package/dist/editor/history/edit.js.map +1 -1
  184. package/dist/editor/history/subtree.d.ts +9 -0
  185. package/dist/editor/history/subtree.d.ts.map +1 -1
  186. package/dist/editor/history/subtree.js +12 -2
  187. package/dist/editor/history/subtree.js.map +1 -1
  188. package/dist/editor/index.d.ts +4 -2
  189. package/dist/editor/index.js +4 -2
  190. package/dist/editor/pages.d.ts +7 -5
  191. package/dist/editor/pages.d.ts.map +1 -1
  192. package/dist/editor/pages.js +35 -25
  193. package/dist/editor/pages.js.map +1 -1
  194. package/dist/editor/play/states.d.ts +3 -1
  195. package/dist/editor/play/states.d.ts.map +1 -1
  196. package/dist/editor/play/states.js +1 -1
  197. package/dist/editor/play/states.js.map +1 -1
  198. package/dist/editor/read-only/actions.js +4 -0
  199. package/dist/editor/read-only/actions.js.map +1 -1
  200. package/dist/editor/render-requests.d.ts +18 -0
  201. package/dist/editor/render-requests.d.ts.map +1 -0
  202. package/dist/editor/render-requests.js +76 -0
  203. package/dist/editor/render-requests.js.map +1 -0
  204. package/dist/editor/scale/rescale.d.ts +1 -1
  205. package/dist/editor/selection/overlays.d.ts.map +1 -1
  206. package/dist/editor/selection/overlays.js +1 -1
  207. package/dist/editor/selection/overlays.js.map +1 -1
  208. package/dist/editor/selection/read.d.ts +4 -0
  209. package/dist/editor/selection.d.ts +5 -0
  210. package/dist/editor/selection.d.ts.map +1 -1
  211. package/dist/editor/tool-registry.d.ts.map +1 -1
  212. package/dist/editor/tool-registry.js +2 -1
  213. package/dist/editor/tool-registry.js.map +1 -1
  214. package/dist/editor/types.d.ts +5 -1
  215. package/dist/editor/types.d.ts.map +1 -1
  216. package/dist/editor/variations/create.d.ts +28 -0
  217. package/dist/editor/variations/create.d.ts.map +1 -0
  218. package/dist/editor/variations/create.js +176 -0
  219. package/dist/editor/variations/create.js.map +1 -0
  220. package/dist/editor/variations/pick.d.ts +16 -0
  221. package/dist/editor/variations/pick.d.ts.map +1 -0
  222. package/dist/editor/variations/pick.js +23 -0
  223. package/dist/editor/variations/pick.js.map +1 -0
  224. package/dist/editor/variations.d.ts +28 -0
  225. package/dist/editor/variations.d.ts.map +1 -0
  226. package/dist/editor/variations.js +88 -0
  227. package/dist/editor/variations.js.map +1 -0
  228. package/dist/figma-api/accessors/reactions.d.ts.map +1 -1
  229. package/dist/figma-api/accessors/reactions.js +4 -1
  230. package/dist/figma-api/accessors/reactions.js.map +1 -1
  231. package/dist/figma-api/accessors/text/index.js +3 -0
  232. package/dist/figma-api/accessors/text/index.js.map +1 -1
  233. package/dist/figma-api/accessors/text/opentype.d.ts +17 -0
  234. package/dist/figma-api/accessors/text/opentype.d.ts.map +1 -0
  235. package/dist/figma-api/accessors/text/opentype.js +28 -0
  236. package/dist/figma-api/accessors/text/opentype.js.map +1 -0
  237. package/dist/figma-api/accessors/visual.d.ts.map +1 -1
  238. package/dist/figma-api/accessors/visual.js +33 -0
  239. package/dist/figma-api/accessors/visual.js.map +1 -1
  240. package/dist/figma-api/effects.d.ts +79 -3
  241. package/dist/figma-api/effects.d.ts.map +1 -1
  242. package/dist/figma-api/effects.js +150 -9
  243. package/dist/figma-api/effects.js.map +1 -1
  244. package/dist/figma-api/index.d.ts +5 -0
  245. package/dist/figma-api/index.d.ts.map +1 -1
  246. package/dist/figma-api/index.js +6 -1
  247. package/dist/figma-api/index.js.map +1 -1
  248. package/dist/figma-api/overrides.d.ts +13 -1
  249. package/dist/figma-api/overrides.d.ts.map +1 -1
  250. package/dist/figma-api/overrides.js +196 -4
  251. package/dist/figma-api/overrides.js.map +1 -1
  252. package/dist/figma-api/paints.d.ts +3 -3
  253. package/dist/figma-api/paints.d.ts.map +1 -1
  254. package/dist/figma-api/paints.js +14 -4
  255. package/dist/figma-api/paints.js.map +1 -1
  256. package/dist/figma-api/proxy.d.ts +4 -1
  257. package/dist/figma-api/proxy.d.ts.map +1 -1
  258. package/dist/figma-api/proxy.js +1 -1
  259. package/dist/figma-api/proxy.js.map +1 -1
  260. package/dist/figma-api/reactions.d.ts +41 -13
  261. package/dist/figma-api/reactions.d.ts.map +1 -1
  262. package/dist/figma-api/reactions.js +113 -31
  263. package/dist/figma-api/reactions.js.map +1 -1
  264. package/dist/figma-api/render-bounds.js +1 -1
  265. package/dist/figma-api/surface.d.ts +6 -3
  266. package/dist/figma-api/surface.d.ts.map +1 -1
  267. package/dist/figma-api/surface.js +6 -2
  268. package/dist/figma-api/surface.js.map +1 -1
  269. package/dist/figma-api/transform.d.ts +1 -1
  270. package/dist/geometry/figma.d.ts +1 -1
  271. package/dist/geometry/image-crop.d.ts +1 -1
  272. package/dist/geometry/image-crop.js +1 -1
  273. package/dist/index.d.ts +4 -2
  274. package/dist/index.js +4 -2
  275. package/dist/io/formats/boolean-path.d.ts +19 -0
  276. package/dist/io/formats/boolean-path.d.ts.map +1 -0
  277. package/dist/io/formats/boolean-path.js +47 -0
  278. package/dist/io/formats/boolean-path.js.map +1 -0
  279. package/dist/io/formats/design-tokens/decode.js +1 -1
  280. package/dist/io/formats/design-tokens/index.d.ts +4 -1
  281. package/dist/io/formats/design-tokens/index.js +4 -1
  282. package/dist/io/formats/design-tokens/plan/changes.d.ts +5 -3
  283. package/dist/io/formats/design-tokens/plan/changes.d.ts.map +1 -1
  284. package/dist/io/formats/design-tokens/plan/changes.js +1 -1
  285. package/dist/io/formats/design-tokens/plan/changes.js.map +1 -1
  286. package/dist/io/formats/design-tokens/project.d.ts +17 -2
  287. package/dist/io/formats/design-tokens/project.d.ts.map +1 -1
  288. package/dist/io/formats/design-tokens/project.js +29 -8
  289. package/dist/io/formats/design-tokens/project.js.map +1 -1
  290. package/dist/io/formats/design-tokens/styles.d.ts.map +1 -1
  291. package/dist/io/formats/design-tokens/styles.js.map +1 -1
  292. package/dist/io/formats/design-tokens/sync/apply.d.ts +42 -0
  293. package/dist/io/formats/design-tokens/sync/apply.d.ts.map +1 -0
  294. package/dist/io/formats/design-tokens/sync/apply.js +73 -0
  295. package/dist/io/formats/design-tokens/sync/apply.js.map +1 -0
  296. package/dist/io/formats/design-tokens/sync/drift.d.ts +77 -0
  297. package/dist/io/formats/design-tokens/sync/drift.d.ts.map +1 -0
  298. package/dist/io/formats/design-tokens/sync/drift.js +391 -0
  299. package/dist/io/formats/design-tokens/sync/drift.js.map +1 -0
  300. package/dist/io/formats/design-tokens/sync/files.d.ts +15 -0
  301. package/dist/io/formats/design-tokens/sync/files.d.ts.map +1 -0
  302. package/dist/io/formats/design-tokens/sync/files.js +35 -0
  303. package/dist/io/formats/design-tokens/sync/files.js.map +1 -0
  304. package/dist/io/formats/drawio/edges.d.ts +7 -1
  305. package/dist/io/formats/drawio/edges.d.ts.map +1 -1
  306. package/dist/io/formats/drawio/edges.js +54 -1
  307. package/dist/io/formats/drawio/edges.js.map +1 -1
  308. package/dist/io/formats/drawio/export.d.ts.map +1 -1
  309. package/dist/io/formats/drawio/export.js +19 -2
  310. package/dist/io/formats/drawio/export.js.map +1 -1
  311. package/dist/io/formats/drawio/index.js +1 -0
  312. package/dist/io/formats/drawio/index.js.map +1 -1
  313. package/dist/io/formats/drawio/label.js +1 -1
  314. package/dist/io/formats/drawio/paint.js +1 -1
  315. package/dist/io/formats/drawio/placement.d.ts +1 -1
  316. package/dist/io/formats/fig/export/patch/index.d.ts.map +1 -1
  317. package/dist/io/formats/fig/export/patch/index.js +5 -0
  318. package/dist/io/formats/fig/export/patch/index.js.map +1 -1
  319. package/dist/io/formats/fig/thumbnail-page.d.ts +3 -4
  320. package/dist/io/formats/fig/thumbnail-page.d.ts.map +1 -1
  321. package/dist/io/formats/fig/thumbnail-page.js.map +1 -1
  322. package/dist/io/formats/html/import.d.ts.map +1 -1
  323. package/dist/io/formats/html/import.js +3 -1
  324. package/dist/io/formats/html/import.js.map +1 -1
  325. package/dist/io/formats/html/index.d.ts +2 -2
  326. package/dist/io/formats/html/index.d.ts.map +1 -1
  327. package/dist/io/formats/html/index.js +6 -4
  328. package/dist/io/formats/html/index.js.map +1 -1
  329. package/dist/io/formats/html/vectors.d.ts +2 -1
  330. package/dist/io/formats/html/vectors.d.ts.map +1 -1
  331. package/dist/io/formats/html/vectors.js +3 -2
  332. package/dist/io/formats/html/vectors.js.map +1 -1
  333. package/dist/io/formats/mermaid/styles.js +1 -1
  334. package/dist/io/formats/pdf/document.d.ts +3 -1
  335. package/dist/io/formats/pdf/document.d.ts.map +1 -1
  336. package/dist/io/formats/pdf/document.js +6 -3
  337. package/dist/io/formats/pdf/document.js.map +1 -1
  338. package/dist/io/formats/pdf/prepare.d.ts +1 -1
  339. package/dist/io/formats/pen/imports.d.ts +4 -1
  340. package/dist/io/formats/pen/imports.d.ts.map +1 -1
  341. package/dist/io/formats/pen/imports.js.map +1 -1
  342. package/dist/io/formats/pen/index.d.ts.map +1 -1
  343. package/dist/io/formats/pen/index.js +31 -3
  344. package/dist/io/formats/pen/index.js.map +1 -1
  345. package/dist/io/formats/pptx/export.js +1 -1
  346. package/dist/io/formats/pptx/geometry.d.ts +1 -1
  347. package/dist/io/formats/raster/adjusted-images.d.ts +15 -0
  348. package/dist/io/formats/raster/adjusted-images.d.ts.map +1 -0
  349. package/dist/io/formats/raster/adjusted-images.js +118 -0
  350. package/dist/io/formats/raster/adjusted-images.js.map +1 -0
  351. package/dist/io/formats/raster/headless.d.ts +11 -1
  352. package/dist/io/formats/raster/headless.d.ts.map +1 -1
  353. package/dist/io/formats/raster/headless.js +4 -4
  354. package/dist/io/formats/raster/headless.js.map +1 -1
  355. package/dist/io/formats/raster/index.d.ts +2 -2
  356. package/dist/io/formats/raster/pixels.d.ts +7 -1
  357. package/dist/io/formats/raster/pixels.d.ts.map +1 -1
  358. package/dist/io/formats/raster/pixels.js.map +1 -1
  359. package/dist/io/formats/raster/render.d.ts.map +1 -1
  360. package/dist/io/formats/raster/render.js +4 -0
  361. package/dist/io/formats/raster/render.js.map +1 -1
  362. package/dist/io/formats/svg/defs.d.ts +5 -6
  363. package/dist/io/formats/svg/defs.d.ts.map +1 -1
  364. package/dist/io/formats/svg/defs.js +1 -53
  365. package/dist/io/formats/svg/defs.js.map +1 -1
  366. package/dist/io/formats/svg/effects.d.ts +16 -0
  367. package/dist/io/formats/svg/effects.d.ts.map +1 -0
  368. package/dist/io/formats/svg/effects.js +126 -0
  369. package/dist/io/formats/svg/effects.js.map +1 -0
  370. package/dist/io/formats/svg/export.d.ts +7 -1
  371. package/dist/io/formats/svg/export.d.ts.map +1 -1
  372. package/dist/io/formats/svg/export.js +174 -36
  373. package/dist/io/formats/svg/export.js.map +1 -1
  374. package/dist/io/formats/svg/filter.d.ts +27 -0
  375. package/dist/io/formats/svg/filter.d.ts.map +1 -0
  376. package/dist/io/formats/svg/filter.js +44 -0
  377. package/dist/io/formats/svg/filter.js.map +1 -0
  378. package/dist/io/formats/svg/grain.d.ts +26 -0
  379. package/dist/io/formats/svg/grain.d.ts.map +1 -0
  380. package/dist/io/formats/svg/grain.js +298 -0
  381. package/dist/io/formats/svg/grain.js.map +1 -0
  382. package/dist/io/formats/svg/strokes.d.ts +1 -1
  383. package/dist/io/formats/svg/strokes.d.ts.map +1 -1
  384. package/dist/io/formats/svg/strokes.js +1 -2
  385. package/dist/io/formats/svg/strokes.js.map +1 -1
  386. package/dist/io/formats/svg/text/import.js +1 -1
  387. package/dist/io/formats/svg/text/layout.d.ts +5 -2
  388. package/dist/io/formats/svg/text/layout.d.ts.map +1 -1
  389. package/dist/io/formats/svg/text/layout.js +6 -3
  390. package/dist/io/formats/svg/text/layout.js.map +1 -1
  391. package/dist/io/formats/video/composite.d.ts +18 -0
  392. package/dist/io/formats/video/composite.d.ts.map +1 -0
  393. package/dist/io/formats/video/composite.js +79 -0
  394. package/dist/io/formats/video/composite.js.map +1 -0
  395. package/dist/io/formats/video/formats.d.ts +29 -0
  396. package/dist/io/formats/video/formats.d.ts.map +1 -0
  397. package/dist/io/formats/video/formats.js +43 -0
  398. package/dist/io/formats/video/formats.js.map +1 -0
  399. package/dist/io/formats/video/gif.d.ts +13 -0
  400. package/dist/io/formats/video/gif.d.ts.map +1 -0
  401. package/dist/io/formats/video/gif.js +56 -0
  402. package/dist/io/formats/video/gif.js.map +1 -0
  403. package/dist/io/formats/video/index.d.ts +9 -0
  404. package/dist/io/formats/video/index.js +9 -0
  405. package/dist/io/formats/video/plan.d.ts +64 -0
  406. package/dist/io/formats/video/plan.d.ts.map +1 -0
  407. package/dist/io/formats/video/plan.js +90 -0
  408. package/dist/io/formats/video/plan.js.map +1 -0
  409. package/dist/io/formats/video/record.d.ts +36 -0
  410. package/dist/io/formats/video/record.d.ts.map +1 -0
  411. package/dist/io/formats/video/record.js +154 -0
  412. package/dist/io/formats/video/record.js.map +1 -0
  413. package/dist/io/formats/video/sink.d.ts +29 -0
  414. package/dist/io/formats/video/sink.d.ts.map +1 -0
  415. package/dist/io/formats/video/sink.js +16 -0
  416. package/dist/io/formats/video/sink.js.map +1 -0
  417. package/dist/io/formats/video/size.d.ts +19 -0
  418. package/dist/io/formats/video/size.d.ts.map +1 -0
  419. package/dist/io/formats/video/size.js +26 -0
  420. package/dist/io/formats/video/size.js.map +1 -0
  421. package/dist/io/formats/video/webcodecs.d.ts +18 -0
  422. package/dist/io/formats/video/webcodecs.d.ts.map +1 -0
  423. package/dist/io/formats/video/webcodecs.js +74 -0
  424. package/dist/io/formats/video/webcodecs.js.map +1 -0
  425. package/dist/io/formats.d.ts.map +1 -1
  426. package/dist/io/formats.js +40 -11
  427. package/dist/io/formats.js.map +1 -1
  428. package/dist/io/types.d.ts +19 -4
  429. package/dist/io/types.d.ts.map +1 -1
  430. package/dist/kiwi/fig/parse/transfer.d.ts +1 -1
  431. package/dist/layout/auto-layout-handles.d.ts +66 -0
  432. package/dist/layout/auto-layout-handles.d.ts.map +1 -0
  433. package/dist/layout/auto-layout-handles.js +291 -0
  434. package/dist/layout/auto-layout-handles.js.map +1 -0
  435. package/dist/layout.d.ts +3 -2
  436. package/dist/layout.d.ts.map +1 -1
  437. package/dist/layout.js +2 -1
  438. package/dist/layout.js.map +1 -1
  439. package/dist/lint/fixes.d.ts.map +1 -1
  440. package/dist/lint/fixes.js +9 -3
  441. package/dist/lint/fixes.js.map +1 -1
  442. package/dist/lint/index.d.ts +3 -2
  443. package/dist/lint/index.js +2 -1
  444. package/dist/lint/linter.d.ts +12 -0
  445. package/dist/lint/linter.d.ts.map +1 -1
  446. package/dist/lint/linter.js +110 -8
  447. package/dist/lint/linter.js.map +1 -1
  448. package/dist/lint/presets.d.ts.map +1 -1
  449. package/dist/lint/presets.js +2 -0
  450. package/dist/lint/presets.js.map +1 -1
  451. package/dist/lint/rules/design-memory.d.ts +15 -0
  452. package/dist/lint/rules/design-memory.d.ts.map +1 -0
  453. package/dist/lint/rules/design-memory.js +90 -0
  454. package/dist/lint/rules/design-memory.js.map +1 -0
  455. package/dist/lint/rules/index.d.ts +6 -5
  456. package/dist/lint/rules/index.d.ts.map +1 -1
  457. package/dist/lint/rules/index.js +6 -2
  458. package/dist/lint/rules/index.js.map +1 -1
  459. package/dist/lint/rules/no-unbound-token-values.d.ts +6 -0
  460. package/dist/lint/rules/no-unbound-token-values.d.ts.map +1 -0
  461. package/dist/lint/rules/no-unbound-token-values.js +79 -0
  462. package/dist/lint/rules/no-unbound-token-values.js.map +1 -0
  463. package/dist/lint/types.d.ts +25 -2
  464. package/dist/lint/types.d.ts.map +1 -1
  465. package/dist/node/video.d.ts +12 -0
  466. package/dist/node/video.d.ts.map +1 -0
  467. package/dist/node/video.js +206 -0
  468. package/dist/node/video.js.map +1 -0
  469. package/dist/pairdraw-api/design-memory.d.ts +19 -0
  470. package/dist/pairdraw-api/design-memory.d.ts.map +1 -0
  471. package/dist/pairdraw-api/design-memory.js +39 -0
  472. package/dist/pairdraw-api/design-memory.js.map +1 -0
  473. package/dist/pairdraw-api/index.d.ts +45 -1
  474. package/dist/pairdraw-api/index.d.ts.map +1 -1
  475. package/dist/pairdraw-api/index.js +55 -2
  476. package/dist/pairdraw-api/index.js.map +1 -1
  477. package/dist/pairdraw-api/nodes.d.ts +12 -1
  478. package/dist/pairdraw-api/nodes.d.ts.map +1 -1
  479. package/dist/pairdraw-api/nodes.js +28 -1
  480. package/dist/pairdraw-api/nodes.js.map +1 -1
  481. package/dist/pairdraw-api/variations.d.ts +48 -0
  482. package/dist/pairdraw-api/variations.d.ts.map +1 -0
  483. package/dist/pairdraw-api/variations.js +76 -0
  484. package/dist/pairdraw-api/variations.js.map +1 -0
  485. package/dist/prototype/easing.d.ts +13 -0
  486. package/dist/prototype/easing.d.ts.map +1 -0
  487. package/dist/prototype/easing.js +36 -0
  488. package/dist/prototype/easing.js.map +1 -0
  489. package/dist/prototype/frames.d.ts +10 -0
  490. package/dist/prototype/frames.d.ts.map +1 -0
  491. package/dist/prototype/frames.js +12 -0
  492. package/dist/prototype/frames.js.map +1 -0
  493. package/dist/prototype/hit.d.ts +17 -0
  494. package/dist/prototype/hit.d.ts.map +1 -0
  495. package/dist/prototype/hit.js +45 -0
  496. package/dist/prototype/hit.js.map +1 -0
  497. package/dist/prototype/index.d.ts +14 -0
  498. package/dist/prototype/index.js +14 -0
  499. package/dist/prototype/pointer.d.ts +63 -0
  500. package/dist/prototype/pointer.d.ts.map +1 -0
  501. package/dist/prototype/pointer.js +104 -0
  502. package/dist/prototype/pointer.js.map +1 -0
  503. package/dist/prototype/reactions.d.ts +45 -0
  504. package/dist/prototype/reactions.d.ts.map +1 -0
  505. package/dist/prototype/reactions.js +122 -0
  506. package/dist/prototype/reactions.js.map +1 -0
  507. package/dist/prototype/scene.d.ts +35 -0
  508. package/dist/prototype/scene.d.ts.map +1 -0
  509. package/dist/prototype/scene.js +86 -0
  510. package/dist/prototype/scene.js.map +1 -0
  511. package/dist/prototype/scenes.d.ts +81 -0
  512. package/dist/prototype/scenes.d.ts.map +1 -0
  513. package/dist/prototype/scenes.js +175 -0
  514. package/dist/prototype/scenes.js.map +1 -0
  515. package/dist/prototype/scroll.d.ts +48 -0
  516. package/dist/prototype/scroll.d.ts.map +1 -0
  517. package/dist/prototype/scroll.js +159 -0
  518. package/dist/prototype/scroll.js.map +1 -0
  519. package/dist/prototype/session.d.ts +71 -0
  520. package/dist/prototype/session.d.ts.map +1 -0
  521. package/dist/prototype/session.js +135 -0
  522. package/dist/prototype/session.js.map +1 -0
  523. package/dist/prototype/smart-animate/animation.d.ts +34 -0
  524. package/dist/prototype/smart-animate/animation.d.ts.map +1 -0
  525. package/dist/prototype/smart-animate/animation.js +212 -0
  526. package/dist/prototype/smart-animate/animation.js.map +1 -0
  527. package/dist/prototype/smart-animate/match.d.ts +24 -0
  528. package/dist/prototype/smart-animate/match.d.ts.map +1 -0
  529. package/dist/prototype/smart-animate/match.js +72 -0
  530. package/dist/prototype/smart-animate/match.js.map +1 -0
  531. package/dist/prototype/snapshot.d.ts +19 -0
  532. package/dist/prototype/snapshot.d.ts.map +1 -0
  533. package/dist/prototype/snapshot.js +56 -0
  534. package/dist/prototype/snapshot.js.map +1 -0
  535. package/dist/prototype/timeline.d.ts +132 -0
  536. package/dist/prototype/timeline.d.ts.map +1 -0
  537. package/dist/prototype/timeline.js +260 -0
  538. package/dist/prototype/timeline.js.map +1 -0
  539. package/dist/rpc/read-commands.js +1 -1
  540. package/dist/text/font/features.d.ts +9 -0
  541. package/dist/text/font/features.d.ts.map +1 -0
  542. package/dist/text/font/features.js +27 -0
  543. package/dist/text/font/features.js.map +1 -0
  544. package/dist/text/font/manager.d.ts +12 -0
  545. package/dist/text/font/manager.d.ts.map +1 -1
  546. package/dist/text/font/manager.js +60 -1
  547. package/dist/text/font/manager.js.map +1 -1
  548. package/dist/text/index.d.ts +10 -8
  549. package/dist/text/index.js +3 -1
  550. package/dist/text/replace-fonts.d.ts +41 -0
  551. package/dist/text/replace-fonts.d.ts.map +1 -0
  552. package/dist/text/replace-fonts.js +121 -0
  553. package/dist/text/replace-fonts.js.map +1 -0
  554. package/dist/tools/analyze/responsive/index.d.ts +15 -0
  555. package/dist/tools/analyze/responsive/index.d.ts.map +1 -0
  556. package/dist/tools/analyze/responsive/index.js +203 -0
  557. package/dist/tools/analyze/responsive/index.js.map +1 -0
  558. package/dist/tools/analyze.d.ts +2 -1
  559. package/dist/tools/analyze.js +2 -1
  560. package/dist/tools/codegen/token-sync.d.ts +7 -0
  561. package/dist/tools/codegen/token-sync.d.ts.map +1 -0
  562. package/dist/tools/codegen/token-sync.js +85 -0
  563. package/dist/tools/codegen/token-sync.js.map +1 -0
  564. package/dist/tools/codegen/tokens.d.ts +1 -1
  565. package/dist/tools/codegen.d.ts +2 -1
  566. package/dist/tools/codegen.js +2 -1
  567. package/dist/tools/create/basic.js +1 -1
  568. package/dist/tools/create/behaviours.js +1 -1
  569. package/dist/tools/create/components.d.ts.map +1 -1
  570. package/dist/tools/create/components.js +4 -0
  571. package/dist/tools/create/components.js.map +1 -1
  572. package/dist/tools/create/html.js +3 -2
  573. package/dist/tools/create/html.js.map +1 -1
  574. package/dist/tools/create/icons.d.ts.map +1 -1
  575. package/dist/tools/create/icons.js +2 -1
  576. package/dist/tools/create/icons.js.map +1 -1
  577. package/dist/tools/create/mermaid.js +2 -1
  578. package/dist/tools/create/mermaid.js.map +1 -1
  579. package/dist/tools/create/render.js +1 -1
  580. package/dist/tools/create/svg.js +2 -1
  581. package/dist/tools/create/svg.js.map +1 -1
  582. package/dist/tools/create/vector.js +1 -1
  583. package/dist/tools/design-memory.d.ts +8 -0
  584. package/dist/tools/design-memory.d.ts.map +1 -0
  585. package/dist/tools/design-memory.js +68 -0
  586. package/dist/tools/design-memory.js.map +1 -0
  587. package/dist/tools/image-ai/generate.d.ts.map +1 -1
  588. package/dist/tools/image-ai/generate.js +3 -1
  589. package/dist/tools/image-ai/generate.js.map +1 -1
  590. package/dist/tools/index.d.ts +2 -1
  591. package/dist/tools/index.js +2 -1
  592. package/dist/tools/modify/fonts.d.ts +6 -0
  593. package/dist/tools/modify/fonts.d.ts.map +1 -0
  594. package/dist/tools/modify/fonts.js +27 -0
  595. package/dist/tools/modify/fonts.js.map +1 -0
  596. package/dist/tools/modify/paint.js +1 -1
  597. package/dist/tools/modify/reactions.d.ts.map +1 -1
  598. package/dist/tools/modify/reactions.js +3 -3
  599. package/dist/tools/modify/reactions.js.map +1 -1
  600. package/dist/tools/modify/text.d.ts.map +1 -1
  601. package/dist/tools/modify/text.js +26 -5
  602. package/dist/tools/modify/text.js.map +1 -1
  603. package/dist/tools/modify/update.d.ts +10 -1
  604. package/dist/tools/modify/update.d.ts.map +1 -1
  605. package/dist/tools/modify/update.js +34 -3
  606. package/dist/tools/modify/update.js.map +1 -1
  607. package/dist/tools/modify.d.ts +2 -1
  608. package/dist/tools/modify.js +2 -1
  609. package/dist/tools/read/fonts.d.ts.map +1 -1
  610. package/dist/tools/read/fonts.js +17 -2
  611. package/dist/tools/read/fonts.js.map +1 -1
  612. package/dist/tools/read/libraries.js +2 -1
  613. package/dist/tools/read/libraries.js.map +1 -1
  614. package/dist/tools/read/space.d.ts +3 -1
  615. package/dist/tools/read/space.d.ts.map +1 -1
  616. package/dist/tools/read/space.js +4 -3
  617. package/dist/tools/read/space.js.map +1 -1
  618. package/dist/tools/registry/core.d.ts +1 -1
  619. package/dist/tools/registry/core.d.ts.map +1 -1
  620. package/dist/tools/registry/core.js +3 -1
  621. package/dist/tools/registry/core.js.map +1 -1
  622. package/dist/tools/registry/extended.d.ts.map +1 -1
  623. package/dist/tools/registry/extended.js +16 -1
  624. package/dist/tools/registry/extended.js.map +1 -1
  625. package/dist/tools/schema.d.ts +18 -2
  626. package/dist/tools/schema.d.ts.map +1 -1
  627. package/dist/tools/schema.js +1 -1
  628. package/dist/tools/schema.js.map +1 -1
  629. package/dist/tools/stock-photo.js +1 -0
  630. package/dist/tools/stock-photo.js.map +1 -1
  631. package/dist/tools/structure/basic.d.ts.map +1 -1
  632. package/dist/tools/structure/basic.js +1 -0
  633. package/dist/tools/structure/basic.js.map +1 -1
  634. package/dist/tools/structure/batch.d.ts.map +1 -1
  635. package/dist/tools/structure/batch.js +8 -1
  636. package/dist/tools/structure/batch.js.map +1 -1
  637. package/dist/tools/structure/hierarchy.d.ts.map +1 -1
  638. package/dist/tools/structure/hierarchy.js +4 -0
  639. package/dist/tools/structure/hierarchy.js.map +1 -1
  640. package/dist/tools/structure/variations.d.ts +8 -0
  641. package/dist/tools/structure/variations.d.ts.map +1 -0
  642. package/dist/tools/structure/variations.js +106 -0
  643. package/dist/tools/structure/variations.js.map +1 -0
  644. package/dist/tools/structure.d.ts +2 -1
  645. package/dist/tools/structure.js +2 -1
  646. package/dist/tools/styles/types.d.ts +2 -4
  647. package/dist/tools/styles/types.d.ts.map +1 -1
  648. package/dist/tools/styles/types.js.map +1 -1
  649. package/dist/tools/vector/boolean.d.ts.map +1 -1
  650. package/dist/tools/vector/boolean.js +4 -0
  651. package/dist/tools/vector/boolean.js.map +1 -1
  652. package/dist/tools/vector/vectorize.js +1 -0
  653. package/dist/tools/vector/vectorize.js.map +1 -1
  654. package/dist/tools/vector/video.d.ts +6 -0
  655. package/dist/tools/vector/video.d.ts.map +1 -0
  656. package/dist/tools/vector/video.js +133 -0
  657. package/dist/tools/vector/video.js.map +1 -0
  658. package/dist/tools/vector.d.ts +2 -1
  659. package/dist/tools/vector.js +2 -1
  660. package/dist/tools/video-host.d.ts +12 -0
  661. package/dist/tools/video-host.d.ts.map +1 -0
  662. package/dist/tools/video-host.js +19 -0
  663. package/dist/tools/video-host.js.map +1 -0
  664. package/dist/vector/point-transform.d.ts +1 -1
  665. package/dist/vector/vectorize/svg/to-vectors.d.ts +1 -1
  666. package/package.json +31 -9
  667. package/src/ai/providers.ts +2 -0
  668. package/src/cache/resource.ts +24 -1
  669. package/src/canvas/effects.ts +47 -50
  670. package/src/canvas/fills.ts +19 -15
  671. package/src/canvas/images/adjustments.ts +203 -0
  672. package/src/canvas/images/sampling.ts +88 -0
  673. package/src/canvas/index.ts +1 -0
  674. package/src/canvas/masks.ts +1 -1
  675. package/src/canvas/noise/render.ts +75 -0
  676. package/src/canvas/noise/shader.ts +161 -0
  677. package/src/canvas/noise/table.ts +91 -0
  678. package/src/canvas/noise/tile.ts +94 -0
  679. package/src/canvas/overlays/auto-layout-hover.ts +47 -65
  680. package/src/canvas/renderer/lifecycle.ts +6 -0
  681. package/src/canvas/renderer/pipeline.ts +19 -1
  682. package/src/canvas/renderer/play-scenes.ts +51 -0
  683. package/src/canvas/renderer/tiles/cache.ts +54 -1
  684. package/src/canvas/renderer/tiles/controller.ts +30 -1
  685. package/src/canvas/renderer/types.ts +18 -2
  686. package/src/canvas/renderer.ts +40 -3
  687. package/src/canvas/scene.ts +65 -9
  688. package/src/canvas/texture.ts +136 -0
  689. package/src/clipboard.ts +23 -10
  690. package/src/constants.ts +6 -0
  691. package/src/design-memory/check.ts +376 -0
  692. package/src/design-memory/describe.ts +77 -0
  693. package/src/design-memory/distil.ts +69 -0
  694. package/src/design-memory/document.ts +80 -0
  695. package/src/design-memory/guard.ts +157 -0
  696. package/src/design-memory/index.ts +8 -0
  697. package/src/design-memory/refusal.ts +90 -0
  698. package/src/design-memory/rules.ts +274 -0
  699. package/src/design-memory/values.ts +179 -0
  700. package/src/editor/bridges/components.ts +2 -0
  701. package/src/editor/clipboard/export.ts +24 -7
  702. package/src/editor/components/instances.ts +31 -0
  703. package/src/editor/create.ts +25 -69
  704. package/src/editor/design-memory.ts +39 -0
  705. package/src/editor/design-tokens.ts +41 -2
  706. package/src/editor/document-colors.ts +65 -0
  707. package/src/editor/eyedropper.ts +198 -0
  708. package/src/editor/fonts.ts +19 -0
  709. package/src/editor/history/atomic-tool.ts +29 -1
  710. package/src/editor/history/capture.ts +19 -0
  711. package/src/editor/history/document-change.ts +5 -17
  712. package/src/editor/history/edit.ts +11 -1
  713. package/src/editor/history/subtree.ts +13 -2
  714. package/src/editor/index.ts +11 -0
  715. package/src/editor/pages.ts +40 -29
  716. package/src/editor/play/states.ts +1 -1
  717. package/src/editor/read-only/actions.ts +4 -0
  718. package/src/editor/render-requests.ts +83 -0
  719. package/src/editor/selection/overlays.ts +1 -0
  720. package/src/editor/tool-registry.ts +2 -1
  721. package/src/editor/types.ts +4 -0
  722. package/src/editor/variations/create.ts +235 -0
  723. package/src/editor/variations/pick.ts +35 -0
  724. package/src/editor/variations.ts +110 -0
  725. package/src/figma-api/accessors/reactions.ts +11 -1
  726. package/src/figma-api/accessors/text/index.ts +7 -0
  727. package/src/figma-api/accessors/text/opentype.ts +33 -0
  728. package/src/figma-api/accessors/visual.ts +55 -2
  729. package/src/figma-api/compatibility.ts +5 -2
  730. package/src/figma-api/effects.ts +143 -5
  731. package/src/figma-api/index.ts +10 -0
  732. package/src/figma-api/overrides.ts +295 -3
  733. package/src/figma-api/paints.ts +24 -9
  734. package/src/figma-api/proxy.ts +6 -1
  735. package/src/figma-api/reactions.ts +130 -32
  736. package/src/figma-api/surface.ts +6 -2
  737. package/src/global.d.ts +26 -0
  738. package/src/io/formats/boolean-path.ts +60 -0
  739. package/src/io/formats/design-tokens/index.ts +21 -0
  740. package/src/io/formats/design-tokens/plan/changes.ts +4 -1
  741. package/src/io/formats/design-tokens/project.ts +40 -9
  742. package/src/io/formats/design-tokens/styles.ts +10 -2
  743. package/src/io/formats/design-tokens/sync/apply.ts +130 -0
  744. package/src/io/formats/design-tokens/sync/drift.ts +587 -0
  745. package/src/io/formats/design-tokens/sync/files.ts +40 -0
  746. package/src/io/formats/drawio/edges.ts +65 -0
  747. package/src/io/formats/drawio/export.ts +37 -14
  748. package/src/io/formats/drawio/index.ts +2 -0
  749. package/src/io/formats/fig/export/patch/index.ts +8 -0
  750. package/src/io/formats/fig/thumbnail-page.ts +4 -4
  751. package/src/io/formats/html/import.ts +9 -1
  752. package/src/io/formats/html/index.ts +14 -7
  753. package/src/io/formats/html/vectors.ts +8 -2
  754. package/src/io/formats/pdf/document.ts +14 -4
  755. package/src/io/formats/pen/imports.ts +5 -6
  756. package/src/io/formats/pen/index.ts +36 -5
  757. package/src/io/formats/raster/adjusted-images.ts +125 -0
  758. package/src/io/formats/raster/headless.ts +3 -3
  759. package/src/io/formats/raster/index.ts +6 -1
  760. package/src/io/formats/raster/pixels.ts +7 -0
  761. package/src/io/formats/raster/render.ts +12 -1
  762. package/src/io/formats/svg/defs.ts +4 -72
  763. package/src/io/formats/svg/effects.ts +131 -0
  764. package/src/io/formats/svg/export.ts +278 -46
  765. package/src/io/formats/svg/filter.ts +47 -0
  766. package/src/io/formats/svg/grain.ts +249 -0
  767. package/src/io/formats/svg/strokes.ts +2 -2
  768. package/src/io/formats/svg/text/layout.ts +13 -3
  769. package/src/io/formats/video/composite.ts +79 -0
  770. package/src/io/formats/video/formats.ts +77 -0
  771. package/src/io/formats/video/gif.ts +65 -0
  772. package/src/io/formats/video/index.ts +30 -0
  773. package/src/io/formats/video/plan.ts +116 -0
  774. package/src/io/formats/video/record.ts +227 -0
  775. package/src/io/formats/video/sink.ts +32 -0
  776. package/src/io/formats/video/size.ts +25 -0
  777. package/src/io/formats/video/webcodecs.ts +89 -0
  778. package/src/io/formats.ts +59 -11
  779. package/src/io/types.ts +29 -10
  780. package/src/layout/auto-layout-handles.ts +396 -0
  781. package/src/layout.ts +2 -0
  782. package/src/lint/fixes.ts +12 -3
  783. package/src/lint/index.ts +3 -1
  784. package/src/lint/linter.ts +107 -10
  785. package/src/lint/presets.ts +2 -0
  786. package/src/lint/rules/design-memory.ts +97 -0
  787. package/src/lint/rules/index.ts +6 -1
  788. package/src/lint/rules/no-unbound-token-values.ts +73 -0
  789. package/src/lint/types.ts +32 -0
  790. package/src/node/video.ts +196 -0
  791. package/src/pairdraw-api/design-memory.ts +61 -0
  792. package/src/pairdraw-api/index.ts +81 -0
  793. package/src/pairdraw-api/nodes.ts +38 -0
  794. package/src/pairdraw-api/variations.ts +109 -0
  795. package/src/prototype/easing.ts +37 -0
  796. package/src/prototype/frames.ts +9 -0
  797. package/src/prototype/hit.ts +70 -0
  798. package/src/prototype/index.ts +69 -0
  799. package/src/prototype/pointer.ts +146 -0
  800. package/src/prototype/reactions.ts +178 -0
  801. package/src/prototype/scene.ts +116 -0
  802. package/src/prototype/scenes.ts +256 -0
  803. package/src/prototype/scroll.ts +190 -0
  804. package/src/prototype/session.ts +188 -0
  805. package/src/prototype/smart-animate/animation.ts +267 -0
  806. package/src/prototype/smart-animate/match.ts +85 -0
  807. package/src/prototype/snapshot.ts +60 -0
  808. package/src/prototype/timeline.ts +400 -0
  809. package/src/text/font/features.ts +27 -0
  810. package/src/text/font/manager.ts +79 -1
  811. package/src/text/index.ts +2 -0
  812. package/src/text/replace-fonts.ts +171 -0
  813. package/src/tools/analyze/responsive/index.ts +264 -0
  814. package/src/tools/analyze.ts +2 -0
  815. package/src/tools/codegen/token-sync.ts +98 -0
  816. package/src/tools/codegen.ts +1 -0
  817. package/src/tools/create/components.ts +4 -0
  818. package/src/tools/create/html.ts +1 -0
  819. package/src/tools/create/icons.ts +1 -0
  820. package/src/tools/create/mermaid.ts +1 -0
  821. package/src/tools/create/svg.ts +1 -0
  822. package/src/tools/design-memory.ts +72 -0
  823. package/src/tools/image-ai/generate.ts +2 -0
  824. package/src/tools/index.ts +1 -0
  825. package/src/tools/modify/fonts.ts +34 -0
  826. package/src/tools/modify/reactions.ts +15 -8
  827. package/src/tools/modify/text.ts +42 -5
  828. package/src/tools/modify/update.ts +46 -2
  829. package/src/tools/modify.ts +1 -0
  830. package/src/tools/read/fonts.ts +24 -2
  831. package/src/tools/read/libraries.ts +1 -0
  832. package/src/tools/read/space.ts +3 -2
  833. package/src/tools/registry/core.ts +3 -1
  834. package/src/tools/registry/extended.ts +28 -1
  835. package/src/tools/schema.ts +28 -4
  836. package/src/tools/stock-photo.ts +1 -0
  837. package/src/tools/structure/basic.ts +1 -0
  838. package/src/tools/structure/batch.ts +12 -1
  839. package/src/tools/structure/hierarchy.ts +4 -0
  840. package/src/tools/structure/variations.ts +118 -0
  841. package/src/tools/structure.ts +2 -0
  842. package/src/tools/styles/types.ts +3 -4
  843. package/src/tools/vector/boolean.ts +4 -0
  844. package/src/tools/vector/vectorize.ts +1 -0
  845. package/src/tools/vector/video.ts +228 -0
  846. package/src/tools/vector.ts +1 -0
  847. package/src/tools/video-host.ts +18 -0
@@ -14,9 +14,11 @@ async function readHTMLDocument(html, options = {}) {
14
14
  cssText: options.cssText,
15
15
  runtime
16
16
  });
17
+ const graph = sceneGraphFromStyledHTML(styled, { pageName: options.pageName });
18
+ if (graph.getPages().every((page) => page.childIds.length === 0)) throw new Error("No layers found in this HTML document; check that it is HTML with visible content.");
17
19
  return {
18
20
  styled,
19
- graph: sceneGraphFromStyledHTML(styled, { pageName: options.pageName })
21
+ graph
20
22
  };
21
23
  }
22
24
  /** Styles HTML for `import_html` with the headless CSS runtime, where Node runs the tools. */
@@ -1 +1 @@
1
- {"version":3,"file":"import.js","names":[],"sources":["../../../../src/io/formats/html/import.ts"],"sourcesContent":["import {\n createHeadlessCSSRuntime,\n htmlToDesignDocument,\n tailwindHTMLToDesignDocument,\n type DesignDocument\n} from '@pairdraw/dom-css'\nimport type { SceneGraph } from '@pairdraw/scene-graph'\n\nimport type { IOFormatAdapter } from '#core/io/types'\n\nimport { htmlClassNames, sceneGraphFromStyledHTML, type HTMLStyler } from './layers'\n\nexport interface ReadHTMLOptions {\n /** A stylesheet applied after the document's own `<style>` blocks. */\n cssText?: string\n /** Tailwind utility candidates compiled into the stylesheet, as the page's classes use. */\n tailwind?: readonly string[]\n pageName?: string\n}\n\nexport interface ReadHTMLResult {\n /** The styled DOM the layers were built from. */\n styled: DesignDocument\n graph: SceneGraph\n}\n\n/**\n * HTML and CSS as a laid-out document, styled by the headless CSS runtime. The runtime needs\n * Node, so browser builds style with the browser runtime and call `sceneGraphFromStyledHTML`.\n */\nexport async function readHTMLDocument(\n html: string,\n options: ReadHTMLOptions = {}\n): Promise<ReadHTMLResult> {\n const runtime = createHeadlessCSSRuntime()\n const styled = options.tailwind\n ? await tailwindHTMLToDesignDocument(html, options.tailwind, { css: options.cssText, runtime })\n : await htmlToDesignDocument(html, { cssText: options.cssText, runtime })\n return { styled, graph: sceneGraphFromStyledHTML(styled, { pageName: options.pageName }) }\n}\n\n/** Styles HTML for `import_html` with the headless CSS runtime, where Node runs the tools. */\nexport const headlessHTMLStyler: HTMLStyler = (html, { cssText, tailwind }) => {\n const runtime = createHeadlessCSSRuntime()\n return tailwind\n ? tailwindHTMLToDesignDocument(html, htmlClassNames(html), { css: cssText, runtime })\n : htmlToDesignDocument(html, { cssText, runtime })\n}\n\n/** Reads HTML files where the headless CSS runtime is available, as in the CLI. */\nexport const headlessHTMLReader: IOFormatAdapter<'html'> = {\n id: 'html',\n label: 'HTML',\n role: 'interchange-document',\n category: 'document',\n extensions: ['html', 'htm'],\n mimeTypes: ['text/html'],\n support: { readDocument: true },\n async readDocument(input) {\n const { graph } = await readHTMLDocument(new TextDecoder().decode(input.data))\n return { graph, sourceFormat: 'html' }\n }\n}\n"],"mappings":";;;;;;;AA8BA,eAAsB,iBACpB,MACA,UAA2B,CAAC,GACH;CACzB,MAAM,UAAU,yBAAyB;CACzC,MAAM,SAAS,QAAQ,WACnB,MAAM,6BAA6B,MAAM,QAAQ,UAAU;EAAE,KAAK,QAAQ;EAAS;CAAQ,CAAC,IAC5F,MAAM,qBAAqB,MAAM;EAAE,SAAS,QAAQ;EAAS;CAAQ,CAAC;CAC1E,OAAO;EAAE;EAAQ,OAAO,yBAAyB,QAAQ,EAAE,UAAU,QAAQ,SAAS,CAAC;CAAE;AAC3F;;AAGA,MAAa,sBAAkC,MAAM,EAAE,SAAS,eAAe;CAC7E,MAAM,UAAU,yBAAyB;CACzC,OAAO,WACH,6BAA6B,MAAM,eAAe,IAAI,GAAG;EAAE,KAAK;EAAS;CAAQ,CAAC,IAClF,qBAAqB,MAAM;EAAE;EAAS;CAAQ,CAAC;AACrD;;AAGA,MAAa,qBAA8C;CACzD,IAAI;CACJ,OAAO;CACP,MAAM;CACN,UAAU;CACV,YAAY,CAAC,QAAQ,KAAK;CAC1B,WAAW,CAAC,WAAW;CACvB,SAAS,EAAE,cAAc,KAAK;CAC9B,MAAM,aAAa,OAAO;EACxB,MAAM,EAAE,UAAU,MAAM,iBAAiB,IAAI,YAAY,CAAC,CAAC,OAAO,MAAM,IAAI,CAAC;EAC7E,OAAO;GAAE;GAAO,cAAc;EAAO;CACvC;AACF"}
1
+ {"version":3,"file":"import.js","names":[],"sources":["../../../../src/io/formats/html/import.ts"],"sourcesContent":["import {\n createHeadlessCSSRuntime,\n htmlToDesignDocument,\n tailwindHTMLToDesignDocument,\n type DesignDocument\n} from '@pairdraw/dom-css'\nimport type { SceneGraph } from '@pairdraw/scene-graph'\n\nimport type { IOFormatAdapter } from '#core/io/types'\n\nimport { htmlClassNames, sceneGraphFromStyledHTML, type HTMLStyler } from './layers'\n\nexport interface ReadHTMLOptions {\n /** A stylesheet applied after the document's own `<style>` blocks. */\n cssText?: string\n /** Tailwind utility candidates compiled into the stylesheet, as the page's classes use. */\n tailwind?: readonly string[]\n pageName?: string\n}\n\nexport interface ReadHTMLResult {\n /** The styled DOM the layers were built from. */\n styled: DesignDocument\n graph: SceneGraph\n}\n\n/**\n * HTML and CSS as a laid-out document, styled by the headless CSS runtime. The runtime needs\n * Node, so browser builds style with the browser runtime and call `sceneGraphFromStyledHTML`.\n */\nexport async function readHTMLDocument(\n html: string,\n options: ReadHTMLOptions = {}\n): Promise<ReadHTMLResult> {\n const runtime = createHeadlessCSSRuntime()\n const styled = options.tailwind\n ? await tailwindHTMLToDesignDocument(html, options.tailwind, { css: options.cssText, runtime })\n : await htmlToDesignDocument(html, { cssText: options.cssText, runtime })\n const graph = sceneGraphFromStyledHTML(styled, { pageName: options.pageName })\n // An empty page or markup a parser could not read would otherwise open as an empty document\n // with nothing to tell the user; every caller reports a thrown error.\n if (graph.getPages().every((page) => page.childIds.length === 0)) {\n throw new Error(\n 'No layers found in this HTML document; check that it is HTML with visible content.'\n )\n }\n return { styled, graph }\n}\n\n/** Styles HTML for `import_html` with the headless CSS runtime, where Node runs the tools. */\nexport const headlessHTMLStyler: HTMLStyler = (html, { cssText, tailwind }) => {\n const runtime = createHeadlessCSSRuntime()\n return tailwind\n ? tailwindHTMLToDesignDocument(html, htmlClassNames(html), { css: cssText, runtime })\n : htmlToDesignDocument(html, { cssText, runtime })\n}\n\n/** Reads HTML files where the headless CSS runtime is available, as in the CLI. */\nexport const headlessHTMLReader: IOFormatAdapter<'html'> = {\n id: 'html',\n label: 'HTML',\n role: 'interchange-document',\n category: 'document',\n extensions: ['html', 'htm'],\n mimeTypes: ['text/html'],\n support: { readDocument: true },\n async readDocument(input) {\n const { graph } = await readHTMLDocument(new TextDecoder().decode(input.data))\n return { graph, sourceFormat: 'html' }\n }\n}\n"],"mappings":";;;;;;;AA8BA,eAAsB,iBACpB,MACA,UAA2B,CAAC,GACH;CACzB,MAAM,UAAU,yBAAyB;CACzC,MAAM,SAAS,QAAQ,WACnB,MAAM,6BAA6B,MAAM,QAAQ,UAAU;EAAE,KAAK,QAAQ;EAAS;CAAQ,CAAC,IAC5F,MAAM,qBAAqB,MAAM;EAAE,SAAS,QAAQ;EAAS;CAAQ,CAAC;CAC1E,MAAM,QAAQ,yBAAyB,QAAQ,EAAE,UAAU,QAAQ,SAAS,CAAC;CAG7E,IAAI,MAAM,SAAS,CAAC,CAAC,OAAO,SAAS,KAAK,SAAS,WAAW,CAAC,GAC7D,MAAM,IAAI,MACR,oFACF;CAEF,OAAO;EAAE;EAAQ;CAAM;AACzB;;AAGA,MAAa,sBAAkC,MAAM,EAAE,SAAS,eAAe;CAC7E,MAAM,UAAU,yBAAyB;CACzC,OAAO,WACH,6BAA6B,MAAM,eAAe,IAAI,GAAG;EAAE,KAAK;EAAS;CAAQ,CAAC,IAClF,qBAAqB,MAAM;EAAE;EAAS;CAAQ,CAAC;AACrD;;AAGA,MAAa,qBAA8C;CACzD,IAAI;CACJ,OAAO;CACP,MAAM;CACN,UAAU;CACV,YAAY,CAAC,QAAQ,KAAK;CAC1B,WAAW,CAAC,WAAW;CACvB,SAAS,EAAE,cAAc,KAAK;CAC9B,MAAM,aAAa,OAAO;EACxB,MAAM,EAAE,UAAU,MAAM,iBAAiB,IAAI,YAAY,CAAC,CAAC,OAAO,MAAM,IAAI,CAAC;EAC7E,OAAO;GAAE;GAAO,cAAc;EAAO;CACvC;AACF"}
@@ -1,7 +1,7 @@
1
- import { ExportAsset, HTMLExportOptions } from "../../types.js";
1
+ import { ExportAsset, HTMLExportOptions, IOContext } from "../../types.js";
2
2
  import { SceneGraph } from "@pairdraw/scene-graph";
3
3
  //#region src/io/formats/html/index.d.ts
4
- declare function renderNodesToHTML(graph: SceneGraph, nodeIds: string[], options?: HTMLExportOptions, fileName?: string): Promise<{
4
+ declare function renderNodesToHTML(graph: SceneGraph, nodeIds: string[], options?: HTMLExportOptions, fileName?: string, context?: IOContext): Promise<{
5
5
  html: string;
6
6
  assets: ExportAsset[];
7
7
  }>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../../../src/io/formats/html/index.ts"],"mappings":";;;iBAkCsB,kBACpB,OAAO,YACP,mBACA,UAAS,mBACT,oBACC;EAAU;EAAc,QAAQ"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../../../src/io/formats/html/index.ts"],"mappings":";;;iBAwCsB,kBACpB,OAAO,YACP,mBACA,UAAS,mBACT,mBACA,UAAU,YACT;EAAU;EAAc,QAAQ"}
@@ -3,9 +3,11 @@ import { exportWebFontFaceAssets } from "../../../text/web-font/assets.js";
3
3
  import { filename } from "pathe/utils";
4
4
  import { exportHTMLBundle, sceneNodesToDesignDocument } from "@pairdraw/dom-css/export";
5
5
  //#region src/io/formats/html/index.ts
6
- function designDocument(graph, nodeIds, options) {
6
+ async function designDocument(graph, nodeIds, options, context) {
7
+ const { booleanPathResolver, needsBooleanPaths } = await import("../boolean-path.js");
8
+ const booleanPath = needsBooleanPaths(graph) ? await booleanPathResolver(context?.canvasKit, context?.renderer) : void 0;
7
9
  const projection = {
8
- vectorElement,
10
+ vectorElement: (vectorGraph, node) => vectorElement(vectorGraph, node, booleanPath),
9
11
  includeLayerNames: options.layerNames ?? true,
10
12
  includeSourceIds: options.layerIds ?? false
11
13
  };
@@ -15,8 +17,8 @@ function designDocument(graph, nodeIds, options) {
15
17
  function assetBasePath(fileName) {
16
18
  return `${fileName && filename(fileName) || "export"}.assets`;
17
19
  }
18
- async function renderNodesToHTML(graph, nodeIds, options = {}, fileName) {
19
- const bundle = await exportHTMLBundle(designDocument(graph, nodeIds, options), {
20
+ async function renderNodesToHTML(graph, nodeIds, options = {}, fileName, context) {
21
+ const bundle = await exportHTMLBundle(await designDocument(graph, nodeIds, options, context), {
20
22
  html: options.html,
21
23
  style: options.style,
22
24
  assets: options.assets,
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../../src/io/formats/html/index.ts"],"sourcesContent":["import { filename } from 'pathe/utils'\n\nimport {\n exportHTMLBundle,\n sceneNodesToDesignDocument,\n type DesignDocument\n} from '@pairdraw/dom-css/export'\nimport type { SceneGraph } from '@pairdraw/scene-graph'\n\nimport type { ExportAsset, HTMLExportOptions } from '#core/io/types'\nimport { exportWebFontFaceAssets } from '#core/text/web-font/assets'\n\nimport { vectorElement } from './vectors'\n\nfunction designDocument(\n graph: SceneGraph,\n nodeIds: string[],\n options: HTMLExportOptions\n): DesignDocument {\n // Layer names help find a layer in the markup; IDs only matter to tools that link back.\n const projection = {\n vectorElement,\n includeLayerNames: options.layerNames ?? true,\n includeSourceIds: options.layerIds ?? false\n }\n return sceneNodesToDesignDocument(graph, nodeIds, projection)\n}\n\n/** `card.html` keeps its external files in `card.assets/` next to it, whatever the path style. */\nfunction assetBasePath(fileName: string | undefined): string {\n const name = fileName && filename(fileName)\n return `${name || 'export'}.assets`\n}\n\nexport async function renderNodesToHTML(\n graph: SceneGraph,\n nodeIds: string[],\n options: HTMLExportOptions = {},\n fileName?: string\n): Promise<{ html: string; assets: ExportAsset[] }> {\n const bundle = await exportHTMLBundle(designDocument(graph, nodeIds, options), {\n html: options.html,\n style: options.style,\n assets: options.assets,\n fonts:\n options.fonts === 'assets'\n ? async (fonts, basePath) =>\n (await exportWebFontFaceAssets({ fonts, assetBasePath: basePath })).assets\n : 'none',\n assetBasePath: assetBasePath(fileName),\n loadTailwindStylesheet: options.loadTailwindStylesheet\n })\n const page = bundle.files.find((file) => file.path === bundle.entrypoint)\n if (typeof page?.content !== 'string') throw new Error('HTML export produced no page')\n return { html: page.content, assets: bundle.files.filter((file) => file !== page) }\n}\n"],"mappings":";;;;;AAcA,SAAS,eACP,OACA,SACA,SACgB;CAEhB,MAAM,aAAa;EACjB;EACA,mBAAmB,QAAQ,cAAc;EACzC,kBAAkB,QAAQ,YAAY;CACxC;CACA,OAAO,2BAA2B,OAAO,SAAS,UAAU;AAC9D;;AAGA,SAAS,cAAc,UAAsC;CAE3D,OAAO,GADM,YAAY,SAAS,QAAQ,KACxB,SAAS;AAC7B;AAEA,eAAsB,kBACpB,OACA,SACA,UAA6B,CAAC,GAC9B,UACkD;CAClD,MAAM,SAAS,MAAM,iBAAiB,eAAe,OAAO,SAAS,OAAO,GAAG;EAC7E,MAAM,QAAQ;EACd,OAAO,QAAQ;EACf,QAAQ,QAAQ;EAChB,OACE,QAAQ,UAAU,WACd,OAAO,OAAO,cACX,MAAM,wBAAwB;GAAE;GAAO,eAAe;EAAS,CAAC,EAAA,CAAG,SACtE;EACN,eAAe,cAAc,QAAQ;EACrC,wBAAwB,QAAQ;CAClC,CAAC;CACD,MAAM,OAAO,OAAO,MAAM,MAAM,SAAS,KAAK,SAAS,OAAO,UAAU;CACxE,IAAI,OAAO,MAAM,YAAY,UAAU,MAAM,IAAI,MAAM,8BAA8B;CACrF,OAAO;EAAE,MAAM,KAAK;EAAS,QAAQ,OAAO,MAAM,QAAQ,SAAS,SAAS,IAAI;CAAE;AACpF"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../../src/io/formats/html/index.ts"],"sourcesContent":["import { filename } from 'pathe/utils'\n\nimport {\n exportHTMLBundle,\n sceneNodesToDesignDocument,\n type DesignDocument\n} from '@pairdraw/dom-css/export'\nimport type { SceneGraph } from '@pairdraw/scene-graph'\n\nimport type { ExportAsset, HTMLExportOptions, IOContext } from '#core/io/types'\nimport { exportWebFontFaceAssets } from '#core/text/web-font/assets'\n\nimport { vectorElement } from './vectors'\n\nasync function designDocument(\n graph: SceneGraph,\n nodeIds: string[],\n options: HTMLExportOptions,\n context?: IOContext\n): Promise<DesignDocument> {\n const { booleanPathResolver, needsBooleanPaths } = await import('#core/io/formats/boolean-path')\n const booleanPath = needsBooleanPaths(graph)\n ? await booleanPathResolver(context?.canvasKit, context?.renderer)\n : undefined\n // Layer names help find a layer in the markup; IDs only matter to tools that link back.\n const projection = {\n vectorElement: (vectorGraph: SceneGraph, node: Parameters<typeof vectorElement>[1]) =>\n vectorElement(vectorGraph, node, booleanPath),\n includeLayerNames: options.layerNames ?? true,\n includeSourceIds: options.layerIds ?? false\n }\n return sceneNodesToDesignDocument(graph, nodeIds, projection)\n}\n\n/** `card.html` keeps its external files in `card.assets/` next to it, whatever the path style. */\nfunction assetBasePath(fileName: string | undefined): string {\n const name = fileName && filename(fileName)\n return `${name || 'export'}.assets`\n}\n\nexport async function renderNodesToHTML(\n graph: SceneGraph,\n nodeIds: string[],\n options: HTMLExportOptions = {},\n fileName?: string,\n context?: IOContext\n): Promise<{ html: string; assets: ExportAsset[] }> {\n const bundle = await exportHTMLBundle(await designDocument(graph, nodeIds, options, context), {\n html: options.html,\n style: options.style,\n assets: options.assets,\n fonts:\n options.fonts === 'assets'\n ? async (fonts, basePath) =>\n (await exportWebFontFaceAssets({ fonts, assetBasePath: basePath })).assets\n : 'none',\n assetBasePath: assetBasePath(fileName),\n loadTailwindStylesheet: options.loadTailwindStylesheet\n })\n const page = bundle.files.find((file) => file.path === bundle.entrypoint)\n if (typeof page?.content !== 'string') throw new Error('HTML export produced no page')\n return { html: page.content, assets: bundle.files.filter((file) => file !== page) }\n}\n"],"mappings":";;;;;AAcA,eAAe,eACb,OACA,SACA,SACA,SACyB;CACzB,MAAM,EAAE,qBAAqB,sBAAsB,MAAM,OAAO;CAChE,MAAM,cAAc,kBAAkB,KAAK,IACvC,MAAM,oBAAoB,SAAS,WAAW,SAAS,QAAQ,IAC/D,KAAA;CAEJ,MAAM,aAAa;EACjB,gBAAgB,aAAyB,SACvC,cAAc,aAAa,MAAM,WAAW;EAC9C,mBAAmB,QAAQ,cAAc;EACzC,kBAAkB,QAAQ,YAAY;CACxC;CACA,OAAO,2BAA2B,OAAO,SAAS,UAAU;AAC9D;;AAGA,SAAS,cAAc,UAAsC;CAE3D,OAAO,GADM,YAAY,SAAS,QAAQ,KACxB,SAAS;AAC7B;AAEA,eAAsB,kBACpB,OACA,SACA,UAA6B,CAAC,GAC9B,UACA,SACkD;CAClD,MAAM,SAAS,MAAM,iBAAiB,MAAM,eAAe,OAAO,SAAS,SAAS,OAAO,GAAG;EAC5F,MAAM,QAAQ;EACd,OAAO,QAAQ;EACf,QAAQ,QAAQ;EAChB,OACE,QAAQ,UAAU,WACd,OAAO,OAAO,cACX,MAAM,wBAAwB;GAAE;GAAO,eAAe;EAAS,CAAC,EAAA,CAAG,SACtE;EACN,eAAe,cAAc,QAAQ;EACrC,wBAAwB,QAAQ;CAClC,CAAC;CACD,MAAM,OAAO,OAAO,MAAM,MAAM,SAAS,KAAK,SAAS,OAAO,UAAU;CACxE,IAAI,OAAO,MAAM,YAAY,UAAU,MAAM,IAAI,MAAM,8BAA8B;CACrF,OAAO;EAAE,MAAM,KAAK;EAAS,QAAQ,OAAO,MAAM,QAAQ,SAAS,SAAS,IAAI;CAAE;AACpF"}
@@ -1,3 +1,4 @@
1
+ import { BooleanPathResolver } from "../boolean-path.js";
1
2
  import { VectorElementRenderer } from "@pairdraw/dom-css/export";
2
3
  //#region src/io/formats/html/vectors.d.ts
3
4
  /**
@@ -7,7 +8,7 @@ import { VectorElementRenderer } from "@pairdraw/dom-css/export";
7
8
  * were edited. Def ids start with the layer's id, so several SVGs on one page never pick up each
8
9
  * other's gradients or filters.
9
10
  */
10
- declare const vectorElement: VectorElementRenderer;
11
+ declare const vectorElement: (graph: Parameters<VectorElementRenderer>[0], node: Parameters<VectorElementRenderer>[1], booleanPath?: BooleanPathResolver) => ReturnType<VectorElementRenderer>;
11
12
  //#endregion
12
13
  export { vectorElement };
13
14
  //# sourceMappingURL=vectors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"vectors.d.ts","names":[],"sources":["../../../../src/io/formats/html/vectors.ts"],"mappings":";;;;;;;;;cAmCa,eAAe"}
1
+ {"version":3,"file":"vectors.d.ts","names":[],"sources":["../../../../src/io/formats/html/vectors.ts"],"mappings":";;;;;;;;;;cAoCa,gBACX,OAAO,WAAW,2BAClB,MAAM,WAAW,2BACjB,cAAc,wBACb,WAAW"}
@@ -29,13 +29,14 @@ function idPart(id) {
29
29
  * were edited. Def ids start with the layer's id, so several SVGs on one page never pick up each
30
30
  * other's gradients or filters.
31
31
  */
32
- const vectorElement = (graph, node) => {
32
+ const vectorElement = (graph, node, booleanPath) => {
33
33
  const idPrefix = `${idPart(node.id)}-`;
34
34
  const icon = readIcon(node);
35
35
  const drawn = renderNodeSVGElement(graph, node, {
36
36
  idPrefix,
37
37
  colorSpace: graph.documentColorSpace,
38
- tint: icon ? readIconTint : void 0
38
+ tint: icon ? readIconTint : void 0,
39
+ booleanPath
39
40
  });
40
41
  const element = drawn && designNode(drawn);
41
42
  if (element?.type !== "element") return null;
@@ -1 +1 @@
1
- {"version":3,"file":"vectors.js","names":[],"sources":["../../../../src/io/formats/html/vectors.ts"],"sourcesContent":["import type { DesignElement, DesignNode, VectorElementRenderer } from '@pairdraw/dom-css/export'\nimport { colorToHex } from '@pairdraw/scene-graph/color'\nimport { isIconModified, readIcon, readIconTint } from '@pairdraw/scene-graph/icons'\n\nimport { iconColor } from '#core/icons/render'\nimport { renderNodeSVGElement } from '#core/io/formats/svg/export'\nimport type { SVGNode } from '#core/io/formats/svg/node'\n\nfunction designNode(node: SVGNode | string): DesignNode {\n if (typeof node === 'string') return { type: 'text', text: node }\n return {\n type: 'element',\n tagName: node.tag,\n attrs: Object.fromEntries(\n Object.entries(node.attrs).map(([name, value]) => [name, String(value)])\n ),\n children: node.children.map(designNode)\n }\n}\n\n/**\n * A layer id as an id-safe string, one to one: letters, digits, and `-` stay, and anything\n * else, `_` included, becomes `_<code point>_`, so `a:b` and `a-b` never meet.\n */\nfunction idPart(id: string): string {\n return id.replace(/[^A-Za-z0-9-]/gu, (char) => `_${char.codePointAt(0)?.toString(16) ?? ''}_`)\n}\n\n/**\n * Vector layers and icons in HTML exports as inline SVG from the SVG export, so paths,\n * gradients, and shadows draw as they do there. An icon is one SVG whose tinted paths take\n * `currentColor`, so a page recolors it with CSS `color`, named by `data-icon` unless its paths\n * were edited. Def ids start with the layer's id, so several SVGs on one page never pick up each\n * other's gradients or filters.\n */\nexport const vectorElement: VectorElementRenderer = (graph, node) => {\n const idPrefix = `${idPart(node.id)}-`\n const icon = readIcon(node)\n const drawn = renderNodeSVGElement(graph, node, {\n idPrefix,\n colorSpace: graph.documentColorSpace,\n tint: icon ? readIconTint : undefined\n })\n const element = drawn && designNode(drawn)\n if (element?.type !== 'element') return null\n const color = icon ? iconColor(graph, node) : null\n return {\n ...element,\n // An icon whose paths were edited no longer draws the named icon, so it goes unnamed.\n attrs:\n icon && !isIconModified(graph, node)\n ? { ...element.attrs, 'data-icon': icon.name }\n : element.attrs,\n // Strokes and shadows can reach past the layer's box, which an inline SVG would clip.\n inlineStyle: { overflow: 'visible', ...(color ? { color: colorToHex(color) } : {}) }\n } satisfies DesignElement\n}\n"],"mappings":";;;;;AAQA,SAAS,WAAW,MAAoC;CACtD,IAAI,OAAO,SAAS,UAAU,OAAO;EAAE,MAAM;EAAQ,MAAM;CAAK;CAChE,OAAO;EACL,MAAM;EACN,SAAS,KAAK;EACd,OAAO,OAAO,YACZ,OAAO,QAAQ,KAAK,KAAK,CAAC,CAAC,KAAK,CAAC,MAAM,WAAW,CAAC,MAAM,OAAO,KAAK,CAAC,CAAC,CACzE;EACA,UAAU,KAAK,SAAS,IAAI,UAAU;CACxC;AACF;;;;;AAMA,SAAS,OAAO,IAAoB;CAClC,OAAO,GAAG,QAAQ,oBAAoB,SAAS,IAAI,KAAK,YAAY,CAAC,CAAC,EAAE,SAAS,EAAE,KAAK,GAAG,EAAE;AAC/F;;;;;;;;AASA,MAAa,iBAAwC,OAAO,SAAS;CACnE,MAAM,WAAW,GAAG,OAAO,KAAK,EAAE,EAAE;CACpC,MAAM,OAAO,SAAS,IAAI;CAC1B,MAAM,QAAQ,qBAAqB,OAAO,MAAM;EAC9C;EACA,YAAY,MAAM;EAClB,MAAM,OAAO,eAAe,KAAA;CAC9B,CAAC;CACD,MAAM,UAAU,SAAS,WAAW,KAAK;CACzC,IAAI,SAAS,SAAS,WAAW,OAAO;CACxC,MAAM,QAAQ,OAAO,UAAU,OAAO,IAAI,IAAI;CAC9C,OAAO;EACL,GAAG;EAEH,OACE,QAAQ,CAAC,eAAe,OAAO,IAAI,IAC/B;GAAE,GAAG,QAAQ;GAAO,aAAa,KAAK;EAAK,IAC3C,QAAQ;EAEd,aAAa;GAAE,UAAU;GAAW,GAAI,QAAQ,EAAE,OAAO,WAAW,KAAK,EAAE,IAAI,CAAC;EAAG;CACrF;AACF"}
1
+ {"version":3,"file":"vectors.js","names":[],"sources":["../../../../src/io/formats/html/vectors.ts"],"sourcesContent":["import type { DesignElement, DesignNode, VectorElementRenderer } from '@pairdraw/dom-css/export'\nimport { colorToHex } from '@pairdraw/scene-graph/color'\nimport { isIconModified, readIcon, readIconTint } from '@pairdraw/scene-graph/icons'\n\nimport { iconColor } from '#core/icons/render'\nimport type { BooleanPathResolver } from '#core/io/formats/boolean-path'\nimport { renderNodeSVGElement } from '#core/io/formats/svg/export'\nimport type { SVGNode } from '#core/io/formats/svg/node'\n\nfunction designNode(node: SVGNode | string): DesignNode {\n if (typeof node === 'string') return { type: 'text', text: node }\n return {\n type: 'element',\n tagName: node.tag,\n attrs: Object.fromEntries(\n Object.entries(node.attrs).map(([name, value]) => [name, String(value)])\n ),\n children: node.children.map(designNode)\n }\n}\n\n/**\n * A layer id as an id-safe string, one to one: letters, digits, and `-` stay, and anything\n * else, `_` included, becomes `_<code point>_`, so `a:b` and `a-b` never meet.\n */\nfunction idPart(id: string): string {\n return id.replace(/[^A-Za-z0-9-]/gu, (char) => `_${char.codePointAt(0)?.toString(16) ?? ''}_`)\n}\n\n/**\n * Vector layers and icons in HTML exports as inline SVG from the SVG export, so paths,\n * gradients, and shadows draw as they do there. An icon is one SVG whose tinted paths take\n * `currentColor`, so a page recolors it with CSS `color`, named by `data-icon` unless its paths\n * were edited. Def ids start with the layer's id, so several SVGs on one page never pick up each\n * other's gradients or filters.\n */\nexport const vectorElement = (\n graph: Parameters<VectorElementRenderer>[0],\n node: Parameters<VectorElementRenderer>[1],\n booleanPath?: BooleanPathResolver\n): ReturnType<VectorElementRenderer> => {\n const idPrefix = `${idPart(node.id)}-`\n const icon = readIcon(node)\n const drawn = renderNodeSVGElement(graph, node, {\n idPrefix,\n colorSpace: graph.documentColorSpace,\n tint: icon ? readIconTint : undefined,\n booleanPath\n })\n const element = drawn && designNode(drawn)\n if (element?.type !== 'element') return null\n const color = icon ? iconColor(graph, node) : null\n return {\n ...element,\n // An icon whose paths were edited no longer draws the named icon, so it goes unnamed.\n attrs:\n icon && !isIconModified(graph, node)\n ? { ...element.attrs, 'data-icon': icon.name }\n : element.attrs,\n // Strokes and shadows can reach past the layer's box, which an inline SVG would clip.\n inlineStyle: { overflow: 'visible', ...(color ? { color: colorToHex(color) } : {}) }\n } satisfies DesignElement\n}\n"],"mappings":";;;;;AASA,SAAS,WAAW,MAAoC;CACtD,IAAI,OAAO,SAAS,UAAU,OAAO;EAAE,MAAM;EAAQ,MAAM;CAAK;CAChE,OAAO;EACL,MAAM;EACN,SAAS,KAAK;EACd,OAAO,OAAO,YACZ,OAAO,QAAQ,KAAK,KAAK,CAAC,CAAC,KAAK,CAAC,MAAM,WAAW,CAAC,MAAM,OAAO,KAAK,CAAC,CAAC,CACzE;EACA,UAAU,KAAK,SAAS,IAAI,UAAU;CACxC;AACF;;;;;AAMA,SAAS,OAAO,IAAoB;CAClC,OAAO,GAAG,QAAQ,oBAAoB,SAAS,IAAI,KAAK,YAAY,CAAC,CAAC,EAAE,SAAS,EAAE,KAAK,GAAG,EAAE;AAC/F;;;;;;;;AASA,MAAa,iBACX,OACA,MACA,gBACsC;CACtC,MAAM,WAAW,GAAG,OAAO,KAAK,EAAE,EAAE;CACpC,MAAM,OAAO,SAAS,IAAI;CAC1B,MAAM,QAAQ,qBAAqB,OAAO,MAAM;EAC9C;EACA,YAAY,MAAM;EAClB,MAAM,OAAO,eAAe,KAAA;EAC5B;CACF,CAAC;CACD,MAAM,UAAU,SAAS,WAAW,KAAK;CACzC,IAAI,SAAS,SAAS,WAAW,OAAO;CACxC,MAAM,QAAQ,OAAO,UAAU,OAAO,IAAI,IAAI;CAC9C,OAAO;EACL,GAAG;EAEH,OACE,QAAQ,CAAC,eAAe,OAAO,IAAI,IAC/B;GAAE,GAAG,QAAQ;GAAO,aAAa,KAAK;EAAK,IAC3C,QAAQ;EAEd,aAAa;GAAE,UAAU;GAAW,GAAI,QAAQ,EAAE,OAAO,WAAW,KAAK,EAAE,IAAI,CAAC;EAAG;CACrF;AACF"}
@@ -1,5 +1,5 @@
1
- import { tryParseColor } from "@pairdraw/scene-graph/color";
2
1
  import { parseCSSNumber } from "@pairdraw/scene-graph/css";
2
+ import { tryParseColor } from "@pairdraw/scene-graph/color";
3
3
  //#region src/io/formats/mermaid/styles.ts
4
4
  function color(value) {
5
5
  if (value === "none" || value === "transparent") return null;
@@ -1,5 +1,7 @@
1
+ import { SkiaRenderer } from "../../../canvas/renderer.js";
1
2
  import { PDFPageSpec } from "./plan.js";
2
3
  import { PDFExportResult } from "./export.js";
4
+ import { CanvasKit } from "canvaskit-wasm";
3
5
  import { SceneGraph } from "@pairdraw/scene-graph";
4
6
  //#region src/io/formats/pdf/document.d.ts
5
7
  interface PDFDocumentOptions {
@@ -13,7 +15,7 @@ interface PDFDocumentOptions {
13
15
  * A PDF of the pages as the canvas draws them: the fonts their text uses loaded, and each
14
16
  * paragraph broken into the lines the canvas breaks it into. Null when no page shows anything.
15
17
  */
16
- declare function exportPDFDocument(graph: SceneGraph, specs: readonly PDFPageSpec[], options: PDFDocumentOptions): Promise<PDFExportResult | null>;
18
+ declare function exportPDFDocument(graph: SceneGraph, specs: readonly PDFPageSpec[], options: PDFDocumentOptions, canvasKit?: CanvasKit, renderer?: SkiaRenderer): Promise<PDFExportResult | null>;
17
19
  //#endregion
18
20
  export { PDFDocumentOptions, exportPDFDocument };
19
21
  //# sourceMappingURL=document.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"document.d.ts","names":[],"sources":["../../../../src/io/formats/pdf/document.ts"],"mappings":";;;;UAQiB;;EAEf;;EAEA;EACA;;;;;;iBAOoB,kBACpB,OAAO,YACP,gBAAgB,eAChB,SAAS,qBACR,QAAQ"}
1
+ {"version":3,"file":"document.d.ts","names":[],"sources":["../../../../src/io/formats/pdf/document.ts"],"mappings":";;;;;;UAYiB;;EAEf;;EAEA;EACA;;;;;;iBAOoB,kBACpB,OAAO,YACP,gBAAgB,eAChB,SAAS,oBACT,YAAY,WACZ,WAAW,eACV,QAAQ"}
@@ -1,15 +1,18 @@
1
1
  import { fontManager } from "../../../text/font/manager.js";
2
2
  import { pdfFontFaces, preparePDFFonts, preparePagesForPDF, withPDFTextLayout } from "./prepare.js";
3
+ import { bakeAdjustedImages, hasAdjustedImagePaints } from "../raster/adjusted-images.js";
3
4
  import { renderPagesToPDFDetailed } from "./export.js";
4
5
  //#region src/io/formats/pdf/document.ts
5
6
  /**
6
7
  * A PDF of the pages as the canvas draws them: the fonts their text uses loaded, and each
7
8
  * paragraph broken into the lines the canvas breaks it into. Null when no page shows anything.
8
9
  */
9
- async function exportPDFDocument(graph, specs, options) {
10
- const status = options.layOutPages ? await preparePagesForPDF(graph, specs) : await preparePDFFonts(graph, specs);
10
+ async function exportPDFDocument(graph, specs, options, canvasKit, renderer) {
11
+ const nodeIds = specs.flatMap((spec) => spec.nodeIds);
12
+ const baked = hasAdjustedImagePaints(graph, nodeIds) ? await bakeAdjustedImages(graph, nodeIds, canvasKit, renderer) : graph;
13
+ const status = options.layOutPages ? await preparePagesForPDF(baked, specs) : await preparePDFFonts(baked, specs);
11
14
  const fonts = options.embedFonts ? pdfFontFaces(status) : void 0;
12
- return withPDFTextLayout((textLayout) => renderPagesToPDFDetailed(graph, specs, {
15
+ return withPDFTextLayout((textLayout) => renderPagesToPDFDetailed(baked, specs, {
13
16
  fonts,
14
17
  textLayout,
15
18
  fallbackFile: (family, style, file) => file === 0 ? fontManager.loadedData(family, style) : fontManager.shardData(family, style)[file - 1] ?? null,
@@ -1 +1 @@
1
- {"version":3,"file":"document.js","names":[],"sources":["../../../../src/io/formats/pdf/document.ts"],"sourcesContent":["import type { SceneGraph } from '@pairdraw/scene-graph'\n\nimport { fontManager } from '#core/text/font/manager'\n\nimport { renderPagesToPDFDetailed, type PDFExportResult } from './export'\nimport type { PDFPageSpec } from './plan'\nimport { pdfFontFaces, preparePagesForPDF, preparePDFFonts, withPDFTextLayout } from './prepare'\n\nexport interface PDFDocumentOptions {\n /** Embed the font files the text uses; without them, text uses standard PDF fonts. */\n embedFonts: boolean\n /** Lay the pages out first, as pages other than the open one have no layout yet. */\n layOutPages?: boolean\n title?: string\n}\n\n/**\n * A PDF of the pages as the canvas draws them: the fonts their text uses loaded, and each\n * paragraph broken into the lines the canvas breaks it into. Null when no page shows anything.\n */\nexport async function exportPDFDocument(\n graph: SceneGraph,\n specs: readonly PDFPageSpec[],\n options: PDFDocumentOptions\n): Promise<PDFExportResult | null> {\n const status = options.layOutPages\n ? await preparePagesForPDF(graph, specs)\n : await preparePDFFonts(graph, specs)\n const fonts = options.embedFonts ? pdfFontFaces(status) : undefined\n return withPDFTextLayout((textLayout) =>\n renderPagesToPDFDetailed(graph, specs, {\n fonts,\n textLayout,\n fallbackFile: (family, style, file) =>\n file === 0\n ? fontManager.loadedData(family, style)\n : (fontManager.shardData(family, style)[file - 1] ?? null),\n title: options.title\n })\n )\n}\n"],"mappings":";;;;;;;;AAoBA,eAAsB,kBACpB,OACA,OACA,SACiC;CACjC,MAAM,SAAS,QAAQ,cACnB,MAAM,mBAAmB,OAAO,KAAK,IACrC,MAAM,gBAAgB,OAAO,KAAK;CACtC,MAAM,QAAQ,QAAQ,aAAa,aAAa,MAAM,IAAI,KAAA;CAC1D,OAAO,mBAAmB,eACxB,yBAAyB,OAAO,OAAO;EACrC;EACA;EACA,eAAe,QAAQ,OAAO,SAC5B,SAAS,IACL,YAAY,WAAW,QAAQ,KAAK,IACnC,YAAY,UAAU,QAAQ,KAAK,CAAC,CAAC,OAAO,MAAM;EACzD,OAAO,QAAQ;CACjB,CAAC,CACH;AACF"}
1
+ {"version":3,"file":"document.js","names":[],"sources":["../../../../src/io/formats/pdf/document.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 { bakeAdjustedImages, hasAdjustedImagePaints } from '#core/io/formats/raster/adjusted-images'\nimport { fontManager } from '#core/text/font/manager'\n\nimport { renderPagesToPDFDetailed, type PDFExportResult } from './export'\nimport type { PDFPageSpec } from './plan'\nimport { pdfFontFaces, preparePagesForPDF, preparePDFFonts, withPDFTextLayout } from './prepare'\n\nexport interface PDFDocumentOptions {\n /** Embed the font files the text uses; without them, text uses standard PDF fonts. */\n embedFonts: boolean\n /** Lay the pages out first, as pages other than the open one have no layout yet. */\n layOutPages?: boolean\n title?: string\n}\n\n/**\n * A PDF of the pages as the canvas draws them: the fonts their text uses loaded, and each\n * paragraph broken into the lines the canvas breaks it into. Null when no page shows anything.\n */\nexport async function exportPDFDocument(\n graph: SceneGraph,\n specs: readonly PDFPageSpec[],\n options: PDFDocumentOptions,\n canvasKit?: CanvasKit,\n renderer?: SkiaRenderer\n): Promise<PDFExportResult | null> {\n const nodeIds = specs.flatMap((spec) => spec.nodeIds)\n const baked = hasAdjustedImagePaints(graph, nodeIds)\n ? await bakeAdjustedImages(graph, nodeIds, canvasKit, renderer)\n : graph\n const status = options.layOutPages\n ? await preparePagesForPDF(baked, specs)\n : await preparePDFFonts(baked, specs)\n const fonts = options.embedFonts ? pdfFontFaces(status) : undefined\n return withPDFTextLayout((textLayout) =>\n renderPagesToPDFDetailed(baked, specs, {\n fonts,\n textLayout,\n fallbackFile: (family, style, file) =>\n file === 0\n ? fontManager.loadedData(family, style)\n : (fontManager.shardData(family, style)[file - 1] ?? null),\n title: options.title\n })\n )\n}\n"],"mappings":";;;;;;;;;AAwBA,eAAsB,kBACpB,OACA,OACA,SACA,WACA,UACiC;CACjC,MAAM,UAAU,MAAM,SAAS,SAAS,KAAK,OAAO;CACpD,MAAM,QAAQ,uBAAuB,OAAO,OAAO,IAC/C,MAAM,mBAAmB,OAAO,SAAS,WAAW,QAAQ,IAC5D;CACJ,MAAM,SAAS,QAAQ,cACnB,MAAM,mBAAmB,OAAO,KAAK,IACrC,MAAM,gBAAgB,OAAO,KAAK;CACtC,MAAM,QAAQ,QAAQ,aAAa,aAAa,MAAM,IAAI,KAAA;CAC1D,OAAO,mBAAmB,eACxB,yBAAyB,OAAO,OAAO;EACrC;EACA;EACA,eAAe,QAAQ,OAAO,SAC5B,SAAS,IACL,YAAY,WAAW,QAAQ,KAAK,IACnC,YAAY,UAAU,QAAQ,KAAK,CAAC,CAAC,OAAO,MAAM;EACzD,OAAO,QAAQ;CACjB,CAAC,CACH;AACF"}
@@ -1,8 +1,8 @@
1
+ import { DocumentFontStatus } from "../../../text/font/status.js";
1
2
  import { SVGTextLayout } from "../svg/text/lines.js";
2
3
  import "../svg/index.js";
3
4
  import { PDFFontFace } from "./fonts.js";
4
5
  import { PDFPageSpec } from "./plan.js";
5
- import { DocumentFontStatus } from "../../../text/font/status.js";
6
6
  import { SceneGraph } from "@pairdraw/scene-graph";
7
7
  //#region src/io/formats/pdf/prepare.d.ts
8
8
  /**
@@ -13,10 +13,13 @@ interface LoadedImports {
13
13
  /** As the host gave them, to read their files with. */
14
14
  opened: Map<string, OpenedImport>;
15
15
  }
16
+ type UnresolvedReason = Extract<ReadDocumentWarning, {
17
+ kind: 'unresolved-imports';
18
+ }>['reason'];
16
19
  /** The imports a document opened without, by why. */
17
20
  declare class UnresolvedImports {
18
21
  #private;
19
- add(reason: ReadDocumentWarning['reason'], path: string): void;
22
+ add(reason: UnresolvedReason, path: string): void;
20
23
  warnings(): ReadDocumentWarning[];
21
24
  }
22
25
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"imports.d.ts","names":[],"sources":["../../../../src/io/formats/pen/imports.ts"],"mappings":";;;;UAgBiB;EACf,OAAO;EACP,SAAS,oBAAoB;;;UAId;;EAEf,SAAS,YAAY;;EAErB,QAAQ,YAAY;;;cAST;;EAMX,IAAI,QAAQ,+BAA+B;EAI3C,YAAY;;;;;;;;;iBA8FE,eACd,KAAK,aACL,OAAO,mBACP,YAAY,oBACX,QAAQ;;;;;iBASW,kBACpB,QAAQ,oBAAoB,eAC5B,cACC,QAAQ"}
1
+ {"version":3,"file":"imports.d.ts","names":[],"sources":["../../../../src/io/formats/pen/imports.ts"],"mappings":";;;;UAgBiB;EACf,OAAO;EACP,SAAS,oBAAoB;;;UAId;;EAEf,SAAS,YAAY;;EAErB,QAAQ,YAAY;;KAGjB,mBAAmB,QAAQ;EAAuB;;;cAK1C;;EAMX,IAAI,QAAQ,kBAAkB;EAI9B,YAAY;;;;;;;;;iBA8FE,eACd,KAAK,aACL,OAAO,mBACP,YAAY,oBACX,QAAQ;;;;;iBASW,kBACpB,QAAQ,oBAAoB,eAC5B,cACC,QAAQ"}
@@ -1 +1 @@
1
- {"version":3,"file":"imports.js","names":["#paths"],"sources":["../../../../src/io/formats/pen/imports.ts"],"sourcesContent":["import { dirname, isAbsolute, join } from 'pathe'\n\nimport {\n importedDocument,\n parseImportedImageURL,\n parsePenDocument,\n type PenDocument,\n type PenImport\n} from '@pairdraw/pen'\n\nimport type { ReadDocumentInput, ReadDocumentWarning } from '#core/io/types'\n\n/** How deep a chain of documents importing one another is read: sixteen documents. */\nconst MAX_IMPORT_DEPTH = 16\n\n/** A document read for another that imports it, with the documents it imports in turn. */\nexport interface OpenedImport {\n input: ReadDocumentInput\n imports: ReadonlyMap<string, OpenedImport>\n}\n\n/** The documents a document imports, read, by the alias it names each one with. */\nexport interface LoadedImports {\n /** As `buildPenGraph` takes them. */\n imports: Map<string, PenImport>\n /** As the host gave them, to read their files with. */\n opened: Map<string, OpenedImport>\n}\n\nconst UNRESOLVED_REASONS: readonly ReadDocumentWarning['reason'][] = [\n 'no-file-access',\n 'unreadable'\n]\n\n/** The imports a document opened without, by why. */\nexport class UnresolvedImports {\n readonly #paths: Record<ReadDocumentWarning['reason'], Set<string>> = {\n 'no-file-access': new Set(),\n unreadable: new Set()\n }\n\n add(reason: ReadDocumentWarning['reason'], path: string): void {\n this.#paths[reason].add(path)\n }\n\n warnings(): ReadDocumentWarning[] {\n return UNRESOLVED_REASONS.flatMap((reason) => {\n const paths = this.#paths[reason]\n return paths.size > 0 ? [{ kind: 'unresolved-imports', reason, paths: [...paths] }] : []\n })\n }\n}\n\n/** A document the host opened, or null for one that is no `.pen` document. */\nfunction parseImported(input: ReadDocumentInput): PenDocument | null {\n try {\n return parsePenDocument(new TextDecoder().decode(input.data))\n } catch {\n return null\n }\n}\n\n/** An import the host opened, or null for one it could not open or that is no `.pen` document. */\ntype OpenedDocument = { input: ReadDocumentInput; doc: PenDocument } | null\n\n/** What one read of a document and its imports shares across every document it reads. */\ninterface ImportRead {\n unresolved: UnresolvedImports\n /** Each import by its path from the document being opened, so the host opens a file once. */\n opened: Map<string, OpenedDocument>\n /** The imports of each document read, by the host's name for it, so each is read once. */\n loaded: Map<string, LoadedImports>\n}\n\n/**\n * The path an import is named by in warnings, from the document being opened: as that document\n * writes it for its own imports, and as the import resolves from there for its imports' imports.\n */\nfunction importPath(at: string, path: string): string {\n return at === '' || isAbsolute(path) ? path : join(dirname(at), path)\n}\n\nasync function openImported(input: ReadDocumentInput, path: string): Promise<OpenedDocument> {\n const opened = await input.openImport?.(path).catch(() => null)\n const doc = opened ? parseImported(opened) : null\n return opened && doc ? { input: opened, doc } : null\n}\n\n/**\n * The documents `doc` imports, opened through `input`, which `doc` was read from, and named as\n * `doc` names them, with the documents they import in turn. `at` is `doc`'s path from the document\n * being opened; `reading` holds the host's names for the documents importing `doc`, so a document\n * importing itself through others, the opened one included, is left out where it comes round.\n * Imports are opened one after another, so a document many import is opened and read once.\n */\nasync function loadImports(\n doc: PenDocument,\n input: ReadDocumentInput,\n read: ImportRead,\n at: string,\n reading: ReadonlySet<string>\n): Promise<LoadedImports> {\n const loaded: LoadedImports = { imports: new Map(), opened: new Map() }\n for (const [alias, path] of Object.entries(doc.imports ?? {})) {\n const shown = importPath(at, path)\n if (!input.openImport) {\n read.unresolved.add('no-file-access', shown)\n continue\n }\n if (reading.size > MAX_IMPORT_DEPTH) continue\n let opened = read.opened.get(shown)\n if (opened === undefined) {\n opened = await openImported(input, path)\n read.opened.set(shown, opened)\n }\n if (!opened) {\n read.unresolved.add('unreadable', shown)\n continue\n }\n const name = opened.input.name ?? shown\n if (reading.has(name)) continue\n let nested = read.loaded.get(name)\n if (!nested) {\n nested = await loadImports(opened.doc, opened.input, read, shown, new Set([...reading, name]))\n read.loaded.set(name, nested)\n }\n loaded.imports.set(alias, importedDocument(alias, path, opened.doc, nested.imports))\n loaded.opened.set(alias, { input: opened.input, imports: nested.opened })\n }\n return loaded\n}\n\n/**\n * The documents `doc` imports, opened through `input`, which `doc` was read from, with the\n * documents they import in turn. An import the host cannot open or that is no `.pen` document is\n * left out and reported to `unresolved`, by its path as `doc` writes it, or for an import's own\n * imports as it resolves from `doc`. The host's name for `doc` is the path its imports resolve\n * to, so an import that leads back to it is recognized.\n */\nexport function loadPenImports(\n doc: PenDocument,\n input: ReadDocumentInput,\n unresolved: UnresolvedImports\n): Promise<LoadedImports> {\n const read: ImportRead = { unresolved, opened: new Map(), loaded: new Map() }\n return loadImports(doc, input, read, '', new Set([input.name ?? '']))\n}\n\n/**\n * The bytes of an image an imported document draws, by the name `buildPenGraph` reads it with,\n * read beside the document that names it; null when no import has it or the host cannot read it.\n */\nexport async function readImportedImage(\n opened: ReadonlyMap<string, OpenedImport>,\n url: string\n): Promise<Uint8Array | null> {\n const parsed = parseImportedImageURL(url)\n const source = parsed ? opened.get(parsed.alias) : undefined\n if (!parsed || !source) return null\n if (parseImportedImageURL(parsed.url)) return readImportedImage(source.imports, parsed.url)\n return (await source.input.readAsset?.(parsed.url).catch(() => null)) ?? null\n}\n"],"mappings":";;;;AAaA,MAAM,mBAAmB;AAgBzB,MAAM,qBAA+D,CACnE,kBACA,YACF;;AAGA,IAAa,oBAAb,MAA+B;CAC7B,SAAsE;EACpE,kCAAkB,IAAI,IAAI;EAC1B,4BAAY,IAAI,IAAI;CACtB;CAEA,IAAI,QAAuC,MAAoB;EAC7D,KAAKA,OAAO,OAAO,CAAC,IAAI,IAAI;CAC9B;CAEA,WAAkC;EAChC,OAAO,mBAAmB,SAAS,WAAW;GAC5C,MAAM,QAAQ,KAAKA,OAAO;GAC1B,OAAO,MAAM,OAAO,IAAI,CAAC;IAAE,MAAM;IAAsB;IAAQ,OAAO,CAAC,GAAG,KAAK;GAAE,CAAC,IAAI,CAAC;EACzF,CAAC;CACH;AACF;;AAGA,SAAS,cAAc,OAA8C;CACnE,IAAI;EACF,OAAO,iBAAiB,IAAI,YAAY,CAAC,CAAC,OAAO,MAAM,IAAI,CAAC;CAC9D,QAAQ;EACN,OAAO;CACT;AACF;;;;;AAkBA,SAAS,WAAW,IAAY,MAAsB;CACpD,OAAO,OAAO,MAAM,WAAW,IAAI,IAAI,OAAO,KAAK,QAAQ,EAAE,GAAG,IAAI;AACtE;AAEA,eAAe,aAAa,OAA0B,MAAuC;CAC3F,MAAM,SAAS,MAAM,MAAM,aAAa,IAAI,CAAC,CAAC,YAAY,IAAI;CAC9D,MAAM,MAAM,SAAS,cAAc,MAAM,IAAI;CAC7C,OAAO,UAAU,MAAM;EAAE,OAAO;EAAQ;CAAI,IAAI;AAClD;;;;;;;;AASA,eAAe,YACb,KACA,OACA,MACA,IACA,SACwB;CACxB,MAAM,SAAwB;EAAE,yBAAS,IAAI,IAAI;EAAG,wBAAQ,IAAI,IAAI;CAAE;CACtE,KAAK,MAAM,CAAC,OAAO,SAAS,OAAO,QAAQ,IA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AU,CAAC,QAAQ,OAAO;CAC/B,IAAI,sBAAsB,OAAO,GAAG,GAAG,OAAO,kBAAkB,OAAO,SAAS,OAAO,GAAG;CAC1F,OAAQ,MAAM,OAAO,MAAM,YAAY,OAAO,GAAG,CAAC,CAAC,YAAY,IAAI,KAAM;AAC3E"}
1
+ {"version":3,"file":"imports.js","names":["#paths"],"sources":["../../../../src/io/formats/pen/imports.ts"],"sourcesContent":["import { dirname, isAbsolute, join } from 'pathe'\n\nimport {\n importedDocument,\n parseImportedImageURL,\n parsePenDocument,\n type PenDocument,\n type PenImport\n} from '@pairdraw/pen'\n\nimport type { ReadDocumentInput, ReadDocumentWarning } from '#core/io/types'\n\n/** How deep a chain of documents importing one another is read: sixteen documents. */\nconst MAX_IMPORT_DEPTH = 16\n\n/** A document read for another that imports it, with the documents it imports in turn. */\nexport interface OpenedImport {\n input: ReadDocumentInput\n imports: ReadonlyMap<string, OpenedImport>\n}\n\n/** The documents a document imports, read, by the alias it names each one with. */\nexport interface LoadedImports {\n /** As `buildPenGraph` takes them. */\n imports: Map<string, PenImport>\n /** As the host gave them, to read their files with. */\n opened: Map<string, OpenedImport>\n}\n\ntype UnresolvedReason = Extract<ReadDocumentWarning, { kind: 'unresolved-imports' }>['reason']\n\nconst UNRESOLVED_REASONS: readonly UnresolvedReason[] = ['no-file-access', 'unreadable']\n\n/** The imports a document opened without, by why. */\nexport class UnresolvedImports {\n readonly #paths: Record<UnresolvedReason, Set<string>> = {\n 'no-file-access': new Set(),\n unreadable: new Set()\n }\n\n add(reason: UnresolvedReason, path: string): void {\n this.#paths[reason].add(path)\n }\n\n warnings(): ReadDocumentWarning[] {\n return UNRESOLVED_REASONS.flatMap((reason) => {\n const paths = this.#paths[reason]\n return paths.size > 0 ? [{ kind: 'unresolved-imports', reason, paths: [...paths] }] : []\n })\n }\n}\n\n/** A document the host opened, or null for one that is no `.pen` document. */\nfunction parseImported(input: ReadDocumentInput): PenDocument | null {\n try {\n return parsePenDocument(new TextDecoder().decode(input.data))\n } catch {\n return null\n }\n}\n\n/** An import the host opened, or null for one it could not open or that is no `.pen` document. */\ntype OpenedDocument = { input: ReadDocumentInput; doc: PenDocument } | null\n\n/** What one read of a document and its imports shares across every document it reads. */\ninterface ImportRead {\n unresolved: UnresolvedImports\n /** Each import by its path from the document being opened, so the host opens a file once. */\n opened: Map<string, OpenedDocument>\n /** The imports of each document read, by the host's name for it, so each is read once. */\n loaded: Map<string, LoadedImports>\n}\n\n/**\n * The path an import is named by in warnings, from the document being opened: as that document\n * writes it for its own imports, and as the import resolves from there for its imports' imports.\n */\nfunction importPath(at: string, path: string): string {\n return at === '' || isAbsolute(path) ? path : join(dirname(at), path)\n}\n\nasync function openImported(input: ReadDocumentInput, path: string): Promise<OpenedDocument> {\n const opened = await input.openImport?.(path).catch(() => null)\n const doc = opened ? parseImported(opened) : null\n return opened && doc ? { input: opened, doc } : null\n}\n\n/**\n * The documents `doc` imports, opened through `input`, which `doc` was read from, and named as\n * `doc` names them, with the documents they import in turn. `at` is `doc`'s path from the document\n * being opened; `reading` holds the host's names for the documents importing `doc`, so a document\n * importing itself through others, the opened one included, is left out where it comes round.\n * Imports are opened one after another, so a document many import is opened and read once.\n */\nasync function loadImports(\n doc: PenDocument,\n input: ReadDocumentInput,\n read: ImportRead,\n at: string,\n reading: ReadonlySet<string>\n): Promise<LoadedImports> {\n const loaded: LoadedImports = { imports: new Map(), opened: new Map() }\n for (const [alias, path] of Object.entries(doc.imports ?? {})) {\n const shown = importPath(at, path)\n if (!input.openImport) {\n read.unresolved.add('no-file-access', shown)\n continue\n }\n if (reading.size > MAX_IMPORT_DEPTH) continue\n let opened = read.opened.get(shown)\n if (opened === undefined) {\n opened = await openImported(input, path)\n read.opened.set(shown, opened)\n }\n if (!opened) {\n read.unresolved.add('unreadable', shown)\n continue\n }\n const name = opened.input.name ?? shown\n if (reading.has(name)) continue\n let nested = read.loaded.get(name)\n if (!nested) {\n nested = await loadImports(opened.doc, opened.input, read, shown, new Set([...reading, name]))\n read.loaded.set(name, nested)\n }\n loaded.imports.set(alias, importedDocument(alias, path, opened.doc, nested.imports))\n loaded.opened.set(alias, { input: opened.input, imports: nested.opened })\n }\n return loaded\n}\n\n/**\n * The documents `doc` imports, opened through `input`, which `doc` was read from, with the\n * documents they import in turn. An import the host cannot open or that is no `.pen` document is\n * left out and reported to `unresolved`, by its path as `doc` writes it, or for an import's own\n * imports as it resolves from `doc`. The host's name for `doc` is the path its imports resolve\n * to, so an import that leads back to it is recognized.\n */\nexport function loadPenImports(\n doc: PenDocument,\n input: ReadDocumentInput,\n unresolved: UnresolvedImports\n): Promise<LoadedImports> {\n const read: ImportRead = { unresolved, opened: new Map(), loaded: new Map() }\n return loadImports(doc, input, read, '', new Set([input.name ?? '']))\n}\n\n/**\n * The bytes of an image an imported document draws, by the name `buildPenGraph` reads it with,\n * read beside the document that names it; null when no import has it or the host cannot read it.\n */\nexport async function readImportedImage(\n opened: ReadonlyMap<string, OpenedImport>,\n url: string\n): Promise<Uint8Array | null> {\n const parsed = parseImportedImageURL(url)\n const source = parsed ? opened.get(parsed.alias) : undefined\n if (!parsed || !source) return null\n if (parseImportedImageURL(parsed.url)) return readImportedImage(source.imports, parsed.url)\n return (await source.input.readAsset?.(parsed.url).catch(() => null)) ?? null\n}\n"],"mappings":";;;;AAaA,MAAM,mBAAmB;AAkBzB,MAAM,qBAAkD,CAAC,kBAAkB,YAAY;;AAGvF,IAAa,oBAAb,MAA+B;CAC7B,SAAyD;EACvD,kCAAkB,IAAI,IAAI;EAC1B,4BAAY,IAAI,IAAI;CACtB;CAEA,IAAI,QAA0B,MAAoB;EAChD,KAAKA,OAAO,OAAO,CAAC,IAAI,IAAI;CAC9B;CAEA,WAAkC;EAChC,OAAO,mBAAmB,SAAS,WAAW;GAC5C,MAAM,QAAQ,KAAKA,OAAO;GAC1B,OAAO,MAAM,OAAO,IAAI,CAAC;IAAE,MAAM;IAAsB;IAAQ,OAAO,CAAC,GAAG,KAAK;GAAE,CAAC,IAAI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M,YAAY,OAAO,KAAK,OAAO,OAAO,MAAM,uBAAO,IAAI,IAAI,CAAC,GAAG,SAAS,IAAI,CAAC,CAAC;GAC7F,KAAK,OAAO,IAAI,MAAM,MAAM;EAC9B;EACA,OAAO,QAAQ,IAAI,OAAO,iBAAiB,OAAO,MAAM,OAAO,KAAK,OAAO,OAAO,CAAC;EACnF,OAAO,OAAO,IAAI,OAAO;GAAE,OAAO,OAAO;GAAO,SAAS,OAAO;EAAO,CAAC;CAC1E;CACA,OAAO;AACT;;;;;;;;AASA,SAAgB,eACd,KACA,OACA,YACwB;CAExB,OAAO,YAAY,KAAK,OAAO;EADJ;EAAY,wBAAQ,IAAI,IAAI;EAAG,wBAAQ,IAAI,IAAI;CACxC,GAAG,oBAAI,IAAI,IAAI,CAAC,MAAM,QAAQ,EAAE,CAAC,CAAC;AACtE;;;;;AAMA,eAAsB,kBACpB,QACA,KAC4B;CAC5B,MAAM,SAAS,sBAAsB,GAAG;CACxC,MAAM,SAAS,SAAS,OAAO,IAAI,OAAO,KAAK,IAAI,KAAA;CACnD,IAAI,CAAC,UAAU,CAAC,QAAQ,OAAO;CAC/B,IAAI,sBAAsB,OAAO,GAAG,GAAG,OAAO,kBAAkB,OAAO,SAAS,OAAO,GAAG;CAC1F,OAAQ,MAAM,OAAO,MAAM,YAAY,OAAO,GAAG,CAAC,CAAC,YAAY,IAAI,KAAM;AAC3E"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../../../src/io/formats/pen/index.ts"],"mappings":";;cAmIa,WAAW"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../../../src/io/formats/pen/index.ts"],"mappings":";;cAoJa,WAAW"}
@@ -8,6 +8,15 @@ import { buildPenGraph, isDataURL, parseImportedImageURL, parsePenDocument, penA
8
8
  //#region src/io/formats/pen/index.ts
9
9
  /** The size icons are fetched at; each is scaled to the box it is drawn in. */
10
10
  const PEN_ICON_SIZE = 24;
11
+ /** How many names one warning lists, so a broken document cannot flood the host's notice. */
12
+ const WARNING_NAMES = 10;
13
+ /** One warning for the names found, capped, or none when nothing was found. */
14
+ function warningList(kind, field, names) {
15
+ return names.size > 0 ? [{
16
+ kind,
17
+ [field]: [...names].slice(0, WARNING_NAMES)
18
+ }] : [];
19
+ }
11
20
  /**
12
21
  * The path a percent-encoded image URL names, decoded one step at a time: a step that would become
13
22
  * a separator or a parent keeps its escape, so a URL cannot name a file outside its folder.
@@ -49,13 +58,19 @@ async function loadPenShaders(urls, input, opened) {
49
58
  }));
50
59
  return shaders;
51
60
  }
61
+ /** The images the host has, and the URLs it does not, whose paints are dropped. */
52
62
  async function loadPenImages(urls, input, opened) {
53
63
  const images = /* @__PURE__ */ new Map();
64
+ const missing = /* @__PURE__ */ new Set();
54
65
  await Promise.all(urls.map(async (url) => {
55
66
  const bytes = await loadPenFile(url, input, opened);
56
67
  if (bytes) images.set(url, bytes);
68
+ else missing.add(url);
57
69
  }));
58
- return images;
70
+ return {
71
+ images,
72
+ missing
73
+ };
59
74
  }
60
75
  /** A request's options as a key, so requests drawn the same way share a fetch. */
61
76
  const optionsKey = (options) => JSON.stringify(options ?? null);
@@ -96,9 +111,12 @@ const penFormat = {
96
111
  async readDocument(input, context) {
97
112
  const doc = parsePenDocument(new TextDecoder().decode(input.data));
98
113
  const unresolved = new UnresolvedImports();
114
+ const unknownVariables = /* @__PURE__ */ new Set();
115
+ const unknownNodes = /* @__PURE__ */ new Set();
99
116
  const { imports, opened } = await loadPenImports(doc, input, unresolved);
117
+ const importsIncomplete = unresolved.warnings().length > 0;
100
118
  const assets = penAssets(withUsedImports(doc, imports));
101
- const [images, shaders, icons, fonts] = await Promise.all([
119
+ const [{ images, missing }, shaders, icons, fonts] = await Promise.all([
102
120
  loadPenImages(assets.images, input, opened),
103
121
  loadPenShaders(assets.shaders, input, opened),
104
122
  loadPenIcons(assets.icons, context?.icons ?? defaultIcons),
@@ -110,9 +128,19 @@ const penFormat = {
110
128
  icons,
111
129
  fonts,
112
130
  imports,
131
+ onUnknownVariable: (name) => {
132
+ if (name.includes(":") && importsIncomplete) return;
133
+ unknownVariables.add(name);
134
+ },
135
+ onUnknownNodeType: (type) => unknownNodes.add(type),
113
136
  layout: (target) => layoutAuthoredNodes(target, target.getPages(true).map((page) => page.id))
114
137
  });
115
- const warnings = unresolved.warnings();
138
+ const warnings = [
139
+ ...unresolved.warnings(),
140
+ ...warningList("unknown-variable", "names", unknownVariables),
141
+ ...warningList("missing-image", "urls", missing),
142
+ ...warningList("unknown-node", "types", unknownNodes)
143
+ ];
116
144
  return warnings.length > 0 ? {
117
145
  graph,
118
146
  sourceFormat: "pen",
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../../src/io/formats/pen/index.ts"],"sourcesContent":["import { groupBy } from 'es-toolkit'\n\nimport {\n buildPenGraph,\n isDataURL,\n parseImportedImageURL,\n parsePenDocument,\n penAssets,\n withUsedImports,\n writePenDocument,\n type PenIconRequest,\n type PenIconSource\n} from '@pairdraw/pen'\n\nimport { defaultIcons, drawIcon, type IconData, type IconProvider } from '#core/icons'\nimport type { IOFormatAdapter, ReadDocumentInput } from '#core/io/types'\nimport { layoutAuthoredNodes } from '#core/layout'\n\nimport { loadPenFonts } from './fonts'\nimport { loadPenImports, readImportedImage, UnresolvedImports, type OpenedImport } from './imports'\n\n/** The size icons are fetched at; each is scaled to the box it is drawn in. */\nconst PEN_ICON_SIZE = 24\n\n/**\n * The path a percent-encoded image URL names, decoded one step at a time: a step that would become\n * a separator or a parent keeps its escape, so a URL cannot name a file outside its folder.\n */\nfunction decodeAssetPath(url: string): string {\n return url\n .split('/')\n .map((segment) => {\n let decoded: string\n try {\n decoded = decodeURIComponent(segment)\n } catch {\n return segment\n }\n if (decoded === '.' || decoded === '..') return segment\n return decoded.replaceAll('/', '%2F').replaceAll('\\\\', '%5C')\n })\n .join('/')\n}\n\n/**\n * An image's bytes: a data URL decoded by the platform's own URL handling, an imported document's\n * file beside that document, and any other file through the host; null when that fails.\n */\nasync function loadPenFile(\n url: string,\n input: ReadDocumentInput,\n opened: ReadonlyMap<string, OpenedImport>\n): Promise<Uint8Array | null> {\n try {\n if (parseImportedImageURL(url)) return await readImportedImage(opened, url)\n // pen.dev writes the path percent-encoded, as `My%20Design-assets/…`.\n if (!isDataURL(url)) return (await input.readAsset?.(decodeAssetPath(url))) ?? null\n // Through `URL`, which lowercases the scheme for runtimes that only fetch `data:`.\n return new Uint8Array(await (await fetch(new URL(url))).arrayBuffer())\n } catch {\n return null\n }\n}\n\n/**\n * The shader files the document's paints and effects name, as their source text. One whose file the\n * host cannot read is left out, so its shader draws nothing rather than an empty frame.\n */\nasync function loadPenShaders(\n urls: readonly string[],\n input: ReadDocumentInput,\n opened: ReadonlyMap<string, OpenedImport>\n): Promise<Map<string, string>> {\n const shaders = new Map<string, string>()\n await Promise.all(\n urls.map(async (url) => {\n const bytes = await loadPenFile(url, input, opened)\n if (bytes) shaders.set(url, new TextDecoder().decode(bytes))\n })\n )\n return shaders\n}\n\nasync function loadPenImages(\n urls: readonly string[],\n input: ReadDocumentInput,\n opened: ReadonlyMap<string, OpenedImport>\n): Promise<Map<string, Uint8Array>> {\n const images = new Map<string, Uint8Array>()\n await Promise.all(\n urls.map(async (url) => {\n const bytes = await loadPenFile(url, input, opened)\n if (bytes) images.set(url, bytes)\n })\n )\n return images\n}\n\n/** A request's options as a key, so requests drawn the same way share a fetch. */\nconst optionsKey = (options: Record<string, number> | undefined) => JSON.stringify(options ?? null)\n\n/**\n * Icons from `provider`, fetched once for each way they are drawn; a document whose icons cannot\n * be fetched opens with empty icons.\n */\nasync function loadPenIcons(\n requests: readonly PenIconRequest[],\n provider: IconProvider\n): Promise<PenIconSource> {\n const glyphs = new Map<string, IconData>()\n const byOptions = groupBy(requests, (request) => optionsKey(request.options))\n await Promise.all(\n Object.values(byOptions).map(async (group) => {\n const names = group.map((request) => request.name)\n const found = await provider\n .icons(names, PEN_ICON_SIZE, group[0]?.options)\n .catch(() => new Map<string, IconData>())\n for (const [name, icon] of found)\n glyphs.set(`${name}\\0${optionsKey(group[0]?.options)}`, icon)\n })\n )\n return {\n draw(graph, frameId, name, size, color, options) {\n const icon = glyphs.get(`${name}\\0${optionsKey(options)}`)\n if (!icon) return false\n drawIcon(graph, frameId, icon, size, color)\n return true\n }\n }\n}\n\nexport const penFormat: IOFormatAdapter<'pen'> = {\n id: 'pen',\n label: 'Pencil Document',\n role: 'interchange-document',\n category: 'document',\n extensions: ['pen'],\n mimeTypes: ['application/json', 'text/plain'],\n support: {\n readDocument: true,\n writeDocument: true\n },\n laysOutOnRead: true,\n matchesFile(fileName, mimeType) {\n return fileName.toLowerCase().endsWith('.pen') || mimeType === 'application/json'\n },\n async readDocument(input, context) {\n const doc = parsePenDocument(new TextDecoder().decode(input.data))\n // The libraries it imports, whose components it uses draw as library components; what the host\n // cannot read draws as placeholders the warnings tell the host about.\n const unresolved = new UnresolvedImports()\n const { imports, opened } = await loadPenImports(doc, input, unresolved)\n const assets = penAssets(withUsedImports(doc, imports))\n const [images, shaders, icons, fonts] = await Promise.all([\n loadPenImages(assets.images, input, opened),\n loadPenShaders(assets.shaders, input, opened),\n loadPenIcons(assets.icons, context?.icons ?? defaultIcons),\n loadPenFonts(doc.fonts ?? [], (url) => loadPenFile(url, input, opened))\n ])\n // A .pen file stores its layout intent, not the sizes and positions it implies; the hidden\n // library page's components are laid out too, as instances of them copy their layers.\n const graph = buildPenGraph(doc, {\n images,\n shaders,\n icons,\n fonts,\n imports,\n layout: (target) =>\n layoutAuthoredNodes(\n target,\n target.getPages(true).map((page) => page.id)\n )\n })\n const warnings = unresolved.warnings()\n return warnings.length > 0\n ? { graph, sourceFormat: 'pen', warnings }\n : { graph, sourceFormat: 'pen' }\n },\n async writeDocument(graph) {\n return {\n format: 'pen',\n mimeType: 'application/json',\n extension: 'pen',\n data: writePenDocument(graph),\n encoding: 'utf8'\n }\n }\n}\n"],"mappings":";;;;;;;;;AAsBA,MAAM,gBAAgB;;;;;AAMtB,SA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AAQ,SAAS,OAAO,SAAS,MAAM,QAAQ,IAAI;GACxD,cAAc,OAAO,QAAQ,OAAO,MAAM;GAC1C,eAAe,OAAO,SAAS,OAAO,MAAM;GAC5C,aAAa,OAAO,OAAO,SAAS,SAAS,YAAY;GACzD,aAAa,IAAI,SAAS,CAAC,IAAI,QAAQ,YAAY,KAAK,OAAO,MAAM,CAAC;EACxE,CAAC;EAGD,MAAM,QAAQ,cAAc,KAAK;GAC/B;GACA;GACA;GACA;GACA;GACA,SAAS,WACP,oBACE,QACA,OAAO,SAAS,IAAI,CAAC,CAAC,KAAK,SAAS,KAAK,EAAE,CAC7C;EACJ,CAAC;EACD,MAAM,WAAW,WAAW,SAAS;EACrC,OAAO,SAAS,SAAS,IACrB;GAAE;GAAO,cAAc;GAAO;EAAS,IACvC;GAAE;GAAO,cAAc;EAAM;CACnC;CACA,MAAM,cAAc,OAAO;EACzB,OAAO;GACL,QAAQ;GACR,UAAU;GACV,WAAW;GACX,MAAM,iBAAiB,KAAK;GAC5B,UAAU;EACZ;CACF;AACF"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../../src/io/formats/pen/index.ts"],"sourcesContent":["import { groupBy } from 'es-toolkit'\n\nimport {\n buildPenGraph,\n isDataURL,\n parseImportedImageURL,\n parsePenDocument,\n penAssets,\n withUsedImports,\n writePenDocument,\n type PenIconRequest,\n type PenIconSource\n} from '@pairdraw/pen'\n\nimport { defaultIcons, drawIcon, type IconData, type IconProvider } from '#core/icons'\nimport type { IOFormatAdapter, ReadDocumentInput, ReadDocumentWarning } from '#core/io/types'\nimport { layoutAuthoredNodes } from '#core/layout'\n\nimport { loadPenFonts } from './fonts'\nimport { loadPenImports, readImportedImage, UnresolvedImports, type OpenedImport } from './imports'\n\n/** The size icons are fetched at; each is scaled to the box it is drawn in. */\nconst PEN_ICON_SIZE = 24\n\n/** How many names one warning lists, so a broken document cannot flood the host's notice. */\nconst WARNING_NAMES = 10\n\n/** One warning for the names found, capped, or none when nothing was found. */\nfunction warningList<K extends 'unknown-variable' | 'missing-image' | 'unknown-node'>(\n kind: K,\n field: K extends 'unknown-variable' ? 'names' : K extends 'missing-image' ? 'urls' : 'types',\n names: ReadonlySet<string>\n): ReadDocumentWarning[] {\n return names.size > 0\n ? [{ kind, [field]: [...names].slice(0, WARNING_NAMES) } as ReadDocumentWarning]\n : []\n}\n\n/**\n * The path a percent-encoded image URL names, decoded one step at a time: a step that would become\n * a separator or a parent keeps its escape, so a URL cannot name a file outside its folder.\n */\nfunction decodeAssetPath(url: string): string {\n return url\n .split('/')\n .map((segment) => {\n let decoded: string\n try {\n decoded = decodeURIComponent(segment)\n } catch {\n return segment\n }\n if (decoded === '.' || decoded === '..') return segment\n return decoded.replaceAll('/', '%2F').replaceAll('\\\\', '%5C')\n })\n .join('/')\n}\n\n/**\n * An image's bytes: a data URL decoded by the platform's own URL handling, an imported document's\n * file beside that document, and any other file through the host; null when that fails.\n */\nasync function loadPenFile(\n url: string,\n input: ReadDocumentInput,\n opened: ReadonlyMap<string, OpenedImport>\n): Promise<Uint8Array | null> {\n try {\n if (parseImportedImageURL(url)) return await readImportedImage(opened, url)\n // pen.dev writes the path percent-encoded, as `My%20Design-assets/…`.\n if (!isDataURL(url)) return (await input.readAsset?.(decodeAssetPath(url))) ?? null\n // Through `URL`, which lowercases the scheme for runtimes that only fetch `data:`.\n return new Uint8Array(await (await fetch(new URL(url))).arrayBuffer())\n } catch {\n return null\n }\n}\n\n/**\n * The shader files the document's paints and effects name, as their source text. One whose file the\n * host cannot read is left out, so its shader draws nothing rather than an empty frame.\n */\nasync function loadPenShaders(\n urls: readonly string[],\n input: ReadDocumentInput,\n opened: ReadonlyMap<string, OpenedImport>\n): Promise<Map<string, string>> {\n const shaders = new Map<string, string>()\n await Promise.all(\n urls.map(async (url) => {\n const bytes = await loadPenFile(url, input, opened)\n if (bytes) shaders.set(url, new TextDecoder().decode(bytes))\n })\n )\n return shaders\n}\n\n/** The images the host has, and the URLs it does not, whose paints are dropped. */\nasync function loadPenImages(\n urls: readonly string[],\n input: ReadDocumentInput,\n opened: ReadonlyMap<string, OpenedImport>\n): Promise<{ images: Map<string, Uint8Array>; missing: Set<string> }> {\n const images = new Map<string, Uint8Array>()\n const missing = new Set<string>()\n await Promise.all(\n urls.map(async (url) => {\n const bytes = await loadPenFile(url, input, opened)\n if (bytes) images.set(url, bytes)\n else missing.add(url)\n })\n )\n return { images, missing }\n}\n\n/** A request's options as a key, so requests drawn the same way share a fetch. */\nconst optionsKey = (options: Record<string, number> | undefined) => JSON.stringify(options ?? null)\n\n/**\n * Icons from `provider`, fetched once for each way they are drawn; a document whose icons cannot\n * be fetched opens with empty icons.\n */\nasync function loadPenIcons(\n requests: readonly PenIconRequest[],\n provider: IconProvider\n): Promise<PenIconSource> {\n const glyphs = new Map<string, IconData>()\n const byOptions = groupBy(requests, (request) => optionsKey(request.options))\n await Promise.all(\n Object.values(byOptions).map(async (group) => {\n const names = group.map((request) => request.name)\n const found = await provider\n .icons(names, PEN_ICON_SIZE, group[0]?.options)\n .catch(() => new Map<string, IconData>())\n for (const [name, icon] of found)\n glyphs.set(`${name}\\0${optionsKey(group[0]?.options)}`, icon)\n })\n )\n return {\n draw(graph, frameId, name, size, color, options) {\n const icon = glyphs.get(`${name}\\0${optionsKey(options)}`)\n if (!icon) return false\n drawIcon(graph, frameId, icon, size, color)\n return true\n }\n }\n}\n\nexport const penFormat: IOFormatAdapter<'pen'> = {\n id: 'pen',\n label: 'Pencil Document',\n role: 'interchange-document',\n category: 'document',\n extensions: ['pen'],\n mimeTypes: ['application/json', 'text/plain'],\n support: {\n readDocument: true,\n writeDocument: true\n },\n laysOutOnRead: true,\n matchesFile(fileName, mimeType) {\n return fileName.toLowerCase().endsWith('.pen') || mimeType === 'application/json'\n },\n async readDocument(input, context) {\n const doc = parsePenDocument(new TextDecoder().decode(input.data))\n // The libraries it imports, whose components it uses draw as library components; what the host\n // cannot read draws as placeholders the warnings tell the host about.\n const unresolved = new UnresolvedImports()\n const unknownVariables = new Set<string>()\n const unknownNodes = new Set<string>()\n const { imports, opened } = await loadPenImports(doc, input, unresolved)\n const importsIncomplete = unresolved.warnings().length > 0\n const assets = penAssets(withUsedImports(doc, imports))\n const [{ images, missing }, shaders, icons, fonts] = await Promise.all([\n loadPenImages(assets.images, input, opened),\n loadPenShaders(assets.shaders, input, opened),\n loadPenIcons(assets.icons, context?.icons ?? defaultIcons),\n loadPenFonts(doc.fonts ?? [], (url) => loadPenFile(url, input, opened))\n ])\n // A .pen file stores its layout intent, not the sizes and positions it implies; the hidden\n // library page's components are laid out too, as instances of them copy their layers.\n const graph = buildPenGraph(doc, {\n images,\n shaders,\n icons,\n fonts,\n imports,\n onUnknownVariable: (name) => {\n // A variable of a library that opened without its own imports is covered by that warning.\n if (name.includes(':') && importsIncomplete) return\n unknownVariables.add(name)\n },\n onUnknownNodeType: (type) => unknownNodes.add(type),\n layout: (target) =>\n layoutAuthoredNodes(\n target,\n target.getPages(true).map((page) => page.id)\n )\n })\n const warnings: ReadDocumentWarning[] = [\n ...unresolved.warnings(),\n ...warningList('unknown-variable', 'names', unknownVariables),\n ...warningList('missing-image', 'urls', missing),\n ...warningList('unknown-node', 'types', unknownNodes)\n ]\n return warnings.length > 0\n ? { graph, sourceFormat: 'pen', warnings }\n : { graph, sourceFormat: 'pen' }\n },\n async writeDocument(graph) {\n return {\n format: 'pen',\n mimeType: 'application/json',\n extension: 'pen',\n data: writePenDocument(graph),\n encoding: 'utf8'\n }\n }\n}\n"],"mappings":";;;;;;;;;AAsBA,MAAM,gBAAgB;;AAGtB,MAAM,gBAAgB;;AAGtB,SAAS,YACP,MACA,OACA,OACuB;CACvB,OAAO,MAAM,OAAO,IAChB,CAAC;EAAE;GAAO,QAAQ,CAAC,GAAG,KAAK,CAAC,CAAC,MAAM,GAAG,aAAa;CAAE,CAAwB,IAC7E,CAAC;AACP;;;;;AAMA,SAAS,gBAAgB,KAAqB;CAC5C,OAAO,IACJ,MAAM,GAAG,CAAC,CACV,KAAK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AO,UAAU;EACvE,MAAM,oBAAoB,WAAW,SAAS,CAAC,CAAC,SAAS;EACzD,MAAM,SAAS,UAAU,gBAAgB,KAAK,OAAO,CAAC;EACtD,MAAM,CAAC,EAAE,QAAQ,WAAW,SAAS,OAAO,SAAS,MAAM,QAAQ,IAAI;GACrE,cAAc,OAAO,QAAQ,OAAO,MAAM;GAC1C,eAAe,OAAO,SAAS,OAAO,MAAM;GAC5C,aAAa,OAAO,OAAO,SAAS,SAAS,YAAY;GACzD,aAAa,IAAI,SAAS,CAAC,IAAI,QAAQ,YAAY,KAAK,OAAO,MAAM,CAAC;EACxE,CAAC;EAGD,MAAM,QAAQ,cAAc,KAAK;GAC/B;GACA;GACA;GACA;GACA;GACA,oBAAoB,SAAS;IAE3B,IAAI,KAAK,SAAS,GAAG,KAAK,mBAAmB;IAC7C,iBAAiB,IAAI,IAAI;GAC3B;GACA,oBAAoB,SAAS,aAAa,IAAI,IAAI;GAClD,SAAS,WACP,oBACE,QACA,OAAO,SAAS,IAAI,CAAC,CAAC,KAAK,SAAS,KAAK,EAAE,CAC7C;EACJ,CAAC;EACD,MAAM,WAAkC;GACtC,GAAG,WAAW,SAAS;GACvB,GAAG,YAAY,oBAAoB,SAAS,gBAAgB;GAC5D,GAAG,YAAY,iBAAiB,QAAQ,OAAO;GAC/C,GAAG,YAAY,gBAAgB,SAAS,YAAY;EACtD;EACA,OAAO,SAAS,SAAS,IACrB;GAAE;GAAO,cAAc;GAAO;EAAS,IACvC;GAAE;GAAO,cAAc;EAAM;CACnC;CACA,MAAM,cAAc,OAAO;EACzB,OAAO;GACL,QAAQ;GACR,UAAU;GACV,WAAW;GACX,MAAM,iBAAiB,KAAK;GAC5B,UAAU;EACZ;CACF;AACF"}
@@ -3,8 +3,8 @@ import { hasUnsupportedTransform, inch, nodeBox, nodeScale, pt, transformNodeVec
3
3
  import { makeIsolatedRasterize } from "./rasterize.js";
4
4
  import { fromUint8Array } from "js-base64";
5
5
  import { getWorldMatrix } from "@pairdraw/scene-graph/coordinate";
6
- import { lineHeightPixels, textLengthPixels } from "@pairdraw/scene-graph/text";
7
6
  import Matrix from "@pairdraw/scene-graph/matrix";
7
+ import { lineHeightPixels, textLengthPixels } from "@pairdraw/scene-graph/text";
8
8
  //#region src/io/formats/pptx/export.ts
9
9
  /**
10
10
  * Scene graph → editable PPTX hybrid conversion.
@@ -1,5 +1,5 @@
1
- import { SceneGraph, SceneNode } from "@pairdraw/scene-graph";
2
1
  import { Mat3 } from "@pairdraw/scene-graph/matrix";
2
+ import { SceneGraph, SceneNode } from "@pairdraw/scene-graph";
3
3
  import { Vector } from "@pairdraw/scene-graph/primitives";
4
4
  //#region src/io/formats/pptx/geometry.d.ts
5
5
  interface PPTXGeometryContext {
@@ -0,0 +1,15 @@
1
+ import { SkiaRenderer } from "../../../canvas/renderer.js";
2
+ import { CanvasKit } from "canvaskit-wasm";
3
+ import { SceneGraph } from "@pairdraw/scene-graph";
4
+ //#region src/io/formats/raster/adjusted-images.d.ts
5
+ /** Whether any paint under `nodeIds` is an image with adjustments the vector formats must bake. */
6
+ declare function hasAdjustedImagePaints(graph: SceneGraph, nodeIds: readonly string[]): boolean;
7
+ /**
8
+ * The graph with every adjusted image paint replaced by the PNG the raster pipeline draws for it
9
+ * at the image's own size, so a vector format embeds the adjusted pixels instead of the untouched
10
+ * bytes. The original graph is not changed: nodes and images are copied, the rest is shared.
11
+ */
12
+ declare function bakeAdjustedImages(graph: SceneGraph, nodeIds: readonly string[], canvasKit?: CanvasKit, renderer?: SkiaRenderer): Promise<SceneGraph>;
13
+ //#endregion
14
+ export { bakeAdjustedImages, hasAdjustedImagePaints };
15
+ //# sourceMappingURL=adjusted-images.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adjusted-images.d.ts","names":[],"sources":["../../../../src/io/formats/raster/adjusted-images.ts"],"mappings":";;;;;iBAsCgB,uBAAuB,OAAO,YAAY;;;;;;iBAuBpC,mBACpB,OAAO,YACP,4BACA,YAAY,WACZ,WAAW,eACV,QAAQ"}
@@ -0,0 +1,118 @@
1
+ import { getCanvasKit } from "../../../canvaskit.js";
2
+ import { renderNodesToImage } from "./render.js";
3
+ import { hasImageAdjustments } from "../../../canvas/images/adjustments.js";
4
+ import { headlessRenderNodes } from "./headless.js";
5
+ import { SceneGraph } from "@pairdraw/scene-graph";
6
+ import { computeImageHash } from "@pairdraw/scene-graph/images";
7
+ //#region src/io/formats/raster/adjusted-images.ts
8
+ /** The paints of a node that are images with adjustments a vector format must bake. */
9
+ function adjustedPaints(node) {
10
+ return [...node.fills ?? [], ...node.strokes ?? []].filter((paint) => paint.type === "IMAGE" && !!paint.imageHash && hasImageAdjustments(paint.filters));
11
+ }
12
+ /** Every node under `nodeIds`, each once. */
13
+ function subtree(graph, nodeIds) {
14
+ const pending = [...nodeIds];
15
+ const seen = /* @__PURE__ */ new Set();
16
+ const nodes = [];
17
+ while (pending.length > 0) {
18
+ const id = pending.pop();
19
+ if (id === void 0 || seen.has(id)) continue;
20
+ seen.add(id);
21
+ const node = graph.getNode(id);
22
+ if (!node) continue;
23
+ nodes.push(node);
24
+ pending.push(...node.childIds);
25
+ }
26
+ return nodes;
27
+ }
28
+ /** Whether any paint under `nodeIds` is an image with adjustments the vector formats must bake. */
29
+ function hasAdjustedImagePaints(graph, nodeIds) {
30
+ return subtree(graph, nodeIds).some((node) => adjustedPaints(node).length > 0);
31
+ }
32
+ function bakedHash(paint, baked) {
33
+ if (paint.type !== "IMAGE" || !hasImageAdjustments(paint.filters) || !paint.imageHash) return null;
34
+ return baked.get(`${paint.imageHash}:${JSON.stringify(paint.filters)}`) ?? null;
35
+ }
36
+ /** `paint` drawing its baked PNG with no adjustments left, when one was baked for it. */
37
+ function withBakedImage(paint, baked) {
38
+ const hash = bakedHash(paint, baked);
39
+ if (!hash || paint.type !== "IMAGE") return paint;
40
+ const copy = {
41
+ ...paint,
42
+ imageHash: hash
43
+ };
44
+ delete copy.filters;
45
+ return copy;
46
+ }
47
+ /**
48
+ * The graph with every adjusted image paint replaced by the PNG the raster pipeline draws for it
49
+ * at the image's own size, so a vector format embeds the adjusted pixels instead of the untouched
50
+ * bytes. The original graph is not changed: nodes and images are copied, the rest is shared.
51
+ */
52
+ async function bakeAdjustedImages(graph, nodeIds, canvasKit, renderer) {
53
+ const ck = canvasKit ?? await getCanvasKit();
54
+ const baked = /* @__PURE__ */ new Map();
55
+ const pngs = /* @__PURE__ */ new Map();
56
+ for (const node of subtree(graph, nodeIds)) for (const paint of adjustedPaints(node)) {
57
+ if (paint.type !== "IMAGE" || !paint.imageHash || !hasImageAdjustments(paint.filters)) continue;
58
+ const key = `${paint.imageHash}:${JSON.stringify(paint.filters)}`;
59
+ if (baked.has(key)) continue;
60
+ const source = graph.images.get(paint.imageHash);
61
+ if (!source) continue;
62
+ const decoded = ck.MakeImageFromEncoded(source);
63
+ if (!decoded) continue;
64
+ const width = decoded.width();
65
+ const height = decoded.height();
66
+ decoded.delete();
67
+ const temp = new SceneGraph();
68
+ temp.images.set(paint.imageHash, source);
69
+ const pageId = temp.getPages()[0].id;
70
+ const layer = temp.createNode("RECTANGLE", pageId, {
71
+ width,
72
+ height,
73
+ fills: [{
74
+ ...paint,
75
+ imageScaleMode: "FILL",
76
+ opacity: 1,
77
+ visible: true
78
+ }]
79
+ });
80
+ let png;
81
+ if (renderer) {
82
+ renderer.invalidateAllPictures();
83
+ await renderer.prepareForExport(temp, pageId, [layer.id]);
84
+ png = renderNodesToImage(ck, renderer, temp, pageId, [layer.id], {
85
+ scale: 1,
86
+ format: "PNG"
87
+ });
88
+ } else png = await headlessRenderNodes(temp, pageId, [layer.id], {
89
+ scale: 1,
90
+ format: "PNG"
91
+ }, ck);
92
+ if (!png) continue;
93
+ const hash = computeImageHash(png);
94
+ pngs.set(hash, png);
95
+ baked.set(key, hash);
96
+ }
97
+ if (baked.size === 0) return graph;
98
+ const clone = Object.create(SceneGraph.prototype);
99
+ Object.assign(clone, graph);
100
+ clone.images = new Map(graph.images);
101
+ for (const [hash, png] of pngs) clone.images.set(hash, png);
102
+ clone.nodes = /* @__PURE__ */ new Map();
103
+ for (const [id, node] of graph.nodes) {
104
+ const fills = node.fills.map((paint) => withBakedImage(paint, baked));
105
+ const strokes = node.strokes.map((paint) => withBakedImage(paint, baked));
106
+ const changed = fills.some((paint, i) => paint !== node.fills[i]) || strokes.some((paint, i) => paint !== node.strokes[i]);
107
+ clone.nodes.set(id, changed ? {
108
+ ...node,
109
+ fills,
110
+ strokes
111
+ } : node);
112
+ }
113
+ return clone;
114
+ }
115
+ //#endregion
116
+ export { bakeAdjustedImages, hasAdjustedImagePaints };
117
+
118
+ //# sourceMappingURL=adjusted-images.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adjusted-images.js","names":[],"sources":["../../../../src/io/formats/raster/adjusted-images.ts"],"sourcesContent":["import type { CanvasKit } from 'canvaskit-wasm'\n\nimport { SceneGraph, type Fill, type Stroke } from '@pairdraw/scene-graph'\nimport { computeImageHash } from '@pairdraw/scene-graph/images'\n\nimport { hasImageAdjustments } from '#core/canvas/images/adjustments'\nimport type { SkiaRenderer } from '#core/canvas/renderer'\nimport { getCanvasKit } from '#core/canvaskit'\n\nimport { headlessRenderNodes } from './headless'\nimport { renderNodesToImage } from './render'\n\n/** The paints of a node that are images with adjustments a vector format must bake. */\nfunction adjustedPaints(node: { fills?: Fill[]; strokes?: Stroke[] }): (Fill | Stroke)[] {\n return [...(node.fills ?? []), ...(node.strokes ?? [])].filter(\n (paint): paint is Fill | Stroke =>\n paint.type === 'IMAGE' && !!paint.imageHash && hasImageAdjustments(paint.filters)\n )\n}\n\n/** Every node under `nodeIds`, each once. */\nfunction subtree(graph: SceneGraph, nodeIds: readonly string[]) {\n const pending = [...nodeIds]\n const seen = new Set<string>()\n const nodes = []\n while (pending.length > 0) {\n const id = pending.pop()\n if (id === undefined || seen.has(id)) continue\n seen.add(id)\n const node = graph.getNode(id)\n if (!node) continue\n nodes.push(node)\n pending.push(...node.childIds)\n }\n return nodes\n}\n\n/** Whether any paint under `nodeIds` is an image with adjustments the vector formats must bake. */\nexport function hasAdjustedImagePaints(graph: SceneGraph, nodeIds: readonly string[]): boolean {\n return subtree(graph, nodeIds).some((node) => adjustedPaints(node).length > 0)\n}\n\nfunction bakedHash(paint: Fill | Stroke, baked: Map<string, string>): string | null {\n if (paint.type !== 'IMAGE' || !hasImageAdjustments(paint.filters) || !paint.imageHash) return null\n return baked.get(`${paint.imageHash}:${JSON.stringify(paint.filters)}`) ?? null\n}\n\n/** `paint` drawing its baked PNG with no adjustments left, when one was baked for it. */\nfunction withBakedImage<P extends Fill | Stroke>(paint: P, baked: Map<string, string>): P {\n const hash = bakedHash(paint, baked)\n if (!hash || paint.type !== 'IMAGE') return paint\n const copy = { ...paint, imageHash: hash }\n delete copy.filters\n return copy\n}\n\n/**\n * The graph with every adjusted image paint replaced by the PNG the raster pipeline draws for it\n * at the image's own size, so a vector format embeds the adjusted pixels instead of the untouched\n * bytes. The original graph is not changed: nodes and images are copied, the rest is shared.\n */\nexport async function bakeAdjustedImages(\n graph: SceneGraph,\n nodeIds: readonly string[],\n canvasKit?: CanvasKit,\n renderer?: SkiaRenderer\n): Promise<SceneGraph> {\n const ck = canvasKit ?? (await getCanvasKit())\n const baked = new Map<string, string>()\n const pngs = new Map<string, Uint8Array>()\n for (const node of subtree(graph, nodeIds)) {\n for (const paint of adjustedPaints(node)) {\n if (paint.type !== 'IMAGE' || !paint.imageHash || !hasImageAdjustments(paint.filters))\n continue\n const key = `${paint.imageHash}:${JSON.stringify(paint.filters)}`\n if (baked.has(key)) continue\n const source = graph.images.get(paint.imageHash)\n if (!source) continue\n const decoded = ck.MakeImageFromEncoded(source)\n if (!decoded) continue\n const width = decoded.width()\n const height = decoded.height()\n decoded.delete()\n const temp = new SceneGraph()\n temp.images.set(paint.imageHash, source)\n const pageId = temp.getPages()[0].id\n const layer = temp.createNode('RECTANGLE', pageId, {\n width,\n height,\n fills: [{ ...paint, imageScaleMode: 'FILL', opacity: 1, visible: true }]\n })\n let png: Uint8Array | null\n if (renderer) {\n renderer.invalidateAllPictures()\n await renderer.prepareForExport(temp, pageId, [layer.id])\n png = renderNodesToImage(ck, renderer, temp, pageId, [layer.id], {\n scale: 1,\n format: 'PNG'\n })\n } else {\n png = await headlessRenderNodes(temp, pageId, [layer.id], { scale: 1, format: 'PNG' }, ck)\n }\n if (!png) continue\n const hash = computeImageHash(png)\n pngs.set(hash, png)\n baked.set(key, hash)\n }\n }\n if (baked.size === 0) return graph\n\n const clone = Object.create(SceneGraph.prototype) as SceneGraph\n Object.assign(clone, graph)\n clone.images = new Map(graph.images)\n for (const [hash, png] of pngs) clone.images.set(hash, png)\n clone.nodes = new Map()\n for (const [id, node] of graph.nodes) {\n const fills = node.fills.map((paint) => withBakedImage(paint, baked))\n const strokes = node.strokes.map((paint) => withBakedImage(paint, baked))\n const changed =\n fills.some((paint, i) => paint !== node.fills[i]) ||\n strokes.some((paint, i) => paint !== node.strokes[i])\n clone.nodes.set(id, changed ? { ...node, fills, strokes } : node)\n }\n return clone\n}\n"],"mappings":";;;;;;;;AAaA,SAAS,eAAe,MAAiE;CACvF,OAAO,CAAC,GAAI,KAAK,SAAS,CAAC,GAAI,GAAI,KAAK,WAAW,CAAC,CAAE,CAAC,CAAC,QACrD,UACC,MAAM,SAAS,WAAW,CAAC,CAAC,MAAM,aAAa,oBAAoB,MAAM,OAAO,CACpF;AACF;;AAGA,SAAS,QAAQ,OAAmB,SAA4B;CAC9D,MAAM,UAAU,CAAC,GAAG,OAAO;CAC3B,MAAM,uBAAO,IAAI,IAAY;CAC7B,MAAM,QAAQ,CAAC;CACf,OAAO,QAAQ,SAAS,GAAG;EACzB,MAAM,KAAK,QAAQ,IAAI;EACvB,IAAI,OAAO,KAAA,KAAa,KAAK,IAAI,EAAE,GAAG;EACtC,KAAK,IAAI,EAAE;EACX,MAAM,OAAO,MAAM,QAAQ,EAAE;EAC7B,IAAI,CAAC,MAAM;EACX,MAAM,KAAK,IAAI;EACf,QAAQ,KA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