attaform 0.27.6 → 0.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (184) hide show
  1. package/dist/abstract.d.mts +5 -4
  2. package/dist/abstract.mjs +4 -3
  3. package/dist/chunks/fingerprint.mjs +0 -1
  4. package/dist/chunks/fingerprint2.mjs +1 -2
  5. package/dist/dev/abstract.mjs +4 -0
  6. package/dist/{chunks → dev/chunks}/dev-key-collision-warnings.mjs +0 -1
  7. package/dist/{chunks → dev/chunks}/devtools.mjs +5 -6
  8. package/dist/{chunks/fingerprint.cjs → dev/chunks/fingerprint.mjs} +7 -10
  9. package/dist/{chunks/fingerprint2.cjs → dev/chunks/fingerprint2.mjs} +32 -35
  10. package/dist/dev/directive.mjs +1 -0
  11. package/dist/dev/history.mjs +89 -0
  12. package/dist/dev/index.mjs +5 -0
  13. package/dist/dev/runtime/plugins/attaform.mjs +40 -0
  14. package/dist/{shared/attaform.D6tk90Rc.cjs → dev/shared/attaform-dev.6qxD-Yqo.mjs} +187 -43
  15. package/dist/{shared/attaform.CQN9R62B.cjs → dev/shared/attaform-dev.BJGA_UOS.mjs} +1 -4
  16. package/dist/{shared/attaform.DYEr28Pt.mjs → dev/shared/attaform-dev.BR8u0YOZ.mjs} +6 -7
  17. package/dist/dev/shared/attaform-dev.BXE2cr0L.mjs +220 -0
  18. package/dist/dev/shared/attaform-dev.By4PRjt0.mjs +248 -0
  19. package/dist/{shared/attaform.B1ZYt2Li.mjs → dev/shared/attaform-dev.D2I8e_Mm.mjs} +132 -568
  20. package/dist/dev/shared/attaform-dev.Dr2YzS5B.mjs +197 -0
  21. package/dist/{shared/attaform.nMaz2C5P.mjs → dev/shared/attaform-dev.P7cseiEG.mjs} +178 -397
  22. package/dist/{shared/attaform.CKH2lGdL.mjs → dev/shared/attaform-dev.WmuhD_CZ.mjs} +3944 -5056
  23. package/dist/{shared/attaform.DMxM2kol.mjs → dev/shared/attaform-dev.oYrkP9dj.mjs} +160 -508
  24. package/dist/dev/zod-v3.mjs +17 -0
  25. package/dist/dev/zod-v4.mjs +16 -0
  26. package/dist/dev/zod.mjs +5 -0
  27. package/dist/directive.d.mts +20 -0
  28. package/dist/directive.mjs +1 -0
  29. package/dist/esbuild.mjs +0 -1
  30. package/dist/history.d.mts +59 -0
  31. package/dist/history.mjs +89 -0
  32. package/dist/index.d.mts +11 -5
  33. package/dist/index.mjs +5 -4
  34. package/dist/nuxt.d.mts +1 -1
  35. package/dist/nuxt.mjs +5 -2
  36. package/dist/rollup.mjs +0 -1
  37. package/dist/rspack.d.mts +6 -1
  38. package/dist/rspack.mjs +0 -1
  39. package/dist/runtime/components/AttaformDevtoolsPanel.vue +9 -8
  40. package/dist/runtime/plugins/attaform.mjs +1 -2
  41. package/dist/shared/{attaform.Fp3sCrVs.d.ts → attaform.B4VkS43-.d.mts} +2 -2
  42. package/dist/shared/{attaform.DrvMscNX.cjs → attaform.B8k8JrmK.mjs} +4073 -5630
  43. package/dist/shared/attaform.BJGA_UOS.mjs +0 -1
  44. package/dist/shared/{attaform.CoR4mWfv.mjs → attaform.C09fpdLS.mjs} +172 -16
  45. package/dist/shared/{attaform.D8kliaKw.cjs → attaform.CJP3RkGa.mjs} +141 -590
  46. package/dist/shared/{attaform.DniawQLP.d.cts → attaform.Cgu-hdSb.d.mts} +268 -68
  47. package/dist/shared/attaform.Cs2Rbdlo.mjs +0 -1
  48. package/dist/shared/{attaform.CHlJLAiv.d.mts → attaform.D5V4tZWq.d.mts} +69 -179
  49. package/dist/shared/{attaform.B9Wyhfro.cjs → attaform.D6DCnnQu.mjs} +11 -16
  50. package/dist/shared/attaform.DhnPb6nK.mjs +0 -1
  51. package/dist/shared/attaform.Dq4vWxuG.mjs +197 -0
  52. package/dist/shared/attaform.JfSWdEcb.d.mts +44 -0
  53. package/dist/shared/attaform.KvlEedlF.mjs +0 -1
  54. package/dist/shared/{attaform.DdQN7sgN.cjs → attaform.NLmerepI.mjs} +175 -557
  55. package/dist/shared/attaform.h0i6LijT.mjs +242 -0
  56. package/dist/shared/{attaform.Biytrv0-.cjs → attaform.uLbun31C.mjs} +204 -544
  57. package/dist/shared/attaform.v0fQtWyA.mjs +0 -1
  58. package/dist/shared/attaform.wfY8XFvm.mjs +197 -0
  59. package/dist/transforms.mjs +0 -1
  60. package/dist/vite.d.mts +17 -5
  61. package/dist/vite.mjs +24 -2
  62. package/dist/webpack.d.mts +6 -1
  63. package/dist/webpack.mjs +0 -1
  64. package/dist/zod-v3.d.mts +11 -6
  65. package/dist/zod-v3.mjs +17 -4
  66. package/dist/zod-v4.d.mts +12 -6
  67. package/dist/zod-v4.mjs +16 -4
  68. package/dist/zod.d.mts +4 -3
  69. package/dist/zod.mjs +5 -4
  70. package/package.json +23 -8
  71. package/skills/attaform/SKILL.md +2 -1
  72. package/dist/abstract.cjs +0 -48
  73. package/dist/abstract.cjs.map +0 -1
  74. package/dist/abstract.d.cts +0 -42
  75. package/dist/abstract.d.ts +0 -42
  76. package/dist/abstract.mjs.map +0 -1
  77. package/dist/chunks/dev-key-collision-warnings.cjs +0 -25
  78. package/dist/chunks/dev-key-collision-warnings.cjs.map +0 -1
  79. package/dist/chunks/dev-key-collision-warnings.mjs.map +0 -1
  80. package/dist/chunks/devtools.cjs +0 -157
  81. package/dist/chunks/devtools.cjs.map +0 -1
  82. package/dist/chunks/devtools.mjs.map +0 -1
  83. package/dist/chunks/fingerprint.cjs.map +0 -1
  84. package/dist/chunks/fingerprint.mjs.map +0 -1
  85. package/dist/chunks/fingerprint2.cjs.map +0 -1
  86. package/dist/chunks/fingerprint2.mjs.map +0 -1
  87. package/dist/esbuild.cjs +0 -28
  88. package/dist/esbuild.cjs.map +0 -1
  89. package/dist/esbuild.d.cts +0 -56
  90. package/dist/esbuild.d.ts +0 -56
  91. package/dist/esbuild.mjs.map +0 -1
  92. package/dist/index.cjs +0 -51
  93. package/dist/index.cjs.map +0 -1
  94. package/dist/index.d.cts +0 -249
  95. package/dist/index.d.ts +0 -249
  96. package/dist/index.mjs.map +0 -1
  97. package/dist/nuxt.cjs +0 -84
  98. package/dist/nuxt.cjs.map +0 -1
  99. package/dist/nuxt.d.cts +0 -66
  100. package/dist/nuxt.d.ts +0 -66
  101. package/dist/nuxt.mjs.map +0 -1
  102. package/dist/rollup.cjs +0 -24
  103. package/dist/rollup.cjs.map +0 -1
  104. package/dist/rollup.d.cts +0 -35
  105. package/dist/rollup.d.ts +0 -35
  106. package/dist/rollup.mjs.map +0 -1
  107. package/dist/rspack.cjs +0 -10
  108. package/dist/rspack.cjs.map +0 -1
  109. package/dist/rspack.d.cts +0 -40
  110. package/dist/rspack.d.ts +0 -40
  111. package/dist/rspack.mjs.map +0 -1
  112. package/dist/runtime/components/AttaformDevtoolsPanel.vue.d.ts +0 -7
  113. package/dist/runtime/components/DevtoolsValueTree.vue.d.ts +0 -35
  114. package/dist/runtime/plugins/attaform.cjs +0 -43
  115. package/dist/runtime/plugins/attaform.cjs.map +0 -1
  116. package/dist/runtime/plugins/attaform.d.cts +0 -5
  117. package/dist/runtime/plugins/attaform.d.ts +0 -5
  118. package/dist/runtime/plugins/attaform.mjs.map +0 -1
  119. package/dist/shared/attaform.B1ZYt2Li.mjs.map +0 -1
  120. package/dist/shared/attaform.B9Wyhfro.cjs.map +0 -1
  121. package/dist/shared/attaform.BGDV42hI.d.cts +0 -232
  122. package/dist/shared/attaform.BJGA_UOS.mjs.map +0 -1
  123. package/dist/shared/attaform.Biytrv0-.cjs.map +0 -1
  124. package/dist/shared/attaform.Bn0IzhD_.cjs +0 -800
  125. package/dist/shared/attaform.Bn0IzhD_.cjs.map +0 -1
  126. package/dist/shared/attaform.C9fPTxjB.d.cts +0 -41
  127. package/dist/shared/attaform.C9fPTxjB.d.ts +0 -41
  128. package/dist/shared/attaform.CKH2lGdL.mjs.map +0 -1
  129. package/dist/shared/attaform.CQN9R62B.cjs.map +0 -1
  130. package/dist/shared/attaform.CoR4mWfv.mjs.map +0 -1
  131. package/dist/shared/attaform.Cs2Rbdlo.mjs.map +0 -1
  132. package/dist/shared/attaform.D6tk90Rc.cjs.map +0 -1
  133. package/dist/shared/attaform.D8kliaKw.cjs.map +0 -1
  134. package/dist/shared/attaform.DLknk9nF.d.mts +0 -232
  135. package/dist/shared/attaform.DMxM2kol.mjs.map +0 -1
  136. package/dist/shared/attaform.DRUT703x.d.cts +0 -56
  137. package/dist/shared/attaform.DRUT703x.d.ts +0 -56
  138. package/dist/shared/attaform.DYEr28Pt.mjs.map +0 -1
  139. package/dist/shared/attaform.DdQN7sgN.cjs.map +0 -1
  140. package/dist/shared/attaform.DhnPb6nK.mjs.map +0 -1
  141. package/dist/shared/attaform.DniawQLP.d.mts +0 -4763
  142. package/dist/shared/attaform.DniawQLP.d.ts +0 -4763
  143. package/dist/shared/attaform.DoQm_Vkd.cjs +0 -58
  144. package/dist/shared/attaform.DoQm_Vkd.cjs.map +0 -1
  145. package/dist/shared/attaform.DrvMscNX.cjs.map +0 -1
  146. package/dist/shared/attaform.F2Q8iv38.d.ts +0 -2494
  147. package/dist/shared/attaform.FmqKO1Ex.d.cts +0 -2494
  148. package/dist/shared/attaform.KvlEedlF.mjs.map +0 -1
  149. package/dist/shared/attaform.RaTzp1WF.cjs +0 -26
  150. package/dist/shared/attaform.RaTzp1WF.cjs.map +0 -1
  151. package/dist/shared/attaform.nMaz2C5P.mjs.map +0 -1
  152. package/dist/shared/attaform.v0fQtWyA.mjs.map +0 -1
  153. package/dist/shared/attaform.yUrz7C2z.cjs +0 -29
  154. package/dist/shared/attaform.yUrz7C2z.cjs.map +0 -1
  155. package/dist/transforms.cjs +0 -12
  156. package/dist/transforms.cjs.map +0 -1
  157. package/dist/transforms.d.cts +0 -73
  158. package/dist/transforms.d.ts +0 -73
  159. package/dist/transforms.mjs.map +0 -1
  160. package/dist/vite.cjs +0 -363
  161. package/dist/vite.cjs.map +0 -1
  162. package/dist/vite.d.cts +0 -133
  163. package/dist/vite.d.ts +0 -133
  164. package/dist/vite.mjs.map +0 -1
  165. package/dist/webpack.cjs +0 -10
  166. package/dist/webpack.cjs.map +0 -1
  167. package/dist/webpack.d.cts +0 -37
  168. package/dist/webpack.d.ts +0 -37
  169. package/dist/webpack.mjs.map +0 -1
  170. package/dist/zod-v3.cjs +0 -53
  171. package/dist/zod-v3.cjs.map +0 -1
  172. package/dist/zod-v3.d.cts +0 -246
  173. package/dist/zod-v3.d.ts +0 -246
  174. package/dist/zod-v3.mjs.map +0 -1
  175. package/dist/zod-v4.cjs +0 -55
  176. package/dist/zod-v4.cjs.map +0 -1
  177. package/dist/zod-v4.d.cts +0 -172
  178. package/dist/zod-v4.d.ts +0 -172
  179. package/dist/zod-v4.mjs.map +0 -1
  180. package/dist/zod.cjs +0 -51
  181. package/dist/zod.cjs.map +0 -1
  182. package/dist/zod.d.cts +0 -7
  183. package/dist/zod.d.ts +0 -7
  184. package/dist/zod.mjs.map +0 -1
@@ -1,7 +1,6 @@
1
- 'use strict';
2
-
3
- const serializeScript = require('./attaform.DrvMscNX.cjs');
4
- const devtoolsShared = require('./attaform.Biytrv0-.cjs');
1
+ import { A as AttaformErrorCode, n as isPlainRecord, s as slimKindOf } from './attaform-dev.WmuhD_CZ.mjs';
2
+ import { e as canonicalizePath } from './attaform-dev.Dr2YzS5B.mjs';
3
+ import { a as safeOwnRead, b as safeAssign } from './attaform-dev.By4PRjt0.mjs';
5
4
 
6
5
  const PATH_SEPARATOR = ".";
7
6
  function createAbstractSchema(rootSchema, intro, services, formKey, options) {
@@ -11,6 +10,7 @@ function createAbstractSchema(rootSchema, intro, services, formKey, options) {
11
10
  const discriminatorCache = /* @__PURE__ */ new Map();
12
11
  let asyncValidationFlag = null;
13
12
  let containerRefineFlag = null;
13
+ let discriminatedUnionFlag = null;
14
14
  function computeDiscriminator(path) {
15
15
  const candidates = path.length === 0 ? [rootSchema] : services.getNestedSchemasAtPath(rootSchema, path, maxRecursionDepth);
16
16
  let matchedUnion;
@@ -62,6 +62,10 @@ function createAbstractSchema(rootSchema, intro, services, formKey, options) {
62
62
  containerRefineFlag ?? (containerRefineFlag = intro.hasContainerOrRootRefine(rootSchema));
63
63
  return containerRefineFlag;
64
64
  },
65
+ hasDiscriminatedUnions() {
66
+ discriminatedUnionFlag ?? (discriminatedUnionFlag = intro.containsDiscriminatedUnion(rootSchema));
67
+ return discriminatedUnionFlag;
68
+ },
65
69
  getDefaultValues(config) {
66
70
  return services.runStrictGetDefaults(rootSchema, config, formKey, maxRecursionDepth);
67
71
  },
@@ -83,14 +87,12 @@ function createAbstractSchema(rootSchema, intro, services, formKey, options) {
83
87
  return services.deriveDefault(first, false, maxRecursionDepth, formKey);
84
88
  },
85
89
  arrayShapeAtPath(path) {
86
- if (path.length === 0) return void 0;
90
+ if (path.length === 0) return null;
87
91
  const [first] = services.getNestedSchemasAtPath(rootSchema, path, maxRecursionDepth);
88
- if (first === void 0) return void 0;
92
+ if (first === void 0) return null;
89
93
  const peeled = services.peelAllWrappers(first);
90
- const kind = intro.kindOf(peeled);
91
- if (kind === "tuple") return intro.getTupleItems(peeled).length;
92
- if (kind === "array") return null;
93
- return void 0;
94
+ if (intro.kindOf(peeled) === "tuple") return intro.getTupleItems(peeled).length;
95
+ return null;
94
96
  },
95
97
  isFixedObjectAtPath(path) {
96
98
  if (path.length === 0) {
@@ -118,7 +120,7 @@ function createAbstractSchema(rootSchema, intro, services, formKey, options) {
118
120
  return out;
119
121
  },
120
122
  isLeafAtPath(path) {
121
- const cacheKey = devtoolsShared.canonicalizePath(path).key;
123
+ const cacheKey = canonicalizePath(path).key;
122
124
  const cached = leafCache.get(cacheKey);
123
125
  if (cached !== void 0) return cached;
124
126
  const prim = this.getSlimPrimitiveTypesAtPath(path);
@@ -127,7 +129,7 @@ function createAbstractSchema(rootSchema, intro, services, formKey, options) {
127
129
  return isLeaf;
128
130
  },
129
131
  isPreprocessOrCoerceLeaf(path) {
130
- const cacheKey = devtoolsShared.canonicalizePath(path).key;
132
+ const cacheKey = canonicalizePath(path).key;
131
133
  const cached = preprocessOrCoerceCache.get(cacheKey);
132
134
  if (cached !== void 0) return cached;
133
135
  let hit = false;
@@ -154,7 +156,7 @@ function createAbstractSchema(rootSchema, intro, services, formKey, options) {
154
156
  return services.resolveFieldMetaAtPath(rootSchema, path, maxRecursionDepth);
155
157
  },
156
158
  getUnionDiscriminatorAtPath(path) {
157
- const cacheKey = devtoolsShared.canonicalizePath(path).key;
159
+ const cacheKey = canonicalizePath(path).key;
158
160
  if (discriminatorCache.has(cacheKey)) {
159
161
  return discriminatorCache.get(cacheKey);
160
162
  }
@@ -174,7 +176,7 @@ function createAbstractSchema(rootSchema, intro, services, formKey, options) {
174
176
  function parseResultToResponse(result) {
175
177
  return result.success ? { data: result.data, errors: void 0, success: true, formKey } : {
176
178
  data: void 0,
177
- errors: services.issuesToValidationErrors(result.issues, formKey),
179
+ errors: services.issuesToValidationErrors(result.issues),
178
180
  success: false,
179
181
  formKey
180
182
  };
@@ -227,8 +229,7 @@ function createAbstractSchema(rootSchema, intro, services, formKey, options) {
227
229
  {
228
230
  message,
229
231
  path: [...errPath],
230
- formKey,
231
- code: serializeScript.AttaformErrorCode.ValidatorThrew
232
+ code: AttaformErrorCode.ValidatorThrew
232
233
  }
233
234
  ],
234
235
  success: false,
@@ -242,8 +243,7 @@ function createAbstractSchema(rootSchema, intro, services, formKey, options) {
242
243
  {
243
244
  message: `Path '${p.join(PATH_SEPARATOR)}' did not resolve to any schema`,
244
245
  path: [...p],
245
- formKey,
246
- code: serializeScript.AttaformErrorCode.PathNotFound
246
+ code: AttaformErrorCode.PathNotFound
247
247
  }
248
248
  ],
249
249
  success: false,
@@ -257,16 +257,16 @@ function createAbstractSchema(rootSchema, intro, services, formKey, options) {
257
257
 
258
258
  function mergeDeep(base, override) {
259
259
  if (override === void 0) return base;
260
- if (!serializeScript.isPlainRecord(override)) return override;
261
- if (!serializeScript.isPlainRecord(base)) return override;
260
+ if (!isPlainRecord(override)) return override;
261
+ if (!isPlainRecord(base)) return override;
262
262
  const result = { ...base };
263
263
  for (const key of Object.keys(override)) {
264
- const oVal = serializeScript.safeOwnRead(override, key);
265
- const bVal = serializeScript.safeOwnRead(base, key);
266
- if (serializeScript.isPlainRecord(oVal) && serializeScript.isPlainRecord(bVal)) {
267
- serializeScript.safeAssign(result, key, mergeDeep(bVal, oVal));
264
+ const oVal = safeOwnRead(override, key);
265
+ const bVal = safeOwnRead(base, key);
266
+ if (isPlainRecord(oVal) && isPlainRecord(bVal)) {
267
+ safeAssign(result, key, mergeDeep(bVal, oVal));
268
268
  } else {
269
- serializeScript.safeAssign(result, key, oVal);
269
+ safeAssign(result, key, oVal);
270
270
  }
271
271
  }
272
272
  return result;
@@ -359,6 +359,144 @@ function walkPathSegments(schema, segments, intro, maxDepth, lazyDepth) {
359
359
  }
360
360
  }
361
361
 
362
+ function fixStructuralDefaults(schema, merged, useDefault, maxRecursionDepth, services) {
363
+ const ctx = {
364
+ useDefault,
365
+ maxDepth: maxRecursionDepth,
366
+ clean: true,
367
+ services
368
+ };
369
+ const data = fixNode(schema, merged, ctx, 0);
370
+ return { data, success: ctx.clean };
371
+ }
372
+ function fixNode(schema, value, ctx, lazyDepth) {
373
+ const { intro } = ctx.services;
374
+ if (intro.isCoercePrimitive(schema) || intro.isPreprocessNode(schema)) return value;
375
+ const kinds = ctx.services.slimPrimitivesOf(schema);
376
+ if (kinds.size > 0 && !kinds.has(slimKindOf(value))) {
377
+ const replacement = deriveFixValue(schema, value, ctx);
378
+ if (kinds.has(slimKindOf(replacement))) return replacement;
379
+ ctx.clean = false;
380
+ return replacement;
381
+ }
382
+ switch (intro.kindOf(schema)) {
383
+ case "optional":
384
+ case "nullable": {
385
+ if (value === void 0 || value === null) return value;
386
+ const inner = intro.unwrapInner(schema);
387
+ return inner === void 0 ? value : fixNode(inner, value, ctx, lazyDepth);
388
+ }
389
+ case "default":
390
+ case "readonly":
391
+ case "catch": {
392
+ const inner = intro.unwrapInner(schema);
393
+ return inner === void 0 ? value : fixNode(inner, value, ctx, lazyDepth);
394
+ }
395
+ case "branded": {
396
+ const inner = intro.unwrapBranded(schema);
397
+ return inner === void 0 ? value : fixNode(inner, value, ctx, lazyDepth);
398
+ }
399
+ case "effects": {
400
+ const inner = intro.unwrapEffectsSource(schema);
401
+ return inner === void 0 ? value : fixNode(inner, value, ctx, lazyDepth);
402
+ }
403
+ case "pipe":
404
+ case "pipeline": {
405
+ const pipeIn = intro.unwrapPipeIn(schema);
406
+ if (pipeIn === void 0 || intro.kindOf(pipeIn) === "transform") return value;
407
+ return fixNode(pipeIn, value, ctx, lazyDepth);
408
+ }
409
+ case "lazy": {
410
+ if (lazyDepth >= ctx.maxDepth) return value;
411
+ const inner = intro.unwrapLazy(schema);
412
+ return inner === void 0 ? value : fixNode(inner, value, ctx, lazyDepth + 1);
413
+ }
414
+ case "discriminated-union": {
415
+ if (value === null || typeof value !== "object") return value;
416
+ const variant = selectVariantByValue(schema, value, intro);
417
+ if (variant === void 0) return value;
418
+ const record = value;
419
+ const shape = intro.getObjectShape(variant);
420
+ for (const key of Object.keys(record)) {
421
+ if (!(key in shape)) delete record[key];
422
+ }
423
+ for (const [key, sub] of Object.entries(shape)) {
424
+ record[key] = fixNode(sub, record[key], ctx, lazyDepth);
425
+ }
426
+ return value;
427
+ }
428
+ case "object": {
429
+ if (value === null || typeof value !== "object") return value;
430
+ const record = value;
431
+ for (const [key, sub] of Object.entries(intro.getObjectShape(schema))) {
432
+ record[key] = fixNode(sub, record[key], ctx, lazyDepth);
433
+ }
434
+ return value;
435
+ }
436
+ case "array": {
437
+ if (!Array.isArray(value)) return value;
438
+ const element = intro.getArrayElement(schema);
439
+ if (element === void 0) return value;
440
+ for (let i = 0; i < value.length; i++) {
441
+ value[i] = fixNode(element, value[i], ctx, lazyDepth);
442
+ }
443
+ return value;
444
+ }
445
+ case "tuple": {
446
+ if (!Array.isArray(value)) return value;
447
+ const items = intro.getTupleItems(schema);
448
+ for (let i = 0; i < items.length; i++) {
449
+ const item = items[i];
450
+ if (item !== void 0) value[i] = fixNode(item, value[i], ctx, lazyDepth);
451
+ }
452
+ return value;
453
+ }
454
+ case "record": {
455
+ if (value === null || typeof value !== "object") return value;
456
+ const valueType = intro.getRecordValueType(schema);
457
+ if (valueType === void 0) return value;
458
+ const record = value;
459
+ for (const key of Object.keys(record)) {
460
+ record[key] = fixNode(valueType, record[key], ctx, lazyDepth);
461
+ }
462
+ return value;
463
+ }
464
+ case "intersection": {
465
+ const left = intro.getIntersectionLeft(schema);
466
+ const right = intro.getIntersectionRight(schema);
467
+ let out = value;
468
+ if (left !== void 0) out = fixNode(left, out, ctx, lazyDepth);
469
+ if (right !== void 0) out = fixNode(right, out, ctx, lazyDepth);
470
+ return out;
471
+ }
472
+ default:
473
+ return value;
474
+ }
475
+ }
476
+ function deriveFixValue(schema, value, ctx) {
477
+ const du = ctx.services.unwrapToDiscriminatedUnion(schema);
478
+ if (du !== void 0) {
479
+ const selected = selectVariantByValue(du, value, ctx.services.intro) ?? ctx.services.intro.getDiscriminatedOptions(du)[0];
480
+ if (selected !== void 0) {
481
+ return ctx.services.deriveDefault(selected, ctx.useDefault);
482
+ }
483
+ }
484
+ return ctx.services.deriveDefault(schema, ctx.useDefault);
485
+ }
486
+ function selectVariantByValue(du, value, intro) {
487
+ if (value === null || typeof value !== "object") return void 0;
488
+ const discKey = intro.getDiscriminator(du);
489
+ if (discKey === void 0) return void 0;
490
+ const discValue = value[discKey];
491
+ if (discValue === void 0) return void 0;
492
+ for (const opt of intro.getDiscriminatedOptions(du)) {
493
+ const litSchema = intro.getObjectShape(opt)[discKey];
494
+ if (litSchema === void 0 || intro.kindOf(litSchema) !== "literal") continue;
495
+ if (intro.getLiteralValues(litSchema).includes(discValue)) return opt;
496
+ }
497
+ return void 0;
498
+ }
499
+
362
500
  const NO_EMBEDDED_DEFAULT = /* @__PURE__ */ Symbol("atta:no-embedded-default");
363
501
  function peelEmbeddedDefault(schema, intro) {
364
502
  let current = schema;
@@ -417,7 +555,7 @@ function deriveDefaultWalk(schema, useDefault, intro, maxDepth, ctx, lazyDepth =
417
555
  const shape = intro.getObjectShape(schema);
418
556
  const out = {};
419
557
  for (const [key, subSchema] of Object.entries(shape)) {
420
- serializeScript.safeAssign(
558
+ safeAssign(
421
559
  out,
422
560
  key,
423
561
  deriveDefaultWalk(subSchema, useDefault, intro, maxDepth, ctx, lazyDepth)
@@ -541,9 +679,6 @@ function deriveDefaultWalk(schema, useDefault, intro, maxDepth, ctx, lazyDepth =
541
679
  }
542
680
  case "catch": {
543
681
  if (useDefault) return intro.getCatchDefault(schema);
544
- if (ctx.catchOnUseDefaultFalse === "preserveCatch" && intro.hasCatchValue(schema)) {
545
- return intro.getCatchDefault(schema);
546
- }
547
682
  const inner = intro.unwrapInner(schema);
548
683
  return inner === void 0 ? void 0 : deriveDefaultWalk(inner, useDefault, intro, maxDepth, ctx, lazyDepth);
549
684
  }
@@ -595,6 +730,13 @@ function getFieldMetaForSchema(schema) {
595
730
  function getFieldMetaListForSchema(schema) {
596
731
  return lists.get(schema) ?? [];
597
732
  }
733
+ let pathMapBuilder = null;
734
+ function installFieldMetaPathMapBuilder(builder) {
735
+ pathMapBuilder = builder;
736
+ }
737
+ function buildFieldMetaPathMap(rootSchema, services) {
738
+ return pathMapBuilder === null ? void 0 : pathMapBuilder(rootSchema, services);
739
+ }
598
740
 
599
741
  const PERMISSIVE_SLIM_KINDS = /* @__PURE__ */ new Set([
600
742
  "string",
@@ -667,7 +809,7 @@ function slimPrimitivesWalk(schema, intro, maxDepth, lazyDepth = 0) {
667
809
  case "literal": {
668
810
  const values = intro.getLiteralValues(schema);
669
811
  const out = /* @__PURE__ */ new Set();
670
- for (const v of values) out.add(serializeScript.slimKindOf(v));
812
+ for (const v of values) out.add(slimKindOf(v));
671
813
  return out.size === 0 ? PERMISSIVE_SLIM_KINDS : out;
672
814
  }
673
815
  case "object":
@@ -754,6 +896,19 @@ function slimPrimitivesWalk(schema, intro, maxDepth, lazyDepth = 0) {
754
896
  }
755
897
  }
756
898
 
899
+ const installingFieldMetaStore = {
900
+ add(schema, payload) {
901
+ installFieldMetaPathMapBuilder(getFieldMetaPathMap);
902
+ fieldMetaStore.add(schema, payload);
903
+ return installingFieldMetaStore;
904
+ },
905
+ get: (schema) => fieldMetaStore.get(schema),
906
+ has: (schema) => fieldMetaStore.has(schema),
907
+ remove: (schema) => {
908
+ fieldMetaStore.remove(schema);
909
+ return installingFieldMetaStore;
910
+ }
911
+ };
757
912
  const pathMetaCache = /* @__PURE__ */ new WeakMap();
758
913
  function getFieldMetaPathMap(rootSchema, services) {
759
914
  const cached = pathMetaCache.get(rootSchema);
@@ -787,7 +942,7 @@ function walkForMeta(schema, path, map, counters, lastPathPerSchema, inProgress,
787
942
  inProgress.add(schema);
788
943
  try {
789
944
  const { intro, peelAllWrappers, getFieldMetaList } = services;
790
- const pathKey = devtoolsShared.canonicalizePath(path).key;
945
+ const pathKey = canonicalizePath(path).key;
791
946
  if (!map.has(pathKey)) {
792
947
  const payload = consumePayload(schema, counters, getFieldMetaList);
793
948
  if (payload !== void 0) {
@@ -905,15 +1060,4 @@ function walkForMeta(schema, path, map, counters, lastPathPerSchema, inProgress,
905
1060
  }
906
1061
  }
907
1062
 
908
- exports.NO_EMBEDDED_DEFAULT = NO_EMBEDDED_DEFAULT;
909
- exports.createAbstractSchema = createAbstractSchema;
910
- exports.deriveDefaultWalk = deriveDefaultWalk;
911
- exports.fieldMetaStore = fieldMetaStore;
912
- exports.getFieldMetaForSchema = getFieldMetaForSchema;
913
- exports.getFieldMetaListForSchema = getFieldMetaListForSchema;
914
- exports.getFieldMetaPathMap = getFieldMetaPathMap;
915
- exports.mergeDeep = mergeDeep;
916
- exports.peelEmbeddedDefault = peelEmbeddedDefault;
917
- exports.slimPrimitivesWalk = slimPrimitivesWalk;
918
- exports.walkPathSegments = walkPathSegments;
919
- //# sourceMappingURL=attaform.D6tk90Rc.cjs.map
1063
+ export { getFieldMetaListForSchema as a, buildFieldMetaPathMap as b, createAbstractSchema as c, deriveDefaultWalk as d, fixStructuralDefaults as f, getFieldMetaForSchema as g, installingFieldMetaStore as i, mergeDeep as m, slimPrimitivesWalk as s, walkPathSegments as w };
@@ -1,5 +1,3 @@
1
- 'use strict';
2
-
3
1
  function canonicalStringify(value, seen = /* @__PURE__ */ new WeakSet()) {
4
2
  if (value === null) return "null";
5
3
  if (value === void 0) return "undefined";
@@ -35,5 +33,4 @@ function canonicalStringify(value, seen = /* @__PURE__ */ new WeakSet()) {
35
33
  return "unknown";
36
34
  }
37
35
 
38
- exports.canonicalStringify = canonicalStringify;
39
- //# sourceMappingURL=attaform.CQN9R62B.cjs.map
36
+ export { canonicalStringify as c };
@@ -1,7 +1,7 @@
1
- import { a as InvalidUseFormConfigError } from './attaform.nMaz2C5P.mjs';
2
- import { u as useForm$2 } from './attaform.B1ZYt2Li.mjs';
3
- import { u as useForm$1 } from './attaform.DMxM2kol.mjs';
4
- import { f as fieldMetaStore, g as getFieldMetaForSchema } from './attaform.CoR4mWfv.mjs';
1
+ import { a as InvalidUseFormConfigError } from './attaform-dev.Dr2YzS5B.mjs';
2
+ import { u as useForm$2 } from './attaform-dev.D2I8e_Mm.mjs';
3
+ import { u as useForm$1 } from './attaform-dev.oYrkP9dj.mjs';
4
+ import { i as installingFieldMetaStore, g as getFieldMetaForSchema } from './attaform-dev.6qxD-Yqo.mjs';
5
5
 
6
6
  function isZodV4SchemaShape(value) {
7
7
  if (typeof value !== "object" || value === null) return false;
@@ -21,12 +21,12 @@ function useForm(configuration) {
21
21
  return useForm$2(configuration);
22
22
  }
23
23
 
24
- const fieldMeta = fieldMetaStore;
24
+ const fieldMeta = installingFieldMetaStore;
25
25
  function withMeta(schema, payload) {
26
26
  const target = schema;
27
27
  const existing = getFieldMetaForSchema(target) ?? {};
28
28
  const cloned = cloneSchema(schema);
29
- fieldMetaStore.add(cloned, { ...existing, ...payload });
29
+ installingFieldMetaStore.add(cloned, { ...existing, ...payload });
30
30
  return cloned;
31
31
  }
32
32
  function cloneSchema(schema) {
@@ -39,4 +39,3 @@ function cloneSchema(schema) {
39
39
  }
40
40
 
41
41
  export { fieldMeta as f, useForm as u, withMeta as w };
42
- //# sourceMappingURL=attaform.DYEr28Pt.mjs.map
@@ -0,0 +1,220 @@
1
+ import { c as RegistryNotInstalledError, O as OutsideSetupError, g as pathKeyToDotted } from './attaform-dev.Dr2YzS5B.mjs';
2
+ import { shallowReactive, getCurrentInstance, inject } from 'vue';
3
+
4
+ function detectSSR(options = {}) {
5
+ if (options.ssr !== void 0) return options.ssr;
6
+ return typeof window === "undefined" && typeof document === "undefined";
7
+ }
8
+
9
+ const kAttaformRegistry = /* @__PURE__ */ Symbol.for("attaform:registry");
10
+ const kAttaformAncestorWizard = /* @__PURE__ */ Symbol.for(
11
+ "attaform:ancestor-wizard"
12
+ );
13
+ const kAttaformWizardActiveStepResolver = /* @__PURE__ */ Symbol.for(
14
+ "attaform:wizard-active-step-resolver"
15
+ );
16
+ const kFormContext = /* @__PURE__ */ Symbol.for("attaform:form-context");
17
+ const kFormInstanceId = /* @__PURE__ */ Symbol.for("attaform:form-instance-id");
18
+ function createRegistry(options = {}) {
19
+ const ssr = detectSSR(options);
20
+ const defaults = Object.freeze({ ...options.defaults ?? {} });
21
+ const forms = shallowReactive(/* @__PURE__ */ new Map());
22
+ const wizards = shallowReactive(/* @__PURE__ */ new Map());
23
+ const pendingHydration = shallowReactive(/* @__PURE__ */ new Map());
24
+ const consumers = /* @__PURE__ */ new Map();
25
+ const pendingEvictions = /* @__PURE__ */ new Map();
26
+ function cancelPendingEviction(key) {
27
+ const pending = pendingEvictions.get(key);
28
+ if (pending === void 0) return;
29
+ pending.cancelled = true;
30
+ pendingEvictions.delete(key);
31
+ }
32
+ function trackConsumer(key) {
33
+ cancelPendingEviction(key);
34
+ consumers.set(key, (consumers.get(key) ?? 0) + 1);
35
+ let disposed = false;
36
+ return () => {
37
+ if (disposed) return;
38
+ disposed = true;
39
+ const remaining = (consumers.get(key) ?? 1) - 1;
40
+ if (remaining > 0) {
41
+ consumers.set(key, remaining);
42
+ return;
43
+ }
44
+ consumers.delete(key);
45
+ const token = { cancelled: false };
46
+ pendingEvictions.set(key, token);
47
+ queueMicrotask(() => {
48
+ if (token.cancelled) return;
49
+ if (pendingEvictions.get(key) !== token) return;
50
+ pendingEvictions.delete(key);
51
+ const state = forms.get(key);
52
+ forms.delete(key);
53
+ if (state === void 0) return;
54
+ state.dispose();
55
+ });
56
+ };
57
+ }
58
+ const wizardConsumers = /* @__PURE__ */ new Map();
59
+ const pendingWizardEvictions = /* @__PURE__ */ new Map();
60
+ function cancelPendingWizardEviction(key) {
61
+ const pending = pendingWizardEvictions.get(key);
62
+ if (pending === void 0) return;
63
+ pending.cancelled = true;
64
+ pendingWizardEvictions.delete(key);
65
+ }
66
+ function trackWizardConsumer(key) {
67
+ cancelPendingWizardEviction(key);
68
+ wizardConsumers.set(key, (wizardConsumers.get(key) ?? 0) + 1);
69
+ let disposed = false;
70
+ return () => {
71
+ if (disposed) return;
72
+ disposed = true;
73
+ const remaining = (wizardConsumers.get(key) ?? 1) - 1;
74
+ if (remaining > 0) {
75
+ wizardConsumers.set(key, remaining);
76
+ return;
77
+ }
78
+ wizardConsumers.delete(key);
79
+ const token = { cancelled: false };
80
+ pendingWizardEvictions.set(key, token);
81
+ queueMicrotask(() => {
82
+ if (token.cancelled) return;
83
+ if (pendingWizardEvictions.get(key) !== token) return;
84
+ pendingWizardEvictions.delete(key);
85
+ wizards.delete(key);
86
+ });
87
+ };
88
+ }
89
+ const prefetchEnqueued = /* @__PURE__ */ new Set();
90
+ const prefetchSkipped = /* @__PURE__ */ new Set();
91
+ function enqueuePrefetch(key) {
92
+ prefetchEnqueued.add(key);
93
+ }
94
+ function skipPrefetch(key) {
95
+ prefetchSkipped.add(key);
96
+ }
97
+ function shouldPrefetch(key) {
98
+ return prefetchEnqueued.has(key) && !prefetchSkipped.has(key);
99
+ }
100
+ return {
101
+ forms,
102
+ wizards,
103
+ pendingHydration,
104
+ ssr,
105
+ defaults,
106
+ trackConsumer,
107
+ trackWizardConsumer,
108
+ enqueuePrefetch,
109
+ skipPrefetch,
110
+ shouldPrefetch
111
+ };
112
+ }
113
+ function useRegistry() {
114
+ const instance = getCurrentInstance();
115
+ if (instance === null) {
116
+ throw new OutsideSetupError();
117
+ }
118
+ const registry = inject(kAttaformRegistry, null);
119
+ if (registry === null) {
120
+ throw new RegistryNotInstalledError();
121
+ }
122
+ return registry;
123
+ }
124
+ function getRegistryFromApp(app) {
125
+ const registry = app._attaform;
126
+ if (registry === void 0) {
127
+ throw new RegistryNotInstalledError();
128
+ }
129
+ return registry;
130
+ }
131
+ function attachRegistryToApp(app, registry) {
132
+ app.provide(kAttaformRegistry, registry);
133
+ app._attaform = registry;
134
+ }
135
+
136
+ function installAttaformOnApp(app, options, source) {
137
+ if (app._attaform !== void 0) {
138
+ if (source === "explicit") {
139
+ console.warn(
140
+ "[attaform] createAttaform() install was called twice on the same app; the second call is a no-op. Likely cause: registering the plugin via both the Nuxt module AND a manual `app.use(...)`."
141
+ );
142
+ }
143
+ return app._attaform;
144
+ }
145
+ const registry = createRegistry(options);
146
+ attachRegistryToApp(app, registry);
147
+ if (options.devtools !== false && !registry.ssr) {
148
+ void (async () => {
149
+ try {
150
+ const { setupAttaformDevtools } = await import('../chunks/devtools.mjs');
151
+ await setupAttaformDevtools(app, registry);
152
+ } catch {
153
+ }
154
+ })();
155
+ }
156
+ return registry;
157
+ }
158
+ function ensureAttaformInstalled(app) {
159
+ return installAttaformOnApp(app, {}, "lazy");
160
+ }
161
+ function createAttaform(options = {}) {
162
+ const plugin = {
163
+ install(app) {
164
+ installAttaformOnApp(app, options, "explicit");
165
+ }
166
+ };
167
+ return plugin;
168
+ }
169
+
170
+ const ATTAFORM_STATE_VERSION = 1;
171
+ function renderAttaformState(app) {
172
+ const registry = getRegistryFromApp(app);
173
+ const forms = [];
174
+ for (const [key, state] of registry.forms) {
175
+ const transientList = [];
176
+ for (const pk of state.blankPaths) {
177
+ const d = pathKeyToDotted(pk);
178
+ if (d !== null) transientList.push(d);
179
+ }
180
+ forms.push([
181
+ key,
182
+ {
183
+ form: state.form.value,
184
+ // The wire shape stays two per-source arrays; the tagged store
185
+ // splits at the boundary and the client replays each side into
186
+ // its cell half.
187
+ schemaErrors: [...state.errorCells.entries()].filter(([, cell]) => cell.schema.length > 0).map(([key2, cell]) => [key2, cell.schema]),
188
+ userErrors: [...state.errorCells.entries()].filter(([, cell]) => cell.user.length > 0).map(([key2, cell]) => [key2, cell.user]),
189
+ fields: Array.from(state.fields.entries()),
190
+ ...transientList.length > 0 ? { blankPaths: transientList } : {}
191
+ }
192
+ ]);
193
+ }
194
+ return { v: ATTAFORM_STATE_VERSION, forms };
195
+ }
196
+ function hydrateAttaformState(app, payload) {
197
+ if (!isHydratableEnvelope(payload)) {
198
+ {
199
+ let got = payload;
200
+ if (payload !== null && typeof payload === "object") {
201
+ got = "v" in payload ? payload.v : void 0;
202
+ }
203
+ 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).`
205
+ );
206
+ }
207
+ return;
208
+ }
209
+ const registry = getRegistryFromApp(app);
210
+ for (const [key, data] of payload.forms) {
211
+ registry.pendingHydration.set(key, data);
212
+ }
213
+ }
214
+ function isHydratableEnvelope(payload) {
215
+ return payload !== null && typeof payload === "object" && "v" in payload && payload.v === ATTAFORM_STATE_VERSION && "forms" in payload && Array.isArray(payload.forms);
216
+ }
217
+
218
+ const DEVTOOLS_WINDOW_KEY = "__attaform_devtools__";
219
+
220
+ export { DEVTOOLS_WINDOW_KEY as D, createRegistry as a, kAttaformWizardActiveStepResolver as b, createAttaform as c, kFormContext as d, ensureAttaformInstalled as e, kFormInstanceId as f, getRegistryFromApp as g, hydrateAttaformState as h, kAttaformAncestorWizard as i, kAttaformRegistry as k, renderAttaformState as r, useRegistry as u };