@pairdraw/core 0.21.1 → 0.22.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (601) hide show
  1. package/dist/canvas/boolean.d.ts +6 -1
  2. package/dist/canvas/boolean.d.ts.map +1 -1
  3. package/dist/canvas/boolean.js +10 -2
  4. package/dist/canvas/boolean.js.map +1 -1
  5. package/dist/canvas/color-space.d.ts +45 -0
  6. package/dist/canvas/color-space.d.ts.map +1 -0
  7. package/dist/canvas/color-space.js +39 -0
  8. package/dist/canvas/color-space.js.map +1 -0
  9. package/dist/canvas/fills.d.ts +10 -10
  10. package/dist/canvas/fills.d.ts.map +1 -1
  11. package/dist/canvas/fills.js +116 -62
  12. package/dist/canvas/fills.js.map +1 -1
  13. package/dist/canvas/flatten.d.ts +11 -3
  14. package/dist/canvas/flatten.d.ts.map +1 -1
  15. package/dist/canvas/flatten.js +62 -4
  16. package/dist/canvas/flatten.js.map +1 -1
  17. package/dist/canvas/images/previews.d.ts +1 -1
  18. package/dist/canvas/index.d.ts +2 -1
  19. package/dist/canvas/index.js +2 -1
  20. package/dist/canvas/layout-grids.d.ts +5 -2
  21. package/dist/canvas/layout-grids.d.ts.map +1 -1
  22. package/dist/canvas/layout-grids.js +7 -2
  23. package/dist/canvas/layout-grids.js.map +1 -1
  24. package/dist/canvas/noise/render.d.ts +17 -4
  25. package/dist/canvas/noise/render.d.ts.map +1 -1
  26. package/dist/canvas/noise/render.js +21 -6
  27. package/dist/canvas/noise/render.js.map +1 -1
  28. package/dist/canvas/noise/shader.d.ts +4 -4
  29. package/dist/canvas/noise/shader.d.ts.map +1 -1
  30. package/dist/canvas/noise/shader.js +5 -6
  31. package/dist/canvas/noise/shader.js.map +1 -1
  32. package/dist/canvas/overlays/annotations.d.ts +19 -0
  33. package/dist/canvas/overlays/annotations.d.ts.map +1 -0
  34. package/dist/canvas/overlays/annotations.js +110 -0
  35. package/dist/canvas/overlays/annotations.js.map +1 -0
  36. package/dist/canvas/overlays/auto-layout-hover.d.ts +11 -1
  37. package/dist/canvas/overlays/auto-layout-hover.d.ts.map +1 -1
  38. package/dist/canvas/overlays/auto-layout-hover.js +25 -1
  39. package/dist/canvas/overlays/auto-layout-hover.js.map +1 -1
  40. package/dist/canvas/overlays/feedback.js +1 -1
  41. package/dist/canvas/overlays/feedback.js.map +1 -1
  42. package/dist/canvas/overlays/index.d.ts +2 -2
  43. package/dist/canvas/overlays/index.js +2 -2
  44. package/dist/canvas/overlays/measurement.d.ts +7 -1
  45. package/dist/canvas/overlays/measurement.d.ts.map +1 -1
  46. package/dist/canvas/overlays/measurement.js +42 -4
  47. package/dist/canvas/overlays/measurement.js.map +1 -1
  48. package/dist/canvas/overlays/presence.d.ts.map +1 -1
  49. package/dist/canvas/overlays/presence.js +21 -24
  50. package/dist/canvas/overlays/presence.js.map +1 -1
  51. package/dist/canvas/renderer/colors.d.ts +7 -1
  52. package/dist/canvas/renderer/colors.d.ts.map +1 -1
  53. package/dist/canvas/renderer/colors.js +9 -1
  54. package/dist/canvas/renderer/colors.js.map +1 -1
  55. package/dist/canvas/renderer/document-surface.d.ts +15 -6
  56. package/dist/canvas/renderer/document-surface.d.ts.map +1 -1
  57. package/dist/canvas/renderer/document-surface.js +1 -0
  58. package/dist/canvas/renderer/document-surface.js.map +1 -1
  59. package/dist/canvas/renderer/lifecycle.d.ts.map +1 -1
  60. package/dist/canvas/renderer/lifecycle.js +2 -2
  61. package/dist/canvas/renderer/lifecycle.js.map +1 -1
  62. package/dist/canvas/renderer/methods.d.ts +1 -0
  63. package/dist/canvas/renderer/methods.d.ts.map +1 -1
  64. package/dist/canvas/renderer/methods.js +4 -1
  65. package/dist/canvas/renderer/methods.js.map +1 -1
  66. package/dist/canvas/renderer/overlay-pass.d.ts.map +1 -1
  67. package/dist/canvas/renderer/overlay-pass.js +6 -1
  68. package/dist/canvas/renderer/overlay-pass.js.map +1 -1
  69. package/dist/canvas/renderer/pipeline.d.ts.map +1 -1
  70. package/dist/canvas/renderer/pipeline.js +7 -0
  71. package/dist/canvas/renderer/pipeline.js.map +1 -1
  72. package/dist/canvas/renderer/types.d.ts +10 -0
  73. package/dist/canvas/renderer/types.d.ts.map +1 -1
  74. package/dist/canvas/renderer.d.ts +10 -2
  75. package/dist/canvas/renderer.d.ts.map +1 -1
  76. package/dist/canvas/renderer.js +15 -3
  77. package/dist/canvas/renderer.js.map +1 -1
  78. package/dist/canvas/scene.d.ts.map +1 -1
  79. package/dist/canvas/scene.js +9 -9
  80. package/dist/canvas/scene.js.map +1 -1
  81. package/dist/clipboard/pairdraw.d.ts.map +1 -1
  82. package/dist/clipboard/pairdraw.js +1 -0
  83. package/dist/clipboard/pairdraw.js.map +1 -1
  84. package/dist/editor/bridges/clipboard.d.ts +2 -0
  85. package/dist/editor/bridges/clipboard.d.ts.map +1 -1
  86. package/dist/editor/bridges/clipboard.js +1 -0
  87. package/dist/editor/bridges/clipboard.js.map +1 -1
  88. package/dist/editor/bridges/components.d.ts +14 -7
  89. package/dist/editor/bridges/components.d.ts.map +1 -1
  90. package/dist/editor/bridges/components.js +6 -0
  91. package/dist/editor/bridges/components.js.map +1 -1
  92. package/dist/editor/bridges/structure.d.ts +1 -1
  93. package/dist/editor/bridges/structure.d.ts.map +1 -1
  94. package/dist/editor/bridges/undo.d.ts +1 -1
  95. package/dist/editor/clipboard/code.d.ts +32 -0
  96. package/dist/editor/clipboard/code.d.ts.map +1 -0
  97. package/dist/editor/clipboard/code.js +30 -0
  98. package/dist/editor/clipboard/code.js.map +1 -0
  99. package/dist/editor/clipboard/paste/dependencies.d.ts +14 -0
  100. package/dist/editor/clipboard/paste/dependencies.d.ts.map +1 -0
  101. package/dist/editor/clipboard/paste/dependencies.js +0 -0
  102. package/dist/editor/clipboard/paste/run.d.ts +14 -0
  103. package/dist/editor/clipboard/paste/run.d.ts.map +1 -0
  104. package/dist/editor/clipboard/paste/run.js +47 -0
  105. package/dist/editor/clipboard/paste/run.js.map +1 -0
  106. package/dist/editor/clipboard/styled.d.ts +2 -8
  107. package/dist/editor/clipboard/styled.d.ts.map +1 -1
  108. package/dist/editor/clipboard/styled.js +2 -32
  109. package/dist/editor/clipboard/styled.js.map +1 -1
  110. package/dist/editor/clipboard.d.ts +2 -0
  111. package/dist/editor/clipboard.d.ts.map +1 -1
  112. package/dist/editor/clipboard.js +34 -0
  113. package/dist/editor/clipboard.js.map +1 -1
  114. package/dist/editor/components/instances.d.ts +5 -0
  115. package/dist/editor/components/instances.d.ts.map +1 -1
  116. package/dist/editor/components/instances.js +69 -4
  117. package/dist/editor/components/instances.js.map +1 -1
  118. package/dist/editor/components/slots/index.d.ts.map +1 -1
  119. package/dist/editor/components/slots/index.js +7 -0
  120. package/dist/editor/components/slots/index.js.map +1 -1
  121. package/dist/editor/components.d.ts +6 -0
  122. package/dist/editor/components.d.ts.map +1 -1
  123. package/dist/editor/components.js +14 -2
  124. package/dist/editor/components.js.map +1 -1
  125. package/dist/editor/create.d.ts +30 -3
  126. package/dist/editor/create.d.ts.map +1 -1
  127. package/dist/editor/create.js +11 -2
  128. package/dist/editor/create.js.map +1 -1
  129. package/dist/editor/design-tokens.d.ts +1 -1
  130. package/dist/editor/design-tokens.d.ts.map +1 -1
  131. package/dist/editor/design-tokens.js +4 -18
  132. package/dist/editor/design-tokens.js.map +1 -1
  133. package/dist/editor/image-edit.d.ts.map +1 -1
  134. package/dist/editor/image-edit.js +1 -2
  135. package/dist/editor/image-edit.js.map +1 -1
  136. package/dist/editor/index.d.ts +4 -4
  137. package/dist/editor/index.js +1 -1
  138. package/dist/editor/layout-mode.d.ts +3 -1
  139. package/dist/editor/layout-mode.d.ts.map +1 -1
  140. package/dist/editor/layout-mode.js +97 -2
  141. package/dist/editor/layout-mode.js.map +1 -1
  142. package/dist/editor/nodes.d.ts +2 -0
  143. package/dist/editor/nodes.d.ts.map +1 -1
  144. package/dist/editor/nodes.js +22 -7
  145. package/dist/editor/nodes.js.map +1 -1
  146. package/dist/editor/read-only/actions.js +6 -0
  147. package/dist/editor/read-only/actions.js.map +1 -1
  148. package/dist/editor/selection/overlays.d.ts +1 -0
  149. package/dist/editor/selection/overlays.d.ts.map +1 -1
  150. package/dist/editor/selection/overlays.js +7 -0
  151. package/dist/editor/selection/overlays.js.map +1 -1
  152. package/dist/editor/selection/read.d.ts +8 -0
  153. package/dist/editor/selection.d.ts +9 -0
  154. package/dist/editor/selection.d.ts.map +1 -1
  155. package/dist/editor/state/shared.js +1 -0
  156. package/dist/editor/state/shared.js.map +1 -1
  157. package/dist/editor/state/view.d.ts.map +1 -1
  158. package/dist/editor/state/view.js +2 -0
  159. package/dist/editor/state/view.js.map +1 -1
  160. package/dist/editor/structure/boolean.d.ts +1 -1
  161. package/dist/editor/structure/boolean.d.ts.map +1 -1
  162. package/dist/editor/structure/boolean.js +20 -1
  163. package/dist/editor/structure/boolean.js.map +1 -1
  164. package/dist/editor/structure/container-wrap.d.ts +8 -2
  165. package/dist/editor/structure/container-wrap.d.ts.map +1 -1
  166. package/dist/editor/structure/container-wrap.js +17 -5
  167. package/dist/editor/structure/container-wrap.js.map +1 -1
  168. package/dist/editor/structure/flatten.d.ts.map +1 -1
  169. package/dist/editor/structure/flatten.js +8 -7
  170. package/dist/editor/structure/flatten.js.map +1 -1
  171. package/dist/editor/structure/group/ungroup.d.ts.map +1 -1
  172. package/dist/editor/structure/group/ungroup.js +2 -0
  173. package/dist/editor/structure/group/ungroup.js.map +1 -1
  174. package/dist/editor/structure/outline-stroke.d.ts.map +1 -1
  175. package/dist/editor/structure/outline-stroke.js +5 -0
  176. package/dist/editor/structure/outline-stroke.js.map +1 -1
  177. package/dist/editor/structure.d.ts +1 -1
  178. package/dist/editor/structure.d.ts.map +1 -1
  179. package/dist/editor/styles.d.ts +26 -0
  180. package/dist/editor/styles.d.ts.map +1 -0
  181. package/dist/editor/styles.js +127 -0
  182. package/dist/editor/styles.js.map +1 -0
  183. package/dist/editor/text/selection-style.d.ts +1 -0
  184. package/dist/editor/text/selection-style.d.ts.map +1 -1
  185. package/dist/editor/text/selection-style.js +10 -2
  186. package/dist/editor/text/selection-style.js.map +1 -1
  187. package/dist/editor/tool-registry.d.ts.map +1 -1
  188. package/dist/editor/tool-registry.js +6 -0
  189. package/dist/editor/tool-registry.js.map +1 -1
  190. package/dist/editor/types.d.ts +14 -2
  191. package/dist/editor/types.d.ts.map +1 -1
  192. package/dist/editor/variable-bindings.d.ts.map +1 -1
  193. package/dist/editor/variable-bindings.js +6 -1
  194. package/dist/editor/variable-bindings.js.map +1 -1
  195. package/dist/figma-api/accessors/basic.d.ts.map +1 -1
  196. package/dist/figma-api/accessors/basic.js +22 -1
  197. package/dist/figma-api/accessors/basic.js.map +1 -1
  198. package/dist/figma-api/accessors/shape.js +1 -1
  199. package/dist/figma-api/accessors/text/index.js +1 -1
  200. package/dist/figma-api/accessors/text/ranges.js +1 -1
  201. package/dist/figma-api/accessors/text/references.js +1 -1
  202. package/dist/figma-api/accessors/variables.js +1 -1
  203. package/dist/figma-api/accessors/vector.d.ts.map +1 -1
  204. package/dist/figma-api/accessors/vector.js +8 -22
  205. package/dist/figma-api/accessors/vector.js.map +1 -1
  206. package/dist/figma-api/accessors/visual.js +1 -1
  207. package/dist/figma-api/compatibility.d.ts +1 -1
  208. package/dist/figma-api/compatibility.d.ts.map +1 -1
  209. package/dist/figma-api/component-scope.d.ts +14 -0
  210. package/dist/figma-api/component-scope.d.ts.map +1 -0
  211. package/dist/figma-api/component-scope.js +28 -0
  212. package/dist/figma-api/component-scope.js.map +1 -0
  213. package/dist/figma-api/components.d.ts.map +1 -1
  214. package/dist/figma-api/components.js +26 -2
  215. package/dist/figma-api/components.js.map +1 -1
  216. package/dist/figma-api/flatten.js +3 -3
  217. package/dist/figma-api/flatten.js.map +1 -1
  218. package/dist/figma-api/index.d.ts +77 -6
  219. package/dist/figma-api/index.d.ts.map +1 -1
  220. package/dist/figma-api/index.js +188 -2
  221. package/dist/figma-api/index.js.map +1 -1
  222. package/dist/figma-api/node-types.d.ts +2 -1
  223. package/dist/figma-api/node-types.d.ts.map +1 -1
  224. package/dist/figma-api/overrides.d.ts +26 -1
  225. package/dist/figma-api/overrides.d.ts.map +1 -1
  226. package/dist/figma-api/overrides.js +157 -10
  227. package/dist/figma-api/overrides.js.map +1 -1
  228. package/dist/figma-api/proxy.d.ts +2 -0
  229. package/dist/figma-api/proxy.d.ts.map +1 -1
  230. package/dist/figma-api/proxy.js +10 -2
  231. package/dist/figma-api/proxy.js.map +1 -1
  232. package/dist/figma-api/reactions.d.ts +65 -9
  233. package/dist/figma-api/reactions.d.ts.map +1 -1
  234. package/dist/figma-api/reactions.js +144 -11
  235. package/dist/figma-api/reactions.js.map +1 -1
  236. package/dist/figma-api/shape-with-text.js +1 -1
  237. package/dist/figma-api/slots.d.ts +3 -1
  238. package/dist/figma-api/slots.d.ts.map +1 -1
  239. package/dist/figma-api/slots.js +9 -8
  240. package/dist/figma-api/slots.js.map +1 -1
  241. package/dist/index.d.ts +4 -4
  242. package/dist/index.js +1 -1
  243. package/dist/io/formats/code/detect.d.ts +23 -0
  244. package/dist/io/formats/code/detect.d.ts.map +1 -0
  245. package/dist/io/formats/code/detect.js +46 -0
  246. package/dist/io/formats/code/detect.js.map +1 -0
  247. package/dist/io/formats/code/index.d.ts +5 -0
  248. package/dist/io/formats/code/index.js +5 -0
  249. package/dist/io/formats/code/read.d.ts +45 -0
  250. package/dist/io/formats/code/read.d.ts.map +1 -0
  251. package/dist/io/formats/code/read.js +86 -0
  252. package/dist/io/formats/code/read.js.map +1 -0
  253. package/dist/io/formats/code/stylesheet.d.ts +13 -0
  254. package/dist/io/formats/code/stylesheet.d.ts.map +1 -0
  255. package/dist/io/formats/code/stylesheet.js +21 -0
  256. package/dist/io/formats/code/stylesheet.js.map +1 -0
  257. package/dist/io/formats/code/tokens.d.ts +18 -0
  258. package/dist/io/formats/code/tokens.d.ts.map +1 -0
  259. package/dist/io/formats/code/tokens.js +135 -0
  260. package/dist/io/formats/code/tokens.js.map +1 -0
  261. package/dist/io/formats/design-tokens/apply.d.ts +7 -3
  262. package/dist/io/formats/design-tokens/apply.d.ts.map +1 -1
  263. package/dist/io/formats/design-tokens/apply.js.map +1 -1
  264. package/dist/io/formats/fig/export/patch/fields.js +5 -0
  265. package/dist/io/formats/fig/export/patch/fields.js.map +1 -1
  266. package/dist/io/formats/fig/export/patch/index.d.ts.map +1 -1
  267. package/dist/io/formats/fig/export/patch/index.js +20 -20
  268. package/dist/io/formats/fig/export/patch/index.js.map +1 -1
  269. package/dist/io/formats/fig/export/setup.d.ts.map +1 -1
  270. package/dist/io/formats/fig/export/setup.js +5 -1
  271. package/dist/io/formats/fig/export/setup.js.map +1 -1
  272. package/dist/io/formats/fig/index.d.ts +3 -2
  273. package/dist/io/formats/fig/index.js +2 -2
  274. package/dist/io/formats/fig/read.d.ts.map +1 -1
  275. package/dist/io/formats/fig/read.js +5 -2
  276. package/dist/io/formats/fig/read.js.map +1 -1
  277. package/dist/io/formats/html/layers.d.ts +3 -1
  278. package/dist/io/formats/html/layers.d.ts.map +1 -1
  279. package/dist/io/formats/html/layers.js +6 -1
  280. package/dist/io/formats/html/layers.js.map +1 -1
  281. package/dist/io/formats/pdf/export.d.ts.map +1 -1
  282. package/dist/io/formats/pdf/export.js +7 -3
  283. package/dist/io/formats/pdf/export.js.map +1 -1
  284. package/dist/io/formats/pdf/plan.d.ts +3 -0
  285. package/dist/io/formats/pdf/plan.d.ts.map +1 -1
  286. package/dist/io/formats/pdf/plan.js +60 -36
  287. package/dist/io/formats/pdf/plan.js.map +1 -1
  288. package/dist/io/formats/raster/headless.d.ts.map +1 -1
  289. package/dist/io/formats/raster/headless.js +3 -2
  290. package/dist/io/formats/raster/headless.js.map +1 -1
  291. package/dist/io/formats/raster/index.d.ts +2 -2
  292. package/dist/io/formats/raster/index.js +2 -2
  293. package/dist/io/formats/raster/render.d.ts +10 -2
  294. package/dist/io/formats/raster/render.d.ts.map +1 -1
  295. package/dist/io/formats/raster/render.js +35 -9
  296. package/dist/io/formats/raster/render.js.map +1 -1
  297. package/dist/io/formats/svg/defs.d.ts.map +1 -1
  298. package/dist/io/formats/svg/defs.js +19 -1
  299. package/dist/io/formats/svg/defs.js.map +1 -1
  300. package/dist/io/formats/svg/export.d.ts +5 -2
  301. package/dist/io/formats/svg/export.d.ts.map +1 -1
  302. package/dist/io/formats/svg/export.js +59 -10
  303. package/dist/io/formats/svg/export.js.map +1 -1
  304. package/dist/io/formats/svg/index.d.ts +2 -2
  305. package/dist/io/formats/svg/index.js +2 -2
  306. package/dist/io/formats/svg/text/layout.d.ts.map +1 -1
  307. package/dist/io/formats/svg/text/layout.js +4 -2
  308. package/dist/io/formats/svg/text/layout.js.map +1 -1
  309. package/dist/io/formats/video/record.d.ts.map +1 -1
  310. package/dist/io/formats/video/record.js +24 -9
  311. package/dist/io/formats/video/record.js.map +1 -1
  312. package/dist/io/formats.d.ts.map +1 -1
  313. package/dist/io/formats.js +20 -13
  314. package/dist/io/formats.js.map +1 -1
  315. package/dist/kiwi/fig/population/client.d.ts.map +1 -1
  316. package/dist/kiwi/fig/population/client.js +2 -1
  317. package/dist/kiwi/fig/population/client.js.map +1 -1
  318. package/dist/kiwi/fig/session/document-state.d.ts +46 -2
  319. package/dist/kiwi/fig/session/document-state.d.ts.map +1 -1
  320. package/dist/kiwi/fig/session/document-state.js +113 -5
  321. package/dist/kiwi/fig/session/document-state.js.map +1 -1
  322. package/dist/kiwi/fig/session/options.d.ts +4 -0
  323. package/dist/kiwi/fig/session/options.d.ts.map +1 -1
  324. package/dist/kiwi/fig/session/options.js.map +1 -1
  325. package/dist/layout/apply.d.ts.map +1 -1
  326. package/dist/layout/apply.js +8 -4
  327. package/dist/layout/apply.js.map +1 -1
  328. package/dist/layout/auto-layout-handles.js +1 -1
  329. package/dist/layout/auto-layout-handles.js.map +1 -1
  330. package/dist/layout/axis-sizing.d.ts.map +1 -1
  331. package/dist/layout/axis-sizing.js +1 -1
  332. package/dist/layout/axis-sizing.js.map +1 -1
  333. package/dist/layout/derived.d.ts.map +1 -1
  334. package/dist/layout/derived.js +1 -1
  335. package/dist/layout/derived.js.map +1 -1
  336. package/dist/layout/effective-generated-text.js +1 -1
  337. package/dist/layout/effective-generated-text.js.map +1 -1
  338. package/dist/layout/grid.d.ts +3 -1
  339. package/dist/layout/grid.d.ts.map +1 -1
  340. package/dist/layout/grid.js +57 -16
  341. package/dist/layout/grid.js.map +1 -1
  342. package/dist/layout.d.ts +1 -1
  343. package/dist/layout.js +6 -5
  344. package/dist/layout.js.map +1 -1
  345. package/dist/node/fs.d.ts.map +1 -1
  346. package/dist/node/fs.js +28 -7
  347. package/dist/node/fs.js.map +1 -1
  348. package/dist/prototype/easing.d.ts +13 -5
  349. package/dist/prototype/easing.d.ts.map +1 -1
  350. package/dist/prototype/easing.js +46 -6
  351. package/dist/prototype/easing.js.map +1 -1
  352. package/dist/prototype/scenes.d.ts +31 -0
  353. package/dist/prototype/scenes.d.ts.map +1 -1
  354. package/dist/prototype/scenes.js +220 -31
  355. package/dist/prototype/scenes.js.map +1 -1
  356. package/dist/prototype/session.d.ts.map +1 -1
  357. package/dist/prototype/session.js +1 -0
  358. package/dist/prototype/session.js.map +1 -1
  359. package/dist/prototype/smart-animate/animation.d.ts +2 -1
  360. package/dist/prototype/smart-animate/animation.d.ts.map +1 -1
  361. package/dist/prototype/smart-animate/animation.js +2 -2
  362. package/dist/prototype/smart-animate/animation.js.map +1 -1
  363. package/dist/prototype/timeline.d.ts +10 -1
  364. package/dist/prototype/timeline.d.ts.map +1 -1
  365. package/dist/prototype/timeline.js +69 -23
  366. package/dist/prototype/timeline.js.map +1 -1
  367. package/dist/prototype/variables.d.ts +23 -0
  368. package/dist/prototype/variables.d.ts.map +1 -0
  369. package/dist/prototype/variables.js +237 -0
  370. package/dist/prototype/variables.js.map +1 -0
  371. package/dist/rpc/read-commands.d.ts +5 -0
  372. package/dist/rpc/read-commands.d.ts.map +1 -1
  373. package/dist/rpc/read-commands.js +4 -1
  374. package/dist/rpc/read-commands.js.map +1 -1
  375. package/dist/text/character-style.d.ts +8 -1
  376. package/dist/text/character-style.d.ts.map +1 -1
  377. package/dist/text/character-style.js +39 -1
  378. package/dist/text/character-style.js.map +1 -1
  379. package/dist/text/font/batch.d.ts +26 -0
  380. package/dist/text/font/batch.d.ts.map +1 -0
  381. package/dist/text/font/batch.js +31 -0
  382. package/dist/text/font/batch.js.map +1 -0
  383. package/dist/text/font/manager.d.ts.map +1 -1
  384. package/dist/text/font/manager.js +14 -1
  385. package/dist/text/font/manager.js.map +1 -1
  386. package/dist/text/index.d.ts +3 -2
  387. package/dist/text/index.js +3 -2
  388. package/dist/tools/create/basic.js +3 -4
  389. package/dist/tools/create/basic.js.map +1 -1
  390. package/dist/tools/create/behaviours.js +1 -1
  391. package/dist/tools/create/code.d.ts +6 -0
  392. package/dist/tools/create/code.d.ts.map +1 -0
  393. package/dist/tools/create/code.js +68 -0
  394. package/dist/tools/create/code.js.map +1 -0
  395. package/dist/tools/create/html.d.ts.map +1 -1
  396. package/dist/tools/create/html.js +9 -57
  397. package/dist/tools/create/html.js.map +1 -1
  398. package/dist/tools/create/icons.js +1 -1
  399. package/dist/tools/create/inputs.d.ts +11 -0
  400. package/dist/tools/create/inputs.d.ts.map +1 -0
  401. package/dist/tools/create/inputs.js +15 -0
  402. package/dist/tools/create/inputs.js.map +1 -0
  403. package/dist/tools/create/mermaid.d.ts.map +1 -1
  404. package/dist/tools/create/mermaid.js +5 -6
  405. package/dist/tools/create/mermaid.js.map +1 -1
  406. package/dist/tools/create/place.d.ts +30 -0
  407. package/dist/tools/create/place.d.ts.map +1 -0
  408. package/dist/tools/create/place.js +70 -0
  409. package/dist/tools/create/place.js.map +1 -0
  410. package/dist/tools/create/render.js +1 -1
  411. package/dist/tools/create/svg.js +1 -1
  412. package/dist/tools/create/vector.js +1 -1
  413. package/dist/tools/create.d.ts +2 -1
  414. package/dist/tools/create.js +2 -1
  415. package/dist/tools/css/gradient.d.ts +28 -0
  416. package/dist/tools/css/gradient.d.ts.map +1 -0
  417. package/dist/tools/css/gradient.js +118 -0
  418. package/dist/tools/css/gradient.js.map +1 -0
  419. package/dist/tools/image-ai/generate.js +1 -1
  420. package/dist/tools/modify/geometry.js +5 -5
  421. package/dist/tools/modify/geometry.js.map +1 -1
  422. package/dist/tools/modify/layout.d.ts.map +1 -1
  423. package/dist/tools/modify/layout.js +7 -1
  424. package/dist/tools/modify/layout.js.map +1 -1
  425. package/dist/tools/modify/matching.js +1 -1
  426. package/dist/tools/modify/overrides.d.ts +6 -0
  427. package/dist/tools/modify/overrides.d.ts.map +1 -0
  428. package/dist/tools/modify/overrides.js +27 -0
  429. package/dist/tools/modify/overrides.js.map +1 -0
  430. package/dist/tools/modify/paint.d.ts.map +1 -1
  431. package/dist/tools/modify/paint.js +84 -39
  432. package/dist/tools/modify/paint.js.map +1 -1
  433. package/dist/tools/modify/text.d.ts +2 -1
  434. package/dist/tools/modify/text.d.ts.map +1 -1
  435. package/dist/tools/modify/text.js +79 -8
  436. package/dist/tools/modify/text.js.map +1 -1
  437. package/dist/tools/modify/update.d.ts.map +1 -1
  438. package/dist/tools/modify/update.js +18 -2
  439. package/dist/tools/modify/update.js.map +1 -1
  440. package/dist/tools/modify.d.ts +3 -2
  441. package/dist/tools/modify.js +3 -2
  442. package/dist/tools/read/css.d.ts.map +1 -1
  443. package/dist/tools/read/css.js +29 -12
  444. package/dist/tools/read/css.js.map +1 -1
  445. package/dist/tools/read/libraries.js +1 -1
  446. package/dist/tools/read/nodes.d.ts.map +1 -1
  447. package/dist/tools/read/nodes.js +19 -5
  448. package/dist/tools/read/nodes.js.map +1 -1
  449. package/dist/tools/registry/extended.d.ts.map +1 -1
  450. package/dist/tools/registry/extended.js +6 -1
  451. package/dist/tools/registry/extended.js.map +1 -1
  452. package/dist/tools/text-range.d.ts +11 -0
  453. package/dist/tools/text-range.d.ts.map +1 -0
  454. package/dist/tools/text-range.js +26 -0
  455. package/dist/tools/text-range.js.map +1 -0
  456. package/dist/tools/variables/bindings.js +1 -1
  457. package/dist/tools/variables/bindings.js.map +1 -1
  458. package/dist/tools/variables/unbind.js +1 -1
  459. package/dist/tools/variables/unbind.js.map +1 -1
  460. package/dist/tools/vector/path.d.ts.map +1 -1
  461. package/dist/tools/vector/path.js +7 -21
  462. package/dist/tools/vector/path.js.map +1 -1
  463. package/dist/vector/rebase.d.ts +17 -0
  464. package/dist/vector/rebase.d.ts.map +1 -0
  465. package/dist/vector/rebase.js +32 -0
  466. package/dist/vector/rebase.js.map +1 -0
  467. package/package.json +14 -9
  468. package/src/canvas/boolean.ts +12 -1
  469. package/src/canvas/color-space.ts +73 -0
  470. package/src/canvas/fills.ts +130 -83
  471. package/src/canvas/flatten.ts +92 -7
  472. package/src/canvas/index.ts +9 -0
  473. package/src/canvas/layout-grids.ts +15 -2
  474. package/src/canvas/noise/render.ts +35 -7
  475. package/src/canvas/noise/shader.ts +8 -10
  476. package/src/canvas/overlays/annotations.ts +117 -0
  477. package/src/canvas/overlays/auto-layout-hover.ts +41 -1
  478. package/src/canvas/overlays/feedback.ts +7 -2
  479. package/src/canvas/overlays/index.ts +1 -1
  480. package/src/canvas/overlays/measurement.ts +49 -3
  481. package/src/canvas/overlays/presence.ts +35 -32
  482. package/src/canvas/renderer/colors.ts +14 -0
  483. package/src/canvas/renderer/document-surface.ts +16 -6
  484. package/src/canvas/renderer/lifecycle.ts +2 -2
  485. package/src/canvas/renderer/methods.ts +4 -0
  486. package/src/canvas/renderer/overlay-pass.ts +4 -0
  487. package/src/canvas/renderer/pipeline.ts +8 -0
  488. package/src/canvas/renderer/types.ts +8 -0
  489. package/src/canvas/renderer.ts +21 -2
  490. package/src/canvas/scene.ts +15 -7
  491. package/src/clipboard/pairdraw.ts +1 -0
  492. package/src/editor/bridges/clipboard.ts +1 -0
  493. package/src/editor/bridges/components.ts +10 -0
  494. package/src/editor/clipboard/code.ts +50 -0
  495. package/src/editor/clipboard/paste/dependencies.ts +18 -0
  496. package/src/editor/clipboard/paste/run.ts +64 -0
  497. package/src/editor/clipboard/styled.ts +4 -52
  498. package/src/editor/clipboard.ts +40 -0
  499. package/src/editor/components/instances.ts +92 -4
  500. package/src/editor/components/slots/index.ts +7 -0
  501. package/src/editor/components.ts +16 -2
  502. package/src/editor/create.ts +15 -1
  503. package/src/editor/design-tokens.ts +3 -23
  504. package/src/editor/image-edit.ts +5 -2
  505. package/src/editor/index.ts +1 -0
  506. package/src/editor/layout-mode.ts +131 -3
  507. package/src/editor/nodes.ts +30 -5
  508. package/src/editor/read-only/actions.ts +6 -0
  509. package/src/editor/selection/overlays.ts +8 -0
  510. package/src/editor/state/shared.ts +1 -0
  511. package/src/editor/state/view.ts +2 -0
  512. package/src/editor/structure/boolean.ts +29 -1
  513. package/src/editor/structure/container-wrap.ts +20 -4
  514. package/src/editor/structure/flatten.ts +15 -8
  515. package/src/editor/structure/group/ungroup.ts +2 -0
  516. package/src/editor/structure/outline-stroke.ts +5 -0
  517. package/src/editor/styles.ts +203 -0
  518. package/src/editor/text/selection-style.ts +18 -1
  519. package/src/editor/tool-registry.ts +2 -0
  520. package/src/editor/types.ts +14 -0
  521. package/src/editor/variable-bindings.ts +11 -0
  522. package/src/figma-api/accessors/basic.ts +33 -1
  523. package/src/figma-api/accessors/vector.ts +6 -13
  524. package/src/figma-api/compatibility.ts +1 -0
  525. package/src/figma-api/component-scope.ts +36 -0
  526. package/src/figma-api/components.ts +24 -0
  527. package/src/figma-api/flatten.ts +7 -3
  528. package/src/figma-api/index.ts +302 -6
  529. package/src/figma-api/node-types.ts +1 -0
  530. package/src/figma-api/overrides.ts +192 -5
  531. package/src/figma-api/proxy.ts +16 -1
  532. package/src/figma-api/reactions.ts +163 -12
  533. package/src/figma-api/slots.ts +10 -9
  534. package/src/io/formats/code/detect.ts +67 -0
  535. package/src/io/formats/code/index.ts +17 -0
  536. package/src/io/formats/code/read.ts +143 -0
  537. package/src/io/formats/code/stylesheet.ts +24 -0
  538. package/src/io/formats/code/tokens.ts +159 -0
  539. package/src/io/formats/design-tokens/apply.ts +3 -2
  540. package/src/io/formats/fig/export/patch/fields.ts +11 -0
  541. package/src/io/formats/fig/export/patch/index.ts +23 -19
  542. package/src/io/formats/fig/export/setup.ts +8 -1
  543. package/src/io/formats/fig/index.ts +6 -0
  544. package/src/io/formats/fig/read.ts +11 -2
  545. package/src/io/formats/html/layers.ts +7 -0
  546. package/src/io/formats/pdf/export.ts +19 -7
  547. package/src/io/formats/pdf/plan.ts +71 -32
  548. package/src/io/formats/raster/headless.ts +3 -1
  549. package/src/io/formats/raster/index.ts +2 -0
  550. package/src/io/formats/raster/render.ts +49 -9
  551. package/src/io/formats/svg/defs.ts +27 -1
  552. package/src/io/formats/svg/export.ts +75 -13
  553. package/src/io/formats/svg/index.ts +1 -0
  554. package/src/io/formats/svg/text/layout.ts +5 -3
  555. package/src/io/formats/video/record.ts +33 -9
  556. package/src/io/formats.ts +35 -15
  557. package/src/kiwi/fig/population/client.ts +6 -1
  558. package/src/kiwi/fig/session/document-state.ts +195 -5
  559. package/src/kiwi/fig/session/options.ts +2 -0
  560. package/src/layout/apply.ts +12 -4
  561. package/src/layout/auto-layout-handles.ts +1 -1
  562. package/src/layout/axis-sizing.ts +3 -1
  563. package/src/layout/derived.ts +3 -1
  564. package/src/layout/effective-generated-text.ts +1 -1
  565. package/src/layout/grid.ts +91 -21
  566. package/src/layout.ts +16 -3
  567. package/src/node/fs.ts +32 -7
  568. package/src/prototype/easing.ts +79 -7
  569. package/src/prototype/scenes.ts +244 -15
  570. package/src/prototype/session.ts +1 -0
  571. package/src/prototype/smart-animate/animation.ts +4 -3
  572. package/src/prototype/timeline.ts +118 -26
  573. package/src/prototype/variables.ts +189 -0
  574. package/src/rpc/read-commands.ts +19 -1
  575. package/src/text/character-style.ts +47 -0
  576. package/src/text/font/batch.ts +58 -0
  577. package/src/text/font/manager.ts +17 -1
  578. package/src/text/index.ts +2 -1
  579. package/src/tools/create/basic.ts +2 -3
  580. package/src/tools/create/code.ts +85 -0
  581. package/src/tools/create/html.ts +9 -46
  582. package/src/tools/create/inputs.ts +12 -0
  583. package/src/tools/create/mermaid.ts +6 -6
  584. package/src/tools/create/place.ts +80 -0
  585. package/src/tools/create.ts +1 -0
  586. package/src/tools/css/gradient.ts +147 -0
  587. package/src/tools/modify/geometry.ts +5 -5
  588. package/src/tools/modify/layout.ts +19 -0
  589. package/src/tools/modify/overrides.ts +35 -0
  590. package/src/tools/modify/paint.ts +124 -54
  591. package/src/tools/modify/text.ts +91 -7
  592. package/src/tools/modify/update.ts +23 -2
  593. package/src/tools/modify.ts +9 -1
  594. package/src/tools/read/css.ts +46 -12
  595. package/src/tools/read/nodes.ts +26 -4
  596. package/src/tools/registry/extended.ts +6 -0
  597. package/src/tools/text-range.ts +29 -0
  598. package/src/tools/variables/bindings.ts +4 -1
  599. package/src/tools/variables/unbind.ts +4 -1
  600. package/src/tools/vector/path.ts +11 -13
  601. package/src/vector/rebase.ts +33 -0
@@ -1 +1 @@
1
- {"version":3,"file":"manager.js","names":[],"sources":["../../../src/text/font/manager.ts"],"sourcesContent":["/* eslint-disable max-lines -- font loading and registration share FontManager lifecycle state */\n\nimport type { CanvasKit, TypefaceFontProvider } from 'canvaskit-wasm'\nimport { uniq } from 'es-toolkit'\n\nimport type { FontVariation, SceneGraph } from '@pairdraw/scene-graph'\nimport {\n GENERIC_FONT_FAMILIES_BY_CLASS,\n genericFontFamilyClass,\n isGenericFontFamily\n} from '@pairdraw/scene-graph/css'\nimport {\n faceLoadKey,\n namesWeight,\n normalizeFontFamily,\n parseFontStyle\n} from '@pairdraw/scene-graph/font-style'\n\nimport { DEFAULT_FONT_FAMILY, IS_BROWSER } from '#core/constants'\nimport {\n fallbackDrawsCharacter,\n fontFallbackEntry,\n type FontFallbackManifestEntry,\n LETTER_FALLBACK_SCRIPTS,\n type FontFallbackScript,\n type LetterFallbackScript\n} from '#core/text/fallbacks'\nimport { BundledFonts, type BundledFontLocator } from '#core/text/font/bundled'\nimport { FamilyFaceCatalog, type HostFontFamily } from '#core/text/font/catalog'\nimport { makeParagraphBuilder, resetFontCollection } from '#core/text/font/collection'\nimport {\n browserFaceDescriptors,\n fontFaceRenderFamily,\n type FamilyFace\n} from '#core/text/font/faces'\nimport { fontFeatureTags } from '#core/text/font/features'\nimport { loadHarfBuzz } from '#core/text/font/harfbuzz'\nimport { LocalFonts } from '#core/text/font/local'\nimport { sameFontFile, SharedReads, withHarfBuzz } from '#core/text/font/reads'\nimport {\n UnsupportedFontFormatError,\n type DownloadedFontCache,\n type FontFamilyOption,\n type FontInfo,\n type FontLoadedSource,\n type FontUnavailableReason,\n type HostFontLoader,\n type LocalFontAccessState\n} from '#core/text/font/sources'\nimport {\n fontAxes,\n hasNamedInstance,\n namedInstances,\n namedInstanceVariations,\n type FontAxis,\n type NamedInstance\n} from '#core/text/font/variation'\nimport { collectGraphFontKeys } from '#core/text/requirements/collect'\nimport { normalizedCoverageText, WebFontResolver } from '#core/text/web-font/resolver'\nimport type { WebFontFetch, WebFontProviderId } from '#core/text/web-font/resolver'\n\nexport type { BundledFontLocator } from '#core/text/font/bundled'\n\n/**\n * How long a web-font fetch may run before the page falls back to an installed or bundled face.\n * A provider that never answers must not block page preparation.\n */\nconst WEB_FONT_FETCH_TIMEOUT_MS = 10_000\n\n/**\n * `load`, bounded by `ms` and cancelled as soon as `signal` aborts, so a provider that never\n * answers cannot block page preparation. The timer clears when the load settles.\n */\nasync function fetchWithin<T>(\n load: (signal: AbortSignal) => Promise<T>,\n signal: AbortSignal | undefined,\n ms: number\n): Promise<T> {\n const bounded = new AbortController()\n const forward = () => bounded.abort(signal?.reason)\n signal?.addEventListener('abort', forward, { once: true })\n const timer = setTimeout(() => bounded.abort(new Error('Web font fetch timed out')), ms)\n try {\n return await load(bounded.signal)\n } finally {\n clearTimeout(timer)\n signal?.removeEventListener('abort', forward)\n }\n}\n\nexport class FontManager {\n private loadedFamilies = new Map<string, ArrayBuffer>()\n /** The families `loadedFamilies` has a face of, so asking needs no scan of its keys. */\n private loadedFamilyNames = new Set<string>()\n private loadedFamilySources = new Map<string, FontLoadedSource>()\n private unavailableFaces = new Map<string, FontUnavailableReason>()\n private supplementalFamilyData = new Map<string, ArrayBuffer[]>()\n /** The name each file of a family loaded from several files is registered under. */\n private fileFamilies = new Map<ArrayBuffer, string>()\n /**\n * Families a style's file was replaced in, such as a web font fetched again for more characters.\n * The old file stays registered first under the family's name, and CanvasKit draws with the\n * first file it has for a style, so these draw from each file's own name.\n */\n private replacedFamilies = new Set<string>()\n /**\n * The files each style's own file replaced, by `family|style`. They stay its fallbacks under\n * names of their own, never beside the file that replaced them, where CanvasKit would pick\n * between the two by the weight each declares.\n */\n private replacedFileData = new Map<string, Set<ArrayBuffer>>()\n private remoteCoverage = new Map<string, Set<string>>()\n private instanceVariations = new WeakMap<ArrayBuffer, Map<string, FontVariation[] | null>>()\n private variations = new WeakMap<\n ArrayBuffer,\n { axes: FontAxis[]; instances: NamedInstance[] } | null\n >()\n private featureTags = new WeakMap<ArrayBuffer, string[] | null>()\n private blockedNodeIds = new Set<string>()\n private fontProvider: TypefaceFontProvider | null = null\n private fontProviders = new Set<TypefaceFontProvider>()\n private providerCanvasKits = new WeakMap<TypefaceFontProvider, CanvasKit>()\n private registrationGeneration = 0\n private providerRegistrations = new WeakMap<TypefaceFontProvider, Map<string, Set<ArrayBuffer>>>()\n private readonly sharedProviders = new Map<\n CanvasKit,\n { provider: TypefaceFontProvider; users: number }\n >()\n private downloadedFontCache: DownloadedFontCache | null = null\n private fallbackUserAgent: string | undefined\n private hostFontLoader: HostFontLoader | null = null\n private readonly hostFontRequests = new SharedReads()\n private webFonts = new WebFontResolver()\n private readonly faceListeners = new Set<(family: string, style: string) => void>()\n private readonly unblockListeners = new Set<(nodeIds: readonly string[]) => void>()\n private readonly bundled = new BundledFonts()\n private readonly localFonts = new LocalFonts()\n private readonly faces = new FamilyFaceCatalog({\n localFonts: () => this.localFonts.list(),\n webFaces: (family) => this.webFonts.familyFaces(family),\n bundledStyles: (family) => this.bundled.styles(family)\n })\n private cjkFallbackFamilies: string[] = []\n private cjkFallbackPromise: Promise<string[]> | null = null\n /** The fallbacks of each script written in letters: Arabic, Hebrew, Thai, Devanagari. */\n private readonly letterFallbackFamilies = new Map<LetterFallbackScript, string[]>(\n LETTER_FALLBACK_SCRIPTS.map((script) => [script, []])\n )\n private readonly letterFallbackPromises = new Map<LetterFallbackScript, Promise<string[]>>()\n\n /**\n * The provider every renderer and shaper of `canvasKit` draws from. They share one module's\n * heap, and a provider holds its own copy of each font file, so a second provider would copy\n * every face again: the scene and overlay canvases, and every CJK system font, alike. A provider\n * already attached for `canvasKit` is shared too, so shaping draws the faces its caller\n * registered, not a second copy. Each call is matched by {@link releaseProvider}; the last\n * release deletes the provider.\n */\n acquireProvider(canvasKit: CanvasKit): TypefaceFontProvider {\n const shared = this.sharedProviders.get(canvasKit)\n if (shared) {\n shared.users++\n return shared.provider\n }\n const attached = this.providerFor(canvasKit)\n if (attached) {\n this.sharedProviders.set(canvasKit, { provider: attached, users: 1 })\n return attached\n }\n const provider = canvasKit.TypefaceFontProvider.Make()\n this.sharedProviders.set(canvasKit, { provider, users: 1 })\n this.attachProvider(canvasKit, provider)\n return provider\n }\n\n releaseProvider(provider: TypefaceFontProvider): void {\n for (const [canvasKit, shared] of this.sharedProviders) {\n if (shared.provider !== provider) continue\n if (--shared.users > 0) return\n this.sharedProviders.delete(canvasKit)\n this.detachProvider(provider)\n resetFontCollection(provider)\n provider.delete()\n return\n }\n }\n\n attachProvider(canvasKit: CanvasKit, provider: TypefaceFontProvider): void {\n this.fontProviders.add(provider)\n this.providerCanvasKits.set(provider, canvasKit)\n this.fontProvider = provider\n this.providerRegistrations.set(provider, new Map())\n this.registrationGeneration++\n for (const [cacheKey, data] of this.loadedFamilies) {\n const separator = cacheKey.indexOf('|')\n const family = cacheKey.slice(0, separator)\n this.registerFontInProvider(provider, family, data)\n for (const supplemental of this.supplementalFamilyData.get(cacheKey) ?? []) {\n this.registerFontInProvider(provider, family, supplemental)\n }\n }\n }\n\n detachProvider(provider: TypefaceFontProvider): void {\n this.fontProviders.delete(provider)\n this.providerRegistrations.delete(provider)\n resetFontCollection(provider)\n if (this.fontProvider === provider) {\n this.fontProvider = Array.from(this.fontProviders).at(-1) ?? null\n }\n }\n\n provider(): TypefaceFontProvider | null {\n return this.fontProvider\n }\n\n /** The latest attached provider made by `canvasKit`; another build's provider cannot shape with it. */\n providerFor(canvasKit: CanvasKit): TypefaceFontProvider | null {\n return (\n Array.from(this.fontProviders)\n .reverse()\n .find((provider) => this.providerCanvasKits.get(provider) === canvasKit) ?? null\n )\n }\n\n generation(): number {\n return this.registrationGeneration\n }\n\n blockNodesUntilFontsResolve(nodeIds: readonly string[]): void {\n for (const nodeId of nodeIds) this.blockedNodeIds.add(nodeId)\n }\n\n unblockNodes(nodeIds: readonly string[]): void {\n const shown: string[] = []\n for (const nodeId of nodeIds) if (this.blockedNodeIds.delete(nodeId)) shown.push(nodeId)\n if (shown.length > 0) for (const listener of this.unblockListeners) listener(shown)\n }\n\n /**\n * Calls the listener with the layers whose block ended, which the canvas left out while blocked\n * and draws again now.\n */\n onNodesUnblocked(listener: (nodeIds: readonly string[]) => void): () => void {\n this.unblockListeners.add(listener)\n return () => this.unblockListeners.delete(listener)\n }\n\n isNodeBlocked(nodeId: string): boolean {\n return this.blockedNodeIds.has(nodeId)\n }\n\n localAccessState(): LocalFontAccessState {\n return this.localFonts.accessState()\n }\n\n setDownloadedFontCache(cache: DownloadedFontCache | null): void {\n this.downloadedFontCache = cache\n }\n\n setFallbackUserAgent(userAgent: string | undefined): void {\n this.fallbackUserAgent = userAgent\n }\n\n setHostFontLoader(loader: HostFontLoader | null): void {\n this.hostFontLoader = loader\n this.hostFontRequests.clear()\n }\n\n /** Lets a host that bundles `@pairdraw/core/assets` itself say where each file ended up. */\n setBundledFontLocator(locate: BundledFontLocator | null): void {\n this.bundled.setLocator(locate)\n }\n\n setOnlineFontProviders(settings: Partial<Record<WebFontProviderId, boolean>>): void {\n this.webFonts.setEnabled(settings)\n this.faces.forget()\n }\n\n /** The system fonts a desktop host lists, by family, with the style names of their faces. */\n setHostFontCatalog(fonts: readonly HostFontFamily[]): void {\n this.faces.setHostCatalog(fonts)\n }\n\n /**\n * The faces a family has: its installed fonts', else a web provider's, else the bundled ones;\n * `null` when nothing says, so a caller offers every weight.\n */\n familyFaces(family: string): Promise<FamilyFace[] | null> {\n return this.faces.faces(family)\n }\n\n /** The faces `familyFaces` found for a family, once it has; `undefined` before. */\n loadedFamilyFaces(family: string): FamilyFace[] | null | undefined {\n return this.faces.foundFaces(family)\n }\n\n /** Whether a family has this face, or nothing found so far says it has not. */\n offersFace(family: string, weight: number, italic: boolean): boolean {\n return this.faces.offersFace(family, weight, italic)\n }\n\n /** The families whose faces `familyFaces` has found so far. */\n familiesWithFoundFaces(): string[] {\n return this.faces.foundFamilies()\n }\n\n /** Calls the listener whenever the faces found so far are forgotten. */\n onFamilyFacesReset(listener: () => void): () => void {\n return this.faces.onReset(listener)\n }\n\n /** The faces known for a family without asking a provider; see {@link FamilyFaceCatalog}. */\n familyFacesSync(family: string): FamilyFace[] | null {\n return this.faces.facesSync(family)\n }\n\n setWebFontFetch(fetcher: WebFontFetch | null): void {\n this.webFonts.setRemoteFetch(fetcher)\n }\n\n resetWebFontFailures(family?: string, style?: string): void {\n this.webFonts.resetFailures(family, style)\n }\n\n enabledOnlineFontProviders(): WebFontProviderId[] {\n return this.webFonts.enabledProviders()\n }\n\n loadCachedFont(family: string, style = 'Regular', characters = ''): Promise<ArrayBuffer | null> {\n return withHarfBuzz(this.restoreCachedFont(family, style, characters))\n }\n\n private async restoreCachedFont(\n family: string,\n style = 'Regular',\n characters = ''\n ): Promise<ArrayBuffer | null> {\n const cached = await this.readDownloadedFont(family, style, characters)\n if (!cached) return null\n const key = `${family}|${style}`\n const loadedCoverage = this.remoteCoverage.get(key) ?? new Set<string>()\n for (const character of normalizedCoverageText(characters)) loadedCoverage.add(character)\n this.remoteCoverage.set(key, loadedCoverage)\n return this.registerAndCache(family, style, cached, 'cache')\n }\n\n async requestLocalFontAccess(): Promise<FontInfo[]> {\n const fonts = await this.localFonts.requestAccess()\n this.faces.forget()\n return fonts\n }\n\n async listFamilies(): Promise<string[]> {\n const options = await this.listFamilyOptions()\n return options.map((option) => option.family)\n }\n\n /**\n * The families loaded from font files, such as a document's fonts, which no catalog lists:\n * installed, web, and bundled sources name their families without the files. A registered\n * family keeps its `document` source however it loads next, so the picker shows where the\n * file it draws from came from.\n */\n registeredFamilyOptions(): FontFamilyOption[] {\n const options: FontFamilyOption[] = []\n const seen = new Set<string>()\n for (const key of this.loadedFamilies.keys()) {\n const family = key.slice(0, key.lastIndexOf('|'))\n if (seen.has(family) || this.loadedFamilySources.get(key) !== 'registered') continue\n seen.add(family)\n options.push({ family, source: 'document' })\n }\n return options.sort((a, b) => a.family.localeCompare(b.family))\n }\n\n async listFamilyOptions(): Promise<FontFamilyOption[]> {\n const fonts = this.localFonts.list() ?? (await this.requestLocalFontAccess())\n const webFontFamilies = await Promise.all(\n this.enabledOnlineFontProviders().map(async (provider) => ({\n provider,\n families: await this.webFonts.listFamilies(provider)\n }))\n )\n const byFamily = new Map<string, FontFamilyOption>()\n byFamily.set(DEFAULT_FONT_FAMILY, { family: DEFAULT_FONT_FAMILY, source: 'bundled' })\n for (const { provider, families } of webFontFamilies) {\n for (const family of families) {\n if (!byFamily.has(family)) byFamily.set(family, { family, source: provider })\n }\n }\n for (const family of [...fonts.map((font) => font.family), ...this.faces.hostFamilies()])\n byFamily.set(family, { family, source: 'local' })\n // A family loaded from a font file draws from that file, whatever the catalogs say.\n for (const option of this.registeredFamilyOptions()) byFamily.set(option.family, option)\n return [...byFamily.values()].sort((a, b) => a.family.localeCompare(b.family))\n }\n\n preloadWebFontFamilies(): void {\n this.webFonts.preloadFamilies()\n }\n\n /** Reads a bundled font; concurrent loads of one file share a request. */\n fetchBundledFont(url: string): Promise<ArrayBuffer | null> {\n return this.bundled.fetch(url)\n }\n\n loadLocalFont(family: string, style = 'Regular'): Promise<ArrayBuffer | null> {\n return withHarfBuzz(this.findLocalOrBundledFont(family, style))\n }\n\n private async findLocalOrBundledFont(\n family: string,\n style = 'Regular'\n ): Promise<ArrayBuffer | null> {\n const loaded = this.loadedFamilies.get(`${family}|${style}`)\n if (loaded) {\n this.registerFontInCanvasKit(family, loaded)\n return loaded\n }\n return (\n (await this.loadInstalledFont(family, style)) ?? (await this.loadBundledFont(family, style))\n )\n }\n\n /** The face installed on this machine, from the host or the browser's local fonts. */\n private async loadInstalledFont(family: string, style: string): Promise<ArrayBuffer | null> {\n const hostBuffer = await this.loadHostFont(family, style)\n if (hostBuffer) return this.registerAndCache(family, style, hostBuffer, 'local')\n const localBuffer = await this.localFonts.read(family, style)\n return localBuffer ? this.registerAndCache(family, style, localBuffer, 'local') : null\n }\n\n private async loadBundledFont(family: string, style: string): Promise<ArrayBuffer | null> {\n const bundledURL = this.bundled.file(family, style)\n if (!bundledURL) return null\n try {\n const buffer = await this.fetchBundledFont(bundledURL)\n return buffer ? this.registerAndCache(family, style, buffer, 'bundled') : null\n } catch (e) {\n console.warn(`Bundled font load failed for \"${family}\" ${style}:`, e)\n return null\n }\n }\n\n loadRemoteFont(\n family: string,\n style = 'Regular',\n characters = '',\n signal?: AbortSignal\n ): Promise<ArrayBuffer | null> {\n return withHarfBuzz(this.downloadFont(family, style, characters, signal))\n }\n\n private async downloadFont(\n family: string,\n style = 'Regular',\n characters = '',\n signal?: AbortSignal\n ): Promise<ArrayBuffer | null> {\n signal?.throwIfAborted()\n if (typeof fetch === 'undefined') return null\n const coverage = this.remoteCoverage.get(`${family}|${style}`)\n if (\n characters &&\n coverage &&\n Array.from(characters).every((character) => coverage.has(character))\n ) {\n return this.loadedData(family, style)\n }\n try {\n const requestedCharacters = normalizedCoverageText(\n `${coverage ? Array.from(coverage).join('') : ''}${characters}`\n )\n const normalized = normalizeFontFamily(family)\n const families = normalized === family ? [family] : [family, normalized]\n const resolved = await fetchWithin(\n (boundedSignal) =>\n this.webFonts.fetchFont(families, style, requestedCharacters, boundedSignal),\n signal,\n WEB_FONT_FETCH_TIMEOUT_MS\n )\n if (!resolved || resolved.buffers.length === 0) return null\n const primary = resolved.buffers[0]\n // Providers serve faces by weight; a named face comes only from a variable file that has it.\n if (!namesWeight(style) && !hasNamedInstance(primary, style)) return null\n await this.writeDownloadedFont(family, style, primary, requestedCharacters)\n const registered = this.registerAndCache(family, style, primary, resolved.provider)\n const loadedCoverage = this.remoteCoverage.get(`${family}|${style}`) ?? new Set<string>()\n for (const character of requestedCharacters) loadedCoverage.add(character)\n this.remoteCoverage.set(`${family}|${style}`, loadedCoverage)\n for (const supplemental of resolved.buffers.slice(1)) {\n this.registerSupplemental(family, style, supplemental)\n }\n return registered\n } catch (e) {\n if (signal?.aborted) throw e\n console.warn(`Web font fetch failed for \"${family}\" ${style}:`, e)\n return null\n }\n }\n\n loadFont(\n family: string,\n style = 'Regular',\n characters = '',\n signal?: AbortSignal\n ): Promise<ArrayBuffer | null> {\n return withHarfBuzz(this.findFont(family, style, characters, signal))\n }\n\n private async findFont(\n family: string,\n style = 'Regular',\n characters = '',\n signal?: AbortSignal\n ): Promise<ArrayBuffer | null> {\n signal?.throwIfAborted()\n // A CSS generic keyword is never a bundled, installed, or served face: it draws a face of the\n // class it names, from the host or the bundle, rather than fetching a name no provider serves.\n if (isGenericFontFamily(family)) return this.loadGenericFont(family, style)\n const loaded = this.loadedData(family, style)\n if (loaded) {\n this.registerFontInCanvasKit(family, loaded)\n return this.withRemoteCoverage(family, style, loaded, characters, signal)\n }\n // An installed face of the style comes first; otherwise a variable file the family already\n // loaded draws it.\n const installed = await this.loadInstalledFont(family, style)\n if (installed) return installed\n const shared = this.sharedVariableFace(family, style)\n if (shared) return this.withRemoteCoverage(family, style, shared, characters, signal)\n\n return (\n (await this.loadBundledFont(family, style)) ??\n (await this.loadCachedFont(family, style, characters)) ??\n (await this.loadRemoteFont(family, style, characters, signal))\n )\n }\n\n /**\n * A CSS generic keyword draws a face of the class it names: the first concrete family the host\n * has, else a bundled one. Its bytes register under the keyword, so the text keeps its name.\n */\n private async loadGenericFont(keyword: string, style: string): Promise<ArrayBuffer | null> {\n const kind = genericFontFamilyClass(keyword)\n if (!kind) return null\n for (const candidate of GENERIC_FONT_FAMILIES_BY_CLASS[kind]) {\n const installed = await this.loadInstalledFont(candidate, style)\n if (installed) return this.registerAndCache(keyword, style, installed, 'local')\n const bundled = await this.loadBundledFont(candidate, style)\n if (bundled) return this.registerAndCache(keyword, style, bundled, 'bundled')\n }\n return null\n }\n\n /**\n * `data`, or a web font fetched again with `characters` when it came from the web without them,\n * as a provider cuts a font down to the text it is asked for.\n */\n private async withRemoteCoverage(\n family: string,\n style: string,\n data: ArrayBuffer,\n characters: string,\n signal?: AbortSignal\n ): Promise<ArrayBuffer> {\n const remoteCoverage = this.remoteCoverage.get(`${family}|${style}`)\n const missingRemoteCoverage = Boolean(\n characters &&\n remoteCoverage &&\n Array.from(characters).some((character) => !remoteCoverage.has(character))\n )\n return missingRemoteCoverage\n ? ((await this.loadRemoteFont(family, style, characters, signal)) ?? data)\n : data\n }\n\n /**\n * A variable font the family loaded for another style in the same slant whose weight axis\n * reaches this style's weight, registered for this style too: one file draws every weight.\n */\n private sharedVariableFace(family: string, style: string): ArrayBuffer | null {\n const { weight, italic } = parseFontStyle(style)\n // A face named apart from its weight (\"Condensed Bold\") is drawn by a file that has it.\n const named = !namesWeight(style)\n for (const [key, data] of this.loadedFamilies) {\n if (!key.startsWith(`${family}|`)) continue\n if (parseFontStyle(key.slice(family.length + 1)).italic !== italic) continue\n if (named && !hasNamedInstance(data, style)) continue\n const wght = fontAxes(data)?.find((axis) => axis.tag === 'wght')\n if (!wght || (!named && (weight < wght.min || weight > wght.max))) continue\n const coverage = this.remoteCoverage.get(key)\n if (coverage) this.remoteCoverage.set(`${family}|${style}`, new Set(coverage))\n return this.registerAndCache(family, style, data, this.loadedFamilySources.get(key))\n }\n return null\n }\n\n async ensureNodeFont(family: string, weight: number): Promise<void> {\n await this.loadFont(family, faceLoadKey(weight))\n }\n\n /** Registers a font the caller already has, resolving once its outlines can be read. */\n async markLoaded(\n family: string,\n style: string,\n data: ArrayBuffer,\n source: FontLoadedSource = 'registered'\n ): Promise<void> {\n this.registerAndCache(family, style, data, source)\n await loadHarfBuzz()\n }\n\n loadedFontSource(family: string, style: string): FontLoadedSource | null {\n return this.loadedFamilySources.get(`${family}|${style}`) ?? null\n }\n\n /** Why the host could not load an installed face, when it reported a reason. */\n unavailableReason(family: string, style: string): FontUnavailableReason | null {\n return this.unavailableFaces.get(`${family}|${style}`) ?? null\n }\n\n isLoaded(family: string): boolean {\n return this.loadedFamilyNames.has(family)\n }\n\n isStyleLoaded(family: string, style: string): boolean {\n return this.loadedFamilies.has(`${family}|${style}`)\n }\n\n remoteStyleNeedsCoverage(family: string, style: string, characters: readonly string[]): boolean {\n const coverage = this.remoteCoverage.get(`${family}|${style}`)\n return !!coverage && characters.some((character) => !coverage.has(character))\n }\n\n loadedData(family: string, style: string): ArrayBuffer | null {\n return this.loadedFamilies.get(`${family}|${style}`) ?? null\n }\n\n /**\n * The variation axes and named instances of a family's variable font, from a face it has loaded,\n * in the slant asked for where it has one: `null` when the faces it has loaded are static,\n * `undefined` when it has loaded none.\n */\n familyVariation(\n family: string,\n italic?: boolean\n ): { data: ArrayBuffer; axes: FontAxis[]; instances: NamedInstance[] } | null | undefined {\n let loaded = false\n let other: { data: ArrayBuffer; axes: FontAxis[]; instances: NamedInstance[] } | null = null\n for (const [key, data] of this.loadedFamilies) {\n if (!key.startsWith(`${family}|`)) continue\n loaded = true\n let variation = this.variations.get(data)\n if (variation === undefined) {\n const axes = fontAxes(data)\n variation = axes ? { axes, instances: namedInstances(data) } : null\n this.variations.set(data, variation)\n }\n if (!variation) continue\n const slant = parseFontStyle(key.slice(family.length + 1)).italic\n if (italic === undefined || slant === italic) return { data, ...variation }\n other ??= { data, ...variation }\n }\n return loaded ? other : undefined\n }\n\n /**\n * The OpenType feature tags a family's loaded font has, from its GSUB feature list: `undefined`\n * when no face of the family is loaded, `null` when its font has no GSUB table, else the tags\n * (empty when the table lists none). The panel offers a feature only when the font has it.\n */\n familyFeatures(family: string): string[] | null | undefined {\n let loaded = false\n for (const [key, data] of this.loadedFamilies) {\n if (!key.startsWith(`${family}|`)) continue\n loaded = true\n let tags = this.featureTags.get(data)\n if (tags === undefined) {\n tags = fontFeatureTags(data)\n this.featureTags.set(data, tags)\n }\n if (tags !== null) return tags\n }\n return loaded ? null : undefined\n }\n\n /** Axis coordinates for `style` when the loaded face is a variable font, otherwise `null`. */\n namedInstanceVariations(family: string, style: string): FontVariation[] | null {\n const data = this.loadedData(family, style)\n if (!data) return null\n let byStyle = this.instanceVariations.get(data)\n if (!byStyle) {\n byStyle = new Map()\n this.instanceVariations.set(data, byStyle)\n }\n if (!byStyle.has(style)) byStyle.set(style, namedInstanceVariations(data, style))\n return byStyle.get(style) ?? null\n }\n\n /**\n * The family CanvasKit is asked for to draw `style` of `family`. A family loaded from one file\n * draws under its own name, with every coverage shard, as some CJK and Arabic faces need to\n * paint. Loaded from several files, such as a bundled static face beside a downloaded variable\n * one, CanvasKit would pick among them by the weight each file declares, which can tie; each\n * style then draws from the file loaded for it, registered with its shards under a name of the\n * file's own. So does a family a style's file was replaced in, whose old file CanvasKit would\n * keep drawing under the family's name. Only the style's coverage shards join its file under\n * that name: a file it replaced, such as a static face cached before a variable one was\n * fetched, could declare the weight asked for and be drawn instead of the file it is outlined\n * from, so it draws only as a fallback, from `renderShardFamilies`.\n */\n renderFamily(family: string, style: string): string {\n const data = this.loadedData(family, style)\n if (!data || (this.familyFileCount(family) < 2 && !this.replacedFamilies.has(family)))\n return family\n const name = this.fileFamily(family, data)\n const replaced = this.replacedFileData.get(`${family}|${style}`)\n for (const shard of this.supplementalFamilyData.get(`${family}|${style}`) ?? [])\n if (!replaced?.has(shard)) this.registerFontInCanvasKit(name, shard)\n return name\n }\n\n /**\n * The names CanvasKit draws the other files of `style` of `family` under, such as the coverage\n * shards of a web font split by unicode-range. CanvasKit draws a character only from the first\n * file registered under a name, so each shard is a family of its own that text falls back to.\n */\n renderShardFamilies(family: string, style: string): string[] {\n return (this.supplementalFamilyData.get(`${family}|${style}`) ?? []).map((data) =>\n this.fileFamily(family, data)\n )\n }\n\n /** The files of `style` of `family` after its own, such as the shards of a split web font. */\n shardData(family: string, style: string): readonly ArrayBuffer[] {\n return this.supplementalFamilyData.get(`${family}|${style}`) ?? []\n }\n\n /** The name one file of `family` is registered under on its own. */\n private fileFamily(family: string, data: ArrayBuffer): string {\n let name = this.fileFamilies.get(data)\n if (!name) {\n name = fontFaceRenderFamily(family, `file ${this.fileFamilies.size + 1}`)\n this.fileFamilies.set(data, name)\n }\n this.registerFontInCanvasKit(name, data)\n return name\n }\n\n /** How many files the family's loaded styles come from. */\n private familyFileCount(family: string): number {\n const files = new Set<ArrayBuffer>()\n for (const [key, data] of this.loadedFamilies) if (key.startsWith(`${family}|`)) files.add(data)\n return files.size\n }\n\n collectFontKeys(graph: SceneGraph, nodeIds: string[]): Array<[string, string]> {\n return collectGraphFontKeys(graph, nodeIds)\n }\n\n async ensureCJKFallback(): Promise<string[]> {\n if (this.cjkFallbackFamilies.length > 0) return this.cjkFallbackFamilies\n if (this.cjkFallbackPromise) return this.cjkFallbackPromise\n\n this.cjkFallbackPromise = this.ensureFallbackFamilies('cjk', this.cjkFallbackFamilies)\n return this.cjkFallbackPromise\n }\n\n getCJKFallbackFamilies(): string[] {\n return this.cjkFallbackFamilies\n }\n\n setCJKFallbackFamily(family: string): void {\n if (!this.cjkFallbackFamilies.includes(family)) {\n this.cjkFallbackFamilies.push(family)\n }\n }\n\n private ensureLetterFallback(script: LetterFallbackScript): Promise<string[]> {\n const families = this.letterFamilies(script)\n if (families.length > 0) return Promise.resolve(families)\n let pending = this.letterFallbackPromises.get(script)\n if (!pending) {\n pending = this.ensureFallbackFamilies(script, families)\n this.letterFallbackPromises.set(script, pending)\n }\n return pending\n }\n\n private letterFamilies(script: LetterFallbackScript): string[] {\n let families = this.letterFallbackFamilies.get(script)\n if (!families) {\n families = []\n this.letterFallbackFamilies.set(script, families)\n }\n return families\n }\n\n /** The list a script's fallback families are kept in. */\n private fallbackTarget(script: FontFallbackScript): string[] {\n return isLetterFallbackScript(script) ? this.letterFamilies(script) : this.cjkFallbackFamilies\n }\n\n ensureFallbackPack(\n scripts: FontFallbackScript[] = ['cjk', 'arabic'],\n characters = '',\n signal?: AbortSignal\n ): Promise<Partial<Record<FontFallbackScript, string[]>>> {\n return withHarfBuzz(this.loadFallbackPack(scripts, characters, signal))\n }\n\n private async loadFallbackPack(\n scripts: FontFallbackScript[] = ['cjk', 'arabic'],\n characters = '',\n signal?: AbortSignal\n ): Promise<Partial<Record<FontFallbackScript, string[]>>> {\n signal?.throwIfAborted()\n const result: Partial<Record<FontFallbackScript, string[]>> = {}\n await Promise.all(\n scripts.map(async (script) => {\n signal?.throwIfAborted()\n const target = this.fallbackTarget(script)\n if (signal) {\n result[script] = await this.ensureFallbackFamilies(script, target, characters, signal)\n } else if (isLetterFallbackScript(script) && !characters) {\n result[script] = await this.ensureLetterFallback(script)\n } else if (script === 'cjk' && !characters) {\n result[script] = await this.ensureCJKFallback()\n } else {\n result[script] = await this.ensureFallbackFamilies(script, target, characters)\n }\n })\n )\n signal?.throwIfAborted()\n return result\n }\n\n /**\n * The fallbacks for scripts written in letters, Arabic first, in the order the renderer tries\n * them: each covers its own script, and all come before the CJK fallbacks.\n */\n getLetterFallbackFamilies(): string[] {\n return uniq(LETTER_FALLBACK_SCRIPTS.flatMap((script) => this.letterFamilies(script)))\n }\n\n setLetterFallbackFamily(script: LetterFallbackScript, family: string): void {\n const families = this.letterFamilies(script)\n if (!families.includes(family)) families.push(family)\n }\n\n /**\n * Loads the fallback faces for `script`. The first installed one of its families comes in, and\n * the next only for the characters of its writing system among `characters` that CanvasKit finds\n * no glyph for in the fallbacks loaded: each is a whole system face, tens of megabytes for a CJK\n * one, copied into CanvasKit. Web fonts come in, cut to the characters, when no installed face\n * covers them.\n */\n private async ensureFallbackFamilies(\n script: FontFallbackScript,\n targetFamilies: string[],\n characters = '',\n signal?: AbortSignal\n ): Promise<string[]> {\n signal?.throwIfAborted()\n const manifest = fontFallbackEntry(script, this.fallbackUserAgent)\n const needed = uniq(Array.from(characters)).filter((character) =>\n fallbackDrawsCharacter(script, character)\n )\n // Families only come in, so what one check resolved stays resolved.\n let pending = needed\n const missing = () => (pending = this.unresolvedCharacters(targetFamilies, pending))\n // Without text to check coverage against, the whole chain comes in as before: a document\n // prepares its fallbacks before any text is known, and the chain must cover any character.\n const loadAll = characters === ''\n\n let installed = false\n for (const family of manifest.localFamilies) {\n if (!loadAll && installed && missing().length === 0) break\n signal?.throwIfAborted()\n const buffer =\n (await this.loadHostFont(family, 'Regular')) ?? (await this.localFonts.read(family))\n signal?.throwIfAborted()\n if (buffer && this.registerAndCache(family, 'Regular', buffer, 'fallback')) {\n if (!targetFamilies.includes(family)) targetFamilies.push(family)\n installed = true\n }\n }\n\n const remoteCharacters = loadAll || !installed ? characters : missing().join('')\n if (loadAll ? targetFamilies.length === 0 : !installed || remoteCharacters) {\n await this.loadRemoteFallbackFamilies(manifest, targetFamilies, remoteCharacters, signal)\n }\n\n return targetFamilies\n }\n\n /** Loads `manifest`'s web families, cut to `characters`, into `targetFamilies`. */\n private async loadRemoteFallbackFamilies(\n manifest: FontFallbackManifestEntry,\n targetFamilies: string[],\n characters: string,\n signal?: AbortSignal\n ): Promise<void> {\n const results = await Promise.allSettled(\n manifest.remoteFamilies.map(async (family) => {\n signal?.throwIfAborted()\n const data = await this.loadRemoteFont(family, 'Regular', characters, signal)\n signal?.throwIfAborted()\n return data ? family : null\n })\n )\n for (const result of results) {\n if (result.status === 'fulfilled' && result.value && !targetFamilies.includes(result.value)) {\n targetFamilies.push(result.value)\n }\n }\n }\n\n /**\n * The characters CanvasKit finds no glyph for in `families`, shaped with the provider the\n * canvas draws from. Without one, as in an export before any canvas or shaper holds it, it\n * cannot tell and counts every character missing, so every family loads as it always did.\n */\n private unresolvedCharacters(families: readonly string[], characters: string[]): string[] {\n if (characters.length === 0) return []\n if (families.length === 0) return characters\n const shared = this.sharedProviders.entries().next().value\n if (!shared) return characters\n const [canvasKit, { provider }] = shared\n const style = new canvasKit.ParagraphStyle({\n textStyle: { fontFamilies: [...families], fontSize: 16 }\n })\n const builder = makeParagraphBuilder(canvasKit, style, provider)\n try {\n builder.addText(characters.join(''))\n const paragraph = builder.build()\n try {\n paragraph.layout(Number.MAX_SAFE_INTEGER)\n const unresolved = new Set(paragraph.unresolvedCodepoints())\n return characters.filter((character) => unresolved.has(character.codePointAt(0) ?? 0))\n } finally {\n paragraph.delete()\n }\n } finally {\n builder.delete()\n }\n }\n\n private loadHostFont(family: string, style: string): Promise<ArrayBuffer | null> {\n const loader = this.hostFontLoader\n if (!loader) return Promise.resolve(null)\n return this.hostFontRequests.read(`${family}|${style}`, () =>\n this.readHostFont(loader, family, style)\n )\n }\n\n private async readHostFont(\n loader: HostFontLoader,\n family: string,\n style: string\n ): Promise<ArrayBuffer | null> {\n const key = `${family}|${style}`\n try {\n const data = await loader(family, style)\n // A read that started under a loader the host has replaced must not register its bytes.\n if (this.hostFontLoader !== loader) return null\n if (data) this.unavailableFaces.delete(key)\n return data\n } catch (e) {\n // A failure from a replaced loader says nothing about the face the new loader serves.\n if (this.hostFontLoader !== loader) return null\n if (e instanceof UnsupportedFontFormatError) {\n this.unavailableFaces.set(key, e.reason)\n return null\n }\n console.warn(`Host fallback font load failed for \"${family}\" ${style}:`, e)\n return null\n }\n }\n\n private async readDownloadedFont(\n family: string,\n style: string,\n characters = ''\n ): Promise<ArrayBuffer | null> {\n if (!this.downloadedFontCache) return null\n try {\n return await this.downloadedFontCache.read(family, style, characters)\n } catch (e) {\n console.warn(`Downloaded font cache read failed for \"${family}\" ${style}:`, e)\n return null\n }\n }\n\n private async writeDownloadedFont(\n family: string,\n style: string,\n data: ArrayBuffer,\n characters = ''\n ): Promise<void> {\n if (!this.downloadedFontCache) return\n try {\n await this.downloadedFontCache.write(family, style, data, characters)\n } catch (e) {\n console.warn(`Downloaded font cache write failed for \"${family}\" ${style}:`, e)\n }\n }\n\n /** Adds `buffer` to the files of `style` after its own, returning the copy of it they keep. */\n private registerSupplemental(\n family: string,\n style: string,\n buffer: ArrayBuffer,\n source?: FontLoadedSource\n ): ArrayBuffer {\n const key = `${family}|${style}`\n const supplemental = this.supplementalFamilyData.get(key) ?? []\n const kept = supplemental.find((file) => sameFontFile(file, buffer))\n if (kept) return kept\n supplemental.push(buffer)\n this.supplementalFamilyData.set(key, supplemental)\n this.registerFontInCanvasKit(family, buffer)\n if (!pageDrawsByName(source)) this.registerFontInBrowser(family, style, buffer)\n return buffer\n }\n\n private registerAndCache(\n family: string,\n style: string,\n buffer: ArrayBuffer,\n source?: FontLoadedSource\n ): ArrayBuffer | null {\n const key = `${family}|${style}`\n const existing = this.loadedFamilies.get(key)\n if (existing && sameFontFile(existing, buffer)) {\n if (source) this.loadedFamilySources.set(key, source)\n this.registerFontInCanvasKit(family, existing)\n return existing\n }\n if (existing) {\n const replaced = this.replacedFileData.get(key) ?? new Set<ArrayBuffer>()\n replaced.add(\n this.registerSupplemental(family, style, existing, this.loadedFamilySources.get(key))\n )\n this.replacedFileData.set(key, replaced)\n this.replacedFamilies.add(family)\n }\n this.loadedFamilies.set(key, buffer)\n this.loadedFamilyNames.add(family)\n if (source) this.loadedFamilySources.set(key, source)\n this.registerFontInCanvasKit(family, buffer)\n // The page's own text falls back to the system's fonts by itself, and a browser face would be\n // one more copy of a whole system file.\n if (!pageDrawsByName(source)) this.registerFontInBrowser(family, style, buffer)\n for (const listener of this.faceListeners) listener(family, style)\n return buffer\n }\n\n /**\n * Calls the listener with each face once its file is registered, by whatever path it loaded:\n * a paste, a script, a retry, or the renderer.\n */\n onFaceLoaded(listener: (family: string, style: string) => void): () => void {\n this.faceListeners.add(listener)\n return () => this.faceListeners.delete(listener)\n }\n\n private registerFontInCanvasKit(family: string, data: ArrayBuffer): boolean {\n let registered = false\n for (const provider of this.fontProviders) {\n registered = this.registerFontInProvider(provider, family, data) || registered\n }\n return registered\n }\n\n private registerFontInProvider(\n provider: TypefaceFontProvider,\n family: string,\n data: ArrayBuffer\n ): boolean {\n if (data.byteLength < 4) return false\n const registrations = this.providerRegistrations.get(provider) ?? new Map()\n const registeredData = registrations.get(family)\n if (registeredData?.has(data)) return true\n try {\n provider.registerFont(data, family)\n resetFontCollection(provider)\n const familyRegistrations = registeredData ?? new Set<ArrayBuffer>()\n familyRegistrations.add(data)\n registrations.set(family, familyRegistrations)\n this.providerRegistrations.set(provider, registrations)\n this.registrationGeneration++\n return true\n } catch {\n return false\n }\n }\n\n /** Makes a face available to the page's own text, such as fields over canvas labels. */\n registerFontInBrowser(family: string, style: string, data: ArrayBuffer) {\n if (!IS_BROWSER) return\n const face = new FontFace(family, data, browserFaceDescriptors(style, data))\n face\n .load()\n .then(() => document.fonts.add(face))\n .catch(() => {\n console.warn(`Failed to load font \"${family}\" (${style})`)\n })\n }\n}\n\n/**\n * Whether the page draws a face from `source` by itself: it draws installed fonts by name and\n * falls back to the system's. A browser face would copy a whole system file, and one under an\n * installed family's name stands in for all of that family's faces: WebView2 draws their bold\n * and italic text in it.\n */\nfunction pageDrawsByName(source: FontLoadedSource | undefined): boolean {\n return source === 'local' || source === 'fallback'\n}\n\nexport const fontManager = new FontManager()\n\nfunction isLetterFallbackScript(script: FontFallbackScript): script is LetterFallbackScript {\n return LETTER_FALLBACK_SCRIPTS.some((letter) => letter === script)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAmEA,MAAM,4BAA4B;;;;;AAMlC,eAAe,YACb,MACA,QACA,IACY;CACZ,MAAM,UAAU,IAAI,gBAAgB;CACpC,MAAM,gBAAgB,QAAQ,MAAM,QAAQ,MAAM;CAClD,QAAQ,iBAAiB,SAAS,SAAS,EAAE,MAAM,KAAK,CAAC;CACzD,MAAM,QAAQ,iBAAiB,QAAQ,sBAAM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MAAM,iBAAiB,cAAc,IAAI,MAAM;EAC/C,IAAI,gBAAgB,IAAI,IAAI,GAAG,OAAO;EACtC,IAAI;GACF,SAAS,aAAa,MAAM,MAAM;GAClC,oBAAoB,QAAQ;GAC5B,MAAM,sBAAsB,kCAAkB,IAAI,IAAiB;GACnE,oBAAoB,IAAI,IAAI;GAC5B,cAAc,IAAI,QAAQ,mBAAmB;GAC7C,KAAK,sBAAsB,IAAI,UAAU,aAAa;GACtD,KAAK;GACL,OAAO;EACT,QAAQ;GACN,OAAO;EACT;CACF;;CAGA,sBAAsB,QAAgB,OAAe,MAAmB;EACtE,IAAI,CAAC,YAAY;EACjB,MAAM,OAAO,IAAI,SAAS,QAAQ,MAAM,uBAAuB,OAAO,IAAI,CAAC;EAC3E,KACG,KAAK,CAAC,CACN,WAAW,SAAS,MAAM,IAAI,IAAI,CAAC,CAAC,CACpC,YAAY;GACX,QAAQ,KAAK,wBAAwB,OAAO,KAAK,MAAM,EAAE;EAC3D,CAAC;CACL;AACF;;;;;;;AAQA,SAAS,gBAAgB,QAA+C;CACtE,OAAO,WAAW,WAAW,WAAW;AAC1C;AAEA,MAAa,cAAc,IAAI,YAAY;AAE3C,SAAS,uBAAuB,QAA4D;CAC1F,OAAO,wBAAwB,MAAM,WAAW,WAAW,MAAM;AACnE"}
1
+ {"version":3,"file":"manager.js","names":[],"sources":["../../../src/text/font/manager.ts"],"sourcesContent":["/* eslint-disable max-lines -- font loading and registration share FontManager lifecycle state */\n\nimport type { CanvasKit, TypefaceFontProvider } from 'canvaskit-wasm'\nimport { uniq } from 'es-toolkit'\n\nimport type { FontVariation, SceneGraph } from '@pairdraw/scene-graph'\nimport {\n GENERIC_FONT_FAMILIES_BY_CLASS,\n genericFontFamilyClass,\n isGenericFontFamily\n} from '@pairdraw/scene-graph/css'\nimport {\n faceLoadKey,\n namesWeight,\n normalizeFontFamily,\n parseFontStyle\n} from '@pairdraw/scene-graph/font-style'\n\nimport { DEFAULT_FONT_FAMILY, IS_BROWSER } from '#core/constants'\nimport {\n fallbackDrawsCharacter,\n fontFallbackEntry,\n type FontFallbackManifestEntry,\n LETTER_FALLBACK_SCRIPTS,\n type FontFallbackScript,\n type LetterFallbackScript\n} from '#core/text/fallbacks'\nimport { createFontFaceBatch, FONT_FACE_BATCH_DELAY_MS } from '#core/text/font/batch'\nimport { BundledFonts, type BundledFontLocator } from '#core/text/font/bundled'\nimport { FamilyFaceCatalog, type HostFontFamily } from '#core/text/font/catalog'\nimport { makeParagraphBuilder, resetFontCollection } from '#core/text/font/collection'\nimport {\n browserFaceDescriptors,\n fontFaceRenderFamily,\n type FamilyFace\n} from '#core/text/font/faces'\nimport { fontFeatureTags } from '#core/text/font/features'\nimport { loadHarfBuzz } from '#core/text/font/harfbuzz'\nimport { LocalFonts } from '#core/text/font/local'\nimport { sameFontFile, SharedReads, withHarfBuzz } from '#core/text/font/reads'\nimport {\n UnsupportedFontFormatError,\n type DownloadedFontCache,\n type FontFamilyOption,\n type FontInfo,\n type FontLoadedSource,\n type FontUnavailableReason,\n type HostFontLoader,\n type LocalFontAccessState\n} from '#core/text/font/sources'\nimport {\n fontAxes,\n hasNamedInstance,\n namedInstances,\n namedInstanceVariations,\n type FontAxis,\n type NamedInstance\n} from '#core/text/font/variation'\nimport { collectGraphFontKeys } from '#core/text/requirements/collect'\nimport { normalizedCoverageText, WebFontResolver } from '#core/text/web-font/resolver'\nimport type { WebFontFetch, WebFontProviderId } from '#core/text/web-font/resolver'\n\nexport type { BundledFontLocator } from '#core/text/font/bundled'\n\n/**\n * How long a web-font fetch may run before the page falls back to an installed or bundled face.\n * A provider that never answers must not block page preparation.\n */\nconst WEB_FONT_FETCH_TIMEOUT_MS = 10_000\n\n/**\n * `load`, bounded by `ms` and cancelled as soon as `signal` aborts, so a provider that never\n * answers cannot block page preparation. The timer clears when the load settles.\n */\nasync function fetchWithin<T>(\n load: (signal: AbortSignal) => Promise<T>,\n signal: AbortSignal | undefined,\n ms: number\n): Promise<T> {\n const bounded = new AbortController()\n const forward = () => bounded.abort(signal?.reason)\n signal?.addEventListener('abort', forward, { once: true })\n const timer = setTimeout(() => bounded.abort(new Error('Web font fetch timed out')), ms)\n try {\n return await load(bounded.signal)\n } finally {\n clearTimeout(timer)\n signal?.removeEventListener('abort', forward)\n }\n}\n\nexport class FontManager {\n private loadedFamilies = new Map<string, ArrayBuffer>()\n /** The families `loadedFamilies` has a face of, so asking needs no scan of its keys. */\n private loadedFamilyNames = new Set<string>()\n private loadedFamilySources = new Map<string, FontLoadedSource>()\n private unavailableFaces = new Map<string, FontUnavailableReason>()\n private supplementalFamilyData = new Map<string, ArrayBuffer[]>()\n /** The name each file of a family loaded from several files is registered under. */\n private fileFamilies = new Map<ArrayBuffer, string>()\n /**\n * Families a style's file was replaced in, such as a web font fetched again for more characters.\n * The old file stays registered first under the family's name, and CanvasKit draws with the\n * first file it has for a style, so these draw from each file's own name.\n */\n private replacedFamilies = new Set<string>()\n /**\n * The files each style's own file replaced, by `family|style`. They stay its fallbacks under\n * names of their own, never beside the file that replaced them, where CanvasKit would pick\n * between the two by the weight each declares.\n */\n private replacedFileData = new Map<string, Set<ArrayBuffer>>()\n private remoteCoverage = new Map<string, Set<string>>()\n private instanceVariations = new WeakMap<ArrayBuffer, Map<string, FontVariation[] | null>>()\n private variations = new WeakMap<\n ArrayBuffer,\n { axes: FontAxis[]; instances: NamedInstance[] } | null\n >()\n private featureTags = new WeakMap<ArrayBuffer, string[] | null>()\n private blockedNodeIds = new Set<string>()\n private fontProvider: TypefaceFontProvider | null = null\n private fontProviders = new Set<TypefaceFontProvider>()\n private providerCanvasKits = new WeakMap<TypefaceFontProvider, CanvasKit>()\n private registrationGeneration = 0\n private providerRegistrations = new WeakMap<TypefaceFontProvider, Map<string, Set<ArrayBuffer>>>()\n private readonly sharedProviders = new Map<\n CanvasKit,\n { provider: TypefaceFontProvider; users: number }\n >()\n private downloadedFontCache: DownloadedFontCache | null = null\n private fallbackUserAgent: string | undefined\n private hostFontLoader: HostFontLoader | null = null\n private readonly hostFontRequests = new SharedReads()\n private webFonts = new WebFontResolver()\n private readonly faceListeners = new Set<(family: string, style: string) => void>()\n private readonly unblockListeners = new Set<(nodeIds: readonly string[]) => void>()\n private readonly bundled = new BundledFonts()\n private readonly localFonts = new LocalFonts()\n private readonly faces = new FamilyFaceCatalog({\n localFonts: () => this.localFonts.list(),\n webFaces: (family) => this.webFonts.familyFaces(family),\n bundledStyles: (family) => this.bundled.styles(family)\n })\n private cjkFallbackFamilies: string[] = []\n private cjkFallbackPromise: Promise<string[]> | null = null\n /** The fallbacks of each script written in letters: Arabic, Hebrew, Thai, Devanagari. */\n private readonly letterFallbackFamilies = new Map<LetterFallbackScript, string[]>(\n LETTER_FALLBACK_SCRIPTS.map((script) => [script, []])\n )\n private readonly letterFallbackPromises = new Map<LetterFallbackScript, Promise<string[]>>()\n\n /**\n * The provider every renderer and shaper of `canvasKit` draws from. They share one module's\n * heap, and a provider holds its own copy of each font file, so a second provider would copy\n * every face again: the scene and overlay canvases, and every CJK system font, alike. A provider\n * already attached for `canvasKit` is shared too, so shaping draws the faces its caller\n * registered, not a second copy. Each call is matched by {@link releaseProvider}; the last\n * release deletes the provider.\n */\n acquireProvider(canvasKit: CanvasKit): TypefaceFontProvider {\n const shared = this.sharedProviders.get(canvasKit)\n if (shared) {\n shared.users++\n return shared.provider\n }\n const attached = this.providerFor(canvasKit)\n if (attached) {\n this.sharedProviders.set(canvasKit, { provider: attached, users: 1 })\n return attached\n }\n const provider = canvasKit.TypefaceFontProvider.Make()\n this.sharedProviders.set(canvasKit, { provider, users: 1 })\n this.attachProvider(canvasKit, provider)\n return provider\n }\n\n releaseProvider(provider: TypefaceFontProvider): void {\n for (const [canvasKit, shared] of this.sharedProviders) {\n if (shared.provider !== provider) continue\n if (--shared.users > 0) return\n this.sharedProviders.delete(canvasKit)\n this.detachProvider(provider)\n resetFontCollection(provider)\n provider.delete()\n return\n }\n }\n\n attachProvider(canvasKit: CanvasKit, provider: TypefaceFontProvider): void {\n this.fontProviders.add(provider)\n this.providerCanvasKits.set(provider, canvasKit)\n this.fontProvider = provider\n this.providerRegistrations.set(provider, new Map())\n this.registrationGeneration++\n for (const [cacheKey, data] of this.loadedFamilies) {\n const separator = cacheKey.indexOf('|')\n const family = cacheKey.slice(0, separator)\n this.registerFontInProvider(provider, family, data)\n for (const supplemental of this.supplementalFamilyData.get(cacheKey) ?? []) {\n this.registerFontInProvider(provider, family, supplemental)\n }\n }\n }\n\n detachProvider(provider: TypefaceFontProvider): void {\n this.fontProviders.delete(provider)\n this.providerRegistrations.delete(provider)\n resetFontCollection(provider)\n if (this.fontProvider === provider) {\n this.fontProvider = Array.from(this.fontProviders).at(-1) ?? null\n }\n }\n\n provider(): TypefaceFontProvider | null {\n return this.fontProvider\n }\n\n /** The latest attached provider made by `canvasKit`; another build's provider cannot shape with it. */\n providerFor(canvasKit: CanvasKit): TypefaceFontProvider | null {\n return (\n Array.from(this.fontProviders)\n .reverse()\n .find((provider) => this.providerCanvasKits.get(provider) === canvasKit) ?? null\n )\n }\n\n generation(): number {\n return this.registrationGeneration\n }\n\n blockNodesUntilFontsResolve(nodeIds: readonly string[]): void {\n for (const nodeId of nodeIds) this.blockedNodeIds.add(nodeId)\n }\n\n unblockNodes(nodeIds: readonly string[]): void {\n const shown: string[] = []\n for (const nodeId of nodeIds) if (this.blockedNodeIds.delete(nodeId)) shown.push(nodeId)\n if (shown.length > 0) for (const listener of this.unblockListeners) listener(shown)\n }\n\n /**\n * Calls the listener with the layers whose block ended, which the canvas left out while blocked\n * and draws again now.\n */\n onNodesUnblocked(listener: (nodeIds: readonly string[]) => void): () => void {\n this.unblockListeners.add(listener)\n return () => this.unblockListeners.delete(listener)\n }\n\n isNodeBlocked(nodeId: string): boolean {\n return this.blockedNodeIds.has(nodeId)\n }\n\n localAccessState(): LocalFontAccessState {\n return this.localFonts.accessState()\n }\n\n setDownloadedFontCache(cache: DownloadedFontCache | null): void {\n this.downloadedFontCache = cache\n }\n\n setFallbackUserAgent(userAgent: string | undefined): void {\n this.fallbackUserAgent = userAgent\n }\n\n setHostFontLoader(loader: HostFontLoader | null): void {\n this.hostFontLoader = loader\n this.hostFontRequests.clear()\n }\n\n /** Lets a host that bundles `@pairdraw/core/assets` itself say where each file ended up. */\n setBundledFontLocator(locate: BundledFontLocator | null): void {\n this.bundled.setLocator(locate)\n }\n\n setOnlineFontProviders(settings: Partial<Record<WebFontProviderId, boolean>>): void {\n this.webFonts.setEnabled(settings)\n this.faces.forget()\n }\n\n /** The system fonts a desktop host lists, by family, with the style names of their faces. */\n setHostFontCatalog(fonts: readonly HostFontFamily[]): void {\n this.faces.setHostCatalog(fonts)\n }\n\n /**\n * The faces a family has: its installed fonts', else a web provider's, else the bundled ones;\n * `null` when nothing says, so a caller offers every weight.\n */\n familyFaces(family: string): Promise<FamilyFace[] | null> {\n return this.faces.faces(family)\n }\n\n /** The faces `familyFaces` found for a family, once it has; `undefined` before. */\n loadedFamilyFaces(family: string): FamilyFace[] | null | undefined {\n return this.faces.foundFaces(family)\n }\n\n /** Whether a family has this face, or nothing found so far says it has not. */\n offersFace(family: string, weight: number, italic: boolean): boolean {\n return this.faces.offersFace(family, weight, italic)\n }\n\n /** The families whose faces `familyFaces` has found so far. */\n familiesWithFoundFaces(): string[] {\n return this.faces.foundFamilies()\n }\n\n /** Calls the listener whenever the faces found so far are forgotten. */\n onFamilyFacesReset(listener: () => void): () => void {\n return this.faces.onReset(listener)\n }\n\n /** The faces known for a family without asking a provider; see {@link FamilyFaceCatalog}. */\n familyFacesSync(family: string): FamilyFace[] | null {\n return this.faces.facesSync(family)\n }\n\n setWebFontFetch(fetcher: WebFontFetch | null): void {\n this.webFonts.setRemoteFetch(fetcher)\n }\n\n resetWebFontFailures(family?: string, style?: string): void {\n this.webFonts.resetFailures(family, style)\n }\n\n enabledOnlineFontProviders(): WebFontProviderId[] {\n return this.webFonts.enabledProviders()\n }\n\n loadCachedFont(family: string, style = 'Regular', characters = ''): Promise<ArrayBuffer | null> {\n return withHarfBuzz(this.restoreCachedFont(family, style, characters))\n }\n\n private async restoreCachedFont(\n family: string,\n style = 'Regular',\n characters = ''\n ): Promise<ArrayBuffer | null> {\n const cached = await this.readDownloadedFont(family, style, characters)\n if (!cached) return null\n const key = `${family}|${style}`\n const loadedCoverage = this.remoteCoverage.get(key) ?? new Set<string>()\n for (const character of normalizedCoverageText(characters)) loadedCoverage.add(character)\n this.remoteCoverage.set(key, loadedCoverage)\n return this.registerAndCache(family, style, cached, 'cache')\n }\n\n async requestLocalFontAccess(): Promise<FontInfo[]> {\n const fonts = await this.localFonts.requestAccess()\n this.faces.forget()\n return fonts\n }\n\n async listFamilies(): Promise<string[]> {\n const options = await this.listFamilyOptions()\n return options.map((option) => option.family)\n }\n\n /**\n * The families loaded from font files, such as a document's fonts, which no catalog lists:\n * installed, web, and bundled sources name their families without the files. A registered\n * family keeps its `document` source however it loads next, so the picker shows where the\n * file it draws from came from.\n */\n registeredFamilyOptions(): FontFamilyOption[] {\n const options: FontFamilyOption[] = []\n const seen = new Set<string>()\n for (const key of this.loadedFamilies.keys()) {\n const family = key.slice(0, key.lastIndexOf('|'))\n if (seen.has(family) || this.loadedFamilySources.get(key) !== 'registered') continue\n seen.add(family)\n options.push({ family, source: 'document' })\n }\n return options.sort((a, b) => a.family.localeCompare(b.family))\n }\n\n async listFamilyOptions(): Promise<FontFamilyOption[]> {\n const fonts = this.localFonts.list() ?? (await this.requestLocalFontAccess())\n const webFontFamilies = await Promise.all(\n this.enabledOnlineFontProviders().map(async (provider) => ({\n provider,\n families: await this.webFonts.listFamilies(provider)\n }))\n )\n const byFamily = new Map<string, FontFamilyOption>()\n byFamily.set(DEFAULT_FONT_FAMILY, { family: DEFAULT_FONT_FAMILY, source: 'bundled' })\n for (const { provider, families } of webFontFamilies) {\n for (const family of families) {\n if (!byFamily.has(family)) byFamily.set(family, { family, source: provider })\n }\n }\n for (const family of [...fonts.map((font) => font.family), ...this.faces.hostFamilies()])\n byFamily.set(family, { family, source: 'local' })\n // A family loaded from a font file draws from that file, whatever the catalogs say.\n for (const option of this.registeredFamilyOptions()) byFamily.set(option.family, option)\n return [...byFamily.values()].sort((a, b) => a.family.localeCompare(b.family))\n }\n\n preloadWebFontFamilies(): void {\n this.webFonts.preloadFamilies()\n }\n\n /** Reads a bundled font; concurrent loads of one file share a request. */\n fetchBundledFont(url: string): Promise<ArrayBuffer | null> {\n return this.bundled.fetch(url)\n }\n\n loadLocalFont(family: string, style = 'Regular'): Promise<ArrayBuffer | null> {\n return withHarfBuzz(this.findLocalOrBundledFont(family, style))\n }\n\n private async findLocalOrBundledFont(\n family: string,\n style = 'Regular'\n ): Promise<ArrayBuffer | null> {\n const loaded = this.loadedFamilies.get(`${family}|${style}`)\n if (loaded) {\n this.registerFontInCanvasKit(family, loaded)\n return loaded\n }\n return (\n (await this.loadInstalledFont(family, style)) ?? (await this.loadBundledFont(family, style))\n )\n }\n\n /** The face installed on this machine, from the host or the browser's local fonts. */\n private async loadInstalledFont(family: string, style: string): Promise<ArrayBuffer | null> {\n const hostBuffer = await this.loadHostFont(family, style)\n if (hostBuffer) return this.registerAndCache(family, style, hostBuffer, 'local')\n const localBuffer = await this.localFonts.read(family, style)\n return localBuffer ? this.registerAndCache(family, style, localBuffer, 'local') : null\n }\n\n private async loadBundledFont(family: string, style: string): Promise<ArrayBuffer | null> {\n const bundledURL = this.bundled.file(family, style)\n if (!bundledURL) return null\n try {\n const buffer = await this.fetchBundledFont(bundledURL)\n return buffer ? this.registerAndCache(family, style, buffer, 'bundled') : null\n } catch (e) {\n console.warn(`Bundled font load failed for \"${family}\" ${style}:`, e)\n return null\n }\n }\n\n loadRemoteFont(\n family: string,\n style = 'Regular',\n characters = '',\n signal?: AbortSignal\n ): Promise<ArrayBuffer | null> {\n return withHarfBuzz(this.downloadFont(family, style, characters, signal))\n }\n\n private async downloadFont(\n family: string,\n style = 'Regular',\n characters = '',\n signal?: AbortSignal\n ): Promise<ArrayBuffer | null> {\n signal?.throwIfAborted()\n if (typeof fetch === 'undefined') return null\n const coverage = this.remoteCoverage.get(`${family}|${style}`)\n if (\n characters &&\n coverage &&\n Array.from(characters).every((character) => coverage.has(character))\n ) {\n return this.loadedData(family, style)\n }\n try {\n const requestedCharacters = normalizedCoverageText(\n `${coverage ? Array.from(coverage).join('') : ''}${characters}`\n )\n const normalized = normalizeFontFamily(family)\n const families = normalized === family ? [family] : [family, normalized]\n const resolved = await fetchWithin(\n (boundedSignal) =>\n this.webFonts.fetchFont(families, style, requestedCharacters, boundedSignal),\n signal,\n WEB_FONT_FETCH_TIMEOUT_MS\n )\n if (!resolved || resolved.buffers.length === 0) return null\n const primary = resolved.buffers[0]\n // Providers serve faces by weight; a named face comes only from a variable file that has it.\n if (!namesWeight(style) && !hasNamedInstance(primary, style)) return null\n await this.writeDownloadedFont(family, style, primary, requestedCharacters)\n const registered = this.registerAndCache(family, style, primary, resolved.provider)\n const loadedCoverage = this.remoteCoverage.get(`${family}|${style}`) ?? new Set<string>()\n for (const character of requestedCharacters) loadedCoverage.add(character)\n this.remoteCoverage.set(`${family}|${style}`, loadedCoverage)\n for (const supplemental of resolved.buffers.slice(1)) {\n this.registerSupplemental(family, style, supplemental)\n }\n return registered\n } catch (e) {\n if (signal?.aborted) throw e\n console.warn(`Web font fetch failed for \"${family}\" ${style}:`, e)\n return null\n }\n }\n\n loadFont(\n family: string,\n style = 'Regular',\n characters = '',\n signal?: AbortSignal\n ): Promise<ArrayBuffer | null> {\n return withHarfBuzz(this.findFont(family, style, characters, signal))\n }\n\n private async findFont(\n family: string,\n style = 'Regular',\n characters = '',\n signal?: AbortSignal\n ): Promise<ArrayBuffer | null> {\n signal?.throwIfAborted()\n // A CSS generic keyword is never a bundled, installed, or served face: it draws a face of the\n // class it names, from the host or the bundle, rather than fetching a name no provider serves.\n if (isGenericFontFamily(family)) return this.loadGenericFont(family, style)\n const loaded = this.loadedData(family, style)\n if (loaded) {\n this.registerFontInCanvasKit(family, loaded)\n return this.withRemoteCoverage(family, style, loaded, characters, signal)\n }\n // An installed face of the style comes first; otherwise a variable file the family already\n // loaded draws it.\n const installed = await this.loadInstalledFont(family, style)\n if (installed) return installed\n const shared = this.sharedVariableFace(family, style)\n if (shared) return this.withRemoteCoverage(family, style, shared, characters, signal)\n\n return (\n (await this.loadBundledFont(family, style)) ??\n (await this.loadCachedFont(family, style, characters)) ??\n (await this.loadRemoteFont(family, style, characters, signal))\n )\n }\n\n /**\n * A CSS generic keyword draws a face of the class it names: the first concrete family the host\n * has, else a bundled one. Its bytes register under the keyword, so the text keeps its name.\n */\n private async loadGenericFont(keyword: string, style: string): Promise<ArrayBuffer | null> {\n const kind = genericFontFamilyClass(keyword)\n if (!kind) return null\n for (const candidate of GENERIC_FONT_FAMILIES_BY_CLASS[kind]) {\n const installed = await this.loadInstalledFont(candidate, style)\n if (installed) return this.registerAndCache(keyword, style, installed, 'local')\n const bundled = await this.loadBundledFont(candidate, style)\n if (bundled) return this.registerAndCache(keyword, style, bundled, 'bundled')\n }\n return null\n }\n\n /**\n * `data`, or a web font fetched again with `characters` when it came from the web without them,\n * as a provider cuts a font down to the text it is asked for.\n */\n private async withRemoteCoverage(\n family: string,\n style: string,\n data: ArrayBuffer,\n characters: string,\n signal?: AbortSignal\n ): Promise<ArrayBuffer> {\n const remoteCoverage = this.remoteCoverage.get(`${family}|${style}`)\n const missingRemoteCoverage = Boolean(\n characters &&\n remoteCoverage &&\n Array.from(characters).some((character) => !remoteCoverage.has(character))\n )\n return missingRemoteCoverage\n ? ((await this.loadRemoteFont(family, style, characters, signal)) ?? data)\n : data\n }\n\n /**\n * A variable font the family loaded for another style in the same slant whose weight axis\n * reaches this style's weight, registered for this style too: one file draws every weight.\n */\n private sharedVariableFace(family: string, style: string): ArrayBuffer | null {\n const { weight, italic } = parseFontStyle(style)\n // A face named apart from its weight (\"Condensed Bold\") is drawn by a file that has it.\n const named = !namesWeight(style)\n for (const [key, data] of this.loadedFamilies) {\n if (!key.startsWith(`${family}|`)) continue\n if (parseFontStyle(key.slice(family.length + 1)).italic !== italic) continue\n if (named && !hasNamedInstance(data, style)) continue\n const wght = fontAxes(data)?.find((axis) => axis.tag === 'wght')\n if (!wght || (!named && (weight < wght.min || weight > wght.max))) continue\n const coverage = this.remoteCoverage.get(key)\n if (coverage) this.remoteCoverage.set(`${family}|${style}`, new Set(coverage))\n return this.registerAndCache(family, style, data, this.loadedFamilySources.get(key))\n }\n return null\n }\n\n async ensureNodeFont(family: string, weight: number): Promise<void> {\n await this.loadFont(family, faceLoadKey(weight))\n }\n\n /** Registers a font the caller already has, resolving once its outlines can be read. */\n async markLoaded(\n family: string,\n style: string,\n data: ArrayBuffer,\n source: FontLoadedSource = 'registered'\n ): Promise<void> {\n this.registerAndCache(family, style, data, source)\n await loadHarfBuzz()\n }\n\n loadedFontSource(family: string, style: string): FontLoadedSource | null {\n return this.loadedFamilySources.get(`${family}|${style}`) ?? null\n }\n\n /** Why the host could not load an installed face, when it reported a reason. */\n unavailableReason(family: string, style: string): FontUnavailableReason | null {\n return this.unavailableFaces.get(`${family}|${style}`) ?? null\n }\n\n isLoaded(family: string): boolean {\n return this.loadedFamilyNames.has(family)\n }\n\n isStyleLoaded(family: string, style: string): boolean {\n return this.loadedFamilies.has(`${family}|${style}`)\n }\n\n remoteStyleNeedsCoverage(family: string, style: string, characters: readonly string[]): boolean {\n const coverage = this.remoteCoverage.get(`${family}|${style}`)\n return !!coverage && characters.some((character) => !coverage.has(character))\n }\n\n loadedData(family: string, style: string): ArrayBuffer | null {\n return this.loadedFamilies.get(`${family}|${style}`) ?? null\n }\n\n /**\n * The variation axes and named instances of a family's variable font, from a face it has loaded,\n * in the slant asked for where it has one: `null` when the faces it has loaded are static,\n * `undefined` when it has loaded none.\n */\n familyVariation(\n family: string,\n italic?: boolean\n ): { data: ArrayBuffer; axes: FontAxis[]; instances: NamedInstance[] } | null | undefined {\n let loaded = false\n let other: { data: ArrayBuffer; axes: FontAxis[]; instances: NamedInstance[] } | null = null\n for (const [key, data] of this.loadedFamilies) {\n if (!key.startsWith(`${family}|`)) continue\n loaded = true\n let variation = this.variations.get(data)\n if (variation === undefined) {\n const axes = fontAxes(data)\n variation = axes ? { axes, instances: namedInstances(data) } : null\n this.variations.set(data, variation)\n }\n if (!variation) continue\n const slant = parseFontStyle(key.slice(family.length + 1)).italic\n if (italic === undefined || slant === italic) return { data, ...variation }\n other ??= { data, ...variation }\n }\n return loaded ? other : undefined\n }\n\n /**\n * The OpenType feature tags a family's loaded font has, from its GSUB feature list: `undefined`\n * when no face of the family is loaded, `null` when its font has no GSUB table, else the tags\n * (empty when the table lists none). The panel offers a feature only when the font has it.\n */\n familyFeatures(family: string): string[] | null | undefined {\n let loaded = false\n for (const [key, data] of this.loadedFamilies) {\n if (!key.startsWith(`${family}|`)) continue\n loaded = true\n let tags = this.featureTags.get(data)\n if (tags === undefined) {\n tags = fontFeatureTags(data)\n this.featureTags.set(data, tags)\n }\n if (tags !== null) return tags\n }\n return loaded ? null : undefined\n }\n\n /** Axis coordinates for `style` when the loaded face is a variable font, otherwise `null`. */\n namedInstanceVariations(family: string, style: string): FontVariation[] | null {\n const data = this.loadedData(family, style)\n if (!data) return null\n let byStyle = this.instanceVariations.get(data)\n if (!byStyle) {\n byStyle = new Map()\n this.instanceVariations.set(data, byStyle)\n }\n if (!byStyle.has(style)) byStyle.set(style, namedInstanceVariations(data, style))\n return byStyle.get(style) ?? null\n }\n\n /**\n * The family CanvasKit is asked for to draw `style` of `family`. A family loaded from one file\n * draws under its own name, with every coverage shard, as some CJK and Arabic faces need to\n * paint. Loaded from several files, such as a bundled static face beside a downloaded variable\n * one, CanvasKit would pick among them by the weight each file declares, which can tie; each\n * style then draws from the file loaded for it, registered with its shards under a name of the\n * file's own. So does a family a style's file was replaced in, whose old file CanvasKit would\n * keep drawing under the family's name. Only the style's coverage shards join its file under\n * that name: a file it replaced, such as a static face cached before a variable one was\n * fetched, could declare the weight asked for and be drawn instead of the file it is outlined\n * from, so it draws only as a fallback, from `renderShardFamilies`.\n */\n renderFamily(family: string, style: string): string {\n const data = this.loadedData(family, style)\n if (!data || (this.familyFileCount(family) < 2 && !this.replacedFamilies.has(family)))\n return family\n const name = this.fileFamily(family, data)\n const replaced = this.replacedFileData.get(`${family}|${style}`)\n for (const shard of this.supplementalFamilyData.get(`${family}|${style}`) ?? [])\n if (!replaced?.has(shard)) this.registerFontInCanvasKit(name, shard)\n return name\n }\n\n /**\n * The names CanvasKit draws the other files of `style` of `family` under, such as the coverage\n * shards of a web font split by unicode-range. CanvasKit draws a character only from the first\n * file registered under a name, so each shard is a family of its own that text falls back to.\n */\n renderShardFamilies(family: string, style: string): string[] {\n return (this.supplementalFamilyData.get(`${family}|${style}`) ?? []).map((data) =>\n this.fileFamily(family, data)\n )\n }\n\n /** The files of `style` of `family` after its own, such as the shards of a split web font. */\n shardData(family: string, style: string): readonly ArrayBuffer[] {\n return this.supplementalFamilyData.get(`${family}|${style}`) ?? []\n }\n\n /** The name one file of `family` is registered under on its own. */\n private fileFamily(family: string, data: ArrayBuffer): string {\n let name = this.fileFamilies.get(data)\n if (!name) {\n name = fontFaceRenderFamily(family, `file ${this.fileFamilies.size + 1}`)\n this.fileFamilies.set(data, name)\n }\n this.registerFontInCanvasKit(name, data)\n return name\n }\n\n /** How many files the family's loaded styles come from. */\n private familyFileCount(family: string): number {\n const files = new Set<ArrayBuffer>()\n for (const [key, data] of this.loadedFamilies) if (key.startsWith(`${family}|`)) files.add(data)\n return files.size\n }\n\n collectFontKeys(graph: SceneGraph, nodeIds: string[]): Array<[string, string]> {\n return collectGraphFontKeys(graph, nodeIds)\n }\n\n async ensureCJKFallback(): Promise<string[]> {\n if (this.cjkFallbackFamilies.length > 0) return this.cjkFallbackFamilies\n if (this.cjkFallbackPromise) return this.cjkFallbackPromise\n\n this.cjkFallbackPromise = this.ensureFallbackFamilies('cjk', this.cjkFallbackFamilies)\n return this.cjkFallbackPromise\n }\n\n getCJKFallbackFamilies(): string[] {\n return this.cjkFallbackFamilies\n }\n\n setCJKFallbackFamily(family: string): void {\n if (!this.cjkFallbackFamilies.includes(family)) {\n this.cjkFallbackFamilies.push(family)\n }\n }\n\n private ensureLetterFallback(script: LetterFallbackScript): Promise<string[]> {\n const families = this.letterFamilies(script)\n if (families.length > 0) return Promise.resolve(families)\n let pending = this.letterFallbackPromises.get(script)\n if (!pending) {\n pending = this.ensureFallbackFamilies(script, families)\n this.letterFallbackPromises.set(script, pending)\n }\n return pending\n }\n\n private letterFamilies(script: LetterFallbackScript): string[] {\n let families = this.letterFallbackFamilies.get(script)\n if (!families) {\n families = []\n this.letterFallbackFamilies.set(script, families)\n }\n return families\n }\n\n /** The list a script's fallback families are kept in. */\n private fallbackTarget(script: FontFallbackScript): string[] {\n return isLetterFallbackScript(script) ? this.letterFamilies(script) : this.cjkFallbackFamilies\n }\n\n ensureFallbackPack(\n scripts: FontFallbackScript[] = ['cjk', 'arabic'],\n characters = '',\n signal?: AbortSignal\n ): Promise<Partial<Record<FontFallbackScript, string[]>>> {\n return withHarfBuzz(this.loadFallbackPack(scripts, characters, signal))\n }\n\n private async loadFallbackPack(\n scripts: FontFallbackScript[] = ['cjk', 'arabic'],\n characters = '',\n signal?: AbortSignal\n ): Promise<Partial<Record<FontFallbackScript, string[]>>> {\n signal?.throwIfAborted()\n const result: Partial<Record<FontFallbackScript, string[]>> = {}\n await Promise.all(\n scripts.map(async (script) => {\n signal?.throwIfAborted()\n const target = this.fallbackTarget(script)\n if (signal) {\n result[script] = await this.ensureFallbackFamilies(script, target, characters, signal)\n } else if (isLetterFallbackScript(script) && !characters) {\n result[script] = await this.ensureLetterFallback(script)\n } else if (script === 'cjk' && !characters) {\n result[script] = await this.ensureCJKFallback()\n } else {\n result[script] = await this.ensureFallbackFamilies(script, target, characters)\n }\n })\n )\n signal?.throwIfAborted()\n return result\n }\n\n /**\n * The fallbacks for scripts written in letters, Arabic first, in the order the renderer tries\n * them: each covers its own script, and all come before the CJK fallbacks.\n */\n getLetterFallbackFamilies(): string[] {\n return uniq(LETTER_FALLBACK_SCRIPTS.flatMap((script) => this.letterFamilies(script)))\n }\n\n setLetterFallbackFamily(script: LetterFallbackScript, family: string): void {\n const families = this.letterFamilies(script)\n if (!families.includes(family)) families.push(family)\n }\n\n /**\n * Loads the fallback faces for `script`. The first installed one of its families comes in, and\n * the next only for the characters of its writing system among `characters` that CanvasKit finds\n * no glyph for in the fallbacks loaded: each is a whole system face, tens of megabytes for a CJK\n * one, copied into CanvasKit. Web fonts come in, cut to the characters, when no installed face\n * covers them.\n */\n private async ensureFallbackFamilies(\n script: FontFallbackScript,\n targetFamilies: string[],\n characters = '',\n signal?: AbortSignal\n ): Promise<string[]> {\n signal?.throwIfAborted()\n const manifest = fontFallbackEntry(script, this.fallbackUserAgent)\n const needed = uniq(Array.from(characters)).filter((character) =>\n fallbackDrawsCharacter(script, character)\n )\n // Families only come in, so what one check resolved stays resolved.\n let pending = needed\n const missing = () => (pending = this.unresolvedCharacters(targetFamilies, pending))\n // Without text to check coverage against, the whole chain comes in as before: a document\n // prepares its fallbacks before any text is known, and the chain must cover any character.\n const loadAll = characters === ''\n\n let installed = false\n for (const family of manifest.localFamilies) {\n if (!loadAll && installed && missing().length === 0) break\n signal?.throwIfAborted()\n const buffer =\n (await this.loadHostFont(family, 'Regular')) ?? (await this.localFonts.read(family))\n signal?.throwIfAborted()\n if (buffer && this.registerAndCache(family, 'Regular', buffer, 'fallback')) {\n if (!targetFamilies.includes(family)) targetFamilies.push(family)\n installed = true\n }\n }\n\n const remoteCharacters = loadAll || !installed ? characters : missing().join('')\n if (loadAll ? targetFamilies.length === 0 : !installed || remoteCharacters) {\n await this.loadRemoteFallbackFamilies(manifest, targetFamilies, remoteCharacters, signal)\n }\n\n return targetFamilies\n }\n\n /** Loads `manifest`'s web families, cut to `characters`, into `targetFamilies`. */\n private async loadRemoteFallbackFamilies(\n manifest: FontFallbackManifestEntry,\n targetFamilies: string[],\n characters: string,\n signal?: AbortSignal\n ): Promise<void> {\n const results = await Promise.allSettled(\n manifest.remoteFamilies.map(async (family) => {\n signal?.throwIfAborted()\n const data = await this.loadRemoteFont(family, 'Regular', characters, signal)\n signal?.throwIfAborted()\n return data ? family : null\n })\n )\n for (const result of results) {\n if (result.status === 'fulfilled' && result.value && !targetFamilies.includes(result.value)) {\n targetFamilies.push(result.value)\n }\n }\n }\n\n /**\n * The characters CanvasKit finds no glyph for in `families`, shaped with the provider the\n * canvas draws from. Without one, as in an export before any canvas or shaper holds it, it\n * cannot tell and counts every character missing, so every family loads as it always did.\n */\n private unresolvedCharacters(families: readonly string[], characters: string[]): string[] {\n if (characters.length === 0) return []\n if (families.length === 0) return characters\n const shared = this.sharedProviders.entries().next().value\n if (!shared) return characters\n const [canvasKit, { provider }] = shared\n const style = new canvasKit.ParagraphStyle({\n textStyle: { fontFamilies: [...families], fontSize: 16 }\n })\n const builder = makeParagraphBuilder(canvasKit, style, provider)\n try {\n builder.addText(characters.join(''))\n const paragraph = builder.build()\n try {\n paragraph.layout(Number.MAX_SAFE_INTEGER)\n const unresolved = new Set(paragraph.unresolvedCodepoints())\n return characters.filter((character) => unresolved.has(character.codePointAt(0) ?? 0))\n } finally {\n paragraph.delete()\n }\n } finally {\n builder.delete()\n }\n }\n\n private loadHostFont(family: string, style: string): Promise<ArrayBuffer | null> {\n const loader = this.hostFontLoader\n if (!loader) return Promise.resolve(null)\n return this.hostFontRequests.read(`${family}|${style}`, () =>\n this.readHostFont(loader, family, style)\n )\n }\n\n private async readHostFont(\n loader: HostFontLoader,\n family: string,\n style: string\n ): Promise<ArrayBuffer | null> {\n const key = `${family}|${style}`\n try {\n const data = await loader(family, style)\n // A read that started under a loader the host has replaced must not register its bytes.\n if (this.hostFontLoader !== loader) return null\n if (data) this.unavailableFaces.delete(key)\n return data\n } catch (e) {\n // A failure from a replaced loader says nothing about the face the new loader serves.\n if (this.hostFontLoader !== loader) return null\n if (e instanceof UnsupportedFontFormatError) {\n this.unavailableFaces.set(key, e.reason)\n return null\n }\n console.warn(`Host fallback font load failed for \"${family}\" ${style}:`, e)\n return null\n }\n }\n\n private async readDownloadedFont(\n family: string,\n style: string,\n characters = ''\n ): Promise<ArrayBuffer | null> {\n if (!this.downloadedFontCache) return null\n try {\n return await this.downloadedFontCache.read(family, style, characters)\n } catch (e) {\n console.warn(`Downloaded font cache read failed for \"${family}\" ${style}:`, e)\n return null\n }\n }\n\n private async writeDownloadedFont(\n family: string,\n style: string,\n data: ArrayBuffer,\n characters = ''\n ): Promise<void> {\n if (!this.downloadedFontCache) return\n try {\n await this.downloadedFontCache.write(family, style, data, characters)\n } catch (e) {\n console.warn(`Downloaded font cache write failed for \"${family}\" ${style}:`, e)\n }\n }\n\n /** Adds `buffer` to the files of `style` after its own, returning the copy of it they keep. */\n private registerSupplemental(\n family: string,\n style: string,\n buffer: ArrayBuffer,\n source?: FontLoadedSource\n ): ArrayBuffer {\n const key = `${family}|${style}`\n const supplemental = this.supplementalFamilyData.get(key) ?? []\n const kept = supplemental.find((file) => sameFontFile(file, buffer))\n if (kept) return kept\n supplemental.push(buffer)\n this.supplementalFamilyData.set(key, supplemental)\n this.registerFontInCanvasKit(family, buffer)\n if (!pageDrawsByName(source)) this.registerFontInBrowser(family, style, buffer)\n return buffer\n }\n\n private registerAndCache(\n family: string,\n style: string,\n buffer: ArrayBuffer,\n source?: FontLoadedSource\n ): ArrayBuffer | null {\n const key = `${family}|${style}`\n const existing = this.loadedFamilies.get(key)\n if (existing && sameFontFile(existing, buffer)) {\n if (source) this.loadedFamilySources.set(key, source)\n this.registerFontInCanvasKit(family, existing)\n return existing\n }\n if (existing) {\n const replaced = this.replacedFileData.get(key) ?? new Set<ArrayBuffer>()\n replaced.add(\n this.registerSupplemental(family, style, existing, this.loadedFamilySources.get(key))\n )\n this.replacedFileData.set(key, replaced)\n this.replacedFamilies.add(family)\n }\n this.loadedFamilies.set(key, buffer)\n this.loadedFamilyNames.add(family)\n if (source) this.loadedFamilySources.set(key, source)\n this.registerFontInCanvasKit(family, buffer)\n // The page's own text falls back to the system's fonts by itself, and a browser face would be\n // one more copy of a whole system file.\n if (!pageDrawsByName(source)) this.registerFontInBrowser(family, style, buffer)\n for (const listener of this.faceListeners) listener(family, style)\n return buffer\n }\n\n /**\n * Calls the listener with each face once its file is registered, by whatever path it loaded:\n * a paste, a script, a retry, or the renderer.\n */\n onFaceLoaded(listener: (family: string, style: string) => void): () => void {\n this.faceListeners.add(listener)\n return () => this.faceListeners.delete(listener)\n }\n\n private registerFontInCanvasKit(family: string, data: ArrayBuffer): boolean {\n let registered = false\n for (const provider of this.fontProviders) {\n registered = this.registerFontInProvider(provider, family, data) || registered\n }\n return registered\n }\n\n private registerFontInProvider(\n provider: TypefaceFontProvider,\n family: string,\n data: ArrayBuffer\n ): boolean {\n if (data.byteLength < 4) return false\n const registrations = this.providerRegistrations.get(provider) ?? new Map()\n const registeredData = registrations.get(family)\n if (registeredData?.has(data)) return true\n try {\n provider.registerFont(data, family)\n resetFontCollection(provider)\n const familyRegistrations = registeredData ?? new Set<ArrayBuffer>()\n familyRegistrations.add(data)\n registrations.set(family, familyRegistrations)\n this.providerRegistrations.set(provider, registrations)\n this.registrationGeneration++\n return true\n } catch {\n return false\n }\n }\n\n /** Makes a face available to the page's own text, such as fields over canvas labels. */\n registerFontInBrowser(family: string, style: string, data: ArrayBuffer) {\n if (!IS_BROWSER) return\n const face = new FontFace(family, data, browserFaceDescriptors(style, data))\n face\n .load()\n .then(() => browserFaces?.push(face))\n .catch(() => {\n console.warn(`Failed to load font \"${family}\" (${style})`)\n })\n }\n}\n\n/**\n * Whether the page draws a face from `source` by itself: it draws installed fonts by name and\n * falls back to the system's. A browser face would copy a whole system file, and one under an\n * installed family's name stands in for all of that family's faces: WebView2 draws their bold\n * and italic text in it.\n */\nfunction pageDrawsByName(source: FontLoadedSource | undefined): boolean {\n return source === 'local' || source === 'fallback'\n}\n\nexport const fontManager = new FontManager()\n\n/**\n * Faces loaded for the page's own text, added once per burst. Each `document.fonts.add` makes\n * WebKit rebuild its style resolver, and a rebuild registers every `@property` rule across every\n * live animation, so a burst of font loads must not clear the resolver once per face.\n */\nconst browserFaces = IS_BROWSER\n ? createFontFaceBatch<FontFace>({\n add: (face) => document.fonts.add(face),\n onError: (face) => console.warn(`Failed to add font \"${face.family}\" to the page`),\n schedule: (run) => {\n setTimeout(run, FONT_FACE_BATCH_DELAY_MS)\n }\n })\n : null\n\nfunction isLetterFallbackScript(script: FontFallbackScript): script is LetterFallbackScript {\n return LETTER_FALLBACK_SCRIPTS.some((letter) => letter === script)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAoEA,MAAM,4BAA4B;;;;;AAMlC,eAAe,YACb,MACA,QACA,IACY;CACZ,MAAM,UAAU,IAAI,gBAAgB;CACpC,MAAM,gBAAgB,QAAQ,MAAM,QAAQ,MAAM;CAClD,QAAQ,iBAAiB,SAAS,SAAS,EAAE,MAAM,KAAK,CAAC;CACzD,MAAM,QAAQ,iBAAiB,QAAQ,sBAAM,IAAI,MAAM,0BAA0B,CAAC,GAAG,EAAE;CACvF,IAAI;EACF,OAAO,MAAM,KAAK,QAAQ,MAAM;CAClC,UAAU;EACR,aAAa,KAAK;EAClB,QAAQ,oBAAoB,SAAS,OAAO;CAC9C;AACF;AAEA,IAAa,cAAb,MAAyB;CACvB,iCAAyB,IAAI,IAAyB;;CAEtD,oCAA4B,IAAI,IAAY;CAC5C,sCAA8B,IAAI,IAA8B;CAChE,mCAA2B,IAAI,IAAmC;CAClE,yCAAiC,IAAI,IAA2B;;CAEhE,+BAAuB,IAAI,IAAyB;;;;;;CAMpD,mCAA2B,IAAI,IAAY;;;;;;CAM3C,mCAA2B,IAAI,IAA8B;CAC7D,iCAAyB,IAAI,IAAyB;CACtD,qCAA6B,IAAI,QAA0D;CAC3F,6BAAqB,IAAI,QAGvB;CACF,8BAAsB,IAAI,QAAsC;CAChE,iCAAyB,IAAI,IAAY;CACzC,eAAoD;CACpD,gCAAwB,IAAI,IAA0B;CACtD,qCAA6B,IAAI,QAAyC;CAC1E,yBAA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B,QAA+C;CACtE,OAAO,WAAW,WAAW,WAAW;AAC1C;AAEA,MAAa,cAAc,IAAI,YAAY;;;;;;AAO3C,MAAM,eAAe,aACjB,oBAA8B;CAC5B,MAAM,SAAS,SAAS,MAAM,IAAI,IAAI;CACtC,UAAU,SAAS,QAAQ,KAAK,uBAAuB,KAAK,OAAO,cAAc;CACjF,WAAW,QAAQ;EACjB,WAAW,KAAA,GAA6B;CAC1C;AACF,CAAC,IACD;AAEJ,SAAS,uBAAuB,QAA4D;CAC1F,OAAO,wBAAwB,MAAM,WAAW,WAAW,MAAM;AACnE"}
@@ -18,6 +18,7 @@ import { InsertStyleSource, adjustRunsForDelete, applyStyleToRange, getStyleAt,
18
18
  import { TextCaseSegment, shownCharacters, shownText, shownTextSlice, textCaseSegments, transformTextCase } from "./case.js";
19
19
  import { textFallbackScriptsWithoutCoverage, textHasFallbackScript, textNeededFallbackScripts, textNeedsFallbackScript } from "./coverage.js";
20
20
  import { fontFeatureTags } from "./font/features.js";
21
+ import { FONT_FACE_BATCH_DELAY_MS, FontFaceBatch, FontFaceBatchOptions, createFontFaceBatch } from "./font/batch.js";
21
22
  import { BundledFontLocator } from "./font/bundled.js";
22
23
  import { DEFAULT_WEB_FONT_PROVIDER_SETTINGS, ResolvedWebFont, WEB_FONT_PROVIDER_IDS, WEB_FONT_PROVIDER_LABELS, WebFontFetch, WebFontProviderId, WebFontResolver, normalizedCoverageText, webFontSubsetsForText } from "./web-font/resolver.js";
23
24
  import { DownloadedFontCache, FontFamilyOption, FontFamilySource, FontInfo, FontLoadedSource, FontUnavailableReason, HostFontLoader, LocalFontAccessState, UnsupportedFontFormatError } from "./font/sources.js";
@@ -33,5 +34,5 @@ import { HyperlinkRunOptions, HyperlinkSpan, hyperlinkInRange, hyperlinkSpanAt,
33
34
  import { resolveFontReadiness } from "./prepare.js";
34
35
  import { TextFace, collectNamedNodeFontFaces, faceForStyle, faceStyleName, textFaceName, textStyleName } from "./font/names.js";
35
36
  import { DocumentFont, FontFaceReference, FontReplacement, FontReplacementCounts, listDocumentFonts, replaceDocumentFonts } from "./replace-fonts.js";
36
- import { layerTextStyleChanges, shownTextStyle } from "./character-style.js";
37
- export { ARABIC_CHARACTER, ARABIC_LOCAL_FALLBACK_FAMILIES, ARABIC_REMOTE_FALLBACK_FAMILIES, BrowserFaceDescriptors, type BundledFontLocator, CJK_CHARACTER, CJK_FALLBACK_CHARACTER, DEFAULT_WEB_FONT_PROVIDER_SETTINGS, DEVANAGARI_CHARACTER, DocumentFont, DocumentFontEntry, DocumentFontInput, DownloadedFontCache, FaceWeight, FamilyFace, FontAxis, FontCandidateSource, FontFaceReadiness, FontFaceRef, FontFaceReference, FontFallbackManifestEntry, FontFallbackScript, FontFamilyOption, FontFamilySource, FontInfo, FontLoadedSource, FontManager, FontProviderLease, FontReadiness, FontReadinessStatus, FontReplacement, FontReplacementCounts, FontResolutionCandidate, FontResolutionDemand, FontResolutionEvent, FontResolutionListener, FontResolutionLoader, FontResolutionSettled, FontResolutionSnapshot, FontResolutionState, FontResolver, FontUnavailableReason, type GlyphOutlineProbe, GraphFontRequirements, HANGUL_CHARACTER, HAN_CHARACTER, HEBREW_CHARACTER, type HarfBuzzSubsetLocator, type HostFontFamily, HostFontLoader, HyperlinkRunOptions, HyperlinkSpan, InsertStyleSource, KANA_CHARACTER, LETTER_FALLBACK_SCRIPTS, LetterFallbackScript, LocalFontAccessState, MissingGlyphOccurrence, MissingGraphFontScriptsOptions, NamedInstance, NamedLocalFont, ObservedShapedLine, type OutlineCommand, PathPoint, PathTextCaret, PathTextLayout, PathTextLineMetrics, ResolvedWebFont, SampledPath, THAI_CHARACTER, TextCaret, TextCaseSegment, TextEditor, TextEditorState, TextFace, UnsupportedFontFormatError, WEB_FONT_PROVIDER_IDS, WEB_FONT_PROVIDER_LABELS, WebFontFetch, WebFontProviderId, WebFontResolver, adjustRunsForDelete, applyStyleToRange, browserFaceDescriptors, calibratePathTextLayout, chooseLocalFontMatch, cjkFallbackScriptForLanguage, cjkLocalFallbackFamilies, collectGraphFontKeys, collectGraphFontRequirements, collectNamedNodeFontFaces, collectNodeFontFaces, documentFontData, documentFontsOf, faceForStyle, faceStyleName, facesFromStyles, fallbackDrawsCharacter, findLocalFont, fitTextPathBoxToGlyphs, fontAxes, fontCoverageDemand, fontFaceDemand, fontFaceFromFigmaFontName, fontFaceRenderFamily, fontFallbackEntry, fontFallbackManifest, fontFallbackScriptForCharacter, fontFeatureTags, fontManager, fontRemoteCoverageDemand, fontResolver, fontTableView, fontWeightMatchOrder, getStyleAt, getTextPathData, hasFamilyFace, hasNamedInstance, hasTrueTypeOutlines, hyperlinkInRange, hyperlinkSpanAt, hyperlinkSpans, insertRunsWithStyle, insertedStyleAt, isDocumentFontFileName, isOpenableLinkURL, isTraditionalOnlyHan, isVariableFont, isWOFF2, layerTextStyleChanges, layoutPathTextFromAdvances, leaseFontProvider, listDocumentFonts, mergeArchiveFonts, missingGlyphCharacters, missingGlyphOccurrences, missingGlyphScripts, missingGlyphsByScript, missingGraphFontScripts, namedInstanceVariations, namedInstances, nearestArcPoint, nearestFamilyFace, normalizeLinkURL, normalizedCoverageText, pathTextCaret, pathTextIndexAt, pathTextSelectionQuads, pointAtArc, prepareDocumentFonts, probeGlyphOutlineCommands, readFontReadiness, reflowPathTextGlyphs, registerDocumentFonts, removeStyleFromRange, replaceDocumentFonts, resolveFontReadiness, runsAfterTyping, sampleTextPath, selectionHasStyle, setHarfBuzzSubsetLocator, sfntFamilyNames, sfntFont, sfntFontName, shownCharacters, shownText, shownTextSlice, shownTextStyle, standardFace, standardFaces, styleRunsWithHyperlink, textCaseSegments, textFaceName, textFallbackScriptsWithoutCoverage, textFontFace, textHasFallbackScript, textNeededFallbackScripts, textNeedsFallbackScript, textPathStartArc, textPathStartDistance, textStyleName, toggleBoldInRange, toggleDecorationInRange, toggleItalicInRange, transformTextCase, webFontSubsetsForText };
37
+ import { layerTextStyleChanges, mixedTextStyleKeys, shownTextStyle } from "./character-style.js";
38
+ export { ARABIC_CHARACTER, ARABIC_LOCAL_FALLBACK_FAMILIES, ARABIC_REMOTE_FALLBACK_FAMILIES, BrowserFaceDescriptors, type BundledFontLocator, CJK_CHARACTER, CJK_FALLBACK_CHARACTER, DEFAULT_WEB_FONT_PROVIDER_SETTINGS, DEVANAGARI_CHARACTER, DocumentFont, DocumentFontEntry, DocumentFontInput, DownloadedFontCache, FONT_FACE_BATCH_DELAY_MS, FaceWeight, FamilyFace, FontAxis, FontCandidateSource, FontFaceBatch, FontFaceBatchOptions, FontFaceReadiness, FontFaceRef, FontFaceReference, FontFallbackManifestEntry, FontFallbackScript, FontFamilyOption, FontFamilySource, FontInfo, FontLoadedSource, FontManager, FontProviderLease, FontReadiness, FontReadinessStatus, FontReplacement, FontReplacementCounts, FontResolutionCandidate, FontResolutionDemand, FontResolutionEvent, FontResolutionListener, FontResolutionLoader, FontResolutionSettled, FontResolutionSnapshot, FontResolutionState, FontResolver, FontUnavailableReason, type GlyphOutlineProbe, GraphFontRequirements, HANGUL_CHARACTER, HAN_CHARACTER, HEBREW_CHARACTER, type HarfBuzzSubsetLocator, type HostFontFamily, HostFontLoader, HyperlinkRunOptions, HyperlinkSpan, InsertStyleSource, KANA_CHARACTER, LETTER_FALLBACK_SCRIPTS, LetterFallbackScript, LocalFontAccessState, MissingGlyphOccurrence, MissingGraphFontScriptsOptions, NamedInstance, NamedLocalFont, ObservedShapedLine, type OutlineCommand, PathPoint, PathTextCaret, PathTextLayout, PathTextLineMetrics, ResolvedWebFont, SampledPath, THAI_CHARACTER, TextCaret, TextCaseSegment, TextEditor, TextEditorState, TextFace, UnsupportedFontFormatError, WEB_FONT_PROVIDER_IDS, WEB_FONT_PROVIDER_LABELS, WebFontFetch, WebFontProviderId, WebFontResolver, adjustRunsForDelete, applyStyleToRange, browserFaceDescriptors, calibratePathTextLayout, chooseLocalFontMatch, cjkFallbackScriptForLanguage, cjkLocalFallbackFamilies, collectGraphFontKeys, collectGraphFontRequirements, collectNamedNodeFontFaces, collectNodeFontFaces, createFontFaceBatch, documentFontData, documentFontsOf, faceForStyle, faceStyleName, facesFromStyles, fallbackDrawsCharacter, findLocalFont, fitTextPathBoxToGlyphs, fontAxes, fontCoverageDemand, fontFaceDemand, fontFaceFromFigmaFontName, fontFaceRenderFamily, fontFallbackEntry, fontFallbackManifest, fontFallbackScriptForCharacter, fontFeatureTags, fontManager, fontRemoteCoverageDemand, fontResolver, fontTableView, fontWeightMatchOrder, getStyleAt, getTextPathData, hasFamilyFace, hasNamedInstance, hasTrueTypeOutlines, hyperlinkInRange, hyperlinkSpanAt, hyperlinkSpans, insertRunsWithStyle, insertedStyleAt, isDocumentFontFileName, isOpenableLinkURL, isTraditionalOnlyHan, isVariableFont, isWOFF2, layerTextStyleChanges, layoutPathTextFromAdvances, leaseFontProvider, listDocumentFonts, mergeArchiveFonts, missingGlyphCharacters, missingGlyphOccurrences, missingGlyphScripts, missingGlyphsByScript, missingGraphFontScripts, mixedTextStyleKeys, namedInstanceVariations, namedInstances, nearestArcPoint, nearestFamilyFace, normalizeLinkURL, normalizedCoverageText, pathTextCaret, pathTextIndexAt, pathTextSelectionQuads, pointAtArc, prepareDocumentFonts, probeGlyphOutlineCommands, readFontReadiness, reflowPathTextGlyphs, registerDocumentFonts, removeStyleFromRange, replaceDocumentFonts, resolveFontReadiness, runsAfterTyping, sampleTextPath, selectionHasStyle, setHarfBuzzSubsetLocator, sfntFamilyNames, sfntFont, sfntFontName, shownCharacters, shownText, shownTextSlice, shownTextStyle, standardFace, standardFaces, styleRunsWithHyperlink, textCaseSegments, textFaceName, textFallbackScriptsWithoutCoverage, textFontFace, textHasFallbackScript, textNeededFallbackScripts, textNeedsFallbackScript, textPathStartArc, textPathStartDistance, textStyleName, toggleBoldInRange, toggleDecorationInRange, toggleItalicInRange, transformTextCase, webFontSubsetsForText };
@@ -1,4 +1,5 @@
1
1
  import { ARABIC_CHARACTER, ARABIC_LOCAL_FALLBACK_FAMILIES, ARABIC_REMOTE_FALLBACK_FAMILIES, CJK_CHARACTER, CJK_FALLBACK_CHARACTER, DEVANAGARI_CHARACTER, HANGUL_CHARACTER, HAN_CHARACTER, HEBREW_CHARACTER, KANA_CHARACTER, LETTER_FALLBACK_SCRIPTS, THAI_CHARACTER, cjkFallbackScriptForLanguage, cjkLocalFallbackFamilies, fallbackDrawsCharacter, fontFallbackEntry, fontFallbackManifest, fontFallbackScriptForCharacter, isTraditionalOnlyHan } from "./fallbacks.js";
2
+ import { FONT_FACE_BATCH_DELAY_MS, createFontFaceBatch } from "./font/batch.js";
2
3
  import { fontAxes, fontTableView, hasNamedInstance, hasTrueTypeOutlines, isVariableFont, namedInstanceVariations, namedInstances, sfntFamilyNames, sfntFontName } from "./font/variation.js";
3
4
  import { browserFaceDescriptors, facesFromStyles, fontFaceFromFigmaFontName, fontFaceRenderFamily, hasFamilyFace, nearestFamilyFace, standardFace, standardFaces } from "./font/faces.js";
4
5
  import { fontFeatureTags } from "./font/features.js";
@@ -19,7 +20,7 @@ import { getTextPathData } from "./path/index.js";
19
20
  import { FontResolver } from "./resolver/resolver.js";
20
21
  import { missingGlyphCharacters, missingGlyphOccurrences, missingGlyphScripts, missingGlyphsByScript } from "./resolver/coverage.js";
21
22
  import { fontCoverageDemand, fontFaceDemand, fontRemoteCoverageDemand, fontResolver } from "./resolver/index.js";
22
- import { layerTextStyleChanges, shownTextStyle } from "./character-style.js";
23
+ import { layerTextStyleChanges, mixedTextStyleKeys, shownTextStyle } from "./character-style.js";
23
24
  import { collectNamedNodeFontFaces, faceForStyle, faceStyleName, textFaceName, textStyleName } from "./font/names.js";
24
25
  import { leaseFontProvider } from "./font/provider.js";
25
26
  import { textFallbackScriptsWithoutCoverage, textHasFallbackScript, textNeededFallbackScripts, textNeedsFallbackScript } from "./coverage.js";
@@ -31,4 +32,4 @@ import { TextEditor } from "./editor.js";
31
32
  import { adjustRunsForDelete, applyStyleToRange, getStyleAt, insertRunsWithStyle, insertedStyleAt, removeStyleFromRange, runsAfterTyping, selectionHasStyle, toggleBoldInRange, toggleDecorationInRange, toggleItalicInRange } from "./style-runs.js";
32
33
  import { listDocumentFonts, replaceDocumentFonts } from "./replace-fonts.js";
33
34
  import { hyperlinkInRange, hyperlinkSpanAt, hyperlinkSpans, isOpenableLinkURL, normalizeLinkURL, styleRunsWithHyperlink } from "./hyperlink.js";
34
- export { ARABIC_CHARACTER, ARABIC_LOCAL_FALLBACK_FAMILIES, ARABIC_REMOTE_FALLBACK_FAMILIES, CJK_CHARACTER, CJK_FALLBACK_CHARACTER, DEFAULT_WEB_FONT_PROVIDER_SETTINGS, DEVANAGARI_CHARACTER, FontManager, FontResolver, HANGUL_CHARACTER, HAN_CHARACTER, HEBREW_CHARACTER, KANA_CHARACTER, LETTER_FALLBACK_SCRIPTS, THAI_CHARACTER, TextEditor, UnsupportedFontFormatError, WEB_FONT_PROVIDER_IDS, WEB_FONT_PROVIDER_LABELS, WebFontResolver, adjustRunsForDelete, applyStyleToRange, browserFaceDescriptors, calibratePathTextLayout, chooseLocalFontMatch, cjkFallbackScriptForLanguage, cjkLocalFallbackFamilies, collectGraphFontKeys, collectGraphFontRequirements, collectNamedNodeFontFaces, collectNodeFontFaces, documentFontData, documentFontsOf, faceForStyle, faceStyleName, facesFromStyles, fallbackDrawsCharacter, findLocalFont, fitTextPathBoxToGlyphs, fontAxes, fontCoverageDemand, fontFaceDemand, fontFaceFromFigmaFontName, fontFaceRenderFamily, fontFallbackEntry, fontFallbackManifest, fontFallbackScriptForCharacter, fontFeatureTags, fontManager, fontRemoteCoverageDemand, fontResolver, fontTableView, fontWeightMatchOrder, getStyleAt, getTextPathData, hasFamilyFace, hasNamedInstance, hasTrueTypeOutlines, hyperlinkInRange, hyperlinkSpanAt, hyperlinkSpans, insertRunsWithStyle, insertedStyleAt, isDocumentFontFileName, isOpenableLinkURL, isTraditionalOnlyHan, isVariableFont, isWOFF2, layerTextStyleChanges, layoutPathTextFromAdvances, leaseFontProvider, listDocumentFonts, mergeArchiveFonts, missingGlyphCharacters, missingGlyphOccurrences, missingGlyphScripts, missingGlyphsByScript, missingGraphFontScripts, namedInstanceVariations, namedInstances, nearestArcPoint, nearestFamilyFace, normalizeLinkURL, normalizedCoverageText, pathTextCaret, pathTextIndexAt, pathTextSelectionQuads, pointAtArc, prepareDocumentFonts, probeGlyphOutlineCommands, readFontReadiness, reflowPathTextGlyphs, registerDocumentFonts, removeStyleFromRange, replaceDocumentFonts, resolveFontReadiness, runsAfterTyping, sampleTextPath, selectionHasStyle, setHarfBuzzSubsetLocator, sfntFamilyNames, sfntFont, sfntFontName, shownCharacters, shownText, shownTextSlice, shownTextStyle, standardFace, standardFaces, styleRunsWithHyperlink, textCaseSegments, textFaceName, textFallbackScriptsWithoutCoverage, textFontFace, textHasFallbackScript, textNeededFallbackScripts, textNeedsFallbackScript, textPathStartArc, textPathStartDistance, textStyleName, toggleBoldInRange, toggleDecorationInRange, toggleItalicInRange, transformTextCase, webFontSubsetsForText };
35
+ export { ARABIC_CHARACTER, ARABIC_LOCAL_FALLBACK_FAMILIES, ARABIC_REMOTE_FALLBACK_FAMILIES, CJK_CHARACTER, CJK_FALLBACK_CHARACTER, DEFAULT_WEB_FONT_PROVIDER_SETTINGS, DEVANAGARI_CHARACTER, FONT_FACE_BATCH_DELAY_MS, FontManager, FontResolver, HANGUL_CHARACTER, HAN_CHARACTER, HEBREW_CHARACTER, KANA_CHARACTER, LETTER_FALLBACK_SCRIPTS, THAI_CHARACTER, TextEditor, UnsupportedFontFormatError, WEB_FONT_PROVIDER_IDS, WEB_FONT_PROVIDER_LABELS, WebFontResolver, adjustRunsForDelete, applyStyleToRange, browserFaceDescriptors, calibratePathTextLayout, chooseLocalFontMatch, cjkFallbackScriptForLanguage, cjkLocalFallbackFamilies, collectGraphFontKeys, collectGraphFontRequirements, collectNamedNodeFontFaces, collectNodeFontFaces, createFontFaceBatch, documentFontData, documentFontsOf, faceForStyle, faceStyleName, facesFromStyles, fallbackDrawsCharacter, findLocalFont, fitTextPathBoxToGlyphs, fontAxes, fontCoverageDemand, fontFaceDemand, fontFaceFromFigmaFontName, fontFaceRenderFamily, fontFallbackEntry, fontFallbackManifest, fontFallbackScriptForCharacter, fontFeatureTags, fontManager, fontRemoteCoverageDemand, fontResolver, fontTableView, fontWeightMatchOrder, getStyleAt, getTextPathData, hasFamilyFace, hasNamedInstance, hasTrueTypeOutlines, hyperlinkInRange, hyperlinkSpanAt, hyperlinkSpans, insertRunsWithStyle, insertedStyleAt, isDocumentFontFileName, isOpenableLinkURL, isTraditionalOnlyHan, isVariableFont, isWOFF2, layerTextStyleChanges, layoutPathTextFromAdvances, leaseFontProvider, listDocumentFonts, mergeArchiveFonts, missingGlyphCharacters, missingGlyphOccurrences, missingGlyphScripts, missingGlyphsByScript, missingGraphFontScripts, mixedTextStyleKeys, namedInstanceVariations, namedInstances, nearestArcPoint, nearestFamilyFace, normalizeLinkURL, normalizedCoverageText, pathTextCaret, pathTextIndexAt, pathTextSelectionQuads, pointAtArc, prepareDocumentFonts, probeGlyphOutlineCommands, readFontReadiness, reflowPathTextGlyphs, registerDocumentFonts, removeStyleFromRange, replaceDocumentFonts, resolveFontReadiness, runsAfterTyping, sampleTextPath, selectionHasStyle, setHarfBuzzSubsetLocator, sfntFamilyNames, sfntFont, sfntFontName, shownCharacters, shownText, shownTextSlice, shownTextStyle, standardFace, standardFaces, styleRunsWithHyperlink, textCaseSegments, textFaceName, textFallbackScriptsWithoutCoverage, textFontFace, textHasFallbackScript, textNeededFallbackScripts, textNeedsFallbackScript, textPathStartArc, textPathStartDistance, textStyleName, toggleBoldInRange, toggleDecorationInRange, toggleItalicInRange, transformTextCase, webFontSubsetsForText };
@@ -1,5 +1,5 @@
1
- import { defineTool, nodeSummary, positionInputs, toolNumber } from "../schema.js";
2
1
  import { prepareSlotInsertion } from "../../figma-api/slots.js";
2
+ import { defineTool, nodeSummary, positionInputs, toolNumber } from "../schema.js";
3
3
  import * as v from "valibot";
4
4
  //#region src/tools/create/basic.ts
5
5
  const createShape = defineTool({
@@ -67,7 +67,7 @@ const createPage = defineTool({
67
67
  });
68
68
  const createSlice = defineTool({
69
69
  name: "create_slice",
70
- description: "Create a slice (export region) on the canvas.",
70
+ description: "Create a slice layer (export region) on the canvas.",
71
71
  execution: {
72
72
  kind: "sync",
73
73
  mutation: "document"
@@ -82,12 +82,11 @@ const createSlice = defineTool({
82
82
  execute: (figma, args) => {
83
83
  const parent = args.parent_id ? figma.getNodeById(args.parent_id) : null;
84
84
  if (parent) prepareSlotInsertion(figma.graph, parent.id, "create_slice");
85
- const node = figma.createFrame();
85
+ const node = figma.createSlice();
86
86
  node.x = args.x;
87
87
  node.y = args.y;
88
88
  node.resize(args.width, args.height);
89
89
  node.name = args.name ?? "Slice";
90
- node.fills = [];
91
90
  if (parent) parent.appendChild(node);
92
91
  return nodeSummary(node);
93
92
  }
@@ -1 +1 @@
1
- {"version":3,"file":"basic.js","names":[],"sources":["../../../src/tools/create/basic.ts"],"sourcesContent":["import * as v from 'valibot'\n\nimport type { FigmaNodeProxy } from '#core/figma-api'\nimport { prepareSlotInsertion } from '#core/figma-api/slots'\nimport { toolNumber, positionInputs, defineTool, nodeSummary } from '#core/tools/schema'\n\nexport const createShape = defineTool({\n name: 'create_shape',\n\n description:\n 'Create a shape on the canvas. Use FRAME for containers/cards, RECTANGLE for solid blocks, ELLIPSE for circles, TEXT for labels, LINE for rules and dividers, STAR for starbursts and badges, POLYGON for triangles and regular polygons, and SECTION for page sections. Use create_vector with an SVG path for arbitrary shapes.',\n execution: { kind: 'sync', mutation: 'document' },\n input: v.strictObject({\n type: v.pipe(\n v.picklist(['FRAME', 'RECTANGLE', 'ELLIPSE', 'TEXT', 'LINE', 'STAR', 'POLYGON', 'SECTION']),\n v.description('Node type')\n ),\n ...positionInputs,\n width: toolNumber(v.pipe(v.number(), v.minValue(1), v.description('Width in pixels'))),\n height: toolNumber(v.pipe(v.number(), v.minValue(1), v.description('Height in pixels'))),\n name: v.optional(v.pipe(v.string(), v.description('Node name shown in layers panel'))),\n parent_id: v.optional(v.pipe(v.string(), v.description('Parent node ID to nest inside')))\n }),\n execute: (figma, args) => {\n const parentId = args.parent_id\n const parent = parentId ? figma.getNodeById(parentId) : null\n // Refuse before creating, so a refused parent leaves no layer behind on the page.\n if (parent) prepareSlotInsertion(figma.graph, parent.id, 'create_shape')\n const createMap: Record<string, () => FigmaNodeProxy> = {\n FRAME: () => figma.createFrame(),\n RECTANGLE: () => figma.createRectangle(),\n ELLIPSE: () => figma.createEllipse(),\n TEXT: () => figma.createText(),\n LINE: () => figma.createLine(),\n STAR: () => figma.createStar(),\n POLYGON: () => figma.createPolygon(),\n SECTION: () => figma.createSection()\n }\n const node = createMap[args.type]()\n node.x = args.x\n node.y = args.y\n node.resize(args.width, args.height)\n if (args.name) node.name = args.name\n if (parent) parent.appendChild(node)\n return nodeSummary(node)\n }\n})\n\nexport const createPage = defineTool({\n name: 'create_page',\n\n description: 'Create a new page.',\n execution: { kind: 'sync', mutation: 'document' },\n input: v.strictObject({\n name: v.pipe(v.string(), v.description('Page name'))\n }),\n execute: (figma, { name }) => {\n const page = figma.createPage()\n page.name = name\n return { id: page.id, name }\n }\n})\n\nexport const createSlice = defineTool({\n name: 'create_slice',\n\n description: 'Create a slice (export region) on the canvas.',\n execution: { kind: 'sync', mutation: 'document' },\n input: v.strictObject({\n ...positionInputs,\n width: toolNumber(v.pipe(v.number(), v.minValue(1), v.description('Width'))),\n height: toolNumber(v.pipe(v.number(), v.minValue(1), v.description('Height'))),\n name: v.optional(v.pipe(v.string(), v.description('Slice name'))),\n parent_id: v.optional(v.pipe(v.string(), v.description('Parent node ID')))\n }),\n execute: (figma, args) => {\n const parent = args.parent_id ? figma.getNodeById(args.parent_id) : null\n if (parent) prepareSlotInsertion(figma.graph, parent.id, 'create_slice')\n const node = figma.createFrame()\n node.x = args.x\n node.y = args.y\n node.resize(args.width, args.height)\n node.name = args.name ?? 'Slice'\n node.fills = []\n if (parent) parent.appendChild(node)\n return nodeSummary(node)\n }\n})\n"],"mappings":";;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AI;EACnC,OAAO,YAAY,IAAI;CACzB;AACF,CAAC"}
1
+ {"version":3,"file":"basic.js","names":[],"sources":["../../../src/tools/create/basic.ts"],"sourcesContent":["import * as v from 'valibot'\n\nimport type { FigmaNodeProxy } from '#core/figma-api'\nimport { prepareSlotInsertion } from '#core/figma-api/slots'\nimport { toolNumber, positionInputs, defineTool, nodeSummary } from '#core/tools/schema'\n\nexport const createShape = defineTool({\n name: 'create_shape',\n\n description:\n 'Create a shape on the canvas. Use FRAME for containers/cards, RECTANGLE for solid blocks, ELLIPSE for circles, TEXT for labels, LINE for rules and dividers, STAR for starbursts and badges, POLYGON for triangles and regular polygons, and SECTION for page sections. Use create_vector with an SVG path for arbitrary shapes.',\n execution: { kind: 'sync', mutation: 'document' },\n input: v.strictObject({\n type: v.pipe(\n v.picklist(['FRAME', 'RECTANGLE', 'ELLIPSE', 'TEXT', 'LINE', 'STAR', 'POLYGON', 'SECTION']),\n v.description('Node type')\n ),\n ...positionInputs,\n width: toolNumber(v.pipe(v.number(), v.minValue(1), v.description('Width in pixels'))),\n height: toolNumber(v.pipe(v.number(), v.minValue(1), v.description('Height in pixels'))),\n name: v.optional(v.pipe(v.string(), v.description('Node name shown in layers panel'))),\n parent_id: v.optional(v.pipe(v.string(), v.description('Parent node ID to nest inside')))\n }),\n execute: (figma, args) => {\n const parentId = args.parent_id\n const parent = parentId ? figma.getNodeById(parentId) : null\n // Refuse before creating, so a refused parent leaves no layer behind on the page.\n if (parent) prepareSlotInsertion(figma.graph, parent.id, 'create_shape')\n const createMap: Record<string, () => FigmaNodeProxy> = {\n FRAME: () => figma.createFrame(),\n RECTANGLE: () => figma.createRectangle(),\n ELLIPSE: () => figma.createEllipse(),\n TEXT: () => figma.createText(),\n LINE: () => figma.createLine(),\n STAR: () => figma.createStar(),\n POLYGON: () => figma.createPolygon(),\n SECTION: () => figma.createSection()\n }\n const node = createMap[args.type]()\n node.x = args.x\n node.y = args.y\n node.resize(args.width, args.height)\n if (args.name) node.name = args.name\n if (parent) parent.appendChild(node)\n return nodeSummary(node)\n }\n})\n\nexport const createPage = defineTool({\n name: 'create_page',\n\n description: 'Create a new page.',\n execution: { kind: 'sync', mutation: 'document' },\n input: v.strictObject({\n name: v.pipe(v.string(), v.description('Page name'))\n }),\n execute: (figma, { name }) => {\n const page = figma.createPage()\n page.name = name\n return { id: page.id, name }\n }\n})\n\nexport const createSlice = defineTool({\n name: 'create_slice',\n\n description: 'Create a slice layer (export region) on the canvas.',\n execution: { kind: 'sync', mutation: 'document' },\n input: v.strictObject({\n ...positionInputs,\n width: toolNumber(v.pipe(v.number(), v.minValue(1), v.description('Width'))),\n height: toolNumber(v.pipe(v.number(), v.minValue(1), v.description('Height'))),\n name: v.optional(v.pipe(v.string(), v.description('Slice name'))),\n parent_id: v.optional(v.pipe(v.string(), v.description('Parent node ID')))\n }),\n execute: (figma, args) => {\n const parent = args.parent_id ? figma.getNodeById(args.parent_id) : null\n if (parent) prepareSlotInsertion(figma.graph, parent.id, 'create_slice')\n const node = figma.createSlice()\n node.x = args.x\n node.y = args.y\n node.resize(args.width, args.height)\n node.name = args.name ?? 'Slice'\n if (parent) parent.appendChild(node)\n return nodeSummary(node)\n }\n})\n"],"mappings":";;;;AAMA,MAAa,cAAc,WAAW;CACpC,MAAM;CAEN,aACE;CACF,WAAW;EAAE,MAAM;EAAQ,UAAU;CAAW;CAChD,OAAO,EAAE,aAAa;EACpB,MAAM,EAAE,KACN,EAAE,SAAS;GAAC;GAAS;GAAa;GAAW;GAAQ;GAAQ;GAAQ;GAAW;EAAS,CAAC,GAC1F,EAAE,YAAY,WAAW,CAC3B;EACA,GAAG;EACH,OAAO,WAAW,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,SAAS,CAAC,GAAG,EAAE,YAAY,iBAAiB,CAAC,CAAC;EACrF,QAAQ,WAAW,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,SAAS,CAAC,GAAG,EAAE,YAAY,kBAAkB,CAAC,CAAC;EACvF,MAAM,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EACpB,GAAG;EACH,OAAO,WAAW,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,SAAS,CAAC,GAAG,EAAE,YAAY,OAAO,CAAC,CAAC;EAC3E,QAAQ,WAAW,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,SAAS,CAAC,GAAG,EAAE,YAAY,QAAQ,CAAC,CAAC;EAC7E,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,YAAY,YAAY,CAAC,CAAC;EAChE,WAAW,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,YAAY,gBAAgB,CAAC,CAAC;CAC3E,CAAC;CACD,UAAU,OAAO,SAAS;EACxB,MAAM,SAAS,KAAK,YAAY,MAAM,YAAY,KAAK,SAAS,IAAI;EACpE,IAAI,QAAQ,qBAAqB,MAAM,OAAO,OAAO,IAAI,cAAc;EACvE,MAAM,OAAO,MAAM,YAAY;EAC/B,KAAK,IAAI,KAAK;EACd,KAAK,IAAI,KAAK;EACd,KAAK,OAAO,KAAK,OAAO,KAAK,MAAM;EACnC,KAAK,OAAO,KAAK,QAAQ;EACzB,IAAI,QAAQ,OAAO,YAAY,IAAI;EACnC,OAAO,YAAY,IAAI;CACzB;AACF,CAAC"}
@@ -1,5 +1,5 @@
1
- import { defineTool, toolFailure, toolNumber } from "../schema.js";
2
1
  import { mergeSlotSettings } from "../../figma-api/slots.js";
2
+ import { defineTool, toolFailure, toolNumber } from "../schema.js";
3
3
  import { PairdrawAPI } from "../../pairdraw-api/index.js";
4
4
  import { slotOwner, slotPropertyId, updateSlotProperty } from "@pairdraw/scene-graph/slots";
5
5
  import { behaviourSpecSchema } from "@pairdraw/scene-graph/behaviours";
@@ -0,0 +1,6 @@
1
+ import { ToolDef } from "../schema.js";
2
+ //#region src/tools/create/code.d.ts
3
+ declare const importCode: ToolDef;
4
+ //#endregion
5
+ export { importCode };
6
+ //# sourceMappingURL=code.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code.d.ts","names":[],"sources":["../../../src/tools/create/code.ts"],"mappings":";;cAgCa,YAAA"}
@@ -0,0 +1,68 @@
1
+ import { findPageId } from "../../io/subgraph.js";
2
+ import { prepareSlotInsertion } from "../../figma-api/slots.js";
3
+ import { readCodeDocument } from "../../io/formats/code/read.js";
4
+ import { bindCodeTokens, codeLayerNodes } from "../../io/formats/code/tokens.js";
5
+ import { defineTool, toolFailure } from "../schema.js";
6
+ import { insertionInput } from "./inputs.js";
7
+ import { insertionParent, placeGraphLayers } from "./place.js";
8
+ import * as v from "valibot";
9
+ import { tokenStylesheet } from "@pairdraw/dom-css/export";
10
+ //#region src/tools/create/code.ts
11
+ /** The layers a call's code draws, with the document's own tokens as its theme. */
12
+ async function readImportCode(graph, args) {
13
+ const tailwind = args.tailwind !== false;
14
+ const tokens = tailwind ? await tokenStylesheet(graph, { format: "tailwind" }) : void 0;
15
+ return readCodeDocument(args.code, {
16
+ css: args.css,
17
+ tokensCSS: tokens?.css,
18
+ kind: args.language === "auto" ? void 0 : args.language,
19
+ tailwind
20
+ });
21
+ }
22
+ const importCode = defineTool({
23
+ name: "import_code",
24
+ description: "Import React or JSX source with Tailwind classes or inline styles, or HTML with CSS, as editable layers. Nothing in the pasted code runs: components it does not define become named frames and expressions it cannot know become placeholder text. css adds a stylesheet (a project globals.css); without x and y the layers go to the right of what the parent already holds. Returns the ids of the top-level layers and what the import could not keep.",
25
+ execution: {
26
+ kind: "async",
27
+ mutation: "document"
28
+ },
29
+ content: "imported",
30
+ input: v.strictObject({
31
+ code: v.pipe(v.string(), v.nonEmpty(), v.description("JSX, TSX, or HTML source: a component, a fragment, or a whole document")),
32
+ css: v.optional(v.pipe(v.string(), v.description("Extra CSS applied after the code’s own styles"))),
33
+ language: v.optional(v.pipe(v.picklist([
34
+ "auto",
35
+ "jsx",
36
+ "html"
37
+ ]), v.description("How to read the code; auto detects it (default)"))),
38
+ tailwind: v.optional(v.pipe(v.boolean(), v.description("Compile Tailwind classes; true unless the paste carries no Tailwind"))),
39
+ ...insertionInput("X of the imported content", "Y of the imported content")
40
+ }),
41
+ execute: async (figma, args) => {
42
+ const { graph, parentId } = insertionParent(figma, args.parent_id);
43
+ prepareSlotInsertion(graph, parentId, "import_code");
44
+ const parent = graph.getNode(parentId);
45
+ if (!parent || parent.type !== "CANVAS" && !findPageId(graph, parentId)) return { error: `Parent "${parentId}" not found` };
46
+ let source;
47
+ let report;
48
+ try {
49
+ const read = await readImportCode(graph, args);
50
+ source = read.graph;
51
+ report = read.report;
52
+ } catch (error) {
53
+ return toolFailure(error);
54
+ }
55
+ const placed = placeGraphLayers(graph, parentId, source, args, (ids) => {
56
+ bindCodeTokens(codeLayerNodes(graph, ids), graph, report);
57
+ });
58
+ if (!placed) return { error: "The code draws no layers" };
59
+ return {
60
+ ...placed,
61
+ report
62
+ };
63
+ }
64
+ });
65
+ //#endregion
66
+ export { importCode };
67
+
68
+ //# sourceMappingURL=code.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code.js","names":[],"sources":["../../../src/tools/create/code.ts"],"sourcesContent":["import * as v from 'valibot'\n\nimport { tokenStylesheet } from '@pairdraw/dom-css/export'\nimport type { SceneGraph } from '@pairdraw/scene-graph'\n\nimport { prepareSlotInsertion } from '#core/figma-api/slots'\nimport { bindCodeTokens, codeLayerNodes, readCodeDocument } from '#core/io/formats/code'\nimport { findPageId } from '#core/io/subgraph'\nimport { defineTool, toolFailure } from '#core/tools/schema'\n\nimport { insertionInput } from './inputs'\nimport { insertionParent, placeGraphLayers } from './place'\n\ninterface ImportCodeArgs {\n code: string\n css?: string\n language?: 'auto' | 'jsx' | 'html'\n tailwind?: boolean\n}\n\n/** The layers a call's code draws, with the document's own tokens as its theme. */\nasync function readImportCode(graph: SceneGraph, args: ImportCodeArgs) {\n const tailwind = args.tailwind !== false\n const tokens = tailwind ? await tokenStylesheet(graph, { format: 'tailwind' }) : undefined\n return readCodeDocument(args.code, {\n css: args.css,\n tokensCSS: tokens?.css,\n kind: args.language === 'auto' ? undefined : args.language,\n tailwind\n })\n}\n\nexport const importCode = defineTool({\n name: 'import_code',\n description:\n 'Import React or JSX source with Tailwind classes or inline styles, or HTML with CSS, as editable layers. Nothing in the pasted code runs: components it does not define become named frames and expressions it cannot know become placeholder text. css adds a stylesheet (a project globals.css); without x and y the layers go to the right of what the parent already holds. Returns the ids of the top-level layers and what the import could not keep.',\n execution: { kind: 'async', mutation: 'document' },\n content: 'imported',\n input: v.strictObject({\n code: v.pipe(\n v.string(),\n v.nonEmpty(),\n v.description('JSX, TSX, or HTML source: a component, a fragment, or a whole document')\n ),\n css: v.optional(\n v.pipe(v.string(), v.description('Extra CSS applied after the code’s own styles'))\n ),\n language: v.optional(\n v.pipe(\n v.picklist(['auto', 'jsx', 'html']),\n v.description('How to read the code; auto detects it (default)')\n )\n ),\n tailwind: v.optional(\n v.pipe(\n v.boolean(),\n v.description('Compile Tailwind classes; true unless the paste carries no Tailwind')\n )\n ),\n ...insertionInput('X of the imported content', 'Y of the imported content')\n }),\n execute: async (figma, args) => {\n const { graph, parentId } = insertionParent(figma, args.parent_id)\n prepareSlotInsertion(graph, parentId, 'import_code')\n const parent = graph.getNode(parentId)\n if (!parent || (parent.type !== 'CANVAS' && !findPageId(graph, parentId))) {\n return { error: `Parent \"${parentId}\" not found` }\n }\n let source: SceneGraph\n let report: Awaited<ReturnType<typeof readImportCode>>['report']\n try {\n const read = await readImportCode(graph, args)\n source = read.graph\n report = read.report\n } catch (error) {\n return toolFailure(error)\n }\n const placed = placeGraphLayers(graph, parentId, source, args, (ids) => {\n // Bound after the transfer: the layers now hold the document's own variable IDs.\n bindCodeTokens(codeLayerNodes(graph, ids), graph, report)\n })\n if (!placed) return { error: 'The code draws no layers' }\n return { ...placed, report }\n }\n})\n"],"mappings":";;;;;;;;;;;AAqBA,eAAe,eAAe,OAAmB,MAAsB;CACrE,MAAM,WAAW,KAAK,aAAa;CACnC,MAAM,SAAS,WAAW,MAAM,gBAAgB,OAAO,EAAE,QAAQ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AC1D,CAAC;EACD,IAAI,CAAC,QAAQ,OAAO,EAAE,OAAO,2BAA2B;EACxD,OAAO;GAAE,GAAG;GAAQ;EAAO;CAC7B;AACF,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"html.d.ts","names":[],"sources":["../../../src/tools/create/html.ts"],"mappings":";;cAca,YAAA"}
1
+ {"version":3,"file":"html.d.ts","names":[],"sources":["../../../src/tools/create/html.ts"],"mappings":";;cAaa,YAAA"}