@voltro/client 0.85.0 → 0.87.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 (116) hide show
  1. package/CHANGELOG.md +5987 -0
  2. package/THIRD-PARTY-NOTICES.md +1125 -34
  3. package/dist/analyticsCatalog.js +47 -0
  4. package/dist/apiConnectivity.js +33 -0
  5. package/dist/apiRoleTransports.js +48 -0
  6. package/dist/apiRuntime.js +145 -0
  7. package/dist/apiSocketTracker.js +21 -0
  8. package/dist/apiSupervisor.js +136 -0
  9. package/dist/authRefresh.js +20 -0
  10. package/dist/awaitResolvedApi.js +23 -0
  11. package/dist/bootstrap.d.ts +1153 -0
  12. package/dist/bootstrap.js +8 -0
  13. package/dist/cellMerger.js +6 -0
  14. package/dist/clientDiagnostics.js +94 -0
  15. package/dist/clientErrorBus.js +16 -0
  16. package/dist/clientScheduler.js +31 -0
  17. package/dist/connectionPrerequisite.js +70 -0
  18. package/dist/connectionScope.js +47 -0
  19. package/dist/connectionSetupController.js +206 -0
  20. package/dist/createHooks.js +15 -0
  21. package/dist/deepLink.js +69 -0
  22. package/dist/filters.js +58 -0
  23. package/dist/form.d.ts +37 -4
  24. package/dist/form.js +7 -2
  25. package/dist/formBinding.js +325 -0
  26. package/dist/formData.js +127 -0
  27. package/dist/formFlashId.js +4 -0
  28. package/dist/formRejection.js +23 -0
  29. package/dist/formSource.js +13 -0
  30. package/dist/frameworkRuntimesContext.js +8 -0
  31. package/dist/globalContext.js +10 -0
  32. package/dist/index.d.ts +152 -27
  33. package/dist/index.js +87 -4121
  34. package/dist/liveRowSort.js +66 -0
  35. package/dist/mutationConnectionSetup.js +16 -0
  36. package/dist/mutationIdentity.js +10 -0
  37. package/dist/mutationSerialExecution.js +53 -0
  38. package/dist/mutationsBus.js +40 -0
  39. package/dist/onlineSource.js +13 -0
  40. package/dist/outbox.js +213 -0
  41. package/dist/outboxHttp.js +104 -0
  42. package/dist/outboxState.js +43 -0
  43. package/dist/permissions.js +20 -0
  44. package/dist/platform.js +121 -0
  45. package/dist/preloadSeed.js +47 -0
  46. package/dist/provider.js +22 -0
  47. package/dist/query.js +12 -2
  48. package/dist/recoveryCoordinator.js +195 -0
  49. package/dist/recoveryRetry.js +24 -0
  50. package/dist/richText.js +176 -0
  51. package/dist/rpcErrorBus.js +39 -0
  52. package/dist/rpcErrorKind.js +13 -0
  53. package/dist/runRpc.js +12 -0
  54. package/dist/runtime.d.ts +49 -3
  55. package/dist/runtime.js +16 -126
  56. package/dist/runtimeCapabilities.js +44 -0
  57. package/dist/runtimeContext.js +49 -0
  58. package/dist/schemaFields.js +219 -0
  59. package/dist/scopeMembership.js +12 -0
  60. package/dist/seedResolvers.js +7 -0
  61. package/dist/sequence.js +65 -0
  62. package/dist/serverRequest.js +28 -0
  63. package/dist/serviceClient.js +129 -0
  64. package/dist/squashRpcCause.js +8 -0
  65. package/dist/stableKey.js +21 -0
  66. package/dist/store.js +288 -0
  67. package/dist/storeStorage.js +28 -0
  68. package/dist/subscriptionCache.js +724 -0
  69. package/dist/tagWalk.js +23 -0
  70. package/dist/traceBus.js +10 -0
  71. package/dist/tracking.js +40 -0
  72. package/dist/uploadProgress.js +21 -0
  73. package/dist/useAction.js +101 -0
  74. package/dist/useAgent.js +53 -0
  75. package/dist/useAgentChat.js +43 -0
  76. package/dist/useAgentStream.js +64 -0
  77. package/dist/useApiOnline.js +14 -0
  78. package/dist/useCapabilityManifest.js +105 -0
  79. package/dist/useConnectionSetup.js +28 -0
  80. package/dist/useConnectionStatus.js +38 -0
  81. package/dist/useConnections.js +107 -0
  82. package/dist/useDataCopilot.js +24 -0
  83. package/dist/useDataTable.js +34 -0
  84. package/dist/useDerived.js +22 -0
  85. package/dist/useEvent.js +98 -0
  86. package/dist/useFormBinding.js +478 -0
  87. package/dist/useLocalQuery.js +59 -0
  88. package/dist/useMutation.js +214 -0
  89. package/dist/useOnRpcError.js +13 -0
  90. package/dist/usePreloadedSubscription.js +18 -0
  91. package/dist/usePreview.js +14 -0
  92. package/dist/useProvenance.js +51 -0
  93. package/dist/useQueryField.js +34 -0
  94. package/dist/useRecord.js +12 -0
  95. package/dist/useRefreshSubscriptions.js +22 -0
  96. package/dist/useResourceCan.js +18 -0
  97. package/dist/useResumableAgentStream.js +75 -0
  98. package/dist/useRpcCaller.js +17 -0
  99. package/dist/useSequence.js +25 -0
  100. package/dist/useSkeleton.js +13 -0
  101. package/dist/useSubscription.js +98 -0
  102. package/dist/useSubscriptionHealth.js +32 -0
  103. package/dist/useTranscription.js +51 -0
  104. package/dist/useUndo.js +33 -0
  105. package/dist/useUndoLog.js +44 -0
  106. package/dist/useUpload.js +296 -0
  107. package/dist/useWindowedSubscription.js +65 -0
  108. package/dist/useWorkflow.js +284 -0
  109. package/dist/useWorkflowRunState.js +93 -0
  110. package/dist/validation.js +39 -0
  111. package/dist/validationMessages.js +5 -0
  112. package/package.json +7 -2
  113. package/dist/authRefresh-DmfSoCca.js +0 -360
  114. package/dist/formData-BfpBt7BQ.js +0 -769
  115. package/dist/queryOnce-D5Y4V1SB.js +0 -55
  116. package/dist/runRpc-Zfz3w709.js +0 -1172
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,2 +1,7 @@
1
- import { C as e, S as t, _ as n, a as r, b as i, g as a, i as o, n as s, o as c, r as l, t as u, v as d, w as f, x as p, y as m } from "./formData-BfpBt7BQ.js";
2
- export { u as FORM_FLASH_SCRIPT_ID, s as FORM_KEY_FIELD, l as FORM_PATH_PREFIX, o as FORM_REDIRECT_FIELD, a as decodeFieldIssues, n as documentLocale, r as formActionPath, c as formDataToInput, p as formField, t as formSections, d as resolveValidationMessage, m as restrictToSchema, e as schemaToColumns, f as schemaToFields, i as validateFields };
1
+ import { formField as e, formSections as t, schemaToColumns as n, schemaToFields as r } from "./schemaFields.js";
2
+ import { decodeFieldIssues as i, documentLocale as a, resolveValidationMessage as o, restrictToSchema as s, validateFields as c } from "./formBinding.js";
3
+ import { FORM_FLASH_SCRIPT_ID as l } from "./formFlashId.js";
4
+ import { FORM_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 };
@@ -0,0 +1,325 @@
1
+ import { Schema as e, SchemaIssue as t } from "effect";
2
+ import * as n from "effect/SchemaAST";
3
+ //#region src/formBinding.ts
4
+ var r = {
5
+ en: {
6
+ "validation.required": "Required",
7
+ "validation.invalid": "Invalid value",
8
+ "validation.minLength": "Must be at least {min} characters",
9
+ "validation.maxLength": "Must be at most {max} characters",
10
+ "validation.pattern": "Invalid format",
11
+ "validation.minValue": "Must be at least {min}",
12
+ "validation.maxValue": "Must be at most {max}",
13
+ "validation.minItems": "Add at least {min}",
14
+ "validation.maxItems": "No more than {max}",
15
+ "validation.integer": "Must be a whole number",
16
+ "validation.checking": "Still checking…",
17
+ "validation.invalidEmail": "Enter a valid email address",
18
+ "validation.invalidUrl": "Enter a valid URL",
19
+ "validation.invalidUuid": "Enter a valid identifier",
20
+ "validation.betweenLength": "Must be between {min} and {max} characters",
21
+ "validation.exactLength": "Must be exactly {amount} characters",
22
+ "validation.minDate": "Must not be earlier than {min}",
23
+ "validation.maxDate": "Must not be later than {max}",
24
+ "validation.invalidFileType": "This file type is not allowed",
25
+ "validation.fileTooLarge": "File is too large"
26
+ },
27
+ de: {
28
+ "validation.required": "Pflichtfeld",
29
+ "validation.invalid": "Ungültiger Wert",
30
+ "validation.minLength": "Mindestens {min} Zeichen",
31
+ "validation.maxLength": "Höchstens {max} Zeichen",
32
+ "validation.pattern": "Ungültiges Format",
33
+ "validation.minValue": "Mindestens {min}",
34
+ "validation.maxValue": "Höchstens {max}",
35
+ "validation.minItems": "Mindestens {min}",
36
+ "validation.maxItems": "Höchstens {max}",
37
+ "validation.integer": "Ganze Zahl erforderlich",
38
+ "validation.checking": "Prüfung läuft…",
39
+ "validation.invalidEmail": "Bitte eine gültige E-Mail-Adresse eingeben",
40
+ "validation.invalidUrl": "Bitte eine gültige URL eingeben",
41
+ "validation.invalidUuid": "Bitte eine gültige Kennung eingeben",
42
+ "validation.betweenLength": "Muss zwischen {min} und {max} Zeichen haben",
43
+ "validation.exactLength": "Muss genau {amount} Zeichen haben",
44
+ "validation.minDate": "Darf nicht früher sein als {min}",
45
+ "validation.maxDate": "Darf nicht später sein als {max}",
46
+ "validation.invalidFileType": "Dieser Dateityp ist nicht erlaubt",
47
+ "validation.fileTooLarge": "Die Datei ist zu groß"
48
+ }
49
+ }, i = (e, t) => {
50
+ let n = !1, r = e.replace(/\{(\w+)\}/g, (e, r) => {
51
+ let i = t?.[r];
52
+ return i === void 0 ? (n = !0, e) : String(i);
53
+ });
54
+ return n ? void 0 : r;
55
+ }, a = () => {
56
+ let e = globalThis.document?.documentElement?.lang ?? "";
57
+ return e === "" ? "en" : e;
58
+ }, o = (e, t) => {
59
+ let n = t?.messages?.(e.id, e.params, e.fallback);
60
+ if (n !== void 0) return n;
61
+ let o = r[(t?.locale ?? a()).toLowerCase().split("-")[0] ?? "en"]?.[e.id] ?? r.en?.[e.id];
62
+ return (o === void 0 ? void 0 : i(o, e.params)) ?? e.fallback;
63
+ }, s = (e) => {
64
+ let t = /^([a-z][\w-]*(?:\.[\w-]+)+)\|(\{.*\})$/.exec(e);
65
+ if (t !== null && t[1] !== void 0 && t[2] !== void 0) try {
66
+ return {
67
+ id: t[1],
68
+ params: JSON.parse(t[2]),
69
+ fallback: e
70
+ };
71
+ } catch {}
72
+ return /^[a-z][\w-]*(?:\.[\w-]+)+$/.test(e) ? {
73
+ id: e,
74
+ fallback: e
75
+ } : {
76
+ id: "validation.custom",
77
+ fallback: e
78
+ };
79
+ }, c = {
80
+ email: "validation.invalidEmail",
81
+ "idn-email": "validation.invalidEmail",
82
+ uri: "validation.invalidUrl",
83
+ url: "validation.invalidUrl",
84
+ uuid: "validation.invalidUuid"
85
+ }, l = (e, t, r) => {
86
+ let i = e.ast;
87
+ for (let e of t.split(".")) {
88
+ if (i === void 0) return {};
89
+ if (/^\d+$/.test(e)) {
90
+ i = n.isArrays(i) ? i.rest[0] ?? i.elements[0] : void 0;
91
+ continue;
92
+ }
93
+ let t = r?.get(i);
94
+ if (t !== void 0) {
95
+ i = t.get(e);
96
+ continue;
97
+ }
98
+ let a;
99
+ if (!n.isObjects(i)) return {};
100
+ if (a = i.propertySignatures, r !== void 0 && a.length >= 32) {
101
+ let t = /* @__PURE__ */ new Map();
102
+ for (let e of a) {
103
+ let n = String(e.name);
104
+ t.has(n) || t.set(n, e.type);
105
+ }
106
+ r.set(i, t), i = t.get(e);
107
+ } else i = a.find((t) => String(t.name) === e)?.type;
108
+ }
109
+ let a = {};
110
+ for (let e of i?.checks ?? []) {
111
+ let t = u(e.annotations);
112
+ if (t === void 0) continue;
113
+ let n = t.payload ?? {};
114
+ a.min === void 0 && t.id === "effect/schema/isMinLength" && typeof n.minLength == "number" && (a.min = n.minLength), a.max === void 0 && t.id === "effect/schema/isMaxLength" && typeof n.maxLength == "number" && (a.max = n.maxLength);
115
+ }
116
+ return a;
117
+ }, u = (e) => {
118
+ let t = e?.representation;
119
+ return t !== void 0 && typeof t.id == "string" ? {
120
+ id: t.id,
121
+ payload: t.payload
122
+ } : void 0;
123
+ }, d = (e, t) => {
124
+ let n = u(e), r = n?.payload ?? {};
125
+ switch (n?.id) {
126
+ case "effect/schema/isMinLength": return t ? {
127
+ id: "validation.minItems",
128
+ params: {
129
+ count: r.minLength,
130
+ min: r.minLength
131
+ }
132
+ } : {
133
+ id: "validation.minLength",
134
+ params: { min: r.minLength }
135
+ };
136
+ case "effect/schema/isMaxLength": return t ? {
137
+ id: "validation.maxItems",
138
+ params: {
139
+ count: r.maxLength,
140
+ max: r.maxLength
141
+ }
142
+ } : {
143
+ id: "validation.maxLength",
144
+ params: { max: r.maxLength }
145
+ };
146
+ case "effect/schema/isBetweenLength": {
147
+ let e = r.minimum, t = r.maximum;
148
+ return e === t ? {
149
+ id: "validation.exactLength",
150
+ params: { amount: e }
151
+ } : {
152
+ id: "validation.betweenLength",
153
+ params: {
154
+ min: e,
155
+ max: t
156
+ }
157
+ };
158
+ }
159
+ case "effect/schema/isPattern": {
160
+ let t = typeof e?.format == "string" ? c[e.format] : void 0;
161
+ return t === void 0 ? {
162
+ id: "validation.pattern",
163
+ params: { pattern: r.source }
164
+ } : { id: t };
165
+ }
166
+ case "effect/schema/isGreaterThanOrEqualTo": return {
167
+ id: "validation.minValue",
168
+ params: { min: r.minimum }
169
+ };
170
+ case "effect/schema/isLessThanOrEqualTo": return {
171
+ id: "validation.maxValue",
172
+ params: { max: r.maximum }
173
+ };
174
+ case "effect/schema/isGreaterThan": return {
175
+ id: "validation.minValue",
176
+ params: {
177
+ min: r.exclusiveMinimum,
178
+ exclusive: !0
179
+ }
180
+ };
181
+ case "effect/schema/isLessThan": return {
182
+ id: "validation.maxValue",
183
+ params: {
184
+ max: r.exclusiveMaximum,
185
+ exclusive: !0
186
+ }
187
+ };
188
+ case "effect/schema/isInt": return { id: "validation.integer" };
189
+ case "effect/schema/isBetween": return {
190
+ id: "validation.minValue",
191
+ params: {
192
+ min: r.minimum,
193
+ max: r.maximum
194
+ }
195
+ };
196
+ default: {
197
+ let e = n?.id ?? "";
198
+ return /isGreaterThanOrEqualToDate|isGreaterThanDate/.test(e) ? { id: "validation.minDate" } : /isLessThanOrEqualToDate|isLessThanDate/.test(e) ? { id: "validation.maxDate" } : { id: "validation.invalid" };
199
+ }
200
+ }
201
+ }, f = (e) => {
202
+ let t = e?.message;
203
+ return typeof t == "string" && t.length > 0 ? t : void 0;
204
+ }, p = (e) => e.map((e) => String(e)), m = t.makeFormatterDefault(), h = (e) => {
205
+ let t = [], n = (e, n, r, i) => {
206
+ t.push({
207
+ path: e.join("."),
208
+ id: n,
209
+ ...r === void 0 ? {} : { params: r },
210
+ fallback: i
211
+ });
212
+ }, r = (e, t) => {
213
+ let r = s(t);
214
+ n(e, r.id, r.params, r.fallback);
215
+ }, i = (e, t, a = !1) => {
216
+ switch (e._tag) {
217
+ case "Composite":
218
+ for (let n of e.issues) i(n, t, e.ast._tag === "Arrays");
219
+ return;
220
+ case "AnyOf":
221
+ for (let n of e.issues) i(n, t, a);
222
+ return;
223
+ case "Pointer":
224
+ i(e.issue, [...t, ...p(e.path)]);
225
+ return;
226
+ case "Encoding":
227
+ i(e.issue, t, a);
228
+ return;
229
+ case "Filter": {
230
+ let o = e.filter.annotations, s = f(o);
231
+ if (s !== void 0) return r(t, s);
232
+ let c = d(o, a);
233
+ if (c.id !== "validation.invalid") {
234
+ n(t, c.id, c.params, g(e));
235
+ return;
236
+ }
237
+ if (e.issue._tag === "Pointer" || e.issue._tag === "Composite" || e.issue._tag === "InvalidValue") {
238
+ i(e.issue, t);
239
+ return;
240
+ }
241
+ n(t, "validation.invalid", void 0, g(e));
242
+ return;
243
+ }
244
+ case "MissingKey":
245
+ n(t, "validation.required", void 0, "Required");
246
+ return;
247
+ case "InvalidValue": {
248
+ let i = f(e.annotations);
249
+ if (i !== void 0) return r(t, i);
250
+ n(t, "validation.invalid", void 0, g(e));
251
+ return;
252
+ }
253
+ default:
254
+ n(t, "validation.invalid", void 0, g(e));
255
+ return;
256
+ }
257
+ };
258
+ return i(e.issue, []), t;
259
+ }, g = (e) => {
260
+ let t = m(e).split("\n")[0] ?? "";
261
+ return t.length > 0 ? t : "Invalid value";
262
+ }, _ = (e, t) => {
263
+ if (typeof t != "object" || !t || Array.isArray(t)) return {
264
+ input: t,
265
+ dropped: []
266
+ };
267
+ let r;
268
+ try {
269
+ let t = e.ast;
270
+ if (!n.isObjects(t)) throw Error("not an object schema");
271
+ r = t.propertySignatures.map((e) => String(e.name));
272
+ } catch {
273
+ return {
274
+ input: t,
275
+ dropped: []
276
+ };
277
+ }
278
+ if (r.length === 0) return {
279
+ input: t,
280
+ dropped: []
281
+ };
282
+ let i = new Set(r), a = Object.entries(t), o = [], s = 0;
283
+ for (let e = 0; e < a.length; e += 1) {
284
+ let t = a[e];
285
+ i.has(t[0]) ? a[s++] = t : o.push(t[0]);
286
+ }
287
+ return o.length === 0 ? {
288
+ input: t,
289
+ dropped: []
290
+ } : (a.length = s, {
291
+ input: Object.fromEntries(a),
292
+ dropped: o
293
+ });
294
+ }, v = (t, n, r) => {
295
+ let i = e.decodeUnknownResult(t, { errors: "all" })(n);
296
+ if (i._tag === "Success") return {
297
+ valid: !0,
298
+ errors: {},
299
+ issues: []
300
+ };
301
+ let a = h(i.failure), s = a.length >= 32 ? /* @__PURE__ */ new WeakMap() : void 0, c = a.map((e) => {
302
+ if (e.id !== "validation.minLength" && e.id !== "validation.maxLength") return e;
303
+ let n = l(t, e.path, s);
304
+ return n.min === void 0 || n.max === void 0 ? e : n.min === n.max ? {
305
+ ...e,
306
+ id: "validation.exactLength",
307
+ params: { amount: n.min }
308
+ } : {
309
+ ...e,
310
+ id: "validation.betweenLength",
311
+ params: {
312
+ min: n.min,
313
+ max: n.max
314
+ }
315
+ };
316
+ }), u = {};
317
+ for (let e of c) e.path !== "" && !(e.path in u) && (u[e.path] = o(e, r));
318
+ return {
319
+ valid: !1,
320
+ errors: u,
321
+ issues: c
322
+ };
323
+ };
324
+ //#endregion
325
+ export { h as decodeFieldIssues, a as documentLocale, o as resolveValidationMessage, _ as restrictToSchema, v as validateFields };
@@ -0,0 +1,127 @@
1
+ import { schemaToFields as e } from "./schemaFields.js";
2
+ import { parseRichText as t } from "./richText.js";
3
+ import { FORM_FLASH_SCRIPT_ID as n } from "./formFlashId.js";
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
+ //#region src/formData.ts
6
+ var m = (e) => {
7
+ let t = Number(e);
8
+ return Number.isFinite(t) ? t === 0 ? 0 : t : e;
9
+ }, h = (e) => {
10
+ let t = e.jsonSchema.items;
11
+ if (!t || typeof t != "object") return;
12
+ let n = t.type;
13
+ return typeof n == "string" ? n : void 0;
14
+ }, g = (e, n) => {
15
+ switch (e.widget) {
16
+ case "rich-text": return n === "" ? {
17
+ type: "doc",
18
+ content: []
19
+ } : t(n);
20
+ case "number": return n === "" ? void 0 : m(n);
21
+ case "date":
22
+ case "datetime": return n === "" ? void 0 : n;
23
+ default: return n;
24
+ }
25
+ }, _ = (t, n) => {
26
+ let r = /* @__PURE__ */ new Map();
27
+ for (let [e, t] of n) {
28
+ let n = r.get(e);
29
+ n === void 0 ? r.set(e, [t]) : n.push(t);
30
+ }
31
+ let i = {}, a = (e, t) => {
32
+ if (!e.includes(".")) {
33
+ i[e] = t;
34
+ return;
35
+ }
36
+ let n = e.split("."), r = i;
37
+ for (let e = 0; e < n.length - 1; e += 1) {
38
+ let t = n[e], i = r[t];
39
+ if (typeof i != "object" || !i) {
40
+ let e = {};
41
+ r[t] = e, r = e;
42
+ } else r = i;
43
+ }
44
+ r[n[n.length - 1]] = t;
45
+ };
46
+ for (let n of e(t)) {
47
+ if (n.widget === "array") continue;
48
+ let e = r.get(n.name);
49
+ if (n.widget === "checkbox" || n.widget === "switch") {
50
+ a(n.name, e !== void 0);
51
+ continue;
52
+ }
53
+ if (n.widget === "multi-select") {
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]);
56
+ a(n.name, o);
57
+ continue;
58
+ }
59
+ if (e === void 0) continue;
60
+ let t = g(n, e[0]);
61
+ t !== void 0 && a(n.name, t);
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;
125
+ };
126
+ //#endregion
127
+ 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 };
@@ -0,0 +1,4 @@
1
+ //#region src/formFlashId.ts
2
+ var e = "__voltro_form_flash__";
3
+ //#endregion
4
+ export { e as FORM_FLASH_SCRIPT_ID };
@@ -0,0 +1,23 @@
1
+ import { Schema as e } from "effect";
2
+ import { errorMemberSchema as t, errorTag as n } from "@voltro/protocol";
3
+ //#region 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
+ //#endregion
23
+ export { i as encodeFormRejection };
@@ -0,0 +1,13 @@
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
+ //#region 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
+ //#endregion
13
+ 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 };
@@ -0,0 +1,8 @@
1
+ import { globalContext as e } from "./globalContext.js";
2
+ //#region src/frameworkRuntimesContext.ts
3
+ var t = (e, t) => {
4
+ let n = Array.from(t).join(", ") || "(none mounted)";
5
+ return /* @__PURE__ */ Error(`@voltro/client: no api named ${JSON.stringify(e)}. Known apis: ${n}`);
6
+ }, n = e("frameworkRuntimes", null), r = (e) => typeof e.runtime?.runFork != "function";
7
+ //#endregion
8
+ export { n as FrameworkRuntimesContext, r as isUnresolvedApi, t as unknownApiError };
@@ -0,0 +1,10 @@
1
+ import { createContext as e } from "react";
2
+ //#region src/globalContext.ts
3
+ var t = (t, n) => {
4
+ let r = globalThis, i = Symbol.for(`@voltro/web/context:${t}`), a = r[i];
5
+ if (a) return a;
6
+ let o = e(n);
7
+ return r[i] = o, o;
8
+ };
9
+ //#endregion
10
+ export { t as globalContext };