@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.
Files changed (53) hide show
  1. package/CHANGELOG.md +1943 -0
  2. package/README.md +22 -0
  3. package/THIRD-PARTY-NOTICES.md +1 -1
  4. package/dist/analytics.d.ts +68 -0
  5. package/dist/analytics.js +1 -0
  6. package/dist/apiRuntime.js +50 -50
  7. package/dist/apiSupervisor.js +25 -25
  8. package/dist/awaitResolvedApi.js +42 -16
  9. package/dist/bootstrap.d.ts +0 -115
  10. package/dist/bootstrap.js +8 -8
  11. package/dist/connectionPrerequisite.js +18 -18
  12. package/dist/connectionSetupController.js +123 -91
  13. package/dist/createHooks.js +11 -11
  14. package/dist/form.js +7 -7
  15. package/dist/index.d.ts +148 -162
  16. package/dist/index.js +88 -86
  17. package/dist/invocationWait.js +14 -0
  18. package/dist/mutationsBus.js +92 -35
  19. package/dist/outbox.js +137 -108
  20. package/dist/outboxState.js +7 -0
  21. package/dist/platform.js +10 -10
  22. package/dist/query.js +3 -10
  23. package/dist/rpcCallOnce.js +30 -0
  24. package/dist/rpcDeclared.js +7 -0
  25. package/dist/runRpc.js +9 -6
  26. package/dist/runtime.d.ts +16 -116
  27. package/dist/runtime.js +16 -16
  28. package/dist/runtimeContext.js +1 -1
  29. package/dist/serviceClient.js +23 -23
  30. package/dist/store.js +3 -3
  31. package/dist/subscriptionCache.js +1 -1
  32. package/dist/traceBus.js +7 -1
  33. package/dist/unknownRpcTag.js +7 -0
  34. package/dist/uploadBytes.js +83 -0
  35. package/dist/uploadClient.js +153 -0
  36. package/dist/useAction.js +148 -74
  37. package/dist/useAgentChat.js +3 -3
  38. package/dist/useCapabilityManifest.js +7 -7
  39. package/dist/useConnectionStatus.js +5 -5
  40. package/dist/useDataTable.js +4 -4
  41. package/dist/useEvent.js +22 -22
  42. package/dist/useFormBinding.js +10 -10
  43. package/dist/useMutation.js +221 -134
  44. package/dist/useOnRpcError.js +5 -5
  45. package/dist/usePreloadedSubscription.js +6 -6
  46. package/dist/useRpcCaller.js +75 -13
  47. package/dist/useRpcInvocationOwner.js +29 -0
  48. package/dist/useSubscription.js +52 -49
  49. package/dist/useTranscription.js +112 -40
  50. package/dist/useUpload.js +160 -242
  51. package/dist/useWorkflow.js +111 -246
  52. package/dist/workflowClient.js +126 -0
  53. package/package.json +8 -3
package/dist/useAction.js CHANGED
@@ -1,16 +1,20 @@
1
- import { publishClientTrace as e } from "./traceBus.js";
2
- import { rpcErrorKind as t } from "./rpcErrorKind.js";
3
- import { useFrameworkApi as n } from "./runtimeContext.js";
4
- import { resolveByTag as r } from "./tagWalk.js";
5
- import { runRpcPromise as i } from "./runRpc.js";
6
- import { awaitReadyApi as a } from "./awaitResolvedApi.js";
7
- import { settleMutation as o, startMutation as s } from "./mutationsBus.js";
8
- import { freshIdempotencyKey as c, withIdempotencyKey as l } from "./mutationIdentity.js";
1
+ import { useFrameworkApi as e } from "./runtimeContext.js";
2
+ import { awaitReadyApi as t, bindResolvedRpcInvocationOwner as n } from "./awaitResolvedApi.js";
3
+ import { useRpcInvocationOwner as r } from "./useRpcInvocationOwner.js";
4
+ import { deferRpcMethod as i, runRpcPromise as a } from "./runRpc.js";
5
+ import { resolveByTag as o } from "./tagWalk.js";
6
+ import { omitMutationInputs as s, omitMutationOutputs as c, startMutation as l } from "./mutationsBus.js";
9
7
  import { getMutationNotifier as u } from "./useMutation.js";
10
- import { useCallback as d, useMemo as f, useRef as p, useState as m } from "react";
11
- import { Effect as h } from "effect";
8
+ import { publishClientTrace as d, publishClientTraceRefusal as f } from "./traceBus.js";
9
+ import { rpcErrorKind as p } from "./rpcErrorKind.js";
10
+ import { reportUnknownRpcTag as m } from "./unknownRpcTag.js";
11
+ import { freshIdempotencyKey as h, withIdempotencyKey as g } from "./mutationIdentity.js";
12
+ import { ConnectionPrerequisiteInvalidated as _ } from "./connectionPrerequisite.js";
13
+ import { waitForInvocation as v } from "./invocationWait.js";
14
+ import { useCallback as y, useEffect as b, useMemo as x, useRef as S, useState as C } from "react";
15
+ import { Effect as w } from "effect";
12
16
  // src/useAction.ts
13
- var g = (e, t) => {
17
+ var T = (e, t) => {
14
18
  if (t === void 0 || typeof e != "object" || !e) return e;
15
19
  try {
16
20
  Object.defineProperty(e, "__voltroTraceId", {
@@ -20,81 +24,151 @@ var g = (e, t) => {
20
24
  });
21
25
  } catch {}
22
26
  return e;
23
- }, _ = (e, t, n) => typeof e == "function" ? e(t, n) : e, v = 0, y = () => `act_${++v}`, b = (v, b) => {
24
- let x = n(v), { descriptors: S } = x, C = p(x);
25
- if (C.current = x, process.env.NODE_ENV !== "production") {
26
- let e = S[b]?.kind;
27
- e !== void 0 && e !== "action" && console.error(`[@voltro/client] useAction('${v}', '${b}') targets a ${e}, not an action. Use ${e === "mutation" ? "useMutation" : e === "workflow" ? "useWorkflow" : `the ${e} hook`} instead.`);
27
+ }, E = (e, t, n) => typeof e == "function" ? e(t, n) : e, D = 0, O = () => `act_${++D}`, k = (D, k) => {
28
+ let A = e(D), { descriptors: j } = A, M = j[k]?.outputRetention === "none", N = j[k]?.clientHistory?.input === "omit", P = S(A);
29
+ P.current = A;
30
+ let { owner: F, current: I, assertCurrent: L } = r(P, D, k);
31
+ if (process.env.NODE_ENV !== "production") {
32
+ m("useAction", D, k, j);
33
+ let e = j[k]?.kind;
34
+ e !== void 0 && e !== "action" && console.error(`[@voltro/client] useAction('${D}', '${k}') targets a ${e}, not an action. Use ${e === "mutation" ? "useMutation" : e === "workflow" ? "useWorkflow" : `the ${e} hook`} instead.`);
28
35
  }
29
- let [w, T] = m(!1), [E, D] = m(void 0), [O, k] = m(void 0), A = d(async (n, d) => {
30
- let f = d?.onError !== void 0 || d?.notify?.error !== void 0;
31
- T(!0), D(void 0);
32
- let p = y(), m = d?.idempotencyKey ?? c();
33
- s({
34
- id: p,
35
- apiName: v,
36
- tag: b,
37
- input: n,
38
- kind: "action"
39
- });
40
- let x, S = !1;
36
+ let [R, z] = C(() => ({
37
+ owner: F,
38
+ pending: 0,
39
+ error: void 0,
40
+ lastResult: void 0
41
+ }));
42
+ b(() => {
43
+ M && (z((e) => e.lastResult === void 0 ? e : {
44
+ ...e,
45
+ lastResult: void 0
46
+ }), c(D, k));
47
+ }, [
48
+ M,
49
+ D,
50
+ k
51
+ ]), b(() => {
52
+ N && s(D, k);
53
+ }, [
54
+ N,
55
+ D,
56
+ k
57
+ ]);
58
+ let B = y(async (e, r) => {
59
+ let s = r?.signal, c = () => {
60
+ if (L(), s?.aborted) throw new DOMException("action aborted", "AbortError");
61
+ };
62
+ c();
63
+ let m = F.subject, y = r?.onError !== void 0 || r?.notify?.error !== void 0;
64
+ z((e) => ({
65
+ owner: F,
66
+ pending: e.owner === F ? e.pending + 1 : 1,
67
+ error: void 0,
68
+ lastResult: e.owner === F ? e.lastResult : void 0
69
+ }));
70
+ let b = O(), x = r?.idempotencyKey ?? h(), S = !1, C = () => {
71
+ let t = P.current.descriptors[k], n = !t || t.clientHistory?.input === "omit";
72
+ return S = t?.outputRetention === "none", l({
73
+ id: b,
74
+ apiName: D,
75
+ tag: k,
76
+ input: n ? void 0 : e,
77
+ kind: "action",
78
+ ...n ? { inputOmitted: !0 } : {},
79
+ ...S ? { outputOmitted: !0 } : {}
80
+ }, F.subject);
81
+ }, A = F.resolved ? C() : void 0, j, M = !1;
41
82
  try {
42
- let { runtime: t, client: s } = await a(C, v, b), c = r(s, b), f = h.currentSpan.pipe(h.tap((t) => h.sync(() => {
43
- x = t.traceId, e({
44
- traceId: t.traceId,
45
- spanId: t.spanId,
83
+ let l = await t(P, D, k, s);
84
+ if (m.aborted) throw new _("inactive");
85
+ n(F, l), c(), A ??= C(), c();
86
+ let { runtime: f, client: p } = l, h = o(p, k), y = w.currentSpan.pipe(w.tap((e) => w.sync(() => {
87
+ j = e.traceId, d({
88
+ traceId: e.traceId,
89
+ spanId: e.spanId,
46
90
  source: "action",
47
- tag: b
91
+ tag: k
48
92
  });
49
- })), h.catch(() => h.void), h.andThen(l(c(n), m))).pipe(h.withSpan(`client.action.${b}`, { attributes: {
50
- "voltro.api": v,
51
- "voltro.actionId": p,
52
- "rpc.tag": b
53
- } }));
54
- S = !0;
55
- let g = await i(t, f);
56
- k(g), o(p, {
93
+ })), w.catch(() => w.void), w.andThen(i(() => {
94
+ c();
95
+ let t = h(e);
96
+ return M = !0, g(t, x);
97
+ }))).pipe(w.withSpan(`client.action.${k}`, { attributes: {
98
+ "voltro.api": D,
99
+ "voltro.actionId": b,
100
+ "rpc.tag": k
101
+ } })), T = await v(a(f, y), s, c);
102
+ c();
103
+ let O = S || P.current.descriptors[k]?.outputRetention === "none";
104
+ z((e) => e.owner === F ? {
105
+ ...e,
106
+ error: void 0,
107
+ lastResult: O ? void 0 : T
108
+ } : e), c(), A?.settle({
57
109
  status: "success",
58
- output: g
59
- }), C.current.errorBus.emitSuccess({
110
+ output: O ? void 0 : T,
111
+ ...O ? { outputOmitted: !0 } : {}
112
+ }), c(), P.current.errorBus.emitSuccess({
60
113
  source: "action",
61
- tag: b
62
- }), d?.onSuccess?.(g, n);
63
- let y = _(d?.notify?.success, g, n);
64
- return y !== void 0 && u()?.success(y), g;
65
- } catch (e) {
66
- let r = g(e, x);
67
- if (D(r), o(p, {
114
+ tag: k
115
+ }), c(), r?.onSuccess?.(T, e), c();
116
+ let N = E(r?.notify?.success, T, e);
117
+ return c(), N !== void 0 && u()?.success(N), c(), T;
118
+ } catch (t) {
119
+ let n = I() && !s?.aborted, i = T(I() ? s?.aborted ? new DOMException("action aborted", "AbortError") : t : new _("inactive"), j);
120
+ if (A?.settle({
68
121
  status: "error",
69
- error: r
70
- }), C.current.errorBus.emit({
122
+ error: i
123
+ }), !n) throw i;
124
+ if (c(), z((e) => e.owner === F ? {
125
+ ...e,
126
+ error: i
127
+ } : e), c(), M && j !== void 0 && p(t, "handler") === "handler" && f({
128
+ traceId: j,
129
+ tag: k
130
+ }), P.current.errorBus.emit({
71
131
  source: "action",
72
- tag: b,
73
- error: r,
74
- kind: S ? t(e, "handler") : "client",
75
- outcome: S && t(e, "handler") === "transport" ? "unknown" : S ? "known" : "not-started",
76
- ...x === void 0 ? {} : { traceId: x }
77
- }), f) {
78
- d?.onError?.(r, n);
79
- let e = _(d?.notify?.error, r, n);
80
- e !== void 0 && u()?.error(e);
132
+ tag: k,
133
+ error: i,
134
+ kind: M ? p(t, "handler") : "client",
135
+ outcome: M && p(t, "handler") === "transport" ? "unknown" : M ? "known" : "not-started",
136
+ ...j === void 0 ? {} : { traceId: j }
137
+ }), c(), y) {
138
+ r?.onError?.(i, e), c();
139
+ let t = E(r?.notify?.error, i, e);
140
+ c(), t !== void 0 && u()?.error(t), c();
81
141
  return;
82
142
  }
83
- throw r;
143
+ throw i;
84
144
  } finally {
85
- T(!1);
145
+ I() && z((e) => e.owner === F ? {
146
+ ...e,
147
+ pending: Math.max(0, e.pending - 1)
148
+ } : e);
86
149
  }
87
- }, [v, b]);
88
- return f(() => ({
89
- run: A,
90
- pending: w,
91
- error: E,
92
- lastResult: O
150
+ }, [
151
+ D,
152
+ k,
153
+ F,
154
+ I,
155
+ L
156
+ ]), V = R.owner === F ? R : {
157
+ pending: 0,
158
+ error: void 0,
159
+ lastResult: void 0
160
+ };
161
+ return x(() => ({
162
+ run: B,
163
+ pending: V.pending > 0,
164
+ error: V.error,
165
+ lastResult: M ? void 0 : V.lastResult
93
166
  }), [
94
- A,
95
- w,
96
- E,
97
- O
167
+ B,
168
+ V.pending,
169
+ V.error,
170
+ V.lastResult,
171
+ M
98
172
  ]);
99
173
  };
100
- export { b as useAction };
174
+ export { k as useAction };
@@ -1,5 +1,5 @@
1
- import { useSubscription as e } from "./useSubscription.js";
2
- import { useAction as t } from "./useAction.js";
1
+ import { useAction as e } from "./useAction.js";
2
+ import { useSubscription as t } from "./useSubscription.js";
3
3
  import { useCallback as n, useMemo as r } from "react";
4
4
  // src/useAgentChat.ts
5
5
  var i = (e, t) => e.order - t.order || (e.stepOrder ?? 0) - (t.stepOrder ?? 0), a = (e) => {
@@ -8,7 +8,7 @@ var i = (e, t) => e.order - t.order || (e.stepOrder ?? 0) - (t.stepOrder ?? 0),
8
8
  if (n.role === "user" && n.content) return n.content;
9
9
  }
10
10
  }, o = (o, s, c) => {
11
- let { threadId: l } = c, u = `${s}.messages`, d = e(o, u, { threadId: l }), f = t(o, `${s}.send`), p = r(() => [...d.data ?? []].sort(i), [d.data]), m = n((e, t = {}) => f.run({
11
+ let { threadId: l } = c, u = `${s}.messages`, d = t(o, u, { threadId: l }), f = e(o, `${s}.send`), p = r(() => [...d.data ?? []].sort(i), [d.data]), m = n((e, t = {}) => f.run({
12
12
  threadId: l,
13
13
  order: d.data?.length ?? 0,
14
14
  prompt: e,
@@ -1,6 +1,6 @@
1
1
  import { useFrameworkApi as e } from "./runtimeContext.js";
2
- import { scopeMembership as t } from "./scopeMembership.js";
3
- import { ADMIN_SCOPE as n, usePermissions as r } from "./permissions.js";
2
+ import { ADMIN_SCOPE as t, usePermissions as n } from "./permissions.js";
3
+ import { scopeMembership as r } from "./scopeMembership.js";
4
4
  import { useEffect as i, useState as a } from "react";
5
5
  // src/useCapabilityManifest.ts
6
6
  var o = (e) => `${e.replace(/\/$/, "")}/_voltro/inspect/manifest`, s = (t) => {
@@ -54,17 +54,17 @@ var o = (e) => `${e.replace(/\/$/, "")}/_voltro/inspect/manifest`, s = (t) => {
54
54
  }
55
55
  }
56
56
  return !0;
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) => {
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, n) => {
58
58
  if (e === void 0) return "unknown";
59
- let i = r.includes(n);
59
+ let i = n.includes(t);
60
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
+ let a = e.length >= 32 && n.length >= 32 && !Object.hasOwn(n, "includes") && !Object.hasOwn(n, Symbol.iterator) && c(e) ? r(n) : void 0, o = !1;
62
62
  for (let t of e) if (t.kind !== "open") {
63
63
  if (t.kind === "upgraded") o = !0;
64
64
  else if (t.kind === "policy") {
65
65
  if (i) continue;
66
66
  o = !0;
67
- } else if (!(i || l(r, t, a))) {
67
+ } else if (!(i || l(n, t, a))) {
68
68
  if (t.resourceScoped) o = !0;
69
69
  else return "denied";
70
70
  }
@@ -72,7 +72,7 @@ var o = (e) => `${e.replace(/\/$/, "")}/_voltro/inspect/manifest`, s = (t) => {
72
72
  return o ? "unknown" : "allowed";
73
73
  }, d = (e) => (e ?? []).flatMap((e) => e.kind === "scope" ? [...e.scope] : []), f = (e) => {
74
74
  for (let t of e ?? []) if (t.kind === "open") return t.reason;
75
- }, p = (e) => u(e, r().scopes), m = (e) => e === void 0 ? {} : {
75
+ }, p = (e) => u(e, n().scopes), m = (e) => e === void 0 ? {} : {
76
76
  tag: e.tag,
77
77
  ...e.guards === void 0 ? {} : { guards: e.guards }
78
78
  }, h = (e) => {
@@ -1,14 +1,14 @@
1
- import { recordClientDiagnostic as e } from "./clientDiagnostics.js";
2
- import { INITIAL_RECOVERY_SNAPSHOT as t, recoveryCoordinatorFor as n } from "./recoveryCoordinator.js";
3
- import { useFrameworkApi as r } from "./runtimeContext.js";
1
+ import { useFrameworkApi as e } from "./runtimeContext.js";
2
+ import { recordClientDiagnostic as t } from "./clientDiagnostics.js";
3
+ import { INITIAL_RECOVERY_SNAPSHOT as n, recoveryCoordinatorFor as r } from "./recoveryCoordinator.js";
4
4
  import { useCallback as i, useEffect as a, useSyncExternalStore as o } from "react";
5
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) => {
9
- let d = r(u), f = d.recovery ?? n(d.errorBus, u), p = o(f.subscribe, f.getSnapshot, f.getServerSnapshot ?? (() => t)), m = o(l, s, c), h = i(() => f.reportExternalSuccess(), [f]), g = m ? p.status : "offline";
9
+ let d = e(u), f = d.recovery ?? r(d.errorBus, u), p = o(f.subscribe, f.getSnapshot, f.getServerSnapshot ?? (() => n)), m = o(l, s, c), h = i(() => f.reportExternalSuccess(), [f]), g = m ? p.status : "offline";
10
10
  return a(() => {
11
- e(u, "connection.status", {
11
+ t(u, "connection.status", {
12
12
  status: g,
13
13
  rawTransport: p.rawTransport,
14
14
  online: m,
@@ -1,7 +1,7 @@
1
1
  import { useFrameworkApi as e } from "./runtimeContext.js";
2
2
  import { useSubscription as t } from "./useSubscription.js";
3
- import { schemaToColumns as n } from "./schemaFields.js";
4
- import { createLiveRowSorter as r } from "./liveRowSort.js";
3
+ import { createLiveRowSorter as n } from "./liveRowSort.js";
4
+ import { schemaToColumns as r } from "./schemaFields.js";
5
5
  import { useCallback as i, useMemo as a, useRef as o, useState as s } from "react";
6
6
  // src/useDataTable.ts
7
7
  var c = (c, l, u = {}) => {
@@ -10,7 +10,7 @@ var c = (c, l, u = {}) => {
10
10
  limit: f
11
11
  }, [u.input, f]), h = t(c, l, m), g = d.descriptors[l]?.output, _ = i(() => {
12
12
  u.pageSize !== void 0 && p((e) => (e ?? u.pageSize) + u.pageSize);
13
- }, [u.pageSize]), v = a(() => u.columns ?? (g === void 0 ? [] : n(g)), [u.columns, g]), [y, b] = s(u.initialSort), x = i((e) => {
13
+ }, [u.pageSize]), v = a(() => u.columns ?? (g === void 0 ? [] : r(g)), [u.columns, g]), [y, b] = s(u.initialSort), x = i((e) => {
14
14
  b((t) => t?.column === e ? {
15
15
  column: e,
16
16
  direction: t.direction === "asc" ? "desc" : "asc"
@@ -19,7 +19,7 @@ var c = (c, l, u = {}) => {
19
19
  direction: "asc"
20
20
  });
21
21
  }, []), S = o(void 0);
22
- return S.current === void 0 && (S.current = r()), {
22
+ return S.current === void 0 && (S.current = n()), {
23
23
  columns: v,
24
24
  rows: a(() => S.current(h.data ?? [], y), [h.data, y]),
25
25
  loading: h.data === void 0,
package/dist/useEvent.js CHANGED
@@ -1,7 +1,7 @@
1
- import { recordClientDiagnostic as e } from "./clientDiagnostics.js";
1
+ import { useFrameworkApi as e } from "./runtimeContext.js";
2
2
  import { isUnresolvedApi as t } from "./frameworkRuntimesContext.js";
3
- import { useFrameworkApi as n } from "./runtimeContext.js";
4
- import { resolveByTag as r } from "./tagWalk.js";
3
+ import { resolveByTag as n } from "./tagWalk.js";
4
+ import { recordClientDiagnostic as r } from "./clientDiagnostics.js";
5
5
  import { useEffect as i, useLayoutEffect as a, useMemo as o, useRef as s, useState as c } from "react";
6
6
  import { Effect as l, Fiber as u, Schedule as d, Stream as f } from "effect";
7
7
  // src/useEvent.ts
@@ -13,7 +13,7 @@ var p = {
13
13
  _tag = "EventStreamClosed";
14
14
  };
15
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(() => ({
16
+ let { skip: y = !1, apiName: b = "app", onMissed: x } = v, S = e(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
17
  resume: /* @__PURE__ */ new Map(),
18
18
  runtime: S.runtime,
19
19
  client: S.client,
@@ -36,26 +36,26 @@ function h(h, g, _, v = {}) {
36
36
  E.current = null;
37
37
  })), i(() => {
38
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) => ({
39
+ let e = !1, t = () => !e && !T.subject?.aborted && E.current?.scope === T, i = (e) => {
40
+ t() && O((t) => ({
41
41
  scope: T,
42
42
  value: e(t?.scope === T ? t.value : p)
43
43
  }));
44
- }, a = (t, r) => {
45
- !n() || t <= 0 || (e(T.apiName, "event.gap", {
44
+ }, a = (e, n) => {
45
+ !t() || e <= 0 || (r(T.apiName, "event.gap", {
46
46
  tag: T.tag,
47
- missed: t,
48
- reason: r
49
- }), i((e) => ({
50
- ...e,
51
- missed: e.missed + t,
47
+ missed: e,
48
+ reason: n
49
+ }), i((t) => ({
50
+ ...t,
51
+ missed: t.missed + e,
52
52
  lastMiss: {
53
- count: t,
54
- reason: r
53
+ count: e,
54
+ reason: n
55
55
  }
56
56
  })), E.current?.onMissed?.({
57
- count: t,
58
- reason: r
57
+ count: e,
58
+ reason: n
59
59
  }));
60
60
  };
61
61
  i((e) => ({
@@ -63,12 +63,12 @@ function h(h, g, _, v = {}) {
63
63
  status: "connecting"
64
64
  }));
65
65
  let o = l.suspend(() => {
66
- if (!n()) return l.interrupt;
66
+ if (!t()) return l.interrupt;
67
67
  let e = [...T.resume].map(([e, t]) => ({
68
68
  origin: e,
69
69
  n: t
70
- })), t = r(T.client, T.tag);
71
- return l.succeed(t({
70
+ })), r = n(T.client, T.tag);
71
+ return l.succeed(r({
72
72
  key: T.key,
73
73
  ...e.length > 0 ? { resume: e } : {}
74
74
  }));
@@ -76,12 +76,12 @@ function h(h, g, _, v = {}) {
76
76
  ...e,
77
77
  status: "connecting"
78
78
  }))))))), c = T.runtime.runFork(f.runForEach(s, (e) => l.sync(() => {
79
- n() && (e._tag === "attached" ? i((e) => ({
79
+ t() && (e._tag === "attached" ? i((e) => ({
80
80
  ...e,
81
81
  status: "live"
82
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
83
  }))), h = () => {
84
- t || (t = !0, T.resume.clear(), O((e) => e?.scope === T ? {
84
+ e || (e = !0, T.resume.clear(), O((e) => e?.scope === T ? {
85
85
  scope: T,
86
86
  value: p
87
87
  } : e), T.runtime.runFork(l.forkDetach(u.interrupt(c))));
@@ -1,6 +1,6 @@
1
- import { globalContext as e } from "./globalContext.js";
2
- import { useFrameworkApi as t } from "./runtimeContext.js";
3
- import { useMutation as n } from "./useMutation.js";
1
+ import { useFrameworkApi as e } from "./runtimeContext.js";
2
+ import { useMutation as t } from "./useMutation.js";
3
+ import { globalContext as n } from "./globalContext.js";
4
4
  import { schemaToFields as r } from "./schemaFields.js";
5
5
  import { resolveValidationMessage as i, restrictToSchema as a, validateFields as o } from "./formBinding.js";
6
6
  import { useValidationMessages as s } from "./validationMessages.js";
@@ -12,7 +12,7 @@ import { fieldIssuesOf as re } from "@voltro/protocol";
12
12
  import { FormApi as ie } from "@tanstack/form-core";
13
13
  import { useStore as ae } from "@tanstack/react-store";
14
14
  // src/useFormBinding.ts
15
- var v = Symbol.for("voltro.client.formEngine"), y = e("formFields", void 0), b = (e, t) => Object.is(e.value, t.value) && e.error === t.error && e.serverError === t.serverError && e.touched === t.touched && e.blurred === t.blurred && e.dirty === t.dirty && e.required === t.required && e.label === t.label && e.widget === t.widget && e.options === t.options && e.description === t.description && e.asyncStatus === t.asyncStatus && e.a11y.id === t.a11y.id && e.a11y["aria-invalid"] === t.a11y["aria-invalid"] && e.a11y["aria-required"] === t.a11y["aria-required"] && e.a11y["aria-describedby"] === t.a11y["aria-describedby"], oe = (e, t) => {
15
+ var v = Symbol.for("voltro.client.formEngine"), y = n("formFields", void 0), b = (e, t) => Object.is(e.value, t.value) && e.error === t.error && e.serverError === t.serverError && e.touched === t.touched && e.blurred === t.blurred && e.dirty === t.dirty && e.required === t.required && e.label === t.label && e.widget === t.widget && e.options === t.options && e.description === t.description && e.asyncStatus === t.asyncStatus && e.a11y.id === t.a11y.id && e.a11y["aria-invalid"] === t.a11y["aria-invalid"] && e.a11y["aria-required"] === t.a11y["aria-required"] && e.a11y["aria-describedby"] === t.a11y["aria-describedby"], oe = (e, t) => {
16
16
  let n = t, r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), a, o = (e) => {
17
17
  let t = n(e), i = r.get(e);
18
18
  return i !== void 0 && b(i, t) ? i : (r.set(e, t), t);
@@ -39,7 +39,7 @@ var v = Symbol.for("voltro.client.formEngine"), y = e("formFields", void 0), b =
39
39
  };
40
40
  }
41
41
  };
42
- }, x = e("formBinding", void 0), se = (e, t) => {
42
+ }, x = n("formBinding", void 0), se = (e, t) => {
43
43
  let n = e;
44
44
  for (let e of t.split(".")) {
45
45
  if (typeof n != "object" || !n) return;
@@ -83,9 +83,9 @@ var v = Symbol.for("voltro.client.formEngine"), y = e("formFields", void 0), b =
83
83
  let i = /^(.+?)\.\d+\.(.+)$/.exec(e);
84
84
  return i === null ? void 0 : n.get(i[1])?.get(i[2]);
85
85
  };
86
- }, S = (e, r, i) => {
87
- let a = t(e), o = h(void 0), s = typeof r == "function" ? r(o.current?.state?.values ?? i.defaults ?? {}) : r, c = h(s).current, l = n(e, s), u = i.schema ?? a.descriptors[s]?.input;
88
- return process.env.NODE_ENV !== "production" && u === void 0 && console.error(`[@voltro/client] useFormBinding('${e}', '${r}'): no input schema. Pass options.schema, or mount the descriptor so its input reaches the client. Rendering no fields; submit skips client-side validation.`), w(e, c, i, u, o, l);
86
+ }, S = (n, r, i) => {
87
+ let a = e(n), o = h(void 0), s = typeof r == "function" ? r(o.current?.state?.values ?? i.defaults ?? {}) : r, c = h(s).current, l = t(n, s), u = i.schema ?? a.descriptors[s]?.input;
88
+ return process.env.NODE_ENV !== "production" && u === void 0 && console.error(`[@voltro/client] useFormBinding('${n}', '${r}'): no input schema. Pass options.schema, or mount the descriptor so its input reaches the client. Rendering no fields; submit skips client-side validation.`), w(n, c, i, u, o, l);
89
89
  }, C = (e) => {
90
90
  let t = h(void 0);
91
91
  return w("local", p(), {
@@ -236,7 +236,7 @@ var v = Symbol.for("voltro.client.formEngine"), y = e("formFields", void 0), b =
236
236
  return {
237
237
  value: R.getFieldValue(e),
238
238
  setValue: (t) => {
239
- q(e), !Object.is(R.getFieldValue(e), t) && R.setFieldValue(e, t);
239
+ q(e), Object.is(R.getFieldValue(e), t) || R.setFieldValue(e, t);
240
240
  },
241
241
  onBlur: () => {
242
242
  R.setFieldMeta(e, (e) => ({
@@ -296,7 +296,7 @@ var v = Symbol.for("voltro.client.formEngine"), y = e("formFields", void 0), b =
296
296
  },
297
297
  field: (t, n) => J(`${e}.${t}.${n}`)
298
298
  }), [R, J]), Ce = d((e) => _.filter((t) => t.section === e), [_]), we = d((e, t) => {
299
- q(e), !Object.is(R.getFieldValue(e), t) && R.setFieldValue(e, t);
299
+ q(e), Object.is(R.getFieldValue(e), t) || R.setFieldValue(e, t);
300
300
  }, [q, R]), Te = d((e) => {
301
301
  for (let [t, n] of Object.entries(e)) R.setFieldValue(t, n);
302
302
  }, [R]), Ee = d((e) => {