@baishuyun/ui-base 6.30.0 → 6.31.0

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 (46) hide show
  1. package/dist/AiRuntimeContainer/index.js +210 -199
  2. package/dist/Amap/index.js +1 -1
  3. package/dist/Calendar/{Calendar-C5BesVb4.js → Calendar-_-doXfR6.js} +1 -1
  4. package/dist/Calendar/index.js +3 -3
  5. package/dist/Card/index.js +1 -1
  6. package/dist/CheckBox/index.js +1 -1
  7. package/dist/ColorPicker/index.js +1 -1
  8. package/dist/ConfigProvider/index.js +1 -1
  9. package/dist/DatePicker/{DatePicker-CZTqH2SV.js → DatePicker-DeTo-7cE.js} +1 -1
  10. package/dist/DatePicker/{DatePickerPanel-C-3XX8nV.js → DatePickerPanel-Ce9qqIsW.js} +1 -1
  11. package/dist/DatePicker/index.js +2 -2
  12. package/dist/DropDown/index.js +1 -1
  13. package/dist/Editor/index.js +1 -1
  14. package/dist/FieldCard/index.js +1 -1
  15. package/dist/Gantt/index.js +1 -1
  16. package/dist/Icon/index.js +1 -1
  17. package/dist/InputTag/index.js +1 -1
  18. package/dist/Kanban/index.js +1 -1
  19. package/dist/Loading/index.js +1 -1
  20. package/dist/Modal/index.js +1 -1
  21. package/dist/NotFoundContent/index.js +1 -1
  22. package/dist/Overlay/index.js +1 -1
  23. package/dist/Radio/index.js +1 -1
  24. package/dist/ScrollBar/index.js +1 -1
  25. package/dist/Segmented/index.js +1 -1
  26. package/dist/Select/index.js +1 -1
  27. package/dist/Table/index.js +1 -1
  28. package/dist/Tabs/index.js +1 -1
  29. package/dist/Tooltip/index.js +1 -1
  30. package/dist/Tree/index.js +1 -1
  31. package/dist/components/AiRuntimeContainer/index.d.ts +8 -14
  32. package/dist/index.js +3 -3
  33. package/dist/vendors/{version-DsAuS9CR.js → version-y1_5EbED.js} +1 -1
  34. package/package.json +1 -1
  35. package/dist/components/AiRuntimeContainer/AiRuntimeContainer.d.ts +0 -17
  36. package/dist/components/AiRuntimeContainer/checkCssSyntax.d.ts +0 -5
  37. package/dist/components/AiRuntimeContainer/compileCache.d.ts +0 -15
  38. package/dist/components/AiRuntimeContainer/execute.d.ts +0 -33
  39. package/dist/components/AiRuntimeContainer/interface.d.ts +0 -45
  40. package/dist/components/AiRuntimeContainer/moduleNames.d.ts +0 -6
  41. package/dist/components/AiRuntimeContainer/parseSourceCode.d.ts +0 -22
  42. package/dist/components/AiRuntimeContainer/registry.d.ts +0 -7
  43. package/dist/components/AiRuntimeContainer/scopeCss.d.ts +0 -8
  44. package/dist/components/AiRuntimeContainer/sourceText.d.ts +0 -6
  45. package/dist/components/AiRuntimeContainer/validateFieldSource.d.ts +0 -17
  46. package/dist/types/css-tree.d.ts +0 -33
@@ -1,37 +1,39 @@
1
- import "../vendors/version-DsAuS9CR.js";
1
+ import "../vendors/version-y1_5EbED.js";
2
2
  import { jsx as e } from "react/jsx-runtime";
3
3
  import * as t from "react";
4
- import { Component as n, useCallback as r, useEffect as i, useLayoutEffect as a, useMemo as o, useRef as s } from "react";
5
- import { createRoot as c } from "react-dom/client";
6
- import * as l from "@babel/standalone";
7
- import { parse as u, walk as d } from "css-tree";
8
- import * as f from "lucide-react";
9
- //#region src/components/AiRuntimeContainer/moduleNames.ts
10
- var p = ["react", "lucide-react"], m = new Set(p), h = p.join("、"), g = [
4
+ import { Component as n, useCallback as r, useEffect as i, useLayoutEffect as a, useMemo as ee, useRef as o } from "react";
5
+ import { createRoot as te } from "react-dom/client";
6
+ import * as s from "@babel/standalone";
7
+ import { parse as c, walk as l } from "css-tree";
8
+ import * as u from "lucide-react";
9
+ //#region ../shared/src/ai-runtime/moduleNames.ts
10
+ var d = ["react", "lucide-react"], f = new Set(d), p = d.join("、"), m = [
11
11
  "value",
12
12
  "onChange",
13
13
  "disabled",
14
+ "readOnly",
14
15
  "formData",
15
16
  "tableMode"
16
- ], _ = new Set([
17
+ ], h = new Set([
17
18
  "fetch",
18
19
  "XMLHttpRequest",
19
20
  "WebSocket",
20
21
  "EventSource",
21
22
  "eval",
23
+ "Function",
22
24
  "globalThis",
23
25
  "self",
24
26
  "window",
25
27
  "localStorage",
26
28
  "sessionStorage",
27
29
  "indexedDB"
28
- ]), v = new Set([
30
+ ]), g = new Set([
29
31
  "script",
30
32
  "iframe",
31
33
  "object",
32
34
  "embed",
33
35
  "link"
34
- ]), y = new Set([
36
+ ]), _ = new Set([
35
37
  "loc",
36
38
  "start",
37
39
  "end",
@@ -40,77 +42,77 @@ var p = ["react", "lucide-react"], m = new Set(p), h = p.join("、"), g = [
40
42
  "leadingComments",
41
43
  "trailingComments",
42
44
  "innerComments"
43
- ]), b = /url\(\s*['"]?\s*(?:https?:)?\/\//i, x = (e) => e?.type === "FunctionDeclaration" || e?.type === "FunctionExpression" || e?.type === "ArrowFunctionExpression";
44
- function S(e, t) {
45
+ ]), v = /url\(\s*['"]?\s*(?:https?:)?\/\//i, y = (e) => e?.type === "FunctionDeclaration" || e?.type === "FunctionExpression" || e?.type === "ArrowFunctionExpression";
46
+ function b(e, t) {
45
47
  if (!(!e || typeof e.type != "string") && t(e) !== !1) for (let n of Object.keys(e)) {
46
- if (y.has(n)) continue;
48
+ if (_.has(n)) continue;
47
49
  let r = e[n];
48
- Array.isArray(r) ? r.forEach((e) => S(e, t)) : r && typeof r == "object" && S(r, t);
50
+ Array.isArray(r) ? r.forEach((e) => b(e, t)) : r && typeof r == "object" && b(r, t);
49
51
  }
50
52
  }
51
- function C(e) {
53
+ function x(e) {
52
54
  let t = e.body.find((e) => e.type === "ExportDefaultDeclaration")?.declaration;
53
55
  if (!t) return null;
54
- if (x(t)) return t;
56
+ if (y(t)) return t;
55
57
  if (t.type !== "Identifier") return null;
56
58
  for (let n of e.body) {
57
59
  if (n.type === "FunctionDeclaration" && n.id?.name === t.name) return n;
58
60
  if (n.type === "VariableDeclaration") {
59
- let e = n.declarations.find((e) => e.id?.name === t.name && x(e.init));
61
+ let e = n.declarations.find((e) => e.id?.name === t.name && y(e.init));
60
62
  if (e) return e.init;
61
63
  }
62
64
  }
63
65
  return null;
64
66
  }
65
- var w = (e) => e.computed ? null : e.key.type === "Identifier" ? e.key.name : e.key.type === "StringLiteral" ? e.key.value : null;
66
- function T(e, t, n) {
67
+ var S = (e) => e.computed ? null : e.key.type === "Identifier" ? e.key.name : e.key.type === "StringLiteral" ? e.key.value : null, C = (e) => e ? e.type === "Identifier" ? e.name : e.type === "StringLiteral" ? e.value : e.type === "TemplateLiteral" && e.expressions.length === 0 ? e.quasis[0]?.value?.cooked ?? null : null : null;
68
+ function w(e, t, n) {
67
69
  for (let r of e.properties) {
68
70
  if (r.type === "RestElement") {
69
- n.push(`组件不能用 ...rest 收集 props,请只解构 ${g.join("、")}。`);
71
+ n.push(`组件不能用 ...rest 收集 props,请只解构 ${m.join("、")}。`);
70
72
  continue;
71
73
  }
72
- let e = w(r);
73
- e === null ? n.push("组件的 props 不能使用计算属性名。") : g.includes(e) || t.add(e);
74
+ let e = S(r);
75
+ e === null ? n.push("组件的 props 不能使用计算属性名。") : m.includes(e) || t.add(e);
74
76
  }
75
77
  }
76
- function E(e) {
78
+ function T(e) {
77
79
  let t = [], n = /* @__PURE__ */ new Set(), [r] = e.params;
78
- return e.params.length > 1 && t.push("组件只接收一个 props 参数,不能有第二个参数(如 ref)。"), r?.type === "AssignmentPattern" && (r = r.left), r?.type === "ObjectPattern" ? T(r, n, t) : r?.type === "Identifier" && S(e.body, (e) => {
80
+ return e.params.length > 1 && t.push("组件只接收一个 props 参数,不能有第二个参数(如 ref)。"), r?.type === "AssignmentPattern" && (r = r.left), r?.type === "ObjectPattern" ? w(r, n, t) : r?.type === "Identifier" && b(e.body, (e) => {
79
81
  if (e.type === "MemberExpression" && e.object?.name === r.name) {
80
82
  let r = e.computed ? null : e.property.name;
81
- return r === null ? t.push("组件不能用动态键读取 props。") : g.includes(r) || n.add(r), !1;
83
+ return r === null ? t.push("组件不能用动态键读取 props。") : m.includes(r) || n.add(r), !1;
82
84
  }
83
- return e.type === "VariableDeclarator" && e.init?.name === r.name && e.id.type === "ObjectPattern" ? (T(e.id, n, t), !1) : !0;
84
- }), n.size && t.unshift(`组件签名只能接收 ${g.join("、")},发现多余的 props:${[...n].join("、")}。平台不会传入它们,请删除,需要的文案或配置直接写在组件内部。`), t;
85
+ return e.type === "VariableDeclarator" && e.init?.name === r.name && e.id.type === "ObjectPattern" ? (w(e.id, n, t), !1) : !0;
86
+ }), n.size && t.unshift(`组件签名只能接收 ${m.join("、")},发现多余的 props:${[...n].join("、")}。平台不会传入它们,请删除,需要的文案或配置直接写在组件内部。`), t;
85
87
  }
86
- function D(e) {
88
+ function E(e) {
87
89
  let t = /* @__PURE__ */ new Set(), n = (e) => {
88
90
  switch (e.type) {
89
- case "Identifier": return _.has(e.name) && t.add(e.name), !0;
91
+ case "Identifier": return h.has(e.name) && t.add(e.name), !0;
90
92
  case "MemberExpression":
91
- case "OptionalMemberExpression": return e.computed ? !0 : (S(e.object, n), !1);
92
- case "ObjectProperty": return e.computed ? !0 : (S(e.value, n), !1);
93
- case "ImportDeclaration": return m.has(e.source.value) || t.add(`import "${e.source.value}"(只能 import ${h})`), !1;
93
+ case "OptionalMemberExpression": return C(e.property) === "constructor" && t.add("constructor"), e.computed ? !0 : (b(e.object, n), !1);
94
+ case "ObjectProperty": return e.computed ? !0 : (b(e.value, n), !1);
95
+ case "ImportDeclaration": return f.has(e.source.value) || t.add(`import "${e.source.value}"(只能 import ${p})`), !1;
94
96
  case "Import":
95
97
  case "ImportExpression": return t.add("动态 import()"), !0;
96
98
  case "JSXOpeningElement": {
97
99
  let n = e.name?.name;
98
- return n === "textarea" ? t.add("<textarea>(单行文本的值不能包含换行)") : v.has(n) && t.add(`<${n}>`), !0;
100
+ return n === "textarea" ? t.add("<textarea>(单行文本的值不能包含换行)") : g.has(n) && t.add(`<${n}>`), !0;
99
101
  }
100
102
  case "JSXAttribute": return e.name?.name === "dangerouslySetInnerHTML" && t.add("dangerouslySetInnerHTML"), !0;
101
103
  default: return !0;
102
104
  }
103
105
  };
104
- return S(e, n), [...t];
106
+ return b(e, n), [...t];
105
107
  }
106
- function O(e) {
108
+ function D(e) {
107
109
  let t = [];
108
- return /@import\b/i.test(e) && t.push("CSS 中不能使用 @import。"), b.test(e) && t.push("CSS 中不能引用外部地址,图片请用内联 svg 或 data: 地址。"), t;
110
+ return /@import\b/i.test(e) && t.push("CSS 中不能使用 @import。"), v.test(e) && t.push("CSS 中不能引用外部地址,图片请用内联 svg 或 data: 地址。"), t;
109
111
  }
110
- function k(e, t = null) {
112
+ function O(e, t = null) {
111
113
  let n = [], r = null;
112
114
  try {
113
- r = l.packages.parser.parse(e, {
115
+ r = s.packages.parser.parse(e, {
114
116
  sourceType: "module",
115
117
  plugins: ["jsx"]
116
118
  }).program;
@@ -118,21 +120,21 @@ function k(e, t = null) {
118
120
  if (!(e instanceof SyntaxError)) throw e;
119
121
  }
120
122
  if (r) {
121
- let e = C(r);
122
- e && n.push(...E(e));
123
- let t = D(r);
124
- t.length && n.push(`不允许使用:${t.join("、")}。组件不能发起网络请求或使用 eval,也不能注入脚本和原始 HTML。`);
123
+ let e = x(r);
124
+ e && n.push(...T(e));
125
+ let t = E(r);
126
+ t.length && n.push(`不允许使用:${t.join("、")}。组件不能发起网络请求、使用 eval 或 Function,也不能读取 constructor 或注入脚本和原始 HTML。`);
125
127
  }
126
- return t != null && n.push(...O(t)), n;
128
+ return t != null && n.push(...D(t)), n;
127
129
  }
128
- function A(e, t = null) {
129
- let n = k(e, t);
130
+ function k(e, t = null) {
131
+ let n = O(e, t);
130
132
  if (n.length) throw Error(`组件不符合运行时约束:\n${n.map((e) => `- ${e}`).join("\n")}`);
131
133
  }
132
134
  //#endregion
133
- //#region src/components/AiRuntimeContainer/checkCssSyntax.ts
134
- function j(e, t = "style.css") {
135
- e?.trim() && d(u(e, {
135
+ //#region ../shared/src/ai-runtime/checkCssSyntax.ts
136
+ function A(e, t = "style.css") {
137
+ e?.trim() && l(c(e, {
136
138
  filename: t,
137
139
  positions: !0,
138
140
  onParseError(e) {
@@ -144,15 +146,15 @@ function j(e, t = "style.css") {
144
146
  });
145
147
  }
146
148
  //#endregion
147
- //#region src/components/AiRuntimeContainer/sourceText.ts
148
- var ee = /function\s+([A-Za-z_$][\w$]*)/, te = /export\s+default\b/;
149
- function ne(e) {
150
- if (!e || te.test(e)) return e;
151
- let t = e.match(ee)?.[1];
149
+ //#region ../shared/src/ai-runtime/sourceText.ts
150
+ var j = /function\s+([A-Za-z_$][\w$]*)/, ne = /export\s+default\b/;
151
+ function M(e) {
152
+ if (!e || ne.test(e)) return e;
153
+ let t = e.match(j)?.[1];
152
154
  return t ? `${e.trim()}\nexport default ${t};\n` : e;
153
155
  }
154
156
  //#endregion
155
- //#region src/components/AiRuntimeContainer/parseSourceCode.ts
157
+ //#region ../shared/src/ai-runtime/parseSourceCode.ts
156
158
  var re = /<(jsx|css)>([\s\S]*?)<\/\1>/g, ie = {
157
159
  ast: !1,
158
160
  sourceType: "module",
@@ -162,7 +164,7 @@ var re = /<(jsx|css)>([\s\S]*?)<\/\1>/g, ie = {
162
164
  }]],
163
165
  plugins: ["transform-modules-commonjs"]
164
166
  };
165
- function M(e) {
167
+ function N(e) {
166
168
  if (typeof e != "string" || !e.trim()) return null;
167
169
  let t = null, n = null;
168
170
  for (let r of e.matchAll(re)) {
@@ -174,13 +176,13 @@ function M(e) {
174
176
  css: n
175
177
  };
176
178
  }
177
- var N = "export default function AiRuntimeField() {\n return null;\n}";
179
+ var ae = "export default function AiRuntimeField() {\n return null;\n}";
178
180
  function P(e, t = "ai") {
179
- let n = M(e);
181
+ let n = N(e);
180
182
  if (!n) throw Error("code 里没有可用的 <jsx> 或 <css>。");
181
- let r = ne(n.jsx || N), i = n.css ?? "";
182
- i && j(i, `${t}.css`), A(r, i || null);
183
- let a = l.transform(r, {
183
+ let r = M(n.jsx || ae), i = n.css ?? "";
184
+ i && A(i, `${t}.css`), k(r, i || null);
185
+ let a = s.transform(r, {
184
186
  ...ie,
185
187
  filename: `${t}.jsx`
186
188
  });
@@ -191,16 +193,16 @@ function P(e, t = "ai") {
191
193
  };
192
194
  }
193
195
  //#endregion
194
- //#region src/components/AiRuntimeContainer/compileCache.ts
195
- var ae = 200, F = /* @__PURE__ */ new Map(), oe = Object.freeze({
196
+ //#region ../shared/src/ai-runtime/compileCache.ts
197
+ var F = 200, I = /* @__PURE__ */ new Map(), oe = Object.freeze({
196
198
  ok: !1,
197
199
  code: "",
198
200
  css: "",
199
201
  error: null
200
- }), I = (e, t) => {
202
+ }), L = (e, t) => {
201
203
  if (typeof e != "string" || !e.trim()) return oe;
202
- let n = F.get(e);
203
- if (n) return F.delete(e), F.set(e, n), n;
204
+ let n = I.get(e);
205
+ if (n) return I.delete(e), I.set(e, n), n;
204
206
  let r;
205
207
  try {
206
208
  let n = P(e, t);
@@ -218,73 +220,73 @@ var ae = 200, F = /* @__PURE__ */ new Map(), oe = Object.freeze({
218
220
  error: e
219
221
  };
220
222
  }
221
- if (F.size >= ae) {
222
- let e = F.keys().next().value;
223
- e !== void 0 && F.delete(e);
223
+ if (I.size >= F) {
224
+ let e = I.keys().next().value;
225
+ e !== void 0 && I.delete(e);
224
226
  }
225
- return F.set(e, r), r;
227
+ return I.set(e, r), r;
226
228
  }, se = () => {
227
- F.clear();
228
- }, L = (e, t) => {
229
+ I.clear();
230
+ }, R = (e, t) => {
229
231
  let n = {};
230
232
  for (let t of Object.keys(e)) n[t] = e[t];
231
233
  return (n.default === void 0 || n.default === null) && (n.default = t), Object.defineProperty(n, "__esModule", { value: !0 }), n;
232
- }, R = t.default || t, ce = {
233
- react: L(t, R),
234
- "lucide-react": L(f, f)
235
- }, z = {};
236
- for (let e of p) {
234
+ }, z = t.default || t, ce = {
235
+ react: R(t, z),
236
+ "lucide-react": R(u, u)
237
+ }, B = {};
238
+ for (let e of d) {
237
239
  let t = ce[e];
238
240
  if (!t) throw Error(`模块 ${e} 在白名单里但没有实现。`);
239
- z[e] = t;
241
+ B[e] = t;
240
242
  }
241
- var B = Object.keys(z), V = (e) => {
242
- let t = z[e];
243
+ var V = Object.keys(B), H = (e) => {
244
+ let t = B[e];
243
245
  if (t) return t;
244
- throw Error(`Unknown module: ${e}(组件只能 require ${B.join("、")})`);
245
- }, H = {
246
+ throw Error(`Unknown module: ${e}(组件只能 require ${V.join("、")})`);
247
+ }, U = {
246
248
  COMPILE: 4001,
247
249
  EXECUTE: 4002,
248
250
  RENDER: 5001,
249
251
  RUNTIME: 5002
250
- }, U = new Set(Object.values(H)), W = (e, t) => {
252
+ }, W = new Set(Object.values(U)), G = (e, t) => {
251
253
  let n = e instanceof Error ? e : Error(String(e)), r = n.code;
252
- return (typeof r != "number" || !U.has(r)) && (n.code = t), n;
253
- }, G = 0, le = () => (G += 1, `ai-runtime-${G}.js`), ue = (e, t) => {
254
+ return (typeof r != "number" || !W.has(r)) && (n.code = t), n;
255
+ }, K = 0, le = (e) => (K += 1, `ai-runtime-${e}-${K}.js`), ue = (e, t) => {
254
256
  if (!e) throw Error("没有可执行的代码。");
255
257
  let n = {}, r = `${e}\n//# sourceURL=${t}`;
256
- if (Function("require", "exports", "React", r)(V, n, R), typeof n.default != "function") throw Error("Missing default export:组件必须默认导出一个函数。");
258
+ if (Function("require", "exports", "React", r)(H, n, z), typeof n.default != "function") throw Error("Missing default export:组件必须默认导出一个函数。");
257
259
  return n.default;
258
- }, K = /* @__PURE__ */ new Map(), q = !1, J = /* @__PURE__ */ new WeakSet(), de = (e) => {
259
- e && typeof e == "object" && J.add(e);
260
- }, Y = (e) => {
261
- if (e && typeof e == "object" && J.has(e)) return;
260
+ }, q = /* @__PURE__ */ new Map(), J = !1, Y = /* @__PURE__ */ new WeakSet(), de = (e) => {
261
+ e && typeof e == "object" && Y.add(e);
262
+ }, X = (e) => {
263
+ if (e && typeof e == "object" && Y.has(e)) return;
262
264
  let t = e instanceof Error ? e.stack : void 0;
263
265
  if (typeof t == "string") {
264
- for (let [n, r] of K) if (t.includes(n)) {
265
- r(W(e, H.RUNTIME));
266
+ for (let [n, r] of q) if (t.includes(n)) {
267
+ r(G(e, U.RUNTIME));
266
268
  return;
267
269
  }
268
270
  }
269
271
  }, fe = () => {
270
- q || typeof window > "u" || (q = !0, window.addEventListener("error", (e) => {
272
+ J || typeof window > "u" || (J = !0, window.addEventListener("error", (e) => {
271
273
  let t = e.error || Error(e.message);
272
- queueMicrotask(() => Y(t));
274
+ queueMicrotask(() => X(t));
273
275
  }), window.addEventListener("unhandledrejection", (e) => {
274
276
  let t = e.reason;
275
- queueMicrotask(() => Y(t));
277
+ queueMicrotask(() => X(t));
276
278
  }));
277
279
  }, pe = (e, t) => {
278
- fe(), K.set(e, t);
280
+ fe(), q.set(e, t);
279
281
  }, me = (e) => {
280
- K.delete(e);
281
- }, he = /(^|[\s,>+~(])(?::root\b|html\b|body\b)/gi, X = (e) => typeof e != "string" || !e ? "" : e.replace(he, "$1:host"), Z = typeof window > "u" ? i : a, ge = class extends n {
282
+ q.delete(e);
283
+ }, he = /(^|[\s,>+~(])(?::root\b|html\b|body\b)/gi, Z = (e) => typeof e != "string" || !e ? "" : e.replace(he, "$1:host"), ge = typeof window > "u" ? i : a, _e = class extends n {
282
284
  state = { failed: !1 };
283
285
  static getDerivedStateFromError() {
284
286
  return { failed: !0 };
285
287
  }
286
288
  componentDidCatch(e) {
287
- de(e), this.props.onError(W(e, H.RENDER));
289
+ de(e), this.props.onError(G(e, U.RENDER));
288
290
  }
289
291
  render() {
290
292
  return this.state.failed ? null : this.props.children;
@@ -294,118 +296,127 @@ var B = Object.keys(z), V = (e) => {
294
296
  return {
295
297
  value: n.value ?? "",
296
298
  disabled: !!n.disabled,
299
+ readOnly: !!n.readOnly,
297
300
  formData: n.formData || {},
298
301
  tableMode: !!n.tableMode,
299
302
  onChange: t
300
303
  };
301
- }, _e = {
304
+ }, ve = {
302
305
  ok: !1,
303
306
  error: null,
304
307
  Component: null
305
- }, $ = ({ code: t, value: n, disabled: a, formData: l, tableMode: u, runToken: d, height: f, minHeight: p, className: m, style: h, onChange: g, onError: _ }) => {
306
- let v = s(null), y = s(null), b = s(null), x = s({});
307
- x.current = {
308
- onChange: g,
309
- onError: _
310
- };
311
- let S = s(null);
312
- S.current === null && (S.current = le());
313
- let C = S.current, w = I(t), T = s({
314
- source: void 0,
315
- token: void 0,
316
- result: _e
317
- });
318
- if (T.current.source !== t || T.current.token !== d) {
319
- let e;
320
- if (!w.ok) e = {
321
- ok: !1,
322
- error: w.error,
323
- Component: null
308
+ };
309
+ function ye(t) {
310
+ let n = ({ code: n, value: a, disabled: s, readOnly: c, formData: l, tableMode: u, runToken: d, height: f, minHeight: p, className: m, style: h, onChange: g, onError: _ }) => {
311
+ let v = o(null), y = o(null), b = o(null), x = o({});
312
+ x.current = {
313
+ onChange: g,
314
+ onError: _
324
315
  };
325
- else try {
326
- e = {
327
- ok: !0,
328
- error: null,
329
- Component: ue(w.code, C)
330
- };
331
- } catch (t) {
332
- e = {
316
+ let S = o(null);
317
+ S.current === null && (S.current = le(t));
318
+ let C = S.current, w = L(n), T = o({
319
+ source: void 0,
320
+ token: void 0,
321
+ result: ve
322
+ });
323
+ if (T.current.source !== n || T.current.token !== d) {
324
+ let e;
325
+ if (!w.ok) e = {
333
326
  ok: !1,
334
- error: t,
327
+ error: w.error,
335
328
  Component: null
336
329
  };
337
- }
338
- T.current = {
339
- source: t,
340
- token: d,
341
- result: e
342
- };
343
- }
344
- let E = T.current.result, D = r((e) => x.current.onChange?.(e), []), O = r((e) => x.current.onError?.(e), []), k = r(() => {
345
- if (y.current) return y.current;
346
- let e = v.current;
347
- if (!e) return null;
348
- let t = e.shadowRoot || e.attachShadow({ mode: "open" }), n = document.createElement("style"), r = document.createElement("div");
349
- return r.setAttribute("data-ai-runtime-mount", ""), r.style.height = "100%", t.append(n, r), y.current = {
350
- root: c(r, { onUncaughtError: (e) => x.current.onError?.(W(e, H.RUNTIME)) }),
351
- styleEl: n,
352
- mountEl: r
353
- }, y.current;
354
- }, []), A = o(() => Q({
355
- value: n,
356
- disabled: a,
357
- formData: l,
358
- tableMode: u
359
- }, D), [
360
- n,
361
- a,
362
- l,
363
- u,
364
- D
365
- ]);
366
- Z(() => {
367
- let t = k();
368
- if (!t) return;
369
- let { root: n, styleEl: r } = t;
370
- if (!E.ok) {
371
- if (b.current !== E && (b.current = E, r.textContent = "", n.render(null), E.error)) {
372
- let e = w.ok ? H.EXECUTE : H.COMPILE;
373
- x.current.onError?.(W(E.error, e));
330
+ else try {
331
+ e = {
332
+ ok: !0,
333
+ error: null,
334
+ Component: ue(w.code, C)
335
+ };
336
+ } catch (t) {
337
+ e = {
338
+ ok: !1,
339
+ error: t,
340
+ Component: null
341
+ };
374
342
  }
375
- return;
343
+ T.current = {
344
+ source: n,
345
+ token: d,
346
+ result: e
347
+ };
376
348
  }
377
- b.current = null;
378
- let i = X(w.css);
379
- r.textContent !== i && (r.textContent = i);
380
- let a = E.Component;
381
- n.render(/* @__PURE__ */ e(ge, {
382
- onError: O,
383
- children: /* @__PURE__ */ e(a, { ...A })
384
- }));
385
- }, [
386
- w,
387
- E,
388
- A,
389
- O,
390
- k
391
- ]), i(() => () => {
392
- let e = y.current;
393
- y.current = null, e && (e.styleEl.remove(), e.mountEl.remove(), queueMicrotask(() => e.root.unmount()));
394
- }, []), i(() => (pe(C, (e) => x.current.onError?.(e)), () => me(C)), [C]);
395
- let j = {
396
- height: f ?? "auto",
397
- minHeight: p ?? 32,
398
- overflow: "auto",
399
- contain: "layout paint",
400
- ...h
349
+ let E = T.current.result, D = r((e) => x.current.onChange?.(e), []), O = r((e) => x.current.onError?.(e), []), k = r(() => {
350
+ if (y.current) return y.current;
351
+ let e = v.current;
352
+ if (!e) return null;
353
+ let t = e.shadowRoot || e.attachShadow({ mode: "open" }), n = document.createElement("style"), r = document.createElement("div");
354
+ return r.setAttribute("data-ai-runtime-mount", ""), r.style.height = "100%", t.append(n, r), y.current = {
355
+ root: te(r, { onUncaughtError: (e) => x.current.onError?.(G(e, U.RUNTIME)) }),
356
+ styleEl: n,
357
+ mountEl: r
358
+ }, y.current;
359
+ }, []), A = ee(() => Q({
360
+ value: a,
361
+ disabled: s,
362
+ readOnly: c,
363
+ formData: l,
364
+ tableMode: u
365
+ }, D), [
366
+ a,
367
+ s,
368
+ c,
369
+ l,
370
+ u,
371
+ D
372
+ ]);
373
+ ge(() => {
374
+ let t = k();
375
+ if (!t) return;
376
+ let { root: n, styleEl: r } = t;
377
+ if (!E.ok) {
378
+ if (b.current !== E && (b.current = E, r.textContent = "", n.render(null), E.error)) {
379
+ let e = w.ok ? U.EXECUTE : U.COMPILE;
380
+ x.current.onError?.(G(E.error, e));
381
+ }
382
+ return;
383
+ }
384
+ b.current = null;
385
+ let i = Z(w.css);
386
+ r.textContent !== i && (r.textContent = i);
387
+ let a = E.Component;
388
+ n.render(/* @__PURE__ */ e(_e, {
389
+ onError: O,
390
+ children: /* @__PURE__ */ e(a, { ...A })
391
+ }));
392
+ }, [
393
+ w,
394
+ E,
395
+ A,
396
+ O,
397
+ k
398
+ ]), i(() => () => {
399
+ let e = y.current;
400
+ y.current = null, e && (e.styleEl.remove(), e.mountEl.remove(), queueMicrotask(() => e.root.unmount()));
401
+ }, []), i(() => (pe(C, (e) => x.current.onError?.(e)), () => me(C)), [C]);
402
+ let j = {
403
+ height: f ?? "auto",
404
+ minHeight: p ?? 32,
405
+ overflow: "auto",
406
+ contain: "layout paint",
407
+ ...h
408
+ };
409
+ return /* @__PURE__ */ e("div", {
410
+ ref: v,
411
+ "data-ai-runtime-host": "",
412
+ className: m,
413
+ style: j
414
+ });
401
415
  };
402
- return /* @__PURE__ */ e("div", {
403
- ref: v,
404
- "data-ai-runtime-host": "",
405
- className: m,
406
- style: j
407
- });
408
- };
409
- $.displayName = "BsyAiRuntimeContainer";
416
+ return n.displayName = "BsyAiRuntimeContainer", n;
417
+ }
418
+ //#endregion
419
+ //#region src/components/AiRuntimeContainer/index.ts
420
+ var $ = ye("ui-base");
410
421
  //#endregion
411
- export { $ as AiRuntimeContainer, $ as default, H as ERROR_CODE, B as MODULE_NAMES, A as assertFieldSource, se as clearCompileCache, P as compileAiCode, I as compileCached, X as scopeCss, M as splitAiCode, Q as toPlainProps, k as validateFieldSource };
422
+ export { $ as AiRuntimeContainer, $ as default, U as ERROR_CODE, V as MODULE_NAMES, k as assertFieldSource, se as clearCompileCache, P as compileAiCode, L as compileCached, Z as scopeCss, N as splitAiCode, Q as toPlainProps, O as validateFieldSource };
@@ -1,4 +1,4 @@
1
- import "../vendors/version-DsAuS9CR.js";
1
+ import "../vendors/version-y1_5EbED.js";
2
2
  import "../vendors/LocaleContext-CsTLO_Y2.js";
3
3
  import "../vendors/ConfigProvider-BDmu_0qa.js";
4
4
  import "../Overlay/OverlayContext-CVSFoyqN.js";
@@ -3,7 +3,7 @@ import { t } from "../vendors/useLocale-3oUjPb-k.js";
3
3
  import { t as n } from "../vendors/cssVars-UpriQzph.js";
4
4
  import { t as r } from "../Segmented/Segmented-BMwjhsZw.js";
5
5
  import { t as i } from "../Tooltip/Tooltip-N06Os8rG.js";
6
- import { t as a } from "../DatePicker/DatePicker-CZTqH2SV.js";
6
+ import { t as a } from "../DatePicker/DatePicker-DeTo-7cE.js";
7
7
  import { jsx as o, jsxs as s } from "react/jsx-runtime";
8
8
  import { memo as c, useCallback as l, useEffect as u, useLayoutEffect as d, useMemo as f, useRef as p, useState as m } from "react";
9
9
  import h from "clsx";
@@ -1,4 +1,4 @@
1
- import "../vendors/version-DsAuS9CR.js";
1
+ import "../vendors/version-y1_5EbED.js";
2
2
  import "../Icon/Icon-CcKDWNGy.js";
3
3
  import "../vendors/LocaleContext-CsTLO_Y2.js";
4
4
  import "../Overlay/OverlayContext-CVSFoyqN.js";
@@ -7,7 +7,7 @@ import "../vendors/useLocale-3oUjPb-k.js";
7
7
  import "../vendors/useLatchedPopupPortalRoot-CC6af8t-.js";
8
8
  import "../Segmented/Segmented-BMwjhsZw.js";
9
9
  import "../Tooltip/Tooltip-N06Os8rG.js";
10
- import { n as e, r as t, t as n } from "./Calendar-C5BesVb4.js";
11
- import "../DatePicker/DatePicker-CZTqH2SV.js";
10
+ import { n as e, r as t, t as n } from "./Calendar-_-doXfR6.js";
11
+ import "../DatePicker/DatePicker-DeTo-7cE.js";
12
12
  import "../DatePicker/pickerLocale-Brf7_Tnd.js";
13
13
  export { n as Calendar, n as default, t as resolveCalendarThemeVars, e as resolvePlatformCalendarTheme };
@@ -1,4 +1,4 @@
1
- import "../vendors/version-DsAuS9CR.js";
1
+ import "../vendors/version-y1_5EbED.js";
2
2
  import "../Icon/Icon-CcKDWNGy.js";
3
3
  import { t as e } from "./Card-BT2LRubP.js";
4
4
  export { e as default };
@@ -1,4 +1,4 @@
1
- import "../vendors/version-DsAuS9CR.js";
1
+ import "../vendors/version-y1_5EbED.js";
2
2
  import "../Icon/Icon-CcKDWNGy.js";
3
3
  import "./CheckBox-DOdRLFKI.js";
4
4
  import { t as e } from "./CheckBox-CtOSHKM0.js";
@@ -1,4 +1,4 @@
1
- import "../vendors/version-DsAuS9CR.js";
1
+ import "../vendors/version-y1_5EbED.js";
2
2
  import "../Icon/Icon-CcKDWNGy.js";
3
3
  import "../vendors/LocaleContext-CsTLO_Y2.js";
4
4
  import "../Overlay/OverlayContext-CVSFoyqN.js";
@@ -1,4 +1,4 @@
1
- import "../vendors/version-DsAuS9CR.js";
1
+ import "../vendors/version-y1_5EbED.js";
2
2
  import "../vendors/LocaleContext-CsTLO_Y2.js";
3
3
  import { n as e, t } from "../vendors/ConfigProvider-BDmu_0qa.js";
4
4
  import "../Overlay/OverlayContext-CVSFoyqN.js";
@@ -48,7 +48,7 @@ var w = {
48
48
  "bsy-date-picker__content": "_bsy-date-picker__content_1i2le_33",
49
49
  "bsy-date-picker__divider": "_bsy-date-picker__divider_1i2le_43",
50
50
  "bsy-date-picker__panel-loading": "_bsy-date-picker__panel-loading_1i2le_49"
51
- }, j = m(() => import("./DatePickerPanel-C-3XX8nV.js")), M = (o) => {
51
+ }, j = m(() => import("./DatePickerPanel-Ce9qqIsW.js")), M = (o) => {
52
52
  let { children: m, picker: S = "date", theme: w, getPopupContainer: D, triggerActiveClassName: O, zIndex: M } = o, { locale: N } = r(), P = e(M), [F, I] = v(o, {
53
53
  defaultValuePropName: "defaultValue",
54
54
  valuePropName: "value",
@@ -1,4 +1,4 @@
1
- import "../vendors/version-DsAuS9CR.js";
1
+ import "../vendors/version-y1_5EbED.js";
2
2
  import { t as e } from "../Icon/Icon-CcKDWNGy.js";
3
3
  import "../vendors/LocaleContext-CsTLO_Y2.js";
4
4
  import { t } from "../vendors/useLocale-3oUjPb-k.js";
@@ -1,9 +1,9 @@
1
- import "../vendors/version-DsAuS9CR.js";
1
+ import "../vendors/version-y1_5EbED.js";
2
2
  import "../vendors/LocaleContext-CsTLO_Y2.js";
3
3
  import "../Overlay/OverlayContext-CVSFoyqN.js";
4
4
  import "../vendors/useFloatingOverlay-B66lOL8v.js";
5
5
  import "../vendors/useLocale-3oUjPb-k.js";
6
6
  import "../vendors/useLatchedPopupPortalRoot-CC6af8t-.js";
7
- import { t as e } from "./DatePicker-CZTqH2SV.js";
7
+ import { t as e } from "./DatePicker-DeTo-7cE.js";
8
8
  import "./pickerLocale-Brf7_Tnd.js";
9
9
  export { e as default };
@@ -1,4 +1,4 @@
1
- import "../vendors/version-DsAuS9CR.js";
1
+ import "../vendors/version-y1_5EbED.js";
2
2
  import "../ScrollBar/style-D26azwz6.js";
3
3
  import "../Icon/Icon-CcKDWNGy.js";
4
4
  import "../vendors/LocaleContext-CsTLO_Y2.js";
@@ -1,4 +1,4 @@
1
- import "../vendors/version-DsAuS9CR.js";
1
+ import "../vendors/version-y1_5EbED.js";
2
2
  import "../ScrollBar/style-D26azwz6.js";
3
3
  import { t as e } from "../Icon/Icon-CcKDWNGy.js";
4
4
  import "../vendors/LocaleContext-CsTLO_Y2.js";
@@ -1,4 +1,4 @@
1
- import "../vendors/version-DsAuS9CR.js";
1
+ import "../vendors/version-y1_5EbED.js";
2
2
  import "../ScrollBar/style-D26azwz6.js";
3
3
  import "../Icon/Icon-CcKDWNGy.js";
4
4
  import "../vendors/LocaleContext-CsTLO_Y2.js";
@@ -1,4 +1,4 @@
1
- import "../vendors/version-DsAuS9CR.js";
1
+ import "../vendors/version-y1_5EbED.js";
2
2
  import "../ScrollBar/style-D26azwz6.js";
3
3
  import { t as e } from "../Icon/Icon-CcKDWNGy.js";
4
4
  import "../vendors/LocaleContext-CsTLO_Y2.js";
@@ -1,3 +1,3 @@
1
- import "../vendors/version-DsAuS9CR.js";
1
+ import "../vendors/version-y1_5EbED.js";
2
2
  import { t as e } from "./Icon-CcKDWNGy.js";
3
3
  export { e as default };
@@ -1,4 +1,4 @@
1
- import "../vendors/version-DsAuS9CR.js";
1
+ import "../vendors/version-y1_5EbED.js";
2
2
  import "../ScrollBar/style-D26azwz6.js";
3
3
  import "../Icon/Icon-CcKDWNGy.js";
4
4
  import "../vendors/LocaleContext-CsTLO_Y2.js";
@@ -1,4 +1,4 @@
1
- import "../vendors/version-DsAuS9CR.js";
1
+ import "../vendors/version-y1_5EbED.js";
2
2
  import "../ScrollBar/style-D26azwz6.js";
3
3
  import { t as e } from "../Icon/Icon-CcKDWNGy.js";
4
4
  import "../vendors/LocaleContext-CsTLO_Y2.js";
@@ -1,4 +1,4 @@
1
- import "../vendors/version-DsAuS9CR.js";
1
+ import "../vendors/version-y1_5EbED.js";
2
2
  import "../vendors/LocaleContext-CsTLO_Y2.js";
3
3
  import "../vendors/useLocale-3oUjPb-k.js";
4
4
  import { t as e } from "./Loading-Dm4i0lYd.js";
@@ -1,4 +1,4 @@
1
- import "../vendors/version-DsAuS9CR.js";
1
+ import "../vendors/version-y1_5EbED.js";
2
2
  import "../Icon/Icon-CcKDWNGy.js";
3
3
  import "../Overlay/OverlayContext-CVSFoyqN.js";
4
4
  import { t as e } from "./Modal-DXH8hz96.js";
@@ -1,3 +1,3 @@
1
- import "../vendors/version-DsAuS9CR.js";
1
+ import "../vendors/version-y1_5EbED.js";
2
2
  import { t as e } from "./NotFoundContent-DJUQ0_2D.js";
3
3
  export { e as NotFoundContent };
@@ -1,3 +1,3 @@
1
- import "../vendors/version-DsAuS9CR.js";
1
+ import "../vendors/version-y1_5EbED.js";
2
2
  import { a as e, i as t, n, t as r } from "./OverlayContext-CVSFoyqN.js";
3
3
  export { r as OVERLAY_Z_BASE, n as OVERLAY_Z_STEP, t as OverlayProvider, e as useOverlayZIndex };
@@ -1,3 +1,3 @@
1
- import "../vendors/version-DsAuS9CR.js";
1
+ import "../vendors/version-y1_5EbED.js";
2
2
  import { t as e } from "./Radio-C0OAW-K-.js";
3
3
  export { e as default };
@@ -1,4 +1,4 @@
1
- import "../vendors/version-DsAuS9CR.js";
1
+ import "../vendors/version-y1_5EbED.js";
2
2
  import "./style-D26azwz6.js";
3
3
  import { t as e } from "./ScrollBar-IMTuAOF5.js";
4
4
  export { e as ScrollBar, e as default };
@@ -1,3 +1,3 @@
1
- import "../vendors/version-DsAuS9CR.js";
1
+ import "../vendors/version-y1_5EbED.js";
2
2
  import { t as e } from "./Segmented-BMwjhsZw.js";
3
3
  export { e as default };
@@ -1,4 +1,4 @@
1
- import "../vendors/version-DsAuS9CR.js";
1
+ import "../vendors/version-y1_5EbED.js";
2
2
  import "../ScrollBar/style-D26azwz6.js";
3
3
  import "../Icon/Icon-CcKDWNGy.js";
4
4
  import "../vendors/LocaleContext-CsTLO_Y2.js";
@@ -1,4 +1,4 @@
1
- import "../vendors/version-DsAuS9CR.js";
1
+ import "../vendors/version-y1_5EbED.js";
2
2
  import "../ScrollBar/style-D26azwz6.js";
3
3
  import "../Icon/Icon-CcKDWNGy.js";
4
4
  import "../vendors/LocaleContext-CsTLO_Y2.js";
@@ -1,4 +1,4 @@
1
- import "../vendors/version-DsAuS9CR.js";
1
+ import "../vendors/version-y1_5EbED.js";
2
2
  import "../Icon/Icon-CcKDWNGy.js";
3
3
  import "../vendors/LocaleContext-CsTLO_Y2.js";
4
4
  import "../Overlay/OverlayContext-CVSFoyqN.js";
@@ -1,4 +1,4 @@
1
- import "../vendors/version-DsAuS9CR.js";
1
+ import "../vendors/version-y1_5EbED.js";
2
2
  import "../Overlay/OverlayContext-CVSFoyqN.js";
3
3
  import "../vendors/useLatchedPopupPortalRoot-CC6af8t-.js";
4
4
  import { n as e, t } from "./Tooltip-N06Os8rG.js";
@@ -1,4 +1,4 @@
1
- import "../vendors/version-DsAuS9CR.js";
1
+ import "../vendors/version-y1_5EbED.js";
2
2
  import "../Icon/Icon-CcKDWNGy.js";
3
3
  import { t as e } from "../vendors/Tree-f0FxoFIC.js";
4
4
  import "../CheckBox/CheckBox-DOdRLFKI.js";
@@ -1,14 +1,8 @@
1
- export { default, AiRuntimeContainer, toPlainProps } from './AiRuntimeContainer';
2
- export type { AiRuntimeContainerError, AiRuntimeContainerErrorCode, AiRuntimeContainerProps, } from './interface';
3
- /**
4
- * 纯函数一并导出:调用方需要在渲染之外复用同一套编译与校验规则,
5
- * 否则会各自维护副本,规则容易漂移。
6
- */
7
- export { compileAiCode, splitAiCode } from './parseSourceCode';
8
- export type { AiCodeParts, CompiledAiCode } from './parseSourceCode';
9
- export { validateFieldSource, assertFieldSource } from './validateFieldSource';
10
- export { scopeCss } from './scopeCss';
11
- export { compileCached, clearCompileCache } from './compileCache';
12
- export type { CompiledCacheEntry } from './compileCache';
13
- export { ERROR_CODE } from './execute';
14
- export { MODULE_NAMES } from './registry';
1
+ declare const AiRuntimeContainer: {
2
+ ({ code, value, disabled, readOnly, formData, tableMode, runToken, height, minHeight, className, style, onChange, onError, }: import('../../../../shared/src/ai-runtime/index.ts').AiRuntimeContainerProps): import("react").JSX.Element;
3
+ displayName: string;
4
+ };
5
+ export { AiRuntimeContainer };
6
+ export default AiRuntimeContainer;
7
+ export type { AiCodeParts, AiRuntimeContainerError, AiRuntimeContainerErrorCode, AiRuntimeContainerProps, CompiledAiCode, CompiledCacheEntry, } from '../../../../shared/src/ai-runtime/index.ts';
8
+ export { assertFieldSource, clearCompileCache, compileAiCode, compileCached, ERROR_CODE, MODULE_NAMES, scopeCss, splitAiCode, toPlainProps, validateFieldSource, } from '../../../../shared/src/ai-runtime/index.ts';
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import "./vendors/version-DsAuS9CR.js";
1
+ import "./vendors/version-y1_5EbED.js";
2
2
  import "./ScrollBar/style-D26azwz6.js";
3
3
  import { t as e } from "./Icon/Icon-CcKDWNGy.js";
4
4
  import "./vendors/LocaleContext-CsTLO_Y2.js";
@@ -29,8 +29,8 @@ import { t as O } from "./DropDown/DropDown-B3VFy5GF.js";
29
29
  import { t as k } from "./Loading/Loading-Dm4i0lYd.js";
30
30
  import "./NotFoundContent/index.js";
31
31
  import { t as A } from "./InputTag/InputTag-C1WA6sDA.js";
32
- import { t as j } from "./Calendar/Calendar-C5BesVb4.js";
33
- import { t as M } from "./DatePicker/DatePicker-CZTqH2SV.js";
32
+ import { t as j } from "./Calendar/Calendar-_-doXfR6.js";
33
+ import { t as M } from "./DatePicker/DatePicker-DeTo-7cE.js";
34
34
  import "./DatePicker/pickerLocale-Brf7_Tnd.js";
35
35
  import { a as N, c as P, d as F, f as I, g as L, h as R, i as z, l as B, m as V, n as H, o as U, p as W, r as G, t as K, u as q } from "./Table/Table-B8381Lni.js";
36
36
  import { t as J } from "./FieldCard/FieldCard-CCv4nLpH.js";
@@ -1,6 +1,6 @@
1
1
  //#region src/version.ts
2
2
  if (typeof window < "u") {
3
3
  let e = window.__BSY_UI__ ??= {};
4
- e["@baishuyun/ui-base"] = "6.30.0";
4
+ e["@baishuyun/ui-base"] = "6.31.0";
5
5
  }
6
6
  //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@baishuyun/ui-base",
3
- "version": "6.30.0",
3
+ "version": "6.31.0",
4
4
  "type": "module",
5
5
  "description": "百数云低代码平台通用组件库",
6
6
  "author": "bsy-fe team",
@@ -1,17 +0,0 @@
1
- import { AiRuntimeContainerProps } from './interface';
2
- type RuntimePropsSource = Pick<AiRuntimeContainerProps, 'value' | 'disabled' | 'formData' | 'tableMode'>;
3
- /** 容器只把这几个 props 交给用户组件,onChange 由容器注入。 */
4
- export declare const toPlainProps: (props: RuntimePropsSource | undefined, onChange: (next: string) => void) => Record<string, unknown>;
5
- /**
6
- * AI 代码运行时容器:编译、执行并渲染用户组件。
7
- *
8
- * 只做样式隔离,不是安全边界:用户代码与宿主同 realm,拿得到 window(见 execute.ts)。
9
- * 隔离只做到 shadow root:用户 CSS 写进 shadow 里的 <style>,容器之间、容器与宿主互不影响,
10
- * 宿主 CSS 自定义属性仍能继承进来。每个容器一个 React root,代价可控。
11
- * 失败一律表现为空白。
12
- */
13
- export declare const AiRuntimeContainer: {
14
- ({ code, value, disabled, formData, tableMode, runToken, height, minHeight, className, style, onChange, onError, }: AiRuntimeContainerProps): import("react").JSX.Element;
15
- displayName: string;
16
- };
17
- export default AiRuntimeContainer;
@@ -1,5 +0,0 @@
1
- /**
2
- * 校验 CSS 文本的语法。
3
- * 格式错误沿用 css-tree 的 codeframe,缺失属性值做行级拦截。
4
- */
5
- export declare function checkCssSyntax(source: string | null | undefined, filename?: string): void;
@@ -1,15 +0,0 @@
1
- /**
2
- * 编译结果缓存。同一页面可能同时挂载大量实例,每次挂载都重走 Babel 会造成主线程阻塞。
3
- * 同一份源码永远编出同一个结果,失败结果也缓存——否则坏代码每次重渲染都要重新抛错。
4
- *
5
- * 缓存键只有源码,filename 只影响报错里的文件名。
6
- */
7
- export interface CompiledCacheEntry {
8
- ok: boolean;
9
- code: string;
10
- css: string;
11
- error: Error | null;
12
- }
13
- export declare const compileCached: (code: unknown, filename?: string) => CompiledCacheEntry;
14
- /** 只给测试用。 */
15
- export declare const clearCompileCache: () => void;
@@ -1,33 +0,0 @@
1
- import { ComponentType } from 'react';
2
- import { AiRuntimeContainerError, AiRuntimeContainerErrorCode } from './interface';
3
- /** 4xx 是代码本身的问题,5xx 是运行时问题。 */
4
- export declare const ERROR_CODE: {
5
- /** Babel 语法/编译失败、静态检查不通过,message 带 codeframe */
6
- readonly COMPILE: 4001;
7
- /** 执行失败(没有 default export、模块不在白名单、模块顶层抛错) */
8
- readonly EXECUTE: 4002;
9
- /** 渲染失败,错误边界捕获 */
10
- readonly RENDER: 5001;
11
- /** 边界之外的异步错误(事件回调、promise) */
12
- readonly RUNTIME: 5002;
13
- };
14
- /**
15
- * 统一错误形态:非 Error 包一层,补上本容器的错误码。
16
- *
17
- * 不能只判断 `code == null`:Babel 抛出的错误自带 `code: 'BABEL_PARSE_ERROR'`,
18
- * 那样 4001 就永远落不上,调用方按错误码分流会失效。已经是我们自己的数字码时不再覆盖,
19
- * 避免同一次错误被下游改写成另一个阶段。
20
- */
21
- export declare const withCode: (value: unknown, code: AiRuntimeContainerErrorCode) => AiRuntimeContainerError;
22
- export type RuntimeComponent = ComponentType<Record<string, unknown>>;
23
- /** 每个容器实例一个脚本名,异步报错靠它回溯归属。 */
24
- export declare const nextScriptName: () => string;
25
- /**
26
- * 执行宿主编译好的 CommonJS 字符串,返回默认导出的组件。
27
- * body 在全局作用域执行、拿得到 window,这是宿主渲染的既定代价,隔离只能靠编译期检查。
28
- */
29
- export declare const executeComponent: (compiledCode: string, scriptName: string) => RuntimeComponent;
30
- export declare const markHandled: (error: unknown) => void;
31
- /** 栈里认不出归属的错误一律不接管,避免把宿主自身的报错算到容器头上。 */
32
- export declare const watchScript: (scriptName: string, onError: (error: AiRuntimeContainerError) => void) => void;
33
- export declare const unwatchScript: (scriptName: string) => void;
@@ -1,45 +0,0 @@
1
- import { CSSProperties } from 'react';
2
- /** 4xx 是代码本身的问题,5xx 是运行时问题。跨端共用,不要改数字。 */
3
- export type AiRuntimeContainerErrorCode =
4
- /** Babel 语法/编译失败、静态检查不通过,message 带 codeframe */
5
- 4001
6
- /** 执行失败(没有 default export、模块不在白名单、模块顶层抛错) */
7
- | 4002
8
- /** 渲染失败,错误边界捕获 */
9
- | 5001
10
- /** 边界之外的异步错误(事件回调、promise) */
11
- | 5002;
12
- export interface AiRuntimeContainerError extends Error {
13
- code: AiRuntimeContainerErrorCode;
14
- }
15
- export interface AiRuntimeContainerProps {
16
- /**
17
- * 用户组件源码,`<jsx>…</jsx><css>…</css>`。
18
- * 空字符串表示没有可渲染内容:容器不渲染,也不上报错误。
19
- */
20
- code: string;
21
- value?: string;
22
- disabled?: boolean;
23
- /** 宿主提供的只读数据快照,原样透传给用户组件。引用变化会触发一次重新渲染。 */
24
- formData?: Record<string, unknown>;
25
- /** 只透传给用户组件,容器自己不解释它。 */
26
- tableMode?: boolean;
27
- /**
28
- * 执行序号。变化时重新执行同一份源码(Babel 结果仍取自缓存),
29
- * 用于强制刷新当前渲染。
30
- */
31
- runToken?: string | number;
32
- /** 默认 `auto`:由内容撑开。需要撑满父容器时传入 `100%`。 */
33
- height?: number | string;
34
- /** 默认 `32`,避免空内容时容器塌成 0。 */
35
- minHeight?: number | string;
36
- className?: string;
37
- /** 覆盖默认容器样式(高度、滚动、contain 都在这里改)。 */
38
- style?: CSSProperties;
39
- onChange?: (next: string) => void;
40
- /**
41
- * 同一次执行只上报一次;`runToken` 变化才算新的一次。
42
- * 容器不负责呈现错误,失败一律表现为空白。
43
- */
44
- onError?: (error: AiRuntimeContainerError) => void;
45
- }
@@ -1,6 +0,0 @@
1
- /**
2
- * 用户代码允许 require 的模块名。registry 按这份清单建注册表,
3
- * 白名单和实现只有这一处来源。
4
- */
5
- export declare const ALLOWED_MODULE_NAMES: readonly ["react", "lucide-react"];
6
- export type AllowedModuleName = (typeof ALLOWED_MODULE_NAMES)[number];
@@ -1,22 +0,0 @@
1
- export interface AiCodeParts {
2
- jsx: string | null;
3
- css: string | null;
4
- }
5
- export interface CompiledAiCode {
6
- code: string;
7
- css: string;
8
- }
9
- /**
10
- * `code` 是一整段文本,`<jsx>` / `<css>` 只是其中的两个标签段。
11
- * 标签存在但内容为空(`<jsx></jsx>`)保留空字符串;标签不存在时返回 null。
12
- */
13
- export declare function splitAiCode(code: unknown): AiCodeParts | null;
14
- /**
15
- * 拆开整段源码,做静态检查并编译成 CommonJS 字符串。
16
- *
17
- * 编译在宿主完成,产物交给 executeComponent 执行;这里**不执行**用户代码。
18
- * 失败抛错,调用方据此清空内容并上报。
19
- *
20
- * @throws {Error} 没有可编译的段、CSS 语法错误、静态检查不通过、Babel 语法错误
21
- */
22
- export declare function compileAiCode(code: string, filename?: string): CompiledAiCode;
@@ -1,7 +0,0 @@
1
- import * as ReactNamespace from 'react';
2
- type CommonJsModule = Record<string, unknown>;
3
- /** classic JSX 会写出裸的 React.createElement,宿主得把它递进去。 */
4
- export declare const React: typeof ReactNamespace;
5
- export declare const MODULE_NAMES: string[];
6
- export declare const resolveModule: (name: string) => CommonJsModule;
7
- export {};
@@ -1,8 +0,0 @@
1
- /**
2
- * `:root` / `html` / `body` 在 shadow root 里匹配不到元素,整块区域的背景色、字号会静默失效,
3
- * 所以统一改写成 `:host`。
4
- *
5
- * 文本层面的近似改写,不是 CSS 解析:只改选择器位置,不碰声明块。
6
- * 已知边界:声明值里出现裸的 html / body(如 `font-family: body`)会被误改。
7
- */
8
- export declare const scopeCss: (css: unknown) => string;
@@ -1,6 +0,0 @@
1
- /**
2
- * 补一个 default export,供编译前的源码使用。
3
- * 模型经常只写 `function AmountField() {}`,Babel 转成 CommonJS 后 moduleExports.default 会是空的。
4
- * 已经有 default export 时原样返回。
5
- */
6
- export declare function withDefaultExport(source: string | null | undefined): string | null | undefined;
@@ -1,17 +0,0 @@
1
- /**
2
- * 在执行用户组件之前做静态检查:签名只含约定的 props、只能引入宿主注册过的模块、
3
- * 不发起网络请求、不使用 eval、不引入危险标签。
4
- *
5
- * 组件直接在宿主里渲染,这段检查是**尽力而为的写法约束,不是安全沙箱**:
6
- * 它挡得住随手写错,挡不住刻意绕过(Function 构造器已放开,
7
- * `new Function("return window")()` 就能出去)。这条链路上没有真正的隔离。
8
- * 语法错误不在此处报告,交给编译步骤输出 codeframe。
9
- *
10
- * @param jsxSource 已补全 default export 的源码
11
- * @returns 违规描述,空数组表示通过
12
- */
13
- export declare function validateFieldSource(jsxSource: string, cssSource?: string | null): string[];
14
- /**
15
- * @throws {Error} 存在违规时抛出,消息即要回传给模型的修正依据
16
- */
17
- export declare function assertFieldSource(jsxSource: string, cssSource?: string | null): void;
@@ -1,33 +0,0 @@
1
- /**
2
- * css-tree 3.x 不随包发布类型(package.json 没有 types / exports.types),
3
- * @types/css-tree 又是 2.x 的签名。这里只声明运行时用到的那部分 API。
4
- *
5
- * 声明不对外导出:消费方拿到的是本包的 dist 类型,不会看到这个文件。
6
- */
7
- declare module 'css-tree' {
8
- export interface CssTreeParseError {
9
- formattedMessage: string;
10
- }
11
-
12
- export interface CssTreeParseOptions {
13
- filename?: string;
14
- positions?: boolean;
15
- onParseError?: (error: CssTreeParseError) => void;
16
- }
17
-
18
- export interface CssTreeNode {
19
- type: string;
20
- property?: string;
21
- loc?: { start?: { line: number; column: number } };
22
- /** Declaration 的值;普通属性是 Value 节点,CSS 变量是 Raw 节点。 */
23
- value?: {
24
- type?: string;
25
- value?: string;
26
- children?: { head?: unknown };
27
- };
28
- }
29
-
30
- export function parse(source: string, options?: CssTreeParseOptions): CssTreeNode;
31
-
32
- export function walk(ast: CssTreeNode, visitor: (node: CssTreeNode) => void): void;
33
- }