@voltro/client 0.84.0 → 0.86.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1215 -0
- package/THIRD-PARTY-NOTICES.md +5 -89
- package/dist/analyticsCatalog.js +47 -0
- package/dist/apiConnectivity.js +33 -0
- package/dist/apiRuntime.js +135 -0
- package/dist/apiSupervisor.js +125 -0
- package/dist/authRefresh.js +20 -0
- package/dist/awaitResolvedApi.js +23 -0
- package/dist/bootstrap.d.ts +1144 -0
- package/dist/bootstrap.js +8 -0
- package/dist/cellMerger.js +6 -0
- package/dist/clientDiagnostics.js +94 -0
- package/dist/clientErrorBus.js +16 -0
- package/dist/clientScheduler.js +31 -0
- package/dist/connectionPrerequisite.js +70 -0
- package/dist/connectionScope.js +35 -0
- package/dist/connectionSetupController.js +206 -0
- package/dist/createHooks.js +15 -0
- package/dist/deepLink.js +69 -0
- package/dist/filters.js +58 -0
- package/dist/form.d.ts +8 -11
- package/dist/form.js +5 -2
- package/dist/formBinding.js +325 -0
- package/dist/formData.js +65 -0
- package/dist/formFlashId.js +4 -0
- package/dist/frameworkRuntimesContext.js +8 -0
- package/dist/globalContext.js +10 -0
- package/dist/index.d.ts +285 -279
- package/dist/index.js +83 -3686
- package/dist/liveRowSort.js +66 -0
- package/dist/mutationConnectionSetup.js +16 -0
- package/dist/mutationIdentity.js +10 -0
- package/dist/mutationSerialExecution.js +53 -0
- package/dist/mutationsBus.js +40 -0
- package/dist/onlineSource.js +13 -0
- package/dist/outbox.js +213 -0
- package/dist/outboxHttp.js +104 -0
- package/dist/outboxState.js +43 -0
- package/dist/permissions.js +20 -0
- package/dist/platform.js +121 -0
- package/dist/preloadSeed.js +47 -0
- package/dist/provider.js +22 -0
- package/dist/query.js +12 -2
- package/dist/recoveryCoordinator.js +195 -0
- package/dist/recoveryRetry.js +24 -0
- package/dist/richText.js +176 -0
- package/dist/rpcErrorBus.js +39 -0
- package/dist/rpcErrorKind.js +13 -0
- package/dist/runRpc.js +12 -0
- package/dist/runtime.d.ts +79 -15
- package/dist/runtime.js +16 -129
- package/dist/runtimeCapabilities.js +44 -0
- package/dist/runtimeContext.js +49 -0
- package/dist/schemaFields.js +219 -0
- package/dist/scopeMembership.js +12 -0
- package/dist/seedResolvers.js +7 -0
- package/dist/sequence.js +65 -0
- package/dist/serverRequest.js +24 -0
- package/dist/serviceClient.js +128 -0
- package/dist/squashRpcCause.js +8 -0
- package/dist/stableKey.js +21 -0
- package/dist/store.js +288 -0
- package/dist/storeStorage.js +28 -0
- package/dist/subscriptionCache.js +724 -0
- package/dist/tagWalk.js +23 -0
- package/dist/traceBus.js +10 -0
- package/dist/tracking.js +40 -0
- package/dist/uploadProgress.js +21 -0
- package/dist/useAction.js +101 -0
- package/dist/useAgent.js +53 -0
- package/dist/useAgentChat.js +43 -0
- package/dist/useAgentStream.js +64 -0
- package/dist/useApiOnline.js +14 -0
- package/dist/useCapabilityManifest.js +101 -0
- package/dist/useConnectionSetup.js +28 -0
- package/dist/useConnectionStatus.js +38 -0
- package/dist/useConnections.js +107 -0
- package/dist/useDataCopilot.js +24 -0
- package/dist/useDataTable.js +34 -0
- package/dist/useDerived.js +22 -0
- package/dist/useEvent.js +88 -0
- package/dist/useFormBinding.js +476 -0
- package/dist/useLocalQuery.js +59 -0
- package/dist/useMutation.js +214 -0
- package/dist/useOnRpcError.js +13 -0
- package/dist/usePreloadedSubscription.js +18 -0
- package/dist/usePreview.js +14 -0
- package/dist/useProvenance.js +51 -0
- package/dist/useQueryField.js +34 -0
- package/dist/useRecord.js +12 -0
- package/dist/useRefreshSubscriptions.js +22 -0
- package/dist/useResourceCan.js +18 -0
- package/dist/useResumableAgentStream.js +75 -0
- package/dist/useSequence.js +25 -0
- package/dist/useSkeleton.js +13 -0
- package/dist/useSubscription.js +89 -0
- package/dist/useSubscriptionHealth.js +32 -0
- package/dist/useTranscription.js +51 -0
- package/dist/useUndo.js +33 -0
- package/dist/useUndoLog.js +44 -0
- package/dist/useUpload.js +296 -0
- package/dist/useWindowedSubscription.js +65 -0
- package/dist/useWorkflow.js +284 -0
- package/dist/useWorkflowRunState.js +93 -0
- package/dist/validation.js +39 -0
- package/dist/validationMessages.js +5 -0
- package/package.json +8 -5
- package/dist/authRefresh-C4Ow8HH7.js +0 -346
- package/dist/formData-dGz5aoUR.js +0 -649
- package/dist/queryOnce-CvdopzOj.js +0 -55
- package/dist/runRpc-DvHpFZAZ.js +0 -1034
package/dist/index.js
CHANGED
|
@@ -1,3687 +1,84 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
get: () => n,
|
|
84
|
-
batch: (e, r) => {
|
|
85
|
-
a === 0 && (o = n, s = e), a += 1;
|
|
86
|
-
let i;
|
|
87
|
-
try {
|
|
88
|
-
i = r();
|
|
89
|
-
} catch (e) {
|
|
90
|
-
throw a === 1 && o !== void 0 && (n = o), --a, a === 0 && (o = void 0, s = void 0), e;
|
|
91
|
-
}
|
|
92
|
-
if (typeof i?.then == "function") throw a === 1 && o !== void 0 && (n = o), --a, a === 0 && (o = void 0, s = void 0), Error(`defineStore: batch('${e}') was given an async function. A batch is synchronous — everything after the first await would land outside it. Await the work first, then batch the writes: \`const r = await load(); store.batch('${e}', () => { … })\`.`);
|
|
93
|
-
if (--a, a > 0) return;
|
|
94
|
-
let l = o, u = s;
|
|
95
|
-
o = void 0, s = void 0, !pt(l, n) && (t(l, n, u), c());
|
|
96
|
-
},
|
|
97
|
-
set: (e, r) => {
|
|
98
|
-
let i = typeof e == "function" ? e(n) : {
|
|
99
|
-
...n,
|
|
100
|
-
...e
|
|
101
|
-
};
|
|
102
|
-
if (pt(i, n)) return;
|
|
103
|
-
let o = n;
|
|
104
|
-
n = i, !(a > 0) && (t(o, i, r), c());
|
|
105
|
-
},
|
|
106
|
-
reset: () => {
|
|
107
|
-
let r = e();
|
|
108
|
-
if (pt(r, n)) return;
|
|
109
|
-
let i = n;
|
|
110
|
-
n = r, !(a > 0) && (t(i, r, "reset"), c());
|
|
111
|
-
},
|
|
112
|
-
subscribe: (e) => (r.add(e), () => {
|
|
113
|
-
r.delete(e);
|
|
114
|
-
})
|
|
115
|
-
};
|
|
116
|
-
}, xt = 200, St = [], Ct = /* @__PURE__ */ new Set(), wt = [], Tt = () => wt, Et = (e) => (Ct.add(e), () => {
|
|
117
|
-
Ct.delete(e);
|
|
118
|
-
}), Dt = () => {
|
|
119
|
-
St.length = 0, wt = [];
|
|
120
|
-
}, Ot = (e, t) => {
|
|
121
|
-
let n = St[e];
|
|
122
|
-
if (n === void 0) return !1;
|
|
123
|
-
let r = Mt.get(n.store);
|
|
124
|
-
if (r === void 0) return !1;
|
|
125
|
-
let i = t === "before" ? n.prev : n.next;
|
|
126
|
-
At = !0;
|
|
127
|
-
try {
|
|
128
|
-
r.set(() => i, n.key, `travel:${t}`);
|
|
129
|
-
} finally {
|
|
130
|
-
At = !1;
|
|
131
|
-
}
|
|
132
|
-
return !0;
|
|
133
|
-
}, kt = !1, At = !1, jt = (e) => {
|
|
134
|
-
St.push(e), St.length > xt && St.shift(), wt = [...St];
|
|
135
|
-
for (let e of [...Ct]) e();
|
|
136
|
-
}, Mt = /* @__PURE__ */ new Map(), Nt = /* @__PURE__ */ new Map(), Pt = 0, Ft = !1, It = /* @__PURE__ */ new Map(), Lt = () => (Ft || (Ft = !0, queueMicrotask(() => {
|
|
137
|
-
Pt += 1, Ft = !1;
|
|
138
|
-
})), Pt), Rt = zt(((/* @__PURE__ */ Error()).stack ?? "").split("\n")[1] ?? "") ?? "";
|
|
139
|
-
function zt(e) {
|
|
140
|
-
let t = e.trim().replace(/^at\s+/, ""), n = /\(([^()]+)\)\s*$/.exec(t)?.[1] ?? t;
|
|
141
|
-
return n.length > 0 ? n : void 0;
|
|
142
|
-
}
|
|
143
|
-
var Bt = () => {
|
|
144
|
-
let e = (/* @__PURE__ */ Error()).stack;
|
|
145
|
-
if (typeof e != "string") return "<unknown>";
|
|
146
|
-
for (let t of e.split("\n").slice(1)) {
|
|
147
|
-
let e = zt(t);
|
|
148
|
-
if (e === void 0) continue;
|
|
149
|
-
let n = e.replace(/:\d+:\d+$/, "");
|
|
150
|
-
if (Rt === "" || n !== Rt.replace(/:\d+:\d+$/, "")) return n;
|
|
151
|
-
}
|
|
152
|
-
return "<unknown>";
|
|
153
|
-
}, Vt = () => [...Mt.values()], Ht = (e, t, n) => {
|
|
154
|
-
let r = Bt(), i = Lt(), a = Mt.get(e);
|
|
155
|
-
if (a !== void 0) {
|
|
156
|
-
let t = Nt.get(e) ?? "<unknown>", n = It.get(e) === i;
|
|
157
|
-
if (r !== "<unknown>" && r === t && !n) return a;
|
|
158
|
-
throw Error(`defineStore: '${e}' is already defined. Store names are the devtools + seed key, so two stores sharing one name would silently share state. Rename one.\n first: ${t}\n second: ${r}`);
|
|
159
|
-
}
|
|
160
|
-
let o = n?.persist, s = () => dt(o?.storage === "session" ? "session" : "local"), c = () => {
|
|
161
|
-
let e = s();
|
|
162
|
-
if (e === null || o === void 0) return;
|
|
163
|
-
let t;
|
|
164
|
-
try {
|
|
165
|
-
t = e.getItem(o.key);
|
|
166
|
-
} catch {
|
|
167
|
-
return;
|
|
168
|
-
}
|
|
169
|
-
if (t === null) return;
|
|
170
|
-
let n;
|
|
171
|
-
try {
|
|
172
|
-
n = JSON.parse(t);
|
|
173
|
-
} catch {
|
|
174
|
-
return;
|
|
175
|
-
}
|
|
176
|
-
return o.migrate ? o.migrate(n) : n;
|
|
177
|
-
}, l = (e) => {
|
|
178
|
-
let t = s();
|
|
179
|
-
if (t === null || o === void 0) return;
|
|
180
|
-
let n = o.pick ? o.pick(e) : e;
|
|
181
|
-
try {
|
|
182
|
-
t.setItem(o.key, JSON.stringify(n));
|
|
183
|
-
} catch {}
|
|
184
|
-
}, u = /* @__PURE__ */ new Map(), d = (n) => {
|
|
185
|
-
let r = n ?? _t, i = u.get(r);
|
|
186
|
-
if (i === void 0) {
|
|
187
|
-
let a = n;
|
|
188
|
-
i = bt(o !== void 0 && n === void 0 ? () => {
|
|
189
|
-
let e = t();
|
|
190
|
-
return f = e, {
|
|
191
|
-
...e,
|
|
192
|
-
...c() ?? {}
|
|
193
|
-
};
|
|
194
|
-
} : t, (t, n, r) => {
|
|
195
|
-
if (o !== void 0 && a === void 0 && l(n), !kt && !At) {
|
|
196
|
-
let e = m(a);
|
|
197
|
-
e.steps.length = e.cursor, e.steps.push({
|
|
198
|
-
prev: t,
|
|
199
|
-
next: n
|
|
200
|
-
}), e.steps.length > h && e.steps.shift(), e.cursor = e.steps.length;
|
|
201
|
-
}
|
|
202
|
-
jt({
|
|
203
|
-
store: e,
|
|
204
|
-
...a === void 0 ? {} : { key: a },
|
|
205
|
-
...r === void 0 ? {} : { label: r },
|
|
206
|
-
...kt || At ? { isUndo: !0 } : {},
|
|
207
|
-
prev: t,
|
|
208
|
-
next: n,
|
|
209
|
-
at: Date.now()
|
|
210
|
-
});
|
|
211
|
-
}), u.set(r, i);
|
|
212
|
-
}
|
|
213
|
-
return i;
|
|
214
|
-
}, f, p = /* @__PURE__ */ new Map(), m = (e) => {
|
|
215
|
-
let t = e ?? _t, n = p.get(t);
|
|
216
|
-
return n === void 0 && (n = {
|
|
217
|
-
steps: [],
|
|
218
|
-
cursor: 0
|
|
219
|
-
}, p.set(t, n)), n;
|
|
220
|
-
}, h = 100, g = /* @__PURE__ */ new Map(), _ = /* @__PURE__ */ new Map(), v = (e) => {
|
|
221
|
-
let t = _.get(e);
|
|
222
|
-
t !== void 0 && (clearTimeout(t), _.delete(e)), g.set(e, (g.get(e) ?? 0) + 1);
|
|
223
|
-
}, y = (e) => {
|
|
224
|
-
let t = (g.get(e) ?? 1) - 1;
|
|
225
|
-
if (t > 0) {
|
|
226
|
-
g.set(e, t);
|
|
227
|
-
return;
|
|
228
|
-
}
|
|
229
|
-
g.delete(e), _.set(e, setTimeout(() => {
|
|
230
|
-
_.delete(e), (g.get(e) ?? 0) === 0 && u.delete(e);
|
|
231
|
-
}, 0));
|
|
232
|
-
}, b = {
|
|
233
|
-
name: e,
|
|
234
|
-
use: (t, n) => {
|
|
235
|
-
let r = d(n?.key), i = U(t);
|
|
236
|
-
i.current = t;
|
|
237
|
-
let a = U(n?.equals);
|
|
238
|
-
a.current = n?.equals;
|
|
239
|
-
let o = U({
|
|
240
|
-
state: void 0,
|
|
241
|
-
value: void 0,
|
|
242
|
-
has: !1
|
|
243
|
-
}), s = B((t) => {
|
|
244
|
-
let n = o.current;
|
|
245
|
-
if (n.has && Object.is(n.state, t)) return n.value;
|
|
246
|
-
let r = i.current(t), s = a.current, c = n.has && (s ? s(n.value, r) : Object.is(n.value, r));
|
|
247
|
-
if (process.env.NODE_ENV !== "production" && s === void 0 && n.has && !c && typeof r == "object" && r && pt(n.value, r)) {
|
|
248
|
-
let t = !0;
|
|
249
|
-
try {
|
|
250
|
-
t = !Object.is(i.current(n.state), n.value);
|
|
251
|
-
} catch {}
|
|
252
|
-
gt(e, t ? `[@voltro/client] ${e}.use(): the selector returns a NEW object each call, so the default identity check never sees it as unchanged and this component re-renders on EVERY store change.\n Pass \`{ equals: shallow }\` (exported from @voltro/client), or select a primitive.` : `[@voltro/client] ${e}.use(): this component re-renders on store changes that do not change what it selects. The selector is stable — it returns the same reference for the same state — and the STORE is writing a new value that is equal one level deep (a fresh \`[]\` or \`{}\`, say).\n Pass \`{ equals: shallow }\` (exported from @voltro/client), or stop writing an equal value.`);
|
|
253
|
-
}
|
|
254
|
-
let l = c ? n.value : r;
|
|
255
|
-
return o.current = {
|
|
256
|
-
state: t,
|
|
257
|
-
value: l,
|
|
258
|
-
has: !0
|
|
259
|
-
}, l;
|
|
260
|
-
}, []), c = n?.key, l = n?.retain === !0, u = B((e) => {
|
|
261
|
-
let t = r.subscribe(e);
|
|
262
|
-
return c !== void 0 && !l && v(c), () => {
|
|
263
|
-
t(), c !== void 0 && !l && y(c);
|
|
264
|
-
};
|
|
265
|
-
}, [
|
|
266
|
-
r,
|
|
267
|
-
c,
|
|
268
|
-
l
|
|
269
|
-
]), p = B(() => s(r.get()), [r, s]), m = B(() => s(yt(e, n?.key, n?.key === void 0 && f !== void 0 ? f : r.get())), [
|
|
270
|
-
r,
|
|
271
|
-
n?.key,
|
|
272
|
-
s
|
|
273
|
-
]), h = G(u, p, m);
|
|
274
|
-
return Fe(h), h;
|
|
275
|
-
},
|
|
276
|
-
instance: d,
|
|
277
|
-
get: (e) => d(e).get(),
|
|
278
|
-
set: (e, t, n) => {
|
|
279
|
-
d(t).set(e, n);
|
|
280
|
-
},
|
|
281
|
-
batch: (e, t, n) => {
|
|
282
|
-
d(n).batch(e, t);
|
|
283
|
-
},
|
|
284
|
-
undo: (e) => {
|
|
285
|
-
let t = m(e);
|
|
286
|
-
if (t.cursor === 0) return !1;
|
|
287
|
-
--t.cursor, kt = !0;
|
|
288
|
-
try {
|
|
289
|
-
d(e).set(() => t.steps[t.cursor].prev, "undo");
|
|
290
|
-
} finally {
|
|
291
|
-
kt = !1;
|
|
292
|
-
}
|
|
293
|
-
return !0;
|
|
294
|
-
},
|
|
295
|
-
redo: (e) => {
|
|
296
|
-
let t = m(e);
|
|
297
|
-
if (t.cursor >= t.steps.length) return !1;
|
|
298
|
-
let n = t.steps[t.cursor];
|
|
299
|
-
t.cursor += 1, kt = !0;
|
|
300
|
-
try {
|
|
301
|
-
d(e).set(() => n.next, "redo");
|
|
302
|
-
} finally {
|
|
303
|
-
kt = !1;
|
|
304
|
-
}
|
|
305
|
-
return !0;
|
|
306
|
-
},
|
|
307
|
-
canUndo: (e) => m(e).cursor > 0,
|
|
308
|
-
canRedo: (e) => {
|
|
309
|
-
let t = m(e);
|
|
310
|
-
return t.cursor < t.steps.length;
|
|
311
|
-
},
|
|
312
|
-
release: (e) => {
|
|
313
|
-
u.delete(e), p.delete(e);
|
|
314
|
-
},
|
|
315
|
-
keys: () => [...u.keys()].filter((e) => e !== _t)
|
|
316
|
-
};
|
|
317
|
-
return Mt.set(e, b), Nt.set(e, r), It.set(e, i), b;
|
|
318
|
-
}, Ut = () => {
|
|
319
|
-
Mt.clear(), Nt.clear(), It.clear(), ht.clear();
|
|
320
|
-
}, Wt = () => ({ seeds: [] }), Gt = (e) => {
|
|
321
|
-
vt = e;
|
|
322
|
-
}, Kt = (e, t, n) => {
|
|
323
|
-
let r = vt?.() ?? null;
|
|
324
|
-
if (r === null) throw Error(`seedStore('${e.name}') was called outside a server render. Seeding exists to put a value into the SSR hydration payload; on the client, set the store directly instead. (If this IS server code, the render did not install a seed bag — that is a framework bug.)`);
|
|
325
|
-
r.seeds.push({
|
|
326
|
-
store: e.name,
|
|
327
|
-
...n?.key === void 0 ? {} : { key: n.key },
|
|
328
|
-
value: t
|
|
329
|
-
});
|
|
330
|
-
}, qt = (e) => {
|
|
331
|
-
if (e !== void 0) for (let t of e) {
|
|
332
|
-
let e = Mt.get(t.store);
|
|
333
|
-
e !== void 0 && e.set(t.value, t.key);
|
|
334
|
-
}
|
|
335
|
-
}, Jt = {
|
|
336
|
-
read: () => typeof navigator > "u" || navigator.onLine,
|
|
337
|
-
subscribe: (e) => {
|
|
338
|
-
if (typeof window > "u") return () => {};
|
|
339
|
-
let t = () => e(!0), n = () => e(!1);
|
|
340
|
-
return window.addEventListener("online", t), window.addEventListener("offline", n), () => {
|
|
341
|
-
window.removeEventListener("online", t), window.removeEventListener("offline", n);
|
|
342
|
-
};
|
|
343
|
-
}
|
|
344
|
-
}, Yt = (e, t = {}) => {
|
|
345
|
-
let n = e.platform.shell !== "browser" && e.platform.shell !== "node" && e.platform.shell !== "test";
|
|
346
|
-
return {
|
|
347
|
-
offlineStart: e.platform.installed || n,
|
|
348
|
-
secureTokenStorage: e.secureStorage.kind !== "none",
|
|
349
|
-
push: e.notifications?.pushToken !== void 0,
|
|
350
|
-
localNotifications: e.notifications?.show !== void 0,
|
|
351
|
-
updates: e.updates !== void 0,
|
|
352
|
-
deepLinks: !0,
|
|
353
|
-
biometrics: e.biometrics !== void 0,
|
|
354
|
-
backgroundSync: e.platform.shell === "tauri" || e.platform.shell === "electron",
|
|
355
|
-
installPrompt: e.platform.shell === "browser" && !e.platform.installed,
|
|
356
|
-
...t
|
|
357
|
-
};
|
|
358
|
-
}, Xt = (e) => {
|
|
359
|
-
let { capabilities: t, ...n } = e;
|
|
360
|
-
return {
|
|
361
|
-
...n,
|
|
362
|
-
capabilities: Yt(n, t)
|
|
363
|
-
};
|
|
364
|
-
}, Zt = (e) => ({
|
|
365
|
-
kind: "none",
|
|
366
|
-
get: async () => null,
|
|
367
|
-
set: async () => {
|
|
368
|
-
throw Error(`secureStorage: ${e}`);
|
|
369
|
-
},
|
|
370
|
-
delete: async () => {}
|
|
371
|
-
}), Qt = () => {
|
|
372
|
-
let e = /* @__PURE__ */ new Map();
|
|
373
|
-
return {
|
|
374
|
-
kind: "memory",
|
|
375
|
-
get: async (t) => e.get(t) ?? null,
|
|
376
|
-
set: async (t, n) => {
|
|
377
|
-
e.set(t, n);
|
|
378
|
-
},
|
|
379
|
-
delete: async (t) => {
|
|
380
|
-
e.delete(t);
|
|
381
|
-
}
|
|
382
|
-
};
|
|
383
|
-
}, $t = {
|
|
384
|
-
read: () => typeof document > "u" ? "active" : document.visibilityState === "hidden" ? "background" : "active",
|
|
385
|
-
subscribe: (e) => {
|
|
386
|
-
if (typeof document > "u") return () => {};
|
|
387
|
-
let t = () => e(document.visibilityState === "hidden" ? "background" : "active");
|
|
388
|
-
return document.addEventListener("visibilitychange", t), () => document.removeEventListener("visibilitychange", t);
|
|
389
|
-
}
|
|
390
|
-
}, en = {
|
|
391
|
-
initialUrl: async () => typeof location > "u" ? null : location.href,
|
|
392
|
-
subscribe: () => () => {}
|
|
393
|
-
}, tn = () => {
|
|
394
|
-
if (typeof Notification > "u") return;
|
|
395
|
-
let e = (e) => e === "granted" ? "granted" : e === "denied" ? "denied" : "prompt";
|
|
396
|
-
return {
|
|
397
|
-
permission: async () => e(Notification.permission),
|
|
398
|
-
requestPermission: async () => e(await Notification.requestPermission()),
|
|
399
|
-
show: async (e) => {
|
|
400
|
-
new Notification(e.title, {
|
|
401
|
-
...e.body === void 0 ? {} : { body: e.body },
|
|
402
|
-
...e.data === void 0 ? {} : { data: e.data }
|
|
403
|
-
});
|
|
404
|
-
}
|
|
405
|
-
};
|
|
406
|
-
}, nn = () => {
|
|
407
|
-
if (typeof window > "u") return !1;
|
|
408
|
-
let e = window.matchMedia;
|
|
409
|
-
return typeof e == "function" && e.call(window, "(display-mode: standalone)").matches ? !0 : navigator.standalone === !0;
|
|
410
|
-
}, rn = (e, t) => {
|
|
411
|
-
let n = globalThis.WebSocket;
|
|
412
|
-
if (n === void 0) throw Error("platform: no global WebSocket in this environment");
|
|
413
|
-
return t === void 0 ? new n(e) : new n(e, t);
|
|
414
|
-
}, an = (e = {}) => {
|
|
415
|
-
let t = typeof window < "u", n = nn(), r = t ? navigator.userAgent : "", i = t ? /jsdom/i.test(r) ? "test" : "browser" : "node", a = tn();
|
|
416
|
-
return Xt({
|
|
417
|
-
platform: {
|
|
418
|
-
kind: n ? "pwa" : "web",
|
|
419
|
-
shell: i,
|
|
420
|
-
installed: n
|
|
421
|
-
},
|
|
422
|
-
webSocket: rn,
|
|
423
|
-
storage: lt,
|
|
424
|
-
secureStorage: Zt("a browser tab has no secure store a page can read; the session is an HttpOnly cookie the server sets"),
|
|
425
|
-
online: Jt,
|
|
426
|
-
lifecycle: $t,
|
|
427
|
-
links: en,
|
|
428
|
-
...a === void 0 ? {} : { notifications: a },
|
|
429
|
-
clock: { now: () => Date.now() },
|
|
430
|
-
...e
|
|
431
|
-
});
|
|
432
|
-
}, on = Symbol.for("@voltro/client/platform"), sn = () => {
|
|
433
|
-
let e = globalThis, t = e[on];
|
|
434
|
-
if (t !== void 0) return t;
|
|
435
|
-
let n = {
|
|
436
|
-
adapter: void 0,
|
|
437
|
-
fallback: void 0,
|
|
438
|
-
listeners: /* @__PURE__ */ new Set()
|
|
439
|
-
};
|
|
440
|
-
return e[on] = n, n;
|
|
441
|
-
}, cn = (e) => {
|
|
442
|
-
let t = sn();
|
|
443
|
-
t.adapter = e, ut(e.storage);
|
|
444
|
-
for (let e of t.listeners) e();
|
|
445
|
-
}, ln = () => {
|
|
446
|
-
let e = sn();
|
|
447
|
-
return e.adapter === void 0 ? (e.fallback === void 0 && (e.fallback = an()), e.fallback) : e.adapter;
|
|
448
|
-
}, un = () => sn().adapter !== void 0, dn = () => {
|
|
449
|
-
let e = sn();
|
|
450
|
-
e.adapter = void 0, e.fallback = void 0, ut(null);
|
|
451
|
-
for (let t of e.listeners) t();
|
|
452
|
-
}, fn = (e) => {
|
|
453
|
-
let t = sn();
|
|
454
|
-
return t.listeners.add(e), () => {
|
|
455
|
-
t.listeners.delete(e);
|
|
456
|
-
};
|
|
457
|
-
}, pn = () => G(fn, ln, ln), mn = (e) => pn().extensions?.[e] ?? null, hn = (e) => {
|
|
458
|
-
let t = e.pattern;
|
|
459
|
-
if (t.length === 0 || t[0] !== "/") throw Error(`defineDeepLink: pattern must start with "/" (got "${t}")`);
|
|
460
|
-
return {
|
|
461
|
-
_tag: "VoltroDeepLink",
|
|
462
|
-
pattern: t,
|
|
463
|
-
handler: e.handler
|
|
464
|
-
};
|
|
465
|
-
}, gn = (e) => {
|
|
466
|
-
let t = e, n = /^([a-zA-Z][a-zA-Z0-9+.-]*):\/\//.exec(t);
|
|
467
|
-
if (n) {
|
|
468
|
-
let e = t.slice(n[0].length), r = n[1].toLowerCase();
|
|
469
|
-
if (r === "http" || r === "https") {
|
|
470
|
-
let n = e.indexOf("/");
|
|
471
|
-
t = n === -1 ? "/" : e.slice(n);
|
|
472
|
-
} else t = `/${e}`;
|
|
473
|
-
}
|
|
474
|
-
let r = t.search(/[?#]/);
|
|
475
|
-
return r !== -1 && (t = t.slice(0, r)), t.split("/").filter((e) => e.length > 0).map((e) => {
|
|
476
|
-
try {
|
|
477
|
-
return decodeURIComponent(e);
|
|
478
|
-
} catch {
|
|
479
|
-
return e;
|
|
480
|
-
}
|
|
481
|
-
});
|
|
482
|
-
}, _n = (e, t) => {
|
|
483
|
-
let n = gn(e), r = gn(t);
|
|
484
|
-
if (n.length !== r.length) return null;
|
|
485
|
-
let i = {};
|
|
486
|
-
for (let e = 0; e < n.length; e++) {
|
|
487
|
-
let t = n[e], a = r[e];
|
|
488
|
-
if (t.startsWith(":")) {
|
|
489
|
-
let e = t.slice(1);
|
|
490
|
-
if (e.length === 0) return null;
|
|
491
|
-
i[e] = a;
|
|
492
|
-
} else if (t !== "*" && t !== a) return null;
|
|
493
|
-
}
|
|
494
|
-
return i;
|
|
495
|
-
}, vn = (e, t) => {
|
|
496
|
-
let n = _n(e.pattern, t);
|
|
497
|
-
return n === null ? null : (e.handler(n), n);
|
|
498
|
-
}, yn = (e, t) => {
|
|
499
|
-
let n = e.split("/").map((n) => {
|
|
500
|
-
if (!n.startsWith(":")) return n;
|
|
501
|
-
let r = n.slice(1), i = t[r];
|
|
502
|
-
if (i === void 0) throw Error(`deepLinkHref: pattern "${e}" needs a ":${r}" param`);
|
|
503
|
-
return encodeURIComponent(i);
|
|
504
|
-
}).join("/");
|
|
505
|
-
return n.length === 0 ? "/" : n;
|
|
506
|
-
}, bn = (e, t) => {
|
|
507
|
-
for (let n of e) {
|
|
508
|
-
let e = _n(n.pattern, t);
|
|
509
|
-
if (e !== null) return {
|
|
510
|
-
descriptor: n,
|
|
511
|
-
params: e
|
|
512
|
-
};
|
|
513
|
-
}
|
|
514
|
-
return null;
|
|
515
|
-
}, xn = (e, t) => {
|
|
516
|
-
let n = bn(e, t);
|
|
517
|
-
if (n === null) return null;
|
|
518
|
-
let r = n.descriptor.handler;
|
|
519
|
-
return r(n.params), n.params;
|
|
520
|
-
}, Sn = Object.freeze({
|
|
521
|
-
data: void 0,
|
|
522
|
-
revision: -1,
|
|
523
|
-
emittedAt: void 0,
|
|
524
|
-
error: void 0,
|
|
525
|
-
pendingPatches: 0
|
|
526
|
-
}), Cn = () => Sn;
|
|
527
|
-
function J(e, t, n = {}, r = {}) {
|
|
528
|
-
let i = r.skip === !0, { runtime: a, cache: o, client: s, descriptors: c } = k(e), l = c[t]?.source, u = U(n);
|
|
529
|
-
u.current = n;
|
|
530
|
-
let d = U(s);
|
|
531
|
-
d.current = s;
|
|
532
|
-
let f = H(() => JSON.stringify(Object.entries(n).sort(([e], [t]) => e.localeCompare(t))), [n]), p = H(() => {
|
|
533
|
-
let e = u.current;
|
|
534
|
-
return {
|
|
535
|
-
queryKey: [t, e],
|
|
536
|
-
fetch: () => v(d.current, t)(e)
|
|
537
|
-
};
|
|
538
|
-
}, [t, f]), m = p.queryKey, h = B((e) => i ? () => {} : o.subscribe(p.queryKey, p.fetch, a, e, l === void 0 ? {} : { source: l }).unsubscribe, [
|
|
539
|
-
o,
|
|
540
|
-
a,
|
|
541
|
-
l,
|
|
542
|
-
i,
|
|
543
|
-
p
|
|
544
|
-
]), g = B(() => i ? Sn : o.peek(m), [
|
|
545
|
-
o,
|
|
546
|
-
i,
|
|
547
|
-
m
|
|
548
|
-
]), _ = G(h, g, Cn), y = _.data !== void 0, b = y && (Array.isArray(_.data) ? _.data.length === 0 : _.data === null), x = {
|
|
549
|
-
revision: _.revision,
|
|
550
|
-
emittedAt: _.emittedAt,
|
|
551
|
-
error: _.error,
|
|
552
|
-
pendingPatches: _.pendingPatches
|
|
553
|
-
};
|
|
554
|
-
if (r.initialSnapshot !== void 0) {
|
|
555
|
-
let e = Array.isArray(r.initialSnapshot) ? r.initialSnapshot.length === 0 : r.initialSnapshot === null;
|
|
556
|
-
return {
|
|
557
|
-
...x,
|
|
558
|
-
data: y ? _.data : r.initialSnapshot,
|
|
559
|
-
loading: !1,
|
|
560
|
-
idle: i,
|
|
561
|
-
isEmpty: y ? b : e,
|
|
562
|
-
failed: !1
|
|
563
|
-
};
|
|
564
|
-
}
|
|
565
|
-
return r.fallback === void 0 ? i ? {
|
|
566
|
-
...x,
|
|
567
|
-
data: void 0,
|
|
568
|
-
loading: !1,
|
|
569
|
-
isEmpty: !1,
|
|
570
|
-
idle: !0,
|
|
571
|
-
failed: !1
|
|
572
|
-
} : y ? {
|
|
573
|
-
...x,
|
|
574
|
-
data: _.data,
|
|
575
|
-
loading: !1,
|
|
576
|
-
isEmpty: b,
|
|
577
|
-
idle: !1,
|
|
578
|
-
failed: !1
|
|
579
|
-
} : x.error === void 0 ? {
|
|
580
|
-
...x,
|
|
581
|
-
data: void 0,
|
|
582
|
-
loading: !0,
|
|
583
|
-
isEmpty: !1,
|
|
584
|
-
idle: !1,
|
|
585
|
-
failed: !1
|
|
586
|
-
} : {
|
|
587
|
-
...x,
|
|
588
|
-
data: void 0,
|
|
589
|
-
loading: !1,
|
|
590
|
-
isEmpty: !1,
|
|
591
|
-
idle: !1,
|
|
592
|
-
failed: !0,
|
|
593
|
-
error: x.error
|
|
594
|
-
} : {
|
|
595
|
-
...x,
|
|
596
|
-
data: y ? _.data : r.fallback,
|
|
597
|
-
loading: !y && !i,
|
|
598
|
-
idle: i,
|
|
599
|
-
isEmpty: b,
|
|
600
|
-
failed: !y && x.error !== void 0
|
|
601
|
-
};
|
|
602
|
-
}
|
|
1
|
+
import { registerCellMerger as e, registeredCellMerger as t } from "./cellMerger.js";
|
|
2
|
+
import { publishClientTrace as n, subscribeClientTraces as r } from "./traceBus.js";
|
|
3
|
+
import { clearClientDiagnostics as i, clientDiagnosticsSnapshot as a, disableClientDiagnosticsPersistence as o, enableClientDiagnosticsPersistence as s, recordClientDiagnostic as c, subscribeClientDiagnostics as l } from "./clientDiagnostics.js";
|
|
4
|
+
import { stableKey as u } from "./stableKey.js";
|
|
5
|
+
import { LoadingSubscriptionCache as d, SubscriptionCache as f, supersedesConfirmedPatches as p } from "./subscriptionCache.js";
|
|
6
|
+
import { publishClientError as m, reportClientError as h, subscribeClientErrors as g } from "./clientErrorBus.js";
|
|
7
|
+
import { RpcErrorBus as _ } from "./rpcErrorBus.js";
|
|
8
|
+
import { apiConnectivity as v } from "./apiConnectivity.js";
|
|
9
|
+
import { INITIAL_RECOVERY_SNAPSHOT as y, RecoveryCoordinator as b, recoveryCoordinatorFor as x, resolveRecoveryOptions as S } from "./recoveryCoordinator.js";
|
|
10
|
+
import { globalContext as C } from "./globalContext.js";
|
|
11
|
+
import { FrameworkRuntimesContext as w, isUnresolvedApi as T, unknownApiError as E } from "./frameworkRuntimesContext.js";
|
|
12
|
+
import { _resetFrameworkRuntimesWarning as D, _resetSsrDescriptors as O, registerSsrDescriptors as k, ssrClientProxy as A, ssrDescriptorsFor as j, ssrStubHandle as M, useFrameworkApi as N, useFrameworkRuntimes as P } from "./runtimeContext.js";
|
|
13
|
+
import { resolveByTag as F } from "./tagWalk.js";
|
|
14
|
+
import { buildApiRuntime as I, makeProtocolOpenRecovery as L } from "./apiRuntime.js";
|
|
15
|
+
import { startApiSupervisor as R } from "./apiSupervisor.js";
|
|
16
|
+
import { FrameworkRuntimesProvider as z } from "./provider.js";
|
|
17
|
+
import { browserStoreStorage as B, resetStoreStorageForTest as V, resolveStoreStorage as H, setStoreStorage as U } from "./storeStorage.js";
|
|
18
|
+
import { applyStoreSeeds as W, clearStoreHistory as G, defineStore as K, definedStores as q, makeStoreSeedBag as J, resetStoreRegistryForTests as Y, seedStore as X, setStoreSeedResolver as Z, shallow as Q, storeHistory as $, subscribeStoreHistory as ee, travelToStoreState as te } from "./store.js";
|
|
19
|
+
import { browserOnlineSource as ne } from "./onlineSource.js";
|
|
20
|
+
import { browserPlatform as re, capabilitiesOf as ie, currentPlatform as ae, definePlatform as oe, installPlatform as se, isPlatformInstalled as ce, isStandaloneDisplay as le, memoryTokenStore as ue, refusingTokenStore as de, resetPlatformForTest as fe, usePlatform as pe, useShellExtension as me } from "./platform.js";
|
|
21
|
+
import { deepLinkHref as he, defineDeepLink as ge, dispatchDeepLink as _e, matchDeepLink as ve, matchFirstDeepLink as ye, runDeepLink as be } from "./deepLink.js";
|
|
22
|
+
import { useSubscription as xe } from "./useSubscription.js";
|
|
23
|
+
import { clearMutations as Se, getMutations as Ce, settleMutation as we, startMutation as Te, subscribeMutations as Ee } from "./mutationsBus.js";
|
|
24
|
+
import { freshIdempotencyKey as De, withIdempotencyKey as Oe } from "./mutationIdentity.js";
|
|
25
|
+
import { MutationSerialExecutionError as ke } from "./mutationSerialExecution.js";
|
|
26
|
+
import { getMutationNotifier as Ae, setMutationNotifier as je, useMutation as Me } from "./useMutation.js";
|
|
27
|
+
import { useAction as Ne } from "./useAction.js";
|
|
28
|
+
import { formField as Pe, formSections as Fe, schemaToColumns as Ie, schemaToFields as Le } from "./schemaFields.js";
|
|
29
|
+
import { decodeFieldIssues as Re, documentLocale as ze, resolveValidationMessage as Be, restrictToSchema as Ve, validateFields as He } from "./formBinding.js";
|
|
30
|
+
import { ValidationMessagesProvider as Ue, useValidationMessages as We } from "./validationMessages.js";
|
|
31
|
+
import { FormBindingProvider as Ge, useFormBinding as Ke, useFormBindingContext as qe, useFormField as Je, useSchemaFormBinding as Ye } from "./useFormBinding.js";
|
|
32
|
+
import { useConnectionSetup as Xe } from "./useConnectionSetup.js";
|
|
33
|
+
import { createHooks as Ze } from "./createHooks.js";
|
|
34
|
+
import { applyPreloadSeeds as Qe, makePreloadSeedBag as $e, readPreloadedSeedOutcome as et, readPreloadedSnapshot as tt, resetPreloadSeeds as nt, seedPreloadedSubscription as rt, seedPreloadedSubscriptionFailure as it, setPreloadSeedResolver as at } from "./preloadSeed.js";
|
|
35
|
+
import { usePreloadedSubscription as ot } from "./usePreloadedSubscription.js";
|
|
36
|
+
import { useEvent as st } from "./useEvent.js";
|
|
37
|
+
import { runSequence as ct, sequence as lt } from "./sequence.js";
|
|
38
|
+
import { useSequence as ut } from "./useSequence.js";
|
|
39
|
+
import { useUpload as dt } from "./useUpload.js";
|
|
40
|
+
import { useTranscription as ft } from "./useTranscription.js";
|
|
41
|
+
import { useWorkflow as pt, useWorkflowDomainEvents as mt, useWorkflowEventDeliveries as ht, useWorkflowEvents as gt, useWorkflowRun as _t, useWorkflowRunEvents as vt, useWorkflowRunSteps as yt, useWorkflowRuns as bt, useWorkflowSignal as xt, useWorkflowUpdate as St } from "./useWorkflow.js";
|
|
42
|
+
import { useWorkflowRunState as Ct } from "./useWorkflowRunState.js";
|
|
43
|
+
import { useAgentStream as wt } from "./useAgentStream.js";
|
|
44
|
+
import { resumableConsumeProgram as Tt, useResumableAgentStream as Et } from "./useResumableAgentStream.js";
|
|
45
|
+
import { useAgentChat as Dt } from "./useAgentChat.js";
|
|
46
|
+
import { useAgent as Ot } from "./useAgent.js";
|
|
47
|
+
import { useDataCopilot as kt } from "./useDataCopilot.js";
|
|
48
|
+
import { useRefreshSubscription as At, useRefreshSubscriptions as jt } from "./useRefreshSubscriptions.js";
|
|
49
|
+
import { queryOnce as Mt } from "./query.js";
|
|
50
|
+
import { isUnauthenticated as Nt, wireAuthRefresh as Pt } from "./authRefresh.js";
|
|
51
|
+
import { useOnRawRpcError as Ft, useOnRpcError as It } from "./useOnRpcError.js";
|
|
52
|
+
import { useSubscriptionHealth as Lt } from "./useSubscriptionHealth.js";
|
|
53
|
+
import { RICH_TEXT_MARKS as Rt, RICH_TEXT_MAX_NODES as zt, RichTextDocument as Bt, emptyRichTextDocument as Vt, isRichTextDocument as Ht, isSafeHref as Ut, parseRichText as Wt, richTextToPlainText as Gt, serializeRichText as Kt } from "./richText.js";
|
|
54
|
+
import { FORM_FLASH_SCRIPT_ID as qt } from "./formFlashId.js";
|
|
55
|
+
import { FORM_KEY_FIELD as Jt, FORM_PATH_PREFIX as Yt, FORM_REDIRECT_FIELD as Xt, formActionPath as Zt, formDataToInput as Qt } from "./formData.js";
|
|
56
|
+
import { ServerRequestContext as $t, ServerRequestProvider as en, useFormFlash as tn, useServerRequest as nn } from "./serverRequest.js";
|
|
57
|
+
import { rowsToOptions as rn, useQueryField as an } from "./useQueryField.js";
|
|
58
|
+
import { useDataTable as on } from "./useDataTable.js";
|
|
59
|
+
import { provenanceUrl as sn, useProvenance as cn } from "./useProvenance.js";
|
|
60
|
+
import { ADMIN_SCOPE as ln, PermissionProvider as un, canCall as dn, canCallAny as fn, useCan as pn, useCanAny as mn, usePermissions as hn } from "./permissions.js";
|
|
61
|
+
import { decideAccess as gn, deriveEntityAdmins as _n, manifestUrl as vn, openAccessReason as yn, requiredScopes as bn, useAccessDecision as xn, useCapabilityManifest as Sn } from "./useCapabilityManifest.js";
|
|
62
|
+
import { useUndo as Cn } from "./useUndo.js";
|
|
63
|
+
import { UNDO_APPLY_TAG as wn, UNDO_LOG_TAG as Tn, UNDO_REDO_TAG as En, useUndoLog as Dn } from "./useUndoLog.js";
|
|
64
|
+
import { defineTracking as On, resolveTrackingEvent as kn, useTracking as An, wrapTrackedCallbacks as jn } from "./tracking.js";
|
|
65
|
+
import { useFormSkeleton as Mn, useTableSkeleton as Nn } from "./useSkeleton.js";
|
|
66
|
+
import { shallowArrayEqual as Pn, sourceValues as Fn, useDerived as In } from "./useDerived.js";
|
|
67
|
+
import { useResourceCan as Ln, useResourceCans as Rn } from "./useResourceCan.js";
|
|
68
|
+
import { filtersFromSchema as zn, useQueryFilters as Bn } from "./filters.js";
|
|
69
|
+
import { useRecord as Vn } from "./useRecord.js";
|
|
70
|
+
import { useAsyncValidation as Hn, useDebounced as Un, validationStatus as Wn } from "./validation.js";
|
|
71
|
+
import { createAnalytics as Gn, defineEvent as Kn, eventCatalog as qn, validateEventPayload as Jn } from "./analyticsCatalog.js";
|
|
72
|
+
import { usePreview as Yn } from "./usePreview.js";
|
|
73
|
+
import { readApiOnline as Xn, subscribeApiOnline as Zn, useApiOnline as Qn } from "./useApiOnline.js";
|
|
74
|
+
import { clearSent as $n, defaultOutboxRetryDelay as er, enqueueEntry as tr, markConflict as nr, markFailed as rr, markSent as ir, replayable as ar, resolveConflictEntry as or, useOutbox as sr } from "./outbox.js";
|
|
75
|
+
import { OUTBOX_DB_NAME as cr, OUTBOX_SYNC_TAG as lr, drainOutboxInWorker as ur, drainOutboxOverHttp as dr, indexedDbOutboxPersistence as fr, rpcHttpOutcome as pr } from "./outboxHttp.js";
|
|
76
|
+
import { computeWindow as mr, useWindowedSubscription as hr } from "./useWindowedSubscription.js";
|
|
77
|
+
import { useConnectionStatus as gr } from "./useConnectionStatus.js";
|
|
78
|
+
import { runLocalQuery as _r, useLocalQuery as vr } from "./useLocalQuery.js";
|
|
79
|
+
import { CONNECTIONS_LIST_TAG as yr, CONNECTION_DISCONNECT_TAG as br, CONNECTION_START_TAG as xr, CONNECTION_SUBMIT_TOKEN_TAG as Sr, useConnection as Cr, useConnections as wr } from "./useConnections.js";
|
|
80
|
+
import { DEV_ACTIVITY_EVENT as Tr, PAIRING_HOST as Er, PAIRING_SCHEME as Dr, PAIRING_STORAGE_KEY as Or, applyPairing as kr, clearPairing as Ar, errorMessage as jr, errorTag as Mr, jsonSchemaDocumentOf as Nr, jsonSchemaOf as Pr, pairingLink as Fr, parsePairingLink as Ir, readPairing as Lr } from "@voltro/protocol";
|
|
81
|
+
//#region src/index.ts
|
|
82
|
+
var Rr = "framework-client";
|
|
603
83
|
//#endregion
|
|
604
|
-
|
|
605
|
-
var wn = 100, Y = [], Tn = /* @__PURE__ */ new Set(), En = [], Dn = () => {
|
|
606
|
-
En = Y.slice();
|
|
607
|
-
}, On = () => {
|
|
608
|
-
Dn();
|
|
609
|
-
for (let e of Tn) try {
|
|
610
|
-
e();
|
|
611
|
-
} catch {}
|
|
612
|
-
}, kn = (e) => {
|
|
613
|
-
let t = {
|
|
614
|
-
...e,
|
|
615
|
-
kind: e.kind ?? "mutation",
|
|
616
|
-
status: "pending",
|
|
617
|
-
startedAt: Date.now()
|
|
618
|
-
};
|
|
619
|
-
Y.unshift(t), Y.length > wn && (Y.length = wn), On();
|
|
620
|
-
}, X = (e, t) => {
|
|
621
|
-
let n = Y.findIndex((t) => t.id === e);
|
|
622
|
-
if (n === -1) return;
|
|
623
|
-
let r = Y[n], i = Date.now();
|
|
624
|
-
Y[n] = t.status === "success" ? {
|
|
625
|
-
...r,
|
|
626
|
-
status: "success",
|
|
627
|
-
output: t.output,
|
|
628
|
-
settledAt: i,
|
|
629
|
-
durationMs: i - r.startedAt
|
|
630
|
-
} : {
|
|
631
|
-
...r,
|
|
632
|
-
status: "error",
|
|
633
|
-
error: t.error,
|
|
634
|
-
settledAt: i,
|
|
635
|
-
durationMs: i - r.startedAt
|
|
636
|
-
}, On();
|
|
637
|
-
}, An = () => En, jn = (e) => (Tn.add(e), () => {
|
|
638
|
-
Tn.delete(e);
|
|
639
|
-
}), Mn = () => {
|
|
640
|
-
Y.length !== 0 && (Y.length = 0, On());
|
|
641
|
-
}, Nn = /* @__PURE__ */ new WeakMap(), Pn = (e, t) => {
|
|
642
|
-
let n = Object.freeze({
|
|
643
|
-
apiName: e,
|
|
644
|
-
kind: "connection-setup"
|
|
645
|
-
});
|
|
646
|
-
return Nn.set(n, t), n;
|
|
647
|
-
}, Fn = (e, t) => {
|
|
648
|
-
let n = Nn.get(e);
|
|
649
|
-
if (n === void 0 || e.apiName !== t) throw Error(`Voltro: connection setup must belong to api "${t}"`);
|
|
650
|
-
return n;
|
|
651
|
-
}, In = /* @__PURE__ */ new WeakMap(), Ln = (e, t) => {
|
|
652
|
-
In.set(e, t);
|
|
653
|
-
}, Rn = (e) => In.get(e)?.capture(), zn = class extends Error {
|
|
654
|
-
reason;
|
|
655
|
-
_tag = "MutationSerialExecutionError";
|
|
656
|
-
constructor(e) {
|
|
657
|
-
super(`Serial mutation cannot start: ${e}`), this.reason = e, this.name = "MutationSerialExecutionError";
|
|
658
|
-
}
|
|
659
|
-
}, Bn = (e = 32) => {
|
|
660
|
-
if (!Number.isSafeInteger(e) || e < 1) throw RangeError("maxPending must be a positive safe integer");
|
|
661
|
-
let t = /* @__PURE__ */ new WeakMap(), n = 0;
|
|
662
|
-
return { reserve(r, i) {
|
|
663
|
-
if (typeof r != "string" || r.length === 0) throw new zn("invalid-key");
|
|
664
|
-
if (i.aborted) throw new zn("scope-changed");
|
|
665
|
-
let a = t.get(i);
|
|
666
|
-
a === void 0 && (a = /* @__PURE__ */ new Map(), t.set(i, a));
|
|
667
|
-
let o = a, s = a.get(r);
|
|
668
|
-
if (s?.blocked.signal.aborted) throw new zn("unknown-predecessor");
|
|
669
|
-
if (n >= e) throw new zn("capacity");
|
|
670
|
-
s === void 0 && (s = {
|
|
671
|
-
semaphore: K.unsafeMakeSemaphore(1),
|
|
672
|
-
calls: 0,
|
|
673
|
-
blocked: new AbortController()
|
|
674
|
-
}, a.set(r, s));
|
|
675
|
-
let c = s;
|
|
676
|
-
n += 1, c.calls += 1;
|
|
677
|
-
let l = new AbortController(), u = () => l.abort();
|
|
678
|
-
i.addEventListener("abort", u, { once: !0 }), c.blocked.signal.addEventListener("abort", u, { once: !0 });
|
|
679
|
-
let d = () => {
|
|
680
|
-
if (i.aborted) throw new zn("scope-changed");
|
|
681
|
-
if (c.blocked.signal.aborted) throw new zn("unknown-predecessor");
|
|
682
|
-
}, f = K.runPromise(c.semaphore.take(1), { signal: l.signal }), p = f.then(() => {
|
|
683
|
-
d();
|
|
684
|
-
}, (e) => {
|
|
685
|
-
throw d(), e;
|
|
686
|
-
});
|
|
687
|
-
p.catch(() => {});
|
|
688
|
-
let m = !1;
|
|
689
|
-
return {
|
|
690
|
-
ready: p,
|
|
691
|
-
assertActive: d,
|
|
692
|
-
release(e) {
|
|
693
|
-
m || (m = !0, e === "unknown" && c.blocked.abort(), f.then(() => {
|
|
694
|
-
K.runSync(c.semaphore.release(1));
|
|
695
|
-
}, () => {}).finally(() => {
|
|
696
|
-
i.removeEventListener("abort", u), c.blocked.signal.removeEventListener("abort", u), --n, --c.calls, c.calls === 0 && !c.blocked.signal.aborted && o.delete(r);
|
|
697
|
-
}));
|
|
698
|
-
}
|
|
699
|
-
};
|
|
700
|
-
} };
|
|
701
|
-
}, Vn = /* @__PURE__ */ new WeakMap(), Hn = (e, t, n) => {
|
|
702
|
-
let r = Vn.get(e);
|
|
703
|
-
r === void 0 && (r = /* @__PURE__ */ new Map(), Vn.set(e, r));
|
|
704
|
-
let i = r.get(t);
|
|
705
|
-
return i === void 0 && (i = Bn(n), r.set(t, i)), i;
|
|
706
|
-
}, Un = (e, t) => {
|
|
707
|
-
if (t === void 0 || typeof e != "object" || !e) return e;
|
|
708
|
-
try {
|
|
709
|
-
Object.defineProperty(e, "__voltroTraceId", {
|
|
710
|
-
value: t,
|
|
711
|
-
enumerable: !1,
|
|
712
|
-
configurable: !0
|
|
713
|
-
});
|
|
714
|
-
} catch {}
|
|
715
|
-
return e;
|
|
716
|
-
}, Wn, Gn = (e) => {
|
|
717
|
-
Wn = e;
|
|
718
|
-
}, Kn = () => Wn, qn = (e, t, n) => typeof e == "function" ? e(t, n) : e, Jn = 0, Yn = () => `mut_${++Jn}`, Xn = (e, t) => ({
|
|
719
|
-
update: (n, r) => {
|
|
720
|
-
e.update(n, r, t);
|
|
721
|
-
},
|
|
722
|
-
forTag: (n, r) => e.forTag(n, r, t)
|
|
723
|
-
}), Zn = (e, t) => {
|
|
724
|
-
let n = k(e), { descriptors: i } = n, a = U(n);
|
|
725
|
-
a.current = n;
|
|
726
|
-
let s = i[t], l = s?.targets;
|
|
727
|
-
if (process.env.NODE_ENV !== "production") {
|
|
728
|
-
let n = s?.kind;
|
|
729
|
-
n !== void 0 && n !== "mutation" && console.error(`[@voltro/client] useMutation('${e}', '${t}') targets a ${n}, not a mutation. Use ${n === "action" ? "useAction" : n === "workflow" ? "useWorkflow" : `the ${n} hook`} instead.`);
|
|
730
|
-
}
|
|
731
|
-
let [u, d] = W(!1), [f, p] = W(void 0), [m, h] = W(void 0), g = U(null), _ = U(!1), y = U(0), b = B(async (n, i) => {
|
|
732
|
-
let s = i?.onError !== void 0 || i?.notify?.error !== void 0, u = (e) => {
|
|
733
|
-
i?.onError?.(e, n);
|
|
734
|
-
let t = qn(i?.notify?.error, e, n);
|
|
735
|
-
t !== void 0 && Wn?.error(t);
|
|
736
|
-
};
|
|
737
|
-
y.current += 1;
|
|
738
|
-
let f = () => d(--y.current > 0);
|
|
739
|
-
d(!0), p(void 0);
|
|
740
|
-
let m, x, C, w, T;
|
|
741
|
-
try {
|
|
742
|
-
w = Rn(b);
|
|
743
|
-
let r = a.current.descriptors[t]?.serialize;
|
|
744
|
-
if (r !== void 0) {
|
|
745
|
-
let i = a.current, o = i.recovery ?? c(i.errorBus, e);
|
|
746
|
-
T = Hn(i.descriptors, t, r.maxPending ?? 32).reserve(r.key(n), o.subjectSignal);
|
|
747
|
-
}
|
|
748
|
-
({runtime: m, cache: x, client: C} = await N(a, e, t));
|
|
749
|
-
} catch (e) {
|
|
750
|
-
if (T?.release(), f(), p(e), a.current.errorBus.emit({
|
|
751
|
-
source: "mutation",
|
|
752
|
-
tag: t,
|
|
753
|
-
error: e,
|
|
754
|
-
kind: "client",
|
|
755
|
-
outcome: "not-started"
|
|
756
|
-
}), s) return u(e);
|
|
757
|
-
throw e;
|
|
758
|
-
}
|
|
759
|
-
let E = Yn(), D = i?.idempotencyKey ?? ae();
|
|
760
|
-
kn({
|
|
761
|
-
id: E,
|
|
762
|
-
apiName: e,
|
|
763
|
-
tag: t,
|
|
764
|
-
input: n
|
|
765
|
-
});
|
|
766
|
-
let ee = g.current, O = _.current;
|
|
767
|
-
try {
|
|
768
|
-
ee ? ee(Xn(x, E), n) : !O && l && l.length > 0 && x.autoApply(l, n, E);
|
|
769
|
-
} catch (e) {
|
|
770
|
-
if (T?.release(), p(e), f(), x.revertByMutation(E), X(E, {
|
|
771
|
-
status: "error",
|
|
772
|
-
error: e
|
|
773
|
-
}), s) return u(e);
|
|
774
|
-
throw e;
|
|
775
|
-
}
|
|
776
|
-
let k, A = !1, j, M, te, P = Date.now();
|
|
777
|
-
try {
|
|
778
|
-
if (T) {
|
|
779
|
-
await T.ready, T.assertActive();
|
|
780
|
-
let n = await N(a, e, t);
|
|
781
|
-
m = n.runtime, C = n.client;
|
|
782
|
-
}
|
|
783
|
-
let s = async (i, o, s, c) => {
|
|
784
|
-
let l = R(i), u = l?.getSnapshot();
|
|
785
|
-
M = l === void 0 ? void 0 : () => a.current.runtime === i && u !== void 0 && l.getSnapshot() === u, c?.(), T?.assertActive();
|
|
786
|
-
let d = w === void 0 ? void 0 : await w.prepare(i, o);
|
|
787
|
-
u = l?.getSnapshot(), c?.();
|
|
788
|
-
let f = v(o, t), p = z(f(n), D), m = K.currentSpan.pipe(K.tap((e) => K.sync(() => {
|
|
789
|
-
k = e.traceId, r({
|
|
790
|
-
traceId: e.traceId,
|
|
791
|
-
spanId: e.spanId,
|
|
792
|
-
source: "mutation",
|
|
793
|
-
tag: t
|
|
794
|
-
});
|
|
795
|
-
})), K.catchAll(() => K.void), K.zipRight(K.try({
|
|
796
|
-
try: () => {
|
|
797
|
-
c?.(), T?.assertActive(), A = !0;
|
|
798
|
-
},
|
|
799
|
-
catch: (e) => e
|
|
800
|
-
})), K.zipRight(p)).pipe(K.withSpan(`client.mutation.${t}`, { attributes: {
|
|
801
|
-
"voltro.api": e,
|
|
802
|
-
"voltro.mutationId": E,
|
|
803
|
-
"rpc.tag": t,
|
|
804
|
-
"voltro.replay": s
|
|
805
|
-
} }));
|
|
806
|
-
return d === void 0 ? S(i, m) : d.run(m);
|
|
807
|
-
}, l;
|
|
808
|
-
try {
|
|
809
|
-
l = await s(m, C, !1);
|
|
810
|
-
} catch (n) {
|
|
811
|
-
let r = o(n, A ? "handler" : "client"), i = Un(n, k);
|
|
812
|
-
r === "transport" && (a.current.errorBus.emit({
|
|
813
|
-
source: "mutation",
|
|
814
|
-
tag: t,
|
|
815
|
-
error: i,
|
|
816
|
-
kind: r,
|
|
817
|
-
...M === void 0 ? {} : { affectsTransport: M() },
|
|
818
|
-
outcome: A ? "unknown" : "not-started",
|
|
819
|
-
...k === void 0 ? {} : { traceId: k }
|
|
820
|
-
}), j = i);
|
|
821
|
-
let u = a.current, d = u.recovery ?? c(u.errorBus, e), f = r === "transport" ? d.reserveMutationReplay(P) : void 0;
|
|
822
|
-
if (f === void 0) throw i;
|
|
823
|
-
try {
|
|
824
|
-
if (!await d.waitForMutationReplaySupport(P) || !await d.waitForProtocolReady(P) || !f.isValid()) throw i;
|
|
825
|
-
let n = () => {
|
|
826
|
-
if (!f.isValid()) throw i;
|
|
827
|
-
};
|
|
828
|
-
for (;;) {
|
|
829
|
-
n();
|
|
830
|
-
let r = await N(a, e, t);
|
|
831
|
-
try {
|
|
832
|
-
l = await s(r.runtime, r.client, !0, n);
|
|
833
|
-
break;
|
|
834
|
-
} catch (e) {
|
|
835
|
-
let t = e;
|
|
836
|
-
if (t?._tag !== "MutationInFlight") throw e;
|
|
837
|
-
let r = typeof t.retryAfterMs == "number" && Number.isFinite(t.retryAfterMs) && t.retryAfterMs > 0 ? t.retryAfterMs : 1e3;
|
|
838
|
-
if (r >= d.replayWindowRemaining(P)) throw e;
|
|
839
|
-
await new Promise((e) => setTimeout(e, r)), n();
|
|
840
|
-
}
|
|
841
|
-
}
|
|
842
|
-
} finally {
|
|
843
|
-
f.release();
|
|
844
|
-
}
|
|
845
|
-
}
|
|
846
|
-
h(l), X(E, {
|
|
847
|
-
status: "success",
|
|
848
|
-
output: l
|
|
849
|
-
}), a.current.errorBus.emitSuccess({
|
|
850
|
-
source: "mutation",
|
|
851
|
-
tag: t
|
|
852
|
-
}), x.confirmByMutation(E), i?.onSuccess?.(l, n);
|
|
853
|
-
let u = qn(i?.notify?.success, l, n);
|
|
854
|
-
return u !== void 0 && Wn?.success(u), l;
|
|
855
|
-
} catch (e) {
|
|
856
|
-
A && (j !== void 0 || o(e, "handler") === "transport") && (te = "unknown");
|
|
857
|
-
let n = Un(e, k);
|
|
858
|
-
if (p(n), X(E, {
|
|
859
|
-
status: "error",
|
|
860
|
-
error: n
|
|
861
|
-
}), x.revertByMutation(E), Object.is(j, n) || a.current.errorBus.emit({
|
|
862
|
-
source: "mutation",
|
|
863
|
-
tag: t,
|
|
864
|
-
error: n,
|
|
865
|
-
kind: A ? o(e, "handler") : "client",
|
|
866
|
-
...M === void 0 ? {} : { affectsTransport: M() },
|
|
867
|
-
outcome: A && o(e, "handler") === "transport" ? "unknown" : A ? "known" : "not-started",
|
|
868
|
-
...k === void 0 ? {} : { traceId: k }
|
|
869
|
-
}), s) return u(n);
|
|
870
|
-
throw n;
|
|
871
|
-
} finally {
|
|
872
|
-
T?.release(te), f();
|
|
873
|
-
}
|
|
874
|
-
}, [
|
|
875
|
-
e,
|
|
876
|
-
t,
|
|
877
|
-
l
|
|
878
|
-
]);
|
|
879
|
-
return H(() => {
|
|
880
|
-
let t = {
|
|
881
|
-
mutate: b,
|
|
882
|
-
pending: u,
|
|
883
|
-
error: f,
|
|
884
|
-
data: m,
|
|
885
|
-
withOptimistic: (e) => (g.current = e, t),
|
|
886
|
-
withoutOptimistic: () => (_.current = !0, t),
|
|
887
|
-
withConnectionSetup: (n) => (Ln(b, Fn(n, e)), t)
|
|
888
|
-
};
|
|
889
|
-
return t;
|
|
890
|
-
}, [
|
|
891
|
-
b,
|
|
892
|
-
u,
|
|
893
|
-
f,
|
|
894
|
-
m,
|
|
895
|
-
e
|
|
896
|
-
]);
|
|
897
|
-
}, Qn = (e, t) => {
|
|
898
|
-
if (t === void 0 || typeof e != "object" || !e) return e;
|
|
899
|
-
try {
|
|
900
|
-
Object.defineProperty(e, "__voltroTraceId", {
|
|
901
|
-
value: t,
|
|
902
|
-
enumerable: !1,
|
|
903
|
-
configurable: !0
|
|
904
|
-
});
|
|
905
|
-
} catch {}
|
|
906
|
-
return e;
|
|
907
|
-
}, $n = (e, t, n) => typeof e == "function" ? e(t, n) : e, er = 0, tr = () => `act_${++er}`, nr = (e, t) => {
|
|
908
|
-
let n = k(e), { descriptors: i } = n, a = U(n);
|
|
909
|
-
if (a.current = n, process.env.NODE_ENV !== "production") {
|
|
910
|
-
let n = i[t]?.kind;
|
|
911
|
-
n !== void 0 && n !== "action" && console.error(`[@voltro/client] useAction('${e}', '${t}') targets a ${n}, not an action. Use ${n === "mutation" ? "useMutation" : n === "workflow" ? "useWorkflow" : `the ${n} hook`} instead.`);
|
|
912
|
-
}
|
|
913
|
-
let [s, c] = W(!1), [l, u] = W(void 0), [d, f] = W(void 0), p = B(async (n, i) => {
|
|
914
|
-
let s = i?.onError !== void 0 || i?.notify?.error !== void 0;
|
|
915
|
-
c(!0), u(void 0);
|
|
916
|
-
let l = tr(), d = i?.idempotencyKey ?? ae();
|
|
917
|
-
kn({
|
|
918
|
-
id: l,
|
|
919
|
-
apiName: e,
|
|
920
|
-
tag: t,
|
|
921
|
-
input: n,
|
|
922
|
-
kind: "action"
|
|
923
|
-
});
|
|
924
|
-
let p, m = !1;
|
|
925
|
-
try {
|
|
926
|
-
let { runtime: o, client: s } = await N(a, e, t), c = v(s, t), u = K.currentSpan.pipe(K.tap((e) => K.sync(() => {
|
|
927
|
-
p = e.traceId, r({
|
|
928
|
-
traceId: e.traceId,
|
|
929
|
-
spanId: e.spanId,
|
|
930
|
-
source: "action",
|
|
931
|
-
tag: t
|
|
932
|
-
});
|
|
933
|
-
})), K.catchAll(() => K.void), K.zipRight(z(c(n), d))).pipe(K.withSpan(`client.action.${t}`, { attributes: {
|
|
934
|
-
"voltro.api": e,
|
|
935
|
-
"voltro.actionId": l,
|
|
936
|
-
"rpc.tag": t
|
|
937
|
-
} }));
|
|
938
|
-
m = !0;
|
|
939
|
-
let h = await S(o, u);
|
|
940
|
-
f(h), X(l, {
|
|
941
|
-
status: "success",
|
|
942
|
-
output: h
|
|
943
|
-
}), a.current.errorBus.emitSuccess({
|
|
944
|
-
source: "action",
|
|
945
|
-
tag: t
|
|
946
|
-
}), i?.onSuccess?.(h, n);
|
|
947
|
-
let g = $n(i?.notify?.success, h, n);
|
|
948
|
-
return g !== void 0 && Kn()?.success(g), h;
|
|
949
|
-
} catch (e) {
|
|
950
|
-
let r = Qn(e, p);
|
|
951
|
-
if (u(r), X(l, {
|
|
952
|
-
status: "error",
|
|
953
|
-
error: r
|
|
954
|
-
}), a.current.errorBus.emit({
|
|
955
|
-
source: "action",
|
|
956
|
-
tag: t,
|
|
957
|
-
error: r,
|
|
958
|
-
kind: m ? o(e, "handler") : "client",
|
|
959
|
-
outcome: m && o(e, "handler") === "transport" ? "unknown" : m ? "known" : "not-started",
|
|
960
|
-
...p === void 0 ? {} : { traceId: p }
|
|
961
|
-
}), s) {
|
|
962
|
-
i?.onError?.(r, n);
|
|
963
|
-
let e = $n(i?.notify?.error, r, n);
|
|
964
|
-
e !== void 0 && Kn()?.error(e);
|
|
965
|
-
return;
|
|
966
|
-
}
|
|
967
|
-
throw r;
|
|
968
|
-
} finally {
|
|
969
|
-
c(!1);
|
|
970
|
-
}
|
|
971
|
-
}, [e, t]);
|
|
972
|
-
return H(() => ({
|
|
973
|
-
run: p,
|
|
974
|
-
pending: s,
|
|
975
|
-
error: l,
|
|
976
|
-
lastResult: d
|
|
977
|
-
}), [
|
|
978
|
-
p,
|
|
979
|
-
s,
|
|
980
|
-
l,
|
|
981
|
-
d
|
|
982
|
-
]);
|
|
983
|
-
}, rr = Me(void 0), ir = (e) => Ne(rr.Provider, { value: e.messages }, e.children), ar = () => Pe(rr), or = Symbol.for("voltro.client.formEngine"), sr = Me(void 0), cr = (e, t) => {
|
|
984
|
-
let n = e;
|
|
985
|
-
for (let e of t.split(".")) {
|
|
986
|
-
if (typeof n != "object" || !n) return;
|
|
987
|
-
n = n[e];
|
|
988
|
-
}
|
|
989
|
-
return n;
|
|
990
|
-
}, lr = (e, t, n) => `vf-${e}-${t}-${n}`.replace(/[^a-zA-Z0-9_-]/g, "-"), ur = {
|
|
991
|
-
isTouched: !1,
|
|
992
|
-
isBlurred: !1,
|
|
993
|
-
isDirty: !1,
|
|
994
|
-
isPristine: !0,
|
|
995
|
-
isDefaultValue: !0,
|
|
996
|
-
isValidating: !1,
|
|
997
|
-
errorMap: {},
|
|
998
|
-
errorSourceMap: {}
|
|
999
|
-
}, dr = (e, t) => {
|
|
1000
|
-
let n = e.find((e) => e.name === t);
|
|
1001
|
-
if (n !== void 0) return n;
|
|
1002
|
-
let r = /^(.+?)\.\d+\.(.+)$/.exec(t);
|
|
1003
|
-
if (r !== null) return e.find((e) => e.name === r[1] && e.widget === "array")?.item?.find((e) => e.name === r[2]);
|
|
1004
|
-
}, fr = (e, t, n) => {
|
|
1005
|
-
let r = k(e), i = U(void 0), a = typeof t == "function" ? t(i.current?.state?.values ?? n.defaults ?? {}) : t, o = U(a).current, s = Zn(e, a), c = n.schema ?? r.descriptors[a]?.input;
|
|
1006
|
-
return process.env.NODE_ENV !== "production" && c === void 0 && console.error(`[@voltro/client] useFormBinding('${e}', '${t}'): no input schema. Pass options.schema, or mount the descriptor so its input reaches the client. Rendering no fields; submit skips client-side validation.`), mr(e, o, n, c, i, s);
|
|
1007
|
-
}, pr = (e) => {
|
|
1008
|
-
let t = U(void 0);
|
|
1009
|
-
return mr("local", Ie(), {
|
|
1010
|
-
...e,
|
|
1011
|
-
onSubmit: async ({ input: t }) => e.onSubmit(await Ue.decodeUnknownPromise(e.schema)(t))
|
|
1012
|
-
}, e.schema, t);
|
|
1013
|
-
}, mr = (e, t, n, r, i, a) => {
|
|
1014
|
-
let o = H(() => r ? ke(r) : [], [r]), s = ar(), c = n.messages ?? s, l = H(() => ({
|
|
1015
|
-
...n.locale === void 0 ? {} : { locale: n.locale },
|
|
1016
|
-
...c === void 0 ? {} : { messages: c }
|
|
1017
|
-
}), [n.locale, c]), u = U(n.asyncFields);
|
|
1018
|
-
u.current = n.asyncFields;
|
|
1019
|
-
let d = U(n);
|
|
1020
|
-
d.current = n;
|
|
1021
|
-
let f = U(a);
|
|
1022
|
-
f.current = a;
|
|
1023
|
-
let p = U(l);
|
|
1024
|
-
p.current = l;
|
|
1025
|
-
let m = U(r);
|
|
1026
|
-
m.current = r;
|
|
1027
|
-
let [h, g] = W(() => n.flash?.errors ?? {}), [_, v] = W(n.flash?.formError), [y, b] = W(void 0), x = U(void 0), S = U(!1), C = B((e) => {
|
|
1028
|
-
let t = m.current;
|
|
1029
|
-
if (t === void 0) return [];
|
|
1030
|
-
let n = d.current, r = e;
|
|
1031
|
-
if (n.toInput !== void 0) try {
|
|
1032
|
-
r = n.toInput(e);
|
|
1033
|
-
} catch {
|
|
1034
|
-
r = e;
|
|
1035
|
-
}
|
|
1036
|
-
let i = fe(t, r, p.current).issues;
|
|
1037
|
-
if (n.toInput === void 0) return i;
|
|
1038
|
-
let a = n.errorPath ?? {};
|
|
1039
|
-
return i.map((t) => {
|
|
1040
|
-
let n = a[t.path];
|
|
1041
|
-
return n === void 0 ? (cr(e, t.path) !== void 0 || t.path.includes("."), t) : {
|
|
1042
|
-
...t,
|
|
1043
|
-
path: n
|
|
1044
|
-
};
|
|
1045
|
-
});
|
|
1046
|
-
}, []), w = B((e) => {
|
|
1047
|
-
let t = { ...e ?? {} }, n = m.current;
|
|
1048
|
-
if (n !== void 0) for (let e of ke(n)) (e.widget === "checkbox" || e.widget === "switch") && !(e.name in t) && (t[e.name] = !1);
|
|
1049
|
-
return t;
|
|
1050
|
-
}, []), T = U(() => Promise.resolve());
|
|
1051
|
-
if (i.current === void 0) {
|
|
1052
|
-
let e = n.flash, t = e === void 0 ? w(n.defaults) : {
|
|
1053
|
-
...w(n.defaults),
|
|
1054
|
-
...e.values
|
|
1055
|
-
};
|
|
1056
|
-
i.current = new rt({
|
|
1057
|
-
onSubmit: ({ value: e }) => T.current(e),
|
|
1058
|
-
defaultValues: t,
|
|
1059
|
-
validators: { onChange: ({ value: e }) => {
|
|
1060
|
-
let t = C(e);
|
|
1061
|
-
if (t.length === 0) return;
|
|
1062
|
-
let n = {};
|
|
1063
|
-
for (let e of t) e.path !== "" && !(e.path in n) && (n[e.path] = Oe(e, p.current));
|
|
1064
|
-
return { fields: n };
|
|
1065
|
-
} }
|
|
1066
|
-
});
|
|
1067
|
-
}
|
|
1068
|
-
let E = i.current, D = E;
|
|
1069
|
-
V(() => D.mount(), [D]);
|
|
1070
|
-
let ee = n.subscribe ?? "all";
|
|
1071
|
-
it(E.store, (e) => ee === "all" ? e : `${e.submissionAttempts}|${String(e.isSubmitting)}|${String(e.isDirty)}|${String(e.isTouched)}`);
|
|
1072
|
-
let O = E.store.state.values, k = E.store.state, A = H(() => C(O), [C, O]), j = n.isLoading === !0, M = n.validate, N = M?.onChange ?? "afterTouched", te = M?.onBlur ?? !0, P = k.submissionAttempts, F = k.fieldMetaBase ?? {}, ne = B((e) => {
|
|
1073
|
-
if (j) return !1;
|
|
1074
|
-
if (P > 0 || N === "always") return !0;
|
|
1075
|
-
if (N === "never") return !1;
|
|
1076
|
-
let t = F[e];
|
|
1077
|
-
return t === void 0 ? !1 : te ? t.isBlurred === !0 : t.isTouched === !0;
|
|
1078
|
-
}, [
|
|
1079
|
-
P,
|
|
1080
|
-
F,
|
|
1081
|
-
j,
|
|
1082
|
-
N,
|
|
1083
|
-
te
|
|
1084
|
-
]), I = B((e) => {
|
|
1085
|
-
let t = h[e];
|
|
1086
|
-
if (t !== void 0) return t;
|
|
1087
|
-
let n = u.current?.[e];
|
|
1088
|
-
if (n !== void 0 && n.status === "invalid") return n.message ?? Oe({
|
|
1089
|
-
id: "validation.invalid",
|
|
1090
|
-
fallback: "Invalid value"
|
|
1091
|
-
}, p.current);
|
|
1092
|
-
if (!ne(e)) return;
|
|
1093
|
-
let r = A.find((t) => t.path === e);
|
|
1094
|
-
return r === void 0 ? void 0 : Oe(r, p.current);
|
|
1095
|
-
}, [
|
|
1096
|
-
h,
|
|
1097
|
-
ne,
|
|
1098
|
-
A
|
|
1099
|
-
]), L = H(() => {
|
|
1100
|
-
let e = {}, t = /* @__PURE__ */ new Set([...A.map((e) => e.path).filter((e) => e !== ""), ...Object.keys(h)]);
|
|
1101
|
-
for (let [e, n] of Object.entries(u.current ?? {})) n.status === "invalid" && t.add(e);
|
|
1102
|
-
for (let n of t) {
|
|
1103
|
-
let t = I(n);
|
|
1104
|
-
t !== void 0 && (e[n] = t);
|
|
1105
|
-
}
|
|
1106
|
-
return e;
|
|
1107
|
-
}, [
|
|
1108
|
-
A,
|
|
1109
|
-
h,
|
|
1110
|
-
I
|
|
1111
|
-
]), R = B((e) => {
|
|
1112
|
-
g((t) => {
|
|
1113
|
-
if (!(e in t)) return t;
|
|
1114
|
-
let n = { ...t };
|
|
1115
|
-
return delete n[e], n;
|
|
1116
|
-
});
|
|
1117
|
-
}, []), z = B((n) => {
|
|
1118
|
-
let r = dr(o, n), i = D.getFieldMeta(n), a = I(n), s = lr(e, t, n), c = u.current?.[n], l = [a === void 0 ? void 0 : `${s}-error`, r?.description === void 0 ? void 0 : `${s}-help`].filter((e) => e !== void 0);
|
|
1119
|
-
return {
|
|
1120
|
-
value: D.getFieldValue(n),
|
|
1121
|
-
setValue: (e) => {
|
|
1122
|
-
R(n), !Object.is(D.getFieldValue(n), e) && D.setFieldValue(n, e);
|
|
1123
|
-
},
|
|
1124
|
-
onBlur: () => {
|
|
1125
|
-
D.setFieldMeta(n, (e) => ({
|
|
1126
|
-
...ur,
|
|
1127
|
-
...e ?? {},
|
|
1128
|
-
isTouched: !0,
|
|
1129
|
-
isBlurred: !0
|
|
1130
|
-
}));
|
|
1131
|
-
},
|
|
1132
|
-
error: a,
|
|
1133
|
-
serverError: h[n],
|
|
1134
|
-
touched: i?.isTouched === !0,
|
|
1135
|
-
blurred: i?.isBlurred === !0,
|
|
1136
|
-
dirty: i?.isDirty === !0,
|
|
1137
|
-
required: r?.required === !0,
|
|
1138
|
-
label: r?.label ?? n,
|
|
1139
|
-
widget: r?.widget ?? "text",
|
|
1140
|
-
options: r?.options,
|
|
1141
|
-
description: r?.description,
|
|
1142
|
-
asyncStatus: c?.status ?? "idle",
|
|
1143
|
-
a11y: {
|
|
1144
|
-
id: s,
|
|
1145
|
-
"aria-invalid": a !== void 0 || void 0,
|
|
1146
|
-
"aria-required": r?.required === !0 || void 0,
|
|
1147
|
-
"aria-describedby": l.length > 0 ? l.join(" ") : void 0
|
|
1148
|
-
}
|
|
1149
|
-
};
|
|
1150
|
-
}, [
|
|
1151
|
-
e,
|
|
1152
|
-
t,
|
|
1153
|
-
R,
|
|
1154
|
-
D,
|
|
1155
|
-
o,
|
|
1156
|
-
h,
|
|
1157
|
-
I
|
|
1158
|
-
]), re = B((e) => ({
|
|
1159
|
-
items: D.getFieldValue(e) ?? [],
|
|
1160
|
-
push: (t) => {
|
|
1161
|
-
D.pushFieldValue(e, t);
|
|
1162
|
-
},
|
|
1163
|
-
insert: (t, n) => {
|
|
1164
|
-
D.insertFieldValue(e, t, n);
|
|
1165
|
-
},
|
|
1166
|
-
remove: (t) => {
|
|
1167
|
-
D.removeFieldValue(e, t);
|
|
1168
|
-
},
|
|
1169
|
-
move: (t, n) => {
|
|
1170
|
-
D.moveFieldValues(e, t, n);
|
|
1171
|
-
},
|
|
1172
|
-
swap: (t, n) => {
|
|
1173
|
-
D.swapFieldValues(e, t, n);
|
|
1174
|
-
},
|
|
1175
|
-
field: (t, n) => z(`${e}.${t}.${n}`)
|
|
1176
|
-
}), [D, z]), ie = B((e) => o.filter((t) => t.section === e), [o]), ae = B((e, t) => {
|
|
1177
|
-
R(e), !Object.is(D.getFieldValue(e), t) && D.setFieldValue(e, t);
|
|
1178
|
-
}, [R, D]), oe = B((e) => {
|
|
1179
|
-
for (let [t, n] of Object.entries(e)) D.setFieldValue(t, n);
|
|
1180
|
-
}, [D]), se = B((e) => {
|
|
1181
|
-
g({}), v(void 0), b(void 0), x.current = void 0, S.current = !1, e === void 0 ? D.reset() : D.reset(w(e));
|
|
1182
|
-
}, [D, w]), ce = n.asyncTimeoutMs ?? 5e3, le = B(async () => {
|
|
1183
|
-
let e = Date.now();
|
|
1184
|
-
for (;;) {
|
|
1185
|
-
let t = u.current;
|
|
1186
|
-
if (t === void 0) return;
|
|
1187
|
-
let n = Object.entries(t), r = n.filter(([, e]) => e.status === "checking");
|
|
1188
|
-
if (r.length === 0) {
|
|
1189
|
-
let e = n.filter(([, e]) => e.status === "invalid");
|
|
1190
|
-
return e.length === 0 ? void 0 : Object.fromEntries(e.map(([e, t]) => [e, t.message ?? Oe({
|
|
1191
|
-
id: "validation.invalid",
|
|
1192
|
-
fallback: "Invalid value"
|
|
1193
|
-
}, p.current)]));
|
|
1194
|
-
}
|
|
1195
|
-
if (Date.now() - e > ce) return Object.fromEntries(r.map(([e]) => [e, Oe({
|
|
1196
|
-
id: "validation.checking",
|
|
1197
|
-
fallback: "Still checking…"
|
|
1198
|
-
}, p.current)]));
|
|
1199
|
-
await new Promise((e) => setTimeout(e, 50));
|
|
1200
|
-
}
|
|
1201
|
-
}, [ce]), ue = B(() => {
|
|
1202
|
-
let n = globalThis.document;
|
|
1203
|
-
if (n?.getElementById === void 0) return;
|
|
1204
|
-
let r = [...o.map((e) => e.name), ...Object.keys(h).filter((e) => !o.some((t) => t.name === e))];
|
|
1205
|
-
for (let i of r) if (I(i) !== void 0) {
|
|
1206
|
-
n.getElementById(lr(e, t, i))?.focus?.();
|
|
1207
|
-
return;
|
|
1208
|
-
}
|
|
1209
|
-
}, [
|
|
1210
|
-
e,
|
|
1211
|
-
t,
|
|
1212
|
-
o,
|
|
1213
|
-
h,
|
|
1214
|
-
I
|
|
1215
|
-
]), de = U(ue);
|
|
1216
|
-
de.current = ue;
|
|
1217
|
-
let pe = B(async () => {
|
|
1218
|
-
v(void 0), g({}), b(void 0), x.current = void 0, S.current = !1;
|
|
1219
|
-
let e, t = !1;
|
|
1220
|
-
if (await D.handleSubmit().catch((n) => {
|
|
1221
|
-
t = !0, e = n;
|
|
1222
|
-
}), t) throw e;
|
|
1223
|
-
return S.current || queueMicrotask(() => {
|
|
1224
|
-
de.current();
|
|
1225
|
-
}), x.current;
|
|
1226
|
-
}, [D]);
|
|
1227
|
-
T.current = (async (e) => {
|
|
1228
|
-
let t = d.current, n = e, r = n;
|
|
1229
|
-
if (t.toInput !== void 0) try {
|
|
1230
|
-
r = t.toInput(n);
|
|
1231
|
-
} catch (e) {
|
|
1232
|
-
v(e instanceof Error ? e.message : String(e));
|
|
1233
|
-
return;
|
|
1234
|
-
}
|
|
1235
|
-
if (C(n).length > 0) {
|
|
1236
|
-
queueMicrotask(() => {
|
|
1237
|
-
de.current();
|
|
1238
|
-
});
|
|
1239
|
-
return;
|
|
1240
|
-
}
|
|
1241
|
-
let i = m.current;
|
|
1242
|
-
if (i !== void 0) {
|
|
1243
|
-
let e = je(i, r);
|
|
1244
|
-
e.dropped.length > 0 && process.env.NODE_ENV !== "production" && console.warn(`[@voltro/client] useFormBinding: dropped ${e.dropped.length} value(s) the mutation's input does not declare (${e.dropped.join(", ")}). The server refuses undeclared fields, so they are not sent. Map them with \`toInput\` if they belong in the write; ignore this if they are form-only state.`), r = e.input;
|
|
1245
|
-
}
|
|
1246
|
-
let a = await le();
|
|
1247
|
-
if (a !== void 0) {
|
|
1248
|
-
g((e) => ({
|
|
1249
|
-
...e,
|
|
1250
|
-
...a
|
|
1251
|
-
})), queueMicrotask(() => {
|
|
1252
|
-
de.current();
|
|
1253
|
-
});
|
|
1254
|
-
return;
|
|
1255
|
-
}
|
|
1256
|
-
let o = (e) => {
|
|
1257
|
-
let t = f.current;
|
|
1258
|
-
return t === void 0 ? Promise.reject(/* @__PURE__ */ Error("A schema form submits through its onSubmit callback")) : t.mutate(e);
|
|
1259
|
-
};
|
|
1260
|
-
try {
|
|
1261
|
-
let e = t.onSubmit === void 0 ? await o(r) : await t.onSubmit({
|
|
1262
|
-
input: r,
|
|
1263
|
-
values: n,
|
|
1264
|
-
mutate: o
|
|
1265
|
-
});
|
|
1266
|
-
x.current = e, S.current = !0, t.onSuccess?.(e);
|
|
1267
|
-
} catch (e) {
|
|
1268
|
-
let t = Ze(e);
|
|
1269
|
-
if (t.length === 0) {
|
|
1270
|
-
b(e), d.current.onError?.(e);
|
|
1271
|
-
return;
|
|
1272
|
-
}
|
|
1273
|
-
let n = {};
|
|
1274
|
-
for (let e of t) e.field in n || (n[e.field] = Oe({
|
|
1275
|
-
id: e.message,
|
|
1276
|
-
...e.params === void 0 ? {} : { params: e.params },
|
|
1277
|
-
fallback: e.message
|
|
1278
|
-
}, p.current));
|
|
1279
|
-
g((e) => ({
|
|
1280
|
-
...e,
|
|
1281
|
-
...n
|
|
1282
|
-
})), queueMicrotask(() => {
|
|
1283
|
-
de.current();
|
|
1284
|
-
});
|
|
1285
|
-
}
|
|
1286
|
-
});
|
|
1287
|
-
let me = A.length === 0, he = Object.values(u.current ?? {}).some((e) => e.status === "checking"), ge = y ?? a?.error, _e = ge !== void 0 && Ze(ge).length > 0 ? void 0 : ge, ve = Object.keys(L).length, ye = (() => {
|
|
1288
|
-
for (let e of o) if (L[e.name] !== void 0) return e.name;
|
|
1289
|
-
let e = Object.keys(L);
|
|
1290
|
-
return e.length > 0 ? e[0] : void 0;
|
|
1291
|
-
})(), be = {
|
|
1292
|
-
isDirty: !j && k.isDirty,
|
|
1293
|
-
isPristine: k.isPristine,
|
|
1294
|
-
isTouched: k.isTouched,
|
|
1295
|
-
isValid: me,
|
|
1296
|
-
isValidating: he,
|
|
1297
|
-
canSubmit: me && !he && !k.isSubmitting && !j,
|
|
1298
|
-
isSubmitting: k.isSubmitting,
|
|
1299
|
-
isSubmitted: k.isSubmitted,
|
|
1300
|
-
isSubmitSuccessful: k.isSubmitSuccessful && S.current,
|
|
1301
|
-
submissionAttempts: k.submissionAttempts,
|
|
1302
|
-
errorCount: ve,
|
|
1303
|
-
firstInvalidPath: ye,
|
|
1304
|
-
pending: a?.pending ?? k.isSubmitting,
|
|
1305
|
-
isLoading: j,
|
|
1306
|
-
submitError: _e,
|
|
1307
|
-
data: a?.data ?? x.current
|
|
1308
|
-
}, xe = {
|
|
1309
|
-
fields: o,
|
|
1310
|
-
values: O,
|
|
1311
|
-
errors: L,
|
|
1312
|
-
issues: A,
|
|
1313
|
-
isValid: me,
|
|
1314
|
-
pending: a?.pending ?? k.isSubmitting,
|
|
1315
|
-
submitError: _e,
|
|
1316
|
-
formError: _,
|
|
1317
|
-
data: a?.data ?? x.current,
|
|
1318
|
-
setValue: ae,
|
|
1319
|
-
setValues: oe,
|
|
1320
|
-
reset: se,
|
|
1321
|
-
submit: pe,
|
|
1322
|
-
field: z,
|
|
1323
|
-
array: re,
|
|
1324
|
-
section: ie,
|
|
1325
|
-
state: be,
|
|
1326
|
-
focusFirstInvalid: ue
|
|
1327
|
-
};
|
|
1328
|
-
return Object.defineProperty(xe, or, {
|
|
1329
|
-
value: {
|
|
1330
|
-
store: E.store,
|
|
1331
|
-
field: z
|
|
1332
|
-
},
|
|
1333
|
-
enumerable: !1
|
|
1334
|
-
}), xe;
|
|
1335
|
-
}, hr = (e) => Ne(sr.Provider, { value: e.binding }, e.children), gr = () => Pe(sr);
|
|
1336
|
-
function _r(e, t) {
|
|
1337
|
-
let n = Pe(sr), r = typeof e == "string" ? void 0 : e, i = typeof e == "string" ? e : t, a = r ?? n;
|
|
1338
|
-
if (a === void 0) throw Error("useFormField(path) found no form binding — mount <FormBindingProvider binding={form}> above this field, or call useFormField(form, path) with the binding in hand.");
|
|
1339
|
-
let o = a[or];
|
|
1340
|
-
if (o === void 0) throw Error("useFormField: not a useFormBinding result");
|
|
1341
|
-
return it(o.store, (e) => {
|
|
1342
|
-
let t = e.fieldMetaBase[i];
|
|
1343
|
-
return `${JSON.stringify(cr(e.values, i))}|${t === void 0 ? "" : `${String(t.isTouched)}${String(t.isBlurred)}${JSON.stringify(t.errorMap)}`}|${e.submissionAttempts}`;
|
|
1344
|
-
}), o.field(i);
|
|
1345
|
-
}
|
|
1346
|
-
//#endregion
|
|
1347
|
-
//#region src/connectionPrerequisite.ts
|
|
1348
|
-
var vr = "voltro:connection-setup-superseded", yr = (e) => e.reason === "voltro:connection-setup-superseded" ? "superseded" : "inactive", Z = class extends Error {
|
|
1349
|
-
reason;
|
|
1350
|
-
_tag = "ConnectionPrerequisiteInvalidated";
|
|
1351
|
-
constructor(e) {
|
|
1352
|
-
super(`Voltro connection prerequisite: ${e}`), this.reason = e, T(this, e === "connection-unavailable" || e === "connection-changed" ? "transport" : "client");
|
|
1353
|
-
}
|
|
1354
|
-
}, br = class {
|
|
1355
|
-
#e;
|
|
1356
|
-
#t;
|
|
1357
|
-
#n = /* @__PURE__ */ new WeakMap();
|
|
1358
|
-
#r = /* @__PURE__ */ new WeakSet();
|
|
1359
|
-
constructor(e, t) {
|
|
1360
|
-
if (!Number.isFinite(t) || t <= 0 || t > 6e4) throw RangeError("Connection prerequisite timeout must be between 0 and 60000 ms");
|
|
1361
|
-
this.#e = e, this.#t = t;
|
|
1362
|
-
}
|
|
1363
|
-
prepare(e, t) {
|
|
1364
|
-
let n = R(e)?.getSnapshot();
|
|
1365
|
-
if (this.#e.aborted) return Promise.reject(new Z(yr(this.#e)));
|
|
1366
|
-
if (n === void 0) return Promise.reject(new Z("connection-unavailable"));
|
|
1367
|
-
let r = this.#n.get(n);
|
|
1368
|
-
if (r !== void 0) return r.then((t) => (this.assertCurrent(e, t), t));
|
|
1369
|
-
let i = this.#a(e, n, t).pipe(K.timeoutFail({
|
|
1370
|
-
duration: this.#t,
|
|
1371
|
-
onTimeout: () => new Z("timeout")
|
|
1372
|
-
})), a = S(e, i).then((t) => {
|
|
1373
|
-
let r = Object.freeze({
|
|
1374
|
-
lease: n,
|
|
1375
|
-
output: t
|
|
1376
|
-
});
|
|
1377
|
-
return this.#r.add(r), this.assertCurrent(e, r), r;
|
|
1378
|
-
});
|
|
1379
|
-
return this.#n.set(n, a), a.catch(() => {
|
|
1380
|
-
this.#n.get(n) === a && this.#n.delete(n);
|
|
1381
|
-
}), a;
|
|
1382
|
-
}
|
|
1383
|
-
assertCurrent(e, t) {
|
|
1384
|
-
if (!this.#r.has(t)) throw new Z(yr(this.#e));
|
|
1385
|
-
this.#i(e, t.lease);
|
|
1386
|
-
}
|
|
1387
|
-
#i(e, t) {
|
|
1388
|
-
if (this.#e.aborted) throw new Z(yr(this.#e));
|
|
1389
|
-
if (t.signal.aborted || R(e)?.getSnapshot() !== t) throw new Z("connection-changed");
|
|
1390
|
-
}
|
|
1391
|
-
run(e, t, n) {
|
|
1392
|
-
let r = K.try({
|
|
1393
|
-
try: () => this.assertCurrent(e, t),
|
|
1394
|
-
catch: (e) => e
|
|
1395
|
-
}).pipe(K.zipRight(n));
|
|
1396
|
-
return S(e, this.#a(e, t.lease, r));
|
|
1397
|
-
}
|
|
1398
|
-
#a(e, t, n) {
|
|
1399
|
-
let r = K.try({
|
|
1400
|
-
try: () => this.#i(e, t),
|
|
1401
|
-
catch: (e) => e
|
|
1402
|
-
}), i = K.async((e) => {
|
|
1403
|
-
let n = () => e(K.fail(new Z(this.#e.aborted ? yr(this.#e) : "connection-changed")));
|
|
1404
|
-
return this.#e.addEventListener("abort", n, { once: !0 }), t.signal.addEventListener("abort", n, { once: !0 }), (this.#e.aborted || t.signal.aborted) && n(), K.sync(() => {
|
|
1405
|
-
this.#e.removeEventListener("abort", n), t.signal.removeEventListener("abort", n);
|
|
1406
|
-
});
|
|
1407
|
-
});
|
|
1408
|
-
return r.pipe(K.zipRight(n), K.tap(() => r), K.raceFirst(i));
|
|
1409
|
-
}
|
|
1410
|
-
}, xr = class {
|
|
1411
|
-
#e;
|
|
1412
|
-
#t;
|
|
1413
|
-
#n;
|
|
1414
|
-
#r = /* @__PURE__ */ new Set();
|
|
1415
|
-
#i;
|
|
1416
|
-
#a = {
|
|
1417
|
-
status: "idle",
|
|
1418
|
-
data: void 0,
|
|
1419
|
-
error: void 0
|
|
1420
|
-
};
|
|
1421
|
-
#o = 0;
|
|
1422
|
-
#s;
|
|
1423
|
-
handle;
|
|
1424
|
-
constructor(e, t, n) {
|
|
1425
|
-
this.#e = e, this.#t = t, this.#n = n, this.handle = Pn(e, { capture: () => this.#f() });
|
|
1426
|
-
}
|
|
1427
|
-
getSnapshot = () => this.#a;
|
|
1428
|
-
subscribe = (e) => (this.#r.add(e), () => {
|
|
1429
|
-
this.#r.delete(e);
|
|
1430
|
-
});
|
|
1431
|
-
clear = (e = !1) => {
|
|
1432
|
-
let t = this.#i;
|
|
1433
|
-
this.#i = void 0, this.#s = void 0, t?.detachSubject?.(), t?.controller.abort(e ? vr : void 0), this.#h({
|
|
1434
|
-
status: "idle",
|
|
1435
|
-
data: void 0,
|
|
1436
|
-
error: void 0
|
|
1437
|
-
});
|
|
1438
|
-
};
|
|
1439
|
-
async activate(e, t) {
|
|
1440
|
-
this.clear(!0);
|
|
1441
|
-
let n = new AbortController(), r = {
|
|
1442
|
-
input: e,
|
|
1443
|
-
key: ae(),
|
|
1444
|
-
controller: n,
|
|
1445
|
-
subject: void 0,
|
|
1446
|
-
detachSubject: void 0,
|
|
1447
|
-
prerequisite: new br(n.signal, this.#c(this.#n()).options.replayWindowMs),
|
|
1448
|
-
established: !1
|
|
1449
|
-
};
|
|
1450
|
-
this.#i = r, this.#h({
|
|
1451
|
-
status: "pending",
|
|
1452
|
-
data: void 0,
|
|
1453
|
-
error: void 0
|
|
1454
|
-
});
|
|
1455
|
-
try {
|
|
1456
|
-
let e = await t(), n = await this.#p(r, e.runtime, e.client);
|
|
1457
|
-
return this.#l(r), r.prerequisite.assertCurrent(e.runtime, n), r.established = !0, n.output;
|
|
1458
|
-
} catch (e) {
|
|
1459
|
-
throw this.#i === r && (this.clear(), this.#h({
|
|
1460
|
-
status: "error",
|
|
1461
|
-
data: void 0,
|
|
1462
|
-
error: e
|
|
1463
|
-
})), e;
|
|
1464
|
-
}
|
|
1465
|
-
}
|
|
1466
|
-
watch(e) {
|
|
1467
|
-
let t = R(e.runtime), n = () => {
|
|
1468
|
-
let n = this.#i;
|
|
1469
|
-
if (n === void 0 || !n.established || this.#n().runtime !== e.runtime) return;
|
|
1470
|
-
if (n.subject !== this.#c(e).subjectSignal) {
|
|
1471
|
-
this.clear();
|
|
1472
|
-
return;
|
|
1473
|
-
}
|
|
1474
|
-
let r = t?.getSnapshot();
|
|
1475
|
-
(r === void 0 || r !== this.#s || this.#a.status !== "ready") && (this.#s = void 0, this.#h({
|
|
1476
|
-
status: "pending",
|
|
1477
|
-
data: void 0,
|
|
1478
|
-
error: void 0
|
|
1479
|
-
}), r !== void 0 && this.#p(n, e.runtime, e.client).catch(() => {}));
|
|
1480
|
-
};
|
|
1481
|
-
return n(), t?.subscribe(n) ?? (() => {});
|
|
1482
|
-
}
|
|
1483
|
-
#c(e) {
|
|
1484
|
-
return e.recovery ?? c(e.errorBus, this.#e);
|
|
1485
|
-
}
|
|
1486
|
-
#l(e) {
|
|
1487
|
-
if (this.#i !== e || e.controller.signal.aborted) throw new Z(yr(e.controller.signal));
|
|
1488
|
-
}
|
|
1489
|
-
#u(e, t, n) {
|
|
1490
|
-
this.#l(e);
|
|
1491
|
-
let r = this.#n();
|
|
1492
|
-
if (e.subject !== void 0 && e.subject !== this.#c(r).subjectSignal) throw new Z("inactive");
|
|
1493
|
-
if (r.runtime !== t || r.client !== n) throw new Z("connection-changed");
|
|
1494
|
-
return r;
|
|
1495
|
-
}
|
|
1496
|
-
#d(e, t) {
|
|
1497
|
-
if (e.subject !== void 0) return;
|
|
1498
|
-
let n = this.#c(t).subjectSignal;
|
|
1499
|
-
e.subject = n;
|
|
1500
|
-
let r = () => {
|
|
1501
|
-
this.#i === e && this.clear();
|
|
1502
|
-
};
|
|
1503
|
-
n.addEventListener("abort", r, { once: !0 }), e.detachSubject = () => n.removeEventListener("abort", r), n.aborted && r();
|
|
1504
|
-
}
|
|
1505
|
-
#f() {
|
|
1506
|
-
let e = this.#i;
|
|
1507
|
-
if (e === void 0) throw new Z("inactive");
|
|
1508
|
-
return { prepare: async (t, n) => {
|
|
1509
|
-
let r = await this.#p(e, t, n);
|
|
1510
|
-
return { run: (i) => e.prerequisite.run(t, r, K.try({
|
|
1511
|
-
try: () => this.#u(e, t, n),
|
|
1512
|
-
catch: (e) => e
|
|
1513
|
-
}).pipe(K.zipRight(i))) };
|
|
1514
|
-
} };
|
|
1515
|
-
}
|
|
1516
|
-
async #p(e, t, n) {
|
|
1517
|
-
let r = this.#u(e, t, n), i = r.descriptors[this.#t];
|
|
1518
|
-
if (i?.kind !== "mutation" || i.idempotencyScope !== "connection") throw Error(`Voltro: useConnectionSetup("${this.#t}") requires a mutation declaring idempotencyScope: 'connection'`);
|
|
1519
|
-
this.#d(e, r), this.#l(e);
|
|
1520
|
-
let a = R(t);
|
|
1521
|
-
if (a === void 0) throw new Z("connection-unavailable");
|
|
1522
|
-
if (a.getSnapshot() === void 0) {
|
|
1523
|
-
let n = K.async((t) => {
|
|
1524
|
-
let n = () => {
|
|
1525
|
-
let n = a.getSnapshot();
|
|
1526
|
-
e.controller.signal.aborted ? t(K.fail(new Z(yr(e.controller.signal)))) : n !== void 0 && t(K.succeed(n));
|
|
1527
|
-
}, r = a.subscribe(n);
|
|
1528
|
-
return e.controller.signal.addEventListener("abort", n, { once: !0 }), n(), K.sync(() => {
|
|
1529
|
-
r(), e.controller.signal.removeEventListener("abort", n);
|
|
1530
|
-
});
|
|
1531
|
-
}).pipe(K.timeoutFail({
|
|
1532
|
-
duration: this.#c(r).options.replayWindowMs,
|
|
1533
|
-
onTimeout: () => new Z("timeout")
|
|
1534
|
-
}));
|
|
1535
|
-
await S(t, n);
|
|
1536
|
-
}
|
|
1537
|
-
this.#u(e, t, n);
|
|
1538
|
-
let o = a.getSnapshot();
|
|
1539
|
-
try {
|
|
1540
|
-
let i = await e.prerequisite.prepare(t, this.#m(e, r));
|
|
1541
|
-
return this.#u(e, t, n), this.#s = i.lease, this.#h({
|
|
1542
|
-
status: "ready",
|
|
1543
|
-
data: i.output,
|
|
1544
|
-
error: void 0
|
|
1545
|
-
}), this.#u(e, t, n), e.prerequisite.assertCurrent(t, i), i;
|
|
1546
|
-
} catch (n) {
|
|
1547
|
-
throw this.#i === e && this.#n().runtime === t && a.getSnapshot() === o && this.#h({
|
|
1548
|
-
status: "error",
|
|
1549
|
-
data: void 0,
|
|
1550
|
-
error: n
|
|
1551
|
-
}), n;
|
|
1552
|
-
}
|
|
1553
|
-
}
|
|
1554
|
-
#m(e, t) {
|
|
1555
|
-
return K.suspend(() => {
|
|
1556
|
-
let n = `setup_${e.key}_${++this.#o}`;
|
|
1557
|
-
return kn({
|
|
1558
|
-
id: n,
|
|
1559
|
-
apiName: this.#e,
|
|
1560
|
-
tag: this.#t,
|
|
1561
|
-
input: e.input
|
|
1562
|
-
}), K.suspend(() => {
|
|
1563
|
-
this.#u(e, t.runtime, t.client);
|
|
1564
|
-
let n = v(t.client, this.#t);
|
|
1565
|
-
return z(n(e.input), e.key);
|
|
1566
|
-
}).pipe(K.withSpan(`client.connectionSetup.${this.#t}`)).pipe(K.onExit((e) => K.sync(() => {
|
|
1567
|
-
if (ze.isSuccess(e)) X(n, {
|
|
1568
|
-
status: "success",
|
|
1569
|
-
output: e.value
|
|
1570
|
-
}), t.errorBus.emitSuccess({
|
|
1571
|
-
source: "mutation",
|
|
1572
|
-
tag: this.#t
|
|
1573
|
-
});
|
|
1574
|
-
else {
|
|
1575
|
-
let r = i(e.cause);
|
|
1576
|
-
if (X(n, {
|
|
1577
|
-
status: "error",
|
|
1578
|
-
error: r
|
|
1579
|
-
}), !Le.isInterruptedOnly(e.cause)) {
|
|
1580
|
-
let e = o(r, "handler");
|
|
1581
|
-
t.errorBus.emit({
|
|
1582
|
-
source: "mutation",
|
|
1583
|
-
tag: this.#t,
|
|
1584
|
-
error: r,
|
|
1585
|
-
kind: e,
|
|
1586
|
-
outcome: e === "transport" ? "unknown" : "known"
|
|
1587
|
-
});
|
|
1588
|
-
}
|
|
1589
|
-
}
|
|
1590
|
-
})));
|
|
1591
|
-
});
|
|
1592
|
-
}
|
|
1593
|
-
#h(e) {
|
|
1594
|
-
if (this.#a.status !== e.status || this.#a.data !== e.data || this.#a.error !== e.error) {
|
|
1595
|
-
this.#a = e;
|
|
1596
|
-
for (let e of this.#r) try {
|
|
1597
|
-
e();
|
|
1598
|
-
} catch {}
|
|
1599
|
-
}
|
|
1600
|
-
}
|
|
1601
|
-
}, Sr = (e, t) => {
|
|
1602
|
-
let n = k(e), r = U(n);
|
|
1603
|
-
r.current = n;
|
|
1604
|
-
let i = H(() => new xr(e, t, () => r.current), [e, t]), a = B((n) => i.activate(n, () => N(r, e, t)), [
|
|
1605
|
-
i,
|
|
1606
|
-
e,
|
|
1607
|
-
t
|
|
1608
|
-
]), o = G(i.subscribe, i.getSnapshot, i.getSnapshot);
|
|
1609
|
-
return V(() => i.watch(r.current), [
|
|
1610
|
-
i,
|
|
1611
|
-
n.runtime,
|
|
1612
|
-
n.client,
|
|
1613
|
-
n.recovery
|
|
1614
|
-
]), V(() => () => i.clear(), [i]), {
|
|
1615
|
-
...o,
|
|
1616
|
-
handle: i.handle,
|
|
1617
|
-
activate: a,
|
|
1618
|
-
clear: i.clear,
|
|
1619
|
-
ready: o.status === "ready"
|
|
1620
|
-
};
|
|
1621
|
-
}, Cr = J, wr = (e) => ({
|
|
1622
|
-
useSubscription: (t, n, r) => Cr(e, t, n, r),
|
|
1623
|
-
useMutation: (t) => Zn(e, t),
|
|
1624
|
-
useConnectionSetup: (t) => Sr(e, t),
|
|
1625
|
-
useAction: (t) => nr(e, t),
|
|
1626
|
-
useFormBinding: (t, n) => fr(e, t, n ?? {})
|
|
1627
|
-
}), Tr = () => ({ seeds: [] }), Er = null, Dr = (e) => {
|
|
1628
|
-
Er = e;
|
|
1629
|
-
}, Or = /* @__PURE__ */ new Map(), kr = (e, t) => `${e}\u0000${t}`, Ar = (e, t, n, r) => {
|
|
1630
|
-
let i = Er?.() ?? null;
|
|
1631
|
-
if (i === null) throw Error(`seedPreloadedSubscription('${e}', '${t}') was called outside a server render. Preload seeds exist to put a subscription's first value into the SSR hydration payload; on the client the live subscription already provides it. (If this IS server code, the render did not install a seed bag — that is a framework bug.)`);
|
|
1632
|
-
i.seeds.push({
|
|
1633
|
-
api: e,
|
|
1634
|
-
key: f([t, n]),
|
|
1635
|
-
value: r
|
|
1636
|
-
});
|
|
1637
|
-
}, jr = (e, t, n) => {
|
|
1638
|
-
let r = Er?.() ?? null;
|
|
1639
|
-
r !== null && r.seeds.push({
|
|
1640
|
-
api: e,
|
|
1641
|
-
key: f([t, n]),
|
|
1642
|
-
value: void 0,
|
|
1643
|
-
failed: !0
|
|
1644
|
-
});
|
|
1645
|
-
}, Mr = (e) => {
|
|
1646
|
-
if (e !== void 0) for (let t of e) Or.set(kr(t.api, t.key), {
|
|
1647
|
-
value: t.value,
|
|
1648
|
-
failed: t.failed === !0
|
|
1649
|
-
});
|
|
1650
|
-
}, Nr = (e, t, n) => {
|
|
1651
|
-
let r = f([t, n]), i = Er?.() ?? null;
|
|
1652
|
-
if (i !== null) {
|
|
1653
|
-
for (let t of i.seeds) if (t.api === e && t.key === r) return t.failed === !0 ? void 0 : t.value;
|
|
1654
|
-
return;
|
|
1655
|
-
}
|
|
1656
|
-
let a = Or.get(kr(e, r));
|
|
1657
|
-
return a === void 0 || a.failed ? void 0 : a.value;
|
|
1658
|
-
}, Pr = (e, t, n) => {
|
|
1659
|
-
let r = f([t, n]), i = Er?.() ?? null;
|
|
1660
|
-
if (i !== null) {
|
|
1661
|
-
for (let t of i.seeds) if (t.api === e && t.key === r) return t.failed === !0 ? "failed" : "seeded";
|
|
1662
|
-
return "absent";
|
|
1663
|
-
}
|
|
1664
|
-
let a = Or.get(kr(e, r));
|
|
1665
|
-
return a === void 0 ? "absent" : a.failed ? "failed" : "seeded";
|
|
1666
|
-
}, Fr = () => {
|
|
1667
|
-
Or.clear();
|
|
1668
|
-
};
|
|
1669
|
-
//#endregion
|
|
1670
|
-
//#region src/usePreloadedSubscription.ts
|
|
1671
|
-
function Ir(e, t, n = {}, r = {}) {
|
|
1672
|
-
let i = Nr(e, t, n), a = J(e, t, n, i === void 0 ? r : {
|
|
1673
|
-
...r,
|
|
1674
|
-
initialSnapshot: i
|
|
1675
|
-
});
|
|
1676
|
-
return Pr(e, t, n) === "failed" ? {
|
|
1677
|
-
...a,
|
|
1678
|
-
preloadFailed: !0
|
|
1679
|
-
} : a;
|
|
1680
|
-
}
|
|
1681
|
-
//#endregion
|
|
1682
|
-
//#region src/useEvent.ts
|
|
1683
|
-
var Lr = {
|
|
1684
|
-
status: "idle",
|
|
1685
|
-
missed: 0,
|
|
1686
|
-
lastMiss: void 0
|
|
1687
|
-
}, Rr = class {
|
|
1688
|
-
_tag = "EventStreamClosed";
|
|
1689
|
-
};
|
|
1690
|
-
function zr(e, t, n, r = {}) {
|
|
1691
|
-
let { skip: i = !1, apiName: o = "app", onMissed: s } = r, c = k(o), { runtime: l, client: u } = c, [d, f] = W(Lr), p = U(n);
|
|
1692
|
-
p.current = n;
|
|
1693
|
-
let m = U(s);
|
|
1694
|
-
m.current = s;
|
|
1695
|
-
let h = U(u);
|
|
1696
|
-
h.current = u;
|
|
1697
|
-
let g = U(l);
|
|
1698
|
-
g.current = l;
|
|
1699
|
-
let _ = U(/* @__PURE__ */ new Map()), y = t === null ? null : JSON.stringify(Object.entries(t).sort(([e], [t]) => e < t ? -1 : 1)), b = U(t);
|
|
1700
|
-
b.current = t;
|
|
1701
|
-
let x = U(null);
|
|
1702
|
-
x.current !== y && (x.current = y, _.current = /* @__PURE__ */ new Map());
|
|
1703
|
-
let S = B((t, n) => {
|
|
1704
|
-
t <= 0 || (a(o, "event.gap", {
|
|
1705
|
-
tag: e.name,
|
|
1706
|
-
missed: t,
|
|
1707
|
-
reason: n
|
|
1708
|
-
}), f((e) => ({
|
|
1709
|
-
...e,
|
|
1710
|
-
missed: e.missed + t,
|
|
1711
|
-
lastMiss: {
|
|
1712
|
-
count: t,
|
|
1713
|
-
reason: n
|
|
1714
|
-
}
|
|
1715
|
-
})), m.current?.({
|
|
1716
|
-
count: t,
|
|
1717
|
-
reason: n
|
|
1718
|
-
}));
|
|
1719
|
-
}, [o, e.name]), C = !i && y !== null && !te(c);
|
|
1720
|
-
return V(() => {
|
|
1721
|
-
if (!C) {
|
|
1722
|
-
f(Lr);
|
|
1723
|
-
return;
|
|
1724
|
-
}
|
|
1725
|
-
f((e) => ({
|
|
1726
|
-
...e,
|
|
1727
|
-
status: "connecting"
|
|
1728
|
-
}));
|
|
1729
|
-
let t = 0, n = K.sync(() => {
|
|
1730
|
-
let t = [..._.current].map(([e, t]) => ({
|
|
1731
|
-
origin: e,
|
|
1732
|
-
n: t
|
|
1733
|
-
}));
|
|
1734
|
-
return v(h.current, e.name)({
|
|
1735
|
-
key: b.current,
|
|
1736
|
-
...t.length > 0 ? { resume: t } : {}
|
|
1737
|
-
});
|
|
1738
|
-
}), r = q.unwrap(n).pipe(q.tap(() => K.sync(() => {
|
|
1739
|
-
t = 0;
|
|
1740
|
-
})), q.concat(q.fail(new Rr())), q.retry(He.exponential("250 millis", 2).pipe(He.either(He.spaced("30 seconds")), He.jittered, He.tapOutput(() => K.sync(() => {
|
|
1741
|
-
t += 1, f((e) => ({
|
|
1742
|
-
...e,
|
|
1743
|
-
status: "connecting"
|
|
1744
|
-
}));
|
|
1745
|
-
}))))), i = g.current.runFork(q.runForEach(r, (e) => K.sync(() => {
|
|
1746
|
-
if (e._tag === "attached") {
|
|
1747
|
-
f((e) => ({
|
|
1748
|
-
...e,
|
|
1749
|
-
status: "live"
|
|
1750
|
-
}));
|
|
1751
|
-
return;
|
|
1752
|
-
}
|
|
1753
|
-
if (e._tag === "gap") {
|
|
1754
|
-
S(e.missed, e.reason);
|
|
1755
|
-
return;
|
|
1756
|
-
}
|
|
1757
|
-
_.current.set(e.origin, Math.max(_.current.get(e.origin) ?? 0, e.n)), p.current(e.payload);
|
|
1758
|
-
})));
|
|
1759
|
-
return () => {
|
|
1760
|
-
g.current.runFork(i.interruptAsFork(i.id()));
|
|
1761
|
-
};
|
|
1762
|
-
}, [
|
|
1763
|
-
C,
|
|
1764
|
-
y,
|
|
1765
|
-
e.name,
|
|
1766
|
-
S
|
|
1767
|
-
]), C ? d : Lr;
|
|
1768
|
-
}
|
|
1769
|
-
//#endregion
|
|
1770
|
-
//#region src/sequence.ts
|
|
1771
|
-
var Br = () => {
|
|
1772
|
-
let e = (t) => ({
|
|
1773
|
-
steps: t,
|
|
1774
|
-
step: ((n, r, i) => e([...t, {
|
|
1775
|
-
name: n,
|
|
1776
|
-
run: r,
|
|
1777
|
-
undo: i?.undo,
|
|
1778
|
-
covers: i?.covers ?? [],
|
|
1779
|
-
when: i?.when
|
|
1780
|
-
}]))
|
|
1781
|
-
});
|
|
1782
|
-
return e([]);
|
|
1783
|
-
}, Vr = async (e, t = {}) => {
|
|
1784
|
-
let n = {}, r = [];
|
|
1785
|
-
for (let i of e.steps) {
|
|
1786
|
-
if (i.when !== void 0 && !i.when(n)) {
|
|
1787
|
-
n[i.name] = void 0;
|
|
1788
|
-
continue;
|
|
1789
|
-
}
|
|
1790
|
-
try {
|
|
1791
|
-
let e = await i.run(n);
|
|
1792
|
-
n[i.name] = e, r.push({
|
|
1793
|
-
step: i,
|
|
1794
|
-
result: e
|
|
1795
|
-
});
|
|
1796
|
-
} catch (e) {
|
|
1797
|
-
let a = [], o = [], s = [], c = [];
|
|
1798
|
-
if (t.compensate !== !1) {
|
|
1799
|
-
let e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map();
|
|
1800
|
-
for (let i = r.length - 1; i >= 0; i--) {
|
|
1801
|
-
let l = r[i], u = l.step.name;
|
|
1802
|
-
if (t.has(u)) {
|
|
1803
|
-
c.push({
|
|
1804
|
-
step: u,
|
|
1805
|
-
coveredBy: t.get(u)
|
|
1806
|
-
});
|
|
1807
|
-
continue;
|
|
1808
|
-
}
|
|
1809
|
-
if (e.has(u)) {
|
|
1810
|
-
s.push(u);
|
|
1811
|
-
continue;
|
|
1812
|
-
}
|
|
1813
|
-
if (l.step.undo !== void 0) try {
|
|
1814
|
-
await l.step.undo(l.result, n), a.push(u);
|
|
1815
|
-
for (let t of l.step.covers) e.set(t, u);
|
|
1816
|
-
} catch (e) {
|
|
1817
|
-
o.push({
|
|
1818
|
-
step: u,
|
|
1819
|
-
error: e
|
|
1820
|
-
});
|
|
1821
|
-
for (let e of l.step.covers) t.set(e, u);
|
|
1822
|
-
}
|
|
1823
|
-
}
|
|
1824
|
-
}
|
|
1825
|
-
let l = {
|
|
1826
|
-
failedStep: i.name,
|
|
1827
|
-
compensated: a,
|
|
1828
|
-
compensationFailures: o,
|
|
1829
|
-
compensationCovered: s,
|
|
1830
|
-
compensationUncertain: c
|
|
1831
|
-
};
|
|
1832
|
-
return t.onError?.(e, l), {
|
|
1833
|
-
ok: !1,
|
|
1834
|
-
error: e,
|
|
1835
|
-
...l
|
|
1836
|
-
};
|
|
1837
|
-
}
|
|
1838
|
-
}
|
|
1839
|
-
return {
|
|
1840
|
-
ok: !0,
|
|
1841
|
-
data: n
|
|
1842
|
-
};
|
|
1843
|
-
}, Hr = (e = {}) => {
|
|
1844
|
-
let [t, n] = W(!1), [r, i] = W(void 0), [a, o] = W(void 0), s = U(e);
|
|
1845
|
-
return s.current = e, {
|
|
1846
|
-
run: B(async (e, t = {}) => {
|
|
1847
|
-
n(!0), i(void 0), o(void 0);
|
|
1848
|
-
try {
|
|
1849
|
-
let n = await Vr(e, {
|
|
1850
|
-
...s.current,
|
|
1851
|
-
...t
|
|
1852
|
-
});
|
|
1853
|
-
return n.ok || (i(n.error), o(n.failedStep)), n;
|
|
1854
|
-
} finally {
|
|
1855
|
-
n(!1);
|
|
1856
|
-
}
|
|
1857
|
-
}, []),
|
|
1858
|
-
pending: t,
|
|
1859
|
-
error: r,
|
|
1860
|
-
failedStep: a
|
|
1861
|
-
};
|
|
1862
|
-
}, Ur = "@voltro/plugin-storage", Q = (e) => et(Ur, e), Wr = (e, t, n, r) => new Promise((i, a) => {
|
|
1863
|
-
let o = new XMLHttpRequest();
|
|
1864
|
-
if (o.open("PUT", e), o.upload.onprogress = (e) => {
|
|
1865
|
-
e.lengthComputable && n(e.loaded / e.total);
|
|
1866
|
-
}, o.onload = () => {
|
|
1867
|
-
if (o.status >= 200 && o.status < 300) {
|
|
1868
|
-
let e = o.getResponseHeader("ETag") ?? o.getResponseHeader("etag");
|
|
1869
|
-
e ? i(e) : a(/* @__PURE__ */ Error("multipart part: response carried no ETag (the bucket CORS must expose the ETag header)"));
|
|
1870
|
-
} else a(Error(`multipart part failed (${o.status}): ${o.responseText || o.statusText}`.trim()));
|
|
1871
|
-
}, o.onerror = () => a(/* @__PURE__ */ Error("multipart part: network error")), o.onabort = () => a(new DOMException("upload aborted", "AbortError")), r.aborted) {
|
|
1872
|
-
o.abort();
|
|
1873
|
-
return;
|
|
1874
|
-
}
|
|
1875
|
-
r.addEventListener("abort", () => o.abort(), { once: !0 }), o.send(t);
|
|
1876
|
-
}), Gr = (e, t, n, r, i, a) => new Promise((o, s) => {
|
|
1877
|
-
let c = new XMLHttpRequest();
|
|
1878
|
-
if (c.open("POST", e), c.setRequestHeader("content-type", t), c.upload.onprogress = (e) => {
|
|
1879
|
-
e.lengthComputable && r(e.loaded / e.total);
|
|
1880
|
-
}, c.onload = () => {
|
|
1881
|
-
if (c.status >= 200 && c.status < 300) {
|
|
1882
|
-
if (!a) return o(null);
|
|
1883
|
-
try {
|
|
1884
|
-
o(JSON.parse(c.responseText));
|
|
1885
|
-
} catch {
|
|
1886
|
-
s(/* @__PURE__ */ Error("resumable upload: malformed final response"));
|
|
1887
|
-
}
|
|
1888
|
-
} else s(Error(`resumable chunk failed (${c.status}): ${c.responseText || c.statusText}`.trim()));
|
|
1889
|
-
}, c.onerror = () => s(/* @__PURE__ */ Error("resumable chunk: network error")), c.onabort = () => s(new DOMException("upload aborted", "AbortError")), i.aborted) {
|
|
1890
|
-
c.abort();
|
|
1891
|
-
return;
|
|
1892
|
-
}
|
|
1893
|
-
i.addEventListener("abort", () => c.abort(), { once: !0 }), c.send(n);
|
|
1894
|
-
}), Kr = (e, t, n, r, i) => new Promise((a, o) => {
|
|
1895
|
-
let s = new XMLHttpRequest();
|
|
1896
|
-
if (s.open("PUT", e), s.setRequestHeader("content-type", t), s.upload.onprogress = (e) => {
|
|
1897
|
-
e.lengthComputable && r(e.loaded / e.total);
|
|
1898
|
-
}, s.onload = () => {
|
|
1899
|
-
s.status >= 200 && s.status < 300 ? a() : o(Error(`direct upload failed (${s.status}): ${s.responseText || s.statusText}`.trim()));
|
|
1900
|
-
}, s.onerror = () => o(/* @__PURE__ */ Error("direct upload: network error")), s.onabort = () => o(new DOMException("upload aborted", "AbortError")), i.aborted) {
|
|
1901
|
-
s.abort();
|
|
1902
|
-
return;
|
|
1903
|
-
}
|
|
1904
|
-
i.addEventListener("abort", () => s.abort(), { once: !0 }), s.send(n);
|
|
1905
|
-
}), qr = (e, t, n, r, i) => new Promise((a, o) => {
|
|
1906
|
-
let s = new XMLHttpRequest();
|
|
1907
|
-
if (s.open("POST", e), s.setRequestHeader("content-type", t), s.upload.onprogress = (e) => {
|
|
1908
|
-
e.lengthComputable && r(e.loaded / e.total);
|
|
1909
|
-
}, s.onload = () => {
|
|
1910
|
-
if (s.status >= 200 && s.status < 300) try {
|
|
1911
|
-
a(JSON.parse(s.responseText));
|
|
1912
|
-
} catch {
|
|
1913
|
-
o(/* @__PURE__ */ Error("storage upload: malformed response"));
|
|
1914
|
-
}
|
|
1915
|
-
else o(Error(`storage upload failed (${s.status}): ${s.responseText || s.statusText}`.trim()));
|
|
1916
|
-
}, s.onerror = () => o(/* @__PURE__ */ Error("storage upload: network error")), s.onabort = () => o(new DOMException("upload aborted", "AbortError")), i.aborted) {
|
|
1917
|
-
s.abort();
|
|
1918
|
-
return;
|
|
1919
|
-
}
|
|
1920
|
-
i.addEventListener("abort", () => s.abort(), { once: !0 }), s.send(n);
|
|
1921
|
-
}), Jr = (e, t = {}) => {
|
|
1922
|
-
let n = k(e), { inspectBaseUrl: r } = n, i = U(n);
|
|
1923
|
-
i.current = n;
|
|
1924
|
-
let [a, s] = W(0), [c, l] = W("idle"), [u, d] = W(void 0), f = U(null), p = B(() => {
|
|
1925
|
-
s(0), l("idle"), d(void 0);
|
|
1926
|
-
}, []), m = B(() => {
|
|
1927
|
-
f.current?.abort();
|
|
1928
|
-
}, []), h = B((e) => /^https?:\/\//.test(e) ? e : `${r}${e}`, [r]), g = B(async (n, r, a, o) => {
|
|
1929
|
-
let { runtime: s, client: c } = await N(i, e, "storage.upload").catch((e) => {
|
|
1930
|
-
throw T(e, "client");
|
|
1931
|
-
}), l = Math.max(0, r.retries ?? t.retries ?? 1), u = (n instanceof File, n.type || "application/octet-stream"), d = n instanceof File ? n.name : "blob", f = r.visibility ?? t.visibility, p = r.key ?? t.key, m = r.folder ?? t.folder, g = r.tags ?? t.tags, _ = {
|
|
1932
|
-
...f ? { visibility: f } : {},
|
|
1933
|
-
...m ? { folder: m } : {},
|
|
1934
|
-
...g ? { tags: g } : {},
|
|
1935
|
-
...r.alt ? { alt: r.alt } : {},
|
|
1936
|
-
...r.caption ? { caption: r.caption } : {}
|
|
1937
|
-
}, y = (e) => ({
|
|
1938
|
-
id: e.id,
|
|
1939
|
-
url: h(e.url),
|
|
1940
|
-
name: d,
|
|
1941
|
-
mime: e.contentType,
|
|
1942
|
-
size: e.size,
|
|
1943
|
-
...e.width === void 0 ? {} : { width: e.width },
|
|
1944
|
-
...e.height === void 0 ? {} : { height: e.height }
|
|
1945
|
-
}), b = async () => {
|
|
1946
|
-
let e = r.mintTag ?? t.mintTag ?? Q("mintUploadTicket"), i = v(c, e), l = await S(s, i({
|
|
1947
|
-
contentType: u,
|
|
1948
|
-
..._,
|
|
1949
|
-
...p ? { key: p } : {}
|
|
1950
|
-
})), d = await qr(h(l.uploadUrl), u, n, o, a);
|
|
1951
|
-
return y(d);
|
|
1952
|
-
}, x = async () => {
|
|
1953
|
-
let e = r.presignMintTag ?? t.presignMintTag ?? Q("mintPresignedUpload"), i = r.finalizeTag ?? t.finalizeTag ?? Q("finalizeUpload"), l;
|
|
1954
|
-
try {
|
|
1955
|
-
let t = v(c, e);
|
|
1956
|
-
l = await S(s, t({
|
|
1957
|
-
contentType: u,
|
|
1958
|
-
..._
|
|
1959
|
-
}));
|
|
1960
|
-
} catch {
|
|
1961
|
-
return null;
|
|
1962
|
-
}
|
|
1963
|
-
await Kr(l.uploadUrl, u, n, o, a);
|
|
1964
|
-
let d = v(c, i), f = await S(s, d({ finalizeToken: l.finalizeToken }));
|
|
1965
|
-
return y(f);
|
|
1966
|
-
}, C = async () => {
|
|
1967
|
-
let e = r.beginResumableTag ?? t.beginResumableTag ?? Q("beginResumableUpload"), i = v(c, e), l = n.size, d = r.chunkSize ?? t.chunkSize, f = await S(s, i({
|
|
1968
|
-
contentType: u,
|
|
1969
|
-
size: l,
|
|
1970
|
-
..._,
|
|
1971
|
-
...d ? { chunkSize: d } : {}
|
|
1972
|
-
})), p = h(f.uploadUrl), m = Math.max(1, f.chunkSize), g = Math.max(1, Math.ceil(l / m)), b = Math.max(0, r.retries ?? t.retries ?? 1), x = 0, C = null;
|
|
1973
|
-
for (let e = 0; e < g; e++) {
|
|
1974
|
-
let t = e * m, r = Math.min(l, t + m), i = n.slice(t, r), s = e === g - 1, c = r - t, d = 0;
|
|
1975
|
-
for (;;) {
|
|
1976
|
-
if (a.aborted) throw new DOMException("upload aborted", "AbortError");
|
|
1977
|
-
try {
|
|
1978
|
-
let t = await Gr(`${p}?${`token=${encodeURIComponent(f.resumableToken)}&index=${e}${s ? "&final=1" : ""}`}`, u, i, (e) => o((x + e * c) / l), a, s);
|
|
1979
|
-
s && (C = t);
|
|
1980
|
-
break;
|
|
1981
|
-
} catch (e) {
|
|
1982
|
-
if (e instanceof DOMException && e.name === "AbortError" || d++ >= b) throw e;
|
|
1983
|
-
}
|
|
1984
|
-
}
|
|
1985
|
-
x += c, o(x / l);
|
|
1986
|
-
}
|
|
1987
|
-
if (!C) throw Error("resumable upload produced no final reply");
|
|
1988
|
-
return y(C);
|
|
1989
|
-
}, w = async () => {
|
|
1990
|
-
let e = r.multipartBeginTag ?? t.multipartBeginTag ?? Q("beginMultipartUpload"), i = r.multipartSignTag ?? t.multipartSignTag ?? Q("signMultipartPart"), l = r.multipartCompleteTag ?? t.multipartCompleteTag ?? Q("completeMultipartUpload"), f = r.multipartAbortTag ?? t.multipartAbortTag ?? Q("abortMultipartUpload"), p = n.size, m = r.chunkSize ?? t.chunkSize, g;
|
|
1991
|
-
try {
|
|
1992
|
-
let t = v(c, e);
|
|
1993
|
-
g = await S(s, t({
|
|
1994
|
-
contentType: u,
|
|
1995
|
-
size: p,
|
|
1996
|
-
..._,
|
|
1997
|
-
...m ? { partSize: m } : {}
|
|
1998
|
-
}));
|
|
1999
|
-
} catch {
|
|
2000
|
-
return null;
|
|
2001
|
-
}
|
|
2002
|
-
let y = v(c, i), b = v(c, l), x = v(c, f), C = Math.max(1, g.partSize), w = Math.max(1, Math.ceil(p / C)), T = Math.max(0, r.retries ?? t.retries ?? 1), E = [], D = 0;
|
|
2003
|
-
try {
|
|
2004
|
-
for (let e = 0; e < w; e++) {
|
|
2005
|
-
let t = e * C, r = Math.min(p, t + C), i = n.slice(t, r), c = e + 1, l = r - t, u = 0;
|
|
2006
|
-
for (;;) {
|
|
2007
|
-
if (a.aborted) throw new DOMException("upload aborted", "AbortError");
|
|
2008
|
-
try {
|
|
2009
|
-
let { url: e } = await S(s, y({
|
|
2010
|
-
multipartToken: g.multipartToken,
|
|
2011
|
-
partNumber: c
|
|
2012
|
-
})), t = await Wr(e, i, (e) => o((D + e * l) / p), a);
|
|
2013
|
-
E.push({
|
|
2014
|
-
partNumber: c,
|
|
2015
|
-
etag: t
|
|
2016
|
-
});
|
|
2017
|
-
break;
|
|
2018
|
-
} catch (e) {
|
|
2019
|
-
if (e instanceof DOMException && e.name === "AbortError" || u++ >= T) throw e;
|
|
2020
|
-
}
|
|
2021
|
-
}
|
|
2022
|
-
D += l, o(D / p);
|
|
2023
|
-
}
|
|
2024
|
-
let e = await S(s, b({
|
|
2025
|
-
multipartToken: g.multipartToken,
|
|
2026
|
-
parts: E
|
|
2027
|
-
}));
|
|
2028
|
-
return {
|
|
2029
|
-
id: e.id,
|
|
2030
|
-
url: h(e.url),
|
|
2031
|
-
name: d,
|
|
2032
|
-
mime: u,
|
|
2033
|
-
size: e.size
|
|
2034
|
-
};
|
|
2035
|
-
} catch (e) {
|
|
2036
|
-
try {
|
|
2037
|
-
await S(s, x({ multipartToken: g.multipartToken }));
|
|
2038
|
-
} catch {}
|
|
2039
|
-
throw e;
|
|
2040
|
-
}
|
|
2041
|
-
};
|
|
2042
|
-
if ((r.prefer ?? t.prefer) === "multipart") return await w() || await C();
|
|
2043
|
-
if ((r.prefer ?? t.prefer) === "resumable") return await C();
|
|
2044
|
-
let E = (r.prefer ?? t.prefer) === "presign", D;
|
|
2045
|
-
for (let e = 0; e <= l; e++) {
|
|
2046
|
-
if (a.aborted) throw new DOMException("upload aborted", "AbortError");
|
|
2047
|
-
try {
|
|
2048
|
-
if (E) {
|
|
2049
|
-
let e = await x();
|
|
2050
|
-
if (e) return e;
|
|
2051
|
-
}
|
|
2052
|
-
return await b();
|
|
2053
|
-
} catch (t) {
|
|
2054
|
-
if (t instanceof DOMException && t.name === "AbortError" || (D = t, e === l)) throw t;
|
|
2055
|
-
}
|
|
2056
|
-
}
|
|
2057
|
-
throw D;
|
|
2058
|
-
}, [
|
|
2059
|
-
e,
|
|
2060
|
-
h,
|
|
2061
|
-
t.mintTag,
|
|
2062
|
-
t.presignMintTag,
|
|
2063
|
-
t.finalizeTag,
|
|
2064
|
-
t.beginResumableTag,
|
|
2065
|
-
t.multipartBeginTag,
|
|
2066
|
-
t.multipartSignTag,
|
|
2067
|
-
t.multipartCompleteTag,
|
|
2068
|
-
t.multipartAbortTag,
|
|
2069
|
-
t.chunkSize,
|
|
2070
|
-
t.prefer,
|
|
2071
|
-
t.visibility,
|
|
2072
|
-
t.key,
|
|
2073
|
-
t.folder,
|
|
2074
|
-
t.tags,
|
|
2075
|
-
t.retries
|
|
2076
|
-
]), _ = B(async (e, n = {}) => {
|
|
2077
|
-
let r = new AbortController();
|
|
2078
|
-
f.current = r, l("uploading"), d(void 0), s(0);
|
|
2079
|
-
try {
|
|
2080
|
-
let t = await g(e, n, r.signal, s);
|
|
2081
|
-
return s(1), l("success"), t;
|
|
2082
|
-
} catch (e) {
|
|
2083
|
-
throw l("error"), d(e), e instanceof DOMException && e.name === "AbortError" || i.current.errorBus.emit({
|
|
2084
|
-
source: "action",
|
|
2085
|
-
tag: n.mintTag ?? t.mintTag ?? Q("mintUploadTicket"),
|
|
2086
|
-
error: e,
|
|
2087
|
-
kind: o(e, "unknown"),
|
|
2088
|
-
outcome: o(e, "unknown") === "transport" ? "unknown" : "not-applicable"
|
|
2089
|
-
}), e;
|
|
2090
|
-
}
|
|
2091
|
-
}, [g, t.mintTag]), y = B(async (e, n = {}) => {
|
|
2092
|
-
if (e.length === 0) return [];
|
|
2093
|
-
let r = new AbortController();
|
|
2094
|
-
f.current = r, l("uploading"), d(void 0), s(0);
|
|
2095
|
-
let a = Math.max(1, n.concurrency ?? t.concurrency ?? 3), c = Array(e.length), u = Array(e.length).fill(0), p = () => s(u.reduce((e, t) => e + t, 0) / e.length), m = 0, h = async () => {
|
|
2096
|
-
for (;;) {
|
|
2097
|
-
let t = m++;
|
|
2098
|
-
if (t >= e.length) return;
|
|
2099
|
-
c[t] = await g(e[t], n, r.signal, (e) => {
|
|
2100
|
-
u[t] = e, p();
|
|
2101
|
-
}), u[t] = 1, p();
|
|
2102
|
-
}
|
|
2103
|
-
};
|
|
2104
|
-
try {
|
|
2105
|
-
return await Promise.all(Array.from({ length: Math.min(a, e.length) }, () => h())), s(1), l("success"), c;
|
|
2106
|
-
} catch (e) {
|
|
2107
|
-
throw r.abort(), l("error"), d(e), e instanceof DOMException && e.name === "AbortError" || i.current.errorBus.emit({
|
|
2108
|
-
source: "action",
|
|
2109
|
-
tag: n.mintTag ?? t.mintTag ?? Q("mintUploadTicket"),
|
|
2110
|
-
error: e,
|
|
2111
|
-
kind: o(e, "unknown"),
|
|
2112
|
-
outcome: o(e, "unknown") === "transport" ? "unknown" : "not-applicable"
|
|
2113
|
-
}), e;
|
|
2114
|
-
}
|
|
2115
|
-
}, [
|
|
2116
|
-
g,
|
|
2117
|
-
t.concurrency,
|
|
2118
|
-
t.mintTag
|
|
2119
|
-
]), b = B((e, t = {}) => {
|
|
2120
|
-
e.preventDefault();
|
|
2121
|
-
let n = e.dataTransfer ? Array.from(e.dataTransfer.files) : [];
|
|
2122
|
-
return n.length ? y(n, t) : Promise.resolve([]);
|
|
2123
|
-
}, [y]), x = B((e, t = {}) => {
|
|
2124
|
-
let n = e.clipboardData ? Array.from(e.clipboardData.files) : [];
|
|
2125
|
-
return n.length ? y(n, t) : Promise.resolve([]);
|
|
2126
|
-
}, [y]), C = H(() => ({
|
|
2127
|
-
onDragOver: (e) => e.preventDefault(),
|
|
2128
|
-
onDrop: (e) => {
|
|
2129
|
-
b(e);
|
|
2130
|
-
}
|
|
2131
|
-
}), [b]);
|
|
2132
|
-
return H(() => ({
|
|
2133
|
-
upload: _,
|
|
2134
|
-
uploadMany: y,
|
|
2135
|
-
progress: a,
|
|
2136
|
-
status: c,
|
|
2137
|
-
error: u,
|
|
2138
|
-
cancel: m,
|
|
2139
|
-
reset: p,
|
|
2140
|
-
onDrop: b,
|
|
2141
|
-
onPaste: x,
|
|
2142
|
-
dropzoneProps: C
|
|
2143
|
-
}), [
|
|
2144
|
-
_,
|
|
2145
|
-
y,
|
|
2146
|
-
a,
|
|
2147
|
-
c,
|
|
2148
|
-
u,
|
|
2149
|
-
m,
|
|
2150
|
-
p,
|
|
2151
|
-
b,
|
|
2152
|
-
x,
|
|
2153
|
-
C
|
|
2154
|
-
]);
|
|
2155
|
-
}, Yr = (e, t) => {
|
|
2156
|
-
let n = Jr(e), r = nr(e, t.action), [i, a] = W("idle"), [o, s] = W(void 0), [c, l] = W(void 0), u = U(t.extra);
|
|
2157
|
-
u.current = t.extra;
|
|
2158
|
-
let d = B(async (e) => {
|
|
2159
|
-
l(void 0), s(void 0), a("uploading");
|
|
2160
|
-
let t;
|
|
2161
|
-
try {
|
|
2162
|
-
t = await n.upload(e);
|
|
2163
|
-
} catch (e) {
|
|
2164
|
-
throw a("error"), l(e), e;
|
|
2165
|
-
}
|
|
2166
|
-
a("transcribing");
|
|
2167
|
-
try {
|
|
2168
|
-
let e = await r.run({
|
|
2169
|
-
storageRef: t.id,
|
|
2170
|
-
...u.current ?? {}
|
|
2171
|
-
});
|
|
2172
|
-
return s(e), a("done"), e;
|
|
2173
|
-
} catch (e) {
|
|
2174
|
-
throw a("error"), l(e), e;
|
|
2175
|
-
}
|
|
2176
|
-
}, [n, r]), f = B(() => {
|
|
2177
|
-
n.cancel(), a("idle");
|
|
2178
|
-
}, [n]), p = B(() => {
|
|
2179
|
-
n.reset(), a("idle"), s(void 0), l(void 0);
|
|
2180
|
-
}, [n]);
|
|
2181
|
-
return H(() => ({
|
|
2182
|
-
phase: i,
|
|
2183
|
-
progress: i === "uploading" ? n.progress : void 0,
|
|
2184
|
-
result: o,
|
|
2185
|
-
error: c ?? n.error,
|
|
2186
|
-
transcribe: d,
|
|
2187
|
-
cancel: f,
|
|
2188
|
-
reset: p
|
|
2189
|
-
}), [
|
|
2190
|
-
i,
|
|
2191
|
-
n.progress,
|
|
2192
|
-
n.error,
|
|
2193
|
-
o,
|
|
2194
|
-
c,
|
|
2195
|
-
d,
|
|
2196
|
-
f,
|
|
2197
|
-
p
|
|
2198
|
-
]);
|
|
2199
|
-
}, $ = async (e) => {
|
|
2200
|
-
let t = v(e.client, e.tag), n = K.currentSpan.pipe(K.tap((t) => K.sync(() => {
|
|
2201
|
-
r({
|
|
2202
|
-
traceId: t.traceId,
|
|
2203
|
-
spanId: t.spanId,
|
|
2204
|
-
source: "mutation",
|
|
2205
|
-
tag: e.tag
|
|
2206
|
-
});
|
|
2207
|
-
})), K.catchAll(() => K.void), K.zipRight(t(e.input)), K.withSpan(`${e.spanPrefix}.${e.tag}`, { attributes: {
|
|
2208
|
-
"voltro.api": e.apiName,
|
|
2209
|
-
"rpc.tag": e.tag
|
|
2210
|
-
} }));
|
|
2211
|
-
return S(e.runtime, n);
|
|
2212
|
-
}, Xr = (e, t) => {
|
|
2213
|
-
let n = k(e), { descriptors: r } = n, i = U(n);
|
|
2214
|
-
if (i.current = n, process.env.NODE_ENV !== "production") {
|
|
2215
|
-
let n = r[t]?.kind;
|
|
2216
|
-
n !== void 0 && n !== "workflow" && console.error(`[@voltro/client] useWorkflow('${e}', '${t}') targets a ${n}, not a workflow. Use ${n === "mutation" ? "useMutation" : n === "action" ? "useAction" : `the ${n} hook`} instead.`);
|
|
2217
|
-
}
|
|
2218
|
-
let [a, o] = W(!1), [s, c] = W(void 0), [l, u] = W(void 0), d = B(async (n) => {
|
|
2219
|
-
o(!0), c(void 0);
|
|
2220
|
-
try {
|
|
2221
|
-
let { runtime: r, client: a } = await N(i, e, t), o = await $({
|
|
2222
|
-
apiName: e,
|
|
2223
|
-
runtime: r,
|
|
2224
|
-
client: a,
|
|
2225
|
-
tag: t,
|
|
2226
|
-
input: n,
|
|
2227
|
-
spanPrefix: "client.workflow.start"
|
|
2228
|
-
});
|
|
2229
|
-
return u(o), o;
|
|
2230
|
-
} catch (e) {
|
|
2231
|
-
throw c(e), e;
|
|
2232
|
-
} finally {
|
|
2233
|
-
o(!1);
|
|
2234
|
-
}
|
|
2235
|
-
}, [e, t]), f = B(async (t) => {
|
|
2236
|
-
let n = "__voltro.workflow.queued.cancel", { runtime: r, client: a } = await N(i, e, n);
|
|
2237
|
-
return $({
|
|
2238
|
-
apiName: e,
|
|
2239
|
-
runtime: r,
|
|
2240
|
-
client: a,
|
|
2241
|
-
tag: n,
|
|
2242
|
-
input: t,
|
|
2243
|
-
spanPrefix: "client.workflow.queued.cancel"
|
|
2244
|
-
});
|
|
2245
|
-
}, [e]), p = B(async (t) => {
|
|
2246
|
-
let n = "__voltro.workflow.queued.control", { runtime: r, client: a } = await N(i, e, n), o = v(a, n);
|
|
2247
|
-
return S(r, q.runHead(o(t)).pipe(K.flatMap((e) => {
|
|
2248
|
-
if (Ve.isSome(e)) {
|
|
2249
|
-
if (e.value._tag === "snapshot") return K.succeed(e.value.data);
|
|
2250
|
-
if (e.value._tag === "error") return K.fail(e.value.error);
|
|
2251
|
-
}
|
|
2252
|
-
return K.fail(/* @__PURE__ */ Error("queued workflow control query ended without a snapshot"));
|
|
2253
|
-
})));
|
|
2254
|
-
}, [e]), m = B(async (t) => {
|
|
2255
|
-
let n = "__voltro.workflow.control", { runtime: r, client: a } = await N(i, e, n), o = v(a, n);
|
|
2256
|
-
return S(r, q.runHead(o(t)).pipe(K.flatMap((e) => {
|
|
2257
|
-
if (Ve.isSome(e)) {
|
|
2258
|
-
if (e.value._tag === "snapshot") return K.succeed(e.value.data);
|
|
2259
|
-
if (e.value._tag === "error") return K.fail(e.value.error);
|
|
2260
|
-
}
|
|
2261
|
-
return K.fail(/* @__PURE__ */ Error("workflow control query ended without a snapshot"));
|
|
2262
|
-
})));
|
|
2263
|
-
}, [e]), h = B(async (t, n) => {
|
|
2264
|
-
let { runtime: r, client: a } = await N(i, e, "__voltro.workflow.cancel");
|
|
2265
|
-
return $({
|
|
2266
|
-
apiName: e,
|
|
2267
|
-
runtime: r,
|
|
2268
|
-
client: a,
|
|
2269
|
-
tag: "__voltro.workflow.cancel",
|
|
2270
|
-
input: {
|
|
2271
|
-
...t,
|
|
2272
|
-
...n === void 0 ? {} : { control: n }
|
|
2273
|
-
},
|
|
2274
|
-
spanPrefix: "client.workflow.cancel"
|
|
2275
|
-
});
|
|
2276
|
-
}, [e]), g = B(async (t, n) => {
|
|
2277
|
-
let { runtime: r, client: a } = await N(i, e, "__voltro.workflow.resume");
|
|
2278
|
-
return $({
|
|
2279
|
-
apiName: e,
|
|
2280
|
-
runtime: r,
|
|
2281
|
-
client: a,
|
|
2282
|
-
tag: "__voltro.workflow.resume",
|
|
2283
|
-
input: {
|
|
2284
|
-
...t,
|
|
2285
|
-
...n === void 0 ? {} : { control: n }
|
|
2286
|
-
},
|
|
2287
|
-
spanPrefix: "client.workflow.resume"
|
|
2288
|
-
});
|
|
2289
|
-
}, [e]), _ = B(async (t, n, r) => {
|
|
2290
|
-
let { runtime: a, client: o } = await N(i, e, "__voltro.workflow.signal");
|
|
2291
|
-
return $({
|
|
2292
|
-
apiName: e,
|
|
2293
|
-
runtime: a,
|
|
2294
|
-
client: o,
|
|
2295
|
-
tag: "__voltro.workflow.signal",
|
|
2296
|
-
input: {
|
|
2297
|
-
id: t.id,
|
|
2298
|
-
signalName: n,
|
|
2299
|
-
...r === void 0 ? {} : { payload: r }
|
|
2300
|
-
},
|
|
2301
|
-
spanPrefix: "client.workflow.signal"
|
|
2302
|
-
});
|
|
2303
|
-
}, [e]), y = B(async (t, n, r, a) => {
|
|
2304
|
-
let { runtime: o, client: s } = await N(i, e, "__voltro.workflow.update");
|
|
2305
|
-
return $({
|
|
2306
|
-
apiName: e,
|
|
2307
|
-
runtime: o,
|
|
2308
|
-
client: s,
|
|
2309
|
-
tag: "__voltro.workflow.update",
|
|
2310
|
-
input: {
|
|
2311
|
-
id: t.id,
|
|
2312
|
-
updateName: n,
|
|
2313
|
-
...r === void 0 ? {} : { payload: r },
|
|
2314
|
-
...a?.timeoutMs === void 0 ? {} : { timeoutMs: a.timeoutMs }
|
|
2315
|
-
},
|
|
2316
|
-
spanPrefix: "client.workflow.update"
|
|
2317
|
-
});
|
|
2318
|
-
}, [e]);
|
|
2319
|
-
return H(() => ({
|
|
2320
|
-
start: d,
|
|
2321
|
-
cancelQueued: f,
|
|
2322
|
-
readQueuedCancellation: p,
|
|
2323
|
-
cancel: h,
|
|
2324
|
-
readControl: m,
|
|
2325
|
-
resume: g,
|
|
2326
|
-
signal: _,
|
|
2327
|
-
update: y,
|
|
2328
|
-
pending: a,
|
|
2329
|
-
error: s,
|
|
2330
|
-
data: l
|
|
2331
|
-
}), [
|
|
2332
|
-
d,
|
|
2333
|
-
f,
|
|
2334
|
-
p,
|
|
2335
|
-
h,
|
|
2336
|
-
m,
|
|
2337
|
-
g,
|
|
2338
|
-
_,
|
|
2339
|
-
y,
|
|
2340
|
-
a,
|
|
2341
|
-
s,
|
|
2342
|
-
l
|
|
2343
|
-
]);
|
|
2344
|
-
}, Zr = (e) => {
|
|
2345
|
-
let t = k(e), n = U(t);
|
|
2346
|
-
n.current = t;
|
|
2347
|
-
let [r, i] = W(!1), [a, o] = W(void 0), [s, c] = W(void 0), l = B(async (t, r, a) => {
|
|
2348
|
-
i(!0), o(void 0);
|
|
2349
|
-
try {
|
|
2350
|
-
let { runtime: i, client: o } = await N(n, e, "__voltro.workflow.signal"), s = await $({
|
|
2351
|
-
apiName: e,
|
|
2352
|
-
runtime: i,
|
|
2353
|
-
client: o,
|
|
2354
|
-
tag: "__voltro.workflow.signal",
|
|
2355
|
-
input: {
|
|
2356
|
-
id: t.id,
|
|
2357
|
-
signalName: r,
|
|
2358
|
-
...a === void 0 ? {} : { payload: a }
|
|
2359
|
-
},
|
|
2360
|
-
spanPrefix: "client.workflow.signal"
|
|
2361
|
-
});
|
|
2362
|
-
return c(s), s;
|
|
2363
|
-
} catch (e) {
|
|
2364
|
-
throw o(e), e;
|
|
2365
|
-
} finally {
|
|
2366
|
-
i(!1);
|
|
2367
|
-
}
|
|
2368
|
-
}, [e]);
|
|
2369
|
-
return H(() => ({
|
|
2370
|
-
signal: l,
|
|
2371
|
-
pending: r,
|
|
2372
|
-
error: a,
|
|
2373
|
-
data: s
|
|
2374
|
-
}), [
|
|
2375
|
-
l,
|
|
2376
|
-
r,
|
|
2377
|
-
a,
|
|
2378
|
-
s
|
|
2379
|
-
]);
|
|
2380
|
-
}, Qr = (e) => {
|
|
2381
|
-
let t = k(e), n = U(t);
|
|
2382
|
-
n.current = t;
|
|
2383
|
-
let [r, i] = W(!1), [a, o] = W(void 0), [s, c] = W(void 0), l = B(async (t, r, a, s) => {
|
|
2384
|
-
i(!0), o(void 0);
|
|
2385
|
-
try {
|
|
2386
|
-
let { runtime: i, client: o } = await N(n, e, "__voltro.workflow.update"), l = await $({
|
|
2387
|
-
apiName: e,
|
|
2388
|
-
runtime: i,
|
|
2389
|
-
client: o,
|
|
2390
|
-
tag: "__voltro.workflow.update",
|
|
2391
|
-
input: {
|
|
2392
|
-
id: t.id,
|
|
2393
|
-
updateName: r,
|
|
2394
|
-
...a === void 0 ? {} : { payload: a },
|
|
2395
|
-
...s?.timeoutMs === void 0 ? {} : { timeoutMs: s.timeoutMs }
|
|
2396
|
-
},
|
|
2397
|
-
spanPrefix: "client.workflow.update"
|
|
2398
|
-
});
|
|
2399
|
-
return c(l), l;
|
|
2400
|
-
} catch (e) {
|
|
2401
|
-
throw o(e), e;
|
|
2402
|
-
} finally {
|
|
2403
|
-
i(!1);
|
|
2404
|
-
}
|
|
2405
|
-
}, [e]);
|
|
2406
|
-
return H(() => ({
|
|
2407
|
-
update: l,
|
|
2408
|
-
pending: r,
|
|
2409
|
-
error: a,
|
|
2410
|
-
data: s
|
|
2411
|
-
}), [
|
|
2412
|
-
l,
|
|
2413
|
-
r,
|
|
2414
|
-
a,
|
|
2415
|
-
s
|
|
2416
|
-
]);
|
|
2417
|
-
}, $r = (e, t) => {
|
|
2418
|
-
let n = J(e, "__voltro.workflow.run", t ? { id: t } : {}, { skip: t === void 0 });
|
|
2419
|
-
return n.loading || n.idle || n.failed ? {
|
|
2420
|
-
...n,
|
|
2421
|
-
run: void 0
|
|
2422
|
-
} : {
|
|
2423
|
-
...n,
|
|
2424
|
-
run: n.data[0]
|
|
2425
|
-
};
|
|
2426
|
-
}, ei = (e, t = {}, n = {}) => {
|
|
2427
|
-
let r = J(e, "__voltro.workflow.runs", t, n);
|
|
2428
|
-
return r.loading || r.idle || r.failed ? {
|
|
2429
|
-
...r,
|
|
2430
|
-
runs: []
|
|
2431
|
-
} : {
|
|
2432
|
-
...r,
|
|
2433
|
-
runs: r.data
|
|
2434
|
-
};
|
|
2435
|
-
}, ti = (e, t) => {
|
|
2436
|
-
let n = J(e, "__voltro.workflow.run.steps", t ? { runId: t } : {}, { skip: t === void 0 });
|
|
2437
|
-
return n.loading || n.idle || n.failed ? {
|
|
2438
|
-
...n,
|
|
2439
|
-
steps: []
|
|
2440
|
-
} : {
|
|
2441
|
-
...n,
|
|
2442
|
-
steps: n.data
|
|
2443
|
-
};
|
|
2444
|
-
}, ni = (e, t) => {
|
|
2445
|
-
let n = J(e, "__voltro.workflow.run.events", t ? { runId: t } : {}, { skip: t === void 0 });
|
|
2446
|
-
return n.loading || n.idle || n.failed ? {
|
|
2447
|
-
...n,
|
|
2448
|
-
events: []
|
|
2449
|
-
} : {
|
|
2450
|
-
...n,
|
|
2451
|
-
events: n.data
|
|
2452
|
-
};
|
|
2453
|
-
}, ri = ni, ii = (e, t = {}, n = {}) => {
|
|
2454
|
-
let r = J(e, "__voltro.workflow.domainEvents", t, n);
|
|
2455
|
-
return r.loading || r.idle || r.failed ? {
|
|
2456
|
-
...r,
|
|
2457
|
-
events: []
|
|
2458
|
-
} : {
|
|
2459
|
-
...r,
|
|
2460
|
-
events: r.data
|
|
2461
|
-
};
|
|
2462
|
-
}, ai = (e, t) => {
|
|
2463
|
-
let n = J(e, "__voltro.workflow.event.deliveries", t ? { eventId: t } : {}, { skip: t === void 0 });
|
|
2464
|
-
return n.loading || n.idle || n.failed ? {
|
|
2465
|
-
...n,
|
|
2466
|
-
deliveries: []
|
|
2467
|
-
} : {
|
|
2468
|
-
...n,
|
|
2469
|
-
deliveries: n.data
|
|
2470
|
-
};
|
|
2471
|
-
}, oi = (e, t) => {
|
|
2472
|
-
let n = e.payload;
|
|
2473
|
-
if (!n || typeof n != "object") return;
|
|
2474
|
-
let r = n[t];
|
|
2475
|
-
return typeof r == "string" ? r : void 0;
|
|
2476
|
-
}, si = (e) => {
|
|
2477
|
-
let t = e.payload;
|
|
2478
|
-
if (!t || typeof t != "object") return;
|
|
2479
|
-
let n = t.updateId;
|
|
2480
|
-
return typeof n == "string" ? n : void 0;
|
|
2481
|
-
}, ci = (e) => {
|
|
2482
|
-
let t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set();
|
|
2483
|
-
for (let r of e) if (r.eventType === "signal-received") {
|
|
2484
|
-
let e = oi(r, "signalName");
|
|
2485
|
-
e && t.add(e);
|
|
2486
|
-
} else if (r.eventType === "update-completed" || r.eventType === "update-failed") {
|
|
2487
|
-
let e = si(r);
|
|
2488
|
-
e && n.add(e);
|
|
2489
|
-
}
|
|
2490
|
-
for (let r = e.length - 1; r >= 0; --r) {
|
|
2491
|
-
let i = e[r];
|
|
2492
|
-
if (i.eventType === "signal-awaited") {
|
|
2493
|
-
let e = oi(i, "signalName");
|
|
2494
|
-
if (e && !t.has(e)) return {
|
|
2495
|
-
name: e,
|
|
2496
|
-
kind: "signal"
|
|
2497
|
-
};
|
|
2498
|
-
} else if (i.eventType === "update-requested") {
|
|
2499
|
-
let e = si(i), t = oi(i, "updateName");
|
|
2500
|
-
if (t && (!e || !n.has(e))) return {
|
|
2501
|
-
name: t,
|
|
2502
|
-
kind: "update"
|
|
2503
|
-
};
|
|
2504
|
-
}
|
|
2505
|
-
}
|
|
2506
|
-
}, li = (e) => e.find((e) => e.status === "running") || (e.length > 0 ? e[e.length - 1] : void 0), ui = (e, t) => {
|
|
2507
|
-
if (!e || e.status !== "failed") return;
|
|
2508
|
-
let n = t.find((e) => e.status === "failed");
|
|
2509
|
-
return {
|
|
2510
|
-
tag: e.errorTag,
|
|
2511
|
-
message: e.errorMessage,
|
|
2512
|
-
step: n?.stepName
|
|
2513
|
-
};
|
|
2514
|
-
}, di = (e, t) => {
|
|
2515
|
-
let n = $r(e, t), r = ti(e, t), i = ni(e, t), a = Xr(e, n.run?.tag ?? ""), o = n.run, s = r.steps, c = i.events, l = B(async () => {
|
|
2516
|
-
if (!o) throw Error("useWorkflowRunState: no run loaded — cannot cancel");
|
|
2517
|
-
await a.cancel({
|
|
2518
|
-
workflowName: o.tag,
|
|
2519
|
-
executionId: o.executionId
|
|
2520
|
-
});
|
|
2521
|
-
}, [a, o]), u = B(async () => {
|
|
2522
|
-
if (!o) throw Error("useWorkflowRunState: no run loaded — cannot resume");
|
|
2523
|
-
await a.resume({
|
|
2524
|
-
workflowName: o.tag,
|
|
2525
|
-
executionId: o.executionId
|
|
2526
|
-
});
|
|
2527
|
-
}, [a, o]), d = B((e, n) => {
|
|
2528
|
-
if (t === void 0) throw Error("useWorkflowRunState: no run id — cannot signal");
|
|
2529
|
-
return a.signal({ id: t }, e, n);
|
|
2530
|
-
}, [a, t]), f = B((e, n, r) => {
|
|
2531
|
-
if (t === void 0) throw Error("useWorkflowRunState: no run id — cannot update");
|
|
2532
|
-
return a.update({ id: t }, e, n, r);
|
|
2533
|
-
}, [a, t]);
|
|
2534
|
-
return H(() => ({
|
|
2535
|
-
run: o,
|
|
2536
|
-
status: o?.status,
|
|
2537
|
-
steps: s,
|
|
2538
|
-
events: c,
|
|
2539
|
-
currentStep: li(s),
|
|
2540
|
-
waitingFor: o?.status === "suspended" ? ci(c) : void 0,
|
|
2541
|
-
error: ui(o, s),
|
|
2542
|
-
traceId: o?.traceId,
|
|
2543
|
-
loading: n.data === void 0,
|
|
2544
|
-
cancel: l,
|
|
2545
|
-
resume: u,
|
|
2546
|
-
signal: d,
|
|
2547
|
-
update: f
|
|
2548
|
-
}), [
|
|
2549
|
-
o,
|
|
2550
|
-
s,
|
|
2551
|
-
c,
|
|
2552
|
-
n.data,
|
|
2553
|
-
l,
|
|
2554
|
-
u,
|
|
2555
|
-
d,
|
|
2556
|
-
f
|
|
2557
|
-
]);
|
|
2558
|
-
}, fi = (e, t) => {
|
|
2559
|
-
let { runtime: n, client: r } = k(e), [a, o] = W([]), [s, c] = W("idle"), [l, u] = W(void 0), d = U(null), f = B(() => {
|
|
2560
|
-
let e = d.current;
|
|
2561
|
-
e && (d.current = null, n.runFork(Be.interrupt(e)), c((e) => e === "streaming" ? "idle" : e));
|
|
2562
|
-
}, [n]);
|
|
2563
|
-
return {
|
|
2564
|
-
events: a,
|
|
2565
|
-
status: s,
|
|
2566
|
-
error: l,
|
|
2567
|
-
start: B((e = {}) => {
|
|
2568
|
-
let a = d.current;
|
|
2569
|
-
a && n.runFork(Be.interrupt(a)), o([]), u(void 0), c("streaming");
|
|
2570
|
-
let s = v(r, t)(e), l = q.runForEach(s, (e) => K.sync(() => o((t) => [...t, e]))).pipe(K.matchCause({
|
|
2571
|
-
onSuccess: () => {
|
|
2572
|
-
c("done");
|
|
2573
|
-
},
|
|
2574
|
-
onFailure: (e) => {
|
|
2575
|
-
Le.isInterruptedOnly(e) || (u(i(e)), c("error"));
|
|
2576
|
-
}
|
|
2577
|
-
}));
|
|
2578
|
-
d.current = n.runFork(l);
|
|
2579
|
-
}, [
|
|
2580
|
-
n,
|
|
2581
|
-
r,
|
|
2582
|
-
t
|
|
2583
|
-
]),
|
|
2584
|
-
cancel: f
|
|
2585
|
-
};
|
|
2586
|
-
}, pi = (e, t, n, r) => {
|
|
2587
|
-
let a = 0, o = !1, s = (e) => K.sync(() => {
|
|
2588
|
-
e.seq <= a || (a = e.seq, n.onEvent(e.event), r.isTerminal(e.event) && (o = !0));
|
|
2589
|
-
}), c = (e) => {
|
|
2590
|
-
if (typeof e != "object" || !e) return;
|
|
2591
|
-
let t = e.name, n = e.message;
|
|
2592
|
-
if (typeof t == "string" || typeof n == "string") return `${typeof t == "string" ? t : ""}::${typeof n == "string" ? n : ""}`;
|
|
2593
|
-
}, l, u = (e, t, i) => {
|
|
2594
|
-
let o = a > t, s = o ? 0 : e + 1, u = i === void 0 ? void 0 : c(i), f = u !== void 0 && u === l && !o;
|
|
2595
|
-
if (l = o ? void 0 : u, f || s > r.maxReconnects) return K.sync(() => {
|
|
2596
|
-
n.onError(i ?? /* @__PURE__ */ Error("stream connection lost")), n.onStatus("error");
|
|
2597
|
-
});
|
|
2598
|
-
let p = Math.min(r.maxBackoffMs, r.backoffMs * 2 ** Math.max(0, s - 1));
|
|
2599
|
-
return K.sync(() => {
|
|
2600
|
-
n.onStatus("reconnecting"), n.onReconnect();
|
|
2601
|
-
}).pipe(K.zipRight(K.sleep(Re.millis(p))), K.zipRight(K.sync(() => n.onStatus("streaming"))), K.zipRight(d(s)));
|
|
2602
|
-
}, d = (r) => K.suspend(() => {
|
|
2603
|
-
let c = a, l = e({
|
|
2604
|
-
...t,
|
|
2605
|
-
fromSeq: c
|
|
2606
|
-
});
|
|
2607
|
-
return q.runForEach(l, s).pipe(K.matchCauseEffect({
|
|
2608
|
-
onSuccess: () => o ? K.sync(() => n.onStatus("done")) : u(r, c, void 0),
|
|
2609
|
-
onFailure: (e) => Le.isInterruptedOnly(e) ? K.void : o ? K.sync(() => n.onStatus("done")) : u(r, c, i(e))
|
|
2610
|
-
}));
|
|
2611
|
-
});
|
|
2612
|
-
return d(0);
|
|
2613
|
-
}, mi = (e) => {
|
|
2614
|
-
let t = e?._tag;
|
|
2615
|
-
return t === "done" || t === "error";
|
|
2616
|
-
}, hi = (e, t, n = {}) => {
|
|
2617
|
-
let { runtime: r, client: i } = k(e), [a, o] = W([]), [s, c] = W("idle"), [l, u] = W(0), [d, f] = W(void 0), p = U(null), m = {
|
|
2618
|
-
maxReconnects: n.maxReconnects ?? 6,
|
|
2619
|
-
backoffMs: n.backoffMs ?? 400,
|
|
2620
|
-
maxBackoffMs: n.maxBackoffMs ?? 8e3,
|
|
2621
|
-
isTerminal: n.isTerminal ?? mi
|
|
2622
|
-
}, h = B(() => {
|
|
2623
|
-
let e = p.current;
|
|
2624
|
-
e && (p.current = null, r.runFork(Be.interrupt(e)), c((e) => e === "streaming" || e === "reconnecting" ? "idle" : e));
|
|
2625
|
-
}, [r]);
|
|
2626
|
-
return {
|
|
2627
|
-
events: a,
|
|
2628
|
-
status: s,
|
|
2629
|
-
reconnects: l,
|
|
2630
|
-
error: d,
|
|
2631
|
-
start: B((e = {}) => {
|
|
2632
|
-
let n = p.current;
|
|
2633
|
-
n && r.runFork(Be.interrupt(n)), o([]), f(void 0), u(0), c("streaming");
|
|
2634
|
-
let a = v(i, t), s = {
|
|
2635
|
-
onEvent: (e) => o((t) => [...t, e]),
|
|
2636
|
-
onStatus: c,
|
|
2637
|
-
onReconnect: () => u((e) => e + 1),
|
|
2638
|
-
onError: f
|
|
2639
|
-
};
|
|
2640
|
-
p.current = r.runFork(pi(a, e, s, m));
|
|
2641
|
-
}, [
|
|
2642
|
-
r,
|
|
2643
|
-
i,
|
|
2644
|
-
t,
|
|
2645
|
-
m.maxReconnects,
|
|
2646
|
-
m.backoffMs,
|
|
2647
|
-
m.maxBackoffMs,
|
|
2648
|
-
m.isTerminal
|
|
2649
|
-
]),
|
|
2650
|
-
cancel: h
|
|
2651
|
-
};
|
|
2652
|
-
}, gi = (e, t) => e.order - t.order || (e.stepOrder ?? 0) - (t.stepOrder ?? 0), _i = (e) => {
|
|
2653
|
-
for (let t = e.length - 1; t >= 0; --t) {
|
|
2654
|
-
let n = e[t];
|
|
2655
|
-
if (n.role === "user" && n.content) return n.content;
|
|
2656
|
-
}
|
|
2657
|
-
}, vi = (e, t, n) => {
|
|
2658
|
-
let { threadId: r } = n, i = J(e, `${t}.messages`, { threadId: r }), a = nr(e, `${t}.send`), o = H(() => [...i.data ?? []].sort(gi), [i.data]), s = B((e, t = {}) => a.run({
|
|
2659
|
-
threadId: r,
|
|
2660
|
-
order: i.data?.length ?? 0,
|
|
2661
|
-
prompt: e,
|
|
2662
|
-
...t
|
|
2663
|
-
}), [
|
|
2664
|
-
a,
|
|
2665
|
-
r,
|
|
2666
|
-
i.data
|
|
2667
|
-
]), c = B(() => {
|
|
2668
|
-
let e = _i(o);
|
|
2669
|
-
return e === void 0 ? void 0 : s(e);
|
|
2670
|
-
}, [o, s]);
|
|
2671
|
-
return H(() => ({
|
|
2672
|
-
messages: o,
|
|
2673
|
-
streaming: o.some((e) => e.streaming),
|
|
2674
|
-
loading: i.data === void 0,
|
|
2675
|
-
error: i.error ?? a.error,
|
|
2676
|
-
send: s,
|
|
2677
|
-
regenerate: c,
|
|
2678
|
-
sending: a.pending
|
|
2679
|
-
}), [
|
|
2680
|
-
o,
|
|
2681
|
-
i.data,
|
|
2682
|
-
i.error,
|
|
2683
|
-
a.error,
|
|
2684
|
-
a.pending,
|
|
2685
|
-
s,
|
|
2686
|
-
c
|
|
2687
|
-
]);
|
|
2688
|
-
}, yi = (e, t) => {
|
|
2689
|
-
let { events: n, status: r, error: i, start: a, cancel: o } = fi(e, t), [s, c] = W([]), l = U(null), u = H(() => n.filter((e) => e._tag === "token").map((e) => e.text ?? "").join(""), [n]);
|
|
2690
|
-
return V(() => {
|
|
2691
|
-
if (r !== "done" || l.current === null) return;
|
|
2692
|
-
let e = l.current;
|
|
2693
|
-
l.current = null, c((t) => [
|
|
2694
|
-
...t,
|
|
2695
|
-
{
|
|
2696
|
-
role: "user",
|
|
2697
|
-
content: e
|
|
2698
|
-
},
|
|
2699
|
-
{
|
|
2700
|
-
role: "assistant",
|
|
2701
|
-
content: u
|
|
2702
|
-
}
|
|
2703
|
-
]);
|
|
2704
|
-
}, [r, u]), {
|
|
2705
|
-
tokens: u,
|
|
2706
|
-
history: s,
|
|
2707
|
-
status: r,
|
|
2708
|
-
error: i,
|
|
2709
|
-
send: B((e = {}) => {
|
|
2710
|
-
let t = e.message;
|
|
2711
|
-
l.current = typeof t == "string" ? t : "", a(e);
|
|
2712
|
-
}, [a]),
|
|
2713
|
-
cancel: o
|
|
2714
|
-
};
|
|
2715
|
-
}, bi = (e, t) => {
|
|
2716
|
-
let n = nr(e, t), [r, i] = W(void 0), a = B(async (e) => {
|
|
2717
|
-
let t = await n.run({ question: e });
|
|
2718
|
-
return i(t), t;
|
|
2719
|
-
}, [n]), o = B(() => i(void 0), []);
|
|
2720
|
-
return H(() => ({
|
|
2721
|
-
ask: a,
|
|
2722
|
-
answer: r,
|
|
2723
|
-
pending: n.pending,
|
|
2724
|
-
error: n.error,
|
|
2725
|
-
reset: o
|
|
2726
|
-
}), [
|
|
2727
|
-
a,
|
|
2728
|
-
r,
|
|
2729
|
-
n.pending,
|
|
2730
|
-
n.error,
|
|
2731
|
-
o
|
|
2732
|
-
]);
|
|
2733
|
-
}, xi = (e) => {
|
|
2734
|
-
let { cache: t, runtime: n } = k(e);
|
|
2735
|
-
return B(() => {
|
|
2736
|
-
t.refreshAll(n);
|
|
2737
|
-
}, [t, n]);
|
|
2738
|
-
}, Si = (e, t, n) => {
|
|
2739
|
-
let { cache: r } = k(e), i = f([t, n]), a = U([t, n]);
|
|
2740
|
-
return a.current = [t, n], H(() => {
|
|
2741
|
-
let e = a.current;
|
|
2742
|
-
return () => r.refresh(e);
|
|
2743
|
-
}, [r, i]);
|
|
2744
|
-
}, Ci = (e, t) => {
|
|
2745
|
-
let n = k(e), r = n.recovery ?? c(n.errorBus, e), i = U(t);
|
|
2746
|
-
i.current = t, V(() => r.onVisibleError((e) => i.current(e)), [r]);
|
|
2747
|
-
}, wi = (e, t) => {
|
|
2748
|
-
let { errorBus: n } = k(e), r = U(t);
|
|
2749
|
-
r.current = t, V(() => n.on((e) => r.current(e)), [n]);
|
|
2750
|
-
}, Ti = {
|
|
2751
|
-
failed: [],
|
|
2752
|
-
healthy: !0
|
|
2753
|
-
}, Ei = (e) => {
|
|
2754
|
-
let { errorBus: t } = k(e), [n, r] = W(Ti);
|
|
2755
|
-
return V(() => {
|
|
2756
|
-
let e = /* @__PURE__ */ new Map(), n = () => {
|
|
2757
|
-
let t = [...e.values()].sort((e, t) => t.at - e.at);
|
|
2758
|
-
r(t.length === 0 ? Ti : {
|
|
2759
|
-
failed: t,
|
|
2760
|
-
healthy: !1
|
|
2761
|
-
});
|
|
2762
|
-
}, i = t.on((t) => {
|
|
2763
|
-
e.set(t.tag, {
|
|
2764
|
-
tag: t.tag,
|
|
2765
|
-
source: t.source,
|
|
2766
|
-
error: t.error,
|
|
2767
|
-
at: Date.now()
|
|
2768
|
-
}), n();
|
|
2769
|
-
}), a = t.onSuccess((t) => {
|
|
2770
|
-
e.delete(t.tag) && n();
|
|
2771
|
-
});
|
|
2772
|
-
return () => {
|
|
2773
|
-
i(), a();
|
|
2774
|
-
};
|
|
2775
|
-
}, [t]), n;
|
|
2776
|
-
}, Di = (e, t) => {
|
|
2777
|
-
let n = globalThis, r = Symbol.for(`@voltro/web/context:${e}`), i = n[r];
|
|
2778
|
-
if (i) return i;
|
|
2779
|
-
let a = Me(t);
|
|
2780
|
-
return n[r] = a, a;
|
|
2781
|
-
}, Oi = Di("serverRequest", null), ki = () => Pe(Oi), Ai = ({ value: e, children: t }) => /* @__PURE__ */ nt(Oi.Provider, {
|
|
2782
|
-
value: e,
|
|
2783
|
-
children: t
|
|
2784
|
-
}), ji = (e) => {
|
|
2785
|
-
let t = ki();
|
|
2786
|
-
return H(() => {
|
|
2787
|
-
if (t !== null) return t.formFlash?.formKey === e ? t.formFlash : void 0;
|
|
2788
|
-
if (typeof document > "u") return;
|
|
2789
|
-
let n = document.getElementById(Ee);
|
|
2790
|
-
if (n !== null && n.textContent !== null && n.textContent !== "") try {
|
|
2791
|
-
let t = JSON.parse(n.textContent);
|
|
2792
|
-
return t.formKey === e ? t : void 0;
|
|
2793
|
-
} catch {
|
|
2794
|
-
return;
|
|
2795
|
-
}
|
|
2796
|
-
}, [t, e]);
|
|
2797
|
-
}, Mi = (e, t, n) => e.map((e) => {
|
|
2798
|
-
let r = String(e[n] ?? ""), i = e[t];
|
|
2799
|
-
return {
|
|
2800
|
-
value: r,
|
|
2801
|
-
label: i == null ? r : String(i)
|
|
2802
|
-
};
|
|
2803
|
-
}), Ni = (e, t, n = {}) => {
|
|
2804
|
-
let r = n.debounceMs ?? 200, i = n.labelField ?? "name", a = n.valueField ?? "id", o = n.input ?? ((e) => ({ q: e })), [s, c] = W(n.initialTerm ?? ""), [l, u] = W(s);
|
|
2805
|
-
V(() => {
|
|
2806
|
-
if (s === l) return;
|
|
2807
|
-
let e = setTimeout(() => u(s), r);
|
|
2808
|
-
return () => clearTimeout(e);
|
|
2809
|
-
}, [
|
|
2810
|
-
s,
|
|
2811
|
-
l,
|
|
2812
|
-
r
|
|
2813
|
-
]);
|
|
2814
|
-
let d = n.skipUntilTerm === !0 && l.trim() === "", f = J(e, t, H(() => o(l), [o, l]), { skip: d }), p = H(() => Mi(f.data ?? [], i, a), [
|
|
2815
|
-
f.data,
|
|
2816
|
-
i,
|
|
2817
|
-
a
|
|
2818
|
-
]), m = B((e) => c(e), []);
|
|
2819
|
-
return {
|
|
2820
|
-
options: p,
|
|
2821
|
-
loading: !d && f.data === void 0,
|
|
2822
|
-
term: s,
|
|
2823
|
-
search: m
|
|
2824
|
-
};
|
|
2825
|
-
}, Pi = (e, t) => e === t ? 0 : e == null ? 1 : t == null || e < t ? -1 : 1, Fi = (e, t, n = {}) => {
|
|
2826
|
-
let r = k(e), [i, a] = W(n.pageSize), o = J(e, t, H(() => i === void 0 ? n.input ?? {} : {
|
|
2827
|
-
...n.input,
|
|
2828
|
-
limit: i
|
|
2829
|
-
}, [n.input, i])), s = r.descriptors[t]?.output, c = B(() => {
|
|
2830
|
-
n.pageSize !== void 0 && a((e) => (e ?? n.pageSize) + n.pageSize);
|
|
2831
|
-
}, [n.pageSize]), l = H(() => n.columns ?? (s === void 0 ? [] : ce(s)), [n.columns, s]), [u, d] = W(n.initialSort), f = B((e) => {
|
|
2832
|
-
d((t) => t?.column === e ? {
|
|
2833
|
-
column: e,
|
|
2834
|
-
direction: t.direction === "asc" ? "desc" : "asc"
|
|
2835
|
-
} : {
|
|
2836
|
-
column: e,
|
|
2837
|
-
direction: "asc"
|
|
2838
|
-
});
|
|
2839
|
-
}, []);
|
|
2840
|
-
return {
|
|
2841
|
-
columns: l,
|
|
2842
|
-
rows: H(() => {
|
|
2843
|
-
let e = o.data ?? [];
|
|
2844
|
-
if (u === void 0) return e;
|
|
2845
|
-
let t = u.direction === "asc" ? 1 : -1;
|
|
2846
|
-
return [...e].sort((e, n) => Pi(e[u.column], n[u.column]) * t);
|
|
2847
|
-
}, [o.data, u]),
|
|
2848
|
-
loading: o.data === void 0,
|
|
2849
|
-
error: o.error,
|
|
2850
|
-
sort: u,
|
|
2851
|
-
toggleSort: f,
|
|
2852
|
-
loadMore: c,
|
|
2853
|
-
hasMore: i !== void 0 && (o.data?.length ?? 0) >= i
|
|
2854
|
-
};
|
|
2855
|
-
}, Ii = (e, t, n, r) => {
|
|
2856
|
-
let i = e.replace(/\/$/, ""), a = new URLSearchParams({
|
|
2857
|
-
table: t,
|
|
2858
|
-
id: n
|
|
2859
|
-
});
|
|
2860
|
-
return r !== void 0 && a.set("column", r), `${i}/_voltro/inspect/provenance?${a.toString()}`;
|
|
2861
|
-
}, Li = Ii, Ri = (e, t, n, r) => {
|
|
2862
|
-
let { inspectBaseUrl: i } = k(e), [a, o] = W({
|
|
2863
|
-
data: void 0,
|
|
2864
|
-
loading: !0,
|
|
2865
|
-
error: void 0
|
|
2866
|
-
});
|
|
2867
|
-
return V(() => {
|
|
2868
|
-
let e = !1;
|
|
2869
|
-
o({
|
|
2870
|
-
data: void 0,
|
|
2871
|
-
loading: !0,
|
|
2872
|
-
error: void 0
|
|
2873
|
-
});
|
|
2874
|
-
let a = Ii(i ?? "", t, n, r);
|
|
2875
|
-
return fetch(a).then(async (e) => {
|
|
2876
|
-
if (!e.ok) throw Error(`provenance fetch failed: HTTP ${e.status}`);
|
|
2877
|
-
return await e.json();
|
|
2878
|
-
}).then((t) => {
|
|
2879
|
-
e || o({
|
|
2880
|
-
data: t,
|
|
2881
|
-
loading: !1,
|
|
2882
|
-
error: void 0
|
|
2883
|
-
});
|
|
2884
|
-
}).catch((t) => {
|
|
2885
|
-
e || o({
|
|
2886
|
-
data: void 0,
|
|
2887
|
-
loading: !1,
|
|
2888
|
-
error: t
|
|
2889
|
-
});
|
|
2890
|
-
}), () => {
|
|
2891
|
-
e = !0;
|
|
2892
|
-
};
|
|
2893
|
-
}, [
|
|
2894
|
-
e,
|
|
2895
|
-
i,
|
|
2896
|
-
t,
|
|
2897
|
-
n,
|
|
2898
|
-
r
|
|
2899
|
-
]), a;
|
|
2900
|
-
}, zi = "admin:full", Bi = (e, t) => e.includes("admin:full") ? !0 : (typeof t == "string" ? [t] : t).every((t) => e.includes(t)), Vi = (e, t) => t.length === 0 || e.includes("admin:full") ? !0 : t.some((t) => e.includes(t)), Hi = Me({ scopes: [] });
|
|
2901
|
-
function Ui(e) {
|
|
2902
|
-
return Ne(Hi.Provider, { value: { scopes: e.scopes } }, e.children);
|
|
2903
|
-
}
|
|
2904
|
-
var Wi = () => Pe(Hi), Gi = (e) => Bi(Wi().scopes, e), Ki = (e) => Vi(Wi().scopes, e), qi = (e) => `${e.replace(/\/$/, "")}/_voltro/inspect/manifest`, Ji = (e) => {
|
|
2905
|
-
let { inspectBaseUrl: t } = k(e), [n, r] = W({
|
|
2906
|
-
manifest: void 0,
|
|
2907
|
-
loading: !0,
|
|
2908
|
-
error: void 0
|
|
2909
|
-
});
|
|
2910
|
-
return V(() => {
|
|
2911
|
-
let e = !1;
|
|
2912
|
-
return r({
|
|
2913
|
-
manifest: void 0,
|
|
2914
|
-
loading: !0,
|
|
2915
|
-
error: void 0
|
|
2916
|
-
}), fetch(qi(t ?? "")).then(async (e) => {
|
|
2917
|
-
if (!e.ok) throw Error(`manifest fetch failed: HTTP ${e.status}`);
|
|
2918
|
-
return await e.json();
|
|
2919
|
-
}).then((t) => {
|
|
2920
|
-
e || r({
|
|
2921
|
-
manifest: t,
|
|
2922
|
-
loading: !1,
|
|
2923
|
-
error: void 0
|
|
2924
|
-
});
|
|
2925
|
-
}).catch((t) => {
|
|
2926
|
-
e || r({
|
|
2927
|
-
manifest: void 0,
|
|
2928
|
-
loading: !1,
|
|
2929
|
-
error: t
|
|
2930
|
-
});
|
|
2931
|
-
}), () => {
|
|
2932
|
-
e = !0;
|
|
2933
|
-
};
|
|
2934
|
-
}, [e, t]), n;
|
|
2935
|
-
}, Yi = (e, t) => t.scope.length === 0 || (t.mode === "any" ? t.scope.some((t) => e.includes(t)) : t.scope.every((t) => e.includes(t))), Xi = (e, t) => {
|
|
2936
|
-
if (e === void 0) return "unknown";
|
|
2937
|
-
if (t.includes("admin:full") || e.length === 0) return "allowed";
|
|
2938
|
-
let n = !1;
|
|
2939
|
-
for (let r of e) if (r.kind !== "open") {
|
|
2940
|
-
if (r.kind === "policy") {
|
|
2941
|
-
n = !0;
|
|
2942
|
-
continue;
|
|
2943
|
-
}
|
|
2944
|
-
if (!Yi(t, r)) {
|
|
2945
|
-
if (r.resourceScoped) {
|
|
2946
|
-
n = !0;
|
|
2947
|
-
continue;
|
|
2948
|
-
}
|
|
2949
|
-
return "denied";
|
|
2950
|
-
}
|
|
2951
|
-
}
|
|
2952
|
-
return n ? "unknown" : "allowed";
|
|
2953
|
-
}, Zi = (e) => (e ?? []).flatMap((e) => e.kind === "scope" ? [...e.scope] : []), Qi = (e) => {
|
|
2954
|
-
for (let t of e ?? []) if (t.kind === "open") return t.reason;
|
|
2955
|
-
}, $i = (e) => Xi(e, Wi().scopes), ea = (e, t) => Array.isArray(e) ? e.includes(t) : e === t, ta = (e, t, n) => e.targets?.some((e) => e.table === t && e.op === n) ?? !1, na = (e) => e === void 0 ? {} : {
|
|
2956
|
-
tag: e.tag,
|
|
2957
|
-
...e.guards === void 0 ? {} : { guards: e.guards }
|
|
2958
|
-
}, ra = (e) => e.tables.filter((e) => !e.framework).map((t) => {
|
|
2959
|
-
let n = e.procedures.find((e) => e.kind === "query" && ea(e.source, t.name)), r = e.procedures.find((e) => e.kind === "mutation" && ta(e, t.name, "insert")), i = e.procedures.find((e) => e.kind === "mutation" && ta(e, t.name, "update")), a = e.procedures.find((e) => e.kind === "mutation" && ta(e, t.name, "delete")), o = t.pkColumn ?? (t.columns.some((e) => e.name === "id") ? "id" : void 0);
|
|
2960
|
-
return {
|
|
2961
|
-
table: t.name,
|
|
2962
|
-
columns: t.columns.filter((e) => e.serverOnly !== !0),
|
|
2963
|
-
serverOnlyColumns: t.columns.filter((e) => e.serverOnly === !0).map((e) => e.name),
|
|
2964
|
-
sensitiveColumns: t.columns.filter((e) => e.sensitive !== void 0).map((e) => e.name),
|
|
2965
|
-
reactive: t.reactive,
|
|
2966
|
-
...o === void 0 ? {} : { pkColumn: o },
|
|
2967
|
-
editable: (t.editable ?? !0) && o !== void 0,
|
|
2968
|
-
list: na(n),
|
|
2969
|
-
create: na(r),
|
|
2970
|
-
update: na(i),
|
|
2971
|
-
delete: na(a)
|
|
2972
|
-
};
|
|
2973
|
-
}), ia = (e) => {
|
|
2974
|
-
let [t, n] = W([]), [r, i] = W([]), a = B((e) => {
|
|
2975
|
-
n((t) => [...t, e]), i([]);
|
|
2976
|
-
}, []), o = B(async () => {
|
|
2977
|
-
let r = t[t.length - 1];
|
|
2978
|
-
r !== void 0 && r.blockedBy === void 0 && (await e.onUndo(r.invocationId), n((e) => e.slice(0, -1)), i((e) => [...e, r]));
|
|
2979
|
-
}, [t, e]), s = B(async () => {
|
|
2980
|
-
let t = r[r.length - 1];
|
|
2981
|
-
t !== void 0 && (await e.onRedo(t.invocationId), i((e) => e.slice(0, -1)), n((e) => [...e, t]));
|
|
2982
|
-
}, [r, e]);
|
|
2983
|
-
return H(() => {
|
|
2984
|
-
let e = t[t.length - 1];
|
|
2985
|
-
return {
|
|
2986
|
-
record: a,
|
|
2987
|
-
undo: o,
|
|
2988
|
-
redo: s,
|
|
2989
|
-
canUndo: t.length > 0 && e?.blockedBy === void 0,
|
|
2990
|
-
canRedo: r.length > 0,
|
|
2991
|
-
stack: t,
|
|
2992
|
-
nextBlockedBy: e?.blockedBy
|
|
2993
|
-
};
|
|
2994
|
-
}, [
|
|
2995
|
-
t,
|
|
2996
|
-
r,
|
|
2997
|
-
a,
|
|
2998
|
-
o,
|
|
2999
|
-
s
|
|
3000
|
-
]);
|
|
3001
|
-
}, aa = "__voltro.undo.log", oa = "__voltro.undo.apply", sa = "__voltro.undo.redo", ca = (e, t) => {
|
|
3002
|
-
let n = t?.limit, { data: r } = J(e, aa, n === void 0 ? {} : { limit: n }), i = Zn(e, oa), a = Zn(e, sa), o = r ?? [], s = o.find((e) => !e.undone && !e.crossesAction), c = o.find((e) => e.undone), l = B(async (e) => {
|
|
3003
|
-
await i.mutate({ invocationId: e });
|
|
3004
|
-
}, [i]), u = B(async (e) => {
|
|
3005
|
-
await a.mutate({ invocationId: e });
|
|
3006
|
-
}, [a]), d = B(async () => {
|
|
3007
|
-
s && await l(s.id);
|
|
3008
|
-
}, [s, l]), f = B(async () => {
|
|
3009
|
-
c && await u(c.id);
|
|
3010
|
-
}, [c, u]);
|
|
3011
|
-
return {
|
|
3012
|
-
entries: o,
|
|
3013
|
-
loading: r === void 0,
|
|
3014
|
-
canUndo: s !== void 0,
|
|
3015
|
-
canRedo: c !== void 0,
|
|
3016
|
-
undo: l,
|
|
3017
|
-
redo: u,
|
|
3018
|
-
undoLast: d,
|
|
3019
|
-
redoLast: f
|
|
3020
|
-
};
|
|
3021
|
-
}, la = (e, t) => ({
|
|
3022
|
-
name: e,
|
|
3023
|
-
map: t
|
|
3024
|
-
}), ua = (e, t) => e === void 0 ? null : typeof e == "string" ? { event: e } : e(t), da = /* @__PURE__ */ new Set(["onMount", "onUnmount"]), fa = (e, t, n) => {
|
|
3025
|
-
let r = { ...t };
|
|
3026
|
-
for (let [i, a] of Object.entries(e.map)) {
|
|
3027
|
-
if (da.has(i) || a === void 0) continue;
|
|
3028
|
-
let e = t[i];
|
|
3029
|
-
r[i] = (...r) => {
|
|
3030
|
-
let i = ua(a, t);
|
|
3031
|
-
if (i !== null && n(i), typeof e == "function") return e(...r);
|
|
3032
|
-
};
|
|
3033
|
-
}
|
|
3034
|
-
return r;
|
|
3035
|
-
}, pa = (e, t, n) => {
|
|
3036
|
-
let r = U({
|
|
3037
|
-
spec: e,
|
|
3038
|
-
props: t,
|
|
3039
|
-
sink: n
|
|
3040
|
-
});
|
|
3041
|
-
return r.current = {
|
|
3042
|
-
spec: e,
|
|
3043
|
-
props: t,
|
|
3044
|
-
sink: n
|
|
3045
|
-
}, V(() => {
|
|
3046
|
-
let e = r.current, t = ua(e.spec.map.onMount, e.props);
|
|
3047
|
-
return t !== null && e.sink(t), () => {
|
|
3048
|
-
let e = r.current, t = ua(e.spec.map.onUnmount, e.props);
|
|
3049
|
-
t !== null && e.sink(t);
|
|
3050
|
-
};
|
|
3051
|
-
}, []), H(() => fa(e, t, n), [
|
|
3052
|
-
e,
|
|
3053
|
-
t,
|
|
3054
|
-
n
|
|
3055
|
-
]);
|
|
3056
|
-
}, ma = (e, t) => {
|
|
3057
|
-
let n = k(e).descriptors[t]?.input;
|
|
3058
|
-
return H(() => n === void 0 ? [] : ke(n), [n]);
|
|
3059
|
-
}, ha = (e, t) => {
|
|
3060
|
-
let n = k(e).descriptors[t]?.output;
|
|
3061
|
-
return H(() => n === void 0 ? [] : ce(n), [n]);
|
|
3062
|
-
}, ga = (e, t) => {
|
|
3063
|
-
if (e === t) return !0;
|
|
3064
|
-
if (e.length !== t.length) return !1;
|
|
3065
|
-
for (let n = 0; n < e.length; n += 1) if (!Object.is(e[n], t[n])) return !1;
|
|
3066
|
-
return !0;
|
|
3067
|
-
}, _a = (e) => Object.keys(e).sort().map((t) => e[t]), va = (e, t) => {
|
|
3068
|
-
let n = U(null), r = _a(e);
|
|
3069
|
-
return (n.current === null || !ga(n.current.key, r)) && (n.current = {
|
|
3070
|
-
key: r,
|
|
3071
|
-
value: t(e)
|
|
3072
|
-
}), n.current.value;
|
|
3073
|
-
}, ya = (e, t, n, r = {}) => {
|
|
3074
|
-
let i = J(e, t, { ...n }, r);
|
|
3075
|
-
return H(() => ({
|
|
3076
|
-
allowed: i.data?.allowed === !0,
|
|
3077
|
-
pending: i.data === void 0
|
|
3078
|
-
}), [i.data]);
|
|
3079
|
-
}, ba = (e, t, n, r = {}) => {
|
|
3080
|
-
let i = J(e, t, { ...n }, r);
|
|
3081
|
-
return H(() => ({
|
|
3082
|
-
allowedIds: new Set(i.data?.allowedIds ?? []),
|
|
3083
|
-
pending: i.data === void 0
|
|
3084
|
-
}), [i.data]);
|
|
3085
|
-
}, xa = (e) => {
|
|
3086
|
-
switch (e) {
|
|
3087
|
-
case "select":
|
|
3088
|
-
case "radio":
|
|
3089
|
-
case "async-select": return "select";
|
|
3090
|
-
case "multi-select": return "multi-select";
|
|
3091
|
-
case "text":
|
|
3092
|
-
case "textarea": return "text";
|
|
3093
|
-
case "number": return "number-range";
|
|
3094
|
-
case "date":
|
|
3095
|
-
case "datetime":
|
|
3096
|
-
case "daterange": return "date-range";
|
|
3097
|
-
case "checkbox":
|
|
3098
|
-
case "switch": return "boolean";
|
|
3099
|
-
default: return null;
|
|
3100
|
-
}
|
|
3101
|
-
}, Sa = (e) => ke(e).map((e) => {
|
|
3102
|
-
if (e.name.includes(".")) return null;
|
|
3103
|
-
let t = xa(e.widget);
|
|
3104
|
-
return t === null ? null : {
|
|
3105
|
-
name: e.name,
|
|
3106
|
-
label: e.label,
|
|
3107
|
-
kind: t,
|
|
3108
|
-
...e.options ? { options: e.options } : {}
|
|
3109
|
-
};
|
|
3110
|
-
}).filter((e) => e !== null), Ca = (e) => {
|
|
3111
|
-
let t = {};
|
|
3112
|
-
for (let [n, r] of Object.entries(e)) r === void 0 || r === "" || Array.isArray(r) && r.length === 0 || (t[n] = r);
|
|
3113
|
-
return t;
|
|
3114
|
-
}, wa = (e, t, n = {}) => {
|
|
3115
|
-
let r = k(e).descriptors[t]?.input, i = H(() => r === void 0 ? [] : Sa(r), [r]), [a, o] = W(n.initial ?? {}), s = B((e, t) => {
|
|
3116
|
-
o((n) => Ca({
|
|
3117
|
-
...n,
|
|
3118
|
-
[e]: t
|
|
3119
|
-
}));
|
|
3120
|
-
}, []), c = B(() => o({}), []), l = J(e, t, H(() => Ca(a), [a]));
|
|
3121
|
-
return {
|
|
3122
|
-
filters: i,
|
|
3123
|
-
values: a,
|
|
3124
|
-
setFilter: s,
|
|
3125
|
-
clear: c,
|
|
3126
|
-
rows: l.data ?? [],
|
|
3127
|
-
count: l.data?.length,
|
|
3128
|
-
loading: l.data === void 0,
|
|
3129
|
-
error: l.error
|
|
3130
|
-
};
|
|
3131
|
-
}, Ta = (e, t, n = {}) => {
|
|
3132
|
-
let r = J(e, t, n), i = r.data;
|
|
3133
|
-
return {
|
|
3134
|
-
record: Array.isArray(i) ? i[0] : i,
|
|
3135
|
-
loading: i === void 0,
|
|
3136
|
-
error: r.error
|
|
3137
|
-
};
|
|
3138
|
-
}, Ea = (e, t = 300) => {
|
|
3139
|
-
let [n, r] = W(e);
|
|
3140
|
-
return V(() => {
|
|
3141
|
-
let n = setTimeout(() => r(e), t);
|
|
3142
|
-
return () => clearTimeout(n);
|
|
3143
|
-
}, [e, t]), n;
|
|
3144
|
-
}, Da = (e) => {
|
|
3145
|
-
let { value: t, debouncedValue: n, data: r, interpret: i, skipEmpty: a = !0 } = e;
|
|
3146
|
-
if (a && t.trim() === "") return {
|
|
3147
|
-
status: "idle",
|
|
3148
|
-
valid: void 0,
|
|
3149
|
-
message: void 0
|
|
3150
|
-
};
|
|
3151
|
-
if (t !== n || r === void 0) return {
|
|
3152
|
-
status: "checking",
|
|
3153
|
-
valid: void 0,
|
|
3154
|
-
message: void 0
|
|
3155
|
-
};
|
|
3156
|
-
let o = i(r);
|
|
3157
|
-
return {
|
|
3158
|
-
status: o.valid ? "valid" : "invalid",
|
|
3159
|
-
valid: o.valid,
|
|
3160
|
-
message: o.message
|
|
3161
|
-
};
|
|
3162
|
-
}, Oa = (e, t, n, r) => {
|
|
3163
|
-
let { input: i, interpret: a, debounceMs: o = 300, skipEmpty: s = !0 } = r, c = Ea(n, o), l = s && c.trim() === "", u = J(e, t, H(() => i ? i(c) : { value: c }, [i, c]), { skip: l });
|
|
3164
|
-
return Da({
|
|
3165
|
-
value: n,
|
|
3166
|
-
debouncedValue: c,
|
|
3167
|
-
data: l ? null : u.data,
|
|
3168
|
-
interpret: a,
|
|
3169
|
-
skipEmpty: s
|
|
3170
|
-
});
|
|
3171
|
-
}, ka = (e, t) => ({
|
|
3172
|
-
name: e,
|
|
3173
|
-
payload: t
|
|
3174
|
-
}), Aa = (e, t) => {
|
|
3175
|
-
let n = Ue.decodeUnknownEither(e.payload, { errors: "all" })(t);
|
|
3176
|
-
if (n._tag === "Right") return {
|
|
3177
|
-
valid: !0,
|
|
3178
|
-
errors: {}
|
|
3179
|
-
};
|
|
3180
|
-
let r = {};
|
|
3181
|
-
for (let e of at.formatErrorSync(n.left)) r[e.path.join(".") || "(root)"] = e.message;
|
|
3182
|
-
return {
|
|
3183
|
-
valid: !1,
|
|
3184
|
-
errors: r
|
|
3185
|
-
};
|
|
3186
|
-
}, ja = (e) => {
|
|
3187
|
-
let t = new Map(e.map((e) => [e.name, e]));
|
|
3188
|
-
return {
|
|
3189
|
-
names: [...t.keys()].sort(),
|
|
3190
|
-
get: (e) => t.get(e),
|
|
3191
|
-
events: e
|
|
3192
|
-
};
|
|
3193
|
-
}, Ma = (e, t) => {
|
|
3194
|
-
let n = ja(e);
|
|
3195
|
-
return {
|
|
3196
|
-
track: (e, r) => {
|
|
3197
|
-
let i = n.get(e);
|
|
3198
|
-
if (i === void 0) {
|
|
3199
|
-
process.env.NODE_ENV !== "production" && console.error(`[@voltro/client] analytics.track: unknown event '${e}' (not in the catalog)`);
|
|
3200
|
-
return;
|
|
3201
|
-
}
|
|
3202
|
-
if (process.env.NODE_ENV !== "production") {
|
|
3203
|
-
let t = Aa(i, r);
|
|
3204
|
-
t.valid || console.error(`[@voltro/client] analytics.track('${e}'): payload failed its schema`, t.errors);
|
|
3205
|
-
}
|
|
3206
|
-
t({
|
|
3207
|
-
event: e,
|
|
3208
|
-
...r
|
|
3209
|
-
});
|
|
3210
|
-
},
|
|
3211
|
-
names: n.names,
|
|
3212
|
-
catalog: n
|
|
3213
|
-
};
|
|
3214
|
-
}, Na = (e, t) => {
|
|
3215
|
-
let n = nr(e, t);
|
|
3216
|
-
return {
|
|
3217
|
-
preview: B((e) => n.run(e), [n]),
|
|
3218
|
-
diff: n.lastResult,
|
|
3219
|
-
pending: n.pending,
|
|
3220
|
-
error: n.error
|
|
3221
|
-
};
|
|
3222
|
-
}, Pa = () => globalThis.navigator?.onLine !== !1, Fa = (e) => Pa() && (g().online(e) ?? !0), Ia = (e) => {
|
|
3223
|
-
let t = g().subscribe(e);
|
|
3224
|
-
return typeof window > "u" ? t : (window.addEventListener("online", e), window.addEventListener("offline", e), () => {
|
|
3225
|
-
t(), window.removeEventListener("online", e), window.removeEventListener("offline", e);
|
|
3226
|
-
});
|
|
3227
|
-
}, La = (e) => {
|
|
3228
|
-
let t = B(() => Fa(e), [e]);
|
|
3229
|
-
return G(Ia, t, () => !0);
|
|
3230
|
-
}, Ra = (e, t, n, r, i) => [...e, {
|
|
3231
|
-
id: t,
|
|
3232
|
-
tag: n,
|
|
3233
|
-
input: r,
|
|
3234
|
-
status: "pending",
|
|
3235
|
-
attempts: 0,
|
|
3236
|
-
...i === void 0 ? {} : { stamp: i }
|
|
3237
|
-
}], za = (e, t, n) => e.map((e) => e.id === t ? {
|
|
3238
|
-
...e,
|
|
3239
|
-
...n
|
|
3240
|
-
} : e), Ba = (e, t) => za(e, t, { status: "sent" }), Va = (e, t, n) => e.map((e) => e.id === t ? {
|
|
3241
|
-
...e,
|
|
3242
|
-
status: "failed",
|
|
3243
|
-
error: n,
|
|
3244
|
-
attempts: e.attempts + 1
|
|
3245
|
-
} : e), Ha = (e, t, n) => za(e, t, {
|
|
3246
|
-
status: "conflict",
|
|
3247
|
-
error: n
|
|
3248
|
-
}), Ua = (e, t, n) => e.map((e) => e.id === t && e.status === "conflict" ? {
|
|
3249
|
-
...e,
|
|
3250
|
-
input: n,
|
|
3251
|
-
status: "pending",
|
|
3252
|
-
error: void 0
|
|
3253
|
-
} : e), Wa = (e) => e.filter((e) => e.status !== "sent"), Ga = (e) => {
|
|
3254
|
-
let t = [];
|
|
3255
|
-
for (let n of e) {
|
|
3256
|
-
if (n.status === "conflict") break;
|
|
3257
|
-
(n.status === "pending" || n.status === "failed") && t.push(n);
|
|
3258
|
-
}
|
|
3259
|
-
return t;
|
|
3260
|
-
}, Ka = (e) => {
|
|
3261
|
-
let t = e;
|
|
3262
|
-
return t?.conflict === !0 || t?._tag === "UndoBoundaryError" && t?.boundary === "conflict";
|
|
3263
|
-
}, qa = (e) => {
|
|
3264
|
-
let t = Math.min(3e4, 1e3 * 2 ** Math.max(0, e - 1));
|
|
3265
|
-
return t / 2 + t / 2 * Math.random();
|
|
3266
|
-
}, Ja = (e) => {
|
|
3267
|
-
let { persistence: t, isConflict: n = Ka, idFor: r, api: i } = e;
|
|
3268
|
-
if (e.send === void 0 && i === void 0) throw Error("useOutbox: pass `send`, or `api` to send through that api's own mutations.");
|
|
3269
|
-
let a = Pe(P), o = a?.demand;
|
|
3270
|
-
V(() => {
|
|
3271
|
-
i !== void 0 && o?.(i);
|
|
3272
|
-
}, [o, i]);
|
|
3273
|
-
let s = i === void 0 || a === null ? void 0 : a.get(i), l = U(s);
|
|
3274
|
-
l.current = s;
|
|
3275
|
-
let [u, d] = W([]), [f, p] = W(0), m = La(i), h = e.online ?? m, g = U([]), _ = B((e) => {
|
|
3276
|
-
let t = e(g.current);
|
|
3277
|
-
g.current = t, d(t);
|
|
3278
|
-
}, []), y = U(e.retryDelay ?? qa);
|
|
3279
|
-
y.current = e.retryDelay ?? qa;
|
|
3280
|
-
let b = U(e.stamp);
|
|
3281
|
-
b.current = e.stamp;
|
|
3282
|
-
let x = U(async () => void 0);
|
|
3283
|
-
x.current = e.send ?? (async (e) => {
|
|
3284
|
-
if (l.current === void 0) throw Error(`useOutbox: no mounted api '${i}' — render it inside the framework's runtime provider.`);
|
|
3285
|
-
let t = await N(l, i, e.tag), n = v(t.client, e.tag);
|
|
3286
|
-
await S(t.runtime, z(n(e.input), e.id));
|
|
3287
|
-
});
|
|
3288
|
-
let C = U(n);
|
|
3289
|
-
C.current = n;
|
|
3290
|
-
let w = U(void 0), T = U(!1), E = U(!0);
|
|
3291
|
-
V(() => (E.current = !0, () => {
|
|
3292
|
-
E.current = !1;
|
|
3293
|
-
}), []);
|
|
3294
|
-
let D = U(0), ee = U(Math.random().toString(36).slice(2, 8)), O = U(t === void 0), [k, A] = W(0), j = s === void 0 ? void 0 : s.recovery ?? c(s.errorBus, i);
|
|
3295
|
-
V(() => {
|
|
3296
|
-
if (j === void 0) return;
|
|
3297
|
-
let e = j.subjectSignal;
|
|
3298
|
-
if (e.aborted) return;
|
|
3299
|
-
let n = () => {
|
|
3300
|
-
g.current = [], d([]), O.current = t === void 0, T.current = !1, A((e) => e + 1);
|
|
3301
|
-
};
|
|
3302
|
-
return e.addEventListener("abort", n, { once: !0 }), () => {
|
|
3303
|
-
e.removeEventListener("abort", n);
|
|
3304
|
-
};
|
|
3305
|
-
}, [
|
|
3306
|
-
j,
|
|
3307
|
-
t,
|
|
3308
|
-
k
|
|
3309
|
-
]), V(() => {
|
|
3310
|
-
if (t === void 0) return;
|
|
3311
|
-
let e = !1;
|
|
3312
|
-
return O.current = !1, t.load().then((t) => {
|
|
3313
|
-
e || (O.current = !0, t.length > 0 && _((e) => [...t, ...e]), p((e) => e + 1));
|
|
3314
|
-
}, () => {
|
|
3315
|
-
e || (O.current = !0, p((e) => e + 1));
|
|
3316
|
-
}), () => {
|
|
3317
|
-
e = !0;
|
|
3318
|
-
};
|
|
3319
|
-
}, [
|
|
3320
|
-
t,
|
|
3321
|
-
_,
|
|
3322
|
-
k
|
|
3323
|
-
]), V(() => {
|
|
3324
|
-
t !== void 0 && O.current && t.save(Wa(u)).catch(() => {});
|
|
3325
|
-
}, [
|
|
3326
|
-
t,
|
|
3327
|
-
u,
|
|
3328
|
-
f
|
|
3329
|
-
]);
|
|
3330
|
-
let M = U(/* @__PURE__ */ new Set()), F = s === void 0 || te(s) ? void 0 : s.cache;
|
|
3331
|
-
V(() => {
|
|
3332
|
-
if (F !== void 0 && s !== void 0) for (let e of u) {
|
|
3333
|
-
let t = s.descriptors[e.tag]?.targets;
|
|
3334
|
-
if (e.status === "pending" || e.status === "failed") {
|
|
3335
|
-
if (M.current.delete(e.id), t === void 0 || t.length === 0 || F.hasIntent(e.id) || typeof e.input != "object" || e.input === null) continue;
|
|
3336
|
-
F.autoApply(t, e.input, e.id, { standing: !0 });
|
|
3337
|
-
} else M.current.has(e.id) || (M.current.add(e.id), e.status === "sent" ? F.confirmByMutation(e.id) : F.revertByMutation(e.id));
|
|
3338
|
-
}
|
|
3339
|
-
}, [
|
|
3340
|
-
F,
|
|
3341
|
-
s,
|
|
3342
|
-
u
|
|
3343
|
-
]);
|
|
3344
|
-
let ne = B((e, t) => {
|
|
3345
|
-
let n = r?.() ?? `obx_${ee.current}_${D.current++}_${e}`;
|
|
3346
|
-
_((r) => Ra(r, n, e, t, b.current?.())), p((e) => e + 1);
|
|
3347
|
-
}, [r, _]), I = U(void 0), L = B(() => {
|
|
3348
|
-
I.current !== void 0 && clearTimeout(I.current), I.current = void 0;
|
|
3349
|
-
}, []);
|
|
3350
|
-
V(() => L, [L]);
|
|
3351
|
-
let R = B(() => {
|
|
3352
|
-
if (!O.current || !E.current) return Promise.resolve();
|
|
3353
|
-
if (w.current !== void 0) return w.current;
|
|
3354
|
-
T.current = !1, L();
|
|
3355
|
-
let e = Promise.resolve().then(async () => {
|
|
3356
|
-
for (; E.current;) {
|
|
3357
|
-
let e = Ga(g.current)[0];
|
|
3358
|
-
if (e === void 0) break;
|
|
3359
|
-
try {
|
|
3360
|
-
if (await x.current(e), !E.current) break;
|
|
3361
|
-
_((t) => Ba(t, e.id));
|
|
3362
|
-
} catch (t) {
|
|
3363
|
-
if (!E.current) break;
|
|
3364
|
-
let n = C.current(t);
|
|
3365
|
-
_((r) => n ? Ha(r, e.id, t) : Va(r, e.id, t)), T.current = !0, n || (I.current = setTimeout(() => {
|
|
3366
|
-
I.current = void 0, re.current();
|
|
3367
|
-
}, y.current(e.attempts + 1)));
|
|
3368
|
-
break;
|
|
3369
|
-
}
|
|
3370
|
-
}
|
|
3371
|
-
}).finally(() => {
|
|
3372
|
-
w.current === e && (w.current = void 0);
|
|
3373
|
-
});
|
|
3374
|
-
return w.current = e, e;
|
|
3375
|
-
}, [_, L]), re = U(R);
|
|
3376
|
-
re.current = R, V(() => {
|
|
3377
|
-
h ? R() : L();
|
|
3378
|
-
}, [
|
|
3379
|
-
h,
|
|
3380
|
-
R,
|
|
3381
|
-
L
|
|
3382
|
-
]), V(() => {
|
|
3383
|
-
h && !T.current && R();
|
|
3384
|
-
}, [
|
|
3385
|
-
f,
|
|
3386
|
-
h,
|
|
3387
|
-
R
|
|
3388
|
-
]);
|
|
3389
|
-
let ie = B((e, t) => {
|
|
3390
|
-
_((n) => Ua(n, e, t)), h && R();
|
|
3391
|
-
}, [
|
|
3392
|
-
h,
|
|
3393
|
-
R,
|
|
3394
|
-
_
|
|
3395
|
-
]);
|
|
3396
|
-
return {
|
|
3397
|
-
queue: u,
|
|
3398
|
-
enqueue: ne,
|
|
3399
|
-
replay: R,
|
|
3400
|
-
online: h,
|
|
3401
|
-
pending: u.filter((e) => e.status === "pending" || e.status === "failed").length,
|
|
3402
|
-
conflicts: u.filter((e) => e.status === "conflict"),
|
|
3403
|
-
resolveConflict: ie
|
|
3404
|
-
};
|
|
3405
|
-
}, Ya = (e) => {
|
|
3406
|
-
let t = e;
|
|
3407
|
-
return t?.conflict === !0 || t?._tag === "UndoBoundaryError" && t?.boundary === "conflict";
|
|
3408
|
-
}, Xa = (e) => {
|
|
3409
|
-
let t = (Array.isArray(e) ? e : [e]).filter((e) => typeof e == "object" && !!e);
|
|
3410
|
-
for (let e of t) {
|
|
3411
|
-
if (e._tag === "Chunk") {
|
|
3412
|
-
for (let t of e.values ?? []) if (t._tag === "error") return {
|
|
3413
|
-
ok: !1,
|
|
3414
|
-
error: t.error
|
|
3415
|
-
};
|
|
3416
|
-
}
|
|
3417
|
-
if (e._tag === "Exit" && e.exit?._tag === "Failure") return {
|
|
3418
|
-
ok: !1,
|
|
3419
|
-
error: e.exit.cause
|
|
3420
|
-
};
|
|
3421
|
-
}
|
|
3422
|
-
return { ok: !0 };
|
|
3423
|
-
}, Za = async (e) => {
|
|
3424
|
-
let t = e.fetch ?? ((e, t) => fetch(e, t)), n = e.isConflict ?? Ya, r = e.queue, i = 0, a = 0, o = 0;
|
|
3425
|
-
for (let s of Ga(e.queue)) {
|
|
3426
|
-
let c;
|
|
3427
|
-
try {
|
|
3428
|
-
let n = await t(e.url, {
|
|
3429
|
-
method: "POST",
|
|
3430
|
-
headers: {
|
|
3431
|
-
"content-type": "application/json",
|
|
3432
|
-
...e.headers
|
|
3433
|
-
},
|
|
3434
|
-
body: JSON.stringify({
|
|
3435
|
-
_tag: "Request",
|
|
3436
|
-
id: s.id,
|
|
3437
|
-
tag: s.tag,
|
|
3438
|
-
payload: s.input,
|
|
3439
|
-
headers: [["idempotency-key", s.id]]
|
|
3440
|
-
})
|
|
3441
|
-
});
|
|
3442
|
-
c = n.ok ? Xa(await n.json().catch(() => null)) : {
|
|
3443
|
-
ok: !1,
|
|
3444
|
-
error: { status: n.status }
|
|
3445
|
-
};
|
|
3446
|
-
} catch (e) {
|
|
3447
|
-
c = {
|
|
3448
|
-
ok: !1,
|
|
3449
|
-
error: e
|
|
3450
|
-
};
|
|
3451
|
-
}
|
|
3452
|
-
if (c.ok) {
|
|
3453
|
-
r = Ba(r, s.id), i++;
|
|
3454
|
-
continue;
|
|
3455
|
-
}
|
|
3456
|
-
if (n(c.error)) {
|
|
3457
|
-
r = Ha(r, s.id, c.error), o++;
|
|
3458
|
-
continue;
|
|
3459
|
-
}
|
|
3460
|
-
r = Va(r, s.id, c.error), a++;
|
|
3461
|
-
break;
|
|
3462
|
-
}
|
|
3463
|
-
return {
|
|
3464
|
-
queue: r,
|
|
3465
|
-
sent: i,
|
|
3466
|
-
failed: a,
|
|
3467
|
-
conflicts: o
|
|
3468
|
-
};
|
|
3469
|
-
}, Qa = "voltro-outbox", $a = "outbox", eo = "queue", to = (e, t) => new Promise((n, r) => {
|
|
3470
|
-
let i = e.open(t, 1);
|
|
3471
|
-
i.onupgradeneeded = () => {
|
|
3472
|
-
i.result.objectStoreNames.contains($a) || i.result.createObjectStore($a);
|
|
3473
|
-
}, i.onsuccess = () => n(i.result), i.onerror = () => r(i.error ?? /* @__PURE__ */ Error("indexedDB open failed"));
|
|
3474
|
-
}), no = (e) => new Promise((t, n) => {
|
|
3475
|
-
e.onsuccess = () => t(e.result), e.onerror = () => n(e.error ?? /* @__PURE__ */ Error("indexedDB request failed"));
|
|
3476
|
-
}), ro = (e = {}) => {
|
|
3477
|
-
let t = e.name ?? "voltro-outbox", n = () => {
|
|
3478
|
-
let t = e.indexedDB ?? globalThis.indexedDB;
|
|
3479
|
-
if (t === void 0) throw Error("indexedDbOutboxPersistence: no indexedDB in this environment");
|
|
3480
|
-
return t;
|
|
3481
|
-
};
|
|
3482
|
-
return {
|
|
3483
|
-
load: async () => {
|
|
3484
|
-
let e = await to(n(), t);
|
|
3485
|
-
try {
|
|
3486
|
-
let t = await no(e.transaction($a, "readonly").objectStore($a).get(eo));
|
|
3487
|
-
return Array.isArray(t) ? t : [];
|
|
3488
|
-
} finally {
|
|
3489
|
-
e.close();
|
|
3490
|
-
}
|
|
3491
|
-
},
|
|
3492
|
-
save: async (e) => {
|
|
3493
|
-
let r = await to(n(), t);
|
|
3494
|
-
try {
|
|
3495
|
-
await no(r.transaction($a, "readwrite").objectStore($a).put(e, eo));
|
|
3496
|
-
} finally {
|
|
3497
|
-
r.close();
|
|
3498
|
-
}
|
|
3499
|
-
}
|
|
3500
|
-
};
|
|
3501
|
-
}, io = "voltro:outbox", ao = async (e) => {
|
|
3502
|
-
let t = e.persistence ?? ro(), n = await t.load(), r = await Za({
|
|
3503
|
-
url: e.url,
|
|
3504
|
-
queue: n,
|
|
3505
|
-
...e.headers ? { headers: e.headers } : {}
|
|
3506
|
-
});
|
|
3507
|
-
return r.sent + r.failed + r.conflicts > 0 && await t.save(r.queue), r;
|
|
3508
|
-
}, oo = (e) => {
|
|
3509
|
-
let { scrollTop: t, viewportHeight: n, rowHeight: r, overscan: i = 5, total: a } = e, o = r > 0 ? r : 1, s = Math.max(0, Math.floor(t / o)), c = Math.ceil(n / o), l = Math.max(0, s - i), u = s + c + i, d = a === void 0 ? u : Math.min(u, a);
|
|
3510
|
-
return {
|
|
3511
|
-
startIndex: l,
|
|
3512
|
-
endIndex: d,
|
|
3513
|
-
offset: l,
|
|
3514
|
-
limit: Math.max(0, d - l),
|
|
3515
|
-
topSpacer: l * r,
|
|
3516
|
-
bottomSpacer: a === void 0 ? 0 : Math.max(0, (a - d) * r)
|
|
3517
|
-
};
|
|
3518
|
-
}, so = (e, t, n) => {
|
|
3519
|
-
let { rowHeight: r, viewportHeight: i, overscan: a, total: o, input: s } = n, [c, l] = W(0), u = H(() => oo({
|
|
3520
|
-
scrollTop: c,
|
|
3521
|
-
viewportHeight: i,
|
|
3522
|
-
rowHeight: r,
|
|
3523
|
-
...a === void 0 ? {} : { overscan: a },
|
|
3524
|
-
...o === void 0 ? {} : { total: o }
|
|
3525
|
-
}), [
|
|
3526
|
-
c,
|
|
3527
|
-
i,
|
|
3528
|
-
r,
|
|
3529
|
-
a,
|
|
3530
|
-
o
|
|
3531
|
-
]), d = J(e, t, H(() => ({
|
|
3532
|
-
...s,
|
|
3533
|
-
offset: u.offset,
|
|
3534
|
-
limit: u.limit
|
|
3535
|
-
}), [
|
|
3536
|
-
s,
|
|
3537
|
-
u.offset,
|
|
3538
|
-
u.limit
|
|
3539
|
-
])), f = B((e) => {
|
|
3540
|
-
l(e.currentTarget.scrollTop);
|
|
3541
|
-
}, []);
|
|
3542
|
-
return {
|
|
3543
|
-
rows: d.data ?? [],
|
|
3544
|
-
window: u,
|
|
3545
|
-
onScroll: f,
|
|
3546
|
-
topSpacer: u.topSpacer,
|
|
3547
|
-
bottomSpacer: u.bottomSpacer,
|
|
3548
|
-
loading: d.data === void 0,
|
|
3549
|
-
error: d.error
|
|
3550
|
-
};
|
|
3551
|
-
}, co = () => typeof navigator > "u" || navigator.onLine, lo = () => !0, uo = (e) => typeof window > "u" ? () => {} : (window.addEventListener("online", e), window.addEventListener("offline", e), () => {
|
|
3552
|
-
window.removeEventListener("online", e), window.removeEventListener("offline", e);
|
|
3553
|
-
}), fo = (e) => {
|
|
3554
|
-
let t = k(e), n = t.recovery ?? c(t.errorBus, e), r = G(n.subscribe, n.getSnapshot, n.getServerSnapshot ?? (() => x)), i = G(uo, co, lo), o = B(() => n.reportExternalSuccess(), [n]), s = i ? r.status : "offline";
|
|
3555
|
-
return V(() => {
|
|
3556
|
-
a(e, "connection.status", {
|
|
3557
|
-
status: s,
|
|
3558
|
-
rawTransport: r.rawTransport,
|
|
3559
|
-
online: i,
|
|
3560
|
-
failureCount: r.failureCount,
|
|
3561
|
-
failedSubscriptions: r.failedSubscriptions.length,
|
|
3562
|
-
pendingMutationReplays: r.pendingMutationReplays,
|
|
3563
|
-
mutationReplay: r.mutationReplay
|
|
3564
|
-
});
|
|
3565
|
-
}, [
|
|
3566
|
-
e,
|
|
3567
|
-
s,
|
|
3568
|
-
i,
|
|
3569
|
-
r
|
|
3570
|
-
]), {
|
|
3571
|
-
status: s,
|
|
3572
|
-
rawTransport: r.rawTransport,
|
|
3573
|
-
online: i,
|
|
3574
|
-
failureCount: r.failureCount,
|
|
3575
|
-
lastFailureAt: r.lastFailureAt,
|
|
3576
|
-
failedSubscriptions: r.failedSubscriptions,
|
|
3577
|
-
pendingMutationReplays: r.pendingMutationReplays,
|
|
3578
|
-
mutationReplay: r.mutationReplay,
|
|
3579
|
-
reportSuccess: o
|
|
3580
|
-
};
|
|
3581
|
-
}, po = (e, t) => e === t ? 0 : e == null ? 1 : t == null ? -1 : e instanceof Date && t instanceof Date ? e.getTime() - t.getTime() : typeof e == "number" && typeof t == "number" ? e - t : String(e).localeCompare(String(t)), mo = (e, t = {}) => {
|
|
3582
|
-
let n = t.where === void 0 ? [...e] : e.filter(t.where), r = t.orderBy;
|
|
3583
|
-
if (r !== void 0) {
|
|
3584
|
-
let e = typeof r == "function" ? r : (e, t) => {
|
|
3585
|
-
let [n, i] = typeof r == "string" ? [r, "asc"] : r, a = po(e[n], t[n]);
|
|
3586
|
-
return i === "desc" ? -a : a;
|
|
3587
|
-
};
|
|
3588
|
-
n = n.sort(e);
|
|
3589
|
-
}
|
|
3590
|
-
return t.limit === void 0 ? n : n.slice(0, Math.max(0, t.limit));
|
|
3591
|
-
}, ho = (e, t, n = {}) => {
|
|
3592
|
-
let { cache: r } = k(e), i = G(B((e) => r.subscribeAny(e), [r]), B(() => r.rowsOf(t), [r, t]), () => go), a = U(n);
|
|
3593
|
-
a.current = n;
|
|
3594
|
-
let { where: o, orderBy: s, limit: c } = n;
|
|
3595
|
-
return H(() => mo(i, a.current), [
|
|
3596
|
-
i,
|
|
3597
|
-
o,
|
|
3598
|
-
s,
|
|
3599
|
-
c
|
|
3600
|
-
]);
|
|
3601
|
-
}, go = [], _o = "__voltro.connections.list", vo = "__voltro.connections.start", yo = "__voltro.connections.submitToken", bo = "__voltro.connections.disconnect", xo = {
|
|
3602
|
-
connectionId: "",
|
|
3603
|
-
kind: "oauth2",
|
|
3604
|
-
label: "",
|
|
3605
|
-
status: "disconnected",
|
|
3606
|
-
accountId: null,
|
|
3607
|
-
accountLabel: null,
|
|
3608
|
-
scopes: [],
|
|
3609
|
-
expiresAt: null,
|
|
3610
|
-
lastError: null,
|
|
3611
|
-
connectedAt: null
|
|
3612
|
-
}, So = (e, t) => {
|
|
3613
|
-
if (t === "redirect") {
|
|
3614
|
-
globalThis.location.assign(e);
|
|
3615
|
-
return;
|
|
3616
|
-
}
|
|
3617
|
-
globalThis.open(e, "voltro-connect", "width=620,height=760,menubar=no,toolbar=no") === null && globalThis.location.assign(e);
|
|
3618
|
-
}, Co = (e) => {
|
|
3619
|
-
let { data: t } = J(e, _o, {}), n = nr(e, vo), r = Zn(e, yo), i = Zn(e, bo), a = t ?? [], o = n.pending || r.pending || i.pending, s = B((e) => ({
|
|
3620
|
-
...e,
|
|
3621
|
-
connected: e.status === "connected",
|
|
3622
|
-
needsAttention: e.status === "expired" || e.status === "revoked" || e.status === "error",
|
|
3623
|
-
pending: o,
|
|
3624
|
-
connect: async (t) => {
|
|
3625
|
-
if (e.kind !== "oauth2") throw Error(`connection "${e.connectionId}" is a personal-access-token connection — call submitToken(token), not connect().`);
|
|
3626
|
-
let r = t?.redirectTo ?? `${globalThis.location.pathname}${globalThis.location.search}`;
|
|
3627
|
-
So((await n.run({
|
|
3628
|
-
connectionId: e.connectionId,
|
|
3629
|
-
redirectTo: r
|
|
3630
|
-
})).authorizeUrl, t?.mode);
|
|
3631
|
-
},
|
|
3632
|
-
submitToken: async (t) => {
|
|
3633
|
-
if (e.kind !== "pat") throw Error(`connection "${e.connectionId}" uses OAuth — call connect(), not submitToken().`);
|
|
3634
|
-
await r.mutate({
|
|
3635
|
-
connectionId: e.connectionId,
|
|
3636
|
-
token: t
|
|
3637
|
-
});
|
|
3638
|
-
},
|
|
3639
|
-
disconnect: async () => {
|
|
3640
|
-
await i.mutate({ connectionId: e.connectionId });
|
|
3641
|
-
}
|
|
3642
|
-
}), [
|
|
3643
|
-
o,
|
|
3644
|
-
n,
|
|
3645
|
-
r,
|
|
3646
|
-
i
|
|
3647
|
-
]), c = B((e) => {
|
|
3648
|
-
let t = a.find((t) => t.connectionId === e);
|
|
3649
|
-
return t === void 0 ? void 0 : s(t);
|
|
3650
|
-
}, [a, s]);
|
|
3651
|
-
return {
|
|
3652
|
-
connections: a,
|
|
3653
|
-
loading: t === void 0,
|
|
3654
|
-
get: c,
|
|
3655
|
-
pending: o
|
|
3656
|
-
};
|
|
3657
|
-
}, wo = (e, t) => {
|
|
3658
|
-
let n = Co(e), r = n.get(t);
|
|
3659
|
-
return H(() => r === void 0 ? {
|
|
3660
|
-
...xo,
|
|
3661
|
-
connectionId: t,
|
|
3662
|
-
label: t,
|
|
3663
|
-
connected: !1,
|
|
3664
|
-
needsAttention: !1,
|
|
3665
|
-
pending: n.pending,
|
|
3666
|
-
loading: n.loading,
|
|
3667
|
-
connect: async () => {
|
|
3668
|
-
throw Error(`connection "${t}" is not declared by this app.`);
|
|
3669
|
-
},
|
|
3670
|
-
submitToken: async () => {
|
|
3671
|
-
throw Error(`connection "${t}" is not declared by this app.`);
|
|
3672
|
-
},
|
|
3673
|
-
disconnect: async () => {
|
|
3674
|
-
throw Error(`connection "${t}" is not declared by this app.`);
|
|
3675
|
-
}
|
|
3676
|
-
} : {
|
|
3677
|
-
...r,
|
|
3678
|
-
loading: n.loading
|
|
3679
|
-
}, [
|
|
3680
|
-
r,
|
|
3681
|
-
t,
|
|
3682
|
-
n.loading,
|
|
3683
|
-
n.pending
|
|
3684
|
-
]);
|
|
3685
|
-
}, To = "framework-client";
|
|
3686
|
-
//#endregion
|
|
3687
|
-
export { zi as ADMIN_SCOPE, To as CLIENT_NAME, _o as CONNECTIONS_LIST_TAG, bo as CONNECTION_DISCONNECT_TAG, vo as CONNECTION_START_TAG, yo as CONNECTION_SUBMIT_TOKEN_TAG, Ee as FORM_FLASH_SCRIPT_ID, xe as FORM_KEY_FIELD, we as FORM_PATH_PREFIX, ve as FORM_REDIRECT_FIELD, hr as FormBindingProvider, P as FrameworkRuntimesContext, ot as FrameworkRuntimesProvider, x as INITIAL_RECOVERY_SNAPSHOT, _ as LoadingSubscriptionCache, zn as MutationSerialExecutionError, Qa as OUTBOX_DB_NAME, io as OUTBOX_SYNC_TAG, We as PAIRING_HOST, Ge as PAIRING_SCHEME, Ke as PAIRING_STORAGE_KEY, Ui as PermissionProvider, Te as RICH_TEXT_MARKS, pe as RICH_TEXT_MAX_NODES, m as RecoveryCoordinator, ye as RichTextDocument, C as RpcErrorBus, Oi as ServerRequestContext, Ai as ServerRequestProvider, p as SubscriptionCache, oa as UNDO_APPLY_TAG, aa as UNDO_LOG_TAG, sa as UNDO_REDO_TAG, ir as ValidationMessagesProvider, j as _resetFrameworkRuntimesWarning, ee as _resetSsrDescriptors, g as apiConnectivity, qe as applyPairing, Mr as applyPreloadSeeds, qt as applyStoreSeeds, Jt as browserOnlineSource, an as browserPlatform, lt as browserStoreStorage, ie as buildApiRuntime, Bi as canCall, Vi as canCallAny, Yt as capabilitiesOf, w as clearClientDiagnostics, Mn as clearMutations, Je as clearPairing, Wa as clearSent, Dt as clearStoreHistory, D as clientDiagnosticsSnapshot, oo as computeWindow, Ma as createAnalytics, wr as createHooks, ln as currentPlatform, Xi as decideAccess, ge as decodeFieldIssues, yn as deepLinkHref, qa as defaultOutboxRetryDelay, hn as defineDeepLink, ka as defineEvent, Xt as definePlatform, Ht as defineStore, la as defineTracking, Vt as definedStores, ra as deriveEntityAdmins, l as disableClientDiagnosticsPersistence, xn as dispatchDeepLink, ue as documentLocale, ao as drainOutboxInWorker, Za as drainOutboxOverHttp, De as emptyRichTextDocument, E as enableClientDiagnosticsPersistence, Ra as enqueueEntry, Ye as errorMessage, Xe as errorTag, ja as eventCatalog, Sa as filtersFromSchema, de as formActionPath, Se as formDataToInput, Ae as formField, le as formSections, ae as freshIdempotencyKey, Kn as getMutationNotifier, An as getMutations, Di as globalContext, ro as indexedDbOutboxPersistence, cn as installPlatform, un as isPlatformInstalled, me as isRichTextDocument, he as isSafeHref, nn as isStandaloneDisplay, se as isUnauthenticated, te as isUnresolvedApi, Tr as makePreloadSeedBag, Wt as makeStoreSeedBag, qi as manifestUrl, Ha as markConflict, Va as markFailed, Ba as markSent, _n as matchDeepLink, bn as matchFirstDeepLink, Qt as memoryTokenStore, Qi as openAccessReason, Qe as pairingLink, $e as parsePairingLink, Ce as parseRichText, Li as provenanceUrl, u as publishClientError, r as publishClientTrace, ne as queryOnce, Fa as readApiOnline, tt as readPairing, Pr as readPreloadedSeedOutcome, Nr as readPreloadedSnapshot, a as recordClientDiagnostic, c as recoveryCoordinatorFor, Zt as refusingTokenStore, h as registerCellMerger, F as registerSsrDescriptors, e as registeredCellMerger, Ga as replayable, d as reportClientError, Zi as requiredScopes, dn as resetPlatformForTest, Fr as resetPreloadSeeds, Ut as resetStoreRegistryForTests, ft as resetStoreStorageForTest, v as resolveByTag, Ua as resolveConflictEntry, y as resolveRecoveryOptions, dt as resolveStoreStorage, ua as resolveTrackingEvent, Oe as resolveValidationMessage, je as restrictToSchema, pi as resumableConsumeProgram, be as richTextToPlainText, Mi as rowsToOptions, Xa as rpcHttpOutcome, vn as runDeepLink, mo as runLocalQuery, Vr as runSequence, ce as schemaToColumns, ke as schemaToFields, Ar as seedPreloadedSubscription, jr as seedPreloadedSubscriptionFailure, Kt as seedStore, Br as sequence, _e as serializeRichText, Gn as setMutationNotifier, Dr as setPreloadSeedResolver, Gt as setStoreSeedResolver, ut as setStoreStorage, X as settleMutation, pt as shallow, ga as shallowArrayEqual, _a as sourceValues, O as ssrClientProxy, M as ssrDescriptorsFor, I as ssrStubHandle, f as stableKey, L as startApiSupervisor, kn as startMutation, Tt as storeHistory, Ia as subscribeApiOnline, t as subscribeClientDiagnostics, b as subscribeClientErrors, n as subscribeClientTraces, jn as subscribeMutations, Et as subscribeStoreHistory, s as supersedesConfirmedPatches, Ot as travelToStoreState, $i as useAccessDecision, nr as useAction, yi as useAgent, vi as useAgentChat, fi as useAgentStream, La as useApiOnline, Oa as useAsyncValidation, Gi as useCan, Ki as useCanAny, Ji as useCapabilityManifest, wo as useConnection, Sr as useConnectionSetup, fo as useConnectionStatus, Co as useConnections, bi as useDataCopilot, Fi as useDataTable, Ea as useDebounced, va as useDerived, zr as useEvent, fr as useFormBinding, gr as useFormBindingContext, _r as useFormField, ji as useFormFlash, ma as useFormSkeleton, k as useFrameworkApi, A as useFrameworkRuntimes, ho as useLocalQuery, Zn as useMutation, wi as useOnRawRpcError, Ci as useOnRpcError, Ja as useOutbox, Wi as usePermissions, pn as usePlatform, Ir as usePreloadedSubscription, Na as usePreview, Ri as useProvenance, Ni as useQueryField, wa as useQueryFilters, Ta as useRecord, Si as useRefreshSubscription, xi as useRefreshSubscriptions, ya as useResourceCan, ba as useResourceCans, hi as useResumableAgentStream, pr as useSchemaFormBinding, Hr as useSequence, ki as useServerRequest, mn as useShellExtension, J as useSubscription, Ei as useSubscriptionHealth, ha as useTableSkeleton, pa as useTracking, Yr as useTranscription, ia as useUndo, ca as useUndoLog, Jr as useUpload, ar as useValidationMessages, so as useWindowedSubscription, Xr as useWorkflow, ii as useWorkflowDomainEvents, ai as useWorkflowEventDeliveries, ri as useWorkflowEvents, $r as useWorkflowRun, ni as useWorkflowRunEvents, di as useWorkflowRunState, ti as useWorkflowRunSteps, ei as useWorkflowRuns, Zr as useWorkflowSignal, Qr as useWorkflowUpdate, Aa as validateEventPayload, fe as validateFields, Da as validationStatus, re as wireAuthRefresh, z as withIdempotencyKey, oe as withProtocolOpenRecovery, fa as wrapTrackedCallbacks };
|
|
84
|
+
export { ln as ADMIN_SCOPE, Rr as CLIENT_NAME, yr as CONNECTIONS_LIST_TAG, br as CONNECTION_DISCONNECT_TAG, xr as CONNECTION_START_TAG, Sr as CONNECTION_SUBMIT_TOKEN_TAG, Tr as DEV_ACTIVITY_EVENT, qt as FORM_FLASH_SCRIPT_ID, Jt as FORM_KEY_FIELD, Yt as FORM_PATH_PREFIX, Xt as FORM_REDIRECT_FIELD, Ge as FormBindingProvider, w as FrameworkRuntimesContext, z as FrameworkRuntimesProvider, y as INITIAL_RECOVERY_SNAPSHOT, d as LoadingSubscriptionCache, ke as MutationSerialExecutionError, cr as OUTBOX_DB_NAME, lr as OUTBOX_SYNC_TAG, Er as PAIRING_HOST, Dr as PAIRING_SCHEME, Or as PAIRING_STORAGE_KEY, un as PermissionProvider, Rt as RICH_TEXT_MARKS, zt as RICH_TEXT_MAX_NODES, b as RecoveryCoordinator, Bt as RichTextDocument, _ as RpcErrorBus, $t as ServerRequestContext, en as ServerRequestProvider, f as SubscriptionCache, wn as UNDO_APPLY_TAG, Tn as UNDO_LOG_TAG, En as UNDO_REDO_TAG, Ue as ValidationMessagesProvider, D as _resetFrameworkRuntimesWarning, O as _resetSsrDescriptors, v as apiConnectivity, kr as applyPairing, Qe as applyPreloadSeeds, W as applyStoreSeeds, ne as browserOnlineSource, re as browserPlatform, B as browserStoreStorage, I as buildApiRuntime, dn as canCall, fn as canCallAny, ie as capabilitiesOf, i as clearClientDiagnostics, Se as clearMutations, Ar as clearPairing, $n as clearSent, G as clearStoreHistory, a as clientDiagnosticsSnapshot, mr as computeWindow, Gn as createAnalytics, Ze as createHooks, ae as currentPlatform, gn as decideAccess, Re as decodeFieldIssues, he as deepLinkHref, er as defaultOutboxRetryDelay, ge as defineDeepLink, Kn as defineEvent, oe as definePlatform, K as defineStore, On as defineTracking, q as definedStores, _n as deriveEntityAdmins, o as disableClientDiagnosticsPersistence, _e as dispatchDeepLink, ze as documentLocale, ur as drainOutboxInWorker, dr as drainOutboxOverHttp, Vt as emptyRichTextDocument, s as enableClientDiagnosticsPersistence, tr as enqueueEntry, jr as errorMessage, Mr as errorTag, qn as eventCatalog, zn as filtersFromSchema, Zt as formActionPath, Qt as formDataToInput, Pe as formField, Fe as formSections, De as freshIdempotencyKey, Ae as getMutationNotifier, Ce as getMutations, C as globalContext, fr as indexedDbOutboxPersistence, se as installPlatform, ce as isPlatformInstalled, Ht as isRichTextDocument, Ut as isSafeHref, le as isStandaloneDisplay, Nt as isUnauthenticated, T as isUnresolvedApi, Nr as jsonSchemaDocumentOf, Pr as jsonSchemaOf, $e as makePreloadSeedBag, L as makeProtocolOpenRecovery, J as makeStoreSeedBag, vn as manifestUrl, nr as markConflict, rr as markFailed, ir as markSent, ve as matchDeepLink, ye as matchFirstDeepLink, ue as memoryTokenStore, yn as openAccessReason, Fr as pairingLink, Ir as parsePairingLink, Wt as parseRichText, sn as provenanceUrl, m as publishClientError, n as publishClientTrace, Mt as queryOnce, Xn as readApiOnline, Lr as readPairing, et as readPreloadedSeedOutcome, tt as readPreloadedSnapshot, c as recordClientDiagnostic, x as recoveryCoordinatorFor, de as refusingTokenStore, e as registerCellMerger, k as registerSsrDescriptors, t as registeredCellMerger, ar as replayable, h as reportClientError, bn as requiredScopes, fe as resetPlatformForTest, nt as resetPreloadSeeds, Y as resetStoreRegistryForTests, V as resetStoreStorageForTest, F as resolveByTag, or as resolveConflictEntry, S as resolveRecoveryOptions, H as resolveStoreStorage, kn as resolveTrackingEvent, Be as resolveValidationMessage, Ve as restrictToSchema, Tt as resumableConsumeProgram, Gt as richTextToPlainText, rn as rowsToOptions, pr as rpcHttpOutcome, be as runDeepLink, _r as runLocalQuery, ct as runSequence, Ie as schemaToColumns, Le as schemaToFields, rt as seedPreloadedSubscription, it as seedPreloadedSubscriptionFailure, X as seedStore, lt as sequence, Kt as serializeRichText, je as setMutationNotifier, at as setPreloadSeedResolver, Z as setStoreSeedResolver, U as setStoreStorage, we as settleMutation, Q as shallow, Pn as shallowArrayEqual, Fn as sourceValues, A as ssrClientProxy, j as ssrDescriptorsFor, M as ssrStubHandle, u as stableKey, R as startApiSupervisor, Te as startMutation, $ as storeHistory, Zn as subscribeApiOnline, l as subscribeClientDiagnostics, g as subscribeClientErrors, r as subscribeClientTraces, Ee as subscribeMutations, ee as subscribeStoreHistory, p as supersedesConfirmedPatches, te as travelToStoreState, E as unknownApiError, xn as useAccessDecision, Ne as useAction, Ot as useAgent, Dt as useAgentChat, wt as useAgentStream, Qn as useApiOnline, Hn as useAsyncValidation, pn as useCan, mn as useCanAny, Sn as useCapabilityManifest, Cr as useConnection, Xe as useConnectionSetup, gr as useConnectionStatus, wr as useConnections, kt as useDataCopilot, on as useDataTable, Un as useDebounced, In as useDerived, st as useEvent, Ke as useFormBinding, qe as useFormBindingContext, Je as useFormField, tn as useFormFlash, Mn as useFormSkeleton, N as useFrameworkApi, P as useFrameworkRuntimes, vr as useLocalQuery, Me as useMutation, Ft as useOnRawRpcError, It as useOnRpcError, sr as useOutbox, hn as usePermissions, pe as usePlatform, ot as usePreloadedSubscription, Yn as usePreview, cn as useProvenance, an as useQueryField, Bn as useQueryFilters, Vn as useRecord, At as useRefreshSubscription, jt as useRefreshSubscriptions, Ln as useResourceCan, Rn as useResourceCans, Et as useResumableAgentStream, Ye as useSchemaFormBinding, ut as useSequence, nn as useServerRequest, me as useShellExtension, xe as useSubscription, Lt as useSubscriptionHealth, Nn as useTableSkeleton, An as useTracking, ft as useTranscription, Cn as useUndo, Dn as useUndoLog, dt as useUpload, We as useValidationMessages, hr as useWindowedSubscription, pt as useWorkflow, mt as useWorkflowDomainEvents, ht as useWorkflowEventDeliveries, gt as useWorkflowEvents, _t as useWorkflowRun, vt as useWorkflowRunEvents, Ct as useWorkflowRunState, yt as useWorkflowRunSteps, bt as useWorkflowRuns, xt as useWorkflowSignal, St as useWorkflowUpdate, Jn as validateEventPayload, He as validateFields, Wn as validationStatus, Pt as wireAuthRefresh, Oe as withIdempotencyKey, jn as wrapTrackedCallbacks };
|