@voltro/client 0.66.1 → 0.67.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 +44 -0
- package/README.md +6 -0
- package/THIRD-PARTY-NOTICES.md +2 -2
- package/dist/index.d.ts +39 -45
- package/dist/index.js +673 -626
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { C as e, S as t, _ as n, a as r, b as i, c as a, d as o, f as s, g as c, h as l, i as u, l as d, m as f, n as p, o as m, p as h, r as g, s as _, t as v, u as y, v as b, w as x, x as S, y as C } from "./formData-He_L4ozH.js";
|
|
2
2
|
import { createContext as w, createElement as T, useCallback as E, useContext as ee, useDebugValue as te, useEffect as D, useMemo as O, useRef as k, useState as A, useSyncExternalStore as j } from "react";
|
|
3
|
-
import { Cause as M, Context as ne, Duration as re, Effect as N, Exit as P, Fiber as ie, Layer as F, ManagedRuntime as I, Option as ae, Schedule as L,
|
|
4
|
-
import * as
|
|
5
|
-
import { RpcClient as
|
|
3
|
+
import { Cause as M, Context as ne, Duration as re, Effect as N, Exit as P, Fiber as ie, Layer as F, ManagedRuntime as I, Option as ae, Schedule as L, Scheduler as oe, Schema as se, Stream as R } from "effect";
|
|
4
|
+
import * as ce from "@effect/platform/Headers";
|
|
5
|
+
import { RpcClient as z, RpcClientError as le, RpcSerialization as ue } from "@effect/rpc";
|
|
6
6
|
import { applyRowPatch as de, fieldIssuesOf as fe, pluginTag as pe } from "@voltro/protocol";
|
|
7
|
-
import * as
|
|
7
|
+
import * as B from "@effect/platform/Socket";
|
|
8
8
|
import { jsx as me } from "react/jsx-runtime";
|
|
9
9
|
import { FormApi as he } from "@tanstack/form-core";
|
|
10
10
|
import { useStore as ge } from "@tanstack/react-store";
|
|
@@ -16,7 +16,7 @@ var ve = /* @__PURE__ */ new Set(), ye = (e) => {
|
|
|
16
16
|
} catch {}
|
|
17
17
|
}, be = (e) => (ve.add(e), () => {
|
|
18
18
|
ve.delete(e);
|
|
19
|
-
}), xe = /* @__PURE__ */ new WeakMap(), Se = (e, t) => ((typeof e == "object" && e || typeof e == "function") && xe.set(e, t), e),
|
|
19
|
+
}), xe = /* @__PURE__ */ new WeakMap(), Se = (e, t) => ((typeof e == "object" && e || typeof e == "function") && xe.set(e, t), e), V = (e, t) => {
|
|
20
20
|
if ((typeof e != "object" || !e) && typeof e != "function") return t;
|
|
21
21
|
let n = xe.get(e);
|
|
22
22
|
if (n !== void 0) return n;
|
|
@@ -25,24 +25,24 @@ var ve = /* @__PURE__ */ new Set(), ye = (e) => {
|
|
|
25
25
|
} catch {
|
|
26
26
|
return t;
|
|
27
27
|
}
|
|
28
|
-
}, Ce = "voltro.client-diagnostics.v1",
|
|
28
|
+
}, Ce = "voltro.client-diagnostics.v1", we = 400, Te = 240, Ee = Symbol.for("@voltro/client/diagnostics"), De = globalThis, Oe = () => typeof performance < "u" && typeof performance.now == "function" ? performance.now() : Date.now(), H = De[Ee] ?? (De[Ee] = {
|
|
29
29
|
sessionStartedAt: Date.now(),
|
|
30
|
-
monotonicStartedAt:
|
|
30
|
+
monotonicStartedAt: Oe(),
|
|
31
31
|
sequence: 0,
|
|
32
32
|
dropped: 0,
|
|
33
33
|
storage: void 0,
|
|
34
34
|
events: [],
|
|
35
35
|
loadedStorage: !1,
|
|
36
36
|
listeners: /* @__PURE__ */ new Set()
|
|
37
|
-
}),
|
|
37
|
+
}), ke = (e) => e.length <= Te ? e : `${e.slice(0, Te)}…`, Ae = (e) => {
|
|
38
38
|
let t = {};
|
|
39
|
-
for (let [n, r] of Object.entries(e)) r !== void 0 && (t[n] = typeof r == "string" ?
|
|
39
|
+
for (let [n, r] of Object.entries(e)) r !== void 0 && (t[n] = typeof r == "string" ? ke(r) : r);
|
|
40
40
|
return t;
|
|
41
|
-
},
|
|
41
|
+
}, je = (e) => {
|
|
42
42
|
if (typeof e != "object" || !e) return !1;
|
|
43
43
|
let t = e;
|
|
44
44
|
return typeof t.sequence == "number" && typeof t.at == "number" && typeof t.elapsedMs == "number" && typeof t.api == "string" && typeof t.kind == "string" && typeof t.fields == "object" && t.fields !== null;
|
|
45
|
-
},
|
|
45
|
+
}, Me = () => {
|
|
46
46
|
if (H.storage !== void 0) try {
|
|
47
47
|
H.storage.setItem(Ce, JSON.stringify({
|
|
48
48
|
version: 1,
|
|
@@ -52,84 +52,76 @@ var ve = /* @__PURE__ */ new Set(), ye = (e) => {
|
|
|
52
52
|
events: H.events
|
|
53
53
|
}));
|
|
54
54
|
} catch {}
|
|
55
|
-
},
|
|
55
|
+
}, Ne = () => {
|
|
56
56
|
for (let e of H.listeners) try {
|
|
57
57
|
e();
|
|
58
58
|
} catch {}
|
|
59
|
-
},
|
|
59
|
+
}, Pe = (e) => {
|
|
60
60
|
if (H.storage = e, !H.loadedStorage) {
|
|
61
61
|
H.loadedStorage = !0;
|
|
62
62
|
try {
|
|
63
63
|
let t = e.getItem(Ce);
|
|
64
64
|
if (t !== null) {
|
|
65
|
-
let e = JSON.parse(t), n = Array.isArray(e.events) ? e.events.filter(
|
|
65
|
+
let e = JSON.parse(t), n = Array.isArray(e.events) ? e.events.filter(je) : [], r = Math.max(typeof e.sequence == "number" ? e.sequence : 0, 0, ...n.map((e) => e.sequence)), i = H.events.map((e, t) => ({
|
|
66
66
|
...e,
|
|
67
67
|
sequence: r + t + 1
|
|
68
|
-
})), a = [...n, ...i], o = Math.max(0, a.length -
|
|
68
|
+
})), a = [...n, ...i], o = Math.max(0, a.length - we), s = typeof e.dropped == "number" ? e.dropped : 0;
|
|
69
69
|
H.dropped = H.dropped + s + o, H.events = a.slice(-400), H.sequence = Math.max(r + i.length, ...H.events.map((e) => e.sequence)), typeof e.sessionStartedAt == "number" && (H.sessionStartedAt = Math.min(H.sessionStartedAt, e.sessionStartedAt));
|
|
70
70
|
}
|
|
71
71
|
} catch {}
|
|
72
72
|
}
|
|
73
|
-
|
|
74
|
-
},
|
|
73
|
+
Me();
|
|
74
|
+
}, Fe = () => {
|
|
75
75
|
H.storage = void 0;
|
|
76
76
|
}, U = (e, t, n = {}) => {
|
|
77
77
|
let r = {
|
|
78
78
|
sequence: ++H.sequence,
|
|
79
79
|
at: Date.now(),
|
|
80
|
-
elapsedMs: Math.max(0, Math.round(
|
|
81
|
-
api:
|
|
80
|
+
elapsedMs: Math.max(0, Math.round(Oe() - H.monotonicStartedAt)),
|
|
81
|
+
api: ke(e),
|
|
82
82
|
kind: t,
|
|
83
|
-
fields:
|
|
83
|
+
fields: Ae(n)
|
|
84
84
|
};
|
|
85
|
-
return H.events.push(r), H.events.length >
|
|
86
|
-
},
|
|
85
|
+
return H.events.push(r), H.events.length > we && (H.events.splice(0, H.events.length - we), H.dropped += 1), Me(), Ne(), r;
|
|
86
|
+
}, Ie = (e) => ({
|
|
87
87
|
version: 1,
|
|
88
88
|
generatedAt: Date.now(),
|
|
89
89
|
sessionStartedAt: H.sessionStartedAt,
|
|
90
90
|
persisted: H.storage !== void 0,
|
|
91
91
|
dropped: H.dropped,
|
|
92
92
|
events: e === void 0 ? [...H.events] : H.events.filter((t) => t.api === e)
|
|
93
|
-
}),
|
|
93
|
+
}), Le = () => {
|
|
94
94
|
H.events = [], H.dropped = 0;
|
|
95
95
|
try {
|
|
96
96
|
H.storage?.removeItem(Ce);
|
|
97
97
|
} catch {}
|
|
98
|
-
|
|
99
|
-
},
|
|
98
|
+
Ne();
|
|
99
|
+
}, Re = (e) => (H.listeners.add(e), () => {
|
|
100
100
|
H.listeners.delete(e);
|
|
101
101
|
}), W = (e) => {
|
|
102
102
|
let t = (e) => e == null ? "null" : typeof e == "string" ? JSON.stringify(e) : typeof e == "number" || typeof e == "boolean" ? String(e) : Array.isArray(e) ? `[${e.map(t).join(",")}]` : typeof e == "object" ? `{${Object.keys(e).sort().map((n) => `${JSON.stringify(n)}:${t(e[n])}`).join(",")}}` : String(e);
|
|
103
103
|
return t(e);
|
|
104
|
-
},
|
|
104
|
+
}, ze = Object.freeze({
|
|
105
105
|
data: void 0,
|
|
106
106
|
revision: -1,
|
|
107
107
|
emittedAt: void 0,
|
|
108
108
|
error: void 0,
|
|
109
109
|
pendingPatches: 0
|
|
110
|
-
}),
|
|
111
|
-
if (e._tag === "error") return !1;
|
|
112
|
-
if (e._tag === "delta") return !0;
|
|
113
|
-
try {
|
|
114
|
-
return JSON.stringify(t) !== JSON.stringify(n);
|
|
115
|
-
} catch {
|
|
116
|
-
return !1;
|
|
117
|
-
}
|
|
118
|
-
}, Ve = 0, He = () => `patch_${++Ve}`, Ue = (e, t) => {
|
|
110
|
+
}), Be = 5e3, Ve = (e, t) => e._tag === "snapshot" && t !== void 0 && e.reconciles === t, He = 0, Ue = 0, We = () => `patch_${++Ue}`, Ge = (e, t) => {
|
|
119
111
|
let n = e;
|
|
120
112
|
for (let e of t.split(".")) {
|
|
121
113
|
if (typeof n != "object" || !n) return;
|
|
122
114
|
n = n[e];
|
|
123
115
|
}
|
|
124
116
|
return n;
|
|
125
|
-
},
|
|
117
|
+
}, Ke = (e, t, n) => {
|
|
126
118
|
let r = t.split("."), i = (e) => typeof e == "object" && e && !Array.isArray(e) ? { ...e } : {}, a = i(e), o = a;
|
|
127
119
|
for (let e = 0; e < r.length - 1; e += 1) o[r[e]] = i(o[r[e]]), o = o[r[e]];
|
|
128
120
|
return o[r[r.length - 1]] = n, a;
|
|
129
|
-
},
|
|
121
|
+
}, qe = (e, t) => {
|
|
130
122
|
let n = e.by ?? "id", r = e.identify ? e.identify(t) : typeof t[n] == "string" ? t[n] : typeof t.id == "string" ? t.id : void 0, i = r === void 0 ? [] : Array.isArray(r) ? r : [r];
|
|
131
123
|
return i.length === 0 ? null : new Set(i);
|
|
132
|
-
},
|
|
124
|
+
}, Je = (e, t, n) => {
|
|
133
125
|
let r = e.path, i = e.by ?? "id";
|
|
134
126
|
if (e.op === "insert") {
|
|
135
127
|
let a = e.shapeItem ?? e.shape, o = a ? {
|
|
@@ -142,11 +134,11 @@ var ve = /* @__PURE__ */ new Set(), ye = (e) => {
|
|
|
142
134
|
optimistic: !0
|
|
143
135
|
}, s = e.order ?? "append";
|
|
144
136
|
return (e) => {
|
|
145
|
-
let t = Array.isArray(
|
|
146
|
-
return
|
|
137
|
+
let t = Array.isArray(Ge(e, r)) ? Ge(e, r) : [];
|
|
138
|
+
return Ke(e ?? {}, r, s === "append" ? [...t, o] : [o, ...t]);
|
|
147
139
|
};
|
|
148
140
|
}
|
|
149
|
-
let a =
|
|
141
|
+
let a = qe(e, t);
|
|
150
142
|
if (a === null) return null;
|
|
151
143
|
if (e.op === "update") {
|
|
152
144
|
let n = e.shapeItem ?? e.shape, o = n ? (e) => ({
|
|
@@ -160,24 +152,24 @@ var ve = /* @__PURE__ */ new Set(), ye = (e) => {
|
|
|
160
152
|
optimistic: !0
|
|
161
153
|
});
|
|
162
154
|
return (e) => {
|
|
163
|
-
let t =
|
|
155
|
+
let t = Ge(e, r);
|
|
164
156
|
if (!Array.isArray(t)) {
|
|
165
157
|
if (typeof t != "object" || !t) return e;
|
|
166
158
|
let n = t;
|
|
167
|
-
return a.has(n[i]) ?
|
|
159
|
+
return a.has(n[i]) ? Ke(e, r, o(n)) : e;
|
|
168
160
|
}
|
|
169
|
-
return
|
|
161
|
+
return Ke(e, r, t.map((e) => a.has(e[i]) ? o(e) : e));
|
|
170
162
|
};
|
|
171
163
|
}
|
|
172
164
|
return (e) => {
|
|
173
|
-
let t = Array.isArray(
|
|
174
|
-
return
|
|
165
|
+
let t = Array.isArray(Ge(e, r)) ? Ge(e, r) : [];
|
|
166
|
+
return Ke(e, r, t.filter((e) => !a.has(e[i])));
|
|
175
167
|
};
|
|
176
|
-
},
|
|
168
|
+
}, Ye = (e, t, n) => {
|
|
177
169
|
if (e.op === "insert") return n;
|
|
178
170
|
let r = t.id;
|
|
179
171
|
return typeof r == "string" && r.length > 0 ? r : null;
|
|
180
|
-
},
|
|
172
|
+
}, Xe = (e, t, n, r) => {
|
|
181
173
|
let { anchorColumn: i, targetColumn: a } = e, o = new Set(n.map((e) => String(e)));
|
|
182
174
|
return (e) => {
|
|
183
175
|
if (!Array.isArray(e)) return e;
|
|
@@ -208,8 +200,8 @@ var ve = /* @__PURE__ */ new Set(), ye = (e) => {
|
|
|
208
200
|
}));
|
|
209
201
|
return c ? n : e;
|
|
210
202
|
};
|
|
211
|
-
},
|
|
212
|
-
if (e.path !== void 0) return
|
|
203
|
+
}, Ze = (e, t, n) => {
|
|
204
|
+
if (e.path !== void 0) return Je(e, t, n);
|
|
213
205
|
switch (e.op) {
|
|
214
206
|
case "insert": {
|
|
215
207
|
let r = e.shape ? {
|
|
@@ -227,7 +219,7 @@ var ve = /* @__PURE__ */ new Set(), ye = (e) => {
|
|
|
227
219
|
};
|
|
228
220
|
}
|
|
229
221
|
case "update": {
|
|
230
|
-
let n =
|
|
222
|
+
let n = qe(e, t);
|
|
231
223
|
if (n === null) return null;
|
|
232
224
|
let r = e.shape, i = r ? (e) => ({
|
|
233
225
|
...r(t, e),
|
|
@@ -250,7 +242,7 @@ var ve = /* @__PURE__ */ new Set(), ye = (e) => {
|
|
|
250
242
|
};
|
|
251
243
|
}
|
|
252
244
|
case "delete": {
|
|
253
|
-
let n =
|
|
245
|
+
let n = qe(e, t);
|
|
254
246
|
return n === null ? null : (e) => {
|
|
255
247
|
if (!Array.isArray(e)) {
|
|
256
248
|
let t = e;
|
|
@@ -260,7 +252,7 @@ var ve = /* @__PURE__ */ new Set(), ye = (e) => {
|
|
|
260
252
|
};
|
|
261
253
|
}
|
|
262
254
|
}
|
|
263
|
-
},
|
|
255
|
+
}, Qe = 5e3, $e = 15e3, et = 2e3, tt = () => globalThis.document?.visibilityState === "hidden", nt = class {
|
|
264
256
|
entries = /* @__PURE__ */ new Map();
|
|
265
257
|
successor;
|
|
266
258
|
inactiveTtlMs;
|
|
@@ -271,7 +263,7 @@ var ve = /* @__PURE__ */ new Set(), ye = (e) => {
|
|
|
271
263
|
apiName;
|
|
272
264
|
recoveryStuckMs;
|
|
273
265
|
constructor(e = {}) {
|
|
274
|
-
this.inactiveTtlMs = e.inactiveTtlMs ??
|
|
266
|
+
this.inactiveTtlMs = e.inactiveTtlMs ?? Qe, this.onChangeHook = e.onChange, this.errorBus = e.errorBus, this.mirror = e.mirror, this.mergeCell = e.mergeCell, this.apiName = e.apiName, this.recoveryStuckMs = e.recoveryStuckMs ?? $e;
|
|
275
267
|
}
|
|
276
268
|
diagnose(e, t, n = {}) {
|
|
277
269
|
this.apiName !== void 0 && U(this.apiName, e, {
|
|
@@ -293,10 +285,9 @@ var ve = /* @__PURE__ */ new Set(), ye = (e) => {
|
|
|
293
285
|
let r = W(e), i = typeof e[0] == "string" ? e[0] : void 0, a = this.entries.get(r);
|
|
294
286
|
a ||= this.createStub(r, i);
|
|
295
287
|
let o = {
|
|
296
|
-
id:
|
|
288
|
+
id: We(),
|
|
297
289
|
mutationId: n,
|
|
298
|
-
reducer: t
|
|
299
|
-
baseMovesAtApply: a.baseMoves
|
|
290
|
+
reducer: t
|
|
300
291
|
};
|
|
301
292
|
return a.state.patches.push(o), this.invalidate(a), this.successor?.update(e, t, n), {
|
|
302
293
|
patchId: o.id,
|
|
@@ -308,10 +299,9 @@ var ve = /* @__PURE__ */ new Set(), ye = (e) => {
|
|
|
308
299
|
for (let i of this.entries.values()) {
|
|
309
300
|
if (i.tag !== e) continue;
|
|
310
301
|
let a = {
|
|
311
|
-
id: `forTag-${++
|
|
302
|
+
id: `forTag-${++Ue}`,
|
|
312
303
|
mutationId: n,
|
|
313
|
-
reducer: t
|
|
314
|
-
baseMovesAtApply: i.baseMoves
|
|
304
|
+
reducer: t
|
|
315
305
|
};
|
|
316
306
|
i.state.patches.push(a), this.invalidate(i), r++;
|
|
317
307
|
}
|
|
@@ -327,16 +317,22 @@ var ve = /* @__PURE__ */ new Set(), ye = (e) => {
|
|
|
327
317
|
confirmByMutation(e) {
|
|
328
318
|
let t = !1;
|
|
329
319
|
for (let n of this.entries.values()) {
|
|
330
|
-
let r =
|
|
331
|
-
|
|
332
|
-
|
|
320
|
+
let r = !1;
|
|
321
|
+
for (let i of n.state.patches) i.mutationId === e && i.confirmed !== !0 && (i.confirmed = !0, r = !0, t = !0);
|
|
322
|
+
if (r && !n.reconciliationScheduled) {
|
|
323
|
+
n.reconciliationScheduled = !0;
|
|
324
|
+
let e = n.generation;
|
|
325
|
+
queueMicrotask(() => {
|
|
326
|
+
n.reconciliationScheduled = !1, this.entries.get(n.key) === n && n.fetch !== null && n.runtime !== null && n.generation === e && n.state.patches.some((e) => e.confirmed === !0) && this.reissue(n, n.runtime, !1);
|
|
327
|
+
});
|
|
328
|
+
}
|
|
333
329
|
}
|
|
334
|
-
t && setTimeout(() => this.resyncUnechoedMutation(e),
|
|
330
|
+
t && setTimeout(() => this.resyncUnechoedMutation(e), Be), this.successor?.confirmByMutation(e);
|
|
335
331
|
}
|
|
336
332
|
resyncUnechoedMutation(e) {
|
|
337
333
|
for (let t of this.entries.values()) {
|
|
338
334
|
if (!t.state.patches.some((t) => t.mutationId === e && t.confirmed === !0)) continue;
|
|
339
|
-
let n = t.tag ?? t.key, r = `optimistic patch for ${n} got no superseding server event within ${
|
|
335
|
+
let n = t.tag ?? t.key, r = `optimistic patch for ${n} got no superseding server event within ${Be}ms — the write is confirmed, so the preview is KEPT. Check the post-ACK primary subscription read and matching client/server versions.`;
|
|
340
336
|
this.errorBus?.emit({
|
|
341
337
|
source: "subscription",
|
|
342
338
|
tag: n,
|
|
@@ -351,7 +347,7 @@ var ve = /* @__PURE__ */ new Set(), ye = (e) => {
|
|
|
351
347
|
}
|
|
352
348
|
}
|
|
353
349
|
autoApply(e, t, n) {
|
|
354
|
-
let r = `optimistic-${n}-${++
|
|
350
|
+
let r = `optimistic-${n}-${++Ue}`;
|
|
355
351
|
for (let i of e) {
|
|
356
352
|
for (let e of this.entries.values()) {
|
|
357
353
|
if (!(Array.isArray(e.source) ? e.source.includes(i.table) : e.source === i.table)) continue;
|
|
@@ -365,13 +361,12 @@ var ve = /* @__PURE__ */ new Set(), ye = (e) => {
|
|
|
365
361
|
if (!n) continue;
|
|
366
362
|
}
|
|
367
363
|
if (e.computed && i.op === "insert" && i.path === void 0) continue;
|
|
368
|
-
let a =
|
|
364
|
+
let a = Ze(i, t, r);
|
|
369
365
|
if (a === null) continue;
|
|
370
366
|
let o = {
|
|
371
367
|
id: `${r}-${e.key}`,
|
|
372
368
|
mutationId: n,
|
|
373
|
-
reducer: a
|
|
374
|
-
baseMovesAtApply: e.baseMoves
|
|
369
|
+
reducer: a
|
|
375
370
|
};
|
|
376
371
|
e.state.patches.push(o), this.invalidate(e);
|
|
377
372
|
}
|
|
@@ -379,15 +374,14 @@ var ve = /* @__PURE__ */ new Set(), ye = (e) => {
|
|
|
379
374
|
if (e !== void 0) for (let [a, o] of Object.entries(e)) {
|
|
380
375
|
let e = t[a];
|
|
381
376
|
if (!Array.isArray(e)) continue;
|
|
382
|
-
let s =
|
|
377
|
+
let s = Ye(i, t, r);
|
|
383
378
|
if (s !== null) for (let t of this.entries.values()) {
|
|
384
379
|
if (!(Array.isArray(t.source) ? t.source.includes(o.junction) : t.source === o.junction) || t.computed) continue;
|
|
385
|
-
let i =
|
|
380
|
+
let i = Xe(o, s, e.map((e) => String(e)), `${r}-${a}`);
|
|
386
381
|
t.state.patches.push({
|
|
387
382
|
id: `${r}-${a}-${t.key}`,
|
|
388
383
|
mutationId: n,
|
|
389
|
-
reducer: i
|
|
390
|
-
baseMovesAtApply: t.baseMoves
|
|
384
|
+
reducer: i
|
|
391
385
|
}), this.invalidate(t);
|
|
392
386
|
}
|
|
393
387
|
}
|
|
@@ -439,23 +433,40 @@ var ve = /* @__PURE__ */ new Set(), ye = (e) => {
|
|
|
439
433
|
}
|
|
440
434
|
resumeTransportFailures(e) {
|
|
441
435
|
let t = 0;
|
|
442
|
-
for (let n of this.entries.values()) {
|
|
443
|
-
if (!n.resumeAfterTransportOpen) continue;
|
|
436
|
+
for (let n of this.entries.values()) if (n.resumeAfterTransportOpen) {
|
|
444
437
|
if (n.fiber !== null || n.fetch === null || n.subscribers.size === 0) {
|
|
445
438
|
this.diagnose("subscription.reissue-skipped", n, { reason: n.fiber === null ? n.fetch === null ? "missing-fetch" : "no-subscribers" : "fiber-running" });
|
|
446
439
|
continue;
|
|
447
440
|
}
|
|
448
|
-
n.recoveryAttempt += 1, n.recoveryPhase = "awaiting-delivery", n.lastReissueAt = Date.now(), n.recoveryBasePreserved = n.state.base !== void 0, this.diagnose("subscription.reissue-started", n, { basePreserved: n.recoveryBasePreserved }), this.reissue(n, e, !1);
|
|
449
|
-
let r = n.recoveryAttempt;
|
|
450
|
-
n.recoveryTimer !== null && clearTimeout(n.recoveryTimer), n.recoveryTimer = setTimeout(() => {
|
|
451
|
-
n.recoveryPhase === "awaiting-delivery" && n.recoveryAttempt === r && (n.recoveryPhase = "stuck", n.recoveryTimer = null, this.diagnose("subscription.recovery-stuck", n, {
|
|
452
|
-
waitedMs: this.recoveryStuckMs,
|
|
453
|
-
help: "run voltroDiagnostics.download() in the browser console"
|
|
454
|
-
}), console.warn(`[voltro] subscription recovery stalled for ${n.tag ?? "unknown"} after ${this.recoveryStuckMs}ms. Run voltroDiagnostics.download() in the browser console and attach the JSON support snapshot.`), this.invalidate(n));
|
|
455
|
-
}, this.recoveryStuckMs), t += 1;
|
|
441
|
+
n.recoveryAttempt += 1, n.recoveryPhase = "awaiting-delivery", n.lastReissueAt = Date.now(), n.recoveryBasePreserved = n.state.base !== void 0, this.diagnose("subscription.reissue-started", n, { basePreserved: n.recoveryBasePreserved }), this.reissue(n, e, !1), this.armRecoveryWatchdog(n), t += 1;
|
|
456
442
|
}
|
|
457
443
|
return t;
|
|
458
444
|
}
|
|
445
|
+
armRecoveryWatchdog(e) {
|
|
446
|
+
let t = e.recoveryAttempt;
|
|
447
|
+
e.recoveryTimer !== null && clearTimeout(e.recoveryTimer);
|
|
448
|
+
let n = 0, r = () => {
|
|
449
|
+
let i = Date.now();
|
|
450
|
+
e.recoveryTimer = setTimeout(() => {
|
|
451
|
+
if (e.recoveryPhase !== "awaiting-delivery" || e.recoveryAttempt !== t) return;
|
|
452
|
+
let a = Date.now() - i, o = Math.max(0, a - this.recoveryStuckMs), s = tt();
|
|
453
|
+
if (o > et || s) {
|
|
454
|
+
n += 1, n === 1 && this.diagnose("subscription.recovery-timer-late", e, {
|
|
455
|
+
waitedMs: a,
|
|
456
|
+
timerLateMs: o,
|
|
457
|
+
hidden: s
|
|
458
|
+
}), r();
|
|
459
|
+
return;
|
|
460
|
+
}
|
|
461
|
+
e.recoveryPhase = "stuck", e.recoveryTimer = null, this.diagnose("subscription.recovery-stuck", e, {
|
|
462
|
+
waitedMs: a,
|
|
463
|
+
deferrals: n,
|
|
464
|
+
help: "run voltroDiagnostics.download() in the browser console"
|
|
465
|
+
}), console.warn(`[voltro] subscription recovery stalled for ${e.tag ?? "unknown"} after ${a}ms. Run voltroDiagnostics.download() in the browser console and attach the JSON support snapshot.`), this.invalidate(e);
|
|
466
|
+
}, this.recoveryStuckMs);
|
|
467
|
+
};
|
|
468
|
+
r();
|
|
469
|
+
}
|
|
459
470
|
reissue(e, t, n = !0) {
|
|
460
471
|
if (!e.fetch) return;
|
|
461
472
|
e.fiber && t.runFork(ie.interrupt(e.fiber)), e.fiber = null;
|
|
@@ -478,7 +489,9 @@ var ve = /* @__PURE__ */ new Set(), ye = (e) => {
|
|
|
478
489
|
patches: r.state.patches.map((e) => (e.confirmed === !0 && n.add(e.mutationId), { ...e })),
|
|
479
490
|
cachedSnapshot: null
|
|
480
491
|
},
|
|
481
|
-
|
|
492
|
+
generation: 0,
|
|
493
|
+
reconciliationScheduled: !1,
|
|
494
|
+
primaryReads: r.primaryReads,
|
|
482
495
|
subscribers: /* @__PURE__ */ new Set(),
|
|
483
496
|
fiber: null,
|
|
484
497
|
resumeAfterTransportOpen: !1,
|
|
@@ -497,7 +510,7 @@ var ve = /* @__PURE__ */ new Set(), ye = (e) => {
|
|
|
497
510
|
};
|
|
498
511
|
this.entries.set(e.key, e), this.scheduleEviction(e), t += 1;
|
|
499
512
|
}
|
|
500
|
-
for (let e of n) setTimeout(() => this.resyncUnechoedMutation(e),
|
|
513
|
+
for (let e of n) setTimeout(() => this.resyncUnechoedMutation(e), Be);
|
|
501
514
|
return t;
|
|
502
515
|
}
|
|
503
516
|
create(e, t, n, r, i) {
|
|
@@ -505,7 +518,9 @@ var ve = /* @__PURE__ */ new Set(), ye = (e) => {
|
|
|
505
518
|
key: e,
|
|
506
519
|
tag: t,
|
|
507
520
|
state: this.freshState(),
|
|
508
|
-
|
|
521
|
+
generation: 0,
|
|
522
|
+
reconciliationScheduled: !1,
|
|
523
|
+
primaryReads: !1,
|
|
509
524
|
subscribers: /* @__PURE__ */ new Set(),
|
|
510
525
|
fiber: null,
|
|
511
526
|
resumeAfterTransportOpen: !1,
|
|
@@ -531,7 +546,9 @@ var ve = /* @__PURE__ */ new Set(), ye = (e) => {
|
|
|
531
546
|
key: e,
|
|
532
547
|
tag: t,
|
|
533
548
|
state: this.freshState(),
|
|
534
|
-
|
|
549
|
+
generation: 0,
|
|
550
|
+
reconciliationScheduled: !1,
|
|
551
|
+
primaryReads: !1,
|
|
535
552
|
subscribers: /* @__PURE__ */ new Set(),
|
|
536
553
|
fiber: null,
|
|
537
554
|
resumeAfterTransportOpen: !1,
|
|
@@ -561,39 +578,40 @@ var ve = /* @__PURE__ */ new Set(), ye = (e) => {
|
|
|
561
578
|
};
|
|
562
579
|
}
|
|
563
580
|
startFiber(e, t, n) {
|
|
564
|
-
let r = e.tag ?? e.key;
|
|
581
|
+
let r = e.tag ?? e.key, i = ++e.generation, a = new Set(e.state.patches.filter((e) => e.confirmed === !0).map((e) => e.id));
|
|
582
|
+
a.size > 0 && (e.primaryReads = !0);
|
|
583
|
+
let o = e.primaryReads ? `reconcile-${++He}` : void 0;
|
|
565
584
|
e.resumeAfterTransportOpen = !1;
|
|
566
|
-
let
|
|
585
|
+
let s = t(), c = R.unwrapScoped(N.currentSpan.pipe(N.catchAll(() => N.succeed(void 0)), N.map((t) => (t && (e.traceId = t.traceId, ye({
|
|
567
586
|
traceId: t.traceId,
|
|
568
587
|
spanId: t.spanId,
|
|
569
588
|
source: "subscription",
|
|
570
589
|
tag: r
|
|
571
|
-
})),
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
590
|
+
})), s)))).pipe(R.withSpan(`client.subscription.${r}`, { attributes: { "rpc.tag": r } })), l = o === void 0 && e.state.baseRevision >= 0 ? e.state.baseRevision : void 0, u = c.pipe(R.runForEach((t) => N.sync(() => {
|
|
591
|
+
if (e.generation === i && this.entries.get(e.key) === e) {
|
|
592
|
+
if (t._tag === "snapshot") e.state.base = t.data, e.state.baseRevision = t.revision, e.state.baseEmittedAt = void 0, e.state.baseError = void 0, t.computed === !0 && (e.computed = !0);
|
|
593
|
+
else if (t._tag === "error") e.state.baseError = M.fail(t.error), typeof t.revision == "number" && (e.state.baseRevision = t.revision);
|
|
594
|
+
else {
|
|
595
|
+
let n = e.state.base;
|
|
596
|
+
Array.isArray(n) && (e.state.base = de(n, t.patch, this.mergeCell === void 0 ? {} : { mergeCell: this.mergeCell })), e.state.baseRevision = t.revision, e.state.baseEmittedAt = t.emittedAt, e.state.baseError = void 0;
|
|
597
|
+
}
|
|
598
|
+
t._tag !== "error" && (e.lastDeliveryAt = Date.now(), e.recoveryPhase !== "steady" && (e.recoveryTimer !== null && clearTimeout(e.recoveryTimer), e.recoveryTimer = null, this.diagnose("subscription.first-delivery", e, {
|
|
599
|
+
delivery: t._tag,
|
|
600
|
+
basePreserved: e.recoveryBasePreserved
|
|
601
|
+
}), e.recoveryPhase = "steady", this.diagnose("subscription.health-cleared", e, { delivery: t._tag })), this.errorBus?.emitSuccess({
|
|
602
|
+
source: "subscription",
|
|
603
|
+
tag: e.tag ?? e.key
|
|
604
|
+
})), Ve(t, o) && (e.state.patches = e.state.patches.filter((e) => !a.has(e.id))), this.mirror !== void 0 && t._tag !== "error" && this.mirror.save(e.key, {
|
|
605
|
+
tag: e.tag,
|
|
606
|
+
data: e.state.base,
|
|
607
|
+
revision: e.state.baseRevision
|
|
608
|
+
}).catch(() => {}), this.invalidate(e);
|
|
578
609
|
}
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
}), e.recoveryPhase = "steady", this.diagnose("subscription.health-cleared", e, { delivery: t._tag })), this.errorBus?.emitSuccess({
|
|
583
|
-
source: "subscription",
|
|
584
|
-
tag: e.tag ?? e.key
|
|
585
|
-
}));
|
|
586
|
-
let r = Be(t, n, e.state.base);
|
|
587
|
-
r && (e.baseMoves += 1), r && e.state.patches.some((e) => e.confirmed === !0) && (e.state.patches = e.state.patches.filter((e) => e.confirmed !== !0)), this.mirror !== void 0 && t._tag !== "error" && this.mirror.save(e.key, {
|
|
588
|
-
tag: e.tag,
|
|
589
|
-
data: e.state.base,
|
|
590
|
-
revision: e.state.baseRevision
|
|
591
|
-
}).catch(() => {}), this.invalidate(e);
|
|
592
|
-
}))), c = n.runFork(o === void 0 ? s : s.pipe(N.locallyWith(ce.currentHeaders, (e) => se.set(e, "voltro-resume-from", String(o)))));
|
|
593
|
-
e.fiber = c, c.addObserver((t) => {
|
|
594
|
-
if (e.fiber === c && (e.fiber = null), P.isFailure(t) && !P.isInterrupted(t)) {
|
|
610
|
+
}))), d = n.runFork(o === void 0 ? l === void 0 ? u : u.pipe(N.locallyWith(z.currentHeaders, (e) => ce.set(e, "voltro-resume-from", String(l)))) : u.pipe(N.locallyWith(z.currentHeaders, (e) => ce.set(ce.remove(e, "voltro-resume-from"), "voltro-reconcile", o))));
|
|
611
|
+
e.fiber = d, d.addObserver((t) => {
|
|
612
|
+
if (e.generation === i && this.entries.get(e.key) === e && (e.fiber === d && (e.fiber = null), P.isFailure(t) && !P.isInterrupted(t))) {
|
|
595
613
|
e.state.baseRevision === -1 && (e.state.baseError = t.cause, this.invalidate(e));
|
|
596
|
-
let n = M.squash(t.cause), r = M.failureOption(t.cause), i = ae.isSome(r) ?
|
|
614
|
+
let n = M.squash(t.cause), r = M.failureOption(t.cause), i = ae.isSome(r) ? V(r.value, "handler") : "unknown";
|
|
597
615
|
i === "transport" && (e.recoveryTimer !== null && clearTimeout(e.recoveryTimer), e.recoveryTimer = null, e.resumeAfterTransportOpen = !0, e.recoveryPhase = "awaiting-protocol", e.lastTransportFailureAt = Date.now(), this.diagnose("subscription.transport-failed", e)), this.errorBus && this.errorBus.emit({
|
|
598
616
|
source: "subscription",
|
|
599
617
|
tag: e.tag ?? e.key,
|
|
@@ -612,7 +630,7 @@ var ve = /* @__PURE__ */ new Set(), ye = (e) => {
|
|
|
612
630
|
}
|
|
613
631
|
getSnapshot(e) {
|
|
614
632
|
let t = this.entries.get(e);
|
|
615
|
-
if (!t) return
|
|
633
|
+
if (!t) return ze;
|
|
616
634
|
if (t.state.cachedSnapshot !== null) return t.state.cachedSnapshot;
|
|
617
635
|
let n = t.state.base;
|
|
618
636
|
if (n !== void 0 && t.state.patches.length > 0) for (let e of t.state.patches) n = e.reducer(n);
|
|
@@ -635,26 +653,26 @@ var ve = /* @__PURE__ */ new Set(), ye = (e) => {
|
|
|
635
653
|
t && t.subscribers.size === 0 && (t.recoveryTimer !== null && clearTimeout(t.recoveryTimer), t.fiber && N.runFork(ie.interrupt(t.fiber)), this.entries.delete(e.key));
|
|
636
654
|
}, this.inactiveTtlMs);
|
|
637
655
|
}
|
|
638
|
-
},
|
|
656
|
+
}, rt = class extends nt {
|
|
639
657
|
subscribe(e, t, n, r, i = {}) {
|
|
640
658
|
return {
|
|
641
659
|
getSnapshot: () => this.peek(e),
|
|
642
660
|
unsubscribe: () => {}
|
|
643
661
|
};
|
|
644
662
|
}
|
|
645
|
-
},
|
|
646
|
-
for (let t of
|
|
663
|
+
}, it = /* @__PURE__ */ new Set(), at = (e) => {
|
|
664
|
+
for (let t of it) try {
|
|
647
665
|
t(e);
|
|
648
666
|
} catch {}
|
|
649
|
-
},
|
|
650
|
-
|
|
651
|
-
}),
|
|
652
|
-
|
|
667
|
+
}, ot = (e) => (it.add(e), () => {
|
|
668
|
+
it.delete(e);
|
|
669
|
+
}), st = (e, t) => {
|
|
670
|
+
at({
|
|
653
671
|
error: e,
|
|
654
672
|
source: "manual",
|
|
655
673
|
...t ? { context: t } : {}
|
|
656
674
|
});
|
|
657
|
-
},
|
|
675
|
+
}, ct = class {
|
|
658
676
|
#e = /* @__PURE__ */ new Set();
|
|
659
677
|
#t = /* @__PURE__ */ new Set();
|
|
660
678
|
on(e) {
|
|
@@ -666,7 +684,7 @@ var ve = /* @__PURE__ */ new Set(), ye = (e) => {
|
|
|
666
684
|
for (let t of this.#e) try {
|
|
667
685
|
t(e);
|
|
668
686
|
} catch {}
|
|
669
|
-
|
|
687
|
+
at({
|
|
670
688
|
error: e.error,
|
|
671
689
|
source: `rpc.${e.source}`,
|
|
672
690
|
context: {
|
|
@@ -688,32 +706,32 @@ var ve = /* @__PURE__ */ new Set(), ye = (e) => {
|
|
|
688
706
|
t(e);
|
|
689
707
|
} catch {}
|
|
690
708
|
}
|
|
691
|
-
},
|
|
692
|
-
let t = Math.trunc(
|
|
709
|
+
}, lt = (e, t, n, r) => Math.min(r, Math.max(n, e === void 0 || !Number.isFinite(e) ? t : e)), ut = (e) => {
|
|
710
|
+
let t = Math.trunc(lt(e?.maxMs, 5e3, 50, 6e4));
|
|
693
711
|
return {
|
|
694
|
-
initialMs: Math.trunc(
|
|
695
|
-
thenMs: Math.trunc(
|
|
696
|
-
factor:
|
|
712
|
+
initialMs: Math.trunc(lt(e?.initialMs, 0, 0, t)),
|
|
713
|
+
thenMs: Math.trunc(lt(e?.thenMs, 500, 50, t)),
|
|
714
|
+
factor: lt(e?.factor, 1.5, 1, 10),
|
|
697
715
|
maxMs: t
|
|
698
716
|
};
|
|
699
|
-
},
|
|
717
|
+
}, dt = (e, t) => t <= 1 ? e.initialMs : Math.min(e.maxMs, e.thenMs * e.factor ** (t - 2)), ft = (e, t) => {
|
|
700
718
|
let n = 0;
|
|
701
719
|
return {
|
|
702
720
|
reset: () => {
|
|
703
721
|
n = 0;
|
|
704
722
|
},
|
|
705
723
|
schedule: L.forever.pipe(L.addDelayEffect(() => N.sync(() => {
|
|
706
|
-
let r =
|
|
724
|
+
let r = dt(e, ++n);
|
|
707
725
|
return t(n, r), r;
|
|
708
726
|
})))
|
|
709
727
|
};
|
|
710
|
-
},
|
|
711
|
-
graceMs:
|
|
712
|
-
retry:
|
|
713
|
-
maxPendingMutations:
|
|
714
|
-
replayWindowMs:
|
|
728
|
+
}, pt = (e, t, n, r) => e === void 0 || !Number.isFinite(e) ? t : Math.min(r, Math.max(n, Math.trunc(e))), mt = (e) => ({
|
|
729
|
+
graceMs: pt(e?.graceMs, 1500, 0, 3e4),
|
|
730
|
+
retry: ut(e?.retry),
|
|
731
|
+
maxPendingMutations: pt(e?.maxPendingMutations, 32, 0, 256),
|
|
732
|
+
replayWindowMs: pt(e?.replayWindowMs, 1e4, 250, 6e4),
|
|
715
733
|
capabilitiesUrl: e?.capabilitiesUrl
|
|
716
|
-
}),
|
|
734
|
+
}), ht = class {
|
|
717
735
|
#e;
|
|
718
736
|
#t;
|
|
719
737
|
#n;
|
|
@@ -736,7 +754,7 @@ var ve = /* @__PURE__ */ new Set(), ye = (e) => {
|
|
|
736
754
|
#y = !1;
|
|
737
755
|
#b;
|
|
738
756
|
constructor(e, t, n) {
|
|
739
|
-
this.#e = e, this.#t =
|
|
757
|
+
this.#e = e, this.#t = mt(t), this.#n = {
|
|
740
758
|
now: n?.now ?? Date.now,
|
|
741
759
|
setTimeout: n?.setTimeout ?? ((e, t) => setTimeout(e, t)),
|
|
742
760
|
clearTimeout: n?.clearTimeout ?? ((e) => clearTimeout(e))
|
|
@@ -884,51 +902,77 @@ var ve = /* @__PURE__ */ new Set(), ye = (e) => {
|
|
|
884
902
|
for (let e of this.#o) e(!1);
|
|
885
903
|
this.#o.clear(), this.#r.clear(), this.#i.clear();
|
|
886
904
|
}
|
|
887
|
-
},
|
|
888
|
-
let r =
|
|
905
|
+
}, gt = /* @__PURE__ */ new WeakMap(), _t = (e, t, n) => {
|
|
906
|
+
let r = gt.get(e);
|
|
889
907
|
if (r !== void 0) return r;
|
|
890
|
-
let i = new
|
|
891
|
-
return e.on((e) => i.observeError(e)), typeof e.onSuccess == "function" && e.onSuccess((e) => i.observeSuccess(e)),
|
|
892
|
-
},
|
|
908
|
+
let i = new ht(t, n);
|
|
909
|
+
return e.on((e) => i.observeError(e)), typeof e.onSuccess == "function" && e.onSuccess((e) => i.observeSuccess(e)), gt.set(e, i), i;
|
|
910
|
+
}, vt = w(null), yt = () => {
|
|
893
911
|
throw Error("Voltro: rpc / cache calls are not invokable on a not-yet-resolved api — either during SSR, or in the client boot window before the api client resolves");
|
|
894
|
-
},
|
|
895
|
-
get: (e, t) =>
|
|
912
|
+
}, bt = new Proxy(() => yt(), {
|
|
913
|
+
get: (e, t) => bt,
|
|
896
914
|
has: () => !0,
|
|
897
|
-
apply: () =>
|
|
898
|
-
}),
|
|
899
|
-
|
|
900
|
-
},
|
|
901
|
-
|
|
902
|
-
},
|
|
915
|
+
apply: () => yt()
|
|
916
|
+
}), xt = Symbol.for("@voltro/client/ssrDescriptors"), St = globalThis, Ct = St[xt] ?? (St[xt] = { byApi: /* @__PURE__ */ new Map() }), wt = (e, t) => {
|
|
917
|
+
Ct.byApi.set(e, t);
|
|
918
|
+
}, Tt = (e) => Ct.byApi.get(e), Et = () => {
|
|
919
|
+
Ct.byApi.clear();
|
|
920
|
+
}, Dt = {
|
|
903
921
|
runtime: { runPromiseExit: () => Promise.resolve(P.die(/* @__PURE__ */ Error("Voltro: mutations are not invokable during SSR"))) },
|
|
904
|
-
cache: new
|
|
905
|
-
client:
|
|
922
|
+
cache: new rt(),
|
|
923
|
+
client: bt,
|
|
906
924
|
descriptors: {},
|
|
907
925
|
inspectBaseUrl: "",
|
|
908
|
-
errorBus: new
|
|
909
|
-
recovery: new
|
|
910
|
-
},
|
|
926
|
+
errorBus: new ct(),
|
|
927
|
+
recovery: new ht("ssr")
|
|
928
|
+
}, Ot = {
|
|
911
929
|
get: (e) => {
|
|
912
|
-
let t =
|
|
913
|
-
return t === void 0 ?
|
|
914
|
-
...
|
|
930
|
+
let t = Tt(e);
|
|
931
|
+
return t === void 0 ? Dt : {
|
|
932
|
+
...Dt,
|
|
915
933
|
descriptors: t
|
|
916
934
|
};
|
|
917
935
|
},
|
|
918
936
|
names: []
|
|
919
|
-
},
|
|
920
|
-
|
|
921
|
-
},
|
|
922
|
-
let e = ee(
|
|
923
|
-
return e ? (
|
|
924
|
-
G = null, !(
|
|
925
|
-
}, 0)),
|
|
937
|
+
}, kt = !1, At = !1, G = null, jt = () => {
|
|
938
|
+
kt = !1, At = !1, G !== null && (clearTimeout(G), G = null);
|
|
939
|
+
}, Mt = () => {
|
|
940
|
+
let e = ee(vt);
|
|
941
|
+
return e ? (At || (At = !0, G !== null && (clearTimeout(G), G = null)), e) : (typeof window < "u" && !kt && !At && G === null && process.env.NODE_ENV !== "production" && (G = setTimeout(() => {
|
|
942
|
+
G = null, !(kt || At) && (kt = !0, console.warn("useFrameworkRuntimes: no <FrameworkRuntimesProvider> in the tree — returning a loading baseline (subscriptions read `undefined`, mutations are no-ops). If this is not an intentional lazy/conditional mount, mount your app via @voltro/web mount() or wrap the subtree in <VoltroRuntimeProvider>."));
|
|
943
|
+
}, 0)), Ot);
|
|
926
944
|
}, K = (e) => {
|
|
927
|
-
let t =
|
|
945
|
+
let t = Mt(), n = t.demand;
|
|
928
946
|
return D(() => {
|
|
929
947
|
n?.(e);
|
|
930
948
|
}, [n, e]), t.get(e);
|
|
931
|
-
},
|
|
949
|
+
}, Nt = (e) => typeof e.runtime?.runFork != "function", Pt = {
|
|
950
|
+
channel: "timer",
|
|
951
|
+
yield: (e) => {
|
|
952
|
+
setTimeout(e, 0);
|
|
953
|
+
}
|
|
954
|
+
}, Ft = (e) => {
|
|
955
|
+
let t = [];
|
|
956
|
+
return e.port1.onmessage = () => {
|
|
957
|
+
t.shift()?.();
|
|
958
|
+
}, e.port1.unref?.(), {
|
|
959
|
+
channel: "message-channel",
|
|
960
|
+
yield: (n) => {
|
|
961
|
+
t.push(n), e.port2.postMessage(null);
|
|
962
|
+
}
|
|
963
|
+
};
|
|
964
|
+
}, It = () => typeof window < "u" && typeof MessageChannel == "function" ? Ft(new MessageChannel()) : Pt, Lt = 2048, Rt = (e = It(), t = Lt) => {
|
|
965
|
+
let n = oe.SchedulerRunner.cached((n, r) => {
|
|
966
|
+
n >= t ? e.yield(() => r(0)) : Promise.resolve().then(() => r(n + 1));
|
|
967
|
+
});
|
|
968
|
+
return {
|
|
969
|
+
yieldChannel: e.channel,
|
|
970
|
+
shouldYield: oe.defaultShouldYield,
|
|
971
|
+
scheduleTask: (e, t, r) => {
|
|
972
|
+
n(r).scheduleTask(e, t);
|
|
973
|
+
}
|
|
974
|
+
};
|
|
975
|
+
}, zt = (e, t, n) => {
|
|
932
976
|
try {
|
|
933
977
|
let r = typeof globalThis.location == "object" ? globalThis.location.href : void 0, i = new URL(e, r);
|
|
934
978
|
if (i.protocol === "wss:" ? i.protocol = "https:" : i.protocol === "ws:" && (i.protocol = "http:"), n !== void 0) return new URL(n, i).toString();
|
|
@@ -942,8 +986,8 @@ var ve = /* @__PURE__ */ new Set(), ye = (e) => {
|
|
|
942
986
|
} catch {
|
|
943
987
|
return;
|
|
944
988
|
}
|
|
945
|
-
},
|
|
946
|
-
let a =
|
|
989
|
+
}, Bt = async (e, t, n = fetch, r = 1500, i) => {
|
|
990
|
+
let a = zt(e, t, i);
|
|
947
991
|
if (a === void 0) return;
|
|
948
992
|
let o = new AbortController(), s = setTimeout(() => o.abort(), r);
|
|
949
993
|
try {
|
|
@@ -964,7 +1008,7 @@ var ve = /* @__PURE__ */ new Set(), ye = (e) => {
|
|
|
964
1008
|
} finally {
|
|
965
1009
|
clearTimeout(s);
|
|
966
1010
|
}
|
|
967
|
-
},
|
|
1011
|
+
}, Vt = class {
|
|
968
1012
|
#e;
|
|
969
1013
|
#t;
|
|
970
1014
|
#n;
|
|
@@ -993,9 +1037,9 @@ var ve = /* @__PURE__ */ new Set(), ye = (e) => {
|
|
|
993
1037
|
e();
|
|
994
1038
|
} catch {}
|
|
995
1039
|
}
|
|
996
|
-
},
|
|
997
|
-
|
|
998
|
-
},
|
|
1040
|
+
}, Ht = /* @__PURE__ */ new WeakMap(), Ut = (e, t) => {
|
|
1041
|
+
Ht.set(e, t);
|
|
1042
|
+
}, Wt = (e) => Ht.get(e), Gt = (e, t, n = new Vt()) => B.Socket.of({
|
|
999
1043
|
...e,
|
|
1000
1044
|
runRaw: (r, i) => N.acquireUseRelease(N.sync(() => n.begin()), (n) => e.runRaw(r, {
|
|
1001
1045
|
...i,
|
|
@@ -1003,10 +1047,10 @@ var ve = /* @__PURE__ */ new Set(), ye = (e) => {
|
|
|
1003
1047
|
n.open() !== void 0 && t();
|
|
1004
1048
|
}))
|
|
1005
1049
|
}), (e) => N.sync(e.close))
|
|
1006
|
-
}),
|
|
1050
|
+
}), Kt = async (e) => {
|
|
1007
1051
|
let { name: t, wsUrl: n, group: r, headers: i, webSocketConstructor: a } = e, o = e.generation ?? 0;
|
|
1008
1052
|
U(t, "runtime.build-started", { generation: o });
|
|
1009
|
-
let s = e.errorBus ?? new
|
|
1053
|
+
let s = e.errorBus ?? new ct(), c = e.recovery ?? _t(s, t), l = ft(c.options.retry, (e, n) => {
|
|
1010
1054
|
U(t, "socket.retry-scheduled", {
|
|
1011
1055
|
generation: o,
|
|
1012
1056
|
attempt: e,
|
|
@@ -1014,30 +1058,33 @@ var ve = /* @__PURE__ */ new Set(), ye = (e) => {
|
|
|
1014
1058
|
owner: "socket"
|
|
1015
1059
|
});
|
|
1016
1060
|
});
|
|
1017
|
-
|
|
1061
|
+
Bt(n, t, fetch, 1500, c.options.capabilitiesUrl).then((e) => {
|
|
1018
1062
|
c.setMutationReplaySupported(e?.mutationReplay === !0, o), U(t, "runtime.capabilities", {
|
|
1019
1063
|
mutationReplay: e?.mutationReplay === !0,
|
|
1020
1064
|
discovered: e !== void 0
|
|
1021
1065
|
});
|
|
1022
1066
|
});
|
|
1023
|
-
let u = new
|
|
1067
|
+
let u = new nt({
|
|
1024
1068
|
errorBus: s,
|
|
1025
1069
|
apiName: t
|
|
1026
|
-
}), d = new
|
|
1070
|
+
}), d = new Vt(), f;
|
|
1027
1071
|
class p extends ne.Tag(`@voltro/client/AppClient/${t}`)() {}
|
|
1028
|
-
let m = F.succeed(
|
|
1072
|
+
let m = F.succeed(B.WebSocketConstructor, a), h = B.layerWebSocket(n).pipe(F.provide(m)), g = F.effect(B.Socket, N.map(B.Socket, (e) => Gt(e, () => {
|
|
1029
1073
|
l.reset();
|
|
1030
1074
|
let e = 0;
|
|
1031
1075
|
f !== void 0 && (e = u.resumeTransportFailures(f)), U(t, "protocol.ready", {
|
|
1032
1076
|
generation: o,
|
|
1033
1077
|
resumed: e
|
|
1034
1078
|
}), c.protocolReady();
|
|
1035
|
-
}, d))).pipe(F.provide(h)), _ =
|
|
1036
|
-
f =
|
|
1079
|
+
}, d))).pipe(F.provide(h)), _ = z.layerProtocolSocket({ retrySchedule: l.schedule }).pipe(F.provide(ue.layerJson), F.provide(g)), v = typeof i == "function" ? await i() : i, y = F.scoped(p, z.make(r)).pipe(F.provide(_)), b = v ? F.locallyScoped(z.currentHeaders, ce.fromInput(v)) : F.empty, x = Rt(), S = I.make(F.merge(y, b).pipe(F.provide(F.setScheduler(x))));
|
|
1080
|
+
f = S, Ut(f, d);
|
|
1037
1081
|
try {
|
|
1038
|
-
let e = await
|
|
1039
|
-
return U(t, "runtime.resolved", {
|
|
1040
|
-
|
|
1082
|
+
let e = await S.runPromise(p);
|
|
1083
|
+
return U(t, "runtime.resolved", {
|
|
1084
|
+
generation: o,
|
|
1085
|
+
scheduler: x.yieldChannel
|
|
1086
|
+
}), {
|
|
1087
|
+
runtime: S,
|
|
1041
1088
|
client: e,
|
|
1042
1089
|
cache: u,
|
|
1043
1090
|
errorBus: s,
|
|
@@ -1047,9 +1094,9 @@ var ve = /* @__PURE__ */ new Set(), ye = (e) => {
|
|
|
1047
1094
|
throw U(t, "runtime.failed", {
|
|
1048
1095
|
generation: o,
|
|
1049
1096
|
errorName: e instanceof Error ? e.name : typeof e
|
|
1050
|
-
}),
|
|
1097
|
+
}), S.dispose(), e;
|
|
1051
1098
|
}
|
|
1052
|
-
},
|
|
1099
|
+
}, qt = (e, t, n) => ({
|
|
1053
1100
|
resolved: null,
|
|
1054
1101
|
retryToken: 0,
|
|
1055
1102
|
failureCount: 0,
|
|
@@ -1063,17 +1110,17 @@ var ve = /* @__PURE__ */ new Set(), ye = (e) => {
|
|
|
1063
1110
|
stopRecoveryError: e.on((e) => t.observeError(e)),
|
|
1064
1111
|
stopRecoverySuccess: e.onSuccess((e) => t.observeSuccess(e)),
|
|
1065
1112
|
ownsRecovery: n
|
|
1066
|
-
}),
|
|
1113
|
+
}), Jt = (e) => {
|
|
1067
1114
|
e.wedgeStop !== null && (e.wedgeStop(), e.wedgeStop = null);
|
|
1068
|
-
},
|
|
1115
|
+
}, Yt = (e) => {
|
|
1069
1116
|
e.cache.destroy(e.runtime), e.runtime.dispose();
|
|
1070
|
-
},
|
|
1117
|
+
}, Xt = (e) => {
|
|
1071
1118
|
let t = e.apis, n = e.buildClient, r = e.onChange, i = e.stableWindowMs ?? 5e3, a = e.scheduler?.setTimeout ?? ((e, t) => setTimeout(e, t)), o = e.scheduler?.clearTimeout ?? ((e) => {
|
|
1072
1119
|
clearTimeout(e);
|
|
1073
1120
|
}), s = e.scheduler?.queueMicrotask ?? queueMicrotask, c = e.onReconnecting, l = e.wedgeBackstop, u = /* @__PURE__ */ new Map();
|
|
1074
1121
|
for (let n of t) {
|
|
1075
|
-
let t = e.errorBusFor?.(n.name) ?? new
|
|
1076
|
-
u.set(n.name,
|
|
1122
|
+
let t = e.errorBusFor?.(n.name) ?? new ct(), r = e.recoveryFor?.(n.name, n.recovery), i = r ?? new ht(n.name, n.recovery);
|
|
1123
|
+
u.set(n.name, qt(t, i, r === void 0));
|
|
1077
1124
|
}
|
|
1078
1125
|
let d = !1, f = /* @__PURE__ */ new Set(), p = (e, t) => {
|
|
1079
1126
|
let n = a(() => {
|
|
@@ -1092,7 +1139,7 @@ var ve = /* @__PURE__ */ new Set(), ye = (e) => {
|
|
|
1092
1139
|
let n = u.get(t.name);
|
|
1093
1140
|
if (!n) return;
|
|
1094
1141
|
h(t, n);
|
|
1095
|
-
let r = e.retryDelayMs?.(n.failureCount) ??
|
|
1142
|
+
let r = e.retryDelayMs?.(n.failureCount) ?? dt(n.recovery.options.retry, n.failureCount);
|
|
1096
1143
|
U(t.name, "socket.retry-scheduled", {
|
|
1097
1144
|
generation: n.generation,
|
|
1098
1145
|
attempt: n.failureCount,
|
|
@@ -1109,7 +1156,7 @@ var ve = /* @__PURE__ */ new Set(), ye = (e) => {
|
|
|
1109
1156
|
if (!t) return;
|
|
1110
1157
|
let r = t.generation, a = () => {
|
|
1111
1158
|
if (d || t.generation !== r) return;
|
|
1112
|
-
t.everOpened = !0,
|
|
1159
|
+
t.everOpened = !0, Jt(t), t.reconnectStatusDispose &&= (t.reconnectStatusDispose(), null), t.retryToken++;
|
|
1113
1160
|
let e = t.failureCount;
|
|
1114
1161
|
p(() => {
|
|
1115
1162
|
d || t.failureCount === e && (t.failureCount = 0);
|
|
@@ -1120,7 +1167,7 @@ var ve = /* @__PURE__ */ new Set(), ye = (e) => {
|
|
|
1120
1167
|
try {
|
|
1121
1168
|
let i = await n(e, r, a, o, t.errorBus, t.recovery);
|
|
1122
1169
|
if (d || t.generation !== r) {
|
|
1123
|
-
|
|
1170
|
+
Yt(i);
|
|
1124
1171
|
return;
|
|
1125
1172
|
}
|
|
1126
1173
|
let s = t.resolved, c = t.subjectMayHaveChanged, l = s && !c ? i.cache.seedStaleFrom(s.cache) : 0;
|
|
@@ -1129,7 +1176,7 @@ var ve = /* @__PURE__ */ new Set(), ye = (e) => {
|
|
|
1129
1176
|
replaced: s !== null,
|
|
1130
1177
|
seeded: l,
|
|
1131
1178
|
subjectMayHaveChanged: c
|
|
1132
|
-
}), m(), s &&
|
|
1179
|
+
}), m(), s && Yt(s);
|
|
1133
1180
|
} catch {
|
|
1134
1181
|
if (d || t.generation !== r) return;
|
|
1135
1182
|
g(e);
|
|
@@ -1137,7 +1184,7 @@ var ve = /* @__PURE__ */ new Set(), ye = (e) => {
|
|
|
1137
1184
|
}, v = (e) => {
|
|
1138
1185
|
if (!d) for (let n of t) {
|
|
1139
1186
|
let t = u.get(n.name);
|
|
1140
|
-
t && (e && (t.subjectMayHaveChanged = !0), t.retryToken += 1, t.generation += 1, e && t.recovery.resetForSubjectChange(t.generation), t.failureCount = 0,
|
|
1187
|
+
t && (e && (t.subjectMayHaveChanged = !0), t.retryToken += 1, t.generation += 1, e && t.recovery.resetForSubjectChange(t.generation), t.failureCount = 0, Jt(t), _(n));
|
|
1141
1188
|
}
|
|
1142
1189
|
};
|
|
1143
1190
|
return t.length === 0 ? (r(/* @__PURE__ */ new Map(), !0), {
|
|
@@ -1154,7 +1201,7 @@ var ve = /* @__PURE__ */ new Set(), ye = (e) => {
|
|
|
1154
1201
|
d = !0;
|
|
1155
1202
|
for (let e of f) o(e);
|
|
1156
1203
|
f.clear();
|
|
1157
|
-
for (let [, e] of u) e.resolved &&
|
|
1204
|
+
for (let [, e] of u) e.resolved && Yt(e.resolved), e.reconnectStatusDispose && e.reconnectStatusDispose(), Jt(e), e.stopRecoveryError(), e.stopRecoverySuccess(), e.ownsRecovery && e.recovery.dispose();
|
|
1158
1205
|
for (let e of t) U(e.name, "runtime.disposed");
|
|
1159
1206
|
u.clear();
|
|
1160
1207
|
}
|
|
@@ -1166,7 +1213,7 @@ var ve = /* @__PURE__ */ new Set(), ye = (e) => {
|
|
|
1166
1213
|
v(!1);
|
|
1167
1214
|
}
|
|
1168
1215
|
});
|
|
1169
|
-
},
|
|
1216
|
+
}, Zt = ({ apis: e, children: t, demand: n }) => {
|
|
1170
1217
|
let r = O(() => ({
|
|
1171
1218
|
get: (t) => {
|
|
1172
1219
|
let n = e.get(t);
|
|
@@ -1179,45 +1226,45 @@ var ve = /* @__PURE__ */ new Set(), ye = (e) => {
|
|
|
1179
1226
|
names: Array.from(e.keys()),
|
|
1180
1227
|
...n === void 0 ? {} : { demand: n }
|
|
1181
1228
|
}), [e]);
|
|
1182
|
-
return /* @__PURE__ */ me(
|
|
1229
|
+
return /* @__PURE__ */ me(vt.Provider, {
|
|
1183
1230
|
value: r,
|
|
1184
1231
|
children: t
|
|
1185
1232
|
});
|
|
1186
|
-
},
|
|
1187
|
-
let e = globalThis, t = e[
|
|
1233
|
+
}, Qt = Symbol.for("@voltro/client/storeStorageProvider"), $t = () => {
|
|
1234
|
+
let e = globalThis, t = e[Qt];
|
|
1188
1235
|
if (t !== void 0) return t;
|
|
1189
1236
|
let n = {
|
|
1190
1237
|
provider: void 0,
|
|
1191
1238
|
used: !1
|
|
1192
1239
|
};
|
|
1193
|
-
return e[
|
|
1194
|
-
},
|
|
1240
|
+
return e[Qt] = n, n;
|
|
1241
|
+
}, en = (e) => {
|
|
1195
1242
|
if (typeof window > "u") return null;
|
|
1196
1243
|
try {
|
|
1197
1244
|
return (e === "session" ? window.sessionStorage : window.localStorage) ?? null;
|
|
1198
1245
|
} catch {
|
|
1199
1246
|
return null;
|
|
1200
1247
|
}
|
|
1201
|
-
},
|
|
1202
|
-
let t =
|
|
1248
|
+
}, tn = (e) => {
|
|
1249
|
+
let t = $t();
|
|
1203
1250
|
t.used && e !== null && console.warn("[voltro] setStoreStorage() was called after a persisted store had already read. That store booted against the previous backing store and will not be re-read. Install storage before the first render — on React Native, after awaiting hydrate()."), t.provider = e ?? void 0;
|
|
1204
|
-
},
|
|
1205
|
-
let t =
|
|
1206
|
-
return t.used = !0, (t.provider ??
|
|
1207
|
-
},
|
|
1208
|
-
let e =
|
|
1251
|
+
}, nn = (e) => {
|
|
1252
|
+
let t = $t();
|
|
1253
|
+
return t.used = !0, (t.provider ?? en)(e);
|
|
1254
|
+
}, rn = () => {
|
|
1255
|
+
let e = $t();
|
|
1209
1256
|
e.provider = void 0, e.used = !1;
|
|
1210
|
-
},
|
|
1257
|
+
}, an = (e, t) => {
|
|
1211
1258
|
if (Object.is(e, t)) return !0;
|
|
1212
1259
|
if (typeof e != "object" || typeof t != "object" || e === null || t === null || Array.isArray(e) !== Array.isArray(t)) return !1;
|
|
1213
1260
|
let n = Object.keys(e), r = Object.keys(t);
|
|
1214
1261
|
if (n.length !== r.length) return !1;
|
|
1215
1262
|
for (let r of n) if (!Object.prototype.hasOwnProperty.call(t, r) || !Object.is(e[r], t[r])) return !1;
|
|
1216
1263
|
return !0;
|
|
1217
|
-
},
|
|
1218
|
-
|
|
1219
|
-
},
|
|
1220
|
-
let r =
|
|
1264
|
+
}, on = 50, sn = /* @__PURE__ */ new Set(), cn = (e, t) => {
|
|
1265
|
+
sn.has(e) || (sn.add(e), console.warn(t));
|
|
1266
|
+
}, ln = "\0global", un = null, dn = (e, t, n) => {
|
|
1267
|
+
let r = un?.() ?? null;
|
|
1221
1268
|
if (r === null) return n;
|
|
1222
1269
|
let i = n;
|
|
1223
1270
|
for (let n of r.seeds) n.store === e && n.key === t && (i = {
|
|
@@ -1225,9 +1272,9 @@ var ve = /* @__PURE__ */ new Set(), ye = (e) => {
|
|
|
1225
1272
|
...n.value
|
|
1226
1273
|
});
|
|
1227
1274
|
return i;
|
|
1228
|
-
},
|
|
1275
|
+
}, fn = (e, t) => {
|
|
1229
1276
|
let n = e(), r = /* @__PURE__ */ new Set(), i = 0, a = 0, o, s, c = () => {
|
|
1230
|
-
if (i >=
|
|
1277
|
+
if (i >= on) throw i = 0, Error(`defineStore: notification depth exceeded ${on} — a subscriber writes a NEW value every time it is notified, so the store can never settle. Look for a listener calling set() with something derived from the current state without converging.`);
|
|
1231
1278
|
i += 1;
|
|
1232
1279
|
try {
|
|
1233
1280
|
for (let e of [...r]) e();
|
|
@@ -1248,20 +1295,20 @@ var ve = /* @__PURE__ */ new Set(), ye = (e) => {
|
|
|
1248
1295
|
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}', () => { … })\`.`);
|
|
1249
1296
|
if (--a, a > 0) return;
|
|
1250
1297
|
let l = o, u = s;
|
|
1251
|
-
o = void 0, s = void 0, !
|
|
1298
|
+
o = void 0, s = void 0, !an(l, n) && (t(l, n, u), c());
|
|
1252
1299
|
},
|
|
1253
1300
|
set: (e, r) => {
|
|
1254
1301
|
let i = typeof e == "function" ? e(n) : {
|
|
1255
1302
|
...n,
|
|
1256
1303
|
...e
|
|
1257
1304
|
};
|
|
1258
|
-
if (
|
|
1305
|
+
if (an(i, n)) return;
|
|
1259
1306
|
let o = n;
|
|
1260
1307
|
n = i, !(a > 0) && (t(o, i, r), c());
|
|
1261
1308
|
},
|
|
1262
1309
|
reset: () => {
|
|
1263
1310
|
let r = e();
|
|
1264
|
-
if (
|
|
1311
|
+
if (an(r, n)) return;
|
|
1265
1312
|
let i = n;
|
|
1266
1313
|
n = r, !(a > 0) && (t(i, r, "reset"), c());
|
|
1267
1314
|
},
|
|
@@ -1269,51 +1316,51 @@ var ve = /* @__PURE__ */ new Set(), ye = (e) => {
|
|
|
1269
1316
|
r.delete(e);
|
|
1270
1317
|
})
|
|
1271
1318
|
};
|
|
1272
|
-
},
|
|
1273
|
-
|
|
1274
|
-
}),
|
|
1275
|
-
|
|
1276
|
-
},
|
|
1277
|
-
let n =
|
|
1319
|
+
}, pn = 200, mn = [], hn = /* @__PURE__ */ new Set(), gn = [], _n = () => gn, vn = (e) => (hn.add(e), () => {
|
|
1320
|
+
hn.delete(e);
|
|
1321
|
+
}), yn = () => {
|
|
1322
|
+
mn.length = 0, gn = [];
|
|
1323
|
+
}, bn = (e, t) => {
|
|
1324
|
+
let n = mn[e];
|
|
1278
1325
|
if (n === void 0) return !1;
|
|
1279
|
-
let r =
|
|
1326
|
+
let r = wn.get(n.store);
|
|
1280
1327
|
if (r === void 0) return !1;
|
|
1281
1328
|
let i = t === "before" ? n.prev : n.next;
|
|
1282
|
-
|
|
1329
|
+
Sn = !0;
|
|
1283
1330
|
try {
|
|
1284
1331
|
r.set(() => i, n.key, `travel:${t}`);
|
|
1285
1332
|
} finally {
|
|
1286
|
-
|
|
1333
|
+
Sn = !1;
|
|
1287
1334
|
}
|
|
1288
1335
|
return !0;
|
|
1289
|
-
},
|
|
1290
|
-
|
|
1291
|
-
for (let e of [...
|
|
1292
|
-
},
|
|
1293
|
-
|
|
1294
|
-
})),
|
|
1295
|
-
function
|
|
1336
|
+
}, xn = !1, Sn = !1, Cn = (e) => {
|
|
1337
|
+
mn.push(e), mn.length > pn && mn.shift(), gn = [...mn];
|
|
1338
|
+
for (let e of [...hn]) e();
|
|
1339
|
+
}, wn = /* @__PURE__ */ new Map(), Tn = /* @__PURE__ */ new Map(), En = 0, Dn = !1, On = /* @__PURE__ */ new Map(), kn = () => (Dn || (Dn = !0, queueMicrotask(() => {
|
|
1340
|
+
En += 1, Dn = !1;
|
|
1341
|
+
})), En), An = jn(((/* @__PURE__ */ Error()).stack ?? "").split("\n")[1] ?? "") ?? "";
|
|
1342
|
+
function jn(e) {
|
|
1296
1343
|
let t = e.trim().replace(/^at\s+/, ""), n = /\(([^()]+)\)\s*$/.exec(t)?.[1] ?? t;
|
|
1297
1344
|
return n.length > 0 ? n : void 0;
|
|
1298
1345
|
}
|
|
1299
|
-
var
|
|
1346
|
+
var Mn = () => {
|
|
1300
1347
|
let e = (/* @__PURE__ */ Error()).stack;
|
|
1301
1348
|
if (typeof e != "string") return "<unknown>";
|
|
1302
1349
|
for (let t of e.split("\n").slice(1)) {
|
|
1303
|
-
let e =
|
|
1350
|
+
let e = jn(t);
|
|
1304
1351
|
if (e === void 0) continue;
|
|
1305
1352
|
let n = e.replace(/:\d+:\d+$/, "");
|
|
1306
|
-
if (
|
|
1353
|
+
if (An === "" || n !== An.replace(/:\d+:\d+$/, "")) return n;
|
|
1307
1354
|
}
|
|
1308
1355
|
return "<unknown>";
|
|
1309
|
-
},
|
|
1310
|
-
let r =
|
|
1356
|
+
}, Nn = () => [...wn.values()], Pn = (e, t, n) => {
|
|
1357
|
+
let r = Mn(), i = kn(), a = wn.get(e);
|
|
1311
1358
|
if (a !== void 0) {
|
|
1312
|
-
let t =
|
|
1359
|
+
let t = Tn.get(e) ?? "<unknown>", n = On.get(e) === i;
|
|
1313
1360
|
if (r !== "<unknown>" && r === t && !n) return a;
|
|
1314
1361
|
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}`);
|
|
1315
1362
|
}
|
|
1316
|
-
let o = n?.persist, s = () =>
|
|
1363
|
+
let o = n?.persist, s = () => nn(o?.storage === "session" ? "session" : "local"), c = () => {
|
|
1317
1364
|
let e = s();
|
|
1318
1365
|
if (e === null || o === void 0) return;
|
|
1319
1366
|
let t;
|
|
@@ -1338,28 +1385,28 @@ var Cn = () => {
|
|
|
1338
1385
|
t.setItem(o.key, JSON.stringify(n));
|
|
1339
1386
|
} catch {}
|
|
1340
1387
|
}, u = /* @__PURE__ */ new Map(), d = (n) => {
|
|
1341
|
-
let r = n ??
|
|
1388
|
+
let r = n ?? ln, i = u.get(r);
|
|
1342
1389
|
if (i === void 0) {
|
|
1343
1390
|
let a = n;
|
|
1344
|
-
i =
|
|
1391
|
+
i = fn(o !== void 0 && n === void 0 ? () => {
|
|
1345
1392
|
let e = t();
|
|
1346
1393
|
return f = e, {
|
|
1347
1394
|
...e,
|
|
1348
1395
|
...c() ?? {}
|
|
1349
1396
|
};
|
|
1350
1397
|
} : t, (t, n, r) => {
|
|
1351
|
-
if (o !== void 0 && a === void 0 && l(n), !
|
|
1398
|
+
if (o !== void 0 && a === void 0 && l(n), !xn && !Sn) {
|
|
1352
1399
|
let e = m(a);
|
|
1353
1400
|
e.steps.length = e.cursor, e.steps.push({
|
|
1354
1401
|
prev: t,
|
|
1355
1402
|
next: n
|
|
1356
1403
|
}), e.steps.length > h && e.steps.shift(), e.cursor = e.steps.length;
|
|
1357
1404
|
}
|
|
1358
|
-
|
|
1405
|
+
Cn({
|
|
1359
1406
|
store: e,
|
|
1360
1407
|
...a === void 0 ? {} : { key: a },
|
|
1361
1408
|
...r === void 0 ? {} : { label: r },
|
|
1362
|
-
...
|
|
1409
|
+
...xn || Sn ? { isUndo: !0 } : {},
|
|
1363
1410
|
prev: t,
|
|
1364
1411
|
next: n,
|
|
1365
1412
|
at: Date.now()
|
|
@@ -1368,7 +1415,7 @@ var Cn = () => {
|
|
|
1368
1415
|
}
|
|
1369
1416
|
return i;
|
|
1370
1417
|
}, f, p = /* @__PURE__ */ new Map(), m = (e) => {
|
|
1371
|
-
let t = e ??
|
|
1418
|
+
let t = e ?? ln, n = p.get(t);
|
|
1372
1419
|
return n === void 0 && (n = {
|
|
1373
1420
|
steps: [],
|
|
1374
1421
|
cursor: 0
|
|
@@ -1400,12 +1447,12 @@ var Cn = () => {
|
|
|
1400
1447
|
let n = o.current;
|
|
1401
1448
|
if (n.has && Object.is(n.state, t)) return n.value;
|
|
1402
1449
|
let r = i.current(t), s = a.current, c = n.has && (s ? s(n.value, r) : Object.is(n.value, r));
|
|
1403
|
-
if (process.env.NODE_ENV !== "production" && s === void 0 && n.has && !c && typeof r == "object" && r &&
|
|
1450
|
+
if (process.env.NODE_ENV !== "production" && s === void 0 && n.has && !c && typeof r == "object" && r && an(n.value, r)) {
|
|
1404
1451
|
let t = !0;
|
|
1405
1452
|
try {
|
|
1406
1453
|
t = !Object.is(i.current(n.state), n.value);
|
|
1407
1454
|
} catch {}
|
|
1408
|
-
|
|
1455
|
+
cn(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.`);
|
|
1409
1456
|
}
|
|
1410
1457
|
let l = c ? n.value : r;
|
|
1411
1458
|
return o.current = {
|
|
@@ -1422,7 +1469,7 @@ var Cn = () => {
|
|
|
1422
1469
|
r,
|
|
1423
1470
|
c,
|
|
1424
1471
|
l
|
|
1425
|
-
]), p = E(() => s(r.get()), [r, s]), m = E(() => s(
|
|
1472
|
+
]), p = E(() => s(r.get()), [r, s]), m = E(() => s(dn(e, n?.key, n?.key === void 0 && f !== void 0 ? f : r.get())), [
|
|
1426
1473
|
r,
|
|
1427
1474
|
n?.key,
|
|
1428
1475
|
s
|
|
@@ -1440,11 +1487,11 @@ var Cn = () => {
|
|
|
1440
1487
|
undo: (e) => {
|
|
1441
1488
|
let t = m(e);
|
|
1442
1489
|
if (t.cursor === 0) return !1;
|
|
1443
|
-
--t.cursor,
|
|
1490
|
+
--t.cursor, xn = !0;
|
|
1444
1491
|
try {
|
|
1445
1492
|
d(e).set(() => t.steps[t.cursor].prev, "undo");
|
|
1446
1493
|
} finally {
|
|
1447
|
-
|
|
1494
|
+
xn = !1;
|
|
1448
1495
|
}
|
|
1449
1496
|
return !0;
|
|
1450
1497
|
},
|
|
@@ -1452,11 +1499,11 @@ var Cn = () => {
|
|
|
1452
1499
|
let t = m(e);
|
|
1453
1500
|
if (t.cursor >= t.steps.length) return !1;
|
|
1454
1501
|
let n = t.steps[t.cursor];
|
|
1455
|
-
t.cursor += 1,
|
|
1502
|
+
t.cursor += 1, xn = !0;
|
|
1456
1503
|
try {
|
|
1457
1504
|
d(e).set(() => n.next, "redo");
|
|
1458
1505
|
} finally {
|
|
1459
|
-
|
|
1506
|
+
xn = !1;
|
|
1460
1507
|
}
|
|
1461
1508
|
return !0;
|
|
1462
1509
|
},
|
|
@@ -1468,24 +1515,24 @@ var Cn = () => {
|
|
|
1468
1515
|
release: (e) => {
|
|
1469
1516
|
u.delete(e), p.delete(e);
|
|
1470
1517
|
},
|
|
1471
|
-
keys: () => [...u.keys()].filter((e) => e !==
|
|
1518
|
+
keys: () => [...u.keys()].filter((e) => e !== ln)
|
|
1472
1519
|
};
|
|
1473
|
-
return
|
|
1474
|
-
},
|
|
1475
|
-
|
|
1476
|
-
},
|
|
1477
|
-
|
|
1478
|
-
},
|
|
1479
|
-
let r =
|
|
1520
|
+
return wn.set(e, b), Tn.set(e, r), On.set(e, i), b;
|
|
1521
|
+
}, Fn = () => {
|
|
1522
|
+
wn.clear(), Tn.clear(), On.clear(), sn.clear();
|
|
1523
|
+
}, In = () => ({ seeds: [] }), Ln = (e) => {
|
|
1524
|
+
un = e;
|
|
1525
|
+
}, Rn = (e, t, n) => {
|
|
1526
|
+
let r = un?.() ?? null;
|
|
1480
1527
|
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.)`);
|
|
1481
1528
|
r.seeds.push({
|
|
1482
1529
|
store: e.name,
|
|
1483
1530
|
...n?.key === void 0 ? {} : { key: n.key },
|
|
1484
1531
|
value: t
|
|
1485
1532
|
});
|
|
1486
|
-
},
|
|
1533
|
+
}, zn = (e) => {
|
|
1487
1534
|
if (e !== void 0) for (let t of e) {
|
|
1488
|
-
let e =
|
|
1535
|
+
let e = wn.get(t.store);
|
|
1489
1536
|
e !== void 0 && e.set(t.value, t.key);
|
|
1490
1537
|
}
|
|
1491
1538
|
}, q = (e, t) => {
|
|
@@ -1507,13 +1554,13 @@ var Cn = () => {
|
|
|
1507
1554
|
}
|
|
1508
1555
|
if (typeof r != "function") throw Error(`@voltro/client: rpc tag ${JSON.stringify(t)} did not resolve to a callable method.`);
|
|
1509
1556
|
return r;
|
|
1510
|
-
},
|
|
1557
|
+
}, Bn = Object.freeze({
|
|
1511
1558
|
data: void 0,
|
|
1512
1559
|
revision: -1,
|
|
1513
1560
|
emittedAt: void 0,
|
|
1514
1561
|
error: void 0,
|
|
1515
1562
|
pendingPatches: 0
|
|
1516
|
-
}),
|
|
1563
|
+
}), Vn = () => Bn;
|
|
1517
1564
|
function J(e, t, n = {}, r = {}) {
|
|
1518
1565
|
let i = r.skip === !0, { runtime: a, cache: o, client: s, descriptors: c } = K(e), l = c[t]?.source, u = k(n);
|
|
1519
1566
|
u.current = n;
|
|
@@ -1531,11 +1578,11 @@ function J(e, t, n = {}, r = {}) {
|
|
|
1531
1578
|
l,
|
|
1532
1579
|
i,
|
|
1533
1580
|
p
|
|
1534
|
-
]), g = E(() => i ?
|
|
1581
|
+
]), g = E(() => i ? Bn : o.peek(m), [
|
|
1535
1582
|
o,
|
|
1536
1583
|
i,
|
|
1537
1584
|
m
|
|
1538
|
-
]), _ = j(h, g,
|
|
1585
|
+
]), _ = j(h, g, Vn), v = _.data !== void 0, y = v && (Array.isArray(_.data) ? _.data.length === 0 : _.data === null), b = {
|
|
1539
1586
|
revision: _.revision,
|
|
1540
1587
|
emittedAt: _.emittedAt,
|
|
1541
1588
|
error: _.error,
|
|
@@ -1592,31 +1639,31 @@ function J(e, t, n = {}, r = {}) {
|
|
|
1592
1639
|
}
|
|
1593
1640
|
//#endregion
|
|
1594
1641
|
//#region src/awaitResolvedApi.ts
|
|
1595
|
-
var
|
|
1596
|
-
if (!
|
|
1597
|
-
let r = Date.now() +
|
|
1598
|
-
for (; Date.now() < r;) if (await new Promise((e) => setTimeout(e, 16)), !
|
|
1599
|
-
throw Error(`Voltro: the api "${t}" did not resolve within ${
|
|
1642
|
+
var Hn = 15e3, Y = async (e, t, n) => {
|
|
1643
|
+
if (!Nt(e.current)) return e.current;
|
|
1644
|
+
let r = Date.now() + Hn;
|
|
1645
|
+
for (; Date.now() < r;) if (await new Promise((e) => setTimeout(e, 16)), !Nt(e.current)) return e.current;
|
|
1646
|
+
throw Error(`Voltro: the api "${t}" did not resolve within ${Hn}ms, so ${n} was never sent. This is not the boot window — that is waited out. Check that "${t}" is a configured api name and that its client could connect.`);
|
|
1600
1647
|
}, X = async (e, t) => {
|
|
1601
1648
|
let n = await e.runPromiseExit(t);
|
|
1602
1649
|
if (P.isSuccess(n)) return n.value;
|
|
1603
1650
|
let r = M.squash(n.cause), i = M.failureOption(n.cause);
|
|
1604
|
-
throw Se(r, ae.isSome(i) ?
|
|
1605
|
-
},
|
|
1606
|
-
|
|
1607
|
-
},
|
|
1608
|
-
|
|
1609
|
-
for (let e of
|
|
1651
|
+
throw Se(r, ae.isSome(i) ? V(i.value, "handler") : "unknown");
|
|
1652
|
+
}, Un = 100, Z = [], Wn = /* @__PURE__ */ new Set(), Gn = [], Kn = () => {
|
|
1653
|
+
Gn = Z.slice();
|
|
1654
|
+
}, qn = () => {
|
|
1655
|
+
Kn();
|
|
1656
|
+
for (let e of Wn) try {
|
|
1610
1657
|
e();
|
|
1611
1658
|
} catch {}
|
|
1612
|
-
},
|
|
1659
|
+
}, Jn = (e) => {
|
|
1613
1660
|
let t = {
|
|
1614
1661
|
...e,
|
|
1615
1662
|
status: "pending",
|
|
1616
1663
|
startedAt: Date.now()
|
|
1617
1664
|
};
|
|
1618
|
-
Z.unshift(t), Z.length >
|
|
1619
|
-
},
|
|
1665
|
+
Z.unshift(t), Z.length > Un && (Z.length = Un), qn();
|
|
1666
|
+
}, Yn = (e, t) => {
|
|
1620
1667
|
let n = Z.findIndex((t) => t.id === e);
|
|
1621
1668
|
if (n === -1) return;
|
|
1622
1669
|
let r = Z[n], i = Date.now();
|
|
@@ -1632,27 +1679,27 @@ var Nn = 15e3, Y = async (e, t, n) => {
|
|
|
1632
1679
|
error: t.error,
|
|
1633
1680
|
settledAt: i,
|
|
1634
1681
|
durationMs: i - r.startedAt
|
|
1635
|
-
},
|
|
1636
|
-
},
|
|
1637
|
-
|
|
1638
|
-
}),
|
|
1639
|
-
Z.length !== 0 && (Z.length = 0,
|
|
1640
|
-
},
|
|
1682
|
+
}, qn();
|
|
1683
|
+
}, Xn = () => Gn, Zn = (e) => (Wn.add(e), () => {
|
|
1684
|
+
Wn.delete(e);
|
|
1685
|
+
}), Qn = () => {
|
|
1686
|
+
Z.length !== 0 && (Z.length = 0, qn());
|
|
1687
|
+
}, $n = /* @__PURE__ */ new WeakMap(), er = (e, t) => {
|
|
1641
1688
|
let n = Object.freeze({
|
|
1642
1689
|
apiName: e,
|
|
1643
1690
|
kind: "connection-setup"
|
|
1644
1691
|
});
|
|
1645
|
-
return
|
|
1646
|
-
},
|
|
1647
|
-
let n =
|
|
1692
|
+
return $n.set(n, t), n;
|
|
1693
|
+
}, tr = (e, t) => {
|
|
1694
|
+
let n = $n.get(e);
|
|
1648
1695
|
if (n === void 0 || e.apiName !== t) throw Error(`Voltro: connection setup must belong to api "${t}"`);
|
|
1649
1696
|
return n;
|
|
1650
|
-
},
|
|
1651
|
-
|
|
1652
|
-
},
|
|
1697
|
+
}, nr = /* @__PURE__ */ new WeakMap(), rr = (e, t) => {
|
|
1698
|
+
nr.set(e, t);
|
|
1699
|
+
}, ir = (e) => nr.get(e)?.capture(), ar = 0, or = () => {
|
|
1653
1700
|
let e = typeof crypto < "u" ? crypto : void 0;
|
|
1654
|
-
return e && typeof e.randomUUID == "function" ? e.randomUUID() : `idem_${Date.now().toString(36)}_${
|
|
1655
|
-
},
|
|
1701
|
+
return e && typeof e.randomUUID == "function" ? e.randomUUID() : `idem_${Date.now().toString(36)}_${ar += 1}`;
|
|
1702
|
+
}, sr = (e, t) => e.pipe(N.locallyWith(z.currentHeaders, (e) => ce.set(e, "idempotency-key", t))), cr = (e, t) => {
|
|
1656
1703
|
if (t === void 0 || typeof e != "object" || !e) return e;
|
|
1657
1704
|
try {
|
|
1658
1705
|
Object.defineProperty(e, "__voltroTraceId", {
|
|
@@ -1662,14 +1709,14 @@ var Nn = 15e3, Y = async (e, t, n) => {
|
|
|
1662
1709
|
});
|
|
1663
1710
|
} catch {}
|
|
1664
1711
|
return e;
|
|
1665
|
-
},
|
|
1666
|
-
|
|
1667
|
-
},
|
|
1712
|
+
}, lr, ur = (e) => {
|
|
1713
|
+
lr = e;
|
|
1714
|
+
}, dr = () => lr, fr = (e, t, n) => typeof e == "function" ? e(t, n) : e, pr = 0, mr = () => `mut_${++pr}`, hr = (e, t) => ({
|
|
1668
1715
|
update: (n, r) => {
|
|
1669
1716
|
e.update(n, r, t);
|
|
1670
1717
|
},
|
|
1671
1718
|
forTag: (n, r) => e.forTag(n, r, t)
|
|
1672
|
-
}),
|
|
1719
|
+
}), gr = (e, t) => {
|
|
1673
1720
|
let n = K(e), { descriptors: r } = n, i = k(n);
|
|
1674
1721
|
i.current = n;
|
|
1675
1722
|
let a = r[t], o = a?.targets;
|
|
@@ -1680,13 +1727,13 @@ var Nn = 15e3, Y = async (e, t, n) => {
|
|
|
1680
1727
|
let [s, c] = A(!1), [l, u] = A(void 0), [d, f] = A(void 0), p = k(null), m = k(!1), h = E(async (n, r) => {
|
|
1681
1728
|
let a = r?.onError !== void 0 || r?.notify?.error !== void 0, s = (e) => {
|
|
1682
1729
|
r?.onError?.(e, n);
|
|
1683
|
-
let t =
|
|
1684
|
-
t !== void 0 &&
|
|
1730
|
+
let t = fr(r?.notify?.error, e, n);
|
|
1731
|
+
t !== void 0 && lr?.error(t);
|
|
1685
1732
|
};
|
|
1686
1733
|
c(!0), u(void 0);
|
|
1687
1734
|
let l, d, g, _;
|
|
1688
1735
|
try {
|
|
1689
|
-
_ =
|
|
1736
|
+
_ = ir(h), {runtime: l, cache: d, client: g} = await Y(i, e, t);
|
|
1690
1737
|
} catch (e) {
|
|
1691
1738
|
if (c(!1), u(e), i.current.errorBus.emit({
|
|
1692
1739
|
source: "mutation",
|
|
@@ -1697,8 +1744,8 @@ var Nn = 15e3, Y = async (e, t, n) => {
|
|
|
1697
1744
|
}), a) return s(e);
|
|
1698
1745
|
throw e;
|
|
1699
1746
|
}
|
|
1700
|
-
let v =
|
|
1701
|
-
|
|
1747
|
+
let v = mr(), y = r?.idempotencyKey ?? or();
|
|
1748
|
+
Jn({
|
|
1702
1749
|
id: v,
|
|
1703
1750
|
apiName: e,
|
|
1704
1751
|
tag: t,
|
|
@@ -1706,9 +1753,9 @@ var Nn = 15e3, Y = async (e, t, n) => {
|
|
|
1706
1753
|
});
|
|
1707
1754
|
let b = p.current, x = m.current;
|
|
1708
1755
|
if (b) try {
|
|
1709
|
-
b(
|
|
1756
|
+
b(hr(d, v), n);
|
|
1710
1757
|
} catch (e) {
|
|
1711
|
-
if (u(e), c(!1), d.revertByMutation(v),
|
|
1758
|
+
if (u(e), c(!1), d.revertByMutation(v), Yn(v, {
|
|
1712
1759
|
status: "error",
|
|
1713
1760
|
error: e
|
|
1714
1761
|
}), a) return s(e);
|
|
@@ -1718,11 +1765,11 @@ var Nn = 15e3, Y = async (e, t, n) => {
|
|
|
1718
1765
|
let S, C = !1, w, T, E = Date.now();
|
|
1719
1766
|
try {
|
|
1720
1767
|
let a = async (r, a, o, s) => {
|
|
1721
|
-
let c =
|
|
1768
|
+
let c = Wt(r), l = c?.getSnapshot();
|
|
1722
1769
|
T = c === void 0 ? void 0 : () => i.current.runtime === r && l !== void 0 && c.getSnapshot() === l, s?.();
|
|
1723
1770
|
let u = _ === void 0 ? void 0 : await _.prepare(r, a);
|
|
1724
1771
|
l = c?.getSnapshot(), s?.();
|
|
1725
|
-
let d =
|
|
1772
|
+
let d = sr(q(a, t)(n), y), f = N.currentSpan.pipe(N.tap((e) => N.sync(() => {
|
|
1726
1773
|
S = e.traceId, ye({
|
|
1727
1774
|
traceId: e.traceId,
|
|
1728
1775
|
spanId: e.spanId,
|
|
@@ -1745,7 +1792,7 @@ var Nn = 15e3, Y = async (e, t, n) => {
|
|
|
1745
1792
|
try {
|
|
1746
1793
|
o = await a(l, g, !1);
|
|
1747
1794
|
} catch (n) {
|
|
1748
|
-
let r =
|
|
1795
|
+
let r = V(n, C ? "handler" : "client"), s = cr(n, S);
|
|
1749
1796
|
r === "transport" && (i.current.errorBus.emit({
|
|
1750
1797
|
source: "mutation",
|
|
1751
1798
|
tag: t,
|
|
@@ -1755,7 +1802,7 @@ var Nn = 15e3, Y = async (e, t, n) => {
|
|
|
1755
1802
|
outcome: C ? "unknown" : "not-started",
|
|
1756
1803
|
...S === void 0 ? {} : { traceId: S }
|
|
1757
1804
|
}), w = s);
|
|
1758
|
-
let c = i.current, l = c.recovery ??
|
|
1805
|
+
let c = i.current, l = c.recovery ?? _t(c.errorBus, e), u = r === "transport" ? l.reserveMutationReplay(E) : void 0;
|
|
1759
1806
|
if (u === void 0) throw s;
|
|
1760
1807
|
try {
|
|
1761
1808
|
if (!await l.waitForMutationReplaySupport(E) || !await l.waitForProtocolReady(E) || !u.isValid()) throw s;
|
|
@@ -1780,27 +1827,27 @@ var Nn = 15e3, Y = async (e, t, n) => {
|
|
|
1780
1827
|
u.release();
|
|
1781
1828
|
}
|
|
1782
1829
|
}
|
|
1783
|
-
f(o),
|
|
1830
|
+
f(o), Yn(v, {
|
|
1784
1831
|
status: "success",
|
|
1785
1832
|
output: o
|
|
1786
1833
|
}), i.current.errorBus.emitSuccess({
|
|
1787
1834
|
source: "mutation",
|
|
1788
1835
|
tag: t
|
|
1789
1836
|
}), d.confirmByMutation(v), r?.onSuccess?.(o, n);
|
|
1790
|
-
let s =
|
|
1791
|
-
return s !== void 0 &&
|
|
1837
|
+
let s = fr(r?.notify?.success, o, n);
|
|
1838
|
+
return s !== void 0 && lr?.success(s), o;
|
|
1792
1839
|
} catch (e) {
|
|
1793
|
-
let n =
|
|
1794
|
-
if (u(n),
|
|
1840
|
+
let n = cr(e, S);
|
|
1841
|
+
if (u(n), Yn(v, {
|
|
1795
1842
|
status: "error",
|
|
1796
1843
|
error: n
|
|
1797
1844
|
}), d.revertByMutation(v), Object.is(w, n) || i.current.errorBus.emit({
|
|
1798
1845
|
source: "mutation",
|
|
1799
1846
|
tag: t,
|
|
1800
1847
|
error: n,
|
|
1801
|
-
kind: C ?
|
|
1848
|
+
kind: C ? V(e, "handler") : "client",
|
|
1802
1849
|
...T === void 0 ? {} : { affectsTransport: T() },
|
|
1803
|
-
outcome: C &&
|
|
1850
|
+
outcome: C && V(e, "handler") === "transport" ? "unknown" : C ? "known" : "not-started",
|
|
1804
1851
|
...S === void 0 ? {} : { traceId: S }
|
|
1805
1852
|
}), a) return s(n);
|
|
1806
1853
|
throw n;
|
|
@@ -1820,7 +1867,7 @@ var Nn = 15e3, Y = async (e, t, n) => {
|
|
|
1820
1867
|
data: d,
|
|
1821
1868
|
withOptimistic: (e) => (p.current = e, t),
|
|
1822
1869
|
withoutOptimistic: () => (m.current = !0, t),
|
|
1823
|
-
withConnectionSetup: (n) => (
|
|
1870
|
+
withConnectionSetup: (n) => (rr(h, tr(n, e)), t)
|
|
1824
1871
|
};
|
|
1825
1872
|
return t;
|
|
1826
1873
|
}, [
|
|
@@ -1830,7 +1877,7 @@ var Nn = 15e3, Y = async (e, t, n) => {
|
|
|
1830
1877
|
d,
|
|
1831
1878
|
e
|
|
1832
1879
|
]);
|
|
1833
|
-
},
|
|
1880
|
+
}, _r = (e, t) => {
|
|
1834
1881
|
if (t === void 0 || typeof e != "object" || !e) return e;
|
|
1835
1882
|
try {
|
|
1836
1883
|
Object.defineProperty(e, "__voltroTraceId", {
|
|
@@ -1840,7 +1887,7 @@ var Nn = 15e3, Y = async (e, t, n) => {
|
|
|
1840
1887
|
});
|
|
1841
1888
|
} catch {}
|
|
1842
1889
|
return e;
|
|
1843
|
-
},
|
|
1890
|
+
}, vr = (e, t, n) => typeof e == "function" ? e(t, n) : e, yr = 0, br = () => `act_${++yr}`, xr = (e, t) => {
|
|
1844
1891
|
let n = K(e), { descriptors: r } = n, i = k(n);
|
|
1845
1892
|
if (i.current = n, process.env.NODE_ENV !== "production") {
|
|
1846
1893
|
let n = r[t]?.kind;
|
|
@@ -1849,8 +1896,8 @@ var Nn = 15e3, Y = async (e, t, n) => {
|
|
|
1849
1896
|
let [a, o] = A(!1), [s, c] = A(void 0), [l, u] = A(void 0), d = E(async (n, r) => {
|
|
1850
1897
|
let a = r?.onError !== void 0 || r?.notify?.error !== void 0;
|
|
1851
1898
|
o(!0), c(void 0);
|
|
1852
|
-
let s =
|
|
1853
|
-
|
|
1899
|
+
let s = br(), l = r?.idempotencyKey ?? or();
|
|
1900
|
+
Jn({
|
|
1854
1901
|
id: s,
|
|
1855
1902
|
apiName: e,
|
|
1856
1903
|
tag: t,
|
|
@@ -1865,38 +1912,38 @@ var Nn = 15e3, Y = async (e, t, n) => {
|
|
|
1865
1912
|
source: "action",
|
|
1866
1913
|
tag: t
|
|
1867
1914
|
});
|
|
1868
|
-
})), N.catchAll(() => N.void), N.zipRight(
|
|
1915
|
+
})), N.catchAll(() => N.void), N.zipRight(sr(c(n), l))).pipe(N.withSpan(`client.action.${t}`, { attributes: {
|
|
1869
1916
|
"voltro.api": e,
|
|
1870
1917
|
"voltro.actionId": s,
|
|
1871
1918
|
"rpc.tag": t
|
|
1872
1919
|
} }));
|
|
1873
1920
|
f = !0;
|
|
1874
1921
|
let m = await X(a, p);
|
|
1875
|
-
u(m),
|
|
1922
|
+
u(m), Yn(s, {
|
|
1876
1923
|
status: "success",
|
|
1877
1924
|
output: m
|
|
1878
1925
|
}), i.current.errorBus.emitSuccess({
|
|
1879
1926
|
source: "action",
|
|
1880
1927
|
tag: t
|
|
1881
1928
|
}), r?.onSuccess?.(m, n);
|
|
1882
|
-
let h =
|
|
1883
|
-
return h !== void 0 &&
|
|
1929
|
+
let h = vr(r?.notify?.success, m, n);
|
|
1930
|
+
return h !== void 0 && dr()?.success(h), m;
|
|
1884
1931
|
} catch (e) {
|
|
1885
|
-
let o =
|
|
1886
|
-
if (c(o),
|
|
1932
|
+
let o = _r(e, d);
|
|
1933
|
+
if (c(o), Yn(s, {
|
|
1887
1934
|
status: "error",
|
|
1888
1935
|
error: o
|
|
1889
1936
|
}), i.current.errorBus.emit({
|
|
1890
1937
|
source: "action",
|
|
1891
1938
|
tag: t,
|
|
1892
1939
|
error: o,
|
|
1893
|
-
kind: f ?
|
|
1894
|
-
outcome: f &&
|
|
1940
|
+
kind: f ? V(e, "handler") : "client",
|
|
1941
|
+
outcome: f && V(e, "handler") === "transport" ? "unknown" : f ? "known" : "not-started",
|
|
1895
1942
|
...d === void 0 ? {} : { traceId: d }
|
|
1896
1943
|
}), a) {
|
|
1897
1944
|
r?.onError?.(o, n);
|
|
1898
|
-
let e =
|
|
1899
|
-
e !== void 0 &&
|
|
1945
|
+
let e = vr(r?.notify?.error, o, n);
|
|
1946
|
+
e !== void 0 && dr()?.error(e);
|
|
1900
1947
|
return;
|
|
1901
1948
|
}
|
|
1902
1949
|
throw o;
|
|
@@ -1915,14 +1962,14 @@ var Nn = 15e3, Y = async (e, t, n) => {
|
|
|
1915
1962
|
s,
|
|
1916
1963
|
l
|
|
1917
1964
|
]);
|
|
1918
|
-
},
|
|
1965
|
+
}, Sr = w(void 0), Cr = (e) => T(Sr.Provider, { value: e.messages }, e.children), wr = () => ee(Sr), Tr = Symbol.for("voltro.client.formEngine"), Er = w(void 0), Dr = (e, t) => {
|
|
1919
1966
|
let n = e;
|
|
1920
1967
|
for (let e of t.split(".")) {
|
|
1921
1968
|
if (typeof n != "object" || !n) return;
|
|
1922
1969
|
n = n[e];
|
|
1923
1970
|
}
|
|
1924
1971
|
return n;
|
|
1925
|
-
},
|
|
1972
|
+
}, Or = (e, t, n) => `vf-${e}-${t}-${n}`.replace(/[^a-zA-Z0-9_-]/g, "-"), kr = {
|
|
1926
1973
|
isTouched: !1,
|
|
1927
1974
|
isBlurred: !1,
|
|
1928
1975
|
isDirty: !1,
|
|
@@ -1931,15 +1978,15 @@ var Nn = 15e3, Y = async (e, t, n) => {
|
|
|
1931
1978
|
isValidating: !1,
|
|
1932
1979
|
errorMap: {},
|
|
1933
1980
|
errorSourceMap: {}
|
|
1934
|
-
},
|
|
1981
|
+
}, Ar = (e, t) => {
|
|
1935
1982
|
let n = e.find((e) => e.name === t);
|
|
1936
1983
|
if (n !== void 0) return n;
|
|
1937
1984
|
let r = /^(.+?)\.\d+\.(.+)$/.exec(t);
|
|
1938
1985
|
if (r !== null) return e.find((e) => e.name === r[1] && e.widget === "array")?.item?.find((e) => e.name === r[2]);
|
|
1939
|
-
},
|
|
1940
|
-
let r = K(e), a = k(void 0), o = typeof t == "function" ? t(a.current?.state?.values ?? n.defaults ?? {}) : t, s = k(o).current, c =
|
|
1986
|
+
}, jr = (e, t, n) => {
|
|
1987
|
+
let r = K(e), a = k(void 0), o = typeof t == "function" ? t(a.current?.state?.values ?? n.defaults ?? {}) : t, s = k(o).current, c = gr(e, o), l = n.schema ?? r.descriptors[o]?.input;
|
|
1941
1988
|
process.env.NODE_ENV !== "production" && l === 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.`);
|
|
1942
|
-
let u = O(() => l ? x(l) : [], [l]), d =
|
|
1989
|
+
let u = O(() => l ? x(l) : [], [l]), d = wr(), f = n.messages ?? d, p = O(() => ({
|
|
1943
1990
|
...n.locale === void 0 ? {} : { locale: n.locale },
|
|
1944
1991
|
...f === void 0 ? {} : { messages: f }
|
|
1945
1992
|
}), [n.locale, f]), m = k(n.asyncFields);
|
|
@@ -1966,7 +2013,7 @@ var Nn = 15e3, Y = async (e, t, n) => {
|
|
|
1966
2013
|
let o = n.errorPath ?? {};
|
|
1967
2014
|
return a.map((t) => {
|
|
1968
2015
|
let n = o[t.path];
|
|
1969
|
-
return n === void 0 ? (
|
|
2016
|
+
return n === void 0 ? (Dr(e, t.path) !== void 0 || t.path.includes("."), t) : {
|
|
1970
2017
|
...t,
|
|
1971
2018
|
path: n
|
|
1972
2019
|
};
|
|
@@ -1997,19 +2044,19 @@ var Nn = 15e3, Y = async (e, t, n) => {
|
|
|
1997
2044
|
D(() => P.mount(), [P]);
|
|
1998
2045
|
let ie = n.subscribe ?? "all";
|
|
1999
2046
|
ge(N.store, (e) => ie === "all" ? e : `${e.submissionAttempts}|${String(e.isSubmitting)}|${String(e.isDirty)}|${String(e.isTouched)}`);
|
|
2000
|
-
let F = N.store.state.values, I = N.store.state, ae = O(() => M(F), [M, F]), L = n.isLoading === !0, oe = n.validate,
|
|
2047
|
+
let F = N.store.state.values, I = N.store.state, ae = O(() => M(F), [M, F]), L = n.isLoading === !0, oe = n.validate, se = oe?.onChange ?? "afterTouched", R = oe?.onBlur ?? !0, ce = I.submissionAttempts, z = I.fieldMetaBase ?? {}, le = E((e) => {
|
|
2001
2048
|
if (L) return !1;
|
|
2002
|
-
if (ce > 0 ||
|
|
2003
|
-
if (
|
|
2004
|
-
let t =
|
|
2005
|
-
return t === void 0 ? !1 :
|
|
2049
|
+
if (ce > 0 || se === "always") return !0;
|
|
2050
|
+
if (se === "never") return !1;
|
|
2051
|
+
let t = z[e];
|
|
2052
|
+
return t === void 0 ? !1 : R ? t.isBlurred === !0 : t.isTouched === !0;
|
|
2006
2053
|
}, [
|
|
2007
2054
|
ce,
|
|
2008
|
-
|
|
2055
|
+
z,
|
|
2009
2056
|
L,
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
]),
|
|
2057
|
+
se,
|
|
2058
|
+
R
|
|
2059
|
+
]), ue = E((e) => {
|
|
2013
2060
|
let t = y[e];
|
|
2014
2061
|
if (t !== void 0) return t;
|
|
2015
2062
|
let n = m.current?.[e];
|
|
@@ -2017,41 +2064,41 @@ var Nn = 15e3, Y = async (e, t, n) => {
|
|
|
2017
2064
|
id: "validation.invalid",
|
|
2018
2065
|
fallback: "Invalid value"
|
|
2019
2066
|
}, _.current);
|
|
2020
|
-
if (!
|
|
2067
|
+
if (!le(e)) return;
|
|
2021
2068
|
let r = ae.find((t) => t.path === e);
|
|
2022
2069
|
return r === void 0 ? void 0 : b(r, _.current);
|
|
2023
2070
|
}, [
|
|
2024
2071
|
y,
|
|
2025
|
-
|
|
2072
|
+
le,
|
|
2026
2073
|
ae
|
|
2027
|
-
]),
|
|
2074
|
+
]), de = O(() => {
|
|
2028
2075
|
let e = {}, t = /* @__PURE__ */ new Set([...ae.map((e) => e.path).filter((e) => e !== ""), ...Object.keys(y)]);
|
|
2029
2076
|
for (let [e, n] of Object.entries(m.current ?? {})) n.status === "invalid" && t.add(e);
|
|
2030
2077
|
for (let n of t) {
|
|
2031
|
-
let t =
|
|
2078
|
+
let t = ue(n);
|
|
2032
2079
|
t !== void 0 && (e[n] = t);
|
|
2033
2080
|
}
|
|
2034
2081
|
return e;
|
|
2035
2082
|
}, [
|
|
2036
2083
|
ae,
|
|
2037
2084
|
y,
|
|
2038
|
-
|
|
2039
|
-
]),
|
|
2085
|
+
ue
|
|
2086
|
+
]), pe = E((e) => {
|
|
2040
2087
|
S((t) => {
|
|
2041
2088
|
if (!(e in t)) return t;
|
|
2042
2089
|
let n = { ...t };
|
|
2043
2090
|
return delete n[e], n;
|
|
2044
2091
|
});
|
|
2045
|
-
}, []),
|
|
2046
|
-
let n =
|
|
2092
|
+
}, []), B = E((t) => {
|
|
2093
|
+
let n = Ar(u, t), r = P.getFieldMeta(t), i = ue(t), a = Or(e, s, t), o = m.current?.[t], c = [i === void 0 ? void 0 : `${a}-error`, n?.description === void 0 ? void 0 : `${a}-help`].filter((e) => e !== void 0);
|
|
2047
2094
|
return {
|
|
2048
2095
|
value: P.getFieldValue(t),
|
|
2049
2096
|
setValue: (e) => {
|
|
2050
|
-
|
|
2097
|
+
pe(t), !Object.is(P.getFieldValue(t), e) && P.setFieldValue(t, e);
|
|
2051
2098
|
},
|
|
2052
2099
|
onBlur: () => {
|
|
2053
2100
|
P.setFieldMeta(t, (e) => ({
|
|
2054
|
-
...
|
|
2101
|
+
...kr,
|
|
2055
2102
|
...e ?? {},
|
|
2056
2103
|
isTouched: !0,
|
|
2057
2104
|
isBlurred: !0
|
|
@@ -2078,12 +2125,12 @@ var Nn = 15e3, Y = async (e, t, n) => {
|
|
|
2078
2125
|
}, [
|
|
2079
2126
|
e,
|
|
2080
2127
|
s,
|
|
2081
|
-
|
|
2128
|
+
pe,
|
|
2082
2129
|
P,
|
|
2083
2130
|
u,
|
|
2084
2131
|
y,
|
|
2085
|
-
|
|
2086
|
-
]),
|
|
2132
|
+
ue
|
|
2133
|
+
]), me = E((e) => ({
|
|
2087
2134
|
items: P.getFieldValue(e) ?? [],
|
|
2088
2135
|
push: (t) => {
|
|
2089
2136
|
P.pushFieldValue(e, t);
|
|
@@ -2100,14 +2147,14 @@ var Nn = 15e3, Y = async (e, t, n) => {
|
|
|
2100
2147
|
swap: (t, n) => {
|
|
2101
2148
|
P.swapFieldValues(e, t, n);
|
|
2102
2149
|
},
|
|
2103
|
-
field: (t, n) =>
|
|
2104
|
-
}), [P,
|
|
2105
|
-
|
|
2106
|
-
}, [
|
|
2150
|
+
field: (t, n) => B(`${e}.${t}.${n}`)
|
|
2151
|
+
}), [P, B]), _e = E((e) => u.filter((t) => t.section === e), [u]), ve = E((e, t) => {
|
|
2152
|
+
pe(e), !Object.is(P.getFieldValue(e), t) && P.setFieldValue(e, t);
|
|
2153
|
+
}, [pe, P]), ye = E((e) => {
|
|
2107
2154
|
for (let [t, n] of Object.entries(e)) P.setFieldValue(t, n);
|
|
2108
|
-
}, [P]),
|
|
2155
|
+
}, [P]), be = E((e) => {
|
|
2109
2156
|
S({}), T(void 0), te(void 0), j.current = void 0, e === void 0 ? P.reset() : P.reset(ne(e));
|
|
2110
|
-
}, [P, ne]),
|
|
2157
|
+
}, [P, ne]), xe = n.asyncTimeoutMs ?? 5e3, Se = E(async () => {
|
|
2111
2158
|
let e = Date.now();
|
|
2112
2159
|
for (;;) {
|
|
2113
2160
|
let t = m.current;
|
|
@@ -2120,18 +2167,18 @@ var Nn = 15e3, Y = async (e, t, n) => {
|
|
|
2120
2167
|
fallback: "Invalid value"
|
|
2121
2168
|
}, _.current)]));
|
|
2122
2169
|
}
|
|
2123
|
-
if (Date.now() - e >
|
|
2170
|
+
if (Date.now() - e > xe) return Object.fromEntries(r.map(([e]) => [e, b({
|
|
2124
2171
|
id: "validation.checking",
|
|
2125
2172
|
fallback: "Still checking…"
|
|
2126
2173
|
}, _.current)]));
|
|
2127
2174
|
await new Promise((e) => setTimeout(e, 50));
|
|
2128
2175
|
}
|
|
2129
|
-
}, [
|
|
2176
|
+
}, [xe]), V = E(() => {
|
|
2130
2177
|
let t = globalThis.document;
|
|
2131
2178
|
if (t?.getElementById === void 0) return;
|
|
2132
2179
|
let n = [...u.map((e) => e.name), ...Object.keys(y).filter((e) => !u.some((t) => t.name === e))];
|
|
2133
|
-
for (let r of n) if (
|
|
2134
|
-
t.getElementById(
|
|
2180
|
+
for (let r of n) if (ue(r) !== void 0) {
|
|
2181
|
+
t.getElementById(Or(e, s, r))?.focus?.();
|
|
2135
2182
|
return;
|
|
2136
2183
|
}
|
|
2137
2184
|
}, [
|
|
@@ -2139,9 +2186,9 @@ var Nn = 15e3, Y = async (e, t, n) => {
|
|
|
2139
2186
|
s,
|
|
2140
2187
|
u,
|
|
2141
2188
|
y,
|
|
2142
|
-
|
|
2143
|
-
]),
|
|
2144
|
-
|
|
2189
|
+
ue
|
|
2190
|
+
]), Ce = k(V);
|
|
2191
|
+
Ce.current = V;
|
|
2145
2192
|
let we = E(async () => {
|
|
2146
2193
|
T(void 0), S({}), te(void 0), j.current = void 0;
|
|
2147
2194
|
let e, t = !1;
|
|
@@ -2149,7 +2196,7 @@ var Nn = 15e3, Y = async (e, t, n) => {
|
|
|
2149
2196
|
t = !0, e = n;
|
|
2150
2197
|
}), t) throw e;
|
|
2151
2198
|
return j.current === void 0 && queueMicrotask(() => {
|
|
2152
|
-
|
|
2199
|
+
Ce.current();
|
|
2153
2200
|
}), j.current;
|
|
2154
2201
|
}, [P]);
|
|
2155
2202
|
re.current = (async (e) => {
|
|
@@ -2162,7 +2209,7 @@ var Nn = 15e3, Y = async (e, t, n) => {
|
|
|
2162
2209
|
}
|
|
2163
2210
|
if (M(n).length > 0) {
|
|
2164
2211
|
queueMicrotask(() => {
|
|
2165
|
-
|
|
2212
|
+
Ce.current();
|
|
2166
2213
|
});
|
|
2167
2214
|
return;
|
|
2168
2215
|
}
|
|
@@ -2171,13 +2218,13 @@ var Nn = 15e3, Y = async (e, t, n) => {
|
|
|
2171
2218
|
let e = C(i, r);
|
|
2172
2219
|
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;
|
|
2173
2220
|
}
|
|
2174
|
-
let a = await
|
|
2221
|
+
let a = await Se();
|
|
2175
2222
|
if (a !== void 0) {
|
|
2176
2223
|
S((e) => ({
|
|
2177
2224
|
...e,
|
|
2178
2225
|
...a
|
|
2179
2226
|
})), queueMicrotask(() => {
|
|
2180
|
-
|
|
2227
|
+
Ce.current();
|
|
2181
2228
|
});
|
|
2182
2229
|
return;
|
|
2183
2230
|
}
|
|
@@ -2205,13 +2252,13 @@ var Nn = 15e3, Y = async (e, t, n) => {
|
|
|
2205
2252
|
...e,
|
|
2206
2253
|
...n
|
|
2207
2254
|
})), queueMicrotask(() => {
|
|
2208
|
-
|
|
2255
|
+
Ce.current();
|
|
2209
2256
|
});
|
|
2210
2257
|
}
|
|
2211
2258
|
});
|
|
2212
|
-
let Te = ae.length === 0, Ee = Object.values(m.current ?? {}).some((e) => e.status === "checking"), De = ee ?? c.error,
|
|
2213
|
-
for (let e of u) if (
|
|
2214
|
-
let e = Object.keys(
|
|
2259
|
+
let Te = ae.length === 0, Ee = Object.values(m.current ?? {}).some((e) => e.status === "checking"), De = ee ?? c.error, Oe = De !== void 0 && fe(De).length > 0 ? void 0 : De, H = Object.keys(de).length, ke = (() => {
|
|
2260
|
+
for (let e of u) if (de[e.name] !== void 0) return e.name;
|
|
2261
|
+
let e = Object.keys(de);
|
|
2215
2262
|
return e.length > 0 ? e[0] : void 0;
|
|
2216
2263
|
})(), Ae = {
|
|
2217
2264
|
isDirty: !L && I.isDirty,
|
|
@@ -2224,48 +2271,48 @@ var Nn = 15e3, Y = async (e, t, n) => {
|
|
|
2224
2271
|
isSubmitted: I.isSubmitted,
|
|
2225
2272
|
isSubmitSuccessful: I.isSubmitSuccessful && j.current !== void 0,
|
|
2226
2273
|
submissionAttempts: I.submissionAttempts,
|
|
2227
|
-
errorCount:
|
|
2274
|
+
errorCount: H,
|
|
2228
2275
|
firstInvalidPath: ke,
|
|
2229
2276
|
pending: c.pending,
|
|
2230
2277
|
isLoading: L,
|
|
2231
|
-
submitError:
|
|
2278
|
+
submitError: Oe,
|
|
2232
2279
|
data: c.data
|
|
2233
2280
|
}, je = {
|
|
2234
2281
|
fields: u,
|
|
2235
2282
|
values: F,
|
|
2236
|
-
errors:
|
|
2283
|
+
errors: de,
|
|
2237
2284
|
issues: ae,
|
|
2238
2285
|
isValid: Te,
|
|
2239
2286
|
pending: c.pending,
|
|
2240
|
-
submitError:
|
|
2287
|
+
submitError: Oe,
|
|
2241
2288
|
formError: w,
|
|
2242
2289
|
data: c.data,
|
|
2243
|
-
setValue:
|
|
2244
|
-
setValues:
|
|
2245
|
-
reset:
|
|
2290
|
+
setValue: ve,
|
|
2291
|
+
setValues: ye,
|
|
2292
|
+
reset: be,
|
|
2246
2293
|
submit: we,
|
|
2247
|
-
field:
|
|
2248
|
-
array:
|
|
2249
|
-
section:
|
|
2294
|
+
field: B,
|
|
2295
|
+
array: me,
|
|
2296
|
+
section: _e,
|
|
2250
2297
|
state: Ae,
|
|
2251
|
-
focusFirstInvalid:
|
|
2298
|
+
focusFirstInvalid: V
|
|
2252
2299
|
};
|
|
2253
|
-
return Object.defineProperty(je,
|
|
2300
|
+
return Object.defineProperty(je, Tr, {
|
|
2254
2301
|
value: {
|
|
2255
2302
|
store: N.store,
|
|
2256
|
-
field:
|
|
2303
|
+
field: B
|
|
2257
2304
|
},
|
|
2258
2305
|
enumerable: !1
|
|
2259
2306
|
}), je;
|
|
2260
|
-
},
|
|
2261
|
-
function
|
|
2262
|
-
let n = ee(
|
|
2307
|
+
}, Mr = (e) => T(Er.Provider, { value: e.binding }, e.children), Nr = () => ee(Er);
|
|
2308
|
+
function Pr(e, t) {
|
|
2309
|
+
let n = ee(Er), r = typeof e == "string" ? void 0 : e, i = typeof e == "string" ? e : t, a = r ?? n;
|
|
2263
2310
|
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.");
|
|
2264
|
-
let o = a[
|
|
2311
|
+
let o = a[Tr];
|
|
2265
2312
|
if (o === void 0) throw Error("useFormField: not a useFormBinding result");
|
|
2266
2313
|
return ge(o.store, (e) => {
|
|
2267
2314
|
let t = e.fieldMetaBase[i];
|
|
2268
|
-
return `${JSON.stringify(
|
|
2315
|
+
return `${JSON.stringify(Dr(e.values, i))}|${t === void 0 ? "" : `${String(t.isTouched)}${String(t.isBlurred)}${JSON.stringify(t.errorMap)}`}|${e.submissionAttempts}`;
|
|
2269
2316
|
}), o.field(i);
|
|
2270
2317
|
}
|
|
2271
2318
|
//#endregion
|
|
@@ -2276,7 +2323,7 @@ var Q = class extends Error {
|
|
|
2276
2323
|
constructor(e) {
|
|
2277
2324
|
super(`Voltro connection prerequisite: ${e}`), this.reason = e, Se(this, e === "connection-unavailable" || e === "connection-changed" ? "transport" : "client");
|
|
2278
2325
|
}
|
|
2279
|
-
},
|
|
2326
|
+
}, Fr = class {
|
|
2280
2327
|
#e;
|
|
2281
2328
|
#t;
|
|
2282
2329
|
#n = /* @__PURE__ */ new WeakMap();
|
|
@@ -2286,7 +2333,7 @@ var Q = class extends Error {
|
|
|
2286
2333
|
this.#e = e, this.#t = t;
|
|
2287
2334
|
}
|
|
2288
2335
|
prepare(e, t) {
|
|
2289
|
-
let n =
|
|
2336
|
+
let n = Wt(e)?.getSnapshot();
|
|
2290
2337
|
if (this.#e.aborted) return Promise.reject(new Q("inactive"));
|
|
2291
2338
|
if (n === void 0) return Promise.reject(new Q("connection-unavailable"));
|
|
2292
2339
|
let r = this.#n.get(n);
|
|
@@ -2311,7 +2358,7 @@ var Q = class extends Error {
|
|
|
2311
2358
|
}
|
|
2312
2359
|
#i(e, t) {
|
|
2313
2360
|
if (this.#e.aborted) throw new Q("inactive");
|
|
2314
|
-
if (t.signal.aborted ||
|
|
2361
|
+
if (t.signal.aborted || Wt(e)?.getSnapshot() !== t) throw new Q("connection-changed");
|
|
2315
2362
|
}
|
|
2316
2363
|
run(e, t, n) {
|
|
2317
2364
|
let r = N.try({
|
|
@@ -2332,7 +2379,7 @@ var Q = class extends Error {
|
|
|
2332
2379
|
});
|
|
2333
2380
|
return r.pipe(N.zipRight(n), N.tap(() => r), N.raceFirst(i));
|
|
2334
2381
|
}
|
|
2335
|
-
},
|
|
2382
|
+
}, Ir = class {
|
|
2336
2383
|
#e;
|
|
2337
2384
|
#t;
|
|
2338
2385
|
#n;
|
|
@@ -2347,7 +2394,7 @@ var Q = class extends Error {
|
|
|
2347
2394
|
#s;
|
|
2348
2395
|
handle;
|
|
2349
2396
|
constructor(e, t, n) {
|
|
2350
|
-
this.#e = e, this.#t = t, this.#n = n, this.handle =
|
|
2397
|
+
this.#e = e, this.#t = t, this.#n = n, this.handle = er(e, { capture: () => this.#f() });
|
|
2351
2398
|
}
|
|
2352
2399
|
getSnapshot = () => this.#a;
|
|
2353
2400
|
subscribe = (e) => (this.#r.add(e), () => {
|
|
@@ -2365,11 +2412,11 @@ var Q = class extends Error {
|
|
|
2365
2412
|
this.clear();
|
|
2366
2413
|
let n = new AbortController(), r = {
|
|
2367
2414
|
input: e,
|
|
2368
|
-
key:
|
|
2415
|
+
key: or(),
|
|
2369
2416
|
controller: n,
|
|
2370
2417
|
subject: void 0,
|
|
2371
2418
|
detachSubject: void 0,
|
|
2372
|
-
prerequisite: new
|
|
2419
|
+
prerequisite: new Fr(n.signal, this.#c(this.#n()).options.replayWindowMs),
|
|
2373
2420
|
established: !1
|
|
2374
2421
|
};
|
|
2375
2422
|
this.#i = r, this.#h({
|
|
@@ -2389,7 +2436,7 @@ var Q = class extends Error {
|
|
|
2389
2436
|
}
|
|
2390
2437
|
}
|
|
2391
2438
|
watch(e) {
|
|
2392
|
-
let t =
|
|
2439
|
+
let t = Wt(e.runtime), n = () => {
|
|
2393
2440
|
let n = this.#i;
|
|
2394
2441
|
if (n === void 0 || !n.established || this.#n().runtime !== e.runtime) return;
|
|
2395
2442
|
if (n.subject !== this.#c(e).subjectSignal) {
|
|
@@ -2406,7 +2453,7 @@ var Q = class extends Error {
|
|
|
2406
2453
|
return n(), t?.subscribe(n) ?? (() => {});
|
|
2407
2454
|
}
|
|
2408
2455
|
#c(e) {
|
|
2409
|
-
return e.recovery ??
|
|
2456
|
+
return e.recovery ?? _t(e.errorBus, this.#e);
|
|
2410
2457
|
}
|
|
2411
2458
|
#l(e) {
|
|
2412
2459
|
if (this.#i !== e || e.controller.signal.aborted) throw new Q("inactive");
|
|
@@ -2442,7 +2489,7 @@ var Q = class extends Error {
|
|
|
2442
2489
|
let r = this.#u(e, t, n), i = r.descriptors[this.#t];
|
|
2443
2490
|
if (i?.kind !== "mutation" || i.idempotencyScope !== "connection") throw Error(`Voltro: useConnectionSetup("${this.#t}") requires a mutation declaring idempotencyScope: 'connection'`);
|
|
2444
2491
|
this.#d(e, r), this.#l(e);
|
|
2445
|
-
let a =
|
|
2492
|
+
let a = Wt(t);
|
|
2446
2493
|
if (a === void 0) throw new Q("connection-unavailable");
|
|
2447
2494
|
a.getSnapshot() === void 0 && await X(t, N.async((t) => {
|
|
2448
2495
|
let n = () => {
|
|
@@ -2475,13 +2522,13 @@ var Q = class extends Error {
|
|
|
2475
2522
|
#m(e, t) {
|
|
2476
2523
|
return N.suspend(() => {
|
|
2477
2524
|
let n = `setup_${e.key}_${++this.#o}`;
|
|
2478
|
-
return
|
|
2525
|
+
return Jn({
|
|
2479
2526
|
id: n,
|
|
2480
2527
|
apiName: this.#e,
|
|
2481
2528
|
tag: this.#t,
|
|
2482
2529
|
input: e.input
|
|
2483
|
-
}), N.suspend(() => (this.#u(e, t.runtime, t.client),
|
|
2484
|
-
if (P.isSuccess(e))
|
|
2530
|
+
}), N.suspend(() => (this.#u(e, t.runtime, t.client), sr(q(t.client, this.#t)(e.input), e.key))).pipe(N.withSpan(`client.connectionSetup.${this.#t}`)).pipe(N.onExit((e) => N.sync(() => {
|
|
2531
|
+
if (P.isSuccess(e)) Yn(n, {
|
|
2485
2532
|
status: "success",
|
|
2486
2533
|
output: e.value
|
|
2487
2534
|
}), t.errorBus.emitSuccess({
|
|
@@ -2490,11 +2537,11 @@ var Q = class extends Error {
|
|
|
2490
2537
|
});
|
|
2491
2538
|
else {
|
|
2492
2539
|
let r = M.squash(e.cause);
|
|
2493
|
-
if (
|
|
2540
|
+
if (Yn(n, {
|
|
2494
2541
|
status: "error",
|
|
2495
2542
|
error: r
|
|
2496
2543
|
}), !M.isInterruptedOnly(e.cause)) {
|
|
2497
|
-
let e =
|
|
2544
|
+
let e = V(r, "handler");
|
|
2498
2545
|
t.errorBus.emit({
|
|
2499
2546
|
source: "mutation",
|
|
2500
2547
|
tag: this.#t,
|
|
@@ -2515,10 +2562,10 @@ var Q = class extends Error {
|
|
|
2515
2562
|
} catch {}
|
|
2516
2563
|
}
|
|
2517
2564
|
}
|
|
2518
|
-
},
|
|
2565
|
+
}, Lr = (e, t) => {
|
|
2519
2566
|
let n = K(e), r = k(n);
|
|
2520
2567
|
r.current = n;
|
|
2521
|
-
let i = O(() => new
|
|
2568
|
+
let i = O(() => new Ir(e, t, () => r.current), [e, t]), a = E((n) => i.activate(n, () => Y(r, e, t)), [
|
|
2522
2569
|
i,
|
|
2523
2570
|
e,
|
|
2524
2571
|
t
|
|
@@ -2535,77 +2582,77 @@ var Q = class extends Error {
|
|
|
2535
2582
|
clear: i.clear,
|
|
2536
2583
|
ready: o.status === "ready"
|
|
2537
2584
|
};
|
|
2538
|
-
},
|
|
2539
|
-
useSubscription: (t, n, r) =>
|
|
2540
|
-
useMutation: (t) =>
|
|
2541
|
-
useConnectionSetup: (t) =>
|
|
2542
|
-
useAction: (t) =>
|
|
2543
|
-
useFormBinding: (t, n) =>
|
|
2544
|
-
}),
|
|
2545
|
-
|
|
2546
|
-
},
|
|
2547
|
-
let i =
|
|
2585
|
+
}, Rr = J, zr = (e) => ({
|
|
2586
|
+
useSubscription: (t, n, r) => Rr(e, t, n, r),
|
|
2587
|
+
useMutation: (t) => gr(e, t),
|
|
2588
|
+
useConnectionSetup: (t) => Lr(e, t),
|
|
2589
|
+
useAction: (t) => xr(e, t),
|
|
2590
|
+
useFormBinding: (t, n) => jr(e, t, n ?? {})
|
|
2591
|
+
}), Br = () => ({ seeds: [] }), Vr = null, Hr = (e) => {
|
|
2592
|
+
Vr = e;
|
|
2593
|
+
}, Ur = /* @__PURE__ */ new Map(), Wr = (e, t) => `${e}\u0000${t}`, Gr = (e, t, n, r) => {
|
|
2594
|
+
let i = Vr?.() ?? null;
|
|
2548
2595
|
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.)`);
|
|
2549
2596
|
i.seeds.push({
|
|
2550
2597
|
api: e,
|
|
2551
2598
|
key: W([t, n]),
|
|
2552
2599
|
value: r
|
|
2553
2600
|
});
|
|
2554
|
-
},
|
|
2555
|
-
let r =
|
|
2601
|
+
}, Kr = (e, t, n) => {
|
|
2602
|
+
let r = Vr?.() ?? null;
|
|
2556
2603
|
r !== null && r.seeds.push({
|
|
2557
2604
|
api: e,
|
|
2558
2605
|
key: W([t, n]),
|
|
2559
2606
|
value: void 0,
|
|
2560
2607
|
failed: !0
|
|
2561
2608
|
});
|
|
2562
|
-
},
|
|
2563
|
-
if (e !== void 0) for (let t of e)
|
|
2609
|
+
}, qr = (e) => {
|
|
2610
|
+
if (e !== void 0) for (let t of e) Ur.set(Wr(t.api, t.key), {
|
|
2564
2611
|
value: t.value,
|
|
2565
2612
|
failed: t.failed === !0
|
|
2566
2613
|
});
|
|
2567
|
-
},
|
|
2568
|
-
let r = W([t, n]), i =
|
|
2614
|
+
}, Jr = (e, t, n) => {
|
|
2615
|
+
let r = W([t, n]), i = Vr?.() ?? null;
|
|
2569
2616
|
if (i !== null) {
|
|
2570
2617
|
for (let t of i.seeds) if (t.api === e && t.key === r) return t.failed === !0 ? void 0 : t.value;
|
|
2571
2618
|
return;
|
|
2572
2619
|
}
|
|
2573
|
-
let a =
|
|
2620
|
+
let a = Ur.get(Wr(e, r));
|
|
2574
2621
|
return a === void 0 || a.failed ? void 0 : a.value;
|
|
2575
|
-
},
|
|
2576
|
-
let r = W([t, n]), i =
|
|
2622
|
+
}, Yr = (e, t, n) => {
|
|
2623
|
+
let r = W([t, n]), i = Vr?.() ?? null;
|
|
2577
2624
|
if (i !== null) {
|
|
2578
2625
|
for (let t of i.seeds) if (t.api === e && t.key === r) return t.failed === !0 ? "failed" : "seeded";
|
|
2579
2626
|
return "absent";
|
|
2580
2627
|
}
|
|
2581
|
-
let a =
|
|
2628
|
+
let a = Ur.get(Wr(e, r));
|
|
2582
2629
|
return a === void 0 ? "absent" : a.failed ? "failed" : "seeded";
|
|
2583
|
-
},
|
|
2584
|
-
|
|
2630
|
+
}, Xr = () => {
|
|
2631
|
+
Ur.clear();
|
|
2585
2632
|
};
|
|
2586
2633
|
//#endregion
|
|
2587
2634
|
//#region src/usePreloadedSubscription.ts
|
|
2588
|
-
function
|
|
2589
|
-
let i =
|
|
2635
|
+
function Zr(e, t, n = {}, r = {}) {
|
|
2636
|
+
let i = Jr(e, t, n), a = J(e, t, n, i === void 0 ? r : {
|
|
2590
2637
|
...r,
|
|
2591
2638
|
initialSnapshot: i
|
|
2592
2639
|
});
|
|
2593
|
-
return
|
|
2640
|
+
return Yr(e, t, n) === "failed" ? {
|
|
2594
2641
|
...a,
|
|
2595
2642
|
preloadFailed: !0
|
|
2596
2643
|
} : a;
|
|
2597
2644
|
}
|
|
2598
2645
|
//#endregion
|
|
2599
2646
|
//#region src/useEvent.ts
|
|
2600
|
-
var
|
|
2647
|
+
var Qr = {
|
|
2601
2648
|
status: "idle",
|
|
2602
2649
|
missed: 0,
|
|
2603
2650
|
lastMiss: void 0
|
|
2604
|
-
},
|
|
2651
|
+
}, $r = class {
|
|
2605
2652
|
_tag = "EventStreamClosed";
|
|
2606
2653
|
};
|
|
2607
|
-
function
|
|
2608
|
-
let { skip: i = !1, apiName: a = "app", onMissed: o } = r, s = K(a), { runtime: c, client: l } = s, [u, d] = A(
|
|
2654
|
+
function ei(e, t, n, r = {}) {
|
|
2655
|
+
let { skip: i = !1, apiName: a = "app", onMissed: o } = r, s = K(a), { runtime: c, client: l } = s, [u, d] = A(Qr), f = k(n);
|
|
2609
2656
|
f.current = n;
|
|
2610
2657
|
let p = k(o);
|
|
2611
2658
|
p.current = o;
|
|
@@ -2633,10 +2680,10 @@ function Gr(e, t, n, r = {}) {
|
|
|
2633
2680
|
count: t,
|
|
2634
2681
|
reason: n
|
|
2635
2682
|
}));
|
|
2636
|
-
}, [a, e.name]), x = !i && _ !== null && !
|
|
2683
|
+
}, [a, e.name]), x = !i && _ !== null && !Nt(s);
|
|
2637
2684
|
return D(() => {
|
|
2638
2685
|
if (!x) {
|
|
2639
|
-
d(
|
|
2686
|
+
d(Qr);
|
|
2640
2687
|
return;
|
|
2641
2688
|
}
|
|
2642
2689
|
d((e) => ({
|
|
@@ -2654,7 +2701,7 @@ function Gr(e, t, n, r = {}) {
|
|
|
2654
2701
|
});
|
|
2655
2702
|
}), r = R.unwrap(n).pipe(R.tap(() => N.sync(() => {
|
|
2656
2703
|
t = 0;
|
|
2657
|
-
})), R.concat(R.fail(new
|
|
2704
|
+
})), R.concat(R.fail(new $r())), R.retry(L.exponential("250 millis", 2).pipe(L.either(L.spaced("30 seconds")), L.jittered, L.tapOutput(() => N.sync(() => {
|
|
2658
2705
|
t += 1, d((e) => ({
|
|
2659
2706
|
...e,
|
|
2660
2707
|
status: "connecting"
|
|
@@ -2681,11 +2728,11 @@ function Gr(e, t, n, r = {}) {
|
|
|
2681
2728
|
_,
|
|
2682
2729
|
e.name,
|
|
2683
2730
|
b
|
|
2684
|
-
]), x ? u :
|
|
2731
|
+
]), x ? u : Qr;
|
|
2685
2732
|
}
|
|
2686
2733
|
//#endregion
|
|
2687
2734
|
//#region src/sequence.ts
|
|
2688
|
-
var
|
|
2735
|
+
var ti = () => {
|
|
2689
2736
|
let e = (t) => ({
|
|
2690
2737
|
steps: t,
|
|
2691
2738
|
step: ((n, r, i) => e([...t, {
|
|
@@ -2697,7 +2744,7 @@ var Kr = () => {
|
|
|
2697
2744
|
}]))
|
|
2698
2745
|
});
|
|
2699
2746
|
return e([]);
|
|
2700
|
-
},
|
|
2747
|
+
}, ni = async (e, t = {}) => {
|
|
2701
2748
|
let n = {}, r = [];
|
|
2702
2749
|
for (let i of e.steps) {
|
|
2703
2750
|
if (i.when !== void 0 && !i.when(n)) {
|
|
@@ -2757,13 +2804,13 @@ var Kr = () => {
|
|
|
2757
2804
|
ok: !0,
|
|
2758
2805
|
data: n
|
|
2759
2806
|
};
|
|
2760
|
-
},
|
|
2807
|
+
}, ri = (e = {}) => {
|
|
2761
2808
|
let [t, n] = A(!1), [r, i] = A(void 0), [a, o] = A(void 0), s = k(e);
|
|
2762
2809
|
return s.current = e, {
|
|
2763
2810
|
run: E(async (e, t = {}) => {
|
|
2764
2811
|
n(!0), i(void 0), o(void 0);
|
|
2765
2812
|
try {
|
|
2766
|
-
let n = await
|
|
2813
|
+
let n = await ni(e, {
|
|
2767
2814
|
...s.current,
|
|
2768
2815
|
...t
|
|
2769
2816
|
});
|
|
@@ -2776,7 +2823,7 @@ var Kr = () => {
|
|
|
2776
2823
|
error: r,
|
|
2777
2824
|
failedStep: a
|
|
2778
2825
|
};
|
|
2779
|
-
},
|
|
2826
|
+
}, ii = "@voltro/plugin-storage", $ = (e) => pe(ii, e), ai = (e, t, n, r) => new Promise((i, a) => {
|
|
2780
2827
|
let o = new XMLHttpRequest();
|
|
2781
2828
|
if (o.open("PUT", e), o.upload.onprogress = (e) => {
|
|
2782
2829
|
e.lengthComputable && n(e.loaded / e.total);
|
|
@@ -2790,7 +2837,7 @@ var Kr = () => {
|
|
|
2790
2837
|
return;
|
|
2791
2838
|
}
|
|
2792
2839
|
r.addEventListener("abort", () => o.abort(), { once: !0 }), o.send(t);
|
|
2793
|
-
}),
|
|
2840
|
+
}), oi = (e, t, n, r, i, a) => new Promise((o, s) => {
|
|
2794
2841
|
let c = new XMLHttpRequest();
|
|
2795
2842
|
if (c.open("POST", e), c.setRequestHeader("content-type", t), c.upload.onprogress = (e) => {
|
|
2796
2843
|
e.lengthComputable && r(e.loaded / e.total);
|
|
@@ -2808,7 +2855,7 @@ var Kr = () => {
|
|
|
2808
2855
|
return;
|
|
2809
2856
|
}
|
|
2810
2857
|
i.addEventListener("abort", () => c.abort(), { once: !0 }), c.send(n);
|
|
2811
|
-
}),
|
|
2858
|
+
}), si = (e, t, n, r, i) => new Promise((a, o) => {
|
|
2812
2859
|
let s = new XMLHttpRequest();
|
|
2813
2860
|
if (s.open("PUT", e), s.setRequestHeader("content-type", t), s.upload.onprogress = (e) => {
|
|
2814
2861
|
e.lengthComputable && r(e.loaded / e.total);
|
|
@@ -2819,7 +2866,7 @@ var Kr = () => {
|
|
|
2819
2866
|
return;
|
|
2820
2867
|
}
|
|
2821
2868
|
i.addEventListener("abort", () => s.abort(), { once: !0 }), s.send(n);
|
|
2822
|
-
}),
|
|
2869
|
+
}), ci = (e, t, n, r, i) => new Promise((a, o) => {
|
|
2823
2870
|
let s = new XMLHttpRequest();
|
|
2824
2871
|
if (s.open("POST", e), s.setRequestHeader("content-type", t), s.upload.onprogress = (e) => {
|
|
2825
2872
|
e.lengthComputable && r(e.loaded / e.total);
|
|
@@ -2835,7 +2882,7 @@ var Kr = () => {
|
|
|
2835
2882
|
return;
|
|
2836
2883
|
}
|
|
2837
2884
|
i.addEventListener("abort", () => s.abort(), { once: !0 }), s.send(n);
|
|
2838
|
-
}),
|
|
2885
|
+
}), li = (e, t = {}) => {
|
|
2839
2886
|
let n = K(e), { inspectBaseUrl: r } = n, i = k(n);
|
|
2840
2887
|
i.current = n;
|
|
2841
2888
|
let [a, o] = A(0), [s, c] = A("idle"), [l, u] = A(void 0), d = k(null), f = E(() => {
|
|
@@ -2864,7 +2911,7 @@ var Kr = () => {
|
|
|
2864
2911
|
contentType: u,
|
|
2865
2912
|
..._,
|
|
2866
2913
|
...p ? { key: p } : {}
|
|
2867
|
-
})), d = await
|
|
2914
|
+
})), d = await ci(m(l.uploadUrl), u, n, o, a);
|
|
2868
2915
|
return v(d);
|
|
2869
2916
|
}, b = async () => {
|
|
2870
2917
|
let e = r.presignMintTag ?? t.presignMintTag ?? $("mintPresignedUpload"), i = r.finalizeTag ?? t.finalizeTag ?? $("finalizeUpload"), l;
|
|
@@ -2877,7 +2924,7 @@ var Kr = () => {
|
|
|
2877
2924
|
} catch {
|
|
2878
2925
|
return null;
|
|
2879
2926
|
}
|
|
2880
|
-
await
|
|
2927
|
+
await si(l.uploadUrl, u, n, o, a);
|
|
2881
2928
|
let d = q(c, i), f = await X(s, d({ finalizeToken: l.finalizeToken }));
|
|
2882
2929
|
return v(f);
|
|
2883
2930
|
}, x = async () => {
|
|
@@ -2892,7 +2939,7 @@ var Kr = () => {
|
|
|
2892
2939
|
for (;;) {
|
|
2893
2940
|
if (a.aborted) throw new DOMException("upload aborted", "AbortError");
|
|
2894
2941
|
try {
|
|
2895
|
-
let t = await
|
|
2942
|
+
let t = await oi(`${p}?${`token=${encodeURIComponent(f.resumableToken)}&index=${e}${s ? "&final=1" : ""}`}`, u, i, (e) => o((b + e * c) / l), a, s);
|
|
2896
2943
|
s && (x = t);
|
|
2897
2944
|
break;
|
|
2898
2945
|
} catch (e) {
|
|
@@ -2926,7 +2973,7 @@ var Kr = () => {
|
|
|
2926
2973
|
let { url: e } = await X(s, v({
|
|
2927
2974
|
multipartToken: g.multipartToken,
|
|
2928
2975
|
partNumber: c
|
|
2929
|
-
})), t = await
|
|
2976
|
+
})), t = await ai(e, i, (e) => o((T + e * l) / p), a);
|
|
2930
2977
|
w.push({
|
|
2931
2978
|
partNumber: c,
|
|
2932
2979
|
etag: t
|
|
@@ -3001,8 +3048,8 @@ var Kr = () => {
|
|
|
3001
3048
|
source: "action",
|
|
3002
3049
|
tag: n.mintTag ?? t.mintTag ?? $("mintUploadTicket"),
|
|
3003
3050
|
error: e,
|
|
3004
|
-
kind:
|
|
3005
|
-
outcome:
|
|
3051
|
+
kind: V(e, "unknown"),
|
|
3052
|
+
outcome: V(e, "unknown") === "transport" ? "unknown" : "not-applicable"
|
|
3006
3053
|
}), e;
|
|
3007
3054
|
}
|
|
3008
3055
|
}, [h, t.mintTag]), _ = E(async (e, n = {}) => {
|
|
@@ -3025,8 +3072,8 @@ var Kr = () => {
|
|
|
3025
3072
|
source: "action",
|
|
3026
3073
|
tag: n.mintTag ?? t.mintTag ?? $("mintUploadTicket"),
|
|
3027
3074
|
error: e,
|
|
3028
|
-
kind:
|
|
3029
|
-
outcome:
|
|
3075
|
+
kind: V(e, "unknown"),
|
|
3076
|
+
outcome: V(e, "unknown") === "transport" ? "unknown" : "not-applicable"
|
|
3030
3077
|
}), e;
|
|
3031
3078
|
}
|
|
3032
3079
|
}, [
|
|
@@ -3069,8 +3116,8 @@ var Kr = () => {
|
|
|
3069
3116
|
y,
|
|
3070
3117
|
b
|
|
3071
3118
|
]);
|
|
3072
|
-
},
|
|
3073
|
-
let n =
|
|
3119
|
+
}, ui = (e, t) => {
|
|
3120
|
+
let n = li(e), r = xr(e, t.action), [i, a] = A("idle"), [o, s] = A(void 0), [c, l] = A(void 0), u = k(t.extra);
|
|
3074
3121
|
u.current = t.extra;
|
|
3075
3122
|
let d = E(async (e) => {
|
|
3076
3123
|
l(void 0), s(void 0), a("uploading");
|
|
@@ -3113,7 +3160,7 @@ var Kr = () => {
|
|
|
3113
3160
|
f,
|
|
3114
3161
|
p
|
|
3115
3162
|
]);
|
|
3116
|
-
},
|
|
3163
|
+
}, di = async (e) => {
|
|
3117
3164
|
let t = q(e.client, e.tag), n = N.currentSpan.pipe(N.tap((t) => N.sync(() => {
|
|
3118
3165
|
ye({
|
|
3119
3166
|
traceId: t.traceId,
|
|
@@ -3126,7 +3173,7 @@ var Kr = () => {
|
|
|
3126
3173
|
"rpc.tag": e.tag
|
|
3127
3174
|
} }));
|
|
3128
3175
|
return X(e.runtime, n);
|
|
3129
|
-
},
|
|
3176
|
+
}, fi = (e, t) => {
|
|
3130
3177
|
let n = K(e), { descriptors: r } = n, i = k(n);
|
|
3131
3178
|
if (i.current = n, process.env.NODE_ENV !== "production") {
|
|
3132
3179
|
let n = r[t]?.kind;
|
|
@@ -3135,7 +3182,7 @@ var Kr = () => {
|
|
|
3135
3182
|
let [a, o] = A(!1), [s, c] = A(void 0), [l, u] = A(void 0), d = E(async (n) => {
|
|
3136
3183
|
o(!0), c(void 0);
|
|
3137
3184
|
try {
|
|
3138
|
-
let { runtime: r, client: a } = await Y(i, e, t), o = await
|
|
3185
|
+
let { runtime: r, client: a } = await Y(i, e, t), o = await di({
|
|
3139
3186
|
apiName: e,
|
|
3140
3187
|
runtime: r,
|
|
3141
3188
|
client: a,
|
|
@@ -3151,7 +3198,7 @@ var Kr = () => {
|
|
|
3151
3198
|
}
|
|
3152
3199
|
}, [e, t]), f = E(async (t) => {
|
|
3153
3200
|
let { runtime: n, client: r } = await Y(i, e, "__voltro.workflow.cancel");
|
|
3154
|
-
await
|
|
3201
|
+
await di({
|
|
3155
3202
|
apiName: e,
|
|
3156
3203
|
runtime: n,
|
|
3157
3204
|
client: r,
|
|
@@ -3161,7 +3208,7 @@ var Kr = () => {
|
|
|
3161
3208
|
});
|
|
3162
3209
|
}, [e]), p = E(async (t) => {
|
|
3163
3210
|
let { runtime: n, client: r } = await Y(i, e, "__voltro.workflow.resume");
|
|
3164
|
-
await
|
|
3211
|
+
await di({
|
|
3165
3212
|
apiName: e,
|
|
3166
3213
|
runtime: n,
|
|
3167
3214
|
client: r,
|
|
@@ -3171,7 +3218,7 @@ var Kr = () => {
|
|
|
3171
3218
|
});
|
|
3172
3219
|
}, [e]), m = E(async (t, n, r) => {
|
|
3173
3220
|
let { runtime: a, client: o } = await Y(i, e, "__voltro.workflow.signal");
|
|
3174
|
-
return
|
|
3221
|
+
return di({
|
|
3175
3222
|
apiName: e,
|
|
3176
3223
|
runtime: a,
|
|
3177
3224
|
client: o,
|
|
@@ -3185,7 +3232,7 @@ var Kr = () => {
|
|
|
3185
3232
|
});
|
|
3186
3233
|
}, [e]), h = E(async (t, n, r, a) => {
|
|
3187
3234
|
let { runtime: o, client: s } = await Y(i, e, "__voltro.workflow.update");
|
|
3188
|
-
return
|
|
3235
|
+
return di({
|
|
3189
3236
|
apiName: e,
|
|
3190
3237
|
runtime: o,
|
|
3191
3238
|
client: s,
|
|
@@ -3218,13 +3265,13 @@ var Kr = () => {
|
|
|
3218
3265
|
s,
|
|
3219
3266
|
l
|
|
3220
3267
|
]);
|
|
3221
|
-
},
|
|
3268
|
+
}, pi = (e) => {
|
|
3222
3269
|
let t = K(e), n = k(t);
|
|
3223
3270
|
n.current = t;
|
|
3224
3271
|
let [r, i] = A(!1), [a, o] = A(void 0), [s, c] = A(void 0), l = E(async (t, r, a) => {
|
|
3225
3272
|
i(!0), o(void 0);
|
|
3226
3273
|
try {
|
|
3227
|
-
let { runtime: i, client: o } = await Y(n, e, "__voltro.workflow.signal"), s = await
|
|
3274
|
+
let { runtime: i, client: o } = await Y(n, e, "__voltro.workflow.signal"), s = await di({
|
|
3228
3275
|
apiName: e,
|
|
3229
3276
|
runtime: i,
|
|
3230
3277
|
client: o,
|
|
@@ -3254,13 +3301,13 @@ var Kr = () => {
|
|
|
3254
3301
|
a,
|
|
3255
3302
|
s
|
|
3256
3303
|
]);
|
|
3257
|
-
},
|
|
3304
|
+
}, mi = (e) => {
|
|
3258
3305
|
let t = K(e), n = k(t);
|
|
3259
3306
|
n.current = t;
|
|
3260
3307
|
let [r, i] = A(!1), [a, o] = A(void 0), [s, c] = A(void 0), l = E(async (t, r, a, s) => {
|
|
3261
3308
|
i(!0), o(void 0);
|
|
3262
3309
|
try {
|
|
3263
|
-
let { runtime: i, client: o } = await Y(n, e, "__voltro.workflow.update"), l = await
|
|
3310
|
+
let { runtime: i, client: o } = await Y(n, e, "__voltro.workflow.update"), l = await di({
|
|
3264
3311
|
apiName: e,
|
|
3265
3312
|
runtime: i,
|
|
3266
3313
|
client: o,
|
|
@@ -3291,7 +3338,7 @@ var Kr = () => {
|
|
|
3291
3338
|
a,
|
|
3292
3339
|
s
|
|
3293
3340
|
]);
|
|
3294
|
-
},
|
|
3341
|
+
}, hi = (e, t) => {
|
|
3295
3342
|
let n = J(e, "__voltro.workflow.run", t ? { id: t } : {}, { skip: t === void 0 });
|
|
3296
3343
|
return n.loading || n.idle || n.failed ? {
|
|
3297
3344
|
...n,
|
|
@@ -3300,7 +3347,7 @@ var Kr = () => {
|
|
|
3300
3347
|
...n,
|
|
3301
3348
|
run: n.data[0]
|
|
3302
3349
|
};
|
|
3303
|
-
},
|
|
3350
|
+
}, gi = (e, t = {}, n = {}) => {
|
|
3304
3351
|
let r = J(e, "__voltro.workflow.runs", t, n);
|
|
3305
3352
|
return r.loading || r.idle || r.failed ? {
|
|
3306
3353
|
...r,
|
|
@@ -3309,7 +3356,7 @@ var Kr = () => {
|
|
|
3309
3356
|
...r,
|
|
3310
3357
|
runs: r.data
|
|
3311
3358
|
};
|
|
3312
|
-
},
|
|
3359
|
+
}, _i = (e, t) => {
|
|
3313
3360
|
let n = J(e, "__voltro.workflow.run.steps", t ? { runId: t } : {}, { skip: t === void 0 });
|
|
3314
3361
|
return n.loading || n.idle || n.failed ? {
|
|
3315
3362
|
...n,
|
|
@@ -3318,7 +3365,7 @@ var Kr = () => {
|
|
|
3318
3365
|
...n,
|
|
3319
3366
|
steps: n.data
|
|
3320
3367
|
};
|
|
3321
|
-
},
|
|
3368
|
+
}, vi = (e, t) => {
|
|
3322
3369
|
let n = J(e, "__voltro.workflow.run.events", t ? { runId: t } : {}, { skip: t === void 0 });
|
|
3323
3370
|
return n.loading || n.idle || n.failed ? {
|
|
3324
3371
|
...n,
|
|
@@ -3327,7 +3374,7 @@ var Kr = () => {
|
|
|
3327
3374
|
...n,
|
|
3328
3375
|
events: n.data
|
|
3329
3376
|
};
|
|
3330
|
-
},
|
|
3377
|
+
}, yi = vi, bi = (e, t = {}, n = {}) => {
|
|
3331
3378
|
let r = J(e, "__voltro.workflow.domainEvents", t, n);
|
|
3332
3379
|
return r.loading || r.idle || r.failed ? {
|
|
3333
3380
|
...r,
|
|
@@ -3336,7 +3383,7 @@ var Kr = () => {
|
|
|
3336
3383
|
...r,
|
|
3337
3384
|
events: r.data
|
|
3338
3385
|
};
|
|
3339
|
-
},
|
|
3386
|
+
}, xi = (e, t) => {
|
|
3340
3387
|
let n = J(e, "__voltro.workflow.event.deliveries", t ? { eventId: t } : {}, { skip: t === void 0 });
|
|
3341
3388
|
return n.loading || n.idle || n.failed ? {
|
|
3342
3389
|
...n,
|
|
@@ -3345,42 +3392,42 @@ var Kr = () => {
|
|
|
3345
3392
|
...n,
|
|
3346
3393
|
deliveries: n.data
|
|
3347
3394
|
};
|
|
3348
|
-
},
|
|
3395
|
+
}, Si = (e, t) => {
|
|
3349
3396
|
let n = e.payload;
|
|
3350
3397
|
if (!n || typeof n != "object") return;
|
|
3351
3398
|
let r = n[t];
|
|
3352
3399
|
return typeof r == "string" ? r : void 0;
|
|
3353
|
-
},
|
|
3400
|
+
}, Ci = (e) => {
|
|
3354
3401
|
let t = e.payload;
|
|
3355
3402
|
if (!t || typeof t != "object") return;
|
|
3356
3403
|
let n = t.updateId;
|
|
3357
3404
|
return typeof n == "string" ? n : void 0;
|
|
3358
|
-
},
|
|
3405
|
+
}, wi = (e) => {
|
|
3359
3406
|
let t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set();
|
|
3360
3407
|
for (let r of e) if (r.eventType === "signal-received") {
|
|
3361
|
-
let e =
|
|
3408
|
+
let e = Si(r, "signalName");
|
|
3362
3409
|
e && t.add(e);
|
|
3363
3410
|
} else if (r.eventType === "update-completed" || r.eventType === "update-failed") {
|
|
3364
|
-
let e =
|
|
3411
|
+
let e = Ci(r);
|
|
3365
3412
|
e && n.add(e);
|
|
3366
3413
|
}
|
|
3367
3414
|
for (let r = e.length - 1; r >= 0; --r) {
|
|
3368
3415
|
let i = e[r];
|
|
3369
3416
|
if (i.eventType === "signal-awaited") {
|
|
3370
|
-
let e =
|
|
3417
|
+
let e = Si(i, "signalName");
|
|
3371
3418
|
if (e && !t.has(e)) return {
|
|
3372
3419
|
name: e,
|
|
3373
3420
|
kind: "signal"
|
|
3374
3421
|
};
|
|
3375
3422
|
} else if (i.eventType === "update-requested") {
|
|
3376
|
-
let e =
|
|
3423
|
+
let e = Ci(i), t = Si(i, "updateName");
|
|
3377
3424
|
if (t && (!e || !n.has(e))) return {
|
|
3378
3425
|
name: t,
|
|
3379
3426
|
kind: "update"
|
|
3380
3427
|
};
|
|
3381
3428
|
}
|
|
3382
3429
|
}
|
|
3383
|
-
},
|
|
3430
|
+
}, Ti = (e) => e.find((e) => e.status === "running") || (e.length > 0 ? e[e.length - 1] : void 0), Ei = (e, t) => {
|
|
3384
3431
|
if (!e || e.status !== "failed") return;
|
|
3385
3432
|
let n = t.find((e) => e.status === "failed");
|
|
3386
3433
|
return {
|
|
@@ -3388,8 +3435,8 @@ var Kr = () => {
|
|
|
3388
3435
|
message: e.errorMessage,
|
|
3389
3436
|
step: n?.stepName
|
|
3390
3437
|
};
|
|
3391
|
-
},
|
|
3392
|
-
let n =
|
|
3438
|
+
}, Di = (e, t) => {
|
|
3439
|
+
let n = hi(e, t), r = _i(e, t), i = vi(e, t), a = fi(e, n.run?.tag ?? ""), o = n.run, s = r.steps, c = i.events, l = E(async () => {
|
|
3393
3440
|
if (!o) throw Error("useWorkflowRunState: no run loaded — cannot cancel");
|
|
3394
3441
|
await a.cancel({
|
|
3395
3442
|
workflowName: o.tag,
|
|
@@ -3413,9 +3460,9 @@ var Kr = () => {
|
|
|
3413
3460
|
status: o?.status,
|
|
3414
3461
|
steps: s,
|
|
3415
3462
|
events: c,
|
|
3416
|
-
currentStep:
|
|
3417
|
-
waitingFor: o?.status === "suspended" ?
|
|
3418
|
-
error:
|
|
3463
|
+
currentStep: Ti(s),
|
|
3464
|
+
waitingFor: o?.status === "suspended" ? wi(c) : void 0,
|
|
3465
|
+
error: Ei(o, s),
|
|
3419
3466
|
traceId: o?.traceId,
|
|
3420
3467
|
loading: n.data === void 0,
|
|
3421
3468
|
cancel: l,
|
|
@@ -3432,7 +3479,7 @@ var Kr = () => {
|
|
|
3432
3479
|
d,
|
|
3433
3480
|
f
|
|
3434
3481
|
]);
|
|
3435
|
-
},
|
|
3482
|
+
}, Oi = (e, t) => {
|
|
3436
3483
|
let { runtime: n, client: r } = K(e), [i, a] = A([]), [o, s] = A("idle"), [c, l] = A(void 0), u = k(null), d = E(() => {
|
|
3437
3484
|
let e = u.current;
|
|
3438
3485
|
e && (u.current = null, n.runFork(ie.interrupt(e)), s((e) => e === "streaming" ? "idle" : e));
|
|
@@ -3460,7 +3507,7 @@ var Kr = () => {
|
|
|
3460
3507
|
]),
|
|
3461
3508
|
cancel: d
|
|
3462
3509
|
};
|
|
3463
|
-
},
|
|
3510
|
+
}, ki = (e, t, n, r) => {
|
|
3464
3511
|
let i = 0, a = !1, o = (e) => N.sync(() => {
|
|
3465
3512
|
e.seq <= i || (i = e.seq, n.onEvent(e.event), r.isTerminal(e.event) && (a = !0));
|
|
3466
3513
|
}), s = (e) => {
|
|
@@ -3487,15 +3534,15 @@ var Kr = () => {
|
|
|
3487
3534
|
}));
|
|
3488
3535
|
});
|
|
3489
3536
|
return u(0);
|
|
3490
|
-
},
|
|
3537
|
+
}, Ai = (e) => {
|
|
3491
3538
|
let t = e?._tag;
|
|
3492
3539
|
return t === "done" || t === "error";
|
|
3493
|
-
},
|
|
3540
|
+
}, ji = (e, t, n = {}) => {
|
|
3494
3541
|
let { runtime: r, client: i } = K(e), [a, o] = A([]), [s, c] = A("idle"), [l, u] = A(0), [d, f] = A(void 0), p = k(null), m = {
|
|
3495
3542
|
maxReconnects: n.maxReconnects ?? 6,
|
|
3496
3543
|
backoffMs: n.backoffMs ?? 400,
|
|
3497
3544
|
maxBackoffMs: n.maxBackoffMs ?? 8e3,
|
|
3498
|
-
isTerminal: n.isTerminal ??
|
|
3545
|
+
isTerminal: n.isTerminal ?? Ai
|
|
3499
3546
|
}, h = E(() => {
|
|
3500
3547
|
let e = p.current;
|
|
3501
3548
|
e && (p.current = null, r.runFork(ie.interrupt(e)), c((e) => e === "streaming" || e === "reconnecting" ? "idle" : e));
|
|
@@ -3514,7 +3561,7 @@ var Kr = () => {
|
|
|
3514
3561
|
onReconnect: () => u((e) => e + 1),
|
|
3515
3562
|
onError: f
|
|
3516
3563
|
};
|
|
3517
|
-
p.current = r.runFork(
|
|
3564
|
+
p.current = r.runFork(ki(a, e, s, m));
|
|
3518
3565
|
}, [
|
|
3519
3566
|
r,
|
|
3520
3567
|
i,
|
|
@@ -3526,13 +3573,13 @@ var Kr = () => {
|
|
|
3526
3573
|
]),
|
|
3527
3574
|
cancel: h
|
|
3528
3575
|
};
|
|
3529
|
-
},
|
|
3576
|
+
}, Mi = (e, t) => e.order - t.order || (e.stepOrder ?? 0) - (t.stepOrder ?? 0), Ni = (e) => {
|
|
3530
3577
|
for (let t = e.length - 1; t >= 0; --t) {
|
|
3531
3578
|
let n = e[t];
|
|
3532
3579
|
if (n.role === "user" && n.content) return n.content;
|
|
3533
3580
|
}
|
|
3534
|
-
},
|
|
3535
|
-
let { threadId: r } = n, i = J(e, `${t}.messages`, { threadId: r }), a =
|
|
3581
|
+
}, Pi = (e, t, n) => {
|
|
3582
|
+
let { threadId: r } = n, i = J(e, `${t}.messages`, { threadId: r }), a = xr(e, `${t}.send`), o = O(() => [...i.data ?? []].sort(Mi), [i.data]), s = E((e, t = {}) => a.run({
|
|
3536
3583
|
threadId: r,
|
|
3537
3584
|
order: i.data?.length ?? 0,
|
|
3538
3585
|
prompt: e,
|
|
@@ -3542,7 +3589,7 @@ var Kr = () => {
|
|
|
3542
3589
|
r,
|
|
3543
3590
|
i.data
|
|
3544
3591
|
]), c = E(() => {
|
|
3545
|
-
let e =
|
|
3592
|
+
let e = Ni(o);
|
|
3546
3593
|
return e === void 0 ? void 0 : s(e);
|
|
3547
3594
|
}, [o, s]);
|
|
3548
3595
|
return O(() => ({
|
|
@@ -3562,8 +3609,8 @@ var Kr = () => {
|
|
|
3562
3609
|
s,
|
|
3563
3610
|
c
|
|
3564
3611
|
]);
|
|
3565
|
-
},
|
|
3566
|
-
let { events: n, status: r, error: i, start: a, cancel: o } =
|
|
3612
|
+
}, Fi = (e, t) => {
|
|
3613
|
+
let { events: n, status: r, error: i, start: a, cancel: o } = Oi(e, t), [s, c] = A([]), l = k(null), u = O(() => n.filter((e) => e._tag === "token").map((e) => e.text ?? "").join(""), [n]);
|
|
3567
3614
|
return D(() => {
|
|
3568
3615
|
if (r !== "done" || l.current === null) return;
|
|
3569
3616
|
let e = l.current;
|
|
@@ -3589,8 +3636,8 @@ var Kr = () => {
|
|
|
3589
3636
|
}, [a]),
|
|
3590
3637
|
cancel: o
|
|
3591
3638
|
};
|
|
3592
|
-
},
|
|
3593
|
-
let n =
|
|
3639
|
+
}, Ii = (e, t) => {
|
|
3640
|
+
let n = xr(e, t), [r, i] = A(void 0), a = E(async (e) => {
|
|
3594
3641
|
let t = await n.run({ question: e });
|
|
3595
3642
|
return i(t), t;
|
|
3596
3643
|
}, [n]), o = E(() => i(void 0), []);
|
|
@@ -3607,14 +3654,14 @@ var Kr = () => {
|
|
|
3607
3654
|
n.error,
|
|
3608
3655
|
o
|
|
3609
3656
|
]);
|
|
3610
|
-
},
|
|
3657
|
+
}, Li = (e) => {
|
|
3611
3658
|
let { cache: t, runtime: n } = K(e);
|
|
3612
3659
|
return E(() => {
|
|
3613
3660
|
t.refreshAll(n);
|
|
3614
3661
|
}, [t, n]);
|
|
3615
|
-
},
|
|
3662
|
+
}, Ri = (e) => e?._tag === "Unauthenticated", zi = (e, t, n = {}) => {
|
|
3616
3663
|
let r = n.cooldownMs ?? 15e3, i = n.maxConsecutive ?? 3, a = n.now ?? (() => Date.now()), o = -Infinity, s = 0, c = e.on((e) => {
|
|
3617
|
-
if (!
|
|
3664
|
+
if (!Ri(e.error) || s >= i) return;
|
|
3618
3665
|
let n = a();
|
|
3619
3666
|
n - o < r || (o = n, s += 1, t());
|
|
3620
3667
|
}), l = e.onSuccess(() => {
|
|
@@ -3628,21 +3675,21 @@ var Kr = () => {
|
|
|
3628
3675
|
s = 0;
|
|
3629
3676
|
}
|
|
3630
3677
|
};
|
|
3631
|
-
},
|
|
3632
|
-
let n = K(e), r = n.recovery ??
|
|
3678
|
+
}, Bi = (e, t) => {
|
|
3679
|
+
let n = K(e), r = n.recovery ?? _t(n.errorBus, e), i = k(t);
|
|
3633
3680
|
i.current = t, D(() => r.onVisibleError((e) => i.current(e)), [r]);
|
|
3634
|
-
},
|
|
3681
|
+
}, Vi = (e, t) => {
|
|
3635
3682
|
let { errorBus: n } = K(e), r = k(t);
|
|
3636
3683
|
r.current = t, D(() => n.on((e) => r.current(e)), [n]);
|
|
3637
|
-
},
|
|
3684
|
+
}, Hi = {
|
|
3638
3685
|
failed: [],
|
|
3639
3686
|
healthy: !0
|
|
3640
|
-
},
|
|
3641
|
-
let { errorBus: t } = K(e), [n, r] = A(
|
|
3687
|
+
}, Ui = (e) => {
|
|
3688
|
+
let { errorBus: t } = K(e), [n, r] = A(Hi);
|
|
3642
3689
|
return D(() => {
|
|
3643
3690
|
let e = /* @__PURE__ */ new Map(), n = () => {
|
|
3644
3691
|
let t = [...e.values()].sort((e, t) => t.at - e.at);
|
|
3645
|
-
r(t.length === 0 ?
|
|
3692
|
+
r(t.length === 0 ? Hi : {
|
|
3646
3693
|
failed: t,
|
|
3647
3694
|
healthy: !1
|
|
3648
3695
|
});
|
|
@@ -3660,16 +3707,16 @@ var Kr = () => {
|
|
|
3660
3707
|
i(), a();
|
|
3661
3708
|
};
|
|
3662
3709
|
}, [t]), n;
|
|
3663
|
-
},
|
|
3710
|
+
}, Wi = (e, t) => {
|
|
3664
3711
|
let n = globalThis, r = Symbol.for(`@voltro/web/context:${e}`), i = n[r];
|
|
3665
3712
|
if (i) return i;
|
|
3666
3713
|
let a = w(t);
|
|
3667
3714
|
return n[r] = a, a;
|
|
3668
|
-
},
|
|
3715
|
+
}, Gi = Wi("serverRequest", null), Ki = () => ee(Gi), qi = ({ value: e, children: t }) => /* @__PURE__ */ me(Gi.Provider, {
|
|
3669
3716
|
value: e,
|
|
3670
3717
|
children: t
|
|
3671
|
-
}),
|
|
3672
|
-
let t =
|
|
3718
|
+
}), Ji = (e) => {
|
|
3719
|
+
let t = Ki();
|
|
3673
3720
|
return O(() => {
|
|
3674
3721
|
if (t !== null) return t.formFlash?.formKey === e ? t.formFlash : void 0;
|
|
3675
3722
|
if (typeof document > "u") return;
|
|
@@ -3681,13 +3728,13 @@ var Kr = () => {
|
|
|
3681
3728
|
return;
|
|
3682
3729
|
}
|
|
3683
3730
|
}, [t, e]);
|
|
3684
|
-
},
|
|
3731
|
+
}, Yi = (e, t, n) => e.map((e) => {
|
|
3685
3732
|
let r = String(e[n] ?? ""), i = e[t];
|
|
3686
3733
|
return {
|
|
3687
3734
|
value: r,
|
|
3688
3735
|
label: i == null ? r : String(i)
|
|
3689
3736
|
};
|
|
3690
|
-
}),
|
|
3737
|
+
}), Xi = (e, t, n = {}) => {
|
|
3691
3738
|
let r = n.debounceMs ?? 200, i = n.labelField ?? "name", a = n.valueField ?? "id", o = n.input ?? ((e) => ({ q: e })), [s, c] = A(n.initialTerm ?? ""), [l, u] = A(s);
|
|
3692
3739
|
D(() => {
|
|
3693
3740
|
if (s === l) return;
|
|
@@ -3698,7 +3745,7 @@ var Kr = () => {
|
|
|
3698
3745
|
l,
|
|
3699
3746
|
r
|
|
3700
3747
|
]);
|
|
3701
|
-
let d = n.skipUntilTerm === !0 && l.trim() === "", f = J(e, t, O(() => o(l), [o, l]), { skip: d }), p = O(() =>
|
|
3748
|
+
let d = n.skipUntilTerm === !0 && l.trim() === "", f = J(e, t, O(() => o(l), [o, l]), { skip: d }), p = O(() => Yi(f.data ?? [], i, a), [
|
|
3702
3749
|
f.data,
|
|
3703
3750
|
i,
|
|
3704
3751
|
a
|
|
@@ -3709,7 +3756,7 @@ var Kr = () => {
|
|
|
3709
3756
|
term: s,
|
|
3710
3757
|
search: m
|
|
3711
3758
|
};
|
|
3712
|
-
},
|
|
3759
|
+
}, Zi = (e, t) => e === t ? 0 : e == null ? 1 : t == null || e < t ? -1 : 1, Qi = (t, n, r = {}) => {
|
|
3713
3760
|
let i = K(t), [a, o] = A(r.pageSize), s = J(t, n, O(() => a === void 0 ? r.input ?? {} : {
|
|
3714
3761
|
...r.input,
|
|
3715
3762
|
limit: a
|
|
@@ -3730,7 +3777,7 @@ var Kr = () => {
|
|
|
3730
3777
|
let e = s.data ?? [];
|
|
3731
3778
|
if (d === void 0) return e;
|
|
3732
3779
|
let t = d.direction === "asc" ? 1 : -1;
|
|
3733
|
-
return [...e].sort((e, n) =>
|
|
3780
|
+
return [...e].sort((e, n) => Zi(e[d.column], n[d.column]) * t);
|
|
3734
3781
|
}, [s.data, d]),
|
|
3735
3782
|
loading: s.data === void 0,
|
|
3736
3783
|
error: s.error,
|
|
@@ -3739,13 +3786,13 @@ var Kr = () => {
|
|
|
3739
3786
|
loadMore: l,
|
|
3740
3787
|
hasMore: a !== void 0 && (s.data?.length ?? 0) >= a
|
|
3741
3788
|
};
|
|
3742
|
-
},
|
|
3789
|
+
}, $i = (e, t, n, r) => {
|
|
3743
3790
|
let i = e.replace(/\/$/, ""), a = new URLSearchParams({
|
|
3744
3791
|
table: t,
|
|
3745
3792
|
id: n
|
|
3746
3793
|
});
|
|
3747
3794
|
return r !== void 0 && a.set("column", r), `${i}/_voltro/inspect/provenance?${a.toString()}`;
|
|
3748
|
-
},
|
|
3795
|
+
}, ea = $i, ta = (e, t, n, r) => {
|
|
3749
3796
|
let { inspectBaseUrl: i } = K(e), [a, o] = A({
|
|
3750
3797
|
data: void 0,
|
|
3751
3798
|
loading: !0,
|
|
@@ -3758,7 +3805,7 @@ var Kr = () => {
|
|
|
3758
3805
|
loading: !0,
|
|
3759
3806
|
error: void 0
|
|
3760
3807
|
});
|
|
3761
|
-
let a =
|
|
3808
|
+
let a = $i(i ?? "", t, n, r);
|
|
3762
3809
|
return fetch(a).then(async (e) => {
|
|
3763
3810
|
if (!e.ok) throw Error(`provenance fetch failed: HTTP ${e.status}`);
|
|
3764
3811
|
return await e.json();
|
|
@@ -3784,11 +3831,11 @@ var Kr = () => {
|
|
|
3784
3831
|
n,
|
|
3785
3832
|
r
|
|
3786
3833
|
]), a;
|
|
3787
|
-
},
|
|
3788
|
-
function
|
|
3789
|
-
return T(
|
|
3834
|
+
}, na = "admin:full", ra = (e, t) => e.includes("admin:full") ? !0 : (typeof t == "string" ? [t] : t).every((t) => e.includes(t)), ia = (e, t) => t.length === 0 || e.includes("admin:full") ? !0 : t.some((t) => e.includes(t)), aa = w({ scopes: [] });
|
|
3835
|
+
function oa(e) {
|
|
3836
|
+
return T(aa.Provider, { value: { scopes: e.scopes } }, e.children);
|
|
3790
3837
|
}
|
|
3791
|
-
var
|
|
3838
|
+
var sa = () => ee(aa), ca = (e) => ra(sa().scopes, e), la = (e) => ia(sa().scopes, e), ua = (e) => `${e.replace(/\/$/, "")}/_voltro/inspect/manifest`, da = (e) => {
|
|
3792
3839
|
let { inspectBaseUrl: t } = K(e), [n, r] = A({
|
|
3793
3840
|
manifest: void 0,
|
|
3794
3841
|
loading: !0,
|
|
@@ -3800,7 +3847,7 @@ var Qi = () => ee(Xi), $i = (e) => Ji(Qi().scopes, e), ea = (e) => Yi(Qi().scope
|
|
|
3800
3847
|
manifest: void 0,
|
|
3801
3848
|
loading: !0,
|
|
3802
3849
|
error: void 0
|
|
3803
|
-
}), fetch(
|
|
3850
|
+
}), fetch(ua(t ?? "")).then(async (e) => {
|
|
3804
3851
|
if (!e.ok) throw Error(`manifest fetch failed: HTTP ${e.status}`);
|
|
3805
3852
|
return await e.json();
|
|
3806
3853
|
}).then((t) => {
|
|
@@ -3819,7 +3866,7 @@ var Qi = () => ee(Xi), $i = (e) => Ji(Qi().scopes, e), ea = (e) => Yi(Qi().scope
|
|
|
3819
3866
|
e = !0;
|
|
3820
3867
|
};
|
|
3821
3868
|
}, [e, t]), n;
|
|
3822
|
-
},
|
|
3869
|
+
}, fa = (e, t) => t.scope.length === 0 || (t.mode === "any" ? t.scope.some((t) => e.includes(t)) : t.scope.every((t) => e.includes(t))), pa = (e, t) => {
|
|
3823
3870
|
if (e === void 0) return "unknown";
|
|
3824
3871
|
if (t.includes("admin:full") || e.length === 0) return "allowed";
|
|
3825
3872
|
let n = !1;
|
|
@@ -3828,7 +3875,7 @@ var Qi = () => ee(Xi), $i = (e) => Ji(Qi().scopes, e), ea = (e) => Yi(Qi().scope
|
|
|
3828
3875
|
n = !0;
|
|
3829
3876
|
continue;
|
|
3830
3877
|
}
|
|
3831
|
-
if (!
|
|
3878
|
+
if (!fa(t, r)) {
|
|
3832
3879
|
if (r.resourceScoped) {
|
|
3833
3880
|
n = !0;
|
|
3834
3881
|
continue;
|
|
@@ -3837,13 +3884,13 @@ var Qi = () => ee(Xi), $i = (e) => Ji(Qi().scopes, e), ea = (e) => Yi(Qi().scope
|
|
|
3837
3884
|
}
|
|
3838
3885
|
}
|
|
3839
3886
|
return n ? "unknown" : "allowed";
|
|
3840
|
-
},
|
|
3887
|
+
}, ma = (e) => (e ?? []).flatMap((e) => e.kind === "scope" ? [...e.scope] : []), ha = (e) => {
|
|
3841
3888
|
for (let t of e ?? []) if (t.kind === "open") return t.reason;
|
|
3842
|
-
},
|
|
3889
|
+
}, ga = (e) => pa(e, sa().scopes), _a = (e, t) => Array.isArray(e) ? e.includes(t) : e === t, va = (e, t, n) => e.targets?.some((e) => e.table === t && e.op === n) ?? !1, ya = (e) => e === void 0 ? {} : {
|
|
3843
3890
|
tag: e.tag,
|
|
3844
3891
|
...e.guards === void 0 ? {} : { guards: e.guards }
|
|
3845
|
-
},
|
|
3846
|
-
let n = e.procedures.find((e) => e.kind === "query" &&
|
|
3892
|
+
}, ba = (e) => e.tables.filter((e) => !e.framework).map((t) => {
|
|
3893
|
+
let n = e.procedures.find((e) => e.kind === "query" && _a(e.source, t.name)), r = e.procedures.find((e) => e.kind === "mutation" && va(e, t.name, "insert")), i = e.procedures.find((e) => e.kind === "mutation" && va(e, t.name, "update")), a = e.procedures.find((e) => e.kind === "mutation" && va(e, t.name, "delete")), o = t.pkColumn ?? (t.columns.some((e) => e.name === "id") ? "id" : void 0);
|
|
3847
3894
|
return {
|
|
3848
3895
|
table: t.name,
|
|
3849
3896
|
columns: t.columns.filter((e) => e.serverOnly !== !0),
|
|
@@ -3852,12 +3899,12 @@ var Qi = () => ee(Xi), $i = (e) => Ji(Qi().scopes, e), ea = (e) => Yi(Qi().scope
|
|
|
3852
3899
|
reactive: t.reactive,
|
|
3853
3900
|
...o === void 0 ? {} : { pkColumn: o },
|
|
3854
3901
|
editable: (t.editable ?? !0) && o !== void 0,
|
|
3855
|
-
list:
|
|
3856
|
-
create:
|
|
3857
|
-
update:
|
|
3858
|
-
delete:
|
|
3902
|
+
list: ya(n),
|
|
3903
|
+
create: ya(r),
|
|
3904
|
+
update: ya(i),
|
|
3905
|
+
delete: ya(a)
|
|
3859
3906
|
};
|
|
3860
|
-
}),
|
|
3907
|
+
}), xa = (e) => {
|
|
3861
3908
|
let [t, n] = A([]), [r, i] = A([]), a = E((e) => {
|
|
3862
3909
|
n((t) => [...t, e]), i([]);
|
|
3863
3910
|
}, []), o = E(async () => {
|
|
@@ -3885,8 +3932,8 @@ var Qi = () => ee(Xi), $i = (e) => Ji(Qi().scopes, e), ea = (e) => Yi(Qi().scope
|
|
|
3885
3932
|
o,
|
|
3886
3933
|
s
|
|
3887
3934
|
]);
|
|
3888
|
-
},
|
|
3889
|
-
let n = t?.limit, { data: r } = J(e,
|
|
3935
|
+
}, Sa = "__voltro.undo.log", Ca = "__voltro.undo.apply", wa = "__voltro.undo.redo", Ta = (e, t) => {
|
|
3936
|
+
let n = t?.limit, { data: r } = J(e, Sa, n === void 0 ? {} : { limit: n }), i = gr(e, Ca), a = gr(e, wa), o = r ?? [], s = o.find((e) => !e.undone && !e.crossesAction), c = o.find((e) => e.undone), l = E(async (e) => {
|
|
3890
3937
|
await i.mutate({ invocationId: e });
|
|
3891
3938
|
}, [i]), u = E(async (e) => {
|
|
3892
3939
|
await a.mutate({ invocationId: e });
|
|
@@ -3905,21 +3952,21 @@ var Qi = () => ee(Xi), $i = (e) => Ji(Qi().scopes, e), ea = (e) => Yi(Qi().scope
|
|
|
3905
3952
|
undoLast: d,
|
|
3906
3953
|
redoLast: f
|
|
3907
3954
|
};
|
|
3908
|
-
},
|
|
3955
|
+
}, Ea = (e, t) => ({
|
|
3909
3956
|
name: e,
|
|
3910
3957
|
map: t
|
|
3911
|
-
}),
|
|
3958
|
+
}), Da = (e, t) => e === void 0 ? null : typeof e == "string" ? { event: e } : e(t), Oa = /* @__PURE__ */ new Set(["onMount", "onUnmount"]), ka = (e, t, n) => {
|
|
3912
3959
|
let r = { ...t };
|
|
3913
3960
|
for (let [i, a] of Object.entries(e.map)) {
|
|
3914
|
-
if (
|
|
3961
|
+
if (Oa.has(i) || a === void 0) continue;
|
|
3915
3962
|
let e = t[i];
|
|
3916
3963
|
r[i] = (...r) => {
|
|
3917
|
-
let i =
|
|
3964
|
+
let i = Da(a, t);
|
|
3918
3965
|
if (i !== null && n(i), typeof e == "function") return e(...r);
|
|
3919
3966
|
};
|
|
3920
3967
|
}
|
|
3921
3968
|
return r;
|
|
3922
|
-
},
|
|
3969
|
+
}, Aa = (e, t, n) => {
|
|
3923
3970
|
let r = k({
|
|
3924
3971
|
spec: e,
|
|
3925
3972
|
props: t,
|
|
@@ -3930,46 +3977,46 @@ var Qi = () => ee(Xi), $i = (e) => Ji(Qi().scopes, e), ea = (e) => Yi(Qi().scope
|
|
|
3930
3977
|
props: t,
|
|
3931
3978
|
sink: n
|
|
3932
3979
|
}, D(() => {
|
|
3933
|
-
let e = r.current, t =
|
|
3980
|
+
let e = r.current, t = Da(e.spec.map.onMount, e.props);
|
|
3934
3981
|
return t !== null && e.sink(t), () => {
|
|
3935
|
-
let e = r.current, t =
|
|
3982
|
+
let e = r.current, t = Da(e.spec.map.onUnmount, e.props);
|
|
3936
3983
|
t !== null && e.sink(t);
|
|
3937
3984
|
};
|
|
3938
|
-
}, []), O(() =>
|
|
3985
|
+
}, []), O(() => ka(e, t, n), [
|
|
3939
3986
|
e,
|
|
3940
3987
|
t,
|
|
3941
3988
|
n
|
|
3942
3989
|
]);
|
|
3943
|
-
},
|
|
3990
|
+
}, ja = (e, t) => {
|
|
3944
3991
|
let n = K(e).descriptors[t]?.input;
|
|
3945
3992
|
return O(() => n === void 0 ? [] : x(n), [n]);
|
|
3946
|
-
},
|
|
3993
|
+
}, Ma = (t, n) => {
|
|
3947
3994
|
let r = K(t).descriptors[n]?.output;
|
|
3948
3995
|
return O(() => r === void 0 ? [] : e(r), [r]);
|
|
3949
|
-
},
|
|
3996
|
+
}, Na = (e, t) => {
|
|
3950
3997
|
if (e === t) return !0;
|
|
3951
3998
|
if (e.length !== t.length) return !1;
|
|
3952
3999
|
for (let n = 0; n < e.length; n += 1) if (!Object.is(e[n], t[n])) return !1;
|
|
3953
4000
|
return !0;
|
|
3954
|
-
},
|
|
3955
|
-
let n = k(null), r =
|
|
3956
|
-
return (n.current === null || !
|
|
4001
|
+
}, Pa = (e) => Object.keys(e).sort().map((t) => e[t]), Fa = (e, t) => {
|
|
4002
|
+
let n = k(null), r = Pa(e);
|
|
4003
|
+
return (n.current === null || !Na(n.current.key, r)) && (n.current = {
|
|
3957
4004
|
key: r,
|
|
3958
4005
|
value: t(e)
|
|
3959
4006
|
}), n.current.value;
|
|
3960
|
-
},
|
|
4007
|
+
}, Ia = (e, t, n, r = {}) => {
|
|
3961
4008
|
let i = J(e, t, { ...n }, r);
|
|
3962
4009
|
return O(() => ({
|
|
3963
4010
|
allowed: i.data?.allowed === !0,
|
|
3964
4011
|
pending: i.data === void 0
|
|
3965
4012
|
}), [i.data]);
|
|
3966
|
-
},
|
|
4013
|
+
}, La = (e, t, n, r = {}) => {
|
|
3967
4014
|
let i = J(e, t, { ...n }, r);
|
|
3968
4015
|
return O(() => ({
|
|
3969
4016
|
allowedIds: new Set(i.data?.allowedIds ?? []),
|
|
3970
4017
|
pending: i.data === void 0
|
|
3971
4018
|
}), [i.data]);
|
|
3972
|
-
},
|
|
4019
|
+
}, Ra = (e) => {
|
|
3973
4020
|
switch (e) {
|
|
3974
4021
|
case "select":
|
|
3975
4022
|
case "radio":
|
|
@@ -3985,26 +4032,26 @@ var Qi = () => ee(Xi), $i = (e) => Ji(Qi().scopes, e), ea = (e) => Yi(Qi().scope
|
|
|
3985
4032
|
case "switch": return "boolean";
|
|
3986
4033
|
default: return null;
|
|
3987
4034
|
}
|
|
3988
|
-
},
|
|
4035
|
+
}, za = (e) => x(e).map((e) => {
|
|
3989
4036
|
if (e.name.includes(".")) return null;
|
|
3990
|
-
let t =
|
|
4037
|
+
let t = Ra(e.widget);
|
|
3991
4038
|
return t === null ? null : {
|
|
3992
4039
|
name: e.name,
|
|
3993
4040
|
label: e.label,
|
|
3994
4041
|
kind: t,
|
|
3995
4042
|
...e.options ? { options: e.options } : {}
|
|
3996
4043
|
};
|
|
3997
|
-
}).filter((e) => e !== null),
|
|
4044
|
+
}).filter((e) => e !== null), Ba = (e) => {
|
|
3998
4045
|
let t = {};
|
|
3999
4046
|
for (let [n, r] of Object.entries(e)) r === void 0 || r === "" || Array.isArray(r) && r.length === 0 || (t[n] = r);
|
|
4000
4047
|
return t;
|
|
4001
|
-
},
|
|
4002
|
-
let r = K(e).descriptors[t]?.input, i = O(() => r === void 0 ? [] :
|
|
4003
|
-
o((n) =>
|
|
4048
|
+
}, Va = (e, t, n = {}) => {
|
|
4049
|
+
let r = K(e).descriptors[t]?.input, i = O(() => r === void 0 ? [] : za(r), [r]), [a, o] = A(n.initial ?? {}), s = E((e, t) => {
|
|
4050
|
+
o((n) => Ba({
|
|
4004
4051
|
...n,
|
|
4005
4052
|
[e]: t
|
|
4006
4053
|
}));
|
|
4007
|
-
}, []), c = E(() => o({}), []), l = J(e, t, O(() =>
|
|
4054
|
+
}, []), c = E(() => o({}), []), l = J(e, t, O(() => Ba(a), [a]));
|
|
4008
4055
|
return {
|
|
4009
4056
|
filters: i,
|
|
4010
4057
|
values: a,
|
|
@@ -4015,20 +4062,20 @@ var Qi = () => ee(Xi), $i = (e) => Ji(Qi().scopes, e), ea = (e) => Yi(Qi().scope
|
|
|
4015
4062
|
loading: l.data === void 0,
|
|
4016
4063
|
error: l.error
|
|
4017
4064
|
};
|
|
4018
|
-
},
|
|
4065
|
+
}, Ha = (e, t, n = {}) => {
|
|
4019
4066
|
let r = J(e, t, n), i = r.data;
|
|
4020
4067
|
return {
|
|
4021
4068
|
record: Array.isArray(i) ? i[0] : i,
|
|
4022
4069
|
loading: i === void 0,
|
|
4023
4070
|
error: r.error
|
|
4024
4071
|
};
|
|
4025
|
-
},
|
|
4072
|
+
}, Ua = (e, t = 300) => {
|
|
4026
4073
|
let [n, r] = A(e);
|
|
4027
4074
|
return D(() => {
|
|
4028
4075
|
let n = setTimeout(() => r(e), t);
|
|
4029
4076
|
return () => clearTimeout(n);
|
|
4030
4077
|
}, [e, t]), n;
|
|
4031
|
-
},
|
|
4078
|
+
}, Wa = (e) => {
|
|
4032
4079
|
let { value: t, debouncedValue: n, data: r, interpret: i, skipEmpty: a = !0 } = e;
|
|
4033
4080
|
if (a && t.trim() === "") return {
|
|
4034
4081
|
status: "idle",
|
|
@@ -4046,20 +4093,20 @@ var Qi = () => ee(Xi), $i = (e) => Ji(Qi().scopes, e), ea = (e) => Yi(Qi().scope
|
|
|
4046
4093
|
valid: o.valid,
|
|
4047
4094
|
message: o.message
|
|
4048
4095
|
};
|
|
4049
|
-
},
|
|
4050
|
-
let { input: i, interpret: a, debounceMs: o = 300, skipEmpty: s = !0 } = r, c =
|
|
4051
|
-
return
|
|
4096
|
+
}, Ga = (e, t, n, r) => {
|
|
4097
|
+
let { input: i, interpret: a, debounceMs: o = 300, skipEmpty: s = !0 } = r, c = Ua(n, o), l = s && c.trim() === "", u = J(e, t, O(() => i ? i(c) : { value: c }, [i, c]), { skip: l });
|
|
4098
|
+
return Wa({
|
|
4052
4099
|
value: n,
|
|
4053
4100
|
debouncedValue: c,
|
|
4054
4101
|
data: l ? null : u.data,
|
|
4055
4102
|
interpret: a,
|
|
4056
4103
|
skipEmpty: s
|
|
4057
4104
|
});
|
|
4058
|
-
},
|
|
4105
|
+
}, Ka = (e, t) => ({
|
|
4059
4106
|
name: e,
|
|
4060
4107
|
payload: t
|
|
4061
|
-
}),
|
|
4062
|
-
let n =
|
|
4108
|
+
}), qa = (e, t) => {
|
|
4109
|
+
let n = se.decodeUnknownEither(e.payload, { errors: "all" })(t);
|
|
4063
4110
|
if (n._tag === "Right") return {
|
|
4064
4111
|
valid: !0,
|
|
4065
4112
|
errors: {}
|
|
@@ -4070,15 +4117,15 @@ var Qi = () => ee(Xi), $i = (e) => Ji(Qi().scopes, e), ea = (e) => Yi(Qi().scope
|
|
|
4070
4117
|
valid: !1,
|
|
4071
4118
|
errors: r
|
|
4072
4119
|
};
|
|
4073
|
-
},
|
|
4120
|
+
}, Ja = (e) => {
|
|
4074
4121
|
let t = new Map(e.map((e) => [e.name, e]));
|
|
4075
4122
|
return {
|
|
4076
4123
|
names: [...t.keys()].sort(),
|
|
4077
4124
|
get: (e) => t.get(e),
|
|
4078
4125
|
events: e
|
|
4079
4126
|
};
|
|
4080
|
-
},
|
|
4081
|
-
let n =
|
|
4127
|
+
}, Ya = (e, t) => {
|
|
4128
|
+
let n = Ja(e);
|
|
4082
4129
|
return {
|
|
4083
4130
|
track: (e, r) => {
|
|
4084
4131
|
let i = n.get(e);
|
|
@@ -4087,7 +4134,7 @@ var Qi = () => ee(Xi), $i = (e) => Ji(Qi().scopes, e), ea = (e) => Yi(Qi().scope
|
|
|
4087
4134
|
return;
|
|
4088
4135
|
}
|
|
4089
4136
|
if (process.env.NODE_ENV !== "production") {
|
|
4090
|
-
let t =
|
|
4137
|
+
let t = qa(i, r);
|
|
4091
4138
|
t.valid || console.error(`[@voltro/client] analytics.track('${e}'): payload failed its schema`, t.errors);
|
|
4092
4139
|
}
|
|
4093
4140
|
t({
|
|
@@ -4098,47 +4145,47 @@ var Qi = () => ee(Xi), $i = (e) => Ji(Qi().scopes, e), ea = (e) => Yi(Qi().scope
|
|
|
4098
4145
|
names: n.names,
|
|
4099
4146
|
catalog: n
|
|
4100
4147
|
};
|
|
4101
|
-
},
|
|
4102
|
-
let n =
|
|
4148
|
+
}, Xa = (e, t) => {
|
|
4149
|
+
let n = xr(e, t);
|
|
4103
4150
|
return {
|
|
4104
4151
|
preview: E((e) => n.run(e), [n]),
|
|
4105
4152
|
diff: n.lastResult,
|
|
4106
4153
|
pending: n.pending,
|
|
4107
4154
|
error: n.error
|
|
4108
4155
|
};
|
|
4109
|
-
},
|
|
4156
|
+
}, Za = (e, t, n, r) => [...e, {
|
|
4110
4157
|
id: t,
|
|
4111
4158
|
tag: n,
|
|
4112
4159
|
input: r,
|
|
4113
4160
|
status: "pending",
|
|
4114
4161
|
attempts: 0
|
|
4115
|
-
}],
|
|
4162
|
+
}], Qa = (e, t, n) => e.map((e) => e.id === t ? {
|
|
4116
4163
|
...e,
|
|
4117
4164
|
...n
|
|
4118
|
-
} : e),
|
|
4165
|
+
} : e), $a = (e, t) => Qa(e, t, { status: "sent" }), eo = (e, t, n) => e.map((e) => e.id === t ? {
|
|
4119
4166
|
...e,
|
|
4120
4167
|
status: "failed",
|
|
4121
4168
|
error: n,
|
|
4122
4169
|
attempts: e.attempts + 1
|
|
4123
|
-
} : e),
|
|
4170
|
+
} : e), to = (e, t, n) => Qa(e, t, {
|
|
4124
4171
|
status: "conflict",
|
|
4125
4172
|
error: n
|
|
4126
|
-
}),
|
|
4173
|
+
}), no = (e, t, n) => e.map((e) => e.id === t && e.status === "conflict" ? {
|
|
4127
4174
|
...e,
|
|
4128
4175
|
input: n,
|
|
4129
4176
|
status: "pending",
|
|
4130
4177
|
error: void 0
|
|
4131
|
-
} : e),
|
|
4178
|
+
} : e), ro = (e) => e.filter((e) => e.status !== "sent"), io = (e) => {
|
|
4132
4179
|
let t = [];
|
|
4133
4180
|
for (let n of e) {
|
|
4134
4181
|
if (n.status === "conflict") break;
|
|
4135
4182
|
(n.status === "pending" || n.status === "failed") && t.push(n);
|
|
4136
4183
|
}
|
|
4137
4184
|
return t;
|
|
4138
|
-
},
|
|
4185
|
+
}, ao = (e) => {
|
|
4139
4186
|
let t = e;
|
|
4140
4187
|
return t?.conflict === !0 || t?._tag === "UndoBoundaryError" && t?.boundary === "conflict";
|
|
4141
|
-
},
|
|
4188
|
+
}, oo = (e) => {
|
|
4142
4189
|
let [t, n] = A(e ?? (typeof navigator < "u" ? navigator.onLine : !0));
|
|
4143
4190
|
return D(() => {
|
|
4144
4191
|
if (e !== void 0) {
|
|
@@ -4151,8 +4198,8 @@ var Qi = () => ee(Xi), $i = (e) => Ji(Qi().scopes, e), ea = (e) => Yi(Qi().scope
|
|
|
4151
4198
|
window.removeEventListener("online", t), window.removeEventListener("offline", r);
|
|
4152
4199
|
};
|
|
4153
4200
|
}, [e]), t;
|
|
4154
|
-
},
|
|
4155
|
-
let { send: t, persistence: n, isConflict: r =
|
|
4201
|
+
}, so = (e) => {
|
|
4202
|
+
let { send: t, persistence: n, isConflict: r = ao, idFor: i } = e, [a, o] = A([]), [s, c] = A(0), l = oo(e.online), u = k([]), d = E((e) => {
|
|
4156
4203
|
let t = e(u.current);
|
|
4157
4204
|
u.current = t, o(t);
|
|
4158
4205
|
}, []), f = k(t);
|
|
@@ -4175,7 +4222,7 @@ var Qi = () => ee(Xi), $i = (e) => Ji(Qi().scopes, e), ea = (e) => Yi(Qi().scope
|
|
|
4175
4222
|
e = !0;
|
|
4176
4223
|
};
|
|
4177
4224
|
}, [n, d]), D(() => {
|
|
4178
|
-
n
|
|
4225
|
+
n !== void 0 && y.current && n.save(ro(a)).catch(() => {});
|
|
4179
4226
|
}, [
|
|
4180
4227
|
n,
|
|
4181
4228
|
a,
|
|
@@ -4183,21 +4230,21 @@ var Qi = () => ee(Xi), $i = (e) => Ji(Qi().scopes, e), ea = (e) => Yi(Qi().scope
|
|
|
4183
4230
|
]);
|
|
4184
4231
|
let b = E((e, t) => {
|
|
4185
4232
|
let n = i?.() ?? `obx_${v.current}_${_.current++}_${e}`;
|
|
4186
|
-
d((r) =>
|
|
4233
|
+
d((r) => Za(r, n, e, t)), c((e) => e + 1);
|
|
4187
4234
|
}, [i, d]), x = E(() => {
|
|
4188
4235
|
if (!y.current || !g.current) return Promise.resolve();
|
|
4189
4236
|
if (m.current !== void 0) return m.current;
|
|
4190
4237
|
h.current = !1;
|
|
4191
4238
|
let e = Promise.resolve().then(async () => {
|
|
4192
4239
|
for (; g.current;) {
|
|
4193
|
-
let e =
|
|
4240
|
+
let e = io(u.current)[0];
|
|
4194
4241
|
if (e === void 0) break;
|
|
4195
4242
|
try {
|
|
4196
4243
|
if (await f.current(e), !g.current) break;
|
|
4197
|
-
d((t) =>
|
|
4244
|
+
d((t) => $a(t, e.id));
|
|
4198
4245
|
} catch (t) {
|
|
4199
4246
|
if (!g.current) break;
|
|
4200
|
-
d((n) => p.current(t) ?
|
|
4247
|
+
d((n) => p.current(t) ? to(n, e.id, t) : eo(n, e.id, t)), h.current = !0;
|
|
4201
4248
|
break;
|
|
4202
4249
|
}
|
|
4203
4250
|
}
|
|
@@ -4216,7 +4263,7 @@ var Qi = () => ee(Xi), $i = (e) => Ji(Qi().scopes, e), ea = (e) => Yi(Qi().scope
|
|
|
4216
4263
|
x
|
|
4217
4264
|
]);
|
|
4218
4265
|
let S = E((e, t) => {
|
|
4219
|
-
d((n) =>
|
|
4266
|
+
d((n) => no(n, e, t)), l && x();
|
|
4220
4267
|
}, [
|
|
4221
4268
|
l,
|
|
4222
4269
|
x,
|
|
@@ -4231,7 +4278,7 @@ var Qi = () => ee(Xi), $i = (e) => Ji(Qi().scopes, e), ea = (e) => Yi(Qi().scope
|
|
|
4231
4278
|
conflicts: a.filter((e) => e.status === "conflict"),
|
|
4232
4279
|
resolveConflict: S
|
|
4233
4280
|
};
|
|
4234
|
-
},
|
|
4281
|
+
}, co = (e) => {
|
|
4235
4282
|
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);
|
|
4236
4283
|
return {
|
|
4237
4284
|
startIndex: l,
|
|
@@ -4241,8 +4288,8 @@ var Qi = () => ee(Xi), $i = (e) => Ji(Qi().scopes, e), ea = (e) => Yi(Qi().scope
|
|
|
4241
4288
|
topSpacer: l * r,
|
|
4242
4289
|
bottomSpacer: a === void 0 ? 0 : Math.max(0, (a - d) * r)
|
|
4243
4290
|
};
|
|
4244
|
-
},
|
|
4245
|
-
let { rowHeight: r, viewportHeight: i, overscan: a, total: o, input: s } = n, [c, l] = A(0), u = O(() =>
|
|
4291
|
+
}, lo = (e, t, n) => {
|
|
4292
|
+
let { rowHeight: r, viewportHeight: i, overscan: a, total: o, input: s } = n, [c, l] = A(0), u = O(() => co({
|
|
4246
4293
|
scrollTop: c,
|
|
4247
4294
|
viewportHeight: i,
|
|
4248
4295
|
rowHeight: r,
|
|
@@ -4274,8 +4321,8 @@ var Qi = () => ee(Xi), $i = (e) => Ji(Qi().scopes, e), ea = (e) => Yi(Qi().scope
|
|
|
4274
4321
|
loading: d.data === void 0,
|
|
4275
4322
|
error: d.error
|
|
4276
4323
|
};
|
|
4277
|
-
},
|
|
4278
|
-
let t = K(e), n = t.recovery ??
|
|
4324
|
+
}, uo = () => typeof navigator > "u" || navigator.onLine, fo = (e) => {
|
|
4325
|
+
let t = K(e), n = t.recovery ?? _t(t.errorBus, e), r = j(n.subscribe, n.getSnapshot, n.getSnapshot), [i, a] = A(uo);
|
|
4279
4326
|
D(() => {
|
|
4280
4327
|
if (typeof window > "u") return;
|
|
4281
4328
|
let e = () => {
|
|
@@ -4312,7 +4359,7 @@ var Qi = () => ee(Xi), $i = (e) => Ji(Qi().scopes, e), ea = (e) => Yi(Qi().scope
|
|
|
4312
4359
|
mutationReplay: r.mutationReplay,
|
|
4313
4360
|
reportSuccess: o
|
|
4314
4361
|
};
|
|
4315
|
-
},
|
|
4362
|
+
}, po = "__voltro.connections.list", mo = "__voltro.connections.start", ho = "__voltro.connections.submitToken", go = "__voltro.connections.disconnect", _o = {
|
|
4316
4363
|
connectionId: "",
|
|
4317
4364
|
kind: "oauth2",
|
|
4318
4365
|
label: "",
|
|
@@ -4323,14 +4370,14 @@ var Qi = () => ee(Xi), $i = (e) => Ji(Qi().scopes, e), ea = (e) => Yi(Qi().scope
|
|
|
4323
4370
|
expiresAt: null,
|
|
4324
4371
|
lastError: null,
|
|
4325
4372
|
connectedAt: null
|
|
4326
|
-
},
|
|
4373
|
+
}, vo = (e, t) => {
|
|
4327
4374
|
if (t === "redirect") {
|
|
4328
4375
|
globalThis.location.assign(e);
|
|
4329
4376
|
return;
|
|
4330
4377
|
}
|
|
4331
4378
|
globalThis.open(e, "voltro-connect", "width=620,height=760,menubar=no,toolbar=no") === null && globalThis.location.assign(e);
|
|
4332
|
-
},
|
|
4333
|
-
let { data: t } = J(e,
|
|
4379
|
+
}, yo = (e) => {
|
|
4380
|
+
let { data: t } = J(e, po, {}), n = xr(e, mo), r = gr(e, ho), i = gr(e, go), a = t ?? [], o = n.pending || r.pending || i.pending, s = E((e) => ({
|
|
4334
4381
|
...e,
|
|
4335
4382
|
connected: e.status === "connected",
|
|
4336
4383
|
needsAttention: e.status === "expired" || e.status === "revoked" || e.status === "error",
|
|
@@ -4338,7 +4385,7 @@ var Qi = () => ee(Xi), $i = (e) => Ji(Qi().scopes, e), ea = (e) => Yi(Qi().scope
|
|
|
4338
4385
|
connect: async (t) => {
|
|
4339
4386
|
if (e.kind !== "oauth2") throw Error(`connection "${e.connectionId}" is a personal-access-token connection — call submitToken(token), not connect().`);
|
|
4340
4387
|
let r = t?.redirectTo ?? `${globalThis.location.pathname}${globalThis.location.search}`;
|
|
4341
|
-
|
|
4388
|
+
vo((await n.run({
|
|
4342
4389
|
connectionId: e.connectionId,
|
|
4343
4390
|
redirectTo: r
|
|
4344
4391
|
})).authorizeUrl, t?.mode);
|
|
@@ -4368,10 +4415,10 @@ var Qi = () => ee(Xi), $i = (e) => Ji(Qi().scopes, e), ea = (e) => Yi(Qi().scope
|
|
|
4368
4415
|
get: c,
|
|
4369
4416
|
pending: o
|
|
4370
4417
|
};
|
|
4371
|
-
},
|
|
4372
|
-
let n =
|
|
4418
|
+
}, bo = (e, t) => {
|
|
4419
|
+
let n = yo(e), r = n.get(t);
|
|
4373
4420
|
return O(() => r === void 0 ? {
|
|
4374
|
-
...
|
|
4421
|
+
..._o,
|
|
4375
4422
|
connectionId: t,
|
|
4376
4423
|
label: t,
|
|
4377
4424
|
connected: !1,
|
|
@@ -4396,6 +4443,6 @@ var Qi = () => ee(Xi), $i = (e) => Ji(Qi().scopes, e), ea = (e) => Yi(Qi().scope
|
|
|
4396
4443
|
n.loading,
|
|
4397
4444
|
n.pending
|
|
4398
4445
|
]);
|
|
4399
|
-
},
|
|
4446
|
+
}, xo = "framework-client";
|
|
4400
4447
|
//#endregion
|
|
4401
|
-
export {
|
|
4448
|
+
export { na as ADMIN_SCOPE, xo as CLIENT_NAME, po as CONNECTIONS_LIST_TAG, go as CONNECTION_DISCONNECT_TAG, mo as CONNECTION_START_TAG, ho as CONNECTION_SUBMIT_TOKEN_TAG, v as FORM_FLASH_SCRIPT_ID, p as FORM_KEY_FIELD, g as FORM_PATH_PREFIX, u as FORM_REDIRECT_FIELD, Mr as FormBindingProvider, vt as FrameworkRuntimesContext, Zt as FrameworkRuntimesProvider, rt as LoadingSubscriptionCache, oa as PermissionProvider, _ as RICH_TEXT_MARKS, a as RICH_TEXT_MAX_NODES, ht as RecoveryCoordinator, d as RichTextDocument, ct as RpcErrorBus, Gi as ServerRequestContext, qi as ServerRequestProvider, nt as SubscriptionCache, Ca as UNDO_APPLY_TAG, Sa as UNDO_LOG_TAG, wa as UNDO_REDO_TAG, Cr as ValidationMessagesProvider, jt as _resetFrameworkRuntimesWarning, Et as _resetSsrDescriptors, qr as applyPreloadSeeds, zn as applyStoreSeeds, Kt as buildApiRuntime, ra as canCall, ia as canCallAny, Le as clearClientDiagnostics, Qn as clearMutations, ro as clearSent, yn as clearStoreHistory, Ie as clientDiagnosticsSnapshot, co as computeWindow, Ya as createAnalytics, zr as createHooks, pa as decideAccess, c as decodeFieldIssues, Ka as defineEvent, Pn as defineStore, Ea as defineTracking, Nn as definedStores, ba as deriveEntityAdmins, Fe as disableClientDiagnosticsPersistence, n as documentLocale, y as emptyRichTextDocument, Pe as enableClientDiagnosticsPersistence, Za as enqueueEntry, Ja as eventCatalog, za as filtersFromSchema, r as formActionPath, m as formDataToInput, S as formField, t as formSections, or as freshIdempotencyKey, dr as getMutationNotifier, Xn as getMutations, Wi as globalContext, o as isRichTextDocument, s as isSafeHref, Ri as isUnauthenticated, Nt as isUnresolvedApi, Br as makePreloadSeedBag, In as makeStoreSeedBag, ua as manifestUrl, to as markConflict, eo as markFailed, $a as markSent, ha as openAccessReason, h as parseRichText, ea as provenanceUrl, at as publishClientError, ye as publishClientTrace, Yr as readPreloadedSeedOutcome, Jr as readPreloadedSnapshot, U as recordClientDiagnostic, _t as recoveryCoordinatorFor, wt as registerSsrDescriptors, io as replayable, st as reportClientError, ma as requiredScopes, Xr as resetPreloadSeeds, Fn as resetStoreRegistryForTests, rn as resetStoreStorageForTest, q as resolveByTag, no as resolveConflictEntry, mt as resolveRecoveryOptions, nn as resolveStoreStorage, Da as resolveTrackingEvent, b as resolveValidationMessage, C as restrictToSchema, ki as resumableConsumeProgram, f as richTextToPlainText, Yi as rowsToOptions, ni as runSequence, e as schemaToColumns, x as schemaToFields, Gr as seedPreloadedSubscription, Kr as seedPreloadedSubscriptionFailure, Rn as seedStore, ti as sequence, l as serializeRichText, ur as setMutationNotifier, Hr as setPreloadSeedResolver, Ln as setStoreSeedResolver, tn as setStoreStorage, Yn as settleMutation, an as shallow, Na as shallowArrayEqual, Pa as sourceValues, bt as ssrClientProxy, Tt as ssrDescriptorsFor, Dt as ssrStubHandle, W as stableKey, Xt as startApiSupervisor, Jn as startMutation, _n as storeHistory, Re as subscribeClientDiagnostics, ot as subscribeClientErrors, be as subscribeClientTraces, Zn as subscribeMutations, vn as subscribeStoreHistory, Ve as supersedesConfirmedPatches, bn as travelToStoreState, ga as useAccessDecision, xr as useAction, Fi as useAgent, Pi as useAgentChat, Oi as useAgentStream, Ga as useAsyncValidation, ca as useCan, la as useCanAny, da as useCapabilityManifest, bo as useConnection, Lr as useConnectionSetup, fo as useConnectionStatus, yo as useConnections, Ii as useDataCopilot, Qi as useDataTable, Ua as useDebounced, Fa as useDerived, ei as useEvent, jr as useFormBinding, Nr as useFormBindingContext, Pr as useFormField, Ji as useFormFlash, ja as useFormSkeleton, K as useFrameworkApi, Mt as useFrameworkRuntimes, gr as useMutation, Vi as useOnRawRpcError, Bi as useOnRpcError, so as useOutbox, sa as usePermissions, Zr as usePreloadedSubscription, Xa as usePreview, ta as useProvenance, Xi as useQueryField, Va as useQueryFilters, Ha as useRecord, Li as useRefreshSubscriptions, Ia as useResourceCan, La as useResourceCans, ji as useResumableAgentStream, ri as useSequence, Ki as useServerRequest, J as useSubscription, Ui as useSubscriptionHealth, Ma as useTableSkeleton, Aa as useTracking, ui as useTranscription, xa as useUndo, Ta as useUndoLog, li as useUpload, wr as useValidationMessages, lo as useWindowedSubscription, fi as useWorkflow, bi as useWorkflowDomainEvents, xi as useWorkflowEventDeliveries, yi as useWorkflowEvents, hi as useWorkflowRun, vi as useWorkflowRunEvents, Di as useWorkflowRunState, _i as useWorkflowRunSteps, gi as useWorkflowRuns, pi as useWorkflowSignal, mi as useWorkflowUpdate, qa as validateEventPayload, i as validateFields, Wa as validationStatus, zi as wireAuthRefresh, sr as withIdempotencyKey, Gt as withProtocolOpenRecovery, ka as wrapTrackedCallbacks };
|