@voltro/client 0.85.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 (110) hide show
  1. package/CHANGELOG.md +666 -0
  2. package/THIRD-PARTY-NOTICES.md +5 -33
  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.js +5 -2
  22. package/dist/formBinding.js +325 -0
  23. package/dist/formData.js +65 -0
  24. package/dist/formFlashId.js +4 -0
  25. package/dist/frameworkRuntimesContext.js +8 -0
  26. package/dist/globalContext.js +10 -0
  27. package/dist/index.d.ts +53 -7
  28. package/dist/index.js +83 -4121
  29. package/dist/liveRowSort.js +66 -0
  30. package/dist/mutationConnectionSetup.js +16 -0
  31. package/dist/mutationIdentity.js +10 -0
  32. package/dist/mutationSerialExecution.js +53 -0
  33. package/dist/mutationsBus.js +40 -0
  34. package/dist/onlineSource.js +13 -0
  35. package/dist/outbox.js +213 -0
  36. package/dist/outboxHttp.js +104 -0
  37. package/dist/outboxState.js +43 -0
  38. package/dist/permissions.js +20 -0
  39. package/dist/platform.js +121 -0
  40. package/dist/preloadSeed.js +47 -0
  41. package/dist/provider.js +22 -0
  42. package/dist/query.js +12 -2
  43. package/dist/recoveryCoordinator.js +195 -0
  44. package/dist/recoveryRetry.js +24 -0
  45. package/dist/richText.js +176 -0
  46. package/dist/rpcErrorBus.js +39 -0
  47. package/dist/rpcErrorKind.js +13 -0
  48. package/dist/runRpc.js +12 -0
  49. package/dist/runtime.d.ts +32 -1
  50. package/dist/runtime.js +16 -126
  51. package/dist/runtimeCapabilities.js +44 -0
  52. package/dist/runtimeContext.js +49 -0
  53. package/dist/schemaFields.js +219 -0
  54. package/dist/scopeMembership.js +12 -0
  55. package/dist/seedResolvers.js +7 -0
  56. package/dist/sequence.js +65 -0
  57. package/dist/serverRequest.js +24 -0
  58. package/dist/serviceClient.js +128 -0
  59. package/dist/squashRpcCause.js +8 -0
  60. package/dist/stableKey.js +21 -0
  61. package/dist/store.js +288 -0
  62. package/dist/storeStorage.js +28 -0
  63. package/dist/subscriptionCache.js +724 -0
  64. package/dist/tagWalk.js +23 -0
  65. package/dist/traceBus.js +10 -0
  66. package/dist/tracking.js +40 -0
  67. package/dist/uploadProgress.js +21 -0
  68. package/dist/useAction.js +101 -0
  69. package/dist/useAgent.js +53 -0
  70. package/dist/useAgentChat.js +43 -0
  71. package/dist/useAgentStream.js +64 -0
  72. package/dist/useApiOnline.js +14 -0
  73. package/dist/useCapabilityManifest.js +101 -0
  74. package/dist/useConnectionSetup.js +28 -0
  75. package/dist/useConnectionStatus.js +38 -0
  76. package/dist/useConnections.js +107 -0
  77. package/dist/useDataCopilot.js +24 -0
  78. package/dist/useDataTable.js +34 -0
  79. package/dist/useDerived.js +22 -0
  80. package/dist/useEvent.js +88 -0
  81. package/dist/useFormBinding.js +476 -0
  82. package/dist/useLocalQuery.js +59 -0
  83. package/dist/useMutation.js +214 -0
  84. package/dist/useOnRpcError.js +13 -0
  85. package/dist/usePreloadedSubscription.js +18 -0
  86. package/dist/usePreview.js +14 -0
  87. package/dist/useProvenance.js +51 -0
  88. package/dist/useQueryField.js +34 -0
  89. package/dist/useRecord.js +12 -0
  90. package/dist/useRefreshSubscriptions.js +22 -0
  91. package/dist/useResourceCan.js +18 -0
  92. package/dist/useResumableAgentStream.js +75 -0
  93. package/dist/useSequence.js +25 -0
  94. package/dist/useSkeleton.js +13 -0
  95. package/dist/useSubscription.js +89 -0
  96. package/dist/useSubscriptionHealth.js +32 -0
  97. package/dist/useTranscription.js +51 -0
  98. package/dist/useUndo.js +33 -0
  99. package/dist/useUndoLog.js +44 -0
  100. package/dist/useUpload.js +296 -0
  101. package/dist/useWindowedSubscription.js +65 -0
  102. package/dist/useWorkflow.js +284 -0
  103. package/dist/useWorkflowRunState.js +93 -0
  104. package/dist/validation.js +39 -0
  105. package/dist/validationMessages.js +5 -0
  106. package/package.json +7 -2
  107. package/dist/authRefresh-DmfSoCca.js +0 -360
  108. package/dist/formData-BfpBt7BQ.js +0 -769
  109. package/dist/queryOnce-D5Y4V1SB.js +0 -55
  110. package/dist/runRpc-Zfz3w709.js +0 -1172
@@ -1,11 +1,11 @@
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 (11 packages).
8
+ Generated from the resolved runtime dependency closure (10 packages).
9
9
 
10
10
  ---
11
11
 
@@ -177,34 +177,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
177
177
  SOFTWARE.
178
178
  ```
179
179
 
180
- ## layerr@3.0.0
181
-
182
- License: MIT
183
-
184
- ```
185
- MIT License
186
-
187
- Copyright (c) 2020 Perry Mitchell
188
-
189
- Permission is hereby granted, free of charge, to any person obtaining a copy
190
- of this software and associated documentation files (the "Software"), to deal
191
- in the Software without restriction, including without limitation the rights
192
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
193
- copies of the Software, and to permit persons to whom the Software is
194
- furnished to do so, subject to the following conditions:
195
-
196
- The above copyright notice and this permission notice shall be included in all
197
- copies or substantial portions of the Software.
198
-
199
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
200
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
201
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
202
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
203
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
204
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
205
- SOFTWARE.
206
- ```
207
-
208
180
  ## typeid-js@1.2.0
209
181
 
210
182
  License: Apache-2.0
@@ -413,14 +385,14 @@ Apache License
413
385
  limitations under the License.
414
386
  ```
415
387
 
416
- ## ulidx@2.4.1
388
+ ## ulid@3.0.2
417
389
 
418
390
  License: MIT
419
391
 
420
392
  ```
421
- MIT License
393
+ The MIT License (MIT)
422
394
 
423
- Copyright (c) 2021 Perry Mitchell
395
+ Copyright (c) 2017 Alizain Feerasta
424
396
 
425
397
  Permission is hereby granted, free of charge, to any person obtaining a copy
426
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 };