@voltro/client 0.89.2 → 0.91.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 +1943 -0
- package/README.md +22 -0
- package/THIRD-PARTY-NOTICES.md +1 -1
- package/dist/analytics.d.ts +68 -0
- package/dist/analytics.js +1 -0
- package/dist/apiRuntime.js +50 -50
- package/dist/apiSupervisor.js +25 -25
- package/dist/awaitResolvedApi.js +42 -16
- package/dist/bootstrap.d.ts +0 -115
- package/dist/bootstrap.js +8 -8
- package/dist/connectionPrerequisite.js +18 -18
- package/dist/connectionSetupController.js +123 -91
- package/dist/createHooks.js +11 -11
- package/dist/form.js +7 -7
- package/dist/index.d.ts +148 -162
- package/dist/index.js +88 -86
- package/dist/invocationWait.js +14 -0
- package/dist/mutationsBus.js +92 -35
- package/dist/outbox.js +137 -108
- package/dist/outboxState.js +7 -0
- package/dist/platform.js +10 -10
- package/dist/query.js +3 -10
- package/dist/rpcCallOnce.js +30 -0
- package/dist/rpcDeclared.js +7 -0
- package/dist/runRpc.js +9 -6
- package/dist/runtime.d.ts +16 -116
- package/dist/runtime.js +16 -16
- package/dist/runtimeContext.js +1 -1
- package/dist/serviceClient.js +23 -23
- package/dist/store.js +3 -3
- package/dist/subscriptionCache.js +1 -1
- package/dist/traceBus.js +7 -1
- package/dist/unknownRpcTag.js +7 -0
- package/dist/uploadBytes.js +83 -0
- package/dist/uploadClient.js +153 -0
- package/dist/useAction.js +148 -74
- package/dist/useAgentChat.js +3 -3
- package/dist/useCapabilityManifest.js +7 -7
- package/dist/useConnectionStatus.js +5 -5
- package/dist/useDataTable.js +4 -4
- package/dist/useEvent.js +22 -22
- package/dist/useFormBinding.js +10 -10
- package/dist/useMutation.js +221 -134
- package/dist/useOnRpcError.js +5 -5
- package/dist/usePreloadedSubscription.js +6 -6
- package/dist/useRpcCaller.js +75 -13
- package/dist/useRpcInvocationOwner.js +29 -0
- package/dist/useSubscription.js +52 -49
- package/dist/useTranscription.js +112 -40
- package/dist/useUpload.js +160 -242
- package/dist/useWorkflow.js +111 -246
- package/dist/workflowClient.js +126 -0
- package/package.json +8 -3
package/dist/outbox.js
CHANGED
|
@@ -1,118 +1,130 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { runRpcPromise as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
1
|
+
import { awaitResolvedApi as e } from "./awaitResolvedApi.js";
|
|
2
|
+
import { withIdempotencyKey as t } from "./mutationIdentity.js";
|
|
3
|
+
import { recoveryCoordinatorFor as n } from "./recoveryCoordinator.js";
|
|
4
|
+
import { runRpcPromise as r } from "./runRpc.js";
|
|
5
|
+
import { FrameworkRuntimesContext as i, isUnresolvedApi as a } from "./frameworkRuntimesContext.js";
|
|
6
|
+
import { resolveByTag as o } from "./tagWalk.js";
|
|
7
7
|
import { useApiOnline as s } from "./useApiOnline.js";
|
|
8
8
|
import { OutboxState as c } from "./outboxState.js";
|
|
9
|
-
import { useCallback as l, useContext as u, useEffect as d, useMemo as
|
|
9
|
+
import { useCallback as l, useContext as u, useEffect as d, useMemo as ee, useRef as f, useState as p } from "react";
|
|
10
10
|
// src/outbox.ts
|
|
11
|
-
var
|
|
11
|
+
var m = (e, t, n, r, i) => [...e, {
|
|
12
12
|
id: t,
|
|
13
13
|
tag: n,
|
|
14
14
|
input: r,
|
|
15
15
|
status: "pending",
|
|
16
16
|
attempts: 0,
|
|
17
17
|
...i === void 0 ? {} : { stamp: i }
|
|
18
|
-
}],
|
|
18
|
+
}], h = (e, t, n) => e.map((e) => e.id === t ? {
|
|
19
19
|
...e,
|
|
20
20
|
...n
|
|
21
|
-
} : e),
|
|
21
|
+
} : e), g = (e, t) => h(e, t, { status: "sent" }), _ = (e, t, n) => e.map((e) => e.id === t ? {
|
|
22
22
|
...e,
|
|
23
23
|
status: "failed",
|
|
24
24
|
error: n,
|
|
25
25
|
attempts: e.attempts + 1
|
|
26
|
-
} : e),
|
|
26
|
+
} : e), v = (e, t, n) => h(e, t, {
|
|
27
27
|
status: "conflict",
|
|
28
28
|
error: n
|
|
29
|
-
}),
|
|
29
|
+
}), y = (e, t, n) => e.map((e) => e.id === t && e.status === "conflict" ? {
|
|
30
30
|
...e,
|
|
31
31
|
input: n,
|
|
32
32
|
status: "pending",
|
|
33
33
|
error: void 0
|
|
34
|
-
} : e),
|
|
34
|
+
} : e), b = (e) => e.filter((e) => e.status !== "sent"), x = (e) => {
|
|
35
35
|
let t = [];
|
|
36
36
|
for (let n of e) {
|
|
37
37
|
if (n.status === "conflict") break;
|
|
38
38
|
(n.status === "pending" || n.status === "failed") && t.push(n);
|
|
39
39
|
}
|
|
40
40
|
return t;
|
|
41
|
-
},
|
|
41
|
+
}, te = (e) => {
|
|
42
42
|
let t = e;
|
|
43
43
|
return t?.conflict === !0 || t?._tag === "UndoBoundaryError" && t?.boundary === "conflict";
|
|
44
|
-
},
|
|
44
|
+
}, S = (e) => {
|
|
45
45
|
let t = Math.min(3e4, 1e3 * 2 ** Math.max(0, e - 1));
|
|
46
46
|
return t / 2 + t / 2 * Math.random();
|
|
47
|
-
},
|
|
48
|
-
let { persistence:
|
|
49
|
-
if (
|
|
50
|
-
let
|
|
47
|
+
}, C = (m) => {
|
|
48
|
+
let { persistence: h, isConflict: g = te, idFor: _, api: v } = m;
|
|
49
|
+
if (m.send === void 0 && v === void 0) throw Error("useOutbox: pass `send`, or `api` to send through that api's own mutations.");
|
|
50
|
+
let y = u(i), x = y?.demand;
|
|
51
51
|
d(() => {
|
|
52
|
-
|
|
53
|
-
}, [
|
|
54
|
-
let
|
|
55
|
-
|
|
56
|
-
let [
|
|
57
|
-
|
|
58
|
-
let
|
|
59
|
-
e(
|
|
60
|
-
}, []),
|
|
61
|
-
|
|
62
|
-
let
|
|
63
|
-
|
|
64
|
-
let
|
|
65
|
-
|
|
66
|
-
if (
|
|
67
|
-
let
|
|
68
|
-
|
|
52
|
+
v !== void 0 && x?.(v);
|
|
53
|
+
}, [x, v]);
|
|
54
|
+
let C = v === void 0 || y === null ? void 0 : y.get(v), w = f(C);
|
|
55
|
+
w.current = C;
|
|
56
|
+
let [ne, T] = p(0), [E, D] = p(0), O = s(v), k = m.online ?? O, A = f(void 0), j = f(0);
|
|
57
|
+
A.current === void 0 && (A.current = new c());
|
|
58
|
+
let M = ee(() => A.current.snapshot(), [ne]), N = l((e) => {
|
|
59
|
+
e(A.current), T((e) => e + 1);
|
|
60
|
+
}, []), P = f(m.retryDelay ?? S);
|
|
61
|
+
P.current = m.retryDelay ?? S;
|
|
62
|
+
let F = f(m.stamp);
|
|
63
|
+
F.current = m.stamp;
|
|
64
|
+
let I = f(async () => void 0);
|
|
65
|
+
I.current = m.send ?? (async (i) => {
|
|
66
|
+
if (w.current === void 0) throw Error(`useOutbox: no mounted api '${v}' — render it inside the framework's runtime provider.`);
|
|
67
|
+
let a = w.current, s = a.subjectSignal ?? (a.recovery ?? n(a.errorBus, v)).subjectSignal, c = await e(w, v, i.tag, s);
|
|
68
|
+
if (s?.throwIfAborted(), a.recovery !== void 0 && a.recovery !== c.recovery) throw Error("Outbox API ownership changed before the queued write started");
|
|
69
|
+
let l = o(c.client, i.tag);
|
|
70
|
+
await r(c.runtime, t(l(i.input), i.id), { signal: s });
|
|
69
71
|
});
|
|
70
|
-
let
|
|
71
|
-
|
|
72
|
-
let
|
|
73
|
-
d(() => (
|
|
74
|
-
|
|
72
|
+
let L = f(g);
|
|
73
|
+
L.current = g;
|
|
74
|
+
let R = f(void 0), z = f(!1), B = f(!0);
|
|
75
|
+
d(() => (B.current = !0, () => {
|
|
76
|
+
B.current = !1;
|
|
75
77
|
}), []);
|
|
76
|
-
let
|
|
78
|
+
let V = f(0), H = f(Math.random().toString(36).slice(2, 8)), U = f(h === void 0), [W, G] = p(0), K = C === void 0 ? void 0 : C.recovery ?? n(C.errorBus, v), q = K?.subjectSignal;
|
|
77
79
|
d(() => {
|
|
78
|
-
if (
|
|
79
|
-
let e =
|
|
80
|
+
if (K === void 0) return;
|
|
81
|
+
let e = K.subjectSignal;
|
|
80
82
|
if (e.aborted) return;
|
|
81
83
|
let t = () => {
|
|
82
|
-
|
|
84
|
+
j.current++, R.current = void 0, Z(), A.current.reset(), T((e) => e + 1), U.current = h === void 0, z.current = !1, G((e) => e + 1);
|
|
83
85
|
};
|
|
84
86
|
return e.addEventListener("abort", t, { once: !0 }), () => {
|
|
85
87
|
e.removeEventListener("abort", t);
|
|
86
88
|
};
|
|
87
89
|
}, [
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
90
|
+
K,
|
|
91
|
+
h,
|
|
92
|
+
W
|
|
91
93
|
]), d(() => {
|
|
92
|
-
if (
|
|
94
|
+
if (h === void 0) return;
|
|
93
95
|
let e = !1;
|
|
94
|
-
return
|
|
95
|
-
e || (
|
|
96
|
+
return U.current = !1, h.load().then((t) => {
|
|
97
|
+
e || (U.current = !0, t.length > 0 && N((e) => e.prepend(t.map((e) => {
|
|
98
|
+
if (e.status !== "conflict" || !(e.error instanceof Error)) return e;
|
|
99
|
+
let t = !1;
|
|
100
|
+
try {
|
|
101
|
+
t = L.current(e.error);
|
|
102
|
+
} catch {}
|
|
103
|
+
return t ? e : {
|
|
104
|
+
...e,
|
|
105
|
+
status: "failed"
|
|
106
|
+
};
|
|
107
|
+
}))), D((e) => e + 1));
|
|
96
108
|
}, () => {
|
|
97
|
-
e || (
|
|
109
|
+
e || (U.current = !0, D((e) => e + 1));
|
|
98
110
|
}), () => {
|
|
99
111
|
e = !0;
|
|
100
112
|
};
|
|
101
113
|
}, [
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
114
|
+
h,
|
|
115
|
+
N,
|
|
116
|
+
W
|
|
105
117
|
]), d(() => {
|
|
106
|
-
|
|
118
|
+
h !== void 0 && U.current && h.save(b(M)).catch(() => {});
|
|
107
119
|
}, [
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
120
|
+
h,
|
|
121
|
+
M,
|
|
122
|
+
E
|
|
111
123
|
]);
|
|
112
|
-
let J =
|
|
124
|
+
let J = f(/* @__PURE__ */ new Set()), Y = C === void 0 || a(C) ? void 0 : C.cache;
|
|
113
125
|
d(() => {
|
|
114
|
-
if (Y !== void 0 &&
|
|
115
|
-
let t =
|
|
126
|
+
if (Y !== void 0 && C !== void 0) for (let e of M) {
|
|
127
|
+
let t = C.descriptors[e.tag]?.targets;
|
|
116
128
|
if (e.status === "pending" || e.status === "failed") {
|
|
117
129
|
if (J.current.delete(e.id), t === void 0 || t.length === 0 || Y.hasIntent(e.id) || typeof e.input != "object" || e.input === null) continue;
|
|
118
130
|
Y.autoApply(t, e.input, e.id, { standing: !0 });
|
|
@@ -120,93 +132,110 @@ var h = (e, t, n, r, i) => [...e, {
|
|
|
120
132
|
}
|
|
121
133
|
}, [
|
|
122
134
|
Y,
|
|
123
|
-
|
|
124
|
-
|
|
135
|
+
C,
|
|
136
|
+
M
|
|
125
137
|
]);
|
|
126
|
-
let
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
138
|
+
let re = l((e, t, n) => {
|
|
139
|
+
if (!B.current || q?.aborted || C !== w.current) throw Error("Outbox ownership changed before enqueue");
|
|
140
|
+
let r = n?.stamp ?? F.current?.();
|
|
141
|
+
if (r !== void 0 && typeof r != "string") throw TypeError("Outbox stamp must be a string");
|
|
142
|
+
let i = _?.() ?? `obx_${H.current}_${V.current++}_${e}`;
|
|
143
|
+
N((n) => n.append({
|
|
144
|
+
id: i,
|
|
130
145
|
tag: e,
|
|
131
146
|
input: t,
|
|
132
147
|
status: "pending",
|
|
133
148
|
attempts: 0,
|
|
134
|
-
...
|
|
135
|
-
})),
|
|
136
|
-
}, [
|
|
149
|
+
...r === void 0 ? {} : { stamp: r }
|
|
150
|
+
})), D((e) => e + 1);
|
|
151
|
+
}, [
|
|
152
|
+
_,
|
|
153
|
+
N,
|
|
154
|
+
q,
|
|
155
|
+
C
|
|
156
|
+
]), X = f(void 0), Z = l(() => {
|
|
137
157
|
X.current !== void 0 && clearTimeout(X.current), X.current = void 0;
|
|
138
158
|
}, []);
|
|
139
159
|
d(() => Z, [Z]);
|
|
140
160
|
let Q = l(() => {
|
|
141
|
-
if (!
|
|
142
|
-
if (
|
|
143
|
-
|
|
144
|
-
let e = Promise.resolve().then(async () => {
|
|
145
|
-
for (;
|
|
146
|
-
let
|
|
147
|
-
if (
|
|
161
|
+
if (!U.current || !B.current) return Promise.resolve();
|
|
162
|
+
if (R.current !== void 0) return R.current;
|
|
163
|
+
z.current = !1, Z();
|
|
164
|
+
let e = j.current, t = Promise.resolve().then(async () => {
|
|
165
|
+
for (; B.current && j.current === e;) {
|
|
166
|
+
let t = A.current.next();
|
|
167
|
+
if (t === void 0) break;
|
|
148
168
|
try {
|
|
149
|
-
if (await
|
|
150
|
-
|
|
169
|
+
if (await I.current(t), !B.current || j.current !== e) break;
|
|
170
|
+
N((e) => e.update(t.id, (e) => ({
|
|
151
171
|
...e,
|
|
152
172
|
status: "sent"
|
|
153
173
|
})));
|
|
154
|
-
} catch (
|
|
155
|
-
if (!
|
|
156
|
-
let
|
|
157
|
-
|
|
174
|
+
} catch (n) {
|
|
175
|
+
if (!B.current || j.current !== e) break;
|
|
176
|
+
let r = L.current(n);
|
|
177
|
+
N((e) => e.update(t.id, (e) => r ? {
|
|
158
178
|
...e,
|
|
159
179
|
status: "conflict",
|
|
160
|
-
error:
|
|
180
|
+
error: n
|
|
161
181
|
} : {
|
|
162
182
|
...e,
|
|
163
183
|
status: "failed",
|
|
164
|
-
error:
|
|
184
|
+
error: n,
|
|
165
185
|
attempts: e.attempts + 1
|
|
166
|
-
})),
|
|
186
|
+
})), z.current = !0, r || (X.current = setTimeout(() => {
|
|
167
187
|
X.current = void 0, $.current();
|
|
168
|
-
},
|
|
188
|
+
}, P.current(t.attempts + 1)));
|
|
169
189
|
break;
|
|
170
190
|
}
|
|
171
191
|
}
|
|
172
192
|
}).finally(() => {
|
|
173
|
-
|
|
193
|
+
R.current === t && (R.current = void 0);
|
|
174
194
|
});
|
|
175
|
-
return
|
|
176
|
-
}, [
|
|
195
|
+
return R.current = t, t;
|
|
196
|
+
}, [N, Z]), $ = f(Q);
|
|
177
197
|
$.current = Q, d(() => {
|
|
178
|
-
|
|
198
|
+
k ? Q() : Z();
|
|
179
199
|
}, [
|
|
180
|
-
|
|
200
|
+
k,
|
|
181
201
|
Q,
|
|
182
202
|
Z
|
|
183
203
|
]), d(() => {
|
|
184
|
-
|
|
204
|
+
k && !z.current && Q();
|
|
185
205
|
}, [
|
|
186
|
-
|
|
187
|
-
|
|
206
|
+
E,
|
|
207
|
+
k,
|
|
188
208
|
Q
|
|
189
209
|
]);
|
|
190
|
-
let
|
|
191
|
-
|
|
210
|
+
let ie = l((e, t) => {
|
|
211
|
+
B.current && !q?.aborted && C === w.current && (N((n) => n.update(e, (e) => e.status === "conflict" ? {
|
|
192
212
|
...e,
|
|
193
213
|
input: t,
|
|
194
214
|
status: "pending",
|
|
195
215
|
error: void 0
|
|
196
|
-
} : e)),
|
|
216
|
+
} : e)), k && Q());
|
|
197
217
|
}, [
|
|
198
|
-
|
|
218
|
+
k,
|
|
219
|
+
Q,
|
|
220
|
+
N,
|
|
221
|
+
q,
|
|
222
|
+
C
|
|
223
|
+
]), ae = l((e) => !B.current || q?.aborted || C !== w.current || !A.current.snapshot().some((t) => t.id === e && t.status === "conflict") || (Y?.revertByMutation(e), !B.current || q?.aborted || C !== w.current) || !A.current.discardConflict(e) ? !1 : (J.current.delete(e), z.current = !1, T((e) => e + 1), D((e) => e + 1), k && Q(), !0), [
|
|
224
|
+
k,
|
|
199
225
|
Q,
|
|
200
|
-
|
|
226
|
+
Y,
|
|
227
|
+
q,
|
|
228
|
+
C
|
|
201
229
|
]);
|
|
202
230
|
return {
|
|
203
|
-
queue:
|
|
204
|
-
enqueue:
|
|
231
|
+
queue: M,
|
|
232
|
+
enqueue: re,
|
|
205
233
|
replay: Q,
|
|
206
|
-
online:
|
|
207
|
-
pending:
|
|
208
|
-
conflicts:
|
|
209
|
-
resolveConflict:
|
|
234
|
+
online: k,
|
|
235
|
+
pending: M.reduce((e, t) => e + +(t.status === "pending" || t.status === "failed"), 0),
|
|
236
|
+
conflicts: M.filter((e) => e.status === "conflict"),
|
|
237
|
+
resolveConflict: ie,
|
|
238
|
+
discardConflict: ae
|
|
210
239
|
};
|
|
211
240
|
};
|
|
212
|
-
export {
|
|
241
|
+
export { b as clearSent, S as defaultOutboxRetryDelay, m as enqueueEntry, v as markConflict, _ as markFailed, g as markSent, x as replayable, y as resolveConflictEntry, C as useOutbox };
|
package/dist/outboxState.js
CHANGED
|
@@ -30,6 +30,13 @@ var e = class {
|
|
|
30
30
|
e !== r && (this.entries[n] = r, r.status !== "sent" && n < this.cursor && (this.cursor = n), this.cached = void 0);
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
+
discardConflict(e) {
|
|
34
|
+
if (!(this.positions.get(e) ?? []).some((e) => this.entries[e].status === "conflict")) return !1;
|
|
35
|
+
let t = this.entries.filter((t) => t.id !== e || t.status !== "conflict");
|
|
36
|
+
this.reset();
|
|
37
|
+
for (let e of t) this.append(e);
|
|
38
|
+
return !0;
|
|
39
|
+
}
|
|
33
40
|
next() {
|
|
34
41
|
for (; this.cursor < this.entries.length;) {
|
|
35
42
|
let e = this.entries[this.cursor];
|
package/dist/platform.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { browserOnlineSource as e } from "./onlineSource.js";
|
|
2
|
+
import { browserStoreStorage as t, setStoreStorage as n } from "./storeStorage.js";
|
|
3
3
|
import { useSyncExternalStore as r } from "react";
|
|
4
4
|
// src/platform.ts
|
|
5
5
|
var i = (e, t = {}) => {
|
|
@@ -73,7 +73,7 @@ var i = (e, t = {}) => {
|
|
|
73
73
|
if (n === void 0) throw Error("platform: no global WebSocket in this environment");
|
|
74
74
|
let r = typeof t == "object" && !Array.isArray(t) ? void 0 : t;
|
|
75
75
|
return r === void 0 ? new n(e) : new n(e, r);
|
|
76
|
-
}, p = (
|
|
76
|
+
}, p = (n = {}) => {
|
|
77
77
|
let r = typeof window < "u", i = d(), s = r ? navigator.userAgent : "", p = r ? /jsdom/i.test(s) ? "test" : "browser" : "node", m = u();
|
|
78
78
|
return a({
|
|
79
79
|
platform: {
|
|
@@ -82,14 +82,14 @@ var i = (e, t = {}) => {
|
|
|
82
82
|
installed: i
|
|
83
83
|
},
|
|
84
84
|
webSocket: f,
|
|
85
|
-
storage:
|
|
85
|
+
storage: t,
|
|
86
86
|
secureStorage: o("a browser tab has no secure store a page can read; the session is an HttpOnly cookie the server sets"),
|
|
87
|
-
online:
|
|
87
|
+
online: e,
|
|
88
88
|
lifecycle: c,
|
|
89
89
|
links: l,
|
|
90
90
|
...m === void 0 ? {} : { notifications: m },
|
|
91
91
|
clock: { now: () => Date.now() },
|
|
92
|
-
...
|
|
92
|
+
...n
|
|
93
93
|
});
|
|
94
94
|
}, m = Symbol.for("@voltro/client/platform"), h = () => {
|
|
95
95
|
let e = globalThis, t = e[m];
|
|
@@ -101,15 +101,15 @@ var i = (e, t = {}) => {
|
|
|
101
101
|
};
|
|
102
102
|
return e[m] = n, n;
|
|
103
103
|
}, g = (e) => {
|
|
104
|
-
let
|
|
105
|
-
|
|
106
|
-
for (let e of
|
|
104
|
+
let t = h();
|
|
105
|
+
t.adapter = e, n(e.storage);
|
|
106
|
+
for (let e of t.listeners) e();
|
|
107
107
|
}, _ = () => {
|
|
108
108
|
let e = h();
|
|
109
109
|
return e.adapter === void 0 ? (e.fallback === void 0 && (e.fallback = p()), e.fallback) : e.adapter;
|
|
110
110
|
}, v = () => h().adapter !== void 0, y = () => {
|
|
111
111
|
let e = h();
|
|
112
|
-
e.adapter = void 0, e.fallback = void 0,
|
|
112
|
+
e.adapter = void 0, e.fallback = void 0, n(null);
|
|
113
113
|
for (let t of e.listeners) t();
|
|
114
114
|
}, b = (e) => {
|
|
115
115
|
let t = h();
|
package/dist/query.js
CHANGED
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { runRpcPromise as t } from "./runRpc.js";
|
|
3
|
-
import { awaitResolvedApi as n } from "./awaitResolvedApi.js";
|
|
4
|
-
import { Effect as r, Option as i, Stream as a } from "effect";
|
|
5
|
-
import { firstEventValue as o } from "@voltro/protocol";
|
|
1
|
+
import { rpcCallOnce as e } from "./rpcCallOnce.js";
|
|
6
2
|
// src/queryOnce.ts
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
return o(l, g, "[loader.query]");
|
|
10
|
-
};
|
|
11
|
-
export { s as queryOnce };
|
|
3
|
+
var t = async (t, n, r, i, a) => e(t, n, r, i ?? {}, a, "[loader.query]");
|
|
4
|
+
export { t as queryOnce };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { awaitResolvedApi as e, bindResolvedRpcInvocationOwner as t, rpcInvocationOwnerCurrent as n } from "./awaitResolvedApi.js";
|
|
2
|
+
import { ConnectionPrerequisiteInvalidated as r } from "./connectionPrerequisite.js";
|
|
3
|
+
import { runRpcPromise as i } from "./runRpc.js";
|
|
4
|
+
import { resolveByTag as a } from "./tagWalk.js";
|
|
5
|
+
import { Effect as o, Option as s, Stream as c } from "effect";
|
|
6
|
+
import { firstEventValue as l } from "@voltro/protocol";
|
|
7
|
+
// src/rpcCallOnce.ts
|
|
8
|
+
var u = async (u, d, f, p, m, h, g) => {
|
|
9
|
+
let _ = () => {
|
|
10
|
+
if (g && !n(g, u.current)) throw new r("inactive");
|
|
11
|
+
};
|
|
12
|
+
_();
|
|
13
|
+
let v = g?.subject, y = await e(u, d, f, m);
|
|
14
|
+
if (v?.aborted) throw new r("inactive");
|
|
15
|
+
g && t(g, y), _();
|
|
16
|
+
let { runtime: b, client: x } = y;
|
|
17
|
+
m?.throwIfAborted();
|
|
18
|
+
let S = g ? new AbortController() : void 0, C = g ? [.../* @__PURE__ */ new Set([g.subject, ...m ? [m] : []])] : [], w = () => S?.abort();
|
|
19
|
+
for (let e of C) e.aborted ? w() : e.addEventListener("abort", w, { once: !0 });
|
|
20
|
+
try {
|
|
21
|
+
_();
|
|
22
|
+
let e = a(x, f)(p), t = o.isEffect(e), n = t ? e : c.runHead(e).pipe(o.flatMap((e) => s.isNone(e) ? o.fail(/* @__PURE__ */ Error(`${h} ${f}: the query ended before its first snapshot`)) : o.succeed(e.value))), r = await i(b, o.suspend(() => (_(), n)), { signal: S?.signal ?? m });
|
|
23
|
+
return _(), t ? r : l(f, r, h);
|
|
24
|
+
} catch (e) {
|
|
25
|
+
throw _(), e;
|
|
26
|
+
} finally {
|
|
27
|
+
for (let e of C) e.removeEventListener("abort", w);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
export { u as rpcCallOnce };
|
package/dist/runRpc.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { squashRpcCause as e } from "./squashRpcCause.js";
|
|
2
2
|
import { rememberRpcErrorKind as t, rpcErrorKind as n } from "./rpcErrorKind.js";
|
|
3
|
-
import { Cause as r,
|
|
3
|
+
import { Cause as r, Effect as i, Exit as a, Option as o } from "effect";
|
|
4
4
|
// src/runRpc.ts
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
var s = (e) => i.try({
|
|
6
|
+
try: e,
|
|
7
|
+
catch: (e) => t(e, n(e, "client"))
|
|
8
|
+
}).pipe(i.flatten), c = async (i, s, c) => {
|
|
9
|
+
let l = await i.runPromiseExit(s, c?.signal === void 0 ? void 0 : { signal: c.signal });
|
|
10
|
+
if (a.isSuccess(l)) return l.value;
|
|
11
|
+
let u = e(l.cause), d = r.findErrorOption(l.cause), f = o.isSome(d) ? n(d.value, "handler") : "unknown";
|
|
9
12
|
throw t(u, f);
|
|
10
13
|
};
|
|
11
|
-
export {
|
|
14
|
+
export { s as deferRpcMethod, c as runRpcPromise };
|