attaform 0.31.0 → 0.31.2

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 (52) hide show
  1. package/dist/abstract.d.mts +5 -5
  2. package/dist/abstract.mjs +5 -4
  3. package/dist/dev/abstract.mjs +5 -4
  4. package/dist/dev/chunks/devtools.mjs +1 -1
  5. package/dist/dev/directive.mjs +1 -1
  6. package/dist/dev/history.mjs +126 -6
  7. package/dist/dev/index.mjs +6 -5
  8. package/dist/dev/runtime/plugins/attaform.mjs +1 -1
  9. package/dist/dev/shared/{attaform-dev.zlvDr0WB.mjs → attaform-dev.04aupFBW.mjs} +3 -2
  10. package/dist/dev/shared/{attaform-dev.CtyqGia7.mjs → attaform-dev.BKWPjEB2.mjs} +5 -4
  11. package/dist/dev/shared/{attaform-dev.DlaT4xGd.mjs → attaform-dev.BnLLxX2l.mjs} +4 -4
  12. package/dist/dev/shared/{attaform-dev.B1q-x9R9.mjs → attaform-dev.Bu6wgrA5.mjs} +1 -1
  13. package/dist/dev/shared/{attaform-dev.k5X47GMD.mjs → attaform-dev.CKSqs_xQ.mjs} +3 -2
  14. package/dist/dev/shared/{attaform-dev.DJ3nsWw6.mjs → attaform-dev.Cf_hZfbT.mjs} +18 -9
  15. package/dist/dev/shared/{attaform-dev.y9x9Vp9F.mjs → attaform-dev.DLk51W7-.mjs} +565 -926
  16. package/dist/dev/shared/attaform-dev.DoG8mZTq.mjs +127 -0
  17. package/dist/dev/shared/attaform-dev.G-3XDl9F.mjs +1192 -0
  18. package/dist/dev/shared/{attaform-dev.Caibt7sb.mjs → attaform-dev.oguHqv1W.mjs} +11 -10
  19. package/dist/dev/zod-v3.mjs +7 -6
  20. package/dist/dev/zod-v4.mjs +7 -6
  21. package/dist/dev/zod.mjs +6 -5
  22. package/dist/directive.d.mts +2 -2
  23. package/dist/directive.mjs +1 -1
  24. package/dist/history.d.mts +1 -1
  25. package/dist/history.mjs +126 -6
  26. package/dist/index.d.mts +16 -55
  27. package/dist/index.mjs +6 -5
  28. package/dist/runtime/plugins/attaform.mjs +1 -1
  29. package/dist/shared/{attaform.DL2nl_QR.mjs → attaform.3kV6PqVJ.mjs} +11 -10
  30. package/dist/shared/{attaform.L011tHgJ.mjs → attaform.BJeiuJE2.mjs} +4 -4
  31. package/dist/shared/attaform.BNUhW4qC.mjs +103 -0
  32. package/dist/shared/{attaform.CdZIEf7_.mjs → attaform.BhtAZysa.mjs} +3 -2
  33. package/dist/shared/{attaform.BWUn8Kjy.mjs → attaform.BlAmZ-WU.mjs} +18 -9
  34. package/dist/shared/{attaform.LUPC-2Qg.mjs → attaform.CMzc4bPI.mjs} +5 -4
  35. package/dist/shared/{attaform.C4shmwyJ.mjs → attaform.CdA9bfRv.mjs} +1 -1
  36. package/dist/shared/attaform.CgyyJVuq.mjs +1187 -0
  37. package/dist/shared/{attaform.DAo0QBmS.d.mts → attaform.CibLYe9-.d.mts} +214 -173
  38. package/dist/shared/{attaform.DNPJPOO7.mjs → attaform.DCUJCKyG.mjs} +562 -925
  39. package/dist/shared/{attaform.D9RqPgGu.d.mts → attaform.DCyZT7u-.d.mts} +1 -1
  40. package/dist/shared/{attaform.CRVe8s82.d.mts → attaform.DD0Y8krq.d.mts} +43 -19
  41. package/dist/shared/{attaform.DxKQsqFZ.mjs → attaform.T0YjhjPU.mjs} +3 -2
  42. package/dist/shared/{attaform.DZnrDrNb.d.mts → attaform.bI_4nKZp.d.mts} +119 -8
  43. package/dist/zod-v3.d.mts +4 -4
  44. package/dist/zod-v3.mjs +7 -6
  45. package/dist/zod-v4.d.mts +15 -11
  46. package/dist/zod-v4.mjs +7 -6
  47. package/dist/zod.d.mts +4 -4
  48. package/dist/zod.mjs +6 -5
  49. package/package.json +2 -1
  50. package/skills/attaform/SKILL.md +1 -0
  51. package/dist/dev/shared/attaform-dev.CZz4GYZ6.mjs +0 -386
  52. package/dist/shared/attaform.8mfKZCwH.mjs +0 -358
@@ -1,6 +1,7 @@
1
- import { A as AttaformErrorCode, k as isPlainRecord, s as slimKindOf } from './attaform-dev.y9x9Vp9F.mjs';
2
- import { e as canonicalizePath, h as SET_MEMBER_SEGMENT } from './attaform-dev.zlvDr0WB.mjs';
3
- import { a as safeOwnRead, b as safeAssign } from './attaform-dev.CZz4GYZ6.mjs';
1
+ import { A as AttaformErrorCode, i as isPlainRecord, s as structuralSnapshot } from './attaform-dev.G-3XDl9F.mjs';
2
+ import { e as canonicalizePath, h as SET_MEMBER_SEGMENT } from './attaform-dev.04aupFBW.mjs';
3
+ import { a as safeOwnRead, s as safeAssign, d as safeOwnHas } from './attaform-dev.DoG8mZTq.mjs';
4
+ import { s as slimKindOf } from './attaform-dev.DLk51W7-.mjs';
4
5
 
5
6
  const PATH_SEPARATOR = ".";
6
7
  function isOpaqueKind(kind) {
@@ -350,7 +351,7 @@ function walkPathSegments(schema, segments, intro, maxDepth, lazyDepth) {
350
351
  switch (kind) {
351
352
  case "object": {
352
353
  const shape = intro.getObjectShape(schema);
353
- if (!Object.hasOwn(shape, head)) return [];
354
+ if (!safeOwnHas(shape, head)) return [];
354
355
  const next = shape[head];
355
356
  return next === void 0 ? [] : walkPathSegments(next, rest, intro, maxDepth, lazyDepth);
356
357
  }
@@ -382,7 +383,7 @@ function walkPathSegments(schema, segments, intro, maxDepth, lazyDepth) {
382
383
  return intro.getUnionOptions(schema).flatMap((opt) => walkPathSegments(opt, segments, intro, maxDepth, lazyDepth));
383
384
  case "discriminated-union": {
384
385
  const options = intro.getDiscriminatedOptions(schema);
385
- const matching = options.filter((opt) => Object.hasOwn(intro.getObjectShape(opt), head));
386
+ const matching = options.filter((opt) => safeOwnHas(intro.getObjectShape(opt), head));
386
387
  const candidates = matching.length > 0 ? matching : options;
387
388
  return candidates.flatMap(
388
389
  (opt) => walkPathSegments(opt, segments, intro, maxDepth, lazyDepth)
@@ -593,9 +594,9 @@ function peelEmbeddedDefault(schema, intro) {
593
594
  for (let i = 0; i < 32; i++) {
594
595
  if (current === void 0) return NO_EMBEDDED_DEFAULT;
595
596
  const k = intro.kindOf(current);
596
- if (k === "default") return intro.getDefaultValue(current);
597
+ if (k === "default") return structuralSnapshot(intro.getDefaultValue(current));
597
598
  if (k === "catch") {
598
- if (intro.hasCatchValue(current)) return intro.getCatchDefault(current);
599
+ if (intro.hasCatchValue(current)) return structuralSnapshot(intro.getCatchDefault(current));
599
600
  current = intro.unwrapInner(current);
600
601
  continue;
601
602
  }
@@ -674,7 +675,7 @@ function deriveDefaultWalk(schema, useDefault, intro, maxDepth, lazyDepth = 0) {
674
675
  case "nullable":
675
676
  return null;
676
677
  case "default": {
677
- if (useDefault) return intro.getDefaultValue(schema);
678
+ if (useDefault) return structuralSnapshot(intro.getDefaultValue(schema));
678
679
  const inner = intro.unwrapInner(schema);
679
680
  return inner === void 0 ? void 0 : deriveDefaultWalk(inner, useDefault, intro, maxDepth, lazyDepth);
680
681
  }
@@ -717,7 +718,7 @@ function deriveDefaultWalk(schema, useDefault, intro, maxDepth, lazyDepth = 0) {
717
718
  case "number":
718
719
  return 0;
719
720
  case "bigint":
720
- return 0n;
721
+ return typeof BigInt === "function" ? BigInt(0) : void 0;
721
722
  case "boolean":
722
723
  return false;
723
724
  case "date":
@@ -764,7 +765,7 @@ function deriveDefaultWalk(schema, useDefault, intro, maxDepth, lazyDepth = 0) {
764
765
  return mergeDeep(l, r);
765
766
  }
766
767
  case "catch": {
767
- if (useDefault) return intro.getCatchDefault(schema);
768
+ if (useDefault) return structuralSnapshot(intro.getCatchDefault(schema));
768
769
  const inner = intro.unwrapInner(schema);
769
770
  return inner === void 0 ? void 0 : deriveDefaultWalk(inner, useDefault, intro, maxDepth, lazyDepth);
770
771
  }
@@ -1,9 +1,10 @@
1
- export { i as isZodSchemaType, u as useForm, z as zodAdapter } from './shared/attaform-dev.CtyqGia7.mjs';
2
- import { i as installingFieldMetaStore, g as getFieldMetaForSchema } from './shared/attaform-dev.Caibt7sb.mjs';
3
- export { A as AttaformError, I as InvalidPathError, a as InvalidUseFormConfigError, O as OutsideSetupError, R as ROOT_PATH, b as ROOT_PATH_KEY, c as RegistryNotInstalledError, d as ReservedFormKeyError, S as SubmitErrorHandlerError, e as canonicalizePath, i as isPathPrefix, p as parseDottedPath } from './shared/attaform-dev.zlvDr0WB.mjs';
4
- export { A as AttaformErrorCode, e as escapeForInlineScript, g as gate, i as injectForm, a as injectWizard, b as isUnset, l as lazy, u as unset, d as useRegister, f as useWizard } from './shared/attaform-dev.y9x9Vp9F.mjs';
5
- export { D as DEVTOOLS_WINDOW_KEY, c as createAttaform, a as createRegistry, g as getRegistryFromApp, h as hydrateAttaformState, k as kAttaformRegistry, r as renderAttaformState, u as useRegistry } from './shared/attaform-dev.B1q-x9R9.mjs';
6
- export { a as assignKey, i as isRegisterValue, v as vRegister } from './shared/attaform-dev.k5X47GMD.mjs';
1
+ export { i as isZodSchemaType, u as useForm, z as zodAdapter } from './shared/attaform-dev.BKWPjEB2.mjs';
2
+ import { i as installingFieldMetaStore, g as getFieldMetaForSchema } from './shared/attaform-dev.oguHqv1W.mjs';
3
+ export { A as AttaformError, I as InvalidPathError, a as InvalidUseFormConfigError, O as OutsideSetupError, R as ROOT_PATH, b as ROOT_PATH_KEY, c as RegistryNotInstalledError, d as ReservedFormKeyError, S as SubmitErrorHandlerError, e as canonicalizePath, i as isPathPrefix, p as parseDottedPath } from './shared/attaform-dev.04aupFBW.mjs';
4
+ export { A as AttaformErrorCode } from './shared/attaform-dev.G-3XDl9F.mjs';
5
+ export { D as DEVTOOLS_WINDOW_KEY, c as createAttaform, a as createRegistry, g as getRegistryFromApp, h as hydrateAttaformState, k as kAttaformRegistry, r as renderAttaformState, u as useRegistry } from './shared/attaform-dev.Bu6wgrA5.mjs';
6
+ export { a as assignKey, i as isRegisterValue, v as vRegister } from './shared/attaform-dev.CKSqs_xQ.mjs';
7
+ export { e as escapeForInlineScript, g as gate, i as injectForm, a as injectWizard, b as isUnset, l as lazy, u as unset, d as useRegister, f as useWizard } from './shared/attaform-dev.DLk51W7-.mjs';
7
8
 
8
9
  const fieldMeta = installingFieldMetaStore;
9
10
  function withMeta(schema, payload) {
@@ -1,9 +1,10 @@
1
- export { a as assertZodVersion, k as kindOf, u as useForm, z as zodAdapter } from './shared/attaform-dev.DJ3nsWw6.mjs';
2
- import { i as installingFieldMetaStore, g as getFieldMetaForSchema } from './shared/attaform-dev.Caibt7sb.mjs';
3
- export { A as AttaformError, I as InvalidPathError, a as InvalidUseFormConfigError, O as OutsideSetupError, R as ROOT_PATH, b as ROOT_PATH_KEY, c as RegistryNotInstalledError, d as ReservedFormKeyError, S as SubmitErrorHandlerError, e as canonicalizePath, i as isPathPrefix, p as parseDottedPath } from './shared/attaform-dev.zlvDr0WB.mjs';
4
- export { A as AttaformErrorCode, e as escapeForInlineScript, g as gate, i as injectForm, a as injectWizard, b as isUnset, l as lazy, u as unset, d as useRegister, f as useWizard } from './shared/attaform-dev.y9x9Vp9F.mjs';
5
- export { D as DEVTOOLS_WINDOW_KEY, c as createAttaform, a as createRegistry, g as getRegistryFromApp, h as hydrateAttaformState, k as kAttaformRegistry, r as renderAttaformState, u as useRegistry } from './shared/attaform-dev.B1q-x9R9.mjs';
6
- export { a as assignKey, i as isRegisterValue, v as vRegister } from './shared/attaform-dev.k5X47GMD.mjs';
1
+ export { a as assertZodVersion, k as kindOf, u as useForm, z as zodAdapter } from './shared/attaform-dev.Cf_hZfbT.mjs';
2
+ import { i as installingFieldMetaStore, g as getFieldMetaForSchema } from './shared/attaform-dev.oguHqv1W.mjs';
3
+ export { A as AttaformError, I as InvalidPathError, a as InvalidUseFormConfigError, O as OutsideSetupError, R as ROOT_PATH, b as ROOT_PATH_KEY, c as RegistryNotInstalledError, d as ReservedFormKeyError, S as SubmitErrorHandlerError, e as canonicalizePath, i as isPathPrefix, p as parseDottedPath } from './shared/attaform-dev.04aupFBW.mjs';
4
+ export { A as AttaformErrorCode } from './shared/attaform-dev.G-3XDl9F.mjs';
5
+ export { D as DEVTOOLS_WINDOW_KEY, c as createAttaform, a as createRegistry, g as getRegistryFromApp, h as hydrateAttaformState, k as kAttaformRegistry, r as renderAttaformState, u as useRegistry } from './shared/attaform-dev.Bu6wgrA5.mjs';
6
+ export { a as assignKey, i as isRegisterValue, v as vRegister } from './shared/attaform-dev.CKSqs_xQ.mjs';
7
+ export { e as escapeForInlineScript, g as gate, i as injectForm, a as injectWizard, b as isUnset, l as lazy, u as unset, d as useRegister, f as useWizard } from './shared/attaform-dev.DLk51W7-.mjs';
7
8
 
8
9
  const fieldMeta = installingFieldMetaStore;
9
10
  function withMeta(schema, payload) {
package/dist/dev/zod.mjs CHANGED
@@ -1,5 +1,6 @@
1
- export { A as AttaformError, I as InvalidPathError, a as InvalidUseFormConfigError, O as OutsideSetupError, R as ROOT_PATH, b as ROOT_PATH_KEY, c as RegistryNotInstalledError, d as ReservedFormKeyError, S as SubmitErrorHandlerError, e as canonicalizePath, i as isPathPrefix, p as parseDottedPath } from './shared/attaform-dev.zlvDr0WB.mjs';
2
- export { A as AttaformErrorCode, e as escapeForInlineScript, g as gate, i as injectForm, a as injectWizard, b as isUnset, l as lazy, u as unset, d as useRegister, f as useWizard } from './shared/attaform-dev.y9x9Vp9F.mjs';
3
- export { D as DEVTOOLS_WINDOW_KEY, c as createAttaform, a as createRegistry, g as getRegistryFromApp, h as hydrateAttaformState, k as kAttaformRegistry, r as renderAttaformState, u as useRegistry } from './shared/attaform-dev.B1q-x9R9.mjs';
4
- export { a as assignKey, i as isRegisterValue, v as vRegister } from './shared/attaform-dev.k5X47GMD.mjs';
5
- export { f as fieldMeta, u as useForm, w as withMeta } from './shared/attaform-dev.DlaT4xGd.mjs';
1
+ export { A as AttaformError, I as InvalidPathError, a as InvalidUseFormConfigError, O as OutsideSetupError, R as ROOT_PATH, b as ROOT_PATH_KEY, c as RegistryNotInstalledError, d as ReservedFormKeyError, S as SubmitErrorHandlerError, e as canonicalizePath, i as isPathPrefix, p as parseDottedPath } from './shared/attaform-dev.04aupFBW.mjs';
2
+ export { A as AttaformErrorCode } from './shared/attaform-dev.G-3XDl9F.mjs';
3
+ export { D as DEVTOOLS_WINDOW_KEY, c as createAttaform, a as createRegistry, g as getRegistryFromApp, h as hydrateAttaformState, k as kAttaformRegistry, r as renderAttaformState, u as useRegistry } from './shared/attaform-dev.Bu6wgrA5.mjs';
4
+ export { a as assignKey, i as isRegisterValue, v as vRegister } from './shared/attaform-dev.CKSqs_xQ.mjs';
5
+ export { e as escapeForInlineScript, g as gate, i as injectForm, a as injectWizard, b as isUnset, l as lazy, u as unset, d as useRegister, f as useWizard } from './shared/attaform-dev.DLk51W7-.mjs';
6
+ export { f as fieldMeta, u as useForm, w as withMeta } from './shared/attaform-dev.BnLLxX2l.mjs';
@@ -1,5 +1,5 @@
1
- export { i as installVRegister, v as vRegister } from './shared/attaform.D9RqPgGu.mjs';
2
- import { an as RegisterModelDynamicCustomDirective } from './shared/attaform.DZnrDrNb.mjs';
1
+ export { i as installVRegister, v as vRegister } from './shared/attaform.DCyZT7u-.mjs';
2
+ import { an as RegisterModelDynamicCustomDirective } from './shared/attaform.bI_4nKZp.mjs';
3
3
  import 'vue';
4
4
 
5
5
  /**
@@ -1 +1 @@
1
- export { i as installVRegister, v as vRegister, b as vRegisterFile } from './shared/attaform.DxKQsqFZ.mjs';
1
+ export { i as installVRegister, v as vRegister, b as vRegisterFile } from './shared/attaform.T0YjhjPU.mjs';
@@ -1,4 +1,4 @@
1
- import { p as HistoryPlugin } from './shared/attaform.DZnrDrNb.mjs';
1
+ import { p as HistoryPlugin } from './shared/attaform.bI_4nKZp.mjs';
2
2
  import 'vue';
3
3
 
4
4
  /** Options for `historyPlugin()`, passed as `useForm({ history })`. */
package/dist/history.mjs CHANGED
@@ -1,6 +1,72 @@
1
- import { shallowRef, computed } from 'vue';
2
- import { n as normalizeNumericOption, D as DEFAULT_HISTORY_MAX_SNAPSHOTS, s as structuralSnapshot } from './shared/attaform.8mfKZCwH.mjs';
1
+ import { shallowRef, computed, toRaw } from 'vue';
2
+ import { n as normalizeNumericOption, D as DEFAULT_HISTORY_MAX_SNAPSHOTS, s as structuralSnapshot, m as migrateMapSubtree, g as getAtPath } from './shared/attaform.CgyyJVuq.mjs';
3
+ import { e as canonicalizePath, s as segmentsForPathKey } from './shared/attaform.BhtAZysa.mjs';
3
4
 
5
+ const flagged = (record) => record.touched || record.interacted || record.blurredAfterInteraction;
6
+ function captureRecords(fields) {
7
+ const out = [];
8
+ for (const record of toRaw(fields).values()) {
9
+ if (flagged(record) && record.path.some((segment) => typeof segment === "number")) {
10
+ out.push(record);
11
+ }
12
+ }
13
+ return out;
14
+ }
15
+ function underIndexIn(path, indices) {
16
+ for (let i = 0; i < path.length; i++) {
17
+ const segment = path[i];
18
+ if (typeof segment === "number" && indices.get(canonicalizePath(path.slice(0, i)).key)?.has(segment) === true) {
19
+ return true;
20
+ }
21
+ }
22
+ return false;
23
+ }
24
+ function planOrders(current, target, holdsList) {
25
+ const live = new Map(current.tokens);
26
+ const liveBaselines = new Map(current.baselines);
27
+ const tokens = new Map(target.tokens);
28
+ const baselines = new Map(target.baselines);
29
+ const remaps = [];
30
+ const depths = /* @__PURE__ */ new Set();
31
+ for (const key of live.keys()) depths.add(segmentsForPathKey(key)?.length ?? 0);
32
+ for (const depth of [...depths].sort((a, b) => a - b)) {
33
+ for (const [key, ids] of [...live]) {
34
+ const segs = segmentsForPathKey(key);
35
+ if (segs?.length !== depth) continue;
36
+ let order = tokens.get(key);
37
+ const baseline = liveBaselines.get(key);
38
+ if (order === void 0) {
39
+ if (baseline === void 0 || !holdsList(segs)) continue;
40
+ order = baseline;
41
+ tokens.set(key, order);
42
+ baselines.set(key, baseline);
43
+ }
44
+ const remap = remapBetween(ids, order);
45
+ if (remap === null) continue;
46
+ remaps.push([segs, remap]);
47
+ migrateMapSubtree(live, segs, remap, (value) => value);
48
+ migrateMapSubtree(liveBaselines, segs, remap, (value) => value);
49
+ }
50
+ }
51
+ return { orders: { tokens, baselines }, remaps };
52
+ }
53
+ function remapBetween(from, to) {
54
+ const slots = new Map(to.map((id, i) => [id, i]));
55
+ const kept = new Set(from);
56
+ const moved = /* @__PURE__ */ new Map();
57
+ const vacated = /* @__PURE__ */ new Set();
58
+ const fresh = /* @__PURE__ */ new Set();
59
+ from.forEach((id, i) => {
60
+ const at = slots.get(id);
61
+ if (at === void 0) vacated.add(i);
62
+ else if (at !== i) moved.set(i, at);
63
+ });
64
+ to.forEach((id, i) => {
65
+ if (!kept.has(id)) fresh.add(i);
66
+ });
67
+ if (moved.size === 0 && vacated.size === 0 && fresh.size === 0) return null;
68
+ return { moved, vacated, fresh, oldLen: from.length, newLen: to.length };
69
+ }
4
70
  function captureErrorCells(map) {
5
71
  const out = [];
6
72
  for (const [k, cell] of map) {
@@ -10,32 +76,81 @@ function captureErrorCells(map) {
10
76
  }
11
77
  function createHistoryRuntime(kernel, max) {
12
78
  const capacity = Math.max(1, max);
79
+ let generation = 0;
13
80
  function captureSnapshot() {
14
81
  return {
15
82
  form: structuralSnapshot(kernel.form.value),
16
83
  blankPaths: [...kernel.blankPaths],
17
- errorCells: captureErrorCells(kernel.errorCells())
84
+ errorCells: captureErrorCells(kernel.errorCells()),
85
+ structure: kernel.captureStructure(),
86
+ records: captureRecords(kernel.fields),
87
+ generation
18
88
  };
19
89
  }
20
90
  const positions = shallowRef([captureSnapshot()]);
21
91
  const cursor = shallowRef(0);
22
92
  let suppressNext = false;
93
+ let disposed = false;
94
+ let released = [];
95
+ kernel.noteReleased = (records) => {
96
+ for (const record of records) if (flagged(record)) released.push(record);
97
+ };
23
98
  const unsubscribeChange = kernel.onFormChange((_next, meta) => {
99
+ const left = released;
100
+ released = [];
24
101
  if (suppressNext) {
25
102
  suppressNext = false;
26
103
  return;
27
104
  }
28
105
  if (meta?.hydration === true) {
29
- clear();
106
+ queueMicrotask(() => {
107
+ if (!disposed) clear();
108
+ });
30
109
  return;
31
110
  }
32
111
  const next = positions.value.slice(0, cursor.value + 1);
112
+ const before = next[next.length - 1];
113
+ if (left.length > 0 && before !== void 0) {
114
+ next[next.length - 1] = { ...before, records: [...before.records, ...left] };
115
+ }
33
116
  next.push(captureSnapshot());
34
117
  while (next.length > capacity) next.shift();
35
118
  positions.value = next;
36
119
  cursor.value = next.length - 1;
37
120
  });
38
- function restorePosition(snap) {
121
+ function retake() {
122
+ const structure = kernel.captureStructure();
123
+ const current = positions.value[cursor.value];
124
+ if (current !== void 0) {
125
+ const next = [...positions.value];
126
+ next[cursor.value] = {
127
+ ...current,
128
+ structure,
129
+ records: captureRecords(kernel.fields),
130
+ generation
131
+ };
132
+ positions.value = next;
133
+ }
134
+ return structure;
135
+ }
136
+ const unsubscribeReset = kernel.onReset(() => {
137
+ generation += 1;
138
+ retake();
139
+ });
140
+ function restorePosition(snap, live) {
141
+ if (snap.generation === generation) {
142
+ const { orders, remaps } = planOrders(
143
+ live.identity,
144
+ snap.structure.identity,
145
+ (segments) => Array.isArray(getAtPath(snap.form, segments))
146
+ );
147
+ const fresh = /* @__PURE__ */ new Map();
148
+ for (const [segments, remap] of remaps) {
149
+ if (remap.fresh.size > 0) fresh.set(canonicalizePath(segments).key, remap.fresh);
150
+ }
151
+ const returning = fresh.size === 0 ? [] : snap.records.filter((record) => underIndexIn(record.path, fresh));
152
+ kernel.restoreStructure({ ...snap.structure, identity: orders }, remaps, returning);
153
+ }
39
154
  suppressNext = true;
40
155
  kernel.blankPaths.clear();
41
156
  for (const key of snap.blankPaths) kernel.blankPaths.add(key);
@@ -45,8 +160,10 @@ function createHistoryRuntime(kernel, max) {
45
160
  function stepTo(nextCursor) {
46
161
  const snap = positions.value[nextCursor];
47
162
  if (snap === void 0) return false;
163
+ const live = retake();
48
164
  cursor.value = nextCursor;
49
- restorePosition(snap);
165
+ restorePosition(snap, live);
166
+ released = [];
50
167
  return true;
51
168
  }
52
169
  function undo() {
@@ -67,7 +184,10 @@ function createHistoryRuntime(kernel, max) {
67
184
  canRedo: computed(() => cursor.value < positions.value.length - 1),
68
185
  historySize: computed(() => positions.value.length),
69
186
  dispose() {
187
+ disposed = true;
188
+ kernel.noteReleased = void 0;
70
189
  unsubscribeChange();
190
+ unsubscribeReset();
71
191
  positions.value = positions.value.slice(cursor.value, cursor.value + 1);
72
192
  cursor.value = 0;
73
193
  }
package/dist/index.d.mts CHANGED
@@ -1,55 +1,15 @@
1
- export { a as AnyForm, b as AttaformDevtoolsBridge, c as AttaformError, d as AttaformErrorCode, e as AttaformPluginOptions, A as AttaformRegistry, C as CompiledStep, D as DEVTOOLS_WINDOW_KEY, F as FormStatus, f as FormStatusSeed, G as GateMarker, I as InjectWizardInput, g as InvalidPathError, h as InvalidUseFormConfigError, L as LazyMarker, O as OutsideSetupError, R as RegistryNotInstalledError, i as ReservedFormKeyError, S as SerializedAttaformState, j as SerializedFormData, k as StepSlot, l as SubmitErrorHandlerError, U as UseRegisterOptions, m as UseRegisterReturn, n as UseWizardReturnType, W as WizardAggregateError, o as WizardCtx, p as WizardCtxForm, q as WizardOnError, r as WizardOnSubmit, s as WizardOptions, t as WizardPersistFn, u as WizardRestoreFn, v as WizardRestoreState, w as WizardStatusesProxy, x as WizardSubmitContext, y as assignKey, z as createAttaform, B as createRegistry, E as escapeForInlineScript, H as gate, J as getRegistryFromApp, K as hydrateAttaformState, M as injectForm, N as injectWizard, P as isRegisterValue, Q as kAttaformRegistry, T as lazy, V as renderAttaformState, X as useRegister, Y as useRegistry, Z as useWizard } from './shared/attaform.DAo0QBmS.mjs';
2
- import { G as GenericForm, F as FormKey, U as UseFormConfiguration, ap as AcceptableDefaults, ab as ValidateOnConfig, a as UseFormReturnType, D as DefaultValuesInput, h as FieldMetaPayload } from './shared/attaform.DZnrDrNb.mjs';
1
+ export { a as AnyForm, b as AttaformDevtoolsBridge, c as AttaformError, d as AttaformErrorCode, e as AttaformPluginOptions, A as AttaformRegistry, C as CompiledStep, D as DEVTOOLS_WINDOW_KEY, F as FormStatus, f as FormStatusSeed, G as GateMarker, I as InjectWizardInput, g as InvalidPathError, h as InvalidUseFormConfigError, L as LazyMarker, O as OutsideSetupError, R as RegistryNotInstalledError, i as ReservedFormKeyError, S as SerializedAttaformState, j as SerializedFormData, k as StepSlot, l as SubmitErrorHandlerError, U as UseRegisterOptions, m as UseRegisterReturn, n as UseWizardReturnType, W as WizardAggregateError, o as WizardCtx, p as WizardCtxForm, q as WizardOnError, r as WizardOnSubmit, s as WizardOptions, t as WizardPersistFn, u as WizardRestoreFn, v as WizardRestoreState, w as WizardStatusesProxy, x as WizardSubmitContext, y as assignKey, z as createAttaform, B as createRegistry, E as escapeForInlineScript, H as gate, J as getRegistryFromApp, K as hydrateAttaformState, M as injectForm, N as injectWizard, P as isRegisterValue, Q as kAttaformRegistry, T as lazy, V as renderAttaformState, X as useRegister, Y as useRegistry, Z as useWizard } from './shared/attaform.CibLYe9-.mjs';
2
+ import { G as GenericForm, F as FormKey, U as UseFormConfiguration, ap as AcceptableDefaults, ab as ValidateOnConfig, a as UseFormReturnType, D as DefaultValuesInput, h as FieldMetaPayload } from './shared/attaform.bI_4nKZp.mjs';
3
3
  import { AbstractSchema } from './abstract.mjs';
4
- export { b as ArrayItem, c as ArrayPath, C as CustomDirectiveRegisterAssignerFn, d as DeepPartial, e as DefaultValuesShape, f as DisplayState, E as ErrorInput, g as ErrorsProxyShape, i as FieldState, j as FieldStateMap, k as FieldStateMapEntry, l as FlatPath, m as FormErrorRecord, n as FormErrorsSurface, o as FormMeta, H as HandleSubmit, p as HistoryPlugin, I as IsTuple, q as IsUnion, J as JoinSegments, r as Json, K as KeyofUnion, L as LiftedValueShape, M as MetaTrackerValue, N as NestedReadType, s as NestedType, O as OnError, t as OnSubmit, P as ParseOptions, u as PartialFlatPath, v as Path, w as PathKey, x as PendingValidationStatus, y as Primitive, R as ROOT_PATH, z as ROOT_PATH_KEY, B as ReactiveValidationStatus, Q as RecordPath, S as RecordValue, T as RegisterDirective, V as RegisterFlatPath, W as RegisterOptions, X as RegisterSelectModifier, Y as RegisterTextModifier, Z as RegisterTransform, _ as RegisterValue, $ as SchemaParseErrorWithData, a0 as SchemaParseErrorWithoutData, a1 as SchemaParseResult, a2 as SchemaParseSuccess, a3 as Segment, a4 as SetValueCallback, a5 as SetValuePayload, a6 as SettledValidationStatus, a7 as SlimPrimitiveKind, a8 as SubmitHandler, a9 as Unset, aa as ValidateOn, ac as ValidationError, ad as ValidationResponse, ae as ValidationResponseWithoutValue, af as ValueOfUnion, ag as WriteMeta, ah as WriteShape, ai as canonicalizePath, aj as isPathPrefix, ak as isUnset, al as parseDottedPath, am as unset } from './shared/attaform.DZnrDrNb.mjs';
5
- export { v as vRegister } from './shared/attaform.D9RqPgGu.mjs';
6
- import { S as SupportedRootSchema, b as StorageShape } from './shared/attaform.CRVe8s82.mjs';
7
- export { P as PathInput, a as PathOutput } from './shared/attaform.CRVe8s82.mjs';
4
+ export { b as ArrayItem, c as ArrayPath, C as CustomDirectiveRegisterAssignerFn, d as DeepPartial, e as DefaultValuesShape, f as DisplayState, E as ErrorInput, g as ErrorsProxyShape, i as FieldState, j as FieldStateMap, k as FieldStateMapEntry, l as FlatPath, m as FormErrorRecord, n as FormErrorsSurface, o as FormMeta, H as HandleSubmit, p as HistoryPlugin, I as IsTuple, q as IsUnion, J as JoinSegments, r as Json, K as KeyofUnion, L as LiftedValueShape, M as MetaTrackerValue, N as NestedReadType, s as NestedType, O as OnError, t as OnSubmit, P as ParseOptions, u as PartialFlatPath, v as Path, w as PathKey, x as PendingValidationStatus, y as Primitive, R as ROOT_PATH, z as ROOT_PATH_KEY, B as ReactiveValidationStatus, Q as RecordPath, S as RecordValue, T as RegisterDirective, V as RegisterFlatPath, W as RegisterOptions, X as RegisterSelectModifier, Y as RegisterTextModifier, Z as RegisterTransform, _ as RegisterValue, $ as SchemaParseErrorWithData, a0 as SchemaParseErrorWithoutData, a1 as SchemaParseResult, a2 as SchemaParseSuccess, a3 as Segment, a4 as SetValueCallback, a5 as SetValuePayload, a6 as SettledValidationStatus, a7 as SlimPrimitiveKind, a8 as SubmitHandler, a9 as Unset, aa as ValidateOn, ac as ValidationError, ad as ValidationResponse, ae as ValidationResponseWithoutValue, af as ValueOfUnion, ag as WriteMeta, ah as WriteShape, ai as canonicalizePath, aj as isPathPrefix, ak as isUnset, al as parseDottedPath, am as unset } from './shared/attaform.bI_4nKZp.mjs';
5
+ export { v as vRegister } from './shared/attaform.DCyZT7u-.mjs';
6
+ import { S as SupportedRootSchema, b as StorageShape } from './shared/attaform.DD0Y8krq.mjs';
7
+ export { P as PathInput, a as PathOutput } from './shared/attaform.DD0Y8krq.mjs';
8
8
  import { S as SupportedRootSchema$1, a as StorageShape$1 } from './shared/attaform.B-Tb62qV.mjs';
9
9
  import { UnwrapZodRoot } from './zod-v3.mjs';
10
10
  import { z } from 'zod';
11
11
  import 'vue';
12
12
 
13
- /**
14
- * Type-level Zod-major discriminator for the unified `attaform/zod`
15
- * entry. The runtime dispatch (`use-form.ts`'s impl) already routes on
16
- * the schema's shape via `isZodV4SchemaShape`; this is the type-level
17
- * mirror so the overloads and projection helpers discriminate the same
18
- * way.
19
- *
20
- * Why a structural marker instead of `z.ZodObject`: the unified entry's
21
- * overloads constrain on `z.ZodObject`, but the published `.d.mts`
22
- * resolves `z` against whichever single Zod major the consumer
23
- * installed. In a v3-only install `z.ZodObject` is v3's `ZodObject`
24
- * (and, lacking its required type arguments, degrades to an `any`-like
25
- * error type under `skipLibCheck`), so a v3 schema satisfies the v4
26
- * overload's constraint and binds it, collapsing the read slot to
27
- * `never`. A Zod v4 schema carries the `_zod` internals brand; a v3
28
- * schema never does.
29
- * Intersecting a v4-only constraint or conditional branch with this
30
- * marker keeps it unreachable for a v3 schema regardless of how `zod`
31
- * resolves, so v3 schemas fall through to the v3 overload.
32
- *
33
- * Distinct from `core/zod-shape.ts`'s runtime `ZodV4Shape` (which reads
34
- * the public `def` getter): at the type level the stable v4 brand is
35
- * `_zod.def`, the same internals `StorageShape` (v4) already reads.
36
- *
37
- * Pairing requirement: a v4 overload/branch must constrain on
38
- * `z.ZodObject<z.ZodRawShape> & ZodV4Internals`, NOT bare
39
- * `z.ZodObject & ZodV4Internals`. In a v3-only install `z.ZodObject`
40
- * with no type argument is `ZodObject<T, ...>` missing its required
41
- * arguments, an error type that behaves like `any` under
42
- * `skipLibCheck`, so `any & ZodV4Internals` collapses back to `any` and
43
- * the marker stops excluding v3 schemas. Supplying `z.ZodRawShape`
44
- * keeps it a concrete object type in both majors, so the intersection
45
- * stays meaningful.
46
- */
47
- type ZodV4Internals = {
48
- _zod: {
49
- def: unknown;
50
- };
51
- };
52
-
53
13
  /**
54
14
  * Per-major projection helpers shared by the unified `attaform/zod`
55
15
  * entry. Each maps an arbitrary Zod v4 OR v3 object schema to the
@@ -101,12 +61,13 @@ type V3ReadOf<S extends SupportedRootSchema$1> = StorageShape$1<UnwrapZodRoot<S>
101
61
  * const form = useForm({ schema })
102
62
  * ```
103
63
  *
104
- * The constraint intersects `ZodV4Internals`, the v4-only `_zod` brand,
105
- * so a v3 schema cannot bind this overload even where `z` resolves to v3
106
- * in a single-major install; it falls through to the v3 overload below.
107
- * See `types-zod-major.ts`.
64
+ * The constraint is structural on Zod's core `_zod` internals. A
65
+ * `zod/mini` schema binds it as its classic twin does, and a v3 schema,
66
+ * which carries no `_zod`, cannot bind it even where `zod` resolves to v3
67
+ * in a single-major install, so it falls through to the v3 overload
68
+ * below. See `SupportedRootSchema` in `../zod-v4/types-root.ts`.
108
69
  */
109
- declare function useForm<Schema extends SupportedRootSchema & ZodV4Internals, K extends FormKey = FormKey>(configuration: Omit<UseFormConfiguration<V4FormOf<Schema>, V4OutOf<Schema>, AbstractSchema<V4FormOf<Schema>, V4OutOf<Schema>>, never, K>, 'schema' | 'validateOn' | 'debounceMs' | 'defaultValues'> & {
70
+ declare function useForm<Schema extends SupportedRootSchema, K extends FormKey = FormKey>(configuration: Omit<UseFormConfiguration<V4FormOf<Schema>, V4OutOf<Schema>, AbstractSchema<V4FormOf<Schema>, V4OutOf<Schema>>, never, K>, 'schema' | 'validateOn' | 'debounceMs' | 'defaultValues'> & {
110
71
  schema: Schema;
111
72
  defaultValues?: AcceptableDefaults<V4FormOf<Schema>, V4SchemaInput<Schema>>;
112
73
  } & ValidateOnConfig): UseFormReturnType<V4FormOf<Schema>, V4OutOf<Schema>, V4ReadOf<Schema>, K>;
@@ -158,11 +119,11 @@ declare function useForm<Schema extends SupportedRootSchema$1, K extends FormKey
158
119
  * cleanly under a generic constraint because no conditional
159
120
  * is present.
160
121
  */
161
- type UseFormReturnV4<Schema extends z.ZodObject, K extends FormKey = FormKey> = UseFormReturnType<V4FormOf<Schema>, V4OutOf<Schema>, V4ReadOf<Schema>, K>;
122
+ type UseFormReturnV4<Schema extends SupportedRootSchema, K extends FormKey = FormKey> = UseFormReturnType<V4FormOf<Schema>, V4OutOf<Schema>, V4ReadOf<Schema>, K>;
162
123
  /**
163
124
  * Direct V4 configuration projection. Mirrors `UseFormReturnV4`.
164
125
  */
165
- type UseFormConfigV4<Schema extends z.ZodObject, K extends FormKey = FormKey> = Omit<UseFormConfiguration<V4FormOf<Schema>, V4OutOf<Schema>, AbstractSchema<V4FormOf<Schema>, V4OutOf<Schema>>, DefaultValuesInput<V4FormOf<Schema>>, K>, 'schema' | 'validateOn' | 'debounceMs'> & {
126
+ type UseFormConfigV4<Schema extends SupportedRootSchema, K extends FormKey = FormKey> = Omit<UseFormConfiguration<V4FormOf<Schema>, V4OutOf<Schema>, AbstractSchema<V4FormOf<Schema>, V4OutOf<Schema>>, DefaultValuesInput<V4FormOf<Schema>>, K>, 'schema' | 'validateOn' | 'debounceMs'> & {
166
127
  schema: Schema;
167
128
  } & ValidateOnConfig;
168
129
  /**
@@ -190,13 +151,13 @@ type UseFormConfigV3<Schema extends z.ZodObject<z.ZodRawShape>, K extends FormKe
190
151
  * under a generic constraint, so this helper's dispatch stays deferred
191
152
  * and return-type compatibility cannot be proven.
192
153
  */
193
- type UseFormReturn<Schema, K extends FormKey = FormKey> = Schema extends SupportedRootSchema & ZodV4Internals ? UseFormReturnType<V4FormOf<Schema>, V4OutOf<Schema>, V4ReadOf<Schema>, K> : Schema extends SupportedRootSchema$1 ? UseFormReturnType<V3FormOf<Schema>, V3OutOf<Schema>, V3ReadOf<Schema>, K> : never;
154
+ type UseFormReturn<Schema, K extends FormKey = FormKey> = Schema extends SupportedRootSchema ? UseFormReturnType<V4FormOf<Schema>, V4OutOf<Schema>, V4ReadOf<Schema>, K> : Schema extends SupportedRootSchema$1 ? UseFormReturnType<V3FormOf<Schema>, V3OutOf<Schema>, V3ReadOf<Schema>, K> : never;
194
155
  /**
195
156
  * The configuration parameter shape of `useForm` for a given Zod
196
157
  * schema. Same dispatch as `UseFormReturn`; it replaces
197
158
  * `Parameters<typeof useForm<Schema, K>>[0]` in test code.
198
159
  */
199
- type UseFormConfig<Schema, K extends FormKey = FormKey> = Schema extends SupportedRootSchema & ZodV4Internals ? Omit<UseFormConfiguration<V4FormOf<Schema>, V4OutOf<Schema>, AbstractSchema<V4FormOf<Schema>, V4OutOf<Schema>>, DefaultValuesInput<V4FormOf<Schema>>, K>, 'schema' | 'validateOn' | 'debounceMs'> & {
160
+ type UseFormConfig<Schema, K extends FormKey = FormKey> = Schema extends SupportedRootSchema ? Omit<UseFormConfiguration<V4FormOf<Schema>, V4OutOf<Schema>, AbstractSchema<V4FormOf<Schema>, V4OutOf<Schema>>, DefaultValuesInput<V4FormOf<Schema>>, K>, 'schema' | 'validateOn' | 'debounceMs'> & {
200
161
  schema: Schema;
201
162
  } & ValidateOnConfig : Schema extends SupportedRootSchema$1 ? Omit<UseFormConfiguration<V3FormOf<Schema>, V3OutOf<Schema>, AbstractSchema<V3FormOf<Schema>, V3OutOf<Schema>>, DefaultValuesInput<V3FormOf<Schema>>, K>, 'schema' | 'validateOn' | 'debounceMs'> & {
202
163
  schema: Schema;
package/dist/index.mjs CHANGED
@@ -1,6 +1,7 @@
1
- export { A as AttaformError, I as InvalidPathError, a as InvalidUseFormConfigError, O as OutsideSetupError, R as ROOT_PATH, b as ROOT_PATH_KEY, c as RegistryNotInstalledError, d as ReservedFormKeyError, S as SubmitErrorHandlerError, e as canonicalizePath, i as isPathPrefix, p as parseDottedPath } from './shared/attaform.CdZIEf7_.mjs';
2
- export { A as AttaformErrorCode, e as escapeForInlineScript, g as gate, i as injectForm, a as injectWizard, b as isUnset, l as lazy, u as unset, d as useRegister, f as useWizard } from './shared/attaform.DNPJPOO7.mjs';
3
- export { D as DEVTOOLS_WINDOW_KEY, c as createAttaform, a as createRegistry, g as getRegistryFromApp, h as hydrateAttaformState, k as kAttaformRegistry, r as renderAttaformState, u as useRegistry } from './shared/attaform.C4shmwyJ.mjs';
4
- export { a as assignKey, v as vRegister } from './shared/attaform.DxKQsqFZ.mjs';
5
- export { f as fieldMeta, u as useForm, w as withMeta } from './shared/attaform.L011tHgJ.mjs';
1
+ export { A as AttaformError, I as InvalidPathError, a as InvalidUseFormConfigError, O as OutsideSetupError, R as ROOT_PATH, b as ROOT_PATH_KEY, c as RegistryNotInstalledError, d as ReservedFormKeyError, S as SubmitErrorHandlerError, e as canonicalizePath, i as isPathPrefix, p as parseDottedPath } from './shared/attaform.BhtAZysa.mjs';
2
+ export { A as AttaformErrorCode } from './shared/attaform.CgyyJVuq.mjs';
3
+ export { D as DEVTOOLS_WINDOW_KEY, c as createAttaform, a as createRegistry, g as getRegistryFromApp, h as hydrateAttaformState, k as kAttaformRegistry, r as renderAttaformState, u as useRegistry } from './shared/attaform.CdA9bfRv.mjs';
4
+ export { a as assignKey, v as vRegister } from './shared/attaform.T0YjhjPU.mjs';
5
+ export { e as escapeForInlineScript, g as gate, i as injectForm, a as injectWizard, b as isUnset, l as lazy, u as unset, d as useRegister, f as useWizard } from './shared/attaform.DCUJCKyG.mjs';
6
+ export { f as fieldMeta, u as useForm, w as withMeta } from './shared/attaform.BJeiuJE2.mjs';
6
7
  export { i as isRegisterValue } from './shared/attaform.KvlEedlF.mjs';
@@ -1,5 +1,5 @@
1
1
  import { defineNuxtPlugin, useRuntimeConfig, useRoute } from 'nuxt/app';
2
- import { c as createAttaform, b as kAttaformWizardActiveStepResolver, r as renderAttaformState, h as hydrateAttaformState, g as getRegistryFromApp, D as DEVTOOLS_WINDOW_KEY } from '../../shared/attaform.C4shmwyJ.mjs';
2
+ import { c as createAttaform, b as kAttaformWizardActiveStepResolver, r as renderAttaformState, h as hydrateAttaformState, g as getRegistryFromApp, D as DEVTOOLS_WINDOW_KEY } from '../../shared/attaform.CdA9bfRv.mjs';
3
3
 
4
4
  var attaform_default = defineNuxtPlugin({
5
5
  // `enforce: 'pre'` makes the "we run before any component's setup" claim
@@ -1,6 +1,7 @@
1
- import { A as AttaformErrorCode, k as isPlainRecord, s as slimKindOf } from './attaform.DNPJPOO7.mjs';
2
- import { e as canonicalizePath, h as SET_MEMBER_SEGMENT } from './attaform.CdZIEf7_.mjs';
3
- import { a as safeOwnRead, b as safeAssign } from './attaform.8mfKZCwH.mjs';
1
+ import { A as AttaformErrorCode, i as isPlainRecord, s as structuralSnapshot } from './attaform.CgyyJVuq.mjs';
2
+ import { e as canonicalizePath, h as SET_MEMBER_SEGMENT } from './attaform.BhtAZysa.mjs';
3
+ import { a as safeOwnRead, s as safeAssign, d as safeOwnHas } from './attaform.BNUhW4qC.mjs';
4
+ import { s as slimKindOf } from './attaform.DCUJCKyG.mjs';
4
5
 
5
6
  const PATH_SEPARATOR = ".";
6
7
  function isOpaqueKind(kind) {
@@ -350,7 +351,7 @@ function walkPathSegments(schema, segments, intro, maxDepth, lazyDepth) {
350
351
  switch (kind) {
351
352
  case "object": {
352
353
  const shape = intro.getObjectShape(schema);
353
- if (!Object.hasOwn(shape, head)) return [];
354
+ if (!safeOwnHas(shape, head)) return [];
354
355
  const next = shape[head];
355
356
  return next === void 0 ? [] : walkPathSegments(next, rest, intro, maxDepth, lazyDepth);
356
357
  }
@@ -382,7 +383,7 @@ function walkPathSegments(schema, segments, intro, maxDepth, lazyDepth) {
382
383
  return intro.getUnionOptions(schema).flatMap((opt) => walkPathSegments(opt, segments, intro, maxDepth, lazyDepth));
383
384
  case "discriminated-union": {
384
385
  const options = intro.getDiscriminatedOptions(schema);
385
- const matching = options.filter((opt) => Object.hasOwn(intro.getObjectShape(opt), head));
386
+ const matching = options.filter((opt) => safeOwnHas(intro.getObjectShape(opt), head));
386
387
  const candidates = matching.length > 0 ? matching : options;
387
388
  return candidates.flatMap(
388
389
  (opt) => walkPathSegments(opt, segments, intro, maxDepth, lazyDepth)
@@ -593,9 +594,9 @@ function peelEmbeddedDefault(schema, intro) {
593
594
  for (let i = 0; i < 32; i++) {
594
595
  if (current === void 0) return NO_EMBEDDED_DEFAULT;
595
596
  const k = intro.kindOf(current);
596
- if (k === "default") return intro.getDefaultValue(current);
597
+ if (k === "default") return structuralSnapshot(intro.getDefaultValue(current));
597
598
  if (k === "catch") {
598
- if (intro.hasCatchValue(current)) return intro.getCatchDefault(current);
599
+ if (intro.hasCatchValue(current)) return structuralSnapshot(intro.getCatchDefault(current));
599
600
  current = intro.unwrapInner(current);
600
601
  continue;
601
602
  }
@@ -674,7 +675,7 @@ function deriveDefaultWalk(schema, useDefault, intro, maxDepth, lazyDepth = 0) {
674
675
  case "nullable":
675
676
  return null;
676
677
  case "default": {
677
- if (useDefault) return intro.getDefaultValue(schema);
678
+ if (useDefault) return structuralSnapshot(intro.getDefaultValue(schema));
678
679
  const inner = intro.unwrapInner(schema);
679
680
  return inner === void 0 ? void 0 : deriveDefaultWalk(inner, useDefault, intro, maxDepth, lazyDepth);
680
681
  }
@@ -717,7 +718,7 @@ function deriveDefaultWalk(schema, useDefault, intro, maxDepth, lazyDepth = 0) {
717
718
  case "number":
718
719
  return 0;
719
720
  case "bigint":
720
- return 0n;
721
+ return typeof BigInt === "function" ? BigInt(0) : void 0;
721
722
  case "boolean":
722
723
  return false;
723
724
  case "date":
@@ -764,7 +765,7 @@ function deriveDefaultWalk(schema, useDefault, intro, maxDepth, lazyDepth = 0) {
764
765
  return mergeDeep(l, r);
765
766
  }
766
767
  case "catch": {
767
- if (useDefault) return intro.getCatchDefault(schema);
768
+ if (useDefault) return structuralSnapshot(intro.getCatchDefault(schema));
768
769
  const inner = intro.unwrapInner(schema);
769
770
  return inner === void 0 ? void 0 : deriveDefaultWalk(inner, useDefault, intro, maxDepth, lazyDepth);
770
771
  }
@@ -1,7 +1,7 @@
1
- import { a as InvalidUseFormConfigError } from './attaform.CdZIEf7_.mjs';
2
- import { u as useForm$2 } from './attaform.LUPC-2Qg.mjs';
3
- import { u as useForm$1 } from './attaform.BWUn8Kjy.mjs';
4
- import { i as installingFieldMetaStore, g as getFieldMetaForSchema } from './attaform.DL2nl_QR.mjs';
1
+ import { a as InvalidUseFormConfigError } from './attaform.BhtAZysa.mjs';
2
+ import { u as useForm$2 } from './attaform.CMzc4bPI.mjs';
3
+ import { u as useForm$1 } from './attaform.BlAmZ-WU.mjs';
4
+ import { i as installingFieldMetaStore, g as getFieldMetaForSchema } from './attaform.3kV6PqVJ.mjs';
5
5
 
6
6
  function isZodV4SchemaShape(value) {
7
7
  if (typeof value !== "object" || value === null) return false;