zod-compiler 1.23.7 → 1.23.8

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 (71) hide show
  1. package/dist/core/codegen/build-path.d.ts +31 -1
  2. package/dist/core/codegen/build-path.d.ts.map +1 -1
  3. package/dist/core/codegen/build-path.js +44 -4
  4. package/dist/core/codegen/build-path.js.map +1 -1
  5. package/dist/core/codegen/context.d.ts +17 -1
  6. package/dist/core/codegen/context.d.ts.map +1 -1
  7. package/dist/core/codegen/context.js +18 -2
  8. package/dist/core/codegen/context.js.map +1 -1
  9. package/dist/core/codegen/emit-issue.d.ts +46 -6
  10. package/dist/core/codegen/emit-issue.d.ts.map +1 -1
  11. package/dist/core/codegen/emit-issue.js +48 -18
  12. package/dist/core/codegen/emit-issue.js.map +1 -1
  13. package/dist/core/codegen/index.js +3 -3
  14. package/dist/core/codegen/index.js.map +1 -1
  15. package/dist/core/codegen/issue-decls.d.ts +62 -2
  16. package/dist/core/codegen/issue-decls.d.ts.map +1 -1
  17. package/dist/core/codegen/issue-decls.js +64 -11
  18. package/dist/core/codegen/issue-decls.js.map +1 -1
  19. package/dist/core/codegen/schemas/array.d.ts.map +1 -1
  20. package/dist/core/codegen/schemas/array.js +2 -0
  21. package/dist/core/codegen/schemas/array.js.map +1 -1
  22. package/dist/core/codegen/schemas/bigint.js +1 -1
  23. package/dist/core/codegen/schemas/bigint.js.map +1 -1
  24. package/dist/core/codegen/schemas/discriminated-union.js +2 -2
  25. package/dist/core/codegen/schemas/discriminated-union.js.map +1 -1
  26. package/dist/core/codegen/schemas/effect.js +1 -1
  27. package/dist/core/codegen/schemas/effect.js.map +1 -1
  28. package/dist/core/codegen/schemas/file.d.ts.map +1 -1
  29. package/dist/core/codegen/schemas/file.js +2 -0
  30. package/dist/core/codegen/schemas/file.js.map +1 -1
  31. package/dist/core/codegen/schemas/map.js +2 -2
  32. package/dist/core/codegen/schemas/map.js.map +1 -1
  33. package/dist/core/codegen/schemas/number.js +6 -3
  34. package/dist/core/codegen/schemas/number.js.map +1 -1
  35. package/dist/core/codegen/schemas/record.d.ts.map +1 -1
  36. package/dist/core/codegen/schemas/record.js +23 -9
  37. package/dist/core/codegen/schemas/record.js.map +1 -1
  38. package/dist/core/codegen/schemas/set.d.ts.map +1 -1
  39. package/dist/core/codegen/schemas/set.js +2 -0
  40. package/dist/core/codegen/schemas/set.js.map +1 -1
  41. package/dist/core/codegen/schemas/sizeable.d.ts +37 -0
  42. package/dist/core/codegen/schemas/sizeable.d.ts.map +1 -0
  43. package/dist/core/codegen/schemas/sizeable.js +115 -0
  44. package/dist/core/codegen/schemas/sizeable.js.map +1 -0
  45. package/dist/core/codegen/schemas/string.d.ts.map +1 -1
  46. package/dist/core/codegen/schemas/string.js +10 -4
  47. package/dist/core/codegen/schemas/string.js.map +1 -1
  48. package/dist/core/codegen/schemas/tuple.d.ts.map +1 -1
  49. package/dist/core/codegen/schemas/tuple.js +25 -20
  50. package/dist/core/codegen/schemas/tuple.js.map +1 -1
  51. package/dist/core/codegen/schemas/union.d.ts.map +1 -1
  52. package/dist/core/codegen/schemas/union.js +5 -2
  53. package/dist/core/codegen/schemas/union.js.map +1 -1
  54. package/dist/core/extract/extractors/object.d.ts.map +1 -1
  55. package/dist/core/extract/extractors/object.js +21 -1
  56. package/dist/core/extract/extractors/object.js.map +1 -1
  57. package/dist/core/extract/extractors/optional.d.ts.map +1 -1
  58. package/dist/core/extract/extractors/optional.js +31 -1
  59. package/dist/core/extract/extractors/optional.js.map +1 -1
  60. package/dist/core/extract/extractors/tuple.d.ts.map +1 -1
  61. package/dist/core/extract/extractors/tuple.js +23 -1
  62. package/dist/core/extract/extractors/tuple.js.map +1 -1
  63. package/dist/core/extract/types.d.ts +9 -0
  64. package/dist/core/extract/types.d.ts.map +1 -1
  65. package/dist/core/iife.d.ts +17 -0
  66. package/dist/core/iife.d.ts.map +1 -1
  67. package/dist/core/iife.js +19 -2
  68. package/dist/core/iife.js.map +1 -1
  69. package/dist/core/types.d.ts +27 -0
  70. package/dist/core/types.d.ts.map +1 -1
  71. package/package.json +1 -1
@@ -1,9 +1,39 @@
1
+ import { hasMutation } from "../../codegen/context.js";
2
+ import { innerAppliesDefaultOnUndefined } from "../../codegen/schemas/optional.js";
1
3
  //#region src/core/extract/extractors/optional.ts
4
+ /**
5
+ * Running `ir` on `undefined` provably leaves the value `undefined` — whether it
6
+ * accepts (yielding undefined) or rejects (leaving the payload untouched).
7
+ *
8
+ * This is the condition under which the compiled optional's `if (input !==
9
+ * undefined)` short-circuit is EQUIVALENT to zod's optin branch, which runs the
10
+ * inner and then nullifies a failure whose value is still undefined
11
+ * (`handleOptionalResult`). Both end at "success, undefined".
12
+ *
13
+ * `!hasMutation` is exactly the property needed at the bottom of the chain: a
14
+ * node that cannot rewrite values cannot turn `undefined` into one. The three
15
+ * named wrappers recurse because they pass `undefined` straight through
16
+ * (`$ZodNullable` only intercepts `null`, `$ZodReadonly` freezes the result, and
17
+ * a nested `$ZodOptional` short-circuits or forwards). Everything else —
18
+ * `default`, `catch`, an effect, and above all a `fallback` leaf standing in for
19
+ * `z.prefault()` / a pipe / a union — reports mutating and is handled by the
20
+ * caller instead.
21
+ */
22
+ function passesUndefinedThrough(ir) {
23
+ switch (ir.type) {
24
+ case "optional":
25
+ case "nullable":
26
+ case "readonly": return passesUndefinedThrough(ir.inner);
27
+ default: return !hasMutation(ir);
28
+ }
29
+ }
2
30
  const extractOptional = (def, ctx) => {
3
31
  if ((ctx.schema?._zod?.traits)?.has("$ZodExactOptional")) return ctx.fallback("unsupported");
32
+ const inner = ctx.visit(def.innerType, "._zod.def.innerType");
33
+ if (def.innerType?._zod?.optin === "optional" && !innerAppliesDefaultOnUndefined(inner) && !passesUndefinedThrough(inner)) return ctx.fallback("unsupported");
4
34
  return {
5
35
  type: "optional",
6
- inner: ctx.visit(def.innerType, "._zod.def.innerType")
36
+ inner
7
37
  };
8
38
  };
9
39
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"optional.js","names":[],"sources":["../../../../src/core/extract/extractors/optional.ts"],"sourcesContent":["import type { Extractor, ZodSchema } from \"../types.js\";\n\nexport const extractOptional: Extractor = (def, ctx) => {\n // z.exactOptional() shares def.type \"optional\" but rejects explicit\n // `undefined` (only a missing key is allowed) — compiled optionals accept\n // undefined, so delegate to Zod. Detectable only via constructor traits.\n const traits = (ctx.schema as ZodSchema | undefined)?._zod?.traits;\n if (traits?.has(\"$ZodExactOptional\")) {\n return ctx.fallback(\"unsupported\");\n }\n return {\n type: \"optional\",\n inner: ctx.visit(def.innerType, \"._zod.def.innerType\"),\n };\n};\n"],"mappings":";AAEA,MAAa,mBAA8B,KAAK,QAAQ;CAKtD,KADgB,IAAI,QAAkC,MAAM,OAAA,EAChD,IAAI,mBAAmB,GACjC,OAAO,IAAI,SAAS,aAAa;CAEnC,OAAO;EACL,MAAM;EACN,OAAO,IAAI,MAAM,IAAI,WAAW,qBAAqB;CACvD;AACF"}
1
+ {"version":3,"file":"optional.js","names":[],"sources":["../../../../src/core/extract/extractors/optional.ts"],"sourcesContent":["import { hasMutation } from \"../../codegen/context.js\";\nimport { innerAppliesDefaultOnUndefined } from \"../../codegen/schemas/optional.js\";\nimport type { SchemaIR } from \"../../types.js\";\nimport type { Extractor, ZodSchema } from \"../types.js\";\n\n/**\n * Running `ir` on `undefined` provably leaves the value `undefined` — whether it\n * accepts (yielding undefined) or rejects (leaving the payload untouched).\n *\n * This is the condition under which the compiled optional's `if (input !==\n * undefined)` short-circuit is EQUIVALENT to zod's optin branch, which runs the\n * inner and then nullifies a failure whose value is still undefined\n * (`handleOptionalResult`). Both end at \"success, undefined\".\n *\n * `!hasMutation` is exactly the property needed at the bottom of the chain: a\n * node that cannot rewrite values cannot turn `undefined` into one. The three\n * named wrappers recurse because they pass `undefined` straight through\n * (`$ZodNullable` only intercepts `null`, `$ZodReadonly` freezes the result, and\n * a nested `$ZodOptional` short-circuits or forwards). Everything else —\n * `default`, `catch`, an effect, and above all a `fallback` leaf standing in for\n * `z.prefault()` / a pipe / a union — reports mutating and is handled by the\n * caller instead.\n */\nfunction passesUndefinedThrough(ir: SchemaIR): boolean {\n switch (ir.type) {\n case \"optional\":\n case \"nullable\":\n case \"readonly\":\n return passesUndefinedThrough(ir.inner);\n default:\n return !hasMutation(ir);\n }\n}\n\nexport const extractOptional: Extractor = (def, ctx) => {\n // z.exactOptional() shares def.type \"optional\" but rejects explicit\n // `undefined` (only a missing key is allowed) — compiled optionals accept\n // undefined, so delegate to Zod. Detectable only via constructor traits.\n const traits = (ctx.schema as ZodSchema | undefined)?._zod?.traits;\n if (traits?.has(\"$ZodExactOptional\")) {\n return ctx.fallback(\"unsupported\");\n }\n const inner = ctx.visit(def.innerType, \"._zod.def.innerType\");\n\n // `$ZodOptional.parse` has TWO branches, chosen by the inner schema's `optin`:\n //\n // if (innerType._zod.optin === \"optional\") // inner consumes `undefined` itself\n // return handleOptionalResult(innerType._zod.run(payload, ctx), payload.value);\n // if (payload.value === undefined) return payload; // short-circuit\n // return innerType._zod.run(payload, ctx);\n //\n // Compiled output models the short-circuit, plus the one first-branch case\n // that matters in practice: a `.default()` beneath, which must SEE the\n // undefined so the default fires (`z.string().default(\"d\").optional()` is\n // \"d\", not undefined).\n //\n // Every other optional-in inner — `z.prefault()`, `z.exactOptional()`,\n // `.nonoptional()`, a pipe, a union with an optional-in option, all of which\n // extract to an opaque `fallback` — can substitute a value for `undefined`\n // where the short-circuit would answer `undefined`, and the compiler cannot\n // see through the delegate to tell which. Worse, zod reads `payload.value`\n // AFTER the inner has run, so a prefault that fails its own checks keeps the\n // failure (the value is no longer undefined) — behaviour with no counterpart\n // here. Delegate the whole optional to zod rather than guess.\n const innerOptin = (def.innerType as ZodSchema | undefined)?._zod?.optin === \"optional\";\n if (innerOptin && !innerAppliesDefaultOnUndefined(inner) && !passesUndefinedThrough(inner)) {\n return ctx.fallback(\"unsupported\");\n }\n\n return { type: \"optional\", inner };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAuBA,SAAS,uBAAuB,IAAuB;CACrD,QAAQ,GAAG,MAAX;EACE,KAAK;EACL,KAAK;EACL,KAAK,YACH,OAAO,uBAAuB,GAAG,KAAK;EACxC,SACE,OAAO,CAAC,YAAY,EAAE;CAC1B;AACF;AAEA,MAAa,mBAA8B,KAAK,QAAQ;CAKtD,KADgB,IAAI,QAAkC,MAAM,OAAA,EAChD,IAAI,mBAAmB,GACjC,OAAO,IAAI,SAAS,aAAa;CAEnC,MAAM,QAAQ,IAAI,MAAM,IAAI,WAAW,qBAAqB;CAuB5D,IADoB,IAAI,WAAqC,MAAM,UAAU,cAC3D,CAAC,+BAA+B,KAAK,KAAK,CAAC,uBAAuB,KAAK,GACvF,OAAO,IAAI,SAAS,aAAa;CAGnC,OAAO;EAAE,MAAM;EAAY;CAAM;AACnC"}
@@ -1 +1 @@
1
- {"version":3,"file":"tuple.d.ts","names":[],"sources":["../../../../src/core/extract/extractors/tuple.ts"],"mappings":";;;iBAGgB,aAAa,KAAK,QAAQ,KAAK,mBAAmB"}
1
+ {"version":3,"file":"tuple.d.ts","names":[],"sources":["../../../../src/core/extract/extractors/tuple.ts"],"mappings":";;;iBAyBgB,aAAa,KAAK,QAAQ,KAAK,mBAAmB"}
@@ -1,9 +1,31 @@
1
1
  //#region src/core/extract/extractors/tuple.ts
2
+ /**
3
+ * Port of `$ZodTuple`'s own `optStart` computation, run against the LIVE item
4
+ * schemas:
5
+ *
6
+ * ```js
7
+ * const reversedIndex = [...items].reverse().findIndex((i) => i._zod.optin !== "optional");
8
+ * const optStart = reversedIndex === -1 ? 0 : items.length - reversedIndex;
9
+ * ```
10
+ *
11
+ * i.e. the start of the trailing run of optional-in items (0 when every item is
12
+ * optional-in). See {@link TupleIR.optStart} for why this is read from the zod
13
+ * schema rather than inferred from the extracted IR.
14
+ */
15
+ function computeOptStart(items) {
16
+ let start = items.length;
17
+ for (let i = items.length - 1; i >= 0; i--) {
18
+ if (items[i]?._zod?.optin !== "optional") break;
19
+ start--;
20
+ }
21
+ return start;
22
+ }
2
23
  function extractTuple(def, ctx) {
3
24
  return {
4
25
  type: "tuple",
5
26
  items: def.items.map((item, i) => ctx.visit(item, `._zod.def.items[${i}]`)),
6
- rest: def.rest ? ctx.visit(def.rest, "._zod.def.rest") : null
27
+ rest: def.rest ? ctx.visit(def.rest, "._zod.def.rest") : null,
28
+ optStart: computeOptStart(def.items)
7
29
  };
8
30
  }
9
31
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"tuple.js","names":[],"sources":["../../../../src/core/extract/extractors/tuple.ts"],"sourcesContent":["import type { SchemaIR } from \"../../types.js\";\nimport type { ExtractorContext, ZodDef } from \"../types.js\";\n\nexport function extractTuple(def: ZodDef, ctx: ExtractorContext): SchemaIR {\n const items = def.items.map((item, i) => ctx.visit(item, `._zod.def.items[${i}]`));\n const rest = def.rest ? ctx.visit(def.rest, \"._zod.def.rest\") : null;\n return { type: \"tuple\", items, rest };\n}\n"],"mappings":";AAGA,SAAgB,aAAa,KAAa,KAAiC;CAGzE,OAAO;EAAE,MAAM;EAAS,OAFV,IAAI,MAAM,KAAK,MAAM,MAAM,IAAI,MAAM,MAAM,mBAAmB,EAAE,EAAE,CAEpD;EAAG,MADlB,IAAI,OAAO,IAAI,MAAM,IAAI,MAAM,gBAAgB,IAAI;CAC5B;AACtC"}
1
+ {"version":3,"file":"tuple.js","names":[],"sources":["../../../../src/core/extract/extractors/tuple.ts"],"sourcesContent":["import type { SchemaIR } from \"../../types.js\";\nimport type { ExtractorContext, ZodDef, ZodSchema } from \"../types.js\";\n\n/**\n * Port of `$ZodTuple`'s own `optStart` computation, run against the LIVE item\n * schemas:\n *\n * ```js\n * const reversedIndex = [...items].reverse().findIndex((i) => i._zod.optin !== \"optional\");\n * const optStart = reversedIndex === -1 ? 0 : items.length - reversedIndex;\n * ```\n *\n * i.e. the start of the trailing run of optional-in items (0 when every item is\n * optional-in). See {@link TupleIR.optStart} for why this is read from the zod\n * schema rather than inferred from the extracted IR.\n */\nfunction computeOptStart(items: unknown[]): number {\n let start = items.length;\n for (let i = items.length - 1; i >= 0; i--) {\n if ((items[i] as ZodSchema | undefined)?._zod?.optin !== \"optional\") break;\n start--;\n }\n return start;\n}\n\nexport function extractTuple(def: ZodDef, ctx: ExtractorContext): SchemaIR {\n const items = def.items.map((item, i) => ctx.visit(item, `._zod.def.items[${i}]`));\n const rest = def.rest ? ctx.visit(def.rest, \"._zod.def.rest\") : null;\n return { type: \"tuple\", items, rest, optStart: computeOptStart(def.items) };\n}\n"],"mappings":";;;;;;;;;;;;;;AAgBA,SAAS,gBAAgB,OAA0B;CACjD,IAAI,QAAQ,MAAM;CAClB,KAAK,IAAI,IAAI,MAAM,SAAS,GAAG,KAAK,GAAG,KAAK;EAC1C,IAAK,MAAM,EAAE,EAA4B,MAAM,UAAU,YAAY;EACrE;CACF;CACA,OAAO;AACT;AAEA,SAAgB,aAAa,KAAa,KAAiC;CAGzE,OAAO;EAAE,MAAM;EAAS,OAFV,IAAI,MAAM,KAAK,MAAM,MAAM,IAAI,MAAM,MAAM,mBAAmB,EAAE,EAAE,CAEpD;EAAG,MADlB,IAAI,OAAO,IAAI,MAAM,IAAI,MAAM,gBAAgB,IAAI;EAC3B,UAAU,gBAAgB,IAAI,KAAK;CAAE;AAC5E"}
@@ -110,6 +110,15 @@ interface ZodSchema {
110
110
  traits?: Set<string>;
111
111
  /** "optional" when the key may be absent in object output (zod optout). */
112
112
  optout?: string;
113
+ /**
114
+ * "optional" when the schema ACCEPTS an absent/undefined input — zod's
115
+ * `optin`. Set outright by `z.optional()`, `z.exactOptional()`,
116
+ * `z.undefined()`, `.default()` and `.prefault()`, and propagated by
117
+ * `.nullable()`, `.readonly()`, `.nonoptional()`, `z.lazy()`, a pipe (from
118
+ * its `in`) and a union (when ANY option has it). Drives which tuple items
119
+ * may be omitted and which branch `$ZodOptional` takes.
120
+ */
121
+ optin?: string;
113
122
  /** Discriminator dispatch values per property key (discriminated unions). */
114
123
  propValues?: Record<string, Set<unknown> | undefined>;
115
124
  };
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","names":[],"sources":["../../../src/core/extract/types.ts"],"mappings":";;UAEiB;EACf;EACA;EACA;EACA,SAAS;EACT;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;EACA;;EAEA,WAAW;EACX,WAAW;EACX;EACA;;UAGe;EACf;IACE,KAAK;;;;;;IAML;;;UAIa;EACf;;EAEA;;EAEA;;EAEA;EACA,QAAQ;EACR;EACA;EACA,SAAS;;EAET;;EAEA,WAAW;EACX,OAAO,eAAe;EACtB,SAAS;EACT,SAAS;EACT,WAAW;;;;;;EAMX,QAAQ;EACR,SAAS;EACT,IAAI;EACJ,KAAK;EACL,OAAO;EACP,MAAM;EACN,SAAS;EACT,WAAW;EACX,MAAM;EACN,OAAO;EACP;;;;;;EAMA;;EAEA;EACA;EACA;EACA,cAAc;;EAEd;;EAEA;;UAGe;EACf;IACE,KAAK;IACL,MAAM;;IAEN,YAAY;;IAEZ,UAAU;;IAEV,SAAS;;IAET,SAAS;;IAET;;IAEA,aAAa,eAAe;;;;UAKf;;EAEf;;EAEA;;;KAMU;;;;;;;;;;UA8CK;;WAEN;;WAEA,SAAS;;EAElB;;;UAMe;;WAEN;;WAEA;;WAEA,MAAM;;WAEN,UAAU;;WAEV,WAAW;;EAGpB,MAAM,sBAAsB,sBAHR;;EAMpB,SAAS,QAH+D,uBAGjC;;;KAI7B,aAAa,KAAK,QAAQ,KAAK,qBAAA"}
1
+ {"version":3,"file":"types.d.ts","names":[],"sources":["../../../src/core/extract/types.ts"],"mappings":";;UAEiB;EACf;EACA;EACA;EACA,SAAS;EACT;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;EACA;;EAEA,WAAW;EACX,WAAW;EACX;EACA;;UAGe;EACf;IACE,KAAK;;;;;;IAML;;;UAIa;EACf;;EAEA;;EAEA;;EAEA;EACA,QAAQ;EACR;EACA;EACA,SAAS;;EAET;;EAEA,WAAW;EACX,OAAO,eAAe;EACtB,SAAS;EACT,SAAS;EACT,WAAW;;;;;;EAMX,QAAQ;EACR,SAAS;EACT,IAAI;EACJ,KAAK;EACL,OAAO;EACP,MAAM;EACN,SAAS;EACT,WAAW;EACX,MAAM;EACN,OAAO;EACP;;;;;;EAMA;;EAEA;EACA;EACA;EACA,cAAc;;EAEd;;EAEA;;UAGe;EACf;IACE,KAAK;IACL,MAAM;;IAEN,YAAY;;IAEZ,UAAU;;IAEV,SAAS;;IAET,SAAS;;IAET;;;;;;;;;IASA;;IAEA,aAAa,eAAe;;;;UAKf;;EAEf;;EAEA;;;KAMU;;;;;;;;;;UA8CK;;WAEN;;WAEA,SAAS;;EAElB;;;UAMe;;WAEN;;WAEA;;WAEA,MAAM;;WAEN,UAAU;;WAEV,WAAW;;EAGpB,MAAM,sBAAsB,sBAHR;;EAMpB,SAAS,QAH+D,uBAGjC;;;KAI7B,aAAa,KAAK,QAAQ,KAAK,qBAAA"}
@@ -155,6 +155,23 @@ declare const FINZ_DECL = "function __zcFinZ(z,i){return new __ZcFailZ(z,i);}";
155
155
  * rejection (a default/catch may still succeed), so it would be unsound as a
156
156
  * standalone guard.
157
157
  *
158
+ * parseAsync/safeParseAsync wrap the SYNC validator, which is right for every
159
+ * schema the compiler can reproduce — none of them are async. It is wrong for
160
+ * the ones it cannot: an `async` refinement or a `z.promise()` extracts to a
161
+ * Zod delegate, and delegating means calling Zod's SYNCHRONOUS safeParse, which
162
+ * raises `$ZodAsyncError` by design. Wrapping that gave the compiled schema an
163
+ * async pair that rejected with `$ZodAsyncError` for EVERY input — including
164
+ * valid ones — where Zod resolves normally, so `await UserSchema.parseAsync(x)`
165
+ * stopped working the moment any part of the schema went async.
166
+ *
167
+ * So both are guarded: a synchronous throw hands off to the schema's ORIGINAL
168
+ * async method, captured before these are installed — the same escape hatch
169
+ * `~standard` already uses for its throw path, and for the same reason (the
170
+ * compiled validator has no async mode to offer, and Zod's is exact). It also
171
+ * fixes the smaller wart that a throwing `fn` made `parseAsync` throw
172
+ * SYNCHRONOUSLY rather than return a rejected promise. With `zodCompat: false`
173
+ * there is no schema to delegate to and the throw propagates as before.
174
+ *
158
175
  * `~standard` is REPLACED, not merely preserved. Zod builds it lazily as
159
176
  * `validate: (v) => safeParse(inst, v)` — the core FUNCTION, which goes straight
160
177
  * to `inst._zod.run`. It never reads the schema's own `safeParse` property, so
@@ -1 +1 @@
1
- {"version":3,"file":"iife.d.ts","names":[],"sources":["../../src/core/iife.ts"],"mappings":";;;;;;;;cAaa;;;;;;;;;;;;;;;;;;;;cAsBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA8CA;;;cAUA;;;;;;;;;;;;;;;;;;;;;;;cAyBA;;;;;;;;;;;;;;;;;;;;;;;cAwBA;;cAMA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAyDA;;;;;;;;;iBAsBG,aACd,oBACA,QAAQ,oBACR;EAAY"}
1
+ {"version":3,"file":"iife.d.ts","names":[],"sources":["../../src/core/iife.ts"],"mappings":";;;;;;;;cAaa;;;;;;;;;;;;;;;;;;;;cAsBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA8CA;;;cAUA;;;;;;;;;;;;;;;;;;;;;;;cAyBA;;;;;;;;;;;;;;;;;;;;;;;cAwBA;;cAMA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA0EA;;;;;;;;;iBAsBG,aACd,oBACA,QAAQ,oBACR;EAAY"}
package/dist/core/iife.js CHANGED
@@ -65,7 +65,7 @@ const ZOD_MSG_DECLARATION = "function __zcUw(m){return typeof m===\"string\"?m:(
65
65
  * dominated by the ZodError construction on the next line (stack capture plus a
66
66
  * JSON.stringify of every issue).
67
67
  */
68
- const FAIL_CLASS_DECL = "function __ZcFail(e,f,i){this.success=false;this._e=e;this._f=f;this._i=i;this._c=undefined;}Object.defineProperty(__ZcFail.prototype,\"error\",{configurable:true,get:function(){if(this._c)return this._c;var e=this._f!==null?this._f(this._i):this._e;for(var i=0;i<e.length;i++){if(e[i].message===undefined&&typeof __zcMsg===\"function\")e[i].message=__zcMsg(e[i]);delete e[i].input;}return this._c=new __zcZodError(e);}});";
68
+ const FAIL_CLASS_DECL = "function __ZcFail(e,f,i){this.success=false;this._e=e;this._f=f;this._i=i;this._c=undefined;}Object.defineProperty(__ZcFail.prototype,\"error\",{configurable:true,get:function(){if(this._c)return this._c;var e=this._f!==null?this._f(this._i):this._e;for(var i=0;i<e.length;i++){if(e[i].message===undefined&&typeof __zcMsg===\"function\")e[i].message=__zcMsg(e[i]);delete e[i].input;delete e[i].continue;}return this._c=new __zcZodError(e);}});";
69
69
  /** Eager finalizer (mutation / partial-fast-path schemas): issues already
70
70
  * collected in `e`; success short-circuits to a plain result literal. */
71
71
  const FIN_DECL = "function __zcFin(e,d){if(!e.length)return{success:true,data:d};return new __ZcFail(e,null,null);}";
@@ -154,6 +154,23 @@ const FINZ_DECL = "function __zcFinZ(z,i){return new __ZcFailZ(z,i);}";
154
154
  * rejection (a default/catch may still succeed), so it would be unsound as a
155
155
  * standalone guard.
156
156
  *
157
+ * parseAsync/safeParseAsync wrap the SYNC validator, which is right for every
158
+ * schema the compiler can reproduce — none of them are async. It is wrong for
159
+ * the ones it cannot: an `async` refinement or a `z.promise()` extracts to a
160
+ * Zod delegate, and delegating means calling Zod's SYNCHRONOUS safeParse, which
161
+ * raises `$ZodAsyncError` by design. Wrapping that gave the compiled schema an
162
+ * async pair that rejected with `$ZodAsyncError` for EVERY input — including
163
+ * valid ones — where Zod resolves normally, so `await UserSchema.parseAsync(x)`
164
+ * stopped working the moment any part of the schema went async.
165
+ *
166
+ * So both are guarded: a synchronous throw hands off to the schema's ORIGINAL
167
+ * async method, captured before these are installed — the same escape hatch
168
+ * `~standard` already uses for its throw path, and for the same reason (the
169
+ * compiled validator has no async mode to offer, and Zod's is exact). It also
170
+ * fixes the smaller wart that a throwing `fn` made `parseAsync` throw
171
+ * SYNCHRONOUSLY rather than return a rejected promise. With `zodCompat: false`
172
+ * there is no schema to delegate to and the throw propagates as before.
173
+ *
157
174
  * `~standard` is REPLACED, not merely preserved. Zod builds it lazily as
158
175
  * `validate: (v) => safeParse(inst, v)` — the core FUNCTION, which goes straight
159
176
  * to `inst._zod.run`. It never reads the schema's own `safeParse` property, so
@@ -172,7 +189,7 @@ const FINZ_DECL = "function __zcFinZ(z,i){return new __ZcFailZ(z,i);}";
172
189
  * redefines the slot as non-writable, so a second `__zcMkv` on the same schema
173
190
  * object — two exports aliasing one schema — would throw under ESM strict mode.
174
191
  */
175
- const MK_VALIDATOR_DECL = "function __zcMkv(fn,schema,fc,is){var w=schema||{};w.parse=fc?function(input){if(fc(input))return input;var r=fn(input);if(r.success)return r.data;throw r.error;}:function(input){var r=fn(input);if(r.success)return r.data;throw r.error;};w.safeParse=fn;w.safeParseAsync=function(input){return Promise.resolve(fn(input));};w.parseAsync=fc?function(input){if(fc(input))return Promise.resolve(input);var r=fn(input);if(r.success)return Promise.resolve(r.data);return Promise.reject(r.error);}:function(input){var r=fn(input);if(r.success)return Promise.resolve(r.data);return Promise.reject(r.error);};w.is=is||function(input){return fn(input).success;};var s=w[\"~standard\"],zv=s&&s.validate;Object.defineProperty(w,\"~standard\",{configurable:true,value:{version:1,vendor:(s&&s.vendor)||\"zod\",validate:function(input){var r;try{if(fc&&fc(input))return{value:input};r=fn(input);}catch(e){if(zv)return zv(input);throw e;}return r.success?{value:r.data}:{issues:r.error.issues};}}});return w;}";
192
+ const MK_VALIDATOR_DECL = "function __zcMkv(fn,schema,fc,is){var w=schema||{};var zpa=w.parseAsync,zspa=w.safeParseAsync;w.parse=fc?function(input){if(fc(input))return input;var r=fn(input);if(r.success)return r.data;throw r.error;}:function(input){var r=fn(input);if(r.success)return r.data;throw r.error;};w.safeParse=fn;w.safeParseAsync=function(input){try{return Promise.resolve(fn(input));}catch(e){if(zspa)return zspa(input);throw e;}};w.parseAsync=fc?function(input){try{if(fc(input))return Promise.resolve(input);var r=fn(input);if(r.success)return Promise.resolve(r.data);return Promise.reject(r.error);}catch(e){if(zpa)return zpa(input);throw e;}}:function(input){try{var r=fn(input);if(r.success)return Promise.resolve(r.data);return Promise.reject(r.error);}catch(e){if(zpa)return zpa(input);throw e;}};w.is=is||function(input){return fn(input).success;};var s=w[\"~standard\"],zv=s&&s.validate;Object.defineProperty(w,\"~standard\",{configurable:true,value:{version:1,vendor:(s&&s.vendor)||\"zod\",validate:function(input){var r;try{if(fc&&fc(input))return{value:input};r=fn(input);}catch(e){if(zv)return zv(input);throw e;}return r.success?{value:r.data}:{issues:r.error.issues};}}});return w;}";
176
193
  function extractFunctionName(functionDef) {
177
194
  const match = /^function\s+(\w+)\s*\(/.exec(functionDef);
178
195
  if (!match?.[1]) throw new Error("Cannot extract function name from generated code");
@@ -1 +1 @@
1
- {"version":3,"file":"iife.js","names":[],"sources":["../../src/core/iife.ts"],"sourcesContent":["/**\n * Shared CompiledSchema<T> IIFE generation.\n * Used by both CLI emitter and unplugin transform.\n */\n\nimport type { CompiledSchemaInfo } from \"./pipeline.js\";\n\n/**\n * Import statement required by generateIIFE output (references\n * __zodCompilerConfig). `core` is bound for $ZodAsyncError: superRefine and\n * custom callbacks may only reveal that they are async through the promise\n * they return, at which point zod's own synchronous parse raises.\n */\nexport const ZOD_CONFIG_IMPORT =\n 'import { config as __zodCompilerConfig, core as __zcCore, ZodRealError as __zcZodError } from \"zod\";';\n\n/**\n * File-level `__zcMsg` declaration (must appear once after ZOD_CONFIG_IMPORT):\n * the message an issue gets when nothing was baked into it at build time.\n *\n * Resolves zod's tail of `finalizeIssue` — `config.customError` then\n * `config.localeError` then \"Invalid input\" — and does it PER CALL, because the\n * config is mutable: `z.config({ localeError })` in an entry point runs after\n * the schema modules it imports, so a value snapshotted at module init misses\n * it. Reading a captured `localeError` alone also dropped `customError`\n * outright, silently ignoring the global map most i18n setups install.\n *\n * The head of zod's chain — the schema's own `error` option — is baked into the\n * issue at build time and short-circuits this. The one link that cannot be\n * reproduced is a per-CALL `ctx.error`, which would have to travel through\n * `safeParse`; that entry point sits at V8's inlining budget, where even an\n * unused extra parameter measured ~12% on every parse.\n *\n * Only ever called while building an error, never on a successful parse.\n */\nexport const ZOD_MSG_DECLARATION =\n 'function __zcUw(m){return typeof m===\"string\"?m:(m===undefined||m===null?undefined:m.message);}' +\n \"var __zcMsg=function(iss){var c=__zodCompilerConfig(),m;\" +\n \"if(c.customError){m=__zcUw(c.customError(iss));if(m!==undefined&&m!==null)return m;}\" +\n \"if(c.localeError){m=__zcUw(c.localeError(iss));if(m!==undefined&&m!==null)return m;}\" +\n 'return \"Invalid input\";};';\n\n/**\n * Shared failure-result for __zcFin / __zcFinD. Inline mode (CLI emitter)\n * declares it once per compiled file; lean mode (all unplugin bundlers) declares\n * it once per bundle in the plugin-materialized runtime module (module-local —\n * generated code only ever references __zcFin/__zcFinD, never __ZcFail).\n *\n * Why a prototype getter and not `{success:false, get error(){...}}`: an object\n * literal with an inline accessor forces V8 down its slow accessor-defining\n * allocation path — ~110ns per failure, measured — which dominates the entire\n * invalid-input cost whenever callers never read `.error`. Hosting `error` on\n * the prototype turns each failure into a plain field-only instantiation (~2ns,\n * ~13x), with the lazy-cache semantics intact. (Trade-off: `error` is a\n * prototype accessor, so it no longer shows up in `Object.keys(result)` / spread\n * / JSON.stringify of the result wrapper — `.success`/`.error`/`.data` access,\n * destructuring, and `in` are unaffected.)\n *\n * One class serves both finalizers, so the instances share one hidden class:\n * __zcFin passes pre-collected issues in `_e` (with `_f===null`); __zcFinD\n * passes the hosted slow-walk in `_f` plus the input in `_i`, and the getter\n * runs the walk on first `.error` read. The whole finalization — locale fill\n * (__zcMsg applied ONLY when an issue carries no message, never overwriting a\n * baked-in custom/fallback message), input strip, and ZodError construction\n * (zod v4 JSON.stringifies every issue into `message` and captures a stack\n * trace) — stays deferred inside the cached accessor exactly as before, since\n * the issues array is observable solely through `.error`.\n *\n * `input` is `delete`d, not assigned `undefined`. Key PRESENCE is observable —\n * `\"input\" in issue`, `Object.keys(issue)`, object spread, `toStrictEqual`\n * against a zod issue — and zod's `util.finalizeIssue` does `delete full.input`\n * whenever `reportInput` is off, so assignment left every compiled issue one\n * enumerable key wider than zod's. The delete's dictionary-mode transition is\n * affordable precisely BECAUSE of the deferral above: it runs only after a\n * caller asks for `.error` on a failed parse, and is memoised in `_c`. Neither\n * a successful parse nor a `.success`/`.is()` check on a rejected one reaches\n * it — measured, the two are unchanged, while the `.error` read itself goes\n * ~3.95us -> ~4.19us per failure, i.e. ~6% of a path whose cost is already\n * dominated by the ZodError construction on the next line (stack capture plus a\n * JSON.stringify of every issue).\n */\nexport const FAIL_CLASS_DECL =\n \"function __ZcFail(e,f,i){this.success=false;this._e=e;this._f=f;this._i=i;this._c=undefined;}\" +\n 'Object.defineProperty(__ZcFail.prototype,\"error\",{configurable:true,get:function(){' +\n \"if(this._c)return this._c;\" +\n \"var e=this._f!==null?this._f(this._i):this._e;\" +\n 'for(var i=0;i<e.length;i++){if(e[i].message===undefined&&typeof __zcMsg===\"function\")e[i].message=__zcMsg(e[i]);delete e[i].input;}' +\n \"return this._c=new __zcZodError(e);}});\";\n\n/** Eager finalizer (mutation / partial-fast-path schemas): issues already\n * collected in `e`; success short-circuits to a plain result literal. */\nexport const FIN_DECL =\n \"function __zcFin(e,d){if(!e.length)return{success:true,data:d};return new __ZcFail(e,null,null);}\";\n\n/**\n * Deferred-collection finalizer for Fast-Path-eligible schemas. When the\n * fast check fails, the ENTIRE slow path (the issue-collecting re-walk) is\n * pushed into the cached `.error` accessor instead of running eagerly:\n * fast-eligible schemas never mutate, so the walk's only output is the\n * issues array, which is observable solely through `.error` — one step\n * further along the same lazy boundary `__zcFin` already established (locale\n * fill, input strip, ZodError construction). A failed safeParse whose\n * `.error` is never read costs the fast check alone.\n *\n * Takes the schema's HOSTED slow-walk function plus the input — NOT a\n * per-call closure: `__zcFinD(__sw_N, input)` allocates only the result\n * object, where `__zcFinD(function(){...})` paid a closure environment and\n * function object per failure. Hosting the walk also shrinks safeParse to\n * two statements, within V8's inlining budget (the success-path result\n * literal becomes escape-analyzable at monomorphic call sites).\n *\n * The walk re-reads `input` at `.error`-read time; a caller that mutates\n * the input between safeParse and reading `.error` sees issues for the\n * mutated value (zod materializes at parse time). Same caveat class as the\n * documented __zcFin deferral.\n */\nexport const FIN_DEFERRED_DECL = \"function __zcFinD(f,inp){return new __ZcFail(null,f,inp);}\";\n\n/**\n * Compact-mode failure class — a lazy failure that delegates error reporting to\n * the ORIGINAL Zod schema's `safeParse`. Used by `output: \"compact\"`, where the\n * compiled slow walk is dropped entirely: a mutation-free schema's fast check\n * is the only generated validation, and on a fast-check failure the cold error\n * path is produced by the retained Zod schema itself (`zod` is the source of\n * truth, so the issues are byte-identical — no second validation engine).\n *\n * `_z` is the schema's PRISTINE bound safeParse (`__rf[N].safeParse.bind(...)`,\n * captured pre-`__zcMkv` by emitRfDelegate — see context.ts — so it is zod's\n * own implementation, never the compiled delegate, avoiding infinite\n * recursion). The zod parse is deferred until `.error` is read and cached, so\n * the common `safeParse(x).success`/`.is(x)` checks on invalid input cost only\n * the fast check (zod never runs) — the same deferral boundary `__zcFinD`\n * establishes for the compiled slow walk. Sound because compact mode is gated\n * on a TOTAL fast path: `fc(input) === false` ⟹ zod rejects, so `success:false`\n * holds without consulting zod.\n *\n * The getter returns zod's OWN ZodError verbatim (no locale fill / input strip /\n * re-wrap — zod already finalized it), so a delegated failure is exactly what\n * the unaltered schema would have produced.\n */\nexport const FAILZ_CLASS_DECL =\n \"function __ZcFailZ(z,i){this.success=false;this._z=z;this._i=i;this._c=undefined;}\" +\n 'Object.defineProperty(__ZcFailZ.prototype,\"error\",{configurable:true,get:function(){' +\n \"return this._c||(this._c=this._z(this._i).error);}});\";\n\n/** Compact-mode finalizer: wrap a pristine bound safeParse + input into a lazy delegated failure. */\nexport const FINZ_DECL = \"function __zcFinZ(z,i){return new __ZcFailZ(z,i);}\";\n\n/**\n * Validator factory. Inline mode (CLI emitter) declares it once per compiled\n * file; lean mode (all unplugin bundlers) exports it once per bundle from the\n * plugin-materialized runtime module — generated code never imports it from\n * the zod-compiler package itself, so zod-compiler stays a devDependency and\n * the helper set is always version-locked to the codegen that calls it.\n * Wraps a safeParse function into the CompiledSchema interface.\n *\n * IDENTITY-PRESERVING: with zodCompat (schema != null) the compiled\n * parse/safeParse/parseAsync/safeParseAsync are installed as OWN properties\n * on the original schema object, which is returned as-is. zod v4 keys\n * several APIs on object identity — toJSONSchema's ctx.seen registers the\n * object it is handed while each processor closure captures the original\n * inst (a wrapper crashes `optionalProcessor` with \"Cannot set properties\n * of undefined (setting 'ref')\" the moment a compiled schema is composed\n * into another schema), and globalRegistry/.meta() is a WeakMap keyed by\n * the schema instance (a wrapper silently loses OpenAPI titles/ids). An\n * Object.create wrapper breaks both; mutating the original breaks neither\n * (zod's internal parsing flows through _zod.run, never the public\n * methods, and derived schemas — .optional(), .extend() — are fresh\n * instances that fall back to plain zod). schema=null (zodCompat: false)\n * still produces a plain method-bag object.\n *\n * fc is the schema's hosted fast-check boolean function (null when no Fast\n * Path exists). parse()/parseAsync() try it first and return the input\n * directly on success: fc is small enough for V8 to inline, so the hot parse\n * path runs with zero allocations — calling fn would allocate an intermediate\n * SafeParseResult that escape analysis cannot remove (fn never inlines).\n * Fast-path-eligible schemas never mutate, so fc(input) ⟹ data === input.\n *\n * is is the TOTAL fast-check predicate (fc when the fast path is total, else\n * null). Installed as `.is()` — a zero-allocation boolean type guard. When\n * null (partial fast path or none) `.is()` derives from fn(input).success: a\n * partial fc can pass-through valid input but its `false` does not imply\n * rejection (a default/catch may still succeed), so it would be unsound as a\n * standalone guard.\n *\n * `~standard` is REPLACED, not merely preserved. Zod builds it lazily as\n * `validate: (v) => safeParse(inst, v)` — the core FUNCTION, which goes straight\n * to `inst._zod.run`. It never reads the schema's own `safeParse` property, so\n * installing the compiled one leaves this route entirely uncompiled: measured\n * 271.7 ns against the compiled 26.6 ns on the same schema, i.e. Standard Schema\n * consumers (tRPC, Hono, TanStack) were getting plain Zod.\n *\n * Zod's own validate is captured first and kept as the throw path: it catches a\n * synchronous throw and retries through `safeParseAsync`, which is how an async\n * refinement resolves and how a throwing check surfaces as a rejected promise\n * rather than a synchronous throw. The compiled validator cannot reproduce that\n * (async schemas delegate to Zod anyway), so deferring to the original is both\n * simpler and exact.\n *\n * Installed with defineProperty rather than assignment: Zod's lazy setter\n * redefines the slot as non-writable, so a second `__zcMkv` on the same schema\n * object — two exports aliasing one schema — would throw under ESM strict mode.\n */\nexport const MK_VALIDATOR_DECL =\n \"function __zcMkv(fn,schema,fc,is){var w=schema||{};w.parse=fc?function(input){if(fc(input))return input;var r=fn(input);if(r.success)return r.data;throw r.error;}:function(input){var r=fn(input);if(r.success)return r.data;throw r.error;};w.safeParse=fn;w.safeParseAsync=function(input){return Promise.resolve(fn(input));};w.parseAsync=fc?function(input){if(fc(input))return Promise.resolve(input);var r=fn(input);if(r.success)return Promise.resolve(r.data);return Promise.reject(r.error);}:function(input){var r=fn(input);if(r.success)return Promise.resolve(r.data);return Promise.reject(r.error);};w.is=is||function(input){return fn(input).success;};\" +\n 'var s=w[\"~standard\"],zv=s&&s.validate;' +\n 'Object.defineProperty(w,\"~standard\",{configurable:true,value:{version:1,vendor:(s&&s.vendor)||\"zod\",validate:function(input){var r;try{if(fc&&fc(input))return{value:input};r=fn(input);}catch(e){if(zv)return zv(input);throw e;}return r.success?{value:r.data}:{issues:r.error.issues};}}});' +\n \"return w;}\";\n\nfunction extractFunctionName(functionDef: string): string {\n const match = /^function\\s+(\\w+)\\s*\\(/.exec(functionDef);\n if (!match?.[1]) {\n throw new Error(\"Cannot extract function name from generated code\");\n }\n return match[1];\n}\n\n/**\n * Generate a `/* @__PURE__ * /` IIFE wrapping a compiled validator.\n *\n * @param schemaExpr - Expression resolving to the original Zod schema\n * (e.g. `\"UserSchema\"` in unplugin, `\"(__src_X as any).schema\"` in CLI)\n * @param schema\n * @param options\n */\nexport function generateIIFE(\n schemaExpr: string,\n schema: CompiledSchemaInfo,\n options?: { zodCompat?: boolean | undefined },\n): string {\n const { codegenResult, refEntries } = schema;\n const fnName = extractFunctionName(codegenResult.functionDef);\n const zodCompat = options?.zodCompat !== false;\n const schemaArg = zodCompat ? schemaExpr : \"null\";\n const fcArg = codegenResult.fastFnName ?? \"null\";\n // `.is()` gets the fast-check directly only when it is a total predicate;\n // partial/none falls back to safeParse().success inside __zcMkv. A rebuilding\n // schema has no by-reference `fc` but still names its predicate separately.\n const isArg = codegenResult.isFnName ?? (codegenResult.fastTotal ? fcArg : \"null\");\n\n return [\n \"/* @__PURE__ */ (() => {\",\n ...(refEntries.length > 0\n ? [`var __rf=[${refEntries.map((fb) => `${schemaExpr}${fb.accessPath}`).join(\",\")}];`]\n : []),\n ...codegenResult.code\n .split(\"\\n\")\n .filter((l) => l.trim() !== \"\" && l.trim() !== \"/* zod-compiler */\"),\n codegenResult.functionDef,\n `return __zcMkv(${fnName},${schemaArg},${fcArg},${isArg});`,\n \"})()\",\n ].join(\"\\n\");\n}\n"],"mappings":";;;;;;;AAaA,MAAa,oBACX;;;;;;;;;;;;;;;;;;;;AAqBF,MAAa,sBACX;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CF,MAAa,kBACX;;;AASF,MAAa,WACX;;;;;;;;;;;;;;;;;;;;;;;AAwBF,MAAa,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;AAwBjC,MAAa,mBACX;;AAKF,MAAa,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyDzB,MAAa,oBACX;AAKF,SAAS,oBAAoB,aAA6B;CACxD,MAAM,QAAQ,yBAAyB,KAAK,WAAW;CACvD,IAAI,CAAC,QAAQ,IACX,MAAM,IAAI,MAAM,kDAAkD;CAEpE,OAAO,MAAM;AACf;;;;;;;;;AAUA,SAAgB,aACd,YACA,QACA,SACQ;CACR,MAAM,EAAE,eAAe,eAAe;CACtC,MAAM,SAAS,oBAAoB,cAAc,WAAW;CAE5D,MAAM,YADY,SAAS,cAAc,QACX,aAAa;CAC3C,MAAM,QAAQ,cAAc,cAAc;CAI1C,MAAM,QAAQ,cAAc,aAAa,cAAc,YAAY,QAAQ;CAE3E,OAAO;EACL;EACA,GAAI,WAAW,SAAS,IACpB,CAAC,aAAa,WAAW,KAAK,OAAO,GAAG,aAAa,GAAG,YAAY,CAAC,CAAC,KAAK,GAAG,EAAE,GAAG,IACnF,CAAC;EACL,GAAG,cAAc,KACd,MAAM,IAAI,CAAC,CACX,QAAQ,MAAM,EAAE,KAAK,MAAM,MAAM,EAAE,KAAK,MAAM,oBAAoB;EACrE,cAAc;EACd,kBAAkB,OAAO,GAAG,UAAU,GAAG,MAAM,GAAG,MAAM;EACxD;CACF,CAAC,CAAC,KAAK,IAAI;AACb"}
1
+ {"version":3,"file":"iife.js","names":[],"sources":["../../src/core/iife.ts"],"sourcesContent":["/**\n * Shared CompiledSchema<T> IIFE generation.\n * Used by both CLI emitter and unplugin transform.\n */\n\nimport type { CompiledSchemaInfo } from \"./pipeline.js\";\n\n/**\n * Import statement required by generateIIFE output (references\n * __zodCompilerConfig). `core` is bound for $ZodAsyncError: superRefine and\n * custom callbacks may only reveal that they are async through the promise\n * they return, at which point zod's own synchronous parse raises.\n */\nexport const ZOD_CONFIG_IMPORT =\n 'import { config as __zodCompilerConfig, core as __zcCore, ZodRealError as __zcZodError } from \"zod\";';\n\n/**\n * File-level `__zcMsg` declaration (must appear once after ZOD_CONFIG_IMPORT):\n * the message an issue gets when nothing was baked into it at build time.\n *\n * Resolves zod's tail of `finalizeIssue` — `config.customError` then\n * `config.localeError` then \"Invalid input\" — and does it PER CALL, because the\n * config is mutable: `z.config({ localeError })` in an entry point runs after\n * the schema modules it imports, so a value snapshotted at module init misses\n * it. Reading a captured `localeError` alone also dropped `customError`\n * outright, silently ignoring the global map most i18n setups install.\n *\n * The head of zod's chain — the schema's own `error` option — is baked into the\n * issue at build time and short-circuits this. The one link that cannot be\n * reproduced is a per-CALL `ctx.error`, which would have to travel through\n * `safeParse`; that entry point sits at V8's inlining budget, where even an\n * unused extra parameter measured ~12% on every parse.\n *\n * Only ever called while building an error, never on a successful parse.\n */\nexport const ZOD_MSG_DECLARATION =\n 'function __zcUw(m){return typeof m===\"string\"?m:(m===undefined||m===null?undefined:m.message);}' +\n \"var __zcMsg=function(iss){var c=__zodCompilerConfig(),m;\" +\n \"if(c.customError){m=__zcUw(c.customError(iss));if(m!==undefined&&m!==null)return m;}\" +\n \"if(c.localeError){m=__zcUw(c.localeError(iss));if(m!==undefined&&m!==null)return m;}\" +\n 'return \"Invalid input\";};';\n\n/**\n * Shared failure-result for __zcFin / __zcFinD. Inline mode (CLI emitter)\n * declares it once per compiled file; lean mode (all unplugin bundlers) declares\n * it once per bundle in the plugin-materialized runtime module (module-local —\n * generated code only ever references __zcFin/__zcFinD, never __ZcFail).\n *\n * Why a prototype getter and not `{success:false, get error(){...}}`: an object\n * literal with an inline accessor forces V8 down its slow accessor-defining\n * allocation path — ~110ns per failure, measured — which dominates the entire\n * invalid-input cost whenever callers never read `.error`. Hosting `error` on\n * the prototype turns each failure into a plain field-only instantiation (~2ns,\n * ~13x), with the lazy-cache semantics intact. (Trade-off: `error` is a\n * prototype accessor, so it no longer shows up in `Object.keys(result)` / spread\n * / JSON.stringify of the result wrapper — `.success`/`.error`/`.data` access,\n * destructuring, and `in` are unaffected.)\n *\n * One class serves both finalizers, so the instances share one hidden class:\n * __zcFin passes pre-collected issues in `_e` (with `_f===null`); __zcFinD\n * passes the hosted slow-walk in `_f` plus the input in `_i`, and the getter\n * runs the walk on first `.error` read. The whole finalization — locale fill\n * (__zcMsg applied ONLY when an issue carries no message, never overwriting a\n * baked-in custom/fallback message), input strip, and ZodError construction\n * (zod v4 JSON.stringifies every issue into `message` and captures a stack\n * trace) — stays deferred inside the cached accessor exactly as before, since\n * the issues array is observable solely through `.error`.\n *\n * `input` is `delete`d, not assigned `undefined`. Key PRESENCE is observable —\n * `\"input\" in issue`, `Object.keys(issue)`, object spread, `toStrictEqual`\n * against a zod issue — and zod's `util.finalizeIssue` does `delete full.input`\n * whenever `reportInput` is off, so assignment left every compiled issue one\n * enumerable key wider than zod's. The delete's dictionary-mode transition is\n * affordable precisely BECAUSE of the deferral above: it runs only after a\n * caller asks for `.error` on a failed parse, and is memoised in `_c`. Neither\n * a successful parse nor a `.success`/`.is()` check on a rejected one reaches\n * it — measured, the two are unchanged, while the `.error` read itself goes\n * ~3.95us -> ~4.19us per failure, i.e. ~6% of a path whose cost is already\n * dominated by the ZodError construction on the next line (stack capture plus a\n * JSON.stringify of every issue).\n */\nexport const FAIL_CLASS_DECL =\n \"function __ZcFail(e,f,i){this.success=false;this._e=e;this._f=f;this._i=i;this._c=undefined;}\" +\n 'Object.defineProperty(__ZcFail.prototype,\"error\",{configurable:true,get:function(){' +\n \"if(this._c)return this._c;\" +\n \"var e=this._f!==null?this._f(this._i):this._e;\" +\n 'for(var i=0;i<e.length;i++){if(e[i].message===undefined&&typeof __zcMsg===\"function\")e[i].message=__zcMsg(e[i]);delete e[i].input;delete e[i].continue;}' +\n \"return this._c=new __zcZodError(e);}});\";\n\n/** Eager finalizer (mutation / partial-fast-path schemas): issues already\n * collected in `e`; success short-circuits to a plain result literal. */\nexport const FIN_DECL =\n \"function __zcFin(e,d){if(!e.length)return{success:true,data:d};return new __ZcFail(e,null,null);}\";\n\n/**\n * Deferred-collection finalizer for Fast-Path-eligible schemas. When the\n * fast check fails, the ENTIRE slow path (the issue-collecting re-walk) is\n * pushed into the cached `.error` accessor instead of running eagerly:\n * fast-eligible schemas never mutate, so the walk's only output is the\n * issues array, which is observable solely through `.error` — one step\n * further along the same lazy boundary `__zcFin` already established (locale\n * fill, input strip, ZodError construction). A failed safeParse whose\n * `.error` is never read costs the fast check alone.\n *\n * Takes the schema's HOSTED slow-walk function plus the input — NOT a\n * per-call closure: `__zcFinD(__sw_N, input)` allocates only the result\n * object, where `__zcFinD(function(){...})` paid a closure environment and\n * function object per failure. Hosting the walk also shrinks safeParse to\n * two statements, within V8's inlining budget (the success-path result\n * literal becomes escape-analyzable at monomorphic call sites).\n *\n * The walk re-reads `input` at `.error`-read time; a caller that mutates\n * the input between safeParse and reading `.error` sees issues for the\n * mutated value (zod materializes at parse time). Same caveat class as the\n * documented __zcFin deferral.\n */\nexport const FIN_DEFERRED_DECL = \"function __zcFinD(f,inp){return new __ZcFail(null,f,inp);}\";\n\n/**\n * Compact-mode failure class — a lazy failure that delegates error reporting to\n * the ORIGINAL Zod schema's `safeParse`. Used by `output: \"compact\"`, where the\n * compiled slow walk is dropped entirely: a mutation-free schema's fast check\n * is the only generated validation, and on a fast-check failure the cold error\n * path is produced by the retained Zod schema itself (`zod` is the source of\n * truth, so the issues are byte-identical — no second validation engine).\n *\n * `_z` is the schema's PRISTINE bound safeParse (`__rf[N].safeParse.bind(...)`,\n * captured pre-`__zcMkv` by emitRfDelegate — see context.ts — so it is zod's\n * own implementation, never the compiled delegate, avoiding infinite\n * recursion). The zod parse is deferred until `.error` is read and cached, so\n * the common `safeParse(x).success`/`.is(x)` checks on invalid input cost only\n * the fast check (zod never runs) — the same deferral boundary `__zcFinD`\n * establishes for the compiled slow walk. Sound because compact mode is gated\n * on a TOTAL fast path: `fc(input) === false` ⟹ zod rejects, so `success:false`\n * holds without consulting zod.\n *\n * The getter returns zod's OWN ZodError verbatim (no locale fill / input strip /\n * re-wrap — zod already finalized it), so a delegated failure is exactly what\n * the unaltered schema would have produced.\n */\nexport const FAILZ_CLASS_DECL =\n \"function __ZcFailZ(z,i){this.success=false;this._z=z;this._i=i;this._c=undefined;}\" +\n 'Object.defineProperty(__ZcFailZ.prototype,\"error\",{configurable:true,get:function(){' +\n \"return this._c||(this._c=this._z(this._i).error);}});\";\n\n/** Compact-mode finalizer: wrap a pristine bound safeParse + input into a lazy delegated failure. */\nexport const FINZ_DECL = \"function __zcFinZ(z,i){return new __ZcFailZ(z,i);}\";\n\n/**\n * Validator factory. Inline mode (CLI emitter) declares it once per compiled\n * file; lean mode (all unplugin bundlers) exports it once per bundle from the\n * plugin-materialized runtime module — generated code never imports it from\n * the zod-compiler package itself, so zod-compiler stays a devDependency and\n * the helper set is always version-locked to the codegen that calls it.\n * Wraps a safeParse function into the CompiledSchema interface.\n *\n * IDENTITY-PRESERVING: with zodCompat (schema != null) the compiled\n * parse/safeParse/parseAsync/safeParseAsync are installed as OWN properties\n * on the original schema object, which is returned as-is. zod v4 keys\n * several APIs on object identity — toJSONSchema's ctx.seen registers the\n * object it is handed while each processor closure captures the original\n * inst (a wrapper crashes `optionalProcessor` with \"Cannot set properties\n * of undefined (setting 'ref')\" the moment a compiled schema is composed\n * into another schema), and globalRegistry/.meta() is a WeakMap keyed by\n * the schema instance (a wrapper silently loses OpenAPI titles/ids). An\n * Object.create wrapper breaks both; mutating the original breaks neither\n * (zod's internal parsing flows through _zod.run, never the public\n * methods, and derived schemas — .optional(), .extend() — are fresh\n * instances that fall back to plain zod). schema=null (zodCompat: false)\n * still produces a plain method-bag object.\n *\n * fc is the schema's hosted fast-check boolean function (null when no Fast\n * Path exists). parse()/parseAsync() try it first and return the input\n * directly on success: fc is small enough for V8 to inline, so the hot parse\n * path runs with zero allocations — calling fn would allocate an intermediate\n * SafeParseResult that escape analysis cannot remove (fn never inlines).\n * Fast-path-eligible schemas never mutate, so fc(input) ⟹ data === input.\n *\n * is is the TOTAL fast-check predicate (fc when the fast path is total, else\n * null). Installed as `.is()` — a zero-allocation boolean type guard. When\n * null (partial fast path or none) `.is()` derives from fn(input).success: a\n * partial fc can pass-through valid input but its `false` does not imply\n * rejection (a default/catch may still succeed), so it would be unsound as a\n * standalone guard.\n *\n * parseAsync/safeParseAsync wrap the SYNC validator, which is right for every\n * schema the compiler can reproduce — none of them are async. It is wrong for\n * the ones it cannot: an `async` refinement or a `z.promise()` extracts to a\n * Zod delegate, and delegating means calling Zod's SYNCHRONOUS safeParse, which\n * raises `$ZodAsyncError` by design. Wrapping that gave the compiled schema an\n * async pair that rejected with `$ZodAsyncError` for EVERY input — including\n * valid ones — where Zod resolves normally, so `await UserSchema.parseAsync(x)`\n * stopped working the moment any part of the schema went async.\n *\n * So both are guarded: a synchronous throw hands off to the schema's ORIGINAL\n * async method, captured before these are installed — the same escape hatch\n * `~standard` already uses for its throw path, and for the same reason (the\n * compiled validator has no async mode to offer, and Zod's is exact). It also\n * fixes the smaller wart that a throwing `fn` made `parseAsync` throw\n * SYNCHRONOUSLY rather than return a rejected promise. With `zodCompat: false`\n * there is no schema to delegate to and the throw propagates as before.\n *\n * `~standard` is REPLACED, not merely preserved. Zod builds it lazily as\n * `validate: (v) => safeParse(inst, v)` — the core FUNCTION, which goes straight\n * to `inst._zod.run`. It never reads the schema's own `safeParse` property, so\n * installing the compiled one leaves this route entirely uncompiled: measured\n * 271.7 ns against the compiled 26.6 ns on the same schema, i.e. Standard Schema\n * consumers (tRPC, Hono, TanStack) were getting plain Zod.\n *\n * Zod's own validate is captured first and kept as the throw path: it catches a\n * synchronous throw and retries through `safeParseAsync`, which is how an async\n * refinement resolves and how a throwing check surfaces as a rejected promise\n * rather than a synchronous throw. The compiled validator cannot reproduce that\n * (async schemas delegate to Zod anyway), so deferring to the original is both\n * simpler and exact.\n *\n * Installed with defineProperty rather than assignment: Zod's lazy setter\n * redefines the slot as non-writable, so a second `__zcMkv` on the same schema\n * object — two exports aliasing one schema — would throw under ESM strict mode.\n */\nexport const MK_VALIDATOR_DECL =\n \"function __zcMkv(fn,schema,fc,is){var w=schema||{};var zpa=w.parseAsync,zspa=w.safeParseAsync;w.parse=fc?function(input){if(fc(input))return input;var r=fn(input);if(r.success)return r.data;throw r.error;}:function(input){var r=fn(input);if(r.success)return r.data;throw r.error;};w.safeParse=fn;w.safeParseAsync=function(input){try{return Promise.resolve(fn(input));}catch(e){if(zspa)return zspa(input);throw e;}};w.parseAsync=fc?function(input){try{if(fc(input))return Promise.resolve(input);var r=fn(input);if(r.success)return Promise.resolve(r.data);return Promise.reject(r.error);}catch(e){if(zpa)return zpa(input);throw e;}}:function(input){try{var r=fn(input);if(r.success)return Promise.resolve(r.data);return Promise.reject(r.error);}catch(e){if(zpa)return zpa(input);throw e;}};w.is=is||function(input){return fn(input).success;};\" +\n 'var s=w[\"~standard\"],zv=s&&s.validate;' +\n 'Object.defineProperty(w,\"~standard\",{configurable:true,value:{version:1,vendor:(s&&s.vendor)||\"zod\",validate:function(input){var r;try{if(fc&&fc(input))return{value:input};r=fn(input);}catch(e){if(zv)return zv(input);throw e;}return r.success?{value:r.data}:{issues:r.error.issues};}}});' +\n \"return w;}\";\n\nfunction extractFunctionName(functionDef: string): string {\n const match = /^function\\s+(\\w+)\\s*\\(/.exec(functionDef);\n if (!match?.[1]) {\n throw new Error(\"Cannot extract function name from generated code\");\n }\n return match[1];\n}\n\n/**\n * Generate a `/* @__PURE__ * /` IIFE wrapping a compiled validator.\n *\n * @param schemaExpr - Expression resolving to the original Zod schema\n * (e.g. `\"UserSchema\"` in unplugin, `\"(__src_X as any).schema\"` in CLI)\n * @param schema\n * @param options\n */\nexport function generateIIFE(\n schemaExpr: string,\n schema: CompiledSchemaInfo,\n options?: { zodCompat?: boolean | undefined },\n): string {\n const { codegenResult, refEntries } = schema;\n const fnName = extractFunctionName(codegenResult.functionDef);\n const zodCompat = options?.zodCompat !== false;\n const schemaArg = zodCompat ? schemaExpr : \"null\";\n const fcArg = codegenResult.fastFnName ?? \"null\";\n // `.is()` gets the fast-check directly only when it is a total predicate;\n // partial/none falls back to safeParse().success inside __zcMkv. A rebuilding\n // schema has no by-reference `fc` but still names its predicate separately.\n const isArg = codegenResult.isFnName ?? (codegenResult.fastTotal ? fcArg : \"null\");\n\n return [\n \"/* @__PURE__ */ (() => {\",\n ...(refEntries.length > 0\n ? [`var __rf=[${refEntries.map((fb) => `${schemaExpr}${fb.accessPath}`).join(\",\")}];`]\n : []),\n ...codegenResult.code\n .split(\"\\n\")\n .filter((l) => l.trim() !== \"\" && l.trim() !== \"/* zod-compiler */\"),\n codegenResult.functionDef,\n `return __zcMkv(${fnName},${schemaArg},${fcArg},${isArg});`,\n \"})()\",\n ].join(\"\\n\");\n}\n"],"mappings":";;;;;;;AAaA,MAAa,oBACX;;;;;;;;;;;;;;;;;;;;AAqBF,MAAa,sBACX;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CF,MAAa,kBACX;;;AASF,MAAa,WACX;;;;;;;;;;;;;;;;;;;;;;;AAwBF,MAAa,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;AAwBjC,MAAa,mBACX;;AAKF,MAAa,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0EzB,MAAa,oBACX;AAKF,SAAS,oBAAoB,aAA6B;CACxD,MAAM,QAAQ,yBAAyB,KAAK,WAAW;CACvD,IAAI,CAAC,QAAQ,IACX,MAAM,IAAI,MAAM,kDAAkD;CAEpE,OAAO,MAAM;AACf;;;;;;;;;AAUA,SAAgB,aACd,YACA,QACA,SACQ;CACR,MAAM,EAAE,eAAe,eAAe;CACtC,MAAM,SAAS,oBAAoB,cAAc,WAAW;CAE5D,MAAM,YADY,SAAS,cAAc,QACX,aAAa;CAC3C,MAAM,QAAQ,cAAc,cAAc;CAI1C,MAAM,QAAQ,cAAc,aAAa,cAAc,YAAY,QAAQ;CAE3E,OAAO;EACL;EACA,GAAI,WAAW,SAAS,IACpB,CAAC,aAAa,WAAW,KAAK,OAAO,GAAG,aAAa,GAAG,YAAY,CAAC,CAAC,KAAK,GAAG,EAAE,GAAG,IACnF,CAAC;EACL,GAAG,cAAc,KACd,MAAM,IAAI,CAAC,CACX,QAAQ,MAAM,EAAE,KAAK,MAAM,MAAM,EAAE,KAAK,MAAM,oBAAoB;EACrE,cAAc;EACd,kBAAkB,OAAO,GAAG,UAAU,GAAG,MAAM,GAAG,MAAM;EACxD;CACF,CAAC,CAAC,KAAK,IAAI;AACb"}
@@ -325,6 +325,33 @@ interface TupleIR {
325
325
  type: "tuple";
326
326
  items: SchemaIR[];
327
327
  rest: SchemaIR | null;
328
+ /**
329
+ * Index where the omittable tail begins — zod's `optStart`, captured from the
330
+ * live schemas at extraction time:
331
+ *
332
+ * ```js
333
+ * const reversedIndex = [...items].reverse().findIndex((i) => i._zod.optin !== "optional");
334
+ * const optStart = reversedIndex === -1 ? 0 : items.length - reversedIndex;
335
+ * ```
336
+ *
337
+ * An item at or past this index is SKIPPED ENTIRELY when the input is shorter
338
+ * than the tuple — zod never runs its schema, so no default/prefault fires for
339
+ * it — and it also moves the under-length `too_small` threshold
340
+ * (`input.length < optStart - 1`).
341
+ *
342
+ * Read from `_zod.optin` rather than inferred from the item's IR type because
343
+ * "optional-in" is a property of the ZOD schema, not of the shape the compiler
344
+ * managed to compile: `z.exactOptional()`, `z.prefault()`, `.nonoptional()`
345
+ * and pipes all extract to an opaque `fallback` leaf, `z.undefined()` and
346
+ * `z.nullable(z.string().optional())` extract to nodes named nothing like
347
+ * "optional", and a union is optional-in when ANY option is. The IR-type
348
+ * inference this replaced recognised only `optional` and `default`, so every
349
+ * other shape lost its omittable tail — `z.tuple([z.exactOptional(z.string())])`
350
+ * rejected `[]` that zod accepts, `z.tuple([z.string().prefault("d")])` turned
351
+ * `[]` into `["d"]`, and `z.tuple([z.string(), z.undefined()])` answered a
352
+ * one-element input with a `too_small` where zod reports nothing.
353
+ */
354
+ optStart: number;
328
355
  }
329
356
  interface RecordIR {
330
357
  type: "record";
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","names":[],"sources":["../../src/core/types.ts"],"mappings":"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"}
1
+ {"version":3,"file":"types.d.ts","names":[],"sources":["../../src/core/types.ts"],"mappings":"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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zod-compiler",
3
- "version": "1.23.7",
3
+ "version": "1.23.8",
4
4
  "description": "Compile Zod schemas into zero-overhead validation functions",
5
5
  "keywords": [
6
6
  "aot",