@burdenoff/fe-libs 2026.1027.5 → 2026.1027.7
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/_virtual/_rolldown/runtime.js +2 -5
- package/dist/chrome/MobileTabBar.d.ts +9 -1
- package/dist/chrome/MobileTabBar.js +70 -70
- package/dist/node_modules/@openuidev/devtools/dist/index.js +34 -35
- package/dist/node_modules/@openuidev/lang-core/dist/index.js +826 -828
- package/dist/node_modules/@openuidev/react-lang/dist/index.js +6 -7
- package/dist/shared/assistant/openui/library.js +73 -73
- package/package.json +1 -1
- package/src/shared/styles/native.css +17 -0
- package/dist/node_modules/react-dom/cjs/react-dom-client.development.js +0 -11168
- package/dist/node_modules/react-dom/cjs/react-dom-client.production.js +0 -7384
- package/dist/node_modules/react-dom/client.js +0 -19
- package/dist/node_modules/scheduler/cjs/scheduler.development.js +0 -203
- package/dist/node_modules/scheduler/cjs/scheduler.production.js +0 -203
- package/dist/node_modules/scheduler/index.js +0 -10
- package/dist/node_modules/zod/v4/classic/errors.js +0 -23
- package/dist/node_modules/zod/v4/classic/iso.js +0 -31
- package/dist/node_modules/zod/v4/classic/parse.js +0 -6
- package/dist/node_modules/zod/v4/classic/schemas.js +0 -339
- package/dist/node_modules/zod/v4/core/api.js +0 -491
- package/dist/node_modules/zod/v4/core/checks.js +0 -283
- package/dist/node_modules/zod/v4/core/core.js +0 -44
- package/dist/node_modules/zod/v4/core/doc.js +0 -23
- package/dist/node_modules/zod/v4/core/errors.js +0 -41
- package/dist/node_modules/zod/v4/core/json-schema-processors.js +0 -306
- package/dist/node_modules/zod/v4/core/parse.js +0 -68
- package/dist/node_modules/zod/v4/core/regexes.js +0 -25
- package/dist/node_modules/zod/v4/core/registries.js +0 -40
- package/dist/node_modules/zod/v4/core/schemas.js +0 -796
- package/dist/node_modules/zod/v4/core/to-json-schema.js +0 -222
- package/dist/node_modules/zod/v4/core/util.js +0 -266
- package/dist/node_modules/zod/v4/core/versions.js +0 -8
|
@@ -1,152 +1,150 @@
|
|
|
1
1
|
import { __toESM as e } from "../../../../_virtual/_rolldown/runtime.js";
|
|
2
2
|
import { TELEMETRY_REQUEST_TIMEOUT_MS as t, getPostHogConfig as n, isRuntimeTelemetryEnabled as r, normalizeProjectIdentity as i } from "./shared-Dzgc28Wo.js";
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import { toJSONSchema as l } from "../../../zod/v4/core/json-schema-processors.js";
|
|
6
|
-
import { _enum as u, any as d, array as f, literal as p, number as m, object as h, record as g, string as _, union as v } from "../../../zod/v4/classic/schemas.js";
|
|
3
|
+
import { literal as a, object as o, z as s } from "zod/v4";
|
|
4
|
+
import * as c from "zod/v4/core";
|
|
7
5
|
//#region node_modules/@openuidev/lang-core/dist/index.mjs
|
|
8
|
-
var
|
|
9
|
-
function
|
|
10
|
-
|
|
6
|
+
var l = /* @__PURE__ */ new WeakSet();
|
|
7
|
+
function u(e) {
|
|
8
|
+
l.add(e);
|
|
11
9
|
}
|
|
12
|
-
function
|
|
13
|
-
return typeof e == "object" && !!e &&
|
|
10
|
+
function d(e) {
|
|
11
|
+
return typeof e == "object" && !!e && l.has(e);
|
|
14
12
|
}
|
|
15
|
-
var
|
|
16
|
-
function
|
|
17
|
-
|
|
13
|
+
var f = /* @__PURE__ */ new WeakMap();
|
|
14
|
+
function p(e, t) {
|
|
15
|
+
f.set(e, t);
|
|
18
16
|
}
|
|
19
|
-
var
|
|
20
|
-
function
|
|
21
|
-
return
|
|
17
|
+
var m = /* @__PURE__ */ new WeakMap();
|
|
18
|
+
function h(e, t) {
|
|
19
|
+
return m.set(t, e), t;
|
|
22
20
|
}
|
|
23
|
-
function
|
|
24
|
-
let n =
|
|
25
|
-
n &&
|
|
26
|
-
let r =
|
|
27
|
-
r &&
|
|
21
|
+
function g(e, t) {
|
|
22
|
+
let n = f.get(e);
|
|
23
|
+
n && f.set(t, n);
|
|
24
|
+
let r = m.get(e);
|
|
25
|
+
r && m.set(t, r);
|
|
28
26
|
}
|
|
29
|
-
function
|
|
27
|
+
function _(e, t) {
|
|
30
28
|
if (typeof e == "object" && e && "_def" in e && !("_zod" in e)) throw Error(`[OpenUI] Component "${t}" was defined with a Zod 3 schema. OpenUI requires Zod 4 schemas. If you're on zod@3.25+, import from "zod/v4" instead of "zod". See: https://zod.dev/v4/versioning`);
|
|
31
29
|
}
|
|
32
|
-
function
|
|
30
|
+
function v(e) {
|
|
33
31
|
return e?._zod?.def;
|
|
34
32
|
}
|
|
35
|
-
function
|
|
36
|
-
return
|
|
33
|
+
function y(e) {
|
|
34
|
+
return v(e)?.type;
|
|
37
35
|
}
|
|
38
|
-
function
|
|
39
|
-
let t =
|
|
36
|
+
function ee(e) {
|
|
37
|
+
let t = y(e);
|
|
40
38
|
return t === "optional" || t === "default" || t === "nullable";
|
|
41
39
|
}
|
|
42
|
-
function
|
|
43
|
-
let t = e, n =
|
|
44
|
-
for (; n?.type === "optional" || n?.type === "default" || n?.type === "nullable";) t = n.innerType, n =
|
|
40
|
+
function b(e) {
|
|
41
|
+
let t = e, n = v(t);
|
|
42
|
+
for (; n?.type === "optional" || n?.type === "default" || n?.type === "nullable";) t = n.innerType, n = v(t);
|
|
45
43
|
return t;
|
|
46
44
|
}
|
|
47
|
-
function
|
|
48
|
-
return
|
|
45
|
+
function te(e) {
|
|
46
|
+
return y(b(e)) === "array";
|
|
49
47
|
}
|
|
50
|
-
function
|
|
51
|
-
let t =
|
|
48
|
+
function ne(e) {
|
|
49
|
+
let t = v(b(e));
|
|
52
50
|
if (t?.type === "array") return t.element ?? t.innerType;
|
|
53
51
|
}
|
|
54
|
-
function
|
|
55
|
-
let t =
|
|
52
|
+
function re(e) {
|
|
53
|
+
let t = v(b(e));
|
|
56
54
|
if (t?.type === "enum") {
|
|
57
55
|
if (Array.isArray(t.values)) return t.values;
|
|
58
56
|
if (t.entries && typeof t.entries == "object") return Object.keys(t.entries);
|
|
59
57
|
}
|
|
60
58
|
}
|
|
61
|
-
function
|
|
59
|
+
function ie(e, t) {
|
|
62
60
|
try {
|
|
63
61
|
let n = t?.get(e);
|
|
64
62
|
if (n?.id) return n.id;
|
|
65
63
|
} catch {}
|
|
66
|
-
if (typeof e == "object" && e) return
|
|
64
|
+
if (typeof e == "object" && e) return f.get(e);
|
|
67
65
|
}
|
|
68
|
-
function
|
|
69
|
-
let t =
|
|
66
|
+
function x(e) {
|
|
67
|
+
let t = v(e);
|
|
70
68
|
if (t?.type === "union" && Array.isArray(t.options)) return t.options;
|
|
71
69
|
}
|
|
72
|
-
function
|
|
73
|
-
let t =
|
|
70
|
+
function ae(e) {
|
|
71
|
+
let t = v(e);
|
|
74
72
|
if (t?.type === "object" && t.shape && typeof t.shape == "object") return t.shape;
|
|
75
73
|
}
|
|
76
|
-
function
|
|
77
|
-
let n =
|
|
74
|
+
function S(e, t) {
|
|
75
|
+
let n = d(e), r = oe(b(e), t);
|
|
78
76
|
if (r) return n ? `$binding<${r}>` : r;
|
|
79
77
|
}
|
|
80
|
-
function
|
|
81
|
-
let n = typeof e == "object" && !!e &&
|
|
78
|
+
function oe(e, t) {
|
|
79
|
+
let n = typeof e == "object" && !!e && m.get(e);
|
|
82
80
|
if (n) return `@${n}`;
|
|
83
|
-
let r =
|
|
81
|
+
let r = ie(e, t);
|
|
84
82
|
if (r) return r;
|
|
85
|
-
let i =
|
|
83
|
+
let i = x(e);
|
|
86
84
|
if (i) {
|
|
87
|
-
let e = i.map((e) =>
|
|
85
|
+
let e = i.map((e) => S(e, t)).filter(Boolean);
|
|
88
86
|
if (e.length > 0) return e.join(" | ");
|
|
89
87
|
}
|
|
90
|
-
if (
|
|
91
|
-
let n =
|
|
88
|
+
if (te(e)) {
|
|
89
|
+
let n = ne(e);
|
|
92
90
|
if (!n) return;
|
|
93
|
-
let r =
|
|
94
|
-
return r ?
|
|
91
|
+
let r = S(n, t);
|
|
92
|
+
return r ? x(b(n)) === void 0 ? `${r}[]` : `(${r})[]` : void 0;
|
|
95
93
|
}
|
|
96
|
-
let a =
|
|
94
|
+
let a = y(e);
|
|
97
95
|
if (a === "string") return "string";
|
|
98
96
|
if (a === "number") return "number";
|
|
99
97
|
if (a === "boolean") return "boolean";
|
|
100
98
|
if (a === "any") return "any";
|
|
101
99
|
if (a === "record") {
|
|
102
|
-
let n =
|
|
103
|
-
return `Record<${
|
|
100
|
+
let n = v(e);
|
|
101
|
+
return `Record<${S(n?.keyType, t) ?? "string"}, ${S(n?.valueType, t) ?? "any"}>`;
|
|
104
102
|
}
|
|
105
|
-
let o =
|
|
103
|
+
let o = re(e);
|
|
106
104
|
if (o) return o.map((e) => `"${e}"`).join(" | ");
|
|
107
105
|
if (a === "literal") {
|
|
108
|
-
let t =
|
|
106
|
+
let t = v(e)?.values;
|
|
109
107
|
if (Array.isArray(t) && t.length === 1) {
|
|
110
108
|
let e = t[0];
|
|
111
109
|
return typeof e == "string" ? `"${e}"` : String(e);
|
|
112
110
|
}
|
|
113
111
|
}
|
|
114
|
-
let s =
|
|
112
|
+
let s = ae(e);
|
|
115
113
|
return s ? `{${Object.entries(s).map(([e, n]) => {
|
|
116
|
-
let r =
|
|
114
|
+
let r = ee(n) ? "?" : "", i = S(n, t);
|
|
117
115
|
return i ? `${e}${r}: ${i}` : `${e}${r}`;
|
|
118
116
|
}).join(", ")}}` : "any";
|
|
119
117
|
}
|
|
120
|
-
function
|
|
118
|
+
function se(e, t) {
|
|
121
119
|
return Object.entries(e).map(([e, n]) => ({
|
|
122
120
|
name: e,
|
|
123
|
-
isOptional:
|
|
124
|
-
isArray:
|
|
125
|
-
typeAnnotation:
|
|
121
|
+
isOptional: ee(n),
|
|
122
|
+
isArray: te(n),
|
|
123
|
+
typeAnnotation: S(n, t)
|
|
126
124
|
}));
|
|
127
125
|
}
|
|
128
|
-
function
|
|
126
|
+
function ce(e, t) {
|
|
129
127
|
return `${e}(${t.map((e) => e.typeAnnotation ? e.isOptional ? `${e.name}?: ${e.typeAnnotation}` : `${e.name}: ${e.typeAnnotation}` : e.isArray ? e.isOptional ? `[${e.name}]?` : `[${e.name}]` : e.isOptional ? `${e.name}?` : e.name).join(", ")})`;
|
|
130
128
|
}
|
|
131
|
-
function
|
|
132
|
-
let i =
|
|
129
|
+
function le(e, t, n, r) {
|
|
130
|
+
let i = ce(e, se(t._zod.def.shape, r)), a = n && S(n, r);
|
|
133
131
|
return a ? `${i} → ${a}` : i;
|
|
134
132
|
}
|
|
135
|
-
var
|
|
133
|
+
var C = (e) => {
|
|
136
134
|
throw Error(`[extend] ${e}`);
|
|
137
135
|
};
|
|
138
|
-
function
|
|
139
|
-
let n =
|
|
136
|
+
function ue(e, t) {
|
|
137
|
+
let n = de(e, t.components), r = me(n, pe(n));
|
|
140
138
|
return {
|
|
141
139
|
...e,
|
|
142
140
|
id: void 0,
|
|
143
|
-
components:
|
|
144
|
-
componentGroups:
|
|
141
|
+
components: ge(n, r),
|
|
142
|
+
componentGroups: Se(e.componentGroups, n.removed),
|
|
145
143
|
functions: [...e.functions ?? [], ...t.functions?.add ?? []],
|
|
146
144
|
actions: [...e.actions ?? [], ...t.actions?.add ?? []]
|
|
147
145
|
};
|
|
148
146
|
}
|
|
149
|
-
function
|
|
147
|
+
function de(e, t = {}) {
|
|
150
148
|
let n = new Map(e.components.map((e) => [e.name, e])), r = new Map(e.components.map((e) => [e.props, e.name])), i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Set(), o = (e) => {
|
|
151
149
|
n.set(e.name, e), r.set(e.props, e.name), a.add(e.name);
|
|
152
150
|
};
|
|
@@ -155,12 +153,12 @@ function _e(e, t = {}) {
|
|
|
155
153
|
component: e,
|
|
156
154
|
slots: void 0
|
|
157
155
|
}, a = t.name;
|
|
158
|
-
n.has(a) &&
|
|
156
|
+
n.has(a) && C(`Component "${a}" already exists. Use override.`), r?.length === 0 && C(`"slots" for "${a}" is empty. Omit it to only list it.`), o(t), r && i.set(a, r);
|
|
159
157
|
}
|
|
160
158
|
let s = /* @__PURE__ */ new Set();
|
|
161
|
-
for (let e of t.override ?? []) n.has(e.name) ||
|
|
159
|
+
for (let e of t.override ?? []) n.has(e.name) || C(`Cannot override "${e.name}": not in the library. Use add.`), s.has(e.name) && C(`Component "${e.name}" is overridden twice.`), s.add(e.name), o(e);
|
|
162
160
|
let c = new Set(t.remove);
|
|
163
|
-
for (let t of c) a.has(t) &&
|
|
161
|
+
for (let t of c) a.has(t) && C(`Cannot remove "${t}": it is added or overridden in the same call.`), n.delete(t) || C(`Cannot remove "${t}": not in the library.`), t === e.root && C(`Cannot remove "${t}": it is the library root.`);
|
|
164
162
|
return {
|
|
165
163
|
byName: n,
|
|
166
164
|
nameOf: r,
|
|
@@ -168,34 +166,34 @@ function _e(e, t = {}) {
|
|
|
168
166
|
removed: c
|
|
169
167
|
};
|
|
170
168
|
}
|
|
171
|
-
function
|
|
172
|
-
let n =
|
|
173
|
-
return r?.type === "array" ?
|
|
169
|
+
function fe(e, t) {
|
|
170
|
+
let n = b(e), r = v(n);
|
|
171
|
+
return r?.type === "array" ? fe(r.element, t) : x(n)?.some((e) => t.has(e)) ? n : void 0;
|
|
174
172
|
}
|
|
175
|
-
function
|
|
173
|
+
function pe({ byName: e, nameOf: t }) {
|
|
176
174
|
let n = [];
|
|
177
|
-
for (let r of e.values()) for (let [e, i] of Object.entries(r.props.shape))
|
|
175
|
+
for (let r of e.values()) for (let [e, i] of Object.entries(r.props.shape)) fe(i, t) && n.push(`${r.name}.${e}`);
|
|
178
176
|
return n;
|
|
179
177
|
}
|
|
180
|
-
function
|
|
178
|
+
function me(e, t) {
|
|
181
179
|
let n = /* @__PURE__ */ new Map();
|
|
182
180
|
for (let [r, i] of e.slotRequests) for (let a of i) {
|
|
183
|
-
let i =
|
|
181
|
+
let i = he(a, r, t, e.byName), o = n.get(i) ?? [];
|
|
184
182
|
o.includes(r) || n.set(i, [...o, r]);
|
|
185
183
|
}
|
|
186
184
|
return n;
|
|
187
185
|
}
|
|
188
|
-
function
|
|
186
|
+
function he(e, t, n, r) {
|
|
189
187
|
if (n.includes(e)) return e;
|
|
190
188
|
let i = e.split(".")[0], a = n.filter((e) => e.startsWith(`${i}.`));
|
|
191
189
|
if (!e.includes(".") && a.length === 1) return a[0];
|
|
192
190
|
let o = `Slot "${e}" for "${t}"`;
|
|
193
|
-
return r.has(i) ||
|
|
191
|
+
return r.has(i) || C(`${o}: "${i}" is not in the library.`), a.length || C(`${o}: "${i}" has no content slot (a prop that is a union of components, or an optional or array of one).`), C(`${o} must be one content slot. Candidates: ${a.join(", ")}.`);
|
|
194
192
|
}
|
|
195
|
-
function
|
|
193
|
+
function ge(e, t) {
|
|
196
194
|
let { byName: n, nameOf: r, removed: i } = e, a = new Map(n), o = /* @__PURE__ */ new Map();
|
|
197
|
-
for (let r of
|
|
198
|
-
let e = n.get(r), t = {}, i =
|
|
195
|
+
for (let r of _e(e, t)) {
|
|
196
|
+
let e = n.get(r), t = {}, i = xe(e.props, { get shape() {
|
|
199
197
|
return t;
|
|
200
198
|
} });
|
|
201
199
|
a.set(r, {
|
|
@@ -204,43 +202,43 @@ function Se(e, t) {
|
|
|
204
202
|
ref: i
|
|
205
203
|
}), o.set(r, t);
|
|
206
204
|
}
|
|
207
|
-
let s = (e) => a.get(e).props, c = (e, t) =>
|
|
205
|
+
let s = (e) => a.get(e).props, c = (e, t) => C(`Cannot remove "${e}": it is the only type allowed in ${t.path}.`), l = (e, t, n) => {
|
|
208
206
|
let a = r.get(e);
|
|
209
207
|
if (a !== void 0) return i.has(a) && c(a, t), s(a);
|
|
210
|
-
let o =
|
|
208
|
+
let o = v(e);
|
|
211
209
|
if (!o || o.type === "lazy") return e;
|
|
212
210
|
if (n.has(e)) return n.get(e);
|
|
213
211
|
n.set(e, e);
|
|
214
|
-
let u = (e) => l(e, t, n), d = {}, f =
|
|
212
|
+
let u = (e) => l(e, t, n), d = {}, f = x(e), p = f?.some((e) => r.has(e));
|
|
215
213
|
for (let [e, t] of Object.entries(o)) {
|
|
216
214
|
if (e === "checks" || p && e === "options") continue;
|
|
217
|
-
let n =
|
|
218
|
-
|
|
215
|
+
let n = ye(e, t, u);
|
|
216
|
+
be(n, t) || (d[e] = n);
|
|
219
217
|
}
|
|
220
218
|
if (p) {
|
|
221
219
|
let n = f.filter((e) => !i.has(r.get(e) ?? "")).map(u), a = e === t.union ? t.added.filter((e) => !n.includes(e)) : [];
|
|
222
220
|
!n.length && !a.length && c(r.get(f[0]), t);
|
|
223
221
|
let o = [...n, ...a];
|
|
224
|
-
|
|
222
|
+
be(o, f) || (d.options = o);
|
|
225
223
|
}
|
|
226
|
-
let m = Object.keys(d).length ?
|
|
224
|
+
let m = Object.keys(d).length ? xe(e, d) : e;
|
|
227
225
|
return n.set(e, m), m;
|
|
228
226
|
};
|
|
229
227
|
for (let [e, i] of o) for (let [a, o] of Object.entries(n.get(e).props.shape)) {
|
|
230
228
|
let n = `${e}.${a}`, c = (t.get(n) ?? []).map(s);
|
|
231
229
|
i[a] = l(o, {
|
|
232
230
|
path: n,
|
|
233
|
-
union:
|
|
231
|
+
union: fe(o, r),
|
|
234
232
|
added: c
|
|
235
233
|
}, /* @__PURE__ */ new Map());
|
|
236
234
|
}
|
|
237
235
|
return [...a.values()];
|
|
238
236
|
}
|
|
239
|
-
function
|
|
237
|
+
function _e({ byName: e, nameOf: t, removed: n }, r) {
|
|
240
238
|
let i = /* @__PURE__ */ new Map();
|
|
241
239
|
for (let [n, r] of e) {
|
|
242
240
|
let e = /* @__PURE__ */ new Set();
|
|
243
|
-
for (let n of Object.values(r.props.shape))
|
|
241
|
+
for (let n of Object.values(r.props.shape)) ve(n, t, e);
|
|
244
242
|
i.set(n, e);
|
|
245
243
|
}
|
|
246
244
|
let a = (r) => {
|
|
@@ -254,58 +252,58 @@ function Ce({ byName: e, nameOf: t, removed: n }, r) {
|
|
|
254
252
|
}
|
|
255
253
|
return s;
|
|
256
254
|
}
|
|
257
|
-
function
|
|
255
|
+
function ve(e, t, n, r = /* @__PURE__ */ new Set()) {
|
|
258
256
|
if (t.has(e)) return void n.add(e);
|
|
259
|
-
let i =
|
|
257
|
+
let i = v(e);
|
|
260
258
|
if (!(!i || i.type === "lazy" || r.has(e))) {
|
|
261
259
|
r.add(e);
|
|
262
|
-
for (let [e, a] of Object.entries(i)) e !== "checks" &&
|
|
260
|
+
for (let [e, a] of Object.entries(i)) e !== "checks" && ye(e, a, (e) => ve(e, t, n, r));
|
|
263
261
|
}
|
|
264
262
|
}
|
|
265
|
-
function
|
|
266
|
-
if (
|
|
263
|
+
function ye(e, t, n) {
|
|
264
|
+
if (v(t)) return n(t);
|
|
267
265
|
if (Array.isArray(t)) return t.map(n);
|
|
268
266
|
if (e !== "shape") return t;
|
|
269
267
|
let r = {};
|
|
270
268
|
for (let [e, i] of Object.entries(t)) r[e] = n(i);
|
|
271
269
|
return r;
|
|
272
270
|
}
|
|
273
|
-
function
|
|
271
|
+
function be(e, t) {
|
|
274
272
|
if (e === t) return !0;
|
|
275
|
-
if (
|
|
273
|
+
if (v(e)) return !1;
|
|
276
274
|
let n = Object.entries(e);
|
|
277
275
|
return n.length === Object.keys(t).length && n.every(([e, n]) => n === t[e]);
|
|
278
276
|
}
|
|
279
|
-
function
|
|
280
|
-
let n = e, r =
|
|
281
|
-
|
|
282
|
-
let i =
|
|
283
|
-
return i &&
|
|
277
|
+
function xe(e, t) {
|
|
278
|
+
let n = e, r = c.clone(n, c.util.mergeDefs(n._zod.def, t));
|
|
279
|
+
g(n, r), d(n) && u(r);
|
|
280
|
+
let i = c.globalRegistry.get(n);
|
|
281
|
+
return i && c.globalRegistry.add(r, i), r;
|
|
284
282
|
}
|
|
285
|
-
function
|
|
283
|
+
function Se(e, t) {
|
|
286
284
|
return e?.map((e) => ({
|
|
287
285
|
...e,
|
|
288
286
|
components: e.components.filter((e) => !t.has(e))
|
|
289
287
|
})).filter((e) => e.components.length);
|
|
290
288
|
}
|
|
291
|
-
function
|
|
292
|
-
if (
|
|
289
|
+
function Ce(e, t) {
|
|
290
|
+
if (_(e, t), e?._zod?.def.type !== "object") throw Error(`[OpenUI] "${t}" params must be a z.object().`);
|
|
293
291
|
}
|
|
294
|
-
function
|
|
295
|
-
return
|
|
292
|
+
function w(e) {
|
|
293
|
+
return Ce(e.params, e.name), e.returns && _(e.returns, e.name), e;
|
|
296
294
|
}
|
|
297
|
-
function
|
|
298
|
-
|
|
299
|
-
let t =
|
|
300
|
-
type:
|
|
295
|
+
function T(e) {
|
|
296
|
+
Ce(e.params, e.name);
|
|
297
|
+
let t = o({
|
|
298
|
+
type: a(e.name),
|
|
301
299
|
params: e.params
|
|
302
300
|
});
|
|
303
301
|
return {
|
|
304
302
|
...e,
|
|
305
|
-
ref:
|
|
303
|
+
ref: h(e.name, t)
|
|
306
304
|
};
|
|
307
305
|
}
|
|
308
|
-
function
|
|
306
|
+
function we(e, t) {
|
|
309
307
|
if (!t || e == null) return;
|
|
310
308
|
if (!t.includes(".")) return e[t];
|
|
311
309
|
let n = e;
|
|
@@ -315,7 +313,7 @@ function Ae(e, t) {
|
|
|
315
313
|
}
|
|
316
314
|
return n;
|
|
317
315
|
}
|
|
318
|
-
function
|
|
316
|
+
function E(e) {
|
|
319
317
|
if (typeof e == "number") return e;
|
|
320
318
|
if (typeof e == "string") {
|
|
321
319
|
let t = Number(e);
|
|
@@ -323,72 +321,72 @@ function A(e) {
|
|
|
323
321
|
}
|
|
324
322
|
return typeof e == "boolean" ? +!!e : 0;
|
|
325
323
|
}
|
|
326
|
-
var
|
|
327
|
-
|
|
324
|
+
var Te = (e) => e.reduce((e, t) => e + E(t), 0), D = () => s.array(s.any()), O = () => s.object({ numbers: s.array(s.number()) }), Ee = () => s.object({ number: s.number() }), De = [
|
|
325
|
+
w({
|
|
328
326
|
name: "Count",
|
|
329
327
|
description: "Returns array length",
|
|
330
|
-
params:
|
|
331
|
-
returns:
|
|
328
|
+
params: s.object({ array: D() }),
|
|
329
|
+
returns: s.number(),
|
|
332
330
|
fn: ({ array: e }) => Array.isArray(e) ? e.length : 0
|
|
333
331
|
}),
|
|
334
|
-
|
|
332
|
+
w({
|
|
335
333
|
name: "First",
|
|
336
334
|
description: "Returns first element of array",
|
|
337
|
-
params:
|
|
338
|
-
returns:
|
|
335
|
+
params: s.object({ array: D() }),
|
|
336
|
+
returns: s.any(),
|
|
339
337
|
fn: ({ array: e }) => Array.isArray(e) ? e[0] ?? null : null
|
|
340
338
|
}),
|
|
341
|
-
|
|
339
|
+
w({
|
|
342
340
|
name: "Last",
|
|
343
341
|
description: "Returns last element of array",
|
|
344
|
-
params:
|
|
345
|
-
returns:
|
|
342
|
+
params: s.object({ array: D() }),
|
|
343
|
+
returns: s.any(),
|
|
346
344
|
fn: ({ array: e }) => Array.isArray(e) ? e[e.length - 1] ?? null : null
|
|
347
345
|
}),
|
|
348
|
-
|
|
346
|
+
w({
|
|
349
347
|
name: "Sum",
|
|
350
348
|
description: "Sum of numeric array",
|
|
351
|
-
params:
|
|
352
|
-
returns:
|
|
353
|
-
fn: ({ numbers: e }) => Array.isArray(e) ?
|
|
349
|
+
params: O(),
|
|
350
|
+
returns: s.number(),
|
|
351
|
+
fn: ({ numbers: e }) => Array.isArray(e) ? Te(e) : 0
|
|
354
352
|
}),
|
|
355
|
-
|
|
353
|
+
w({
|
|
356
354
|
name: "Avg",
|
|
357
355
|
description: "Average of numeric array",
|
|
358
|
-
params:
|
|
359
|
-
returns:
|
|
360
|
-
fn: ({ numbers: e }) => Array.isArray(e) && e.length ?
|
|
356
|
+
params: O(),
|
|
357
|
+
returns: s.number(),
|
|
358
|
+
fn: ({ numbers: e }) => Array.isArray(e) && e.length ? Te(e) / e.length : 0
|
|
361
359
|
}),
|
|
362
|
-
|
|
360
|
+
w({
|
|
363
361
|
name: "Min",
|
|
364
362
|
description: "Minimum value in array",
|
|
365
|
-
params:
|
|
366
|
-
returns:
|
|
367
|
-
fn: ({ numbers: e }) => Array.isArray(e) && e.length ? e.reduce((e, t) => Math.min(e,
|
|
363
|
+
params: O(),
|
|
364
|
+
returns: s.number(),
|
|
365
|
+
fn: ({ numbers: e }) => Array.isArray(e) && e.length ? e.reduce((e, t) => Math.min(e, E(t)), E(e[0])) : 0
|
|
368
366
|
}),
|
|
369
|
-
|
|
367
|
+
w({
|
|
370
368
|
name: "Max",
|
|
371
369
|
description: "Maximum value in array",
|
|
372
|
-
params:
|
|
373
|
-
returns:
|
|
374
|
-
fn: ({ numbers: e }) => Array.isArray(e) && e.length ? e.reduce((e, t) => Math.max(e,
|
|
370
|
+
params: O(),
|
|
371
|
+
returns: s.number(),
|
|
372
|
+
fn: ({ numbers: e }) => Array.isArray(e) && e.length ? e.reduce((e, t) => Math.max(e, E(t)), E(e[0])) : 0
|
|
375
373
|
}),
|
|
376
|
-
|
|
374
|
+
w({
|
|
377
375
|
name: "Sort",
|
|
378
376
|
description: "Sort array by field. Direction: \"asc\" (default) or \"desc\"",
|
|
379
|
-
params:
|
|
380
|
-
array:
|
|
381
|
-
field:
|
|
382
|
-
direction:
|
|
377
|
+
params: s.object({
|
|
378
|
+
array: D(),
|
|
379
|
+
field: s.string(),
|
|
380
|
+
direction: s.enum(["asc", "desc"]).optional()
|
|
383
381
|
}),
|
|
384
|
-
returns:
|
|
382
|
+
returns: D(),
|
|
385
383
|
fn: ({ array: e, field: t, direction: n }) => {
|
|
386
384
|
if (!Array.isArray(e)) return e;
|
|
387
385
|
let r = String(t ?? ""), i = String(n ?? "asc") === "desc";
|
|
388
386
|
return [...e].sort((e, t) => {
|
|
389
|
-
let n = r ?
|
|
387
|
+
let n = r ? we(e, r) : e, a = r ? we(t, r) : t, o = typeof n == "number" || typeof n == "string" && !isNaN(Number(n)) && n !== "", s = typeof a == "number" || typeof a == "string" && !isNaN(Number(a)) && a !== "";
|
|
390
388
|
if (o && s) {
|
|
391
|
-
let e =
|
|
389
|
+
let e = E(n) - E(a);
|
|
392
390
|
return i ? -e : e;
|
|
393
391
|
}
|
|
394
392
|
let c = String(n ?? "").localeCompare(String(a ?? ""));
|
|
@@ -396,13 +394,13 @@ var je = (e) => e.reduce((e, t) => e + A(t), 0), j = () => f(d()), M = () => h({
|
|
|
396
394
|
});
|
|
397
395
|
}
|
|
398
396
|
}),
|
|
399
|
-
|
|
397
|
+
w({
|
|
400
398
|
name: "Filter",
|
|
401
399
|
description: "Filter array by field value",
|
|
402
|
-
params:
|
|
403
|
-
array:
|
|
404
|
-
field:
|
|
405
|
-
operator:
|
|
400
|
+
params: s.object({
|
|
401
|
+
array: D(),
|
|
402
|
+
field: s.string(),
|
|
403
|
+
operator: s.enum([
|
|
406
404
|
"==",
|
|
407
405
|
"!=",
|
|
408
406
|
">",
|
|
@@ -411,164 +409,164 @@ var je = (e) => e.reduce((e, t) => e + A(t), 0), j = () => f(d()), M = () => h({
|
|
|
411
409
|
"<=",
|
|
412
410
|
"contains"
|
|
413
411
|
]),
|
|
414
|
-
value:
|
|
412
|
+
value: s.any()
|
|
415
413
|
}),
|
|
416
|
-
returns:
|
|
414
|
+
returns: D(),
|
|
417
415
|
fn: ({ array: e, field: t, operator: n, value: r }) => {
|
|
418
416
|
if (!Array.isArray(e)) return [];
|
|
419
417
|
let i = String(t ?? ""), a = String(n ?? "==");
|
|
420
418
|
return e.filter((e) => {
|
|
421
|
-
let t = i ?
|
|
419
|
+
let t = i ? we(e, i) : e;
|
|
422
420
|
switch (a) {
|
|
423
421
|
case "==": return t == r;
|
|
424
422
|
case "!=": return t != r;
|
|
425
|
-
case ">": return
|
|
426
|
-
case "<": return
|
|
427
|
-
case ">=": return
|
|
428
|
-
case "<=": return
|
|
423
|
+
case ">": return E(t) > E(r);
|
|
424
|
+
case "<": return E(t) < E(r);
|
|
425
|
+
case ">=": return E(t) >= E(r);
|
|
426
|
+
case "<=": return E(t) <= E(r);
|
|
429
427
|
case "contains": return String(t ?? "").includes(String(r ?? ""));
|
|
430
428
|
default: return !1;
|
|
431
429
|
}
|
|
432
430
|
});
|
|
433
431
|
}
|
|
434
432
|
}),
|
|
435
|
-
|
|
433
|
+
w({
|
|
436
434
|
name: "Round",
|
|
437
435
|
description: "Round to N decimal places (default 0)",
|
|
438
|
-
params:
|
|
439
|
-
number:
|
|
440
|
-
decimals:
|
|
436
|
+
params: s.object({
|
|
437
|
+
number: s.number(),
|
|
438
|
+
decimals: s.number().optional()
|
|
441
439
|
}),
|
|
442
|
-
returns:
|
|
440
|
+
returns: s.number(),
|
|
443
441
|
fn: ({ number: e, decimals: t }) => {
|
|
444
|
-
let n =
|
|
442
|
+
let n = E(e), r = 10 ** (t == null ? 0 : E(t));
|
|
445
443
|
return Math.round(n * r) / r;
|
|
446
444
|
}
|
|
447
445
|
}),
|
|
448
|
-
|
|
446
|
+
w({
|
|
449
447
|
name: "Abs",
|
|
450
448
|
description: "Absolute value",
|
|
451
|
-
params:
|
|
452
|
-
returns:
|
|
453
|
-
fn: ({ number: e }) => Math.abs(
|
|
449
|
+
params: Ee(),
|
|
450
|
+
returns: s.number(),
|
|
451
|
+
fn: ({ number: e }) => Math.abs(E(e))
|
|
454
452
|
}),
|
|
455
|
-
|
|
453
|
+
w({
|
|
456
454
|
name: "Floor",
|
|
457
455
|
description: "Round down to nearest integer",
|
|
458
|
-
params:
|
|
459
|
-
returns:
|
|
460
|
-
fn: ({ number: e }) => Math.floor(
|
|
456
|
+
params: Ee(),
|
|
457
|
+
returns: s.number(),
|
|
458
|
+
fn: ({ number: e }) => Math.floor(E(e))
|
|
461
459
|
}),
|
|
462
|
-
|
|
460
|
+
w({
|
|
463
461
|
name: "Ceil",
|
|
464
462
|
description: "Round up to nearest integer",
|
|
465
|
-
params:
|
|
466
|
-
returns:
|
|
467
|
-
fn: ({ number: e }) => Math.ceil(
|
|
463
|
+
params: Ee(),
|
|
464
|
+
returns: s.number(),
|
|
465
|
+
fn: ({ number: e }) => Math.ceil(E(e))
|
|
468
466
|
}),
|
|
469
467
|
{
|
|
470
468
|
name: "Each",
|
|
471
469
|
description: "Evaluate template for each element. varName is the loop variable — use it ONLY inside the template expression (inline). Do NOT create a separate statement for the template.",
|
|
472
|
-
params:
|
|
473
|
-
array:
|
|
474
|
-
varName:
|
|
475
|
-
template:
|
|
470
|
+
params: s.object({
|
|
471
|
+
array: D(),
|
|
472
|
+
varName: s.string(),
|
|
473
|
+
template: s.any()
|
|
476
474
|
}),
|
|
477
475
|
lazy: !0
|
|
478
476
|
}
|
|
479
|
-
],
|
|
477
|
+
], Oe = Object.fromEntries(De.map((e) => [e.name, e])), k = {
|
|
480
478
|
Run: "run",
|
|
481
479
|
ToAssistant: "continue_conversation",
|
|
482
480
|
OpenUrl: "open_url",
|
|
483
481
|
Set: "set",
|
|
484
482
|
Reset: "reset"
|
|
485
483
|
};
|
|
486
|
-
function
|
|
487
|
-
let t =
|
|
488
|
-
return
|
|
489
|
-
}
|
|
490
|
-
var
|
|
491
|
-
type:
|
|
492
|
-
url:
|
|
493
|
-
}),
|
|
494
|
-
type:
|
|
495
|
-
context:
|
|
496
|
-
}),
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
type:
|
|
501
|
-
params:
|
|
484
|
+
function ke(e) {
|
|
485
|
+
let t = s.any();
|
|
486
|
+
return p(t, e), t;
|
|
487
|
+
}
|
|
488
|
+
var Ae = () => s.object({
|
|
489
|
+
type: s.literal("open_url"),
|
|
490
|
+
url: s.string()
|
|
491
|
+
}), je = () => s.object({
|
|
492
|
+
type: s.literal("continue_conversation"),
|
|
493
|
+
context: s.string().optional()
|
|
494
|
+
}), Me = s.union([
|
|
495
|
+
Ae(),
|
|
496
|
+
je(),
|
|
497
|
+
s.object({
|
|
498
|
+
type: s.string(),
|
|
499
|
+
params: s.record(s.string(), s.any()).optional()
|
|
502
500
|
})
|
|
503
501
|
]);
|
|
504
|
-
|
|
505
|
-
function
|
|
506
|
-
return
|
|
507
|
-
}
|
|
508
|
-
var
|
|
509
|
-
OpenUrl: { ref:
|
|
510
|
-
ToAssistant: { ref:
|
|
511
|
-
},
|
|
512
|
-
ActionExpression:
|
|
513
|
-
OpenUrl:
|
|
514
|
-
ToAssistant:
|
|
515
|
-
},
|
|
502
|
+
p(Me, "ActionExpression");
|
|
503
|
+
function Ne() {
|
|
504
|
+
return Me;
|
|
505
|
+
}
|
|
506
|
+
var A = {
|
|
507
|
+
OpenUrl: { ref: h("OpenUrl", Ae()) },
|
|
508
|
+
ToAssistant: { ref: h("ToAssistant", je()) }
|
|
509
|
+
}, Pe = {
|
|
510
|
+
ActionExpression: Me,
|
|
511
|
+
OpenUrl: A.OpenUrl.ref,
|
|
512
|
+
ToAssistant: A.ToAssistant.ref
|
|
513
|
+
}, Fe = [
|
|
516
514
|
{
|
|
517
|
-
...
|
|
515
|
+
...T({
|
|
518
516
|
name: "Run",
|
|
519
517
|
description: "Execute a Mutation or re-fetch a Query (ref must be a declared Query/Mutation)",
|
|
520
|
-
params:
|
|
518
|
+
params: s.object({ ref: ke("Query | Mutation") })
|
|
521
519
|
}),
|
|
522
520
|
lazy: !0
|
|
523
521
|
},
|
|
524
522
|
{
|
|
525
|
-
...
|
|
523
|
+
...T({
|
|
526
524
|
name: "ToAssistant",
|
|
527
525
|
description: "Send a message to the assistant (for conversational buttons like \"Tell me more\", \"Explain this\"). The optional context is any value (object, array, string, number) passed to the assistant as hidden data, e.g. @ToAssistant(\"Show details\", {orderId: 42})",
|
|
528
|
-
params:
|
|
529
|
-
message:
|
|
530
|
-
context:
|
|
526
|
+
params: s.object({
|
|
527
|
+
message: s.string(),
|
|
528
|
+
context: s.any().optional()
|
|
531
529
|
})
|
|
532
530
|
}),
|
|
533
|
-
ref:
|
|
531
|
+
ref: A.ToAssistant.ref,
|
|
534
532
|
step: ({ message: e, context: t }) => ({
|
|
535
|
-
type:
|
|
533
|
+
type: k.ToAssistant,
|
|
536
534
|
message: String(e ?? ""),
|
|
537
535
|
context: t ?? void 0
|
|
538
536
|
})
|
|
539
537
|
},
|
|
540
538
|
{
|
|
541
|
-
...
|
|
539
|
+
...T({
|
|
542
540
|
name: "OpenUrl",
|
|
543
541
|
description: "Navigate to a URL",
|
|
544
|
-
params:
|
|
542
|
+
params: s.object({ url: s.string() })
|
|
545
543
|
}),
|
|
546
|
-
ref:
|
|
544
|
+
ref: A.OpenUrl.ref,
|
|
547
545
|
step: ({ url: e }) => ({
|
|
548
|
-
type:
|
|
546
|
+
type: k.OpenUrl,
|
|
549
547
|
url: String(e ?? "")
|
|
550
548
|
})
|
|
551
549
|
},
|
|
552
550
|
{
|
|
553
|
-
...
|
|
551
|
+
...T({
|
|
554
552
|
name: "Set",
|
|
555
553
|
description: "Set a $variable to a specific value",
|
|
556
|
-
params:
|
|
557
|
-
variable:
|
|
558
|
-
value:
|
|
554
|
+
params: s.object({
|
|
555
|
+
variable: ke("$variable"),
|
|
556
|
+
value: s.any()
|
|
559
557
|
})
|
|
560
558
|
}),
|
|
561
559
|
lazy: !0
|
|
562
560
|
},
|
|
563
561
|
{
|
|
564
|
-
...
|
|
562
|
+
...T({
|
|
565
563
|
name: "Reset",
|
|
566
564
|
description: "Reset $variables to their declared defaults; pass several to reset each (e.g. @Reset($title, $priority) restores $title=\"\" and $priority=\"medium\")",
|
|
567
|
-
params:
|
|
565
|
+
params: s.object({ variable: ke("$variable") })
|
|
568
566
|
}),
|
|
569
567
|
lazy: !0
|
|
570
568
|
}
|
|
571
|
-
],
|
|
569
|
+
], Ie = Object.fromEntries(Fe.map((e) => [e.name, e])), Le = (e, t) => ({
|
|
572
570
|
kind: e,
|
|
573
571
|
params: Object.keys(t.params.shape).map((e) => ({
|
|
574
572
|
name: e,
|
|
@@ -576,9 +574,9 @@ var P = {
|
|
|
576
574
|
})),
|
|
577
575
|
builtin: !0,
|
|
578
576
|
...t.lazy ? { lazy: !0 } : {}
|
|
579
|
-
}),
|
|
580
|
-
...
|
|
581
|
-
...
|
|
577
|
+
}), j = new Map([
|
|
578
|
+
...De.map((e) => [e.name, Le("function", e)]),
|
|
579
|
+
...Fe.map((e) => [e.name, Le("action", e)]),
|
|
582
580
|
["Action", {
|
|
583
581
|
kind: "action",
|
|
584
582
|
params: [{
|
|
@@ -589,24 +587,24 @@ var P = {
|
|
|
589
587
|
lazy: !0
|
|
590
588
|
}]
|
|
591
589
|
]);
|
|
592
|
-
function
|
|
593
|
-
return e?.callDefs ??
|
|
590
|
+
function M(e) {
|
|
591
|
+
return e?.callDefs ?? j;
|
|
594
592
|
}
|
|
595
|
-
function
|
|
596
|
-
return
|
|
593
|
+
function N(e) {
|
|
594
|
+
return j.has(e);
|
|
597
595
|
}
|
|
598
|
-
function
|
|
599
|
-
return
|
|
596
|
+
function Re(e, t) {
|
|
597
|
+
return j.get(e)?.kind === "action" || !!t && Object.prototype.hasOwnProperty.call(t, e);
|
|
600
598
|
}
|
|
601
|
-
var
|
|
599
|
+
var P = {
|
|
602
600
|
Query: "Query",
|
|
603
601
|
Mutation: "Mutation"
|
|
604
602
|
};
|
|
605
|
-
function
|
|
606
|
-
return e in
|
|
603
|
+
function F(e) {
|
|
604
|
+
return e in P;
|
|
607
605
|
}
|
|
608
|
-
var
|
|
609
|
-
function
|
|
606
|
+
var ze = "lang_core_system_prompt_generation_used", Be = "lang_core_parser_parse_used", Ve = .1, He = .1, Ue = "1.0.1", We = Symbol.for("@openuidev/lang-core/telemetry/v1");
|
|
607
|
+
function Ge(e) {
|
|
610
608
|
let t = (e.tools?.length ?? 0) > 0, n = e.toolCalls ?? t, r = e.bindings ?? n, i = Object.entries(e.components).sort(([e], [t]) => e.localeCompare(t)).map(([e, t]) => ({
|
|
611
609
|
name: e,
|
|
612
610
|
signature: t.signature,
|
|
@@ -628,30 +626,30 @@ function Ze(e) {
|
|
|
628
626
|
}
|
|
629
627
|
};
|
|
630
628
|
}
|
|
631
|
-
async function
|
|
629
|
+
async function Ke(e) {
|
|
632
630
|
let t = globalThis.crypto?.subtle;
|
|
633
631
|
if (!t) throw Error("Web Crypto is unavailable");
|
|
634
632
|
let n = new TextEncoder().encode(e), r = await t.digest("SHA-256", n);
|
|
635
633
|
return Array.from(new Uint8Array(r), (e) => e.toString(16).padStart(2, "0")).join("");
|
|
636
634
|
}
|
|
637
|
-
function
|
|
638
|
-
return
|
|
635
|
+
function qe(e) {
|
|
636
|
+
return Ke(JSON.stringify(Ge(e)));
|
|
639
637
|
}
|
|
640
|
-
function
|
|
638
|
+
function Je() {
|
|
641
639
|
let e = globalThis.process;
|
|
642
640
|
if (!(!e || typeof e != "object")) return e;
|
|
643
641
|
}
|
|
644
|
-
function
|
|
642
|
+
function Ye() {
|
|
645
643
|
let e = globalThis;
|
|
646
644
|
return e.navigator?.product === "ReactNative" || !!(e.window && e.document);
|
|
647
645
|
}
|
|
648
|
-
function
|
|
646
|
+
function Xe() {
|
|
649
647
|
let e = globalThis.WorkerGlobalScope;
|
|
650
648
|
return !!(e && e.prototype.isPrototypeOf(globalThis));
|
|
651
649
|
}
|
|
652
|
-
function
|
|
653
|
-
if (
|
|
654
|
-
let e = globalThis, t =
|
|
650
|
+
function Ze() {
|
|
651
|
+
if (Ye()) return;
|
|
652
|
+
let e = globalThis, t = Je();
|
|
655
653
|
if (e.Bun && typeof e.Bun == "object") return {
|
|
656
654
|
name: "bun",
|
|
657
655
|
version: e.Bun.version,
|
|
@@ -667,22 +665,22 @@ function rt() {
|
|
|
667
665
|
version: e.EdgeRuntime
|
|
668
666
|
};
|
|
669
667
|
if (typeof e.WebSocketPair == "function") return { name: "edge" };
|
|
670
|
-
if (!
|
|
668
|
+
if (!Xe() && (t?.release?.name === "node" || typeof t?.versions?.node == "string" && t.versions.node.length > 0)) return {
|
|
671
669
|
name: "node",
|
|
672
670
|
version: t.versions?.node,
|
|
673
671
|
env: t.env,
|
|
674
672
|
process: t
|
|
675
673
|
};
|
|
676
674
|
}
|
|
677
|
-
function
|
|
675
|
+
function Qe(e) {
|
|
678
676
|
let t = e?.NODE_ENV;
|
|
679
677
|
return t === "production" || t === "development" || t === "test" ? t : "unknown";
|
|
680
678
|
}
|
|
681
|
-
function
|
|
679
|
+
function $e() {
|
|
682
680
|
let e = globalThis;
|
|
683
|
-
return e[
|
|
681
|
+
return e[We] ??= { runtimeId: globalThis.crypto.randomUUID() }, e[We];
|
|
684
682
|
}
|
|
685
|
-
function
|
|
683
|
+
function et(e) {
|
|
686
684
|
let t = e.getBuiltinModule?.("node:child_process")?.execFile;
|
|
687
685
|
return t ? new Promise((e) => {
|
|
688
686
|
try {
|
|
@@ -704,19 +702,19 @@ function ot(e) {
|
|
|
704
702
|
}
|
|
705
703
|
}) : Promise.resolve(void 0);
|
|
706
704
|
}
|
|
707
|
-
async function
|
|
705
|
+
async function tt(e) {
|
|
708
706
|
if (!e) return;
|
|
709
|
-
let t = await
|
|
707
|
+
let t = await et(e) || e.env?.REPOSITORY_URL || e.cwd?.();
|
|
710
708
|
return t && i(t) || void 0;
|
|
711
709
|
}
|
|
712
|
-
function
|
|
710
|
+
function nt(e) {
|
|
713
711
|
let t = i(e);
|
|
714
|
-
return t ?
|
|
712
|
+
return t ? Ke(t) : Promise.reject(/* @__PURE__ */ TypeError("Repository identifier is empty"));
|
|
715
713
|
}
|
|
716
|
-
function
|
|
717
|
-
return t.name === "node" ? (e.projectHash ??= Promise.resolve().then(() =>
|
|
714
|
+
function rt(e, t) {
|
|
715
|
+
return t.name === "node" ? (e.projectHash ??= Promise.resolve().then(() => tt(t.process)).then((e) => e ? nt(e) : void 0).catch(() => void 0), e.projectHash) : Promise.resolve(void 0);
|
|
718
716
|
}
|
|
719
|
-
async function
|
|
717
|
+
async function it(t) {
|
|
720
718
|
if (!t.env) return {
|
|
721
719
|
id: null,
|
|
722
720
|
isCI: !1
|
|
@@ -734,7 +732,7 @@ async function ut(t) {
|
|
|
734
732
|
};
|
|
735
733
|
}
|
|
736
734
|
}
|
|
737
|
-
async function
|
|
735
|
+
async function at(e, r, i) {
|
|
738
736
|
let a = n(i.env);
|
|
739
737
|
await globalThis.fetch(a.captureUrl, {
|
|
740
738
|
method: "POST",
|
|
@@ -749,13 +747,13 @@ async function dt(e, r, i) {
|
|
|
749
747
|
signal: globalThis.AbortSignal.timeout(t)
|
|
750
748
|
});
|
|
751
749
|
}
|
|
752
|
-
async function
|
|
750
|
+
async function ot(e, t, n, r, i, a) {
|
|
753
751
|
let [o, s, c] = await Promise.all([
|
|
754
752
|
n,
|
|
755
|
-
|
|
756
|
-
|
|
753
|
+
rt(e, i),
|
|
754
|
+
it(i)
|
|
757
755
|
]);
|
|
758
|
-
await
|
|
756
|
+
await at(ze, {
|
|
759
757
|
distinct_id: e.runtimeId,
|
|
760
758
|
$process_person_profile: !1,
|
|
761
759
|
event_id: globalThis.crypto.randomUUID(),
|
|
@@ -765,7 +763,7 @@ async function ft(e, t, n, r, i, a) {
|
|
|
765
763
|
component_count: Object.keys(t.components).length,
|
|
766
764
|
tool_count: t.tools?.length ?? 0,
|
|
767
765
|
sdk_name: "@openuidev/lang-core",
|
|
768
|
-
sdk_version:
|
|
766
|
+
sdk_version: Ue,
|
|
769
767
|
api_surface: "generate_system_prompt",
|
|
770
768
|
input_shape: r,
|
|
771
769
|
runtime: i.name,
|
|
@@ -773,24 +771,24 @@ async function ft(e, t, n, r, i, a) {
|
|
|
773
771
|
environment: a,
|
|
774
772
|
ci: c.isCI,
|
|
775
773
|
...c.id ? { ci_name: c.id } : {},
|
|
776
|
-
sample_rate:
|
|
774
|
+
sample_rate: Ve,
|
|
777
775
|
...s ? {
|
|
778
776
|
project_hash_version: 1,
|
|
779
777
|
project_hash: s
|
|
780
778
|
} : {}
|
|
781
779
|
}, i);
|
|
782
780
|
}
|
|
783
|
-
function
|
|
781
|
+
function st(e, t) {
|
|
784
782
|
try {
|
|
785
|
-
let n =
|
|
783
|
+
let n = Ze();
|
|
786
784
|
if (!n || typeof globalThis.fetch != "function" || !globalThis.crypto?.subtle || typeof globalThis.crypto.randomUUID != "function" || typeof globalThis.AbortSignal?.timeout != "function") return;
|
|
787
|
-
let i = n.env, a =
|
|
788
|
-
if (!r(i) || Math.random() >=
|
|
789
|
-
let o =
|
|
790
|
-
Promise.resolve().then(() =>
|
|
785
|
+
let i = n.env, a = Qe(i);
|
|
786
|
+
if (!r(i) || Math.random() >= Ve) return;
|
|
787
|
+
let o = $e(), s = qe(e);
|
|
788
|
+
Promise.resolve().then(() => ot(o, e, s, t, n, a)).catch(() => void 0);
|
|
791
789
|
} catch {}
|
|
792
790
|
}
|
|
793
|
-
function
|
|
791
|
+
function ct(e) {
|
|
794
792
|
let t = {
|
|
795
793
|
"unknown-component": 0,
|
|
796
794
|
"missing-required": 0,
|
|
@@ -810,7 +808,7 @@ function mt(e) {
|
|
|
810
808
|
excess_args_count: t["excess-args"]
|
|
811
809
|
};
|
|
812
810
|
}
|
|
813
|
-
function
|
|
811
|
+
function lt(e) {
|
|
814
812
|
return {
|
|
815
813
|
outcome: e.meta.errors.length > 0 ? "invalid" : e.root ? "valid" : "no_renderable_root",
|
|
816
814
|
incomplete: e.meta.incomplete,
|
|
@@ -819,25 +817,25 @@ function ht(e) {
|
|
|
819
817
|
unresolved_count: e.meta.unresolved.length,
|
|
820
818
|
orphaned_count: e.meta.orphaned.length,
|
|
821
819
|
validation_error_count: e.meta.errors.length,
|
|
822
|
-
...
|
|
820
|
+
...ct(e)
|
|
823
821
|
};
|
|
824
822
|
}
|
|
825
|
-
async function
|
|
826
|
-
let { state: n, runtime: r, environment: i } = e, [a, o] = await Promise.all([
|
|
827
|
-
await
|
|
823
|
+
async function ut(e, t) {
|
|
824
|
+
let { state: n, runtime: r, environment: i } = e, [a, o] = await Promise.all([rt(n, r), it(r)]);
|
|
825
|
+
await at(Be, {
|
|
828
826
|
distinct_id: n.runtimeId,
|
|
829
827
|
$process_person_profile: !1,
|
|
830
828
|
event_id: globalThis.crypto.randomUUID(),
|
|
831
829
|
telemetry_schema_version: 1,
|
|
832
830
|
sdk_name: "@openuidev/lang-core",
|
|
833
|
-
sdk_version:
|
|
831
|
+
sdk_version: Ue,
|
|
834
832
|
api_surface: "parser.parse",
|
|
835
833
|
runtime: r.name,
|
|
836
834
|
runtime_version: r.version,
|
|
837
835
|
environment: i,
|
|
838
836
|
ci: o.isCI,
|
|
839
837
|
...o.id ? { ci_name: o.id } : {},
|
|
840
|
-
sample_rate:
|
|
838
|
+
sample_rate: He,
|
|
841
839
|
...t,
|
|
842
840
|
...a ? {
|
|
843
841
|
project_hash_version: 1,
|
|
@@ -845,55 +843,55 @@ async function gt(e, t) {
|
|
|
845
843
|
} : {}
|
|
846
844
|
}, r);
|
|
847
845
|
}
|
|
848
|
-
function
|
|
846
|
+
function dt() {
|
|
849
847
|
try {
|
|
850
|
-
let e =
|
|
848
|
+
let e = Ze();
|
|
851
849
|
if (!e || typeof globalThis.fetch != "function" || typeof globalThis.crypto?.randomUUID != "function" || typeof globalThis.AbortSignal?.timeout != "function") return;
|
|
852
850
|
let t = e.env;
|
|
853
|
-
return !r(t) || Math.random() >=
|
|
854
|
-
state:
|
|
851
|
+
return !r(t) || Math.random() >= He ? void 0 : {
|
|
852
|
+
state: $e(),
|
|
855
853
|
runtime: e,
|
|
856
|
-
environment:
|
|
854
|
+
environment: Qe(t)
|
|
857
855
|
};
|
|
858
856
|
} catch {
|
|
859
857
|
return;
|
|
860
858
|
}
|
|
861
859
|
}
|
|
862
|
-
function
|
|
860
|
+
function ft(e, t) {
|
|
863
861
|
if (e) try {
|
|
864
|
-
let n =
|
|
865
|
-
Promise.resolve().then(() =>
|
|
862
|
+
let n = lt(t);
|
|
863
|
+
Promise.resolve().then(() => ut(e, n)).catch(() => void 0);
|
|
866
864
|
} catch {}
|
|
867
865
|
}
|
|
868
|
-
function
|
|
866
|
+
function pt(e) {
|
|
869
867
|
if (e) try {
|
|
870
|
-
Promise.resolve().then(() =>
|
|
868
|
+
Promise.resolve().then(() => ut(e, { outcome: "threw" })).catch(() => void 0);
|
|
871
869
|
} catch {}
|
|
872
870
|
}
|
|
873
|
-
var
|
|
874
|
-
function
|
|
871
|
+
var mt = /^#\/\$defs\/(.+)$/;
|
|
872
|
+
function I(e) {
|
|
875
873
|
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
876
874
|
}
|
|
877
|
-
function
|
|
875
|
+
function ht(e, t, n, r) {
|
|
878
876
|
if (Array.isArray(e)) {
|
|
879
|
-
e.forEach((e, i) =>
|
|
877
|
+
e.forEach((e, i) => ht(e, `${t}/${i}`, n, r));
|
|
880
878
|
return;
|
|
881
879
|
}
|
|
882
|
-
if (!
|
|
880
|
+
if (!I(e)) return;
|
|
883
881
|
let i = e.$ref;
|
|
884
882
|
if (typeof i == "string") {
|
|
885
|
-
let e =
|
|
883
|
+
let e = mt.exec(i);
|
|
886
884
|
(!e || !n.has(e[1])) && r.push({
|
|
887
885
|
code: "unresolved-ref",
|
|
888
886
|
message: `Unresolvable $ref "${i}" at ${t} — refs must be "#/$defs/<name>" pointing at a component in $defs.`,
|
|
889
887
|
path: t
|
|
890
888
|
});
|
|
891
889
|
}
|
|
892
|
-
for (let [i, a] of Object.entries(e)) i !== "$ref" &&
|
|
890
|
+
for (let [i, a] of Object.entries(e)) i !== "$ref" && ht(a, `${t}/${i}`, n, r);
|
|
893
891
|
}
|
|
894
|
-
function
|
|
892
|
+
function gt(e) {
|
|
895
893
|
let t = [];
|
|
896
|
-
if (!
|
|
894
|
+
if (!I(e)) return [{
|
|
897
895
|
code: "invalid-shape",
|
|
898
896
|
message: "chatLibrary must be an object."
|
|
899
897
|
}];
|
|
@@ -902,13 +900,13 @@ function St(e) {
|
|
|
902
900
|
code: "invalid-shape",
|
|
903
901
|
message: "chatLibrary.root, when present, must be a non-empty string.",
|
|
904
902
|
path: "root"
|
|
905
|
-
}), !
|
|
903
|
+
}), !I(r)) return t.push({
|
|
906
904
|
code: "invalid-shape",
|
|
907
905
|
message: "chatLibrary.schema must be an object with a $defs map of component schemas.",
|
|
908
906
|
path: "schema"
|
|
909
907
|
}), t;
|
|
910
908
|
let a = r.$defs;
|
|
911
|
-
if (!
|
|
909
|
+
if (!I(a) || Object.keys(a).length === 0) return t.push({
|
|
912
910
|
code: "invalid-shape",
|
|
913
911
|
message: "chatLibrary.schema.$defs must be a non-empty object keyed by component name.",
|
|
914
912
|
path: "schema/$defs"
|
|
@@ -921,7 +919,7 @@ function St(e) {
|
|
|
921
919
|
});
|
|
922
920
|
for (let [e, n] of Object.entries(a)) {
|
|
923
921
|
let r = `$defs/${e}`;
|
|
924
|
-
if (!
|
|
922
|
+
if (!I(n)) {
|
|
925
923
|
t.push({
|
|
926
924
|
code: "invalid-shape",
|
|
927
925
|
message: `${r} must be an object component schema.`,
|
|
@@ -930,7 +928,7 @@ function St(e) {
|
|
|
930
928
|
continue;
|
|
931
929
|
}
|
|
932
930
|
let i = n.properties;
|
|
933
|
-
i !== void 0 && !
|
|
931
|
+
i !== void 0 && !I(i) && t.push({
|
|
934
932
|
code: "invalid-shape",
|
|
935
933
|
message: `${r}/properties must be an object.`,
|
|
936
934
|
path: `${r}/properties`
|
|
@@ -942,17 +940,17 @@ function St(e) {
|
|
|
942
940
|
path: `${r}/required`
|
|
943
941
|
});
|
|
944
942
|
else {
|
|
945
|
-
let e = new Set(
|
|
943
|
+
let e = new Set(I(i) ? Object.keys(i) : []);
|
|
946
944
|
for (let n of a) e.has(n) || t.push({
|
|
947
945
|
code: "invalid-required",
|
|
948
946
|
message: `${r} lists required property "${n}" that is not in properties.`,
|
|
949
947
|
path: `${r}/required`
|
|
950
948
|
});
|
|
951
949
|
}
|
|
952
|
-
|
|
950
|
+
ht(i, `${r}/properties`, o, t);
|
|
953
951
|
}
|
|
954
952
|
for (let e of i ?? []) {
|
|
955
|
-
if (!
|
|
953
|
+
if (!I(e) || typeof e.name != "string" || !Array.isArray(e.components)) {
|
|
956
954
|
t.push({
|
|
957
955
|
code: "invalid-shape",
|
|
958
956
|
message: "Each componentGroups entry must be {name: string, components: string[], notes?: string[]}.",
|
|
@@ -968,30 +966,30 @@ function St(e) {
|
|
|
968
966
|
}
|
|
969
967
|
return t;
|
|
970
968
|
}
|
|
971
|
-
var
|
|
972
|
-
function
|
|
969
|
+
var _t = "]]>openui:config\n", vt = "0.1.0";
|
|
970
|
+
function yt(e) {
|
|
973
971
|
if (!e) return;
|
|
974
972
|
let t = {};
|
|
975
973
|
return e.examples && (t.examples = e.examples), e.preamble && (t.preamble = e.preamble), e.additionalRules && (t.additionalRules = e.additionalRules), Object.keys(t).length > 0 ? t : void 0;
|
|
976
974
|
}
|
|
977
|
-
function
|
|
975
|
+
function bt(e) {
|
|
978
976
|
let t;
|
|
979
977
|
if (e.library) {
|
|
980
|
-
let n =
|
|
978
|
+
let n = gt(e.library);
|
|
981
979
|
if (n.length > 0) throw Error(`[generateSystemPrompt] Invalid library: ${n.map((e) => e.message).join(" ")}`);
|
|
982
|
-
let { components: r, ...i } = e.library, a =
|
|
980
|
+
let { components: r, ...i } = e.library, a = yt(e.promptOptions);
|
|
983
981
|
t = {
|
|
984
982
|
chatLibrary: i,
|
|
985
983
|
...a ? { systemPromptOptions: a } : {}
|
|
986
984
|
};
|
|
987
985
|
} else {
|
|
988
|
-
if (e.promptOptions &&
|
|
989
|
-
t = { libraryVersion:
|
|
986
|
+
if (e.promptOptions && yt(e.promptOptions)) throw Error("[generateSystemPrompt] promptOptions requires a library — the built-in library ignores it.");
|
|
987
|
+
t = { libraryVersion: vt };
|
|
990
988
|
}
|
|
991
|
-
let n = `${
|
|
989
|
+
let n = `${_t}${JSON.stringify(t)}`;
|
|
992
990
|
return e.instructions ? `${n}\n${e.instructions}` : n;
|
|
993
991
|
}
|
|
994
|
-
function
|
|
992
|
+
function L(e) {
|
|
995
993
|
let t = e.type;
|
|
996
994
|
if (t === "string") {
|
|
997
995
|
let t = e.enum;
|
|
@@ -1001,19 +999,19 @@ function Dt(e) {
|
|
|
1001
999
|
if (t === "boolean") return "boolean";
|
|
1002
1000
|
if (t === "array") {
|
|
1003
1001
|
let t = e.items;
|
|
1004
|
-
return t ? `${
|
|
1002
|
+
return t ? `${L(t)}[]` : "any[]";
|
|
1005
1003
|
}
|
|
1006
1004
|
if (t === "object") {
|
|
1007
1005
|
let t = e.properties;
|
|
1008
1006
|
if (t && Object.keys(t).length > 0) {
|
|
1009
1007
|
let n = e.required ?? [];
|
|
1010
|
-
return `{${Object.entries(t).map(([e, t]) => `${e}${n.includes(e) ? "" : "?"}: ${
|
|
1008
|
+
return `{${Object.entries(t).map(([e, t]) => `${e}${n.includes(e) ? "" : "?"}: ${L(t)}`).join(", ")}}`;
|
|
1011
1009
|
}
|
|
1012
1010
|
return "object";
|
|
1013
1011
|
}
|
|
1014
1012
|
return "any";
|
|
1015
1013
|
}
|
|
1016
|
-
function
|
|
1014
|
+
function xt(e) {
|
|
1017
1015
|
let t = e.type;
|
|
1018
1016
|
if (t === "string") return "";
|
|
1019
1017
|
if (t === "number" || t === "integer") return 0;
|
|
@@ -1023,15 +1021,15 @@ function Ot(e) {
|
|
|
1023
1021
|
let t = e.properties;
|
|
1024
1022
|
if (t && Object.keys(t).length > 0) {
|
|
1025
1023
|
let e = {};
|
|
1026
|
-
for (let [n, r] of Object.entries(t)) e[n] =
|
|
1024
|
+
for (let [n, r] of Object.entries(t)) e[n] = xt(r);
|
|
1027
1025
|
return e;
|
|
1028
1026
|
}
|
|
1029
1027
|
return {};
|
|
1030
1028
|
}
|
|
1031
1029
|
return null;
|
|
1032
1030
|
}
|
|
1033
|
-
var
|
|
1034
|
-
function
|
|
1031
|
+
var St = "You are an AI assistant that responds using openui-lang, a declarative UI language. Your ENTIRE response must be valid openui-lang code — no markdown, no explanations, just openui-lang.";
|
|
1032
|
+
function Ct(e, t) {
|
|
1035
1033
|
let n = [
|
|
1036
1034
|
"## Syntax Rules",
|
|
1037
1035
|
"",
|
|
@@ -1045,13 +1043,13 @@ function At(e, t) {
|
|
|
1045
1043
|
], r = 8;
|
|
1046
1044
|
return t.bindings && n.push(`${r++}. Declare mutable state with \`$varName = defaultValue\`. Components marked with \`$binding\` can read/write these. Undeclared $variables are auto-created with null default.`), t.supportsExpressions && n.push(`${r++}. String concatenation: \`"text" + $var + "more"\``, `${r++}. Dot member access: \`query.field\` reads a field; on arrays it extracts that field from every element`, `${r++}. Index access: \`arr[0]\`, \`data[index]\``, `${r++}. Arithmetic operators: +, -, *, /, % (work on numbers; + is string concat when either side is a string)`, `${r++}. Comparison: ==, !=, >, <, >=, <=`, `${r++}. Logical: &&, ||, ! (prefix)`, `${r++}. Ternary: \`condition ? valueIfTrue : valueIfFalse\``, `${r++}. Parentheses for grouping: \`(a + b) * c\``), n.push("- Strings use double quotes with backslash escaping"), n.join("\n");
|
|
1047
1045
|
}
|
|
1048
|
-
function
|
|
1046
|
+
function R(e) {
|
|
1049
1047
|
return e.description ? `@${e.signature} — ${e.description}` : `@${e.signature}`;
|
|
1050
1048
|
}
|
|
1051
|
-
function
|
|
1052
|
-
let n = [...Object.values(
|
|
1049
|
+
function wt(e, t) {
|
|
1050
|
+
let n = [...Object.values(Oe).map((e) => R({
|
|
1053
1051
|
...e,
|
|
1054
|
-
signature:
|
|
1052
|
+
signature: le(e.name, e.params, e.returns)
|
|
1055
1053
|
})), ...e].join("\n");
|
|
1056
1054
|
return `## Built-in Functions
|
|
1057
1055
|
|
|
@@ -1068,24 +1066,24 @@ IMPORTANT @Each rule: The loop variable (e.g. "item") is ONLY available inside t
|
|
|
1068
1066
|
CORRECT: \`list = @Each(rows, "t", Comp(t.name))\`
|
|
1069
1067
|
WRONG: \`item = Comp(t.name)\` then \`list = @Each(rows, "t", item)\`, because t is undefined in item.`;
|
|
1070
1068
|
}
|
|
1071
|
-
function
|
|
1069
|
+
function Tt() {
|
|
1072
1070
|
return "## Query — Live Data Fetching\n\nFetch data from available tools. Returns defaults instantly, swaps in real data when it arrives.\n\n```\nmetrics = Query(\"tool_name\", {arg1: value, arg2: $binding}, {defaultField: 0, defaultData: []}, refreshInterval?)\n```\n\n- First arg: tool name (string)\n- Second arg: arguments object (may reference $bindings — re-fetches automatically on change)\n- Third arg: default data (rendered immediately before fetch resolves)\n- Fourth arg (optional): refresh interval in seconds (e.g. 30 for auto-refresh every 30s)\n- Use dot access on results: metrics.totalEvents, metrics.data.day (array pluck)\n- Query results must use regular identifiers: `metrics = Query(...)`, NOT `$metrics = Query(...)`\n- Manual refresh: `Button(\"Refresh\", Action([@Run(query1), @Run(query2)]), \"secondary\")` — re-fetches the listed queries\n- Refresh all queries: create Action with @Run for each query";
|
|
1073
1071
|
}
|
|
1074
|
-
function
|
|
1072
|
+
function Et() {
|
|
1075
1073
|
return "## Mutation — Write Operations\n\nExecute state-changing tool calls (create, update, delete). Unlike Query (auto-fetches on render), Mutation fires only on button click via Action.\n\n```\nresult = Mutation(\"tool_name\", {arg1: $binding, arg2: \"value\"})\n```\n\n- First arg: tool name (string)\n- Second arg: arguments object (evaluated with current $binding values at click time)\n- result.status: \"idle\" | \"loading\" | \"success\" | \"error\"\n- result.data: tool response on success\n- result.error: error message on failure\n- Mutation results use regular identifiers: `result = Mutation(...)`, NOT `$result`\n- Show loading state: `result.status == \"loading\" ? TextContent(\"Saving...\") : null`";
|
|
1076
1074
|
}
|
|
1077
|
-
var
|
|
1078
|
-
function
|
|
1079
|
-
return Object.values(
|
|
1075
|
+
var Dt = "## Action — Button Behavior";
|
|
1076
|
+
function Ot(e) {
|
|
1077
|
+
return Object.values(Ie).filter((t) => t.name === "Run" ? e.toolCalls : t.name === "Set" || t.name === "Reset" ? e.bindings : !0);
|
|
1080
1078
|
}
|
|
1081
|
-
function
|
|
1082
|
-
let n = [...
|
|
1079
|
+
function kt(e, t) {
|
|
1080
|
+
let n = [...Ot(e).map((e) => `- ${R({
|
|
1083
1081
|
...e,
|
|
1084
|
-
signature:
|
|
1082
|
+
signature: le(e.name, e.params)
|
|
1085
1083
|
})}`), ...t], r = [];
|
|
1086
1084
|
e.toolCalls && r.push("Example — mutation + refresh + reset (PREFERRED pattern):\n```\n$binding = \"default\"\nresult = Mutation(\"tool_name\", {field: $binding})\ndata = Query(\"tool_name\", {}, {rows: []})\nonSubmit = Action([@Run(result), @Run(data), @Reset($binding)])\n```"), r.push("Example — simple nav:\n```\nviewBtn = Button(\"View\", @OpenUrl(\"https://example.com\"))\n```");
|
|
1087
1085
|
let i = ["- An action can be assigned to a variable or inlined: Button(\"Go\", onSubmit) and Button(\"Go\", Action([...])) both work"];
|
|
1088
|
-
return e.toolCalls && i.push("- If a @Run(mutation) step fails, remaining steps are skipped (halt on failure)", "- @Run(queryRef) re-fetches the query (fire-and-forget, cannot fail)"), `${
|
|
1086
|
+
return e.toolCalls && i.push("- If a @Run(mutation) step fails, remaining steps are skipped (halt on failure)", "- @Run(queryRef) re-fetches the query (fire-and-forget, cannot fail)"), `${Dt}
|
|
1089
1087
|
|
|
1090
1088
|
An action wires a button click to operations. Pass one @-prefixed step bare, e.g. Button("Ask", @ToAssistant("Tell me more")). Put several steps in Action([...]), e.g. Button("Read", Action([@OpenUrl("https://example.com"), @ToAssistant("Summarize this page")])). Steps execute in order.
|
|
1091
1089
|
Buttons without an action automatically send their label to the assistant (equivalent to @ToAssistant(label)).
|
|
@@ -1097,13 +1095,13 @@ ${r.join("\n\n")}
|
|
|
1097
1095
|
|
|
1098
1096
|
${i.join("\n")}`;
|
|
1099
1097
|
}
|
|
1100
|
-
function
|
|
1098
|
+
function At() {
|
|
1101
1099
|
return "## Interactive Filters\n\nTo let the user filter data with a dropdown:\n1. Declare a $variable with a default: `$dateRange = \"14\"`\n2. Create a Select with name, items, and binding: `Select(\"dateRange\", [SelectItem(\"7\", \"Last 7 days\"), ...], null, null, $dateRange)`\n3. Wrap in FormControl for a label: `FormControl(\"Date Range\", Select(...))`\n4. Pass $dateRange in Query args: `Query(\"tool\", {dateRange: $dateRange}, {defaults})`\n5. When the user changes the Select, $dateRange updates and the Query automatically re-fetches\n\nFILTER WIRING RULE: If a $binding filter is visible in the UI, EVERY relevant Query MUST reference that $binding in its args. Never show a filter dropdown while hardcoding the query args.\n\nRules for $variables:\n- $variables hold simple values (strings or numbers), NOT arrays or objects\n- $variables must be bound to a Select/Input component via the value argument (last positional arg) to be interactive\n- Queries must use regular identifiers (NOT $variables): `metrics = Query(...)` not `$metrics = Query(...)`\n- **Auto-declare**: You do NOT need to explicitly declare $variables. If you use `$foo` without declaring it, the parser auto-creates `$foo = null`. You can still declare explicitly to set a default: `$days = \"14\"`\n\n## Forms\n\nSimple form — no $bindings needed. Field values are managed internally by the Form via the name prop:\n```\ncontactForm = Form(\"contact\", submitBtn, [nameField, emailField])\nnameField = FormControl(\"Name\", Input(\"name\", \"Your name\", \"text\", {required: true}))\nemailField = FormControl(\"Email\", Input(\"email\", \"your@email.com\", \"email\", {required: true, email: true}))\nsubmitBtn = Button(\"Submit\")\n```\n\nUse $bindings when you need to read field values elsewhere (in Action context, Query args, or conditionals). They are auto-declared:\n```\n$role = \"engineer\"\ncontactForm = Form(\"contact\", submitBtn, [nameField, emailField, roleField])\nnameField = FormControl(\"Name\", Input(\"name\", \"Enter your name\", \"text\", {required: true}, $name))\nemailField = FormControl(\"Email\", Input(\"email\", \"Enter your email\", \"email\", {required: true, email: true}, $email))\nroleField = FormControl(\"Role\", Select(\"role\", [SelectItem(\"engineer\", \"Engineer\"), SelectItem(\"designer\", \"Designer\"), SelectItem(\"pm\", \"PM\")], null, {required: true}, $role))\nsubmitBtn = Button(\"Submit\")\n```\n\nFor form + mutation patterns (create, refresh, reset), see the Action section example above.\n\nIMPORTANT: Always add validation rules to form fields used with Mutations. Use OBJECT syntax: {required: true, email: true, minLength: 8}. The renderer shows error messages automatically and blocks submit when validation fails.";
|
|
1102
1100
|
}
|
|
1103
|
-
function
|
|
1101
|
+
function jt() {
|
|
1104
1102
|
return "## Edit Mode\n\nThe runtime merges by statement name: same name = replace, new name = append.\nOutput ONLY statements that changed or are new. Everything else is kept automatically.\n\n### Delete\nTo remove a component, re-declare its parent without that component in the parent's children array. The removed component and any statements only it referenced are automatically garbage-collected.\n\n### Patch size guide\n- Changing a title or label: 1 statement\n- Adding a component: 2-3 statements (the new component + parent update)\n- Removing a component: 1 statement (re-declare parent without the removed child)\n- Adding a filter + wiring to query: 3-5 statements\n- Restructuring into tabs: 5-10 statements\n\n### Rules\n- Reuse existing statement names exactly — do not rename\n- Do NOT re-emit unchanged statements — the runtime keeps them\n- A typical edit patch is 1-10 statements, not 20+\n- If the existing code already satisfies the request, output only the root statement\n- NEVER output the entire program as a patch. Only output what actually changes\n- If you are about to output more than 10 statements, reconsider — most edits need fewer";
|
|
1105
1103
|
}
|
|
1106
|
-
function
|
|
1104
|
+
function Mt(e, t) {
|
|
1107
1105
|
let n = [`1. \`root = ${e}(...)\` — UI shell appears immediately`];
|
|
1108
1106
|
if (t.supportsExpressions) {
|
|
1109
1107
|
n.push("2. $variable declarations — state ready for bindings"), t.toolCalls && n.push("3. Query statements — defaults resolve immediately so components render with data");
|
|
@@ -1121,13 +1119,13 @@ ${n.join("\n")}
|
|
|
1121
1119
|
|
|
1122
1120
|
Always write the root = ${e}(...) statement first so the UI shell appears immediately, even before child data has streamed in.`;
|
|
1123
1121
|
}
|
|
1124
|
-
function
|
|
1122
|
+
function Nt() {
|
|
1125
1123
|
return "## Inline Mode\n\nYou are in inline mode. You can respond in two ways:\n\n### 1. Code response (when the user wants to CREATE or CHANGE the UI)\nWrap openui-lang code in triple-backtick fences. You can include explanatory text before/after:\n\nHere's your dashboard:\n\n```openui-lang\nroot = RootComp([header, content])\nheader = SomeHeader(\"Title\")\ncontent = SomeContent(\"Hello world\")\n```\n\nI created a simple layout with a header.\n\n### 2. Text-only response (when the user asks a QUESTION)\nIf the user asks \"what is this?\", \"explain the chart\", \"how does this work\", etc. — respond with plain text. Do NOT output any openui-lang code. The existing dashboard stays unchanged.\n\n### Rules\n- When the user asks for changes, output ONLY the changed/new statements in a fenced block\n- When the user asks a question, respond with text only — NO code. The dashboard stays unchanged.\n- The parser extracts code from fences automatically. Text outside fences is shown as chat.";
|
|
1126
1124
|
}
|
|
1127
|
-
function
|
|
1125
|
+
function Pt() {
|
|
1128
1126
|
return "## Data Workflow\n\nWhen tools are available, follow this workflow:\n1. FIRST: Call the most relevant tool to inspect the real data shape before generating code\n2. Use Query() for READ operations (data that should stay live) — NEVER hardcode tool results as literal arrays or objects\n3. Use Mutation() for WRITE operations (create, update, delete) — triggered by button clicks via @Run(mutationRef)\n4. Use the real data from step 1 as condensed Query defaults (3-5 rows) so the UI renders immediately\n5. Use @-prefixed builtins (@Count, @Filter, @Sort, @Sum) on Query results for KPIs and aggregations — the runtime evaluates these live on every refresh\n6. Hardcoded arrays are ONLY for static display data (labels, options) where no tool exists\n\nWRONG — you called a tool and got data back, but you inlined the results:\n```\nopenCount = 2\nitem1 = SomeComp(\"first item title\")\nitem2 = SomeComp(\"second item title\")\nlist = SomeList([item1, item2])\nchart = SomeChart([\"A\", \"B\"], [12, 8])\n```\nThis is static — it shows stale data and won't update. Creating item1, item2, item3... manually is ALWAYS wrong when a tool exists.\n\nRIGHT — use Query() for live data, Mutation() for writes, @builtins to derive values:\n```\ndata = Query(\"tool_name\", {}, {rows: []})\nopenCount = @Count(@Filter(data.rows, \"field\", \"==\", \"value\"))\nlist = @Each(data.rows, \"item\", SomeComp(item.title, item.field))\ncreateResult = Mutation(\"create_tool\", {title: $title})\nsubmitBtn = Button(\"Create\", Action([@Run(createResult), @Run(data), @Reset($title)]))\n```\nEverything derives from the Query — when data refreshes, the entire dashboard updates automatically.";
|
|
1129
1127
|
}
|
|
1130
|
-
function
|
|
1128
|
+
function Ft(e, t) {
|
|
1131
1129
|
let n = [`1. root = ${e}(...) is the FIRST line (for optimal streaming).`, "2. Every referenced name is defined. Every defined name (other than root) is reachable from root."];
|
|
1132
1130
|
return t.toolCalls && n.push("3. Every Query result is referenced by at least one component."), t.bindings && n.push(`${t.toolCalls ? "4" : "3"}. Every $binding appears in at least one component or expression.`), t.toolCalls && t.bindings && n.push("5. Every visible filter $binding appears in at least one Query args object."), `## Important Rules
|
|
1133
1131
|
- Choose components that best represent the content (tables for comparisons, charts for trends, forms for input, etc.)
|
|
@@ -1136,43 +1134,43 @@ function Ht(e, t) {
|
|
|
1136
1134
|
Before finishing, walk your output and verify:
|
|
1137
1135
|
${n.join("\n")}`;
|
|
1138
1136
|
}
|
|
1139
|
-
function
|
|
1137
|
+
function It(e) {
|
|
1140
1138
|
let t = "";
|
|
1141
1139
|
if (e.inputSchema) {
|
|
1142
1140
|
let n = e.inputSchema.properties, r = e.inputSchema.required ?? [];
|
|
1143
|
-
n && Object.keys(n).length > 0 && (t = Object.entries(n).map(([e, t]) => `${e}${r.includes(e) ? "" : "?"}: ${
|
|
1141
|
+
n && Object.keys(n).length > 0 && (t = Object.entries(n).map(([e, t]) => `${e}${r.includes(e) ? "" : "?"}: ${L(t)}`).join(", "));
|
|
1144
1142
|
}
|
|
1145
1143
|
let n = "";
|
|
1146
|
-
e.outputSchema && (n = ` → ${
|
|
1144
|
+
e.outputSchema && (n = ` → ${L(e.outputSchema)}`);
|
|
1147
1145
|
let r = `- ${e.name}(${t})${n}`;
|
|
1148
1146
|
return e.description && (r += `\n ${e.description}`), r;
|
|
1149
1147
|
}
|
|
1150
|
-
function
|
|
1148
|
+
function Lt(e) {
|
|
1151
1149
|
let t = [], n = [], r = [];
|
|
1152
1150
|
for (let t of e) typeof t == "string" ? n.push(t) : r.push(t);
|
|
1153
1151
|
t.push("## Available Tools"), t.push(""), t.push("Use these with Query() for read operations or Mutation() for write operations. The LLM decides which is appropriate based on the tool's purpose."), t.push("");
|
|
1154
1152
|
for (let e of n) t.push(`- ${e}`);
|
|
1155
|
-
for (let e of r) t.push(
|
|
1153
|
+
for (let e of r) t.push(It(e));
|
|
1156
1154
|
let i = r.filter((e) => e.outputSchema);
|
|
1157
1155
|
if (i.length > 0) {
|
|
1158
1156
|
t.push(""), t.push("### Default values for Query results"), t.push(""), t.push("Use these shapes as minimal Query defaults:");
|
|
1159
1157
|
for (let e of i) {
|
|
1160
|
-
let n =
|
|
1158
|
+
let n = xt(e.outputSchema);
|
|
1161
1159
|
t.push(`- ${e.name}: \`${JSON.stringify(n)}\``);
|
|
1162
1160
|
}
|
|
1163
1161
|
}
|
|
1164
1162
|
return t.push(""), t.push("CRITICAL: Use ONLY the tools listed above in Query() and Mutation() calls. Do NOT invent or guess tool names. If the user asks for functionality that doesn't match any available tool, use realistic mock data instead of fabricating a tool call."), t.join("\n");
|
|
1165
1163
|
}
|
|
1166
|
-
var
|
|
1167
|
-
function
|
|
1164
|
+
var Rt = /[:|] @[A-Z]/;
|
|
1165
|
+
function zt(e, t) {
|
|
1168
1166
|
let n = [
|
|
1169
1167
|
"## Component Signatures",
|
|
1170
1168
|
"",
|
|
1171
1169
|
"Arguments marked with ? are optional. Sub-components can be inline or referenced; prefer references for better streaming."
|
|
1172
1170
|
];
|
|
1173
1171
|
if (t.usesActionExpression) {
|
|
1174
|
-
let r = [...
|
|
1175
|
-
n.push(`Props typed \`ActionExpression\` accept one @step, or Action([@steps...]) for several. See the Action section for available steps (${r.join(", ")}).`), Object.values(e.components).some((e) =>
|
|
1172
|
+
let r = [...Ot(t).map((e) => e.name), ...Object.keys(e.actions ?? {})].map((e) => `@${e}`);
|
|
1173
|
+
n.push(`Props typed \`ActionExpression\` accept one @step, or Action([@steps...]) for several. See the Action section for available steps (${r.join(", ")}).`), Object.values(e.components).some((e) => Rt.test(e.signature ?? "")) && n.push("Props typed like `@OpenUrl | @ToAssistant` accept only the steps listed.");
|
|
1176
1174
|
}
|
|
1177
1175
|
(t.bindings || Object.values(e.components).some((e) => e.signature?.includes("$binding"))) && n.push("Props marked `$binding<type>` accept a `$variable` reference for two-way binding.");
|
|
1178
1176
|
let r = (e) => e.description ? `${e.signature} — ${e.description}` : e.signature;
|
|
@@ -1201,23 +1199,23 @@ function Kt(e, t) {
|
|
|
1201
1199
|
}
|
|
1202
1200
|
return n.join("\n");
|
|
1203
1201
|
}
|
|
1204
|
-
function
|
|
1205
|
-
let t = e.root ?? "Root", n = !!e.tools?.length, r = e.toolCalls ?? n, i = e.bindings ?? r, a = r || i, o = Object.values(e.components).some((e) => e.signature?.includes("ActionExpression") ||
|
|
1206
|
-
s.push(e.preamble ??
|
|
1202
|
+
function z(e) {
|
|
1203
|
+
let t = e.root ?? "Root", n = !!e.tools?.length, r = e.toolCalls ?? n, i = e.bindings ?? r, a = r || i, o = Object.values(e.components).some((e) => e.signature?.includes("ActionExpression") || Rt.test(e.signature ?? "")), s = [];
|
|
1204
|
+
s.push(e.preamble ?? St), s.push(""), s.push(Ct(t, {
|
|
1207
1205
|
supportsExpressions: a,
|
|
1208
1206
|
bindings: i
|
|
1209
|
-
})), s.push(""), s.push(
|
|
1207
|
+
})), s.push(""), s.push(zt(e, {
|
|
1210
1208
|
toolCalls: r,
|
|
1211
1209
|
bindings: i,
|
|
1212
1210
|
usesActionExpression: o
|
|
1213
1211
|
}));
|
|
1214
|
-
let c = Object.values(e.functions ?? {}).map(
|
|
1215
|
-
e.builtinFunctions ?? a ? (s.push(""), s.push(
|
|
1216
|
-
let l = Object.values(e.actions ?? {}).map((e) => `- ${
|
|
1217
|
-
o ? (s.push(""), s.push(
|
|
1212
|
+
let c = Object.values(e.functions ?? {}).map(R);
|
|
1213
|
+
e.builtinFunctions ?? a ? (s.push(""), s.push(wt(c, r))) : c.length && (s.push(""), s.push(`## Built-in Functions\n\n${c.join("\n")}`)), r && (s.push(""), s.push(Tt()), s.push(""), s.push(Et()));
|
|
1214
|
+
let l = Object.values(e.actions ?? {}).map((e) => `- ${R(e)}`);
|
|
1215
|
+
o ? (s.push(""), s.push(kt({
|
|
1218
1216
|
toolCalls: r,
|
|
1219
1217
|
bindings: i
|
|
1220
|
-
}, l))) : l.length && (s.push(""), s.push(`${
|
|
1218
|
+
}, l))) : l.length && (s.push(""), s.push(`${Dt}\n\nPass one step, or Action([...]) with several steps, as a button's action.\n\nAvailable steps:\n${l.join("\n")}`)), r && i && (s.push(""), s.push(At())), r && (s.push(""), s.push(Pt())), e.tools?.length && (s.push(""), s.push(Lt(e.tools))), s.push(""), s.push(Mt(t, {
|
|
1221
1219
|
supportsExpressions: a,
|
|
1222
1220
|
toolCalls: r
|
|
1223
1221
|
}));
|
|
@@ -1226,7 +1224,7 @@ function qt(e) {
|
|
|
1226
1224
|
s.push(""), s.push("## Examples"), s.push("");
|
|
1227
1225
|
for (let e of u) s.push(e), s.push("");
|
|
1228
1226
|
}
|
|
1229
|
-
if (e.editMode && (s.push(""), s.push(
|
|
1227
|
+
if (e.editMode && (s.push(""), s.push(jt())), e.inlineMode && (s.push(""), s.push(Nt())), s.push(Ft(t, {
|
|
1230
1228
|
toolCalls: r,
|
|
1231
1229
|
bindings: i
|
|
1232
1230
|
})), e.additionalRules?.length) {
|
|
@@ -1235,69 +1233,69 @@ function qt(e) {
|
|
|
1235
1233
|
}
|
|
1236
1234
|
return s.join("\n");
|
|
1237
1235
|
}
|
|
1238
|
-
function
|
|
1239
|
-
if (
|
|
1240
|
-
if (!
|
|
1241
|
-
let t =
|
|
1242
|
-
return
|
|
1236
|
+
function Bt(e) {
|
|
1237
|
+
if (Vt(e)) return bt(e);
|
|
1238
|
+
if (!Ht(e)) {
|
|
1239
|
+
let t = z(e);
|
|
1240
|
+
return st(e, "legacy_prompt_spec"), t;
|
|
1243
1241
|
}
|
|
1244
1242
|
let t = {
|
|
1245
1243
|
...e.library,
|
|
1246
1244
|
...e.promptOptions
|
|
1247
|
-
}, n =
|
|
1248
|
-
return
|
|
1245
|
+
}, n = z(t);
|
|
1246
|
+
return st(t, "library_spec"), n;
|
|
1249
1247
|
}
|
|
1250
|
-
function
|
|
1248
|
+
function Vt(e) {
|
|
1251
1249
|
return "cloud" in e && e.cloud === !0;
|
|
1252
1250
|
}
|
|
1253
|
-
function
|
|
1251
|
+
function Ht(e) {
|
|
1254
1252
|
return "library" in e && typeof e.library == "object";
|
|
1255
1253
|
}
|
|
1256
|
-
function
|
|
1257
|
-
return
|
|
1254
|
+
function Ut(e) {
|
|
1255
|
+
return _(e.props, e.name), p(e.props, e.name), {
|
|
1258
1256
|
...e,
|
|
1259
1257
|
ref: e.props
|
|
1260
1258
|
};
|
|
1261
1259
|
}
|
|
1262
|
-
function
|
|
1260
|
+
function Wt(e, t) {
|
|
1263
1261
|
let n = {};
|
|
1264
1262
|
for (let [r, i] of Object.entries(e)) n[r] = {
|
|
1265
|
-
signature:
|
|
1263
|
+
signature: le(r, i.props, void 0, t),
|
|
1266
1264
|
description: i.description
|
|
1267
1265
|
};
|
|
1268
1266
|
return n;
|
|
1269
1267
|
}
|
|
1270
|
-
function
|
|
1268
|
+
function Gt(e, t) {
|
|
1271
1269
|
let n = Object.entries(e);
|
|
1272
1270
|
if (!n.length) return;
|
|
1273
1271
|
let r = {};
|
|
1274
1272
|
for (let [e, i] of n) r[e] = {
|
|
1275
|
-
signature:
|
|
1273
|
+
signature: le(e, i.params, "returns" in i ? i.returns : void 0, t),
|
|
1276
1274
|
description: i.description
|
|
1277
1275
|
};
|
|
1278
1276
|
return r;
|
|
1279
1277
|
}
|
|
1280
|
-
var
|
|
1281
|
-
function
|
|
1282
|
-
return typeof globalThis.crypto?.randomUUID == "function" ? globalThis.crypto.randomUUID() : (
|
|
1278
|
+
var Kt = 0;
|
|
1279
|
+
function qt() {
|
|
1280
|
+
return typeof globalThis.crypto?.randomUUID == "function" ? globalThis.crypto.randomUUID() : (Kt += 1, `openui-lib-${Date.now().toString(36)}-${Kt.toString(36)}`);
|
|
1283
1281
|
}
|
|
1284
|
-
function
|
|
1285
|
-
let t = {}, n = c(), r =
|
|
1282
|
+
function Jt(e) {
|
|
1283
|
+
let t = {}, n = c.registry(), r = qt();
|
|
1286
1284
|
for (let r of e.components) n.add(r.props, { id: r.name }), t[r.name] = r;
|
|
1287
|
-
for (let [e, r] of Object.entries(
|
|
1285
|
+
for (let [e, r] of Object.entries(Pe)) t[e] || n.add(r, { id: e });
|
|
1288
1286
|
if (e.root && !t[e.root]) {
|
|
1289
1287
|
let n = Object.keys(t).join(", ");
|
|
1290
1288
|
throw Error(`[createLibrary] Root component "${e.root}" was not found in components. Available components: ${n}`);
|
|
1291
1289
|
}
|
|
1292
1290
|
let i = new Set(Object.keys(t)), a = (e, t) => {
|
|
1293
|
-
if (
|
|
1291
|
+
if (N(t) || F(t) || i.has(t)) throw Error(`[createLibrary] ${e} "${t}" collides with a built-in, component, function, or action of the same name. Rename it.`);
|
|
1294
1292
|
i.add(t);
|
|
1295
|
-
},
|
|
1296
|
-
for (let t of e.functions ?? []) a("Function", t.name),
|
|
1297
|
-
let
|
|
1298
|
-
for (let t of e.actions ?? []) a("Action", t.name),
|
|
1293
|
+
}, s = {};
|
|
1294
|
+
for (let t of e.functions ?? []) a("Function", t.name), s[t.name] = t;
|
|
1295
|
+
let l = {};
|
|
1296
|
+
for (let t of e.actions ?? []) a("Action", t.name), l[t.name] = t, n.add(t.ref, { id: t.name });
|
|
1299
1297
|
let u = () => {
|
|
1300
|
-
let e =
|
|
1298
|
+
let e = Gt(s, n), t = Gt(l, n);
|
|
1301
1299
|
return {
|
|
1302
1300
|
...e ? { functions: e } : {},
|
|
1303
1301
|
...t ? { actions: t } : {}
|
|
@@ -1305,15 +1303,15 @@ function nn(e) {
|
|
|
1305
1303
|
}, d = {
|
|
1306
1304
|
components: t,
|
|
1307
1305
|
componentGroups: e.componentGroups,
|
|
1308
|
-
functions:
|
|
1309
|
-
actions:
|
|
1306
|
+
functions: s,
|
|
1307
|
+
actions: l,
|
|
1310
1308
|
root: e.root,
|
|
1311
1309
|
id: e.id,
|
|
1312
1310
|
__libraryId: r,
|
|
1313
1311
|
prompt(r) {
|
|
1314
|
-
return
|
|
1312
|
+
return z({
|
|
1315
1313
|
root: e.root,
|
|
1316
|
-
components:
|
|
1314
|
+
components: Wt(t, n),
|
|
1317
1315
|
componentGroups: e.componentGroups,
|
|
1318
1316
|
...u(),
|
|
1319
1317
|
...r
|
|
@@ -1322,7 +1320,7 @@ function nn(e) {
|
|
|
1322
1320
|
toSpec() {
|
|
1323
1321
|
return {
|
|
1324
1322
|
root: e.root,
|
|
1325
|
-
components:
|
|
1323
|
+
components: Wt(t, n),
|
|
1326
1324
|
componentGroups: e.componentGroups,
|
|
1327
1325
|
...u(),
|
|
1328
1326
|
schema: m(),
|
|
@@ -1333,11 +1331,11 @@ function nn(e) {
|
|
|
1333
1331
|
return m();
|
|
1334
1332
|
},
|
|
1335
1333
|
extend(t) {
|
|
1336
|
-
return
|
|
1334
|
+
return Jt(ue(e, t));
|
|
1337
1335
|
}
|
|
1338
1336
|
};
|
|
1339
1337
|
function f(e) {
|
|
1340
|
-
let { $schema: t, $defs: r, ...i } =
|
|
1338
|
+
let { $schema: t, $defs: r, ...i } = c.toJSONSchema(e, { metadata: n });
|
|
1341
1339
|
return i;
|
|
1342
1340
|
}
|
|
1343
1341
|
function p(e) {
|
|
@@ -1349,37 +1347,37 @@ function nn(e) {
|
|
|
1349
1347
|
}]));
|
|
1350
1348
|
}
|
|
1351
1349
|
function m() {
|
|
1352
|
-
let e =
|
|
1353
|
-
for (let [
|
|
1354
|
-
let t =
|
|
1355
|
-
t &&
|
|
1350
|
+
let e = o(Object.fromEntries(Object.entries(t).map(([e, t]) => [e, t.props]))), r = c.toJSONSchema(e, { metadata: n });
|
|
1351
|
+
for (let [e, n] of Object.entries(t)) {
|
|
1352
|
+
let t = r.$defs?.[e];
|
|
1353
|
+
t && n.description && (t.description = n.description);
|
|
1356
1354
|
}
|
|
1357
|
-
let r = p(o);
|
|
1358
|
-
r && (e.functions = r);
|
|
1359
1355
|
let i = p(s);
|
|
1360
|
-
|
|
1356
|
+
i && (r.functions = i);
|
|
1357
|
+
let a = p(l);
|
|
1358
|
+
return a && (r.actions = a), r;
|
|
1361
1359
|
}
|
|
1362
1360
|
return d;
|
|
1363
1361
|
}
|
|
1364
|
-
var
|
|
1362
|
+
var B = "]]>openui:", Yt = /^\]\]>openui:([a-z]+)(?:\?(.*))?$/, Xt = /([^\n])(?=\]\]>openui:content(?:\?|\r?\n|$))/g, Zt = /[^\n](\]\]>[a-z:]*)$/, Qt = (e) => encodeURIComponent(e).replace(/[!'()~]/g, (e) => `%${e.charCodeAt(0).toString(16).toUpperCase()}`).replace(/%20/g, "+"), $t = (e) => {
|
|
1365
1363
|
try {
|
|
1366
1364
|
return decodeURIComponent(e.replace(/\+/g, " "));
|
|
1367
1365
|
} catch {
|
|
1368
1366
|
return e;
|
|
1369
1367
|
}
|
|
1370
1368
|
};
|
|
1371
|
-
function
|
|
1369
|
+
function en(e = "") {
|
|
1372
1370
|
let t = {};
|
|
1373
1371
|
for (let n of e.split("&")) {
|
|
1374
|
-
let e = n.indexOf("="), r =
|
|
1375
|
-
r && (t[r] = e === -1 ? "" :
|
|
1372
|
+
let e = n.indexOf("="), r = $t(e === -1 ? n : n.slice(0, e));
|
|
1373
|
+
r && (t[r] = e === -1 ? "" : $t(n.slice(e + 1)));
|
|
1376
1374
|
}
|
|
1377
1375
|
return t;
|
|
1378
1376
|
}
|
|
1379
|
-
function
|
|
1380
|
-
let n = e.replace(
|
|
1381
|
-
r && `${
|
|
1382
|
-
let i = n.split("\n"), a = i[i.length - 1], o = t && a !== "" && (a.startsWith(
|
|
1377
|
+
function tn(e, { streaming: t } = {}) {
|
|
1378
|
+
let n = e.replace(Xt, "$1\n"), r = t ? Zt.exec(n) : null;
|
|
1379
|
+
r && `${B}content`.startsWith(r[1]) && (n = n.slice(0, r.index + 1));
|
|
1380
|
+
let i = n.split("\n"), a = i[i.length - 1], o = t && a !== "" && (a.startsWith(B) || B.startsWith(a));
|
|
1383
1381
|
o && i.pop();
|
|
1384
1382
|
let s = [{
|
|
1385
1383
|
kind: null,
|
|
@@ -1390,7 +1388,7 @@ function un(e, { streaming: t } = {}) {
|
|
|
1390
1388
|
e.length && (e[e.length - 1] = e[e.length - 1].replace(/\r$/, ""));
|
|
1391
1389
|
}, l = -1;
|
|
1392
1390
|
for (let [e, t] of i.entries()) {
|
|
1393
|
-
let n =
|
|
1391
|
+
let n = Yt.exec(t.replace(/\r$/, ""));
|
|
1394
1392
|
if (!n) {
|
|
1395
1393
|
s[s.length - 1].lines.push(t);
|
|
1396
1394
|
continue;
|
|
@@ -1401,7 +1399,7 @@ function un(e, { streaming: t } = {}) {
|
|
|
1401
1399
|
}
|
|
1402
1400
|
s.push({
|
|
1403
1401
|
kind: n[1],
|
|
1404
|
-
attributes:
|
|
1402
|
+
attributes: en(n[2]),
|
|
1405
1403
|
lines: []
|
|
1406
1404
|
});
|
|
1407
1405
|
}
|
|
@@ -1418,19 +1416,19 @@ function un(e, { streaming: t } = {}) {
|
|
|
1418
1416
|
end: h
|
|
1419
1417
|
};
|
|
1420
1418
|
}
|
|
1421
|
-
function
|
|
1422
|
-
let i = Object.entries(n ?? {}).map(([e, t]) => `${
|
|
1423
|
-
return t != null && (a += `\n${
|
|
1419
|
+
function nn({ content: e, context: t, attributes: n, end: r }) {
|
|
1420
|
+
let i = Object.entries(n ?? {}).map(([e, t]) => `${Qt(e)}=${Qt(t)}`).join("&"), a = `${B}content${i ? `?${i}` : ""}\n${e}`;
|
|
1421
|
+
return t != null && (a += `\n${B}context\n${typeof t == "string" ? t : JSON.stringify(t)}`), r ? `${a}\n${B}end` : a;
|
|
1424
1422
|
}
|
|
1425
|
-
function
|
|
1423
|
+
function V(e) {
|
|
1426
1424
|
if (!e || typeof e != "object" || Array.isArray(e)) return !1;
|
|
1427
1425
|
let t = e;
|
|
1428
1426
|
return t.type === "element" && typeof t.typeName == "string" && typeof t.props == "object" && t.props !== null && typeof t.partial == "boolean";
|
|
1429
1427
|
}
|
|
1430
|
-
var
|
|
1428
|
+
var rn = /* @__PURE__ */ function(e) {
|
|
1431
1429
|
return e.ContinueConversation = "continue_conversation", e.OpenUrl = "open_url", e;
|
|
1432
1430
|
}({});
|
|
1433
|
-
function
|
|
1431
|
+
function an(e) {
|
|
1434
1432
|
switch (e.k) {
|
|
1435
1433
|
case "StateRef":
|
|
1436
1434
|
case "RuntimeRef":
|
|
@@ -1443,7 +1441,7 @@ function pn(e) {
|
|
|
1443
1441
|
default: return !1;
|
|
1444
1442
|
}
|
|
1445
1443
|
}
|
|
1446
|
-
var
|
|
1444
|
+
var on = new Set([
|
|
1447
1445
|
"Comp",
|
|
1448
1446
|
"Ref",
|
|
1449
1447
|
"StateRef",
|
|
@@ -1462,10 +1460,10 @@ var mn = new Set([
|
|
|
1462
1460
|
"Obj",
|
|
1463
1461
|
"Ph"
|
|
1464
1462
|
]);
|
|
1465
|
-
function
|
|
1466
|
-
return !e || typeof e != "object" || Array.isArray(e) ? !1 :
|
|
1463
|
+
function H(e) {
|
|
1464
|
+
return !e || typeof e != "object" || Array.isArray(e) ? !1 : on.has(e.k);
|
|
1467
1465
|
}
|
|
1468
|
-
function
|
|
1466
|
+
function U(e, t) {
|
|
1469
1467
|
let n = (e) => {
|
|
1470
1468
|
switch (t(e), e.k) {
|
|
1471
1469
|
case "Comp":
|
|
@@ -1499,7 +1497,7 @@ function hn(e, t) {
|
|
|
1499
1497
|
};
|
|
1500
1498
|
n(e);
|
|
1501
1499
|
}
|
|
1502
|
-
function
|
|
1500
|
+
function sn(e) {
|
|
1503
1501
|
return e == null ? { k: "Null" } : typeof e == "string" ? {
|
|
1504
1502
|
k: "Str",
|
|
1505
1503
|
v: e
|
|
@@ -1511,13 +1509,13 @@ function gn(e) {
|
|
|
1511
1509
|
v: e
|
|
1512
1510
|
} : Array.isArray(e) ? {
|
|
1513
1511
|
k: "Arr",
|
|
1514
|
-
els: e.map(
|
|
1512
|
+
els: e.map(sn)
|
|
1515
1513
|
} : typeof e == "object" ? {
|
|
1516
1514
|
k: "Obj",
|
|
1517
|
-
entries: Object.entries(e).map(([e, t]) => [e,
|
|
1515
|
+
entries: Object.entries(e).map(([e, t]) => [e, sn(t)])
|
|
1518
1516
|
} : { k: "Null" };
|
|
1519
1517
|
}
|
|
1520
|
-
function
|
|
1518
|
+
function cn(e) {
|
|
1521
1519
|
switch (e.k) {
|
|
1522
1520
|
case "Str":
|
|
1523
1521
|
case "Num":
|
|
@@ -1526,7 +1524,7 @@ function _n(e) {
|
|
|
1526
1524
|
case "Arr": {
|
|
1527
1525
|
let t = [];
|
|
1528
1526
|
for (let n of e.els) {
|
|
1529
|
-
let e =
|
|
1527
|
+
let e = cn(n);
|
|
1530
1528
|
if (!e) return;
|
|
1531
1529
|
t.push(e.v);
|
|
1532
1530
|
}
|
|
@@ -1535,7 +1533,7 @@ function _n(e) {
|
|
|
1535
1533
|
case "Obj": {
|
|
1536
1534
|
let t = {};
|
|
1537
1535
|
for (let [n, r] of e.entries) {
|
|
1538
|
-
let e =
|
|
1536
|
+
let e = cn(r);
|
|
1539
1537
|
if (!e) return;
|
|
1540
1538
|
t[n] = e.v;
|
|
1541
1539
|
}
|
|
@@ -1544,8 +1542,8 @@ function _n(e) {
|
|
|
1544
1542
|
default: return;
|
|
1545
1543
|
}
|
|
1546
1544
|
}
|
|
1547
|
-
var
|
|
1548
|
-
function
|
|
1545
|
+
var ln = 1, un = 2, dn = 3, fn = 4, W = 5, pn = 6, mn = 7, hn = 8, gn = 9;
|
|
1546
|
+
function _n(e) {
|
|
1549
1547
|
let t = 0, n = () => e[t] ?? { t: 13 }, r = () => {
|
|
1550
1548
|
let e = n();
|
|
1551
1549
|
return t++, e;
|
|
@@ -1554,22 +1552,22 @@ function En(e) {
|
|
|
1554
1552
|
};
|
|
1555
1553
|
function a(e) {
|
|
1556
1554
|
switch (e.t) {
|
|
1557
|
-
case 34: return
|
|
1558
|
-
case 32: return
|
|
1559
|
-
case 31: return
|
|
1555
|
+
case 34: return ln;
|
|
1556
|
+
case 32: return un;
|
|
1557
|
+
case 31: return dn;
|
|
1560
1558
|
case 25:
|
|
1561
|
-
case 26: return
|
|
1559
|
+
case 26: return fn;
|
|
1562
1560
|
case 27:
|
|
1563
1561
|
case 28:
|
|
1564
1562
|
case 29:
|
|
1565
|
-
case 30: return
|
|
1563
|
+
case 30: return W;
|
|
1566
1564
|
case 20:
|
|
1567
|
-
case 21: return
|
|
1565
|
+
case 21: return pn;
|
|
1568
1566
|
case 22:
|
|
1569
1567
|
case 23:
|
|
1570
|
-
case 24: return
|
|
1568
|
+
case 24: return mn;
|
|
1571
1569
|
case 19:
|
|
1572
|
-
case 3: return
|
|
1570
|
+
case 3: return gn;
|
|
1573
1571
|
default: return 0;
|
|
1574
1572
|
}
|
|
1575
1573
|
}
|
|
@@ -1612,7 +1610,7 @@ function En(e) {
|
|
|
1612
1610
|
}
|
|
1613
1611
|
if (a.t === 17) {
|
|
1614
1612
|
let n = a.v;
|
|
1615
|
-
return e[t + 1]?.t === 1 && (!
|
|
1613
|
+
return e[t + 1]?.t === 1 && (!N(n) || n === "Action") ? l() : (r(), {
|
|
1616
1614
|
k: "Ref",
|
|
1617
1615
|
n
|
|
1618
1616
|
});
|
|
@@ -1620,7 +1618,7 @@ function En(e) {
|
|
|
1620
1618
|
if (a.t === 35) {
|
|
1621
1619
|
if (e[t + 1]?.t === 1) {
|
|
1622
1620
|
let e = l();
|
|
1623
|
-
return e.k === "Comp" && !
|
|
1621
|
+
return e.k === "Comp" && !N(e.name) && (e.fn = !0), e;
|
|
1624
1622
|
}
|
|
1625
1623
|
return r(), {
|
|
1626
1624
|
k: "Ref",
|
|
@@ -1634,12 +1632,12 @@ function En(e) {
|
|
|
1634
1632
|
if (a.t === 33) return r(), {
|
|
1635
1633
|
k: "UnaryOp",
|
|
1636
1634
|
op: "!",
|
|
1637
|
-
operand: o(
|
|
1635
|
+
operand: o(hn)
|
|
1638
1636
|
};
|
|
1639
1637
|
if (a.t === 21) return r(), {
|
|
1640
1638
|
k: "UnaryOp",
|
|
1641
1639
|
op: "-",
|
|
1642
|
-
operand: o(
|
|
1640
|
+
operand: o(hn)
|
|
1643
1641
|
};
|
|
1644
1642
|
if (a.t === 1) {
|
|
1645
1643
|
r();
|
|
@@ -1654,79 +1652,79 @@ function En(e) {
|
|
|
1654
1652
|
k: "BinOp",
|
|
1655
1653
|
op: "+",
|
|
1656
1654
|
left: e,
|
|
1657
|
-
right: o(
|
|
1655
|
+
right: o(pn)
|
|
1658
1656
|
};
|
|
1659
1657
|
if (t.t === 21) return r(), {
|
|
1660
1658
|
k: "BinOp",
|
|
1661
1659
|
op: "-",
|
|
1662
1660
|
left: e,
|
|
1663
|
-
right: o(
|
|
1661
|
+
right: o(pn)
|
|
1664
1662
|
};
|
|
1665
1663
|
if (t.t === 22) return r(), {
|
|
1666
1664
|
k: "BinOp",
|
|
1667
1665
|
op: "*",
|
|
1668
1666
|
left: e,
|
|
1669
|
-
right: o(
|
|
1667
|
+
right: o(mn)
|
|
1670
1668
|
};
|
|
1671
1669
|
if (t.t === 23) return r(), {
|
|
1672
1670
|
k: "BinOp",
|
|
1673
1671
|
op: "/",
|
|
1674
1672
|
left: e,
|
|
1675
|
-
right: o(
|
|
1673
|
+
right: o(mn)
|
|
1676
1674
|
};
|
|
1677
1675
|
if (t.t === 24) return r(), {
|
|
1678
1676
|
k: "BinOp",
|
|
1679
1677
|
op: "%",
|
|
1680
1678
|
left: e,
|
|
1681
|
-
right: o(
|
|
1679
|
+
right: o(mn)
|
|
1682
1680
|
};
|
|
1683
1681
|
if (t.t === 25) return r(), {
|
|
1684
1682
|
k: "BinOp",
|
|
1685
1683
|
op: "==",
|
|
1686
1684
|
left: e,
|
|
1687
|
-
right: o(
|
|
1685
|
+
right: o(fn)
|
|
1688
1686
|
};
|
|
1689
1687
|
if (t.t === 26) return r(), {
|
|
1690
1688
|
k: "BinOp",
|
|
1691
1689
|
op: "!=",
|
|
1692
1690
|
left: e,
|
|
1693
|
-
right: o(
|
|
1691
|
+
right: o(fn)
|
|
1694
1692
|
};
|
|
1695
1693
|
if (t.t === 27) return r(), {
|
|
1696
1694
|
k: "BinOp",
|
|
1697
1695
|
op: ">",
|
|
1698
1696
|
left: e,
|
|
1699
|
-
right: o(
|
|
1697
|
+
right: o(W)
|
|
1700
1698
|
};
|
|
1701
1699
|
if (t.t === 28) return r(), {
|
|
1702
1700
|
k: "BinOp",
|
|
1703
1701
|
op: "<",
|
|
1704
1702
|
left: e,
|
|
1705
|
-
right: o(
|
|
1703
|
+
right: o(W)
|
|
1706
1704
|
};
|
|
1707
1705
|
if (t.t === 29) return r(), {
|
|
1708
1706
|
k: "BinOp",
|
|
1709
1707
|
op: ">=",
|
|
1710
1708
|
left: e,
|
|
1711
|
-
right: o(
|
|
1709
|
+
right: o(W)
|
|
1712
1710
|
};
|
|
1713
1711
|
if (t.t === 30) return r(), {
|
|
1714
1712
|
k: "BinOp",
|
|
1715
1713
|
op: "<=",
|
|
1716
1714
|
left: e,
|
|
1717
|
-
right: o(
|
|
1715
|
+
right: o(W)
|
|
1718
1716
|
};
|
|
1719
1717
|
if (t.t === 31) return r(), {
|
|
1720
1718
|
k: "BinOp",
|
|
1721
1719
|
op: "&&",
|
|
1722
1720
|
left: e,
|
|
1723
|
-
right: o(
|
|
1721
|
+
right: o(dn)
|
|
1724
1722
|
};
|
|
1725
1723
|
if (t.t === 32) return r(), {
|
|
1726
1724
|
k: "BinOp",
|
|
1727
1725
|
op: "||",
|
|
1728
1726
|
left: e,
|
|
1729
|
-
right: o(
|
|
1727
|
+
right: o(un)
|
|
1730
1728
|
};
|
|
1731
1729
|
if (t.t === 34) {
|
|
1732
1730
|
r();
|
|
@@ -1792,7 +1790,7 @@ function En(e) {
|
|
|
1792
1790
|
}
|
|
1793
1791
|
return o(0);
|
|
1794
1792
|
}
|
|
1795
|
-
function
|
|
1793
|
+
function vn(e) {
|
|
1796
1794
|
let t = [], n = 0, r = e.length;
|
|
1797
1795
|
for (; n < r;) {
|
|
1798
1796
|
for (; n < r && (e[n] === " " || e[n] === " " || e[n] === "\r");) n++;
|
|
@@ -1990,21 +1988,21 @@ function Dn(e) {
|
|
|
1990
1988
|
}
|
|
1991
1989
|
return t.push({ t: 13 }), t;
|
|
1992
1990
|
}
|
|
1993
|
-
var
|
|
1991
|
+
var yn = [
|
|
1994
1992
|
"string",
|
|
1995
1993
|
"number",
|
|
1996
1994
|
"boolean"
|
|
1997
|
-
],
|
|
1998
|
-
function
|
|
1995
|
+
], bn = {}, xn = [];
|
|
1996
|
+
function Sn(e) {
|
|
1999
1997
|
return Array.isArray(e) ? "array" : typeof e;
|
|
2000
1998
|
}
|
|
2001
|
-
function
|
|
1999
|
+
function Cn(e) {
|
|
2002
2000
|
return typeof e.$ref == "string" ? e.$ref.split("/").pop() : void 0;
|
|
2003
2001
|
}
|
|
2004
|
-
function
|
|
2002
|
+
function wn(e) {
|
|
2005
2003
|
return "$ref" in e || "anyOf" in e || "oneOf" in e || "allOf" in e;
|
|
2006
2004
|
}
|
|
2007
|
-
function
|
|
2005
|
+
function Tn(e) {
|
|
2008
2006
|
if (Array.isArray(e.enum)) return { enumValues: e.enum };
|
|
2009
2007
|
if ("const" in e) return { enumValues: [e.const] };
|
|
2010
2008
|
switch (e.type) {
|
|
@@ -2015,33 +2013,33 @@ function Pn(e) {
|
|
|
2015
2013
|
default: return {};
|
|
2016
2014
|
}
|
|
2017
2015
|
}
|
|
2018
|
-
function
|
|
2016
|
+
function En(e) {
|
|
2019
2017
|
if (!(!e || typeof e != "object" || Array.isArray(e))) return e.default;
|
|
2020
2018
|
}
|
|
2021
|
-
function
|
|
2019
|
+
function Dn(e) {
|
|
2022
2020
|
if (!e || typeof e != "object" || Array.isArray(e)) return;
|
|
2023
|
-
let t = e, n =
|
|
2021
|
+
let t = e, n = Cn(t);
|
|
2024
2022
|
if (n) return n;
|
|
2025
|
-
let r =
|
|
2023
|
+
let r = Tn(t);
|
|
2026
2024
|
return r.enumValues ? r.enumValues.map((e) => JSON.stringify(e)).join("|") : r.expectedType ? r.expectedType : typeof t.type == "string" ? t.type : void 0;
|
|
2027
2025
|
}
|
|
2028
|
-
function
|
|
2026
|
+
function On(e, t) {
|
|
2029
2027
|
return `${e}(${t.map((e) => {
|
|
2030
|
-
let t =
|
|
2028
|
+
let t = Dn(e.schema), n = e.required ? `${e.name}*` : e.name;
|
|
2031
2029
|
return t ? `${n}: ${t}` : n;
|
|
2032
2030
|
}).join(", ")})`;
|
|
2033
2031
|
}
|
|
2034
|
-
function
|
|
2032
|
+
function kn(e, t) {
|
|
2035
2033
|
let n = typeof e;
|
|
2036
|
-
return t.enumValues ? !
|
|
2034
|
+
return t.enumValues ? !yn.includes(n) || t.enumValues.includes(e) ? null : {
|
|
2037
2035
|
expected: `one of [${t.enumValues.map((e) => JSON.stringify(e)).join(", ")}]`,
|
|
2038
2036
|
actual: JSON.stringify(e)
|
|
2039
2037
|
} : t.expectedType && t.expectedType !== n ? {
|
|
2040
2038
|
expected: t.expectedType,
|
|
2041
|
-
actual:
|
|
2039
|
+
actual: Sn(e)
|
|
2042
2040
|
} : null;
|
|
2043
2041
|
}
|
|
2044
|
-
function
|
|
2042
|
+
function An(e, t, n) {
|
|
2045
2043
|
switch (n.code) {
|
|
2046
2044
|
case "type-mismatch": return `field "${t}" expects ${n.expected} but got ${n.actual}`;
|
|
2047
2045
|
case "missing-required": return `missing required field "${t}"${n.signature ? ` — signature: ${n.signature}` : ""}`;
|
|
@@ -2053,168 +2051,168 @@ function zn(e, t, n) {
|
|
|
2053
2051
|
case "no-root": return n.reason === "not-component" ? "root does not evaluate to a component" : n.reason === "fallback" ? `No root statement. Rendering the first statement that calls the root component ${e}` : e ? `No root statement, and no statement calls the root component ${e}` : "No root statement";
|
|
2054
2052
|
}
|
|
2055
2053
|
}
|
|
2056
|
-
function
|
|
2054
|
+
function G(e, t, n, r) {
|
|
2057
2055
|
e.errors.push({
|
|
2058
2056
|
code: r.code,
|
|
2059
2057
|
component: t,
|
|
2060
2058
|
path: n,
|
|
2061
|
-
message:
|
|
2059
|
+
message: An(t, n, r),
|
|
2062
2060
|
statementId: e.currentStatementId,
|
|
2063
2061
|
...r.code === "no-root" && r.reason === "fallback" && { severity: "warning" }
|
|
2064
2062
|
});
|
|
2065
2063
|
}
|
|
2066
|
-
var
|
|
2067
|
-
function
|
|
2068
|
-
return t === void 0 ? e ?
|
|
2064
|
+
var K = Symbol("invalid");
|
|
2065
|
+
function jn(e, t) {
|
|
2066
|
+
return t === void 0 ? e ? K : void 0 : t;
|
|
2069
2067
|
}
|
|
2070
|
-
function
|
|
2071
|
-
return
|
|
2068
|
+
function Mn(e, t, n, r, i) {
|
|
2069
|
+
return wn(t) ? !1 : typeof t.type == "string" || Array.isArray(t.enum) || "const" in t ? (G(i, n, r, {
|
|
2072
2070
|
code: "type-mismatch",
|
|
2073
2071
|
expected: typeof t.type == "string" ? t.type : "a literal value",
|
|
2074
2072
|
actual: `component "${e.typeName}"`
|
|
2075
2073
|
}), !0) : !1;
|
|
2076
2074
|
}
|
|
2077
|
-
function
|
|
2078
|
-
return (e.anyOf ?? e.oneOf ?? [e]).map(
|
|
2075
|
+
function Nn(e) {
|
|
2076
|
+
return (e.anyOf ?? e.oneOf ?? [e]).map(Cn);
|
|
2079
2077
|
}
|
|
2080
|
-
function
|
|
2081
|
-
let n =
|
|
2078
|
+
function Pn(e, t) {
|
|
2079
|
+
let n = Nn(e);
|
|
2082
2080
|
return n.length > 0 && n.every((e) => e !== void 0 && t.cat?.has(e));
|
|
2083
2081
|
}
|
|
2084
|
-
function
|
|
2085
|
-
if (typeof e != "object" || Array.isArray(e)) return
|
|
2082
|
+
function Fn(e, t, n, r, i) {
|
|
2083
|
+
if (typeof e != "object" || Array.isArray(e)) return G(i, n, r, {
|
|
2086
2084
|
code: "type-mismatch",
|
|
2087
2085
|
expected: "object",
|
|
2088
|
-
actual:
|
|
2089
|
-
}),
|
|
2090
|
-
let a = e, o, s = t.properties && typeof t.properties == "object" ? t.properties :
|
|
2086
|
+
actual: Sn(e)
|
|
2087
|
+
}), K;
|
|
2088
|
+
let a = e, o, s = t.properties && typeof t.properties == "object" ? t.properties : bn, c = Array.isArray(t.required) ? t.required : xn, l = !1;
|
|
2091
2089
|
if (!i.partial) for (let e of c) {
|
|
2092
2090
|
let t = e in a;
|
|
2093
2091
|
if (!t || a[e] == null) {
|
|
2094
|
-
let c =
|
|
2092
|
+
let c = En(s[e]);
|
|
2095
2093
|
if (c !== void 0) {
|
|
2096
2094
|
(o ??= { ...a })[e] = c;
|
|
2097
2095
|
continue;
|
|
2098
2096
|
}
|
|
2099
|
-
|
|
2097
|
+
G(i, n, `${r}/${e}`, { code: t ? "null-required" : "missing-required" }), l = !0;
|
|
2100
2098
|
}
|
|
2101
2099
|
}
|
|
2102
2100
|
for (let e of Object.keys(s)) {
|
|
2103
2101
|
if (!(e in a)) continue;
|
|
2104
|
-
let t = s[e], u =
|
|
2105
|
-
if (u ===
|
|
2102
|
+
let t = s[e], u = q(a[e], t, n, `${r}/${e}`, i);
|
|
2103
|
+
if (u === K && (u = jn(c.includes(e), En(t)), u === K)) {
|
|
2106
2104
|
l = !0;
|
|
2107
2105
|
continue;
|
|
2108
2106
|
}
|
|
2109
2107
|
u !== a[e] && (o ??= { ...a }, u === void 0 ? delete o[e] : o[e] = u);
|
|
2110
2108
|
}
|
|
2111
|
-
return l ?
|
|
2109
|
+
return l ? K : o ?? a;
|
|
2112
2110
|
}
|
|
2113
|
-
function
|
|
2114
|
-
if (!Array.isArray(e)) return
|
|
2111
|
+
function In(e, t, n, r, i) {
|
|
2112
|
+
if (!Array.isArray(e)) return G(i, n, r, {
|
|
2115
2113
|
code: "type-mismatch",
|
|
2116
2114
|
expected: "array",
|
|
2117
|
-
actual:
|
|
2118
|
-
}),
|
|
2115
|
+
actual: Sn(e)
|
|
2116
|
+
}), K;
|
|
2119
2117
|
let a = t.items;
|
|
2120
2118
|
if (!a || typeof a != "object" || Array.isArray(a)) return e;
|
|
2121
2119
|
let o;
|
|
2122
2120
|
for (let t = 0; t < e.length; t++) {
|
|
2123
|
-
let s =
|
|
2124
|
-
s !== e[t] && !o && (o = e.slice(0, t)), o && s !==
|
|
2121
|
+
let s = q(e[t], a, n, `${r}/${t}`, i);
|
|
2122
|
+
s !== e[t] && !o && (o = e.slice(0, t)), o && s !== K && o.push(s);
|
|
2125
2123
|
}
|
|
2126
2124
|
return o ?? e;
|
|
2127
2125
|
}
|
|
2128
|
-
function
|
|
2129
|
-
let a =
|
|
2126
|
+
function Ln(e, t, n, r, i) {
|
|
2127
|
+
let a = Tn(t);
|
|
2130
2128
|
if (a.expectedType == null && a.enumValues == null || a.enumValues && i.partial) return !1;
|
|
2131
|
-
let o =
|
|
2132
|
-
return o ? (
|
|
2129
|
+
let o = kn(e, a);
|
|
2130
|
+
return o ? (G(i, n, r, {
|
|
2133
2131
|
code: "type-mismatch",
|
|
2134
2132
|
...o
|
|
2135
2133
|
}), !0) : !1;
|
|
2136
2134
|
}
|
|
2137
|
-
function
|
|
2135
|
+
function q(e, t, n, r, i) {
|
|
2138
2136
|
if (!t || typeof t != "object" || Array.isArray(t)) return e;
|
|
2139
2137
|
let a = t;
|
|
2140
|
-
if (e == null ||
|
|
2141
|
-
if (
|
|
2142
|
-
if (
|
|
2138
|
+
if (e == null || H(e)) return e;
|
|
2139
|
+
if (V(e)) return Mn(e, a, n, r, i) ? K : e;
|
|
2140
|
+
if (wn(a)) return Pn(a, i) ? (G(i, n, r, {
|
|
2143
2141
|
code: "type-mismatch",
|
|
2144
|
-
expected:
|
|
2142
|
+
expected: Nn(a).join(" | "),
|
|
2145
2143
|
actual: Array.isArray(e) ? "array" : typeof e == "object" ? "plain object" : typeof e
|
|
2146
|
-
}),
|
|
2144
|
+
}), K) : e;
|
|
2147
2145
|
let o = a.type;
|
|
2148
|
-
return o === "object" ?
|
|
2146
|
+
return o === "object" ? Fn(e, a, n, r, i) : o === "array" ? In(e, a, n, r, i) : Ln(e, a, n, r, i) ? K : e;
|
|
2149
2147
|
}
|
|
2150
|
-
function
|
|
2148
|
+
function Rn(e) {
|
|
2151
2149
|
if (typeof e != "object" || !e) return !1;
|
|
2152
|
-
if (
|
|
2153
|
-
if (Array.isArray(e)) return e.some(
|
|
2154
|
-
if (
|
|
2150
|
+
if (H(e)) return !0;
|
|
2151
|
+
if (Array.isArray(e)) return e.some(Rn);
|
|
2152
|
+
if (V(e)) return Object.values(e.props).some(Rn);
|
|
2155
2153
|
let t = e;
|
|
2156
|
-
return Array.isArray(t.steps) ? !0 : Object.values(t).some(
|
|
2154
|
+
return Array.isArray(t.steps) ? !0 : Object.values(t).some(Rn);
|
|
2157
2155
|
}
|
|
2158
|
-
function
|
|
2156
|
+
function zn(e, t, n) {
|
|
2159
2157
|
if (t.visited.has(e) || !t.syms.has(e)) return t.unres.push(e), n === "expr" ? {
|
|
2160
2158
|
k: "Ph",
|
|
2161
2159
|
n: e
|
|
2162
2160
|
} : null;
|
|
2163
2161
|
let r = t.syms.get(e);
|
|
2164
|
-
if (t.unreached?.delete(e), r.k === "Comp" &&
|
|
2162
|
+
if (t.unreached?.delete(e), r.k === "Comp" && F(r.name)) return {
|
|
2165
2163
|
k: "RuntimeRef",
|
|
2166
2164
|
n: e,
|
|
2167
|
-
refType: r.name ===
|
|
2165
|
+
refType: r.name === P.Mutation ? "mutation" : "query"
|
|
2168
2166
|
};
|
|
2169
2167
|
t.visited.add(e);
|
|
2170
2168
|
let i = t.currentStatementId;
|
|
2171
2169
|
t.currentStatementId = e;
|
|
2172
2170
|
try {
|
|
2173
|
-
let i = n === "value" ?
|
|
2174
|
-
return n === "value" &&
|
|
2171
|
+
let i = n === "value" ? Y(r, t) : Kn(r, t);
|
|
2172
|
+
return n === "value" && V(i) && (i.statementId = e), i;
|
|
2175
2173
|
} finally {
|
|
2176
2174
|
t.currentStatementId = i, t.visited.delete(e);
|
|
2177
2175
|
}
|
|
2178
2176
|
}
|
|
2179
|
-
function
|
|
2180
|
-
return
|
|
2177
|
+
function Bn(e, t) {
|
|
2178
|
+
return M(t.cat).has(e) || F(e);
|
|
2181
2179
|
}
|
|
2182
|
-
function
|
|
2180
|
+
function Vn(e, t) {
|
|
2183
2181
|
let n = {};
|
|
2184
2182
|
for (let r = 0; r < t.length && r < e.length; r++) n[t[r].name] = e[r];
|
|
2185
2183
|
return n;
|
|
2186
2184
|
}
|
|
2187
|
-
function
|
|
2185
|
+
function Hn(e, t, n, r) {
|
|
2188
2186
|
let { params: i } = n;
|
|
2189
|
-
t.length > i.length &&
|
|
2187
|
+
t.length > i.length && G(r, e, "", {
|
|
2190
2188
|
code: "excess-args",
|
|
2191
2189
|
declared: i.length,
|
|
2192
2190
|
got: t.length
|
|
2193
2191
|
});
|
|
2194
|
-
let a =
|
|
2192
|
+
let a = Vn(t, i), o = !1, s = r.errors.length;
|
|
2195
2193
|
for (let t of i) {
|
|
2196
|
-
let n = a[t.name], s = n ?
|
|
2194
|
+
let n = a[t.name], s = n ? cn(n) : { v: void 0 };
|
|
2197
2195
|
if (!s) continue;
|
|
2198
2196
|
if (s.v == null) {
|
|
2199
2197
|
if (!t.required || t.defaultValue !== void 0) continue;
|
|
2200
|
-
|
|
2198
|
+
G(r, e, `/${t.name}`, {
|
|
2201
2199
|
code: n ? "null-required" : "missing-required",
|
|
2202
|
-
signature:
|
|
2200
|
+
signature: On(e, i)
|
|
2203
2201
|
}), o = !0;
|
|
2204
2202
|
continue;
|
|
2205
2203
|
}
|
|
2206
|
-
let c =
|
|
2207
|
-
c ===
|
|
2204
|
+
let c = q(s.v, t.schema, e, `/${t.name}`, r);
|
|
2205
|
+
c === K && (c = jn(t.required, t.defaultValue)), c === K ? o = !0 : c === void 0 ? delete a[t.name] : c !== s.v && (a[t.name] = sn(c));
|
|
2208
2206
|
}
|
|
2209
2207
|
return n.kind === "action" && r.errors.length > s && (o = !0), o ? null : a;
|
|
2210
2208
|
}
|
|
2211
|
-
function
|
|
2212
|
-
let r = e.args.map(n), i =
|
|
2209
|
+
function Un(e, t, n) {
|
|
2210
|
+
let r = e.args.map(n), i = M(t.cat).get(e.name);
|
|
2213
2211
|
if (!i || i.lazy) return {
|
|
2214
2212
|
...e,
|
|
2215
2213
|
args: r
|
|
2216
2214
|
};
|
|
2217
|
-
let a = i.builtin ?
|
|
2215
|
+
let a = i.builtin ? Vn(r, i.params) : Hn(e.name, r, i, t);
|
|
2218
2216
|
return a ? {
|
|
2219
2217
|
...e,
|
|
2220
2218
|
args: r,
|
|
@@ -2228,41 +2226,41 @@ function Qn(e, t, n) {
|
|
|
2228
2226
|
}]
|
|
2229
2227
|
} : { k: "Null" };
|
|
2230
2228
|
}
|
|
2231
|
-
function
|
|
2229
|
+
function Wn(e, t, n) {
|
|
2232
2230
|
let r = t.currentStatementId;
|
|
2233
2231
|
t.currentStatementId = n;
|
|
2234
2232
|
let i = /* @__PURE__ */ new Set();
|
|
2235
|
-
for (let n of e)
|
|
2233
|
+
for (let n of e) U(n, (e) => {
|
|
2236
2234
|
if (e.k !== "Comp" || i.has(e)) return;
|
|
2237
2235
|
i.add(e);
|
|
2238
|
-
let n =
|
|
2239
|
-
!n || n.lazy || (e.mappedProps = (n.builtin ? null :
|
|
2236
|
+
let n = M(t.cat).get(e.name);
|
|
2237
|
+
!n || n.lazy || (e.mappedProps = (n.builtin ? null : Hn(e.name, e.args, n, t)) ?? Vn(e.args, n.params));
|
|
2240
2238
|
});
|
|
2241
2239
|
t.currentStatementId = r;
|
|
2242
2240
|
}
|
|
2243
|
-
function
|
|
2244
|
-
let r =
|
|
2241
|
+
function Gn(e, t, n) {
|
|
2242
|
+
let r = M(t.cat).get(e.name);
|
|
2245
2243
|
if (r?.kind !== "function" || !r.lazy || e.args.length < 3) return null;
|
|
2246
2244
|
let i = e.args[1], a = i.k === "Ref" ? i.n : i.k === "Str" ? i.v : null;
|
|
2247
2245
|
if (!a) return null;
|
|
2248
2246
|
let o = new Set(n);
|
|
2249
2247
|
o.add(a);
|
|
2250
|
-
let s = e.args.map((e, n) => n === 1 ? e :
|
|
2248
|
+
let s = e.args.map((e, n) => n === 1 ? e : J(e, t, o));
|
|
2251
2249
|
return {
|
|
2252
2250
|
...e,
|
|
2253
2251
|
args: s
|
|
2254
2252
|
};
|
|
2255
2253
|
}
|
|
2256
|
-
function
|
|
2254
|
+
function J(e, t, n) {
|
|
2257
2255
|
switch (e.k) {
|
|
2258
|
-
case "Ref": return n.has(e.n) ? e :
|
|
2256
|
+
case "Ref": return n.has(e.n) ? e : zn(e.n, t, "expr");
|
|
2259
2257
|
case "Ph": return e;
|
|
2260
2258
|
case "Comp": {
|
|
2261
|
-
if (e.fn && !
|
|
2262
|
-
let r =
|
|
2259
|
+
if (e.fn && !Bn(e.name, t)) return G(t, e.name, "", { code: "unknown-function" }), { k: "Null" };
|
|
2260
|
+
let r = Gn(e, t, n);
|
|
2263
2261
|
if (r) return r;
|
|
2264
|
-
if (
|
|
2265
|
-
let i = e.args.map((e) =>
|
|
2262
|
+
if (Bn(e.name, t)) return Un(e, t, (e) => J(e, t, n));
|
|
2263
|
+
let i = e.args.map((e) => J(e, t, n)), a = t.cat?.get(e.name);
|
|
2266
2264
|
if (a) {
|
|
2267
2265
|
let t = {};
|
|
2268
2266
|
for (let e = 0; e < a.params.length && e < i.length; e++) t[a.params[e].name] = i[e];
|
|
@@ -2272,7 +2270,7 @@ function Y(e, t, n) {
|
|
|
2272
2270
|
mappedProps: t
|
|
2273
2271
|
};
|
|
2274
2272
|
}
|
|
2275
|
-
return
|
|
2273
|
+
return G(t, e.name, "", {
|
|
2276
2274
|
code: "unknown-component",
|
|
2277
2275
|
available: t.cat && [...t.cat.keys()]
|
|
2278
2276
|
}), {
|
|
@@ -2282,49 +2280,49 @@ function Y(e, t, n) {
|
|
|
2282
2280
|
}
|
|
2283
2281
|
case "Arr": return {
|
|
2284
2282
|
...e,
|
|
2285
|
-
els: e.els.map((e) =>
|
|
2283
|
+
els: e.els.map((e) => J(e, t, n))
|
|
2286
2284
|
};
|
|
2287
2285
|
case "Obj": return {
|
|
2288
2286
|
...e,
|
|
2289
|
-
entries: e.entries.map(([e, r]) => [e,
|
|
2287
|
+
entries: e.entries.map(([e, r]) => [e, J(r, t, n)])
|
|
2290
2288
|
};
|
|
2291
2289
|
case "BinOp": return {
|
|
2292
2290
|
...e,
|
|
2293
|
-
left:
|
|
2294
|
-
right:
|
|
2291
|
+
left: J(e.left, t, n),
|
|
2292
|
+
right: J(e.right, t, n)
|
|
2295
2293
|
};
|
|
2296
2294
|
case "UnaryOp": return {
|
|
2297
2295
|
...e,
|
|
2298
|
-
operand:
|
|
2296
|
+
operand: J(e.operand, t, n)
|
|
2299
2297
|
};
|
|
2300
2298
|
case "Ternary": return {
|
|
2301
2299
|
...e,
|
|
2302
|
-
cond:
|
|
2303
|
-
then:
|
|
2304
|
-
else:
|
|
2300
|
+
cond: J(e.cond, t, n),
|
|
2301
|
+
then: J(e.then, t, n),
|
|
2302
|
+
else: J(e.else, t, n)
|
|
2305
2303
|
};
|
|
2306
2304
|
case "Member": return {
|
|
2307
2305
|
...e,
|
|
2308
|
-
obj:
|
|
2306
|
+
obj: J(e.obj, t, n)
|
|
2309
2307
|
};
|
|
2310
2308
|
case "Index": return {
|
|
2311
2309
|
...e,
|
|
2312
|
-
obj:
|
|
2313
|
-
index:
|
|
2310
|
+
obj: J(e.obj, t, n),
|
|
2311
|
+
index: J(e.index, t, n)
|
|
2314
2312
|
};
|
|
2315
2313
|
case "Assign": return {
|
|
2316
2314
|
...e,
|
|
2317
|
-
value:
|
|
2315
|
+
value: J(e.value, t, n)
|
|
2318
2316
|
};
|
|
2319
2317
|
default: return e;
|
|
2320
2318
|
}
|
|
2321
2319
|
}
|
|
2322
|
-
function
|
|
2323
|
-
return
|
|
2320
|
+
function Kn(e, t) {
|
|
2321
|
+
return J(e, t, /* @__PURE__ */ new Set());
|
|
2324
2322
|
}
|
|
2325
|
-
function
|
|
2323
|
+
function Y(e, t) {
|
|
2326
2324
|
switch (e.k) {
|
|
2327
|
-
case "Ref": return
|
|
2325
|
+
case "Ref": return zn(e.n, t, "value");
|
|
2328
2326
|
case "Str": return e.v;
|
|
2329
2327
|
case "Num": return e.v;
|
|
2330
2328
|
case "Bool": return e.v;
|
|
@@ -2334,31 +2332,31 @@ function X(e, t) {
|
|
|
2334
2332
|
let n = [];
|
|
2335
2333
|
for (let r of e.els) {
|
|
2336
2334
|
if (r.k === "Ph") continue;
|
|
2337
|
-
let e =
|
|
2335
|
+
let e = Y(r, t);
|
|
2338
2336
|
e === null && (r.k === "Comp" || r.k === "Ref") || n.push(e);
|
|
2339
2337
|
}
|
|
2340
2338
|
return n;
|
|
2341
2339
|
}
|
|
2342
2340
|
case "Obj": {
|
|
2343
2341
|
let n = {};
|
|
2344
|
-
for (let [r, i] of e.entries) n[r] =
|
|
2342
|
+
for (let [r, i] of e.entries) n[r] = Y(i, t);
|
|
2345
2343
|
return n;
|
|
2346
2344
|
}
|
|
2347
2345
|
case "Comp": {
|
|
2348
2346
|
let { name: n, args: r } = e;
|
|
2349
|
-
if (e.fn && !
|
|
2350
|
-
if (
|
|
2351
|
-
if (
|
|
2347
|
+
if (e.fn && !Bn(n, t)) return G(t, n, "", { code: "unknown-function" }), null;
|
|
2348
|
+
if (F(n)) return G(t, n, "", { code: "inline-reserved" }), null;
|
|
2349
|
+
if (Bn(n, t)) return Gn(e, t, /* @__PURE__ */ new Set()) || Un(e, t, (e) => Kn(e, t));
|
|
2352
2350
|
let i = t.cat?.get(n), a = {};
|
|
2353
2351
|
if (i) {
|
|
2354
2352
|
let e = !1;
|
|
2355
2353
|
for (let o = 0; o < i.params.length && o < r.length; o++) {
|
|
2356
|
-
let s = i.params[o], c =
|
|
2354
|
+
let s = i.params[o], c = Y(r[o], t);
|
|
2357
2355
|
if (a[s.name] = c, s.schema === void 0) continue;
|
|
2358
|
-
let l =
|
|
2359
|
-
l ===
|
|
2356
|
+
let l = q(c, s.schema, n, `/${s.name}`, t);
|
|
2357
|
+
l === K && (l = jn(s.required, s.defaultValue), l === K ? e = !0 : l === void 0 && delete a[s.name]), l !== K && l !== void 0 && (a[s.name] = l);
|
|
2360
2358
|
}
|
|
2361
|
-
r.length > i.params.length &&
|
|
2359
|
+
r.length > i.params.length && G(t, n, "", {
|
|
2362
2360
|
code: "excess-args",
|
|
2363
2361
|
declared: i.params.length,
|
|
2364
2362
|
got: r.length
|
|
@@ -2367,19 +2365,19 @@ function X(e, t) {
|
|
|
2367
2365
|
if (o.length) {
|
|
2368
2366
|
let e = o.filter((e) => e.defaultValue === void 0 ? !0 : (a[e.name] = e.defaultValue, !1));
|
|
2369
2367
|
if (e.length) {
|
|
2370
|
-
for (let r of e)
|
|
2368
|
+
for (let r of e) G(t, n, `/${r.name}`, {
|
|
2371
2369
|
code: r.name in a ? "null-required" : "missing-required",
|
|
2372
|
-
signature:
|
|
2370
|
+
signature: On(n, i.params)
|
|
2373
2371
|
});
|
|
2374
2372
|
return null;
|
|
2375
2373
|
}
|
|
2376
2374
|
}
|
|
2377
2375
|
if (e) return null;
|
|
2378
|
-
} else return
|
|
2376
|
+
} else return G(t, n, "", {
|
|
2379
2377
|
code: "unknown-component",
|
|
2380
2378
|
available: t.cat && [...t.cat.keys()]
|
|
2381
2379
|
}), null;
|
|
2382
|
-
let o = Object.values(a).some((e) =>
|
|
2380
|
+
let o = Object.values(a).some((e) => Rn(e));
|
|
2383
2381
|
return {
|
|
2384
2382
|
type: "element",
|
|
2385
2383
|
typeName: n,
|
|
@@ -2388,10 +2386,10 @@ function X(e, t) {
|
|
|
2388
2386
|
hasDynamicProps: o
|
|
2389
2387
|
};
|
|
2390
2388
|
}
|
|
2391
|
-
default: return
|
|
2389
|
+
default: return an(e) ? Kn(e, t) : e;
|
|
2392
2390
|
}
|
|
2393
2391
|
}
|
|
2394
|
-
function
|
|
2392
|
+
function qn(e) {
|
|
2395
2393
|
let t = [], n = !1, r = !1;
|
|
2396
2394
|
for (let i = 0; i < e.length; i++) {
|
|
2397
2395
|
let a = e[i];
|
|
@@ -2425,7 +2423,7 @@ function nr(e) {
|
|
|
2425
2423
|
wasIncomplete: !0
|
|
2426
2424
|
};
|
|
2427
2425
|
}
|
|
2428
|
-
function
|
|
2426
|
+
function Jn(e) {
|
|
2429
2427
|
let t = [], n = 0;
|
|
2430
2428
|
for (; n < e.length;) {
|
|
2431
2429
|
for (; n < e.length && e[n].t === 0;) n++;
|
|
@@ -2468,7 +2466,7 @@ function rr(e) {
|
|
|
2468
2466
|
}
|
|
2469
2467
|
return t;
|
|
2470
2468
|
}
|
|
2471
|
-
function
|
|
2469
|
+
function Yn(e = !0) {
|
|
2472
2470
|
return {
|
|
2473
2471
|
root: null,
|
|
2474
2472
|
meta: {
|
|
@@ -2483,32 +2481,32 @@ function ir(e = !0) {
|
|
|
2483
2481
|
mutationStatements: []
|
|
2484
2482
|
};
|
|
2485
2483
|
}
|
|
2486
|
-
function
|
|
2487
|
-
if (!
|
|
2484
|
+
function Xn(e) {
|
|
2485
|
+
if (!H(e)) return [];
|
|
2488
2486
|
let t = /* @__PURE__ */ new Set();
|
|
2489
|
-
return
|
|
2487
|
+
return U(e, (e) => {
|
|
2490
2488
|
e.k === "StateRef" && t.add(e.n);
|
|
2491
2489
|
}), [...t];
|
|
2492
2490
|
}
|
|
2493
|
-
function
|
|
2494
|
-
if (t.k === "Comp" && t.name ===
|
|
2495
|
-
let n =
|
|
2491
|
+
function Zn(e, t) {
|
|
2492
|
+
if (t.k === "Comp" && t.name === P.Query) {
|
|
2493
|
+
let n = Xn(t.args[1]);
|
|
2496
2494
|
return {
|
|
2497
2495
|
kind: "query",
|
|
2498
2496
|
id: e.id,
|
|
2499
2497
|
call: {
|
|
2500
|
-
callee:
|
|
2498
|
+
callee: P.Query,
|
|
2501
2499
|
args: t.args
|
|
2502
2500
|
},
|
|
2503
2501
|
expr: t,
|
|
2504
2502
|
deps: n.length > 0 ? n : void 0
|
|
2505
2503
|
};
|
|
2506
2504
|
}
|
|
2507
|
-
return t.k === "Comp" && t.name ===
|
|
2505
|
+
return t.k === "Comp" && t.name === P.Mutation ? {
|
|
2508
2506
|
kind: "mutation",
|
|
2509
2507
|
id: e.id,
|
|
2510
2508
|
call: {
|
|
2511
|
-
callee:
|
|
2509
|
+
callee: P.Mutation,
|
|
2512
2510
|
args: t.args
|
|
2513
2511
|
},
|
|
2514
2512
|
expr: t
|
|
@@ -2522,14 +2520,14 @@ function or(e, t) {
|
|
|
2522
2520
|
expr: t
|
|
2523
2521
|
};
|
|
2524
2522
|
}
|
|
2525
|
-
function
|
|
2523
|
+
function Qn(e, t, n) {
|
|
2526
2524
|
let r = {}, i = [], a = [];
|
|
2527
2525
|
for (let n of e) switch (n.kind) {
|
|
2528
2526
|
case "state":
|
|
2529
|
-
r[n.id] =
|
|
2527
|
+
r[n.id] = Y(n.init, t);
|
|
2530
2528
|
break;
|
|
2531
2529
|
case "query":
|
|
2532
|
-
|
|
2530
|
+
Wn(n.call.args, t, n.id), i.push({
|
|
2533
2531
|
statementId: n.id,
|
|
2534
2532
|
toolAST: n.call.args[0] ?? null,
|
|
2535
2533
|
argsAST: n.call.args[1] ?? null,
|
|
@@ -2540,7 +2538,7 @@ function sr(e, t, n) {
|
|
|
2540
2538
|
});
|
|
2541
2539
|
break;
|
|
2542
2540
|
case "mutation":
|
|
2543
|
-
|
|
2541
|
+
Wn(n.call.args, t, n.id), a.push({
|
|
2544
2542
|
statementId: n.id,
|
|
2545
2543
|
toolAST: n.call.args[0] ?? null,
|
|
2546
2544
|
argsAST: n.call.args[1] ?? null
|
|
@@ -2549,7 +2547,7 @@ function sr(e, t, n) {
|
|
|
2549
2547
|
}
|
|
2550
2548
|
for (let t of e) {
|
|
2551
2549
|
let e = t.kind === "state" ? [t.init] : t.kind === "value" ? [t.expr] : t.kind === "query" || t.kind === "mutation" ? t.call.args : [];
|
|
2552
|
-
for (let i of e) for (let e of
|
|
2550
|
+
for (let i of e) for (let e of Xn(i)) e === n?.name && n.stmts.has(t) || e in r || (r[e] = null);
|
|
2553
2551
|
}
|
|
2554
2552
|
return {
|
|
2555
2553
|
stateDeclarations: r,
|
|
@@ -2557,34 +2555,34 @@ function sr(e, t, n) {
|
|
|
2557
2555
|
mutationStatements: a
|
|
2558
2556
|
};
|
|
2559
2557
|
}
|
|
2560
|
-
var
|
|
2561
|
-
function
|
|
2562
|
-
return e?.k === "Comp" && !e.fn && !
|
|
2558
|
+
var $n = "root";
|
|
2559
|
+
function er(e) {
|
|
2560
|
+
return e?.k === "Comp" && !e.fn && !N(e.name) && !F(e.name);
|
|
2563
2561
|
}
|
|
2564
|
-
function
|
|
2565
|
-
if (e.has(
|
|
2566
|
-
id:
|
|
2562
|
+
function tr(e, t) {
|
|
2563
|
+
if (e.has($n)) return {
|
|
2564
|
+
id: $n,
|
|
2567
2565
|
fallback: !1
|
|
2568
2566
|
};
|
|
2569
|
-
for (let n of e.values()) if (n.kind === "value" &&
|
|
2567
|
+
for (let n of e.values()) if (n.kind === "value" && er(n.expr) && n.expr.name === t) return {
|
|
2570
2568
|
id: n.id,
|
|
2571
2569
|
fallback: !0
|
|
2572
2570
|
};
|
|
2573
2571
|
return null;
|
|
2574
2572
|
}
|
|
2575
|
-
function
|
|
2573
|
+
function nr(e, t) {
|
|
2576
2574
|
let n = /* @__PURE__ */ new Set();
|
|
2577
2575
|
for (; e?.k === "Ref" && !n.has(e.n);) n.add(e.n), e = t.get(e.n);
|
|
2578
|
-
return
|
|
2576
|
+
return er(e);
|
|
2579
2577
|
}
|
|
2580
|
-
function
|
|
2578
|
+
function rr(e) {
|
|
2581
2579
|
let t = !1;
|
|
2582
|
-
return
|
|
2583
|
-
|
|
2580
|
+
return U(e, (e) => {
|
|
2581
|
+
er(e) && (t = !0);
|
|
2584
2582
|
}), t;
|
|
2585
2583
|
}
|
|
2586
|
-
function
|
|
2587
|
-
let s =
|
|
2584
|
+
function ir(e, t, n, r, i, a, o) {
|
|
2585
|
+
let s = tr(e, a), c = /* @__PURE__ */ new Map();
|
|
2588
2586
|
for (let [t, n] of e) c.set(t, n.kind === "state" ? n.init : n.expr);
|
|
2589
2587
|
let l = [], u = [], d = /* @__PURE__ */ new Set();
|
|
2590
2588
|
for (let [t, n] of e) t !== s?.id && (n.kind === "state" || n.kind === "query" || n.kind === "mutation" || d.add(t));
|
|
@@ -2599,30 +2597,30 @@ function pr(e, t, n, r, i, a, o) {
|
|
|
2599
2597
|
unreached: d
|
|
2600
2598
|
}, p = null, m;
|
|
2601
2599
|
if (s) {
|
|
2602
|
-
let e =
|
|
2603
|
-
|
|
2600
|
+
let e = Y(c.get(s.id), f);
|
|
2601
|
+
V(e) ? (p = e, p.statementId = s.id) : H(e) && rr(e) && (m = e);
|
|
2604
2602
|
}
|
|
2605
|
-
let { stateDeclarations: h, queryStatements: g, mutationStatements: _ } =
|
|
2603
|
+
let { stateDeclarations: h, queryStatements: g, mutationStatements: _ } = Qn(t, f, o);
|
|
2606
2604
|
f.currentStatementId = s?.id;
|
|
2607
2605
|
let v = a ?? "";
|
|
2608
|
-
s ? !p && !m && !
|
|
2606
|
+
s ? !p && !m && !nr(c.get(s.id), c) ? G(f, v, "", {
|
|
2609
2607
|
code: "no-root",
|
|
2610
2608
|
reason: "not-component"
|
|
2611
|
-
}) : s.fallback &&
|
|
2609
|
+
}) : s.fallback && G(f, v, "", {
|
|
2612
2610
|
code: "no-root",
|
|
2613
2611
|
reason: p ? "fallback" : "missing"
|
|
2614
|
-
}) :
|
|
2612
|
+
}) : G(f, v, "", {
|
|
2615
2613
|
code: "no-root",
|
|
2616
2614
|
reason: "missing"
|
|
2617
2615
|
});
|
|
2618
|
-
let
|
|
2616
|
+
let y = s ? [...d] : [];
|
|
2619
2617
|
return {
|
|
2620
2618
|
root: p,
|
|
2621
2619
|
...m ? { rootExpression: m } : {},
|
|
2622
2620
|
meta: {
|
|
2623
2621
|
incomplete: n,
|
|
2624
2622
|
unresolved: l,
|
|
2625
|
-
orphaned:
|
|
2623
|
+
orphaned: y,
|
|
2626
2624
|
statementCount: r,
|
|
2627
2625
|
errors: u
|
|
2628
2626
|
},
|
|
@@ -2631,7 +2629,7 @@ function pr(e, t, n, r, i, a, o) {
|
|
|
2631
2629
|
mutationStatements: _
|
|
2632
2630
|
};
|
|
2633
2631
|
}
|
|
2634
|
-
function
|
|
2632
|
+
function ar(e, t) {
|
|
2635
2633
|
if (e[t] !== "\"") return t;
|
|
2636
2634
|
let n = t + 1;
|
|
2637
2635
|
for (; n < e.length;) {
|
|
@@ -2642,12 +2640,12 @@ function mr(e, t) {
|
|
|
2642
2640
|
}
|
|
2643
2641
|
return n;
|
|
2644
2642
|
}
|
|
2645
|
-
function
|
|
2643
|
+
function or(e) {
|
|
2646
2644
|
let t = [], n = 0;
|
|
2647
2645
|
for (; n < e.length;) {
|
|
2648
2646
|
let r = -1;
|
|
2649
2647
|
for (; n < e.length;) {
|
|
2650
|
-
let t =
|
|
2648
|
+
let t = ar(e, n);
|
|
2651
2649
|
if (t > n) {
|
|
2652
2650
|
n = t;
|
|
2653
2651
|
continue;
|
|
@@ -2668,7 +2666,7 @@ function hr(e) {
|
|
|
2668
2666
|
i++;
|
|
2669
2667
|
let a = -1, o = i;
|
|
2670
2668
|
for (; o < e.length;) {
|
|
2671
|
-
let t =
|
|
2669
|
+
let t = ar(e, o);
|
|
2672
2670
|
if (t > o) {
|
|
2673
2671
|
o = t;
|
|
2674
2672
|
continue;
|
|
@@ -2690,7 +2688,7 @@ function hr(e) {
|
|
|
2690
2688
|
}
|
|
2691
2689
|
return e;
|
|
2692
2690
|
}
|
|
2693
|
-
function
|
|
2691
|
+
function sr(e) {
|
|
2694
2692
|
let t = !1;
|
|
2695
2693
|
return e.split("\n").map((e) => {
|
|
2696
2694
|
for (let n = 0; n < e.length; n++) {
|
|
@@ -2712,32 +2710,32 @@ function gr(e) {
|
|
|
2712
2710
|
return e;
|
|
2713
2711
|
}).join("\n");
|
|
2714
2712
|
}
|
|
2715
|
-
function
|
|
2716
|
-
return
|
|
2713
|
+
function cr(e) {
|
|
2714
|
+
return sr(or(e.trim())).trim();
|
|
2717
2715
|
}
|
|
2718
|
-
function
|
|
2719
|
-
let r =
|
|
2720
|
-
if (!r) return
|
|
2721
|
-
let { text: i, wasIncomplete: a } =
|
|
2722
|
-
if (!o.length) return
|
|
2716
|
+
function lr(e, t, n) {
|
|
2717
|
+
let r = cr(e);
|
|
2718
|
+
if (!r) return Yn();
|
|
2719
|
+
let { text: i, wasIncomplete: a } = qn(r), o = Jn(vn(i));
|
|
2720
|
+
if (!o.length) return Yn(a);
|
|
2723
2721
|
let s = /* @__PURE__ */ new Map();
|
|
2724
2722
|
for (let e of o) {
|
|
2725
|
-
let t =
|
|
2723
|
+
let t = Zn(e, _n(e.tokens));
|
|
2726
2724
|
s.set(e.id, t);
|
|
2727
2725
|
}
|
|
2728
|
-
return
|
|
2726
|
+
return ir(s, [...s.values()], a, s.size, t, n);
|
|
2729
2727
|
}
|
|
2730
|
-
function
|
|
2728
|
+
function ur(e, t) {
|
|
2731
2729
|
let n = "", r = "", i = 0, a = /* @__PURE__ */ new Map(), o = 0;
|
|
2732
2730
|
function s(e) {
|
|
2733
2731
|
let t = e.trim();
|
|
2734
|
-
if (t) for (let e of
|
|
2735
|
-
let t =
|
|
2732
|
+
if (t) for (let e of Jn(vn(t))) {
|
|
2733
|
+
let t = Zn(e, _n(e.tokens));
|
|
2736
2734
|
a.set(e.id, t), o++;
|
|
2737
2735
|
}
|
|
2738
2736
|
}
|
|
2739
2737
|
function c() {
|
|
2740
|
-
let e =
|
|
2738
|
+
let e = cr(n);
|
|
2741
2739
|
e.startsWith(r.slice(0, i)) || (i = 0, a.clear(), o = 0), r = e;
|
|
2742
2740
|
}
|
|
2743
2741
|
function l() {
|
|
@@ -2777,17 +2775,17 @@ function yr(e, t) {
|
|
|
2777
2775
|
function u(i = !1) {
|
|
2778
2776
|
c();
|
|
2779
2777
|
let s = l(), u = r.slice(s).trim();
|
|
2780
|
-
if (!u) return o === 0 ?
|
|
2781
|
-
let { text: d, wasIncomplete: f } =
|
|
2782
|
-
if (!p.length) return o === 0 ?
|
|
2778
|
+
if (!u) return o === 0 ? Yn() : ir(a, [...a.values()], !1, o, e, t);
|
|
2779
|
+
let { text: d, wasIncomplete: f } = qn(u), p = Jn(vn(d));
|
|
2780
|
+
if (!p.length) return o === 0 ? Yn(f) : ir(a, [...a.values()], f, o, e, t);
|
|
2783
2781
|
let m = new Map(a), h = /* @__PURE__ */ new Set();
|
|
2784
2782
|
for (let e of p) {
|
|
2785
2783
|
if (a.has(e.id) && f) continue;
|
|
2786
|
-
let t =
|
|
2784
|
+
let t = Zn(e, _n(e.tokens));
|
|
2787
2785
|
m.set(e.id, t), h.add(t);
|
|
2788
2786
|
}
|
|
2789
2787
|
let g = i ? void 0 : /\$\w+$/.exec(n)?.[0], _ = g && u.endsWith(g) && !RegExp(`\\${g}(?!\\w)`).test(u.slice(0, -g.length)) ? g : void 0;
|
|
2790
|
-
return
|
|
2788
|
+
return ir(m, [...m.values()], f, o + p.length, e, t, _ ? {
|
|
2791
2789
|
name: _,
|
|
2792
2790
|
stmts: h
|
|
2793
2791
|
} : void 0);
|
|
@@ -2807,62 +2805,62 @@ function yr(e, t) {
|
|
|
2807
2805
|
getResult: u
|
|
2808
2806
|
};
|
|
2809
2807
|
}
|
|
2810
|
-
function
|
|
2808
|
+
function dr(e, t) {
|
|
2811
2809
|
if (!e || typeof e != "object") return e;
|
|
2812
2810
|
let n = e.$ref;
|
|
2813
|
-
if (typeof n == "string") return t.has(n) ?
|
|
2811
|
+
if (typeof n == "string") return t.has(n) ? dr(t.get(n), t) : e;
|
|
2814
2812
|
let r = Array.isArray(e) ? [...e] : { ...e }, i = !1;
|
|
2815
|
-
for (let [e, n] of Object.entries(r)) r[e] =
|
|
2813
|
+
for (let [e, n] of Object.entries(r)) r[e] = dr(n, t), i ||= r[e] !== n;
|
|
2816
2814
|
return i ? r : e;
|
|
2817
2815
|
}
|
|
2818
|
-
function
|
|
2816
|
+
function fr(e, t) {
|
|
2819
2817
|
let n = e.properties ?? {}, r = e.required ?? [];
|
|
2820
2818
|
return Object.keys(n).map((e) => ({
|
|
2821
2819
|
name: e,
|
|
2822
2820
|
required: r.includes(e),
|
|
2823
|
-
defaultValue:
|
|
2824
|
-
schema: t.size ?
|
|
2821
|
+
defaultValue: En(n[e]),
|
|
2822
|
+
schema: t.size ? dr(n[e], t) : n[e]
|
|
2825
2823
|
}));
|
|
2826
2824
|
}
|
|
2827
|
-
function
|
|
2825
|
+
function pr(e) {
|
|
2828
2826
|
let t = /* @__PURE__ */ new Map(), n = e.properties && new Set(Object.keys(e.properties)), r = /* @__PURE__ */ new Map();
|
|
2829
|
-
for (let t of [...Object.keys(
|
|
2827
|
+
for (let t of [...Object.keys(Pe), ...Object.keys(e.actions ?? {})]) {
|
|
2830
2828
|
let i = e.$defs?.[t];
|
|
2831
2829
|
i && !n?.has(t) && r.set(`#/$defs/${t}`, i);
|
|
2832
2830
|
}
|
|
2833
|
-
for (let [i, a] of Object.entries(e.$defs ?? {})) (n ? !n.has(i) : r.has(`#/$defs/${i}`)) || t.set(i, { params:
|
|
2834
|
-
t.callDefs = new Map(
|
|
2831
|
+
for (let [i, a] of Object.entries(e.$defs ?? {})) (n ? !n.has(i) : r.has(`#/$defs/${i}`)) || t.set(i, { params: fr(a, r) });
|
|
2832
|
+
t.callDefs = new Map(j);
|
|
2835
2833
|
for (let [n, i] of Object.entries(e.functions ?? {})) t.callDefs.set(n, {
|
|
2836
2834
|
kind: "function",
|
|
2837
|
-
params:
|
|
2835
|
+
params: fr(i.params, r)
|
|
2838
2836
|
});
|
|
2839
2837
|
for (let [n, i] of Object.entries(e.actions ?? {})) t.callDefs.set(n, {
|
|
2840
2838
|
kind: "action",
|
|
2841
|
-
params:
|
|
2839
|
+
params: fr(i.params, r)
|
|
2842
2840
|
});
|
|
2843
2841
|
return t;
|
|
2844
2842
|
}
|
|
2845
|
-
function
|
|
2846
|
-
let n =
|
|
2843
|
+
function mr(e, t) {
|
|
2844
|
+
let n = pr(e);
|
|
2847
2845
|
return { parse(e) {
|
|
2848
|
-
let r =
|
|
2846
|
+
let r = dt();
|
|
2849
2847
|
try {
|
|
2850
|
-
let i =
|
|
2851
|
-
return
|
|
2848
|
+
let i = lr(e, n, t);
|
|
2849
|
+
return ft(r, i), i;
|
|
2852
2850
|
} catch (e) {
|
|
2853
|
-
throw
|
|
2851
|
+
throw pt(r), e;
|
|
2854
2852
|
}
|
|
2855
2853
|
} };
|
|
2856
2854
|
}
|
|
2857
|
-
function
|
|
2858
|
-
return
|
|
2855
|
+
function hr(e, t) {
|
|
2856
|
+
return ur(pr(e), t);
|
|
2859
2857
|
}
|
|
2860
|
-
function
|
|
2858
|
+
function gr(e, t) {
|
|
2861
2859
|
if (!t?.properties) return;
|
|
2862
2860
|
let n = new Set(t.required ?? []);
|
|
2863
2861
|
return `Signature: ${e}(${Object.keys(t.properties).map((e) => n.has(e) ? `${e}*` : e).join(", ")}) — * marks required`;
|
|
2864
2862
|
}
|
|
2865
|
-
function
|
|
2863
|
+
function _r(e, t, n) {
|
|
2866
2864
|
return e.map((e) => {
|
|
2867
2865
|
let r = {
|
|
2868
2866
|
source: "parser",
|
|
@@ -2873,10 +2871,10 @@ function Er(e, t, n) {
|
|
|
2873
2871
|
statementId: e.statementId,
|
|
2874
2872
|
...e.severity && { severity: e.severity }
|
|
2875
2873
|
};
|
|
2876
|
-
return e.code === "unknown-component" && n.length ? r.hint = `Available components: ${n.join(", ")}` : e.code === "missing-required" || e.code === "null-required" ? r.hint =
|
|
2874
|
+
return e.code === "unknown-component" && n.length ? r.hint = `Available components: ${n.join(", ")}` : e.code === "missing-required" || e.code === "null-required" ? r.hint = gr(e.component, t.$defs?.[e.component]) : e.code === "inline-reserved" && (r.hint = `Declare as a top-level statement: myVar = ${e.component}(...)`), r;
|
|
2877
2875
|
});
|
|
2878
2876
|
}
|
|
2879
|
-
function
|
|
2877
|
+
function vr(e) {
|
|
2880
2878
|
let t = [], n = 0, r = !1, i = !1, a = 0;
|
|
2881
2879
|
for (let o = 0; o < e.length; o++) {
|
|
2882
2880
|
let s = e[o];
|
|
@@ -2906,40 +2904,40 @@ function Dr(e) {
|
|
|
2906
2904
|
let o = e.slice(a).trim();
|
|
2907
2905
|
return o && t.push(o), t;
|
|
2908
2906
|
}
|
|
2909
|
-
function
|
|
2907
|
+
function yr(e) {
|
|
2910
2908
|
let t = e.trim();
|
|
2911
2909
|
if (!t) return [];
|
|
2912
2910
|
let n = [];
|
|
2913
|
-
for (let e of
|
|
2914
|
-
let t =
|
|
2911
|
+
for (let e of vr(t)) {
|
|
2912
|
+
let t = Jn(vn(e))[0];
|
|
2915
2913
|
t && n.push({
|
|
2916
2914
|
id: t.id,
|
|
2917
|
-
ast:
|
|
2915
|
+
ast: _n(t.tokens),
|
|
2918
2916
|
raw: e
|
|
2919
2917
|
});
|
|
2920
2918
|
}
|
|
2921
2919
|
return n;
|
|
2922
2920
|
}
|
|
2923
|
-
function
|
|
2924
|
-
|
|
2921
|
+
function br(e, t) {
|
|
2922
|
+
U(e, (e) => {
|
|
2925
2923
|
e.k === "Ref" && t.add(e.n), e.k === "RuntimeRef" && t.add(e.n);
|
|
2926
2924
|
});
|
|
2927
2925
|
}
|
|
2928
|
-
function
|
|
2926
|
+
function xr(e, t, n, r = "root") {
|
|
2929
2927
|
if (!n.get(r)) return;
|
|
2930
2928
|
let i = new Set([r]), a = [r];
|
|
2931
2929
|
for (; a.length > 0;) {
|
|
2932
2930
|
let e = a.pop(), t = n.get(e);
|
|
2933
2931
|
if (!t) continue;
|
|
2934
2932
|
let r = /* @__PURE__ */ new Set();
|
|
2935
|
-
|
|
2933
|
+
br(t, r);
|
|
2936
2934
|
for (let e of r) !i.has(e) && n.has(e) && (i.add(e), a.push(e));
|
|
2937
2935
|
}
|
|
2938
2936
|
for (let t of e) t.startsWith("$") && i.add(t);
|
|
2939
2937
|
for (let n = e.length - 1; n >= 0; n--) i.has(e[n]) || (t.delete(e[n]), e.splice(n, 1));
|
|
2940
2938
|
}
|
|
2941
|
-
function
|
|
2942
|
-
let r =
|
|
2939
|
+
function Sr(e, t, n = "root") {
|
|
2940
|
+
let r = yr(e), i = yr(or(t));
|
|
2943
2941
|
if (!r.length) return i.map((e) => e.raw).join("\n");
|
|
2944
2942
|
if (!i.length) return e;
|
|
2945
2943
|
let a = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), s = [];
|
|
@@ -2953,12 +2951,12 @@ function jr(e, t, n = "root") {
|
|
|
2953
2951
|
}
|
|
2954
2952
|
a.has(e.id) || s.push(e.id), a.set(e.id, e.raw), o.set(e.id, e.ast);
|
|
2955
2953
|
}
|
|
2956
|
-
return
|
|
2954
|
+
return xr(s, a, o, n), s.filter((e) => a.has(e)).map((e) => a.get(e)).join("\n");
|
|
2957
2955
|
}
|
|
2958
|
-
function
|
|
2956
|
+
function Cr(e) {
|
|
2959
2957
|
return typeof e == "object" && !!e && e.__reactive === "assign";
|
|
2960
2958
|
}
|
|
2961
|
-
function
|
|
2959
|
+
function X(e, t, n) {
|
|
2962
2960
|
switch (e.k) {
|
|
2963
2961
|
case "Str": return e.v;
|
|
2964
2962
|
case "Num": return e.v;
|
|
@@ -2968,39 +2966,39 @@ function Z(e, t, n) {
|
|
|
2968
2966
|
case "StateRef": return t.extraScope?.[e.n] ?? t.getState(e.n);
|
|
2969
2967
|
case "Ref":
|
|
2970
2968
|
case "RuntimeRef": return t.resolveRef(e.n);
|
|
2971
|
-
case "Arr": return e.els.map((e) =>
|
|
2972
|
-
case "Obj": return Object.fromEntries(e.entries.map(([e, n]) => [e,
|
|
2969
|
+
case "Arr": return e.els.map((e) => X(e, t));
|
|
2970
|
+
case "Obj": return Object.fromEntries(e.entries.map(([e, n]) => [e, X(n, t)]));
|
|
2973
2971
|
case "Comp": {
|
|
2974
|
-
let r =
|
|
2975
|
-
if (r) return r.lazy ?
|
|
2976
|
-
if (
|
|
2972
|
+
let r = Oe[e.name];
|
|
2973
|
+
if (r) return r.lazy ? Lr(e.name, e.args, t, n) : r.fn(Tr(e, t));
|
|
2974
|
+
if (Re(e.name)) return Pr(e, t);
|
|
2977
2975
|
let i = t.functions;
|
|
2978
|
-
if (i && Object.prototype.hasOwnProperty.call(i, e.name)) return
|
|
2976
|
+
if (i && Object.prototype.hasOwnProperty.call(i, e.name)) return kr(e.name, i[e.name], e, t);
|
|
2979
2977
|
let a = t.actions;
|
|
2980
2978
|
if (a && Object.prototype.hasOwnProperty.call(a, e.name)) {
|
|
2981
|
-
let n = a[e.name], r =
|
|
2982
|
-
if (
|
|
2983
|
-
let i =
|
|
2984
|
-
if (i ===
|
|
2979
|
+
let n = a[e.name], r = Er(e, t, n.params);
|
|
2980
|
+
if (Or(r, n.params)) return { steps: [] };
|
|
2981
|
+
let i = Dr(r, n.params, e.name, "", t, !0);
|
|
2982
|
+
if (i === K) return { steps: [] };
|
|
2985
2983
|
let o = {
|
|
2986
2984
|
type: "custom_action",
|
|
2987
2985
|
name: e.name,
|
|
2988
2986
|
params: i
|
|
2989
2987
|
};
|
|
2990
|
-
return
|
|
2988
|
+
return Mr.add(o), { steps: [o] };
|
|
2991
2989
|
}
|
|
2992
2990
|
if (e.mappedProps) {
|
|
2993
2991
|
let r = n?.library.components[e.name], i = {};
|
|
2994
2992
|
for (let [a, o] of Object.entries(e.mappedProps)) {
|
|
2995
2993
|
let e = r?.props?.shape?.[a];
|
|
2996
|
-
o.k === "StateRef" && e &&
|
|
2994
|
+
o.k === "StateRef" && e && d(e) ? i[a] = {
|
|
2997
2995
|
__reactive: "assign",
|
|
2998
2996
|
target: o.n,
|
|
2999
2997
|
expr: {
|
|
3000
2998
|
k: "StateRef",
|
|
3001
2999
|
n: "$value"
|
|
3002
3000
|
}
|
|
3003
|
-
} : o.k === "StateRef" ? i[a] = n ? t.getState(o.n) : o : i[a] =
|
|
3001
|
+
} : o.k === "StateRef" ? i[a] = n ? t.getState(o.n) : o : i[a] = X(o, t, n);
|
|
3004
3002
|
}
|
|
3005
3003
|
let a = {
|
|
3006
3004
|
type: "element",
|
|
@@ -3009,39 +3007,39 @@ function Z(e, t, n) {
|
|
|
3009
3007
|
partial: !1,
|
|
3010
3008
|
hasDynamicProps: !0
|
|
3011
3009
|
};
|
|
3012
|
-
if (n) for (let [e, r] of Object.entries(i))
|
|
3010
|
+
if (n) for (let [e, r] of Object.entries(i)) V(r) ? i[e] = Z(r, t, n) : Array.isArray(r) && (i[e] = r.map((e) => V(e) ? Z(e, t, n) : e));
|
|
3013
3011
|
return a;
|
|
3014
3012
|
}
|
|
3015
3013
|
return console.warn(`[openui] Unexpected unmapped Comp node: ${e.name}`), null;
|
|
3016
3014
|
}
|
|
3017
3015
|
case "BinOp": {
|
|
3018
|
-
if (e.op === "&&") return
|
|
3019
|
-
if (e.op === "||") return
|
|
3020
|
-
let n =
|
|
3016
|
+
if (e.op === "&&") return X(e.left, t) && X(e.right, t);
|
|
3017
|
+
if (e.op === "||") return X(e.left, t) || X(e.right, t);
|
|
3018
|
+
let n = X(e.left, t), r = X(e.right, t);
|
|
3021
3019
|
switch (e.op) {
|
|
3022
|
-
case "+": return typeof n == "string" || typeof r == "string" ? String(n ?? "") + String(r ?? "") :
|
|
3023
|
-
case "-": return
|
|
3024
|
-
case "*": return
|
|
3025
|
-
case "/": return
|
|
3026
|
-
case "%": return
|
|
3020
|
+
case "+": return typeof n == "string" || typeof r == "string" ? String(n ?? "") + String(r ?? "") : E(n) + E(r);
|
|
3021
|
+
case "-": return E(n) - E(r);
|
|
3022
|
+
case "*": return E(n) * E(r);
|
|
3023
|
+
case "/": return E(r) === 0 ? 0 : E(n) / E(r);
|
|
3024
|
+
case "%": return E(r) === 0 ? 0 : E(n) % E(r);
|
|
3027
3025
|
case "==": return n == r;
|
|
3028
3026
|
case "!=": return n != r;
|
|
3029
|
-
case ">": return
|
|
3030
|
-
case "<": return
|
|
3031
|
-
case ">=": return
|
|
3032
|
-
case "<=": return
|
|
3027
|
+
case ">": return E(n) > E(r);
|
|
3028
|
+
case "<": return E(n) < E(r);
|
|
3029
|
+
case ">=": return E(n) >= E(r);
|
|
3030
|
+
case "<=": return E(n) <= E(r);
|
|
3033
3031
|
default: return null;
|
|
3034
3032
|
}
|
|
3035
3033
|
}
|
|
3036
|
-
case "UnaryOp": return e.op === "!" ? !
|
|
3037
|
-
case "Ternary": return
|
|
3034
|
+
case "UnaryOp": return e.op === "!" ? !X(e.operand, t) : e.op === "-" ? -E(X(e.operand, t)) : null;
|
|
3035
|
+
case "Ternary": return X(e.cond, t) ? X(e.then, t) : X(e.else, t);
|
|
3038
3036
|
case "Member": {
|
|
3039
|
-
let n =
|
|
3037
|
+
let n = X(e.obj, t);
|
|
3040
3038
|
return n == null ? null : Array.isArray(n) ? e.field === "length" ? n.length : n.map((t) => t?.[e.field] ?? null) : n[e.field];
|
|
3041
3039
|
}
|
|
3042
3040
|
case "Index": {
|
|
3043
|
-
let n =
|
|
3044
|
-
return n == null || r == null ? null : Array.isArray(n) ? n[
|
|
3041
|
+
let n = X(e.obj, t), r = X(e.index, t);
|
|
3042
|
+
return n == null || r == null ? null : Array.isArray(n) ? n[E(r)] : n[String(r)];
|
|
3045
3043
|
}
|
|
3046
3044
|
case "Assign": return {
|
|
3047
3045
|
__reactive: "assign",
|
|
@@ -3050,53 +3048,53 @@ function Z(e, t, n) {
|
|
|
3050
3048
|
};
|
|
3051
3049
|
}
|
|
3052
3050
|
}
|
|
3053
|
-
function
|
|
3051
|
+
function Z(e, t, n) {
|
|
3054
3052
|
if (e.hasDynamicProps === !1) return e;
|
|
3055
3053
|
let r = n.library.components[e.typeName], i = {};
|
|
3056
3054
|
for (let [a, o] of Object.entries(e.props)) {
|
|
3057
3055
|
let e = r?.props?.shape?.[a];
|
|
3058
|
-
i[a] =
|
|
3056
|
+
i[a] = wr(o, t, n, e);
|
|
3059
3057
|
}
|
|
3060
3058
|
return {
|
|
3061
3059
|
...e,
|
|
3062
3060
|
props: i
|
|
3063
3061
|
};
|
|
3064
3062
|
}
|
|
3065
|
-
function
|
|
3066
|
-
return
|
|
3067
|
-
recurseElement: (e) =>
|
|
3068
|
-
recurse: (e, r) =>
|
|
3063
|
+
function wr(e, t, n, r) {
|
|
3064
|
+
return Rr(e, t, n, r, {
|
|
3065
|
+
recurseElement: (e) => Z(e, t, n),
|
|
3066
|
+
recurse: (e, r) => wr(e, t, n, r)
|
|
3069
3067
|
});
|
|
3070
3068
|
}
|
|
3071
|
-
function
|
|
3072
|
-
let r = e.mappedProps ??
|
|
3073
|
-
for (let e in r) i[e] =
|
|
3069
|
+
function Tr(e, t, n = j.get(e.name)?.params ?? []) {
|
|
3070
|
+
let r = e.mappedProps ?? Vn(e.args, n), i = {};
|
|
3071
|
+
for (let e in r) i[e] = X(r[e], t);
|
|
3074
3072
|
return i;
|
|
3075
3073
|
}
|
|
3076
|
-
function
|
|
3077
|
-
let r =
|
|
3074
|
+
function Er(e, t, n) {
|
|
3075
|
+
let r = Tr(e, t, Object.keys(n.properties ?? {}).map((e) => ({
|
|
3078
3076
|
name: e,
|
|
3079
3077
|
required: !1
|
|
3080
3078
|
})));
|
|
3081
3079
|
for (let e in r) r[e] === null && !n.required?.includes(e) && delete r[e];
|
|
3082
3080
|
return r;
|
|
3083
3081
|
}
|
|
3084
|
-
function
|
|
3082
|
+
function Dr(e, t, n, r, i, a = !1) {
|
|
3085
3083
|
let o = {
|
|
3086
3084
|
errors: [],
|
|
3087
3085
|
partial: !1
|
|
3088
|
-
}, s =
|
|
3086
|
+
}, s = q(e, t, n, r, o);
|
|
3089
3087
|
for (let e of o.errors) i.reportError?.(`@${n}: ${e.message}`);
|
|
3090
|
-
return a && o.errors.length > 0 ?
|
|
3088
|
+
return a && o.errors.length > 0 ? K : s;
|
|
3091
3089
|
}
|
|
3092
|
-
function
|
|
3093
|
-
return !!t.required?.some((n) => e[n] == null &&
|
|
3090
|
+
function Or(e, t) {
|
|
3091
|
+
return !!t.required?.some((n) => e[n] == null && En(t.properties?.[n]) === void 0);
|
|
3094
3092
|
}
|
|
3095
|
-
function
|
|
3096
|
-
let i =
|
|
3097
|
-
if (
|
|
3098
|
-
let a =
|
|
3099
|
-
if (a ===
|
|
3093
|
+
function kr(e, t, n, r) {
|
|
3094
|
+
let i = Er(n, r, t.params);
|
|
3095
|
+
if (Or(i, t.params)) return null;
|
|
3096
|
+
let a = Dr(i, t.params, e, "", r);
|
|
3097
|
+
if (a === K) return null;
|
|
3100
3098
|
let o;
|
|
3101
3099
|
try {
|
|
3102
3100
|
o = t.fn(a);
|
|
@@ -3104,51 +3102,51 @@ function zr(e, t, n, r) {
|
|
|
3104
3102
|
return r.reportError?.(`@${e} threw: ${t instanceof Error ? t.message : String(t)}`), null;
|
|
3105
3103
|
}
|
|
3106
3104
|
if (!t.returns) return o;
|
|
3107
|
-
let s =
|
|
3108
|
-
return s ===
|
|
3105
|
+
let s = Dr(o, t.returns, e, "/returns", r);
|
|
3106
|
+
return s === K ? null : s ?? null;
|
|
3109
3107
|
}
|
|
3110
|
-
function
|
|
3108
|
+
function Ar(e) {
|
|
3111
3109
|
return typeof e == "object" && !!e && Array.isArray(e.steps);
|
|
3112
3110
|
}
|
|
3113
|
-
function
|
|
3114
|
-
return
|
|
3111
|
+
function jr(e) {
|
|
3112
|
+
return Nr({ steps: e.flatMap((e) => Ar(e) ? e.steps : typeof e == "object" && e && "type" in e ? [e] : []) });
|
|
3115
3113
|
}
|
|
3116
|
-
var
|
|
3117
|
-
function
|
|
3118
|
-
let t = (e) => e?.type !== "custom_action" ||
|
|
3114
|
+
var Mr = /* @__PURE__ */ new WeakSet();
|
|
3115
|
+
function Nr(e) {
|
|
3116
|
+
let t = (e) => e?.type !== "custom_action" || Mr.has(e);
|
|
3119
3117
|
return e.steps.every(t) ? e : {
|
|
3120
3118
|
...e,
|
|
3121
3119
|
steps: e.steps.filter(t)
|
|
3122
3120
|
};
|
|
3123
3121
|
}
|
|
3124
|
-
function
|
|
3122
|
+
function Pr(e, t) {
|
|
3125
3123
|
let { name: n, args: r } = e;
|
|
3126
3124
|
if (n === "Action") {
|
|
3127
|
-
let e = r.length > 0 ?
|
|
3128
|
-
return
|
|
3125
|
+
let e = r.length > 0 ? X(r[0], t) : [];
|
|
3126
|
+
return jr(Array.isArray(e) ? e : []);
|
|
3129
3127
|
}
|
|
3130
|
-
let i =
|
|
3128
|
+
let i = Ie[n], a = i.step ? i.step(Tr(e, t)) : Fr(n, r);
|
|
3131
3129
|
return { steps: a ? [a] : [] };
|
|
3132
3130
|
}
|
|
3133
|
-
function
|
|
3131
|
+
function Fr(e, t) {
|
|
3134
3132
|
switch (e) {
|
|
3135
3133
|
case "Run": {
|
|
3136
3134
|
let e = t[0];
|
|
3137
3135
|
return e?.k === "RuntimeRef" ? {
|
|
3138
|
-
type:
|
|
3136
|
+
type: k.Run,
|
|
3139
3137
|
statementId: e.n,
|
|
3140
3138
|
refType: e.refType
|
|
3141
3139
|
} : null;
|
|
3142
3140
|
}
|
|
3143
3141
|
case "Set": return t.length < 2 || t[0].k !== "StateRef" ? null : {
|
|
3144
|
-
type:
|
|
3142
|
+
type: k.Set,
|
|
3145
3143
|
target: t[0].n,
|
|
3146
3144
|
valueAST: t[1]
|
|
3147
3145
|
};
|
|
3148
3146
|
case "Reset": {
|
|
3149
3147
|
let e = t.filter((e) => e.k === "StateRef").map((e) => e.n);
|
|
3150
3148
|
return e.length === 0 ? null : {
|
|
3151
|
-
type:
|
|
3149
|
+
type: k.Reset,
|
|
3152
3150
|
targets: e
|
|
3153
3151
|
};
|
|
3154
3152
|
}
|
|
@@ -3157,9 +3155,9 @@ function Gr(e, t) {
|
|
|
3157
3155
|
}
|
|
3158
3156
|
function Q(e, t, n) {
|
|
3159
3157
|
switch (e.k) {
|
|
3160
|
-
case "Ref": return e.n === t ?
|
|
3158
|
+
case "Ref": return e.n === t ? sn(n) : e;
|
|
3161
3159
|
case "Member":
|
|
3162
|
-
if (
|
|
3160
|
+
if (H(e.obj)) {
|
|
3163
3161
|
let r = Q(e.obj, t, n);
|
|
3164
3162
|
if (r.k === "Obj") {
|
|
3165
3163
|
let t = r.entries.find(([t]) => t === e.field);
|
|
@@ -3173,8 +3171,8 @@ function Q(e, t, n) {
|
|
|
3173
3171
|
return e;
|
|
3174
3172
|
case "Index": return {
|
|
3175
3173
|
...e,
|
|
3176
|
-
obj:
|
|
3177
|
-
index:
|
|
3174
|
+
obj: H(e.obj) ? Q(e.obj, t, n) : e.obj,
|
|
3175
|
+
index: H(e.index) ? Q(e.index, t, n) : e.index
|
|
3178
3176
|
};
|
|
3179
3177
|
case "BinOp": return {
|
|
3180
3178
|
...e,
|
|
@@ -3204,7 +3202,7 @@ function Q(e, t, n) {
|
|
|
3204
3202
|
...e,
|
|
3205
3203
|
args: e.args.map(r)
|
|
3206
3204
|
};
|
|
3207
|
-
return e.mappedProps && (i.mappedProps =
|
|
3205
|
+
return e.mappedProps && (i.mappedProps = Ir(e.mappedProps, r)), i;
|
|
3208
3206
|
}
|
|
3209
3207
|
case "Assign": return {
|
|
3210
3208
|
...e,
|
|
@@ -3213,15 +3211,15 @@ function Q(e, t, n) {
|
|
|
3213
3211
|
default: return e;
|
|
3214
3212
|
}
|
|
3215
3213
|
}
|
|
3216
|
-
function
|
|
3214
|
+
function Ir(e, t) {
|
|
3217
3215
|
let n = {};
|
|
3218
3216
|
for (let r in e) n[r] = t(e[r]);
|
|
3219
3217
|
return n;
|
|
3220
3218
|
}
|
|
3221
|
-
function
|
|
3219
|
+
function Lr(e, t, n, r) {
|
|
3222
3220
|
if (e === "Each") {
|
|
3223
3221
|
if (t.length < 3) return [];
|
|
3224
|
-
let e =
|
|
3222
|
+
let e = X(t[0], n);
|
|
3225
3223
|
if (!Array.isArray(e)) return [];
|
|
3226
3224
|
let i = t[1].k === "Ref" ? t[1].n : t[1].k === "Str" ? t[1].v : null;
|
|
3227
3225
|
if (!i) return [];
|
|
@@ -3230,20 +3228,20 @@ function qr(e, t, n, r) {
|
|
|
3230
3228
|
let o = Q(a, i, e), s = {
|
|
3231
3229
|
...n,
|
|
3232
3230
|
resolveRef: (t) => t === i ? e : n.resolveRef(t)
|
|
3233
|
-
}, c =
|
|
3234
|
-
return r &&
|
|
3231
|
+
}, c = X(o, s, r);
|
|
3232
|
+
return r && V(c) ? Z(c, s, r) : c;
|
|
3235
3233
|
});
|
|
3236
3234
|
}
|
|
3237
3235
|
return null;
|
|
3238
3236
|
}
|
|
3239
|
-
function
|
|
3240
|
-
let a =
|
|
3241
|
-
return
|
|
3237
|
+
function Rr(e, t, n, r, i) {
|
|
3238
|
+
let a = zr(e, t, n, r, i);
|
|
3239
|
+
return Ar(a) ? Nr(a) : a;
|
|
3242
3240
|
}
|
|
3243
|
-
function
|
|
3241
|
+
function zr(e, t, n, r, i) {
|
|
3244
3242
|
if (typeof e != "object" || !e) return e;
|
|
3245
|
-
if (
|
|
3246
|
-
if (e.k === "StateRef" && r &&
|
|
3243
|
+
if (H(e)) {
|
|
3244
|
+
if (e.k === "StateRef" && r && d(r)) return {
|
|
3247
3245
|
__reactive: "assign",
|
|
3248
3246
|
target: e.n,
|
|
3249
3247
|
expr: {
|
|
@@ -3251,13 +3249,13 @@ function Yr(e, t, n, r, i) {
|
|
|
3251
3249
|
n: "$value"
|
|
3252
3250
|
}
|
|
3253
3251
|
};
|
|
3254
|
-
let a =
|
|
3255
|
-
return
|
|
3252
|
+
let a = X(e, t, n);
|
|
3253
|
+
return V(a) ? i.recurseElement(a) : Array.isArray(a) ? a.map((e) => V(e) ? i.recurseElement(e) : e) : Cr(a) && !(r && d(r)) ? t.getState(a.target) ?? null : a;
|
|
3256
3254
|
}
|
|
3257
|
-
if (typeof e == "string" && r &&
|
|
3255
|
+
if (typeof e == "string" && r && d(r)) return e;
|
|
3258
3256
|
if (Array.isArray(e)) return e.map((e) => i.recurse(e, r));
|
|
3259
|
-
if (
|
|
3260
|
-
if (
|
|
3257
|
+
if (V(e)) return i.recurseElement(e);
|
|
3258
|
+
if (Ar(e)) return e;
|
|
3261
3259
|
let a = e, o = !1;
|
|
3262
3260
|
for (let e of Object.values(a)) if (typeof e == "object" && e) {
|
|
3263
3261
|
o = !0;
|
|
@@ -3270,7 +3268,7 @@ function Yr(e, t, n, r, i) {
|
|
|
3270
3268
|
}
|
|
3271
3269
|
return e;
|
|
3272
3270
|
}
|
|
3273
|
-
function
|
|
3271
|
+
function Br(e, t) {
|
|
3274
3272
|
if (e.hasDynamicProps === !1) return e;
|
|
3275
3273
|
let n = { library: t.library }, r = t.library.components[e.typeName], i = {}, a = "", o = (n) => {
|
|
3276
3274
|
t.errors?.push({
|
|
@@ -3292,7 +3290,7 @@ function Xr(e, t) {
|
|
|
3292
3290
|
a = t;
|
|
3293
3291
|
let e = r?.props?.shape?.[a];
|
|
3294
3292
|
try {
|
|
3295
|
-
i[a] =
|
|
3293
|
+
i[a] = Hr(c, s, n, e);
|
|
3296
3294
|
} catch (e) {
|
|
3297
3295
|
i[a] = c, o(e instanceof Error ? e.message : String(e));
|
|
3298
3296
|
}
|
|
@@ -3302,33 +3300,33 @@ function Xr(e, t) {
|
|
|
3302
3300
|
props: i
|
|
3303
3301
|
};
|
|
3304
3302
|
}
|
|
3305
|
-
function
|
|
3306
|
-
if (e.root) return
|
|
3303
|
+
function Vr(e, t) {
|
|
3304
|
+
if (e.root) return Br(e.root, t);
|
|
3307
3305
|
if (!e.rootExpression) return null;
|
|
3308
|
-
let n =
|
|
3309
|
-
return
|
|
3306
|
+
let n = X(e.rootExpression, t.ctx, { library: t.library });
|
|
3307
|
+
return V(n) ? Br(n, t) : (t.errors?.push({
|
|
3310
3308
|
source: "runtime",
|
|
3311
3309
|
code: "no-root",
|
|
3312
3310
|
statementId: "root",
|
|
3313
3311
|
message: "root does not evaluate to a component"
|
|
3314
3312
|
}), null);
|
|
3315
3313
|
}
|
|
3316
|
-
function
|
|
3317
|
-
return
|
|
3318
|
-
recurseElement: (e) =>
|
|
3319
|
-
recurse: (e, r) =>
|
|
3314
|
+
function Hr(e, t, n, r) {
|
|
3315
|
+
return Rr(e, t.ctx, n, r, {
|
|
3316
|
+
recurseElement: (e) => Br(e, t),
|
|
3317
|
+
recurse: (e, r) => Hr(e, t, n, r)
|
|
3320
3318
|
});
|
|
3321
3319
|
}
|
|
3322
|
-
var
|
|
3320
|
+
var Ur = class extends Error {
|
|
3323
3321
|
toolErrorText;
|
|
3324
3322
|
constructor(e) {
|
|
3325
3323
|
super(`MCP tool error: ${e || "Unknown error"}`), this.name = "McpToolError", this.toolErrorText = e;
|
|
3326
3324
|
}
|
|
3327
3325
|
};
|
|
3328
|
-
function
|
|
3326
|
+
function Wr(e) {
|
|
3329
3327
|
if (e.isError) {
|
|
3330
3328
|
let t = e.content?.filter((e) => e.type === "text").map((e) => e.text).join("\n");
|
|
3331
|
-
throw new
|
|
3329
|
+
throw new Ur(t || "Unknown error");
|
|
3332
3330
|
}
|
|
3333
3331
|
if (e.structuredContent != null) return e.structuredContent;
|
|
3334
3332
|
let t = e.content?.filter((e) => e.type === "text").map((e) => e.text ?? "");
|
|
@@ -3342,14 +3340,14 @@ function ei(e) {
|
|
|
3342
3340
|
}
|
|
3343
3341
|
return null;
|
|
3344
3342
|
}
|
|
3345
|
-
var
|
|
3343
|
+
var Gr = class extends Error {
|
|
3346
3344
|
toolName;
|
|
3347
3345
|
availableTools;
|
|
3348
3346
|
constructor(e, t = []) {
|
|
3349
3347
|
super(`[openui] No handler for tool "${e}". Available: ${t.join(", ") || "(none)"}`), this.name = "ToolNotFoundError", this.toolName = e, this.availableTools = t;
|
|
3350
3348
|
}
|
|
3351
3349
|
};
|
|
3352
|
-
function
|
|
3350
|
+
function Kr(e) {
|
|
3353
3351
|
return JSON.stringify(e, (e, t) => {
|
|
3354
3352
|
if (t && typeof t == "object" && !Array.isArray(t)) {
|
|
3355
3353
|
let e = {};
|
|
@@ -3365,11 +3363,11 @@ function ni(e) {
|
|
|
3365
3363
|
return t;
|
|
3366
3364
|
});
|
|
3367
3365
|
}
|
|
3368
|
-
function
|
|
3369
|
-
let r = n == null ? "" : "::" +
|
|
3370
|
-
return e + "::" +
|
|
3366
|
+
function qr(e, t, n) {
|
|
3367
|
+
let r = n == null ? "" : "::" + Kr(n);
|
|
3368
|
+
return e + "::" + Kr(t) + r;
|
|
3371
3369
|
}
|
|
3372
|
-
function
|
|
3370
|
+
function Jr(e) {
|
|
3373
3371
|
let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Set(), a = {
|
|
3374
3372
|
__openui_loading: [],
|
|
3375
3373
|
__openui_refetching: [],
|
|
@@ -3426,7 +3424,7 @@ function ii(e) {
|
|
|
3426
3424
|
}
|
|
3427
3425
|
} catch (e) {
|
|
3428
3426
|
let n = t.get(i);
|
|
3429
|
-
n && n.cacheKey === o && (e instanceof
|
|
3427
|
+
n && n.cacheKey === o && (e instanceof Gr ? n.error = {
|
|
3430
3428
|
source: "query",
|
|
3431
3429
|
code: "tool-not-found",
|
|
3432
3430
|
message: `Query tool "${c}" not found`,
|
|
@@ -3434,7 +3432,7 @@ function ii(e) {
|
|
|
3434
3432
|
component: "Query",
|
|
3435
3433
|
toolName: c,
|
|
3436
3434
|
hint: e.availableTools.length ? `Available tools: ${e.availableTools.join(", ")}` : void 0
|
|
3437
|
-
} : e instanceof
|
|
3435
|
+
} : e instanceof Ur ? n.error = {
|
|
3438
3436
|
source: "query",
|
|
3439
3437
|
code: "mcp-error",
|
|
3440
3438
|
message: `Query "${c}" returned an error: ${e.toolErrorText}`,
|
|
@@ -3465,7 +3463,7 @@ function ii(e) {
|
|
|
3465
3463
|
for (let [e, n] of t) i.has(e) || (n.timer && clearInterval(n.timer), t.delete(e), f(n.cacheKey), n.prevCacheKey && f(n.prevCacheKey));
|
|
3466
3464
|
for (let i of n) {
|
|
3467
3465
|
if (!i.complete) continue;
|
|
3468
|
-
let n =
|
|
3466
|
+
let n = qr(i.toolName, i.args, i.deps), a = t.get(i.statementId);
|
|
3469
3467
|
a ? (a.cacheKey !== n && (a.prevCacheKey = a.cacheKey), a.toolName = i.toolName, a.args = i.args, a.defaults = i.defaults, a.cacheKey = n) : t.set(i.statementId, {
|
|
3470
3468
|
toolName: i.toolName,
|
|
3471
3469
|
args: i.args,
|
|
@@ -3527,7 +3525,7 @@ function ii(e) {
|
|
|
3527
3525
|
}
|
|
3528
3526
|
l() && u();
|
|
3529
3527
|
}
|
|
3530
|
-
async function
|
|
3528
|
+
async function y(t, r, i) {
|
|
3531
3529
|
if (s || !e) return !1;
|
|
3532
3530
|
let a = n.get(t);
|
|
3533
3531
|
if (!a || a.result.status === "loading") return !1;
|
|
@@ -3547,7 +3545,7 @@ function ii(e) {
|
|
|
3547
3545
|
a.result = {
|
|
3548
3546
|
status: "error",
|
|
3549
3547
|
error: n
|
|
3550
|
-
}, e instanceof
|
|
3548
|
+
}, e instanceof Gr ? a.error = {
|
|
3551
3549
|
source: "mutation",
|
|
3552
3550
|
code: "tool-not-found",
|
|
3553
3551
|
message: `Mutation tool "${a.toolName}" not found`,
|
|
@@ -3555,7 +3553,7 @@ function ii(e) {
|
|
|
3555
3553
|
component: "Mutation",
|
|
3556
3554
|
toolName: a.toolName,
|
|
3557
3555
|
hint: e.availableTools.length ? `Available tools: ${e.availableTools.join(", ")}` : void 0
|
|
3558
|
-
} : e instanceof
|
|
3556
|
+
} : e instanceof Ur ? a.error = {
|
|
3559
3557
|
source: "mutation",
|
|
3560
3558
|
code: "mcp-error",
|
|
3561
3559
|
message: `Mutation "${a.toolName}" returned an error: ${e.toolErrorText}`,
|
|
@@ -3573,19 +3571,19 @@ function ii(e) {
|
|
|
3573
3571
|
}
|
|
3574
3572
|
return l(), u(), d && i?.length && _(i), d;
|
|
3575
3573
|
}
|
|
3576
|
-
function
|
|
3574
|
+
function ee(e) {
|
|
3577
3575
|
return n.get(e)?.result ?? null;
|
|
3578
3576
|
}
|
|
3579
|
-
function
|
|
3577
|
+
function b(e) {
|
|
3580
3578
|
return i.add(e), () => i.delete(e);
|
|
3581
3579
|
}
|
|
3582
|
-
function
|
|
3580
|
+
function te() {
|
|
3583
3581
|
return a;
|
|
3584
3582
|
}
|
|
3585
|
-
function
|
|
3583
|
+
function ne() {
|
|
3586
3584
|
s = !1;
|
|
3587
3585
|
}
|
|
3588
|
-
function
|
|
3586
|
+
function re() {
|
|
3589
3587
|
s = !0, c++, i.clear();
|
|
3590
3588
|
for (let e of t.values()) e.timer &&= (clearInterval(e.timer), void 0), e.refreshInterval = 0, e.loading = !1, e.needsRefetch = !1;
|
|
3591
3589
|
n.clear();
|
|
@@ -3597,22 +3595,22 @@ function ii(e) {
|
|
|
3597
3595
|
isAnyLoading: g,
|
|
3598
3596
|
invalidate: _,
|
|
3599
3597
|
registerMutations: v,
|
|
3600
|
-
fireMutation:
|
|
3601
|
-
getMutationResult:
|
|
3602
|
-
subscribe:
|
|
3603
|
-
getSnapshot:
|
|
3604
|
-
activate:
|
|
3605
|
-
dispose:
|
|
3598
|
+
fireMutation: y,
|
|
3599
|
+
getMutationResult: ee,
|
|
3600
|
+
subscribe: b,
|
|
3601
|
+
getSnapshot: te,
|
|
3602
|
+
activate: ne,
|
|
3603
|
+
dispose: re
|
|
3606
3604
|
};
|
|
3607
3605
|
}
|
|
3608
|
-
function
|
|
3609
|
-
if (
|
|
3606
|
+
function Yr(e, t, n, r, i, a) {
|
|
3607
|
+
if (Cr(t) && n && r) {
|
|
3610
3608
|
let { target: i, expr: a } = t;
|
|
3611
3609
|
return {
|
|
3612
3610
|
name: e,
|
|
3613
3611
|
value: n.get(i),
|
|
3614
3612
|
setValue: (e) => {
|
|
3615
|
-
let t = { $value: e }, o =
|
|
3613
|
+
let t = { $value: e }, o = X(a, {
|
|
3616
3614
|
...r,
|
|
3617
3615
|
extraScope: t
|
|
3618
3616
|
});
|
|
@@ -3628,7 +3626,7 @@ function ai(e, t, n, r, i, a) {
|
|
|
3628
3626
|
isReactive: !1
|
|
3629
3627
|
};
|
|
3630
3628
|
}
|
|
3631
|
-
function
|
|
3629
|
+
function Xr() {
|
|
3632
3630
|
let e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set(), r = {};
|
|
3633
3631
|
function i() {
|
|
3634
3632
|
let e = [...n];
|
|
@@ -3677,28 +3675,28 @@ function oi() {
|
|
|
3677
3675
|
dispose: d
|
|
3678
3676
|
};
|
|
3679
3677
|
}
|
|
3680
|
-
var
|
|
3678
|
+
var Zr = new Set([
|
|
3681
3679
|
"min",
|
|
3682
3680
|
"max",
|
|
3683
3681
|
"minLength",
|
|
3684
3682
|
"maxLength"
|
|
3685
3683
|
]);
|
|
3686
|
-
function
|
|
3684
|
+
function Qr(e) {
|
|
3687
3685
|
let t = e.indexOf(":");
|
|
3688
3686
|
if (t === -1) return { type: e };
|
|
3689
3687
|
let n = e.slice(0, t), r = e.slice(t + 1);
|
|
3690
3688
|
return {
|
|
3691
3689
|
type: n,
|
|
3692
|
-
arg:
|
|
3690
|
+
arg: Zr.has(n) && !Number.isNaN(Number(r)) ? Number(r) : r
|
|
3693
3691
|
};
|
|
3694
3692
|
}
|
|
3695
|
-
function
|
|
3696
|
-
return Array.isArray(e) ? e.filter((e) => typeof e == "string").map(
|
|
3693
|
+
function $r(e) {
|
|
3694
|
+
return Array.isArray(e) ? e.filter((e) => typeof e == "string").map(Qr) : [];
|
|
3697
3695
|
}
|
|
3698
3696
|
function $(e) {
|
|
3699
3697
|
return e == null || e === "" || Array.isArray(e) && e.length === 0 ? !0 : e && typeof e == "object" && !Array.isArray(e) && "value" in e ? $(e.value) : !!(typeof e == "object" && e && !Array.isArray(e) && Object.keys(e).length === 0);
|
|
3700
3698
|
}
|
|
3701
|
-
var
|
|
3699
|
+
var ei = {
|
|
3702
3700
|
required: (e) => {
|
|
3703
3701
|
if ($(e)) return "This field is required";
|
|
3704
3702
|
if (typeof e == "object" && !Array.isArray(e) && e !== null) {
|
|
@@ -3755,9 +3753,9 @@ var ui = {
|
|
|
3755
3753
|
}
|
|
3756
3754
|
}
|
|
3757
3755
|
};
|
|
3758
|
-
function
|
|
3756
|
+
function ti(e, t, n) {
|
|
3759
3757
|
for (let r of t) {
|
|
3760
|
-
let t = n?.[r.type] ??
|
|
3758
|
+
let t = n?.[r.type] ?? ei[r.type];
|
|
3761
3759
|
if (!t) {
|
|
3762
3760
|
console.warn(`[openui] Unknown validation rule type: "${r.type}"`);
|
|
3763
3761
|
continue;
|
|
@@ -3766,7 +3764,7 @@ function di(e, t, n) {
|
|
|
3766
3764
|
if (i) return i;
|
|
3767
3765
|
}
|
|
3768
3766
|
}
|
|
3769
|
-
function
|
|
3767
|
+
function ni(e) {
|
|
3770
3768
|
if (!e || typeof e != "object" || Array.isArray(e)) return [];
|
|
3771
3769
|
let t = e, n = [];
|
|
3772
3770
|
for (let [e, r] of Object.entries(t)) r === !1 || r == null || (r === !0 ? n.push({ type: e }) : n.push({
|
|
@@ -3776,4 +3774,4 @@ function fi(e) {
|
|
|
3776
3774
|
return n;
|
|
3777
3775
|
}
|
|
3778
3776
|
//#endregion
|
|
3779
|
-
export {
|
|
3777
|
+
export { k as ACTION_STEPS, rn as BuiltinActionType, Gr as ToolNotFoundError, Ne as action, nn as buildMessage, ei as builtInValidators, Jt as createLibrary, mr as createParser, Jr as createQueryManager, Xr as createStore, hr as createStreamingParser, T as defineAction, Ut as defineComponent, w as defineFunction, _r as enrichErrors, X as evaluate, Vr as evaluateRoot, Wr as extractToolResult, z as generatePrompt, Bt as generateSystemPrompt, Cr as isReactiveAssign, u as markReactive, Sr as mergeStatements, tn as parseMessage, $r as parseRules, ni as parseStructuredRules, Yr as resolveStateField, A as steps, p as tagSchemaId, ti as validate };
|