@voltro/client 0.86.0 → 0.88.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 +5484 -0
- package/THIRD-PARTY-NOTICES.md +6 -230
- package/dist/analyticsCatalog.js +1 -2
- package/dist/apiConnectivity.js +1 -2
- package/dist/apiRoleTransports.js +47 -0
- package/dist/apiRuntime.js +76 -67
- package/dist/apiSocketTracker.js +20 -0
- package/dist/apiSupervisor.js +17 -7
- package/dist/authRefresh.js +1 -2
- package/dist/awaitResolvedApi.js +5 -6
- package/dist/bootstrap.d.ts +9 -0
- package/dist/bootstrap.js +3 -3
- package/dist/cellMerger.js +1 -2
- package/dist/clientDiagnostics.js +1 -2
- package/dist/clientErrorBus.js +1 -2
- package/dist/clientScheduler.js +1 -2
- package/dist/connectionPrerequisite.js +1 -2
- package/dist/connectionScope.js +15 -4
- package/dist/connectionSetupController.js +1 -2
- package/dist/createHooks.js +1 -2
- package/dist/deepLink.js +1 -2
- package/dist/filters.js +1 -2
- package/dist/form.d.ts +37 -4
- package/dist/form.js +4 -2
- package/dist/formBinding.js +1 -2
- package/dist/formData.js +73 -12
- package/dist/formFlashId.js +1 -2
- package/dist/formRejection.js +22 -0
- package/dist/formSource.js +12 -0
- package/dist/frameworkRuntimesContext.js +1 -2
- package/dist/globalContext.js +1 -2
- package/dist/index.d.ts +99 -20
- package/dist/index.js +57 -54
- package/dist/liveRowSort.js +1 -2
- package/dist/mutationConnectionSetup.js +1 -2
- package/dist/mutationIdentity.js +1 -2
- package/dist/mutationSerialExecution.js +1 -2
- package/dist/mutationsBus.js +1 -2
- package/dist/onlineSource.js +1 -2
- package/dist/outbox.js +1 -2
- package/dist/outboxHttp.js +1 -2
- package/dist/outboxState.js +1 -2
- package/dist/permissions.js +1 -2
- package/dist/platform.js +1 -2
- package/dist/preloadSeed.js +1 -2
- package/dist/provider.js +1 -2
- package/dist/query.js +1 -2
- package/dist/recoveryCoordinator.js +1 -2
- package/dist/recoveryRetry.js +1 -2
- package/dist/richText.js +1 -2
- package/dist/rpcErrorBus.js +1 -2
- package/dist/rpcErrorKind.js +1 -2
- package/dist/runRpc.js +1 -2
- package/dist/runtime.d.ts +17 -2
- package/dist/runtimeCapabilities.js +1 -2
- package/dist/runtimeContext.js +1 -2
- package/dist/schemaFields.js +1 -2
- package/dist/scopeMembership.js +1 -2
- package/dist/seedResolvers.js +1 -2
- package/dist/sequence.js +1 -2
- package/dist/serverRequest.js +12 -9
- package/dist/serviceClient.js +50 -50
- package/dist/squashRpcCause.js +1 -2
- package/dist/stableKey.js +1 -2
- package/dist/store.js +1 -2
- package/dist/storeStorage.js +1 -2
- package/dist/subscriptionCache.js +5 -6
- package/dist/tagWalk.js +1 -2
- package/dist/traceBus.js +1 -2
- package/dist/tracking.js +1 -2
- package/dist/uploadProgress.js +1 -2
- package/dist/useAction.js +1 -2
- package/dist/useAgent.js +1 -2
- package/dist/useAgentChat.js +1 -2
- package/dist/useAgentStream.js +1 -2
- package/dist/useApiOnline.js +1 -2
- package/dist/useCapabilityManifest.js +28 -25
- package/dist/useConnectionSetup.js +1 -2
- package/dist/useConnectionStatus.js +1 -2
- package/dist/useConnections.js +1 -2
- package/dist/useDataCopilot.js +1 -2
- package/dist/useDataTable.js +1 -2
- package/dist/useDerived.js +1 -2
- package/dist/useEvent.js +78 -69
- package/dist/useFormBinding.js +227 -226
- package/dist/useLocalQuery.js +1 -2
- package/dist/useMutation.js +1 -2
- package/dist/useOnRpcError.js +1 -2
- package/dist/usePreloadedSubscription.js +1 -2
- package/dist/usePreview.js +1 -2
- package/dist/useProvenance.js +1 -2
- package/dist/useQueryField.js +1 -2
- package/dist/useRecord.js +1 -2
- package/dist/useRefreshSubscriptions.js +1 -2
- package/dist/useResourceCan.js +1 -2
- package/dist/useResumableAgentStream.js +1 -2
- package/dist/useRpcCaller.js +16 -0
- package/dist/useSequence.js +1 -2
- package/dist/useSkeleton.js +1 -2
- package/dist/useSubscription.js +56 -48
- package/dist/useSubscriptionHealth.js +1 -2
- package/dist/useTranscription.js +1 -2
- package/dist/useUndo.js +1 -2
- package/dist/useUndoLog.js +1 -2
- package/dist/useUpload.js +1 -2
- package/dist/useWindowedSubscription.js +1 -2
- package/dist/useWorkflow.js +1 -2
- package/dist/useWorkflowRunState.js +1 -2
- package/dist/validation.js +1 -2
- package/dist/validationMessages.js +1 -2
- package/package.json +4 -4
package/dist/awaitResolvedApi.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { isUnresolvedApi as e } from "./frameworkRuntimesContext.js";
|
|
2
2
|
import { ConnectionPrerequisiteInvalidated as t } from "./connectionPrerequisite.js";
|
|
3
|
-
|
|
4
|
-
var n = 15e3, r = async (t, r, i) => {
|
|
5
|
-
if (!e(t.current)) return t.current;
|
|
6
|
-
let
|
|
7
|
-
for (; Date.now() <
|
|
3
|
+
// src/awaitResolvedApi.ts
|
|
4
|
+
var n = 15e3, r = async (t, r, i, a) => {
|
|
5
|
+
if (a?.throwIfAborted(), !e(t.current)) return t.current;
|
|
6
|
+
let o = Date.now() + n;
|
|
7
|
+
for (; Date.now() < o;) if (await new Promise((e) => setTimeout(e, 16)), a?.throwIfAborted(), !e(t.current)) return t.current;
|
|
8
8
|
throw Error(`Voltro: the api "${r}" did not resolve within ${n}ms, so ${i} was never sent. This is not the boot window — that is waited out. Check that "${r}" is a configured api name and that its client could connect.`);
|
|
9
9
|
}, i = async (n, i, a) => {
|
|
10
10
|
let o = e(n.current) ? void 0 : n.current.recovery, s = o?.subjectSignal, c = await r(n, i, a), l = c.recovery;
|
|
@@ -19,5 +19,4 @@ var n = 15e3, r = async (t, r, i) => {
|
|
|
19
19
|
if (l.getSnapshot().rawTransport === "connected") return c;
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
|
-
//#endregion
|
|
23
22
|
export { n as RESOLVE_TIMEOUT_MS, i as awaitReadyApi, r as awaitResolvedApi };
|
package/dist/bootstrap.d.ts
CHANGED
|
@@ -37,6 +37,8 @@ export declare interface ApiHandle {
|
|
|
37
37
|
readonly errorBus: RpcErrorBus;
|
|
38
38
|
/** Stable UI/raw transport recovery state for this logical api. */
|
|
39
39
|
readonly recovery?: RecoveryCoordinator;
|
|
40
|
+
/** Identity lifetime captured when this transport was built. */
|
|
41
|
+
readonly subjectSignal?: AbortSignal;
|
|
40
42
|
}
|
|
41
43
|
|
|
42
44
|
/**
|
|
@@ -262,6 +264,11 @@ declare interface FormFlashPayload {
|
|
|
262
264
|
readonly errors: Readonly<Record<string, string>>;
|
|
263
265
|
/** A non-field error (the RPC refused after valid input: guard, server). */
|
|
264
266
|
readonly formError?: string;
|
|
267
|
+
/** JSON encoded through the procedure's declared error schema. Private to
|
|
268
|
+
* this failed submit; never a publication or permission proof. */
|
|
269
|
+
readonly rejection?: unknown;
|
|
270
|
+
/** Admitted original page for repeated native errors and late hydration. */
|
|
271
|
+
readonly sourcePath?: string;
|
|
265
272
|
}
|
|
266
273
|
|
|
267
274
|
export declare interface FrameworkRuntimes {
|
|
@@ -716,6 +723,8 @@ declare interface ServerRequestContextValue {
|
|
|
716
723
|
* would add a fiber fork the client boot does not have, and every
|
|
717
724
|
* ancestor arity difference shifts every useId in the app. */
|
|
718
725
|
readonly formFlash?: FormFlashPayload;
|
|
726
|
+
/** Public captured build/class selection, never a credential or write permit. */
|
|
727
|
+
readonly formSource?: string;
|
|
719
728
|
}
|
|
720
729
|
|
|
721
730
|
declare type ShellKind = 'browser' | 'expo' | 'tauri' | 'electron' | 'node' | 'test';
|
package/dist/bootstrap.js
CHANGED
|
@@ -3,6 +3,6 @@ import { FrameworkRuntimesContext as t } from "./frameworkRuntimesContext.js";
|
|
|
3
3
|
import { FrameworkRuntimesProvider as n } from "./provider.js";
|
|
4
4
|
import { applyStoreSeeds as r } from "./store.js";
|
|
5
5
|
import { browserPlatform as i, currentPlatform as a, installPlatform as o, isPlatformInstalled as s, usePlatform as c } from "./platform.js";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
export { t as FrameworkRuntimesContext, n as FrameworkRuntimesProvider,
|
|
6
|
+
import { useServerRequest as l } from "./serverRequest.js";
|
|
7
|
+
import { applyPreloadSeeds as u } from "./preloadSeed.js";
|
|
8
|
+
export { t as FrameworkRuntimesContext, n as FrameworkRuntimesProvider, u as applyPreloadSeeds, r as applyStoreSeeds, i as browserPlatform, a as currentPlatform, e as globalContext, o as installPlatform, s as isPlatformInstalled, c as usePlatform, l as useServerRequest };
|
package/dist/cellMerger.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/clientDiagnostics.ts
|
|
2
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
3
|
sessionStartedAt: Date.now(),
|
|
4
4
|
monotonicStartedAt: r(),
|
|
@@ -90,5 +90,4 @@ var e = "voltro.client-diagnostics.v1", t = Symbol.for("@voltro/client/diagnosti
|
|
|
90
90
|
}, h = (e) => (i.listeners.add(e), () => {
|
|
91
91
|
i.listeners.delete(e);
|
|
92
92
|
});
|
|
93
|
-
//#endregion
|
|
94
93
|
export { m as clearClientDiagnostics, p as clientDiagnosticsSnapshot, d as disableClientDiagnosticsPersistence, u as enableClientDiagnosticsPersistence, f as recordClientDiagnostic, h as subscribeClientDiagnostics };
|
package/dist/clientErrorBus.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/clientErrorBus.ts
|
|
2
2
|
var e = /* @__PURE__ */ new Set(), t = (t) => {
|
|
3
3
|
for (let n of e) try {
|
|
4
4
|
n(t);
|
|
@@ -12,5 +12,4 @@ var e = /* @__PURE__ */ new Set(), t = (t) => {
|
|
|
12
12
|
...n ? { context: n } : {}
|
|
13
13
|
});
|
|
14
14
|
};
|
|
15
|
-
//#endregion
|
|
16
15
|
export { t as publishClientError, r as reportClientError, n as subscribeClientErrors };
|
package/dist/clientScheduler.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MutableList as e, Scheduler as t } from "effect";
|
|
2
|
-
|
|
2
|
+
// src/clientScheduler.ts
|
|
3
3
|
var n = {
|
|
4
4
|
channel: "timer",
|
|
5
5
|
yield: (e) => {
|
|
@@ -27,5 +27,4 @@ var n = {
|
|
|
27
27
|
});
|
|
28
28
|
return Object.assign(n, { yieldChannel: e.channel });
|
|
29
29
|
};
|
|
30
|
-
//#endregion
|
|
31
30
|
export { i as hostMacrotaskYield, a as makeClientScheduler, r as messageChannelYield, n as timerYield };
|
|
@@ -2,7 +2,7 @@ import { rememberRpcErrorKind as e } from "./rpcErrorKind.js";
|
|
|
2
2
|
import { connectionScopeForRuntime as t } from "./connectionScope.js";
|
|
3
3
|
import { runRpcPromise as n } from "./runRpc.js";
|
|
4
4
|
import { Effect as r } from "effect";
|
|
5
|
-
|
|
5
|
+
// src/connectionPrerequisite.ts
|
|
6
6
|
var i = "voltro:connection-setup-superseded", a = (e) => e.reason === "voltro:connection-setup-superseded" ? "superseded" : "inactive", o = class extends Error {
|
|
7
7
|
reason;
|
|
8
8
|
_tag = "ConnectionPrerequisiteInvalidated";
|
|
@@ -66,5 +66,4 @@ var i = "voltro:connection-setup-superseded", a = (e) => e.reason === "voltro:co
|
|
|
66
66
|
return i.pipe(r.andThen(n), r.tap(() => i), r.raceFirst(s));
|
|
67
67
|
}
|
|
68
68
|
};
|
|
69
|
-
//#endregion
|
|
70
69
|
export { s as ConnectionPrerequisite, o as ConnectionPrerequisiteInvalidated, i as SUPERSEDED_BY_LATER_ACTIVATION, a as activationEndReason };
|
package/dist/connectionScope.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/connectionScope.ts
|
|
2
2
|
var e = class {
|
|
3
3
|
#e;
|
|
4
4
|
#t;
|
|
@@ -30,6 +30,17 @@ var e = class {
|
|
|
30
30
|
}
|
|
31
31
|
}, t = /* @__PURE__ */ new WeakMap(), n = (e, n) => {
|
|
32
32
|
t.set(e, n);
|
|
33
|
-
}, r = (e) => t.get(e)
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
}, r = (e) => t.get(e), i = (t) => {
|
|
34
|
+
let n = new e(), r = n.begin(), i = !1, a = () => {
|
|
35
|
+
let e = t.length > 0 && t.every((e) => e.getSnapshot() !== void 0);
|
|
36
|
+
e !== i && (i = e, i ? r.open() : (r.close(), r = n.begin()));
|
|
37
|
+
}, o = t.map((e) => e.subscribe(a));
|
|
38
|
+
return a(), {
|
|
39
|
+
scope: n,
|
|
40
|
+
close: () => {
|
|
41
|
+
for (let e of o) e();
|
|
42
|
+
r.close();
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
export { e as ConnectionScope, i as combineConnectionScopes, r as connectionScopeForRuntime, n as registerConnectionScope };
|
|
@@ -9,7 +9,7 @@ import { settleMutation as u, startMutation as d } from "./mutationsBus.js";
|
|
|
9
9
|
import { createConnectionSetupHandle as f } from "./mutationConnectionSetup.js";
|
|
10
10
|
import { freshIdempotencyKey as p, withIdempotencyKey as m } from "./mutationIdentity.js";
|
|
11
11
|
import { Cause as h, Effect as g, Exit as _ } from "effect";
|
|
12
|
-
|
|
12
|
+
// src/connectionSetupController.ts
|
|
13
13
|
var v = class {
|
|
14
14
|
#e;
|
|
15
15
|
#t;
|
|
@@ -202,5 +202,4 @@ var v = class {
|
|
|
202
202
|
}
|
|
203
203
|
}
|
|
204
204
|
};
|
|
205
|
-
//#endregion
|
|
206
205
|
export { v as ConnectionSetupController };
|
package/dist/createHooks.js
CHANGED
|
@@ -3,7 +3,7 @@ import { useMutation as t } from "./useMutation.js";
|
|
|
3
3
|
import { useAction as n } from "./useAction.js";
|
|
4
4
|
import { useFormBinding as r } from "./useFormBinding.js";
|
|
5
5
|
import { useConnectionSetup as i } from "./useConnectionSetup.js";
|
|
6
|
-
|
|
6
|
+
// src/createHooks.ts
|
|
7
7
|
var a = e, o = (e) => ({
|
|
8
8
|
useSubscription: (t, n, r) => a(e, t, n, r),
|
|
9
9
|
useMutation: (n) => t(e, n),
|
|
@@ -11,5 +11,4 @@ var a = e, o = (e) => ({
|
|
|
11
11
|
useAction: (t) => n(e, t),
|
|
12
12
|
useFormBinding: (t, n) => r(e, t, n ?? {})
|
|
13
13
|
});
|
|
14
|
-
//#endregion
|
|
15
14
|
export { o as createHooks };
|
package/dist/deepLink.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/deepLink.ts
|
|
2
2
|
var e = (e) => {
|
|
3
3
|
let t = e.pattern;
|
|
4
4
|
if (t.length === 0 || t[0] !== "/") throw Error(`defineDeepLink: pattern must start with "/" (got "${t}")`);
|
|
@@ -65,5 +65,4 @@ var e = (e) => {
|
|
|
65
65
|
let r = n.descriptor.handler;
|
|
66
66
|
return r(n.params), n.params;
|
|
67
67
|
};
|
|
68
|
-
//#endregion
|
|
69
68
|
export { i as deepLinkHref, e as defineDeepLink, o as dispatchDeepLink, n as matchDeepLink, a as matchFirstDeepLink, r as runDeepLink };
|
package/dist/filters.js
CHANGED
|
@@ -2,7 +2,7 @@ import { useFrameworkApi as e } from "./runtimeContext.js";
|
|
|
2
2
|
import { useSubscription as t } from "./useSubscription.js";
|
|
3
3
|
import { schemaToFields as n } from "./schemaFields.js";
|
|
4
4
|
import { useCallback as r, useMemo as i, useState as a } from "react";
|
|
5
|
-
|
|
5
|
+
// src/filters.ts
|
|
6
6
|
var o = (e) => {
|
|
7
7
|
switch (e) {
|
|
8
8
|
case "select":
|
|
@@ -54,5 +54,4 @@ var o = (e) => {
|
|
|
54
54
|
error: _.error
|
|
55
55
|
};
|
|
56
56
|
};
|
|
57
|
-
//#endregion
|
|
58
57
|
export { s as filtersFromSchema, l as useQueryFilters };
|
package/dist/form.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import { encodeNativeFormCapture } from '@voltro/protocol';
|
|
2
|
+
import { FORM_CAPTURE_FIELD } from '@voltro/protocol';
|
|
3
|
+
import { FORM_CAPTURE_META_NAME } from '@voltro/protocol';
|
|
4
|
+
import { formCaptureSource } from '@voltro/protocol';
|
|
5
|
+
import { readFormCaptureSource } from '@voltro/protocol';
|
|
1
6
|
import { Schema } from 'effect';
|
|
2
7
|
|
|
3
8
|
/**
|
|
@@ -11,6 +16,13 @@ export declare const decodeFieldIssues: (error: Schema.SchemaError) => ReadonlyA
|
|
|
11
16
|
* outside a browser. Primary subtag only (`de-AT` → `de`). */
|
|
12
17
|
export declare const documentLocale: () => string;
|
|
13
18
|
|
|
19
|
+
/** Encode only a declared public tagged error. Run in the schema's own module graph,
|
|
20
|
+
* including a production SSR bundle. Defects, invalid values, service-dependent
|
|
21
|
+
* codecs and oversized errors contribute no structured form state. */
|
|
22
|
+
export declare const encodeFormRejection: (schema: Schema.Top | undefined, error: unknown) => unknown;
|
|
23
|
+
|
|
24
|
+
export { encodeNativeFormCapture }
|
|
25
|
+
|
|
14
26
|
export declare interface FieldDescriptor {
|
|
15
27
|
/** Property name on the input object. */
|
|
16
28
|
readonly name: string;
|
|
@@ -79,22 +91,27 @@ export declare interface FieldSection {
|
|
|
79
91
|
readonly fields: ReadonlyArray<FieldDescriptor>;
|
|
80
92
|
}
|
|
81
93
|
|
|
94
|
+
export { FORM_CAPTURE_FIELD }
|
|
95
|
+
|
|
96
|
+
export { FORM_CAPTURE_META_NAME }
|
|
97
|
+
|
|
82
98
|
/** DOM id of the JSON script the 422 re-render embeds (survives the
|
|
83
99
|
* `interactive:'none'` strip — it is neither `type="module"` nor `src`). */
|
|
84
100
|
export declare const FORM_FLASH_SCRIPT_ID = "__voltro_form_flash__";
|
|
85
101
|
|
|
86
|
-
/** Hidden field carrying the form's instance key (multi-form pages). */
|
|
87
102
|
export declare const FORM_KEY_FIELD = "__voltro_form";
|
|
88
103
|
|
|
89
|
-
/** URL prefix the web listener mounts the no-JS endpoint under. */
|
|
90
104
|
export declare const FORM_PATH_PREFIX = "/form/";
|
|
91
105
|
|
|
92
|
-
/** Hidden field carrying the declared success-redirect path. */
|
|
93
106
|
export declare const FORM_REDIRECT_FIELD = "__voltro_redirect";
|
|
94
107
|
|
|
95
|
-
/** The
|
|
108
|
+
/** The original page, distinct from an optional success redirect. */
|
|
109
|
+
export declare const FORM_SOURCE_FIELD = "__voltro_source";
|
|
110
|
+
|
|
96
111
|
export declare const formActionPath: (mutationTag: string) => string;
|
|
97
112
|
|
|
113
|
+
export { formCaptureSource }
|
|
114
|
+
|
|
98
115
|
/**
|
|
99
116
|
* Convert posted form entries into the input object the mutation's schema
|
|
100
117
|
* decodes — the shape `validateFields` (and the RPC payload) expects.
|
|
@@ -156,6 +173,11 @@ export declare interface FormFlashPayload {
|
|
|
156
173
|
readonly errors: Readonly<Record<string, string>>;
|
|
157
174
|
/** A non-field error (the RPC refused after valid input: guard, server). */
|
|
158
175
|
readonly formError?: string;
|
|
176
|
+
/** JSON encoded through the procedure's declared error schema. Private to
|
|
177
|
+
* this failed submit; never a publication or permission proof. */
|
|
178
|
+
readonly rejection?: unknown;
|
|
179
|
+
/** Admitted original page for repeated native errors and late hydration. */
|
|
180
|
+
readonly sourcePath?: string;
|
|
159
181
|
}
|
|
160
182
|
|
|
161
183
|
/**
|
|
@@ -166,6 +188,17 @@ export declare interface FormFlashPayload {
|
|
|
166
188
|
*/
|
|
167
189
|
export declare const formSections: (fields: ReadonlyArray<FieldDescriptor>) => ReadonlyArray<FieldSection>;
|
|
168
190
|
|
|
191
|
+
/** Admit a local source page; native form endpoints cannot be their own source. */
|
|
192
|
+
export declare const formSourcePath: (raw: unknown) => string | undefined;
|
|
193
|
+
|
|
194
|
+
export { readFormCaptureSource }
|
|
195
|
+
|
|
196
|
+
/** Recover edits made to one native form before its JavaScript booted.
|
|
197
|
+
* Uses the ordinary native schema mapper; only changed, editable controls
|
|
198
|
+
* replace initial values. Hidden metadata and unrelated forms stay intact.
|
|
199
|
+
* Call once when initializing state, never as a submission or authority check. */
|
|
200
|
+
export declare const recoverNativeFormValues: (schema: Schema.Top, formKey: string, values: Readonly<Record<string, unknown>>) => Readonly<Record<string, unknown>>;
|
|
201
|
+
|
|
169
202
|
/**
|
|
170
203
|
* Render one issue id to display text: app resolver first (its `undefined`
|
|
171
204
|
* falls through), then the built-in catalog for the locale's primary subtag,
|
package/dist/form.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { formField as e, formSections as t, schemaToColumns as n, schemaToFields as r } from "./schemaFields.js";
|
|
2
2
|
import { decodeFieldIssues as i, documentLocale as a, resolveValidationMessage as o, restrictToSchema as s, validateFields as c } from "./formBinding.js";
|
|
3
3
|
import { FORM_FLASH_SCRIPT_ID as l } from "./formFlashId.js";
|
|
4
|
-
import {
|
|
5
|
-
|
|
4
|
+
import { FORM_CAPTURE_FIELD as u, FORM_CAPTURE_META_NAME as d, FORM_KEY_FIELD as f, FORM_PATH_PREFIX as p, FORM_REDIRECT_FIELD as m, FORM_SOURCE_FIELD as h, encodeNativeFormCapture as g, formActionPath as _, formCaptureSource as v, formSourcePath as y, readFormCaptureSource as b } from "./formSource.js";
|
|
5
|
+
import { formDataToInput as x, recoverNativeFormValues as S } from "./formData.js";
|
|
6
|
+
import { encodeFormRejection as C } from "./formRejection.js";
|
|
7
|
+
export { u as FORM_CAPTURE_FIELD, d as FORM_CAPTURE_META_NAME, l as FORM_FLASH_SCRIPT_ID, f as FORM_KEY_FIELD, p as FORM_PATH_PREFIX, m as FORM_REDIRECT_FIELD, h as FORM_SOURCE_FIELD, i as decodeFieldIssues, a as documentLocale, C as encodeFormRejection, g as encodeNativeFormCapture, _ as formActionPath, v as formCaptureSource, x as formDataToInput, e as formField, t as formSections, y as formSourcePath, b as readFormCaptureSource, S as recoverNativeFormValues, o as resolveValidationMessage, s as restrictToSchema, n as schemaToColumns, r as schemaToFields, c as validateFields };
|
package/dist/formBinding.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Schema as e, SchemaIssue as t } from "effect";
|
|
2
2
|
import * as n from "effect/SchemaAST";
|
|
3
|
-
|
|
3
|
+
// src/formBinding.ts
|
|
4
4
|
var r = {
|
|
5
5
|
en: {
|
|
6
6
|
"validation.required": "Required",
|
|
@@ -321,5 +321,4 @@ var r = {
|
|
|
321
321
|
issues: c
|
|
322
322
|
};
|
|
323
323
|
};
|
|
324
|
-
//#endregion
|
|
325
324
|
export { h as decodeFieldIssues, a as documentLocale, o as resolveValidationMessage, _ as restrictToSchema, v as validateFields };
|
package/dist/formData.js
CHANGED
|
@@ -1,27 +1,28 @@
|
|
|
1
1
|
import { schemaToFields as e } from "./schemaFields.js";
|
|
2
2
|
import { parseRichText as t } from "./richText.js";
|
|
3
3
|
import { FORM_FLASH_SCRIPT_ID as n } from "./formFlashId.js";
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
import { FORM_CAPTURE_FIELD as r, FORM_CAPTURE_META_NAME as i, FORM_KEY_FIELD as a, FORM_PATH_PREFIX as o, FORM_REDIRECT_FIELD as s, FORM_SOURCE_FIELD as c, encodeNativeFormCapture as l, formActionPath as u, formCaptureSource as d, formSourcePath as f, readFormCaptureSource as p } from "./formSource.js";
|
|
5
|
+
// src/formData.ts
|
|
6
|
+
var m = (e) => {
|
|
6
7
|
let t = Number(e);
|
|
7
|
-
return Number.
|
|
8
|
-
},
|
|
8
|
+
return Number.isFinite(t) ? t === 0 ? 0 : t : e;
|
|
9
|
+
}, h = (e) => {
|
|
9
10
|
let t = e.jsonSchema.items;
|
|
10
11
|
if (!t || typeof t != "object") return;
|
|
11
12
|
let n = t.type;
|
|
12
13
|
return typeof n == "string" ? n : void 0;
|
|
13
|
-
},
|
|
14
|
+
}, g = (e, n) => {
|
|
14
15
|
switch (e.widget) {
|
|
15
16
|
case "rich-text": return n === "" ? {
|
|
16
17
|
type: "doc",
|
|
17
18
|
content: []
|
|
18
19
|
} : t(n);
|
|
19
|
-
case "number": return n === "" ? void 0 :
|
|
20
|
+
case "number": return n === "" ? void 0 : m(n);
|
|
20
21
|
case "date":
|
|
21
22
|
case "datetime": return n === "" ? void 0 : n;
|
|
22
23
|
default: return n;
|
|
23
24
|
}
|
|
24
|
-
},
|
|
25
|
+
}, _ = (t, n) => {
|
|
25
26
|
let r = /* @__PURE__ */ new Map();
|
|
26
27
|
for (let [e, t] of n) {
|
|
27
28
|
let n = r.get(e);
|
|
@@ -50,16 +51,76 @@ var r = "/form/", i = (e) => `${r}${encodeURIComponent(e)}`, a = "__voltro_form"
|
|
|
50
51
|
continue;
|
|
51
52
|
}
|
|
52
53
|
if (n.widget === "multi-select") {
|
|
53
|
-
let t =
|
|
54
|
-
if (i) for (let e = 0; e < o.length; e += 1) o[e] =
|
|
54
|
+
let t = h(n), r = e ?? [], i = t === "number" || t === "integer", o = r.filter((e) => e !== "");
|
|
55
|
+
if (i) for (let e = 0; e < o.length; e += 1) o[e] = m(o[e]);
|
|
55
56
|
a(n.name, o);
|
|
56
57
|
continue;
|
|
57
58
|
}
|
|
58
59
|
if (e === void 0) continue;
|
|
59
|
-
let t =
|
|
60
|
+
let t = g(n, e[0]);
|
|
60
61
|
t !== void 0 && a(n.name, t);
|
|
61
62
|
}
|
|
62
63
|
return i;
|
|
64
|
+
}, v = (t, n, r) => {
|
|
65
|
+
let i = globalThis.document;
|
|
66
|
+
if (i?.forms === void 0) return r;
|
|
67
|
+
let a = [...i.forms].filter((e) => {
|
|
68
|
+
let t = [...e.elements].filter((e) => e.tagName === "INPUT" && e.name === "__voltro_form");
|
|
69
|
+
return t.length === 1 && t[0].type === "hidden" && t[0].value === n;
|
|
70
|
+
});
|
|
71
|
+
if (a.length !== 1) return r;
|
|
72
|
+
let o = a[0], s = e(t).map((e) => e.name);
|
|
73
|
+
if (s.some((e) => e.split(".").some((e) => [
|
|
74
|
+
"__proto__",
|
|
75
|
+
"prototype",
|
|
76
|
+
"constructor"
|
|
77
|
+
].includes(e)))) return r;
|
|
78
|
+
let c = new Set(s), l = /* @__PURE__ */ new Set();
|
|
79
|
+
for (let e of o.elements) {
|
|
80
|
+
if (![
|
|
81
|
+
"INPUT",
|
|
82
|
+
"TEXTAREA",
|
|
83
|
+
"SELECT"
|
|
84
|
+
].includes(e.tagName) || e.matches(":disabled")) continue;
|
|
85
|
+
let t = e, n = t.name;
|
|
86
|
+
if (n !== void 0 && c.has(n)) {
|
|
87
|
+
if (t.tagName === "INPUT") {
|
|
88
|
+
let e = t;
|
|
89
|
+
if (e.readOnly || [
|
|
90
|
+
"hidden",
|
|
91
|
+
"file",
|
|
92
|
+
"button",
|
|
93
|
+
"submit",
|
|
94
|
+
"reset",
|
|
95
|
+
"image"
|
|
96
|
+
].includes(e.type ?? "")) continue;
|
|
97
|
+
e.type === "checkbox" || e.type === "radio" ? e.checked !== e.defaultChecked && l.add(n) : e.value !== e.defaultValue && l.add(n);
|
|
98
|
+
} else if (t.tagName === "TEXTAREA") {
|
|
99
|
+
let e = t;
|
|
100
|
+
!e.readOnly && e.value !== e.defaultValue && l.add(n);
|
|
101
|
+
} else [...t.options ?? []].some((e) => e.selected !== e.defaultSelected) && l.add(n);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
if (l.size === 0) return r;
|
|
105
|
+
let u = o.ownerDocument.defaultView?.FormData;
|
|
106
|
+
if (u === void 0) return r;
|
|
107
|
+
let d = [];
|
|
108
|
+
for (let [e, t] of new u(o)) typeof t == "string" && d.push([e, t]);
|
|
109
|
+
let f = _(t, d), p = (e, t) => {
|
|
110
|
+
let n = e;
|
|
111
|
+
for (let e of t) {
|
|
112
|
+
if (typeof n != "object" || !n || !Object.hasOwn(n, e)) return;
|
|
113
|
+
n = n[e];
|
|
114
|
+
}
|
|
115
|
+
return n;
|
|
116
|
+
}, m = (e, t, n) => {
|
|
117
|
+
let r = Array.isArray(e) ? [...e] : typeof e == "object" && e ? { ...e } : {}, i = r, a = t[0];
|
|
118
|
+
return i[a] = t.length === 1 ? n : m(i[a], t.slice(1), n), r;
|
|
119
|
+
}, h = r;
|
|
120
|
+
for (let e of l) {
|
|
121
|
+
let t = e.split(".");
|
|
122
|
+
h = m(h, t, p(f, t));
|
|
123
|
+
}
|
|
124
|
+
return h;
|
|
63
125
|
};
|
|
64
|
-
|
|
65
|
-
export { n as FORM_FLASH_SCRIPT_ID, a as FORM_KEY_FIELD, r as FORM_PATH_PREFIX, o as FORM_REDIRECT_FIELD, i as formActionPath, u as formDataToInput };
|
|
126
|
+
export { r as FORM_CAPTURE_FIELD, i as FORM_CAPTURE_META_NAME, n as FORM_FLASH_SCRIPT_ID, a as FORM_KEY_FIELD, o as FORM_PATH_PREFIX, s as FORM_REDIRECT_FIELD, c as FORM_SOURCE_FIELD, l as encodeNativeFormCapture, u as formActionPath, d as formCaptureSource, _ as formDataToInput, f as formSourcePath, p as readFormCaptureSource, v as recoverNativeFormValues };
|
package/dist/formFlashId.js
CHANGED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Schema as e } from "effect";
|
|
2
|
+
import { errorMemberSchema as t, errorTag as n } from "@voltro/protocol";
|
|
3
|
+
// src/formRejection.ts
|
|
4
|
+
var r = 65536, i = (i, a) => {
|
|
5
|
+
if (i !== void 0) try {
|
|
6
|
+
let o = n(a);
|
|
7
|
+
if (o === void 0) return;
|
|
8
|
+
let s = t(i, o);
|
|
9
|
+
if (s === void 0) return;
|
|
10
|
+
let c = e.toCodecJson(s), l = e.encodeUnknownSync(c), u;
|
|
11
|
+
try {
|
|
12
|
+
u = l(a);
|
|
13
|
+
} catch {
|
|
14
|
+
u = l(e.decodeUnknownSync(c)(a));
|
|
15
|
+
}
|
|
16
|
+
let d = JSON.stringify(u);
|
|
17
|
+
return d === void 0 || d.length > r || new TextEncoder().encode(d).byteLength > r ? void 0 : JSON.parse(d);
|
|
18
|
+
} catch {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
export { i as encodeFormRejection };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { FORM_FLASH_SCRIPT_ID as e } from "./formFlashId.js";
|
|
2
|
+
import { FORM_CAPTURE_FIELD as t, FORM_CAPTURE_META_NAME as n, encodeNativeFormCapture as r, formCaptureSource as i, readFormCaptureSource as a } from "@voltro/protocol";
|
|
3
|
+
// src/formSource.ts
|
|
4
|
+
var o = "/form/", s = "__voltro_form", c = "__voltro_redirect", l = "__voltro_source", u = (e) => `${o}${encodeURIComponent(e)}`, d = (e) => {
|
|
5
|
+
if (!(typeof e != "string" || e.length === 0 || e.length > 8192 || !e.startsWith("/") || e.startsWith("//") || /[\\\x00-\x1f\x7f]/.test(e))) try {
|
|
6
|
+
let t = new URL(e, "https://form.invalid");
|
|
7
|
+
return t.origin !== "https://form.invalid" || t.pathname === "/form" || t.pathname.startsWith("/form/") ? void 0 : t.pathname + t.search;
|
|
8
|
+
} catch {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
export { t as FORM_CAPTURE_FIELD, n as FORM_CAPTURE_META_NAME, e as FORM_FLASH_SCRIPT_ID, s as FORM_KEY_FIELD, o as FORM_PATH_PREFIX, c as FORM_REDIRECT_FIELD, l as FORM_SOURCE_FIELD, r as encodeNativeFormCapture, u as formActionPath, i as formCaptureSource, d as formSourcePath, a as readFormCaptureSource };
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { globalContext as e } from "./globalContext.js";
|
|
2
|
-
|
|
2
|
+
// src/frameworkRuntimesContext.ts
|
|
3
3
|
var t = (e, t) => {
|
|
4
4
|
let n = Array.from(t).join(", ") || "(none mounted)";
|
|
5
5
|
return /* @__PURE__ */ Error(`@voltro/client: no api named ${JSON.stringify(e)}. Known apis: ${n}`);
|
|
6
6
|
}, n = e("frameworkRuntimes", null), r = (e) => typeof e.runtime?.runFork != "function";
|
|
7
|
-
//#endregion
|
|
8
7
|
export { n as FrameworkRuntimesContext, r as isUnresolvedApi, t as unknownApiError };
|
package/dist/globalContext.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { createContext as e } from "react";
|
|
2
|
-
|
|
2
|
+
// src/globalContext.ts
|
|
3
3
|
var t = (t, n) => {
|
|
4
4
|
let r = globalThis, i = Symbol.for(`@voltro/web/context:${t}`), a = r[i];
|
|
5
5
|
if (a) return a;
|
|
6
6
|
let o = e(n);
|
|
7
7
|
return r[i] = o, o;
|
|
8
8
|
};
|
|
9
|
-
//#endregion
|
|
10
9
|
export { t as globalContext };
|