attaform 0.29.0 → 0.30.1

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 (79) hide show
  1. package/dist/abstract.d.mts +15 -21
  2. package/dist/abstract.mjs +4 -4
  3. package/dist/dev/abstract.mjs +4 -4
  4. package/dist/dev/chunks/dev-key-collision-warnings.mjs +47 -8
  5. package/dist/dev/chunks/devtools.mjs +2 -2
  6. package/dist/dev/directive.mjs +1 -1
  7. package/dist/dev/history.mjs +1 -2
  8. package/dist/dev/index.mjs +5 -5
  9. package/dist/dev/runtime/plugins/attaform.mjs +3 -3
  10. package/dist/dev/shared/{attaform-dev.BO-71R54.mjs → attaform-dev.BJK1kqHY.mjs} +44 -198
  11. package/dist/dev/shared/{attaform-dev.D8aoKb89.mjs → attaform-dev.BMQ3GcgD.mjs} +51 -64
  12. package/dist/dev/shared/{attaform-dev.BgM6FdtA.mjs → attaform-dev.BUIFcTYf.mjs} +94 -62
  13. package/dist/dev/shared/{attaform-dev.q6UutkCx.mjs → attaform-dev.CT7MDjPy.mjs} +92 -152
  14. package/dist/dev/shared/{attaform-dev.ButTkwHd.mjs → attaform-dev.CZz4GYZ6.mjs} +26 -15
  15. package/dist/dev/shared/{attaform-dev.DD5m2W51.mjs → attaform-dev.Chm4D6SJ.mjs} +2 -4
  16. package/dist/dev/shared/{attaform-dev.DrzObAZo.mjs → attaform-dev.DuEE4GU1.mjs} +4 -4
  17. package/dist/dev/shared/{attaform-dev.DHuydLAC.mjs → attaform-dev.DxHdkkPG.mjs} +674 -734
  18. package/dist/dev/shared/{attaform-dev.A-TpJW0B.mjs → attaform-dev.zlvDr0WB.mjs} +3 -21
  19. package/dist/dev/zod-v3.mjs +6 -6
  20. package/dist/dev/zod-v4.mjs +6 -6
  21. package/dist/dev/zod.mjs +5 -5
  22. package/dist/directive.d.mts +4 -4
  23. package/dist/directive.mjs +1 -1
  24. package/dist/esbuild.d.mts +11 -0
  25. package/dist/esbuild.mjs +1 -1
  26. package/dist/history.d.mts +3 -32
  27. package/dist/history.mjs +1 -2
  28. package/dist/index.d.mts +67 -70
  29. package/dist/index.mjs +5 -5
  30. package/dist/nuxt.d.mts +6 -14
  31. package/dist/nuxt.mjs +3 -7
  32. package/dist/rollup.d.mts +11 -0
  33. package/dist/rollup.mjs +1 -1
  34. package/dist/rspack.d.mts +19 -11
  35. package/dist/rspack.mjs +1 -1
  36. package/dist/runtime/components/AttaformDevtoolsPanel.vue +12 -12
  37. package/dist/runtime/components/DevtoolsValueTree.vue +2 -2
  38. package/dist/runtime/plugins/attaform.mjs +3 -3
  39. package/dist/shared/{attaform.CIWLMY-R.d.mts → attaform.2FslhB9R.d.mts} +83 -95
  40. package/dist/shared/{attaform.Cvao8bW5.mjs → attaform.8mfKZCwH.mjs} +7 -7
  41. package/dist/shared/{attaform.DRUT703x.d.mts → attaform.B-Tb62qV.d.mts} +12 -12
  42. package/dist/shared/{attaform.v0fQtWyA.mjs → attaform.B1rH9ht6.mjs} +1 -1
  43. package/dist/shared/{attaform.BndjUUYX.mjs → attaform.B2iebkPA.mjs} +4 -4
  44. package/dist/shared/{attaform.DhnPb6nK.mjs → attaform.BAf3UNn4.mjs} +1 -1
  45. package/dist/shared/{attaform.CZMAYwSK.mjs → attaform.BIWicztt.mjs} +651 -678
  46. package/dist/shared/attaform.BcQwgWaq.d.mts +2153 -0
  47. package/dist/shared/attaform.Br8EBn5B.d.mts +4553 -0
  48. package/dist/shared/{attaform.C2MVyuxC.mjs → attaform.CO918TdU.mjs} +44 -198
  49. package/dist/shared/{attaform.CZYt_5N_.mjs → attaform.CdZIEf7_.mjs} +1 -19
  50. package/dist/shared/{attaform.B0dKL8ST.mjs → attaform.DRsANMok.mjs} +94 -62
  51. package/dist/shared/{attaform.DffRL5pP.mjs → attaform.D_f1WgYf.mjs} +46 -59
  52. package/dist/shared/{attaform.D1fnTifF.mjs → attaform.D_pt1gOj.mjs} +92 -150
  53. package/dist/shared/attaform.L0kUn3vL.d.mts +42 -0
  54. package/dist/shared/{attaform.D0x-qSXm.mjs → attaform.WiGdIqgx.mjs} +1 -3
  55. package/dist/shared/{attaform.BK0cgu2K.mjs → attaform.ZYn2ahzJ.mjs} +3 -3
  56. package/dist/transforms.d.mts +153 -26
  57. package/dist/transforms.mjs +1 -1
  58. package/dist/vite.d.mts +29 -52
  59. package/dist/vite.mjs +8 -3
  60. package/dist/webpack.d.mts +20 -12
  61. package/dist/webpack.mjs +1 -1
  62. package/dist/zod-v3.d.mts +90 -96
  63. package/dist/zod-v3.mjs +6 -6
  64. package/dist/zod-v4.d.mts +119 -119
  65. package/dist/zod-v4.mjs +6 -6
  66. package/dist/zod.d.mts +5 -5
  67. package/dist/zod.mjs +5 -5
  68. package/package.json +9 -7
  69. package/skills/attaform/SKILL.md +1 -1
  70. package/skills/attaform/references/custom-components.md +1 -1
  71. package/dist/chunks/fingerprint.mjs +0 -183
  72. package/dist/chunks/fingerprint2.mjs +0 -159
  73. package/dist/dev/chunks/fingerprint.mjs +0 -183
  74. package/dist/dev/chunks/fingerprint2.mjs +0 -159
  75. package/dist/dev/shared/attaform-dev.BxfsuwBR.mjs +0 -44
  76. package/dist/shared/attaform.BxfsuwBR.mjs +0 -44
  77. package/dist/shared/attaform.CsoeRi3P.d.mts +0 -5155
  78. package/dist/shared/attaform.DDtqHYv1.d.mts +0 -2465
  79. package/dist/shared/attaform.axHXVQO7.d.mts +0 -44
@@ -1,7 +1,7 @@
1
- import { w as walkPathSegments, s as slimPrimitivesWalk, c as createAbstractSchema, b as buildFieldMetaPathMap, g as getFieldMetaForSchema, m as mergeDeep, f as fixStructuralDefaults, d as deriveDefaultWalk, a as getFieldMetaListForSchema } from './attaform-dev.BgM6FdtA.mjs';
2
- import { p as getAtPath, q as humanize, h as useAbstractForm } from './attaform-dev.DHuydLAC.mjs';
3
- import { c as callConsumerSchemaFn } from './attaform-dev.ButTkwHd.mjs';
4
- import { A as AttaformError, e as canonicalizePath, a as InvalidUseFormConfigError } from './attaform-dev.A-TpJW0B.mjs';
1
+ import { w as walkPathSegments, s as slimPrimitivesWalk, c as createAbstractSchema, a as createSharedSchemaStore, b as buildFieldMetaPathMap, g as getFieldMetaForSchema, f as fixStructuralDefaults, m as mergeDeep, d as deriveDefaultWalk, e as getFieldMetaListForSchema } from './attaform-dev.BUIFcTYf.mjs';
2
+ import { h as getAtPath, j as humanize, c as useAbstractForm } from './attaform-dev.DxHdkkPG.mjs';
3
+ import { c as callConsumerFn } from './attaform-dev.CZz4GYZ6.mjs';
4
+ import { A as AttaformError, e as canonicalizePath, a as InvalidUseFormConfigError } from './attaform-dev.zlvDr0WB.mjs';
5
5
 
6
6
  function isZodSchemaType(schema, expectedType) {
7
7
  if (typeof schema !== "object" || schema === null) return false;
@@ -127,22 +127,29 @@ function getTupleItems(schema) {
127
127
  const def = readDef(schema);
128
128
  return def?.items ?? [];
129
129
  }
130
+ function readOptionList(options) {
131
+ if (options === void 0) return [];
132
+ if (options instanceof Map) return [...options.values()];
133
+ return [...options];
134
+ }
130
135
  function getUnionOptions(schema) {
131
- const def = readDef(schema);
132
- return def?.options ?? [];
136
+ return readOptionList(readDef(schema)?.options);
133
137
  }
134
138
  function getDiscriminatedOptions(schema) {
135
- const def = readDef(schema);
136
- return def?.options ?? [];
139
+ return readOptionList(readDef(schema)?.options);
137
140
  }
138
141
  function getDiscriminator(schema) {
139
142
  const def = readDef(schema);
140
143
  return def?.discriminator;
141
144
  }
142
145
  function getDiscriminatedOptionsMap(schema) {
143
- const map = readDef(schema)?.optionsMap;
146
+ const def = readDef(schema);
147
+ const map = def?.optionsMap ?? def?.options;
144
148
  return map instanceof Map ? map : void 0;
145
149
  }
150
+ function discriminatedOptionsAreMapped(schema) {
151
+ return readDef(schema)?.options instanceof Map;
152
+ }
146
153
  function getIntersectionLeft(schema) {
147
154
  const def = readDef(schema);
148
155
  return def?.left;
@@ -299,11 +306,7 @@ function unwrapLazy(schema) {
299
306
  const def = readDef(schema);
300
307
  const getter = def?.getter;
301
308
  if (typeof getter !== "function") return void 0;
302
- return callConsumerSchemaFn(() => getter(), void 0, "lazy-getter");
303
- }
304
- function getLazyGetter(schema) {
305
- const def = readDef(schema);
306
- return typeof def?.getter === "function" ? def.getter : void 0;
309
+ return callConsumerFn(() => getter(), void 0, "lazy-getter");
307
310
  }
308
311
  function getLiteralValues(schema) {
309
312
  const def = readDef(schema);
@@ -320,17 +323,13 @@ function getDefaultValue(schema) {
320
323
  const def = readDef(schema);
321
324
  const thunk = def?.defaultValue;
322
325
  if (typeof thunk !== "function") return void 0;
323
- return callConsumerSchemaFn(() => thunk(), void 0, "default-factory");
326
+ return callConsumerFn(() => thunk(), void 0, "default-factory");
324
327
  }
325
328
  function getCatchDefault(schema) {
326
329
  const def = readDef(schema);
327
330
  const cv = def?.catchValue;
328
331
  if (typeof cv !== "function") return void 0;
329
- return callConsumerSchemaFn(
330
- () => cv({ error: null, input: void 0 }),
331
- void 0,
332
- "catch-factory"
333
- );
332
+ return callConsumerFn(() => cv({ error: null, input: void 0 }), void 0, "catch-factory");
334
333
  }
335
334
  function hasCatchValue(schema) {
336
335
  const def = readDef(schema);
@@ -447,7 +446,6 @@ const V3_INTROSPECTOR = {
447
446
  // Walker accessors (D2 / D3 / D5).
448
447
  getArrayElement,
449
448
  getSetValueType,
450
- getRecordKeyType,
451
449
  getRecordValueType,
452
450
  getMapKeyType: (schema) => kindOf(schema) === "map" ? getMapKeyType(schema) : void 0,
453
451
  getMapValueType: (schema) => kindOf(schema) === "map" ? getMapValueType(schema) : void 0,
@@ -465,7 +463,6 @@ const V3_INTROSPECTOR = {
465
463
  unwrapPipeIn,
466
464
  unwrapPipeOut,
467
465
  unwrapLazy,
468
- getLazyGetter,
469
466
  getDefaultValue,
470
467
  getCatchDefault,
471
468
  hasCatchValue
@@ -601,22 +598,22 @@ function rebuildDiscriminatedUnion(original, options) {
601
598
  if (replacement !== void 0) optionsMap.set(value, replacement);
602
599
  }
603
600
  }
601
+ if (discriminatedOptionsAreMapped(original)) {
602
+ return rebuildWithDef(original, { options: optionsMap });
603
+ }
604
604
  return rebuildWithDef(original, { options, optionsMap });
605
605
  }
606
606
  function rebuildEffects(original, source, effect) {
607
607
  return rebuildWithDef(original, { schema: source, effect });
608
608
  }
609
609
 
610
- function stripAsyncChecks(schema) {
611
- return walkEffects(schema, "strip");
612
- }
613
610
  function wrapAsyncSafeRefinements(schema) {
614
- return walkEffects(schema, "wrap");
611
+ return walkEffects(schema);
615
612
  }
616
613
  function isThenable(value) {
617
614
  return value !== null && (typeof value === "object" || typeof value === "function") && typeof value.then === "function";
618
615
  }
619
- function walkEffects(schema, policy) {
616
+ function walkEffects(schema) {
620
617
  const seen = /* @__PURE__ */ new WeakSet();
621
618
  function recurse(s) {
622
619
  const candidate = s;
@@ -626,7 +623,6 @@ function walkEffects(schema, policy) {
626
623
  if (isZodSchemaType(s, "ZodEffects")) {
627
624
  const inner = unwrapEffectsSource(s);
628
625
  if (inner === void 0) return s;
629
- if (policy === "strip") return recurse(inner);
630
626
  const effect = getEffect(s);
631
627
  const rebuiltInner = recurse(inner);
632
628
  const original = effect?.["refinement"];
@@ -800,18 +796,18 @@ function zodAdapter(zodSchema) {
800
796
  `[attaform/zod-v3] useForm schema root must be a ZodObject, ZodRecord, or ZodDiscriminatedUnion (got '${name}'). Wrap other shapes under a key.`
801
797
  );
802
798
  }
803
- return (formKey, options) => createAbstractSchema(
799
+ return (_formKey, options) => sharedV3Schemas(
804
800
  zodSchema,
805
- V3_INTROSPECTOR,
806
- buildV3Services(options.maxRecursionDepth),
807
- formKey,
808
- options
801
+ options.maxRecursionDepth,
802
+ () => createAbstractSchema(
803
+ zodSchema,
804
+ V3_INTROSPECTOR,
805
+ buildV3Services(options.maxRecursionDepth),
806
+ options
807
+ )
809
808
  );
810
809
  }
811
- async function lazyFingerprint(schema) {
812
- const { fingerprintZodSchema } = await import('../chunks/fingerprint.mjs');
813
- return fingerprintZodSchema(schema);
814
- }
810
+ const sharedV3Schemas = createSharedSchemaStore();
815
811
  const syncSafeCache = /* @__PURE__ */ new WeakMap();
816
812
  function syncSafe(schema) {
817
813
  const cached = syncSafeCache.get(schema);
@@ -832,19 +828,14 @@ function buildV3Services(maxRecursionDepth) {
832
828
  return normalizeIssuePaths(issues, schema, data, maxRecursionDepth, peelAllV3Wrappers);
833
829
  };
834
830
  return {
835
- fingerprint: (schema) => lazyFingerprint(schema),
836
831
  getNestedSchemasAtPath: (schema, path, maxRecursionDepth2) => getNestedZodSchemasAtPath(schema, path, maxRecursionDepth2),
837
- // v3 pre-strips refinements / defaults / wrappers off the root for
838
- // slim-mode walks — `getSlimPrimitiveTypesAtPath` and
839
- // `getSchemasAtPath` both consume this variant so the yielded
840
- // candidates reflect the slim shape.
841
- // The slim-root projection is gone (size-teardown P7): the shared
842
- // path walker peels wrappers / effects inline, so the slim and
843
- // unstripped walks coincide — same aliasing v4 always had.
832
+ // The shared path walker peels wrappers and effects inline, so the
833
+ // slim and unstripped walks coincide and the root needs no slim
834
+ // projection of its own. Same aliasing v4 has.
844
835
  getNestedSchemasInSlimMode: (schema, path, maxRecursionDepth2) => getNestedZodSchemasAtPath(schema, path, maxRecursionDepth2),
845
836
  slimPrimitivesOf: (schema, _maxRecursionDepth) => slimPrimitivesV3(schema),
846
- deriveDefault: (schema, useDefault, _maxRecursionDepth, formKey) => getDefaultValuesFromZodSchema(schema, useDefault, formKey),
847
- runStrictGetDefaults: (schema, config, formKey, maxRecursionDepth2) => runStrictGetDefaultsV3(schema, config, formKey, maxRecursionDepth2),
837
+ deriveDefault: (schema, useDefault) => getDefaultValuesFromZodSchema(schema, useDefault),
838
+ runGetDefaults: (schema, config, maxRecursionDepth2) => runGetDefaultsV3(schema, config, maxRecursionDepth2),
848
839
  unwrapStructuralWrappers: (schema) => unwrapStructuralLeafV3(schema),
849
840
  unwrapToDiscriminatedUnion: (schema) => unwrapToDiscriminatedUnion(schema),
850
841
  peelAllWrappers: (schema) => peelAllV3Wrappers(schema),
@@ -859,15 +850,14 @@ function buildV3Services(maxRecursionDepth) {
859
850
  const result = await schema.safeParseAsync(data);
860
851
  return result.success ? { success: true, data: result.data } : { success: false, issues: refileIssues(schema, data, result.error.issues) };
861
852
  },
862
- // v3 returns the full recursive AbstractSchema for sub-schemas (the
863
- // historical shape) — `getSchemasAtPath` consumers may probe any
864
- // method on the result. The factory call rebuilds the full surface
865
- // against the sub-schema with its own per-form caches.
866
- makeSubSchema: (sub, formKey, maxRecursionDepth2) => createAbstractSchema(
853
+ // A `getSchemasAtPath` consumer may probe any method on the result,
854
+ // so a sub-schema comes back as a full recursive AbstractSchema: the
855
+ // factory call rebuilds the whole surface against it, with its own
856
+ // per-form caches.
857
+ makeSubSchema: (sub, maxRecursionDepth2) => createAbstractSchema(
867
858
  sub,
868
859
  V3_INTROSPECTOR,
869
860
  buildV3Services(maxRecursionDepth2),
870
- formKey,
871
861
  { maxRecursionDepth: maxRecursionDepth2 }
872
862
  )
873
863
  };
@@ -889,17 +879,16 @@ function zodIssuesToValidationErrors(issues) {
889
879
  }
890
880
  validationErrors.push({
891
881
  message: issue.message,
892
- // `ValidationError.path` is `(string | number)[]` per the
893
- // public type. v3's `issue.path` is the same in the standard
894
- // case, but a custom check via `ctx.addIssue({ path: [...] })`
895
- // can smuggle a Symbol through — the public surface promised
896
- // strings/numbers, so coerce defensively to keep the contract.
897
- // Mirrors v4's behaviour at the same site.
882
+ // `ValidationError.path` is `(string | number)[]` publicly, and
883
+ // v3's `issue.path` matches in the standard case, but a custom
884
+ // check calling `ctx.addIssue({ path: [...] })` can smuggle a
885
+ // Symbol through. Coerce to keep the promise. v4 does the same
886
+ // here.
898
887
  //
899
- // Adapter-side paths stay schema-relative — the validation
900
- // pipeline in `create-form-store.ts` prepends the parent path
901
- // to absolutise, then routes form-level (absolute path length 0)
902
- // entries to the empty-string bucket at storage time.
888
+ // Adapter-side paths stay schema-RELATIVE: the validation pipeline
889
+ // in `core/create-form-store.ts` prepends the parent path to
890
+ // absolutise, then routes form-level entries, those whose absolute
891
+ // path is empty, to the empty-string bucket at storage time.
903
892
  path: coercePathSegments(issue.path),
904
893
  code
905
894
  });
@@ -931,10 +920,10 @@ function unwrapStructuralLeafV3(schema) {
931
920
  return current;
932
921
  }
933
922
  function isStructuralV3Kind(schema) {
934
- return isZodSchemaType(schema, "ZodObject") || isZodSchemaType(schema, "ZodArray") || isZodSchemaType(schema, "ZodRecord") || isZodSchemaType(schema, "ZodTuple") || isZodSchemaType(schema, "ZodUnion") || isZodSchemaType(schema, "ZodDiscriminatedUnion") || // Wrappers that themselves resolve to a structural type — keep
935
- // peeling at the next iteration.
936
- isZodSchemaType(schema, "ZodOptional") || isZodSchemaType(schema, "ZodNullable") || isZodSchemaType(schema, "ZodDefault") || isZodSchemaType(schema, "ZodEffects") || // Newer transparent wrappers (v3.23+). Each wraps a single inner
937
- // schema with no structural impact — `peelV3Wrappers` resolves them.
923
+ return isZodSchemaType(schema, "ZodObject") || isZodSchemaType(schema, "ZodArray") || isZodSchemaType(schema, "ZodRecord") || isZodSchemaType(schema, "ZodTuple") || isZodSchemaType(schema, "ZodUnion") || isZodSchemaType(schema, "ZodDiscriminatedUnion") || // Wrappers that themselves resolve to a structural type; keep
924
+ // peeling next iteration.
925
+ isZodSchemaType(schema, "ZodOptional") || isZodSchemaType(schema, "ZodNullable") || isZodSchemaType(schema, "ZodDefault") || isZodSchemaType(schema, "ZodEffects") || // Newer transparent wrappers (v3.23+), each wrapping one inner
926
+ // schema with no structural impact. `peelV3Wrappers` resolves them.
938
927
  isZodSchemaType(schema, "ZodPipeline") || isZodSchemaType(schema, "ZodReadonly") || isZodSchemaType(schema, "ZodBranded");
939
928
  }
940
929
  function peelV3Wrappers(schema) {
@@ -1086,16 +1075,8 @@ function peelAllV3Wrappers(schema) {
1086
1075
  }
1087
1076
  return current;
1088
1077
  }
1089
- function getDefaultValuesFromZodSchema(formSchema, useDefaultSchemaValues, formKey) {
1090
- return deriveDefaultWalk(formSchema, useDefaultSchemaValues, V3_INTROSPECTOR, 64, {
1091
- unsupportedKindFallback: (schema) => {
1092
- const kindName = schema.constructor?.name ?? "unknown";
1093
- console.warn(
1094
- `[attaform] zod-v3 adapter: unsupported schema kind '${kindName}' on form '${formKey}'. Defaulting the field to null. Use a supported zod kind (object/array/record/string/number/etc.) at this path.`
1095
- );
1096
- return null;
1097
- }
1098
- });
1078
+ function getDefaultValuesFromZodSchema(formSchema, useDefaultSchemaValues) {
1079
+ return deriveDefaultWalk(formSchema, useDefaultSchemaValues, V3_INTROSPECTOR, 64);
1099
1080
  }
1100
1081
  function resolveFieldMetaAtPathV3(rootSchema, path, maxRecursionDepth) {
1101
1082
  const lastSegment = path.length === 0 ? "" : path[path.length - 1];
@@ -1126,92 +1107,51 @@ function resolveFieldMetaAtPathV3(rootSchema, path, maxRecursionDepth) {
1126
1107
  meta: Object.freeze({ ...payload ?? {} })
1127
1108
  };
1128
1109
  }
1129
- function runStrictGetDefaultsV3(rootSchema, config, formKey, maxRecursionDepth) {
1110
+ function runGetDefaultsV3(rootSchema, config, maxRecursionDepth) {
1130
1111
  const defaultValuesWithoutConstraints = getDefaultValuesFromZodSchema(
1131
1112
  rootSchema,
1132
- config.useDefaultSchemaValues,
1133
- formKey
1113
+ config.useDefaultSchemaValues
1134
1114
  );
1135
- const rawDefaultValues = mergeDeep(defaultValuesWithoutConstraints, config.constraints);
1136
- if ((config.strict ?? true) !== false) {
1137
- if (containsAsyncTransform(rootSchema)) {
1138
- return {
1139
- data: rawDefaultValues,
1140
- errors: void 0,
1141
- success: true,
1142
- formKey
1143
- };
1144
- }
1145
- try {
1146
- const strictResult = syncSafe(rootSchema).safeParse(rawDefaultValues);
1147
- if (strictResult.success) {
1148
- return {
1149
- data: rawDefaultValues,
1150
- errors: void 0,
1151
- success: true,
1152
- formKey
1153
- };
1154
- }
1155
- return {
1156
- data: rawDefaultValues,
1157
- errors: zodIssuesToValidationErrors(strictResult.error.issues),
1158
- success: false,
1159
- formKey
1160
- };
1161
- } catch (err) {
1162
- const isAsyncDetect = err instanceof Error && err.message.includes("Async refinement encountered");
1163
- if (isAsyncDetect) {
1164
- try {
1165
- const strippedResult = syncSafe(stripAsyncChecks(rootSchema)).safeParse(rawDefaultValues);
1166
- if (strippedResult.success) {
1167
- return {
1168
- data: rawDefaultValues,
1169
- errors: void 0,
1170
- success: true,
1171
- formKey
1172
- };
1173
- }
1174
- return {
1175
- data: rawDefaultValues,
1176
- errors: zodIssuesToValidationErrors(strippedResult.error.issues),
1177
- success: false,
1178
- formKey
1179
- };
1180
- } catch {
1181
- return {
1182
- data: rawDefaultValues,
1183
- errors: void 0,
1184
- success: true,
1185
- formKey
1186
- };
1187
- }
1188
- }
1189
- return {
1190
- data: rawDefaultValues,
1191
- errors: void 0,
1192
- success: true,
1193
- formKey
1194
- };
1195
- }
1196
- }
1197
- const fixed = fixStructuralDefaults(
1115
+ const rawDefaultValues = config.constraints === void 0 ? defaultValuesWithoutConstraints : fixStructuralDefaults(
1198
1116
  rootSchema,
1199
- rawDefaultValues,
1117
+ mergeDeep(defaultValuesWithoutConstraints, config.constraints),
1200
1118
  config.useDefaultSchemaValues,
1201
1119
  maxRecursionDepth,
1202
1120
  {
1203
1121
  intro: V3_INTROSPECTOR,
1204
1122
  slimPrimitivesOf: (s) => slimPrimitivesV3(s),
1205
- deriveDefault: (s, useDefault) => getDefaultValuesFromZodSchema(s, useDefault, formKey),
1123
+ deriveDefault: (s, useDefault) => getDefaultValuesFromZodSchema(s, useDefault),
1206
1124
  unwrapToDiscriminatedUnion: (s) => unwrapToDiscriminatedUnion(s)
1207
1125
  }
1208
- );
1209
- return {
1210
- data: fixed.data,
1211
- errors: void 0,
1212
- success: true,
1213
- formKey
1214
- };
1126
+ ).data;
1127
+ if (containsAsyncTransform(rootSchema)) {
1128
+ return {
1129
+ data: rawDefaultValues,
1130
+ errors: void 0,
1131
+ success: true
1132
+ };
1133
+ }
1134
+ try {
1135
+ const parseResult = syncSafe(rootSchema).safeParse(rawDefaultValues);
1136
+ if (parseResult.success) {
1137
+ return {
1138
+ data: rawDefaultValues,
1139
+ errors: void 0,
1140
+ success: true
1141
+ };
1142
+ }
1143
+ return {
1144
+ data: rawDefaultValues,
1145
+ errors: zodIssuesToValidationErrors(parseResult.error.issues),
1146
+ success: false
1147
+ };
1148
+ } catch {
1149
+ return {
1150
+ data: rawDefaultValues,
1151
+ errors: void 0,
1152
+ success: true
1153
+ };
1154
+ }
1215
1155
  }
1216
1156
 
1217
1157
  function useForm(configuration) {
@@ -1,4 +1,4 @@
1
- import { m as mapSegmentKeys, f as pathsEqual, i as isPathPrefix } from './attaform-dev.A-TpJW0B.mjs';
1
+ import { m as mapSegmentKeys, f as pathsEqual, i as isPathPrefix } from './attaform-dev.zlvDr0WB.mjs';
2
2
 
3
3
  const DEFAULT_FIELD_VALIDATION_DEBOUNCE_MS = 0;
4
4
  const DEFAULT_HISTORY_MAX_SNAPSHOTS = 128;
@@ -7,13 +7,11 @@ const ANONYMOUS_FORM_KEY_PREFIX = `${RESERVED_KEY_PREFIX}anon:`;
7
7
  const ANONYMOUS_WIZARD_KEY_PREFIX = `${RESERVED_KEY_PREFIX}anon-wizard:`;
8
8
  const DEFAULT_MAX_RECURSION_DEPTH = 64;
9
9
  function normalizeNumericOption(config) {
10
- const { value, source, allowInfinity, min, defaultValue } = config;
11
- if (allowInfinity && value === Infinity) return Infinity;
12
- if (typeof value !== "number" || Number.isNaN(value) || value === Infinity || value === -Infinity) {
10
+ const { value, source, min, defaultValue } = config;
11
+ if (typeof value !== "number" || !Number.isFinite(value)) {
13
12
  {
14
- const acceptedDescription = allowInfinity ? "a non-negative integer or Infinity" : "a non-negative finite integer";
15
13
  console.warn(
16
- `[attaform] ${source} must be ${acceptedDescription}; got ${String(value)}. Falling back to ${String(defaultValue)}.`
14
+ `[attaform] ${source} must be a non-negative finite integer; got ${String(value)}. Falling back to ${String(defaultValue)}.`
17
15
  );
18
16
  }
19
17
  return defaultValue;
@@ -29,20 +27,32 @@ function pickDefined(bag) {
29
27
  }
30
28
 
31
29
  const reported = /* @__PURE__ */ new Set() ;
32
- function report(site, err) {
33
- if (reported === null || reported.has(site)) return;
34
- reported.add(site);
35
- const advice = site === "default-factory" ? "a `.default(() => ...)` factory threw. Attaform used `undefined` for that field's initial value." : site === "catch-factory" ? "a `.catch(() => ...)` fallback threw. Attaform used `undefined` for that value." : "a `z.lazy(() => ...)` factory threw. Attaform stopped descending at that node, so paths below it will not resolve.";
30
+ function reportConsumerThrow(site, detail, err) {
31
+ const key = detail === void 0 ? site : `${site}|${detail}`;
32
+ if (reported === null || reported.has(key)) return;
33
+ reported.add(key);
34
+ const at = detail === void 0 ? "" : ` at \`${detail}\``;
35
+ const advice = {
36
+ "default-factory": "a `.default(() => ...)` factory threw. Attaform used `undefined` for that field's initial value.",
37
+ "catch-factory": "a `.catch(() => ...)` fallback threw. Attaform used `undefined` for that value.",
38
+ "lazy-getter": "a `z.lazy(() => ...)` factory threw. Attaform stopped descending at that node, so paths below it will not resolve.",
39
+ "wizard-slot": `a function step slot threw${at}. Attaform dropped that step from the compiled list; the rest of the flow still navigates.`,
40
+ "wizard-lazy-slot": `a \`lazy()\` step resolver threw${at}. Attaform dropped that step from the compiled list until the resolver's own dependencies change.`,
41
+ "wizard-progress": "a `useWizard({ progress })` override threw. Attaform fell back to its own valid-step ratio.",
42
+ "wizard-restore": "a `useWizard({ restore })` callback threw. Attaform read no step from it, so the wizard stays where it is.",
43
+ "wizard-persist": "a `useWizard({ persist })` callback threw. Attaform navigated anyway, so the step is live but unrecorded.",
44
+ "wizard-default-statuses": "a `useWizard({ defaultStatuses })` factory threw or rejected. Attaform seeded no statuses, the same as omitting the option."
45
+ };
36
46
  console.error(
37
- `[attaform] ${advice} A function inside your schema must not throw; wrap your own try/catch if the failure is recoverable. Original error:`,
47
+ `[attaform] ${advice[site]} Attaform has nowhere to surface this, so it must not throw; wrap your own try/catch if the failure is recoverable. Original error:`,
38
48
  err
39
49
  );
40
50
  }
41
- function callConsumerSchemaFn(fn, fallback, site) {
51
+ function callConsumerFn(fn, fallback, site, detail) {
42
52
  try {
43
53
  return fn();
44
54
  } catch (err) {
45
- report(site, err);
55
+ reportConsumerThrow(site, detail, err);
46
56
  return fallback;
47
57
  }
48
58
  }
@@ -94,8 +104,9 @@ function safeAssign(target, key, value) {
94
104
  }
95
105
  target[key] = value;
96
106
  }
107
+ const SHADOWED_KEYS = new Set(Object.getOwnPropertyNames(Object.prototype));
97
108
  function isShadowedKey(key) {
98
- return key in Object.prototype;
109
+ return SHADOWED_KEYS.has(key);
99
110
  }
100
111
  function safeOwnRead(target, key) {
101
112
  if (isShadowedKey(key)) {
@@ -372,4 +383,4 @@ function structuralSnapshot(value) {
372
383
  return out;
373
384
  }
374
385
 
375
- export { ANONYMOUS_FORM_KEY_PREFIX as A, DEFAULT_HISTORY_MAX_SNAPSHOTS as D, RESERVED_KEY_PREFIX as R, safeOwnRead as a, safeAssign as b, callConsumerSchemaFn as c, consumerHas as d, safeOwnHas as e, spreadConsumerRecord as f, copyConsumerArray as g, consumerKeys as h, isShadowedKey as i, readConsumerProp as j, diffAndApply as k, DEFAULT_FIELD_VALIDATION_DEBOUNCE_MS as l, consumerSymbolKeys as m, normalizeNumericOption as n, applyChangedKeys as o, pickDefined as p, DEFAULT_MAX_RECURSION_DEPTH as q, readConsumerIndex as r, structuralSnapshot as s, ANONYMOUS_WIZARD_KEY_PREFIX as t };
386
+ export { ANONYMOUS_FORM_KEY_PREFIX as A, DEFAULT_HISTORY_MAX_SNAPSHOTS as D, RESERVED_KEY_PREFIX as R, safeOwnRead as a, safeAssign as b, callConsumerFn as c, safeOwnHas as d, consumerHas as e, spreadConsumerRecord as f, copyConsumerArray as g, consumerKeys as h, isShadowedKey as i, readConsumerProp as j, diffAndApply as k, DEFAULT_FIELD_VALIDATION_DEBOUNCE_MS as l, consumerSymbolKeys as m, normalizeNumericOption as n, applyChangedKeys as o, pickDefined as p, DEFAULT_MAX_RECURSION_DEPTH as q, readConsumerIndex as r, structuralSnapshot as s, reportConsumerThrow as t, ANONYMOUS_WIZARD_KEY_PREFIX as u };
@@ -1,4 +1,4 @@
1
- import { c as RegistryNotInstalledError, O as OutsideSetupError, g as pathKeyToDotted } from './attaform-dev.A-TpJW0B.mjs';
1
+ import { c as RegistryNotInstalledError, O as OutsideSetupError, g as pathKeyToDotted } from './attaform-dev.zlvDr0WB.mjs';
2
2
  import { shallowReactive, getCurrentInstance, inject } from 'vue';
3
3
 
4
4
  function detectSSR(options = {}) {
@@ -17,7 +17,6 @@ const kFormContext = /* @__PURE__ */ Symbol.for("attaform:form-context");
17
17
  const kFormInstanceId = /* @__PURE__ */ Symbol.for("attaform:form-instance-id");
18
18
  function createRegistry(options = {}) {
19
19
  const ssr = detectSSR(options);
20
- const defaults = Object.freeze({ ...options.defaults ?? {} });
21
20
  const forms = shallowReactive(/* @__PURE__ */ new Map());
22
21
  const wizards = shallowReactive(/* @__PURE__ */ new Map());
23
22
  const pendingHydration = shallowReactive(/* @__PURE__ */ new Map());
@@ -102,7 +101,6 @@ function createRegistry(options = {}) {
102
101
  wizards,
103
102
  pendingHydration,
104
103
  ssr,
105
- defaults,
106
104
  trackConsumer,
107
105
  trackWizardConsumer,
108
106
  enqueuePrefetch,
@@ -201,7 +199,7 @@ function hydrateAttaformState(app, payload) {
201
199
  got = "v" in payload ? payload.v : void 0;
202
200
  }
203
201
  console.warn(
204
- `[attaform] hydrateAttaformState: payload version mismatch (expected ${ATTAFORM_STATE_VERSION}, got ${String(got)}). Skipping hydration \u2014 forms will construct fresh. This usually means the SSR bundle is on a different attaform version than the client (rolling deploy / stale cache).`
202
+ `[attaform] hydrateAttaformState: payload version mismatch (expected ${ATTAFORM_STATE_VERSION}, got ${String(got)}). Skipping hydration; forms will construct fresh. This usually means the SSR bundle is on a different attaform version than the client (rolling deploy / stale cache).`
205
203
  );
206
204
  }
207
205
  return;
@@ -1,7 +1,7 @@
1
- import { a as InvalidUseFormConfigError } from './attaform-dev.A-TpJW0B.mjs';
2
- import { u as useForm$2 } from './attaform-dev.q6UutkCx.mjs';
3
- import { u as useForm$1 } from './attaform-dev.BO-71R54.mjs';
4
- import { i as installingFieldMetaStore, g as getFieldMetaForSchema } from './attaform-dev.BgM6FdtA.mjs';
1
+ import { a as InvalidUseFormConfigError } from './attaform-dev.zlvDr0WB.mjs';
2
+ import { u as useForm$2 } from './attaform-dev.CT7MDjPy.mjs';
3
+ import { u as useForm$1 } from './attaform-dev.BJK1kqHY.mjs';
4
+ import { i as installingFieldMetaStore, g as getFieldMetaForSchema } from './attaform-dev.BUIFcTYf.mjs';
5
5
 
6
6
  function isZodV4SchemaShape(value) {
7
7
  if (typeof value !== "object" || value === null) return false;