@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.
Files changed (111) hide show
  1. package/CHANGELOG.md +5484 -0
  2. package/THIRD-PARTY-NOTICES.md +6 -230
  3. package/dist/analyticsCatalog.js +1 -2
  4. package/dist/apiConnectivity.js +1 -2
  5. package/dist/apiRoleTransports.js +47 -0
  6. package/dist/apiRuntime.js +76 -67
  7. package/dist/apiSocketTracker.js +20 -0
  8. package/dist/apiSupervisor.js +17 -7
  9. package/dist/authRefresh.js +1 -2
  10. package/dist/awaitResolvedApi.js +5 -6
  11. package/dist/bootstrap.d.ts +9 -0
  12. package/dist/bootstrap.js +3 -3
  13. package/dist/cellMerger.js +1 -2
  14. package/dist/clientDiagnostics.js +1 -2
  15. package/dist/clientErrorBus.js +1 -2
  16. package/dist/clientScheduler.js +1 -2
  17. package/dist/connectionPrerequisite.js +1 -2
  18. package/dist/connectionScope.js +15 -4
  19. package/dist/connectionSetupController.js +1 -2
  20. package/dist/createHooks.js +1 -2
  21. package/dist/deepLink.js +1 -2
  22. package/dist/filters.js +1 -2
  23. package/dist/form.d.ts +37 -4
  24. package/dist/form.js +4 -2
  25. package/dist/formBinding.js +1 -2
  26. package/dist/formData.js +73 -12
  27. package/dist/formFlashId.js +1 -2
  28. package/dist/formRejection.js +22 -0
  29. package/dist/formSource.js +12 -0
  30. package/dist/frameworkRuntimesContext.js +1 -2
  31. package/dist/globalContext.js +1 -2
  32. package/dist/index.d.ts +99 -20
  33. package/dist/index.js +57 -54
  34. package/dist/liveRowSort.js +1 -2
  35. package/dist/mutationConnectionSetup.js +1 -2
  36. package/dist/mutationIdentity.js +1 -2
  37. package/dist/mutationSerialExecution.js +1 -2
  38. package/dist/mutationsBus.js +1 -2
  39. package/dist/onlineSource.js +1 -2
  40. package/dist/outbox.js +1 -2
  41. package/dist/outboxHttp.js +1 -2
  42. package/dist/outboxState.js +1 -2
  43. package/dist/permissions.js +1 -2
  44. package/dist/platform.js +1 -2
  45. package/dist/preloadSeed.js +1 -2
  46. package/dist/provider.js +1 -2
  47. package/dist/query.js +1 -2
  48. package/dist/recoveryCoordinator.js +1 -2
  49. package/dist/recoveryRetry.js +1 -2
  50. package/dist/richText.js +1 -2
  51. package/dist/rpcErrorBus.js +1 -2
  52. package/dist/rpcErrorKind.js +1 -2
  53. package/dist/runRpc.js +1 -2
  54. package/dist/runtime.d.ts +17 -2
  55. package/dist/runtimeCapabilities.js +1 -2
  56. package/dist/runtimeContext.js +1 -2
  57. package/dist/schemaFields.js +1 -2
  58. package/dist/scopeMembership.js +1 -2
  59. package/dist/seedResolvers.js +1 -2
  60. package/dist/sequence.js +1 -2
  61. package/dist/serverRequest.js +12 -9
  62. package/dist/serviceClient.js +50 -50
  63. package/dist/squashRpcCause.js +1 -2
  64. package/dist/stableKey.js +1 -2
  65. package/dist/store.js +1 -2
  66. package/dist/storeStorage.js +1 -2
  67. package/dist/subscriptionCache.js +5 -6
  68. package/dist/tagWalk.js +1 -2
  69. package/dist/traceBus.js +1 -2
  70. package/dist/tracking.js +1 -2
  71. package/dist/uploadProgress.js +1 -2
  72. package/dist/useAction.js +1 -2
  73. package/dist/useAgent.js +1 -2
  74. package/dist/useAgentChat.js +1 -2
  75. package/dist/useAgentStream.js +1 -2
  76. package/dist/useApiOnline.js +1 -2
  77. package/dist/useCapabilityManifest.js +28 -25
  78. package/dist/useConnectionSetup.js +1 -2
  79. package/dist/useConnectionStatus.js +1 -2
  80. package/dist/useConnections.js +1 -2
  81. package/dist/useDataCopilot.js +1 -2
  82. package/dist/useDataTable.js +1 -2
  83. package/dist/useDerived.js +1 -2
  84. package/dist/useEvent.js +78 -69
  85. package/dist/useFormBinding.js +227 -226
  86. package/dist/useLocalQuery.js +1 -2
  87. package/dist/useMutation.js +1 -2
  88. package/dist/useOnRpcError.js +1 -2
  89. package/dist/usePreloadedSubscription.js +1 -2
  90. package/dist/usePreview.js +1 -2
  91. package/dist/useProvenance.js +1 -2
  92. package/dist/useQueryField.js +1 -2
  93. package/dist/useRecord.js +1 -2
  94. package/dist/useRefreshSubscriptions.js +1 -2
  95. package/dist/useResourceCan.js +1 -2
  96. package/dist/useResumableAgentStream.js +1 -2
  97. package/dist/useRpcCaller.js +16 -0
  98. package/dist/useSequence.js +1 -2
  99. package/dist/useSkeleton.js +1 -2
  100. package/dist/useSubscription.js +56 -48
  101. package/dist/useSubscriptionHealth.js +1 -2
  102. package/dist/useTranscription.js +1 -2
  103. package/dist/useUndo.js +1 -2
  104. package/dist/useUndoLog.js +1 -2
  105. package/dist/useUpload.js +1 -2
  106. package/dist/useWindowedSubscription.js +1 -2
  107. package/dist/useWorkflow.js +1 -2
  108. package/dist/useWorkflowRunState.js +1 -2
  109. package/dist/validation.js +1 -2
  110. package/dist/validationMessages.js +1 -2
  111. package/package.json +4 -4
@@ -1,10 +1,10 @@
1
1
  import { isUnresolvedApi as e } from "./frameworkRuntimesContext.js";
2
2
  import { ConnectionPrerequisiteInvalidated as t } from "./connectionPrerequisite.js";
3
- //#region src/awaitResolvedApi.ts
4
- var n = 15e3, r = async (t, r, i) => {
5
- if (!e(t.current)) return t.current;
6
- let a = Date.now() + n;
7
- for (; Date.now() < a;) if (await new Promise((e) => setTimeout(e, 16)), !e(t.current)) return t.current;
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 };
@@ -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 { 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 };
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 };
@@ -1,6 +1,5 @@
1
- //#region src/cellMerger.ts
1
+ // src/cellMerger.ts
2
2
  var e = Symbol.for("voltro.client.cellMerger"), t = (t) => {
3
3
  globalThis[e] = t;
4
4
  }, n = () => globalThis[e];
5
- //#endregion
6
5
  export { t as registerCellMerger, n as registeredCellMerger };
@@ -1,4 +1,4 @@
1
- //#region src/clientDiagnostics.ts
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 };
@@ -1,4 +1,4 @@
1
- //#region src/clientErrorBus.ts
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 };
@@ -1,5 +1,5 @@
1
1
  import { MutableList as e, Scheduler as t } from "effect";
2
- //#region src/clientScheduler.ts
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
- //#region src/connectionPrerequisite.ts
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 };
@@ -1,4 +1,4 @@
1
- //#region src/connectionScope.ts
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
- //#endregion
35
- export { e as ConnectionScope, r as connectionScopeForRuntime, n as registerConnectionScope };
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
- //#region src/connectionSetupController.ts
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 };
@@ -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
- //#region src/createHooks.ts
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
- //#region src/deepLink.ts
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
- //#region src/filters.ts
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 path a native `<AutoForm>` POST goes to. */
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 { 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 };
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 };
@@ -1,6 +1,6 @@
1
1
  import { Schema as e, SchemaIssue as t } from "effect";
2
2
  import * as n from "effect/SchemaAST";
3
- //#region src/formBinding.ts
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
- //#region src/formData.ts
5
- var r = "/form/", i = (e) => `${r}${encodeURIComponent(e)}`, a = "__voltro_form", o = "__voltro_redirect", s = (e) => {
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.isNaN(t) ? e : t;
8
- }, c = (e) => {
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
- }, l = (e, n) => {
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 : s(n);
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
- }, u = (t, n) => {
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 = c(n), r = e ?? [], i = t === "number" || t === "integer", o = r.filter((e) => e !== "");
54
- if (i) for (let e = 0; e < o.length; e += 1) o[e] = s(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 = l(n, e[0]);
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
- //#endregion
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 };
@@ -1,4 +1,3 @@
1
- //#region src/formFlashId.ts
1
+ // src/formFlashId.ts
2
2
  var e = "__voltro_form_flash__";
3
- //#endregion
4
3
  export { e as FORM_FLASH_SCRIPT_ID };
@@ -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
- //#region src/frameworkRuntimesContext.ts
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 };
@@ -1,10 +1,9 @@
1
1
  import { createContext as e } from "react";
2
- //#region src/globalContext.ts
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 };