@moondraft/import 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (323) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/LICENSE +34 -0
  3. package/README.md +36 -2
  4. package/SOURCE.md +169 -0
  5. package/dist/adapter/convert.d.ts +122 -0
  6. package/dist/adapter/convert.js +2302 -0
  7. package/dist/adapter/figma.d.ts +9 -0
  8. package/dist/adapter/figma.js +30 -0
  9. package/dist/adapter/file-components.d.ts +14 -0
  10. package/dist/adapter/file-components.js +262 -0
  11. package/dist/adapter/file-resources.d.ts +29 -0
  12. package/dist/adapter/file-resources.js +562 -0
  13. package/dist/adapter/index.d.ts +6 -0
  14. package/dist/adapter/index.js +9 -0
  15. package/dist/adapter/link.d.ts +45 -0
  16. package/dist/adapter/link.js +688 -0
  17. package/dist/adapter/payload.d.ts +31 -0
  18. package/dist/adapter/payload.js +78 -0
  19. package/dist/adapter/shapes.d.ts +31 -0
  20. package/dist/adapter/shapes.js +75 -0
  21. package/dist/adapter/variables.d.ts +44 -0
  22. package/dist/adapter/variables.js +103 -0
  23. package/dist/figma-file.d.ts +38 -0
  24. package/dist/figma-file.js +97 -0
  25. package/dist/figma-worker.d.ts +11 -0
  26. package/dist/figma-worker.js +12 -0
  27. package/dist/figma.d.ts +26 -0
  28. package/dist/figma.js +96 -0
  29. package/dist/index.d.ts +28 -0
  30. package/dist/index.js +49 -0
  31. package/dist/report.d.ts +15 -0
  32. package/dist/report.js +69 -0
  33. package/dist/svg.d.ts +33 -0
  34. package/dist/svg.js +44 -0
  35. package/dist/syntax.d.ts +8 -0
  36. package/dist/syntax.js +19 -0
  37. package/dist/taco/figma-import/clipboard.d.ts +25 -0
  38. package/dist/taco/figma-import/clipboard.js +87 -0
  39. package/dist/taco/figma-import/clipboardSize.d.ts +31 -0
  40. package/dist/taco/figma-import/clipboardSize.js +107 -0
  41. package/dist/taco/figma-import/container/compression.d.ts +9 -0
  42. package/dist/taco/figma-import/container/compression.js +174 -0
  43. package/dist/taco/figma-import/container/error.d.ts +15 -0
  44. package/dist/taco/figma-import/container/error.js +19 -0
  45. package/dist/taco/figma-import/container/kiwiContainer.d.ts +38 -0
  46. package/dist/taco/figma-import/container/kiwiContainer.js +61 -0
  47. package/dist/taco/figma-import/container/limits.d.ts +22 -0
  48. package/dist/taco/figma-import/container/limits.js +22 -0
  49. package/dist/taco/figma-import/container/zip.d.ts +14 -0
  50. package/dist/taco/figma-import/container/zip.js +154 -0
  51. package/dist/taco/figma-import/figFile.d.ts +34 -0
  52. package/dist/taco/figma-import/figFile.js +91 -0
  53. package/dist/taco/figma-import/figFileDocument.d.ts +25 -0
  54. package/dist/taco/figma-import/figFileDocument.js +100 -0
  55. package/dist/taco/figma-import/import/blobs.d.ts +10 -0
  56. package/dist/taco/figma-import/import/blobs.js +23 -0
  57. package/dist/taco/figma-import/import/carry.d.ts +11 -0
  58. package/dist/taco/figma-import/import/carry.js +33 -0
  59. package/dist/taco/figma-import/import/componentProps.d.ts +84 -0
  60. package/dist/taco/figma-import/import/componentProps.js +313 -0
  61. package/dist/taco/figma-import/import/componentSets.d.ts +83 -0
  62. package/dist/taco/figma-import/import/componentSets.js +647 -0
  63. package/dist/taco/figma-import/import/converters/effects.d.ts +31 -0
  64. package/dist/taco/figma-import/import/converters/effects.js +127 -0
  65. package/dist/taco/figma-import/import/converters/ellipse.d.ts +7 -0
  66. package/dist/taco/figma-import/import/converters/ellipse.js +54 -0
  67. package/dist/taco/figma-import/import/converters/frame.d.ts +21 -0
  68. package/dist/taco/figma-import/import/converters/frame.js +55 -0
  69. package/dist/taco/figma-import/import/converters/gradient.d.ts +72 -0
  70. package/dist/taco/figma-import/import/converters/gradient.js +106 -0
  71. package/dist/taco/figma-import/import/converters/group.d.ts +21 -0
  72. package/dist/taco/figma-import/import/converters/group.js +39 -0
  73. package/dist/taco/figma-import/import/converters/image.d.ts +13 -0
  74. package/dist/taco/figma-import/import/converters/image.js +83 -0
  75. package/dist/taco/figma-import/import/converters/layout.d.ts +34 -0
  76. package/dist/taco/figma-import/import/converters/layout.js +168 -0
  77. package/dist/taco/figma-import/import/converters/line.d.ts +11 -0
  78. package/dist/taco/figma-import/import/converters/line.js +40 -0
  79. package/dist/taco/figma-import/import/converters/rectangle.d.ts +3 -0
  80. package/dist/taco/figma-import/import/converters/rectangle.js +11 -0
  81. package/dist/taco/figma-import/import/converters/section.d.ts +9 -0
  82. package/dist/taco/figma-import/import/converters/section.js +35 -0
  83. package/dist/taco/figma-import/import/converters/shared.d.ts +68 -0
  84. package/dist/taco/figma-import/import/converters/shared.js +362 -0
  85. package/dist/taco/figma-import/import/converters/text.d.ts +41 -0
  86. package/dist/taco/figma-import/import/converters/text.js +576 -0
  87. package/dist/taco/figma-import/import/converters/vector.d.ts +84 -0
  88. package/dist/taco/figma-import/import/converters/vector.js +468 -0
  89. package/dist/taco/figma-import/import/converters/vectorNetwork.d.ts +98 -0
  90. package/dist/taco/figma-import/import/converters/vectorNetwork.js +385 -0
  91. package/dist/taco/figma-import/import/fields.d.ts +15 -0
  92. package/dist/taco/figma-import/import/fields.js +29 -0
  93. package/dist/taco/figma-import/import/instances.d.ts +163 -0
  94. package/dist/taco/figma-import/import/instances.js +1323 -0
  95. package/dist/taco/figma-import/import/nestingCycles.d.ts +86 -0
  96. package/dist/taco/figma-import/import/nestingCycles.js +488 -0
  97. package/dist/taco/figma-import/import/slots.d.ts +56 -0
  98. package/dist/taco/figma-import/import/slots.js +96 -0
  99. package/dist/taco/figma-import/import/styles.d.ts +46 -0
  100. package/dist/taco/figma-import/import/styles.js +42 -0
  101. package/dist/taco/figma-import/import/tree.d.ts +66 -0
  102. package/dist/taco/figma-import/import/tree.js +194 -0
  103. package/dist/taco/figma-import/import/types.d.ts +232 -0
  104. package/dist/taco/figma-import/import/types.js +33 -0
  105. package/dist/taco/figma-import/import/variables.d.ts +136 -0
  106. package/dist/taco/figma-import/import/variables.js +762 -0
  107. package/dist/taco/figma-import/import/variantTrees.d.ts +20 -0
  108. package/dist/taco/figma-import/import/variantTrees.js +480 -0
  109. package/dist/taco/figma-import/import/walk.d.ts +159 -0
  110. package/dist/taco/figma-import/import/walk.js +1297 -0
  111. package/dist/taco/figma-import/index.d.ts +22 -0
  112. package/dist/taco/figma-import/index.js +13 -0
  113. package/dist/taco/figma-import/kiwi/byteReader.d.ts +37 -0
  114. package/dist/taco/figma-import/kiwi/byteReader.js +151 -0
  115. package/dist/taco/figma-import/kiwi/error.d.ts +14 -0
  116. package/dist/taco/figma-import/kiwi/error.js +29 -0
  117. package/dist/taco/figma-import/kiwi/limits.d.ts +18 -0
  118. package/dist/taco/figma-import/kiwi/limits.js +18 -0
  119. package/dist/taco/figma-import/kiwi/message.d.ts +10 -0
  120. package/dist/taco/figma-import/kiwi/message.js +145 -0
  121. package/dist/taco/figma-import/kiwi/schema.d.ts +42 -0
  122. package/dist/taco/figma-import/kiwi/schema.js +206 -0
  123. package/dist/taco/figma-import/kiwi/types.d.ts +46 -0
  124. package/dist/taco/figma-import/kiwi/types.js +18 -0
  125. package/dist/taco/model/agent-hidden-fields.d.ts +20 -0
  126. package/dist/taco/model/agent-hidden-fields.js +29 -0
  127. package/dist/taco/model/asset-users.d.ts +23 -0
  128. package/dist/taco/model/asset-users.js +128 -0
  129. package/dist/taco/model/auto-layout-lines.d.ts +32 -0
  130. package/dist/taco/model/auto-layout-lines.js +70 -0
  131. package/dist/taco/model/codec.d.ts +444 -0
  132. package/dist/taco/model/codec.js +5635 -0
  133. package/dist/taco/model/color.d.ts +11 -0
  134. package/dist/taco/model/color.js +61 -0
  135. package/dist/taco/model/comment-operations.d.ts +102 -0
  136. package/dist/taco/model/comment-operations.js +227 -0
  137. package/dist/taco/model/component-evaluation.d.ts +94 -0
  138. package/dist/taco/model/component-evaluation.js +548 -0
  139. package/dist/taco/model/component-expressions.d.ts +242 -0
  140. package/dist/taco/model/component-expressions.js +1082 -0
  141. package/dist/taco/model/component-properties.d.ts +111 -0
  142. package/dist/taco/model/component-properties.js +339 -0
  143. package/dist/taco/model/component-samples.d.ts +83 -0
  144. package/dist/taco/model/component-samples.js +290 -0
  145. package/dist/taco/model/component-validity.d.ts +85 -0
  146. package/dist/taco/model/component-validity.js +397 -0
  147. package/dist/taco/model/components.d.ts +155 -0
  148. package/dist/taco/model/components.js +505 -0
  149. package/dist/taco/model/connector-ends.d.ts +20 -0
  150. package/dist/taco/model/connector-ends.js +188 -0
  151. package/dist/taco/model/connector-geometry.d.ts +74 -0
  152. package/dist/taco/model/connector-geometry.js +293 -0
  153. package/dist/taco/model/corner-radii.d.ts +26 -0
  154. package/dist/taco/model/corner-radii.js +47 -0
  155. package/dist/taco/model/derivations.d.ts +81 -0
  156. package/dist/taco/model/derivations.js +151 -0
  157. package/dist/taco/model/export-settings.d.ts +53 -0
  158. package/dist/taco/model/export-settings.js +156 -0
  159. package/dist/taco/model/expressions/ast.d.ts +153 -0
  160. package/dist/taco/model/expressions/ast.js +6 -0
  161. package/dist/taco/model/expressions/cache.d.ts +23 -0
  162. package/dist/taco/model/expressions/cache.js +43 -0
  163. package/dist/taco/model/expressions/check.d.ts +72 -0
  164. package/dist/taco/model/expressions/check.js +517 -0
  165. package/dist/taco/model/expressions/completion.d.ts +61 -0
  166. package/dist/taco/model/expressions/completion.js +421 -0
  167. package/dist/taco/model/expressions/evaluate.d.ts +32 -0
  168. package/dist/taco/model/expressions/evaluate.js +519 -0
  169. package/dist/taco/model/expressions/forms.d.ts +84 -0
  170. package/dist/taco/model/expressions/forms.js +200 -0
  171. package/dist/taco/model/expressions/index.d.ts +14 -0
  172. package/dist/taco/model/expressions/index.js +17 -0
  173. package/dist/taco/model/expressions/lexer.d.ts +42 -0
  174. package/dist/taco/model/expressions/lexer.js +213 -0
  175. package/dist/taco/model/expressions/library.d.ts +33 -0
  176. package/dist/taco/model/expressions/library.js +117 -0
  177. package/dist/taco/model/expressions/names.d.ts +43 -0
  178. package/dist/taco/model/expressions/names.js +99 -0
  179. package/dist/taco/model/expressions/parser.d.ts +15 -0
  180. package/dist/taco/model/expressions/parser.js +438 -0
  181. package/dist/taco/model/expressions/rename.d.ts +34 -0
  182. package/dist/taco/model/expressions/rename.js +46 -0
  183. package/dist/taco/model/expressions/source.d.ts +15 -0
  184. package/dist/taco/model/expressions/source.js +161 -0
  185. package/dist/taco/model/expressions/types.d.ts +119 -0
  186. package/dist/taco/model/expressions/types.js +102 -0
  187. package/dist/taco/model/expressions/values.d.ts +97 -0
  188. package/dist/taco/model/expressions/values.js +160 -0
  189. package/dist/taco/model/geometry-limits.d.ts +16 -0
  190. package/dist/taco/model/geometry-limits.js +67 -0
  191. package/dist/taco/model/geometry.d.ts +47 -0
  192. package/dist/taco/model/geometry.js +193 -0
  193. package/dist/taco/model/group-bounds.d.ts +38 -0
  194. package/dist/taco/model/group-bounds.js +144 -0
  195. package/dist/taco/model/id-table.d.ts +37 -0
  196. package/dist/taco/model/id-table.js +80 -0
  197. package/dist/taco/model/index.d.ts +25 -0
  198. package/dist/taco/model/index.js +27 -0
  199. package/dist/taco/model/instance-resolver.d.ts +372 -0
  200. package/dist/taco/model/instance-resolver.js +1748 -0
  201. package/dist/taco/model/layer-syntax.d.ts +340 -0
  202. package/dist/taco/model/layer-syntax.js +3506 -0
  203. package/dist/taco/model/layout/constraints.d.ts +84 -0
  204. package/dist/taco/model/layout/constraints.js +445 -0
  205. package/dist/taco/model/layout/frame-layout.d.ts +46 -0
  206. package/dist/taco/model/layout/frame-layout.js +618 -0
  207. package/dist/taco/model/layout/node-sizing.d.ts +163 -0
  208. package/dist/taco/model/layout/node-sizing.js +486 -0
  209. package/dist/taco/model/legacy-connector-caps.d.ts +15 -0
  210. package/dist/taco/model/legacy-connector-caps.js +70 -0
  211. package/dist/taco/model/linear-call.d.ts +48 -0
  212. package/dist/taco/model/linear-call.js +58 -0
  213. package/dist/taco/model/new-nodes.d.ts +145 -0
  214. package/dist/taco/model/new-nodes.js +277 -0
  215. package/dist/taco/model/node-builder.d.ts +449 -0
  216. package/dist/taco/model/node-builder.js +2294 -0
  217. package/dist/taco/model/node-table-watch.d.ts +36 -0
  218. package/dist/taco/model/node-table-watch.js +63 -0
  219. package/dist/taco/model/node-transform.d.ts +39 -0
  220. package/dist/taco/model/node-transform.js +79 -0
  221. package/dist/taco/model/node-users-index.d.ts +10 -0
  222. package/dist/taco/model/node-users-index.js +82 -0
  223. package/dist/taco/model/operation-references.d.ts +80 -0
  224. package/dist/taco/model/operation-references.js +399 -0
  225. package/dist/taco/model/operations.d.ts +610 -0
  226. package/dist/taco/model/operations.js +2882 -0
  227. package/dist/taco/model/overlay-table.d.ts +71 -0
  228. package/dist/taco/model/overlay-table.js +171 -0
  229. package/dist/taco/model/override-remap.d.ts +69 -0
  230. package/dist/taco/model/override-remap.js +230 -0
  231. package/dist/taco/model/parent-table.d.ts +53 -0
  232. package/dist/taco/model/parent-table.js +193 -0
  233. package/dist/taco/model/problem-collector.d.ts +27 -0
  234. package/dist/taco/model/problem-collector.js +101 -0
  235. package/dist/taco/model/sha256.d.ts +10 -0
  236. package/dist/taco/model/sha256.js +74 -0
  237. package/dist/taco/model/shape-geometry.d.ts +96 -0
  238. package/dist/taco/model/shape-geometry.js +368 -0
  239. package/dist/taco/model/shared-node-table.d.ts +97 -0
  240. package/dist/taco/model/shared-node-table.js +546 -0
  241. package/dist/taco/model/slots.d.ts +113 -0
  242. package/dist/taco/model/slots.js +281 -0
  243. package/dist/taco/model/stroke-settings.d.ts +37 -0
  244. package/dist/taco/model/stroke-settings.js +90 -0
  245. package/dist/taco/model/svg-path-import.d.ts +89 -0
  246. package/dist/taco/model/svg-path-import.js +219 -0
  247. package/dist/taco/model/text-measurement.d.ts +142 -0
  248. package/dist/taco/model/text-measurement.js +846 -0
  249. package/dist/taco/model/text-reads.d.ts +66 -0
  250. package/dist/taco/model/text-reads.js +128 -0
  251. package/dist/taco/model/text-sizer.d.ts +358 -0
  252. package/dist/taco/model/text-sizer.js +996 -0
  253. package/dist/taco/model/theme-users.d.ts +59 -0
  254. package/dist/taco/model/theme-users.js +312 -0
  255. package/dist/taco/model/thumbnail.d.ts +15 -0
  256. package/dist/taco/model/thumbnail.js +34 -0
  257. package/dist/taco/model/types.d.ts +2347 -0
  258. package/dist/taco/model/types.js +366 -0
  259. package/dist/taco/model/unknown-property.d.ts +5 -0
  260. package/dist/taco/model/unknown-property.js +7 -0
  261. package/dist/taco/model/validated-documents.d.ts +22 -0
  262. package/dist/taco/model/validated-documents.js +22 -0
  263. package/dist/taco/model/variable-modes.d.ts +61 -0
  264. package/dist/taco/model/variable-modes.js +438 -0
  265. package/dist/taco/model/variable-references.d.ts +54 -0
  266. package/dist/taco/model/variable-references.js +183 -0
  267. package/dist/taco/model/variables.d.ts +24 -0
  268. package/dist/taco/model/variables.js +151 -0
  269. package/dist/taco/model/vector-network.d.ts +34 -0
  270. package/dist/taco/model/vector-network.js +411 -0
  271. package/dist/taco/svg-import/import-svg.d.ts +36 -0
  272. package/dist/taco/svg-import/import-svg.js +729 -0
  273. package/dist/taco/svg-import/index.d.ts +3 -0
  274. package/dist/taco/svg-import/index.js +3 -0
  275. package/dist/taco/svg-import/limits/limits.d.ts +79 -0
  276. package/dist/taco/svg-import/limits/limits.js +160 -0
  277. package/dist/taco/svg-import/paint/gradients.d.ts +64 -0
  278. package/dist/taco/svg-import/paint/gradients.js +429 -0
  279. package/dist/taco/svg-import/paint/paint.d.ts +32 -0
  280. package/dist/taco/svg-import/paint/paint.js +162 -0
  281. package/dist/taco/svg-import/paths/paths.d.ts +58 -0
  282. package/dist/taco/svg-import/paths/paths.js +205 -0
  283. package/dist/taco/svg-import/public-types.d.ts +279 -0
  284. package/dist/taco/svg-import/public-types.js +56 -0
  285. package/dist/taco/svg-import/report/report.d.ts +44 -0
  286. package/dist/taco/svg-import/report/report.js +79 -0
  287. package/dist/taco/svg-import/reuse/reuse.d.ts +99 -0
  288. package/dist/taco/svg-import/reuse/reuse.js +840 -0
  289. package/dist/taco/svg-import/shapes/shapes.d.ts +35 -0
  290. package/dist/taco/svg-import/shapes/shapes.js +386 -0
  291. package/dist/taco/svg-import/structure/effects.d.ts +26 -0
  292. package/dist/taco/svg-import/structure/effects.js +618 -0
  293. package/dist/taco/svg-import/structure/image.d.ts +24 -0
  294. package/dist/taco/svg-import/structure/image.js +495 -0
  295. package/dist/taco/svg-import/structure/walk.d.ts +85 -0
  296. package/dist/taco/svg-import/structure/walk.js +544 -0
  297. package/dist/taco/svg-import/style/color.d.ts +40 -0
  298. package/dist/taco/svg-import/style/color.js +275 -0
  299. package/dist/taco/svg-import/style/computed.d.ts +214 -0
  300. package/dist/taco/svg-import/style/computed.js +1534 -0
  301. package/dist/taco/svg-import/style/css.d.ts +127 -0
  302. package/dist/taco/svg-import/style/css.js +541 -0
  303. package/dist/taco/svg-import/style/media.d.ts +25 -0
  304. package/dist/taco/svg-import/style/media.js +307 -0
  305. package/dist/taco/svg-import/style/properties.d.ts +43 -0
  306. package/dist/taco/svg-import/style/properties.js +135 -0
  307. package/dist/taco/svg-import/style/selector-reach.d.ts +30 -0
  308. package/dist/taco/svg-import/style/selector-reach.js +169 -0
  309. package/dist/taco/svg-import/style/selector-validity.d.ts +14 -0
  310. package/dist/taco/svg-import/style/selector-validity.js +307 -0
  311. package/dist/taco/svg-import/text/text.d.ts +29 -0
  312. package/dist/taco/svg-import/text/text.js +545 -0
  313. package/dist/taco/svg-import/transform/matrix.d.ts +111 -0
  314. package/dist/taco/svg-import/transform/matrix.js +229 -0
  315. package/dist/taco/svg-import/tree/element-data.d.ts +52 -0
  316. package/dist/taco/svg-import/tree/element-data.js +155 -0
  317. package/dist/taco/svg-import/tree/elements.d.ts +36 -0
  318. package/dist/taco/svg-import/tree/elements.js +121 -0
  319. package/dist/taco/svg-import/units/length.d.ts +43 -0
  320. package/dist/taco/svg-import/units/length.js +125 -0
  321. package/dist/taco/svg-import/units/viewbox.d.ts +35 -0
  322. package/dist/taco/svg-import/units/viewbox.js +77 -0
  323. package/package.json +54 -4
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Which text measurements a piece of work read, by `textLayoutKey`. With
3
+ * the keys a sizer changed since a version (`TextSizer.changedKeysSince`),
4
+ * they let the layout view (`laidOut`) refit, after a text size changes,
5
+ * only the components and instances whose layout read that size.
6
+ *
7
+ * Internal to the model: not exported from the package.
8
+ */
9
+ /** A text measurement's width and height. */
10
+ interface ReadSize {
11
+ readonly width: number;
12
+ readonly height: number;
13
+ }
14
+ /** Whether a collection is running, so a measurement should say which key it read. */
15
+ export declare function collectingTextLayoutReads(): boolean;
16
+ /** Tells the innermost collection that a measurement with these keys was read. */
17
+ export declare function noteTextLayoutReads(keys: ReadonlySet<string>): void;
18
+ /**
19
+ * Tells the innermost collection that the read of `key` it was just told of
20
+ * (`noteTextLayoutRead`) got `size`: the drawn size, or the measurement used
21
+ * while there was none, or null when it got only the stored frame.
22
+ */
23
+ export declare function noteTextSizeRead(key: string, size: ReadSize | null): void;
24
+ /**
25
+ * The size every read of `key` got in the collection that gave `keys`
26
+ * (`collectTextLayoutReads`): undefined when it did not read `key`, null
27
+ * when the reads got different sizes or the size is not known. A drawn size
28
+ * recorded later that equals it changes nothing that collection read.
29
+ */
30
+ export declare function readSizeOf(keys: ReadonlySet<string>, key: string): ReadSize | null | undefined;
31
+ /** Tells the innermost collection that the measurement `key` was read. */
32
+ export declare function noteTextLayoutRead(key: string): void;
33
+ /**
34
+ * Runs `read`, and returns what it returns with the keys of the text
35
+ * measurements it read. The keys also count as read by the collection
36
+ * around this one, so a result kept in a cache can give them again
37
+ * (`noteTextLayoutReads`) when it is reused.
38
+ */
39
+ export declare function collectTextLayoutReads<T>(read: () => T): {
40
+ readonly value: T;
41
+ readonly keys: ReadonlySet<string>;
42
+ };
43
+ /**
44
+ * The text measurements the layout view read, per component instance (its
45
+ * refits) and per component (its computed texts). Filled while it is the
46
+ * active log (`withTextReadLog`); a later read of the same instance or
47
+ * component replaces the earlier one.
48
+ */
49
+ export interface TextReadLog {
50
+ readonly instances: Map<string, ReadonlySet<string>>;
51
+ readonly components: Map<string, ReadonlySet<string>>;
52
+ }
53
+ /** The log that the component cascade and the computed text fit write to, if any. */
54
+ export declare function activeTextReadLog(): TextReadLog | undefined;
55
+ /** Runs `work` with `log` as the active log. */
56
+ export declare function withTextReadLog<T>(log: TextReadLog, work: () => T): T;
57
+ /**
58
+ * Runs `compute` with no text measured for a size: a text that sizes itself
59
+ * keeps its stored frame where a derived or variable-bound text would be
60
+ * measured again. For resolutions without layout
61
+ * (`ResolveInstanceOptions.layout`), whose readers read words and fonts only.
62
+ */
63
+ export declare function withoutTextMeasurement<T>(compute: () => T): T;
64
+ /** Whether text is left unmeasured now (`withoutTextMeasurement`). */
65
+ export declare function textMeasurementPaused(): boolean;
66
+ export {};
@@ -0,0 +1,128 @@
1
+ /**
2
+ * Which text measurements a piece of work read, by `textLayoutKey`. With
3
+ * the keys a sizer changed since a version (`TextSizer.changedKeysSince`),
4
+ * they let the layout view (`laidOut`) refit, after a text size changes,
5
+ * only the components and instances whose layout read that size.
6
+ *
7
+ * Internal to the model: not exported from the package.
8
+ */
9
+ /** The keys read by each collection that is running, innermost last. */
10
+ const collectors = [];
11
+ /**
12
+ * The size the reads of each key got, by collection: as `collectors`, and
13
+ * as kept for each set of keys a collection gave (`readSizeOf`). Null when
14
+ * reads of the key got different sizes, only the stored frame, or a size
15
+ * that was not noted (`noteTextSizeRead`).
16
+ */
17
+ const sizeCollectors = [];
18
+ const sizesOfReads = new WeakMap();
19
+ function noteSize(sizes, key, size) {
20
+ if (!sizes.has(key)) {
21
+ sizes.set(key, size === null ? null : { width: size.width, height: size.height });
22
+ return;
23
+ }
24
+ const known = sizes.get(key);
25
+ if (known !== null && (size === null || known.width !== size.width || known.height !== size.height))
26
+ sizes.set(key, null);
27
+ }
28
+ /** Whether a collection is running, so a measurement should say which key it read. */
29
+ export function collectingTextLayoutReads() {
30
+ return collectors.length > 0;
31
+ }
32
+ /** Tells the innermost collection that a measurement with these keys was read. */
33
+ export function noteTextLayoutReads(keys) {
34
+ const innermost = collectors[collectors.length - 1];
35
+ if (innermost === undefined)
36
+ return;
37
+ const sizes = sizeCollectors[sizeCollectors.length - 1];
38
+ const known = sizesOfReads.get(keys);
39
+ for (const key of keys) {
40
+ innermost.add(key);
41
+ noteSize(sizes, key, known?.get(key) ?? null);
42
+ }
43
+ }
44
+ /**
45
+ * Tells the innermost collection that the read of `key` it was just told of
46
+ * (`noteTextLayoutRead`) got `size`: the drawn size, or the measurement used
47
+ * while there was none, or null when it got only the stored frame.
48
+ */
49
+ export function noteTextSizeRead(key, size) {
50
+ const sizes = sizeCollectors[sizeCollectors.length - 1];
51
+ if (sizes !== undefined)
52
+ noteSize(sizes, key, size);
53
+ }
54
+ /**
55
+ * The size every read of `key` got in the collection that gave `keys`
56
+ * (`collectTextLayoutReads`): undefined when it did not read `key`, null
57
+ * when the reads got different sizes or the size is not known. A drawn size
58
+ * recorded later that equals it changes nothing that collection read.
59
+ */
60
+ export function readSizeOf(keys, key) {
61
+ if (!keys.has(key))
62
+ return undefined;
63
+ return sizesOfReads.get(keys)?.get(key) ?? null;
64
+ }
65
+ /** Tells the innermost collection that the measurement `key` was read. */
66
+ export function noteTextLayoutRead(key) {
67
+ collectors[collectors.length - 1]?.add(key);
68
+ }
69
+ /**
70
+ * Runs `read`, and returns what it returns with the keys of the text
71
+ * measurements it read. The keys also count as read by the collection
72
+ * around this one, so a result kept in a cache can give them again
73
+ * (`noteTextLayoutReads`) when it is reused.
74
+ */
75
+ export function collectTextLayoutReads(read) {
76
+ const keys = new Set();
77
+ const sizes = new Map();
78
+ collectors.push(keys);
79
+ sizeCollectors.push(sizes);
80
+ let value;
81
+ try {
82
+ value = read();
83
+ }
84
+ finally {
85
+ collectors.pop();
86
+ sizeCollectors.pop();
87
+ }
88
+ sizesOfReads.set(keys, sizes);
89
+ noteTextLayoutReads(keys);
90
+ return { value, keys };
91
+ }
92
+ let activeLog;
93
+ /** The log that the component cascade and the computed text fit write to, if any. */
94
+ export function activeTextReadLog() {
95
+ return activeLog;
96
+ }
97
+ /** Runs `work` with `log` as the active log. */
98
+ export function withTextReadLog(log, work) {
99
+ const outer = activeLog;
100
+ activeLog = log;
101
+ try {
102
+ return work();
103
+ }
104
+ finally {
105
+ activeLog = outer;
106
+ }
107
+ }
108
+ /** How many resolutions without layout are running (`withoutTextMeasurement`). */
109
+ let measurementPauses = 0;
110
+ /**
111
+ * Runs `compute` with no text measured for a size: a text that sizes itself
112
+ * keeps its stored frame where a derived or variable-bound text would be
113
+ * measured again. For resolutions without layout
114
+ * (`ResolveInstanceOptions.layout`), whose readers read words and fonts only.
115
+ */
116
+ export function withoutTextMeasurement(compute) {
117
+ measurementPauses += 1;
118
+ try {
119
+ return compute();
120
+ }
121
+ finally {
122
+ measurementPauses -= 1;
123
+ }
124
+ }
125
+ /** Whether text is left unmeasured now (`withoutTextMeasurement`). */
126
+ export function textMeasurementPaused() {
127
+ return measurementPauses > 0;
128
+ }
@@ -0,0 +1,358 @@
1
+ import type { DesignDocument, DocumentId, Rect, TextParagraph, TextualNode } from "./types.ts";
2
+ /** The size the renderer gave a text it drew. */
3
+ export interface DrawnTextSize {
4
+ readonly width: number;
5
+ readonly height: number;
6
+ }
7
+ /**
8
+ * One font file the renderer draws a document with, as `TextSizer.setFontSet`
9
+ * compares one font set with the next to tell which texts the change can
10
+ * reach.
11
+ */
12
+ export interface DrawnFontFile {
13
+ /** The font asset the file belongs to. */
14
+ readonly assetId: string;
15
+ /** The file's part of its font, for a font that arrives in parts (a Google Fonts family); undefined for a whole font. */
16
+ readonly sliceId?: string;
17
+ readonly byteLength: number;
18
+ /** The characters a font in parts draws with this file, as sorted inclusive code point ranges. */
19
+ readonly unicodeRanges?: readonly (readonly [number, number])[];
20
+ /**
21
+ * True for a file the renderer adds by itself to any text that has a
22
+ * character its own fonts lack (automatic font fallback), which no text
23
+ * names. It reaches a text only through the characters it covers, so a
24
+ * file without `unicodeRanges` reaches every text.
25
+ */
26
+ readonly automaticFallback?: boolean;
27
+ }
28
+ /**
29
+ * Where a text size came from:
30
+ * - `drawn`: the size the renderer gave a text like it before (`TextSizer.record`);
31
+ * - `renderer`: the renderer laid the text out just now (`TextSizer.setRendererMeasurer`);
32
+ * - `canvas`: an estimate, measured with the browser canvas (or the sizer's own `estimate`);
33
+ * - `stored`: the frame already in the document, used when nothing else can
34
+ * say (in Node, with no canvas), and for a text whose size is fixed.
35
+ */
36
+ export type TextSizeSource = "drawn" | "renderer" | "canvas" | "stored";
37
+ /** The box an auto-sized text takes, and where that size came from. */
38
+ export interface TextSize {
39
+ readonly width: number;
40
+ readonly height: number;
41
+ readonly source: TextSizeSource;
42
+ }
43
+ /**
44
+ * Lays a text out with the renderer that shows its document, and returns the
45
+ * size the renderer gives it, or undefined when the renderer cannot say:
46
+ * it is busy, or it lacks a font the text needs. `node` may be a text that
47
+ * the renderer has never drawn, such as one an edit is making.
48
+ */
49
+ export type RendererTextMeasurer = (document: DesignDocument, node: TextualNode) => DrawnTextSize | undefined;
50
+ /**
51
+ * Estimates the natural size of a text's words, before rounding: the width of
52
+ * its longest line and the height of all its lines. Undefined when it cannot.
53
+ */
54
+ export type TextSizeEstimate = (document: DesignDocument, node: TextualNode, paragraphs: readonly TextParagraph[]) => DrawnTextSize | undefined;
55
+ /**
56
+ * Asks the renderer for the sizes of many texts at once, without holding the
57
+ * thread that asks: a renderer in a worker, say. Gives one size, or
58
+ * undefined when it cannot say, per text, in order.
59
+ */
60
+ export type AsyncRendererTextMeasurer = (document: DesignDocument, nodes: readonly TextualNode[]) => Promise<readonly (DrawnTextSize | undefined)[]>;
61
+ /** The longest the sizer asks a renderer without an async slot (`setRendererMeasurer`) in one task of `requestRendererSizes`. */
62
+ export declare const RENDERER_SIZE_SLICE_MS = 8;
63
+ export interface TextSizeOptions {
64
+ /**
65
+ * Whether the renderer may be asked (`setRendererMeasurer`). False for a
66
+ * text whose words are derived; see `getDerivedAutoSizedTextFrame`.
67
+ */
68
+ readonly askRenderer?: boolean;
69
+ }
70
+ /**
71
+ * Answers "what size is this auto-sized text" for one document, and says
72
+ * where each answer came from (`TextSizeSource`). It remembers the sizes the
73
+ * renderer drew texts at, keyed by `textLayoutKey`, and the font files they
74
+ * were drawn with. Find the one of a document with `textSizerFor`.
75
+ */
76
+ export interface TextSizer {
77
+ readonly documentId: DocumentId;
78
+ /**
79
+ * Changes whenever a drawn text size is recorded, changed or forgotten.
80
+ * Anything that keeps sizes derived from `getAutoSizedTextFrame` (resolved
81
+ * instances, the component view) compares it to know they are out of date.
82
+ * Every sizer counts on one shared counter, so the number also changes when
83
+ * another document's sizes change, as it did when the sizes were global.
84
+ */
85
+ readonly version: number;
86
+ /**
87
+ * The box `node` takes for `paragraphs`: the size the renderer gave a text
88
+ * like it, the size the renderer gives it now, an estimate, or, when none
89
+ * can say, its stored frame. A text that sets only its height keeps its
90
+ * stored width; a fixed-size text keeps its stored frame (source `stored`).
91
+ */
92
+ size(document: DesignDocument, node: TextualNode, paragraphs?: readonly TextParagraph[], options?: TextSizeOptions): TextSize;
93
+ /** The size the renderer gave a text like this one, when it has drawn one. */
94
+ drawnSize(document: DesignDocument, node: TextualNode, paragraphs?: readonly TextParagraph[]): DrawnTextSize | undefined;
95
+ /** The size the renderer gave a text whose `textLayoutKey` is `key`, when it has drawn one. */
96
+ drawnSizeOfKey(key: string): DrawnTextSize | undefined;
97
+ /** How many drawn sizes the sizer remembers; with none, no text needs its layout key worked out. */
98
+ readonly drawnSizeCount: number;
99
+ /**
100
+ * The layout keys (`textLayoutKey`) whose remembered size this sizer
101
+ * recorded, replaced or dropped after `version` (a value of `version`
102
+ * read earlier), so a view made at `version` needs to look again only at
103
+ * the texts with those keys. Undefined when the sizer cannot say: it
104
+ * forgot every size since (`clear`), or the changes since are more than
105
+ * it keeps a list of.
106
+ */
107
+ changedKeysSince(version: number): ReadonlySet<string> | undefined;
108
+ /**
109
+ * Remembers the size the renderer gave an auto-sized text it drew, so every
110
+ * text of the same document with the same words, styles, font files and
111
+ * sizing takes that size from now on. The renderer is the authority for
112
+ * text sizes: it lays text out with the fonts it draws with, which the
113
+ * browser canvas often cannot measure (a Google Fonts family, an automatic
114
+ * fallback font).
115
+ *
116
+ * `node` is the text as it was drawn; its frame's width is part of the key
117
+ * when only its height follows the text. Returns whether the size is new or
118
+ * differs from the one remembered, in which case `version` changes and
119
+ * sizes derived before it are out of date.
120
+ */
121
+ record(document: DesignDocument, node: TextualNode, size: DrawnTextSize): boolean;
122
+ /**
123
+ * Tells the sizer which font files the renderer draws the document with.
124
+ * `name` stands for the whole set: every file of every font asset that has
125
+ * arrived (a Google Fonts family arrives in parts) and the fallback fonts
126
+ * the renderer picks itself, none of which the document names. The same
127
+ * name twice changes nothing, so every surface that shows the document can
128
+ * say it.
129
+ *
130
+ * With another name, the sizes recorded so far are from other files and may
131
+ * be wrong. They are kept for now, so text on screen does not jump to the
132
+ * canvas estimate and back: each is either found right by the next draw
133
+ * (`confirm`) or replaced (`record`), and the ones no draw vouched for are
134
+ * dropped by `forgetEarlierFonts`. Returns whether the name changed.
135
+ *
136
+ * With `files`, the files `name` stands for, given this time and the time
137
+ * before, only the sizes of texts that a file which arrived, changed or
138
+ * went away can reach are in doubt: texts that name its font asset, and,
139
+ * for an automatic fallback file, texts with a character it covers. Every
140
+ * other remembered size is as right with the new files as it was with the
141
+ * earlier ones and stays confirmed, so nothing measures those texts again.
142
+ */
143
+ setFontSet(name: string, files?: readonly DrawnFontFile[]): boolean;
144
+ /**
145
+ * Marks the remembered size of a text as right for the font files in use:
146
+ * the renderer has just drawn the text at that size. Does nothing for a text
147
+ * with no remembered size, or with another one.
148
+ */
149
+ confirm(document: DesignDocument, node: TextualNode): void;
150
+ /**
151
+ * Forgets the sizes recorded with earlier font files that no draw has found
152
+ * right since (`setFontSet`): text that is not drawn now, whose size with
153
+ * the files in use is unknown. Such a text is estimated again and corrected
154
+ * when it is next drawn. Call it once every text on screen is settled.
155
+ * Returns how many sizes were forgotten.
156
+ */
157
+ forgetEarlierFonts(): number;
158
+ /**
159
+ * A value that changes whenever the font set does (`setFontSet`, `clear`),
160
+ * and that no other sizer has had: a surface that skips confirming a size
161
+ * it found right before must confirm it again once this changes.
162
+ */
163
+ fontSetGeneration(): number;
164
+ /** Forgets every drawn size and the font set. */
165
+ clear(): void;
166
+ /**
167
+ * Lets the sizer ask the renderer for the size of a text the renderer has
168
+ * not drawn yet, so an edit stores the size the text will be drawn at
169
+ * instead of the canvas estimate. The size is remembered as a drawn size
170
+ * (`record`). The model does not load a renderer: the host that shows the
171
+ * document gives one. Without one, or when it returns no size, the canvas
172
+ * estimate is used and the host corrects it once the text is drawn.
173
+ *
174
+ * Returns a function that removes this measurer, and does nothing once
175
+ * another measurer has replaced it.
176
+ */
177
+ setRendererMeasurer(measurer: RendererTextMeasurer): () => void;
178
+ /**
179
+ * Gives the sizer a renderer it asks without waiting (`requestRendererSizes`).
180
+ * Returns a function that removes it, and does nothing once another has
181
+ * replaced it.
182
+ */
183
+ setAsyncRendererMeasurer(measurer: AsyncRendererTextMeasurer): () => void;
184
+ /**
185
+ * Asks the renderer for the sizes of `nodes` later, on the next frame or
186
+ * idle tick, never in this call: a view of many texts (a thumbnail, the
187
+ * texts of variable modes) shows the drawn size or the estimate now
188
+ * (`size` with `askRenderer: false`), then follows the sizes this
189
+ * records, as it follows drawn sizes. Requests made before the tick are
190
+ * asked together, and a text with a drawn size by then is not asked. The
191
+ * async renderer (`setAsyncRendererMeasurer`) is asked when there is one;
192
+ * else the renderer of `setRendererMeasurer`, in tasks of at most
193
+ * `RENDERER_SIZE_SLICE_MS`. Resolves, never rejects, once every text is
194
+ * answered: true when that changed a remembered size.
195
+ */
196
+ requestRendererSizes(document: DesignDocument, nodes: readonly TextualNode[]): Promise<boolean>;
197
+ /**
198
+ * Puts in place the sizes an earlier run of the app saved for this
199
+ * document (`savedSizes`), so the texts drawn then are not measured again.
200
+ * They are read only when a text is looked up. Each is given as a size in
201
+ * doubt, as one recorded with earlier font files is (`setFontSet`): the
202
+ * first draw of the text confirms it (`confirm`, which keeps it as drawn
203
+ * in this run) or replaces it (`record`), so only a text the renderer
204
+ * really draws at another size is laid out anew. The automatic fallback
205
+ * files are not part of a text's key and can differ from one run to the
206
+ * next, which the draw finds. A text whose font asset changed has another
207
+ * layout key (`fontAssetFingerprint`), so it finds no saved size. Sizes
208
+ * drawn in this run come first. Replaces the sizes put in place before.
209
+ * Given after this run has sizes, it changes no view and tells no
210
+ * listener: the first draw of a text with a restored key tells that
211
+ * text's change.
212
+ */
213
+ restoreSavedSizes(saved: SavedTextSizes): void;
214
+ /**
215
+ * The sizes to save for a later run: each size drawn or confirmed, the one
216
+ * used last at the end, within `MAX_SAVED_TEXT_SIZES`. Each is kept
217
+ * under the SHA-256 of its layout key (`savedTextSizeKey`), so no words
218
+ * of the document are kept, and is given back only for a key with that
219
+ * digest: two texts share a size only if SHA-256 collides.
220
+ */
221
+ savedSizes(): SavedTextSizes;
222
+ /** Changes whenever `savedSizes` would give something else, so a host writes them out only then. */
223
+ readonly savedSizesVersion: number;
224
+ }
225
+ /**
226
+ * Drawn text sizes as a host keeps them between runs of the app
227
+ * (`TextSizer.savedSizes`): plain JSON. Each entry is the SHA-256 of the
228
+ * layout key (`savedTextSizeKey`), the width and the height.
229
+ */
230
+ export interface SavedTextSizes {
231
+ readonly entries: readonly (readonly [key: string, width: number, height: number])[];
232
+ }
233
+ /** The most drawn sizes saved for one document; past it the one used longest ago is dropped. */
234
+ export declare const MAX_SAVED_TEXT_SIZES = 32768;
235
+ /**
236
+ * The key a size is saved under for a later run: the SHA-256 of the layout
237
+ * key (`textLayoutKey`), as 64 lowercase hexadecimal digits. A layout key
238
+ * holds the text's words; the digest keeps them out of the host's storage,
239
+ * at a fixed length.
240
+ */
241
+ export declare function savedTextSizeKey(layoutKey: string): string;
242
+ export interface TextSizerOptions {
243
+ /** The renderer to ask first; see `TextSizer.setRendererMeasurer`. */
244
+ readonly measure?: RendererTextMeasurer;
245
+ /**
246
+ * The estimate to use when no renderer can say. The browser canvas when not
247
+ * given; tests give fixed sizes instead.
248
+ */
249
+ readonly estimate?: TextSizeEstimate;
250
+ }
251
+ /** The fields of the demoted sizes `sizer` keeps, and how many there are; to check they stay light. */
252
+ export declare function demotedTextSizeFields(sizer: TextSizer): {
253
+ readonly count: number;
254
+ readonly fields: readonly string[];
255
+ };
256
+ /**
257
+ * How many times, since the page loaded, a sizer was given a drawn size
258
+ * it did not know already (`TextSizer.record` returned true): each is a text
259
+ * the renderer measured and the layout view laid out anew. A document
260
+ * opened again with its saved sizes (`TextSizer.restoreSavedSizes`) and the
261
+ * same font files adds none for the texts it drew before.
262
+ */
263
+ export declare function drawnTextSizeRecords(): number;
264
+ /**
265
+ * How many times, since the page loaded, the frame of an auto-sized text
266
+ * that no renderer had drawn yet was sized by the renderer
267
+ * (`TextSizer.setRendererMeasurer`) and by the browser canvas estimate. A
268
+ * size the renderer had already drawn the text at counts as neither. Tests
269
+ * read it to tell that an edit was sized by the renderer, not by a silent
270
+ * fallback to the canvas.
271
+ */
272
+ export declare function autoSizedTextSources(): {
273
+ readonly renderer: number;
274
+ readonly canvas: number;
275
+ };
276
+ /**
277
+ * A sizer for one document that is not registered: a test's scripted sizer,
278
+ * say, which `registerTextSizer` then puts in place of the document's own.
279
+ */
280
+ export declare function createTextSizer(documentId: DocumentId, options?: TextSizerOptions): TextSizer;
281
+ /**
282
+ * The sizer of a document: the one `registerTextSizer` put in place, or one
283
+ * kept for it here, made on first use. The host that shows a document gives
284
+ * that sizer its renderer (`TextSizer.setRendererMeasurer`).
285
+ */
286
+ export declare function textSizerFor(documentId: DocumentId): TextSizer;
287
+ /**
288
+ * Puts `sizer` in place for its document, in place of the one kept for it.
289
+ * Returns a function that removes it again, and does nothing once another
290
+ * sizer has replaced it.
291
+ */
292
+ export declare function registerTextSizer(sizer: TextSizer): () => void;
293
+ /** Forgets every drawn text size of one document, or of all documents when none is given. */
294
+ export declare function clearDrawnTextSizes(documentId?: DocumentId): void;
295
+ /**
296
+ * The frame an auto-sized text box takes for its content, from `sizer` (the
297
+ * document's own when not given; see `TextSizer.size`). Fixed-size text keeps
298
+ * its frame. The new frame keeps the point from `textAutoResizeAnchor` in
299
+ * place on the page.
300
+ */
301
+ export declare function getAutoSizedTextFrame(document: DesignDocument, node: TextualNode, paragraphs?: readonly TextParagraph[], sizer?: TextSizer): Rect;
302
+ /**
303
+ * The frame of an auto-sized text in a view of many texts: like
304
+ * `getAutoSizedTextFrame`, but the renderer is not asked now. A text with no
305
+ * drawn size takes the estimate, and its size is asked for on the next tick
306
+ * (`TextSizer.requestRendererSizes`); the views that read it follow the
307
+ * size that records.
308
+ */
309
+ export declare function getRequestedAutoSizedTextFrame(document: DesignDocument, node: TextualNode, paragraphs?: readonly TextParagraph[], sizer?: TextSizer): Rect;
310
+ /**
311
+ * The frame of an auto-sized text whose words are derived: a component's
312
+ * computed text, or a text of an instance that shows other words than its
313
+ * main component. Like `getAutoSizedTextFrame`, but the renderer is not
314
+ * asked (`TextSizer.setRendererMeasurer`). Such a text gets its size from the
315
+ * renderer once it is drawn (`TextSizer.record`), and that same step derives
316
+ * again the stored sizes that depend on it. A size the renderer gave while
317
+ * the text was only being resolved would leave those stored sizes as they
318
+ * were.
319
+ */
320
+ export declare function getDerivedAutoSizedTextFrame(document: DesignDocument, node: TextualNode, paragraphs?: readonly TextParagraph[], sizer?: TextSizer): Rect;
321
+ /** The size the renderer gave a text like `node` in its document, when it drew one; see `TextSizer.drawnSize`. */
322
+ export declare function drawnTextSize(document: DesignDocument, node: TextualNode, paragraphs?: readonly TextParagraph[]): DrawnTextSize | undefined;
323
+ /** `TextSizer.record` on the sizer of the document. */
324
+ export declare function recordDrawnTextSize(document: DesignDocument, node: TextualNode, size: DrawnTextSize): boolean;
325
+ /** `TextSizer.setFontSet` on the sizer of the document. */
326
+ export declare function setDrawnTextFontSet(documentId: DocumentId, name: string, files?: readonly DrawnFontFile[]): boolean;
327
+ /** `TextSizer.confirm` on the sizer of the document. */
328
+ export declare function confirmDrawnTextSize(document: DesignDocument, node: TextualNode): void;
329
+ /** `TextSizer.fontSetGeneration` on the sizer of the document. */
330
+ export declare function drawnTextFontSetGeneration(documentId: DocumentId): number;
331
+ /** `TextSizer.forgetEarlierFonts` on the sizer of the document. */
332
+ export declare function forgetDrawnTextSizesOfEarlierFonts(documentId: DocumentId): number;
333
+ /** The version shared by every sizer; see `TextSizer.version`. */
334
+ export declare function getDrawnTextSizesVersion(): number;
335
+ /**
336
+ * Calls `listener` right after the shared version (`getDrawnTextSizesVersion`)
337
+ * changes, which can be in the middle of a draw: a listener that updates a
338
+ * screen should defer its work. The listener is given the id of the document
339
+ * whose sizes changed. Returns a function that removes it.
340
+ */
341
+ export declare function subscribeDrawnTextSizes(listener: (documentId: DocumentId) => void): () => void;
342
+ /**
343
+ * Calls `listener` whenever the saved sizes of a document change
344
+ * (`TextSizer.savedSizesVersion`), including a change of their order only,
345
+ * which tells no listener of `subscribeDrawnTextSizes`. It is called in the
346
+ * middle of a draw: a listener should only schedule its work. Returns a
347
+ * function that removes it.
348
+ */
349
+ export declare function subscribeSavedTextSizes(listener: (documentId: DocumentId) => void): () => void;
350
+ /** `TextSizer.restoreSavedSizes` on the sizer of the document. */
351
+ export declare function restoreSavedTextSizes(documentId: DocumentId, saved: SavedTextSizes): void;
352
+ /** `TextSizer.savedSizes` and `TextSizer.savedSizesVersion` of the sizer of the document. */
353
+ export declare function savedTextSizes(documentId: DocumentId): {
354
+ readonly version: number;
355
+ readonly saved: SavedTextSizes;
356
+ };
357
+ /** `TextSizer.setRendererMeasurer` on the sizer of the document. */
358
+ export declare function setRendererTextMeasurer(documentId: DocumentId, measurer: RendererTextMeasurer): () => void;