attaform 0.27.6 → 0.29.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 (192) hide show
  1. package/dist/abstract.d.mts +5 -4
  2. package/dist/abstract.mjs +4 -3
  3. package/dist/chunks/fingerprint.mjs +1 -2
  4. package/dist/chunks/fingerprint2.mjs +2 -3
  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/dev/shared/attaform-dev.A-TpJW0B.mjs +207 -0
  15. package/dist/dev/shared/attaform-dev.BO-71R54.mjs +820 -0
  16. package/dist/{shared/attaform.D6tk90Rc.cjs → dev/shared/attaform-dev.BgM6FdtA.mjs} +324 -73
  17. package/dist/dev/shared/attaform-dev.ButTkwHd.mjs +375 -0
  18. package/dist/{shared/attaform.BJGA_UOS.mjs → dev/shared/attaform-dev.BxfsuwBR.mjs} +8 -1
  19. package/dist/{shared/attaform.nMaz2C5P.mjs → dev/shared/attaform-dev.D8aoKb89.mjs} +190 -400
  20. package/dist/dev/shared/attaform-dev.DD5m2W51.mjs +220 -0
  21. package/dist/{shared/attaform.CKH2lGdL.mjs → dev/shared/attaform-dev.DHuydLAC.mjs} +3867 -4731
  22. package/dist/{shared/attaform.DYEr28Pt.mjs → dev/shared/attaform-dev.DrzObAZo.mjs} +6 -7
  23. package/dist/{shared/attaform.B1ZYt2Li.mjs → dev/shared/attaform-dev.q6UutkCx.mjs} +274 -672
  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 +14 -6
  33. package/dist/index.mjs +5 -4
  34. package/dist/nuxt.d.mts +10 -10
  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.CoR4mWfv.mjs → attaform.B0dKL8ST.mjs} +309 -46
  42. package/dist/shared/{attaform.Cs2Rbdlo.mjs → attaform.BK0cgu2K.mjs} +123 -140
  43. package/dist/shared/{attaform.B9Wyhfro.cjs → attaform.BndjUUYX.mjs} +11 -16
  44. package/dist/shared/{attaform.CQN9R62B.cjs → attaform.BxfsuwBR.mjs} +9 -4
  45. package/dist/shared/attaform.C2MVyuxC.mjs +811 -0
  46. package/dist/shared/{attaform.Fp3sCrVs.d.ts → attaform.CIWLMY-R.d.mts} +2 -2
  47. package/dist/shared/attaform.CZMAYwSK.mjs +6383 -0
  48. package/dist/shared/attaform.CZYt_5N_.mjs +207 -0
  49. package/dist/shared/{attaform.DniawQLP.d.cts → attaform.CsoeRi3P.d.mts} +490 -98
  50. package/dist/shared/attaform.Cvao8bW5.mjs +358 -0
  51. package/dist/shared/attaform.D0x-qSXm.mjs +197 -0
  52. package/dist/shared/{attaform.D8kliaKw.cjs → attaform.D1fnTifF.mjs} +279 -692
  53. package/dist/shared/{attaform.CHlJLAiv.d.mts → attaform.DDtqHYv1.d.mts} +155 -184
  54. package/dist/shared/{attaform.Biytrv0-.cjs → attaform.DffRL5pP.mjs} +215 -547
  55. package/dist/shared/attaform.DhnPb6nK.mjs +0 -1
  56. package/dist/shared/attaform.KvlEedlF.mjs +0 -1
  57. package/dist/shared/attaform.axHXVQO7.d.mts +44 -0
  58. package/dist/shared/attaform.v0fQtWyA.mjs +0 -1
  59. package/dist/transforms.d.mts +0 -22
  60. package/dist/transforms.mjs +1 -2
  61. package/dist/vite.d.mts +30 -9
  62. package/dist/vite.mjs +27 -4
  63. package/dist/webpack.d.mts +6 -1
  64. package/dist/webpack.mjs +0 -1
  65. package/dist/zod-v3.d.mts +13 -6
  66. package/dist/zod-v3.mjs +17 -4
  67. package/dist/zod-v4.d.mts +19 -26
  68. package/dist/zod-v4.mjs +16 -4
  69. package/dist/zod.d.mts +4 -3
  70. package/dist/zod.mjs +5 -4
  71. package/package.json +38 -20
  72. package/skills/attaform/SKILL.md +6 -2
  73. package/skills/attaform/references/custom-components.md +7 -2
  74. package/skills/attaform/references/errors.md +8 -3
  75. package/skills/attaform/references/saving.md +77 -0
  76. package/skills/attaform/references/wizards.md +10 -8
  77. package/dist/abstract.cjs +0 -48
  78. package/dist/abstract.cjs.map +0 -1
  79. package/dist/abstract.d.cts +0 -42
  80. package/dist/abstract.d.ts +0 -42
  81. package/dist/abstract.mjs.map +0 -1
  82. package/dist/chunks/dev-key-collision-warnings.cjs +0 -25
  83. package/dist/chunks/dev-key-collision-warnings.cjs.map +0 -1
  84. package/dist/chunks/dev-key-collision-warnings.mjs.map +0 -1
  85. package/dist/chunks/devtools.cjs +0 -157
  86. package/dist/chunks/devtools.cjs.map +0 -1
  87. package/dist/chunks/devtools.mjs.map +0 -1
  88. package/dist/chunks/fingerprint.cjs.map +0 -1
  89. package/dist/chunks/fingerprint.mjs.map +0 -1
  90. package/dist/chunks/fingerprint2.cjs.map +0 -1
  91. package/dist/chunks/fingerprint2.mjs.map +0 -1
  92. package/dist/esbuild.cjs +0 -28
  93. package/dist/esbuild.cjs.map +0 -1
  94. package/dist/esbuild.d.cts +0 -56
  95. package/dist/esbuild.d.ts +0 -56
  96. package/dist/esbuild.mjs.map +0 -1
  97. package/dist/index.cjs +0 -51
  98. package/dist/index.cjs.map +0 -1
  99. package/dist/index.d.cts +0 -249
  100. package/dist/index.d.ts +0 -249
  101. package/dist/index.mjs.map +0 -1
  102. package/dist/nuxt.cjs +0 -84
  103. package/dist/nuxt.cjs.map +0 -1
  104. package/dist/nuxt.d.cts +0 -66
  105. package/dist/nuxt.d.ts +0 -66
  106. package/dist/nuxt.mjs.map +0 -1
  107. package/dist/rollup.cjs +0 -24
  108. package/dist/rollup.cjs.map +0 -1
  109. package/dist/rollup.d.cts +0 -35
  110. package/dist/rollup.d.ts +0 -35
  111. package/dist/rollup.mjs.map +0 -1
  112. package/dist/rspack.cjs +0 -10
  113. package/dist/rspack.cjs.map +0 -1
  114. package/dist/rspack.d.cts +0 -40
  115. package/dist/rspack.d.ts +0 -40
  116. package/dist/rspack.mjs.map +0 -1
  117. package/dist/runtime/components/AttaformDevtoolsPanel.vue.d.ts +0 -7
  118. package/dist/runtime/components/DevtoolsValueTree.vue.d.ts +0 -35
  119. package/dist/runtime/plugins/attaform.cjs +0 -43
  120. package/dist/runtime/plugins/attaform.cjs.map +0 -1
  121. package/dist/runtime/plugins/attaform.d.cts +0 -5
  122. package/dist/runtime/plugins/attaform.d.ts +0 -5
  123. package/dist/runtime/plugins/attaform.mjs.map +0 -1
  124. package/dist/shared/attaform.B1ZYt2Li.mjs.map +0 -1
  125. package/dist/shared/attaform.B9Wyhfro.cjs.map +0 -1
  126. package/dist/shared/attaform.BGDV42hI.d.cts +0 -232
  127. package/dist/shared/attaform.BJGA_UOS.mjs.map +0 -1
  128. package/dist/shared/attaform.Biytrv0-.cjs.map +0 -1
  129. package/dist/shared/attaform.Bn0IzhD_.cjs +0 -800
  130. package/dist/shared/attaform.Bn0IzhD_.cjs.map +0 -1
  131. package/dist/shared/attaform.C9fPTxjB.d.cts +0 -41
  132. package/dist/shared/attaform.C9fPTxjB.d.ts +0 -41
  133. package/dist/shared/attaform.CKH2lGdL.mjs.map +0 -1
  134. package/dist/shared/attaform.CQN9R62B.cjs.map +0 -1
  135. package/dist/shared/attaform.CoR4mWfv.mjs.map +0 -1
  136. package/dist/shared/attaform.Cs2Rbdlo.mjs.map +0 -1
  137. package/dist/shared/attaform.D6tk90Rc.cjs.map +0 -1
  138. package/dist/shared/attaform.D8kliaKw.cjs.map +0 -1
  139. package/dist/shared/attaform.DLknk9nF.d.mts +0 -232
  140. package/dist/shared/attaform.DMxM2kol.mjs +0 -1275
  141. package/dist/shared/attaform.DMxM2kol.mjs.map +0 -1
  142. package/dist/shared/attaform.DRUT703x.d.cts +0 -56
  143. package/dist/shared/attaform.DRUT703x.d.ts +0 -56
  144. package/dist/shared/attaform.DYEr28Pt.mjs.map +0 -1
  145. package/dist/shared/attaform.DdQN7sgN.cjs +0 -1302
  146. package/dist/shared/attaform.DdQN7sgN.cjs.map +0 -1
  147. package/dist/shared/attaform.DhnPb6nK.mjs.map +0 -1
  148. package/dist/shared/attaform.DniawQLP.d.mts +0 -4763
  149. package/dist/shared/attaform.DniawQLP.d.ts +0 -4763
  150. package/dist/shared/attaform.DoQm_Vkd.cjs +0 -58
  151. package/dist/shared/attaform.DoQm_Vkd.cjs.map +0 -1
  152. package/dist/shared/attaform.DrvMscNX.cjs +0 -7697
  153. package/dist/shared/attaform.DrvMscNX.cjs.map +0 -1
  154. package/dist/shared/attaform.F2Q8iv38.d.ts +0 -2494
  155. package/dist/shared/attaform.FmqKO1Ex.d.cts +0 -2494
  156. package/dist/shared/attaform.KvlEedlF.mjs.map +0 -1
  157. package/dist/shared/attaform.RaTzp1WF.cjs +0 -26
  158. package/dist/shared/attaform.RaTzp1WF.cjs.map +0 -1
  159. package/dist/shared/attaform.nMaz2C5P.mjs.map +0 -1
  160. package/dist/shared/attaform.v0fQtWyA.mjs.map +0 -1
  161. package/dist/shared/attaform.yUrz7C2z.cjs +0 -29
  162. package/dist/shared/attaform.yUrz7C2z.cjs.map +0 -1
  163. package/dist/transforms.cjs +0 -12
  164. package/dist/transforms.cjs.map +0 -1
  165. package/dist/transforms.d.cts +0 -73
  166. package/dist/transforms.d.ts +0 -73
  167. package/dist/transforms.mjs.map +0 -1
  168. package/dist/vite.cjs +0 -363
  169. package/dist/vite.cjs.map +0 -1
  170. package/dist/vite.d.cts +0 -133
  171. package/dist/vite.d.ts +0 -133
  172. package/dist/vite.mjs.map +0 -1
  173. package/dist/webpack.cjs +0 -10
  174. package/dist/webpack.cjs.map +0 -1
  175. package/dist/webpack.d.cts +0 -37
  176. package/dist/webpack.d.ts +0 -37
  177. package/dist/webpack.mjs.map +0 -1
  178. package/dist/zod-v3.cjs +0 -53
  179. package/dist/zod-v3.cjs.map +0 -1
  180. package/dist/zod-v3.d.cts +0 -246
  181. package/dist/zod-v3.d.ts +0 -246
  182. package/dist/zod-v3.mjs.map +0 -1
  183. package/dist/zod-v4.cjs +0 -55
  184. package/dist/zod-v4.cjs.map +0 -1
  185. package/dist/zod-v4.d.cts +0 -172
  186. package/dist/zod-v4.d.ts +0 -172
  187. package/dist/zod-v4.mjs.map +0 -1
  188. package/dist/zod.cjs +0 -51
  189. package/dist/zod.cjs.map +0 -1
  190. package/dist/zod.d.cts +0 -7
  191. package/dist/zod.d.ts +0 -7
  192. package/dist/zod.mjs.map +0 -1
@@ -1,16 +1,30 @@
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, o as crossCopyState } from './attaform-dev.DHuydLAC.mjs';
2
+ import { e as canonicalizePath, h as SET_MEMBER_SEGMENT } from './attaform-dev.A-TpJW0B.mjs';
3
+ import { a as safeOwnRead, b as safeAssign } from './attaform-dev.ButTkwHd.mjs';
5
4
 
6
5
  const PATH_SEPARATOR = ".";
6
+ function isOpaqueKind(kind) {
7
+ return kind === "any" || kind === "unknown" || kind === "custom";
8
+ }
7
9
  function createAbstractSchema(rootSchema, intro, services, formKey, options) {
8
10
  const maxRecursionDepth = options.maxRecursionDepth;
9
11
  const leafCache = /* @__PURE__ */ new Map();
10
12
  const preprocessOrCoerceCache = /* @__PURE__ */ new Map();
13
+ const opaqueLeafCache = /* @__PURE__ */ new Map();
11
14
  const discriminatorCache = /* @__PURE__ */ new Map();
15
+ const entryKeyKindCache = /* @__PURE__ */ new Map();
12
16
  let asyncValidationFlag = null;
13
17
  let containerRefineFlag = null;
18
+ let discriminatedUnionFlag = null;
19
+ function mapKeySegmentKind(schema) {
20
+ const keyType = intro.getMapKeyType(schema);
21
+ if (keyType === void 0) return void 0;
22
+ const kinds = services.slimPrimitivesOf(keyType, maxRecursionDepth);
23
+ const string = kinds.has("string");
24
+ const number = kinds.has("number");
25
+ if (string === number) return void 0;
26
+ return string ? "string" : "number";
27
+ }
14
28
  function computeDiscriminator(path) {
15
29
  const candidates = path.length === 0 ? [rootSchema] : services.getNestedSchemasAtPath(rootSchema, path, maxRecursionDepth);
16
30
  let matchedUnion;
@@ -62,6 +76,10 @@ function createAbstractSchema(rootSchema, intro, services, formKey, options) {
62
76
  containerRefineFlag ?? (containerRefineFlag = intro.hasContainerOrRootRefine(rootSchema));
63
77
  return containerRefineFlag;
64
78
  },
79
+ hasDiscriminatedUnions() {
80
+ discriminatedUnionFlag ?? (discriminatedUnionFlag = intro.containsDiscriminatedUnion(rootSchema));
81
+ return discriminatedUnionFlag;
82
+ },
65
83
  getDefaultValues(config) {
66
84
  return services.runStrictGetDefaults(rootSchema, config, formKey, maxRecursionDepth);
67
85
  },
@@ -83,14 +101,12 @@ function createAbstractSchema(rootSchema, intro, services, formKey, options) {
83
101
  return services.deriveDefault(first, false, maxRecursionDepth, formKey);
84
102
  },
85
103
  arrayShapeAtPath(path) {
86
- if (path.length === 0) return void 0;
104
+ if (path.length === 0) return null;
87
105
  const [first] = services.getNestedSchemasAtPath(rootSchema, path, maxRecursionDepth);
88
- if (first === void 0) return void 0;
106
+ if (first === void 0) return null;
89
107
  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;
108
+ if (intro.kindOf(peeled) === "tuple") return intro.getTupleItems(peeled).length;
109
+ return null;
94
110
  },
95
111
  isFixedObjectAtPath(path) {
96
112
  if (path.length === 0) {
@@ -100,6 +116,32 @@ function createAbstractSchema(rootSchema, intro, services, formKey, options) {
100
116
  if (resolved.length === 0) return false;
101
117
  return resolved.every((s) => intro.kindOf(services.peelAllWrappers(s)) === "object");
102
118
  },
119
+ entryKeyKindAtPath(path) {
120
+ const cacheKey = canonicalizePath(path).key;
121
+ if (entryKeyKindCache.has(cacheKey)) return entryKeyKindCache.get(cacheKey);
122
+ const resolved = path.length === 0 ? [rootSchema] : services.getNestedSchemasAtPath(rootSchema, path, maxRecursionDepth);
123
+ let answer;
124
+ const only = resolved.length === 1 ? resolved[0] : void 0;
125
+ if (only !== void 0) {
126
+ switch (intro.kindOf(services.peelAllWrappers(only))) {
127
+ case "array":
128
+ case "tuple":
129
+ answer = "number";
130
+ break;
131
+ case "object":
132
+ case "record":
133
+ answer = "string";
134
+ break;
135
+ case "map":
136
+ answer = mapKeySegmentKind(services.peelAllWrappers(only));
137
+ break;
138
+ default:
139
+ answer = void 0;
140
+ }
141
+ }
142
+ entryKeyKindCache.set(cacheKey, answer);
143
+ return answer;
144
+ },
103
145
  getSchemasAtPath(path) {
104
146
  const resolved = services.getNestedSchemasInSlimMode(rootSchema, path, maxRecursionDepth);
105
147
  if (resolved.length === 0) return [];
@@ -118,16 +160,17 @@ function createAbstractSchema(rootSchema, intro, services, formKey, options) {
118
160
  return out;
119
161
  },
120
162
  isLeafAtPath(path) {
121
- const cacheKey = devtoolsShared.canonicalizePath(path).key;
163
+ const cacheKey = canonicalizePath(path).key;
122
164
  const cached = leafCache.get(cacheKey);
123
165
  if (cached !== void 0) return cached;
124
- const prim = this.getSlimPrimitiveTypesAtPath(path);
125
- const isLeaf = prim.size > 0 && !prim.has("object") && !prim.has("array") && !prim.has("map") && !prim.has("set");
166
+ const opaque = path.length > 0 && this.isOpaqueLeafAtPath(path);
167
+ const prim = opaque ? void 0 : this.getSlimPrimitiveTypesAtPath(path);
168
+ const isLeaf = opaque || prim !== void 0 && prim.size > 0 && !prim.has("object") && !prim.has("array") && !prim.has("map") && !prim.has("set");
126
169
  leafCache.set(cacheKey, isLeaf);
127
170
  return isLeaf;
128
171
  },
129
172
  isPreprocessOrCoerceLeaf(path) {
130
- const cacheKey = devtoolsShared.canonicalizePath(path).key;
173
+ const cacheKey = canonicalizePath(path).key;
131
174
  const cached = preprocessOrCoerceCache.get(cacheKey);
132
175
  if (cached !== void 0) return cached;
133
176
  let hit = false;
@@ -144,6 +187,17 @@ function createAbstractSchema(rootSchema, intro, services, formKey, options) {
144
187
  preprocessOrCoerceCache.set(cacheKey, hit);
145
188
  return hit;
146
189
  },
190
+ isOpaqueLeafAtPath(path) {
191
+ const cacheKey = canonicalizePath(path).key;
192
+ const cached = opaqueLeafCache.get(cacheKey);
193
+ if (cached !== void 0) return cached;
194
+ const resolved = path.length === 0 ? [rootSchema] : services.getNestedSchemasAtPath(rootSchema, path, maxRecursionDepth);
195
+ const opaque = resolved.length > 0 && resolved.every(
196
+ (candidate) => isOpaqueKind(intro.kindOf(services.peelAllWrappers(candidate)))
197
+ );
198
+ opaqueLeafCache.set(cacheKey, opaque);
199
+ return opaque;
200
+ },
147
201
  isRequiredAtPath(path) {
148
202
  if (path.length === 0) return true;
149
203
  const resolved = services.getNestedSchemasAtPath(rootSchema, path, maxRecursionDepth);
@@ -154,7 +208,7 @@ function createAbstractSchema(rootSchema, intro, services, formKey, options) {
154
208
  return services.resolveFieldMetaAtPath(rootSchema, path, maxRecursionDepth);
155
209
  },
156
210
  getUnionDiscriminatorAtPath(path) {
157
- const cacheKey = devtoolsShared.canonicalizePath(path).key;
211
+ const cacheKey = canonicalizePath(path).key;
158
212
  if (discriminatorCache.has(cacheKey)) {
159
213
  return discriminatorCache.get(cacheKey);
160
214
  }
@@ -174,7 +228,7 @@ function createAbstractSchema(rootSchema, intro, services, formKey, options) {
174
228
  function parseResultToResponse(result) {
175
229
  return result.success ? { data: result.data, errors: void 0, success: true, formKey } : {
176
230
  data: void 0,
177
- errors: services.issuesToValidationErrors(result.issues, formKey),
231
+ errors: services.issuesToValidationErrors(result.issues),
178
232
  success: false,
179
233
  formKey
180
234
  };
@@ -227,8 +281,7 @@ function createAbstractSchema(rootSchema, intro, services, formKey, options) {
227
281
  {
228
282
  message,
229
283
  path: [...errPath],
230
- formKey,
231
- code: serializeScript.AttaformErrorCode.ValidatorThrew
284
+ code: AttaformErrorCode.ValidatorThrew
232
285
  }
233
286
  ],
234
287
  success: false,
@@ -242,8 +295,7 @@ function createAbstractSchema(rootSchema, intro, services, formKey, options) {
242
295
  {
243
296
  message: `Path '${p.join(PATH_SEPARATOR)}' did not resolve to any schema`,
244
297
  path: [...p],
245
- formKey,
246
- code: serializeScript.AttaformErrorCode.PathNotFound
298
+ code: AttaformErrorCode.PathNotFound
247
299
  }
248
300
  ],
249
301
  success: false,
@@ -257,16 +309,16 @@ function createAbstractSchema(rootSchema, intro, services, formKey, options) {
257
309
 
258
310
  function mergeDeep(base, override) {
259
311
  if (override === void 0) return base;
260
- if (!serializeScript.isPlainRecord(override)) return override;
261
- if (!serializeScript.isPlainRecord(base)) return override;
312
+ if (!isPlainRecord(override)) return override;
313
+ if (!isPlainRecord(base)) return override;
262
314
  const result = { ...base };
263
315
  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));
316
+ const oVal = safeOwnRead(override, key);
317
+ const bVal = safeOwnRead(base, key);
318
+ if (isPlainRecord(oVal) && isPlainRecord(bVal)) {
319
+ safeAssign(result, key, mergeDeep(bVal, oVal));
268
320
  } else {
269
- serializeScript.safeAssign(result, key, oVal);
321
+ safeAssign(result, key, oVal);
270
322
  }
271
323
  }
272
324
  return result;
@@ -289,6 +341,7 @@ function walkPathSegments(schema, segments, intro, maxDepth, lazyDepth) {
289
341
  return inner === void 0 ? [] : walkPathSegments(inner, rest, intro, maxDepth, lazyDepth);
290
342
  }
291
343
  case "set": {
344
+ if (head !== SET_MEMBER_SEGMENT) return [];
292
345
  const inner = intro.getSetValueType(schema);
293
346
  return inner === void 0 ? [] : walkPathSegments(inner, rest, intro, maxDepth, lazyDepth);
294
347
  }
@@ -296,6 +349,10 @@ function walkPathSegments(schema, segments, intro, maxDepth, lazyDepth) {
296
349
  const inner = intro.getRecordValueType(schema);
297
350
  return inner === void 0 ? [] : walkPathSegments(inner, rest, intro, maxDepth, lazyDepth);
298
351
  }
352
+ case "map": {
353
+ const inner = intro.getMapValueType(schema);
354
+ return inner === void 0 ? [] : walkPathSegments(inner, rest, intro, maxDepth, lazyDepth);
355
+ }
299
356
  case "tuple": {
300
357
  const index = Number(head);
301
358
  if (!Number.isInteger(index)) return [];
@@ -349,16 +406,165 @@ function walkPathSegments(schema, segments, intro, maxDepth, lazyDepth) {
349
406
  const rightResults = right === void 0 ? [] : walkPathSegments(right, segments, intro, maxDepth, lazyDepth);
350
407
  return [...leftResults, ...rightResults];
351
408
  }
352
- // Leaves — can't descend further. The unsupported kinds (`map` /
353
- // `symbol` / `function` / `promise`) are rejected at adapter
354
- // construction by `assertSupportedKinds`; falling through to `[]`
355
- // keeps the walker defensive in case construction is skipped
356
- // (e.g. a downstream test instantiates a sub-schema directly).
409
+ // Leaves — can't descend further. Opaque leaves (`any` /
410
+ // `unknown` / `custom`) land here too and `[]` is the truthful
411
+ // answer: the schema declares no sub-paths under them, so none are
412
+ // fabricated. `symbol` / `function` / `promise` hold a value
413
+ // without declaring anything inside it and land here for the same
414
+ // reason. No kind is refused at construction (#607), so this is
415
+ // the only branch they ever take.
357
416
  default:
358
417
  return [];
359
418
  }
360
419
  }
361
420
 
421
+ function fixStructuralDefaults(schema, merged, useDefault, maxRecursionDepth, services) {
422
+ const ctx = {
423
+ useDefault,
424
+ maxDepth: maxRecursionDepth,
425
+ clean: true,
426
+ services
427
+ };
428
+ const data = fixNode(schema, merged, ctx, 0);
429
+ return { data, success: ctx.clean };
430
+ }
431
+ function fixNode(schema, value, ctx, lazyDepth) {
432
+ const { intro } = ctx.services;
433
+ if (intro.isCoercePrimitive(schema) || intro.isPreprocessNode(schema)) return value;
434
+ const kinds = ctx.services.slimPrimitivesOf(schema);
435
+ if (kinds.size > 0 && !kinds.has(slimKindOf(value))) {
436
+ const replacement = deriveFixValue(schema, value, ctx);
437
+ if (kinds.has(slimKindOf(replacement))) return replacement;
438
+ ctx.clean = false;
439
+ return replacement;
440
+ }
441
+ switch (intro.kindOf(schema)) {
442
+ case "optional":
443
+ case "nullable": {
444
+ if (value === void 0 || value === null) return value;
445
+ const inner = intro.unwrapInner(schema);
446
+ return inner === void 0 ? value : fixNode(inner, value, ctx, lazyDepth);
447
+ }
448
+ case "default":
449
+ case "readonly":
450
+ case "catch": {
451
+ const inner = intro.unwrapInner(schema);
452
+ return inner === void 0 ? value : fixNode(inner, value, ctx, lazyDepth);
453
+ }
454
+ case "branded": {
455
+ const inner = intro.unwrapBranded(schema);
456
+ return inner === void 0 ? value : fixNode(inner, value, ctx, lazyDepth);
457
+ }
458
+ case "effects": {
459
+ const inner = intro.unwrapEffectsSource(schema);
460
+ return inner === void 0 ? value : fixNode(inner, value, ctx, lazyDepth);
461
+ }
462
+ case "pipe":
463
+ case "pipeline": {
464
+ const pipeIn = intro.unwrapPipeIn(schema);
465
+ if (pipeIn === void 0 || intro.kindOf(pipeIn) === "transform") return value;
466
+ return fixNode(pipeIn, value, ctx, lazyDepth);
467
+ }
468
+ case "lazy": {
469
+ if (lazyDepth >= ctx.maxDepth) return value;
470
+ const inner = intro.unwrapLazy(schema);
471
+ return inner === void 0 ? value : fixNode(inner, value, ctx, lazyDepth + 1);
472
+ }
473
+ case "discriminated-union": {
474
+ if (value === null || typeof value !== "object") return value;
475
+ const variant = selectVariantByValue(schema, value, intro);
476
+ if (variant === void 0) return value;
477
+ const record = value;
478
+ const shape = intro.getObjectShape(variant);
479
+ for (const key of Object.keys(record)) {
480
+ if (!(key in shape)) delete record[key];
481
+ }
482
+ for (const [key, sub] of Object.entries(shape)) {
483
+ record[key] = fixNode(sub, record[key], ctx, lazyDepth);
484
+ }
485
+ return value;
486
+ }
487
+ case "object": {
488
+ if (value === null || typeof value !== "object") return value;
489
+ const record = value;
490
+ for (const [key, sub] of Object.entries(intro.getObjectShape(schema))) {
491
+ record[key] = fixNode(sub, record[key], ctx, lazyDepth);
492
+ }
493
+ return value;
494
+ }
495
+ case "array": {
496
+ if (!Array.isArray(value)) return value;
497
+ const element = intro.getArrayElement(schema);
498
+ if (element === void 0) return value;
499
+ for (let i = 0; i < value.length; i++) {
500
+ value[i] = fixNode(element, value[i], ctx, lazyDepth);
501
+ }
502
+ return value;
503
+ }
504
+ case "tuple": {
505
+ if (!Array.isArray(value)) return value;
506
+ const items = intro.getTupleItems(schema);
507
+ for (let i = 0; i < items.length; i++) {
508
+ const item = items[i];
509
+ if (item !== void 0) value[i] = fixNode(item, value[i], ctx, lazyDepth);
510
+ }
511
+ return value;
512
+ }
513
+ case "record": {
514
+ if (value === null || typeof value !== "object") return value;
515
+ const valueType = intro.getRecordValueType(schema);
516
+ if (valueType === void 0) return value;
517
+ const record = value;
518
+ for (const key of Object.keys(record)) {
519
+ record[key] = fixNode(valueType, record[key], ctx, lazyDepth);
520
+ }
521
+ return value;
522
+ }
523
+ case "map": {
524
+ if (!(value instanceof Map)) return value;
525
+ const valueType = intro.getMapValueType(schema);
526
+ if (valueType === void 0) return value;
527
+ for (const [key, entry] of [...value]) {
528
+ value.set(key, fixNode(valueType, entry, ctx, lazyDepth));
529
+ }
530
+ return value;
531
+ }
532
+ case "intersection": {
533
+ const left = intro.getIntersectionLeft(schema);
534
+ const right = intro.getIntersectionRight(schema);
535
+ let out = value;
536
+ if (left !== void 0) out = fixNode(left, out, ctx, lazyDepth);
537
+ if (right !== void 0) out = fixNode(right, out, ctx, lazyDepth);
538
+ return out;
539
+ }
540
+ default:
541
+ return value;
542
+ }
543
+ }
544
+ function deriveFixValue(schema, value, ctx) {
545
+ const du = ctx.services.unwrapToDiscriminatedUnion(schema);
546
+ if (du !== void 0) {
547
+ const selected = selectVariantByValue(du, value, ctx.services.intro) ?? ctx.services.intro.getDiscriminatedOptions(du)[0];
548
+ if (selected !== void 0) {
549
+ return ctx.services.deriveDefault(selected, ctx.useDefault);
550
+ }
551
+ }
552
+ return ctx.services.deriveDefault(schema, ctx.useDefault);
553
+ }
554
+ function selectVariantByValue(du, value, intro) {
555
+ if (value === null || typeof value !== "object") return void 0;
556
+ const discKey = intro.getDiscriminator(du);
557
+ if (discKey === void 0) return void 0;
558
+ const discValue = value[discKey];
559
+ if (discValue === void 0) return void 0;
560
+ for (const opt of intro.getDiscriminatedOptions(du)) {
561
+ const litSchema = intro.getObjectShape(opt)[discKey];
562
+ if (litSchema === void 0 || intro.kindOf(litSchema) !== "literal") continue;
563
+ if (intro.getLiteralValues(litSchema).includes(discValue)) return opt;
564
+ }
565
+ return void 0;
566
+ }
567
+
362
568
  const NO_EMBEDDED_DEFAULT = /* @__PURE__ */ Symbol("atta:no-embedded-default");
363
569
  function peelEmbeddedDefault(schema, intro) {
364
570
  let current = schema;
@@ -417,7 +623,7 @@ function deriveDefaultWalk(schema, useDefault, intro, maxDepth, ctx, lazyDepth =
417
623
  const shape = intro.getObjectShape(schema);
418
624
  const out = {};
419
625
  for (const [key, subSchema] of Object.entries(shape)) {
420
- serializeScript.safeAssign(
626
+ safeAssign(
421
627
  out,
422
628
  key,
423
629
  deriveDefaultWalk(subSchema, useDefault, intro, maxDepth, ctx, lazyDepth)
@@ -541,59 +747,68 @@ function deriveDefaultWalk(schema, useDefault, intro, maxDepth, ctx, lazyDepth =
541
747
  }
542
748
  case "catch": {
543
749
  if (useDefault) return intro.getCatchDefault(schema);
544
- if (ctx.catchOnUseDefaultFalse === "preserveCatch" && intro.hasCatchValue(schema)) {
545
- return intro.getCatchDefault(schema);
546
- }
547
750
  const inner = intro.unwrapInner(schema);
548
751
  return inner === void 0 ? void 0 : deriveDefaultWalk(inner, useDefault, intro, maxDepth, ctx, lazyDepth);
549
752
  }
550
753
  case "file":
551
754
  return null;
755
+ case "map":
756
+ return /* @__PURE__ */ new Map();
757
+ case "template-literal":
758
+ return "";
552
759
  case "any":
553
760
  case "unknown":
761
+ case "custom":
554
762
  case "void":
555
763
  case "never":
556
764
  case "promise":
557
- case "custom":
558
- case "template-literal":
559
- case "transform":
560
- case "map":
561
765
  case "symbol":
562
766
  case "function":
767
+ case "transform":
563
768
  return void 0;
564
769
  default:
565
770
  return ctx.unsupportedKindFallback(schema, kind);
566
771
  }
567
772
  }
568
773
 
569
- const store = /* @__PURE__ */ new WeakMap();
570
- const lists = /* @__PURE__ */ new WeakMap();
774
+ const state = crossCopyState(/* @__PURE__ */ Symbol.for("attaform:field-meta-state"), () => ({
775
+ store: /* @__PURE__ */ new WeakMap(),
776
+ lists: /* @__PURE__ */ new WeakMap(),
777
+ pathMapBuilder: null
778
+ }));
571
779
  const registry = {
572
780
  add(schema, payload) {
573
- store.set(schema, payload);
574
- const list = lists.get(schema) ?? [];
781
+ state.store.set(schema, payload);
782
+ const list = state.lists.get(schema) ?? [];
575
783
  list.push(payload);
576
- lists.set(schema, list);
784
+ state.lists.set(schema, list);
577
785
  return registry;
578
786
  },
579
787
  get(schema) {
580
- return store.get(schema);
788
+ return state.store.get(schema);
581
789
  },
582
790
  has(schema) {
583
- return store.has(schema);
791
+ return state.store.has(schema);
584
792
  },
585
793
  remove(schema) {
586
- store.delete(schema);
587
- lists.delete(schema);
794
+ state.store.delete(schema);
795
+ state.lists.delete(schema);
588
796
  return registry;
589
797
  }
590
798
  };
591
799
  const fieldMetaStore = registry;
592
800
  function getFieldMetaForSchema(schema) {
593
- return store.get(schema);
801
+ return state.store.get(schema);
594
802
  }
595
803
  function getFieldMetaListForSchema(schema) {
596
- return lists.get(schema) ?? [];
804
+ return state.lists.get(schema) ?? [];
805
+ }
806
+ function installFieldMetaPathMapBuilder(builder) {
807
+ state.pathMapBuilder = builder;
808
+ }
809
+ function buildFieldMetaPathMap(rootSchema, services) {
810
+ const builder = state.pathMapBuilder;
811
+ return builder === null ? void 0 : builder(rootSchema, services);
597
812
  }
598
813
 
599
814
  const PERMISSIVE_SLIM_KINDS = /* @__PURE__ */ new Set([
@@ -622,6 +837,16 @@ const KIND_UNDEFINED = /* @__PURE__ */ new Set(["undefined"]);
622
837
  const KIND_OBJECT = /* @__PURE__ */ new Set(["object"]);
623
838
  const KIND_ARRAY = /* @__PURE__ */ new Set(["array"]);
624
839
  const KIND_SET = /* @__PURE__ */ new Set(["set"]);
840
+ const KIND_MAP = /* @__PURE__ */ new Set(["map"]);
841
+ const KIND_SYMBOL = /* @__PURE__ */ new Set(["symbol", "undefined"]);
842
+ const KIND_FUNCTION = /* @__PURE__ */ new Set([
843
+ "function",
844
+ "undefined"
845
+ ]);
846
+ const KIND_PROMISE = /* @__PURE__ */ new Set([
847
+ "object",
848
+ "undefined"
849
+ ]);
625
850
  const KIND_FILE = /* @__PURE__ */ new Set(["file", "null"]);
626
851
  const EMPTY_KINDS = /* @__PURE__ */ new Set();
627
852
  function slimPrimitivesWalk(schema, intro, maxDepth, lazyDepth = 0) {
@@ -667,7 +892,7 @@ function slimPrimitivesWalk(schema, intro, maxDepth, lazyDepth = 0) {
667
892
  case "literal": {
668
893
  const values = intro.getLiteralValues(schema);
669
894
  const out = /* @__PURE__ */ new Set();
670
- for (const v of values) out.add(serializeScript.slimKindOf(v));
895
+ for (const v of values) out.add(slimKindOf(v));
671
896
  return out.size === 0 ? PERMISSIVE_SLIM_KINDS : out;
672
897
  }
673
898
  case "object":
@@ -678,6 +903,16 @@ function slimPrimitivesWalk(schema, intro, maxDepth, lazyDepth = 0) {
678
903
  return KIND_ARRAY;
679
904
  case "set":
680
905
  return KIND_SET;
906
+ case "map":
907
+ return KIND_MAP;
908
+ case "symbol":
909
+ return KIND_SYMBOL;
910
+ case "function":
911
+ return KIND_FUNCTION;
912
+ case "promise":
913
+ return KIND_PROMISE;
914
+ case "template-literal":
915
+ return KIND_STRING;
681
916
  case "optional": {
682
917
  const inner = intro.unwrapInner(schema);
683
918
  const innerSet = inner === void 0 ? EMPTY_KINDS : slimPrimitivesWalk(inner, intro, maxDepth, lazyDepth);
@@ -741,19 +976,37 @@ function slimPrimitivesWalk(schema, intro, maxDepth, lazyDepth = 0) {
741
976
  }
742
977
  case "never":
743
978
  return EMPTY_KINDS;
979
+ // Opaque leaves: the schema says nothing about the value's shape,
980
+ // so every kind is admissible. `custom` is the kind
981
+ // `z.instanceof(X)` and `z.custom<T>()` compile to on v4 (#542);
982
+ // it belongs with `any` / `unknown` rather than in the defensive
983
+ // fallthrough, because it reaches here through the public surface.
744
984
  case "any":
745
985
  case "unknown":
986
+ case "custom":
746
987
  return PERMISSIVE_SLIM_KINDS;
747
- // Opaque / unsupported kinds: be permissive so legitimate writes
748
- // aren't false-rejected. The unsupported kinds (`map` / `symbol` /
749
- // `function` / `promise`) are rejected at adapter construction by
750
- // `assertSupportedKinds`; this fallthrough keeps the walker
751
- // defensive in case construction is skipped.
988
+ // A kind this walker has no case for — in practice a kind a newer
989
+ // Zod introduced. Be permissive rather than reject: the adapter
990
+ // carries the value opaquely and the schema's own parse is what
991
+ // decides whether it was legal.
752
992
  default:
753
993
  return PERMISSIVE_SLIM_KINDS;
754
994
  }
755
995
  }
756
996
 
997
+ const installingFieldMetaStore = {
998
+ add(schema, payload) {
999
+ installFieldMetaPathMapBuilder(getFieldMetaPathMap);
1000
+ fieldMetaStore.add(schema, payload);
1001
+ return installingFieldMetaStore;
1002
+ },
1003
+ get: (schema) => fieldMetaStore.get(schema),
1004
+ has: (schema) => fieldMetaStore.has(schema),
1005
+ remove: (schema) => {
1006
+ fieldMetaStore.remove(schema);
1007
+ return installingFieldMetaStore;
1008
+ }
1009
+ };
757
1010
  const pathMetaCache = /* @__PURE__ */ new WeakMap();
758
1011
  function getFieldMetaPathMap(rootSchema, services) {
759
1012
  const cached = pathMetaCache.get(rootSchema);
@@ -787,7 +1040,7 @@ function walkForMeta(schema, path, map, counters, lastPathPerSchema, inProgress,
787
1040
  inProgress.add(schema);
788
1041
  try {
789
1042
  const { intro, peelAllWrappers, getFieldMetaList } = services;
790
- const pathKey = devtoolsShared.canonicalizePath(path).key;
1043
+ const pathKey = canonicalizePath(path).key;
791
1044
  if (!map.has(pathKey)) {
792
1045
  const payload = consumePayload(schema, counters, getFieldMetaList);
793
1046
  if (payload !== void 0) {
@@ -829,11 +1082,20 @@ function walkForMeta(schema, path, map, counters, lastPathPerSchema, inProgress,
829
1082
  case "set": {
830
1083
  const inner = intro.getSetValueType(schema);
831
1084
  if (inner !== void 0)
832
- walkForMeta(inner, [...path, 0], map, counters, lastPathPerSchema, inProgress, services);
1085
+ walkForMeta(
1086
+ inner,
1087
+ [...path, SET_MEMBER_SEGMENT],
1088
+ map,
1089
+ counters,
1090
+ lastPathPerSchema,
1091
+ inProgress,
1092
+ services
1093
+ );
833
1094
  return;
834
1095
  }
835
- case "record": {
836
- const inner = intro.getRecordValueType(schema);
1096
+ case "record":
1097
+ case "map": {
1098
+ const inner = kind === "map" ? intro.getMapValueType(schema) : intro.getRecordValueType(schema);
837
1099
  if (inner !== void 0)
838
1100
  walkForMeta(inner, [...path, "*"], map, counters, lastPathPerSchema, inProgress, services);
839
1101
  return;
@@ -905,15 +1167,4 @@ function walkForMeta(schema, path, map, counters, lastPathPerSchema, inProgress,
905
1167
  }
906
1168
  }
907
1169
 
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
1170
+ 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 };