@voltro/client 0.62.2 → 0.63.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 +27 -0
- package/dist/index.d.ts +141 -25
- package/dist/index.js +906 -652
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -16,7 +16,7 @@ var _e = /* @__PURE__ */ new Set(), ve = (e) => {
|
|
|
16
16
|
} catch {}
|
|
17
17
|
}, ye = (e) => (_e.add(e), () => {
|
|
18
18
|
_e.delete(e);
|
|
19
|
-
}), be = /* @__PURE__ */ new WeakMap(), xe = (e, t) => ((typeof e == "object" && e || typeof e == "function") && be.set(e, t), e),
|
|
19
|
+
}), be = /* @__PURE__ */ new WeakMap(), xe = (e, t) => ((typeof e == "object" && e || typeof e == "function") && be.set(e, t), e), V = (e, t) => {
|
|
20
20
|
if ((typeof e != "object" || !e) && typeof e != "function") return t;
|
|
21
21
|
let n = be.get(e);
|
|
22
22
|
if (n !== void 0) return n;
|
|
@@ -25,89 +25,89 @@ var _e = /* @__PURE__ */ new Set(), ve = (e) => {
|
|
|
25
25
|
} catch {
|
|
26
26
|
return t;
|
|
27
27
|
}
|
|
28
|
-
},
|
|
28
|
+
}, Se = "voltro.client-diagnostics.v1", H = 400, Ce = 240, we = Symbol.for("@voltro/client/diagnostics"), Te = globalThis, Ee = () => typeof performance < "u" && typeof performance.now == "function" ? performance.now() : Date.now(), U = Te[we] ?? (Te[we] = {
|
|
29
29
|
sessionStartedAt: Date.now(),
|
|
30
|
-
monotonicStartedAt:
|
|
30
|
+
monotonicStartedAt: Ee(),
|
|
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
|
+
}), De = (e) => e.length <= Ce ? e : `${e.slice(0, Ce)}…`, Oe = (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" ? De(r) : r);
|
|
40
40
|
return t;
|
|
41
|
-
},
|
|
41
|
+
}, ke = (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
|
+
}, Ae = () => {
|
|
46
|
+
if (U.storage !== void 0) try {
|
|
47
|
+
U.storage.setItem(Se, JSON.stringify({
|
|
48
48
|
version: 1,
|
|
49
|
-
sessionStartedAt:
|
|
50
|
-
sequence:
|
|
51
|
-
dropped:
|
|
52
|
-
events:
|
|
49
|
+
sessionStartedAt: U.sessionStartedAt,
|
|
50
|
+
sequence: U.sequence,
|
|
51
|
+
dropped: U.dropped,
|
|
52
|
+
events: U.events
|
|
53
53
|
}));
|
|
54
54
|
} catch {}
|
|
55
|
-
},
|
|
56
|
-
for (let e of
|
|
55
|
+
}, je = () => {
|
|
56
|
+
for (let e of U.listeners) try {
|
|
57
57
|
e();
|
|
58
58
|
} catch {}
|
|
59
|
-
},
|
|
60
|
-
if (
|
|
61
|
-
|
|
59
|
+
}, Me = (e) => {
|
|
60
|
+
if (U.storage = e, !U.loadedStorage) {
|
|
61
|
+
U.loadedStorage = !0;
|
|
62
62
|
try {
|
|
63
|
-
let t = e.getItem(
|
|
63
|
+
let t = e.getItem(Se);
|
|
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(ke) : [], r = Math.max(typeof e.sequence == "number" ? e.sequence : 0, 0, ...n.map((e) => e.sequence)), i = U.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 - H), s = typeof e.dropped == "number" ? e.dropped : 0;
|
|
69
|
+
U.dropped = U.dropped + s + o, U.events = a.slice(-400), U.sequence = Math.max(r + i.length, ...U.events.map((e) => e.sequence)), typeof e.sessionStartedAt == "number" && (U.sessionStartedAt = Math.min(U.sessionStartedAt, e.sessionStartedAt));
|
|
70
70
|
}
|
|
71
71
|
} catch {}
|
|
72
72
|
}
|
|
73
|
-
|
|
74
|
-
},
|
|
75
|
-
|
|
76
|
-
},
|
|
73
|
+
Ae();
|
|
74
|
+
}, Ne = () => {
|
|
75
|
+
U.storage = void 0;
|
|
76
|
+
}, W = (e, t, n = {}) => {
|
|
77
77
|
let r = {
|
|
78
|
-
sequence: ++
|
|
78
|
+
sequence: ++U.sequence,
|
|
79
79
|
at: Date.now(),
|
|
80
|
-
elapsedMs: Math.max(0, Math.round(
|
|
81
|
-
api:
|
|
80
|
+
elapsedMs: Math.max(0, Math.round(Ee() - U.monotonicStartedAt)),
|
|
81
|
+
api: De(e),
|
|
82
82
|
kind: t,
|
|
83
|
-
fields:
|
|
83
|
+
fields: Oe(n)
|
|
84
84
|
};
|
|
85
|
-
return
|
|
86
|
-
},
|
|
85
|
+
return U.events.push(r), U.events.length > H && (U.events.splice(0, U.events.length - H), U.dropped += 1), Ae(), je(), r;
|
|
86
|
+
}, Pe = (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: U.sessionStartedAt,
|
|
90
|
+
persisted: U.storage !== void 0,
|
|
91
|
+
dropped: U.dropped,
|
|
92
|
+
events: e === void 0 ? [...U.events] : U.events.filter((t) => t.api === e)
|
|
93
|
+
}), Fe = () => {
|
|
94
|
+
U.events = [], U.dropped = 0;
|
|
95
95
|
try {
|
|
96
|
-
|
|
96
|
+
U.storage?.removeItem(Se);
|
|
97
97
|
} catch {}
|
|
98
|
-
|
|
99
|
-
},
|
|
100
|
-
|
|
101
|
-
}),
|
|
98
|
+
je();
|
|
99
|
+
}, Ie = (e) => (U.listeners.add(e), () => {
|
|
100
|
+
U.listeners.delete(e);
|
|
101
|
+
}), G = (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
|
+
}, Le = 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
|
-
}),
|
|
110
|
+
}), Re = 5e3, ze = (e, t, n) => {
|
|
111
111
|
if (e._tag === "error") return !1;
|
|
112
112
|
if (e._tag === "delta") return !0;
|
|
113
113
|
try {
|
|
@@ -115,21 +115,21 @@ var _e = /* @__PURE__ */ new Set(), ve = (e) => {
|
|
|
115
115
|
} catch {
|
|
116
116
|
return !1;
|
|
117
117
|
}
|
|
118
|
-
},
|
|
118
|
+
}, Be = 0, Ve = () => `patch_${++Be}`, He = (e, t) => {
|
|
119
119
|
let n = e;
|
|
120
120
|
for (let e of t.split(".")) {
|
|
121
121
|
if (typeof n != "object" || !n) return;
|
|
122
122
|
n = n[e];
|
|
123
123
|
}
|
|
124
124
|
return n;
|
|
125
|
-
},
|
|
125
|
+
}, Ue = (e, t, n) => {
|
|
126
126
|
let r = t.split("."), i = (e) => typeof e == "object" && e && !Array.isArray(e) ? { ...e } : {}, a = i(e), o = a;
|
|
127
127
|
for (let e = 0; e < r.length - 1; e += 1) o[r[e]] = i(o[r[e]]), o = o[r[e]];
|
|
128
128
|
return o[r[r.length - 1]] = n, a;
|
|
129
|
-
},
|
|
129
|
+
}, We = (e, t) => {
|
|
130
130
|
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
131
|
return i.length === 0 ? null : new Set(i);
|
|
132
|
-
},
|
|
132
|
+
}, Ge = (e, t, n) => {
|
|
133
133
|
let r = e.path, i = e.by ?? "id";
|
|
134
134
|
if (e.op === "insert") {
|
|
135
135
|
let a = e.shapeItem ?? e.shape, o = a ? {
|
|
@@ -142,11 +142,11 @@ var _e = /* @__PURE__ */ new Set(), ve = (e) => {
|
|
|
142
142
|
optimistic: !0
|
|
143
143
|
}, s = e.order ?? "append";
|
|
144
144
|
return (e) => {
|
|
145
|
-
let t = Array.isArray(
|
|
146
|
-
return
|
|
145
|
+
let t = Array.isArray(He(e, r)) ? He(e, r) : [];
|
|
146
|
+
return Ue(e ?? {}, r, s === "append" ? [...t, o] : [o, ...t]);
|
|
147
147
|
};
|
|
148
148
|
}
|
|
149
|
-
let a =
|
|
149
|
+
let a = We(e, t);
|
|
150
150
|
if (a === null) return null;
|
|
151
151
|
if (e.op === "update") {
|
|
152
152
|
let n = e.shapeItem ?? e.shape, o = n ? (e) => ({
|
|
@@ -160,24 +160,24 @@ var _e = /* @__PURE__ */ new Set(), ve = (e) => {
|
|
|
160
160
|
optimistic: !0
|
|
161
161
|
});
|
|
162
162
|
return (e) => {
|
|
163
|
-
let t =
|
|
163
|
+
let t = He(e, r);
|
|
164
164
|
if (!Array.isArray(t)) {
|
|
165
165
|
if (typeof t != "object" || !t) return e;
|
|
166
166
|
let n = t;
|
|
167
|
-
return a.has(n[i]) ?
|
|
167
|
+
return a.has(n[i]) ? Ue(e, r, o(n)) : e;
|
|
168
168
|
}
|
|
169
|
-
return
|
|
169
|
+
return Ue(e, r, t.map((e) => a.has(e[i]) ? o(e) : e));
|
|
170
170
|
};
|
|
171
171
|
}
|
|
172
172
|
return (e) => {
|
|
173
|
-
let t = Array.isArray(
|
|
174
|
-
return
|
|
173
|
+
let t = Array.isArray(He(e, r)) ? He(e, r) : [];
|
|
174
|
+
return Ue(e, r, t.filter((e) => !a.has(e[i])));
|
|
175
175
|
};
|
|
176
|
-
},
|
|
176
|
+
}, Ke = (e, t, n) => {
|
|
177
177
|
if (e.op === "insert") return n;
|
|
178
178
|
let r = t.id;
|
|
179
179
|
return typeof r == "string" && r.length > 0 ? r : null;
|
|
180
|
-
},
|
|
180
|
+
}, qe = (e, t, n, r) => {
|
|
181
181
|
let { anchorColumn: i, targetColumn: a } = e, o = new Set(n.map((e) => String(e)));
|
|
182
182
|
return (e) => {
|
|
183
183
|
if (!Array.isArray(e)) return e;
|
|
@@ -208,8 +208,8 @@ var _e = /* @__PURE__ */ new Set(), ve = (e) => {
|
|
|
208
208
|
}));
|
|
209
209
|
return c ? n : e;
|
|
210
210
|
};
|
|
211
|
-
},
|
|
212
|
-
if (e.path !== void 0) return
|
|
211
|
+
}, Je = (e, t, n) => {
|
|
212
|
+
if (e.path !== void 0) return Ge(e, t, n);
|
|
213
213
|
switch (e.op) {
|
|
214
214
|
case "insert": {
|
|
215
215
|
let r = e.shape ? {
|
|
@@ -227,7 +227,7 @@ var _e = /* @__PURE__ */ new Set(), ve = (e) => {
|
|
|
227
227
|
};
|
|
228
228
|
}
|
|
229
229
|
case "update": {
|
|
230
|
-
let n =
|
|
230
|
+
let n = We(e, t);
|
|
231
231
|
if (n === null) return null;
|
|
232
232
|
let r = e.shape, i = r ? (e) => ({
|
|
233
233
|
...r(t, e),
|
|
@@ -250,7 +250,7 @@ var _e = /* @__PURE__ */ new Set(), ve = (e) => {
|
|
|
250
250
|
};
|
|
251
251
|
}
|
|
252
252
|
case "delete": {
|
|
253
|
-
let n =
|
|
253
|
+
let n = We(e, t);
|
|
254
254
|
return n === null ? null : (e) => {
|
|
255
255
|
if (!Array.isArray(e)) {
|
|
256
256
|
let t = e;
|
|
@@ -260,8 +260,9 @@ var _e = /* @__PURE__ */ new Set(), ve = (e) => {
|
|
|
260
260
|
};
|
|
261
261
|
}
|
|
262
262
|
}
|
|
263
|
-
},
|
|
263
|
+
}, Ye = 5e3, Xe = 15e3, Ze = class {
|
|
264
264
|
entries = /* @__PURE__ */ new Map();
|
|
265
|
+
successor;
|
|
265
266
|
inactiveTtlMs;
|
|
266
267
|
onChangeHook;
|
|
267
268
|
errorBus;
|
|
@@ -270,10 +271,10 @@ var _e = /* @__PURE__ */ new Set(), ve = (e) => {
|
|
|
270
271
|
apiName;
|
|
271
272
|
recoveryStuckMs;
|
|
272
273
|
constructor(e = {}) {
|
|
273
|
-
this.inactiveTtlMs = e.inactiveTtlMs ??
|
|
274
|
+
this.inactiveTtlMs = e.inactiveTtlMs ?? Ye, this.onChangeHook = e.onChange, this.errorBus = e.errorBus, this.mirror = e.mirror, this.mergeCell = e.mergeCell, this.apiName = e.apiName, this.recoveryStuckMs = e.recoveryStuckMs ?? Xe;
|
|
274
275
|
}
|
|
275
276
|
diagnose(e, t, n = {}) {
|
|
276
|
-
this.apiName !== void 0 &&
|
|
277
|
+
this.apiName !== void 0 && W(this.apiName, e, {
|
|
277
278
|
tag: t.tag ?? "unknown",
|
|
278
279
|
revision: t.state.baseRevision,
|
|
279
280
|
subscribers: t.subscribers.size,
|
|
@@ -282,21 +283,21 @@ var _e = /* @__PURE__ */ new Set(), ve = (e) => {
|
|
|
282
283
|
});
|
|
283
284
|
}
|
|
284
285
|
subscribe(e, t, n, r, i = {}) {
|
|
285
|
-
let a =
|
|
286
|
+
let a = G(e), o = typeof e[0] == "string" ? e[0] : void 0, s = this.entries.get(a);
|
|
286
287
|
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), {
|
|
287
288
|
getSnapshot: () => this.getSnapshot(a),
|
|
288
289
|
unsubscribe: () => this.unsubscribe(a, r)
|
|
289
290
|
};
|
|
290
291
|
}
|
|
291
292
|
update(e, t, n) {
|
|
292
|
-
let r =
|
|
293
|
+
let r = G(e), i = typeof e[0] == "string" ? e[0] : void 0, a = this.entries.get(r);
|
|
293
294
|
a ||= this.createStub(r, i);
|
|
294
295
|
let o = {
|
|
295
|
-
id:
|
|
296
|
+
id: Ve(),
|
|
296
297
|
mutationId: n,
|
|
297
298
|
reducer: t
|
|
298
299
|
};
|
|
299
|
-
return a.state.patches.push(o), this.invalidate(a), {
|
|
300
|
+
return a.state.patches.push(o), this.invalidate(a), this.successor?.update(e, t, n), {
|
|
300
301
|
patchId: o.id,
|
|
301
302
|
revert: () => this.revertPatch(r, o.id)
|
|
302
303
|
};
|
|
@@ -306,34 +307,36 @@ var _e = /* @__PURE__ */ new Set(), ve = (e) => {
|
|
|
306
307
|
for (let i of this.entries.values()) {
|
|
307
308
|
if (i.tag !== e) continue;
|
|
308
309
|
let a = {
|
|
309
|
-
id: `forTag-${++
|
|
310
|
+
id: `forTag-${++Be}`,
|
|
310
311
|
mutationId: n,
|
|
311
312
|
reducer: t
|
|
312
313
|
};
|
|
313
314
|
i.state.patches.push(a), this.invalidate(i), r++;
|
|
314
315
|
}
|
|
315
|
-
return { patchedCount: r };
|
|
316
|
+
return this.successor?.forTag(e, t, n), { patchedCount: r };
|
|
316
317
|
}
|
|
317
318
|
revertByMutation(e) {
|
|
318
319
|
for (let t of this.entries.values()) {
|
|
319
320
|
let n = t.state.patches.length;
|
|
320
321
|
t.state.patches = t.state.patches.filter((t) => t.mutationId !== e), t.state.patches.length !== n && this.invalidate(t);
|
|
321
322
|
}
|
|
323
|
+
this.successor?.revertByMutation(e);
|
|
322
324
|
}
|
|
323
325
|
confirmByMutation(e) {
|
|
324
326
|
let t = !1;
|
|
325
327
|
for (let n of this.entries.values()) for (let r of n.state.patches) r.mutationId === e && r.confirmed !== !0 && (r.confirmed = !0, t = !0);
|
|
326
|
-
t && setTimeout(() => this.resyncUnechoedMutation(e),
|
|
328
|
+
t && setTimeout(() => this.resyncUnechoedMutation(e), Re), this.successor?.confirmByMutation(e);
|
|
327
329
|
}
|
|
328
330
|
resyncUnechoedMutation(e) {
|
|
329
331
|
for (let t of this.entries.values()) {
|
|
330
332
|
if (!t.state.patches.some((t) => t.mutationId === e && t.confirmed === !0)) continue;
|
|
331
|
-
let n = t.tag ?? t.key, r = `optimistic patch for ${n} got no superseding server event within ${
|
|
333
|
+
let n = t.tag ?? t.key, r = `optimistic patch for ${n} got no superseding server event within ${Re}ms — the write is confirmed, so the preview is KEPT. Check reactivity for this query's source table.`;
|
|
332
334
|
this.errorBus?.emit({
|
|
333
335
|
source: "subscription",
|
|
334
336
|
tag: n,
|
|
335
337
|
error: Error(r),
|
|
336
338
|
kind: "client",
|
|
339
|
+
outcome: "not-applicable",
|
|
337
340
|
...t.traceId === void 0 ? {} : { traceId: t.traceId }
|
|
338
341
|
}), console.warn(`[voltro] ${r}`, {
|
|
339
342
|
mutationId: e,
|
|
@@ -342,7 +345,7 @@ var _e = /* @__PURE__ */ new Set(), ve = (e) => {
|
|
|
342
345
|
}
|
|
343
346
|
}
|
|
344
347
|
autoApply(e, t, n) {
|
|
345
|
-
let r = `optimistic-${n}-${++
|
|
348
|
+
let r = `optimistic-${n}-${++Be}`;
|
|
346
349
|
for (let i of e) {
|
|
347
350
|
for (let e of this.entries.values()) {
|
|
348
351
|
if (!(Array.isArray(e.source) ? e.source.includes(i.table) : e.source === i.table)) continue;
|
|
@@ -356,7 +359,7 @@ var _e = /* @__PURE__ */ new Set(), ve = (e) => {
|
|
|
356
359
|
if (!n) continue;
|
|
357
360
|
}
|
|
358
361
|
if (e.computed && i.op === "insert" && i.path === void 0) continue;
|
|
359
|
-
let a =
|
|
362
|
+
let a = Je(i, t, r);
|
|
360
363
|
if (a === null) continue;
|
|
361
364
|
let o = {
|
|
362
365
|
id: `${r}-${e.key}`,
|
|
@@ -369,10 +372,10 @@ var _e = /* @__PURE__ */ new Set(), ve = (e) => {
|
|
|
369
372
|
if (e !== void 0) for (let [a, o] of Object.entries(e)) {
|
|
370
373
|
let e = t[a];
|
|
371
374
|
if (!Array.isArray(e)) continue;
|
|
372
|
-
let s =
|
|
375
|
+
let s = Ke(i, t, r);
|
|
373
376
|
if (s !== null) for (let t of this.entries.values()) {
|
|
374
377
|
if (!(Array.isArray(t.source) ? t.source.includes(o.junction) : t.source === o.junction) || t.computed) continue;
|
|
375
|
-
let i =
|
|
378
|
+
let i = qe(o, s, e.map((e) => String(e)), `${r}-${a}`);
|
|
376
379
|
t.state.patches.push({
|
|
377
380
|
id: `${r}-${a}-${t.key}`,
|
|
378
381
|
mutationId: n,
|
|
@@ -381,6 +384,7 @@ var _e = /* @__PURE__ */ new Set(), ve = (e) => {
|
|
|
381
384
|
}
|
|
382
385
|
}
|
|
383
386
|
}
|
|
387
|
+
this.successor?.autoApply(e, t, n);
|
|
384
388
|
}
|
|
385
389
|
revertPatch(e, t) {
|
|
386
390
|
let n = this.entries.get(e);
|
|
@@ -389,10 +393,10 @@ var _e = /* @__PURE__ */ new Set(), ve = (e) => {
|
|
|
389
393
|
n.state.patches = n.state.patches.filter((e) => e.id !== t), n.state.patches.length !== r && this.invalidate(n);
|
|
390
394
|
}
|
|
391
395
|
peek(e) {
|
|
392
|
-
return this.getSnapshot(
|
|
396
|
+
return this.getSnapshot(G(e));
|
|
393
397
|
}
|
|
394
398
|
getEntry(e) {
|
|
395
|
-
return this.entries.get(
|
|
399
|
+
return this.entries.get(G(e));
|
|
396
400
|
}
|
|
397
401
|
size() {
|
|
398
402
|
return this.entries.size;
|
|
@@ -451,18 +455,19 @@ var _e = /* @__PURE__ */ new Set(), ve = (e) => {
|
|
|
451
455
|
e.state = this.freshState(), e.state.patches = r, n || (e.state.base = i, e.state.baseRevision = a, e.state.baseEmittedAt = o), this.startFiber(e, e.fetch, t);
|
|
452
456
|
}
|
|
453
457
|
seedStaleFrom(e) {
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
458
|
+
e.successor = this;
|
|
459
|
+
let t = 0, n = /* @__PURE__ */ new Set();
|
|
460
|
+
for (let r of e.entries.values()) {
|
|
461
|
+
if (r.state.base === void 0 || this.entries.has(r.key)) continue;
|
|
457
462
|
let e = {
|
|
458
|
-
key:
|
|
459
|
-
tag:
|
|
463
|
+
key: r.key,
|
|
464
|
+
tag: r.tag,
|
|
460
465
|
state: {
|
|
461
|
-
base:
|
|
462
|
-
baseRevision:
|
|
463
|
-
baseEmittedAt:
|
|
466
|
+
base: r.state.base,
|
|
467
|
+
baseRevision: r.state.baseRevision,
|
|
468
|
+
baseEmittedAt: r.state.baseEmittedAt,
|
|
464
469
|
baseError: void 0,
|
|
465
|
-
patches:
|
|
470
|
+
patches: r.state.patches.map((e) => (e.confirmed === !0 && n.add(e.mutationId), { ...e })),
|
|
466
471
|
cachedSnapshot: null
|
|
467
472
|
},
|
|
468
473
|
subscribers: /* @__PURE__ */ new Set(),
|
|
@@ -476,13 +481,14 @@ var _e = /* @__PURE__ */ new Set(), ve = (e) => {
|
|
|
476
481
|
recoveryBasePreserved: !1,
|
|
477
482
|
recoveryTimer: null,
|
|
478
483
|
evictionTimer: null,
|
|
479
|
-
source:
|
|
480
|
-
computed:
|
|
484
|
+
source: r.source,
|
|
485
|
+
computed: r.computed,
|
|
481
486
|
fetch: null,
|
|
482
487
|
runtime: null
|
|
483
488
|
};
|
|
484
489
|
this.entries.set(e.key, e), this.scheduleEviction(e), t += 1;
|
|
485
490
|
}
|
|
491
|
+
for (let e of n) setTimeout(() => this.resyncUnechoedMutation(e), Re);
|
|
486
492
|
return t;
|
|
487
493
|
}
|
|
488
494
|
create(e, t, n, r, i) {
|
|
@@ -565,7 +571,7 @@ var _e = /* @__PURE__ */ new Set(), ve = (e) => {
|
|
|
565
571
|
}), e.recoveryPhase = "steady", this.diagnose("subscription.health-cleared", e, { delivery: t._tag })), this.errorBus?.emitSuccess({
|
|
566
572
|
source: "subscription",
|
|
567
573
|
tag: e.tag ?? e.key
|
|
568
|
-
})), e.state.patches.some((e) => e.confirmed === !0) &&
|
|
574
|
+
})), e.state.patches.some((e) => e.confirmed === !0) && ze(t, n, e.state.base) && (e.state.patches = e.state.patches.filter((e) => e.confirmed !== !0)), this.mirror !== void 0 && t._tag !== "error" && this.mirror.save(e.key, {
|
|
569
575
|
tag: e.tag,
|
|
570
576
|
data: e.state.base,
|
|
571
577
|
revision: e.state.baseRevision
|
|
@@ -574,12 +580,13 @@ var _e = /* @__PURE__ */ new Set(), ve = (e) => {
|
|
|
574
580
|
e.fiber = c, c.addObserver((t) => {
|
|
575
581
|
if (e.fiber === c && (e.fiber = null), N.isFailure(t) && !N.isInterrupted(t)) {
|
|
576
582
|
e.state.baseRevision === -1 && (e.state.baseError = t.cause, this.invalidate(e));
|
|
577
|
-
let n = j.squash(t.cause), r = j.failureOption(t.cause), i = L.isSome(r) ?
|
|
583
|
+
let n = j.squash(t.cause), r = j.failureOption(t.cause), i = L.isSome(r) ? V(r.value, "handler") : "unknown";
|
|
578
584
|
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({
|
|
579
585
|
source: "subscription",
|
|
580
586
|
tag: e.tag ?? e.key,
|
|
581
587
|
error: n,
|
|
582
588
|
kind: i,
|
|
589
|
+
outcome: "not-applicable",
|
|
583
590
|
...e.traceId === void 0 ? {} : { traceId: e.traceId }
|
|
584
591
|
});
|
|
585
592
|
}
|
|
@@ -592,7 +599,7 @@ var _e = /* @__PURE__ */ new Set(), ve = (e) => {
|
|
|
592
599
|
}
|
|
593
600
|
getSnapshot(e) {
|
|
594
601
|
let t = this.entries.get(e);
|
|
595
|
-
if (!t) return
|
|
602
|
+
if (!t) return Le;
|
|
596
603
|
if (t.state.cachedSnapshot !== null) return t.state.cachedSnapshot;
|
|
597
604
|
let n = t.state.base;
|
|
598
605
|
if (n !== void 0 && t.state.patches.length > 0) for (let e of t.state.patches) n = e.reducer(n);
|
|
@@ -615,26 +622,26 @@ var _e = /* @__PURE__ */ new Set(), ve = (e) => {
|
|
|
615
622
|
t && t.subscribers.size === 0 && (t.recoveryTimer !== null && clearTimeout(t.recoveryTimer), t.fiber && M.runFork(P.interrupt(t.fiber)), this.entries.delete(e.key));
|
|
616
623
|
}, this.inactiveTtlMs);
|
|
617
624
|
}
|
|
618
|
-
},
|
|
625
|
+
}, Qe = class extends Ze {
|
|
619
626
|
subscribe(e, t, n, r, i = {}) {
|
|
620
627
|
return {
|
|
621
628
|
getSnapshot: () => this.peek(e),
|
|
622
629
|
unsubscribe: () => {}
|
|
623
630
|
};
|
|
624
631
|
}
|
|
625
|
-
},
|
|
626
|
-
for (let t of
|
|
632
|
+
}, $e = /* @__PURE__ */ new Set(), et = (e) => {
|
|
633
|
+
for (let t of $e) try {
|
|
627
634
|
t(e);
|
|
628
635
|
} catch {}
|
|
629
|
-
},
|
|
630
|
-
|
|
631
|
-
}),
|
|
632
|
-
|
|
636
|
+
}, tt = (e) => ($e.add(e), () => {
|
|
637
|
+
$e.delete(e);
|
|
638
|
+
}), nt = (e, t) => {
|
|
639
|
+
et({
|
|
633
640
|
error: e,
|
|
634
641
|
source: "manual",
|
|
635
642
|
...t ? { context: t } : {}
|
|
636
643
|
});
|
|
637
|
-
},
|
|
644
|
+
}, rt = class {
|
|
638
645
|
#e = /* @__PURE__ */ new Set();
|
|
639
646
|
#t = /* @__PURE__ */ new Set();
|
|
640
647
|
on(e) {
|
|
@@ -646,12 +653,13 @@ var _e = /* @__PURE__ */ new Set(), ve = (e) => {
|
|
|
646
653
|
for (let t of this.#e) try {
|
|
647
654
|
t(e);
|
|
648
655
|
} catch {}
|
|
649
|
-
|
|
656
|
+
et({
|
|
650
657
|
error: e.error,
|
|
651
658
|
source: `rpc.${e.source}`,
|
|
652
659
|
context: {
|
|
653
660
|
rpcTag: e.tag,
|
|
654
661
|
rpcErrorKind: e.kind,
|
|
662
|
+
...e.outcome === void 0 ? {} : { rpcCallOutcome: e.outcome },
|
|
655
663
|
...e.traceId === void 0 ? {} : { traceId: e.traceId }
|
|
656
664
|
}
|
|
657
665
|
});
|
|
@@ -666,81 +674,296 @@ var _e = /* @__PURE__ */ new Set(), ve = (e) => {
|
|
|
666
674
|
t(e);
|
|
667
675
|
} catch {}
|
|
668
676
|
}
|
|
669
|
-
},
|
|
677
|
+
}, it = (e, t, n, r) => e === void 0 || !Number.isFinite(e) ? t : Math.min(r, Math.max(n, Math.trunc(e))), at = (e) => ({
|
|
678
|
+
graceMs: it(e?.graceMs, 1500, 0, 3e4),
|
|
679
|
+
maxPendingMutations: it(e?.maxPendingMutations, 32, 0, 256),
|
|
680
|
+
replayWindowMs: it(e?.replayWindowMs, 1e4, 250, 6e4),
|
|
681
|
+
capabilitiesUrl: e?.capabilitiesUrl
|
|
682
|
+
}), ot = class {
|
|
683
|
+
#e;
|
|
684
|
+
#t;
|
|
685
|
+
#n;
|
|
686
|
+
#r = /* @__PURE__ */ new Set();
|
|
687
|
+
#i = /* @__PURE__ */ new Set();
|
|
688
|
+
#a = /* @__PURE__ */ new Set();
|
|
689
|
+
#o = /* @__PURE__ */ new Set();
|
|
690
|
+
#s = /* @__PURE__ */ new Set();
|
|
691
|
+
#c = "connected";
|
|
692
|
+
#l = "connected";
|
|
693
|
+
#u = 0;
|
|
694
|
+
#d;
|
|
695
|
+
#f = 0;
|
|
696
|
+
#p = "unknown";
|
|
697
|
+
#m = -1;
|
|
698
|
+
#h = 0;
|
|
699
|
+
#g;
|
|
700
|
+
#_;
|
|
701
|
+
#v = !1;
|
|
702
|
+
#y;
|
|
703
|
+
constructor(e, t, n) {
|
|
704
|
+
this.#e = e, this.#t = at(t), this.#n = {
|
|
705
|
+
now: n?.now ?? Date.now,
|
|
706
|
+
setTimeout: n?.setTimeout ?? ((e, t) => setTimeout(e, t)),
|
|
707
|
+
clearTimeout: n?.clearTimeout ?? ((e) => clearTimeout(e))
|
|
708
|
+
}, this.#y = this.#b();
|
|
709
|
+
}
|
|
710
|
+
get options() {
|
|
711
|
+
return this.#t;
|
|
712
|
+
}
|
|
713
|
+
getSnapshot = () => this.#y;
|
|
714
|
+
subscribe = (e) => (this.#r.add(e), () => {
|
|
715
|
+
this.#r.delete(e);
|
|
716
|
+
});
|
|
717
|
+
onVisibleError(e) {
|
|
718
|
+
return this.#i.add(e), () => {
|
|
719
|
+
this.#i.delete(e);
|
|
720
|
+
};
|
|
721
|
+
}
|
|
722
|
+
#b() {
|
|
723
|
+
return {
|
|
724
|
+
rawTransport: this.#c,
|
|
725
|
+
status: this.#l,
|
|
726
|
+
failureCount: this.#u,
|
|
727
|
+
lastFailureAt: this.#d,
|
|
728
|
+
failedSubscriptions: [...this.#s].sort(),
|
|
729
|
+
pendingMutationReplays: this.#f,
|
|
730
|
+
mutationReplay: this.#p
|
|
731
|
+
};
|
|
732
|
+
}
|
|
733
|
+
#x() {
|
|
734
|
+
this.#y = this.#b();
|
|
735
|
+
for (let e of this.#r) try {
|
|
736
|
+
e();
|
|
737
|
+
} catch {}
|
|
738
|
+
W(this.#e, "recovery.state", {
|
|
739
|
+
rawTransport: this.#y.rawTransport,
|
|
740
|
+
status: this.#y.status,
|
|
741
|
+
failureCount: this.#y.failureCount,
|
|
742
|
+
failedSubscriptions: this.#y.failedSubscriptions.length,
|
|
743
|
+
pendingMutationReplays: this.#y.pendingMutationReplays,
|
|
744
|
+
mutationReplay: this.#y.mutationReplay
|
|
745
|
+
});
|
|
746
|
+
}
|
|
747
|
+
#S(e) {
|
|
748
|
+
for (let t of this.#i) try {
|
|
749
|
+
t(e);
|
|
750
|
+
} catch {}
|
|
751
|
+
}
|
|
752
|
+
#C() {
|
|
753
|
+
if (this.#l === "connected") {
|
|
754
|
+
if (this.#l = this.#t.graceMs === 0 ? "degraded" : "recovering", this.#t.graceMs === 0) {
|
|
755
|
+
this.#_ !== void 0 && (this.#v = !0, this.#S(this.#_));
|
|
756
|
+
return;
|
|
757
|
+
}
|
|
758
|
+
this.#g = this.#n.setTimeout(() => {
|
|
759
|
+
this.#g = void 0, this.#l === "recovering" && (this.#l = "degraded", this.#_ !== void 0 && (this.#v = !0, this.#S(this.#_)), this.#x());
|
|
760
|
+
}, this.#t.graceMs);
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
#w() {
|
|
764
|
+
this.#c !== "connected" || this.#s.size > 0 || (this.#g !== void 0 && (this.#n.clearTimeout(this.#g), this.#g = void 0), this.#l = "connected", this.#u = 0, this.#_ = void 0, this.#v = !1);
|
|
765
|
+
}
|
|
766
|
+
transportIssue() {
|
|
767
|
+
this.#c = "disconnected", this.#u += 1, this.#d = this.#n.now(), this.#C(), this.#x();
|
|
768
|
+
}
|
|
769
|
+
protocolReady() {
|
|
770
|
+
this.#c = "connected";
|
|
771
|
+
for (let e of this.#a) e();
|
|
772
|
+
this.#a.clear(), this.#w(), this.#x();
|
|
773
|
+
}
|
|
774
|
+
observeError(e) {
|
|
775
|
+
if (e.kind !== "transport") {
|
|
776
|
+
this.#S(e);
|
|
777
|
+
return;
|
|
778
|
+
}
|
|
779
|
+
this.#_ === void 0 && (this.#_ = e), e.source === "subscription" && this.#s.add(e.tag), this.#c !== "disconnected" && (this.#c = "disconnected", this.#u += 1, this.#d = this.#n.now()), this.#C(), this.#l === "degraded" && !this.#v && (this.#v = !0, this.#S(e)), this.#x();
|
|
780
|
+
}
|
|
781
|
+
observeSuccess(e) {
|
|
782
|
+
e.source === "subscription" && this.#s.delete(e.tag), this.#w(), this.#x();
|
|
783
|
+
}
|
|
784
|
+
reportExternalSuccess() {
|
|
785
|
+
this.#c = "connected";
|
|
786
|
+
for (let e of this.#a) e();
|
|
787
|
+
this.#a.clear(), this.#w(), this.#x();
|
|
788
|
+
}
|
|
789
|
+
resetForSubjectChange(e = 0) {
|
|
790
|
+
this.#g !== void 0 && this.#n.clearTimeout(this.#g), this.#g = void 0, this.#c = "disconnected", this.#l = "connected", this.#u = 0, this.#d = void 0, this.#s.clear(), this.#_ = void 0, this.#v = !1, this.#p = "unknown", this.#h += 1, this.#m = e;
|
|
791
|
+
for (let e of this.#o) e(!1);
|
|
792
|
+
this.#o.clear();
|
|
793
|
+
for (let e of this.#a) e();
|
|
794
|
+
this.#a.clear(), this.#C(), this.#x();
|
|
795
|
+
}
|
|
796
|
+
setMutationReplaySupported(e, t = 0) {
|
|
797
|
+
if (!(t < this.#m)) {
|
|
798
|
+
this.#m = t, this.#p = e ? "enabled" : "disabled";
|
|
799
|
+
for (let t of this.#o) t(e);
|
|
800
|
+
this.#o.clear(), this.#x();
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
waitForMutationReplaySupport(e) {
|
|
804
|
+
if (this.#p !== "unknown") return Promise.resolve(this.#p === "enabled");
|
|
805
|
+
let t = this.#t.replayWindowMs - (this.#n.now() - e);
|
|
806
|
+
return t <= 0 ? Promise.resolve(!1) : new Promise((e) => {
|
|
807
|
+
let n = !1, r, i = (t) => {
|
|
808
|
+
n || (n = !0, this.#o.delete(i), r !== void 0 && this.#n.clearTimeout(r), e(t));
|
|
809
|
+
};
|
|
810
|
+
this.#o.add(i), r = this.#n.setTimeout(() => i(!1), t);
|
|
811
|
+
});
|
|
812
|
+
}
|
|
813
|
+
reserveMutationReplay(e) {
|
|
814
|
+
if (this.#p === "disabled" || this.#n.now() - e > this.#t.replayWindowMs || this.#f >= this.#t.maxPendingMutations) return;
|
|
815
|
+
this.#f += 1, this.#x();
|
|
816
|
+
let t = this.#h, n = !1;
|
|
817
|
+
return {
|
|
818
|
+
isValid: () => !n && t === this.#h && this.#p === "enabled" && this.#c === "connected" && this.#n.now() - e <= this.#t.replayWindowMs,
|
|
819
|
+
release: () => {
|
|
820
|
+
n || (n = !0, --this.#f, this.#x());
|
|
821
|
+
}
|
|
822
|
+
};
|
|
823
|
+
}
|
|
824
|
+
waitForProtocolReady(e) {
|
|
825
|
+
if (this.#c === "connected") return Promise.resolve(!0);
|
|
826
|
+
let t = this.#t.replayWindowMs - (this.#n.now() - e);
|
|
827
|
+
return t <= 0 ? Promise.resolve(!1) : new Promise((e) => {
|
|
828
|
+
let n = !1, r = (t) => {
|
|
829
|
+
n || (n = !0, this.#a.delete(i), this.#n.clearTimeout(a), e(t && this.#c === "connected"));
|
|
830
|
+
}, i = () => r(!0);
|
|
831
|
+
this.#a.add(i);
|
|
832
|
+
let a = this.#n.setTimeout(() => r(!1), t);
|
|
833
|
+
});
|
|
834
|
+
}
|
|
835
|
+
dispose() {
|
|
836
|
+
this.#g !== void 0 && this.#n.clearTimeout(this.#g), this.#g = void 0;
|
|
837
|
+
for (let e of this.#a) e();
|
|
838
|
+
this.#a.clear();
|
|
839
|
+
for (let e of this.#o) e(!1);
|
|
840
|
+
this.#o.clear(), this.#r.clear(), this.#i.clear();
|
|
841
|
+
}
|
|
842
|
+
}, st = /* @__PURE__ */ new WeakMap(), ct = (e, t, n) => {
|
|
843
|
+
let r = st.get(e);
|
|
844
|
+
if (r !== void 0) return r;
|
|
845
|
+
let i = new ot(t, n);
|
|
846
|
+
return e.on((e) => i.observeError(e)), typeof e.onSuccess == "function" && e.onSuccess((e) => i.observeSuccess(e)), st.set(e, i), i;
|
|
847
|
+
}, lt = C(null), ut = () => {
|
|
670
848
|
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");
|
|
671
|
-
},
|
|
672
|
-
get: (e, t) =>
|
|
849
|
+
}, dt = new Proxy(() => ut(), {
|
|
850
|
+
get: (e, t) => dt,
|
|
673
851
|
has: () => !0,
|
|
674
|
-
apply: () =>
|
|
675
|
-
}),
|
|
676
|
-
|
|
677
|
-
},
|
|
678
|
-
|
|
679
|
-
},
|
|
852
|
+
apply: () => ut()
|
|
853
|
+
}), ft = Symbol.for("@voltro/client/ssrDescriptors"), pt = globalThis, mt = pt[ft] ?? (pt[ft] = { byApi: /* @__PURE__ */ new Map() }), ht = (e, t) => {
|
|
854
|
+
mt.byApi.set(e, t);
|
|
855
|
+
}, gt = (e) => mt.byApi.get(e), _t = () => {
|
|
856
|
+
mt.byApi.clear();
|
|
857
|
+
}, vt = {
|
|
680
858
|
runtime: { runPromiseExit: () => Promise.resolve(N.die(/* @__PURE__ */ Error("Voltro: mutations are not invokable during SSR"))) },
|
|
681
|
-
cache: new
|
|
682
|
-
client:
|
|
859
|
+
cache: new Qe(),
|
|
860
|
+
client: dt,
|
|
683
861
|
descriptors: {},
|
|
684
862
|
inspectBaseUrl: "",
|
|
685
|
-
errorBus: new
|
|
686
|
-
|
|
863
|
+
errorBus: new rt(),
|
|
864
|
+
recovery: new ot("ssr")
|
|
865
|
+
}, yt = {
|
|
687
866
|
get: (e) => {
|
|
688
|
-
let t =
|
|
689
|
-
return t === void 0 ?
|
|
690
|
-
...
|
|
867
|
+
let t = gt(e);
|
|
868
|
+
return t === void 0 ? vt : {
|
|
869
|
+
...vt,
|
|
691
870
|
descriptors: t
|
|
692
871
|
};
|
|
693
872
|
},
|
|
694
873
|
names: []
|
|
695
|
-
},
|
|
696
|
-
|
|
697
|
-
},
|
|
698
|
-
let e = te(
|
|
699
|
-
return e ? (
|
|
700
|
-
|
|
701
|
-
}, 0)),
|
|
702
|
-
},
|
|
703
|
-
let t =
|
|
874
|
+
}, bt = !1, xt = !1, K = null, St = () => {
|
|
875
|
+
bt = !1, xt = !1, K !== null && (clearTimeout(K), K = null);
|
|
876
|
+
}, Ct = () => {
|
|
877
|
+
let e = te(lt);
|
|
878
|
+
return e ? (xt || (xt = !0, K !== null && (clearTimeout(K), K = null)), e) : (typeof window < "u" && !bt && !xt && K === null && process.env.NODE_ENV !== "production" && (K = setTimeout(() => {
|
|
879
|
+
K = null, !(bt || xt) && (bt = !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>."));
|
|
880
|
+
}, 0)), yt);
|
|
881
|
+
}, q = (e) => {
|
|
882
|
+
let t = Ct(), n = t.demand;
|
|
704
883
|
return E(() => {
|
|
705
884
|
n?.(e);
|
|
706
885
|
}, [n, e]), t.get(e);
|
|
707
|
-
},
|
|
886
|
+
}, wt = (e) => typeof e.runtime?.runFork != "function", Tt = (e, t, n) => {
|
|
887
|
+
try {
|
|
888
|
+
let r = typeof globalThis.location == "object" ? globalThis.location.href : void 0, i = new URL(e, r);
|
|
889
|
+
if (i.protocol === "wss:" ? i.protocol = "https:" : i.protocol === "ws:" && (i.protocol = "http:"), n !== void 0) return new URL(n, i).toString();
|
|
890
|
+
let a = `/ws/${t}`;
|
|
891
|
+
if (i.pathname === a) i.pathname = `/_voltro/api/${encodeURIComponent(t)}/_voltro/runtime-capabilities`;
|
|
892
|
+
else {
|
|
893
|
+
let e = i.pathname.lastIndexOf("/");
|
|
894
|
+
i.pathname = `${e <= 0 ? "" : i.pathname.slice(0, e)}/_voltro/runtime-capabilities`;
|
|
895
|
+
}
|
|
896
|
+
return i.search = "", i.hash = "", i.toString();
|
|
897
|
+
} catch {
|
|
898
|
+
return;
|
|
899
|
+
}
|
|
900
|
+
}, Et = async (e, t, n = fetch, r = 1500, i) => {
|
|
901
|
+
let a = Tt(e, t, i);
|
|
902
|
+
if (a === void 0) return;
|
|
903
|
+
let o = new AbortController(), s = setTimeout(() => o.abort(), r);
|
|
904
|
+
try {
|
|
905
|
+
let e = await n(a, {
|
|
906
|
+
method: "GET",
|
|
907
|
+
headers: { accept: "application/json" },
|
|
908
|
+
cache: "no-store",
|
|
909
|
+
signal: o.signal
|
|
910
|
+
});
|
|
911
|
+
if (!e.ok) return;
|
|
912
|
+
let t = await e.json();
|
|
913
|
+
return t.protocol !== 1 || typeof t.mutationReplay != "boolean" ? void 0 : {
|
|
914
|
+
protocol: 1,
|
|
915
|
+
mutationReplay: t.mutationReplay
|
|
916
|
+
};
|
|
917
|
+
} catch {
|
|
918
|
+
return;
|
|
919
|
+
} finally {
|
|
920
|
+
clearTimeout(s);
|
|
921
|
+
}
|
|
922
|
+
}, Dt = (e, t) => B.Socket.of({
|
|
708
923
|
...e,
|
|
709
924
|
runRaw: (n, r) => e.runRaw(n, {
|
|
710
925
|
...r,
|
|
711
926
|
onOpen: M.zipRight(r?.onOpen ?? M.void, M.sync(t))
|
|
712
927
|
})
|
|
713
|
-
}),
|
|
928
|
+
}), Ot = async (e) => {
|
|
714
929
|
let { name: t, wsUrl: n, group: r, headers: i, webSocketConstructor: a } = e, o = e.generation ?? 0;
|
|
715
|
-
|
|
716
|
-
let s = e.errorBus ?? new
|
|
930
|
+
W(t, "runtime.build-started", { generation: o });
|
|
931
|
+
let s = e.errorBus ?? new rt(), c = e.recovery ?? ct(s, t);
|
|
932
|
+
Et(n, t, fetch, 1500, c.options.capabilitiesUrl).then((e) => {
|
|
933
|
+
c.setMutationReplaySupported(e?.mutationReplay === !0, o), W(t, "runtime.capabilities", {
|
|
934
|
+
mutationReplay: e?.mutationReplay === !0,
|
|
935
|
+
discovered: e !== void 0
|
|
936
|
+
});
|
|
937
|
+
});
|
|
938
|
+
let l = new Ze({
|
|
717
939
|
errorBus: s,
|
|
718
940
|
apiName: t
|
|
719
|
-
}),
|
|
720
|
-
class
|
|
721
|
-
let
|
|
941
|
+
}), u;
|
|
942
|
+
class d extends re.Tag(`@voltro/client/AppClient/${t}`)() {}
|
|
943
|
+
let f = F.succeed(B.WebSocketConstructor, a), p = B.layerWebSocket(n).pipe(F.provide(f)), m = F.effect(B.Socket, M.map(B.Socket, (e) => Dt(e, () => {
|
|
722
944
|
let e = 0;
|
|
723
|
-
|
|
945
|
+
u !== void 0 && (e = l.resumeTransportFailures(u)), W(t, "protocol.ready", {
|
|
724
946
|
generation: o,
|
|
725
947
|
resumed: e
|
|
726
|
-
});
|
|
727
|
-
}))).pipe(F.provide(
|
|
728
|
-
|
|
948
|
+
}), c.protocolReady();
|
|
949
|
+
}))).pipe(F.provide(p)), h = se.layerProtocolSocket().pipe(F.provide(le.layerJson), F.provide(m)), g = typeof i == "function" ? await i() : i, _ = F.scoped(d, se.make(r)).pipe(F.provide(h)), v = g ? F.locallyScoped(se.currentHeaders, oe.fromInput(g)) : F.empty, y = I.make(F.merge(_, v));
|
|
950
|
+
u = y;
|
|
729
951
|
try {
|
|
730
|
-
let e = await
|
|
731
|
-
return
|
|
732
|
-
runtime:
|
|
952
|
+
let e = await y.runPromise(d);
|
|
953
|
+
return W(t, "runtime.resolved", { generation: o }), {
|
|
954
|
+
runtime: y,
|
|
733
955
|
client: e,
|
|
734
|
-
cache:
|
|
735
|
-
errorBus: s
|
|
956
|
+
cache: l,
|
|
957
|
+
errorBus: s,
|
|
958
|
+
recovery: c
|
|
736
959
|
};
|
|
737
960
|
} catch (e) {
|
|
738
|
-
throw
|
|
961
|
+
throw W(t, "runtime.failed", {
|
|
739
962
|
generation: o,
|
|
740
963
|
errorName: e instanceof Error ? e.name : typeof e
|
|
741
|
-
}),
|
|
964
|
+
}), y.dispose(), e;
|
|
742
965
|
}
|
|
743
|
-
},
|
|
966
|
+
}, kt = (e) => Math.min(500 * 2 ** Math.min(e - 1, 4), 5e3), At = (e, t, n) => ({
|
|
744
967
|
resolved: null,
|
|
745
968
|
retryToken: 0,
|
|
746
969
|
failureCount: 0,
|
|
@@ -749,16 +972,23 @@ var _e = /* @__PURE__ */ new Set(), ve = (e) => {
|
|
|
749
972
|
everOpened: !1,
|
|
750
973
|
wedgeStop: null,
|
|
751
974
|
subjectMayHaveChanged: !1,
|
|
752
|
-
errorBus: e
|
|
753
|
-
|
|
975
|
+
errorBus: e,
|
|
976
|
+
recovery: t,
|
|
977
|
+
stopRecoveryError: e.on((e) => t.observeError(e)),
|
|
978
|
+
stopRecoverySuccess: e.onSuccess((e) => t.observeSuccess(e)),
|
|
979
|
+
ownsRecovery: n
|
|
980
|
+
}), jt = (e) => {
|
|
754
981
|
e.wedgeStop !== null && (e.wedgeStop(), e.wedgeStop = null);
|
|
755
|
-
},
|
|
982
|
+
}, Mt = (e) => {
|
|
756
983
|
e.cache.destroy(e.runtime), e.runtime.dispose();
|
|
757
|
-
},
|
|
758
|
-
let t = e.apis, n = e.buildClient, r = e.onChange, i = e.retryDelayMs ??
|
|
984
|
+
}, Nt = (e) => {
|
|
985
|
+
let t = e.apis, n = e.buildClient, r = e.onChange, i = e.retryDelayMs ?? kt, a = e.stableWindowMs ?? 5e3, o = e.scheduler?.setTimeout ?? ((e, t) => setTimeout(e, t)), s = e.scheduler?.clearTimeout ?? ((e) => {
|
|
759
986
|
clearTimeout(e);
|
|
760
987
|
}), c = e.scheduler?.queueMicrotask ?? queueMicrotask, l = e.onReconnecting, u = e.wedgeBackstop, d = /* @__PURE__ */ new Map();
|
|
761
|
-
for (let n of t)
|
|
988
|
+
for (let n of t) {
|
|
989
|
+
let t = e.errorBusFor?.(n.name) ?? new rt(), r = e.recoveryFor?.(n.name, n.recovery), i = r ?? new ot(n.name, n.recovery);
|
|
990
|
+
d.set(n.name, At(t, i, r === void 0));
|
|
991
|
+
}
|
|
762
992
|
let f = !1, p = /* @__PURE__ */ new Set(), m = (e, t) => {
|
|
763
993
|
let n = o(() => {
|
|
764
994
|
p.delete(n), e();
|
|
@@ -775,7 +1005,7 @@ var _e = /* @__PURE__ */ new Set(), ve = (e) => {
|
|
|
775
1005
|
if (!t) return;
|
|
776
1006
|
t.failureCount += 1;
|
|
777
1007
|
let n = i(t.failureCount);
|
|
778
|
-
|
|
1008
|
+
W(e.name, "socket.retry-scheduled", {
|
|
779
1009
|
generation: t.generation,
|
|
780
1010
|
attempt: t.failureCount,
|
|
781
1011
|
delayMs: n
|
|
@@ -790,27 +1020,27 @@ var _e = /* @__PURE__ */ new Set(), ve = (e) => {
|
|
|
790
1020
|
if (!t) return;
|
|
791
1021
|
let r = t.generation, i = () => {
|
|
792
1022
|
if (f || t.generation !== r) return;
|
|
793
|
-
t.everOpened = !0,
|
|
1023
|
+
t.everOpened = !0, jt(t), t.retryToken++;
|
|
794
1024
|
let e = t.failureCount;
|
|
795
1025
|
m(() => {
|
|
796
1026
|
f || t.failureCount === e && (t.failureCount = 0);
|
|
797
1027
|
}, a);
|
|
798
1028
|
}, o = (n) => {
|
|
799
|
-
f || t.generation !== r || g(e);
|
|
1029
|
+
f || t.generation !== r || (t.recovery.transportIssue(), g(e));
|
|
800
1030
|
};
|
|
801
1031
|
try {
|
|
802
|
-
let a = await n(e, r, i, o, t.errorBus);
|
|
1032
|
+
let a = await n(e, r, i, o, t.errorBus, t.recovery);
|
|
803
1033
|
if (f || t.generation !== r) {
|
|
804
|
-
|
|
1034
|
+
Mt(a);
|
|
805
1035
|
return;
|
|
806
1036
|
}
|
|
807
1037
|
let s = t.resolved, c = t.subjectMayHaveChanged, l = s && !c ? a.cache.seedStaleFrom(s.cache) : 0;
|
|
808
|
-
t.subjectMayHaveChanged = !1, t.resolved = a,
|
|
1038
|
+
t.subjectMayHaveChanged = !1, t.resolved = a, W(e.name, "runtime.swapped", {
|
|
809
1039
|
generation: r,
|
|
810
1040
|
replaced: s !== null,
|
|
811
1041
|
seeded: l,
|
|
812
1042
|
subjectMayHaveChanged: c
|
|
813
|
-
}), t.reconnectStatusDispose &&= (t.reconnectStatusDispose(), null), h(), s &&
|
|
1043
|
+
}), t.reconnectStatusDispose &&= (t.reconnectStatusDispose(), null), h(), s && Mt(s);
|
|
814
1044
|
} catch {
|
|
815
1045
|
if (f || t.generation !== r) return;
|
|
816
1046
|
g(e);
|
|
@@ -818,7 +1048,7 @@ var _e = /* @__PURE__ */ new Set(), ve = (e) => {
|
|
|
818
1048
|
}, v = (e) => {
|
|
819
1049
|
if (!f) for (let n of t) {
|
|
820
1050
|
let t = d.get(n.name);
|
|
821
|
-
t && (e && (t.subjectMayHaveChanged = !0), t.retryToken += 1, t.generation += 1, t.failureCount = 0,
|
|
1051
|
+
t && (e && (t.subjectMayHaveChanged = !0), t.retryToken += 1, t.generation += 1, e && t.recovery.resetForSubjectChange(t.generation), t.failureCount = 0, jt(t), _(n));
|
|
822
1052
|
}
|
|
823
1053
|
};
|
|
824
1054
|
return t.length === 0 ? (r(/* @__PURE__ */ new Map(), !0), {
|
|
@@ -835,8 +1065,8 @@ var _e = /* @__PURE__ */ new Set(), ve = (e) => {
|
|
|
835
1065
|
f = !0;
|
|
836
1066
|
for (let e of p) s(e);
|
|
837
1067
|
p.clear();
|
|
838
|
-
for (let [, e] of d) e.resolved &&
|
|
839
|
-
for (let e of t)
|
|
1068
|
+
for (let [, e] of d) e.resolved && Mt(e.resolved), e.reconnectStatusDispose && e.reconnectStatusDispose(), jt(e), e.stopRecoveryError(), e.stopRecoverySuccess(), e.ownsRecovery && e.recovery.dispose();
|
|
1069
|
+
for (let e of t) W(e.name, "runtime.disposed");
|
|
840
1070
|
d.clear();
|
|
841
1071
|
}
|
|
842
1072
|
},
|
|
@@ -847,7 +1077,7 @@ var _e = /* @__PURE__ */ new Set(), ve = (e) => {
|
|
|
847
1077
|
v(!1);
|
|
848
1078
|
}
|
|
849
1079
|
});
|
|
850
|
-
},
|
|
1080
|
+
}, Pt = ({ apis: e, children: t, demand: n }) => {
|
|
851
1081
|
let r = D(() => ({
|
|
852
1082
|
get: (t) => {
|
|
853
1083
|
let n = e.get(t);
|
|
@@ -860,45 +1090,45 @@ var _e = /* @__PURE__ */ new Set(), ve = (e) => {
|
|
|
860
1090
|
names: Array.from(e.keys()),
|
|
861
1091
|
...n === void 0 ? {} : { demand: n }
|
|
862
1092
|
}), [e]);
|
|
863
|
-
return /* @__PURE__ */ pe(
|
|
1093
|
+
return /* @__PURE__ */ pe(lt.Provider, {
|
|
864
1094
|
value: r,
|
|
865
1095
|
children: t
|
|
866
1096
|
});
|
|
867
|
-
},
|
|
868
|
-
let e = globalThis, t = e[
|
|
1097
|
+
}, Ft = Symbol.for("@voltro/client/storeStorageProvider"), It = () => {
|
|
1098
|
+
let e = globalThis, t = e[Ft];
|
|
869
1099
|
if (t !== void 0) return t;
|
|
870
1100
|
let n = {
|
|
871
1101
|
provider: void 0,
|
|
872
1102
|
used: !1
|
|
873
1103
|
};
|
|
874
|
-
return e[
|
|
875
|
-
},
|
|
1104
|
+
return e[Ft] = n, n;
|
|
1105
|
+
}, Lt = (e) => {
|
|
876
1106
|
if (typeof window > "u") return null;
|
|
877
1107
|
try {
|
|
878
1108
|
return (e === "session" ? window.sessionStorage : window.localStorage) ?? null;
|
|
879
1109
|
} catch {
|
|
880
1110
|
return null;
|
|
881
1111
|
}
|
|
882
|
-
},
|
|
883
|
-
let t =
|
|
1112
|
+
}, Rt = (e) => {
|
|
1113
|
+
let t = It();
|
|
884
1114
|
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;
|
|
885
|
-
},
|
|
886
|
-
let t =
|
|
887
|
-
return t.used = !0, (t.provider ??
|
|
888
|
-
},
|
|
889
|
-
let e =
|
|
1115
|
+
}, zt = (e) => {
|
|
1116
|
+
let t = It();
|
|
1117
|
+
return t.used = !0, (t.provider ?? Lt)(e);
|
|
1118
|
+
}, Bt = () => {
|
|
1119
|
+
let e = It();
|
|
890
1120
|
e.provider = void 0, e.used = !1;
|
|
891
|
-
},
|
|
1121
|
+
}, Vt = (e, t) => {
|
|
892
1122
|
if (Object.is(e, t)) return !0;
|
|
893
1123
|
if (typeof e != "object" || typeof t != "object" || e === null || t === null || Array.isArray(e) !== Array.isArray(t)) return !1;
|
|
894
1124
|
let n = Object.keys(e), r = Object.keys(t);
|
|
895
1125
|
if (n.length !== r.length) return !1;
|
|
896
1126
|
for (let r of n) if (!Object.prototype.hasOwnProperty.call(t, r) || !Object.is(e[r], t[r])) return !1;
|
|
897
1127
|
return !0;
|
|
898
|
-
},
|
|
899
|
-
|
|
900
|
-
},
|
|
901
|
-
let r =
|
|
1128
|
+
}, Ht = 50, Ut = /* @__PURE__ */ new Set(), Wt = (e, t) => {
|
|
1129
|
+
Ut.has(e) || (Ut.add(e), console.warn(t));
|
|
1130
|
+
}, Gt = "\0global", Kt = null, qt = (e, t, n) => {
|
|
1131
|
+
let r = Kt?.() ?? null;
|
|
902
1132
|
if (r === null) return n;
|
|
903
1133
|
let i = n;
|
|
904
1134
|
for (let n of r.seeds) n.store === e && n.key === t && (i = {
|
|
@@ -906,9 +1136,9 @@ var _e = /* @__PURE__ */ new Set(), ve = (e) => {
|
|
|
906
1136
|
...n.value
|
|
907
1137
|
});
|
|
908
1138
|
return i;
|
|
909
|
-
},
|
|
1139
|
+
}, Jt = (e, t) => {
|
|
910
1140
|
let n = e(), r = /* @__PURE__ */ new Set(), i = 0, a = 0, o, s, c = () => {
|
|
911
|
-
if (i >=
|
|
1141
|
+
if (i >= Ht) throw i = 0, Error(`defineStore: notification depth exceeded ${Ht} — 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.`);
|
|
912
1142
|
i += 1;
|
|
913
1143
|
try {
|
|
914
1144
|
for (let e of [...r]) e();
|
|
@@ -929,20 +1159,20 @@ var _e = /* @__PURE__ */ new Set(), ve = (e) => {
|
|
|
929
1159
|
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}', () => { … })\`.`);
|
|
930
1160
|
if (--a, a > 0) return;
|
|
931
1161
|
let l = o, u = s;
|
|
932
|
-
o = void 0, s = void 0, !
|
|
1162
|
+
o = void 0, s = void 0, !Vt(l, n) && (t(l, n, u), c());
|
|
933
1163
|
},
|
|
934
1164
|
set: (e, r) => {
|
|
935
1165
|
let i = typeof e == "function" ? e(n) : {
|
|
936
1166
|
...n,
|
|
937
1167
|
...e
|
|
938
1168
|
};
|
|
939
|
-
if (
|
|
1169
|
+
if (Vt(i, n)) return;
|
|
940
1170
|
let o = n;
|
|
941
1171
|
n = i, !(a > 0) && (t(o, i, r), c());
|
|
942
1172
|
},
|
|
943
1173
|
reset: () => {
|
|
944
1174
|
let r = e();
|
|
945
|
-
if (
|
|
1175
|
+
if (Vt(r, n)) return;
|
|
946
1176
|
let i = n;
|
|
947
1177
|
n = r, !(a > 0) && (t(i, r, "reset"), c());
|
|
948
1178
|
},
|
|
@@ -950,51 +1180,51 @@ var _e = /* @__PURE__ */ new Set(), ve = (e) => {
|
|
|
950
1180
|
r.delete(e);
|
|
951
1181
|
})
|
|
952
1182
|
};
|
|
953
|
-
},
|
|
954
|
-
|
|
955
|
-
}),
|
|
956
|
-
|
|
957
|
-
},
|
|
958
|
-
let n =
|
|
1183
|
+
}, Yt = 200, Xt = [], Zt = /* @__PURE__ */ new Set(), Qt = [], $t = () => Qt, en = (e) => (Zt.add(e), () => {
|
|
1184
|
+
Zt.delete(e);
|
|
1185
|
+
}), tn = () => {
|
|
1186
|
+
Xt.length = 0, Qt = [];
|
|
1187
|
+
}, nn = (e, t) => {
|
|
1188
|
+
let n = Xt[e];
|
|
959
1189
|
if (n === void 0) return !1;
|
|
960
|
-
let r =
|
|
1190
|
+
let r = sn.get(n.store);
|
|
961
1191
|
if (r === void 0) return !1;
|
|
962
1192
|
let i = t === "before" ? n.prev : n.next;
|
|
963
|
-
|
|
1193
|
+
an = !0;
|
|
964
1194
|
try {
|
|
965
1195
|
r.set(() => i, n.key, `travel:${t}`);
|
|
966
1196
|
} finally {
|
|
967
|
-
|
|
1197
|
+
an = !1;
|
|
968
1198
|
}
|
|
969
1199
|
return !0;
|
|
970
|
-
},
|
|
971
|
-
|
|
972
|
-
for (let e of [...
|
|
973
|
-
},
|
|
974
|
-
|
|
975
|
-
})),
|
|
976
|
-
function
|
|
1200
|
+
}, rn = !1, an = !1, on = (e) => {
|
|
1201
|
+
Xt.push(e), Xt.length > Yt && Xt.shift(), Qt = [...Xt];
|
|
1202
|
+
for (let e of [...Zt]) e();
|
|
1203
|
+
}, sn = /* @__PURE__ */ new Map(), cn = /* @__PURE__ */ new Map(), ln = 0, un = !1, dn = /* @__PURE__ */ new Map(), fn = () => (un || (un = !0, queueMicrotask(() => {
|
|
1204
|
+
ln += 1, un = !1;
|
|
1205
|
+
})), ln), pn = mn(((/* @__PURE__ */ Error()).stack ?? "").split("\n")[1] ?? "") ?? "";
|
|
1206
|
+
function mn(e) {
|
|
977
1207
|
let t = e.trim().replace(/^at\s+/, ""), n = /\(([^()]+)\)\s*$/.exec(t)?.[1] ?? t;
|
|
978
1208
|
return n.length > 0 ? n : void 0;
|
|
979
1209
|
}
|
|
980
|
-
var
|
|
1210
|
+
var hn = () => {
|
|
981
1211
|
let e = (/* @__PURE__ */ Error()).stack;
|
|
982
1212
|
if (typeof e != "string") return "<unknown>";
|
|
983
1213
|
for (let t of e.split("\n").slice(1)) {
|
|
984
|
-
let e =
|
|
1214
|
+
let e = mn(t);
|
|
985
1215
|
if (e === void 0) continue;
|
|
986
1216
|
let n = e.replace(/:\d+:\d+$/, "");
|
|
987
|
-
if (
|
|
1217
|
+
if (pn === "" || n !== pn.replace(/:\d+:\d+$/, "")) return n;
|
|
988
1218
|
}
|
|
989
1219
|
return "<unknown>";
|
|
990
|
-
},
|
|
991
|
-
let r =
|
|
1220
|
+
}, gn = () => [...sn.values()], _n = (e, t, n) => {
|
|
1221
|
+
let r = hn(), i = fn(), a = sn.get(e);
|
|
992
1222
|
if (a !== void 0) {
|
|
993
|
-
let t =
|
|
1223
|
+
let t = cn.get(e) ?? "<unknown>", n = dn.get(e) === i;
|
|
994
1224
|
if (r !== "<unknown>" && r === t && !n) return a;
|
|
995
1225
|
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}`);
|
|
996
1226
|
}
|
|
997
|
-
let o = n?.persist, s = () =>
|
|
1227
|
+
let o = n?.persist, s = () => zt(o?.storage === "session" ? "session" : "local"), c = () => {
|
|
998
1228
|
let e = s();
|
|
999
1229
|
if (e === null || o === void 0) return;
|
|
1000
1230
|
let t;
|
|
@@ -1019,28 +1249,28 @@ var ln = () => {
|
|
|
1019
1249
|
t.setItem(o.key, JSON.stringify(n));
|
|
1020
1250
|
} catch {}
|
|
1021
1251
|
}, u = /* @__PURE__ */ new Map(), d = (n) => {
|
|
1022
|
-
let r = n ??
|
|
1252
|
+
let r = n ?? Gt, i = u.get(r);
|
|
1023
1253
|
if (i === void 0) {
|
|
1024
1254
|
let a = n;
|
|
1025
|
-
i =
|
|
1255
|
+
i = Jt(o !== void 0 && n === void 0 ? () => {
|
|
1026
1256
|
let e = t();
|
|
1027
1257
|
return f = e, {
|
|
1028
1258
|
...e,
|
|
1029
1259
|
...c() ?? {}
|
|
1030
1260
|
};
|
|
1031
1261
|
} : t, (t, n, r) => {
|
|
1032
|
-
if (o !== void 0 && a === void 0 && l(n), !
|
|
1262
|
+
if (o !== void 0 && a === void 0 && l(n), !rn && !an) {
|
|
1033
1263
|
let e = m(a);
|
|
1034
1264
|
e.steps.length = e.cursor, e.steps.push({
|
|
1035
1265
|
prev: t,
|
|
1036
1266
|
next: n
|
|
1037
1267
|
}), e.steps.length > h && e.steps.shift(), e.cursor = e.steps.length;
|
|
1038
1268
|
}
|
|
1039
|
-
|
|
1269
|
+
on({
|
|
1040
1270
|
store: e,
|
|
1041
1271
|
...a === void 0 ? {} : { key: a },
|
|
1042
1272
|
...r === void 0 ? {} : { label: r },
|
|
1043
|
-
...
|
|
1273
|
+
...rn || an ? { isUndo: !0 } : {},
|
|
1044
1274
|
prev: t,
|
|
1045
1275
|
next: n,
|
|
1046
1276
|
at: Date.now()
|
|
@@ -1049,7 +1279,7 @@ var ln = () => {
|
|
|
1049
1279
|
}
|
|
1050
1280
|
return i;
|
|
1051
1281
|
}, f, p = /* @__PURE__ */ new Map(), m = (e) => {
|
|
1052
|
-
let t = e ??
|
|
1282
|
+
let t = e ?? Gt, n = p.get(t);
|
|
1053
1283
|
return n === void 0 && (n = {
|
|
1054
1284
|
steps: [],
|
|
1055
1285
|
cursor: 0
|
|
@@ -1081,12 +1311,12 @@ var ln = () => {
|
|
|
1081
1311
|
let n = o.current;
|
|
1082
1312
|
if (n.has && Object.is(n.state, t)) return n.value;
|
|
1083
1313
|
let r = i.current(t), s = a.current, c = n.has && (s ? s(n.value, r) : Object.is(n.value, r));
|
|
1084
|
-
if (process.env.NODE_ENV !== "production" && s === void 0 && n.has && !c && typeof r == "object" && r &&
|
|
1314
|
+
if (process.env.NODE_ENV !== "production" && s === void 0 && n.has && !c && typeof r == "object" && r && Vt(n.value, r)) {
|
|
1085
1315
|
let t = !0;
|
|
1086
1316
|
try {
|
|
1087
1317
|
t = !Object.is(i.current(n.state), n.value);
|
|
1088
1318
|
} catch {}
|
|
1089
|
-
|
|
1319
|
+
Wt(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.`);
|
|
1090
1320
|
}
|
|
1091
1321
|
let l = c ? n.value : r;
|
|
1092
1322
|
return o.current = {
|
|
@@ -1103,7 +1333,7 @@ var ln = () => {
|
|
|
1103
1333
|
r,
|
|
1104
1334
|
c,
|
|
1105
1335
|
l
|
|
1106
|
-
]), p = T(() => s(r.get()), [r, s]), m = T(() => s(
|
|
1336
|
+
]), p = T(() => s(r.get()), [r, s]), m = T(() => s(qt(e, n?.key, n?.key === void 0 && f !== void 0 ? f : r.get())), [
|
|
1107
1337
|
r,
|
|
1108
1338
|
n?.key,
|
|
1109
1339
|
s
|
|
@@ -1121,11 +1351,11 @@ var ln = () => {
|
|
|
1121
1351
|
undo: (e) => {
|
|
1122
1352
|
let t = m(e);
|
|
1123
1353
|
if (t.cursor === 0) return !1;
|
|
1124
|
-
--t.cursor,
|
|
1354
|
+
--t.cursor, rn = !0;
|
|
1125
1355
|
try {
|
|
1126
1356
|
d(e).set(() => t.steps[t.cursor].prev, "undo");
|
|
1127
1357
|
} finally {
|
|
1128
|
-
|
|
1358
|
+
rn = !1;
|
|
1129
1359
|
}
|
|
1130
1360
|
return !0;
|
|
1131
1361
|
},
|
|
@@ -1133,11 +1363,11 @@ var ln = () => {
|
|
|
1133
1363
|
let t = m(e);
|
|
1134
1364
|
if (t.cursor >= t.steps.length) return !1;
|
|
1135
1365
|
let n = t.steps[t.cursor];
|
|
1136
|
-
t.cursor += 1,
|
|
1366
|
+
t.cursor += 1, rn = !0;
|
|
1137
1367
|
try {
|
|
1138
1368
|
d(e).set(() => n.next, "redo");
|
|
1139
1369
|
} finally {
|
|
1140
|
-
|
|
1370
|
+
rn = !1;
|
|
1141
1371
|
}
|
|
1142
1372
|
return !0;
|
|
1143
1373
|
},
|
|
@@ -1149,27 +1379,27 @@ var ln = () => {
|
|
|
1149
1379
|
release: (e) => {
|
|
1150
1380
|
u.delete(e), p.delete(e);
|
|
1151
1381
|
},
|
|
1152
|
-
keys: () => [...u.keys()].filter((e) => e !==
|
|
1382
|
+
keys: () => [...u.keys()].filter((e) => e !== Gt)
|
|
1153
1383
|
};
|
|
1154
|
-
return
|
|
1155
|
-
},
|
|
1156
|
-
|
|
1157
|
-
},
|
|
1158
|
-
|
|
1159
|
-
},
|
|
1160
|
-
let r =
|
|
1384
|
+
return sn.set(e, b), cn.set(e, r), dn.set(e, i), b;
|
|
1385
|
+
}, vn = () => {
|
|
1386
|
+
sn.clear(), cn.clear(), dn.clear(), Ut.clear();
|
|
1387
|
+
}, yn = () => ({ seeds: [] }), bn = (e) => {
|
|
1388
|
+
Kt = e;
|
|
1389
|
+
}, xn = (e, t, n) => {
|
|
1390
|
+
let r = Kt?.() ?? null;
|
|
1161
1391
|
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.)`);
|
|
1162
1392
|
r.seeds.push({
|
|
1163
1393
|
store: e.name,
|
|
1164
1394
|
...n?.key === void 0 ? {} : { key: n.key },
|
|
1165
1395
|
value: t
|
|
1166
1396
|
});
|
|
1167
|
-
},
|
|
1397
|
+
}, Sn = (e) => {
|
|
1168
1398
|
if (e !== void 0) for (let t of e) {
|
|
1169
|
-
let e =
|
|
1399
|
+
let e = sn.get(t.store);
|
|
1170
1400
|
e !== void 0 && e.set(t.value, t.key);
|
|
1171
1401
|
}
|
|
1172
|
-
},
|
|
1402
|
+
}, J = (e, t) => {
|
|
1173
1403
|
let n = t.split("."), r = e;
|
|
1174
1404
|
for (let e = 0; e < n.length; e++) {
|
|
1175
1405
|
let i = n[e];
|
|
@@ -1188,15 +1418,15 @@ var ln = () => {
|
|
|
1188
1418
|
}
|
|
1189
1419
|
if (typeof r != "function") throw Error(`@voltro/client: rpc tag ${JSON.stringify(t)} did not resolve to a callable method.`);
|
|
1190
1420
|
return r;
|
|
1191
|
-
},
|
|
1421
|
+
}, Cn = Object.freeze({
|
|
1192
1422
|
data: void 0,
|
|
1193
1423
|
revision: -1,
|
|
1194
1424
|
emittedAt: void 0,
|
|
1195
1425
|
error: void 0,
|
|
1196
1426
|
pendingPatches: 0
|
|
1197
|
-
}),
|
|
1198
|
-
function
|
|
1199
|
-
let i = r.skip === !0, { runtime: a, cache: o, client: s, descriptors: c } =
|
|
1427
|
+
}), wn = () => Cn;
|
|
1428
|
+
function Y(e, t, n = {}, r = {}) {
|
|
1429
|
+
let i = r.skip === !0, { runtime: a, cache: o, client: s, descriptors: c } = q(e), l = c[t]?.source, u = O(n);
|
|
1200
1430
|
u.current = n;
|
|
1201
1431
|
let d = O(s);
|
|
1202
1432
|
d.current = s;
|
|
@@ -1204,7 +1434,7 @@ function J(e, t, n = {}, r = {}) {
|
|
|
1204
1434
|
let e = u.current;
|
|
1205
1435
|
return {
|
|
1206
1436
|
queryKey: [t, e],
|
|
1207
|
-
fetch: () =>
|
|
1437
|
+
fetch: () => J(d.current, t)(e)
|
|
1208
1438
|
};
|
|
1209
1439
|
}, [t, f]), m = p.queryKey, h = T((e) => i ? () => {} : o.subscribe(p.queryKey, p.fetch, a, e, l === void 0 ? {} : { source: l }).unsubscribe, [
|
|
1210
1440
|
o,
|
|
@@ -1212,11 +1442,11 @@ function J(e, t, n = {}, r = {}) {
|
|
|
1212
1442
|
l,
|
|
1213
1443
|
i,
|
|
1214
1444
|
p
|
|
1215
|
-
]), g = T(() => i ?
|
|
1445
|
+
]), g = T(() => i ? Cn : o.peek(m), [
|
|
1216
1446
|
o,
|
|
1217
1447
|
i,
|
|
1218
1448
|
m
|
|
1219
|
-
]), _ = A(h, g,
|
|
1449
|
+
]), _ = A(h, g, wn), v = _.data !== void 0, y = v && (Array.isArray(_.data) ? _.data.length === 0 : _.data === null), b = {
|
|
1220
1450
|
revision: _.revision,
|
|
1221
1451
|
emittedAt: _.emittedAt,
|
|
1222
1452
|
error: _.error,
|
|
@@ -1273,35 +1503,35 @@ function J(e, t, n = {}, r = {}) {
|
|
|
1273
1503
|
}
|
|
1274
1504
|
//#endregion
|
|
1275
1505
|
//#region src/awaitResolvedApi.ts
|
|
1276
|
-
var
|
|
1277
|
-
if (!
|
|
1278
|
-
let r = Date.now() +
|
|
1279
|
-
for (; Date.now() < r;) if (await new Promise((e) => setTimeout(e, 16)), !
|
|
1280
|
-
throw Error(`Voltro: the api "${t}" did not resolve within ${
|
|
1281
|
-
},
|
|
1506
|
+
var Tn = 15e3, X = async (e, t, n) => {
|
|
1507
|
+
if (!wt(e.current)) return e.current;
|
|
1508
|
+
let r = Date.now() + Tn;
|
|
1509
|
+
for (; Date.now() < r;) if (await new Promise((e) => setTimeout(e, 16)), !wt(e.current)) return e.current;
|
|
1510
|
+
throw Error(`Voltro: the api "${t}" did not resolve within ${Tn}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.`);
|
|
1511
|
+
}, Z = async (e, t) => {
|
|
1282
1512
|
let n = await e.runPromiseExit(t);
|
|
1283
1513
|
if (N.isSuccess(n)) return n.value;
|
|
1284
1514
|
let r = j.squash(n.cause), i = j.failureOption(n.cause);
|
|
1285
|
-
throw xe(r, L.isSome(i) ?
|
|
1286
|
-
},
|
|
1287
|
-
|
|
1288
|
-
},
|
|
1289
|
-
|
|
1290
|
-
for (let e of
|
|
1515
|
+
throw xe(r, L.isSome(i) ? V(i.value, "handler") : "unknown");
|
|
1516
|
+
}, En = 100, Q = [], Dn = /* @__PURE__ */ new Set(), On = [], kn = () => {
|
|
1517
|
+
On = Q.slice();
|
|
1518
|
+
}, An = () => {
|
|
1519
|
+
kn();
|
|
1520
|
+
for (let e of Dn) try {
|
|
1291
1521
|
e();
|
|
1292
1522
|
} catch {}
|
|
1293
|
-
},
|
|
1523
|
+
}, jn = (e) => {
|
|
1294
1524
|
let t = {
|
|
1295
1525
|
...e,
|
|
1296
1526
|
status: "pending",
|
|
1297
1527
|
startedAt: Date.now()
|
|
1298
1528
|
};
|
|
1299
|
-
|
|
1300
|
-
},
|
|
1301
|
-
let n =
|
|
1529
|
+
Q.unshift(t), Q.length > En && (Q.length = En), An();
|
|
1530
|
+
}, Mn = (e, t) => {
|
|
1531
|
+
let n = Q.findIndex((t) => t.id === e);
|
|
1302
1532
|
if (n === -1) return;
|
|
1303
|
-
let r =
|
|
1304
|
-
|
|
1533
|
+
let r = Q[n], i = Date.now();
|
|
1534
|
+
Q[n] = t.status === "success" ? {
|
|
1305
1535
|
...r,
|
|
1306
1536
|
status: "success",
|
|
1307
1537
|
output: t.output,
|
|
@@ -1313,12 +1543,12 @@ var yn = 15e3, Y = async (e, t, n) => {
|
|
|
1313
1543
|
error: t.error,
|
|
1314
1544
|
settledAt: i,
|
|
1315
1545
|
durationMs: i - r.startedAt
|
|
1316
|
-
},
|
|
1317
|
-
},
|
|
1318
|
-
|
|
1319
|
-
}),
|
|
1320
|
-
|
|
1321
|
-
},
|
|
1546
|
+
}, An();
|
|
1547
|
+
}, Nn = () => On, Pn = (e) => (Dn.add(e), () => {
|
|
1548
|
+
Dn.delete(e);
|
|
1549
|
+
}), Fn = () => {
|
|
1550
|
+
Q.length !== 0 && (Q.length = 0, An());
|
|
1551
|
+
}, In = (e, t) => {
|
|
1322
1552
|
if (t === void 0 || typeof e != "object" || !e) return e;
|
|
1323
1553
|
try {
|
|
1324
1554
|
Object.defineProperty(e, "__voltroTraceId", {
|
|
@@ -1328,18 +1558,18 @@ var yn = 15e3, Y = async (e, t, n) => {
|
|
|
1328
1558
|
});
|
|
1329
1559
|
} catch {}
|
|
1330
1560
|
return e;
|
|
1331
|
-
},
|
|
1332
|
-
|
|
1333
|
-
},
|
|
1561
|
+
}, Ln, Rn = (e) => {
|
|
1562
|
+
Ln = e;
|
|
1563
|
+
}, zn = () => Ln, Bn = (e, t, n) => typeof e == "function" ? e(t, n) : e, Vn = 0, Hn = () => `mut_${++Vn}`, Un = 0, Wn = () => {
|
|
1334
1564
|
let e = typeof crypto < "u" ? crypto : void 0;
|
|
1335
|
-
return e && typeof e.randomUUID == "function" ? e.randomUUID() : `idem_${Date.now().toString(36)}_${
|
|
1336
|
-
},
|
|
1565
|
+
return e && typeof e.randomUUID == "function" ? e.randomUUID() : `idem_${Date.now().toString(36)}_${Un += 1}`;
|
|
1566
|
+
}, Gn = (e, t) => e.pipe(M.locallyWith(se.currentHeaders, (e) => oe.set(e, "idempotency-key", t))), Kn = (e, t) => ({
|
|
1337
1567
|
update: (n, r) => {
|
|
1338
1568
|
e.update(n, r, t);
|
|
1339
1569
|
},
|
|
1340
1570
|
forTag: (n, r) => e.forTag(n, r, t)
|
|
1341
|
-
}),
|
|
1342
|
-
let n =
|
|
1571
|
+
}), qn = (e, t) => {
|
|
1572
|
+
let n = q(e), { descriptors: r } = n, i = O(n);
|
|
1343
1573
|
i.current = n;
|
|
1344
1574
|
let a = r[t], o = a?.targets;
|
|
1345
1575
|
if (process.env.NODE_ENV !== "production") {
|
|
@@ -1349,24 +1579,25 @@ var yn = 15e3, Y = async (e, t, n) => {
|
|
|
1349
1579
|
let [s, c] = k(!1), [l, u] = k(void 0), [d, f] = k(void 0), p = O(null), m = O(!1), h = T(async (n, r) => {
|
|
1350
1580
|
let a = r?.onError !== void 0 || r?.notify?.error !== void 0, s = (e) => {
|
|
1351
1581
|
r?.onError?.(e, n);
|
|
1352
|
-
let t =
|
|
1353
|
-
t !== void 0 &&
|
|
1582
|
+
let t = Bn(r?.notify?.error, e, n);
|
|
1583
|
+
t !== void 0 && Ln?.error(t);
|
|
1354
1584
|
};
|
|
1355
1585
|
c(!0), u(void 0);
|
|
1356
1586
|
let l, d, h;
|
|
1357
1587
|
try {
|
|
1358
|
-
({runtime: l, cache: d, client: h} = await
|
|
1588
|
+
({runtime: l, cache: d, client: h} = await X(i, e, t));
|
|
1359
1589
|
} catch (e) {
|
|
1360
1590
|
if (c(!1), u(e), i.current.errorBus.emit({
|
|
1361
1591
|
source: "mutation",
|
|
1362
1592
|
tag: t,
|
|
1363
1593
|
error: e,
|
|
1364
|
-
kind: "client"
|
|
1594
|
+
kind: "client",
|
|
1595
|
+
outcome: "not-started"
|
|
1365
1596
|
}), a) return s(e);
|
|
1366
1597
|
throw e;
|
|
1367
1598
|
}
|
|
1368
|
-
let g =
|
|
1369
|
-
|
|
1599
|
+
let g = Hn(), _ = r?.idempotencyKey ?? Wn();
|
|
1600
|
+
jn({
|
|
1370
1601
|
id: g,
|
|
1371
1602
|
apiName: e,
|
|
1372
1603
|
tag: t,
|
|
@@ -1374,50 +1605,76 @@ var yn = 15e3, Y = async (e, t, n) => {
|
|
|
1374
1605
|
});
|
|
1375
1606
|
let v = p.current, y = m.current;
|
|
1376
1607
|
if (v) try {
|
|
1377
|
-
v(
|
|
1608
|
+
v(Kn(d, g), n);
|
|
1378
1609
|
} catch (e) {
|
|
1379
|
-
if (u(e), c(!1), d.revertByMutation(g),
|
|
1610
|
+
if (u(e), c(!1), d.revertByMutation(g), Mn(g, {
|
|
1380
1611
|
status: "error",
|
|
1381
1612
|
error: e
|
|
1382
1613
|
}), a) return s(e);
|
|
1383
1614
|
throw e;
|
|
1384
1615
|
}
|
|
1385
1616
|
else !y && o && o.length > 0 && d.autoApply(o, n, g);
|
|
1386
|
-
let b, x = !1;
|
|
1617
|
+
let b, x = !1, S, ee = Date.now();
|
|
1387
1618
|
try {
|
|
1388
|
-
let a =
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1619
|
+
let a = async (r, i, a) => {
|
|
1620
|
+
let o = J(i, t), s = M.currentSpan.pipe(M.tap((e) => M.sync(() => {
|
|
1621
|
+
b = e.traceId, ve({
|
|
1622
|
+
traceId: e.traceId,
|
|
1623
|
+
spanId: e.spanId,
|
|
1624
|
+
source: "mutation",
|
|
1625
|
+
tag: t
|
|
1626
|
+
});
|
|
1627
|
+
})), M.catchAll(() => M.void), M.zipRight(Gn(o(n), _))).pipe(M.withSpan(`client.mutation.${t}`, { attributes: {
|
|
1628
|
+
"voltro.api": e,
|
|
1629
|
+
"voltro.mutationId": g,
|
|
1630
|
+
"rpc.tag": t,
|
|
1631
|
+
"voltro.replay": a
|
|
1632
|
+
} }));
|
|
1633
|
+
return x = !0, Z(r, s);
|
|
1634
|
+
}, o;
|
|
1635
|
+
try {
|
|
1636
|
+
o = await a(l, h, !1);
|
|
1637
|
+
} catch (n) {
|
|
1638
|
+
let r = x ? V(n, "handler") : "client", s = In(n, b);
|
|
1639
|
+
r === "transport" && (i.current.errorBus.emit({
|
|
1392
1640
|
source: "mutation",
|
|
1393
|
-
tag: t
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1641
|
+
tag: t,
|
|
1642
|
+
error: s,
|
|
1643
|
+
kind: r,
|
|
1644
|
+
outcome: "unknown",
|
|
1645
|
+
...b === void 0 ? {} : { traceId: b }
|
|
1646
|
+
}), S = s);
|
|
1647
|
+
let c = i.current, l = c.recovery ?? ct(c.errorBus, e), u = r === "transport" ? l.reserveMutationReplay(ee) : void 0;
|
|
1648
|
+
if (u === void 0) throw s;
|
|
1649
|
+
try {
|
|
1650
|
+
if (!await l.waitForMutationReplaySupport(ee) || !await l.waitForProtocolReady(ee)) throw s;
|
|
1651
|
+
let n = await X(i, e, t);
|
|
1652
|
+
if (!u.isValid()) throw s;
|
|
1653
|
+
o = await a(n.runtime, n.client, !0);
|
|
1654
|
+
} finally {
|
|
1655
|
+
u.release();
|
|
1656
|
+
}
|
|
1657
|
+
}
|
|
1658
|
+
f(o), Mn(g, {
|
|
1403
1659
|
status: "success",
|
|
1404
|
-
output:
|
|
1660
|
+
output: o
|
|
1405
1661
|
}), i.current.errorBus.emitSuccess({
|
|
1406
1662
|
source: "mutation",
|
|
1407
1663
|
tag: t
|
|
1408
|
-
}), d.confirmByMutation(g), r?.onSuccess?.(
|
|
1409
|
-
let
|
|
1410
|
-
return
|
|
1664
|
+
}), d.confirmByMutation(g), r?.onSuccess?.(o, n);
|
|
1665
|
+
let s = Bn(r?.notify?.success, o, n);
|
|
1666
|
+
return s !== void 0 && Ln?.success(s), o;
|
|
1411
1667
|
} catch (e) {
|
|
1412
|
-
let n =
|
|
1413
|
-
if (u(n),
|
|
1668
|
+
let n = In(e, b);
|
|
1669
|
+
if (u(n), Mn(g, {
|
|
1414
1670
|
status: "error",
|
|
1415
1671
|
error: n
|
|
1416
|
-
}), d.revertByMutation(g), i.current.errorBus.emit({
|
|
1672
|
+
}), d.revertByMutation(g), Object.is(S, n) || i.current.errorBus.emit({
|
|
1417
1673
|
source: "mutation",
|
|
1418
1674
|
tag: t,
|
|
1419
1675
|
error: n,
|
|
1420
|
-
kind: x ?
|
|
1676
|
+
kind: x ? V(e, "handler") : "client",
|
|
1677
|
+
outcome: x && V(e, "handler") === "transport" ? "unknown" : x ? "known" : "not-started",
|
|
1421
1678
|
...b === void 0 ? {} : { traceId: b }
|
|
1422
1679
|
}), a) return s(n);
|
|
1423
1680
|
throw n;
|
|
@@ -1445,7 +1702,7 @@ var yn = 15e3, Y = async (e, t, n) => {
|
|
|
1445
1702
|
l,
|
|
1446
1703
|
d
|
|
1447
1704
|
]);
|
|
1448
|
-
},
|
|
1705
|
+
}, Jn = (e, t) => {
|
|
1449
1706
|
if (t === void 0 || typeof e != "object" || !e) return e;
|
|
1450
1707
|
try {
|
|
1451
1708
|
Object.defineProperty(e, "__voltroTraceId", {
|
|
@@ -1455,8 +1712,8 @@ var yn = 15e3, Y = async (e, t, n) => {
|
|
|
1455
1712
|
});
|
|
1456
1713
|
} catch {}
|
|
1457
1714
|
return e;
|
|
1458
|
-
},
|
|
1459
|
-
let n =
|
|
1715
|
+
}, Yn = (e, t, n) => typeof e == "function" ? e(t, n) : e, Xn = 0, Zn = () => `act_${++Xn}`, Qn = (e, t) => {
|
|
1716
|
+
let n = q(e), { descriptors: r } = n, i = O(n);
|
|
1460
1717
|
if (i.current = n, process.env.NODE_ENV !== "production") {
|
|
1461
1718
|
let n = r[t]?.kind;
|
|
1462
1719
|
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.`);
|
|
@@ -1464,8 +1721,8 @@ var yn = 15e3, Y = async (e, t, n) => {
|
|
|
1464
1721
|
let [a, o] = k(!1), [s, c] = k(void 0), [l, u] = k(void 0), d = T(async (n, r) => {
|
|
1465
1722
|
let a = r?.onError !== void 0 || r?.notify?.error !== void 0;
|
|
1466
1723
|
o(!0), c(void 0);
|
|
1467
|
-
let s =
|
|
1468
|
-
|
|
1724
|
+
let s = Zn(), l = r?.idempotencyKey ?? Wn();
|
|
1725
|
+
jn({
|
|
1469
1726
|
id: s,
|
|
1470
1727
|
apiName: e,
|
|
1471
1728
|
tag: t,
|
|
@@ -1473,44 +1730,45 @@ var yn = 15e3, Y = async (e, t, n) => {
|
|
|
1473
1730
|
});
|
|
1474
1731
|
let d, f = !1;
|
|
1475
1732
|
try {
|
|
1476
|
-
let { runtime: a, client: o } = await
|
|
1733
|
+
let { runtime: a, client: o } = await X(i, e, t), c = J(o, t), p = M.currentSpan.pipe(M.tap((e) => M.sync(() => {
|
|
1477
1734
|
d = e.traceId, ve({
|
|
1478
1735
|
traceId: e.traceId,
|
|
1479
1736
|
spanId: e.spanId,
|
|
1480
1737
|
source: "action",
|
|
1481
1738
|
tag: t
|
|
1482
1739
|
});
|
|
1483
|
-
})), M.catchAll(() => M.void), M.zipRight(
|
|
1740
|
+
})), M.catchAll(() => M.void), M.zipRight(Gn(c(n), l))).pipe(M.withSpan(`client.action.${t}`, { attributes: {
|
|
1484
1741
|
"voltro.api": e,
|
|
1485
1742
|
"voltro.actionId": s,
|
|
1486
1743
|
"rpc.tag": t
|
|
1487
1744
|
} }));
|
|
1488
1745
|
f = !0;
|
|
1489
|
-
let m = await
|
|
1490
|
-
u(m),
|
|
1746
|
+
let m = await Z(a, p);
|
|
1747
|
+
u(m), Mn(s, {
|
|
1491
1748
|
status: "success",
|
|
1492
1749
|
output: m
|
|
1493
1750
|
}), i.current.errorBus.emitSuccess({
|
|
1494
1751
|
source: "action",
|
|
1495
1752
|
tag: t
|
|
1496
1753
|
}), r?.onSuccess?.(m, n);
|
|
1497
|
-
let h =
|
|
1498
|
-
return h !== void 0 &&
|
|
1754
|
+
let h = Yn(r?.notify?.success, m, n);
|
|
1755
|
+
return h !== void 0 && zn()?.success(h), m;
|
|
1499
1756
|
} catch (e) {
|
|
1500
|
-
let o =
|
|
1501
|
-
if (c(o),
|
|
1757
|
+
let o = Jn(e, d);
|
|
1758
|
+
if (c(o), Mn(s, {
|
|
1502
1759
|
status: "error",
|
|
1503
1760
|
error: o
|
|
1504
1761
|
}), i.current.errorBus.emit({
|
|
1505
1762
|
source: "action",
|
|
1506
1763
|
tag: t,
|
|
1507
1764
|
error: o,
|
|
1508
|
-
kind: f ?
|
|
1765
|
+
kind: f ? V(e, "handler") : "client",
|
|
1766
|
+
outcome: f && V(e, "handler") === "transport" ? "unknown" : f ? "known" : "not-started",
|
|
1509
1767
|
...d === void 0 ? {} : { traceId: d }
|
|
1510
1768
|
}), a) {
|
|
1511
1769
|
r?.onError?.(o, n);
|
|
1512
|
-
let e =
|
|
1513
|
-
e !== void 0 &&
|
|
1770
|
+
let e = Yn(r?.notify?.error, o, n);
|
|
1771
|
+
e !== void 0 && zn()?.error(e);
|
|
1514
1772
|
return;
|
|
1515
1773
|
}
|
|
1516
1774
|
throw o;
|
|
@@ -1529,14 +1787,14 @@ var yn = 15e3, Y = async (e, t, n) => {
|
|
|
1529
1787
|
s,
|
|
1530
1788
|
l
|
|
1531
1789
|
]);
|
|
1532
|
-
},
|
|
1790
|
+
}, $n = C(void 0), er = (e) => w($n.Provider, { value: e.messages }, e.children), tr = () => te($n), nr = Symbol.for("voltro.client.formEngine"), rr = C(void 0), ir = (e, t) => {
|
|
1533
1791
|
let n = e;
|
|
1534
1792
|
for (let e of t.split(".")) {
|
|
1535
1793
|
if (typeof n != "object" || !n) return;
|
|
1536
1794
|
n = n[e];
|
|
1537
1795
|
}
|
|
1538
1796
|
return n;
|
|
1539
|
-
},
|
|
1797
|
+
}, ar = (e, t, n) => `vf-${e}-${t}-${n}`.replace(/[^a-zA-Z0-9_-]/g, "-"), or = {
|
|
1540
1798
|
isTouched: !1,
|
|
1541
1799
|
isBlurred: !1,
|
|
1542
1800
|
isDirty: !1,
|
|
@@ -1545,15 +1803,15 @@ var yn = 15e3, Y = async (e, t, n) => {
|
|
|
1545
1803
|
isValidating: !1,
|
|
1546
1804
|
errorMap: {},
|
|
1547
1805
|
errorSourceMap: {}
|
|
1548
|
-
},
|
|
1806
|
+
}, sr = (e, t) => {
|
|
1549
1807
|
let n = e.find((e) => e.name === t);
|
|
1550
1808
|
if (n !== void 0) return n;
|
|
1551
1809
|
let r = /^(.+?)\.\d+\.(.+)$/.exec(t);
|
|
1552
1810
|
if (r !== null) return e.find((e) => e.name === r[1] && e.widget === "array")?.item?.find((e) => e.name === r[2]);
|
|
1553
|
-
},
|
|
1554
|
-
let r =
|
|
1811
|
+
}, cr = (e, t, n) => {
|
|
1812
|
+
let r = q(e), a = O(void 0), o = typeof t == "function" ? t(a.current?.state?.values ?? n.defaults ?? {}) : t, s = O(o).current, c = qn(e, o), l = n.schema ?? r.descriptors[o]?.input;
|
|
1555
1813
|
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.`);
|
|
1556
|
-
let u = D(() => l ? x(l) : [], [l]), d =
|
|
1814
|
+
let u = D(() => l ? x(l) : [], [l]), d = tr(), f = n.messages ?? d, p = D(() => ({
|
|
1557
1815
|
...n.locale === void 0 ? {} : { locale: n.locale },
|
|
1558
1816
|
...f === void 0 ? {} : { messages: f }
|
|
1559
1817
|
}), [n.locale, f]), m = O(n.asyncFields);
|
|
@@ -1580,7 +1838,7 @@ var yn = 15e3, Y = async (e, t, n) => {
|
|
|
1580
1838
|
let o = n.errorPath ?? {};
|
|
1581
1839
|
return a.map((t) => {
|
|
1582
1840
|
let n = o[t.path];
|
|
1583
|
-
return n === void 0 ? (
|
|
1841
|
+
return n === void 0 ? (ir(e, t.path) !== void 0 || t.path.includes("."), t) : {
|
|
1584
1842
|
...t,
|
|
1585
1843
|
path: n
|
|
1586
1844
|
};
|
|
@@ -1657,7 +1915,7 @@ var yn = 15e3, Y = async (e, t, n) => {
|
|
|
1657
1915
|
return delete n[e], n;
|
|
1658
1916
|
});
|
|
1659
1917
|
}, []), pe = T((t) => {
|
|
1660
|
-
let n =
|
|
1918
|
+
let n = sr(u, t), r = N.getFieldMeta(t), i = ue(t), a = ar(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);
|
|
1661
1919
|
return {
|
|
1662
1920
|
value: N.getFieldValue(t),
|
|
1663
1921
|
setValue: (e) => {
|
|
@@ -1665,7 +1923,7 @@ var yn = 15e3, Y = async (e, t, n) => {
|
|
|
1665
1923
|
},
|
|
1666
1924
|
onBlur: () => {
|
|
1667
1925
|
N.setFieldMeta(t, (e) => ({
|
|
1668
|
-
|
|
1926
|
+
...or,
|
|
1669
1927
|
...e ?? {},
|
|
1670
1928
|
isTouched: !0,
|
|
1671
1929
|
isBlurred: !0
|
|
@@ -1721,7 +1979,7 @@ var yn = 15e3, Y = async (e, t, n) => {
|
|
|
1721
1979
|
for (let [t, n] of Object.entries(e)) N.setFieldValue(t, n);
|
|
1722
1980
|
}, [N]), be = T((e) => {
|
|
1723
1981
|
S({}), w(void 0), ne(void 0), A.current = void 0, e === void 0 ? N.reset() : N.reset(re(e));
|
|
1724
|
-
}, [N, re]), xe = n.asyncTimeoutMs ?? 5e3,
|
|
1982
|
+
}, [N, re]), xe = n.asyncTimeoutMs ?? 5e3, V = T(async () => {
|
|
1725
1983
|
let e = Date.now();
|
|
1726
1984
|
for (;;) {
|
|
1727
1985
|
let t = m.current;
|
|
@@ -1740,12 +1998,12 @@ var yn = 15e3, Y = async (e, t, n) => {
|
|
|
1740
1998
|
}, _.current)]));
|
|
1741
1999
|
await new Promise((e) => setTimeout(e, 50));
|
|
1742
2000
|
}
|
|
1743
|
-
}, [xe]),
|
|
2001
|
+
}, [xe]), Se = T(() => {
|
|
1744
2002
|
let t = globalThis.document;
|
|
1745
2003
|
if (t?.getElementById === void 0) return;
|
|
1746
2004
|
let n = [...u.map((e) => e.name), ...Object.keys(y).filter((e) => !u.some((t) => t.name === e))];
|
|
1747
2005
|
for (let r of n) if (ue(r) !== void 0) {
|
|
1748
|
-
t.getElementById(
|
|
2006
|
+
t.getElementById(ar(e, s, r))?.focus?.();
|
|
1749
2007
|
return;
|
|
1750
2008
|
}
|
|
1751
2009
|
}, [
|
|
@@ -1754,16 +2012,16 @@ var yn = 15e3, Y = async (e, t, n) => {
|
|
|
1754
2012
|
u,
|
|
1755
2013
|
y,
|
|
1756
2014
|
ue
|
|
1757
|
-
]),
|
|
1758
|
-
|
|
1759
|
-
let
|
|
2015
|
+
]), H = O(Se);
|
|
2016
|
+
H.current = Se;
|
|
2017
|
+
let Ce = T(async () => {
|
|
1760
2018
|
w(void 0), S({}), ne(void 0), A.current = void 0;
|
|
1761
2019
|
let e, t = !1;
|
|
1762
2020
|
if (await N.handleSubmit().catch((n) => {
|
|
1763
2021
|
t = !0, e = n;
|
|
1764
2022
|
}), t) throw e;
|
|
1765
2023
|
return A.current === void 0 && queueMicrotask(() => {
|
|
1766
|
-
|
|
2024
|
+
H.current();
|
|
1767
2025
|
}), A.current;
|
|
1768
2026
|
}, [N]);
|
|
1769
2027
|
ie.current = (async (e) => {
|
|
@@ -1776,7 +2034,7 @@ var yn = 15e3, Y = async (e, t, n) => {
|
|
|
1776
2034
|
}
|
|
1777
2035
|
if (j(n).length > 0) {
|
|
1778
2036
|
queueMicrotask(() => {
|
|
1779
|
-
|
|
2037
|
+
H.current();
|
|
1780
2038
|
});
|
|
1781
2039
|
return;
|
|
1782
2040
|
}
|
|
@@ -1785,13 +2043,13 @@ var yn = 15e3, Y = async (e, t, n) => {
|
|
|
1785
2043
|
let e = ee(i, r);
|
|
1786
2044
|
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;
|
|
1787
2045
|
}
|
|
1788
|
-
let a = await
|
|
2046
|
+
let a = await V();
|
|
1789
2047
|
if (a !== void 0) {
|
|
1790
2048
|
S((e) => ({
|
|
1791
2049
|
...e,
|
|
1792
2050
|
...a
|
|
1793
2051
|
})), queueMicrotask(() => {
|
|
1794
|
-
|
|
2052
|
+
H.current();
|
|
1795
2053
|
});
|
|
1796
2054
|
return;
|
|
1797
2055
|
}
|
|
@@ -1819,141 +2077,141 @@ var yn = 15e3, Y = async (e, t, n) => {
|
|
|
1819
2077
|
...e,
|
|
1820
2078
|
...n
|
|
1821
2079
|
})), queueMicrotask(() => {
|
|
1822
|
-
|
|
2080
|
+
H.current();
|
|
1823
2081
|
});
|
|
1824
2082
|
}
|
|
1825
2083
|
});
|
|
1826
|
-
let
|
|
2084
|
+
let we = L.length === 0, Te = Object.values(m.current ?? {}).some((e) => e.status === "checking"), Ee = te ?? c.error, U = Ee !== void 0 && de(Ee).length > 0 ? void 0 : Ee, De = Object.keys(fe).length, Oe = (() => {
|
|
1827
2085
|
for (let e of u) if (fe[e.name] !== void 0) return e.name;
|
|
1828
2086
|
let e = Object.keys(fe);
|
|
1829
2087
|
return e.length > 0 ? e[0] : void 0;
|
|
1830
|
-
})(),
|
|
2088
|
+
})(), ke = {
|
|
1831
2089
|
isDirty: !R && I.isDirty,
|
|
1832
2090
|
isPristine: I.isPristine,
|
|
1833
2091
|
isTouched: I.isTouched,
|
|
1834
|
-
isValid:
|
|
1835
|
-
isValidating:
|
|
1836
|
-
canSubmit:
|
|
2092
|
+
isValid: we,
|
|
2093
|
+
isValidating: Te,
|
|
2094
|
+
canSubmit: we && !Te && !I.isSubmitting && !R,
|
|
1837
2095
|
isSubmitting: I.isSubmitting,
|
|
1838
2096
|
isSubmitted: I.isSubmitted,
|
|
1839
2097
|
isSubmitSuccessful: I.isSubmitSuccessful && A.current !== void 0,
|
|
1840
2098
|
submissionAttempts: I.submissionAttempts,
|
|
1841
|
-
errorCount:
|
|
1842
|
-
firstInvalidPath:
|
|
2099
|
+
errorCount: De,
|
|
2100
|
+
firstInvalidPath: Oe,
|
|
1843
2101
|
pending: c.pending,
|
|
1844
2102
|
isLoading: R,
|
|
1845
|
-
submitError:
|
|
2103
|
+
submitError: U,
|
|
1846
2104
|
data: c.data
|
|
1847
|
-
},
|
|
2105
|
+
}, Ae = {
|
|
1848
2106
|
fields: u,
|
|
1849
2107
|
values: F,
|
|
1850
2108
|
errors: fe,
|
|
1851
2109
|
issues: L,
|
|
1852
|
-
isValid:
|
|
2110
|
+
isValid: we,
|
|
1853
2111
|
pending: c.pending,
|
|
1854
|
-
submitError:
|
|
2112
|
+
submitError: U,
|
|
1855
2113
|
formError: C,
|
|
1856
2114
|
data: c.data,
|
|
1857
2115
|
setValue: ve,
|
|
1858
2116
|
setValues: ye,
|
|
1859
2117
|
reset: be,
|
|
1860
|
-
submit:
|
|
2118
|
+
submit: Ce,
|
|
1861
2119
|
field: pe,
|
|
1862
2120
|
array: ge,
|
|
1863
2121
|
section: _e,
|
|
1864
|
-
state:
|
|
1865
|
-
focusFirstInvalid:
|
|
2122
|
+
state: ke,
|
|
2123
|
+
focusFirstInvalid: Se
|
|
1866
2124
|
};
|
|
1867
|
-
return Object.defineProperty(
|
|
2125
|
+
return Object.defineProperty(Ae, nr, {
|
|
1868
2126
|
value: {
|
|
1869
2127
|
store: M.store,
|
|
1870
2128
|
field: pe
|
|
1871
2129
|
},
|
|
1872
2130
|
enumerable: !1
|
|
1873
|
-
}),
|
|
1874
|
-
},
|
|
1875
|
-
function
|
|
1876
|
-
let n = te(
|
|
2131
|
+
}), Ae;
|
|
2132
|
+
}, lr = (e) => w(rr.Provider, { value: e.binding }, e.children), ur = () => te(rr);
|
|
2133
|
+
function dr(e, t) {
|
|
2134
|
+
let n = te(rr), r = typeof e == "string" ? void 0 : e, i = typeof e == "string" ? e : t, a = r ?? n;
|
|
1877
2135
|
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.");
|
|
1878
|
-
let o = a[
|
|
2136
|
+
let o = a[nr];
|
|
1879
2137
|
if (o === void 0) throw Error("useFormField: not a useFormBinding result");
|
|
1880
2138
|
return he(o.store, (e) => {
|
|
1881
2139
|
let t = e.fieldMetaBase[i];
|
|
1882
|
-
return `${JSON.stringify(
|
|
2140
|
+
return `${JSON.stringify(ir(e.values, i))}|${t === void 0 ? "" : `${String(t.isTouched)}${String(t.isBlurred)}${JSON.stringify(t.errorMap)}`}|${e.submissionAttempts}`;
|
|
1883
2141
|
}), o.field(i);
|
|
1884
2142
|
}
|
|
1885
2143
|
//#endregion
|
|
1886
2144
|
//#region src/createHooks.ts
|
|
1887
|
-
var
|
|
1888
|
-
useSubscription: (t, n, r) =>
|
|
1889
|
-
useMutation: (t) =>
|
|
1890
|
-
useAction: (t) =>
|
|
1891
|
-
useFormBinding: (t, n) =>
|
|
1892
|
-
}),
|
|
1893
|
-
|
|
1894
|
-
},
|
|
1895
|
-
let i =
|
|
2145
|
+
var fr = Y, pr = (e) => ({
|
|
2146
|
+
useSubscription: (t, n, r) => fr(e, t, n, r),
|
|
2147
|
+
useMutation: (t) => qn(e, t),
|
|
2148
|
+
useAction: (t) => Qn(e, t),
|
|
2149
|
+
useFormBinding: (t, n) => cr(e, t, n ?? {})
|
|
2150
|
+
}), mr = () => ({ seeds: [] }), hr = null, gr = (e) => {
|
|
2151
|
+
hr = e;
|
|
2152
|
+
}, _r = /* @__PURE__ */ new Map(), vr = (e, t) => `${e}\u0000${t}`, yr = (e, t, n, r) => {
|
|
2153
|
+
let i = hr?.() ?? null;
|
|
1896
2154
|
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.)`);
|
|
1897
2155
|
i.seeds.push({
|
|
1898
2156
|
api: e,
|
|
1899
|
-
key:
|
|
2157
|
+
key: G([t, n]),
|
|
1900
2158
|
value: r
|
|
1901
2159
|
});
|
|
1902
|
-
},
|
|
1903
|
-
let r =
|
|
2160
|
+
}, br = (e, t, n) => {
|
|
2161
|
+
let r = hr?.() ?? null;
|
|
1904
2162
|
r !== null && r.seeds.push({
|
|
1905
2163
|
api: e,
|
|
1906
|
-
key:
|
|
2164
|
+
key: G([t, n]),
|
|
1907
2165
|
value: void 0,
|
|
1908
2166
|
failed: !0
|
|
1909
2167
|
});
|
|
1910
|
-
},
|
|
1911
|
-
if (e !== void 0) for (let t of e)
|
|
2168
|
+
}, xr = (e) => {
|
|
2169
|
+
if (e !== void 0) for (let t of e) _r.set(vr(t.api, t.key), {
|
|
1912
2170
|
value: t.value,
|
|
1913
2171
|
failed: t.failed === !0
|
|
1914
2172
|
});
|
|
1915
|
-
},
|
|
1916
|
-
let r =
|
|
2173
|
+
}, Sr = (e, t, n) => {
|
|
2174
|
+
let r = G([t, n]), i = hr?.() ?? null;
|
|
1917
2175
|
if (i !== null) {
|
|
1918
2176
|
for (let t of i.seeds) if (t.api === e && t.key === r) return t.failed === !0 ? void 0 : t.value;
|
|
1919
2177
|
return;
|
|
1920
2178
|
}
|
|
1921
|
-
let a =
|
|
2179
|
+
let a = _r.get(vr(e, r));
|
|
1922
2180
|
return a === void 0 || a.failed ? void 0 : a.value;
|
|
1923
|
-
},
|
|
1924
|
-
let r =
|
|
2181
|
+
}, Cr = (e, t, n) => {
|
|
2182
|
+
let r = G([t, n]), i = hr?.() ?? null;
|
|
1925
2183
|
if (i !== null) {
|
|
1926
2184
|
for (let t of i.seeds) if (t.api === e && t.key === r) return t.failed === !0 ? "failed" : "seeded";
|
|
1927
2185
|
return "absent";
|
|
1928
2186
|
}
|
|
1929
|
-
let a =
|
|
2187
|
+
let a = _r.get(vr(e, r));
|
|
1930
2188
|
return a === void 0 ? "absent" : a.failed ? "failed" : "seeded";
|
|
1931
|
-
},
|
|
1932
|
-
|
|
2189
|
+
}, wr = () => {
|
|
2190
|
+
_r.clear();
|
|
1933
2191
|
};
|
|
1934
2192
|
//#endregion
|
|
1935
2193
|
//#region src/usePreloadedSubscription.ts
|
|
1936
|
-
function
|
|
1937
|
-
let i =
|
|
2194
|
+
function Tr(e, t, n = {}, r = {}) {
|
|
2195
|
+
let i = Sr(e, t, n), a = Y(e, t, n, i === void 0 ? r : {
|
|
1938
2196
|
...r,
|
|
1939
2197
|
initialSnapshot: i
|
|
1940
2198
|
});
|
|
1941
|
-
return
|
|
2199
|
+
return Cr(e, t, n) === "failed" ? {
|
|
1942
2200
|
...a,
|
|
1943
2201
|
preloadFailed: !0
|
|
1944
2202
|
} : a;
|
|
1945
2203
|
}
|
|
1946
2204
|
//#endregion
|
|
1947
2205
|
//#region src/useEvent.ts
|
|
1948
|
-
var
|
|
2206
|
+
var Er = {
|
|
1949
2207
|
status: "idle",
|
|
1950
2208
|
missed: 0,
|
|
1951
2209
|
lastMiss: void 0
|
|
1952
|
-
},
|
|
2210
|
+
}, Dr = class {
|
|
1953
2211
|
_tag = "EventStreamClosed";
|
|
1954
2212
|
};
|
|
1955
|
-
function
|
|
1956
|
-
let { skip: i = !1, apiName: a = "app", onMissed: o } = r, s =
|
|
2213
|
+
function Or(e, t, n, r = {}) {
|
|
2214
|
+
let { skip: i = !1, apiName: a = "app", onMissed: o } = r, s = q(a), { runtime: c, client: l } = s, [u, d] = k(Er), f = O(n);
|
|
1957
2215
|
f.current = n;
|
|
1958
2216
|
let p = O(o);
|
|
1959
2217
|
p.current = o;
|
|
@@ -1965,22 +2223,26 @@ function xr(e, t, n, r = {}) {
|
|
|
1965
2223
|
v.current = t;
|
|
1966
2224
|
let y = O(null);
|
|
1967
2225
|
y.current !== _ && (y.current = _, g.current = /* @__PURE__ */ new Map());
|
|
1968
|
-
let b = T((
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
missed:
|
|
2226
|
+
let b = T((t, n) => {
|
|
2227
|
+
t <= 0 || (W(a, "event.gap", {
|
|
2228
|
+
tag: e.name,
|
|
2229
|
+
missed: t,
|
|
2230
|
+
reason: n
|
|
2231
|
+
}), d((e) => ({
|
|
2232
|
+
...e,
|
|
2233
|
+
missed: e.missed + t,
|
|
1972
2234
|
lastMiss: {
|
|
1973
|
-
count:
|
|
1974
|
-
reason:
|
|
2235
|
+
count: t,
|
|
2236
|
+
reason: n
|
|
1975
2237
|
}
|
|
1976
2238
|
})), p.current?.({
|
|
1977
|
-
count:
|
|
1978
|
-
reason:
|
|
2239
|
+
count: t,
|
|
2240
|
+
reason: n
|
|
1979
2241
|
}));
|
|
1980
|
-
}, []), x = !i && _ !== null && !
|
|
2242
|
+
}, [a, e.name]), x = !i && _ !== null && !wt(s);
|
|
1981
2243
|
return E(() => {
|
|
1982
2244
|
if (!x) {
|
|
1983
|
-
d(
|
|
2245
|
+
d(Er);
|
|
1984
2246
|
return;
|
|
1985
2247
|
}
|
|
1986
2248
|
d((e) => ({
|
|
@@ -1992,13 +2254,13 @@ function xr(e, t, n, r = {}) {
|
|
|
1992
2254
|
origin: e,
|
|
1993
2255
|
n: t
|
|
1994
2256
|
}));
|
|
1995
|
-
return
|
|
2257
|
+
return J(m.current, e.name)({
|
|
1996
2258
|
key: v.current,
|
|
1997
2259
|
...t.length > 0 ? { resume: t } : {}
|
|
1998
2260
|
});
|
|
1999
2261
|
}), r = z.unwrap(n).pipe(z.tap(() => M.sync(() => {
|
|
2000
2262
|
t = 0;
|
|
2001
|
-
})), z.concat(z.fail(new
|
|
2263
|
+
})), z.concat(z.fail(new Dr())), z.retry(R.exponential("250 millis", 2).pipe(R.either(R.spaced("30 seconds")), R.jittered, R.tapOutput(() => M.sync(() => {
|
|
2002
2264
|
t += 1, d((e) => ({
|
|
2003
2265
|
...e,
|
|
2004
2266
|
status: "connecting"
|
|
@@ -2025,11 +2287,11 @@ function xr(e, t, n, r = {}) {
|
|
|
2025
2287
|
_,
|
|
2026
2288
|
e.name,
|
|
2027
2289
|
b
|
|
2028
|
-
]), x ? u :
|
|
2290
|
+
]), x ? u : Er;
|
|
2029
2291
|
}
|
|
2030
2292
|
//#endregion
|
|
2031
2293
|
//#region src/sequence.ts
|
|
2032
|
-
var
|
|
2294
|
+
var kr = () => {
|
|
2033
2295
|
let e = (t) => ({
|
|
2034
2296
|
steps: t,
|
|
2035
2297
|
step: ((n, r, i) => e([...t, {
|
|
@@ -2041,7 +2303,7 @@ var Sr = () => {
|
|
|
2041
2303
|
}]))
|
|
2042
2304
|
});
|
|
2043
2305
|
return e([]);
|
|
2044
|
-
},
|
|
2306
|
+
}, Ar = async (e, t = {}) => {
|
|
2045
2307
|
let n = {}, r = [];
|
|
2046
2308
|
for (let i of e.steps) {
|
|
2047
2309
|
if (i.when !== void 0 && !i.when(n)) {
|
|
@@ -2101,13 +2363,13 @@ var Sr = () => {
|
|
|
2101
2363
|
ok: !0,
|
|
2102
2364
|
data: n
|
|
2103
2365
|
};
|
|
2104
|
-
},
|
|
2366
|
+
}, jr = (e = {}) => {
|
|
2105
2367
|
let [t, n] = k(!1), [r, i] = k(void 0), [a, o] = k(void 0), s = O(e);
|
|
2106
2368
|
return s.current = e, {
|
|
2107
2369
|
run: T(async (e, t = {}) => {
|
|
2108
2370
|
n(!0), i(void 0), o(void 0);
|
|
2109
2371
|
try {
|
|
2110
|
-
let n = await
|
|
2372
|
+
let n = await Ar(e, {
|
|
2111
2373
|
...s.current,
|
|
2112
2374
|
...t
|
|
2113
2375
|
});
|
|
@@ -2120,7 +2382,7 @@ var Sr = () => {
|
|
|
2120
2382
|
error: r,
|
|
2121
2383
|
failedStep: a
|
|
2122
2384
|
};
|
|
2123
|
-
},
|
|
2385
|
+
}, Mr = "@voltro/plugin-storage", $ = (e) => fe(Mr, e), Nr = (e, t, n, r) => new Promise((i, a) => {
|
|
2124
2386
|
let o = new XMLHttpRequest();
|
|
2125
2387
|
if (o.open("PUT", e), o.upload.onprogress = (e) => {
|
|
2126
2388
|
e.lengthComputable && n(e.loaded / e.total);
|
|
@@ -2134,7 +2396,7 @@ var Sr = () => {
|
|
|
2134
2396
|
return;
|
|
2135
2397
|
}
|
|
2136
2398
|
r.addEventListener("abort", () => o.abort(), { once: !0 }), o.send(t);
|
|
2137
|
-
}),
|
|
2399
|
+
}), Pr = (e, t, n, r, i, a) => new Promise((o, s) => {
|
|
2138
2400
|
let c = new XMLHttpRequest();
|
|
2139
2401
|
if (c.open("POST", e), c.setRequestHeader("content-type", t), c.upload.onprogress = (e) => {
|
|
2140
2402
|
e.lengthComputable && r(e.loaded / e.total);
|
|
@@ -2152,7 +2414,7 @@ var Sr = () => {
|
|
|
2152
2414
|
return;
|
|
2153
2415
|
}
|
|
2154
2416
|
i.addEventListener("abort", () => c.abort(), { once: !0 }), c.send(n);
|
|
2155
|
-
}),
|
|
2417
|
+
}), Fr = (e, t, n, r, i) => new Promise((a, o) => {
|
|
2156
2418
|
let s = new XMLHttpRequest();
|
|
2157
2419
|
if (s.open("PUT", e), s.setRequestHeader("content-type", t), s.upload.onprogress = (e) => {
|
|
2158
2420
|
e.lengthComputable && r(e.loaded / e.total);
|
|
@@ -2163,7 +2425,7 @@ var Sr = () => {
|
|
|
2163
2425
|
return;
|
|
2164
2426
|
}
|
|
2165
2427
|
i.addEventListener("abort", () => s.abort(), { once: !0 }), s.send(n);
|
|
2166
|
-
}),
|
|
2428
|
+
}), Ir = (e, t, n, r, i) => new Promise((a, o) => {
|
|
2167
2429
|
let s = new XMLHttpRequest();
|
|
2168
2430
|
if (s.open("POST", e), s.setRequestHeader("content-type", t), s.upload.onprogress = (e) => {
|
|
2169
2431
|
e.lengthComputable && r(e.loaded / e.total);
|
|
@@ -2179,15 +2441,15 @@ var Sr = () => {
|
|
|
2179
2441
|
return;
|
|
2180
2442
|
}
|
|
2181
2443
|
i.addEventListener("abort", () => s.abort(), { once: !0 }), s.send(n);
|
|
2182
|
-
}),
|
|
2183
|
-
let n =
|
|
2444
|
+
}), Lr = (e, t = {}) => {
|
|
2445
|
+
let n = q(e), { inspectBaseUrl: r } = n, i = O(n);
|
|
2184
2446
|
i.current = n;
|
|
2185
2447
|
let [a, o] = k(0), [s, c] = k("idle"), [l, u] = k(void 0), d = O(null), f = T(() => {
|
|
2186
2448
|
o(0), c("idle"), u(void 0);
|
|
2187
2449
|
}, []), p = T(() => {
|
|
2188
2450
|
d.current?.abort();
|
|
2189
2451
|
}, []), m = T((e) => /^https?:\/\//.test(e) ? e : `${r}${e}`, [r]), h = T(async (n, r, a, o) => {
|
|
2190
|
-
let { runtime: s, client: c } = await
|
|
2452
|
+
let { runtime: s, client: c } = await X(i, e, "storage.upload").catch((e) => {
|
|
2191
2453
|
throw xe(e, "client");
|
|
2192
2454
|
}), 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, _ = {
|
|
2193
2455
|
...f ? { visibility: f } : {},
|
|
@@ -2204,28 +2466,28 @@ var Sr = () => {
|
|
|
2204
2466
|
...e.width === void 0 ? {} : { width: e.width },
|
|
2205
2467
|
...e.height === void 0 ? {} : { height: e.height }
|
|
2206
2468
|
}), y = async () => {
|
|
2207
|
-
let e = r.mintTag ?? t.mintTag ?? $("mintUploadTicket"), i =
|
|
2469
|
+
let e = r.mintTag ?? t.mintTag ?? $("mintUploadTicket"), i = J(c, e), l = await Z(s, i({
|
|
2208
2470
|
contentType: u,
|
|
2209
2471
|
..._,
|
|
2210
2472
|
...p ? { key: p } : {}
|
|
2211
|
-
})), d = await
|
|
2473
|
+
})), d = await Ir(m(l.uploadUrl), u, n, o, a);
|
|
2212
2474
|
return v(d);
|
|
2213
2475
|
}, b = async () => {
|
|
2214
2476
|
let e = r.presignMintTag ?? t.presignMintTag ?? $("mintPresignedUpload"), i = r.finalizeTag ?? t.finalizeTag ?? $("finalizeUpload"), l;
|
|
2215
2477
|
try {
|
|
2216
|
-
let t =
|
|
2217
|
-
l = await
|
|
2478
|
+
let t = J(c, e);
|
|
2479
|
+
l = await Z(s, t({
|
|
2218
2480
|
contentType: u,
|
|
2219
2481
|
..._
|
|
2220
2482
|
}));
|
|
2221
2483
|
} catch {
|
|
2222
2484
|
return null;
|
|
2223
2485
|
}
|
|
2224
|
-
await
|
|
2225
|
-
let d =
|
|
2486
|
+
await Fr(l.uploadUrl, u, n, o, a);
|
|
2487
|
+
let d = J(c, i), f = await Z(s, d({ finalizeToken: l.finalizeToken }));
|
|
2226
2488
|
return v(f);
|
|
2227
2489
|
}, x = async () => {
|
|
2228
|
-
let e = r.beginResumableTag ?? t.beginResumableTag ?? $("beginResumableUpload"), i =
|
|
2490
|
+
let e = r.beginResumableTag ?? t.beginResumableTag ?? $("beginResumableUpload"), i = J(c, e), l = n.size, d = r.chunkSize ?? t.chunkSize, f = await Z(s, i({
|
|
2229
2491
|
contentType: u,
|
|
2230
2492
|
size: l,
|
|
2231
2493
|
..._,
|
|
@@ -2236,7 +2498,7 @@ var Sr = () => {
|
|
|
2236
2498
|
for (;;) {
|
|
2237
2499
|
if (a.aborted) throw new DOMException("upload aborted", "AbortError");
|
|
2238
2500
|
try {
|
|
2239
|
-
let t = await
|
|
2501
|
+
let t = await Pr(`${p}?${`token=${encodeURIComponent(f.resumableToken)}&index=${e}${s ? "&final=1" : ""}`}`, u, i, (e) => o((b + e * c) / l), a, s);
|
|
2240
2502
|
s && (x = t);
|
|
2241
2503
|
break;
|
|
2242
2504
|
} catch (e) {
|
|
@@ -2250,8 +2512,8 @@ var Sr = () => {
|
|
|
2250
2512
|
}, S = async () => {
|
|
2251
2513
|
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;
|
|
2252
2514
|
try {
|
|
2253
|
-
let t =
|
|
2254
|
-
g = await
|
|
2515
|
+
let t = J(c, e);
|
|
2516
|
+
g = await Z(s, t({
|
|
2255
2517
|
contentType: u,
|
|
2256
2518
|
size: p,
|
|
2257
2519
|
..._,
|
|
@@ -2260,17 +2522,17 @@ var Sr = () => {
|
|
|
2260
2522
|
} catch {
|
|
2261
2523
|
return null;
|
|
2262
2524
|
}
|
|
2263
|
-
let v =
|
|
2525
|
+
let v = J(c, i), y = J(c, l), b = J(c, f), x = Math.max(1, g.partSize), S = Math.max(1, Math.ceil(p / x)), ee = Math.max(0, r.retries ?? t.retries ?? 1), C = [], w = 0;
|
|
2264
2526
|
try {
|
|
2265
2527
|
for (let e = 0; e < S; e++) {
|
|
2266
2528
|
let t = e * x, r = Math.min(p, t + x), i = n.slice(t, r), c = e + 1, l = r - t, u = 0;
|
|
2267
2529
|
for (;;) {
|
|
2268
2530
|
if (a.aborted) throw new DOMException("upload aborted", "AbortError");
|
|
2269
2531
|
try {
|
|
2270
|
-
let { url: e } = await
|
|
2532
|
+
let { url: e } = await Z(s, v({
|
|
2271
2533
|
multipartToken: g.multipartToken,
|
|
2272
2534
|
partNumber: c
|
|
2273
|
-
})), t = await
|
|
2535
|
+
})), t = await Nr(e, i, (e) => o((w + e * l) / p), a);
|
|
2274
2536
|
C.push({
|
|
2275
2537
|
partNumber: c,
|
|
2276
2538
|
etag: t
|
|
@@ -2282,7 +2544,7 @@ var Sr = () => {
|
|
|
2282
2544
|
}
|
|
2283
2545
|
w += l, o(w / p);
|
|
2284
2546
|
}
|
|
2285
|
-
let e = await
|
|
2547
|
+
let e = await Z(s, y({
|
|
2286
2548
|
multipartToken: g.multipartToken,
|
|
2287
2549
|
parts: C
|
|
2288
2550
|
}));
|
|
@@ -2295,7 +2557,7 @@ var Sr = () => {
|
|
|
2295
2557
|
};
|
|
2296
2558
|
} catch (e) {
|
|
2297
2559
|
try {
|
|
2298
|
-
await
|
|
2560
|
+
await Z(s, b({ multipartToken: g.multipartToken }));
|
|
2299
2561
|
} catch {}
|
|
2300
2562
|
throw e;
|
|
2301
2563
|
}
|
|
@@ -2345,7 +2607,8 @@ var Sr = () => {
|
|
|
2345
2607
|
source: "action",
|
|
2346
2608
|
tag: n.mintTag ?? t.mintTag ?? $("mintUploadTicket"),
|
|
2347
2609
|
error: e,
|
|
2348
|
-
kind:
|
|
2610
|
+
kind: V(e, "unknown"),
|
|
2611
|
+
outcome: V(e, "unknown") === "transport" ? "unknown" : "not-applicable"
|
|
2349
2612
|
}), e;
|
|
2350
2613
|
}
|
|
2351
2614
|
}, [h, t.mintTag]), _ = T(async (e, n = {}) => {
|
|
@@ -2368,7 +2631,8 @@ var Sr = () => {
|
|
|
2368
2631
|
source: "action",
|
|
2369
2632
|
tag: n.mintTag ?? t.mintTag ?? $("mintUploadTicket"),
|
|
2370
2633
|
error: e,
|
|
2371
|
-
kind:
|
|
2634
|
+
kind: V(e, "unknown"),
|
|
2635
|
+
outcome: V(e, "unknown") === "transport" ? "unknown" : "not-applicable"
|
|
2372
2636
|
}), e;
|
|
2373
2637
|
}
|
|
2374
2638
|
}, [
|
|
@@ -2411,8 +2675,8 @@ var Sr = () => {
|
|
|
2411
2675
|
y,
|
|
2412
2676
|
b
|
|
2413
2677
|
]);
|
|
2414
|
-
},
|
|
2415
|
-
let n =
|
|
2678
|
+
}, Rr = (e, t) => {
|
|
2679
|
+
let n = Lr(e), r = Qn(e, t.action), [i, a] = k("idle"), [o, s] = k(void 0), [c, l] = k(void 0), u = O(t.extra);
|
|
2416
2680
|
u.current = t.extra;
|
|
2417
2681
|
let d = T(async (e) => {
|
|
2418
2682
|
l(void 0), s(void 0), a("uploading");
|
|
@@ -2455,8 +2719,8 @@ var Sr = () => {
|
|
|
2455
2719
|
f,
|
|
2456
2720
|
p
|
|
2457
2721
|
]);
|
|
2458
|
-
},
|
|
2459
|
-
let t =
|
|
2722
|
+
}, zr = async (e) => {
|
|
2723
|
+
let t = J(e.client, e.tag), n = M.currentSpan.pipe(M.tap((t) => M.sync(() => {
|
|
2460
2724
|
ve({
|
|
2461
2725
|
traceId: t.traceId,
|
|
2462
2726
|
spanId: t.spanId,
|
|
@@ -2467,9 +2731,9 @@ var Sr = () => {
|
|
|
2467
2731
|
"voltro.api": e.apiName,
|
|
2468
2732
|
"rpc.tag": e.tag
|
|
2469
2733
|
} }));
|
|
2470
|
-
return
|
|
2471
|
-
},
|
|
2472
|
-
let n =
|
|
2734
|
+
return Z(e.runtime, n);
|
|
2735
|
+
}, Br = (e, t) => {
|
|
2736
|
+
let n = q(e), { descriptors: r } = n, i = O(n);
|
|
2473
2737
|
if (i.current = n, process.env.NODE_ENV !== "production") {
|
|
2474
2738
|
let n = r[t]?.kind;
|
|
2475
2739
|
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.`);
|
|
@@ -2477,7 +2741,7 @@ var Sr = () => {
|
|
|
2477
2741
|
let [a, o] = k(!1), [s, c] = k(void 0), [l, u] = k(void 0), d = T(async (n) => {
|
|
2478
2742
|
o(!0), c(void 0);
|
|
2479
2743
|
try {
|
|
2480
|
-
let { runtime: r, client: a } = await
|
|
2744
|
+
let { runtime: r, client: a } = await X(i, e, t), o = await zr({
|
|
2481
2745
|
apiName: e,
|
|
2482
2746
|
runtime: r,
|
|
2483
2747
|
client: a,
|
|
@@ -2492,8 +2756,8 @@ var Sr = () => {
|
|
|
2492
2756
|
o(!1);
|
|
2493
2757
|
}
|
|
2494
2758
|
}, [e, t]), f = T(async (t) => {
|
|
2495
|
-
let { runtime: n, client: r } = await
|
|
2496
|
-
await
|
|
2759
|
+
let { runtime: n, client: r } = await X(i, e, "__voltro.workflow.cancel");
|
|
2760
|
+
await zr({
|
|
2497
2761
|
apiName: e,
|
|
2498
2762
|
runtime: n,
|
|
2499
2763
|
client: r,
|
|
@@ -2502,8 +2766,8 @@ var Sr = () => {
|
|
|
2502
2766
|
spanPrefix: "client.workflow.cancel"
|
|
2503
2767
|
});
|
|
2504
2768
|
}, [e]), p = T(async (t) => {
|
|
2505
|
-
let { runtime: n, client: r } = await
|
|
2506
|
-
await
|
|
2769
|
+
let { runtime: n, client: r } = await X(i, e, "__voltro.workflow.resume");
|
|
2770
|
+
await zr({
|
|
2507
2771
|
apiName: e,
|
|
2508
2772
|
runtime: n,
|
|
2509
2773
|
client: r,
|
|
@@ -2512,8 +2776,8 @@ var Sr = () => {
|
|
|
2512
2776
|
spanPrefix: "client.workflow.resume"
|
|
2513
2777
|
});
|
|
2514
2778
|
}, [e]), m = T(async (t, n, r) => {
|
|
2515
|
-
let { runtime: a, client: o } = await
|
|
2516
|
-
return
|
|
2779
|
+
let { runtime: a, client: o } = await X(i, e, "__voltro.workflow.signal");
|
|
2780
|
+
return zr({
|
|
2517
2781
|
apiName: e,
|
|
2518
2782
|
runtime: a,
|
|
2519
2783
|
client: o,
|
|
@@ -2526,8 +2790,8 @@ var Sr = () => {
|
|
|
2526
2790
|
spanPrefix: "client.workflow.signal"
|
|
2527
2791
|
});
|
|
2528
2792
|
}, [e]), h = T(async (t, n, r, a) => {
|
|
2529
|
-
let { runtime: o, client: s } = await
|
|
2530
|
-
return
|
|
2793
|
+
let { runtime: o, client: s } = await X(i, e, "__voltro.workflow.update");
|
|
2794
|
+
return zr({
|
|
2531
2795
|
apiName: e,
|
|
2532
2796
|
runtime: o,
|
|
2533
2797
|
client: s,
|
|
@@ -2560,13 +2824,13 @@ var Sr = () => {
|
|
|
2560
2824
|
s,
|
|
2561
2825
|
l
|
|
2562
2826
|
]);
|
|
2563
|
-
},
|
|
2564
|
-
let t =
|
|
2827
|
+
}, Vr = (e) => {
|
|
2828
|
+
let t = q(e), n = O(t);
|
|
2565
2829
|
n.current = t;
|
|
2566
2830
|
let [r, i] = k(!1), [a, o] = k(void 0), [s, c] = k(void 0), l = T(async (t, r, a) => {
|
|
2567
2831
|
i(!0), o(void 0);
|
|
2568
2832
|
try {
|
|
2569
|
-
let { runtime: i, client: o } = await
|
|
2833
|
+
let { runtime: i, client: o } = await X(n, e, "__voltro.workflow.signal"), s = await zr({
|
|
2570
2834
|
apiName: e,
|
|
2571
2835
|
runtime: i,
|
|
2572
2836
|
client: o,
|
|
@@ -2596,13 +2860,13 @@ var Sr = () => {
|
|
|
2596
2860
|
a,
|
|
2597
2861
|
s
|
|
2598
2862
|
]);
|
|
2599
|
-
},
|
|
2600
|
-
let t =
|
|
2863
|
+
}, Hr = (e) => {
|
|
2864
|
+
let t = q(e), n = O(t);
|
|
2601
2865
|
n.current = t;
|
|
2602
2866
|
let [r, i] = k(!1), [a, o] = k(void 0), [s, c] = k(void 0), l = T(async (t, r, a, s) => {
|
|
2603
2867
|
i(!0), o(void 0);
|
|
2604
2868
|
try {
|
|
2605
|
-
let { runtime: i, client: o } = await
|
|
2869
|
+
let { runtime: i, client: o } = await X(n, e, "__voltro.workflow.update"), l = await zr({
|
|
2606
2870
|
apiName: e,
|
|
2607
2871
|
runtime: i,
|
|
2608
2872
|
client: o,
|
|
@@ -2633,8 +2897,8 @@ var Sr = () => {
|
|
|
2633
2897
|
a,
|
|
2634
2898
|
s
|
|
2635
2899
|
]);
|
|
2636
|
-
},
|
|
2637
|
-
let n =
|
|
2900
|
+
}, Ur = (e, t) => {
|
|
2901
|
+
let n = Y(e, "__voltro.workflow.run", t ? { id: t } : {}, { skip: t === void 0 });
|
|
2638
2902
|
return n.loading || n.idle || n.failed ? {
|
|
2639
2903
|
...n,
|
|
2640
2904
|
run: void 0
|
|
@@ -2642,8 +2906,8 @@ var Sr = () => {
|
|
|
2642
2906
|
...n,
|
|
2643
2907
|
run: n.data[0]
|
|
2644
2908
|
};
|
|
2645
|
-
},
|
|
2646
|
-
let r =
|
|
2909
|
+
}, Wr = (e, t = {}, n = {}) => {
|
|
2910
|
+
let r = Y(e, "__voltro.workflow.runs", t, n);
|
|
2647
2911
|
return r.loading || r.idle || r.failed ? {
|
|
2648
2912
|
...r,
|
|
2649
2913
|
runs: []
|
|
@@ -2651,8 +2915,8 @@ var Sr = () => {
|
|
|
2651
2915
|
...r,
|
|
2652
2916
|
runs: r.data
|
|
2653
2917
|
};
|
|
2654
|
-
},
|
|
2655
|
-
let n =
|
|
2918
|
+
}, Gr = (e, t) => {
|
|
2919
|
+
let n = Y(e, "__voltro.workflow.run.steps", t ? { runId: t } : {}, { skip: t === void 0 });
|
|
2656
2920
|
return n.loading || n.idle || n.failed ? {
|
|
2657
2921
|
...n,
|
|
2658
2922
|
steps: []
|
|
@@ -2660,8 +2924,8 @@ var Sr = () => {
|
|
|
2660
2924
|
...n,
|
|
2661
2925
|
steps: n.data
|
|
2662
2926
|
};
|
|
2663
|
-
},
|
|
2664
|
-
let n =
|
|
2927
|
+
}, Kr = (e, t) => {
|
|
2928
|
+
let n = Y(e, "__voltro.workflow.run.events", t ? { runId: t } : {}, { skip: t === void 0 });
|
|
2665
2929
|
return n.loading || n.idle || n.failed ? {
|
|
2666
2930
|
...n,
|
|
2667
2931
|
events: []
|
|
@@ -2669,8 +2933,8 @@ var Sr = () => {
|
|
|
2669
2933
|
...n,
|
|
2670
2934
|
events: n.data
|
|
2671
2935
|
};
|
|
2672
|
-
},
|
|
2673
|
-
let r =
|
|
2936
|
+
}, qr = Kr, Jr = (e, t = {}, n = {}) => {
|
|
2937
|
+
let r = Y(e, "__voltro.workflow.domainEvents", t, n);
|
|
2674
2938
|
return r.loading || r.idle || r.failed ? {
|
|
2675
2939
|
...r,
|
|
2676
2940
|
events: []
|
|
@@ -2678,8 +2942,8 @@ var Sr = () => {
|
|
|
2678
2942
|
...r,
|
|
2679
2943
|
events: r.data
|
|
2680
2944
|
};
|
|
2681
|
-
},
|
|
2682
|
-
let n =
|
|
2945
|
+
}, Yr = (e, t) => {
|
|
2946
|
+
let n = Y(e, "__voltro.workflow.event.deliveries", t ? { eventId: t } : {}, { skip: t === void 0 });
|
|
2683
2947
|
return n.loading || n.idle || n.failed ? {
|
|
2684
2948
|
...n,
|
|
2685
2949
|
deliveries: []
|
|
@@ -2687,42 +2951,42 @@ var Sr = () => {
|
|
|
2687
2951
|
...n,
|
|
2688
2952
|
deliveries: n.data
|
|
2689
2953
|
};
|
|
2690
|
-
},
|
|
2954
|
+
}, Xr = (e, t) => {
|
|
2691
2955
|
let n = e.payload;
|
|
2692
2956
|
if (!n || typeof n != "object") return;
|
|
2693
2957
|
let r = n[t];
|
|
2694
2958
|
return typeof r == "string" ? r : void 0;
|
|
2695
|
-
},
|
|
2959
|
+
}, Zr = (e) => {
|
|
2696
2960
|
let t = e.payload;
|
|
2697
2961
|
if (!t || typeof t != "object") return;
|
|
2698
2962
|
let n = t.updateId;
|
|
2699
2963
|
return typeof n == "string" ? n : void 0;
|
|
2700
|
-
},
|
|
2964
|
+
}, Qr = (e) => {
|
|
2701
2965
|
let t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set();
|
|
2702
2966
|
for (let r of e) if (r.eventType === "signal-received") {
|
|
2703
|
-
let e =
|
|
2967
|
+
let e = Xr(r, "signalName");
|
|
2704
2968
|
e && t.add(e);
|
|
2705
2969
|
} else if (r.eventType === "update-completed" || r.eventType === "update-failed") {
|
|
2706
|
-
let e =
|
|
2970
|
+
let e = Zr(r);
|
|
2707
2971
|
e && n.add(e);
|
|
2708
2972
|
}
|
|
2709
2973
|
for (let r = e.length - 1; r >= 0; --r) {
|
|
2710
2974
|
let i = e[r];
|
|
2711
2975
|
if (i.eventType === "signal-awaited") {
|
|
2712
|
-
let e =
|
|
2976
|
+
let e = Xr(i, "signalName");
|
|
2713
2977
|
if (e && !t.has(e)) return {
|
|
2714
2978
|
name: e,
|
|
2715
2979
|
kind: "signal"
|
|
2716
2980
|
};
|
|
2717
2981
|
} else if (i.eventType === "update-requested") {
|
|
2718
|
-
let e =
|
|
2982
|
+
let e = Zr(i), t = Xr(i, "updateName");
|
|
2719
2983
|
if (t && (!e || !n.has(e))) return {
|
|
2720
2984
|
name: t,
|
|
2721
2985
|
kind: "update"
|
|
2722
2986
|
};
|
|
2723
2987
|
}
|
|
2724
2988
|
}
|
|
2725
|
-
},
|
|
2989
|
+
}, $r = (e) => e.find((e) => e.status === "running") || (e.length > 0 ? e[e.length - 1] : void 0), ei = (e, t) => {
|
|
2726
2990
|
if (!e || e.status !== "failed") return;
|
|
2727
2991
|
let n = t.find((e) => e.status === "failed");
|
|
2728
2992
|
return {
|
|
@@ -2730,8 +2994,8 @@ var Sr = () => {
|
|
|
2730
2994
|
message: e.errorMessage,
|
|
2731
2995
|
step: n?.stepName
|
|
2732
2996
|
};
|
|
2733
|
-
},
|
|
2734
|
-
let n =
|
|
2997
|
+
}, ti = (e, t) => {
|
|
2998
|
+
let n = Ur(e, t), r = Gr(e, t), i = Kr(e, t), a = Br(e, n.run?.tag ?? ""), o = n.run, s = r.steps, c = i.events, l = T(async () => {
|
|
2735
2999
|
if (!o) throw Error("useWorkflowRunState: no run loaded — cannot cancel");
|
|
2736
3000
|
await a.cancel({
|
|
2737
3001
|
workflowName: o.tag,
|
|
@@ -2755,9 +3019,9 @@ var Sr = () => {
|
|
|
2755
3019
|
status: o?.status,
|
|
2756
3020
|
steps: s,
|
|
2757
3021
|
events: c,
|
|
2758
|
-
currentStep:
|
|
2759
|
-
waitingFor: o?.status === "suspended" ?
|
|
2760
|
-
error:
|
|
3022
|
+
currentStep: $r(s),
|
|
3023
|
+
waitingFor: o?.status === "suspended" ? Qr(c) : void 0,
|
|
3024
|
+
error: ei(o, s),
|
|
2761
3025
|
traceId: o?.traceId,
|
|
2762
3026
|
loading: n.data === void 0,
|
|
2763
3027
|
cancel: l,
|
|
@@ -2774,8 +3038,8 @@ var Sr = () => {
|
|
|
2774
3038
|
d,
|
|
2775
3039
|
f
|
|
2776
3040
|
]);
|
|
2777
|
-
},
|
|
2778
|
-
let { runtime: n, client: r } =
|
|
3041
|
+
}, ni = (e, t) => {
|
|
3042
|
+
let { runtime: n, client: r } = q(e), [i, a] = k([]), [o, s] = k("idle"), [c, l] = k(void 0), u = O(null), d = T(() => {
|
|
2779
3043
|
let e = u.current;
|
|
2780
3044
|
e && (u.current = null, n.runFork(P.interrupt(e)), s((e) => e === "streaming" ? "idle" : e));
|
|
2781
3045
|
}, [n]);
|
|
@@ -2786,7 +3050,7 @@ var Sr = () => {
|
|
|
2786
3050
|
start: T((e = {}) => {
|
|
2787
3051
|
let i = u.current;
|
|
2788
3052
|
i && n.runFork(P.interrupt(i)), a([]), l(void 0), s("streaming");
|
|
2789
|
-
let o =
|
|
3053
|
+
let o = J(r, t)(e), c = z.runForEach(o, (e) => M.sync(() => a((t) => [...t, e]))).pipe(M.matchCause({
|
|
2790
3054
|
onSuccess: () => {
|
|
2791
3055
|
s("done");
|
|
2792
3056
|
},
|
|
@@ -2802,7 +3066,7 @@ var Sr = () => {
|
|
|
2802
3066
|
]),
|
|
2803
3067
|
cancel: d
|
|
2804
3068
|
};
|
|
2805
|
-
},
|
|
3069
|
+
}, ri = (e, t, n, r) => {
|
|
2806
3070
|
let i = 0, a = !1, o = (e) => M.sync(() => {
|
|
2807
3071
|
e.seq <= i || (i = e.seq, n.onEvent(e.event), r.isTerminal(e.event) && (a = !0));
|
|
2808
3072
|
}), s = (e) => {
|
|
@@ -2829,15 +3093,15 @@ var Sr = () => {
|
|
|
2829
3093
|
}));
|
|
2830
3094
|
});
|
|
2831
3095
|
return u(0);
|
|
2832
|
-
},
|
|
3096
|
+
}, ii = (e) => {
|
|
2833
3097
|
let t = e?._tag;
|
|
2834
3098
|
return t === "done" || t === "error";
|
|
2835
|
-
},
|
|
2836
|
-
let { runtime: r, client: i } =
|
|
3099
|
+
}, ai = (e, t, n = {}) => {
|
|
3100
|
+
let { runtime: r, client: i } = q(e), [a, o] = k([]), [s, c] = k("idle"), [l, u] = k(0), [d, f] = k(void 0), p = O(null), m = {
|
|
2837
3101
|
maxReconnects: n.maxReconnects ?? 6,
|
|
2838
3102
|
backoffMs: n.backoffMs ?? 400,
|
|
2839
3103
|
maxBackoffMs: n.maxBackoffMs ?? 8e3,
|
|
2840
|
-
isTerminal: n.isTerminal ??
|
|
3104
|
+
isTerminal: n.isTerminal ?? ii
|
|
2841
3105
|
}, h = T(() => {
|
|
2842
3106
|
let e = p.current;
|
|
2843
3107
|
e && (p.current = null, r.runFork(P.interrupt(e)), c((e) => e === "streaming" || e === "reconnecting" ? "idle" : e));
|
|
@@ -2850,13 +3114,13 @@ var Sr = () => {
|
|
|
2850
3114
|
start: T((e = {}) => {
|
|
2851
3115
|
let n = p.current;
|
|
2852
3116
|
n && r.runFork(P.interrupt(n)), o([]), f(void 0), u(0), c("streaming");
|
|
2853
|
-
let a =
|
|
3117
|
+
let a = J(i, t), s = {
|
|
2854
3118
|
onEvent: (e) => o((t) => [...t, e]),
|
|
2855
3119
|
onStatus: c,
|
|
2856
3120
|
onReconnect: () => u((e) => e + 1),
|
|
2857
3121
|
onError: f
|
|
2858
3122
|
};
|
|
2859
|
-
p.current = r.runFork(
|
|
3123
|
+
p.current = r.runFork(ri(a, e, s, m));
|
|
2860
3124
|
}, [
|
|
2861
3125
|
r,
|
|
2862
3126
|
i,
|
|
@@ -2868,13 +3132,13 @@ var Sr = () => {
|
|
|
2868
3132
|
]),
|
|
2869
3133
|
cancel: h
|
|
2870
3134
|
};
|
|
2871
|
-
},
|
|
3135
|
+
}, oi = (e, t) => e.order - t.order || (e.stepOrder ?? 0) - (t.stepOrder ?? 0), si = (e) => {
|
|
2872
3136
|
for (let t = e.length - 1; t >= 0; --t) {
|
|
2873
3137
|
let n = e[t];
|
|
2874
3138
|
if (n.role === "user" && n.content) return n.content;
|
|
2875
3139
|
}
|
|
2876
|
-
},
|
|
2877
|
-
let { threadId: r } = n, i =
|
|
3140
|
+
}, ci = (e, t, n) => {
|
|
3141
|
+
let { threadId: r } = n, i = Y(e, `${t}.messages`, { threadId: r }), a = Qn(e, `${t}.send`), o = D(() => [...i.data ?? []].sort(oi), [i.data]), s = T((e, t = {}) => a.run({
|
|
2878
3142
|
threadId: r,
|
|
2879
3143
|
order: i.data?.length ?? 0,
|
|
2880
3144
|
prompt: e,
|
|
@@ -2884,7 +3148,7 @@ var Sr = () => {
|
|
|
2884
3148
|
r,
|
|
2885
3149
|
i.data
|
|
2886
3150
|
]), c = T(() => {
|
|
2887
|
-
let e =
|
|
3151
|
+
let e = si(o);
|
|
2888
3152
|
return e === void 0 ? void 0 : s(e);
|
|
2889
3153
|
}, [o, s]);
|
|
2890
3154
|
return D(() => ({
|
|
@@ -2904,8 +3168,8 @@ var Sr = () => {
|
|
|
2904
3168
|
s,
|
|
2905
3169
|
c
|
|
2906
3170
|
]);
|
|
2907
|
-
},
|
|
2908
|
-
let { events: n, status: r, error: i, start: a, cancel: o } =
|
|
3171
|
+
}, li = (e, t) => {
|
|
3172
|
+
let { events: n, status: r, error: i, start: a, cancel: o } = ni(e, t), [s, c] = k([]), l = O(null), u = D(() => n.filter((e) => e._tag === "token").map((e) => e.text ?? "").join(""), [n]);
|
|
2909
3173
|
return E(() => {
|
|
2910
3174
|
if (r !== "done" || l.current === null) return;
|
|
2911
3175
|
let e = l.current;
|
|
@@ -2931,8 +3195,8 @@ var Sr = () => {
|
|
|
2931
3195
|
}, [a]),
|
|
2932
3196
|
cancel: o
|
|
2933
3197
|
};
|
|
2934
|
-
},
|
|
2935
|
-
let n =
|
|
3198
|
+
}, ui = (e, t) => {
|
|
3199
|
+
let n = Qn(e, t), [r, i] = k(void 0), a = T(async (e) => {
|
|
2936
3200
|
let t = await n.run({ question: e });
|
|
2937
3201
|
return i(t), t;
|
|
2938
3202
|
}, [n]), o = T(() => i(void 0), []);
|
|
@@ -2949,14 +3213,14 @@ var Sr = () => {
|
|
|
2949
3213
|
n.error,
|
|
2950
3214
|
o
|
|
2951
3215
|
]);
|
|
2952
|
-
},
|
|
2953
|
-
let { cache: t, runtime: n } =
|
|
3216
|
+
}, di = (e) => {
|
|
3217
|
+
let { cache: t, runtime: n } = q(e);
|
|
2954
3218
|
return T(() => {
|
|
2955
3219
|
t.refreshAll(n);
|
|
2956
3220
|
}, [t, n]);
|
|
2957
|
-
},
|
|
3221
|
+
}, fi = (e) => e?._tag === "Unauthenticated", pi = (e, t, n = {}) => {
|
|
2958
3222
|
let r = n.cooldownMs ?? 15e3, i = n.maxConsecutive ?? 3, a = n.now ?? (() => Date.now()), o = -Infinity, s = 0, c = e.on((e) => {
|
|
2959
|
-
if (!
|
|
3223
|
+
if (!fi(e.error) || s >= i) return;
|
|
2960
3224
|
let n = a();
|
|
2961
3225
|
n - o < r || (o = n, s += 1, t());
|
|
2962
3226
|
}), l = e.onSuccess(() => {
|
|
@@ -2970,18 +3234,21 @@ var Sr = () => {
|
|
|
2970
3234
|
s = 0;
|
|
2971
3235
|
}
|
|
2972
3236
|
};
|
|
2973
|
-
},
|
|
2974
|
-
let
|
|
2975
|
-
E(() =>
|
|
2976
|
-
},
|
|
3237
|
+
}, mi = (e, t) => {
|
|
3238
|
+
let n = q(e), r = n.recovery ?? ct(n.errorBus, e), i = O(t);
|
|
3239
|
+
i.current = t, E(() => r.onVisibleError((e) => i.current(e)), [r]);
|
|
3240
|
+
}, hi = (e, t) => {
|
|
3241
|
+
let { errorBus: n } = q(e), r = O(t);
|
|
3242
|
+
r.current = t, E(() => n.on((e) => r.current(e)), [n]);
|
|
3243
|
+
}, gi = {
|
|
2977
3244
|
failed: [],
|
|
2978
3245
|
healthy: !0
|
|
2979
|
-
},
|
|
2980
|
-
let { errorBus: t } =
|
|
3246
|
+
}, _i = (e) => {
|
|
3247
|
+
let { errorBus: t } = q(e), [n, r] = k(gi);
|
|
2981
3248
|
return E(() => {
|
|
2982
3249
|
let e = /* @__PURE__ */ new Map(), n = () => {
|
|
2983
3250
|
let t = [...e.values()].sort((e, t) => t.at - e.at);
|
|
2984
|
-
r(t.length === 0 ?
|
|
3251
|
+
r(t.length === 0 ? gi : {
|
|
2985
3252
|
failed: t,
|
|
2986
3253
|
healthy: !1
|
|
2987
3254
|
});
|
|
@@ -2999,16 +3266,16 @@ var Sr = () => {
|
|
|
2999
3266
|
i(), a();
|
|
3000
3267
|
};
|
|
3001
3268
|
}, [t]), n;
|
|
3002
|
-
},
|
|
3269
|
+
}, vi = (e, t) => {
|
|
3003
3270
|
let n = globalThis, r = Symbol.for(`@voltro/web/context:${e}`), i = n[r];
|
|
3004
3271
|
if (i) return i;
|
|
3005
3272
|
let a = C(t);
|
|
3006
3273
|
return n[r] = a, a;
|
|
3007
|
-
},
|
|
3274
|
+
}, yi = vi("serverRequest", null), bi = () => te(yi), xi = ({ value: e, children: t }) => /* @__PURE__ */ pe(yi.Provider, {
|
|
3008
3275
|
value: e,
|
|
3009
3276
|
children: t
|
|
3010
|
-
}),
|
|
3011
|
-
let t =
|
|
3277
|
+
}), Si = (e) => {
|
|
3278
|
+
let t = bi();
|
|
3012
3279
|
return D(() => {
|
|
3013
3280
|
if (t !== null) return t.formFlash?.formKey === e ? t.formFlash : void 0;
|
|
3014
3281
|
if (typeof document > "u") return;
|
|
@@ -3020,13 +3287,13 @@ var Sr = () => {
|
|
|
3020
3287
|
return;
|
|
3021
3288
|
}
|
|
3022
3289
|
}, [t, e]);
|
|
3023
|
-
},
|
|
3290
|
+
}, Ci = (e, t, n) => e.map((e) => {
|
|
3024
3291
|
let r = String(e[n] ?? ""), i = e[t];
|
|
3025
3292
|
return {
|
|
3026
3293
|
value: r,
|
|
3027
3294
|
label: i == null ? r : String(i)
|
|
3028
3295
|
};
|
|
3029
|
-
}),
|
|
3296
|
+
}), wi = (e, t, n = {}) => {
|
|
3030
3297
|
let r = n.debounceMs ?? 200, i = n.labelField ?? "name", a = n.valueField ?? "id", o = n.input ?? ((e) => ({ q: e })), [s, c] = k(n.initialTerm ?? ""), [l, u] = k(s);
|
|
3031
3298
|
E(() => {
|
|
3032
3299
|
if (s === l) return;
|
|
@@ -3037,7 +3304,7 @@ var Sr = () => {
|
|
|
3037
3304
|
l,
|
|
3038
3305
|
r
|
|
3039
3306
|
]);
|
|
3040
|
-
let d = n.skipUntilTerm === !0 && l.trim() === "", f =
|
|
3307
|
+
let d = n.skipUntilTerm === !0 && l.trim() === "", f = Y(e, t, D(() => o(l), [o, l]), { skip: d }), p = D(() => Ci(f.data ?? [], i, a), [
|
|
3041
3308
|
f.data,
|
|
3042
3309
|
i,
|
|
3043
3310
|
a
|
|
@@ -3048,8 +3315,8 @@ var Sr = () => {
|
|
|
3048
3315
|
term: s,
|
|
3049
3316
|
search: m
|
|
3050
3317
|
};
|
|
3051
|
-
},
|
|
3052
|
-
let i =
|
|
3318
|
+
}, Ti = (e, t) => e === t ? 0 : e == null ? 1 : t == null || e < t ? -1 : 1, Ei = (t, n, r = {}) => {
|
|
3319
|
+
let i = q(t), [a, o] = k(r.pageSize), s = Y(t, n, D(() => a === void 0 ? r.input ?? {} : {
|
|
3053
3320
|
...r.input,
|
|
3054
3321
|
limit: a
|
|
3055
3322
|
}, [r.input, a])), c = i.descriptors[n]?.output, l = T(() => {
|
|
@@ -3069,7 +3336,7 @@ var Sr = () => {
|
|
|
3069
3336
|
let e = s.data ?? [];
|
|
3070
3337
|
if (d === void 0) return e;
|
|
3071
3338
|
let t = d.direction === "asc" ? 1 : -1;
|
|
3072
|
-
return [...e].sort((e, n) =>
|
|
3339
|
+
return [...e].sort((e, n) => Ti(e[d.column], n[d.column]) * t);
|
|
3073
3340
|
}, [s.data, d]),
|
|
3074
3341
|
loading: s.data === void 0,
|
|
3075
3342
|
error: s.error,
|
|
@@ -3078,14 +3345,14 @@ var Sr = () => {
|
|
|
3078
3345
|
loadMore: l,
|
|
3079
3346
|
hasMore: a !== void 0 && (s.data?.length ?? 0) >= a
|
|
3080
3347
|
};
|
|
3081
|
-
},
|
|
3348
|
+
}, Di = (e, t, n, r) => {
|
|
3082
3349
|
let i = e.replace(/\/$/, ""), a = new URLSearchParams({
|
|
3083
3350
|
table: t,
|
|
3084
3351
|
id: n
|
|
3085
3352
|
});
|
|
3086
3353
|
return r !== void 0 && a.set("column", r), `${i}/_voltro/inspect/provenance?${a.toString()}`;
|
|
3087
|
-
},
|
|
3088
|
-
let { inspectBaseUrl: i } =
|
|
3354
|
+
}, Oi = Di, ki = (e, t, n, r) => {
|
|
3355
|
+
let { inspectBaseUrl: i } = q(e), [a, o] = k({
|
|
3089
3356
|
data: void 0,
|
|
3090
3357
|
loading: !0,
|
|
3091
3358
|
error: void 0
|
|
@@ -3097,7 +3364,7 @@ var Sr = () => {
|
|
|
3097
3364
|
loading: !0,
|
|
3098
3365
|
error: void 0
|
|
3099
3366
|
});
|
|
3100
|
-
let a =
|
|
3367
|
+
let a = Di(i ?? "", t, n, r);
|
|
3101
3368
|
return fetch(a).then(async (e) => {
|
|
3102
3369
|
if (!e.ok) throw Error(`provenance fetch failed: HTTP ${e.status}`);
|
|
3103
3370
|
return await e.json();
|
|
@@ -3123,12 +3390,12 @@ var Sr = () => {
|
|
|
3123
3390
|
n,
|
|
3124
3391
|
r
|
|
3125
3392
|
]), a;
|
|
3126
|
-
},
|
|
3127
|
-
function
|
|
3128
|
-
return w(
|
|
3393
|
+
}, Ai = "admin:full", ji = (e, t) => e.includes("admin:full") ? !0 : (typeof t == "string" ? [t] : t).every((t) => e.includes(t)), Mi = (e, t) => t.length === 0 || e.includes("admin:full") ? !0 : t.some((t) => e.includes(t)), Ni = C({ scopes: [] });
|
|
3394
|
+
function Pi(e) {
|
|
3395
|
+
return w(Ni.Provider, { value: { scopes: e.scopes } }, e.children);
|
|
3129
3396
|
}
|
|
3130
|
-
var
|
|
3131
|
-
let { inspectBaseUrl: t } =
|
|
3397
|
+
var Fi = () => te(Ni), Ii = (e) => ji(Fi().scopes, e), Li = (e) => Mi(Fi().scopes, e), Ri = (e) => `${e.replace(/\/$/, "")}/_voltro/inspect/manifest`, zi = (e) => {
|
|
3398
|
+
let { inspectBaseUrl: t } = q(e), [n, r] = k({
|
|
3132
3399
|
manifest: void 0,
|
|
3133
3400
|
loading: !0,
|
|
3134
3401
|
error: void 0
|
|
@@ -3139,7 +3406,7 @@ var Di = () => te(Ti), Oi = (e) => Ci(Di().scopes, e), ki = (e) => wi(Di().scope
|
|
|
3139
3406
|
manifest: void 0,
|
|
3140
3407
|
loading: !0,
|
|
3141
3408
|
error: void 0
|
|
3142
|
-
}), fetch(
|
|
3409
|
+
}), fetch(Ri(t ?? "")).then(async (e) => {
|
|
3143
3410
|
if (!e.ok) throw Error(`manifest fetch failed: HTTP ${e.status}`);
|
|
3144
3411
|
return await e.json();
|
|
3145
3412
|
}).then((t) => {
|
|
@@ -3158,7 +3425,7 @@ var Di = () => te(Ti), Oi = (e) => Ci(Di().scopes, e), ki = (e) => wi(Di().scope
|
|
|
3158
3425
|
e = !0;
|
|
3159
3426
|
};
|
|
3160
3427
|
}, [e, t]), n;
|
|
3161
|
-
},
|
|
3428
|
+
}, Bi = (e, t) => t.scope.length === 0 || (t.mode === "any" ? t.scope.some((t) => e.includes(t)) : t.scope.every((t) => e.includes(t))), Vi = (e, t) => {
|
|
3162
3429
|
if (e === void 0) return "unknown";
|
|
3163
3430
|
if (t.includes("admin:full") || e.length === 0) return "allowed";
|
|
3164
3431
|
let n = !1;
|
|
@@ -3167,7 +3434,7 @@ var Di = () => te(Ti), Oi = (e) => Ci(Di().scopes, e), ki = (e) => wi(Di().scope
|
|
|
3167
3434
|
n = !0;
|
|
3168
3435
|
continue;
|
|
3169
3436
|
}
|
|
3170
|
-
if (!
|
|
3437
|
+
if (!Bi(t, r)) {
|
|
3171
3438
|
if (r.resourceScoped) {
|
|
3172
3439
|
n = !0;
|
|
3173
3440
|
continue;
|
|
@@ -3176,13 +3443,13 @@ var Di = () => te(Ti), Oi = (e) => Ci(Di().scopes, e), ki = (e) => wi(Di().scope
|
|
|
3176
3443
|
}
|
|
3177
3444
|
}
|
|
3178
3445
|
return n ? "unknown" : "allowed";
|
|
3179
|
-
},
|
|
3446
|
+
}, Hi = (e) => (e ?? []).flatMap((e) => e.kind === "scope" ? [...e.scope] : []), Ui = (e) => {
|
|
3180
3447
|
for (let t of e ?? []) if (t.kind === "open") return t.reason;
|
|
3181
|
-
},
|
|
3448
|
+
}, Wi = (e) => Vi(e, Fi().scopes), Gi = (e, t) => Array.isArray(e) ? e.includes(t) : e === t, Ki = (e, t, n) => e.targets?.some((e) => e.table === t && e.op === n) ?? !1, qi = (e) => e === void 0 ? {} : {
|
|
3182
3449
|
tag: e.tag,
|
|
3183
3450
|
...e.guards === void 0 ? {} : { guards: e.guards }
|
|
3184
|
-
},
|
|
3185
|
-
let n = e.procedures.find((e) => e.kind === "query" &&
|
|
3451
|
+
}, Ji = (e) => e.tables.filter((e) => !e.framework).map((t) => {
|
|
3452
|
+
let n = e.procedures.find((e) => e.kind === "query" && Gi(e.source, t.name)), r = e.procedures.find((e) => e.kind === "mutation" && Ki(e, t.name, "insert")), i = e.procedures.find((e) => e.kind === "mutation" && Ki(e, t.name, "update")), a = e.procedures.find((e) => e.kind === "mutation" && Ki(e, t.name, "delete")), o = t.pkColumn ?? (t.columns.some((e) => e.name === "id") ? "id" : void 0);
|
|
3186
3453
|
return {
|
|
3187
3454
|
table: t.name,
|
|
3188
3455
|
columns: t.columns.filter((e) => e.serverOnly !== !0),
|
|
@@ -3191,12 +3458,12 @@ var Di = () => te(Ti), Oi = (e) => Ci(Di().scopes, e), ki = (e) => wi(Di().scope
|
|
|
3191
3458
|
reactive: t.reactive,
|
|
3192
3459
|
...o === void 0 ? {} : { pkColumn: o },
|
|
3193
3460
|
editable: (t.editable ?? !0) && o !== void 0,
|
|
3194
|
-
list:
|
|
3195
|
-
create:
|
|
3196
|
-
update:
|
|
3197
|
-
delete:
|
|
3461
|
+
list: qi(n),
|
|
3462
|
+
create: qi(r),
|
|
3463
|
+
update: qi(i),
|
|
3464
|
+
delete: qi(a)
|
|
3198
3465
|
};
|
|
3199
|
-
}),
|
|
3466
|
+
}), Yi = (e) => {
|
|
3200
3467
|
let [t, n] = k([]), [r, i] = k([]), a = T((e) => {
|
|
3201
3468
|
n((t) => [...t, e]), i([]);
|
|
3202
3469
|
}, []), o = T(async () => {
|
|
@@ -3224,8 +3491,8 @@ var Di = () => te(Ti), Oi = (e) => Ci(Di().scopes, e), ki = (e) => wi(Di().scope
|
|
|
3224
3491
|
o,
|
|
3225
3492
|
s
|
|
3226
3493
|
]);
|
|
3227
|
-
},
|
|
3228
|
-
let n = t?.limit, { data: r } =
|
|
3494
|
+
}, Xi = "__voltro.undo.log", Zi = "__voltro.undo.apply", Qi = "__voltro.undo.redo", $i = (e, t) => {
|
|
3495
|
+
let n = t?.limit, { data: r } = Y(e, Xi, n === void 0 ? {} : { limit: n }), i = qn(e, Zi), a = qn(e, Qi), o = r ?? [], s = o.find((e) => !e.undone && !e.crossesAction), c = o.find((e) => e.undone), l = T(async (e) => {
|
|
3229
3496
|
await i.mutate({ invocationId: e });
|
|
3230
3497
|
}, [i]), u = T(async (e) => {
|
|
3231
3498
|
await a.mutate({ invocationId: e });
|
|
@@ -3244,21 +3511,21 @@ var Di = () => te(Ti), Oi = (e) => Ci(Di().scopes, e), ki = (e) => wi(Di().scope
|
|
|
3244
3511
|
undoLast: d,
|
|
3245
3512
|
redoLast: f
|
|
3246
3513
|
};
|
|
3247
|
-
},
|
|
3514
|
+
}, ea = (e, t) => ({
|
|
3248
3515
|
name: e,
|
|
3249
3516
|
map: t
|
|
3250
|
-
}),
|
|
3517
|
+
}), ta = (e, t) => e === void 0 ? null : typeof e == "string" ? { event: e } : e(t), na = /* @__PURE__ */ new Set(["onMount", "onUnmount"]), ra = (e, t, n) => {
|
|
3251
3518
|
let r = { ...t };
|
|
3252
3519
|
for (let [i, a] of Object.entries(e.map)) {
|
|
3253
|
-
if (
|
|
3520
|
+
if (na.has(i) || a === void 0) continue;
|
|
3254
3521
|
let e = t[i];
|
|
3255
3522
|
r[i] = (...r) => {
|
|
3256
|
-
let i =
|
|
3523
|
+
let i = ta(a, t);
|
|
3257
3524
|
if (i !== null && n(i), typeof e == "function") return e(...r);
|
|
3258
3525
|
};
|
|
3259
3526
|
}
|
|
3260
3527
|
return r;
|
|
3261
|
-
},
|
|
3528
|
+
}, ia = (e, t, n) => {
|
|
3262
3529
|
let r = O({
|
|
3263
3530
|
spec: e,
|
|
3264
3531
|
props: t,
|
|
@@ -3269,46 +3536,46 @@ var Di = () => te(Ti), Oi = (e) => Ci(Di().scopes, e), ki = (e) => wi(Di().scope
|
|
|
3269
3536
|
props: t,
|
|
3270
3537
|
sink: n
|
|
3271
3538
|
}, E(() => {
|
|
3272
|
-
let e = r.current, t =
|
|
3539
|
+
let e = r.current, t = ta(e.spec.map.onMount, e.props);
|
|
3273
3540
|
return t !== null && e.sink(t), () => {
|
|
3274
|
-
let e = r.current, t =
|
|
3541
|
+
let e = r.current, t = ta(e.spec.map.onUnmount, e.props);
|
|
3275
3542
|
t !== null && e.sink(t);
|
|
3276
3543
|
};
|
|
3277
|
-
}, []), D(() =>
|
|
3544
|
+
}, []), D(() => ra(e, t, n), [
|
|
3278
3545
|
e,
|
|
3279
3546
|
t,
|
|
3280
3547
|
n
|
|
3281
3548
|
]);
|
|
3282
|
-
},
|
|
3283
|
-
let n =
|
|
3549
|
+
}, aa = (e, t) => {
|
|
3550
|
+
let n = q(e).descriptors[t]?.input;
|
|
3284
3551
|
return D(() => n === void 0 ? [] : x(n), [n]);
|
|
3285
|
-
},
|
|
3286
|
-
let r =
|
|
3552
|
+
}, oa = (t, n) => {
|
|
3553
|
+
let r = q(t).descriptors[n]?.output;
|
|
3287
3554
|
return D(() => r === void 0 ? [] : e(r), [r]);
|
|
3288
|
-
},
|
|
3555
|
+
}, sa = (e, t) => {
|
|
3289
3556
|
if (e === t) return !0;
|
|
3290
3557
|
if (e.length !== t.length) return !1;
|
|
3291
3558
|
for (let n = 0; n < e.length; n += 1) if (!Object.is(e[n], t[n])) return !1;
|
|
3292
3559
|
return !0;
|
|
3293
|
-
},
|
|
3294
|
-
let n = O(null), r =
|
|
3295
|
-
return (n.current === null ||
|
|
3560
|
+
}, ca = (e) => Object.keys(e).sort().map((t) => e[t]), la = (e, t) => {
|
|
3561
|
+
let n = O(null), r = ca(e);
|
|
3562
|
+
return (n.current === null || !sa(n.current.key, r)) && (n.current = {
|
|
3296
3563
|
key: r,
|
|
3297
3564
|
value: t(e)
|
|
3298
3565
|
}), n.current.value;
|
|
3299
|
-
},
|
|
3300
|
-
let i =
|
|
3566
|
+
}, ua = (e, t, n, r = {}) => {
|
|
3567
|
+
let i = Y(e, t, { ...n }, r);
|
|
3301
3568
|
return D(() => ({
|
|
3302
3569
|
allowed: i.data?.allowed === !0,
|
|
3303
3570
|
pending: i.data === void 0
|
|
3304
3571
|
}), [i.data]);
|
|
3305
|
-
},
|
|
3306
|
-
let i =
|
|
3572
|
+
}, da = (e, t, n, r = {}) => {
|
|
3573
|
+
let i = Y(e, t, { ...n }, r);
|
|
3307
3574
|
return D(() => ({
|
|
3308
3575
|
allowedIds: new Set(i.data?.allowedIds ?? []),
|
|
3309
3576
|
pending: i.data === void 0
|
|
3310
3577
|
}), [i.data]);
|
|
3311
|
-
},
|
|
3578
|
+
}, fa = (e) => {
|
|
3312
3579
|
switch (e) {
|
|
3313
3580
|
case "select":
|
|
3314
3581
|
case "radio":
|
|
@@ -3324,26 +3591,26 @@ var Di = () => te(Ti), Oi = (e) => Ci(Di().scopes, e), ki = (e) => wi(Di().scope
|
|
|
3324
3591
|
case "switch": return "boolean";
|
|
3325
3592
|
default: return null;
|
|
3326
3593
|
}
|
|
3327
|
-
},
|
|
3594
|
+
}, pa = (e) => x(e).map((e) => {
|
|
3328
3595
|
if (e.name.includes(".")) return null;
|
|
3329
|
-
let t =
|
|
3596
|
+
let t = fa(e.widget);
|
|
3330
3597
|
return t === null ? null : {
|
|
3331
3598
|
name: e.name,
|
|
3332
3599
|
label: e.label,
|
|
3333
3600
|
kind: t,
|
|
3334
3601
|
...e.options ? { options: e.options } : {}
|
|
3335
3602
|
};
|
|
3336
|
-
}).filter((e) => e !== null),
|
|
3603
|
+
}).filter((e) => e !== null), ma = (e) => {
|
|
3337
3604
|
let t = {};
|
|
3338
3605
|
for (let [n, r] of Object.entries(e)) r === void 0 || r === "" || Array.isArray(r) && r.length === 0 || (t[n] = r);
|
|
3339
3606
|
return t;
|
|
3340
|
-
},
|
|
3341
|
-
let r =
|
|
3342
|
-
o((n) =>
|
|
3607
|
+
}, ha = (e, t, n = {}) => {
|
|
3608
|
+
let r = q(e).descriptors[t]?.input, i = D(() => r === void 0 ? [] : pa(r), [r]), [a, o] = k(n.initial ?? {}), s = T((e, t) => {
|
|
3609
|
+
o((n) => ma({
|
|
3343
3610
|
...n,
|
|
3344
3611
|
[e]: t
|
|
3345
3612
|
}));
|
|
3346
|
-
}, []), c = T(() => o({}), []), l =
|
|
3613
|
+
}, []), c = T(() => o({}), []), l = Y(e, t, D(() => ma(a), [a]));
|
|
3347
3614
|
return {
|
|
3348
3615
|
filters: i,
|
|
3349
3616
|
values: a,
|
|
@@ -3354,20 +3621,20 @@ var Di = () => te(Ti), Oi = (e) => Ci(Di().scopes, e), ki = (e) => wi(Di().scope
|
|
|
3354
3621
|
loading: l.data === void 0,
|
|
3355
3622
|
error: l.error
|
|
3356
3623
|
};
|
|
3357
|
-
},
|
|
3358
|
-
let r =
|
|
3624
|
+
}, ga = (e, t, n = {}) => {
|
|
3625
|
+
let r = Y(e, t, n), i = r.data;
|
|
3359
3626
|
return {
|
|
3360
3627
|
record: Array.isArray(i) ? i[0] : i,
|
|
3361
3628
|
loading: i === void 0,
|
|
3362
3629
|
error: r.error
|
|
3363
3630
|
};
|
|
3364
|
-
},
|
|
3631
|
+
}, _a = (e, t = 300) => {
|
|
3365
3632
|
let [n, r] = k(e);
|
|
3366
3633
|
return E(() => {
|
|
3367
3634
|
let n = setTimeout(() => r(e), t);
|
|
3368
3635
|
return () => clearTimeout(n);
|
|
3369
3636
|
}, [e, t]), n;
|
|
3370
|
-
},
|
|
3637
|
+
}, va = (e) => {
|
|
3371
3638
|
let { value: t, debouncedValue: n, data: r, interpret: i, skipEmpty: a = !0 } = e;
|
|
3372
3639
|
if (a && t.trim() === "") return {
|
|
3373
3640
|
status: "idle",
|
|
@@ -3385,19 +3652,19 @@ var Di = () => te(Ti), Oi = (e) => Ci(Di().scopes, e), ki = (e) => wi(Di().scope
|
|
|
3385
3652
|
valid: o.valid,
|
|
3386
3653
|
message: o.message
|
|
3387
3654
|
};
|
|
3388
|
-
},
|
|
3389
|
-
let { input: i, interpret: a, debounceMs: o = 300, skipEmpty: s = !0 } = r, c =
|
|
3390
|
-
return
|
|
3655
|
+
}, ya = (e, t, n, r) => {
|
|
3656
|
+
let { input: i, interpret: a, debounceMs: o = 300, skipEmpty: s = !0 } = r, c = _a(n, o), l = s && c.trim() === "", u = Y(e, t, D(() => i ? i(c) : { value: c }, [i, c]), { skip: l });
|
|
3657
|
+
return va({
|
|
3391
3658
|
value: n,
|
|
3392
3659
|
debouncedValue: c,
|
|
3393
3660
|
data: l ? null : u.data,
|
|
3394
3661
|
interpret: a,
|
|
3395
3662
|
skipEmpty: s
|
|
3396
3663
|
});
|
|
3397
|
-
},
|
|
3664
|
+
}, ba = (e, t) => ({
|
|
3398
3665
|
name: e,
|
|
3399
3666
|
payload: t
|
|
3400
|
-
}),
|
|
3667
|
+
}), xa = (e, t) => {
|
|
3401
3668
|
let n = ae.decodeUnknownEither(e.payload, { errors: "all" })(t);
|
|
3402
3669
|
if (n._tag === "Right") return {
|
|
3403
3670
|
valid: !0,
|
|
@@ -3409,15 +3676,15 @@ var Di = () => te(Ti), Oi = (e) => Ci(Di().scopes, e), ki = (e) => wi(Di().scope
|
|
|
3409
3676
|
valid: !1,
|
|
3410
3677
|
errors: r
|
|
3411
3678
|
};
|
|
3412
|
-
},
|
|
3679
|
+
}, Sa = (e) => {
|
|
3413
3680
|
let t = new Map(e.map((e) => [e.name, e]));
|
|
3414
3681
|
return {
|
|
3415
3682
|
names: [...t.keys()].sort(),
|
|
3416
3683
|
get: (e) => t.get(e),
|
|
3417
3684
|
events: e
|
|
3418
3685
|
};
|
|
3419
|
-
},
|
|
3420
|
-
let n =
|
|
3686
|
+
}, Ca = (e, t) => {
|
|
3687
|
+
let n = Sa(e);
|
|
3421
3688
|
return {
|
|
3422
3689
|
track: (e, r) => {
|
|
3423
3690
|
let i = n.get(e);
|
|
@@ -3426,7 +3693,7 @@ var Di = () => te(Ti), Oi = (e) => Ci(Di().scopes, e), ki = (e) => wi(Di().scope
|
|
|
3426
3693
|
return;
|
|
3427
3694
|
}
|
|
3428
3695
|
if (process.env.NODE_ENV !== "production") {
|
|
3429
|
-
let t =
|
|
3696
|
+
let t = xa(i, r);
|
|
3430
3697
|
t.valid || console.error(`[@voltro/client] analytics.track('${e}'): payload failed its schema`, t.errors);
|
|
3431
3698
|
}
|
|
3432
3699
|
t({
|
|
@@ -3437,47 +3704,47 @@ var Di = () => te(Ti), Oi = (e) => Ci(Di().scopes, e), ki = (e) => wi(Di().scope
|
|
|
3437
3704
|
names: n.names,
|
|
3438
3705
|
catalog: n
|
|
3439
3706
|
};
|
|
3440
|
-
},
|
|
3441
|
-
let n =
|
|
3707
|
+
}, wa = (e, t) => {
|
|
3708
|
+
let n = Qn(e, t);
|
|
3442
3709
|
return {
|
|
3443
3710
|
preview: T((e) => n.run(e), [n]),
|
|
3444
3711
|
diff: n.lastResult,
|
|
3445
3712
|
pending: n.pending,
|
|
3446
3713
|
error: n.error
|
|
3447
3714
|
};
|
|
3448
|
-
},
|
|
3715
|
+
}, Ta = (e, t, n, r) => [...e, {
|
|
3449
3716
|
id: t,
|
|
3450
3717
|
tag: n,
|
|
3451
3718
|
input: r,
|
|
3452
3719
|
status: "pending",
|
|
3453
3720
|
attempts: 0
|
|
3454
|
-
}],
|
|
3721
|
+
}], Ea = (e, t, n) => e.map((e) => e.id === t ? {
|
|
3455
3722
|
...e,
|
|
3456
3723
|
...n
|
|
3457
|
-
} : e),
|
|
3724
|
+
} : e), Da = (e, t) => Ea(e, t, { status: "sent" }), Oa = (e, t, n) => e.map((e) => e.id === t ? {
|
|
3458
3725
|
...e,
|
|
3459
3726
|
status: "failed",
|
|
3460
3727
|
error: n,
|
|
3461
3728
|
attempts: e.attempts + 1
|
|
3462
|
-
} : e),
|
|
3729
|
+
} : e), ka = (e, t, n) => Ea(e, t, {
|
|
3463
3730
|
status: "conflict",
|
|
3464
3731
|
error: n
|
|
3465
|
-
}),
|
|
3732
|
+
}), Aa = (e, t, n) => e.map((e) => e.id === t && e.status === "conflict" ? {
|
|
3466
3733
|
...e,
|
|
3467
3734
|
input: n,
|
|
3468
3735
|
status: "pending",
|
|
3469
3736
|
error: void 0
|
|
3470
|
-
} : e),
|
|
3737
|
+
} : e), ja = (e) => e.filter((e) => e.status !== "sent"), Ma = (e) => {
|
|
3471
3738
|
let t = [];
|
|
3472
3739
|
for (let n of e) {
|
|
3473
3740
|
if (n.status === "conflict") break;
|
|
3474
3741
|
(n.status === "pending" || n.status === "failed") && t.push(n);
|
|
3475
3742
|
}
|
|
3476
3743
|
return t;
|
|
3477
|
-
},
|
|
3744
|
+
}, Na = (e) => {
|
|
3478
3745
|
let t = e;
|
|
3479
3746
|
return t?.conflict === !0 || t?._tag === "UndoBoundaryError" && t?.boundary === "conflict";
|
|
3480
|
-
},
|
|
3747
|
+
}, Pa = (e) => {
|
|
3481
3748
|
let [t, n] = k(e ?? (typeof navigator < "u" ? navigator.onLine : !0));
|
|
3482
3749
|
return E(() => {
|
|
3483
3750
|
if (e !== void 0) {
|
|
@@ -3490,8 +3757,8 @@ var Di = () => te(Ti), Oi = (e) => Ci(Di().scopes, e), ki = (e) => wi(Di().scope
|
|
|
3490
3757
|
window.removeEventListener("online", t), window.removeEventListener("offline", r);
|
|
3491
3758
|
};
|
|
3492
3759
|
}, [e]), t;
|
|
3493
|
-
},
|
|
3494
|
-
let { send: t, persistence: n, isConflict: r =
|
|
3760
|
+
}, Fa = (e) => {
|
|
3761
|
+
let { send: t, persistence: n, isConflict: r = Na, idFor: i } = e, [a, o] = k([]), s = Pa(e.online), c = O(a);
|
|
3495
3762
|
c.current = a;
|
|
3496
3763
|
let l = O(0), u = O(Math.random().toString(36).slice(2, 8)), d = O(n === void 0);
|
|
3497
3764
|
E(() => {
|
|
@@ -3505,27 +3772,27 @@ var Di = () => te(Ti), Oi = (e) => Ci(Di().scopes, e), ki = (e) => wi(Di().scope
|
|
|
3505
3772
|
e = !0;
|
|
3506
3773
|
};
|
|
3507
3774
|
}, [n]), E(() => {
|
|
3508
|
-
n === void 0 || !d.current || n.save(
|
|
3775
|
+
n === void 0 || !d.current || n.save(ja(a)).catch(() => {});
|
|
3509
3776
|
}, [n, a]);
|
|
3510
3777
|
let f = T((e, t) => {
|
|
3511
3778
|
let n = i?.() ?? `obx_${u.current}_${l.current++}_${e}`;
|
|
3512
|
-
o((r) =>
|
|
3779
|
+
o((r) => Ta(r, n, e, t));
|
|
3513
3780
|
}, [i]), p = T(async () => {
|
|
3514
|
-
for (let e of
|
|
3515
|
-
await t(e), o((t) =>
|
|
3781
|
+
for (let e of Ma(c.current)) try {
|
|
3782
|
+
await t(e), o((t) => Da(t, e.id));
|
|
3516
3783
|
} catch (t) {
|
|
3517
3784
|
if (r(t)) {
|
|
3518
|
-
o((n) =>
|
|
3785
|
+
o((n) => ka(n, e.id, t));
|
|
3519
3786
|
break;
|
|
3520
3787
|
}
|
|
3521
|
-
o((n) =>
|
|
3788
|
+
o((n) => Oa(n, e.id, t));
|
|
3522
3789
|
}
|
|
3523
3790
|
}, [t, r]);
|
|
3524
3791
|
E(() => {
|
|
3525
3792
|
s && p();
|
|
3526
3793
|
}, [s, p]);
|
|
3527
3794
|
let m = T((e, t) => {
|
|
3528
|
-
let n =
|
|
3795
|
+
let n = Aa(c.current, e, t);
|
|
3529
3796
|
c.current = n, o(n), s && p();
|
|
3530
3797
|
}, [s, p]);
|
|
3531
3798
|
return {
|
|
@@ -3537,7 +3804,7 @@ var Di = () => te(Ti), Oi = (e) => Ci(Di().scopes, e), ki = (e) => wi(Di().scope
|
|
|
3537
3804
|
conflicts: a.filter((e) => e.status === "conflict"),
|
|
3538
3805
|
resolveConflict: m
|
|
3539
3806
|
};
|
|
3540
|
-
},
|
|
3807
|
+
}, Ia = (e) => {
|
|
3541
3808
|
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);
|
|
3542
3809
|
return {
|
|
3543
3810
|
startIndex: l,
|
|
@@ -3547,8 +3814,8 @@ var Di = () => te(Ti), Oi = (e) => Ci(Di().scopes, e), ki = (e) => wi(Di().scope
|
|
|
3547
3814
|
topSpacer: l * r,
|
|
3548
3815
|
bottomSpacer: a === void 0 ? 0 : Math.max(0, (a - d) * r)
|
|
3549
3816
|
};
|
|
3550
|
-
},
|
|
3551
|
-
let { rowHeight: r, viewportHeight: i, overscan: a, total: o, input: s } = n, [c, l] = k(0), u = D(() =>
|
|
3817
|
+
}, La = (e, t, n) => {
|
|
3818
|
+
let { rowHeight: r, viewportHeight: i, overscan: a, total: o, input: s } = n, [c, l] = k(0), u = D(() => Ia({
|
|
3552
3819
|
scrollTop: c,
|
|
3553
3820
|
viewportHeight: i,
|
|
3554
3821
|
rowHeight: r,
|
|
@@ -3560,7 +3827,7 @@ var Di = () => te(Ti), Oi = (e) => Ci(Di().scopes, e), ki = (e) => wi(Di().scope
|
|
|
3560
3827
|
r,
|
|
3561
3828
|
a,
|
|
3562
3829
|
o
|
|
3563
|
-
]), d =
|
|
3830
|
+
]), d = Y(e, t, D(() => ({
|
|
3564
3831
|
...s,
|
|
3565
3832
|
offset: u.offset,
|
|
3566
3833
|
limit: u.limit
|
|
@@ -3580,58 +3847,45 @@ var Di = () => te(Ti), Oi = (e) => Ci(Di().scopes, e), ki = (e) => wi(Di().scope
|
|
|
3580
3847
|
loading: d.data === void 0,
|
|
3581
3848
|
error: d.error
|
|
3582
3849
|
};
|
|
3583
|
-
},
|
|
3584
|
-
let
|
|
3585
|
-
E(() =>
|
|
3586
|
-
u.current = !1;
|
|
3587
|
-
}), []), E(() => {
|
|
3850
|
+
}, Ra = () => typeof navigator > "u" || navigator.onLine, za = (e) => {
|
|
3851
|
+
let t = q(e), n = t.recovery ?? ct(t.errorBus, e), r = A(n.subscribe, n.getSnapshot, n.getSnapshot), [i, a] = k(Ra);
|
|
3852
|
+
E(() => {
|
|
3588
3853
|
if (typeof window > "u") return;
|
|
3589
3854
|
let e = () => {
|
|
3590
|
-
|
|
3591
|
-
}, t = () =>
|
|
3855
|
+
a(!0);
|
|
3856
|
+
}, t = () => a(!1);
|
|
3592
3857
|
return window.addEventListener("online", e), window.addEventListener("offline", t), () => {
|
|
3593
3858
|
window.removeEventListener("online", e), window.removeEventListener("offline", t);
|
|
3594
3859
|
};
|
|
3595
|
-
}, [])
|
|
3596
|
-
|
|
3597
|
-
let e = /* @__PURE__ */ new Set();
|
|
3598
|
-
d.current = e, a(0), s(void 0), l([]);
|
|
3599
|
-
let n = () => {
|
|
3600
|
-
e.size === 0 && a(0), l([...e].sort());
|
|
3601
|
-
}, r = t.on((t) => {
|
|
3602
|
-
u.current && (t.kind === "transport" ? (t.source === "subscription" && (e.add(t.tag), l([...e].sort())), a((e) => e + 1), s(Date.now())) : t.kind === "handler" && n());
|
|
3603
|
-
}), i = t.onSuccess((t) => {
|
|
3604
|
-
u.current && (t.source === "subscription" && e.delete(t.tag), n());
|
|
3605
|
-
});
|
|
3606
|
-
return () => {
|
|
3607
|
-
r(), i(), d.current === e && (d.current = /* @__PURE__ */ new Set());
|
|
3608
|
-
};
|
|
3609
|
-
}, [t]);
|
|
3610
|
-
let f = T(() => {
|
|
3611
|
-
d.current.size === 0 && a(0);
|
|
3612
|
-
}, []), p = n ? i > 0 ? "degraded" : "connected" : "offline";
|
|
3860
|
+
}, []);
|
|
3861
|
+
let o = T(() => n.reportExternalSuccess(), [n]), s = i ? r.status : "offline";
|
|
3613
3862
|
return E(() => {
|
|
3614
|
-
|
|
3615
|
-
status:
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
|
|
3863
|
+
W(e, "connection.status", {
|
|
3864
|
+
status: s,
|
|
3865
|
+
rawTransport: r.rawTransport,
|
|
3866
|
+
online: i,
|
|
3867
|
+
failureCount: r.failureCount,
|
|
3868
|
+
failedSubscriptions: r.failedSubscriptions.length,
|
|
3869
|
+
pendingMutationReplays: r.pendingMutationReplays,
|
|
3870
|
+
mutationReplay: r.mutationReplay
|
|
3619
3871
|
});
|
|
3620
3872
|
}, [
|
|
3621
3873
|
e,
|
|
3622
|
-
|
|
3623
|
-
n,
|
|
3874
|
+
s,
|
|
3624
3875
|
i,
|
|
3625
|
-
|
|
3876
|
+
r
|
|
3626
3877
|
]), {
|
|
3627
|
-
status:
|
|
3628
|
-
|
|
3629
|
-
|
|
3630
|
-
|
|
3631
|
-
|
|
3632
|
-
|
|
3878
|
+
status: s,
|
|
3879
|
+
rawTransport: r.rawTransport,
|
|
3880
|
+
online: i,
|
|
3881
|
+
failureCount: r.failureCount,
|
|
3882
|
+
lastFailureAt: r.lastFailureAt,
|
|
3883
|
+
failedSubscriptions: r.failedSubscriptions,
|
|
3884
|
+
pendingMutationReplays: r.pendingMutationReplays,
|
|
3885
|
+
mutationReplay: r.mutationReplay,
|
|
3886
|
+
reportSuccess: o
|
|
3633
3887
|
};
|
|
3634
|
-
},
|
|
3888
|
+
}, Ba = "__voltro.connections.list", Va = "__voltro.connections.start", Ha = "__voltro.connections.submitToken", Ua = "__voltro.connections.disconnect", Wa = {
|
|
3635
3889
|
connectionId: "",
|
|
3636
3890
|
kind: "oauth2",
|
|
3637
3891
|
label: "",
|
|
@@ -3642,14 +3896,14 @@ var Di = () => te(Ti), Oi = (e) => Ci(Di().scopes, e), ki = (e) => wi(Di().scope
|
|
|
3642
3896
|
expiresAt: null,
|
|
3643
3897
|
lastError: null,
|
|
3644
3898
|
connectedAt: null
|
|
3645
|
-
},
|
|
3899
|
+
}, Ga = (e, t) => {
|
|
3646
3900
|
if (t === "redirect") {
|
|
3647
3901
|
globalThis.location.assign(e);
|
|
3648
3902
|
return;
|
|
3649
3903
|
}
|
|
3650
3904
|
globalThis.open(e, "voltro-connect", "width=620,height=760,menubar=no,toolbar=no") === null && globalThis.location.assign(e);
|
|
3651
|
-
},
|
|
3652
|
-
let { data: t } =
|
|
3905
|
+
}, Ka = (e) => {
|
|
3906
|
+
let { data: t } = Y(e, Ba, {}), n = Qn(e, Va), r = qn(e, Ha), i = qn(e, Ua), a = t ?? [], o = n.pending || r.pending || i.pending, s = T((e) => ({
|
|
3653
3907
|
...e,
|
|
3654
3908
|
connected: e.status === "connected",
|
|
3655
3909
|
needsAttention: e.status === "expired" || e.status === "revoked" || e.status === "error",
|
|
@@ -3657,7 +3911,7 @@ var Di = () => te(Ti), Oi = (e) => Ci(Di().scopes, e), ki = (e) => wi(Di().scope
|
|
|
3657
3911
|
connect: async (t) => {
|
|
3658
3912
|
if (e.kind !== "oauth2") throw Error(`connection "${e.connectionId}" is a personal-access-token connection — call submitToken(token), not connect().`);
|
|
3659
3913
|
let r = t?.redirectTo ?? `${globalThis.location.pathname}${globalThis.location.search}`;
|
|
3660
|
-
|
|
3914
|
+
Ga((await n.run({
|
|
3661
3915
|
connectionId: e.connectionId,
|
|
3662
3916
|
redirectTo: r
|
|
3663
3917
|
})).authorizeUrl, t?.mode);
|
|
@@ -3687,10 +3941,10 @@ var Di = () => te(Ti), Oi = (e) => Ci(Di().scopes, e), ki = (e) => wi(Di().scope
|
|
|
3687
3941
|
get: c,
|
|
3688
3942
|
pending: o
|
|
3689
3943
|
};
|
|
3690
|
-
},
|
|
3691
|
-
let n =
|
|
3944
|
+
}, qa = (e, t) => {
|
|
3945
|
+
let n = Ka(e), r = n.get(t);
|
|
3692
3946
|
return D(() => r === void 0 ? {
|
|
3693
|
-
...
|
|
3947
|
+
...Wa,
|
|
3694
3948
|
connectionId: t,
|
|
3695
3949
|
label: t,
|
|
3696
3950
|
connected: !1,
|
|
@@ -3715,6 +3969,6 @@ var Di = () => te(Ti), Oi = (e) => Ci(Di().scopes, e), ki = (e) => wi(Di().scope
|
|
|
3715
3969
|
n.loading,
|
|
3716
3970
|
n.pending
|
|
3717
3971
|
]);
|
|
3718
|
-
},
|
|
3972
|
+
}, Ja = "framework-client";
|
|
3719
3973
|
//#endregion
|
|
3720
|
-
export {
|
|
3974
|
+
export { Ai as ADMIN_SCOPE, Ja as CLIENT_NAME, Ba as CONNECTIONS_LIST_TAG, Ua as CONNECTION_DISCONNECT_TAG, Va as CONNECTION_START_TAG, Ha 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, lt as FrameworkRuntimesContext, Pt as FrameworkRuntimesProvider, Qe as LoadingSubscriptionCache, Pi as PermissionProvider, _ as RICH_TEXT_MARKS, a as RICH_TEXT_MAX_NODES, ot as RecoveryCoordinator, d as RichTextDocument, rt as RpcErrorBus, yi as ServerRequestContext, xi as ServerRequestProvider, Ze as SubscriptionCache, Zi as UNDO_APPLY_TAG, Xi as UNDO_LOG_TAG, Qi as UNDO_REDO_TAG, er as ValidationMessagesProvider, St as _resetFrameworkRuntimesWarning, _t as _resetSsrDescriptors, xr as applyPreloadSeeds, Sn as applyStoreSeeds, Ot as buildApiRuntime, ji as canCall, Mi as canCallAny, Fe as clearClientDiagnostics, Fn as clearMutations, ja as clearSent, tn as clearStoreHistory, Pe as clientDiagnosticsSnapshot, Ia as computeWindow, Ca as createAnalytics, pr as createHooks, Vi as decideAccess, c as decodeFieldIssues, ba as defineEvent, _n as defineStore, ea as defineTracking, gn as definedStores, Ji as deriveEntityAdmins, Ne as disableClientDiagnosticsPersistence, n as documentLocale, y as emptyRichTextDocument, Me as enableClientDiagnosticsPersistence, Ta as enqueueEntry, Sa as eventCatalog, pa as filtersFromSchema, r as formActionPath, m as formDataToInput, S as formField, t as formSections, Wn as freshIdempotencyKey, zn as getMutationNotifier, Nn as getMutations, vi as globalContext, o as isRichTextDocument, s as isSafeHref, fi as isUnauthenticated, wt as isUnresolvedApi, mr as makePreloadSeedBag, yn as makeStoreSeedBag, Ri as manifestUrl, ka as markConflict, Oa as markFailed, Da as markSent, Ui as openAccessReason, h as parseRichText, Oi as provenanceUrl, et as publishClientError, ve as publishClientTrace, Cr as readPreloadedSeedOutcome, Sr as readPreloadedSnapshot, W as recordClientDiagnostic, ct as recoveryCoordinatorFor, ht as registerSsrDescriptors, Ma as replayable, nt as reportClientError, Hi as requiredScopes, wr as resetPreloadSeeds, vn as resetStoreRegistryForTests, Bt as resetStoreStorageForTest, J as resolveByTag, Aa as resolveConflictEntry, at as resolveRecoveryOptions, zt as resolveStoreStorage, ta as resolveTrackingEvent, b as resolveValidationMessage, ee as restrictToSchema, ri as resumableConsumeProgram, f as richTextToPlainText, Ci as rowsToOptions, Ar as runSequence, e as schemaToColumns, x as schemaToFields, yr as seedPreloadedSubscription, br as seedPreloadedSubscriptionFailure, xn as seedStore, kr as sequence, l as serializeRichText, Rn as setMutationNotifier, gr as setPreloadSeedResolver, bn as setStoreSeedResolver, Rt as setStoreStorage, Mn as settleMutation, Vt as shallow, sa as shallowArrayEqual, ca as sourceValues, dt as ssrClientProxy, gt as ssrDescriptorsFor, vt as ssrStubHandle, G as stableKey, Nt as startApiSupervisor, jn as startMutation, $t as storeHistory, Ie as subscribeClientDiagnostics, tt as subscribeClientErrors, ye as subscribeClientTraces, Pn as subscribeMutations, en as subscribeStoreHistory, ze as supersedesConfirmedPatches, nn as travelToStoreState, Wi as useAccessDecision, Qn as useAction, li as useAgent, ci as useAgentChat, ni as useAgentStream, ya as useAsyncValidation, Ii as useCan, Li as useCanAny, zi as useCapabilityManifest, qa as useConnection, za as useConnectionStatus, Ka as useConnections, ui as useDataCopilot, Ei as useDataTable, _a as useDebounced, la as useDerived, Or as useEvent, cr as useFormBinding, ur as useFormBindingContext, dr as useFormField, Si as useFormFlash, aa as useFormSkeleton, q as useFrameworkApi, Ct as useFrameworkRuntimes, qn as useMutation, hi as useOnRawRpcError, mi as useOnRpcError, Fa as useOutbox, Fi as usePermissions, Tr as usePreloadedSubscription, wa as usePreview, ki as useProvenance, wi as useQueryField, ha as useQueryFilters, ga as useRecord, di as useRefreshSubscriptions, ua as useResourceCan, da as useResourceCans, ai as useResumableAgentStream, jr as useSequence, bi as useServerRequest, Y as useSubscription, _i as useSubscriptionHealth, oa as useTableSkeleton, ia as useTracking, Rr as useTranscription, Yi as useUndo, $i as useUndoLog, Lr as useUpload, tr as useValidationMessages, La as useWindowedSubscription, Br as useWorkflow, Jr as useWorkflowDomainEvents, Yr as useWorkflowEventDeliveries, qr as useWorkflowEvents, Ur as useWorkflowRun, Kr as useWorkflowRunEvents, ti as useWorkflowRunState, Gr as useWorkflowRunSteps, Wr as useWorkflowRuns, Vr as useWorkflowSignal, Hr as useWorkflowUpdate, xa as validateEventPayload, i as validateFields, va as validationStatus, pi as wireAuthRefresh, Gn as withIdempotencyKey, Dt as withProtocolOpenRecovery, ra as wrapTrackedCallbacks };
|