attaform 0.30.1 → 0.31.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/dist/abstract.d.mts +5 -5
  2. package/dist/abstract.mjs +4 -4
  3. package/dist/dev/abstract.mjs +4 -4
  4. package/dist/dev/chunks/devtools.mjs +3 -3
  5. package/dist/dev/directive.mjs +1 -1
  6. package/dist/dev/history.mjs +15 -2
  7. package/dist/dev/index.mjs +5 -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.DxHdkkPG.mjs → attaform-dev.3uTCYwy8.mjs} +770 -254
  11. package/dist/dev/shared/{attaform-dev.BJK1kqHY.mjs → attaform-dev.BpVGFSFa.mjs} +88 -115
  12. package/dist/dev/shared/{attaform-dev.Chm4D6SJ.mjs → attaform-dev.Bu6wgrA5.mjs} +3 -3
  13. package/dist/dev/shared/{attaform-dev.BMQ3GcgD.mjs → attaform-dev.Cbx0AiQF.mjs} +476 -337
  14. package/dist/dev/shared/attaform-dev.CwYTWyPX.mjs +120 -0
  15. package/dist/dev/shared/{attaform-dev.DuEE4GU1.mjs → attaform-dev.D7lKyM_7.mjs} +4 -4
  16. package/dist/dev/shared/{attaform-dev.CT7MDjPy.mjs → attaform-dev.OceE0X3v.mjs} +154 -229
  17. package/dist/{shared/attaform.DRsANMok.mjs → dev/shared/attaform-dev.PTGM9KE1.mjs} +16 -15
  18. package/dist/{shared/attaform.8mfKZCwH.mjs → dev/shared/attaform-dev.n6n00owJ.mjs} +49 -128
  19. package/dist/dev/zod-v3.mjs +6 -6
  20. package/dist/dev/zod-v4.mjs +6 -6
  21. package/dist/dev/zod.mjs +5 -5
  22. package/dist/directive.d.mts +2 -2
  23. package/dist/directive.mjs +1 -1
  24. package/dist/history.d.mts +1 -1
  25. package/dist/history.mjs +15 -2
  26. package/dist/index.d.mts +16 -55
  27. package/dist/index.mjs +5 -5
  28. package/dist/runtime/components/AttaformDevtoolsPanel.vue +3 -3
  29. package/dist/runtime/plugins/attaform.mjs +1 -1
  30. package/dist/shared/{attaform.CO918TdU.mjs → attaform.B5b-HmhH.mjs} +88 -115
  31. package/dist/shared/{attaform.2FslhB9R.d.mts → attaform.B9PYKlhB.d.mts} +43 -19
  32. package/dist/shared/{attaform.D_f1WgYf.mjs → attaform.BPMOl562.mjs} +458 -319
  33. package/dist/{dev/shared/attaform-dev.CZz4GYZ6.mjs → shared/attaform.BPSqtU7a.mjs} +44 -156
  34. package/dist/shared/{attaform.CdZIEf7_.mjs → attaform.BhtAZysa.mjs} +3 -2
  35. package/dist/shared/{attaform.BcQwgWaq.d.mts → attaform.CYlF4P6X.d.mts} +58 -17
  36. package/dist/shared/{attaform.WiGdIqgx.mjs → attaform.CdA9bfRv.mjs} +3 -3
  37. package/dist/shared/{attaform.BIWicztt.mjs → attaform.DAf4ehIe.mjs} +765 -251
  38. package/dist/shared/{attaform.ZYn2ahzJ.mjs → attaform.DBCbxlyk.mjs} +59 -1
  39. package/dist/shared/{attaform.L0kUn3vL.d.mts → attaform.DZOynI6c.d.mts} +1 -1
  40. package/dist/shared/{attaform.B2iebkPA.mjs → attaform.KEfNRDot.mjs} +4 -4
  41. package/dist/shared/attaform._1Zp3mDG.mjs +96 -0
  42. package/dist/shared/{attaform.Br8EBn5B.d.mts → attaform.i13OEHJF.d.mts} +195 -38
  43. package/dist/{dev/shared/attaform-dev.BUIFcTYf.mjs → shared/attaform.j9xI_ObC.mjs} +16 -15
  44. package/dist/shared/{attaform.D_pt1gOj.mjs → attaform.u6jfHoed.mjs} +154 -229
  45. package/dist/transforms.mjs +1 -1
  46. package/dist/vite.mjs +1 -1
  47. package/dist/zod-v3.d.mts +4 -4
  48. package/dist/zod-v3.mjs +6 -6
  49. package/dist/zod-v4.d.mts +22 -16
  50. package/dist/zod-v4.mjs +6 -6
  51. package/dist/zod.d.mts +4 -4
  52. package/dist/zod.mjs +5 -5
  53. package/package.json +2 -1
  54. package/skills/attaform/SKILL.md +2 -1
  55. package/skills/attaform/references/custom-components.md +4 -0
@@ -1,6 +1,6 @@
1
- import { A as AttaformErrorCode, k as isPlainRecord, s as slimKindOf } from './attaform-dev.DxHdkkPG.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, k as isPlainRecord, s as slimKindOf } from './attaform.DAf4ehIe.mjs';
2
+ import { e as canonicalizePath, h as SET_MEMBER_SEGMENT } from './attaform.BhtAZysa.mjs';
3
+ import { a as safeOwnRead, s as safeAssign, e as safeOwnHas } from './attaform._1Zp3mDG.mjs';
4
4
 
5
5
  const PATH_SEPARATOR = ".";
6
6
  function isOpaqueKind(kind) {
@@ -37,9 +37,6 @@ function createAbstractSchema(rootSchema, intro, services, options) {
37
37
  const discriminatorCache = /* @__PURE__ */ new Map();
38
38
  const entryKeyKindCache = /* @__PURE__ */ new Map();
39
39
  const slimKindsCache = /* @__PURE__ */ new Map();
40
- let asyncValidationFlag = null;
41
- let containerRefineFlag = null;
42
- let discriminatedUnionFlag = null;
43
40
  function mapKeySegmentKind(schema) {
44
41
  const keyType = intro.getMapKeyType(schema);
45
42
  if (keyType === void 0) return void 0;
@@ -92,20 +89,24 @@ function createAbstractSchema(rootSchema, intro, services, options) {
92
89
  }
93
90
  const abstractSchema = {
94
91
  needsAsyncValidation() {
95
- asyncValidationFlag ?? (asyncValidationFlag = intro.containsAsyncRefine(rootSchema) || intro.containsAsyncTransform(rootSchema));
96
- return asyncValidationFlag;
92
+ const { asyncRefine, asyncTransform } = intro.capabilitiesOf(rootSchema);
93
+ return asyncRefine || asyncTransform;
97
94
  },
98
95
  hasContainerOrRootRefine() {
99
- containerRefineFlag ?? (containerRefineFlag = intro.hasContainerOrRootRefine(rootSchema));
100
- return containerRefineFlag;
96
+ return intro.capabilitiesOf(rootSchema).containerOrRootRefine;
101
97
  },
102
98
  hasDiscriminatedUnions() {
103
- discriminatedUnionFlag ?? (discriminatedUnionFlag = intro.containsDiscriminatedUnion(rootSchema));
104
- return discriminatedUnionFlag;
99
+ return intro.capabilitiesOf(rootSchema).discriminatedUnion;
100
+ },
101
+ hasPreprocessOrCoerce() {
102
+ return intro.capabilitiesOf(rootSchema).preprocessOrCoerce;
105
103
  },
106
104
  getDefaultValues(config) {
107
105
  return services.runGetDefaults(rootSchema, config, maxRecursionDepth);
108
106
  },
107
+ validateSync(data) {
108
+ return services.validateSync(rootSchema, data);
109
+ },
109
110
  getDefaultAtPath(path) {
110
111
  if (path.length === 0) {
111
112
  return services.deriveDefault(rootSchema, true, maxRecursionDepth);
@@ -349,7 +350,7 @@ function walkPathSegments(schema, segments, intro, maxDepth, lazyDepth) {
349
350
  switch (kind) {
350
351
  case "object": {
351
352
  const shape = intro.getObjectShape(schema);
352
- if (!Object.hasOwn(shape, head)) return [];
353
+ if (!safeOwnHas(shape, head)) return [];
353
354
  const next = shape[head];
354
355
  return next === void 0 ? [] : walkPathSegments(next, rest, intro, maxDepth, lazyDepth);
355
356
  }
@@ -381,7 +382,7 @@ function walkPathSegments(schema, segments, intro, maxDepth, lazyDepth) {
381
382
  return intro.getUnionOptions(schema).flatMap((opt) => walkPathSegments(opt, segments, intro, maxDepth, lazyDepth));
382
383
  case "discriminated-union": {
383
384
  const options = intro.getDiscriminatedOptions(schema);
384
- const matching = options.filter((opt) => Object.hasOwn(intro.getObjectShape(opt), head));
385
+ const matching = options.filter((opt) => safeOwnHas(intro.getObjectShape(opt), head));
385
386
  const candidates = matching.length > 0 ? matching : options;
386
387
  return candidates.flatMap(
387
388
  (opt) => walkPathSegments(opt, segments, intro, maxDepth, lazyDepth)
@@ -716,7 +717,7 @@ function deriveDefaultWalk(schema, useDefault, intro, maxDepth, lazyDepth = 0) {
716
717
  case "number":
717
718
  return 0;
718
719
  case "bigint":
719
- return 0n;
720
+ return typeof BigInt === "function" ? BigInt(0) : void 0;
720
721
  case "boolean":
721
722
  return false;
722
723
  case "date":
@@ -1,7 +1,7 @@
1
- import { w as walkPathSegments, s as slimPrimitivesWalk, c as createAbstractSchema, a as createSharedSchemaStore, b as buildFieldMetaPathMap, g as getFieldMetaForSchema, f as fixStructuralDefaults, m as mergeDeep, d as deriveDefaultWalk, e as getFieldMetaListForSchema } from './attaform.DRsANMok.mjs';
2
- import { h as getAtPath, j as humanize, c as useAbstractForm } from './attaform.BIWicztt.mjs';
3
- import { c as callConsumerFn } from './attaform.8mfKZCwH.mjs';
4
- import { A as AttaformError, e as canonicalizePath, a as InvalidUseFormConfigError } from './attaform.CdZIEf7_.mjs';
1
+ import { w as walkPathSegments, s as slimPrimitivesWalk, c as createAbstractSchema, a as createSharedSchemaStore, b as buildFieldMetaPathMap, g as getFieldMetaForSchema, f as fixStructuralDefaults, m as mergeDeep, d as deriveDefaultWalk, e as getFieldMetaListForSchema } from './attaform.j9xI_ObC.mjs';
2
+ import { h as getAtPath, j as humanize, c as useAbstractForm } from './attaform.DAf4ehIe.mjs';
3
+ import { d as callConsumerFn } from './attaform._1Zp3mDG.mjs';
4
+ import { A as AttaformError, e as canonicalizePath, a as InvalidUseFormConfigError } from './attaform.BhtAZysa.mjs';
5
5
 
6
6
  function isZodSchemaType(schema, expectedType) {
7
7
  if (typeof schema !== "object" || schema === null) return false;
@@ -196,104 +196,6 @@ function isAsyncEffect(schema) {
196
196
  if (typeof fn !== "function") return false;
197
197
  return fn.constructor.name === "AsyncFunction";
198
198
  }
199
- function containsAsyncRefine(schema, seen) {
200
- return walkForTarget(schema, "refinement", seen ?? /* @__PURE__ */ new WeakSet());
201
- }
202
- function containsMapOrSet(schema, seen) {
203
- return walkForTarget(schema, "map-or-set", /* @__PURE__ */ new WeakSet());
204
- }
205
- function containsDiscriminatedUnion(schema, seen) {
206
- return walkForTarget(schema, "discriminated-union", seen ?? /* @__PURE__ */ new WeakSet());
207
- }
208
- function containsAsyncTransform(schema, seen) {
209
- return walkForTarget(schema, "transform-or-preprocess", seen ?? /* @__PURE__ */ new WeakSet());
210
- }
211
- function walkForTarget(schema, target, visited) {
212
- const candidate = schema;
213
- if (typeof candidate !== "object" || candidate === null) return false;
214
- if (visited.has(candidate)) return false;
215
- visited.add(candidate);
216
- if (isZodSchemaType(schema, "ZodEffects")) {
217
- const kind = getEffectsKind(schema);
218
- if (target === "refinement" && kind === "refinement") return true;
219
- if (target === "transform-or-preprocess" && (kind === "transform" || kind === "preprocess") && isAsyncEffect(schema)) {
220
- return true;
221
- }
222
- const inner = unwrapEffectsSource(schema);
223
- return inner !== void 0 && walkForTarget(inner, target, visited);
224
- }
225
- if (isZodSchemaType(schema, "ZodOptional") || isZodSchemaType(schema, "ZodNullable") || isZodSchemaType(schema, "ZodDefault") || isZodSchemaType(schema, "ZodCatch") || isZodSchemaType(schema, "ZodReadonly")) {
226
- const inner = unwrapInner(schema);
227
- return inner !== void 0 && walkForTarget(inner, target, visited);
228
- }
229
- if (isZodSchemaType(schema, "ZodBranded")) {
230
- const inner = unwrapBranded(schema);
231
- return inner !== void 0 && walkForTarget(inner, target, visited);
232
- }
233
- if (isZodSchemaType(schema, "ZodLazy")) {
234
- const inner = unwrapLazy(schema);
235
- return inner !== void 0 && walkForTarget(inner, target, visited);
236
- }
237
- if (isZodSchemaType(schema, "ZodPipeline")) {
238
- const inSide = unwrapPipeIn(schema);
239
- if (inSide !== void 0 && walkForTarget(inSide, target, visited)) return true;
240
- const outSide = unwrapPipeOut(schema);
241
- if (outSide !== void 0 && walkForTarget(outSide, target, visited)) return true;
242
- return false;
243
- }
244
- if (isZodSchemaType(schema, "ZodObject")) {
245
- for (const sub of Object.values(getObjectShape(schema))) {
246
- if (walkForTarget(sub, target, visited)) return true;
247
- }
248
- return false;
249
- }
250
- if (isZodSchemaType(schema, "ZodArray")) {
251
- const elem = getArrayElement(schema);
252
- return elem !== void 0 && walkForTarget(elem, target, visited);
253
- }
254
- if (isZodSchemaType(schema, "ZodTuple")) {
255
- for (const it of getTupleItems(schema)) {
256
- if (walkForTarget(it, target, visited)) return true;
257
- }
258
- return false;
259
- }
260
- if (isZodSchemaType(schema, "ZodUnion") || isZodSchemaType(schema, "ZodDiscriminatedUnion")) {
261
- if (target === "discriminated-union" && isZodSchemaType(schema, "ZodDiscriminatedUnion")) {
262
- return true;
263
- }
264
- for (const opt of getUnionOptions(schema)) {
265
- if (walkForTarget(opt, target, visited)) return true;
266
- }
267
- return false;
268
- }
269
- if (isZodSchemaType(schema, "ZodIntersection")) {
270
- const left = getIntersectionLeft(schema);
271
- if (left !== void 0 && walkForTarget(left, target, visited)) return true;
272
- const right = getIntersectionRight(schema);
273
- if (right !== void 0 && walkForTarget(right, target, visited)) return true;
274
- return false;
275
- }
276
- if (isZodSchemaType(schema, "ZodRecord")) {
277
- const keyType = getRecordKeyType(schema);
278
- if (keyType !== void 0 && walkForTarget(keyType, target, visited)) return true;
279
- const valueType = getRecordValueType(schema);
280
- if (valueType !== void 0 && walkForTarget(valueType, target, visited)) return true;
281
- return false;
282
- }
283
- if (isZodSchemaType(schema, "ZodSet")) {
284
- if (target === "map-or-set") return true;
285
- const elem = getSetValueType(schema);
286
- return elem !== void 0 && walkForTarget(elem, target, visited);
287
- }
288
- if (isZodSchemaType(schema, "ZodMap")) {
289
- if (target === "map-or-set") return true;
290
- const keyType = getMapKeyType(schema);
291
- if (keyType !== void 0 && walkForTarget(keyType, target, visited)) return true;
292
- const valueType = getMapValueType(schema);
293
- return valueType !== void 0 && walkForTarget(valueType, target, visited);
294
- }
295
- return false;
296
- }
297
199
  function unwrapPipeIn(schema) {
298
200
  const def = readDef(schema);
299
201
  return def?.in;
@@ -335,99 +237,136 @@ function hasCatchValue(schema) {
335
237
  const def = readDef(schema);
336
238
  return typeof def?.catchValue === "function";
337
239
  }
338
- function hasContainerOrRootRefine(schema, seen) {
339
- const visited = seen ?? /* @__PURE__ */ new WeakSet();
240
+ const capabilityMemo = /* @__PURE__ */ new WeakMap();
241
+ function capabilitiesOf(schema) {
242
+ let capabilities = capabilityMemo.get(schema);
243
+ if (capabilities === void 0) {
244
+ capabilities = scanCapabilities(schema);
245
+ const key = schema;
246
+ if (typeof key === "object" && key !== null) capabilityMemo.set(key, capabilities);
247
+ }
248
+ return capabilities;
249
+ }
250
+ function scanCapabilities(schema) {
251
+ const capabilities = {
252
+ asyncRefine: false,
253
+ asyncTransform: false,
254
+ discriminatedUnion: false,
255
+ containerOrRootRefine: false,
256
+ preprocessOrCoerce: false,
257
+ mapOrSet: false
258
+ };
259
+ walkCapabilities(schema, capabilities, /* @__PURE__ */ new WeakSet());
260
+ return capabilities;
261
+ }
262
+ function walkCapabilities(schema, capabilities, visited) {
263
+ if (schema === void 0) return;
340
264
  const candidate = schema;
341
- if (typeof candidate !== "object" || candidate === null) return false;
342
- if (visited.has(candidate)) return false;
265
+ if (typeof candidate !== "object" || candidate === null || visited.has(candidate)) return;
343
266
  visited.add(candidate);
344
- if (isZodSchemaType(schema, "ZodEffects")) {
345
- const inner = unwrapEffectsSource(schema);
346
- if (inner === void 0) return false;
347
- if (isContainerAfterWrapperPeel(inner)) return true;
348
- return hasContainerOrRootRefine(inner, visited);
349
- }
350
- if (isZodSchemaType(schema, "ZodOptional") || isZodSchemaType(schema, "ZodNullable") || isZodSchemaType(schema, "ZodDefault") || isZodSchemaType(schema, "ZodCatch") || isZodSchemaType(schema, "ZodReadonly")) {
351
- const inner = unwrapInner(schema);
352
- return inner !== void 0 && hasContainerOrRootRefine(inner, visited);
353
- }
354
- if (isZodSchemaType(schema, "ZodBranded")) {
355
- const inner = unwrapBranded(schema);
356
- return inner !== void 0 && hasContainerOrRootRefine(inner, visited);
357
- }
358
- if (isZodSchemaType(schema, "ZodLazy")) {
359
- const inner = unwrapLazy(schema);
360
- return inner !== void 0 && hasContainerOrRootRefine(inner, visited);
361
- }
362
- if (isZodSchemaType(schema, "ZodPipeline")) {
363
- const inSide = unwrapPipeIn(schema);
364
- if (inSide !== void 0 && hasContainerOrRootRefine(inSide, visited)) return true;
365
- const outSide = unwrapPipeOut(schema);
366
- if (outSide !== void 0 && hasContainerOrRootRefine(outSide, visited)) return true;
367
- return false;
368
- }
369
- if (isZodSchemaType(schema, "ZodObject")) {
370
- for (const sub of Object.values(getObjectShape(schema))) {
371
- if (hasContainerOrRootRefine(sub, visited)) return true;
372
- }
373
- return false;
374
- }
375
- if (isZodSchemaType(schema, "ZodArray")) {
376
- const elem = getArrayElement(schema);
377
- return elem !== void 0 && hasContainerOrRootRefine(elem, visited);
378
- }
379
- if (isZodSchemaType(schema, "ZodTuple")) {
380
- for (const it of getTupleItems(schema)) {
381
- if (hasContainerOrRootRefine(it, visited)) return true;
382
- }
383
- return false;
384
- }
385
- if (isZodSchemaType(schema, "ZodUnion") || isZodSchemaType(schema, "ZodDiscriminatedUnion")) {
386
- for (const opt of getUnionOptions(schema)) {
387
- if (hasContainerOrRootRefine(opt, visited)) return true;
267
+ if (isCoercePrimitive(schema)) capabilities.preprocessOrCoerce = true;
268
+ const typeName = getTypeName(schema) ?? "";
269
+ switch (typeName) {
270
+ case "ZodEffects": {
271
+ const kind = getEffectsKind(schema);
272
+ if (kind === "refinement") capabilities.asyncRefine = true;
273
+ else if ((kind === "transform" || kind === "preprocess") && isAsyncEffect(schema)) {
274
+ capabilities.asyncTransform = true;
275
+ }
276
+ if (kind === "preprocess") capabilities.preprocessOrCoerce = true;
277
+ const inner = unwrapEffectsSource(schema);
278
+ if (!capabilities.containerOrRootRefine && inner !== void 0 && isContainerAfterWrapperPeel(inner)) {
279
+ capabilities.containerOrRootRefine = true;
280
+ }
281
+ walkCapabilities(inner, capabilities, visited);
282
+ return;
388
283
  }
389
- return false;
390
- }
391
- if (isZodSchemaType(schema, "ZodIntersection")) {
392
- const left = getIntersectionLeft(schema);
393
- if (left !== void 0 && hasContainerOrRootRefine(left, visited)) return true;
394
- const right = getIntersectionRight(schema);
395
- if (right !== void 0 && hasContainerOrRootRefine(right, visited)) return true;
396
- return false;
397
- }
398
- if (isZodSchemaType(schema, "ZodRecord")) {
399
- const keyType = getRecordKeyType(schema);
400
- if (keyType !== void 0 && hasContainerOrRootRefine(keyType, visited)) return true;
401
- const valueType = getRecordValueType(schema);
402
- if (valueType !== void 0 && hasContainerOrRootRefine(valueType, visited)) return true;
403
- return false;
404
- }
405
- if (isZodSchemaType(schema, "ZodSet")) {
406
- const elem = getSetValueType(schema);
407
- return elem !== void 0 && hasContainerOrRootRefine(elem, visited);
284
+ case "ZodOptional":
285
+ case "ZodNullable":
286
+ case "ZodDefault":
287
+ case "ZodCatch":
288
+ case "ZodReadonly":
289
+ walkCapabilities(unwrapInner(schema), capabilities, visited);
290
+ return;
291
+ case "ZodBranded":
292
+ walkCapabilities(unwrapBranded(schema), capabilities, visited);
293
+ return;
294
+ case "ZodLazy":
295
+ walkCapabilities(unwrapLazy(schema), capabilities, visited);
296
+ return;
297
+ case "ZodPipeline":
298
+ walkCapabilities(unwrapPipeIn(schema), capabilities, visited);
299
+ walkCapabilities(unwrapPipeOut(schema), capabilities, visited);
300
+ return;
301
+ case "ZodObject":
302
+ for (const sub of Object.values(getObjectShape(schema))) {
303
+ walkCapabilities(sub, capabilities, visited);
304
+ }
305
+ return;
306
+ case "ZodArray":
307
+ walkCapabilities(getArrayElement(schema), capabilities, visited);
308
+ return;
309
+ case "ZodTuple":
310
+ for (const item of getTupleItems(schema)) walkCapabilities(item, capabilities, visited);
311
+ return;
312
+ case "ZodUnion":
313
+ case "ZodDiscriminatedUnion":
314
+ if (typeName === "ZodDiscriminatedUnion") capabilities.discriminatedUnion = true;
315
+ for (const option of getUnionOptions(schema)) walkCapabilities(option, capabilities, visited);
316
+ return;
317
+ case "ZodIntersection":
318
+ walkCapabilities(getIntersectionLeft(schema), capabilities, visited);
319
+ walkCapabilities(getIntersectionRight(schema), capabilities, visited);
320
+ return;
321
+ case "ZodRecord":
322
+ walkCapabilities(getRecordKeyType(schema), capabilities, visited);
323
+ walkCapabilities(getRecordValueType(schema), capabilities, visited);
324
+ return;
325
+ case "ZodSet":
326
+ capabilities.mapOrSet = true;
327
+ walkCapabilities(getSetValueType(schema), capabilities, visited);
328
+ return;
329
+ case "ZodMap":
330
+ capabilities.mapOrSet = true;
331
+ walkCapabilities(getMapKeyType(schema), capabilities, visited);
332
+ walkCapabilities(getMapValueType(schema), capabilities, visited);
333
+ return;
408
334
  }
409
- return false;
410
335
  }
336
+ const CONTAINER_TYPE_NAMES = /* @__PURE__ */ new Set([
337
+ "ZodObject",
338
+ "ZodArray",
339
+ "ZodTuple",
340
+ "ZodIntersection",
341
+ "ZodUnion",
342
+ "ZodDiscriminatedUnion",
343
+ "ZodRecord",
344
+ "ZodMap",
345
+ "ZodSet"
346
+ ]);
411
347
  function isContainerAfterWrapperPeel(schema) {
412
348
  let cur = schema;
413
- for (let i = 0; i < MAX_UNWRAP_STEPS$1; i++) {
414
- if (isZodSchemaType(cur, "ZodOptional") || isZodSchemaType(cur, "ZodNullable") || isZodSchemaType(cur, "ZodDefault") || isZodSchemaType(cur, "ZodCatch") || isZodSchemaType(cur, "ZodReadonly")) {
415
- const inner = unwrapInner(cur);
416
- if (inner === void 0) return false;
417
- cur = inner;
418
- } else if (isZodSchemaType(cur, "ZodBranded")) {
419
- const inner = unwrapBranded(cur);
420
- if (inner === void 0) return false;
421
- cur = inner;
422
- } else if (isZodSchemaType(cur, "ZodLazy")) {
423
- const inner = unwrapLazy(cur);
424
- if (inner === void 0) return false;
425
- cur = inner;
426
- } else {
427
- break;
349
+ for (let i = 0; i < MAX_UNWRAP_STEPS$1 && cur !== void 0; i++) {
350
+ const typeName = getTypeName(cur) ?? "";
351
+ switch (typeName) {
352
+ case "ZodOptional":
353
+ case "ZodNullable":
354
+ case "ZodDefault":
355
+ case "ZodCatch":
356
+ case "ZodReadonly":
357
+ cur = unwrapInner(cur);
358
+ break;
359
+ case "ZodBranded":
360
+ cur = unwrapBranded(cur);
361
+ break;
362
+ case "ZodLazy":
363
+ cur = unwrapLazy(cur);
364
+ break;
365
+ default:
366
+ return CONTAINER_TYPE_NAMES.has(typeName);
428
367
  }
429
368
  }
430
- return isZodSchemaType(cur, "ZodObject") || isZodSchemaType(cur, "ZodArray") || isZodSchemaType(cur, "ZodTuple") || isZodSchemaType(cur, "ZodIntersection") || isZodSchemaType(cur, "ZodUnion") || isZodSchemaType(cur, "ZodDiscriminatedUnion") || isZodSchemaType(cur, "ZodRecord") || isZodSchemaType(cur, "ZodSet");
369
+ return false;
431
370
  }
432
371
 
433
372
  const V3_INTROSPECTOR = {
@@ -439,10 +378,7 @@ const V3_INTROSPECTOR = {
439
378
  getLiteralValues,
440
379
  isPreprocessNode,
441
380
  isCoercePrimitive,
442
- containsAsyncRefine,
443
- containsAsyncTransform,
444
- containsDiscriminatedUnion,
445
- hasContainerOrRootRefine,
381
+ capabilitiesOf,
446
382
  // Walker accessors (D2 / D3 / D5).
447
383
  getArrayElement,
448
384
  getSetValueType,
@@ -467,6 +403,10 @@ const V3_INTROSPECTOR = {
467
403
  getCatchDefault,
468
404
  hasCatchValue
469
405
  };
406
+ const V3_SUB_SCHEMA_INTROSPECTOR = {
407
+ ...V3_INTROSPECTOR,
408
+ capabilitiesOf: scanCapabilities
409
+ };
470
410
 
471
411
  function mapKeyAt(value, index) {
472
412
  if (!(value instanceof Map)) return void 0;
@@ -534,7 +474,7 @@ function normalizeOne(path, rootSchema, data, maxRecursionDepth, peel) {
534
474
  }
535
475
 
536
476
  function slimPrimitivesV3(schema) {
537
- return new Set(slimPrimitivesWalk(schema, V3_INTROSPECTOR, 64));
477
+ return slimPrimitivesWalk(schema, V3_INTROSPECTOR, 64);
538
478
  }
539
479
 
540
480
  function rebuildWithDef(original, defPatch) {
@@ -603,6 +543,9 @@ function rebuildDiscriminatedUnion(original, options) {
603
543
  }
604
544
  return rebuildWithDef(original, { options, optionsMap });
605
545
  }
546
+ function rebuildPipeline(original, inSide, outSide) {
547
+ return rebuildWithDef(original, { in: inSide, out: outSide });
548
+ }
606
549
  function rebuildEffects(original, source, effect) {
607
550
  return rebuildWithDef(original, { schema: source, effect });
608
551
  }
@@ -678,7 +621,9 @@ function walkEffects(schema) {
678
621
  }
679
622
  if (isZodSchemaType(s, "ZodPipeline")) {
680
623
  const inSide = unwrapPipeIn(s);
681
- return inSide === void 0 ? s : recurse(inSide);
624
+ const outSide = unwrapPipeOut(s);
625
+ if (inSide === void 0 || outSide === void 0) return s;
626
+ return rebuildPipeline(s, recurse(inSide), recurse(outSide));
682
627
  }
683
628
  if (isZodSchemaType(s, "ZodObject")) {
684
629
  const shape = getObjectShape(s);
@@ -816,16 +761,22 @@ function syncSafe(schema) {
816
761
  return wrapped;
817
762
  }
818
763
  function buildV3Services(maxRecursionDepth) {
819
- const mapOrSetBySchema = /* @__PURE__ */ new WeakMap();
820
764
  const refileIssues = (schema, data, issues) => {
821
- let hasMapOrSet = mapOrSetBySchema.get(schema);
822
- if (hasMapOrSet === void 0) {
823
- hasMapOrSet = containsMapOrSet(schema);
824
- mapOrSetBySchema.set(schema, hasMapOrSet);
765
+ if (!issues.some((issue) => issue.path.some((segment) => typeof segment === "number"))) {
766
+ return issues;
825
767
  }
826
- if (!hasMapOrSet) return issues;
768
+ if (!capabilitiesOf(schema).mapOrSet) return issues;
827
769
  return normalizeIssuePaths(issues, schema, data, maxRecursionDepth, peelAllV3Wrappers);
828
770
  };
771
+ const validateSync = (schema, data) => {
772
+ if (capabilitiesOf(schema).asyncTransform) return [];
773
+ try {
774
+ const result = syncSafe(schema).safeParse(data);
775
+ return result.success ? [] : zodIssuesToValidationErrors(refileIssues(schema, data, result.error.issues));
776
+ } catch {
777
+ return [];
778
+ }
779
+ };
829
780
  return {
830
781
  getNestedSchemasAtPath: (schema, path, maxRecursionDepth2) => getNestedZodSchemasAtPath(schema, path, maxRecursionDepth2),
831
782
  // The shared path walker peels wrappers and effects inline, so the
@@ -835,6 +786,7 @@ function buildV3Services(maxRecursionDepth) {
835
786
  slimPrimitivesOf: (schema, _maxRecursionDepth) => slimPrimitivesV3(schema),
836
787
  deriveDefault: (schema, useDefault) => getDefaultValuesFromZodSchema(schema, useDefault),
837
788
  runGetDefaults: (schema, config, maxRecursionDepth2) => runGetDefaultsV3(schema, config, maxRecursionDepth2),
789
+ validateSync,
838
790
  unwrapStructuralWrappers: (schema) => unwrapStructuralLeafV3(schema),
839
791
  unwrapToDiscriminatedUnion: (schema) => unwrapToDiscriminatedUnion(schema),
840
792
  peelAllWrappers: (schema) => peelAllV3Wrappers(schema),
@@ -852,10 +804,10 @@ function buildV3Services(maxRecursionDepth) {
852
804
  // A `getSchemasAtPath` consumer may probe any method on the result,
853
805
  // so a sub-schema comes back as a full recursive AbstractSchema: the
854
806
  // factory call rebuilds the whole surface against it, with its own
855
- // per-form caches.
807
+ // per-form caches, and walks its capabilities without the memo.
856
808
  makeSubSchema: (sub, maxRecursionDepth2) => createAbstractSchema(
857
809
  sub,
858
- V3_INTROSPECTOR,
810
+ V3_SUB_SCHEMA_INTROSPECTOR,
859
811
  buildV3Services(maxRecursionDepth2),
860
812
  { maxRecursionDepth: maxRecursionDepth2 }
861
813
  )
@@ -1105,7 +1057,8 @@ function runGetDefaultsV3(rootSchema, config, maxRecursionDepth) {
1105
1057
  rootSchema,
1106
1058
  config.useDefaultSchemaValues
1107
1059
  );
1108
- const rawDefaultValues = config.constraints === void 0 ? defaultValuesWithoutConstraints : fixStructuralDefaults(
1060
+ if (config.constraints === void 0) return defaultValuesWithoutConstraints;
1061
+ return fixStructuralDefaults(
1109
1062
  rootSchema,
1110
1063
  mergeDeep(defaultValuesWithoutConstraints, config.constraints),
1111
1064
  config.useDefaultSchemaValues,
@@ -1117,34 +1070,6 @@ function runGetDefaultsV3(rootSchema, config, maxRecursionDepth) {
1117
1070
  unwrapToDiscriminatedUnion: (s) => unwrapToDiscriminatedUnion(s)
1118
1071
  }
1119
1072
  ).data;
1120
- if (containsAsyncTransform(rootSchema)) {
1121
- return {
1122
- data: rawDefaultValues,
1123
- errors: void 0,
1124
- success: true
1125
- };
1126
- }
1127
- try {
1128
- const parseResult = syncSafe(rootSchema).safeParse(rawDefaultValues);
1129
- if (parseResult.success) {
1130
- return {
1131
- data: rawDefaultValues,
1132
- errors: void 0,
1133
- success: true
1134
- };
1135
- }
1136
- return {
1137
- data: rawDefaultValues,
1138
- errors: zodIssuesToValidationErrors(parseResult.error.issues),
1139
- success: false
1140
- };
1141
- } catch {
1142
- return {
1143
- data: rawDefaultValues,
1144
- errors: void 0,
1145
- success: true
1146
- };
1147
- }
1148
1073
  }
1149
1074
 
1150
1075
  function useForm(configuration) {
@@ -1 +1 @@
1
- export { c as componentBridgeTransform, i as inputTextAreaNodeTransform, r as redundantBindingWarnTransform, v as vRegisterHintTransform, a as vRegisterPreambleTransform } from './shared/attaform.ZYn2ahzJ.mjs';
1
+ export { c as componentBridgeTransform, i as inputTextAreaNodeTransform, r as redundantBindingWarnTransform, v as vRegisterHintTransform, a as vRegisterPreambleTransform } from './shared/attaform.DBCbxlyk.mjs';
package/dist/vite.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { r as resolveZodAliasTarget, i as isRewritableZodSpecifier } from './shared/attaform.BAf3UNn4.mjs';
2
- import { a as vRegisterPreambleTransform, r as redundantBindingWarnTransform, c as componentBridgeTransform, i as inputTextAreaNodeTransform, v as vRegisterHintTransform } from './shared/attaform.ZYn2ahzJ.mjs';
2
+ import { a as vRegisterPreambleTransform, r as redundantBindingWarnTransform, c as componentBridgeTransform, i as inputTextAreaNodeTransform, v as vRegisterHintTransform } from './shared/attaform.DBCbxlyk.mjs';
3
3
  import { parse, babelParse } from '@vue/compiler-sfc';
4
4
  import { NodeTypes } from '@vue/compiler-core';
5
5
 
package/dist/zod-v3.d.mts CHANGED
@@ -1,10 +1,10 @@
1
1
  import { z } from 'zod';
2
- import { G as GenericForm, F as FormKey, U as UseFormConfiguration, aq as AcceptableDefaults, a as UseFormReturnType, ac as ValidateOnConfig, ap as SchemaFactoryOptions, h as FieldMetaPayload } from './shared/attaform.Br8EBn5B.mjs';
2
+ import { G as GenericForm, F as FormKey, U as UseFormConfiguration, ap as AcceptableDefaults, a as UseFormReturnType, ab as ValidateOnConfig, ao as SchemaFactoryOptions, h as FieldMetaPayload } from './shared/attaform.i13OEHJF.mjs';
3
3
  import { AbstractSchema } from './abstract.mjs';
4
- export { b as ArrayItem, c as ArrayPath, C as CustomDirectiveRegisterAssignerFn, d as DeepPartial, D as DefaultValuesInput, 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 SchemaDefaultsResult, a0 as SchemaParseErrorWithData, a1 as SchemaParseErrorWithoutData, a2 as SchemaParseResult, a3 as SchemaParseSuccess, a4 as Segment, a5 as SetValueCallback, a6 as SetValuePayload, a7 as SettledValidationStatus, a8 as SlimPrimitiveKind, a9 as SubmitHandler, aa as Unset, ab as ValidateOn, ad as ValidationError, ae as ValidationResponse, af as ValidationResponseWithoutValue, ag as ValueOfUnion, ah as WriteMeta, ai as WriteShape, aj as canonicalizePath, ak as isPathPrefix, al as isUnset, am as parseDottedPath, an as unset } from './shared/attaform.Br8EBn5B.mjs';
4
+ export { b as ArrayItem, c as ArrayPath, C as CustomDirectiveRegisterAssignerFn, d as DeepPartial, D as DefaultValuesInput, 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.i13OEHJF.mjs';
5
5
  import { S as SupportedRootSchema, U as UnwrapZodRoot, a as StorageShape } from './shared/attaform.B-Tb62qV.mjs';
6
- 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.BcQwgWaq.mjs';
7
- export { v as vRegister } from './shared/attaform.L0kUn3vL.mjs';
6
+ 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.CYlF4P6X.mjs';
7
+ export { v as vRegister } from './shared/attaform.DZOynI6c.mjs';
8
8
  import 'vue';
9
9
 
10
10
  /**
package/dist/zod-v3.mjs CHANGED
@@ -1,9 +1,9 @@
1
- export { i as isZodSchemaType, u as useForm, z as zodAdapter } from './shared/attaform.D_pt1gOj.mjs';
2
- import { i as installingFieldMetaStore, g as getFieldMetaForSchema } from './shared/attaform.DRsANMok.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.CdZIEf7_.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.BIWicztt.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.WiGdIqgx.mjs';
6
- export { a as assignKey, v as vRegister } from './shared/attaform.D_f1WgYf.mjs';
1
+ export { i as isZodSchemaType, u as useForm, z as zodAdapter } from './shared/attaform.u6jfHoed.mjs';
2
+ import { i as installingFieldMetaStore, g as getFieldMetaForSchema } from './shared/attaform.j9xI_ObC.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.BhtAZysa.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.DAf4ehIe.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.CdA9bfRv.mjs';
6
+ export { a as assignKey, v as vRegister } from './shared/attaform.BPMOl562.mjs';
7
7
  export { i as isRegisterValue } from './shared/attaform.KvlEedlF.mjs';
8
8
 
9
9
  const fieldMeta = installingFieldMetaStore;