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
@@ -0,0 +1,120 @@
1
+ const reported = /* @__PURE__ */ new Set() ;
2
+ function reportConsumerThrow(site, detail, err) {
3
+ const key = detail === void 0 ? site : `${site}|${detail}`;
4
+ if (reported === null || reported.has(key)) return;
5
+ reported.add(key);
6
+ const at = detail === void 0 ? "" : ` at \`${detail}\``;
7
+ const advice = {
8
+ "default-factory": "a `.default(() => ...)` factory threw. Attaform used `undefined` for that field's initial value.",
9
+ "catch-factory": "a `.catch(() => ...)` fallback threw. Attaform used `undefined` for that value.",
10
+ "lazy-getter": "a `z.lazy(() => ...)` factory threw. Attaform stopped descending at that node, so paths below it will not resolve.",
11
+ "wizard-slot": `a function step slot threw${at}. Attaform dropped that step from the compiled list; the rest of the flow still navigates.`,
12
+ "wizard-lazy-slot": `a \`lazy()\` step resolver threw${at}. Attaform dropped that step from the compiled list until the resolver's own dependencies change.`,
13
+ "wizard-progress": "a `useWizard({ progress })` override threw. Attaform fell back to its own valid-step ratio.",
14
+ "wizard-restore": "a `useWizard({ restore })` callback threw. Attaform read no step from it, so the wizard stays where it is.",
15
+ "wizard-persist": "a `useWizard({ persist })` callback threw. Attaform navigated anyway, so the step is live but unrecorded.",
16
+ "wizard-default-statuses": "a `useWizard({ defaultStatuses })` factory threw or rejected. Attaform seeded no statuses, the same as omitting the option.",
17
+ "stored-value": "a written value threw as Vue read it to store it (a Proxy whose `get` trap throws). Attaform skipped that write, so the form keeps the value it had."
18
+ };
19
+ console.error(
20
+ `[attaform] ${advice[site]} Attaform has nowhere to surface this, so it must not throw; wrap your own try/catch if the failure is recoverable. Original error:`,
21
+ err
22
+ );
23
+ }
24
+ function callConsumerFn(fn, fallback, site, detail) {
25
+ try {
26
+ return fn();
27
+ } catch (err) {
28
+ reportConsumerThrow(site, detail, err);
29
+ return fallback;
30
+ }
31
+ }
32
+ function readConsumerProp(obj, key) {
33
+ try {
34
+ return obj[key];
35
+ } catch {
36
+ return void 0;
37
+ }
38
+ }
39
+ function consumerKeys(obj) {
40
+ try {
41
+ return Object.keys(obj);
42
+ } catch {
43
+ return [];
44
+ }
45
+ }
46
+ function readConsumerIndex(arr, i) {
47
+ try {
48
+ return arr[i];
49
+ } catch {
50
+ return void 0;
51
+ }
52
+ }
53
+ function consumerSymbolKeys(obj) {
54
+ try {
55
+ return Object.getOwnPropertySymbols(obj);
56
+ } catch {
57
+ return [];
58
+ }
59
+ }
60
+ function consumerHas(obj, key) {
61
+ try {
62
+ return key in obj;
63
+ } catch {
64
+ return false;
65
+ }
66
+ }
67
+
68
+ function safeAssign(target, key, value) {
69
+ if (key === "__proto__") {
70
+ Object.defineProperty(target, key, {
71
+ value,
72
+ writable: true,
73
+ enumerable: true,
74
+ configurable: true
75
+ });
76
+ return;
77
+ }
78
+ target[key] = value;
79
+ }
80
+ const SHADOWED_KEYS = new Set(Object.getOwnPropertyNames(Object.prototype));
81
+ function isShadowedKey(key) {
82
+ return SHADOWED_KEYS.has(key);
83
+ }
84
+ function safeOwnRead(target, key) {
85
+ if (isShadowedKey(key)) {
86
+ const desc = Object.getOwnPropertyDescriptor(target, key);
87
+ if (desc === void 0) return void 0;
88
+ return "value" in desc ? desc.value : readConsumerProp(target, key);
89
+ }
90
+ return readConsumerProp(target, key);
91
+ }
92
+ function safeOwnHas(target, key) {
93
+ try {
94
+ return Object.prototype.hasOwnProperty.call(target, key);
95
+ } catch {
96
+ return false;
97
+ }
98
+ }
99
+ function spreadConsumerRecord(src) {
100
+ try {
101
+ return { ...src };
102
+ } catch {
103
+ const out = {};
104
+ for (const key of Object.keys(src)) {
105
+ safeAssign(out, key, readConsumerProp(src, key));
106
+ }
107
+ return out;
108
+ }
109
+ }
110
+ function copyConsumerArray(src) {
111
+ try {
112
+ return src.slice();
113
+ } catch {
114
+ const out = new Array(src.length);
115
+ for (let i = 0; i < src.length; i++) out[i] = readConsumerIndex(src, i);
116
+ return out;
117
+ }
118
+ }
119
+
120
+ export { safeOwnRead as a, readConsumerProp as b, consumerKeys as c, callConsumerFn as d, safeOwnHas as e, consumerHas as f, spreadConsumerRecord as g, copyConsumerArray as h, isShadowedKey as i, consumerSymbolKeys as j, reportConsumerThrow as k, readConsumerIndex as r, safeAssign as s };
@@ -1,7 +1,7 @@
1
- import { a as InvalidUseFormConfigError } from './attaform-dev.zlvDr0WB.mjs';
2
- import { u as useForm$2 } from './attaform-dev.CT7MDjPy.mjs';
3
- import { u as useForm$1 } from './attaform-dev.BJK1kqHY.mjs';
4
- import { i as installingFieldMetaStore, g as getFieldMetaForSchema } from './attaform-dev.BUIFcTYf.mjs';
1
+ import { a as InvalidUseFormConfigError } from './attaform-dev.04aupFBW.mjs';
2
+ import { u as useForm$2 } from './attaform-dev.OceE0X3v.mjs';
3
+ import { u as useForm$1 } from './attaform-dev.BpVGFSFa.mjs';
4
+ import { i as installingFieldMetaStore, g as getFieldMetaForSchema } from './attaform-dev.PTGM9KE1.mjs';
5
5
 
6
6
  function isZodV4SchemaShape(value) {
7
7
  if (typeof value !== "object" || value === null) return false;
@@ -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-dev.BUIFcTYf.mjs';
2
- import { h as getAtPath, j as humanize, c as useAbstractForm } from './attaform-dev.DxHdkkPG.mjs';
3
- import { c as callConsumerFn } from './attaform-dev.CZz4GYZ6.mjs';
4
- import { A as AttaformError, e as canonicalizePath, a as InvalidUseFormConfigError } from './attaform-dev.zlvDr0WB.mjs';
1
+ import { w as walkPathSegments, s as slimPrimitivesWalk, c as createAbstractSchema, a as createSharedSchemaStore, b as buildFieldMetaPathMap, g as getFieldMetaForSchema, f as fixStructuralDefaults, m as mergeDeep, d as deriveDefaultWalk, e as getFieldMetaListForSchema } from './attaform-dev.PTGM9KE1.mjs';
2
+ import { h as getAtPath, j as humanize, c as useAbstractForm } from './attaform-dev.3uTCYwy8.mjs';
3
+ import { d as callConsumerFn } from './attaform-dev.CwYTWyPX.mjs';
4
+ import { A as AttaformError, e as canonicalizePath, a as InvalidUseFormConfigError } from './attaform-dev.04aupFBW.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);
@@ -817,16 +762,22 @@ function syncSafe(schema) {
817
762
  return wrapped;
818
763
  }
819
764
  function buildV3Services(maxRecursionDepth) {
820
- const mapOrSetBySchema = /* @__PURE__ */ new WeakMap();
821
765
  const refileIssues = (schema, data, issues) => {
822
- let hasMapOrSet = mapOrSetBySchema.get(schema);
823
- if (hasMapOrSet === void 0) {
824
- hasMapOrSet = containsMapOrSet(schema);
825
- mapOrSetBySchema.set(schema, hasMapOrSet);
766
+ if (!issues.some((issue) => issue.path.some((segment) => typeof segment === "number"))) {
767
+ return issues;
826
768
  }
827
- if (!hasMapOrSet) return issues;
769
+ if (!capabilitiesOf(schema).mapOrSet) return issues;
828
770
  return normalizeIssuePaths(issues, schema, data, maxRecursionDepth, peelAllV3Wrappers);
829
771
  };
772
+ const validateSync = (schema, data) => {
773
+ if (capabilitiesOf(schema).asyncTransform) return [];
774
+ try {
775
+ const result = syncSafe(schema).safeParse(data);
776
+ return result.success ? [] : zodIssuesToValidationErrors(refileIssues(schema, data, result.error.issues));
777
+ } catch {
778
+ return [];
779
+ }
780
+ };
830
781
  return {
831
782
  getNestedSchemasAtPath: (schema, path, maxRecursionDepth2) => getNestedZodSchemasAtPath(schema, path, maxRecursionDepth2),
832
783
  // The shared path walker peels wrappers and effects inline, so the
@@ -836,6 +787,7 @@ function buildV3Services(maxRecursionDepth) {
836
787
  slimPrimitivesOf: (schema, _maxRecursionDepth) => slimPrimitivesV3(schema),
837
788
  deriveDefault: (schema, useDefault) => getDefaultValuesFromZodSchema(schema, useDefault),
838
789
  runGetDefaults: (schema, config, maxRecursionDepth2) => runGetDefaultsV3(schema, config, maxRecursionDepth2),
790
+ validateSync,
839
791
  unwrapStructuralWrappers: (schema) => unwrapStructuralLeafV3(schema),
840
792
  unwrapToDiscriminatedUnion: (schema) => unwrapToDiscriminatedUnion(schema),
841
793
  peelAllWrappers: (schema) => peelAllV3Wrappers(schema),
@@ -853,10 +805,10 @@ function buildV3Services(maxRecursionDepth) {
853
805
  // A `getSchemasAtPath` consumer may probe any method on the result,
854
806
  // so a sub-schema comes back as a full recursive AbstractSchema: the
855
807
  // factory call rebuilds the whole surface against it, with its own
856
- // per-form caches.
808
+ // per-form caches, and walks its capabilities without the memo.
857
809
  makeSubSchema: (sub, maxRecursionDepth2) => createAbstractSchema(
858
810
  sub,
859
- V3_INTROSPECTOR,
811
+ V3_SUB_SCHEMA_INTROSPECTOR,
860
812
  buildV3Services(maxRecursionDepth2),
861
813
  { maxRecursionDepth: maxRecursionDepth2 }
862
814
  )
@@ -1112,7 +1064,8 @@ function runGetDefaultsV3(rootSchema, config, maxRecursionDepth) {
1112
1064
  rootSchema,
1113
1065
  config.useDefaultSchemaValues
1114
1066
  );
1115
- const rawDefaultValues = config.constraints === void 0 ? defaultValuesWithoutConstraints : fixStructuralDefaults(
1067
+ if (config.constraints === void 0) return defaultValuesWithoutConstraints;
1068
+ return fixStructuralDefaults(
1116
1069
  rootSchema,
1117
1070
  mergeDeep(defaultValuesWithoutConstraints, config.constraints),
1118
1071
  config.useDefaultSchemaValues,
@@ -1124,34 +1077,6 @@ function runGetDefaultsV3(rootSchema, config, maxRecursionDepth) {
1124
1077
  unwrapToDiscriminatedUnion: (s) => unwrapToDiscriminatedUnion(s)
1125
1078
  }
1126
1079
  ).data;
1127
- if (containsAsyncTransform(rootSchema)) {
1128
- return {
1129
- data: rawDefaultValues,
1130
- errors: void 0,
1131
- success: true
1132
- };
1133
- }
1134
- try {
1135
- const parseResult = syncSafe(rootSchema).safeParse(rawDefaultValues);
1136
- if (parseResult.success) {
1137
- return {
1138
- data: rawDefaultValues,
1139
- errors: void 0,
1140
- success: true
1141
- };
1142
- }
1143
- return {
1144
- data: rawDefaultValues,
1145
- errors: zodIssuesToValidationErrors(parseResult.error.issues),
1146
- success: false
1147
- };
1148
- } catch {
1149
- return {
1150
- data: rawDefaultValues,
1151
- errors: void 0,
1152
- success: true
1153
- };
1154
- }
1155
1080
  }
1156
1081
 
1157
1082
  function useForm(configuration) {