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