@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
package/dist/platform.js
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { browserStoreStorage as e, setStoreStorage as t } from "./storeStorage.js";
|
|
2
|
+
import { browserOnlineSource as n } from "./onlineSource.js";
|
|
3
|
+
import { useSyncExternalStore as r } from "react";
|
|
4
|
+
//#region src/platform.ts
|
|
5
|
+
var i = (e, t = {}) => {
|
|
6
|
+
let n = e.platform.shell !== "browser" && e.platform.shell !== "node" && e.platform.shell !== "test";
|
|
7
|
+
return {
|
|
8
|
+
offlineStart: e.platform.installed || n,
|
|
9
|
+
secureTokenStorage: e.secureStorage.kind !== "none",
|
|
10
|
+
push: e.notifications?.pushToken !== void 0,
|
|
11
|
+
localNotifications: e.notifications?.show !== void 0,
|
|
12
|
+
updates: e.updates !== void 0,
|
|
13
|
+
deepLinks: !0,
|
|
14
|
+
biometrics: e.biometrics !== void 0,
|
|
15
|
+
backgroundSync: e.platform.shell === "tauri" || e.platform.shell === "electron",
|
|
16
|
+
installPrompt: e.platform.shell === "browser" && !e.platform.installed,
|
|
17
|
+
...t
|
|
18
|
+
};
|
|
19
|
+
}, a = (e) => {
|
|
20
|
+
let { capabilities: t, ...n } = e;
|
|
21
|
+
return {
|
|
22
|
+
...n,
|
|
23
|
+
capabilities: i(n, t)
|
|
24
|
+
};
|
|
25
|
+
}, o = (e) => ({
|
|
26
|
+
kind: "none",
|
|
27
|
+
get: async () => null,
|
|
28
|
+
set: async () => {
|
|
29
|
+
throw Error(`secureStorage: ${e}`);
|
|
30
|
+
},
|
|
31
|
+
delete: async () => {}
|
|
32
|
+
}), s = () => {
|
|
33
|
+
let e = /* @__PURE__ */ new Map();
|
|
34
|
+
return {
|
|
35
|
+
kind: "memory",
|
|
36
|
+
get: async (t) => e.get(t) ?? null,
|
|
37
|
+
set: async (t, n) => {
|
|
38
|
+
e.set(t, n);
|
|
39
|
+
},
|
|
40
|
+
delete: async (t) => {
|
|
41
|
+
e.delete(t);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}, c = {
|
|
45
|
+
read: () => typeof document > "u" ? "active" : document.visibilityState === "hidden" ? "background" : "active",
|
|
46
|
+
subscribe: (e) => {
|
|
47
|
+
if (typeof document > "u") return () => {};
|
|
48
|
+
let t = () => e(document.visibilityState === "hidden" ? "background" : "active");
|
|
49
|
+
return document.addEventListener("visibilitychange", t), () => document.removeEventListener("visibilitychange", t);
|
|
50
|
+
}
|
|
51
|
+
}, l = {
|
|
52
|
+
initialUrl: async () => typeof location > "u" ? null : location.href,
|
|
53
|
+
subscribe: () => () => {}
|
|
54
|
+
}, u = () => {
|
|
55
|
+
if (typeof Notification > "u") return;
|
|
56
|
+
let e = (e) => e === "granted" ? "granted" : e === "denied" ? "denied" : "prompt";
|
|
57
|
+
return {
|
|
58
|
+
permission: async () => e(Notification.permission),
|
|
59
|
+
requestPermission: async () => e(await Notification.requestPermission()),
|
|
60
|
+
show: async (e) => {
|
|
61
|
+
new Notification(e.title, {
|
|
62
|
+
...e.body === void 0 ? {} : { body: e.body },
|
|
63
|
+
...e.data === void 0 ? {} : { data: e.data }
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
}, d = () => {
|
|
68
|
+
if (typeof window > "u") return !1;
|
|
69
|
+
let e = window.matchMedia;
|
|
70
|
+
return typeof e == "function" && e.call(window, "(display-mode: standalone)").matches ? !0 : navigator.standalone === !0;
|
|
71
|
+
}, f = (e, t) => {
|
|
72
|
+
let n = globalThis.WebSocket;
|
|
73
|
+
if (n === void 0) throw Error("platform: no global WebSocket in this environment");
|
|
74
|
+
let r = typeof t == "object" && !Array.isArray(t) ? void 0 : t;
|
|
75
|
+
return r === void 0 ? new n(e) : new n(e, r);
|
|
76
|
+
}, p = (t = {}) => {
|
|
77
|
+
let r = typeof window < "u", i = d(), s = r ? navigator.userAgent : "", p = r ? /jsdom/i.test(s) ? "test" : "browser" : "node", m = u();
|
|
78
|
+
return a({
|
|
79
|
+
platform: {
|
|
80
|
+
kind: i ? "pwa" : "web",
|
|
81
|
+
shell: p,
|
|
82
|
+
installed: i
|
|
83
|
+
},
|
|
84
|
+
webSocket: f,
|
|
85
|
+
storage: e,
|
|
86
|
+
secureStorage: o("a browser tab has no secure store a page can read; the session is an HttpOnly cookie the server sets"),
|
|
87
|
+
online: n,
|
|
88
|
+
lifecycle: c,
|
|
89
|
+
links: l,
|
|
90
|
+
...m === void 0 ? {} : { notifications: m },
|
|
91
|
+
clock: { now: () => Date.now() },
|
|
92
|
+
...t
|
|
93
|
+
});
|
|
94
|
+
}, m = Symbol.for("@voltro/client/platform"), h = () => {
|
|
95
|
+
let e = globalThis, t = e[m];
|
|
96
|
+
if (t !== void 0) return t;
|
|
97
|
+
let n = {
|
|
98
|
+
adapter: void 0,
|
|
99
|
+
fallback: void 0,
|
|
100
|
+
listeners: /* @__PURE__ */ new Set()
|
|
101
|
+
};
|
|
102
|
+
return e[m] = n, n;
|
|
103
|
+
}, g = (e) => {
|
|
104
|
+
let n = h();
|
|
105
|
+
n.adapter = e, t(e.storage);
|
|
106
|
+
for (let e of n.listeners) e();
|
|
107
|
+
}, _ = () => {
|
|
108
|
+
let e = h();
|
|
109
|
+
return e.adapter === void 0 ? (e.fallback === void 0 && (e.fallback = p()), e.fallback) : e.adapter;
|
|
110
|
+
}, v = () => h().adapter !== void 0, y = () => {
|
|
111
|
+
let e = h();
|
|
112
|
+
e.adapter = void 0, e.fallback = void 0, t(null);
|
|
113
|
+
for (let t of e.listeners) t();
|
|
114
|
+
}, b = (e) => {
|
|
115
|
+
let t = h();
|
|
116
|
+
return t.listeners.add(e), () => {
|
|
117
|
+
t.listeners.delete(e);
|
|
118
|
+
};
|
|
119
|
+
}, x = () => r(b, _, _), S = (e) => x().extensions?.[e] ?? null;
|
|
120
|
+
//#endregion
|
|
121
|
+
export { p as browserPlatform, i as capabilitiesOf, _ as currentPlatform, a as definePlatform, g as installPlatform, v as isPlatformInstalled, d as isStandaloneDisplay, s as memoryTokenStore, o as refusingTokenStore, y as resetPlatformForTest, x as usePlatform, S as useShellExtension };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { stableKey as e } from "./stableKey.js";
|
|
2
|
+
import { seedResolvers as t } from "./seedResolvers.js";
|
|
3
|
+
//#region src/preloadSeed.ts
|
|
4
|
+
var n = () => ({ seeds: [] }), r = (e) => {
|
|
5
|
+
t.preload = e;
|
|
6
|
+
}, i = /* @__PURE__ */ new Map(), a = (e, t) => `${e}\u0000${t}`, o = (n, r, i, a) => {
|
|
7
|
+
let o = t.preload?.() ?? null;
|
|
8
|
+
if (o === null) throw Error(`seedPreloadedSubscription('${n}', '${r}') was called outside a server render. Preload seeds exist to put a subscription's first value into the SSR hydration payload; on the client the live subscription already provides it. (If this IS server code, the render did not install a seed bag — that is a framework bug.)`);
|
|
9
|
+
o.seeds.push({
|
|
10
|
+
api: n,
|
|
11
|
+
key: e([r, i]),
|
|
12
|
+
value: a
|
|
13
|
+
});
|
|
14
|
+
}, s = (n, r, i) => {
|
|
15
|
+
let a = t.preload?.() ?? null;
|
|
16
|
+
a !== null && a.seeds.push({
|
|
17
|
+
api: n,
|
|
18
|
+
key: e([r, i]),
|
|
19
|
+
value: void 0,
|
|
20
|
+
failed: !0
|
|
21
|
+
});
|
|
22
|
+
}, c = (e) => {
|
|
23
|
+
if (e !== void 0) for (let t of e) i.set(a(t.api, t.key), {
|
|
24
|
+
value: t.value,
|
|
25
|
+
failed: t.failed === !0
|
|
26
|
+
});
|
|
27
|
+
}, l = (n, r, o) => {
|
|
28
|
+
let s = e([r, o]), c = t.preload?.() ?? null;
|
|
29
|
+
if (c !== null) {
|
|
30
|
+
for (let e of c.seeds) if (e.api === n && e.key === s) return e.failed === !0 ? void 0 : e.value;
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
let l = i.get(a(n, s));
|
|
34
|
+
return l === void 0 || l.failed ? void 0 : l.value;
|
|
35
|
+
}, u = (n, r, o) => {
|
|
36
|
+
let s = e([r, o]), c = t.preload?.() ?? null;
|
|
37
|
+
if (c !== null) {
|
|
38
|
+
for (let e of c.seeds) if (e.api === n && e.key === s) return e.failed === !0 ? "failed" : "seeded";
|
|
39
|
+
return "absent";
|
|
40
|
+
}
|
|
41
|
+
let l = i.get(a(n, s));
|
|
42
|
+
return l === void 0 ? "absent" : l.failed ? "failed" : "seeded";
|
|
43
|
+
}, d = () => {
|
|
44
|
+
i.clear();
|
|
45
|
+
};
|
|
46
|
+
//#endregion
|
|
47
|
+
export { c as applyPreloadSeeds, n as makePreloadSeedBag, u as readPreloadedSeedOutcome, l as readPreloadedSnapshot, d as resetPreloadSeeds, o as seedPreloadedSubscription, s as seedPreloadedSubscriptionFailure, r as setPreloadSeedResolver };
|
package/dist/provider.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { FrameworkRuntimesContext as e, unknownApiError as t } from "./frameworkRuntimesContext.js";
|
|
2
|
+
import { useMemo as n } from "react";
|
|
3
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
4
|
+
//#region src/provider.tsx
|
|
5
|
+
var i = ({ apis: i, children: a, demand: o, queryOnce: s }) => {
|
|
6
|
+
let c = n(() => ({
|
|
7
|
+
get: (e) => {
|
|
8
|
+
let n = i.get(e);
|
|
9
|
+
if (!n) throw t(e, i.keys());
|
|
10
|
+
return n;
|
|
11
|
+
},
|
|
12
|
+
names: Array.from(i.keys()),
|
|
13
|
+
...o === void 0 ? {} : { demand: o },
|
|
14
|
+
...s === void 0 ? {} : { queryOnce: s }
|
|
15
|
+
}), [i]);
|
|
16
|
+
return /* @__PURE__ */ r(e.Provider, {
|
|
17
|
+
value: c,
|
|
18
|
+
children: a
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
//#endregion
|
|
22
|
+
export { i as FrameworkRuntimesProvider };
|
package/dist/query.js
CHANGED
|
@@ -1,2 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { resolveByTag as e } from "./tagWalk.js";
|
|
2
|
+
import { runRpcPromise as t } from "./runRpc.js";
|
|
3
|
+
import { awaitResolvedApi as n } from "./awaitResolvedApi.js";
|
|
4
|
+
import { Effect as r, Option as i, Stream as a } from "effect";
|
|
5
|
+
import { firstEventValue as o } from "@voltro/protocol";
|
|
6
|
+
//#region src/queryOnce.ts
|
|
7
|
+
var s = async (s, c, l, u, d) => {
|
|
8
|
+
let { runtime: f, client: p } = await n(s, c, l), m = e(p, l)(u ?? {}), h = r.isEffect(m) ? m : a.runHead(m).pipe(r.map(i.getOrUndefined)), g = await t(f, h, { signal: d });
|
|
9
|
+
return o(l, g, "[loader.query]");
|
|
10
|
+
};
|
|
11
|
+
//#endregion
|
|
12
|
+
export { s as queryOnce };
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { recordClientDiagnostic as e } from "./clientDiagnostics.js";
|
|
2
|
+
import { notifyApiTransportChanged as t, registerApiTransport as n } from "./apiConnectivity.js";
|
|
3
|
+
import { resolveRecoveryRetry as r } from "./recoveryRetry.js";
|
|
4
|
+
//#region src/recoveryCoordinator.ts
|
|
5
|
+
var i = (e, t, n, r) => e === void 0 || !Number.isFinite(e) ? t : Math.min(r, Math.max(n, Math.trunc(e))), a = (e) => ({
|
|
6
|
+
graceMs: i(e?.graceMs, 1500, 0, 3e4),
|
|
7
|
+
retry: r(e?.retry),
|
|
8
|
+
maxPendingMutations: i(e?.maxPendingMutations, 32, 0, 256),
|
|
9
|
+
replayWindowMs: i(e?.replayWindowMs, 1e4, 250, 6e4),
|
|
10
|
+
capabilitiesUrl: e?.capabilitiesUrl
|
|
11
|
+
}), o = Object.freeze({
|
|
12
|
+
rawTransport: "connected",
|
|
13
|
+
status: "connected",
|
|
14
|
+
failureCount: 0,
|
|
15
|
+
lastFailureAt: void 0,
|
|
16
|
+
failedSubscriptions: Object.freeze([]),
|
|
17
|
+
pendingMutationReplays: 0,
|
|
18
|
+
mutationReplay: "unknown"
|
|
19
|
+
}), s = class {
|
|
20
|
+
#e;
|
|
21
|
+
#t;
|
|
22
|
+
#n;
|
|
23
|
+
#r = /* @__PURE__ */ new Set();
|
|
24
|
+
#i = /* @__PURE__ */ new Set();
|
|
25
|
+
#a = /* @__PURE__ */ new Set();
|
|
26
|
+
#o = /* @__PURE__ */ new Set();
|
|
27
|
+
#s = /* @__PURE__ */ new Set();
|
|
28
|
+
#c = "connected";
|
|
29
|
+
#l = "connected";
|
|
30
|
+
#u = 0;
|
|
31
|
+
#d;
|
|
32
|
+
#f = 0;
|
|
33
|
+
#p = "unknown";
|
|
34
|
+
#m = -1;
|
|
35
|
+
#h = 0;
|
|
36
|
+
#g = !0;
|
|
37
|
+
#_ = new AbortController();
|
|
38
|
+
#v;
|
|
39
|
+
#y;
|
|
40
|
+
#b = !1;
|
|
41
|
+
#x;
|
|
42
|
+
#S;
|
|
43
|
+
constructor(e, t, r) {
|
|
44
|
+
this.#e = e, this.#t = a(t), this.#n = {
|
|
45
|
+
now: r?.now ?? Date.now,
|
|
46
|
+
setTimeout: r?.setTimeout ?? ((e, t) => setTimeout(e, t)),
|
|
47
|
+
clearTimeout: r?.clearTimeout ?? ((e) => clearTimeout(e))
|
|
48
|
+
}, this.#x = this.#C(), this.#S = n(e, () => this.#c === "connected");
|
|
49
|
+
}
|
|
50
|
+
get options() {
|
|
51
|
+
return this.#t;
|
|
52
|
+
}
|
|
53
|
+
get subjectSignal() {
|
|
54
|
+
return this.#_.signal;
|
|
55
|
+
}
|
|
56
|
+
getPreloadSeedPermission = () => this.#g;
|
|
57
|
+
invalidatePreloadSeeds() {
|
|
58
|
+
this.#g && (this.#g = !1, this.#w());
|
|
59
|
+
}
|
|
60
|
+
getSnapshot = () => this.#x;
|
|
61
|
+
getServerSnapshot = () => o;
|
|
62
|
+
subscribe = (e) => (this.#r.add(e), () => {
|
|
63
|
+
this.#r.delete(e);
|
|
64
|
+
});
|
|
65
|
+
onVisibleError(e) {
|
|
66
|
+
return this.#i.add(e), () => {
|
|
67
|
+
this.#i.delete(e);
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
#C() {
|
|
71
|
+
return {
|
|
72
|
+
rawTransport: this.#c,
|
|
73
|
+
status: this.#l,
|
|
74
|
+
failureCount: this.#u,
|
|
75
|
+
lastFailureAt: this.#d,
|
|
76
|
+
failedSubscriptions: [...this.#s].sort(),
|
|
77
|
+
pendingMutationReplays: this.#f,
|
|
78
|
+
mutationReplay: this.#p
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
#w() {
|
|
82
|
+
let n = this.#x.rawTransport !== this.#c;
|
|
83
|
+
this.#x = this.#C();
|
|
84
|
+
for (let e of this.#r) try {
|
|
85
|
+
e();
|
|
86
|
+
} catch {}
|
|
87
|
+
n && t(), e(this.#e, "recovery.state", {
|
|
88
|
+
rawTransport: this.#x.rawTransport,
|
|
89
|
+
status: this.#x.status,
|
|
90
|
+
failureCount: this.#x.failureCount,
|
|
91
|
+
failedSubscriptions: this.#x.failedSubscriptions.length,
|
|
92
|
+
pendingMutationReplays: this.#x.pendingMutationReplays,
|
|
93
|
+
mutationReplay: this.#x.mutationReplay
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
#T(e) {
|
|
97
|
+
for (let t of this.#i) try {
|
|
98
|
+
t(e);
|
|
99
|
+
} catch {}
|
|
100
|
+
}
|
|
101
|
+
#E() {
|
|
102
|
+
this.#l === "connected" && (this.#l = this.#t.graceMs === 0 ? "degraded" : "recovering", this.#t.graceMs === 0 ? this.#y !== void 0 && (this.#b = !0, this.#T(this.#y)) : this.#v = this.#n.setTimeout(() => {
|
|
103
|
+
this.#v = void 0, this.#l === "recovering" && (this.#l = "degraded", this.#y !== void 0 && (this.#b = !0, this.#T(this.#y)), this.#w());
|
|
104
|
+
}, this.#t.graceMs));
|
|
105
|
+
}
|
|
106
|
+
#D() {
|
|
107
|
+
this.#c !== "connected" || this.#s.size > 0 || (this.#v !== void 0 && (this.#n.clearTimeout(this.#v), this.#v = void 0), this.#l = "connected", this.#u = 0, this.#y = void 0, this.#b = !1);
|
|
108
|
+
}
|
|
109
|
+
transportIssue() {
|
|
110
|
+
this.#c = "disconnected", this.#u += 1, this.#d = this.#n.now(), this.#E(), this.#w();
|
|
111
|
+
}
|
|
112
|
+
protocolReady() {
|
|
113
|
+
this.#c = "connected";
|
|
114
|
+
for (let e of this.#a) e();
|
|
115
|
+
this.#a.clear(), this.#D(), this.#w();
|
|
116
|
+
}
|
|
117
|
+
observeError(e) {
|
|
118
|
+
(e.kind !== "transport" || e.affectsTransport !== !1) && (e.kind === "transport" ? (this.#y === void 0 && (this.#y = e), e.source === "subscription" && this.#s.add(e.tag), this.#c !== "disconnected" && (this.#c = "disconnected", this.#u += 1, this.#d = this.#n.now()), this.#E(), this.#l === "degraded" && !this.#b && (this.#b = !0, this.#T(e)), this.#w()) : this.#T(e));
|
|
119
|
+
}
|
|
120
|
+
observeSuccess(e) {
|
|
121
|
+
e.source === "subscription" && this.#s.delete(e.tag), this.#D(), this.#w();
|
|
122
|
+
}
|
|
123
|
+
reportExternalSuccess() {
|
|
124
|
+
this.#c = "connected";
|
|
125
|
+
for (let e of this.#a) e();
|
|
126
|
+
this.#a.clear(), this.#D(), this.#w();
|
|
127
|
+
}
|
|
128
|
+
resetForSubjectChange(e = 0) {
|
|
129
|
+
this.#v !== void 0 && this.#n.clearTimeout(this.#v), this.#v = void 0, this.#c = "disconnected", this.#l = "connected", this.#u = 0, this.#d = void 0, this.#s.clear(), this.#y = void 0, this.#b = !1, this.#p = "unknown", this.#h += 1, this.#g = !1;
|
|
130
|
+
let t = this.#_;
|
|
131
|
+
this.#_ = new AbortController(), t.abort(), this.#m = e;
|
|
132
|
+
for (let e of this.#o) e(!1);
|
|
133
|
+
this.#o.clear();
|
|
134
|
+
for (let e of this.#a) e();
|
|
135
|
+
this.#a.clear(), this.#E(), this.#w();
|
|
136
|
+
}
|
|
137
|
+
setMutationReplaySupported(e, t = 0) {
|
|
138
|
+
if (!(t < this.#m)) {
|
|
139
|
+
this.#m = t, this.#p = e ? "enabled" : "disabled";
|
|
140
|
+
for (let t of this.#o) t(e);
|
|
141
|
+
this.#o.clear(), this.#w();
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
replayWindowRemaining(e) {
|
|
145
|
+
return Math.max(0, this.#t.replayWindowMs - (this.#n.now() - e));
|
|
146
|
+
}
|
|
147
|
+
waitForMutationReplaySupport(e) {
|
|
148
|
+
if (this.#p !== "unknown") return Promise.resolve(this.#p === "enabled");
|
|
149
|
+
let t = this.#t.replayWindowMs - (this.#n.now() - e);
|
|
150
|
+
return t <= 0 ? Promise.resolve(!1) : new Promise((e) => {
|
|
151
|
+
let n = !1, r, i = (t) => {
|
|
152
|
+
n || (n = !0, this.#o.delete(i), r !== void 0 && this.#n.clearTimeout(r), e(t));
|
|
153
|
+
};
|
|
154
|
+
this.#o.add(i), r = this.#n.setTimeout(() => i(!1), t);
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
reserveMutationReplay(e) {
|
|
158
|
+
if (this.#p === "disabled" || this.#n.now() - e > this.#t.replayWindowMs || this.#f >= this.#t.maxPendingMutations) return;
|
|
159
|
+
this.#f += 1, this.#w();
|
|
160
|
+
let t = this.#h, n = !1;
|
|
161
|
+
return {
|
|
162
|
+
isValid: () => !n && t === this.#h && this.#p === "enabled" && this.#c === "connected" && this.#n.now() - e <= this.#t.replayWindowMs,
|
|
163
|
+
release: () => {
|
|
164
|
+
n || (n = !0, --this.#f, this.#w());
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
waitForProtocolReady(e, t) {
|
|
169
|
+
if (t?.aborted) return Promise.resolve(!1);
|
|
170
|
+
if (this.#c === "connected") return Promise.resolve(!0);
|
|
171
|
+
let n = this.#t.replayWindowMs - (this.#n.now() - e);
|
|
172
|
+
return n <= 0 ? Promise.resolve(!1) : new Promise((e) => {
|
|
173
|
+
let r = !1, i = (n) => {
|
|
174
|
+
r || (r = !0, this.#a.delete(a), this.#n.clearTimeout(s), t?.removeEventListener("abort", o), e(n && this.#c === "connected"));
|
|
175
|
+
}, a = () => i(!0), o = () => i(!1);
|
|
176
|
+
this.#a.add(a);
|
|
177
|
+
let s = this.#n.setTimeout(() => i(!1), n);
|
|
178
|
+
t?.addEventListener("abort", o, { once: !0 }), t?.aborted && o();
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
dispose() {
|
|
182
|
+
this.#S(), this.#_.abort(), this.#v !== void 0 && this.#n.clearTimeout(this.#v), this.#v = void 0;
|
|
183
|
+
for (let e of this.#a) e();
|
|
184
|
+
this.#a.clear();
|
|
185
|
+
for (let e of this.#o) e(!1);
|
|
186
|
+
this.#o.clear(), this.#r.clear(), this.#i.clear();
|
|
187
|
+
}
|
|
188
|
+
}, c = /* @__PURE__ */ new WeakMap(), l = (e, t, n) => {
|
|
189
|
+
let r = c.get(e);
|
|
190
|
+
if (r !== void 0) return r;
|
|
191
|
+
let i = new s(t, n);
|
|
192
|
+
return e.on((e) => i.observeError(e)), typeof e.onSuccess == "function" && e.onSuccess((e) => i.observeSuccess(e)), c.set(e, i), i;
|
|
193
|
+
};
|
|
194
|
+
//#endregion
|
|
195
|
+
export { o as INITIAL_RECOVERY_SNAPSHOT, s as RecoveryCoordinator, l as recoveryCoordinatorFor, a as resolveRecoveryOptions };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Effect as e, Schedule as t } from "effect";
|
|
2
|
+
//#region src/recoveryRetry.ts
|
|
3
|
+
var n = (e, t, n, r) => Math.min(r, Math.max(n, e === void 0 || !Number.isFinite(e) ? t : e)), r = (e) => {
|
|
4
|
+
let t = Math.trunc(n(e?.maxMs, 5e3, 50, 6e4));
|
|
5
|
+
return {
|
|
6
|
+
initialMs: Math.trunc(n(e?.initialMs, 0, 0, t)),
|
|
7
|
+
thenMs: Math.trunc(n(e?.thenMs, 500, 50, t)),
|
|
8
|
+
factor: n(e?.factor, 1.5, 1, 10),
|
|
9
|
+
maxMs: t
|
|
10
|
+
};
|
|
11
|
+
}, i = (e, t) => t <= 1 ? e.initialMs : Math.min(e.maxMs, e.thenMs * e.factor ** (t - 2)), a = (n, r) => {
|
|
12
|
+
let a = 0;
|
|
13
|
+
return {
|
|
14
|
+
reset: () => {
|
|
15
|
+
a = 0;
|
|
16
|
+
},
|
|
17
|
+
schedule: t.forever.pipe(t.addDelay(() => e.sync(() => {
|
|
18
|
+
let e = i(n, ++a);
|
|
19
|
+
return r(a, e), e;
|
|
20
|
+
})))
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
//#endregion
|
|
24
|
+
export { a as makeRecoveryRetry, i as recoveryRetryDelay, r as resolveRecoveryRetry };
|
package/dist/richText.js
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { formField as e } from "./schemaFields.js";
|
|
2
|
+
import { Schema as t } from "effect";
|
|
3
|
+
//#region src/richText.ts
|
|
4
|
+
var n = [
|
|
5
|
+
"bold",
|
|
6
|
+
"italic",
|
|
7
|
+
"code",
|
|
8
|
+
"strike"
|
|
9
|
+
], r = 5e3, i = (e) => {
|
|
10
|
+
let t = "";
|
|
11
|
+
for (let n of e) {
|
|
12
|
+
let e = n.codePointAt(0) ?? 0;
|
|
13
|
+
if (e > 32 && e !== 127 && (t += n, t.length >= 8 || t === "#" || t.startsWith("/") && t.length >= 2)) break;
|
|
14
|
+
}
|
|
15
|
+
return t.toLowerCase();
|
|
16
|
+
}, a = (e) => {
|
|
17
|
+
let t = i(e);
|
|
18
|
+
return t.length === 0 ? !1 : t.startsWith("#") || t.startsWith("/") ? !t.startsWith("//") : t.startsWith("https://") || t.startsWith("http://") || t.startsWith("mailto:");
|
|
19
|
+
}, o = t.String.pipe(t.check(t.makeFilter((e) => a(e) || "href must be http(s), mailto:, a #fragment or a /path"))), s = t.Struct({
|
|
20
|
+
type: t.Literal("text"),
|
|
21
|
+
text: t.String,
|
|
22
|
+
marks: t.optional(t.Array(t.Literals(n)))
|
|
23
|
+
}), c = t.Struct({
|
|
24
|
+
type: t.Literal("link"),
|
|
25
|
+
href: o,
|
|
26
|
+
content: t.Array(s)
|
|
27
|
+
}), l = t.Union([s, c]), u = t.Struct({
|
|
28
|
+
type: t.Literal("listItem"),
|
|
29
|
+
content: t.Array(l)
|
|
30
|
+
}), d = t.Union([
|
|
31
|
+
t.Struct({
|
|
32
|
+
type: t.Literal("paragraph"),
|
|
33
|
+
content: t.Array(l)
|
|
34
|
+
}),
|
|
35
|
+
t.Struct({
|
|
36
|
+
type: t.Literal("heading"),
|
|
37
|
+
level: t.Literals([
|
|
38
|
+
1,
|
|
39
|
+
2,
|
|
40
|
+
3
|
|
41
|
+
]),
|
|
42
|
+
content: t.Array(l)
|
|
43
|
+
}),
|
|
44
|
+
t.Struct({
|
|
45
|
+
type: t.Literal("blockquote"),
|
|
46
|
+
content: t.Array(l)
|
|
47
|
+
}),
|
|
48
|
+
t.Struct({
|
|
49
|
+
type: t.Literal("bulletList"),
|
|
50
|
+
content: t.Array(u)
|
|
51
|
+
}),
|
|
52
|
+
t.Struct({
|
|
53
|
+
type: t.Literal("orderedList"),
|
|
54
|
+
content: t.Array(u)
|
|
55
|
+
}),
|
|
56
|
+
t.Struct({
|
|
57
|
+
type: t.Literal("codeBlock"),
|
|
58
|
+
text: t.String
|
|
59
|
+
})
|
|
60
|
+
]), f = (e) => {
|
|
61
|
+
let t = 1, n = (e) => {
|
|
62
|
+
for (let r of e) {
|
|
63
|
+
if (t += 1, t > 5e3) return;
|
|
64
|
+
let e = r.content;
|
|
65
|
+
if (Array.isArray(e) && n(e), t > 5e3) return;
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
return n(e.content), t;
|
|
69
|
+
}, p = t.Struct({
|
|
70
|
+
type: t.Literal("doc"),
|
|
71
|
+
content: t.Array(d)
|
|
72
|
+
}).pipe(t.check(t.makeFilter((e) => f(e) <= 5e3 || "rich text document exceeds 5000 nodes")), t.annotate(e({ widget: "rich-text" }))), m = {
|
|
73
|
+
type: "doc",
|
|
74
|
+
content: []
|
|
75
|
+
}, h = (e) => typeof e == "object" && !!e && e.type === "doc" && Array.isArray(e.content), g = /(\*\*([^*]+)\*\*)|(~~([^~]+)~~)|(\*([^*]+)\*)|(`([^`]+)`)|(\[([^\]]*)\]\(([^)\s]+)\))/, _ = (e, t) => t && t.length > 0 ? {
|
|
76
|
+
type: "text",
|
|
77
|
+
text: e,
|
|
78
|
+
marks: t
|
|
79
|
+
} : {
|
|
80
|
+
type: "text",
|
|
81
|
+
text: e
|
|
82
|
+
}, v = (e) => {
|
|
83
|
+
let t = [], n = e;
|
|
84
|
+
for (;;) {
|
|
85
|
+
let e = g.exec(n);
|
|
86
|
+
if (e === null || e.index === void 0) break;
|
|
87
|
+
e.index > 0 && t.push(_(n.slice(0, e.index))), e[2] === void 0 ? e[4] === void 0 ? e[6] === void 0 ? e[8] === void 0 ? e[11] !== void 0 && (a(e[11]) ? t.push({
|
|
88
|
+
type: "link",
|
|
89
|
+
href: e[11],
|
|
90
|
+
content: [{
|
|
91
|
+
type: "text",
|
|
92
|
+
text: e[10] ?? ""
|
|
93
|
+
}]
|
|
94
|
+
}) : t.push(_(e[0]))) : t.push(_(e[8], ["code"])) : t.push(_(e[6], ["italic"])) : t.push(_(e[4], ["strike"])) : t.push(_(e[2], ["bold"])), n = n.slice(e.index + e[0].length);
|
|
95
|
+
}
|
|
96
|
+
return n.length > 0 && t.push(_(n)), t;
|
|
97
|
+
}, y = (e, t) => e.map((e) => ({
|
|
98
|
+
type: "listItem",
|
|
99
|
+
content: v(e.replace(t, ""))
|
|
100
|
+
})), b = (e) => {
|
|
101
|
+
if (e.length === 0) return null;
|
|
102
|
+
let t = e[0];
|
|
103
|
+
if (t.startsWith("```")) {
|
|
104
|
+
let t = "", n = !1;
|
|
105
|
+
for (let r of e) r.startsWith("```") || (n && (t += "\n"), t += r, n = !0);
|
|
106
|
+
return {
|
|
107
|
+
type: "codeBlock",
|
|
108
|
+
text: t
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
let n = /^(#{1,3})\s+(.*)$/.exec(t);
|
|
112
|
+
if (n !== null) return {
|
|
113
|
+
type: "heading",
|
|
114
|
+
level: n[1].length,
|
|
115
|
+
content: v(n[2])
|
|
116
|
+
};
|
|
117
|
+
if (e.every((e) => /^[-*]\s+/.test(e))) return {
|
|
118
|
+
type: "bulletList",
|
|
119
|
+
content: y(e, /^[-*]\s+/)
|
|
120
|
+
};
|
|
121
|
+
if (e.every((e) => /^\d+\.\s+/.test(e))) return {
|
|
122
|
+
type: "orderedList",
|
|
123
|
+
content: y(e, /^\d+\.\s+/)
|
|
124
|
+
};
|
|
125
|
+
if (e.every((e) => e.startsWith(">"))) {
|
|
126
|
+
for (let t = 0; t < e.length; t++) e[t] = e[t].replace(/^>\s?/, "");
|
|
127
|
+
return {
|
|
128
|
+
type: "blockquote",
|
|
129
|
+
content: v(e.join(" "))
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
return {
|
|
133
|
+
type: "paragraph",
|
|
134
|
+
content: v(e.join(" "))
|
|
135
|
+
};
|
|
136
|
+
}, x = (e) => {
|
|
137
|
+
let t = [], n = [], r = () => {
|
|
138
|
+
let e = b(n);
|
|
139
|
+
e !== null && t.push(e), n = [];
|
|
140
|
+
};
|
|
141
|
+
for (let t of e.replace(/\r\n/g, "\n").split("\n")) t.trim() === "" ? r() : n.push(t);
|
|
142
|
+
return r(), {
|
|
143
|
+
type: "doc",
|
|
144
|
+
content: t
|
|
145
|
+
};
|
|
146
|
+
}, S = (e) => e.map((e) => {
|
|
147
|
+
if (e.type === "link") return `[${e.content.map((e) => e.text).join("")}](${e.href})`;
|
|
148
|
+
let t = e.marks ?? [];
|
|
149
|
+
return t.includes("bold") ? `**${e.text}**` : t.includes("strike") ? `~~${e.text}~~` : t.includes("italic") ? `*${e.text}*` : t.includes("code") ? `\`${e.text}\`` : e.text;
|
|
150
|
+
}).join(""), C = (e) => h(e) ? e.content.map((e) => {
|
|
151
|
+
switch (e.type) {
|
|
152
|
+
case "heading": return `${"#".repeat(e.level)} ${S(e.content)}`;
|
|
153
|
+
case "bulletList": return e.content.map((e) => `- ${S(e.content)}`).join("\n");
|
|
154
|
+
case "orderedList": return e.content.map((e, t) => `${t + 1}. ${S(e.content)}`).join("\n");
|
|
155
|
+
case "blockquote": return `> ${S(e.content)}`;
|
|
156
|
+
case "codeBlock": return [
|
|
157
|
+
"```",
|
|
158
|
+
e.text,
|
|
159
|
+
"```"
|
|
160
|
+
].join("\n");
|
|
161
|
+
default: return S(e.content);
|
|
162
|
+
}
|
|
163
|
+
}).join("\n\n") : "", w = (e) => {
|
|
164
|
+
if (!h(e)) return "";
|
|
165
|
+
let t = (e) => e.map((e) => e.type === "link" ? e.content.map((e) => e.text).join("") : e.text).join("");
|
|
166
|
+
return e.content.map((e) => {
|
|
167
|
+
switch (e.type) {
|
|
168
|
+
case "bulletList":
|
|
169
|
+
case "orderedList": return e.content.map((e) => t(e.content)).join("\n");
|
|
170
|
+
case "codeBlock": return e.text;
|
|
171
|
+
default: return t(e.content);
|
|
172
|
+
}
|
|
173
|
+
}).join("\n\n");
|
|
174
|
+
};
|
|
175
|
+
//#endregion
|
|
176
|
+
export { n as RICH_TEXT_MARKS, r as RICH_TEXT_MAX_NODES, p as RichTextDocument, m as emptyRichTextDocument, h as isRichTextDocument, a as isSafeHref, x as parseRichText, w as richTextToPlainText, C as serializeRichText };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { publishClientError as e } from "./clientErrorBus.js";
|
|
2
|
+
//#region src/rpcErrorBus.ts
|
|
3
|
+
var t = class {
|
|
4
|
+
#e = /* @__PURE__ */ new Set();
|
|
5
|
+
#t = /* @__PURE__ */ new Set();
|
|
6
|
+
on(e) {
|
|
7
|
+
return this.#e.add(e), () => {
|
|
8
|
+
this.#e.delete(e);
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
emit(t) {
|
|
12
|
+
for (let e of this.#e) try {
|
|
13
|
+
e(t);
|
|
14
|
+
} catch {}
|
|
15
|
+
e({
|
|
16
|
+
error: t.error,
|
|
17
|
+
source: `rpc.${t.source}`,
|
|
18
|
+
context: {
|
|
19
|
+
rpcTag: t.tag,
|
|
20
|
+
rpcErrorKind: t.kind,
|
|
21
|
+
...t.affectsTransport === void 0 ? {} : { affectsTransport: t.affectsTransport },
|
|
22
|
+
...t.outcome === void 0 ? {} : { rpcCallOutcome: t.outcome },
|
|
23
|
+
...t.traceId === void 0 ? {} : { traceId: t.traceId }
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
onSuccess(e) {
|
|
28
|
+
return this.#t.add(e), () => {
|
|
29
|
+
this.#t.delete(e);
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
emitSuccess(e) {
|
|
33
|
+
for (let t of this.#t) try {
|
|
34
|
+
t(e);
|
|
35
|
+
} catch {}
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
//#endregion
|
|
39
|
+
export { t as RpcErrorBus };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region src/rpcErrorKind.ts
|
|
2
|
+
var e = /* @__PURE__ */ new WeakMap(), t = (t, n) => ((typeof t == "object" && t || typeof t == "function") && e.set(t, n), t), n = (t, n) => {
|
|
3
|
+
if ((typeof t != "object" || !t) && typeof t != "function") return n;
|
|
4
|
+
let r = e.get(t);
|
|
5
|
+
if (r !== void 0) return r;
|
|
6
|
+
try {
|
|
7
|
+
return t._tag === "RpcClientError" ? "transport" : n;
|
|
8
|
+
} catch {
|
|
9
|
+
return n;
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
//#endregion
|
|
13
|
+
export { t as rememberRpcErrorKind, n as rpcErrorKind };
|
package/dist/runRpc.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { squashRpcCause as e } from "./squashRpcCause.js";
|
|
2
|
+
import { rememberRpcErrorKind as t, rpcErrorKind as n } from "./rpcErrorKind.js";
|
|
3
|
+
import { Cause as r, Exit as i, Option as a } from "effect";
|
|
4
|
+
//#region src/runRpc.ts
|
|
5
|
+
var o = async (o, s, c) => {
|
|
6
|
+
let l = await o.runPromiseExit(s, c?.signal === void 0 ? void 0 : { signal: c.signal });
|
|
7
|
+
if (i.isSuccess(l)) return l.value;
|
|
8
|
+
let u = e(l.cause), d = r.findErrorOption(l.cause), f = a.isSome(d) ? n(d.value, "handler") : "unknown";
|
|
9
|
+
throw t(u, f);
|
|
10
|
+
};
|
|
11
|
+
//#endregion
|
|
12
|
+
export { o as runRpcPromise };
|