@voltro/client 0.89.1 → 0.90.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 +1835 -0
- package/README.md +22 -0
- package/dist/analytics.d.ts +68 -0
- package/dist/analytics.js +1 -0
- package/dist/awaitResolvedApi.js +45 -19
- package/dist/bootstrap.d.ts +0 -115
- package/dist/connectionSetupController.js +93 -61
- package/dist/index.d.ts +148 -162
- package/dist/index.js +87 -85
- package/dist/invocationWait.js +14 -0
- package/dist/mutationsBus.js +92 -35
- package/dist/outbox.js +147 -118
- package/dist/outboxState.js +7 -0
- 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/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 +146 -72
- package/dist/useMutation.js +220 -133
- package/dist/useRpcCaller.js +74 -12
- package/dist/useRpcInvocationOwner.js +29 -0
- package/dist/useSubscription.js +52 -49
- package/dist/useTranscription.js +114 -42
- package/dist/useUpload.js +160 -242
- package/dist/useWorkflow.js +111 -246
- package/dist/workflowClient.js +126 -0
- package/package.json +7 -2
package/dist/useSubscription.js
CHANGED
|
@@ -1,97 +1,100 @@
|
|
|
1
1
|
import { useFrameworkApi as e } from "./runtimeContext.js";
|
|
2
2
|
import { resolveByTag as t } from "./tagWalk.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { reportUnknownRpcTag as n } from "./unknownRpcTag.js";
|
|
4
|
+
import { useCallback as r, useMemo as i, useRef as a, useSyncExternalStore as o } from "react";
|
|
5
|
+
import { Stream as s } from "effect";
|
|
5
6
|
// src/useSubscription.ts
|
|
6
|
-
var
|
|
7
|
+
var c = Object.freeze({
|
|
7
8
|
data: void 0,
|
|
8
9
|
revision: -1,
|
|
9
10
|
emittedAt: void 0,
|
|
10
11
|
error: void 0,
|
|
11
12
|
pendingPatches: 0
|
|
12
|
-
}),
|
|
13
|
-
function
|
|
14
|
-
let
|
|
15
|
-
|
|
16
|
-
let b =
|
|
17
|
-
b.current =
|
|
18
|
-
let x =
|
|
19
|
-
|
|
13
|
+
}), l = () => c;
|
|
14
|
+
function u(u, d, f = {}, p = {}) {
|
|
15
|
+
let m = p.skip === !0, { runtime: h, cache: g, client: _, descriptors: v } = e(u);
|
|
16
|
+
process.env.NODE_ENV !== "production" && !m && n("useSubscription", u, d, v);
|
|
17
|
+
let y = v[d]?.source, b = a(f);
|
|
18
|
+
b.current = f;
|
|
19
|
+
let x = a(_);
|
|
20
|
+
x.current = _;
|
|
21
|
+
let S = i(() => JSON.stringify(Object.entries(f).sort(([e], [t]) => e.localeCompare(t))), [f]), C = i(() => {
|
|
22
|
+
let e = b.current;
|
|
20
23
|
return {
|
|
21
|
-
queryKey: [
|
|
24
|
+
queryKey: [d, e],
|
|
22
25
|
fetch: () => {
|
|
23
26
|
let n;
|
|
24
27
|
try {
|
|
25
|
-
n = t(
|
|
28
|
+
n = t(x.current, d);
|
|
26
29
|
} catch (e) {
|
|
27
|
-
return
|
|
30
|
+
return s.fail(e);
|
|
28
31
|
}
|
|
29
32
|
return n(e);
|
|
30
33
|
}
|
|
31
34
|
};
|
|
32
|
-
}, [
|
|
35
|
+
}, [d, S]), w = C.queryKey, T = r((e) => m ? () => {} : g.subscribe(C.queryKey, C.fetch, h, e, y === void 0 ? {} : { source: y }).unsubscribe, [
|
|
36
|
+
g,
|
|
33
37
|
h,
|
|
38
|
+
y,
|
|
34
39
|
m,
|
|
35
|
-
v,
|
|
36
|
-
p,
|
|
37
|
-
S
|
|
38
|
-
]), T = n(() => p ? s : h.peek(C), [
|
|
39
|
-
h,
|
|
40
|
-
p,
|
|
41
40
|
C
|
|
42
|
-
]), E =
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
41
|
+
]), E = r(() => m ? c : g.peek(w), [
|
|
42
|
+
g,
|
|
43
|
+
m,
|
|
44
|
+
w
|
|
45
|
+
]), D = o(T, E, l), O = D.data !== void 0, k = O && (Array.isArray(D.data) ? D.data.length === 0 : D.data === null), A = {
|
|
46
|
+
revision: D.revision,
|
|
47
|
+
emittedAt: D.emittedAt,
|
|
48
|
+
error: D.error,
|
|
49
|
+
pendingPatches: D.pendingPatches
|
|
47
50
|
};
|
|
48
|
-
if (
|
|
49
|
-
let e = Array.isArray(
|
|
51
|
+
if (p.initialSnapshot !== void 0) {
|
|
52
|
+
let e = Array.isArray(p.initialSnapshot) ? p.initialSnapshot.length === 0 : p.initialSnapshot === null;
|
|
50
53
|
return {
|
|
51
|
-
...
|
|
52
|
-
data:
|
|
54
|
+
...A,
|
|
55
|
+
data: O ? D.data : p.initialSnapshot,
|
|
53
56
|
loading: !1,
|
|
54
|
-
idle:
|
|
55
|
-
isEmpty:
|
|
57
|
+
idle: m,
|
|
58
|
+
isEmpty: O ? k : e,
|
|
56
59
|
failed: !1
|
|
57
60
|
};
|
|
58
61
|
}
|
|
59
|
-
return
|
|
60
|
-
...
|
|
62
|
+
return p.fallback === void 0 ? m ? {
|
|
63
|
+
...A,
|
|
61
64
|
data: void 0,
|
|
62
65
|
loading: !1,
|
|
63
66
|
isEmpty: !1,
|
|
64
67
|
idle: !0,
|
|
65
68
|
failed: !1
|
|
66
|
-
} :
|
|
67
|
-
...
|
|
68
|
-
data:
|
|
69
|
+
} : O ? {
|
|
70
|
+
...A,
|
|
71
|
+
data: D.data,
|
|
69
72
|
loading: !1,
|
|
70
|
-
isEmpty:
|
|
73
|
+
isEmpty: k,
|
|
71
74
|
idle: !1,
|
|
72
75
|
failed: !1
|
|
73
|
-
} :
|
|
74
|
-
...
|
|
76
|
+
} : A.error === void 0 ? {
|
|
77
|
+
...A,
|
|
75
78
|
data: void 0,
|
|
76
79
|
loading: !0,
|
|
77
80
|
isEmpty: !1,
|
|
78
81
|
idle: !1,
|
|
79
82
|
failed: !1
|
|
80
83
|
} : {
|
|
81
|
-
...
|
|
84
|
+
...A,
|
|
82
85
|
data: void 0,
|
|
83
86
|
loading: !1,
|
|
84
87
|
isEmpty: !1,
|
|
85
88
|
idle: !1,
|
|
86
89
|
failed: !0,
|
|
87
|
-
error:
|
|
90
|
+
error: A.error
|
|
88
91
|
} : {
|
|
89
|
-
...
|
|
90
|
-
data:
|
|
91
|
-
loading: !
|
|
92
|
-
idle:
|
|
93
|
-
isEmpty:
|
|
94
|
-
failed: !
|
|
92
|
+
...A,
|
|
93
|
+
data: O ? D.data : p.fallback,
|
|
94
|
+
loading: !O && !m,
|
|
95
|
+
idle: m,
|
|
96
|
+
isEmpty: k,
|
|
97
|
+
failed: !O && A.error !== void 0
|
|
95
98
|
};
|
|
96
99
|
}
|
|
97
|
-
export {
|
|
100
|
+
export { u as useSubscription };
|
package/dist/useTranscription.js
CHANGED
|
@@ -1,50 +1,122 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { useFrameworkApi as e } from "./runtimeContext.js";
|
|
2
|
+
import { ConnectionPrerequisiteInvalidated as t } from "./connectionPrerequisite.js";
|
|
3
|
+
import { bindResolvedRpcInvocationOwner as n } from "./awaitResolvedApi.js";
|
|
4
|
+
import { useRpcInvocationOwner as r } from "./useRpcInvocationOwner.js";
|
|
5
|
+
import { waitForInvocation as i } from "./invocationWait.js";
|
|
6
|
+
import { useAction as a } from "./useAction.js";
|
|
7
|
+
import { useUpload as o } from "./useUpload.js";
|
|
8
|
+
import { useCallback as s, useEffect as c, useMemo as l, useRef as u, useState as d } from "react";
|
|
4
9
|
// src/useTranscription.ts
|
|
5
|
-
var
|
|
6
|
-
let
|
|
7
|
-
|
|
8
|
-
let _ =
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
var f = (f, p) => {
|
|
11
|
+
let m = e(f), h = u(m);
|
|
12
|
+
h.current = m;
|
|
13
|
+
let { owner: g, current: _, assertCurrent: v } = r(h, f, p.action), y = o(f), b = a(f, p.action), x = l(() => ({ active: void 0 }), [g]), S = u(void 0), [C, w] = d(() => ({
|
|
14
|
+
owner: g,
|
|
15
|
+
phase: "idle",
|
|
16
|
+
result: void 0,
|
|
17
|
+
error: void 0
|
|
18
|
+
})), T = u(p.extra);
|
|
19
|
+
T.current = p.extra, c(() => () => {
|
|
20
|
+
let e = x.active;
|
|
21
|
+
e && (e.controller.abort(), S.current === e && (e.resetUpload(), S.current = void 0)), x.active = void 0, w((e) => e.owner === g ? {
|
|
22
|
+
owner: g,
|
|
23
|
+
phase: "idle",
|
|
24
|
+
result: void 0,
|
|
25
|
+
error: void 0
|
|
26
|
+
} : e);
|
|
27
|
+
}, [x, g]);
|
|
28
|
+
let E = s(async (e) => {
|
|
29
|
+
if (v(), x.active) throw Error("useTranscription: another transcription is in progress; await it, cancel or reset before starting another.");
|
|
30
|
+
let r = T.current ?? {};
|
|
31
|
+
if (Object.hasOwn(r, "storageRef")) throw TypeError("useTranscription: extra.storageRef is reserved for the uploaded file.");
|
|
32
|
+
let a = { ...r }, o = {
|
|
33
|
+
controller: new AbortController(),
|
|
34
|
+
resetUpload: y.reset
|
|
35
|
+
}, s = S.current;
|
|
36
|
+
s && (s.controller.abort(), s.resetUpload()), x.active = o, S.current = o, w({
|
|
37
|
+
owner: g,
|
|
38
|
+
phase: "uploading",
|
|
39
|
+
result: void 0,
|
|
40
|
+
error: void 0
|
|
41
|
+
});
|
|
42
|
+
let c, l = () => o.controller.abort(), u = () => {
|
|
43
|
+
c !== g.subject && (c?.removeEventListener("abort", l), c = g.subject, c.addEventListener("abort", l, { once: !0 })), c.aborted && l();
|
|
44
|
+
}, d = () => {
|
|
45
|
+
if (v(), x.active !== o || o.controller.signal.aborted) throw new DOMException("transcription aborted", "AbortError");
|
|
46
|
+
}, f = () => _() && x.active === o && !o.controller.signal.aborted;
|
|
47
|
+
u();
|
|
11
48
|
try {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
storageRef: t.id,
|
|
20
|
-
...g.current ?? {}
|
|
49
|
+
d();
|
|
50
|
+
let t = await i(y.upload(e), o.controller.signal, d);
|
|
51
|
+
d(), n(g, h.current), u(), d(), S.current === o && (S.current = void 0), w({
|
|
52
|
+
owner: g,
|
|
53
|
+
phase: "transcribing",
|
|
54
|
+
result: void 0,
|
|
55
|
+
error: void 0
|
|
21
56
|
});
|
|
22
|
-
|
|
57
|
+
let r = await i(b.run({
|
|
58
|
+
...a,
|
|
59
|
+
storageRef: t.id
|
|
60
|
+
}, { signal: o.controller.signal }), o.controller.signal, d);
|
|
61
|
+
if (r == null) throw TypeError("useTranscription: the declared action returned no transcript.");
|
|
62
|
+
return d(), w({
|
|
63
|
+
owner: g,
|
|
64
|
+
phase: "done",
|
|
65
|
+
result: r,
|
|
66
|
+
error: void 0
|
|
67
|
+
}), r;
|
|
23
68
|
} catch (e) {
|
|
24
|
-
|
|
69
|
+
let n = _() ? o.controller.signal.aborted || x.active !== o ? new DOMException("transcription aborted", "AbortError") : e : new t("inactive");
|
|
70
|
+
throw f() && w({
|
|
71
|
+
owner: g,
|
|
72
|
+
phase: "error",
|
|
73
|
+
result: void 0,
|
|
74
|
+
error: n
|
|
75
|
+
}), n;
|
|
76
|
+
} finally {
|
|
77
|
+
c?.removeEventListener("abort", l), x.active === o && (x.active = void 0), S.current === o && (S.current = void 0);
|
|
25
78
|
}
|
|
26
|
-
}, [
|
|
27
|
-
c.cancel(), d("idle");
|
|
28
|
-
}, [c]), y = n(() => {
|
|
29
|
-
c.reset(), d("idle"), p(void 0), h(void 0);
|
|
30
|
-
}, [c]);
|
|
31
|
-
return r(() => ({
|
|
32
|
-
phase: u,
|
|
33
|
-
progress: u === "uploading" ? c.progress : void 0,
|
|
34
|
-
result: f,
|
|
35
|
-
error: m ?? c.error,
|
|
36
|
-
transcribe: _,
|
|
37
|
-
cancel: v,
|
|
38
|
-
reset: y
|
|
39
|
-
}), [
|
|
40
|
-
u,
|
|
41
|
-
c.progress,
|
|
42
|
-
c.error,
|
|
43
|
-
f,
|
|
44
|
-
m,
|
|
45
|
-
_,
|
|
79
|
+
}, [
|
|
46
80
|
v,
|
|
47
|
-
|
|
81
|
+
_,
|
|
82
|
+
x,
|
|
83
|
+
g,
|
|
84
|
+
y.upload,
|
|
85
|
+
y.reset,
|
|
86
|
+
b.run
|
|
87
|
+
]), D = s(() => {
|
|
88
|
+
_() && (x.active?.controller.abort(), x.active = void 0, y.reset(), S.current = void 0, w({
|
|
89
|
+
owner: g,
|
|
90
|
+
phase: "idle",
|
|
91
|
+
result: void 0,
|
|
92
|
+
error: void 0
|
|
93
|
+
}));
|
|
94
|
+
}, [
|
|
95
|
+
_,
|
|
96
|
+
x,
|
|
97
|
+
g,
|
|
98
|
+
y.reset
|
|
99
|
+
]), O = D, k = C.owner === g ? C : {
|
|
100
|
+
phase: "idle",
|
|
101
|
+
result: void 0,
|
|
102
|
+
error: void 0
|
|
103
|
+
};
|
|
104
|
+
return l(() => ({
|
|
105
|
+
phase: k.phase,
|
|
106
|
+
progress: k.phase === "uploading" ? y.progress : void 0,
|
|
107
|
+
result: k.result,
|
|
108
|
+
error: k.error,
|
|
109
|
+
transcribe: E,
|
|
110
|
+
cancel: D,
|
|
111
|
+
reset: O
|
|
112
|
+
}), [
|
|
113
|
+
k.phase,
|
|
114
|
+
y.progress,
|
|
115
|
+
k.result,
|
|
116
|
+
k.error,
|
|
117
|
+
E,
|
|
118
|
+
D,
|
|
119
|
+
O
|
|
48
120
|
]);
|
|
49
121
|
};
|
|
50
|
-
export {
|
|
122
|
+
export { f as useTranscription };
|