zod-compiler 1.28.0 → 2.0.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 (97) hide show
  1. package/README.md +176 -148
  2. package/dist/core/codegen/build-path.d.ts +12 -1
  3. package/dist/core/codegen/build-path.d.ts.map +1 -1
  4. package/dist/core/codegen/build-path.js +102 -21
  5. package/dist/core/codegen/build-path.js.map +1 -1
  6. package/dist/core/codegen/context.d.ts +31 -16
  7. package/dist/core/codegen/context.d.ts.map +1 -1
  8. package/dist/core/codegen/context.js +43 -18
  9. package/dist/core/codegen/context.js.map +1 -1
  10. package/dist/core/codegen/emit-issue.d.ts +17 -20
  11. package/dist/core/codegen/emit-issue.d.ts.map +1 -1
  12. package/dist/core/codegen/emit-issue.js +13 -13
  13. package/dist/core/codegen/emit-issue.js.map +1 -1
  14. package/dist/core/codegen/index.d.ts.map +1 -1
  15. package/dist/core/codegen/index.js +9 -7
  16. package/dist/core/codegen/index.js.map +1 -1
  17. package/dist/core/codegen/issue-decls.d.ts +83 -7
  18. package/dist/core/codegen/issue-decls.d.ts.map +1 -1
  19. package/dist/core/codegen/issue-decls.js +93 -10
  20. package/dist/core/codegen/issue-decls.js.map +1 -1
  21. package/dist/core/codegen/schemas/array.js +1 -1
  22. package/dist/core/codegen/schemas/array.js.map +1 -1
  23. package/dist/core/codegen/schemas/bigint.d.ts.map +1 -1
  24. package/dist/core/codegen/schemas/bigint.js +15 -4
  25. package/dist/core/codegen/schemas/bigint.js.map +1 -1
  26. package/dist/core/codegen/schemas/catch.d.ts.map +1 -1
  27. package/dist/core/codegen/schemas/catch.js +3 -2
  28. package/dist/core/codegen/schemas/catch.js.map +1 -1
  29. package/dist/core/codegen/schemas/discriminated-union.d.ts +6 -2
  30. package/dist/core/codegen/schemas/discriminated-union.d.ts.map +1 -1
  31. package/dist/core/codegen/schemas/discriminated-union.js +16 -56
  32. package/dist/core/codegen/schemas/discriminated-union.js.map +1 -1
  33. package/dist/core/codegen/schemas/effect.d.ts.map +1 -1
  34. package/dist/core/codegen/schemas/effect.js +4 -2
  35. package/dist/core/codegen/schemas/effect.js.map +1 -1
  36. package/dist/core/codegen/schemas/file.js +2 -8
  37. package/dist/core/codegen/schemas/file.js.map +1 -1
  38. package/dist/core/codegen/schemas/number.js +4 -3
  39. package/dist/core/codegen/schemas/number.js.map +1 -1
  40. package/dist/core/codegen/schemas/object.d.ts +11 -1
  41. package/dist/core/codegen/schemas/object.d.ts.map +1 -1
  42. package/dist/core/codegen/schemas/object.js +58 -14
  43. package/dist/core/codegen/schemas/object.js.map +1 -1
  44. package/dist/core/codegen/schemas/readonly.d.ts.map +1 -1
  45. package/dist/core/codegen/schemas/readonly.js.map +1 -1
  46. package/dist/core/codegen/schemas/record.d.ts.map +1 -1
  47. package/dist/core/codegen/schemas/record.js +8 -3
  48. package/dist/core/codegen/schemas/record.js.map +1 -1
  49. package/dist/core/codegen/schemas/sizeable.d.ts +49 -3
  50. package/dist/core/codegen/schemas/sizeable.d.ts.map +1 -1
  51. package/dist/core/codegen/schemas/sizeable.js +101 -8
  52. package/dist/core/codegen/schemas/sizeable.js.map +1 -1
  53. package/dist/core/codegen/schemas/string-bool.d.ts +12 -1
  54. package/dist/core/codegen/schemas/string-bool.d.ts.map +1 -1
  55. package/dist/core/codegen/schemas/string-bool.js +19 -4
  56. package/dist/core/codegen/schemas/string-bool.js.map +1 -1
  57. package/dist/core/codegen/schemas/string.d.ts.map +1 -1
  58. package/dist/core/codegen/schemas/string.js +60 -26
  59. package/dist/core/codegen/schemas/string.js.map +1 -1
  60. package/dist/core/codegen/schemas/tuple.d.ts +14 -11
  61. package/dist/core/codegen/schemas/tuple.d.ts.map +1 -1
  62. package/dist/core/codegen/schemas/tuple.js +99 -49
  63. package/dist/core/codegen/schemas/tuple.js.map +1 -1
  64. package/dist/core/codegen/well-known-regex.d.ts +26 -1
  65. package/dist/core/codegen/well-known-regex.d.ts.map +1 -1
  66. package/dist/core/codegen/well-known-regex.js +31 -4
  67. package/dist/core/codegen/well-known-regex.js.map +1 -1
  68. package/dist/core/extract/checks.d.ts.map +1 -1
  69. package/dist/core/extract/checks.js +1 -0
  70. package/dist/core/extract/checks.js.map +1 -1
  71. package/dist/core/extract/extractors/intersection.js +21 -6
  72. package/dist/core/extract/extractors/intersection.js.map +1 -1
  73. package/dist/core/extract/extractors/object.d.ts.map +1 -1
  74. package/dist/core/extract/extractors/object.js +25 -9
  75. package/dist/core/extract/extractors/object.js.map +1 -1
  76. package/dist/core/extract/extractors/optional.d.ts.map +1 -1
  77. package/dist/core/extract/extractors/optional.js +1 -28
  78. package/dist/core/extract/extractors/optional.js.map +1 -1
  79. package/dist/core/extract/extractors/record.js +9 -3
  80. package/dist/core/extract/extractors/record.js.map +1 -1
  81. package/dist/core/extract/extractors/tuple.d.ts.map +1 -1
  82. package/dist/core/extract/extractors/tuple.js +16 -20
  83. package/dist/core/extract/extractors/tuple.js.map +1 -1
  84. package/dist/core/extract/types.d.ts +16 -8
  85. package/dist/core/extract/types.d.ts.map +1 -1
  86. package/dist/core/iife.d.ts +2 -1
  87. package/dist/core/iife.d.ts.map +1 -1
  88. package/dist/core/iife.js +2 -1
  89. package/dist/core/iife.js.map +1 -1
  90. package/dist/core/types.d.ts +70 -21
  91. package/dist/core/types.d.ts.map +1 -1
  92. package/dist/jit.d.ts.map +1 -1
  93. package/dist/jit.js +47 -12
  94. package/dist/jit.js.map +1 -1
  95. package/dist/runtime.d.ts +4 -1
  96. package/dist/runtime.js +14 -11
  97. package/package.json +2 -2
package/dist/jit.js CHANGED
@@ -25,6 +25,13 @@ import { ZodRealError, config, core } from "zod";
25
25
  * ones. Importing a module of 500 schemas therefore costs nothing, and a
26
26
  * serverless invocation touching three of them pays for three.
27
27
  *
28
+ * Zod itself keeps the parse methods on the PROTOTYPE (since 4.4): each is a
29
+ * getter that binds the method on first read and installs the bound copy as an
30
+ * own data property, so a fresh schema carries no own `parse` / `safeParse` at
31
+ * all, while one that has been read already does. `jit()` meets both shapes —
32
+ * it snapshots whatever the slots hold, fronts them with its own accessors, and
33
+ * hands back exactly what it found whenever it has to step aside.
34
+ *
28
35
  * Runtime code generation is not always permitted — a strict CSP without
29
36
  * `unsafe-eval`, some edge runtimes. Zod v4 has the same constraint (its object
30
37
  * fast-pass is itself a `new Function`) and already exposes the two switches
@@ -124,19 +131,24 @@ function jit(schema, options) {
124
131
  /**
125
132
  * Front every installed method with a compile-on-read accessor. `trigger`
126
133
  * materializes the schema, which normally replaces these accessors with the
127
- * compiled methods (or restores Zod's own). When that replacement does not take,
128
- * the getter falls back to the snapshot rather than re-reading the slot — see
129
- * the re-entrancy note in the body.
134
+ * compiled methods (or restores what Zod had). When that replacement does not
135
+ * take, the getter serves Zod's own method rather than re-reading the slot —
136
+ * see the re-entrancy note in the body.
130
137
  */
131
138
  function installAccessors(target, original, trigger, cancel) {
132
139
  for (const slot of SLOTS) {
133
140
  let reading = false;
141
+ let stranded;
142
+ const serveZod = () => {
143
+ stranded ??= { value: fromZod(target, original, slot) };
144
+ return stranded.value;
145
+ };
134
146
  const read = function() {
135
- if (reading) return fromSnapshot(target, original, slot);
147
+ if (reading) return serveZod();
136
148
  reading = true;
137
149
  try {
138
150
  trigger();
139
- if (stillFrontedBy(target, slot, read)) return fromSnapshot(target, original, slot);
151
+ if (stillFrontedBy(target, slot, read)) return serveZod();
140
152
  return target[slot];
141
153
  } finally {
142
154
  reading = false;
@@ -148,6 +160,10 @@ function installAccessors(target, original, trigger, cancel) {
148
160
  get: read,
149
161
  set(value) {
150
162
  cancel();
163
+ if (!stillFrontedBy(target, slot, read)) {
164
+ target[slot] = value;
165
+ return;
166
+ }
151
167
  Object.defineProperty(target, slot, {
152
168
  configurable: true,
153
169
  enumerable: original.get(slot)?.enumerable ?? false,
@@ -172,14 +188,29 @@ function stillFrontedBy(target, slot, getter) {
172
188
  }
173
189
  }
174
190
  /**
175
- * What Zod had in `slot`, taken from the snapshot made before installation.
176
- * `undefined` for `is`, which no plain Zod schema carries — the same thing every
177
- * other degradation path leaves there.
191
+ * Zod's own value for `slot`, bypassing the accessor that fronts it.
192
+ *
193
+ * A slot the snapshot holds is answered from the snapshot. One it does not hold
194
+ * lives on the prototype, where Zod's getter binds the method to its receiver
195
+ * and installs the bound copy as an own property — on a target that accepts
196
+ * the install, that also replaces the stranded accessor with the copy, which is
197
+ * the handover materialize() could not make. A target that refuses the install
198
+ * (frozen, or a wrapper that vetoes `defineProperty`) makes Zod's getter throw
199
+ * instead; there the read goes through a stand-in that inherits from the target,
200
+ * so the copy lands on the stand-in and the method reaches `_zod` through the
201
+ * chain. `undefined` for `is`, which no plain Zod schema carries — the same
202
+ * thing every other degradation path leaves there.
178
203
  */
179
- function fromSnapshot(target, original, slot) {
204
+ function fromZod(target, original, slot) {
180
205
  const descriptor = original.get(slot);
181
- if (descriptor === void 0) return void 0;
182
- return descriptor.get === void 0 ? descriptor.value : descriptor.get.call(target);
206
+ if (descriptor !== void 0) return descriptor.get === void 0 ? descriptor.value : descriptor.get.call(target);
207
+ const proto = Object.getPrototypeOf(target);
208
+ if (proto === null) return void 0;
209
+ try {
210
+ return Reflect.get(proto, slot, target);
211
+ } catch {
212
+ return Reflect.get(proto, slot, Object.create(target));
213
+ }
183
214
  }
184
215
  /**
185
216
  * Compile every Zod schema found among an object's own values — typically a
@@ -197,7 +228,11 @@ function fromSnapshot(target, original, slot) {
197
228
  function jitAll(schemas, options) {
198
229
  for (const value of Object.values(schemas)) if (isZodSchema(value)) jit(value, options);
199
230
  }
200
- /** Put Zod's own descriptors back, dropping the compile-on-read accessors. */
231
+ /**
232
+ * Put back what the snapshot holds, dropping the compile-on-read accessors: the
233
+ * own copy Zod (or the build plugin) had installed, or nothing at all, so the
234
+ * slot reads through to Zod's prototype getter again.
235
+ */
201
236
  function restore(target, original) {
202
237
  for (const slot of SLOTS) try {
203
238
  const descriptor = original.get(slot);
package/dist/jit.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"jit.js","names":["zodCore","zodConfig"],"sources":["../src/jit.ts"],"sourcesContent":["/**\n * Runtime compilation — the same extract → codegen pipeline the build plugin\n * runs, executed in-process and evaluated through `new Function`.\n *\n * The AOT paths (unplugin, CLI) need a build step to fire. Plenty of everyday\n * code has none: `tsx server.ts`, `node --experimental-strip-types`, a Jest\n * suite, a serverless handler bundled by someone else's toolchain, a library\n * that ships schemas to consumers. There `compile()` is a no-op and every parse\n * runs plain Zod. `jit()` closes that gap — one call, no build integration,\n * measured 3-25x on everyday schemas at ~0.1-0.2 ms of one-time compilation.\n *\n * Nothing here re-implements validation: {@link compileSchemas} and\n * {@link generateIIFE} are the exact modules the plugin and CLI use, so the\n * generated validator, its Zod parity and its performance are identical to what\n * a build would have emitted. The only difference is *when* the code is\n * produced.\n *\n * Compilation is LAZY by default: `jit()` installs accessors that compile on\n * the first read of a parse method and replace themselves with the compiled\n * ones. Importing a module of 500 schemas therefore costs nothing, and a\n * serverless invocation touching three of them pays for three.\n *\n * Runtime code generation is not always permitted — a strict CSP without\n * `unsafe-eval`, some edge runtimes. Zod v4 has the same constraint (its object\n * fast-pass is itself a `new Function`) and already exposes the two switches\n * for it: the `core.util.allowsEval` probe and `z.config({ jitless: true })`.\n * `jit()` honours both and degrades to plain Zod, so one setting governs both\n * compilers. Those targets are where the build plugin belongs anyway — it emits\n * the same validator with no runtime evaluation at all.\n */\n\nimport { config as zodConfig, core as zodCore, ZodRealError, type output, type ZodType } from \"zod\";\nimport {\n FAIL_CLASS_DECL,\n FAILZ_CLASS_DECL,\n FIN_DECL,\n FIN_DEFERRED_DECL,\n FINZ_DECL,\n generateIIFE,\n MK_VALIDATOR_DECL,\n ZOD_MSG_DECLARATION,\n} from \"./core/iife.js\";\nimport { compileSchemas } from \"./core/pipeline.js\";\nimport type { CompiledSchema } from \"./core/types.js\";\nimport { isZodSchema } from \"./is-zod-schema.js\";\n\n/**\n * The declarations `ZOD_CONFIG_IMPORT` supplies to an emitted module, minus the\n * import itself — `zod`'s three bindings arrive as parameters instead, so the\n * evaluated code has no module scope to resolve. Byte-for-byte the same helper\n * source the CLI emitter writes into a `.compiled.ts`, so a JIT validator and\n * an AOT one share their entire runtime layer.\n */\nconst RUNTIME_PRELUDE = [\n ZOD_MSG_DECLARATION,\n FAIL_CLASS_DECL,\n MK_VALIDATOR_DECL,\n FIN_DECL,\n FIN_DEFERRED_DECL,\n FAILZ_CLASS_DECL,\n FINZ_DECL,\n].join(\"\\n\");\n\n/**\n * Methods `__zcMkv` installs. Each is fronted by a compile-on-read accessor\n * until the schema materializes.\n *\n * `~standard` earns its place: Zod builds it as a closure over `_zod.run`, not\n * over the schema's `safeParse` property, so a Standard Schema consumer (tRPC,\n * Hono, TanStack Form) that never touches `safeParse` would otherwise keep\n * running plain Zod forever behind a \"compiled\" schema.\n */\nconst SLOTS = [\"parse\", \"safeParse\", \"parseAsync\", \"safeParseAsync\", \"is\", \"~standard\"] as const;\n\n/** Schemas already handed to `jit()`, so a second call is a no-op rather than a recompile. */\nconst seen = new WeakSet<object>();\n\nexport interface JitOptions {\n /**\n * Compile immediately instead of on first use. Costs ~0.1-0.2 ms per schema\n * at import time; useful for a long-lived server that would rather pay during\n * startup than on the first request, or to surface a compilation failure\n * eagerly. Default `false`.\n */\n eager?: boolean | undefined;\n /** Use compact codegen and delegate cold error production to Zod. @default \"schema\" */\n output?: \"schema\" | \"compact\" | undefined;\n}\n\n/**\n * Compile `schema` in-process and install the compiled `parse` / `safeParse` /\n * `parseAsync` / `safeParseAsync` / `is` / `~standard` on it.\n *\n * Returns the SAME object — identity-preserving exactly as the build plugin is,\n * so `.shape`, `_zod`, `instanceof`, `z.toJSONSchema()`, `.meta()` and\n * composition into a larger schema all keep working, and every existing\n * reference to the schema picks the compiled methods up.\n *\n * ```ts\n * import { z } from \"zod\";\n * import { jit } from \"zod-compiler/jit\";\n *\n * export const UserSchema = jit(z.object({ name: z.string(), email: z.email() }));\n * UserSchema.safeParse(input); // compiled on this first call\n * ```\n *\n * Schemas the compiler cannot reproduce fall back to Zod per sub-schema, the\n * same way they do at build time; a schema that cannot be compiled at all is\n * left as plain Zod.\n */\nexport function jit<T extends ZodType>(\n schema: T,\n options?: JitOptions,\n): T & CompiledSchema<output<T>> {\n const target = schema as unknown as Record<string, unknown>;\n if (seen.has(target)) return schema as T & CompiledSchema<output<T>>;\n seen.add(target);\n\n if (options?.eager === true) {\n materialize(schema, options);\n return schema as T & CompiledSchema<output<T>>;\n }\n\n // Snapshot Zod's own descriptors first: materialize() restores them before\n // handing the object to `__zcMkv`, so the generated code sees a pristine\n // schema — it captures the original `parseAsync` / `safeParseAsync` as its\n // throw paths, and capturing a stub there would loop back into itself.\n const original = new Map<string, PropertyDescriptor | undefined>();\n try {\n for (const slot of SLOTS) {\n original.set(slot, Object.getOwnPropertyDescriptor(target, slot));\n }\n } catch {\n // The target answers a descriptor query with a throw — an exotic wrapper,\n // not anything Zod built. Without a snapshot there is nothing to roll back\n // to, so install nothing and hand back the schema exactly as it came.\n return schema as T & CompiledSchema<output<T>>;\n }\n\n // Installing the accessors is the step most likely to throw rather than\n // degrade: a slot locked non-configurable (a future Zod, another wrapper) makes\n // defineProperty raise, and `jit()` is called at module scope — so an\n // unhandled throw here takes down the importing app at boot. Roll back to\n // whatever Zod had and leave the schema alone instead.\n let pending = true;\n try {\n installAccessors(\n target,\n original,\n () => {\n if (!pending) return;\n pending = false;\n restore(target, original);\n materialize(schema, options);\n },\n () => {\n if (!pending) return;\n pending = false;\n // Restore EVERY slot, not just the one being written. A left-behind\n // accessor whose trigger has been cancelled would read `target[slot]`\n // and re-enter itself — unbounded recursion, which is what a later read\n // of an untouched slot (`~standard`, from a Standard Schema consumer)\n // would otherwise hit.\n //\n // Reached only when something WRITES a slot before anything reads one: a\n // test double, another wrapper, or an AOT `safeParse` assigned directly.\n // The build plugin's own `__zcMkv` does not land here — its first\n // statement READS `parseAsync`/`safeParseAsync` to capture their\n // originals, so it triggers materialization and then overwrites the\n // compiled-by-jit methods with the compiled-by-plugin ones.\n restore(target, original);\n },\n );\n } catch {\n pending = false;\n restore(target, original);\n }\n\n return schema as T & CompiledSchema<output<T>>;\n}\n\n/**\n * Front every installed method with a compile-on-read accessor. `trigger`\n * materializes the schema, which normally replaces these accessors with the\n * compiled methods (or restores Zod's own). When that replacement does not take,\n * the getter falls back to the snapshot rather than re-reading the slot — see\n * the re-entrancy note in the body.\n */\nfunction installAccessors(\n target: Record<string, unknown>,\n original: ReadonlyMap<string, PropertyDescriptor | undefined>,\n trigger: () => void,\n cancel: () => void,\n): void {\n for (const slot of SLOTS) {\n // Re-entrancy is settled structurally rather than by inspection. Reading the\n // slot again is how this getter normally hands over — to the compiled method\n // materialize() installed, or to Zod's own that restore() put back — but the\n // handover can fail to take: a target frozen after `jit()` refuses both, and\n // a second copy of this module in the graph leaves ITS accessor on the slot,\n // so the two bounce reads between them. `trigger()` is spent by then, so\n // either way the read recurses until the stack blows. While a read is already\n // in flight, serve Zod's own method from the snapshot: a schema that cannot\n // be compiled still parses.\n let reading = false;\n const read = function (): unknown {\n if (reading) return fromSnapshot(target, original, slot);\n reading = true;\n try {\n trigger();\n if (stillFrontedBy(target, slot, read)) return fromSnapshot(target, original, slot);\n return target[slot];\n } finally {\n reading = false;\n }\n };\n Object.defineProperty(target, slot, {\n configurable: true,\n // Preserve Zod's own visibility: parse/safeParse/... are enumerable own\n // properties, `~standard` is not. `is` does not exist on a Zod schema, so\n // it follows the non-enumerable convention `compile()` already uses.\n enumerable: original.get(slot)?.enumerable ?? false,\n get: read,\n set(value: unknown) {\n // Someone overwrote a method before first use (a test double, another\n // wrapper). Their value wins, and compilation is cancelled outright —\n // materializing later would restore Zod's descriptors over it.\n cancel();\n Object.defineProperty(target, slot, {\n configurable: true,\n enumerable: original.get(slot)?.enumerable ?? false,\n value,\n writable: true,\n });\n },\n });\n }\n}\n\n/**\n * Is `slot` still fronted by this very accessor — i.e. did the replacement that\n * `trigger()` was supposed to perform not take? A target that will not answer\n * the question is assumed to still hold it, since reading the slot to find out\n * is the recursion being avoided.\n */\nfunction stillFrontedBy(\n target: Record<string, unknown>,\n slot: string,\n getter: () => unknown,\n): boolean {\n try {\n return Object.getOwnPropertyDescriptor(target, slot)?.get === getter;\n } catch {\n return true;\n }\n}\n\n/**\n * What Zod had in `slot`, taken from the snapshot made before installation.\n * `undefined` for `is`, which no plain Zod schema carries — the same thing every\n * other degradation path leaves there.\n */\nfunction fromSnapshot(\n target: Record<string, unknown>,\n original: ReadonlyMap<string, PropertyDescriptor | undefined>,\n slot: string,\n): unknown {\n const descriptor = original.get(slot);\n if (descriptor === undefined) return undefined;\n // `~standard` is a lazy getter on a Zod schema, so invoke it rather than\n // reading a `value` it does not have.\n return descriptor.get === undefined ? descriptor.value : descriptor.get.call(target);\n}\n\n/**\n * Compile every Zod schema found among an object's own values — typically a\n * module namespace, so a whole schema file opts in with one call:\n *\n * ```ts\n * import * as schemas from \"./schemas.js\";\n * jitAll(schemas);\n * ```\n *\n * The namespace object itself is never written to (a module namespace is\n * read-only); `jit()` mutates the schema objects it holds, which is what every\n * importer of that module already references.\n */\nexport function jitAll(schemas: object, options?: JitOptions): void {\n for (const value of Object.values(schemas)) {\n if (isZodSchema(value)) jit(value, options);\n }\n}\n\n/** Put Zod's own descriptors back, dropping the compile-on-read accessors. */\nfunction restore(\n target: Record<string, unknown>,\n original: ReadonlyMap<string, PropertyDescriptor | undefined>,\n): void {\n for (const slot of SLOTS) {\n // Per slot, because this also runs as the rollback for a failed install: a\n // target that refuses one slot must not cost the others their restoration.\n // A slot left fronted by its accessor still reads correctly — the getter\n // serves Zod's own method from the snapshot — but it keeps a redundant\n // indirection, so restoring what can be restored is worth the try/catch.\n try {\n const descriptor = original.get(slot);\n if (descriptor === undefined) delete target[slot];\n else Object.defineProperty(target, slot, descriptor);\n } catch {\n // Nothing further to try for this slot.\n }\n }\n}\n\n/**\n * Whether runtime code generation is permitted here. Read per call, never\n * snapshotted: `z.config({ jitless: true })` runs in an entry point, after the\n * schema modules it imports have already been evaluated.\n */\nfunction codegenAllowed(): boolean {\n return zodCore.globalConfig.jitless !== true && zodCore.util.allowsEval.value;\n}\n\n/**\n * Run the pipeline and let the generated IIFE install its methods on `schema`.\n * Swallows failure: a schema that cannot be compiled keeps Zod's own methods,\n * which the caller already has, so there is nothing to report and nothing to\n * break.\n */\nfunction materialize(schema: unknown, options?: JitOptions): void {\n if (!codegenAllowed()) return;\n try {\n buildValidator(schema, options);\n } catch {\n // Left as plain Zod. Deliberately silent: `jit()` is an optimization, and a\n // schema using a construct the compiler declines is a supported outcome,\n // not an error.\n }\n}\n\n/**\n * Generate the validator and evaluate it, reproducing the module a\n * `.compiled.ts` would have been: helper preamble, the file-level shared block,\n * then the `__zcMkv` IIFE whose `__rf[]` bases and install target are the live\n * schema object passed in as `__schema`.\n */\nfunction buildValidator(schema: unknown, options?: JitOptions): void {\n const { schemas, shared } = compileSchemas([{ exportName: \"jit\", schema }], {\n compact: options?.output === \"compact\",\n mode: \"inline\",\n });\n const compiled = schemas[0];\n if (compiled === undefined) throw new Error(\"zod-compiler: schema produced no validator\");\n\n const body = [RUNTIME_PRELUDE, shared.code, `return ${generateIIFE(\"__schema\", compiled)};`].join(\n \"\\n\",\n );\n\n // The three bindings ZOD_CONFIG_IMPORT would have imported, passed in so the\n // evaluated code needs no module resolution of its own.\n // oxlint-disable-next-line no-new-func -- generating the validator IS the feature\n const factory = new Function(\n \"__zodCompilerConfig\",\n \"__zcCore\",\n \"__zcZodError\",\n \"__schema\",\n body,\n ) as (\n zodConfigFn: typeof zodConfig,\n zodCoreNs: typeof zodCore,\n zodErrorCtor: typeof ZodRealError,\n target: unknown,\n ) => unknown;\n\n factory(zodConfig, zodCore, ZodRealError, schema);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqDA,MAAM,kBAAkB;CACtB;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC,CAAC,KAAK,IAAI;;;;;;;;;;AAWX,MAAM,QAAQ;CAAC;CAAS;CAAa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,GAAW,MAAM,IAAI,MAAM,4CAA4C;CAExF,MAAM,OAAO;EAAC;EAAiB,OAAO;EAAM,UAAU,aAAa,YAAY,QAAQ,EAAE;CAAE,CAAC,CAAC,KAC3F,IACF;CAkBA,IAboB,SAClB,uBACA,YACA,gBACA,YACA,IAQI,CAAC,CAACC,QAAWD,MAAS,cAAc,MAAM;AAClD"}
1
+ {"version":3,"file":"jit.js","names":["zodCore","zodConfig"],"sources":["../src/jit.ts"],"sourcesContent":["/**\n * Runtime compilation — the same extract → codegen pipeline the build plugin\n * runs, executed in-process and evaluated through `new Function`.\n *\n * The AOT paths (unplugin, CLI) need a build step to fire. Plenty of everyday\n * code has none: `tsx server.ts`, `node --experimental-strip-types`, a Jest\n * suite, a serverless handler bundled by someone else's toolchain, a library\n * that ships schemas to consumers. There `compile()` is a no-op and every parse\n * runs plain Zod. `jit()` closes that gap — one call, no build integration,\n * measured 3-25x on everyday schemas at ~0.1-0.2 ms of one-time compilation.\n *\n * Nothing here re-implements validation: {@link compileSchemas} and\n * {@link generateIIFE} are the exact modules the plugin and CLI use, so the\n * generated validator, its Zod parity and its performance are identical to what\n * a build would have emitted. The only difference is *when* the code is\n * produced.\n *\n * Compilation is LAZY by default: `jit()` installs accessors that compile on\n * the first read of a parse method and replace themselves with the compiled\n * ones. Importing a module of 500 schemas therefore costs nothing, and a\n * serverless invocation touching three of them pays for three.\n *\n * Zod itself keeps the parse methods on the PROTOTYPE (since 4.4): each is a\n * getter that binds the method on first read and installs the bound copy as an\n * own data property, so a fresh schema carries no own `parse` / `safeParse` at\n * all, while one that has been read already does. `jit()` meets both shapes —\n * it snapshots whatever the slots hold, fronts them with its own accessors, and\n * hands back exactly what it found whenever it has to step aside.\n *\n * Runtime code generation is not always permitted — a strict CSP without\n * `unsafe-eval`, some edge runtimes. Zod v4 has the same constraint (its object\n * fast-pass is itself a `new Function`) and already exposes the two switches\n * for it: the `core.util.allowsEval` probe and `z.config({ jitless: true })`.\n * `jit()` honours both and degrades to plain Zod, so one setting governs both\n * compilers. Those targets are where the build plugin belongs anyway — it emits\n * the same validator with no runtime evaluation at all.\n */\n\nimport { config as zodConfig, core as zodCore, ZodRealError, type output, type ZodType } from \"zod\";\nimport {\n FAIL_CLASS_DECL,\n FAILZ_CLASS_DECL,\n FIN_DECL,\n FIN_DEFERRED_DECL,\n FINZ_DECL,\n generateIIFE,\n MK_VALIDATOR_DECL,\n ZOD_MSG_DECLARATION,\n} from \"./core/iife.js\";\nimport { compileSchemas } from \"./core/pipeline.js\";\nimport type { CompiledSchema } from \"./core/types.js\";\nimport { isZodSchema } from \"./is-zod-schema.js\";\n\n/**\n * The declarations `ZOD_CONFIG_IMPORT` supplies to an emitted module, minus the\n * import itself — `zod`'s three bindings arrive as parameters instead, so the\n * evaluated code has no module scope to resolve. Byte-for-byte the same helper\n * source the CLI emitter writes into a `.compiled.ts`, so a JIT validator and\n * an AOT one share their entire runtime layer.\n */\nconst RUNTIME_PRELUDE = [\n ZOD_MSG_DECLARATION,\n FAIL_CLASS_DECL,\n MK_VALIDATOR_DECL,\n FIN_DECL,\n FIN_DEFERRED_DECL,\n FAILZ_CLASS_DECL,\n FINZ_DECL,\n].join(\"\\n\");\n\n/**\n * Methods `__zcMkv` installs. Each is fronted by a compile-on-read accessor\n * until the schema materializes.\n *\n * `~standard` earns its place: Zod builds it as a closure over `_zod.run`, not\n * over the schema's `safeParse` property, so a Standard Schema consumer (tRPC,\n * Hono, TanStack Form) that never touches `safeParse` would otherwise keep\n * running plain Zod forever behind a \"compiled\" schema.\n */\nconst SLOTS = [\"parse\", \"safeParse\", \"parseAsync\", \"safeParseAsync\", \"is\", \"~standard\"] as const;\n\n/** Schemas already handed to `jit()`, so a second call is a no-op rather than a recompile. */\nconst seen = new WeakSet<object>();\n\nexport interface JitOptions {\n /**\n * Compile immediately instead of on first use. Costs ~0.1-0.2 ms per schema\n * at import time; useful for a long-lived server that would rather pay during\n * startup than on the first request, or to surface a compilation failure\n * eagerly. Default `false`.\n */\n eager?: boolean | undefined;\n /** Use compact codegen and delegate cold error production to Zod. @default \"schema\" */\n output?: \"schema\" | \"compact\" | undefined;\n}\n\n/**\n * Compile `schema` in-process and install the compiled `parse` / `safeParse` /\n * `parseAsync` / `safeParseAsync` / `is` / `~standard` on it.\n *\n * Returns the SAME object — identity-preserving exactly as the build plugin is,\n * so `.shape`, `_zod`, `instanceof`, `z.toJSONSchema()`, `.meta()` and\n * composition into a larger schema all keep working, and every existing\n * reference to the schema picks the compiled methods up.\n *\n * ```ts\n * import { z } from \"zod\";\n * import { jit } from \"zod-compiler/jit\";\n *\n * export const UserSchema = jit(z.object({ name: z.string(), email: z.email() }));\n * UserSchema.safeParse(input); // compiled on this first call\n * ```\n *\n * Schemas the compiler cannot reproduce fall back to Zod per sub-schema, the\n * same way they do at build time; a schema that cannot be compiled at all is\n * left as plain Zod.\n */\nexport function jit<T extends ZodType>(\n schema: T,\n options?: JitOptions,\n): T & CompiledSchema<output<T>> {\n const target = schema as unknown as Record<string, unknown>;\n if (seen.has(target)) return schema as T & CompiledSchema<output<T>>;\n seen.add(target);\n\n if (options?.eager === true) {\n materialize(schema, options);\n return schema as T & CompiledSchema<output<T>>;\n }\n\n // Snapshot what each slot holds before anything is installed: materialize()\n // restores it before handing the object to `__zcMkv`, so the generated code\n // sees a pristine schema — it captures the original `parseAsync` /\n // `safeParseAsync` as its throw paths, and capturing a stub there would loop\n // back into itself. An untouched schema holds NOTHING here: Zod keeps the\n // methods on the prototype and only installs a bound own copy on first read,\n // so `undefined` is the common entry and means \"back to the prototype\". A\n // schema that was read before `jit()` — or that the build plugin's `__zcMkv`\n // already materialized — carries the copies, and those go back verbatim.\n const original = new Map<string, PropertyDescriptor | undefined>();\n try {\n for (const slot of SLOTS) {\n original.set(slot, Object.getOwnPropertyDescriptor(target, slot));\n }\n } catch {\n // The target answers a descriptor query with a throw — an exotic wrapper,\n // not anything Zod built. Without a snapshot there is nothing to roll back\n // to, so install nothing and hand back the schema exactly as it came.\n return schema as T & CompiledSchema<output<T>>;\n }\n\n // Installing the accessors is the step most likely to throw rather than\n // degrade: a slot locked non-configurable (a future Zod, another wrapper) makes\n // defineProperty raise, and `jit()` is called at module scope — so an\n // unhandled throw here takes down the importing app at boot. Roll back to\n // whatever Zod had and leave the schema alone instead.\n let pending = true;\n try {\n installAccessors(\n target,\n original,\n () => {\n if (!pending) return;\n pending = false;\n restore(target, original);\n materialize(schema, options);\n },\n () => {\n if (!pending) return;\n pending = false;\n // Restore EVERY slot, not just the one being written. A left-behind\n // accessor whose trigger has been cancelled would read `target[slot]`\n // and re-enter itself — unbounded recursion, which is what a later read\n // of an untouched slot (`~standard`, from a Standard Schema consumer)\n // would otherwise hit.\n //\n // Reached only when something WRITES a slot before anything reads one: a\n // test double, another wrapper, or an AOT `safeParse` assigned directly.\n // The build plugin's own `__zcMkv` does not land here — its first\n // statement READS `parseAsync`/`safeParseAsync` to capture their\n // originals, so it triggers materialization and then overwrites the\n // compiled-by-jit methods with the compiled-by-plugin ones.\n restore(target, original);\n },\n );\n } catch {\n pending = false;\n restore(target, original);\n }\n\n return schema as T & CompiledSchema<output<T>>;\n}\n\n/**\n * Front every installed method with a compile-on-read accessor. `trigger`\n * materializes the schema, which normally replaces these accessors with the\n * compiled methods (or restores what Zod had). When that replacement does not\n * take, the getter serves Zod's own method rather than re-reading the slot —\n * see the re-entrancy note in the body.\n */\nfunction installAccessors(\n target: Record<string, unknown>,\n original: ReadonlyMap<string, PropertyDescriptor | undefined>,\n trigger: () => void,\n cancel: () => void,\n): void {\n for (const slot of SLOTS) {\n // Re-entrancy is settled structurally rather than by inspection. Reading the\n // slot again is how this getter normally hands over — to the compiled method\n // materialize() installed, or to whatever restore() put back — but the\n // handover can fail to take: a target frozen after `jit()` refuses both, and\n // a second copy of this module in the graph leaves ITS accessor on the slot,\n // so the two bounce reads between them. `trigger()` is spent by then, so\n // either way the read recurses until the stack blows. While a read is already\n // in flight, or once the accessor is known to be stranded, serve Zod's own\n // method instead: a schema that cannot be compiled still parses.\n let reading = false;\n // A stranded accessor is permanent, so what it serves is resolved once.\n let stranded: { value: unknown } | undefined;\n const serveZod = (): unknown => {\n stranded ??= { value: fromZod(target, original, slot) };\n return stranded.value;\n };\n const read = function (): unknown {\n if (reading) return serveZod();\n reading = true;\n try {\n trigger();\n if (stillFrontedBy(target, slot, read)) return serveZod();\n return target[slot];\n } finally {\n reading = false;\n }\n };\n Object.defineProperty(target, slot, {\n configurable: true,\n // Keep the schema's own-key set as it was. A slot Zod already materialized\n // is an enumerable own copy, so the accessor fronting it is enumerable too;\n // an untouched slot has no own key at all, and `is` never exists on a Zod\n // schema, so those stay out of `Object.keys` — the non-enumerable\n // convention `compile()` already uses.\n enumerable: original.get(slot)?.enumerable ?? false,\n get: read,\n set(value: unknown) {\n // Someone overwrote a method before first use (a test double, another\n // wrapper). Their value wins, and compilation is cancelled outright —\n // materializing later would restore the snapshot over it. With the\n // accessor gone the write does what it would have without `jit()`:\n // overwrite the own copy, or run Zod's prototype setter, which installs\n // one. Only a target that refused the rollback still routes here, and a\n // direct define is the one way left to honour the write.\n cancel();\n if (!stillFrontedBy(target, slot, read)) {\n target[slot] = value;\n return;\n }\n Object.defineProperty(target, slot, {\n configurable: true,\n enumerable: original.get(slot)?.enumerable ?? false,\n value,\n writable: true,\n });\n },\n });\n }\n}\n\n/**\n * Is `slot` still fronted by this very accessor — i.e. did the replacement that\n * `trigger()` was supposed to perform not take? A target that will not answer\n * the question is assumed to still hold it, since reading the slot to find out\n * is the recursion being avoided.\n */\nfunction stillFrontedBy(\n target: Record<string, unknown>,\n slot: string,\n getter: () => unknown,\n): boolean {\n try {\n return Object.getOwnPropertyDescriptor(target, slot)?.get === getter;\n } catch {\n return true;\n }\n}\n\n/**\n * Zod's own value for `slot`, bypassing the accessor that fronts it.\n *\n * A slot the snapshot holds is answered from the snapshot. One it does not hold\n * lives on the prototype, where Zod's getter binds the method to its receiver\n * and installs the bound copy as an own property — on a target that accepts\n * the install, that also replaces the stranded accessor with the copy, which is\n * the handover materialize() could not make. A target that refuses the install\n * (frozen, or a wrapper that vetoes `defineProperty`) makes Zod's getter throw\n * instead; there the read goes through a stand-in that inherits from the target,\n * so the copy lands on the stand-in and the method reaches `_zod` through the\n * chain. `undefined` for `is`, which no plain Zod schema carries — the same\n * thing every other degradation path leaves there.\n */\nfunction fromZod(\n target: Record<string, unknown>,\n original: ReadonlyMap<string, PropertyDescriptor | undefined>,\n slot: string,\n): unknown {\n const descriptor = original.get(slot);\n if (descriptor !== undefined) {\n // A snapshot can hold another accessor (a second copy of this module\n // installed first), so invoke it rather than reading a `value` it lacks.\n return descriptor.get === undefined ? descriptor.value : descriptor.get.call(target);\n }\n const proto = Object.getPrototypeOf(target) as object | null;\n if (proto === null) return undefined;\n try {\n return Reflect.get(proto, slot, target);\n } catch {\n return Reflect.get(proto, slot, Object.create(target));\n }\n}\n\n/**\n * Compile every Zod schema found among an object's own values — typically a\n * module namespace, so a whole schema file opts in with one call:\n *\n * ```ts\n * import * as schemas from \"./schemas.js\";\n * jitAll(schemas);\n * ```\n *\n * The namespace object itself is never written to (a module namespace is\n * read-only); `jit()` mutates the schema objects it holds, which is what every\n * importer of that module already references.\n */\nexport function jitAll(schemas: object, options?: JitOptions): void {\n for (const value of Object.values(schemas)) {\n if (isZodSchema(value)) jit(value, options);\n }\n}\n\n/**\n * Put back what the snapshot holds, dropping the compile-on-read accessors: the\n * own copy Zod (or the build plugin) had installed, or nothing at all, so the\n * slot reads through to Zod's prototype getter again.\n */\nfunction restore(\n target: Record<string, unknown>,\n original: ReadonlyMap<string, PropertyDescriptor | undefined>,\n): void {\n for (const slot of SLOTS) {\n // Per slot, because this also runs as the rollback for a failed install: a\n // target that refuses one slot must not cost the others their restoration.\n // A slot left fronted by its accessor still reads correctly — the getter\n // serves Zod's own method — but it keeps a redundant indirection, so\n // restoring what can be restored is worth the try/catch.\n try {\n const descriptor = original.get(slot);\n if (descriptor === undefined) delete target[slot];\n else Object.defineProperty(target, slot, descriptor);\n } catch {\n // Nothing further to try for this slot.\n }\n }\n}\n\n/**\n * Whether runtime code generation is permitted here. Read per call, never\n * snapshotted: `z.config({ jitless: true })` runs in an entry point, after the\n * schema modules it imports have already been evaluated.\n */\nfunction codegenAllowed(): boolean {\n return zodCore.globalConfig.jitless !== true && zodCore.util.allowsEval.value;\n}\n\n/**\n * Run the pipeline and let the generated IIFE install its methods on `schema`.\n * Swallows failure: a schema that cannot be compiled keeps Zod's own methods,\n * which the caller already has, so there is nothing to report and nothing to\n * break.\n */\nfunction materialize(schema: unknown, options?: JitOptions): void {\n if (!codegenAllowed()) return;\n try {\n buildValidator(schema, options);\n } catch {\n // Left as plain Zod. Deliberately silent: `jit()` is an optimization, and a\n // schema using a construct the compiler declines is a supported outcome,\n // not an error.\n }\n}\n\n/**\n * Generate the validator and evaluate it, reproducing the module a\n * `.compiled.ts` would have been: helper preamble, the file-level shared block,\n * then the `__zcMkv` IIFE whose `__rf[]` bases and install target are the live\n * schema object passed in as `__schema`.\n */\nfunction buildValidator(schema: unknown, options?: JitOptions): void {\n const { schemas, shared } = compileSchemas([{ exportName: \"jit\", schema }], {\n compact: options?.output === \"compact\",\n mode: \"inline\",\n });\n const compiled = schemas[0];\n if (compiled === undefined) throw new Error(\"zod-compiler: schema produced no validator\");\n\n const body = [RUNTIME_PRELUDE, shared.code, `return ${generateIIFE(\"__schema\", compiled)};`].join(\n \"\\n\",\n );\n\n // The three bindings ZOD_CONFIG_IMPORT would have imported, passed in so the\n // evaluated code needs no module resolution of its own.\n // oxlint-disable-next-line no-new-func -- generating the validator IS the feature\n const factory = new Function(\n \"__zodCompilerConfig\",\n \"__zcCore\",\n \"__zcZodError\",\n \"__schema\",\n body,\n ) as (\n zodConfigFn: typeof zodConfig,\n zodCoreNs: typeof zodCore,\n zodErrorCtor: typeof ZodRealError,\n target: unknown,\n ) => unknown;\n\n factory(zodConfig, zodCore, ZodRealError, schema);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AO,OAAO;OACvC,OAAO,eAAe,QAAQ,MAAM,UAAU;CACrD,QAAQ,CAER;AAEJ;;;;;;AAOA,SAAS,iBAA0B;CACjC,OAAOA,KAAQ,aAAa,YAAY,QAAQA,KAAQ,KAAK,WAAW;AAC1E;;;;;;;AAQA,SAAS,YAAY,QAAiB,SAA4B;CAChE,IAAI,CAAC,eAAe,GAAG;CACvB,IAAI;EACF,eAAe,QAAQ,OAAO;CAChC,QAAQ,CAIR;AACF;;;;;;;AAQA,SAAS,eAAe,QAAiB,SAA4B;CACnE,MAAM,EAAE,SAAS,WAAW,eAAe,CAAC;EAAE,YAAY;EAAO;CAAO,CAAC,GAAG;EAC1E,SAAS,SAAS,WAAW;EAC7B,MAAM;CACR,CAAC;CACD,MAAM,WAAW,QAAQ;CACzB,IAAI,aAAa,KAAA,GAAW,MAAM,IAAI,MAAM,4CAA4C;CAExF,MAAM,OAAO;EAAC;EAAiB,OAAO;EAAM,UAAU,aAAa,YAAY,QAAQ,EAAE;CAAE,CAAC,CAAC,KAC3F,IACF;CAkBA,IAboB,SAClB,uBACA,YACA,gBACA,YACA,IAQI,CAAC,CAACC,QAAWD,MAAS,cAAc,MAAM;AAClD"}
package/dist/runtime.d.ts CHANGED
@@ -6,7 +6,7 @@ export declare const __zcFin: any;
6
6
  export declare const __zcFinD: any;
7
7
  export declare const __zcFinZ: any;
8
8
  export declare const __zcTS: any;
9
- export declare const __zcTSn: any;
9
+ export declare const __zcTSt: any;
10
10
  export declare const __zcTSx: any;
11
11
  export declare const __zcTB: any;
12
12
  export declare const __zcTBt: any;
@@ -22,6 +22,9 @@ export declare const __zcFz: any;
22
22
  export declare const __zcHop: any;
23
23
  export declare const __zcLo: any;
24
24
  export declare const __zcSo: any;
25
+ export declare const __zcCpl: any;
26
+ export declare const __zcEmail: any;
27
+ export declare const __zcPs: any;
25
28
  export declare const __zcPlain: any;
26
29
  export declare const __zcPfx: any;
27
30
  export declare const __zcCu: any;
package/dist/runtime.js CHANGED
@@ -8,7 +8,7 @@ export function __zcFinD(f,inp){return new __ZcFail(null,f,inp);}
8
8
  export function __zcFinZ(z,r,i){return new __ZcFailZ(z,r,i);}
9
9
  function __zcSrRun(f,p){var r=f(p);if(r&&typeof r.then==="function"){throw new __zcCore.$ZodAsyncError();}}
10
10
  export function __zcTS(m,o,i,inp,p,msg){var r={origin:o,code:"too_small",minimum:m,inclusive:i,input:inp,path:p};if(msg!==undefined)r.message=msg;return r;}
11
- export function __zcTSn(m,o,inp,p,msg){var r={code:"too_small",minimum:m,origin:o,input:inp,path:p,continue:false};if(msg!==undefined)r.message=msg;return r;}
11
+ export function __zcTSt(m,o,inp,p,msg){var r={code:"too_small",minimum:m,inclusive:true,origin:o,input:inp,path:p,continue:false};if(msg!==undefined)r.message=msg;return r;}
12
12
  export function __zcTSx(m,o,inp,p,msg){var r={origin:o,code:"too_small",minimum:m,inclusive:true,exact:true,input:inp,path:p};if(msg!==undefined)r.message=msg;return r;}
13
13
  export function __zcTB(m,o,i,inp,p,msg){var r={origin:o,code:"too_big",maximum:m,inclusive:i,input:inp,path:p};if(msg!==undefined)r.message=msg;return r;}
14
14
  export function __zcTBt(m,o,inp,p,msg){var r={code:"too_big",maximum:m,inclusive:true,origin:o,input:inp,path:p,continue:false};if(msg!==undefined)r.message=msg;return r;}
@@ -18,26 +18,29 @@ export function __zcITc(e,inp,p,msg){var r={code:"invalid_type",expected:e,input
18
18
  export function __zcIF(o,f,inp,p,extra,msg){var r=o===undefined?{code:"invalid_format",format:f}:{origin:o,code:"invalid_format",format:f};if(extra)Object.assign(r,extra);r.input=inp;r.path=p;if(msg!==undefined)r.message=msg;return r;}
19
19
  export function __zcIV(values,inp,p,extra,msg){var r={code:"invalid_value"};if(extra)Object.assign(r,extra);r.values=values;r.input=inp;r.path=p;if(msg!==undefined)r.message=msg;return r;}
20
20
  export function __zcUK(k,inp,p,msg){var r={code:"unrecognized_keys",keys:k,input:inp,path:p};if(msg!==undefined)r.message=msg;return r;}
21
- export function __zcAb(e,i){for(;i<e.length;i++){var s=e[i];if(s.continue===false)return true;var c=s.code;if(c==="invalid_type"||c==="invalid_value"||c==="invalid_union"||c==="unrecognized_keys"||c==="invalid_key"||c==="invalid_element")return true;}return false;}
22
- export function __zcFsr(v,s){var vd=((""+v).split(".")[1]||"").length;var ss=""+s;var sd=(ss.split(".")[1]||"").length;if(sd===0&&/\d?e-\d?/.test(ss)){var m=ss.match(/\d?e-(\d?)/);if(m&&m[1]){sd=parseInt(m[1],10);}}var d=vd>sd?vd:sd;var vi=parseInt(v.toFixed(d).replace(".",""),10);var si=parseInt(s.toFixed(d).replace(".",""),10);return (vi%si)/Math.pow(10,d);}
21
+ export function __zcAb(e,i){for(;i<e.length;i++){var s=e[i];if(s.continue===false)return true;var c=s.code;if(c==="invalid_type"||c==="invalid_value"||c==="invalid_union"||c==="invalid_key"||c==="invalid_element")return true;}return false;}
22
+ export function __zcFsr(v,s){var r=v/s;var q=Math.round(r);var t=4*Number.EPSILON*Math.max(Math.abs(r),1);return Math.abs(r-q)<t?0:r-q;}
23
23
  export function __zcFz(e){for(var i=0;i<e.length;i++){var s=e[i];if(s.message===undefined&&typeof __zcMsg==="function")s.message=__zcMsg(s);delete s.input;delete s.continue;}return e;}
24
24
  export const __zcHop=Object.prototype.hasOwnProperty;
25
25
  export function __zcLo(v){return Array.isArray(v)?"array":typeof v==="string"?"string":"unknown";}
26
26
  export function __zcSo(v){return v instanceof Set?"set":v instanceof Map?"map":(typeof File!=="undefined"&&v instanceof File)?"file":"unknown";}
27
- export function __zcPlain(o){if(typeof o!=="object"||o===null||Array.isArray(o))return false;var c=o.constructor;if(c===undefined||typeof c!=="function")return true;var p=c.prototype;if(typeof p!=="object"||p===null||Array.isArray(p))return false;return Object.prototype.hasOwnProperty.call(p,"isPrototypeOf");}
27
+ export function __zcCpl(s){var n=s.length;if(!/[\uD800-\uDBFF]/.test(s))return n;var c=n;for(var i=0;i<n-1;i++){if((s.charCodeAt(i)&0xfc00)===0xd800&&(s.charCodeAt(i+1)&0xfc00)===0xdc00){c--;i++;}}return c;}
28
+ export function __zcEmail(s){var n=s.length,i=0,c,p=46;for(;;){if(i===n)return false;c=s.charCodeAt(i);if(c===64)break;if(c===46){if(p===46)return false;}else if(!((c>=97&&c<=122)||(c>=65&&c<=90)||(c>=48&&c<=57)||c===95||c===39||c===43||c===45))return false;p=c;i++;}if(p===46||p===39)return false;var l=++i,d=0,t=true;for(;i<n;i++){c=s.charCodeAt(i);if((c>=97&&c<=122)||(c>=65&&c<=90))continue;if(c===46){if(i===l)return false;d++;l=i+1;t=true;continue;}if((c>=48&&c<=57)||c===45){if(c===45&&i===l)return false;t=false;continue;}return false;}return d>0&&t&&n-l>=2;}
29
+ export function __zcPs(o){if(!Object.prototype.hasOwnProperty.call(o,"__proto__"))return o;var c={...o};delete c["__proto__"];return c;}
30
+ export function __zcPlain(o){if(typeof o!=="object"||o===null||Array.isArray(o))return false;var c=o.constructor;if(c===Object||c===undefined||typeof c!=="function")return true;var p=c.prototype;if(typeof p!=="object"||p===null||Array.isArray(p))return false;return Object.prototype.hasOwnProperty.call(p,"isPrototypeOf");}
28
31
  export function __zcPfx(d,s,b,k){for(var i=0;i<s.length;i++){var x=s[i];x.path=b.concat(k,x.path);d.push(x);}}
29
32
  export function __zcCu(f,v){var r=f(v);if(r&&typeof r.then==="function"){throw new __zcCore.$ZodAsyncError();}return !!r;}
30
- export function __zcSr(f,v,p,e){var q={value:v,issues:[]};__zcSrRun(f,q);for(var i=0;i<q.issues.length;i++){var s=q.issues[i],t={};for(var k in s){if(k!=="inst"&&k!=="continue")t[k]=s[k];}if(s.continue!==true)q.aborted=true;t.path=s.path&&s.path.length?p.concat(s.path):p;e.push(t);}return q;}
33
+ export function __zcSr(f,v,p,e,m){var q={value:v,issues:[]};__zcSrRun(f,q);for(var i=0;i<q.issues.length;i++){var s=q.issues[i],t={};for(var k in s){if(k!=="inst"&&k!=="continue")t[k]=s[k];}if(s.continue!==true)q.aborted=true;t.path=s.path&&s.path.length?p.concat(s.path):p;if(t.message===undefined&&m!==undefined)t.message=m;e.push(t);}return q;}
31
34
  export function __zcSrOk(f,v){var p={value:v,issues:[]};__zcSrRun(f,p);return p.issues.length===0&&p.value===v;}
32
35
  export const __zcReEmail=new RegExp("^(?:[A-Za-z0-9_'+\\-]+\\.)*[A-Za-z0-9_'+\\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$");
33
36
  export const __zcReEmailSrc="/^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$/";
34
37
  export const __zcReUuid=new RegExp("^([0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]-[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$");
35
38
  export const __zcReUuidSrc="/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/";
36
- export const __zcReCuid=new RegExp("^[cC][^\\s-][^\\s-][^\\s-][^\\s-][^\\s-][^\\s-][^\\s-][^\\s-][^\\s-]*$");
37
- export const __zcReCuidSrc="/^[cC][^\\s-]{8,}$/";
39
+ export const __zcReCuid=new RegExp("^[cC][0-9a-z][0-9a-z][0-9a-z][0-9a-z][0-9a-z][0-9a-z][0-9a-z]*$");
40
+ export const __zcReCuidSrc="/^[cC][0-9a-z]{6,}$/";
38
41
  export const __zcReCuid2=new RegExp("^[0-9a-z]+$");
39
- export const __zcReUlid=new RegExp("^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]$");
40
- export const __zcReUlidSrc="/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/";
42
+ export const __zcReUlid=new RegExp("^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp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zA-Z0-9_-][a-zA-Z0-9_-][a-zA-Z0-9_-][a-zA-Z0-9_-][a-zA-Z0-9_-]$");
42
45
  export const __zcReNanoidSrc="/^[a-zA-Z0-9_-]{21}$/";
43
46
  export const __zcReXid=new RegExp("^[0-9a-vA-V][0-9a-vA-V][0-9a-vA-V][0-9a-vA-V][0-9a-vA-V][0-9a-vA-V][0-9a-vA-V][0-9a-vA-V][0-9a-vA-V][0-9a-vA-V][0-9a-vA-V][0-9a-vA-V][0-9a-vA-V][0-9a-vA-V][0-9a-vA-V][0-9a-vA-V][0-9a-vA-V][0-9a-vA-V][0-9a-vA-V][0-9a-vA-V]$");
@@ -56,6 +59,6 @@ export const __zcReGuidSrc="/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9
56
59
  export const __zcReIsoDate=new RegExp("^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d\\d\\d\\d-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$");
57
60
  export const __zcReIsoDateSrc="/^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$/";
58
61
  export const __zcReIsoTime=new RegExp("^(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?$");
59
- export const __zcReIsoDateTime=new RegExp("^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d\\d\\d\\d-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$");
60
- export const __zcReIsoDateTimeSrc="/^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$/";
62
+ export const __zcReIsoDateTime=new RegExp("^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d\\d\\d\\d-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$");
63
+ export const __zcReIsoDateTimeSrc="/^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$/";
61
64
  export const __zcReIsoDuration=new RegExp("^P(?:(\\d+W)|(?!.*W)(?=\\d|T\\d)(\\d+Y)?(\\d+M)?(\\d+D)?(T(?=\\d)(\\d+H)?(\\d+M)?(\\d+([.,]\\d+)?S)?)?)$");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zod-compiler",
3
- "version": "1.28.0",
3
+ "version": "2.0.1",
4
4
  "description": "Compile Zod schemas into zero-overhead validation functions",
5
5
  "keywords": [
6
6
  "aot",
@@ -161,7 +161,7 @@
161
161
  "peerDependencies": {
162
162
  "@rsbuild/core": "^1.0.0 || ^2.0.0",
163
163
  "@swc/core": ">=1.3.0",
164
- "zod": "^4.0.0"
164
+ "zod": "^4.5.0"
165
165
  },
166
166
  "peerDependenciesMeta": {
167
167
  "@rsbuild/core": {