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
package/dist/static-filter.js
CHANGED
|
@@ -1,396 +1,269 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { pathToFileURL } from "node:url";
|
|
3
3
|
import { parse } from "acorn";
|
|
4
|
+
//#region src/static-filter.ts
|
|
4
5
|
/** Lazily created jiti instance used only for single-file transpilation. */
|
|
5
6
|
let transformerPromise;
|
|
6
7
|
function getTransformer() {
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
transformerPromise ??= import("jiti").then(({ createJiti }) => createJiti(pathToFileURL(path.resolve("__zod-compiler-static-filter__.mjs")).href));
|
|
9
|
+
return transformerPromise;
|
|
9
10
|
}
|
|
10
11
|
/**
|
|
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
|
-
// Module mode: the CJS output has no import/export statements, but may
|
|
40
|
-
// contain top-level await (async transform).
|
|
41
|
-
program = parse(transpiled, { ecmaVersion: "latest", sourceType: "module" });
|
|
42
|
-
}
|
|
43
|
-
catch {
|
|
44
|
-
return true;
|
|
45
|
-
}
|
|
46
|
-
return analyzeProgram(program);
|
|
12
|
+
* Check whether a file's exports could include Zod schemas (or compile()
|
|
13
|
+
* results) without executing the file. `filename` selects the TS/JSX
|
|
14
|
+
* transforms; the file does not need to exist on disk.
|
|
15
|
+
*/
|
|
16
|
+
async function mayExportSchemas(code, filename) {
|
|
17
|
+
let transpiled;
|
|
18
|
+
try {
|
|
19
|
+
transpiled = (await getTransformer()).transform({
|
|
20
|
+
source: code,
|
|
21
|
+
filename,
|
|
22
|
+
ts: /\.[cm]?tsx?$/.test(filename),
|
|
23
|
+
jsx: /\.[cm]?[jt]sx$/.test(filename),
|
|
24
|
+
async: true
|
|
25
|
+
});
|
|
26
|
+
} catch {
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
if (transpiled.includes("__JITI_ERROR__")) return true;
|
|
30
|
+
let program;
|
|
31
|
+
try {
|
|
32
|
+
program = parse(transpiled, {
|
|
33
|
+
ecmaVersion: "latest",
|
|
34
|
+
sourceType: "module"
|
|
35
|
+
});
|
|
36
|
+
} catch {
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
return analyzeProgram(program);
|
|
47
40
|
}
|
|
48
41
|
function analyzeProgram(program) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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
|
-
|
|
123
|
-
|
|
124
|
-
|
|
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
|
-
if (exportTarget.kind === "local")
|
|
169
|
-
bindingNames.push(exportTarget.name);
|
|
170
|
-
exportTargets.push(exportTarget);
|
|
171
|
-
}
|
|
172
|
-
for (const exportTarget of exportTargets) {
|
|
173
|
-
if (exportTarget.kind === "named") {
|
|
174
|
-
if (classifyValue(value, false, new Set(), bindingNames) === "candidate")
|
|
175
|
-
return "candidate";
|
|
176
|
-
}
|
|
177
|
-
else if (exportTarget.kind === "default") {
|
|
178
|
-
if (classifyValue(value, true, new Set(), bindingNames) === "candidate")
|
|
179
|
-
return "candidate";
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
// Catch-all: the value itself may reference exports in a shape we did
|
|
183
|
-
// not positively classify (e.g. `exports.a = fn(exports.b)`).
|
|
184
|
-
return mentionsExports(value) ? "candidate" : "safe";
|
|
185
|
-
}
|
|
186
|
-
function processVariableDeclaration(stmt) {
|
|
187
|
-
for (const decl of stmt.declarations) {
|
|
188
|
-
if (!decl.init)
|
|
189
|
-
continue;
|
|
190
|
-
if (decl.id.type === "Identifier") {
|
|
191
|
-
if (processAssignment(decl.init, decl.id.name) === "candidate")
|
|
192
|
-
return "candidate";
|
|
193
|
-
}
|
|
194
|
-
else if (mentionsExports(decl.init)) {
|
|
195
|
-
// Destructuring declarators don't export by themselves (babel emits
|
|
196
|
-
// separate `exports.x = x` statements), but be paranoid about any
|
|
197
|
-
// exports reference hiding inside.
|
|
198
|
-
return "candidate";
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
return "safe";
|
|
202
|
-
}
|
|
203
|
-
function processStatement(stmt) {
|
|
204
|
-
switch (stmt.type) {
|
|
205
|
-
case "FunctionDeclaration":
|
|
206
|
-
case "ClassDeclaration":
|
|
207
|
-
// Bodies that touch exports (hand-written CJS patterns) are opaque.
|
|
208
|
-
return mentionsExports(stmt) ? "candidate" : "safe";
|
|
209
|
-
case "VariableDeclaration":
|
|
210
|
-
return processVariableDeclaration(stmt);
|
|
211
|
-
case "ExpressionStatement":
|
|
212
|
-
return processExpression(stmt.expression);
|
|
213
|
-
case "EmptyStatement":
|
|
214
|
-
return "safe";
|
|
215
|
-
default:
|
|
216
|
-
// if/try/for/... — babel never emits exports there for ESM input,
|
|
217
|
-
// but hand-written CJS might (`if (x) module.exports = ...`).
|
|
218
|
-
return mentionsExports(stmt) ? "candidate" : "safe";
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
function processExpression(expr) {
|
|
222
|
-
switch (expr.type) {
|
|
223
|
-
case "Literal":
|
|
224
|
-
// Directive prologue ("use strict")
|
|
225
|
-
return "safe";
|
|
226
|
-
case "AssignmentExpression":
|
|
227
|
-
return processAssignment(expr);
|
|
228
|
-
case "SequenceExpression": {
|
|
229
|
-
for (const sub of expr.expressions) {
|
|
230
|
-
if (processExpression(sub) === "candidate")
|
|
231
|
-
return "candidate";
|
|
232
|
-
}
|
|
233
|
-
return "safe";
|
|
234
|
-
}
|
|
235
|
-
case "CallExpression":
|
|
236
|
-
if (isEsModuleMarker(expr))
|
|
237
|
-
return "safe";
|
|
238
|
-
// Other exports-touching calls: re-export getters
|
|
239
|
-
// (Object.defineProperty), `export *` loops, helpers.
|
|
240
|
-
return mentionsExports(expr) ? "candidate" : "safe";
|
|
241
|
-
default:
|
|
242
|
-
return mentionsExports(expr) ? "candidate" : "safe";
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
for (const stmt of program.body) {
|
|
246
|
-
// The CJS output of jiti's transform contains no module declarations,
|
|
247
|
-
// but if one ever appears, treat the file as a candidate.
|
|
248
|
-
if (!isStatement(stmt))
|
|
249
|
-
return true;
|
|
250
|
-
if (processStatement(stmt) === "candidate")
|
|
251
|
-
return true;
|
|
252
|
-
}
|
|
253
|
-
return false;
|
|
42
|
+
const safeDecls = /* @__PURE__ */ new Set();
|
|
43
|
+
const varInits = /* @__PURE__ */ new Map();
|
|
44
|
+
const expectedNodes = /* @__PURE__ */ new Set();
|
|
45
|
+
function recordChainNodes(expr) {
|
|
46
|
+
let node = expr;
|
|
47
|
+
let hasExportTarget = false;
|
|
48
|
+
while (node.type === "AssignmentExpression" && node.operator === "=") {
|
|
49
|
+
if (node.left.type === "Identifier") expectedNodes.add(node.left);
|
|
50
|
+
else if (node.left.type === "MemberExpression" && mentionsExports(node.left)) hasExportTarget = true;
|
|
51
|
+
node = node.right;
|
|
52
|
+
}
|
|
53
|
+
if (hasExportTarget && node.type === "Identifier") expectedNodes.add(node);
|
|
54
|
+
}
|
|
55
|
+
for (const stmt of program.body) if (stmt.type === "FunctionDeclaration" || stmt.type === "ClassDeclaration") {
|
|
56
|
+
safeDecls.add(stmt.id.name);
|
|
57
|
+
expectedNodes.add(stmt.id);
|
|
58
|
+
} else if (stmt.type === "VariableDeclaration") for (const decl of stmt.declarations) {
|
|
59
|
+
if (decl.id.type === "Identifier") {
|
|
60
|
+
expectedNodes.add(decl.id);
|
|
61
|
+
varInits.set(decl.id.name, decl.init ? unwrapAssignmentChain(decl.init).value : null);
|
|
62
|
+
}
|
|
63
|
+
if (decl.init) recordChainNodes(decl.init);
|
|
64
|
+
}
|
|
65
|
+
else if (stmt.type === "ExpressionStatement") recordChainNodes(stmt.expression);
|
|
66
|
+
const referencedNames = collectReferencedNames(program, expectedNodes);
|
|
67
|
+
function resolveIdentifier(name, defaultish, seen) {
|
|
68
|
+
if (seen.has(name)) return "candidate";
|
|
69
|
+
seen.add(name);
|
|
70
|
+
if (safeDecls.has(name)) return "safe";
|
|
71
|
+
const init = varInits.get(name);
|
|
72
|
+
if (init === void 0 || init === null) return "candidate";
|
|
73
|
+
return classifyValue(init, defaultish, seen, [name]);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Could this expression evaluate to a Zod schema (an object carrying
|
|
77
|
+
* `_zod.def` or the compile() marker)? `bindingNames` are the local
|
|
78
|
+
* aliases of the value — a mutable container (object/array) is only safe
|
|
79
|
+
* when none of its aliases are referenced elsewhere in the file.
|
|
80
|
+
*/
|
|
81
|
+
function classifyValue(node, defaultish, seen, bindingNames) {
|
|
82
|
+
switch (node.type) {
|
|
83
|
+
case "Literal":
|
|
84
|
+
case "TemplateLiteral":
|
|
85
|
+
case "ArrowFunctionExpression":
|
|
86
|
+
case "FunctionExpression":
|
|
87
|
+
case "ClassExpression":
|
|
88
|
+
case "UnaryExpression":
|
|
89
|
+
case "UpdateExpression":
|
|
90
|
+
case "BinaryExpression": return "safe";
|
|
91
|
+
case "ObjectExpression":
|
|
92
|
+
case "ArrayExpression":
|
|
93
|
+
if (defaultish) return "candidate";
|
|
94
|
+
return bindingNames.some((n) => referencedNames.has(n)) ? "candidate" : "safe";
|
|
95
|
+
case "Identifier": return resolveIdentifier(node.name, defaultish, seen);
|
|
96
|
+
case "ConditionalExpression": return classifyValue(node.consequent, defaultish, seen, bindingNames) === "safe" && classifyValue(node.alternate, defaultish, seen, bindingNames) === "safe" ? "safe" : "candidate";
|
|
97
|
+
case "LogicalExpression": return classifyValue(node.left, defaultish, seen, bindingNames) === "safe" && classifyValue(node.right, defaultish, seen, bindingNames) === "safe" ? "safe" : "candidate";
|
|
98
|
+
case "SequenceExpression": {
|
|
99
|
+
const last = node.expressions[node.expressions.length - 1];
|
|
100
|
+
return last ? classifyValue(last, defaultish, seen, bindingNames) : "candidate";
|
|
101
|
+
}
|
|
102
|
+
case "AssignmentExpression": return classifyValue(unwrapAssignmentChain(node).value, defaultish, seen, bindingNames);
|
|
103
|
+
default: return "candidate";
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
/** Process one assignment chain: classify the value for each export target. */
|
|
107
|
+
function processAssignment(expr, declaredName) {
|
|
108
|
+
const { targets, value } = unwrapAssignmentChain(expr);
|
|
109
|
+
const bindingNames = declaredName ? [declaredName] : [];
|
|
110
|
+
const exportTargets = [];
|
|
111
|
+
for (const target of targets) {
|
|
112
|
+
const exportTarget = exportTargetOf(target);
|
|
113
|
+
if (exportTarget.kind === "unknown") return "candidate";
|
|
114
|
+
if (exportTarget.kind === "local") bindingNames.push(exportTarget.name);
|
|
115
|
+
exportTargets.push(exportTarget);
|
|
116
|
+
}
|
|
117
|
+
for (const exportTarget of exportTargets) if (exportTarget.kind === "named") {
|
|
118
|
+
if (classifyValue(value, false, /* @__PURE__ */ new Set(), bindingNames) === "candidate") return "candidate";
|
|
119
|
+
} else if (exportTarget.kind === "default") {
|
|
120
|
+
if (classifyValue(value, true, /* @__PURE__ */ new Set(), bindingNames) === "candidate") return "candidate";
|
|
121
|
+
}
|
|
122
|
+
return mentionsExports(value) ? "candidate" : "safe";
|
|
123
|
+
}
|
|
124
|
+
function processVariableDeclaration(stmt) {
|
|
125
|
+
for (const decl of stmt.declarations) {
|
|
126
|
+
if (!decl.init) continue;
|
|
127
|
+
if (decl.id.type === "Identifier") {
|
|
128
|
+
if (processAssignment(decl.init, decl.id.name) === "candidate") return "candidate";
|
|
129
|
+
} else if (mentionsExports(decl.init)) return "candidate";
|
|
130
|
+
}
|
|
131
|
+
return "safe";
|
|
132
|
+
}
|
|
133
|
+
function processStatement(stmt) {
|
|
134
|
+
switch (stmt.type) {
|
|
135
|
+
case "FunctionDeclaration":
|
|
136
|
+
case "ClassDeclaration": return mentionsExports(stmt) ? "candidate" : "safe";
|
|
137
|
+
case "VariableDeclaration": return processVariableDeclaration(stmt);
|
|
138
|
+
case "ExpressionStatement": return processExpression(stmt.expression);
|
|
139
|
+
case "EmptyStatement": return "safe";
|
|
140
|
+
default: return mentionsExports(stmt) ? "candidate" : "safe";
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
function processExpression(expr) {
|
|
144
|
+
switch (expr.type) {
|
|
145
|
+
case "Literal": return "safe";
|
|
146
|
+
case "AssignmentExpression": return processAssignment(expr);
|
|
147
|
+
case "SequenceExpression":
|
|
148
|
+
for (const sub of expr.expressions) if (processExpression(sub) === "candidate") return "candidate";
|
|
149
|
+
return "safe";
|
|
150
|
+
case "CallExpression":
|
|
151
|
+
if (isEsModuleMarker(expr)) return "safe";
|
|
152
|
+
return mentionsExports(expr) ? "candidate" : "safe";
|
|
153
|
+
default: return mentionsExports(expr) ? "candidate" : "safe";
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
for (const stmt of program.body) {
|
|
157
|
+
if (!isStatement(stmt)) return true;
|
|
158
|
+
if (processStatement(stmt) === "candidate") return true;
|
|
159
|
+
}
|
|
160
|
+
return false;
|
|
254
161
|
}
|
|
255
162
|
function isStatement(node) {
|
|
256
|
-
|
|
163
|
+
return !node.type.startsWith("Import") && !node.type.startsWith("Export");
|
|
257
164
|
}
|
|
258
165
|
/**
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
166
|
+
* Unwrap `a = b = c = value` into its assignment targets and final value.
|
|
167
|
+
* Non-assignment expressions return zero targets and themselves as value.
|
|
168
|
+
*/
|
|
262
169
|
function unwrapAssignmentChain(expr) {
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
170
|
+
const targets = [];
|
|
171
|
+
let value = expr;
|
|
172
|
+
while (value.type === "AssignmentExpression" && value.operator === "=") {
|
|
173
|
+
targets.push(value.left);
|
|
174
|
+
value = value.right;
|
|
175
|
+
}
|
|
176
|
+
return {
|
|
177
|
+
targets,
|
|
178
|
+
value
|
|
179
|
+
};
|
|
270
180
|
}
|
|
271
181
|
/** Classify an assignment target by what discovery would see. */
|
|
272
182
|
function exportTargetOf(target) {
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
if (target.object.type === "MemberExpression" &&
|
|
299
|
-
target.object.object.type === "Identifier" &&
|
|
300
|
-
target.object.object.name === "module" &&
|
|
301
|
-
!target.object.computed &&
|
|
302
|
-
target.object.property.type === "Identifier" &&
|
|
303
|
-
target.object.property.name === "exports") {
|
|
304
|
-
if (propName === null)
|
|
305
|
-
return { kind: "unknown" };
|
|
306
|
-
return propName === "default" ? { kind: "default" } : { kind: "named", name: propName };
|
|
307
|
-
}
|
|
308
|
-
return mentionsExports(target) ? { kind: "unknown" } : { kind: "ignored" };
|
|
183
|
+
if (target.type === "Identifier") {
|
|
184
|
+
if (target.name === "exports" || target.name === "module") return { kind: "unknown" };
|
|
185
|
+
return {
|
|
186
|
+
kind: "local",
|
|
187
|
+
name: target.name
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
if (target.type !== "MemberExpression") return mentionsExports(target) ? { kind: "unknown" } : { kind: "ignored" };
|
|
191
|
+
const propName = !target.computed && target.property.type === "Identifier" ? target.property.name : target.computed && target.property.type === "Literal" ? String(target.property.value) : null;
|
|
192
|
+
if (target.object.type === "Identifier" && target.object.name === "exports") {
|
|
193
|
+
if (propName === null) return { kind: "unknown" };
|
|
194
|
+
return propName === "default" ? { kind: "default" } : {
|
|
195
|
+
kind: "named",
|
|
196
|
+
name: propName
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
if (target.object.type === "Identifier" && target.object.name === "module") return propName === "exports" ? { kind: "default" } : { kind: "unknown" };
|
|
200
|
+
if (target.object.type === "MemberExpression" && target.object.object.type === "Identifier" && target.object.object.name === "module" && !target.object.computed && target.object.property.type === "Identifier" && target.object.property.name === "exports") {
|
|
201
|
+
if (propName === null) return { kind: "unknown" };
|
|
202
|
+
return propName === "default" ? { kind: "default" } : {
|
|
203
|
+
kind: "named",
|
|
204
|
+
name: propName
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
return mentionsExports(target) ? { kind: "unknown" } : { kind: "ignored" };
|
|
309
208
|
}
|
|
310
209
|
/** Object.defineProperty(exports, "__esModule", { value: true }) */
|
|
311
210
|
function isEsModuleMarker(expr) {
|
|
312
|
-
|
|
313
|
-
expr.callee.type === "MemberExpression" &&
|
|
314
|
-
expr.callee.object.type === "Identifier" &&
|
|
315
|
-
expr.callee.object.name === "Object" &&
|
|
316
|
-
!expr.callee.computed &&
|
|
317
|
-
expr.callee.property.type === "Identifier" &&
|
|
318
|
-
expr.callee.property.name === "defineProperty" &&
|
|
319
|
-
expr.arguments[0]?.type === "Identifier" &&
|
|
320
|
-
expr.arguments[0].name === "exports" &&
|
|
321
|
-
expr.arguments[1]?.type === "Literal" &&
|
|
322
|
-
expr.arguments[1].value === "__esModule");
|
|
211
|
+
return expr.type === "CallExpression" && expr.callee.type === "MemberExpression" && expr.callee.object.type === "Identifier" && expr.callee.object.name === "Object" && !expr.callee.computed && expr.callee.property.type === "Identifier" && expr.callee.property.name === "defineProperty" && expr.arguments[0]?.type === "Identifier" && expr.arguments[0].name === "exports" && expr.arguments[1]?.type === "Literal" && expr.arguments[1].value === "__esModule";
|
|
323
212
|
}
|
|
324
213
|
/**
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
214
|
+
* Collect every identifier name used in a reference position, excluding the
|
|
215
|
+
* `expected` nodes (declaration ids and exports-chain participants).
|
|
216
|
+
* Non-reference positions — non-computed member properties, non-computed
|
|
217
|
+
* object/class keys, labels — are skipped. Over-counting (e.g. shadowed
|
|
218
|
+
* names in nested scopes, function params) only makes the filter more
|
|
219
|
+
* conservative, never less safe.
|
|
220
|
+
*/
|
|
332
221
|
function collectReferencedNames(program, expected) {
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
continue;
|
|
359
|
-
if (key === "key" &&
|
|
360
|
-
(type === "Property" || type === "PropertyDefinition" || type === "MethodDefinition") &&
|
|
361
|
-
record["computed"] !== true)
|
|
362
|
-
continue;
|
|
363
|
-
if (key === "label")
|
|
364
|
-
continue;
|
|
365
|
-
stack.push(value);
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
return names;
|
|
222
|
+
const names = /* @__PURE__ */ new Set();
|
|
223
|
+
const stack = [program];
|
|
224
|
+
while (stack.length > 0) {
|
|
225
|
+
const node = stack.pop();
|
|
226
|
+
if (Array.isArray(node)) {
|
|
227
|
+
for (const item of node) stack.push(item);
|
|
228
|
+
continue;
|
|
229
|
+
}
|
|
230
|
+
if (typeof node !== "object" || node === null) continue;
|
|
231
|
+
const record = node;
|
|
232
|
+
const type = record["type"];
|
|
233
|
+
if (typeof type !== "string") continue;
|
|
234
|
+
if (type === "Identifier") {
|
|
235
|
+
if (!expected.has(node)) names.add(record["name"]);
|
|
236
|
+
continue;
|
|
237
|
+
}
|
|
238
|
+
for (const [key, value] of Object.entries(record)) {
|
|
239
|
+
if (typeof value !== "object" || value === null) continue;
|
|
240
|
+
if (key === "property" && type === "MemberExpression" && record["computed"] !== true) continue;
|
|
241
|
+
if (key === "key" && (type === "Property" || type === "PropertyDefinition" || type === "MethodDefinition") && record["computed"] !== true) continue;
|
|
242
|
+
if (key === "label") continue;
|
|
243
|
+
stack.push(value);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
return names;
|
|
369
247
|
}
|
|
370
248
|
/** Deep-walk an acorn node for any reference to `exports` or `module`. */
|
|
371
249
|
function mentionsExports(root) {
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
for (const value of Object.values(record)) {
|
|
390
|
-
if (typeof value === "object" && value !== null)
|
|
391
|
-
stack.push(value);
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
return false;
|
|
250
|
+
const stack = [root];
|
|
251
|
+
while (stack.length > 0) {
|
|
252
|
+
const node = stack.pop();
|
|
253
|
+
if (Array.isArray(node)) {
|
|
254
|
+
for (const item of node) stack.push(item);
|
|
255
|
+
continue;
|
|
256
|
+
}
|
|
257
|
+
if (typeof node !== "object" || node === null) continue;
|
|
258
|
+
const record = node;
|
|
259
|
+
if (typeof record["type"] === "string") {
|
|
260
|
+
if (record["type"] === "Identifier" && (record["name"] === "exports" || record["name"] === "module")) return true;
|
|
261
|
+
}
|
|
262
|
+
for (const value of Object.values(record)) if (typeof value === "object" && value !== null) stack.push(value);
|
|
263
|
+
}
|
|
264
|
+
return false;
|
|
395
265
|
}
|
|
266
|
+
//#endregion
|
|
267
|
+
export { mayExportSchemas };
|
|
268
|
+
|
|
396
269
|
//# sourceMappingURL=static-filter.js.map
|