@qredence/fleet 0.5.1 → 0.5.5
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/CHANGELOG.md +7 -0
- package/bin/fleet-prime.mjs +6 -0
- package/dist/web/client/assets/action-swap-roll-DX5o_33Q.js +1 -0
- package/dist/web/client/assets/artifacts-panel-C3yewUBP.js +1 -0
- package/dist/web/client/assets/{chat-CsepBQwy.js → chat-W-yOMyG_.js} +1 -1
- package/dist/web/client/assets/chat-command-palette-D0xDK1j4.js +1 -0
- package/dist/web/client/assets/command-CQzrtjyj.js +2 -0
- package/dist/web/client/assets/{fleet-pi-tool-renderer-BD_ZAjlG.js → fleet-pi-tool-renderer-B0Y7ou0U.js} +16 -16
- package/dist/web/client/assets/generative-text-renderer-SS9c1kNX.js +6 -0
- package/dist/web/client/assets/globals-D_Hy9bT1.css +2 -0
- package/dist/web/client/assets/{index-DweoFRMs.js → index-C9FloFgj.js} +2 -2
- package/dist/web/client/assets/{ipython-tool-BfeIa0nK.js → ipython-tool-BrMePqD-.js} +1 -1
- package/dist/web/client/assets/{openui-renderer-DlUo6ehT.js → openui-renderer-CCfQqUfE.js} +5 -5
- package/dist/web/client/assets/{prime-agent-artifacts-CHGb5V_j.js → prime-agent-artifacts-C-g1VPiW.js} +1 -1
- package/dist/web/client/assets/range-65lubOFp.js +2 -0
- package/dist/web/client/assets/repl-panel-CCh4ly7J.js +1 -0
- package/dist/web/client/assets/routes-DSTyx_J0.js +16 -0
- package/dist/web/client/assets/session-insights-panel-CQdT90Op.js +1 -0
- package/dist/web/client/assets/subagent-chat-panel-D-qw4uWb.js +1 -0
- package/dist/web/client/assets/subagent-transcript-C7oRwEEP.js +1 -0
- package/dist/web/client/assets/subagents-panel-aSMWZP9p.js +1 -0
- package/dist/web/client/assets/{tool-result-CBzwwUE9.js → tool-result-C2NvnN32.js} +3 -3
- package/dist/web/server/{_tanstack-start-manifest_v-bDUlyKY0-KFW35JRO.js → _tanstack-start-manifest_v-DZc7dwm7-6ZQLGXB7.js} +13 -13
- package/dist/web/server/{artifacts-panel-D9w1DHAN-FGRDCYU2.js → artifacts-panel-Bt7YUzm4-NCBMXJ25.js} +15 -15
- package/dist/web/server/{chat-command-palette-BaenPkCN-BHSOPGU4.js → chat-command-palette-Co1L3rUY-RQLNME4T.js} +33 -12
- package/dist/web/server/{chunk-KPNGZR2R.js → chunk-2V6B62OF.js} +204 -204
- package/dist/web/server/{chunk-44IVTHDV.js → chunk-3HUI75QM.js} +60 -60
- package/dist/web/server/{chunk-5AVQZ4AZ.js → chunk-4UBOIY2S.js} +2 -1
- package/dist/web/server/{chunk-Y6LJ4WBI.js → chunk-56HSKUBD.js} +699 -691
- package/dist/web/server/{chunk-RPROZ2JC.js → chunk-5RQ6QAZX.js} +133 -133
- package/dist/web/server/{chunk-PWK2HJIV.js → chunk-6D524OCJ.js} +175 -175
- package/dist/web/server/{chunk-FBOO3G67.js → chunk-AECEK3K7.js} +6 -6
- package/dist/web/server/{chunk-VHCAD46L.js → chunk-AWFOBHH4.js} +4 -4
- package/dist/web/server/{chunk-FVWDJNXR.js → chunk-BEMDNODD.js} +1 -1
- package/dist/web/server/{chunk-X2TUFLTP.js → chunk-BLVCDQ7E.js} +438 -438
- package/dist/web/server/{chunk-EIVNRYP3.js → chunk-FZRBAPUM.js} +2 -2
- package/dist/web/server/chunk-KOIPYBJF.js +3773 -0
- package/dist/web/server/{chunk-XYYNYFFD.js → chunk-LSIHVSUT.js} +2 -2
- package/dist/web/server/{chunk-H64JLONZ.js → chunk-PDRD2X5G.js} +2 -2
- package/dist/web/server/{chunk-FE4KN6T2.js → chunk-RX62LUDV.js} +4 -4
- package/dist/web/server/chunk-SR65ARVS.js +192 -0
- package/dist/web/server/{chunk-WK7CQS2N.js → chunk-SZ65K4CO.js} +48 -48
- package/dist/web/server/{chunk-DO3TVNGA.js → chunk-TO3YPLNZ.js} +6 -6
- package/dist/web/server/{chunk-3IKSPTYI.js → chunk-UKINNXJY.js} +2 -2
- package/dist/web/server/{chunk-M2FGGPNA.js → chunk-VGDP4YDU.js} +70 -45
- package/dist/web/server/{chunk-PCJ5EKFE.js → chunk-VRLTWOVJ.js} +11 -6
- package/dist/web/server/{chunk-HBZ6YKRB.js → chunk-WN77JNYY.js} +2 -2
- package/dist/web/server/{chunk-2U7PWSJX.js → chunk-WZNZQNI4.js} +231 -3633
- package/dist/web/server/{chunk-B2F6MLVZ.js → chunk-XFVL5ITL.js} +2246 -2228
- package/dist/web/server/{chunk-3GSFXWL5.js → chunk-XLCTCC4W.js} +3 -3
- package/dist/web/server/{chunk-AZZHUVJR.js → chunk-Y4MHIA7B.js} +18 -26
- package/dist/web/server/{fleet-pi-tool-renderer-lJvZWmBJ-4M5YI6VS.js → fleet-pi-tool-renderer-CE45vM6T-2UQN6RJM.js} +11 -9
- package/dist/web/server/{fork-picker-dialog-BZzfxdQd-Y725VJ7G.js → fork-picker-dialog-DCzuGelH-TN2Q5OXI.js} +5 -5
- package/dist/web/server/{openui-renderer-Cg4RSE9k-7BTJIYZJ.js → openui-renderer-c36_GYes-HX46N4M5.js} +11 -11
- package/dist/web/server/{repl-panel-BEQrC2ef-V3YEZ7EO.js → repl-panel-D9E8nkQy-L45ZNG2V.js} +4 -3
- package/dist/web/server/{router-CEahIUpn-SRG7XKIH.js → router-_ZpegqiQ-QIE44PIB.js} +1737 -1370
- package/dist/web/server/{routes-BznemByz-F4DJAYIM.js → routes-Ct81-8Tq-LHRMOS7R.js} +2882 -2330
- package/dist/web/server/server.js +3 -3
- package/dist/web/server/{session-insights-panel-JfeTHE0d-3HZB3ZWI.js → session-insights-panel-BHZyKDTo-LRMAMA3O.js} +4 -2
- package/dist/web/server/{settings-dialog-DgeBMORv-7SRSENPM.js → settings-dialog-B4uUS6f--AZ4I4ZOT.js} +142 -142
- package/dist/web/server/{start-CLAD7RcD-56S4BWMM.js → start-BYVnok_H-IA6TWGA3.js} +1 -1
- package/dist/web/server/subagent-chat-panel-C97S3WID-DLOAD5TG.js +63 -0
- package/dist/web/server/subagents-panel-iHpvMIZy-LI6XK66M.js +181 -0
- package/dist/web/server/{workspace-panel-y54P79_B-VPIYUXF6.js → workspace-panel-CHPoiXEo-YB4WS3MK.js} +2 -2
- package/package.json +5 -5
- package/dist/web/client/assets/artifacts-panel-CX62LQ13.js +0 -1
- package/dist/web/client/assets/chat-command-palette-C4sSf8Kg.js +0 -1
- package/dist/web/client/assets/collapsible-DmyYcezk.js +0 -1
- package/dist/web/client/assets/command-CB6emP8m.js +0 -2
- package/dist/web/client/assets/conversation-turns-ByFoWPXe.js +0 -6
- package/dist/web/client/assets/globals-CqqQdk2S.css +0 -2
- package/dist/web/client/assets/range-vSJ7Ux_5.js +0 -2
- package/dist/web/client/assets/repl-panel-DiGS6uCw.js +0 -1
- package/dist/web/client/assets/routes-CxlNCi_v.js +0 -16
- package/dist/web/client/assets/session-insights-panel-DwmwiikS.js +0 -1
- package/dist/web/client/assets/subagents-panel-DGnsK6Nx.js +0 -1
- package/dist/web/server/chunk-ZEVZFLIY.js +0 -334
- package/dist/web/server/subagents-panel-CzZe3co7-2VZ5JTWF.js +0 -332
|
@@ -1,24 +1,38 @@
|
|
|
1
1
|
import {
|
|
2
2
|
UiErrorBoundary,
|
|
3
3
|
encodeOpenPanelActionMessage
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-WN77JNYY.js";
|
|
5
5
|
import {
|
|
6
|
+
ACTION_STEPS,
|
|
7
|
+
BuiltinActionType,
|
|
6
8
|
Card,
|
|
7
9
|
CardContent,
|
|
8
10
|
CardDescription,
|
|
9
11
|
CardHeader,
|
|
10
12
|
CardTitle,
|
|
13
|
+
ToolNotFoundError,
|
|
14
|
+
createLibrary,
|
|
15
|
+
createQueryManager,
|
|
16
|
+
createStore,
|
|
17
|
+
createStreamingParser,
|
|
18
|
+
defineComponent,
|
|
19
|
+
enrichErrors,
|
|
20
|
+
evaluate,
|
|
21
|
+
evaluateElementProps,
|
|
22
|
+
extractToolResult,
|
|
23
|
+
markReactive,
|
|
24
|
+
parseStructuredRules,
|
|
25
|
+
resolveStateField,
|
|
26
|
+
tagSchemaId,
|
|
27
|
+
validate,
|
|
11
28
|
validateAndNormalizeOpenUIHtmlArtifact
|
|
12
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-KOIPYBJF.js";
|
|
13
30
|
import {
|
|
14
31
|
OpenPanelActionSchema,
|
|
15
32
|
RightPanelIdSchema,
|
|
16
33
|
WorkspaceRelativePathSchema,
|
|
17
|
-
external_exports
|
|
18
|
-
|
|
19
|
-
registry,
|
|
20
|
-
toJSONSchema
|
|
21
|
-
} from "./chunk-B2F6MLVZ.js";
|
|
34
|
+
external_exports
|
|
35
|
+
} from "./chunk-XFVL5ITL.js";
|
|
22
36
|
import {
|
|
23
37
|
segmentOpenUIContent
|
|
24
38
|
} from "./chunk-NFRJDPB3.js";
|
|
@@ -63,7 +77,7 @@ import {
|
|
|
63
77
|
Separator,
|
|
64
78
|
Switch,
|
|
65
79
|
useRender
|
|
66
|
-
} from "./chunk-
|
|
80
|
+
} from "./chunk-AECEK3K7.js";
|
|
67
81
|
import {
|
|
68
82
|
Select,
|
|
69
83
|
arrow$2,
|
|
@@ -76,34 +90,34 @@ import {
|
|
|
76
90
|
shift,
|
|
77
91
|
size,
|
|
78
92
|
useFloating
|
|
79
|
-
} from "./chunk-
|
|
93
|
+
} from "./chunk-TO3YPLNZ.js";
|
|
80
94
|
import {
|
|
81
95
|
ChevronDown
|
|
82
96
|
} from "./chunk-QLY3L4A2.js";
|
|
83
97
|
import {
|
|
84
98
|
Input
|
|
85
|
-
} from "./chunk-
|
|
99
|
+
} from "./chunk-AWFOBHH4.js";
|
|
86
100
|
import {
|
|
87
101
|
Dialog,
|
|
88
102
|
DialogContent,
|
|
89
103
|
DialogHeader,
|
|
90
104
|
DialogTitle
|
|
91
|
-
} from "./chunk-
|
|
105
|
+
} from "./chunk-RX62LUDV.js";
|
|
92
106
|
import {
|
|
93
107
|
Button,
|
|
94
108
|
cva,
|
|
95
109
|
require_with_selector,
|
|
96
110
|
visuallyHidden
|
|
97
|
-
} from "./chunk-
|
|
111
|
+
} from "./chunk-5RQ6QAZX.js";
|
|
98
112
|
import {
|
|
99
113
|
useBaseUiId
|
|
100
|
-
} from "./chunk-
|
|
114
|
+
} from "./chunk-LSIHVSUT.js";
|
|
101
115
|
import {
|
|
102
116
|
formatErrorMessage,
|
|
103
117
|
mergeProps,
|
|
104
118
|
useIsoLayoutEffect,
|
|
105
119
|
useRenderElement
|
|
106
|
-
} from "./chunk-
|
|
120
|
+
} from "./chunk-BLVCDQ7E.js";
|
|
107
121
|
import {
|
|
108
122
|
characterEntitiesLegacy
|
|
109
123
|
} from "./chunk-ST5I2PLN.js";
|
|
@@ -134,7 +148,7 @@ import {
|
|
|
134
148
|
__toESM
|
|
135
149
|
} from "./chunk-L547YHC4.js";
|
|
136
150
|
|
|
137
|
-
// web/app/dist/server/assets/openui-renderer-
|
|
151
|
+
// web/app/dist/server/assets/openui-renderer-c36_GYes.js
|
|
138
152
|
import * as React$2 from "react";
|
|
139
153
|
import React, { Children, Component as Component2, Fragment as Fragment2, PureComponent, cloneElement as cloneElement2, createContext as createContext2, createElement as createElement2, forwardRef as forwardRef2, isValidElement as isValidElement2, memo as memo2, useCallback as useCallback2, useContext as useContext2, useEffect as useEffect2, useId as useId2, useImperativeHandle, useInsertionEffect, useLayoutEffect as useLayoutEffect3, useMemo as useMemo2, useRef as useRef2, useState as useState2, useSyncExternalStore } from "react";
|
|
140
154
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -18430,3422 +18444,6 @@ function useRegisteredLabelId(idProp, setLabelId) {
|
|
|
18430
18444
|
}, [id, setLabelId]);
|
|
18431
18445
|
return id;
|
|
18432
18446
|
}
|
|
18433
|
-
function resolveField(obj, path2) {
|
|
18434
|
-
if (!path2 || obj == null) return void 0;
|
|
18435
|
-
if (!path2.includes(".")) return obj[path2];
|
|
18436
|
-
let cur = obj;
|
|
18437
|
-
for (const p of path2.split(".")) {
|
|
18438
|
-
if (cur == null) return void 0;
|
|
18439
|
-
cur = cur[p];
|
|
18440
|
-
}
|
|
18441
|
-
return cur;
|
|
18442
|
-
}
|
|
18443
|
-
function toNumber$2(val) {
|
|
18444
|
-
if (typeof val === "number") return val;
|
|
18445
|
-
if (typeof val === "string") {
|
|
18446
|
-
const n = Number(val);
|
|
18447
|
-
return isNaN(n) ? 0 : n;
|
|
18448
|
-
}
|
|
18449
|
-
if (typeof val === "boolean") return val ? 1 : 0;
|
|
18450
|
-
return 0;
|
|
18451
|
-
}
|
|
18452
|
-
var BUILTINS = {
|
|
18453
|
-
Count: {
|
|
18454
|
-
name: "Count",
|
|
18455
|
-
signature: "Count(array) \u2192 number",
|
|
18456
|
-
description: "Returns array length",
|
|
18457
|
-
fn: (arr) => Array.isArray(arr) ? arr.length : 0
|
|
18458
|
-
},
|
|
18459
|
-
First: {
|
|
18460
|
-
name: "First",
|
|
18461
|
-
signature: "First(array) \u2192 element",
|
|
18462
|
-
description: "Returns first element of array",
|
|
18463
|
-
fn: (arr) => Array.isArray(arr) ? arr[0] ?? null : null
|
|
18464
|
-
},
|
|
18465
|
-
Last: {
|
|
18466
|
-
name: "Last",
|
|
18467
|
-
signature: "Last(array) \u2192 element",
|
|
18468
|
-
description: "Returns last element of array",
|
|
18469
|
-
fn: (arr) => Array.isArray(arr) ? arr[arr.length - 1] ?? null : null
|
|
18470
|
-
},
|
|
18471
|
-
Sum: {
|
|
18472
|
-
name: "Sum",
|
|
18473
|
-
signature: "Sum(numbers[]) \u2192 number",
|
|
18474
|
-
description: "Sum of numeric array",
|
|
18475
|
-
fn: (arr) => Array.isArray(arr) ? arr.reduce((a2, b) => a2 + toNumber$2(b), 0) : 0
|
|
18476
|
-
},
|
|
18477
|
-
Avg: {
|
|
18478
|
-
name: "Avg",
|
|
18479
|
-
signature: "Avg(numbers[]) \u2192 number",
|
|
18480
|
-
description: "Average of numeric array",
|
|
18481
|
-
fn: (arr) => Array.isArray(arr) && arr.length ? arr.reduce((a2, b) => a2 + toNumber$2(b), 0) / arr.length : 0
|
|
18482
|
-
},
|
|
18483
|
-
Min: {
|
|
18484
|
-
name: "Min",
|
|
18485
|
-
signature: "Min(numbers[]) \u2192 number",
|
|
18486
|
-
description: "Minimum value in array",
|
|
18487
|
-
fn: (arr) => Array.isArray(arr) && arr.length ? arr.reduce((acc, b) => Math.min(acc, toNumber$2(b)), toNumber$2(arr[0])) : 0
|
|
18488
|
-
},
|
|
18489
|
-
Max: {
|
|
18490
|
-
name: "Max",
|
|
18491
|
-
signature: "Max(numbers[]) \u2192 number",
|
|
18492
|
-
description: "Maximum value in array",
|
|
18493
|
-
fn: (arr) => Array.isArray(arr) && arr.length ? arr.reduce((acc, b) => Math.max(acc, toNumber$2(b)), toNumber$2(arr[0])) : 0
|
|
18494
|
-
},
|
|
18495
|
-
Sort: {
|
|
18496
|
-
name: "Sort",
|
|
18497
|
-
signature: "Sort(array, field, direction?) \u2192 sorted array",
|
|
18498
|
-
description: 'Sort array by field. Direction: "asc" (default) or "desc"',
|
|
18499
|
-
fn: (arr, field, dir) => {
|
|
18500
|
-
if (!Array.isArray(arr)) return arr;
|
|
18501
|
-
const f = String(field ?? "");
|
|
18502
|
-
const desc = String(dir ?? "asc") === "desc";
|
|
18503
|
-
return [...arr].sort((a2, b) => {
|
|
18504
|
-
const av = f ? resolveField(a2, f) : a2;
|
|
18505
|
-
const bv = f ? resolveField(b, f) : b;
|
|
18506
|
-
const aIsNumeric = typeof av === "number" || typeof av === "string" && !isNaN(Number(av)) && av !== "";
|
|
18507
|
-
const bIsNumeric = typeof bv === "number" || typeof bv === "string" && !isNaN(Number(bv)) && bv !== "";
|
|
18508
|
-
if (aIsNumeric && bIsNumeric) {
|
|
18509
|
-
const diff2 = toNumber$2(av) - toNumber$2(bv);
|
|
18510
|
-
return desc ? -diff2 : diff2;
|
|
18511
|
-
}
|
|
18512
|
-
const cmp = String(av ?? "").localeCompare(String(bv ?? ""));
|
|
18513
|
-
return desc ? -cmp : cmp;
|
|
18514
|
-
});
|
|
18515
|
-
}
|
|
18516
|
-
},
|
|
18517
|
-
Filter: {
|
|
18518
|
-
name: "Filter",
|
|
18519
|
-
signature: 'Filter(array, field, operator: "==" | "!=" | ">" | "<" | ">=" | "<=" | "contains", value) \u2192 filtered array',
|
|
18520
|
-
description: "Filter array by field value",
|
|
18521
|
-
fn: (arr, field, op, value) => {
|
|
18522
|
-
if (!Array.isArray(arr)) return [];
|
|
18523
|
-
const f = String(field ?? "");
|
|
18524
|
-
const o = String(op ?? "==");
|
|
18525
|
-
return arr.filter((item) => {
|
|
18526
|
-
const v2 = f ? resolveField(item, f) : item;
|
|
18527
|
-
switch (o) {
|
|
18528
|
-
case "==":
|
|
18529
|
-
return v2 == value;
|
|
18530
|
-
case "!=":
|
|
18531
|
-
return v2 != value;
|
|
18532
|
-
case ">":
|
|
18533
|
-
return toNumber$2(v2) > toNumber$2(value);
|
|
18534
|
-
case "<":
|
|
18535
|
-
return toNumber$2(v2) < toNumber$2(value);
|
|
18536
|
-
case ">=":
|
|
18537
|
-
return toNumber$2(v2) >= toNumber$2(value);
|
|
18538
|
-
case "<=":
|
|
18539
|
-
return toNumber$2(v2) <= toNumber$2(value);
|
|
18540
|
-
case "contains":
|
|
18541
|
-
return String(v2 ?? "").includes(String(value ?? ""));
|
|
18542
|
-
default:
|
|
18543
|
-
return false;
|
|
18544
|
-
}
|
|
18545
|
-
});
|
|
18546
|
-
}
|
|
18547
|
-
},
|
|
18548
|
-
Round: {
|
|
18549
|
-
name: "Round",
|
|
18550
|
-
signature: "Round(number, decimals?) \u2192 number",
|
|
18551
|
-
description: "Round to N decimal places (default 0)",
|
|
18552
|
-
fn: (n, decimals) => {
|
|
18553
|
-
const num = toNumber$2(n);
|
|
18554
|
-
const d2 = decimals != null ? toNumber$2(decimals) : 0;
|
|
18555
|
-
const factor2 = Math.pow(10, d2);
|
|
18556
|
-
return Math.round(num * factor2) / factor2;
|
|
18557
|
-
}
|
|
18558
|
-
},
|
|
18559
|
-
Abs: {
|
|
18560
|
-
name: "Abs",
|
|
18561
|
-
signature: "Abs(number) \u2192 number",
|
|
18562
|
-
description: "Absolute value",
|
|
18563
|
-
fn: (n) => Math.abs(toNumber$2(n))
|
|
18564
|
-
},
|
|
18565
|
-
Floor: {
|
|
18566
|
-
name: "Floor",
|
|
18567
|
-
signature: "Floor(number) \u2192 number",
|
|
18568
|
-
description: "Round down to nearest integer",
|
|
18569
|
-
fn: (n) => Math.floor(toNumber$2(n))
|
|
18570
|
-
},
|
|
18571
|
-
Ceil: {
|
|
18572
|
-
name: "Ceil",
|
|
18573
|
-
signature: "Ceil(number) \u2192 number",
|
|
18574
|
-
description: "Round up to nearest integer",
|
|
18575
|
-
fn: (n) => Math.ceil(toNumber$2(n))
|
|
18576
|
-
}
|
|
18577
|
-
};
|
|
18578
|
-
var LAZY_BUILTINS = /* @__PURE__ */ new Set(["Each"]);
|
|
18579
|
-
var LAZY_BUILTIN_DEFS = { Each: {
|
|
18580
|
-
signature: "Each(array, varName, template)",
|
|
18581
|
-
description: "Evaluate template for each element. varName is the loop variable \u2014 use it ONLY inside the template expression (inline). Do NOT create a separate statement for the template."
|
|
18582
|
-
} };
|
|
18583
|
-
var ACTION_STEPS = {
|
|
18584
|
-
Run: "run",
|
|
18585
|
-
ToAssistant: "continue_conversation",
|
|
18586
|
-
OpenUrl: "open_url",
|
|
18587
|
-
Set: "set",
|
|
18588
|
-
Reset: "reset"
|
|
18589
|
-
};
|
|
18590
|
-
var ACTION_NAMES = /* @__PURE__ */ new Set(["Action", ...Object.keys(ACTION_STEPS)]);
|
|
18591
|
-
var BUILTIN_NAMES = /* @__PURE__ */ new Set([
|
|
18592
|
-
...Object.keys(BUILTINS),
|
|
18593
|
-
...LAZY_BUILTINS,
|
|
18594
|
-
...ACTION_NAMES
|
|
18595
|
-
]);
|
|
18596
|
-
function isBuiltin(name) {
|
|
18597
|
-
return BUILTIN_NAMES.has(name);
|
|
18598
|
-
}
|
|
18599
|
-
var RESERVED_CALLS = {
|
|
18600
|
-
Query: "Query",
|
|
18601
|
-
Mutation: "Mutation"
|
|
18602
|
-
};
|
|
18603
|
-
function isReservedCall(name) {
|
|
18604
|
-
return name in RESERVED_CALLS;
|
|
18605
|
-
}
|
|
18606
|
-
function jsonSchemaTypeStr(schema) {
|
|
18607
|
-
const type = schema.type;
|
|
18608
|
-
if (type === "string") {
|
|
18609
|
-
const enumVals = schema.enum;
|
|
18610
|
-
if (enumVals) return enumVals.map((v2) => `"${v2}"`).join(" | ");
|
|
18611
|
-
return "string";
|
|
18612
|
-
}
|
|
18613
|
-
if (type === "number" || type === "integer") return "number";
|
|
18614
|
-
if (type === "boolean") return "boolean";
|
|
18615
|
-
if (type === "array") {
|
|
18616
|
-
const items = schema.items;
|
|
18617
|
-
if (items) return `${jsonSchemaTypeStr(items)}[]`;
|
|
18618
|
-
return "any[]";
|
|
18619
|
-
}
|
|
18620
|
-
if (type === "object") {
|
|
18621
|
-
const props = schema.properties;
|
|
18622
|
-
if (props && Object.keys(props).length > 0) {
|
|
18623
|
-
const required = schema.required ?? [];
|
|
18624
|
-
return `{${Object.entries(props).map(([k2, v2]) => {
|
|
18625
|
-
return `${k2}${required.includes(k2) ? "" : "?"}: ${jsonSchemaTypeStr(v2)}`;
|
|
18626
|
-
}).join(", ")}}`;
|
|
18627
|
-
}
|
|
18628
|
-
return "object";
|
|
18629
|
-
}
|
|
18630
|
-
return "any";
|
|
18631
|
-
}
|
|
18632
|
-
function defaultForSchema(schema) {
|
|
18633
|
-
const type = schema.type;
|
|
18634
|
-
if (type === "string") return "";
|
|
18635
|
-
if (type === "number" || type === "integer") return 0;
|
|
18636
|
-
if (type === "boolean") return false;
|
|
18637
|
-
if (type === "array") return [];
|
|
18638
|
-
if (type === "object") {
|
|
18639
|
-
const props = schema.properties;
|
|
18640
|
-
if (props && Object.keys(props).length > 0) {
|
|
18641
|
-
const result = {};
|
|
18642
|
-
for (const [k2, v2] of Object.entries(props)) result[k2] = defaultForSchema(v2);
|
|
18643
|
-
return result;
|
|
18644
|
-
}
|
|
18645
|
-
return {};
|
|
18646
|
-
}
|
|
18647
|
-
return null;
|
|
18648
|
-
}
|
|
18649
|
-
var PREAMBLE = `You are an AI assistant that responds using openui-lang, a declarative UI language. Your ENTIRE response must be valid openui-lang code \u2014 no markdown, no explanations, just openui-lang.`;
|
|
18650
|
-
function syntaxRules(rootName, flags) {
|
|
18651
|
-
const lines = [
|
|
18652
|
-
"## Syntax Rules",
|
|
18653
|
-
"",
|
|
18654
|
-
"1. Each statement is on its own line: `identifier = Expression`",
|
|
18655
|
-
`2. \`root\` is the entry point \u2014 every program must define \`root = ${rootName}(...)\``,
|
|
18656
|
-
'3. Expressions are: strings ("..."), numbers, booleans (true/false), null, arrays ([...]), objects ({...}), or component calls TypeName(arg1, arg2, ...)',
|
|
18657
|
-
"4. Use references for readability: define `name = ...` on one line, then use `name` later",
|
|
18658
|
-
"5. EVERY variable (except root) MUST be referenced by at least one other variable. Unreferenced variables are silently dropped and will NOT render. Always include defined variables in their parent's children/items array.",
|
|
18659
|
-
'6. Arguments are POSITIONAL (order matters, not names). Write `Stack([children], "row", "l")` NOT `Stack([children], direction: "row", gap: "l")` \u2014 colon syntax is NOT supported and silently breaks',
|
|
18660
|
-
"7. Optional arguments can be omitted from the end"
|
|
18661
|
-
];
|
|
18662
|
-
let ruleNum = 8;
|
|
18663
|
-
if (flags.bindings) lines.push(`${ruleNum++}. Declare mutable state with \`$varName = defaultValue\`. Components marked with \`$binding\` can read/write these. Undeclared $variables are auto-created with null default.`);
|
|
18664
|
-
if (flags.supportsExpressions) lines.push(`${ruleNum++}. String concatenation: \`"text" + $var + "more"\``, `${ruleNum++}. Dot member access: \`query.field\` reads a field; on arrays it extracts that field from every element`, `${ruleNum++}. Index access: \`arr[0]\`, \`data[index]\``, `${ruleNum++}. Arithmetic operators: +, -, *, /, % (work on numbers; + is string concat when either side is a string)`, `${ruleNum++}. Comparison: ==, !=, >, <, >=, <=`, `${ruleNum++}. Logical: &&, ||, ! (prefix)`, `${ruleNum++}. Ternary: \`condition ? valueIfTrue : valueIfFalse\``, `${ruleNum++}. Parentheses for grouping: \`(a + b) * c\``);
|
|
18665
|
-
lines.push("- Strings use double quotes with backslash escaping");
|
|
18666
|
-
return lines.join("\n");
|
|
18667
|
-
}
|
|
18668
|
-
function builtinFunctionsSection() {
|
|
18669
|
-
const builtinLines = Object.values(BUILTINS).map((b) => `@${b.signature} \u2014 ${b.description}`);
|
|
18670
|
-
const lazyLines = Object.values(LAZY_BUILTIN_DEFS).map((b) => `@${b.signature} \u2014 ${b.description}`);
|
|
18671
|
-
return `## Built-in Functions
|
|
18672
|
-
|
|
18673
|
-
Data functions prefixed with \`@\` to distinguish from components. These are the ONLY functions available \u2014 do NOT invent new ones.
|
|
18674
|
-
Use @-prefixed built-in functions (@Count, @Sum, @Avg, @Min, @Max, @Round) on Query results \u2014 do NOT hardcode computed values.
|
|
18675
|
-
|
|
18676
|
-
${[...builtinLines, ...lazyLines].join("\n")}
|
|
18677
|
-
|
|
18678
|
-
Builtins compose \u2014 output of one is input to the next:
|
|
18679
|
-
\`@Count(@Filter(data.rows, "field", "==", "val"))\` for KPIs/chart values, \`@Round(@Avg(data.rows.score), 1)\`, \`@Each(data.rows, "item", Comp(item.field))\` for per-item rendering.
|
|
18680
|
-
Array pluck: \`data.rows.field\` extracts a field from every row \u2192 use with @Sum, @Avg, charts, tables.
|
|
18681
|
-
|
|
18682
|
-
IMPORTANT @Each rule: The loop variable (e.g. "item") is ONLY available inside the @Each template expression. Always inline the template \u2014 do NOT extract it to a separate statement.
|
|
18683
|
-
CORRECT: \`Col("Actions", @Each(rows, "t", Button("Edit", Action([@Set($id, t.id)]))))\`
|
|
18684
|
-
WRONG: \`myBtn = Button("Edit", Action([@Set($id, t.id)]))\` then \`Col("Actions", @Each(rows, "t", myBtn))\` \u2014 t is undefined in myBtn.`;
|
|
18685
|
-
}
|
|
18686
|
-
function querySection() {
|
|
18687
|
-
return `## Query \u2014 Live Data Fetching
|
|
18688
|
-
|
|
18689
|
-
Fetch data from available tools. Returns defaults instantly, swaps in real data when it arrives.
|
|
18690
|
-
|
|
18691
|
-
\`\`\`
|
|
18692
|
-
metrics = Query("tool_name", {arg1: value, arg2: $binding}, {defaultField: 0, defaultData: []}, refreshInterval?)
|
|
18693
|
-
\`\`\`
|
|
18694
|
-
|
|
18695
|
-
- First arg: tool name (string)
|
|
18696
|
-
- Second arg: arguments object (may reference $bindings \u2014 re-fetches automatically on change)
|
|
18697
|
-
- Third arg: default data (rendered immediately before fetch resolves)
|
|
18698
|
-
- Fourth arg (optional): refresh interval in seconds (e.g. 30 for auto-refresh every 30s)
|
|
18699
|
-
- Use dot access on results: metrics.totalEvents, metrics.data.day (array pluck)
|
|
18700
|
-
- Query results must use regular identifiers: \`metrics = Query(...)\`, NOT \`$metrics = Query(...)\`
|
|
18701
|
-
- Manual refresh: \`Button("Refresh", Action([@Run(query1), @Run(query2)]), "secondary")\` \u2014 re-fetches the listed queries
|
|
18702
|
-
- Refresh all queries: create Action with @Run for each query`;
|
|
18703
|
-
}
|
|
18704
|
-
function mutationSection() {
|
|
18705
|
-
return `## Mutation \u2014 Write Operations
|
|
18706
|
-
|
|
18707
|
-
Execute state-changing tool calls (create, update, delete). Unlike Query (auto-fetches on render), Mutation fires only on button click via Action.
|
|
18708
|
-
|
|
18709
|
-
\`\`\`
|
|
18710
|
-
result = Mutation("tool_name", {arg1: $binding, arg2: "value"})
|
|
18711
|
-
\`\`\`
|
|
18712
|
-
|
|
18713
|
-
- First arg: tool name (string)
|
|
18714
|
-
- Second arg: arguments object (evaluated with current $binding values at click time)
|
|
18715
|
-
- result.status: "idle" | "loading" | "success" | "error"
|
|
18716
|
-
- result.data: tool response on success
|
|
18717
|
-
- result.error: error message on failure
|
|
18718
|
-
- Mutation results use regular identifiers: \`result = Mutation(...)\`, NOT \`$result\`
|
|
18719
|
-
- Show loading state: \`result.status == "loading" ? TextContent("Saving...") : null\``;
|
|
18720
|
-
}
|
|
18721
|
-
function actionSection(flags) {
|
|
18722
|
-
const steps = ['- @ToAssistant("message") \u2014 Send a message to the assistant (for conversational buttons like "Tell me more", "Explain this")', '- @OpenUrl("https://...") \u2014 Navigate to a URL'];
|
|
18723
|
-
if (flags.bindings) steps.push("- @Set($variable, value) \u2014 Set a $variable to a specific value", '- @Reset($var1, $var2, ...) \u2014 Reset $variables to their declared defaults (e.g. @Reset($title, $priority) restores $title="" and $priority="medium")');
|
|
18724
|
-
if (flags.toolCalls) steps.unshift("- @Run(queryOrMutationRef) \u2014 Execute a Mutation or re-fetch a Query (ref must be a declared Query/Mutation)");
|
|
18725
|
-
const examples = [];
|
|
18726
|
-
if (flags.toolCalls) examples.push(`Example \u2014 mutation + refresh + reset (PREFERRED pattern):
|
|
18727
|
-
\`\`\`
|
|
18728
|
-
$binding = "default"
|
|
18729
|
-
result = Mutation("tool_name", {field: $binding})
|
|
18730
|
-
data = Query("tool_name", {}, {rows: []})
|
|
18731
|
-
onSubmit = Action([@Run(result), @Run(data), @Reset($binding)])
|
|
18732
|
-
\`\`\``);
|
|
18733
|
-
examples.push(`Example \u2014 simple nav:
|
|
18734
|
-
\`\`\`
|
|
18735
|
-
viewBtn = Button("View", Action([@OpenUrl("https://example.com")]))
|
|
18736
|
-
\`\`\``);
|
|
18737
|
-
const rules = ['- Action can be assigned to a variable or inlined: Button("Go", onSubmit) and Button("Go", Action([...])) both work'];
|
|
18738
|
-
if (flags.toolCalls) rules.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)");
|
|
18739
|
-
return `## Action \u2014 Button Behavior
|
|
18740
|
-
|
|
18741
|
-
Action([@steps...]) wires button clicks to operations. Steps are @-prefixed built-in actions. Steps execute in order.
|
|
18742
|
-
Buttons without an explicit Action prop automatically send their label to the assistant (equivalent to Action([@ToAssistant(label)])).
|
|
18743
|
-
|
|
18744
|
-
Available steps:
|
|
18745
|
-
${steps.join("\n")}
|
|
18746
|
-
|
|
18747
|
-
${examples.join("\n\n")}
|
|
18748
|
-
|
|
18749
|
-
${rules.join("\n")}`;
|
|
18750
|
-
}
|
|
18751
|
-
function interactiveFiltersSection() {
|
|
18752
|
-
return `## Interactive Filters
|
|
18753
|
-
|
|
18754
|
-
To let the user filter data with a dropdown:
|
|
18755
|
-
1. Declare a $variable with a default: \`$dateRange = "14"\`
|
|
18756
|
-
2. Create a Select with name, items, and binding: \`Select("dateRange", [SelectItem("7", "Last 7 days"), ...], null, null, $dateRange)\`
|
|
18757
|
-
3. Wrap in FormControl for a label: \`FormControl("Date Range", Select(...))\`
|
|
18758
|
-
4. Pass $dateRange in Query args: \`Query("tool", {dateRange: $dateRange}, {defaults})\`
|
|
18759
|
-
5. When the user changes the Select, $dateRange updates and the Query automatically re-fetches
|
|
18760
|
-
|
|
18761
|
-
FILTER 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.
|
|
18762
|
-
|
|
18763
|
-
Rules for $variables:
|
|
18764
|
-
- $variables hold simple values (strings or numbers), NOT arrays or objects
|
|
18765
|
-
- $variables must be bound to a Select/Input component via the value argument (last positional arg) to be interactive
|
|
18766
|
-
- Queries must use regular identifiers (NOT $variables): \`metrics = Query(...)\` not \`$metrics = Query(...)\`
|
|
18767
|
-
- **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"\`
|
|
18768
|
-
|
|
18769
|
-
## Forms
|
|
18770
|
-
|
|
18771
|
-
Simple form \u2014 no $bindings needed. Field values are managed internally by the Form via the name prop:
|
|
18772
|
-
\`\`\`
|
|
18773
|
-
contactForm = Form("contact", submitBtn, [nameField, emailField])
|
|
18774
|
-
nameField = FormControl("Name", Input("name", "Your name", "text", {required: true}))
|
|
18775
|
-
emailField = FormControl("Email", Input("email", "your@email.com", "email", {required: true, email: true}))
|
|
18776
|
-
submitBtn = Button("Submit")
|
|
18777
|
-
\`\`\`
|
|
18778
|
-
|
|
18779
|
-
Use $bindings when you need to read field values elsewhere (in Action context, Query args, or conditionals). They are auto-declared:
|
|
18780
|
-
\`\`\`
|
|
18781
|
-
$role = "engineer"
|
|
18782
|
-
contactForm = Form("contact", submitBtn, [nameField, emailField, roleField])
|
|
18783
|
-
nameField = FormControl("Name", Input("name", "Enter your name", "text", {required: true}, $name))
|
|
18784
|
-
emailField = FormControl("Email", Input("email", "Enter your email", "email", {required: true, email: true}, $email))
|
|
18785
|
-
roleField = FormControl("Role", Select("role", [SelectItem("engineer", "Engineer"), SelectItem("designer", "Designer"), SelectItem("pm", "PM")], null, {required: true}, $role))
|
|
18786
|
-
submitBtn = Button("Submit")
|
|
18787
|
-
\`\`\`
|
|
18788
|
-
|
|
18789
|
-
For form + mutation patterns (create, refresh, reset), see the Action section example above.
|
|
18790
|
-
|
|
18791
|
-
IMPORTANT: 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.`;
|
|
18792
|
-
}
|
|
18793
|
-
function editModeSection() {
|
|
18794
|
-
return `## Edit Mode
|
|
18795
|
-
|
|
18796
|
-
The runtime merges by statement name: same name = replace, new name = append.
|
|
18797
|
-
Output ONLY statements that changed or are new. Everything else is kept automatically.
|
|
18798
|
-
|
|
18799
|
-
### Delete
|
|
18800
|
-
To remove a component, update the parent to exclude it from its children array. Orphaned statements are automatically garbage-collected.
|
|
18801
|
-
Example \u2014 remove chart: \`root = Stack([header, kpiRow, table])\` \u2014 chart is no longer in the children list, so it and any statements only it referenced are auto-deleted.
|
|
18802
|
-
|
|
18803
|
-
### Patch size guide
|
|
18804
|
-
- Changing a title or label: 1 statement
|
|
18805
|
-
- Adding a component: 2-3 statements (the new component + parent update)
|
|
18806
|
-
- Removing a component: 1 statement (re-declare parent without the removed child)
|
|
18807
|
-
- Adding a filter + wiring to query: 3-5 statements
|
|
18808
|
-
- Restructuring into tabs: 5-10 statements
|
|
18809
|
-
|
|
18810
|
-
### Rules
|
|
18811
|
-
- Reuse existing statement names exactly \u2014 do not rename
|
|
18812
|
-
- Do NOT re-emit unchanged statements \u2014 the runtime keeps them
|
|
18813
|
-
- A typical edit patch is 1-10 statements, not 20+
|
|
18814
|
-
- If the existing code already satisfies the request, output only the root statement
|
|
18815
|
-
- NEVER output the entire program as a patch. Only output what actually changes
|
|
18816
|
-
- If you are about to output more than 10 statements, reconsider \u2014 most edits need fewer`;
|
|
18817
|
-
}
|
|
18818
|
-
function streamingRules(rootName, flags) {
|
|
18819
|
-
const steps = [`1. \`root = ${rootName}(...)\` \u2014 UI shell appears immediately`];
|
|
18820
|
-
if (flags.supportsExpressions) {
|
|
18821
|
-
steps.push("2. $variable declarations \u2014 state ready for bindings");
|
|
18822
|
-
steps.push("3. Query statements \u2014 defaults resolve immediately so components render with data");
|
|
18823
|
-
steps.push("4. Component definitions \u2014 fill in with data already available");
|
|
18824
|
-
steps.push("5. Data values \u2014 leaf content last");
|
|
18825
|
-
} else {
|
|
18826
|
-
steps.push("2. Component definitions \u2014 fill in as they stream");
|
|
18827
|
-
steps.push("3. Data values \u2014 leaf content last");
|
|
18828
|
-
}
|
|
18829
|
-
return `## Hoisting & Streaming (CRITICAL)
|
|
18830
|
-
|
|
18831
|
-
openui-lang supports hoisting: a reference can be used BEFORE it is defined. The parser resolves all references after the full input is parsed.
|
|
18832
|
-
|
|
18833
|
-
During streaming, the output is re-parsed on every chunk. Undefined references are temporarily unresolved and appear once their definitions stream in. This creates a progressive top-down reveal \u2014 structure first, then data fills in.
|
|
18834
|
-
|
|
18835
|
-
**Recommended statement order for optimal streaming:**
|
|
18836
|
-
${steps.join("\n")}
|
|
18837
|
-
|
|
18838
|
-
Always write the root = ${rootName}(...) statement first so the UI shell appears immediately, even before child data has streamed in.`;
|
|
18839
|
-
}
|
|
18840
|
-
function inlineModeSection() {
|
|
18841
|
-
return `## Inline Mode
|
|
18842
|
-
|
|
18843
|
-
You are in inline mode. You can respond in two ways:
|
|
18844
|
-
|
|
18845
|
-
### 1. Code response (when the user wants to CREATE or CHANGE the UI)
|
|
18846
|
-
Wrap openui-lang code in triple-backtick fences. You can include explanatory text before/after:
|
|
18847
|
-
|
|
18848
|
-
Here's your dashboard:
|
|
18849
|
-
|
|
18850
|
-
\`\`\`openui-lang
|
|
18851
|
-
root = RootComp([header, content])
|
|
18852
|
-
header = SomeHeader("Title")
|
|
18853
|
-
content = SomeContent("Hello world")
|
|
18854
|
-
\`\`\`
|
|
18855
|
-
|
|
18856
|
-
I created a simple layout with a header.
|
|
18857
|
-
|
|
18858
|
-
### 2. Text-only response (when the user asks a QUESTION)
|
|
18859
|
-
If the user asks "what is this?", "explain the chart", "how does this work", etc. \u2014 respond with plain text. Do NOT output any openui-lang code. The existing dashboard stays unchanged.
|
|
18860
|
-
|
|
18861
|
-
### Rules
|
|
18862
|
-
- When the user asks for changes, output ONLY the changed/new statements in a fenced block
|
|
18863
|
-
- When the user asks a question, respond with text only \u2014 NO code. The dashboard stays unchanged.
|
|
18864
|
-
- The parser extracts code from fences automatically. Text outside fences is shown as chat.`;
|
|
18865
|
-
}
|
|
18866
|
-
function toolWorkflowSection() {
|
|
18867
|
-
return `## Data Workflow
|
|
18868
|
-
|
|
18869
|
-
When tools are available, follow this workflow:
|
|
18870
|
-
1. FIRST: Call the most relevant tool to inspect the real data shape before generating code
|
|
18871
|
-
2. Use Query() for READ operations (data that should stay live) \u2014 NEVER hardcode tool results as literal arrays or objects
|
|
18872
|
-
3. Use Mutation() for WRITE operations (create, update, delete) \u2014 triggered by button clicks via Action([@Run(mutationRef)])
|
|
18873
|
-
4. Use the real data from step 1 as condensed Query defaults (3-5 rows) so the UI renders immediately
|
|
18874
|
-
5. Use @-prefixed builtins (@Count, @Filter, @Sort, @Sum) on Query results for KPIs and aggregations \u2014 the runtime evaluates these live on every refresh
|
|
18875
|
-
6. Hardcoded arrays are ONLY for static display data (labels, options) where no tool exists
|
|
18876
|
-
|
|
18877
|
-
WRONG \u2014 you called a tool and got data back, but you inlined the results:
|
|
18878
|
-
\`\`\`
|
|
18879
|
-
openCount = 2
|
|
18880
|
-
item1 = SomeComp("first item title")
|
|
18881
|
-
item2 = SomeComp("second item title")
|
|
18882
|
-
list = Stack([item1, item2])
|
|
18883
|
-
chart = SomeChart(["A", "B"], [12, 8])
|
|
18884
|
-
\`\`\`
|
|
18885
|
-
This is static \u2014 it shows stale data and won't update. Creating item1, item2, item3... manually is ALWAYS wrong when a tool exists.
|
|
18886
|
-
|
|
18887
|
-
RIGHT \u2014 use Query() for live data, Mutation() for writes, @builtins to derive values:
|
|
18888
|
-
\`\`\`
|
|
18889
|
-
data = Query("tool_name", {}, {rows: []})
|
|
18890
|
-
openCount = @Count(@Filter(data.rows, "field", "==", "value"))
|
|
18891
|
-
list = @Each(data.rows, "item", SomeComp(item.title, item.field))
|
|
18892
|
-
createResult = Mutation("create_tool", {title: $title})
|
|
18893
|
-
submitBtn = Button("Create", Action([@Run(createResult), @Run(data), @Reset($title)]))
|
|
18894
|
-
\`\`\`
|
|
18895
|
-
Everything derives from the Query \u2014 when data refreshes, the entire dashboard updates automatically.`;
|
|
18896
|
-
}
|
|
18897
|
-
function importantRules(rootName, flags) {
|
|
18898
|
-
const verifyLines = [`1. root = ${rootName}(...) is the FIRST line (for optimal streaming).`, "2. Every referenced name is defined. Every defined name (other than root) is reachable from root."];
|
|
18899
|
-
if (flags.toolCalls) verifyLines.push("3. Every Query result is referenced by at least one component.");
|
|
18900
|
-
if (flags.bindings) verifyLines.push(`${flags.toolCalls ? "4" : "3"}. Every $binding appears in at least one component or expression.`);
|
|
18901
|
-
if (flags.toolCalls && flags.bindings) verifyLines.push("5. Every visible filter $binding appears in at least one Query args object.");
|
|
18902
|
-
return `## Important Rules
|
|
18903
|
-
- When asked about data, generate realistic/plausible data
|
|
18904
|
-
- Choose components that best represent the content (tables for comparisons, charts for trends, forms for input, etc.)
|
|
18905
|
-
|
|
18906
|
-
## Final Verification
|
|
18907
|
-
Before finishing, walk your output and verify:
|
|
18908
|
-
${verifyLines.join("\n")}`;
|
|
18909
|
-
}
|
|
18910
|
-
function renderToolSignature(tool) {
|
|
18911
|
-
let args = "";
|
|
18912
|
-
if (tool.inputSchema) {
|
|
18913
|
-
const props = tool.inputSchema.properties;
|
|
18914
|
-
const required = tool.inputSchema.required ?? [];
|
|
18915
|
-
if (props && Object.keys(props).length > 0) args = Object.entries(props).map(([k2, v2]) => {
|
|
18916
|
-
return `${k2}${required.includes(k2) ? "" : "?"}: ${jsonSchemaTypeStr(v2)}`;
|
|
18917
|
-
}).join(", ");
|
|
18918
|
-
}
|
|
18919
|
-
let returnType = "";
|
|
18920
|
-
if (tool.outputSchema) returnType = ` \u2192 ${jsonSchemaTypeStr(tool.outputSchema)}`;
|
|
18921
|
-
let line = `- ${tool.name}(${args})${returnType}`;
|
|
18922
|
-
if (tool.description) line += `
|
|
18923
|
-
${tool.description}`;
|
|
18924
|
-
return line;
|
|
18925
|
-
}
|
|
18926
|
-
function renderToolsSection(tools) {
|
|
18927
|
-
const lines = [];
|
|
18928
|
-
const stringTools = [];
|
|
18929
|
-
const specTools = [];
|
|
18930
|
-
for (const tool of tools) if (typeof tool === "string") stringTools.push(tool);
|
|
18931
|
-
else specTools.push(tool);
|
|
18932
|
-
lines.push("## Available Tools");
|
|
18933
|
-
lines.push("");
|
|
18934
|
-
lines.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.");
|
|
18935
|
-
lines.push("");
|
|
18936
|
-
for (const t of stringTools) lines.push(`- ${t}`);
|
|
18937
|
-
for (const t of specTools) lines.push(renderToolSignature(t));
|
|
18938
|
-
const toolsWithOutput = specTools.filter((t) => t.outputSchema);
|
|
18939
|
-
if (toolsWithOutput.length > 0) {
|
|
18940
|
-
lines.push("");
|
|
18941
|
-
lines.push("### Default values for Query results");
|
|
18942
|
-
lines.push("");
|
|
18943
|
-
lines.push("Use these shapes as minimal Query defaults:");
|
|
18944
|
-
for (const t of toolsWithOutput) {
|
|
18945
|
-
const defaults2 = defaultForSchema(t.outputSchema);
|
|
18946
|
-
lines.push(`- ${t.name}: \`${JSON.stringify(defaults2)}\``);
|
|
18947
|
-
}
|
|
18948
|
-
}
|
|
18949
|
-
lines.push("");
|
|
18950
|
-
lines.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.");
|
|
18951
|
-
return lines.join("\n");
|
|
18952
|
-
}
|
|
18953
|
-
function generateComponentSignatures(spec, flags) {
|
|
18954
|
-
const lines = [
|
|
18955
|
-
"## Component Signatures",
|
|
18956
|
-
"",
|
|
18957
|
-
"Arguments marked with ? are optional. Sub-components can be inline or referenced; prefer references for better streaming."
|
|
18958
|
-
];
|
|
18959
|
-
if (flags.usesActionExpression) {
|
|
18960
|
-
const allSteps = [
|
|
18961
|
-
flags.toolCalls ? "@Run" : "",
|
|
18962
|
-
"@ToAssistant",
|
|
18963
|
-
"@OpenUrl",
|
|
18964
|
-
flags.bindings ? "@Set" : "",
|
|
18965
|
-
flags.bindings ? "@Reset" : ""
|
|
18966
|
-
].filter(Boolean);
|
|
18967
|
-
lines.push(`Props typed \`ActionExpression\` accept an Action([@steps...]) expression. See the Action section for available steps (${allSteps.join(", ")}).`);
|
|
18968
|
-
}
|
|
18969
|
-
if (flags.bindings || Object.values(spec.components).some((c2) => c2.signature?.includes("$binding"))) lines.push("Props marked `$binding<type>` accept a `$variable` reference for two-way binding.");
|
|
18970
|
-
const formatSig = (comp) => comp.description ? `${comp.signature} \u2014 ${comp.description}` : comp.signature;
|
|
18971
|
-
if (spec.componentGroups?.length) {
|
|
18972
|
-
const grouped = /* @__PURE__ */ new Set();
|
|
18973
|
-
for (const group of spec.componentGroups) {
|
|
18974
|
-
lines.push("", `### ${group.name}`);
|
|
18975
|
-
for (const name of group.components) {
|
|
18976
|
-
if (grouped.has(name)) continue;
|
|
18977
|
-
const comp = spec.components[name];
|
|
18978
|
-
if (!comp) continue;
|
|
18979
|
-
grouped.add(name);
|
|
18980
|
-
lines.push(formatSig(comp));
|
|
18981
|
-
}
|
|
18982
|
-
if (group.notes?.length) for (const note of group.notes) lines.push(note);
|
|
18983
|
-
}
|
|
18984
|
-
const ungrouped = Object.keys(spec.components).filter((n) => !grouped.has(n));
|
|
18985
|
-
if (ungrouped.length) {
|
|
18986
|
-
lines.push("", "### Other");
|
|
18987
|
-
for (const name of ungrouped) {
|
|
18988
|
-
const comp = spec.components[name];
|
|
18989
|
-
lines.push(formatSig(comp));
|
|
18990
|
-
}
|
|
18991
|
-
}
|
|
18992
|
-
} else {
|
|
18993
|
-
lines.push("");
|
|
18994
|
-
for (const [, comp] of Object.entries(spec.components)) lines.push(formatSig(comp));
|
|
18995
|
-
}
|
|
18996
|
-
return lines.join("\n");
|
|
18997
|
-
}
|
|
18998
|
-
function generatePrompt(spec) {
|
|
18999
|
-
const rootName = spec.root ?? "Root";
|
|
19000
|
-
const hasTools = !!spec.tools?.length;
|
|
19001
|
-
const toolCalls = spec.toolCalls ?? hasTools;
|
|
19002
|
-
const bindings = spec.bindings ?? toolCalls;
|
|
19003
|
-
const supportsExpressions = toolCalls || bindings;
|
|
19004
|
-
const usesActionExpression = Object.values(spec.components).some((c2) => c2.signature?.includes("ActionExpression"));
|
|
19005
|
-
const parts = [];
|
|
19006
|
-
parts.push(spec.preamble ?? PREAMBLE);
|
|
19007
|
-
parts.push("");
|
|
19008
|
-
parts.push(syntaxRules(rootName, {
|
|
19009
|
-
supportsExpressions,
|
|
19010
|
-
bindings
|
|
19011
|
-
}));
|
|
19012
|
-
parts.push("");
|
|
19013
|
-
parts.push(generateComponentSignatures(spec, {
|
|
19014
|
-
toolCalls,
|
|
19015
|
-
bindings,
|
|
19016
|
-
usesActionExpression
|
|
19017
|
-
}));
|
|
19018
|
-
if (supportsExpressions) {
|
|
19019
|
-
parts.push("");
|
|
19020
|
-
parts.push(builtinFunctionsSection());
|
|
19021
|
-
}
|
|
19022
|
-
if (toolCalls) {
|
|
19023
|
-
parts.push("");
|
|
19024
|
-
parts.push(querySection());
|
|
19025
|
-
parts.push("");
|
|
19026
|
-
parts.push(mutationSection());
|
|
19027
|
-
}
|
|
19028
|
-
if (usesActionExpression) {
|
|
19029
|
-
parts.push("");
|
|
19030
|
-
parts.push(actionSection({
|
|
19031
|
-
toolCalls,
|
|
19032
|
-
bindings
|
|
19033
|
-
}));
|
|
19034
|
-
}
|
|
19035
|
-
if (toolCalls && bindings) {
|
|
19036
|
-
parts.push("");
|
|
19037
|
-
parts.push(interactiveFiltersSection());
|
|
19038
|
-
}
|
|
19039
|
-
if (toolCalls) {
|
|
19040
|
-
parts.push("");
|
|
19041
|
-
parts.push(toolWorkflowSection());
|
|
19042
|
-
}
|
|
19043
|
-
if (spec.tools?.length) {
|
|
19044
|
-
parts.push("");
|
|
19045
|
-
parts.push(renderToolsSection(spec.tools));
|
|
19046
|
-
}
|
|
19047
|
-
parts.push("");
|
|
19048
|
-
parts.push(streamingRules(rootName, { supportsExpressions }));
|
|
19049
|
-
const allExamples = [...spec.examples ?? [], ...spec.toolExamples ?? []];
|
|
19050
|
-
if (allExamples.length) {
|
|
19051
|
-
parts.push("");
|
|
19052
|
-
parts.push("## Examples");
|
|
19053
|
-
parts.push("");
|
|
19054
|
-
for (const ex of allExamples) {
|
|
19055
|
-
parts.push(ex);
|
|
19056
|
-
parts.push("");
|
|
19057
|
-
}
|
|
19058
|
-
}
|
|
19059
|
-
if (spec.editMode) {
|
|
19060
|
-
parts.push("");
|
|
19061
|
-
parts.push(editModeSection());
|
|
19062
|
-
}
|
|
19063
|
-
if (spec.inlineMode) {
|
|
19064
|
-
parts.push("");
|
|
19065
|
-
parts.push(inlineModeSection());
|
|
19066
|
-
}
|
|
19067
|
-
parts.push(importantRules(rootName, {
|
|
19068
|
-
toolCalls,
|
|
19069
|
-
bindings
|
|
19070
|
-
}));
|
|
19071
|
-
if (spec.additionalRules?.length) {
|
|
19072
|
-
parts.push("");
|
|
19073
|
-
for (const rule of spec.additionalRules) parts.push(`- ${rule}`);
|
|
19074
|
-
}
|
|
19075
|
-
return parts.join("\n");
|
|
19076
|
-
}
|
|
19077
|
-
var reactiveSchemas = /* @__PURE__ */ new WeakSet();
|
|
19078
|
-
function markReactive(schema) {
|
|
19079
|
-
reactiveSchemas.add(schema);
|
|
19080
|
-
}
|
|
19081
|
-
function isReactiveSchema(schema) {
|
|
19082
|
-
return typeof schema === "object" && schema !== null && reactiveSchemas.has(schema);
|
|
19083
|
-
}
|
|
19084
|
-
var schemaIdTags = /* @__PURE__ */ new WeakMap();
|
|
19085
|
-
function tagSchemaId(schema, id) {
|
|
19086
|
-
schemaIdTags.set(schema, id);
|
|
19087
|
-
}
|
|
19088
|
-
function assertV4Schema(schema, componentName) {
|
|
19089
|
-
if (schema != null && typeof schema === "object" && "_def" in schema && !("_zod" in schema)) throw new Error(`[OpenUI] Component "${componentName}" 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`);
|
|
19090
|
-
}
|
|
19091
|
-
function defineComponent(config2) {
|
|
19092
|
-
assertV4Schema(config2.props, config2.name);
|
|
19093
|
-
schemaIdTags.set(config2.props, config2.name);
|
|
19094
|
-
return {
|
|
19095
|
-
...config2,
|
|
19096
|
-
ref: config2.props
|
|
19097
|
-
};
|
|
19098
|
-
}
|
|
19099
|
-
function getZodDef(schema) {
|
|
19100
|
-
return schema?._zod?.def;
|
|
19101
|
-
}
|
|
19102
|
-
function getZodType(schema) {
|
|
19103
|
-
return getZodDef(schema)?.type;
|
|
19104
|
-
}
|
|
19105
|
-
function isOptionalType(schema) {
|
|
19106
|
-
const type = getZodType(schema);
|
|
19107
|
-
return type === "optional" || type === "default" || type === "nullable";
|
|
19108
|
-
}
|
|
19109
|
-
function unwrap$1(schema) {
|
|
19110
|
-
let s2 = schema;
|
|
19111
|
-
let def = getZodDef(s2);
|
|
19112
|
-
while (def?.type === "optional" || def?.type === "default" || def?.type === "nullable") {
|
|
19113
|
-
s2 = def.innerType;
|
|
19114
|
-
def = getZodDef(s2);
|
|
19115
|
-
}
|
|
19116
|
-
return s2;
|
|
19117
|
-
}
|
|
19118
|
-
function isArrayType(schema) {
|
|
19119
|
-
return getZodType(unwrap$1(schema)) === "array";
|
|
19120
|
-
}
|
|
19121
|
-
function getArrayInnerType(schema) {
|
|
19122
|
-
const def = getZodDef(unwrap$1(schema));
|
|
19123
|
-
if (def?.type === "array") return def.element ?? def.innerType;
|
|
19124
|
-
}
|
|
19125
|
-
function getEnumValues(schema) {
|
|
19126
|
-
const def = getZodDef(unwrap$1(schema));
|
|
19127
|
-
if (def?.type !== "enum") return void 0;
|
|
19128
|
-
if (Array.isArray(def.values)) return def.values;
|
|
19129
|
-
if (def.entries && typeof def.entries === "object") return Object.keys(def.entries);
|
|
19130
|
-
}
|
|
19131
|
-
function getSchemaId(schema, reg) {
|
|
19132
|
-
try {
|
|
19133
|
-
const meta = reg.get(schema);
|
|
19134
|
-
if (meta?.id) return meta.id;
|
|
19135
|
-
} catch {
|
|
19136
|
-
}
|
|
19137
|
-
if (typeof schema === "object" && schema !== null) return schemaIdTags.get(schema);
|
|
19138
|
-
}
|
|
19139
|
-
function getUnionOptions(schema) {
|
|
19140
|
-
const def = getZodDef(schema);
|
|
19141
|
-
if (def?.type === "union" && Array.isArray(def.options)) return def.options;
|
|
19142
|
-
}
|
|
19143
|
-
function getObjectShape(schema) {
|
|
19144
|
-
const def = getZodDef(schema);
|
|
19145
|
-
if (def?.type === "object" && def.shape && typeof def.shape === "object") return def.shape;
|
|
19146
|
-
}
|
|
19147
|
-
function resolveTypeAnnotation(schema, reg) {
|
|
19148
|
-
const isReactive = isReactiveSchema(schema);
|
|
19149
|
-
const baseType = resolveBaseType(unwrap$1(schema), reg);
|
|
19150
|
-
if (!baseType) return void 0;
|
|
19151
|
-
return isReactive ? `$binding<${baseType}>` : baseType;
|
|
19152
|
-
}
|
|
19153
|
-
function resolveBaseType(inner, reg) {
|
|
19154
|
-
const directId = getSchemaId(inner, reg);
|
|
19155
|
-
if (directId) return directId;
|
|
19156
|
-
const unionOpts = getUnionOptions(inner);
|
|
19157
|
-
if (unionOpts) {
|
|
19158
|
-
const names = unionOpts.map((o) => resolveTypeAnnotation(o, reg)).filter(Boolean);
|
|
19159
|
-
if (names.length > 0) return names.join(" | ");
|
|
19160
|
-
}
|
|
19161
|
-
if (isArrayType(inner)) {
|
|
19162
|
-
const arrayInner = getArrayInnerType(inner);
|
|
19163
|
-
if (!arrayInner) return void 0;
|
|
19164
|
-
const innerType = resolveTypeAnnotation(arrayInner, reg);
|
|
19165
|
-
if (innerType) return getUnionOptions(unwrap$1(arrayInner)) !== void 0 ? `(${innerType})[]` : `${innerType}[]`;
|
|
19166
|
-
return;
|
|
19167
|
-
}
|
|
19168
|
-
const zodType = getZodType(inner);
|
|
19169
|
-
if (zodType === "string") return "string";
|
|
19170
|
-
if (zodType === "number") return "number";
|
|
19171
|
-
if (zodType === "boolean") return "boolean";
|
|
19172
|
-
if (zodType === "any") return "any";
|
|
19173
|
-
if (zodType === "record") {
|
|
19174
|
-
const def = getZodDef(inner);
|
|
19175
|
-
return `Record<${resolveTypeAnnotation(def?.keyType, reg) ?? "string"}, ${resolveTypeAnnotation(def?.valueType, reg) ?? "any"}>`;
|
|
19176
|
-
}
|
|
19177
|
-
const enumVals = getEnumValues(inner);
|
|
19178
|
-
if (enumVals) return enumVals.map((v2) => `"${v2}"`).join(" | ");
|
|
19179
|
-
if (zodType === "literal") {
|
|
19180
|
-
const vals = getZodDef(inner)?.values;
|
|
19181
|
-
if (Array.isArray(vals) && vals.length === 1) {
|
|
19182
|
-
const v2 = vals[0];
|
|
19183
|
-
return typeof v2 === "string" ? `"${v2}"` : String(v2);
|
|
19184
|
-
}
|
|
19185
|
-
}
|
|
19186
|
-
const shape = getObjectShape(inner);
|
|
19187
|
-
if (shape) return `{${Object.entries(shape).map(([name, fieldSchema]) => {
|
|
19188
|
-
const opt = isOptionalType(fieldSchema) ? "?" : "";
|
|
19189
|
-
const fieldType = resolveTypeAnnotation(fieldSchema, reg);
|
|
19190
|
-
return fieldType ? `${name}${opt}: ${fieldType}` : `${name}${opt}`;
|
|
19191
|
-
}).join(", ")}}`;
|
|
19192
|
-
return "any";
|
|
19193
|
-
}
|
|
19194
|
-
function analyzeFields(shape, reg) {
|
|
19195
|
-
return Object.entries(shape).map(([name, schema]) => ({
|
|
19196
|
-
name,
|
|
19197
|
-
isOptional: isOptionalType(schema),
|
|
19198
|
-
isArray: isArrayType(schema),
|
|
19199
|
-
typeAnnotation: resolveTypeAnnotation(schema, reg)
|
|
19200
|
-
}));
|
|
19201
|
-
}
|
|
19202
|
-
function buildSignature(componentName, fields) {
|
|
19203
|
-
return `${componentName}(${fields.map((f) => {
|
|
19204
|
-
if (f.typeAnnotation) return f.isOptional ? `${f.name}?: ${f.typeAnnotation}` : `${f.name}: ${f.typeAnnotation}`;
|
|
19205
|
-
if (f.isArray) return f.isOptional ? `[${f.name}]?` : `[${f.name}]`;
|
|
19206
|
-
return f.isOptional ? `${f.name}?` : f.name;
|
|
19207
|
-
}).join(", ")})`;
|
|
19208
|
-
}
|
|
19209
|
-
function buildComponentSpecs(components, reg) {
|
|
19210
|
-
const specs = {};
|
|
19211
|
-
for (const [name, def] of Object.entries(components)) specs[name] = {
|
|
19212
|
-
signature: buildSignature(name, analyzeFields(def.props.shape, reg)),
|
|
19213
|
-
description: def.description
|
|
19214
|
-
};
|
|
19215
|
-
return specs;
|
|
19216
|
-
}
|
|
19217
|
-
var fallbackLibraryId = 0;
|
|
19218
|
-
function createLibraryId() {
|
|
19219
|
-
if (typeof globalThis.crypto?.randomUUID === "function") return globalThis.crypto.randomUUID();
|
|
19220
|
-
fallbackLibraryId += 1;
|
|
19221
|
-
return `openui-lib-${Date.now().toString(36)}-${fallbackLibraryId.toString(36)}`;
|
|
19222
|
-
}
|
|
19223
|
-
function createLibrary(input) {
|
|
19224
|
-
const componentsRecord = {};
|
|
19225
|
-
const reg = registry();
|
|
19226
|
-
const __libraryId = createLibraryId();
|
|
19227
|
-
for (const comp of input.components) {
|
|
19228
|
-
reg.add(comp.props, { id: comp.name });
|
|
19229
|
-
componentsRecord[comp.name] = comp;
|
|
19230
|
-
}
|
|
19231
|
-
if (input.root && !componentsRecord[input.root]) {
|
|
19232
|
-
const available = Object.keys(componentsRecord).join(", ");
|
|
19233
|
-
throw new Error(`[createLibrary] Root component "${input.root}" was not found in components. Available components: ${available}`);
|
|
19234
|
-
}
|
|
19235
|
-
const library = {
|
|
19236
|
-
components: componentsRecord,
|
|
19237
|
-
componentGroups: input.componentGroups,
|
|
19238
|
-
root: input.root,
|
|
19239
|
-
id: input.id,
|
|
19240
|
-
__libraryId,
|
|
19241
|
-
prompt(options) {
|
|
19242
|
-
return generatePrompt({
|
|
19243
|
-
root: input.root,
|
|
19244
|
-
components: buildComponentSpecs(componentsRecord, reg),
|
|
19245
|
-
componentGroups: input.componentGroups,
|
|
19246
|
-
...options
|
|
19247
|
-
});
|
|
19248
|
-
},
|
|
19249
|
-
toSpec() {
|
|
19250
|
-
return {
|
|
19251
|
-
root: input.root,
|
|
19252
|
-
components: buildComponentSpecs(componentsRecord, reg),
|
|
19253
|
-
componentGroups: input.componentGroups,
|
|
19254
|
-
schema: buildJSONSchema(),
|
|
19255
|
-
...input.id !== void 0 ? { id: input.id } : {}
|
|
19256
|
-
};
|
|
19257
|
-
},
|
|
19258
|
-
toJSONSchema() {
|
|
19259
|
-
return buildJSONSchema();
|
|
19260
|
-
}
|
|
19261
|
-
};
|
|
19262
|
-
function buildJSONSchema() {
|
|
19263
|
-
const combinedSchema = object(Object.fromEntries(Object.entries(componentsRecord).map(([k2, v2]) => [k2, v2.props])));
|
|
19264
|
-
const schema = toJSONSchema(combinedSchema, { metadata: reg });
|
|
19265
|
-
for (const [name, comp] of Object.entries(componentsRecord)) {
|
|
19266
|
-
const def = schema.$defs?.[name];
|
|
19267
|
-
if (def && comp.description) def.description = comp.description;
|
|
19268
|
-
}
|
|
19269
|
-
return schema;
|
|
19270
|
-
}
|
|
19271
|
-
return library;
|
|
19272
|
-
}
|
|
19273
|
-
function isElementNode(value) {
|
|
19274
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
19275
|
-
const node = value;
|
|
19276
|
-
return node.type === "element" && typeof node.typeName === "string" && typeof node.props === "object" && node.props !== null && typeof node.partial === "boolean";
|
|
19277
|
-
}
|
|
19278
|
-
var BuiltinActionType = /* @__PURE__ */ (function(BuiltinActionType2) {
|
|
19279
|
-
BuiltinActionType2["ContinueConversation"] = "continue_conversation";
|
|
19280
|
-
BuiltinActionType2["OpenUrl"] = "open_url";
|
|
19281
|
-
return BuiltinActionType2;
|
|
19282
|
-
})({});
|
|
19283
|
-
function isRuntimeExpr(node) {
|
|
19284
|
-
switch (node.k) {
|
|
19285
|
-
case "StateRef":
|
|
19286
|
-
case "RuntimeRef":
|
|
19287
|
-
case "BinOp":
|
|
19288
|
-
case "UnaryOp":
|
|
19289
|
-
case "Ternary":
|
|
19290
|
-
case "Member":
|
|
19291
|
-
case "Index":
|
|
19292
|
-
case "Assign":
|
|
19293
|
-
return true;
|
|
19294
|
-
default:
|
|
19295
|
-
return false;
|
|
19296
|
-
}
|
|
19297
|
-
}
|
|
19298
|
-
var AST_KINDS = /* @__PURE__ */ new Set([
|
|
19299
|
-
"Comp",
|
|
19300
|
-
"Ref",
|
|
19301
|
-
"StateRef",
|
|
19302
|
-
"RuntimeRef",
|
|
19303
|
-
"BinOp",
|
|
19304
|
-
"UnaryOp",
|
|
19305
|
-
"Ternary",
|
|
19306
|
-
"Member",
|
|
19307
|
-
"Index",
|
|
19308
|
-
"Assign",
|
|
19309
|
-
"Str",
|
|
19310
|
-
"Num",
|
|
19311
|
-
"Bool",
|
|
19312
|
-
"Null",
|
|
19313
|
-
"Arr",
|
|
19314
|
-
"Obj",
|
|
19315
|
-
"Ph"
|
|
19316
|
-
]);
|
|
19317
|
-
function isASTNode(value) {
|
|
19318
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
19319
|
-
return AST_KINDS.has(value.k);
|
|
19320
|
-
}
|
|
19321
|
-
function walkAST(node, visit2) {
|
|
19322
|
-
const walk = (current2) => {
|
|
19323
|
-
visit2(current2);
|
|
19324
|
-
switch (current2.k) {
|
|
19325
|
-
case "Comp":
|
|
19326
|
-
current2.args.forEach(walk);
|
|
19327
|
-
Object.values(current2.mappedProps ?? {}).forEach(walk);
|
|
19328
|
-
break;
|
|
19329
|
-
case "Arr":
|
|
19330
|
-
current2.els.forEach(walk);
|
|
19331
|
-
break;
|
|
19332
|
-
case "Obj":
|
|
19333
|
-
current2.entries.forEach(([, value]) => walk(value));
|
|
19334
|
-
break;
|
|
19335
|
-
case "BinOp":
|
|
19336
|
-
walk(current2.left);
|
|
19337
|
-
walk(current2.right);
|
|
19338
|
-
break;
|
|
19339
|
-
case "UnaryOp":
|
|
19340
|
-
walk(current2.operand);
|
|
19341
|
-
break;
|
|
19342
|
-
case "Ternary":
|
|
19343
|
-
walk(current2.cond);
|
|
19344
|
-
walk(current2.then);
|
|
19345
|
-
walk(current2.else);
|
|
19346
|
-
break;
|
|
19347
|
-
case "Member":
|
|
19348
|
-
walk(current2.obj);
|
|
19349
|
-
break;
|
|
19350
|
-
case "Index":
|
|
19351
|
-
walk(current2.obj);
|
|
19352
|
-
walk(current2.index);
|
|
19353
|
-
break;
|
|
19354
|
-
case "Assign":
|
|
19355
|
-
walk(current2.value);
|
|
19356
|
-
}
|
|
19357
|
-
};
|
|
19358
|
-
walk(node);
|
|
19359
|
-
}
|
|
19360
|
-
var PREC_TERNARY = 1;
|
|
19361
|
-
var PREC_OR = 2;
|
|
19362
|
-
var PREC_AND = 3;
|
|
19363
|
-
var PREC_EQ = 4;
|
|
19364
|
-
var PREC_CMP = 5;
|
|
19365
|
-
var PREC_ADD = 6;
|
|
19366
|
-
var PREC_MUL = 7;
|
|
19367
|
-
var PREC_UNARY = 8;
|
|
19368
|
-
var PREC_MEMBER = 9;
|
|
19369
|
-
function parseExpression(tokens) {
|
|
19370
|
-
let pos = 0;
|
|
19371
|
-
const cur = () => tokens[pos] ?? { t: 13 };
|
|
19372
|
-
const adv = () => {
|
|
19373
|
-
const tok = cur();
|
|
19374
|
-
pos++;
|
|
19375
|
-
return tok;
|
|
19376
|
-
};
|
|
19377
|
-
const eat = (kind) => {
|
|
19378
|
-
if (cur().t === kind) pos++;
|
|
19379
|
-
};
|
|
19380
|
-
function getInfixPrec(tok) {
|
|
19381
|
-
switch (tok.t) {
|
|
19382
|
-
case 34:
|
|
19383
|
-
return PREC_TERNARY;
|
|
19384
|
-
case 32:
|
|
19385
|
-
return PREC_OR;
|
|
19386
|
-
case 31:
|
|
19387
|
-
return PREC_AND;
|
|
19388
|
-
case 25:
|
|
19389
|
-
case 26:
|
|
19390
|
-
return PREC_EQ;
|
|
19391
|
-
case 27:
|
|
19392
|
-
case 28:
|
|
19393
|
-
case 29:
|
|
19394
|
-
case 30:
|
|
19395
|
-
return PREC_CMP;
|
|
19396
|
-
case 20:
|
|
19397
|
-
case 21:
|
|
19398
|
-
return PREC_ADD;
|
|
19399
|
-
case 22:
|
|
19400
|
-
case 23:
|
|
19401
|
-
case 24:
|
|
19402
|
-
return PREC_MUL;
|
|
19403
|
-
case 19:
|
|
19404
|
-
case 3:
|
|
19405
|
-
return PREC_MEMBER;
|
|
19406
|
-
default:
|
|
19407
|
-
return 0;
|
|
19408
|
-
}
|
|
19409
|
-
}
|
|
19410
|
-
function parseExpr(minPrec = 0) {
|
|
19411
|
-
let left = parsePrefix();
|
|
19412
|
-
while (getInfixPrec(cur()) > minPrec) left = parseInfix(left);
|
|
19413
|
-
return left;
|
|
19414
|
-
}
|
|
19415
|
-
function parsePrefix() {
|
|
19416
|
-
const tok = cur();
|
|
19417
|
-
if (tok.t === 14) {
|
|
19418
|
-
adv();
|
|
19419
|
-
return {
|
|
19420
|
-
k: "Str",
|
|
19421
|
-
v: tok.v
|
|
19422
|
-
};
|
|
19423
|
-
}
|
|
19424
|
-
if (tok.t === 15) {
|
|
19425
|
-
adv();
|
|
19426
|
-
return {
|
|
19427
|
-
k: "Num",
|
|
19428
|
-
v: tok.v
|
|
19429
|
-
};
|
|
19430
|
-
}
|
|
19431
|
-
if (tok.t === 10) {
|
|
19432
|
-
adv();
|
|
19433
|
-
return {
|
|
19434
|
-
k: "Bool",
|
|
19435
|
-
v: true
|
|
19436
|
-
};
|
|
19437
|
-
}
|
|
19438
|
-
if (tok.t === 11) {
|
|
19439
|
-
adv();
|
|
19440
|
-
return {
|
|
19441
|
-
k: "Bool",
|
|
19442
|
-
v: false
|
|
19443
|
-
};
|
|
19444
|
-
}
|
|
19445
|
-
if (tok.t === 12) {
|
|
19446
|
-
adv();
|
|
19447
|
-
return { k: "Null" };
|
|
19448
|
-
}
|
|
19449
|
-
if (tok.t === 3) return parseArr();
|
|
19450
|
-
if (tok.t === 5) return parseObj();
|
|
19451
|
-
if (tok.t === 18) {
|
|
19452
|
-
const name = tok.v;
|
|
19453
|
-
adv();
|
|
19454
|
-
if (cur().t === 9) {
|
|
19455
|
-
adv();
|
|
19456
|
-
return {
|
|
19457
|
-
k: "Assign",
|
|
19458
|
-
target: name,
|
|
19459
|
-
value: parseExpr(0)
|
|
19460
|
-
};
|
|
19461
|
-
}
|
|
19462
|
-
return {
|
|
19463
|
-
k: "StateRef",
|
|
19464
|
-
n: name
|
|
19465
|
-
};
|
|
19466
|
-
}
|
|
19467
|
-
if (tok.t === 17) {
|
|
19468
|
-
const name = tok.v;
|
|
19469
|
-
if (tokens[pos + 1]?.t === 1 && (!isBuiltin(name) || name === "Action")) return parseComp();
|
|
19470
|
-
adv();
|
|
19471
|
-
return {
|
|
19472
|
-
k: "Ref",
|
|
19473
|
-
n: name
|
|
19474
|
-
};
|
|
19475
|
-
}
|
|
19476
|
-
if (tok.t === 35) {
|
|
19477
|
-
if (tokens[pos + 1]?.t === 1) return parseComp();
|
|
19478
|
-
adv();
|
|
19479
|
-
return {
|
|
19480
|
-
k: "Ref",
|
|
19481
|
-
n: tok.v
|
|
19482
|
-
};
|
|
19483
|
-
}
|
|
19484
|
-
if (tok.t === 16) {
|
|
19485
|
-
adv();
|
|
19486
|
-
return {
|
|
19487
|
-
k: "Ref",
|
|
19488
|
-
n: tok.v
|
|
19489
|
-
};
|
|
19490
|
-
}
|
|
19491
|
-
if (tok.t === 33) {
|
|
19492
|
-
adv();
|
|
19493
|
-
return {
|
|
19494
|
-
k: "UnaryOp",
|
|
19495
|
-
op: "!",
|
|
19496
|
-
operand: parseExpr(PREC_UNARY)
|
|
19497
|
-
};
|
|
19498
|
-
}
|
|
19499
|
-
if (tok.t === 21) {
|
|
19500
|
-
adv();
|
|
19501
|
-
return {
|
|
19502
|
-
k: "UnaryOp",
|
|
19503
|
-
op: "-",
|
|
19504
|
-
operand: parseExpr(PREC_UNARY)
|
|
19505
|
-
};
|
|
19506
|
-
}
|
|
19507
|
-
if (tok.t === 1) {
|
|
19508
|
-
adv();
|
|
19509
|
-
const inner = parseExpr(0);
|
|
19510
|
-
eat(2);
|
|
19511
|
-
return inner;
|
|
19512
|
-
}
|
|
19513
|
-
adv();
|
|
19514
|
-
return { k: "Null" };
|
|
19515
|
-
}
|
|
19516
|
-
function parseInfix(left) {
|
|
19517
|
-
const tok = cur();
|
|
19518
|
-
if (tok.t === 20) {
|
|
19519
|
-
adv();
|
|
19520
|
-
return {
|
|
19521
|
-
k: "BinOp",
|
|
19522
|
-
op: "+",
|
|
19523
|
-
left,
|
|
19524
|
-
right: parseExpr(PREC_ADD)
|
|
19525
|
-
};
|
|
19526
|
-
}
|
|
19527
|
-
if (tok.t === 21) {
|
|
19528
|
-
adv();
|
|
19529
|
-
return {
|
|
19530
|
-
k: "BinOp",
|
|
19531
|
-
op: "-",
|
|
19532
|
-
left,
|
|
19533
|
-
right: parseExpr(PREC_ADD)
|
|
19534
|
-
};
|
|
19535
|
-
}
|
|
19536
|
-
if (tok.t === 22) {
|
|
19537
|
-
adv();
|
|
19538
|
-
return {
|
|
19539
|
-
k: "BinOp",
|
|
19540
|
-
op: "*",
|
|
19541
|
-
left,
|
|
19542
|
-
right: parseExpr(PREC_MUL)
|
|
19543
|
-
};
|
|
19544
|
-
}
|
|
19545
|
-
if (tok.t === 23) {
|
|
19546
|
-
adv();
|
|
19547
|
-
return {
|
|
19548
|
-
k: "BinOp",
|
|
19549
|
-
op: "/",
|
|
19550
|
-
left,
|
|
19551
|
-
right: parseExpr(PREC_MUL)
|
|
19552
|
-
};
|
|
19553
|
-
}
|
|
19554
|
-
if (tok.t === 24) {
|
|
19555
|
-
adv();
|
|
19556
|
-
return {
|
|
19557
|
-
k: "BinOp",
|
|
19558
|
-
op: "%",
|
|
19559
|
-
left,
|
|
19560
|
-
right: parseExpr(PREC_MUL)
|
|
19561
|
-
};
|
|
19562
|
-
}
|
|
19563
|
-
if (tok.t === 25) {
|
|
19564
|
-
adv();
|
|
19565
|
-
return {
|
|
19566
|
-
k: "BinOp",
|
|
19567
|
-
op: "==",
|
|
19568
|
-
left,
|
|
19569
|
-
right: parseExpr(PREC_EQ)
|
|
19570
|
-
};
|
|
19571
|
-
}
|
|
19572
|
-
if (tok.t === 26) {
|
|
19573
|
-
adv();
|
|
19574
|
-
return {
|
|
19575
|
-
k: "BinOp",
|
|
19576
|
-
op: "!=",
|
|
19577
|
-
left,
|
|
19578
|
-
right: parseExpr(PREC_EQ)
|
|
19579
|
-
};
|
|
19580
|
-
}
|
|
19581
|
-
if (tok.t === 27) {
|
|
19582
|
-
adv();
|
|
19583
|
-
return {
|
|
19584
|
-
k: "BinOp",
|
|
19585
|
-
op: ">",
|
|
19586
|
-
left,
|
|
19587
|
-
right: parseExpr(PREC_CMP)
|
|
19588
|
-
};
|
|
19589
|
-
}
|
|
19590
|
-
if (tok.t === 28) {
|
|
19591
|
-
adv();
|
|
19592
|
-
return {
|
|
19593
|
-
k: "BinOp",
|
|
19594
|
-
op: "<",
|
|
19595
|
-
left,
|
|
19596
|
-
right: parseExpr(PREC_CMP)
|
|
19597
|
-
};
|
|
19598
|
-
}
|
|
19599
|
-
if (tok.t === 29) {
|
|
19600
|
-
adv();
|
|
19601
|
-
return {
|
|
19602
|
-
k: "BinOp",
|
|
19603
|
-
op: ">=",
|
|
19604
|
-
left,
|
|
19605
|
-
right: parseExpr(PREC_CMP)
|
|
19606
|
-
};
|
|
19607
|
-
}
|
|
19608
|
-
if (tok.t === 30) {
|
|
19609
|
-
adv();
|
|
19610
|
-
return {
|
|
19611
|
-
k: "BinOp",
|
|
19612
|
-
op: "<=",
|
|
19613
|
-
left,
|
|
19614
|
-
right: parseExpr(PREC_CMP)
|
|
19615
|
-
};
|
|
19616
|
-
}
|
|
19617
|
-
if (tok.t === 31) {
|
|
19618
|
-
adv();
|
|
19619
|
-
return {
|
|
19620
|
-
k: "BinOp",
|
|
19621
|
-
op: "&&",
|
|
19622
|
-
left,
|
|
19623
|
-
right: parseExpr(PREC_AND)
|
|
19624
|
-
};
|
|
19625
|
-
}
|
|
19626
|
-
if (tok.t === 32) {
|
|
19627
|
-
adv();
|
|
19628
|
-
return {
|
|
19629
|
-
k: "BinOp",
|
|
19630
|
-
op: "||",
|
|
19631
|
-
left,
|
|
19632
|
-
right: parseExpr(PREC_OR)
|
|
19633
|
-
};
|
|
19634
|
-
}
|
|
19635
|
-
if (tok.t === 34) {
|
|
19636
|
-
adv();
|
|
19637
|
-
const then = parseExpr(0);
|
|
19638
|
-
eat(8);
|
|
19639
|
-
return {
|
|
19640
|
-
k: "Ternary",
|
|
19641
|
-
cond: left,
|
|
19642
|
-
then,
|
|
19643
|
-
else: parseExpr(0)
|
|
19644
|
-
};
|
|
19645
|
-
}
|
|
19646
|
-
if (tok.t === 19) {
|
|
19647
|
-
adv();
|
|
19648
|
-
const fieldTok = cur();
|
|
19649
|
-
return {
|
|
19650
|
-
k: "Member",
|
|
19651
|
-
obj: left,
|
|
19652
|
-
field: fieldTok.t === 16 || fieldTok.t === 17 || fieldTok.t === 14 || fieldTok.t === 15 ? (adv(), String(fieldTok.v)) : fieldTok.t === 18 ? (adv(), fieldTok.v.replace(/^\$/, "")) : (adv(), "?")
|
|
19653
|
-
};
|
|
19654
|
-
}
|
|
19655
|
-
if (tok.t === 3) {
|
|
19656
|
-
adv();
|
|
19657
|
-
const index = parseExpr(0);
|
|
19658
|
-
eat(4);
|
|
19659
|
-
return {
|
|
19660
|
-
k: "Index",
|
|
19661
|
-
obj: left,
|
|
19662
|
-
index
|
|
19663
|
-
};
|
|
19664
|
-
}
|
|
19665
|
-
return left;
|
|
19666
|
-
}
|
|
19667
|
-
function parseComp() {
|
|
19668
|
-
const name = cur().v;
|
|
19669
|
-
adv();
|
|
19670
|
-
eat(1);
|
|
19671
|
-
const args = [];
|
|
19672
|
-
while (cur().t !== 2 && cur().t !== 13) {
|
|
19673
|
-
args.push(parseExpr(0));
|
|
19674
|
-
if (cur().t === 7) adv();
|
|
19675
|
-
}
|
|
19676
|
-
eat(2);
|
|
19677
|
-
return {
|
|
19678
|
-
k: "Comp",
|
|
19679
|
-
name,
|
|
19680
|
-
args
|
|
19681
|
-
};
|
|
19682
|
-
}
|
|
19683
|
-
function parseArr() {
|
|
19684
|
-
adv();
|
|
19685
|
-
const els = [];
|
|
19686
|
-
while (cur().t !== 4 && cur().t !== 13) {
|
|
19687
|
-
els.push(parseExpr(0));
|
|
19688
|
-
if (cur().t === 7) adv();
|
|
19689
|
-
}
|
|
19690
|
-
eat(4);
|
|
19691
|
-
return {
|
|
19692
|
-
k: "Arr",
|
|
19693
|
-
els
|
|
19694
|
-
};
|
|
19695
|
-
}
|
|
19696
|
-
function parseObj() {
|
|
19697
|
-
adv();
|
|
19698
|
-
const entries = [];
|
|
19699
|
-
while (cur().t !== 6 && cur().t !== 13) {
|
|
19700
|
-
const kt = cur();
|
|
19701
|
-
const key = kt.t === 16 || kt.t === 14 || kt.t === 17 || kt.t === 15 ? (adv(), String(kt.v)) : kt.t === 18 ? (adv(), kt.v.replace(/^\$/, "")) : (adv(), "?");
|
|
19702
|
-
eat(8);
|
|
19703
|
-
entries.push([key, parseExpr(0)]);
|
|
19704
|
-
if (cur().t === 7) adv();
|
|
19705
|
-
}
|
|
19706
|
-
eat(6);
|
|
19707
|
-
return {
|
|
19708
|
-
k: "Obj",
|
|
19709
|
-
entries
|
|
19710
|
-
};
|
|
19711
|
-
}
|
|
19712
|
-
return parseExpr(0);
|
|
19713
|
-
}
|
|
19714
|
-
function tokenize(src) {
|
|
19715
|
-
const tokens = [];
|
|
19716
|
-
let i = 0;
|
|
19717
|
-
const n = src.length;
|
|
19718
|
-
while (i < n) {
|
|
19719
|
-
while (i < n && (src[i] === " " || src[i] === " " || src[i] === "\r")) i++;
|
|
19720
|
-
if (i >= n) break;
|
|
19721
|
-
const c2 = src[i];
|
|
19722
|
-
if (c2 === "\n") {
|
|
19723
|
-
tokens.push({ t: 0 });
|
|
19724
|
-
i++;
|
|
19725
|
-
continue;
|
|
19726
|
-
}
|
|
19727
|
-
if (c2 === "(") {
|
|
19728
|
-
tokens.push({ t: 1 });
|
|
19729
|
-
i++;
|
|
19730
|
-
continue;
|
|
19731
|
-
}
|
|
19732
|
-
if (c2 === ")") {
|
|
19733
|
-
tokens.push({ t: 2 });
|
|
19734
|
-
i++;
|
|
19735
|
-
continue;
|
|
19736
|
-
}
|
|
19737
|
-
if (c2 === "[") {
|
|
19738
|
-
tokens.push({ t: 3 });
|
|
19739
|
-
i++;
|
|
19740
|
-
continue;
|
|
19741
|
-
}
|
|
19742
|
-
if (c2 === "]") {
|
|
19743
|
-
tokens.push({ t: 4 });
|
|
19744
|
-
i++;
|
|
19745
|
-
continue;
|
|
19746
|
-
}
|
|
19747
|
-
if (c2 === "{") {
|
|
19748
|
-
tokens.push({ t: 5 });
|
|
19749
|
-
i++;
|
|
19750
|
-
continue;
|
|
19751
|
-
}
|
|
19752
|
-
if (c2 === "}") {
|
|
19753
|
-
tokens.push({ t: 6 });
|
|
19754
|
-
i++;
|
|
19755
|
-
continue;
|
|
19756
|
-
}
|
|
19757
|
-
if (c2 === ",") {
|
|
19758
|
-
tokens.push({ t: 7 });
|
|
19759
|
-
i++;
|
|
19760
|
-
continue;
|
|
19761
|
-
}
|
|
19762
|
-
if (c2 === ":") {
|
|
19763
|
-
tokens.push({ t: 8 });
|
|
19764
|
-
i++;
|
|
19765
|
-
continue;
|
|
19766
|
-
}
|
|
19767
|
-
if (c2 === "=") {
|
|
19768
|
-
if (i + 1 < n && src[i + 1] === "=") {
|
|
19769
|
-
tokens.push({ t: 25 });
|
|
19770
|
-
i += 2;
|
|
19771
|
-
} else {
|
|
19772
|
-
tokens.push({ t: 9 });
|
|
19773
|
-
i++;
|
|
19774
|
-
}
|
|
19775
|
-
continue;
|
|
19776
|
-
}
|
|
19777
|
-
if (c2 === "!") {
|
|
19778
|
-
if (i + 1 < n && src[i + 1] === "=") {
|
|
19779
|
-
tokens.push({ t: 26 });
|
|
19780
|
-
i += 2;
|
|
19781
|
-
} else {
|
|
19782
|
-
tokens.push({ t: 33 });
|
|
19783
|
-
i++;
|
|
19784
|
-
}
|
|
19785
|
-
continue;
|
|
19786
|
-
}
|
|
19787
|
-
if (c2 === ">") {
|
|
19788
|
-
if (i + 1 < n && src[i + 1] === "=") {
|
|
19789
|
-
tokens.push({ t: 29 });
|
|
19790
|
-
i += 2;
|
|
19791
|
-
} else {
|
|
19792
|
-
tokens.push({ t: 27 });
|
|
19793
|
-
i++;
|
|
19794
|
-
}
|
|
19795
|
-
continue;
|
|
19796
|
-
}
|
|
19797
|
-
if (c2 === "<") {
|
|
19798
|
-
if (i + 1 < n && src[i + 1] === "=") {
|
|
19799
|
-
tokens.push({ t: 30 });
|
|
19800
|
-
i += 2;
|
|
19801
|
-
} else {
|
|
19802
|
-
tokens.push({ t: 28 });
|
|
19803
|
-
i++;
|
|
19804
|
-
}
|
|
19805
|
-
continue;
|
|
19806
|
-
}
|
|
19807
|
-
if (c2 === "&") {
|
|
19808
|
-
if (i + 1 < n && src[i + 1] === "&") {
|
|
19809
|
-
tokens.push({ t: 31 });
|
|
19810
|
-
i += 2;
|
|
19811
|
-
} else {
|
|
19812
|
-
tokens.push({ t: 31 });
|
|
19813
|
-
i++;
|
|
19814
|
-
}
|
|
19815
|
-
continue;
|
|
19816
|
-
}
|
|
19817
|
-
if (c2 === "|") {
|
|
19818
|
-
if (i + 1 < n && src[i + 1] === "|") {
|
|
19819
|
-
tokens.push({ t: 32 });
|
|
19820
|
-
i += 2;
|
|
19821
|
-
} else {
|
|
19822
|
-
tokens.push({ t: 32 });
|
|
19823
|
-
i++;
|
|
19824
|
-
}
|
|
19825
|
-
continue;
|
|
19826
|
-
}
|
|
19827
|
-
if (c2 === ".") {
|
|
19828
|
-
tokens.push({ t: 19 });
|
|
19829
|
-
i++;
|
|
19830
|
-
continue;
|
|
19831
|
-
}
|
|
19832
|
-
if (c2 === "?") {
|
|
19833
|
-
tokens.push({ t: 34 });
|
|
19834
|
-
i++;
|
|
19835
|
-
continue;
|
|
19836
|
-
}
|
|
19837
|
-
if (c2 === "+") {
|
|
19838
|
-
tokens.push({ t: 20 });
|
|
19839
|
-
i++;
|
|
19840
|
-
continue;
|
|
19841
|
-
}
|
|
19842
|
-
if (c2 === "*") {
|
|
19843
|
-
tokens.push({ t: 22 });
|
|
19844
|
-
i++;
|
|
19845
|
-
continue;
|
|
19846
|
-
}
|
|
19847
|
-
if (c2 === "/") {
|
|
19848
|
-
tokens.push({ t: 23 });
|
|
19849
|
-
i++;
|
|
19850
|
-
continue;
|
|
19851
|
-
}
|
|
19852
|
-
if (c2 === "%") {
|
|
19853
|
-
tokens.push({ t: 24 });
|
|
19854
|
-
i++;
|
|
19855
|
-
continue;
|
|
19856
|
-
}
|
|
19857
|
-
if (c2 === '"') {
|
|
19858
|
-
const start = i;
|
|
19859
|
-
i++;
|
|
19860
|
-
let isClosed = false;
|
|
19861
|
-
while (i < n) if (src[i] === "\\") i += 2;
|
|
19862
|
-
else if (src[i] === '"') {
|
|
19863
|
-
i++;
|
|
19864
|
-
isClosed = true;
|
|
19865
|
-
break;
|
|
19866
|
-
} else i++;
|
|
19867
|
-
const rawString = src.slice(start, i);
|
|
19868
|
-
try {
|
|
19869
|
-
const validJsonString = isClosed ? rawString : rawString + '"';
|
|
19870
|
-
tokens.push({
|
|
19871
|
-
t: 14,
|
|
19872
|
-
v: JSON.parse(validJsonString)
|
|
19873
|
-
});
|
|
19874
|
-
} catch {
|
|
19875
|
-
const stripped = rawString.replace(/^"|"$/g, "");
|
|
19876
|
-
tokens.push({
|
|
19877
|
-
t: 14,
|
|
19878
|
-
v: stripped
|
|
19879
|
-
});
|
|
19880
|
-
}
|
|
19881
|
-
continue;
|
|
19882
|
-
}
|
|
19883
|
-
if (c2 === "'") {
|
|
19884
|
-
i++;
|
|
19885
|
-
let result = "";
|
|
19886
|
-
while (i < n) if (src[i] === "\\") {
|
|
19887
|
-
i++;
|
|
19888
|
-
if (i < n) {
|
|
19889
|
-
const esc = src[i];
|
|
19890
|
-
if (esc === "'") result += "'";
|
|
19891
|
-
else if (esc === "\\") result += "\\";
|
|
19892
|
-
else if (esc === "n") result += "\n";
|
|
19893
|
-
else if (esc === "t") result += " ";
|
|
19894
|
-
else result += esc;
|
|
19895
|
-
i++;
|
|
19896
|
-
}
|
|
19897
|
-
} else if (src[i] === "'") {
|
|
19898
|
-
i++;
|
|
19899
|
-
break;
|
|
19900
|
-
} else {
|
|
19901
|
-
result += src[i];
|
|
19902
|
-
i++;
|
|
19903
|
-
}
|
|
19904
|
-
tokens.push({
|
|
19905
|
-
t: 14,
|
|
19906
|
-
v: result
|
|
19907
|
-
});
|
|
19908
|
-
continue;
|
|
19909
|
-
}
|
|
19910
|
-
if (c2 === "-") {
|
|
19911
|
-
const prev = tokens.length > 0 ? tokens[tokens.length - 1] : null;
|
|
19912
|
-
if (!(prev != null && (prev.t === 15 || prev.t === 14 || prev.t === 16 || prev.t === 17 || prev.t === 2 || prev.t === 4 || prev.t === 10 || prev.t === 11 || prev.t === 12 || prev.t === 18 || prev.t === 35)) && i + 1 < n && src[i + 1] >= "0" && src[i + 1] <= "9") {
|
|
19913
|
-
} else {
|
|
19914
|
-
tokens.push({ t: 21 });
|
|
19915
|
-
i++;
|
|
19916
|
-
continue;
|
|
19917
|
-
}
|
|
19918
|
-
}
|
|
19919
|
-
const isDigit = c2 >= "0" && c2 <= "9";
|
|
19920
|
-
const isNegDigit = c2 === "-" && i + 1 < n && src[i + 1] >= "0" && src[i + 1] <= "9";
|
|
19921
|
-
if (isDigit || isNegDigit) {
|
|
19922
|
-
const start = i;
|
|
19923
|
-
if (src[i] === "-") i++;
|
|
19924
|
-
while (i < n && src[i] >= "0" && src[i] <= "9") i++;
|
|
19925
|
-
if (i < n && src[i] === "." && i + 1 < n && src[i + 1] >= "0" && src[i + 1] <= "9") {
|
|
19926
|
-
i++;
|
|
19927
|
-
while (i < n && src[i] >= "0" && src[i] <= "9") i++;
|
|
19928
|
-
}
|
|
19929
|
-
if (i < n && (src[i] === "e" || src[i] === "E")) {
|
|
19930
|
-
i++;
|
|
19931
|
-
if (i < n && (src[i] === "+" || src[i] === "-")) i++;
|
|
19932
|
-
while (i < n && src[i] >= "0" && src[i] <= "9") i++;
|
|
19933
|
-
}
|
|
19934
|
-
tokens.push({
|
|
19935
|
-
t: 15,
|
|
19936
|
-
v: +src.slice(start, i)
|
|
19937
|
-
});
|
|
19938
|
-
continue;
|
|
19939
|
-
}
|
|
19940
|
-
if (c2 === "$" && i + 1 < n && (src[i + 1] >= "a" && src[i + 1] <= "z" || src[i + 1] >= "A" && src[i + 1] <= "Z" || src[i + 1] === "_")) {
|
|
19941
|
-
const start = i;
|
|
19942
|
-
i++;
|
|
19943
|
-
while (i < n && (src[i] >= "a" && src[i] <= "z" || src[i] >= "A" && src[i] <= "Z" || src[i] >= "0" && src[i] <= "9" || src[i] === "_")) i++;
|
|
19944
|
-
tokens.push({
|
|
19945
|
-
t: 18,
|
|
19946
|
-
v: src.slice(start, i)
|
|
19947
|
-
});
|
|
19948
|
-
continue;
|
|
19949
|
-
}
|
|
19950
|
-
if (c2 >= "a" && c2 <= "z" || c2 >= "A" && c2 <= "Z" || c2 === "_") {
|
|
19951
|
-
const start = i;
|
|
19952
|
-
while (i < n && (src[i] >= "a" && src[i] <= "z" || src[i] >= "A" && src[i] <= "Z" || src[i] >= "0" && src[i] <= "9" || src[i] === "_")) i++;
|
|
19953
|
-
const word = src.slice(start, i);
|
|
19954
|
-
if (word === "true") {
|
|
19955
|
-
tokens.push({ t: 10 });
|
|
19956
|
-
continue;
|
|
19957
|
-
}
|
|
19958
|
-
if (word === "false") {
|
|
19959
|
-
tokens.push({ t: 11 });
|
|
19960
|
-
continue;
|
|
19961
|
-
}
|
|
19962
|
-
if (word === "null") {
|
|
19963
|
-
tokens.push({ t: 12 });
|
|
19964
|
-
continue;
|
|
19965
|
-
}
|
|
19966
|
-
const kind = c2 >= "A" && c2 <= "Z" ? 17 : 16;
|
|
19967
|
-
tokens.push({
|
|
19968
|
-
t: kind,
|
|
19969
|
-
v: word
|
|
19970
|
-
});
|
|
19971
|
-
continue;
|
|
19972
|
-
}
|
|
19973
|
-
if (c2 === "@" && i + 1 < n && (src[i + 1] >= "a" && src[i + 1] <= "z" || src[i + 1] >= "A" && src[i + 1] <= "Z" || src[i + 1] === "_")) {
|
|
19974
|
-
i++;
|
|
19975
|
-
const start = i;
|
|
19976
|
-
while (i < n && (src[i] >= "a" && src[i] <= "z" || src[i] >= "A" && src[i] <= "Z" || src[i] >= "0" && src[i] <= "9" || src[i] === "_")) i++;
|
|
19977
|
-
tokens.push({
|
|
19978
|
-
t: 35,
|
|
19979
|
-
v: src.slice(start, i)
|
|
19980
|
-
});
|
|
19981
|
-
continue;
|
|
19982
|
-
}
|
|
19983
|
-
i++;
|
|
19984
|
-
}
|
|
19985
|
-
tokens.push({ t: 13 });
|
|
19986
|
-
return tokens;
|
|
19987
|
-
}
|
|
19988
|
-
var SCALAR_TYPEOFS = [
|
|
19989
|
-
"string",
|
|
19990
|
-
"number",
|
|
19991
|
-
"boolean"
|
|
19992
|
-
];
|
|
19993
|
-
var NO_PROPS = {};
|
|
19994
|
-
var NO_REQUIRED = [];
|
|
19995
|
-
function jsType(value) {
|
|
19996
|
-
return Array.isArray(value) ? "array" : typeof value;
|
|
19997
|
-
}
|
|
19998
|
-
function isCompositeSchema(s2) {
|
|
19999
|
-
return "$ref" in s2 || "anyOf" in s2 || "oneOf" in s2 || "allOf" in s2;
|
|
20000
|
-
}
|
|
20001
|
-
function getScalarTypeInfo(s2) {
|
|
20002
|
-
if (Array.isArray(s2["enum"])) return { enumValues: s2["enum"] };
|
|
20003
|
-
if ("const" in s2) return { enumValues: [s2["const"]] };
|
|
20004
|
-
switch (s2["type"]) {
|
|
20005
|
-
case "string":
|
|
20006
|
-
return { expectedType: "string" };
|
|
20007
|
-
case "number":
|
|
20008
|
-
case "integer":
|
|
20009
|
-
return { expectedType: "number" };
|
|
20010
|
-
case "boolean":
|
|
20011
|
-
return { expectedType: "boolean" };
|
|
20012
|
-
default:
|
|
20013
|
-
return {};
|
|
20014
|
-
}
|
|
20015
|
-
}
|
|
20016
|
-
function getSchemaDefaultValue(property2) {
|
|
20017
|
-
if (!property2 || typeof property2 !== "object" || Array.isArray(property2)) return;
|
|
20018
|
-
return property2.default;
|
|
20019
|
-
}
|
|
20020
|
-
function getTypeFromSchema(property2) {
|
|
20021
|
-
if (!property2 || typeof property2 !== "object" || Array.isArray(property2)) return;
|
|
20022
|
-
const p = property2;
|
|
20023
|
-
if (typeof p.$ref === "string") return p.$ref.split("/").pop();
|
|
20024
|
-
const leaf = getScalarTypeInfo(p);
|
|
20025
|
-
if (leaf.enumValues) return leaf.enumValues.map((v2) => JSON.stringify(v2)).join("|");
|
|
20026
|
-
if (leaf.expectedType) return leaf.expectedType;
|
|
20027
|
-
return typeof p.type === "string" ? p.type : void 0;
|
|
20028
|
-
}
|
|
20029
|
-
function buildParamsSignature(component, params) {
|
|
20030
|
-
return `${component}(${params.map((p) => {
|
|
20031
|
-
const type = getTypeFromSchema(p.schema);
|
|
20032
|
-
const marked = p.required ? `${p.name}*` : p.name;
|
|
20033
|
-
return type ? `${marked}: ${type}` : marked;
|
|
20034
|
-
}).join(", ")})`;
|
|
20035
|
-
}
|
|
20036
|
-
function checkTypeMismatch(value, info) {
|
|
20037
|
-
const actual = typeof value;
|
|
20038
|
-
if (info.enumValues) {
|
|
20039
|
-
if (!SCALAR_TYPEOFS.includes(actual)) return null;
|
|
20040
|
-
if (info.enumValues.includes(value)) return null;
|
|
20041
|
-
return {
|
|
20042
|
-
expected: `one of [${info.enumValues.map((v2) => JSON.stringify(v2)).join(", ")}]`,
|
|
20043
|
-
actual: JSON.stringify(value)
|
|
20044
|
-
};
|
|
20045
|
-
}
|
|
20046
|
-
if (info.expectedType && info.expectedType !== actual) return {
|
|
20047
|
-
expected: info.expectedType,
|
|
20048
|
-
actual: jsType(value)
|
|
20049
|
-
};
|
|
20050
|
-
return null;
|
|
20051
|
-
}
|
|
20052
|
-
function validationMessage$1(component, path2, issue) {
|
|
20053
|
-
switch (issue.code) {
|
|
20054
|
-
case "type-mismatch":
|
|
20055
|
-
return `field "${path2}" expects ${issue.expected} but got ${issue.actual}`;
|
|
20056
|
-
case "missing-required":
|
|
20057
|
-
return `missing required field "${path2}"${issue.signature ? ` \u2014 signature: ${issue.signature}` : ""}`;
|
|
20058
|
-
case "null-required":
|
|
20059
|
-
return `required field "${path2}" cannot be null${issue.signature ? ` \u2014 signature: ${issue.signature}` : ""}`;
|
|
20060
|
-
case "unknown-component":
|
|
20061
|
-
return `Unknown component "${component}" \u2014 not found in catalog or builtins${issue.available?.length ? `. Available components: ${issue.available.join(", ")}` : ""}`;
|
|
20062
|
-
case "inline-reserved":
|
|
20063
|
-
return `${component}() must be declared as a top-level statement, not used inline as a value`;
|
|
20064
|
-
case "excess-args":
|
|
20065
|
-
return `${component} takes ${issue.declared} arg(s), got ${issue.got} (${issue.got - issue.declared} excess dropped)`;
|
|
20066
|
-
}
|
|
20067
|
-
}
|
|
20068
|
-
function pushValidationIssue(ctx, component, path2, issue) {
|
|
20069
|
-
ctx.errors.push({
|
|
20070
|
-
code: issue.code,
|
|
20071
|
-
component,
|
|
20072
|
-
path: path2,
|
|
20073
|
-
message: validationMessage$1(component, path2, issue),
|
|
20074
|
-
statementId: ctx.currentStatementId
|
|
20075
|
-
});
|
|
20076
|
-
}
|
|
20077
|
-
function resolveInvalidValue(container, key, required, defaultValue) {
|
|
20078
|
-
if (defaultValue !== void 0) {
|
|
20079
|
-
container[key] = defaultValue;
|
|
20080
|
-
return false;
|
|
20081
|
-
}
|
|
20082
|
-
if (required) return true;
|
|
20083
|
-
delete container[key];
|
|
20084
|
-
return false;
|
|
20085
|
-
}
|
|
20086
|
-
function validateElementPosition(element, s2, component, path2, ctx) {
|
|
20087
|
-
if (isCompositeSchema(s2)) return false;
|
|
20088
|
-
if (typeof s2["type"] === "string" || Array.isArray(s2["enum"]) || "const" in s2) {
|
|
20089
|
-
pushValidationIssue(ctx, component, path2, {
|
|
20090
|
-
code: "type-mismatch",
|
|
20091
|
-
expected: typeof s2["type"] === "string" ? s2["type"] : "a literal value",
|
|
20092
|
-
actual: `component "${element.typeName}"`
|
|
20093
|
-
});
|
|
20094
|
-
return true;
|
|
20095
|
-
}
|
|
20096
|
-
return false;
|
|
20097
|
-
}
|
|
20098
|
-
function validateObjectValue(value, s2, component, path2, ctx) {
|
|
20099
|
-
if (typeof value !== "object" || Array.isArray(value)) {
|
|
20100
|
-
pushValidationIssue(ctx, component, path2, {
|
|
20101
|
-
code: "type-mismatch",
|
|
20102
|
-
expected: "object",
|
|
20103
|
-
actual: jsType(value)
|
|
20104
|
-
});
|
|
20105
|
-
return true;
|
|
20106
|
-
}
|
|
20107
|
-
const obj = value;
|
|
20108
|
-
const props = s2["properties"] && typeof s2["properties"] === "object" ? s2["properties"] : NO_PROPS;
|
|
20109
|
-
const required = Array.isArray(s2["required"]) ? s2["required"] : NO_REQUIRED;
|
|
20110
|
-
let invalid = false;
|
|
20111
|
-
if (!ctx.partial) for (const key of required) {
|
|
20112
|
-
const present = key in obj;
|
|
20113
|
-
if (!present || obj[key] == null) {
|
|
20114
|
-
const fallback = getSchemaDefaultValue(props[key]);
|
|
20115
|
-
if (fallback !== void 0) {
|
|
20116
|
-
obj[key] = fallback;
|
|
20117
|
-
continue;
|
|
20118
|
-
}
|
|
20119
|
-
pushValidationIssue(ctx, component, `${path2}/${key}`, { code: present ? "null-required" : "missing-required" });
|
|
20120
|
-
invalid = true;
|
|
20121
|
-
}
|
|
20122
|
-
}
|
|
20123
|
-
for (const key of Object.keys(props)) if (key in obj) {
|
|
20124
|
-
const sub = props[key];
|
|
20125
|
-
if (validateSchemaValue(obj[key], sub, component, `${path2}/${key}`, ctx)) {
|
|
20126
|
-
if (resolveInvalidValue(obj, key, required.includes(key), getSchemaDefaultValue(sub))) invalid = true;
|
|
20127
|
-
}
|
|
20128
|
-
}
|
|
20129
|
-
return invalid;
|
|
20130
|
-
}
|
|
20131
|
-
function validateArrayValue(value, s2, component, path2, ctx) {
|
|
20132
|
-
if (!Array.isArray(value)) {
|
|
20133
|
-
pushValidationIssue(ctx, component, path2, {
|
|
20134
|
-
code: "type-mismatch",
|
|
20135
|
-
expected: "array",
|
|
20136
|
-
actual: jsType(value)
|
|
20137
|
-
});
|
|
20138
|
-
return true;
|
|
20139
|
-
}
|
|
20140
|
-
const items = s2["items"];
|
|
20141
|
-
if (!items || typeof items !== "object" || Array.isArray(items)) return false;
|
|
20142
|
-
let invalid;
|
|
20143
|
-
for (let i = 0; i < value.length; i++) if (validateSchemaValue(value[i], items, component, `${path2}/${i}`, ctx)) (invalid ??= []).push(i);
|
|
20144
|
-
if (invalid) for (let i = invalid.length - 1; i >= 0; i--) value.splice(invalid[i], 1);
|
|
20145
|
-
return false;
|
|
20146
|
-
}
|
|
20147
|
-
function validateLeafValue(value, s2, component, path2, ctx) {
|
|
20148
|
-
const leaf = getScalarTypeInfo(s2);
|
|
20149
|
-
if (leaf.expectedType == null && leaf.enumValues == null) return false;
|
|
20150
|
-
if (leaf.enumValues && ctx.partial) return false;
|
|
20151
|
-
const mismatch = checkTypeMismatch(value, leaf);
|
|
20152
|
-
if (mismatch) {
|
|
20153
|
-
pushValidationIssue(ctx, component, path2, {
|
|
20154
|
-
code: "type-mismatch",
|
|
20155
|
-
...mismatch
|
|
20156
|
-
});
|
|
20157
|
-
return true;
|
|
20158
|
-
}
|
|
20159
|
-
return false;
|
|
20160
|
-
}
|
|
20161
|
-
function validateSchemaValue(value, schema, component, path2, ctx) {
|
|
20162
|
-
if (!schema || typeof schema !== "object" || Array.isArray(schema)) return false;
|
|
20163
|
-
const s2 = schema;
|
|
20164
|
-
if (value == null) return false;
|
|
20165
|
-
if (isASTNode(value)) return false;
|
|
20166
|
-
if (isElementNode(value)) return validateElementPosition(value, s2, component, path2, ctx);
|
|
20167
|
-
if (isCompositeSchema(s2)) return false;
|
|
20168
|
-
const type = s2["type"];
|
|
20169
|
-
if (type === "object") return validateObjectValue(value, s2, component, path2, ctx);
|
|
20170
|
-
if (type === "array") return validateArrayValue(value, s2, component, path2, ctx);
|
|
20171
|
-
return validateLeafValue(value, s2, component, path2, ctx);
|
|
20172
|
-
}
|
|
20173
|
-
function containsDynamicValue(v2) {
|
|
20174
|
-
if (v2 == null || typeof v2 !== "object") return false;
|
|
20175
|
-
if (isASTNode(v2)) return true;
|
|
20176
|
-
if (Array.isArray(v2)) return v2.some(containsDynamicValue);
|
|
20177
|
-
if (isElementNode(v2)) return Object.values(v2.props).some(containsDynamicValue);
|
|
20178
|
-
return Object.values(v2).some(containsDynamicValue);
|
|
20179
|
-
}
|
|
20180
|
-
function resolveRef(name, ctx, mode) {
|
|
20181
|
-
if (ctx.visited.has(name)) {
|
|
20182
|
-
ctx.unres.push(name);
|
|
20183
|
-
return mode === "expr" ? {
|
|
20184
|
-
k: "Ph",
|
|
20185
|
-
n: name
|
|
20186
|
-
} : null;
|
|
20187
|
-
}
|
|
20188
|
-
if (!ctx.syms.has(name)) {
|
|
20189
|
-
ctx.unres.push(name);
|
|
20190
|
-
return mode === "expr" ? {
|
|
20191
|
-
k: "Ph",
|
|
20192
|
-
n: name
|
|
20193
|
-
} : null;
|
|
20194
|
-
}
|
|
20195
|
-
const target = ctx.syms.get(name);
|
|
20196
|
-
ctx.unreached?.delete(name);
|
|
20197
|
-
if (target.k === "Comp" && isReservedCall(target.name)) return {
|
|
20198
|
-
k: "RuntimeRef",
|
|
20199
|
-
n: name,
|
|
20200
|
-
refType: target.name === RESERVED_CALLS.Mutation ? "mutation" : "query"
|
|
20201
|
-
};
|
|
20202
|
-
ctx.visited.add(name);
|
|
20203
|
-
const prevStatementId = ctx.currentStatementId;
|
|
20204
|
-
ctx.currentStatementId = name;
|
|
20205
|
-
try {
|
|
20206
|
-
const result = mode === "value" ? materializeValue(target, ctx) : materializeExpr(target, ctx);
|
|
20207
|
-
if (mode === "value" && isElementNode(result)) result.statementId = name;
|
|
20208
|
-
return result;
|
|
20209
|
-
} finally {
|
|
20210
|
-
ctx.currentStatementId = prevStatementId;
|
|
20211
|
-
ctx.visited.delete(name);
|
|
20212
|
-
}
|
|
20213
|
-
}
|
|
20214
|
-
function materializeLazyBuiltin(node, ctx, scopedRefs) {
|
|
20215
|
-
if (!LAZY_BUILTINS.has(node.name) || node.args.length < 3) return null;
|
|
20216
|
-
const varArg = node.args[1];
|
|
20217
|
-
const varName = varArg.k === "Ref" ? varArg.n : varArg.k === "Str" ? varArg.v : null;
|
|
20218
|
-
if (!varName) return null;
|
|
20219
|
-
const nextScopedRefs = new Set(scopedRefs);
|
|
20220
|
-
nextScopedRefs.add(varName);
|
|
20221
|
-
const recursedArgs = node.args.map((a2, i) => i === 1 ? a2 : materializeExprInternal(a2, ctx, nextScopedRefs));
|
|
20222
|
-
return {
|
|
20223
|
-
...node,
|
|
20224
|
-
args: recursedArgs
|
|
20225
|
-
};
|
|
20226
|
-
}
|
|
20227
|
-
function materializeExprInternal(node, ctx, scopedRefs) {
|
|
20228
|
-
switch (node.k) {
|
|
20229
|
-
case "Ref":
|
|
20230
|
-
return scopedRefs.has(node.n) ? node : resolveRef(node.n, ctx, "expr");
|
|
20231
|
-
case "Ph":
|
|
20232
|
-
return node;
|
|
20233
|
-
case "Comp": {
|
|
20234
|
-
const lazy = materializeLazyBuiltin(node, ctx, scopedRefs);
|
|
20235
|
-
if (lazy) return lazy;
|
|
20236
|
-
const recursedArgs = node.args.map((a2) => materializeExprInternal(a2, ctx, scopedRefs));
|
|
20237
|
-
if (isBuiltin(node.name) || isReservedCall(node.name)) return {
|
|
20238
|
-
...node,
|
|
20239
|
-
args: recursedArgs
|
|
20240
|
-
};
|
|
20241
|
-
const def = ctx.cat?.get(node.name);
|
|
20242
|
-
if (def) {
|
|
20243
|
-
const mappedProps = {};
|
|
20244
|
-
for (let i = 0; i < def.params.length && i < recursedArgs.length; i++) mappedProps[def.params[i].name] = recursedArgs[i];
|
|
20245
|
-
return {
|
|
20246
|
-
...node,
|
|
20247
|
-
args: recursedArgs,
|
|
20248
|
-
mappedProps
|
|
20249
|
-
};
|
|
20250
|
-
}
|
|
20251
|
-
pushValidationIssue(ctx, node.name, "", {
|
|
20252
|
-
code: "unknown-component",
|
|
20253
|
-
available: ctx.cat && [...ctx.cat.keys()]
|
|
20254
|
-
});
|
|
20255
|
-
return {
|
|
20256
|
-
...node,
|
|
20257
|
-
args: recursedArgs
|
|
20258
|
-
};
|
|
20259
|
-
}
|
|
20260
|
-
case "Arr":
|
|
20261
|
-
return {
|
|
20262
|
-
...node,
|
|
20263
|
-
els: node.els.map((e) => materializeExprInternal(e, ctx, scopedRefs))
|
|
20264
|
-
};
|
|
20265
|
-
case "Obj":
|
|
20266
|
-
return {
|
|
20267
|
-
...node,
|
|
20268
|
-
entries: node.entries.map(([k2, v2]) => [k2, materializeExprInternal(v2, ctx, scopedRefs)])
|
|
20269
|
-
};
|
|
20270
|
-
case "BinOp":
|
|
20271
|
-
return {
|
|
20272
|
-
...node,
|
|
20273
|
-
left: materializeExprInternal(node.left, ctx, scopedRefs),
|
|
20274
|
-
right: materializeExprInternal(node.right, ctx, scopedRefs)
|
|
20275
|
-
};
|
|
20276
|
-
case "UnaryOp":
|
|
20277
|
-
return {
|
|
20278
|
-
...node,
|
|
20279
|
-
operand: materializeExprInternal(node.operand, ctx, scopedRefs)
|
|
20280
|
-
};
|
|
20281
|
-
case "Ternary":
|
|
20282
|
-
return {
|
|
20283
|
-
...node,
|
|
20284
|
-
cond: materializeExprInternal(node.cond, ctx, scopedRefs),
|
|
20285
|
-
then: materializeExprInternal(node.then, ctx, scopedRefs),
|
|
20286
|
-
else: materializeExprInternal(node.else, ctx, scopedRefs)
|
|
20287
|
-
};
|
|
20288
|
-
case "Member":
|
|
20289
|
-
return {
|
|
20290
|
-
...node,
|
|
20291
|
-
obj: materializeExprInternal(node.obj, ctx, scopedRefs)
|
|
20292
|
-
};
|
|
20293
|
-
case "Index":
|
|
20294
|
-
return {
|
|
20295
|
-
...node,
|
|
20296
|
-
obj: materializeExprInternal(node.obj, ctx, scopedRefs),
|
|
20297
|
-
index: materializeExprInternal(node.index, ctx, scopedRefs)
|
|
20298
|
-
};
|
|
20299
|
-
case "Assign":
|
|
20300
|
-
return {
|
|
20301
|
-
...node,
|
|
20302
|
-
value: materializeExprInternal(node.value, ctx, scopedRefs)
|
|
20303
|
-
};
|
|
20304
|
-
default:
|
|
20305
|
-
return node;
|
|
20306
|
-
}
|
|
20307
|
-
}
|
|
20308
|
-
function materializeExpr(node, ctx) {
|
|
20309
|
-
return materializeExprInternal(node, ctx, /* @__PURE__ */ new Set());
|
|
20310
|
-
}
|
|
20311
|
-
function materializeValue(node, ctx) {
|
|
20312
|
-
switch (node.k) {
|
|
20313
|
-
case "Ref":
|
|
20314
|
-
return resolveRef(node.n, ctx, "value");
|
|
20315
|
-
case "Str":
|
|
20316
|
-
return node.v;
|
|
20317
|
-
case "Num":
|
|
20318
|
-
return node.v;
|
|
20319
|
-
case "Bool":
|
|
20320
|
-
return node.v;
|
|
20321
|
-
case "Null":
|
|
20322
|
-
return null;
|
|
20323
|
-
case "Ph":
|
|
20324
|
-
return null;
|
|
20325
|
-
case "Arr": {
|
|
20326
|
-
const items = [];
|
|
20327
|
-
for (const e of node.els) {
|
|
20328
|
-
if (e.k === "Ph") continue;
|
|
20329
|
-
const value = materializeValue(e, ctx);
|
|
20330
|
-
if (value === null && (e.k === "Comp" || e.k === "Ref")) continue;
|
|
20331
|
-
items.push(value);
|
|
20332
|
-
}
|
|
20333
|
-
return items;
|
|
20334
|
-
}
|
|
20335
|
-
case "Obj": {
|
|
20336
|
-
const o = {};
|
|
20337
|
-
for (const [k2, v2] of node.entries) o[k2] = materializeValue(v2, ctx);
|
|
20338
|
-
return o;
|
|
20339
|
-
}
|
|
20340
|
-
case "Comp": {
|
|
20341
|
-
const { name, args } = node;
|
|
20342
|
-
if (isBuiltin(name)) {
|
|
20343
|
-
const lazy = materializeLazyBuiltin(node, ctx, /* @__PURE__ */ new Set());
|
|
20344
|
-
if (lazy) return lazy;
|
|
20345
|
-
return {
|
|
20346
|
-
...node,
|
|
20347
|
-
args: args.map((a2) => materializeExpr(a2, ctx))
|
|
20348
|
-
};
|
|
20349
|
-
}
|
|
20350
|
-
if (isReservedCall(name)) {
|
|
20351
|
-
pushValidationIssue(ctx, name, "", { code: "inline-reserved" });
|
|
20352
|
-
return null;
|
|
20353
|
-
}
|
|
20354
|
-
const def = ctx.cat?.get(name);
|
|
20355
|
-
const props = {};
|
|
20356
|
-
if (def) {
|
|
20357
|
-
let dropComponent = false;
|
|
20358
|
-
for (let i = 0; i < def.params.length && i < args.length; i++) {
|
|
20359
|
-
const param = def.params[i];
|
|
20360
|
-
const value = materializeValue(args[i], ctx);
|
|
20361
|
-
props[param.name] = value;
|
|
20362
|
-
if (param.schema !== void 0 && validateSchemaValue(value, param.schema, name, `/${param.name}`, ctx)) {
|
|
20363
|
-
if (resolveInvalidValue(props, param.name, param.required, param.defaultValue)) dropComponent = true;
|
|
20364
|
-
}
|
|
20365
|
-
}
|
|
20366
|
-
if (args.length > def.params.length) pushValidationIssue(ctx, name, "", {
|
|
20367
|
-
code: "excess-args",
|
|
20368
|
-
declared: def.params.length,
|
|
20369
|
-
got: args.length
|
|
20370
|
-
});
|
|
20371
|
-
const missingRequired = def.params.filter((p) => p.required && (!(p.name in props) || props[p.name] === null));
|
|
20372
|
-
if (missingRequired.length) {
|
|
20373
|
-
const stillInvalid = missingRequired.filter((p) => {
|
|
20374
|
-
if (p.defaultValue !== void 0) {
|
|
20375
|
-
props[p.name] = p.defaultValue;
|
|
20376
|
-
return false;
|
|
20377
|
-
}
|
|
20378
|
-
return true;
|
|
20379
|
-
});
|
|
20380
|
-
if (stillInvalid.length) {
|
|
20381
|
-
for (const p of stillInvalid) pushValidationIssue(ctx, name, `/${p.name}`, {
|
|
20382
|
-
code: p.name in props ? "null-required" : "missing-required",
|
|
20383
|
-
signature: buildParamsSignature(name, def.params)
|
|
20384
|
-
});
|
|
20385
|
-
return null;
|
|
20386
|
-
}
|
|
20387
|
-
}
|
|
20388
|
-
if (dropComponent) return null;
|
|
20389
|
-
} else if (!isBuiltin(name) && !isReservedCall(name)) {
|
|
20390
|
-
pushValidationIssue(ctx, name, "", {
|
|
20391
|
-
code: "unknown-component",
|
|
20392
|
-
available: ctx.cat && [...ctx.cat.keys()]
|
|
20393
|
-
});
|
|
20394
|
-
return null;
|
|
20395
|
-
}
|
|
20396
|
-
const hasDynamicProps = Object.values(props).some((v2) => containsDynamicValue(v2));
|
|
20397
|
-
return {
|
|
20398
|
-
type: "element",
|
|
20399
|
-
typeName: name,
|
|
20400
|
-
props,
|
|
20401
|
-
partial: ctx.partial,
|
|
20402
|
-
hasDynamicProps
|
|
20403
|
-
};
|
|
20404
|
-
}
|
|
20405
|
-
default:
|
|
20406
|
-
if (isRuntimeExpr(node)) return materializeExpr(node, ctx);
|
|
20407
|
-
return node;
|
|
20408
|
-
}
|
|
20409
|
-
}
|
|
20410
|
-
function autoClose(input) {
|
|
20411
|
-
const stack = [];
|
|
20412
|
-
let inStr = false;
|
|
20413
|
-
let esc = false;
|
|
20414
|
-
for (let i = 0; i < input.length; i++) {
|
|
20415
|
-
const c2 = input[i];
|
|
20416
|
-
if (esc) {
|
|
20417
|
-
esc = false;
|
|
20418
|
-
continue;
|
|
20419
|
-
}
|
|
20420
|
-
if (c2 === "\\" && inStr) {
|
|
20421
|
-
esc = true;
|
|
20422
|
-
continue;
|
|
20423
|
-
}
|
|
20424
|
-
if (inStr) {
|
|
20425
|
-
if (c2 === inStr) inStr = false;
|
|
20426
|
-
continue;
|
|
20427
|
-
}
|
|
20428
|
-
if (c2 === '"' || c2 === "'") {
|
|
20429
|
-
inStr = c2;
|
|
20430
|
-
continue;
|
|
20431
|
-
}
|
|
20432
|
-
if (c2 === "(" || c2 === "[" || c2 === "{") stack.push(c2);
|
|
20433
|
-
else if (c2 === ")" && stack[stack.length - 1] === "(") stack.pop();
|
|
20434
|
-
else if (c2 === "]" && stack[stack.length - 1] === "[") stack.pop();
|
|
20435
|
-
else if (c2 === "}" && stack[stack.length - 1] === "{") stack.pop();
|
|
20436
|
-
}
|
|
20437
|
-
if (!(!!inStr || stack.length > 0)) return {
|
|
20438
|
-
text: input,
|
|
20439
|
-
wasIncomplete: false
|
|
20440
|
-
};
|
|
20441
|
-
let out = input;
|
|
20442
|
-
if (inStr) {
|
|
20443
|
-
if (esc) out += "\\";
|
|
20444
|
-
out += inStr;
|
|
20445
|
-
}
|
|
20446
|
-
for (let j2 = stack.length - 1; j2 >= 0; j2--) out += stack[j2] === "(" ? ")" : stack[j2] === "[" ? "]" : "}";
|
|
20447
|
-
return {
|
|
20448
|
-
text: out,
|
|
20449
|
-
wasIncomplete: true
|
|
20450
|
-
};
|
|
20451
|
-
}
|
|
20452
|
-
function split(tokens) {
|
|
20453
|
-
const stmts = [];
|
|
20454
|
-
let pos = 0;
|
|
20455
|
-
while (pos < tokens.length) {
|
|
20456
|
-
while (pos < tokens.length && tokens[pos].t === 0) pos++;
|
|
20457
|
-
if (pos >= tokens.length || tokens[pos].t === 13) break;
|
|
20458
|
-
const tok = tokens[pos];
|
|
20459
|
-
if (tok.t !== 16 && tok.t !== 17 && tok.t !== 18) {
|
|
20460
|
-
while (pos < tokens.length && tokens[pos].t !== 0 && tokens[pos].t !== 13) pos++;
|
|
20461
|
-
continue;
|
|
20462
|
-
}
|
|
20463
|
-
const id = tok.v;
|
|
20464
|
-
const idTokenType = tok.t;
|
|
20465
|
-
pos++;
|
|
20466
|
-
if (pos >= tokens.length || tokens[pos].t !== 9) {
|
|
20467
|
-
while (pos < tokens.length && tokens[pos].t !== 0 && tokens[pos].t !== 13) pos++;
|
|
20468
|
-
continue;
|
|
20469
|
-
}
|
|
20470
|
-
pos++;
|
|
20471
|
-
const expr = [];
|
|
20472
|
-
let depth = 0;
|
|
20473
|
-
let ternaryDepth = 0;
|
|
20474
|
-
while (pos < tokens.length && tokens[pos].t !== 13) {
|
|
20475
|
-
const tt = tokens[pos].t;
|
|
20476
|
-
if (tt === 0 && depth <= 0 && ternaryDepth <= 0) {
|
|
20477
|
-
let peek2 = pos + 1;
|
|
20478
|
-
while (peek2 < tokens.length && tokens[peek2].t === 0) peek2++;
|
|
20479
|
-
const nextT = peek2 < tokens.length ? tokens[peek2].t : 13;
|
|
20480
|
-
if (nextT === 34 || nextT === 8 && ternaryDepth > 0) {
|
|
20481
|
-
pos++;
|
|
20482
|
-
continue;
|
|
20483
|
-
}
|
|
20484
|
-
break;
|
|
20485
|
-
}
|
|
20486
|
-
if (tt === 0) {
|
|
20487
|
-
pos++;
|
|
20488
|
-
continue;
|
|
20489
|
-
}
|
|
20490
|
-
if (tt === 1 || tt === 3 || tt === 5) depth++;
|
|
20491
|
-
else if ((tt === 2 || tt === 4 || tt === 6) && depth > 0) depth--;
|
|
20492
|
-
else if (tt === 34 && depth === 0) ternaryDepth++;
|
|
20493
|
-
else if (tt === 8 && depth === 0 && ternaryDepth > 0) ternaryDepth--;
|
|
20494
|
-
expr.push(tokens[pos++]);
|
|
20495
|
-
}
|
|
20496
|
-
if (expr.length) stmts.push({
|
|
20497
|
-
id,
|
|
20498
|
-
idTokenType,
|
|
20499
|
-
tokens: expr
|
|
20500
|
-
});
|
|
20501
|
-
}
|
|
20502
|
-
return stmts;
|
|
20503
|
-
}
|
|
20504
|
-
function emptyResult(incomplete = true) {
|
|
20505
|
-
return {
|
|
20506
|
-
root: null,
|
|
20507
|
-
meta: {
|
|
20508
|
-
incomplete,
|
|
20509
|
-
unresolved: [],
|
|
20510
|
-
orphaned: [],
|
|
20511
|
-
statementCount: 0,
|
|
20512
|
-
errors: []
|
|
20513
|
-
},
|
|
20514
|
-
stateDeclarations: {},
|
|
20515
|
-
queryStatements: [],
|
|
20516
|
-
mutationStatements: []
|
|
20517
|
-
};
|
|
20518
|
-
}
|
|
20519
|
-
function collectQueryDeps(node) {
|
|
20520
|
-
if (!isASTNode(node)) return [];
|
|
20521
|
-
const refs = /* @__PURE__ */ new Set();
|
|
20522
|
-
walkAST(node, (current2) => {
|
|
20523
|
-
if (current2.k === "StateRef") refs.add(current2.n);
|
|
20524
|
-
});
|
|
20525
|
-
return [...refs];
|
|
20526
|
-
}
|
|
20527
|
-
function classifyStatement(raw, expr) {
|
|
20528
|
-
if (expr.k === "Comp" && expr.name === RESERVED_CALLS.Query) {
|
|
20529
|
-
const deps = collectQueryDeps(expr.args[1]);
|
|
20530
|
-
return {
|
|
20531
|
-
kind: "query",
|
|
20532
|
-
id: raw.id,
|
|
20533
|
-
call: {
|
|
20534
|
-
callee: RESERVED_CALLS.Query,
|
|
20535
|
-
args: expr.args
|
|
20536
|
-
},
|
|
20537
|
-
expr,
|
|
20538
|
-
deps: deps.length > 0 ? deps : void 0
|
|
20539
|
-
};
|
|
20540
|
-
}
|
|
20541
|
-
if (expr.k === "Comp" && expr.name === RESERVED_CALLS.Mutation) return {
|
|
20542
|
-
kind: "mutation",
|
|
20543
|
-
id: raw.id,
|
|
20544
|
-
call: {
|
|
20545
|
-
callee: RESERVED_CALLS.Mutation,
|
|
20546
|
-
args: expr.args
|
|
20547
|
-
},
|
|
20548
|
-
expr
|
|
20549
|
-
};
|
|
20550
|
-
if (raw.idTokenType === 18) return {
|
|
20551
|
-
kind: "state",
|
|
20552
|
-
id: raw.id,
|
|
20553
|
-
init: expr
|
|
20554
|
-
};
|
|
20555
|
-
return {
|
|
20556
|
-
kind: "value",
|
|
20557
|
-
id: raw.id,
|
|
20558
|
-
expr
|
|
20559
|
-
};
|
|
20560
|
-
}
|
|
20561
|
-
function extractStatements(stmts, ctx) {
|
|
20562
|
-
const stateDeclarations = {};
|
|
20563
|
-
const queryStatements = [];
|
|
20564
|
-
const mutationStatements = [];
|
|
20565
|
-
for (const stmt of stmts) switch (stmt.kind) {
|
|
20566
|
-
case "state":
|
|
20567
|
-
stateDeclarations[stmt.id] = materializeValue(stmt.init, ctx);
|
|
20568
|
-
break;
|
|
20569
|
-
case "query":
|
|
20570
|
-
queryStatements.push({
|
|
20571
|
-
statementId: stmt.id,
|
|
20572
|
-
toolAST: stmt.call.args[0] ?? null,
|
|
20573
|
-
argsAST: stmt.call.args[1] ?? null,
|
|
20574
|
-
defaultsAST: stmt.call.args[2] ?? null,
|
|
20575
|
-
refreshAST: stmt.call.args[3] ?? null,
|
|
20576
|
-
deps: stmt.deps,
|
|
20577
|
-
complete: true
|
|
20578
|
-
});
|
|
20579
|
-
break;
|
|
20580
|
-
case "mutation":
|
|
20581
|
-
mutationStatements.push({
|
|
20582
|
-
statementId: stmt.id,
|
|
20583
|
-
toolAST: stmt.call.args[0] ?? null,
|
|
20584
|
-
argsAST: stmt.call.args[1] ?? null
|
|
20585
|
-
});
|
|
20586
|
-
break;
|
|
20587
|
-
}
|
|
20588
|
-
for (const stmt of stmts) {
|
|
20589
|
-
const nodes = stmt.kind === "state" ? [stmt.init] : stmt.kind === "value" ? [stmt.expr] : stmt.kind === "query" || stmt.kind === "mutation" ? stmt.call.args : [];
|
|
20590
|
-
for (const node of nodes) for (const dep of collectQueryDeps(node)) if (!(dep in stateDeclarations)) stateDeclarations[dep] = null;
|
|
20591
|
-
}
|
|
20592
|
-
return {
|
|
20593
|
-
stateDeclarations,
|
|
20594
|
-
queryStatements,
|
|
20595
|
-
mutationStatements
|
|
20596
|
-
};
|
|
20597
|
-
}
|
|
20598
|
-
var DEFAULT_ROOT_STATEMENT_ID = "root";
|
|
20599
|
-
function isComponentStatement(stmt) {
|
|
20600
|
-
return stmt.kind === "value" && stmt.expr.k === "Comp" && !isBuiltin(stmt.expr.name) && stmt.expr.name !== RESERVED_CALLS.Query && stmt.expr.name !== RESERVED_CALLS.Mutation;
|
|
20601
|
-
}
|
|
20602
|
-
function pickEntryId(stmtMap, typedStmts, firstId, rootName) {
|
|
20603
|
-
if (stmtMap.has(DEFAULT_ROOT_STATEMENT_ID)) return DEFAULT_ROOT_STATEMENT_ID;
|
|
20604
|
-
if (rootName && stmtMap.has(rootName)) return rootName;
|
|
20605
|
-
const preferredComponent = rootName ? typedStmts.find((stmt) => isComponentStatement(stmt) && stmt.expr.name === rootName) : void 0;
|
|
20606
|
-
if (preferredComponent) return preferredComponent.id;
|
|
20607
|
-
return typedStmts.find(isComponentStatement)?.id ?? firstId;
|
|
20608
|
-
}
|
|
20609
|
-
function buildResult(stmtMap, typedStmts, firstId, wasIncomplete, stmtCount, cat, rootName) {
|
|
20610
|
-
const entryId = pickEntryId(stmtMap, typedStmts, firstId, rootName);
|
|
20611
|
-
if (!stmtMap.has(entryId)) return emptyResult(wasIncomplete);
|
|
20612
|
-
const syms = /* @__PURE__ */ new Map();
|
|
20613
|
-
for (const [id, stmt] of stmtMap) syms.set(id, stmt.kind === "state" ? stmt.init : stmt.expr);
|
|
20614
|
-
const unres = [];
|
|
20615
|
-
const errors = [];
|
|
20616
|
-
const unreached = /* @__PURE__ */ new Set();
|
|
20617
|
-
for (const [id, stmt] of stmtMap) {
|
|
20618
|
-
if (id === entryId) continue;
|
|
20619
|
-
if (stmt.kind === "state" || stmt.kind === "query" || stmt.kind === "mutation") continue;
|
|
20620
|
-
unreached.add(id);
|
|
20621
|
-
}
|
|
20622
|
-
const ctx = {
|
|
20623
|
-
syms,
|
|
20624
|
-
cat,
|
|
20625
|
-
errors,
|
|
20626
|
-
unres,
|
|
20627
|
-
visited: /* @__PURE__ */ new Set(),
|
|
20628
|
-
partial: wasIncomplete,
|
|
20629
|
-
currentStatementId: entryId,
|
|
20630
|
-
unreached
|
|
20631
|
-
};
|
|
20632
|
-
const materialized = materializeValue(syms.get(entryId), ctx);
|
|
20633
|
-
const root2 = isElementNode(materialized) ? materialized : null;
|
|
20634
|
-
if (root2) root2.statementId = entryId;
|
|
20635
|
-
const { stateDeclarations, queryStatements, mutationStatements } = extractStatements(typedStmts, ctx);
|
|
20636
|
-
return {
|
|
20637
|
-
root: root2,
|
|
20638
|
-
meta: {
|
|
20639
|
-
incomplete: wasIncomplete,
|
|
20640
|
-
unresolved: unres,
|
|
20641
|
-
orphaned: [...unreached],
|
|
20642
|
-
statementCount: stmtCount,
|
|
20643
|
-
errors
|
|
20644
|
-
},
|
|
20645
|
-
stateDeclarations,
|
|
20646
|
-
queryStatements,
|
|
20647
|
-
mutationStatements
|
|
20648
|
-
};
|
|
20649
|
-
}
|
|
20650
|
-
function skipString(input, start) {
|
|
20651
|
-
if (input[start] !== '"') return start;
|
|
20652
|
-
let i = start + 1;
|
|
20653
|
-
while (i < input.length) {
|
|
20654
|
-
const c2 = input[i];
|
|
20655
|
-
if (c2 === "\\") i += 2;
|
|
20656
|
-
else if (c2 === '"') return i + 1;
|
|
20657
|
-
else i++;
|
|
20658
|
-
}
|
|
20659
|
-
return i;
|
|
20660
|
-
}
|
|
20661
|
-
function stripFences(input) {
|
|
20662
|
-
const blocks = [];
|
|
20663
|
-
let i = 0;
|
|
20664
|
-
while (i < input.length) {
|
|
20665
|
-
let fenceStart = -1;
|
|
20666
|
-
while (i < input.length) {
|
|
20667
|
-
const nextI = skipString(input, i);
|
|
20668
|
-
if (nextI > i) {
|
|
20669
|
-
i = nextI;
|
|
20670
|
-
continue;
|
|
20671
|
-
}
|
|
20672
|
-
if (input[i] === "`" && i + 1 < input.length && input[i + 1] === "`" && i + 2 < input.length && input[i + 2] === "`") {
|
|
20673
|
-
fenceStart = i;
|
|
20674
|
-
break;
|
|
20675
|
-
}
|
|
20676
|
-
i++;
|
|
20677
|
-
}
|
|
20678
|
-
if (fenceStart === -1) break;
|
|
20679
|
-
let j2 = fenceStart + 3;
|
|
20680
|
-
while (j2 < input.length && input[j2] !== "\n") j2++;
|
|
20681
|
-
if (j2 >= input.length) {
|
|
20682
|
-
blocks.push(input.slice(fenceStart + 3).replace(/^[^\n]*\n?/, ""));
|
|
20683
|
-
i = input.length;
|
|
20684
|
-
break;
|
|
20685
|
-
}
|
|
20686
|
-
j2++;
|
|
20687
|
-
let closePos = -1;
|
|
20688
|
-
let k2 = j2;
|
|
20689
|
-
while (k2 < input.length) {
|
|
20690
|
-
const nextK = skipString(input, k2);
|
|
20691
|
-
if (nextK > k2) {
|
|
20692
|
-
k2 = nextK;
|
|
20693
|
-
continue;
|
|
20694
|
-
}
|
|
20695
|
-
if (input[k2] === "`" && k2 + 1 < input.length && input[k2 + 1] === "`" && k2 + 2 < input.length && input[k2 + 2] === "`") {
|
|
20696
|
-
closePos = k2;
|
|
20697
|
-
break;
|
|
20698
|
-
}
|
|
20699
|
-
k2++;
|
|
20700
|
-
}
|
|
20701
|
-
if (closePos !== -1) {
|
|
20702
|
-
blocks.push(input.slice(j2, closePos));
|
|
20703
|
-
i = closePos + 3;
|
|
20704
|
-
} else {
|
|
20705
|
-
blocks.push(input.slice(j2));
|
|
20706
|
-
i = input.length;
|
|
20707
|
-
}
|
|
20708
|
-
}
|
|
20709
|
-
if (blocks.length > 0) return blocks.join("\n");
|
|
20710
|
-
if (input.startsWith("```")) {
|
|
20711
|
-
let j2 = 3;
|
|
20712
|
-
while (j2 < input.length && input[j2] !== "\n") j2++;
|
|
20713
|
-
const start = j2 < input.length ? j2 + 1 : 3;
|
|
20714
|
-
const body = input.slice(start);
|
|
20715
|
-
const trailingFence = body.lastIndexOf("```");
|
|
20716
|
-
if (trailingFence !== -1) return body.slice(0, trailingFence);
|
|
20717
|
-
return body;
|
|
20718
|
-
}
|
|
20719
|
-
return input;
|
|
20720
|
-
}
|
|
20721
|
-
function stripComments(input) {
|
|
20722
|
-
let inStr = false;
|
|
20723
|
-
return input.split("\n").map((line) => {
|
|
20724
|
-
for (let i = 0; i < line.length; i++) {
|
|
20725
|
-
const c2 = line[i];
|
|
20726
|
-
if (inStr) {
|
|
20727
|
-
if (c2 === "\\" && i + 1 < line.length) {
|
|
20728
|
-
i++;
|
|
20729
|
-
continue;
|
|
20730
|
-
}
|
|
20731
|
-
if (c2 === inStr) inStr = false;
|
|
20732
|
-
continue;
|
|
20733
|
-
}
|
|
20734
|
-
if (c2 === '"' || c2 === "'") {
|
|
20735
|
-
inStr = c2;
|
|
20736
|
-
continue;
|
|
20737
|
-
}
|
|
20738
|
-
if (c2 === "/" && line[i + 1] === "/") return line.substring(0, i).trimEnd();
|
|
20739
|
-
if (c2 === "#") return line.substring(0, i).trimEnd();
|
|
20740
|
-
}
|
|
20741
|
-
return line;
|
|
20742
|
-
}).join("\n");
|
|
20743
|
-
}
|
|
20744
|
-
function preprocess(input) {
|
|
20745
|
-
return stripComments(stripFences(input.trim())).trim();
|
|
20746
|
-
}
|
|
20747
|
-
function createStreamParser(cat, rootName) {
|
|
20748
|
-
let buf = "";
|
|
20749
|
-
let cleaned = "";
|
|
20750
|
-
let completedEnd = 0;
|
|
20751
|
-
const completedStmtMap = /* @__PURE__ */ new Map();
|
|
20752
|
-
let completedCount = 0;
|
|
20753
|
-
let firstId = "";
|
|
20754
|
-
function addStmt(text) {
|
|
20755
|
-
const t = text.trim();
|
|
20756
|
-
if (!t) return;
|
|
20757
|
-
for (const s2 of split(tokenize(t))) {
|
|
20758
|
-
const stmt = classifyStatement(s2, parseExpression(s2.tokens));
|
|
20759
|
-
completedStmtMap.set(s2.id, stmt);
|
|
20760
|
-
completedCount++;
|
|
20761
|
-
if (!firstId) firstId = s2.id;
|
|
20762
|
-
}
|
|
20763
|
-
}
|
|
20764
|
-
function refreshCleaned() {
|
|
20765
|
-
const next = preprocess(buf);
|
|
20766
|
-
if (!next.startsWith(cleaned.slice(0, completedEnd))) {
|
|
20767
|
-
completedEnd = 0;
|
|
20768
|
-
completedStmtMap.clear();
|
|
20769
|
-
completedCount = 0;
|
|
20770
|
-
firstId = "";
|
|
20771
|
-
}
|
|
20772
|
-
cleaned = next;
|
|
20773
|
-
}
|
|
20774
|
-
function scanNewCompleted() {
|
|
20775
|
-
let depth = 0, ternaryDepth = 0, inStr = false, esc = false;
|
|
20776
|
-
let stmtStart = completedEnd;
|
|
20777
|
-
for (let i = completedEnd; i < cleaned.length; i++) {
|
|
20778
|
-
const c2 = cleaned[i];
|
|
20779
|
-
if (esc) {
|
|
20780
|
-
esc = false;
|
|
20781
|
-
continue;
|
|
20782
|
-
}
|
|
20783
|
-
if (c2 === "\\" && inStr) {
|
|
20784
|
-
esc = true;
|
|
20785
|
-
continue;
|
|
20786
|
-
}
|
|
20787
|
-
if (inStr) {
|
|
20788
|
-
if (c2 === inStr) inStr = false;
|
|
20789
|
-
continue;
|
|
20790
|
-
}
|
|
20791
|
-
if (c2 === '"' || c2 === "'") {
|
|
20792
|
-
inStr = c2;
|
|
20793
|
-
continue;
|
|
20794
|
-
}
|
|
20795
|
-
if (c2 === "(" || c2 === "[" || c2 === "{") depth++;
|
|
20796
|
-
else if (c2 === ")" || c2 === "]" || c2 === "}") depth = Math.max(0, depth - 1);
|
|
20797
|
-
else if (c2 === "?" && depth === 0) ternaryDepth++;
|
|
20798
|
-
else if (c2 === ":" && depth === 0 && ternaryDepth > 0) ternaryDepth--;
|
|
20799
|
-
else if (c2 === "\n" && depth <= 0 && ternaryDepth <= 0) {
|
|
20800
|
-
let peek2 = i + 1;
|
|
20801
|
-
while (peek2 < cleaned.length && (cleaned[peek2] === " " || cleaned[peek2] === " " || cleaned[peek2] === "\r" || cleaned[peek2] === "\n")) peek2++;
|
|
20802
|
-
if (peek2 < cleaned.length && (cleaned[peek2] === "?" || cleaned[peek2] === ":" && ternaryDepth > 0)) continue;
|
|
20803
|
-
const t = cleaned.slice(stmtStart, i).trim();
|
|
20804
|
-
if (t) addStmt(t);
|
|
20805
|
-
stmtStart = i + 1;
|
|
20806
|
-
completedEnd = i + 1;
|
|
20807
|
-
}
|
|
20808
|
-
}
|
|
20809
|
-
return stmtStart;
|
|
20810
|
-
}
|
|
20811
|
-
function currentResult() {
|
|
20812
|
-
refreshCleaned();
|
|
20813
|
-
const pendingStart = scanNewCompleted();
|
|
20814
|
-
const pendingText = cleaned.slice(pendingStart).trim();
|
|
20815
|
-
if (!pendingText) {
|
|
20816
|
-
if (completedCount === 0) return emptyResult();
|
|
20817
|
-
return buildResult(completedStmtMap, [...completedStmtMap.values()], firstId, false, completedCount, cat, rootName);
|
|
20818
|
-
}
|
|
20819
|
-
const { text: closed, wasIncomplete } = autoClose(pendingText);
|
|
20820
|
-
const stmts = split(tokenize(closed));
|
|
20821
|
-
if (!stmts.length) {
|
|
20822
|
-
if (completedCount === 0) return emptyResult(wasIncomplete);
|
|
20823
|
-
return buildResult(completedStmtMap, [...completedStmtMap.values()], firstId, wasIncomplete, completedCount, cat, rootName);
|
|
20824
|
-
}
|
|
20825
|
-
const allStmtMap = new Map(completedStmtMap);
|
|
20826
|
-
for (const s2 of stmts) {
|
|
20827
|
-
if (completedStmtMap.has(s2.id)) continue;
|
|
20828
|
-
const stmt = classifyStatement(s2, parseExpression(s2.tokens));
|
|
20829
|
-
allStmtMap.set(s2.id, stmt);
|
|
20830
|
-
}
|
|
20831
|
-
return buildResult(allStmtMap, [...allStmtMap.values()], firstId || stmts[0].id, wasIncomplete, completedCount + stmts.length, cat, rootName);
|
|
20832
|
-
}
|
|
20833
|
-
function reset() {
|
|
20834
|
-
buf = "";
|
|
20835
|
-
cleaned = "";
|
|
20836
|
-
completedEnd = 0;
|
|
20837
|
-
completedStmtMap.clear();
|
|
20838
|
-
completedCount = 0;
|
|
20839
|
-
firstId = "";
|
|
20840
|
-
}
|
|
20841
|
-
return {
|
|
20842
|
-
push(chunk) {
|
|
20843
|
-
buf += chunk;
|
|
20844
|
-
return currentResult();
|
|
20845
|
-
},
|
|
20846
|
-
set(fullText) {
|
|
20847
|
-
if (fullText.length < buf.length || !fullText.startsWith(buf)) reset();
|
|
20848
|
-
const delta = fullText.slice(buf.length);
|
|
20849
|
-
if (delta) buf += delta;
|
|
20850
|
-
return currentResult();
|
|
20851
|
-
},
|
|
20852
|
-
getResult: currentResult
|
|
20853
|
-
};
|
|
20854
|
-
}
|
|
20855
|
-
function compileSchema(schema) {
|
|
20856
|
-
const map2 = /* @__PURE__ */ new Map();
|
|
20857
|
-
const defs = schema.$defs ?? {};
|
|
20858
|
-
for (const [name, def] of Object.entries(defs)) {
|
|
20859
|
-
const properties2 = def.properties ?? {};
|
|
20860
|
-
const required = def.required ?? [];
|
|
20861
|
-
const params = Object.keys(properties2).map((key) => ({
|
|
20862
|
-
name: key,
|
|
20863
|
-
required: required.includes(key),
|
|
20864
|
-
defaultValue: getSchemaDefaultValue(properties2[key]),
|
|
20865
|
-
schema: properties2[key]
|
|
20866
|
-
}));
|
|
20867
|
-
map2.set(name, { params });
|
|
20868
|
-
}
|
|
20869
|
-
return map2;
|
|
20870
|
-
}
|
|
20871
|
-
function createStreamingParser(schema, rootName) {
|
|
20872
|
-
return createStreamParser(compileSchema(schema), rootName);
|
|
20873
|
-
}
|
|
20874
|
-
function buildSignatureHint(componentName, schema) {
|
|
20875
|
-
if (!schema?.properties) return void 0;
|
|
20876
|
-
const required = new Set(schema.required ?? []);
|
|
20877
|
-
return `Signature: ${componentName}(${Object.keys(schema.properties).map((k2) => required.has(k2) ? `${k2}*` : k2).join(", ")}) \u2014 * marks required`;
|
|
20878
|
-
}
|
|
20879
|
-
function enrichErrors(validationErrors, schema, componentNames) {
|
|
20880
|
-
return validationErrors.map((ve) => {
|
|
20881
|
-
const error = {
|
|
20882
|
-
source: "parser",
|
|
20883
|
-
code: ve.code,
|
|
20884
|
-
message: ve.message,
|
|
20885
|
-
component: ve.component,
|
|
20886
|
-
path: ve.path || void 0,
|
|
20887
|
-
statementId: ve.statementId
|
|
20888
|
-
};
|
|
20889
|
-
if (ve.code === "unknown-component" && componentNames.length) error.hint = `Available components: ${componentNames.join(", ")}`;
|
|
20890
|
-
else if (ve.code === "missing-required" || ve.code === "null-required") error.hint = buildSignatureHint(ve.component, schema.$defs?.[ve.component]);
|
|
20891
|
-
else if (ve.code === "inline-reserved") error.hint = `Declare as a top-level statement: myVar = ${ve.component}(...)`;
|
|
20892
|
-
return error;
|
|
20893
|
-
});
|
|
20894
|
-
}
|
|
20895
|
-
function isReactiveAssign(value) {
|
|
20896
|
-
return typeof value === "object" && value !== null && value.__reactive === "assign";
|
|
20897
|
-
}
|
|
20898
|
-
function evaluate(node, context, schemaCtx) {
|
|
20899
|
-
switch (node.k) {
|
|
20900
|
-
case "Str":
|
|
20901
|
-
return node.v;
|
|
20902
|
-
case "Num":
|
|
20903
|
-
return node.v;
|
|
20904
|
-
case "Bool":
|
|
20905
|
-
return node.v;
|
|
20906
|
-
case "Null":
|
|
20907
|
-
return null;
|
|
20908
|
-
case "Ph":
|
|
20909
|
-
return null;
|
|
20910
|
-
case "StateRef":
|
|
20911
|
-
return context.extraScope?.[node.n] ?? context.getState(node.n);
|
|
20912
|
-
case "Ref":
|
|
20913
|
-
case "RuntimeRef":
|
|
20914
|
-
return context.resolveRef(node.n);
|
|
20915
|
-
case "Arr":
|
|
20916
|
-
return node.els.map((el) => evaluate(el, context));
|
|
20917
|
-
case "Obj":
|
|
20918
|
-
return Object.fromEntries(node.entries.map(([k2, v2]) => [k2, evaluate(v2, context)]));
|
|
20919
|
-
case "Comp": {
|
|
20920
|
-
if (LAZY_BUILTINS.has(node.name)) return evaluateLazyBuiltin(node.name, node.args, context, schemaCtx);
|
|
20921
|
-
const builtin = BUILTINS[node.name];
|
|
20922
|
-
if (builtin) {
|
|
20923
|
-
const args = node.args.map((a2) => evaluate(a2, context));
|
|
20924
|
-
return builtin.fn(...args);
|
|
20925
|
-
}
|
|
20926
|
-
if (ACTION_NAMES.has(node.name)) return evaluateActionCall(node.name, node.args, context);
|
|
20927
|
-
if (node.mappedProps) {
|
|
20928
|
-
const def = schemaCtx?.library.components[node.name];
|
|
20929
|
-
const props = {};
|
|
20930
|
-
for (const [key, val] of Object.entries(node.mappedProps)) {
|
|
20931
|
-
const propSchema = def?.props?.shape?.[key];
|
|
20932
|
-
if (val.k === "StateRef" && propSchema && isReactiveSchema(propSchema)) props[key] = {
|
|
20933
|
-
__reactive: "assign",
|
|
20934
|
-
target: val.n,
|
|
20935
|
-
expr: {
|
|
20936
|
-
k: "StateRef",
|
|
20937
|
-
n: "$value"
|
|
20938
|
-
}
|
|
20939
|
-
};
|
|
20940
|
-
else if (val.k === "StateRef") props[key] = schemaCtx ? context.getState(val.n) : val;
|
|
20941
|
-
else props[key] = evaluate(val, context, schemaCtx);
|
|
20942
|
-
}
|
|
20943
|
-
const result = {
|
|
20944
|
-
type: "element",
|
|
20945
|
-
typeName: node.name,
|
|
20946
|
-
props,
|
|
20947
|
-
partial: false,
|
|
20948
|
-
hasDynamicProps: true
|
|
20949
|
-
};
|
|
20950
|
-
if (schemaCtx) {
|
|
20951
|
-
for (const [key, val] of Object.entries(props)) if (isElementNode(val)) props[key] = evaluateElementInline(val, context, schemaCtx);
|
|
20952
|
-
else if (Array.isArray(val)) props[key] = val.map((item) => isElementNode(item) ? evaluateElementInline(item, context, schemaCtx) : item);
|
|
20953
|
-
}
|
|
20954
|
-
return result;
|
|
20955
|
-
}
|
|
20956
|
-
console.warn(`[openui] Unexpected unmapped Comp node: ${node.name}`);
|
|
20957
|
-
return null;
|
|
20958
|
-
}
|
|
20959
|
-
case "BinOp": {
|
|
20960
|
-
if (node.op === "&&") {
|
|
20961
|
-
const left2 = evaluate(node.left, context);
|
|
20962
|
-
return left2 ? evaluate(node.right, context) : left2;
|
|
20963
|
-
}
|
|
20964
|
-
if (node.op === "||") {
|
|
20965
|
-
const left2 = evaluate(node.left, context);
|
|
20966
|
-
return left2 ? left2 : evaluate(node.right, context);
|
|
20967
|
-
}
|
|
20968
|
-
const left = evaluate(node.left, context);
|
|
20969
|
-
const right = evaluate(node.right, context);
|
|
20970
|
-
switch (node.op) {
|
|
20971
|
-
case "+":
|
|
20972
|
-
if (typeof left === "string" || typeof right === "string") return String(left ?? "") + String(right ?? "");
|
|
20973
|
-
return toNumber$2(left) + toNumber$2(right);
|
|
20974
|
-
case "-":
|
|
20975
|
-
return toNumber$2(left) - toNumber$2(right);
|
|
20976
|
-
case "*":
|
|
20977
|
-
return toNumber$2(left) * toNumber$2(right);
|
|
20978
|
-
case "/":
|
|
20979
|
-
return toNumber$2(right) === 0 ? 0 : toNumber$2(left) / toNumber$2(right);
|
|
20980
|
-
case "%":
|
|
20981
|
-
return toNumber$2(right) === 0 ? 0 : toNumber$2(left) % toNumber$2(right);
|
|
20982
|
-
case "==":
|
|
20983
|
-
return left == right;
|
|
20984
|
-
case "!=":
|
|
20985
|
-
return left != right;
|
|
20986
|
-
case ">":
|
|
20987
|
-
return toNumber$2(left) > toNumber$2(right);
|
|
20988
|
-
case "<":
|
|
20989
|
-
return toNumber$2(left) < toNumber$2(right);
|
|
20990
|
-
case ">=":
|
|
20991
|
-
return toNumber$2(left) >= toNumber$2(right);
|
|
20992
|
-
case "<=":
|
|
20993
|
-
return toNumber$2(left) <= toNumber$2(right);
|
|
20994
|
-
default:
|
|
20995
|
-
return null;
|
|
20996
|
-
}
|
|
20997
|
-
}
|
|
20998
|
-
case "UnaryOp":
|
|
20999
|
-
if (node.op === "!") return !evaluate(node.operand, context);
|
|
21000
|
-
if (node.op === "-") return -toNumber$2(evaluate(node.operand, context));
|
|
21001
|
-
return null;
|
|
21002
|
-
case "Ternary":
|
|
21003
|
-
return evaluate(node.cond, context) ? evaluate(node.then, context) : evaluate(node.else, context);
|
|
21004
|
-
case "Member": {
|
|
21005
|
-
const obj = evaluate(node.obj, context);
|
|
21006
|
-
if (obj == null) return null;
|
|
21007
|
-
if (Array.isArray(obj)) {
|
|
21008
|
-
if (node.field === "length") return obj.length;
|
|
21009
|
-
return obj.map((item) => item?.[node.field] ?? null);
|
|
21010
|
-
}
|
|
21011
|
-
return obj[node.field];
|
|
21012
|
-
}
|
|
21013
|
-
case "Index": {
|
|
21014
|
-
const obj = evaluate(node.obj, context);
|
|
21015
|
-
const idx = evaluate(node.index, context);
|
|
21016
|
-
if (obj == null || idx == null) return null;
|
|
21017
|
-
if (Array.isArray(obj)) return obj[toNumber$2(idx)];
|
|
21018
|
-
return obj[String(idx)];
|
|
21019
|
-
}
|
|
21020
|
-
case "Assign":
|
|
21021
|
-
return {
|
|
21022
|
-
__reactive: "assign",
|
|
21023
|
-
target: node.target,
|
|
21024
|
-
expr: node.value
|
|
21025
|
-
};
|
|
21026
|
-
}
|
|
21027
|
-
}
|
|
21028
|
-
function evaluateElementInline(el, context, schemaCtx) {
|
|
21029
|
-
if (el.hasDynamicProps === false) return el;
|
|
21030
|
-
const def = schemaCtx.library.components[el.typeName];
|
|
21031
|
-
const evaluated = {};
|
|
21032
|
-
for (const [key, value] of Object.entries(el.props)) {
|
|
21033
|
-
const propSchema = def?.props?.shape?.[key];
|
|
21034
|
-
evaluated[key] = evaluatePropInline(value, context, schemaCtx, propSchema);
|
|
21035
|
-
}
|
|
21036
|
-
return {
|
|
21037
|
-
...el,
|
|
21038
|
-
props: evaluated
|
|
21039
|
-
};
|
|
21040
|
-
}
|
|
21041
|
-
function evaluatePropInline(value, context, schemaCtx, reactiveSchema) {
|
|
21042
|
-
return evaluatePropCore(value, context, schemaCtx, reactiveSchema, {
|
|
21043
|
-
recurseElement: (el) => evaluateElementInline(el, context, schemaCtx),
|
|
21044
|
-
recurse: (v2, rs) => evaluatePropInline(v2, context, schemaCtx, rs)
|
|
21045
|
-
});
|
|
21046
|
-
}
|
|
21047
|
-
function toLiteralAST(value) {
|
|
21048
|
-
if (value === null || value === void 0) return { k: "Null" };
|
|
21049
|
-
if (typeof value === "string") return {
|
|
21050
|
-
k: "Str",
|
|
21051
|
-
v: value
|
|
21052
|
-
};
|
|
21053
|
-
if (typeof value === "number") return {
|
|
21054
|
-
k: "Num",
|
|
21055
|
-
v: value
|
|
21056
|
-
};
|
|
21057
|
-
if (typeof value === "boolean") return {
|
|
21058
|
-
k: "Bool",
|
|
21059
|
-
v: value
|
|
21060
|
-
};
|
|
21061
|
-
if (Array.isArray(value)) return {
|
|
21062
|
-
k: "Arr",
|
|
21063
|
-
els: value.map(toLiteralAST)
|
|
21064
|
-
};
|
|
21065
|
-
if (typeof value === "object") return {
|
|
21066
|
-
k: "Obj",
|
|
21067
|
-
entries: Object.entries(value).map(([k2, v2]) => [k2, toLiteralAST(v2)])
|
|
21068
|
-
};
|
|
21069
|
-
return { k: "Null" };
|
|
21070
|
-
}
|
|
21071
|
-
function evaluateActionCall(name, args, context) {
|
|
21072
|
-
switch (name) {
|
|
21073
|
-
case "Action": {
|
|
21074
|
-
const stepsArg = args.length > 0 ? evaluate(args[0], context) : [];
|
|
21075
|
-
return { steps: (Array.isArray(stepsArg) ? stepsArg : []).filter((s2) => s2 != null && typeof s2 === "object" && "type" in s2) };
|
|
21076
|
-
}
|
|
21077
|
-
case "Run": {
|
|
21078
|
-
if (args.length === 0) return null;
|
|
21079
|
-
const refNode = args[0];
|
|
21080
|
-
if (refNode.k === "RuntimeRef") return {
|
|
21081
|
-
type: ACTION_STEPS.Run,
|
|
21082
|
-
statementId: refNode.n,
|
|
21083
|
-
refType: refNode.refType
|
|
21084
|
-
};
|
|
21085
|
-
return null;
|
|
21086
|
-
}
|
|
21087
|
-
case "ToAssistant": {
|
|
21088
|
-
const message2 = args.length > 0 ? String(evaluate(args[0], context) ?? "") : "";
|
|
21089
|
-
const ctx = args.length > 1 ? String(evaluate(args[1], context) ?? "") : void 0;
|
|
21090
|
-
return {
|
|
21091
|
-
type: ACTION_STEPS.ToAssistant,
|
|
21092
|
-
message: message2,
|
|
21093
|
-
context: ctx
|
|
21094
|
-
};
|
|
21095
|
-
}
|
|
21096
|
-
case "OpenUrl": {
|
|
21097
|
-
const url = args.length > 0 ? String(evaluate(args[0], context) ?? "") : "";
|
|
21098
|
-
return {
|
|
21099
|
-
type: ACTION_STEPS.OpenUrl,
|
|
21100
|
-
url
|
|
21101
|
-
};
|
|
21102
|
-
}
|
|
21103
|
-
case "Set": {
|
|
21104
|
-
if (args.length < 2) return null;
|
|
21105
|
-
const targetNode = args[0];
|
|
21106
|
-
if (targetNode.k !== "StateRef") return null;
|
|
21107
|
-
return {
|
|
21108
|
-
type: ACTION_STEPS.Set,
|
|
21109
|
-
target: targetNode.n,
|
|
21110
|
-
valueAST: args[1]
|
|
21111
|
-
};
|
|
21112
|
-
}
|
|
21113
|
-
case "Reset": {
|
|
21114
|
-
const targets = args.filter((a2) => a2.k === "StateRef").map((a2) => a2.n);
|
|
21115
|
-
if (targets.length === 0) return null;
|
|
21116
|
-
return {
|
|
21117
|
-
type: ACTION_STEPS.Reset,
|
|
21118
|
-
targets
|
|
21119
|
-
};
|
|
21120
|
-
}
|
|
21121
|
-
default:
|
|
21122
|
-
return null;
|
|
21123
|
-
}
|
|
21124
|
-
}
|
|
21125
|
-
function substituteRef(node, varName, value) {
|
|
21126
|
-
switch (node.k) {
|
|
21127
|
-
case "Ref":
|
|
21128
|
-
return node.n === varName ? toLiteralAST(value) : node;
|
|
21129
|
-
case "Member":
|
|
21130
|
-
if (isASTNode(node.obj)) {
|
|
21131
|
-
const subObj = substituteRef(node.obj, varName, value);
|
|
21132
|
-
if (subObj.k === "Obj") {
|
|
21133
|
-
const entry = subObj.entries.find(([k2]) => k2 === node.field);
|
|
21134
|
-
if (entry) return entry[1];
|
|
21135
|
-
}
|
|
21136
|
-
return {
|
|
21137
|
-
...node,
|
|
21138
|
-
obj: subObj
|
|
21139
|
-
};
|
|
21140
|
-
}
|
|
21141
|
-
return node;
|
|
21142
|
-
case "Index":
|
|
21143
|
-
return {
|
|
21144
|
-
...node,
|
|
21145
|
-
obj: isASTNode(node.obj) ? substituteRef(node.obj, varName, value) : node.obj,
|
|
21146
|
-
index: isASTNode(node.index) ? substituteRef(node.index, varName, value) : node.index
|
|
21147
|
-
};
|
|
21148
|
-
case "BinOp":
|
|
21149
|
-
return {
|
|
21150
|
-
...node,
|
|
21151
|
-
left: substituteRef(node.left, varName, value),
|
|
21152
|
-
right: substituteRef(node.right, varName, value)
|
|
21153
|
-
};
|
|
21154
|
-
case "UnaryOp":
|
|
21155
|
-
return {
|
|
21156
|
-
...node,
|
|
21157
|
-
operand: substituteRef(node.operand, varName, value)
|
|
21158
|
-
};
|
|
21159
|
-
case "Ternary":
|
|
21160
|
-
return {
|
|
21161
|
-
...node,
|
|
21162
|
-
cond: substituteRef(node.cond, varName, value),
|
|
21163
|
-
then: substituteRef(node.then, varName, value),
|
|
21164
|
-
else: substituteRef(node.else, varName, value)
|
|
21165
|
-
};
|
|
21166
|
-
case "Arr":
|
|
21167
|
-
return {
|
|
21168
|
-
...node,
|
|
21169
|
-
els: node.els.map((e) => substituteRef(e, varName, value))
|
|
21170
|
-
};
|
|
21171
|
-
case "Obj":
|
|
21172
|
-
return {
|
|
21173
|
-
...node,
|
|
21174
|
-
entries: node.entries.map(([k2, v2]) => [k2, substituteRef(v2, varName, value)])
|
|
21175
|
-
};
|
|
21176
|
-
case "Comp": {
|
|
21177
|
-
const result = {
|
|
21178
|
-
...node,
|
|
21179
|
-
args: node.args.map((a2) => substituteRef(a2, varName, value))
|
|
21180
|
-
};
|
|
21181
|
-
if (node.mappedProps) {
|
|
21182
|
-
const subProps = {};
|
|
21183
|
-
for (const [k2, v2] of Object.entries(node.mappedProps)) subProps[k2] = substituteRef(v2, varName, value);
|
|
21184
|
-
result.mappedProps = subProps;
|
|
21185
|
-
}
|
|
21186
|
-
return result;
|
|
21187
|
-
}
|
|
21188
|
-
case "Assign":
|
|
21189
|
-
return {
|
|
21190
|
-
...node,
|
|
21191
|
-
value: substituteRef(node.value, varName, value)
|
|
21192
|
-
};
|
|
21193
|
-
default:
|
|
21194
|
-
return node;
|
|
21195
|
-
}
|
|
21196
|
-
}
|
|
21197
|
-
function evaluateLazyBuiltin(name, args, context, schemaCtx) {
|
|
21198
|
-
if (name === "Each") {
|
|
21199
|
-
if (args.length < 3) return [];
|
|
21200
|
-
const arr = evaluate(args[0], context);
|
|
21201
|
-
if (!Array.isArray(arr)) return [];
|
|
21202
|
-
const varName = args[1].k === "Ref" ? args[1].n : args[1].k === "Str" ? args[1].v : null;
|
|
21203
|
-
if (!varName) return [];
|
|
21204
|
-
const template = args[2];
|
|
21205
|
-
return arr.map((item, _idx) => {
|
|
21206
|
-
const substituted = substituteRef(template, varName, item);
|
|
21207
|
-
const childCtx = {
|
|
21208
|
-
...context,
|
|
21209
|
-
resolveRef: (refName) => {
|
|
21210
|
-
if (refName === varName) return item;
|
|
21211
|
-
return context.resolveRef(refName);
|
|
21212
|
-
}
|
|
21213
|
-
};
|
|
21214
|
-
const result = evaluate(substituted, childCtx, schemaCtx);
|
|
21215
|
-
if (schemaCtx && isElementNode(result)) return evaluateElementInline(result, childCtx, schemaCtx);
|
|
21216
|
-
return result;
|
|
21217
|
-
});
|
|
21218
|
-
}
|
|
21219
|
-
return null;
|
|
21220
|
-
}
|
|
21221
|
-
function evaluatePropCore(value, context, schemaCtx, reactiveSchema, callbacks) {
|
|
21222
|
-
if (value == null) return value;
|
|
21223
|
-
if (typeof value !== "object") return value;
|
|
21224
|
-
if (isASTNode(value)) {
|
|
21225
|
-
if (value.k === "StateRef" && reactiveSchema && isReactiveSchema(reactiveSchema)) return {
|
|
21226
|
-
__reactive: "assign",
|
|
21227
|
-
target: value.n,
|
|
21228
|
-
expr: {
|
|
21229
|
-
k: "StateRef",
|
|
21230
|
-
n: "$value"
|
|
21231
|
-
}
|
|
21232
|
-
};
|
|
21233
|
-
const result = evaluate(value, context, schemaCtx);
|
|
21234
|
-
if (isElementNode(result)) return callbacks.recurseElement(result);
|
|
21235
|
-
if (Array.isArray(result)) return result.map((item) => isElementNode(item) ? callbacks.recurseElement(item) : item);
|
|
21236
|
-
if (isReactiveAssign(result) && !(reactiveSchema && isReactiveSchema(reactiveSchema))) return context.getState(result.target) ?? null;
|
|
21237
|
-
return result;
|
|
21238
|
-
}
|
|
21239
|
-
if (typeof value === "string" && reactiveSchema && isReactiveSchema(reactiveSchema)) return value;
|
|
21240
|
-
if (Array.isArray(value)) return value.map((v2) => callbacks.recurse(v2, reactiveSchema));
|
|
21241
|
-
if (isElementNode(value)) return callbacks.recurseElement(value);
|
|
21242
|
-
const obj = value;
|
|
21243
|
-
if ("steps" in obj && Array.isArray(obj.steps)) return value;
|
|
21244
|
-
if ("type" in obj && "valueAST" in obj) return value;
|
|
21245
|
-
let needsEval = false;
|
|
21246
|
-
for (const val of Object.values(obj)) if (typeof val === "object" && val !== null) {
|
|
21247
|
-
needsEval = true;
|
|
21248
|
-
break;
|
|
21249
|
-
}
|
|
21250
|
-
if (needsEval) {
|
|
21251
|
-
const result = {};
|
|
21252
|
-
for (const [k2, v2] of Object.entries(obj)) result[k2] = callbacks.recurse(v2, reactiveSchema);
|
|
21253
|
-
return result;
|
|
21254
|
-
}
|
|
21255
|
-
return value;
|
|
21256
|
-
}
|
|
21257
|
-
function evaluateElementProps(el, evalCtx) {
|
|
21258
|
-
if (el.hasDynamicProps === false) return el;
|
|
21259
|
-
const schemaCtx = { library: evalCtx.library };
|
|
21260
|
-
const def = evalCtx.library.components[el.typeName];
|
|
21261
|
-
const evaluated = {};
|
|
21262
|
-
for (const [key, value] of Object.entries(el.props)) {
|
|
21263
|
-
const propSchema = def?.props?.shape?.[key];
|
|
21264
|
-
try {
|
|
21265
|
-
evaluated[key] = evaluatePropValue(value, evalCtx, schemaCtx, propSchema);
|
|
21266
|
-
} catch (e) {
|
|
21267
|
-
evaluated[key] = value;
|
|
21268
|
-
const msg = e instanceof Error ? e.message : String(e);
|
|
21269
|
-
evalCtx.errors?.push({
|
|
21270
|
-
source: "runtime",
|
|
21271
|
-
code: "runtime-error",
|
|
21272
|
-
component: el.typeName,
|
|
21273
|
-
statementId: el.statementId,
|
|
21274
|
-
message: `Evaluating prop "${key}" on ${el.typeName} failed: ${msg}`,
|
|
21275
|
-
hint: `Check the expression used for prop "${key}"`
|
|
21276
|
-
});
|
|
21277
|
-
}
|
|
21278
|
-
}
|
|
21279
|
-
return {
|
|
21280
|
-
...el,
|
|
21281
|
-
props: evaluated
|
|
21282
|
-
};
|
|
21283
|
-
}
|
|
21284
|
-
function evaluatePropValue(value, evalCtx, schemaCtx, reactiveSchema) {
|
|
21285
|
-
return evaluatePropCore(value, evalCtx.ctx, schemaCtx, reactiveSchema, {
|
|
21286
|
-
recurseElement: (el) => evaluateElementProps(el, evalCtx),
|
|
21287
|
-
recurse: (v2, rs) => evaluatePropValue(v2, evalCtx, schemaCtx, rs)
|
|
21288
|
-
});
|
|
21289
|
-
}
|
|
21290
|
-
var McpToolError = class extends Error {
|
|
21291
|
-
toolErrorText;
|
|
21292
|
-
constructor(errorText) {
|
|
21293
|
-
super(`MCP tool error: ${errorText || "Unknown error"}`);
|
|
21294
|
-
this.name = "McpToolError";
|
|
21295
|
-
this.toolErrorText = errorText;
|
|
21296
|
-
}
|
|
21297
|
-
};
|
|
21298
|
-
function extractToolResult(result) {
|
|
21299
|
-
if (result.isError) {
|
|
21300
|
-
const errorText = result.content?.filter((c2) => c2.type === "text").map((c2) => c2.text).join("\n");
|
|
21301
|
-
throw new McpToolError(errorText || "Unknown error");
|
|
21302
|
-
}
|
|
21303
|
-
if (result.structuredContent != null) return result.structuredContent;
|
|
21304
|
-
const textParts = result.content?.filter((c2) => c2.type === "text").map((c2) => c2.text ?? "");
|
|
21305
|
-
if (textParts?.length) {
|
|
21306
|
-
const text = textParts.join("");
|
|
21307
|
-
try {
|
|
21308
|
-
return JSON.parse(text);
|
|
21309
|
-
} catch {
|
|
21310
|
-
return text;
|
|
21311
|
-
}
|
|
21312
|
-
}
|
|
21313
|
-
return null;
|
|
21314
|
-
}
|
|
21315
|
-
var ToolNotFoundError = class extends Error {
|
|
21316
|
-
toolName;
|
|
21317
|
-
availableTools;
|
|
21318
|
-
constructor(toolName, availableTools = []) {
|
|
21319
|
-
super(`[openui] No handler for tool "${toolName}". Available: ${availableTools.join(", ") || "(none)"}`);
|
|
21320
|
-
this.name = "ToolNotFoundError";
|
|
21321
|
-
this.toolName = toolName;
|
|
21322
|
-
this.availableTools = availableTools;
|
|
21323
|
-
}
|
|
21324
|
-
};
|
|
21325
|
-
function stableStringify(value) {
|
|
21326
|
-
return JSON.stringify(value, (_key, val) => {
|
|
21327
|
-
if (val && typeof val === "object" && !Array.isArray(val)) {
|
|
21328
|
-
const sorted = {};
|
|
21329
|
-
for (const k2 of Object.keys(val).sort()) sorted[k2] = val[k2];
|
|
21330
|
-
return sorted;
|
|
21331
|
-
}
|
|
21332
|
-
if (val === void 0) return "__undefined__";
|
|
21333
|
-
if (typeof val === "number") {
|
|
21334
|
-
if (Number.isNaN(val)) return "__NaN__";
|
|
21335
|
-
if (val === Infinity) return "__Inf__";
|
|
21336
|
-
if (val === -Infinity) return "__-Inf__";
|
|
21337
|
-
}
|
|
21338
|
-
return val;
|
|
21339
|
-
});
|
|
21340
|
-
}
|
|
21341
|
-
function buildCacheKey(toolName, args, deps) {
|
|
21342
|
-
const depsKey = deps != null ? "::" + stableStringify(deps) : "";
|
|
21343
|
-
return toolName + "::" + stableStringify(args) + depsKey;
|
|
21344
|
-
}
|
|
21345
|
-
function createQueryManager(toolProvider) {
|
|
21346
|
-
const queries = /* @__PURE__ */ new Map();
|
|
21347
|
-
const mutations = /* @__PURE__ */ new Map();
|
|
21348
|
-
const cache2 = /* @__PURE__ */ new Map();
|
|
21349
|
-
const listeners = /* @__PURE__ */ new Set();
|
|
21350
|
-
let snapshot = {
|
|
21351
|
-
__openui_loading: [],
|
|
21352
|
-
__openui_refetching: [],
|
|
21353
|
-
__openui_errors: []
|
|
21354
|
-
};
|
|
21355
|
-
let snapshotJson = JSON.stringify(snapshot);
|
|
21356
|
-
let disposed = false;
|
|
21357
|
-
let generation = 0;
|
|
21358
|
-
function rebuildSnapshot() {
|
|
21359
|
-
const out = {
|
|
21360
|
-
__openui_loading: [],
|
|
21361
|
-
__openui_refetching: [],
|
|
21362
|
-
__openui_errors: []
|
|
21363
|
-
};
|
|
21364
|
-
for (const [sid, q2] of queries) {
|
|
21365
|
-
const entry = cache2.get(q2.cacheKey);
|
|
21366
|
-
if (entry && entry.data !== void 0) out[sid] = entry.data;
|
|
21367
|
-
else if (q2.prevCacheKey) {
|
|
21368
|
-
const prev = cache2.get(q2.prevCacheKey);
|
|
21369
|
-
if (prev && prev.data !== void 0) out[sid] = prev.data;
|
|
21370
|
-
else out[sid] = q2.defaults;
|
|
21371
|
-
} else out[sid] = q2.defaults;
|
|
21372
|
-
if (q2.loading) {
|
|
21373
|
-
out.__openui_loading.push(sid);
|
|
21374
|
-
if (q2.everFetched) out.__openui_refetching.push(sid);
|
|
21375
|
-
}
|
|
21376
|
-
if (q2.error) out.__openui_errors.push(q2.error);
|
|
21377
|
-
}
|
|
21378
|
-
for (const [sid, m] of mutations) {
|
|
21379
|
-
out[sid] = m.result;
|
|
21380
|
-
if (m.error) out.__openui_errors.push(m.error);
|
|
21381
|
-
}
|
|
21382
|
-
try {
|
|
21383
|
-
const outJson = JSON.stringify(out);
|
|
21384
|
-
if (outJson === snapshotJson) return false;
|
|
21385
|
-
snapshot = out;
|
|
21386
|
-
snapshotJson = outJson;
|
|
21387
|
-
} catch {
|
|
21388
|
-
snapshot = out;
|
|
21389
|
-
snapshotJson = "";
|
|
21390
|
-
}
|
|
21391
|
-
return true;
|
|
21392
|
-
}
|
|
21393
|
-
function notify() {
|
|
21394
|
-
for (const listener2 of [...listeners]) listener2();
|
|
21395
|
-
}
|
|
21396
|
-
async function executeFetch(cacheKey, statementId) {
|
|
21397
|
-
if (!toolProvider) return;
|
|
21398
|
-
const q2 = queries.get(statementId);
|
|
21399
|
-
if (!q2) return;
|
|
21400
|
-
const fetchKey = cacheKey;
|
|
21401
|
-
const toolName = q2.toolName;
|
|
21402
|
-
const args = q2.args;
|
|
21403
|
-
let entry = cache2.get(fetchKey);
|
|
21404
|
-
if (!entry) {
|
|
21405
|
-
entry = {
|
|
21406
|
-
data: void 0,
|
|
21407
|
-
inFlight: true
|
|
21408
|
-
};
|
|
21409
|
-
cache2.set(fetchKey, entry);
|
|
21410
|
-
} else entry.inFlight = true;
|
|
21411
|
-
q2.loading = true;
|
|
21412
|
-
rebuildSnapshot();
|
|
21413
|
-
notify();
|
|
21414
|
-
try {
|
|
21415
|
-
const data = await toolProvider.callTool(toolName, args ?? {});
|
|
21416
|
-
if (disposed) return;
|
|
21417
|
-
const current2 = queries.get(statementId);
|
|
21418
|
-
if (!current2 || current2.cacheKey !== fetchKey) {
|
|
21419
|
-
entry.inFlight = false;
|
|
21420
|
-
return;
|
|
21421
|
-
}
|
|
21422
|
-
entry.data = data ?? null;
|
|
21423
|
-
current2.everFetched = true;
|
|
21424
|
-
current2.error = void 0;
|
|
21425
|
-
if (current2.prevCacheKey && current2.prevCacheKey !== fetchKey) {
|
|
21426
|
-
const prevKey = current2.prevCacheKey;
|
|
21427
|
-
current2.prevCacheKey = void 0;
|
|
21428
|
-
cleanupCacheEntry(prevKey);
|
|
21429
|
-
}
|
|
21430
|
-
} catch (err) {
|
|
21431
|
-
const current2 = queries.get(statementId);
|
|
21432
|
-
if (current2 && current2.cacheKey === fetchKey) if (err instanceof ToolNotFoundError) current2.error = {
|
|
21433
|
-
source: "query",
|
|
21434
|
-
code: "tool-not-found",
|
|
21435
|
-
message: `Query tool "${toolName}" not found`,
|
|
21436
|
-
statementId,
|
|
21437
|
-
component: "Query",
|
|
21438
|
-
toolName,
|
|
21439
|
-
hint: err.availableTools.length ? `Available tools: ${err.availableTools.join(", ")}` : void 0
|
|
21440
|
-
};
|
|
21441
|
-
else if (err instanceof McpToolError) current2.error = {
|
|
21442
|
-
source: "query",
|
|
21443
|
-
code: "mcp-error",
|
|
21444
|
-
message: `Query "${toolName}" returned an error: ${err.toolErrorText}`,
|
|
21445
|
-
statementId,
|
|
21446
|
-
component: "Query",
|
|
21447
|
-
toolName
|
|
21448
|
-
};
|
|
21449
|
-
else current2.error = {
|
|
21450
|
-
source: "query",
|
|
21451
|
-
code: "tool-error",
|
|
21452
|
-
message: `Query "${toolName}" failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
21453
|
-
statementId,
|
|
21454
|
-
component: "Query",
|
|
21455
|
-
toolName
|
|
21456
|
-
};
|
|
21457
|
-
console.error(`Query "${toolName}" failed:`, err);
|
|
21458
|
-
} finally {
|
|
21459
|
-
entry.inFlight = false;
|
|
21460
|
-
const current2 = queries.get(statementId);
|
|
21461
|
-
if (current2 && current2.cacheKey === fetchKey) {
|
|
21462
|
-
current2.loading = false;
|
|
21463
|
-
if (rebuildSnapshot()) notify();
|
|
21464
|
-
if (current2.needsRefetch) {
|
|
21465
|
-
current2.needsRefetch = false;
|
|
21466
|
-
executeFetch(current2.cacheKey, statementId);
|
|
21467
|
-
}
|
|
21468
|
-
} else if (rebuildSnapshot()) notify();
|
|
21469
|
-
}
|
|
21470
|
-
}
|
|
21471
|
-
function cleanupCacheEntry(cacheKey) {
|
|
21472
|
-
for (const q2 of queries.values()) if (q2.cacheKey === cacheKey || q2.prevCacheKey === cacheKey) return;
|
|
21473
|
-
cache2.delete(cacheKey);
|
|
21474
|
-
}
|
|
21475
|
-
function evaluateQueries(queryNodes) {
|
|
21476
|
-
if (disposed) return;
|
|
21477
|
-
const activeIds = new Set(queryNodes.map((n) => n.statementId));
|
|
21478
|
-
for (const [sid, q2] of queries) if (!activeIds.has(sid)) {
|
|
21479
|
-
if (q2.timer) clearInterval(q2.timer);
|
|
21480
|
-
queries.delete(sid);
|
|
21481
|
-
cleanupCacheEntry(q2.cacheKey);
|
|
21482
|
-
if (q2.prevCacheKey) cleanupCacheEntry(q2.prevCacheKey);
|
|
21483
|
-
}
|
|
21484
|
-
for (const node of queryNodes) {
|
|
21485
|
-
if (!node.complete) continue;
|
|
21486
|
-
const cacheKey = buildCacheKey(node.toolName, node.args, node.deps);
|
|
21487
|
-
const existing = queries.get(node.statementId);
|
|
21488
|
-
if (existing) {
|
|
21489
|
-
if (existing.cacheKey !== cacheKey) existing.prevCacheKey = existing.cacheKey;
|
|
21490
|
-
existing.toolName = node.toolName;
|
|
21491
|
-
existing.args = node.args;
|
|
21492
|
-
existing.defaults = node.defaults;
|
|
21493
|
-
existing.cacheKey = cacheKey;
|
|
21494
|
-
} else queries.set(node.statementId, {
|
|
21495
|
-
toolName: node.toolName,
|
|
21496
|
-
args: node.args,
|
|
21497
|
-
defaults: node.defaults,
|
|
21498
|
-
cacheKey,
|
|
21499
|
-
loading: false,
|
|
21500
|
-
everFetched: false,
|
|
21501
|
-
refreshInterval: 0,
|
|
21502
|
-
needsRefetch: false
|
|
21503
|
-
});
|
|
21504
|
-
const q2 = queries.get(node.statementId);
|
|
21505
|
-
const entry = cache2.get(cacheKey);
|
|
21506
|
-
const hasSettledData = entry && entry.data !== void 0 && !entry.inFlight;
|
|
21507
|
-
if (toolProvider && !hasSettledData && !entry?.inFlight) executeFetch(cacheKey, node.statementId);
|
|
21508
|
-
const newInterval = node.refreshInterval ?? 0;
|
|
21509
|
-
if (newInterval !== q2.refreshInterval) {
|
|
21510
|
-
if (q2.timer) {
|
|
21511
|
-
clearInterval(q2.timer);
|
|
21512
|
-
q2.timer = void 0;
|
|
21513
|
-
}
|
|
21514
|
-
if (newInterval > 0) q2.timer = setInterval(() => {
|
|
21515
|
-
if (disposed || !toolProvider) return;
|
|
21516
|
-
if (!cache2.get(q2.cacheKey)?.inFlight) executeFetch(q2.cacheKey, node.statementId);
|
|
21517
|
-
}, newInterval * 1e3);
|
|
21518
|
-
q2.refreshInterval = newInterval;
|
|
21519
|
-
}
|
|
21520
|
-
}
|
|
21521
|
-
if (rebuildSnapshot()) notify();
|
|
21522
|
-
}
|
|
21523
|
-
function getResult(statementId) {
|
|
21524
|
-
const q2 = queries.get(statementId);
|
|
21525
|
-
if (!q2) return null;
|
|
21526
|
-
const entry = cache2.get(q2.cacheKey);
|
|
21527
|
-
if (entry && entry.data !== void 0) return entry.data;
|
|
21528
|
-
if (q2.prevCacheKey) {
|
|
21529
|
-
const prev = cache2.get(q2.prevCacheKey);
|
|
21530
|
-
if (prev && prev.data !== void 0) return prev.data;
|
|
21531
|
-
}
|
|
21532
|
-
return q2.defaults;
|
|
21533
|
-
}
|
|
21534
|
-
function isLoading(statementId) {
|
|
21535
|
-
return queries.get(statementId)?.loading ?? false;
|
|
21536
|
-
}
|
|
21537
|
-
function isAnyLoading() {
|
|
21538
|
-
for (const q2 of queries.values()) if (q2.loading) return true;
|
|
21539
|
-
return false;
|
|
21540
|
-
}
|
|
21541
|
-
function invalidate(statementIds) {
|
|
21542
|
-
if (disposed || !toolProvider) return;
|
|
21543
|
-
const targets = statementIds?.length ? statementIds.filter((sid) => queries.has(sid)) : [...queries.keys()];
|
|
21544
|
-
for (const sid of targets) {
|
|
21545
|
-
const q2 = queries.get(sid);
|
|
21546
|
-
if (!q2) continue;
|
|
21547
|
-
if (cache2.get(q2.cacheKey)?.inFlight) q2.needsRefetch = true;
|
|
21548
|
-
else executeFetch(q2.cacheKey, sid);
|
|
21549
|
-
}
|
|
21550
|
-
}
|
|
21551
|
-
function registerMutations(nodes) {
|
|
21552
|
-
const activeIds = new Set(nodes.map((n) => n.statementId));
|
|
21553
|
-
for (const sid of mutations.keys()) if (!activeIds.has(sid)) mutations.delete(sid);
|
|
21554
|
-
for (const node of nodes) {
|
|
21555
|
-
const existing = mutations.get(node.statementId);
|
|
21556
|
-
if (existing) {
|
|
21557
|
-
if (existing.toolName !== node.toolName) {
|
|
21558
|
-
existing.toolName = node.toolName;
|
|
21559
|
-
existing.result = {
|
|
21560
|
-
status: "idle",
|
|
21561
|
-
data: null,
|
|
21562
|
-
error: null
|
|
21563
|
-
};
|
|
21564
|
-
existing.error = void 0;
|
|
21565
|
-
}
|
|
21566
|
-
} else mutations.set(node.statementId, {
|
|
21567
|
-
toolName: node.toolName,
|
|
21568
|
-
result: { status: "idle" }
|
|
21569
|
-
});
|
|
21570
|
-
}
|
|
21571
|
-
if (rebuildSnapshot()) notify();
|
|
21572
|
-
}
|
|
21573
|
-
async function fireMutation(statementId, evaluatedArgs, refreshQueryIds) {
|
|
21574
|
-
if (disposed || !toolProvider) return false;
|
|
21575
|
-
const m = mutations.get(statementId);
|
|
21576
|
-
if (!m) return false;
|
|
21577
|
-
if (m.result.status === "loading") return false;
|
|
21578
|
-
const gen = generation;
|
|
21579
|
-
m.result = { status: "loading" };
|
|
21580
|
-
rebuildSnapshot();
|
|
21581
|
-
notify();
|
|
21582
|
-
let success = false;
|
|
21583
|
-
try {
|
|
21584
|
-
const data = await toolProvider.callTool(m.toolName, evaluatedArgs);
|
|
21585
|
-
if (disposed || gen !== generation) return false;
|
|
21586
|
-
m.result = {
|
|
21587
|
-
status: "success",
|
|
21588
|
-
data
|
|
21589
|
-
};
|
|
21590
|
-
m.error = void 0;
|
|
21591
|
-
success = true;
|
|
21592
|
-
} catch (err) {
|
|
21593
|
-
if (disposed || gen !== generation) return false;
|
|
21594
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
21595
|
-
m.result = {
|
|
21596
|
-
status: "error",
|
|
21597
|
-
error: msg
|
|
21598
|
-
};
|
|
21599
|
-
if (err instanceof ToolNotFoundError) m.error = {
|
|
21600
|
-
source: "mutation",
|
|
21601
|
-
code: "tool-not-found",
|
|
21602
|
-
message: `Mutation tool "${m.toolName}" not found`,
|
|
21603
|
-
statementId,
|
|
21604
|
-
component: "Mutation",
|
|
21605
|
-
toolName: m.toolName,
|
|
21606
|
-
hint: err.availableTools.length ? `Available tools: ${err.availableTools.join(", ")}` : void 0
|
|
21607
|
-
};
|
|
21608
|
-
else if (err instanceof McpToolError) m.error = {
|
|
21609
|
-
source: "mutation",
|
|
21610
|
-
code: "mcp-error",
|
|
21611
|
-
message: `Mutation "${m.toolName}" returned an error: ${err.toolErrorText}`,
|
|
21612
|
-
statementId,
|
|
21613
|
-
component: "Mutation",
|
|
21614
|
-
toolName: m.toolName
|
|
21615
|
-
};
|
|
21616
|
-
else m.error = {
|
|
21617
|
-
source: "mutation",
|
|
21618
|
-
code: "tool-error",
|
|
21619
|
-
message: `Mutation "${m.toolName}" failed: ${msg}`,
|
|
21620
|
-
statementId,
|
|
21621
|
-
component: "Mutation",
|
|
21622
|
-
toolName: m.toolName
|
|
21623
|
-
};
|
|
21624
|
-
}
|
|
21625
|
-
rebuildSnapshot();
|
|
21626
|
-
notify();
|
|
21627
|
-
if (success && refreshQueryIds?.length) invalidate(refreshQueryIds);
|
|
21628
|
-
return success;
|
|
21629
|
-
}
|
|
21630
|
-
function getMutationResult(statementId) {
|
|
21631
|
-
return mutations.get(statementId)?.result ?? null;
|
|
21632
|
-
}
|
|
21633
|
-
function subscribe2(listener2) {
|
|
21634
|
-
listeners.add(listener2);
|
|
21635
|
-
return () => listeners.delete(listener2);
|
|
21636
|
-
}
|
|
21637
|
-
function getSnapshot() {
|
|
21638
|
-
return snapshot;
|
|
21639
|
-
}
|
|
21640
|
-
function activate() {
|
|
21641
|
-
disposed = false;
|
|
21642
|
-
}
|
|
21643
|
-
function dispose() {
|
|
21644
|
-
disposed = true;
|
|
21645
|
-
generation++;
|
|
21646
|
-
listeners.clear();
|
|
21647
|
-
for (const q2 of queries.values()) {
|
|
21648
|
-
if (q2.timer) {
|
|
21649
|
-
clearInterval(q2.timer);
|
|
21650
|
-
q2.timer = void 0;
|
|
21651
|
-
}
|
|
21652
|
-
q2.refreshInterval = 0;
|
|
21653
|
-
q2.loading = false;
|
|
21654
|
-
q2.needsRefetch = false;
|
|
21655
|
-
}
|
|
21656
|
-
mutations.clear();
|
|
21657
|
-
}
|
|
21658
|
-
return {
|
|
21659
|
-
evaluateQueries,
|
|
21660
|
-
getResult,
|
|
21661
|
-
isLoading,
|
|
21662
|
-
isAnyLoading,
|
|
21663
|
-
invalidate,
|
|
21664
|
-
registerMutations,
|
|
21665
|
-
fireMutation,
|
|
21666
|
-
getMutationResult,
|
|
21667
|
-
subscribe: subscribe2,
|
|
21668
|
-
getSnapshot,
|
|
21669
|
-
activate,
|
|
21670
|
-
dispose
|
|
21671
|
-
};
|
|
21672
|
-
}
|
|
21673
|
-
function resolveStateField(name, bindingValue, store2, evaluationContext, fieldGetter, fieldSetter) {
|
|
21674
|
-
if (isReactiveAssign(bindingValue) && store2 && evaluationContext) {
|
|
21675
|
-
const { target, expr } = bindingValue;
|
|
21676
|
-
return {
|
|
21677
|
-
name,
|
|
21678
|
-
value: store2.get(target),
|
|
21679
|
-
setValue: (value) => {
|
|
21680
|
-
const extraScope = { $value: value };
|
|
21681
|
-
const nextValue = evaluate(expr, {
|
|
21682
|
-
...evaluationContext,
|
|
21683
|
-
extraScope
|
|
21684
|
-
});
|
|
21685
|
-
store2.set(target, nextValue);
|
|
21686
|
-
},
|
|
21687
|
-
isReactive: true
|
|
21688
|
-
};
|
|
21689
|
-
}
|
|
21690
|
-
return {
|
|
21691
|
-
name,
|
|
21692
|
-
value: fieldGetter(name) ?? bindingValue,
|
|
21693
|
-
setValue: (value) => fieldSetter(name, value),
|
|
21694
|
-
isReactive: false
|
|
21695
|
-
};
|
|
21696
|
-
}
|
|
21697
|
-
function createStore$2() {
|
|
21698
|
-
const state = /* @__PURE__ */ new Map();
|
|
21699
|
-
const listeners = /* @__PURE__ */ new Set();
|
|
21700
|
-
let snapshot = {};
|
|
21701
|
-
function notify() {
|
|
21702
|
-
const currentListeners = [...listeners];
|
|
21703
|
-
for (const listener2 of currentListeners) listener2();
|
|
21704
|
-
}
|
|
21705
|
-
function rebuildSnapshot() {
|
|
21706
|
-
snapshot = Object.fromEntries(state);
|
|
21707
|
-
}
|
|
21708
|
-
function get2(name) {
|
|
21709
|
-
return state.get(name);
|
|
21710
|
-
}
|
|
21711
|
-
function set3(name, value) {
|
|
21712
|
-
const existing = state.get(name);
|
|
21713
|
-
if (Object.is(existing, value)) return;
|
|
21714
|
-
if (value && existing && typeof value === "object" && typeof existing === "object" && !Array.isArray(value) && !Array.isArray(existing)) {
|
|
21715
|
-
const nk = Object.keys(value);
|
|
21716
|
-
const ok = Object.keys(existing);
|
|
21717
|
-
if (nk.length === ok.length && nk.every((k2) => Object.is(value[k2], existing[k2]))) return;
|
|
21718
|
-
}
|
|
21719
|
-
state.set(name, value);
|
|
21720
|
-
rebuildSnapshot();
|
|
21721
|
-
notify();
|
|
21722
|
-
}
|
|
21723
|
-
function subscribe2(listener2) {
|
|
21724
|
-
listeners.add(listener2);
|
|
21725
|
-
return () => {
|
|
21726
|
-
listeners.delete(listener2);
|
|
21727
|
-
};
|
|
21728
|
-
}
|
|
21729
|
-
function getSnapshot() {
|
|
21730
|
-
return snapshot;
|
|
21731
|
-
}
|
|
21732
|
-
function initialize(defaults2, persisted) {
|
|
21733
|
-
for (const key of Object.keys(persisted)) state.set(key, persisted[key]);
|
|
21734
|
-
for (const key of Object.keys(defaults2)) if (!state.has(key)) state.set(key, defaults2[key]);
|
|
21735
|
-
rebuildSnapshot();
|
|
21736
|
-
notify();
|
|
21737
|
-
}
|
|
21738
|
-
function dispose() {
|
|
21739
|
-
state.clear();
|
|
21740
|
-
listeners.clear();
|
|
21741
|
-
snapshot = {};
|
|
21742
|
-
}
|
|
21743
|
-
return {
|
|
21744
|
-
get: get2,
|
|
21745
|
-
set: set3,
|
|
21746
|
-
subscribe: subscribe2,
|
|
21747
|
-
getSnapshot,
|
|
21748
|
-
initialize,
|
|
21749
|
-
dispose
|
|
21750
|
-
};
|
|
21751
|
-
}
|
|
21752
|
-
function isEmpty(value) {
|
|
21753
|
-
if (value === null || value === void 0 || value === "") return true;
|
|
21754
|
-
if (Array.isArray(value) && value.length === 0) return true;
|
|
21755
|
-
if (value && typeof value === "object" && !Array.isArray(value) && "value" in value) return isEmpty(value.value);
|
|
21756
|
-
if (typeof value === "object" && value !== null && !Array.isArray(value) && Object.keys(value).length === 0) return true;
|
|
21757
|
-
return false;
|
|
21758
|
-
}
|
|
21759
|
-
var builtInValidators = {
|
|
21760
|
-
required: (value) => {
|
|
21761
|
-
if (isEmpty(value)) return "This field is required";
|
|
21762
|
-
if (typeof value === "object" && !Array.isArray(value) && value !== null) {
|
|
21763
|
-
const vals = Object.values(value);
|
|
21764
|
-
if (vals.length > 0 && vals.every((v2) => typeof v2 === "boolean") && !vals.some(Boolean)) return "At least one option is required";
|
|
21765
|
-
}
|
|
21766
|
-
},
|
|
21767
|
-
email: (value) => {
|
|
21768
|
-
if (isEmpty(value)) return void 0;
|
|
21769
|
-
if (typeof value !== "string") return "Please enter a valid email";
|
|
21770
|
-
return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value) ? void 0 : "Please enter a valid email";
|
|
21771
|
-
},
|
|
21772
|
-
url: (value) => {
|
|
21773
|
-
if (isEmpty(value)) return void 0;
|
|
21774
|
-
if (typeof value !== "string") return "Please enter a valid URL";
|
|
21775
|
-
try {
|
|
21776
|
-
new URL(value);
|
|
21777
|
-
return;
|
|
21778
|
-
} catch {
|
|
21779
|
-
return "Please enter a valid URL";
|
|
21780
|
-
}
|
|
21781
|
-
},
|
|
21782
|
-
numeric: (value) => {
|
|
21783
|
-
if (isEmpty(value)) return void 0;
|
|
21784
|
-
if (typeof value === "number" && !isNaN(value)) return void 0;
|
|
21785
|
-
if (typeof value === "string" && !isNaN(parseFloat(value)) && value.trim() !== "") return void 0;
|
|
21786
|
-
return "Must be a number";
|
|
21787
|
-
},
|
|
21788
|
-
min: (value, arg) => {
|
|
21789
|
-
if (isEmpty(value)) return void 0;
|
|
21790
|
-
const n = typeof value === "number" ? value : parseFloat(String(value));
|
|
21791
|
-
if (isNaN(n)) return void 0;
|
|
21792
|
-
const min = Number(arg);
|
|
21793
|
-
return n >= min ? void 0 : `Must be at least ${min}`;
|
|
21794
|
-
},
|
|
21795
|
-
max: (value, arg) => {
|
|
21796
|
-
if (isEmpty(value)) return void 0;
|
|
21797
|
-
const n = typeof value === "number" ? value : parseFloat(String(value));
|
|
21798
|
-
if (isNaN(n)) return void 0;
|
|
21799
|
-
const max = Number(arg);
|
|
21800
|
-
return n <= max ? void 0 : `Must be no more than ${max}`;
|
|
21801
|
-
},
|
|
21802
|
-
minLength: (value, arg) => {
|
|
21803
|
-
if (isEmpty(value)) return void 0;
|
|
21804
|
-
if (typeof value !== "string") return void 0;
|
|
21805
|
-
const min = Number(arg);
|
|
21806
|
-
return value.length >= min ? void 0 : `Must be at least ${min} characters`;
|
|
21807
|
-
},
|
|
21808
|
-
maxLength: (value, arg) => {
|
|
21809
|
-
if (isEmpty(value)) return void 0;
|
|
21810
|
-
if (typeof value !== "string") return void 0;
|
|
21811
|
-
const max = Number(arg);
|
|
21812
|
-
return value.length <= max ? void 0 : `Must be no more than ${max} characters`;
|
|
21813
|
-
},
|
|
21814
|
-
pattern: (value, arg) => {
|
|
21815
|
-
if (isEmpty(value)) return void 0;
|
|
21816
|
-
if (typeof value !== "string" || typeof arg !== "string") return void 0;
|
|
21817
|
-
try {
|
|
21818
|
-
return new RegExp(arg).test(value) ? void 0 : "Invalid format";
|
|
21819
|
-
} catch {
|
|
21820
|
-
return;
|
|
21821
|
-
}
|
|
21822
|
-
}
|
|
21823
|
-
};
|
|
21824
|
-
function validate(value, rules, customValidators) {
|
|
21825
|
-
for (const rule of rules) {
|
|
21826
|
-
const validator = customValidators?.[rule.type] ?? builtInValidators[rule.type];
|
|
21827
|
-
if (!validator) {
|
|
21828
|
-
console.warn(`[openui] Unknown validation rule type: "${rule.type}"`);
|
|
21829
|
-
continue;
|
|
21830
|
-
}
|
|
21831
|
-
const error = validator(value, rule.arg);
|
|
21832
|
-
if (error) return error;
|
|
21833
|
-
}
|
|
21834
|
-
}
|
|
21835
|
-
function parseStructuredRules(rules) {
|
|
21836
|
-
if (!rules || typeof rules !== "object" || Array.isArray(rules)) return [];
|
|
21837
|
-
const obj = rules;
|
|
21838
|
-
const result = [];
|
|
21839
|
-
for (const [key, val] of Object.entries(obj)) {
|
|
21840
|
-
if (val === false || val === void 0 || val === null) continue;
|
|
21841
|
-
if (val === true) result.push({ type: key });
|
|
21842
|
-
else result.push({
|
|
21843
|
-
type: key,
|
|
21844
|
-
arg: val
|
|
21845
|
-
});
|
|
21846
|
-
}
|
|
21847
|
-
return result;
|
|
21848
|
-
}
|
|
21849
18447
|
var ALL_KEY = "all";
|
|
21850
18448
|
function createObservability() {
|
|
21851
18449
|
const listeners = /* @__PURE__ */ new Map();
|
|
@@ -22105,7 +18703,7 @@ function useOpenUIState({ response, library, isStreaming, onAction, onStateUpdat
|
|
|
22105
18703
|
return null;
|
|
22106
18704
|
}
|
|
22107
18705
|
}, [sp, response]);
|
|
22108
|
-
const store2 = useMemo2(() => createStore
|
|
18706
|
+
const store2 = useMemo2(() => createStore(), []);
|
|
22109
18707
|
const queryManager = useMemo2(() => createQueryManager(toolProvider ?? null), [toolProvider]);
|
|
22110
18708
|
useEffect2(() => {
|
|
22111
18709
|
queryManager.activate();
|
|
@@ -24115,37 +20713,37 @@ function toPath(deepKey) {
|
|
|
24115
20713
|
if (key) result.push(key);
|
|
24116
20714
|
return result;
|
|
24117
20715
|
}
|
|
24118
|
-
function get$7(
|
|
24119
|
-
if (
|
|
20716
|
+
function get$7(object, path2, defaultValue) {
|
|
20717
|
+
if (object == null) return defaultValue;
|
|
24120
20718
|
switch (typeof path2) {
|
|
24121
20719
|
case "string": {
|
|
24122
20720
|
if (isUnsafeProperty(path2)) return defaultValue;
|
|
24123
|
-
const result =
|
|
24124
|
-
if (result === void 0) if (isDeepKey(path2) && !Object.hasOwn(
|
|
20721
|
+
const result = object[path2];
|
|
20722
|
+
if (result === void 0) if (isDeepKey(path2) && !Object.hasOwn(object, path2)) return get$7(object, toPath(path2), defaultValue);
|
|
24125
20723
|
else return defaultValue;
|
|
24126
20724
|
return result;
|
|
24127
20725
|
}
|
|
24128
20726
|
case "number":
|
|
24129
20727
|
case "symbol": {
|
|
24130
20728
|
if (typeof path2 === "number") path2 = toKey(path2);
|
|
24131
|
-
const result =
|
|
20729
|
+
const result = object[path2];
|
|
24132
20730
|
if (result === void 0) return defaultValue;
|
|
24133
20731
|
return result;
|
|
24134
20732
|
}
|
|
24135
20733
|
default: {
|
|
24136
|
-
if (Array.isArray(path2)) return getWithPath(
|
|
20734
|
+
if (Array.isArray(path2)) return getWithPath(object, path2, defaultValue);
|
|
24137
20735
|
if (Object.is(path2?.valueOf(), -0)) path2 = "-0";
|
|
24138
20736
|
else path2 = String(path2);
|
|
24139
20737
|
if (isUnsafeProperty(path2)) return defaultValue;
|
|
24140
|
-
const result =
|
|
20738
|
+
const result = object[path2];
|
|
24141
20739
|
if (result === void 0) return defaultValue;
|
|
24142
20740
|
return result;
|
|
24143
20741
|
}
|
|
24144
20742
|
}
|
|
24145
20743
|
}
|
|
24146
|
-
function getWithPath(
|
|
20744
|
+
function getWithPath(object, path2, defaultValue) {
|
|
24147
20745
|
if (path2.length === 0) return defaultValue;
|
|
24148
|
-
let current2 =
|
|
20746
|
+
let current2 = object;
|
|
24149
20747
|
for (let index = 0; index < path2.length; index++) {
|
|
24150
20748
|
if (current2 == null) return defaultValue;
|
|
24151
20749
|
if (isUnsafeProperty(path2[index])) return defaultValue;
|
|
@@ -24641,8 +21239,8 @@ function isArrayLike(value) {
|
|
|
24641
21239
|
return value != null && typeof value !== "function" && isLength(value.length);
|
|
24642
21240
|
}
|
|
24643
21241
|
function property(path2) {
|
|
24644
|
-
return function(
|
|
24645
|
-
return get$7(
|
|
21242
|
+
return function(object) {
|
|
21243
|
+
return get$7(object, path2);
|
|
24646
21244
|
};
|
|
24647
21245
|
}
|
|
24648
21246
|
function isPrimitive(value) {
|
|
@@ -24651,8 +21249,8 @@ function isPrimitive(value) {
|
|
|
24651
21249
|
function isTypedArray(x2) {
|
|
24652
21250
|
return ArrayBuffer.isView(x2) && !(x2 instanceof DataView);
|
|
24653
21251
|
}
|
|
24654
|
-
function getSymbols(
|
|
24655
|
-
return Object.getOwnPropertySymbols(
|
|
21252
|
+
function getSymbols(object) {
|
|
21253
|
+
return Object.getOwnPropertySymbols(object).filter((symbol) => Object.prototype.propertyIsEnumerable.call(object, symbol));
|
|
24656
21254
|
}
|
|
24657
21255
|
function getTag(value) {
|
|
24658
21256
|
if (value == null) return value === void 0 ? "[object Undefined]" : "[object Null]";
|
|
@@ -24791,8 +21389,8 @@ function copyProperties(target, source, objectToClone = target, stack, cloneValu
|
|
|
24791
21389
|
if (descriptor == null || descriptor.writable) target[key] = cloneDeepWithImpl(source[key], key, objectToClone, stack, cloneValue);
|
|
24792
21390
|
}
|
|
24793
21391
|
}
|
|
24794
|
-
function isCloneableObject(
|
|
24795
|
-
switch (getTag(
|
|
21392
|
+
function isCloneableObject(object) {
|
|
21393
|
+
switch (getTag(object)) {
|
|
24796
21394
|
case argumentsTag:
|
|
24797
21395
|
case arrayTag:
|
|
24798
21396
|
case arrayBufferTag:
|
|
@@ -24831,8 +21429,8 @@ function isObject$6(value) {
|
|
|
24831
21429
|
}
|
|
24832
21430
|
function isMatchWith(target, source, compare) {
|
|
24833
21431
|
if (typeof compare !== "function") return isMatchWith(target, source, () => void 0);
|
|
24834
|
-
return isMatchWithInternal(target, source, function doesMatch(objValue, srcValue, key,
|
|
24835
|
-
const isEqual = compare(objValue, srcValue, key,
|
|
21432
|
+
return isMatchWithInternal(target, source, function doesMatch(objValue, srcValue, key, object, source2, stack) {
|
|
21433
|
+
const isEqual = compare(objValue, srcValue, key, object, source2, stack);
|
|
24836
21434
|
if (isEqual !== void 0) return Boolean(isEqual);
|
|
24837
21435
|
return isMatchWithInternal(objValue, srcValue, doesMatch, stack, false);
|
|
24838
21436
|
}, /* @__PURE__ */ new Map(), true);
|
|
@@ -24926,14 +21524,14 @@ function matches(source) {
|
|
|
24926
21524
|
};
|
|
24927
21525
|
}
|
|
24928
21526
|
function cloneDeepWith(obj, customizer) {
|
|
24929
|
-
return cloneDeepWith$1(obj, (value, key,
|
|
24930
|
-
const cloned = customizer?.(value, key,
|
|
21527
|
+
return cloneDeepWith$1(obj, (value, key, object, stack) => {
|
|
21528
|
+
const cloned = customizer?.(value, key, object, stack);
|
|
24931
21529
|
if (cloned !== void 0) return cloned;
|
|
24932
21530
|
if (typeof obj !== "object") return;
|
|
24933
21531
|
if (getTag(obj) === "[object Object]" && typeof obj.constructor !== "function") {
|
|
24934
21532
|
const result = {};
|
|
24935
21533
|
stack.set(obj, result);
|
|
24936
|
-
copyProperties(result, obj,
|
|
21534
|
+
copyProperties(result, obj, object, stack);
|
|
24937
21535
|
return result;
|
|
24938
21536
|
}
|
|
24939
21537
|
switch (Object.prototype.toString.call(obj)) {
|
|
@@ -24973,13 +21571,13 @@ function isIndex(value, length = Number.MAX_SAFE_INTEGER) {
|
|
|
24973
21571
|
function isArguments(value) {
|
|
24974
21572
|
return value !== null && typeof value === "object" && getTag(value) === "[object Arguments]";
|
|
24975
21573
|
}
|
|
24976
|
-
function has$2(
|
|
21574
|
+
function has$2(object, path2) {
|
|
24977
21575
|
let resolvedPath;
|
|
24978
21576
|
if (Array.isArray(path2)) resolvedPath = path2;
|
|
24979
|
-
else if (typeof path2 === "string" && isDeepKey(path2) && !(path2 in Object(
|
|
21577
|
+
else if (typeof path2 === "string" && isDeepKey(path2) && !(path2 in Object(object))) resolvedPath = toPath(path2);
|
|
24980
21578
|
else resolvedPath = [path2];
|
|
24981
21579
|
if (resolvedPath.length === 0) return false;
|
|
24982
|
-
let current2 =
|
|
21580
|
+
let current2 = object;
|
|
24983
21581
|
for (let i = 0; i < resolvedPath.length; i++) {
|
|
24984
21582
|
const key = resolvedPath[i];
|
|
24985
21583
|
if (current2 == null || !Object.hasOwn(current2, key)) {
|
|
@@ -25222,9 +21820,9 @@ function flatten(arr, depth = 1) {
|
|
|
25222
21820
|
recursive(arr, 0);
|
|
25223
21821
|
return result;
|
|
25224
21822
|
}
|
|
25225
|
-
function isIterateeCall(value, index,
|
|
25226
|
-
if (!isObject$6(
|
|
25227
|
-
if (typeof index === "number" && isArrayLike(
|
|
21823
|
+
function isIterateeCall(value, index, object) {
|
|
21824
|
+
if (!isObject$6(object)) return false;
|
|
21825
|
+
if (typeof index === "number" && isArrayLike(object) && isIndex(index) && index < object.length || typeof index === "string" && index in object) return eq(object[index], value);
|
|
25228
21826
|
return false;
|
|
25229
21827
|
}
|
|
25230
21828
|
function getPriority(a2) {
|
|
@@ -25251,10 +21849,10 @@ function isSymbol$1(value) {
|
|
|
25251
21849
|
}
|
|
25252
21850
|
var regexIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/;
|
|
25253
21851
|
var regexIsPlainProp = /^\w*$/;
|
|
25254
|
-
function isKey(value,
|
|
21852
|
+
function isKey(value, object) {
|
|
25255
21853
|
if (Array.isArray(value)) return false;
|
|
25256
21854
|
if (typeof value === "number" || typeof value === "boolean" || value == null || isSymbol$1(value)) return true;
|
|
25257
|
-
return typeof value === "string" && (regexIsPlainProp.test(value) || !regexIsDeepProp.test(value)) ||
|
|
21855
|
+
return typeof value === "string" && (regexIsPlainProp.test(value) || !regexIsDeepProp.test(value)) || object != null && Object.hasOwn(object, value);
|
|
25258
21856
|
}
|
|
25259
21857
|
function orderBy(collection, criteria, orders, guard) {
|
|
25260
21858
|
if (collection == null) return [];
|
|
@@ -25264,22 +21862,22 @@ function orderBy(collection, criteria, orders, guard) {
|
|
|
25264
21862
|
if (criteria.length === 0) criteria = [null];
|
|
25265
21863
|
if (!Array.isArray(orders)) orders = orders == null ? [] : [orders];
|
|
25266
21864
|
orders = orders.map((order) => String(order));
|
|
25267
|
-
const getValueByNestedPath = (
|
|
25268
|
-
let target =
|
|
21865
|
+
const getValueByNestedPath = (object, path2) => {
|
|
21866
|
+
let target = object;
|
|
25269
21867
|
let index = 0;
|
|
25270
21868
|
for (; index < path2.length && target != null; ++index) target = target[path2[index]];
|
|
25271
21869
|
return index > 0 && index === path2.length ? target : void 0;
|
|
25272
21870
|
};
|
|
25273
|
-
const getValueByCriterion = (criterion,
|
|
25274
|
-
if (criterion == null) return
|
|
25275
|
-
if (
|
|
21871
|
+
const getValueByCriterion = (criterion, object) => {
|
|
21872
|
+
if (criterion == null) return object;
|
|
21873
|
+
if (object == null) return;
|
|
25276
21874
|
if (typeof criterion === "object" && "key" in criterion) {
|
|
25277
|
-
if (Object.hasOwn(
|
|
25278
|
-
return getValueByNestedPath(
|
|
21875
|
+
if (Object.hasOwn(object, criterion.key)) return object[criterion.key];
|
|
21876
|
+
return getValueByNestedPath(object, criterion.path);
|
|
25279
21877
|
}
|
|
25280
|
-
if (typeof criterion === "function") return criterion(
|
|
25281
|
-
if (Array.isArray(criterion)) return getValueByNestedPath(
|
|
25282
|
-
return
|
|
21878
|
+
if (typeof criterion === "function") return criterion(object);
|
|
21879
|
+
if (Array.isArray(criterion)) return getValueByNestedPath(object, criterion);
|
|
21880
|
+
return object[criterion];
|
|
25283
21881
|
};
|
|
25284
21882
|
const preparedCriteria = criteria.map((criterion) => {
|
|
25285
21883
|
if (Array.isArray(criterion) && criterion.length === 1) criterion = criterion[0];
|
|
@@ -25572,8 +22170,8 @@ function compose$1(...funcs) {
|
|
|
25572
22170
|
return funcs.reduce((a2, b) => (...args) => a2(b(...args)));
|
|
25573
22171
|
}
|
|
25574
22172
|
function applyMiddleware(...middlewares) {
|
|
25575
|
-
return (
|
|
25576
|
-
const store2 =
|
|
22173
|
+
return (createStore22) => (reducer, preloadedState) => {
|
|
22174
|
+
const store2 = createStore22(reducer, preloadedState);
|
|
25577
22175
|
let dispatch = () => {
|
|
25578
22176
|
throw new Error(formatProdErrorMessage$1(15));
|
|
25579
22177
|
};
|
|
@@ -39703,28 +36301,28 @@ var require_react_is_production = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
39703
36301
|
var REACT_MEMO_TYPE = /* @__PURE__ */ Symbol.for("react.memo");
|
|
39704
36302
|
var REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy");
|
|
39705
36303
|
var REACT_VIEW_TRANSITION_TYPE = /* @__PURE__ */ Symbol.for("react.view_transition");
|
|
39706
|
-
function typeOf(
|
|
39707
|
-
if ("object" === typeof
|
|
39708
|
-
var $$typeof =
|
|
36304
|
+
function typeOf(object) {
|
|
36305
|
+
if ("object" === typeof object && null !== object) {
|
|
36306
|
+
var $$typeof = object.$$typeof;
|
|
39709
36307
|
switch ($$typeof) {
|
|
39710
36308
|
case REACT_ELEMENT_TYPE:
|
|
39711
|
-
switch (
|
|
36309
|
+
switch (object = object.type, object) {
|
|
39712
36310
|
case REACT_FRAGMENT_TYPE:
|
|
39713
36311
|
case REACT_PROFILER_TYPE:
|
|
39714
36312
|
case REACT_STRICT_MODE_TYPE:
|
|
39715
36313
|
case REACT_SUSPENSE_TYPE:
|
|
39716
36314
|
case REACT_SUSPENSE_LIST_TYPE:
|
|
39717
36315
|
case REACT_VIEW_TRANSITION_TYPE:
|
|
39718
|
-
return
|
|
36316
|
+
return object;
|
|
39719
36317
|
default:
|
|
39720
|
-
switch (
|
|
36318
|
+
switch (object = object && object.$$typeof, object) {
|
|
39721
36319
|
case REACT_CONTEXT_TYPE:
|
|
39722
36320
|
case REACT_FORWARD_REF_TYPE:
|
|
39723
36321
|
case REACT_LAZY_TYPE:
|
|
39724
36322
|
case REACT_MEMO_TYPE:
|
|
39725
|
-
return
|
|
36323
|
+
return object;
|
|
39726
36324
|
case REACT_CONSUMER_TYPE:
|
|
39727
|
-
return
|
|
36325
|
+
return object;
|
|
39728
36326
|
default:
|
|
39729
36327
|
return $$typeof;
|
|
39730
36328
|
}
|
|
@@ -39734,8 +36332,8 @@ var require_react_is_production = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
39734
36332
|
}
|
|
39735
36333
|
}
|
|
39736
36334
|
}
|
|
39737
|
-
exports.isFragment = function(
|
|
39738
|
-
return typeOf(
|
|
36335
|
+
exports.isFragment = function(object) {
|
|
36336
|
+
return typeOf(object) === REACT_FRAGMENT_TYPE;
|
|
39739
36337
|
};
|
|
39740
36338
|
}));
|
|
39741
36339
|
var import_react_is$1 = (/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
@@ -48853,7 +45451,7 @@ var createStoreImpl = (createState) => {
|
|
|
48853
45451
|
const initialState2 = state = createState(setState, getState2, api);
|
|
48854
45452
|
return api;
|
|
48855
45453
|
};
|
|
48856
|
-
var
|
|
45454
|
+
var createStore2 = (createState) => createState ? createStoreImpl(createState) : createStoreImpl;
|
|
48857
45455
|
var { useDebugValue } = React;
|
|
48858
45456
|
var { useSyncExternalStoreWithSelector } = import_with_selector$1.default;
|
|
48859
45457
|
var identity$2 = (arg) => arg;
|
|
@@ -48863,7 +45461,7 @@ function useStore(api, selector = identity$2, equalityFn) {
|
|
|
48863
45461
|
return slice;
|
|
48864
45462
|
}
|
|
48865
45463
|
var createImpl = (createState) => {
|
|
48866
|
-
const api = typeof createState === "function" ?
|
|
45464
|
+
const api = typeof createState === "function" ? createStore2(createState) : createState;
|
|
48867
45465
|
const useBoundStore = (selector, equalityFn) => useStore(api, selector, equalityFn);
|
|
48868
45466
|
Object.assign(useBoundStore, api);
|
|
48869
45467
|
return useBoundStore;
|
|
@@ -49459,20 +46057,20 @@ function buildArtifactRendererRegistry(configs) {
|
|
|
49459
46057
|
byType
|
|
49460
46058
|
};
|
|
49461
46059
|
}
|
|
49462
|
-
function lookupArtifactRenderer(
|
|
49463
|
-
return
|
|
46060
|
+
function lookupArtifactRenderer(registry, toolName) {
|
|
46061
|
+
return registry.byToolName.get(toolName) ?? null;
|
|
49464
46062
|
}
|
|
49465
|
-
function lookupArtifactRendererByType(
|
|
49466
|
-
return
|
|
46063
|
+
function lookupArtifactRendererByType(registry, type) {
|
|
46064
|
+
return registry.byType.get(type) ?? null;
|
|
49467
46065
|
}
|
|
49468
46066
|
var ArtifactRenderersContext = createContext2(null);
|
|
49469
46067
|
var useArtifactRendererRegistry = () => {
|
|
49470
46068
|
return useContext2(ArtifactRenderersContext);
|
|
49471
46069
|
};
|
|
49472
46070
|
function useArtifactRenderer(toolName) {
|
|
49473
|
-
const
|
|
49474
|
-
if (!
|
|
49475
|
-
return lookupArtifactRenderer(
|
|
46071
|
+
const registry = useArtifactRendererRegistry();
|
|
46072
|
+
if (!registry) return null;
|
|
46073
|
+
return lookupArtifactRenderer(registry, toolName);
|
|
49476
46074
|
}
|
|
49477
46075
|
function useDetailedView(viewId) {
|
|
49478
46076
|
const store2 = useDetailedViewStore();
|
|
@@ -50019,7 +46617,7 @@ var mergeThreadList = (existing, incoming) => Array.from(new Map([...existing, .
|
|
|
50019
46617
|
var createChatStore = (configRef) => {
|
|
50020
46618
|
const { storage } = configRef.current;
|
|
50021
46619
|
const { thread: threadStorage } = storage;
|
|
50022
|
-
return
|
|
46620
|
+
return createStore2()(subscribeWithSelector((set3, get2) => ({
|
|
50023
46621
|
threads: [],
|
|
50024
46622
|
isLoadingThreads: false,
|
|
50025
46623
|
threadListError: null,
|
|
@@ -50218,7 +46816,7 @@ var createChatStore = (configRef) => {
|
|
|
50218
46816
|
})));
|
|
50219
46817
|
};
|
|
50220
46818
|
var createDetailedViewStore = () => {
|
|
50221
|
-
return
|
|
46819
|
+
return createStore2()(subscribeWithSelector((set3, get2) => ({
|
|
50222
46820
|
activeDetailedViewId: null,
|
|
50223
46821
|
setActiveDetailedView: (id) => {
|
|
50224
46822
|
set3({ activeDetailedViewId: id });
|
|
@@ -50233,16 +46831,16 @@ var createDetailedViewStore = () => {
|
|
|
50233
46831
|
})));
|
|
50234
46832
|
};
|
|
50235
46833
|
var entriesEqual = (a2, b) => a2.heading === b.heading && a2.type === b.type;
|
|
50236
|
-
var upsertVersion = (
|
|
50237
|
-
const existing =
|
|
46834
|
+
var upsertVersion = (registry, entry) => {
|
|
46835
|
+
const existing = registry[entry.id] ?? [];
|
|
50238
46836
|
const sameVersionIdx = existing.findIndex((e) => e.version === entry.version);
|
|
50239
46837
|
if (sameVersionIdx !== -1) {
|
|
50240
46838
|
const current2 = existing[sameVersionIdx];
|
|
50241
|
-
if (entriesEqual(current2, entry)) return
|
|
46839
|
+
if (entriesEqual(current2, entry)) return registry;
|
|
50242
46840
|
const next2 = existing.slice();
|
|
50243
46841
|
next2[sameVersionIdx] = entry;
|
|
50244
46842
|
return {
|
|
50245
|
-
...
|
|
46843
|
+
...registry,
|
|
50246
46844
|
[entry.id]: next2
|
|
50247
46845
|
};
|
|
50248
46846
|
}
|
|
@@ -50253,28 +46851,28 @@ var upsertVersion = (registry2, entry) => {
|
|
|
50253
46851
|
...existing.slice(insertIdx)
|
|
50254
46852
|
];
|
|
50255
46853
|
return {
|
|
50256
|
-
...
|
|
46854
|
+
...registry,
|
|
50257
46855
|
[entry.id]: next
|
|
50258
46856
|
};
|
|
50259
46857
|
};
|
|
50260
|
-
var removeVersion = (
|
|
50261
|
-
const existing =
|
|
50262
|
-
if (!existing) return
|
|
46858
|
+
var removeVersion = (registry, id, version) => {
|
|
46859
|
+
const existing = registry[id];
|
|
46860
|
+
if (!existing) return registry;
|
|
50263
46861
|
const idx = existing.findIndex((e) => e.version === version);
|
|
50264
|
-
if (idx === -1) return
|
|
46862
|
+
if (idx === -1) return registry;
|
|
50265
46863
|
if (existing.length === 1) {
|
|
50266
|
-
const { [id]: _removed, ...rest2 } =
|
|
46864
|
+
const { [id]: _removed, ...rest2 } = registry;
|
|
50267
46865
|
return rest2;
|
|
50268
46866
|
}
|
|
50269
46867
|
const next = existing.slice();
|
|
50270
46868
|
next.splice(idx, 1);
|
|
50271
46869
|
return {
|
|
50272
|
-
...
|
|
46870
|
+
...registry,
|
|
50273
46871
|
[id]: next
|
|
50274
46872
|
};
|
|
50275
46873
|
};
|
|
50276
46874
|
var createThreadContextStore = () => {
|
|
50277
|
-
return
|
|
46875
|
+
return createStore2()(subscribeWithSelector((set3) => ({
|
|
50278
46876
|
artifacts: {},
|
|
50279
46877
|
registerArtifact: (entry) => {
|
|
50280
46878
|
set3((s2) => ({ artifacts: upsertVersion(s2.artifacts, entry) }));
|
|
@@ -60131,8 +56729,8 @@ function buildMatchFn(args) {
|
|
|
60131
56729
|
};
|
|
60132
56730
|
};
|
|
60133
56731
|
}
|
|
60134
|
-
function findKey(
|
|
60135
|
-
for (const key in
|
|
56732
|
+
function findKey(object, predicate) {
|
|
56733
|
+
for (const key in object) if (Object.prototype.hasOwnProperty.call(object, key) && predicate(object[key])) return key;
|
|
60136
56734
|
}
|
|
60137
56735
|
function findIndex(array, predicate) {
|
|
60138
56736
|
for (let key = 0; key < array.length; key++) if (predicate(array[key])) return key;
|
|
@@ -64215,11 +60813,11 @@ var require__isKey = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
64215
60813
|
var isSymbol2 = require_isSymbol();
|
|
64216
60814
|
var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/;
|
|
64217
60815
|
var reIsPlainProp = /^\w*$/;
|
|
64218
|
-
function isKey2(value,
|
|
60816
|
+
function isKey2(value, object) {
|
|
64219
60817
|
if (isArray2(value)) return false;
|
|
64220
60818
|
var type = typeof value;
|
|
64221
60819
|
if (type == "number" || type == "symbol" || type == "boolean" || value == null || isSymbol2(value)) return true;
|
|
64222
|
-
return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
|
|
60820
|
+
return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || object != null && value in Object(object);
|
|
64223
60821
|
}
|
|
64224
60822
|
module.exports = isKey2;
|
|
64225
60823
|
}));
|
|
@@ -64294,16 +60892,16 @@ var require__baseIsNative = /* @__PURE__ */ __commonJSMin(((exports, module) =>
|
|
|
64294
60892
|
module.exports = baseIsNative;
|
|
64295
60893
|
}));
|
|
64296
60894
|
var require__getValue = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
64297
|
-
function getValue(
|
|
64298
|
-
return
|
|
60895
|
+
function getValue(object, key) {
|
|
60896
|
+
return object == null ? void 0 : object[key];
|
|
64299
60897
|
}
|
|
64300
60898
|
module.exports = getValue;
|
|
64301
60899
|
}));
|
|
64302
60900
|
var require__getNative = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
64303
60901
|
var baseIsNative = require__baseIsNative();
|
|
64304
60902
|
var getValue = require__getValue();
|
|
64305
|
-
function getNative(
|
|
64306
|
-
var value = getValue(
|
|
60903
|
+
function getNative(object, key) {
|
|
60904
|
+
var value = getValue(object, key);
|
|
64307
60905
|
return baseIsNative(value) ? value : void 0;
|
|
64308
60906
|
}
|
|
64309
60907
|
module.exports = getNative;
|
|
@@ -64632,9 +61230,9 @@ var require__castPath = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
64632
61230
|
var isKey2 = require__isKey();
|
|
64633
61231
|
var stringToPath = require__stringToPath();
|
|
64634
61232
|
var toString2 = require_toString();
|
|
64635
|
-
function castPath(value,
|
|
61233
|
+
function castPath(value, object) {
|
|
64636
61234
|
if (isArray2(value)) return value;
|
|
64637
|
-
return isKey2(value,
|
|
61235
|
+
return isKey2(value, object) ? [value] : stringToPath(toString2(value));
|
|
64638
61236
|
}
|
|
64639
61237
|
module.exports = castPath;
|
|
64640
61238
|
}));
|
|
@@ -64651,18 +61249,18 @@ var require__toKey = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
64651
61249
|
var require__baseGet = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
64652
61250
|
var castPath = require__castPath();
|
|
64653
61251
|
var toKey2 = require__toKey();
|
|
64654
|
-
function baseGet(
|
|
64655
|
-
path2 = castPath(path2,
|
|
61252
|
+
function baseGet(object, path2) {
|
|
61253
|
+
path2 = castPath(path2, object);
|
|
64656
61254
|
var index = 0, length = path2.length;
|
|
64657
|
-
while (
|
|
64658
|
-
return index && index == length ?
|
|
61255
|
+
while (object != null && index < length) object = object[toKey2(path2[index++])];
|
|
61256
|
+
return index && index == length ? object : void 0;
|
|
64659
61257
|
}
|
|
64660
61258
|
module.exports = baseGet;
|
|
64661
61259
|
}));
|
|
64662
61260
|
var require_get = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
64663
61261
|
var baseGet = require__baseGet();
|
|
64664
|
-
function get2(
|
|
64665
|
-
var result =
|
|
61262
|
+
function get2(object, path2, defaultValue) {
|
|
61263
|
+
var result = object == null ? void 0 : baseGet(object, path2);
|
|
64666
61264
|
return result === void 0 ? defaultValue : result;
|
|
64667
61265
|
}
|
|
64668
61266
|
module.exports = get2;
|
|
@@ -66424,39 +63022,39 @@ var require__equalByTag = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
66424
63022
|
var dataViewTag2 = "[object DataView]";
|
|
66425
63023
|
var symbolProto2 = Symbol2 ? Symbol2.prototype : void 0;
|
|
66426
63024
|
var symbolValueOf = symbolProto2 ? symbolProto2.valueOf : void 0;
|
|
66427
|
-
function equalByTag(
|
|
63025
|
+
function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
|
|
66428
63026
|
switch (tag) {
|
|
66429
63027
|
case dataViewTag2:
|
|
66430
|
-
if (
|
|
66431
|
-
|
|
63028
|
+
if (object.byteLength != other.byteLength || object.byteOffset != other.byteOffset) return false;
|
|
63029
|
+
object = object.buffer;
|
|
66432
63030
|
other = other.buffer;
|
|
66433
63031
|
case arrayBufferTag2:
|
|
66434
|
-
if (
|
|
63032
|
+
if (object.byteLength != other.byteLength || !equalFunc(new Uint8Array2(object), new Uint8Array2(other))) return false;
|
|
66435
63033
|
return true;
|
|
66436
63034
|
case boolTag:
|
|
66437
63035
|
case dateTag2:
|
|
66438
63036
|
case numberTag2:
|
|
66439
|
-
return eq2(+
|
|
63037
|
+
return eq2(+object, +other);
|
|
66440
63038
|
case errorTag:
|
|
66441
|
-
return
|
|
63039
|
+
return object.name == other.name && object.message == other.message;
|
|
66442
63040
|
case regexpTag2:
|
|
66443
63041
|
case stringTag2:
|
|
66444
|
-
return
|
|
63042
|
+
return object == other + "";
|
|
66445
63043
|
case mapTag2:
|
|
66446
63044
|
var convert = mapToArray;
|
|
66447
63045
|
case setTag2:
|
|
66448
63046
|
var isPartial = bitmask & COMPARE_PARTIAL_FLAG;
|
|
66449
63047
|
convert || (convert = setToArray);
|
|
66450
|
-
if (
|
|
66451
|
-
var stacked = stack.get(
|
|
63048
|
+
if (object.size != other.size && !isPartial) return false;
|
|
63049
|
+
var stacked = stack.get(object);
|
|
66452
63050
|
if (stacked) return stacked == other;
|
|
66453
63051
|
bitmask |= COMPARE_UNORDERED_FLAG;
|
|
66454
|
-
stack.set(
|
|
66455
|
-
var result = equalArrays(convert(
|
|
66456
|
-
stack["delete"](
|
|
63052
|
+
stack.set(object, other);
|
|
63053
|
+
var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
|
|
63054
|
+
stack["delete"](object);
|
|
66457
63055
|
return result;
|
|
66458
63056
|
case symbolTag2:
|
|
66459
|
-
if (symbolValueOf) return symbolValueOf.call(
|
|
63057
|
+
if (symbolValueOf) return symbolValueOf.call(object) == symbolValueOf.call(other);
|
|
66460
63058
|
}
|
|
66461
63059
|
return false;
|
|
66462
63060
|
}
|
|
@@ -66473,9 +63071,9 @@ var require__arrayPush = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
66473
63071
|
var require__baseGetAllKeys = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
66474
63072
|
var arrayPush = require__arrayPush();
|
|
66475
63073
|
var isArray2 = require_isArray();
|
|
66476
|
-
function baseGetAllKeys(
|
|
66477
|
-
var result = keysFunc(
|
|
66478
|
-
return isArray2(
|
|
63074
|
+
function baseGetAllKeys(object, keysFunc, symbolsFunc) {
|
|
63075
|
+
var result = keysFunc(object);
|
|
63076
|
+
return isArray2(object) ? result : arrayPush(result, symbolsFunc(object));
|
|
66479
63077
|
}
|
|
66480
63078
|
module.exports = baseGetAllKeys;
|
|
66481
63079
|
}));
|
|
@@ -66501,11 +63099,11 @@ var require__getSymbols = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
66501
63099
|
var stubArray = require_stubArray();
|
|
66502
63100
|
var propertyIsEnumerable = Object.prototype.propertyIsEnumerable;
|
|
66503
63101
|
var nativeGetSymbols = Object.getOwnPropertySymbols;
|
|
66504
|
-
module.exports = !nativeGetSymbols ? stubArray : function(
|
|
66505
|
-
if (
|
|
66506
|
-
|
|
66507
|
-
return arrayFilter(nativeGetSymbols(
|
|
66508
|
-
return propertyIsEnumerable.call(
|
|
63102
|
+
module.exports = !nativeGetSymbols ? stubArray : function(object) {
|
|
63103
|
+
if (object == null) return [];
|
|
63104
|
+
object = Object(object);
|
|
63105
|
+
return arrayFilter(nativeGetSymbols(object), function(symbol) {
|
|
63106
|
+
return propertyIsEnumerable.call(object, symbol);
|
|
66509
63107
|
});
|
|
66510
63108
|
};
|
|
66511
63109
|
}));
|
|
@@ -66672,10 +63270,10 @@ var require__baseKeys = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
66672
63270
|
var isPrototype = require__isPrototype();
|
|
66673
63271
|
var nativeKeys = require__nativeKeys();
|
|
66674
63272
|
var hasOwnProperty2 = Object.prototype.hasOwnProperty;
|
|
66675
|
-
function baseKeys(
|
|
66676
|
-
if (!isPrototype(
|
|
63273
|
+
function baseKeys(object) {
|
|
63274
|
+
if (!isPrototype(object)) return nativeKeys(object);
|
|
66677
63275
|
var result = [];
|
|
66678
|
-
for (var key in Object(
|
|
63276
|
+
for (var key in Object(object)) if (hasOwnProperty2.call(object, key) && key != "constructor") result.push(key);
|
|
66679
63277
|
return result;
|
|
66680
63278
|
}
|
|
66681
63279
|
module.exports = baseKeys;
|
|
@@ -66692,8 +63290,8 @@ var require_keys = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
66692
63290
|
var arrayLikeKeys = require__arrayLikeKeys();
|
|
66693
63291
|
var baseKeys = require__baseKeys();
|
|
66694
63292
|
var isArrayLike2 = require_isArrayLike();
|
|
66695
|
-
function keys2(
|
|
66696
|
-
return isArrayLike2(
|
|
63293
|
+
function keys2(object) {
|
|
63294
|
+
return isArrayLike2(object) ? arrayLikeKeys(object) : baseKeys(object);
|
|
66697
63295
|
}
|
|
66698
63296
|
module.exports = keys2;
|
|
66699
63297
|
}));
|
|
@@ -66701,8 +63299,8 @@ var require__getAllKeys = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
66701
63299
|
var baseGetAllKeys = require__baseGetAllKeys();
|
|
66702
63300
|
var getSymbols2 = require__getSymbols();
|
|
66703
63301
|
var keys2 = require_keys();
|
|
66704
|
-
function getAllKeys(
|
|
66705
|
-
return baseGetAllKeys(
|
|
63302
|
+
function getAllKeys(object) {
|
|
63303
|
+
return baseGetAllKeys(object, keys2, getSymbols2);
|
|
66706
63304
|
}
|
|
66707
63305
|
module.exports = getAllKeys;
|
|
66708
63306
|
}));
|
|
@@ -66710,25 +63308,25 @@ var require__equalObjects = /* @__PURE__ */ __commonJSMin(((exports, module) =>
|
|
|
66710
63308
|
var getAllKeys = require__getAllKeys();
|
|
66711
63309
|
var COMPARE_PARTIAL_FLAG = 1;
|
|
66712
63310
|
var hasOwnProperty2 = Object.prototype.hasOwnProperty;
|
|
66713
|
-
function equalObjects(
|
|
66714
|
-
var isPartial = bitmask & COMPARE_PARTIAL_FLAG, objProps = getAllKeys(
|
|
63311
|
+
function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
|
|
63312
|
+
var isPartial = bitmask & COMPARE_PARTIAL_FLAG, objProps = getAllKeys(object), objLength = objProps.length;
|
|
66715
63313
|
if (objLength != getAllKeys(other).length && !isPartial) return false;
|
|
66716
63314
|
var index = objLength;
|
|
66717
63315
|
while (index--) {
|
|
66718
63316
|
var key = objProps[index];
|
|
66719
63317
|
if (!(isPartial ? key in other : hasOwnProperty2.call(other, key))) return false;
|
|
66720
63318
|
}
|
|
66721
|
-
var objStacked = stack.get(
|
|
63319
|
+
var objStacked = stack.get(object);
|
|
66722
63320
|
var othStacked = stack.get(other);
|
|
66723
|
-
if (objStacked && othStacked) return objStacked == other && othStacked ==
|
|
63321
|
+
if (objStacked && othStacked) return objStacked == other && othStacked == object;
|
|
66724
63322
|
var result = true;
|
|
66725
|
-
stack.set(
|
|
66726
|
-
stack.set(other,
|
|
63323
|
+
stack.set(object, other);
|
|
63324
|
+
stack.set(other, object);
|
|
66727
63325
|
var skipCtor = isPartial;
|
|
66728
63326
|
while (++index < objLength) {
|
|
66729
63327
|
key = objProps[index];
|
|
66730
|
-
var objValue =
|
|
66731
|
-
if (customizer) var compared = isPartial ? customizer(othValue, objValue, key, other,
|
|
63328
|
+
var objValue = object[key], othValue = other[key];
|
|
63329
|
+
if (customizer) var compared = isPartial ? customizer(othValue, objValue, key, other, object, stack) : customizer(objValue, othValue, key, object, other, stack);
|
|
66732
63330
|
if (!(compared === void 0 ? objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack) : compared)) {
|
|
66733
63331
|
result = false;
|
|
66734
63332
|
break;
|
|
@@ -66736,10 +63334,10 @@ var require__equalObjects = /* @__PURE__ */ __commonJSMin(((exports, module) =>
|
|
|
66736
63334
|
skipCtor || (skipCtor = key == "constructor");
|
|
66737
63335
|
}
|
|
66738
63336
|
if (result && !skipCtor) {
|
|
66739
|
-
var objCtor =
|
|
66740
|
-
if (objCtor != othCtor && "constructor" in
|
|
63337
|
+
var objCtor = object.constructor, othCtor = other.constructor;
|
|
63338
|
+
if (objCtor != othCtor && "constructor" in object && "constructor" in other && !(typeof objCtor == "function" && objCtor instanceof objCtor && typeof othCtor == "function" && othCtor instanceof othCtor)) result = false;
|
|
66741
63339
|
}
|
|
66742
|
-
stack["delete"](
|
|
63340
|
+
stack["delete"](object);
|
|
66743
63341
|
stack["delete"](other);
|
|
66744
63342
|
return result;
|
|
66745
63343
|
}
|
|
@@ -66809,31 +63407,31 @@ var require__baseIsEqualDeep = /* @__PURE__ */ __commonJSMin(((exports, module)
|
|
|
66809
63407
|
var arrayTag2 = "[object Array]";
|
|
66810
63408
|
var objectTag2 = "[object Object]";
|
|
66811
63409
|
var hasOwnProperty2 = Object.prototype.hasOwnProperty;
|
|
66812
|
-
function baseIsEqualDeep(
|
|
66813
|
-
var objIsArr = isArray2(
|
|
63410
|
+
function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
|
|
63411
|
+
var objIsArr = isArray2(object), othIsArr = isArray2(other), objTag = objIsArr ? arrayTag2 : getTag2(object), othTag = othIsArr ? arrayTag2 : getTag2(other);
|
|
66814
63412
|
objTag = objTag == argsTag ? objectTag2 : objTag;
|
|
66815
63413
|
othTag = othTag == argsTag ? objectTag2 : othTag;
|
|
66816
63414
|
var objIsObj = objTag == objectTag2, othIsObj = othTag == objectTag2, isSameTag = objTag == othTag;
|
|
66817
|
-
if (isSameTag && isBuffer2(
|
|
63415
|
+
if (isSameTag && isBuffer2(object)) {
|
|
66818
63416
|
if (!isBuffer2(other)) return false;
|
|
66819
63417
|
objIsArr = true;
|
|
66820
63418
|
objIsObj = false;
|
|
66821
63419
|
}
|
|
66822
63420
|
if (isSameTag && !objIsObj) {
|
|
66823
63421
|
stack || (stack = new Stack2());
|
|
66824
|
-
return objIsArr || isTypedArray2(
|
|
63422
|
+
return objIsArr || isTypedArray2(object) ? equalArrays(object, other, bitmask, customizer, equalFunc, stack) : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
|
|
66825
63423
|
}
|
|
66826
63424
|
if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
|
|
66827
|
-
var objIsWrapped = objIsObj && hasOwnProperty2.call(
|
|
63425
|
+
var objIsWrapped = objIsObj && hasOwnProperty2.call(object, "__wrapped__"), othIsWrapped = othIsObj && hasOwnProperty2.call(other, "__wrapped__");
|
|
66828
63426
|
if (objIsWrapped || othIsWrapped) {
|
|
66829
|
-
var objUnwrapped = objIsWrapped ?
|
|
63427
|
+
var objUnwrapped = objIsWrapped ? object.value() : object, othUnwrapped = othIsWrapped ? other.value() : other;
|
|
66830
63428
|
stack || (stack = new Stack2());
|
|
66831
63429
|
return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
|
|
66832
63430
|
}
|
|
66833
63431
|
}
|
|
66834
63432
|
if (!isSameTag) return false;
|
|
66835
63433
|
stack || (stack = new Stack2());
|
|
66836
|
-
return equalObjects(
|
|
63434
|
+
return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
|
|
66837
63435
|
}
|
|
66838
63436
|
module.exports = baseIsEqualDeep;
|
|
66839
63437
|
}));
|
|
@@ -66852,22 +63450,22 @@ var require__baseIsMatch = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
66852
63450
|
var baseIsEqual = require__baseIsEqual();
|
|
66853
63451
|
var COMPARE_PARTIAL_FLAG = 1;
|
|
66854
63452
|
var COMPARE_UNORDERED_FLAG = 2;
|
|
66855
|
-
function baseIsMatch(
|
|
63453
|
+
function baseIsMatch(object, source, matchData, customizer) {
|
|
66856
63454
|
var index = matchData.length, length = index, noCustomizer = !customizer;
|
|
66857
|
-
if (
|
|
66858
|
-
|
|
63455
|
+
if (object == null) return !length;
|
|
63456
|
+
object = Object(object);
|
|
66859
63457
|
while (index--) {
|
|
66860
63458
|
var data = matchData[index];
|
|
66861
|
-
if (noCustomizer && data[2] ? data[1] !==
|
|
63459
|
+
if (noCustomizer && data[2] ? data[1] !== object[data[0]] : !(data[0] in object)) return false;
|
|
66862
63460
|
}
|
|
66863
63461
|
while (++index < length) {
|
|
66864
63462
|
data = matchData[index];
|
|
66865
|
-
var key = data[0], objValue =
|
|
63463
|
+
var key = data[0], objValue = object[key], srcValue = data[1];
|
|
66866
63464
|
if (noCustomizer && data[2]) {
|
|
66867
|
-
if (objValue === void 0 && !(key in
|
|
63465
|
+
if (objValue === void 0 && !(key in object)) return false;
|
|
66868
63466
|
} else {
|
|
66869
63467
|
var stack = new Stack2();
|
|
66870
|
-
if (customizer) var result = customizer(objValue, srcValue, key,
|
|
63468
|
+
if (customizer) var result = customizer(objValue, srcValue, key, object, source, stack);
|
|
66871
63469
|
if (!(result === void 0 ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack) : result)) return false;
|
|
66872
63470
|
}
|
|
66873
63471
|
}
|
|
@@ -66885,10 +63483,10 @@ var require__isStrictComparable = /* @__PURE__ */ __commonJSMin(((exports, modul
|
|
|
66885
63483
|
var require__getMatchData = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
66886
63484
|
var isStrictComparable = require__isStrictComparable();
|
|
66887
63485
|
var keys2 = require_keys();
|
|
66888
|
-
function getMatchData(
|
|
66889
|
-
var result = keys2(
|
|
63486
|
+
function getMatchData(object) {
|
|
63487
|
+
var result = keys2(object), length = result.length;
|
|
66890
63488
|
while (length--) {
|
|
66891
|
-
var key = result[length], value =
|
|
63489
|
+
var key = result[length], value = object[key];
|
|
66892
63490
|
result[length] = [
|
|
66893
63491
|
key,
|
|
66894
63492
|
value,
|
|
@@ -66901,9 +63499,9 @@ var require__getMatchData = /* @__PURE__ */ __commonJSMin(((exports, module) =>
|
|
|
66901
63499
|
}));
|
|
66902
63500
|
var require__matchesStrictComparable = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
66903
63501
|
function matchesStrictComparable(key, srcValue) {
|
|
66904
|
-
return function(
|
|
66905
|
-
if (
|
|
66906
|
-
return
|
|
63502
|
+
return function(object) {
|
|
63503
|
+
if (object == null) return false;
|
|
63504
|
+
return object[key] === srcValue && (srcValue !== void 0 || key in Object(object));
|
|
66907
63505
|
};
|
|
66908
63506
|
}
|
|
66909
63507
|
module.exports = matchesStrictComparable;
|
|
@@ -66915,15 +63513,15 @@ var require__baseMatches = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
66915
63513
|
function baseMatches(source) {
|
|
66916
63514
|
var matchData = getMatchData(source);
|
|
66917
63515
|
if (matchData.length == 1 && matchData[0][2]) return matchesStrictComparable(matchData[0][0], matchData[0][1]);
|
|
66918
|
-
return function(
|
|
66919
|
-
return
|
|
63516
|
+
return function(object) {
|
|
63517
|
+
return object === source || baseIsMatch(object, source, matchData);
|
|
66920
63518
|
};
|
|
66921
63519
|
}
|
|
66922
63520
|
module.exports = baseMatches;
|
|
66923
63521
|
}));
|
|
66924
63522
|
var require__baseHasIn = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
66925
|
-
function baseHasIn(
|
|
66926
|
-
return
|
|
63523
|
+
function baseHasIn(object, key) {
|
|
63524
|
+
return object != null && key in Object(object);
|
|
66927
63525
|
}
|
|
66928
63526
|
module.exports = baseHasIn;
|
|
66929
63527
|
}));
|
|
@@ -66934,25 +63532,25 @@ var require__hasPath = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
66934
63532
|
var isIndex2 = require__isIndex();
|
|
66935
63533
|
var isLength2 = require_isLength();
|
|
66936
63534
|
var toKey2 = require__toKey();
|
|
66937
|
-
function hasPath(
|
|
66938
|
-
path2 = castPath(path2,
|
|
63535
|
+
function hasPath(object, path2, hasFunc) {
|
|
63536
|
+
path2 = castPath(path2, object);
|
|
66939
63537
|
var index = -1, length = path2.length, result = false;
|
|
66940
63538
|
while (++index < length) {
|
|
66941
63539
|
var key = toKey2(path2[index]);
|
|
66942
|
-
if (!(result =
|
|
66943
|
-
|
|
63540
|
+
if (!(result = object != null && hasFunc(object, key))) break;
|
|
63541
|
+
object = object[key];
|
|
66944
63542
|
}
|
|
66945
63543
|
if (result || ++index != length) return result;
|
|
66946
|
-
length =
|
|
66947
|
-
return !!length && isLength2(length) && isIndex2(key, length) && (isArray2(
|
|
63544
|
+
length = object == null ? 0 : object.length;
|
|
63545
|
+
return !!length && isLength2(length) && isIndex2(key, length) && (isArray2(object) || isArguments2(object));
|
|
66948
63546
|
}
|
|
66949
63547
|
module.exports = hasPath;
|
|
66950
63548
|
}));
|
|
66951
63549
|
var require_hasIn = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
66952
63550
|
var baseHasIn = require__baseHasIn();
|
|
66953
63551
|
var hasPath = require__hasPath();
|
|
66954
|
-
function hasIn(
|
|
66955
|
-
return
|
|
63552
|
+
function hasIn(object, path2) {
|
|
63553
|
+
return object != null && hasPath(object, path2, baseHasIn);
|
|
66956
63554
|
}
|
|
66957
63555
|
module.exports = hasIn;
|
|
66958
63556
|
}));
|
|
@@ -66968,9 +63566,9 @@ var require__baseMatchesProperty = /* @__PURE__ */ __commonJSMin(((exports, modu
|
|
|
66968
63566
|
var COMPARE_UNORDERED_FLAG = 2;
|
|
66969
63567
|
function baseMatchesProperty(path2, srcValue) {
|
|
66970
63568
|
if (isKey2(path2) && isStrictComparable(srcValue)) return matchesStrictComparable(toKey2(path2), srcValue);
|
|
66971
|
-
return function(
|
|
66972
|
-
var objValue = get2(
|
|
66973
|
-
return objValue === void 0 && objValue === srcValue ? hasIn(
|
|
63569
|
+
return function(object) {
|
|
63570
|
+
var objValue = get2(object, path2);
|
|
63571
|
+
return objValue === void 0 && objValue === srcValue ? hasIn(object, path2) : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
|
|
66974
63572
|
};
|
|
66975
63573
|
}
|
|
66976
63574
|
module.exports = baseMatchesProperty;
|
|
@@ -66983,8 +63581,8 @@ var require_identity = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
66983
63581
|
}));
|
|
66984
63582
|
var require__baseProperty = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
66985
63583
|
function baseProperty(key) {
|
|
66986
|
-
return function(
|
|
66987
|
-
return
|
|
63584
|
+
return function(object) {
|
|
63585
|
+
return object == null ? void 0 : object[key];
|
|
66988
63586
|
};
|
|
66989
63587
|
}
|
|
66990
63588
|
module.exports = baseProperty;
|
|
@@ -66992,8 +63590,8 @@ var require__baseProperty = /* @__PURE__ */ __commonJSMin(((exports, module) =>
|
|
|
66992
63590
|
var require__basePropertyDeep = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
66993
63591
|
var baseGet = require__baseGet();
|
|
66994
63592
|
function basePropertyDeep(path2) {
|
|
66995
|
-
return function(
|
|
66996
|
-
return baseGet(
|
|
63593
|
+
return function(object) {
|
|
63594
|
+
return baseGet(object, path2);
|
|
66997
63595
|
};
|
|
66998
63596
|
}
|
|
66999
63597
|
module.exports = basePropertyDeep;
|
|
@@ -67436,13 +64034,13 @@ var require__baseFlatten = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
67436
64034
|
}));
|
|
67437
64035
|
var require__createBaseFor = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
67438
64036
|
function createBaseFor(fromRight) {
|
|
67439
|
-
return function(
|
|
67440
|
-
var index = -1, iterable = Object(
|
|
64037
|
+
return function(object, iteratee2, keysFunc) {
|
|
64038
|
+
var index = -1, iterable = Object(object), props = keysFunc(object), length = props.length;
|
|
67441
64039
|
while (length--) {
|
|
67442
64040
|
var key = props[fromRight ? length : ++index];
|
|
67443
64041
|
if (iteratee2(iterable[key], key, iterable) === false) break;
|
|
67444
64042
|
}
|
|
67445
|
-
return
|
|
64043
|
+
return object;
|
|
67446
64044
|
};
|
|
67447
64045
|
}
|
|
67448
64046
|
module.exports = createBaseFor;
|
|
@@ -67453,8 +64051,8 @@ var require__baseFor = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
67453
64051
|
var require__baseForOwn = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
67454
64052
|
var baseFor = require__baseFor();
|
|
67455
64053
|
var keys2 = require_keys();
|
|
67456
|
-
function baseForOwn(
|
|
67457
|
-
return
|
|
64054
|
+
function baseForOwn(object, iteratee2) {
|
|
64055
|
+
return object && baseFor(object, iteratee2, keys2);
|
|
67458
64056
|
}
|
|
67459
64057
|
module.exports = baseForOwn;
|
|
67460
64058
|
}));
|
|
@@ -67511,8 +64109,8 @@ var require__compareAscending = /* @__PURE__ */ __commonJSMin(((exports, module)
|
|
|
67511
64109
|
}));
|
|
67512
64110
|
var require__compareMultiple = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
67513
64111
|
var compareAscending = require__compareAscending();
|
|
67514
|
-
function compareMultiple(
|
|
67515
|
-
var index = -1, objCriteria =
|
|
64112
|
+
function compareMultiple(object, other, orders) {
|
|
64113
|
+
var index = -1, objCriteria = object.criteria, othCriteria = other.criteria, length = objCriteria.length, ordersLength = orders.length;
|
|
67516
64114
|
while (++index < length) {
|
|
67517
64115
|
var result = compareAscending(objCriteria[index], othCriteria[index]);
|
|
67518
64116
|
if (result) {
|
|
@@ -67520,7 +64118,7 @@ var require__compareMultiple = /* @__PURE__ */ __commonJSMin(((exports, module)
|
|
|
67520
64118
|
return result * (orders[index] == "desc" ? -1 : 1);
|
|
67521
64119
|
}
|
|
67522
64120
|
}
|
|
67523
|
-
return
|
|
64121
|
+
return object.index - other.index;
|
|
67524
64122
|
}
|
|
67525
64123
|
module.exports = compareMultiple;
|
|
67526
64124
|
}));
|
|
@@ -67552,8 +64150,8 @@ var require__baseOrderBy = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
67552
64150
|
"index": ++index,
|
|
67553
64151
|
"value": value
|
|
67554
64152
|
};
|
|
67555
|
-
}), function(
|
|
67556
|
-
return compareMultiple(
|
|
64153
|
+
}), function(object, other) {
|
|
64154
|
+
return compareMultiple(object, other, orders);
|
|
67557
64155
|
});
|
|
67558
64156
|
}
|
|
67559
64157
|
module.exports = baseOrderBy;
|
|
@@ -67658,10 +64256,10 @@ var require__isIterateeCall = /* @__PURE__ */ __commonJSMin(((exports, module) =
|
|
|
67658
64256
|
var isArrayLike2 = require_isArrayLike();
|
|
67659
64257
|
var isIndex2 = require__isIndex();
|
|
67660
64258
|
var isObject2 = require_isObject();
|
|
67661
|
-
function isIterateeCall2(value, index,
|
|
67662
|
-
if (!isObject2(
|
|
64259
|
+
function isIterateeCall2(value, index, object) {
|
|
64260
|
+
if (!isObject2(object)) return false;
|
|
67663
64261
|
var type = typeof index;
|
|
67664
|
-
if (type == "number" ? isArrayLike2(
|
|
64262
|
+
if (type == "number" ? isArrayLike2(object) && isIndex2(index, object.length) : type == "string" && index in object) return eq2(object[index], value);
|
|
67665
64263
|
return false;
|
|
67666
64264
|
}
|
|
67667
64265
|
module.exports = isIterateeCall2;
|
|
@@ -72016,10 +68614,10 @@ function createIsCircular(areItemsEqual) {
|
|
|
72016
68614
|
function getShortTag(value) {
|
|
72017
68615
|
return value != null ? value[Symbol.toStringTag] : void 0;
|
|
72018
68616
|
}
|
|
72019
|
-
function getStrictProperties(
|
|
72020
|
-
return getOwnPropertyNames(
|
|
68617
|
+
function getStrictProperties(object) {
|
|
68618
|
+
return getOwnPropertyNames(object).concat(getOwnPropertySymbols(object));
|
|
72021
68619
|
}
|
|
72022
|
-
var hasOwn = Object.hasOwn || ((
|
|
68620
|
+
var hasOwn = Object.hasOwn || ((object, property2) => hasOwnProperty.call(object, property2));
|
|
72023
68621
|
function sameValueZeroEqual(a2, b) {
|
|
72024
68622
|
return a2 === b || !a2 && !b && a2 !== a2 && b !== b;
|
|
72025
68623
|
}
|
|
@@ -77046,14 +73644,14 @@ var ifOverflowMatches = function ifOverflowMatches2(props, value) {
|
|
|
77046
73644
|
};
|
|
77047
73645
|
var require__baseAssignValue = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
77048
73646
|
var defineProperty = require__defineProperty();
|
|
77049
|
-
function baseAssignValue(
|
|
77050
|
-
if (key == "__proto__" && defineProperty) defineProperty(
|
|
73647
|
+
function baseAssignValue(object, key, value) {
|
|
73648
|
+
if (key == "__proto__" && defineProperty) defineProperty(object, key, {
|
|
77051
73649
|
"configurable": true,
|
|
77052
73650
|
"enumerable": true,
|
|
77053
73651
|
"value": value,
|
|
77054
73652
|
"writable": true
|
|
77055
73653
|
});
|
|
77056
|
-
else
|
|
73654
|
+
else object[key] = value;
|
|
77057
73655
|
}
|
|
77058
73656
|
module.exports = baseAssignValue;
|
|
77059
73657
|
}));
|
|
@@ -77061,11 +73659,11 @@ var require_mapValues = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
77061
73659
|
var baseAssignValue = require__baseAssignValue();
|
|
77062
73660
|
var baseForOwn = require__baseForOwn();
|
|
77063
73661
|
var baseIteratee = require__baseIteratee();
|
|
77064
|
-
function mapValues(
|
|
73662
|
+
function mapValues(object, iteratee2) {
|
|
77065
73663
|
var result = {};
|
|
77066
73664
|
iteratee2 = baseIteratee(iteratee2, 3);
|
|
77067
|
-
baseForOwn(
|
|
77068
|
-
baseAssignValue(result, key, iteratee2(value, key,
|
|
73665
|
+
baseForOwn(object, function(value, key, object2) {
|
|
73666
|
+
baseAssignValue(result, key, iteratee2(value, key, object2));
|
|
77069
73667
|
});
|
|
77070
73668
|
return result;
|
|
77071
73669
|
}
|
|
@@ -85266,8 +81864,8 @@ function getLastAssistantMessageId(messages2) {
|
|
|
85266
81864
|
}
|
|
85267
81865
|
return null;
|
|
85268
81866
|
}
|
|
85269
|
-
function getMatchedRendererActivities(
|
|
85270
|
-
return activities.filter((a2) => !!(
|
|
81867
|
+
function getMatchedRendererActivities(registry, activities) {
|
|
81868
|
+
return activities.filter((a2) => !!(registry && lookupArtifactRenderer(registry, a2.toolName)));
|
|
85271
81869
|
}
|
|
85272
81870
|
var OPENUI_INLINE_SENTINEL = "]]>openui:";
|
|
85273
81871
|
var CONTENT_MARKER = `${OPENUI_INLINE_SENTINEL}content`;
|
|
@@ -86653,12 +83251,12 @@ var formatArtifactUpdatedAt = (updatedAt) => {
|
|
|
86653
83251
|
return new Intl.DateTimeFormat(void 0, { dateStyle: "medium" }).format(date2);
|
|
86654
83252
|
};
|
|
86655
83253
|
var useArtifactIcon = (type) => {
|
|
86656
|
-
const
|
|
86657
|
-
return (
|
|
83254
|
+
const registry = useArtifactRendererRegistry();
|
|
83255
|
+
return (registry ? lookupArtifactRendererByType(registry, type)?.icon : void 0) ?? /* @__PURE__ */ jsx(Boxes, { size: "1em" });
|
|
86658
83256
|
};
|
|
86659
83257
|
var useArtifactTypeLabel = (type) => {
|
|
86660
|
-
const
|
|
86661
|
-
return (
|
|
83258
|
+
const registry = useArtifactRendererRegistry();
|
|
83259
|
+
return (registry ? lookupArtifactRendererByType(registry, type)?.label : void 0) ?? prettifyType(type);
|
|
86662
83260
|
};
|
|
86663
83261
|
var ArtifactBrowserCard = ({ artifact, updatedAt, onClick }) => {
|
|
86664
83262
|
const icon2 = useArtifactIcon(artifact.type);
|
|
@@ -87123,7 +83721,7 @@ var ArtifactNav = ({ className, icon: icon2 }) => {
|
|
|
87123
83721
|
};
|
|
87124
83722
|
var ArtifactViewPage = ({ artifactId, categoryName }) => {
|
|
87125
83723
|
const storage = useArtifactStorage();
|
|
87126
|
-
const
|
|
83724
|
+
const registry = useArtifactRendererRegistry();
|
|
87127
83725
|
const { navigate } = useNav();
|
|
87128
83726
|
const selectThread = useThreadList((s2) => s2.selectThread);
|
|
87129
83727
|
const [artifact, setArtifact] = useState2(null);
|
|
@@ -87149,9 +83747,9 @@ var ArtifactViewPage = ({ artifactId, categoryName }) => {
|
|
|
87149
83747
|
navigate(void 0);
|
|
87150
83748
|
};
|
|
87151
83749
|
const renderer = useMemo2(() => {
|
|
87152
|
-
if (!artifact || !
|
|
87153
|
-
return lookupArtifactRendererByType(
|
|
87154
|
-
}, [artifact,
|
|
83750
|
+
if (!artifact || !registry) return null;
|
|
83751
|
+
return lookupArtifactRendererByType(registry, artifact.type);
|
|
83752
|
+
}, [artifact, registry]);
|
|
87155
83753
|
const parsed = useMemo2(() => {
|
|
87156
83754
|
if (!artifact || !renderer) return null;
|
|
87157
83755
|
return renderer.parser({
|
|
@@ -90224,8 +86822,8 @@ var WorkspaceItem = ({ entry }) => {
|
|
|
90224
86822
|
})]
|
|
90225
86823
|
}) });
|
|
90226
86824
|
};
|
|
90227
|
-
function latestPerId(
|
|
90228
|
-
return Object.values(
|
|
86825
|
+
function latestPerId(registry) {
|
|
86826
|
+
return Object.values(registry).map((versions) => versions[versions.length - 1]).filter((entry) => entry !== void 0);
|
|
90229
86827
|
}
|
|
90230
86828
|
function entryMatchesCategory(entry, category) {
|
|
90231
86829
|
return category.filter.type.includes(entry.type);
|