@voltro/client 0.89.2 → 0.91.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1943 -0
- package/README.md +22 -0
- package/THIRD-PARTY-NOTICES.md +1 -1
- package/dist/analytics.d.ts +68 -0
- package/dist/analytics.js +1 -0
- package/dist/apiRuntime.js +50 -50
- package/dist/apiSupervisor.js +25 -25
- package/dist/awaitResolvedApi.js +42 -16
- package/dist/bootstrap.d.ts +0 -115
- package/dist/bootstrap.js +8 -8
- package/dist/connectionPrerequisite.js +18 -18
- package/dist/connectionSetupController.js +123 -91
- package/dist/createHooks.js +11 -11
- package/dist/form.js +7 -7
- package/dist/index.d.ts +148 -162
- package/dist/index.js +88 -86
- package/dist/invocationWait.js +14 -0
- package/dist/mutationsBus.js +92 -35
- package/dist/outbox.js +137 -108
- package/dist/outboxState.js +7 -0
- package/dist/platform.js +10 -10
- package/dist/query.js +3 -10
- package/dist/rpcCallOnce.js +30 -0
- package/dist/rpcDeclared.js +7 -0
- package/dist/runRpc.js +9 -6
- package/dist/runtime.d.ts +16 -116
- package/dist/runtime.js +16 -16
- package/dist/runtimeContext.js +1 -1
- package/dist/serviceClient.js +23 -23
- package/dist/store.js +3 -3
- package/dist/subscriptionCache.js +1 -1
- package/dist/traceBus.js +7 -1
- package/dist/unknownRpcTag.js +7 -0
- package/dist/uploadBytes.js +83 -0
- package/dist/uploadClient.js +153 -0
- package/dist/useAction.js +148 -74
- package/dist/useAgentChat.js +3 -3
- package/dist/useCapabilityManifest.js +7 -7
- package/dist/useConnectionStatus.js +5 -5
- package/dist/useDataTable.js +4 -4
- package/dist/useEvent.js +22 -22
- package/dist/useFormBinding.js +10 -10
- package/dist/useMutation.js +221 -134
- package/dist/useOnRpcError.js +5 -5
- package/dist/usePreloadedSubscription.js +6 -6
- package/dist/useRpcCaller.js +75 -13
- package/dist/useRpcInvocationOwner.js +29 -0
- package/dist/useSubscription.js +52 -49
- package/dist/useTranscription.js +112 -40
- package/dist/useUpload.js +160 -242
- package/dist/useWorkflow.js +111 -246
- package/dist/workflowClient.js +126 -0
- package/package.json +8 -3
package/dist/useAction.js
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
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 {
|
|
11
|
-
import {
|
|
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
|
|
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
|
-
},
|
|
24
|
-
let
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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 [
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
});
|
|
40
|
-
|
|
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
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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:
|
|
91
|
+
tag: k
|
|
48
92
|
});
|
|
49
|
-
})),
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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:
|
|
59
|
-
|
|
110
|
+
output: O ? void 0 : T,
|
|
111
|
+
...O ? { outputOmitted: !0 } : {}
|
|
112
|
+
}), c(), P.current.errorBus.emitSuccess({
|
|
60
113
|
source: "action",
|
|
61
|
-
tag:
|
|
62
|
-
}),
|
|
63
|
-
let
|
|
64
|
-
return
|
|
65
|
-
} catch (
|
|
66
|
-
let
|
|
67
|
-
if (
|
|
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:
|
|
70
|
-
}),
|
|
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:
|
|
73
|
-
error:
|
|
74
|
-
kind:
|
|
75
|
-
outcome:
|
|
76
|
-
...
|
|
77
|
-
}),
|
|
78
|
-
|
|
79
|
-
let
|
|
80
|
-
|
|
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
|
|
143
|
+
throw i;
|
|
84
144
|
} finally {
|
|
85
|
-
|
|
145
|
+
I() && z((e) => e.owner === F ? {
|
|
146
|
+
...e,
|
|
147
|
+
pending: Math.max(0, e.pending - 1)
|
|
148
|
+
} : e);
|
|
86
149
|
}
|
|
87
|
-
}, [
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
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
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
167
|
+
B,
|
|
168
|
+
V.pending,
|
|
169
|
+
V.error,
|
|
170
|
+
V.lastResult,
|
|
171
|
+
M
|
|
98
172
|
]);
|
|
99
173
|
};
|
|
100
|
-
export {
|
|
174
|
+
export { k as useAction };
|
package/dist/useAgentChat.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
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 =
|
|
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 {
|
|
3
|
-
import {
|
|
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,
|
|
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 =
|
|
59
|
+
let i = n.includes(t);
|
|
60
60
|
if (e.length === 0) return "allowed";
|
|
61
|
-
let a = e.length >= 32 &&
|
|
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(
|
|
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,
|
|
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 {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
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 =
|
|
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
|
-
|
|
11
|
+
t(u, "connection.status", {
|
|
12
12
|
status: g,
|
|
13
13
|
rawTransport: p.rawTransport,
|
|
14
14
|
online: m,
|
package/dist/useDataTable.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useFrameworkApi as e } from "./runtimeContext.js";
|
|
2
2
|
import { useSubscription as t } from "./useSubscription.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
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 ? [] :
|
|
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 =
|
|
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 {
|
|
1
|
+
import { useFrameworkApi as e } from "./runtimeContext.js";
|
|
2
2
|
import { isUnresolvedApi as t } from "./frameworkRuntimesContext.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
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 =
|
|
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
|
|
40
|
-
|
|
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 = (
|
|
45
|
-
!
|
|
44
|
+
}, a = (e, n) => {
|
|
45
|
+
!t() || e <= 0 || (r(T.apiName, "event.gap", {
|
|
46
46
|
tag: T.tag,
|
|
47
|
-
missed:
|
|
48
|
-
reason:
|
|
49
|
-
}), i((
|
|
50
|
-
...
|
|
51
|
-
missed:
|
|
47
|
+
missed: e,
|
|
48
|
+
reason: n
|
|
49
|
+
}), i((t) => ({
|
|
50
|
+
...t,
|
|
51
|
+
missed: t.missed + e,
|
|
52
52
|
lastMiss: {
|
|
53
|
-
count:
|
|
54
|
-
reason:
|
|
53
|
+
count: e,
|
|
54
|
+
reason: n
|
|
55
55
|
}
|
|
56
56
|
})), E.current?.onMissed?.({
|
|
57
|
-
count:
|
|
58
|
-
reason:
|
|
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 (!
|
|
66
|
+
if (!t()) return l.interrupt;
|
|
67
67
|
let e = [...T.resume].map(([e, t]) => ({
|
|
68
68
|
origin: e,
|
|
69
69
|
n: t
|
|
70
|
-
})),
|
|
71
|
-
return l.succeed(
|
|
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
|
-
|
|
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
|
-
|
|
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))));
|
package/dist/useFormBinding.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
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 =
|
|
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 =
|
|
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 = (
|
|
87
|
-
let a =
|
|
88
|
-
return process.env.NODE_ENV !== "production" && u === void 0 && console.error(`[@voltro/client] useFormBinding('${
|
|
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),
|
|
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),
|
|
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) => {
|