reactive-md 0.9.0 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (162) hide show
  1. package/CHANGELOG-ch.md +13 -0
  2. package/CHANGELOG.md +13 -0
  3. package/README-ch.md +6 -6
  4. package/README-en.md +6 -6
  5. package/README.md +6 -6
  6. package/SECURITY-ch.md +3 -3
  7. package/SECURITY.md +3 -3
  8. package/THIRD_PARTY_NOTICES.md +111 -1
  9. package/cli/build.mjs +1 -0
  10. package/cli/init.mjs +1 -1
  11. package/dist-library/{LocalDocumentView-K7Y-2bRJ.js → LocalDocumentView-sthUP0ct.js} +10 -10
  12. package/dist-library/LocalDocumentViewCore-GiWV3bey.js +9829 -0
  13. package/dist-library/LocalReactiveDocumentCore-ZjQSGyHE.js +275 -0
  14. package/dist-library/{authoring-Co_TiE-P.js → authoring-Dsune4Hy.js} +40 -20
  15. package/dist-library/{compile-LhpTKqCR.js → compile-wUv8KEge.js} +1 -1
  16. package/dist-library/{compiler-core-DTxY-qYz.js → compiler-core-As_m-MNm.js} +2449 -1742
  17. package/dist-library/{compiler-DfGbQhyD.js → compiler-eOfcinZs.js} +19 -19
  18. package/dist-library/{component-state-BBJ08vML.js → component-state-C52ZFJGl.js} +1 -1
  19. package/dist-library/{config-BUo-8O5C.js → config-BadfhjdP.js} +1 -1
  20. package/dist-library/{config-validation-C5kJYk-J.js → config-validation-F47AcE6o.js} +49 -1
  21. package/dist-library/{controls-BWiLLtBO.js → controls-CcT6n7k_.js} +2433 -2409
  22. package/dist-library/{coordinate-BSl6enWV.js → coordinate-CWS9p5q_.js} +108 -107
  23. package/dist-library/{data-table-DfvytZKQ.js → data-table-Bgccxd7h.js} +68 -65
  24. package/dist-library/{display-lw3BT1TA.js → display-B-VhqVND.js} +1 -1
  25. package/dist-library/{export-C7IDW9ul.js → export-BqVmTXm8.js} +145 -87
  26. package/dist-library/{gallery-B8kSt1oI.js → gallery-CY6mTx8i.js} +151 -147
  27. package/dist-library/html-CNT4KD-2.js +757 -0
  28. package/dist-library/{incremental-D_6vwAAE.js → incremental-Dv0FSp_U.js} +404 -142
  29. package/dist-library/layout-C0YlEPGr.js +562 -0
  30. package/dist-library/{mount-preset-C5s9ebEH.js → mount-preset-KxvtKgJb.js} +2 -2
  31. package/dist-library/options-1aDLK7JY.js +121 -0
  32. package/dist-library/{package-core-D0POW4Gd.js → package-core-WFK1RhAZ.js} +3 -3
  33. package/dist-library/{parser-standard-OToYcOBL.js → parser-standard-Yuf3A_VI.js} +3270 -3778
  34. package/dist-library/react-D5iGiUdL.js +7 -0
  35. package/dist-library/reactive-md-authoring.js +16 -18
  36. package/dist-library/reactive-md-build.js +51 -51
  37. package/dist-library/reactive-md-compiler-standard.js +10 -9
  38. package/dist-library/reactive-md-compiler.js +3 -3
  39. package/dist-library/reactive-md-export.js +4 -4
  40. package/dist-library/reactive-md-minimal-react-preset.js +3 -3
  41. package/dist-library/reactive-md-pdf.js +127 -3
  42. package/dist-library/reactive-md-plugin-chart.js +2 -2
  43. package/dist-library/reactive-md-plugin-data.js +4 -4
  44. package/dist-library/reactive-md-plugin-diagram.js +3 -3
  45. package/dist-library/reactive-md-plugin-forms.js +2 -2
  46. package/dist-library/reactive-md-plugin-gallery.js +2 -2
  47. package/dist-library/reactive-md-plugin-navigation.js +2 -2
  48. package/dist-library/reactive-md-plugin-network.js +117 -115
  49. package/dist-library/reactive-md-plugin-plot.js +3 -3
  50. package/dist-library/reactive-md-react-minimal.js +4 -4
  51. package/dist-library/reactive-md-react-server.js +6 -6
  52. package/dist-library/reactive-md-react-unstyled.js +10 -11
  53. package/dist-library/reactive-md-react.js +10 -11
  54. package/dist-library/reactive-md-sdk.js +3 -3
  55. package/dist-library/reactive-md-standalone-configured.js +2 -2
  56. package/dist-library/reactive-md-standalone-host.js +2 -2
  57. package/dist-library/reactive-md-testing-browser.js +2 -2
  58. package/dist-library/reactive-md-testing-react.js +6 -6
  59. package/dist-library/reactive-md-testing.js +4 -4
  60. package/dist-library/reactive-md.js +280 -193
  61. package/dist-library/{registry-05JiqmEp.js → registry-B9NGct4d.js} +1 -1
  62. package/dist-library/{resources-IeJomeUT.js → resources-D2GDQS0p.js} +1 -1
  63. package/dist-library/{runtime-CuOyRe9f.js → runtime-kcA7bG7G.js} +341 -341
  64. package/dist-library/{schema-C-AeByPp.js → schema-BufhKUSM.js} +5 -5
  65. package/dist-library/{sdk-core-BJLJaVR5.js → sdk-core-BoJT1SIt.js} +490 -150
  66. package/dist-library/{session-core-BGka5D1J.js → session-core-nmJHuR9c.js} +170 -156
  67. package/dist-library/{shareable-jkGi2g6y.js → shareable-DpbE-59H.js} +207 -242
  68. package/dist-library/types/authoring/catalog.d.ts +1 -2
  69. package/dist-library/types/components/shared/visual-frame.d.ts +6 -2
  70. package/dist-library/types/local/compilation/compiler-capabilities.d.ts +3 -0
  71. package/dist-library/types/local/compilation/compiler-core.d.ts +11 -3
  72. package/dist-library/types/local/compilation/compiler-services.d.ts +8 -4
  73. package/dist-library/types/local/compilation/compiler.d.ts +3 -3
  74. package/dist-library/types/local/compilation/session/incremental.d.ts +20 -5
  75. package/dist-library/types/local/compilation/streaming.d.ts +27 -0
  76. package/dist-library/types/local/configuration/capability-policy.d.ts +3 -0
  77. package/dist-library/types/local/configuration/diagnostic-messages.d.ts +48 -0
  78. package/dist-library/types/local/configuration/options-core.d.ts +1 -2
  79. package/dist-library/types/local/configuration/options.d.ts +1 -0
  80. package/dist-library/types/local/css/author-css.d.ts +66 -0
  81. package/dist-library/types/local/html/extended-fragment.d.ts +41 -0
  82. package/dist-library/types/local/html/html.d.ts +39 -3
  83. package/dist-library/types/local/index.d.ts +1 -1
  84. package/dist-library/types/local/parsing/author-markdown.d.ts +11 -0
  85. package/dist-library/types/local/parsing/parse-session.d.ts +2 -2
  86. package/dist-library/types/local/parsing/parser-convert.d.ts +2 -1
  87. package/dist-library/types/local/parsing/parser-core.d.ts +8 -1
  88. package/dist-library/types/local/parsing/parser.d.ts +2 -2
  89. package/dist-library/types/local/rendering/document/ExtendedHtmlFragment.d.ts +14 -0
  90. package/dist-library/types/local/rendering/document/LocalDocumentViewCore.d.ts +25 -1
  91. package/dist-library/types/local/rendering/document/LocalReactiveDocumentCore.d.ts +1 -1
  92. package/dist-library/types/local/rendering/document/use-author-script.d.ts +3 -0
  93. package/dist-library/types/local/rendering/document/view-render-context.d.ts +11 -1
  94. package/dist-library/types/local/runtime/author-script-protocol.d.ts +59 -0
  95. package/dist-library/types/local/transport/worker.d.ts +27 -4
  96. package/dist-library/types/local/types.d.ts +52 -16
  97. package/dist-library/types/react/component-api.d.ts +10 -1
  98. package/dist-library/types/react/component-utils.d.ts +9 -1
  99. package/dist-library/types/react/sdk-core.d.ts +4 -1
  100. package/dist-library/types/shareable.d.ts +5 -4
  101. package/dist-library/types/standalone/prepare.d.ts +1 -1
  102. package/dist-library/types/standalone/session-core.d.ts +3 -2
  103. package/dist-library/{types-BFC5rzC4.js → types-BeNtPqdY.js} +1 -1
  104. package/dist-library/{validation-BlDL2uD9.js → validation-BEBA_HvS.js} +88 -72
  105. package/dist-library/{visual-frame-G8PHoj1e.js → visual-frame-CyV1FXzs.js} +6 -5
  106. package/dist-library/{visuals-BkYRmYGO.js → visuals-BZbZYA7w.js} +24181 -24180
  107. package/dist-standalone/reactive-md-standalone.js +124 -117
  108. package/docs/README-ch.md +2 -1
  109. package/docs/README.md +2 -1
  110. package/docs/compatibility/compatibility-ch.md +6 -6
  111. package/docs/compatibility/compatibility-en.md +6 -6
  112. package/docs/compatibility/source-versioning-ch.md +1 -1
  113. package/docs/compatibility/source-versioning-en.md +1 -1
  114. package/docs/development/component-development-ch.md +2 -2
  115. package/docs/development/component-development-en.md +2 -2
  116. package/docs/development/component-development-reference-ch.md +2 -2
  117. package/docs/development/component-development-reference-en.md +2 -2
  118. package/docs/development/component-protocol-ch.md +2 -2
  119. package/docs/development/component-protocol-en.md +2 -2
  120. package/docs/development/extension-tutorial-ch.md +3 -3
  121. package/docs/development/extension-tutorial-en.md +3 -3
  122. package/docs/integration/author-tools-ch.md +1 -1
  123. package/docs/integration/author-tools-en.md +1 -1
  124. package/docs/integration/compiler-ch.md +3 -1
  125. package/docs/integration/compiler-en.md +3 -1
  126. package/docs/integration/editor-ch.md +3 -3
  127. package/docs/integration/editor-en.md +3 -3
  128. package/docs/integration/extension-sdk-ch.md +2 -2
  129. package/docs/integration/extension-sdk-en.md +2 -2
  130. package/docs/integration/local-integration-ch.md +130 -8
  131. package/docs/integration/local-integration-en.md +130 -8
  132. package/docs/integration/shareable-export-ch.md +4 -2
  133. package/docs/integration/shareable-export-en.md +4 -2
  134. package/docs/reference/html-compatibility-ch.md +20 -67
  135. package/docs/reference/html-compatibility-en.md +19 -64
  136. package/docs/reference/public-api-ch.md +10 -7
  137. package/docs/reference/public-api-en.md +10 -7
  138. package/docs/releases/release-0.9.1-ch.md +29 -0
  139. package/docs/releases/release-0.9.1-en.md +29 -0
  140. package/examples/component-package/README-ch.md +1 -1
  141. package/examples/component-package/README.md +1 -1
  142. package/examples/game-2048-package/README-ch.md +1 -1
  143. package/examples/game-2048-package/README.md +1 -1
  144. package/examples/integration/README-ch.md +21 -2
  145. package/examples/integration/README.md +21 -2
  146. package/examples/integration/extension-sdk/README-ch.md +1 -1
  147. package/examples/integration/extension-sdk/README.md +1 -1
  148. package/examples/integration/streaming/index.html +48 -0
  149. package/examples/integration/streaming/main.js +175 -0
  150. package/examples/integration/streaming/package.json +13 -0
  151. package/examples/integration/streaming/worker.js +3 -0
  152. package/examples/minimal-extension/README-ch.md +3 -3
  153. package/examples/minimal-extension/README.md +3 -3
  154. package/examples/tetris-package/README-ch.md +1 -1
  155. package/examples/tetris-package/README.md +1 -1
  156. package/package.json +6 -1
  157. package/dist-library/LocalDocumentViewCore-BLG4hMuO.js +0 -9535
  158. package/dist-library/LocalReactiveDocumentCore-DVQ6WA9G.js +0 -259
  159. package/dist-library/component-utils-BvHL8VGt.js +0 -298
  160. package/dist-library/layout-C22VjZh0.js +0 -542
  161. package/dist-library/options-CdSKOi7p.js +0 -116
  162. package/dist-library/react-LY5qsVeP.js +0 -7
@@ -1,44 +1,46 @@
1
1
  import { O as e } from "./preset-core-CKc5YXSM.js";
2
- import { i as t } from "./props-sJ8vk0cr.js";
3
- import { s as n } from "./config-BUo-8O5C.js";
4
- import { C as r, E as i, T as a, j as o, x as s } from "./component-state-BoLCGee4.js";
5
- import { t as c } from "./runtime-B2fxeveq.js";
6
- import { i as l } from "./resources-IeJomeUT.js";
7
- import { Component as u, createElement as d } from "react";
2
+ import { M as t } from "./config-validation-F47AcE6o.js";
3
+ import { i as n, o as r } from "./props-sJ8vk0cr.js";
4
+ import { s as i } from "./config-BadfhjdP.js";
5
+ import { C as a, E as o, T as s, j as c, x as l } from "./component-state-BoLCGee4.js";
6
+ import { t as u } from "./runtime-B2fxeveq.js";
7
+ import { i as d } from "./resources-D2GDQS0p.js";
8
+ import { Component as f, createElement as p, useCallback as m, useEffect as h, useRef as g, useState as _ } from "react";
9
+ import { jsx as v, jsxs as y } from "react/jsx-runtime";
8
10
  // src/react/component-api.tsx
9
- var f = Symbol("reactive-md.content-node");
10
- function p(e) {
11
- return e[f];
11
+ var b = Symbol("reactive-md.content-node");
12
+ function x(e) {
13
+ return e[b];
12
14
  }
13
- function m(e, t) {
14
- return Object.defineProperty(e, f, {
15
+ function S(e, t) {
16
+ return Object.defineProperty(e, b, {
15
17
  value: t,
16
18
  enumerable: !1,
17
19
  configurable: !1,
18
20
  writable: !1
19
21
  }), Object.freeze(e);
20
22
  }
21
- var h = /^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/;
22
- function g(e) {
23
+ var C = /^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/;
24
+ function w(e) {
23
25
  return e === null ? "" : typeof e == "string" ? e : typeof e == "number" ? Number.isFinite(e) ? String(e) : null : typeof e == "boolean" ? e ? "true" : "false" : null;
24
26
  }
25
- function _(e) {
27
+ function T(e) {
26
28
  if (!Number.isFinite(e)) return "—";
27
29
  if (Object.is(e, -0)) return "0";
28
30
  let t = Math.abs(e);
29
31
  return t >= 0xe8d4a51000 || t > 0 && t < 1e-4 ? e.toExponential(3).replace(/(\.\d*?)0+e/, "$1e").replace(/\.e/, "e") : Number(e.toFixed(6)).toString();
30
32
  }
31
- function v(e) {
33
+ function E(e) {
32
34
  return Array.isArray(e) ? Object.freeze(e.slice()) : e === void 0 ? null : e;
33
35
  }
34
- function y(e) {
36
+ function D(e) {
35
37
  return Array.isArray(e) ? e.slice() : e;
36
38
  }
37
- function b(e, n, r, i) {
39
+ function O(e, t, r, i) {
38
40
  try {
39
41
  return {
40
42
  ok: !0,
41
- value: t(e, n, r, i)
43
+ value: n(e, t, r, i)
42
44
  };
43
45
  } catch (e) {
44
46
  return {
@@ -47,16 +49,16 @@ function b(e, n, r, i) {
47
49
  };
48
50
  }
49
51
  }
50
- var x = /* @__PURE__ */ new WeakMap(), S = /* @__PURE__ */ new WeakMap();
51
- function C(e) {
52
- S.delete(D(e));
52
+ var ee = /* @__PURE__ */ new WeakMap(), k = /* @__PURE__ */ new WeakMap();
53
+ function te(e) {
54
+ k.delete(j(e));
53
55
  }
54
- var w = /* @__PURE__ */ new WeakMap(), T = 4096, E = 512;
55
- function D(e) {
56
- let t = M.get(e);
57
- return t || (t = Object.freeze({}), M.set(e, t)), t;
56
+ var A = /* @__PURE__ */ new WeakMap(), ne = 4096, re = 512;
57
+ function j(e) {
58
+ let t = N.get(e);
59
+ return t || (t = Object.freeze({}), N.set(e, t)), t;
58
60
  }
59
- function O(e, t, n) {
61
+ function ie(e, t, n) {
60
62
  let { environment: r, node: i } = e, a = r.positionOf?.(i.range.start) ?? {
61
63
  line: 1,
62
64
  column: 1
@@ -73,22 +75,22 @@ function O(e, t, n) {
73
75
  column: a.column
74
76
  };
75
77
  }
76
- function k(e, t, n) {
78
+ function ae(e, t, n) {
77
79
  if (n.length === 0) return;
78
80
  if (typeof window > "u") {
79
81
  e.report(n);
80
82
  return;
81
83
  }
82
- let r = w.get(t);
84
+ let r = A.get(t);
83
85
  r || (r = {
84
86
  diagnostics: [],
85
87
  scheduled: !1,
86
88
  report: e.report
87
- }, w.set(t, r));
89
+ }, A.set(t, r));
88
90
  let i = r;
89
91
  i.report = e.report;
90
92
  for (let e of n) {
91
- if (i.diagnostics.length >= E) break;
93
+ if (i.diagnostics.length >= re) break;
92
94
  i.diagnostics.push(e);
93
95
  }
94
96
  if (i.scheduled) return;
@@ -100,16 +102,16 @@ function k(e, t, n) {
100
102
  };
101
103
  typeof queueMicrotask == "function" ? queueMicrotask(a) : setTimeout(a, 0);
102
104
  }
103
- function A(e, t, n, r) {
105
+ function oe(e, t, n, r) {
104
106
  if (!e) return {};
105
- let i = t ?? {}, a = {}, o = r?.environment.mode === "static" && typeof window > "u", s = r !== void 0, c = r ? D(n) : null, l = null;
107
+ let i = t ?? {}, a = {}, o = r?.environment.mode === "static" && typeof window > "u", s = r !== void 0, c = r ? j(n) : null, l = null;
106
108
  if (r && c && s) {
107
- let e = o ? S : x;
108
- l = e.get(c) ?? null, l ? l.size > T && l.clear() : (l = /* @__PURE__ */ new Map(), e.set(c, l));
109
+ let e = o ? k : ee;
110
+ l = e.get(c) ?? null, l ? l.size > ne && l.clear() : (l = /* @__PURE__ */ new Map(), e.set(c, l));
109
111
  }
110
112
  let u = [];
111
113
  for (let t of Object.keys(e.props)) {
112
- let o = Object.hasOwn(i, t) && typeof i[t] == "string" ? i[t] : void 0, s = b(e, t, o, n);
114
+ let o = Object.hasOwn(i, t) && typeof i[t] == "string" ? i[t] : void 0, s = O(e, t, o, n);
113
115
  if (s.ok) a[t] = s.value, r && l && l.delete(`${r.node.id}\u0000${t}`);
114
116
  else if (a[t] = null, r) {
115
117
  if (l) {
@@ -117,32 +119,32 @@ function A(e, t, n, r) {
117
119
  if (l.get(e) === n) continue;
118
120
  l.set(e, n);
119
121
  }
120
- u.push(O(r, t, s.error));
122
+ u.push(ie(r, t, s.error));
121
123
  }
122
124
  }
123
- return r && c && k(r.environment, c, u), a;
125
+ return r && c && ae(r.environment, c, u), a;
124
126
  }
125
- function ee(e) {
127
+ function se(e) {
126
128
  return e?.bindings ?? {};
127
129
  }
128
- function j(e, t, n, r) {
130
+ function M(e, t, n, r) {
129
131
  let i = r.get(e);
130
132
  if (i) return i;
131
- let a = e.type === "component" || e.type === "hostComponent", o = a ? t.definitionFor(e.name ?? "") : void 0, s = Object.freeze(a ? A(o, e.attrs, t.runtime, {
133
+ let a = e.type === "component" || e.type === "hostComponent", o = a ? t.definitionFor(e.name ?? "") : void 0, s = Object.freeze(a ? oe(o, e.attrs, t.runtime, {
132
134
  environment: t,
133
135
  node: e
134
- }) : {}), c = (e.children ?? []).map((e) => j(e, t, n, r)), l = null;
136
+ }) : {}), c = (e.children ?? []).map((e) => M(e, t, n, r)), l = null;
135
137
  if (a) try {
136
- l = v(t.runtime.get(e));
138
+ l = E(t.runtime.get(e));
137
139
  } catch {
138
140
  l = null;
139
141
  }
140
142
  else if (e.type === "interpolation") try {
141
- l = v(t.runtime.evaluate(e.value ?? ""));
143
+ l = E(t.runtime.evaluate(e.value ?? ""));
142
144
  } catch {
143
145
  l = null;
144
146
  }
145
- let u = m({
147
+ let u = S({
146
148
  id: e.id,
147
149
  kind: a ? "component" : e.type,
148
150
  name: a ? e.name ?? "" : "",
@@ -161,11 +163,11 @@ function j(e, t, n, r) {
161
163
  }, e);
162
164
  return r.set(e, u), u;
163
165
  }
164
- var M = /* @__PURE__ */ new WeakMap();
165
- function N(e, t, n) {
166
- let r = t === "static", i = M.get(e);
167
- i || (i = Object.freeze({}), M.set(e, i));
168
- let a = p, o = (e) => (e.length > 0 && n(e), e), s = (e, t) => {
166
+ var N = /* @__PURE__ */ new WeakMap();
167
+ function ce(e, t, n) {
168
+ let r = t === "static", i = N.get(e);
169
+ i || (i = Object.freeze({}), N.set(e, i));
170
+ let a = x, o = (e) => (e.length > 0 && n(e), e), s = (e, t) => {
169
171
  let n = {
170
172
  start: e.range.start,
171
173
  end: e.range.end
@@ -182,12 +184,12 @@ function N(e, t, n) {
182
184
  return Object.freeze({
183
185
  identity: i,
184
186
  get(t, n) {
185
- return v(e.get(a(t), n === "value" ? void 0 : n));
187
+ return E(e.get(a(t), n === "value" ? void 0 : n));
186
188
  },
187
189
  set(t, n, i) {
188
190
  if (r) return s(t, /* @__PURE__ */ Error("Runtime is read-only in static mode."));
189
191
  try {
190
- return o(e.set(a(t), y(n), i === "value" ? void 0 : i));
192
+ return o(e.set(a(t), D(n), i === "value" ? void 0 : i));
191
193
  } catch (e) {
192
194
  return s(t, e);
193
195
  }
@@ -196,7 +198,7 @@ function N(e, t, n) {
196
198
  if (r) return s(t, /* @__PURE__ */ Error("Runtime is read-only in static mode."));
197
199
  try {
198
200
  let r = {};
199
- for (let [e, t] of Object.entries(n)) r[e] = y(t);
201
+ for (let [e, t] of Object.entries(n)) r[e] = D(t);
200
202
  return o(e.setMany(a(t), r));
201
203
  } catch (e) {
202
204
  return s(t, e);
@@ -215,12 +217,12 @@ function N(e, t, n) {
215
217
  }
216
218
  },
217
219
  evaluate(t) {
218
- return v(e.evaluate(t));
220
+ return E(e.evaluate(t));
219
221
  },
220
222
  snapshot() {
221
223
  try {
222
224
  let t = e.snapshot(), n = {};
223
- for (let [e, r] of Object.entries(t.state)) n[e] = v(r);
225
+ for (let [e, r] of Object.entries(t.state)) n[e] = E(r);
224
226
  return {
225
227
  revision: t.revision,
226
228
  state: Object.freeze(n)
@@ -264,7 +266,7 @@ function N(e, t, n) {
264
266
  }
265
267
  });
266
268
  }
267
- function te(e, t, n, r) {
269
+ function le(e, t, n, r) {
268
270
  return Object.freeze({
269
271
  get: () => {
270
272
  try {
@@ -286,11 +288,11 @@ function te(e, t, n, r) {
286
288
  }
287
289
  });
288
290
  }
289
- function ne(e, t) {
291
+ function ue(e, t) {
290
292
  let n = [], r = e.children, i = t.definitionFor(e.name), a = i?.rules?.find((e) => e.kind === "options-body"), o = a?.kind === "options-body" ? a.child : i?.structure?.child ?? "option", s = a?.kind === "options-body" ? a.valueAttribute : i?.structure?.valueAttribute ?? "value", c = 0;
291
293
  for (let i of r) {
292
294
  if (i.kind !== "component" || i.name !== o) continue;
293
- let r = p(i), a = i.attrs[s] ?? `option-${c + 1}`;
295
+ let r = x(i), a = i.attrs[s] ?? `option-${c + 1}`;
294
296
  c += 1;
295
297
  let l = t.renderToText(r.children) || i.attrs[s] || "";
296
298
  n.push(Object.freeze({
@@ -306,8 +308,8 @@ function P(e, t) {
306
308
  let n = e.children ?? [], r = n.filter((e) => !(e.type === "text" && !(e.value ?? "").trim())), i, a = "empty", o = "", s = null, c = null;
307
309
  if (r.length === 1 && r[0].type === "interpolation") try {
308
310
  i = t.runtime.evaluate(r[0].value ?? "");
309
- let e = g(i);
310
- i === null ? (a = "null", o = "") : typeof i == "string" ? (a = "string", o = i) : typeof i == "number" ? Number.isFinite(i) ? (a = "number", o = _(i), s = i) : (a = "error", o = t.locale === "zh" ? "无法计算" : "Cannot compute", c = t.locale === "zh" ? "结果不是有限数字" : "Result is not a finite number") : typeof i == "boolean" ? (a = "boolean", o = i ? "true" : "false") : (a = "array", o = e ?? "", c = t.locale === "zh" ? "数组需要先用 len 等函数转换" : "Arrays must first be converted with a function such as len");
311
+ let e = w(i);
312
+ i === null ? (a = "null", o = "") : typeof i == "string" ? (a = "string", o = i) : typeof i == "number" ? Number.isFinite(i) ? (a = "number", o = T(i), s = i) : (a = "error", o = t.locale === "zh" ? "无法计算" : "Cannot compute", c = t.locale === "zh" ? "结果不是有限数字" : "Result is not a finite number") : typeof i == "boolean" ? (a = "boolean", o = i ? "true" : "false") : (a = "array", o = e ?? "", c = t.locale === "zh" ? "数组需要先用 len 等函数转换" : "Arrays must first be converted with a function such as len");
311
313
  } catch (e) {
312
314
  a = "error", o = t.locale === "zh" ? "无法计算" : "Cannot compute", c = e instanceof Error ? e.message : String(e);
313
315
  }
@@ -315,7 +317,7 @@ function P(e, t) {
315
317
  let e = "", l = null, u = (n) => {
316
318
  for (let r of n ?? []) if (r.type === "text" || r.type === "inlineCode" || r.type === "code") e += r.value ?? "";
317
319
  else if (r.type === "interpolation") try {
318
- let n = g(t.runtime.evaluate(r.value ?? ""));
320
+ let n = w(t.runtime.evaluate(r.value ?? ""));
319
321
  n === null ? l ??= t.locale === "zh" ? "数组需要先用 len 等函数转换" : "Arrays must first be converted with a function such as len" : e += n;
320
322
  } catch (n) {
321
323
  l ??= n instanceof Error ? n.message : String(n), e += t.locale === "zh" ? "无法计算" : "Cannot compute";
@@ -324,7 +326,7 @@ function P(e, t) {
324
326
  };
325
327
  u(n);
326
328
  let d = r.length > 0 && r.every((e) => e.type === "text"), f = e.trim();
327
- if (d && h.test(f)) {
329
+ if (d && C.test(f)) {
328
330
  let t = Number(f);
329
331
  Number.isFinite(t) && (a = "number", o = e, s = t, i = t);
330
332
  }
@@ -339,10 +341,10 @@ function P(e, t) {
339
341
  render: () => t.renderInline(n, !0)
340
342
  });
341
343
  }
342
- function re(e, t) {
344
+ function de(e, t) {
343
345
  let n = e.children.find((e) => e.kind === "table");
344
346
  if (!n) return null;
345
- let r = (p(n).children ?? []).filter((e) => e.type === "tableRow");
347
+ let r = (x(n).children ?? []).filter((e) => e.type === "tableRow");
346
348
  if (r.length === 0) return null;
347
349
  let i = (r[0].children ?? []).map((e) => P(e, t));
348
350
  return Object.freeze({
@@ -354,11 +356,11 @@ function re(e, t) {
354
356
  })))
355
357
  });
356
358
  }
357
- function ie(e, t) {
359
+ function fe(e, t) {
358
360
  let n = e["state-key"];
359
- return a(typeof n == "string" ? n : t["state-key"]);
361
+ return s(typeof n == "string" ? n : t["state-key"]);
360
362
  }
361
- function ae(e) {
363
+ function pe(e) {
362
364
  try {
363
365
  return e.document.source;
364
366
  } catch {
@@ -369,87 +371,87 @@ var F = /* @__PURE__ */ new WeakMap();
369
371
  function I(e) {
370
372
  if (e.services !== void 0) return e.services;
371
373
  let t = F.get(e);
372
- return t === void 0 && (t = c({ sourceDigest: r(ae(e)) }), F.set(e, t)), t;
374
+ return t === void 0 && (t = u({ sourceDigest: a(pe(e)) }), F.set(e, t)), t;
373
375
  }
374
376
  function L(e, t) {
375
- let n = t.definitionFor(e.name ?? ""), r = /* @__PURE__ */ new Map(), a = j(e, t, t.visible, r), c = N(t.runtime, t.mode, t.report), l = t.services ?? I(t.runtime), u = n?.id ?? e.name ?? e.type, d = ie(a.props, a.attrs), f = null, m = () => (f === null && (f = l.state.handle({
377
+ let n = t.definitionFor(e.name ?? ""), r = /* @__PURE__ */ new Map(), i = M(e, t, t.visible, r), a = ce(t.runtime, t.mode, t.report), s = t.services ?? I(t.runtime), u = n?.id ?? e.name ?? e.type, d = fe(i.props, i.attrs), f = null, p = () => (f === null && (f = s.state.handle({
376
378
  nodeId: e.id,
377
379
  component: u,
378
380
  componentVersion: n?.version ?? "0.0.0",
379
381
  stateKey: d,
380
382
  stateVersion: 0
381
- })), f), h = typeof a.props.seed == "number" && Number.isFinite(a.props.seed) ? a.props.seed : void 0, g = i({
382
- explicitSeed: h,
383
- documentSeed: l.randomSeed,
383
+ })), f), m = typeof i.props.seed == "number" && Number.isFinite(i.props.seed) ? i.props.seed : void 0, h = o({
384
+ explicitSeed: m,
385
+ documentSeed: s.randomSeed,
384
386
  componentId: u,
385
387
  nodeId: e.id,
386
388
  stateKey: d
387
- }), v = Object.freeze({
388
- network: t.mode === "static" ? o : t.network ?? t.runtime.network ?? o,
389
+ }), g = Object.freeze({
390
+ network: t.mode === "static" ? c : t.network ?? t.runtime.network ?? c,
389
391
  random: Object.freeze({
390
- seed: g,
391
- derive: (e) => s(g, e)
392
+ seed: h,
393
+ derive: (e) => l(h, e)
392
394
  }),
393
- clock: l.clock,
394
- scheduler: l.scheduler,
395
+ clock: s.clock,
396
+ scheduler: s.scheduler,
395
397
  get state() {
396
- return m();
398
+ return p();
397
399
  }
398
- }), y = t.mode === "static", b = ee(n), x = {};
399
- for (let e of Object.keys(b)) x[e] = te(c, a, e, y);
400
- let S = x.value ?? Object.freeze({
400
+ }), _ = t.mode === "static", v = se(n), y = {};
401
+ for (let e of Object.keys(v)) y[e] = le(a, i, e, _);
402
+ let b = y.value ?? Object.freeze({
401
403
  get: () => null,
402
404
  set: () => ({
403
405
  ok: !1,
404
406
  diagnostics: []
405
407
  })
406
- }), C = Object.freeze({
408
+ }), S = Object.freeze({
407
409
  render: () => t.renderChildren(e.children, t.visible),
408
410
  inline: () => t.renderInline(e.children, t.visible),
409
411
  text: () => t.renderToText(e.children),
410
- items: () => a.children,
411
- renderItems: (e, n) => t.renderChildren(e.map((e) => p(e)), n ?? t.visible),
412
- renderInlineItems: (e, n) => t.renderInline(e.map((e) => p(e)), n ?? t.visible),
413
- textOf: (e) => t.renderToText(e.map((e) => p(e))),
414
- options: () => ne(a, t),
415
- table: () => re(a, t),
416
- math: () => a.children.filter((e) => e.kind === "math" || e.kind === "inlineMath")
417
- }), w = Object.freeze({
418
- value: S,
419
- slots: Object.freeze(x),
420
- isReadOnly: y,
412
+ items: () => i.children,
413
+ renderItems: (e, n) => t.renderChildren(e.map((e) => x(e)), n ?? t.visible),
414
+ renderInlineItems: (e, n) => t.renderInline(e.map((e) => x(e)), n ?? t.visible),
415
+ textOf: (e) => t.renderToText(e.map((e) => x(e))),
416
+ options: () => ue(i, t),
417
+ table: () => de(i, t),
418
+ math: () => i.children.filter((e) => e.kind === "math" || e.kind === "inlineMath")
419
+ }), C = Object.freeze({
420
+ value: b,
421
+ slots: Object.freeze(y),
422
+ isReadOnly: _,
421
423
  get(e = "value") {
422
- let t = x[e];
424
+ let t = y[e];
423
425
  return t ? t.get() : null;
424
426
  },
425
427
  set(e, t) {
426
- let n = x[e];
428
+ let n = y[e];
427
429
  return n ? n.set(t) : {
428
430
  ok: !1,
429
431
  diagnostics: [{
430
432
  code: "local.extension.binding",
431
- message: `Component <${a.name || a.id}> has no binding slot "${e}".`,
433
+ message: `Component <${i.name || i.id}> has no binding slot "${e}".`,
432
434
  severity: "error",
433
- range: a.range,
435
+ range: i.range,
434
436
  line: 1,
435
437
  column: 1
436
438
  }]
437
439
  };
438
440
  },
439
441
  setMany(e) {
440
- if (y) return {
442
+ if (_) return {
441
443
  ok: !1,
442
444
  diagnostics: []
443
445
  };
444
- let t = c.setMany(a, e);
446
+ let t = a.setMany(i, e);
445
447
  return {
446
448
  ok: t.length === 0,
447
449
  diagnostics: t
448
450
  };
449
451
  }
450
- }), T = Object.freeze({
451
- fieldFor: (e) => t.validationFieldFor(p(e)),
452
- hintFor: (e) => t.validationHintFor(p(e))
452
+ }), w = Object.freeze({
453
+ fieldFor: (e) => t.validationFieldFor(x(e)),
454
+ hintFor: (e) => t.validationHintFor(x(e))
453
455
  }), E = Object.freeze({
454
456
  targetId: (e) => t.targetId(e),
455
457
  anchorId: () => t.anchorId(e),
@@ -489,15 +491,18 @@ function L(e, t) {
489
491
  }), O = Object.freeze({
490
492
  locale: t.locale,
491
493
  t: (e, n) => t.locale === "zh" ? n : e,
492
- formatNumber: _
494
+ formatNumber: T
493
495
  });
494
496
  return Object.freeze({
495
- props: a.props,
496
- content: a,
497
- services: v,
498
- bindings: w,
499
- children: C,
500
- runtime: c,
497
+ props: i.props,
498
+ authorStyle: t.authorStyle,
499
+ authorStyleText: t.authorStyleText,
500
+ dispatchAuthorAction: t.dispatchAuthorAction,
501
+ content: i,
502
+ services: g,
503
+ bindings: C,
504
+ children: S,
505
+ runtime: a,
501
506
  instance: Object.freeze({
502
507
  id: e.id,
503
508
  componentId: n?.id ?? e.name ?? "",
@@ -511,8 +516,8 @@ function L(e, t) {
511
516
  disabled: t.disabled,
512
517
  disabledInvalid: t.disabledInvalid,
513
518
  resetToken: t.resetToken,
514
- validation: T,
515
- source: Object.freeze({ attributes: (n) => t.sourceAttributes(n ? p(n) : e, e.name) }),
519
+ validation: w,
520
+ source: Object.freeze({ attributes: (n) => t.sourceAttributes(n ? x(n) : e, e.name) }),
516
521
  navigation: E,
517
522
  url: D,
518
523
  locale: O,
@@ -548,12 +553,12 @@ function B(e, t, n) {
548
553
  if (t.interactive === !1 && t.offline === !0 && t.static !== !0) throw TypeError(`Component "${e.id ?? ""}" declares offline output without any renderable implementation.`);
549
554
  }
550
555
  }
551
- function V(e) {
556
+ function me(e) {
552
557
  if (!e || typeof e != "object" || Array.isArray(e)) throw TypeError("defineReactComponent requires a component definition object.");
553
558
  return e;
554
559
  }
555
- function H(t, n) {
556
- let r = V(t);
560
+ function he(t, n) {
561
+ let r = me(t);
557
562
  if (!n || typeof n != "object") throw TypeError("defineReactComponent requires an implementation object.");
558
563
  B(r, z(r), n);
559
564
  let i;
@@ -569,14 +574,346 @@ function H(t, n) {
569
574
  ...n.renderStatic === void 0 ? {} : { renderStatic: n.renderStatic }
570
575
  });
571
576
  }
572
- // src/react/sdk-core.tsx
577
+ // src/react/component-utils.tsx
578
+ function ge(e) {
579
+ return {
580
+ context: e,
581
+ content: e.content,
582
+ props: e.props,
583
+ runtime: e.runtime,
584
+ bindings: e.bindings,
585
+ children: e.children,
586
+ mode: e.mode,
587
+ visible: e.visible,
588
+ disabled: e.disabled,
589
+ disabledInvalid: e.disabledInvalid,
590
+ resetToken: e.resetToken,
591
+ t: e.locale.t,
592
+ locale: e.locale.locale,
593
+ validation: e.validation,
594
+ source: e.source,
595
+ navigation: e.navigation,
596
+ url: e.url,
597
+ report: e.report,
598
+ render: (t, n) => e.children.renderItems(t ?? e.children.items(), n),
599
+ renderInline: (t, n) => e.children.renderInlineItems(t ?? e.children.items(), n)
600
+ };
601
+ }
602
+ function _e(e) {
603
+ let [n, r] = _(null), { locale: i, report: a, bindings: o } = e, s = m((e) => e.map((e) => t(e, i.locale)).join("; "), [i.locale]);
604
+ return {
605
+ write: m((e, t = "value") => {
606
+ let n = o.set(t, e);
607
+ return n.ok ? (r(null), !0) : (n.diagnostics.length > 0 ? (r(s(n.diagnostics)), a(n.diagnostics)) : r(i.t("Cannot write this value", "无法写入此值")), !1);
608
+ }, [
609
+ o,
610
+ i,
611
+ s,
612
+ a
613
+ ]),
614
+ writeMany: m((e) => {
615
+ let t = o.setMany(e);
616
+ return t.ok ? (r(null), !0) : (t.diagnostics.length > 0 ? (r(s(t.diagnostics)), a(t.diagnostics)) : r(i.t("Cannot write this value", "无法写入此值")), !1);
617
+ }, [
618
+ o,
619
+ i,
620
+ s,
621
+ a
622
+ ]),
623
+ error: n,
624
+ setError: r
625
+ };
626
+ }
627
+ function ve(e) {
628
+ return {
629
+ disabled: e.disabled,
630
+ invalid: e.disabledInvalid
631
+ };
632
+ }
633
+ function ye(e, t) {
634
+ return e.validation.fieldFor(t ?? e.content);
635
+ }
636
+ function be(e, t) {
637
+ return e.validation.hintFor(t ?? e.content);
638
+ }
639
+ function xe(e, t) {
640
+ return e.source.attributes(t);
641
+ }
642
+ function Se(e, t) {
643
+ let n = e.resetToken, r = g(n), i = g(t);
644
+ i.current = t, h(() => {
645
+ r.current !== n && (r.current = n, i.current());
646
+ }, [n]);
647
+ }
648
+ function Ce(e, t) {
649
+ return e.attrs[t];
650
+ }
651
+ function we(e, t, n = "") {
652
+ let r = e.props[t];
653
+ return typeof r == "string" ? r : typeof r == "number" ? Number.isFinite(r) ? String(r) : n : typeof r == "boolean" ? r ? "true" : "false" : e.content.attrs[t] === void 0 ? n : e.locale.t("Cannot compute", "无法计算");
654
+ }
655
+ function V(e, t, n) {
656
+ let r = e.props[t];
657
+ return typeof r == "number" && Number.isFinite(r) ? r : n;
658
+ }
659
+ function Te(e, t, n, r = "") {
660
+ let i = t.props[n];
661
+ return typeof i == "string" ? i : typeof i == "number" ? Number.isFinite(i) ? String(i) : r : typeof i == "boolean" ? i ? "true" : "false" : t.attrs[n] === void 0 ? r : e.locale.t("Cannot compute", "无法计算");
662
+ }
663
+ function Ee(e, t, n, r = !1) {
664
+ let i = t.props[n];
665
+ return typeof i == "boolean" ? i : r;
666
+ }
667
+ function De(e, t) {
668
+ if (e.content.attrs[t] === void 0) return {
669
+ present: !1,
670
+ error: !1
671
+ };
672
+ let n = e.props[t];
673
+ return typeof n == "number" && Number.isFinite(n) ? {
674
+ present: !0,
675
+ error: !1,
676
+ value: n
677
+ } : {
678
+ present: !0,
679
+ error: !0
680
+ };
681
+ }
682
+ function Oe(e, t) {
683
+ if (e.content.attrs[t] === void 0) return {
684
+ present: !1,
685
+ error: !1
686
+ };
687
+ let n = e.props[t];
688
+ return typeof n == "string" ? {
689
+ present: !0,
690
+ error: !1,
691
+ value: n
692
+ } : {
693
+ present: !0,
694
+ error: !0
695
+ };
696
+ }
697
+ function H(e, t, n) {
698
+ if (e.content.attrs[t] === void 0) return {
699
+ ok: !0,
700
+ value: n
701
+ };
702
+ let r = e.props[t];
703
+ return typeof r == "boolean" ? {
704
+ ok: !0,
705
+ value: r
706
+ } : { ok: !1 };
707
+ }
708
+ function ke(e, t, n = !1) {
709
+ let r = H(e, t, n);
710
+ return r.ok ? r.value : n;
711
+ }
712
+ function Ae(e, t, n, r) {
713
+ if (e.content.attrs[t] === void 0) return {
714
+ tone: r,
715
+ error: !1
716
+ };
717
+ let i = e.props[t];
718
+ return typeof i == "string" && n.includes(i) ? {
719
+ tone: i,
720
+ error: !1
721
+ } : {
722
+ tone: r,
723
+ error: /\{\{/.test(e.content.attrs[t] ?? "")
724
+ };
725
+ }
726
+ function je(e) {
727
+ let t = e.attrs.color;
728
+ if (t === void 0) return;
729
+ let n = t.trim();
730
+ return n !== "" && r(n) ? n : void 0;
731
+ }
732
+ function Me(e) {
733
+ if (e) return {
734
+ "--local-accent": e,
735
+ "--local-accent-soft": `color-mix(in srgb, ${e} 14%, var(--surface))`,
736
+ "--local-accent-strong": e
737
+ };
738
+ }
573
739
  function U(e) {
740
+ return e === null ? "" : typeof e == "string" ? e : typeof e == "number" ? Number.isFinite(e) ? String(e) : null : typeof e == "boolean" ? e ? "true" : "false" : null;
741
+ }
742
+ function Ne(e) {
743
+ return U(e) ?? "";
744
+ }
745
+ function Pe(e) {
746
+ try {
747
+ return e.runtime.get(e.content);
748
+ } catch {
749
+ return null;
750
+ }
751
+ }
752
+ function Fe(e, t, n) {
753
+ try {
754
+ let r = e.runtime.get(e.content, t);
755
+ return typeof r == "number" && Number.isFinite(r) ? r : n;
756
+ } catch {
757
+ return n;
758
+ }
759
+ }
760
+ function Ie(e, t, n) {
761
+ return Math.min(n, Math.max(t, e));
762
+ }
763
+ function Le(e, t, n, r) {
764
+ let i = Number.isFinite(r) && r > 0 ? r : 1, a = Math.max(0, Math.floor((n - t) / i + 1e-9)), o = t + Math.max(0, Math.min(a, Math.round((e - t) / i))) * i;
765
+ return Number(o.toPrecision(15));
766
+ }
767
+ function Re(e, t, n, r, i, a = 1) {
768
+ let o = V(e, t, r), s = V(e, n, i);
769
+ o > s && ([o, s] = [s, o]);
770
+ let c = V(e, "step", a);
771
+ return {
772
+ min: o,
773
+ max: s,
774
+ step: Number.isFinite(c) && c > 0 ? c : 1
775
+ };
776
+ }
777
+ function ze(e) {
778
+ return e.trim() === "" ? "—" : e;
779
+ }
780
+ var W = (e) => e.startsWith("--") ? e : e.replace(/^ms-?/, "-ms").replace(/[A-Z]/g, (e) => `-${e.toLowerCase()}`);
781
+ function Be(e, t, n) {
782
+ let r = e.ownerDocument.createElement("span").style;
783
+ for (let [e, n] of Object.entries(t ?? {})) {
784
+ if (n == null) continue;
785
+ let t = W(e);
786
+ r.setProperty(t, String(n)), typeof n == "number" && !t.startsWith("--") && !r.getPropertyValue(t) && r.setProperty(t, `${n}px`);
787
+ }
788
+ let i = r.cssText;
789
+ return e.style.cssText = i + n, () => {
790
+ e.style.cssText = i;
791
+ };
792
+ }
793
+ function Ve(e) {
794
+ let t = e.authorStyle, n = e.authorStyleText, r = m((e) => {
795
+ if (!e || !t) return;
796
+ let n = Object.entries(t).map(([e, t]) => `${W(e)}:${t};`).join("");
797
+ e.style.cssText += n;
798
+ }, [t]);
799
+ return (e) => {
800
+ if (n) return {
801
+ style: {
802
+ ...e,
803
+ "--rmd-author-inline": `initial;${n}`
804
+ },
805
+ ref: (t) => t ? Be(t, e, n) : void 0
806
+ };
807
+ if (!t) return {
808
+ style: e,
809
+ ref: void 0
810
+ };
811
+ let i = { ...e };
812
+ for (let [e, n] of Object.entries(t)) delete i[e], i[e] = n;
813
+ return {
814
+ style: i,
815
+ ref: r
816
+ };
817
+ };
818
+ }
819
+ function He({ label: e, value: t, hint: n, className: r = "", multiline: i = !1, authorRoot: a }) {
820
+ return /* @__PURE__ */ y("div", {
821
+ className: `md-control local-static-control ${r}`.trim(),
822
+ ...a,
823
+ children: [
824
+ /* @__PURE__ */ v("span", {
825
+ className: "md-label",
826
+ children: e
827
+ }),
828
+ /* @__PURE__ */ v("span", {
829
+ className: `local-static-value${i ? " local-static-multiline" : ""}`,
830
+ "data-local-static-value": "",
831
+ children: t
832
+ }),
833
+ n ? /* @__PURE__ */ v("span", {
834
+ className: "md-hint",
835
+ children: n
836
+ }) : null
837
+ ]
838
+ });
839
+ }
840
+ function Ue({ value: e, block: t = !1 }) {
841
+ return t ? /* @__PURE__ */ v("div", {
842
+ className: "local-print-value local-print-block",
843
+ "aria-hidden": "true",
844
+ "data-local-print-value": "",
845
+ children: e
846
+ }) : /* @__PURE__ */ v("span", {
847
+ className: "local-print-value",
848
+ "aria-hidden": "true",
849
+ "data-local-print-value": "",
850
+ children: e
851
+ });
852
+ }
853
+ function We({ message: e, id: t }) {
854
+ return e ? /* @__PURE__ */ v("span", {
855
+ id: t,
856
+ className: "field-error",
857
+ role: "alert",
858
+ children: e
859
+ }) : null;
860
+ }
861
+ function Ge({ message: e }) {
862
+ return /* @__PURE__ */ v("span", {
863
+ className: "local-error",
864
+ role: "alert",
865
+ children: e ?? "Cannot compute"
866
+ });
867
+ }
868
+ function Ke({ message: e }) {
869
+ return /* @__PURE__ */ v("span", {
870
+ className: "local-error local-tone-error",
871
+ role: "status",
872
+ children: e
873
+ });
874
+ }
875
+ function qe(e, t) {
876
+ let n = Math.max(0, Math.floor(e)), r = Math.floor(n / 60), i = n % 60;
877
+ return r === 0 ? t(`${i} seconds`, `${i} 秒`) : `${r}:${String(i).padStart(2, "0")}`;
878
+ }
879
+ function Je(e) {
880
+ return T(e);
881
+ }
882
+ function G(e, t, n = 0) {
883
+ if (!t || n > 64) return "";
884
+ let r = "";
885
+ for (let i of t) switch (i.kind) {
886
+ case "text":
887
+ case "inlineCode":
888
+ case "fallback":
889
+ r += i.text;
890
+ break;
891
+ case "interpolation":
892
+ try {
893
+ let t = U(e.runtime.evaluate(i.text));
894
+ r += t ?? e.locale.t("Cannot compute", "无法计算");
895
+ } catch {
896
+ r += e.locale.t("Cannot compute", "无法计算");
897
+ }
898
+ break;
899
+ case "break":
900
+ r += " ";
901
+ break;
902
+ default: r += G(e, i.children, n + 1);
903
+ }
904
+ return r;
905
+ }
906
+ function Ye(e, t) {
907
+ return G(e, t.content.children) || t.content.attrs.value || "";
908
+ }
909
+ // src/react/sdk-core.tsx
910
+ function Xe(e) {
574
911
  if (!e || typeof e != "object" || Array.isArray(e)) throw TypeError("defineReactComponent requires a component definition object.");
575
912
  return e;
576
913
  }
577
- var W = /* @__PURE__ */ new WeakMap();
578
- function G(e) {
579
- let t = W.get(e);
914
+ var K = /* @__PURE__ */ new WeakMap();
915
+ function q(e) {
916
+ let t = K.get(e);
580
917
  if (t) return t;
581
918
  let n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
582
919
  for (let t of e.components) n.set(t.definition.name, t), r.set(t.definition.id, t);
@@ -584,9 +921,9 @@ function G(e) {
584
921
  byName: n,
585
922
  byId: r
586
923
  });
587
- return W.set(e, i), i;
924
+ return K.set(e, i), i;
588
925
  }
589
- function K(e) {
926
+ function Ze(e) {
590
927
  if (!e || typeof e != "object" || Array.isArray(e)) throw TypeError("createReactConfig components must be LocalReactComponent values.");
591
928
  let t = e;
592
929
  if (!t.definition || typeof t.definition != "object") throw TypeError("A React component is missing its manifest definition.");
@@ -594,17 +931,17 @@ function K(e) {
594
931
  if (t.renderStatic !== void 0 && typeof t.renderStatic != "function") throw TypeError("A React component renderStatic must be a function.");
595
932
  return t;
596
933
  }
597
- function q(t, r, i) {
598
- let a = n(t), o = r?.components;
934
+ function Qe(t, n, r) {
935
+ let a = i(t), o = n?.components;
599
936
  if (!Array.isArray(o)) throw TypeError("createReactConfig requires a components array.");
600
- let s = r?.presets ?? [];
937
+ let s = n?.presets ?? [];
601
938
  if (!Array.isArray(s)) throw TypeError("createReactConfig presets must be an array.");
602
939
  let c = [], l = [], u = /* @__PURE__ */ new Set(), d = (t, n) => {
603
- let r = K(t), i = U(r.definition), a = e(i);
940
+ let r = Ze(t), i = Xe(r.definition), a = e(i);
604
941
  if (r.digest !== a) throw TypeError(`React component "${i.id}" from ${n} has a stale digest; create it with defineReactComponent.`);
605
942
  return c.push(r), r;
606
943
  };
607
- for (let e of i) {
944
+ for (let e of r) {
608
945
  let t = d(e, "the default React preset");
609
946
  u.add(t);
610
947
  }
@@ -636,9 +973,9 @@ function q(t, r, i) {
636
973
  components: Object.freeze(g),
637
974
  implementations: Object.freeze(f),
638
975
  themes: _,
639
- hostRenderer: Q(v)
976
+ hostRenderer: rt(v)
640
977
  });
641
- return W.set(y, v), y;
978
+ return K.set(y, v), y;
642
979
  }
643
980
  var J = class extends Error {
644
981
  componentName;
@@ -646,14 +983,14 @@ var J = class extends Error {
646
983
  super(`No React implementation is registered for <${e}>.`), this.name = "LocalReactExtensionMissingError", this.componentName = e;
647
984
  }
648
985
  };
649
- function oe(e) {
986
+ function $e(e) {
650
987
  try {
651
988
  return e.snapshot().revision;
652
989
  } catch {
653
990
  return 0;
654
991
  }
655
992
  }
656
- function se(e, t) {
993
+ function et(e, t) {
657
994
  if (typeof e != "string" || e.length === 0) return {
658
995
  line: 1,
659
996
  column: 1
@@ -666,7 +1003,7 @@ function se(e, t) {
666
1003
  };
667
1004
  }
668
1005
  function Y(e, t, n, r, i) {
669
- let { line: a, column: o } = se(r, n.start);
1006
+ let { line: a, column: o } = et(r, n.start);
670
1007
  return {
671
1008
  code: e,
672
1009
  message: `Component <${t}> failed: ${i instanceof Error ? i.message : String(i)}`,
@@ -679,7 +1016,7 @@ function Y(e, t, n, r, i) {
679
1016
  column: o
680
1017
  };
681
1018
  }
682
- var ce = class extends u {
1019
+ var X = class extends f {
683
1020
  state = { failed: !1 };
684
1021
  static getDerivedStateFromError() {
685
1022
  return { failed: !0 };
@@ -693,7 +1030,7 @@ var ce = class extends u {
693
1030
  this.state.failed && e.revision !== this.props.revision && this.setState({ failed: !1 });
694
1031
  }
695
1032
  render() {
696
- return this.state.failed ? d("span", {
1033
+ return this.state.failed ? p("span", {
697
1034
  className: "local-host-component local-host-unavailable local-sdk-unavailable",
698
1035
  "data-local-host-component": this.props.name,
699
1036
  "data-local-host-reason": "error",
@@ -706,11 +1043,14 @@ var ce = class extends u {
706
1043
  }, `Component <${this.props.name}> is unavailable here.`) : this.props.children;
707
1044
  }
708
1045
  };
709
- function le({ implementation: e, node: t, environment: n }) {
1046
+ function tt({ implementation: e, node: t, environment: n }) {
710
1047
  let r = e.definition.id.startsWith("reactive-md/"), i = n.mode === "static" ? "static" : "interactive";
711
1048
  if (!r && !e.definition.capabilities[i]) throw Error(`Component ${e.definition.id} does not support ${i} rendering.`);
712
1049
  let a = L(t, {
713
1050
  runtime: n.runtime,
1051
+ authorStyle: n.authorStyle,
1052
+ authorStyleText: n.authorStyleText,
1053
+ dispatchAuthorAction: n.dispatchAuthorAction,
714
1054
  network: n.network,
715
1055
  services: n.services ?? n.runtime.services,
716
1056
  mode: n.mode,
@@ -734,9 +1074,9 @@ function le({ implementation: e, node: t, environment: n }) {
734
1074
  urlPolicy: n.urlPolicy,
735
1075
  imageResolver: n.imageResolver
736
1076
  }), o = n.mode === "static" && e.renderStatic ? e.renderStatic : e.render;
737
- return d(o, a);
1077
+ return p(o, a);
738
1078
  }
739
- function X(e, t, n) {
1079
+ function Z(e, t, n) {
740
1080
  let r = t.name ?? "", i = e.byName.get(r);
741
1081
  if (!i) throw new J(r);
742
1082
  let a;
@@ -745,30 +1085,30 @@ function X(e, t, n) {
745
1085
  } catch {
746
1086
  a = void 0;
747
1087
  }
748
- let o = d(le, {
1088
+ let o = p(tt, {
749
1089
  implementation: i,
750
1090
  node: t,
751
1091
  environment: n
752
1092
  });
753
- return i.definition.id.startsWith("reactive-md/") ? o : d(ce, {
1093
+ return i.definition.id.startsWith("reactive-md/") ? o : p(X, {
754
1094
  name: r,
755
1095
  nodeId: t.id,
756
- revision: oe(n.runtime),
1096
+ revision: $e(n.runtime),
757
1097
  range: t.range,
758
1098
  source: a,
759
1099
  report: n.report
760
1100
  }, o);
761
1101
  }
762
- function ue(e) {
763
- return (t, n) => X(G(e), t, n);
1102
+ function nt(e) {
1103
+ return (t, n) => Z(q(e), t, n);
764
1104
  }
765
- function Z(e) {
1105
+ function Q(e) {
766
1106
  let t = "";
767
- for (let n of e ?? []) n.type === "text" || n.type === "inlineCode" || n.type === "code" ? t += n.value ?? "" : n.type === "math" || n.type === "inlineMath" || n.type === "image" ? t += n.value ?? n.alt ?? "" : t += Z(n.children);
1107
+ for (let n of e ?? []) n.type === "text" || n.type === "inlineCode" || n.type === "code" ? t += n.value ?? "" : n.type === "math" || n.type === "inlineMath" || n.type === "image" ? t += n.value ?? n.alt ?? "" : t += Q(n.children);
768
1108
  return t;
769
1109
  }
770
- function Q(e) {
771
- return (t, n, r) => X(e, t, {
1110
+ function rt(e) {
1111
+ return (t, n, r) => Z(e, t, {
772
1112
  runtime: r.runtime,
773
1113
  mode: r.mode,
774
1114
  visible: r.visible,
@@ -778,7 +1118,7 @@ function Q(e) {
778
1118
  locale: "en",
779
1119
  renderChildren: (e, t) => r.render(e, t),
780
1120
  renderInline: (e, t) => r.render(e, t),
781
- renderToText: (e) => Z(e),
1121
+ renderToText: (e) => Q(e),
782
1122
  report: (e) => r.report(e),
783
1123
  definitionFor: (t) => e.byName.get(t)?.definition,
784
1124
  validationField: () => ({ invalid: !1 }),
@@ -790,12 +1130,12 @@ function Q(e) {
790
1130
  jumpTo: () => "missing"
791
1131
  });
792
1132
  }
793
- function de(e, t) {
794
- let n = l(t, e.config);
1133
+ function it(e, t) {
1134
+ let n = d(t, e.config);
795
1135
  if (n.length || !t || typeof t != "object") return n;
796
1136
  let r = t.components;
797
1137
  if (!Array.isArray(r)) return n;
798
- let i = G(e);
1138
+ let i = q(e);
799
1139
  for (let e of r) i.byId.has(e.id) || n.push({
800
1140
  code: "local.extension.renderer-missing",
801
1141
  severity: "error",
@@ -814,7 +1154,7 @@ function $(e, t, n) {
814
1154
  e.report([Y("local.extension.event", e.instance.componentId, e.instance.range, n, t)]);
815
1155
  } catch {}
816
1156
  }
817
- function fe(e, t, n) {
1157
+ function at(e, t, n) {
818
1158
  return (...r) => {
819
1159
  try {
820
1160
  t(...r);
@@ -823,4 +1163,4 @@ function fe(e, t, n) {
823
1163
  }
824
1164
  };
825
1165
  }
826
- export { fe as a, H as c, $ as i, _ as l, q as n, de as o, ue as r, C as s, J as t };
1166
+ export { U as A, xe as B, je as C, Ye as D, Re as E, Ae as F, he as G, be as H, Ve as I, ge as L, Le as M, ze as N, Ce as O, we as P, ve as R, Te as S, De as T, _e as U, ye as V, te as W, Ne as _, at as a, G as b, Ge as c, Ke as d, Me as f, Oe as g, Pe as h, $ as i, Fe as j, H as k, Ue as l, Ie as m, Qe as n, it as o, ke as p, nt as r, We as s, J as t, He as u, Je as v, V as w, Ee as x, qe as y, Se as z };