@baishuyun/ui-mobile 0.20.1 → 0.22.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.
- package/dist/AMap/index.js +1 -1
- package/dist/ActionSheet/index.js +1 -1
- package/dist/AiRuntimeContainer/index.js +197 -153
- package/dist/Calendar/index.js +1 -1
- package/dist/ConfigProvider/index.js +1 -1
- package/dist/Editor/index.js +1 -1
- package/dist/FieldCard/index.js +1 -1
- package/dist/Gantt/index.js +1 -1
- package/dist/Icon/index.js +1 -1
- package/dist/Kanban/index.js +1 -1
- package/dist/Overlay/index.js +1 -1
- package/dist/Popup/index.js +1 -1
- package/dist/Segmented/index.js +1 -1
- package/dist/ai-runtime/AiRuntimeContainer.d.ts +4 -5
- package/dist/ai-runtime/compileCache.d.ts +2 -2
- package/dist/ai-runtime/interface.d.ts +4 -4
- package/dist/ai-runtime/moduleNames.d.ts +1 -1
- package/dist/ai-runtime/validateFieldSource.d.ts +1 -0
- package/dist/components/AiRuntimeContainer/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/vendors/{version-Dwc2amZV.js → version-DNBZk93g.js} +1 -1
- package/package.json +1 -1
package/dist/AMap/index.js
CHANGED
|
@@ -1,28 +1,34 @@
|
|
|
1
|
-
import "../vendors/version-
|
|
1
|
+
import "../vendors/version-DNBZk93g.js";
|
|
2
2
|
import * as e from "react";
|
|
3
3
|
import { Component as t, useCallback as n, useEffect as r, useLayoutEffect as i, useMemo as a, useRef as o } from "react";
|
|
4
|
-
import
|
|
4
|
+
import * as s from "react-dom";
|
|
5
|
+
import { jsx as c } from "react/jsx-runtime";
|
|
5
6
|
import { createRoot as ee } from "react-dom/client";
|
|
6
|
-
import * as
|
|
7
|
-
import { parse as
|
|
8
|
-
import * as
|
|
7
|
+
import * as l from "@babel/standalone";
|
|
8
|
+
import { parse as u, walk as d } from "css-tree";
|
|
9
|
+
import * as f from "lucide-react";
|
|
9
10
|
//#region ../shared/src/ai-runtime/moduleNames.ts
|
|
10
|
-
var
|
|
11
|
+
var p = [
|
|
12
|
+
"react",
|
|
13
|
+
"react-dom",
|
|
14
|
+
"lucide-react"
|
|
15
|
+
], m = new Set(p), h = p.join("、"), g = [
|
|
11
16
|
"value",
|
|
12
17
|
"onChange",
|
|
13
|
-
"onClick",
|
|
14
18
|
"disabled",
|
|
15
19
|
"readOnly",
|
|
16
20
|
"formData",
|
|
17
21
|
"env",
|
|
18
|
-
"widget"
|
|
19
|
-
|
|
22
|
+
"widget",
|
|
23
|
+
"onClick",
|
|
24
|
+
"onRequestOptions"
|
|
25
|
+
], _ = new Set([
|
|
20
26
|
"script",
|
|
21
27
|
"iframe",
|
|
22
28
|
"object",
|
|
23
29
|
"embed",
|
|
24
30
|
"link"
|
|
25
|
-
]),
|
|
31
|
+
]), v = new Set([
|
|
26
32
|
"loc",
|
|
27
33
|
"start",
|
|
28
34
|
"end",
|
|
@@ -31,73 +37,73 @@ var f = ["react", "lucide-react"], p = new Set(f), m = f.join("、"), h = [
|
|
|
31
37
|
"leadingComments",
|
|
32
38
|
"trailingComments",
|
|
33
39
|
"innerComments"
|
|
34
|
-
]),
|
|
35
|
-
function
|
|
40
|
+
]), y = /url\(\s*['"]?\s*(?:https?:)?\/\//i, b = (e) => e?.type === "FunctionDeclaration" || e?.type === "FunctionExpression" || e?.type === "ArrowFunctionExpression";
|
|
41
|
+
function x(e, t) {
|
|
36
42
|
if (!(!e || typeof e.type != "string") && t(e) !== !1) for (let n of Object.keys(e)) {
|
|
37
|
-
if (
|
|
43
|
+
if (v.has(n)) continue;
|
|
38
44
|
let r = e[n];
|
|
39
|
-
Array.isArray(r) ? r.forEach((e) =>
|
|
45
|
+
Array.isArray(r) ? r.forEach((e) => x(e, t)) : r && typeof r == "object" && x(r, t);
|
|
40
46
|
}
|
|
41
47
|
}
|
|
42
|
-
function
|
|
48
|
+
function S(e) {
|
|
43
49
|
let t = e.body.find((e) => e.type === "ExportDefaultDeclaration")?.declaration;
|
|
44
50
|
if (!t) return null;
|
|
45
|
-
if (
|
|
51
|
+
if (b(t)) return t;
|
|
46
52
|
if (t.type !== "Identifier") return null;
|
|
47
53
|
for (let n of e.body) {
|
|
48
54
|
if (n.type === "FunctionDeclaration" && n.id?.name === t.name) return n;
|
|
49
55
|
if (n.type === "VariableDeclaration") {
|
|
50
|
-
let e = n.declarations.find((e) => e.id?.name === t.name &&
|
|
56
|
+
let e = n.declarations.find((e) => e.id?.name === t.name && b(e.init));
|
|
51
57
|
if (e) return e.init;
|
|
52
58
|
}
|
|
53
59
|
}
|
|
54
60
|
return null;
|
|
55
61
|
}
|
|
56
|
-
var
|
|
57
|
-
function
|
|
62
|
+
var C = (e) => e.computed ? null : e.key.type === "Identifier" ? e.key.name : e.key.type === "StringLiteral" ? e.key.value : null;
|
|
63
|
+
function w(e, t, n) {
|
|
58
64
|
for (let r of e.properties) {
|
|
59
65
|
if (r.type === "RestElement") {
|
|
60
|
-
n.push(`组件不能用 ...rest 收集 props,请只解构 ${
|
|
66
|
+
n.push(`组件不能用 ...rest 收集 props,请只解构 ${g.join("、")}。`);
|
|
61
67
|
continue;
|
|
62
68
|
}
|
|
63
|
-
let e =
|
|
64
|
-
e === null ? n.push("组件的 props 不能使用计算属性名。") :
|
|
69
|
+
let e = C(r);
|
|
70
|
+
e === null ? n.push("组件的 props 不能使用计算属性名。") : g.includes(e) || t.add(e);
|
|
65
71
|
}
|
|
66
72
|
}
|
|
67
|
-
function
|
|
73
|
+
function T(e) {
|
|
68
74
|
let t = [], n = /* @__PURE__ */ new Set(), [r] = e.params;
|
|
69
|
-
return e.params.length > 1 && t.push("组件只接收一个 props 参数,不能有第二个参数(如 ref)。"), r?.type === "AssignmentPattern" && (r = r.left), r?.type === "ObjectPattern" ?
|
|
75
|
+
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" && x(e.body, (e) => {
|
|
70
76
|
if (e.type === "MemberExpression" && e.object?.name === r.name) {
|
|
71
77
|
let r = e.computed ? null : e.property.name;
|
|
72
|
-
return r === null ? t.push("组件不能用动态键读取 props。") :
|
|
78
|
+
return r === null ? t.push("组件不能用动态键读取 props。") : g.includes(r) || n.add(r), !1;
|
|
73
79
|
}
|
|
74
|
-
return e.type === "VariableDeclarator" && e.init?.name === r.name && e.id.type === "ObjectPattern" ? (
|
|
75
|
-
}), n.size && t.unshift(`组件签名只能接收 ${
|
|
80
|
+
return e.type === "VariableDeclarator" && e.init?.name === r.name && e.id.type === "ObjectPattern" ? (w(e.id, n, t), !1) : !0;
|
|
81
|
+
}), n.size && t.unshift(`组件签名只能接收 ${g.join("、")},发现多余的 props:${[...n].join("、")}。平台不会传入它们,请删除。`), t;
|
|
76
82
|
}
|
|
77
|
-
function
|
|
83
|
+
function E(e) {
|
|
78
84
|
let t = /* @__PURE__ */ new Set();
|
|
79
|
-
return
|
|
85
|
+
return x(e, (e) => {
|
|
80
86
|
switch (e.type) {
|
|
81
|
-
case "ImportDeclaration": return
|
|
87
|
+
case "ImportDeclaration": return m.has(e.source.value) || t.add(`import "${e.source.value}"(只能 import ${h})`), !1;
|
|
82
88
|
case "Import":
|
|
83
89
|
case "ImportExpression": return t.add("动态 import()"), !0;
|
|
84
90
|
case "JSXOpeningElement": {
|
|
85
91
|
let n = e.name?.name;
|
|
86
|
-
return
|
|
92
|
+
return _.has(n) && t.add(`<${n}>`), !0;
|
|
87
93
|
}
|
|
88
94
|
case "JSXAttribute": return e.name?.name === "dangerouslySetInnerHTML" && t.add("dangerouslySetInnerHTML"), !0;
|
|
89
95
|
default: return !0;
|
|
90
96
|
}
|
|
91
97
|
}), [...t];
|
|
92
98
|
}
|
|
93
|
-
function
|
|
99
|
+
function D(e) {
|
|
94
100
|
let t = [];
|
|
95
|
-
return /@import\b/i.test(e) && t.push("CSS 中不能使用 @import。"),
|
|
101
|
+
return /@import\b/i.test(e) && t.push("CSS 中不能使用 @import。"), y.test(e) && t.push("CSS 中不能引用外部地址,图片请用内联 svg 或 data: 地址。"), t;
|
|
96
102
|
}
|
|
97
|
-
function
|
|
103
|
+
function O(e, t = null) {
|
|
98
104
|
let n = [], r = null;
|
|
99
105
|
try {
|
|
100
|
-
r =
|
|
106
|
+
r = l.packages.parser.parse(e, {
|
|
101
107
|
sourceType: "module",
|
|
102
108
|
plugins: ["jsx"]
|
|
103
109
|
}).program;
|
|
@@ -105,21 +111,21 @@ function D(e, t = null) {
|
|
|
105
111
|
if (!(e instanceof SyntaxError)) throw e;
|
|
106
112
|
}
|
|
107
113
|
if (r) {
|
|
108
|
-
let e =
|
|
109
|
-
e && n.push(...
|
|
110
|
-
let t =
|
|
114
|
+
let e = S(r);
|
|
115
|
+
e && n.push(...T(e));
|
|
116
|
+
let t = E(r);
|
|
111
117
|
t.length && n.push(`不允许使用:${t.join("、")}。组件只能 import 宿主注册过的模块,也不能注入脚本和原始 HTML。`);
|
|
112
118
|
}
|
|
113
|
-
return t != null && n.push(...
|
|
119
|
+
return t != null && n.push(...D(t)), n;
|
|
114
120
|
}
|
|
115
|
-
function
|
|
116
|
-
let n =
|
|
121
|
+
function k(e, t = null) {
|
|
122
|
+
let n = O(e, t);
|
|
117
123
|
if (n.length) throw Error(`组件不符合运行时约束:\n${n.map((e) => `- ${e}`).join("\n")}`);
|
|
118
124
|
}
|
|
119
125
|
//#endregion
|
|
120
126
|
//#region ../shared/src/ai-runtime/checkCssSyntax.ts
|
|
121
|
-
function
|
|
122
|
-
e?.trim() && u(
|
|
127
|
+
function A(e, t = "style.css") {
|
|
128
|
+
e?.trim() && d(u(e, {
|
|
123
129
|
filename: t,
|
|
124
130
|
positions: !0,
|
|
125
131
|
onParseError(e) {
|
|
@@ -132,15 +138,15 @@ function k(e, t = "style.css") {
|
|
|
132
138
|
}
|
|
133
139
|
//#endregion
|
|
134
140
|
//#region ../shared/src/ai-runtime/sourceText.ts
|
|
135
|
-
var
|
|
136
|
-
function
|
|
137
|
-
if (!e ||
|
|
138
|
-
let t = e.match(
|
|
141
|
+
var j = /function\s+([A-Za-z_$][\w$]*)/, M = /export\s+default\b/;
|
|
142
|
+
function N(e) {
|
|
143
|
+
if (!e || M.test(e)) return e;
|
|
144
|
+
let t = e.match(j)?.[1];
|
|
139
145
|
return t ? `${e.trim()}\nexport default ${t};\n` : e;
|
|
140
146
|
}
|
|
141
147
|
//#endregion
|
|
142
148
|
//#region ../shared/src/ai-runtime/parseSourceCode.ts
|
|
143
|
-
var
|
|
149
|
+
var P = /<(jsx|css)>([\s\S]*?)<\/\1>/g, F = {
|
|
144
150
|
ast: !1,
|
|
145
151
|
sourceType: "module",
|
|
146
152
|
presets: [["react", {
|
|
@@ -149,10 +155,10 @@ var N = /<(jsx|css)>([\s\S]*?)<\/\1>/g, P = {
|
|
|
149
155
|
}]],
|
|
150
156
|
plugins: ["transform-modules-commonjs"]
|
|
151
157
|
};
|
|
152
|
-
function
|
|
158
|
+
function I(e) {
|
|
153
159
|
if (typeof e != "string" || !e.trim()) return null;
|
|
154
160
|
let t = null, n = null;
|
|
155
|
-
for (let r of e.matchAll(
|
|
161
|
+
for (let r of e.matchAll(P)) {
|
|
156
162
|
let e = r[2].trim();
|
|
157
163
|
r[1] === "jsx" && (t = e), r[1] === "css" && (n = e);
|
|
158
164
|
}
|
|
@@ -161,14 +167,14 @@ function F(e) {
|
|
|
161
167
|
css: n
|
|
162
168
|
};
|
|
163
169
|
}
|
|
164
|
-
var
|
|
165
|
-
function
|
|
166
|
-
let n =
|
|
170
|
+
var te = "export default function AiRuntimeField() {\n return null;\n}";
|
|
171
|
+
function ne(e, t = "ai") {
|
|
172
|
+
let n = I(e);
|
|
167
173
|
if (!n) throw Error("code 里没有可用的 <jsx> 或 <css>。");
|
|
168
|
-
let r =
|
|
169
|
-
i &&
|
|
170
|
-
let a =
|
|
171
|
-
...
|
|
174
|
+
let r = N(n.jsx || te), i = n.css ?? "";
|
|
175
|
+
i && A(i, `${t}.css`), k(r, i || null);
|
|
176
|
+
let a = l.transform(r, {
|
|
177
|
+
...F,
|
|
172
178
|
filename: `${t}.jsx`
|
|
173
179
|
});
|
|
174
180
|
if (!a?.code) throw Error("Babel 没有产出可执行的代码。");
|
|
@@ -179,152 +185,190 @@ function L(e, t = "ai") {
|
|
|
179
185
|
}
|
|
180
186
|
//#endregion
|
|
181
187
|
//#region ../shared/src/ai-runtime/compileCache.ts
|
|
182
|
-
var
|
|
188
|
+
var re = 200, L = /* @__PURE__ */ new Map(), ie = Object.freeze({
|
|
183
189
|
ok: !1,
|
|
184
190
|
code: "",
|
|
185
191
|
css: "",
|
|
186
192
|
error: null
|
|
187
|
-
}),
|
|
188
|
-
if (typeof e != "string" || !e.trim()) return
|
|
189
|
-
let n =
|
|
190
|
-
if (
|
|
191
|
-
let
|
|
193
|
+
}), R = (e, t) => {
|
|
194
|
+
if (typeof e != "string" || !e.trim()) return ie;
|
|
195
|
+
let n = e, r = L.get(n);
|
|
196
|
+
if (r) return L.delete(n), L.set(n, r), r;
|
|
197
|
+
let i;
|
|
192
198
|
try {
|
|
193
|
-
let n =
|
|
194
|
-
|
|
199
|
+
let n = ne(e, t);
|
|
200
|
+
i = {
|
|
195
201
|
ok: !0,
|
|
196
202
|
code: n.code,
|
|
197
203
|
css: n.css || "",
|
|
198
204
|
error: null
|
|
199
205
|
};
|
|
200
206
|
} catch (e) {
|
|
201
|
-
|
|
207
|
+
i = {
|
|
202
208
|
ok: !1,
|
|
203
209
|
code: "",
|
|
204
210
|
css: "",
|
|
205
211
|
error: e
|
|
206
212
|
};
|
|
207
213
|
}
|
|
208
|
-
if (
|
|
209
|
-
let e =
|
|
210
|
-
e !== void 0 &&
|
|
214
|
+
if (L.size >= re) {
|
|
215
|
+
let e = L.keys().next().value;
|
|
216
|
+
e !== void 0 && L.delete(e);
|
|
211
217
|
}
|
|
212
|
-
return
|
|
213
|
-
},
|
|
214
|
-
|
|
215
|
-
},
|
|
218
|
+
return L.set(n, i), i;
|
|
219
|
+
}, ae = () => {
|
|
220
|
+
L.clear();
|
|
221
|
+
}, z = (e, t) => {
|
|
216
222
|
let n = {};
|
|
217
223
|
for (let t of Object.keys(e)) n[t] = e[t];
|
|
218
224
|
return (n.default === void 0 || n.default === null) && (n.default = t), Object.defineProperty(n, "__esModule", { value: !0 }), n;
|
|
219
|
-
},
|
|
220
|
-
react:
|
|
221
|
-
"
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
+
}, B = e.default || e, oe = s.default || s, se = {
|
|
226
|
+
react: z(e, B),
|
|
227
|
+
"react-dom": z(s, oe),
|
|
228
|
+
"lucide-react": z(f, f)
|
|
229
|
+
}, V = {};
|
|
230
|
+
for (let e of p) {
|
|
231
|
+
let t = se[e];
|
|
225
232
|
if (!t) throw Error(`模块 ${e} 在白名单里但没有实现。`);
|
|
226
|
-
|
|
233
|
+
V[e] = t;
|
|
227
234
|
}
|
|
228
|
-
var
|
|
229
|
-
let t =
|
|
235
|
+
var H = Object.keys(V), ce = (e) => {
|
|
236
|
+
let t = V[e];
|
|
230
237
|
if (t) return t;
|
|
231
|
-
throw Error(`Unknown module: ${e}(组件只能 require ${
|
|
232
|
-
},
|
|
238
|
+
throw Error(`Unknown module: ${e}(组件只能 require ${H.join("、")})`);
|
|
239
|
+
}, U = {
|
|
233
240
|
COMPILE: 4001,
|
|
234
241
|
EXECUTE: 4002,
|
|
235
242
|
RENDER: 5001,
|
|
236
243
|
RUNTIME: 5002
|
|
237
|
-
},
|
|
244
|
+
}, le = new Set(Object.values(U)), W = (e, t) => {
|
|
238
245
|
let n = e instanceof Error ? e : Error(String(e)), r = n.code;
|
|
239
|
-
return (typeof r != "number" || !
|
|
240
|
-
},
|
|
246
|
+
return (typeof r != "number" || !le.has(r)) && (n.code = t), n;
|
|
247
|
+
}, G = 0, ue = (e) => (G += 1, `ai-runtime-${e}-${G}.js`), de = (e, t) => {
|
|
241
248
|
if (!e) throw Error("没有可执行的代码。");
|
|
242
249
|
let n = {}, r = `${e}\n//# sourceURL=${t}`;
|
|
243
|
-
if (Function("require", "exports", "React", r)(
|
|
250
|
+
if (Function("require", "exports", "React", r)(ce, n, B), typeof n.default != "function") throw Error("Missing default export:组件必须默认导出一个函数。");
|
|
244
251
|
return n.default;
|
|
245
|
-
},
|
|
246
|
-
e && typeof e == "object" &&
|
|
247
|
-
},
|
|
248
|
-
if (e && typeof e == "object" &&
|
|
252
|
+
}, K = /* @__PURE__ */ new Map(), q = !1, J = /* @__PURE__ */ new WeakSet(), fe = (e) => {
|
|
253
|
+
e && typeof e == "object" && J.add(e);
|
|
254
|
+
}, Y = (e) => {
|
|
255
|
+
if (e && typeof e == "object" && J.has(e)) return;
|
|
249
256
|
let t = e instanceof Error ? e.stack : void 0;
|
|
250
257
|
if (typeof t == "string") {
|
|
251
|
-
for (let [n, r] of
|
|
252
|
-
r(
|
|
258
|
+
for (let [n, r] of K) if (t.includes(n)) {
|
|
259
|
+
r(W(e, U.RUNTIME));
|
|
253
260
|
return;
|
|
254
261
|
}
|
|
255
262
|
}
|
|
256
|
-
},
|
|
257
|
-
|
|
263
|
+
}, pe = () => {
|
|
264
|
+
q || typeof window > "u" || (q = !0, window.addEventListener("error", (e) => {
|
|
258
265
|
let t = e.error || Error(e.message);
|
|
259
|
-
queueMicrotask(() =>
|
|
266
|
+
queueMicrotask(() => Y(t));
|
|
260
267
|
}), window.addEventListener("unhandledrejection", (e) => {
|
|
261
268
|
let t = e.reason;
|
|
262
|
-
queueMicrotask(() =>
|
|
269
|
+
queueMicrotask(() => Y(t));
|
|
263
270
|
}));
|
|
264
|
-
},
|
|
265
|
-
|
|
266
|
-
},
|
|
267
|
-
|
|
268
|
-
},
|
|
271
|
+
}, me = (e, t) => {
|
|
272
|
+
pe(), K.set(e, t);
|
|
273
|
+
}, he = (e) => {
|
|
274
|
+
K.delete(e);
|
|
275
|
+
}, ge = /(^|[\s,>+~(])(?::root\b|html\b|body\b)/gi, X = (e) => typeof e != "string" || !e ? "" : e.replace(ge, "$1:host"), _e = typeof window > "u" ? r : i, ve = class extends t {
|
|
269
276
|
state = { failed: !1 };
|
|
270
277
|
static getDerivedStateFromError() {
|
|
271
278
|
return { failed: !0 };
|
|
272
279
|
}
|
|
273
280
|
componentDidCatch(e) {
|
|
274
|
-
|
|
281
|
+
fe(e), this.props.onError(W(e, U.RENDER));
|
|
275
282
|
}
|
|
276
283
|
render() {
|
|
277
284
|
return this.state.failed ? null : this.props.children;
|
|
278
285
|
}
|
|
279
|
-
},
|
|
286
|
+
}, ye = new Set([
|
|
280
287
|
"form",
|
|
281
288
|
"table",
|
|
282
289
|
"card"
|
|
283
|
-
]),
|
|
284
|
-
view:
|
|
290
|
+
]), be = (e) => ({
|
|
291
|
+
view: ye.has(e?.view) ? e?.view : "form",
|
|
285
292
|
platform: e?.platform === "mobile" ? "mobile" : "pc"
|
|
286
|
-
}),
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
+
}), Z = new Set([
|
|
294
|
+
"code",
|
|
295
|
+
"runToken",
|
|
296
|
+
"height",
|
|
297
|
+
"minHeight",
|
|
298
|
+
"className",
|
|
299
|
+
"style",
|
|
300
|
+
"onError",
|
|
301
|
+
"value",
|
|
302
|
+
"disabled",
|
|
303
|
+
"readOnly",
|
|
304
|
+
"formData",
|
|
305
|
+
"env",
|
|
306
|
+
"onChange",
|
|
307
|
+
"widget"
|
|
308
|
+
]), Q = (e, t) => {
|
|
309
|
+
let n = e ?? {}, r = {
|
|
310
|
+
value: n.value ?? "",
|
|
311
|
+
disabled: !!n.disabled,
|
|
312
|
+
readOnly: !!n.readOnly,
|
|
313
|
+
formData: n.formData || {},
|
|
314
|
+
env: be(n.env),
|
|
293
315
|
onChange: t
|
|
294
316
|
};
|
|
295
|
-
|
|
296
|
-
|
|
317
|
+
for (let e of Object.keys(n)) {
|
|
318
|
+
let t = n[e];
|
|
319
|
+
t === void 0 || Z.has(e) || (r[e] = t);
|
|
320
|
+
}
|
|
321
|
+
return n.widget && (r.widget = n.widget), r;
|
|
322
|
+
}, xe = (e) => {
|
|
323
|
+
let t = Object.keys(e).sort(), n = "";
|
|
324
|
+
for (let r of t) {
|
|
325
|
+
let t = e[r];
|
|
326
|
+
typeof t == "function" ? n += `${r}:fn\0` : t !== void 0 && (typeof t != "object" || !t) && (n += `${r}:${String(t)}\0`);
|
|
327
|
+
}
|
|
328
|
+
return n;
|
|
329
|
+
}, Se = (e, t) => {
|
|
330
|
+
let n = {};
|
|
331
|
+
for (let r of Object.keys(e)) {
|
|
332
|
+
let i = e[r];
|
|
333
|
+
i === void 0 || Z.has(r) || (typeof i == "function" ? n[r] = (...e) => {
|
|
334
|
+
let n = t()[r];
|
|
335
|
+
return typeof n == "function" ? n(...e) : void 0;
|
|
336
|
+
} : n[r] = i);
|
|
337
|
+
}
|
|
338
|
+
return n;
|
|
339
|
+
}, Ce = {
|
|
297
340
|
ok: !1,
|
|
298
341
|
error: null,
|
|
299
342
|
Component: null
|
|
300
343
|
};
|
|
301
|
-
function
|
|
302
|
-
let t = ({ code: t, value: i, disabled:
|
|
344
|
+
function we(e) {
|
|
345
|
+
let t = ({ code: t, value: i, disabled: s, readOnly: l, formData: u, env: d, widget: f, runToken: p, height: m, minHeight: h, className: g, style: _, onChange: v, onError: y, ...b }) => {
|
|
303
346
|
let x = o(null), S = o(null), C = o(null), w = o({});
|
|
304
347
|
w.current = {
|
|
305
348
|
onChange: v,
|
|
306
|
-
|
|
307
|
-
onError: b
|
|
349
|
+
onError: y
|
|
308
350
|
};
|
|
309
|
-
let T = o(
|
|
310
|
-
T.current
|
|
311
|
-
let E =
|
|
351
|
+
let T = o(b);
|
|
352
|
+
T.current = b;
|
|
353
|
+
let E = o(null);
|
|
354
|
+
E.current === null && (E.current = ue(e));
|
|
355
|
+
let D = E.current, O = R(t), k = o({
|
|
312
356
|
source: void 0,
|
|
313
357
|
token: void 0,
|
|
314
|
-
result:
|
|
358
|
+
result: Ce
|
|
315
359
|
});
|
|
316
|
-
if (
|
|
360
|
+
if (k.current.source !== t || k.current.token !== p) {
|
|
317
361
|
let e;
|
|
318
|
-
if (!
|
|
362
|
+
if (!O.ok) e = {
|
|
319
363
|
ok: !1,
|
|
320
|
-
error:
|
|
364
|
+
error: O.error,
|
|
321
365
|
Component: null
|
|
322
366
|
};
|
|
323
367
|
else try {
|
|
324
368
|
e = {
|
|
325
369
|
ok: !0,
|
|
326
370
|
error: null,
|
|
327
|
-
Component:
|
|
371
|
+
Component: de(O.code, D)
|
|
328
372
|
};
|
|
329
373
|
} catch (t) {
|
|
330
374
|
e = {
|
|
@@ -333,76 +377,76 @@ function ye(e) {
|
|
|
333
377
|
Component: null
|
|
334
378
|
};
|
|
335
379
|
}
|
|
336
|
-
|
|
380
|
+
k.current = {
|
|
337
381
|
source: t,
|
|
338
382
|
token: p,
|
|
339
383
|
result: e
|
|
340
384
|
};
|
|
341
385
|
}
|
|
342
|
-
let
|
|
386
|
+
let A = k.current.result, j = n((e) => w.current.onChange?.(e), []), M = a(() => Se(T.current, () => T.current), [xe(b)]), N = n((e) => w.current.onError?.(e), []), P = n(() => {
|
|
343
387
|
if (S.current) return S.current;
|
|
344
388
|
let e = x.current;
|
|
345
389
|
if (!e) return null;
|
|
346
390
|
let t = e.shadowRoot || e.attachShadow({ mode: "open" }), n = document.createElement("style"), r = document.createElement("div");
|
|
347
391
|
return r.setAttribute("data-ai-runtime-mount", ""), r.style.height = "100%", t.append(n, r), S.current = {
|
|
348
|
-
root: ee(r, { onUncaughtError: (e) => w.current.onError?.(
|
|
392
|
+
root: ee(r, { onUncaughtError: (e) => w.current.onError?.(W(e, U.RUNTIME)) }),
|
|
349
393
|
styleEl: n,
|
|
350
394
|
mountEl: r
|
|
351
395
|
}, S.current;
|
|
352
396
|
}, []), F = a(() => Q({
|
|
353
397
|
value: i,
|
|
354
|
-
disabled:
|
|
398
|
+
disabled: s,
|
|
355
399
|
readOnly: l,
|
|
356
400
|
formData: u,
|
|
357
401
|
env: d,
|
|
358
|
-
widget: f
|
|
359
|
-
|
|
402
|
+
widget: f,
|
|
403
|
+
...M
|
|
404
|
+
}, j), [
|
|
360
405
|
i,
|
|
361
|
-
|
|
406
|
+
s,
|
|
362
407
|
l,
|
|
363
408
|
u,
|
|
364
409
|
d,
|
|
365
410
|
f,
|
|
366
|
-
|
|
367
|
-
M
|
|
368
|
-
j
|
|
411
|
+
j,
|
|
412
|
+
M
|
|
369
413
|
]);
|
|
370
|
-
|
|
414
|
+
_e(() => {
|
|
371
415
|
let e = P();
|
|
372
416
|
if (!e) return;
|
|
373
417
|
let { root: t, styleEl: n } = e;
|
|
374
|
-
if (!
|
|
375
|
-
if (C.current !==
|
|
376
|
-
let e =
|
|
377
|
-
w.current.onError?.(
|
|
418
|
+
if (!A.ok) {
|
|
419
|
+
if (C.current !== A && (C.current = A, n.textContent = "", t.render(null), A.error)) {
|
|
420
|
+
let e = O.ok ? U.EXECUTE : U.COMPILE;
|
|
421
|
+
w.current.onError?.(W(A.error, e));
|
|
378
422
|
}
|
|
379
423
|
return;
|
|
380
424
|
}
|
|
381
425
|
C.current = null;
|
|
382
|
-
let r =
|
|
426
|
+
let r = X(O.css);
|
|
383
427
|
n.textContent !== r && (n.textContent = r);
|
|
384
|
-
let i =
|
|
385
|
-
t.render(/* @__PURE__ */
|
|
428
|
+
let i = A.Component;
|
|
429
|
+
t.render(/* @__PURE__ */ c(ve, {
|
|
386
430
|
onError: N,
|
|
387
|
-
children: /* @__PURE__ */
|
|
431
|
+
children: /* @__PURE__ */ c(i, { ...F })
|
|
388
432
|
}));
|
|
389
433
|
}, [
|
|
390
|
-
|
|
391
|
-
|
|
434
|
+
O,
|
|
435
|
+
A,
|
|
392
436
|
F,
|
|
393
437
|
N,
|
|
394
438
|
P
|
|
395
439
|
]), r(() => () => {
|
|
396
440
|
let e = S.current;
|
|
397
441
|
S.current = null, e && (e.styleEl.remove(), e.mountEl.remove(), queueMicrotask(() => e.root.unmount()));
|
|
398
|
-
}, []), r(() => (
|
|
442
|
+
}, []), r(() => (me(D, (e) => w.current.onError?.(e)), () => he(D)), [D]);
|
|
399
443
|
let I = {
|
|
400
444
|
height: m ?? "auto",
|
|
401
445
|
minHeight: h ?? 32,
|
|
402
446
|
contain: "layout paint",
|
|
403
447
|
..._
|
|
404
448
|
};
|
|
405
|
-
return /* @__PURE__ */
|
|
449
|
+
return /* @__PURE__ */ c("div", {
|
|
406
450
|
ref: x,
|
|
407
451
|
"data-ai-runtime-host": "",
|
|
408
452
|
className: g,
|
|
@@ -413,6 +457,6 @@ function ye(e) {
|
|
|
413
457
|
}
|
|
414
458
|
//#endregion
|
|
415
459
|
//#region src/components/AiRuntimeContainer/index.ts
|
|
416
|
-
var $ =
|
|
460
|
+
var $ = we("ui-mobile");
|
|
417
461
|
//#endregion
|
|
418
|
-
export { $ as AiRuntimeContainer, $ as default,
|
|
462
|
+
export { $ as AiRuntimeContainer, $ as default, U as ERROR_CODE, H as MODULE_NAMES, k as assertFieldSource, ae as clearCompileCache, ne as compileAiCode, R as compileCached, X as scopeCss, I as splitAiCode, Q as toPlainProps, O as validateFieldSource };
|
package/dist/Calendar/index.js
CHANGED
package/dist/Editor/index.js
CHANGED
package/dist/FieldCard/index.js
CHANGED
package/dist/Gantt/index.js
CHANGED
package/dist/Icon/index.js
CHANGED
package/dist/Kanban/index.js
CHANGED
package/dist/Overlay/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import "../vendors/version-
|
|
1
|
+
import "../vendors/version-DNBZk93g.js";
|
|
2
2
|
import { a as e, i as t, n, o as r, r as i, t as a } from "./Overlay-DFiZYsBs.js";
|
|
3
3
|
export { a as OVERLAY_Z_BASE, n as OVERLAY_Z_STEP, i as OverlayProvider, t as getNextImperativeOverlayZIndex, e as imperativeOverlayStyle, r as useOverlayZIndex };
|
package/dist/Popup/index.js
CHANGED
package/dist/Segmented/index.js
CHANGED
|
@@ -3,11 +3,10 @@ type RuntimePropsSource = Pick<AiRuntimeContainerProps, 'value' | 'disabled' | '
|
|
|
3
3
|
/** 缺省是 pc 端表单。 */
|
|
4
4
|
export declare const normalizeFieldEnv: (env: AiRuntimeContainerProps["env"]) => FieldEnv;
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* widget 没传时不放进 props。
|
|
6
|
+
* 壳子只转发。共有的值在这里补缺省,其余平级 props 原样附上。
|
|
7
|
+
* 壳子自己的参数、以及值为 undefined 的项,不放进组件 props。
|
|
9
8
|
*/
|
|
10
|
-
export declare const toPlainProps: (props: RuntimePropsSource | undefined, onChange: (next: string) => void
|
|
9
|
+
export declare const toPlainProps: (props: (RuntimePropsSource & Record<string, unknown>) | undefined, onChange: (next: string) => void) => Record<string, unknown>;
|
|
11
10
|
/**
|
|
12
11
|
* AI 代码运行时容器:编译、执行并渲染用户组件。
|
|
13
12
|
*
|
|
@@ -17,7 +16,7 @@ export declare const toPlainProps: (props: RuntimePropsSource | undefined, onCha
|
|
|
17
16
|
* 失败一律表现为空白。
|
|
18
17
|
*/
|
|
19
18
|
export declare function createAiRuntimeContainer(scriptPrefix: string): {
|
|
20
|
-
({ code, value, disabled, readOnly, formData, env, widget, runToken, height, minHeight, className, style, onChange,
|
|
19
|
+
({ code, value, disabled, readOnly, formData, env, widget, runToken, height, minHeight, className, style, onChange, onError, ...rest }: AiRuntimeContainerProps): import("react").JSX.Element;
|
|
21
20
|
displayName: string;
|
|
22
21
|
};
|
|
23
22
|
export {};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 编译结果缓存。同一页面可能同时挂载大量实例,每次挂载都重走 Babel 会造成主线程阻塞。
|
|
3
|
-
*
|
|
3
|
+
* 同一份源码编出同一个结果。失败结果也缓存——否则坏代码每次重渲染都要重新抛错。
|
|
4
4
|
*
|
|
5
|
-
*
|
|
5
|
+
* filename 只影响报错里的文件名,不进缓存键。
|
|
6
6
|
*/
|
|
7
7
|
export interface CompiledCacheEntry {
|
|
8
8
|
ok: boolean;
|
|
@@ -47,13 +47,13 @@ export interface AiRuntimeContainerProps {
|
|
|
47
47
|
/** 覆盖默认容器样式(高度、滚动、contain 都在这里改)。 */
|
|
48
48
|
style?: CSSProperties;
|
|
49
49
|
onChange?: (next: string) => void;
|
|
50
|
-
/**
|
|
51
|
-
* 暂时为扩展按钮专用。生成的组件在点击时调用它,不传参数
|
|
52
|
-
*/
|
|
53
|
-
onClick?: () => void;
|
|
54
50
|
/**
|
|
55
51
|
* 同一次执行只上报一次;`runToken` 变化才算新的一次。
|
|
56
52
|
* 容器不负责呈现错误,失败一律表现为空白。
|
|
57
53
|
*/
|
|
58
54
|
onError?: (error: AiRuntimeContainerError) => void;
|
|
55
|
+
/**
|
|
56
|
+
* 字段自己的 props,和 value、onChange 平级传入。壳子不解释这些名字,原样转发给组件。
|
|
57
|
+
*/
|
|
58
|
+
[key: string]: unknown;
|
|
59
59
|
}
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
* 用户代码允许 require 的模块名。registry 按这份清单建注册表,
|
|
3
3
|
* 白名单和实现只有这一处来源。
|
|
4
4
|
*/
|
|
5
|
-
export declare const ALLOWED_MODULE_NAMES: readonly ["react", "lucide-react"];
|
|
5
|
+
export declare const ALLOWED_MODULE_NAMES: readonly ["react", "react-dom", "lucide-react"];
|
|
6
6
|
export type AllowedModuleName = (typeof ALLOWED_MODULE_NAMES)[number];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
declare const AiRuntimeContainer: {
|
|
2
|
-
({ code, value, disabled, readOnly, formData, env, widget, runToken, height, minHeight, className, style, onChange,
|
|
2
|
+
({ code, value, disabled, readOnly, formData, env, widget, runToken, height, minHeight, className, style, onChange, onError, ...rest }: import('../../ai-runtime/index').AiRuntimeContainerProps): import("react").JSX.Element;
|
|
3
3
|
displayName: string;
|
|
4
4
|
};
|
|
5
5
|
export { AiRuntimeContainer };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./vendors/version-
|
|
1
|
+
import "./vendors/version-DNBZk93g.js";
|
|
2
2
|
import { a as e, i as t, n, o as r, r as i, t as a } from "./Overlay/Overlay-DFiZYsBs.js";
|
|
3
3
|
import { t as o } from "./ConfigProvider/useLocale-DiKogqPs.js";
|
|
4
4
|
import { t as s } from "./Popup/Popup-Cg3t422z.js";
|