@holo-js/forms 0.3.23 → 0.3.25
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/dist/index.mjs
CHANGED
|
@@ -205,8 +205,7 @@ function isNextHeadersModule(value) {
|
|
|
205
205
|
}
|
|
206
206
|
async function importNextHeadersModule() {
|
|
207
207
|
try {
|
|
208
|
-
const
|
|
209
|
-
const module = runtime.__holoFormsNextHeadersImport__ ? await runtime.__holoFormsNextHeadersImport__() : await import(
|
|
208
|
+
const module = await import(
|
|
210
209
|
/* @vite-ignore */
|
|
211
210
|
/* webpackIgnore: true */
|
|
212
211
|
nextHeadersModuleSpecifier
|
|
@@ -420,7 +419,7 @@ async function safeParse(input, schemaDefinition, options = {}) {
|
|
|
420
419
|
if (usesSecurityOptions) {
|
|
421
420
|
const request = normalizedRequestInput;
|
|
422
421
|
try {
|
|
423
|
-
const { loadSecurityModule } = await import("./security-
|
|
422
|
+
const { loadSecurityModule } = await import("./security-YE5UGG47.mjs");
|
|
424
423
|
const security = await loadSecurityModule();
|
|
425
424
|
const inspection = await safeParseInput(request.clone(), schemaDefinition);
|
|
426
425
|
const throttleValues = inspection.valid ? inspection.data : inspection.values;
|
|
@@ -430,7 +429,7 @@ async function safeParse(input, schemaDefinition, options = {}) {
|
|
|
430
429
|
values: throttleValues
|
|
431
430
|
});
|
|
432
431
|
} catch (error) {
|
|
433
|
-
const { formsSecurityInternals } = await import("./security-
|
|
432
|
+
const { formsSecurityInternals } = await import("./security-YE5UGG47.mjs");
|
|
434
433
|
if (formsSecurityInternals.isRootSecurityError(error)) {
|
|
435
434
|
if (validatedSubmission) {
|
|
436
435
|
return createFailedSubmission(
|
package/dist/internal/client.mjs
CHANGED
|
@@ -22,21 +22,8 @@ import {
|
|
|
22
22
|
|
|
23
23
|
// src/client-security.ts
|
|
24
24
|
var securityClientModulePromise;
|
|
25
|
-
async function importSecurityClientModule() {
|
|
26
|
-
if (typeof process !== "undefined" && process.env && process.env.VITEST) {
|
|
27
|
-
return await import(
|
|
28
|
-
/* @vite-ignore */
|
|
29
|
-
"@holo-js/security/client"
|
|
30
|
-
);
|
|
31
|
-
}
|
|
32
|
-
return await import("@holo-js/security/client");
|
|
33
|
-
}
|
|
34
25
|
async function loadSecurityClientModule() {
|
|
35
|
-
|
|
36
|
-
if (runtime.__holoFormsSecurityClientModule__) {
|
|
37
|
-
return runtime.__holoFormsSecurityClientModule__;
|
|
38
|
-
}
|
|
39
|
-
securityClientModulePromise ??= (runtime.__holoFormsSecurityClientImport__ ? runtime.__holoFormsSecurityClientImport__() : importSecurityClientModule()).then((module) => module).catch(async (error) => {
|
|
26
|
+
securityClientModulePromise ??= import("@holo-js/security/client").catch((error) => {
|
|
40
27
|
securityClientModulePromise = void 0;
|
|
41
28
|
if (isMissingOptionalPackageError(error)) {
|
|
42
29
|
throw createMissingSecurityPackageError();
|
|
@@ -242,7 +229,9 @@ function buildFormData(value, path = "", formData = new FormData()) {
|
|
|
242
229
|
return formData;
|
|
243
230
|
}
|
|
244
231
|
if (Array.isArray(value)) {
|
|
245
|
-
for (const item of value)
|
|
232
|
+
for (const [index, item] of value.entries()) {
|
|
233
|
+
buildFormData(item, `${path}[${isPlainFormObject(item) || Array.isArray(item) ? index : ""}]`, formData);
|
|
234
|
+
}
|
|
246
235
|
return formData;
|
|
247
236
|
}
|
|
248
237
|
if (isPlainFormObject(value)) {
|
|
@@ -373,6 +362,7 @@ var FormClientState = class {
|
|
|
373
362
|
};
|
|
374
363
|
|
|
375
364
|
// src/internal/client.ts
|
|
365
|
+
import { normalizeHoloHttpError } from "@holo-js/kernel/http-errors";
|
|
376
366
|
var browserFormSubmitSymbol = /* @__PURE__ */ Symbol("browserFormSubmit");
|
|
377
367
|
var clientSubmitControlFlowErrors = /* @__PURE__ */ new WeakSet();
|
|
378
368
|
function isBrowserFormSubmitter(value) {
|
|
@@ -793,7 +783,13 @@ function createFormClient(schemaDefinition, options = {}) {
|
|
|
793
783
|
const action = options.action ?? liveForm?.action;
|
|
794
784
|
const liveFormData = getActiveBrowserFormData(liveForm);
|
|
795
785
|
const formData = liveFormData ?? buildFormData(state.values);
|
|
796
|
-
|
|
786
|
+
if (liveFormData) {
|
|
787
|
+
const nativeFields = new Set([...liveFormData.keys()].map((name) => name.replace(/\[\d+\]$/, "[]")));
|
|
788
|
+
for (const [name, value] of buildFormData(state.values)) {
|
|
789
|
+
if (!nativeFields.has(name)) formData.append(name, value);
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
const localSubmission = liveFormData ? await runValidationForInput(formData) : await runValidation();
|
|
797
793
|
if (!localSubmission.valid) {
|
|
798
794
|
return localSubmission;
|
|
799
795
|
}
|
|
@@ -816,7 +812,7 @@ function createFormClient(schemaDefinition, options = {}) {
|
|
|
816
812
|
throw error;
|
|
817
813
|
}
|
|
818
814
|
return applyServerState(
|
|
819
|
-
validationExceptionToFailure(error, localSubmission.data) ?? createTransportFailure(localSubmission.data),
|
|
815
|
+
validationExceptionToFailure(error, localSubmission.data) ?? createTransportFailure(localSubmission.data, normalizeHoloHttpError(error)?.status),
|
|
820
816
|
submissionSequence
|
|
821
817
|
);
|
|
822
818
|
}
|
|
@@ -8,21 +8,8 @@ import "./chunk-OFPH5LBY.mjs";
|
|
|
8
8
|
|
|
9
9
|
// src/security.ts
|
|
10
10
|
var securityModulePromise;
|
|
11
|
-
async function importSecurityModule() {
|
|
12
|
-
if (typeof process !== "undefined" && process.env && process.env.VITEST) {
|
|
13
|
-
return await import(
|
|
14
|
-
/* @vite-ignore */
|
|
15
|
-
"@holo-js/security"
|
|
16
|
-
);
|
|
17
|
-
}
|
|
18
|
-
return await import("@holo-js/security");
|
|
19
|
-
}
|
|
20
11
|
async function loadSecurityModule() {
|
|
21
|
-
|
|
22
|
-
if (runtime.__holoFormsSecurityModule__) {
|
|
23
|
-
return runtime.__holoFormsSecurityModule__;
|
|
24
|
-
}
|
|
25
|
-
securityModulePromise ??= (runtime.__holoFormsSecurityImport__ ? runtime.__holoFormsSecurityImport__() : importSecurityModule()).then((module) => module).catch(async (error) => {
|
|
12
|
+
securityModulePromise ??= import("@holo-js/security").catch((error) => {
|
|
26
13
|
securityModulePromise = void 0;
|
|
27
14
|
if (isMissingOptionalPackageError(error)) {
|
|
28
15
|
throw createMissingSecurityPackageError();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@holo-js/forms",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.25",
|
|
4
4
|
"description": "Holo-JS Framework - forms-first validation and submission contracts",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -25,13 +25,14 @@
|
|
|
25
25
|
"build": "tsup",
|
|
26
26
|
"stub": "tsup",
|
|
27
27
|
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
28
|
-
"test": "vitest --run"
|
|
28
|
+
"test": "vitest --run && node --test --test-concurrency=3 ../../tests/forms-native-browser.mjs ../../tests/forms-native-packages.mjs"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@holo-js/
|
|
31
|
+
"@holo-js/kernel": "^0.3.25",
|
|
32
|
+
"@holo-js/validation": "^0.3.25"
|
|
32
33
|
},
|
|
33
34
|
"peerDependencies": {
|
|
34
|
-
"@holo-js/security": "^0.3.
|
|
35
|
+
"@holo-js/security": "^0.3.25"
|
|
35
36
|
},
|
|
36
37
|
"peerDependenciesMeta": {
|
|
37
38
|
"@holo-js/security": {
|