@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.
- package/CHANGELOG.md +666 -0
- package/THIRD-PARTY-NOTICES.md +5 -33
- package/dist/analyticsCatalog.js +47 -0
- package/dist/apiConnectivity.js +33 -0
- package/dist/apiRuntime.js +135 -0
- package/dist/apiSupervisor.js +125 -0
- package/dist/authRefresh.js +20 -0
- package/dist/awaitResolvedApi.js +23 -0
- package/dist/bootstrap.d.ts +1144 -0
- package/dist/bootstrap.js +8 -0
- package/dist/cellMerger.js +6 -0
- package/dist/clientDiagnostics.js +94 -0
- package/dist/clientErrorBus.js +16 -0
- package/dist/clientScheduler.js +31 -0
- package/dist/connectionPrerequisite.js +70 -0
- package/dist/connectionScope.js +35 -0
- package/dist/connectionSetupController.js +206 -0
- package/dist/createHooks.js +15 -0
- package/dist/deepLink.js +69 -0
- package/dist/filters.js +58 -0
- package/dist/form.js +5 -2
- package/dist/formBinding.js +325 -0
- package/dist/formData.js +65 -0
- package/dist/formFlashId.js +4 -0
- package/dist/frameworkRuntimesContext.js +8 -0
- package/dist/globalContext.js +10 -0
- package/dist/index.d.ts +53 -7
- package/dist/index.js +83 -4121
- package/dist/liveRowSort.js +66 -0
- package/dist/mutationConnectionSetup.js +16 -0
- package/dist/mutationIdentity.js +10 -0
- package/dist/mutationSerialExecution.js +53 -0
- package/dist/mutationsBus.js +40 -0
- package/dist/onlineSource.js +13 -0
- package/dist/outbox.js +213 -0
- package/dist/outboxHttp.js +104 -0
- package/dist/outboxState.js +43 -0
- package/dist/permissions.js +20 -0
- package/dist/platform.js +121 -0
- package/dist/preloadSeed.js +47 -0
- package/dist/provider.js +22 -0
- package/dist/query.js +12 -2
- package/dist/recoveryCoordinator.js +195 -0
- package/dist/recoveryRetry.js +24 -0
- package/dist/richText.js +176 -0
- package/dist/rpcErrorBus.js +39 -0
- package/dist/rpcErrorKind.js +13 -0
- package/dist/runRpc.js +12 -0
- package/dist/runtime.d.ts +32 -1
- package/dist/runtime.js +16 -126
- package/dist/runtimeCapabilities.js +44 -0
- package/dist/runtimeContext.js +49 -0
- package/dist/schemaFields.js +219 -0
- package/dist/scopeMembership.js +12 -0
- package/dist/seedResolvers.js +7 -0
- package/dist/sequence.js +65 -0
- package/dist/serverRequest.js +24 -0
- package/dist/serviceClient.js +128 -0
- package/dist/squashRpcCause.js +8 -0
- package/dist/stableKey.js +21 -0
- package/dist/store.js +288 -0
- package/dist/storeStorage.js +28 -0
- package/dist/subscriptionCache.js +724 -0
- package/dist/tagWalk.js +23 -0
- package/dist/traceBus.js +10 -0
- package/dist/tracking.js +40 -0
- package/dist/uploadProgress.js +21 -0
- package/dist/useAction.js +101 -0
- package/dist/useAgent.js +53 -0
- package/dist/useAgentChat.js +43 -0
- package/dist/useAgentStream.js +64 -0
- package/dist/useApiOnline.js +14 -0
- package/dist/useCapabilityManifest.js +101 -0
- package/dist/useConnectionSetup.js +28 -0
- package/dist/useConnectionStatus.js +38 -0
- package/dist/useConnections.js +107 -0
- package/dist/useDataCopilot.js +24 -0
- package/dist/useDataTable.js +34 -0
- package/dist/useDerived.js +22 -0
- package/dist/useEvent.js +88 -0
- package/dist/useFormBinding.js +476 -0
- package/dist/useLocalQuery.js +59 -0
- package/dist/useMutation.js +214 -0
- package/dist/useOnRpcError.js +13 -0
- package/dist/usePreloadedSubscription.js +18 -0
- package/dist/usePreview.js +14 -0
- package/dist/useProvenance.js +51 -0
- package/dist/useQueryField.js +34 -0
- package/dist/useRecord.js +12 -0
- package/dist/useRefreshSubscriptions.js +22 -0
- package/dist/useResourceCan.js +18 -0
- package/dist/useResumableAgentStream.js +75 -0
- package/dist/useSequence.js +25 -0
- package/dist/useSkeleton.js +13 -0
- package/dist/useSubscription.js +89 -0
- package/dist/useSubscriptionHealth.js +32 -0
- package/dist/useTranscription.js +51 -0
- package/dist/useUndo.js +33 -0
- package/dist/useUndoLog.js +44 -0
- package/dist/useUpload.js +296 -0
- package/dist/useWindowedSubscription.js +65 -0
- package/dist/useWorkflow.js +284 -0
- package/dist/useWorkflowRunState.js +93 -0
- package/dist/validation.js +39 -0
- package/dist/validationMessages.js +5 -0
- package/package.json +7 -2
- package/dist/authRefresh-DmfSoCca.js +0 -360
- package/dist/formData-BfpBt7BQ.js +0 -769
- package/dist/queryOnce-D5Y4V1SB.js +0 -55
- package/dist/runRpc-Zfz3w709.js +0 -1172
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { globalContext as e } from "./globalContext.js";
|
|
2
|
+
import { FrameworkRuntimesContext as t } from "./frameworkRuntimesContext.js";
|
|
3
|
+
import { FrameworkRuntimesProvider as n } from "./provider.js";
|
|
4
|
+
import { applyStoreSeeds as r } from "./store.js";
|
|
5
|
+
import { browserPlatform as i, currentPlatform as a, installPlatform as o, isPlatformInstalled as s, usePlatform as c } from "./platform.js";
|
|
6
|
+
import { applyPreloadSeeds as l } from "./preloadSeed.js";
|
|
7
|
+
import { useServerRequest as u } from "./serverRequest.js";
|
|
8
|
+
export { t as FrameworkRuntimesContext, n as FrameworkRuntimesProvider, l as applyPreloadSeeds, r as applyStoreSeeds, i as browserPlatform, a as currentPlatform, e as globalContext, o as installPlatform, s as isPlatformInstalled, c as usePlatform, u as useServerRequest };
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
//#region src/clientDiagnostics.ts
|
|
2
|
+
var e = "voltro.client-diagnostics.v1", t = Symbol.for("@voltro/client/diagnostics"), n = globalThis, r = () => typeof performance < "u" && typeof performance.now == "function" ? performance.now() : Date.now(), i = n[t] ?? (n[t] = {
|
|
3
|
+
sessionStartedAt: Date.now(),
|
|
4
|
+
monotonicStartedAt: r(),
|
|
5
|
+
sequence: 0,
|
|
6
|
+
dropped: 0,
|
|
7
|
+
storage: void 0,
|
|
8
|
+
events: [],
|
|
9
|
+
resolved: {},
|
|
10
|
+
loadedStorage: !1,
|
|
11
|
+
listeners: /* @__PURE__ */ new Set()
|
|
12
|
+
}), a = (e) => e.length <= 240 ? e : `${e.slice(0, 240)}…`, o = (e) => {
|
|
13
|
+
let t = {};
|
|
14
|
+
for (let [n, r] of Object.entries(e)) r !== void 0 && (t[n] = typeof r == "string" ? a(r) : r);
|
|
15
|
+
return t;
|
|
16
|
+
}, s = (e) => {
|
|
17
|
+
if (typeof e != "object" || !e) return !1;
|
|
18
|
+
let t = e;
|
|
19
|
+
return typeof t.sequence == "number" && typeof t.at == "number" && typeof t.elapsedMs == "number" && typeof t.api == "string" && typeof t.kind == "string" && typeof t.fields == "object" && t.fields !== null;
|
|
20
|
+
}, c = () => {
|
|
21
|
+
if (i.storage !== void 0) try {
|
|
22
|
+
i.storage.setItem(e, JSON.stringify({
|
|
23
|
+
version: 1,
|
|
24
|
+
sessionStartedAt: i.sessionStartedAt,
|
|
25
|
+
sequence: i.sequence,
|
|
26
|
+
dropped: i.dropped,
|
|
27
|
+
events: i.events
|
|
28
|
+
}));
|
|
29
|
+
} catch {}
|
|
30
|
+
}, l = () => {
|
|
31
|
+
for (let e of i.listeners) try {
|
|
32
|
+
e();
|
|
33
|
+
} catch {}
|
|
34
|
+
}, u = (t) => {
|
|
35
|
+
if (i.storage = t, !i.loadedStorage) {
|
|
36
|
+
i.loadedStorage = !0;
|
|
37
|
+
try {
|
|
38
|
+
let n = t.getItem(e);
|
|
39
|
+
if (n !== null) {
|
|
40
|
+
let e = JSON.parse(n), t = Array.isArray(e.events) ? e.events : [], r = 0;
|
|
41
|
+
for (let e of t) s(e) && (t[r++] = e);
|
|
42
|
+
t.length = r;
|
|
43
|
+
let a = t, o = Math.max(typeof e.sequence == "number" ? e.sequence : 0, 0);
|
|
44
|
+
for (let e of a) o = Math.max(o, e.sequence);
|
|
45
|
+
let c = i.events.map((e, t) => ({
|
|
46
|
+
...e,
|
|
47
|
+
sequence: o + t + 1
|
|
48
|
+
})), l = a.length + c.length, u = Math.max(0, l - 400), d = Array(Math.min(400, l));
|
|
49
|
+
for (let e = 0; e < d.length; e += 1) {
|
|
50
|
+
let t = u + e;
|
|
51
|
+
d[e] = t < a.length ? a[t] : c[t - a.length];
|
|
52
|
+
}
|
|
53
|
+
let f = typeof e.dropped == "number" ? e.dropped : 0;
|
|
54
|
+
i.dropped = i.dropped + f + u, i.events = d, i.sequence = o + c.length;
|
|
55
|
+
for (let e of i.events) i.sequence = Math.max(i.sequence, e.sequence);
|
|
56
|
+
typeof e.sessionStartedAt == "number" && (i.sessionStartedAt = Math.min(i.sessionStartedAt, e.sessionStartedAt));
|
|
57
|
+
}
|
|
58
|
+
} catch {}
|
|
59
|
+
}
|
|
60
|
+
c();
|
|
61
|
+
}, d = () => {
|
|
62
|
+
i.storage = void 0;
|
|
63
|
+
}, f = (e, t, n = {}) => {
|
|
64
|
+
let s = {
|
|
65
|
+
sequence: ++i.sequence,
|
|
66
|
+
at: Date.now(),
|
|
67
|
+
elapsedMs: Math.max(0, Math.round(r() - i.monotonicStartedAt)),
|
|
68
|
+
api: a(e),
|
|
69
|
+
kind: t,
|
|
70
|
+
fields: o(n)
|
|
71
|
+
};
|
|
72
|
+
return t === "runtime.resolved" && (i.resolved = {
|
|
73
|
+
...i.resolved,
|
|
74
|
+
[s.api]: s.fields
|
|
75
|
+
}), i.events.push(s), i.events.length > 400 && (i.events.splice(0, i.events.length - 400), i.dropped += 1), c(), l(), s;
|
|
76
|
+
}, p = (e) => ({
|
|
77
|
+
version: 1,
|
|
78
|
+
generatedAt: Date.now(),
|
|
79
|
+
sessionStartedAt: i.sessionStartedAt,
|
|
80
|
+
persisted: i.storage !== void 0,
|
|
81
|
+
dropped: i.dropped,
|
|
82
|
+
events: e === void 0 ? [...i.events] : i.events.filter((t) => t.api === e),
|
|
83
|
+
runtime: e === void 0 ? { ...i.resolved } : i.resolved[e] === void 0 ? {} : { [e]: i.resolved[e] }
|
|
84
|
+
}), m = () => {
|
|
85
|
+
i.events = [], i.dropped = 0;
|
|
86
|
+
try {
|
|
87
|
+
i.storage?.removeItem(e);
|
|
88
|
+
} catch {}
|
|
89
|
+
l();
|
|
90
|
+
}, h = (e) => (i.listeners.add(e), () => {
|
|
91
|
+
i.listeners.delete(e);
|
|
92
|
+
});
|
|
93
|
+
//#endregion
|
|
94
|
+
export { m as clearClientDiagnostics, p as clientDiagnosticsSnapshot, d as disableClientDiagnosticsPersistence, u as enableClientDiagnosticsPersistence, f as recordClientDiagnostic, h as subscribeClientDiagnostics };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//#region src/clientErrorBus.ts
|
|
2
|
+
var e = /* @__PURE__ */ new Set(), t = (t) => {
|
|
3
|
+
for (let n of e) try {
|
|
4
|
+
n(t);
|
|
5
|
+
} catch {}
|
|
6
|
+
}, n = (t) => (e.add(t), () => {
|
|
7
|
+
e.delete(t);
|
|
8
|
+
}), r = (e, n) => {
|
|
9
|
+
t({
|
|
10
|
+
error: e,
|
|
11
|
+
source: "manual",
|
|
12
|
+
...n ? { context: n } : {}
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
//#endregion
|
|
16
|
+
export { t as publishClientError, r as reportClientError, n as subscribeClientErrors };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { MutableList as e, Scheduler as t } from "effect";
|
|
2
|
+
//#region src/clientScheduler.ts
|
|
3
|
+
var n = {
|
|
4
|
+
channel: "timer",
|
|
5
|
+
yield: (e) => {
|
|
6
|
+
setTimeout(e, 0);
|
|
7
|
+
}
|
|
8
|
+
}, r = (t) => {
|
|
9
|
+
let n = e.make();
|
|
10
|
+
return t.port1.onmessage = () => {
|
|
11
|
+
let t = e.take(n);
|
|
12
|
+
t !== e.Empty && t();
|
|
13
|
+
}, t.port1.unref?.(), {
|
|
14
|
+
channel: "message-channel",
|
|
15
|
+
yield: (r) => {
|
|
16
|
+
e.append(n, r), t.port2.postMessage(null);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
}, i = () => globalThis.window !== void 0 && typeof MessageChannel == "function" ? r(new MessageChannel()) : n, a = (e = i()) => {
|
|
20
|
+
let n = new t.MixedScheduler("async", (t) => {
|
|
21
|
+
let n = !0;
|
|
22
|
+
return e.yield(() => {
|
|
23
|
+
n && t();
|
|
24
|
+
}), () => {
|
|
25
|
+
n = !1;
|
|
26
|
+
};
|
|
27
|
+
});
|
|
28
|
+
return Object.assign(n, { yieldChannel: e.channel });
|
|
29
|
+
};
|
|
30
|
+
//#endregion
|
|
31
|
+
export { i as hostMacrotaskYield, a as makeClientScheduler, r as messageChannelYield, n as timerYield };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { rememberRpcErrorKind as e } from "./rpcErrorKind.js";
|
|
2
|
+
import { connectionScopeForRuntime as t } from "./connectionScope.js";
|
|
3
|
+
import { runRpcPromise as n } from "./runRpc.js";
|
|
4
|
+
import { Effect as r } from "effect";
|
|
5
|
+
//#region src/connectionPrerequisite.ts
|
|
6
|
+
var i = "voltro:connection-setup-superseded", a = (e) => e.reason === "voltro:connection-setup-superseded" ? "superseded" : "inactive", o = class extends Error {
|
|
7
|
+
reason;
|
|
8
|
+
_tag = "ConnectionPrerequisiteInvalidated";
|
|
9
|
+
constructor(t) {
|
|
10
|
+
super(`Voltro connection prerequisite: ${t}`), this.reason = t, e(this, t === "connection-unavailable" || t === "connection-changed" ? "transport" : "client");
|
|
11
|
+
}
|
|
12
|
+
}, s = class {
|
|
13
|
+
#e;
|
|
14
|
+
#t;
|
|
15
|
+
#n = /* @__PURE__ */ new WeakMap();
|
|
16
|
+
#r = /* @__PURE__ */ new WeakSet();
|
|
17
|
+
constructor(e, t) {
|
|
18
|
+
if (!Number.isFinite(t) || t <= 0 || t > 6e4) throw RangeError("Connection prerequisite timeout must be between 0 and 60000 ms");
|
|
19
|
+
this.#e = e, this.#t = t;
|
|
20
|
+
}
|
|
21
|
+
prepare(e, i) {
|
|
22
|
+
let s = t(e)?.getSnapshot();
|
|
23
|
+
if (this.#e.aborted) return Promise.reject(new o(a(this.#e)));
|
|
24
|
+
if (s === void 0) return Promise.reject(new o("connection-unavailable"));
|
|
25
|
+
let c = this.#n.get(s);
|
|
26
|
+
if (c !== void 0) return c.then((t) => (this.assertCurrent(e, t), t));
|
|
27
|
+
let l = this.#a(e, s, i).pipe(r.timeoutOrElse({
|
|
28
|
+
duration: this.#t,
|
|
29
|
+
orElse: () => r.fail(new o("timeout"))
|
|
30
|
+
})), u = n(e, l).then((t) => {
|
|
31
|
+
let n = Object.freeze({
|
|
32
|
+
lease: s,
|
|
33
|
+
output: t
|
|
34
|
+
});
|
|
35
|
+
return this.#r.add(n), this.assertCurrent(e, n), n;
|
|
36
|
+
});
|
|
37
|
+
return this.#n.set(s, u), u.catch(() => {
|
|
38
|
+
this.#n.get(s) === u && this.#n.delete(s);
|
|
39
|
+
}), u;
|
|
40
|
+
}
|
|
41
|
+
assertCurrent(e, t) {
|
|
42
|
+
if (!this.#r.has(t)) throw new o(a(this.#e));
|
|
43
|
+
this.#i(e, t.lease);
|
|
44
|
+
}
|
|
45
|
+
#i(e, n) {
|
|
46
|
+
if (this.#e.aborted) throw new o(a(this.#e));
|
|
47
|
+
if (n.signal.aborted || t(e)?.getSnapshot() !== n) throw new o("connection-changed");
|
|
48
|
+
}
|
|
49
|
+
run(e, t, i) {
|
|
50
|
+
let a = r.try({
|
|
51
|
+
try: () => this.assertCurrent(e, t),
|
|
52
|
+
catch: (e) => e
|
|
53
|
+
}).pipe(r.andThen(i));
|
|
54
|
+
return n(e, this.#a(e, t.lease, a));
|
|
55
|
+
}
|
|
56
|
+
#a(e, t, n) {
|
|
57
|
+
let i = r.try({
|
|
58
|
+
try: () => this.#i(e, t),
|
|
59
|
+
catch: (e) => e
|
|
60
|
+
}), s = r.callback((e) => {
|
|
61
|
+
let n = () => e(r.fail(new o(this.#e.aborted ? a(this.#e) : "connection-changed")));
|
|
62
|
+
return this.#e.addEventListener("abort", n, { once: !0 }), t.signal.addEventListener("abort", n, { once: !0 }), (this.#e.aborted || t.signal.aborted) && n(), r.sync(() => {
|
|
63
|
+
this.#e.removeEventListener("abort", n), t.signal.removeEventListener("abort", n);
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
return i.pipe(r.andThen(n), r.tap(() => i), r.raceFirst(s));
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
//#endregion
|
|
70
|
+
export { s as ConnectionPrerequisite, o as ConnectionPrerequisiteInvalidated, i as SUPERSEDED_BY_LATER_ACTIVATION, a as activationEndReason };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
//#region src/connectionScope.ts
|
|
2
|
+
var e = class {
|
|
3
|
+
#e;
|
|
4
|
+
#t;
|
|
5
|
+
#n;
|
|
6
|
+
#r = /* @__PURE__ */ new Set();
|
|
7
|
+
getSnapshot = () => this.#n;
|
|
8
|
+
subscribe = (e) => (this.#r.add(e), () => {
|
|
9
|
+
this.#r.delete(e);
|
|
10
|
+
});
|
|
11
|
+
begin() {
|
|
12
|
+
let e = {};
|
|
13
|
+
return this.#e = e, this.#i(), {
|
|
14
|
+
open: () => {
|
|
15
|
+
if (this.#e === e) return this.#n === void 0 && (this.#t = new AbortController(), this.#n = Object.freeze({ signal: this.#t.signal }), this.#a()), this.#e === e ? this.#n : void 0;
|
|
16
|
+
},
|
|
17
|
+
close: () => {
|
|
18
|
+
this.#e === e && (this.#e = void 0, this.#i());
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
#i() {
|
|
23
|
+
let e = this.#t, t = this.#n !== void 0;
|
|
24
|
+
this.#t = void 0, this.#n = void 0, e?.abort(), t && this.#a();
|
|
25
|
+
}
|
|
26
|
+
#a() {
|
|
27
|
+
for (let e of this.#r) try {
|
|
28
|
+
e();
|
|
29
|
+
} catch {}
|
|
30
|
+
}
|
|
31
|
+
}, t = /* @__PURE__ */ new WeakMap(), n = (e, n) => {
|
|
32
|
+
t.set(e, n);
|
|
33
|
+
}, r = (e) => t.get(e);
|
|
34
|
+
//#endregion
|
|
35
|
+
export { e as ConnectionScope, r as connectionScopeForRuntime, n as registerConnectionScope };
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { squashRpcCause as e } from "./squashRpcCause.js";
|
|
2
|
+
import { rpcErrorKind as t } from "./rpcErrorKind.js";
|
|
3
|
+
import { recoveryCoordinatorFor as n } from "./recoveryCoordinator.js";
|
|
4
|
+
import { connectionScopeForRuntime as r } from "./connectionScope.js";
|
|
5
|
+
import { resolveByTag as i } from "./tagWalk.js";
|
|
6
|
+
import { runRpcPromise as a } from "./runRpc.js";
|
|
7
|
+
import { ConnectionPrerequisite as o, ConnectionPrerequisiteInvalidated as s, SUPERSEDED_BY_LATER_ACTIVATION as c, activationEndReason as l } from "./connectionPrerequisite.js";
|
|
8
|
+
import { settleMutation as u, startMutation as d } from "./mutationsBus.js";
|
|
9
|
+
import { createConnectionSetupHandle as f } from "./mutationConnectionSetup.js";
|
|
10
|
+
import { freshIdempotencyKey as p, withIdempotencyKey as m } from "./mutationIdentity.js";
|
|
11
|
+
import { Cause as h, Effect as g, Exit as _ } from "effect";
|
|
12
|
+
//#region src/connectionSetupController.ts
|
|
13
|
+
var v = class {
|
|
14
|
+
#e;
|
|
15
|
+
#t;
|
|
16
|
+
#n;
|
|
17
|
+
#r = /* @__PURE__ */ new Set();
|
|
18
|
+
#i;
|
|
19
|
+
#a = {
|
|
20
|
+
status: "idle",
|
|
21
|
+
data: void 0,
|
|
22
|
+
error: void 0
|
|
23
|
+
};
|
|
24
|
+
#o = 0;
|
|
25
|
+
#s;
|
|
26
|
+
handle;
|
|
27
|
+
constructor(e, t, n) {
|
|
28
|
+
this.#e = e, this.#t = t, this.#n = n, this.handle = f(e, { capture: () => this.#f() });
|
|
29
|
+
}
|
|
30
|
+
getSnapshot = () => this.#a;
|
|
31
|
+
subscribe = (e) => (this.#r.add(e), () => {
|
|
32
|
+
this.#r.delete(e);
|
|
33
|
+
});
|
|
34
|
+
clear = (e = !1) => {
|
|
35
|
+
let t = this.#i;
|
|
36
|
+
this.#i = void 0, this.#s = void 0, t?.detachSubject?.(), t?.controller.abort(e ? c : void 0), this.#h({
|
|
37
|
+
status: "idle",
|
|
38
|
+
data: void 0,
|
|
39
|
+
error: void 0
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
async activate(e, t) {
|
|
43
|
+
this.clear(!0);
|
|
44
|
+
let n = new AbortController(), r = {
|
|
45
|
+
input: e,
|
|
46
|
+
key: p(),
|
|
47
|
+
controller: n,
|
|
48
|
+
subject: void 0,
|
|
49
|
+
detachSubject: void 0,
|
|
50
|
+
prerequisite: new o(n.signal, this.#c(this.#n()).options.replayWindowMs),
|
|
51
|
+
established: !1
|
|
52
|
+
};
|
|
53
|
+
this.#i = r, this.#h({
|
|
54
|
+
status: "pending",
|
|
55
|
+
data: void 0,
|
|
56
|
+
error: void 0
|
|
57
|
+
});
|
|
58
|
+
try {
|
|
59
|
+
let e = await t(), n = await this.#p(r, e.runtime, e.client);
|
|
60
|
+
return this.#l(r), r.prerequisite.assertCurrent(e.runtime, n), r.established = !0, n.output;
|
|
61
|
+
} catch (e) {
|
|
62
|
+
throw this.#i === r && (this.clear(), this.#h({
|
|
63
|
+
status: "error",
|
|
64
|
+
data: void 0,
|
|
65
|
+
error: e
|
|
66
|
+
})), e;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
watch(e) {
|
|
70
|
+
let t = r(e.runtime), n = () => {
|
|
71
|
+
let n = this.#i;
|
|
72
|
+
if (n === void 0 || !n.established || this.#n().runtime !== e.runtime) return;
|
|
73
|
+
if (n.subject !== this.#c(e).subjectSignal) {
|
|
74
|
+
this.clear();
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
let r = t?.getSnapshot();
|
|
78
|
+
(r === void 0 || r !== this.#s || this.#a.status !== "ready") && (this.#s = void 0, this.#h({
|
|
79
|
+
status: "pending",
|
|
80
|
+
data: void 0,
|
|
81
|
+
error: void 0
|
|
82
|
+
}), r !== void 0 && this.#p(n, e.runtime, e.client).catch(() => {}));
|
|
83
|
+
};
|
|
84
|
+
return n(), t?.subscribe(n) ?? (() => {});
|
|
85
|
+
}
|
|
86
|
+
#c(e) {
|
|
87
|
+
return e.recovery ?? n(e.errorBus, this.#e);
|
|
88
|
+
}
|
|
89
|
+
#l(e) {
|
|
90
|
+
if (this.#i !== e || e.controller.signal.aborted) throw new s(l(e.controller.signal));
|
|
91
|
+
}
|
|
92
|
+
#u(e, t, n) {
|
|
93
|
+
this.#l(e);
|
|
94
|
+
let r = this.#n();
|
|
95
|
+
if (e.subject !== void 0 && e.subject !== this.#c(r).subjectSignal) throw new s("inactive");
|
|
96
|
+
if (r.runtime !== t || r.client !== n) throw new s("connection-changed");
|
|
97
|
+
return r;
|
|
98
|
+
}
|
|
99
|
+
#d(e, t) {
|
|
100
|
+
if (e.subject !== void 0) return;
|
|
101
|
+
let n = this.#c(t).subjectSignal;
|
|
102
|
+
e.subject = n;
|
|
103
|
+
let r = () => {
|
|
104
|
+
this.#i === e && this.clear();
|
|
105
|
+
};
|
|
106
|
+
n.addEventListener("abort", r, { once: !0 }), e.detachSubject = () => n.removeEventListener("abort", r), n.aborted && r();
|
|
107
|
+
}
|
|
108
|
+
#f() {
|
|
109
|
+
let e = this.#i;
|
|
110
|
+
if (e === void 0) throw new s("inactive");
|
|
111
|
+
return { prepare: async (t, n) => {
|
|
112
|
+
let r = await this.#p(e, t, n);
|
|
113
|
+
return { run: (i) => e.prerequisite.run(t, r, g.try({
|
|
114
|
+
try: () => this.#u(e, t, n),
|
|
115
|
+
catch: (e) => e
|
|
116
|
+
}).pipe(g.andThen(i))) };
|
|
117
|
+
} };
|
|
118
|
+
}
|
|
119
|
+
async #p(e, t, n) {
|
|
120
|
+
let i = this.#u(e, t, n), o = i.descriptors[this.#t];
|
|
121
|
+
if (o?.kind !== "mutation" || o.idempotencyScope !== "connection") throw Error(`Voltro: useConnectionSetup("${this.#t}") requires a mutation declaring idempotencyScope: 'connection'`);
|
|
122
|
+
this.#d(e, i), this.#l(e);
|
|
123
|
+
let c = r(t);
|
|
124
|
+
if (c === void 0) throw new s("connection-unavailable");
|
|
125
|
+
if (c.getSnapshot() === void 0) {
|
|
126
|
+
let n = g.callback((t) => {
|
|
127
|
+
let n = () => {
|
|
128
|
+
let n = c.getSnapshot();
|
|
129
|
+
e.controller.signal.aborted ? t(g.fail(new s(l(e.controller.signal)))) : n !== void 0 && t(g.succeed(n));
|
|
130
|
+
}, r = c.subscribe(n);
|
|
131
|
+
return e.controller.signal.addEventListener("abort", n, { once: !0 }), n(), g.sync(() => {
|
|
132
|
+
r(), e.controller.signal.removeEventListener("abort", n);
|
|
133
|
+
});
|
|
134
|
+
}).pipe(g.timeoutOrElse({
|
|
135
|
+
duration: this.#c(i).options.replayWindowMs,
|
|
136
|
+
orElse: () => g.fail(new s("timeout"))
|
|
137
|
+
}));
|
|
138
|
+
await a(t, n);
|
|
139
|
+
}
|
|
140
|
+
this.#u(e, t, n);
|
|
141
|
+
let u = c.getSnapshot();
|
|
142
|
+
try {
|
|
143
|
+
let r = await e.prerequisite.prepare(t, this.#m(e, i));
|
|
144
|
+
return this.#u(e, t, n), this.#s = r.lease, this.#h({
|
|
145
|
+
status: "ready",
|
|
146
|
+
data: r.output,
|
|
147
|
+
error: void 0
|
|
148
|
+
}), this.#u(e, t, n), e.prerequisite.assertCurrent(t, r), r;
|
|
149
|
+
} catch (n) {
|
|
150
|
+
throw this.#i === e && this.#n().runtime === t && c.getSnapshot() === u && this.#h({
|
|
151
|
+
status: "error",
|
|
152
|
+
data: void 0,
|
|
153
|
+
error: n
|
|
154
|
+
}), n;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
#m(n, r) {
|
|
158
|
+
return g.suspend(() => {
|
|
159
|
+
let a = `setup_${n.key}_${++this.#o}`;
|
|
160
|
+
return d({
|
|
161
|
+
id: a,
|
|
162
|
+
apiName: this.#e,
|
|
163
|
+
tag: this.#t,
|
|
164
|
+
input: n.input
|
|
165
|
+
}), g.suspend(() => {
|
|
166
|
+
this.#u(n, r.runtime, r.client);
|
|
167
|
+
let e = i(r.client, this.#t);
|
|
168
|
+
return m(e(n.input), n.key);
|
|
169
|
+
}).pipe(g.withSpan(`client.connectionSetup.${this.#t}`)).pipe(g.onExit((n) => g.sync(() => {
|
|
170
|
+
if (_.isSuccess(n)) u(a, {
|
|
171
|
+
status: "success",
|
|
172
|
+
output: n.value
|
|
173
|
+
}), r.errorBus.emitSuccess({
|
|
174
|
+
source: "mutation",
|
|
175
|
+
tag: this.#t
|
|
176
|
+
});
|
|
177
|
+
else {
|
|
178
|
+
let i = e(n.cause);
|
|
179
|
+
if (u(a, {
|
|
180
|
+
status: "error",
|
|
181
|
+
error: i
|
|
182
|
+
}), !h.hasInterruptsOnly(n.cause)) {
|
|
183
|
+
let e = t(i, "handler");
|
|
184
|
+
r.errorBus.emit({
|
|
185
|
+
source: "mutation",
|
|
186
|
+
tag: this.#t,
|
|
187
|
+
error: i,
|
|
188
|
+
kind: e,
|
|
189
|
+
outcome: e === "transport" ? "unknown" : "known"
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
})));
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
#h(e) {
|
|
197
|
+
if (this.#a.status !== e.status || this.#a.data !== e.data || this.#a.error !== e.error) {
|
|
198
|
+
this.#a = e;
|
|
199
|
+
for (let e of this.#r) try {
|
|
200
|
+
e();
|
|
201
|
+
} catch {}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
//#endregion
|
|
206
|
+
export { v as ConnectionSetupController };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { useSubscription as e } from "./useSubscription.js";
|
|
2
|
+
import { useMutation as t } from "./useMutation.js";
|
|
3
|
+
import { useAction as n } from "./useAction.js";
|
|
4
|
+
import { useFormBinding as r } from "./useFormBinding.js";
|
|
5
|
+
import { useConnectionSetup as i } from "./useConnectionSetup.js";
|
|
6
|
+
//#region src/createHooks.ts
|
|
7
|
+
var a = e, o = (e) => ({
|
|
8
|
+
useSubscription: (t, n, r) => a(e, t, n, r),
|
|
9
|
+
useMutation: (n) => t(e, n),
|
|
10
|
+
useConnectionSetup: (t) => i(e, t),
|
|
11
|
+
useAction: (t) => n(e, t),
|
|
12
|
+
useFormBinding: (t, n) => r(e, t, n ?? {})
|
|
13
|
+
});
|
|
14
|
+
//#endregion
|
|
15
|
+
export { o as createHooks };
|
package/dist/deepLink.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
//#region src/deepLink.ts
|
|
2
|
+
var e = (e) => {
|
|
3
|
+
let t = e.pattern;
|
|
4
|
+
if (t.length === 0 || t[0] !== "/") throw Error(`defineDeepLink: pattern must start with "/" (got "${t}")`);
|
|
5
|
+
return {
|
|
6
|
+
_tag: "VoltroDeepLink",
|
|
7
|
+
pattern: t,
|
|
8
|
+
handler: e.handler
|
|
9
|
+
};
|
|
10
|
+
}, t = (e) => {
|
|
11
|
+
let t = e, n = /^([a-zA-Z][a-zA-Z0-9+.-]*):\/\//.exec(t);
|
|
12
|
+
if (n) {
|
|
13
|
+
let e = t.slice(n[0].length), r = n[1].toLowerCase();
|
|
14
|
+
if (r === "http" || r === "https") {
|
|
15
|
+
let n = e.indexOf("/");
|
|
16
|
+
t = n === -1 ? "/" : e.slice(n);
|
|
17
|
+
} else t = `/${e}`;
|
|
18
|
+
}
|
|
19
|
+
let r = t.search(/[?#]/);
|
|
20
|
+
r !== -1 && (t = t.slice(0, r));
|
|
21
|
+
let i = [];
|
|
22
|
+
for (let e of t.split("/")) if (e.length !== 0) try {
|
|
23
|
+
i.push(decodeURIComponent(e));
|
|
24
|
+
} catch {
|
|
25
|
+
i.push(e);
|
|
26
|
+
}
|
|
27
|
+
return i;
|
|
28
|
+
}, n = (e, n) => {
|
|
29
|
+
let r = t(e), i = t(n);
|
|
30
|
+
if (r.length !== i.length) return null;
|
|
31
|
+
let a = {};
|
|
32
|
+
for (let e = 0; e < r.length; e++) {
|
|
33
|
+
let t = r[e], n = i[e];
|
|
34
|
+
if (t.startsWith(":")) {
|
|
35
|
+
let e = t.slice(1);
|
|
36
|
+
if (e.length === 0) return null;
|
|
37
|
+
a[e] = n;
|
|
38
|
+
} else if (t !== "*" && t !== n) return null;
|
|
39
|
+
}
|
|
40
|
+
return a;
|
|
41
|
+
}, r = (e, t) => {
|
|
42
|
+
let r = n(e.pattern, t);
|
|
43
|
+
return r === null ? null : (e.handler(r), r);
|
|
44
|
+
}, i = (e, t) => {
|
|
45
|
+
let n = "", r = !0;
|
|
46
|
+
for (let i of e.split("/")) if (r || (n += "/"), r = !1, !i.startsWith(":")) n += i;
|
|
47
|
+
else {
|
|
48
|
+
let r = i.slice(1), a = t[r];
|
|
49
|
+
if (a === void 0) throw Error(`deepLinkHref: pattern "${e}" needs a ":${r}" param`);
|
|
50
|
+
n += encodeURIComponent(a);
|
|
51
|
+
}
|
|
52
|
+
return n.length === 0 ? "/" : n;
|
|
53
|
+
}, a = (e, t) => {
|
|
54
|
+
for (let r of e) {
|
|
55
|
+
let e = n(r.pattern, t);
|
|
56
|
+
if (e !== null) return {
|
|
57
|
+
descriptor: r,
|
|
58
|
+
params: e
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
return null;
|
|
62
|
+
}, o = (e, t) => {
|
|
63
|
+
let n = a(e, t);
|
|
64
|
+
if (n === null) return null;
|
|
65
|
+
let r = n.descriptor.handler;
|
|
66
|
+
return r(n.params), n.params;
|
|
67
|
+
};
|
|
68
|
+
//#endregion
|
|
69
|
+
export { i as deepLinkHref, e as defineDeepLink, o as dispatchDeepLink, n as matchDeepLink, a as matchFirstDeepLink, r as runDeepLink };
|
package/dist/filters.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { useFrameworkApi as e } from "./runtimeContext.js";
|
|
2
|
+
import { useSubscription as t } from "./useSubscription.js";
|
|
3
|
+
import { schemaToFields as n } from "./schemaFields.js";
|
|
4
|
+
import { useCallback as r, useMemo as i, useState as a } from "react";
|
|
5
|
+
//#region src/filters.ts
|
|
6
|
+
var o = (e) => {
|
|
7
|
+
switch (e) {
|
|
8
|
+
case "select":
|
|
9
|
+
case "radio":
|
|
10
|
+
case "async-select": return "select";
|
|
11
|
+
case "multi-select": return "multi-select";
|
|
12
|
+
case "text":
|
|
13
|
+
case "textarea": return "text";
|
|
14
|
+
case "number": return "number-range";
|
|
15
|
+
case "date":
|
|
16
|
+
case "datetime":
|
|
17
|
+
case "daterange": return "date-range";
|
|
18
|
+
case "checkbox":
|
|
19
|
+
case "switch": return "boolean";
|
|
20
|
+
default: return null;
|
|
21
|
+
}
|
|
22
|
+
}, s = (e) => {
|
|
23
|
+
let t = [];
|
|
24
|
+
for (let r of n(e)) {
|
|
25
|
+
if (r.name.includes(".")) continue;
|
|
26
|
+
let e = o(r.widget);
|
|
27
|
+
e !== null && t.push({
|
|
28
|
+
name: r.name,
|
|
29
|
+
label: r.label,
|
|
30
|
+
kind: e,
|
|
31
|
+
...r.options ? { options: r.options } : {}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
return t;
|
|
35
|
+
}, c = (e) => {
|
|
36
|
+
let t = {};
|
|
37
|
+
for (let [n, r] of Object.entries(e)) r === void 0 || r === "" || Array.isArray(r) && r.length === 0 || (t[n] = r);
|
|
38
|
+
return t;
|
|
39
|
+
}, l = (n, o, l = {}) => {
|
|
40
|
+
let u = e(n).descriptors[o]?.input, d = i(() => u === void 0 ? [] : s(u), [u]), [f, p] = a(l.initial ?? {}), m = r((e, t) => {
|
|
41
|
+
p((n) => c({
|
|
42
|
+
...n,
|
|
43
|
+
[e]: t
|
|
44
|
+
}));
|
|
45
|
+
}, []), h = r(() => p({}), []), g = i(() => c(f), [f]), _ = t(n, o, g);
|
|
46
|
+
return {
|
|
47
|
+
filters: d,
|
|
48
|
+
values: f,
|
|
49
|
+
setFilter: m,
|
|
50
|
+
clear: h,
|
|
51
|
+
rows: _.data ?? [],
|
|
52
|
+
count: _.data?.length,
|
|
53
|
+
loading: _.data === void 0,
|
|
54
|
+
error: _.error
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
//#endregion
|
|
58
|
+
export { s as filtersFromSchema, l as useQueryFilters };
|
package/dist/form.js
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { formField as e, formSections as t, schemaToColumns as n, schemaToFields as r } from "./schemaFields.js";
|
|
2
|
+
import { decodeFieldIssues as i, documentLocale as a, resolveValidationMessage as o, restrictToSchema as s, validateFields as c } from "./formBinding.js";
|
|
3
|
+
import { FORM_FLASH_SCRIPT_ID as l } from "./formFlashId.js";
|
|
4
|
+
import { FORM_KEY_FIELD as u, FORM_PATH_PREFIX as d, FORM_REDIRECT_FIELD as f, formActionPath as p, formDataToInput as m } from "./formData.js";
|
|
5
|
+
export { l as FORM_FLASH_SCRIPT_ID, u as FORM_KEY_FIELD, d as FORM_PATH_PREFIX, f as FORM_REDIRECT_FIELD, i as decodeFieldIssues, a as documentLocale, p as formActionPath, m as formDataToInput, e as formField, t as formSections, o as resolveValidationMessage, s as restrictToSchema, n as schemaToColumns, r as schemaToFields, c as validateFields };
|