@voltro/client 0.86.0 → 0.88.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 +5484 -0
  2. package/THIRD-PARTY-NOTICES.md +6 -230
  3. package/dist/analyticsCatalog.js +1 -2
  4. package/dist/apiConnectivity.js +1 -2
  5. package/dist/apiRoleTransports.js +47 -0
  6. package/dist/apiRuntime.js +76 -67
  7. package/dist/apiSocketTracker.js +20 -0
  8. package/dist/apiSupervisor.js +17 -7
  9. package/dist/authRefresh.js +1 -2
  10. package/dist/awaitResolvedApi.js +5 -6
  11. package/dist/bootstrap.d.ts +9 -0
  12. package/dist/bootstrap.js +3 -3
  13. package/dist/cellMerger.js +1 -2
  14. package/dist/clientDiagnostics.js +1 -2
  15. package/dist/clientErrorBus.js +1 -2
  16. package/dist/clientScheduler.js +1 -2
  17. package/dist/connectionPrerequisite.js +1 -2
  18. package/dist/connectionScope.js +15 -4
  19. package/dist/connectionSetupController.js +1 -2
  20. package/dist/createHooks.js +1 -2
  21. package/dist/deepLink.js +1 -2
  22. package/dist/filters.js +1 -2
  23. package/dist/form.d.ts +37 -4
  24. package/dist/form.js +4 -2
  25. package/dist/formBinding.js +1 -2
  26. package/dist/formData.js +73 -12
  27. package/dist/formFlashId.js +1 -2
  28. package/dist/formRejection.js +22 -0
  29. package/dist/formSource.js +12 -0
  30. package/dist/frameworkRuntimesContext.js +1 -2
  31. package/dist/globalContext.js +1 -2
  32. package/dist/index.d.ts +99 -20
  33. package/dist/index.js +57 -54
  34. package/dist/liveRowSort.js +1 -2
  35. package/dist/mutationConnectionSetup.js +1 -2
  36. package/dist/mutationIdentity.js +1 -2
  37. package/dist/mutationSerialExecution.js +1 -2
  38. package/dist/mutationsBus.js +1 -2
  39. package/dist/onlineSource.js +1 -2
  40. package/dist/outbox.js +1 -2
  41. package/dist/outboxHttp.js +1 -2
  42. package/dist/outboxState.js +1 -2
  43. package/dist/permissions.js +1 -2
  44. package/dist/platform.js +1 -2
  45. package/dist/preloadSeed.js +1 -2
  46. package/dist/provider.js +1 -2
  47. package/dist/query.js +1 -2
  48. package/dist/recoveryCoordinator.js +1 -2
  49. package/dist/recoveryRetry.js +1 -2
  50. package/dist/richText.js +1 -2
  51. package/dist/rpcErrorBus.js +1 -2
  52. package/dist/rpcErrorKind.js +1 -2
  53. package/dist/runRpc.js +1 -2
  54. package/dist/runtime.d.ts +17 -2
  55. package/dist/runtimeCapabilities.js +1 -2
  56. package/dist/runtimeContext.js +1 -2
  57. package/dist/schemaFields.js +1 -2
  58. package/dist/scopeMembership.js +1 -2
  59. package/dist/seedResolvers.js +1 -2
  60. package/dist/sequence.js +1 -2
  61. package/dist/serverRequest.js +12 -9
  62. package/dist/serviceClient.js +50 -50
  63. package/dist/squashRpcCause.js +1 -2
  64. package/dist/stableKey.js +1 -2
  65. package/dist/store.js +1 -2
  66. package/dist/storeStorage.js +1 -2
  67. package/dist/subscriptionCache.js +5 -6
  68. package/dist/tagWalk.js +1 -2
  69. package/dist/traceBus.js +1 -2
  70. package/dist/tracking.js +1 -2
  71. package/dist/uploadProgress.js +1 -2
  72. package/dist/useAction.js +1 -2
  73. package/dist/useAgent.js +1 -2
  74. package/dist/useAgentChat.js +1 -2
  75. package/dist/useAgentStream.js +1 -2
  76. package/dist/useApiOnline.js +1 -2
  77. package/dist/useCapabilityManifest.js +28 -25
  78. package/dist/useConnectionSetup.js +1 -2
  79. package/dist/useConnectionStatus.js +1 -2
  80. package/dist/useConnections.js +1 -2
  81. package/dist/useDataCopilot.js +1 -2
  82. package/dist/useDataTable.js +1 -2
  83. package/dist/useDerived.js +1 -2
  84. package/dist/useEvent.js +78 -69
  85. package/dist/useFormBinding.js +227 -226
  86. package/dist/useLocalQuery.js +1 -2
  87. package/dist/useMutation.js +1 -2
  88. package/dist/useOnRpcError.js +1 -2
  89. package/dist/usePreloadedSubscription.js +1 -2
  90. package/dist/usePreview.js +1 -2
  91. package/dist/useProvenance.js +1 -2
  92. package/dist/useQueryField.js +1 -2
  93. package/dist/useRecord.js +1 -2
  94. package/dist/useRefreshSubscriptions.js +1 -2
  95. package/dist/useResourceCan.js +1 -2
  96. package/dist/useResumableAgentStream.js +1 -2
  97. package/dist/useRpcCaller.js +16 -0
  98. package/dist/useSequence.js +1 -2
  99. package/dist/useSkeleton.js +1 -2
  100. package/dist/useSubscription.js +56 -48
  101. package/dist/useSubscriptionHealth.js +1 -2
  102. package/dist/useTranscription.js +1 -2
  103. package/dist/useUndo.js +1 -2
  104. package/dist/useUndoLog.js +1 -2
  105. package/dist/useUpload.js +1 -2
  106. package/dist/useWindowedSubscription.js +1 -2
  107. package/dist/useWorkflow.js +1 -2
  108. package/dist/useWorkflowRunState.js +1 -2
  109. package/dist/validation.js +1 -2
  110. package/dist/validationMessages.js +1 -2
  111. package/package.json +4 -4
package/dist/useAction.js CHANGED
@@ -9,7 +9,7 @@ import { freshIdempotencyKey as c, withIdempotencyKey as l } from "./mutationIde
9
9
  import { getMutationNotifier as u } from "./useMutation.js";
10
10
  import { useCallback as d, useMemo as f, useRef as p, useState as m } from "react";
11
11
  import { Effect as h } from "effect";
12
- //#region src/useAction.ts
12
+ // src/useAction.ts
13
13
  var g = (e, t) => {
14
14
  if (t === void 0 || typeof e != "object" || !e) return e;
15
15
  try {
@@ -97,5 +97,4 @@ var g = (e, t) => {
97
97
  O
98
98
  ]);
99
99
  };
100
- //#endregion
101
100
  export { b as useAction };
package/dist/useAgent.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { useAgentStream as e } from "./useAgentStream.js";
2
2
  import { useCallback as t, useEffect as n, useMemo as r, useRef as i, useState as a } from "react";
3
- //#region src/useAgent.ts
3
+ // src/useAgent.ts
4
4
  var o = (o, s) => {
5
5
  let { events: c, status: l, error: u, start: d, cancel: f } = e(o, s), [p, m] = a([]), h = i(null), g = i({
6
6
  events: [],
@@ -49,5 +49,4 @@ var o = (o, s) => {
49
49
  cancel: f
50
50
  };
51
51
  };
52
- //#endregion
53
52
  export { o as useAgent };
@@ -1,7 +1,7 @@
1
1
  import { useSubscription as e } from "./useSubscription.js";
2
2
  import { useAction as t } from "./useAction.js";
3
3
  import { useCallback as n, useMemo as r } from "react";
4
- //#region src/useAgentChat.ts
4
+ // src/useAgentChat.ts
5
5
  var i = (e, t) => e.order - t.order || (e.stepOrder ?? 0) - (t.stepOrder ?? 0), a = (e) => {
6
6
  for (let t = e.length - 1; t >= 0; --t) {
7
7
  let n = e[t];
@@ -39,5 +39,4 @@ var i = (e, t) => e.order - t.order || (e.stepOrder ?? 0) - (t.stepOrder ?? 0),
39
39
  h
40
40
  ]);
41
41
  };
42
- //#endregion
43
42
  export { o as useAgentChat };
@@ -3,7 +3,7 @@ import { useFrameworkApi as t } from "./runtimeContext.js";
3
3
  import { resolveByTag as n } from "./tagWalk.js";
4
4
  import { useCallback as r, useEffect as i, useRef as a, useState as o } from "react";
5
5
  import { Cause as s, Effect as c, Fiber as l, Stream as u } from "effect";
6
- //#region src/useAgentStream.ts
6
+ // src/useAgentStream.ts
7
7
  var d = (d, f) => {
8
8
  let { runtime: p, client: m } = t(d), [h, g] = o([]), [_, v] = o("idle"), [y, b] = o(void 0), x = a(null), S = a(null);
9
9
  i(() => () => {
@@ -60,5 +60,4 @@ var d = (d, f) => {
60
60
  cancel: C
61
61
  };
62
62
  };
63
- //#endregion
64
63
  export { d as useAgentStream };
@@ -1,6 +1,6 @@
1
1
  import { apiConnectivity as e } from "./apiConnectivity.js";
2
2
  import { useCallback as t, useSyncExternalStore as n } from "react";
3
- //#region src/useApiOnline.ts
3
+ // src/useApiOnline.ts
4
4
  var r = () => globalThis.navigator?.onLine !== !1, i = (t) => r() && (e().online(t) ?? !0), a = (t) => {
5
5
  let n = e().subscribe(t);
6
6
  return typeof window > "u" ? n : (window.addEventListener("online", t), window.addEventListener("offline", t), () => {
@@ -10,5 +10,4 @@ var r = () => globalThis.navigator?.onLine !== !1, i = (t) => r() && (e().online
10
10
  let r = t(() => i(e), [e]);
11
11
  return n(a, r, () => !0);
12
12
  };
13
- //#endregion
14
13
  export { i as readApiOnline, a as subscribeApiOnline, o as useApiOnline };
@@ -1,21 +1,21 @@
1
1
  import { useFrameworkApi as e } from "./runtimeContext.js";
2
2
  import { scopeMembership as t } from "./scopeMembership.js";
3
- import { usePermissions as n } from "./permissions.js";
4
- import { useEffect as r, useState as i } from "react";
5
- //#region src/useCapabilityManifest.ts
6
- var a = (e) => `${e.replace(/\/$/, "")}/_voltro/inspect/manifest`, o = (t) => {
7
- let { inspectBaseUrl: n } = e(t), [o, s] = i({
3
+ import { ADMIN_SCOPE as n, usePermissions as r } from "./permissions.js";
4
+ import { useEffect as i, useState as a } from "react";
5
+ // src/useCapabilityManifest.ts
6
+ var o = (e) => `${e.replace(/\/$/, "")}/_voltro/inspect/manifest`, s = (t) => {
7
+ let { inspectBaseUrl: n } = e(t), [r, s] = a({
8
8
  manifest: void 0,
9
9
  loading: !0,
10
10
  error: void 0
11
11
  });
12
- return r(() => {
12
+ return i(() => {
13
13
  let e = !1;
14
14
  return s({
15
15
  manifest: void 0,
16
16
  loading: !0,
17
17
  error: void 0
18
- }), fetch(a(n ?? "")).then(async (e) => {
18
+ }), fetch(o(n ?? "")).then(async (e) => {
19
19
  if (!e.ok) throw Error(`manifest fetch failed: HTTP ${e.status}`);
20
20
  return await e.json();
21
21
  }).then((t) => {
@@ -33,8 +33,8 @@ var a = (e) => `${e.replace(/\/$/, "")}/_voltro/inspect/manifest`, o = (t) => {
33
33
  }), () => {
34
34
  e = !0;
35
35
  };
36
- }, [t, n]), o;
37
- }, s = (e) => {
36
+ }, [t, n]), r;
37
+ }, c = (e) => {
38
38
  if (Object.getPrototypeOf(e) !== Array.prototype || Object.hasOwn(e, Symbol.iterator)) return !1;
39
39
  for (let t = 0; t < e.length; t++) {
40
40
  let n = Object.getOwnPropertyDescriptor(e, String(t));
@@ -54,24 +54,28 @@ var a = (e) => `${e.replace(/\/$/, "")}/_voltro/inspect/manifest`, o = (t) => {
54
54
  }
55
55
  }
56
56
  return !0;
57
- }, c = (e, t, n) => t.scope.length === 0 || (t.mode === "any" ? t.scope.some((t) => n?.has(t) ?? e.includes(t)) : t.scope.every((t) => n?.has(t) ?? e.includes(t))), l = (e, n) => {
57
+ }, l = (e, t, n) => t.scope.length === 0 || (t.mode === "any" ? t.scope.some((t) => n?.has(t) ?? e.includes(t)) : t.scope.every((t) => n?.has(t) ?? e.includes(t))), u = (e, r) => {
58
58
  if (e === void 0) return "unknown";
59
- if (n.includes("admin:full") || e.length === 0) return "allowed";
60
- let r = e.length >= 32 && n.length >= 32 && !Object.hasOwn(n, "includes") && !Object.hasOwn(n, Symbol.iterator) && s(e) ? t(n) : void 0, i = !1;
59
+ let i = r.includes(n);
60
+ if (e.length === 0) return "allowed";
61
+ let a = e.length >= 32 && r.length >= 32 && !Object.hasOwn(r, "includes") && !Object.hasOwn(r, Symbol.iterator) && c(e) ? t(r) : void 0, o = !1;
61
62
  for (let t of e) if (t.kind !== "open") {
62
- if (t.kind === "policy") i = !0;
63
- else if (!c(n, t, r)) {
64
- if (t.resourceScoped) i = !0;
63
+ if (t.kind === "upgraded") o = !0;
64
+ else if (t.kind === "policy") {
65
+ if (i) continue;
66
+ o = !0;
67
+ } else if (!(i || l(r, t, a))) {
68
+ if (t.resourceScoped) o = !0;
65
69
  else return "denied";
66
70
  }
67
71
  }
68
- return i ? "unknown" : "allowed";
69
- }, u = (e) => (e ?? []).flatMap((e) => e.kind === "scope" ? [...e.scope] : []), d = (e) => {
72
+ return o ? "unknown" : "allowed";
73
+ }, d = (e) => (e ?? []).flatMap((e) => e.kind === "scope" ? [...e.scope] : []), f = (e) => {
70
74
  for (let t of e ?? []) if (t.kind === "open") return t.reason;
71
- }, f = (e) => l(e, n().scopes), p = (e) => e === void 0 ? {} : {
75
+ }, p = (e) => u(e, r().scopes), m = (e) => e === void 0 ? {} : {
72
76
  tag: e.tag,
73
77
  ...e.guards === void 0 ? {} : { guards: e.guards }
74
- }, m = (e) => {
78
+ }, h = (e) => {
75
79
  let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
76
80
  for (let r of e.procedures) if (r.kind === "query") {
77
81
  let e = Array.isArray(r.source) ? r.source : [r.source];
@@ -90,12 +94,11 @@ var a = (e) => `${e.replace(/\/$/, "")}/_voltro/inspect/manifest`, o = (t) => {
90
94
  reactive: e.reactive,
91
95
  ...c === void 0 ? {} : { pkColumn: c },
92
96
  editable: (e.editable ?? !0) && c !== void 0,
93
- list: p(r),
94
- create: p(a),
95
- update: p(o),
96
- delete: p(s)
97
+ list: m(r),
98
+ create: m(a),
99
+ update: m(o),
100
+ delete: m(s)
97
101
  };
98
102
  });
99
103
  };
100
- //#endregion
101
- export { l as decideAccess, m as deriveEntityAdmins, a as manifestUrl, d as openAccessReason, u as requiredScopes, f as useAccessDecision, o as useCapabilityManifest };
104
+ export { u as decideAccess, h as deriveEntityAdmins, o as manifestUrl, f as openAccessReason, d as requiredScopes, p as useAccessDecision, s as useCapabilityManifest };
@@ -2,7 +2,7 @@ import { useFrameworkApi as e } from "./runtimeContext.js";
2
2
  import { awaitResolvedApi as t } from "./awaitResolvedApi.js";
3
3
  import { ConnectionSetupController as n } from "./connectionSetupController.js";
4
4
  import { useCallback as r, useEffect as i, useMemo as a, useRef as o, useSyncExternalStore as s } from "react";
5
- //#region src/useConnectionSetup.ts
5
+ // src/useConnectionSetup.ts
6
6
  var c = (c, l) => {
7
7
  let u = e(c), d = o(u);
8
8
  d.current = u;
@@ -24,5 +24,4 @@ var c = (c, l) => {
24
24
  ready: m.status === "ready"
25
25
  };
26
26
  };
27
- //#endregion
28
27
  export { c as useConnectionSetup };
@@ -2,7 +2,7 @@ import { recordClientDiagnostic as e } from "./clientDiagnostics.js";
2
2
  import { INITIAL_RECOVERY_SNAPSHOT as t, recoveryCoordinatorFor as n } from "./recoveryCoordinator.js";
3
3
  import { useFrameworkApi as r } from "./runtimeContext.js";
4
4
  import { useCallback as i, useEffect as a, useSyncExternalStore as o } from "react";
5
- //#region src/useConnectionStatus.ts
5
+ // src/useConnectionStatus.ts
6
6
  var s = () => typeof navigator > "u" || navigator.onLine, c = () => !0, l = (e) => typeof window > "u" ? () => {} : (window.addEventListener("online", e), window.addEventListener("offline", e), () => {
7
7
  window.removeEventListener("online", e), window.removeEventListener("offline", e);
8
8
  }), u = (u) => {
@@ -34,5 +34,4 @@ var s = () => typeof navigator > "u" || navigator.onLine, c = () => !0, l = (e)
34
34
  reportSuccess: h
35
35
  };
36
36
  };
37
- //#endregion
38
37
  export { u as useConnectionStatus };
@@ -2,7 +2,7 @@ import { useSubscription as e } from "./useSubscription.js";
2
2
  import { useMutation as t } from "./useMutation.js";
3
3
  import { useAction as n } from "./useAction.js";
4
4
  import { useCallback as r, useMemo as i } from "react";
5
- //#region src/useConnections.ts
5
+ // src/useConnections.ts
6
6
  var a = "__voltro.connections.list", o = "__voltro.connections.start", s = "__voltro.connections.submitToken", c = "__voltro.connections.disconnect", l = {
7
7
  connectionId: "",
8
8
  kind: "oauth2",
@@ -103,5 +103,4 @@ var a = "__voltro.connections.list", o = "__voltro.connections.start", s = "__vo
103
103
  n.pending
104
104
  ]);
105
105
  };
106
- //#endregion
107
106
  export { a as CONNECTIONS_LIST_TAG, c as CONNECTION_DISCONNECT_TAG, o as CONNECTION_START_TAG, s as CONNECTION_SUBMIT_TOKEN_TAG, p as useConnection, f as useConnections };
@@ -1,6 +1,6 @@
1
1
  import { useAction as e } from "./useAction.js";
2
2
  import { useCallback as t, useMemo as n, useState as r } from "react";
3
- //#region src/useDataCopilot.ts
3
+ // src/useDataCopilot.ts
4
4
  var i = (i, a) => {
5
5
  let o = e(i, a), [s, c] = r(void 0), l = t(async (e) => {
6
6
  let t = await o.run({ question: e });
@@ -20,5 +20,4 @@ var i = (i, a) => {
20
20
  u
21
21
  ]);
22
22
  };
23
- //#endregion
24
23
  export { i as useDataCopilot };
@@ -3,7 +3,7 @@ import { useSubscription as t } from "./useSubscription.js";
3
3
  import { schemaToColumns as n } from "./schemaFields.js";
4
4
  import { createLiveRowSorter as r } from "./liveRowSort.js";
5
5
  import { useCallback as i, useMemo as a, useRef as o, useState as s } from "react";
6
- //#region src/useDataTable.ts
6
+ // src/useDataTable.ts
7
7
  var c = (c, l, u = {}) => {
8
8
  let d = e(c), [f, p] = s(u.pageSize), m = a(() => f === void 0 ? u.input ?? {} : {
9
9
  ...u.input,
@@ -30,5 +30,4 @@ var c = (c, l, u = {}) => {
30
30
  hasMore: f !== void 0 && (h.data?.length ?? 0) >= f
31
31
  };
32
32
  };
33
- //#endregion
34
33
  export { c as useDataTable };
@@ -1,5 +1,5 @@
1
1
  import { useRef as e } from "react";
2
- //#region src/useDerived.ts
2
+ // src/useDerived.ts
3
3
  var t = (e, t) => {
4
4
  if (e === t) return !0;
5
5
  if (e.length !== t.length) return !1;
@@ -18,5 +18,4 @@ var t = (e, t) => {
18
18
  names: s
19
19
  }), i.current.value;
20
20
  };
21
- //#endregion
22
21
  export { t as shallowArrayEqual, n as sourceValues, r as useDerived };
package/dist/useEvent.js CHANGED
@@ -2,87 +2,96 @@ import { recordClientDiagnostic as e } from "./clientDiagnostics.js";
2
2
  import { isUnresolvedApi as t } from "./frameworkRuntimesContext.js";
3
3
  import { useFrameworkApi as n } from "./runtimeContext.js";
4
4
  import { resolveByTag as r } from "./tagWalk.js";
5
- import { useCallback as i, useEffect as a, useRef as o, useState as s } from "react";
6
- import { Effect as c, Fiber as l, Schedule as u, Stream as d } from "effect";
7
- //#region src/useEvent.ts
8
- var f = {
5
+ import { useEffect as i, useLayoutEffect as a, useMemo as o, useRef as s, useState as c } from "react";
6
+ import { Effect as l, Fiber as u, Schedule as d, Stream as f } from "effect";
7
+ // src/useEvent.ts
8
+ var p = {
9
9
  status: "idle",
10
10
  missed: 0,
11
11
  lastMiss: void 0
12
- }, p = class {
12
+ }, m = class {
13
13
  _tag = "EventStreamClosed";
14
14
  };
15
- function m(m, h, g, _ = {}) {
16
- let { skip: v = !1, apiName: y = "app", onMissed: b } = _, x = n(y), { runtime: S, client: C } = x, [w, T] = s(f), E = o(g);
17
- E.current = g;
18
- let D = o(b);
19
- D.current = b;
20
- let O = o(C);
21
- O.current = C;
22
- let k = o(S);
23
- k.current = S;
24
- let A = o(/* @__PURE__ */ new Map()), j = h === null ? null : JSON.stringify(Object.entries(h).sort(([e], [t]) => e < t ? -1 : 1)), M = o(h);
25
- M.current = h;
26
- let N = o(null);
27
- N.current !== j && (N.current = j, A.current = /* @__PURE__ */ new Map());
28
- let P = i((t, n) => {
29
- t <= 0 || (e(y, "event.gap", {
30
- tag: m.name,
31
- missed: t,
32
- reason: n
33
- }), T((e) => ({
34
- ...e,
35
- missed: e.missed + t,
36
- lastMiss: {
15
+ function h(h, g, _, v = {}) {
16
+ let { skip: y = !1, apiName: b = "app", onMissed: x } = v, S = n(b), C = g === null ? null : JSON.stringify(Object.entries(g).sort(([e], [t]) => e < t ? -1 : 1)), w = !y && C !== null && !t(S), T = o(() => ({
17
+ resume: /* @__PURE__ */ new Map(),
18
+ runtime: S.runtime,
19
+ client: S.client,
20
+ subject: S.subjectSignal ?? S.recovery?.subjectSignal,
21
+ key: C === null ? null : Object.fromEntries(JSON.parse(C)),
22
+ tag: h.name,
23
+ apiName: b
24
+ }), [
25
+ S.cache,
26
+ b,
27
+ h.name,
28
+ C,
29
+ w
30
+ ]), E = s(null), [D, O] = c(null);
31
+ return a(() => (E.current = {
32
+ scope: T,
33
+ handler: _,
34
+ onMissed: x
35
+ }, () => {
36
+ E.current = null;
37
+ })), i(() => {
38
+ if (!w || T.subject?.aborted) return;
39
+ let t = !1, n = () => !t && !T.subject?.aborted && E.current?.scope === T, i = (e) => {
40
+ n() && O((t) => ({
41
+ scope: T,
42
+ value: e(t?.scope === T ? t.value : p)
43
+ }));
44
+ }, a = (t, r) => {
45
+ !n() || t <= 0 || (e(T.apiName, "event.gap", {
46
+ tag: T.tag,
47
+ missed: t,
48
+ reason: r
49
+ }), i((e) => ({
50
+ ...e,
51
+ missed: e.missed + t,
52
+ lastMiss: {
53
+ count: t,
54
+ reason: r
55
+ }
56
+ })), E.current?.onMissed?.({
37
57
  count: t,
38
- reason: n
39
- }
40
- })), D.current?.({
41
- count: t,
42
- reason: n
43
- }));
44
- }, [y, m.name]), F = !v && j !== null && !t(x);
45
- return a(() => {
46
- if (!F) {
47
- T(f);
48
- return;
49
- }
50
- T((e) => ({
58
+ reason: r
59
+ }));
60
+ };
61
+ i((e) => ({
51
62
  ...e,
52
63
  status: "connecting"
53
64
  }));
54
- let e = 0, t = c.sync(() => {
55
- let e = [];
56
- for (let [t, n] of A.current) e.push({
57
- origin: t,
58
- n
59
- });
60
- return r(O.current, m.name)({
61
- key: M.current,
65
+ let o = l.suspend(() => {
66
+ if (!n()) return l.interrupt;
67
+ let e = [...T.resume].map(([e, t]) => ({
68
+ origin: e,
69
+ n: t
70
+ })), t = r(T.client, T.tag);
71
+ return l.succeed(t({
72
+ key: T.key,
62
73
  ...e.length > 0 ? { resume: e } : {}
63
- });
64
- }), n = d.unwrap(t).pipe(d.tap(() => c.sync(() => {
65
- e = 0;
66
- })), d.concat(d.fail(new p())), d.retry(u.min([u.exponential("250 millis", 2), u.spaced("30 seconds")]).pipe(u.jittered, u.tap(() => c.sync(() => {
67
- e += 1, T((e) => ({
68
- ...e,
69
- status: "connecting"
70
74
  }));
71
- }))))), i = k.current.runFork(d.runForEach(n, (e) => c.sync(() => {
72
- e._tag === "attached" ? T((e) => ({
75
+ }), s = f.unwrap(o).pipe(f.concat(f.fail(new m())), f.retry(d.min([d.exponential("250 millis", 2), d.spaced("30 seconds")]).pipe(d.jittered, d.tap(() => l.sync(() => i((e) => ({
76
+ ...e,
77
+ status: "connecting"
78
+ }))))))), c = T.runtime.runFork(f.runForEach(s, (e) => l.sync(() => {
79
+ n() && (e._tag === "attached" ? i((e) => ({
73
80
  ...e,
74
81
  status: "live"
75
- })) : e._tag === "gap" ? P(e.missed, e.reason) : (A.current.set(e.origin, Math.max(A.current.get(e.origin) ?? 0, e.n)), E.current(e.payload));
76
- })));
77
- return () => {
78
- k.current.runFork(c.forkDetach(l.interrupt(i)));
82
+ })) : e._tag === "gap" ? a(e.missed, e.reason) : (T.resume.set(e.origin, Math.max(T.resume.get(e.origin) ?? 0, e.n)), E.current?.handler(e.payload)));
83
+ }))), h = () => {
84
+ t || (t = !0, T.resume.clear(), O((e) => e?.scope === T ? {
85
+ scope: T,
86
+ value: p
87
+ } : e), T.runtime.runFork(l.forkDetach(u.interrupt(c))));
88
+ };
89
+ return T.subject?.addEventListener("abort", h, { once: !0 }), T.subject?.aborted && h(), () => {
90
+ T.subject?.removeEventListener("abort", h), h();
79
91
  };
80
- }, [
81
- F,
82
- j,
83
- m.name,
84
- P
85
- ]), F ? w : f;
92
+ }, [w, T]), !w || T.subject?.aborted ? p : D?.scope === T ? D.value : {
93
+ ...p,
94
+ status: "connecting"
95
+ };
86
96
  }
87
- //#endregion
88
- export { m as useEvent };
97
+ export { h as useEvent };