reactive-md 0.5.2 → 0.5.3

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 (45) hide show
  1. package/CHANGELOG-ch.md +11 -0
  2. package/CHANGELOG.md +11 -0
  3. package/README-ch.md +7 -7
  4. package/README-en.md +8 -8
  5. package/README.md +8 -8
  6. package/cli/build.mjs +1 -1
  7. package/cli/package.mjs +1 -0
  8. package/dist-library/authoring-DJJjKYg9.js +842 -0
  9. package/dist-library/{runtime-UiQPz5ZV.js → compiler-UyPwGzJZ.js} +5631 -5389
  10. package/dist-library/react-fizgU3i8.js +12764 -0
  11. package/dist-library/reactive-md-authoring.js +1514 -0
  12. package/dist-library/reactive-md-editor.js +577 -571
  13. package/dist-library/reactive-md-print.css +284 -0
  14. package/dist-library/reactive-md-react-unstyled.js +1 -0
  15. package/dist-library/reactive-md-react.js +1 -13208
  16. package/dist-library/reactive-md.css +1 -1
  17. package/dist-library/reactive-md.js +244 -1062
  18. package/dist-library/runtime-DXtle_6c.js +498 -0
  19. package/dist-library/types/authoring/index.d.ts +24 -0
  20. package/dist-library/types/editor/command-types.d.ts +10 -0
  21. package/dist-library/types/editor/editor-commands.d.ts +2 -2
  22. package/dist-library/types/editor/editor-i18n.d.ts +1 -1
  23. package/dist-library/types/editor/native-components.d.ts +1 -1
  24. package/dist-library/types/editor/source-authoring.d.ts +5 -3
  25. package/dist-library/types/editor/types.d.ts +5 -10
  26. package/dist-library/types/local/LocalDocumentView.d.ts +4 -2
  27. package/dist-library/types/local/authoring.d.ts +9 -5
  28. package/dist-library/types/local/diagnostics.d.ts +40 -0
  29. package/dist-library/types/local/index.d.ts +1 -0
  30. package/dist-library/types/local/math-display.d.ts +72 -0
  31. package/dist-library/types/local/math-view.d.ts +2 -0
  32. package/dist-library/types/local/options.d.ts +3 -1
  33. package/dist-library/types/local/types.d.ts +10 -0
  34. package/dist-library/types/local/worker.d.ts +3 -2
  35. package/dist-library/types/react/index.d.ts +1 -1
  36. package/dist-standalone/reactive-md-standalone.js +54 -50
  37. package/docs/author-tools-ch.md +11 -5
  38. package/docs/author-tools-en.md +11 -5
  39. package/docs/editor-ch.md +237 -235
  40. package/docs/editor-en.md +237 -235
  41. package/docs/local-integration-ch.md +392 -390
  42. package/docs/local-integration-en.md +392 -390
  43. package/docs/release-0.5.3-ch.md +25 -0
  44. package/docs/release-0.5.3-en.md +25 -0
  45. package/package.json +12 -2
@@ -0,0 +1,498 @@
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";
2
+ // src/local/runtime.ts
3
+ var v = 1e-9, re = 200;
4
+ function y(e) {
5
+ return Array.isArray(e) ? e.slice() : e;
6
+ }
7
+ function b(e) {
8
+ return {
9
+ ...e,
10
+ range: { ...e.range }
11
+ };
12
+ }
13
+ function x(e, t) {
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
+ }
16
+ function S(e) {
17
+ return e === "" || d(e) !== null;
18
+ }
19
+ function C(e, t, n) {
20
+ let r = (e - t) / n;
21
+ return Math.abs(r - Math.round(r)) <= v * Math.max(1, Math.abs(r));
22
+ }
23
+ function ie(e) {
24
+ for (let [t, n] of Object.entries(e)) Array.isArray(n) && !Object.isFrozen(n) && (e[t] = Object.freeze([...n]));
25
+ return Object.freeze(e);
26
+ }
27
+ function w(e, t, n, r) {
28
+ let i = Math.max(0, Math.min(e.source.length, t.range.start)), a = e.source.slice(0, i).split("\n");
29
+ return {
30
+ code: n,
31
+ message: g(r),
32
+ severity: "error",
33
+ range: {
34
+ start: i,
35
+ end: Math.max(i + 1, Math.min(e.source.length, t.range.end))
36
+ },
37
+ line: a.length,
38
+ column: (a.at(-1) ?? "").length + 1,
39
+ messageKey: r.key,
40
+ ...r.params ? { params: r.params } : {}
41
+ };
42
+ }
43
+ function T(e, t) {
44
+ return {
45
+ code: e,
46
+ message: t,
47
+ severity: "error",
48
+ range: {
49
+ start: 0,
50
+ end: 0
51
+ },
52
+ line: 1,
53
+ column: 1
54
+ };
55
+ }
56
+ function E(e, t) {
57
+ return e.attrs?.[t];
58
+ }
59
+ function D(e, t) {
60
+ let n = E(e, t);
61
+ if (n === "true") return !0;
62
+ if (n === "false") return !1;
63
+ }
64
+ function O(e, t) {
65
+ let n = E(e, t);
66
+ if (n === void 0) return;
67
+ let r = Number(n);
68
+ return Number.isFinite(r) ? r : void 0;
69
+ }
70
+ function k(t) {
71
+ return e(t);
72
+ }
73
+ function A(e, t) {
74
+ return {
75
+ ok: !1,
76
+ detail: p(e, t)
77
+ };
78
+ }
79
+ function j(e, t) {
80
+ if (e.name === "date") {
81
+ if (!S(t)) return A("local.runtime.value.date-invalid");
82
+ if (t === "" && D(e, "required") === !0) return A("local.runtime.value.date-required");
83
+ let n = E(e, "min"), r = E(e, "max");
84
+ return t !== "" && n && t < n ? A("local.runtime.value.date-earlier", { min: n }) : t !== "" && r && t > r ? A("local.runtime.value.date-later", { max: r }) : {
85
+ ok: !0,
86
+ value: t
87
+ };
88
+ }
89
+ if (e.name === "input" || e.name === "textarea") {
90
+ let n = k(t);
91
+ if (t === "" && D(e, "required") === !0) return A("local.runtime.value.field-required");
92
+ let r = O(e, "min-length"), i = O(e, "max-length");
93
+ if (r !== void 0 && r > 0 && t !== "" && n < r) return A("local.runtime.value.min-length", { min: r });
94
+ if (i !== void 0 && n > i) return A("local.runtime.value.max-length", { max: i });
95
+ if (e.name === "input" && E(e, "type") === "email" && t !== "") {
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");
98
+ }
99
+ }
100
+ return {
101
+ ok: !0,
102
+ value: t
103
+ };
104
+ }
105
+ function M(e, t, n) {
106
+ switch (e.type) {
107
+ case "number": {
108
+ if (typeof n != "number" || !Number.isFinite(n)) return A("local.runtime.value.finite-number", { name: e.name });
109
+ if (e.min !== void 0 && n < e.min) return A("local.runtime.value.min", {
110
+ name: e.name,
111
+ min: e.min
112
+ });
113
+ if (e.max !== void 0 && n > e.max) return A("local.runtime.value.max", {
114
+ name: e.name,
115
+ max: e.max
116
+ });
117
+ let t = e.step ?? 1, r = e.min ?? 0;
118
+ return t > 0 && !C(n, r, t) ? A("local.runtime.value.step", {
119
+ name: e.name,
120
+ step: t,
121
+ base: r
122
+ }) : {
123
+ ok: !0,
124
+ value: n
125
+ };
126
+ }
127
+ case "boolean": return typeof n == "boolean" ? {
128
+ ok: !0,
129
+ value: n
130
+ } : A("local.runtime.value.boolean", { name: e.name });
131
+ case "string": {
132
+ if (typeof n != "string") return A("local.runtime.value.string", { name: e.name });
133
+ let r = c(n);
134
+ if (r) return A("local.runtime.value.budget", {
135
+ name: e.name,
136
+ detail: g(r),
137
+ detailKey: r.key,
138
+ ...r.params
139
+ });
140
+ for (let e of t) {
141
+ let t = j(e, n);
142
+ if (!t.ok) return t;
143
+ }
144
+ return e.options?.length && !e.options.includes(n) ? A("local.runtime.value.option", {
145
+ value: n,
146
+ options: e.options.join(", ")
147
+ }) : {
148
+ ok: !0,
149
+ value: n
150
+ };
151
+ }
152
+ case "array": {
153
+ if (!Array.isArray(n)) return A("local.runtime.value.array", { name: e.name });
154
+ let t = c(n);
155
+ if (t) return A("local.runtime.value.budget", {
156
+ name: e.name,
157
+ detail: g(t),
158
+ detailKey: t.key,
159
+ ...t.params
160
+ });
161
+ let r = /* @__PURE__ */ new Set();
162
+ for (let t of n) {
163
+ if (typeof t != "string") return A("local.runtime.value.array-members", { name: e.name });
164
+ if (e.options && !e.options.includes(t)) return A("local.runtime.value.checklist-option", { value: t });
165
+ r.add(t);
166
+ }
167
+ let i = e.options ? e.options.filter((e) => r.has(e)) : [...r];
168
+ return e.maxItems !== void 0 && i.length > e.maxItems ? A("local.runtime.value.max-items", {
169
+ name: e.name,
170
+ max: e.maxItems
171
+ }) : {
172
+ ok: !0,
173
+ value: i
174
+ };
175
+ }
176
+ case "null": return {
177
+ ok: !0,
178
+ value: n
179
+ };
180
+ }
181
+ return A("local.runtime.value.unsupported-type", { name: e.name });
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);
188
+ };
189
+ m(e.nodes);
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);
199
+ }
200
+ S.set(t, i);
201
+ }
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();
205
+ for (let [e, t] of C) for (let n of Object.values(t)) {
206
+ if (n.startsWith("@")) continue;
207
+ let t = D.get(n) ?? /* @__PURE__ */ new Set();
208
+ t.add(e), D.set(n, t);
209
+ }
210
+ let O = (e, t) => {
211
+ let n = C.get(e);
212
+ if (!n?.start || !n?.end) return !1;
213
+ let r = t[n.start], i = t[n.end];
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));
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);
225
+ if (i) {
226
+ F.set(e, new n("expression-budget", `Constant "${e}": ${i}`, 0));
227
+ continue;
228
+ }
229
+ P[e] = y(r);
230
+ continue;
231
+ }
232
+ let r = j.get(e);
233
+ if (!r) F.set(e, new n("expression-eval", `Constant "${e}" cannot be evaluated.`, 0));
234
+ else try {
235
+ let t = r.evaluate({ ...P }), i = o(t);
236
+ if (i) {
237
+ F.set(e, new n("expression-budget", `Constant "${e}": ${i}`, 0));
238
+ continue;
239
+ }
240
+ P[e] = y(t);
241
+ } catch (t) {
242
+ F.set(e, I(t));
243
+ }
244
+ }
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));
247
+ let R = [];
248
+ if (Array.isArray(e.validations)) {
249
+ for (let n of e.validations) if (u(n)) try {
250
+ R.push({
251
+ rule: n,
252
+ expression: t(n.expression),
253
+ error: null
254
+ });
255
+ } catch (e) {
256
+ R.push({
257
+ rule: n,
258
+ expression: null,
259
+ error: I(e)
260
+ });
261
+ }
262
+ }
263
+ let z = te(typeof e.source == "string" ? e.source : ""), B = null, oe = (e) => {
264
+ let t;
265
+ try {
266
+ t = s(e, G);
267
+ } catch {
268
+ t = ne;
269
+ }
270
+ return h(t);
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}`)));
276
+ continue;
277
+ }
278
+ if (!e.expression) continue;
279
+ let r;
280
+ try {
281
+ r = e.expression.evaluate(G);
282
+ } catch (r) {
283
+ t.push(_(n, z, e.rule.range, f, h(`Validation expression failed: ${r instanceof Error ? r.message : String(r)}`)));
284
+ continue;
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."));
287
+ }
288
+ return t;
289
+ }, V = v, H = 0, U = {}, W = /* @__PURE__ */ new Map(), G = {}, K = {}, q = {
290
+ revision: 0,
291
+ state: ie({})
292
+ }, J = !1, Y = /* @__PURE__ */ new Set(), X = /* @__PURE__ */ new Map(), Z = /* @__PURE__ */ new Map(), Q = () => {
293
+ if (J) throw Error("The local interaction runtime has been disposed.");
294
+ }, ce = () => {
295
+ if (A.length === 0) U = {}, W = /* @__PURE__ */ new Map();
296
+ else {
297
+ let e = r(k, N, j, V, P);
298
+ U = e.values, W = e.errors;
299
+ for (let [e, t] of F) Object.hasOwn(U, e) || W.set(e, t);
300
+ for (let [e, t] of L) Object.hasOwn(U, e) || W.set(e, t);
301
+ }
302
+ let e = {};
303
+ for (let [t, n] of Object.entries(V)) e[t] = n;
304
+ for (let [t, n] of Object.entries(U)) e[t] = n;
305
+ for (let [t, n] of W) Object.hasOwn(U, t) || Object.defineProperty(e, t, {
306
+ enumerable: !0,
307
+ configurable: !0,
308
+ get() {
309
+ throw n;
310
+ }
311
+ });
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;
317
+ }, le = () => {
318
+ q = {
319
+ revision: H,
320
+ state: ie(K)
321
+ };
322
+ }, $ = (e) => {
323
+ V = e, H += 1, ce(), le();
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) => {
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__\"."));
334
+ continue;
335
+ }
336
+ if (a.startsWith("@")) {
337
+ n.push(T("local.runtime.parameter", `Internal parameter "${a}" cannot be written by name.`));
338
+ continue;
339
+ }
340
+ if (!Object.hasOwn(e.bindings, a)) {
341
+ n.push(T("local.runtime.parameter", `Unknown parameter "${a}".`));
342
+ continue;
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));
346
+ }
347
+ if (n.length) return n;
348
+ if (!i.some((e) => !x(V[e], r[e]))) return [];
349
+ let a = {
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"))));
357
+ }
358
+ return n.length ? n : ($(a), []);
359
+ };
360
+ ce(), le();
361
+ let fe = (e) => {
362
+ let n = Z.get(e);
363
+ if (!n) {
364
+ if (n = t(e), Z.size >= re) {
365
+ let e = Z.keys().next().value;
366
+ e !== void 0 && Z.delete(e);
367
+ }
368
+ Z.set(e, n);
369
+ }
370
+ return n;
371
+ }, pe = (e) => {
372
+ let t = /* @__PURE__ */ new Set(), n = (e) => {
373
+ t.add(e.id);
374
+ for (let t of e.children ?? []) n(t);
375
+ };
376
+ return n(e), t;
377
+ };
378
+ return {
379
+ document: e,
380
+ snapshot() {
381
+ return Q(), q;
382
+ },
383
+ get(e, t) {
384
+ Q();
385
+ let n = d.get(e.id);
386
+ if (!n) return null;
387
+ let r = t === void 0 ? i(n) : C.get(n.id)?.[t];
388
+ return r && Object.hasOwn(V, r) ? y(V[r]) : null;
389
+ },
390
+ set(t, n, r) {
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 = {
406
+ ...V,
407
+ [s]: u
408
+ };
409
+ return O(a.id, f) ? [w(e, a, "local.runtime.value", p("local.runtime.value.range-order"))] : ($(f), []);
410
+ },
411
+ setMany(t, n) {
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);
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), []);
428
+ },
429
+ parameterNames() {
430
+ return Q(), E;
431
+ },
432
+ getParameter(t) {
433
+ if (Q(), !t.startsWith("@") && Object.hasOwn(e.bindings, t)) return Object.hasOwn(V, t) ? y(V[t]) : void 0;
434
+ },
435
+ getParameters() {
436
+ Q();
437
+ let e = {};
438
+ for (let t of E) {
439
+ let n = V[t];
440
+ e[t] = Array.isArray(n) ? Object.freeze([...n]) : n;
441
+ }
442
+ return Object.freeze(e);
443
+ },
444
+ setParameter(e, t) {
445
+ Q();
446
+ let n = Object.create(null);
447
+ return n[e] = t, de(n);
448
+ },
449
+ setParameters(e) {
450
+ if (Q(), typeof e != "object" || !e || Array.isArray(e)) throw TypeError("setParameters requires an object of parameter values.");
451
+ return de(e);
452
+ },
453
+ evaluate(e) {
454
+ Q();
455
+ let t = fe(e).evaluate(G);
456
+ return Array.isArray(t) ? t.slice() : t;
457
+ },
458
+ validate() {
459
+ if (Q(), B && B.revision === H) return B.diagnostics.map(b);
460
+ let e = se();
461
+ return B = {
462
+ revision: H,
463
+ diagnostics: e
464
+ }, e.map(b);
465
+ },
466
+ text(e) {
467
+ return Q(), s(e, G);
468
+ },
469
+ reset(t) {
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);
479
+ }
480
+ for (let e of i) X.set(e, (X.get(e) ?? 0) + 1);
481
+ $(a);
482
+ },
483
+ resetToken(e) {
484
+ Q();
485
+ let t = d.get(e.id);
486
+ return t ? X.get(t.id) ?? 0 : 0;
487
+ },
488
+ subscribe(e) {
489
+ return Q(), Y.add(e), () => {
490
+ Y.delete(e);
491
+ };
492
+ },
493
+ dispose() {
494
+ J || (J = !0, Y.clear(), Z.clear(), j.clear(), X.clear());
495
+ }
496
+ };
497
+ }
498
+ export { N as t };
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Public, DOM-free authoring entry for Reactive MD.
3
+ *
4
+ * This module is the stable surface for non-React hosts (for example a
5
+ * CodeMirror 6 extension). It re-exports the pure authoring services, the
6
+ * component schema, the native-component catalog with template rendering, and
7
+ * the pure Markdown toolbar commands. Nothing here imports React, a stylesheet
8
+ * or a UI component, so the entry can run in a worker or a server process.
9
+ *
10
+ * Compile options mirror the preview pipeline: pass the same
11
+ * `LocalCompileOptions` used for rendering so analysis diagnostics, host
12
+ * components, limits and HTML mode stay consistent.
13
+ */
14
+ export { analyzeLocalSource, completeLocalSource, formatLocalSource, renameLocalBinding, } from '../local/authoring.js';
15
+ export type { AuthorAnalysis, AuthorBinding, AuthorCompletion, AuthorCompletionKind, AuthorRename, AuthorToken, } from '../local/authoring.js';
16
+ export { LOCAL_COMPONENT_NAMES, LOCAL_COMPONENTS, closestName, getLocalComponent, getPropDefault, localComponentNames, suggestAttribute, suggestComponent, } from '../local/schema.js';
17
+ export type { LocalBindingFamily, LocalBindingSchema, LocalBindingSlotSchema, LocalChildRule, LocalComponentForm, LocalComponentSchema, LocalInitialRule, LocalPropKind, LocalPropSchema, } from '../local/schema.js';
18
+ export type { Diagnostic, LocalCompileLimits, LocalCompileOptions, LocalHostComponentSchema, LocalHostPropKind, LocalHostPropSchema, LocalHtmlOptions, LocalHtmlPolicy, LocalValue, SourceRange, } from '../local/types.js';
19
+ export { EXTENDED_NATIVE_COMPONENT_COPY_ZH, EXTENDED_NATIVE_COMPONENTS, } from '../editor/extended-native-components.js';
20
+ export { NATIVE_COMPONENT_GROUPS, NATIVE_COMPONENT_GROUPS_ZH, NATIVE_COMPONENTS, NATIVE_COMPONENTS_ZH, getNativeComponentCatalog, renderNativeSnippet, } from '../editor/native-components.js';
21
+ export type { NativeComponentCatalog, NativeComponentDefinition, NativeComponentGroup, NativeComponentGroupId, } from '../editor/native-components.js';
22
+ export { formatBold, formatHeading, formatInlineCode, formatItalic, formatOrderedList, formatQuote, formatStrike, formatTaskList, formatBulletList, indentSelection, insertCodeBlock, insertDivider, insertImage, insertLink, insertTable, insertTemplate, insertText, outdentSelection, readFormatState, } from '../editor/editor-commands.js';
23
+ export type { EditorEdit, EditorFormatState, EditorListType, EditorSelection, InsertTemplateOptions, } from '../editor/editor-commands.js';
24
+ export type { EditorLocale } from '../editor/command-types.js';
@@ -0,0 +1,10 @@
1
+ /** DOM- and React-independent types shared by editor text commands. */
2
+ export type EditorLocale = 'en' | 'zh';
3
+ export interface EditorSelection {
4
+ start: number;
5
+ end: number;
6
+ }
7
+ export interface EditorEdit {
8
+ value: string;
9
+ selection: EditorSelection;
10
+ }
@@ -8,8 +8,8 @@
8
8
  * Commands that insert human-readable text accept an optional locale and
9
9
  * default to English, so direct callers keep their original output.
10
10
  */
11
- import type { EditorEdit, EditorLocale, EditorSelection } from './types.js';
12
- export type { EditorEdit, EditorSelection } from './types.js';
11
+ import type { EditorEdit, EditorLocale, EditorSelection } from './command-types.js';
12
+ export type { EditorEdit, EditorSelection } from './command-types.js';
13
13
  export interface InsertTemplateOptions {
14
14
  block?: boolean;
15
15
  }
@@ -7,7 +7,7 @@
7
7
  * templates live in `native-components.ts`; this module carries the Chinese
8
8
  * overrides plus the group names for both languages.
9
9
  */
10
- import type { EditorLocale } from './types.js';
10
+ import type { EditorLocale } from './command-types.js';
11
11
  export interface EditorCommandCopy {
12
12
  boldPlaceholder: string;
13
13
  italicPlaceholder: string;
@@ -8,7 +8,7 @@
8
8
  * - Leaf components never receive a closing tag; container bodies use blank
9
9
  * lines so inserted Markdown keeps a natural block layout.
10
10
  */
11
- import type { EditorLocale } from './types.js';
11
+ import type { EditorLocale } from './command-types.js';
12
12
  export type NativeComponentGroupId = 'input' | 'action' | 'layout' | 'data' | 'hint';
13
13
  export interface NativeComponentGroup {
14
14
  id: NativeComponentGroupId;
@@ -7,7 +7,7 @@
7
7
  * and controlled updates keep working unchanged.
8
8
  */
9
9
  import { type RefObject } from 'react';
10
- import type { Diagnostic, LocalDocument, SourceRange } from 'reactive-md';
10
+ import type { Diagnostic, LocalCompileOptions, LocalDocument, SourceRange } from 'reactive-md';
11
11
  import type { EditorEdit } from './types.js';
12
12
  export interface AuthorToken {
13
13
  kind: string;
@@ -34,7 +34,7 @@ export interface AuthorAnalysis {
34
34
  * Analyses the exact source; caret movement never retriggers this work.
35
35
  * `enabled` lets the editor skip the analysis when authoring tools are off.
36
36
  */
37
- export declare function useAuthorAnalysis(source: string, enabled?: boolean): AuthorAnalysis;
37
+ export declare function useAuthorAnalysis(source: string, enabled?: boolean, compileOptions?: LocalCompileOptions): AuthorAnalysis;
38
38
  export interface AuthorHighlightProps {
39
39
  source: string;
40
40
  tokens: AuthorToken[];
@@ -48,10 +48,12 @@ export interface AuthoringPanelProps {
48
48
  analysis: AuthorAnalysis;
49
49
  /** Latest successful document, used for binding value types. */
50
50
  bindingDocument: LocalDocument | null;
51
+ /** Same compile options as the preview; analysis, completion, rename and format follow them. */
52
+ compileOptions?: LocalCompileOptions;
51
53
  editorRef: RefObject<HTMLTextAreaElement | null>;
52
54
  onEdit(edit: EditorEdit): void;
53
55
  onLocate(range: SourceRange): void;
54
56
  /** Read-only and disabled editors block every authoring action. */
55
57
  disabled?: boolean;
56
58
  }
57
- export declare function AuthoringPanel({ source, analysis, bindingDocument, editorRef, onEdit, onLocate, disabled, }: AuthoringPanelProps): import("react").JSX.Element;
59
+ export declare function AuthoringPanel({ source, analysis, bindingDocument, compileOptions, editorRef, onEdit, onLocate, disabled, }: AuthoringPanelProps): import("react").JSX.Element;
@@ -1,16 +1,9 @@
1
1
  import type { CSSProperties, ReactNode, RefObject } from 'react';
2
- import type { Diagnostic, LocalDocument, SourceRange } from '../local/types.js';
3
- export type EditorLocale = 'en' | 'zh';
2
+ import type { Diagnostic, LocalCompileOptions, LocalDocument, SourceRange } from '../local/types.js';
3
+ import type { EditorLocale, EditorSelection } from './command-types.js';
4
+ export type { EditorLocale, EditorSelection, EditorEdit } from './command-types.js';
4
5
  export type EditorTheme = 'light' | 'dark' | 'auto';
5
6
  export type EditorViewMode = 'edit' | 'split' | 'preview';
6
- export interface EditorSelection {
7
- start: number;
8
- end: number;
9
- }
10
- export interface EditorEdit {
11
- value: string;
12
- selection: EditorSelection;
13
- }
14
7
  export interface ReactiveMarkdownEditorProps {
15
8
  value: string;
16
9
  onChange(value: string): void;
@@ -34,6 +27,8 @@ export interface ReactiveMarkdownEditorProps {
34
27
  /** Reset history, selection and scroll when switching source documents. */
35
28
  documentKey?: string | number;
36
29
  diagnostics?: readonly Diagnostic[];
30
+ /** Compile options used by the host preview; authoring analyses follow them. */
31
+ compileOptions?: LocalCompileOptions;
37
32
  /** Optional compiled document for the binding inspector's value types. */
38
33
  document?: LocalDocument | null;
39
34
  toolbar?: boolean;
@@ -69,8 +69,10 @@ export interface LocalReactiveDocumentProps {
69
69
  hostRenderer?: LocalHostRenderer;
70
70
  /**
71
71
  * Host-owned compile options. HTML capability flags select the temporary
72
- * whole-document native branch; the component recompiles when a flag or the
73
- * node budget changes, but not when an equal object is recreated.
72
+ * whole-document native branch; Markdown capability options such as
73
+ * `markdownBreaks` change the parsed tree. The component recompiles when a
74
+ * flag, the soft-break option or the node budget changes, but not when an
75
+ * equal object is recreated.
74
76
  */
75
77
  compileOptions?: LocalCompileOptions;
76
78
  }
@@ -1,4 +1,4 @@
1
- import type { Diagnostic, SourceRange } from './types.js';
1
+ import type { Diagnostic, LocalCompileOptions, SourceRange } from './types.js';
2
2
  /**
3
3
  * DOM-free authoring services for the local interaction syntax.
4
4
  *
@@ -7,6 +7,10 @@ import type { Diagnostic, SourceRange } from './types.js';
7
7
  * syntax is taken from `parseLocal`. Code, display math, comments, escaped
8
8
  * syntax, footnotes and unknown/fallback regions produce no binding reads or
9
9
  * formatting edits; computable plot parameters use the LaTeX AST.
10
+ *
11
+ * Every entry point accepts the same optional `LocalCompileOptions` as the
12
+ * preview compiler. Host components and syntax limits therefore shape analysis
13
+ * exactly as they shape rendering, and HTML mode is treated as opaque.
10
14
  */
11
15
  export interface AuthorToken {
12
16
  kind: string;
@@ -38,13 +42,13 @@ export interface AuthorRename {
38
42
  }[];
39
43
  }
40
44
  /** Analyze active syntax, binding declarations/references and compile diagnostics. */
41
- export declare function analyzeLocalSource(source: string): AuthorAnalysis;
45
+ export declare function analyzeLocalSource(source: string, options?: LocalCompileOptions): AuthorAnalysis;
42
46
  /**
43
47
  * Complete tags, schema attributes, enum values and declared binding names at
44
48
  * `offset`. Replacement ranges cover an already-typed valid suffix so applying
45
49
  * a suggestion never duplicates letters. Inactive regions yield no results.
46
50
  */
47
- export declare function completeLocalSource(source: string, offset: number): AuthorCompletion[];
51
+ export declare function completeLocalSource(source: string, offset: number, options?: LocalCompileOptions): AuthorCompletion[];
48
52
  /**
49
53
  * Rename a declared binding and every active reference. Literal attribute
50
54
  * text, Markdown text, strings inside expressions, code, display math, comments
@@ -52,7 +56,7 @@ export declare function completeLocalSource(source: string, offset: number): Aut
52
56
  * meaning. Invalid names, collisions and structural
53
57
  * parse failures are rejected.
54
58
  */
55
- export declare function renameLocalBinding(source: string, oldName: string, newName: string): AuthorRename;
59
+ export declare function renameLocalBinding(source: string, oldName: string, newName: string, options?: LocalCompileOptions): AuthorRename;
56
60
  /**
57
61
  * Conservatively normalize whitespace inside recognized reactive tags:
58
62
  * single spaces between attributes, no spaces around `=`, no space before `>`,
@@ -60,4 +64,4 @@ export declare function renameLocalBinding(source: string, oldName: string, newN
60
64
  * Markdown, newlines, indentation, code, math and fallback regions are not
61
65
  * modified. Any compile error leaves the document unchanged.
62
66
  */
63
- export declare function formatLocalSource(source: string): string;
67
+ export declare function formatLocalSource(source: string, options?: LocalCompileOptions): string;