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.
- package/CHANGELOG-ch.md +195 -165
- package/CHANGELOG.md +195 -165
- package/CONTRIBUTING-ch.md +67 -62
- package/CONTRIBUTING.md +69 -64
- package/README-ch.md +157 -155
- package/README-en.md +184 -181
- package/README.md +184 -181
- package/SECURITY-ch.md +81 -81
- package/SECURITY.md +81 -81
- package/THIRD_PARTY_NOTICES.md +585 -1
- package/bin/reactive-md.mjs +39 -39
- package/cli/args.mjs +181 -181
- package/cli/assets.mjs +390 -390
- package/cli/build.mjs +268 -268
- package/cli/document.mjs +130 -130
- package/cli/errors.mjs +61 -61
- package/cli/fs-utils.mjs +133 -133
- package/cli/glob.mjs +203 -203
- package/cli/help.mjs +138 -138
- package/cli/lint.mjs +177 -177
- package/cli/main.mjs +55 -55
- package/cli/migrate.mjs +368 -368
- package/cli/package.mjs +210 -210
- package/dist-library/{authoring-DJJjKYg9.js → authoring-BEVyth5X.js} +58 -58
- package/dist-library/compiler-Cm3ppMxG.js +46044 -0
- package/dist-library/react-Bh7_oxZp.js +59655 -0
- package/dist-library/reactive-md-authoring.js +2 -2
- package/dist-library/reactive-md-editor.js +13 -0
- package/dist-library/reactive-md-print.css +284 -284
- package/dist-library/reactive-md-react-unstyled.js +1 -1
- package/dist-library/reactive-md-react.js +1 -1
- package/dist-library/reactive-md.css +1 -1
- package/dist-library/reactive-md.js +123 -123
- package/dist-library/{runtime-DXtle_6c.js → runtime-DlFYQ4s_.js} +151 -151
- package/dist-library/types/editor/types.d.ts +2 -0
- package/dist-library/types/local/code-block.d.ts +3 -1
- package/dist-library/types/local/code-languages.d.ts +7 -0
- package/dist-library/types/local/compiled-data.d.ts +6 -0
- package/dist-library/types/local/compiler.d.ts +1 -0
- package/dist-library/types/local/diagnostics.d.ts +31 -0
- package/dist-library/types/local/diagram-layout.d.ts +69 -0
- package/dist-library/types/local/html-names.d.ts +6 -0
- package/dist-library/types/local/html-table.d.ts +25 -0
- package/dist-library/types/local/math-display.d.ts +22 -22
- package/dist-library/types/local/math-view.d.ts +6 -7
- package/dist-library/types/local/table-surface.d.ts +10 -0
- package/dist-library/types/local/types.d.ts +2 -0
- package/dist-library/types/local/visuals.d.ts +9 -0
- package/dist-standalone/reactive-md-standalone.css +1 -1
- package/dist-standalone/reactive-md-standalone.js +331 -51
- package/docs/README.md +84 -0
- package/docs/{compatibility-ch.md → compatibility/compatibility-ch.md} +121 -109
- package/docs/{compatibility-en.md → compatibility/compatibility-en.md} +121 -109
- package/docs/{source-versioning-ch.md → compatibility/source-versioning-ch.md} +159 -159
- package/docs/{source-versioning-en.md → compatibility/source-versioning-en.md} +159 -159
- package/docs/{component-development-ch.md → development/component-development-ch.md} +210 -210
- package/docs/{component-development-en.md → development/component-development-en.md} +210 -210
- package/docs/{component-protocol-ch.md → development/component-protocol-ch.md} +747 -747
- package/docs/{component-protocol-en.md → development/component-protocol-en.md} +747 -747
- package/docs/{performance-ch.md → development/performance-ch.md} +76 -76
- package/docs/{performance-en.md → development/performance-en.md} +76 -76
- package/docs/{releasing-ch.md → development/releasing-ch.md} +108 -108
- package/docs/{releasing-en.md → development/releasing-en.md} +108 -108
- package/docs/guides/local-guide-ch.md +513 -0
- package/docs/guides/local-guide-en.md +513 -0
- package/docs/{author-tools-ch.md → integration/author-tools-ch.md} +57 -57
- package/docs/{author-tools-en.md → integration/author-tools-en.md} +57 -57
- package/docs/{editor-ch.md → integration/editor-ch.md} +7 -6
- package/docs/{editor-en.md → integration/editor-en.md} +7 -6
- package/docs/{local-integration-ch.md → integration/local-integration-ch.md} +33 -15
- package/docs/{local-integration-en.md → integration/local-integration-en.md} +33 -15
- package/docs/{shareable-export-ch.md → integration/shareable-export-ch.md} +221 -209
- package/docs/{shareable-export-en.md → integration/shareable-export-en.md} +223 -211
- package/docs/{computations-formatting-ch.md → reference/computations-formatting-ch.md} +87 -87
- package/docs/{computations-formatting-en.md → reference/computations-formatting-en.md} +87 -87
- package/docs/{constraints-collections-ch.md → reference/constraints-collections-ch.md} +84 -84
- package/docs/{constraints-collections-en.md → reference/constraints-collections-en.md} +84 -84
- package/docs/{diagnostics-counting-ch.md → reference/diagnostics-counting-ch.md} +104 -84
- package/docs/{diagnostics-counting-en.md → reference/diagnostics-counting-en.md} +104 -84
- package/docs/{html-compatibility-ch.md → reference/html-compatibility-ch.md} +42 -4
- package/docs/{html-compatibility-en.md → reference/html-compatibility-en.md} +42 -4
- package/docs/{local-components-v2-ch.md → reference/local-components-v2-ch.md} +138 -138
- package/docs/{local-components-v2-en.md → reference/local-components-v2-en.md} +104 -104
- package/docs/{local-interaction-syntax-ch.md → reference/local-interaction-syntax-ch.md} +515 -492
- package/docs/{local-interaction-syntax-en.md → reference/local-interaction-syntax-en.md} +511 -488
- package/docs/{theme-protocol-ch.md → reference/theme-protocol-ch.md} +107 -107
- package/docs/{theme-protocol-en.md → reference/theme-protocol-en.md} +107 -107
- package/docs/{release-0.4.0-ch.md → releases/release-0.4.0-ch.md} +89 -89
- package/docs/{release-0.4.0-en.md → releases/release-0.4.0-en.md} +89 -89
- package/docs/{release-0.4.1-ch.md → releases/release-0.4.1-ch.md} +23 -23
- package/docs/{release-0.4.1-en.md → releases/release-0.4.1-en.md} +23 -23
- package/docs/{release-0.5.0-ch.md → releases/release-0.5.0-ch.md} +4 -4
- package/docs/{release-0.5.0-en.md → releases/release-0.5.0-en.md} +4 -4
- package/docs/{release-0.5.1-ch.md → releases/release-0.5.1-ch.md} +4 -4
- package/docs/{release-0.5.1-en.md → releases/release-0.5.1-en.md} +4 -4
- package/docs/{release-0.5.2-ch.md → releases/release-0.5.2-ch.md} +3 -3
- package/docs/{release-0.5.2-en.md → releases/release-0.5.2-en.md} +3 -3
- package/docs/{release-0.5.3-ch.md → releases/release-0.5.3-ch.md} +1 -1
- package/docs/{release-0.5.3-en.md → releases/release-0.5.3-en.md} +1 -1
- package/docs/releases/release-0.6.0-ch.md +57 -0
- package/docs/releases/release-0.6.0-en.md +57 -0
- package/docs/releases/release-0.6.1-ch.md +27 -0
- package/docs/releases/release-0.6.1-en.md +27 -0
- package/examples/conformance/README.md +53 -53
- package/examples/conformance/component-protocol-1.json +482 -482
- package/examples/conformance/component-protocol-1.schema.json +76 -76
- package/examples/conformance/local-draft-1.json +50 -50
- package/examples/conformance/local-draft-2.json +212 -212
- package/examples/integration/README.md +47 -45
- package/examples/integration/core/index.mjs +32 -32
- package/examples/integration/worker/index.html +19 -19
- package/examples/integration/worker/main.js +61 -61
- package/examples/integration/worker/package.json +13 -13
- package/examples/integration/worker/worker.js +3 -3
- package/examples/local/README.md +74 -74
- package/examples/local/charts.reactive.md +73 -73
- package/examples/local/html-compat.reactive.md +19 -0
- package/examples/local/recipes/invoice-zh.reactive.md +36 -36
- package/examples/local/recipes/invoice.reactive.md +36 -36
- package/examples/local/recipes/workshop-zh.reactive.md +33 -33
- package/examples/local/recipes/workshop.reactive.md +33 -33
- package/examples/local/showcase/README.md +25 -25
- package/examples/local/showcase/explore.reactive.md +102 -102
- package/examples/local/showcase/flow.reactive.md +86 -86
- package/examples/local/showcase/forms.reactive.md +126 -126
- package/examples/local/showcase/functions.reactive.md +119 -119
- package/examples/local/showcase/layout.reactive.md +100 -100
- package/examples/local/showcase/statistics.reactive.md +108 -108
- package/examples/local/showcase/tasks.reactive.md +89 -89
- package/examples/local/showcase/zh/explore.reactive.md +102 -102
- package/examples/local/showcase/zh/flow.reactive.md +86 -86
- package/examples/local/showcase/zh/forms.reactive.md +126 -126
- package/examples/local/showcase/zh/functions.reactive.md +119 -119
- package/examples/local/showcase/zh/layout.reactive.md +100 -100
- package/examples/local/showcase/zh/statistics.reactive.md +108 -108
- package/examples/local/showcase/zh/tasks.reactive.md +89 -89
- package/package.json +152 -145
- package/dist-library/compiler-UyPwGzJZ.js +0 -22109
- package/dist-library/react-fizgU3i8.js +0 -12764
- package/docs/local-guide-ch.md +0 -967
- package/docs/local-guide-en.md +0 -967
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as e,
|
|
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 === "" ||
|
|
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:
|
|
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(
|
|
71
|
-
return e
|
|
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:
|
|
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 (!
|
|
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 =
|
|
133
|
+
let r = u(n);
|
|
134
134
|
if (r) return A("local.runtime.value.budget", {
|
|
135
135
|
name: e.name,
|
|
136
|
-
detail:
|
|
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 =
|
|
154
|
+
let t = u(n);
|
|
155
155
|
if (t) return A("local.runtime.value.budget", {
|
|
156
156
|
name: e.name,
|
|
157
|
-
detail:
|
|
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(
|
|
184
|
-
if (!
|
|
185
|
-
if (
|
|
186
|
-
let
|
|
187
|
-
for (let t of e)
|
|
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
|
-
|
|
189
|
+
_(s.nodes);
|
|
190
190
|
let v = {}, S = /* @__PURE__ */ new Map();
|
|
191
|
-
for (let [
|
|
192
|
-
let
|
|
193
|
-
if (
|
|
194
|
-
v[
|
|
195
|
-
let
|
|
196
|
-
for (let e of
|
|
197
|
-
let t =
|
|
198
|
-
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(
|
|
200
|
+
S.set(e, r);
|
|
201
201
|
}
|
|
202
202
|
let C = /* @__PURE__ */ new Map();
|
|
203
|
-
for (let [
|
|
204
|
-
let E = Object.freeze(Object.keys(
|
|
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 =
|
|
216
|
-
for (let [e,
|
|
217
|
-
j.set(e, t
|
|
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 } =
|
|
220
|
-
for (let
|
|
221
|
-
let
|
|
222
|
-
if (!
|
|
223
|
-
if (Object.hasOwn(
|
|
224
|
-
let 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(
|
|
226
|
+
F.set(t, new a("expression-budget", `Constant "${t}": ${i}`, 0));
|
|
227
227
|
continue;
|
|
228
228
|
}
|
|
229
|
-
P[
|
|
229
|
+
P[t] = y(r);
|
|
230
230
|
continue;
|
|
231
231
|
}
|
|
232
|
-
let r = j.get(
|
|
233
|
-
if (!r) F.set(
|
|
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
|
|
235
|
+
let n = r.evaluate({ ...P }), i = e(n);
|
|
236
236
|
if (i) {
|
|
237
|
-
F.set(
|
|
237
|
+
F.set(t, new a("expression-budget", `Constant "${t}": ${i}`, 0));
|
|
238
238
|
continue;
|
|
239
239
|
}
|
|
240
|
-
P[
|
|
241
|
-
} catch (
|
|
242
|
-
F.set(
|
|
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
|
|
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(
|
|
249
|
-
for (let
|
|
248
|
+
if (Array.isArray(s.validations)) {
|
|
249
|
+
for (let e of s.validations) if (l(e)) try {
|
|
250
250
|
R.push({
|
|
251
|
-
rule:
|
|
252
|
-
expression:
|
|
251
|
+
rule: e,
|
|
252
|
+
expression: o(e.expression),
|
|
253
253
|
error: null
|
|
254
254
|
});
|
|
255
|
-
} catch (
|
|
255
|
+
} catch (t) {
|
|
256
256
|
R.push({
|
|
257
|
-
rule:
|
|
257
|
+
rule: e,
|
|
258
258
|
expression: null,
|
|
259
|
-
error: I(
|
|
259
|
+
error: I(t)
|
|
260
260
|
});
|
|
261
261
|
}
|
|
262
262
|
}
|
|
263
|
-
let z =
|
|
263
|
+
let z = ee(typeof s.source == "string" ? s.source : ""), B = null, oe = (e) => {
|
|
264
264
|
let t;
|
|
265
265
|
try {
|
|
266
|
-
t =
|
|
266
|
+
t = r(e, G);
|
|
267
267
|
} catch {
|
|
268
|
-
t =
|
|
268
|
+
t = te;
|
|
269
269
|
}
|
|
270
|
-
return
|
|
270
|
+
return m(t);
|
|
271
271
|
}, se = () => {
|
|
272
|
-
let
|
|
273
|
-
for (let
|
|
274
|
-
if (
|
|
275
|
-
|
|
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 (!
|
|
278
|
+
if (!n.expression) continue;
|
|
279
279
|
let r;
|
|
280
280
|
try {
|
|
281
|
-
r =
|
|
281
|
+
r = n.expression.evaluate(G);
|
|
282
282
|
} catch (r) {
|
|
283
|
-
|
|
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 ||
|
|
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
|
|
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 =
|
|
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
|
|
314
|
-
for (let [e,
|
|
315
|
-
for (let [e,
|
|
316
|
-
K =
|
|
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 = (
|
|
326
|
-
let
|
|
327
|
-
return
|
|
328
|
-
}, de = (
|
|
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
|
|
331
|
-
for (let
|
|
332
|
-
if (
|
|
333
|
-
|
|
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 (
|
|
337
|
-
|
|
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(
|
|
341
|
-
|
|
340
|
+
if (!Object.hasOwn(s.bindings, i)) {
|
|
341
|
+
t.push(T("local.runtime.parameter", `Unknown parameter "${i}".`));
|
|
342
342
|
continue;
|
|
343
343
|
}
|
|
344
|
-
let
|
|
345
|
-
|
|
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 (
|
|
348
|
-
if (!
|
|
349
|
-
let
|
|
347
|
+
if (t.length) return t;
|
|
348
|
+
if (!r.some((e) => !x(V[e], n[e]))) return [];
|
|
349
|
+
let i = {
|
|
350
350
|
...V,
|
|
351
|
-
...
|
|
352
|
-
},
|
|
353
|
-
for (let e of
|
|
354
|
-
for (let
|
|
355
|
-
let
|
|
356
|
-
|
|
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
|
|
358
|
+
return t.length ? t : ($(i), []);
|
|
359
359
|
};
|
|
360
360
|
ce(), le();
|
|
361
361
|
let fe = (e) => {
|
|
362
|
-
let
|
|
363
|
-
if (!
|
|
364
|
-
if (
|
|
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,
|
|
368
|
+
Z.set(e, t);
|
|
369
369
|
}
|
|
370
|
-
return
|
|
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:
|
|
379
|
+
document: s,
|
|
380
380
|
snapshot() {
|
|
381
381
|
return Q(), q;
|
|
382
382
|
},
|
|
383
383
|
get(e, t) {
|
|
384
384
|
Q();
|
|
385
|
-
let n =
|
|
385
|
+
let n = p.get(e.id);
|
|
386
386
|
if (!n) return null;
|
|
387
|
-
let r = t === void 0 ?
|
|
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
|
|
390
|
+
set(e, t, n) {
|
|
391
391
|
Q();
|
|
392
|
-
let
|
|
393
|
-
if (!
|
|
394
|
-
let
|
|
395
|
-
if (
|
|
396
|
-
if (
|
|
397
|
-
|
|
398
|
-
} else if (
|
|
399
|
-
let
|
|
400
|
-
if (!
|
|
401
|
-
let
|
|
402
|
-
if (!
|
|
403
|
-
let
|
|
404
|
-
if (x(V[
|
|
405
|
-
let
|
|
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
|
-
[
|
|
407
|
+
[a]: l
|
|
408
408
|
};
|
|
409
|
-
return O(
|
|
409
|
+
return O(r.id, u) ? [w(s, r, "local.runtime.value", h("local.runtime.value.range-order"))] : ($(u), []);
|
|
410
410
|
},
|
|
411
|
-
setMany(
|
|
411
|
+
setMany(e, t) {
|
|
412
412
|
Q();
|
|
413
|
-
let
|
|
414
|
-
if (!
|
|
415
|
-
let
|
|
416
|
-
if (!
|
|
417
|
-
let
|
|
418
|
-
if (!
|
|
419
|
-
let
|
|
420
|
-
for (let [
|
|
421
|
-
let
|
|
422
|
-
if (!
|
|
423
|
-
let
|
|
424
|
-
if (!
|
|
425
|
-
|
|
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(
|
|
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(
|
|
433
|
-
if (Q(), !
|
|
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(),
|
|
467
|
+
return Q(), r(e, G);
|
|
468
468
|
},
|
|
469
|
-
reset(
|
|
469
|
+
reset(e) {
|
|
470
470
|
Q();
|
|
471
|
-
let
|
|
472
|
-
if (!
|
|
473
|
-
let
|
|
474
|
-
for (let [
|
|
475
|
-
if (!(S.get(
|
|
476
|
-
let
|
|
477
|
-
if (
|
|
478
|
-
|
|
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
|
|
481
|
-
$(
|
|
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 =
|
|
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
|
|
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;
|