@voltro/client 0.66.1 → 0.68.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 +259 -0
- package/README.md +6 -0
- package/THIRD-PARTY-NOTICES.md +2 -2
- package/dist/index.d.ts +58 -45
- package/dist/index.js +825 -758
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -1,135 +1,127 @@
|
|
|
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
|
|
6
|
-
import { applyRowPatch as
|
|
7
|
-
import * as
|
|
8
|
-
import { jsx as
|
|
9
|
-
import { FormApi as
|
|
10
|
-
import { useStore as
|
|
11
|
-
import { ArrayFormatter 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 le, RpcClientError as ue, RpcSerialization as de } from "@effect/rpc";
|
|
6
|
+
import { applyRowPatch as fe, compareSurfaces as pe, fieldIssuesOf as me, groupShapeDigests as he, pluginTag as ge } from "@voltro/protocol";
|
|
7
|
+
import * as _e from "@effect/platform/Socket";
|
|
8
|
+
import { jsx as ve } from "react/jsx-runtime";
|
|
9
|
+
import { FormApi as ye } from "@tanstack/form-core";
|
|
10
|
+
import { useStore as be } from "@tanstack/react-store";
|
|
11
|
+
import { ArrayFormatter as xe } from "effect/ParseResult";
|
|
12
12
|
//#region src/traceBus.ts
|
|
13
|
-
var
|
|
14
|
-
for (let t of
|
|
13
|
+
var Se = /* @__PURE__ */ new Set(), Ce = (e) => {
|
|
14
|
+
for (let t of Se) try {
|
|
15
15
|
t(e);
|
|
16
16
|
} catch {}
|
|
17
|
-
},
|
|
18
|
-
|
|
19
|
-
}),
|
|
17
|
+
}, we = (e) => (Se.add(e), () => {
|
|
18
|
+
Se.delete(e);
|
|
19
|
+
}), Te = /* @__PURE__ */ new WeakMap(), z = (e, t) => ((typeof e == "object" && e || typeof e == "function") && Te.set(e, t), e), B = (e, t) => {
|
|
20
20
|
if ((typeof e != "object" || !e) && typeof e != "function") return t;
|
|
21
|
-
let n =
|
|
21
|
+
let n = Te.get(e);
|
|
22
22
|
if (n !== void 0) return n;
|
|
23
23
|
try {
|
|
24
|
-
return
|
|
24
|
+
return ue.TypeId in e ? "transport" : t;
|
|
25
25
|
} catch {
|
|
26
26
|
return t;
|
|
27
27
|
}
|
|
28
|
-
},
|
|
28
|
+
}, Ee = "voltro.client-diagnostics.v1", De = 400, Oe = 240, ke = Symbol.for("@voltro/client/diagnostics"), Ae = globalThis, je = () => typeof performance < "u" && typeof performance.now == "function" ? performance.now() : Date.now(), V = Ae[ke] ?? (Ae[ke] = {
|
|
29
29
|
sessionStartedAt: Date.now(),
|
|
30
|
-
monotonicStartedAt:
|
|
30
|
+
monotonicStartedAt: je(),
|
|
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
|
+
}), Me = (e) => e.length <= Oe ? e : `${e.slice(0, Oe)}…`, Ne = (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" ? Me(r) : r);
|
|
40
40
|
return t;
|
|
41
|
-
},
|
|
41
|
+
}, Pe = (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
|
-
},
|
|
46
|
-
if (
|
|
47
|
-
|
|
45
|
+
}, Fe = () => {
|
|
46
|
+
if (V.storage !== void 0) try {
|
|
47
|
+
V.storage.setItem(Ee, JSON.stringify({
|
|
48
48
|
version: 1,
|
|
49
|
-
sessionStartedAt:
|
|
50
|
-
sequence:
|
|
51
|
-
dropped:
|
|
52
|
-
events:
|
|
49
|
+
sessionStartedAt: V.sessionStartedAt,
|
|
50
|
+
sequence: V.sequence,
|
|
51
|
+
dropped: V.dropped,
|
|
52
|
+
events: V.events
|
|
53
53
|
}));
|
|
54
54
|
} catch {}
|
|
55
|
-
},
|
|
56
|
-
for (let e of
|
|
55
|
+
}, Ie = () => {
|
|
56
|
+
for (let e of V.listeners) try {
|
|
57
57
|
e();
|
|
58
58
|
} catch {}
|
|
59
|
-
},
|
|
60
|
-
if (
|
|
61
|
-
|
|
59
|
+
}, Le = (e) => {
|
|
60
|
+
if (V.storage = e, !V.loadedStorage) {
|
|
61
|
+
V.loadedStorage = !0;
|
|
62
62
|
try {
|
|
63
|
-
let t = e.getItem(
|
|
63
|
+
let t = e.getItem(Ee);
|
|
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(Pe) : [], r = Math.max(typeof e.sequence == "number" ? e.sequence : 0, 0, ...n.map((e) => e.sequence)), i = V.events.map((e, t) => ({
|
|
66
66
|
...e,
|
|
67
67
|
sequence: r + t + 1
|
|
68
|
-
})), a = [...n, ...i], o = Math.max(0, a.length -
|
|
69
|
-
|
|
68
|
+
})), a = [...n, ...i], o = Math.max(0, a.length - De), s = typeof e.dropped == "number" ? e.dropped : 0;
|
|
69
|
+
V.dropped = V.dropped + s + o, V.events = a.slice(-400), V.sequence = Math.max(r + i.length, ...V.events.map((e) => e.sequence)), typeof e.sessionStartedAt == "number" && (V.sessionStartedAt = Math.min(V.sessionStartedAt, e.sessionStartedAt));
|
|
70
70
|
}
|
|
71
71
|
} catch {}
|
|
72
72
|
}
|
|
73
|
-
|
|
74
|
-
},
|
|
75
|
-
|
|
76
|
-
},
|
|
73
|
+
Fe();
|
|
74
|
+
}, Re = () => {
|
|
75
|
+
V.storage = void 0;
|
|
76
|
+
}, H = (e, t, n = {}) => {
|
|
77
77
|
let r = {
|
|
78
|
-
sequence: ++
|
|
78
|
+
sequence: ++V.sequence,
|
|
79
79
|
at: Date.now(),
|
|
80
|
-
elapsedMs: Math.max(0, Math.round(
|
|
81
|
-
api:
|
|
80
|
+
elapsedMs: Math.max(0, Math.round(je() - V.monotonicStartedAt)),
|
|
81
|
+
api: Me(e),
|
|
82
82
|
kind: t,
|
|
83
|
-
fields:
|
|
83
|
+
fields: Ne(n)
|
|
84
84
|
};
|
|
85
|
-
return
|
|
86
|
-
},
|
|
85
|
+
return V.events.push(r), V.events.length > De && (V.events.splice(0, V.events.length - De), V.dropped += 1), Fe(), Ie(), r;
|
|
86
|
+
}, ze = (e) => ({
|
|
87
87
|
version: 1,
|
|
88
88
|
generatedAt: Date.now(),
|
|
89
|
-
sessionStartedAt:
|
|
90
|
-
persisted:
|
|
91
|
-
dropped:
|
|
92
|
-
events: e === void 0 ? [...
|
|
93
|
-
}),
|
|
94
|
-
|
|
89
|
+
sessionStartedAt: V.sessionStartedAt,
|
|
90
|
+
persisted: V.storage !== void 0,
|
|
91
|
+
dropped: V.dropped,
|
|
92
|
+
events: e === void 0 ? [...V.events] : V.events.filter((t) => t.api === e)
|
|
93
|
+
}), Be = () => {
|
|
94
|
+
V.events = [], V.dropped = 0;
|
|
95
95
|
try {
|
|
96
|
-
|
|
96
|
+
V.storage?.removeItem(Ee);
|
|
97
97
|
} catch {}
|
|
98
|
-
|
|
99
|
-
},
|
|
100
|
-
|
|
101
|
-
}),
|
|
98
|
+
Ie();
|
|
99
|
+
}, Ve = (e) => (V.listeners.add(e), () => {
|
|
100
|
+
V.listeners.delete(e);
|
|
101
|
+
}), U = (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
|
+
}, He = 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
|
+
}), Ue = 5e3, We = (e, t) => e._tag === "snapshot" && t !== void 0 && e.reconciles === t, Ge = 0, Ke = 0, qe = () => `patch_${++Ke}`, Je = (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
|
+
}, Ye = (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
|
+
}, Xe = (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
|
+
}, Ze = (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(Je(e, r)) ? Je(e, r) : [];
|
|
138
|
+
return Ye(e ?? {}, r, s === "append" ? [...t, o] : [o, ...t]);
|
|
147
139
|
};
|
|
148
140
|
}
|
|
149
|
-
let a =
|
|
141
|
+
let a = Xe(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 = Je(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]) ? Ye(e, r, o(n)) : e;
|
|
168
160
|
}
|
|
169
|
-
return
|
|
161
|
+
return Ye(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(Je(e, r)) ? Je(e, r) : [];
|
|
166
|
+
return Ye(e, r, t.filter((e) => !a.has(e[i])));
|
|
175
167
|
};
|
|
176
|
-
},
|
|
168
|
+
}, Qe = (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
|
+
}, $e = (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
|
+
}, et = (e, t, n) => {
|
|
204
|
+
if (e.path !== void 0) return Ze(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 = Xe(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 = Xe(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
|
+
}, tt = 5e3, nt = 15e3, rt = 2e3, it = () => globalThis.document?.visibilityState === "hidden", at = class {
|
|
264
256
|
entries = /* @__PURE__ */ new Map();
|
|
265
257
|
successor;
|
|
266
258
|
inactiveTtlMs;
|
|
@@ -271,10 +263,10 @@ 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 ?? tt, this.onChangeHook = e.onChange, this.errorBus = e.errorBus, this.mirror = e.mirror, this.mergeCell = e.mergeCell, this.apiName = e.apiName, this.recoveryStuckMs = e.recoveryStuckMs ?? nt;
|
|
275
267
|
}
|
|
276
268
|
diagnose(e, t, n = {}) {
|
|
277
|
-
this.apiName !== void 0 &&
|
|
269
|
+
this.apiName !== void 0 && H(this.apiName, e, {
|
|
278
270
|
tag: t.tag ?? "unknown",
|
|
279
271
|
revision: t.state.baseRevision,
|
|
280
272
|
subscribers: t.subscribers.size,
|
|
@@ -283,20 +275,19 @@ var ve = /* @__PURE__ */ new Set(), ye = (e) => {
|
|
|
283
275
|
});
|
|
284
276
|
}
|
|
285
277
|
subscribe(e, t, n, r, i = {}) {
|
|
286
|
-
let a =
|
|
278
|
+
let a = U(e), o = typeof e[0] == "string" ? e[0] : void 0, s = this.entries.get(a);
|
|
287
279
|
return s && s.evictionTimer !== null && (clearTimeout(s.evictionTimer), s.evictionTimer = null), s ? (s.fiber === null && (s.fetch = t, s.runtime = n, this.startFiber(s, t, n)), s.source === void 0 && i.source !== void 0 && (s.source = i.source)) : s = this.create(a, o, t, n, i.source), s.subscribers.add(r), {
|
|
288
280
|
getSnapshot: () => this.getSnapshot(a),
|
|
289
281
|
unsubscribe: () => this.unsubscribe(a, r)
|
|
290
282
|
};
|
|
291
283
|
}
|
|
292
284
|
update(e, t, n) {
|
|
293
|
-
let r =
|
|
285
|
+
let r = U(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: qe(),
|
|
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-${++Ke}`,
|
|
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), Ue), 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 ${Ue}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}-${++Ke}`;
|
|
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 = et(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 = Qe(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 = $e(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
|
}
|
|
@@ -401,10 +395,10 @@ var ve = /* @__PURE__ */ new Set(), ye = (e) => {
|
|
|
401
395
|
n.state.patches = n.state.patches.filter((e) => e.id !== t), n.state.patches.length !== r && this.invalidate(n);
|
|
402
396
|
}
|
|
403
397
|
peek(e) {
|
|
404
|
-
return this.getSnapshot(
|
|
398
|
+
return this.getSnapshot(U(e));
|
|
405
399
|
}
|
|
406
400
|
getEntry(e) {
|
|
407
|
-
return this.entries.get(
|
|
401
|
+
return this.entries.get(U(e));
|
|
408
402
|
}
|
|
409
403
|
size() {
|
|
410
404
|
return this.entries.size;
|
|
@@ -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 = it();
|
|
453
|
+
if (o > rt || 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), Ue);
|
|
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,37 +578,38 @@ 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-${++Ge}` : 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, Ce({
|
|
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 = fe(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
|
+
})), We(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(le.currentHeaders, (e) => ce.set(e, "voltro-resume-from", String(l)))) : u.pipe(N.locallyWith(le.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
614
|
let n = M.squash(t.cause), r = M.failureOption(t.cause), i = ae.isSome(r) ? B(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({
|
|
@@ -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 He;
|
|
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
|
+
}, ot = class extends at {
|
|
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
|
+
}, st = /* @__PURE__ */ new Set(), ct = (e) => {
|
|
664
|
+
for (let t of st) try {
|
|
647
665
|
t(e);
|
|
648
666
|
} catch {}
|
|
649
|
-
},
|
|
650
|
-
|
|
651
|
-
}),
|
|
652
|
-
|
|
667
|
+
}, lt = (e) => (st.add(e), () => {
|
|
668
|
+
st.delete(e);
|
|
669
|
+
}), ut = (e, t) => {
|
|
670
|
+
ct({
|
|
653
671
|
error: e,
|
|
654
672
|
source: "manual",
|
|
655
673
|
...t ? { context: t } : {}
|
|
656
674
|
});
|
|
657
|
-
},
|
|
675
|
+
}, dt = 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
|
+
ct({
|
|
670
688
|
error: e.error,
|
|
671
689
|
source: `rpc.${e.source}`,
|
|
672
690
|
context: {
|
|
@@ -688,32 +706,40 @@ var ve = /* @__PURE__ */ new Set(), ye = (e) => {
|
|
|
688
706
|
t(e);
|
|
689
707
|
} catch {}
|
|
690
708
|
}
|
|
691
|
-
},
|
|
692
|
-
let t = Math.trunc(
|
|
709
|
+
}, ft = (e, t, n, r) => Math.min(r, Math.max(n, e === void 0 || !Number.isFinite(e) ? t : e)), pt = (e) => {
|
|
710
|
+
let t = Math.trunc(ft(e?.maxMs, 5e3, 50, 6e4));
|
|
693
711
|
return {
|
|
694
|
-
initialMs: Math.trunc(
|
|
695
|
-
thenMs: Math.trunc(
|
|
696
|
-
factor:
|
|
712
|
+
initialMs: Math.trunc(ft(e?.initialMs, 0, 0, t)),
|
|
713
|
+
thenMs: Math.trunc(ft(e?.thenMs, 500, 50, t)),
|
|
714
|
+
factor: ft(e?.factor, 1.5, 1, 10),
|
|
697
715
|
maxMs: t
|
|
698
716
|
};
|
|
699
|
-
},
|
|
717
|
+
}, mt = (e, t) => t <= 1 ? e.initialMs : Math.min(e.maxMs, e.thenMs * e.factor ** (t - 2)), ht = (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 = mt(e, ++n);
|
|
707
725
|
return t(n, r), r;
|
|
708
726
|
})))
|
|
709
727
|
};
|
|
710
|
-
},
|
|
711
|
-
graceMs:
|
|
712
|
-
retry:
|
|
713
|
-
maxPendingMutations:
|
|
714
|
-
replayWindowMs:
|
|
728
|
+
}, gt = (e, t, n, r) => e === void 0 || !Number.isFinite(e) ? t : Math.min(r, Math.max(n, Math.trunc(e))), _t = (e) => ({
|
|
729
|
+
graceMs: gt(e?.graceMs, 1500, 0, 3e4),
|
|
730
|
+
retry: pt(e?.retry),
|
|
731
|
+
maxPendingMutations: gt(e?.maxPendingMutations, 32, 0, 256),
|
|
732
|
+
replayWindowMs: gt(e?.replayWindowMs, 1e4, 250, 6e4),
|
|
715
733
|
capabilitiesUrl: e?.capabilitiesUrl
|
|
716
|
-
}),
|
|
734
|
+
}), vt = Object.freeze({
|
|
735
|
+
rawTransport: "connected",
|
|
736
|
+
status: "connected",
|
|
737
|
+
failureCount: 0,
|
|
738
|
+
lastFailureAt: void 0,
|
|
739
|
+
failedSubscriptions: Object.freeze([]),
|
|
740
|
+
pendingMutationReplays: 0,
|
|
741
|
+
mutationReplay: "unknown"
|
|
742
|
+
}), yt = class {
|
|
717
743
|
#e;
|
|
718
744
|
#t;
|
|
719
745
|
#n;
|
|
@@ -736,7 +762,7 @@ var ve = /* @__PURE__ */ new Set(), ye = (e) => {
|
|
|
736
762
|
#y = !1;
|
|
737
763
|
#b;
|
|
738
764
|
constructor(e, t, n) {
|
|
739
|
-
this.#e = e, this.#t =
|
|
765
|
+
this.#e = e, this.#t = _t(t), this.#n = {
|
|
740
766
|
now: n?.now ?? Date.now,
|
|
741
767
|
setTimeout: n?.setTimeout ?? ((e, t) => setTimeout(e, t)),
|
|
742
768
|
clearTimeout: n?.clearTimeout ?? ((e) => clearTimeout(e))
|
|
@@ -749,6 +775,7 @@ var ve = /* @__PURE__ */ new Set(), ye = (e) => {
|
|
|
749
775
|
return this.#g.signal;
|
|
750
776
|
}
|
|
751
777
|
getSnapshot = () => this.#b;
|
|
778
|
+
getServerSnapshot = () => vt;
|
|
752
779
|
subscribe = (e) => (this.#r.add(e), () => {
|
|
753
780
|
this.#r.delete(e);
|
|
754
781
|
});
|
|
@@ -773,7 +800,7 @@ var ve = /* @__PURE__ */ new Set(), ye = (e) => {
|
|
|
773
800
|
for (let e of this.#r) try {
|
|
774
801
|
e();
|
|
775
802
|
} catch {}
|
|
776
|
-
|
|
803
|
+
H(this.#e, "recovery.state", {
|
|
777
804
|
rawTransport: this.#b.rawTransport,
|
|
778
805
|
status: this.#b.status,
|
|
779
806
|
failureCount: this.#b.failureCount,
|
|
@@ -884,51 +911,77 @@ var ve = /* @__PURE__ */ new Set(), ye = (e) => {
|
|
|
884
911
|
for (let e of this.#o) e(!1);
|
|
885
912
|
this.#o.clear(), this.#r.clear(), this.#i.clear();
|
|
886
913
|
}
|
|
887
|
-
},
|
|
888
|
-
let r =
|
|
914
|
+
}, bt = /* @__PURE__ */ new WeakMap(), xt = (e, t, n) => {
|
|
915
|
+
let r = bt.get(e);
|
|
889
916
|
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
|
-
},
|
|
917
|
+
let i = new yt(t, n);
|
|
918
|
+
return e.on((e) => i.observeError(e)), typeof e.onSuccess == "function" && e.onSuccess((e) => i.observeSuccess(e)), bt.set(e, i), i;
|
|
919
|
+
}, St = w(null), Ct = () => {
|
|
893
920
|
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) =>
|
|
921
|
+
}, wt = new Proxy(() => Ct(), {
|
|
922
|
+
get: (e, t) => wt,
|
|
896
923
|
has: () => !0,
|
|
897
|
-
apply: () =>
|
|
898
|
-
}),
|
|
899
|
-
|
|
900
|
-
},
|
|
901
|
-
|
|
902
|
-
},
|
|
924
|
+
apply: () => Ct()
|
|
925
|
+
}), Tt = Symbol.for("@voltro/client/ssrDescriptors"), Et = globalThis, Dt = Et[Tt] ?? (Et[Tt] = { byApi: /* @__PURE__ */ new Map() }), Ot = (e, t) => {
|
|
926
|
+
Dt.byApi.set(e, t);
|
|
927
|
+
}, kt = (e) => Dt.byApi.get(e), At = () => {
|
|
928
|
+
Dt.byApi.clear();
|
|
929
|
+
}, jt = {
|
|
903
930
|
runtime: { runPromiseExit: () => Promise.resolve(P.die(/* @__PURE__ */ Error("Voltro: mutations are not invokable during SSR"))) },
|
|
904
|
-
cache: new
|
|
905
|
-
client:
|
|
931
|
+
cache: new ot(),
|
|
932
|
+
client: wt,
|
|
906
933
|
descriptors: {},
|
|
907
934
|
inspectBaseUrl: "",
|
|
908
|
-
errorBus: new
|
|
909
|
-
recovery: new
|
|
910
|
-
},
|
|
935
|
+
errorBus: new dt(),
|
|
936
|
+
recovery: new yt("ssr")
|
|
937
|
+
}, Mt = {
|
|
911
938
|
get: (e) => {
|
|
912
|
-
let t =
|
|
913
|
-
return t === void 0 ?
|
|
914
|
-
...
|
|
939
|
+
let t = kt(e);
|
|
940
|
+
return t === void 0 ? jt : {
|
|
941
|
+
...jt,
|
|
915
942
|
descriptors: t
|
|
916
943
|
};
|
|
917
944
|
},
|
|
918
945
|
names: []
|
|
919
|
-
},
|
|
920
|
-
|
|
921
|
-
},
|
|
922
|
-
let e = ee(
|
|
923
|
-
return e ? (
|
|
924
|
-
|
|
925
|
-
}, 0)),
|
|
926
|
-
},
|
|
927
|
-
let t =
|
|
946
|
+
}, Nt = !1, Pt = !1, W = null, Ft = () => {
|
|
947
|
+
Nt = !1, Pt = !1, W !== null && (clearTimeout(W), W = null);
|
|
948
|
+
}, It = () => {
|
|
949
|
+
let e = ee(St);
|
|
950
|
+
return e ? (Pt || (Pt = !0, W !== null && (clearTimeout(W), W = null)), e) : (typeof window < "u" && !Nt && !Pt && W === null && process.env.NODE_ENV !== "production" && (W = setTimeout(() => {
|
|
951
|
+
W = null, !(Nt || Pt) && (Nt = !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>."));
|
|
952
|
+
}, 0)), Mt);
|
|
953
|
+
}, G = (e) => {
|
|
954
|
+
let t = It(), n = t.demand;
|
|
928
955
|
return D(() => {
|
|
929
956
|
n?.(e);
|
|
930
957
|
}, [n, e]), t.get(e);
|
|
931
|
-
},
|
|
958
|
+
}, Lt = (e) => typeof e.runtime?.runFork != "function", Rt = {
|
|
959
|
+
channel: "timer",
|
|
960
|
+
yield: (e) => {
|
|
961
|
+
setTimeout(e, 0);
|
|
962
|
+
}
|
|
963
|
+
}, zt = (e) => {
|
|
964
|
+
let t = [];
|
|
965
|
+
return e.port1.onmessage = () => {
|
|
966
|
+
t.shift()?.();
|
|
967
|
+
}, e.port1.unref?.(), {
|
|
968
|
+
channel: "message-channel",
|
|
969
|
+
yield: (n) => {
|
|
970
|
+
t.push(n), e.port2.postMessage(null);
|
|
971
|
+
}
|
|
972
|
+
};
|
|
973
|
+
}, Bt = () => typeof window < "u" && typeof MessageChannel == "function" ? zt(new MessageChannel()) : Rt, Vt = 2048, Ht = (e = Bt(), t = Vt) => {
|
|
974
|
+
let n = oe.SchedulerRunner.cached((n, r) => {
|
|
975
|
+
n >= t ? e.yield(() => r(0)) : Promise.resolve().then(() => r(n + 1));
|
|
976
|
+
});
|
|
977
|
+
return {
|
|
978
|
+
yieldChannel: e.channel,
|
|
979
|
+
shouldYield: oe.defaultShouldYield,
|
|
980
|
+
scheduleTask: (e, t, r) => {
|
|
981
|
+
n(r).scheduleTask(e, t);
|
|
982
|
+
}
|
|
983
|
+
};
|
|
984
|
+
}, Ut = (e, t, n) => {
|
|
932
985
|
try {
|
|
933
986
|
let r = typeof globalThis.location == "object" ? globalThis.location.href : void 0, i = new URL(e, r);
|
|
934
987
|
if (i.protocol === "wss:" ? i.protocol = "https:" : i.protocol === "ws:" && (i.protocol = "http:"), n !== void 0) return new URL(n, i).toString();
|
|
@@ -942,8 +995,8 @@ var ve = /* @__PURE__ */ new Set(), ye = (e) => {
|
|
|
942
995
|
} catch {
|
|
943
996
|
return;
|
|
944
997
|
}
|
|
945
|
-
},
|
|
946
|
-
let a =
|
|
998
|
+
}, Wt = async (e, t, n = fetch, r = 1500, i) => {
|
|
999
|
+
let a = Ut(e, t, i);
|
|
947
1000
|
if (a === void 0) return;
|
|
948
1001
|
let o = new AbortController(), s = setTimeout(() => o.abort(), r);
|
|
949
1002
|
try {
|
|
@@ -955,16 +1008,19 @@ var ve = /* @__PURE__ */ new Set(), ye = (e) => {
|
|
|
955
1008
|
});
|
|
956
1009
|
if (!e.ok) return;
|
|
957
1010
|
let t = await e.json();
|
|
958
|
-
|
|
1011
|
+
if (t.protocol !== 1 || typeof t.mutationReplay != "boolean") return;
|
|
1012
|
+
let r = t.surface, i = typeof r == "object" && r && !Array.isArray(r) && Object.values(r).every((e) => typeof e == "string") ? r : void 0;
|
|
1013
|
+
return {
|
|
959
1014
|
protocol: 1,
|
|
960
|
-
mutationReplay: t.mutationReplay
|
|
1015
|
+
mutationReplay: t.mutationReplay,
|
|
1016
|
+
...i === void 0 ? {} : { surface: i }
|
|
961
1017
|
};
|
|
962
1018
|
} catch {
|
|
963
1019
|
return;
|
|
964
1020
|
} finally {
|
|
965
1021
|
clearTimeout(s);
|
|
966
1022
|
}
|
|
967
|
-
},
|
|
1023
|
+
}, Gt = class {
|
|
968
1024
|
#e;
|
|
969
1025
|
#t;
|
|
970
1026
|
#n;
|
|
@@ -993,9 +1049,9 @@ var ve = /* @__PURE__ */ new Set(), ye = (e) => {
|
|
|
993
1049
|
e();
|
|
994
1050
|
} catch {}
|
|
995
1051
|
}
|
|
996
|
-
},
|
|
997
|
-
|
|
998
|
-
},
|
|
1052
|
+
}, Kt = /* @__PURE__ */ new WeakMap(), qt = (e, t) => {
|
|
1053
|
+
Kt.set(e, t);
|
|
1054
|
+
}, Jt = (e) => Kt.get(e), Yt = (e, t, n = new Gt()) => _e.Socket.of({
|
|
999
1055
|
...e,
|
|
1000
1056
|
runRaw: (r, i) => N.acquireUseRelease(N.sync(() => n.begin()), (n) => e.runRaw(r, {
|
|
1001
1057
|
...i,
|
|
@@ -1003,53 +1059,72 @@ var ve = /* @__PURE__ */ new Set(), ye = (e) => {
|
|
|
1003
1059
|
n.open() !== void 0 && t();
|
|
1004
1060
|
}))
|
|
1005
1061
|
}), (e) => N.sync(e.close))
|
|
1006
|
-
}),
|
|
1062
|
+
}), Xt = 3, Zt = (e, t, n) => {
|
|
1063
|
+
let r;
|
|
1064
|
+
try {
|
|
1065
|
+
r = pe(he(t), n);
|
|
1066
|
+
} catch {
|
|
1067
|
+
return;
|
|
1068
|
+
}
|
|
1069
|
+
let { differing: i, missingHere: a } = r;
|
|
1070
|
+
if (i.length === 0 && a.length === 0) return;
|
|
1071
|
+
H(e, "runtime.surface-mismatch", {
|
|
1072
|
+
differing: i.length,
|
|
1073
|
+
missingHere: a.length,
|
|
1074
|
+
first: i[0] ?? a[0] ?? null
|
|
1075
|
+
});
|
|
1076
|
+
let o = [...i, ...a].slice(0, Xt), s = i.length + a.length - o.length;
|
|
1077
|
+
console.warn(`[voltro] the api client this page loaded does not match what the '${e}' server binds: ${o.join(", ")}${s > 0 ? ` and ${s} more` : ""}. Responses for those procedures may decode against the wrong schema — a field the server sends and this client does not know is dropped silently. Reload; if it persists, stop the dev server, delete \`.framework/.vite\`, and start it again.`);
|
|
1078
|
+
}, Qt = async (e) => {
|
|
1007
1079
|
let { name: t, wsUrl: n, group: r, headers: i, webSocketConstructor: a } = e, o = e.generation ?? 0;
|
|
1008
|
-
|
|
1009
|
-
let s = e.errorBus ?? new
|
|
1010
|
-
|
|
1080
|
+
H(t, "runtime.build-started", { generation: o });
|
|
1081
|
+
let s = e.errorBus ?? new dt(), c = e.recovery ?? xt(s, t), l = ht(c.options.retry, (e, n) => {
|
|
1082
|
+
H(t, "socket.retry-scheduled", {
|
|
1011
1083
|
generation: o,
|
|
1012
1084
|
attempt: e,
|
|
1013
1085
|
delayMs: n,
|
|
1014
1086
|
owner: "socket"
|
|
1015
1087
|
});
|
|
1016
1088
|
});
|
|
1017
|
-
|
|
1018
|
-
c.setMutationReplaySupported(e?.mutationReplay === !0, o),
|
|
1089
|
+
Wt(n, t, fetch, 1500, c.options.capabilitiesUrl).then((e) => {
|
|
1090
|
+
c.setMutationReplaySupported(e?.mutationReplay === !0, o), H(t, "runtime.capabilities", {
|
|
1019
1091
|
mutationReplay: e?.mutationReplay === !0,
|
|
1020
1092
|
discovered: e !== void 0
|
|
1021
|
-
});
|
|
1093
|
+
}), e?.surface !== void 0 && Zt(t, r, e.surface);
|
|
1022
1094
|
});
|
|
1023
|
-
let u = new
|
|
1095
|
+
let u = new at({
|
|
1024
1096
|
errorBus: s,
|
|
1025
1097
|
apiName: t
|
|
1026
|
-
}), d = new
|
|
1098
|
+
}), d = new Gt(), f;
|
|
1027
1099
|
class p extends ne.Tag(`@voltro/client/AppClient/${t}`)() {}
|
|
1028
|
-
let m = F.succeed(
|
|
1100
|
+
let m = F.succeed(_e.WebSocketConstructor, a), h = _e.layerWebSocket(n).pipe(F.provide(m)), g = F.effect(_e.Socket, N.map(_e.Socket, (e) => Yt(e, () => {
|
|
1029
1101
|
l.reset();
|
|
1030
1102
|
let e = 0;
|
|
1031
|
-
f !== void 0 && (e = u.resumeTransportFailures(f)),
|
|
1103
|
+
f !== void 0 && (e = u.resumeTransportFailures(f)), H(t, "protocol.ready", {
|
|
1032
1104
|
generation: o,
|
|
1033
1105
|
resumed: e
|
|
1034
1106
|
}), c.protocolReady();
|
|
1035
|
-
}, d))).pipe(F.provide(h)), _ =
|
|
1036
|
-
f =
|
|
1107
|
+
}, d))).pipe(F.provide(h)), _ = le.layerProtocolSocket({ retrySchedule: l.schedule }).pipe(F.provide(de.layerJson), F.provide(g)), v = typeof i == "function" ? await i() : i, y = F.scoped(p, le.make(r)).pipe(F.provide(_)), b = v ? F.locallyScoped(le.currentHeaders, ce.fromInput(v)) : F.empty, x = Ht(), S = I.make(F.merge(y, b).pipe(F.provide(F.setScheduler(x))));
|
|
1108
|
+
f = S, qt(f, d);
|
|
1037
1109
|
try {
|
|
1038
|
-
let e = await
|
|
1039
|
-
return
|
|
1040
|
-
|
|
1110
|
+
let e = await S.runPromise(p);
|
|
1111
|
+
return H(t, "runtime.resolved", {
|
|
1112
|
+
generation: o,
|
|
1113
|
+
scheduler: x.yieldChannel
|
|
1114
|
+
}), {
|
|
1115
|
+
runtime: S,
|
|
1041
1116
|
client: e,
|
|
1042
1117
|
cache: u,
|
|
1043
1118
|
errorBus: s,
|
|
1044
1119
|
recovery: c
|
|
1045
1120
|
};
|
|
1046
1121
|
} catch (e) {
|
|
1047
|
-
throw
|
|
1122
|
+
throw H(t, "runtime.failed", {
|
|
1048
1123
|
generation: o,
|
|
1049
1124
|
errorName: e instanceof Error ? e.name : typeof e
|
|
1050
|
-
}),
|
|
1125
|
+
}), S.dispose(), e;
|
|
1051
1126
|
}
|
|
1052
|
-
},
|
|
1127
|
+
}, $t = (e, t, n) => ({
|
|
1053
1128
|
resolved: null,
|
|
1054
1129
|
retryToken: 0,
|
|
1055
1130
|
failureCount: 0,
|
|
@@ -1063,17 +1138,17 @@ var ve = /* @__PURE__ */ new Set(), ye = (e) => {
|
|
|
1063
1138
|
stopRecoveryError: e.on((e) => t.observeError(e)),
|
|
1064
1139
|
stopRecoverySuccess: e.onSuccess((e) => t.observeSuccess(e)),
|
|
1065
1140
|
ownsRecovery: n
|
|
1066
|
-
}),
|
|
1141
|
+
}), en = (e) => {
|
|
1067
1142
|
e.wedgeStop !== null && (e.wedgeStop(), e.wedgeStop = null);
|
|
1068
|
-
},
|
|
1143
|
+
}, tn = (e) => {
|
|
1069
1144
|
e.cache.destroy(e.runtime), e.runtime.dispose();
|
|
1070
|
-
},
|
|
1145
|
+
}, nn = (e) => {
|
|
1071
1146
|
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
1147
|
clearTimeout(e);
|
|
1073
1148
|
}), s = e.scheduler?.queueMicrotask ?? queueMicrotask, c = e.onReconnecting, l = e.wedgeBackstop, u = /* @__PURE__ */ new Map();
|
|
1074
1149
|
for (let n of t) {
|
|
1075
|
-
let t = e.errorBusFor?.(n.name) ?? new
|
|
1076
|
-
u.set(n.name,
|
|
1150
|
+
let t = e.errorBusFor?.(n.name) ?? new dt(), r = e.recoveryFor?.(n.name, n.recovery), i = r ?? new yt(n.name, n.recovery);
|
|
1151
|
+
u.set(n.name, $t(t, i, r === void 0));
|
|
1077
1152
|
}
|
|
1078
1153
|
let d = !1, f = /* @__PURE__ */ new Set(), p = (e, t) => {
|
|
1079
1154
|
let n = a(() => {
|
|
@@ -1092,8 +1167,8 @@ var ve = /* @__PURE__ */ new Set(), ye = (e) => {
|
|
|
1092
1167
|
let n = u.get(t.name);
|
|
1093
1168
|
if (!n) return;
|
|
1094
1169
|
h(t, n);
|
|
1095
|
-
let r = e.retryDelayMs?.(n.failureCount) ??
|
|
1096
|
-
|
|
1170
|
+
let r = e.retryDelayMs?.(n.failureCount) ?? mt(n.recovery.options.retry, n.failureCount);
|
|
1171
|
+
H(t.name, "socket.retry-scheduled", {
|
|
1097
1172
|
generation: n.generation,
|
|
1098
1173
|
attempt: n.failureCount,
|
|
1099
1174
|
delayMs: r,
|
|
@@ -1109,7 +1184,7 @@ var ve = /* @__PURE__ */ new Set(), ye = (e) => {
|
|
|
1109
1184
|
if (!t) return;
|
|
1110
1185
|
let r = t.generation, a = () => {
|
|
1111
1186
|
if (d || t.generation !== r) return;
|
|
1112
|
-
t.everOpened = !0,
|
|
1187
|
+
t.everOpened = !0, en(t), t.reconnectStatusDispose &&= (t.reconnectStatusDispose(), null), t.retryToken++;
|
|
1113
1188
|
let e = t.failureCount;
|
|
1114
1189
|
p(() => {
|
|
1115
1190
|
d || t.failureCount === e && (t.failureCount = 0);
|
|
@@ -1120,16 +1195,16 @@ var ve = /* @__PURE__ */ new Set(), ye = (e) => {
|
|
|
1120
1195
|
try {
|
|
1121
1196
|
let i = await n(e, r, a, o, t.errorBus, t.recovery);
|
|
1122
1197
|
if (d || t.generation !== r) {
|
|
1123
|
-
|
|
1198
|
+
tn(i);
|
|
1124
1199
|
return;
|
|
1125
1200
|
}
|
|
1126
1201
|
let s = t.resolved, c = t.subjectMayHaveChanged, l = s && !c ? i.cache.seedStaleFrom(s.cache) : 0;
|
|
1127
|
-
t.subjectMayHaveChanged = !1, t.resolved = i,
|
|
1202
|
+
t.subjectMayHaveChanged = !1, t.resolved = i, H(e.name, "runtime.swapped", {
|
|
1128
1203
|
generation: r,
|
|
1129
1204
|
replaced: s !== null,
|
|
1130
1205
|
seeded: l,
|
|
1131
1206
|
subjectMayHaveChanged: c
|
|
1132
|
-
}), m(), s &&
|
|
1207
|
+
}), m(), s && tn(s);
|
|
1133
1208
|
} catch {
|
|
1134
1209
|
if (d || t.generation !== r) return;
|
|
1135
1210
|
g(e);
|
|
@@ -1137,7 +1212,7 @@ var ve = /* @__PURE__ */ new Set(), ye = (e) => {
|
|
|
1137
1212
|
}, v = (e) => {
|
|
1138
1213
|
if (!d) for (let n of t) {
|
|
1139
1214
|
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,
|
|
1215
|
+
t && (e && (t.subjectMayHaveChanged = !0), t.retryToken += 1, t.generation += 1, e && t.recovery.resetForSubjectChange(t.generation), t.failureCount = 0, en(t), _(n));
|
|
1141
1216
|
}
|
|
1142
1217
|
};
|
|
1143
1218
|
return t.length === 0 ? (r(/* @__PURE__ */ new Map(), !0), {
|
|
@@ -1154,8 +1229,8 @@ var ve = /* @__PURE__ */ new Set(), ye = (e) => {
|
|
|
1154
1229
|
d = !0;
|
|
1155
1230
|
for (let e of f) o(e);
|
|
1156
1231
|
f.clear();
|
|
1157
|
-
for (let [, e] of u) e.resolved &&
|
|
1158
|
-
for (let e of t)
|
|
1232
|
+
for (let [, e] of u) e.resolved && tn(e.resolved), e.reconnectStatusDispose && e.reconnectStatusDispose(), en(e), e.stopRecoveryError(), e.stopRecoverySuccess(), e.ownsRecovery && e.recovery.dispose();
|
|
1233
|
+
for (let e of t) H(e.name, "runtime.disposed");
|
|
1159
1234
|
u.clear();
|
|
1160
1235
|
}
|
|
1161
1236
|
},
|
|
@@ -1166,7 +1241,7 @@ var ve = /* @__PURE__ */ new Set(), ye = (e) => {
|
|
|
1166
1241
|
v(!1);
|
|
1167
1242
|
}
|
|
1168
1243
|
});
|
|
1169
|
-
},
|
|
1244
|
+
}, rn = ({ apis: e, children: t, demand: n }) => {
|
|
1170
1245
|
let r = O(() => ({
|
|
1171
1246
|
get: (t) => {
|
|
1172
1247
|
let n = e.get(t);
|
|
@@ -1179,45 +1254,45 @@ var ve = /* @__PURE__ */ new Set(), ye = (e) => {
|
|
|
1179
1254
|
names: Array.from(e.keys()),
|
|
1180
1255
|
...n === void 0 ? {} : { demand: n }
|
|
1181
1256
|
}), [e]);
|
|
1182
|
-
return /* @__PURE__ */
|
|
1257
|
+
return /* @__PURE__ */ ve(St.Provider, {
|
|
1183
1258
|
value: r,
|
|
1184
1259
|
children: t
|
|
1185
1260
|
});
|
|
1186
|
-
},
|
|
1187
|
-
let e = globalThis, t = e[
|
|
1261
|
+
}, an = Symbol.for("@voltro/client/storeStorageProvider"), on = () => {
|
|
1262
|
+
let e = globalThis, t = e[an];
|
|
1188
1263
|
if (t !== void 0) return t;
|
|
1189
1264
|
let n = {
|
|
1190
1265
|
provider: void 0,
|
|
1191
1266
|
used: !1
|
|
1192
1267
|
};
|
|
1193
|
-
return e[
|
|
1194
|
-
},
|
|
1268
|
+
return e[an] = n, n;
|
|
1269
|
+
}, sn = (e) => {
|
|
1195
1270
|
if (typeof window > "u") return null;
|
|
1196
1271
|
try {
|
|
1197
1272
|
return (e === "session" ? window.sessionStorage : window.localStorage) ?? null;
|
|
1198
1273
|
} catch {
|
|
1199
1274
|
return null;
|
|
1200
1275
|
}
|
|
1201
|
-
},
|
|
1202
|
-
let t =
|
|
1276
|
+
}, cn = (e) => {
|
|
1277
|
+
let t = on();
|
|
1203
1278
|
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 =
|
|
1279
|
+
}, ln = (e) => {
|
|
1280
|
+
let t = on();
|
|
1281
|
+
return t.used = !0, (t.provider ?? sn)(e);
|
|
1282
|
+
}, un = () => {
|
|
1283
|
+
let e = on();
|
|
1209
1284
|
e.provider = void 0, e.used = !1;
|
|
1210
|
-
},
|
|
1285
|
+
}, dn = (e, t) => {
|
|
1211
1286
|
if (Object.is(e, t)) return !0;
|
|
1212
1287
|
if (typeof e != "object" || typeof t != "object" || e === null || t === null || Array.isArray(e) !== Array.isArray(t)) return !1;
|
|
1213
1288
|
let n = Object.keys(e), r = Object.keys(t);
|
|
1214
1289
|
if (n.length !== r.length) return !1;
|
|
1215
1290
|
for (let r of n) if (!Object.prototype.hasOwnProperty.call(t, r) || !Object.is(e[r], t[r])) return !1;
|
|
1216
1291
|
return !0;
|
|
1217
|
-
},
|
|
1218
|
-
|
|
1219
|
-
},
|
|
1220
|
-
let r =
|
|
1292
|
+
}, fn = 50, pn = /* @__PURE__ */ new Set(), mn = (e, t) => {
|
|
1293
|
+
pn.has(e) || (pn.add(e), console.warn(t));
|
|
1294
|
+
}, hn = "\0global", gn = null, _n = (e, t, n) => {
|
|
1295
|
+
let r = gn?.() ?? null;
|
|
1221
1296
|
if (r === null) return n;
|
|
1222
1297
|
let i = n;
|
|
1223
1298
|
for (let n of r.seeds) n.store === e && n.key === t && (i = {
|
|
@@ -1225,9 +1300,9 @@ var ve = /* @__PURE__ */ new Set(), ye = (e) => {
|
|
|
1225
1300
|
...n.value
|
|
1226
1301
|
});
|
|
1227
1302
|
return i;
|
|
1228
|
-
},
|
|
1303
|
+
}, vn = (e, t) => {
|
|
1229
1304
|
let n = e(), r = /* @__PURE__ */ new Set(), i = 0, a = 0, o, s, c = () => {
|
|
1230
|
-
if (i >=
|
|
1305
|
+
if (i >= fn) throw i = 0, Error(`defineStore: notification depth exceeded ${fn} — 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
1306
|
i += 1;
|
|
1232
1307
|
try {
|
|
1233
1308
|
for (let e of [...r]) e();
|
|
@@ -1248,20 +1323,20 @@ var ve = /* @__PURE__ */ new Set(), ye = (e) => {
|
|
|
1248
1323
|
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
1324
|
if (--a, a > 0) return;
|
|
1250
1325
|
let l = o, u = s;
|
|
1251
|
-
o = void 0, s = void 0, !
|
|
1326
|
+
o = void 0, s = void 0, !dn(l, n) && (t(l, n, u), c());
|
|
1252
1327
|
},
|
|
1253
1328
|
set: (e, r) => {
|
|
1254
1329
|
let i = typeof e == "function" ? e(n) : {
|
|
1255
1330
|
...n,
|
|
1256
1331
|
...e
|
|
1257
1332
|
};
|
|
1258
|
-
if (
|
|
1333
|
+
if (dn(i, n)) return;
|
|
1259
1334
|
let o = n;
|
|
1260
1335
|
n = i, !(a > 0) && (t(o, i, r), c());
|
|
1261
1336
|
},
|
|
1262
1337
|
reset: () => {
|
|
1263
1338
|
let r = e();
|
|
1264
|
-
if (
|
|
1339
|
+
if (dn(r, n)) return;
|
|
1265
1340
|
let i = n;
|
|
1266
1341
|
n = r, !(a > 0) && (t(i, r, "reset"), c());
|
|
1267
1342
|
},
|
|
@@ -1269,51 +1344,51 @@ var ve = /* @__PURE__ */ new Set(), ye = (e) => {
|
|
|
1269
1344
|
r.delete(e);
|
|
1270
1345
|
})
|
|
1271
1346
|
};
|
|
1272
|
-
},
|
|
1273
|
-
|
|
1274
|
-
}),
|
|
1275
|
-
|
|
1276
|
-
},
|
|
1277
|
-
let n =
|
|
1347
|
+
}, yn = 200, bn = [], xn = /* @__PURE__ */ new Set(), Sn = [], Cn = () => Sn, wn = (e) => (xn.add(e), () => {
|
|
1348
|
+
xn.delete(e);
|
|
1349
|
+
}), Tn = () => {
|
|
1350
|
+
bn.length = 0, Sn = [];
|
|
1351
|
+
}, En = (e, t) => {
|
|
1352
|
+
let n = bn[e];
|
|
1278
1353
|
if (n === void 0) return !1;
|
|
1279
|
-
let r =
|
|
1354
|
+
let r = An.get(n.store);
|
|
1280
1355
|
if (r === void 0) return !1;
|
|
1281
1356
|
let i = t === "before" ? n.prev : n.next;
|
|
1282
|
-
|
|
1357
|
+
On = !0;
|
|
1283
1358
|
try {
|
|
1284
1359
|
r.set(() => i, n.key, `travel:${t}`);
|
|
1285
1360
|
} finally {
|
|
1286
|
-
|
|
1361
|
+
On = !1;
|
|
1287
1362
|
}
|
|
1288
1363
|
return !0;
|
|
1289
|
-
},
|
|
1290
|
-
|
|
1291
|
-
for (let e of [...
|
|
1292
|
-
},
|
|
1293
|
-
|
|
1294
|
-
})),
|
|
1295
|
-
function
|
|
1364
|
+
}, Dn = !1, On = !1, kn = (e) => {
|
|
1365
|
+
bn.push(e), bn.length > yn && bn.shift(), Sn = [...bn];
|
|
1366
|
+
for (let e of [...xn]) e();
|
|
1367
|
+
}, An = /* @__PURE__ */ new Map(), jn = /* @__PURE__ */ new Map(), Mn = 0, Nn = !1, Pn = /* @__PURE__ */ new Map(), Fn = () => (Nn || (Nn = !0, queueMicrotask(() => {
|
|
1368
|
+
Mn += 1, Nn = !1;
|
|
1369
|
+
})), Mn), In = Ln(((/* @__PURE__ */ Error()).stack ?? "").split("\n")[1] ?? "") ?? "";
|
|
1370
|
+
function Ln(e) {
|
|
1296
1371
|
let t = e.trim().replace(/^at\s+/, ""), n = /\(([^()]+)\)\s*$/.exec(t)?.[1] ?? t;
|
|
1297
1372
|
return n.length > 0 ? n : void 0;
|
|
1298
1373
|
}
|
|
1299
|
-
var
|
|
1374
|
+
var Rn = () => {
|
|
1300
1375
|
let e = (/* @__PURE__ */ Error()).stack;
|
|
1301
1376
|
if (typeof e != "string") return "<unknown>";
|
|
1302
1377
|
for (let t of e.split("\n").slice(1)) {
|
|
1303
|
-
let e =
|
|
1378
|
+
let e = Ln(t);
|
|
1304
1379
|
if (e === void 0) continue;
|
|
1305
1380
|
let n = e.replace(/:\d+:\d+$/, "");
|
|
1306
|
-
if (
|
|
1381
|
+
if (In === "" || n !== In.replace(/:\d+:\d+$/, "")) return n;
|
|
1307
1382
|
}
|
|
1308
1383
|
return "<unknown>";
|
|
1309
|
-
},
|
|
1310
|
-
let r =
|
|
1384
|
+
}, zn = () => [...An.values()], Bn = (e, t, n) => {
|
|
1385
|
+
let r = Rn(), i = Fn(), a = An.get(e);
|
|
1311
1386
|
if (a !== void 0) {
|
|
1312
|
-
let t =
|
|
1387
|
+
let t = jn.get(e) ?? "<unknown>", n = Pn.get(e) === i;
|
|
1313
1388
|
if (r !== "<unknown>" && r === t && !n) return a;
|
|
1314
1389
|
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
1390
|
}
|
|
1316
|
-
let o = n?.persist, s = () =>
|
|
1391
|
+
let o = n?.persist, s = () => ln(o?.storage === "session" ? "session" : "local"), c = () => {
|
|
1317
1392
|
let e = s();
|
|
1318
1393
|
if (e === null || o === void 0) return;
|
|
1319
1394
|
let t;
|
|
@@ -1338,28 +1413,28 @@ var Cn = () => {
|
|
|
1338
1413
|
t.setItem(o.key, JSON.stringify(n));
|
|
1339
1414
|
} catch {}
|
|
1340
1415
|
}, u = /* @__PURE__ */ new Map(), d = (n) => {
|
|
1341
|
-
let r = n ??
|
|
1416
|
+
let r = n ?? hn, i = u.get(r);
|
|
1342
1417
|
if (i === void 0) {
|
|
1343
1418
|
let a = n;
|
|
1344
|
-
i =
|
|
1419
|
+
i = vn(o !== void 0 && n === void 0 ? () => {
|
|
1345
1420
|
let e = t();
|
|
1346
1421
|
return f = e, {
|
|
1347
1422
|
...e,
|
|
1348
1423
|
...c() ?? {}
|
|
1349
1424
|
};
|
|
1350
1425
|
} : t, (t, n, r) => {
|
|
1351
|
-
if (o !== void 0 && a === void 0 && l(n), !
|
|
1426
|
+
if (o !== void 0 && a === void 0 && l(n), !Dn && !On) {
|
|
1352
1427
|
let e = m(a);
|
|
1353
1428
|
e.steps.length = e.cursor, e.steps.push({
|
|
1354
1429
|
prev: t,
|
|
1355
1430
|
next: n
|
|
1356
1431
|
}), e.steps.length > h && e.steps.shift(), e.cursor = e.steps.length;
|
|
1357
1432
|
}
|
|
1358
|
-
|
|
1433
|
+
kn({
|
|
1359
1434
|
store: e,
|
|
1360
1435
|
...a === void 0 ? {} : { key: a },
|
|
1361
1436
|
...r === void 0 ? {} : { label: r },
|
|
1362
|
-
...
|
|
1437
|
+
...Dn || On ? { isUndo: !0 } : {},
|
|
1363
1438
|
prev: t,
|
|
1364
1439
|
next: n,
|
|
1365
1440
|
at: Date.now()
|
|
@@ -1368,7 +1443,7 @@ var Cn = () => {
|
|
|
1368
1443
|
}
|
|
1369
1444
|
return i;
|
|
1370
1445
|
}, f, p = /* @__PURE__ */ new Map(), m = (e) => {
|
|
1371
|
-
let t = e ??
|
|
1446
|
+
let t = e ?? hn, n = p.get(t);
|
|
1372
1447
|
return n === void 0 && (n = {
|
|
1373
1448
|
steps: [],
|
|
1374
1449
|
cursor: 0
|
|
@@ -1400,12 +1475,12 @@ var Cn = () => {
|
|
|
1400
1475
|
let n = o.current;
|
|
1401
1476
|
if (n.has && Object.is(n.state, t)) return n.value;
|
|
1402
1477
|
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 &&
|
|
1478
|
+
if (process.env.NODE_ENV !== "production" && s === void 0 && n.has && !c && typeof r == "object" && r && dn(n.value, r)) {
|
|
1404
1479
|
let t = !0;
|
|
1405
1480
|
try {
|
|
1406
1481
|
t = !Object.is(i.current(n.state), n.value);
|
|
1407
1482
|
} catch {}
|
|
1408
|
-
|
|
1483
|
+
mn(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
1484
|
}
|
|
1410
1485
|
let l = c ? n.value : r;
|
|
1411
1486
|
return o.current = {
|
|
@@ -1422,7 +1497,7 @@ var Cn = () => {
|
|
|
1422
1497
|
r,
|
|
1423
1498
|
c,
|
|
1424
1499
|
l
|
|
1425
|
-
]), p = E(() => s(r.get()), [r, s]), m = E(() => s(
|
|
1500
|
+
]), p = E(() => s(r.get()), [r, s]), m = E(() => s(_n(e, n?.key, n?.key === void 0 && f !== void 0 ? f : r.get())), [
|
|
1426
1501
|
r,
|
|
1427
1502
|
n?.key,
|
|
1428
1503
|
s
|
|
@@ -1440,11 +1515,11 @@ var Cn = () => {
|
|
|
1440
1515
|
undo: (e) => {
|
|
1441
1516
|
let t = m(e);
|
|
1442
1517
|
if (t.cursor === 0) return !1;
|
|
1443
|
-
--t.cursor,
|
|
1518
|
+
--t.cursor, Dn = !0;
|
|
1444
1519
|
try {
|
|
1445
1520
|
d(e).set(() => t.steps[t.cursor].prev, "undo");
|
|
1446
1521
|
} finally {
|
|
1447
|
-
|
|
1522
|
+
Dn = !1;
|
|
1448
1523
|
}
|
|
1449
1524
|
return !0;
|
|
1450
1525
|
},
|
|
@@ -1452,11 +1527,11 @@ var Cn = () => {
|
|
|
1452
1527
|
let t = m(e);
|
|
1453
1528
|
if (t.cursor >= t.steps.length) return !1;
|
|
1454
1529
|
let n = t.steps[t.cursor];
|
|
1455
|
-
t.cursor += 1,
|
|
1530
|
+
t.cursor += 1, Dn = !0;
|
|
1456
1531
|
try {
|
|
1457
1532
|
d(e).set(() => n.next, "redo");
|
|
1458
1533
|
} finally {
|
|
1459
|
-
|
|
1534
|
+
Dn = !1;
|
|
1460
1535
|
}
|
|
1461
1536
|
return !0;
|
|
1462
1537
|
},
|
|
@@ -1468,27 +1543,27 @@ var Cn = () => {
|
|
|
1468
1543
|
release: (e) => {
|
|
1469
1544
|
u.delete(e), p.delete(e);
|
|
1470
1545
|
},
|
|
1471
|
-
keys: () => [...u.keys()].filter((e) => e !==
|
|
1546
|
+
keys: () => [...u.keys()].filter((e) => e !== hn)
|
|
1472
1547
|
};
|
|
1473
|
-
return
|
|
1474
|
-
},
|
|
1475
|
-
|
|
1476
|
-
},
|
|
1477
|
-
|
|
1478
|
-
},
|
|
1479
|
-
let r =
|
|
1548
|
+
return An.set(e, b), jn.set(e, r), Pn.set(e, i), b;
|
|
1549
|
+
}, Vn = () => {
|
|
1550
|
+
An.clear(), jn.clear(), Pn.clear(), pn.clear();
|
|
1551
|
+
}, Hn = () => ({ seeds: [] }), Un = (e) => {
|
|
1552
|
+
gn = e;
|
|
1553
|
+
}, Wn = (e, t, n) => {
|
|
1554
|
+
let r = gn?.() ?? null;
|
|
1480
1555
|
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
1556
|
r.seeds.push({
|
|
1482
1557
|
store: e.name,
|
|
1483
1558
|
...n?.key === void 0 ? {} : { key: n.key },
|
|
1484
1559
|
value: t
|
|
1485
1560
|
});
|
|
1486
|
-
},
|
|
1561
|
+
}, Gn = (e) => {
|
|
1487
1562
|
if (e !== void 0) for (let t of e) {
|
|
1488
|
-
let e =
|
|
1563
|
+
let e = An.get(t.store);
|
|
1489
1564
|
e !== void 0 && e.set(t.value, t.key);
|
|
1490
1565
|
}
|
|
1491
|
-
},
|
|
1566
|
+
}, K = (e, t) => {
|
|
1492
1567
|
let n = t.split("."), r = e;
|
|
1493
1568
|
for (let e = 0; e < n.length; e++) {
|
|
1494
1569
|
let i = n[e];
|
|
@@ -1507,15 +1582,15 @@ var Cn = () => {
|
|
|
1507
1582
|
}
|
|
1508
1583
|
if (typeof r != "function") throw Error(`@voltro/client: rpc tag ${JSON.stringify(t)} did not resolve to a callable method.`);
|
|
1509
1584
|
return r;
|
|
1510
|
-
},
|
|
1585
|
+
}, Kn = Object.freeze({
|
|
1511
1586
|
data: void 0,
|
|
1512
1587
|
revision: -1,
|
|
1513
1588
|
emittedAt: void 0,
|
|
1514
1589
|
error: void 0,
|
|
1515
1590
|
pendingPatches: 0
|
|
1516
|
-
}),
|
|
1517
|
-
function
|
|
1518
|
-
let i = r.skip === !0, { runtime: a, cache: o, client: s, descriptors: c } =
|
|
1591
|
+
}), qn = () => Kn;
|
|
1592
|
+
function q(e, t, n = {}, r = {}) {
|
|
1593
|
+
let i = r.skip === !0, { runtime: a, cache: o, client: s, descriptors: c } = G(e), l = c[t]?.source, u = k(n);
|
|
1519
1594
|
u.current = n;
|
|
1520
1595
|
let d = k(s);
|
|
1521
1596
|
d.current = s;
|
|
@@ -1523,7 +1598,7 @@ function J(e, t, n = {}, r = {}) {
|
|
|
1523
1598
|
let e = u.current;
|
|
1524
1599
|
return {
|
|
1525
1600
|
queryKey: [t, e],
|
|
1526
|
-
fetch: () =>
|
|
1601
|
+
fetch: () => K(d.current, t)(e)
|
|
1527
1602
|
};
|
|
1528
1603
|
}, [t, f]), m = p.queryKey, h = E((e) => i ? () => {} : o.subscribe(p.queryKey, p.fetch, a, e, l === void 0 ? {} : { source: l }).unsubscribe, [
|
|
1529
1604
|
o,
|
|
@@ -1531,11 +1606,11 @@ function J(e, t, n = {}, r = {}) {
|
|
|
1531
1606
|
l,
|
|
1532
1607
|
i,
|
|
1533
1608
|
p
|
|
1534
|
-
]), g = E(() => i ?
|
|
1609
|
+
]), g = E(() => i ? Kn : o.peek(m), [
|
|
1535
1610
|
o,
|
|
1536
1611
|
i,
|
|
1537
1612
|
m
|
|
1538
|
-
]), _ = j(h, g,
|
|
1613
|
+
]), _ = j(h, g, qn), v = _.data !== void 0, y = v && (Array.isArray(_.data) ? _.data.length === 0 : _.data === null), b = {
|
|
1539
1614
|
revision: _.revision,
|
|
1540
1615
|
emittedAt: _.emittedAt,
|
|
1541
1616
|
error: _.error,
|
|
@@ -1592,35 +1667,35 @@ function J(e, t, n = {}, r = {}) {
|
|
|
1592
1667
|
}
|
|
1593
1668
|
//#endregion
|
|
1594
1669
|
//#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 ${
|
|
1600
|
-
},
|
|
1670
|
+
var Jn = 15e3, J = async (e, t, n) => {
|
|
1671
|
+
if (!Lt(e.current)) return e.current;
|
|
1672
|
+
let r = Date.now() + Jn;
|
|
1673
|
+
for (; Date.now() < r;) if (await new Promise((e) => setTimeout(e, 16)), !Lt(e.current)) return e.current;
|
|
1674
|
+
throw Error(`Voltro: the api "${t}" did not resolve within ${Jn}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.`);
|
|
1675
|
+
}, Y = async (e, t) => {
|
|
1601
1676
|
let n = await e.runPromiseExit(t);
|
|
1602
1677
|
if (P.isSuccess(n)) return n.value;
|
|
1603
1678
|
let r = M.squash(n.cause), i = M.failureOption(n.cause);
|
|
1604
|
-
throw
|
|
1605
|
-
},
|
|
1606
|
-
|
|
1607
|
-
},
|
|
1608
|
-
|
|
1609
|
-
for (let e of
|
|
1679
|
+
throw z(r, ae.isSome(i) ? B(i.value, "handler") : "unknown");
|
|
1680
|
+
}, Yn = 100, X = [], Xn = /* @__PURE__ */ new Set(), Zn = [], Qn = () => {
|
|
1681
|
+
Zn = X.slice();
|
|
1682
|
+
}, $n = () => {
|
|
1683
|
+
Qn();
|
|
1684
|
+
for (let e of Xn) try {
|
|
1610
1685
|
e();
|
|
1611
1686
|
} catch {}
|
|
1612
|
-
},
|
|
1687
|
+
}, er = (e) => {
|
|
1613
1688
|
let t = {
|
|
1614
1689
|
...e,
|
|
1615
1690
|
status: "pending",
|
|
1616
1691
|
startedAt: Date.now()
|
|
1617
1692
|
};
|
|
1618
|
-
|
|
1619
|
-
},
|
|
1620
|
-
let n =
|
|
1693
|
+
X.unshift(t), X.length > Yn && (X.length = Yn), $n();
|
|
1694
|
+
}, Z = (e, t) => {
|
|
1695
|
+
let n = X.findIndex((t) => t.id === e);
|
|
1621
1696
|
if (n === -1) return;
|
|
1622
|
-
let r =
|
|
1623
|
-
|
|
1697
|
+
let r = X[n], i = Date.now();
|
|
1698
|
+
X[n] = t.status === "success" ? {
|
|
1624
1699
|
...r,
|
|
1625
1700
|
status: "success",
|
|
1626
1701
|
output: t.output,
|
|
@@ -1632,27 +1707,27 @@ var Nn = 15e3, Y = async (e, t, n) => {
|
|
|
1632
1707
|
error: t.error,
|
|
1633
1708
|
settledAt: i,
|
|
1634
1709
|
durationMs: i - r.startedAt
|
|
1635
|
-
},
|
|
1636
|
-
},
|
|
1637
|
-
|
|
1638
|
-
}),
|
|
1639
|
-
|
|
1640
|
-
},
|
|
1710
|
+
}, $n();
|
|
1711
|
+
}, tr = () => Zn, nr = (e) => (Xn.add(e), () => {
|
|
1712
|
+
Xn.delete(e);
|
|
1713
|
+
}), rr = () => {
|
|
1714
|
+
X.length !== 0 && (X.length = 0, $n());
|
|
1715
|
+
}, ir = /* @__PURE__ */ new WeakMap(), ar = (e, t) => {
|
|
1641
1716
|
let n = Object.freeze({
|
|
1642
1717
|
apiName: e,
|
|
1643
1718
|
kind: "connection-setup"
|
|
1644
1719
|
});
|
|
1645
|
-
return
|
|
1646
|
-
},
|
|
1647
|
-
let n =
|
|
1720
|
+
return ir.set(n, t), n;
|
|
1721
|
+
}, or = (e, t) => {
|
|
1722
|
+
let n = ir.get(e);
|
|
1648
1723
|
if (n === void 0 || e.apiName !== t) throw Error(`Voltro: connection setup must belong to api "${t}"`);
|
|
1649
1724
|
return n;
|
|
1650
|
-
},
|
|
1651
|
-
|
|
1652
|
-
},
|
|
1725
|
+
}, sr = /* @__PURE__ */ new WeakMap(), cr = (e, t) => {
|
|
1726
|
+
sr.set(e, t);
|
|
1727
|
+
}, lr = (e) => sr.get(e)?.capture(), ur = 0, dr = () => {
|
|
1653
1728
|
let e = typeof crypto < "u" ? crypto : void 0;
|
|
1654
|
-
return e && typeof e.randomUUID == "function" ? e.randomUUID() : `idem_${Date.now().toString(36)}_${
|
|
1655
|
-
},
|
|
1729
|
+
return e && typeof e.randomUUID == "function" ? e.randomUUID() : `idem_${Date.now().toString(36)}_${ur += 1}`;
|
|
1730
|
+
}, fr = (e, t) => e.pipe(N.locallyWith(le.currentHeaders, (e) => ce.set(e, "idempotency-key", t))), pr = (e, t) => {
|
|
1656
1731
|
if (t === void 0 || typeof e != "object" || !e) return e;
|
|
1657
1732
|
try {
|
|
1658
1733
|
Object.defineProperty(e, "__voltroTraceId", {
|
|
@@ -1662,15 +1737,15 @@ var Nn = 15e3, Y = async (e, t, n) => {
|
|
|
1662
1737
|
});
|
|
1663
1738
|
} catch {}
|
|
1664
1739
|
return e;
|
|
1665
|
-
},
|
|
1666
|
-
|
|
1667
|
-
},
|
|
1740
|
+
}, mr, hr = (e) => {
|
|
1741
|
+
mr = e;
|
|
1742
|
+
}, gr = () => mr, _r = (e, t, n) => typeof e == "function" ? e(t, n) : e, vr = 0, yr = () => `mut_${++vr}`, br = (e, t) => ({
|
|
1668
1743
|
update: (n, r) => {
|
|
1669
1744
|
e.update(n, r, t);
|
|
1670
1745
|
},
|
|
1671
1746
|
forTag: (n, r) => e.forTag(n, r, t)
|
|
1672
|
-
}),
|
|
1673
|
-
let n =
|
|
1747
|
+
}), xr = (e, t) => {
|
|
1748
|
+
let n = G(e), { descriptors: r } = n, i = k(n);
|
|
1674
1749
|
i.current = n;
|
|
1675
1750
|
let a = r[t], o = a?.targets;
|
|
1676
1751
|
if (process.env.NODE_ENV !== "production") {
|
|
@@ -1680,13 +1755,13 @@ var Nn = 15e3, Y = async (e, t, n) => {
|
|
|
1680
1755
|
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
1756
|
let a = r?.onError !== void 0 || r?.notify?.error !== void 0, s = (e) => {
|
|
1682
1757
|
r?.onError?.(e, n);
|
|
1683
|
-
let t =
|
|
1684
|
-
t !== void 0 &&
|
|
1758
|
+
let t = _r(r?.notify?.error, e, n);
|
|
1759
|
+
t !== void 0 && mr?.error(t);
|
|
1685
1760
|
};
|
|
1686
1761
|
c(!0), u(void 0);
|
|
1687
1762
|
let l, d, g, _;
|
|
1688
1763
|
try {
|
|
1689
|
-
_ =
|
|
1764
|
+
_ = lr(h), {runtime: l, cache: d, client: g} = await J(i, e, t);
|
|
1690
1765
|
} catch (e) {
|
|
1691
1766
|
if (c(!1), u(e), i.current.errorBus.emit({
|
|
1692
1767
|
source: "mutation",
|
|
@@ -1697,8 +1772,8 @@ var Nn = 15e3, Y = async (e, t, n) => {
|
|
|
1697
1772
|
}), a) return s(e);
|
|
1698
1773
|
throw e;
|
|
1699
1774
|
}
|
|
1700
|
-
let v =
|
|
1701
|
-
|
|
1775
|
+
let v = yr(), y = r?.idempotencyKey ?? dr();
|
|
1776
|
+
er({
|
|
1702
1777
|
id: v,
|
|
1703
1778
|
apiName: e,
|
|
1704
1779
|
tag: t,
|
|
@@ -1706,9 +1781,9 @@ var Nn = 15e3, Y = async (e, t, n) => {
|
|
|
1706
1781
|
});
|
|
1707
1782
|
let b = p.current, x = m.current;
|
|
1708
1783
|
if (b) try {
|
|
1709
|
-
b(
|
|
1784
|
+
b(br(d, v), n);
|
|
1710
1785
|
} catch (e) {
|
|
1711
|
-
if (u(e), c(!1), d.revertByMutation(v),
|
|
1786
|
+
if (u(e), c(!1), d.revertByMutation(v), Z(v, {
|
|
1712
1787
|
status: "error",
|
|
1713
1788
|
error: e
|
|
1714
1789
|
}), a) return s(e);
|
|
@@ -1718,12 +1793,12 @@ var Nn = 15e3, Y = async (e, t, n) => {
|
|
|
1718
1793
|
let S, C = !1, w, T, E = Date.now();
|
|
1719
1794
|
try {
|
|
1720
1795
|
let a = async (r, a, o, s) => {
|
|
1721
|
-
let c =
|
|
1796
|
+
let c = Jt(r), l = c?.getSnapshot();
|
|
1722
1797
|
T = c === void 0 ? void 0 : () => i.current.runtime === r && l !== void 0 && c.getSnapshot() === l, s?.();
|
|
1723
1798
|
let u = _ === void 0 ? void 0 : await _.prepare(r, a);
|
|
1724
1799
|
l = c?.getSnapshot(), s?.();
|
|
1725
|
-
let d =
|
|
1726
|
-
S = e.traceId,
|
|
1800
|
+
let d = fr(K(a, t)(n), y), f = N.currentSpan.pipe(N.tap((e) => N.sync(() => {
|
|
1801
|
+
S = e.traceId, Ce({
|
|
1727
1802
|
traceId: e.traceId,
|
|
1728
1803
|
spanId: e.spanId,
|
|
1729
1804
|
source: "mutation",
|
|
@@ -1740,12 +1815,12 @@ var Nn = 15e3, Y = async (e, t, n) => {
|
|
|
1740
1815
|
"rpc.tag": t,
|
|
1741
1816
|
"voltro.replay": o
|
|
1742
1817
|
} }));
|
|
1743
|
-
return u === void 0 ?
|
|
1818
|
+
return u === void 0 ? Y(r, f) : u.run(f);
|
|
1744
1819
|
}, o;
|
|
1745
1820
|
try {
|
|
1746
1821
|
o = await a(l, g, !1);
|
|
1747
1822
|
} catch (n) {
|
|
1748
|
-
let r = B(n, C ? "handler" : "client"), s =
|
|
1823
|
+
let r = B(n, C ? "handler" : "client"), s = pr(n, S);
|
|
1749
1824
|
r === "transport" && (i.current.errorBus.emit({
|
|
1750
1825
|
source: "mutation",
|
|
1751
1826
|
tag: t,
|
|
@@ -1755,7 +1830,7 @@ var Nn = 15e3, Y = async (e, t, n) => {
|
|
|
1755
1830
|
outcome: C ? "unknown" : "not-started",
|
|
1756
1831
|
...S === void 0 ? {} : { traceId: S }
|
|
1757
1832
|
}), w = s);
|
|
1758
|
-
let c = i.current, l = c.recovery ??
|
|
1833
|
+
let c = i.current, l = c.recovery ?? xt(c.errorBus, e), u = r === "transport" ? l.reserveMutationReplay(E) : void 0;
|
|
1759
1834
|
if (u === void 0) throw s;
|
|
1760
1835
|
try {
|
|
1761
1836
|
if (!await l.waitForMutationReplaySupport(E) || !await l.waitForProtocolReady(E) || !u.isValid()) throw s;
|
|
@@ -1764,7 +1839,7 @@ var Nn = 15e3, Y = async (e, t, n) => {
|
|
|
1764
1839
|
};
|
|
1765
1840
|
for (;;) {
|
|
1766
1841
|
n();
|
|
1767
|
-
let r = await
|
|
1842
|
+
let r = await J(i, e, t);
|
|
1768
1843
|
try {
|
|
1769
1844
|
o = await a(r.runtime, r.client, !0, n);
|
|
1770
1845
|
break;
|
|
@@ -1780,18 +1855,18 @@ var Nn = 15e3, Y = async (e, t, n) => {
|
|
|
1780
1855
|
u.release();
|
|
1781
1856
|
}
|
|
1782
1857
|
}
|
|
1783
|
-
f(o),
|
|
1858
|
+
f(o), Z(v, {
|
|
1784
1859
|
status: "success",
|
|
1785
1860
|
output: o
|
|
1786
1861
|
}), i.current.errorBus.emitSuccess({
|
|
1787
1862
|
source: "mutation",
|
|
1788
1863
|
tag: t
|
|
1789
1864
|
}), d.confirmByMutation(v), r?.onSuccess?.(o, n);
|
|
1790
|
-
let s =
|
|
1791
|
-
return s !== void 0 &&
|
|
1865
|
+
let s = _r(r?.notify?.success, o, n);
|
|
1866
|
+
return s !== void 0 && mr?.success(s), o;
|
|
1792
1867
|
} catch (e) {
|
|
1793
|
-
let n =
|
|
1794
|
-
if (u(n),
|
|
1868
|
+
let n = pr(e, S);
|
|
1869
|
+
if (u(n), Z(v, {
|
|
1795
1870
|
status: "error",
|
|
1796
1871
|
error: n
|
|
1797
1872
|
}), d.revertByMutation(v), Object.is(w, n) || i.current.errorBus.emit({
|
|
@@ -1820,7 +1895,7 @@ var Nn = 15e3, Y = async (e, t, n) => {
|
|
|
1820
1895
|
data: d,
|
|
1821
1896
|
withOptimistic: (e) => (p.current = e, t),
|
|
1822
1897
|
withoutOptimistic: () => (m.current = !0, t),
|
|
1823
|
-
withConnectionSetup: (n) => (
|
|
1898
|
+
withConnectionSetup: (n) => (cr(h, or(n, e)), t)
|
|
1824
1899
|
};
|
|
1825
1900
|
return t;
|
|
1826
1901
|
}, [
|
|
@@ -1830,7 +1905,7 @@ var Nn = 15e3, Y = async (e, t, n) => {
|
|
|
1830
1905
|
d,
|
|
1831
1906
|
e
|
|
1832
1907
|
]);
|
|
1833
|
-
},
|
|
1908
|
+
}, Sr = (e, t) => {
|
|
1834
1909
|
if (t === void 0 || typeof e != "object" || !e) return e;
|
|
1835
1910
|
try {
|
|
1836
1911
|
Object.defineProperty(e, "__voltroTraceId", {
|
|
@@ -1840,8 +1915,8 @@ var Nn = 15e3, Y = async (e, t, n) => {
|
|
|
1840
1915
|
});
|
|
1841
1916
|
} catch {}
|
|
1842
1917
|
return e;
|
|
1843
|
-
},
|
|
1844
|
-
let n =
|
|
1918
|
+
}, Cr = (e, t, n) => typeof e == "function" ? e(t, n) : e, wr = 0, Tr = () => `act_${++wr}`, Er = (e, t) => {
|
|
1919
|
+
let n = G(e), { descriptors: r } = n, i = k(n);
|
|
1845
1920
|
if (i.current = n, process.env.NODE_ENV !== "production") {
|
|
1846
1921
|
let n = r[t]?.kind;
|
|
1847
1922
|
n !== void 0 && n !== "action" && console.error(`[@voltro/client] useAction('${e}', '${t}') targets a ${n}, not an action. Use ${n === "mutation" ? "useMutation" : n === "workflow" ? "useWorkflow" : `the ${n} hook`} instead.`);
|
|
@@ -1849,8 +1924,8 @@ var Nn = 15e3, Y = async (e, t, n) => {
|
|
|
1849
1924
|
let [a, o] = A(!1), [s, c] = A(void 0), [l, u] = A(void 0), d = E(async (n, r) => {
|
|
1850
1925
|
let a = r?.onError !== void 0 || r?.notify?.error !== void 0;
|
|
1851
1926
|
o(!0), c(void 0);
|
|
1852
|
-
let s =
|
|
1853
|
-
|
|
1927
|
+
let s = Tr(), l = r?.idempotencyKey ?? dr();
|
|
1928
|
+
er({
|
|
1854
1929
|
id: s,
|
|
1855
1930
|
apiName: e,
|
|
1856
1931
|
tag: t,
|
|
@@ -1858,32 +1933,32 @@ var Nn = 15e3, Y = async (e, t, n) => {
|
|
|
1858
1933
|
});
|
|
1859
1934
|
let d, f = !1;
|
|
1860
1935
|
try {
|
|
1861
|
-
let { runtime: a, client: o } = await
|
|
1862
|
-
d = e.traceId,
|
|
1936
|
+
let { runtime: a, client: o } = await J(i, e, t), c = K(o, t), p = N.currentSpan.pipe(N.tap((e) => N.sync(() => {
|
|
1937
|
+
d = e.traceId, Ce({
|
|
1863
1938
|
traceId: e.traceId,
|
|
1864
1939
|
spanId: e.spanId,
|
|
1865
1940
|
source: "action",
|
|
1866
1941
|
tag: t
|
|
1867
1942
|
});
|
|
1868
|
-
})), N.catchAll(() => N.void), N.zipRight(
|
|
1943
|
+
})), N.catchAll(() => N.void), N.zipRight(fr(c(n), l))).pipe(N.withSpan(`client.action.${t}`, { attributes: {
|
|
1869
1944
|
"voltro.api": e,
|
|
1870
1945
|
"voltro.actionId": s,
|
|
1871
1946
|
"rpc.tag": t
|
|
1872
1947
|
} }));
|
|
1873
1948
|
f = !0;
|
|
1874
|
-
let m = await
|
|
1875
|
-
u(m),
|
|
1949
|
+
let m = await Y(a, p);
|
|
1950
|
+
u(m), Z(s, {
|
|
1876
1951
|
status: "success",
|
|
1877
1952
|
output: m
|
|
1878
1953
|
}), i.current.errorBus.emitSuccess({
|
|
1879
1954
|
source: "action",
|
|
1880
1955
|
tag: t
|
|
1881
1956
|
}), r?.onSuccess?.(m, n);
|
|
1882
|
-
let h =
|
|
1883
|
-
return h !== void 0 &&
|
|
1957
|
+
let h = Cr(r?.notify?.success, m, n);
|
|
1958
|
+
return h !== void 0 && gr()?.success(h), m;
|
|
1884
1959
|
} catch (e) {
|
|
1885
|
-
let o =
|
|
1886
|
-
if (c(o),
|
|
1960
|
+
let o = Sr(e, d);
|
|
1961
|
+
if (c(o), Z(s, {
|
|
1887
1962
|
status: "error",
|
|
1888
1963
|
error: o
|
|
1889
1964
|
}), i.current.errorBus.emit({
|
|
@@ -1895,8 +1970,8 @@ var Nn = 15e3, Y = async (e, t, n) => {
|
|
|
1895
1970
|
...d === void 0 ? {} : { traceId: d }
|
|
1896
1971
|
}), a) {
|
|
1897
1972
|
r?.onError?.(o, n);
|
|
1898
|
-
let e =
|
|
1899
|
-
e !== void 0 &&
|
|
1973
|
+
let e = Cr(r?.notify?.error, o, n);
|
|
1974
|
+
e !== void 0 && gr()?.error(e);
|
|
1900
1975
|
return;
|
|
1901
1976
|
}
|
|
1902
1977
|
throw o;
|
|
@@ -1915,14 +1990,14 @@ var Nn = 15e3, Y = async (e, t, n) => {
|
|
|
1915
1990
|
s,
|
|
1916
1991
|
l
|
|
1917
1992
|
]);
|
|
1918
|
-
},
|
|
1993
|
+
}, Dr = w(void 0), Or = (e) => T(Dr.Provider, { value: e.messages }, e.children), kr = () => ee(Dr), Ar = Symbol.for("voltro.client.formEngine"), jr = w(void 0), Mr = (e, t) => {
|
|
1919
1994
|
let n = e;
|
|
1920
1995
|
for (let e of t.split(".")) {
|
|
1921
1996
|
if (typeof n != "object" || !n) return;
|
|
1922
1997
|
n = n[e];
|
|
1923
1998
|
}
|
|
1924
1999
|
return n;
|
|
1925
|
-
},
|
|
2000
|
+
}, Nr = (e, t, n) => `vf-${e}-${t}-${n}`.replace(/[^a-zA-Z0-9_-]/g, "-"), Pr = {
|
|
1926
2001
|
isTouched: !1,
|
|
1927
2002
|
isBlurred: !1,
|
|
1928
2003
|
isDirty: !1,
|
|
@@ -1931,15 +2006,15 @@ var Nn = 15e3, Y = async (e, t, n) => {
|
|
|
1931
2006
|
isValidating: !1,
|
|
1932
2007
|
errorMap: {},
|
|
1933
2008
|
errorSourceMap: {}
|
|
1934
|
-
},
|
|
2009
|
+
}, Fr = (e, t) => {
|
|
1935
2010
|
let n = e.find((e) => e.name === t);
|
|
1936
2011
|
if (n !== void 0) return n;
|
|
1937
2012
|
let r = /^(.+?)\.\d+\.(.+)$/.exec(t);
|
|
1938
2013
|
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 =
|
|
2014
|
+
}, Ir = (e, t, n) => {
|
|
2015
|
+
let r = G(e), a = k(void 0), o = typeof t == "function" ? t(a.current?.state?.values ?? n.defaults ?? {}) : t, s = k(o).current, c = xr(e, o), l = n.schema ?? r.descriptors[o]?.input;
|
|
1941
2016
|
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 =
|
|
2017
|
+
let u = O(() => l ? x(l) : [], [l]), d = kr(), f = n.messages ?? d, p = O(() => ({
|
|
1943
2018
|
...n.locale === void 0 ? {} : { locale: n.locale },
|
|
1944
2019
|
...f === void 0 ? {} : { messages: f }
|
|
1945
2020
|
}), [n.locale, f]), m = k(n.asyncFields);
|
|
@@ -1966,7 +2041,7 @@ var Nn = 15e3, Y = async (e, t, n) => {
|
|
|
1966
2041
|
let o = n.errorPath ?? {};
|
|
1967
2042
|
return a.map((t) => {
|
|
1968
2043
|
let n = o[t.path];
|
|
1969
|
-
return n === void 0 ? (
|
|
2044
|
+
return n === void 0 ? (Mr(e, t.path) !== void 0 || t.path.includes("."), t) : {
|
|
1970
2045
|
...t,
|
|
1971
2046
|
path: n
|
|
1972
2047
|
};
|
|
@@ -1981,7 +2056,7 @@ var Nn = 15e3, Y = async (e, t, n) => {
|
|
|
1981
2056
|
...ne(n.defaults),
|
|
1982
2057
|
...e.values
|
|
1983
2058
|
};
|
|
1984
|
-
a.current = new
|
|
2059
|
+
a.current = new ye({
|
|
1985
2060
|
onSubmit: ({ value: e }) => re.current(e),
|
|
1986
2061
|
defaultValues: t,
|
|
1987
2062
|
validators: { onChange: ({ value: e }) => {
|
|
@@ -1996,19 +2071,19 @@ var Nn = 15e3, Y = async (e, t, n) => {
|
|
|
1996
2071
|
let N = a.current, P = N;
|
|
1997
2072
|
D(() => P.mount(), [P]);
|
|
1998
2073
|
let ie = n.subscribe ?? "all";
|
|
1999
|
-
|
|
2000
|
-
let F = N.store.state.values, I = N.store.state, ae = O(() => M(F), [M, F]), L = n.isLoading === !0, oe = n.validate,
|
|
2074
|
+
be(N.store, (e) => ie === "all" ? e : `${e.submissionAttempts}|${String(e.isSubmitting)}|${String(e.isDirty)}|${String(e.isTouched)}`);
|
|
2075
|
+
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, le = I.fieldMetaBase ?? {}, ue = E((e) => {
|
|
2001
2076
|
if (L) return !1;
|
|
2002
|
-
if (ce > 0 ||
|
|
2003
|
-
if (
|
|
2077
|
+
if (ce > 0 || se === "always") return !0;
|
|
2078
|
+
if (se === "never") return !1;
|
|
2004
2079
|
let t = le[e];
|
|
2005
|
-
return t === void 0 ? !1 :
|
|
2080
|
+
return t === void 0 ? !1 : R ? t.isBlurred === !0 : t.isTouched === !0;
|
|
2006
2081
|
}, [
|
|
2007
2082
|
ce,
|
|
2008
2083
|
le,
|
|
2009
2084
|
L,
|
|
2010
|
-
|
|
2011
|
-
|
|
2085
|
+
se,
|
|
2086
|
+
R
|
|
2012
2087
|
]), de = E((e) => {
|
|
2013
2088
|
let t = y[e];
|
|
2014
2089
|
if (t !== void 0) return t;
|
|
@@ -2024,7 +2099,7 @@ var Nn = 15e3, Y = async (e, t, n) => {
|
|
|
2024
2099
|
y,
|
|
2025
2100
|
ue,
|
|
2026
2101
|
ae
|
|
2027
|
-
]),
|
|
2102
|
+
]), fe = O(() => {
|
|
2028
2103
|
let e = {}, t = /* @__PURE__ */ new Set([...ae.map((e) => e.path).filter((e) => e !== ""), ...Object.keys(y)]);
|
|
2029
2104
|
for (let [e, n] of Object.entries(m.current ?? {})) n.status === "invalid" && t.add(e);
|
|
2030
2105
|
for (let n of t) {
|
|
@@ -2036,22 +2111,22 @@ var Nn = 15e3, Y = async (e, t, n) => {
|
|
|
2036
2111
|
ae,
|
|
2037
2112
|
y,
|
|
2038
2113
|
de
|
|
2039
|
-
]),
|
|
2114
|
+
]), pe = E((e) => {
|
|
2040
2115
|
S((t) => {
|
|
2041
2116
|
if (!(e in t)) return t;
|
|
2042
2117
|
let n = { ...t };
|
|
2043
2118
|
return delete n[e], n;
|
|
2044
2119
|
});
|
|
2045
|
-
}, []),
|
|
2046
|
-
let n =
|
|
2120
|
+
}, []), he = E((t) => {
|
|
2121
|
+
let n = Fr(u, t), r = P.getFieldMeta(t), i = de(t), a = Nr(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
2122
|
return {
|
|
2048
2123
|
value: P.getFieldValue(t),
|
|
2049
2124
|
setValue: (e) => {
|
|
2050
|
-
|
|
2125
|
+
pe(t), !Object.is(P.getFieldValue(t), e) && P.setFieldValue(t, e);
|
|
2051
2126
|
},
|
|
2052
2127
|
onBlur: () => {
|
|
2053
2128
|
P.setFieldMeta(t, (e) => ({
|
|
2054
|
-
...
|
|
2129
|
+
...Pr,
|
|
2055
2130
|
...e ?? {},
|
|
2056
2131
|
isTouched: !0,
|
|
2057
2132
|
isBlurred: !0
|
|
@@ -2078,12 +2153,12 @@ var Nn = 15e3, Y = async (e, t, n) => {
|
|
|
2078
2153
|
}, [
|
|
2079
2154
|
e,
|
|
2080
2155
|
s,
|
|
2081
|
-
|
|
2156
|
+
pe,
|
|
2082
2157
|
P,
|
|
2083
2158
|
u,
|
|
2084
2159
|
y,
|
|
2085
2160
|
de
|
|
2086
|
-
]),
|
|
2161
|
+
]), ge = E((e) => ({
|
|
2087
2162
|
items: P.getFieldValue(e) ?? [],
|
|
2088
2163
|
push: (t) => {
|
|
2089
2164
|
P.pushFieldValue(e, t);
|
|
@@ -2100,14 +2175,14 @@ var Nn = 15e3, Y = async (e, t, n) => {
|
|
|
2100
2175
|
swap: (t, n) => {
|
|
2101
2176
|
P.swapFieldValues(e, t, n);
|
|
2102
2177
|
},
|
|
2103
|
-
field: (t, n) =>
|
|
2104
|
-
}), [P,
|
|
2105
|
-
|
|
2106
|
-
}, [
|
|
2178
|
+
field: (t, n) => he(`${e}.${t}.${n}`)
|
|
2179
|
+
}), [P, he]), _e = E((e) => u.filter((t) => t.section === e), [u]), ve = E((e, t) => {
|
|
2180
|
+
pe(e), !Object.is(P.getFieldValue(e), t) && P.setFieldValue(e, t);
|
|
2181
|
+
}, [pe, P]), xe = E((e) => {
|
|
2107
2182
|
for (let [t, n] of Object.entries(e)) P.setFieldValue(t, n);
|
|
2108
|
-
}, [P]),
|
|
2183
|
+
}, [P]), Se = E((e) => {
|
|
2109
2184
|
S({}), T(void 0), te(void 0), j.current = void 0, e === void 0 ? P.reset() : P.reset(ne(e));
|
|
2110
|
-
}, [P, ne]),
|
|
2185
|
+
}, [P, ne]), Ce = n.asyncTimeoutMs ?? 5e3, we = E(async () => {
|
|
2111
2186
|
let e = Date.now();
|
|
2112
2187
|
for (;;) {
|
|
2113
2188
|
let t = m.current;
|
|
@@ -2120,18 +2195,18 @@ var Nn = 15e3, Y = async (e, t, n) => {
|
|
|
2120
2195
|
fallback: "Invalid value"
|
|
2121
2196
|
}, _.current)]));
|
|
2122
2197
|
}
|
|
2123
|
-
if (Date.now() - e >
|
|
2198
|
+
if (Date.now() - e > Ce) return Object.fromEntries(r.map(([e]) => [e, b({
|
|
2124
2199
|
id: "validation.checking",
|
|
2125
2200
|
fallback: "Still checking…"
|
|
2126
2201
|
}, _.current)]));
|
|
2127
2202
|
await new Promise((e) => setTimeout(e, 50));
|
|
2128
2203
|
}
|
|
2129
|
-
}, [
|
|
2204
|
+
}, [Ce]), Te = E(() => {
|
|
2130
2205
|
let t = globalThis.document;
|
|
2131
2206
|
if (t?.getElementById === void 0) return;
|
|
2132
2207
|
let n = [...u.map((e) => e.name), ...Object.keys(y).filter((e) => !u.some((t) => t.name === e))];
|
|
2133
2208
|
for (let r of n) if (de(r) !== void 0) {
|
|
2134
|
-
t.getElementById(
|
|
2209
|
+
t.getElementById(Nr(e, s, r))?.focus?.();
|
|
2135
2210
|
return;
|
|
2136
2211
|
}
|
|
2137
2212
|
}, [
|
|
@@ -2140,16 +2215,16 @@ var Nn = 15e3, Y = async (e, t, n) => {
|
|
|
2140
2215
|
u,
|
|
2141
2216
|
y,
|
|
2142
2217
|
de
|
|
2143
|
-
]),
|
|
2144
|
-
|
|
2145
|
-
let
|
|
2218
|
+
]), z = k(Te);
|
|
2219
|
+
z.current = Te;
|
|
2220
|
+
let B = E(async () => {
|
|
2146
2221
|
T(void 0), S({}), te(void 0), j.current = void 0;
|
|
2147
2222
|
let e, t = !1;
|
|
2148
2223
|
if (await P.handleSubmit().catch((n) => {
|
|
2149
2224
|
t = !0, e = n;
|
|
2150
2225
|
}), t) throw e;
|
|
2151
2226
|
return j.current === void 0 && queueMicrotask(() => {
|
|
2152
|
-
|
|
2227
|
+
z.current();
|
|
2153
2228
|
}), j.current;
|
|
2154
2229
|
}, [P]);
|
|
2155
2230
|
re.current = (async (e) => {
|
|
@@ -2162,7 +2237,7 @@ var Nn = 15e3, Y = async (e, t, n) => {
|
|
|
2162
2237
|
}
|
|
2163
2238
|
if (M(n).length > 0) {
|
|
2164
2239
|
queueMicrotask(() => {
|
|
2165
|
-
|
|
2240
|
+
z.current();
|
|
2166
2241
|
});
|
|
2167
2242
|
return;
|
|
2168
2243
|
}
|
|
@@ -2171,13 +2246,13 @@ var Nn = 15e3, Y = async (e, t, n) => {
|
|
|
2171
2246
|
let e = C(i, r);
|
|
2172
2247
|
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
2248
|
}
|
|
2174
|
-
let a = await
|
|
2249
|
+
let a = await we();
|
|
2175
2250
|
if (a !== void 0) {
|
|
2176
2251
|
S((e) => ({
|
|
2177
2252
|
...e,
|
|
2178
2253
|
...a
|
|
2179
2254
|
})), queueMicrotask(() => {
|
|
2180
|
-
|
|
2255
|
+
z.current();
|
|
2181
2256
|
});
|
|
2182
2257
|
return;
|
|
2183
2258
|
}
|
|
@@ -2190,7 +2265,7 @@ var Nn = 15e3, Y = async (e, t, n) => {
|
|
|
2190
2265
|
});
|
|
2191
2266
|
j.current = e, t.onSuccess?.(e);
|
|
2192
2267
|
} catch (e) {
|
|
2193
|
-
let t =
|
|
2268
|
+
let t = me(e);
|
|
2194
2269
|
if (t.length === 0) {
|
|
2195
2270
|
te(e), h.current.onError?.(e);
|
|
2196
2271
|
return;
|
|
@@ -2205,67 +2280,67 @@ var Nn = 15e3, Y = async (e, t, n) => {
|
|
|
2205
2280
|
...e,
|
|
2206
2281
|
...n
|
|
2207
2282
|
})), queueMicrotask(() => {
|
|
2208
|
-
|
|
2283
|
+
z.current();
|
|
2209
2284
|
});
|
|
2210
2285
|
}
|
|
2211
2286
|
});
|
|
2212
|
-
let
|
|
2213
|
-
for (let e of u) if (
|
|
2214
|
-
let e = Object.keys(
|
|
2287
|
+
let Ee = ae.length === 0, De = Object.values(m.current ?? {}).some((e) => e.status === "checking"), Oe = ee ?? c.error, ke = Oe !== void 0 && me(Oe).length > 0 ? void 0 : Oe, Ae = Object.keys(fe).length, je = (() => {
|
|
2288
|
+
for (let e of u) if (fe[e.name] !== void 0) return e.name;
|
|
2289
|
+
let e = Object.keys(fe);
|
|
2215
2290
|
return e.length > 0 ? e[0] : void 0;
|
|
2216
|
-
})(),
|
|
2291
|
+
})(), V = {
|
|
2217
2292
|
isDirty: !L && I.isDirty,
|
|
2218
2293
|
isPristine: I.isPristine,
|
|
2219
2294
|
isTouched: I.isTouched,
|
|
2220
|
-
isValid:
|
|
2221
|
-
isValidating:
|
|
2222
|
-
canSubmit:
|
|
2295
|
+
isValid: Ee,
|
|
2296
|
+
isValidating: De,
|
|
2297
|
+
canSubmit: Ee && !De && !I.isSubmitting && !L,
|
|
2223
2298
|
isSubmitting: I.isSubmitting,
|
|
2224
2299
|
isSubmitted: I.isSubmitted,
|
|
2225
2300
|
isSubmitSuccessful: I.isSubmitSuccessful && j.current !== void 0,
|
|
2226
2301
|
submissionAttempts: I.submissionAttempts,
|
|
2227
|
-
errorCount:
|
|
2228
|
-
firstInvalidPath:
|
|
2302
|
+
errorCount: Ae,
|
|
2303
|
+
firstInvalidPath: je,
|
|
2229
2304
|
pending: c.pending,
|
|
2230
2305
|
isLoading: L,
|
|
2231
|
-
submitError:
|
|
2306
|
+
submitError: ke,
|
|
2232
2307
|
data: c.data
|
|
2233
|
-
},
|
|
2308
|
+
}, Me = {
|
|
2234
2309
|
fields: u,
|
|
2235
2310
|
values: F,
|
|
2236
|
-
errors:
|
|
2311
|
+
errors: fe,
|
|
2237
2312
|
issues: ae,
|
|
2238
|
-
isValid:
|
|
2313
|
+
isValid: Ee,
|
|
2239
2314
|
pending: c.pending,
|
|
2240
|
-
submitError:
|
|
2315
|
+
submitError: ke,
|
|
2241
2316
|
formError: w,
|
|
2242
2317
|
data: c.data,
|
|
2243
|
-
setValue:
|
|
2244
|
-
setValues:
|
|
2245
|
-
reset:
|
|
2246
|
-
submit:
|
|
2247
|
-
field:
|
|
2248
|
-
array:
|
|
2249
|
-
section:
|
|
2250
|
-
state:
|
|
2251
|
-
focusFirstInvalid:
|
|
2318
|
+
setValue: ve,
|
|
2319
|
+
setValues: xe,
|
|
2320
|
+
reset: Se,
|
|
2321
|
+
submit: B,
|
|
2322
|
+
field: he,
|
|
2323
|
+
array: ge,
|
|
2324
|
+
section: _e,
|
|
2325
|
+
state: V,
|
|
2326
|
+
focusFirstInvalid: Te
|
|
2252
2327
|
};
|
|
2253
|
-
return Object.defineProperty(
|
|
2328
|
+
return Object.defineProperty(Me, Ar, {
|
|
2254
2329
|
value: {
|
|
2255
2330
|
store: N.store,
|
|
2256
|
-
field:
|
|
2331
|
+
field: he
|
|
2257
2332
|
},
|
|
2258
2333
|
enumerable: !1
|
|
2259
|
-
}),
|
|
2260
|
-
},
|
|
2261
|
-
function
|
|
2262
|
-
let n = ee(
|
|
2334
|
+
}), Me;
|
|
2335
|
+
}, Lr = (e) => T(jr.Provider, { value: e.binding }, e.children), Rr = () => ee(jr);
|
|
2336
|
+
function zr(e, t) {
|
|
2337
|
+
let n = ee(jr), r = typeof e == "string" ? void 0 : e, i = typeof e == "string" ? e : t, a = r ?? n;
|
|
2263
2338
|
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[
|
|
2339
|
+
let o = a[Ar];
|
|
2265
2340
|
if (o === void 0) throw Error("useFormField: not a useFormBinding result");
|
|
2266
|
-
return
|
|
2341
|
+
return be(o.store, (e) => {
|
|
2267
2342
|
let t = e.fieldMetaBase[i];
|
|
2268
|
-
return `${JSON.stringify(
|
|
2343
|
+
return `${JSON.stringify(Mr(e.values, i))}|${t === void 0 ? "" : `${String(t.isTouched)}${String(t.isBlurred)}${JSON.stringify(t.errorMap)}`}|${e.submissionAttempts}`;
|
|
2269
2344
|
}), o.field(i);
|
|
2270
2345
|
}
|
|
2271
2346
|
//#endregion
|
|
@@ -2274,9 +2349,9 @@ var Q = class extends Error {
|
|
|
2274
2349
|
reason;
|
|
2275
2350
|
_tag = "ConnectionPrerequisiteInvalidated";
|
|
2276
2351
|
constructor(e) {
|
|
2277
|
-
super(`Voltro connection prerequisite: ${e}`), this.reason = e,
|
|
2352
|
+
super(`Voltro connection prerequisite: ${e}`), this.reason = e, z(this, e === "connection-unavailable" || e === "connection-changed" ? "transport" : "client");
|
|
2278
2353
|
}
|
|
2279
|
-
},
|
|
2354
|
+
}, Br = class {
|
|
2280
2355
|
#e;
|
|
2281
2356
|
#t;
|
|
2282
2357
|
#n = /* @__PURE__ */ new WeakMap();
|
|
@@ -2286,12 +2361,12 @@ var Q = class extends Error {
|
|
|
2286
2361
|
this.#e = e, this.#t = t;
|
|
2287
2362
|
}
|
|
2288
2363
|
prepare(e, t) {
|
|
2289
|
-
let n =
|
|
2364
|
+
let n = Jt(e)?.getSnapshot();
|
|
2290
2365
|
if (this.#e.aborted) return Promise.reject(new Q("inactive"));
|
|
2291
2366
|
if (n === void 0) return Promise.reject(new Q("connection-unavailable"));
|
|
2292
2367
|
let r = this.#n.get(n);
|
|
2293
2368
|
if (r !== void 0) return r.then((t) => (this.assertCurrent(e, t), t));
|
|
2294
|
-
let i =
|
|
2369
|
+
let i = Y(e, this.#a(e, n, t).pipe(N.timeoutFail({
|
|
2295
2370
|
duration: this.#t,
|
|
2296
2371
|
onTimeout: () => new Q("timeout")
|
|
2297
2372
|
}))).then((t) => {
|
|
@@ -2311,14 +2386,14 @@ var Q = class extends Error {
|
|
|
2311
2386
|
}
|
|
2312
2387
|
#i(e, t) {
|
|
2313
2388
|
if (this.#e.aborted) throw new Q("inactive");
|
|
2314
|
-
if (t.signal.aborted ||
|
|
2389
|
+
if (t.signal.aborted || Jt(e)?.getSnapshot() !== t) throw new Q("connection-changed");
|
|
2315
2390
|
}
|
|
2316
2391
|
run(e, t, n) {
|
|
2317
2392
|
let r = N.try({
|
|
2318
2393
|
try: () => this.assertCurrent(e, t),
|
|
2319
2394
|
catch: (e) => e
|
|
2320
2395
|
}).pipe(N.zipRight(n));
|
|
2321
|
-
return
|
|
2396
|
+
return Y(e, this.#a(e, t.lease, r));
|
|
2322
2397
|
}
|
|
2323
2398
|
#a(e, t, n) {
|
|
2324
2399
|
let r = N.try({
|
|
@@ -2332,7 +2407,7 @@ var Q = class extends Error {
|
|
|
2332
2407
|
});
|
|
2333
2408
|
return r.pipe(N.zipRight(n), N.tap(() => r), N.raceFirst(i));
|
|
2334
2409
|
}
|
|
2335
|
-
},
|
|
2410
|
+
}, Vr = class {
|
|
2336
2411
|
#e;
|
|
2337
2412
|
#t;
|
|
2338
2413
|
#n;
|
|
@@ -2347,7 +2422,7 @@ var Q = class extends Error {
|
|
|
2347
2422
|
#s;
|
|
2348
2423
|
handle;
|
|
2349
2424
|
constructor(e, t, n) {
|
|
2350
|
-
this.#e = e, this.#t = t, this.#n = n, this.handle =
|
|
2425
|
+
this.#e = e, this.#t = t, this.#n = n, this.handle = ar(e, { capture: () => this.#f() });
|
|
2351
2426
|
}
|
|
2352
2427
|
getSnapshot = () => this.#a;
|
|
2353
2428
|
subscribe = (e) => (this.#r.add(e), () => {
|
|
@@ -2365,11 +2440,11 @@ var Q = class extends Error {
|
|
|
2365
2440
|
this.clear();
|
|
2366
2441
|
let n = new AbortController(), r = {
|
|
2367
2442
|
input: e,
|
|
2368
|
-
key:
|
|
2443
|
+
key: dr(),
|
|
2369
2444
|
controller: n,
|
|
2370
2445
|
subject: void 0,
|
|
2371
2446
|
detachSubject: void 0,
|
|
2372
|
-
prerequisite: new
|
|
2447
|
+
prerequisite: new Br(n.signal, this.#c(this.#n()).options.replayWindowMs),
|
|
2373
2448
|
established: !1
|
|
2374
2449
|
};
|
|
2375
2450
|
this.#i = r, this.#h({
|
|
@@ -2389,7 +2464,7 @@ var Q = class extends Error {
|
|
|
2389
2464
|
}
|
|
2390
2465
|
}
|
|
2391
2466
|
watch(e) {
|
|
2392
|
-
let t =
|
|
2467
|
+
let t = Jt(e.runtime), n = () => {
|
|
2393
2468
|
let n = this.#i;
|
|
2394
2469
|
if (n === void 0 || !n.established || this.#n().runtime !== e.runtime) return;
|
|
2395
2470
|
if (n.subject !== this.#c(e).subjectSignal) {
|
|
@@ -2406,7 +2481,7 @@ var Q = class extends Error {
|
|
|
2406
2481
|
return n(), t?.subscribe(n) ?? (() => {});
|
|
2407
2482
|
}
|
|
2408
2483
|
#c(e) {
|
|
2409
|
-
return e.recovery ??
|
|
2484
|
+
return e.recovery ?? xt(e.errorBus, this.#e);
|
|
2410
2485
|
}
|
|
2411
2486
|
#l(e) {
|
|
2412
2487
|
if (this.#i !== e || e.controller.signal.aborted) throw new Q("inactive");
|
|
@@ -2442,9 +2517,9 @@ var Q = class extends Error {
|
|
|
2442
2517
|
let r = this.#u(e, t, n), i = r.descriptors[this.#t];
|
|
2443
2518
|
if (i?.kind !== "mutation" || i.idempotencyScope !== "connection") throw Error(`Voltro: useConnectionSetup("${this.#t}") requires a mutation declaring idempotencyScope: 'connection'`);
|
|
2444
2519
|
this.#d(e, r), this.#l(e);
|
|
2445
|
-
let a =
|
|
2520
|
+
let a = Jt(t);
|
|
2446
2521
|
if (a === void 0) throw new Q("connection-unavailable");
|
|
2447
|
-
a.getSnapshot() === void 0 && await
|
|
2522
|
+
a.getSnapshot() === void 0 && await Y(t, N.async((t) => {
|
|
2448
2523
|
let n = () => {
|
|
2449
2524
|
let n = a.getSnapshot();
|
|
2450
2525
|
e.controller.signal.aborted ? t(N.fail(new Q("inactive"))) : n !== void 0 && t(N.succeed(n));
|
|
@@ -2475,13 +2550,13 @@ var Q = class extends Error {
|
|
|
2475
2550
|
#m(e, t) {
|
|
2476
2551
|
return N.suspend(() => {
|
|
2477
2552
|
let n = `setup_${e.key}_${++this.#o}`;
|
|
2478
|
-
return
|
|
2553
|
+
return er({
|
|
2479
2554
|
id: n,
|
|
2480
2555
|
apiName: this.#e,
|
|
2481
2556
|
tag: this.#t,
|
|
2482
2557
|
input: e.input
|
|
2483
|
-
}), N.suspend(() => (this.#u(e, t.runtime, t.client),
|
|
2484
|
-
if (P.isSuccess(e))
|
|
2558
|
+
}), N.suspend(() => (this.#u(e, t.runtime, t.client), fr(K(t.client, this.#t)(e.input), e.key))).pipe(N.withSpan(`client.connectionSetup.${this.#t}`)).pipe(N.onExit((e) => N.sync(() => {
|
|
2559
|
+
if (P.isSuccess(e)) Z(n, {
|
|
2485
2560
|
status: "success",
|
|
2486
2561
|
output: e.value
|
|
2487
2562
|
}), t.errorBus.emitSuccess({
|
|
@@ -2490,7 +2565,7 @@ var Q = class extends Error {
|
|
|
2490
2565
|
});
|
|
2491
2566
|
else {
|
|
2492
2567
|
let r = M.squash(e.cause);
|
|
2493
|
-
if (
|
|
2568
|
+
if (Z(n, {
|
|
2494
2569
|
status: "error",
|
|
2495
2570
|
error: r
|
|
2496
2571
|
}), !M.isInterruptedOnly(e.cause)) {
|
|
@@ -2515,10 +2590,10 @@ var Q = class extends Error {
|
|
|
2515
2590
|
} catch {}
|
|
2516
2591
|
}
|
|
2517
2592
|
}
|
|
2518
|
-
},
|
|
2519
|
-
let n =
|
|
2593
|
+
}, Hr = (e, t) => {
|
|
2594
|
+
let n = G(e), r = k(n);
|
|
2520
2595
|
r.current = n;
|
|
2521
|
-
let i = O(() => new
|
|
2596
|
+
let i = O(() => new Vr(e, t, () => r.current), [e, t]), a = E((n) => i.activate(n, () => J(r, e, t)), [
|
|
2522
2597
|
i,
|
|
2523
2598
|
e,
|
|
2524
2599
|
t
|
|
@@ -2535,77 +2610,77 @@ var Q = class extends Error {
|
|
|
2535
2610
|
clear: i.clear,
|
|
2536
2611
|
ready: o.status === "ready"
|
|
2537
2612
|
};
|
|
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 =
|
|
2613
|
+
}, Ur = q, Wr = (e) => ({
|
|
2614
|
+
useSubscription: (t, n, r) => Ur(e, t, n, r),
|
|
2615
|
+
useMutation: (t) => xr(e, t),
|
|
2616
|
+
useConnectionSetup: (t) => Hr(e, t),
|
|
2617
|
+
useAction: (t) => Er(e, t),
|
|
2618
|
+
useFormBinding: (t, n) => Ir(e, t, n ?? {})
|
|
2619
|
+
}), Gr = () => ({ seeds: [] }), Kr = null, qr = (e) => {
|
|
2620
|
+
Kr = e;
|
|
2621
|
+
}, Jr = /* @__PURE__ */ new Map(), Yr = (e, t) => `${e}\u0000${t}`, Xr = (e, t, n, r) => {
|
|
2622
|
+
let i = Kr?.() ?? null;
|
|
2548
2623
|
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
2624
|
i.seeds.push({
|
|
2550
2625
|
api: e,
|
|
2551
|
-
key:
|
|
2626
|
+
key: U([t, n]),
|
|
2552
2627
|
value: r
|
|
2553
2628
|
});
|
|
2554
|
-
},
|
|
2555
|
-
let r =
|
|
2629
|
+
}, Zr = (e, t, n) => {
|
|
2630
|
+
let r = Kr?.() ?? null;
|
|
2556
2631
|
r !== null && r.seeds.push({
|
|
2557
2632
|
api: e,
|
|
2558
|
-
key:
|
|
2633
|
+
key: U([t, n]),
|
|
2559
2634
|
value: void 0,
|
|
2560
2635
|
failed: !0
|
|
2561
2636
|
});
|
|
2562
|
-
},
|
|
2563
|
-
if (e !== void 0) for (let t of e)
|
|
2637
|
+
}, Qr = (e) => {
|
|
2638
|
+
if (e !== void 0) for (let t of e) Jr.set(Yr(t.api, t.key), {
|
|
2564
2639
|
value: t.value,
|
|
2565
2640
|
failed: t.failed === !0
|
|
2566
2641
|
});
|
|
2567
|
-
},
|
|
2568
|
-
let r =
|
|
2642
|
+
}, $r = (e, t, n) => {
|
|
2643
|
+
let r = U([t, n]), i = Kr?.() ?? null;
|
|
2569
2644
|
if (i !== null) {
|
|
2570
2645
|
for (let t of i.seeds) if (t.api === e && t.key === r) return t.failed === !0 ? void 0 : t.value;
|
|
2571
2646
|
return;
|
|
2572
2647
|
}
|
|
2573
|
-
let a =
|
|
2648
|
+
let a = Jr.get(Yr(e, r));
|
|
2574
2649
|
return a === void 0 || a.failed ? void 0 : a.value;
|
|
2575
|
-
},
|
|
2576
|
-
let r =
|
|
2650
|
+
}, ei = (e, t, n) => {
|
|
2651
|
+
let r = U([t, n]), i = Kr?.() ?? null;
|
|
2577
2652
|
if (i !== null) {
|
|
2578
2653
|
for (let t of i.seeds) if (t.api === e && t.key === r) return t.failed === !0 ? "failed" : "seeded";
|
|
2579
2654
|
return "absent";
|
|
2580
2655
|
}
|
|
2581
|
-
let a =
|
|
2656
|
+
let a = Jr.get(Yr(e, r));
|
|
2582
2657
|
return a === void 0 ? "absent" : a.failed ? "failed" : "seeded";
|
|
2583
|
-
},
|
|
2584
|
-
|
|
2658
|
+
}, ti = () => {
|
|
2659
|
+
Jr.clear();
|
|
2585
2660
|
};
|
|
2586
2661
|
//#endregion
|
|
2587
2662
|
//#region src/usePreloadedSubscription.ts
|
|
2588
|
-
function
|
|
2589
|
-
let i =
|
|
2663
|
+
function ni(e, t, n = {}, r = {}) {
|
|
2664
|
+
let i = $r(e, t, n), a = q(e, t, n, i === void 0 ? r : {
|
|
2590
2665
|
...r,
|
|
2591
2666
|
initialSnapshot: i
|
|
2592
2667
|
});
|
|
2593
|
-
return
|
|
2668
|
+
return ei(e, t, n) === "failed" ? {
|
|
2594
2669
|
...a,
|
|
2595
2670
|
preloadFailed: !0
|
|
2596
2671
|
} : a;
|
|
2597
2672
|
}
|
|
2598
2673
|
//#endregion
|
|
2599
2674
|
//#region src/useEvent.ts
|
|
2600
|
-
var
|
|
2675
|
+
var ri = {
|
|
2601
2676
|
status: "idle",
|
|
2602
2677
|
missed: 0,
|
|
2603
2678
|
lastMiss: void 0
|
|
2604
|
-
},
|
|
2679
|
+
}, ii = class {
|
|
2605
2680
|
_tag = "EventStreamClosed";
|
|
2606
2681
|
};
|
|
2607
|
-
function
|
|
2608
|
-
let { skip: i = !1, apiName: a = "app", onMissed: o } = r, s =
|
|
2682
|
+
function ai(e, t, n, r = {}) {
|
|
2683
|
+
let { skip: i = !1, apiName: a = "app", onMissed: o } = r, s = G(a), { runtime: c, client: l } = s, [u, d] = A(ri), f = k(n);
|
|
2609
2684
|
f.current = n;
|
|
2610
2685
|
let p = k(o);
|
|
2611
2686
|
p.current = o;
|
|
@@ -2618,7 +2693,7 @@ function Gr(e, t, n, r = {}) {
|
|
|
2618
2693
|
let y = k(null);
|
|
2619
2694
|
y.current !== _ && (y.current = _, g.current = /* @__PURE__ */ new Map());
|
|
2620
2695
|
let b = E((t, n) => {
|
|
2621
|
-
t <= 0 || (
|
|
2696
|
+
t <= 0 || (H(a, "event.gap", {
|
|
2622
2697
|
tag: e.name,
|
|
2623
2698
|
missed: t,
|
|
2624
2699
|
reason: n
|
|
@@ -2633,10 +2708,10 @@ function Gr(e, t, n, r = {}) {
|
|
|
2633
2708
|
count: t,
|
|
2634
2709
|
reason: n
|
|
2635
2710
|
}));
|
|
2636
|
-
}, [a, e.name]), x = !i && _ !== null && !
|
|
2711
|
+
}, [a, e.name]), x = !i && _ !== null && !Lt(s);
|
|
2637
2712
|
return D(() => {
|
|
2638
2713
|
if (!x) {
|
|
2639
|
-
d(
|
|
2714
|
+
d(ri);
|
|
2640
2715
|
return;
|
|
2641
2716
|
}
|
|
2642
2717
|
d((e) => ({
|
|
@@ -2648,13 +2723,13 @@ function Gr(e, t, n, r = {}) {
|
|
|
2648
2723
|
origin: e,
|
|
2649
2724
|
n: t
|
|
2650
2725
|
}));
|
|
2651
|
-
return
|
|
2726
|
+
return K(m.current, e.name)({
|
|
2652
2727
|
key: v.current,
|
|
2653
2728
|
...t.length > 0 ? { resume: t } : {}
|
|
2654
2729
|
});
|
|
2655
2730
|
}), r = R.unwrap(n).pipe(R.tap(() => N.sync(() => {
|
|
2656
2731
|
t = 0;
|
|
2657
|
-
})), R.concat(R.fail(new
|
|
2732
|
+
})), R.concat(R.fail(new ii())), R.retry(L.exponential("250 millis", 2).pipe(L.either(L.spaced("30 seconds")), L.jittered, L.tapOutput(() => N.sync(() => {
|
|
2658
2733
|
t += 1, d((e) => ({
|
|
2659
2734
|
...e,
|
|
2660
2735
|
status: "connecting"
|
|
@@ -2681,11 +2756,11 @@ function Gr(e, t, n, r = {}) {
|
|
|
2681
2756
|
_,
|
|
2682
2757
|
e.name,
|
|
2683
2758
|
b
|
|
2684
|
-
]), x ? u :
|
|
2759
|
+
]), x ? u : ri;
|
|
2685
2760
|
}
|
|
2686
2761
|
//#endregion
|
|
2687
2762
|
//#region src/sequence.ts
|
|
2688
|
-
var
|
|
2763
|
+
var oi = () => {
|
|
2689
2764
|
let e = (t) => ({
|
|
2690
2765
|
steps: t,
|
|
2691
2766
|
step: ((n, r, i) => e([...t, {
|
|
@@ -2697,7 +2772,7 @@ var Kr = () => {
|
|
|
2697
2772
|
}]))
|
|
2698
2773
|
});
|
|
2699
2774
|
return e([]);
|
|
2700
|
-
},
|
|
2775
|
+
}, si = async (e, t = {}) => {
|
|
2701
2776
|
let n = {}, r = [];
|
|
2702
2777
|
for (let i of e.steps) {
|
|
2703
2778
|
if (i.when !== void 0 && !i.when(n)) {
|
|
@@ -2757,13 +2832,13 @@ var Kr = () => {
|
|
|
2757
2832
|
ok: !0,
|
|
2758
2833
|
data: n
|
|
2759
2834
|
};
|
|
2760
|
-
},
|
|
2835
|
+
}, ci = (e = {}) => {
|
|
2761
2836
|
let [t, n] = A(!1), [r, i] = A(void 0), [a, o] = A(void 0), s = k(e);
|
|
2762
2837
|
return s.current = e, {
|
|
2763
2838
|
run: E(async (e, t = {}) => {
|
|
2764
2839
|
n(!0), i(void 0), o(void 0);
|
|
2765
2840
|
try {
|
|
2766
|
-
let n = await
|
|
2841
|
+
let n = await si(e, {
|
|
2767
2842
|
...s.current,
|
|
2768
2843
|
...t
|
|
2769
2844
|
});
|
|
@@ -2776,7 +2851,7 @@ var Kr = () => {
|
|
|
2776
2851
|
error: r,
|
|
2777
2852
|
failedStep: a
|
|
2778
2853
|
};
|
|
2779
|
-
},
|
|
2854
|
+
}, li = "@voltro/plugin-storage", $ = (e) => ge(li, e), ui = (e, t, n, r) => new Promise((i, a) => {
|
|
2780
2855
|
let o = new XMLHttpRequest();
|
|
2781
2856
|
if (o.open("PUT", e), o.upload.onprogress = (e) => {
|
|
2782
2857
|
e.lengthComputable && n(e.loaded / e.total);
|
|
@@ -2790,7 +2865,7 @@ var Kr = () => {
|
|
|
2790
2865
|
return;
|
|
2791
2866
|
}
|
|
2792
2867
|
r.addEventListener("abort", () => o.abort(), { once: !0 }), o.send(t);
|
|
2793
|
-
}),
|
|
2868
|
+
}), di = (e, t, n, r, i, a) => new Promise((o, s) => {
|
|
2794
2869
|
let c = new XMLHttpRequest();
|
|
2795
2870
|
if (c.open("POST", e), c.setRequestHeader("content-type", t), c.upload.onprogress = (e) => {
|
|
2796
2871
|
e.lengthComputable && r(e.loaded / e.total);
|
|
@@ -2808,7 +2883,7 @@ var Kr = () => {
|
|
|
2808
2883
|
return;
|
|
2809
2884
|
}
|
|
2810
2885
|
i.addEventListener("abort", () => c.abort(), { once: !0 }), c.send(n);
|
|
2811
|
-
}),
|
|
2886
|
+
}), fi = (e, t, n, r, i) => new Promise((a, o) => {
|
|
2812
2887
|
let s = new XMLHttpRequest();
|
|
2813
2888
|
if (s.open("PUT", e), s.setRequestHeader("content-type", t), s.upload.onprogress = (e) => {
|
|
2814
2889
|
e.lengthComputable && r(e.loaded / e.total);
|
|
@@ -2819,7 +2894,7 @@ var Kr = () => {
|
|
|
2819
2894
|
return;
|
|
2820
2895
|
}
|
|
2821
2896
|
i.addEventListener("abort", () => s.abort(), { once: !0 }), s.send(n);
|
|
2822
|
-
}),
|
|
2897
|
+
}), pi = (e, t, n, r, i) => new Promise((a, o) => {
|
|
2823
2898
|
let s = new XMLHttpRequest();
|
|
2824
2899
|
if (s.open("POST", e), s.setRequestHeader("content-type", t), s.upload.onprogress = (e) => {
|
|
2825
2900
|
e.lengthComputable && r(e.loaded / e.total);
|
|
@@ -2835,16 +2910,16 @@ var Kr = () => {
|
|
|
2835
2910
|
return;
|
|
2836
2911
|
}
|
|
2837
2912
|
i.addEventListener("abort", () => s.abort(), { once: !0 }), s.send(n);
|
|
2838
|
-
}),
|
|
2839
|
-
let n =
|
|
2913
|
+
}), mi = (e, t = {}) => {
|
|
2914
|
+
let n = G(e), { inspectBaseUrl: r } = n, i = k(n);
|
|
2840
2915
|
i.current = n;
|
|
2841
2916
|
let [a, o] = A(0), [s, c] = A("idle"), [l, u] = A(void 0), d = k(null), f = E(() => {
|
|
2842
2917
|
o(0), c("idle"), u(void 0);
|
|
2843
2918
|
}, []), p = E(() => {
|
|
2844
2919
|
d.current?.abort();
|
|
2845
2920
|
}, []), m = E((e) => /^https?:\/\//.test(e) ? e : `${r}${e}`, [r]), h = E(async (n, r, a, o) => {
|
|
2846
|
-
let { runtime: s, client: c } = await
|
|
2847
|
-
throw
|
|
2921
|
+
let { runtime: s, client: c } = await J(i, e, "storage.upload").catch((e) => {
|
|
2922
|
+
throw z(e, "client");
|
|
2848
2923
|
}), l = Math.max(0, r.retries ?? t.retries ?? 1), u = (n instanceof File, n.type || "application/octet-stream"), d = n instanceof File ? n.name : "blob", f = r.visibility ?? t.visibility, p = r.key ?? t.key, h = r.folder ?? t.folder, g = r.tags ?? t.tags, _ = {
|
|
2849
2924
|
...f ? { visibility: f } : {},
|
|
2850
2925
|
...h ? { folder: h } : {},
|
|
@@ -2860,28 +2935,28 @@ var Kr = () => {
|
|
|
2860
2935
|
...e.width === void 0 ? {} : { width: e.width },
|
|
2861
2936
|
...e.height === void 0 ? {} : { height: e.height }
|
|
2862
2937
|
}), y = async () => {
|
|
2863
|
-
let e = r.mintTag ?? t.mintTag ?? $("mintUploadTicket"), i =
|
|
2938
|
+
let e = r.mintTag ?? t.mintTag ?? $("mintUploadTicket"), i = K(c, e), l = await Y(s, i({
|
|
2864
2939
|
contentType: u,
|
|
2865
2940
|
..._,
|
|
2866
2941
|
...p ? { key: p } : {}
|
|
2867
|
-
})), d = await
|
|
2942
|
+
})), d = await pi(m(l.uploadUrl), u, n, o, a);
|
|
2868
2943
|
return v(d);
|
|
2869
2944
|
}, b = async () => {
|
|
2870
2945
|
let e = r.presignMintTag ?? t.presignMintTag ?? $("mintPresignedUpload"), i = r.finalizeTag ?? t.finalizeTag ?? $("finalizeUpload"), l;
|
|
2871
2946
|
try {
|
|
2872
|
-
let t =
|
|
2873
|
-
l = await
|
|
2947
|
+
let t = K(c, e);
|
|
2948
|
+
l = await Y(s, t({
|
|
2874
2949
|
contentType: u,
|
|
2875
2950
|
..._
|
|
2876
2951
|
}));
|
|
2877
2952
|
} catch {
|
|
2878
2953
|
return null;
|
|
2879
2954
|
}
|
|
2880
|
-
await
|
|
2881
|
-
let d =
|
|
2955
|
+
await fi(l.uploadUrl, u, n, o, a);
|
|
2956
|
+
let d = K(c, i), f = await Y(s, d({ finalizeToken: l.finalizeToken }));
|
|
2882
2957
|
return v(f);
|
|
2883
2958
|
}, x = async () => {
|
|
2884
|
-
let e = r.beginResumableTag ?? t.beginResumableTag ?? $("beginResumableUpload"), i =
|
|
2959
|
+
let e = r.beginResumableTag ?? t.beginResumableTag ?? $("beginResumableUpload"), i = K(c, e), l = n.size, d = r.chunkSize ?? t.chunkSize, f = await Y(s, i({
|
|
2885
2960
|
contentType: u,
|
|
2886
2961
|
size: l,
|
|
2887
2962
|
..._,
|
|
@@ -2892,7 +2967,7 @@ var Kr = () => {
|
|
|
2892
2967
|
for (;;) {
|
|
2893
2968
|
if (a.aborted) throw new DOMException("upload aborted", "AbortError");
|
|
2894
2969
|
try {
|
|
2895
|
-
let t = await
|
|
2970
|
+
let t = await di(`${p}?${`token=${encodeURIComponent(f.resumableToken)}&index=${e}${s ? "&final=1" : ""}`}`, u, i, (e) => o((b + e * c) / l), a, s);
|
|
2896
2971
|
s && (x = t);
|
|
2897
2972
|
break;
|
|
2898
2973
|
} catch (e) {
|
|
@@ -2906,8 +2981,8 @@ var Kr = () => {
|
|
|
2906
2981
|
}, S = async () => {
|
|
2907
2982
|
let e = r.multipartBeginTag ?? t.multipartBeginTag ?? $("beginMultipartUpload"), i = r.multipartSignTag ?? t.multipartSignTag ?? $("signMultipartPart"), l = r.multipartCompleteTag ?? t.multipartCompleteTag ?? $("completeMultipartUpload"), f = r.multipartAbortTag ?? t.multipartAbortTag ?? $("abortMultipartUpload"), p = n.size, h = r.chunkSize ?? t.chunkSize, g;
|
|
2908
2983
|
try {
|
|
2909
|
-
let t =
|
|
2910
|
-
g = await
|
|
2984
|
+
let t = K(c, e);
|
|
2985
|
+
g = await Y(s, t({
|
|
2911
2986
|
contentType: u,
|
|
2912
2987
|
size: p,
|
|
2913
2988
|
..._,
|
|
@@ -2916,17 +2991,17 @@ var Kr = () => {
|
|
|
2916
2991
|
} catch {
|
|
2917
2992
|
return null;
|
|
2918
2993
|
}
|
|
2919
|
-
let v =
|
|
2994
|
+
let v = K(c, i), y = K(c, l), b = K(c, f), x = Math.max(1, g.partSize), S = Math.max(1, Math.ceil(p / x)), C = Math.max(0, r.retries ?? t.retries ?? 1), w = [], T = 0;
|
|
2920
2995
|
try {
|
|
2921
2996
|
for (let e = 0; e < S; e++) {
|
|
2922
2997
|
let t = e * x, r = Math.min(p, t + x), i = n.slice(t, r), c = e + 1, l = r - t, u = 0;
|
|
2923
2998
|
for (;;) {
|
|
2924
2999
|
if (a.aborted) throw new DOMException("upload aborted", "AbortError");
|
|
2925
3000
|
try {
|
|
2926
|
-
let { url: e } = await
|
|
3001
|
+
let { url: e } = await Y(s, v({
|
|
2927
3002
|
multipartToken: g.multipartToken,
|
|
2928
3003
|
partNumber: c
|
|
2929
|
-
})), t = await
|
|
3004
|
+
})), t = await ui(e, i, (e) => o((T + e * l) / p), a);
|
|
2930
3005
|
w.push({
|
|
2931
3006
|
partNumber: c,
|
|
2932
3007
|
etag: t
|
|
@@ -2938,7 +3013,7 @@ var Kr = () => {
|
|
|
2938
3013
|
}
|
|
2939
3014
|
T += l, o(T / p);
|
|
2940
3015
|
}
|
|
2941
|
-
let e = await
|
|
3016
|
+
let e = await Y(s, y({
|
|
2942
3017
|
multipartToken: g.multipartToken,
|
|
2943
3018
|
parts: w
|
|
2944
3019
|
}));
|
|
@@ -2951,7 +3026,7 @@ var Kr = () => {
|
|
|
2951
3026
|
};
|
|
2952
3027
|
} catch (e) {
|
|
2953
3028
|
try {
|
|
2954
|
-
await
|
|
3029
|
+
await Y(s, b({ multipartToken: g.multipartToken }));
|
|
2955
3030
|
} catch {}
|
|
2956
3031
|
throw e;
|
|
2957
3032
|
}
|
|
@@ -3069,8 +3144,8 @@ var Kr = () => {
|
|
|
3069
3144
|
y,
|
|
3070
3145
|
b
|
|
3071
3146
|
]);
|
|
3072
|
-
},
|
|
3073
|
-
let n =
|
|
3147
|
+
}, hi = (e, t) => {
|
|
3148
|
+
let n = mi(e), r = Er(e, t.action), [i, a] = A("idle"), [o, s] = A(void 0), [c, l] = A(void 0), u = k(t.extra);
|
|
3074
3149
|
u.current = t.extra;
|
|
3075
3150
|
let d = E(async (e) => {
|
|
3076
3151
|
l(void 0), s(void 0), a("uploading");
|
|
@@ -3113,9 +3188,9 @@ var Kr = () => {
|
|
|
3113
3188
|
f,
|
|
3114
3189
|
p
|
|
3115
3190
|
]);
|
|
3116
|
-
},
|
|
3117
|
-
let t =
|
|
3118
|
-
|
|
3191
|
+
}, gi = async (e) => {
|
|
3192
|
+
let t = K(e.client, e.tag), n = N.currentSpan.pipe(N.tap((t) => N.sync(() => {
|
|
3193
|
+
Ce({
|
|
3119
3194
|
traceId: t.traceId,
|
|
3120
3195
|
spanId: t.spanId,
|
|
3121
3196
|
source: "mutation",
|
|
@@ -3125,9 +3200,9 @@ var Kr = () => {
|
|
|
3125
3200
|
"voltro.api": e.apiName,
|
|
3126
3201
|
"rpc.tag": e.tag
|
|
3127
3202
|
} }));
|
|
3128
|
-
return
|
|
3129
|
-
},
|
|
3130
|
-
let n =
|
|
3203
|
+
return Y(e.runtime, n);
|
|
3204
|
+
}, _i = (e, t) => {
|
|
3205
|
+
let n = G(e), { descriptors: r } = n, i = k(n);
|
|
3131
3206
|
if (i.current = n, process.env.NODE_ENV !== "production") {
|
|
3132
3207
|
let n = r[t]?.kind;
|
|
3133
3208
|
n !== void 0 && n !== "workflow" && console.error(`[@voltro/client] useWorkflow('${e}', '${t}') targets a ${n}, not a workflow. Use ${n === "mutation" ? "useMutation" : n === "action" ? "useAction" : `the ${n} hook`} instead.`);
|
|
@@ -3135,7 +3210,7 @@ var Kr = () => {
|
|
|
3135
3210
|
let [a, o] = A(!1), [s, c] = A(void 0), [l, u] = A(void 0), d = E(async (n) => {
|
|
3136
3211
|
o(!0), c(void 0);
|
|
3137
3212
|
try {
|
|
3138
|
-
let { runtime: r, client: a } = await
|
|
3213
|
+
let { runtime: r, client: a } = await J(i, e, t), o = await gi({
|
|
3139
3214
|
apiName: e,
|
|
3140
3215
|
runtime: r,
|
|
3141
3216
|
client: a,
|
|
@@ -3150,8 +3225,8 @@ var Kr = () => {
|
|
|
3150
3225
|
o(!1);
|
|
3151
3226
|
}
|
|
3152
3227
|
}, [e, t]), f = E(async (t) => {
|
|
3153
|
-
let { runtime: n, client: r } = await
|
|
3154
|
-
await
|
|
3228
|
+
let { runtime: n, client: r } = await J(i, e, "__voltro.workflow.cancel");
|
|
3229
|
+
await gi({
|
|
3155
3230
|
apiName: e,
|
|
3156
3231
|
runtime: n,
|
|
3157
3232
|
client: r,
|
|
@@ -3160,8 +3235,8 @@ var Kr = () => {
|
|
|
3160
3235
|
spanPrefix: "client.workflow.cancel"
|
|
3161
3236
|
});
|
|
3162
3237
|
}, [e]), p = E(async (t) => {
|
|
3163
|
-
let { runtime: n, client: r } = await
|
|
3164
|
-
await
|
|
3238
|
+
let { runtime: n, client: r } = await J(i, e, "__voltro.workflow.resume");
|
|
3239
|
+
await gi({
|
|
3165
3240
|
apiName: e,
|
|
3166
3241
|
runtime: n,
|
|
3167
3242
|
client: r,
|
|
@@ -3170,8 +3245,8 @@ var Kr = () => {
|
|
|
3170
3245
|
spanPrefix: "client.workflow.resume"
|
|
3171
3246
|
});
|
|
3172
3247
|
}, [e]), m = E(async (t, n, r) => {
|
|
3173
|
-
let { runtime: a, client: o } = await
|
|
3174
|
-
return
|
|
3248
|
+
let { runtime: a, client: o } = await J(i, e, "__voltro.workflow.signal");
|
|
3249
|
+
return gi({
|
|
3175
3250
|
apiName: e,
|
|
3176
3251
|
runtime: a,
|
|
3177
3252
|
client: o,
|
|
@@ -3184,8 +3259,8 @@ var Kr = () => {
|
|
|
3184
3259
|
spanPrefix: "client.workflow.signal"
|
|
3185
3260
|
});
|
|
3186
3261
|
}, [e]), h = E(async (t, n, r, a) => {
|
|
3187
|
-
let { runtime: o, client: s } = await
|
|
3188
|
-
return
|
|
3262
|
+
let { runtime: o, client: s } = await J(i, e, "__voltro.workflow.update");
|
|
3263
|
+
return gi({
|
|
3189
3264
|
apiName: e,
|
|
3190
3265
|
runtime: o,
|
|
3191
3266
|
client: s,
|
|
@@ -3218,13 +3293,13 @@ var Kr = () => {
|
|
|
3218
3293
|
s,
|
|
3219
3294
|
l
|
|
3220
3295
|
]);
|
|
3221
|
-
},
|
|
3222
|
-
let t =
|
|
3296
|
+
}, vi = (e) => {
|
|
3297
|
+
let t = G(e), n = k(t);
|
|
3223
3298
|
n.current = t;
|
|
3224
3299
|
let [r, i] = A(!1), [a, o] = A(void 0), [s, c] = A(void 0), l = E(async (t, r, a) => {
|
|
3225
3300
|
i(!0), o(void 0);
|
|
3226
3301
|
try {
|
|
3227
|
-
let { runtime: i, client: o } = await
|
|
3302
|
+
let { runtime: i, client: o } = await J(n, e, "__voltro.workflow.signal"), s = await gi({
|
|
3228
3303
|
apiName: e,
|
|
3229
3304
|
runtime: i,
|
|
3230
3305
|
client: o,
|
|
@@ -3254,13 +3329,13 @@ var Kr = () => {
|
|
|
3254
3329
|
a,
|
|
3255
3330
|
s
|
|
3256
3331
|
]);
|
|
3257
|
-
},
|
|
3258
|
-
let t =
|
|
3332
|
+
}, yi = (e) => {
|
|
3333
|
+
let t = G(e), n = k(t);
|
|
3259
3334
|
n.current = t;
|
|
3260
3335
|
let [r, i] = A(!1), [a, o] = A(void 0), [s, c] = A(void 0), l = E(async (t, r, a, s) => {
|
|
3261
3336
|
i(!0), o(void 0);
|
|
3262
3337
|
try {
|
|
3263
|
-
let { runtime: i, client: o } = await
|
|
3338
|
+
let { runtime: i, client: o } = await J(n, e, "__voltro.workflow.update"), l = await gi({
|
|
3264
3339
|
apiName: e,
|
|
3265
3340
|
runtime: i,
|
|
3266
3341
|
client: o,
|
|
@@ -3291,8 +3366,8 @@ var Kr = () => {
|
|
|
3291
3366
|
a,
|
|
3292
3367
|
s
|
|
3293
3368
|
]);
|
|
3294
|
-
},
|
|
3295
|
-
let n =
|
|
3369
|
+
}, bi = (e, t) => {
|
|
3370
|
+
let n = q(e, "__voltro.workflow.run", t ? { id: t } : {}, { skip: t === void 0 });
|
|
3296
3371
|
return n.loading || n.idle || n.failed ? {
|
|
3297
3372
|
...n,
|
|
3298
3373
|
run: void 0
|
|
@@ -3300,8 +3375,8 @@ var Kr = () => {
|
|
|
3300
3375
|
...n,
|
|
3301
3376
|
run: n.data[0]
|
|
3302
3377
|
};
|
|
3303
|
-
},
|
|
3304
|
-
let r =
|
|
3378
|
+
}, xi = (e, t = {}, n = {}) => {
|
|
3379
|
+
let r = q(e, "__voltro.workflow.runs", t, n);
|
|
3305
3380
|
return r.loading || r.idle || r.failed ? {
|
|
3306
3381
|
...r,
|
|
3307
3382
|
runs: []
|
|
@@ -3309,8 +3384,8 @@ var Kr = () => {
|
|
|
3309
3384
|
...r,
|
|
3310
3385
|
runs: r.data
|
|
3311
3386
|
};
|
|
3312
|
-
},
|
|
3313
|
-
let n =
|
|
3387
|
+
}, Si = (e, t) => {
|
|
3388
|
+
let n = q(e, "__voltro.workflow.run.steps", t ? { runId: t } : {}, { skip: t === void 0 });
|
|
3314
3389
|
return n.loading || n.idle || n.failed ? {
|
|
3315
3390
|
...n,
|
|
3316
3391
|
steps: []
|
|
@@ -3318,8 +3393,8 @@ var Kr = () => {
|
|
|
3318
3393
|
...n,
|
|
3319
3394
|
steps: n.data
|
|
3320
3395
|
};
|
|
3321
|
-
},
|
|
3322
|
-
let n =
|
|
3396
|
+
}, Ci = (e, t) => {
|
|
3397
|
+
let n = q(e, "__voltro.workflow.run.events", t ? { runId: t } : {}, { skip: t === void 0 });
|
|
3323
3398
|
return n.loading || n.idle || n.failed ? {
|
|
3324
3399
|
...n,
|
|
3325
3400
|
events: []
|
|
@@ -3327,8 +3402,8 @@ var Kr = () => {
|
|
|
3327
3402
|
...n,
|
|
3328
3403
|
events: n.data
|
|
3329
3404
|
};
|
|
3330
|
-
},
|
|
3331
|
-
let r =
|
|
3405
|
+
}, wi = Ci, Ti = (e, t = {}, n = {}) => {
|
|
3406
|
+
let r = q(e, "__voltro.workflow.domainEvents", t, n);
|
|
3332
3407
|
return r.loading || r.idle || r.failed ? {
|
|
3333
3408
|
...r,
|
|
3334
3409
|
events: []
|
|
@@ -3336,8 +3411,8 @@ var Kr = () => {
|
|
|
3336
3411
|
...r,
|
|
3337
3412
|
events: r.data
|
|
3338
3413
|
};
|
|
3339
|
-
},
|
|
3340
|
-
let n =
|
|
3414
|
+
}, Ei = (e, t) => {
|
|
3415
|
+
let n = q(e, "__voltro.workflow.event.deliveries", t ? { eventId: t } : {}, { skip: t === void 0 });
|
|
3341
3416
|
return n.loading || n.idle || n.failed ? {
|
|
3342
3417
|
...n,
|
|
3343
3418
|
deliveries: []
|
|
@@ -3345,42 +3420,42 @@ var Kr = () => {
|
|
|
3345
3420
|
...n,
|
|
3346
3421
|
deliveries: n.data
|
|
3347
3422
|
};
|
|
3348
|
-
},
|
|
3423
|
+
}, Di = (e, t) => {
|
|
3349
3424
|
let n = e.payload;
|
|
3350
3425
|
if (!n || typeof n != "object") return;
|
|
3351
3426
|
let r = n[t];
|
|
3352
3427
|
return typeof r == "string" ? r : void 0;
|
|
3353
|
-
},
|
|
3428
|
+
}, Oi = (e) => {
|
|
3354
3429
|
let t = e.payload;
|
|
3355
3430
|
if (!t || typeof t != "object") return;
|
|
3356
3431
|
let n = t.updateId;
|
|
3357
3432
|
return typeof n == "string" ? n : void 0;
|
|
3358
|
-
},
|
|
3433
|
+
}, ki = (e) => {
|
|
3359
3434
|
let t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set();
|
|
3360
3435
|
for (let r of e) if (r.eventType === "signal-received") {
|
|
3361
|
-
let e =
|
|
3436
|
+
let e = Di(r, "signalName");
|
|
3362
3437
|
e && t.add(e);
|
|
3363
3438
|
} else if (r.eventType === "update-completed" || r.eventType === "update-failed") {
|
|
3364
|
-
let e =
|
|
3439
|
+
let e = Oi(r);
|
|
3365
3440
|
e && n.add(e);
|
|
3366
3441
|
}
|
|
3367
3442
|
for (let r = e.length - 1; r >= 0; --r) {
|
|
3368
3443
|
let i = e[r];
|
|
3369
3444
|
if (i.eventType === "signal-awaited") {
|
|
3370
|
-
let e =
|
|
3445
|
+
let e = Di(i, "signalName");
|
|
3371
3446
|
if (e && !t.has(e)) return {
|
|
3372
3447
|
name: e,
|
|
3373
3448
|
kind: "signal"
|
|
3374
3449
|
};
|
|
3375
3450
|
} else if (i.eventType === "update-requested") {
|
|
3376
|
-
let e =
|
|
3451
|
+
let e = Oi(i), t = Di(i, "updateName");
|
|
3377
3452
|
if (t && (!e || !n.has(e))) return {
|
|
3378
3453
|
name: t,
|
|
3379
3454
|
kind: "update"
|
|
3380
3455
|
};
|
|
3381
3456
|
}
|
|
3382
3457
|
}
|
|
3383
|
-
},
|
|
3458
|
+
}, Ai = (e) => e.find((e) => e.status === "running") || (e.length > 0 ? e[e.length - 1] : void 0), ji = (e, t) => {
|
|
3384
3459
|
if (!e || e.status !== "failed") return;
|
|
3385
3460
|
let n = t.find((e) => e.status === "failed");
|
|
3386
3461
|
return {
|
|
@@ -3388,8 +3463,8 @@ var Kr = () => {
|
|
|
3388
3463
|
message: e.errorMessage,
|
|
3389
3464
|
step: n?.stepName
|
|
3390
3465
|
};
|
|
3391
|
-
},
|
|
3392
|
-
let n =
|
|
3466
|
+
}, Mi = (e, t) => {
|
|
3467
|
+
let n = bi(e, t), r = Si(e, t), i = Ci(e, t), a = _i(e, n.run?.tag ?? ""), o = n.run, s = r.steps, c = i.events, l = E(async () => {
|
|
3393
3468
|
if (!o) throw Error("useWorkflowRunState: no run loaded — cannot cancel");
|
|
3394
3469
|
await a.cancel({
|
|
3395
3470
|
workflowName: o.tag,
|
|
@@ -3413,9 +3488,9 @@ var Kr = () => {
|
|
|
3413
3488
|
status: o?.status,
|
|
3414
3489
|
steps: s,
|
|
3415
3490
|
events: c,
|
|
3416
|
-
currentStep:
|
|
3417
|
-
waitingFor: o?.status === "suspended" ?
|
|
3418
|
-
error:
|
|
3491
|
+
currentStep: Ai(s),
|
|
3492
|
+
waitingFor: o?.status === "suspended" ? ki(c) : void 0,
|
|
3493
|
+
error: ji(o, s),
|
|
3419
3494
|
traceId: o?.traceId,
|
|
3420
3495
|
loading: n.data === void 0,
|
|
3421
3496
|
cancel: l,
|
|
@@ -3432,8 +3507,8 @@ var Kr = () => {
|
|
|
3432
3507
|
d,
|
|
3433
3508
|
f
|
|
3434
3509
|
]);
|
|
3435
|
-
},
|
|
3436
|
-
let { runtime: n, client: r } =
|
|
3510
|
+
}, Ni = (e, t) => {
|
|
3511
|
+
let { runtime: n, client: r } = G(e), [i, a] = A([]), [o, s] = A("idle"), [c, l] = A(void 0), u = k(null), d = E(() => {
|
|
3437
3512
|
let e = u.current;
|
|
3438
3513
|
e && (u.current = null, n.runFork(ie.interrupt(e)), s((e) => e === "streaming" ? "idle" : e));
|
|
3439
3514
|
}, [n]);
|
|
@@ -3444,7 +3519,7 @@ var Kr = () => {
|
|
|
3444
3519
|
start: E((e = {}) => {
|
|
3445
3520
|
let i = u.current;
|
|
3446
3521
|
i && n.runFork(ie.interrupt(i)), a([]), l(void 0), s("streaming");
|
|
3447
|
-
let o =
|
|
3522
|
+
let o = K(r, t)(e), c = R.runForEach(o, (e) => N.sync(() => a((t) => [...t, e]))).pipe(N.matchCause({
|
|
3448
3523
|
onSuccess: () => {
|
|
3449
3524
|
s("done");
|
|
3450
3525
|
},
|
|
@@ -3460,7 +3535,7 @@ var Kr = () => {
|
|
|
3460
3535
|
]),
|
|
3461
3536
|
cancel: d
|
|
3462
3537
|
};
|
|
3463
|
-
},
|
|
3538
|
+
}, Pi = (e, t, n, r) => {
|
|
3464
3539
|
let i = 0, a = !1, o = (e) => N.sync(() => {
|
|
3465
3540
|
e.seq <= i || (i = e.seq, n.onEvent(e.event), r.isTerminal(e.event) && (a = !0));
|
|
3466
3541
|
}), s = (e) => {
|
|
@@ -3487,15 +3562,15 @@ var Kr = () => {
|
|
|
3487
3562
|
}));
|
|
3488
3563
|
});
|
|
3489
3564
|
return u(0);
|
|
3490
|
-
},
|
|
3565
|
+
}, Fi = (e) => {
|
|
3491
3566
|
let t = e?._tag;
|
|
3492
3567
|
return t === "done" || t === "error";
|
|
3493
|
-
},
|
|
3494
|
-
let { runtime: r, client: i } =
|
|
3568
|
+
}, Ii = (e, t, n = {}) => {
|
|
3569
|
+
let { runtime: r, client: i } = G(e), [a, o] = A([]), [s, c] = A("idle"), [l, u] = A(0), [d, f] = A(void 0), p = k(null), m = {
|
|
3495
3570
|
maxReconnects: n.maxReconnects ?? 6,
|
|
3496
3571
|
backoffMs: n.backoffMs ?? 400,
|
|
3497
3572
|
maxBackoffMs: n.maxBackoffMs ?? 8e3,
|
|
3498
|
-
isTerminal: n.isTerminal ??
|
|
3573
|
+
isTerminal: n.isTerminal ?? Fi
|
|
3499
3574
|
}, h = E(() => {
|
|
3500
3575
|
let e = p.current;
|
|
3501
3576
|
e && (p.current = null, r.runFork(ie.interrupt(e)), c((e) => e === "streaming" || e === "reconnecting" ? "idle" : e));
|
|
@@ -3508,13 +3583,13 @@ var Kr = () => {
|
|
|
3508
3583
|
start: E((e = {}) => {
|
|
3509
3584
|
let n = p.current;
|
|
3510
3585
|
n && r.runFork(ie.interrupt(n)), o([]), f(void 0), u(0), c("streaming");
|
|
3511
|
-
let a =
|
|
3586
|
+
let a = K(i, t), s = {
|
|
3512
3587
|
onEvent: (e) => o((t) => [...t, e]),
|
|
3513
3588
|
onStatus: c,
|
|
3514
3589
|
onReconnect: () => u((e) => e + 1),
|
|
3515
3590
|
onError: f
|
|
3516
3591
|
};
|
|
3517
|
-
p.current = r.runFork(
|
|
3592
|
+
p.current = r.runFork(Pi(a, e, s, m));
|
|
3518
3593
|
}, [
|
|
3519
3594
|
r,
|
|
3520
3595
|
i,
|
|
@@ -3526,13 +3601,13 @@ var Kr = () => {
|
|
|
3526
3601
|
]),
|
|
3527
3602
|
cancel: h
|
|
3528
3603
|
};
|
|
3529
|
-
},
|
|
3604
|
+
}, Li = (e, t) => e.order - t.order || (e.stepOrder ?? 0) - (t.stepOrder ?? 0), Ri = (e) => {
|
|
3530
3605
|
for (let t = e.length - 1; t >= 0; --t) {
|
|
3531
3606
|
let n = e[t];
|
|
3532
3607
|
if (n.role === "user" && n.content) return n.content;
|
|
3533
3608
|
}
|
|
3534
|
-
},
|
|
3535
|
-
let { threadId: r } = n, i =
|
|
3609
|
+
}, zi = (e, t, n) => {
|
|
3610
|
+
let { threadId: r } = n, i = q(e, `${t}.messages`, { threadId: r }), a = Er(e, `${t}.send`), o = O(() => [...i.data ?? []].sort(Li), [i.data]), s = E((e, t = {}) => a.run({
|
|
3536
3611
|
threadId: r,
|
|
3537
3612
|
order: i.data?.length ?? 0,
|
|
3538
3613
|
prompt: e,
|
|
@@ -3542,7 +3617,7 @@ var Kr = () => {
|
|
|
3542
3617
|
r,
|
|
3543
3618
|
i.data
|
|
3544
3619
|
]), c = E(() => {
|
|
3545
|
-
let e =
|
|
3620
|
+
let e = Ri(o);
|
|
3546
3621
|
return e === void 0 ? void 0 : s(e);
|
|
3547
3622
|
}, [o, s]);
|
|
3548
3623
|
return O(() => ({
|
|
@@ -3562,8 +3637,8 @@ var Kr = () => {
|
|
|
3562
3637
|
s,
|
|
3563
3638
|
c
|
|
3564
3639
|
]);
|
|
3565
|
-
},
|
|
3566
|
-
let { events: n, status: r, error: i, start: a, cancel: o } =
|
|
3640
|
+
}, Bi = (e, t) => {
|
|
3641
|
+
let { events: n, status: r, error: i, start: a, cancel: o } = Ni(e, t), [s, c] = A([]), l = k(null), u = O(() => n.filter((e) => e._tag === "token").map((e) => e.text ?? "").join(""), [n]);
|
|
3567
3642
|
return D(() => {
|
|
3568
3643
|
if (r !== "done" || l.current === null) return;
|
|
3569
3644
|
let e = l.current;
|
|
@@ -3589,8 +3664,8 @@ var Kr = () => {
|
|
|
3589
3664
|
}, [a]),
|
|
3590
3665
|
cancel: o
|
|
3591
3666
|
};
|
|
3592
|
-
},
|
|
3593
|
-
let n =
|
|
3667
|
+
}, Vi = (e, t) => {
|
|
3668
|
+
let n = Er(e, t), [r, i] = A(void 0), a = E(async (e) => {
|
|
3594
3669
|
let t = await n.run({ question: e });
|
|
3595
3670
|
return i(t), t;
|
|
3596
3671
|
}, [n]), o = E(() => i(void 0), []);
|
|
@@ -3607,14 +3682,14 @@ var Kr = () => {
|
|
|
3607
3682
|
n.error,
|
|
3608
3683
|
o
|
|
3609
3684
|
]);
|
|
3610
|
-
},
|
|
3611
|
-
let { cache: t, runtime: n } =
|
|
3685
|
+
}, Hi = (e) => {
|
|
3686
|
+
let { cache: t, runtime: n } = G(e);
|
|
3612
3687
|
return E(() => {
|
|
3613
3688
|
t.refreshAll(n);
|
|
3614
3689
|
}, [t, n]);
|
|
3615
|
-
},
|
|
3690
|
+
}, Ui = (e) => e?._tag === "Unauthenticated", Wi = (e, t, n = {}) => {
|
|
3616
3691
|
let r = n.cooldownMs ?? 15e3, i = n.maxConsecutive ?? 3, a = n.now ?? (() => Date.now()), o = -Infinity, s = 0, c = e.on((e) => {
|
|
3617
|
-
if (!
|
|
3692
|
+
if (!Ui(e.error) || s >= i) return;
|
|
3618
3693
|
let n = a();
|
|
3619
3694
|
n - o < r || (o = n, s += 1, t());
|
|
3620
3695
|
}), l = e.onSuccess(() => {
|
|
@@ -3628,21 +3703,21 @@ var Kr = () => {
|
|
|
3628
3703
|
s = 0;
|
|
3629
3704
|
}
|
|
3630
3705
|
};
|
|
3631
|
-
},
|
|
3632
|
-
let n =
|
|
3706
|
+
}, Gi = (e, t) => {
|
|
3707
|
+
let n = G(e), r = n.recovery ?? xt(n.errorBus, e), i = k(t);
|
|
3633
3708
|
i.current = t, D(() => r.onVisibleError((e) => i.current(e)), [r]);
|
|
3634
|
-
},
|
|
3635
|
-
let { errorBus: n } =
|
|
3709
|
+
}, Ki = (e, t) => {
|
|
3710
|
+
let { errorBus: n } = G(e), r = k(t);
|
|
3636
3711
|
r.current = t, D(() => n.on((e) => r.current(e)), [n]);
|
|
3637
|
-
},
|
|
3712
|
+
}, qi = {
|
|
3638
3713
|
failed: [],
|
|
3639
3714
|
healthy: !0
|
|
3640
|
-
},
|
|
3641
|
-
let { errorBus: t } =
|
|
3715
|
+
}, Ji = (e) => {
|
|
3716
|
+
let { errorBus: t } = G(e), [n, r] = A(qi);
|
|
3642
3717
|
return D(() => {
|
|
3643
3718
|
let e = /* @__PURE__ */ new Map(), n = () => {
|
|
3644
3719
|
let t = [...e.values()].sort((e, t) => t.at - e.at);
|
|
3645
|
-
r(t.length === 0 ?
|
|
3720
|
+
r(t.length === 0 ? qi : {
|
|
3646
3721
|
failed: t,
|
|
3647
3722
|
healthy: !1
|
|
3648
3723
|
});
|
|
@@ -3660,16 +3735,16 @@ var Kr = () => {
|
|
|
3660
3735
|
i(), a();
|
|
3661
3736
|
};
|
|
3662
3737
|
}, [t]), n;
|
|
3663
|
-
},
|
|
3738
|
+
}, Yi = (e, t) => {
|
|
3664
3739
|
let n = globalThis, r = Symbol.for(`@voltro/web/context:${e}`), i = n[r];
|
|
3665
3740
|
if (i) return i;
|
|
3666
3741
|
let a = w(t);
|
|
3667
3742
|
return n[r] = a, a;
|
|
3668
|
-
},
|
|
3743
|
+
}, Xi = Yi("serverRequest", null), Zi = () => ee(Xi), Qi = ({ value: e, children: t }) => /* @__PURE__ */ ve(Xi.Provider, {
|
|
3669
3744
|
value: e,
|
|
3670
3745
|
children: t
|
|
3671
|
-
}),
|
|
3672
|
-
let t =
|
|
3746
|
+
}), $i = (e) => {
|
|
3747
|
+
let t = Zi();
|
|
3673
3748
|
return O(() => {
|
|
3674
3749
|
if (t !== null) return t.formFlash?.formKey === e ? t.formFlash : void 0;
|
|
3675
3750
|
if (typeof document > "u") return;
|
|
@@ -3681,13 +3756,13 @@ var Kr = () => {
|
|
|
3681
3756
|
return;
|
|
3682
3757
|
}
|
|
3683
3758
|
}, [t, e]);
|
|
3684
|
-
},
|
|
3759
|
+
}, ea = (e, t, n) => e.map((e) => {
|
|
3685
3760
|
let r = String(e[n] ?? ""), i = e[t];
|
|
3686
3761
|
return {
|
|
3687
3762
|
value: r,
|
|
3688
3763
|
label: i == null ? r : String(i)
|
|
3689
3764
|
};
|
|
3690
|
-
}),
|
|
3765
|
+
}), ta = (e, t, n = {}) => {
|
|
3691
3766
|
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
3767
|
D(() => {
|
|
3693
3768
|
if (s === l) return;
|
|
@@ -3698,7 +3773,7 @@ var Kr = () => {
|
|
|
3698
3773
|
l,
|
|
3699
3774
|
r
|
|
3700
3775
|
]);
|
|
3701
|
-
let d = n.skipUntilTerm === !0 && l.trim() === "", f =
|
|
3776
|
+
let d = n.skipUntilTerm === !0 && l.trim() === "", f = q(e, t, O(() => o(l), [o, l]), { skip: d }), p = O(() => ea(f.data ?? [], i, a), [
|
|
3702
3777
|
f.data,
|
|
3703
3778
|
i,
|
|
3704
3779
|
a
|
|
@@ -3709,8 +3784,8 @@ var Kr = () => {
|
|
|
3709
3784
|
term: s,
|
|
3710
3785
|
search: m
|
|
3711
3786
|
};
|
|
3712
|
-
},
|
|
3713
|
-
let i =
|
|
3787
|
+
}, na = (e, t) => e === t ? 0 : e == null ? 1 : t == null || e < t ? -1 : 1, ra = (t, n, r = {}) => {
|
|
3788
|
+
let i = G(t), [a, o] = A(r.pageSize), s = q(t, n, O(() => a === void 0 ? r.input ?? {} : {
|
|
3714
3789
|
...r.input,
|
|
3715
3790
|
limit: a
|
|
3716
3791
|
}, [r.input, a])), c = i.descriptors[n]?.output, l = E(() => {
|
|
@@ -3730,7 +3805,7 @@ var Kr = () => {
|
|
|
3730
3805
|
let e = s.data ?? [];
|
|
3731
3806
|
if (d === void 0) return e;
|
|
3732
3807
|
let t = d.direction === "asc" ? 1 : -1;
|
|
3733
|
-
return [...e].sort((e, n) =>
|
|
3808
|
+
return [...e].sort((e, n) => na(e[d.column], n[d.column]) * t);
|
|
3734
3809
|
}, [s.data, d]),
|
|
3735
3810
|
loading: s.data === void 0,
|
|
3736
3811
|
error: s.error,
|
|
@@ -3739,14 +3814,14 @@ var Kr = () => {
|
|
|
3739
3814
|
loadMore: l,
|
|
3740
3815
|
hasMore: a !== void 0 && (s.data?.length ?? 0) >= a
|
|
3741
3816
|
};
|
|
3742
|
-
},
|
|
3817
|
+
}, ia = (e, t, n, r) => {
|
|
3743
3818
|
let i = e.replace(/\/$/, ""), a = new URLSearchParams({
|
|
3744
3819
|
table: t,
|
|
3745
3820
|
id: n
|
|
3746
3821
|
});
|
|
3747
3822
|
return r !== void 0 && a.set("column", r), `${i}/_voltro/inspect/provenance?${a.toString()}`;
|
|
3748
|
-
},
|
|
3749
|
-
let { inspectBaseUrl: i } =
|
|
3823
|
+
}, aa = ia, oa = (e, t, n, r) => {
|
|
3824
|
+
let { inspectBaseUrl: i } = G(e), [a, o] = A({
|
|
3750
3825
|
data: void 0,
|
|
3751
3826
|
loading: !0,
|
|
3752
3827
|
error: void 0
|
|
@@ -3758,7 +3833,7 @@ var Kr = () => {
|
|
|
3758
3833
|
loading: !0,
|
|
3759
3834
|
error: void 0
|
|
3760
3835
|
});
|
|
3761
|
-
let a =
|
|
3836
|
+
let a = ia(i ?? "", t, n, r);
|
|
3762
3837
|
return fetch(a).then(async (e) => {
|
|
3763
3838
|
if (!e.ok) throw Error(`provenance fetch failed: HTTP ${e.status}`);
|
|
3764
3839
|
return await e.json();
|
|
@@ -3784,12 +3859,12 @@ var Kr = () => {
|
|
|
3784
3859
|
n,
|
|
3785
3860
|
r
|
|
3786
3861
|
]), a;
|
|
3787
|
-
},
|
|
3788
|
-
function
|
|
3789
|
-
return T(
|
|
3862
|
+
}, sa = "admin:full", ca = (e, t) => e.includes("admin:full") ? !0 : (typeof t == "string" ? [t] : t).every((t) => e.includes(t)), la = (e, t) => t.length === 0 || e.includes("admin:full") ? !0 : t.some((t) => e.includes(t)), ua = w({ scopes: [] });
|
|
3863
|
+
function da(e) {
|
|
3864
|
+
return T(ua.Provider, { value: { scopes: e.scopes } }, e.children);
|
|
3790
3865
|
}
|
|
3791
|
-
var
|
|
3792
|
-
let { inspectBaseUrl: t } =
|
|
3866
|
+
var fa = () => ee(ua), pa = (e) => ca(fa().scopes, e), ma = (e) => la(fa().scopes, e), ha = (e) => `${e.replace(/\/$/, "")}/_voltro/inspect/manifest`, ga = (e) => {
|
|
3867
|
+
let { inspectBaseUrl: t } = G(e), [n, r] = A({
|
|
3793
3868
|
manifest: void 0,
|
|
3794
3869
|
loading: !0,
|
|
3795
3870
|
error: void 0
|
|
@@ -3800,7 +3875,7 @@ var Qi = () => ee(Xi), $i = (e) => Ji(Qi().scopes, e), ea = (e) => Yi(Qi().scope
|
|
|
3800
3875
|
manifest: void 0,
|
|
3801
3876
|
loading: !0,
|
|
3802
3877
|
error: void 0
|
|
3803
|
-
}), fetch(
|
|
3878
|
+
}), fetch(ha(t ?? "")).then(async (e) => {
|
|
3804
3879
|
if (!e.ok) throw Error(`manifest fetch failed: HTTP ${e.status}`);
|
|
3805
3880
|
return await e.json();
|
|
3806
3881
|
}).then((t) => {
|
|
@@ -3819,7 +3894,7 @@ var Qi = () => ee(Xi), $i = (e) => Ji(Qi().scopes, e), ea = (e) => Yi(Qi().scope
|
|
|
3819
3894
|
e = !0;
|
|
3820
3895
|
};
|
|
3821
3896
|
}, [e, t]), n;
|
|
3822
|
-
},
|
|
3897
|
+
}, _a = (e, t) => t.scope.length === 0 || (t.mode === "any" ? t.scope.some((t) => e.includes(t)) : t.scope.every((t) => e.includes(t))), va = (e, t) => {
|
|
3823
3898
|
if (e === void 0) return "unknown";
|
|
3824
3899
|
if (t.includes("admin:full") || e.length === 0) return "allowed";
|
|
3825
3900
|
let n = !1;
|
|
@@ -3828,7 +3903,7 @@ var Qi = () => ee(Xi), $i = (e) => Ji(Qi().scopes, e), ea = (e) => Yi(Qi().scope
|
|
|
3828
3903
|
n = !0;
|
|
3829
3904
|
continue;
|
|
3830
3905
|
}
|
|
3831
|
-
if (!
|
|
3906
|
+
if (!_a(t, r)) {
|
|
3832
3907
|
if (r.resourceScoped) {
|
|
3833
3908
|
n = !0;
|
|
3834
3909
|
continue;
|
|
@@ -3837,13 +3912,13 @@ var Qi = () => ee(Xi), $i = (e) => Ji(Qi().scopes, e), ea = (e) => Yi(Qi().scope
|
|
|
3837
3912
|
}
|
|
3838
3913
|
}
|
|
3839
3914
|
return n ? "unknown" : "allowed";
|
|
3840
|
-
},
|
|
3915
|
+
}, ya = (e) => (e ?? []).flatMap((e) => e.kind === "scope" ? [...e.scope] : []), ba = (e) => {
|
|
3841
3916
|
for (let t of e ?? []) if (t.kind === "open") return t.reason;
|
|
3842
|
-
},
|
|
3917
|
+
}, xa = (e) => va(e, fa().scopes), Sa = (e, t) => Array.isArray(e) ? e.includes(t) : e === t, Ca = (e, t, n) => e.targets?.some((e) => e.table === t && e.op === n) ?? !1, wa = (e) => e === void 0 ? {} : {
|
|
3843
3918
|
tag: e.tag,
|
|
3844
3919
|
...e.guards === void 0 ? {} : { guards: e.guards }
|
|
3845
|
-
},
|
|
3846
|
-
let n = e.procedures.find((e) => e.kind === "query" &&
|
|
3920
|
+
}, Ta = (e) => e.tables.filter((e) => !e.framework).map((t) => {
|
|
3921
|
+
let n = e.procedures.find((e) => e.kind === "query" && Sa(e.source, t.name)), r = e.procedures.find((e) => e.kind === "mutation" && Ca(e, t.name, "insert")), i = e.procedures.find((e) => e.kind === "mutation" && Ca(e, t.name, "update")), a = e.procedures.find((e) => e.kind === "mutation" && Ca(e, t.name, "delete")), o = t.pkColumn ?? (t.columns.some((e) => e.name === "id") ? "id" : void 0);
|
|
3847
3922
|
return {
|
|
3848
3923
|
table: t.name,
|
|
3849
3924
|
columns: t.columns.filter((e) => e.serverOnly !== !0),
|
|
@@ -3852,12 +3927,12 @@ var Qi = () => ee(Xi), $i = (e) => Ji(Qi().scopes, e), ea = (e) => Yi(Qi().scope
|
|
|
3852
3927
|
reactive: t.reactive,
|
|
3853
3928
|
...o === void 0 ? {} : { pkColumn: o },
|
|
3854
3929
|
editable: (t.editable ?? !0) && o !== void 0,
|
|
3855
|
-
list:
|
|
3856
|
-
create:
|
|
3857
|
-
update:
|
|
3858
|
-
delete:
|
|
3930
|
+
list: wa(n),
|
|
3931
|
+
create: wa(r),
|
|
3932
|
+
update: wa(i),
|
|
3933
|
+
delete: wa(a)
|
|
3859
3934
|
};
|
|
3860
|
-
}),
|
|
3935
|
+
}), Ea = (e) => {
|
|
3861
3936
|
let [t, n] = A([]), [r, i] = A([]), a = E((e) => {
|
|
3862
3937
|
n((t) => [...t, e]), i([]);
|
|
3863
3938
|
}, []), o = E(async () => {
|
|
@@ -3885,8 +3960,8 @@ var Qi = () => ee(Xi), $i = (e) => Ji(Qi().scopes, e), ea = (e) => Yi(Qi().scope
|
|
|
3885
3960
|
o,
|
|
3886
3961
|
s
|
|
3887
3962
|
]);
|
|
3888
|
-
},
|
|
3889
|
-
let n = t?.limit, { data: r } =
|
|
3963
|
+
}, Da = "__voltro.undo.log", Oa = "__voltro.undo.apply", ka = "__voltro.undo.redo", Aa = (e, t) => {
|
|
3964
|
+
let n = t?.limit, { data: r } = q(e, Da, n === void 0 ? {} : { limit: n }), i = xr(e, Oa), a = xr(e, ka), o = r ?? [], s = o.find((e) => !e.undone && !e.crossesAction), c = o.find((e) => e.undone), l = E(async (e) => {
|
|
3890
3965
|
await i.mutate({ invocationId: e });
|
|
3891
3966
|
}, [i]), u = E(async (e) => {
|
|
3892
3967
|
await a.mutate({ invocationId: e });
|
|
@@ -3905,21 +3980,21 @@ var Qi = () => ee(Xi), $i = (e) => Ji(Qi().scopes, e), ea = (e) => Yi(Qi().scope
|
|
|
3905
3980
|
undoLast: d,
|
|
3906
3981
|
redoLast: f
|
|
3907
3982
|
};
|
|
3908
|
-
},
|
|
3983
|
+
}, ja = (e, t) => ({
|
|
3909
3984
|
name: e,
|
|
3910
3985
|
map: t
|
|
3911
|
-
}),
|
|
3986
|
+
}), Ma = (e, t) => e === void 0 ? null : typeof e == "string" ? { event: e } : e(t), Na = /* @__PURE__ */ new Set(["onMount", "onUnmount"]), Pa = (e, t, n) => {
|
|
3912
3987
|
let r = { ...t };
|
|
3913
3988
|
for (let [i, a] of Object.entries(e.map)) {
|
|
3914
|
-
if (
|
|
3989
|
+
if (Na.has(i) || a === void 0) continue;
|
|
3915
3990
|
let e = t[i];
|
|
3916
3991
|
r[i] = (...r) => {
|
|
3917
|
-
let i =
|
|
3992
|
+
let i = Ma(a, t);
|
|
3918
3993
|
if (i !== null && n(i), typeof e == "function") return e(...r);
|
|
3919
3994
|
};
|
|
3920
3995
|
}
|
|
3921
3996
|
return r;
|
|
3922
|
-
},
|
|
3997
|
+
}, Fa = (e, t, n) => {
|
|
3923
3998
|
let r = k({
|
|
3924
3999
|
spec: e,
|
|
3925
4000
|
props: t,
|
|
@@ -3930,46 +4005,46 @@ var Qi = () => ee(Xi), $i = (e) => Ji(Qi().scopes, e), ea = (e) => Yi(Qi().scope
|
|
|
3930
4005
|
props: t,
|
|
3931
4006
|
sink: n
|
|
3932
4007
|
}, D(() => {
|
|
3933
|
-
let e = r.current, t =
|
|
4008
|
+
let e = r.current, t = Ma(e.spec.map.onMount, e.props);
|
|
3934
4009
|
return t !== null && e.sink(t), () => {
|
|
3935
|
-
let e = r.current, t =
|
|
4010
|
+
let e = r.current, t = Ma(e.spec.map.onUnmount, e.props);
|
|
3936
4011
|
t !== null && e.sink(t);
|
|
3937
4012
|
};
|
|
3938
|
-
}, []), O(() =>
|
|
4013
|
+
}, []), O(() => Pa(e, t, n), [
|
|
3939
4014
|
e,
|
|
3940
4015
|
t,
|
|
3941
4016
|
n
|
|
3942
4017
|
]);
|
|
3943
|
-
},
|
|
3944
|
-
let n =
|
|
4018
|
+
}, Ia = (e, t) => {
|
|
4019
|
+
let n = G(e).descriptors[t]?.input;
|
|
3945
4020
|
return O(() => n === void 0 ? [] : x(n), [n]);
|
|
3946
|
-
},
|
|
3947
|
-
let r =
|
|
4021
|
+
}, La = (t, n) => {
|
|
4022
|
+
let r = G(t).descriptors[n]?.output;
|
|
3948
4023
|
return O(() => r === void 0 ? [] : e(r), [r]);
|
|
3949
|
-
},
|
|
4024
|
+
}, Ra = (e, t) => {
|
|
3950
4025
|
if (e === t) return !0;
|
|
3951
4026
|
if (e.length !== t.length) return !1;
|
|
3952
4027
|
for (let n = 0; n < e.length; n += 1) if (!Object.is(e[n], t[n])) return !1;
|
|
3953
4028
|
return !0;
|
|
3954
|
-
},
|
|
3955
|
-
let n = k(null), r =
|
|
3956
|
-
return (n.current === null || !
|
|
4029
|
+
}, za = (e) => Object.keys(e).sort().map((t) => e[t]), Ba = (e, t) => {
|
|
4030
|
+
let n = k(null), r = za(e);
|
|
4031
|
+
return (n.current === null || !Ra(n.current.key, r)) && (n.current = {
|
|
3957
4032
|
key: r,
|
|
3958
4033
|
value: t(e)
|
|
3959
4034
|
}), n.current.value;
|
|
3960
|
-
},
|
|
3961
|
-
let i =
|
|
4035
|
+
}, Va = (e, t, n, r = {}) => {
|
|
4036
|
+
let i = q(e, t, { ...n }, r);
|
|
3962
4037
|
return O(() => ({
|
|
3963
4038
|
allowed: i.data?.allowed === !0,
|
|
3964
4039
|
pending: i.data === void 0
|
|
3965
4040
|
}), [i.data]);
|
|
3966
|
-
},
|
|
3967
|
-
let i =
|
|
4041
|
+
}, Ha = (e, t, n, r = {}) => {
|
|
4042
|
+
let i = q(e, t, { ...n }, r);
|
|
3968
4043
|
return O(() => ({
|
|
3969
4044
|
allowedIds: new Set(i.data?.allowedIds ?? []),
|
|
3970
4045
|
pending: i.data === void 0
|
|
3971
4046
|
}), [i.data]);
|
|
3972
|
-
},
|
|
4047
|
+
}, Ua = (e) => {
|
|
3973
4048
|
switch (e) {
|
|
3974
4049
|
case "select":
|
|
3975
4050
|
case "radio":
|
|
@@ -3985,26 +4060,26 @@ var Qi = () => ee(Xi), $i = (e) => Ji(Qi().scopes, e), ea = (e) => Yi(Qi().scope
|
|
|
3985
4060
|
case "switch": return "boolean";
|
|
3986
4061
|
default: return null;
|
|
3987
4062
|
}
|
|
3988
|
-
},
|
|
4063
|
+
}, Wa = (e) => x(e).map((e) => {
|
|
3989
4064
|
if (e.name.includes(".")) return null;
|
|
3990
|
-
let t =
|
|
4065
|
+
let t = Ua(e.widget);
|
|
3991
4066
|
return t === null ? null : {
|
|
3992
4067
|
name: e.name,
|
|
3993
4068
|
label: e.label,
|
|
3994
4069
|
kind: t,
|
|
3995
4070
|
...e.options ? { options: e.options } : {}
|
|
3996
4071
|
};
|
|
3997
|
-
}).filter((e) => e !== null),
|
|
4072
|
+
}).filter((e) => e !== null), Ga = (e) => {
|
|
3998
4073
|
let t = {};
|
|
3999
4074
|
for (let [n, r] of Object.entries(e)) r === void 0 || r === "" || Array.isArray(r) && r.length === 0 || (t[n] = r);
|
|
4000
4075
|
return t;
|
|
4001
|
-
},
|
|
4002
|
-
let r =
|
|
4003
|
-
o((n) =>
|
|
4076
|
+
}, Ka = (e, t, n = {}) => {
|
|
4077
|
+
let r = G(e).descriptors[t]?.input, i = O(() => r === void 0 ? [] : Wa(r), [r]), [a, o] = A(n.initial ?? {}), s = E((e, t) => {
|
|
4078
|
+
o((n) => Ga({
|
|
4004
4079
|
...n,
|
|
4005
4080
|
[e]: t
|
|
4006
4081
|
}));
|
|
4007
|
-
}, []), c = E(() => o({}), []), l =
|
|
4082
|
+
}, []), c = E(() => o({}), []), l = q(e, t, O(() => Ga(a), [a]));
|
|
4008
4083
|
return {
|
|
4009
4084
|
filters: i,
|
|
4010
4085
|
values: a,
|
|
@@ -4015,20 +4090,20 @@ var Qi = () => ee(Xi), $i = (e) => Ji(Qi().scopes, e), ea = (e) => Yi(Qi().scope
|
|
|
4015
4090
|
loading: l.data === void 0,
|
|
4016
4091
|
error: l.error
|
|
4017
4092
|
};
|
|
4018
|
-
},
|
|
4019
|
-
let r =
|
|
4093
|
+
}, qa = (e, t, n = {}) => {
|
|
4094
|
+
let r = q(e, t, n), i = r.data;
|
|
4020
4095
|
return {
|
|
4021
4096
|
record: Array.isArray(i) ? i[0] : i,
|
|
4022
4097
|
loading: i === void 0,
|
|
4023
4098
|
error: r.error
|
|
4024
4099
|
};
|
|
4025
|
-
},
|
|
4100
|
+
}, Ja = (e, t = 300) => {
|
|
4026
4101
|
let [n, r] = A(e);
|
|
4027
4102
|
return D(() => {
|
|
4028
4103
|
let n = setTimeout(() => r(e), t);
|
|
4029
4104
|
return () => clearTimeout(n);
|
|
4030
4105
|
}, [e, t]), n;
|
|
4031
|
-
},
|
|
4106
|
+
}, Ya = (e) => {
|
|
4032
4107
|
let { value: t, debouncedValue: n, data: r, interpret: i, skipEmpty: a = !0 } = e;
|
|
4033
4108
|
if (a && t.trim() === "") return {
|
|
4034
4109
|
status: "idle",
|
|
@@ -4046,39 +4121,39 @@ var Qi = () => ee(Xi), $i = (e) => Ji(Qi().scopes, e), ea = (e) => Yi(Qi().scope
|
|
|
4046
4121
|
valid: o.valid,
|
|
4047
4122
|
message: o.message
|
|
4048
4123
|
};
|
|
4049
|
-
},
|
|
4050
|
-
let { input: i, interpret: a, debounceMs: o = 300, skipEmpty: s = !0 } = r, c =
|
|
4051
|
-
return
|
|
4124
|
+
}, Xa = (e, t, n, r) => {
|
|
4125
|
+
let { input: i, interpret: a, debounceMs: o = 300, skipEmpty: s = !0 } = r, c = Ja(n, o), l = s && c.trim() === "", u = q(e, t, O(() => i ? i(c) : { value: c }, [i, c]), { skip: l });
|
|
4126
|
+
return Ya({
|
|
4052
4127
|
value: n,
|
|
4053
4128
|
debouncedValue: c,
|
|
4054
4129
|
data: l ? null : u.data,
|
|
4055
4130
|
interpret: a,
|
|
4056
4131
|
skipEmpty: s
|
|
4057
4132
|
});
|
|
4058
|
-
},
|
|
4133
|
+
}, Za = (e, t) => ({
|
|
4059
4134
|
name: e,
|
|
4060
4135
|
payload: t
|
|
4061
|
-
}),
|
|
4062
|
-
let n =
|
|
4136
|
+
}), Qa = (e, t) => {
|
|
4137
|
+
let n = se.decodeUnknownEither(e.payload, { errors: "all" })(t);
|
|
4063
4138
|
if (n._tag === "Right") return {
|
|
4064
4139
|
valid: !0,
|
|
4065
4140
|
errors: {}
|
|
4066
4141
|
};
|
|
4067
4142
|
let r = {};
|
|
4068
|
-
for (let e of
|
|
4143
|
+
for (let e of xe.formatErrorSync(n.left)) r[e.path.join(".") || "(root)"] = e.message;
|
|
4069
4144
|
return {
|
|
4070
4145
|
valid: !1,
|
|
4071
4146
|
errors: r
|
|
4072
4147
|
};
|
|
4073
|
-
},
|
|
4148
|
+
}, $a = (e) => {
|
|
4074
4149
|
let t = new Map(e.map((e) => [e.name, e]));
|
|
4075
4150
|
return {
|
|
4076
4151
|
names: [...t.keys()].sort(),
|
|
4077
4152
|
get: (e) => t.get(e),
|
|
4078
4153
|
events: e
|
|
4079
4154
|
};
|
|
4080
|
-
},
|
|
4081
|
-
let n =
|
|
4155
|
+
}, eo = (e, t) => {
|
|
4156
|
+
let n = $a(e);
|
|
4082
4157
|
return {
|
|
4083
4158
|
track: (e, r) => {
|
|
4084
4159
|
let i = n.get(e);
|
|
@@ -4087,7 +4162,7 @@ var Qi = () => ee(Xi), $i = (e) => Ji(Qi().scopes, e), ea = (e) => Yi(Qi().scope
|
|
|
4087
4162
|
return;
|
|
4088
4163
|
}
|
|
4089
4164
|
if (process.env.NODE_ENV !== "production") {
|
|
4090
|
-
let t =
|
|
4165
|
+
let t = Qa(i, r);
|
|
4091
4166
|
t.valid || console.error(`[@voltro/client] analytics.track('${e}'): payload failed its schema`, t.errors);
|
|
4092
4167
|
}
|
|
4093
4168
|
t({
|
|
@@ -4098,47 +4173,47 @@ var Qi = () => ee(Xi), $i = (e) => Ji(Qi().scopes, e), ea = (e) => Yi(Qi().scope
|
|
|
4098
4173
|
names: n.names,
|
|
4099
4174
|
catalog: n
|
|
4100
4175
|
};
|
|
4101
|
-
},
|
|
4102
|
-
let n =
|
|
4176
|
+
}, to = (e, t) => {
|
|
4177
|
+
let n = Er(e, t);
|
|
4103
4178
|
return {
|
|
4104
4179
|
preview: E((e) => n.run(e), [n]),
|
|
4105
4180
|
diff: n.lastResult,
|
|
4106
4181
|
pending: n.pending,
|
|
4107
4182
|
error: n.error
|
|
4108
4183
|
};
|
|
4109
|
-
},
|
|
4184
|
+
}, no = (e, t, n, r) => [...e, {
|
|
4110
4185
|
id: t,
|
|
4111
4186
|
tag: n,
|
|
4112
4187
|
input: r,
|
|
4113
4188
|
status: "pending",
|
|
4114
4189
|
attempts: 0
|
|
4115
|
-
}],
|
|
4190
|
+
}], ro = (e, t, n) => e.map((e) => e.id === t ? {
|
|
4116
4191
|
...e,
|
|
4117
4192
|
...n
|
|
4118
|
-
} : e),
|
|
4193
|
+
} : e), io = (e, t) => ro(e, t, { status: "sent" }), ao = (e, t, n) => e.map((e) => e.id === t ? {
|
|
4119
4194
|
...e,
|
|
4120
4195
|
status: "failed",
|
|
4121
4196
|
error: n,
|
|
4122
4197
|
attempts: e.attempts + 1
|
|
4123
|
-
} : e),
|
|
4198
|
+
} : e), oo = (e, t, n) => ro(e, t, {
|
|
4124
4199
|
status: "conflict",
|
|
4125
4200
|
error: n
|
|
4126
|
-
}),
|
|
4201
|
+
}), so = (e, t, n) => e.map((e) => e.id === t && e.status === "conflict" ? {
|
|
4127
4202
|
...e,
|
|
4128
4203
|
input: n,
|
|
4129
4204
|
status: "pending",
|
|
4130
4205
|
error: void 0
|
|
4131
|
-
} : e),
|
|
4206
|
+
} : e), co = (e) => e.filter((e) => e.status !== "sent"), lo = (e) => {
|
|
4132
4207
|
let t = [];
|
|
4133
4208
|
for (let n of e) {
|
|
4134
4209
|
if (n.status === "conflict") break;
|
|
4135
4210
|
(n.status === "pending" || n.status === "failed") && t.push(n);
|
|
4136
4211
|
}
|
|
4137
4212
|
return t;
|
|
4138
|
-
},
|
|
4213
|
+
}, uo = (e) => {
|
|
4139
4214
|
let t = e;
|
|
4140
4215
|
return t?.conflict === !0 || t?._tag === "UndoBoundaryError" && t?.boundary === "conflict";
|
|
4141
|
-
},
|
|
4216
|
+
}, fo = (e) => {
|
|
4142
4217
|
let [t, n] = A(e ?? (typeof navigator < "u" ? navigator.onLine : !0));
|
|
4143
4218
|
return D(() => {
|
|
4144
4219
|
if (e !== void 0) {
|
|
@@ -4151,8 +4226,8 @@ var Qi = () => ee(Xi), $i = (e) => Ji(Qi().scopes, e), ea = (e) => Yi(Qi().scope
|
|
|
4151
4226
|
window.removeEventListener("online", t), window.removeEventListener("offline", r);
|
|
4152
4227
|
};
|
|
4153
4228
|
}, [e]), t;
|
|
4154
|
-
},
|
|
4155
|
-
let { send: t, persistence: n, isConflict: r =
|
|
4229
|
+
}, po = (e) => {
|
|
4230
|
+
let { send: t, persistence: n, isConflict: r = uo, idFor: i } = e, [a, o] = A([]), [s, c] = A(0), l = fo(e.online), u = k([]), d = E((e) => {
|
|
4156
4231
|
let t = e(u.current);
|
|
4157
4232
|
u.current = t, o(t);
|
|
4158
4233
|
}, []), f = k(t);
|
|
@@ -4175,7 +4250,7 @@ var Qi = () => ee(Xi), $i = (e) => Ji(Qi().scopes, e), ea = (e) => Yi(Qi().scope
|
|
|
4175
4250
|
e = !0;
|
|
4176
4251
|
};
|
|
4177
4252
|
}, [n, d]), D(() => {
|
|
4178
|
-
n
|
|
4253
|
+
n !== void 0 && y.current && n.save(co(a)).catch(() => {});
|
|
4179
4254
|
}, [
|
|
4180
4255
|
n,
|
|
4181
4256
|
a,
|
|
@@ -4183,21 +4258,21 @@ var Qi = () => ee(Xi), $i = (e) => Ji(Qi().scopes, e), ea = (e) => Yi(Qi().scope
|
|
|
4183
4258
|
]);
|
|
4184
4259
|
let b = E((e, t) => {
|
|
4185
4260
|
let n = i?.() ?? `obx_${v.current}_${_.current++}_${e}`;
|
|
4186
|
-
d((r) =>
|
|
4261
|
+
d((r) => no(r, n, e, t)), c((e) => e + 1);
|
|
4187
4262
|
}, [i, d]), x = E(() => {
|
|
4188
4263
|
if (!y.current || !g.current) return Promise.resolve();
|
|
4189
4264
|
if (m.current !== void 0) return m.current;
|
|
4190
4265
|
h.current = !1;
|
|
4191
4266
|
let e = Promise.resolve().then(async () => {
|
|
4192
4267
|
for (; g.current;) {
|
|
4193
|
-
let e =
|
|
4268
|
+
let e = lo(u.current)[0];
|
|
4194
4269
|
if (e === void 0) break;
|
|
4195
4270
|
try {
|
|
4196
4271
|
if (await f.current(e), !g.current) break;
|
|
4197
|
-
d((t) =>
|
|
4272
|
+
d((t) => io(t, e.id));
|
|
4198
4273
|
} catch (t) {
|
|
4199
4274
|
if (!g.current) break;
|
|
4200
|
-
d((n) => p.current(t) ?
|
|
4275
|
+
d((n) => p.current(t) ? oo(n, e.id, t) : ao(n, e.id, t)), h.current = !0;
|
|
4201
4276
|
break;
|
|
4202
4277
|
}
|
|
4203
4278
|
}
|
|
@@ -4216,7 +4291,7 @@ var Qi = () => ee(Xi), $i = (e) => Ji(Qi().scopes, e), ea = (e) => Yi(Qi().scope
|
|
|
4216
4291
|
x
|
|
4217
4292
|
]);
|
|
4218
4293
|
let S = E((e, t) => {
|
|
4219
|
-
d((n) =>
|
|
4294
|
+
d((n) => so(n, e, t)), l && x();
|
|
4220
4295
|
}, [
|
|
4221
4296
|
l,
|
|
4222
4297
|
x,
|
|
@@ -4231,7 +4306,7 @@ var Qi = () => ee(Xi), $i = (e) => Ji(Qi().scopes, e), ea = (e) => Yi(Qi().scope
|
|
|
4231
4306
|
conflicts: a.filter((e) => e.status === "conflict"),
|
|
4232
4307
|
resolveConflict: S
|
|
4233
4308
|
};
|
|
4234
|
-
},
|
|
4309
|
+
}, mo = (e) => {
|
|
4235
4310
|
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
4311
|
return {
|
|
4237
4312
|
startIndex: l,
|
|
@@ -4241,8 +4316,8 @@ var Qi = () => ee(Xi), $i = (e) => Ji(Qi().scopes, e), ea = (e) => Yi(Qi().scope
|
|
|
4241
4316
|
topSpacer: l * r,
|
|
4242
4317
|
bottomSpacer: a === void 0 ? 0 : Math.max(0, (a - d) * r)
|
|
4243
4318
|
};
|
|
4244
|
-
},
|
|
4245
|
-
let { rowHeight: r, viewportHeight: i, overscan: a, total: o, input: s } = n, [c, l] = A(0), u = O(() =>
|
|
4319
|
+
}, ho = (e, t, n) => {
|
|
4320
|
+
let { rowHeight: r, viewportHeight: i, overscan: a, total: o, input: s } = n, [c, l] = A(0), u = O(() => mo({
|
|
4246
4321
|
scrollTop: c,
|
|
4247
4322
|
viewportHeight: i,
|
|
4248
4323
|
rowHeight: r,
|
|
@@ -4254,7 +4329,7 @@ var Qi = () => ee(Xi), $i = (e) => Ji(Qi().scopes, e), ea = (e) => Yi(Qi().scope
|
|
|
4254
4329
|
r,
|
|
4255
4330
|
a,
|
|
4256
4331
|
o
|
|
4257
|
-
]), d =
|
|
4332
|
+
]), d = q(e, t, O(() => ({
|
|
4258
4333
|
...s,
|
|
4259
4334
|
offset: u.offset,
|
|
4260
4335
|
limit: u.limit
|
|
@@ -4274,21 +4349,13 @@ var Qi = () => ee(Xi), $i = (e) => Ji(Qi().scopes, e), ea = (e) => Yi(Qi().scope
|
|
|
4274
4349
|
loading: d.data === void 0,
|
|
4275
4350
|
error: d.error
|
|
4276
4351
|
};
|
|
4277
|
-
},
|
|
4278
|
-
|
|
4279
|
-
|
|
4280
|
-
|
|
4281
|
-
let e = () => {
|
|
4282
|
-
a(!0);
|
|
4283
|
-
}, t = () => a(!1);
|
|
4284
|
-
return window.addEventListener("online", e), window.addEventListener("offline", t), () => {
|
|
4285
|
-
window.removeEventListener("online", e), window.removeEventListener("offline", t);
|
|
4286
|
-
};
|
|
4287
|
-
}, []);
|
|
4288
|
-
let o = E(() => n.reportExternalSuccess(), [n]), s = i ? r.status : "offline";
|
|
4352
|
+
}, go = () => typeof navigator > "u" || navigator.onLine, _o = () => !0, vo = (e) => typeof window > "u" ? () => {} : (window.addEventListener("online", e), window.addEventListener("offline", e), () => {
|
|
4353
|
+
window.removeEventListener("online", e), window.removeEventListener("offline", e);
|
|
4354
|
+
}), yo = (e) => {
|
|
4355
|
+
let t = G(e), n = t.recovery ?? xt(t.errorBus, e), r = j(n.subscribe, n.getSnapshot, n.getServerSnapshot ?? (() => vt)), i = j(vo, go, _o), a = E(() => n.reportExternalSuccess(), [n]), o = i ? r.status : "offline";
|
|
4289
4356
|
return D(() => {
|
|
4290
|
-
|
|
4291
|
-
status:
|
|
4357
|
+
H(e, "connection.status", {
|
|
4358
|
+
status: o,
|
|
4292
4359
|
rawTransport: r.rawTransport,
|
|
4293
4360
|
online: i,
|
|
4294
4361
|
failureCount: r.failureCount,
|
|
@@ -4298,11 +4365,11 @@ var Qi = () => ee(Xi), $i = (e) => Ji(Qi().scopes, e), ea = (e) => Yi(Qi().scope
|
|
|
4298
4365
|
});
|
|
4299
4366
|
}, [
|
|
4300
4367
|
e,
|
|
4301
|
-
|
|
4368
|
+
o,
|
|
4302
4369
|
i,
|
|
4303
4370
|
r
|
|
4304
4371
|
]), {
|
|
4305
|
-
status:
|
|
4372
|
+
status: o,
|
|
4306
4373
|
rawTransport: r.rawTransport,
|
|
4307
4374
|
online: i,
|
|
4308
4375
|
failureCount: r.failureCount,
|
|
@@ -4310,9 +4377,9 @@ var Qi = () => ee(Xi), $i = (e) => Ji(Qi().scopes, e), ea = (e) => Yi(Qi().scope
|
|
|
4310
4377
|
failedSubscriptions: r.failedSubscriptions,
|
|
4311
4378
|
pendingMutationReplays: r.pendingMutationReplays,
|
|
4312
4379
|
mutationReplay: r.mutationReplay,
|
|
4313
|
-
reportSuccess:
|
|
4380
|
+
reportSuccess: a
|
|
4314
4381
|
};
|
|
4315
|
-
},
|
|
4382
|
+
}, bo = "__voltro.connections.list", xo = "__voltro.connections.start", So = "__voltro.connections.submitToken", Co = "__voltro.connections.disconnect", wo = {
|
|
4316
4383
|
connectionId: "",
|
|
4317
4384
|
kind: "oauth2",
|
|
4318
4385
|
label: "",
|
|
@@ -4323,14 +4390,14 @@ var Qi = () => ee(Xi), $i = (e) => Ji(Qi().scopes, e), ea = (e) => Yi(Qi().scope
|
|
|
4323
4390
|
expiresAt: null,
|
|
4324
4391
|
lastError: null,
|
|
4325
4392
|
connectedAt: null
|
|
4326
|
-
},
|
|
4393
|
+
}, To = (e, t) => {
|
|
4327
4394
|
if (t === "redirect") {
|
|
4328
4395
|
globalThis.location.assign(e);
|
|
4329
4396
|
return;
|
|
4330
4397
|
}
|
|
4331
4398
|
globalThis.open(e, "voltro-connect", "width=620,height=760,menubar=no,toolbar=no") === null && globalThis.location.assign(e);
|
|
4332
|
-
},
|
|
4333
|
-
let { data: t } =
|
|
4399
|
+
}, Eo = (e) => {
|
|
4400
|
+
let { data: t } = q(e, bo, {}), n = Er(e, xo), r = xr(e, So), i = xr(e, Co), a = t ?? [], o = n.pending || r.pending || i.pending, s = E((e) => ({
|
|
4334
4401
|
...e,
|
|
4335
4402
|
connected: e.status === "connected",
|
|
4336
4403
|
needsAttention: e.status === "expired" || e.status === "revoked" || e.status === "error",
|
|
@@ -4338,7 +4405,7 @@ var Qi = () => ee(Xi), $i = (e) => Ji(Qi().scopes, e), ea = (e) => Yi(Qi().scope
|
|
|
4338
4405
|
connect: async (t) => {
|
|
4339
4406
|
if (e.kind !== "oauth2") throw Error(`connection "${e.connectionId}" is a personal-access-token connection — call submitToken(token), not connect().`);
|
|
4340
4407
|
let r = t?.redirectTo ?? `${globalThis.location.pathname}${globalThis.location.search}`;
|
|
4341
|
-
|
|
4408
|
+
To((await n.run({
|
|
4342
4409
|
connectionId: e.connectionId,
|
|
4343
4410
|
redirectTo: r
|
|
4344
4411
|
})).authorizeUrl, t?.mode);
|
|
@@ -4368,10 +4435,10 @@ var Qi = () => ee(Xi), $i = (e) => Ji(Qi().scopes, e), ea = (e) => Yi(Qi().scope
|
|
|
4368
4435
|
get: c,
|
|
4369
4436
|
pending: o
|
|
4370
4437
|
};
|
|
4371
|
-
},
|
|
4372
|
-
let n =
|
|
4438
|
+
}, Do = (e, t) => {
|
|
4439
|
+
let n = Eo(e), r = n.get(t);
|
|
4373
4440
|
return O(() => r === void 0 ? {
|
|
4374
|
-
...
|
|
4441
|
+
...wo,
|
|
4375
4442
|
connectionId: t,
|
|
4376
4443
|
label: t,
|
|
4377
4444
|
connected: !1,
|
|
@@ -4396,6 +4463,6 @@ var Qi = () => ee(Xi), $i = (e) => Ji(Qi().scopes, e), ea = (e) => Yi(Qi().scope
|
|
|
4396
4463
|
n.loading,
|
|
4397
4464
|
n.pending
|
|
4398
4465
|
]);
|
|
4399
|
-
},
|
|
4466
|
+
}, Oo = "framework-client";
|
|
4400
4467
|
//#endregion
|
|
4401
|
-
export {
|
|
4468
|
+
export { sa as ADMIN_SCOPE, Oo as CLIENT_NAME, bo as CONNECTIONS_LIST_TAG, Co as CONNECTION_DISCONNECT_TAG, xo as CONNECTION_START_TAG, So 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, Lr as FormBindingProvider, St as FrameworkRuntimesContext, rn as FrameworkRuntimesProvider, vt as INITIAL_RECOVERY_SNAPSHOT, ot as LoadingSubscriptionCache, da as PermissionProvider, _ as RICH_TEXT_MARKS, a as RICH_TEXT_MAX_NODES, yt as RecoveryCoordinator, d as RichTextDocument, dt as RpcErrorBus, Xi as ServerRequestContext, Qi as ServerRequestProvider, at as SubscriptionCache, Oa as UNDO_APPLY_TAG, Da as UNDO_LOG_TAG, ka as UNDO_REDO_TAG, Or as ValidationMessagesProvider, Ft as _resetFrameworkRuntimesWarning, At as _resetSsrDescriptors, Qr as applyPreloadSeeds, Gn as applyStoreSeeds, Qt as buildApiRuntime, ca as canCall, la as canCallAny, Be as clearClientDiagnostics, rr as clearMutations, co as clearSent, Tn as clearStoreHistory, ze as clientDiagnosticsSnapshot, mo as computeWindow, eo as createAnalytics, Wr as createHooks, va as decideAccess, c as decodeFieldIssues, Za as defineEvent, Bn as defineStore, ja as defineTracking, zn as definedStores, Ta as deriveEntityAdmins, Re as disableClientDiagnosticsPersistence, n as documentLocale, y as emptyRichTextDocument, Le as enableClientDiagnosticsPersistence, no as enqueueEntry, $a as eventCatalog, Wa as filtersFromSchema, r as formActionPath, m as formDataToInput, S as formField, t as formSections, dr as freshIdempotencyKey, gr as getMutationNotifier, tr as getMutations, Yi as globalContext, o as isRichTextDocument, s as isSafeHref, Ui as isUnauthenticated, Lt as isUnresolvedApi, Gr as makePreloadSeedBag, Hn as makeStoreSeedBag, ha as manifestUrl, oo as markConflict, ao as markFailed, io as markSent, ba as openAccessReason, h as parseRichText, aa as provenanceUrl, ct as publishClientError, Ce as publishClientTrace, ei as readPreloadedSeedOutcome, $r as readPreloadedSnapshot, H as recordClientDiagnostic, xt as recoveryCoordinatorFor, Ot as registerSsrDescriptors, lo as replayable, ut as reportClientError, ya as requiredScopes, ti as resetPreloadSeeds, Vn as resetStoreRegistryForTests, un as resetStoreStorageForTest, K as resolveByTag, so as resolveConflictEntry, _t as resolveRecoveryOptions, ln as resolveStoreStorage, Ma as resolveTrackingEvent, b as resolveValidationMessage, C as restrictToSchema, Pi as resumableConsumeProgram, f as richTextToPlainText, ea as rowsToOptions, si as runSequence, e as schemaToColumns, x as schemaToFields, Xr as seedPreloadedSubscription, Zr as seedPreloadedSubscriptionFailure, Wn as seedStore, oi as sequence, l as serializeRichText, hr as setMutationNotifier, qr as setPreloadSeedResolver, Un as setStoreSeedResolver, cn as setStoreStorage, Z as settleMutation, dn as shallow, Ra as shallowArrayEqual, za as sourceValues, wt as ssrClientProxy, kt as ssrDescriptorsFor, jt as ssrStubHandle, U as stableKey, nn as startApiSupervisor, er as startMutation, Cn as storeHistory, Ve as subscribeClientDiagnostics, lt as subscribeClientErrors, we as subscribeClientTraces, nr as subscribeMutations, wn as subscribeStoreHistory, We as supersedesConfirmedPatches, En as travelToStoreState, xa as useAccessDecision, Er as useAction, Bi as useAgent, zi as useAgentChat, Ni as useAgentStream, Xa as useAsyncValidation, pa as useCan, ma as useCanAny, ga as useCapabilityManifest, Do as useConnection, Hr as useConnectionSetup, yo as useConnectionStatus, Eo as useConnections, Vi as useDataCopilot, ra as useDataTable, Ja as useDebounced, Ba as useDerived, ai as useEvent, Ir as useFormBinding, Rr as useFormBindingContext, zr as useFormField, $i as useFormFlash, Ia as useFormSkeleton, G as useFrameworkApi, It as useFrameworkRuntimes, xr as useMutation, Ki as useOnRawRpcError, Gi as useOnRpcError, po as useOutbox, fa as usePermissions, ni as usePreloadedSubscription, to as usePreview, oa as useProvenance, ta as useQueryField, Ka as useQueryFilters, qa as useRecord, Hi as useRefreshSubscriptions, Va as useResourceCan, Ha as useResourceCans, Ii as useResumableAgentStream, ci as useSequence, Zi as useServerRequest, q as useSubscription, Ji as useSubscriptionHealth, La as useTableSkeleton, Fa as useTracking, hi as useTranscription, Ea as useUndo, Aa as useUndoLog, mi as useUpload, kr as useValidationMessages, ho as useWindowedSubscription, _i as useWorkflow, Ti as useWorkflowDomainEvents, Ei as useWorkflowEventDeliveries, wi as useWorkflowEvents, bi as useWorkflowRun, Ci as useWorkflowRunEvents, Mi as useWorkflowRunState, Si as useWorkflowRunSteps, xi as useWorkflowRuns, vi as useWorkflowSignal, yi as useWorkflowUpdate, Qa as validateEventPayload, i as validateFields, Ya as validationStatus, Wi as wireAuthRefresh, fr as withIdempotencyKey, Yt as withProtocolOpenRecovery, Pa as wrapTrackedCallbacks };
|