zod-compiler 1.23.2 → 1.23.4
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.
- package/README.md +10 -5
- package/dist/core/codegen/build-path.d.ts.map +1 -1
- package/dist/core/codegen/build-path.js +36 -9
- package/dist/core/codegen/build-path.js.map +1 -1
- package/dist/core/codegen/dedupe.js +1 -0
- package/dist/core/codegen/dedupe.js.map +1 -1
- package/dist/core/codegen/fast-path.d.ts.map +1 -1
- package/dist/core/codegen/fast-path.js +2 -0
- package/dist/core/codegen/fast-path.js.map +1 -1
- package/dist/core/codegen/fast-size.d.ts.map +1 -1
- package/dist/core/codegen/fast-size.js +2 -0
- package/dist/core/codegen/fast-size.js.map +1 -1
- package/dist/core/codegen/issue-decls.d.ts +7 -1
- package/dist/core/codegen/issue-decls.d.ts.map +1 -1
- package/dist/core/codegen/issue-decls.js +8 -1
- package/dist/core/codegen/issue-decls.js.map +1 -1
- package/dist/core/codegen/schemas/custom.d.ts +10 -0
- package/dist/core/codegen/schemas/custom.d.ts.map +1 -0
- package/dist/core/codegen/schemas/custom.js +17 -0
- package/dist/core/codegen/schemas/custom.js.map +1 -0
- package/dist/core/codegen/schemas/fallback.d.ts +3 -1
- package/dist/core/codegen/schemas/fallback.d.ts.map +1 -1
- package/dist/core/codegen/schemas/fallback.js +23 -20
- package/dist/core/codegen/schemas/fallback.js.map +1 -1
- package/dist/core/codegen/schemas/string-bool.d.ts +5 -2
- package/dist/core/codegen/schemas/string-bool.d.ts.map +1 -1
- package/dist/core/codegen/schemas/string-bool.js +18 -9
- package/dist/core/codegen/schemas/string-bool.js.map +1 -1
- package/dist/core/codegen/slow-path.d.ts.map +1 -1
- package/dist/core/codegen/slow-path.js +3 -1
- package/dist/core/codegen/slow-path.js.map +1 -1
- package/dist/core/extract/extractors/custom.d.ts +12 -0
- package/dist/core/extract/extractors/custom.d.ts.map +1 -0
- package/dist/core/extract/extractors/custom.js +35 -0
- package/dist/core/extract/extractors/custom.js.map +1 -0
- package/dist/core/extract/registry.d.ts +2 -0
- package/dist/core/extract/registry.d.ts.map +1 -1
- package/dist/core/extract/registry.js +2 -0
- package/dist/core/extract/registry.js.map +1 -1
- package/dist/core/extract/types.d.ts +7 -1
- package/dist/core/extract/types.d.ts.map +1 -1
- package/dist/core/iife.d.ts +3 -4
- package/dist/core/iife.d.ts.map +1 -1
- package/dist/core/iife.js +3 -4
- package/dist/core/iife.js.map +1 -1
- package/dist/core/types.d.ts +17 -2
- package/dist/core/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fast-size.js","names":[],"sources":["../../../src/core/codegen/fast-size.ts"],"sourcesContent":["/**\n * Fast-path size estimation, used to bound the size of each emitted fast-check\n * function. V8's TurboFan refuses to optimize functions whose bytecode exceeds\n * ~60KB and falls back to the weaker Maglev tier — measured ~1.3-1.8x slower on\n * deeply-nested schemas whose monolithic fast-check crosses that budget. By\n * extracting large, self-contained sub-schemas into their own boolean helpers\n * (`generateFast`), each function stays small enough to TurboFan.\n *\n * `estimateFastCost` is a path-agnostic subtree estimate in approximate\n * generated-character units (it can't see the access-path prefix the node will\n * be emitted under, since that lives in the call site, not the IR). The actual\n * emitted size of an inlined node grows with that prefix length — `input[\"a\"]\n * [\"b\"][\"c\"]…` repeated per check — so the extraction decision scales the\n * estimate by `1 + inputLen/PATH_GROWTH_DIVISOR` (see `predictedInlineSize`).\n * The accumulator itself (generateFast) tracks EXACT emitted chars via the\n * returned string length, so only the look-ahead prediction is approximate.\n */\n\nimport type { SchemaIR } from \"../types.js\";\nimport type { CodeGenContext } from \"./context.js\";\n\n/**\n * Per-function soft size cap, in emitted characters. Once the fast-check being\n * assembled would exceed this, the next large hoistable sub-schema is split into\n * its own helper. Set below the ~60KB bytecode point where TurboFan bails (chars\n * over-approximate bytecode) with margin for one look-ahead mis-prediction.\n */\nexport const EXTRACT_CAP = 38_000;\n\n/**\n * Each nesting level lengthens every access path inside a node (`x[\"a\"]` →\n * `x[\"a\"][\"b\"]`), inflating real emitted chars above the path-agnostic estimate.\n * The extraction look-ahead multiplies the estimate by `1 + inputLen/this` so a\n * deep subtree is split before it inlines into an over-budget function. Smaller\n * ⇒ more eager splitting at depth. Calibrated against deeply-nested fixtures.\n */\nconst PATH_GROWTH_DIVISOR = 26;\n\n/**\n * Predicted emitted size of inlining `ir` at a call site whose input expression\n * is `inputLen` chars long — the path-agnostic subtree estimate scaled up for\n * the access-path prefix that estimate omits. Used only for the extract/inline\n * decision; the running total uses exact emitted lengths.\n */\nexport function predictedInlineSize(\n ir: SchemaIR,\n inputLen: number,\n cache: WeakMap<SchemaIR, number>,\n): number {\n return estimateFastCost(ir, cache) * (1 + inputLen / PATH_GROWTH_DIVISOR);\n}\n\n/**\n * Floor for extraction: never hoist a sub-schema smaller than this even when\n * the enclosing function is over the cap — a tiny helper trades a real call for\n * no optimization benefit. Only sub-schemas big enough to matter are split.\n */\nexport const MIN_EXTRACT = 1_200;\n\n/** Approximate size contributed to the enclosing function by an extracted call `__fo_N(expr)`. */\nexport const CALL_COST = 24;\n\n/**\n * Node types whose fast-check is a self-contained boolean over a single input\n * expression and large enough to be worth hoisting into `function f(p){return …}`.\n * Thin wrappers (optional/nullable/default/…) are omitted: their inner schema is\n * visited through `generateFast` and gets hoisted on its own when large.\n */\nexport const HOISTABLE: ReadonlySet<SchemaIR[\"type\"]> = new Set([\n \"object\",\n \"record\",\n \"tuple\",\n \"discriminatedUnion\",\n \"union\",\n \"intersection\",\n]);\n\n/** A node's own contribution to the emitted fast-check, EXCLUDING its children. */\nfunction shallowFastCost(ir: SchemaIR): number {\n switch (ir.type) {\n case \"object\":\n return 50 + Object.keys(ir.properties).length * 25 + (ir.strict ? 120 : 0);\n case \"string\":\n return 20 + ir.checks.length * 35;\n case \"number\":\n return 25 + ir.checks.length * 30;\n case \"bigint\":\n case \"date\":\n return 25 + (ir.checks?.length ?? 0) * 25;\n case \"enum\":\n return 15 + ir.values.length * 12;\n case \"tuple\":\n return 40 + ir.items.length * 15;\n case \"union\":\n return 12 + ir.options.length * 6;\n case \"discriminatedUnion\":\n return 45 + ir.cases.length * 12;\n case \"array\":\n case \"record\":\n case \"set\":\n case \"map\":\n return 55;\n case \"file\":\n case \"templateLiteral\":\n return 40;\n case \"literal\":\n case \"optional\":\n case \"nullable\":\n case \"default\":\n return 22;\n case \"recursiveRef\":\n case \"recursionTarget\":\n // Both emit just a call to a hosted helper; the target's `inner` is sized\n // independently when its own helper body is generated, so it is NOT\n // counted against the enclosing function here (see fastChildren).\n return 15;\n default:\n return 18;\n }\n}\n\n/** Child IR nodes that the fast generator recurses into (mirrors the fast schema generators). */\nfunction fastChildren(ir: SchemaIR): readonly SchemaIR[] {\n switch (ir.type) {\n case \"object\":\n return Object.values(ir.properties);\n case \"array\":\n return [ir.element];\n case \"tuple\":\n return ir.rest !== null ? [...ir.items, ir.rest] : ir.items;\n case \"record\":\n case \"map\":\n return [ir.keyType, ir.valueType];\n case \"set\":\n return [ir.valueType];\n case \"union\":\n case \"discriminatedUnion\":\n return ir.options;\n case \"intersection\":\n return [ir.left, ir.right];\n case \"pipe\":\n return [ir.in, ir.out];\n case \"optional\":\n case \"nullable\":\n case \"readonly\":\n case \"default\":\n case \"catch\":\n return [ir.inner];\n default:\n return [];\n }\n}\n\n/**\n * Estimated total size of a node's fast-check (the node plus everything inlined\n * beneath it). Memoized per IR node: schemas dedupe shared sub-trees and the\n * estimate is consulted at every nesting level, so without the cache a deep tree\n * would be re-walked quadratically.\n */\nexport function estimateFastCost(ir: SchemaIR, cache: WeakMap<SchemaIR, number>): number {\n const cached = cache.get(ir);\n if (cached !== undefined) return cached;\n // Defensive cycle break (the IR is a tree today; recursiveRef is a leaf).\n cache.set(ir, 0);\n let total = shallowFastCost(ir);\n for (const child of fastChildren(ir)) total += estimateFastCost(child, cache);\n cache.set(ir, total);\n return total;\n}\n\n// ─── Runtime cost (check ordering) ───────────────────────────────────────────\n\n/**\n * Assumed element count for unbounded collections, used only to weight a\n * container against its siblings when ordering an `&&` chain.\n */\nconst ASSUMED_ELEMENTS = 4;\n\n/** Runtime weight of one check on an already-type-confirmed value. */\nfunction checkRuntimeCost(kind: string): number {\n switch (kind) {\n // A `.test()` call costs ~9 ns of dispatch before it matches a character —\n // an order of magnitude above every other check, and the reason ordering\n // matters at all.\n case \"string_format\":\n return 100;\n // Zero-capture user predicate: a real call, cheaper than a regex.\n case \"refine_effect\":\n return 20;\n case \"includes\":\n case \"starts_with\":\n case \"ends_with\":\n return 6;\n case \"multiple_of\":\n case \"bigint_multiple_of\":\n return 4;\n default:\n // length/size/range comparisons: a load and a compare.\n return 1;\n }\n}\n\n/** A node's own runtime weight, EXCLUDING its children. */\nfunction shallowRuntimeCost(ir: SchemaIR): number {\n switch (ir.type) {\n case \"string\":\n case \"number\":\n return 2 + ir.checks.reduce((sum, c) => sum + checkRuntimeCost(c.kind), 0);\n case \"bigint\":\n case \"date\":\n return 3 + (ir.checks?.length ?? 0);\n case \"file\":\n return 3 + (ir.checks?.length ?? 0) * 2;\n case \"enum\":\n // Inlined `===` chain (or one hashed lookup) — sub-nanosecond either way.\n return 1 + Math.min(ir.values.length, 8);\n case \"object\":\n // Type guard, plus the strict pass's per-key membership test.\n return 3 + (ir.strict === true ? Object.keys(ir.properties).length : 0);\n case \"array\":\n case \"set\":\n case \"record\":\n case \"map\":\n case \"tuple\":\n return 3;\n case \"templateLiteral\":\n return 100;\n case \"recursiveRef\":\n case \"recursionTarget\":\n // A recursive call expands into an unknown amount of work; treat it as\n // the most expensive sibling so it is probed last.\n return 200;\n default:\n return 1;\n }\n}\n\n/** estimateRuntimeCost against the per-compile memo hanging off the context. */\nfunction runtimeCostOf(ir: SchemaIR, ctx: CodeGenContext): number {\n return estimateRuntimeCost(ir, (ctx.fastRuntimeCostCache ??= new WeakMap<SchemaIR, number>()));\n}\n\n/**\n * Sort a fast-check's sibling conjuncts (or union options) cheapest-first.\n * Returns a new array; ties keep source order (Array#sort is stable), so a\n * schema whose members all cost the same emits byte-identical output.\n */\nexport function orderByRuntimeCost<T>(\n items: readonly T[],\n irOf: (item: T) => SchemaIR,\n ctx: CodeGenContext,\n): T[] {\n if (items.length < 2) return [...items];\n return [...items].sort((a, b) => runtimeCostOf(irOf(a), ctx) - runtimeCostOf(irOf(b), ctx));\n}\n\n/**\n * Estimated runtime cost of a node's fast-check, in arbitrary units calibrated\n * so a regex format check dominates a handful of type guards. Memoized per IR\n * node, like estimateFastCost — the estimate is consulted at every nesting\n * level, and shared sub-trees are common.\n *\n * Used to order the conjuncts of an `&&` chain cheapest-first. Accepting input\n * runs every conjunct regardless, so ordering is free there; REJECTING input\n * stops at the first false one, which is where a schema pays for probing a\n * `z.email()` before the `kind` literal that actually discriminates. Measured\n * on a 3-option union of objects that each declare `{email, kind, note}`:\n * 102 ns → 39 ns for an input matching the last option, and 102 ns → 6 ns for\n * one matching none.\n */\nfunction estimateRuntimeCost(ir: SchemaIR, cache: WeakMap<SchemaIR, number>): number {\n const cached = cache.get(ir);\n if (cached !== undefined) return cached;\n cache.set(ir, 0); // cycle break (mirrors estimateFastCost)\n let total = shallowRuntimeCost(ir);\n const children = fastChildren(ir);\n switch (ir.type) {\n case \"array\":\n case \"set\":\n case \"record\":\n case \"map\":\n // Per-element work, repeated for an assumed handful of entries.\n for (const child of children) total += estimateRuntimeCost(child, cache) * ASSUMED_ELEMENTS;\n break;\n case \"discriminatedUnion\":\n // O(1) switch: only the matched case runs. Charge the priciest option so\n // the estimate stays an upper bound.\n total += children.reduce((max, c) => Math.max(max, estimateRuntimeCost(c, cache)), 0);\n break;\n default:\n // object/tuple/union/intersection/wrappers: every child is on the path\n // (a union probes options until one matches — worst case, all of them).\n for (const child of children) total += estimateRuntimeCost(child, cache);\n break;\n }\n cache.set(ir, total);\n return total;\n}\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"fast-size.js","names":[],"sources":["../../../src/core/codegen/fast-size.ts"],"sourcesContent":["/**\n * Fast-path size estimation, used to bound the size of each emitted fast-check\n * function. V8's TurboFan refuses to optimize functions whose bytecode exceeds\n * ~60KB and falls back to the weaker Maglev tier — measured ~1.3-1.8x slower on\n * deeply-nested schemas whose monolithic fast-check crosses that budget. By\n * extracting large, self-contained sub-schemas into their own boolean helpers\n * (`generateFast`), each function stays small enough to TurboFan.\n *\n * `estimateFastCost` is a path-agnostic subtree estimate in approximate\n * generated-character units (it can't see the access-path prefix the node will\n * be emitted under, since that lives in the call site, not the IR). The actual\n * emitted size of an inlined node grows with that prefix length — `input[\"a\"]\n * [\"b\"][\"c\"]…` repeated per check — so the extraction decision scales the\n * estimate by `1 + inputLen/PATH_GROWTH_DIVISOR` (see `predictedInlineSize`).\n * The accumulator itself (generateFast) tracks EXACT emitted chars via the\n * returned string length, so only the look-ahead prediction is approximate.\n */\n\nimport type { SchemaIR } from \"../types.js\";\nimport type { CodeGenContext } from \"./context.js\";\n\n/**\n * Per-function soft size cap, in emitted characters. Once the fast-check being\n * assembled would exceed this, the next large hoistable sub-schema is split into\n * its own helper. Set below the ~60KB bytecode point where TurboFan bails (chars\n * over-approximate bytecode) with margin for one look-ahead mis-prediction.\n */\nexport const EXTRACT_CAP = 38_000;\n\n/**\n * Each nesting level lengthens every access path inside a node (`x[\"a\"]` →\n * `x[\"a\"][\"b\"]`), inflating real emitted chars above the path-agnostic estimate.\n * The extraction look-ahead multiplies the estimate by `1 + inputLen/this` so a\n * deep subtree is split before it inlines into an over-budget function. Smaller\n * ⇒ more eager splitting at depth. Calibrated against deeply-nested fixtures.\n */\nconst PATH_GROWTH_DIVISOR = 26;\n\n/**\n * Predicted emitted size of inlining `ir` at a call site whose input expression\n * is `inputLen` chars long — the path-agnostic subtree estimate scaled up for\n * the access-path prefix that estimate omits. Used only for the extract/inline\n * decision; the running total uses exact emitted lengths.\n */\nexport function predictedInlineSize(\n ir: SchemaIR,\n inputLen: number,\n cache: WeakMap<SchemaIR, number>,\n): number {\n return estimateFastCost(ir, cache) * (1 + inputLen / PATH_GROWTH_DIVISOR);\n}\n\n/**\n * Floor for extraction: never hoist a sub-schema smaller than this even when\n * the enclosing function is over the cap — a tiny helper trades a real call for\n * no optimization benefit. Only sub-schemas big enough to matter are split.\n */\nexport const MIN_EXTRACT = 1_200;\n\n/** Approximate size contributed to the enclosing function by an extracted call `__fo_N(expr)`. */\nexport const CALL_COST = 24;\n\n/**\n * Node types whose fast-check is a self-contained boolean over a single input\n * expression and large enough to be worth hoisting into `function f(p){return …}`.\n * Thin wrappers (optional/nullable/default/…) are omitted: their inner schema is\n * visited through `generateFast` and gets hoisted on its own when large.\n */\nexport const HOISTABLE: ReadonlySet<SchemaIR[\"type\"]> = new Set([\n \"object\",\n \"record\",\n \"tuple\",\n \"discriminatedUnion\",\n \"union\",\n \"intersection\",\n]);\n\n/** A node's own contribution to the emitted fast-check, EXCLUDING its children. */\nfunction shallowFastCost(ir: SchemaIR): number {\n switch (ir.type) {\n case \"object\":\n return 50 + Object.keys(ir.properties).length * 25 + (ir.strict ? 120 : 0);\n case \"string\":\n return 20 + ir.checks.length * 35;\n case \"number\":\n return 25 + ir.checks.length * 30;\n case \"bigint\":\n case \"date\":\n return 25 + (ir.checks?.length ?? 0) * 25;\n case \"enum\":\n return 15 + ir.values.length * 12;\n case \"tuple\":\n return 40 + ir.items.length * 15;\n case \"union\":\n return 12 + ir.options.length * 6;\n case \"discriminatedUnion\":\n return 45 + ir.cases.length * 12;\n case \"array\":\n case \"record\":\n case \"set\":\n case \"map\":\n return 55;\n case \"file\":\n case \"templateLiteral\":\n return 40;\n case \"custom\":\n return 30;\n case \"literal\":\n case \"optional\":\n case \"nullable\":\n case \"default\":\n return 22;\n case \"recursiveRef\":\n case \"recursionTarget\":\n // Both emit just a call to a hosted helper; the target's `inner` is sized\n // independently when its own helper body is generated, so it is NOT\n // counted against the enclosing function here (see fastChildren).\n return 15;\n default:\n return 18;\n }\n}\n\n/** Child IR nodes that the fast generator recurses into (mirrors the fast schema generators). */\nfunction fastChildren(ir: SchemaIR): readonly SchemaIR[] {\n switch (ir.type) {\n case \"object\":\n return Object.values(ir.properties);\n case \"array\":\n return [ir.element];\n case \"tuple\":\n return ir.rest !== null ? [...ir.items, ir.rest] : ir.items;\n case \"record\":\n case \"map\":\n return [ir.keyType, ir.valueType];\n case \"set\":\n return [ir.valueType];\n case \"union\":\n case \"discriminatedUnion\":\n return ir.options;\n case \"intersection\":\n return [ir.left, ir.right];\n case \"pipe\":\n return [ir.in, ir.out];\n case \"optional\":\n case \"nullable\":\n case \"readonly\":\n case \"default\":\n case \"catch\":\n return [ir.inner];\n default:\n return [];\n }\n}\n\n/**\n * Estimated total size of a node's fast-check (the node plus everything inlined\n * beneath it). Memoized per IR node: schemas dedupe shared sub-trees and the\n * estimate is consulted at every nesting level, so without the cache a deep tree\n * would be re-walked quadratically.\n */\nexport function estimateFastCost(ir: SchemaIR, cache: WeakMap<SchemaIR, number>): number {\n const cached = cache.get(ir);\n if (cached !== undefined) return cached;\n // Defensive cycle break (the IR is a tree today; recursiveRef is a leaf).\n cache.set(ir, 0);\n let total = shallowFastCost(ir);\n for (const child of fastChildren(ir)) total += estimateFastCost(child, cache);\n cache.set(ir, total);\n return total;\n}\n\n// ─── Runtime cost (check ordering) ───────────────────────────────────────────\n\n/**\n * Assumed element count for unbounded collections, used only to weight a\n * container against its siblings when ordering an `&&` chain.\n */\nconst ASSUMED_ELEMENTS = 4;\n\n/** Runtime weight of one check on an already-type-confirmed value. */\nfunction checkRuntimeCost(kind: string): number {\n switch (kind) {\n // A `.test()` call costs ~9 ns of dispatch before it matches a character —\n // an order of magnitude above every other check, and the reason ordering\n // matters at all.\n case \"string_format\":\n return 100;\n // Zero-capture user predicate: a real call, cheaper than a regex.\n case \"refine_effect\":\n return 20;\n case \"includes\":\n case \"starts_with\":\n case \"ends_with\":\n return 6;\n case \"multiple_of\":\n case \"bigint_multiple_of\":\n return 4;\n default:\n // length/size/range comparisons: a load and a compare.\n return 1;\n }\n}\n\n/** A node's own runtime weight, EXCLUDING its children. */\nfunction shallowRuntimeCost(ir: SchemaIR): number {\n switch (ir.type) {\n case \"string\":\n case \"number\":\n return 2 + ir.checks.reduce((sum, c) => sum + checkRuntimeCost(c.kind), 0);\n case \"bigint\":\n case \"date\":\n return 3 + (ir.checks?.length ?? 0);\n case \"file\":\n return 3 + (ir.checks?.length ?? 0) * 2;\n case \"enum\":\n // Inlined `===` chain (or one hashed lookup) — sub-nanosecond either way.\n return 1 + Math.min(ir.values.length, 8);\n case \"object\":\n // Type guard, plus the strict pass's per-key membership test.\n return 3 + (ir.strict === true ? Object.keys(ir.properties).length : 0);\n case \"array\":\n case \"set\":\n case \"record\":\n case \"map\":\n case \"tuple\":\n return 3;\n case \"templateLiteral\":\n return 100;\n case \"custom\":\n return 20;\n case \"recursiveRef\":\n case \"recursionTarget\":\n // A recursive call expands into an unknown amount of work; treat it as\n // the most expensive sibling so it is probed last.\n return 200;\n default:\n return 1;\n }\n}\n\n/** estimateRuntimeCost against the per-compile memo hanging off the context. */\nfunction runtimeCostOf(ir: SchemaIR, ctx: CodeGenContext): number {\n return estimateRuntimeCost(ir, (ctx.fastRuntimeCostCache ??= new WeakMap<SchemaIR, number>()));\n}\n\n/**\n * Sort a fast-check's sibling conjuncts (or union options) cheapest-first.\n * Returns a new array; ties keep source order (Array#sort is stable), so a\n * schema whose members all cost the same emits byte-identical output.\n */\nexport function orderByRuntimeCost<T>(\n items: readonly T[],\n irOf: (item: T) => SchemaIR,\n ctx: CodeGenContext,\n): T[] {\n if (items.length < 2) return [...items];\n return [...items].sort((a, b) => runtimeCostOf(irOf(a), ctx) - runtimeCostOf(irOf(b), ctx));\n}\n\n/**\n * Estimated runtime cost of a node's fast-check, in arbitrary units calibrated\n * so a regex format check dominates a handful of type guards. Memoized per IR\n * node, like estimateFastCost — the estimate is consulted at every nesting\n * level, and shared sub-trees are common.\n *\n * Used to order the conjuncts of an `&&` chain cheapest-first. Accepting input\n * runs every conjunct regardless, so ordering is free there; REJECTING input\n * stops at the first false one, which is where a schema pays for probing a\n * `z.email()` before the `kind` literal that actually discriminates. Measured\n * on a 3-option union of objects that each declare `{email, kind, note}`:\n * 102 ns → 39 ns for an input matching the last option, and 102 ns → 6 ns for\n * one matching none.\n */\nfunction estimateRuntimeCost(ir: SchemaIR, cache: WeakMap<SchemaIR, number>): number {\n const cached = cache.get(ir);\n if (cached !== undefined) return cached;\n cache.set(ir, 0); // cycle break (mirrors estimateFastCost)\n let total = shallowRuntimeCost(ir);\n const children = fastChildren(ir);\n switch (ir.type) {\n case \"array\":\n case \"set\":\n case \"record\":\n case \"map\":\n // Per-element work, repeated for an assumed handful of entries.\n for (const child of children) total += estimateRuntimeCost(child, cache) * ASSUMED_ELEMENTS;\n break;\n case \"discriminatedUnion\":\n // O(1) switch: only the matched case runs. Charge the priciest option so\n // the estimate stays an upper bound.\n total += children.reduce((max, c) => Math.max(max, estimateRuntimeCost(c, cache)), 0);\n break;\n default:\n // object/tuple/union/intersection/wrappers: every child is on the path\n // (a union probes options until one matches — worst case, all of them).\n for (const child of children) total += estimateRuntimeCost(child, cache);\n break;\n }\n cache.set(ir, total);\n return total;\n}\n"],"mappings":"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"}
|
|
@@ -104,6 +104,12 @@ declare const ZC_SR_OK_DECL: string;
|
|
|
104
104
|
* callbacks return undefined, so the guard short-circuits on the first operand.
|
|
105
105
|
*/
|
|
106
106
|
declare const ZC_SR_RUN_DECL: string;
|
|
107
|
+
/**
|
|
108
|
+
* z.custom()/z.instanceof() fast verdict. Zod treats truthy predicate returns
|
|
109
|
+
* as success and raises $ZodAsyncError when a synchronous parse encounters a
|
|
110
|
+
* thenable, including a non-async function that happens to return a Promise.
|
|
111
|
+
*/
|
|
112
|
+
declare const ZC_CUSTOM_OK_DECL: string;
|
|
107
113
|
/**
|
|
108
114
|
* superRefine slow-path merge: run the callback, then move its issues onto the
|
|
109
115
|
* validator's list the way zod's finalizeIssue does — the node's path prefixed
|
|
@@ -123,5 +129,5 @@ declare const ZC_SR_DECL: string;
|
|
|
123
129
|
/** Non-issue runtime helper declarations hosted in the virtual module. */
|
|
124
130
|
declare const RUNTIME_HELPER_DECLS: Readonly<Record<string, string>>;
|
|
125
131
|
//#endregion
|
|
126
|
-
export { ISSUE_DECLS, RUNTIME_HELPER_DECLS, ZC_AB_DECL, ZC_FSR_DECL, ZC_FZ_DECL, ZC_HOP_DECL, ZC_PFX_DECL, ZC_SR_DECL, ZC_SR_OK_DECL, ZC_SR_RUN_DECL, abortingCodeTest, propertyKeyTest };
|
|
132
|
+
export { ISSUE_DECLS, RUNTIME_HELPER_DECLS, ZC_AB_DECL, ZC_CUSTOM_OK_DECL, ZC_FSR_DECL, ZC_FZ_DECL, ZC_HOP_DECL, ZC_PFX_DECL, ZC_SR_DECL, ZC_SR_OK_DECL, ZC_SR_RUN_DECL, abortingCodeTest, propertyKeyTest };
|
|
127
133
|
//# sourceMappingURL=issue-decls.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"issue-decls.d.ts","names":[],"sources":["../../../src/core/codegen/issue-decls.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;cA4Ca,aAAa,SAAS;;;;;;cAgBtB;;;;;;;;;;cAYA;;iBAyBG,iBAAiB;;;;;;;;;;;;;;;cAkBpB;;;;;;;;;;;;cAaA;;;;;;;;;cAaA;;iBAIG,gBAAgB;;;;;;;;;;;;;;;;cAmBnB;;;;;;;;;;;;;cAgBA;;;;;;;;;;;;;;;;cAmBA;;cAQA,sBAAsB,SAAS"}
|
|
1
|
+
{"version":3,"file":"issue-decls.d.ts","names":[],"sources":["../../../src/core/codegen/issue-decls.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;cA4Ca,aAAa,SAAS;;;;;;cAgBtB;;;;;;;;;;cAYA;;iBAyBG,iBAAiB;;;;;;;;;;;;;;;cAkBpB;;;;;;;;;;;;cAaA;;;;;;;;;cAaA;;iBAIG,gBAAgB;;;;;;;;;;;;;;;;cAmBnB;;;;;;;;;;;;;cAgBA;;;;;;cASA;;;;;;;;;;;;;;;;cAmBA;;cAQA,sBAAsB,SAAS"}
|
|
@@ -120,6 +120,12 @@ const ZC_SR_OK_DECL = "function __zcSrOk(f,v){var p={value:v,issues:[]};__zcSrRu
|
|
|
120
120
|
*/
|
|
121
121
|
const ZC_SR_RUN_DECL = "function __zcSrRun(f,p){var r=f(p);if(r&&typeof r.then===\"function\"){throw new __zcCore.$ZodAsyncError();}}";
|
|
122
122
|
/**
|
|
123
|
+
* z.custom()/z.instanceof() fast verdict. Zod treats truthy predicate returns
|
|
124
|
+
* as success and raises $ZodAsyncError when a synchronous parse encounters a
|
|
125
|
+
* thenable, including a non-async function that happens to return a Promise.
|
|
126
|
+
*/
|
|
127
|
+
const ZC_CUSTOM_OK_DECL = "function __zcCu(f,v){var r=f(v);if(r&&typeof r.then===\"function\"){throw new __zcCore.$ZodAsyncError();}return !!r;}";
|
|
128
|
+
/**
|
|
123
129
|
* superRefine slow-path merge: run the callback, then move its issues onto the
|
|
124
130
|
* validator's list the way zod's finalizeIssue does — the node's path prefixed
|
|
125
131
|
* onto any path the user supplied, and the internal `inst`/`continue` fields
|
|
@@ -142,10 +148,11 @@ const RUNTIME_HELPER_DECLS = {
|
|
|
142
148
|
__zcFz: ZC_FZ_DECL,
|
|
143
149
|
__zcHop: ZC_HOP_DECL,
|
|
144
150
|
__zcPfx: ZC_PFX_DECL,
|
|
151
|
+
__zcCu: ZC_CUSTOM_OK_DECL,
|
|
145
152
|
__zcSr: ZC_SR_DECL,
|
|
146
153
|
__zcSrOk: ZC_SR_OK_DECL
|
|
147
154
|
};
|
|
148
155
|
//#endregion
|
|
149
|
-
export { ISSUE_DECLS, RUNTIME_HELPER_DECLS, ZC_AB_DECL, ZC_FSR_DECL, ZC_FZ_DECL, ZC_HOP_DECL, ZC_PFX_DECL, ZC_SR_DECL, ZC_SR_OK_DECL, ZC_SR_RUN_DECL, abortingCodeTest, propertyKeyTest };
|
|
156
|
+
export { ISSUE_DECLS, RUNTIME_HELPER_DECLS, ZC_AB_DECL, ZC_CUSTOM_OK_DECL, ZC_FSR_DECL, ZC_FZ_DECL, ZC_HOP_DECL, ZC_PFX_DECL, ZC_SR_DECL, ZC_SR_OK_DECL, ZC_SR_RUN_DECL, abortingCodeTest, propertyKeyTest };
|
|
150
157
|
|
|
151
158
|
//# sourceMappingURL=issue-decls.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"issue-decls.js","names":[],"sources":["../../../src/core/codegen/issue-decls.ts"],"sourcesContent":["/**\n * Issue factory function bodies (statement form).\n *\n * These functions produce the same `{code, ...}` shapes that lean-mode\n * generated code would otherwise inline at every check site.\n * Hosted in \"virtual:zod-compiler/runtime\" and called as `__zcTS(...)` etc.\n *\n * Argument convention (positional, kept short to minimize call-site bytes):\n * __zcTS(minimum, origin, inclusive, input, path, msg?) — too_small\n * __zcTB(maximum, origin, inclusive, input, path, msg?) — too_big\n * __zcIT(expected, input, path, msg?) — invalid_type\n * __zcIF(format, input, path, extra?, msg?) — invalid_format (extra merged into result)\n * __zcIV(values, input, path, msg?) — invalid_value\n * __zcUK(keys, input, path, msg?) — unrecognized_keys\n *\n * The trailing msg argument carries a static custom error message; when\n * absent, the __zcFin finalizer applies the configured locale default.\n */\n\nconst ZC_TS_DECL =\n 'function __zcTS(m,o,i,inp,p,msg){var r={code:\"too_small\",minimum:m,origin:o,inclusive:i,input:inp,path:p};if(msg!==undefined)r.message=msg;return r;}';\n\nconst ZC_TS_EXACT_DECL =\n 'function __zcTSx(m,o,inp,p,msg){var r={code:\"too_small\",minimum:m,origin:o,inclusive:true,exact:true,input:inp,path:p};if(msg!==undefined)r.message=msg;return r;}';\n\nconst ZC_TB_DECL =\n 'function __zcTB(m,o,i,inp,p,msg){var r={code:\"too_big\",maximum:m,origin:o,inclusive:i,input:inp,path:p};if(msg!==undefined)r.message=msg;return r;}';\n\nconst ZC_TB_EXACT_DECL =\n 'function __zcTBx(m,o,inp,p,msg){var r={code:\"too_big\",maximum:m,origin:o,inclusive:true,exact:true,input:inp,path:p};if(msg!==undefined)r.message=msg;return r;}';\n\nconst ZC_IT_DECL =\n 'function __zcIT(e,inp,p,msg){var r={code:\"invalid_type\",expected:e,input:inp,path:p};if(msg!==undefined)r.message=msg;return r;}';\n\nconst ZC_IF_DECL =\n 'function __zcIF(f,inp,p,extra,msg){var r={code:\"invalid_format\",format:f,input:inp,path:p};if(extra)Object.assign(r,extra);if(msg!==undefined)r.message=msg;return r;}';\n\nconst ZC_IV_DECL =\n 'function __zcIV(values,inp,p,msg){var r={code:\"invalid_value\",values:values,input:inp,path:p};if(msg!==undefined)r.message=msg;return r;}';\n\nconst ZC_UK_DECL =\n '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;}';\n\n/** All issue factory declarations indexed by helper name. */\nexport const ISSUE_DECLS: Readonly<Record<string, string>> = {\n __zcTS: ZC_TS_DECL,\n __zcTSx: ZC_TS_EXACT_DECL,\n __zcTB: ZC_TB_DECL,\n __zcTBx: ZC_TB_EXACT_DECL,\n __zcIT: ZC_IT_DECL,\n __zcIF: ZC_IF_DECL,\n __zcIV: ZC_IV_DECL,\n __zcUK: ZC_UK_DECL,\n};\n\n/**\n * Float-safe remainder — byte-for-byte port of zod's util.floatSafeRemainder.\n * Raw `%` mis-rejects valid multiples of decimal steps (0.3 % 0.1 !== 0);\n * zod scales both operands to integers by their decimal-place count first.\n */\nexport const ZC_FSR_DECL =\n '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);}';\n\n/**\n * Hoisted `Object.prototype.hasOwnProperty` reference. Record fast/slow paths\n * iterate keys with `for(k in o)` (no `Object.keys` array allocation) and guard\n * each key with `__zcHop.call(o,k)` to skip inherited enumerable properties —\n * yielding the exact own-enumerable string-key set `Object.keys` would, so\n * fast/slow stay in agreement and parity with zod's own-key record semantics is\n * preserved. The hoisted reference inlines in V8; reading the prototype property\n * per call would not.\n */\nexport const ZC_HOP_DECL = \"const __zcHop=Object.prototype.hasOwnProperty;\";\n\n/**\n * Issue codes zod raises from a schema's `_zod.parse` rather than from a check,\n * and which therefore carry `continue !== true` — what `util.aborted` looks for.\n *\n * Everything a CHECK produces (`too_small`, `too_big`, `invalid_format`,\n * `not_multiple_of`, a refine's `custom`) is continuable, because `$ZodCheck`\n * sets `continue: !def.abort` and an `abort: true` check costs the schema its\n * compiled path anyway — so classifying by code alone is exact for generated\n * issues.\n *\n * Read by {@link ZC_AB_DECL} and by the union's option-pruning loop, which\n * applies the same rule inline over a per-option issue array.\n */\nconst ABORTING_ISSUE_CODES: readonly string[] = [\n \"invalid_type\",\n \"invalid_value\",\n \"invalid_union\",\n \"unrecognized_keys\",\n \"invalid_key\",\n \"invalid_element\",\n];\n\n/** `c===\"invalid_type\"||c===\"invalid_value\"||…` over the code held in `codeExpr`. */\nexport function abortingCodeTest(codeExpr: string): string {\n return ABORTING_ISSUE_CODES.map((code) => `${codeExpr}===${JSON.stringify(code)}`).join(\"||\");\n}\n\n/**\n * Port of zod's `util.aborted(payload, startIndex)`: has anything since\n * `startIndex` produced a NON-continuable issue?\n *\n * zod gates a schema's check chain on this (`runChecks`: `else if (isAborted)\n * continue`), which is what makes a container's `.refine()` still run after a\n * property or element failed its own `min`/`max`/format check, and stop running\n * once one failed to parse at all. The `startIndex` is the issue count when the\n * node was entered, mirroring the fresh payload zod hands each sub-schema.\n *\n * Size/length checks are exempt in zod — they declare a `when` predicate, which\n * bypasses the abort gate — so generated code leaves those ungated and only\n * wraps the refine/superRefine effects.\n */\nexport const ZC_AB_DECL = `function __zcAb(e,i){for(;i<e.length;i++){var c=e[i].code;if(${abortingCodeTest(\"c\")})return true;}return false;}`;\n\n/**\n * Port of zod's `util.finalizeIssue` for issues NESTED inside an\n * `invalid_key` / `invalid_element` wrapper. Those never reach the top-level\n * finalization loop (which walks only the outer array), so zod finalizes them\n * where it builds the wrapper: locale message applied when none was baked in,\n * `input` cleared. Their `path` stays RELATIVE to the key or value schema — zod\n * ran it on a fresh payload — so nothing rewrites it.\n *\n * `input` is cleared by assignment rather than `delete`, matching the top-level\n * finalizer and the union's per-option loop.\n */\nexport const ZC_FZ_DECL =\n \"function __zcFz(e){for(var i=0;i<e.length;i++){var s=e[i];\" +\n 'if(s.message===undefined&&typeof __zcMsg===\"function\")s.message=__zcMsg(s);' +\n \"s.input=undefined;}return e;}\";\n\n/**\n * Port of zod's `util.prefixIssues(key, issues)` for a map entry whose key is a\n * property-key type: each issue's RELATIVE path is spliced onto the map's own\n * path plus the key, and the issue moves into the parent's array.\n *\n * `b.concat(k,x.path)` flattens `x.path` one level, giving exactly\n * `[...base, key, ...relative]`.\n */\nexport const ZC_PFX_DECL =\n \"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);}}\";\n\n/** Does `keyExpr` hold one of zod's `util.propertyKeyTypes` (string|number|symbol)? */\nexport function propertyKeyTest(keyExpr: string): string {\n return `typeof ${keyExpr}===\"string\"||typeof ${keyExpr}===\"number\"||typeof ${keyExpr}===\"symbol\"`;\n}\n\n/**\n * superRefine fast-check: run the payload callback on a throwaway payload and\n * report whether it both added nothing AND left the value alone. zod's own\n * wrapper (the referenced function) installs `addIssue` and normalizes what the\n * user adds, so the verdict is zod's; the issues themselves are re-collected by\n * the slow walk.\n *\n * The `p.value===v` half is what lets a superRefine node keep a fast path at\n * all. `value` is writable public API ($RefinementCtx extends ParsePayload), so\n * a callback may rewrite it, and the fast path's caller returns the ORIGINAL\n * input on success — which would then be stale. Reporting false when the value\n * moved routes those parses into the slow walk, which propagates the new value\n * (see ZC_SR_DECL). Callbacks that only validate — effectively all of them —\n * still take the fast exit.\n */\nexport const ZC_SR_OK_DECL =\n \"function __zcSrOk(f,v){var p={value:v,issues:[]};__zcSrRun(f,p);\" +\n \"return p.issues.length===0&&p.value===v;}\";\n\n/**\n * Module-local (never imported by generated code) — __zcSr/__zcSrOk call it.\n * Lean mode declares it in the runtime module beside them; inline mode pushes it\n * into the preamble alongside whichever of the two is used.\n *\n * Invoke the referenced wrapper, reproducing zod's synchronous-parse contract:\n * a callback that returns a promise makes zod raise $ZodAsyncError rather than\n * silently accepting. Because the ref points at zod's superRefine WRAPPER, not\n * the user's function, an async callback cannot be detected while extracting —\n * the returned thenable is the only evidence, so the test lives here. Sync\n * callbacks return undefined, so the guard short-circuits on the first operand.\n */\nexport const ZC_SR_RUN_DECL =\n \"function __zcSrRun(f,p){var r=f(p);\" +\n 'if(r&&typeof r.then===\"function\"){throw new __zcCore.$ZodAsyncError();}}';\n\n/**\n * superRefine slow-path merge: run the callback, then move its issues onto the\n * validator's list the way zod's finalizeIssue does — the node's path prefixed\n * onto any path the user supplied, and the internal `inst`/`continue` fields\n * dropped (they are zod bookkeeping, deleted before the issue is user-visible).\n *\n * Returns the payload, so the caller can write `.value` back (the callback may\n * have rewritten it) and read `.aborted`. Aborted is set when any issue aborts\n * in zod's sense (`continue !== true`, which covers `fatal: true` and the string\n * shorthand, whose issue carries no `continue` at all) — or when the callback\n * set it directly, also public payload API. A union option uses it to mark\n * itself aborted, matching how zod prunes option errors; without it an option\n * failing only through superRefine would be surfaced directly instead of inside\n * `invalid_union`.\n */\nexport const ZC_SR_DECL =\n \"function __zcSr(f,v,p,e){var q={value:v,issues:[]};__zcSrRun(f,q);\" +\n \"for(var i=0;i<q.issues.length;i++){var s=q.issues[i],t={};\" +\n 'for(var k in s){if(k!==\"inst\"&&k!==\"continue\")t[k]=s[k];}' +\n \"if(s.continue!==true)q.aborted=true;\" +\n \"t.path=s.path&&s.path.length?p.concat(s.path):p;e.push(t);}return q;}\";\n\n/** Non-issue runtime helper declarations hosted in the virtual module. */\nexport const RUNTIME_HELPER_DECLS: Readonly<Record<string, string>> = {\n __zcAb: ZC_AB_DECL,\n __zcFsr: ZC_FSR_DECL,\n __zcFz: ZC_FZ_DECL,\n __zcHop: ZC_HOP_DECL,\n __zcPfx: ZC_PFX_DECL,\n __zcSr: ZC_SR_DECL,\n __zcSrOk: ZC_SR_OK_DECL,\n};\n"],"mappings":";AA4CA,MAAa,cAAgD;CAC3D,QAAQ;CACR,SAAS;CACT,QAAQ;CACR,SAAS;CACT,QAAQ;CACR,QAAQ;CACR,QAAQ;CACR,QAAQ;AACV;;;;;;AAOA,MAAa,cACX;;;;;;;;;;AAWF,MAAa,cAAc;;;;;;;;;;;;;;AAe3B,MAAM,uBAA0C;CAC9C;CACA;CACA;CACA;CACA;CACA;AACF;;AAGA,SAAgB,iBAAiB,UAA0B;CACzD,OAAO,qBAAqB,KAAK,SAAS,GAAG,SAAS,KAAK,KAAK,UAAU,IAAI,GAAG,CAAC,CAAC,KAAK,IAAI;AAC9F;;;;;;;;;;;;;;;AAgBA,MAAa,aAAa,gEAAgE,iBAAiB,GAAG,EAAE;;;;;;;;;;;;AAahH,MAAa,aACX;;;;;;;;;AAYF,MAAa,cACX;;AAGF,SAAgB,gBAAgB,SAAyB;CACvD,OAAO,UAAU,QAAQ,sBAAsB,QAAQ,sBAAsB,QAAQ;AACvF;;;;;;;;;;;;;;;;AAiBA,MAAa,gBACX;;;;;;;;;;;;;AAeF,MAAa,iBACX;;;;;;;;;;;;;;;;AAkBF,MAAa,aACX;;AAOF,MAAa,uBAAyD;CACpE,QAAQ;CACR,SAAS;CACT,QAAQ;CACR,SAAS;CACT,SAAS;CACT,QAAQ;CACR,UAAU;AACZ"}
|
|
1
|
+
{"version":3,"file":"issue-decls.js","names":[],"sources":["../../../src/core/codegen/issue-decls.ts"],"sourcesContent":["/**\n * Issue factory function bodies (statement form).\n *\n * These functions produce the same `{code, ...}` shapes that lean-mode\n * generated code would otherwise inline at every check site.\n * Hosted in \"virtual:zod-compiler/runtime\" and called as `__zcTS(...)` etc.\n *\n * Argument convention (positional, kept short to minimize call-site bytes):\n * __zcTS(minimum, origin, inclusive, input, path, msg?) — too_small\n * __zcTB(maximum, origin, inclusive, input, path, msg?) — too_big\n * __zcIT(expected, input, path, msg?) — invalid_type\n * __zcIF(format, input, path, extra?, msg?) — invalid_format (extra merged into result)\n * __zcIV(values, input, path, msg?) — invalid_value\n * __zcUK(keys, input, path, msg?) — unrecognized_keys\n *\n * The trailing msg argument carries a static custom error message; when\n * absent, the __zcFin finalizer applies the configured locale default.\n */\n\nconst ZC_TS_DECL =\n 'function __zcTS(m,o,i,inp,p,msg){var r={code:\"too_small\",minimum:m,origin:o,inclusive:i,input:inp,path:p};if(msg!==undefined)r.message=msg;return r;}';\n\nconst ZC_TS_EXACT_DECL =\n 'function __zcTSx(m,o,inp,p,msg){var r={code:\"too_small\",minimum:m,origin:o,inclusive:true,exact:true,input:inp,path:p};if(msg!==undefined)r.message=msg;return r;}';\n\nconst ZC_TB_DECL =\n 'function __zcTB(m,o,i,inp,p,msg){var r={code:\"too_big\",maximum:m,origin:o,inclusive:i,input:inp,path:p};if(msg!==undefined)r.message=msg;return r;}';\n\nconst ZC_TB_EXACT_DECL =\n 'function __zcTBx(m,o,inp,p,msg){var r={code:\"too_big\",maximum:m,origin:o,inclusive:true,exact:true,input:inp,path:p};if(msg!==undefined)r.message=msg;return r;}';\n\nconst ZC_IT_DECL =\n 'function __zcIT(e,inp,p,msg){var r={code:\"invalid_type\",expected:e,input:inp,path:p};if(msg!==undefined)r.message=msg;return r;}';\n\nconst ZC_IF_DECL =\n 'function __zcIF(f,inp,p,extra,msg){var r={code:\"invalid_format\",format:f,input:inp,path:p};if(extra)Object.assign(r,extra);if(msg!==undefined)r.message=msg;return r;}';\n\nconst ZC_IV_DECL =\n 'function __zcIV(values,inp,p,msg){var r={code:\"invalid_value\",values:values,input:inp,path:p};if(msg!==undefined)r.message=msg;return r;}';\n\nconst ZC_UK_DECL =\n '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;}';\n\n/** All issue factory declarations indexed by helper name. */\nexport const ISSUE_DECLS: Readonly<Record<string, string>> = {\n __zcTS: ZC_TS_DECL,\n __zcTSx: ZC_TS_EXACT_DECL,\n __zcTB: ZC_TB_DECL,\n __zcTBx: ZC_TB_EXACT_DECL,\n __zcIT: ZC_IT_DECL,\n __zcIF: ZC_IF_DECL,\n __zcIV: ZC_IV_DECL,\n __zcUK: ZC_UK_DECL,\n};\n\n/**\n * Float-safe remainder — byte-for-byte port of zod's util.floatSafeRemainder.\n * Raw `%` mis-rejects valid multiples of decimal steps (0.3 % 0.1 !== 0);\n * zod scales both operands to integers by their decimal-place count first.\n */\nexport const ZC_FSR_DECL =\n '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);}';\n\n/**\n * Hoisted `Object.prototype.hasOwnProperty` reference. Record fast/slow paths\n * iterate keys with `for(k in o)` (no `Object.keys` array allocation) and guard\n * each key with `__zcHop.call(o,k)` to skip inherited enumerable properties —\n * yielding the exact own-enumerable string-key set `Object.keys` would, so\n * fast/slow stay in agreement and parity with zod's own-key record semantics is\n * preserved. The hoisted reference inlines in V8; reading the prototype property\n * per call would not.\n */\nexport const ZC_HOP_DECL = \"const __zcHop=Object.prototype.hasOwnProperty;\";\n\n/**\n * Issue codes zod raises from a schema's `_zod.parse` rather than from a check,\n * and which therefore carry `continue !== true` — what `util.aborted` looks for.\n *\n * Everything a CHECK produces (`too_small`, `too_big`, `invalid_format`,\n * `not_multiple_of`, a refine's `custom`) is continuable, because `$ZodCheck`\n * sets `continue: !def.abort` and an `abort: true` check costs the schema its\n * compiled path anyway — so classifying by code alone is exact for generated\n * issues.\n *\n * Read by {@link ZC_AB_DECL} and by the union's option-pruning loop, which\n * applies the same rule inline over a per-option issue array.\n */\nconst ABORTING_ISSUE_CODES: readonly string[] = [\n \"invalid_type\",\n \"invalid_value\",\n \"invalid_union\",\n \"unrecognized_keys\",\n \"invalid_key\",\n \"invalid_element\",\n];\n\n/** `c===\"invalid_type\"||c===\"invalid_value\"||…` over the code held in `codeExpr`. */\nexport function abortingCodeTest(codeExpr: string): string {\n return ABORTING_ISSUE_CODES.map((code) => `${codeExpr}===${JSON.stringify(code)}`).join(\"||\");\n}\n\n/**\n * Port of zod's `util.aborted(payload, startIndex)`: has anything since\n * `startIndex` produced a NON-continuable issue?\n *\n * zod gates a schema's check chain on this (`runChecks`: `else if (isAborted)\n * continue`), which is what makes a container's `.refine()` still run after a\n * property or element failed its own `min`/`max`/format check, and stop running\n * once one failed to parse at all. The `startIndex` is the issue count when the\n * node was entered, mirroring the fresh payload zod hands each sub-schema.\n *\n * Size/length checks are exempt in zod — they declare a `when` predicate, which\n * bypasses the abort gate — so generated code leaves those ungated and only\n * wraps the refine/superRefine effects.\n */\nexport const ZC_AB_DECL = `function __zcAb(e,i){for(;i<e.length;i++){var c=e[i].code;if(${abortingCodeTest(\"c\")})return true;}return false;}`;\n\n/**\n * Port of zod's `util.finalizeIssue` for issues NESTED inside an\n * `invalid_key` / `invalid_element` wrapper. Those never reach the top-level\n * finalization loop (which walks only the outer array), so zod finalizes them\n * where it builds the wrapper: locale message applied when none was baked in,\n * `input` cleared. Their `path` stays RELATIVE to the key or value schema — zod\n * ran it on a fresh payload — so nothing rewrites it.\n *\n * `input` is cleared by assignment rather than `delete`, matching the top-level\n * finalizer and the union's per-option loop.\n */\nexport const ZC_FZ_DECL =\n \"function __zcFz(e){for(var i=0;i<e.length;i++){var s=e[i];\" +\n 'if(s.message===undefined&&typeof __zcMsg===\"function\")s.message=__zcMsg(s);' +\n \"s.input=undefined;}return e;}\";\n\n/**\n * Port of zod's `util.prefixIssues(key, issues)` for a map entry whose key is a\n * property-key type: each issue's RELATIVE path is spliced onto the map's own\n * path plus the key, and the issue moves into the parent's array.\n *\n * `b.concat(k,x.path)` flattens `x.path` one level, giving exactly\n * `[...base, key, ...relative]`.\n */\nexport const ZC_PFX_DECL =\n \"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);}}\";\n\n/** Does `keyExpr` hold one of zod's `util.propertyKeyTypes` (string|number|symbol)? */\nexport function propertyKeyTest(keyExpr: string): string {\n return `typeof ${keyExpr}===\"string\"||typeof ${keyExpr}===\"number\"||typeof ${keyExpr}===\"symbol\"`;\n}\n\n/**\n * superRefine fast-check: run the payload callback on a throwaway payload and\n * report whether it both added nothing AND left the value alone. zod's own\n * wrapper (the referenced function) installs `addIssue` and normalizes what the\n * user adds, so the verdict is zod's; the issues themselves are re-collected by\n * the slow walk.\n *\n * The `p.value===v` half is what lets a superRefine node keep a fast path at\n * all. `value` is writable public API ($RefinementCtx extends ParsePayload), so\n * a callback may rewrite it, and the fast path's caller returns the ORIGINAL\n * input on success — which would then be stale. Reporting false when the value\n * moved routes those parses into the slow walk, which propagates the new value\n * (see ZC_SR_DECL). Callbacks that only validate — effectively all of them —\n * still take the fast exit.\n */\nexport const ZC_SR_OK_DECL =\n \"function __zcSrOk(f,v){var p={value:v,issues:[]};__zcSrRun(f,p);\" +\n \"return p.issues.length===0&&p.value===v;}\";\n\n/**\n * Module-local (never imported by generated code) — __zcSr/__zcSrOk call it.\n * Lean mode declares it in the runtime module beside them; inline mode pushes it\n * into the preamble alongside whichever of the two is used.\n *\n * Invoke the referenced wrapper, reproducing zod's synchronous-parse contract:\n * a callback that returns a promise makes zod raise $ZodAsyncError rather than\n * silently accepting. Because the ref points at zod's superRefine WRAPPER, not\n * the user's function, an async callback cannot be detected while extracting —\n * the returned thenable is the only evidence, so the test lives here. Sync\n * callbacks return undefined, so the guard short-circuits on the first operand.\n */\nexport const ZC_SR_RUN_DECL =\n \"function __zcSrRun(f,p){var r=f(p);\" +\n 'if(r&&typeof r.then===\"function\"){throw new __zcCore.$ZodAsyncError();}}';\n\n/**\n * z.custom()/z.instanceof() fast verdict. Zod treats truthy predicate returns\n * as success and raises $ZodAsyncError when a synchronous parse encounters a\n * thenable, including a non-async function that happens to return a Promise.\n */\nexport const ZC_CUSTOM_OK_DECL =\n \"function __zcCu(f,v){var r=f(v);\" +\n 'if(r&&typeof r.then===\"function\"){throw new __zcCore.$ZodAsyncError();}return !!r;}';\n\n/**\n * superRefine slow-path merge: run the callback, then move its issues onto the\n * validator's list the way zod's finalizeIssue does — the node's path prefixed\n * onto any path the user supplied, and the internal `inst`/`continue` fields\n * dropped (they are zod bookkeeping, deleted before the issue is user-visible).\n *\n * Returns the payload, so the caller can write `.value` back (the callback may\n * have rewritten it) and read `.aborted`. Aborted is set when any issue aborts\n * in zod's sense (`continue !== true`, which covers `fatal: true` and the string\n * shorthand, whose issue carries no `continue` at all) — or when the callback\n * set it directly, also public payload API. A union option uses it to mark\n * itself aborted, matching how zod prunes option errors; without it an option\n * failing only through superRefine would be surfaced directly instead of inside\n * `invalid_union`.\n */\nexport const ZC_SR_DECL =\n \"function __zcSr(f,v,p,e){var q={value:v,issues:[]};__zcSrRun(f,q);\" +\n \"for(var i=0;i<q.issues.length;i++){var s=q.issues[i],t={};\" +\n 'for(var k in s){if(k!==\"inst\"&&k!==\"continue\")t[k]=s[k];}' +\n \"if(s.continue!==true)q.aborted=true;\" +\n \"t.path=s.path&&s.path.length?p.concat(s.path):p;e.push(t);}return q;}\";\n\n/** Non-issue runtime helper declarations hosted in the virtual module. */\nexport const RUNTIME_HELPER_DECLS: Readonly<Record<string, string>> = {\n __zcAb: ZC_AB_DECL,\n __zcFsr: ZC_FSR_DECL,\n __zcFz: ZC_FZ_DECL,\n __zcHop: ZC_HOP_DECL,\n __zcPfx: ZC_PFX_DECL,\n __zcCu: ZC_CUSTOM_OK_DECL,\n __zcSr: ZC_SR_DECL,\n __zcSrOk: ZC_SR_OK_DECL,\n};\n"],"mappings":";AA4CA,MAAa,cAAgD;CAC3D,QAAQ;CACR,SAAS;CACT,QAAQ;CACR,SAAS;CACT,QAAQ;CACR,QAAQ;CACR,QAAQ;CACR,QAAQ;AACV;;;;;;AAOA,MAAa,cACX;;;;;;;;;;AAWF,MAAa,cAAc;;;;;;;;;;;;;;AAe3B,MAAM,uBAA0C;CAC9C;CACA;CACA;CACA;CACA;CACA;AACF;;AAGA,SAAgB,iBAAiB,UAA0B;CACzD,OAAO,qBAAqB,KAAK,SAAS,GAAG,SAAS,KAAK,KAAK,UAAU,IAAI,GAAG,CAAC,CAAC,KAAK,IAAI;AAC9F;;;;;;;;;;;;;;;AAgBA,MAAa,aAAa,gEAAgE,iBAAiB,GAAG,EAAE;;;;;;;;;;;;AAahH,MAAa,aACX;;;;;;;;;AAYF,MAAa,cACX;;AAGF,SAAgB,gBAAgB,SAAyB;CACvD,OAAO,UAAU,QAAQ,sBAAsB,QAAQ,sBAAsB,QAAQ;AACvF;;;;;;;;;;;;;;;;AAiBA,MAAa,gBACX;;;;;;;;;;;;;AAeF,MAAa,iBACX;;;;;;AAQF,MAAa,oBACX;;;;;;;;;;;;;;;;AAkBF,MAAa,aACX;;AAOF,MAAa,uBAAyD;CACpE,QAAQ;CACR,SAAS;CACT,QAAQ;CACR,SAAS;CACT,SAAS;CACT,QAAQ;CACR,QAAQ;CACR,UAAU;AACZ"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CustomIR } from "../../types.js";
|
|
2
|
+
import { FastGen, SlowGen } from "../context.js";
|
|
3
|
+
//#region src/core/codegen/schemas/custom.d.ts
|
|
4
|
+
/** Total hot-path predicate for z.custom() and z.instanceof(). */
|
|
5
|
+
declare function fastCustom(ir: CustomIR, g: FastGen): string;
|
|
6
|
+
/** Let Zod construct the exact custom/instanceof issue only after rejection. */
|
|
7
|
+
declare function slowCustom(ir: CustomIR, g: SlowGen): string;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { fastCustom, slowCustom };
|
|
10
|
+
//# sourceMappingURL=custom.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custom.d.ts","names":[],"sources":["../../../../src/core/codegen/schemas/custom.ts"],"mappings":";;;;iBAOgB,WAAW,IAAI,UAAU,GAAG;;iBAM5B,WAAW,IAAI,UAAU,GAAG"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { emitEffectCallable, emitRuntimeHelper } from "../context.js";
|
|
2
|
+
import { ZC_CUSTOM_OK_DECL } from "../issue-decls.js";
|
|
3
|
+
import { slowZodDelegate } from "./fallback.js";
|
|
4
|
+
//#region src/core/codegen/schemas/custom.ts
|
|
5
|
+
/** Total hot-path predicate for z.custom() and z.instanceof(). */
|
|
6
|
+
function fastCustom(ir, g) {
|
|
7
|
+
return `${emitRuntimeHelper(g.ctx, "__zcCu", ZC_CUSTOM_OK_DECL)}(${emitEffectCallable(g.ctx, ir)},${g.input})`;
|
|
8
|
+
}
|
|
9
|
+
/** Let Zod construct the exact custom/instanceof issue only after rejection. */
|
|
10
|
+
function slowCustom(ir, g) {
|
|
11
|
+
const onFailure = ir.abort && g.aborted ? `${g.aborted}=true;` : "";
|
|
12
|
+
return slowZodDelegate(ir.schemaRefIndex, g, onFailure);
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
export { fastCustom, slowCustom };
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=custom.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custom.js","names":[],"sources":["../../../../src/core/codegen/schemas/custom.ts"],"sourcesContent":["import type { CustomIR } from \"../../types.js\";\nimport type { FastGen, SlowGen } from \"../context.js\";\nimport { emitEffectCallable, emitRuntimeHelper } from \"../context.js\";\nimport { ZC_CUSTOM_OK_DECL } from \"../issue-decls.js\";\nimport { slowZodDelegate } from \"./fallback.js\";\n\n/** Total hot-path predicate for z.custom() and z.instanceof(). */\nexport function fastCustom(ir: CustomIR, g: FastGen): string {\n const ok = emitRuntimeHelper(g.ctx, \"__zcCu\", ZC_CUSTOM_OK_DECL);\n return `${ok}(${emitEffectCallable(g.ctx, ir)},${g.input})`;\n}\n\n/** Let Zod construct the exact custom/instanceof issue only after rejection. */\nexport function slowCustom(ir: CustomIR, g: SlowGen): string {\n const onFailure = ir.abort && g.aborted ? `${g.aborted}=true;` : \"\";\n return slowZodDelegate(ir.schemaRefIndex, g, onFailure);\n}\n"],"mappings":";;;;;AAOA,SAAgB,WAAW,IAAc,GAAoB;CAE3D,OAAO,GADI,kBAAkB,EAAE,KAAK,UAAU,iBACnC,EAAE,GAAG,mBAAmB,EAAE,KAAK,EAAE,EAAE,GAAG,EAAE,MAAM;AAC3D;;AAGA,SAAgB,WAAW,IAAc,GAAoB;CAC3D,MAAM,YAAY,GAAG,SAAS,EAAE,UAAU,GAAG,EAAE,QAAQ,UAAU;CACjE,OAAO,gBAAgB,GAAG,gBAAgB,GAAG,SAAS;AACxD"}
|
|
@@ -2,6 +2,8 @@ import { FallbackIR } from "../../types.js";
|
|
|
2
2
|
import { SlowGen } from "../context.js";
|
|
3
3
|
//#region src/core/codegen/schemas/fallback.d.ts
|
|
4
4
|
declare function slowFallback(ir: FallbackIR, g: SlowGen): string;
|
|
5
|
+
/** Delegate a cold slow-walk leaf to a pristine retained Zod schema. */
|
|
6
|
+
declare function slowZodDelegate(refIndex: number, g: SlowGen, onFailure?: string): string;
|
|
5
7
|
//#endregion
|
|
6
|
-
export { slowFallback };
|
|
8
|
+
export { slowFallback, slowZodDelegate };
|
|
7
9
|
//# sourceMappingURL=fallback.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fallback.d.ts","names":[],"sources":["../../../../src/core/codegen/schemas/fallback.ts"],"mappings":";;;iBAKgB,aAAa,IAAI,YAAY,GAAG"}
|
|
1
|
+
{"version":3,"file":"fallback.d.ts","names":[],"sources":["../../../../src/core/codegen/schemas/fallback.ts"],"mappings":";;;iBAKgB,aAAa,IAAI,YAAY,GAAG;;iBAQhC,gBAAgB,kBAAkB,GAAG,SAAS"}
|
|
@@ -2,28 +2,31 @@ import { emitRfDelegate } from "../context.js";
|
|
|
2
2
|
import { emit } from "../emit.js";
|
|
3
3
|
//#region src/core/codegen/schemas/fallback.ts
|
|
4
4
|
function slowFallback(ir, g) {
|
|
5
|
-
if (ir.refIndex !== void 0)
|
|
6
|
-
const idx = ir.refIndex;
|
|
7
|
-
const delegate = emitRfDelegate(g.ctx, idx);
|
|
8
|
-
const rVar = `__rf_r${idx}`;
|
|
9
|
-
const iVar = `__rf_i${idx}`;
|
|
10
|
-
const jVar = `__rf_j${idx}`;
|
|
11
|
-
return `${emit`
|
|
12
|
-
var ${rVar}=${delegate}(${g.input});
|
|
13
|
-
if(!${rVar}.success){
|
|
14
|
-
var ${iVar}=${rVar}.error.issues;
|
|
15
|
-
for(var ${jVar}=0;${jVar}<${iVar}.length;${jVar}++){
|
|
16
|
-
${g.issues}.push({...${iVar}[${jVar}],
|
|
17
|
-
path:${g.path}.concat(${iVar}[${jVar}].path)});
|
|
18
|
-
}
|
|
19
|
-
}else{
|
|
20
|
-
${g.output}=${rVar}.data;
|
|
21
|
-
}
|
|
22
|
-
`}\n`;
|
|
23
|
-
}
|
|
5
|
+
if (ir.refIndex !== void 0) return slowZodDelegate(ir.refIndex, g);
|
|
24
6
|
return `${g.issues}.push({code:"custom",path:${g.path},message:"Fallback schema: ${ir.reason}"});\n`;
|
|
25
7
|
}
|
|
8
|
+
/** Delegate a cold slow-walk leaf to a pristine retained Zod schema. */
|
|
9
|
+
function slowZodDelegate(refIndex, g, onFailure = "") {
|
|
10
|
+
const idx = refIndex;
|
|
11
|
+
const delegate = emitRfDelegate(g.ctx, idx);
|
|
12
|
+
const rVar = `__rf_r${idx}`;
|
|
13
|
+
const iVar = `__rf_i${idx}`;
|
|
14
|
+
const jVar = `__rf_j${idx}`;
|
|
15
|
+
return `${emit`
|
|
16
|
+
var ${rVar}=${delegate}(${g.input});
|
|
17
|
+
if(!${rVar}.success){
|
|
18
|
+
${onFailure}
|
|
19
|
+
var ${iVar}=${rVar}.error.issues;
|
|
20
|
+
for(var ${jVar}=0;${jVar}<${iVar}.length;${jVar}++){
|
|
21
|
+
${g.issues}.push({...${iVar}[${jVar}],
|
|
22
|
+
path:${g.path}.concat(${iVar}[${jVar}].path)});
|
|
23
|
+
}
|
|
24
|
+
}else{
|
|
25
|
+
${g.output}=${rVar}.data;
|
|
26
|
+
}
|
|
27
|
+
`}\n`;
|
|
28
|
+
}
|
|
26
29
|
//#endregion
|
|
27
|
-
export { slowFallback };
|
|
30
|
+
export { slowFallback, slowZodDelegate };
|
|
28
31
|
|
|
29
32
|
//# sourceMappingURL=fallback.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fallback.js","names":[],"sources":["../../../../src/core/codegen/schemas/fallback.ts"],"sourcesContent":["import type { FallbackIR } from \"../../types.js\";\nimport type { SlowGen } from \"../context.js\";\nimport { emitRfDelegate } from \"../context.js\";\nimport { emit } from \"../emit.js\";\n\nexport function slowFallback(ir: FallbackIR, g: SlowGen): string {\n if (ir.refIndex !== undefined) {\n const idx =
|
|
1
|
+
{"version":3,"file":"fallback.js","names":[],"sources":["../../../../src/core/codegen/schemas/fallback.ts"],"sourcesContent":["import type { FallbackIR } from \"../../types.js\";\nimport type { SlowGen } from \"../context.js\";\nimport { emitRfDelegate } from \"../context.js\";\nimport { emit } from \"../emit.js\";\n\nexport function slowFallback(ir: FallbackIR, g: SlowGen): string {\n if (ir.refIndex !== undefined) {\n return slowZodDelegate(ir.refIndex, g);\n }\n return `${g.issues}.push({code:\"custom\",path:${g.path},message:\"Fallback schema: ${ir.reason}\"});\\n`;\n}\n\n/** Delegate a cold slow-walk leaf to a pristine retained Zod schema. */\nexport function slowZodDelegate(refIndex: number, g: SlowGen, onFailure = \"\"): string {\n const idx = refIndex;\n // Captured pre-__zcMkv (emitRfDelegate): a per-parse `__rf[N].safeParse`\n // read resolves to the compiled validator itself when CSE/dedup or an\n // identifier schemaExpr makes the entry alias the mutated schema object.\n const delegate = emitRfDelegate(g.ctx, idx);\n const rVar = `__rf_r${idx}`;\n const iVar = `__rf_i${idx}`;\n const jVar = `__rf_j${idx}`;\n return `${emit`\n var ${rVar}=${delegate}(${g.input});\n if(!${rVar}.success){\n ${onFailure}\n var ${iVar}=${rVar}.error.issues;\n for(var ${jVar}=0;${jVar}<${iVar}.length;${jVar}++){\n ${g.issues}.push({...${iVar}[${jVar}],\n path:${g.path}.concat(${iVar}[${jVar}].path)});\n }\n }else{\n ${g.output}=${rVar}.data;\n }\n `}\\n`;\n}\n"],"mappings":";;;AAKA,SAAgB,aAAa,IAAgB,GAAoB;CAC/D,IAAI,GAAG,aAAa,KAAA,GAClB,OAAO,gBAAgB,GAAG,UAAU,CAAC;CAEvC,OAAO,GAAG,EAAE,OAAO,4BAA4B,EAAE,KAAK,6BAA6B,GAAG,OAAO;AAC/F;;AAGA,SAAgB,gBAAgB,UAAkB,GAAY,YAAY,IAAY;CACpF,MAAM,MAAM;CAIZ,MAAM,WAAW,eAAe,EAAE,KAAK,GAAG;CAC1C,MAAM,OAAO,SAAS;CACtB,MAAM,OAAO,SAAS;CACtB,MAAM,OAAO,SAAS;CACtB,OAAO,GAAG,IAAI;UACN,KAAK,GAAG,SAAS,GAAG,EAAE,MAAM;UAC5B,KAAK;QACP,UAAU;YACN,KAAK,GAAG,KAAK;gBACT,KAAK,KAAK,KAAK,GAAG,KAAK,UAAU,KAAK;UAC5C,EAAE,OAAO,YAAY,KAAK,GAAG,KAAK;iBAC3B,EAAE,KAAK,UAAU,KAAK,GAAG,KAAK;;;QAGvC,EAAE,OAAO,GAAG,KAAK;;IAErB;AACJ"}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { StringBoolIR } from "../../types.js";
|
|
2
|
-
import { SlowGen } from "../context.js";
|
|
2
|
+
import { CodeGenContext, SlowGen } from "../context.js";
|
|
3
3
|
//#region src/core/codegen/schemas/string-bool.d.ts
|
|
4
4
|
declare function slowStringBool(ir: StringBoolIR, g: SlowGen): string;
|
|
5
|
+
declare function stringBoolUsesInline(ir: StringBoolIR): boolean;
|
|
6
|
+
/** One lookup distinguishes true, false and absent; shared by hot and issue walks. */
|
|
7
|
+
declare function emitStringBoolMap(ir: StringBoolIR, ctx: CodeGenContext): string;
|
|
5
8
|
//#endregion
|
|
6
|
-
export { slowStringBool };
|
|
9
|
+
export { emitStringBoolMap, slowStringBool, stringBoolUsesInline };
|
|
7
10
|
//# sourceMappingURL=string-bool.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"string-bool.d.ts","names":[],"sources":["../../../../src/core/codegen/schemas/string-bool.ts"],"mappings":";;;iBAMgB,eAAe,IAAI,cAAc,GAAG"}
|
|
1
|
+
{"version":3,"file":"string-bool.d.ts","names":[],"sources":["../../../../src/core/codegen/schemas/string-bool.ts"],"mappings":";;;iBAMgB,eAAe,IAAI,cAAc,GAAG;iBAyCpC,qBAAqB,IAAI;;iBAKzB,kBAAkB,IAAI,cAAc,KAAK"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { escapeString } from "../context.js";
|
|
1
|
+
import { emitConstant, escapeString } from "../context.js";
|
|
2
2
|
import { emit } from "../emit.js";
|
|
3
3
|
import { invalidType, invalidValue } from "../emit-issue.js";
|
|
4
4
|
//#region src/core/codegen/schemas/string-bool.ts
|
|
@@ -9,10 +9,11 @@ function slowStringBool(ir, g) {
|
|
|
9
9
|
${invalidType(g, "string")}
|
|
10
10
|
}else{
|
|
11
11
|
`;
|
|
12
|
-
const normalized = ir.caseSensitive ? g.input :
|
|
12
|
+
const normalized = ir.caseSensitive ? g.input : g.temp("sbn");
|
|
13
|
+
if (!ir.caseSensitive) code += `var ${normalized}=${g.input}.toLowerCase();`;
|
|
13
14
|
const allValues = [...ir.truthy, ...ir.falsy];
|
|
14
15
|
const valuesExpr = JSON.stringify(allValues);
|
|
15
|
-
if (ir
|
|
16
|
+
if (stringBoolUsesInline(ir)) {
|
|
16
17
|
const truthyCondition = ir.truthy.map((v) => `${normalized}===${escapeString(v)}`).join("||");
|
|
17
18
|
const falsyCondition = ir.falsy.map((v) => `${normalized}===${escapeString(v)}`).join("||");
|
|
18
19
|
code += emit`
|
|
@@ -21,18 +22,26 @@ function slowStringBool(ir, g) {
|
|
|
21
22
|
else{${invalidValue(g, valuesExpr)}}
|
|
22
23
|
`;
|
|
23
24
|
} else {
|
|
24
|
-
const
|
|
25
|
-
const
|
|
25
|
+
const value = g.temp("sbv");
|
|
26
|
+
const lookup = emitStringBoolMap(ir, g.ctx);
|
|
26
27
|
code += emit`
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
else{${
|
|
28
|
+
var ${value}=${lookup}.get(${normalized});
|
|
29
|
+
if(${value}===undefined){${invalidValue(g, valuesExpr)}}
|
|
30
|
+
else{${g.output}=${value};}
|
|
30
31
|
`;
|
|
31
32
|
}
|
|
32
33
|
code += emit`}`;
|
|
33
34
|
return `${code}\n`;
|
|
34
35
|
}
|
|
36
|
+
function stringBoolUsesInline(ir) {
|
|
37
|
+
return ir.truthy.length <= 5 && ir.falsy.length <= 5;
|
|
38
|
+
}
|
|
39
|
+
/** One lookup distinguishes true, false and absent; shared by hot and issue walks. */
|
|
40
|
+
function emitStringBoolMap(ir, ctx) {
|
|
41
|
+
const pairs = [...ir.truthy.map((value) => [value, true]), ...ir.falsy.map((value) => [value, false])];
|
|
42
|
+
return emitConstant(ctx, "map_sb", `new Map(${JSON.stringify(pairs)})`);
|
|
43
|
+
}
|
|
35
44
|
//#endregion
|
|
36
|
-
export { slowStringBool };
|
|
45
|
+
export { emitStringBoolMap, slowStringBool, stringBoolUsesInline };
|
|
37
46
|
|
|
38
47
|
//# sourceMappingURL=string-bool.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"string-bool.js","names":[],"sources":["../../../../src/core/codegen/schemas/string-bool.ts"],"sourcesContent":["import type { StringBoolIR } from \"../../types.js\";\nimport type { SlowGen } from \"../context.js\";\nimport { ENUM_INLINE_THRESHOLD, escapeString } from \"../context.js\";\nimport { emit } from \"../emit.js\";\nimport { invalidType, invalidValue } from \"../emit-issue.js\";\n\nexport function slowStringBool(ir: StringBoolIR, g: SlowGen): string {\n let code = \"\";\n\n // Type check: input must be a string\n code += emit`\n if(typeof ${g.input}!==\"string\"){\n ${invalidType(g, \"string\")}\n }else{\n `;\n\n // Normalize input for case-insensitive matching\n const normalized = ir.caseSensitive ? g.input :
|
|
1
|
+
{"version":3,"file":"string-bool.js","names":[],"sources":["../../../../src/core/codegen/schemas/string-bool.ts"],"sourcesContent":["import type { StringBoolIR } from \"../../types.js\";\nimport type { CodeGenContext, SlowGen } from \"../context.js\";\nimport { ENUM_INLINE_THRESHOLD, emitConstant, escapeString } from \"../context.js\";\nimport { emit } from \"../emit.js\";\nimport { invalidType, invalidValue } from \"../emit-issue.js\";\n\nexport function slowStringBool(ir: StringBoolIR, g: SlowGen): string {\n let code = \"\";\n\n // Type check: input must be a string\n code += emit`\n if(typeof ${g.input}!==\"string\"){\n ${invalidType(g, \"string\")}\n }else{\n `;\n\n // Normalize input for case-insensitive matching\n const normalized = ir.caseSensitive ? g.input : g.temp(\"sbn\");\n if (!ir.caseSensitive) code += `var ${normalized}=${g.input}.toLowerCase();`;\n const allValues = [...ir.truthy, ...ir.falsy];\n const valuesExpr = JSON.stringify(allValues);\n\n // Compare per-side counts against threshold (not the combined total)\n const useInline = stringBoolUsesInline(ir);\n\n if (useInline) {\n const truthyCondition = ir.truthy.map((v) => `${normalized}===${escapeString(v)}`).join(\"||\");\n const falsyCondition = ir.falsy.map((v) => `${normalized}===${escapeString(v)}`).join(\"||\");\n code += emit`\n if(${truthyCondition}){${g.output}=true;}\n else if(${falsyCondition}){${g.output}=false;}\n else{${invalidValue(g, valuesExpr)}}\n `;\n } else {\n const value = g.temp(\"sbv\");\n const lookup = emitStringBoolMap(ir, g.ctx);\n code += emit`\n var ${value}=${lookup}.get(${normalized});\n if(${value}===undefined){${invalidValue(g, valuesExpr)}}\n else{${g.output}=${value};}\n `;\n }\n\n code += emit`}`;\n return `${code}\\n`;\n}\n\nexport function stringBoolUsesInline(ir: StringBoolIR): boolean {\n return ir.truthy.length <= ENUM_INLINE_THRESHOLD && ir.falsy.length <= ENUM_INLINE_THRESHOLD;\n}\n\n/** One lookup distinguishes true, false and absent; shared by hot and issue walks. */\nexport function emitStringBoolMap(ir: StringBoolIR, ctx: CodeGenContext): string {\n const pairs = [\n ...ir.truthy.map((value) => [value, true]),\n ...ir.falsy.map((value) => [value, false]),\n ];\n return emitConstant(ctx, \"map_sb\", `new Map(${JSON.stringify(pairs)})`);\n}\n"],"mappings":";;;;AAMA,SAAgB,eAAe,IAAkB,GAAoB;CACnE,IAAI,OAAO;CAGX,QAAQ,IAAI;gBACE,EAAE,MAAM;QAChB,YAAY,GAAG,QAAQ,EAAE;;;CAK/B,MAAM,aAAa,GAAG,gBAAgB,EAAE,QAAQ,EAAE,KAAK,KAAK;CAC5D,IAAI,CAAC,GAAG,eAAe,QAAQ,OAAO,WAAW,GAAG,EAAE,MAAM;CAC5D,MAAM,YAAY,CAAC,GAAG,GAAG,QAAQ,GAAG,GAAG,KAAK;CAC5C,MAAM,aAAa,KAAK,UAAU,SAAS;CAK3C,IAFkB,qBAAqB,EAE3B,GAAG;EACb,MAAM,kBAAkB,GAAG,OAAO,KAAK,MAAM,GAAG,WAAW,KAAK,aAAa,CAAC,GAAG,CAAC,CAAC,KAAK,IAAI;EAC5F,MAAM,iBAAiB,GAAG,MAAM,KAAK,MAAM,GAAG,WAAW,KAAK,aAAa,CAAC,GAAG,CAAC,CAAC,KAAK,IAAI;EAC1F,QAAQ,IAAI;WACL,gBAAgB,IAAI,EAAE,OAAO;gBACxB,eAAe,IAAI,EAAE,OAAO;aAC/B,aAAa,GAAG,UAAU,EAAE;;CAEvC,OAAO;EACL,MAAM,QAAQ,EAAE,KAAK,KAAK;EAC1B,MAAM,SAAS,kBAAkB,IAAI,EAAE,GAAG;EAC1C,QAAQ,IAAI;YACJ,MAAM,GAAG,OAAO,OAAO,WAAW;WACnC,MAAM,gBAAgB,aAAa,GAAG,UAAU,EAAE;aAChD,EAAE,OAAO,GAAG,MAAM;;CAE7B;CAEA,QAAQ,IAAI;CACZ,OAAO,GAAG,KAAK;AACjB;AAEA,SAAgB,qBAAqB,IAA2B;CAC9D,OAAO,GAAG,OAAO,UAAA,KAAmC,GAAG,MAAM,UAAA;AAC/D;;AAGA,SAAgB,kBAAkB,IAAkB,KAA6B;CAC/E,MAAM,QAAQ,CACZ,GAAG,GAAG,OAAO,KAAK,UAAU,CAAC,OAAO,IAAI,CAAC,GACzC,GAAG,GAAG,MAAM,KAAK,UAAU,CAAC,OAAO,KAAK,CAAC,CAC3C;CACA,OAAO,aAAa,KAAK,UAAU,WAAW,KAAK,UAAU,KAAK,EAAE,EAAE;AACxE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slow-path.d.ts","names":[],"sources":["../../../src/core/codegen/slow-path.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"slow-path.d.ts","names":[],"sources":["../../../src/core/codegen/slow-path.ts"],"mappings":";;;iBAmGgB,cACd,mBACA,oBACA,kBACA,mBACA,KAAK,gBACL,sBACC;iBAyCa,aAAa,IAAI,UAAU,GAAG"}
|
|
@@ -5,11 +5,12 @@ import { slowArray } from "./schemas/array.js";
|
|
|
5
5
|
import { slowBigInt } from "./schemas/bigint.js";
|
|
6
6
|
import { slowBoolean } from "./schemas/boolean.js";
|
|
7
7
|
import { slowCatch } from "./schemas/catch.js";
|
|
8
|
+
import { slowFallback } from "./schemas/fallback.js";
|
|
9
|
+
import { slowCustom } from "./schemas/custom.js";
|
|
8
10
|
import { slowDate } from "./schemas/date.js";
|
|
9
11
|
import { slowDefault } from "./schemas/default.js";
|
|
10
12
|
import { slowDiscriminatedUnion } from "./schemas/discriminated-union.js";
|
|
11
13
|
import { slowEnum } from "./schemas/enum.js";
|
|
12
|
-
import { slowFallback } from "./schemas/fallback.js";
|
|
13
14
|
import { slowFile } from "./schemas/file.js";
|
|
14
15
|
import { slowIntersection } from "./schemas/intersection.js";
|
|
15
16
|
import { slowLiteral } from "./schemas/literal.js";
|
|
@@ -68,6 +69,7 @@ const slowRegistry = {
|
|
|
68
69
|
default: slowDefault,
|
|
69
70
|
pipe: slowPipe,
|
|
70
71
|
effect: slowEffect,
|
|
72
|
+
custom: slowCustom,
|
|
71
73
|
templateLiteral: slowTemplateLiteral,
|
|
72
74
|
catch: slowCatch,
|
|
73
75
|
fallback: slowFallback,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slow-path.js","names":[],"sources":["../../../src/core/codegen/slow-path.ts"],"sourcesContent":["import type { SchemaIR } from \"../types.js\";\nimport type { CodeGenContext, SlowGen, SlowGenerator } from \"./context.js\";\nimport { emitRegex, emitSet, emitTemp } from \"./context.js\";\nimport { slowAny } from \"./schemas/any.js\";\nimport { slowArray } from \"./schemas/array.js\";\nimport { slowBigInt } from \"./schemas/bigint.js\";\nimport { slowBoolean } from \"./schemas/boolean.js\";\nimport { slowCatch } from \"./schemas/catch.js\";\nimport { slowDate } from \"./schemas/date.js\";\nimport { slowDefault } from \"./schemas/default.js\";\nimport { slowDiscriminatedUnion } from \"./schemas/discriminated-union.js\";\nimport { slowEffect } from \"./schemas/effect.js\";\nimport { slowEnum } from \"./schemas/enum.js\";\nimport { slowFallback } from \"./schemas/fallback.js\";\nimport { slowFile } from \"./schemas/file.js\";\nimport { slowIntersection } from \"./schemas/intersection.js\";\nimport { slowLiteral } from \"./schemas/literal.js\";\nimport { slowMap } from \"./schemas/map.js\";\nimport { slowNan } from \"./schemas/nan.js\";\nimport { slowNever } from \"./schemas/never.js\";\nimport { slowNull } from \"./schemas/null.js\";\nimport { slowNullable } from \"./schemas/nullable.js\";\nimport { slowNumber } from \"./schemas/number.js\";\nimport { slowObject } from \"./schemas/object.js\";\nimport { slowOptional } from \"./schemas/optional.js\";\nimport { slowPipe } from \"./schemas/pipe.js\";\nimport { slowReadonly } from \"./schemas/readonly.js\";\nimport { slowRecord } from \"./schemas/record.js\";\nimport { slowRecursionTarget, slowRecursiveRef } from \"./schemas/recursive-ref.js\";\nimport { slowSet } from \"./schemas/set.js\";\nimport { slowString } from \"./schemas/string.js\";\nimport { slowStringBool } from \"./schemas/string-bool.js\";\nimport { slowSymbol } from \"./schemas/symbol.js\";\nimport { slowTemplateLiteral } from \"./schemas/template-literal.js\";\nimport { slowTuple } from \"./schemas/tuple.js\";\nimport { slowUndefined } from \"./schemas/undefined.js\";\nimport { slowUnion } from \"./schemas/union.js\";\nimport { slowUnknown } from \"./schemas/unknown.js\";\nimport { slowVoid } from \"./schemas/void.js\";\n\n// ─── Typed registry ─────────────────────────────────────────────────────────\n// Adding a new SchemaIR type without registering a generator here causes a\n// compile error, preventing the silent-missing-case bugs that plagued the old\n// switch-based dispatch.\n\nconst slowRegistry = {\n // Primitives (order follows SchemaIR union in types.ts)\n string: slowString,\n number: slowNumber,\n boolean: slowBoolean,\n bigint: slowBigInt,\n date: slowDate,\n symbol: slowSymbol,\n null: slowNull,\n undefined: slowUndefined,\n void: slowVoid,\n nan: slowNan,\n never: slowNever,\n any: slowAny,\n unknown: slowUnknown,\n literal: slowLiteral,\n enum: slowEnum,\n // Containers\n object: slowObject,\n array: slowArray,\n tuple: slowTuple,\n record: slowRecord,\n set: slowSet,\n map: slowMap,\n file: slowFile,\n // Unions & Intersections\n union: slowUnion,\n discriminatedUnion: slowDiscriminatedUnion,\n intersection: slowIntersection,\n // Modifiers\n optional: slowOptional,\n nullable: slowNullable,\n readonly: slowReadonly,\n default: slowDefault,\n pipe: slowPipe,\n // Effects\n effect: slowEffect,\n // Special\n templateLiteral: slowTemplateLiteral,\n catch: slowCatch,\n fallback: slowFallback,\n recursiveRef: slowRecursiveRef,\n recursionTarget: slowRecursionTarget,\n stringBool: slowStringBool,\n} satisfies {\n [K in SchemaIR[\"type\"]]: SlowGenerator<Extract<SchemaIR, { type: K }>>;\n};\n\n// ─── Factory ─────────────────────────────────────────────────────────────────\n// Lives here (not in context.ts) to avoid circular imports:\n// visit() → generateSlow() → imports from context.ts\n\nexport function createSlowGen(\n inputExpr: string,\n outputExpr: string,\n pathExpr: string,\n issuesVar: string,\n ctx: CodeGenContext,\n abortedVar?: string,\n): SlowGen {\n return {\n input: inputExpr,\n output: outputExpr,\n path: pathExpr,\n issues: issuesVar,\n aborted: abortedVar,\n ctx,\n visit(ir, overrides) {\n const input = overrides?.input ?? inputExpr;\n const output = overrides?.output ?? outputExpr;\n const path = overrides?.path ?? pathExpr;\n const issues = overrides?.issues ?? issuesVar;\n // `aborted` is deliberately NOT inherited (see SlowGen.aborted): a child\n // only tracks abort when the parent explicitly forwards it, so a pipe\n // buried inside a container never trips its ancestor union's abort flag.\n const aborted = overrides?.aborted;\n // Shared sub-schema: call the file-level `__zcSw_N(input, path, issues)`\n // walk (signature defined in dedupe.ts) instead of inlining a duplicate.\n // It returns the parsed value, so the assignment delivers whatever an\n // inlined walk would have written to `output` — a stripping object's\n // rebuilt result, a coerced number, a trimmed string.\n //\n // But the shared walk's 3-arg signature can't carry this call site's\n // abort flag — a shared pipe option would silently drop it. When we're in\n // an abort-tracking position (`aborted` set), inline instead of sharing so\n // the pipe's abort reaches the union. Non-tracking sites still share.\n const ref = aborted === undefined ? ctx.sharedSchemas?.refFor(ir) : undefined;\n if (ref !== undefined) {\n return `${output}=${ref.name}(${input},${path},${issues});`;\n }\n return generateSlow(ir, createSlowGen(input, output, path, issues, ctx, aborted));\n },\n temp: (prefix) => emitTemp(ctx, prefix),\n regex: (prefix, pattern, flags) => emitRegex(ctx, prefix, pattern, flags),\n set: (prefix, values) => emitSet(ctx, prefix, values),\n };\n}\n\n// ─── Dispatch ────────────────────────────────────────────────────────────────\n\nexport function generateSlow(ir: SchemaIR, g: SlowGen): string {\n // Surface the node's schema-level error message to issue emission. visit()\n // always builds a fresh context, so typeMsg never leaks into child nodes.\n const gen0 = ir.typeMessage !== g.typeMsg ? { ...g, typeMsg: ir.typeMessage } : g;\n const gen = slowRegistry[ir.type];\n // oxlint-disable-next-line typescript/no-explicit-any -- registry dispatch requires type erasure at call site\n return (gen as any)(ir, gen0);\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"slow-path.js","names":[],"sources":["../../../src/core/codegen/slow-path.ts"],"sourcesContent":["import type { SchemaIR } from \"../types.js\";\nimport type { CodeGenContext, SlowGen, SlowGenerator } from \"./context.js\";\nimport { emitRegex, emitSet, emitTemp } from \"./context.js\";\nimport { slowAny } from \"./schemas/any.js\";\nimport { slowArray } from \"./schemas/array.js\";\nimport { slowBigInt } from \"./schemas/bigint.js\";\nimport { slowBoolean } from \"./schemas/boolean.js\";\nimport { slowCatch } from \"./schemas/catch.js\";\nimport { slowCustom } from \"./schemas/custom.js\";\nimport { slowDate } from \"./schemas/date.js\";\nimport { slowDefault } from \"./schemas/default.js\";\nimport { slowDiscriminatedUnion } from \"./schemas/discriminated-union.js\";\nimport { slowEffect } from \"./schemas/effect.js\";\nimport { slowEnum } from \"./schemas/enum.js\";\nimport { slowFallback } from \"./schemas/fallback.js\";\nimport { slowFile } from \"./schemas/file.js\";\nimport { slowIntersection } from \"./schemas/intersection.js\";\nimport { slowLiteral } from \"./schemas/literal.js\";\nimport { slowMap } from \"./schemas/map.js\";\nimport { slowNan } from \"./schemas/nan.js\";\nimport { slowNever } from \"./schemas/never.js\";\nimport { slowNull } from \"./schemas/null.js\";\nimport { slowNullable } from \"./schemas/nullable.js\";\nimport { slowNumber } from \"./schemas/number.js\";\nimport { slowObject } from \"./schemas/object.js\";\nimport { slowOptional } from \"./schemas/optional.js\";\nimport { slowPipe } from \"./schemas/pipe.js\";\nimport { slowReadonly } from \"./schemas/readonly.js\";\nimport { slowRecord } from \"./schemas/record.js\";\nimport { slowRecursionTarget, slowRecursiveRef } from \"./schemas/recursive-ref.js\";\nimport { slowSet } from \"./schemas/set.js\";\nimport { slowString } from \"./schemas/string.js\";\nimport { slowStringBool } from \"./schemas/string-bool.js\";\nimport { slowSymbol } from \"./schemas/symbol.js\";\nimport { slowTemplateLiteral } from \"./schemas/template-literal.js\";\nimport { slowTuple } from \"./schemas/tuple.js\";\nimport { slowUndefined } from \"./schemas/undefined.js\";\nimport { slowUnion } from \"./schemas/union.js\";\nimport { slowUnknown } from \"./schemas/unknown.js\";\nimport { slowVoid } from \"./schemas/void.js\";\n\n// ─── Typed registry ─────────────────────────────────────────────────────────\n// Adding a new SchemaIR type without registering a generator here causes a\n// compile error, preventing the silent-missing-case bugs that plagued the old\n// switch-based dispatch.\n\nconst slowRegistry = {\n // Primitives (order follows SchemaIR union in types.ts)\n string: slowString,\n number: slowNumber,\n boolean: slowBoolean,\n bigint: slowBigInt,\n date: slowDate,\n symbol: slowSymbol,\n null: slowNull,\n undefined: slowUndefined,\n void: slowVoid,\n nan: slowNan,\n never: slowNever,\n any: slowAny,\n unknown: slowUnknown,\n literal: slowLiteral,\n enum: slowEnum,\n // Containers\n object: slowObject,\n array: slowArray,\n tuple: slowTuple,\n record: slowRecord,\n set: slowSet,\n map: slowMap,\n file: slowFile,\n // Unions & Intersections\n union: slowUnion,\n discriminatedUnion: slowDiscriminatedUnion,\n intersection: slowIntersection,\n // Modifiers\n optional: slowOptional,\n nullable: slowNullable,\n readonly: slowReadonly,\n default: slowDefault,\n pipe: slowPipe,\n // Effects\n effect: slowEffect,\n // Special\n custom: slowCustom,\n templateLiteral: slowTemplateLiteral,\n catch: slowCatch,\n fallback: slowFallback,\n recursiveRef: slowRecursiveRef,\n recursionTarget: slowRecursionTarget,\n stringBool: slowStringBool,\n} satisfies {\n [K in SchemaIR[\"type\"]]: SlowGenerator<Extract<SchemaIR, { type: K }>>;\n};\n\n// ─── Factory ─────────────────────────────────────────────────────────────────\n// Lives here (not in context.ts) to avoid circular imports:\n// visit() → generateSlow() → imports from context.ts\n\nexport function createSlowGen(\n inputExpr: string,\n outputExpr: string,\n pathExpr: string,\n issuesVar: string,\n ctx: CodeGenContext,\n abortedVar?: string,\n): SlowGen {\n return {\n input: inputExpr,\n output: outputExpr,\n path: pathExpr,\n issues: issuesVar,\n aborted: abortedVar,\n ctx,\n visit(ir, overrides) {\n const input = overrides?.input ?? inputExpr;\n const output = overrides?.output ?? outputExpr;\n const path = overrides?.path ?? pathExpr;\n const issues = overrides?.issues ?? issuesVar;\n // `aborted` is deliberately NOT inherited (see SlowGen.aborted): a child\n // only tracks abort when the parent explicitly forwards it, so a pipe\n // buried inside a container never trips its ancestor union's abort flag.\n const aborted = overrides?.aborted;\n // Shared sub-schema: call the file-level `__zcSw_N(input, path, issues)`\n // walk (signature defined in dedupe.ts) instead of inlining a duplicate.\n // It returns the parsed value, so the assignment delivers whatever an\n // inlined walk would have written to `output` — a stripping object's\n // rebuilt result, a coerced number, a trimmed string.\n //\n // But the shared walk's 3-arg signature can't carry this call site's\n // abort flag — a shared pipe option would silently drop it. When we're in\n // an abort-tracking position (`aborted` set), inline instead of sharing so\n // the pipe's abort reaches the union. Non-tracking sites still share.\n const ref = aborted === undefined ? ctx.sharedSchemas?.refFor(ir) : undefined;\n if (ref !== undefined) {\n return `${output}=${ref.name}(${input},${path},${issues});`;\n }\n return generateSlow(ir, createSlowGen(input, output, path, issues, ctx, aborted));\n },\n temp: (prefix) => emitTemp(ctx, prefix),\n regex: (prefix, pattern, flags) => emitRegex(ctx, prefix, pattern, flags),\n set: (prefix, values) => emitSet(ctx, prefix, values),\n };\n}\n\n// ─── Dispatch ────────────────────────────────────────────────────────────────\n\nexport function generateSlow(ir: SchemaIR, g: SlowGen): string {\n // Surface the node's schema-level error message to issue emission. visit()\n // always builds a fresh context, so typeMsg never leaks into child nodes.\n const gen0 = ir.typeMessage !== g.typeMsg ? { ...g, typeMsg: ir.typeMessage } : g;\n const gen = slowRegistry[ir.type];\n // oxlint-disable-next-line typescript/no-explicit-any -- registry dispatch requires type erasure at call site\n return (gen as any)(ir, gen0);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8CA,MAAM,eAAe;CAEnB,QAAQ;CACR,QAAQ;CACR,SAAS;CACT,QAAQ;CACR,MAAM;CACN,QAAQ;CACR,MAAM;CACN,WAAW;CACX,MAAM;CACN,KAAK;CACL,OAAO;CACP,KAAK;CACL,SAAS;CACT,SAAS;CACT,MAAM;CAEN,QAAQ;CACR,OAAO;CACP,OAAO;CACP,QAAQ;CACR,KAAK;CACL,KAAK;CACL,MAAM;CAEN,OAAO;CACP,oBAAoB;CACpB,cAAc;CAEd,UAAU;CACV,UAAU;CACV,UAAU;CACV,SAAS;CACT,MAAM;CAEN,QAAQ;CAER,QAAQ;CACR,iBAAiB;CACjB,OAAO;CACP,UAAU;CACV,cAAc;CACd,iBAAiB;CACjB,YAAY;AACd;AAQA,SAAgB,cACd,WACA,YACA,UACA,WACA,KACA,YACS;CACT,OAAO;EACL,OAAO;EACP,QAAQ;EACR,MAAM;EACN,QAAQ;EACR,SAAS;EACT;EACA,MAAM,IAAI,WAAW;GACnB,MAAM,QAAQ,WAAW,SAAS;GAClC,MAAM,SAAS,WAAW,UAAU;GACpC,MAAM,OAAO,WAAW,QAAQ;GAChC,MAAM,SAAS,WAAW,UAAU;GAIpC,MAAM,UAAU,WAAW;GAW3B,MAAM,MAAM,YAAY,KAAA,IAAY,IAAI,eAAe,OAAO,EAAE,IAAI,KAAA;GACpE,IAAI,QAAQ,KAAA,GACV,OAAO,GAAG,OAAO,GAAG,IAAI,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO;GAE1D,OAAO,aAAa,IAAI,cAAc,OAAO,QAAQ,MAAM,QAAQ,KAAK,OAAO,CAAC;EAClF;EACA,OAAO,WAAW,SAAS,KAAK,MAAM;EACtC,QAAQ,QAAQ,SAAS,UAAU,UAAU,KAAK,QAAQ,SAAS,KAAK;EACxE,MAAM,QAAQ,WAAW,QAAQ,KAAK,QAAQ,MAAM;CACtD;AACF;AAIA,SAAgB,aAAa,IAAc,GAAoB;CAG7D,MAAM,OAAO,GAAG,gBAAgB,EAAE,UAAU;EAAE,GAAG;EAAG,SAAS,GAAG;CAAY,IAAI;CAChF,MAAM,MAAM,aAAa,GAAG;CAE5B,OAAQ,IAAY,IAAI,IAAI;AAC9B"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { SchemaIR } from "../../types.js";
|
|
2
|
+
import { ExtractorContext, ZodDef } from "../types.js";
|
|
3
|
+
//#region src/core/extract/extractors/custom.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Compile z.custom() and z.instanceof() as pure predicates. The predicate is
|
|
6
|
+
* enough for the total hot-path verdict; the original schema is retained so a
|
|
7
|
+
* failed parse can delegate issue construction to Zod on the cold path.
|
|
8
|
+
*/
|
|
9
|
+
declare function extractCustom(def: ZodDef, ctx: ExtractorContext): SchemaIR;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { extractCustom };
|
|
12
|
+
//# sourceMappingURL=custom.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custom.d.ts","names":[],"sources":["../../../../src/core/extract/extractors/custom.ts"],"mappings":";;;;;;;;iBASgB,cAAc,KAAK,QAAQ,KAAK,mBAAmB"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { isReferenceablePredicate, tryCompileEffect } from "../effects.js";
|
|
2
|
+
//#region src/core/extract/extractors/custom.ts
|
|
3
|
+
/**
|
|
4
|
+
* Compile z.custom() and z.instanceof() as pure predicates. The predicate is
|
|
5
|
+
* enough for the total hot-path verdict; the original schema is retained so a
|
|
6
|
+
* failed parse can delegate issue construction to Zod on the cold path.
|
|
7
|
+
*/
|
|
8
|
+
function extractCustom(def, ctx) {
|
|
9
|
+
const refs = ctx.refs;
|
|
10
|
+
if (!refs || !isReferenceablePredicate(def.fn)) return ctx.fallback("custom");
|
|
11
|
+
const source = tryCompileEffect(def.fn);
|
|
12
|
+
let refIndex;
|
|
13
|
+
if (source === void 0) {
|
|
14
|
+
refIndex = refs.length;
|
|
15
|
+
refs.push({
|
|
16
|
+
schema: def.fn,
|
|
17
|
+
accessPath: `${ctx.path}._zod.def.fn`
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
const schemaRefIndex = refs.length;
|
|
21
|
+
refs.push({
|
|
22
|
+
schema: ctx.schema,
|
|
23
|
+
accessPath: ctx.path
|
|
24
|
+
});
|
|
25
|
+
return {
|
|
26
|
+
type: "custom",
|
|
27
|
+
...source === void 0 ? { refIndex } : { source },
|
|
28
|
+
schemaRefIndex,
|
|
29
|
+
abort: def.abort !== false
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
33
|
+
export { extractCustom };
|
|
34
|
+
|
|
35
|
+
//# sourceMappingURL=custom.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custom.js","names":[],"sources":["../../../../src/core/extract/extractors/custom.ts"],"sourcesContent":["import type { CustomIR, SchemaIR } from \"../../types.js\";\nimport { isReferenceablePredicate, tryCompileEffect } from \"../effects.js\";\nimport type { ExtractorContext, ZodDef } from \"../types.js\";\n\n/**\n * Compile z.custom() and z.instanceof() as pure predicates. The predicate is\n * enough for the total hot-path verdict; the original schema is retained so a\n * failed parse can delegate issue construction to Zod on the cold path.\n */\nexport function extractCustom(def: ZodDef, ctx: ExtractorContext): SchemaIR {\n const refs = ctx.refs;\n if (!refs || !isReferenceablePredicate(def.fn)) return ctx.fallback(\"custom\");\n\n const source = tryCompileEffect(def.fn);\n let refIndex: number | undefined;\n if (source === undefined) {\n refIndex = refs.length;\n refs.push({ schema: def.fn, accessPath: `${ctx.path}._zod.def.fn` });\n }\n\n const schemaRefIndex = refs.length;\n refs.push({ schema: ctx.schema, accessPath: ctx.path });\n\n return {\n type: \"custom\",\n ...(source === undefined ? { refIndex: refIndex as number } : { source }),\n schemaRefIndex,\n abort: def.abort !== false,\n } satisfies CustomIR;\n}\n"],"mappings":";;;;;;;AASA,SAAgB,cAAc,KAAa,KAAiC;CAC1E,MAAM,OAAO,IAAI;CACjB,IAAI,CAAC,QAAQ,CAAC,yBAAyB,IAAI,EAAE,GAAG,OAAO,IAAI,SAAS,QAAQ;CAE5E,MAAM,SAAS,iBAAiB,IAAI,EAAE;CACtC,IAAI;CACJ,IAAI,WAAW,KAAA,GAAW;EACxB,WAAW,KAAK;EAChB,KAAK,KAAK;GAAE,QAAQ,IAAI;GAAI,YAAY,GAAG,IAAI,KAAK;EAAc,CAAC;CACrE;CAEA,MAAM,iBAAiB,KAAK;CAC5B,KAAK,KAAK;EAAE,QAAQ,IAAI;EAAQ,YAAY,IAAI;CAAK,CAAC;CAEtD,OAAO;EACL,MAAM;EACN,GAAI,WAAW,KAAA,IAAY,EAAY,SAAmB,IAAI,EAAE,OAAO;EACvE;EACA,OAAO,IAAI,UAAU;CACvB;AACF"}
|
|
@@ -3,6 +3,7 @@ import { Extractor, RecursionState, RefEntry } from "./types.js";
|
|
|
3
3
|
import { extractArray } from "./extractors/array.js";
|
|
4
4
|
import { extractBigint } from "./extractors/bigint.js";
|
|
5
5
|
import { extractCatch } from "./extractors/catch.js";
|
|
6
|
+
import { extractCustom } from "./extractors/custom.js";
|
|
6
7
|
import { extractDate } from "./extractors/date.js";
|
|
7
8
|
import { extractDefault } from "./extractors/default.js";
|
|
8
9
|
import { extractFile } from "./extractors/file.js";
|
|
@@ -34,6 +35,7 @@ declare const extractRegistry: {
|
|
|
34
35
|
nullable: Extractor;
|
|
35
36
|
readonly: Extractor;
|
|
36
37
|
intersection: Extractor;
|
|
38
|
+
custom: typeof extractCustom;
|
|
37
39
|
string: typeof extractString;
|
|
38
40
|
number: typeof extractNumber;
|
|
39
41
|
bigint: typeof extractBigint;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","names":[],"sources":["../../../src/core/extract/registry.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"registry.d.ts","names":[],"sources":["../../../src/core/extract/registry.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;cAsDa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA0FG,SACd,oBACA,cACA,MAAM,wBACN,UAAU,cACV,WAAW,iBACV"}
|
|
@@ -4,6 +4,7 @@ import { extractArray } from "./extractors/array.js";
|
|
|
4
4
|
import { extractBigint } from "./extractors/bigint.js";
|
|
5
5
|
import { extractBoolean } from "./extractors/boolean.js";
|
|
6
6
|
import { extractCatch } from "./extractors/catch.js";
|
|
7
|
+
import { extractCustom } from "./extractors/custom.js";
|
|
7
8
|
import { extractDate } from "./extractors/date.js";
|
|
8
9
|
import { extractDefault } from "./extractors/default.js";
|
|
9
10
|
import { extractEnum } from "./extractors/enum.js";
|
|
@@ -49,6 +50,7 @@ const extractRegistry = {
|
|
|
49
50
|
nullable: extractNullable,
|
|
50
51
|
readonly: extractReadonly,
|
|
51
52
|
intersection: extractIntersection,
|
|
53
|
+
custom: extractCustom,
|
|
52
54
|
string: extractString,
|
|
53
55
|
number: extractNumber,
|
|
54
56
|
bigint: extractBigint,
|