@pairdraw/core 0.18.0 → 0.19.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (912) hide show
  1. package/dist/canvas/effects.d.ts +5 -11
  2. package/dist/canvas/effects.d.ts.map +1 -1
  3. package/dist/canvas/effects.js +25 -30
  4. package/dist/canvas/effects.js.map +1 -1
  5. package/dist/canvas/labels/hit-test.d.ts +5 -0
  6. package/dist/canvas/labels/hit-test.d.ts.map +1 -1
  7. package/dist/canvas/labels/hit-test.js +1 -1
  8. package/dist/canvas/labels/hit-test.js.map +1 -1
  9. package/dist/canvas/labels/paragraph-cache.d.ts.map +1 -1
  10. package/dist/canvas/labels/paragraph-cache.js +3 -2
  11. package/dist/canvas/labels/paragraph-cache.js.map +1 -1
  12. package/dist/canvas/labels/selection.js +3 -2
  13. package/dist/canvas/labels/selection.js.map +1 -1
  14. package/dist/canvas/labels/style.d.ts +1 -1
  15. package/dist/canvas/node-edit-overlay.js +2 -2
  16. package/dist/canvas/node-edit-overlay.js.map +1 -1
  17. package/dist/canvas/overlays/index.d.ts +2 -2
  18. package/dist/canvas/overlays/index.js +2 -2
  19. package/dist/canvas/overlays/selection.d.ts +1 -2
  20. package/dist/canvas/overlays/selection.d.ts.map +1 -1
  21. package/dist/canvas/overlays/selection.js +4 -37
  22. package/dist/canvas/overlays/selection.js.map +1 -1
  23. package/dist/canvas/region-hatch.js +3 -2
  24. package/dist/canvas/region-hatch.js.map +1 -1
  25. package/dist/canvas/renderer/colors.d.ts.map +1 -1
  26. package/dist/canvas/renderer/colors.js +36 -18
  27. package/dist/canvas/renderer/colors.js.map +1 -1
  28. package/dist/canvas/renderer/font-waiters.d.ts +9 -0
  29. package/dist/canvas/renderer/font-waiters.d.ts.map +1 -0
  30. package/dist/canvas/renderer/font-waiters.js +26 -0
  31. package/dist/canvas/renderer/font-waiters.js.map +1 -0
  32. package/dist/canvas/renderer/fonts.d.ts +4 -2
  33. package/dist/canvas/renderer/fonts.d.ts.map +1 -1
  34. package/dist/canvas/renderer/fonts.js +23 -9
  35. package/dist/canvas/renderer/fonts.js.map +1 -1
  36. package/dist/canvas/renderer/lifecycle.d.ts.map +1 -1
  37. package/dist/canvas/renderer/lifecycle.js +6 -9
  38. package/dist/canvas/renderer/lifecycle.js.map +1 -1
  39. package/dist/canvas/renderer/methods.d.ts +4 -5
  40. package/dist/canvas/renderer/methods.d.ts.map +1 -1
  41. package/dist/canvas/renderer/methods.js +1 -4
  42. package/dist/canvas/renderer/methods.js.map +1 -1
  43. package/dist/canvas/renderer/paints.d.ts.map +1 -1
  44. package/dist/canvas/renderer/paints.js +0 -6
  45. package/dist/canvas/renderer/paints.js.map +1 -1
  46. package/dist/canvas/renderer/pipeline.d.ts.map +1 -1
  47. package/dist/canvas/renderer/pipeline.js +20 -2
  48. package/dist/canvas/renderer/pipeline.js.map +1 -1
  49. package/dist/canvas/renderer/retained-backing.js +4 -4
  50. package/dist/canvas/renderer/retained-backing.js.map +1 -1
  51. package/dist/canvas/renderer/state.js +1 -1
  52. package/dist/canvas/renderer/state.js.map +1 -1
  53. package/dist/canvas/renderer/tiles/controller.d.ts +2 -0
  54. package/dist/canvas/renderer/tiles/controller.d.ts.map +1 -1
  55. package/dist/canvas/renderer/tiles/controller.js +8 -0
  56. package/dist/canvas/renderer/tiles/controller.js.map +1 -1
  57. package/dist/canvas/renderer/tiles/surface-pool.js +1 -1
  58. package/dist/canvas/renderer/tiles/surface-pool.js.map +1 -1
  59. package/dist/canvas/renderer/visual-bounds.d.ts.map +1 -1
  60. package/dist/canvas/renderer/visual-bounds.js +7 -5
  61. package/dist/canvas/renderer/visual-bounds.js.map +1 -1
  62. package/dist/canvas/renderer.d.ts +22 -7
  63. package/dist/canvas/renderer.d.ts.map +1 -1
  64. package/dist/canvas/renderer.js +46 -11
  65. package/dist/canvas/renderer.js.map +1 -1
  66. package/dist/canvas/rulers.d.ts +8 -1
  67. package/dist/canvas/rulers.d.ts.map +1 -1
  68. package/dist/canvas/rulers.js +30 -5
  69. package/dist/canvas/rulers.js.map +1 -1
  70. package/dist/canvas/scene.d.ts +2 -1
  71. package/dist/canvas/scene.d.ts.map +1 -1
  72. package/dist/canvas/scene.js +30 -18
  73. package/dist/canvas/scene.js.map +1 -1
  74. package/dist/canvas/shadows/shape.js +1 -1
  75. package/dist/canvas/shadows/shape.js.map +1 -1
  76. package/dist/canvas/shadows/silhouette.d.ts.map +1 -1
  77. package/dist/canvas/shadows/silhouette.js +4 -2
  78. package/dist/canvas/shadows/silhouette.js.map +1 -1
  79. package/dist/canvas/shadows.d.ts.map +1 -1
  80. package/dist/canvas/shadows.js +3 -2
  81. package/dist/canvas/shadows.js.map +1 -1
  82. package/dist/canvas/text/derived.d.ts +1 -2
  83. package/dist/canvas/text/derived.d.ts.map +1 -1
  84. package/dist/canvas/text/derived.js +1 -7
  85. package/dist/canvas/text/derived.js.map +1 -1
  86. package/dist/canvas/text/emoji/index.js +1 -1
  87. package/dist/canvas/text/emoji/raster.d.ts.map +1 -1
  88. package/dist/canvas/text/emoji/raster.js +14 -10
  89. package/dist/canvas/text/emoji/raster.js.map +1 -1
  90. package/dist/canvas/text/font-families.d.ts.map +1 -1
  91. package/dist/canvas/text/font-families.js +5 -2
  92. package/dist/canvas/text/font-families.js.map +1 -1
  93. package/dist/canvas/text/index.d.ts +1 -3
  94. package/dist/canvas/text/index.d.ts.map +1 -1
  95. package/dist/canvas/text/index.js +1 -8
  96. package/dist/canvas/text/index.js.map +1 -1
  97. package/dist/canvas/text/layout/build.d.ts.map +1 -1
  98. package/dist/canvas/text/layout/build.js +25 -9
  99. package/dist/canvas/text/layout/build.js.map +1 -1
  100. package/dist/canvas/text/layout/index.d.ts.map +1 -1
  101. package/dist/canvas/text/layout/index.js +8 -4
  102. package/dist/canvas/text/layout/index.js.map +1 -1
  103. package/dist/canvas/text/layout/lines.js +5 -3
  104. package/dist/canvas/text/layout/lines.js.map +1 -1
  105. package/dist/canvas/text/paragraph/index.d.ts +5 -0
  106. package/dist/canvas/text/paragraph/index.d.ts.map +1 -1
  107. package/dist/canvas/text/paragraph/index.js +16 -7
  108. package/dist/canvas/text/paragraph/index.js.map +1 -1
  109. package/dist/canvas/text/paragraph/inputs.d.ts +1 -1
  110. package/dist/canvas/text/paragraph/inputs.d.ts.map +1 -1
  111. package/dist/canvas/text/paragraph/inputs.js +9 -2
  112. package/dist/canvas/text/paragraph/inputs.js.map +1 -1
  113. package/dist/canvas/text/placed.js +1 -1
  114. package/dist/canvas/text/shape.d.ts +4 -3
  115. package/dist/canvas/text/shape.d.ts.map +1 -1
  116. package/dist/canvas/text/shape.js +9 -22
  117. package/dist/canvas/text/shape.js.map +1 -1
  118. package/dist/constants.d.ts +6 -2
  119. package/dist/constants.d.ts.map +1 -1
  120. package/dist/constants.js +6 -2
  121. package/dist/constants.js.map +1 -1
  122. package/dist/editor/bridges/clipboard.d.ts +1 -0
  123. package/dist/editor/bridges/clipboard.js +1 -0
  124. package/dist/editor/bridges/clipboard.js.map +1 -1
  125. package/dist/editor/bridges/components.d.ts +2 -0
  126. package/dist/editor/bridges/components.d.ts.map +1 -1
  127. package/dist/editor/bridges/components.js +2 -0
  128. package/dist/editor/bridges/components.js.map +1 -1
  129. package/dist/editor/bridges/frames.d.ts +4 -3
  130. package/dist/editor/bridges/frames.d.ts.map +1 -1
  131. package/dist/editor/bridges/frames.js +6 -4
  132. package/dist/editor/bridges/frames.js.map +1 -1
  133. package/dist/editor/bridges/structure.d.ts +1 -0
  134. package/dist/editor/bridges/structure.d.ts.map +1 -1
  135. package/dist/editor/bridges/structure.js +1 -0
  136. package/dist/editor/bridges/structure.js.map +1 -1
  137. package/dist/editor/clipboard/detach.js +2 -2
  138. package/dist/editor/clipboard/detach.js.map +1 -1
  139. package/dist/editor/clipboard/paste/properties.js +1 -1
  140. package/dist/editor/clipboard/paste/target.js +2 -2
  141. package/dist/editor/clipboard/paste/target.js.map +1 -1
  142. package/dist/editor/clipboard/snapshot.d.ts +3 -0
  143. package/dist/editor/clipboard/snapshot.d.ts.map +1 -1
  144. package/dist/editor/clipboard/snapshot.js +2 -0
  145. package/dist/editor/clipboard/snapshot.js.map +1 -1
  146. package/dist/editor/clipboard/variables.d.ts.map +1 -1
  147. package/dist/editor/clipboard/variables.js +14 -1
  148. package/dist/editor/clipboard/variables.js.map +1 -1
  149. package/dist/editor/clipboard.d.ts +1 -0
  150. package/dist/editor/clipboard.d.ts.map +1 -1
  151. package/dist/editor/clipboard.js +122 -16
  152. package/dist/editor/clipboard.js.map +1 -1
  153. package/dist/editor/component-sync.d.ts +10 -1
  154. package/dist/editor/component-sync.d.ts.map +1 -1
  155. package/dist/editor/component-sync.js +25 -8
  156. package/dist/editor/component-sync.js.map +1 -1
  157. package/dist/editor/components/authoring/text-edit.d.ts.map +1 -1
  158. package/dist/editor/components/authoring/text-edit.js +11 -2
  159. package/dist/editor/components/authoring/text-edit.js.map +1 -1
  160. package/dist/editor/components/authoring/visibility-edit.d.ts.map +1 -1
  161. package/dist/editor/components/authoring/visibility-edit.js +7 -3
  162. package/dist/editor/components/authoring/visibility-edit.js.map +1 -1
  163. package/dist/editor/components/instances.d.ts +2 -0
  164. package/dist/editor/components/instances.d.ts.map +1 -1
  165. package/dist/editor/components/instances.js +37 -7
  166. package/dist/editor/components/instances.js.map +1 -1
  167. package/dist/editor/components/properties.d.ts.map +1 -1
  168. package/dist/editor/components/properties.js +3 -0
  169. package/dist/editor/components/properties.js.map +1 -1
  170. package/dist/editor/components/slots/authoring.js +2 -1
  171. package/dist/editor/components/slots/authoring.js.map +1 -1
  172. package/dist/editor/components.d.ts +2 -0
  173. package/dist/editor/components.d.ts.map +1 -1
  174. package/dist/editor/create.d.ts +17 -3
  175. package/dist/editor/create.d.ts.map +1 -1
  176. package/dist/editor/create.js +43 -6
  177. package/dist/editor/create.js.map +1 -1
  178. package/dist/editor/guides.d.ts.map +1 -1
  179. package/dist/editor/guides.js +20 -13
  180. package/dist/editor/guides.js.map +1 -1
  181. package/dist/editor/history/document-change.d.ts +19 -3
  182. package/dist/editor/history/document-change.d.ts.map +1 -1
  183. package/dist/editor/history/document-change.js +94 -8
  184. package/dist/editor/history/document-change.js.map +1 -1
  185. package/dist/editor/history/edit.d.ts.map +1 -1
  186. package/dist/editor/history/edit.js +56 -12
  187. package/dist/editor/history/edit.js.map +1 -1
  188. package/dist/editor/history/position.js +1 -4
  189. package/dist/editor/history/position.js.map +1 -1
  190. package/dist/editor/history/sources.d.ts +14 -0
  191. package/dist/editor/history/sources.d.ts.map +1 -0
  192. package/dist/editor/history/sources.js +24 -0
  193. package/dist/editor/history/sources.js.map +1 -0
  194. package/dist/editor/index.d.ts +2 -2
  195. package/dist/editor/index.js +1 -1
  196. package/dist/editor/layout-mode.d.ts.map +1 -1
  197. package/dist/editor/layout-mode.js +16 -1
  198. package/dist/editor/layout-mode.js.map +1 -1
  199. package/dist/editor/node-preview.d.ts.map +1 -1
  200. package/dist/editor/node-preview.js +26 -7
  201. package/dist/editor/node-preview.js.map +1 -1
  202. package/dist/editor/nodes.d.ts.map +1 -1
  203. package/dist/editor/nodes.js +33 -10
  204. package/dist/editor/nodes.js.map +1 -1
  205. package/dist/editor/nudge.d.ts.map +1 -1
  206. package/dist/editor/nudge.js +12 -2
  207. package/dist/editor/nudge.js.map +1 -1
  208. package/dist/editor/pages.d.ts +2 -1
  209. package/dist/editor/pages.d.ts.map +1 -1
  210. package/dist/editor/pages.js +94 -15
  211. package/dist/editor/pages.js.map +1 -1
  212. package/dist/editor/play/states.d.ts.map +1 -1
  213. package/dist/editor/play/states.js +0 -5
  214. package/dist/editor/play/states.js.map +1 -1
  215. package/dist/editor/read-only/actions.js +3 -0
  216. package/dist/editor/read-only/actions.js.map +1 -1
  217. package/dist/editor/selection/hit-test.d.ts +2 -1
  218. package/dist/editor/selection/hit-test.d.ts.map +1 -1
  219. package/dist/editor/selection/hit-test.js +29 -4
  220. package/dist/editor/selection/hit-test.js.map +1 -1
  221. package/dist/editor/selection.d.ts +2 -2
  222. package/dist/editor/selection.d.ts.map +1 -1
  223. package/dist/editor/shapes/pen.js +6 -2
  224. package/dist/editor/shapes/pen.js.map +1 -1
  225. package/dist/editor/shapes.d.ts.map +1 -1
  226. package/dist/editor/shapes.js +2 -1
  227. package/dist/editor/shapes.js.map +1 -1
  228. package/dist/editor/structure/auto-layout-wrap.d.ts.map +1 -1
  229. package/dist/editor/structure/auto-layout-wrap.js +12 -0
  230. package/dist/editor/structure/auto-layout-wrap.js.map +1 -1
  231. package/dist/editor/structure/boolean.js +1 -1
  232. package/dist/editor/structure/group/bounds.d.ts +4 -2
  233. package/dist/editor/structure/group/bounds.d.ts.map +1 -1
  234. package/dist/editor/structure/group/bounds.js +17 -4
  235. package/dist/editor/structure/group/bounds.js.map +1 -1
  236. package/dist/editor/structure/rename.d.ts +2 -3
  237. package/dist/editor/structure/rename.d.ts.map +1 -1
  238. package/dist/editor/structure/rename.js +2 -5
  239. package/dist/editor/structure/rename.js.map +1 -1
  240. package/dist/editor/structure/reorder.d.ts.map +1 -1
  241. package/dist/editor/structure/reorder.js +20 -9
  242. package/dist/editor/structure/reorder.js.map +1 -1
  243. package/dist/editor/structure/state.js +1 -1
  244. package/dist/editor/structure.d.ts +1 -0
  245. package/dist/editor/structure.d.ts.map +1 -1
  246. package/dist/editor/structure.js +76 -20
  247. package/dist/editor/structure.js.map +1 -1
  248. package/dist/editor/text/hyperlink.d.ts.map +1 -1
  249. package/dist/editor/text/hyperlink.js +1 -1
  250. package/dist/editor/text/hyperlink.js.map +1 -1
  251. package/dist/editor/text/name.d.ts +13 -5
  252. package/dist/editor/text/name.d.ts.map +1 -1
  253. package/dist/editor/text/name.js +47 -17
  254. package/dist/editor/text/name.js.map +1 -1
  255. package/dist/editor/text/pending-layout.d.ts +2 -1
  256. package/dist/editor/text/pending-layout.d.ts.map +1 -1
  257. package/dist/editor/text/pending-layout.js +33 -6
  258. package/dist/editor/text/pending-layout.js.map +1 -1
  259. package/dist/editor/text/selection-style.d.ts +1 -0
  260. package/dist/editor/text/selection-style.d.ts.map +1 -1
  261. package/dist/editor/text/selection-style.js +16 -4
  262. package/dist/editor/text/selection-style.js.map +1 -1
  263. package/dist/editor/text.d.ts +5 -0
  264. package/dist/editor/text.d.ts.map +1 -1
  265. package/dist/editor/text.js +70 -3
  266. package/dist/editor/text.js.map +1 -1
  267. package/dist/editor/types.d.ts +18 -1
  268. package/dist/editor/types.d.ts.map +1 -1
  269. package/dist/editor/undo.d.ts.map +1 -1
  270. package/dist/editor/undo.js +14 -2
  271. package/dist/editor/undo.js.map +1 -1
  272. package/dist/editor/variable-bindings.d.ts.map +1 -1
  273. package/dist/editor/variable-bindings.js +21 -2
  274. package/dist/editor/variable-bindings.js.map +1 -1
  275. package/dist/editor/variables.d.ts +1 -1
  276. package/dist/editor/variables.d.ts.map +1 -1
  277. package/dist/editor/variables.js +7 -8
  278. package/dist/editor/variables.js.map +1 -1
  279. package/dist/editor/viewport.d.ts +11 -2
  280. package/dist/editor/viewport.d.ts.map +1 -1
  281. package/dist/editor/viewport.js +61 -21
  282. package/dist/editor/viewport.js.map +1 -1
  283. package/dist/editor/views/actions.d.ts.map +1 -1
  284. package/dist/editor/views/actions.js +13 -5
  285. package/dist/editor/views/actions.js.map +1 -1
  286. package/dist/editor/views/present.d.ts +6 -4
  287. package/dist/editor/views/present.d.ts.map +1 -1
  288. package/dist/editor/views/present.js +12 -10
  289. package/dist/editor/views/present.js.map +1 -1
  290. package/dist/editor/views/types.d.ts +11 -5
  291. package/dist/editor/views/types.d.ts.map +1 -1
  292. package/dist/figma-api/accessor-utils.d.ts.map +1 -1
  293. package/dist/figma-api/accessor-utils.js +4 -1
  294. package/dist/figma-api/accessor-utils.js.map +1 -1
  295. package/dist/figma-api/accessors/basic.d.ts.map +1 -1
  296. package/dist/figma-api/accessors/basic.js +41 -21
  297. package/dist/figma-api/accessors/basic.js.map +1 -1
  298. package/dist/figma-api/accessors/layout.d.ts.map +1 -1
  299. package/dist/figma-api/accessors/layout.js +37 -7
  300. package/dist/figma-api/accessors/layout.js.map +1 -1
  301. package/dist/figma-api/accessors/reactions.d.ts +11 -0
  302. package/dist/figma-api/accessors/reactions.d.ts.map +1 -0
  303. package/dist/figma-api/accessors/reactions.js +30 -0
  304. package/dist/figma-api/accessors/reactions.js.map +1 -0
  305. package/dist/figma-api/accessors/strokes.d.ts.map +1 -1
  306. package/dist/figma-api/accessors/strokes.js +12 -4
  307. package/dist/figma-api/accessors/strokes.js.map +1 -1
  308. package/dist/figma-api/accessors/text/index.d.ts.map +1 -1
  309. package/dist/figma-api/accessors/text/index.js +3 -1
  310. package/dist/figma-api/accessors/text/index.js.map +1 -1
  311. package/dist/figma-api/accessors/vector.d.ts.map +1 -1
  312. package/dist/figma-api/accessors/vector.js +1 -1
  313. package/dist/figma-api/accessors/vector.js.map +1 -1
  314. package/dist/figma-api/accessors/visual.d.ts +6 -5
  315. package/dist/figma-api/accessors/visual.d.ts.map +1 -1
  316. package/dist/figma-api/accessors/visual.js +20 -17
  317. package/dist/figma-api/accessors/visual.js.map +1 -1
  318. package/dist/figma-api/components.d.ts.map +1 -1
  319. package/dist/figma-api/components.js +2 -1
  320. package/dist/figma-api/components.js.map +1 -1
  321. package/dist/figma-api/finite.d.ts +27 -0
  322. package/dist/figma-api/finite.d.ts.map +1 -0
  323. package/dist/figma-api/finite.js +69 -0
  324. package/dist/figma-api/finite.js.map +1 -0
  325. package/dist/figma-api/fonts/list.d.ts +13 -0
  326. package/dist/figma-api/fonts/list.d.ts.map +1 -0
  327. package/dist/figma-api/fonts/list.js +25 -0
  328. package/dist/figma-api/fonts/list.js.map +1 -0
  329. package/dist/figma-api/index.d.ts +21 -3
  330. package/dist/figma-api/index.d.ts.map +1 -1
  331. package/dist/figma-api/index.js +58 -13
  332. package/dist/figma-api/index.js.map +1 -1
  333. package/dist/figma-api/overrides.d.ts +6 -1
  334. package/dist/figma-api/overrides.d.ts.map +1 -1
  335. package/dist/figma-api/overrides.js +2 -2
  336. package/dist/figma-api/overrides.js.map +1 -1
  337. package/dist/figma-api/pending-layout.d.ts +12 -2
  338. package/dist/figma-api/pending-layout.d.ts.map +1 -1
  339. package/dist/figma-api/pending-layout.js +41 -1
  340. package/dist/figma-api/pending-layout.js.map +1 -1
  341. package/dist/figma-api/pending-sync.d.ts +19 -0
  342. package/dist/figma-api/pending-sync.d.ts.map +1 -0
  343. package/dist/figma-api/pending-sync.js +52 -0
  344. package/dist/figma-api/pending-sync.js.map +1 -0
  345. package/dist/figma-api/proxy.d.ts +15 -2
  346. package/dist/figma-api/proxy.d.ts.map +1 -1
  347. package/dist/figma-api/proxy.js +23 -3
  348. package/dist/figma-api/proxy.js.map +1 -1
  349. package/dist/figma-api/reactions.d.ts +104 -0
  350. package/dist/figma-api/reactions.d.ts.map +1 -0
  351. package/dist/figma-api/reactions.js +157 -0
  352. package/dist/figma-api/reactions.js.map +1 -0
  353. package/dist/figma-api/render-bounds.d.ts.map +1 -1
  354. package/dist/figma-api/render-bounds.js +4 -4
  355. package/dist/figma-api/render-bounds.js.map +1 -1
  356. package/dist/figma-api/serialization.js +2 -2
  357. package/dist/figma-api/serialization.js.map +1 -1
  358. package/dist/figma-api/slots.d.ts +7 -1
  359. package/dist/figma-api/slots.d.ts.map +1 -1
  360. package/dist/figma-api/slots.js +12 -4
  361. package/dist/figma-api/slots.js.map +1 -1
  362. package/dist/figma-api/strokes.d.ts +5 -2
  363. package/dist/figma-api/strokes.d.ts.map +1 -1
  364. package/dist/figma-api/strokes.js +12 -19
  365. package/dist/figma-api/strokes.js.map +1 -1
  366. package/dist/figma-api/text/bindings.js +1 -1
  367. package/dist/figma-api/text/index.d.ts +2 -3
  368. package/dist/figma-api/text/index.d.ts.map +1 -1
  369. package/dist/figma-api/text/index.js +2 -12
  370. package/dist/figma-api/text/index.js.map +1 -1
  371. package/dist/figma-api/variables/bindings.js +1 -1
  372. package/dist/figma-api/variables/variable.d.ts.map +1 -1
  373. package/dist/figma-api/variables/variable.js +2 -2
  374. package/dist/figma-api/variables/variable.js.map +1 -1
  375. package/dist/geometry/figma.d.ts +6 -1
  376. package/dist/geometry/figma.d.ts.map +1 -1
  377. package/dist/geometry/figma.js +8 -1
  378. package/dist/geometry/figma.js.map +1 -1
  379. package/dist/geometry/index.d.ts +2 -2
  380. package/dist/geometry/index.js +2 -2
  381. package/dist/icons/api.d.ts +3 -2
  382. package/dist/icons/api.d.ts.map +1 -1
  383. package/dist/icons/api.js +12 -12
  384. package/dist/icons/api.js.map +1 -1
  385. package/dist/icons/provider.d.ts +4 -3
  386. package/dist/icons/provider.d.ts.map +1 -1
  387. package/dist/icons/provider.js +6 -13
  388. package/dist/icons/provider.js.map +1 -1
  389. package/dist/icons/schema.d.ts +33 -1
  390. package/dist/icons/schema.d.ts.map +1 -1
  391. package/dist/icons/schema.js +30 -1
  392. package/dist/icons/schema.js.map +1 -1
  393. package/dist/icons/svg/presentation.d.ts +8 -1
  394. package/dist/icons/svg/presentation.d.ts.map +1 -1
  395. package/dist/icons/svg/presentation.js +21 -3
  396. package/dist/icons/svg/presentation.js.map +1 -1
  397. package/dist/icons/svg/text.js +1 -1
  398. package/dist/icons/svg/text.js.map +1 -1
  399. package/dist/icons/svg.d.ts +8 -3
  400. package/dist/icons/svg.d.ts.map +1 -1
  401. package/dist/icons/svg.js +15 -13
  402. package/dist/icons/svg.js.map +1 -1
  403. package/dist/icons/types.d.ts +1 -19
  404. package/dist/icons/types.d.ts.map +1 -1
  405. package/dist/index.d.ts +2 -2
  406. package/dist/index.js +1 -1
  407. package/dist/io/formats/design-tokens/css/read.js +1 -1
  408. package/dist/io/formats/design-tokens/decode.js +1 -1
  409. package/dist/io/formats/design-tokens/plan/index.js +4 -2
  410. package/dist/io/formats/design-tokens/plan/index.js.map +1 -1
  411. package/dist/io/formats/design-tokens/plan/styles.d.ts +9 -1
  412. package/dist/io/formats/design-tokens/plan/styles.d.ts.map +1 -1
  413. package/dist/io/formats/design-tokens/plan/styles.js +23 -3
  414. package/dist/io/formats/design-tokens/plan/styles.js.map +1 -1
  415. package/dist/io/formats/design-tokens/styles.d.ts +9 -1
  416. package/dist/io/formats/design-tokens/styles.d.ts.map +1 -1
  417. package/dist/io/formats/design-tokens/styles.js +41 -4
  418. package/dist/io/formats/design-tokens/styles.js.map +1 -1
  419. package/dist/io/formats/design-tokens/types.d.ts +5 -0
  420. package/dist/io/formats/design-tokens/types.d.ts.map +1 -1
  421. package/dist/io/formats/design-tokens/types.js +1 -0
  422. package/dist/io/formats/design-tokens/types.js.map +1 -1
  423. package/dist/io/formats/fig/export/setup.d.ts.map +1 -1
  424. package/dist/io/formats/fig/export/setup.js +8 -4
  425. package/dist/io/formats/fig/export/setup.js.map +1 -1
  426. package/dist/io/formats/fig/export/variables.d.ts.map +1 -1
  427. package/dist/io/formats/fig/export/variables.js +2 -2
  428. package/dist/io/formats/fig/export/variables.js.map +1 -1
  429. package/dist/io/formats/fig/index.d.ts +2 -2
  430. package/dist/io/formats/fig/index.js +2 -2
  431. package/dist/io/formats/fig/read.d.ts +9 -2
  432. package/dist/io/formats/fig/read.d.ts.map +1 -1
  433. package/dist/io/formats/fig/read.js +44 -20
  434. package/dist/io/formats/fig/read.js.map +1 -1
  435. package/dist/io/formats/html/index.d.ts.map +1 -1
  436. package/dist/io/formats/html/index.js +2 -6
  437. package/dist/io/formats/html/index.js.map +1 -1
  438. package/dist/io/formats/pdf/dom.d.ts.map +1 -1
  439. package/dist/io/formats/pdf/dom.js +65 -1
  440. package/dist/io/formats/pdf/dom.js.map +1 -1
  441. package/dist/io/formats/pdf/prepare.js +1 -1
  442. package/dist/io/formats/pen/fonts.d.ts +14 -0
  443. package/dist/io/formats/pen/fonts.d.ts.map +1 -0
  444. package/dist/io/formats/pen/fonts.js +39 -0
  445. package/dist/io/formats/pen/fonts.js.map +1 -0
  446. package/dist/io/formats/pen/index.d.ts.map +1 -1
  447. package/dist/io/formats/pen/index.js +25 -6
  448. package/dist/io/formats/pen/index.js.map +1 -1
  449. package/dist/io/formats/raster/headless.d.ts +2 -2
  450. package/dist/io/formats/raster/headless.d.ts.map +1 -1
  451. package/dist/io/formats/raster/headless.js +24 -13
  452. package/dist/io/formats/raster/headless.js.map +1 -1
  453. package/dist/io/formats/raster/index.d.ts +2 -2
  454. package/dist/io/formats/raster/index.js +2 -2
  455. package/dist/io/formats/raster/render.d.ts +7 -1
  456. package/dist/io/formats/raster/render.d.ts.map +1 -1
  457. package/dist/io/formats/raster/render.js +40 -6
  458. package/dist/io/formats/raster/render.js.map +1 -1
  459. package/dist/io/formats/svg/export.d.ts.map +1 -1
  460. package/dist/io/formats/svg/export.js +28 -24
  461. package/dist/io/formats/svg/export.js.map +1 -1
  462. package/dist/io/formats/svg/paths.d.ts +8 -2
  463. package/dist/io/formats/svg/paths.d.ts.map +1 -1
  464. package/dist/io/formats/svg/paths.js +11 -3
  465. package/dist/io/formats/svg/paths.js.map +1 -1
  466. package/dist/io/formats/svg/strokes.d.ts.map +1 -1
  467. package/dist/io/formats/svg/strokes.js +2 -5
  468. package/dist/io/formats/svg/strokes.js.map +1 -1
  469. package/dist/io/formats/svg/text/export.d.ts.map +1 -1
  470. package/dist/io/formats/svg/text/export.js +19 -1
  471. package/dist/io/formats/svg/text/export.js.map +1 -1
  472. package/dist/io/formats/svg/text/import.d.ts.map +1 -1
  473. package/dist/io/formats/svg/text/import.js +2 -1
  474. package/dist/io/formats/svg/text/import.js.map +1 -1
  475. package/dist/io/subgraph.d.ts.map +1 -1
  476. package/dist/io/subgraph.js +5 -2
  477. package/dist/io/subgraph.js.map +1 -1
  478. package/dist/kiwi/fig/population/client.d.ts.map +1 -1
  479. package/dist/kiwi/fig/population/client.js +63 -45
  480. package/dist/kiwi/fig/population/client.js.map +1 -1
  481. package/dist/kiwi/fig/population/delta.d.ts +34 -3
  482. package/dist/kiwi/fig/population/delta.d.ts.map +1 -1
  483. package/dist/kiwi/fig/population/delta.js +99 -16
  484. package/dist/kiwi/fig/population/delta.js.map +1 -1
  485. package/dist/kiwi/fig/population/edits.d.ts +51 -0
  486. package/dist/kiwi/fig/population/edits.d.ts.map +1 -0
  487. package/dist/kiwi/fig/population/edits.js +169 -0
  488. package/dist/kiwi/fig/population/edits.js.map +1 -0
  489. package/dist/kiwi/fig/session/archive/access.d.ts +3 -0
  490. package/dist/kiwi/fig/session/archive/access.d.ts.map +1 -1
  491. package/dist/kiwi/fig/session/archive/access.js +8 -1
  492. package/dist/kiwi/fig/session/archive/access.js.map +1 -1
  493. package/dist/kiwi/fig/session/archive/changes.d.ts +2 -1
  494. package/dist/kiwi/fig/session/archive/changes.d.ts.map +1 -1
  495. package/dist/kiwi/fig/session/archive/changes.js +12 -5
  496. package/dist/kiwi/fig/session/archive/changes.js.map +1 -1
  497. package/dist/kiwi/fig/session/document-state.d.ts +7 -1
  498. package/dist/kiwi/fig/session/document-state.d.ts.map +1 -1
  499. package/dist/kiwi/fig/session/document-state.js +16 -2
  500. package/dist/kiwi/fig/session/document-state.js.map +1 -1
  501. package/dist/kiwi/fig/session/protocol.d.ts +31 -3
  502. package/dist/kiwi/fig/session/protocol.d.ts.map +1 -1
  503. package/dist/kiwi/fig/session/worker.js +33 -8
  504. package/dist/kiwi/fig/session/worker.js.map +1 -1
  505. package/dist/layout/apply.d.ts +6 -1
  506. package/dist/layout/apply.d.ts.map +1 -1
  507. package/dist/layout/apply.js +39 -14
  508. package/dist/layout/apply.js.map +1 -1
  509. package/dist/layout/arrange/boxes.d.ts.map +1 -1
  510. package/dist/layout/arrange/boxes.js +31 -0
  511. package/dist/layout/arrange/boxes.js.map +1 -1
  512. package/dist/layout/flow-edges.d.ts +26 -0
  513. package/dist/layout/flow-edges.d.ts.map +1 -0
  514. package/dist/layout/flow-edges.js +105 -0
  515. package/dist/layout/flow-edges.js.map +1 -0
  516. package/dist/layout/grid.d.ts.map +1 -1
  517. package/dist/layout/grid.js +9 -5
  518. package/dist/layout/grid.js.map +1 -1
  519. package/dist/layout/text-auto-resize.d.ts.map +1 -1
  520. package/dist/layout/text-auto-resize.js +9 -4
  521. package/dist/layout/text-auto-resize.js.map +1 -1
  522. package/dist/layout/text-measurement.d.ts +15 -1
  523. package/dist/layout/text-measurement.d.ts.map +1 -1
  524. package/dist/layout/text-measurement.js +40 -4
  525. package/dist/layout/text-measurement.js.map +1 -1
  526. package/dist/layout/variables.d.ts +1 -1
  527. package/dist/layout.d.ts.map +1 -1
  528. package/dist/layout.js +35 -35
  529. package/dist/layout.js.map +1 -1
  530. package/dist/library/asset-keys.d.ts +3 -2
  531. package/dist/library/asset-keys.d.ts.map +1 -1
  532. package/dist/library/asset-keys.js +4 -3
  533. package/dist/library/asset-keys.js.map +1 -1
  534. package/dist/library/copied-references.d.ts +8 -3
  535. package/dist/library/copied-references.d.ts.map +1 -1
  536. package/dist/library/copied-references.js +15 -5
  537. package/dist/library/copied-references.js.map +1 -1
  538. package/dist/library/materialize.js +1 -1
  539. package/dist/library/materialize.js.map +1 -1
  540. package/dist/library/schema.js.map +1 -1
  541. package/dist/library/snapshot.d.ts.map +1 -1
  542. package/dist/library/snapshot.js +10 -2
  543. package/dist/library/snapshot.js.map +1 -1
  544. package/dist/pairdraw-api/variables.d.ts.map +1 -1
  545. package/dist/pairdraw-api/variables.js +0 -2
  546. package/dist/pairdraw-api/variables.js.map +1 -1
  547. package/dist/profiler/hud-controller.d.ts +4 -3
  548. package/dist/profiler/hud-controller.d.ts.map +1 -1
  549. package/dist/profiler/hud-controller.js +7 -5
  550. package/dist/profiler/hud-controller.js.map +1 -1
  551. package/dist/profiler/hud-renderer.d.ts +5 -2
  552. package/dist/profiler/hud-renderer.d.ts.map +1 -1
  553. package/dist/profiler/hud-renderer.js +8 -5
  554. package/dist/profiler/hud-renderer.js.map +1 -1
  555. package/dist/profiler/render-profiler.d.ts +3 -2
  556. package/dist/profiler/render-profiler.d.ts.map +1 -1
  557. package/dist/profiler/render-profiler.js +3 -2
  558. package/dist/profiler/render-profiler.js.map +1 -1
  559. package/dist/text/character-style.d.ts +11 -1
  560. package/dist/text/character-style.d.ts.map +1 -1
  561. package/dist/text/character-style.js +27 -5
  562. package/dist/text/character-style.js.map +1 -1
  563. package/dist/text/coverage.d.ts.map +1 -1
  564. package/dist/text/coverage.js +15 -16
  565. package/dist/text/coverage.js.map +1 -1
  566. package/dist/text/editor.d.ts.map +1 -1
  567. package/dist/text/editor.js +3 -8
  568. package/dist/text/editor.js.map +1 -1
  569. package/dist/text/fallbacks.d.ts +19 -2
  570. package/dist/text/fallbacks.d.ts.map +1 -1
  571. package/dist/text/fallbacks.js +63 -12
  572. package/dist/text/fallbacks.js.map +1 -1
  573. package/dist/text/font/catalog.d.ts +4 -0
  574. package/dist/text/font/catalog.d.ts.map +1 -1
  575. package/dist/text/font/catalog.js +8 -0
  576. package/dist/text/font/catalog.js.map +1 -1
  577. package/dist/text/font/collection.d.ts +13 -0
  578. package/dist/text/font/collection.d.ts.map +1 -0
  579. package/dist/text/font/collection.js +51 -0
  580. package/dist/text/font/collection.js.map +1 -0
  581. package/dist/text/font/faces.d.ts +2 -1
  582. package/dist/text/font/faces.d.ts.map +1 -1
  583. package/dist/text/font/faces.js +9 -5
  584. package/dist/text/font/faces.js.map +1 -1
  585. package/dist/text/font/glyphs.d.ts +14 -3
  586. package/dist/text/font/glyphs.d.ts.map +1 -1
  587. package/dist/text/font/glyphs.js +22 -5
  588. package/dist/text/font/glyphs.js.map +1 -1
  589. package/dist/text/font/local.js +2 -2
  590. package/dist/text/font/local.js.map +1 -1
  591. package/dist/text/font/manager.d.ts +36 -0
  592. package/dist/text/font/manager.d.ts.map +1 -1
  593. package/dist/text/font/manager.js +139 -19
  594. package/dist/text/font/manager.js.map +1 -1
  595. package/dist/text/font/style.d.ts +7 -2
  596. package/dist/text/font/style.d.ts.map +1 -1
  597. package/dist/text/font/style.js +31 -3
  598. package/dist/text/font/style.js.map +1 -1
  599. package/dist/text/index.d.ts +5 -4
  600. package/dist/text/index.js +5 -4
  601. package/dist/text/outlines.d.ts.map +1 -1
  602. package/dist/text/outlines.js +70 -70
  603. package/dist/text/outlines.js.map +1 -1
  604. package/dist/text/prepare.d.ts.map +1 -1
  605. package/dist/text/prepare.js +7 -1
  606. package/dist/text/prepare.js.map +1 -1
  607. package/dist/text/style-runs.d.ts +14 -2
  608. package/dist/text/style-runs.d.ts.map +1 -1
  609. package/dist/text/style-runs.js +22 -14
  610. package/dist/text/style-runs.js.map +1 -1
  611. package/dist/tools/analyze/overlaps/helpers.d.ts.map +1 -1
  612. package/dist/tools/analyze/overlaps/helpers.js +9 -1
  613. package/dist/tools/analyze/overlaps/helpers.js.map +1 -1
  614. package/dist/tools/analyze/overlaps/index.d.ts.map +1 -1
  615. package/dist/tools/analyze/overlaps/index.js +27 -5
  616. package/dist/tools/analyze/overlaps/index.js.map +1 -1
  617. package/dist/tools/codegen/component-map.js +3 -3
  618. package/dist/tools/codegen/component-map.js.map +1 -1
  619. package/dist/tools/create/basic.d.ts.map +1 -1
  620. package/dist/tools/create/basic.js +5 -4
  621. package/dist/tools/create/basic.js.map +1 -1
  622. package/dist/tools/create/html.d.ts.map +1 -1
  623. package/dist/tools/create/html.js +4 -2
  624. package/dist/tools/create/html.js.map +1 -1
  625. package/dist/tools/create/icons.d.ts.map +1 -1
  626. package/dist/tools/create/icons.js +3 -1
  627. package/dist/tools/create/icons.js.map +1 -1
  628. package/dist/tools/create/mermaid.d.ts.map +1 -1
  629. package/dist/tools/create/mermaid.js +2 -0
  630. package/dist/tools/create/mermaid.js.map +1 -1
  631. package/dist/tools/create/render.d.ts.map +1 -1
  632. package/dist/tools/create/render.js +2 -0
  633. package/dist/tools/create/render.js.map +1 -1
  634. package/dist/tools/create/script.js +3 -1
  635. package/dist/tools/create/script.js.map +1 -1
  636. package/dist/tools/create/svg.d.ts.map +1 -1
  637. package/dist/tools/create/svg.js +4 -1
  638. package/dist/tools/create/svg.js.map +1 -1
  639. package/dist/tools/create/vector.d.ts.map +1 -1
  640. package/dist/tools/create/vector.js +4 -4
  641. package/dist/tools/create/vector.js.map +1 -1
  642. package/dist/tools/image-ai/apply.js +1 -1
  643. package/dist/tools/image-ai/generate.d.ts.map +1 -1
  644. package/dist/tools/image-ai/generate.js +3 -0
  645. package/dist/tools/image-ai/generate.js.map +1 -1
  646. package/dist/tools/modify/matching.js +1 -1
  647. package/dist/tools/modify/reactions.d.ts +6 -0
  648. package/dist/tools/modify/reactions.d.ts.map +1 -0
  649. package/dist/tools/modify/reactions.js +35 -0
  650. package/dist/tools/modify/reactions.js.map +1 -0
  651. package/dist/tools/modify.d.ts +2 -1
  652. package/dist/tools/modify.js +2 -1
  653. package/dist/tools/read/components.js +20 -22
  654. package/dist/tools/read/components.js.map +1 -1
  655. package/dist/tools/read/fonts.js +1 -1
  656. package/dist/tools/read/fonts.js.map +1 -1
  657. package/dist/tools/read/libraries.d.ts.map +1 -1
  658. package/dist/tools/read/libraries.js +2 -0
  659. package/dist/tools/read/libraries.js.map +1 -1
  660. package/dist/tools/read/nodes.d.ts.map +1 -1
  661. package/dist/tools/read/nodes.js +38 -16
  662. package/dist/tools/read/nodes.js.map +1 -1
  663. package/dist/tools/read/pages.d.ts.map +1 -1
  664. package/dist/tools/read/pages.js +4 -3
  665. package/dist/tools/read/pages.js.map +1 -1
  666. package/dist/tools/read/query.js +1 -0
  667. package/dist/tools/read/query.js.map +1 -1
  668. package/dist/tools/read/reactions.d.ts +6 -0
  669. package/dist/tools/read/reactions.d.ts.map +1 -0
  670. package/dist/tools/read/reactions.js +24 -0
  671. package/dist/tools/read/reactions.js.map +1 -0
  672. package/dist/tools/read/space.js +1 -1
  673. package/dist/tools/read.d.ts +2 -1
  674. package/dist/tools/read.js +2 -1
  675. package/dist/tools/registry/extended.d.ts.map +1 -1
  676. package/dist/tools/registry/extended.js +4 -0
  677. package/dist/tools/registry/extended.js.map +1 -1
  678. package/dist/tools/schema.d.ts +6 -0
  679. package/dist/tools/schema.d.ts.map +1 -1
  680. package/dist/tools/schema.js +53 -9
  681. package/dist/tools/schema.js.map +1 -1
  682. package/dist/tools/stock-photo/apply.js +8 -9
  683. package/dist/tools/stock-photo/apply.js.map +1 -1
  684. package/dist/tools/structure/batch.d.ts.map +1 -1
  685. package/dist/tools/structure/batch.js +85 -90
  686. package/dist/tools/structure/batch.js.map +1 -1
  687. package/dist/vector/fill-geometry.d.ts +4 -1
  688. package/dist/vector/fill-geometry.d.ts.map +1 -1
  689. package/dist/vector/fill-geometry.js +8 -5
  690. package/dist/vector/fill-geometry.js.map +1 -1
  691. package/dist/vector/index.js +1 -1
  692. package/dist/vector/index.js.map +1 -1
  693. package/dist/vector/path-helpers.d.ts +1 -1
  694. package/dist/vector/path-helpers.d.ts.map +1 -1
  695. package/dist/vector/path-helpers.js +24 -7
  696. package/dist/vector/path-helpers.js.map +1 -1
  697. package/dist/vector/placement.js +1 -1
  698. package/dist/vector/placement.js.map +1 -1
  699. package/dist/vector/vectorize/preprocess.js +1 -1
  700. package/dist/vector/vectorize/preprocess.js.map +1 -1
  701. package/package.json +10 -10
  702. package/src/canvas/effects.ts +29 -33
  703. package/src/canvas/labels/hit-test.ts +6 -2
  704. package/src/canvas/labels/paragraph-cache.ts +2 -1
  705. package/src/canvas/labels/selection.ts +3 -3
  706. package/src/canvas/node-edit-overlay.ts +3 -2
  707. package/src/canvas/overlays/index.ts +0 -1
  708. package/src/canvas/overlays/selection.ts +4 -52
  709. package/src/canvas/region-hatch.ts +7 -2
  710. package/src/canvas/renderer/colors.ts +41 -26
  711. package/src/canvas/renderer/font-waiters.ts +25 -0
  712. package/src/canvas/renderer/fonts.ts +40 -17
  713. package/src/canvas/renderer/lifecycle.ts +8 -10
  714. package/src/canvas/renderer/methods.ts +9 -13
  715. package/src/canvas/renderer/paints.ts +0 -10
  716. package/src/canvas/renderer/pipeline.ts +29 -3
  717. package/src/canvas/renderer/retained-backing.ts +4 -4
  718. package/src/canvas/renderer/state.ts +1 -1
  719. package/src/canvas/renderer/tiles/controller.ts +8 -0
  720. package/src/canvas/renderer/tiles/surface-pool.ts +1 -1
  721. package/src/canvas/renderer/visual-bounds.ts +7 -6
  722. package/src/canvas/renderer.ts +39 -11
  723. package/src/canvas/rulers.ts +55 -26
  724. package/src/canvas/scene.ts +37 -16
  725. package/src/canvas/shadows/shape.ts +1 -1
  726. package/src/canvas/shadows/silhouette.ts +4 -2
  727. package/src/canvas/shadows.ts +4 -2
  728. package/src/canvas/text/derived.ts +0 -9
  729. package/src/canvas/text/emoji/raster.ts +14 -10
  730. package/src/canvas/text/font-families.ts +6 -0
  731. package/src/canvas/text/index.ts +0 -8
  732. package/src/canvas/text/layout/build.ts +35 -18
  733. package/src/canvas/text/layout/index.ts +15 -6
  734. package/src/canvas/text/layout/lines.ts +10 -4
  735. package/src/canvas/text/paragraph/index.ts +17 -8
  736. package/src/canvas/text/paragraph/inputs.ts +4 -2
  737. package/src/canvas/text/shape.ts +20 -31
  738. package/src/constants.ts +6 -1
  739. package/src/editor/bridges/clipboard.ts +1 -0
  740. package/src/editor/bridges/components.ts +2 -0
  741. package/src/editor/bridges/frames.ts +6 -4
  742. package/src/editor/bridges/structure.ts +1 -0
  743. package/src/editor/clipboard/detach.ts +3 -3
  744. package/src/editor/clipboard/paste/target.ts +2 -2
  745. package/src/editor/clipboard/snapshot.ts +7 -0
  746. package/src/editor/clipboard/variables.ts +20 -0
  747. package/src/editor/clipboard.ts +133 -14
  748. package/src/editor/component-sync.ts +28 -7
  749. package/src/editor/components/authoring/text-edit.ts +15 -2
  750. package/src/editor/components/authoring/visibility-edit.ts +11 -3
  751. package/src/editor/components/instances.ts +61 -11
  752. package/src/editor/components/properties.ts +10 -0
  753. package/src/editor/components/slots/authoring.ts +4 -1
  754. package/src/editor/create.ts +58 -8
  755. package/src/editor/guides.ts +27 -12
  756. package/src/editor/history/document-change.ts +115 -7
  757. package/src/editor/history/edit.ts +62 -14
  758. package/src/editor/history/position.ts +1 -4
  759. package/src/editor/history/sources.ts +25 -0
  760. package/src/editor/index.ts +3 -1
  761. package/src/editor/layout-mode.ts +20 -1
  762. package/src/editor/node-preview.ts +44 -8
  763. package/src/editor/nodes.ts +52 -12
  764. package/src/editor/nudge.ts +16 -2
  765. package/src/editor/pages.ts +100 -17
  766. package/src/editor/play/states.ts +0 -7
  767. package/src/editor/read-only/actions.ts +4 -0
  768. package/src/editor/selection/hit-test.ts +37 -4
  769. package/src/editor/shapes/pen.ts +6 -3
  770. package/src/editor/shapes.ts +2 -1
  771. package/src/editor/structure/auto-layout-wrap.ts +26 -0
  772. package/src/editor/structure/group/bounds.ts +22 -4
  773. package/src/editor/structure/rename.ts +2 -6
  774. package/src/editor/structure/reorder.ts +26 -8
  775. package/src/editor/structure.ts +88 -24
  776. package/src/editor/text/hyperlink.ts +2 -1
  777. package/src/editor/text/name.ts +51 -15
  778. package/src/editor/text/pending-layout.ts +42 -4
  779. package/src/editor/text/selection-style.ts +17 -3
  780. package/src/editor/text.ts +86 -4
  781. package/src/editor/types.ts +19 -0
  782. package/src/editor/undo.ts +21 -2
  783. package/src/editor/variable-bindings.ts +22 -2
  784. package/src/editor/variables.ts +10 -6
  785. package/src/editor/viewport.ts +55 -21
  786. package/src/editor/views/actions.ts +17 -7
  787. package/src/editor/views/present.ts +20 -11
  788. package/src/editor/views/types.ts +11 -5
  789. package/src/figma-api/accessor-utils.ts +4 -1
  790. package/src/figma-api/accessors/basic.ts +54 -18
  791. package/src/figma-api/accessors/layout.ts +46 -7
  792. package/src/figma-api/accessors/reactions.ts +29 -0
  793. package/src/figma-api/accessors/strokes.ts +28 -8
  794. package/src/figma-api/accessors/text/index.ts +4 -0
  795. package/src/figma-api/accessors/vector.ts +3 -1
  796. package/src/figma-api/accessors/visual.ts +25 -28
  797. package/src/figma-api/components.ts +9 -7
  798. package/src/figma-api/finite.ts +102 -0
  799. package/src/figma-api/fonts/list.ts +24 -0
  800. package/src/figma-api/index.ts +82 -12
  801. package/src/figma-api/overrides.ts +1 -1
  802. package/src/figma-api/pending-layout.ts +50 -1
  803. package/src/figma-api/pending-sync.ts +61 -0
  804. package/src/figma-api/proxy.ts +35 -2
  805. package/src/figma-api/reactions.ts +212 -0
  806. package/src/figma-api/render-bounds.ts +13 -4
  807. package/src/figma-api/serialization.ts +2 -2
  808. package/src/figma-api/slots.ts +12 -3
  809. package/src/figma-api/strokes.ts +16 -12
  810. package/src/figma-api/text/index.ts +9 -15
  811. package/src/figma-api/variables/variable.ts +3 -2
  812. package/src/geometry/figma.ts +9 -0
  813. package/src/geometry/index.ts +1 -0
  814. package/src/global.d.ts +6 -0
  815. package/src/icons/api.ts +27 -16
  816. package/src/icons/provider.ts +9 -20
  817. package/src/icons/schema.ts +31 -0
  818. package/src/icons/svg/presentation.ts +27 -3
  819. package/src/icons/svg/text.ts +1 -1
  820. package/src/icons/svg.ts +21 -19
  821. package/src/icons/types.ts +0 -14
  822. package/src/io/formats/design-tokens/plan/index.ts +7 -1
  823. package/src/io/formats/design-tokens/plan/styles.ts +40 -4
  824. package/src/io/formats/design-tokens/styles.ts +60 -3
  825. package/src/io/formats/design-tokens/types.ts +3 -0
  826. package/src/io/formats/fig/export/setup.ts +16 -14
  827. package/src/io/formats/fig/export/variables.ts +7 -8
  828. package/src/io/formats/fig/index.ts +1 -0
  829. package/src/io/formats/fig/read.ts +66 -23
  830. package/src/io/formats/html/index.ts +2 -6
  831. package/src/io/formats/pdf/dom.ts +96 -3
  832. package/src/io/formats/pen/fonts.ts +45 -0
  833. package/src/io/formats/pen/index.ts +30 -6
  834. package/src/io/formats/raster/headless.ts +31 -12
  835. package/src/io/formats/raster/index.ts +3 -0
  836. package/src/io/formats/raster/render.ts +62 -6
  837. package/src/io/formats/svg/export.ts +24 -25
  838. package/src/io/formats/svg/paths.ts +11 -2
  839. package/src/io/formats/svg/strokes.ts +8 -2
  840. package/src/io/formats/svg/text/export.ts +23 -0
  841. package/src/io/formats/svg/text/import.ts +2 -1
  842. package/src/io/subgraph.ts +3 -1
  843. package/src/kiwi/fig/population/client.ts +77 -43
  844. package/src/kiwi/fig/population/delta.ts +141 -18
  845. package/src/kiwi/fig/population/edits.ts +235 -0
  846. package/src/kiwi/fig/session/archive/access.ts +15 -0
  847. package/src/kiwi/fig/session/archive/changes.ts +27 -6
  848. package/src/kiwi/fig/session/document-state.ts +23 -1
  849. package/src/kiwi/fig/session/protocol.ts +26 -1
  850. package/src/kiwi/fig/session/worker.ts +38 -11
  851. package/src/layout/apply.ts +52 -10
  852. package/src/layout/arrange/boxes.ts +36 -0
  853. package/src/layout/flow-edges.ts +139 -0
  854. package/src/layout/grid.ts +14 -4
  855. package/src/layout/text-auto-resize.ts +13 -4
  856. package/src/layout/text-measurement.ts +46 -3
  857. package/src/layout.ts +60 -66
  858. package/src/library/asset-keys.ts +4 -3
  859. package/src/library/copied-references.ts +29 -5
  860. package/src/library/materialize.ts +1 -1
  861. package/src/library/schema.ts +1 -1
  862. package/src/library/snapshot.ts +11 -2
  863. package/src/pairdraw-api/variables.ts +1 -3
  864. package/src/profiler/hud-controller.ts +8 -6
  865. package/src/profiler/hud-renderer.ts +9 -6
  866. package/src/profiler/render-profiler.ts +4 -3
  867. package/src/text/character-style.ts +29 -9
  868. package/src/text/coverage.ts +17 -18
  869. package/src/text/editor.ts +3 -8
  870. package/src/text/fallbacks.ts +82 -15
  871. package/src/text/font/catalog.ts +10 -0
  872. package/src/text/font/collection.ts +60 -0
  873. package/src/text/font/faces.ts +9 -5
  874. package/src/text/font/glyphs.ts +29 -4
  875. package/src/text/font/local.ts +2 -2
  876. package/src/text/font/manager.ts +170 -32
  877. package/src/text/font/style.ts +52 -3
  878. package/src/text/index.ts +1 -0
  879. package/src/text/outlines.ts +105 -89
  880. package/src/text/prepare.ts +17 -0
  881. package/src/text/style-runs.ts +43 -16
  882. package/src/tools/analyze/overlaps/helpers.ts +18 -1
  883. package/src/tools/analyze/overlaps/index.ts +37 -6
  884. package/src/tools/codegen/component-map.ts +3 -3
  885. package/src/tools/create/basic.ts +6 -4
  886. package/src/tools/create/html.ts +3 -1
  887. package/src/tools/create/icons.ts +3 -1
  888. package/src/tools/create/mermaid.ts +2 -0
  889. package/src/tools/create/render.ts +2 -0
  890. package/src/tools/create/script.ts +5 -1
  891. package/src/tools/create/svg.ts +4 -1
  892. package/src/tools/create/vector.ts +4 -4
  893. package/src/tools/image-ai/generate.ts +3 -0
  894. package/src/tools/modify/reactions.ts +40 -0
  895. package/src/tools/modify.ts +1 -0
  896. package/src/tools/read/components.ts +28 -25
  897. package/src/tools/read/fonts.ts +1 -1
  898. package/src/tools/read/libraries.ts +3 -0
  899. package/src/tools/read/nodes.ts +47 -17
  900. package/src/tools/read/pages.ts +7 -4
  901. package/src/tools/read/query.ts +2 -0
  902. package/src/tools/read/reactions.ts +21 -0
  903. package/src/tools/read.ts +1 -0
  904. package/src/tools/registry/extended.ts +4 -0
  905. package/src/tools/schema.ts +68 -12
  906. package/src/tools/stock-photo/apply.ts +17 -5
  907. package/src/tools/structure/batch.ts +82 -101
  908. package/src/vector/fill-geometry.ts +11 -5
  909. package/src/vector/index.ts +1 -1
  910. package/src/vector/path-helpers.ts +34 -8
  911. package/src/vector/placement.ts +1 -1
  912. package/src/vector/vectorize/preprocess.ts +1 -1
@@ -0,0 +1,169 @@
1
+ import { settingsSnapshot } from "../session/archive/changes.js";
2
+ import { isEqual } from "es-toolkit/predicate";
3
+ //#region src/kiwi/fig/population/edits.ts
4
+ /** The page under the document holds no override maps an edit writes into in place. */
5
+ function withAncestorsBelowPage(graph, ids) {
6
+ const result = /* @__PURE__ */ new Set();
7
+ for (const id of ids) {
8
+ result.add(id);
9
+ let parentId = graph.getNode(id)?.parentId;
10
+ while (parentId && !result.has(parentId)) {
11
+ const parent = graph.getNode(parentId);
12
+ if (!parent || parent.type === "CANVAS" || parent.id === graph.rootId) break;
13
+ result.add(parentId);
14
+ parentId = parent.parentId;
15
+ }
16
+ }
17
+ return result;
18
+ }
19
+ function depthOf(graph, node) {
20
+ let depth = 0;
21
+ let parentId = node.parentId;
22
+ while (parentId) {
23
+ depth++;
24
+ parentId = graph.getNode(parentId)?.parentId ?? null;
25
+ }
26
+ return depth;
27
+ }
28
+ /**
29
+ * Sends `graph`'s edits to the reader worker as they happen, once per task. Layout a page gets
30
+ * as it loads or as its fonts arrive is not sent: the worker's copy never had it, and it reaches
31
+ * every layer of a page. Layout an edit causes is, as it is part of the edit.
32
+ *
33
+ * Variables and collections have no change observers here, so each batch diffs them against the
34
+ * state the last batch carried, as the archive tracker does.
35
+ */
36
+ function trackFigGraphEdits(graph, post) {
37
+ let revision = 0;
38
+ let ignored = 0;
39
+ let scheduled = false;
40
+ let settings = settingsSnapshot(graph);
41
+ let variables = new Map(graph.variables);
42
+ let collections = new Map(graph.variableCollections);
43
+ const pendingNodes = /* @__PURE__ */ new Set();
44
+ const sent = [];
45
+ const skip = () => ignored > 0 || graph.isApplyingDerivedLayout;
46
+ function schedule() {
47
+ if (scheduled) return;
48
+ scheduled = true;
49
+ queueMicrotask(flush);
50
+ }
51
+ function changedRecords(previous, current) {
52
+ const changed = [];
53
+ for (const [id, record] of current) if (!isEqual(previous.get(id), record)) changed.push([id, record]);
54
+ for (const id of previous.keys()) if (!current.has(id)) changed.push([id, null]);
55
+ return changed;
56
+ }
57
+ function flush() {
58
+ scheduled = false;
59
+ const nextSettings = settingsSnapshot(graph);
60
+ const settingsChanged = !isEqual(settings, nextSettings);
61
+ const variableChanges = changedRecords(variables, graph.variables);
62
+ const collectionChanges = changedRecords(collections, graph.variableCollections);
63
+ if (pendingNodes.size === 0 && variableChanges.length === 0 && collectionChanges.length === 0 && !settingsChanged) return;
64
+ const ids = withAncestorsBelowPage(graph, pendingNodes);
65
+ const nodes = [];
66
+ const removed = [];
67
+ for (const id of ids) {
68
+ const node = graph.getNode(id);
69
+ if (node) nodes.push(node);
70
+ else removed.push(id);
71
+ }
72
+ const depths = new Map(nodes.map((node) => [node.id, depthOf(graph, node)]));
73
+ nodes.sort((a, b) => (depths.get(a.id) ?? 0) - (depths.get(b.id) ?? 0));
74
+ revision++;
75
+ post({
76
+ revision,
77
+ nodes,
78
+ removed,
79
+ variables: variableChanges,
80
+ collections: collectionChanges,
81
+ ...settingsChanged ? { settings: nextSettings } : {}
82
+ });
83
+ settings = nextSettings;
84
+ variables = new Map(graph.variables);
85
+ collections = new Map(graph.variableCollections);
86
+ sent.push({
87
+ revision,
88
+ ids
89
+ });
90
+ pendingNodes.clear();
91
+ }
92
+ const touch = (id) => {
93
+ if (skip()) return;
94
+ pendingNodes.add(id);
95
+ schedule();
96
+ };
97
+ return {
98
+ get revision() {
99
+ flush();
100
+ return revision;
101
+ },
102
+ flush,
103
+ changedSince(since) {
104
+ const changed = /* @__PURE__ */ new Set();
105
+ for (const batch of sent) {
106
+ if (batch.revision <= since) continue;
107
+ for (const id of batch.ids) changed.add(id);
108
+ }
109
+ return changed;
110
+ },
111
+ forget(through) {
112
+ while (sent.length > 0 && sent[0].revision <= through) sent.shift();
113
+ },
114
+ ignoring(fn) {
115
+ ignored++;
116
+ try {
117
+ return fn();
118
+ } finally {
119
+ ignored--;
120
+ }
121
+ },
122
+ send(ids) {
123
+ for (const id of ids) pendingNodes.add(id);
124
+ if (pendingNodes.size > 0) schedule();
125
+ },
126
+ stop: graph.observeNodeChanges({
127
+ before: (node) => touch(node.id),
128
+ created: (node) => touch(node.id)
129
+ })
130
+ };
131
+ }
132
+ /**
133
+ * Brings the reader worker's graph to the main thread's state of what `edits` changed. They are
134
+ * edits there too, so pages that load afterwards reconcile their instances with them, as a page
135
+ * loading into an edited graph does on the main thread.
136
+ */
137
+ function applyFigGraphEdits(graph, edits) {
138
+ graph.preserveSourceMetadataDuring(() => {
139
+ for (const node of edits.nodes) {
140
+ const current = graph.getNode(node.id);
141
+ if (!current) {
142
+ graph.createNodeWithId(node.id, node.type, node.parentId, node);
143
+ continue;
144
+ }
145
+ const absent = Object.keys(current).filter((key) => !(key in node));
146
+ graph.restoreNodeProperties(node.id, node, absent);
147
+ }
148
+ for (const id of edits.removed) {
149
+ const node = graph.getNode(id);
150
+ if (!node) continue;
151
+ const stillInside = node.childIds.filter((childId) => graph.getNode(childId)?.parentId === id);
152
+ if (stillInside.length !== node.childIds.length) graph.restoreNodeProperties(id, { childIds: stillInside }, []);
153
+ }
154
+ for (const id of edits.removed) graph.deleteNode(id);
155
+ for (const [id, variable] of edits.variables) if (variable) graph.variables.set(id, variable);
156
+ else graph.variables.delete(id);
157
+ for (const [id, collection] of edits.collections) if (collection) graph.variableCollections.set(id, collection);
158
+ else graph.variableCollections.delete(id);
159
+ if (edits.settings) {
160
+ graph.documentColorSpace = edits.settings.colorSpace;
161
+ graph.documentKind = edits.settings.kind;
162
+ graph.enabledLibraries = new Map(edits.settings.libraries);
163
+ }
164
+ });
165
+ }
166
+ //#endregion
167
+ export { applyFigGraphEdits, trackFigGraphEdits };
168
+
169
+ //# sourceMappingURL=edits.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"edits.js","names":[],"sources":["../../../../src/kiwi/fig/population/edits.ts"],"sourcesContent":["import { isEqual } from 'es-toolkit/predicate'\n\nimport type { SceneGraph, SceneNode, Variable, VariableCollection } from '@pairdraw/scene-graph'\n\nimport { settingsSnapshot, type SettingsSnapshot } from '#core/kiwi/fig/session/archive/changes'\n\n/**\n * What edits on the main thread changed since the last batch, as the main thread now has it, for\n * the reader worker's copy of the graph: pages keep loading there after the document is edited.\n */\nexport interface FigGraphEdits {\n revision: number\n /** Whole copies of the layers added or changed, with their ancestors below the page. */\n nodes: SceneNode[]\n /** Layers the main thread no longer has. */\n removed: string[]\n /** A variable or collection the main thread no longer has is null. */\n variables: Array<[string, Variable | null]>\n collections: Array<[string, VariableCollection | null]>\n settings?: SettingsSnapshot\n}\n\nexport interface FigGraphEditTracker {\n /** The revision of the last batch sent, after sending what is pending. */\n readonly revision: number\n /** Sends what changed since the last batch, if anything did. */\n flush(): void\n /** Layers changed in batches after `revision`, including those sent with `send`. */\n changedSince(revision: number): Set<string>\n /** Forgets the layers of batches up to `revision`, which no page load is waiting on. */\n forget(revision: number): void\n /** Writes `fn` makes are the worker's own, such as a page it loaded, and are not sent. */\n ignoring<T>(fn: () => T): T\n /** Sends the main thread's state of `ids` in the next batch, as an edit would. */\n send(ids: Iterable<string>): void\n stop(): void\n}\n\n/** The page under the document holds no override maps an edit writes into in place. */\nfunction withAncestorsBelowPage(graph: SceneGraph, ids: Iterable<string>): Set<string> {\n const result = new Set<string>()\n for (const id of ids) {\n result.add(id)\n let parentId = graph.getNode(id)?.parentId\n while (parentId && !result.has(parentId)) {\n const parent = graph.getNode(parentId)\n if (!parent || parent.type === 'CANVAS' || parent.id === graph.rootId) break\n result.add(parentId)\n parentId = parent.parentId\n }\n }\n return result\n}\n\nfunction depthOf(graph: SceneGraph, node: SceneNode): number {\n let depth = 0\n let parentId = node.parentId\n while (parentId) {\n depth++\n parentId = graph.getNode(parentId)?.parentId ?? null\n }\n return depth\n}\n\n/**\n * Sends `graph`'s edits to the reader worker as they happen, once per task. Layout a page gets\n * as it loads or as its fonts arrive is not sent: the worker's copy never had it, and it reaches\n * every layer of a page. Layout an edit causes is, as it is part of the edit.\n *\n * Variables and collections have no change observers here, so each batch diffs them against the\n * state the last batch carried, as the archive tracker does.\n */\nexport function trackFigGraphEdits(\n graph: SceneGraph,\n post: (edits: FigGraphEdits) => void\n): FigGraphEditTracker {\n let revision = 0\n let ignored = 0\n let scheduled = false\n let settings = settingsSnapshot(graph)\n let variables = new Map(graph.variables)\n let collections = new Map(graph.variableCollections)\n const pendingNodes = new Set<string>()\n const sent: Array<{ revision: number; ids: Set<string> }> = []\n const skip = () => ignored > 0 || graph.isApplyingDerivedLayout\n\n function schedule() {\n if (scheduled) return\n scheduled = true\n queueMicrotask(flush)\n }\n\n function changedRecords<T>(\n previous: ReadonlyMap<string, T>,\n current: ReadonlyMap<string, T>\n ): Array<[string, T | null]> {\n const changed: Array<[string, T | null]> = []\n for (const [id, record] of current) {\n if (!isEqual(previous.get(id), record)) changed.push([id, record])\n }\n for (const id of previous.keys()) {\n if (!current.has(id)) changed.push([id, null])\n }\n return changed\n }\n\n function flush() {\n scheduled = false\n const nextSettings = settingsSnapshot(graph)\n const settingsChanged = !isEqual(settings, nextSettings)\n const variableChanges = changedRecords(variables, graph.variables)\n const collectionChanges = changedRecords(collections, graph.variableCollections)\n if (\n pendingNodes.size === 0 &&\n variableChanges.length === 0 &&\n collectionChanges.length === 0 &&\n !settingsChanged\n ) {\n return\n }\n const ids = withAncestorsBelowPage(graph, pendingNodes)\n const nodes: SceneNode[] = []\n const removed: string[] = []\n for (const id of ids) {\n const node = graph.getNode(id)\n if (node) nodes.push(node)\n else removed.push(id)\n }\n // A parent is added before the layers in it.\n const depths = new Map(nodes.map((node) => [node.id, depthOf(graph, node)]))\n nodes.sort((a, b) => (depths.get(a.id) ?? 0) - (depths.get(b.id) ?? 0))\n revision++\n post({\n revision,\n nodes,\n removed,\n variables: variableChanges,\n collections: collectionChanges,\n ...(settingsChanged ? { settings: nextSettings } : {})\n })\n settings = nextSettings\n variables = new Map(graph.variables)\n collections = new Map(graph.variableCollections)\n sent.push({ revision, ids })\n pendingNodes.clear()\n }\n\n const touch = (id: string) => {\n if (skip()) return\n pendingNodes.add(id)\n schedule()\n }\n const stopObserving = graph.observeNodeChanges({\n before: (node) => touch(node.id),\n created: (node) => touch(node.id)\n })\n // Variables, collections, and settings change without node events here; each batch diffs them\n // against the state the last one carried. A page load flushes before it asks the worker, so\n // edits made since the last batch reach it even when no layer changed.\n\n return {\n get revision() {\n flush()\n return revision\n },\n flush,\n changedSince(since) {\n const changed = new Set<string>()\n for (const batch of sent) {\n if (batch.revision <= since) continue\n for (const id of batch.ids) changed.add(id)\n }\n return changed\n },\n forget(through) {\n while (sent.length > 0 && sent[0].revision <= through) sent.shift()\n },\n ignoring(fn) {\n ignored++\n try {\n return fn()\n } finally {\n ignored--\n }\n },\n send(ids) {\n for (const id of ids) pendingNodes.add(id)\n if (pendingNodes.size > 0) schedule()\n },\n stop: stopObserving\n }\n}\n\n/**\n * Brings the reader worker's graph to the main thread's state of what `edits` changed. They are\n * edits there too, so pages that load afterwards reconcile their instances with them, as a page\n * loading into an edited graph does on the main thread.\n */\nexport function applyFigGraphEdits(graph: SceneGraph, edits: FigGraphEdits): void {\n graph.preserveSourceMetadataDuring(() => {\n for (const node of edits.nodes) {\n const current = graph.getNode(node.id)\n if (!current) {\n graph.createNodeWithId(node.id, node.type, node.parentId, node)\n continue\n }\n const absent = (Object.keys(current) as (keyof SceneNode)[]).filter((key) => !(key in node))\n graph.restoreNodeProperties(node.id, node, absent)\n }\n // A layer moved out of a removed one is already where the main thread has it; every removed\n // layer drops such links before any is removed, since removing one removes what it holds.\n for (const id of edits.removed) {\n const node = graph.getNode(id)\n if (!node) continue\n const stillInside = node.childIds.filter((childId) => graph.getNode(childId)?.parentId === id)\n if (stillInside.length !== node.childIds.length) {\n graph.restoreNodeProperties(id, { childIds: stillInside }, [])\n }\n }\n for (const id of edits.removed) graph.deleteNode(id)\n for (const [id, variable] of edits.variables) {\n if (variable) graph.variables.set(id, variable)\n else graph.variables.delete(id)\n }\n for (const [id, collection] of edits.collections) {\n if (collection) graph.variableCollections.set(id, collection)\n else graph.variableCollections.delete(id)\n }\n if (edits.settings) {\n graph.documentColorSpace = edits.settings.colorSpace\n graph.documentKind = edits.settings.kind\n graph.enabledLibraries = new Map(edits.settings.libraries)\n }\n })\n}\n"],"mappings":";;;;AAuCA,SAAS,uBAAuB,OAAmB,KAAoC;CACrF,MAAM,yBAAS,IAAI,IAAY;CAC/B,KAAK,MAAM,MAAM,KAAK;EACpB,OAAO,IAAI,EAAE;EACb,IAAI,WAAW,MAAM,QAAQ,EAAE,CAAC,EAAE;EAClC,OAAO,YAAY,CAAC,OAAO,IAAI,QAAQ,GAAG;GACxC,MAAM,SAAS,MAAM,QAAQ,QAAQ;GACrC,IAAI,CAAC,UAAU,OAAO,SAAS,YAAY,OAAO,OAAO,MAAM,QAAQ;GACvE,OAAO,IAAI,QAAQ;GACnB,WAAW,OAAO;EACpB;CACF;CACA,OAAO;AACT;AAEA,SAAS,QAAQ,OAAmB,MAAyB;CAC3D,IAAI,QAAQ;CACZ,IAAI,WAAW,KAAK;CACp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(): Promise<FigArchiveRecordInfo>;
12
12
  /** Archive GUIDs of the pages whose instances use these components. */
13
13
  componentPages(componentIds: string[]): Promise<string[]>;
14
+ /** The archive GUID of the page each record is on, `null` for one on no page. */
15
+ recordPages(recordIds: string[]): Promise<(string | null)[]>;
14
16
  patch(patch: FigRecordPatch, input: FigPatchedArchiveInput): Promise<Uint8Array>;
15
17
  /** The document closed: release whatever holds the archive. */
16
18
  close(): void;
@@ -27,6 +29,7 @@ declare function createFigArchiveOperations(bytes: ArrayBuffer, info: () => FigA
27
29
  original: () => Uint8Array<ArrayBuffer>;
28
30
  info: () => FigArchiveRecordInfo;
29
31
  componentPages: (componentIds: string[]) => string[];
32
+ recordPages: (recordIds: string[]) => (string | null)[];
30
33
  patch: (patch: FigRecordPatch, input: FigPatchedArchiveInput) => Promise<Uint8Array<ArrayBufferLike>>;
31
34
  };
32
35
  declare function localFigArchive(bytes: ArrayBuffer, info: () => FigArchiveRecordInfo): FigArchiveAccess;
@@ -1 +1 @@
1
- {"version":3,"file":"access.d.ts","names":[],"sources":["../../../../../src/kiwi/fig/session/archive/access.ts"],"mappings":";;;;;;;;UAkBiB;EACf,YAAY,QAAQ;EACpB,QAAQ,QAAQ;;EAEhB,eAAe,yBAAyB;EACxC,MAAM,OAAO,gBAAgB,OAAO,yBAAyB,QAAQ;;EAErE;;iBAKc,mBAAmB,OAAO,YAAY,SAAS;iBAI/C,WAAW,OAAO,aAAa;iBAI/B,kBAAkB,OAAO;;;;;;iBAUzB,2BAA2B,OAAO,aAAa,YAAY;;EAAA,YAAA;EAIxC,iBAAA;EACV,QAAA,OAAA,gBAAc,OAAS,2BAAsB,QAAA,WAAA;;iBAKtD,gBACd,OAAO,aACP,YAAY,uBACX;KA+BE,cAAc,KAAK;KACnB,gBAAgB,KAAK;UAGT,+BAA+B;;EAE9C;;;;;;;iBAcc,iBACd,MAAM,aACN,QAAQ,eACR,gBAAgB,mBACf"}
1
+ {"version":3,"file":"access.d.ts","names":[],"sources":["../../../../../src/kiwi/fig/session/archive/access.ts"],"mappings":";;;;;;;;UAmBiB;EACf,YAAY,QAAQ;EACpB,QAAQ,QAAQ;;EAEhB,eAAe,yBAAyB;;EAExC,YAAY,sBAAsB;EAClC,MAAM,OAAO,gBAAgB,OAAO,yBAAyB,QAAQ;;EAErE;;iBAKc,mBAAmB,OAAO,YAAY,SAAS;iBAI/C,WAAW,OAAO,aAAa;iBAI/B,kBAAkB,OAAO;;;;;;iBAUzB,2BAA2B,OAAO,aAAa,YAAY;;EAAA,YAAA;EAIxC,iBAAA;EACN,cAAA;EAEJ,QAAA,OAAA,gBAAc,OAAS,2BAAsB,QAAA,WAAA;;iBAKtD,gBACd,OAAO,aACP,YAAY,uBACX;KAkCE,cAAc,KAAK;KACnB,gBAAgB,KAAK;UAGT,+BAA+B;;EAE9C;;;;;;;iBAcc,iBACd,MAAM,aACN,QAAQ,eACR,gBAAgB,mBACf"}
@@ -1,5 +1,5 @@
1
1
  import { randomHex } from "@pairdraw/scene-graph/random";
2
- import { figArchiveComponentUsePages, patchFigArchive } from "@pairdraw/fig";
2
+ import { figArchiveComponentUsePages, figArchiveRecordPages, patchFigArchive } from "@pairdraw/fig";
3
3
  import { loadFigDataCompressor } from "@pairdraw/kiwi/fig/container";
4
4
  //#region src/kiwi/fig/session/archive/access.ts
5
5
  const archives = /* @__PURE__ */ new WeakMap();
@@ -23,6 +23,7 @@ function createFigArchiveOperations(bytes, info) {
23
23
  original: () => new Uint8Array(bytes.slice(0)),
24
24
  info,
25
25
  componentPages: (componentIds) => figArchiveComponentUsePages(bytes, componentIds),
26
+ recordPages: (recordIds) => figArchiveRecordPages(bytes, recordIds).map((pageId) => pageId ?? null),
26
27
  patch: async (patch, input) => patchFigArchive(bytes, patch, input, await loadFigDataCompressor(input.compressionLevel))
27
28
  };
28
29
  }
@@ -32,6 +33,7 @@ function localFigArchive(bytes, info) {
32
33
  original: async () => operations.original(),
33
34
  info: async () => operations.info(),
34
35
  componentPages: async (componentIds) => operations.componentPages(componentIds),
36
+ recordPages: async (recordIds) => operations.recordPages(recordIds),
35
37
  patch: (patch, input) => operations.patch(patch, input),
36
38
  close: () => void 0
37
39
  };
@@ -40,6 +42,7 @@ const ARCHIVE_RESPONSES = /* @__PURE__ */ new Set([
40
42
  "original-archive-result",
41
43
  "archive-info-result",
42
44
  "component-pages-result",
45
+ "record-pages-result",
43
46
  "patch-archive-result",
44
47
  "archive-error"
45
48
  ]);
@@ -97,6 +100,10 @@ function workerFigArchive(port, worker, fallback) {
97
100
  type: "component-pages",
98
101
  componentIds
99
102
  }, "component-pages-result", (response) => response.pageIds, (access) => access.componentPages(componentIds)),
103
+ recordPages: (recordIds) => ask({
104
+ type: "record-pages",
105
+ recordIds
106
+ }, "record-pages-result", (response) => response.pageIds, (access) => access.recordPages(recordIds)),
100
107
  patch: (patch, input) => ask({
101
108
  type: "patch-archive",
102
109
  patch,
@@ -1 +1 @@
1
- {"version":3,"file":"access.js","names":[],"sources":["../../../../../src/kiwi/fig/session/archive/access.ts"],"sourcesContent":["import {\n figArchiveComponentUsePages,\n patchFigArchive,\n type FigArchiveRecordInfo,\n type FigPatchedArchiveInput,\n type FigRecordPatch\n} from '@pairdraw/fig'\nimport { loadFigDataCompressor } from '@pairdraw/kiwi/fig/container'\nimport type { SceneGraph } from '@pairdraw/scene-graph'\nimport { randomHex } from '@pairdraw/scene-graph/random'\n\nimport type { FigSessionRequest, FigSessionResponse } from '#core/kiwi/fig/session/protocol'\n\n/**\n * The `.fig` archive a document was opened from, for writing the document back as that archive\n * with only its changed records replaced. In the browser the reader's worker holds the archive\n * and does this work; elsewhere, or once that worker is gone, it runs where it is asked.\n */\nexport interface FigArchiveAccess {\n original(): Promise<Uint8Array>\n info(): Promise<FigArchiveRecordInfo>\n /** Archive GUIDs of the pages whose instances use these components. */\n componentPages(componentIds: string[]): Promise<string[]>\n patch(patch: FigRecordPatch, input: FigPatchedArchiveInput): Promise<Uint8Array>\n /** The document closed: release whatever holds the archive. */\n close(): void\n}\n\nconst archives = new WeakMap<SceneGraph, FigArchiveAccess>()\n\nexport function registerFigArchive(graph: SceneGraph, archive: FigArchiveAccess): void {\n archives.set(graph, archive)\n}\n\nexport function figArchive(graph: SceneGraph): FigArchiveAccess | undefined {\n return archives.get(graph)\n}\n\nexport function releaseFigArchive(graph: SceneGraph): void {\n archives.get(graph)?.close()\n archives.delete(graph)\n}\n\n/**\n * The archive operations themselves, over bytes nothing else writes to. They read the archive\n * as bytes, so they outlive the reader session that opened it; only the record info comes from\n * that session, taken while its records are decoded.\n */\nexport function createFigArchiveOperations(bytes: ArrayBuffer, info: () => FigArchiveRecordInfo) {\n return {\n original: () => new Uint8Array(bytes.slice(0)),\n info,\n componentPages: (componentIds: string[]) => figArchiveComponentUsePages(bytes, componentIds),\n patch: async (patch: FigRecordPatch, input: FigPatchedArchiveInput) =>\n patchFigArchive(bytes, patch, input, await loadFigDataCompressor(input.compressionLevel))\n }\n}\n\nexport function localFigArchive(\n bytes: ArrayBuffer,\n info: () => FigArchiveRecordInfo\n): FigArchiveAccess {\n const operations = createFigArchiveOperations(bytes, info)\n return {\n original: async () => operations.original(),\n info: async () => operations.info(),\n componentPages: async (componentIds) => operations.componentPages(componentIds),\n patch: (patch, input) => operations.patch(patch, input),\n close: () => undefined\n }\n}\n\ntype ArchiveResponse = Extract<\n FigSessionResponse,\n {\n type:\n | 'original-archive-result'\n | 'archive-info-result'\n | 'component-pages-result'\n | 'patch-archive-result'\n | 'archive-error'\n }\n>\n\nconst ARCHIVE_RESPONSES = new Set<FigSessionResponse['type']>([\n 'original-archive-result',\n 'archive-info-result',\n 'component-pages-result',\n 'patch-archive-result',\n 'archive-error'\n])\n\ntype ArchivePort = Pick<MessagePort, 'postMessage' | 'addEventListener' | 'close'>\ntype ArchiveWorker = Pick<Worker, 'terminate' | 'addEventListener'>\ntype DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, K> : never\n\nexport interface WorkerFigArchiveAccess extends FigArchiveAccess {\n /** Stop the worker now, as an abandoned page load does; requests continue on the fallback. */\n dropWorker(): void\n}\n\ninterface WaitingRequest {\n retry: (access: FigArchiveAccess) => void\n resolve: (response: ArchiveResponse) => void\n reject: (error: Error) => void\n}\n\n/**\n * Archive operations answered by the reader's worker over its session port. The worker serves\n * the archive until the document closes, even after it stops loading pages. If it fails or is\n * stopped, requests, those waiting included, run on the fallback instead.\n */\nexport function workerFigArchive(\n port: ArchivePort,\n worker: ArchiveWorker,\n fallback: () => FigArchiveAccess\n): WorkerFigArchiveAccess {\n const pending = new Map<string, WaitingRequest>()\n let local: FigArchiveAccess | undefined\n let closed = false\n const toFallback = (): FigArchiveAccess => {\n if (local) return local\n const access = fallback()\n local = access\n worker.terminate()\n for (const waiting of pending.values()) waiting.retry(access)\n pending.clear()\n return access\n }\n worker.addEventListener('error', () => toFallback())\n port.addEventListener('message', (event: MessageEvent<FigSessionResponse>) => {\n if (!ARCHIVE_RESPONSES.has(event.data.type)) return\n const response = event.data as ArchiveResponse\n const waiting = pending.get(response.requestId)\n if (!waiting) return\n pending.delete(response.requestId)\n if (response.type === 'archive-error') waiting.reject(new Error(response.error))\n else waiting.resolve(response)\n })\n const ask = <T extends ArchiveResponse['type'], Result>(\n message: DistributiveOmit<FigSessionRequest, 'requestId'>,\n type: T,\n read: (response: Extract<ArchiveResponse, { type: T }>) => Result,\n onFallback: (access: FigArchiveAccess) => Promise<Result>\n ): Promise<Result> => {\n if (closed) return Promise.reject(new Error('The document closed'))\n if (local) return onFallback(local)\n return new Promise<Result>((resolve, reject) => {\n const requestId = randomHex()\n pending.set(requestId, {\n retry: (access) => void onFallback(access).then(resolve, reject),\n resolve: (response) => {\n if (response.type === type)\n resolve(read(response as Extract<ArchiveResponse, { type: T }>))\n else reject(new Error(`Unexpected ${response.type} for ${message.type}`))\n },\n reject\n })\n port.postMessage({ ...message, requestId })\n })\n }\n return {\n original: () =>\n ask(\n { type: 'original-archive' },\n 'original-archive-result',\n (response) => response.bytes,\n (access) => access.original()\n ),\n info: () =>\n ask(\n { type: 'archive-info' },\n 'archive-info-result',\n (response) => response.info,\n (access) => access.info()\n ),\n componentPages: (componentIds) =>\n ask(\n { type: 'component-pages', componentIds },\n 'component-pages-result',\n (response) => response.pageIds,\n (access) => access.componentPages(componentIds)\n ),\n patch: (patch, input) =>\n ask(\n { type: 'patch-archive', patch, input },\n 'patch-archive-result',\n (response) => response.bytes,\n (access) => access.patch(patch, input)\n ),\n dropWorker: () => void toFallback(),\n close() {\n if (closed) return\n closed = true\n for (const waiting of pending.values()) waiting.reject(new Error('The document closed'))\n pending.clear()\n if (local) return\n port.postMessage({ type: 'dispose' })\n port.close()\n worker.terminate()\n }\n }\n}\n"],"mappings":";;;;AA4BA,MAAM,2BAAW,IAAI,QAAsC;AAE3D,SAAgB,mBAAmB,OAAmB,SAAiC;CACrF,SAAS,IAAI,OAAO,OAAO;AAC7B;AAEA,SAAgB,WAAW,OAAiD;CAC1E,OAAO,SAAS,IAAI,KAAK;AAC3B;AAEA,SAAgB,kBAAkB,OAAyB;CACzD,SAAS,IAAI,KAAK,CAAC,EAAE,MAAM;CAC3B,SAAS,OAAO,KAAK;AACvB;;;;;;AAOA,SAAgB,2BAA2B,OAAoB,MAAkC;CAC/F,OAAO;EACL,gBAAgB,IAAI,WAAW,MAAM,MAAM,CAAC,CAAC;EAC7C;EACA,iBAAiB,iBAA2B,4BAA4B,OAAO,YAAY;EAC3F,OAAO,OAAO,OAAuB,UACnC,gBAAgB,OAAO,OAAO,OAAO,MAAM,sBAAsB,MAAM,gBAAgB,CAAC;CAC5F;AACF;AAEA,SAAgB,gBACd,OACA,MACkB;CAClB,MAAM,aAAa,2BAA2B,OAAO,IAAI;CACzD,OAAO;EACL,UAAU,YAAY,WAAW,SAAS;EAC1C,MAAM,YAAY,WAAW,KAAK;EAClC,gBAAgB,OAAO,iBAAiB,WAAW,eAAe,YAAY;EAC9E,QAAQ,OAAO,UAAU,WAAW,MAAM,OAAO,KAAK;EACtD,aAAa,KAAA;CACf;AACF;A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G;IAAS;GAAU,CAAC;EAC5C,CAAC;CACH;CACA,OAAO;EACL,gBACE,IACE,EAAE,MAAM,mBAAmB,GAC3B,4BACC,aAAa,SAAS,QACtB,WAAW,OAAO,SAAS,CAC9B;EACF,YACE,IACE,EAAE,MAAM,eAAe,GACvB,wBACC,aAAa,SAAS,OACtB,WAAW,OAAO,KAAK,CAC1B;EACF,iBAAiB,iBACf,IACE;GAAE,MAAM;GAAmB;EAAa,GACxC,2BACC,aAAa,SAAS,UACtB,WAAW,OAAO,eAAe,YAAY,CAChD;EACF,QAAQ,OAAO,UACb,IACE;GAAE,MAAM;GAAiB;GAAO;EAAM,GACtC,yBACC,aAAa,SAAS,QACtB,WAAW,OAAO,MAAM,OAAO,KAAK,CACvC;EACF,kBAAkB,KAAK,WAAW;EAClC,QAAQ;GACN,IAAI,QAAQ;GACZ,SAAS;GACT,KAAK,MAAM,WAAW,QAAQ,OAAO,GAAG,QAAQ,uBAAO,IAAI,MAAM,qBAAqB,CAAC;GACvF,QAAQ,MAAM;GACd,IAAI,OAAO;GACX,KAAK,YAAY,EAAE,MAAM,UAAU,CAAC;GACpC,KAAK,MAAM;GACX,OAAO,UAAU;EACnB;CACF;AACF"}
1
+ {"version":3,"file":"access.js","names":[],"sources":["../../../../../src/kiwi/fig/session/archive/access.ts"],"sourcesContent":["import {\n figArchiveComponentUsePages,\n figArchiveRecordPages,\n patchFigArchive,\n type FigArchiveRecordInfo,\n type FigPatchedArchiveInput,\n type FigRecordPatch\n} from '@pairdraw/fig'\nimport { loadFigDataCompressor } from '@pairdraw/kiwi/fig/container'\nimport type { SceneGraph } from '@pairdraw/scene-graph'\nimport { randomHex } from '@pairdraw/scene-graph/random'\n\nimport type { FigSessionRequest, FigSessionResponse } from '#core/kiwi/fig/session/protocol'\n\n/**\n * The `.fig` archive a document was opened from, for writing the document back as that archive\n * with only its changed records replaced. In the browser the reader's worker holds the archive\n * and does this work; elsewhere, or once that worker is gone, it runs where it is asked.\n */\nexport interface FigArchiveAccess {\n original(): Promise<Uint8Array>\n info(): Promise<FigArchiveRecordInfo>\n /** Archive GUIDs of the pages whose instances use these components. */\n componentPages(componentIds: string[]): Promise<string[]>\n /** The archive GUID of the page each record is on, `null` for one on no page. */\n recordPages(recordIds: string[]): Promise<(string | null)[]>\n patch(patch: FigRecordPatch, input: FigPatchedArchiveInput): Promise<Uint8Array>\n /** The document closed: release whatever holds the archive. */\n close(): void\n}\n\nconst archives = new WeakMap<SceneGraph, FigArchiveAccess>()\n\nexport function registerFigArchive(graph: SceneGraph, archive: FigArchiveAccess): void {\n archives.set(graph, archive)\n}\n\nexport function figArchive(graph: SceneGraph): FigArchiveAccess | undefined {\n return archives.get(graph)\n}\n\nexport function releaseFigArchive(graph: SceneGraph): void {\n archives.get(graph)?.close()\n archives.delete(graph)\n}\n\n/**\n * The archive operations themselves, over bytes nothing else writes to. They read the archive\n * as bytes, so they outlive the reader session that opened it; only the record info comes from\n * that session, taken while its records are decoded.\n */\nexport function createFigArchiveOperations(bytes: ArrayBuffer, info: () => FigArchiveRecordInfo) {\n return {\n original: () => new Uint8Array(bytes.slice(0)),\n info,\n componentPages: (componentIds: string[]) => figArchiveComponentUsePages(bytes, componentIds),\n recordPages: (recordIds: string[]) =>\n figArchiveRecordPages(bytes, recordIds).map((pageId) => pageId ?? null),\n patch: async (patch: FigRecordPatch, input: FigPatchedArchiveInput) =>\n patchFigArchive(bytes, patch, input, await loadFigDataCompressor(input.compressionLevel))\n }\n}\n\nexport function localFigArchive(\n bytes: ArrayBuffer,\n info: () => FigArchiveRecordInfo\n): FigArchiveAccess {\n const operations = createFigArchiveOperations(bytes, info)\n return {\n original: async () => operations.original(),\n info: async () => operations.info(),\n componentPages: async (componentIds) => operations.componentPages(componentIds),\n recordPages: async (recordIds) => operations.recordPages(recordIds),\n patch: (patch, input) => operations.patch(patch, input),\n close: () => undefined\n }\n}\n\ntype ArchiveResponse = Extract<\n FigSessionResponse,\n {\n type:\n | 'original-archive-result'\n | 'archive-info-result'\n | 'component-pages-result'\n | 'record-pages-result'\n | 'patch-archive-result'\n | 'archive-error'\n }\n>\n\nconst ARCHIVE_RESPONSES = new Set<FigSessionResponse['type']>([\n 'original-archive-result',\n 'archive-info-result',\n 'component-pages-result',\n 'record-pages-result',\n 'patch-archive-result',\n 'archive-error'\n])\n\ntype ArchivePort = Pick<MessagePort, 'postMessage' | 'addEventListener' | 'close'>\ntype ArchiveWorker = Pick<Worker, 'terminate' | 'addEventListener'>\ntype DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, K> : never\n\nexport interface WorkerFigArchiveAccess extends FigArchiveAccess {\n /** Stop the worker now, as an abandoned page load does; requests continue on the fallback. */\n dropWorker(): void\n}\n\ninterface WaitingRequest {\n retry: (access: FigArchiveAccess) => void\n resolve: (response: ArchiveResponse) => void\n reject: (error: Error) => void\n}\n\n/**\n * Archive operations answered by the reader's worker over its session port. The worker serves\n * the archive until the document closes, even after it stops loading pages. If it fails or is\n * stopped, requests, those waiting included, run on the fallback instead.\n */\nexport function workerFigArchive(\n port: ArchivePort,\n worker: ArchiveWorker,\n fallback: () => FigArchiveAccess\n): WorkerFigArchiveAccess {\n const pending = new Map<string, WaitingRequest>()\n let local: FigArchiveAccess | undefined\n let closed = false\n const toFallback = (): FigArchiveAccess => {\n if (local) return local\n const access = fallback()\n local = access\n worker.terminate()\n for (const waiting of pending.values()) waiting.retry(access)\n pending.clear()\n return access\n }\n worker.addEventListener('error', () => toFallback())\n port.addEventListener('message', (event: MessageEvent<FigSessionResponse>) => {\n if (!ARCHIVE_RESPONSES.has(event.data.type)) return\n const response = event.data as ArchiveResponse\n const waiting = pending.get(response.requestId)\n if (!waiting) return\n pending.delete(response.requestId)\n if (response.type === 'archive-error') waiting.reject(new Error(response.error))\n else waiting.resolve(response)\n })\n const ask = <T extends ArchiveResponse['type'], Result>(\n message: DistributiveOmit<FigSessionRequest, 'requestId'>,\n type: T,\n read: (response: Extract<ArchiveResponse, { type: T }>) => Result,\n onFallback: (access: FigArchiveAccess) => Promise<Result>\n ): Promise<Result> => {\n if (closed) return Promise.reject(new Error('The document closed'))\n if (local) return onFallback(local)\n return new Promise<Result>((resolve, reject) => {\n const requestId = randomHex()\n pending.set(requestId, {\n retry: (access) => void onFallback(access).then(resolve, reject),\n resolve: (response) => {\n if (response.type === type)\n resolve(read(response as Extract<ArchiveResponse, { type: T }>))\n else reject(new Error(`Unexpected ${response.type} for ${message.type}`))\n },\n reject\n })\n port.postMessage({ ...message, requestId })\n })\n }\n return {\n original: () =>\n ask(\n { type: 'original-archive' },\n 'original-archive-result',\n (response) => response.bytes,\n (access) => access.original()\n ),\n info: () =>\n ask(\n { type: 'archive-info' },\n 'archive-info-result',\n (response) => response.info,\n (access) => access.info()\n ),\n componentPages: (componentIds) =>\n ask(\n { type: 'component-pages', componentIds },\n 'component-pages-result',\n (response) => response.pageIds,\n (access) => access.componentPages(componentIds)\n ),\n recordPages: (recordIds) =>\n ask(\n { type: 'record-pages', recordIds },\n 'record-pages-result',\n (response) => response.pageIds,\n (access) => access.recordPages(recordIds)\n ),\n patch: (patch, input) =>\n ask(\n { type: 'patch-archive', patch, input },\n 'patch-archive-result',\n (response) => response.bytes,\n (access) => access.patch(patch, input)\n ),\n dropWorker: () => void toFallback(),\n close() {\n if (closed) return\n closed = true\n for (const waiting of pending.values()) waiting.reject(new Error('The document closed'))\n pending.clear()\n if (local) return\n port.postMessage({ type: 'dispose' })\n port.close()\n worker.terminate()\n }\n }\n}\n"],"mappings":";;;;AA+BA,MAAM,2BAAW,IAAI,QAAsC;AAE3D,SAAgB,mBAAmB,OAAmB,SAAiC;CACrF,SAAS,IAAI,OAAO,OAAO;AAC7B;AAEA,SAAgB,WAAW,OAAiD;CAC1E,OAAO,SAAS,IAAI,KAAK;AAC3B;AAEA,SAAgB,kBAAkB,OAAyB;CACzD,SAAS,IAAI,KAAK,CAAC,EAAE,MAAM;CAC3B,SAAS,OAAO,KAAK;AACvB;;;;;;AAOA,SAAgB,2BAA2B,OAAo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IAAI,QAAQ;GACZ,SAAS;GACT,KAAK,MAAM,WAAW,QAAQ,OAAO,GAAG,QAAQ,uBAAO,IAAI,MAAM,qBAAqB,CAAC;GACvF,QAAQ,MAAM;GACd,IAAI,OAAO;GACX,KAAK,YAAY,EAAE,MAAM,UAAU,CAAC;GACpC,KAAK,MAAM;GACX,OAAO,UAAU;EACnB;CACF;AACF"}
@@ -11,6 +11,7 @@ interface CollectionsSnapshot {
11
11
  collections: Array<[string, VariableCollection]>;
12
12
  activeMode: Array<[string, string]>;
13
13
  }
14
+ declare function settingsSnapshot(graph: SceneGraph): SettingsSnapshot;
14
15
  declare function trackArchiveChanges(graph: SceneGraph): void;
15
16
  interface ArchiveChangeSummary {
16
17
  /**
@@ -39,5 +40,5 @@ interface ArchiveBaseline {
39
40
  }
40
41
  declare function archiveBaseline(graph: SceneGraph): ArchiveBaseline | undefined;
41
42
  //#endregion
42
- export { ArchiveBaseline, ArchiveChangeSummary, archiveBaseline, archiveChanges, trackArchiveChanges };
43
+ export { ArchiveBaseline, ArchiveChangeSummary, SettingsSnapshot, archiveBaseline, archiveChanges, settingsSnapshot, trackArchiveChanges };
43
44
  //# sourceMappingURL=changes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"changes.d.ts","names":[],"sources":["../../../../../src/kiwi/fig/session/archive/changes.ts"],"mappings":";;;UAqCU;EACR,YAAY;EACZ,MAAM;EACN,WAAW,eAAe;;;UAIlB;EACR,aAAa,eAAe;EAC5B,YAAY;;iBA6BE,oBAAoB,OAAO;UAyC1B;;;;;EAKf,SAAS;EACT,aAAa;;EAEb,kBAAkB;EAClB;EACA;;iBAGc,eAAe,OAAO,aAAa;;UAiBlC;;EAEf,QAAQ,oBAAoB;;EAE5B,SAAS;;EAET,kBAAkB;EAClB,WAAW,oBAAoB;EAC/B,aAAa;EACb,UAAU;;iBAGI,gBAAgB,OAAO,aAAa"}
1
+ {"version":3,"file":"changes.d.ts","names":[],"sources":["../../../../../src/kiwi/fig/session/archive/changes.ts"],"mappings":";;;UAsCiB;EACf,YAAY;EACZ,MAAM;EACN,WAAW,eAAe;;;UAIlB;EACR,aAAa,eAAe;EAC5B,YAAY;;iBAKE,iBAAiB,OAAO,aAAa;iBAwBrC,oBAAoB,OAAO;UA+C1B;;;;;EAKf,SAAS;EACT,aAAa;;EAEb,kBAAkB;EAClB;EACA;;iBAac,eAAe,OAAO,aAAa;;UAqBlC;;EAEf,QAAQ,oBAAoB;;EAE5B,SAAS;;EAET,kBAAkB;EAClB,WAAW,oBAAoB;EAC/B,aAAa;EACb,UAAU;;iBAGI,gBAAgB,OAAO,aAAa"}
@@ -1,4 +1,5 @@
1
- import { isEqual } from "es-toolkit/predicate";
1
+ import { isEqual, isPlainObject } from "es-toolkit/predicate";
2
+ import { mapValues, omitBy } from "es-toolkit/object";
2
3
  //#region src/kiwi/fig/session/archive/changes.ts
3
4
  const changes = /* @__PURE__ */ new WeakMap();
4
5
  function settingsSnapshot(graph) {
@@ -34,7 +35,7 @@ function trackArchiveChanges(graph) {
34
35
  settings: settingsSnapshot(graph)
35
36
  };
36
37
  const touch = (id) => {
37
- if (!graph.isApplyingImportedState && !graph.isApplyingDerivedLayout) entry.touched.add(id);
38
+ if (!graph.isApplyingImportedState && !graph.isApplyingDerivedLayout && !graph.isApplyingComponentDerived) entry.touched.add(id);
38
39
  };
39
40
  const edits = () => !graph.isApplyingImportedState && !graph.isApplyingDerivedLayout;
40
41
  graph.observeNodeChanges({
@@ -58,17 +59,23 @@ function trackArchiveChanges(graph) {
58
59
  });
59
60
  changes.set(graph, entry);
60
61
  }
62
+ /** A value without its unset keys: a field set to `undefined` and one removed are the same. */
63
+ function withoutUnset(value) {
64
+ if (Array.isArray(value)) return value.map(withoutUnset);
65
+ if (!isPlainObject(value)) return value;
66
+ return mapValues(omitBy(value, (field) => field === void 0), withoutUnset);
67
+ }
61
68
  function archiveChanges(graph) {
62
69
  const entry = changes.get(graph);
63
70
  if (!entry) return void 0;
64
71
  const changedVariables = /* @__PURE__ */ new Set();
65
- for (const [id, variable] of graph.variables) if (!isEqual(entry.variables.get(id), variable)) changedVariables.add(id);
72
+ for (const [id, variable] of graph.variables) if (!isEqual(withoutUnset(entry.variables.get(id)), withoutUnset(variable))) changedVariables.add(id);
66
73
  for (const id of entry.variables.keys()) if (!graph.variables.has(id)) changedVariables.add(id);
67
74
  return {
68
75
  touched: entry.touched,
69
76
  resourceIds: entry.resourceIds,
70
77
  changedVariables,
71
- collectionsChanged: !isEqual(entry.collections, collectionsSnapshot(graph)),
78
+ collectionsChanged: !isEqual(withoutUnset(entry.collections), withoutUnset(collectionsSnapshot(graph))),
72
79
  documentChanged: !isEqual(entry.settings, settingsSnapshot(graph))
73
80
  };
74
81
  }
@@ -85,6 +92,6 @@ function archiveBaseline(graph) {
85
92
  };
86
93
  }
87
94
  //#endregion
88
- export { archiveBaseline, archiveChanges, trackArchiveChanges };
95
+ export { archiveBaseline, archiveChanges, settingsSnapshot, trackArchiveChanges };
89
96
 
90
97
  //# sourceMappingURL=changes.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"changes.js","names":[],"sources":["../../../../../src/kiwi/fig/session/archive/changes.ts"],"sourcesContent":["import { isEqual } from 'es-toolkit/predicate'\n\nimport type {\n DocumentColorSpace,\n DocumentKind,\n EnabledLibraryBinding,\n SceneGraph,\n SceneNode,\n Variable,\n VariableCollection\n} from '@pairdraw/scene-graph'\n\n/**\n * How a document opened from a `.fig` archive has diverged from it, for writing only what\n * changed. Layers loading from the archive are not changes, nor is the layout a page gets as\n * it loads or as its fonts arrive; the layout an edit causes is, since it moves the layers\n * around the edit.\n */\ninterface ArchiveChanges {\n touched: Set<string>\n /** Layers an edit changed, as they were before it: the archive's state of them. */\n before: Map<string, SceneNode>\n /** Layers added since the archive opened, which it does not hold. */\n created: Set<string>\n /**\n * Layers loaded from the archive after an edit, so the edit may already show in them, as in\n * instances of an edited component: their state before it is unknown.\n */\n loadedAfterEdits: Set<string>\n /** The variables, collections and modes the archive holds. */\n resourceIds: Set<string>\n variables: Map<string, Variable>\n collections: CollectionsSnapshot\n settings: SettingsSnapshot\n}\n\n/** The document's own settings, which its record holds rather than any layer. */\ninterface SettingsSnapshot {\n colorSpace: DocumentColorSpace\n kind: DocumentKind\n libraries: Array<[string, EnabledLibraryBinding]>\n}\n\n/** The variable collections and the modes the document shows them in. */\ninterface CollectionsSnapshot {\n collections: Array<[string, VariableCollection]>\n activeMode: Array<[string, string]>\n}\n\nconst changes = new WeakMap<SceneGraph, ArchiveChanges>()\n\nfunction settingsSnapshot(graph: SceneGraph): SettingsSnapshot {\n return structuredClone({\n colorSpace: graph.documentColorSpace,\n kind: graph.documentKind,\n libraries: [...graph.enabledLibraries]\n })\n}\n\nfunction collectionsSnapshot(graph: SceneGraph): CollectionsSnapshot {\n return structuredClone({\n collections: [...graph.variableCollections],\n activeMode: [...graph.activeMode]\n })\n}\n\nfunction resourceIdsOf(graph: SceneGraph): Set<string> {\n const ids = new Set(graph.variables.keys())\n for (const [id, collection] of graph.variableCollections) {\n ids.add(id)\n for (const mode of collection.modes) ids.add(mode.modeId)\n }\n return ids\n}\n\nexport function trackArchiveChanges(graph: SceneGraph): void {\n const entry: ArchiveChanges = {\n touched: new Set(),\n before: new Map(),\n created: new Set(),\n loadedAfterEdits: new Set(),\n resourceIds: resourceIdsOf(graph),\n variables: new Map(\n [...graph.variables].map(([id, variable]) => [id, structuredClone(variable)])\n ),\n collections: collectionsSnapshot(graph),\n settings: settingsSnapshot(graph)\n }\n const touch = (id: string) => {\n if (!graph.isApplyingImportedState && !graph.isApplyingDerivedLayout) entry.touched.add(id)\n }\n const edits = () => !graph.isApplyingImportedState && !graph.isApplyingDerivedLayout\n graph.observeNodeChanges({\n before: (node) => {\n if (!edits() || entry.created.has(node.id) || entry.before.has(node.id)) return\n entry.before.set(node.id, structuredClone(node))\n },\n created: (node) => {\n if (edits()) entry.created.add(node.id)\n else if (entry.touched.size > 0) entry.loadedAfterEdits.add(node.id)\n }\n })\n graph.onNodeEvents({\n created: (node) => touch(node.id),\n updated: touch,\n reparented: touch,\n reordered: touch,\n // A removed layer has no record of its own to write: the instance or component holding it\n // changes, and the parent leads there.\n deleted: (_id, parentId) => {\n if (parentId) touch(parentId)\n }\n })\n changes.set(graph, entry)\n}\n\nexport interface ArchiveChangeSummary {\n /**\n * Layers created, updated or moved since the archive opened, and the parents of layers\n * removed; some may be gone since.\n */\n touched: ReadonlySet<string>\n resourceIds: ReadonlySet<string>\n /** Variables whose value, binding or presence changed. */\n changedVariables: ReadonlySet<string>\n collectionsChanged: boolean\n documentChanged: boolean\n}\n\nexport function archiveChanges(graph: SceneGraph): ArchiveChangeSummary | undefined {\n const entry = changes.get(graph)\n if (!entry) return undefined\n const changedVariables = new Set<string>()\n for (const [id, variable] of graph.variables)\n if (!isEqual(entry.variables.get(id), variable)) changedVariables.add(id)\n for (const id of entry.variables.keys()) if (!graph.variables.has(id)) changedVariables.add(id)\n return {\n touched: entry.touched,\n resourceIds: entry.resourceIds,\n changedVariables,\n collectionsChanged: !isEqual(entry.collections, collectionsSnapshot(graph)),\n documentChanged: !isEqual(entry.settings, settingsSnapshot(graph))\n }\n}\n\n/** The document as the archive holds it, for the layers that have loaded. */\nexport interface ArchiveBaseline {\n /** Layers edits changed, as they were before. */\n before: ReadonlyMap<string, SceneNode>\n /** Layers added since, which the archive does not hold. */\n created: ReadonlySet<string>\n /** Layers loaded after an edit, whose state before it is unknown. */\n loadedAfterEdits: ReadonlySet<string>\n variables: ReadonlyMap<string, Variable>\n collections: CollectionsSnapshot\n settings: SettingsSnapshot\n}\n\nexport function archiveBaseline(graph: SceneGraph): ArchiveBaseline | undefined {\n const entry = changes.get(graph)\n if (!entry) return undefined\n return {\n before: entry.before,\n created: entry.created,\n loadedAfterEdits: entry.loadedAfterEdits,\n variables: entry.variables,\n collections: entry.collections,\n settings: entry.settings\n }\n}\n"],"mappings":";;AAiDA,MAAM,0BAAU,IAAI,QAAoC;AAExD,SAAS,iBAAiB,OAAqC;CAC7D,OA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ACjB,IAAI,MAAM,GAAG,MAAM,QAAQ,IAAI,KAAK,EAAE;QACjC,IAAI,MAAM,QAAQ,OAAO,GAAG,MAAM,iBAAiB,IAAI,KAAK,EAAE;EACrE;CACF,CAAC;CACD,MAAM,aAAa;EACjB,UAAU,SAAS,MAAM,KAAK,EAAE;EAChC,SAAS;EACT,YAAY;EACZ,WAAW;EAGX,UAAU,KAAK,aAAa;GAC1B,IAAI,UAAU,MAAM,QAAQ;EAC9B;CACF,CAAC;CACD,QAAQ,IAAI,OAAO,KAAK;AAC1B;AAeA,SAAgB,eAAe,OAAqD;CAClF,MAAM,QAAQ,QAAQ,IAAI,KAAK;CAC/B,IAAI,CAAC,OAAO,OAAO,KAAA;CACnB,MAAM,mCAAmB,IAAI,IAAY;CACzC,KAAK,MAAM,CAAC,IAAI,aAAa,MAAM,WACjC,IAAI,CAAC,QAAQ,MAAM,UAAU,IAAI,EAAE,GAAG,QAAQ,GAAG,iBAAiB,IAAI,EAAE;CAC1E,KAAK,MAAM,MAAM,MAAM,UAAU,KAAK,GAAG,IAAI,CAAC,MAAM,UAAU,IAAI,EAAE,GAAG,iBAAiB,IAAI,EAAE;CAC9F,OAAO;EACL,SAAS,MAAM;EACf,aAAa,MAAM;EACnB;EACA,oBAAoB,CAAC,QAAQ,MAAM,aAAa,oBAAoB,KAAK,CAAC;EAC1E,iBAAiB,CAAC,QAAQ,MAAM,UAAU,iBAAiB,KAAK,CAAC;CACnE;AACF;AAeA,SAAgB,gBAAgB,OAAgD;CAC9E,MAAM,QAAQ,QAAQ,IAAI,KAAK;CAC/B,IAAI,CAAC,OAAO,OAAO,KAAA;CACnB,OAAO;EACL,QAAQ,MAAM;EACd,SAAS,MAAM;EACf,kBAAkB,MAAM;EACxB,WAAW,MAAM;EACjB,aAAa,MAAM;EACnB,UAAU,MAAM;CAClB;AACF"}
1
+ {"version":3,"file":"changes.js","names":[],"sources":["../../../../../src/kiwi/fig/session/archive/changes.ts"],"sourcesContent":["import { mapValues, omitBy } from 'es-toolkit/object'\nimport { isEqual, isPlainObject } from 'es-toolkit/predicate'\n\nimport type {\n DocumentColorSpace,\n DocumentKind,\n EnabledLibraryBinding,\n SceneGraph,\n SceneNode,\n Variable,\n VariableCollection\n} from '@pairdraw/scene-graph'\n\n/**\n * How a document opened from a `.fig` archive has diverged from it, for writing only what\n * changed. Layers loading from the archive are not changes, nor is the layout a page gets as\n * it loads or as its fonts arrive; the layout an edit causes is, since it moves the layers\n * around the edit.\n */\ninterface ArchiveChanges {\n touched: Set<string>\n /** Layers an edit changed, as they were before it: the archive's state of them. */\n before: Map<string, SceneNode>\n /** Layers added since the archive opened, which it does not hold. */\n created: Set<string>\n /**\n * Layers loaded from the archive after an edit, so the edit may already show in them, as in\n * instances of an edited component: their state before it is unknown.\n */\n loadedAfterEdits: Set<string>\n /** The variables, collections and modes the archive holds. */\n resourceIds: Set<string>\n variables: Map<string, Variable>\n collections: CollectionsSnapshot\n settings: SettingsSnapshot\n}\n\n/** The document's own settings, which its record holds rather than any layer. */\nexport interface SettingsSnapshot {\n colorSpace: DocumentColorSpace\n kind: DocumentKind\n libraries: Array<[string, EnabledLibraryBinding]>\n}\n\n/** The variable collections and the modes the document shows them in. */\ninterface CollectionsSnapshot {\n collections: Array<[string, VariableCollection]>\n activeMode: Array<[string, string]>\n}\n\nconst changes = new WeakMap<SceneGraph, ArchiveChanges>()\n\nexport function settingsSnapshot(graph: SceneGraph): SettingsSnapshot {\n return structuredClone({\n colorSpace: graph.documentColorSpace,\n kind: graph.documentKind,\n libraries: [...graph.enabledLibraries]\n })\n}\n\nfunction collectionsSnapshot(graph: SceneGraph): CollectionsSnapshot {\n return structuredClone({\n collections: [...graph.variableCollections],\n activeMode: [...graph.activeMode]\n })\n}\n\nfunction resourceIdsOf(graph: SceneGraph): Set<string> {\n const ids = new Set(graph.variables.keys())\n for (const [id, collection] of graph.variableCollections) {\n ids.add(id)\n for (const mode of collection.modes) ids.add(mode.modeId)\n }\n return ids\n}\n\nexport function trackArchiveChanges(graph: SceneGraph): void {\n const entry: ArchiveChanges = {\n touched: new Set(),\n before: new Map(),\n created: new Set(),\n loadedAfterEdits: new Set(),\n resourceIds: resourceIdsOf(graph),\n variables: new Map(\n [...graph.variables].map(([id, variable]) => [id, structuredClone(variable)])\n ),\n collections: collectionsSnapshot(graph),\n settings: settingsSnapshot(graph)\n }\n // What a copy takes from its component is saved with the component, not as the copy's edit.\n const touch = (id: string) => {\n if (\n !graph.isApplyingImportedState &&\n !graph.isApplyingDerivedLayout &&\n !graph.isApplyingComponentDerived\n )\n entry.touched.add(id)\n }\n const edits = () => !graph.isApplyingImportedState && !graph.isApplyingDerivedLayout\n graph.observeNodeChanges({\n before: (node) => {\n if (!edits() || entry.created.has(node.id) || entry.before.has(node.id)) return\n entry.before.set(node.id, structuredClone(node))\n },\n created: (node) => {\n if (edits()) entry.created.add(node.id)\n else if (entry.touched.size > 0) entry.loadedAfterEdits.add(node.id)\n }\n })\n graph.onNodeEvents({\n created: (node) => touch(node.id),\n updated: touch,\n reparented: touch,\n reordered: touch,\n // A removed layer has no record of its own to write: the instance or component holding it\n // changes, and the parent leads there.\n deleted: (_id, parentId) => {\n if (parentId) touch(parentId)\n }\n })\n changes.set(graph, entry)\n}\n\nexport interface ArchiveChangeSummary {\n /**\n * Layers created, updated or moved since the archive opened, and the parents of layers\n * removed; some may be gone since.\n */\n touched: ReadonlySet<string>\n resourceIds: ReadonlySet<string>\n /** Variables whose value, binding or presence changed. */\n changedVariables: ReadonlySet<string>\n collectionsChanged: boolean\n documentChanged: boolean\n}\n\n/** A value without its unset keys: a field set to `undefined` and one removed are the same. */\nfunction withoutUnset(value: unknown): unknown {\n if (Array.isArray(value)) return value.map(withoutUnset)\n if (!isPlainObject(value)) return value\n return mapValues(\n omitBy(value, (field) => field === undefined),\n withoutUnset\n )\n}\n\nexport function archiveChanges(graph: SceneGraph): ArchiveChangeSummary | undefined {\n const entry = changes.get(graph)\n if (!entry) return undefined\n const changedVariables = new Set<string>()\n for (const [id, variable] of graph.variables)\n if (!isEqual(withoutUnset(entry.variables.get(id)), withoutUnset(variable)))\n changedVariables.add(id)\n for (const id of entry.variables.keys()) if (!graph.variables.has(id)) changedVariables.add(id)\n return {\n touched: entry.touched,\n resourceIds: entry.resourceIds,\n changedVariables,\n collectionsChanged: !isEqual(\n withoutUnset(entry.collections),\n withoutUnset(collectionsSnapshot(graph))\n ),\n documentChanged: !isEqual(entry.settings, settingsSnapshot(graph))\n }\n}\n\n/** The document as the archive holds it, for the layers that have loaded. */\nexport interface ArchiveBaseline {\n /** Layers edits changed, as they were before. */\n before: ReadonlyMap<string, SceneNode>\n /** Layers added since, which the archive does not hold. */\n created: ReadonlySet<string>\n /** Layers loaded after an edit, whose state before it is unknown. */\n loadedAfterEdits: ReadonlySet<string>\n variables: ReadonlyMap<string, Variable>\n collections: CollectionsSnapshot\n settings: SettingsSnapshot\n}\n\nexport function archiveBaseline(graph: SceneGraph): ArchiveBaseline | undefined {\n const entry = changes.get(graph)\n if (!entry) return undefined\n return {\n before: entry.before,\n created: entry.created,\n loadedAfterEdits: entry.loadedAfterEdits,\n variables: entry.variables,\n collections: entry.collections,\n settings: entry.settings\n }\n}\n"],"mappings":";;;AAkDA,MAAM,0BAAU,IAAI,QAAoC;AAExD,SAAgB,iBAAiB,OAAqC;CACpE,OAAO,gBAAgB;EACrB,YAAY,MAAM;EAClB,MAAM,MAAM;EACZ,WAAW,CAAC,GAAG,MAAM,gBAAgB;CACvC,CAAC;AACH;AAEA,SAAS,oBAAoB,OAAwC;CACnE,OAAO,gBAAgB;EACrB,aAAa,CAAC,GAAG,MAAM,mBAAmB;EAC1C,YAAY,CAAC,GAAG,MAAM,UAAU;CAClC,CAAC;AACH;AAEA,SAAS,cAAc,OAAgC;CACrD,MAAM,MAAM,IAAI,IAAI,MAAM,UAAU,KAAK,CAAC;CAC1C,KAAK,MAAM,CAAC,IAAI,eAAe,MAAM,qBAAqB;EACxD,IAAI,IAAI,EAAE;EACV,KAAK,MAAM,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AG,OAAO,MAAM,IAAI,YAAY;CACvD,IAAI,CAAC,cAAc,KAAK,GAAG,OAAO;CAClC,OAAO,UACL,OAAO,QAAQ,UAAU,UAAU,KAAA,CAAS,GAC5C,YACF;AACF;AAEA,SAAgB,eAAe,OAAqD;CAClF,MAAM,QAAQ,QAAQ,IAAI,KAAK;CAC/B,IAAI,CAAC,OAAO,OAAO,KAAA;CACnB,MAAM,mCAAmB,IAAI,IAAY;CACzC,KAAK,MAAM,CAAC,IAAI,aAAa,MAAM,WACjC,IAAI,CAAC,QAAQ,aAAa,MAAM,UAAU,IAAI,EAAE,CAAC,GAAG,aAAa,QAAQ,CAAC,GACxE,iBAAiB,IAAI,EAAE;CAC3B,KAAK,MAAM,MAAM,MAAM,UAAU,KAAK,GAAG,IAAI,CAAC,MAAM,UAAU,IAAI,EAAE,GAAG,iBAAiB,IAAI,EAAE;CAC9F,OAAO;EACL,SAAS,MAAM;EACf,aAAa,MAAM;EACnB;EACA,oBAAoB,CAAC,QACnB,aAAa,MAAM,WAAW,GAC9B,aAAa,oBAAoB,KAAK,CAAC,CACzC;EACA,iBAAiB,CAAC,QAAQ,MAAM,UAAU,iBAAiB,KAAK,CAAC;CACnE;AACF;AAeA,SAAgB,gBAAgB,OAAgD;CAC9E,MAAM,QAAQ,QAAQ,IAAI,KAAK;CAC/B,IAAI,CAAC,OAAO,OAAO,KAAA;CACnB,OAAO;EACL,QAAQ,MAAM;EACd,SAAS,MAAM;EACf,kBAAkB,MAAM;EACxB,WAAW,MAAM;EACjB,aAAa,MAAM;EACnB,UAAU,MAAM;CAClB;AACF"}
@@ -7,6 +7,12 @@ declare function registerReaderSession(bytes: ArrayBuffer, session: ReturnType<t
7
7
  /** Records skipped while opening, recovering, or exporting this graph's document. */
8
8
  declare function readerDiagnostics(graph: SceneGraph): readonly FigReaderDiagnostic[];
9
9
  declare function isReaderPagePending(graph: SceneGraph, pageId: string): boolean;
10
+ /**
11
+ * The page holding a layer of the file while that page has not loaded, so a layer named by its
12
+ * ID, as a link to it names it, is found by loading its page. A layer's ID is its record's GUID;
13
+ * the archive answers which page holds it, in the reader's worker when there is one.
14
+ */
15
+ declare function pendingReaderPageOfNode(graph: SceneGraph, nodeId: string): Promise<string | null>;
10
16
  /** Where the reader stands: which records became which layers, and which pages it loaded. */
11
17
  declare function readerCheckpoint(graph: SceneGraph): FigSessionCheckpoint | undefined;
12
18
  declare function hasReaderSession(graph: SceneGraph): boolean;
@@ -29,5 +35,5 @@ declare function updateReaderRecovery(graph: SceneGraph, checkpoint: FigSessionC
29
35
  declare function releaseReaderRecovery(graph: SceneGraph): void;
30
36
  declare function recoverReaderPage(graph: SceneGraph, pageId: string): boolean;
31
37
  //#endregion
32
- export { hasPendingReaderPages, hasReaderSession, isReaderPagePending, populateAllFigPages, populateFigInternalPages, populateFigPage, populateReaderExport, readerCheckpoint, readerDiagnostics, recoverReaderPage, registerReaderRecovery, registerReaderSession, releaseReaderRecovery, updateReaderRecovery };
38
+ export { hasPendingReaderPages, hasReaderSession, isReaderPagePending, pendingReaderPageOfNode, populateAllFigPages, populateFigInternalPages, populateFigPage, populateReaderExport, readerCheckpoint, readerDiagnostics, recoverReaderPage, registerReaderRecovery, registerReaderSession, releaseReaderRecovery, updateReaderRecovery };
33
39
  //# sourceMappingURL=document-state.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"document-state.d.ts","names":[],"sources":["../../../../src/kiwi/fig/session/document-state.ts"],"mappings":";;;;iBAqBgB,uBACd,OAAO,YACP,OAAO,aACP,YAAY;iBAKE,sBACd,OAAO,aACP,SAAS,kBAAkB,2BAC3B,cAAa;;iBAMC,kBAAkB,OAAO,sBAAsB;iBAI/C,oBAAoB,OAAO,YAAY;;iBAavC,iBAAiB,OAAO,aAAa;iBAKrC,iBAAiB,OAAO;iBAIxB,gBAAgB,OAAO,YAAY;iBAInC,oBAAoB,OAAO;;;;;;;iBA6B3B,yBAAyB,OAAO;;;;;iBAkBhC,sBAAsB,OAAO;iBAO7B,qBAAqB,QAAQ,YAAY,QAAQ;iBAkBjD,qBAAqB,OAAO,YAAY,YAAY;iBAKpD,sBAAsB,OAAO;iBAI7B,kBAAkB,OAAO,YAAY"}
1
+ {"version":3,"file":"document-state.d.ts","names":[],"sources":["../../../../src/kiwi/fig/session/document-state.ts"],"mappings":";;;;iBA0BgB,uBACd,OAAO,YACP,OAAO,aACP,YAAY;iBAKE,sBACd,OAAO,aACP,SAAS,kBAAkB,2BAC3B,cAAa;;iBAMC,kBAAkB,OAAO,sBAAsB;iBAI/C,oBAAoB,OAAO,YAAY;;;;;;iBAiBjC,wBACpB,OAAO,YACP,iBACC;;iBAUa,iBAAiB,OAAO,aAAa;iBAKrC,iBAAiB,OAAO;iBAIxB,gBAAgB,OAAO,YAAY;iBAInC,oBAAoB,OAAO;;;;;;;iBA6B3B,yBAAyB,OAAO;;;;;iBAkBhC,sBAAsB,OAAO;iBAO7B,qBAAqB,QAAQ,YAAY,QAAQ;iBAkBjD,qBAAqB,OAAO,YAAY,YAAY;iBAKpD,sBAAsB,OAAO;iBAI7B,kBAAkB,OAAO,YAAY"}
@@ -1,5 +1,6 @@
1
+ import { figArchive } from "./archive/access.js";
1
2
  import { readerSessionOptions } from "./options.js";
2
- import { createFigDocumentSession } from "@pairdraw/fig";
3
+ import { createFigDocumentSession, figCheckpointRecords } from "@pairdraw/fig";
3
4
  //#region src/kiwi/fig/session/document-state.ts
4
5
  const states = /* @__PURE__ */ new WeakMap();
5
6
  function registerReaderRecovery(graph, bytes, checkpoint) {
@@ -29,6 +30,19 @@ function isReaderPagePending(graph, pageId) {
29
30
  const session = state.session;
30
31
  return session ? session.pages.some((page) => page.id === sourceId) && !session.loadedPageIds.has(sourceId) : !checkpoint.loadedPageIds.includes(sourceId);
31
32
  }
33
+ /**
34
+ * The page holding a layer of the file while that page has not loaded, so a layer named by its
35
+ * ID, as a link to it names it, is found by loading its page. A layer's ID is its record's GUID;
36
+ * the archive answers which page holds it, in the reader's worker when there is one.
37
+ */
38
+ async function pendingReaderPageOfNode(graph, nodeId) {
39
+ const archive = figArchive(graph);
40
+ const checkpoint = readerCheckpoint(graph);
41
+ if (!archive || !checkpoint || states.get(graph)?.complete) return null;
42
+ const [pageGuid] = await archive.recordPages([nodeId]);
43
+ const pageId = pageGuid ? figCheckpointRecords(checkpoint).get(pageGuid) : void 0;
44
+ return pageId && isReaderPagePending(graph, pageId) ? pageId : null;
45
+ }
32
46
  /** Where the reader stands: which records became which layers, and which pages it loaded. */
33
47
  function readerCheckpoint(graph) {
34
48
  const state = states.get(graph);
@@ -129,6 +143,6 @@ function recoverReaderPage(graph, pageId) {
129
143
  return populated;
130
144
  }
131
145
  //#endregion
132
- export { hasPendingReaderPages, hasReaderSession, isReaderPagePending, populateAllFigPages, populateFigInternalPages, populateFigPage, populateReaderExport, readerCheckpoint, readerDiagnostics, recoverReaderPage, registerReaderRecovery, registerReaderSession, releaseReaderRecovery, updateReaderRecovery };
146
+ export { hasPendingReaderPages, hasReaderSession, isReaderPagePending, pendingReaderPageOfNode, populateAllFigPages, populateFigInternalPages, populateFigPage, populateReaderExport, readerCheckpoint, readerDiagnostics, recoverReaderPage, registerReaderRecovery, registerReaderSession, releaseReaderRecovery, updateReaderRecovery };
133
147
 
134
148
  //# sourceMappingURL=document-state.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"document-state.js","names":[],"sources":["../../../../src/kiwi/fig/session/document-state.ts"],"sourcesContent":["import { createFigDocumentSession, type FigSessionCheckpoint } from '@pairdraw/fig'\nimport type { SceneGraph } from '@pairdraw/scene-graph'\n\nimport { readerSessionOptions, type FigReaderDiagnostic } from '#core/kiwi/fig/session/options'\n\n/**\n * Per-graph reader state: the archive bytes, the live session or its checkpoint, and the\n * records that session skipped. Page population, diagnostics and recovery all read it.\n */\ninterface ReaderState {\n /** The archive, until every page is in the graph and nothing is left to read from it. */\n bytes?: ArrayBuffer\n checkpoint?: FigSessionCheckpoint\n session?: ReturnType<typeof createFigDocumentSession>\n /** Records skipped by sessions this recovery state has opened. */\n diagnostics: FigReaderDiagnostic[]\n /** Every page is loaded and the reader released; only the diagnostics remain. */\n complete?: true\n}\nconst states = new WeakMap<SceneGraph, ReaderState>()\n\nexport function registerReaderRecovery(\n graph: SceneGraph,\n bytes: ArrayBuffer,\n checkpoint: FigSessionCheckpoint\n): void {\n states.set(graph, { bytes, checkpoint, diagnostics: [] })\n}\n\nexport function registerReaderSession(\n bytes: ArrayBuffer,\n session: ReturnType<typeof createFigDocumentSession>,\n diagnostics: FigReaderDiagnostic[] = []\n): void {\n states.set(session.graph, { bytes, session, diagnostics })\n}\n\n/** Records skipped while opening, recovering, or exporting this graph's document. */\nexport function readerDiagnostics(graph: SceneGraph): readonly FigReaderDiagnostic[] {\n return states.get(graph)?.diagnostics ?? []\n}\n\nexport function isReaderPagePending(graph: SceneGraph, pageId: string): boolean {\n const state = states.get(graph)\n if (!state || state.complete) return false\n const checkpoint = state.session?.checkpoint() ?? state.checkpoint\n const sourceId = checkpoint?.sources.find(([, graphId]) => graphId === pageId)?.[0]\n if (!sourceId) return false\n const session = state.session\n return session\n ? session.pages.some((page) => page.id === sourceId) && !session.loadedPageIds.has(sourceId)\n : !checkpoint.loadedPageIds.includes(sourceId)\n}\n\n/** Where the reader stands: which records became which layers, and which pages it loaded. */\nexport function readerCheckpoint(graph: SceneGraph): FigSessionCheckpoint | undefined {\n const state = states.get(graph)\n return state?.session?.checkpoint() ?? state?.checkpoint\n}\n\nexport function hasReaderSession(graph: SceneGraph): boolean {\n return states.has(graph)\n}\n\nexport function populateFigPage(graph: SceneGraph, pageId: string): boolean {\n return isReaderPagePending(graph, pageId) ? recoverReaderPage(graph, pageId) : false\n}\n\nexport function populateAllFigPages(graph: SceneGraph): boolean {\n let changed = false\n for (const page of graph.getPages()) {\n if (populateFigPage(graph, page.id)) changed = true\n }\n return changed\n}\n\n/**\n * Drop the session and the archive once every page is in the graph, internal ones included, which\n * the first full save loads. The session keeps every record of the file decoded, which for a\n * large design kit is gigabytes, and no page is pending. The checkpoint stays: it says which\n * record each layer came from, which saving only the changed records still reads.\n */\nfunction releaseLoadedReader(state: ReaderState): void {\n const session = state.session\n if (!session?.pages.every((page) => session.loadedPageIds.has(page.id))) return\n state.checkpoint = session.checkpoint()\n state.session = undefined\n state.bytes = undefined\n state.complete = true\n}\n\n/**\n * Load the pages the editor never shows, such as Figma's internal canvas, into the document's own\n * graph, so a save no longer opens a second session to read them into its copy. Their layers\n * never draw and loading them is not an edit. Only a live session loads them: while a population\n * worker still fills the graph, a second session must not, and the export reads them as before.\n */\nexport function populateFigInternalPages(graph: SceneGraph): boolean {\n const state = states.get(graph)\n const session = state?.session\n if (!state || !session) return false\n let changed = false\n for (const page of session.pages) {\n if (!page.internalOnly || session.loadedPageIds.has(page.id)) continue\n graph.applyImportedStateDuring(() => session.loadPage(page.id))\n changed = true\n }\n releaseLoadedReader(state)\n return changed\n}\n\n/**\n * Whether a save still has pages to read from the archive, which it reads into a copy of the\n * document: a population worker still fills the graph, or a page is not loaded yet.\n */\nexport function hasPendingReaderPages(graph: SceneGraph): boolean {\n const state = states.get(graph)\n if (!state || state.complete) return false\n const session = state.session\n return !session || !session.pages.every((page) => session.loadedPageIds.has(page.id))\n}\n\nexport function populateReaderExport(source: SceneGraph, target: SceneGraph): boolean {\n const state = states.get(source)\n if (!state || state.complete) return false\n const live = state.session\n // Every page is already in the graph the target was copied from.\n if (live?.pages.every((page) => live.loadedPageIds.has(page.id))) return false\n const checkpoint = live?.checkpoint() ?? state.checkpoint\n if (!checkpoint || !state.bytes) throw new Error('Missing reader checkpoint')\n const session = createFigDocumentSession(state.bytes, readerSessionOptions(state.diagnostics), {\n graph: target,\n checkpoint\n })\n // Export must include internal content too, not just the dependency closure needed\n // for visible pages. Loading happens on the isolated target, never the live graph.\n for (const page of session.pages) session.loadPage(page.id)\n return true\n}\n\nexport function updateReaderRecovery(graph: SceneGraph, checkpoint: FigSessionCheckpoint): void {\n const state = states.get(graph)\n if (state && !state.session) state.checkpoint = checkpoint\n}\n\nexport function releaseReaderRecovery(graph: SceneGraph): void {\n states.delete(graph)\n}\n\nexport function recoverReaderPage(graph: SceneGraph, pageId: string): boolean {\n const state = states.get(graph)\n if (!state) throw new Error('No reader recovery state')\n if (state.complete) return false\n if (!state.session) {\n if (!state.checkpoint || !state.bytes) throw new Error('Missing reader checkpoint')\n state.session = createFigDocumentSession(state.bytes, readerSessionOptions(state.diagnostics), {\n graph,\n checkpoint: state.checkpoint\n })\n }\n const page = state.session.pages.find((page) => state.session?.graphPageId(page.id) === pageId)\n if (!page) throw new Error(`Unknown graph page ${pageId}`)\n const session = state.session\n const populated = !session.loadedPageIds.has(page.id)\n // The layers come from the opened file, as they do through the population worker's delta.\n graph.applyImportedStateDuring(() => session.loadPage(page.id))\n releaseLoadedReader(state)\n return populated\n}\n"],"mappings":";;;AAmBA,MAAM,yBAAS,IAAI,QAAiC;AAEpD,SAAgB,uBACd,OACA,OACA,YACM;CACN,OAAO,IAAI,OAAO;EAAE;EAAO;EAAY,aAAa,CAAC;CAAE,CAAC;AAC1D;AAEA,SAAgB,sBACd,OACA,SACA,cAAqC,CAAC,GAChC;CACN,OAAO,IAAI,QAAQ,OAAO;EAAE;EAAO;EAAS;CAAY,CAAC;AAC3D;;AAGA,SAAgB,kBAAkB,OAAmD;CACnF,OAAO,OAAO,IAAI,KAAK,CAAC,EAAE,eAAe,CAAC;AAC5C;AAEA,SAAgB,oBAAoB,OAAmB,QAAyB;CAC9E,MAAM,QAAQ,OAAO,IAAI,KAAK;CAC9B,IAAI,CAAC,SAAS,MAAM,UAAU,OAAO;CACrC,MAAM,aAAa,MAAM,SAAS,WAAW,KAAK,MAAM;CACxD,MAAM,WAAW,YAAY,QAAQ,MAAM,GAAG,aAAa,YAAY,MAAM,CAAC,GAAG;CACjF,IAAI,CAAC,UAAU,OAAO;CACtB,MAAM,UAAU,MAAM;CACtB,OAAO,UACH,QAAQ,MAAM,MAAM,SAAS,KAAK,OAAO,QAAQ,KAAK,CAAC,QAAQ,cAAc,I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AAM,MAAM,SAAS,MAAM,SAAS,YAAY,KAAK,EAAE,MAAM,MAAM;CAC9F,IAAI,CAAC,MAAM,MAAM,IAAI,MAAM,sBAAsB,QAAQ;CACzD,MAAM,UAAU,MAAM;CACtB,MAAM,YAAY,CAAC,QAAQ,cAAc,IAAI,KAAK,EAAE;CAEpD,MAAM,+BAA+B,QAAQ,SAAS,KAAK,EAAE,CAAC;CAC9D,oBAAoB,KAAK;CACzB,OAAO;AACT"}
1
+ {"version":3,"file":"document-state.js","names":[],"sources":["../../../../src/kiwi/fig/session/document-state.ts"],"sourcesContent":["import {\n createFigDocumentSession,\n figCheckpointRecords,\n type FigSessionCheckpoint\n} from '@pairdraw/fig'\nimport type { SceneGraph } from '@pairdraw/scene-graph'\n\nimport { figArchive } from '#core/kiwi/fig/session/archive/access'\nimport { readerSessionOptions, type FigReaderDiagnostic } from '#core/kiwi/fig/session/options'\n\n/**\n * Per-graph reader state: the archive bytes, the live session or its checkpoint, and the\n * records that session skipped. Page population, diagnostics and recovery all read it.\n */\ninterface ReaderState {\n /** The archive, until every page is in the graph and nothing is left to read from it. */\n bytes?: ArrayBuffer\n checkpoint?: FigSessionCheckpoint\n session?: ReturnType<typeof createFigDocumentSession>\n /** Records skipped by sessions this recovery state has opened. */\n diagnostics: FigReaderDiagnostic[]\n /** Every page is loaded and the reader released; only the diagnostics remain. */\n complete?: true\n}\nconst states = new WeakMap<SceneGraph, ReaderState>()\n\nexport function registerReaderRecovery(\n graph: SceneGraph,\n bytes: ArrayBuffer,\n checkpoint: FigSessionCheckpoint\n): void {\n states.set(graph, { bytes, checkpoint, diagnostics: [] })\n}\n\nexport function registerReaderSession(\n bytes: ArrayBuffer,\n session: ReturnType<typeof createFigDocumentSession>,\n diagnostics: FigReaderDiagnostic[] = []\n): void {\n states.set(session.graph, { bytes, session, diagnostics })\n}\n\n/** Records skipped while opening, recovering, or exporting this graph's document. */\nexport function readerDiagnostics(graph: SceneGraph): readonly FigReaderDiagnostic[] {\n return states.get(graph)?.diagnostics ?? []\n}\n\nexport function isReaderPagePending(graph: SceneGraph, pageId: string): boolean {\n const state = states.get(graph)\n if (!state || state.complete) return false\n const checkpoint = state.session?.checkpoint() ?? state.checkpoint\n const sourceId = checkpoint?.sources.find(([, graphId]) => graphId === pageId)?.[0]\n if (!sourceId) return false\n const session = state.session\n return session\n ? session.pages.some((page) => page.id === sourceId) && !session.loadedPageIds.has(sourceId)\n : !checkpoint.loadedPageIds.includes(sourceId)\n}\n\n/**\n * The page holding a layer of the file while that page has not loaded, so a layer named by its\n * ID, as a link to it names it, is found by loading its page. A layer's ID is its record's GUID;\n * the archive answers which page holds it, in the reader's worker when there is one.\n */\nexport async function pendingReaderPageOfNode(\n graph: SceneGraph,\n nodeId: string\n): Promise<string | null> {\n const archive = figArchive(graph)\n const checkpoint = readerCheckpoint(graph)\n if (!archive || !checkpoint || states.get(graph)?.complete) return null\n const [pageGuid] = await archive.recordPages([nodeId])\n const pageId = pageGuid ? figCheckpointRecords(checkpoint).get(pageGuid) : undefined\n return pageId && isReaderPagePending(graph, pageId) ? pageId : null\n}\n\n/** Where the reader stands: which records became which layers, and which pages it loaded. */\nexport function readerCheckpoint(graph: SceneGraph): FigSessionCheckpoint | undefined {\n const state = states.get(graph)\n return state?.session?.checkpoint() ?? state?.checkpoint\n}\n\nexport function hasReaderSession(graph: SceneGraph): boolean {\n return states.has(graph)\n}\n\nexport function populateFigPage(graph: SceneGraph, pageId: string): boolean {\n return isReaderPagePending(graph, pageId) ? recoverReaderPage(graph, pageId) : false\n}\n\nexport function populateAllFigPages(graph: SceneGraph): boolean {\n let changed = false\n for (const page of graph.getPages()) {\n if (populateFigPage(graph, page.id)) changed = true\n }\n return changed\n}\n\n/**\n * Drop the session and the archive once every page is in the graph, internal ones included, which\n * the first full save loads. The session keeps every record of the file decoded, which for a\n * large design kit is gigabytes, and no page is pending. The checkpoint stays: it says which\n * record each layer came from, which saving only the changed records still reads.\n */\nfunction releaseLoadedReader(state: ReaderState): void {\n const session = state.session\n if (!session?.pages.every((page) => session.loadedPageIds.has(page.id))) return\n state.checkpoint = session.checkpoint()\n state.session = undefined\n state.bytes = undefined\n state.complete = true\n}\n\n/**\n * Load the pages the editor never shows, such as Figma's internal canvas, into the document's own\n * graph, so a save no longer opens a second session to read them into its copy. Their layers\n * never draw and loading them is not an edit. Only a live session loads them: while a population\n * worker still fills the graph, a second session must not, and the export reads them as before.\n */\nexport function populateFigInternalPages(graph: SceneGraph): boolean {\n const state = states.get(graph)\n const session = state?.session\n if (!state || !session) return false\n let changed = false\n for (const page of session.pages) {\n if (!page.internalOnly || session.loadedPageIds.has(page.id)) continue\n graph.applyImportedStateDuring(() => session.loadPage(page.id))\n changed = true\n }\n releaseLoadedReader(state)\n return changed\n}\n\n/**\n * Whether a save still has pages to read from the archive, which it reads into a copy of the\n * document: a population worker still fills the graph, or a page is not loaded yet.\n */\nexport function hasPendingReaderPages(graph: SceneGraph): boolean {\n const state = states.get(graph)\n if (!state || state.complete) return false\n const session = state.session\n return !session || !session.pages.every((page) => session.loadedPageIds.has(page.id))\n}\n\nexport function populateReaderExport(source: SceneGraph, target: SceneGraph): boolean {\n const state = states.get(source)\n if (!state || state.complete) return false\n const live = state.session\n // Every page is already in the graph the target was copied from.\n if (live?.pages.every((page) => live.loadedPageIds.has(page.id))) return false\n const checkpoint = live?.checkpoint() ?? state.checkpoint\n if (!checkpoint || !state.bytes) throw new Error('Missing reader checkpoint')\n const session = createFigDocumentSession(state.bytes, readerSessionOptions(state.diagnostics), {\n graph: target,\n checkpoint\n })\n // Export must include internal content too, not just the dependency closure needed\n // for visible pages. Loading happens on the isolated target, never the live graph.\n for (const page of session.pages) session.loadPage(page.id)\n return true\n}\n\nexport function updateReaderRecovery(graph: SceneGraph, checkpoint: FigSessionCheckpoint): void {\n const state = states.get(graph)\n if (state && !state.session) state.checkpoint = checkpoint\n}\n\nexport function releaseReaderRecovery(graph: SceneGraph): void {\n states.delete(graph)\n}\n\nexport function recoverReaderPage(graph: SceneGraph, pageId: string): boolean {\n const state = states.get(graph)\n if (!state) throw new Error('No reader recovery state')\n if (state.complete) return false\n if (!state.session) {\n if (!state.checkpoint || !state.bytes) throw new Error('Missing reader checkpoint')\n state.session = createFigDocumentSession(state.bytes, readerSessionOptions(state.diagnostics), {\n graph,\n checkpoint: state.checkpoint\n })\n }\n const page = state.session.pages.find((page) => state.session?.graphPageId(page.id) === pageId)\n if (!page) throw new Error(`Unknown graph page ${pageId}`)\n const session = state.session\n const populated = !session.loadedPageIds.has(page.id)\n // The layers come from the opened file, as they do through the population worker's delta.\n graph.applyImportedStateDuring(() => session.loadPage(page.id))\n releaseLoadedReader(state)\n return populated\n}\n"],"mappings":";;;;AAwBA,MAAM,yBAAS,IAAI,QAAiC;AAEpD,SAAgB,uBACd,OACA,OACA,YACM;CACN,OAAO,IAAI,OAAO;EAAE;EAAO;EAAY,aAAa,CAAC;CAAE,CAAC;AAC1D;AAEA,SAAgB,sBACd,OACA,SACA,cAAqC,CAAC,GAChC;CACN,OAAO,IAAI,QAAQ,OAAO;EAAE;EAAO;EAAS;CAAY,CAAC;AAC3D;;AAGA,SAAgB,kBAAkB,OAAmD;CACnF,OAAO,OAAO,IAAI,KAAK,CAAC,EAAE,eAAe,CAAC;AAC5C;AAEA,SAAgB,oBAAoB,OAAmB,QAAyB;CAC9E,MAAM,QAAQ,OAAO,IAAI,KAAK;CAC9B,IAAI,CAAC,SAAS,MAAM,UAAU,OAAO;CACrC,MAAM,aAAa,MAAM,SAAS,WAAW,KAAK,MAAM;CACxD,MAAM,WAAW,YAAY,QAAQ,MAAM,GAAG,aAAa,YAAY,MAAM,CAAC,GAAG;CACjF,IAAI,CAAC,UAAU,OAAO;CACtB,MAAM,UAAU,MAAM;CACtB,OAAO,UACH,QAAQ,MAAM,MAAM,SAAS,KAAK,OAAO,QAAQ,KAAK,CAAC,QAAQ,cAAc,IAAI,QAAQ,IACzF,CAAC,WAAW,cAAc,SAAS,QAAQ;AACjD;;;;;;AAOA,eAAs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