@voltro/client 0.90.0 → 0.91.1
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 +131 -0
- package/THIRD-PARTY-NOTICES.md +1 -1
- package/dist/apiRuntime.js +50 -50
- package/dist/apiSupervisor.js +25 -25
- package/dist/awaitResolvedApi.js +17 -17
- package/dist/bootstrap.js +8 -8
- package/dist/connectionPrerequisite.js +18 -18
- package/dist/connectionSetupController.js +97 -97
- package/dist/createHooks.js +11 -11
- package/dist/form.js +7 -7
- package/dist/index.js +82 -82
- package/dist/outbox.js +133 -133
- package/dist/platform.js +10 -10
- package/dist/rpcCallOnce.js +10 -10
- 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/uploadClient.js +35 -35
- package/dist/useAction.js +59 -59
- 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 +89 -89
- package/dist/useOnRpcError.js +5 -5
- package/dist/usePreloadedSubscription.js +6 -6
- package/dist/useRpcCaller.js +21 -21
- package/dist/useRpcInvocationOwner.js +6 -6
- package/dist/useTranscription.js +27 -27
- package/dist/useWorkflow.js +22 -22
- package/dist/workflowClient.js +33 -33
- package/package.json +3 -3
package/dist/outbox.js
CHANGED
|
@@ -1,180 +1,180 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { runRpcPromise as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { useApiOnline as
|
|
8
|
-
import { OutboxState as
|
|
9
|
-
import { useCallback as
|
|
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
|
+
import { useApiOnline as s } from "./useApiOnline.js";
|
|
8
|
+
import { OutboxState as c } from "./outboxState.js";
|
|
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
|
|
51
|
-
|
|
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
|
-
if (
|
|
69
|
-
let
|
|
70
|
-
await
|
|
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
|
+
d(() => {
|
|
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 });
|
|
71
71
|
});
|
|
72
|
-
let
|
|
73
|
-
|
|
74
|
-
let
|
|
75
|
-
|
|
76
|
-
|
|
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;
|
|
77
77
|
}), []);
|
|
78
|
-
let
|
|
79
|
-
|
|
80
|
-
if (
|
|
81
|
-
let e =
|
|
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;
|
|
79
|
+
d(() => {
|
|
80
|
+
if (K === void 0) return;
|
|
81
|
+
let e = K.subjectSignal;
|
|
82
82
|
if (e.aborted) return;
|
|
83
83
|
let t = () => {
|
|
84
|
-
|
|
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);
|
|
85
85
|
};
|
|
86
86
|
return e.addEventListener("abort", t, { once: !0 }), () => {
|
|
87
87
|
e.removeEventListener("abort", t);
|
|
88
88
|
};
|
|
89
89
|
}, [
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
]),
|
|
94
|
-
if (
|
|
90
|
+
K,
|
|
91
|
+
h,
|
|
92
|
+
W
|
|
93
|
+
]), d(() => {
|
|
94
|
+
if (h === void 0) return;
|
|
95
95
|
let e = !1;
|
|
96
|
-
return
|
|
97
|
-
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
98
|
if (e.status !== "conflict" || !(e.error instanceof Error)) return e;
|
|
99
99
|
let t = !1;
|
|
100
100
|
try {
|
|
101
|
-
t =
|
|
101
|
+
t = L.current(e.error);
|
|
102
102
|
} catch {}
|
|
103
103
|
return t ? e : {
|
|
104
104
|
...e,
|
|
105
105
|
status: "failed"
|
|
106
106
|
};
|
|
107
|
-
}))),
|
|
107
|
+
}))), D((e) => e + 1));
|
|
108
108
|
}, () => {
|
|
109
|
-
e || (
|
|
109
|
+
e || (U.current = !0, D((e) => e + 1));
|
|
110
110
|
}), () => {
|
|
111
111
|
e = !0;
|
|
112
112
|
};
|
|
113
113
|
}, [
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
]),
|
|
118
|
-
|
|
114
|
+
h,
|
|
115
|
+
N,
|
|
116
|
+
W
|
|
117
|
+
]), d(() => {
|
|
118
|
+
h !== void 0 && U.current && h.save(b(M)).catch(() => {});
|
|
119
119
|
}, [
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
120
|
+
h,
|
|
121
|
+
M,
|
|
122
|
+
E
|
|
123
123
|
]);
|
|
124
|
-
let
|
|
125
|
-
|
|
126
|
-
if (
|
|
127
|
-
let t =
|
|
124
|
+
let J = f(/* @__PURE__ */ new Set()), Y = C === void 0 || a(C) ? void 0 : C.cache;
|
|
125
|
+
d(() => {
|
|
126
|
+
if (Y !== void 0 && C !== void 0) for (let e of M) {
|
|
127
|
+
let t = C.descriptors[e.tag]?.targets;
|
|
128
128
|
if (e.status === "pending" || e.status === "failed") {
|
|
129
|
-
if (
|
|
130
|
-
|
|
131
|
-
} else
|
|
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;
|
|
130
|
+
Y.autoApply(t, e.input, e.id, { standing: !0 });
|
|
131
|
+
} else J.current.has(e.id) || (J.current.add(e.id), e.status === "sent" ? Y.confirmByMutation(e.id) : Y.revertByMutation(e.id));
|
|
132
132
|
}
|
|
133
133
|
}, [
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
134
|
+
Y,
|
|
135
|
+
C,
|
|
136
|
+
M
|
|
137
137
|
]);
|
|
138
|
-
let
|
|
139
|
-
if (!
|
|
140
|
-
let r = n?.stamp ??
|
|
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
141
|
if (r !== void 0 && typeof r != "string") throw TypeError("Outbox stamp must be a string");
|
|
142
|
-
let i =
|
|
143
|
-
|
|
142
|
+
let i = _?.() ?? `obx_${H.current}_${V.current++}_${e}`;
|
|
143
|
+
N((n) => n.append({
|
|
144
144
|
id: i,
|
|
145
145
|
tag: e,
|
|
146
146
|
input: t,
|
|
147
147
|
status: "pending",
|
|
148
148
|
attempts: 0,
|
|
149
149
|
...r === void 0 ? {} : { stamp: r }
|
|
150
|
-
})),
|
|
150
|
+
})), D((e) => e + 1);
|
|
151
151
|
}, [
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
]), X =
|
|
152
|
+
_,
|
|
153
|
+
N,
|
|
154
|
+
q,
|
|
155
|
+
C
|
|
156
|
+
]), X = f(void 0), Z = l(() => {
|
|
157
157
|
X.current !== void 0 && clearTimeout(X.current), X.current = void 0;
|
|
158
158
|
}, []);
|
|
159
|
-
|
|
160
|
-
let Q =
|
|
161
|
-
if (!
|
|
162
|
-
if (
|
|
163
|
-
|
|
164
|
-
let e =
|
|
165
|
-
for (;
|
|
166
|
-
let t =
|
|
159
|
+
d(() => Z, [Z]);
|
|
160
|
+
let Q = l(() => {
|
|
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
167
|
if (t === void 0) break;
|
|
168
168
|
try {
|
|
169
|
-
if (await
|
|
170
|
-
|
|
169
|
+
if (await I.current(t), !B.current || j.current !== e) break;
|
|
170
|
+
N((e) => e.update(t.id, (e) => ({
|
|
171
171
|
...e,
|
|
172
172
|
status: "sent"
|
|
173
173
|
})));
|
|
174
174
|
} catch (n) {
|
|
175
|
-
if (!
|
|
176
|
-
let r =
|
|
177
|
-
|
|
175
|
+
if (!B.current || j.current !== e) break;
|
|
176
|
+
let r = L.current(n);
|
|
177
|
+
N((e) => e.update(t.id, (e) => r ? {
|
|
178
178
|
...e,
|
|
179
179
|
status: "conflict",
|
|
180
180
|
error: n
|
|
@@ -183,59 +183,59 @@ var f = (e, t, n, r, i) => [...e, {
|
|
|
183
183
|
status: "failed",
|
|
184
184
|
error: n,
|
|
185
185
|
attempts: e.attempts + 1
|
|
186
|
-
})),
|
|
186
|
+
})), z.current = !0, r || (X.current = setTimeout(() => {
|
|
187
187
|
X.current = void 0, $.current();
|
|
188
|
-
},
|
|
188
|
+
}, P.current(t.attempts + 1)));
|
|
189
189
|
break;
|
|
190
190
|
}
|
|
191
191
|
}
|
|
192
192
|
}).finally(() => {
|
|
193
|
-
|
|
193
|
+
R.current === t && (R.current = void 0);
|
|
194
194
|
});
|
|
195
|
-
return
|
|
196
|
-
}, [
|
|
197
|
-
$.current = Q,
|
|
198
|
-
|
|
195
|
+
return R.current = t, t;
|
|
196
|
+
}, [N, Z]), $ = f(Q);
|
|
197
|
+
$.current = Q, d(() => {
|
|
198
|
+
k ? Q() : Z();
|
|
199
199
|
}, [
|
|
200
|
-
|
|
200
|
+
k,
|
|
201
201
|
Q,
|
|
202
202
|
Z
|
|
203
|
-
]),
|
|
204
|
-
|
|
203
|
+
]), d(() => {
|
|
204
|
+
k && !z.current && Q();
|
|
205
205
|
}, [
|
|
206
|
-
|
|
207
|
-
|
|
206
|
+
E,
|
|
207
|
+
k,
|
|
208
208
|
Q
|
|
209
209
|
]);
|
|
210
|
-
let ie =
|
|
211
|
-
|
|
210
|
+
let ie = l((e, t) => {
|
|
211
|
+
B.current && !q?.aborted && C === w.current && (N((n) => n.update(e, (e) => e.status === "conflict" ? {
|
|
212
212
|
...e,
|
|
213
213
|
input: t,
|
|
214
214
|
status: "pending",
|
|
215
215
|
error: void 0
|
|
216
|
-
} : e)),
|
|
216
|
+
} : e)), k && Q());
|
|
217
217
|
}, [
|
|
218
|
-
|
|
218
|
+
k,
|
|
219
219
|
Q,
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
]), ae =
|
|
224
|
-
|
|
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,
|
|
225
225
|
Q,
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
226
|
+
Y,
|
|
227
|
+
q,
|
|
228
|
+
C
|
|
229
229
|
]);
|
|
230
230
|
return {
|
|
231
|
-
queue:
|
|
232
|
-
enqueue:
|
|
231
|
+
queue: M,
|
|
232
|
+
enqueue: re,
|
|
233
233
|
replay: Q,
|
|
234
|
-
online:
|
|
235
|
-
pending:
|
|
236
|
-
conflicts:
|
|
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
237
|
resolveConflict: ie,
|
|
238
238
|
discardConflict: ae
|
|
239
239
|
};
|
|
240
240
|
};
|
|
241
|
-
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/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/rpcCallOnce.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
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
5
|
import { Effect as o, Option as s, Stream as c } from "effect";
|
|
6
6
|
import { firstEventValue as l } from "@voltro/protocol";
|
|
7
7
|
// src/rpcCallOnce.ts
|
|
8
8
|
var u = async (u, d, f, p, m, h, g) => {
|
|
9
9
|
let _ = () => {
|
|
10
|
-
if (g && !
|
|
10
|
+
if (g && !n(g, u.current)) throw new r("inactive");
|
|
11
11
|
};
|
|
12
12
|
_();
|
|
13
|
-
let v = g?.subject, y = await
|
|
14
|
-
if (v?.aborted) throw new
|
|
15
|
-
g &&
|
|
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
16
|
let { runtime: b, client: x } = y;
|
|
17
17
|
m?.throwIfAborted();
|
|
18
18
|
let S = g ? new AbortController() : void 0, C = g ? [.../* @__PURE__ */ new Set([g.subject, ...m ? [m] : []])] : [], w = () => S?.abort();
|
|
19
19
|
for (let e of C) e.aborted ? w() : e.addEventListener("abort", w, { once: !0 });
|
|
20
20
|
try {
|
|
21
21
|
_();
|
|
22
|
-
let
|
|
23
|
-
return _(),
|
|
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
24
|
} catch (e) {
|
|
25
25
|
throw _(), e;
|
|
26
26
|
} finally {
|
package/dist/runtime.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { stableKey as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { resolveByTag as
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
export {
|
|
1
|
+
import { buildApiRuntime as e, makeProtocolOpenRecovery as t } from "./apiRuntime.js";
|
|
2
|
+
import { startApiSupervisor as n } from "./apiSupervisor.js";
|
|
3
|
+
import { LoadingSubscriptionCache as r, SubscriptionCache as i, supersedesConfirmedPatches as a } from "./subscriptionCache.js";
|
|
4
|
+
import { stableKey as o } from "./stableKey.js";
|
|
5
|
+
import { RpcErrorBus as s } from "./rpcErrorBus.js";
|
|
6
|
+
import { INITIAL_RECOVERY_SNAPSHOT as c, RecoveryCoordinator as l, recoveryCoordinatorFor as u, resolveRecoveryOptions as d } from "./recoveryCoordinator.js";
|
|
7
|
+
import { apiConnectivity as f } from "./apiConnectivity.js";
|
|
8
|
+
import { runRpcPromise as p } from "./runRpc.js";
|
|
9
|
+
import { rememberRpcErrorKind as m, rpcErrorKind as h } from "./rpcErrorKind.js";
|
|
10
|
+
import { resolveByTag as g } from "./tagWalk.js";
|
|
11
|
+
import { DEFAULT_SERVICE_CALL_TIMEOUT_MS as _, makeServiceClient as v, serviceApi as y } from "./serviceClient.js";
|
|
12
|
+
import { isUnauthenticated as b, wireAuthRefresh as x } from "./authRefresh.js";
|
|
13
|
+
import { publishClientTrace as S, publishClientTraceRefusal as C, subscribeClientTraceRefusals as w, subscribeClientTraces as T } from "./traceBus.js";
|
|
14
|
+
import { publishClientError as E, reportClientError as D, subscribeClientErrors as O } from "./clientErrorBus.js";
|
|
15
|
+
import { clearClientDiagnostics as k, clientDiagnosticsSnapshot as A, recordClientDiagnostic as j, subscribeClientDiagnostics as M } from "./clientDiagnostics.js";
|
|
16
|
+
export { _ as DEFAULT_SERVICE_CALL_TIMEOUT_MS, c as INITIAL_RECOVERY_SNAPSHOT, r as LoadingSubscriptionCache, l as RecoveryCoordinator, s as RpcErrorBus, i as SubscriptionCache, f as apiConnectivity, e as buildApiRuntime, k as clearClientDiagnostics, A as clientDiagnosticsSnapshot, b as isUnauthenticated, t as makeProtocolOpenRecovery, v as makeServiceClient, E as publishClientError, S as publishClientTrace, C as publishClientTraceRefusal, j as recordClientDiagnostic, u as recoveryCoordinatorFor, m as rememberRpcErrorKind, D as reportClientError, g as resolveByTag, d as resolveRecoveryOptions, h as rpcErrorKind, p as runRpcPromise, y as serviceApi, o as stableKey, n as startApiSupervisor, M as subscribeClientDiagnostics, O as subscribeClientErrors, w as subscribeClientTraceRefusals, T as subscribeClientTraces, a as supersedesConfirmedPatches, x as wireAuthRefresh };
|
package/dist/runtimeContext.js
CHANGED
|
@@ -37,7 +37,7 @@ var l = () => {
|
|
|
37
37
|
}, C = () => {
|
|
38
38
|
let e = o(r);
|
|
39
39
|
return e ? (b || (b = !0, x !== null && (clearTimeout(x), x = null)), e) : (globalThis.window !== void 0 && !y && !b && x === null && process.env.NODE_ENV !== "production" && (x = setTimeout(() => {
|
|
40
|
-
x = null,
|
|
40
|
+
x = null, y || b || (y = !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>."));
|
|
41
41
|
}, 0)), v);
|
|
42
42
|
}, w = (e) => {
|
|
43
43
|
let t = C(), n = t.demand;
|
package/dist/serviceClient.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { buildApiRuntime as e } from "./apiRuntime.js";
|
|
2
|
+
import { freshIdempotencyKey as t, withIdempotencyKey as n } from "./mutationIdentity.js";
|
|
3
|
+
import { squashRpcCause as r } from "./squashRpcCause.js";
|
|
4
|
+
import { resolveByTag as i } from "./tagWalk.js";
|
|
5
5
|
import { Duration as a, Effect as o, Exit as s, Option as c, Schedule as l, Stream as u } from "effect";
|
|
6
6
|
import * as d from "effect/http/Headers";
|
|
7
7
|
import { RpcClient as f } from "effect/rpc";
|
|
@@ -19,14 +19,14 @@ var g = (e) => e?._tag === "MutationInFlight", _ = 1e4, v = (e, t) => {
|
|
|
19
19
|
message: "client closed"
|
|
20
20
|
}));
|
|
21
21
|
if (x !== void 0) return x;
|
|
22
|
-
let
|
|
23
|
-
return x =
|
|
22
|
+
let t = typeof _.wsUrl == "function" ? _.wsUrl() : _.wsUrl, n = _.webSocketConstructor ?? ((e, t) => new globalThis.WebSocket(e, typeof t == "object" && !Array.isArray(t) ? void 0 : t));
|
|
23
|
+
return x = e({
|
|
24
24
|
name: `service:${_.name}`,
|
|
25
|
-
wsUrl:
|
|
25
|
+
wsUrl: t,
|
|
26
26
|
roleEndpoints: y,
|
|
27
27
|
group: _.group,
|
|
28
28
|
headers: async () => ({ authorization: `Bearer ${_.token()}` }),
|
|
29
|
-
webSocketConstructor:
|
|
29
|
+
webSocketConstructor: n,
|
|
30
30
|
surfaceAudience: "service"
|
|
31
31
|
}).then((e) => (S = e, e), (e) => {
|
|
32
32
|
throw x = void 0, e;
|
|
@@ -47,7 +47,7 @@ var g = (e) => e?._tag === "MutationInFlight", _ = 1e4, v = (e, t) => {
|
|
|
47
47
|
if (c.isNone(e)) return o.fail(/* @__PURE__ */ Error("the query stream ended before its first snapshot"));
|
|
48
48
|
let t = e.value;
|
|
49
49
|
return t._tag === "error" ? o.fail(t.error) : o.succeed(t.data);
|
|
50
|
-
})), O = (e,
|
|
50
|
+
})), O = (e, r, s) => {
|
|
51
51
|
let c = v(_, e), u = s?.timeoutMs ?? b, d = Date.now(), f = (t) => {
|
|
52
52
|
_.onCall?.({
|
|
53
53
|
api: _.name,
|
|
@@ -61,13 +61,13 @@ var g = (e) => e?._tag === "MutationInFlight", _ = 1e4, v = (e, t) => {
|
|
|
61
61
|
let u = yield* o.tryPromise({
|
|
62
62
|
try: () => w(),
|
|
63
63
|
catch: (t) => T(e, C ? "closed" : "transport", `could not build the connection: ${String(t)}`)
|
|
64
|
-
}), d =
|
|
64
|
+
}), d = i(u.client, e);
|
|
65
65
|
if (c === "query") {
|
|
66
|
-
let e = d(
|
|
66
|
+
let e = d(r);
|
|
67
67
|
return yield* E(D(e));
|
|
68
68
|
}
|
|
69
|
-
let f = s?.idempotencyKey === void 0 && _.ambientIdempotencyKey !== void 0 ? yield* _.ambientIdempotencyKey(e,
|
|
70
|
-
return yield* E(
|
|
69
|
+
let f = s?.idempotencyKey === void 0 && _.ambientIdempotencyKey !== void 0 ? yield* _.ambientIdempotencyKey(e, r) : void 0, p = s?.idempotencyKey ?? f ?? t();
|
|
70
|
+
return yield* E(n(d(r), p)).pipe(o.tapError((e) => o.sync(() => {
|
|
71
71
|
g(e) && (h = !0);
|
|
72
72
|
})), o.retry({
|
|
73
73
|
while: g,
|
|
@@ -81,26 +81,26 @@ var g = (e) => e?._tag === "MutationInFlight", _ = 1e4, v = (e, t) => {
|
|
|
81
81
|
};
|
|
82
82
|
return {
|
|
83
83
|
name: _.name,
|
|
84
|
-
call: async (t, n
|
|
85
|
-
let i = await o.runPromiseExit(O(t, n
|
|
84
|
+
call: async (e, t, n) => {
|
|
85
|
+
let i = await o.runPromiseExit(O(e, t, n), n?.signal === void 0 ? void 0 : { signal: n.signal });
|
|
86
86
|
if (s.isSuccess(i)) return i.value;
|
|
87
|
-
throw
|
|
87
|
+
throw r(i.cause);
|
|
88
88
|
},
|
|
89
89
|
callEffect: O,
|
|
90
|
-
subscribe: (e,
|
|
90
|
+
subscribe: (e, t, n) => {
|
|
91
91
|
if (v(_, e) !== "query") throw Error(`apis.${_.name}: '${e}' is not a query — only a query can be subscribed to`);
|
|
92
|
-
let
|
|
92
|
+
let r, a = !1, o = -2, s;
|
|
93
93
|
return w().then((c) => {
|
|
94
94
|
if (a) return;
|
|
95
|
-
let l = [e,
|
|
95
|
+
let l = [e, t], u = c.cache.subscribe(l, () => i(c.client, e)(t), c.runtime, () => {
|
|
96
96
|
let e = u.getSnapshot();
|
|
97
|
-
e.error !== void 0 && e.error !== s && (s = e.error,
|
|
97
|
+
e.error !== void 0 && e.error !== s && (s = e.error, n.onError?.(e.error)), e.revision >= 0 && e.revision !== o && e.data !== void 0 && (o = e.revision, n.onValue(e.data));
|
|
98
98
|
});
|
|
99
|
-
|
|
99
|
+
r = u.unsubscribe;
|
|
100
100
|
}, (t) => {
|
|
101
|
-
|
|
101
|
+
n.onError?.(T(e, "transport", `could not build the connection: ${String(t)}`));
|
|
102
102
|
}), { unsubscribe: () => {
|
|
103
|
-
a = !0,
|
|
103
|
+
a = !0, r?.();
|
|
104
104
|
} };
|
|
105
105
|
},
|
|
106
106
|
connected: () => S !== void 0,
|