reactive-md 0.5.3 → 0.6.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 (141) hide show
  1. package/CHANGELOG-ch.md +195 -165
  2. package/CHANGELOG.md +195 -165
  3. package/CONTRIBUTING-ch.md +67 -62
  4. package/CONTRIBUTING.md +69 -64
  5. package/README-ch.md +157 -155
  6. package/README-en.md +184 -181
  7. package/README.md +184 -181
  8. package/SECURITY-ch.md +81 -81
  9. package/SECURITY.md +81 -81
  10. package/THIRD_PARTY_NOTICES.md +585 -1
  11. package/bin/reactive-md.mjs +39 -39
  12. package/cli/args.mjs +181 -181
  13. package/cli/assets.mjs +390 -390
  14. package/cli/build.mjs +268 -268
  15. package/cli/document.mjs +130 -130
  16. package/cli/errors.mjs +61 -61
  17. package/cli/fs-utils.mjs +133 -133
  18. package/cli/glob.mjs +203 -203
  19. package/cli/help.mjs +138 -138
  20. package/cli/lint.mjs +177 -177
  21. package/cli/main.mjs +55 -55
  22. package/cli/migrate.mjs +368 -368
  23. package/cli/package.mjs +210 -210
  24. package/dist-library/{authoring-DJJjKYg9.js → authoring-BEVyth5X.js} +58 -58
  25. package/dist-library/compiler-Cm3ppMxG.js +46044 -0
  26. package/dist-library/react-Bh7_oxZp.js +59655 -0
  27. package/dist-library/reactive-md-authoring.js +2 -2
  28. package/dist-library/reactive-md-editor.js +13 -0
  29. package/dist-library/reactive-md-print.css +284 -284
  30. package/dist-library/reactive-md-react-unstyled.js +1 -1
  31. package/dist-library/reactive-md-react.js +1 -1
  32. package/dist-library/reactive-md.css +1 -1
  33. package/dist-library/reactive-md.js +123 -123
  34. package/dist-library/{runtime-DXtle_6c.js → runtime-DlFYQ4s_.js} +151 -151
  35. package/dist-library/types/editor/types.d.ts +2 -0
  36. package/dist-library/types/local/code-block.d.ts +3 -1
  37. package/dist-library/types/local/code-languages.d.ts +7 -0
  38. package/dist-library/types/local/compiled-data.d.ts +6 -0
  39. package/dist-library/types/local/compiler.d.ts +1 -0
  40. package/dist-library/types/local/diagnostics.d.ts +31 -0
  41. package/dist-library/types/local/diagram-layout.d.ts +69 -0
  42. package/dist-library/types/local/html-names.d.ts +6 -0
  43. package/dist-library/types/local/html-table.d.ts +25 -0
  44. package/dist-library/types/local/math-display.d.ts +22 -22
  45. package/dist-library/types/local/math-view.d.ts +6 -7
  46. package/dist-library/types/local/table-surface.d.ts +10 -0
  47. package/dist-library/types/local/types.d.ts +2 -0
  48. package/dist-library/types/local/visuals.d.ts +9 -0
  49. package/dist-standalone/reactive-md-standalone.css +1 -1
  50. package/dist-standalone/reactive-md-standalone.js +331 -51
  51. package/docs/README.md +84 -0
  52. package/docs/{compatibility-ch.md → compatibility/compatibility-ch.md} +121 -109
  53. package/docs/{compatibility-en.md → compatibility/compatibility-en.md} +121 -109
  54. package/docs/{source-versioning-ch.md → compatibility/source-versioning-ch.md} +159 -159
  55. package/docs/{source-versioning-en.md → compatibility/source-versioning-en.md} +159 -159
  56. package/docs/{component-development-ch.md → development/component-development-ch.md} +210 -210
  57. package/docs/{component-development-en.md → development/component-development-en.md} +210 -210
  58. package/docs/{component-protocol-ch.md → development/component-protocol-ch.md} +747 -747
  59. package/docs/{component-protocol-en.md → development/component-protocol-en.md} +747 -747
  60. package/docs/{performance-ch.md → development/performance-ch.md} +76 -76
  61. package/docs/{performance-en.md → development/performance-en.md} +76 -76
  62. package/docs/{releasing-ch.md → development/releasing-ch.md} +108 -108
  63. package/docs/{releasing-en.md → development/releasing-en.md} +108 -108
  64. package/docs/guides/local-guide-ch.md +513 -0
  65. package/docs/guides/local-guide-en.md +513 -0
  66. package/docs/{author-tools-ch.md → integration/author-tools-ch.md} +57 -57
  67. package/docs/{author-tools-en.md → integration/author-tools-en.md} +57 -57
  68. package/docs/{editor-ch.md → integration/editor-ch.md} +7 -6
  69. package/docs/{editor-en.md → integration/editor-en.md} +7 -6
  70. package/docs/{local-integration-ch.md → integration/local-integration-ch.md} +33 -15
  71. package/docs/{local-integration-en.md → integration/local-integration-en.md} +33 -15
  72. package/docs/{shareable-export-ch.md → integration/shareable-export-ch.md} +221 -209
  73. package/docs/{shareable-export-en.md → integration/shareable-export-en.md} +223 -211
  74. package/docs/{computations-formatting-ch.md → reference/computations-formatting-ch.md} +87 -87
  75. package/docs/{computations-formatting-en.md → reference/computations-formatting-en.md} +87 -87
  76. package/docs/{constraints-collections-ch.md → reference/constraints-collections-ch.md} +84 -84
  77. package/docs/{constraints-collections-en.md → reference/constraints-collections-en.md} +84 -84
  78. package/docs/{diagnostics-counting-ch.md → reference/diagnostics-counting-ch.md} +104 -84
  79. package/docs/{diagnostics-counting-en.md → reference/diagnostics-counting-en.md} +104 -84
  80. package/docs/{html-compatibility-ch.md → reference/html-compatibility-ch.md} +42 -4
  81. package/docs/{html-compatibility-en.md → reference/html-compatibility-en.md} +42 -4
  82. package/docs/{local-components-v2-ch.md → reference/local-components-v2-ch.md} +138 -138
  83. package/docs/{local-components-v2-en.md → reference/local-components-v2-en.md} +104 -104
  84. package/docs/{local-interaction-syntax-ch.md → reference/local-interaction-syntax-ch.md} +515 -492
  85. package/docs/{local-interaction-syntax-en.md → reference/local-interaction-syntax-en.md} +511 -488
  86. package/docs/{theme-protocol-ch.md → reference/theme-protocol-ch.md} +107 -107
  87. package/docs/{theme-protocol-en.md → reference/theme-protocol-en.md} +107 -107
  88. package/docs/{release-0.4.0-ch.md → releases/release-0.4.0-ch.md} +89 -89
  89. package/docs/{release-0.4.0-en.md → releases/release-0.4.0-en.md} +89 -89
  90. package/docs/{release-0.4.1-ch.md → releases/release-0.4.1-ch.md} +23 -23
  91. package/docs/{release-0.4.1-en.md → releases/release-0.4.1-en.md} +23 -23
  92. package/docs/{release-0.5.0-ch.md → releases/release-0.5.0-ch.md} +4 -4
  93. package/docs/{release-0.5.0-en.md → releases/release-0.5.0-en.md} +4 -4
  94. package/docs/{release-0.5.1-ch.md → releases/release-0.5.1-ch.md} +4 -4
  95. package/docs/{release-0.5.1-en.md → releases/release-0.5.1-en.md} +4 -4
  96. package/docs/{release-0.5.2-ch.md → releases/release-0.5.2-ch.md} +3 -3
  97. package/docs/{release-0.5.2-en.md → releases/release-0.5.2-en.md} +3 -3
  98. package/docs/{release-0.5.3-ch.md → releases/release-0.5.3-ch.md} +1 -1
  99. package/docs/{release-0.5.3-en.md → releases/release-0.5.3-en.md} +1 -1
  100. package/docs/releases/release-0.6.0-ch.md +57 -0
  101. package/docs/releases/release-0.6.0-en.md +57 -0
  102. package/docs/releases/release-0.6.1-ch.md +27 -0
  103. package/docs/releases/release-0.6.1-en.md +27 -0
  104. package/examples/conformance/README.md +53 -53
  105. package/examples/conformance/component-protocol-1.json +482 -482
  106. package/examples/conformance/component-protocol-1.schema.json +76 -76
  107. package/examples/conformance/local-draft-1.json +50 -50
  108. package/examples/conformance/local-draft-2.json +212 -212
  109. package/examples/integration/README.md +47 -45
  110. package/examples/integration/core/index.mjs +32 -32
  111. package/examples/integration/worker/index.html +19 -19
  112. package/examples/integration/worker/main.js +61 -61
  113. package/examples/integration/worker/package.json +13 -13
  114. package/examples/integration/worker/worker.js +3 -3
  115. package/examples/local/README.md +74 -74
  116. package/examples/local/charts.reactive.md +73 -73
  117. package/examples/local/html-compat.reactive.md +19 -0
  118. package/examples/local/recipes/invoice-zh.reactive.md +36 -36
  119. package/examples/local/recipes/invoice.reactive.md +36 -36
  120. package/examples/local/recipes/workshop-zh.reactive.md +33 -33
  121. package/examples/local/recipes/workshop.reactive.md +33 -33
  122. package/examples/local/showcase/README.md +25 -25
  123. package/examples/local/showcase/explore.reactive.md +102 -102
  124. package/examples/local/showcase/flow.reactive.md +86 -86
  125. package/examples/local/showcase/forms.reactive.md +126 -126
  126. package/examples/local/showcase/functions.reactive.md +119 -119
  127. package/examples/local/showcase/layout.reactive.md +100 -100
  128. package/examples/local/showcase/statistics.reactive.md +108 -108
  129. package/examples/local/showcase/tasks.reactive.md +89 -89
  130. package/examples/local/showcase/zh/explore.reactive.md +102 -102
  131. package/examples/local/showcase/zh/flow.reactive.md +86 -86
  132. package/examples/local/showcase/zh/forms.reactive.md +126 -126
  133. package/examples/local/showcase/zh/functions.reactive.md +119 -119
  134. package/examples/local/showcase/zh/layout.reactive.md +100 -100
  135. package/examples/local/showcase/zh/statistics.reactive.md +108 -108
  136. package/examples/local/showcase/zh/tasks.reactive.md +89 -89
  137. package/package.json +152 -145
  138. package/dist-library/compiler-UyPwGzJZ.js +0 -22109
  139. package/dist-library/react-fizgU3i8.js +0 -12764
  140. package/docs/local-guide-ch.md +0 -967
  141. package/docs/local-guide-en.md +0 -967
@@ -1,4 +1,4 @@
1
- import { $ as e, J as t, K as n, L as r, Q as i, R as a, X as o, Y as s, Z as c, a as l, c as u, ht as d, i as f, it as p, k as ee, l as te, mt as m, o as ne, s as h, tt as g, u as _ } from "./compiler-UyPwGzJZ.js";
1
+ import { $ as e, B as t, M as n, Q as r, V as i, Y as a, Z as o, _t as s, a as c, c as l, et as u, i as d, it as f, l as ee, nt as p, o as te, s as m, st as h, tt as ne, u as g, vt as _ } from "./compiler-Cm3ppMxG.js";
2
2
  // src/local/runtime.ts
3
3
  var v = 1e-9, re = 200;
4
4
  function y(e) {
@@ -14,7 +14,7 @@ function x(e, t) {
14
14
  return Array.isArray(e) || Array.isArray(t) ? !Array.isArray(e) || !Array.isArray(t) || e.length !== t.length ? !1 : e.every((e, n) => e === t[n]) : e === t;
15
15
  }
16
16
  function S(e) {
17
- return e === "" || d(e) !== null;
17
+ return e === "" || _(e) !== null;
18
18
  }
19
19
  function C(e, t, n) {
20
20
  let r = (e - t) / n;
@@ -28,7 +28,7 @@ function w(e, t, n, r) {
28
28
  let i = Math.max(0, Math.min(e.source.length, t.range.start)), a = e.source.slice(0, i).split("\n");
29
29
  return {
30
30
  code: n,
31
- message: g(r),
31
+ message: f(r),
32
32
  severity: "error",
33
33
  range: {
34
34
  start: i,
@@ -67,13 +67,13 @@ function O(e, t) {
67
67
  let r = Number(n);
68
68
  return Number.isFinite(r) ? r : void 0;
69
69
  }
70
- function k(t) {
71
- return e(t);
70
+ function k(e) {
71
+ return p(e);
72
72
  }
73
73
  function A(e, t) {
74
74
  return {
75
75
  ok: !1,
76
- detail: p(e, t)
76
+ detail: h(e, t)
77
77
  };
78
78
  }
79
79
  function j(e, t) {
@@ -94,7 +94,7 @@ function j(e, t) {
94
94
  if (i !== void 0 && n > i) return A("local.runtime.value.max-length", { max: i });
95
95
  if (e.name === "input" && E(e, "type") === "email" && t !== "") {
96
96
  if (t.length > 254) return A("local.runtime.value.email-length", { limit: 254 });
97
- if (!m(t)) return A("local.runtime.value.email-invalid");
97
+ if (!s(t)) return A("local.runtime.value.email-invalid");
98
98
  }
99
99
  }
100
100
  return {
@@ -130,10 +130,10 @@ function M(e, t, n) {
130
130
  } : A("local.runtime.value.boolean", { name: e.name });
131
131
  case "string": {
132
132
  if (typeof n != "string") return A("local.runtime.value.string", { name: e.name });
133
- let r = c(n);
133
+ let r = u(n);
134
134
  if (r) return A("local.runtime.value.budget", {
135
135
  name: e.name,
136
- detail: g(r),
136
+ detail: f(r),
137
137
  detailKey: r.key,
138
138
  ...r.params
139
139
  });
@@ -151,10 +151,10 @@ function M(e, t, n) {
151
151
  }
152
152
  case "array": {
153
153
  if (!Array.isArray(n)) return A("local.runtime.value.array", { name: e.name });
154
- let t = c(n);
154
+ let t = u(n);
155
155
  if (t) return A("local.runtime.value.budget", {
156
156
  name: e.name,
157
- detail: g(t),
157
+ detail: f(t),
158
158
  detailKey: t.key,
159
159
  ...t.params
160
160
  });
@@ -180,28 +180,28 @@ function M(e, t, n) {
180
180
  }
181
181
  return A("local.runtime.value.unsupported-type", { name: e.name });
182
182
  }
183
- function N(e) {
184
- if (!e || e.syntax !== "local") throw Error("createLocalRuntime requires a local interaction document.");
185
- if (e.syntaxVersion !== void 0 && e.syntaxVersion !== "local-draft-2" || e.versionDeclaration && e.versionDeclaration.version !== "local-draft-2") throw Error(`createLocalRuntime requires ${ee}; migrate the source before constructing a runtime.`);
186
- let d = /* @__PURE__ */ new Map(), m = (e) => {
187
- for (let t of e) d.set(t.id, t), t.children && m(t.children);
183
+ function N(s) {
184
+ if (!s || s.syntax !== "local") throw Error("createLocalRuntime requires a local interaction document.");
185
+ if (s.syntaxVersion !== void 0 && s.syntaxVersion !== "local-draft-2" || s.versionDeclaration && s.versionDeclaration.version !== "local-draft-2") throw Error(`createLocalRuntime requires ${n}; migrate the source before constructing a runtime.`);
186
+ let p = /* @__PURE__ */ new Map(), _ = (e) => {
187
+ for (let t of e) p.set(t.id, t), t.children && _(t.children);
188
188
  };
189
- m(e.nodes);
189
+ _(s.nodes);
190
190
  let v = {}, S = /* @__PURE__ */ new Map();
191
- for (let [t, r] of Object.entries(e.bindings)) {
192
- let e = c(r.initial);
193
- if (e) throw new n("expression-budget", `Parameter "${t}": ${g(e)}`, 0);
194
- v[t] = y(r.initial);
195
- let i = [];
196
- for (let e of r.nodeIds) {
197
- let t = d.get(e);
198
- t && i.push(t);
191
+ for (let [e, t] of Object.entries(s.bindings)) {
192
+ let n = u(t.initial);
193
+ if (n) throw new a("expression-budget", `Parameter "${e}": ${f(n)}`, 0);
194
+ v[e] = y(t.initial);
195
+ let r = [];
196
+ for (let e of t.nodeIds) {
197
+ let t = p.get(e);
198
+ t && r.push(t);
199
199
  }
200
- S.set(t, i);
200
+ S.set(e, r);
201
201
  }
202
202
  let C = /* @__PURE__ */ new Map();
203
- for (let [t, n] of Object.entries(e.bindingSlots ?? {})) C.set(t, { ...n });
204
- let E = Object.freeze(Object.keys(e.bindings).filter((e) => !e.startsWith("@")).sort()), D = /* @__PURE__ */ new Map();
203
+ for (let [e, t] of Object.entries(s.bindingSlots ?? {})) C.set(e, { ...t });
204
+ let E = Object.freeze(Object.keys(s.bindings).filter((e) => !e.startsWith("@")).sort()), D = /* @__PURE__ */ new Map();
205
205
  for (let [e, t] of C) for (let n of Object.values(t)) {
206
206
  if (n.startsWith("@")) continue;
207
207
  let t = D.get(n) ?? /* @__PURE__ */ new Set();
@@ -212,80 +212,80 @@ function N(e) {
212
212
  if (!n?.start || !n?.end) return !1;
213
213
  let r = t[n.start], i = t[n.end];
214
214
  return typeof r == "number" && typeof i == "number" && r > i;
215
- }, k = e.computations ?? {}, A = Object.keys(k), j = /* @__PURE__ */ new Map();
216
- for (let [e, n] of Object.entries(k)) try {
217
- j.set(e, t(n.source));
215
+ }, k = s.computations ?? {}, A = Object.keys(k), j = /* @__PURE__ */ new Map();
216
+ for (let [e, t] of Object.entries(k)) try {
217
+ j.set(e, o(t.source));
218
218
  } catch {}
219
- let { order: N, cyclic: ae } = a(k), P = {}, F = /* @__PURE__ */ new Map(), I = (e) => e instanceof n ? e : new n("expression-eval", e instanceof Error ? e.message : String(e), 0);
220
- for (let e of N) {
221
- let t = k[e];
222
- if (!t || t.kind !== "const") continue;
223
- if (Object.hasOwn(t, "value")) {
224
- let r = t.value, i = o(r);
219
+ let { order: N, cyclic: ae } = i(k), P = {}, F = /* @__PURE__ */ new Map(), I = (e) => e instanceof a ? e : new a("expression-eval", e instanceof Error ? e.message : String(e), 0);
220
+ for (let t of N) {
221
+ let n = k[t];
222
+ if (!n || n.kind !== "const") continue;
223
+ if (Object.hasOwn(n, "value")) {
224
+ let r = n.value, i = e(r);
225
225
  if (i) {
226
- F.set(e, new n("expression-budget", `Constant "${e}": ${i}`, 0));
226
+ F.set(t, new a("expression-budget", `Constant "${t}": ${i}`, 0));
227
227
  continue;
228
228
  }
229
- P[e] = y(r);
229
+ P[t] = y(r);
230
230
  continue;
231
231
  }
232
- let r = j.get(e);
233
- if (!r) F.set(e, new n("expression-eval", `Constant "${e}" cannot be evaluated.`, 0));
232
+ let r = j.get(t);
233
+ if (!r) F.set(t, new a("expression-eval", `Constant "${t}" cannot be evaluated.`, 0));
234
234
  else try {
235
- let t = r.evaluate({ ...P }), i = o(t);
235
+ let n = r.evaluate({ ...P }), i = e(n);
236
236
  if (i) {
237
- F.set(e, new n("expression-budget", `Constant "${e}": ${i}`, 0));
237
+ F.set(t, new a("expression-budget", `Constant "${t}": ${i}`, 0));
238
238
  continue;
239
239
  }
240
- P[e] = y(t);
241
- } catch (t) {
242
- F.set(e, I(t));
240
+ P[t] = y(n);
241
+ } catch (e) {
242
+ F.set(t, I(e));
243
243
  }
244
244
  }
245
245
  let L = /* @__PURE__ */ new Map();
246
- for (let e of ae) L.set(e, new n("expression-cycle", `Computation "${e}" is part of a dependency cycle.`, 0));
246
+ for (let e of ae) L.set(e, new a("expression-cycle", `Computation "${e}" is part of a dependency cycle.`, 0));
247
247
  let R = [];
248
- if (Array.isArray(e.validations)) {
249
- for (let n of e.validations) if (u(n)) try {
248
+ if (Array.isArray(s.validations)) {
249
+ for (let e of s.validations) if (l(e)) try {
250
250
  R.push({
251
- rule: n,
252
- expression: t(n.expression),
251
+ rule: e,
252
+ expression: o(e.expression),
253
253
  error: null
254
254
  });
255
- } catch (e) {
255
+ } catch (t) {
256
256
  R.push({
257
- rule: n,
257
+ rule: e,
258
258
  expression: null,
259
- error: I(e)
259
+ error: I(t)
260
260
  });
261
261
  }
262
262
  }
263
- let z = te(typeof e.source == "string" ? e.source : ""), B = null, oe = (e) => {
263
+ let z = ee(typeof s.source == "string" ? s.source : ""), B = null, oe = (e) => {
264
264
  let t;
265
265
  try {
266
- t = s(e, G);
266
+ t = r(e, G);
267
267
  } catch {
268
- t = ne;
268
+ t = te;
269
269
  }
270
- return h(t);
270
+ return m(t);
271
271
  }, se = () => {
272
- let t = [], n = typeof e.source == "string" ? e.source : "";
273
- for (let e of R) {
274
- if (e.error) {
275
- t.push(_(n, z, e.rule.range, f, h(`Validation expression is invalid: ${e.error.message}`)));
272
+ let e = [], t = typeof s.source == "string" ? s.source : "";
273
+ for (let n of R) {
274
+ if (n.error) {
275
+ e.push(g(t, z, n.rule.range, d, m(`Validation expression is invalid: ${n.error.message}`)));
276
276
  continue;
277
277
  }
278
- if (!e.expression) continue;
278
+ if (!n.expression) continue;
279
279
  let r;
280
280
  try {
281
- r = e.expression.evaluate(G);
281
+ r = n.expression.evaluate(G);
282
282
  } catch (r) {
283
- t.push(_(n, z, e.rule.range, f, h(`Validation expression failed: ${r instanceof Error ? r.message : String(r)}`)));
283
+ e.push(g(t, z, n.rule.range, d, m(`Validation expression failed: ${r instanceof Error ? r.message : String(r)}`)));
284
284
  continue;
285
285
  }
286
- typeof r == "boolean" ? r || t.push(_(n, z, e.rule.range, l, oe(e.rule.message))) : t.push(_(n, z, e.rule.range, f, "Validation expression must evaluate to a boolean."));
286
+ typeof r == "boolean" ? r || e.push(g(t, z, n.rule.range, c, oe(n.rule.message))) : e.push(g(t, z, n.rule.range, d, "Validation expression must evaluate to a boolean."));
287
287
  }
288
- return t;
288
+ return e;
289
289
  }, V = v, H = 0, U = {}, W = /* @__PURE__ */ new Map(), G = {}, K = {}, q = {
290
290
  revision: 0,
291
291
  state: ie({})
@@ -294,7 +294,7 @@ function N(e) {
294
294
  }, ce = () => {
295
295
  if (A.length === 0) U = {}, W = /* @__PURE__ */ new Map();
296
296
  else {
297
- let e = r(k, N, j, V, P);
297
+ let e = t(k, N, j, V, P);
298
298
  U = e.values, W = e.errors;
299
299
  for (let [e, t] of F) Object.hasOwn(U, e) || W.set(e, t);
300
300
  for (let [e, t] of L) Object.hasOwn(U, e) || W.set(e, t);
@@ -310,10 +310,10 @@ function N(e) {
310
310
  }
311
311
  });
312
312
  G = e;
313
- let t = {};
314
- for (let [e, n] of Object.entries(V)) t[e] = n;
315
- for (let [e, n] of Object.entries(U)) t[e] = n;
316
- K = t;
313
+ let n = {};
314
+ for (let [e, t] of Object.entries(V)) n[e] = t;
315
+ for (let [e, t] of Object.entries(U)) n[e] = t;
316
+ K = n;
317
317
  }, le = () => {
318
318
  q = {
319
319
  revision: H,
@@ -322,52 +322,52 @@ function N(e) {
322
322
  }, $ = (e) => {
323
323
  V = e, H += 1, ce(), le();
324
324
  for (let e of Y) e();
325
- }, ue = (t, n) => {
326
- let r = (S.get(t.name) ?? [])[0] ?? (t.owner ? d.get(t.owner) : void 0) ?? (t.nodeIds[0] ? d.get(t.nodeIds[0]) : void 0);
327
- return r ? w(e, r, "local.runtime.value", n) : T("local.runtime.value", g(n));
328
- }, de = (t) => {
325
+ }, ue = (e, t) => {
326
+ let n = (S.get(e.name) ?? [])[0] ?? (e.owner ? p.get(e.owner) : void 0) ?? (e.nodeIds[0] ? p.get(e.nodeIds[0]) : void 0);
327
+ return n ? w(s, n, "local.runtime.value", t) : T("local.runtime.value", f(t));
328
+ }, de = (e) => {
329
329
  Q();
330
- let n = [], r = {}, i = Object.keys(t).sort();
331
- for (let a of i) {
332
- if (a === "__proto__") {
333
- n.push(T("local.runtime.parameter", "Parameter names cannot be \"__proto__\"."));
330
+ let t = [], n = {}, r = Object.keys(e).sort();
331
+ for (let i of r) {
332
+ if (i === "__proto__") {
333
+ t.push(T("local.runtime.parameter", "Parameter names cannot be \"__proto__\"."));
334
334
  continue;
335
335
  }
336
- if (a.startsWith("@")) {
337
- n.push(T("local.runtime.parameter", `Internal parameter "${a}" cannot be written by name.`));
336
+ if (i.startsWith("@")) {
337
+ t.push(T("local.runtime.parameter", `Internal parameter "${i}" cannot be written by name.`));
338
338
  continue;
339
339
  }
340
- if (!Object.hasOwn(e.bindings, a)) {
341
- n.push(T("local.runtime.parameter", `Unknown parameter "${a}".`));
340
+ if (!Object.hasOwn(s.bindings, i)) {
341
+ t.push(T("local.runtime.parameter", `Unknown parameter "${i}".`));
342
342
  continue;
343
343
  }
344
- let i = e.bindings[a], o = M(i, S.get(a) ?? [], t[a]);
345
- o.ok ? r[a] = y(o.value) : n.push(ue(i, o.detail));
344
+ let r = s.bindings[i], a = M(r, S.get(i) ?? [], e[i]);
345
+ a.ok ? n[i] = y(a.value) : t.push(ue(r, a.detail));
346
346
  }
347
- if (n.length) return n;
348
- if (!i.some((e) => !x(V[e], r[e]))) return [];
349
- let a = {
347
+ if (t.length) return t;
348
+ if (!r.some((e) => !x(V[e], n[e]))) return [];
349
+ let i = {
350
350
  ...V,
351
- ...r
352
- }, o = /* @__PURE__ */ new Set();
353
- for (let e of i) for (let t of D.get(e) ?? []) o.add(t);
354
- for (let t of [...o].sort()) if (O(t, a)) {
355
- let r = d.get(t);
356
- n.push(r ? w(e, r, "local.runtime.value", p("local.runtime.value.range-order")) : T("local.runtime.value", g(p("local.runtime.value.range-order"))));
351
+ ...n
352
+ }, a = /* @__PURE__ */ new Set();
353
+ for (let e of r) for (let t of D.get(e) ?? []) a.add(t);
354
+ for (let e of [...a].sort()) if (O(e, i)) {
355
+ let n = p.get(e);
356
+ t.push(n ? w(s, n, "local.runtime.value", h("local.runtime.value.range-order")) : T("local.runtime.value", f(h("local.runtime.value.range-order"))));
357
357
  }
358
- return n.length ? n : ($(a), []);
358
+ return t.length ? t : ($(i), []);
359
359
  };
360
360
  ce(), le();
361
361
  let fe = (e) => {
362
- let n = Z.get(e);
363
- if (!n) {
364
- if (n = t(e), Z.size >= re) {
362
+ let t = Z.get(e);
363
+ if (!t) {
364
+ if (t = o(e), Z.size >= re) {
365
365
  let e = Z.keys().next().value;
366
366
  e !== void 0 && Z.delete(e);
367
367
  }
368
- Z.set(e, n);
368
+ Z.set(e, t);
369
369
  }
370
- return n;
370
+ return t;
371
371
  }, pe = (e) => {
372
372
  let t = /* @__PURE__ */ new Set(), n = (e) => {
373
373
  t.add(e.id);
@@ -376,61 +376,61 @@ function N(e) {
376
376
  return n(e), t;
377
377
  };
378
378
  return {
379
- document: e,
379
+ document: s,
380
380
  snapshot() {
381
381
  return Q(), q;
382
382
  },
383
383
  get(e, t) {
384
384
  Q();
385
- let n = d.get(e.id);
385
+ let n = p.get(e.id);
386
386
  if (!n) return null;
387
- let r = t === void 0 ? i(n) : C.get(n.id)?.[t];
387
+ let r = t === void 0 ? ne(n) : C.get(n.id)?.[t];
388
388
  return r && Object.hasOwn(V, r) ? y(V[r]) : null;
389
389
  },
390
- set(t, n, r) {
390
+ set(e, t, n) {
391
391
  Q();
392
- let a = d.get(t.id);
393
- if (!a) return [w(e, t, "local.runtime.binding", p("local.runtime.binding.no-writable"))];
394
- let o = C.get(a.id), s;
395
- if (r === void 0) {
396
- if (o) return [w(e, a, "local.runtime.binding", p("local.runtime.binding.needs-slot"))];
397
- s = i(a);
398
- } else if (s = o?.[r], !s) return [w(e, a, "local.runtime.binding", p("local.runtime.binding.unknown-slot", { slot: r }))];
399
- let c = Object.hasOwn(e.bindings, s) ? e.bindings[s] : void 0;
400
- if (!c) return [w(e, a, "local.runtime.binding", p("local.runtime.binding.no-writable"))];
401
- let l = M(c, S.get(s) ?? [], n);
402
- if (!l.ok) return [w(e, a, "local.runtime.value", l.detail)];
403
- let u = y(l.value);
404
- if (x(V[s], u)) return [];
405
- let f = {
392
+ let r = p.get(e.id);
393
+ if (!r) return [w(s, e, "local.runtime.binding", h("local.runtime.binding.no-writable"))];
394
+ let i = C.get(r.id), a;
395
+ if (n === void 0) {
396
+ if (i) return [w(s, r, "local.runtime.binding", h("local.runtime.binding.needs-slot"))];
397
+ a = ne(r);
398
+ } else if (a = i?.[n], !a) return [w(s, r, "local.runtime.binding", h("local.runtime.binding.unknown-slot", { slot: n }))];
399
+ let o = Object.hasOwn(s.bindings, a) ? s.bindings[a] : void 0;
400
+ if (!o) return [w(s, r, "local.runtime.binding", h("local.runtime.binding.no-writable"))];
401
+ let c = M(o, S.get(a) ?? [], t);
402
+ if (!c.ok) return [w(s, r, "local.runtime.value", c.detail)];
403
+ let l = y(c.value);
404
+ if (x(V[a], l)) return [];
405
+ let u = {
406
406
  ...V,
407
- [s]: u
407
+ [a]: l
408
408
  };
409
- return O(a.id, f) ? [w(e, a, "local.runtime.value", p("local.runtime.value.range-order"))] : ($(f), []);
409
+ return O(r.id, u) ? [w(s, r, "local.runtime.value", h("local.runtime.value.range-order"))] : ($(u), []);
410
410
  },
411
- setMany(t, n) {
411
+ setMany(e, t) {
412
412
  Q();
413
- let r = d.get(t.id);
414
- if (!r) return [w(e, t, "local.runtime.binding", p("local.runtime.binding.no-writable"))];
415
- let i = C.get(r.id);
416
- if (!i) return [w(e, r, "local.runtime.binding", p("local.runtime.binding.no-multi-slot"))];
417
- let a = Object.entries(n);
418
- if (!a.length) return [];
419
- let o = { ...V };
420
- for (let [t, n] of a) {
421
- let a = i[t];
422
- if (!a || !Object.hasOwn(e.bindings, a)) return [w(e, r, "local.runtime.binding", p("local.runtime.binding.unknown-slot", { slot: t }))];
423
- let s = M(e.bindings[a], S.get(a) ?? [], n);
424
- if (!s.ok) return [w(e, r, "local.runtime.value", s.detail)];
425
- o[a] = y(s.value);
413
+ let n = p.get(e.id);
414
+ if (!n) return [w(s, e, "local.runtime.binding", h("local.runtime.binding.no-writable"))];
415
+ let r = C.get(n.id);
416
+ if (!r) return [w(s, n, "local.runtime.binding", h("local.runtime.binding.no-multi-slot"))];
417
+ let i = Object.entries(t);
418
+ if (!i.length) return [];
419
+ let a = { ...V };
420
+ for (let [e, t] of i) {
421
+ let i = r[e];
422
+ if (!i || !Object.hasOwn(s.bindings, i)) return [w(s, n, "local.runtime.binding", h("local.runtime.binding.unknown-slot", { slot: e }))];
423
+ let o = M(s.bindings[i], S.get(i) ?? [], t);
424
+ if (!o.ok) return [w(s, n, "local.runtime.value", o.detail)];
425
+ a[i] = y(o.value);
426
426
  }
427
- return O(r.id, o) ? [w(e, r, "local.runtime.value", p("local.runtime.value.range-order"))] : (a.every(([e, t]) => x(V[i[e]], t)) || $(o), []);
427
+ return O(n.id, a) ? [w(s, n, "local.runtime.value", h("local.runtime.value.range-order"))] : (i.every(([e, t]) => x(V[r[e]], t)) || $(a), []);
428
428
  },
429
429
  parameterNames() {
430
430
  return Q(), E;
431
431
  },
432
- getParameter(t) {
433
- if (Q(), !t.startsWith("@") && Object.hasOwn(e.bindings, t)) return Object.hasOwn(V, t) ? y(V[t]) : void 0;
432
+ getParameter(e) {
433
+ if (Q(), !e.startsWith("@") && Object.hasOwn(s.bindings, e)) return Object.hasOwn(V, e) ? y(V[e]) : void 0;
434
434
  },
435
435
  getParameters() {
436
436
  Q();
@@ -464,25 +464,25 @@ function N(e) {
464
464
  }, e.map(b);
465
465
  },
466
466
  text(e) {
467
- return Q(), s(e, G);
467
+ return Q(), r(e, G);
468
468
  },
469
- reset(t) {
469
+ reset(e) {
470
470
  Q();
471
- let r = d.get(t.id);
472
- if (!r) return;
473
- let i = pe(r), a = { ...V };
474
- for (let [t, r] of Object.entries(e.bindings)) {
475
- if (!(S.get(t) ?? []).some((e) => i.has(e.id))) continue;
476
- let e = c(r.initial);
477
- if (e) throw new n("expression-budget", `Parameter "${t}": ${g(e)}`, 0);
478
- a[t] = y(r.initial);
471
+ let t = p.get(e.id);
472
+ if (!t) return;
473
+ let n = pe(t), r = { ...V };
474
+ for (let [e, t] of Object.entries(s.bindings)) {
475
+ if (!(S.get(e) ?? []).some((e) => n.has(e.id))) continue;
476
+ let i = u(t.initial);
477
+ if (i) throw new a("expression-budget", `Parameter "${e}": ${f(i)}`, 0);
478
+ r[e] = y(t.initial);
479
479
  }
480
- for (let e of i) X.set(e, (X.get(e) ?? 0) + 1);
481
- $(a);
480
+ for (let e of n) X.set(e, (X.get(e) ?? 0) + 1);
481
+ $(r);
482
482
  },
483
483
  resetToken(e) {
484
484
  Q();
485
- let t = d.get(e.id);
485
+ let t = p.get(e.id);
486
486
  return t ? X.get(t.id) ?? 0 : 0;
487
487
  },
488
488
  subscribe(e) {
@@ -41,6 +41,8 @@ export interface ReactiveMarkdownEditorHandle {
41
41
  selectRange(range: SourceRange): void;
42
42
  getSelection(): EditorSelection;
43
43
  getTextarea(): HTMLTextAreaElement | null;
44
+ /** Replace the current selection and record one undoable host edit. */
45
+ insertText(text: string): void;
44
46
  undo(): void;
45
47
  redo(): void;
46
48
  }
@@ -13,8 +13,10 @@ export interface CodeHighlight {
13
13
  /** Highlighted children, or `null` when the source should render verbatim. */
14
14
  nodes: ReactNode[] | null;
15
15
  highlighted: boolean;
16
+ /** Resolved grammar, including the detected language for unlabeled blocks. */
17
+ language?: string;
16
18
  }
17
- /** Highlight a source string without automatic language detection. */
19
+ /** Highlight explicit languages, or detect unlabeled code with bounded grammars. */
18
20
  export declare function highlightCode(value: string, language?: string): CodeHighlight;
19
21
  export interface CodeBlockViewProps {
20
22
  value: string;
@@ -0,0 +1,7 @@
1
+ import type { LanguageFn } from 'highlight.js';
2
+ /** Cattca embeds command blocks in Markdown narrative. */
3
+ export declare const cattca: LanguageFn;
4
+ /** Highlight Mermaid source as code; rendering diagrams is a separate feature. */
5
+ export declare const mermaid: LanguageFn;
6
+ /** Vue SFCs combine HTML templates, JavaScript/TypeScript and CSS/SCSS. */
7
+ export declare const vue: LanguageFn;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Publish compiler-owned data as ordinary records and arrays. Internal maps can
3
+ * keep null prototypes; React Server Component props require ordinary records.
4
+ * Keep undefined fields, shared references and existing frozen metadata intact.
5
+ */
6
+ export declare function plainCompiledData<T>(value: T): T;
@@ -1,3 +1,4 @@
1
1
  import type { LocalCompileOptions, LocalCompileResult } from './types.js';
2
+ /** Compile to plain data that can cross a React Server Component boundary. */
2
3
  export declare function compileLocal(source: string, options?: LocalCompileOptions): LocalCompileResult;
3
4
  export declare function compileLocalDocument(source: string, options?: LocalCompileOptions): LocalCompileResult;
@@ -230,6 +230,34 @@ export declare const LOCAL_DIAGNOSTIC_MESSAGES: {
230
230
  readonly en: 'Raw HTML is not part of the local interaction syntax.';
231
231
  readonly zh: '原始 HTML 不属于本地交互语法。';
232
232
  };
233
+ readonly 'html.fallback': {
234
+ readonly en: 'Native HTML was safely converted to inert source text.';
235
+ readonly zh: '原生 HTML 已安全回退为惰性源码文本。';
236
+ };
237
+ readonly 'html.fallbackAttribute': {
238
+ readonly en: 'Native HTML attribute {name} is unsupported; the element was safely converted to inert source text.';
239
+ readonly zh: '原生 HTML 属性 {name} 不受支持;该元素已安全回退为惰性源码文本。';
240
+ };
241
+ readonly 'html.table.structure': {
242
+ readonly en: 'Invalid native HTML table structure in <{tag}>.';
243
+ readonly zh: '原生 HTML 表格的 <{tag}> 结构无效。';
244
+ };
245
+ readonly 'html.table.mixed': {
246
+ readonly en: 'Keep text and Markdown inside cells or captions; native HTML table structure cannot mix with Markdown table rows.';
247
+ readonly zh: '文字和 Markdown 应写在单元格或标题内;原生 HTML 表格结构不能混用 Markdown 表格行。';
248
+ };
249
+ readonly 'html.table.attribute': {
250
+ readonly en: 'Attribute {name} is not supported on native HTML <{tag}>. ReactiveMD table options require a Markdown table body.';
251
+ readonly zh: '原生 HTML <{tag}> 不支持属性 {name}。ReactiveMD 表格选项只适用于 Markdown 表格正文。';
252
+ };
253
+ readonly 'html.table.value': {
254
+ readonly en: 'Invalid value for {name} on native HTML <{tag}>.';
255
+ readonly zh: '原生 HTML <{tag}> 的 {name} 属性值无效。';
256
+ };
257
+ readonly 'html.table.unclosed': {
258
+ readonly en: 'Native HTML table is missing </table>.';
259
+ readonly zh: '原生 HTML 表格缺少 </table>。';
260
+ };
233
261
  readonly 'html.extended': {
234
262
  readonly en: 'HTML element <{name}> requires enableExtendedHtml in this mode; it is shown as source.';
235
263
  readonly zh: '此模式下 HTML 元素 <{name}> 需要启用 enableExtendedHtml;已按源码显示。';
@@ -1326,6 +1354,9 @@ declare const LOCAL_DIAGNOSTIC_TEMPLATE_ALIASES: {
1326
1354
  readonly 'local.math.whitespace': 'math.whitespace';
1327
1355
  readonly 'local.footnote.unsupported': 'footnote.unsupported';
1328
1356
  readonly 'local.html': 'html.raw';
1357
+ readonly 'local.html.fallback': 'html.fallback';
1358
+ readonly 'local.html.fallback.attribute': 'html.fallbackAttribute';
1359
+ readonly 'local.html.table': 'html.table.structure';
1329
1360
  readonly 'local.html.extended': 'html.extended';
1330
1361
  readonly 'local.html.attribute': 'html.attribute';
1331
1362
  readonly 'local.html.unsafe-url': 'html.unsafeUrl';
@@ -0,0 +1,69 @@
1
+ export type DiagramDirection = 'right' | 'down';
2
+ export interface DiagramLayoutNodeInput {
3
+ id: string;
4
+ width: number;
5
+ height: number;
6
+ }
7
+ export interface DiagramLayoutEdgeInput {
8
+ id: string;
9
+ from: string;
10
+ to: string;
11
+ label?: string;
12
+ labelWidth?: number;
13
+ labelHeight?: number;
14
+ }
15
+ export interface DiagramLayoutInput {
16
+ direction: DiagramDirection;
17
+ nodes: DiagramLayoutNodeInput[];
18
+ edges: DiagramLayoutEdgeInput[];
19
+ }
20
+ export interface DiagramPoint {
21
+ x: number;
22
+ y: number;
23
+ }
24
+ export interface DiagramEdgeSection {
25
+ startPoint: DiagramPoint;
26
+ endPoint: DiagramPoint;
27
+ bendPoints: DiagramPoint[];
28
+ /** ELK spline points are cubic controls, not polyline vertices. */
29
+ cubic?: boolean;
30
+ }
31
+ /** Round routed corners without moving ports or leaving the routing corridor. */
32
+ export declare function diagramEdgePath(sections: DiagramEdgeSection[], radius?: number): string;
33
+ export interface DiagramLabelRect {
34
+ x: number;
35
+ y: number;
36
+ width: number;
37
+ height: number;
38
+ }
39
+ export interface DiagramEdgeLayout {
40
+ sections: DiagramEdgeSection[];
41
+ label?: DiagramLabelRect;
42
+ }
43
+ export interface DiagramNodeLayout {
44
+ /** Node centre, matching the SVG translate used for node cards. */
45
+ x: number;
46
+ y: number;
47
+ width: number;
48
+ height: number;
49
+ }
50
+ export interface DiagramLayoutResult {
51
+ width: number;
52
+ height: number;
53
+ nodes: Map<string, DiagramNodeLayout>;
54
+ edges: Map<string, DiagramEdgeLayout>;
55
+ source: 'elk' | 'fallback';
56
+ }
57
+ /** Every value that can change geometry; selection, tone and body do not. */
58
+ export declare function diagramLayoutKey(input: DiagramLayoutInput): string;
59
+ /**
60
+ * Resolves the layered layout. Failures (including an unsupported runtime)
61
+ * degrade to the synchronous fallback instead of breaking the diagram.
62
+ */
63
+ export declare function layoutDiagram(input: DiagramLayoutInput): Promise<DiagramLayoutResult>;
64
+ /**
65
+ * Deterministic layered layout used before ELK resolves (SSR, static export
66
+ * and first paint). Cycle-closing edges found by a declaration-order DFS are
67
+ * ignored for layering and routed outside the node band.
68
+ */
69
+ export declare function createDiagramLayoutFallback(input: DiagramLayoutInput): DiagramLayoutResult;