@formicoidea/labre-core 0.49.0 → 0.51.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 (241) hide show
  1. package/dist/_pkgs/affine-block-attachment/asset-picker.d.ts +24 -0
  2. package/dist/_pkgs/affine-block-attachment/asset-picker.js +87 -0
  3. package/dist/_pkgs/affine-block-attachment/configs/slash-menu.js +3 -20
  4. package/dist/_pkgs/affine-block-attachment/index.d.ts +1 -0
  5. package/dist/_pkgs/affine-block-attachment/index.js +1 -0
  6. package/dist/_pkgs/affine-block-attachment/utils.d.ts +9 -1
  7. package/dist/_pkgs/affine-block-attachment/utils.js +9 -0
  8. package/dist/_pkgs/affine-block-bookmark/adapters/markdown/markdown.js +14 -1
  9. package/dist/_pkgs/affine-block-bookmark/adapters/notion-html.js +5 -1
  10. package/dist/_pkgs/affine-block-database/adapters/markdown.js +5 -3
  11. package/dist/_pkgs/affine-block-embed/common/adapters/html.js +5 -3
  12. package/dist/_pkgs/affine-block-embed/common/adapters/markdown.js +11 -0
  13. package/dist/_pkgs/affine-block-frame/frame-template.d.ts +58 -0
  14. package/dist/_pkgs/affine-block-frame/frame-template.js +207 -0
  15. package/dist/_pkgs/affine-block-frame/frame-toolbar.js +19 -3
  16. package/dist/_pkgs/affine-block-frame/index.d.ts +1 -0
  17. package/dist/_pkgs/affine-block-frame/index.js +1 -0
  18. package/dist/_pkgs/affine-block-frame/translations.d.ts +7 -0
  19. package/dist/_pkgs/affine-block-frame/translations.js +16 -1
  20. package/dist/_pkgs/affine-block-frame/view.js +6 -0
  21. package/dist/_pkgs/affine-block-image/asset-picker.d.ts +63 -0
  22. package/dist/_pkgs/affine-block-image/asset-picker.js +183 -0
  23. package/dist/_pkgs/affine-block-image/commands/insert-images.d.ts +5 -0
  24. package/dist/_pkgs/affine-block-image/commands/insert-images.js +8 -8
  25. package/dist/_pkgs/affine-block-image/components/page-image-block.d.ts +11 -0
  26. package/dist/_pkgs/affine-block-image/components/page-image-block.js +81 -12
  27. package/dist/_pkgs/affine-block-image/configs/replace-action.d.ts +9 -0
  28. package/dist/_pkgs/affine-block-image/configs/replace-action.js +27 -0
  29. package/dist/_pkgs/affine-block-image/configs/toolbar.js +6 -0
  30. package/dist/_pkgs/affine-block-image/crop/crop-controller.d.ts +46 -0
  31. package/dist/_pkgs/affine-block-image/crop/crop-controller.js +104 -0
  32. package/dist/_pkgs/affine-block-image/crop/crop-math.d.ts +70 -0
  33. package/dist/_pkgs/affine-block-image/crop/crop-math.js +141 -0
  34. package/dist/_pkgs/affine-block-image/crop/crop-overlay.d.ts +57 -0
  35. package/dist/_pkgs/affine-block-image/crop/crop-overlay.js +343 -0
  36. package/dist/_pkgs/affine-block-image/crop/crop-toolbar.d.ts +12 -0
  37. package/dist/_pkgs/affine-block-image/crop/crop-toolbar.js +78 -0
  38. package/dist/_pkgs/affine-block-image/crop/write-crop.d.ts +16 -0
  39. package/dist/_pkgs/affine-block-image/crop/write-crop.js +57 -0
  40. package/dist/_pkgs/affine-block-image/edgeless-clipboard-config.js +4 -1
  41. package/dist/_pkgs/affine-block-image/effects.js +2 -0
  42. package/dist/_pkgs/affine-block-image/image-block.d.ts +2 -0
  43. package/dist/_pkgs/affine-block-image/image-block.js +2 -0
  44. package/dist/_pkgs/affine-block-image/image-edgeless-block.d.ts +2 -0
  45. package/dist/_pkgs/affine-block-image/image-edgeless-block.js +36 -8
  46. package/dist/_pkgs/affine-block-image/image-resize-manager.js +15 -0
  47. package/dist/_pkgs/affine-block-image/index.d.ts +1 -0
  48. package/dist/_pkgs/affine-block-image/index.js +1 -0
  49. package/dist/_pkgs/affine-block-image/translations.d.ts +15 -0
  50. package/dist/_pkgs/affine-block-image/translations.js +43 -0
  51. package/dist/_pkgs/affine-block-image/utils.d.ts +13 -0
  52. package/dist/_pkgs/affine-block-image/utils.js +10 -1
  53. package/dist/_pkgs/affine-block-root/clipboard/page-clipboard.js +5 -0
  54. package/dist/_pkgs/affine-block-root/commands/page-export-commands.d.ts +2 -0
  55. package/dist/_pkgs/affine-block-root/commands/page-export-commands.js +71 -0
  56. package/dist/_pkgs/affine-block-root/index.d.ts +1 -0
  57. package/dist/_pkgs/affine-block-root/index.js +1 -0
  58. package/dist/_pkgs/affine-block-root/view.js +8 -0
  59. package/dist/_pkgs/affine-block-surface/extensions/drawio-export/capability.d.ts +30 -0
  60. package/dist/_pkgs/affine-block-surface/extensions/drawio-export/capability.js +44 -0
  61. package/dist/_pkgs/affine-block-surface/extensions/drawio-export/colors.d.ts +26 -0
  62. package/dist/_pkgs/affine-block-surface/extensions/drawio-export/colors.js +82 -0
  63. package/dist/_pkgs/affine-block-surface/extensions/drawio-export/command.d.ts +18 -0
  64. package/dist/_pkgs/affine-block-surface/extensions/drawio-export/command.js +91 -0
  65. package/dist/_pkgs/affine-block-surface/extensions/drawio-export/index.d.ts +3 -0
  66. package/dist/_pkgs/affine-block-surface/extensions/drawio-export/index.js +3 -0
  67. package/dist/_pkgs/affine-block-surface/extensions/drawio-export/writer.d.ts +50 -0
  68. package/dist/_pkgs/affine-block-surface/extensions/drawio-export/writer.js +732 -0
  69. package/dist/_pkgs/affine-block-surface/extensions/export-manager/draw-image-block.d.ts +12 -0
  70. package/dist/_pkgs/affine-block-surface/extensions/export-manager/draw-image-block.js +15 -0
  71. package/dist/_pkgs/affine-block-surface/extensions/export-manager/export-manager.js +7 -1
  72. package/dist/_pkgs/affine-block-surface/extensions/export-svg/command.d.ts +7 -1
  73. package/dist/_pkgs/affine-block-surface/extensions/export-svg/command.js +60 -1
  74. package/dist/_pkgs/affine-block-surface/extensions/export-svg/index.d.ts +2 -2
  75. package/dist/_pkgs/affine-block-surface/extensions/export-svg/index.js +2 -2
  76. package/dist/_pkgs/affine-block-surface/extensions/export-svg/marker-version.d.ts +6 -0
  77. package/dist/_pkgs/affine-block-surface/extensions/export-svg/marker-version.js +8 -0
  78. package/dist/_pkgs/affine-block-surface/extensions/export-svg/render.d.ts +28 -1
  79. package/dist/_pkgs/affine-block-surface/extensions/export-svg/render.js +66 -6
  80. package/dist/_pkgs/affine-block-surface/extensions/export-svg/svg-context.d.ts +2 -7
  81. package/dist/_pkgs/affine-block-surface/extensions/export-svg/svg-context.js +2 -6
  82. package/dist/_pkgs/affine-block-surface/extensions/index.d.ts +2 -0
  83. package/dist/_pkgs/affine-block-surface/extensions/index.js +2 -0
  84. package/dist/_pkgs/affine-block-surface/extensions/interchange-export.d.ts +84 -0
  85. package/dist/_pkgs/affine-block-surface/extensions/interchange-export.js +150 -0
  86. package/dist/_pkgs/affine-block-surface/extensions/interchange-import.js +24 -2
  87. package/dist/_pkgs/affine-block-surface/extensions/interchange.d.ts +23 -2
  88. package/dist/_pkgs/affine-block-surface/extensions/interchange.js +4 -1
  89. package/dist/_pkgs/affine-block-surface/extensions/legend-role.d.ts +18 -0
  90. package/dist/_pkgs/affine-block-surface/extensions/legend-role.js +20 -0
  91. package/dist/_pkgs/affine-block-surface/extensions/legend.d.ts +2 -19
  92. package/dist/_pkgs/affine-block-surface/extensions/legend.js +2 -18
  93. package/dist/_pkgs/affine-block-surface/extensions/svg-sanitize.d.ts +67 -0
  94. package/dist/_pkgs/affine-block-surface/extensions/svg-sanitize.js +235 -0
  95. package/dist/_pkgs/affine-block-surface/extensions/svg-sketch-translations.d.ts +1 -0
  96. package/dist/_pkgs/affine-block-surface/extensions/svg-sketch-translations.js +9 -0
  97. package/dist/_pkgs/affine-block-surface/extensions/svg-sketch.d.ts +17 -13
  98. package/dist/_pkgs/affine-block-surface/extensions/svg-sketch.js +52 -80
  99. package/dist/_pkgs/affine-block-surface/extensions/xml-element.d.ts +98 -0
  100. package/dist/_pkgs/affine-block-surface/extensions/xml-element.js +261 -0
  101. package/dist/_pkgs/affine-block-surface/extensions/xml-reader.d.ts +238 -0
  102. package/dist/_pkgs/affine-block-surface/extensions/xml-reader.js +570 -0
  103. package/dist/_pkgs/affine-block-surface/framework-background/def.js +1 -1
  104. package/dist/_pkgs/affine-block-surface/interchange-headless.d.ts +29 -0
  105. package/dist/_pkgs/affine-block-surface/interchange-headless.js +32 -0
  106. package/dist/_pkgs/affine-block-surface/view.js +22 -2
  107. package/dist/_pkgs/affine-block-table/adapters/utils.js +24 -1
  108. package/dist/_pkgs/affine-components/color-picker/color-panel.d.ts +11 -0
  109. package/dist/_pkgs/affine-components/color-picker/color-panel.js +87 -12
  110. package/dist/_pkgs/affine-components/color-picker/framework-palette.d.ts +8 -0
  111. package/dist/_pkgs/affine-components/color-picker/framework-palette.js +11 -3
  112. package/dist/_pkgs/affine-components/color-picker/icons.d.ts +9 -0
  113. package/dist/_pkgs/affine-components/color-picker/icons.js +12 -0
  114. package/dist/_pkgs/affine-gfx-note/toolbar/note-menu.js +5 -8
  115. package/dist/_pkgs/affine-gfx-template/contribute.d.ts +14 -4
  116. package/dist/_pkgs/affine-gfx-template/contribute.js +47 -6
  117. package/dist/_pkgs/affine-gfx-template/toolbar/builtin-templates.d.ts +7 -2
  118. package/dist/_pkgs/affine-gfx-template/toolbar/builtin-templates.js +14 -40
  119. package/dist/_pkgs/affine-gfx-template/toolbar/resolve-name.d.ts +1 -1
  120. package/dist/_pkgs/affine-gfx-template/toolbar/resolve-name.js +1 -1
  121. package/dist/_pkgs/affine-gfx-template/toolbar/template-panel.d.ts +4 -4
  122. package/dist/_pkgs/affine-gfx-template/toolbar/template-panel.js +9 -9
  123. package/dist/_pkgs/affine-gfx-template/toolbar/template-type.d.ts +2 -4
  124. package/dist/_pkgs/affine-gfx-template/translations.d.ts +5 -0
  125. package/dist/_pkgs/affine-gfx-template/translations.js +9 -0
  126. package/dist/_pkgs/affine-inline-footnote/adapters/markdown/inline-delta.js +6 -0
  127. package/dist/_pkgs/affine-inline-footnote/adapters/markdown/markdown-inline.js +7 -0
  128. package/dist/_pkgs/affine-inline-link/adapters/html/html-inline.js +4 -1
  129. package/dist/_pkgs/affine-inline-link/adapters/html/inline-delta.js +3 -1
  130. package/dist/_pkgs/affine-inline-link/adapters/markdown/inline-delta.js +4 -1
  131. package/dist/_pkgs/affine-inline-link/adapters/notion-html/html-inline.js +2 -1
  132. package/dist/_pkgs/affine-inline-link/link-node/affine-link.d.ts +7 -0
  133. package/dist/_pkgs/affine-inline-link/link-node/affine-link.js +37 -0
  134. package/dist/_pkgs/affine-inline-link/link-node/index.d.ts +1 -0
  135. package/dist/_pkgs/affine-inline-link/link-node/index.js +1 -0
  136. package/dist/_pkgs/affine-inline-link/link-node/propose-views.d.ts +22 -0
  137. package/dist/_pkgs/affine-inline-link/link-node/propose-views.js +59 -0
  138. package/dist/_pkgs/affine-model/blocks/database/types.d.ts +28 -0
  139. package/dist/_pkgs/affine-model/blocks/image/image-crop.d.ts +48 -0
  140. package/dist/_pkgs/affine-model/blocks/image/image-crop.js +78 -0
  141. package/dist/_pkgs/affine-model/blocks/image/image-model.d.ts +6 -0
  142. package/dist/_pkgs/affine-model/blocks/image/image-model.js +2 -0
  143. package/dist/_pkgs/affine-model/blocks/image/index.d.ts +1 -0
  144. package/dist/_pkgs/affine-model/blocks/image/index.js +1 -0
  145. package/dist/_pkgs/affine-model/consts/shape.d.ts +2 -0
  146. package/dist/_pkgs/affine-model/consts/shape.js +5 -0
  147. package/dist/_pkgs/affine-model/elements/bpmn/consts.d.ts +31 -0
  148. package/dist/_pkgs/affine-model/elements/bpmn/consts.js +31 -0
  149. package/dist/_pkgs/affine-model/elements/bpmn/index.d.ts +1 -0
  150. package/dist/_pkgs/affine-model/elements/bpmn/index.js +1 -0
  151. package/dist/_pkgs/affine-model/elements/bpmn/pool.d.ts +0 -25
  152. package/dist/_pkgs/affine-model/elements/bpmn/pool.js +1 -25
  153. package/dist/_pkgs/affine-model/elements/shape/shape.d.ts +0 -2
  154. package/dist/_pkgs/affine-model/elements/shape/shape.js +1 -2
  155. package/dist/_pkgs/affine-model/elements/uml/consts.d.ts +133 -0
  156. package/dist/_pkgs/affine-model/elements/uml/consts.js +107 -0
  157. package/dist/_pkgs/affine-model/elements/uml/diagram.d.ts +1 -79
  158. package/dist/_pkgs/affine-model/elements/uml/diagram.js +1 -53
  159. package/dist/_pkgs/affine-model/elements/uml/fragment.d.ts +0 -15
  160. package/dist/_pkgs/affine-model/elements/uml/fragment.js +1 -15
  161. package/dist/_pkgs/affine-model/elements/uml/index.d.ts +1 -0
  162. package/dist/_pkgs/affine-model/elements/uml/index.js +1 -0
  163. package/dist/_pkgs/affine-model/elements/uml/partition.d.ts +0 -20
  164. package/dist/_pkgs/affine-model/elements/uml/partition.js +1 -20
  165. package/dist/_pkgs/affine-model/elements/uml/region.d.ts +0 -11
  166. package/dist/_pkgs/affine-model/elements/uml/region.js +1 -11
  167. package/dist/_pkgs/affine-model/headless.d.ts +19 -0
  168. package/dist/_pkgs/affine-model/headless.js +19 -0
  169. package/dist/_pkgs/affine-shared/headless.d.ts +10 -0
  170. package/dist/_pkgs/affine-shared/headless.js +10 -0
  171. package/dist/_pkgs/affine-shared/services/asset-picker-service.d.ts +63 -0
  172. package/dist/_pkgs/affine-shared/services/asset-picker-service.js +20 -0
  173. package/dist/_pkgs/affine-shared/services/data-source-picker-service.d.ts +6 -3
  174. package/dist/_pkgs/affine-shared/services/frame-template-service.d.ts +83 -0
  175. package/dist/_pkgs/affine-shared/services/frame-template-service.js +17 -0
  176. package/dist/_pkgs/affine-shared/services/index.d.ts +2 -0
  177. package/dist/_pkgs/affine-shared/services/index.js +2 -0
  178. package/dist/_pkgs/affine-shared/services/translation-service/chrome.d.ts +6 -0
  179. package/dist/_pkgs/affine-shared/services/translation-service/chrome.js +10 -0
  180. package/dist/_pkgs/affine-widget-drag-handle/watchers/drag-event-watcher.js +8 -3
  181. package/dist/_pkgs/affine-widget-keyboard-toolbar/config.js +4 -16
  182. package/dist/_pkgs/affine-widget-linked-doc/transformers/html.d.ts +7 -0
  183. package/dist/_pkgs/affine-widget-linked-doc/transformers/html.js +25 -24
  184. package/dist/_pkgs/affine-widget-linked-doc/transformers/index.d.ts +1 -1
  185. package/dist/_pkgs/affine-widget-linked-doc/transformers/markdown.d.ts +7 -0
  186. package/dist/_pkgs/affine-widget-linked-doc/transformers/markdown.js +26 -25
  187. package/dist/_pkgs/affine-widget-linked-doc/transformers/utils.d.ts +23 -0
  188. package/dist/_pkgs/affine-widget-linked-doc/transformers/utils.js +14 -0
  189. package/dist/_pkgs/data-view/core/common/properties.d.ts +29 -0
  190. package/dist/_pkgs/data-view/core/common/properties.js +110 -8
  191. package/dist/_pkgs/data-view/core/common/property-menu.d.ts +44 -1
  192. package/dist/_pkgs/data-view/core/common/property-menu.js +100 -3
  193. package/dist/_pkgs/data-view/core/component/tags/color-carousel.d.ts +41 -0
  194. package/dist/_pkgs/data-view/core/component/tags/color-carousel.js +199 -0
  195. package/dist/_pkgs/data-view/core/component/tags/color-menu.d.ts +49 -0
  196. package/dist/_pkgs/data-view/core/component/tags/color-menu.js +123 -0
  197. package/dist/_pkgs/data-view/core/component/tags/index.d.ts +3 -0
  198. package/dist/_pkgs/data-view/core/component/tags/index.js +3 -0
  199. package/dist/_pkgs/data-view/core/component/tags/multi-tag-select.d.ts +8 -1
  200. package/dist/_pkgs/data-view/core/component/tags/multi-tag-select.js +21 -20
  201. package/dist/_pkgs/data-view/core/component/tags/softened-colors.d.ts +42 -0
  202. package/dist/_pkgs/data-view/core/component/tags/softened-colors.js +79 -0
  203. package/dist/_pkgs/data-view/core/data-view.d.ts +8 -1
  204. package/dist/_pkgs/data-view/core/data-view.js +18 -2
  205. package/dist/_pkgs/data-view/core/effect.js +2 -1
  206. package/dist/_pkgs/data-view/core/filter/eval.d.ts +6 -1
  207. package/dist/_pkgs/data-view/core/filter/eval.js +7 -2
  208. package/dist/_pkgs/data-view/core/group-by/renderer/select-group.d.ts +3 -0
  209. package/dist/_pkgs/data-view/core/group-by/renderer/select-group.js +119 -71
  210. package/dist/_pkgs/data-view/core/view/color-rules.d.ts +85 -0
  211. package/dist/_pkgs/data-view/core/view/color-rules.js +165 -0
  212. package/dist/_pkgs/data-view/core/view/index.d.ts +1 -0
  213. package/dist/_pkgs/data-view/core/view/index.js +1 -0
  214. package/dist/_pkgs/data-view/property-presets/multi-select/cell-renderer.js +1 -0
  215. package/dist/_pkgs/data-view/property-presets/select/cell-renderer.js +1 -0
  216. package/dist/_pkgs/data-view/translations.d.ts +34 -0
  217. package/dist/_pkgs/data-view/translations.js +80 -0
  218. package/dist/_pkgs/data-view/view-presets/gallery/gallery-view.js +7 -1
  219. package/dist/_pkgs/data-view/view-presets/kanban/mobile/card.js +6 -1
  220. package/dist/_pkgs/data-view/view-presets/kanban/pc/card.js +6 -1
  221. package/dist/_pkgs/data-view/view-presets/list/list-view.js +4 -0
  222. package/dist/_pkgs/data-view/view-presets/table/mobile/row.js +3 -0
  223. package/dist/_pkgs/data-view/view-presets/table/pc/header/database-header-column.d.ts +3 -1
  224. package/dist/_pkgs/data-view/view-presets/table/pc/header/database-header-column.js +149 -175
  225. package/dist/_pkgs/data-view/view-presets/table/pc/row/row.js +6 -0
  226. package/dist/_pkgs/data-view/widget-presets/tools/presets/view-options/color-rules-menu.d.ts +12 -0
  227. package/dist/_pkgs/data-view/widget-presets/tools/presets/view-options/color-rules-menu.js +206 -0
  228. package/dist/_pkgs/data-view/widget-presets/tools/presets/view-options/view-options.js +16 -2
  229. package/dist/_pkgs/data-view/widget-presets/tools/presets/view-options/view-settings.d.ts +4 -2
  230. package/dist/_pkgs/data-view/widget-presets/tools/presets/view-options/view-settings.js +11 -2
  231. package/dist/commands.js +5 -2
  232. package/dist/host-panels.d.ts +21 -1
  233. package/dist/host-panels.js +50 -10
  234. package/dist/interchange.d.ts +1 -0
  235. package/dist/interchange.js +1 -0
  236. package/dist/model/headless.d.ts +1 -0
  237. package/dist/model/headless.js +1 -0
  238. package/dist/shared/headless.d.ts +1 -0
  239. package/dist/shared/headless.js +1 -0
  240. package/dist/translations.js +8 -1
  241. package/package.json +13 -1
@@ -0,0 +1,238 @@
1
+ /**
2
+ * A tolerant XML READER — the inverse of UML's `xml.ts` writer, and the one
3
+ * thing an importer cannot do without. Read by the XMI and draw.io importers,
4
+ * by BPMN and by the SVG sketch (through `xml-element.ts`), all four servable
5
+ * from the editor-free `./interchange` entry.
6
+ *
7
+ * ## Why not `DOMParser`
8
+ *
9
+ * BPMN and the SVG sketch used to call it, and the P0 import spike measured
10
+ * the cost on a server: a DOM to install (jsdom, 6 MB, behind `vm`), and a
11
+ * BPMN read that grew quadratically on it. An interchange parser is a PURE function of a string (`docs/adr/0012` P3) — the
12
+ * same function an editor command, a unit test and labre-mcp all call — and
13
+ * `DOMParser` is a DOM global that exists in exactly one of those three. A
14
+ * reader that needs `happy-dom` to be loaded is a reader with an environment in
15
+ * its signature.
16
+ *
17
+ * So: two hundred lines of scanner, and no global in sight.
18
+ *
19
+ * ## Tolerant, and what that costs
20
+ *
21
+ * **It never throws.** A file that stops mid-element, a close tag that names
22
+ * the wrong element, an attribute with no quotes, an entity nobody declared —
23
+ * every one of them produces a tree with a NOTE beside it rather than an
24
+ * exception. That is not sloppiness, it is the job: the files this reader is
25
+ * handed were written by Papyrus, StarUML, Enterprise Architect and a dozen
26
+ * scripts, and a user who exported a model from one of them is entitled to get
27
+ * back everything it said even when part of it is malformed. The alternative —
28
+ * one exception for one stray `&` — imports nothing at all.
29
+ *
30
+ * What it does NOT do is pretend to be a conformant parser. There is no DTD, no
31
+ * entity declaration, no namespace RESOLUTION (prefixes are kept exactly as the
32
+ * file spelled them — see {@link XmlNode.prefix}), no attribute-value
33
+ * normalization beyond the character references XML 1.0 §3.3.3 makes
34
+ * mandatory. Every one of those is a feature an XMI file in the wild does not
35
+ * use, and each would be a piece of surface with nothing behind it.
36
+ *
37
+ * ## Verbatim means the source's own bytes
38
+ *
39
+ * Every node records the byte RANGE it was read from ({@link XmlNode.range}),
40
+ * and {@link xmlFragmentOf} hands back that slice of the original string. So a
41
+ * quarantined fragment (ADR 0012 D5) is the file's own text — its comments, its
42
+ * whitespace, its attribute order, its prefixes — and not this reader's opinion
43
+ * of it. {@link serializeXmlNode} re-serializes from the tree instead, and is
44
+ * the fallback for a node assembled rather than read.
45
+ *
46
+ * ## Bounded, because a server reads it too
47
+ *
48
+ * The one exception to "never throws": a document past {@link XML_MAX_NODES}
49
+ * nodes or {@link XML_MAX_CHARACTERS} characters is refused with an
50
+ * {@link InterchangeImportError} carrying a static key, at the node that
51
+ * crosses the line and not after the tree is built. Each node costs about two
52
+ * hundred bytes of heap, and a 1.5 KiB `.drawio` inflates to a million of
53
+ * them (the 2026-10-14 security review: 3.2 s and 223 MiB before the cap). The
54
+ * scan is linear in the source otherwise: an orphan close tag is answered from
55
+ * a count of open names, not by searching the stack.
56
+ *
57
+ * Pure: a string in, a tree out. No `std`, no DOM, no clock.
58
+ */
59
+ import type { ChromeWording } from '../../affine-shared/services/index.js';
60
+ /**
61
+ * One element.
62
+ *
63
+ * `name` is the qualified name AS WRITTEN (`uml:Model`), with {@link prefix}
64
+ * and {@link local} split out beside it, because an importer asks both
65
+ * questions: the prefix is how a file says which vocabulary it means, and the
66
+ * local name is the only half two tools reliably agree on — Papyrus writes
67
+ * `uml:Class`, an older Enterprise Architect writes `UML:Class`, and a
68
+ * namespace-defaulted file writes `Class`.
69
+ */
70
+ export interface XmlNode {
71
+ /** The qualified name, verbatim: `uml:Model`, `packagedElement`. */
72
+ name: string;
73
+ /** The prefix, `''` when the name carries none. */
74
+ prefix: string;
75
+ /** The local name — `Model`, `packagedElement`. */
76
+ local: string;
77
+ /** Attributes by qualified name, values entity-decoded, in document order. */
78
+ attrs: Record<string, string>;
79
+ children: XmlNode[];
80
+ /**
81
+ * The element's character data — text and CDATA, concatenated and decoded.
82
+ *
83
+ * Absent rather than `''` when the element holds nothing but whitespace and
84
+ * children, which is what every element of an indented XMI document holds.
85
+ * A `<body>` with prose in it has this; a `<packagedElement>` does not.
86
+ */
87
+ text?: string;
88
+ /**
89
+ * `[start, end)` in the SOURCE string — what {@link xmlFragmentOf} slices.
90
+ *
91
+ * `end` is the offset just past this element's close tag (or past `/>`). For
92
+ * an element the file never closed it is the end of what was read, which is
93
+ * the honest answer and keeps the slice well-formed enough to re-parse.
94
+ */
95
+ range: [number, number];
96
+ /**
97
+ * Everything inside the element IN DOCUMENT ORDER: child elements, character
98
+ * data (text and CDATA, decoded, whitespace included), comments and
99
+ * processing instructions. {@link text} and {@link children} are the two
100
+ * convenient projections of it; this is what a reader needs when order or
101
+ * markup that is not an element matters (`<text>a<tspan>b</tspan>c</text>`,
102
+ * a vendor comment carried back verbatim). Always present on a node
103
+ * {@link readXml} produced; absent on one a caller assembled.
104
+ */
105
+ content?: XmlContent[];
106
+ }
107
+ /** One entry of {@link XmlNode.content}. */
108
+ export type XmlContent = XmlNode
109
+ /** Text and CDATA are one kind: a consumer escapes both the same way. */
110
+ | {
111
+ kind: 'text';
112
+ value: string;
113
+ } | {
114
+ kind: 'comment';
115
+ value: string;
116
+ } | {
117
+ kind: 'pi';
118
+ /** The target, `xml-stylesheet` in `<?xml-stylesheet href="…"?>`. */
119
+ target: string;
120
+ /** The rest, leading whitespace dropped, as the DOM's `data` has it. */
121
+ data: string;
122
+ };
123
+ /** How strictly {@link readXml} reads. */
124
+ export interface XmlReadOptions {
125
+ /**
126
+ * Two XML 1.0 rules the tolerant default leaves out, for a caller that used
127
+ * to read with `DOMParser` and must keep its answers (BPMN, the SVG sketch):
128
+ * attribute values are whitespace-normalized as §3.3.3 makes mandatory (a
129
+ * literal tab or newline reads as a space, a character reference keeps its
130
+ * character), and a second top-level element is a note. Off by default, so
131
+ * the XMI and draw.io readers keep reading exactly what they read before.
132
+ */
133
+ conformant?: boolean;
134
+ /**
135
+ * Elements, attributes, character runs, comments, instructions and notes,
136
+ * counted together. Default {@link XML_MAX_NODES}.
137
+ */
138
+ maxNodes?: number;
139
+ /**
140
+ * Characters of decoded text, attribute values, comments and instructions.
141
+ * Default {@link XML_MAX_CHARACTERS}.
142
+ */
143
+ maxCharacters?: number;
144
+ }
145
+ /**
146
+ * Safe for a function with 256 MiB and two seconds: the largest file of the
147
+ * corpus holds a few thousand nodes, a reading at the cap about 40 MiB.
148
+ */
149
+ export declare const XML_MAX_NODES = 200000;
150
+ /** Notes written in full; the rest are counted in one last note. */
151
+ export declare const XML_MAX_NOTES = 100;
152
+ /** 2 MiB of decoded characters, well past any drawing the canvas can show. */
153
+ export declare const XML_MAX_CHARACTERS: number;
154
+ /** The reader's one refusal; static, so a server can hand the key on. */
155
+ export declare const XML_READ_TOO_LARGE: ChromeWording;
156
+ /** A document, and everything the reader had to complain about to read it. */
157
+ export interface XmlDocument {
158
+ /** The first top-level element, or `undefined` for a document with none. */
159
+ root?: XmlNode;
160
+ /**
161
+ * Every top-level element, in order.
162
+ *
163
+ * A well-formed document has exactly one. A file that has been concatenated,
164
+ * truncated or hand-edited has none or several, and the reader says what it
165
+ * found rather than deciding which one was meant.
166
+ */
167
+ roots: XmlNode[];
168
+ /** One line each, in the user's words — see the header on tolerance. */
169
+ notes: string[];
170
+ }
171
+ /**
172
+ * Character data as its characters — the five named entities and any numeric
173
+ * reference.
174
+ *
175
+ * An entity this reader does not know (`&nbsp;`, a DTD-declared one) is left
176
+ * EXACTLY as it was written, unresolved and unannounced. Two reasons, and the
177
+ * second is the one that matters: resolving it would need the DTD the file
178
+ * does not ship, and dropping it would lose a character; leaving the reference
179
+ * standing means a later re-serialization writes back what the file said, which
180
+ * is the promise `xmlFragmentOf` makes and this keeps true for text as well.
181
+ */
182
+ export declare function decodeXmlText(value: string): string;
183
+ /**
184
+ * Read a document. Throws only past its size caps; see the header.
185
+ *
186
+ * The scan is a single left-to-right pass with an explicit stack, which is what
187
+ * makes the tolerance cheap: every recovery is "say what is wrong, and carry on
188
+ * from the next `<`", and there is no recursion to unwind. In conformant mode
189
+ * the first note STOPS the read: its callers refuse on any note, and a file
190
+ * built to raise twenty thousand of them must not get to.
191
+ */
192
+ export declare function readXml(source: string, options?: XmlReadOptions): XmlDocument;
193
+ /**
194
+ * The element's own bytes, from the string it was read from.
195
+ *
196
+ * This is what a quarantined fragment is (ADR 0012 D5): the file's text, not a
197
+ * re-rendering of this reader's tree. Comments, attribute order, prefixes and
198
+ * whitespace all survive, because none of them was ever taken apart.
199
+ */
200
+ export declare function xmlFragmentOf(source: string, node: XmlNode): string;
201
+ /**
202
+ * A node back as XML, from the TREE rather than from the source.
203
+ *
204
+ * The fallback for a fragment that has no range to slice — one assembled by a
205
+ * caller, or read out of a document this function's caller no longer holds. It
206
+ * is faithful to what the tree records and therefore drops what the tree does
207
+ * not: comments, processing instructions, and the file's own indentation.
208
+ * Prefer {@link xmlFragmentOf} whenever the source string is still in hand.
209
+ */
210
+ export declare function serializeXmlNode(node: XmlNode): string;
211
+ /** Children with this local name, whatever prefix the file gave them. */
212
+ export declare function xmlChildren(node: XmlNode, local: string): XmlNode[];
213
+ /** The first child with this local name, if any. */
214
+ export declare function xmlChild(node: XmlNode, local: string): XmlNode | undefined;
215
+ /**
216
+ * An attribute by LOCAL name — `xmi:id`, `xmi:ID` and a bare `id` all answer.
217
+ *
218
+ * Prefix-insensitive on purpose, and it is the difference between reading three
219
+ * tools and reading one: the XMI prefix is `xmi` by convention and by nothing
220
+ * else, Enterprise Architect has shipped files under `XMI`, and an
221
+ * attribute-defaulted file drops it altogether. The QUALIFIED name is still in
222
+ * `attrs` for anything that needs it, and {@link xmlFragmentOf} still writes
223
+ * back what the file said.
224
+ *
225
+ * The first match in document order wins, which only matters for a file that
226
+ * spells the same attribute twice under two prefixes.
227
+ */
228
+ export declare function xmlAttr(node: XmlNode, local: string): string | undefined;
229
+ /** Every `xmlns` / `xmlns:*` declaration on this element, by prefix (`''`). */
230
+ export declare function xmlNamespaces(node: XmlNode): Record<string, string>;
231
+ /**
232
+ * Every element under `node`, at any depth, in document order.
233
+ *
234
+ * An explicit stack rather than recursion: the depth of a file is whatever its
235
+ * author chose, and a hostile one nested a hundred thousand deep must cost a
236
+ * loop, not the call stack.
237
+ */
238
+ export declare function xmlDescendants(node: XmlNode): XmlNode[];