reactive-md 0.9.0 → 0.9.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 (162) hide show
  1. package/CHANGELOG-ch.md +13 -0
  2. package/CHANGELOG.md +13 -0
  3. package/README-ch.md +6 -6
  4. package/README-en.md +6 -6
  5. package/README.md +6 -6
  6. package/SECURITY-ch.md +3 -3
  7. package/SECURITY.md +3 -3
  8. package/THIRD_PARTY_NOTICES.md +111 -1
  9. package/cli/build.mjs +1 -0
  10. package/cli/init.mjs +1 -1
  11. package/dist-library/{LocalDocumentView-K7Y-2bRJ.js → LocalDocumentView-sthUP0ct.js} +10 -10
  12. package/dist-library/LocalDocumentViewCore-GiWV3bey.js +9829 -0
  13. package/dist-library/LocalReactiveDocumentCore-ZjQSGyHE.js +275 -0
  14. package/dist-library/{authoring-Co_TiE-P.js → authoring-Dsune4Hy.js} +40 -20
  15. package/dist-library/{compile-LhpTKqCR.js → compile-wUv8KEge.js} +1 -1
  16. package/dist-library/{compiler-core-DTxY-qYz.js → compiler-core-As_m-MNm.js} +2449 -1742
  17. package/dist-library/{compiler-DfGbQhyD.js → compiler-eOfcinZs.js} +19 -19
  18. package/dist-library/{component-state-BBJ08vML.js → component-state-C52ZFJGl.js} +1 -1
  19. package/dist-library/{config-BUo-8O5C.js → config-BadfhjdP.js} +1 -1
  20. package/dist-library/{config-validation-C5kJYk-J.js → config-validation-F47AcE6o.js} +49 -1
  21. package/dist-library/{controls-BWiLLtBO.js → controls-CcT6n7k_.js} +2433 -2409
  22. package/dist-library/{coordinate-BSl6enWV.js → coordinate-CWS9p5q_.js} +108 -107
  23. package/dist-library/{data-table-DfvytZKQ.js → data-table-Bgccxd7h.js} +68 -65
  24. package/dist-library/{display-lw3BT1TA.js → display-B-VhqVND.js} +1 -1
  25. package/dist-library/{export-C7IDW9ul.js → export-BqVmTXm8.js} +145 -87
  26. package/dist-library/{gallery-B8kSt1oI.js → gallery-CY6mTx8i.js} +151 -147
  27. package/dist-library/html-CNT4KD-2.js +757 -0
  28. package/dist-library/{incremental-D_6vwAAE.js → incremental-Dv0FSp_U.js} +404 -142
  29. package/dist-library/layout-C0YlEPGr.js +562 -0
  30. package/dist-library/{mount-preset-C5s9ebEH.js → mount-preset-KxvtKgJb.js} +2 -2
  31. package/dist-library/options-1aDLK7JY.js +121 -0
  32. package/dist-library/{package-core-D0POW4Gd.js → package-core-WFK1RhAZ.js} +3 -3
  33. package/dist-library/{parser-standard-OToYcOBL.js → parser-standard-Yuf3A_VI.js} +3270 -3778
  34. package/dist-library/react-D5iGiUdL.js +7 -0
  35. package/dist-library/reactive-md-authoring.js +16 -18
  36. package/dist-library/reactive-md-build.js +51 -51
  37. package/dist-library/reactive-md-compiler-standard.js +10 -9
  38. package/dist-library/reactive-md-compiler.js +3 -3
  39. package/dist-library/reactive-md-export.js +4 -4
  40. package/dist-library/reactive-md-minimal-react-preset.js +3 -3
  41. package/dist-library/reactive-md-pdf.js +127 -3
  42. package/dist-library/reactive-md-plugin-chart.js +2 -2
  43. package/dist-library/reactive-md-plugin-data.js +4 -4
  44. package/dist-library/reactive-md-plugin-diagram.js +3 -3
  45. package/dist-library/reactive-md-plugin-forms.js +2 -2
  46. package/dist-library/reactive-md-plugin-gallery.js +2 -2
  47. package/dist-library/reactive-md-plugin-navigation.js +2 -2
  48. package/dist-library/reactive-md-plugin-network.js +117 -115
  49. package/dist-library/reactive-md-plugin-plot.js +3 -3
  50. package/dist-library/reactive-md-react-minimal.js +4 -4
  51. package/dist-library/reactive-md-react-server.js +6 -6
  52. package/dist-library/reactive-md-react-unstyled.js +10 -11
  53. package/dist-library/reactive-md-react.js +10 -11
  54. package/dist-library/reactive-md-sdk.js +3 -3
  55. package/dist-library/reactive-md-standalone-configured.js +2 -2
  56. package/dist-library/reactive-md-standalone-host.js +2 -2
  57. package/dist-library/reactive-md-testing-browser.js +2 -2
  58. package/dist-library/reactive-md-testing-react.js +6 -6
  59. package/dist-library/reactive-md-testing.js +4 -4
  60. package/dist-library/reactive-md.js +280 -193
  61. package/dist-library/{registry-05JiqmEp.js → registry-B9NGct4d.js} +1 -1
  62. package/dist-library/{resources-IeJomeUT.js → resources-D2GDQS0p.js} +1 -1
  63. package/dist-library/{runtime-CuOyRe9f.js → runtime-kcA7bG7G.js} +341 -341
  64. package/dist-library/{schema-C-AeByPp.js → schema-BufhKUSM.js} +5 -5
  65. package/dist-library/{sdk-core-BJLJaVR5.js → sdk-core-BoJT1SIt.js} +490 -150
  66. package/dist-library/{session-core-BGka5D1J.js → session-core-nmJHuR9c.js} +170 -156
  67. package/dist-library/{shareable-jkGi2g6y.js → shareable-DpbE-59H.js} +207 -242
  68. package/dist-library/types/authoring/catalog.d.ts +1 -2
  69. package/dist-library/types/components/shared/visual-frame.d.ts +6 -2
  70. package/dist-library/types/local/compilation/compiler-capabilities.d.ts +3 -0
  71. package/dist-library/types/local/compilation/compiler-core.d.ts +11 -3
  72. package/dist-library/types/local/compilation/compiler-services.d.ts +8 -4
  73. package/dist-library/types/local/compilation/compiler.d.ts +3 -3
  74. package/dist-library/types/local/compilation/session/incremental.d.ts +20 -5
  75. package/dist-library/types/local/compilation/streaming.d.ts +27 -0
  76. package/dist-library/types/local/configuration/capability-policy.d.ts +3 -0
  77. package/dist-library/types/local/configuration/diagnostic-messages.d.ts +48 -0
  78. package/dist-library/types/local/configuration/options-core.d.ts +1 -2
  79. package/dist-library/types/local/configuration/options.d.ts +1 -0
  80. package/dist-library/types/local/css/author-css.d.ts +66 -0
  81. package/dist-library/types/local/html/extended-fragment.d.ts +41 -0
  82. package/dist-library/types/local/html/html.d.ts +39 -3
  83. package/dist-library/types/local/index.d.ts +1 -1
  84. package/dist-library/types/local/parsing/author-markdown.d.ts +11 -0
  85. package/dist-library/types/local/parsing/parse-session.d.ts +2 -2
  86. package/dist-library/types/local/parsing/parser-convert.d.ts +2 -1
  87. package/dist-library/types/local/parsing/parser-core.d.ts +8 -1
  88. package/dist-library/types/local/parsing/parser.d.ts +2 -2
  89. package/dist-library/types/local/rendering/document/ExtendedHtmlFragment.d.ts +14 -0
  90. package/dist-library/types/local/rendering/document/LocalDocumentViewCore.d.ts +25 -1
  91. package/dist-library/types/local/rendering/document/LocalReactiveDocumentCore.d.ts +1 -1
  92. package/dist-library/types/local/rendering/document/use-author-script.d.ts +3 -0
  93. package/dist-library/types/local/rendering/document/view-render-context.d.ts +11 -1
  94. package/dist-library/types/local/runtime/author-script-protocol.d.ts +59 -0
  95. package/dist-library/types/local/transport/worker.d.ts +27 -4
  96. package/dist-library/types/local/types.d.ts +52 -16
  97. package/dist-library/types/react/component-api.d.ts +10 -1
  98. package/dist-library/types/react/component-utils.d.ts +9 -1
  99. package/dist-library/types/react/sdk-core.d.ts +4 -1
  100. package/dist-library/types/shareable.d.ts +5 -4
  101. package/dist-library/types/standalone/prepare.d.ts +1 -1
  102. package/dist-library/types/standalone/session-core.d.ts +3 -2
  103. package/dist-library/{types-BFC5rzC4.js → types-BeNtPqdY.js} +1 -1
  104. package/dist-library/{validation-BlDL2uD9.js → validation-BEBA_HvS.js} +88 -72
  105. package/dist-library/{visual-frame-G8PHoj1e.js → visual-frame-CyV1FXzs.js} +6 -5
  106. package/dist-library/{visuals-BkYRmYGO.js → visuals-BZbZYA7w.js} +24181 -24180
  107. package/dist-standalone/reactive-md-standalone.js +124 -117
  108. package/docs/README-ch.md +2 -1
  109. package/docs/README.md +2 -1
  110. package/docs/compatibility/compatibility-ch.md +6 -6
  111. package/docs/compatibility/compatibility-en.md +6 -6
  112. package/docs/compatibility/source-versioning-ch.md +1 -1
  113. package/docs/compatibility/source-versioning-en.md +1 -1
  114. package/docs/development/component-development-ch.md +2 -2
  115. package/docs/development/component-development-en.md +2 -2
  116. package/docs/development/component-development-reference-ch.md +2 -2
  117. package/docs/development/component-development-reference-en.md +2 -2
  118. package/docs/development/component-protocol-ch.md +2 -2
  119. package/docs/development/component-protocol-en.md +2 -2
  120. package/docs/development/extension-tutorial-ch.md +3 -3
  121. package/docs/development/extension-tutorial-en.md +3 -3
  122. package/docs/integration/author-tools-ch.md +1 -1
  123. package/docs/integration/author-tools-en.md +1 -1
  124. package/docs/integration/compiler-ch.md +3 -1
  125. package/docs/integration/compiler-en.md +3 -1
  126. package/docs/integration/editor-ch.md +3 -3
  127. package/docs/integration/editor-en.md +3 -3
  128. package/docs/integration/extension-sdk-ch.md +2 -2
  129. package/docs/integration/extension-sdk-en.md +2 -2
  130. package/docs/integration/local-integration-ch.md +130 -8
  131. package/docs/integration/local-integration-en.md +130 -8
  132. package/docs/integration/shareable-export-ch.md +4 -2
  133. package/docs/integration/shareable-export-en.md +4 -2
  134. package/docs/reference/html-compatibility-ch.md +20 -67
  135. package/docs/reference/html-compatibility-en.md +19 -64
  136. package/docs/reference/public-api-ch.md +10 -7
  137. package/docs/reference/public-api-en.md +10 -7
  138. package/docs/releases/release-0.9.1-ch.md +29 -0
  139. package/docs/releases/release-0.9.1-en.md +29 -0
  140. package/examples/component-package/README-ch.md +1 -1
  141. package/examples/component-package/README.md +1 -1
  142. package/examples/game-2048-package/README-ch.md +1 -1
  143. package/examples/game-2048-package/README.md +1 -1
  144. package/examples/integration/README-ch.md +21 -2
  145. package/examples/integration/README.md +21 -2
  146. package/examples/integration/extension-sdk/README-ch.md +1 -1
  147. package/examples/integration/extension-sdk/README.md +1 -1
  148. package/examples/integration/streaming/index.html +48 -0
  149. package/examples/integration/streaming/main.js +175 -0
  150. package/examples/integration/streaming/package.json +13 -0
  151. package/examples/integration/streaming/worker.js +3 -0
  152. package/examples/minimal-extension/README-ch.md +3 -3
  153. package/examples/minimal-extension/README.md +3 -3
  154. package/examples/tetris-package/README-ch.md +1 -1
  155. package/examples/tetris-package/README.md +1 -1
  156. package/package.json +6 -1
  157. package/dist-library/LocalDocumentViewCore-BLG4hMuO.js +0 -9535
  158. package/dist-library/LocalReactiveDocumentCore-DVQ6WA9G.js +0 -259
  159. package/dist-library/component-utils-BvHL8VGt.js +0 -298
  160. package/dist-library/layout-C22VjZh0.js +0 -542
  161. package/dist-library/options-CdSKOi7p.js +0 -116
  162. package/dist-library/react-LY5qsVeP.js +0 -7
@@ -1,15 +1,205 @@
1
1
  import { r as e } from "./latex-1w7aQgD5.js";
2
2
  import "./preset-core-CKc5YXSM.js";
3
- import { t } from "./compile-LhpTKqCR.js";
4
- import { s as n } from "./compiler-core-DTxY-qYz.js";
5
- import { n as r } from "./display-lw3BT1TA.js";
6
- import { i, n as a, r as o } from "./parser-standard-OToYcOBL.js";
7
- import { s } from "./config-BUo-8O5C.js";
8
- import { n as c, t as l } from "./options-CdSKOi7p.js";
9
- import { n as u } from "./compiler-DfGbQhyD.js";
10
- import { c as d, r as f } from "./schema-C-AeByPp.js";
3
+ import { t } from "./compile-wUv8KEge.js";
4
+ import { d as n, f as r } from "./compiler-core-As_m-MNm.js";
5
+ import { n as i } from "./display-B-VhqVND.js";
6
+ import { i as a, n as o, r as s } from "./parser-standard-Yuf3A_VI.js";
7
+ import { s as c } from "./config-BadfhjdP.js";
8
+ import { r as l, t as u } from "./options-1aDLK7JY.js";
9
+ import { n as d } from "./compiler-eOfcinZs.js";
10
+ import { c as f, r as p } from "./schema-BufhKUSM.js";
11
+ function m(e, t) {
12
+ if (typeof t != "string" || t.length > 1e6) return !0;
13
+ if (e.severity !== "error") return !1;
14
+ let n = e.code, r = (e) => n === e || n.startsWith(`${e}.`);
15
+ return r("local.options") || r("local.budget") || r("local.version") || r("local.html") || r("local.parse") || r("local.security") || r("local.config") || r("local.registry") || r("local.capability");
16
+ }
17
+ function h(e, t) {
18
+ let n = e.filter((e) => !m(e, t)), r = [];
19
+ for (let i of e) m(i, t) && (i.code === "local.html" && n.some((e) => e.range.start === i.range.start && e.range.end === i.range.end) ? n.push(i) : r.push(i));
20
+ return {
21
+ definite: r,
22
+ transient: n
23
+ };
24
+ }
25
+ function g(e) {
26
+ return `${e.code}:${e.range.start}:${e.range.end}`;
27
+ }
28
+ function _(e, t) {
29
+ return e.range.start - t.range.start || e.range.end - t.range.end || e.line - t.line || e.column - t.column || (e.code < t.code ? -1 : +(e.code > t.code));
30
+ }
31
+ function v(e) {
32
+ let t = /* @__PURE__ */ new Map();
33
+ for (let n of e) for (let e of n) {
34
+ let n = g(e);
35
+ t.has(n) || t.set(n, e);
36
+ }
37
+ return [...t.values()].sort(_);
38
+ }
39
+ function y(e, t) {
40
+ let n = t.filter((e) => e.code !== "local.author.unclosed"), r = t.filter((e) => e.code === "local.author.unclosed"), i = new Set(n.map(g));
41
+ return {
42
+ diagnostics: n,
43
+ transientDiagnostics: v([...e, r]).filter((e) => !i.has(g(e)))
44
+ };
45
+ }
46
+ function b(e, t) {
47
+ if (e.length !== t.length) return !1;
48
+ for (let n = 0; n < e.length; n += 1) if (e[n].start !== t[n].start || e[n].end !== t[n].end) return !1;
49
+ return !0;
50
+ }
51
+ function x(e, t) {
52
+ return e.length === 1 && e[0].start === 0 && e[0].end === t;
53
+ }
54
+ function S(e, t, n) {
55
+ for (let r of e) if (r.range.start <= t && r.range.end >= n) return r;
56
+ }
57
+ function C(e, t, n) {
58
+ let r = t.length, i = Math.max(0, Math.min(r, e.range.start)), a = S(n, i, Math.max(i, Math.min(r, e.range.end)));
59
+ if (a) return {
60
+ start: a.range.start,
61
+ end: a.range.end
62
+ };
63
+ let o = i;
64
+ for (; o > 0 && t[o - 1] !== "\n";) --o;
65
+ let s = i;
66
+ for (; s < r && t[s] !== "\n";) s += 1;
67
+ return s < r && (s += 1), s > o ? {
68
+ start: o,
69
+ end: s
70
+ } : {
71
+ start: i,
72
+ end: r
73
+ };
74
+ }
75
+ function w(e, t) {
76
+ let n = t;
77
+ for (let t of e) t.range.start < n && (n = t.range.start);
78
+ return n;
79
+ }
80
+ function T(e, t, n, i, a) {
81
+ let o = [...e];
82
+ for (let e of t) o.push(C(e, i, n?.nodes ?? []));
83
+ let s = r(o, i.length), c = w(t, i.length);
84
+ return a && (s = r([...s, {
85
+ start: c,
86
+ end: i.length
87
+ }], i.length)), b(s, e) && (s = r([...e, {
88
+ start: c,
89
+ end: i.length
90
+ }], i.length)), s;
91
+ }
92
+ function E(e, t) {
93
+ for (let [n, r] of Object.entries(t)) typeof r == "number" && Number.isFinite(r) && (e[n] = (e[n] ?? 0) + r);
94
+ }
95
+ function ee(e, t, n) {
96
+ let r = [], i = [], a = {}, o, s = 0;
97
+ for (let c = 1; c <= 6; c += 1) {
98
+ s = c, o = d(e, t, n, r), E(a, o.timings);
99
+ let l = o.result;
100
+ if (l.ok) {
101
+ let e = y(i, l.diagnostics);
102
+ return {
103
+ result: {
104
+ ...l,
105
+ status: "partial",
106
+ ...e
107
+ },
108
+ ...o.parsed ? { parsed: o.parsed } : {},
109
+ transientDiagnostics: e.transientDiagnostics,
110
+ literalRanges: [...r],
111
+ attempts: s,
112
+ timings: a
113
+ };
114
+ }
115
+ let { definite: u, transient: f } = h(l.diagnostics, e);
116
+ if (u.length > 0) {
117
+ let e = v([...i, f]);
118
+ return {
119
+ result: {
120
+ ok: !1,
121
+ diagnostics: u,
122
+ ...l.recoveries ? { recoveries: [...l.recoveries] } : {},
123
+ status: "failed",
124
+ transientDiagnostics: e
125
+ },
126
+ ...o.parsed ? { parsed: o.parsed } : {},
127
+ transientDiagnostics: e,
128
+ literalRanges: [...r],
129
+ attempts: s,
130
+ timings: a
131
+ };
132
+ }
133
+ if (i.push(f), c === 6) break;
134
+ let p = T(r, f, o.parsed, e, c >= 5);
135
+ if (b(p, r)) break;
136
+ r = p, x(r, e.length);
137
+ }
138
+ if (typeof e == "string" && e.length <= 1e6 && !x(r, e.length)) {
139
+ let o = [{
140
+ start: 0,
141
+ end: e.length
142
+ }], c = d(e, t, n, o);
143
+ if (E(a, c.timings), s += 1, c.result.ok) {
144
+ let e = y(i, c.result.diagnostics);
145
+ return {
146
+ result: {
147
+ ...c.result,
148
+ status: "partial",
149
+ ...e
150
+ },
151
+ ...c.parsed ? { parsed: c.parsed } : {},
152
+ transientDiagnostics: e.transientDiagnostics,
153
+ literalRanges: o,
154
+ attempts: s,
155
+ timings: a
156
+ };
157
+ }
158
+ let { definite: l, transient: u } = h(c.result.diagnostics, e), f = v([...i, u]);
159
+ if (l.length > 0) return {
160
+ result: {
161
+ ok: !1,
162
+ diagnostics: l,
163
+ ...c.result.recoveries ? { recoveries: [...c.result.recoveries] } : {},
164
+ status: "failed",
165
+ transientDiagnostics: f
166
+ },
167
+ ...c.parsed ? { parsed: c.parsed } : {},
168
+ transientDiagnostics: f,
169
+ literalRanges: o,
170
+ attempts: s,
171
+ timings: a
172
+ };
173
+ r = o;
174
+ }
175
+ let c = o, l = v(i);
176
+ return {
177
+ result: {
178
+ ok: !1,
179
+ diagnostics: c !== void 0 && c.result.ok === !1 && c.result.diagnostics.length > 0 ? [...c.result.diagnostics] : l.length > 0 ? l : [{
180
+ code: "local.parse",
181
+ message: "The streaming snapshot could not be compiled.",
182
+ severity: "error",
183
+ range: {
184
+ start: 0,
185
+ end: 0
186
+ },
187
+ line: 1,
188
+ column: 1
189
+ }],
190
+ ...c?.result.recoveries ? { recoveries: [...c.result.recoveries] } : {},
191
+ status: "failed",
192
+ transientDiagnostics: l
193
+ },
194
+ ...c?.parsed ? { parsed: c.parsed } : {},
195
+ transientDiagnostics: l,
196
+ literalRanges: [...r],
197
+ attempts: s,
198
+ timings: a
199
+ };
200
+ }
11
201
  // src/local/compilation/session/semantic-cache.ts
12
- var p = () => ({
202
+ var D = () => ({
13
203
  expressionsCompiled: 0,
14
204
  expressionsReused: 0,
15
205
  typesInferred: 0,
@@ -22,18 +212,18 @@ var p = () => ({
22
212
  formulasReused: 0,
23
213
  displaysInspected: 0,
24
214
  displaysReused: 0
25
- }), m = class {
215
+ }), te = class {
26
216
  capacity;
27
217
  maxWeight;
28
218
  key;
29
219
  values = /* @__PURE__ */ new Map();
30
220
  weight = 0;
31
- counts = p();
221
+ counts = D();
32
222
  constructor(e = 16384, t = 8e6) {
33
223
  this.capacity = e, this.maxWeight = t;
34
224
  }
35
225
  begin(e) {
36
- this.key !== e && (this.clear(), this.key = e), this.counts = p();
226
+ this.key !== e && (this.clear(), this.key = e), this.counts = D();
37
227
  }
38
228
  get stats() {
39
229
  return {
@@ -42,7 +232,7 @@ var p = () => ({
42
232
  };
43
233
  }
44
234
  clear() {
45
- this.values.clear(), this.weight = 0, this.key = void 0, this.counts = p();
235
+ this.values.clear(), this.weight = 0, this.key = void 0, this.counts = D();
46
236
  }
47
237
  get(e) {
48
238
  let t = this.values.get(e);
@@ -91,16 +281,16 @@ var p = () => ({
91
281
  return this.counts.formulasCompiled++, this.put(n, i), i;
92
282
  }
93
283
  display(e, t) {
94
- let n = "display:" + JSON.stringify([e, t]), i = this.get(n);
95
- if (i) return this.counts.displaysReused++, i;
96
- let a = r(e, t);
284
+ let n = "display:" + JSON.stringify([e, t]), r = this.get(n);
285
+ if (r) return this.counts.displaysReused++, r;
286
+ let a = i(e, t);
97
287
  return this.counts.displaysInspected++, this.put(n, a), a;
98
288
  }
99
- }, h = 128, g = 512, _ = 32, v = 131072, y = (e) => JSON.parse(JSON.stringify(e));
100
- function b(e) {
289
+ }, ne = 128, re = 512, ie = 32, ae = 131072, O = (e) => JSON.parse(JSON.stringify(e));
290
+ function oe(e) {
101
291
  return typeof e == "object" && !!e && e.strict === !1;
102
292
  }
103
- var x = class {
293
+ var k = class {
104
294
  limit;
105
295
  byteLimit;
106
296
  entries = /* @__PURE__ */ new Map();
@@ -128,13 +318,13 @@ var x = class {
128
318
  clear() {
129
319
  this.entries.clear(), this.bytes = 0;
130
320
  }
131
- }, S = class {
321
+ }, se = class {
132
322
  disposed = !1;
133
323
  optionKey;
134
324
  recoveryMode;
135
- plans = new x(h, 524288);
136
- inline = new x(g, 262144);
137
- trees = new x(_, 524288);
325
+ plans = new k(ne, 524288);
326
+ inline = new k(re, 262144);
327
+ trees = new k(ie, 524288);
138
328
  counts = {
139
329
  hits: 0,
140
330
  misses: 0,
@@ -145,10 +335,10 @@ var x = class {
145
335
  reusedItemNodes: 0,
146
336
  reusedAst: 0
147
337
  };
148
- parse(e, t, n, r) {
338
+ parse(e, t, n, r, i) {
149
339
  if (this.disposed) throw Error("Local parse session is disposed");
150
- let i = l(t), a = b(t);
151
- return (i !== this.optionKey || a !== this.recoveryMode) && (this.optionKey = i, this.recoveryMode = a, this.reset()), d(e, t, n, this, r);
340
+ let a = u(t), o = oe(t);
341
+ return (a !== this.optionKey || o !== this.recoveryMode) && (this.optionKey = a, this.recoveryMode = o, this.reset()), i && i.length > 0 ? f(e, t, n, void 0, void 0, i) : f(e, t, n, this, r);
152
342
  }
153
343
  clear() {
154
344
  this.optionKey = void 0, this.recoveryMode = void 0, this.reset();
@@ -193,9 +383,9 @@ var x = class {
193
383
  return this.lookup(this.inline, e);
194
384
  }
195
385
  writeInline(e, t) {
196
- e.length > v || this.inline.write(y(e), t?.map((e) => ({
386
+ e.length > ae || this.inline.write(O(e), t?.map((e) => ({
197
387
  ...e,
198
- value: y(e.value)
388
+ value: O(e.value)
199
389
  })));
200
390
  }
201
391
  notePlanReuse() {
@@ -217,8 +407,8 @@ var x = class {
217
407
  let r = e.read(t);
218
408
  return r.hit ? (this.counts.hits += 1, n && (this.counts.reusedAst += 1)) : this.counts.misses += 1, r;
219
409
  }
220
- }, C = /* @__PURE__ */ new WeakSet();
221
- function w(e, t) {
410
+ }, A = /* @__PURE__ */ new WeakSet();
411
+ function j(e, t) {
222
412
  let n = 0, r = 0, i = /* @__PURE__ */ new WeakMap(), a = [], o = (e, t, n) => {
223
413
  e && (Object.defineProperty(e.output, t, {
224
414
  value: n,
@@ -229,7 +419,7 @@ function w(e, t) {
229
419
  }, s = (e, t, r, o) => {
230
420
  if (typeof t != "object" || !t) return t;
231
421
  if (e === t) return n++, e;
232
- if (e === void 0 && C.has(t)) return n++, t;
422
+ if (e === void 0 && A.has(t)) return n++, t;
233
423
  if (i.has(t)) return i.get(t);
234
424
  let s = Array.isArray(t), c = typeof e == "object" && e && Array.isArray(e) === s ? e : void 0, l = Object.keys(t), u = c ? Object.keys(c) : [], d = s ? Array(t.length) : {};
235
425
  i.set(t, d);
@@ -256,7 +446,7 @@ function w(e, t) {
256
446
  }
257
447
  a.pop();
258
448
  let t;
259
- e.equal ? (t = e.before, n++) : (r++, t = Object.isFrozen(e.after) ? Object.freeze(e.output) : e.output, C.add(t)), i.set(e.after, t), e.parent ? o(e.parent, e.key, t) : c = t;
449
+ e.equal ? (t = e.before, n++) : (r++, t = Object.isFrozen(e.after) ? Object.freeze(e.output) : e.output, A.add(t)), i.set(e.after, t), e.parent ? o(e.parent, e.key, t) : c = t;
260
450
  }
261
451
  return {
262
452
  value: c,
@@ -264,7 +454,7 @@ function w(e, t) {
264
454
  created: r
265
455
  };
266
456
  }
267
- function T(e, t) {
457
+ function ce(e, t) {
268
458
  if (!e?.ok || !t.ok) return 0;
269
459
  let n = /* @__PURE__ */ new Set(), r = [...e.document.nodes];
270
460
  for (; r.length;) {
@@ -279,7 +469,7 @@ function T(e, t) {
279
469
  return i;
280
470
  }
281
471
  // src/local/compilation/session/row-reuse.ts
282
- function E(e) {
472
+ function M(e) {
283
473
  if (e.nodes.length !== 1) return;
284
474
  let t = e.nodes[0], n, r;
285
475
  if (t.type === "list") n = "item", r = "listItem";
@@ -305,25 +495,25 @@ function E(e) {
305
495
  rows: a
306
496
  };
307
497
  }
308
- function D(e, t) {
498
+ function N(e, t) {
309
499
  if (e === t) return !0;
310
500
  if (typeof e != "object" || typeof t != "object" || e === null || t === null || Array.isArray(e) !== Array.isArray(t)) return !1;
311
501
  let n = Object.keys(e), r = Object.keys(t);
312
502
  if (n.length !== r.length) return !1;
313
- for (let r of n) if (!Object.hasOwn(t, r) || !D(e[r], t[r])) return !1;
503
+ for (let r of n) if (!Object.hasOwn(t, r) || !N(e[r], t[r])) return !1;
314
504
  return !0;
315
505
  }
316
- function O(e, t, n, r) {
506
+ function P(e, t, n, r) {
317
507
  if (e.type !== t.type || e.range.start - n !== t.range.start - r || e.range.end - n !== t.range.end - r) return !1;
318
508
  let i = Object.keys(e), a = Object.keys(t);
319
509
  if (i.length !== a.length) return !1;
320
- for (let n of i) if (n !== "id" && n !== "range" && n !== "children" && (!Object.hasOwn(t, n) || !D(e[n], t[n]))) return !1;
510
+ for (let n of i) if (n !== "id" && n !== "range" && n !== "children" && (!Object.hasOwn(t, n) || !N(e[n], t[n]))) return !1;
321
511
  let o = e.children ?? [], s = t.children ?? [];
322
512
  if (o.length !== s.length) return !1;
323
- for (let e = 0; e < o.length; e++) if (!O(o[e], s[e], n, r)) return !1;
513
+ for (let e = 0; e < o.length; e++) if (!P(o[e], s[e], n, r)) return !1;
324
514
  return !0;
325
515
  }
326
- function k(e, t) {
516
+ function F(e, t) {
327
517
  let n = {
328
518
  ...e,
329
519
  range: {
@@ -331,14 +521,14 @@ function k(e, t) {
331
521
  end: e.range.end + t
332
522
  }
333
523
  };
334
- return e.attrs && (n.attrs = { ...e.attrs }), e.align && (n.align = [...e.align]), e.children && (n.children = e.children.map((e) => k(e, t))), n;
524
+ return e.attrs && (n.attrs = { ...e.attrs }), e.align && (n.align = [...e.align]), e.children && (n.children = e.children.map((e) => F(e, t))), n;
335
525
  }
336
- function A(e, t) {
337
- if (t.add(e.id), e.children) for (let n of e.children) A(n, t);
526
+ function I(e, t) {
527
+ if (t.add(e.id), e.children) for (let n of e.children) I(n, t);
338
528
  }
339
- function j(e, t) {
529
+ function le(e, t) {
340
530
  if (!e) return;
341
- let n = E(e), r = E(t);
531
+ let n = M(e), r = M(t);
342
532
  if (!n || !r || n.kind !== r.kind) return;
343
533
  let i = n.rows, a = r.rows, o = Math.min(i.length, a.length), s = 0;
344
534
  for (; s < o && i[s].text === a[s].text;) s += 1;
@@ -349,9 +539,9 @@ function j(e, t) {
349
539
  let n;
350
540
  if (t < s ? n = t : t >= a.length - c && (n = i.length - (a.length - t)), n === void 0) return e.node;
351
541
  let r = i[n];
352
- if (!O(r.node, e.node, r.node.range.start, e.node.range.start)) return e.node;
353
- let o = e.node.range.start - r.node.range.start, d = o === 0 ? r.node : k(r.node, o);
354
- return u += 1, A(d, l), d;
542
+ if (!P(r.node, e.node, r.node.range.start, e.node.range.start)) return e.node;
543
+ let o = e.node.range.start - r.node.range.start, d = o === 0 ? r.node : F(r.node, o);
544
+ return u += 1, I(d, l), d;
355
545
  });
356
546
  if (!u) return;
357
547
  let f = {
@@ -367,14 +557,42 @@ function j(e, t) {
367
557
  };
368
558
  }
369
559
  // src/local/compilation/session/incremental.ts
370
- function M(e) {
560
+ function L(e) {
371
561
  return typeof e == "object" && !!e && e.strict === !1;
372
562
  }
373
- function N(e) {
563
+ function R(e) {
374
564
  return Object.hasOwn(e, "recoveries") && e.recoveries !== void 0;
375
565
  }
376
- var P = o.configure(a), F = "\n\n<!-- incremental-boundary -->\n\n";
377
- function I(e) {
566
+ function z(e) {
567
+ return e === "streaming" || e === "final" ? e : void 0;
568
+ }
569
+ function ue() {
570
+ return {
571
+ ok: !1,
572
+ status: "failed",
573
+ diagnostics: [{
574
+ code: "local.options.invalid",
575
+ message: "Compile option sourcePhase must be \"streaming\" or \"final\".",
576
+ severity: "error",
577
+ range: {
578
+ start: 0,
579
+ end: 0
580
+ },
581
+ line: 1,
582
+ column: 1,
583
+ messageKey: "local.options.invalid.source-phase"
584
+ }]
585
+ };
586
+ }
587
+ function de(e) {
588
+ try {
589
+ return typeof e == "object" && e ? z(e.sourcePhase) : void 0;
590
+ } catch {
591
+ return;
592
+ }
593
+ }
594
+ var B = s.configure(o), V = "\n\n<!-- incremental-boundary -->\n\n";
595
+ function H(e) {
378
596
  let t = [], n = [...e].reverse();
379
597
  for (; n.length;) {
380
598
  let e = n.pop();
@@ -382,7 +600,7 @@ function I(e) {
382
600
  }
383
601
  return t;
384
602
  }
385
- function L(e, t, n) {
603
+ function U(e, t, n) {
386
604
  return t === 0 && !n ? e : e.map((e) => ({
387
605
  ...e,
388
606
  id: n?.get(e.id) ?? e.id,
@@ -392,18 +610,22 @@ function L(e, t, n) {
392
610
  },
393
611
  ...e.attrs ? { attrs: { ...e.attrs } } : {},
394
612
  ...e.align ? { align: [...e.align] } : {},
395
- ...e.children ? { children: L(e.children, t, n) } : {}
613
+ ...e.children ? { children: U(e.children, t, n) } : {}
396
614
  }));
397
615
  }
398
- function R(e, t, n) {
616
+ function W(e, t, n) {
399
617
  let r = Object.create(null);
400
- for (let i of I(e)) r[n?.get(i.id) ?? i.id] = t.dependencies?.[i.id] ?? null;
618
+ for (let i of H(e)) r[n?.get(i.id) ?? i.id] = t.dependencies?.[i.id] ?? null;
401
619
  return r;
402
620
  }
403
- function z(e) {
621
+ function G(e) {
404
622
  let t = !1;
405
- for (let n of I([e])) {
623
+ for (let n of H([e])) {
406
624
  if ([
625
+ "authorCss",
626
+ "authorJavaScript",
627
+ "extendedHtmlRaw"
628
+ ].includes(n.type) || n.attrs && (Object.hasOwn(n.attrs, "css") || Object.hasOwn(n.attrs, "action-id")) || [
407
629
  "definition",
408
630
  "footnoteDefinition",
409
631
  "footnoteReference",
@@ -411,19 +633,19 @@ function z(e) {
411
633
  "imageReference"
412
634
  ].includes(n.type) || n.type === "hostComponent" || n.type === "htmlDocument" || n.type === "fallback") return "unsupported";
413
635
  if (n.type === "component") {
414
- if (["anchor", "jump"].includes(n.name ?? "") || !f(n.name ?? "")) return "unsupported";
636
+ if (["anchor", "jump"].includes(n.name ?? "") || !p(n.name ?? "")) return "unsupported";
415
637
  t = !0;
416
638
  }
417
639
  n.type === "comment" && (t = !0);
418
640
  }
419
641
  return t ? "context" : "fragment";
420
642
  }
421
- function B(e, t) {
643
+ function K(e, t) {
422
644
  let n = "", r = 0;
423
645
  for (let i of t) n += e.slice(r, i.from) + i.text.replace(/[^\r\n]/g, " "), r = i.to;
424
646
  return n + e.slice(r);
425
647
  }
426
- function V(e, t, n) {
648
+ function q(e, t, n) {
427
649
  let r = e.cursor();
428
650
  do
429
651
  if (r.name === "LinkReference") return null;
@@ -442,14 +664,14 @@ function V(e, t, n) {
442
664
  }
443
665
  return i;
444
666
  }
445
- function H(e) {
667
+ function J(e) {
446
668
  return /\r(?!\n)/.test(e);
447
669
  }
448
- function U(e, t) {
670
+ function fe(e, t) {
449
671
  for (; t > 0 && e[t - 1] !== "\n" && e[t - 1] !== "\r";) t--;
450
672
  return t;
451
673
  }
452
- function W(e, t) {
674
+ function Y(e, t) {
453
675
  let n = new Set(t.map((e) => e.from));
454
676
  for (let r of t) {
455
677
  let t = r.to;
@@ -464,7 +686,7 @@ function W(e, t) {
464
686
  }
465
687
  return !1;
466
688
  }
467
- function G(e, t, n, r) {
689
+ function X(e, t, n, r) {
468
690
  if (e.type !== n.type || e.range.start + t !== n.range.start + r || e.range.end + t !== n.range.end + r) return !1;
469
691
  let i = 0;
470
692
  for (let [a, o] of Object.entries(e)) {
@@ -474,13 +696,13 @@ function G(e, t, n, r) {
474
696
  if (a === "children") {
475
697
  let n = o, i = e;
476
698
  if (!i || n.length !== i.length) return !1;
477
- for (let e = 0; e < n.length; e++) if (!G(n[e], t, i[e], r)) return !1;
699
+ for (let e = 0; e < n.length; e++) if (!X(n[e], t, i[e], r)) return !1;
478
700
  } else if (o !== e && JSON.stringify(o) !== JSON.stringify(e)) return !1;
479
701
  }
480
702
  for (let [e, t] of Object.entries(n)) t !== void 0 && e !== "id" && e !== "range" && i--;
481
703
  return i === 0;
482
704
  }
483
- function K(e, t) {
705
+ function Z(e, t) {
484
706
  let n = 0, r = e.length, i = t.length;
485
707
  for (; n < r && n < i && e.charCodeAt(n) === t.charCodeAt(n);) n++;
486
708
  for (; r > n && i > n && e.charCodeAt(r - 1) === t.charCodeAt(i - 1);) r--, i--;
@@ -491,19 +713,19 @@ function K(e, t) {
491
713
  delta: i - r
492
714
  };
493
715
  }
494
- function q(e, t) {
716
+ function Q(e, t) {
495
717
  let n = e.parsed?.plans;
496
718
  if (n?.length) {
497
719
  for (let e of n) if (e.source === t) return e.rows;
498
720
  if (n.length === 1) return n[0].rows;
499
721
  }
500
722
  }
501
- var J = class {
723
+ var $ = class {
502
724
  disposed = !1;
503
725
  snapshot = null;
504
726
  deferred = null;
505
- parseSession = new S();
506
- semantic = new m();
727
+ parseSession = new se();
728
+ semantic = new te();
507
729
  services = {
508
730
  parser: this.parseSession,
509
731
  semantic: this.semantic
@@ -511,6 +733,7 @@ var J = class {
511
733
  shared = null;
512
734
  sharedKey;
513
735
  sharedMode;
736
+ streamingCache = null;
514
737
  epoch = 0;
515
738
  cacheBuilds = 0;
516
739
  serial = 0;
@@ -527,25 +750,64 @@ var J = class {
527
750
  cacheBuilds: this.cacheBuilds
528
751
  };
529
752
  }
530
- compile(e, t) {
531
- let r = this.compileShared(e, t), i = performance.now(), a = n(r);
753
+ compile(e, t, r) {
754
+ let i = this.compileShared(e, t, r), a = performance.now(), o = n(i);
532
755
  return this.lastStats = {
533
756
  ...this.lastStats,
534
757
  stages: {
535
758
  ...this.lastStats.stages,
536
- publicSnapshotMs: performance.now() - i
759
+ publicSnapshotMs: performance.now() - a
537
760
  }
538
- }, a;
761
+ }, o;
539
762
  }
540
- compileShared(e, t) {
763
+ compileShared(e, t, n) {
541
764
  if (this.disposed) throw Error("Local compile session is disposed");
765
+ if (n !== void 0 && z(n) === void 0) return ue();
766
+ let r = z(n) ?? de(t);
767
+ return r === "streaming" ? this.compileStreaming(e, t) : r === "final" ? this.compileFinal(e, t) : this.compileFinalOrLegacy(e, t);
768
+ }
769
+ compileFinal(e, t) {
770
+ let n = this.compileFinalOrLegacy(e, t);
771
+ return n.ok ? {
772
+ ...n,
773
+ status: R(n) ? "recovered" : "valid"
774
+ } : {
775
+ ...n,
776
+ status: "failed"
777
+ };
778
+ }
779
+ compileStreaming(e, t) {
780
+ let n = l(t).ok, r = u(t), i = this.streamingCache;
781
+ if (n && i !== null && i.source === e && i.key === r) return this.lastStats = {
782
+ mode: "streaming",
783
+ totalBlocks: i.blocks,
784
+ compiledBlocks: 0,
785
+ reusedBlocks: 0,
786
+ compiledCharacters: 0
787
+ }, i.result;
788
+ let a = ee(e, t, this.services), o = a.parsed?.nodes.length ?? 0;
789
+ return this.lastStats = {
790
+ mode: "streaming",
791
+ totalBlocks: o,
792
+ compiledBlocks: o,
793
+ reusedBlocks: 0,
794
+ compiledCharacters: typeof e == "string" ? e.length : 0,
795
+ stages: a.timings
796
+ }, n && (this.streamingCache = {
797
+ source: e,
798
+ key: r,
799
+ result: a.result,
800
+ blocks: o
801
+ }), a.result;
802
+ }
803
+ compileFinalOrLegacy(e, t) {
542
804
  this.epoch++;
543
- let n = l(t), r = M(t);
805
+ let n = u(t), r = L(t);
544
806
  (n !== this.sharedKey || r !== this.sharedMode) && (this.shared = null, this.sharedKey = n, this.sharedMode = r);
545
- let i = this.compileCore(e, t), a = performance.now(), o = this.shared, s = w(o ?? void 0, i).value;
807
+ let i = this.compileCore(e, t), a = performance.now(), o = this.shared, s = j(o ?? void 0, i).value;
546
808
  return this.shared = s, this.lastStats = {
547
809
  ...this.lastStats,
548
- sharedNodes: T(o, s),
810
+ sharedNodes: ce(o, s),
549
811
  parse: this.parseSession.stats,
550
812
  semantic: this.lastStats.semantic ?? this.semantic.stats,
551
813
  stages: {
@@ -557,8 +819,8 @@ var J = class {
557
819
  compileCore(e, t) {
558
820
  if (this.disposed) throw Error("Local compile session is disposed");
559
821
  this.cacheBuilds = 0;
560
- let r = l(t), i = c(t), a = M(t), o = a ? "recovery-reference" : "initial", d = !1, f = this.deferred;
561
- if (this.deferred = null, !a && f && f.key === r && i.ok && !i.htmlActive && typeof e == "string" && e.length <= 1e6) {
822
+ let r = u(t), i = l(t), a = L(t), o = a ? "recovery-reference" : "initial", s = !1, f = this.deferred;
823
+ if (this.deferred = null, !a && f && f.key === r && i.ok && typeof e == "string" && e.length <= 1e6) {
562
824
  if (e === f.source) return this.deferred = f, this.lastStats = {
563
825
  mode: "cached",
564
826
  totalBlocks: this.lastStats.totalBlocks,
@@ -566,16 +828,16 @@ var J = class {
566
828
  reusedBlocks: this.lastStats.totalBlocks,
567
829
  compiledCharacters: 0
568
830
  }, f.tracked.result;
569
- d = !0, o = "scope-or-boundary";
570
- let n = K(f.source, e), i = (e) => n.from <= e.end && n.oldTo >= e.start, a = f.tracked.parsed;
571
- if (a && !/[`\\~]/.test(f.source.slice(n.from, n.oldTo) + e.slice(n.from, n.newTo)) && !a.nodes.some((e) => i(e.range) && z(e) !== "fragment") && ![a.versionDeclaration?.range, a.themeRange].some((e) => e && i(e))) try {
831
+ s = !0, o = "scope-or-boundary";
832
+ let n = Z(f.source, e), i = (e) => n.from <= e.end && n.oldTo >= e.start, a = f.tracked.parsed;
833
+ if (a && !/[`\\~]/.test(f.source.slice(n.from, n.oldTo) + e.slice(n.from, n.newTo)) && !a.nodes.some((e) => i(e.range) && G(e) !== "fragment") && ![a.versionDeclaration?.range, a.themeRange].some((e) => e && i(e))) try {
572
834
  this.snapshot = this.seed(f.source, r, f.tracked, t);
573
835
  } catch {
574
836
  this.snapshot = null;
575
837
  }
576
838
  } else f && (o = a ? "recovery-reference" : "options-or-limits");
577
839
  let p = this.snapshot;
578
- if (!a && p && p.key === r && i.ok && !i.htmlActive && typeof e == "string" && e.length <= 1e6) {
840
+ if (!a && p && p.key === r && i.ok && typeof e == "string" && e.length <= 1e6) {
579
841
  if (e === p.source) return this.lastStats = {
580
842
  mode: "cached",
581
843
  totalBlocks: p.blocks.length,
@@ -588,10 +850,10 @@ var J = class {
588
850
  n = this.update(p, e, t, i.maxSyntaxNodes);
589
851
  } catch {}
590
852
  if (n) return this.snapshot = n, this.publish(n);
591
- o = "scope-or-boundary", d = !0;
853
+ o = "scope-or-boundary", s = !0;
592
854
  } else p && (o = a ? "recovery-reference" : "options-or-limits");
593
855
  this.snapshot = null;
594
- let m = u(e, t, this.services);
856
+ let m = d(e, t, this.services);
595
857
  if (this.lastStats = {
596
858
  mode: "full",
597
859
  totalBlocks: m.parsed?.nodes.length ?? 0,
@@ -601,13 +863,13 @@ var J = class {
601
863
  fallbackReason: o,
602
864
  semantic: m.semantic,
603
865
  stages: m.timings
604
- }, !a && m.result.ok && m.result.diagnostics.length === 0 && !N(m.result) && i.ok && !i.htmlActive && r !== "invalid") {
605
- if (d) {
866
+ }, !a && m.result.ok && !m.result.document.capabilities && m.result.diagnostics.length === 0 && !R(m.result) && i.ok && r !== "invalid") {
867
+ if (s) {
606
868
  let i = t === void 0 ? void 0 : n(t), a = i;
607
869
  if (i?.config !== void 0) try {
608
870
  a = {
609
871
  ...i,
610
- config: s(i.config)
872
+ config: c(i.config)
611
873
  };
612
874
  } catch {}
613
875
  this.deferred = {
@@ -626,8 +888,8 @@ var J = class {
626
888
  return this.snapshot ? this.publish(this.snapshot) : m.result;
627
889
  }
628
890
  seed(e, t, n, r, i) {
629
- if (this.cacheBuilds++, !n.result.ok || !n.parsed || N(n.result) || e.includes("[^") || e.includes("") || H(e)) return null;
630
- let a = n.parsed.nodes, o = a.map(z), s = a.length === 1 && o[0] === "fragment" && (a[0].type === "list" || a[0].type === "table");
891
+ if (this.cacheBuilds++, !n.result.ok || !n.parsed || R(n.result) || e.includes("[^") || e.includes("") || J(e)) return null;
892
+ let a = n.parsed.nodes, o = a.map(G), s = a.length === 1 && o[0] === "fragment" && (a[0].type === "list" || a[0].type === "table");
631
893
  if (o.includes("unsupported") || !s && o.filter((e) => e === "fragment").length < 2) return null;
632
894
  let c = {
633
895
  ...n.result.document,
@@ -645,7 +907,7 @@ var J = class {
645
907
  origin: n.range.start,
646
908
  text: e.slice(n.range.start, n.range.end),
647
909
  nodes: t,
648
- dependencies: R(t, c),
910
+ dependencies: W(t, c),
649
911
  cost: 0
650
912
  });
651
913
  }
@@ -659,10 +921,10 @@ var J = class {
659
921
  dependencies: {},
660
922
  cost: 0
661
923
  });
662
- if (u.sort((e, t) => e.from - t.from), W(e, u)) return null;
663
- let f = B(e, u);
924
+ if (u.sort((e, t) => e.from - t.from), Y(e, u)) return null;
925
+ let f = K(e, u);
664
926
  if (f.includes("<")) return null;
665
- let p = i ?? P.parse(f), m = V(p, u, f);
927
+ let p = i ?? B.parse(f), m = q(p, u, f);
666
928
  if (!m) return null;
667
929
  let h = [], g = 0;
668
930
  for (let t of m) {
@@ -673,20 +935,20 @@ var J = class {
673
935
  r.push(e), g++;
674
936
  }
675
937
  if (!r.length) return null;
676
- let i = r.flatMap((e) => l.has(e.id) ? [l.get(e.id)] : []), a = I(i).length, o = e.slice(t.start, t.end);
938
+ let i = r.flatMap((e) => l.has(e.id) ? [l.get(e.id)] : []), a = H(i).length, o = e.slice(t.start, t.end);
677
939
  h.push({
678
940
  from: t.start,
679
941
  to: t.end,
680
942
  origin: t.start,
681
943
  text: o,
682
944
  nodes: i,
683
- dependencies: R(i, c),
945
+ dependencies: W(i, c),
684
946
  cost: a,
685
- rowPlans: q(n, o)
947
+ rowPlans: Q(n, o)
686
948
  });
687
949
  }
688
950
  if (g !== d.length) return null;
689
- let _ = u.length ? u.map((e) => e.text).join(F) + F : "", v = _ ? this.parseSession.parse(_, r) : null;
951
+ let _ = u.length ? u.map((e) => e.text).join(V) + V : "", v = _ ? this.parseSession.parse(_, r) : null;
690
952
  if (v?.diagnostics.length) return null;
691
953
  let y = (n.parsed.syntaxNodes ?? 0) - h.reduce((e, t) => e + t.cost, 0);
692
954
  return y < 0 ? null : (c.nodes = [], c.source = "", delete c.dependencies, {
@@ -702,13 +964,13 @@ var J = class {
702
964
  });
703
965
  }
704
966
  update(e, t, n, r) {
705
- if (t.includes("[^") || t.includes("") || H(t)) return null;
706
- let a = K(e.source, t);
707
- if (/[`\\~]/.test(e.source.slice(a.from, a.oldTo) + t.slice(a.from, a.newTo))) return null;
967
+ if (t.includes("[^") || t.includes("") || J(t)) return null;
968
+ let i = Z(e.source, t);
969
+ if (/[`\\~]/.test(e.source.slice(i.from, i.oldTo) + t.slice(i.from, i.newTo))) return null;
708
970
  let o = [];
709
971
  for (let n of e.context) {
710
- if (a.from <= n.to && a.oldTo >= n.from) return null;
711
- let e = n.from >= a.oldTo ? a.delta : 0, r = {
972
+ if (i.from <= n.to && i.oldTo >= n.from) return null;
973
+ let e = n.from >= i.oldTo ? i.delta : 0, r = {
712
974
  ...n,
713
975
  from: n.from + e,
714
976
  to: n.to + e
@@ -716,38 +978,38 @@ var J = class {
716
978
  if (t.slice(r.from, r.to) !== n.text) return null;
717
979
  o.push(r);
718
980
  }
719
- if (W(t, o)) return null;
720
- let s = i.applyChanges(i.addTree(e.tree), [{
721
- fromA: a.from,
722
- toA: a.oldTo,
723
- fromB: a.from,
724
- toB: a.newTo
725
- }], 0), c = B(t, o);
981
+ if (Y(t, o)) return null;
982
+ let s = a.applyChanges(a.addTree(e.tree), [{
983
+ fromA: i.from,
984
+ toA: i.oldTo,
985
+ fromB: i.from,
986
+ toB: i.newTo
987
+ }], 0), c = K(t, o);
726
988
  if (c.includes("<")) return null;
727
- let l = P.parse(c, s), d = V(l, o, c);
728
- if (!d) return null;
989
+ let l = B.parse(c, s), u = q(l, o, c);
990
+ if (!u) return null;
729
991
  let f = new Map(e.blocks.map((e) => [`${e.from}:${e.to}`, e])), p = [], m = /* @__PURE__ */ new Set(), h = /* @__PURE__ */ new Set(), g = 0, _ = 0, v = 0, y = e.contextCost;
730
- for (let i of d) {
731
- let o = i.start >= a.newTo ? a.delta : 0, s = i.end <= a.from || i.start >= a.newTo ? f.get(`${i.start - o}:${i.end - o}`) : void 0, c = t.slice(i.start, i.end);
992
+ for (let a of u) {
993
+ let o = a.start >= i.newTo ? i.delta : 0, s = a.end <= i.from || a.start >= i.newTo ? f.get(`${a.start - o}:${a.end - o}`) : void 0, c = t.slice(a.start, a.end);
732
994
  if (s && s.text === c) {
733
995
  p.push({
734
996
  ...s,
735
- from: i.start,
736
- to: i.end
997
+ from: a.start,
998
+ to: a.end
737
999
  }), g++, y += s.cost;
738
- for (let e of I(s.nodes)) m.add(e.id);
1000
+ for (let e of H(s.nodes)) m.add(e.id);
739
1001
  } else {
740
1002
  let t = e.prefix.length, r = e.blocks.find((e) => {
741
- let t = e.from >= a.oldTo ? e.from + a.delta : e.from, n = e.to >= a.oldTo ? e.to + a.delta : e.to;
742
- return t < i.end && n > i.start;
1003
+ let t = e.from >= i.oldTo ? e.from + i.delta : e.from, n = e.to >= i.oldTo ? e.to + i.delta : e.to;
1004
+ return t < a.end && n > a.start;
743
1005
  }), o = r?.rowPlans ? {
744
1006
  ...this.services,
745
1007
  rowPlans: r.rowPlans
746
- } : this.services, s = u(e.prefix + c, n, o);
747
- if (v += t + c.length, _++, !s.result.ok || s.result.diagnostics.length || !s.parsed || N(s.result)) return null;
1008
+ } : this.services, s = d(e.prefix + c, n, o);
1009
+ if (v += t + c.length, _++, !s.result.ok || s.result.diagnostics.length || !s.parsed || R(s.result)) return null;
748
1010
  let l = s.parsed.nodes.filter((e) => e.range.start >= t);
749
- if (!l.length || l.some((e) => z(e) !== "fragment")) return null;
750
- let d = s.result.document.nodes.filter((e) => e.range.start >= t), f = new Map(I(d).map((e) => [e.id, `incremental-${++this.serial}-${e.id}`])), g = L(d, 0, f), b = r ? j({
1011
+ if (!l.length || l.some((e) => G(e) !== "fragment")) return null;
1012
+ let u = s.result.document.nodes.filter((e) => e.range.start >= t), f = new Map(H(u).map((e) => [e.id, `incremental-${++this.serial}-${e.id}`])), g = U(u, 0, f), b = r ? le({
751
1013
  text: r.text,
752
1014
  origin: r.origin,
753
1015
  nodes: r.nodes
@@ -763,29 +1025,29 @@ var J = class {
763
1025
  }
764
1026
  }
765
1027
  let x = b?.nodes ?? g, S = (s.parsed.syntaxNodes ?? 0) - e.prefixCost;
766
- if (S < I(x).length) return null;
767
- let C = R(d, s.result.document, f), w = Object.create(null);
768
- for (let e of I(x)) w[e.id] = C[e.id] ?? null;
1028
+ if (S < H(x).length) return null;
1029
+ let C = W(u, s.result.document, f), w = Object.create(null);
1030
+ for (let e of H(x)) w[e.id] = C[e.id] ?? null;
769
1031
  if (b && r) {
770
1032
  let e = r.nodes[0]?.id, t = g[0]?.id;
771
1033
  for (let n of b.reusedIds) w[n] = n === e && t !== void 0 ? C[t] ?? null : r.dependencies[n] ?? null, m.add(n);
772
1034
  for (let e = 0; e < b.reused; e++) this.parseSession.noteRowReuse(b.kind);
773
1035
  }
774
1036
  let T = {
775
- from: i.start,
776
- to: i.end,
1037
+ from: a.start,
1038
+ to: a.end,
777
1039
  origin: t,
778
1040
  text: c,
779
1041
  nodes: x,
780
1042
  dependencies: w,
781
1043
  cost: S,
782
- rowPlans: q(s, c)
1044
+ rowPlans: Q(s, c)
783
1045
  };
784
1046
  p.push(T), h.add(T), y += S;
785
1047
  }
786
1048
  if (y > r) return null;
787
1049
  }
788
- return y > r || !this.sameBoundaries(t, p, o, h, a, n) ? null : (this.lastStats = {
1050
+ return y > r || !this.sameBoundaries(t, p, o, h, i, n) ? null : (this.lastStats = {
789
1051
  mode: "incremental",
790
1052
  totalBlocks: p.length,
791
1053
  compiledBlocks: _,
@@ -819,7 +1081,7 @@ var J = class {
819
1081
  delta: a
820
1082
  });
821
1083
  }
822
- let i = r[0], l = r[r.length - 1], u = "node" in i ? Math.max(s[t].from, U(e, i.node.range.start + i.delta)) : i.from, d = "node" in l ? l.node.range.end + l.delta : l.to, f = s.slice(t, n + 2).flatMap((e) => e.rowPlans ? [e.rowPlans] : []), p = f.length < 2 ? f[0] : {
1084
+ let i = r[0], l = r[r.length - 1], u = "node" in i ? Math.max(s[t].from, fe(e, i.node.range.start + i.delta)) : i.from, d = "node" in l ? l.node.range.end + l.delta : l.to, f = s.slice(t, n + 2).flatMap((e) => e.rowPlans ? [e.rowPlans] : []), p = f.length < 2 ? f[0] : {
823
1085
  has: (e) => f.some((t) => t.has(e)),
824
1086
  get: (e) => f.find((t) => t.has(e))?.get(e)
825
1087
  }, m = this.parseSession.parse(e.slice(u, d), a, void 0, p);
@@ -827,7 +1089,7 @@ var J = class {
827
1089
  for (let e = 0; e < r.length; e++) {
828
1090
  let t = r[e], n = m.nodes[e];
829
1091
  if ("node" in t) {
830
- if (!G(n, u, t.node, t.delta)) return !1;
1092
+ if (!X(n, u, t.node, t.delta)) return !1;
831
1093
  } else if (n.range.start + u !== t.from || n.range.end + u !== t.to) return !1;
832
1094
  }
833
1095
  t = n;
@@ -841,7 +1103,7 @@ var J = class {
841
1103
  t.nodes = r.flatMap((e) => {
842
1104
  let t = e.from - e.origin;
843
1105
  if (e.publication?.delta === t) return e.publication.nodes;
844
- let n = w(e.publication?.nodes ?? e.nodes.map((e) => i.get(e.id)).filter((e) => !!e), L(e.nodes, t)).value;
1106
+ let n = j(e.publication?.nodes ?? e.nodes.map((e) => i.get(e.id)).filter((e) => !!e), U(e.nodes, t)).value;
845
1107
  return e.publication = {
846
1108
  delta: t,
847
1109
  nodes: n
@@ -895,7 +1157,7 @@ var J = class {
895
1157
  if (await t(), !i() || !n.tracked.result.ok || !n.tracked.parsed) return !1;
896
1158
  let a = [], o = n.tracked.parsed.nodes;
897
1159
  for (let e = 0; e < o.length; e++) {
898
- let r = o[e], s = z(r);
1160
+ let r = o[e], s = G(r);
899
1161
  if (s === "unsupported" || (s === "context" && a.push({
900
1162
  from: r.range.start,
901
1163
  to: r.range.end,
@@ -916,9 +1178,9 @@ var J = class {
916
1178
  cost: 0
917
1179
  });
918
1180
  a.sort((e, t) => e.from - t.from);
919
- let s = B(n.source, a);
1181
+ let s = K(n.source, a);
920
1182
  if (s.includes("<")) return !1;
921
- let c = P.startParse(s), l = null;
1183
+ let c = B.startParse(s), l = null;
922
1184
  for (; !l;) if (l = c.advance(), !l && (await t(), !i())) return !1;
923
1185
  if (await t(), !i()) return !1;
924
1186
  let u = this.cacheBuilds;
@@ -932,13 +1194,13 @@ var J = class {
932
1194
  }
933
1195
  }
934
1196
  clear() {
935
- this.epoch++, this.snapshot = null, this.deferred = null, this.serial = 0, this.cacheBuilds = 0, this.shared = null, this.sharedKey = void 0, this.sharedMode = void 0, this.parseSession.clear(), this.semantic.clear();
1197
+ this.epoch++, this.snapshot = null, this.deferred = null, this.serial = 0, this.cacheBuilds = 0, this.shared = null, this.sharedKey = void 0, this.sharedMode = void 0, this.streamingCache = null, this.parseSession.clear(), this.semantic.clear();
936
1198
  }
937
1199
  dispose() {
938
1200
  this.clear(), this.parseSession.dispose(), this.disposed = !0;
939
1201
  }
940
1202
  };
941
- function Y() {
942
- return new J();
1203
+ function pe() {
1204
+ return new $();
943
1205
  }
944
- export { Y as n, J as t };
1206
+ export { pe as n, $ as t };