@voltro/client 0.84.0 → 0.86.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.
Files changed (111) hide show
  1. package/CHANGELOG.md +1215 -0
  2. package/THIRD-PARTY-NOTICES.md +5 -89
  3. package/dist/analyticsCatalog.js +47 -0
  4. package/dist/apiConnectivity.js +33 -0
  5. package/dist/apiRuntime.js +135 -0
  6. package/dist/apiSupervisor.js +125 -0
  7. package/dist/authRefresh.js +20 -0
  8. package/dist/awaitResolvedApi.js +23 -0
  9. package/dist/bootstrap.d.ts +1144 -0
  10. package/dist/bootstrap.js +8 -0
  11. package/dist/cellMerger.js +6 -0
  12. package/dist/clientDiagnostics.js +94 -0
  13. package/dist/clientErrorBus.js +16 -0
  14. package/dist/clientScheduler.js +31 -0
  15. package/dist/connectionPrerequisite.js +70 -0
  16. package/dist/connectionScope.js +35 -0
  17. package/dist/connectionSetupController.js +206 -0
  18. package/dist/createHooks.js +15 -0
  19. package/dist/deepLink.js +69 -0
  20. package/dist/filters.js +58 -0
  21. package/dist/form.d.ts +8 -11
  22. package/dist/form.js +5 -2
  23. package/dist/formBinding.js +325 -0
  24. package/dist/formData.js +65 -0
  25. package/dist/formFlashId.js +4 -0
  26. package/dist/frameworkRuntimesContext.js +8 -0
  27. package/dist/globalContext.js +10 -0
  28. package/dist/index.d.ts +285 -279
  29. package/dist/index.js +83 -3686
  30. package/dist/liveRowSort.js +66 -0
  31. package/dist/mutationConnectionSetup.js +16 -0
  32. package/dist/mutationIdentity.js +10 -0
  33. package/dist/mutationSerialExecution.js +53 -0
  34. package/dist/mutationsBus.js +40 -0
  35. package/dist/onlineSource.js +13 -0
  36. package/dist/outbox.js +213 -0
  37. package/dist/outboxHttp.js +104 -0
  38. package/dist/outboxState.js +43 -0
  39. package/dist/permissions.js +20 -0
  40. package/dist/platform.js +121 -0
  41. package/dist/preloadSeed.js +47 -0
  42. package/dist/provider.js +22 -0
  43. package/dist/query.js +12 -2
  44. package/dist/recoveryCoordinator.js +195 -0
  45. package/dist/recoveryRetry.js +24 -0
  46. package/dist/richText.js +176 -0
  47. package/dist/rpcErrorBus.js +39 -0
  48. package/dist/rpcErrorKind.js +13 -0
  49. package/dist/runRpc.js +12 -0
  50. package/dist/runtime.d.ts +79 -15
  51. package/dist/runtime.js +16 -129
  52. package/dist/runtimeCapabilities.js +44 -0
  53. package/dist/runtimeContext.js +49 -0
  54. package/dist/schemaFields.js +219 -0
  55. package/dist/scopeMembership.js +12 -0
  56. package/dist/seedResolvers.js +7 -0
  57. package/dist/sequence.js +65 -0
  58. package/dist/serverRequest.js +24 -0
  59. package/dist/serviceClient.js +128 -0
  60. package/dist/squashRpcCause.js +8 -0
  61. package/dist/stableKey.js +21 -0
  62. package/dist/store.js +288 -0
  63. package/dist/storeStorage.js +28 -0
  64. package/dist/subscriptionCache.js +724 -0
  65. package/dist/tagWalk.js +23 -0
  66. package/dist/traceBus.js +10 -0
  67. package/dist/tracking.js +40 -0
  68. package/dist/uploadProgress.js +21 -0
  69. package/dist/useAction.js +101 -0
  70. package/dist/useAgent.js +53 -0
  71. package/dist/useAgentChat.js +43 -0
  72. package/dist/useAgentStream.js +64 -0
  73. package/dist/useApiOnline.js +14 -0
  74. package/dist/useCapabilityManifest.js +101 -0
  75. package/dist/useConnectionSetup.js +28 -0
  76. package/dist/useConnectionStatus.js +38 -0
  77. package/dist/useConnections.js +107 -0
  78. package/dist/useDataCopilot.js +24 -0
  79. package/dist/useDataTable.js +34 -0
  80. package/dist/useDerived.js +22 -0
  81. package/dist/useEvent.js +88 -0
  82. package/dist/useFormBinding.js +476 -0
  83. package/dist/useLocalQuery.js +59 -0
  84. package/dist/useMutation.js +214 -0
  85. package/dist/useOnRpcError.js +13 -0
  86. package/dist/usePreloadedSubscription.js +18 -0
  87. package/dist/usePreview.js +14 -0
  88. package/dist/useProvenance.js +51 -0
  89. package/dist/useQueryField.js +34 -0
  90. package/dist/useRecord.js +12 -0
  91. package/dist/useRefreshSubscriptions.js +22 -0
  92. package/dist/useResourceCan.js +18 -0
  93. package/dist/useResumableAgentStream.js +75 -0
  94. package/dist/useSequence.js +25 -0
  95. package/dist/useSkeleton.js +13 -0
  96. package/dist/useSubscription.js +89 -0
  97. package/dist/useSubscriptionHealth.js +32 -0
  98. package/dist/useTranscription.js +51 -0
  99. package/dist/useUndo.js +33 -0
  100. package/dist/useUndoLog.js +44 -0
  101. package/dist/useUpload.js +296 -0
  102. package/dist/useWindowedSubscription.js +65 -0
  103. package/dist/useWorkflow.js +284 -0
  104. package/dist/useWorkflowRunState.js +93 -0
  105. package/dist/validation.js +39 -0
  106. package/dist/validationMessages.js +5 -0
  107. package/package.json +8 -5
  108. package/dist/authRefresh-C4Ow8HH7.js +0 -346
  109. package/dist/formData-dGz5aoUR.js +0 -649
  110. package/dist/queryOnce-CvdopzOj.js +0 -55
  111. package/dist/runRpc-DvHpFZAZ.js +0 -1034
@@ -1,70 +1,14 @@
1
1
  # Third-Party Notices — @voltro/client
2
2
 
3
- This package depends on the open-source software listed below. Each is the
3
+ This package uses the open-source software listed below. Each is the
4
4
  property of its respective copyright holders and is used under the terms of
5
5
  its license. This file is provided for attribution; it grants no rights in
6
6
  @voltro/client itself, which is proprietary (see LICENSE).
7
7
 
8
- Generated from the resolved runtime dependency closure (13 packages).
8
+ Generated from the resolved runtime dependency closure (10 packages).
9
9
 
10
10
  ---
11
11
 
12
- ## @effect/experimental@0.61.1
13
-
14
- License: MIT
15
-
16
- ```
17
- MIT License
18
-
19
- Copyright (c) 2023-present The Contributors
20
-
21
- Permission is hereby granted, free of charge, to any person obtaining a copy
22
- of this software and associated documentation files (the "Software"), to deal
23
- in the Software without restriction, including without limitation the rights
24
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
25
- copies of the Software, and to permit persons to whom the Software is
26
- furnished to do so, subject to the following conditions:
27
-
28
- The above copyright notice and this permission notice shall be included in all
29
- copies or substantial portions of the Software.
30
-
31
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
32
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
33
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
34
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
35
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
36
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
37
- SOFTWARE.
38
- ```
39
-
40
- ## @effect/sql@0.52.1
41
-
42
- License: MIT
43
-
44
- ```
45
- MIT License
46
-
47
- Copyright (c) 2023-present The Contributors
48
-
49
- Permission is hereby granted, free of charge, to any person obtaining a copy
50
- of this software and associated documentation files (the "Software"), to deal
51
- in the Software without restriction, including without limitation the rights
52
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
53
- copies of the Software, and to permit persons to whom the Software is
54
- furnished to do so, subject to the following conditions:
55
-
56
- The above copyright notice and this permission notice shall be included in all
57
- copies or substantial portions of the Software.
58
-
59
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
60
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
61
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
62
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
63
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
64
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
65
- SOFTWARE.
66
- ```
67
-
68
12
  ## @tanstack/devtools-event-client@0.4.4
69
13
 
70
14
  License: MIT
@@ -233,34 +177,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
233
177
  SOFTWARE.
234
178
  ```
235
179
 
236
- ## layerr@3.0.0
237
-
238
- License: MIT
239
-
240
- ```
241
- MIT License
242
-
243
- Copyright (c) 2020 Perry Mitchell
244
-
245
- Permission is hereby granted, free of charge, to any person obtaining a copy
246
- of this software and associated documentation files (the "Software"), to deal
247
- in the Software without restriction, including without limitation the rights
248
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
249
- copies of the Software, and to permit persons to whom the Software is
250
- furnished to do so, subject to the following conditions:
251
-
252
- The above copyright notice and this permission notice shall be included in all
253
- copies or substantial portions of the Software.
254
-
255
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
256
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
257
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
258
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
259
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
260
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
261
- SOFTWARE.
262
- ```
263
-
264
180
  ## typeid-js@1.2.0
265
181
 
266
182
  License: Apache-2.0
@@ -469,14 +385,14 @@ Apache License
469
385
  limitations under the License.
470
386
  ```
471
387
 
472
- ## ulidx@2.4.1
388
+ ## ulid@3.0.2
473
389
 
474
390
  License: MIT
475
391
 
476
392
  ```
477
- MIT License
393
+ The MIT License (MIT)
478
394
 
479
- Copyright (c) 2021 Perry Mitchell
395
+ Copyright (c) 2017 Alizain Feerasta
480
396
 
481
397
  Permission is hereby granted, free of charge, to any person obtaining a copy
482
398
  of this software and associated documentation files (the "Software"), to deal
@@ -0,0 +1,47 @@
1
+ import { Schema as e, SchemaIssue as t } from "effect";
2
+ //#region src/analyticsCatalog.ts
3
+ var n = (e, t) => ({
4
+ name: e,
5
+ payload: t
6
+ }), r = (n, r) => {
7
+ let i = e.decodeUnknownResult(n.payload, { errors: "all" })(r);
8
+ if (i._tag === "Success") return {
9
+ valid: !0,
10
+ errors: {}
11
+ };
12
+ let a = {};
13
+ for (let e of t.makeFormatterStandardSchemaV1()(i.failure.issue).issues) a[(e.path ?? []).join(".") || "(root)"] = e.message;
14
+ return {
15
+ valid: !1,
16
+ errors: a
17
+ };
18
+ }, i = (e) => {
19
+ let t = new Map(e.map((e) => [e.name, e]));
20
+ return {
21
+ names: [...t.keys()].sort(),
22
+ get: (e) => t.get(e),
23
+ events: e
24
+ };
25
+ }, a = (e, t) => {
26
+ let n = i(e);
27
+ return {
28
+ track: (e, i) => {
29
+ let a = n.get(e);
30
+ if (a === void 0) process.env.NODE_ENV !== "production" && console.error(`[@voltro/client] analytics.track: unknown event '${e}' (not in the catalog)`);
31
+ else {
32
+ if (process.env.NODE_ENV !== "production") {
33
+ let t = r(a, i);
34
+ t.valid || console.error(`[@voltro/client] analytics.track('${e}'): payload failed its schema`, t.errors);
35
+ }
36
+ t({
37
+ event: e,
38
+ ...i
39
+ });
40
+ }
41
+ },
42
+ names: n.names,
43
+ catalog: n
44
+ };
45
+ };
46
+ //#endregion
47
+ export { a as createAnalytics, n as defineEvent, i as eventCatalog, r as validateEventPayload };
@@ -0,0 +1,33 @@
1
+ //#region src/apiConnectivity.ts
2
+ var e = Symbol.for("voltro.client.connectivity"), t = () => {
3
+ let e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Set(), n = () => {
4
+ for (let e of t) try {
5
+ e();
6
+ } catch {}
7
+ };
8
+ return {
9
+ online: (t) => {
10
+ let n = [];
11
+ if (t === void 0) for (let t of e.values()) for (let e of t) n.push(e);
12
+ else for (let r of e.get(t) ?? []) n.push(r);
13
+ if (n.length !== 0) return n.some((e) => e.connected());
14
+ },
15
+ subscribe: (e) => (t.add(e), () => {
16
+ t.delete(e);
17
+ }),
18
+ register: (t, r) => {
19
+ let i = e.get(t) ?? /* @__PURE__ */ new Set();
20
+ return i.add(r), e.set(t, i), n(), () => {
21
+ i.delete(r), i.size === 0 && e.delete(t), n();
22
+ };
23
+ },
24
+ notify: n
25
+ };
26
+ }, n = () => {
27
+ let n = globalThis;
28
+ return n[e] ??= t();
29
+ }, r = (e, t) => n().register(e, { connected: t }), i = () => {
30
+ n().notify();
31
+ }, a = () => n();
32
+ //#endregion
33
+ export { a as apiConnectivity, i as notifyApiTransportChanged, r as registerApiTransport };
@@ -0,0 +1,135 @@
1
+ import { recordClientDiagnostic as e } from "./clientDiagnostics.js";
2
+ import { SubscriptionCache as t } from "./subscriptionCache.js";
3
+ import { RpcErrorBus as n } from "./rpcErrorBus.js";
4
+ import { makeRecoveryRetry as r } from "./recoveryRetry.js";
5
+ import { recoveryCoordinatorFor as i } from "./recoveryCoordinator.js";
6
+ import { makeClientScheduler as a } from "./clientScheduler.js";
7
+ import { readRuntimeCapabilities as o } from "./runtimeCapabilities.js";
8
+ import { ConnectionScope as s, registerConnectionScope as c } from "./connectionScope.js";
9
+ import { resolveByTag as l } from "./tagWalk.js";
10
+ import { Context as u, Effect as d, Layer as f, ManagedRuntime as p, Result as m, Scheduler as h, Schema as g, Stream as _ } from "effect";
11
+ import * as v from "effect/http/Headers";
12
+ import { RpcClient as y, RpcSerialization as b } from "effect/rpc";
13
+ import { compareSurfaces as x, groupShapeDigests as S } from "@voltro/protocol";
14
+ import * as C from "effect/socket/Socket";
15
+ //#region src/apiRuntime.ts
16
+ var w = async (t, n, r, i) => {
17
+ if (r !== void 0) try {
18
+ let a = await r({
19
+ apiName: t,
20
+ descriptors: i
21
+ });
22
+ return e(t, "runtime.mirror", {
23
+ generation: n,
24
+ mirrored: a !== void 0
25
+ }), a;
26
+ } catch (r) {
27
+ e(t, "runtime.mirror", {
28
+ generation: n,
29
+ mirrored: !1,
30
+ errorName: r instanceof Error ? r.name : typeof r
31
+ });
32
+ return;
33
+ }
34
+ }, T = (e, t = new s()) => {
35
+ let n;
36
+ return {
37
+ wrap: (e) => C.Socket.of({
38
+ ...e,
39
+ reader: d.gen(function* () {
40
+ let r = t.begin();
41
+ yield* d.addFinalizer(() => d.sync(() => {
42
+ n === r && (n = void 0), r.close();
43
+ }));
44
+ let i = yield* e.reader;
45
+ return n = r, i;
46
+ })
47
+ }),
48
+ hooks: {
49
+ onConnect: d.sync(() => {
50
+ let t = n;
51
+ n = void 0, t?.open() !== void 0 && e();
52
+ }),
53
+ onDisconnect: d.void
54
+ }
55
+ };
56
+ }, E = 3, D = (t, n, r) => {
57
+ let i;
58
+ try {
59
+ i = x(S(n), r);
60
+ } catch {
61
+ return;
62
+ }
63
+ let { differing: a, missingHere: o } = i;
64
+ if (a.length === 0 && o.length === 0) return;
65
+ e(t, "runtime.surface-mismatch", {
66
+ differing: a.length,
67
+ missingHere: o.length,
68
+ first: a[0] ?? o[0] ?? null
69
+ });
70
+ let s = [...a, ...o].slice(0, E), c = a.length + o.length - s.length;
71
+ console.warn(`[voltro] the api client this page loaded does not match what the '${t}' 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.`);
72
+ }, O = async (x) => {
73
+ let { name: S, wsUrl: E, group: O, headers: k, webSocketConstructor: A } = x, j = x.generation ?? 0;
74
+ e(S, "runtime.build-started", { generation: j });
75
+ let M = x.errorBus ?? new n(), N = x.recovery ?? i(M, S), P = r(N.options.retry, (t, n) => {
76
+ e(S, "socket.retry-scheduled", {
77
+ generation: j,
78
+ attempt: t,
79
+ delayMs: n,
80
+ owner: "socket"
81
+ });
82
+ });
83
+ o(E, S, fetch, 1500, N.options.capabilitiesUrl).then((t) => {
84
+ N.setMutationReplaySupported(t?.mutationReplay === !0, j), e(S, "runtime.capabilities", {
85
+ mutationReplay: t?.mutationReplay === !0,
86
+ discovered: t !== void 0
87
+ });
88
+ let n = x.surfaceAudience === "service" ? t?.serviceSurface : t?.surface;
89
+ n !== void 0 && D(S, O, n);
90
+ });
91
+ let F = x.descriptors ?? {}, I = await w(S, j, x.mirror, F), L = new t({
92
+ errorBus: M,
93
+ apiName: S,
94
+ ...I === void 0 ? {} : { mirror: I }
95
+ }), R = new s(), z;
96
+ class B extends u.Service()(`@voltro/client/AppClient/${S}`) {}
97
+ let V = f.succeed(C.WebSocketConstructor, A), H = C.layerWebSocket(E).pipe(f.provide(V)), U = T(() => {
98
+ P.reset();
99
+ let t = 0;
100
+ z !== void 0 && (t = L.resumeTransportFailures(z)), e(S, "protocol.ready", {
101
+ generation: j,
102
+ resumed: t
103
+ }), N.protocolReady();
104
+ }, R), W = f.effect(C.Socket, d.map(C.Socket, U.wrap)).pipe(f.provide(H)), G = f.effect(y.Protocol, y.makeProtocolSocket({ retryPolicy: P.schedule })).pipe(f.provide(b.layerJson), f.provide(W), f.provide(f.succeed(y.ConnectionHooks, U.hooks))), K = typeof k == "function" ? await k() : k, q = f.effect(B, y.make(O)).pipe(f.provide(G)), J = K ? f.succeed(y.CurrentHeaders, v.fromInput(K)) : f.empty, Y = a(), X = p.make(f.merge(q, J).pipe(f.provideMerge(f.succeed(h.Scheduler, Y))));
105
+ z = X, c(z, R);
106
+ try {
107
+ let t = await X.runPromise(B);
108
+ e(S, "runtime.resolved", {
109
+ generation: j,
110
+ scheduler: Y.yieldChannel
111
+ });
112
+ let n = (I?.warmTags ?? []).filter((e) => {
113
+ let t = F[e]?.input;
114
+ return t !== void 0 && m.isSuccess(g.decodeUnknownResult(t)({}));
115
+ }).map((e) => [e, {}]);
116
+ for (let [e, r] of [...I?.warm ?? [], ...n]) {
117
+ let n = F[e]?.source;
118
+ L.subscribe([e, r], () => _.suspend(() => l(t, e)(r)), X, () => {}, n === void 0 ? {} : { source: n });
119
+ }
120
+ return {
121
+ runtime: X,
122
+ client: t,
123
+ cache: L,
124
+ errorBus: M,
125
+ recovery: N
126
+ };
127
+ } catch (t) {
128
+ throw e(S, "runtime.failed", {
129
+ generation: j,
130
+ errorName: t instanceof Error ? t.name : typeof t
131
+ }), X.dispose(), t;
132
+ }
133
+ };
134
+ //#endregion
135
+ export { O as buildApiRuntime, T as makeProtocolOpenRecovery };
@@ -0,0 +1,125 @@
1
+ import { recordClientDiagnostic as e } from "./clientDiagnostics.js";
2
+ import { RpcErrorBus as t } from "./rpcErrorBus.js";
3
+ import { recoveryRetryDelay as n } from "./recoveryRetry.js";
4
+ import { RecoveryCoordinator as r } from "./recoveryCoordinator.js";
5
+ //#region src/apiSupervisor.ts
6
+ var i = (e, t, n) => ({
7
+ resolved: null,
8
+ retryToken: 0,
9
+ failureCount: 0,
10
+ generation: 0,
11
+ reconnectStatusDispose: null,
12
+ everOpened: !1,
13
+ wedgeStop: null,
14
+ subjectMayHaveChanged: !1,
15
+ errorBus: e,
16
+ recovery: t,
17
+ stopRecoveryError: e.on((e) => t.observeError(e)),
18
+ stopRecoverySuccess: e.onSuccess((e) => t.observeSuccess(e)),
19
+ ownsRecovery: n
20
+ }), a = (e) => {
21
+ e.wedgeStop !== null && (e.wedgeStop(), e.wedgeStop = null);
22
+ }, o = (e) => {
23
+ e.cache.destroy(e.runtime), e.runtime.dispose();
24
+ }, s = (s) => {
25
+ 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) => {
26
+ clearTimeout(e);
27
+ }), m = s.scheduler?.queueMicrotask ?? queueMicrotask, h = s.onReconnecting, g = s.wedgeBackstop, _ = /* @__PURE__ */ new Map();
28
+ for (let e of c) {
29
+ let n = s.errorBusFor?.(e.name) ?? new t(), a = s.recoveryFor?.(e.name, e.recovery), o = a ?? new r(e.name, e.recovery);
30
+ _.set(e.name, i(n, o, a === void 0));
31
+ }
32
+ let v = !1, y = /* @__PURE__ */ new Set(), b = (e, t) => {
33
+ let n = f(() => {
34
+ y.delete(n), e();
35
+ }, t);
36
+ return y.add(n), n;
37
+ }, x = () => {
38
+ if (v) return;
39
+ let e = /* @__PURE__ */ new Map();
40
+ for (let [t, n] of _) n.resolved && e.set(t, n.resolved);
41
+ u(e, c.every((t) => e.has(t.name)));
42
+ }, S = (e, t) => {
43
+ 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));
44
+ }, C = (t) => {
45
+ if (v) return;
46
+ let r = _.get(t.name);
47
+ if (!r) return;
48
+ S(t, r);
49
+ let i = s.retryDelayMs?.(r.failureCount) ?? n(r.recovery.options.retry, r.failureCount);
50
+ e(t.name, "socket.retry-scheduled", {
51
+ generation: r.generation,
52
+ attempt: r.failureCount,
53
+ delayMs: i,
54
+ owner: "runtime-build"
55
+ });
56
+ let a = ++r.retryToken;
57
+ b(() => {
58
+ v || r.retryToken === a && (r.generation += 1, w(t));
59
+ }, i);
60
+ }, w = async (t) => {
61
+ if (v) return;
62
+ let n = _.get(t.name);
63
+ if (!n) return;
64
+ let r = n.generation, i = () => {
65
+ if (v || n.generation !== r) return;
66
+ n.everOpened = !0, a(n), n.reconnectStatusDispose &&= (n.reconnectStatusDispose(), null), n.retryToken++;
67
+ let e = n.failureCount;
68
+ b(() => {
69
+ v || n.failureCount === e && (n.failureCount = 0);
70
+ }, d);
71
+ }, s = (e) => {
72
+ v || n.generation !== r || (n.recovery.transportIssue(), S(t, n));
73
+ };
74
+ try {
75
+ let a = await l(t, r, i, s, n.errorBus, n.recovery);
76
+ if (v || n.generation !== r) {
77
+ o(a);
78
+ return;
79
+ }
80
+ let c = n.resolved, u = n.subjectMayHaveChanged, d = c && !u ? a.cache.seedStaleFrom(c.cache) : 0;
81
+ n.subjectMayHaveChanged = !1, n.resolved = a, e(t.name, "runtime.swapped", {
82
+ generation: r,
83
+ replaced: c !== null,
84
+ seeded: d,
85
+ subjectMayHaveChanged: u
86
+ }), x(), c && o(c);
87
+ } catch {
88
+ if (v || n.generation !== r) return;
89
+ C(t);
90
+ }
91
+ }, T = (e) => {
92
+ if (!v) for (let t of c) {
93
+ let n = _.get(t.name);
94
+ n && (e && (n.subjectMayHaveChanged = !0), n.retryToken += 1, n.generation += 1, e && n.recovery.resetForSubjectChange(n.generation), n.failureCount = 0, a(n), w(t));
95
+ }
96
+ };
97
+ return c.length === 0 ? (u(/* @__PURE__ */ new Map(), !0), {
98
+ dispose: () => {
99
+ v = !0;
100
+ },
101
+ reconnect: () => {},
102
+ refreshAuth: () => {}
103
+ }) : (m(() => {
104
+ if (!v) for (let e of c) w(e);
105
+ }), {
106
+ dispose: () => {
107
+ if (!v) {
108
+ v = !0;
109
+ for (let e of y) p(e);
110
+ y.clear();
111
+ for (let [, e] of _) e.resolved && o(e.resolved), e.reconnectStatusDispose && e.reconnectStatusDispose(), a(e), e.stopRecoveryError(), e.stopRecoverySuccess(), e.ownsRecovery && e.recovery.dispose();
112
+ for (let t of c) e(t.name, "runtime.disposed");
113
+ _.clear();
114
+ }
115
+ },
116
+ reconnect: () => {
117
+ T(!0);
118
+ },
119
+ refreshAuth: () => {
120
+ T(!1);
121
+ }
122
+ });
123
+ };
124
+ //#endregion
125
+ export { s as startApiSupervisor };
@@ -0,0 +1,20 @@
1
+ //#region src/authRefresh.ts
2
+ var e = (e) => e?._tag === "Unauthenticated", t = (t, n, r = {}) => {
3
+ let i = r.cooldownMs ?? 15e3, a = r.maxConsecutive ?? 3, o = r.now ?? (() => Date.now()), s = -Infinity, c = 0, l = t.on((t) => {
4
+ if (!e(t.error) || c >= a) return;
5
+ let r = o();
6
+ r - s < i || (s = r, c += 1, n());
7
+ }), u = t.onSuccess(() => {
8
+ c = 0;
9
+ });
10
+ return {
11
+ dispose: () => {
12
+ l(), u();
13
+ },
14
+ noteSuccess: () => {
15
+ c = 0;
16
+ }
17
+ };
18
+ };
19
+ //#endregion
20
+ export { e as isUnauthenticated, t as wireAuthRefresh };
@@ -0,0 +1,23 @@
1
+ import { isUnresolvedApi as e } from "./frameworkRuntimesContext.js";
2
+ import { ConnectionPrerequisiteInvalidated as t } from "./connectionPrerequisite.js";
3
+ //#region src/awaitResolvedApi.ts
4
+ var n = 15e3, r = async (t, r, i) => {
5
+ if (!e(t.current)) return t.current;
6
+ let a = Date.now() + n;
7
+ for (; Date.now() < a;) if (await new Promise((e) => setTimeout(e, 16)), !e(t.current)) return t.current;
8
+ throw Error(`Voltro: the api "${r}" did not resolve within ${n}ms, so ${i} was never sent. This is not the boot window — that is waited out. Check that "${r}" is a configured api name and that its client could connect.`);
9
+ }, i = async (n, i, a) => {
10
+ let o = e(n.current) ? void 0 : n.current.recovery, s = o?.subjectSignal, c = await r(n, i, a), l = c.recovery;
11
+ if (s?.aborted || o !== void 0 && l !== o) throw new t("inactive");
12
+ if (l === void 0) return c;
13
+ let u = s ?? l.subjectSignal, d = Date.now();
14
+ for (;;) {
15
+ let e = await l.waitForProtocolReady(d, u);
16
+ if (u.aborted || l.subjectSignal !== u) throw new t("inactive");
17
+ if (!e) throw new t("timeout");
18
+ if (c = await r(n, i, a), u.aborted || c.recovery !== l) throw new t("inactive");
19
+ if (l.getSnapshot().rawTransport === "connected") return c;
20
+ }
21
+ };
22
+ //#endregion
23
+ export { n as RESOLVE_TIMEOUT_MS, i as awaitReadyApi, r as awaitResolvedApi };