attaform 0.20.2 → 0.21.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/dist/chunks/dev-key-collision-warnings.cjs +58 -0
- package/dist/chunks/dev-key-collision-warnings.cjs.map +1 -0
- package/dist/chunks/dev-key-collision-warnings.mjs +55 -0
- package/dist/chunks/dev-key-collision-warnings.mjs.map +1 -0
- package/dist/chunks/devtools.cjs +1 -1
- package/dist/chunks/devtools.mjs +1 -1
- package/dist/chunks/fingerprint.cjs +186 -0
- package/dist/chunks/fingerprint.cjs.map +1 -0
- package/dist/chunks/fingerprint.mjs +184 -0
- package/dist/chunks/fingerprint.mjs.map +1 -0
- package/dist/chunks/fingerprint2.cjs +162 -0
- package/dist/chunks/fingerprint2.cjs.map +1 -0
- package/dist/chunks/fingerprint2.mjs +160 -0
- package/dist/chunks/fingerprint2.mjs.map +1 -0
- package/dist/chunks/indexeddb.cjs +1 -1
- package/dist/chunks/indexeddb.mjs +1 -1
- package/dist/chunks/local-storage.cjs +1 -1
- package/dist/chunks/local-storage.mjs +1 -1
- package/dist/chunks/multi-tab-sync.cjs +367 -0
- package/dist/chunks/multi-tab-sync.cjs.map +1 -0
- package/dist/chunks/multi-tab-sync.mjs +364 -0
- package/dist/chunks/multi-tab-sync.mjs.map +1 -0
- package/dist/chunks/session-storage.cjs +1 -1
- package/dist/chunks/session-storage.mjs +1 -1
- package/dist/chunks/wire-persistence.cjs +396 -0
- package/dist/chunks/wire-persistence.cjs.map +1 -0
- package/dist/chunks/wire-persistence.mjs +394 -0
- package/dist/chunks/wire-persistence.mjs.map +1 -0
- package/dist/esbuild.cjs +28 -0
- package/dist/esbuild.cjs.map +1 -0
- package/dist/esbuild.d.cts +56 -0
- package/dist/esbuild.d.mts +56 -0
- package/dist/esbuild.d.ts +56 -0
- package/dist/esbuild.mjs +26 -0
- package/dist/esbuild.mjs.map +1 -0
- package/dist/index.cjs +5 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +65 -70
- package/dist/index.d.mts +65 -70
- package/dist/index.d.ts +65 -70
- package/dist/index.mjs +5 -5
- package/dist/nuxt.d.cts +1 -1
- package/dist/nuxt.d.mts +1 -1
- package/dist/nuxt.d.ts +1 -1
- package/dist/rollup.cjs +24 -0
- package/dist/rollup.cjs.map +1 -0
- package/dist/rollup.d.cts +35 -0
- package/dist/rollup.d.mts +35 -0
- package/dist/rollup.d.ts +35 -0
- package/dist/rollup.mjs +22 -0
- package/dist/rollup.mjs.map +1 -0
- package/dist/rspack.cjs +10 -0
- package/dist/rspack.cjs.map +1 -0
- package/dist/rspack.d.cts +40 -0
- package/dist/rspack.d.mts +40 -0
- package/dist/rspack.d.ts +40 -0
- package/dist/rspack.mjs +8 -0
- package/dist/rspack.mjs.map +1 -0
- package/dist/runtime/plugins/attaform.cjs +2 -2
- package/dist/runtime/plugins/attaform.mjs +2 -2
- package/dist/shared/{attaform.ceGEAEMk.d.ts → attaform.7lzO9pdM.d.mts} +95 -1
- package/dist/shared/{attaform.99cfHcIt.d.cts → attaform.B1nyO4ec.d.cts} +82 -30
- package/dist/shared/{attaform.99cfHcIt.d.mts → attaform.B1nyO4ec.d.mts} +82 -30
- package/dist/shared/{attaform.99cfHcIt.d.ts → attaform.B1nyO4ec.d.ts} +82 -30
- package/dist/shared/{attaform.z5j3LwJz.cjs → attaform.BA3vRDos.cjs} +3 -3
- package/dist/shared/attaform.BA3vRDos.cjs.map +1 -0
- package/dist/shared/{attaform.BXinSW2T.d.mts → attaform.BDIEq9qP.d.cts} +1 -1
- package/dist/shared/attaform.BJGA_UOS.mjs +37 -0
- package/dist/shared/attaform.BJGA_UOS.mjs.map +1 -0
- package/dist/shared/{attaform.DN5CvZrg.d.ts → attaform.BK1RE2ha.d.ts} +1 -1
- package/dist/shared/{attaform.CywE4y8x.d.cts → attaform.BQ6drorq.d.mts} +1 -1
- package/dist/shared/attaform.BRGIpZo4.cjs +26 -0
- package/dist/shared/attaform.BRGIpZo4.cjs.map +1 -0
- package/dist/shared/{attaform.CwLjUqmQ.cjs → attaform.BUszFoKq.cjs} +383 -911
- package/dist/shared/attaform.BUszFoKq.cjs.map +1 -0
- package/dist/shared/{attaform.C5aYC_T8.mjs → attaform.BnK_bfcb.mjs} +39 -392
- package/dist/shared/attaform.BnK_bfcb.mjs.map +1 -0
- package/dist/shared/{attaform.DAKrGhxc.cjs → attaform.BzvOdiSI.cjs} +101 -417
- package/dist/shared/attaform.BzvOdiSI.cjs.map +1 -0
- package/dist/shared/attaform.C3Doa9Pt.mjs +24 -0
- package/dist/shared/attaform.C3Doa9Pt.mjs.map +1 -0
- package/dist/shared/{attaform.D2SCCd4O.cjs → attaform.CEf6wYfD.cjs} +2 -2
- package/dist/shared/{attaform.D2SCCd4O.cjs.map → attaform.CEf6wYfD.cjs.map} +1 -1
- package/dist/shared/attaform.CQN9R62B.cjs +39 -0
- package/dist/shared/attaform.CQN9R62B.cjs.map +1 -0
- package/dist/shared/{attaform.sWm8B15V.d.mts → attaform.CRsXyy-Y.d.ts} +95 -1
- package/dist/shared/{attaform.Dt7dEcHk.mjs → attaform.CkjTapyq.mjs} +89 -405
- package/dist/shared/attaform.CkjTapyq.mjs.map +1 -0
- package/dist/shared/{attaform.tiWEVznj.mjs → attaform.DSqO6Db7.mjs} +372 -912
- package/dist/shared/attaform.DSqO6Db7.mjs.map +1 -0
- package/dist/shared/attaform.DuzQYscR.d.cts +41 -0
- package/dist/shared/attaform.DuzQYscR.d.mts +41 -0
- package/dist/shared/attaform.DuzQYscR.d.ts +41 -0
- package/dist/shared/{attaform.DbRgDFa7.d.cts → attaform.F8LMHHWV.d.cts} +95 -1
- package/dist/shared/attaform.LEWUFqUw.cjs +54 -0
- package/dist/shared/attaform.LEWUFqUw.cjs.map +1 -0
- package/dist/shared/{attaform.Cd4AOfwu.cjs → attaform.PnqML3xW.cjs} +68 -402
- package/dist/shared/attaform.PnqML3xW.cjs.map +1 -0
- package/dist/shared/{attaform.QG5TG8lB.mjs → attaform.Y_Mgg0Yp.mjs} +3 -3
- package/dist/shared/attaform.Y_Mgg0Yp.mjs.map +1 -0
- package/dist/shared/{attaform.B_hph5AE.cjs → attaform._rsCZy2j.cjs} +172 -20
- package/dist/shared/attaform._rsCZy2j.cjs.map +1 -0
- package/dist/shared/{attaform.CnrxbkB6.mjs → attaform.ezb5Nh2t.mjs} +2 -2
- package/dist/shared/{attaform.CnrxbkB6.mjs.map → attaform.ezb5Nh2t.mjs.map} +1 -1
- package/dist/shared/{attaform.BGk8cfw2.mjs → attaform.r3PePkDR.mjs} +172 -21
- package/dist/shared/attaform.r3PePkDR.mjs.map +1 -0
- package/dist/shared/attaform.sHkHv_98.mjs +51 -0
- package/dist/shared/attaform.sHkHv_98.mjs.map +1 -0
- package/dist/vite.cjs +9 -45
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.d.cts +36 -0
- package/dist/vite.d.mts +36 -0
- package/dist/vite.d.ts +36 -0
- package/dist/vite.mjs +8 -44
- package/dist/vite.mjs.map +1 -1
- package/dist/webpack.cjs +10 -0
- package/dist/webpack.cjs.map +1 -0
- package/dist/webpack.d.cts +37 -0
- package/dist/webpack.d.mts +37 -0
- package/dist/webpack.d.ts +37 -0
- package/dist/webpack.mjs +8 -0
- package/dist/webpack.mjs.map +1 -0
- package/dist/zod-v3.cjs +3 -3
- package/dist/zod-v3.d.cts +3 -3
- package/dist/zod-v3.d.mts +3 -3
- package/dist/zod-v3.d.ts +3 -3
- package/dist/zod-v3.mjs +3 -3
- package/dist/zod-v4.cjs +3 -3
- package/dist/zod-v4.d.cts +4 -4
- package/dist/zod-v4.d.mts +4 -4
- package/dist/zod-v4.d.ts +4 -4
- package/dist/zod-v4.mjs +3 -3
- package/dist/zod.cjs +8 -8
- package/dist/zod.cjs.map +1 -1
- package/dist/zod.d.cts +5 -5
- package/dist/zod.d.mts +5 -5
- package/dist/zod.d.ts +5 -5
- package/dist/zod.mjs +6 -6
- package/package.json +19 -5
- package/dist/shared/attaform.BGk8cfw2.mjs.map +0 -1
- package/dist/shared/attaform.B_hph5AE.cjs.map +0 -1
- package/dist/shared/attaform.C5aYC_T8.mjs.map +0 -1
- package/dist/shared/attaform.Cd4AOfwu.cjs.map +0 -1
- package/dist/shared/attaform.CwLjUqmQ.cjs.map +0 -1
- package/dist/shared/attaform.DAKrGhxc.cjs.map +0 -1
- package/dist/shared/attaform.Dt7dEcHk.mjs.map +0 -1
- package/dist/shared/attaform.QG5TG8lB.mjs.map +0 -1
- package/dist/shared/attaform.tiWEVznj.mjs.map +0 -1
- package/dist/shared/attaform.z5j3LwJz.cjs.map +0 -1
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const injectWizard = require('./attaform.
|
|
4
|
-
const paths = require('./attaform.
|
|
5
|
-
const
|
|
3
|
+
const injectWizard = require('./attaform.BUszFoKq.cjs');
|
|
4
|
+
const paths = require('./attaform.BA3vRDos.cjs');
|
|
5
|
+
const walkFieldMeta = require('./attaform._rsCZy2j.cjs');
|
|
6
6
|
const zod = require('zod');
|
|
7
7
|
|
|
8
|
-
const fieldMeta =
|
|
8
|
+
const fieldMeta = walkFieldMeta.fieldMetaStore;
|
|
9
9
|
function getFieldMetaList(schema) {
|
|
10
|
-
return
|
|
10
|
+
return walkFieldMeta.getFieldMetaListForSchema(schema);
|
|
11
11
|
}
|
|
12
12
|
function withMeta(schema, payload) {
|
|
13
|
-
const existing =
|
|
13
|
+
const existing = walkFieldMeta.getFieldMetaForSchema(schema) ?? {};
|
|
14
14
|
const cloned = schema.clone();
|
|
15
|
-
|
|
15
|
+
walkFieldMeta.fieldMetaStore.add(cloned, { ...existing, ...payload });
|
|
16
16
|
return cloned;
|
|
17
17
|
}
|
|
18
18
|
function getFieldMeta(schema) {
|
|
19
|
-
return
|
|
19
|
+
return walkFieldMeta.getFieldMetaForSchema(schema);
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
let warnedZodCodeMissing = false;
|
|
@@ -516,207 +516,18 @@ function getDiscriminatedUnionFirstOption(schema) {
|
|
|
516
516
|
return options[0];
|
|
517
517
|
}
|
|
518
518
|
|
|
519
|
-
const cyclicSentinel = "<cyclic>";
|
|
520
|
-
function fingerprintZodSchema(schema) {
|
|
521
|
-
const cache = /* @__PURE__ */ new WeakMap();
|
|
522
|
-
const inProgress = /* @__PURE__ */ new WeakSet();
|
|
523
|
-
return visit(schema, cache, inProgress);
|
|
524
|
-
}
|
|
525
|
-
function visit(schema, cache, inProgress) {
|
|
526
|
-
const cached = cache.get(schema);
|
|
527
|
-
if (cached !== void 0) return cached;
|
|
528
|
-
if (inProgress.has(schema)) return cyclicSentinel;
|
|
529
|
-
inProgress.add(schema);
|
|
530
|
-
try {
|
|
531
|
-
const computed = computeFingerprint(schema, cache, inProgress);
|
|
532
|
-
cache.set(schema, computed);
|
|
533
|
-
return computed;
|
|
534
|
-
} finally {
|
|
535
|
-
inProgress.delete(schema);
|
|
536
|
-
}
|
|
537
|
-
}
|
|
538
|
-
function computeFingerprint(schema, cache, inProgress) {
|
|
539
|
-
const kind = kindOf(schema);
|
|
540
|
-
const recurse = (child) => visit(child, cache, inProgress);
|
|
541
|
-
switch (kind) {
|
|
542
|
-
// Kind-only leaves: no further structure to descend into.
|
|
543
|
-
case "boolean":
|
|
544
|
-
case "null":
|
|
545
|
-
case "undefined":
|
|
546
|
-
case "any":
|
|
547
|
-
case "unknown":
|
|
548
|
-
case "nan":
|
|
549
|
-
case "void":
|
|
550
|
-
case "never":
|
|
551
|
-
return kind;
|
|
552
|
-
// Leaves with checks (min/max/email/regex/...). Checks are
|
|
553
|
-
// canonicalised and sorted so `.min(3).max(10)` and `.max(10).min(3)`
|
|
554
|
-
// produce identical fingerprints.
|
|
555
|
-
case "string":
|
|
556
|
-
case "number":
|
|
557
|
-
case "bigint":
|
|
558
|
-
case "date":
|
|
559
|
-
return `${kind}${formatChecks(schema)}`;
|
|
560
|
-
case "literal": {
|
|
561
|
-
const values = [...getLiteralValues(schema)].sort((a, b) => {
|
|
562
|
-
const as = canonicalStringify(a);
|
|
563
|
-
const bs = canonicalStringify(b);
|
|
564
|
-
return as < bs ? -1 : as > bs ? 1 : 0;
|
|
565
|
-
});
|
|
566
|
-
return `literal:${canonicalStringify(values)}`;
|
|
567
|
-
}
|
|
568
|
-
case "enum":
|
|
569
|
-
return `enum:${canonicalStringify([...getEnumValues(schema)].sort((a, b) => compare(a, b)))}`;
|
|
570
|
-
case "object": {
|
|
571
|
-
const shape = getObjectShape(schema);
|
|
572
|
-
const sortedEntries = Object.entries(shape).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([k, v]) => `${JSON.stringify(k)}:${recurse(v)}`);
|
|
573
|
-
return `object{${sortedEntries.join(",")}}${formatChecks(schema)}`;
|
|
574
|
-
}
|
|
575
|
-
case "array":
|
|
576
|
-
return `array[${recurse(getArrayElement(schema))}]${formatChecks(schema)}`;
|
|
577
|
-
case "set":
|
|
578
|
-
return `set<${recurse(getSetValueType(schema))}>${formatChecks(schema)}`;
|
|
579
|
-
case "tuple":
|
|
580
|
-
return `tuple[${getTupleItems(schema).map(recurse).join(",")}]`;
|
|
581
|
-
case "record":
|
|
582
|
-
return `record<${recurse(getRecordKeyType(schema))},${recurse(getRecordValueType(schema))}>`;
|
|
583
|
-
case "union": {
|
|
584
|
-
const options = getUnionOptions(schema).map(recurse).sort();
|
|
585
|
-
return `union(${options.join("|")})`;
|
|
586
|
-
}
|
|
587
|
-
case "discriminated-union": {
|
|
588
|
-
const disc = getDiscriminator(schema) ?? "?";
|
|
589
|
-
const options = getDiscriminatedOptions(schema).map(recurse).sort();
|
|
590
|
-
return `dunion[${JSON.stringify(disc)}](${options.join("|")})`;
|
|
591
|
-
}
|
|
592
|
-
case "optional": {
|
|
593
|
-
const inner = unwrapInner(schema);
|
|
594
|
-
return inner === void 0 ? "optional(?)" : `optional(${recurse(inner)})`;
|
|
595
|
-
}
|
|
596
|
-
case "nullable": {
|
|
597
|
-
const inner = unwrapInner(schema);
|
|
598
|
-
return inner === void 0 ? "nullable(?)" : `nullable(${recurse(inner)})`;
|
|
599
|
-
}
|
|
600
|
-
case "default": {
|
|
601
|
-
const inner = unwrapInner(schema);
|
|
602
|
-
return `default[${stableValueRepr(getDefaultValue, schema)}](${inner === void 0 ? "?" : recurse(inner)})`;
|
|
603
|
-
}
|
|
604
|
-
case "readonly": {
|
|
605
|
-
const inner = unwrapInner(schema);
|
|
606
|
-
return inner === void 0 ? "readonly(?)" : `readonly(${recurse(inner)})`;
|
|
607
|
-
}
|
|
608
|
-
case "pipe": {
|
|
609
|
-
const inner = unwrapPipe(schema);
|
|
610
|
-
return inner === void 0 ? "pipe(?)" : `pipe(${recurse(inner)})`;
|
|
611
|
-
}
|
|
612
|
-
case "catch": {
|
|
613
|
-
const inner = unwrapInner(schema);
|
|
614
|
-
return `catch[${stableValueRepr(getCatchDefault, schema)}](${inner === void 0 ? "?" : recurse(inner)})`;
|
|
615
|
-
}
|
|
616
|
-
case "lazy": {
|
|
617
|
-
const inner = unwrapLazy(schema);
|
|
618
|
-
return inner === void 0 ? "lazy(?)" : `lazy(${recurse(inner)})`;
|
|
619
|
-
}
|
|
620
|
-
case "intersection": {
|
|
621
|
-
const left = getIntersectionLeft(schema);
|
|
622
|
-
const right = getIntersectionRight(schema);
|
|
623
|
-
const leftFp = left === void 0 ? "?" : recurse(left);
|
|
624
|
-
const rightFp = right === void 0 ? "?" : recurse(right);
|
|
625
|
-
const parts = [leftFp, rightFp].sort();
|
|
626
|
-
return `intersection(${parts.join("&")})`;
|
|
627
|
-
}
|
|
628
|
-
// Structural shape isn't observable for these. Bucket them into
|
|
629
|
-
// kind-only fingerprints — a schema-mismatch warning can't do
|
|
630
|
-
// better than "both are `custom`" here, but that still catches
|
|
631
|
-
// `object` vs `custom` mismatches. `map` / `symbol` / `function`
|
|
632
|
-
// are rejected at adapter construction; kept here for exhaustive
|
|
633
|
-
// switch safety when `fingerprintSchema` is called from tooling.
|
|
634
|
-
case "promise":
|
|
635
|
-
case "custom":
|
|
636
|
-
case "template-literal":
|
|
637
|
-
case "transform":
|
|
638
|
-
case "file":
|
|
639
|
-
case "map":
|
|
640
|
-
case "symbol":
|
|
641
|
-
case "function":
|
|
642
|
-
return `${kind}:*`;
|
|
643
|
-
default: {
|
|
644
|
-
const _ = kind;
|
|
645
|
-
return `unknown:${String(_)}`;
|
|
646
|
-
}
|
|
647
|
-
}
|
|
648
|
-
}
|
|
649
|
-
function stableValueRepr(get, schema) {
|
|
650
|
-
const first = get(schema);
|
|
651
|
-
const second = get(schema);
|
|
652
|
-
if (!Object.is(first, second) || typeof first === "function") return "fn:*";
|
|
653
|
-
return canonicalStringify(first);
|
|
654
|
-
}
|
|
655
|
-
function formatChecks(schema) {
|
|
656
|
-
const checks = getChecks(schema);
|
|
657
|
-
if (checks.length === 0) return "";
|
|
658
|
-
const parts = checks.map((c) => serializeCheck(c)).sort();
|
|
659
|
-
return `[${parts.join(";")}]`;
|
|
660
|
-
}
|
|
661
|
-
function serializeCheck(check) {
|
|
662
|
-
if (check !== null && typeof check === "object") {
|
|
663
|
-
const def = check._zod?.def;
|
|
664
|
-
if (def !== void 0) return canonicalStringify(def);
|
|
665
|
-
}
|
|
666
|
-
return canonicalStringify(check);
|
|
667
|
-
}
|
|
668
|
-
function canonicalStringify(value, seen = /* @__PURE__ */ new WeakSet()) {
|
|
669
|
-
if (value === null) return "null";
|
|
670
|
-
if (value === void 0) return "undefined";
|
|
671
|
-
const t = typeof value;
|
|
672
|
-
if (t === "string") return JSON.stringify(value);
|
|
673
|
-
if (t === "number" || t === "boolean") return String(value);
|
|
674
|
-
if (t === "bigint") return `${String(value)}n`;
|
|
675
|
-
if (t === "function") return "fn:*";
|
|
676
|
-
if (t === "symbol") return "symbol:*";
|
|
677
|
-
if (Array.isArray(value)) {
|
|
678
|
-
if (seen.has(value)) return "<cyclic>";
|
|
679
|
-
seen.add(value);
|
|
680
|
-
try {
|
|
681
|
-
const parts = value.map((v) => canonicalStringify(v, seen));
|
|
682
|
-
return `[${parts.join(",")}]`;
|
|
683
|
-
} finally {
|
|
684
|
-
seen.delete(value);
|
|
685
|
-
}
|
|
686
|
-
}
|
|
687
|
-
if (t === "object") {
|
|
688
|
-
const obj = value;
|
|
689
|
-
if (seen.has(obj)) return "<cyclic>";
|
|
690
|
-
seen.add(obj);
|
|
691
|
-
try {
|
|
692
|
-
if (value instanceof Date) return `date:${value.getTime()}`;
|
|
693
|
-
if (value instanceof RegExp) return `regex:${String(value)}`;
|
|
694
|
-
const entries = Object.entries(obj).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([k, v]) => `${JSON.stringify(k)}:${canonicalStringify(v, seen)}`);
|
|
695
|
-
return `{${entries.join(",")}}`;
|
|
696
|
-
} finally {
|
|
697
|
-
seen.delete(obj);
|
|
698
|
-
}
|
|
699
|
-
}
|
|
700
|
-
return "unknown";
|
|
701
|
-
}
|
|
702
|
-
function compare(a, b) {
|
|
703
|
-
const as = String(a);
|
|
704
|
-
const bs = String(b);
|
|
705
|
-
return as < bs ? -1 : as > bs ? 1 : 0;
|
|
706
|
-
}
|
|
707
|
-
|
|
708
519
|
const V4_INTROSPECTOR = {
|
|
709
520
|
kindOf: (schema) => kindOf(schema),
|
|
710
521
|
getObjectShape: (schema) => getObjectShape(schema),
|
|
711
|
-
getTupleItems
|
|
522
|
+
getTupleItems,
|
|
712
523
|
getDiscriminatedOptions: (schema) => getDiscriminatedOptions(schema),
|
|
713
|
-
getDiscriminator
|
|
714
|
-
getLiteralValues
|
|
715
|
-
isPreprocessNode
|
|
716
|
-
isCoercePrimitive
|
|
717
|
-
containsAsyncRefine
|
|
718
|
-
containsAsyncTransform
|
|
719
|
-
hasContainerOrRootRefine
|
|
524
|
+
getDiscriminator,
|
|
525
|
+
getLiteralValues,
|
|
526
|
+
isPreprocessNode,
|
|
527
|
+
isCoercePrimitive,
|
|
528
|
+
containsAsyncRefine,
|
|
529
|
+
containsAsyncTransform,
|
|
530
|
+
hasContainerOrRootRefine,
|
|
720
531
|
// Walker accessors (D2 / D3 / D5).
|
|
721
532
|
getArrayElement: (schema) => {
|
|
722
533
|
if (kindOf(schema) !== "array") return void 0;
|
|
@@ -725,35 +536,35 @@ const V4_INTROSPECTOR = {
|
|
|
725
536
|
getSetValueType: (schema) => kindOf(schema) === "set" ? getSetValueType(schema) : void 0,
|
|
726
537
|
getRecordKeyType: (schema) => kindOf(schema) === "record" ? getRecordKeyType(schema) : void 0,
|
|
727
538
|
getRecordValueType: (schema) => kindOf(schema) === "record" ? getRecordValueType(schema) : void 0,
|
|
728
|
-
getUnionOptions
|
|
729
|
-
getIntersectionLeft
|
|
730
|
-
getIntersectionRight
|
|
731
|
-
getEnumValues
|
|
732
|
-
getNativeEnumValues
|
|
733
|
-
unwrapInner
|
|
734
|
-
unwrapBranded
|
|
735
|
-
unwrapEffectsSource
|
|
736
|
-
unwrapPipeIn
|
|
737
|
-
unwrapPipeOut
|
|
738
|
-
unwrapLazy
|
|
739
|
-
getLazyGetter
|
|
740
|
-
getDefaultValue
|
|
741
|
-
getCatchDefault
|
|
742
|
-
hasCatchValue
|
|
539
|
+
getUnionOptions,
|
|
540
|
+
getIntersectionLeft,
|
|
541
|
+
getIntersectionRight,
|
|
542
|
+
getEnumValues,
|
|
543
|
+
getNativeEnumValues,
|
|
544
|
+
unwrapInner,
|
|
545
|
+
unwrapBranded,
|
|
546
|
+
unwrapEffectsSource,
|
|
547
|
+
unwrapPipeIn,
|
|
548
|
+
unwrapPipeOut,
|
|
549
|
+
unwrapLazy,
|
|
550
|
+
getLazyGetter,
|
|
551
|
+
getDefaultValue,
|
|
552
|
+
getCatchDefault,
|
|
553
|
+
hasCatchValue
|
|
743
554
|
};
|
|
744
555
|
|
|
745
556
|
function slimPrimitivesOf(schema, maxRecursionDepth) {
|
|
746
|
-
return new Set(
|
|
557
|
+
return new Set(walkFieldMeta.slimPrimitivesWalk(schema, V4_INTROSPECTOR, maxRecursionDepth));
|
|
747
558
|
}
|
|
748
559
|
|
|
749
560
|
const PATH_SEPARATOR = ".";
|
|
750
561
|
function getNestedZodSchemasAtPath(schema, path, maxRecursionDepth) {
|
|
751
562
|
if (Array.isArray(path)) {
|
|
752
|
-
return
|
|
563
|
+
return walkFieldMeta.walkPathSegments(schema, path.map(String), V4_INTROSPECTOR, maxRecursionDepth, 0);
|
|
753
564
|
}
|
|
754
565
|
const pathString = path;
|
|
755
566
|
if (pathString.length === 0) return [schema];
|
|
756
|
-
return
|
|
567
|
+
return walkFieldMeta.walkPathSegments(
|
|
757
568
|
schema,
|
|
758
569
|
pathString.split(PATH_SEPARATOR),
|
|
759
570
|
V4_INTROSPECTOR,
|
|
@@ -1156,7 +967,7 @@ function walkSlim(schema, stripConfig, maxDepth, lazyDepth) {
|
|
|
1156
967
|
}
|
|
1157
968
|
|
|
1158
969
|
function deriveDefault(schema, useDefault, maxRecursionDepth) {
|
|
1159
|
-
return
|
|
970
|
+
return walkFieldMeta.deriveDefaultWalk(schema, useDefault, V4_INTROSPECTOR, maxRecursionDepth, {
|
|
1160
971
|
// v4 has an exhaustive switch against `SchemaIntrospector.kindOf`;
|
|
1161
972
|
// unknown kinds genuinely shouldn't appear, so return undefined.
|
|
1162
973
|
unsupportedKindFallback: () => void 0,
|
|
@@ -1170,7 +981,7 @@ function deriveDefault(schema, useDefault, maxRecursionDepth) {
|
|
|
1170
981
|
function getDefaultValuesFromZodSchema(opts) {
|
|
1171
982
|
const { schema, useDefaultSchemaValues, constraints, maxRecursionDepth } = opts;
|
|
1172
983
|
const initial = deriveDefault(schema, useDefaultSchemaValues, maxRecursionDepth);
|
|
1173
|
-
const merged =
|
|
984
|
+
const merged = walkFieldMeta.mergeDeep(initial, constraints);
|
|
1174
985
|
const slimSchema = getSlimSchema(
|
|
1175
986
|
schema,
|
|
1176
987
|
{
|
|
@@ -1319,7 +1130,7 @@ function isLeafRequired(schema, depth = 0) {
|
|
|
1319
1130
|
function zodV4Adapter(rootSchema) {
|
|
1320
1131
|
assertZodVersion(rootSchema);
|
|
1321
1132
|
assertSupportedKinds(rootSchema);
|
|
1322
|
-
return (formKey, options) =>
|
|
1133
|
+
return (formKey, options) => walkFieldMeta.createAbstractSchema(
|
|
1323
1134
|
rootSchema,
|
|
1324
1135
|
V4_INTROSPECTOR,
|
|
1325
1136
|
buildV4Services(),
|
|
@@ -1327,9 +1138,13 @@ function zodV4Adapter(rootSchema) {
|
|
|
1327
1138
|
options
|
|
1328
1139
|
);
|
|
1329
1140
|
}
|
|
1141
|
+
async function lazyFingerprint(schema) {
|
|
1142
|
+
const { fingerprintZodSchema } = await import('../chunks/fingerprint2.cjs');
|
|
1143
|
+
return fingerprintZodSchema(schema);
|
|
1144
|
+
}
|
|
1330
1145
|
function buildV4Services() {
|
|
1331
1146
|
return {
|
|
1332
|
-
fingerprint: (schema) =>
|
|
1147
|
+
fingerprint: (schema) => lazyFingerprint(schema),
|
|
1333
1148
|
getNestedSchemasAtPath: (schema, path, maxRecursionDepth) => getNestedZodSchemasAtPath(schema, path, maxRecursionDepth),
|
|
1334
1149
|
// v4 doesn't pre-strip for the slim-mode walk — its path walker
|
|
1335
1150
|
// already peels every transparent wrapper inline, so the slim and
|
|
@@ -1386,7 +1201,7 @@ function runStrictGetDefaultsV4(rootSchema, config, formKey, maxRecursionDepth)
|
|
|
1386
1201
|
}
|
|
1387
1202
|
function buildSubSchemaStubV4(schema, formKey, maxRecursionDepth) {
|
|
1388
1203
|
return {
|
|
1389
|
-
fingerprint: () =>
|
|
1204
|
+
fingerprint: () => lazyFingerprint(schema),
|
|
1390
1205
|
needsAsyncValidation: () => containsAsyncRefine(schema),
|
|
1391
1206
|
getDefaultValues: () => ({
|
|
1392
1207
|
data: deriveDefault(schema, true, maxRecursionDepth),
|
|
@@ -1414,178 +1229,6 @@ function buildSubSchemaStubV4(schema, formKey, maxRecursionDepth) {
|
|
|
1414
1229
|
}
|
|
1415
1230
|
};
|
|
1416
1231
|
}
|
|
1417
|
-
const pathMetaCache = /* @__PURE__ */ new WeakMap();
|
|
1418
|
-
function getPathMetaMap(rootSchema) {
|
|
1419
|
-
const cached = pathMetaCache.get(rootSchema);
|
|
1420
|
-
if (cached !== void 0) return cached;
|
|
1421
|
-
const map = /* @__PURE__ */ new Map();
|
|
1422
|
-
const counters = /* @__PURE__ */ new Map();
|
|
1423
|
-
const lastPathPerSchema = /* @__PURE__ */ new Map();
|
|
1424
|
-
const inProgress = /* @__PURE__ */ new WeakSet();
|
|
1425
|
-
walkForMeta(rootSchema, [], map, counters, lastPathPerSchema, inProgress);
|
|
1426
|
-
for (const [schema, lastPath] of lastPathPerSchema) {
|
|
1427
|
-
const list = getFieldMetaList(schema);
|
|
1428
|
-
const consumed = counters.get(schema) ?? 0;
|
|
1429
|
-
if (list.length <= consumed) continue;
|
|
1430
|
-
const surplus = list.slice(consumed).reduce((acc, p) => ({ ...acc, ...p }), {});
|
|
1431
|
-
const existing = map.get(lastPath) ?? {};
|
|
1432
|
-
map.set(lastPath, { ...existing, ...surplus });
|
|
1433
|
-
}
|
|
1434
|
-
pathMetaCache.set(rootSchema, map);
|
|
1435
|
-
return map;
|
|
1436
|
-
}
|
|
1437
|
-
function walkForMeta(schema, path, map, counters, lastPathPerSchema, inProgress) {
|
|
1438
|
-
if (inProgress.has(schema)) return;
|
|
1439
|
-
inProgress.add(schema);
|
|
1440
|
-
try {
|
|
1441
|
-
const pathKey = paths.canonicalizePath(path).key;
|
|
1442
|
-
if (!map.has(pathKey)) {
|
|
1443
|
-
const payload = consumePayload(schema, counters);
|
|
1444
|
-
if (payload !== void 0) {
|
|
1445
|
-
map.set(pathKey, payload);
|
|
1446
|
-
lastPathPerSchema.set(schema, pathKey);
|
|
1447
|
-
}
|
|
1448
|
-
}
|
|
1449
|
-
const peeled = peelAllWrappers(schema);
|
|
1450
|
-
if (peeled !== schema && !map.has(pathKey)) {
|
|
1451
|
-
const payload = consumePayload(peeled, counters);
|
|
1452
|
-
if (payload !== void 0) {
|
|
1453
|
-
map.set(pathKey, payload);
|
|
1454
|
-
lastPathPerSchema.set(peeled, pathKey);
|
|
1455
|
-
}
|
|
1456
|
-
}
|
|
1457
|
-
const kind = kindOf(schema);
|
|
1458
|
-
switch (kind) {
|
|
1459
|
-
case "object": {
|
|
1460
|
-
const shape = getObjectShape(schema);
|
|
1461
|
-
for (const [key, child] of Object.entries(shape)) {
|
|
1462
|
-
walkForMeta(child, [...path, key], map, counters, lastPathPerSchema, inProgress);
|
|
1463
|
-
}
|
|
1464
|
-
return;
|
|
1465
|
-
}
|
|
1466
|
-
case "array": {
|
|
1467
|
-
walkForMeta(
|
|
1468
|
-
getArrayElement(schema),
|
|
1469
|
-
[...path, 0],
|
|
1470
|
-
map,
|
|
1471
|
-
counters,
|
|
1472
|
-
lastPathPerSchema,
|
|
1473
|
-
inProgress
|
|
1474
|
-
);
|
|
1475
|
-
return;
|
|
1476
|
-
}
|
|
1477
|
-
case "tuple": {
|
|
1478
|
-
const items = getTupleItems(schema);
|
|
1479
|
-
for (let i = 0; i < items.length; i++) {
|
|
1480
|
-
const item = items[i];
|
|
1481
|
-
if (item !== void 0)
|
|
1482
|
-
walkForMeta(item, [...path, i], map, counters, lastPathPerSchema, inProgress);
|
|
1483
|
-
}
|
|
1484
|
-
return;
|
|
1485
|
-
}
|
|
1486
|
-
case "set":
|
|
1487
|
-
walkForMeta(
|
|
1488
|
-
getSetValueType(schema),
|
|
1489
|
-
[...path, 0],
|
|
1490
|
-
map,
|
|
1491
|
-
counters,
|
|
1492
|
-
lastPathPerSchema,
|
|
1493
|
-
inProgress
|
|
1494
|
-
);
|
|
1495
|
-
return;
|
|
1496
|
-
case "record":
|
|
1497
|
-
walkForMeta(
|
|
1498
|
-
getRecordValueType(schema),
|
|
1499
|
-
[...path, "*"],
|
|
1500
|
-
map,
|
|
1501
|
-
counters,
|
|
1502
|
-
lastPathPerSchema,
|
|
1503
|
-
inProgress
|
|
1504
|
-
);
|
|
1505
|
-
return;
|
|
1506
|
-
case "union": {
|
|
1507
|
-
for (const opt of getUnionOptions(schema)) {
|
|
1508
|
-
walkForMeta(opt, path, map, counters, lastPathPerSchema, inProgress);
|
|
1509
|
-
}
|
|
1510
|
-
return;
|
|
1511
|
-
}
|
|
1512
|
-
case "discriminated-union": {
|
|
1513
|
-
for (const opt of getDiscriminatedOptions(schema)) {
|
|
1514
|
-
walkForMeta(opt, path, map, counters, lastPathPerSchema, inProgress);
|
|
1515
|
-
}
|
|
1516
|
-
return;
|
|
1517
|
-
}
|
|
1518
|
-
case "optional":
|
|
1519
|
-
case "nullable":
|
|
1520
|
-
case "default":
|
|
1521
|
-
case "readonly":
|
|
1522
|
-
case "catch": {
|
|
1523
|
-
const inner = unwrapInner(schema);
|
|
1524
|
-
if (inner !== void 0)
|
|
1525
|
-
walkForMeta(inner, path, map, counters, lastPathPerSchema, inProgress);
|
|
1526
|
-
return;
|
|
1527
|
-
}
|
|
1528
|
-
case "pipe": {
|
|
1529
|
-
const inner = unwrapPipe(schema);
|
|
1530
|
-
if (inner !== void 0)
|
|
1531
|
-
walkForMeta(inner, path, map, counters, lastPathPerSchema, inProgress);
|
|
1532
|
-
return;
|
|
1533
|
-
}
|
|
1534
|
-
case "lazy": {
|
|
1535
|
-
const inner = unwrapLazy(schema);
|
|
1536
|
-
if (inner !== void 0)
|
|
1537
|
-
walkForMeta(inner, path, map, counters, lastPathPerSchema, inProgress);
|
|
1538
|
-
return;
|
|
1539
|
-
}
|
|
1540
|
-
case "intersection": {
|
|
1541
|
-
const left = getIntersectionLeft(schema);
|
|
1542
|
-
const right = getIntersectionRight(schema);
|
|
1543
|
-
if (left !== void 0)
|
|
1544
|
-
walkForMeta(left, path, map, counters, lastPathPerSchema, inProgress);
|
|
1545
|
-
if (right !== void 0)
|
|
1546
|
-
walkForMeta(right, path, map, counters, lastPathPerSchema, inProgress);
|
|
1547
|
-
return;
|
|
1548
|
-
}
|
|
1549
|
-
// Leaf kinds — no children to descend into; metadata for the
|
|
1550
|
-
// path itself was captured above. Listed explicitly so the
|
|
1551
|
-
// exhaustiveness check catches any new kind landing in Zod
|
|
1552
|
-
// without a corresponding decision here.
|
|
1553
|
-
case "string":
|
|
1554
|
-
case "number":
|
|
1555
|
-
case "bigint":
|
|
1556
|
-
case "boolean":
|
|
1557
|
-
case "date":
|
|
1558
|
-
case "enum":
|
|
1559
|
-
case "literal":
|
|
1560
|
-
case "null":
|
|
1561
|
-
case "undefined":
|
|
1562
|
-
case "any":
|
|
1563
|
-
case "unknown":
|
|
1564
|
-
case "nan":
|
|
1565
|
-
case "void":
|
|
1566
|
-
case "never":
|
|
1567
|
-
case "promise":
|
|
1568
|
-
case "custom":
|
|
1569
|
-
case "template-literal":
|
|
1570
|
-
case "transform":
|
|
1571
|
-
case "file":
|
|
1572
|
-
case "map":
|
|
1573
|
-
case "symbol":
|
|
1574
|
-
case "function":
|
|
1575
|
-
return;
|
|
1576
|
-
}
|
|
1577
|
-
} finally {
|
|
1578
|
-
inProgress.delete(schema);
|
|
1579
|
-
}
|
|
1580
|
-
}
|
|
1581
|
-
function consumePayload(schema, counters) {
|
|
1582
|
-
const list = getFieldMetaList(schema);
|
|
1583
|
-
if (list.length === 0) return void 0;
|
|
1584
|
-
const idx = counters.get(schema) ?? 0;
|
|
1585
|
-
const payload = list[Math.min(idx, list.length - 1)];
|
|
1586
|
-
counters.set(schema, idx + 1);
|
|
1587
|
-
return payload;
|
|
1588
|
-
}
|
|
1589
1232
|
function resolveFieldMetaAtPath(rootSchema, path, maxRecursionDepth) {
|
|
1590
1233
|
const lastSegment = path.length === 0 ? "" : path[path.length - 1];
|
|
1591
1234
|
const candidates = path.length === 0 ? [rootSchema] : getNestedZodSchemasAtPath(rootSchema, path, maxRecursionDepth);
|
|
@@ -1598,7 +1241,11 @@ function resolveFieldMetaAtPath(rootSchema, path, maxRecursionDepth) {
|
|
|
1598
1241
|
meta: Object.freeze({})
|
|
1599
1242
|
};
|
|
1600
1243
|
}
|
|
1601
|
-
const pathMap =
|
|
1244
|
+
const pathMap = walkFieldMeta.getFieldMetaPathMap(rootSchema, {
|
|
1245
|
+
intro: V4_INTROSPECTOR,
|
|
1246
|
+
peelAllWrappers,
|
|
1247
|
+
getFieldMetaList
|
|
1248
|
+
});
|
|
1602
1249
|
const pathKey = paths.canonicalizePath(path).key;
|
|
1603
1250
|
const peeled = peelAllWrappers(target);
|
|
1604
1251
|
const payload = pathMap.get(pathKey) ?? getFieldMeta(target) ?? (peeled !== target ? getFieldMeta(peeled) : void 0);
|
|
@@ -1632,8 +1279,27 @@ function useForm(configuration) {
|
|
|
1632
1279
|
exports.UnsupportedSchemaError = UnsupportedSchemaError;
|
|
1633
1280
|
exports.assertZodVersion = assertZodVersion;
|
|
1634
1281
|
exports.fieldMeta = fieldMeta;
|
|
1282
|
+
exports.getArrayElement = getArrayElement;
|
|
1283
|
+
exports.getCatchDefault = getCatchDefault;
|
|
1284
|
+
exports.getChecks = getChecks;
|
|
1285
|
+
exports.getDefaultValue = getDefaultValue;
|
|
1286
|
+
exports.getDiscriminatedOptions = getDiscriminatedOptions;
|
|
1287
|
+
exports.getDiscriminator = getDiscriminator;
|
|
1288
|
+
exports.getEnumValues = getEnumValues;
|
|
1289
|
+
exports.getIntersectionLeft = getIntersectionLeft;
|
|
1290
|
+
exports.getIntersectionRight = getIntersectionRight;
|
|
1291
|
+
exports.getLiteralValues = getLiteralValues;
|
|
1292
|
+
exports.getObjectShape = getObjectShape;
|
|
1293
|
+
exports.getRecordKeyType = getRecordKeyType;
|
|
1294
|
+
exports.getRecordValueType = getRecordValueType;
|
|
1295
|
+
exports.getSetValueType = getSetValueType;
|
|
1296
|
+
exports.getTupleItems = getTupleItems;
|
|
1297
|
+
exports.getUnionOptions = getUnionOptions;
|
|
1635
1298
|
exports.kindOf = kindOf;
|
|
1299
|
+
exports.unwrapInner = unwrapInner;
|
|
1300
|
+
exports.unwrapLazy = unwrapLazy;
|
|
1301
|
+
exports.unwrapPipe = unwrapPipe;
|
|
1636
1302
|
exports.useForm = useForm;
|
|
1637
1303
|
exports.withMeta = withMeta;
|
|
1638
1304
|
exports.zodV4Adapter = zodV4Adapter;
|
|
1639
|
-
//# sourceMappingURL=attaform.
|
|
1305
|
+
//# sourceMappingURL=attaform.PnqML3xW.cjs.map
|