@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/README.md
CHANGED
|
@@ -20,7 +20,29 @@ Installation, guides, the full API reference, and examples all live in the
|
|
|
20
20
|
**[Voltro documentation](https://docs.voltro.dev/docs/intro/getting-started)** — the single source of truth. This README is
|
|
21
21
|
deliberately short so there is nothing here to drift out of date.
|
|
22
22
|
|
|
23
|
+
Workflow commands and control reads belong to their original API, Subject and
|
|
24
|
+
mounted view. See the [callback lifetime contract](https://docs.voltro.dev/docs/reference/hooks-data#workflow-callback-lifetime)
|
|
25
|
+
for account changes, concurrent calls and uncertain remote outcomes.
|
|
26
|
+
|
|
27
|
+
Uploads capture original files and metadata and own every local batch. See the
|
|
28
|
+
[upload lifetime contract](https://docs.voltro.dev/docs/plugins/storage#upload-callback-lifetime)
|
|
29
|
+
for cancellation, reset and unconfirmed physical cleanup.
|
|
30
|
+
|
|
31
|
+
Transcription owns one local intent and captures its original extra data. See
|
|
32
|
+
[media modalities](https://docs.voltro.dev/docs/ai/media) and
|
|
33
|
+
[action withdrawal](https://docs.voltro.dev/docs/data/actions) for cancellation
|
|
34
|
+
and uncertain server outcomes.
|
|
35
|
+
|
|
23
36
|
## License
|
|
24
37
|
|
|
25
38
|
Proprietary. © 2026 Voltro UG. Your use is governed by the
|
|
26
39
|
[Terms of Service](https://voltro.cloud/legal/terms). See the bundled `LICENSE`.
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
## Analytics taxonomy without RPC bindings
|
|
43
|
+
|
|
44
|
+
`@voltro/client/analytics` exports the existing `defineEvent`, `eventCatalog`,
|
|
45
|
+
`validateEventPayload` and `createAnalytics`, plus their types and
|
|
46
|
+
`TrackingEvent`/`TrackingSink`. It loads no RPC or hook binding. The Client root
|
|
47
|
+
re-exports the same implementation. `createAnalytics` remains best effort;
|
|
48
|
+
consent and durable telemetry delivery require their owning runtime contracts.
|
package/THIRD-PARTY-NOTICES.md
CHANGED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { Schema } from 'effect';
|
|
2
|
+
|
|
3
|
+
export declare interface Analytics<E extends ReadonlyArray<EventDescriptor<string, unknown>>> {
|
|
4
|
+
/** Emit an event — name + payload typed by the catalog; validated at runtime. */
|
|
5
|
+
readonly track: <K extends keyof EventMap<E> & string>(name: K, payload: EventMap<E>[K]) => void;
|
|
6
|
+
readonly names: ReadonlyArray<string>;
|
|
7
|
+
readonly catalog: EventCatalog;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Build a typed analytics surface from a declared event list + a sink. `track`
|
|
12
|
+
* is typed against the catalog; on a payload that fails its Schema it logs a
|
|
13
|
+
* loud dev error (the "bad event shape is loud" rule) and still forwards (best-
|
|
14
|
+
* effort — losing the event would be worse than a slightly-off payload).
|
|
15
|
+
*/
|
|
16
|
+
export declare const createAnalytics: <const E extends ReadonlyArray<EventDescriptor<string, unknown>>>(events: E, sink: TrackingSink) => Analytics<E>;
|
|
17
|
+
|
|
18
|
+
/** Declare a typed analytics event. */
|
|
19
|
+
export declare const defineEvent: <const Name extends string, A, I>(name: Name, payload: Schema.Codec<A, I>) => EventDescriptor<Name, A>;
|
|
20
|
+
|
|
21
|
+
export declare interface EventCatalog {
|
|
22
|
+
readonly names: ReadonlyArray<string>;
|
|
23
|
+
readonly get: (name: string) => EventDescriptor<string, unknown> | undefined;
|
|
24
|
+
/** Discovery inventory: every event's name + its JSON-Schema-able payload. */
|
|
25
|
+
readonly events: ReadonlyArray<EventDescriptor<string, unknown>>;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export declare const eventCatalog: (events: ReadonlyArray<EventDescriptor<string, unknown>>) => EventCatalog;
|
|
29
|
+
|
|
30
|
+
export declare interface EventDescriptor<Name extends string, A> {
|
|
31
|
+
readonly name: Name;
|
|
32
|
+
/** The payload Schema, erased — `Schema` is INVARIANT in its decoded type, so
|
|
33
|
+
* storing `Schema.Schema<A>` here would make `EventDescriptor` invariant in
|
|
34
|
+
* `A` and break a heterogeneous catalog. The decoded type is carried by the
|
|
35
|
+
* covariant phantom `_type` below instead, so `EventDescriptor<string,
|
|
36
|
+
* unknown>` accepts every typed descriptor AND `track` stays typed. */
|
|
37
|
+
readonly payload: Schema.Top;
|
|
38
|
+
/** Phantom — never present at runtime; carries the decoded payload type for
|
|
39
|
+
* `track`'s compile-time signature. Covariant (optional), so erasure works. */
|
|
40
|
+
readonly _type?: A;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** Map a tuple of event descriptors → `{ name: payloadType }` for typing track.
|
|
44
|
+
* The covariant `_type` phantom lets `EventDescriptor<string, unknown>` accept
|
|
45
|
+
* every typed descriptor as a constraint while inference still recovers `A`. */
|
|
46
|
+
declare type EventMap<E extends ReadonlyArray<EventDescriptor<string, unknown>>> = {
|
|
47
|
+
[D in E[number] as D['name']]: D extends EventDescriptor<string, infer A> ? A : never;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export declare interface EventValidation {
|
|
51
|
+
readonly valid: boolean;
|
|
52
|
+
/** `path` → message, empty when valid. */
|
|
53
|
+
readonly errors: Readonly<Record<string, string>>;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** A resolved analytics event: a name + arbitrary payload. */
|
|
57
|
+
export declare type TrackingEvent = {
|
|
58
|
+
readonly event: string;
|
|
59
|
+
} & Record<string, unknown>;
|
|
60
|
+
|
|
61
|
+
/** Where resolved events go — the analytics sink (the client→server transport
|
|
62
|
+
* provides this; tests provide a recorder). */
|
|
63
|
+
export declare type TrackingSink = (event: TrackingEvent) => void;
|
|
64
|
+
|
|
65
|
+
/** Validate a payload against an event descriptor's Schema. Pure. */
|
|
66
|
+
export declare const validateEventPayload: (descriptor: EventDescriptor<string, unknown>, payload: unknown) => EventValidation;
|
|
67
|
+
|
|
68
|
+
export { }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createAnalytics, defineEvent, eventCatalog, validateEventPayload } from "./analyticsCatalog.js";
|
package/dist/apiRuntime.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { SubscriptionCache as e } from "./subscriptionCache.js";
|
|
2
|
+
import { RpcErrorBus as t } from "./rpcErrorBus.js";
|
|
3
|
+
import { recordClientDiagnostic as n } from "./clientDiagnostics.js";
|
|
4
|
+
import { makeClientScheduler as r } from "./clientScheduler.js";
|
|
5
5
|
import { recoveryCoordinatorFor as i } from "./recoveryCoordinator.js";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
6
|
+
import { readRuntimeCapabilities as a } from "./runtimeCapabilities.js";
|
|
7
|
+
import { makeRecoveryRetry as o } from "./recoveryRetry.js";
|
|
8
8
|
import { ConnectionScope as s, combineConnectionScopes as c, registerConnectionScope as l } from "./connectionScope.js";
|
|
9
9
|
import { resolveByTag as u } from "./tagWalk.js";
|
|
10
10
|
import { combineApiRoleClients as d, planApiRoleTransports as f } from "./apiRoleTransports.js";
|
|
@@ -14,19 +14,19 @@ import { RpcClient as S, RpcSerialization as C } from "effect/rpc";
|
|
|
14
14
|
import { compareSurfaces as w, groupShapeDigests as T } from "@voltro/protocol";
|
|
15
15
|
import * as E from "effect/socket/Socket";
|
|
16
16
|
// src/apiRuntime.ts
|
|
17
|
-
var D = async (
|
|
17
|
+
var D = async (e, t, r, i) => {
|
|
18
18
|
if (r !== void 0) try {
|
|
19
19
|
let a = await r({
|
|
20
|
-
apiName:
|
|
20
|
+
apiName: e,
|
|
21
21
|
descriptors: i
|
|
22
22
|
});
|
|
23
|
-
return e
|
|
24
|
-
generation:
|
|
23
|
+
return n(e, "runtime.mirror", {
|
|
24
|
+
generation: t,
|
|
25
25
|
mirrored: a !== void 0
|
|
26
26
|
}), a;
|
|
27
27
|
} catch (r) {
|
|
28
|
-
e
|
|
29
|
-
generation:
|
|
28
|
+
n(e, "runtime.mirror", {
|
|
29
|
+
generation: t,
|
|
30
30
|
mirrored: !1,
|
|
31
31
|
errorName: r instanceof Error ? r.name : typeof r
|
|
32
32
|
});
|
|
@@ -54,91 +54,91 @@ var D = async (t, n, r, i) => {
|
|
|
54
54
|
onDisconnect: m.void
|
|
55
55
|
}
|
|
56
56
|
};
|
|
57
|
-
}, k = 3, A = (
|
|
57
|
+
}, k = 3, A = (e, t, r) => {
|
|
58
58
|
let i;
|
|
59
59
|
try {
|
|
60
|
-
i = w(T(
|
|
60
|
+
i = w(T(t), r);
|
|
61
61
|
} catch {
|
|
62
62
|
return;
|
|
63
63
|
}
|
|
64
64
|
let { differing: a, missingHere: o } = i;
|
|
65
65
|
if (a.length === 0 && o.length === 0) return;
|
|
66
|
-
e
|
|
66
|
+
n(e, "runtime.surface-mismatch", {
|
|
67
67
|
differing: a.length,
|
|
68
68
|
missingHere: o.length,
|
|
69
69
|
first: a[0] ?? o[0] ?? null
|
|
70
70
|
});
|
|
71
71
|
let s = [...a, ...o].slice(0, k), c = a.length + o.length - s.length;
|
|
72
|
-
console.warn(`[voltro] the api client this page loaded does not match what the '${
|
|
72
|
+
console.warn(`[voltro] the api client this page loaded does not match what the '${e}' server binds: ${s.join(", ")}${c > 0 ? ` and ${c} more` : ""}. Responses for those procedures may decode against the wrong schema — a field the server sends and this client does not know is dropped silently. Reload; if it persists, stop the dev server, delete \`.framework/.vite\`, and start it again.`);
|
|
73
73
|
}, j = async (w) => {
|
|
74
74
|
let { name: T, wsUrl: k, group: j, headers: M, webSocketConstructor: N } = w, P = f(j, k, w.roleEndpoints), F = w.generation ?? 0;
|
|
75
|
-
|
|
76
|
-
let I = w.errorBus ?? new
|
|
77
|
-
|
|
78
|
-
L.setMutationReplaySupported(
|
|
79
|
-
mutationReplay:
|
|
80
|
-
discovered:
|
|
75
|
+
n(T, "runtime.build-started", { generation: F });
|
|
76
|
+
let I = w.errorBus ?? new t(), L = w.recovery ?? i(I, T), R = L.subjectSignal;
|
|
77
|
+
a(k, T, fetch, 1500, L.options.capabilitiesUrl).then((e) => {
|
|
78
|
+
L.setMutationReplaySupported(e?.mutationReplay === !0, F), n(T, "runtime.capabilities", {
|
|
79
|
+
mutationReplay: e?.mutationReplay === !0,
|
|
80
|
+
discovered: e !== void 0
|
|
81
81
|
});
|
|
82
|
-
let
|
|
83
|
-
|
|
82
|
+
let t = w.surfaceAudience === "service" ? e?.serviceSurface : e?.surface;
|
|
83
|
+
t !== void 0 && A(T, j, t);
|
|
84
84
|
});
|
|
85
|
-
let z = w.descriptors ?? {}, B = await D(T, F, w.mirror, z), V = new
|
|
85
|
+
let z = w.descriptors ?? {}, B = await D(T, F, w.mirror, z), V = new e({
|
|
86
86
|
errorBus: I,
|
|
87
87
|
apiName: T,
|
|
88
88
|
...B === void 0 ? {} : { mirror: B }
|
|
89
89
|
}), H = P.map(() => new s()), U = c(H), W;
|
|
90
90
|
class G extends p.Service()(`@voltro/client/AppClient/${T}`) {}
|
|
91
|
-
let K = h.succeed(E.WebSocketConstructor, N), q = P.map((e, t) => p.Service(`@voltro/client/Role/${T}/${t}/${e.name}`)), J = P.map((
|
|
92
|
-
let
|
|
93
|
-
|
|
91
|
+
let K = h.succeed(E.WebSocketConstructor, N), q = P.map((e, t) => p.Service(`@voltro/client/Role/${T}/${t}/${e.name}`)), J = P.map((e, t) => {
|
|
92
|
+
let r = o(L.options.retry, (t, r) => {
|
|
93
|
+
n(T, "socket.retry-scheduled", {
|
|
94
94
|
generation: F,
|
|
95
|
-
role:
|
|
96
|
-
attempt:
|
|
95
|
+
role: e.name,
|
|
96
|
+
attempt: t,
|
|
97
97
|
delayMs: r,
|
|
98
98
|
owner: "socket"
|
|
99
99
|
});
|
|
100
|
-
}),
|
|
101
|
-
|
|
102
|
-
let
|
|
103
|
-
|
|
100
|
+
}), i = E.layerWebSocket(e.url).pipe(h.provide(K)), a = O(() => {
|
|
101
|
+
r.reset();
|
|
102
|
+
let t = W === void 0 ? 0 : V.resumeTransportFailures(W, w.roleEndpoints === void 0 ? void 0 : (t) => t !== void 0 && e.tags.has(t));
|
|
103
|
+
n(T, "protocol.ready", {
|
|
104
104
|
generation: F,
|
|
105
|
-
role:
|
|
106
|
-
resumed:
|
|
105
|
+
role: e.name,
|
|
106
|
+
resumed: t
|
|
107
107
|
}), U.scope.getSnapshot() !== void 0 && L.protocolReady();
|
|
108
|
-
}, H[
|
|
109
|
-
return h.effect(q[
|
|
108
|
+
}, H[t]), s = h.effect(E.Socket, m.map(E.Socket, a.wrap)).pipe(h.provide(i)), c = h.effect(S.Protocol, S.makeProtocolSocket({ retryPolicy: r.schedule })).pipe(h.provide(C.layerJson), h.provide(s), h.provide(h.succeed(S.ConnectionHooks, a.hooks)));
|
|
109
|
+
return h.effect(q[t], S.make(e.group)).pipe(h.provide(c));
|
|
110
110
|
}), Y = typeof M == "function" ? await M() : M, X = J.reduce((e, t) => h.merge(e, t), h.empty), Z = h.effect(G, m.map(m.all(q.map((e) => e)), (e) => d(e.map((e, t) => ({
|
|
111
111
|
client: e,
|
|
112
112
|
tags: P[t].tags
|
|
113
|
-
}))))).pipe(h.provide(X)), ee = h.effectDiscard(m.acquireRelease(m.void, () => m.sync(U.close))), te = Y ? h.succeed(S.CurrentHeaders, x.fromInput(Y)) : h.empty, Q =
|
|
113
|
+
}))))).pipe(h.provide(X)), ee = h.effectDiscard(m.acquireRelease(m.void, () => m.sync(U.close))), te = Y ? h.succeed(S.CurrentHeaders, x.fromInput(Y)) : h.empty, Q = r(), $ = g.make(h.mergeAll(Z, te, ee).pipe(h.provideMerge(h.succeed(v.Scheduler, Q))));
|
|
114
114
|
W = $, l(W, U.scope);
|
|
115
115
|
try {
|
|
116
|
-
let
|
|
117
|
-
|
|
116
|
+
let e = await $.runPromise(G);
|
|
117
|
+
n(T, "runtime.resolved", {
|
|
118
118
|
generation: F,
|
|
119
119
|
scheduler: Q.yieldChannel
|
|
120
120
|
});
|
|
121
|
-
let
|
|
121
|
+
let t = (B?.warmTags ?? []).filter((e) => {
|
|
122
122
|
let t = z[e]?.input;
|
|
123
123
|
return t !== void 0 && _.isSuccess(y.decodeUnknownResult(t)({}));
|
|
124
124
|
}).map((e) => [e, {}]);
|
|
125
|
-
for (let [
|
|
126
|
-
let
|
|
127
|
-
V.subscribe([
|
|
125
|
+
for (let [n, r] of [...B?.warm ?? [], ...t]) {
|
|
126
|
+
let t = z[n]?.source;
|
|
127
|
+
V.subscribe([n, r], () => b.suspend(() => u(e, n)(r)), $, () => {}, t === void 0 ? {} : { source: t });
|
|
128
128
|
}
|
|
129
129
|
return {
|
|
130
130
|
runtime: $,
|
|
131
|
-
client:
|
|
131
|
+
client: e,
|
|
132
132
|
cache: V,
|
|
133
133
|
errorBus: I,
|
|
134
134
|
recovery: L,
|
|
135
135
|
subjectSignal: R
|
|
136
136
|
};
|
|
137
|
-
} catch (
|
|
138
|
-
throw
|
|
137
|
+
} catch (e) {
|
|
138
|
+
throw n(T, "runtime.failed", {
|
|
139
139
|
generation: F,
|
|
140
|
-
errorName:
|
|
141
|
-
}), await $.dispose(), U.close(),
|
|
140
|
+
errorName: e instanceof Error ? e.name : typeof e
|
|
141
|
+
}), await $.dispose(), U.close(), e;
|
|
142
142
|
}
|
|
143
143
|
};
|
|
144
144
|
export { j as buildApiRuntime, O as makeProtocolOpenRecovery };
|
package/dist/apiSupervisor.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { RpcErrorBus as e } from "./rpcErrorBus.js";
|
|
2
|
+
import { recordClientDiagnostic as t } from "./clientDiagnostics.js";
|
|
3
|
+
import { RecoveryCoordinator as n } from "./recoveryCoordinator.js";
|
|
4
|
+
import { recoveryRetryDelay as r } from "./recoveryRetry.js";
|
|
5
5
|
// src/apiSupervisor.ts
|
|
6
6
|
var i = (e, t, n) => ({
|
|
7
7
|
resolved: null,
|
|
@@ -26,9 +26,9 @@ var i = (e, t, n) => ({
|
|
|
26
26
|
let c = s.apis, l = s.buildClient, u = s.onChange, d = s.stableWindowMs ?? 5e3, f = s.scheduler?.setTimeout ?? ((e, t) => setTimeout(e, t)), p = s.scheduler?.clearTimeout ?? ((e) => {
|
|
27
27
|
clearTimeout(e);
|
|
28
28
|
}), m = s.scheduler?.queueMicrotask ?? queueMicrotask, h = s.onReconnecting, g = s.wedgeBackstop, _ = /* @__PURE__ */ new Map();
|
|
29
|
-
for (let
|
|
30
|
-
let
|
|
31
|
-
_.set(
|
|
29
|
+
for (let t of c) {
|
|
30
|
+
let r = s.errorBusFor?.(t.name) ?? new e(), a = s.recoveryFor?.(t.name, t.recovery), o = a ?? new n(t.name, t.recovery);
|
|
31
|
+
_.set(t.name, i(r, o, a === void 0));
|
|
32
32
|
}
|
|
33
33
|
let v = !1, y = /* @__PURE__ */ new Set(), b = (e, t) => {
|
|
34
34
|
let n = f(() => {
|
|
@@ -42,25 +42,25 @@ var i = (e, t, n) => ({
|
|
|
42
42
|
u(e, c.every((t) => e.has(t.name)));
|
|
43
43
|
}, S = (e, t) => {
|
|
44
44
|
t.failureCount += 1, !t.reconnectStatusDispose && h && (t.reconnectStatusDispose = h(e.name)), g && t.everOpened && t.failureCount >= g.afterFailures && t.wedgeStop === null && (t.wedgeStop = g.arm(e.name));
|
|
45
|
-
}, C = (
|
|
45
|
+
}, C = (e) => {
|
|
46
46
|
if (v) return;
|
|
47
|
-
let
|
|
48
|
-
if (!
|
|
49
|
-
S(
|
|
50
|
-
let i = s.retryDelayMs?.(
|
|
51
|
-
e
|
|
52
|
-
generation:
|
|
53
|
-
attempt:
|
|
47
|
+
let n = _.get(e.name);
|
|
48
|
+
if (!n) return;
|
|
49
|
+
S(e, n);
|
|
50
|
+
let i = s.retryDelayMs?.(n.failureCount) ?? r(n.recovery.options.retry, n.failureCount);
|
|
51
|
+
t(e.name, "socket.retry-scheduled", {
|
|
52
|
+
generation: n.generation,
|
|
53
|
+
attempt: n.failureCount,
|
|
54
54
|
delayMs: i,
|
|
55
55
|
owner: "runtime-build"
|
|
56
56
|
});
|
|
57
|
-
let a = ++
|
|
57
|
+
let a = ++n.retryToken;
|
|
58
58
|
b(() => {
|
|
59
|
-
v ||
|
|
59
|
+
v || n.retryToken === a && (n.generation += 1, w(e));
|
|
60
60
|
}, i);
|
|
61
|
-
}, w = async (
|
|
61
|
+
}, w = async (e) => {
|
|
62
62
|
if (v) return;
|
|
63
|
-
let n = _.get(
|
|
63
|
+
let n = _.get(e.name);
|
|
64
64
|
if (!n) return;
|
|
65
65
|
let r = n.generation, i = () => {
|
|
66
66
|
if (v || n.generation !== r) return;
|
|
@@ -69,17 +69,17 @@ var i = (e, t, n) => ({
|
|
|
69
69
|
b(() => {
|
|
70
70
|
v || n.failureCount === e && (n.failureCount = 0);
|
|
71
71
|
}, d);
|
|
72
|
-
}, s = (
|
|
73
|
-
v || n.generation !== r || (n.recovery.transportIssue(), S(
|
|
72
|
+
}, s = (t) => {
|
|
73
|
+
v || n.generation !== r || (n.recovery.transportIssue(), S(e, n));
|
|
74
74
|
};
|
|
75
75
|
try {
|
|
76
|
-
let a = await l(
|
|
76
|
+
let a = await l(e, r, i, s, n.errorBus, n.recovery);
|
|
77
77
|
if (v || n.generation !== r) {
|
|
78
78
|
o(a);
|
|
79
79
|
return;
|
|
80
80
|
}
|
|
81
81
|
let c = n.resolved, u = n.subjectMayHaveChanged, d = c && !u ? a.cache.seedStaleFrom(c.cache) : 0;
|
|
82
|
-
n.subjectMayHaveChanged = !1, n.resolved = a, e
|
|
82
|
+
n.subjectMayHaveChanged = !1, n.resolved = a, t(e.name, "runtime.swapped", {
|
|
83
83
|
generation: r,
|
|
84
84
|
replaced: c !== null,
|
|
85
85
|
seeded: d,
|
|
@@ -90,7 +90,7 @@ var i = (e, t, n) => ({
|
|
|
90
90
|
for (let e of f) e.resolve();
|
|
91
91
|
} catch {
|
|
92
92
|
if (v || n.generation !== r) return;
|
|
93
|
-
C(
|
|
93
|
+
C(e);
|
|
94
94
|
}
|
|
95
95
|
}, T = (e) => {
|
|
96
96
|
if (!v) for (let t of c) {
|
|
@@ -117,7 +117,7 @@ var i = (e, t, n) => ({
|
|
|
117
117
|
for (let t of e.swapWaiters) t.resolve();
|
|
118
118
|
e.swapWaiters = [];
|
|
119
119
|
}
|
|
120
|
-
for (let
|
|
120
|
+
for (let e of c) t(e.name, "runtime.disposed");
|
|
121
121
|
_.clear();
|
|
122
122
|
}
|
|
123
123
|
},
|
package/dist/awaitResolvedApi.js
CHANGED
|
@@ -1,22 +1,48 @@
|
|
|
1
1
|
import { isUnresolvedApi as e } from "./frameworkRuntimesContext.js";
|
|
2
|
-
import {
|
|
2
|
+
import { recoveryCoordinatorFor as t } from "./recoveryCoordinator.js";
|
|
3
|
+
import { ConnectionPrerequisiteInvalidated as n } from "./connectionPrerequisite.js";
|
|
3
4
|
// src/awaitResolvedApi.ts
|
|
4
|
-
var
|
|
5
|
+
var r = 15e3, i = (n, r, i, a) => {
|
|
6
|
+
let o = n.recovery ?? t(n.errorBus, r), s = n.subjectSignal ?? o.subjectSignal, c = !e(n);
|
|
7
|
+
return !a || a.apiName !== r || a.rpcTag !== i || a.subject.aborted || a.resolved && (a.recovery !== o || a.subject !== s) ? {
|
|
8
|
+
apiName: r,
|
|
9
|
+
rpcTag: i,
|
|
10
|
+
recovery: o,
|
|
11
|
+
subject: s,
|
|
12
|
+
resolved: c
|
|
13
|
+
} : (!a.resolved && c && (a.recovery = o, a.subject = s, a.resolved = !0), a);
|
|
14
|
+
}, a = (n, r) => {
|
|
15
|
+
if (n.subject.aborted) return !1;
|
|
16
|
+
if (!n.resolved && e(r)) return !0;
|
|
17
|
+
let i = r.recovery ?? t(r.errorBus, n.apiName);
|
|
18
|
+
return i === n.recovery && (r.subjectSignal ?? i.subjectSignal) === n.subject;
|
|
19
|
+
}, o = (e, n) => {
|
|
20
|
+
if (e.resolved) return;
|
|
21
|
+
let r = n.recovery ?? t(n.errorBus, e.apiName);
|
|
22
|
+
e.recovery = r, e.subject = n.subjectSignal ?? r.subjectSignal, e.resolved = !0;
|
|
23
|
+
}, s = async (t, n, i, a) => {
|
|
5
24
|
if (a?.throwIfAborted(), !e(t.current)) return t.current;
|
|
6
|
-
let o = Date.now() +
|
|
25
|
+
let o = Date.now() + r;
|
|
7
26
|
for (; Date.now() < o;) if (await new Promise((e) => setTimeout(e, 16)), a?.throwIfAborted(), !e(t.current)) return t.current;
|
|
8
|
-
throw Error(`Voltro: the api "${
|
|
9
|
-
},
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
if (
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
27
|
+
throw Error(`Voltro: the api "${n}" did not resolve within ${r}ms, so ${i} was never sent. This is not the boot window — that is waited out. Check that "${n}" is a configured api name and that its client could connect.`);
|
|
28
|
+
}, c = async (t, r, i, a) => {
|
|
29
|
+
a?.throwIfAborted();
|
|
30
|
+
let o = e(t.current) ? void 0 : t.current.recovery, c = o?.subjectSignal, l = await s(t, r, i, a), u = l.recovery;
|
|
31
|
+
if (a?.aborted || c?.aborted || o !== void 0 && u !== o) throw new n("inactive");
|
|
32
|
+
if (u === void 0) return l;
|
|
33
|
+
let d = c ?? u.subjectSignal, f = a === void 0 ? void 0 : new AbortController(), p = () => f?.abort();
|
|
34
|
+
f && (d.addEventListener("abort", p, { once: !0 }), a?.addEventListener("abort", p, { once: !0 }), (d.aborted || a?.aborted) && f.abort());
|
|
35
|
+
let m = Date.now();
|
|
36
|
+
try {
|
|
37
|
+
for (;;) {
|
|
38
|
+
let e = await u.waitForProtocolReady(m, f?.signal ?? d);
|
|
39
|
+
if (a?.aborted || d.aborted || u.subjectSignal !== d) throw new n("inactive");
|
|
40
|
+
if (!e) throw new n("timeout");
|
|
41
|
+
if (l = await s(t, r, i, a), a?.aborted || d.aborted || l.recovery !== u) throw new n("inactive");
|
|
42
|
+
if (u.getSnapshot().rawTransport === "connected") return l;
|
|
43
|
+
}
|
|
44
|
+
} finally {
|
|
45
|
+
d.removeEventListener("abort", p), a?.removeEventListener("abort", p);
|
|
20
46
|
}
|
|
21
47
|
};
|
|
22
|
-
export {
|
|
48
|
+
export { r as RESOLVE_TIMEOUT_MS, c as awaitReadyApi, s as awaitResolvedApi, o as bindResolvedRpcInvocationOwner, i as captureRpcInvocationOwner, a as rpcInvocationOwnerCurrent };
|
package/dist/bootstrap.d.ts
CHANGED
|
@@ -520,7 +520,6 @@ declare type RawTransportStatus = 'connected' | 'disconnected';
|
|
|
520
520
|
* retain the complete sequence.
|
|
521
521
|
*/
|
|
522
522
|
declare class RecoveryCoordinator {
|
|
523
|
-
#private;
|
|
524
523
|
constructor(apiName: string, options?: RecoveryOptions, scheduler?: Partial<RecoveryScheduler>);
|
|
525
524
|
get options(): ResolvedRecoveryOptions;
|
|
526
525
|
/** Ends on login/logout, tenant change or API disposal, not ordinary reconnect. */
|
|
@@ -654,7 +653,6 @@ declare interface RpcError {
|
|
|
654
653
|
}
|
|
655
654
|
|
|
656
655
|
declare class RpcErrorBus {
|
|
657
|
-
#private;
|
|
658
656
|
/** Subscribe. Returns an unsubscribe function. */
|
|
659
657
|
on(listener: RpcErrorListener): () => void;
|
|
660
658
|
/** Emit. Pipeline code (useMutation / subscriptionCache) calls this. */
|
|
@@ -753,36 +751,7 @@ declare type StoreStorageArea = 'local' | 'session';
|
|
|
753
751
|
declare type StoreStorageProvider = (area: StoreStorageArea) => StoreStorage | null;
|
|
754
752
|
|
|
755
753
|
declare class SubscriptionCache {
|
|
756
|
-
private readonly entries;
|
|
757
|
-
private readonly entriesByTable;
|
|
758
|
-
private readonly entriesByTag;
|
|
759
|
-
private readonly entriesByMutation;
|
|
760
|
-
private readonly patchMemberships;
|
|
761
|
-
private readonly entryOrder;
|
|
762
|
-
private orderedMemberships;
|
|
763
|
-
private nextEntryOrder;
|
|
764
|
-
/** Standing optimistic intents, by mutation id — see `autoApply`. */
|
|
765
|
-
private readonly intents;
|
|
766
|
-
private readonly tableRows;
|
|
767
|
-
private readonly anyListeners;
|
|
768
|
-
private readonly tableListeners;
|
|
769
|
-
private readonly refreshing;
|
|
770
|
-
/**
|
|
771
|
-
* Same-subject runtime replacement. A mutation may settle against the cache
|
|
772
|
-
* it started on after React has already switched to the replacement cache.
|
|
773
|
-
* Keep this link one-way so staging and settlement follow the visible data
|
|
774
|
-
* without retaining an old cache from the new runtime.
|
|
775
|
-
*/
|
|
776
|
-
private successor;
|
|
777
|
-
private readonly inactiveTtlMs;
|
|
778
|
-
private readonly onChangeHook;
|
|
779
|
-
private readonly errorBus;
|
|
780
|
-
private readonly mirror;
|
|
781
|
-
private readonly mergeCell;
|
|
782
|
-
private readonly apiName;
|
|
783
|
-
private readonly recoveryStuckMs;
|
|
784
754
|
constructor(options?: SubscriptionCacheOptions);
|
|
785
|
-
private diagnose;
|
|
786
755
|
/**
|
|
787
756
|
* Register a subscriber. The cache forks the underlying fiber on the
|
|
788
757
|
* first subscriber and re-uses it for the rest. Returns the snapshot
|
|
@@ -846,31 +815,6 @@ declare class SubscriptionCache {
|
|
|
846
815
|
* resolve briefly exposes a stale base before the server delta lands.
|
|
847
816
|
*/
|
|
848
817
|
confirmByMutation(mutationId: string): void;
|
|
849
|
-
/**
|
|
850
|
-
* The confirmed-patch window expired: a committed write never got its
|
|
851
|
-
* superseding server event. Re-issue the affected subscriptions instead of
|
|
852
|
-
* discarding the write's preview.
|
|
853
|
-
*
|
|
854
|
-
* Three things are load-bearing, and each was a way to reintroduce the bug:
|
|
855
|
-
*
|
|
856
|
-
* - **The patch is KEPT across the resync.** `refreshAll` already
|
|
857
|
-
* establishes that shape ("the new base snapshot will land on top of
|
|
858
|
-
* them"). Clearing it here would be the revert again, wearing a longer
|
|
859
|
-
* word.
|
|
860
|
-
* - **A stub entry — no `fetch`, no `runtime` — is left ALONE.** There is
|
|
861
|
-
* nothing to re-issue, and the only other option is to show a base the
|
|
862
|
-
* client knows is stale. Keeping the patch is the honest state.
|
|
863
|
-
* - **It is LOUD.** The reporter found the jump only by reading minified
|
|
864
|
-
* source, because in the UI it is indistinguishable from "the server did
|
|
865
|
-
* not save it" — and that is the false trail they followed first. This
|
|
866
|
-
* goes to the error bus, so it reaches `voltro logs` rather than only a
|
|
867
|
-
* console nobody has open.
|
|
868
|
-
*
|
|
869
|
-
* No second timer is armed: this runs once per mutation, from the one
|
|
870
|
-
* `confirmByMutation` scheduled it, so a server that never echoes cannot put
|
|
871
|
-
* the client into a resync loop.
|
|
872
|
-
*/
|
|
873
|
-
private resyncUnechoedMutation;
|
|
874
818
|
/**
|
|
875
819
|
* Auto-derive optimistic patches from a mutation's declared target(s).
|
|
876
820
|
* Iterates every cache entry whose `source` table matches a target's
|
|
@@ -894,10 +838,6 @@ declare class SubscriptionCache {
|
|
|
894
838
|
* {@link SubscriptionCache.autoApply}). Carried to a same-subject
|
|
895
839
|
* replacement cache, so a stager can tell "already staged" from "new". */
|
|
896
840
|
hasIntent(mutationId: string): boolean;
|
|
897
|
-
private applyIntent;
|
|
898
|
-
private applyStandingIntents;
|
|
899
|
-
/** Drop a specific patch by id. */
|
|
900
|
-
private revertPatch;
|
|
901
841
|
/**
|
|
902
842
|
* Read the current snapshot for a key WITHOUT subscribing. If the
|
|
903
843
|
* entry doesn't exist, returns the "empty" snapshot (data=undefined,
|
|
@@ -944,40 +884,6 @@ declare class SubscriptionCache {
|
|
|
944
884
|
* patches. Coalesce refreshes until that request answers or fails; never
|
|
945
885
|
* interrupt an initial read merely because another refresh was requested. */
|
|
946
886
|
refresh(key: ReadonlyArray<unknown>): boolean;
|
|
947
|
-
/* Excluded from this release type: resumeTransportFailures */
|
|
948
|
-
/**
|
|
949
|
-
* The stall watchdog for one re-issued entry: `recoveryStuckMs` after the
|
|
950
|
-
* re-issue with neither snapshot nor delta, the entry is reported stuck and
|
|
951
|
-
* its subscribers are notified.
|
|
952
|
-
*
|
|
953
|
-
* That is a finding only if the watchdog itself ran on time. A browser
|
|
954
|
-
* throttles timers in a hidden tab — to a one-second grid, then a one-minute
|
|
955
|
-
* grid — so a timer there fires whenever the tab next wakes, and it used to
|
|
956
|
-
* report the interval it was ARMED with as the interval waited. A delivery
|
|
957
|
-
* queued behind the same throttling then arrived a moment after the warning
|
|
958
|
-
* and the invalidation, under the same attempt: the watchdog had measured
|
|
959
|
-
* its own delay and called it a stall.
|
|
960
|
-
*
|
|
961
|
-
* So the watchdog compares its due time with its fire time. Late beyond the
|
|
962
|
-
* tolerance, or firing in a hidden tab, it does not judge: it records ONE
|
|
963
|
-
* `recovery-timer-late` for the attempt (with how late, and whether hidden)
|
|
964
|
-
* and re-arms. The first on-time fire in a visible tab decides — which gives
|
|
965
|
-
* a delivery `recoveryStuckMs` of unthrottled time once the tab is looked at
|
|
966
|
-
* again, and reports a real stall within that.
|
|
967
|
-
*/
|
|
968
|
-
private armRecoveryWatchdog;
|
|
969
|
-
/**
|
|
970
|
-
* Re-issue ONE entry's subscription: interrupt the fiber, reset the base,
|
|
971
|
-
* re-fork through the saved `fetch`.
|
|
972
|
-
*
|
|
973
|
-
* Extracted so `refreshAll` and the confirmed-patch resync cannot disagree
|
|
974
|
-
* about it — and the thing they must agree on is that **optimistic patches
|
|
975
|
-
* survive**. For a re-auth they belong to in-flight mutations; for the resync
|
|
976
|
-
* they describe a write the server has already committed. Dropping them here
|
|
977
|
-
* would be a revert with a longer name, which is the defect the resync exists
|
|
978
|
-
* to remove.
|
|
979
|
-
*/
|
|
980
|
-
private reissue;
|
|
981
887
|
/**
|
|
982
888
|
* Seed this (fresh) cache with the last-known-good rows held by the cache it
|
|
983
889
|
* REPLACES, so a transport rebuild degrades to STALE DATA rather than to
|
|
@@ -1017,21 +923,6 @@ declare class SubscriptionCache {
|
|
|
1017
923
|
* Returns the number of entries seeded (diagnostics / tests).
|
|
1018
924
|
*/
|
|
1019
925
|
seedStaleFrom(previous: SubscriptionCache): number;
|
|
1020
|
-
private create;
|
|
1021
|
-
private createStub;
|
|
1022
|
-
private freshState;
|
|
1023
|
-
private startFiber;
|
|
1024
|
-
private sourceTables;
|
|
1025
|
-
private addIndex;
|
|
1026
|
-
private removeIndex;
|
|
1027
|
-
private orderedEntries;
|
|
1028
|
-
private indexSource;
|
|
1029
|
-
private appendPatch;
|
|
1030
|
-
private replacePatches;
|
|
1031
|
-
private indexPatches;
|
|
1032
|
-
private registerEntry;
|
|
1033
|
-
private unindexEntry;
|
|
1034
|
-
private invalidate;
|
|
1035
926
|
/**
|
|
1036
927
|
* Every row of `table` this cache holds — the client's local replica of the
|
|
1037
928
|
* table: the union of the rows of every entry sourced on that table ALONE
|
|
@@ -1045,12 +936,6 @@ declare class SubscriptionCache {
|
|
|
1045
936
|
subscribeTable(table: string, listener: () => void): () => void;
|
|
1046
937
|
/** Call `listener` after any entry changed. Returns the unsubscribe. */
|
|
1047
938
|
subscribeAny(listener: () => void): () => void;
|
|
1048
|
-
private getSnapshot;
|
|
1049
|
-
private unsubscribe;
|
|
1050
|
-
/** Start (or restart) the inactive-TTL countdown for `entry`: unless
|
|
1051
|
-
* something subscribes first, interrupt its fiber and drop it. Shared by
|
|
1052
|
-
* the last-subscriber-out path and by `seedStaleFrom`'s unclaimed seeds. */
|
|
1053
|
-
private scheduleEviction;
|
|
1054
939
|
}
|
|
1055
940
|
|
|
1056
941
|
declare interface SubscriptionCacheOptions {
|
package/dist/bootstrap.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
export {
|
|
1
|
+
import { FrameworkRuntimesContext as e } from "./frameworkRuntimesContext.js";
|
|
2
|
+
import { FrameworkRuntimesProvider as t } from "./provider.js";
|
|
3
|
+
import { globalContext as n } from "./globalContext.js";
|
|
4
|
+
import { browserPlatform as r, currentPlatform as i, installPlatform as a, isPlatformInstalled as o, usePlatform as s } from "./platform.js";
|
|
5
|
+
import { applyStoreSeeds as c } from "./store.js";
|
|
6
|
+
import { applyPreloadSeeds as l } from "./preloadSeed.js";
|
|
7
|
+
import { useServerRequest as u } from "./serverRequest.js";
|
|
8
|
+
export { e as FrameworkRuntimesContext, t as FrameworkRuntimesProvider, l as applyPreloadSeeds, c as applyStoreSeeds, r as browserPlatform, i as currentPlatform, n as globalContext, a as installPlatform, o as isPlatformInstalled, s as usePlatform, u as useServerRequest };
|