zod-compiler 1.23.0 → 1.23.2
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 +9 -6
- package/dist/cli/commands/check.d.ts +10 -7
- package/dist/cli/commands/check.d.ts.map +1 -1
- package/dist/cli/commands/check.js +125 -148
- package/dist/cli/commands/check.js.map +1 -1
- package/dist/cli/commands/generate.d.ts +22 -19
- package/dist/cli/commands/generate.d.ts.map +1 -1
- package/dist/cli/commands/generate.js +102 -133
- package/dist/cli/commands/generate.js.map +1 -1
- package/dist/cli/commands/watch.d.ts +17 -15
- package/dist/cli/commands/watch.d.ts.map +1 -1
- package/dist/cli/commands/watch.js +126 -154
- package/dist/cli/commands/watch.js.map +1 -1
- package/dist/cli/emitter.d.ts +19 -16
- package/dist/cli/emitter.d.ts.map +1 -1
- package/dist/cli/emitter.js +55 -71
- package/dist/cli/emitter.js.map +1 -1
- package/dist/cli/errors.d.ts +4 -1
- package/dist/cli/errors.d.ts.map +1 -1
- package/dist/cli/errors.js +6 -2
- package/dist/cli/errors.js.map +1 -1
- package/dist/cli/index.d.ts +1 -3
- package/dist/cli/index.js +147 -160
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/logger.d.ts +18 -15
- package/dist/cli/logger.d.ts.map +1 -1
- package/dist/cli/logger.js +38 -37
- package/dist/cli/logger.js.map +1 -1
- package/dist/core/codegen/build-path.d.ts +7 -41
- package/dist/core/codegen/build-path.d.ts.map +1 -1
- package/dist/core/codegen/build-path.js +481 -570
- package/dist/core/codegen/build-path.js.map +1 -1
- package/dist/core/codegen/context.d.ts +256 -253
- package/dist/core/codegen/context.d.ts.map +1 -1
- package/dist/core/codegen/context.js +363 -437
- package/dist/core/codegen/context.js.map +1 -1
- package/dist/core/codegen/dedupe.d.ts +22 -56
- package/dist/core/codegen/dedupe.d.ts.map +1 -1
- package/dist/core/codegen/dedupe.js +150 -242
- package/dist/core/codegen/dedupe.js.map +1 -1
- package/dist/core/codegen/emit-issue.d.ts +44 -68
- package/dist/core/codegen/emit-issue.d.ts.map +1 -1
- package/dist/core/codegen/emit-issue.js +76 -108
- package/dist/core/codegen/emit-issue.js.map +1 -1
- package/dist/core/codegen/emit.d.ts +4 -1
- package/dist/core/codegen/emit.d.ts.map +1 -1
- package/dist/core/codegen/emit.js +16 -13
- package/dist/core/codegen/emit.js.map +1 -1
- package/dist/core/codegen/fast-path.d.ts +7 -12
- package/dist/core/codegen/fast-path.d.ts.map +1 -1
- package/dist/core/codegen/fast-path.js +116 -145
- package/dist/core/codegen/fast-path.js.map +1 -1
- package/dist/core/codegen/fast-size.d.ts +12 -26
- package/dist/core/codegen/fast-size.d.ts.map +1 -1
- package/dist/core/codegen/fast-size.js +169 -244
- package/dist/core/codegen/fast-size.js.map +1 -1
- package/dist/core/codegen/index.d.ts +25 -23
- package/dist/core/codegen/index.d.ts.map +1 -1
- package/dist/core/codegen/index.js +239 -405
- package/dist/core/codegen/index.js.map +1 -1
- package/dist/core/codegen/issue-decls.d.ts +15 -12
- package/dist/core/codegen/issue-decls.d.ts.map +1 -1
- package/dist/core/codegen/issue-decls.js +131 -162
- package/dist/core/codegen/issue-decls.js.map +1 -1
- package/dist/core/codegen/regex-unroll.d.ts +4 -1
- package/dist/core/codegen/regex-unroll.d.ts.map +1 -1
- package/dist/core/codegen/regex-unroll.js +173 -197
- package/dist/core/codegen/regex-unroll.js.map +1 -1
- package/dist/core/codegen/schemas/any.d.ts +7 -4
- package/dist/core/codegen/schemas/any.d.ts.map +1 -1
- package/dist/core/codegen/schemas/any.js +8 -4
- package/dist/core/codegen/schemas/any.js.map +1 -1
- package/dist/core/codegen/schemas/array.d.ts +8 -5
- package/dist/core/codegen/schemas/array.d.ts.map +1 -1
- package/dist/core/codegen/schemas/array.js +77 -95
- package/dist/core/codegen/schemas/array.js.map +1 -1
- package/dist/core/codegen/schemas/bigint.d.ts +7 -4
- package/dist/core/codegen/schemas/bigint.d.ts.map +1 -1
- package/dist/core/codegen/schemas/bigint.js +44 -56
- package/dist/core/codegen/schemas/bigint.js.map +1 -1
- package/dist/core/codegen/schemas/boolean.d.ts +7 -4
- package/dist/core/codegen/schemas/boolean.d.ts.map +1 -1
- package/dist/core/codegen/schemas/boolean.js +12 -11
- package/dist/core/codegen/schemas/boolean.js.map +1 -1
- package/dist/core/codegen/schemas/catch.d.ts +8 -5
- package/dist/core/codegen/schemas/catch.d.ts.map +1 -1
- package/dist/core/codegen/schemas/catch.js +23 -23
- package/dist/core/codegen/schemas/catch.js.map +1 -1
- package/dist/core/codegen/schemas/date.d.ts +7 -4
- package/dist/core/codegen/schemas/date.d.ts.map +1 -1
- package/dist/core/codegen/schemas/date.js +49 -68
- package/dist/core/codegen/schemas/date.js.map +1 -1
- package/dist/core/codegen/schemas/default.d.ts +9 -6
- package/dist/core/codegen/schemas/default.d.ts.map +1 -1
- package/dist/core/codegen/schemas/default.js +29 -27
- package/dist/core/codegen/schemas/default.js.map +1 -1
- package/dist/core/codegen/schemas/discriminated-union.d.ts +12 -10
- package/dist/core/codegen/schemas/discriminated-union.d.ts.map +1 -1
- package/dist/core/codegen/schemas/discriminated-union.js +153 -178
- package/dist/core/codegen/schemas/discriminated-union.js.map +1 -1
- package/dist/core/codegen/schemas/effect.d.ts +9 -6
- package/dist/core/codegen/schemas/effect.d.ts.map +1 -1
- package/dist/core/codegen/schemas/effect.js +54 -67
- package/dist/core/codegen/schemas/effect.js.map +1 -1
- package/dist/core/codegen/schemas/enum.d.ts +7 -4
- package/dist/core/codegen/schemas/enum.d.ts.map +1 -1
- package/dist/core/codegen/schemas/enum.js +15 -21
- package/dist/core/codegen/schemas/enum.js.map +1 -1
- package/dist/core/codegen/schemas/fallback.d.ts +6 -3
- package/dist/core/codegen/schemas/fallback.d.ts.map +1 -1
- package/dist/core/codegen/schemas/fallback.js +14 -13
- package/dist/core/codegen/schemas/fallback.js.map +1 -1
- package/dist/core/codegen/schemas/file.d.ts +7 -4
- package/dist/core/codegen/schemas/file.d.ts.map +1 -1
- package/dist/core/codegen/schemas/file.js +51 -57
- package/dist/core/codegen/schemas/file.js.map +1 -1
- package/dist/core/codegen/schemas/intersection.d.ts +8 -5
- package/dist/core/codegen/schemas/intersection.d.ts.map +1 -1
- package/dist/core/codegen/schemas/intersection.js +16 -13
- package/dist/core/codegen/schemas/intersection.js.map +1 -1
- package/dist/core/codegen/schemas/literal.d.ts +7 -4
- package/dist/core/codegen/schemas/literal.d.ts.map +1 -1
- package/dist/core/codegen/schemas/literal.js +20 -23
- package/dist/core/codegen/schemas/literal.js.map +1 -1
- package/dist/core/codegen/schemas/map.d.ts +8 -5
- package/dist/core/codegen/schemas/map.d.ts.map +1 -1
- package/dist/core/codegen/schemas/map.js +61 -67
- package/dist/core/codegen/schemas/map.js.map +1 -1
- package/dist/core/codegen/schemas/nan.d.ts +7 -4
- package/dist/core/codegen/schemas/nan.d.ts.map +1 -1
- package/dist/core/codegen/schemas/nan.js +8 -4
- package/dist/core/codegen/schemas/nan.js.map +1 -1
- package/dist/core/codegen/schemas/never.d.ts +7 -4
- package/dist/core/codegen/schemas/never.d.ts.map +1 -1
- package/dist/core/codegen/schemas/never.js +8 -4
- package/dist/core/codegen/schemas/never.js.map +1 -1
- package/dist/core/codegen/schemas/null.d.ts +7 -4
- package/dist/core/codegen/schemas/null.d.ts.map +1 -1
- package/dist/core/codegen/schemas/null.js +8 -4
- package/dist/core/codegen/schemas/null.js.map +1 -1
- package/dist/core/codegen/schemas/nullable.d.ts +8 -5
- package/dist/core/codegen/schemas/nullable.d.ts.map +1 -1
- package/dist/core/codegen/schemas/nullable.js +8 -5
- package/dist/core/codegen/schemas/nullable.js.map +1 -1
- package/dist/core/codegen/schemas/number.d.ts +7 -4
- package/dist/core/codegen/schemas/number.d.ts.map +1 -1
- package/dist/core/codegen/schemas/number.js +120 -176
- package/dist/core/codegen/schemas/number.js.map +1 -1
- package/dist/core/codegen/schemas/object.d.ts +8 -5
- package/dist/core/codegen/schemas/object.d.ts.map +1 -1
- package/dist/core/codegen/schemas/object.js +144 -231
- package/dist/core/codegen/schemas/object.js.map +1 -1
- package/dist/core/codegen/schemas/optional.d.ts +9 -6
- package/dist/core/codegen/schemas/optional.d.ts.map +1 -1
- package/dist/core/codegen/schemas/optional.js +23 -31
- package/dist/core/codegen/schemas/optional.js.map +1 -1
- package/dist/core/codegen/schemas/pipe.d.ts +8 -5
- package/dist/core/codegen/schemas/pipe.d.ts.map +1 -1
- package/dist/core/codegen/schemas/pipe.js +20 -27
- package/dist/core/codegen/schemas/pipe.js.map +1 -1
- package/dist/core/codegen/schemas/readonly.d.ts +8 -5
- package/dist/core/codegen/schemas/readonly.d.ts.map +1 -1
- package/dist/core/codegen/schemas/readonly.js +8 -5
- package/dist/core/codegen/schemas/readonly.js.map +1 -1
- package/dist/core/codegen/schemas/record.d.ts +8 -5
- package/dist/core/codegen/schemas/record.d.ts.map +1 -1
- package/dist/core/codegen/schemas/record.js +52 -65
- package/dist/core/codegen/schemas/record.js.map +1 -1
- package/dist/core/codegen/schemas/recursive-ref.d.ts +9 -6
- package/dist/core/codegen/schemas/recursive-ref.d.ts.map +1 -1
- package/dist/core/codegen/schemas/recursive-ref.js +44 -44
- package/dist/core/codegen/schemas/recursive-ref.js.map +1 -1
- package/dist/core/codegen/schemas/set.d.ts +8 -5
- package/dist/core/codegen/schemas/set.d.ts.map +1 -1
- package/dist/core/codegen/schemas/set.js +61 -73
- package/dist/core/codegen/schemas/set.js.map +1 -1
- package/dist/core/codegen/schemas/string-bool.d.ts +6 -3
- package/dist/core/codegen/schemas/string-bool.d.ts.map +1 -1
- package/dist/core/codegen/schemas/string-bool.js +22 -23
- package/dist/core/codegen/schemas/string-bool.js.map +1 -1
- package/dist/core/codegen/schemas/string.d.ts +8 -5
- package/dist/core/codegen/schemas/string.d.ts.map +1 -1
- package/dist/core/codegen/schemas/string.js +168 -207
- package/dist/core/codegen/schemas/string.js.map +1 -1
- package/dist/core/codegen/schemas/symbol.d.ts +7 -4
- package/dist/core/codegen/schemas/symbol.d.ts.map +1 -1
- package/dist/core/codegen/schemas/symbol.js +8 -4
- package/dist/core/codegen/schemas/symbol.js.map +1 -1
- package/dist/core/codegen/schemas/template-literal.d.ts +7 -4
- package/dist/core/codegen/schemas/template-literal.d.ts.map +1 -1
- package/dist/core/codegen/schemas/template-literal.js +12 -13
- package/dist/core/codegen/schemas/template-literal.js.map +1 -1
- package/dist/core/codegen/schemas/tuple.d.ts +8 -5
- package/dist/core/codegen/schemas/tuple.d.ts.map +1 -1
- package/dist/core/codegen/schemas/tuple.js +84 -94
- package/dist/core/codegen/schemas/tuple.js.map +1 -1
- package/dist/core/codegen/schemas/undefined.d.ts +7 -4
- package/dist/core/codegen/schemas/undefined.d.ts.map +1 -1
- package/dist/core/codegen/schemas/undefined.js +8 -4
- package/dist/core/codegen/schemas/undefined.js.map +1 -1
- package/dist/core/codegen/schemas/union.d.ts +8 -5
- package/dist/core/codegen/schemas/union.d.ts.map +1 -1
- package/dist/core/codegen/schemas/union.js +49 -69
- package/dist/core/codegen/schemas/union.js.map +1 -1
- package/dist/core/codegen/schemas/unknown.d.ts +7 -4
- package/dist/core/codegen/schemas/unknown.d.ts.map +1 -1
- package/dist/core/codegen/schemas/unknown.js +8 -4
- package/dist/core/codegen/schemas/unknown.js.map +1 -1
- package/dist/core/codegen/schemas/void.d.ts +7 -4
- package/dist/core/codegen/schemas/void.d.ts.map +1 -1
- package/dist/core/codegen/schemas/void.js +8 -4
- package/dist/core/codegen/schemas/void.js.map +1 -1
- package/dist/core/codegen/slow-path.d.ts +7 -4
- package/dist/core/codegen/slow-path.d.ts.map +1 -1
- package/dist/core/codegen/slow-path.js +71 -96
- package/dist/core/codegen/slow-path.js.map +1 -1
- package/dist/core/codegen/well-known-regex.d.ts +22 -19
- package/dist/core/codegen/well-known-regex.d.ts.map +1 -1
- package/dist/core/codegen/well-known-regex.js +127 -96
- package/dist/core/codegen/well-known-regex.js.map +1 -1
- package/dist/core/compile.d.ts +7 -4
- package/dist/core/compile.d.ts.map +1 -1
- package/dist/core/compile.js +48 -48
- package/dist/core/compile.js.map +1 -1
- package/dist/core/diagnostic.d.ts +38 -39
- package/dist/core/diagnostic.d.ts.map +1 -1
- package/dist/core/diagnostic.js +140 -164
- package/dist/core/diagnostic.js.map +1 -1
- package/dist/core/extract/checks.d.ts +18 -15
- package/dist/core/extract/checks.d.ts.map +1 -1
- package/dist/core/extract/checks.js +318 -311
- package/dist/core/extract/checks.js.map +1 -1
- package/dist/core/extract/effects.d.ts +13 -10
- package/dist/core/extract/effects.d.ts.map +1 -1
- package/dist/core/extract/effects.js +153 -222
- package/dist/core/extract/effects.js.map +1 -1
- package/dist/core/extract/extractors/any.d.ts +5 -2
- package/dist/core/extract/extractors/any.d.ts.map +1 -1
- package/dist/core/extract/extractors/any.js +5 -1
- package/dist/core/extract/extractors/any.js.map +1 -1
- package/dist/core/extract/extractors/array.d.ts +6 -3
- package/dist/core/extract/extractors/array.d.ts.map +1 -1
- package/dist/core/extract/extractors/array.js +25 -20
- package/dist/core/extract/extractors/array.js.map +1 -1
- package/dist/core/extract/extractors/bigint.d.ts +6 -3
- package/dist/core/extract/extractors/bigint.d.ts.map +1 -1
- package/dist/core/extract/extractors/bigint.js +66 -64
- package/dist/core/extract/extractors/bigint.js.map +1 -1
- package/dist/core/extract/extractors/boolean.d.ts +5 -2
- package/dist/core/extract/extractors/boolean.d.ts.map +1 -1
- package/dist/core/extract/extractors/boolean.js +7 -3
- package/dist/core/extract/extractors/boolean.js.map +1 -1
- package/dist/core/extract/extractors/catch.d.ts +6 -3
- package/dist/core/extract/extractors/catch.d.ts.map +1 -1
- package/dist/core/extract/extractors/catch.js +26 -17
- package/dist/core/extract/extractors/catch.js.map +1 -1
- package/dist/core/extract/extractors/date.d.ts +6 -3
- package/dist/core/extract/extractors/date.d.ts.map +1 -1
- package/dist/core/extract/extractors/date.js +42 -46
- package/dist/core/extract/extractors/date.js.map +1 -1
- package/dist/core/extract/extractors/default.d.ts +6 -3
- package/dist/core/extract/extractors/default.d.ts.map +1 -1
- package/dist/core/extract/extractors/default.js +20 -14
- package/dist/core/extract/extractors/default.js.map +1 -1
- package/dist/core/extract/extractors/enum.d.ts +5 -2
- package/dist/core/extract/extractors/enum.d.ts.map +1 -1
- package/dist/core/extract/extractors/enum.js +12 -13
- package/dist/core/extract/extractors/enum.js.map +1 -1
- package/dist/core/extract/extractors/file.d.ts +6 -3
- package/dist/core/extract/extractors/file.d.ts.map +1 -1
- package/dist/core/extract/extractors/file.js +34 -28
- package/dist/core/extract/extractors/file.js.map +1 -1
- package/dist/core/extract/extractors/intersection.d.ts +5 -2
- package/dist/core/extract/extractors/intersection.d.ts.map +1 -1
- package/dist/core/extract/extractors/intersection.js +13 -11
- package/dist/core/extract/extractors/intersection.js.map +1 -1
- package/dist/core/extract/extractors/lazy.d.ts +6 -3
- package/dist/core/extract/extractors/lazy.d.ts.map +1 -1
- package/dist/core/extract/extractors/lazy.js +21 -30
- package/dist/core/extract/extractors/lazy.js.map +1 -1
- package/dist/core/extract/extractors/literal.d.ts +5 -2
- package/dist/core/extract/extractors/literal.d.ts.map +1 -1
- package/dist/core/extract/extractors/literal.js +8 -1
- package/dist/core/extract/extractors/literal.js.map +1 -1
- package/dist/core/extract/extractors/map.d.ts +6 -3
- package/dist/core/extract/extractors/map.d.ts.map +1 -1
- package/dist/core/extract/extractors/map.js +10 -4
- package/dist/core/extract/extractors/map.js.map +1 -1
- package/dist/core/extract/extractors/nan.d.ts +5 -2
- package/dist/core/extract/extractors/nan.d.ts.map +1 -1
- package/dist/core/extract/extractors/nan.js +5 -1
- package/dist/core/extract/extractors/nan.js.map +1 -1
- package/dist/core/extract/extractors/never.d.ts +5 -2
- package/dist/core/extract/extractors/never.d.ts.map +1 -1
- package/dist/core/extract/extractors/never.js +5 -1
- package/dist/core/extract/extractors/never.js.map +1 -1
- package/dist/core/extract/extractors/null.d.ts +5 -2
- package/dist/core/extract/extractors/null.d.ts.map +1 -1
- package/dist/core/extract/extractors/null.js +5 -1
- package/dist/core/extract/extractors/null.js.map +1 -1
- package/dist/core/extract/extractors/nullable.d.ts +5 -2
- package/dist/core/extract/extractors/nullable.d.ts.map +1 -1
- package/dist/core/extract/extractors/nullable.js +7 -3
- package/dist/core/extract/extractors/nullable.js.map +1 -1
- package/dist/core/extract/extractors/number.d.ts +6 -3
- package/dist/core/extract/extractors/number.d.ts.map +1 -1
- package/dist/core/extract/extractors/number.js +35 -35
- package/dist/core/extract/extractors/number.js.map +1 -1
- package/dist/core/extract/extractors/object.d.ts +6 -3
- package/dist/core/extract/extractors/object.d.ts.map +1 -1
- package/dist/core/extract/extractors/object.js +49 -76
- package/dist/core/extract/extractors/object.js.map +1 -1
- package/dist/core/extract/extractors/optional.d.ts +5 -2
- package/dist/core/extract/extractors/optional.d.ts.map +1 -1
- package/dist/core/extract/extractors/optional.js +10 -12
- package/dist/core/extract/extractors/optional.js.map +1 -1
- package/dist/core/extract/extractors/pipe.d.ts +6 -3
- package/dist/core/extract/extractors/pipe.d.ts.map +1 -1
- package/dist/core/extract/extractors/pipe.js +40 -41
- package/dist/core/extract/extractors/pipe.js.map +1 -1
- package/dist/core/extract/extractors/readonly.d.ts +5 -2
- package/dist/core/extract/extractors/readonly.d.ts.map +1 -1
- package/dist/core/extract/extractors/readonly.js +10 -6
- package/dist/core/extract/extractors/readonly.js.map +1 -1
- package/dist/core/extract/extractors/record.d.ts +6 -3
- package/dist/core/extract/extractors/record.d.ts.map +1 -1
- package/dist/core/extract/extractors/record.js +24 -35
- package/dist/core/extract/extractors/record.js.map +1 -1
- package/dist/core/extract/extractors/set.d.ts +6 -3
- package/dist/core/extract/extractors/set.d.ts.map +1 -1
- package/dist/core/extract/extractors/set.js +36 -30
- package/dist/core/extract/extractors/set.js.map +1 -1
- package/dist/core/extract/extractors/string-bool.d.ts +7 -4
- package/dist/core/extract/extractors/string-bool.d.ts.map +1 -1
- package/dist/core/extract/extractors/string-bool.js +66 -84
- package/dist/core/extract/extractors/string-bool.js.map +1 -1
- package/dist/core/extract/extractors/string.d.ts +6 -3
- package/dist/core/extract/extractors/string.d.ts.map +1 -1
- package/dist/core/extract/extractors/string.js +34 -37
- package/dist/core/extract/extractors/string.js.map +1 -1
- package/dist/core/extract/extractors/symbol.d.ts +5 -2
- package/dist/core/extract/extractors/symbol.d.ts.map +1 -1
- package/dist/core/extract/extractors/symbol.js +5 -1
- package/dist/core/extract/extractors/symbol.js.map +1 -1
- package/dist/core/extract/extractors/template-literal.d.ts +6 -3
- package/dist/core/extract/extractors/template-literal.d.ts.map +1 -1
- package/dist/core/extract/extractors/template-literal.js +11 -6
- package/dist/core/extract/extractors/template-literal.js.map +1 -1
- package/dist/core/extract/extractors/tuple.d.ts +6 -3
- package/dist/core/extract/extractors/tuple.d.ts.map +1 -1
- package/dist/core/extract/extractors/tuple.js +10 -4
- package/dist/core/extract/extractors/tuple.js.map +1 -1
- package/dist/core/extract/extractors/undefined.d.ts +5 -2
- package/dist/core/extract/extractors/undefined.d.ts.map +1 -1
- package/dist/core/extract/extractors/undefined.js +5 -1
- package/dist/core/extract/extractors/undefined.js.map +1 -1
- package/dist/core/extract/extractors/union.d.ts +6 -3
- package/dist/core/extract/extractors/union.d.ts.map +1 -1
- package/dist/core/extract/extractors/union.js +38 -64
- package/dist/core/extract/extractors/union.js.map +1 -1
- package/dist/core/extract/extractors/unknown.d.ts +5 -2
- package/dist/core/extract/extractors/unknown.d.ts.map +1 -1
- package/dist/core/extract/extractors/unknown.js +5 -1
- package/dist/core/extract/extractors/unknown.js.map +1 -1
- package/dist/core/extract/extractors/void.d.ts +5 -2
- package/dist/core/extract/extractors/void.d.ts.map +1 -1
- package/dist/core/extract/extractors/void.js +5 -1
- package/dist/core/extract/extractors/void.js.map +1 -1
- package/dist/core/extract/fallback.d.ts +6 -3
- package/dist/core/extract/fallback.d.ts.map +1 -1
- package/dist/core/extract/fallback.js +21 -7
- package/dist/core/extract/fallback.js.map +1 -1
- package/dist/core/extract/index.d.ts +6 -4
- package/dist/core/extract/index.d.ts.map +1 -1
- package/dist/core/extract/index.js +15 -15
- package/dist/core/extract/index.js.map +1 -1
- package/dist/core/extract/registry.d.ts +39 -36
- package/dist/core/extract/registry.d.ts.map +1 -1
- package/dist/core/extract/registry.js +96 -123
- package/dist/core/extract/registry.js.map +1 -1
- package/dist/core/extract/types.d.ts +124 -120
- package/dist/core/extract/types.d.ts.map +1 -1
- package/dist/core/extract/types.js +0 -1
- package/dist/core/iife.d.ts +14 -15
- package/dist/core/iife.d.ts.map +1 -1
- package/dist/core/iife.js +182 -206
- package/dist/core/iife.js.map +1 -1
- package/dist/core/pipeline.d.ts +33 -30
- package/dist/core/pipeline.d.ts.map +1 -1
- package/dist/core/pipeline.js +67 -74
- package/dist/core/pipeline.js.map +1 -1
- package/dist/core/types.d.ts +430 -427
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/types.js +0 -5
- package/dist/discovery.d.ts +8 -5
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +31 -32
- package/dist/discovery.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +2 -2
- package/dist/jit.d.ts +15 -42
- package/dist/jit.d.ts.map +1 -1
- package/dist/jit.js +187 -216
- package/dist/jit.js.map +1 -1
- package/dist/loader.d.ts +14 -11
- package/dist/loader.d.ts.map +1 -1
- package/dist/loader.js +226 -258
- package/dist/loader.js.map +1 -1
- package/dist/static-filter.d.ts +4 -1
- package/dist/static-filter.d.ts.map +1 -1
- package/dist/static-filter.js +240 -367
- package/dist/static-filter.js.map +1 -1
- package/dist/swc.d.ts +38 -35
- package/dist/swc.d.ts.map +1 -1
- package/dist/swc.js +83 -76
- package/dist/swc.js.map +1 -1
- package/dist/unplugin/bun.d.ts +5 -2
- package/dist/unplugin/bun.d.ts.map +1 -1
- package/dist/unplugin/bun.js +5 -1
- package/dist/unplugin/bun.js.map +1 -1
- package/dist/unplugin/dep-graph.d.ts +10 -7
- package/dist/unplugin/dep-graph.d.ts.map +1 -1
- package/dist/unplugin/dep-graph.js +216 -252
- package/dist/unplugin/dep-graph.js.map +1 -1
- package/dist/unplugin/disk-cache.d.ts +121 -92
- package/dist/unplugin/disk-cache.d.ts.map +1 -1
- package/dist/unplugin/disk-cache.js +425 -444
- package/dist/unplugin/disk-cache.js.map +1 -1
- package/dist/unplugin/edits.d.ts +15 -12
- package/dist/unplugin/edits.d.ts.map +1 -1
- package/dist/unplugin/edits.js +24 -37
- package/dist/unplugin/edits.js.map +1 -1
- package/dist/unplugin/esbuild.d.ts +5 -2
- package/dist/unplugin/esbuild.d.ts.map +1 -1
- package/dist/unplugin/esbuild.js +5 -1
- package/dist/unplugin/esbuild.js.map +1 -1
- package/dist/unplugin/farm.d.ts +5 -2
- package/dist/unplugin/farm.d.ts.map +1 -1
- package/dist/unplugin/farm.js +5 -1
- package/dist/unplugin/farm.js.map +1 -1
- package/dist/unplugin/hoist-compile.d.ts +14 -42
- package/dist/unplugin/hoist-compile.d.ts.map +1 -1
- package/dist/unplugin/hoist-compile.js +67 -112
- package/dist/unplugin/hoist-compile.js.map +1 -1
- package/dist/unplugin/hoist.d.ts +56 -54
- package/dist/unplugin/hoist.d.ts.map +1 -1
- package/dist/unplugin/hoist.js +945 -1170
- package/dist/unplugin/hoist.js.map +1 -1
- package/dist/unplugin/index.d.ts +5 -3
- package/dist/unplugin/index.d.ts.map +1 -1
- package/dist/unplugin/index.js +175 -250
- package/dist/unplugin/index.js.map +1 -1
- package/dist/unplugin/rolldown.d.ts +5 -2
- package/dist/unplugin/rolldown.d.ts.map +1 -1
- package/dist/unplugin/rolldown.js +5 -1
- package/dist/unplugin/rolldown.js.map +1 -1
- package/dist/unplugin/rollup.d.ts +5 -2
- package/dist/unplugin/rollup.d.ts.map +1 -1
- package/dist/unplugin/rollup.js +5 -1
- package/dist/unplugin/rollup.js.map +1 -1
- package/dist/unplugin/rsbuild.d.ts +6 -3
- package/dist/unplugin/rsbuild.d.ts.map +1 -1
- package/dist/unplugin/rsbuild.js +15 -11
- package/dist/unplugin/rsbuild.js.map +1 -1
- package/dist/unplugin/rspack.d.ts +5 -2
- package/dist/unplugin/rspack.d.ts.map +1 -1
- package/dist/unplugin/rspack.js +5 -1
- package/dist/unplugin/rspack.js.map +1 -1
- package/dist/unplugin/transform.d.ts +30 -27
- package/dist/unplugin/transform.d.ts.map +1 -1
- package/dist/unplugin/transform.js +433 -620
- package/dist/unplugin/transform.js.map +1 -1
- package/dist/unplugin/types.d.ts +189 -184
- package/dist/unplugin/types.d.ts.map +1 -1
- package/dist/unplugin/types.js +22 -18
- package/dist/unplugin/types.js.map +1 -1
- package/dist/unplugin/virtual.d.ts +11 -8
- package/dist/unplugin/virtual.d.ts.map +1 -1
- package/dist/unplugin/virtual.js +65 -83
- package/dist/unplugin/virtual.js.map +1 -1
- package/dist/unplugin/vite.d.ts +5 -2
- package/dist/unplugin/vite.d.ts.map +1 -1
- package/dist/unplugin/vite.js +5 -1
- package/dist/unplugin/vite.js.map +1 -1
- package/dist/unplugin/webpack.d.ts +5 -2
- package/dist/unplugin/webpack.d.ts.map +1 -1
- package/dist/unplugin/webpack.js +5 -1
- package/dist/unplugin/webpack.js.map +1 -1
- package/package.json +23 -14
- package/dist/cli/index.d.ts.map +0 -1
- package/dist/core/extract/types.js.map +0 -1
- package/dist/core/types.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
|
@@ -1,201 +1,202 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { BigIntCheckIR, CheckIR, DateCheckIR, SchemaIR, SetCheckIR } from "../types.js";
|
|
2
|
+
import { SharedSchemaPlan } from "./dedupe.js";
|
|
3
|
+
//#region src/core/codegen/context.d.ts
|
|
3
4
|
/** Codegen output mode. "inline" emits self-contained code (CLI .compiled.ts). "lean" emits references to imports from "virtual:zod-compiler/runtime" (unplugin). */
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
5
|
+
type CodegenMode = "inline" | "lean";
|
|
6
|
+
interface CodeGenResult {
|
|
7
|
+
code: string;
|
|
8
|
+
functionDef: string;
|
|
9
|
+
/** Number of fallback schemas referenced by __rf[N] in the generated code. 0 = no fallbacks. */
|
|
10
|
+
refCount: number;
|
|
11
|
+
/**
|
|
12
|
+
* Helper names referenced by this schema in lean mode (e.g. "__zcTS", "__zcReEmail").
|
|
13
|
+
* Used by the unplugin transform to construct the `import { ... } from "virtual:zod-compiler/runtime"` line.
|
|
14
|
+
* Always empty in inline mode.
|
|
15
|
+
*/
|
|
16
|
+
usedHelpers: Set<string>;
|
|
17
|
+
/**
|
|
18
|
+
* Name of the hosted fast-check boolean function in the preamble (null when
|
|
19
|
+
* the schema has no Fast Path). generateIIFE passes it to __zcMkv so parse()
|
|
20
|
+
* and parseAsync() can return valid input without allocating an
|
|
21
|
+
* intermediate SafeParseResult.
|
|
22
|
+
*/
|
|
23
|
+
fastFnName: string | null;
|
|
24
|
+
/**
|
|
25
|
+
* True when `fastFnName` is a TOTAL predicate: `fc(input) === true` iff the
|
|
26
|
+
* schema accepts `input` (mutation-free schemas, where a fast-check failure
|
|
27
|
+
* can never become a slow-path success). generateIIFE installs it as the
|
|
28
|
+
* zero-allocation `.is()` guard. False for partial fast paths
|
|
29
|
+
* (default/catch — `fc` only shortcuts present-and-valid input, so a `false`
|
|
30
|
+
* result does NOT imply rejection) and for schemas with no fast path, such as
|
|
31
|
+
* coercion; `.is()` then derives from `safeParse(input).success`.
|
|
32
|
+
*/
|
|
33
|
+
fastTotal: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Hosted predicate installed as `.is()`, when it differs from `fastFnName`.
|
|
36
|
+
* A schema that rebuilds its output has no by-reference shortcut (so
|
|
37
|
+
* `fastFnName` is null) yet still has an exact acceptance predicate, because
|
|
38
|
+
* stripping reshapes the payload and never the verdict.
|
|
39
|
+
*/
|
|
40
|
+
isFnName?: string | null;
|
|
41
|
+
/**
|
|
42
|
+
* Compact mode only: the `__rf[N]` index this validator delegates its cold
|
|
43
|
+
* error path to (the schema itself, captured as a fresh root RefEntry). When
|
|
44
|
+
* set, the pipeline appends a `{ schema, accessPath: "" }` entry at this index
|
|
45
|
+
* so `generateIIFE` materializes `__rf[N]` as the original Zod schema. Absent
|
|
46
|
+
* for every non-compact (fully compiled) validator.
|
|
47
|
+
*/
|
|
48
|
+
rootDelegateRefIndex?: number;
|
|
48
49
|
}
|
|
49
50
|
/** Hosted-validator names for one recursion target (see CodeGenContext.recTargets). */
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
51
|
+
interface RecTargetGen {
|
|
52
|
+
/** True for the root target (refId 0) — reuses the schema's own functions. */
|
|
53
|
+
isRoot: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* safeParse-shaped slow validator name: `safeParse_<name>` for the root,
|
|
56
|
+
* `__rsp_N` for a non-root target. `slowRecursiveRef` calls this.
|
|
57
|
+
*/
|
|
58
|
+
slowName: string;
|
|
59
|
+
/**
|
|
60
|
+
* Boolean fast-check name (`__fcr_N`). Allocated lazily for the root (mirrors
|
|
61
|
+
* recFastName), eagerly for non-root targets. Absent until the fast path
|
|
62
|
+
* reaches a ref to this target.
|
|
63
|
+
*/
|
|
64
|
+
fastName?: string;
|
|
65
|
+
/** Inner IR hosted as the standalone validator body (non-root targets only). */
|
|
66
|
+
inner?: SchemaIR;
|
|
66
67
|
}
|
|
67
68
|
/** Shared mutable state for code generation. Fast and slow paths share the same instance. */
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
69
|
+
interface CodeGenContext {
|
|
70
|
+
preamble: string[];
|
|
71
|
+
counter: number;
|
|
72
|
+
fnName: string;
|
|
73
|
+
/** Deduplicates regex patterns: same pattern string → same preamble variable name. */
|
|
74
|
+
regexCache: Map<string, string>;
|
|
75
|
+
/** Codegen output mode. */
|
|
76
|
+
mode: CodegenMode;
|
|
77
|
+
/** Names of helpers from "virtual:zod-compiler/runtime" referenced in this schema (lean mode only). */
|
|
78
|
+
usedHelpers: Set<string>;
|
|
79
|
+
/**
|
|
80
|
+
* Name of the fast-path boolean helper for the ROOT recursion target
|
|
81
|
+
* (refId 0), allocated on first fastRecursiveRef visit. generateValidator
|
|
82
|
+
* wraps the root fast expression as `function <name>(input){return <expr>;}`
|
|
83
|
+
* so recursive refs can call it. undefined = root has no recursion on the
|
|
84
|
+
* fast path.
|
|
85
|
+
*/
|
|
86
|
+
recFastName?: string;
|
|
87
|
+
/**
|
|
88
|
+
* Hosted-validator name table for recursion targets, keyed by refId. Entry 0
|
|
89
|
+
* is the root (the schema's own `safeParse_<name>` / `recFastName`); entries
|
|
90
|
+
* ≥ 1 are non-root targets hosted as standalone `__rsp_N` (slow) / `__fcr_N`
|
|
91
|
+
* (fast) helpers. `recursiveRef`/`recursionTarget` generators look up the
|
|
92
|
+
* call target here. Undefined when not generating a full validator (e.g. unit
|
|
93
|
+
* tests calling a single generator) — treated as root-only.
|
|
94
|
+
*/
|
|
95
|
+
recTargets?: Map<number, RecTargetGen>;
|
|
96
|
+
/** Dedup cache for hosted zero-capture effect functions: source text → preamble var. */
|
|
97
|
+
effectFnCache?: Map<string, string>;
|
|
98
|
+
/** Dedup cache for constant preamble declarations: initializer text → preamble var. */
|
|
99
|
+
valueCache?: Map<string, string>;
|
|
100
|
+
/** Name of the build path's FAIL sentinel, declared once per validator. */
|
|
101
|
+
buildFailName?: string;
|
|
102
|
+
/** Hosted build-function name per recursion target refId, so back-edges resolve. */
|
|
103
|
+
buildRecNames?: Map<number, string>;
|
|
104
|
+
/**
|
|
105
|
+
* Set by the build path when it emitted a `.default()` substitution. Such a
|
|
106
|
+
* schema ACCEPTS an input its fast expression rejects — `fastDefault` demands a
|
|
107
|
+
* present value, since the fast path's contract is `data === input` and a
|
|
108
|
+
* substituted default is not the input — so the expression is no longer an
|
|
109
|
+
* exact acceptance predicate and must not be installed as `.is()`. Stripping,
|
|
110
|
+
* by contrast, reshapes only the payload, which is why a build-path schema
|
|
111
|
+
* otherwise still hands its predicate over.
|
|
112
|
+
*/
|
|
113
|
+
buildSubstitutesValue?: boolean;
|
|
114
|
+
/** Memo for estimateFastCost (size-gated fast-check extraction). Lazily created. */
|
|
115
|
+
fastSizeCache?: WeakMap<SchemaIR, number>;
|
|
116
|
+
/** Memo for estimateRuntimeCost (cheapest-first check ordering). Lazily created. */
|
|
117
|
+
fastRuntimeCostCache?: WeakMap<SchemaIR, number>;
|
|
118
|
+
/**
|
|
119
|
+
* File-level shared slow-walk plan. Set only when generating a mutation-free
|
|
120
|
+
* schema (so shared walks stay on the deferred cold path); the slow-path
|
|
121
|
+
* visit() consults it to replace a repeated sub-IR with a `__zcSw_N` call.
|
|
122
|
+
*/
|
|
123
|
+
sharedSchemas?: SharedSchemaPlan;
|
|
123
124
|
}
|
|
124
125
|
/** Context object for slow-path (error-collecting) generator functions. */
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
126
|
+
interface SlowGen {
|
|
127
|
+
readonly input: string;
|
|
128
|
+
readonly output: string;
|
|
129
|
+
readonly path: string;
|
|
130
|
+
readonly issues: string;
|
|
131
|
+
readonly ctx: CodeGenContext;
|
|
132
|
+
/**
|
|
133
|
+
* Schema-level static error message of the node being generated
|
|
134
|
+
* (z.string({ error: "..." })). Default message for issues this node emits
|
|
135
|
+
* when the individual check has no message of its own. Set by generateSlow()
|
|
136
|
+
* from ir.typeMessage; never inherited by child nodes.
|
|
137
|
+
*/
|
|
138
|
+
readonly typeMsg?: string | undefined;
|
|
139
|
+
/**
|
|
140
|
+
* Name of a boolean variable that this node sets to `true` when it aborts in
|
|
141
|
+
* the zod sense (`payload.aborted`) — currently only a pipe/codec whose `in`
|
|
142
|
+
* step fails (zod's `handlePipeResult` sets `left.aborted = true`). A `union`
|
|
143
|
+
* allocates one per option and reads it during pruning so a pipe option whose
|
|
144
|
+
* `in` failed counts as aborted even when its only issue is a non-aborting
|
|
145
|
+
* `custom`/check-level code. Undefined when the node is not inside an
|
|
146
|
+
* abort-tracking option, in which case the abort is a no-op.
|
|
147
|
+
*
|
|
148
|
+
* Unlike input/output/path/issues, this is NOT inherited by `visit()`: it is
|
|
149
|
+
* cleared at every boundary unless a node explicitly forwards it (the
|
|
150
|
+
* pass-through wrappers optional/nullable/readonly do), mirroring how zod
|
|
151
|
+
* propagates `payload.aborted` through transparent wrappers but not across
|
|
152
|
+
* container boundaries.
|
|
153
|
+
*/
|
|
154
|
+
readonly aborted?: string | undefined;
|
|
155
|
+
/**
|
|
156
|
+
* Recursively generate validation for a child IR node.
|
|
157
|
+
* input/output/path/issues are inherited from parent unless overridden;
|
|
158
|
+
* `aborted` is the exception — it is only set when explicitly passed (see the
|
|
159
|
+
* `aborted` field doc), so it never leaks into container children.
|
|
160
|
+
* Union generators use `{ issues }` to redirect child errors to temporary arrays.
|
|
161
|
+
* Container generators use `{ input, output, path }` for element traversal.
|
|
162
|
+
*/
|
|
163
|
+
visit(ir: SchemaIR, overrides?: {
|
|
164
|
+
input?: string;
|
|
165
|
+
output?: string;
|
|
166
|
+
path?: string;
|
|
167
|
+
issues?: string;
|
|
168
|
+
aborted?: string | undefined;
|
|
169
|
+
}): string;
|
|
170
|
+
/** Generate a unique temp variable name: `__${prefix}_${counter++}` */
|
|
171
|
+
temp(prefix: string): string;
|
|
172
|
+
/** Add a regex to preamble and return the variable name. */
|
|
173
|
+
regex(prefix: string, pattern: string, flags?: string): string;
|
|
174
|
+
/** Add a Set to preamble and return the variable name. */
|
|
175
|
+
set(prefix: string, values: readonly unknown[]): string;
|
|
175
176
|
}
|
|
176
177
|
/** Slow-path generator function signature — registered in slowRegistry. */
|
|
177
|
-
|
|
178
|
+
type SlowGenerator<T extends SchemaIR = SchemaIR> = (ir: T, g: SlowGen) => string;
|
|
178
179
|
/**
|
|
179
180
|
* Per-emitted-function size accumulator for size-gated fast-check extraction.
|
|
180
181
|
* Shared by every node inlined into the same function; a fresh instance starts
|
|
181
182
|
* each hosted helper (and the root). See fast-size.ts / generateFast.
|
|
182
183
|
*/
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
184
|
+
interface FastScope {
|
|
185
|
+
used: number;
|
|
186
|
+
/**
|
|
187
|
+
* `var` temps that the function this scope is assembling must declare, in
|
|
188
|
+
* allocation order. Populated by {@link FastGen.local}; every site that
|
|
189
|
+
* materializes a function body from a fresh scope emits
|
|
190
|
+
* {@link declareFastTemps} at the top of that body.
|
|
191
|
+
*
|
|
192
|
+
* Function-scoped (never module-scoped) is load-bearing: a recursive
|
|
193
|
+
* validator re-enters itself while an outer frame still holds a live temp,
|
|
194
|
+
* and each invocation needs its own binding.
|
|
195
|
+
*/
|
|
196
|
+
temps: string[];
|
|
196
197
|
}
|
|
197
198
|
/** `var a,b;` declaration for a scope's temps, or "" when it allocated none. */
|
|
198
|
-
|
|
199
|
+
declare function declareFastTemps(scope: FastScope): string;
|
|
199
200
|
/**
|
|
200
201
|
* Fast check for a wrapper that compares its input against a sentinel and
|
|
201
202
|
* otherwise delegates to an inner schema — `optional` (`===undefined`),
|
|
@@ -215,59 +216,59 @@ export declare function declareFastTemps(scope: FastScope): string;
|
|
|
215
216
|
* element variable, a record value) is already a single load, so it keeps the
|
|
216
217
|
* shorter form and byte-identical output.
|
|
217
218
|
*/
|
|
218
|
-
|
|
219
|
+
declare function fastSentinelWrapper(g: FastGen, innerIR: SchemaIR, sentinel: string, joiner: "&&" | "||"): string | null;
|
|
219
220
|
/** Context object for fast-path (boolean expression) generator functions. */
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
221
|
+
interface FastGen {
|
|
222
|
+
readonly input: string;
|
|
223
|
+
readonly ctx: CodeGenContext;
|
|
224
|
+
/**
|
|
225
|
+
* Whether the CURRENT node may be hoisted into its own boolean helper when it
|
|
226
|
+
* (with the already-emitted siblings) would overflow the function size cap.
|
|
227
|
+
* False for the root and for a helper's own top node — those are already their
|
|
228
|
+
* own function — but their children are extractable. See generateFast.
|
|
229
|
+
*/
|
|
230
|
+
readonly extractable: boolean;
|
|
231
|
+
/** Accumulated size (≈ chars) of the function currently being assembled. */
|
|
232
|
+
readonly scope: FastScope;
|
|
233
|
+
/**
|
|
234
|
+
* Set on the gen for a discriminated-union option only: the discriminator
|
|
235
|
+
* key. Signals `fastObject` to omit its type-guard and skip re-checking that
|
|
236
|
+
* property (the switch already matched its value). Never propagated to child
|
|
237
|
+
* nodes — nested objects keep their own guard.
|
|
238
|
+
*/
|
|
239
|
+
readonly discSkipKey?: string | undefined;
|
|
240
|
+
/**
|
|
241
|
+
* Recursively generate fast-check expression for a child IR node.
|
|
242
|
+
* Returns null if any child is ineligible for fast path.
|
|
243
|
+
*/
|
|
244
|
+
visit(ir: SchemaIR, overrides?: {
|
|
245
|
+
input?: string;
|
|
246
|
+
discSkipKey?: string;
|
|
247
|
+
}): string | null;
|
|
248
|
+
/**
|
|
249
|
+
* A FastGen for emitting a SEPARATE function body (a hand-built preamble
|
|
250
|
+
* helper such as a discriminated-union switch or an array-element loop). It
|
|
251
|
+
* carries a FRESH size accumulator, so the helper's own content is size-gated
|
|
252
|
+
* against the cap independently of the caller — without this, a helper's body
|
|
253
|
+
* accrues to the caller's scope while the helper itself grows unbounded.
|
|
254
|
+
*/
|
|
255
|
+
scoped(input: string): FastGen;
|
|
256
|
+
/** Generate a unique temp variable name. */
|
|
257
|
+
temp(prefix: string): string;
|
|
258
|
+
/**
|
|
259
|
+
* Allocate a unique name AND record it on this scope so the enclosing
|
|
260
|
+
* emitted function declares it as a `var` (see {@link FastScope.temps}).
|
|
261
|
+
* Use for a value bound inside an expression — `(t=x["k"])===undefined` —
|
|
262
|
+
* where `temp()` alone would leave the name undeclared.
|
|
263
|
+
*/
|
|
264
|
+
local(prefix: string): string;
|
|
265
|
+
/** Add a regex to preamble and return the variable name. */
|
|
266
|
+
regex(prefix: string, pattern: string, flags?: string): string;
|
|
266
267
|
}
|
|
267
268
|
/** Fast-path generator function signature — registered in fastRegistry. */
|
|
268
|
-
|
|
269
|
+
type FastGenerator<T extends SchemaIR = SchemaIR> = (ir: T, g: FastGen) => string | null;
|
|
269
270
|
/** Allocate a fresh `__${prefix}_${n}` identifier and bump the shared counter. */
|
|
270
|
-
|
|
271
|
+
declare function emitTemp(ctx: CodeGenContext, prefix: string): string;
|
|
271
272
|
/**
|
|
272
273
|
* Host a zero-capture effect function (refine predicate, transform,
|
|
273
274
|
* overwrite) in the preamble and return its variable name. The inline
|
|
@@ -280,7 +281,7 @@ export declare function emitTemp(ctx: CodeGenContext, prefix: string): string;
|
|
|
280
281
|
* a single preamble binding is semantically identical. Deduped per schema
|
|
281
282
|
* by source text.
|
|
282
283
|
*/
|
|
283
|
-
|
|
284
|
+
declare function emitEffectFn(ctx: CodeGenContext, source: string): string;
|
|
284
285
|
/**
|
|
285
286
|
* Callable expression for a user callback — a refine predicate or a transform.
|
|
286
287
|
*
|
|
@@ -291,9 +292,9 @@ export declare function emitEffectFn(ctx: CodeGenContext, source: string): strin
|
|
|
291
292
|
* re-read per call, for the same reason call-invoked helpers are (a per-call
|
|
292
293
|
* array element load is not a foldable callee).
|
|
293
294
|
*/
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
295
|
+
declare function emitEffectCallable(ctx: CodeGenContext, effect: {
|
|
296
|
+
refIndex?: number | undefined;
|
|
297
|
+
source?: string | undefined;
|
|
297
298
|
}): string;
|
|
298
299
|
/**
|
|
299
300
|
* Pristine fallback delegate: declare `var __rfp_N=__rf[N].safeParse.bind(__rf[N]);`
|
|
@@ -312,14 +313,14 @@ export declare function emitEffectCallable(ctx: CodeGenContext, effect: {
|
|
|
312
313
|
* compiled validator (whose own delegates were captured even earlier), never
|
|
313
314
|
* a cycle.
|
|
314
315
|
*/
|
|
315
|
-
|
|
316
|
+
declare function emitRfDelegate(ctx: CodeGenContext, refIndex: number): string;
|
|
316
317
|
/**
|
|
317
318
|
* Resolve a regex pattern to a runtime variable name.
|
|
318
319
|
* Lean mode short-circuits well-known patterns to virtual-module names so the
|
|
319
320
|
* bundler can dedup across files; everything else is cached + declared in the
|
|
320
321
|
* per-IIFE preamble exactly once per pattern.
|
|
321
322
|
*/
|
|
322
|
-
|
|
323
|
+
declare function emitRegex(ctx: CodeGenContext, prefix: string, pattern: string, flags?: string): string;
|
|
323
324
|
/**
|
|
324
325
|
* Resolve the ORIGINAL `/source/flags` pattern string of a regex for issue
|
|
325
326
|
* reporting. Only needed when emitRegex swapped in a faster equivalent test
|
|
@@ -327,7 +328,7 @@ export declare function emitRegex(ctx: CodeGenContext, prefix: string, pattern:
|
|
|
327
328
|
* references the shared `<name>Src` virtual export so the original pattern
|
|
328
329
|
* stays a single bundle-wide string; inline mode declares it once per IIFE.
|
|
329
330
|
*/
|
|
330
|
-
|
|
331
|
+
declare function emitRegexSourceString(ctx: CodeGenContext, pattern: string): string;
|
|
331
332
|
/**
|
|
332
333
|
* Declare a constant value in the preamble and return its variable name,
|
|
333
334
|
* reusing an earlier declaration of the SAME initializer.
|
|
@@ -339,9 +340,9 @@ export declare function emitRegexSourceString(ctx: CodeGenContext, pattern: stri
|
|
|
339
340
|
* 20-value enum schema's generated bytes, 16% for an object with two identical
|
|
340
341
|
* enums. Keyed by initializer text, so only identical payloads collapse.
|
|
341
342
|
*/
|
|
342
|
-
|
|
343
|
+
declare function emitConstant(ctx: CodeGenContext, prefix: string, initializer: string): string;
|
|
343
344
|
/** Declare a `new Set([...])` in the preamble and return its variable name. */
|
|
344
|
-
|
|
345
|
+
declare function emitSet(ctx: CodeGenContext, prefix: string, values: readonly unknown[]): string;
|
|
345
346
|
/**
|
|
346
347
|
* Shape-key count at or below which the unknown-key pass compares with an
|
|
347
348
|
* inline `===` chain rather than a hashed lookup.
|
|
@@ -361,7 +362,7 @@ export declare function emitSet(ctx: CodeGenContext, prefix: string, values: rea
|
|
|
361
362
|
* only loses past ~96, where `Set.has` (not the table, which never wins at any
|
|
362
363
|
* size) takes over. 64 sits below that crossover and above any realistic shape.
|
|
363
364
|
*/
|
|
364
|
-
|
|
365
|
+
declare const KEY_MEMBERSHIP_INLINE_THRESHOLD = 64;
|
|
365
366
|
/**
|
|
366
367
|
* Boolean membership test for one key variable against a fixed key list.
|
|
367
368
|
* Empty list recognizes nothing.
|
|
@@ -371,7 +372,7 @@ export declare const KEY_MEMBERSHIP_INLINE_THRESHOLD = 64;
|
|
|
371
372
|
* by an object literal, so that key would silently read as unknown), which the
|
|
372
373
|
* Set has no trouble with.
|
|
373
374
|
*/
|
|
374
|
-
|
|
375
|
+
declare function keyMembershipTest(ctx: CodeGenContext, keys: readonly string[], keyVar: string): string;
|
|
375
376
|
/**
|
|
376
377
|
* Enum values at or below this count use inline === checks instead of Set.has().
|
|
377
378
|
* Measured on V8: for ≤5 values, an === chain beats Set.has by up to ~3x with
|
|
@@ -379,21 +380,21 @@ export declare function keyMembershipTest(ctx: CodeGenContext, keys: readonly st
|
|
|
379
380
|
* successful comparison, making subsequent arms pointer-equality — and is no
|
|
380
381
|
* worse than Set.has even with adversarial shared-prefix values.
|
|
381
382
|
*/
|
|
382
|
-
|
|
383
|
-
|
|
383
|
+
declare const ENUM_INLINE_THRESHOLD = 5;
|
|
384
|
+
declare function escapeString(s: string | number): string;
|
|
384
385
|
/**
|
|
385
386
|
* JS source for a primitive literal value (literal schemas, discriminator
|
|
386
387
|
* case labels). JSON.stringify covers string/number/boolean/null; bigint
|
|
387
388
|
* needs the `n` suffix (JSON.stringify throws and String(5n) renders a
|
|
388
389
|
* number literal that never strict-equals a bigint); undefined isn't JSON.
|
|
389
390
|
*/
|
|
390
|
-
|
|
391
|
+
declare function literalToJs(v: string | number | boolean | null | bigint | undefined): string;
|
|
391
392
|
/**
|
|
392
393
|
* Reference a shared runtime helper (e.g. __zcFsr) from generated code.
|
|
393
394
|
* Lean mode: registers it for the `virtual:zod-compiler/runtime` import.
|
|
394
395
|
* Inline mode: declares it once in the per-IIFE preamble.
|
|
395
396
|
*/
|
|
396
|
-
|
|
397
|
+
declare function emitRuntimeHelper(ctx: CodeGenContext, name: string, decl: string): string;
|
|
397
398
|
/**
|
|
398
399
|
* Extend a path expression with one or more scalar segment expressions
|
|
399
400
|
* (escaped string literals, numeric literals, or loop-variable names).
|
|
@@ -405,11 +406,11 @@ export declare function emitRuntimeHelper(ctx: CodeGenContext, name: string, dec
|
|
|
405
406
|
* (`["data"].concat("items").concat(__i_7)`). Opaque expressions fall back
|
|
406
407
|
* to .concat().
|
|
407
408
|
*/
|
|
408
|
-
|
|
409
|
+
declare function extendPath(parentPath: string, segExpr: string): string;
|
|
409
410
|
/** Extend a path expression with a static string key. */
|
|
410
|
-
|
|
411
|
+
declare function extendStaticPath(parentPath: string, key: string): string;
|
|
411
412
|
/** Extend a path expression with a numeric index. */
|
|
412
|
-
|
|
413
|
+
declare function extendStaticPathIndex(parentPath: string, index: number): string;
|
|
413
414
|
/**
|
|
414
415
|
* Check if a SchemaIR tree produces output that is not the input itself —
|
|
415
416
|
* either value-mutating operations (coerce, default, catch, overwrite) that
|
|
@@ -419,7 +420,7 @@ export declare function extendStaticPathIndex(parentPath: string, index: number)
|
|
|
419
420
|
* input), by generateValidator to keep such schemas off the by-reference fast
|
|
420
421
|
* path, and by the shared-walk dedup + intersection extractor to exclude them.
|
|
421
422
|
*/
|
|
422
|
-
|
|
423
|
+
declare function hasMutation(ir: SchemaIR): boolean;
|
|
423
424
|
/**
|
|
424
425
|
* Is a defaulted property's key guaranteed to appear in the stripped output?
|
|
425
426
|
*
|
|
@@ -433,7 +434,7 @@ export declare function hasMutation(ir: SchemaIR): boolean;
|
|
|
433
434
|
* branch runs only when `input[key] !== undefined`, which implies `key in input`
|
|
434
435
|
* — so zod's presence test keeps the key whatever the inner produced.
|
|
435
436
|
*/
|
|
436
|
-
|
|
437
|
+
declare function outputAlwaysDefined(ir: SchemaIR): boolean;
|
|
437
438
|
/**
|
|
438
439
|
* Does this schema reject `undefined` outright?
|
|
439
440
|
*
|
|
@@ -442,10 +443,12 @@ export declare function outputAlwaysDefined(ir: SchemaIR): boolean;
|
|
|
442
443
|
* `optin: "optional"` and accepts a shorter array. Conservative: anything that
|
|
443
444
|
* might accept, produce, or default to `undefined` answers false.
|
|
444
445
|
*/
|
|
445
|
-
|
|
446
|
+
declare function rejectsUndefined(ir: SchemaIR): boolean;
|
|
446
447
|
/**
|
|
447
448
|
* Sort comparator for CheckIR: cheapest/most-discriminating checks first.
|
|
448
449
|
* Used by fast-path generators after filtering out refine_effect entries.
|
|
449
450
|
*/
|
|
450
|
-
|
|
451
|
+
declare function checkPriority(a: CheckIR | BigIntCheckIR | DateCheckIR | SetCheckIR, b: CheckIR | BigIntCheckIR | DateCheckIR | SetCheckIR): number;
|
|
452
|
+
//#endregion
|
|
453
|
+
export { CodeGenContext, CodeGenResult, CodegenMode, ENUM_INLINE_THRESHOLD, FastGen, FastGenerator, FastScope, KEY_MEMBERSHIP_INLINE_THRESHOLD, RecTargetGen, SlowGen, SlowGenerator, checkPriority, declareFastTemps, emitConstant, emitEffectCallable, emitEffectFn, emitRegex, emitRegexSourceString, emitRfDelegate, emitRuntimeHelper, emitSet, emitTemp, escapeString, extendPath, extendStaticPath, extendStaticPathIndex, fastSentinelWrapper, hasMutation, keyMembershipTest, literalToJs, outputAlwaysDefined, rejectsUndefined };
|
|
451
454
|
//# sourceMappingURL=context.d.ts.map
|