@pairdraw/core 0.19.2 → 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (847) hide show
  1. package/dist/ai/providers.d.ts +6 -0
  2. package/dist/ai/providers.d.ts.map +1 -1
  3. package/dist/ai/providers.js.map +1 -1
  4. package/dist/cache/resource.d.ts +8 -1
  5. package/dist/cache/resource.d.ts.map +1 -1
  6. package/dist/cache/resource.js +18 -0
  7. package/dist/cache/resource.js.map +1 -1
  8. package/dist/canvas/effects.d.ts +6 -4
  9. package/dist/canvas/effects.d.ts.map +1 -1
  10. package/dist/canvas/effects.js +37 -34
  11. package/dist/canvas/effects.js.map +1 -1
  12. package/dist/canvas/fills.d.ts.map +1 -1
  13. package/dist/canvas/fills.js +12 -8
  14. package/dist/canvas/fills.js.map +1 -1
  15. package/dist/canvas/images/adjustments.d.ts +18 -0
  16. package/dist/canvas/images/adjustments.d.ts.map +1 -0
  17. package/dist/canvas/images/adjustments.js +184 -0
  18. package/dist/canvas/images/adjustments.js.map +1 -0
  19. package/dist/canvas/images/sampling.d.ts +13 -0
  20. package/dist/canvas/images/sampling.d.ts.map +1 -0
  21. package/dist/canvas/images/sampling.js +49 -0
  22. package/dist/canvas/images/sampling.js.map +1 -0
  23. package/dist/canvas/index.d.ts +2 -2
  24. package/dist/canvas/masks.d.ts +1 -1
  25. package/dist/canvas/masks.d.ts.map +1 -1
  26. package/dist/canvas/masks.js.map +1 -1
  27. package/dist/canvas/noise/render.d.ts +15 -0
  28. package/dist/canvas/noise/render.d.ts.map +1 -0
  29. package/dist/canvas/noise/render.js +56 -0
  30. package/dist/canvas/noise/render.js.map +1 -0
  31. package/dist/canvas/noise/shader.d.ts +43 -0
  32. package/dist/canvas/noise/shader.d.ts.map +1 -0
  33. package/dist/canvas/noise/shader.js +161 -0
  34. package/dist/canvas/noise/shader.js.map +1 -0
  35. package/dist/canvas/noise/table.d.ts +13 -0
  36. package/dist/canvas/noise/table.d.ts.map +1 -0
  37. package/dist/canvas/noise/table.js +408 -0
  38. package/dist/canvas/noise/table.js.map +1 -0
  39. package/dist/canvas/noise/tile.d.ts +22 -0
  40. package/dist/canvas/noise/tile.d.ts.map +1 -0
  41. package/dist/canvas/noise/tile.js +73 -0
  42. package/dist/canvas/noise/tile.js.map +1 -0
  43. package/dist/canvas/outline-stroke.js +1 -1
  44. package/dist/canvas/overlays/auto-layout-hover.d.ts.map +1 -1
  45. package/dist/canvas/overlays/auto-layout-hover.js +31 -71
  46. package/dist/canvas/overlays/auto-layout-hover.js.map +1 -1
  47. package/dist/canvas/renderer/chunks/index.d.ts +1 -1
  48. package/dist/canvas/renderer/lifecycle.d.ts.map +1 -1
  49. package/dist/canvas/renderer/lifecycle.js +6 -0
  50. package/dist/canvas/renderer/lifecycle.js.map +1 -1
  51. package/dist/canvas/renderer/pipeline.d.ts.map +1 -1
  52. package/dist/canvas/renderer/pipeline.js +13 -1
  53. package/dist/canvas/renderer/pipeline.js.map +1 -1
  54. package/dist/canvas/renderer/play-scenes.d.ts +13 -0
  55. package/dist/canvas/renderer/play-scenes.d.ts.map +1 -0
  56. package/dist/canvas/renderer/play-scenes.js +40 -0
  57. package/dist/canvas/renderer/play-scenes.js.map +1 -0
  58. package/dist/canvas/renderer/tiles/cache.d.ts +19 -1
  59. package/dist/canvas/renderer/tiles/cache.d.ts.map +1 -1
  60. package/dist/canvas/renderer/tiles/cache.js +32 -1
  61. package/dist/canvas/renderer/tiles/cache.js.map +1 -1
  62. package/dist/canvas/renderer/tiles/controller.d.ts +11 -0
  63. package/dist/canvas/renderer/tiles/controller.d.ts.map +1 -1
  64. package/dist/canvas/renderer/tiles/controller.js +18 -1
  65. package/dist/canvas/renderer/tiles/controller.js.map +1 -1
  66. package/dist/canvas/renderer/tiles/index.d.ts +2 -2
  67. package/dist/canvas/renderer/tiles/planner.d.ts +1 -1
  68. package/dist/canvas/renderer/types.d.ts +18 -3
  69. package/dist/canvas/renderer/types.d.ts.map +1 -1
  70. package/dist/canvas/renderer/visual-bounds.d.ts +1 -1
  71. package/dist/canvas/renderer/visual-bounds.js +1 -1
  72. package/dist/canvas/renderer.d.ts +22 -2
  73. package/dist/canvas/renderer.d.ts.map +1 -1
  74. package/dist/canvas/renderer.js +29 -1
  75. package/dist/canvas/renderer.js.map +1 -1
  76. package/dist/canvas/scene.d.ts +2 -1
  77. package/dist/canvas/scene.d.ts.map +1 -1
  78. package/dist/canvas/scene.js +41 -9
  79. package/dist/canvas/scene.js.map +1 -1
  80. package/dist/canvas/shadows/silhouette.js +1 -1
  81. package/dist/canvas/texture.d.ts +20 -0
  82. package/dist/canvas/texture.d.ts.map +1 -0
  83. package/dist/canvas/texture.js +100 -0
  84. package/dist/canvas/texture.js.map +1 -0
  85. package/dist/clipboard.js +16 -5
  86. package/dist/clipboard.js.map +1 -1
  87. package/dist/constants.d.ts +5 -1
  88. package/dist/constants.d.ts.map +1 -1
  89. package/dist/constants.js +5 -1
  90. package/dist/constants.js.map +1 -1
  91. package/dist/design-jsx/renderer.d.ts.map +1 -1
  92. package/dist/design-memory/check.d.ts +90 -0
  93. package/dist/design-memory/check.d.ts.map +1 -0
  94. package/dist/design-memory/check.js +281 -0
  95. package/dist/design-memory/check.js.map +1 -0
  96. package/dist/design-memory/describe.d.ts +37 -0
  97. package/dist/design-memory/describe.d.ts.map +1 -0
  98. package/dist/design-memory/describe.js +52 -0
  99. package/dist/design-memory/describe.js.map +1 -0
  100. package/dist/design-memory/distil.d.ts +22 -0
  101. package/dist/design-memory/distil.d.ts.map +1 -0
  102. package/dist/design-memory/distil.js +54 -0
  103. package/dist/design-memory/distil.js.map +1 -0
  104. package/dist/design-memory/document.d.ts +12 -0
  105. package/dist/design-memory/document.d.ts.map +1 -0
  106. package/dist/design-memory/document.js +64 -0
  107. package/dist/design-memory/document.js.map +1 -0
  108. package/dist/design-memory/guard.d.ts +48 -0
  109. package/dist/design-memory/guard.d.ts.map +1 -0
  110. package/dist/design-memory/guard.js +105 -0
  111. package/dist/design-memory/guard.js.map +1 -0
  112. package/dist/design-memory/index.d.ts +9 -0
  113. package/dist/design-memory/index.js +9 -0
  114. package/dist/design-memory/refusal.d.ts +32 -0
  115. package/dist/design-memory/refusal.d.ts.map +1 -0
  116. package/dist/design-memory/refusal.js +68 -0
  117. package/dist/design-memory/refusal.js.map +1 -0
  118. package/dist/design-memory/rules.d.ts +63 -0
  119. package/dist/design-memory/rules.d.ts.map +1 -0
  120. package/dist/design-memory/rules.js +224 -0
  121. package/dist/design-memory/rules.js.map +1 -0
  122. package/dist/design-memory/values.d.ts +28 -0
  123. package/dist/design-memory/values.d.ts.map +1 -0
  124. package/dist/design-memory/values.js +160 -0
  125. package/dist/design-memory/values.js.map +1 -0
  126. package/dist/editor/alignment.js +1 -1
  127. package/dist/editor/bridges/components.d.ts +2 -0
  128. package/dist/editor/bridges/components.d.ts.map +1 -1
  129. package/dist/editor/bridges/components.js +2 -0
  130. package/dist/editor/bridges/components.js.map +1 -1
  131. package/dist/editor/bridges/undo.d.ts +1 -1
  132. package/dist/editor/clipboard/assets.js +1 -1
  133. package/dist/editor/clipboard/export.d.ts.map +1 -1
  134. package/dist/editor/clipboard/export.js +16 -2
  135. package/dist/editor/clipboard/export.js.map +1 -1
  136. package/dist/editor/clipboard/placement.d.ts +1 -1
  137. package/dist/editor/clipboard/placement.js +1 -1
  138. package/dist/editor/components/instances.d.ts +2 -0
  139. package/dist/editor/components/instances.d.ts.map +1 -1
  140. package/dist/editor/components/instances.js +22 -1
  141. package/dist/editor/components/instances.js.map +1 -1
  142. package/dist/editor/components.d.ts +2 -0
  143. package/dist/editor/components.d.ts.map +1 -1
  144. package/dist/editor/connectors/attach.js +1 -1
  145. package/dist/editor/create.d.ts +27 -3
  146. package/dist/editor/create.d.ts.map +1 -1
  147. package/dist/editor/create.js +16 -60
  148. package/dist/editor/create.js.map +1 -1
  149. package/dist/editor/design-memory.d.ts +11 -0
  150. package/dist/editor/design-memory.d.ts.map +1 -0
  151. package/dist/editor/design-memory.js +40 -0
  152. package/dist/editor/design-memory.js.map +1 -0
  153. package/dist/editor/design-tokens.d.ts +4 -0
  154. package/dist/editor/design-tokens.d.ts.map +1 -1
  155. package/dist/editor/design-tokens.js +30 -1
  156. package/dist/editor/design-tokens.js.map +1 -1
  157. package/dist/editor/document-colors.d.ts +23 -0
  158. package/dist/editor/document-colors.d.ts.map +1 -0
  159. package/dist/editor/document-colors.js +53 -0
  160. package/dist/editor/document-colors.js.map +1 -0
  161. package/dist/editor/eyedropper.d.ts +47 -0
  162. package/dist/editor/eyedropper.d.ts.map +1 -0
  163. package/dist/editor/eyedropper.js +168 -0
  164. package/dist/editor/eyedropper.js.map +1 -0
  165. package/dist/editor/fonts.d.ts +9 -0
  166. package/dist/editor/fonts.d.ts.map +1 -0
  167. package/dist/editor/fonts.js +14 -0
  168. package/dist/editor/fonts.js.map +1 -0
  169. package/dist/editor/history/atomic-tool.d.ts +9 -2
  170. package/dist/editor/history/atomic-tool.d.ts.map +1 -1
  171. package/dist/editor/history/atomic-tool.js +6 -0
  172. package/dist/editor/history/atomic-tool.js.map +1 -1
  173. package/dist/editor/history/capture.d.ts +13 -0
  174. package/dist/editor/history/capture.d.ts.map +1 -0
  175. package/dist/editor/history/capture.js +28 -0
  176. package/dist/editor/history/capture.js.map +1 -0
  177. package/dist/editor/history/document-change.d.ts.map +1 -1
  178. package/dist/editor/history/document-change.js +2 -22
  179. package/dist/editor/history/document-change.js.map +1 -1
  180. package/dist/editor/history/edit.d.ts +7 -0
  181. package/dist/editor/history/edit.d.ts.map +1 -1
  182. package/dist/editor/history/edit.js +4 -2
  183. package/dist/editor/history/edit.js.map +1 -1
  184. package/dist/editor/history/subtree.d.ts +9 -0
  185. package/dist/editor/history/subtree.d.ts.map +1 -1
  186. package/dist/editor/history/subtree.js +12 -2
  187. package/dist/editor/history/subtree.js.map +1 -1
  188. package/dist/editor/index.d.ts +4 -2
  189. package/dist/editor/index.js +4 -2
  190. package/dist/editor/pages.d.ts +7 -5
  191. package/dist/editor/pages.d.ts.map +1 -1
  192. package/dist/editor/pages.js +35 -25
  193. package/dist/editor/pages.js.map +1 -1
  194. package/dist/editor/play/states.d.ts +3 -1
  195. package/dist/editor/play/states.d.ts.map +1 -1
  196. package/dist/editor/play/states.js +1 -1
  197. package/dist/editor/play/states.js.map +1 -1
  198. package/dist/editor/read-only/actions.js +4 -0
  199. package/dist/editor/read-only/actions.js.map +1 -1
  200. package/dist/editor/render-requests.d.ts +18 -0
  201. package/dist/editor/render-requests.d.ts.map +1 -0
  202. package/dist/editor/render-requests.js +76 -0
  203. package/dist/editor/render-requests.js.map +1 -0
  204. package/dist/editor/scale/rescale.d.ts +1 -1
  205. package/dist/editor/selection/overlays.d.ts.map +1 -1
  206. package/dist/editor/selection/overlays.js +1 -1
  207. package/dist/editor/selection/overlays.js.map +1 -1
  208. package/dist/editor/selection/read.d.ts +4 -0
  209. package/dist/editor/selection.d.ts +5 -0
  210. package/dist/editor/selection.d.ts.map +1 -1
  211. package/dist/editor/tool-registry.d.ts.map +1 -1
  212. package/dist/editor/tool-registry.js +2 -1
  213. package/dist/editor/tool-registry.js.map +1 -1
  214. package/dist/editor/types.d.ts +5 -1
  215. package/dist/editor/types.d.ts.map +1 -1
  216. package/dist/editor/variations/create.d.ts +28 -0
  217. package/dist/editor/variations/create.d.ts.map +1 -0
  218. package/dist/editor/variations/create.js +176 -0
  219. package/dist/editor/variations/create.js.map +1 -0
  220. package/dist/editor/variations/pick.d.ts +16 -0
  221. package/dist/editor/variations/pick.d.ts.map +1 -0
  222. package/dist/editor/variations/pick.js +23 -0
  223. package/dist/editor/variations/pick.js.map +1 -0
  224. package/dist/editor/variations.d.ts +28 -0
  225. package/dist/editor/variations.d.ts.map +1 -0
  226. package/dist/editor/variations.js +88 -0
  227. package/dist/editor/variations.js.map +1 -0
  228. package/dist/figma-api/accessors/reactions.d.ts.map +1 -1
  229. package/dist/figma-api/accessors/reactions.js +4 -1
  230. package/dist/figma-api/accessors/reactions.js.map +1 -1
  231. package/dist/figma-api/accessors/text/index.js +3 -0
  232. package/dist/figma-api/accessors/text/index.js.map +1 -1
  233. package/dist/figma-api/accessors/text/opentype.d.ts +17 -0
  234. package/dist/figma-api/accessors/text/opentype.d.ts.map +1 -0
  235. package/dist/figma-api/accessors/text/opentype.js +28 -0
  236. package/dist/figma-api/accessors/text/opentype.js.map +1 -0
  237. package/dist/figma-api/accessors/visual.d.ts.map +1 -1
  238. package/dist/figma-api/accessors/visual.js +33 -0
  239. package/dist/figma-api/accessors/visual.js.map +1 -1
  240. package/dist/figma-api/effects.d.ts +79 -3
  241. package/dist/figma-api/effects.d.ts.map +1 -1
  242. package/dist/figma-api/effects.js +150 -9
  243. package/dist/figma-api/effects.js.map +1 -1
  244. package/dist/figma-api/index.d.ts +5 -0
  245. package/dist/figma-api/index.d.ts.map +1 -1
  246. package/dist/figma-api/index.js +6 -1
  247. package/dist/figma-api/index.js.map +1 -1
  248. package/dist/figma-api/overrides.d.ts +13 -1
  249. package/dist/figma-api/overrides.d.ts.map +1 -1
  250. package/dist/figma-api/overrides.js +196 -4
  251. package/dist/figma-api/overrides.js.map +1 -1
  252. package/dist/figma-api/paints.d.ts +3 -3
  253. package/dist/figma-api/paints.d.ts.map +1 -1
  254. package/dist/figma-api/paints.js +14 -4
  255. package/dist/figma-api/paints.js.map +1 -1
  256. package/dist/figma-api/proxy.d.ts +4 -1
  257. package/dist/figma-api/proxy.d.ts.map +1 -1
  258. package/dist/figma-api/proxy.js +1 -1
  259. package/dist/figma-api/proxy.js.map +1 -1
  260. package/dist/figma-api/reactions.d.ts +41 -13
  261. package/dist/figma-api/reactions.d.ts.map +1 -1
  262. package/dist/figma-api/reactions.js +113 -31
  263. package/dist/figma-api/reactions.js.map +1 -1
  264. package/dist/figma-api/render-bounds.js +1 -1
  265. package/dist/figma-api/surface.d.ts +6 -3
  266. package/dist/figma-api/surface.d.ts.map +1 -1
  267. package/dist/figma-api/surface.js +6 -2
  268. package/dist/figma-api/surface.js.map +1 -1
  269. package/dist/figma-api/transform.d.ts +1 -1
  270. package/dist/geometry/figma.d.ts +1 -1
  271. package/dist/geometry/image-crop.d.ts +1 -1
  272. package/dist/geometry/image-crop.js +1 -1
  273. package/dist/index.d.ts +4 -2
  274. package/dist/index.js +4 -2
  275. package/dist/io/formats/boolean-path.d.ts +19 -0
  276. package/dist/io/formats/boolean-path.d.ts.map +1 -0
  277. package/dist/io/formats/boolean-path.js +47 -0
  278. package/dist/io/formats/boolean-path.js.map +1 -0
  279. package/dist/io/formats/design-tokens/decode.js +1 -1
  280. package/dist/io/formats/design-tokens/index.d.ts +4 -1
  281. package/dist/io/formats/design-tokens/index.js +4 -1
  282. package/dist/io/formats/design-tokens/plan/changes.d.ts +5 -3
  283. package/dist/io/formats/design-tokens/plan/changes.d.ts.map +1 -1
  284. package/dist/io/formats/design-tokens/plan/changes.js +1 -1
  285. package/dist/io/formats/design-tokens/plan/changes.js.map +1 -1
  286. package/dist/io/formats/design-tokens/project.d.ts +17 -2
  287. package/dist/io/formats/design-tokens/project.d.ts.map +1 -1
  288. package/dist/io/formats/design-tokens/project.js +29 -8
  289. package/dist/io/formats/design-tokens/project.js.map +1 -1
  290. package/dist/io/formats/design-tokens/styles.d.ts.map +1 -1
  291. package/dist/io/formats/design-tokens/styles.js.map +1 -1
  292. package/dist/io/formats/design-tokens/sync/apply.d.ts +42 -0
  293. package/dist/io/formats/design-tokens/sync/apply.d.ts.map +1 -0
  294. package/dist/io/formats/design-tokens/sync/apply.js +73 -0
  295. package/dist/io/formats/design-tokens/sync/apply.js.map +1 -0
  296. package/dist/io/formats/design-tokens/sync/drift.d.ts +77 -0
  297. package/dist/io/formats/design-tokens/sync/drift.d.ts.map +1 -0
  298. package/dist/io/formats/design-tokens/sync/drift.js +391 -0
  299. package/dist/io/formats/design-tokens/sync/drift.js.map +1 -0
  300. package/dist/io/formats/design-tokens/sync/files.d.ts +15 -0
  301. package/dist/io/formats/design-tokens/sync/files.d.ts.map +1 -0
  302. package/dist/io/formats/design-tokens/sync/files.js +35 -0
  303. package/dist/io/formats/design-tokens/sync/files.js.map +1 -0
  304. package/dist/io/formats/drawio/edges.d.ts +7 -1
  305. package/dist/io/formats/drawio/edges.d.ts.map +1 -1
  306. package/dist/io/formats/drawio/edges.js +54 -1
  307. package/dist/io/formats/drawio/edges.js.map +1 -1
  308. package/dist/io/formats/drawio/export.d.ts.map +1 -1
  309. package/dist/io/formats/drawio/export.js +19 -2
  310. package/dist/io/formats/drawio/export.js.map +1 -1
  311. package/dist/io/formats/drawio/index.js +1 -0
  312. package/dist/io/formats/drawio/index.js.map +1 -1
  313. package/dist/io/formats/drawio/label.js +1 -1
  314. package/dist/io/formats/drawio/paint.js +1 -1
  315. package/dist/io/formats/drawio/placement.d.ts +1 -1
  316. package/dist/io/formats/fig/export/patch/index.d.ts.map +1 -1
  317. package/dist/io/formats/fig/export/patch/index.js +5 -0
  318. package/dist/io/formats/fig/export/patch/index.js.map +1 -1
  319. package/dist/io/formats/fig/thumbnail-page.d.ts +3 -4
  320. package/dist/io/formats/fig/thumbnail-page.d.ts.map +1 -1
  321. package/dist/io/formats/fig/thumbnail-page.js.map +1 -1
  322. package/dist/io/formats/html/import.d.ts.map +1 -1
  323. package/dist/io/formats/html/import.js +3 -1
  324. package/dist/io/formats/html/import.js.map +1 -1
  325. package/dist/io/formats/html/index.d.ts +2 -2
  326. package/dist/io/formats/html/index.d.ts.map +1 -1
  327. package/dist/io/formats/html/index.js +6 -4
  328. package/dist/io/formats/html/index.js.map +1 -1
  329. package/dist/io/formats/html/vectors.d.ts +2 -1
  330. package/dist/io/formats/html/vectors.d.ts.map +1 -1
  331. package/dist/io/formats/html/vectors.js +3 -2
  332. package/dist/io/formats/html/vectors.js.map +1 -1
  333. package/dist/io/formats/mermaid/styles.js +1 -1
  334. package/dist/io/formats/pdf/document.d.ts +3 -1
  335. package/dist/io/formats/pdf/document.d.ts.map +1 -1
  336. package/dist/io/formats/pdf/document.js +6 -3
  337. package/dist/io/formats/pdf/document.js.map +1 -1
  338. package/dist/io/formats/pdf/prepare.d.ts +1 -1
  339. package/dist/io/formats/pen/imports.d.ts +4 -1
  340. package/dist/io/formats/pen/imports.d.ts.map +1 -1
  341. package/dist/io/formats/pen/imports.js.map +1 -1
  342. package/dist/io/formats/pen/index.d.ts.map +1 -1
  343. package/dist/io/formats/pen/index.js +31 -3
  344. package/dist/io/formats/pen/index.js.map +1 -1
  345. package/dist/io/formats/pptx/export.js +1 -1
  346. package/dist/io/formats/pptx/geometry.d.ts +1 -1
  347. package/dist/io/formats/raster/adjusted-images.d.ts +15 -0
  348. package/dist/io/formats/raster/adjusted-images.d.ts.map +1 -0
  349. package/dist/io/formats/raster/adjusted-images.js +118 -0
  350. package/dist/io/formats/raster/adjusted-images.js.map +1 -0
  351. package/dist/io/formats/raster/headless.d.ts +11 -1
  352. package/dist/io/formats/raster/headless.d.ts.map +1 -1
  353. package/dist/io/formats/raster/headless.js +4 -4
  354. package/dist/io/formats/raster/headless.js.map +1 -1
  355. package/dist/io/formats/raster/index.d.ts +2 -2
  356. package/dist/io/formats/raster/pixels.d.ts +7 -1
  357. package/dist/io/formats/raster/pixels.d.ts.map +1 -1
  358. package/dist/io/formats/raster/pixels.js.map +1 -1
  359. package/dist/io/formats/raster/render.d.ts.map +1 -1
  360. package/dist/io/formats/raster/render.js +4 -0
  361. package/dist/io/formats/raster/render.js.map +1 -1
  362. package/dist/io/formats/svg/defs.d.ts +5 -6
  363. package/dist/io/formats/svg/defs.d.ts.map +1 -1
  364. package/dist/io/formats/svg/defs.js +1 -53
  365. package/dist/io/formats/svg/defs.js.map +1 -1
  366. package/dist/io/formats/svg/effects.d.ts +16 -0
  367. package/dist/io/formats/svg/effects.d.ts.map +1 -0
  368. package/dist/io/formats/svg/effects.js +126 -0
  369. package/dist/io/formats/svg/effects.js.map +1 -0
  370. package/dist/io/formats/svg/export.d.ts +7 -1
  371. package/dist/io/formats/svg/export.d.ts.map +1 -1
  372. package/dist/io/formats/svg/export.js +174 -36
  373. package/dist/io/formats/svg/export.js.map +1 -1
  374. package/dist/io/formats/svg/filter.d.ts +27 -0
  375. package/dist/io/formats/svg/filter.d.ts.map +1 -0
  376. package/dist/io/formats/svg/filter.js +44 -0
  377. package/dist/io/formats/svg/filter.js.map +1 -0
  378. package/dist/io/formats/svg/grain.d.ts +26 -0
  379. package/dist/io/formats/svg/grain.d.ts.map +1 -0
  380. package/dist/io/formats/svg/grain.js +298 -0
  381. package/dist/io/formats/svg/grain.js.map +1 -0
  382. package/dist/io/formats/svg/strokes.d.ts +1 -1
  383. package/dist/io/formats/svg/strokes.d.ts.map +1 -1
  384. package/dist/io/formats/svg/strokes.js +1 -2
  385. package/dist/io/formats/svg/strokes.js.map +1 -1
  386. package/dist/io/formats/svg/text/import.js +1 -1
  387. package/dist/io/formats/svg/text/layout.d.ts +5 -2
  388. package/dist/io/formats/svg/text/layout.d.ts.map +1 -1
  389. package/dist/io/formats/svg/text/layout.js +6 -3
  390. package/dist/io/formats/svg/text/layout.js.map +1 -1
  391. package/dist/io/formats/video/composite.d.ts +18 -0
  392. package/dist/io/formats/video/composite.d.ts.map +1 -0
  393. package/dist/io/formats/video/composite.js +79 -0
  394. package/dist/io/formats/video/composite.js.map +1 -0
  395. package/dist/io/formats/video/formats.d.ts +29 -0
  396. package/dist/io/formats/video/formats.d.ts.map +1 -0
  397. package/dist/io/formats/video/formats.js +43 -0
  398. package/dist/io/formats/video/formats.js.map +1 -0
  399. package/dist/io/formats/video/gif.d.ts +13 -0
  400. package/dist/io/formats/video/gif.d.ts.map +1 -0
  401. package/dist/io/formats/video/gif.js +56 -0
  402. package/dist/io/formats/video/gif.js.map +1 -0
  403. package/dist/io/formats/video/index.d.ts +9 -0
  404. package/dist/io/formats/video/index.js +9 -0
  405. package/dist/io/formats/video/plan.d.ts +64 -0
  406. package/dist/io/formats/video/plan.d.ts.map +1 -0
  407. package/dist/io/formats/video/plan.js +90 -0
  408. package/dist/io/formats/video/plan.js.map +1 -0
  409. package/dist/io/formats/video/record.d.ts +36 -0
  410. package/dist/io/formats/video/record.d.ts.map +1 -0
  411. package/dist/io/formats/video/record.js +154 -0
  412. package/dist/io/formats/video/record.js.map +1 -0
  413. package/dist/io/formats/video/sink.d.ts +29 -0
  414. package/dist/io/formats/video/sink.d.ts.map +1 -0
  415. package/dist/io/formats/video/sink.js +16 -0
  416. package/dist/io/formats/video/sink.js.map +1 -0
  417. package/dist/io/formats/video/size.d.ts +19 -0
  418. package/dist/io/formats/video/size.d.ts.map +1 -0
  419. package/dist/io/formats/video/size.js +26 -0
  420. package/dist/io/formats/video/size.js.map +1 -0
  421. package/dist/io/formats/video/webcodecs.d.ts +18 -0
  422. package/dist/io/formats/video/webcodecs.d.ts.map +1 -0
  423. package/dist/io/formats/video/webcodecs.js +74 -0
  424. package/dist/io/formats/video/webcodecs.js.map +1 -0
  425. package/dist/io/formats.d.ts.map +1 -1
  426. package/dist/io/formats.js +40 -11
  427. package/dist/io/formats.js.map +1 -1
  428. package/dist/io/types.d.ts +19 -4
  429. package/dist/io/types.d.ts.map +1 -1
  430. package/dist/kiwi/fig/parse/transfer.d.ts +1 -1
  431. package/dist/layout/auto-layout-handles.d.ts +66 -0
  432. package/dist/layout/auto-layout-handles.d.ts.map +1 -0
  433. package/dist/layout/auto-layout-handles.js +291 -0
  434. package/dist/layout/auto-layout-handles.js.map +1 -0
  435. package/dist/layout.d.ts +3 -2
  436. package/dist/layout.d.ts.map +1 -1
  437. package/dist/layout.js +2 -1
  438. package/dist/layout.js.map +1 -1
  439. package/dist/lint/fixes.d.ts.map +1 -1
  440. package/dist/lint/fixes.js +9 -3
  441. package/dist/lint/fixes.js.map +1 -1
  442. package/dist/lint/index.d.ts +3 -2
  443. package/dist/lint/index.js +2 -1
  444. package/dist/lint/linter.d.ts +12 -0
  445. package/dist/lint/linter.d.ts.map +1 -1
  446. package/dist/lint/linter.js +110 -8
  447. package/dist/lint/linter.js.map +1 -1
  448. package/dist/lint/presets.d.ts.map +1 -1
  449. package/dist/lint/presets.js +2 -0
  450. package/dist/lint/presets.js.map +1 -1
  451. package/dist/lint/rules/design-memory.d.ts +15 -0
  452. package/dist/lint/rules/design-memory.d.ts.map +1 -0
  453. package/dist/lint/rules/design-memory.js +90 -0
  454. package/dist/lint/rules/design-memory.js.map +1 -0
  455. package/dist/lint/rules/index.d.ts +6 -5
  456. package/dist/lint/rules/index.d.ts.map +1 -1
  457. package/dist/lint/rules/index.js +6 -2
  458. package/dist/lint/rules/index.js.map +1 -1
  459. package/dist/lint/rules/no-unbound-token-values.d.ts +6 -0
  460. package/dist/lint/rules/no-unbound-token-values.d.ts.map +1 -0
  461. package/dist/lint/rules/no-unbound-token-values.js +79 -0
  462. package/dist/lint/rules/no-unbound-token-values.js.map +1 -0
  463. package/dist/lint/types.d.ts +25 -2
  464. package/dist/lint/types.d.ts.map +1 -1
  465. package/dist/node/video.d.ts +12 -0
  466. package/dist/node/video.d.ts.map +1 -0
  467. package/dist/node/video.js +206 -0
  468. package/dist/node/video.js.map +1 -0
  469. package/dist/pairdraw-api/design-memory.d.ts +19 -0
  470. package/dist/pairdraw-api/design-memory.d.ts.map +1 -0
  471. package/dist/pairdraw-api/design-memory.js +39 -0
  472. package/dist/pairdraw-api/design-memory.js.map +1 -0
  473. package/dist/pairdraw-api/index.d.ts +45 -1
  474. package/dist/pairdraw-api/index.d.ts.map +1 -1
  475. package/dist/pairdraw-api/index.js +55 -2
  476. package/dist/pairdraw-api/index.js.map +1 -1
  477. package/dist/pairdraw-api/nodes.d.ts +12 -1
  478. package/dist/pairdraw-api/nodes.d.ts.map +1 -1
  479. package/dist/pairdraw-api/nodes.js +28 -1
  480. package/dist/pairdraw-api/nodes.js.map +1 -1
  481. package/dist/pairdraw-api/variations.d.ts +48 -0
  482. package/dist/pairdraw-api/variations.d.ts.map +1 -0
  483. package/dist/pairdraw-api/variations.js +76 -0
  484. package/dist/pairdraw-api/variations.js.map +1 -0
  485. package/dist/prototype/easing.d.ts +13 -0
  486. package/dist/prototype/easing.d.ts.map +1 -0
  487. package/dist/prototype/easing.js +36 -0
  488. package/dist/prototype/easing.js.map +1 -0
  489. package/dist/prototype/frames.d.ts +10 -0
  490. package/dist/prototype/frames.d.ts.map +1 -0
  491. package/dist/prototype/frames.js +12 -0
  492. package/dist/prototype/frames.js.map +1 -0
  493. package/dist/prototype/hit.d.ts +17 -0
  494. package/dist/prototype/hit.d.ts.map +1 -0
  495. package/dist/prototype/hit.js +45 -0
  496. package/dist/prototype/hit.js.map +1 -0
  497. package/dist/prototype/index.d.ts +14 -0
  498. package/dist/prototype/index.js +14 -0
  499. package/dist/prototype/pointer.d.ts +63 -0
  500. package/dist/prototype/pointer.d.ts.map +1 -0
  501. package/dist/prototype/pointer.js +104 -0
  502. package/dist/prototype/pointer.js.map +1 -0
  503. package/dist/prototype/reactions.d.ts +45 -0
  504. package/dist/prototype/reactions.d.ts.map +1 -0
  505. package/dist/prototype/reactions.js +122 -0
  506. package/dist/prototype/reactions.js.map +1 -0
  507. package/dist/prototype/scene.d.ts +35 -0
  508. package/dist/prototype/scene.d.ts.map +1 -0
  509. package/dist/prototype/scene.js +86 -0
  510. package/dist/prototype/scene.js.map +1 -0
  511. package/dist/prototype/scenes.d.ts +81 -0
  512. package/dist/prototype/scenes.d.ts.map +1 -0
  513. package/dist/prototype/scenes.js +175 -0
  514. package/dist/prototype/scenes.js.map +1 -0
  515. package/dist/prototype/scroll.d.ts +48 -0
  516. package/dist/prototype/scroll.d.ts.map +1 -0
  517. package/dist/prototype/scroll.js +159 -0
  518. package/dist/prototype/scroll.js.map +1 -0
  519. package/dist/prototype/session.d.ts +71 -0
  520. package/dist/prototype/session.d.ts.map +1 -0
  521. package/dist/prototype/session.js +135 -0
  522. package/dist/prototype/session.js.map +1 -0
  523. package/dist/prototype/smart-animate/animation.d.ts +34 -0
  524. package/dist/prototype/smart-animate/animation.d.ts.map +1 -0
  525. package/dist/prototype/smart-animate/animation.js +212 -0
  526. package/dist/prototype/smart-animate/animation.js.map +1 -0
  527. package/dist/prototype/smart-animate/match.d.ts +24 -0
  528. package/dist/prototype/smart-animate/match.d.ts.map +1 -0
  529. package/dist/prototype/smart-animate/match.js +72 -0
  530. package/dist/prototype/smart-animate/match.js.map +1 -0
  531. package/dist/prototype/snapshot.d.ts +19 -0
  532. package/dist/prototype/snapshot.d.ts.map +1 -0
  533. package/dist/prototype/snapshot.js +56 -0
  534. package/dist/prototype/snapshot.js.map +1 -0
  535. package/dist/prototype/timeline.d.ts +132 -0
  536. package/dist/prototype/timeline.d.ts.map +1 -0
  537. package/dist/prototype/timeline.js +260 -0
  538. package/dist/prototype/timeline.js.map +1 -0
  539. package/dist/rpc/read-commands.js +1 -1
  540. package/dist/text/font/features.d.ts +9 -0
  541. package/dist/text/font/features.d.ts.map +1 -0
  542. package/dist/text/font/features.js +27 -0
  543. package/dist/text/font/features.js.map +1 -0
  544. package/dist/text/font/manager.d.ts +12 -0
  545. package/dist/text/font/manager.d.ts.map +1 -1
  546. package/dist/text/font/manager.js +60 -1
  547. package/dist/text/font/manager.js.map +1 -1
  548. package/dist/text/index.d.ts +10 -8
  549. package/dist/text/index.js +3 -1
  550. package/dist/text/replace-fonts.d.ts +41 -0
  551. package/dist/text/replace-fonts.d.ts.map +1 -0
  552. package/dist/text/replace-fonts.js +121 -0
  553. package/dist/text/replace-fonts.js.map +1 -0
  554. package/dist/tools/analyze/responsive/index.d.ts +15 -0
  555. package/dist/tools/analyze/responsive/index.d.ts.map +1 -0
  556. package/dist/tools/analyze/responsive/index.js +203 -0
  557. package/dist/tools/analyze/responsive/index.js.map +1 -0
  558. package/dist/tools/analyze.d.ts +2 -1
  559. package/dist/tools/analyze.js +2 -1
  560. package/dist/tools/codegen/token-sync.d.ts +7 -0
  561. package/dist/tools/codegen/token-sync.d.ts.map +1 -0
  562. package/dist/tools/codegen/token-sync.js +85 -0
  563. package/dist/tools/codegen/token-sync.js.map +1 -0
  564. package/dist/tools/codegen/tokens.d.ts +1 -1
  565. package/dist/tools/codegen.d.ts +2 -1
  566. package/dist/tools/codegen.js +2 -1
  567. package/dist/tools/create/basic.js +1 -1
  568. package/dist/tools/create/behaviours.js +1 -1
  569. package/dist/tools/create/components.d.ts.map +1 -1
  570. package/dist/tools/create/components.js +4 -0
  571. package/dist/tools/create/components.js.map +1 -1
  572. package/dist/tools/create/html.js +3 -2
  573. package/dist/tools/create/html.js.map +1 -1
  574. package/dist/tools/create/icons.d.ts.map +1 -1
  575. package/dist/tools/create/icons.js +2 -1
  576. package/dist/tools/create/icons.js.map +1 -1
  577. package/dist/tools/create/mermaid.js +2 -1
  578. package/dist/tools/create/mermaid.js.map +1 -1
  579. package/dist/tools/create/render.js +1 -1
  580. package/dist/tools/create/svg.js +2 -1
  581. package/dist/tools/create/svg.js.map +1 -1
  582. package/dist/tools/create/vector.js +1 -1
  583. package/dist/tools/design-memory.d.ts +8 -0
  584. package/dist/tools/design-memory.d.ts.map +1 -0
  585. package/dist/tools/design-memory.js +68 -0
  586. package/dist/tools/design-memory.js.map +1 -0
  587. package/dist/tools/image-ai/generate.d.ts.map +1 -1
  588. package/dist/tools/image-ai/generate.js +3 -1
  589. package/dist/tools/image-ai/generate.js.map +1 -1
  590. package/dist/tools/index.d.ts +2 -1
  591. package/dist/tools/index.js +2 -1
  592. package/dist/tools/modify/fonts.d.ts +6 -0
  593. package/dist/tools/modify/fonts.d.ts.map +1 -0
  594. package/dist/tools/modify/fonts.js +27 -0
  595. package/dist/tools/modify/fonts.js.map +1 -0
  596. package/dist/tools/modify/paint.js +1 -1
  597. package/dist/tools/modify/reactions.d.ts.map +1 -1
  598. package/dist/tools/modify/reactions.js +3 -3
  599. package/dist/tools/modify/reactions.js.map +1 -1
  600. package/dist/tools/modify/text.d.ts.map +1 -1
  601. package/dist/tools/modify/text.js +26 -5
  602. package/dist/tools/modify/text.js.map +1 -1
  603. package/dist/tools/modify/update.d.ts +10 -1
  604. package/dist/tools/modify/update.d.ts.map +1 -1
  605. package/dist/tools/modify/update.js +34 -3
  606. package/dist/tools/modify/update.js.map +1 -1
  607. package/dist/tools/modify.d.ts +2 -1
  608. package/dist/tools/modify.js +2 -1
  609. package/dist/tools/read/fonts.d.ts.map +1 -1
  610. package/dist/tools/read/fonts.js +17 -2
  611. package/dist/tools/read/fonts.js.map +1 -1
  612. package/dist/tools/read/libraries.js +2 -1
  613. package/dist/tools/read/libraries.js.map +1 -1
  614. package/dist/tools/read/space.d.ts +3 -1
  615. package/dist/tools/read/space.d.ts.map +1 -1
  616. package/dist/tools/read/space.js +4 -3
  617. package/dist/tools/read/space.js.map +1 -1
  618. package/dist/tools/registry/core.d.ts +1 -1
  619. package/dist/tools/registry/core.d.ts.map +1 -1
  620. package/dist/tools/registry/core.js +3 -1
  621. package/dist/tools/registry/core.js.map +1 -1
  622. package/dist/tools/registry/extended.d.ts.map +1 -1
  623. package/dist/tools/registry/extended.js +16 -1
  624. package/dist/tools/registry/extended.js.map +1 -1
  625. package/dist/tools/schema.d.ts +18 -2
  626. package/dist/tools/schema.d.ts.map +1 -1
  627. package/dist/tools/schema.js +1 -1
  628. package/dist/tools/schema.js.map +1 -1
  629. package/dist/tools/stock-photo.js +1 -0
  630. package/dist/tools/stock-photo.js.map +1 -1
  631. package/dist/tools/structure/basic.d.ts.map +1 -1
  632. package/dist/tools/structure/basic.js +1 -0
  633. package/dist/tools/structure/basic.js.map +1 -1
  634. package/dist/tools/structure/batch.d.ts.map +1 -1
  635. package/dist/tools/structure/batch.js +8 -1
  636. package/dist/tools/structure/batch.js.map +1 -1
  637. package/dist/tools/structure/hierarchy.d.ts.map +1 -1
  638. package/dist/tools/structure/hierarchy.js +4 -0
  639. package/dist/tools/structure/hierarchy.js.map +1 -1
  640. package/dist/tools/structure/variations.d.ts +8 -0
  641. package/dist/tools/structure/variations.d.ts.map +1 -0
  642. package/dist/tools/structure/variations.js +106 -0
  643. package/dist/tools/structure/variations.js.map +1 -0
  644. package/dist/tools/structure.d.ts +2 -1
  645. package/dist/tools/structure.js +2 -1
  646. package/dist/tools/styles/types.d.ts +2 -4
  647. package/dist/tools/styles/types.d.ts.map +1 -1
  648. package/dist/tools/styles/types.js.map +1 -1
  649. package/dist/tools/vector/boolean.d.ts.map +1 -1
  650. package/dist/tools/vector/boolean.js +4 -0
  651. package/dist/tools/vector/boolean.js.map +1 -1
  652. package/dist/tools/vector/vectorize.js +1 -0
  653. package/dist/tools/vector/vectorize.js.map +1 -1
  654. package/dist/tools/vector/video.d.ts +6 -0
  655. package/dist/tools/vector/video.d.ts.map +1 -0
  656. package/dist/tools/vector/video.js +133 -0
  657. package/dist/tools/vector/video.js.map +1 -0
  658. package/dist/tools/vector.d.ts +2 -1
  659. package/dist/tools/vector.js +2 -1
  660. package/dist/tools/video-host.d.ts +12 -0
  661. package/dist/tools/video-host.d.ts.map +1 -0
  662. package/dist/tools/video-host.js +19 -0
  663. package/dist/tools/video-host.js.map +1 -0
  664. package/dist/vector/point-transform.d.ts +1 -1
  665. package/dist/vector/vectorize/svg/to-vectors.d.ts +1 -1
  666. package/package.json +31 -9
  667. package/src/ai/providers.ts +2 -0
  668. package/src/cache/resource.ts +24 -1
  669. package/src/canvas/effects.ts +47 -50
  670. package/src/canvas/fills.ts +19 -15
  671. package/src/canvas/images/adjustments.ts +203 -0
  672. package/src/canvas/images/sampling.ts +88 -0
  673. package/src/canvas/index.ts +1 -0
  674. package/src/canvas/masks.ts +1 -1
  675. package/src/canvas/noise/render.ts +75 -0
  676. package/src/canvas/noise/shader.ts +161 -0
  677. package/src/canvas/noise/table.ts +91 -0
  678. package/src/canvas/noise/tile.ts +94 -0
  679. package/src/canvas/overlays/auto-layout-hover.ts +47 -65
  680. package/src/canvas/renderer/lifecycle.ts +6 -0
  681. package/src/canvas/renderer/pipeline.ts +19 -1
  682. package/src/canvas/renderer/play-scenes.ts +51 -0
  683. package/src/canvas/renderer/tiles/cache.ts +54 -1
  684. package/src/canvas/renderer/tiles/controller.ts +30 -1
  685. package/src/canvas/renderer/types.ts +18 -2
  686. package/src/canvas/renderer.ts +40 -3
  687. package/src/canvas/scene.ts +65 -9
  688. package/src/canvas/texture.ts +136 -0
  689. package/src/clipboard.ts +23 -10
  690. package/src/constants.ts +6 -0
  691. package/src/design-memory/check.ts +376 -0
  692. package/src/design-memory/describe.ts +77 -0
  693. package/src/design-memory/distil.ts +69 -0
  694. package/src/design-memory/document.ts +80 -0
  695. package/src/design-memory/guard.ts +157 -0
  696. package/src/design-memory/index.ts +8 -0
  697. package/src/design-memory/refusal.ts +90 -0
  698. package/src/design-memory/rules.ts +274 -0
  699. package/src/design-memory/values.ts +179 -0
  700. package/src/editor/bridges/components.ts +2 -0
  701. package/src/editor/clipboard/export.ts +24 -7
  702. package/src/editor/components/instances.ts +31 -0
  703. package/src/editor/create.ts +25 -69
  704. package/src/editor/design-memory.ts +39 -0
  705. package/src/editor/design-tokens.ts +41 -2
  706. package/src/editor/document-colors.ts +65 -0
  707. package/src/editor/eyedropper.ts +198 -0
  708. package/src/editor/fonts.ts +19 -0
  709. package/src/editor/history/atomic-tool.ts +29 -1
  710. package/src/editor/history/capture.ts +19 -0
  711. package/src/editor/history/document-change.ts +5 -17
  712. package/src/editor/history/edit.ts +11 -1
  713. package/src/editor/history/subtree.ts +13 -2
  714. package/src/editor/index.ts +11 -0
  715. package/src/editor/pages.ts +40 -29
  716. package/src/editor/play/states.ts +1 -1
  717. package/src/editor/read-only/actions.ts +4 -0
  718. package/src/editor/render-requests.ts +83 -0
  719. package/src/editor/selection/overlays.ts +1 -0
  720. package/src/editor/tool-registry.ts +2 -1
  721. package/src/editor/types.ts +4 -0
  722. package/src/editor/variations/create.ts +235 -0
  723. package/src/editor/variations/pick.ts +35 -0
  724. package/src/editor/variations.ts +110 -0
  725. package/src/figma-api/accessors/reactions.ts +11 -1
  726. package/src/figma-api/accessors/text/index.ts +7 -0
  727. package/src/figma-api/accessors/text/opentype.ts +33 -0
  728. package/src/figma-api/accessors/visual.ts +55 -2
  729. package/src/figma-api/compatibility.ts +5 -2
  730. package/src/figma-api/effects.ts +143 -5
  731. package/src/figma-api/index.ts +10 -0
  732. package/src/figma-api/overrides.ts +295 -3
  733. package/src/figma-api/paints.ts +24 -9
  734. package/src/figma-api/proxy.ts +6 -1
  735. package/src/figma-api/reactions.ts +130 -32
  736. package/src/figma-api/surface.ts +6 -2
  737. package/src/global.d.ts +26 -0
  738. package/src/io/formats/boolean-path.ts +60 -0
  739. package/src/io/formats/design-tokens/index.ts +21 -0
  740. package/src/io/formats/design-tokens/plan/changes.ts +4 -1
  741. package/src/io/formats/design-tokens/project.ts +40 -9
  742. package/src/io/formats/design-tokens/styles.ts +10 -2
  743. package/src/io/formats/design-tokens/sync/apply.ts +130 -0
  744. package/src/io/formats/design-tokens/sync/drift.ts +587 -0
  745. package/src/io/formats/design-tokens/sync/files.ts +40 -0
  746. package/src/io/formats/drawio/edges.ts +65 -0
  747. package/src/io/formats/drawio/export.ts +37 -14
  748. package/src/io/formats/drawio/index.ts +2 -0
  749. package/src/io/formats/fig/export/patch/index.ts +8 -0
  750. package/src/io/formats/fig/thumbnail-page.ts +4 -4
  751. package/src/io/formats/html/import.ts +9 -1
  752. package/src/io/formats/html/index.ts +14 -7
  753. package/src/io/formats/html/vectors.ts +8 -2
  754. package/src/io/formats/pdf/document.ts +14 -4
  755. package/src/io/formats/pen/imports.ts +5 -6
  756. package/src/io/formats/pen/index.ts +36 -5
  757. package/src/io/formats/raster/adjusted-images.ts +125 -0
  758. package/src/io/formats/raster/headless.ts +3 -3
  759. package/src/io/formats/raster/index.ts +6 -1
  760. package/src/io/formats/raster/pixels.ts +7 -0
  761. package/src/io/formats/raster/render.ts +12 -1
  762. package/src/io/formats/svg/defs.ts +4 -72
  763. package/src/io/formats/svg/effects.ts +131 -0
  764. package/src/io/formats/svg/export.ts +278 -46
  765. package/src/io/formats/svg/filter.ts +47 -0
  766. package/src/io/formats/svg/grain.ts +249 -0
  767. package/src/io/formats/svg/strokes.ts +2 -2
  768. package/src/io/formats/svg/text/layout.ts +13 -3
  769. package/src/io/formats/video/composite.ts +79 -0
  770. package/src/io/formats/video/formats.ts +77 -0
  771. package/src/io/formats/video/gif.ts +65 -0
  772. package/src/io/formats/video/index.ts +30 -0
  773. package/src/io/formats/video/plan.ts +116 -0
  774. package/src/io/formats/video/record.ts +227 -0
  775. package/src/io/formats/video/sink.ts +32 -0
  776. package/src/io/formats/video/size.ts +25 -0
  777. package/src/io/formats/video/webcodecs.ts +89 -0
  778. package/src/io/formats.ts +59 -11
  779. package/src/io/types.ts +29 -10
  780. package/src/layout/auto-layout-handles.ts +396 -0
  781. package/src/layout.ts +2 -0
  782. package/src/lint/fixes.ts +12 -3
  783. package/src/lint/index.ts +3 -1
  784. package/src/lint/linter.ts +107 -10
  785. package/src/lint/presets.ts +2 -0
  786. package/src/lint/rules/design-memory.ts +97 -0
  787. package/src/lint/rules/index.ts +6 -1
  788. package/src/lint/rules/no-unbound-token-values.ts +73 -0
  789. package/src/lint/types.ts +32 -0
  790. package/src/node/video.ts +196 -0
  791. package/src/pairdraw-api/design-memory.ts +61 -0
  792. package/src/pairdraw-api/index.ts +81 -0
  793. package/src/pairdraw-api/nodes.ts +38 -0
  794. package/src/pairdraw-api/variations.ts +109 -0
  795. package/src/prototype/easing.ts +37 -0
  796. package/src/prototype/frames.ts +9 -0
  797. package/src/prototype/hit.ts +70 -0
  798. package/src/prototype/index.ts +69 -0
  799. package/src/prototype/pointer.ts +146 -0
  800. package/src/prototype/reactions.ts +178 -0
  801. package/src/prototype/scene.ts +116 -0
  802. package/src/prototype/scenes.ts +256 -0
  803. package/src/prototype/scroll.ts +190 -0
  804. package/src/prototype/session.ts +188 -0
  805. package/src/prototype/smart-animate/animation.ts +267 -0
  806. package/src/prototype/smart-animate/match.ts +85 -0
  807. package/src/prototype/snapshot.ts +60 -0
  808. package/src/prototype/timeline.ts +400 -0
  809. package/src/text/font/features.ts +27 -0
  810. package/src/text/font/manager.ts +79 -1
  811. package/src/text/index.ts +2 -0
  812. package/src/text/replace-fonts.ts +171 -0
  813. package/src/tools/analyze/responsive/index.ts +264 -0
  814. package/src/tools/analyze.ts +2 -0
  815. package/src/tools/codegen/token-sync.ts +98 -0
  816. package/src/tools/codegen.ts +1 -0
  817. package/src/tools/create/components.ts +4 -0
  818. package/src/tools/create/html.ts +1 -0
  819. package/src/tools/create/icons.ts +1 -0
  820. package/src/tools/create/mermaid.ts +1 -0
  821. package/src/tools/create/svg.ts +1 -0
  822. package/src/tools/design-memory.ts +72 -0
  823. package/src/tools/image-ai/generate.ts +2 -0
  824. package/src/tools/index.ts +1 -0
  825. package/src/tools/modify/fonts.ts +34 -0
  826. package/src/tools/modify/reactions.ts +15 -8
  827. package/src/tools/modify/text.ts +42 -5
  828. package/src/tools/modify/update.ts +46 -2
  829. package/src/tools/modify.ts +1 -0
  830. package/src/tools/read/fonts.ts +24 -2
  831. package/src/tools/read/libraries.ts +1 -0
  832. package/src/tools/read/space.ts +3 -2
  833. package/src/tools/registry/core.ts +3 -1
  834. package/src/tools/registry/extended.ts +28 -1
  835. package/src/tools/schema.ts +28 -4
  836. package/src/tools/stock-photo.ts +1 -0
  837. package/src/tools/structure/basic.ts +1 -0
  838. package/src/tools/structure/batch.ts +12 -1
  839. package/src/tools/structure/hierarchy.ts +4 -0
  840. package/src/tools/structure/variations.ts +118 -0
  841. package/src/tools/structure.ts +2 -0
  842. package/src/tools/styles/types.ts +3 -4
  843. package/src/tools/vector/boolean.ts +4 -0
  844. package/src/tools/vector/vectorize.ts +1 -0
  845. package/src/tools/vector/video.ts +228 -0
  846. package/src/tools/vector.ts +1 -0
  847. package/src/tools/video-host.ts +18 -0
@@ -0,0 +1,260 @@
1
+ import { easingAt } from "./easing.js";
2
+ import { primaryAction, shownFrame, startSession, step, timeoutReactions, topFrameOf } from "./session.js";
3
+ //#region src/prototype/timeline.ts
4
+ /** A flow that cannot be played as asked, with a message naming the frame or click at fault. */
5
+ var TimelineError = class extends Error {
6
+ reason;
7
+ name = "TimelineError";
8
+ constructor(message, reason = "invalid") {
9
+ super(message);
10
+ this.reason = reason;
11
+ }
12
+ };
13
+ /** Steps a timeline may take before it is refused, which stops cycles that take no time. */
14
+ const MAX_TIMELINE_STEPS = 1e4;
15
+ /** How long an action's transition runs, in milliseconds; a cut takes none. */
16
+ function transitionMs(action) {
17
+ if (action.type !== "NODE" || action.transition.type === "INSTANT") return 0;
18
+ return Math.max(0, action.transition.duration * 1e3);
19
+ }
20
+ /**
21
+ * How play animates `action` from `session`: a cut when it takes no time; Smart animate for a
22
+ * Smart animate Change to, or a navigation between screens while no overlay is open, as Figma
23
+ * has no Smart animate for overlays; a crossfade otherwise.
24
+ */
25
+ function animationFor(session, action) {
26
+ if (transitionMs(action) === 0 || action.type !== "NODE") return "cut";
27
+ if (action.transition.type !== "SMART_ANIMATE") return "dissolve";
28
+ if (action.navigation === "CHANGE_TO") return "smart";
29
+ return action.navigation === "NAVIGATE" && session.overlays.length === 0 ? "smart" : "dissolve";
30
+ }
31
+ /**
32
+ * The curve a dissolve fades along, CSS `ease-out`, which Figma's dissolve uses by default: the
33
+ * x and y of its two cubic Bézier control points. The player draws its crossfade with
34
+ * `DISSOLVE_EASING_CSS` and a recording samples `dissolveEasing`, so both fade alike.
35
+ */
36
+ const DISSOLVE_EASING = {
37
+ x1: 0,
38
+ y1: 0,
39
+ x2: .58,
40
+ y2: 1
41
+ };
42
+ /** `DISSOLVE_EASING` as a CSS timing function. */
43
+ const DISSOLVE_EASING_CSS = `cubic-bezier(${DISSOLVE_EASING.x1}, ${DISSOLVE_EASING.y1}, ${DISSOLVE_EASING.x2}, ${DISSOLVE_EASING.y2})`;
44
+ /** The share of the new screen a dissolve shows at `progress` of the way, along `DISSOLVE_EASING`. */
45
+ function dissolveEasing(progress) {
46
+ return easingAt("EASE_OUT", progress);
47
+ }
48
+ /**
49
+ * What play draws, as a key two sessions share when they look alike: the base frame and its
50
+ * overlays. History only matters to Back. State that changes what a frame shows extends it here,
51
+ * and the recorder's screen cache follows.
52
+ */
53
+ function sessionDrawKey(session) {
54
+ return [session.frameId, ...session.overlays].join(" ");
55
+ }
56
+ function nameOf(graph, id) {
57
+ return graph.getNode(id)?.name ?? id;
58
+ }
59
+ function seconds(ms) {
60
+ return `${(ms / 1e3).toFixed(2)} s`;
61
+ }
62
+ /** Whether `node` sits in `frameId`, or is that frame. */
63
+ function isInside(graph, node, frameId) {
64
+ let current = node;
65
+ while (current) {
66
+ if (current.id === frameId) return true;
67
+ current = current.parentId ? graph.getNode(current.parentId) : void 0;
68
+ }
69
+ return false;
70
+ }
71
+ /**
72
+ * The action a click on `nodeId` runs, as a click on the canvas resolves one: the layer or its
73
+ * nearest ancestor inside the shown frame with an `ON_CLICK` reaction. Throws when the layer is not
74
+ * on the shown frame; null when nothing there reacts to a click.
75
+ */
76
+ function clickAction(graph, session, click, index) {
77
+ const shown = shownFrame(session);
78
+ const node = graph.getNode(click.nodeId);
79
+ if (!node || !isInside(graph, node, shown)) throw new TimelineError(`click ${index + 1}: '${node?.name ?? click.nodeId}' is not on the shown frame '${nameOf(graph, shown)}' at ${seconds(click.atMs)}`);
80
+ let current = node;
81
+ while (current) {
82
+ const reaction = current.prototypeReactions.find((candidate) => candidate.trigger.type === "ON_CLICK");
83
+ const action = reaction ? primaryAction(reaction) : null;
84
+ if (action) return action;
85
+ if (current.id === shown) return null;
86
+ current = current.parentId ? graph.getNode(current.parentId) : void 0;
87
+ }
88
+ return null;
89
+ }
90
+ /** The shown frame's After delay reactions, each due `delay` after the frame finished entering. */
91
+ function armTimers(graph, session, readyMs) {
92
+ return timeoutReactions(graph, session).map(({ action, delayMs }) => ({
93
+ atMs: readyMs + delayMs,
94
+ action
95
+ })).toSorted((a, b) => a.atMs - b.atMs);
96
+ }
97
+ /** Play at its start frame, which must be a top-level frame with something to follow. */
98
+ function startWalk(graph, options) {
99
+ const start = graph.getNode(options.startFrameId);
100
+ if (!start || topFrameOf(graph, start)?.id !== start.id) throw new TimelineError(`'${start?.name ?? options.startFrameId}' is not a top-level frame`);
101
+ const session = startSession(start.id);
102
+ const walk = {
103
+ graph,
104
+ session,
105
+ readyMs: 0,
106
+ timers: armTimers(graph, session, 0),
107
+ clicks: (options.clicks ?? []).toSorted((a, b) => a.atMs - b.atMs),
108
+ clickIndex: 0,
109
+ skippedClicks: [],
110
+ segments: [],
111
+ steps: [],
112
+ overlayPositions: {}
113
+ };
114
+ if (walk.timers.length === 0 && walk.clicks.length === 0) throw new TimelineError(`'${start.name}' has no After delay interaction to follow`, "nothing-to-follow");
115
+ return {
116
+ walk,
117
+ start
118
+ };
119
+ }
120
+ /** Holds the shown screen from when it finished entering until `endMs`. */
121
+ function hold(walk, endMs) {
122
+ if (endMs > walk.readyMs) walk.segments.push({
123
+ kind: "hold",
124
+ session: walk.session,
125
+ startMs: walk.readyMs,
126
+ endMs
127
+ });
128
+ }
129
+ /** The earliest due timer or click, taken off its queue; null when nothing else will happen. */
130
+ function takeNextEvent(walk) {
131
+ const timer = walk.timers.at(0);
132
+ const click = walk.clicks.at(walk.clickIndex);
133
+ if (timer && (!click || timer.atMs <= click.atMs)) {
134
+ walk.timers = walk.timers.slice(1);
135
+ return {
136
+ atMs: timer.atMs,
137
+ action: timer.action,
138
+ trigger: "AFTER_TIMEOUT"
139
+ };
140
+ }
141
+ if (!click) return null;
142
+ const action = clickAction(walk.graph, walk.session, click, walk.clickIndex);
143
+ walk.clickIndex += 1;
144
+ if (!action) walk.skippedClicks.push(click);
145
+ return {
146
+ atMs: click.atMs,
147
+ action,
148
+ trigger: "ON_CLICK"
149
+ };
150
+ }
151
+ /** The earliest event's time without taking it, or infinity when nothing else will happen. */
152
+ function nextEventAt(walk) {
153
+ const timerAt = walk.timers.at(0)?.atMs ?? Number.POSITIVE_INFINITY;
154
+ const clickAt = walk.clicks.at(walk.clickIndex)?.atMs ?? Number.POSITIVE_INFINITY;
155
+ return Math.min(timerAt, clickAt);
156
+ }
157
+ /** Runs `action` at `atMs`, recording the hold before it, its crossfade, and the step. */
158
+ function advance(walk, event, next) {
159
+ const { atMs, action } = event;
160
+ const running = walk.segments.at(-1);
161
+ if (running && running.kind !== "hold" && running.endMs > atMs) running.endMs = atMs;
162
+ hold(walk, atMs);
163
+ const durationMs = transitionMs(action);
164
+ const animation = animationFor(walk.session, action);
165
+ if (animation !== "cut") walk.segments.push({
166
+ kind: animation === "smart" ? "smart" : "dissolve",
167
+ from: walk.session,
168
+ to: next,
169
+ startMs: atMs,
170
+ endMs: atMs + durationMs,
171
+ fadeMs: durationMs,
172
+ ...action.type === "NODE" && action.transition.easing ? { easing: action.transition.easing } : {}
173
+ });
174
+ walk.steps.push({
175
+ atMs,
176
+ frameId: shownFrame(next),
177
+ trigger: event.trigger,
178
+ transition: durationMs > 0 && action.type === "NODE" ? action.transition.type : "INSTANT"
179
+ });
180
+ if (action.type === "NODE" && action.navigation === "OVERLAY" && action.nodeId) walk.overlayPositions[action.nodeId] = action.overlayPosition;
181
+ walk.session = next;
182
+ walk.readyMs = atMs + durationMs;
183
+ walk.timers = armTimers(walk.graph, next, walk.readyMs);
184
+ }
185
+ function finish(walk, durationMs, end) {
186
+ return {
187
+ segments: walk.segments,
188
+ durationMs,
189
+ loops: end === "loops",
190
+ truncated: end === "truncated",
191
+ steps: walk.steps,
192
+ overlayPositions: walk.overlayPositions,
193
+ skippedClicks: [...walk.skippedClicks, ...walk.clicks.slice(walk.clickIndex)]
194
+ };
195
+ }
196
+ /**
197
+ * Plays a prototype on a virtual clock, from `startFrameId`, following its After delay
198
+ * reactions and the scripted clicks as the player would, without waiting for real time. Each delay
199
+ * counts from when the transition into its frame ends, as in Figma. The walk stops when play
200
+ * returns to the screen it started on (`loops`), when nothing else will happen (the last screen is
201
+ * held `tailMs`), or at `maxMs` (`truncated`).
202
+ */
203
+ function planTimeline(graph, options) {
204
+ const { walk, start } = startWalk(graph, options);
205
+ const startKey = sessionDrawKey(walk.session);
206
+ for (let taken = 0; taken <= MAX_TIMELINE_STEPS; taken++) {
207
+ const dueAt = nextEventAt(walk);
208
+ if (dueAt >= options.maxMs) {
209
+ const endMs = Math.min(walk.readyMs + options.tailMs, options.maxMs);
210
+ const truncated = dueAt !== Number.POSITIVE_INFINITY || walk.readyMs > options.maxMs;
211
+ hold(walk, truncated ? options.maxMs : endMs);
212
+ if (!truncated && endMs <= walk.readyMs) walk.segments.push({
213
+ kind: "hold",
214
+ session: walk.session,
215
+ startMs: walk.readyMs,
216
+ endMs: walk.readyMs
217
+ });
218
+ return truncated ? finish(walk, options.maxMs, "truncated") : finish(walk, endMs, "ends");
219
+ }
220
+ const event = takeNextEvent(walk);
221
+ const action = event?.action;
222
+ if (!event || !action) continue;
223
+ const next = step(graph, walk.session, action);
224
+ if (next === walk.session) continue;
225
+ advance(walk, {
226
+ ...event,
227
+ action
228
+ }, next);
229
+ if (sessionDrawKey(next) === startKey && walk.clickIndex >= walk.clicks.length) {
230
+ if (walk.readyMs === 0) throw new TimelineError(`The flow loops back to '${start.name}' at once`);
231
+ if (walk.readyMs > options.maxMs) return finish(walk, options.maxMs, "truncated");
232
+ return finish(walk, walk.readyMs, "loops");
233
+ }
234
+ }
235
+ throw new TimelineError(`The flow takes more than ${MAX_TIMELINE_STEPS} steps`);
236
+ }
237
+ /** What the timeline shows at `atMs`; past its end, the last screen it shows. */
238
+ function frameAt(timeline, atMs) {
239
+ for (const segment of timeline.segments) {
240
+ if (atMs >= segment.endMs) continue;
241
+ if (segment.kind === "hold") return { session: segment.session };
242
+ const progress = (atMs - segment.startMs) / segment.fadeMs;
243
+ if (segment.kind === "smart") return {
244
+ smart: segment,
245
+ progress
246
+ };
247
+ return {
248
+ from: segment.from,
249
+ to: segment.to,
250
+ mix: easingAt(segment.easing, progress)
251
+ };
252
+ }
253
+ const last = timeline.segments.at(-1);
254
+ if (!last) throw new TimelineError("The timeline is empty");
255
+ return { session: last.kind === "hold" ? last.session : last.to };
256
+ }
257
+ //#endregion
258
+ export { DISSOLVE_EASING, DISSOLVE_EASING_CSS, TimelineError, animationFor, dissolveEasing, frameAt, planTimeline, sessionDrawKey, transitionMs };
259
+
260
+ //# sourceMappingURL=timeline.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"timeline.js","names":[],"sources":["../../src/prototype/timeline.ts"],"sourcesContent":["import type {\n PrototypeAction,\n PrototypeEasingType,\n PrototypeOverlayPositionType,\n PrototypeTransitionType,\n SceneGraph,\n SceneNode\n} from '@pairdraw/scene-graph'\n\nimport { easingAt } from './easing'\nimport {\n primaryAction,\n shownFrame,\n startSession,\n step,\n timeoutReactions,\n topFrameOf,\n type PlaySession\n} from './session'\n\n/** A scripted click: the layer clicked, and when, in milliseconds from the start of play. */\nexport interface TimelineClick {\n atMs: number\n nodeId: string\n}\n\nexport interface TimelineOptions {\n /** The top-level frame play starts from. */\n startFrameId: string\n /** Clicks to run as play goes, in time order. */\n clicks?: readonly TimelineClick[]\n /** Where the timeline stops when the flow goes on longer. */\n maxMs: number\n /** How long the last frame stays once nothing else happens. */\n tailMs: number\n}\n\n/** A stretch of play that moves from one screen to the next over a transition's own length. */\ninterface TimelineTransition {\n from: PlaySession\n to: PlaySession\n startMs: number\n endMs: number\n /** The transition's own length, which keeps its pace when a later step cuts it short. */\n fadeMs: number\n easing?: PrototypeEasingType\n}\n\n/**\n * A stretch of play: one screen held still, a crossfade from one screen to the next, or a Smart\n * animate between them.\n */\nexport type TimelineSegment =\n | { kind: 'hold'; session: PlaySession; startMs: number; endMs: number }\n | ({ kind: 'dissolve' } & TimelineTransition)\n | ({ kind: 'smart' } & TimelineTransition)\n\n/** A Smart animate stretch of a timeline. */\nexport type TimelineSmartSegment = Extract<TimelineSegment, { kind: 'smart' }>\n\n/** One step play took: when, the frame it shows afterwards, what started it, and how it moved. */\nexport interface TimelineStep {\n atMs: number\n frameId: string\n trigger: 'AFTER_TIMEOUT' | 'ON_CLICK'\n transition: PrototypeTransitionType\n}\n\nexport interface Timeline {\n segments: TimelineSegment[]\n durationMs: number\n /** Clicks the walk never ran: past the cap, or on a layer whose hit runs no reaction. */\n skippedClicks: TimelineClick[]\n /** Play came back to the screen it started on, so the clip repeats seamlessly. */\n loops: boolean\n /** The flow went on past `maxMs`, where the timeline stops. */\n truncated: boolean\n steps: TimelineStep[]\n /** Where each overlay frame play opened sits over the screen, from the action that opened it. */\n overlayPositions: Record<string, PrototypeOverlayPositionType>\n}\n\n/**\n * What a timeline shows at a moment: one screen, two mid-crossfade with `mix` of the second, or a\n * Smart animate `progress` of the way through its time, which its animation eases.\n */\nexport type TimelineFrame =\n | { session: PlaySession }\n | { from: PlaySession; to: PlaySession; mix: number }\n | { smart: TimelineSmartSegment; progress: number }\n\n/** Why a flow cannot be played: the start frame has nothing to follow, or anything else. */\nexport type TimelineErrorReason = 'nothing-to-follow' | 'invalid'\n\n/** A flow that cannot be played as asked, with a message naming the frame or click at fault. */\nexport class TimelineError extends Error {\n override name = 'TimelineError'\n constructor(\n message: string,\n readonly reason: TimelineErrorReason = 'invalid'\n ) {\n super(message)\n }\n}\n\n/** Steps a timeline may take before it is refused, which stops cycles that take no time. */\nconst MAX_TIMELINE_STEPS = 10_000\n\n/** How long an action's transition runs, in milliseconds; a cut takes none. */\nexport function transitionMs(action: PrototypeAction): number {\n if (action.type !== 'NODE' || action.transition.type === 'INSTANT') return 0\n return Math.max(0, action.transition.duration * 1000)\n}\n\n/** How play shows a step: a cut, a crossfade, or Smart animate. */\nexport type PlayAnimation = 'cut' | 'dissolve' | 'smart'\n\n/**\n * How play animates `action` from `session`: a cut when it takes no time; Smart animate for a\n * Smart animate Change to, or a navigation between screens while no overlay is open, as Figma\n * has no Smart animate for overlays; a crossfade otherwise.\n */\nexport function animationFor(session: PlaySession, action: PrototypeAction): PlayAnimation {\n if (transitionMs(action) === 0 || action.type !== 'NODE') return 'cut'\n if (action.transition.type !== 'SMART_ANIMATE') return 'dissolve'\n if (action.navigation === 'CHANGE_TO') return 'smart'\n return action.navigation === 'NAVIGATE' && session.overlays.length === 0 ? 'smart' : 'dissolve'\n}\n\n/**\n * The curve a dissolve fades along, CSS `ease-out`, which Figma's dissolve uses by default: the\n * x and y of its two cubic Bézier control points. The player draws its crossfade with\n * `DISSOLVE_EASING_CSS` and a recording samples `dissolveEasing`, so both fade alike.\n */\nexport const DISSOLVE_EASING = { x1: 0, y1: 0, x2: 0.58, y2: 1 } as const\n\n/** `DISSOLVE_EASING` as a CSS timing function. */\nexport const DISSOLVE_EASING_CSS = `cubic-bezier(${DISSOLVE_EASING.x1}, ${DISSOLVE_EASING.y1}, ${DISSOLVE_EASING.x2}, ${DISSOLVE_EASING.y2})`\n\n/** The share of the new screen a dissolve shows at `progress` of the way, along `DISSOLVE_EASING`. */\nexport function dissolveEasing(progress: number): number {\n return easingAt('EASE_OUT', progress)\n}\n\n/**\n * What play draws, as a key two sessions share when they look alike: the base frame and its\n * overlays. History only matters to Back. State that changes what a frame shows extends it here,\n * and the recorder's screen cache follows.\n */\nexport function sessionDrawKey(session: PlaySession): string {\n return [session.frameId, ...session.overlays].join(' ')\n}\n\nfunction nameOf(graph: SceneGraph, id: string): string {\n return graph.getNode(id)?.name ?? id\n}\n\nfunction seconds(ms: number): string {\n return `${(ms / 1000).toFixed(2)} s`\n}\n\n/** Whether `node` sits in `frameId`, or is that frame. */\nfunction isInside(graph: SceneGraph, node: SceneNode, frameId: string): boolean {\n let current: SceneNode | undefined = node\n while (current) {\n if (current.id === frameId) return true\n current = current.parentId ? graph.getNode(current.parentId) : undefined\n }\n return false\n}\n\n/**\n * The action a click on `nodeId` runs, as a click on the canvas resolves one: the layer or its\n * nearest ancestor inside the shown frame with an `ON_CLICK` reaction. Throws when the layer is not\n * on the shown frame; null when nothing there reacts to a click.\n */\nfunction clickAction(\n graph: SceneGraph,\n session: PlaySession,\n click: TimelineClick,\n index: number\n): PrototypeAction | null {\n const shown = shownFrame(session)\n const node = graph.getNode(click.nodeId)\n if (!node || !isInside(graph, node, shown)) {\n throw new TimelineError(\n `click ${index + 1}: '${node?.name ?? click.nodeId}' is not on the shown frame '${nameOf(graph, shown)}' at ${seconds(click.atMs)}`\n )\n }\n let current: SceneNode | undefined = node\n while (current) {\n const reaction = current.prototypeReactions.find(\n (candidate) => candidate.trigger.type === 'ON_CLICK'\n )\n const action = reaction ? primaryAction(reaction) : null\n if (action) return action\n if (current.id === shown) return null\n current = current.parentId ? graph.getNode(current.parentId) : undefined\n }\n return null\n}\n\ninterface ArmedTimer {\n atMs: number\n action: PrototypeAction\n}\n\n/** The shown frame's After delay reactions, each due `delay` after the frame finished entering. */\nfunction armTimers(graph: SceneGraph, session: PlaySession, readyMs: number): ArmedTimer[] {\n return timeoutReactions(graph, session)\n .map(({ action, delayMs }) => ({ atMs: readyMs + delayMs, action }))\n .toSorted((a, b) => a.atMs - b.atMs)\n}\n\n/** Play at its start frame, which must be a top-level frame with something to follow. */\nfunction startWalk(graph: SceneGraph, options: TimelineOptions): { walk: Walk; start: SceneNode } {\n const start = graph.getNode(options.startFrameId)\n if (!start || topFrameOf(graph, start)?.id !== start.id) {\n throw new TimelineError(`'${start?.name ?? options.startFrameId}' is not a top-level frame`)\n }\n const session = startSession(start.id)\n const walk: Walk = {\n graph,\n session,\n readyMs: 0,\n timers: armTimers(graph, session, 0),\n clicks: (options.clicks ?? []).toSorted((a, b) => a.atMs - b.atMs),\n clickIndex: 0,\n skippedClicks: [],\n segments: [],\n steps: [],\n overlayPositions: {}\n }\n if (walk.timers.length === 0 && walk.clicks.length === 0) {\n throw new TimelineError(\n `'${start.name}' has no After delay interaction to follow`,\n 'nothing-to-follow'\n )\n }\n return { walk, start }\n}\n\n/** Play in progress on the virtual clock: what is shown, since when, and what is due next. */\ninterface Walk {\n graph: SceneGraph\n session: PlaySession\n /** When the shown screen finished entering; its After delays count from here. */\n readyMs: number\n timers: ArmedTimer[]\n clicks: TimelineClick[]\n clickIndex: number\n skippedClicks: TimelineClick[]\n segments: TimelineSegment[]\n steps: TimelineStep[]\n overlayPositions: Record<string, PrototypeOverlayPositionType>\n}\n\ninterface WalkEvent {\n atMs: number\n action: PrototypeAction | null\n trigger: TimelineStep['trigger']\n}\n\n/** Holds the shown screen from when it finished entering until `endMs`. */\nfunction hold(walk: Walk, endMs: number): void {\n if (endMs > walk.readyMs) {\n walk.segments.push({ kind: 'hold', session: walk.session, startMs: walk.readyMs, endMs })\n }\n}\n\n/** The earliest due timer or click, taken off its queue; null when nothing else will happen. */\nfunction takeNextEvent(walk: Walk): WalkEvent | null {\n const timer = walk.timers.at(0)\n const click = walk.clicks.at(walk.clickIndex)\n if (timer && (!click || timer.atMs <= click.atMs)) {\n walk.timers = walk.timers.slice(1)\n return { atMs: timer.atMs, action: timer.action, trigger: 'AFTER_TIMEOUT' }\n }\n if (!click) return null\n const action = clickAction(walk.graph, walk.session, click, walk.clickIndex)\n walk.clickIndex += 1\n if (!action) walk.skippedClicks.push(click)\n return { atMs: click.atMs, action, trigger: 'ON_CLICK' }\n}\n\n/** The earliest event's time without taking it, or infinity when nothing else will happen. */\nfunction nextEventAt(walk: Walk): number {\n const timerAt = walk.timers.at(0)?.atMs ?? Number.POSITIVE_INFINITY\n const clickAt = walk.clicks.at(walk.clickIndex)?.atMs ?? Number.POSITIVE_INFINITY\n return Math.min(timerAt, clickAt)\n}\n\n/** Runs `action` at `atMs`, recording the hold before it, its crossfade, and the step. */\nfunction advance(walk: Walk, event: WalkEvent & { action: PrototypeAction }, next: PlaySession) {\n const { atMs, action } = event\n // A step while a transition still runs cuts it short where it is.\n const running = walk.segments.at(-1)\n if (running && running.kind !== 'hold' && running.endMs > atMs) running.endMs = atMs\n hold(walk, atMs)\n const durationMs = transitionMs(action)\n const animation = animationFor(walk.session, action)\n if (animation !== 'cut') {\n walk.segments.push({\n kind: animation === 'smart' ? 'smart' : 'dissolve',\n from: walk.session,\n to: next,\n startMs: atMs,\n endMs: atMs + durationMs,\n fadeMs: durationMs,\n ...(action.type === 'NODE' && action.transition.easing\n ? { easing: action.transition.easing }\n : {})\n })\n }\n walk.steps.push({\n atMs,\n frameId: shownFrame(next),\n trigger: event.trigger,\n transition: durationMs > 0 && action.type === 'NODE' ? action.transition.type : 'INSTANT'\n })\n if (action.type === 'NODE' && action.navigation === 'OVERLAY' && action.nodeId) {\n walk.overlayPositions[action.nodeId] = action.overlayPosition\n }\n walk.session = next\n walk.readyMs = atMs + durationMs\n walk.timers = armTimers(walk.graph, next, walk.readyMs)\n}\n\nfunction finish(walk: Walk, durationMs: number, end: 'ends' | 'loops' | 'truncated'): Timeline {\n return {\n segments: walk.segments,\n durationMs,\n loops: end === 'loops',\n truncated: end === 'truncated',\n steps: walk.steps,\n overlayPositions: walk.overlayPositions,\n skippedClicks: [...walk.skippedClicks, ...walk.clicks.slice(walk.clickIndex)]\n }\n}\n\n/**\n * Plays a prototype on a virtual clock, from `startFrameId`, following its After delay\n * reactions and the scripted clicks as the player would, without waiting for real time. Each delay\n * counts from when the transition into its frame ends, as in Figma. The walk stops when play\n * returns to the screen it started on (`loops`), when nothing else will happen (the last screen is\n * held `tailMs`), or at `maxMs` (`truncated`).\n */\nexport function planTimeline(graph: SceneGraph, options: TimelineOptions): Timeline {\n const { walk, start } = startWalk(graph, options)\n const startKey = sessionDrawKey(walk.session)\n\n for (let taken = 0; taken <= MAX_TIMELINE_STEPS; taken++) {\n const dueAt = nextEventAt(walk)\n if (dueAt >= options.maxMs) {\n const endMs = Math.min(walk.readyMs + options.tailMs, options.maxMs)\n // More is due past the cap, or the cap falls before the last transition has ended.\n const truncated = dueAt !== Number.POSITIVE_INFINITY || walk.readyMs > options.maxMs\n hold(walk, truncated ? options.maxMs : endMs)\n // With no time left to hold it, the last screen still ends the timeline.\n if (!truncated && endMs <= walk.readyMs) {\n walk.segments.push({\n kind: 'hold',\n session: walk.session,\n startMs: walk.readyMs,\n endMs: walk.readyMs\n })\n }\n return truncated ? finish(walk, options.maxMs, 'truncated') : finish(walk, endMs, 'ends')\n }\n const event = takeNextEvent(walk)\n const action = event?.action\n if (!event || !action) continue\n const next = step(graph, walk.session, action)\n if (next === walk.session) continue\n advance(walk, { ...event, action }, next)\n\n if (sessionDrawKey(next) === startKey && walk.clickIndex >= walk.clicks.length) {\n if (walk.readyMs === 0) {\n throw new TimelineError(`The flow loops back to '${start.name}' at once`)\n }\n if (walk.readyMs > options.maxMs) return finish(walk, options.maxMs, 'truncated')\n return finish(walk, walk.readyMs, 'loops')\n }\n }\n throw new TimelineError(`The flow takes more than ${MAX_TIMELINE_STEPS} steps`)\n}\n\n/** What the timeline shows at `atMs`; past its end, the last screen it shows. */\nexport function frameAt(timeline: Timeline, atMs: number): TimelineFrame {\n for (const segment of timeline.segments) {\n if (atMs >= segment.endMs) continue\n if (segment.kind === 'hold') return { session: segment.session }\n const progress = (atMs - segment.startMs) / segment.fadeMs\n if (segment.kind === 'smart') return { smart: segment, progress }\n return { from: segment.from, to: segment.to, mix: easingAt(segment.easing, progress) }\n }\n const last = timeline.segments.at(-1)\n if (!last) throw new TimelineError('The timeline is empty')\n return { session: last.kind === 'hold' ? last.session : last.to }\n}\n"],"mappings":";;;;AA+FA,IAAa,gBAAb,cAAmC,MAAM;CAI5B;CAHX,OAAgB;CAChB,YACE,SACA,SAAuC,WACvC;EACA,MAAM,OAAO;EAFJ,KAAA,SAAA;CAGX;AACF;;AAGA,MAAM,qBAAqB;;AAG3B,SAAgB,aAAa,QAAiC;CAC5D,IAAI,OAAO,SAAS,UAAU,OAAO,WAAW,SAAS,WAAW,OAAO;CAC3E,OAAO,KAAK,IAAI,GAAG,OAAO,WAAW,WAAW,GAAI;AACtD;;;;;;AAUA,SAAgB,aAAa,SAAsB,QAAwC;CACzF,IAAI,aAAa,MAAM,MAAM,KAAK,OAAO,SAAS,QAAQ,OAAO;CACjE,IAAI,OAAO,WAAW,SAAS,iBAAiB,OAAO;CACvD,IAAI,OAAO,eAAe,aAAa,OAAO;CAC9C,OAAO,OAAO,eAAe,cAAc,QAAQ,SAAS,WAAW,IAAI,UAAU;AACvF;;;;;;AAOA,MAAa,kBAAkB;CAAE,IAAI;CAAG,IAAI;CAAG,IAAI;CAAM,IAAI;AAAE;;AAG/D,MAAa,sBAAsB,gBAAgB,gBAAgB,GAAG,IAAI,gBAAgB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C,IAAI,eAAe,IAAI,MAAM,YAAY,KAAK,cAAc,KAAK,OAAO,QAAQ;GAC9E,IAAI,KAAK,YAAY,GACnB,MAAM,IAAI,cAAc,2BAA2B,MAAM,KAAK,UAAU;GAE1E,IAAI,KAAK,UAAU,QAAQ,OAAO,OAAO,OAAO,MAAM,QAAQ,OAAO,WAAW;GAChF,OAAO,OAAO,MAAM,KAAK,SAAS,OAAO;EAC3C;CACF;CACA,MAAM,IAAI,cAAc,4BAA4B,mBAAmB,OAAO;AAChF;;AAGA,SAAgB,QAAQ,UAAoB,MAA6B;CACvE,KAAK,MAAM,WAAW,SAAS,UAAU;EACvC,IAAI,QAAQ,QAAQ,OAAO;EAC3B,IAAI,QAAQ,SAAS,QAAQ,OAAO,EAAE,SAAS,QAAQ,QAAQ;EAC/D,MAAM,YAAY,OAAO,QAAQ,WAAW,QAAQ;EACpD,IAAI,QAAQ,SAAS,SAAS,OAAO;GAAE,OAAO;GAAS;EAAS;EAChE,OAAO;GAAE,MAAM,QAAQ;GAAM,IAAI,QAAQ;GAAI,KAAK,SAAS,QAAQ,QAAQ,QAAQ;EAAE;CACvF;CACA,MAAM,OAAO,SAAS,SAAS,GAAG,EAAE;CACpC,IAAI,CAAC,MAAM,MAAM,IAAI,cAAc,uBAAuB;CAC1D,OAAO,EAAE,SAAS,KAAK,SAAS,SAAS,KAAK,UAAU,KAAK,GAAG;AAClE"}
@@ -1,7 +1,7 @@
1
1
  import "../text/ellipsis.js";
2
2
  import { prepareGraphFonts } from "../text/prepare.js";
3
- import { queryByXPath } from "../xpath.js";
4
3
  import { shapeDetailFields } from "../figma-api/shape-details.js";
4
+ import { queryByXPath } from "../xpath.js";
5
5
  import { sumBy } from "es-toolkit";
6
6
  //#region src/rpc/read-commands.ts
7
7
  /** Walk descendants. Callback returns `false` to stop traversal. */
@@ -0,0 +1,9 @@
1
+ //#region src/text/font/features.d.ts
2
+ /**
3
+ * The OpenType feature tags a font's GSUB table lists, in the table's own order, or `null` for a
4
+ * font without one. The panel offers a feature only when the font actually has it, as Figma does.
5
+ */
6
+ declare function fontFeatureTags(data: ArrayBuffer): string[] | null;
7
+ //#endregion
8
+ export { fontFeatureTags };
9
+ //# sourceMappingURL=features.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features.d.ts","names":[],"sources":["../../../src/text/font/features.ts"],"mappings":";;;;;iBAQgB,gBAAgB,MAAM"}
@@ -0,0 +1,27 @@
1
+ import { fontTableView } from "./variation.js";
2
+ import { uniq } from "es-toolkit/array";
3
+ //#region src/text/font/features.ts
4
+ /**
5
+ * The OpenType feature tags a font's GSUB table lists, in the table's own order, or `null` for a
6
+ * font without one. The panel offers a feature only when the font actually has it, as Figma does.
7
+ */
8
+ function fontFeatureTags(data) {
9
+ const gsub = fontTableView(data, "GSUB");
10
+ if (!gsub || gsub.byteLength < 14) return null;
11
+ const featureListOffset = gsub.getUint16(6);
12
+ if (featureListOffset + 2 > gsub.byteLength) return null;
13
+ const count = gsub.getUint16(featureListOffset);
14
+ const tags = [];
15
+ for (let index = 0; index < count; index++) {
16
+ const record = featureListOffset + 2 + index * 6;
17
+ if (record + 4 > gsub.byteLength) break;
18
+ let tag = "";
19
+ for (let c = 0; c < 4; c++) tag += String.fromCharCode(gsub.getUint8(record + c));
20
+ tags.push(tag.toUpperCase());
21
+ }
22
+ return uniq(tags);
23
+ }
24
+ //#endregion
25
+ export { fontFeatureTags };
26
+
27
+ //# sourceMappingURL=features.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features.js","names":[],"sources":["../../../src/text/font/features.ts"],"sourcesContent":["import { uniq } from 'es-toolkit/array'\n\nimport { fontTableView } from './variation'\n\n/**\n * The OpenType feature tags a font's GSUB table lists, in the table's own order, or `null` for a\n * font without one. The panel offers a feature only when the font actually has it, as Figma does.\n */\nexport function fontFeatureTags(data: ArrayBuffer): string[] | null {\n const gsub = fontTableView(data, 'GSUB')\n if (!gsub || gsub.byteLength < 14) return null\n // GSUB header: version (4), ScriptList offset (2), FeatureList offset (2), LookupList offset (2);\n // version 1.1 adds a FeatureVariations offset (4). The FeatureList offset is at byte 6 either way.\n const featureListOffset = gsub.getUint16(6)\n if (featureListOffset + 2 > gsub.byteLength) return null\n const count = gsub.getUint16(featureListOffset)\n const tags: string[] = []\n for (let index = 0; index < count; index++) {\n // Each FeatureRecord: a 4-byte tag and a 2-byte offset to its feature table.\n const record = featureListOffset + 2 + index * 6\n if (record + 4 > gsub.byteLength) break\n let tag = ''\n for (let c = 0; c < 4; c++) tag += String.fromCharCode(gsub.getUint8(record + c))\n tags.push(tag.toUpperCase())\n }\n return uniq(tags)\n}\n"],"mappings":";;;;;;;AAQA,SAAgB,gBAAgB,MAAoC;CAClE,MAAM,OAAO,cAAc,MAAM,MAAM;CACvC,IAAI,CAAC,QAAQ,KAAK,aAAa,IAAI,OAAO;CAG1C,MAAM,oBAAoB,KAAK,UAAU,CAAC;CAC1C,IAAI,oBAAoB,IAAI,KAAK,YAAY,OAAO;CACpD,MAAM,QAAQ,KAAK,UAAU,iBAAiB;CAC9C,MAAM,OAAiB,CAAC;CACxB,KAAK,IAAI,QAAQ,GAAG,QAAQ,OAAO,SAAS;EAE1C,MAAM,SAAS,oBAAoB,IAAI,QAAQ;EAC/C,IAAI,SAAS,IAAI,KAAK,YAAY;EAClC,IAAI,MAAM;EACV,KAAK,IAAI,IAAI,GAAG,IAAI,GAAG,KAAK,OAAO,OAAO,aAAa,KAAK,SAAS,SAAS,CAAC,CAAC;EAChF,KAAK,KAAK,IAAI,YAAY,CAAC;CAC7B;CACA,OAAO,KAAK,IAAI;AAClB"}
@@ -32,6 +32,7 @@ declare class FontManager {
32
32
  private remoteCoverage;
33
33
  private instanceVariations;
34
34
  private variations;
35
+ private featureTags;
35
36
  private blockedNodeIds;
36
37
  private fontProvider;
37
38
  private fontProviders;
@@ -129,6 +130,11 @@ declare class FontManager {
129
130
  private downloadFont;
130
131
  loadFont(family: string, style?: string, characters?: string, signal?: AbortSignal): Promise<ArrayBuffer | null>;
131
132
  private findFont;
133
+ /**
134
+ * A CSS generic keyword draws a face of the class it names: the first concrete family the host
135
+ * has, else a bundled one. Its bytes register under the keyword, so the text keeps its name.
136
+ */
137
+ private loadGenericFont;
132
138
  /**
133
139
  * `data`, or a web font fetched again with `characters` when it came from the web without them,
134
140
  * as a provider cuts a font down to the text it is asked for.
@@ -159,6 +165,12 @@ declare class FontManager {
159
165
  axes: FontAxis[];
160
166
  instances: NamedInstance[];
161
167
  } | null | undefined;
168
+ /**
169
+ * The OpenType feature tags a family's loaded font has, from its GSUB feature list: `undefined`
170
+ * when no face of the family is loaded, `null` when its font has no GSUB table, else the tags
171
+ * (empty when the table lists none). The panel offers a feature only when the font has it.
172
+ */
173
+ familyFeatures(family: string): string[] | null | undefined;
162
174
  /** Axis coordinates for `style` when the loaded face is a variable font, otherwise `null`. */
163
175
  namedInstanceVariations(family: string, style: string): FontVariation[] | null;
164
176
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"manager.d.ts","names":[],"sources":["../../../src/text/font/manager.ts"],"mappings":";;;;;;;;;;cAyDa;UACH;;UAEA;UACA;UACA;UACA;;UAEA;;;;;;UAMA;;;;;;UAMA;UACA;UACA;UACA;UAIA;UACA;UACA;UACA;UACA;UACA;mBACS;UAIT;UACA;UACA;mBACS;UACT;mBACS;mBACA;mBACA;mBACA;mBACA;UAKT;UACA;;mBAES;mBAGA;;;;;;;;;EAUjB,gBAAgB,WAAW,YAAY;EAiBvC,gBAAgB,UAAU;EAY1B,eAAe,WAAW,WAAW,UAAU;EAgB/C,eAAe,UAAU;EASzB,YAAY;;EAKZ,YAAY,WAAW,YAAY;EAQnC;EAIA,4BAA4B;EAI5B,aAAa;;;;;EAUb,iBAAiB,WAAW;EAK5B,cAAc;EAId,oBAAoB;EAIpB,uBAAuB,OAAO;EAI9B,qBAAqB;EAIrB,kBAAkB,QAAQ;;EAM1B,sBAAsB,QAAQ;EAI9B,uBAAuB,UAAU,QAAQ,OAAO;;EAMhD,mBAAmB,g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B,QAAQ;UAI5C;;UAeA;UAOA;EAYd,eACE,gBACA,gBACA,qBACA,SAAS,cACR,QAAQ;UAIG;EAgDd,SACE,gBACA,gBACA,qBACA,SAAS,cACR,QAAQ;UAIG;;;;;UAiCA;;;;;UAgBA;;;;;UAsBN;EAiBF,eAAe,gBAAgB,iBAAiB;;EAKhD,WACJ,gBACA,eACA,MAAM,aACN,SAAQ,mBACP;EAKH,iBAAiB,gBAAgB,gBAAgB;;EAKjD,kBAAkB,gBAAgB,gBAAgB;EAIlD,SAAS;EAIT,cAAc,gBAAgB;EAI9B,yBAAyB,gBAAgB,eAAe;EAKxD,WAAW,gBAAgB,gBAAgB;;;;;;EAS3C,gBACE,gBACA;IACG,MAAM;IAAa,MAAM;IAAY,WAAW;;;;;;;EAyBrD,eAAe;;EAgBf,wBAAwB,gBAAgB,gBAAgB;;;;;;;;;;;;;EAwBxD,aAAa,gBAAgB;;;;;;EAgB7B,oBAAoB,gBAAgB;;EAOpC,UAAU,gBAAgB,yBAAyB;;UAK3C;;UAWA;EAMR,gBAAgB,OAAO,YAAY,oBAAoB;EAIjD,qBAAqB;EAQ3B;EAIA,qBAAqB;UAMb;UAWA;;UAUA;EAIR,mBACE,UAAS,sBACT,qBACA,SAAS,cACR,QAAQ,QAAQ,OAAO;UAIZ;;;;;EA8Bd;EAIA,wBAAwB,QAAQ,sBAAsB;;;;;;;;UAYxC;;UAwCA;;;;;;UA0BN;UAyBA;UAQM;UAwBA;UAcA;;UAeN;UAiBA;;;;;EAoCR,aAAa,WAAW,gBAAgB;UAKhC;UAQA;;EAwBR,sBAAsB,gBAAgB,eAAe,MAAM;;cAsBhD,aAAW"}
@@ -5,6 +5,7 @@ import { fontAxes, hasNamedInstance, namedInstanceVariations, namedInstances } f
5
5
  import { browserFaceDescriptors, fontFaceRenderFamily } from "./faces.js";
6
6
  import { FamilyFaceCatalog } from "./catalog.js";
7
7
  import { makeParagraphBuilder, resetFontCollection } from "./collection.js";
8
+ import { fontFeatureTags } from "./features.js";
8
9
  import { loadHarfBuzz } from "./harfbuzz.js";
9
10
  import { SharedReads, sameFontFile, withHarfBuzz } from "./reads.js";
10
11
  import { LocalFonts } from "./local.js";
@@ -13,7 +14,29 @@ import { collectGraphFontKeys } from "../requirements/collect.js";
13
14
  import { WebFontResolver, normalizedCoverageText } from "../web-font/resolver.js";
14
15
  import { faceLoadKey, namesWeight, normalizeFontFamily, parseFontStyle } from "@pairdraw/scene-graph/font-style";
15
16
  import { uniq } from "es-toolkit";
17
+ import { GENERIC_FONT_FAMILIES_BY_CLASS, genericFontFamilyClass, isGenericFontFamily } from "@pairdraw/scene-graph/css";
16
18
  //#region src/text/font/manager.ts
19
+ /**
20
+ * How long a web-font fetch may run before the page falls back to an installed or bundled face.
21
+ * A provider that never answers must not block page preparation.
22
+ */
23
+ const WEB_FONT_FETCH_TIMEOUT_MS = 1e4;
24
+ /**
25
+ * `load`, bounded by `ms` and cancelled as soon as `signal` aborts, so a provider that never
26
+ * answers cannot block page preparation. The timer clears when the load settles.
27
+ */
28
+ async function fetchWithin(load, signal, ms) {
29
+ const bounded = new AbortController();
30
+ const forward = () => bounded.abort(signal?.reason);
31
+ signal?.addEventListener("abort", forward, { once: true });
32
+ const timer = setTimeout(() => bounded.abort(/* @__PURE__ */ new Error("Web font fetch timed out")), ms);
33
+ try {
34
+ return await load(bounded.signal);
35
+ } finally {
36
+ clearTimeout(timer);
37
+ signal?.removeEventListener("abort", forward);
38
+ }
39
+ }
17
40
  var FontManager = class {
18
41
  loadedFamilies = /* @__PURE__ */ new Map();
19
42
  /** The families `loadedFamilies` has a face of, so asking needs no scan of its keys. */
@@ -38,6 +61,7 @@ var FontManager = class {
38
61
  remoteCoverage = /* @__PURE__ */ new Map();
39
62
  instanceVariations = /* @__PURE__ */ new WeakMap();
40
63
  variations = /* @__PURE__ */ new WeakMap();
64
+ featureTags = /* @__PURE__ */ new WeakMap();
41
65
  blockedNodeIds = /* @__PURE__ */ new Set();
42
66
  fontProvider = null;
43
67
  fontProviders = /* @__PURE__ */ new Set();
@@ -324,7 +348,7 @@ var FontManager = class {
324
348
  const requestedCharacters = normalizedCoverageText(`${coverage ? Array.from(coverage).join("") : ""}${characters}`);
325
349
  const normalized = normalizeFontFamily(family);
326
350
  const families = normalized === family ? [family] : [family, normalized];
327
- const resolved = await this.webFonts.fetchFont(families, style, requestedCharacters, signal);
351
+ const resolved = await fetchWithin((boundedSignal) => this.webFonts.fetchFont(families, style, requestedCharacters, boundedSignal), signal, WEB_FONT_FETCH_TIMEOUT_MS);
328
352
  if (!resolved || resolved.buffers.length === 0) return null;
329
353
  const primary = resolved.buffers[0];
330
354
  if (!namesWeight(style) && !hasNamedInstance(primary, style)) return null;
@@ -346,6 +370,7 @@ var FontManager = class {
346
370
  }
347
371
  async findFont(family, style = "Regular", characters = "", signal) {
348
372
  signal?.throwIfAborted();
373
+ if (isGenericFontFamily(family)) return this.loadGenericFont(family, style);
349
374
  const loaded = this.loadedData(family, style);
350
375
  if (loaded) {
351
376
  this.registerFontInCanvasKit(family, loaded);
@@ -358,6 +383,21 @@ var FontManager = class {
358
383
  return await this.loadBundledFont(family, style) ?? await this.loadCachedFont(family, style, characters) ?? await this.loadRemoteFont(family, style, characters, signal);
359
384
  }
360
385
  /**
386
+ * A CSS generic keyword draws a face of the class it names: the first concrete family the host
387
+ * has, else a bundled one. Its bytes register under the keyword, so the text keeps its name.
388
+ */
389
+ async loadGenericFont(keyword, style) {
390
+ const kind = genericFontFamilyClass(keyword);
391
+ if (!kind) return null;
392
+ for (const candidate of GENERIC_FONT_FAMILIES_BY_CLASS[kind]) {
393
+ const installed = await this.loadInstalledFont(candidate, style);
394
+ if (installed) return this.registerAndCache(keyword, style, installed, "local");
395
+ const bundled = await this.loadBundledFont(candidate, style);
396
+ if (bundled) return this.registerAndCache(keyword, style, bundled, "bundled");
397
+ }
398
+ return null;
399
+ }
400
+ /**
361
401
  * `data`, or a web font fetched again with `characters` when it came from the web without them,
362
402
  * as a provider cuts a font down to the text it is asked for.
363
403
  */
@@ -445,6 +485,25 @@ var FontManager = class {
445
485
  }
446
486
  return loaded ? other : void 0;
447
487
  }
488
+ /**
489
+ * The OpenType feature tags a family's loaded font has, from its GSUB feature list: `undefined`
490
+ * when no face of the family is loaded, `null` when its font has no GSUB table, else the tags
491
+ * (empty when the table lists none). The panel offers a feature only when the font has it.
492
+ */
493
+ familyFeatures(family) {
494
+ let loaded = false;
495
+ for (const [key, data] of this.loadedFamilies) {
496
+ if (!key.startsWith(`${family}|`)) continue;
497
+ loaded = true;
498
+ let tags = this.featureTags.get(data);
499
+ if (tags === void 0) {
500
+ tags = fontFeatureTags(data);
501
+ this.featureTags.set(data, tags);
502
+ }
503
+ if (tags !== null) return tags;
504
+ }
505
+ return loaded ? null : void 0;
506
+ }
448
507
  /** Axis coordinates for `style` when the loaded face is a variable font, otherwise `null`. */
449
508
  namedInstanceVariations(family, style) {
450
509
  const data = this.loadedData(family, style);