@scriptc/compiler 0.4.6 → 0.4.7
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/ambient/node-fallback/events.d.ts +6 -1
- package/ambient/node-fallback/fs-promises.d.ts +1 -1
- package/ambient/node-fallback/fs.d.ts +54 -10
- package/ambient/node-fallback/http.d.ts +3 -1
- package/ambient/node-fallback/net.d.ts +19 -0
- package/ambient/node-fallback/querystring.d.ts +3 -3
- package/ambient/scriptc-node-fallback.d.ts +58 -13
- package/dist/backend/executable-features.js +13 -0
- package/dist/backend/executable-features.js.map +1 -1
- package/dist/backend/immutability.d.ts +12 -1
- package/dist/backend/immutability.js +50 -4
- package/dist/backend/immutability.js.map +1 -1
- package/dist/backend/immutability.test.js +95 -1
- package/dist/backend/immutability.test.js.map +1 -1
- package/dist/backend/library-pack.js +2 -0
- package/dist/backend/library-pack.js.map +1 -1
- package/dist/backend/linker.d.ts +11 -0
- package/dist/backend/linker.js +31 -3
- package/dist/backend/linker.js.map +1 -1
- package/dist/backend/lld.d.ts +7 -2
- package/dist/backend/lld.js +5 -3
- package/dist/backend/lld.js.map +1 -1
- package/dist/backend/lld.test.js +10 -4
- package/dist/backend/lld.test.js.map +1 -1
- package/dist/backend/llvm/constant-callbacks.test.js +50 -1
- package/dist/backend/llvm/constant-callbacks.test.js.map +1 -1
- package/dist/backend/llvm/cpu-dispatch.js +6 -5
- package/dist/backend/llvm/cpu-dispatch.js.map +1 -1
- package/dist/backend/llvm/dyn.d.ts +53 -1
- package/dist/backend/llvm/dyn.js +221 -9
- package/dist/backend/llvm/dyn.js.map +1 -1
- package/dist/backend/llvm/emit-function.js +1 -1
- package/dist/backend/llvm/emit-function.js.map +1 -1
- package/dist/backend/llvm/emit-module.js +148 -50
- package/dist/backend/llvm/emit-module.js.map +1 -1
- package/dist/backend/llvm/emit-statements.js +39 -19
- package/dist/backend/llvm/emit-statements.js.map +1 -1
- package/dist/backend/llvm/emitter.d.ts +29 -2
- package/dist/backend/llvm/emitter.js +86 -7
- package/dist/backend/llvm/emitter.js.map +1 -1
- package/dist/backend/llvm/expr-calls.d.ts +4 -1
- package/dist/backend/llvm/expr-calls.js +20 -4
- package/dist/backend/llvm/expr-calls.js.map +1 -1
- package/dist/backend/llvm/expr-dynamic.js +209 -16
- package/dist/backend/llvm/expr-dynamic.js.map +1 -1
- package/dist/backend/llvm/expr-primitives.js +94 -11
- package/dist/backend/llvm/expr-primitives.js.map +1 -1
- package/dist/backend/llvm/expr-stream-bridges.d.ts +8 -0
- package/dist/backend/llvm/expr-stream-bridges.js +42 -2
- package/dist/backend/llvm/expr-stream-bridges.js.map +1 -1
- package/dist/backend/llvm/expr-stream-callbacks.d.ts +16 -0
- package/dist/backend/llvm/expr-stream-callbacks.js +206 -20
- package/dist/backend/llvm/expr-stream-callbacks.js.map +1 -1
- package/dist/backend/llvm/integer-values.d.ts +2 -0
- package/dist/backend/llvm/integer-values.js +6 -0
- package/dist/backend/llvm/integer-values.js.map +1 -1
- package/dist/backend/llvm/js-ic.d.ts +38 -0
- package/dist/backend/llvm/js-ic.js +295 -1
- package/dist/backend/llvm/js-ic.js.map +1 -1
- package/dist/backend/llvm/lib-dispatch.js +20 -0
- package/dist/backend/llvm/lib-dispatch.js.map +1 -1
- package/dist/backend/llvm/lib-filesystem.js +116 -11
- package/dist/backend/llvm/lib-filesystem.js.map +1 -1
- package/dist/backend/llvm/lib-process.js +136 -24
- package/dist/backend/llvm/lib-process.js.map +1 -1
- package/dist/backend/llvm/lib-shared.js +70 -0
- package/dist/backend/llvm/lib-shared.js.map +1 -1
- package/dist/backend/llvm/lib-stream.js +67 -0
- package/dist/backend/llvm/lib-stream.js.map +1 -1
- package/dist/backend/llvm/loop-entry-versions.d.ts +2 -2
- package/dist/backend/llvm/loop-entry-versions.js +43 -21
- package/dist/backend/llvm/loop-entry-versions.js.map +1 -1
- package/dist/backend/llvm/loop-state.d.ts +7 -1
- package/dist/backend/llvm/loop-state.js +20 -2
- package/dist/backend/llvm/loop-state.js.map +1 -1
- package/dist/backend/llvm/map-number-lookup.d.ts +3 -1
- package/dist/backend/llvm/map-number-lookup.js +7 -3
- package/dist/backend/llvm/map-number-lookup.js.map +1 -1
- package/dist/backend/llvm/map-number-lookup.test.js +52 -11
- package/dist/backend/llvm/map-number-lookup.test.js.map +1 -1
- package/dist/backend/llvm/receiver-brackets.test.d.ts +1 -0
- package/dist/backend/llvm/receiver-brackets.test.js +68 -0
- package/dist/backend/llvm/receiver-brackets.test.js.map +1 -0
- package/dist/backend/llvm/record-views.d.ts +22 -2
- package/dist/backend/llvm/record-views.js +139 -10
- package/dist/backend/llvm/record-views.js.map +1 -1
- package/dist/backend/llvm/record-views.test.js +76 -0
- package/dist/backend/llvm/record-views.test.js.map +1 -1
- package/dist/backend/llvm/reference-writes.js +1 -0
- package/dist/backend/llvm/reference-writes.js.map +1 -1
- package/dist/backend/llvm/shapes.d.ts +3 -0
- package/dist/backend/llvm/shapes.js +18 -3
- package/dist/backend/llvm/shapes.js.map +1 -1
- package/dist/backend/llvm/shapes.test.js +4 -0
- package/dist/backend/llvm/shapes.test.js.map +1 -1
- package/dist/backend/llvm/speculative-integers.d.ts +10 -1
- package/dist/backend/llvm/speculative-integers.js +59 -8
- package/dist/backend/llvm/speculative-integers.js.map +1 -1
- package/dist/backend/llvm/unwind-abi.d.ts +3 -3
- package/dist/backend/llvm/unwind-abi.js +8 -3
- package/dist/backend/llvm/unwind-abi.js.map +1 -1
- package/dist/backend/llvm/walkers.js +1 -1
- package/dist/backend/llvm/walkers.js.map +1 -1
- package/dist/backend/native/contracts.d.ts +54 -0
- package/dist/backend/native/executable.js +87 -5
- package/dist/backend/native/executable.js.map +1 -1
- package/dist/backend/native/library.js +1 -1
- package/dist/backend/native/library.js.map +1 -1
- package/dist/backend/native/runtime-inputs.js +5 -1
- package/dist/backend/native/runtime-inputs.js.map +1 -1
- package/dist/backend/native/vendor.d.ts +1 -1
- package/dist/backend/native/vendor.js +1 -1
- package/dist/backend/native/vendor.js.map +1 -1
- package/dist/backend/native-codegen.js +3 -0
- package/dist/backend/native-codegen.js.map +1 -1
- package/dist/backend/native-link-info-core.d.ts +43 -0
- package/dist/backend/native-link-info-core.js.map +1 -1
- package/dist/backend/native-link-info.js +1 -0
- package/dist/backend/native-link-info.js.map +1 -1
- package/dist/backend/native-profile.d.ts +4 -1
- package/dist/backend/native-profile.js +12 -1
- package/dist/backend/native-profile.js.map +1 -1
- package/dist/backend/native-profile.test.js +10 -0
- package/dist/backend/native-profile.test.js.map +1 -1
- package/dist/backend/publication.d.ts +4 -1
- package/dist/backend/publication.js +4 -2
- package/dist/backend/publication.js.map +1 -1
- package/dist/backend/runtime-abi.d.ts +2 -2
- package/dist/backend/runtime-abi.js +2 -2
- package/dist/backend/runtime-pack-core.d.ts +31 -7
- package/dist/backend/runtime-pack-core.js +21 -1
- package/dist/backend/runtime-pack-core.js.map +1 -1
- package/dist/backend/runtime-pack-native.d.ts +18 -1
- package/dist/backend/runtime-pack-native.js +138 -29
- package/dist/backend/runtime-pack-native.js.map +1 -1
- package/dist/backend/runtime-pack-native.test.js +166 -4
- package/dist/backend/runtime-pack-native.test.js.map +1 -1
- package/dist/backend/runtime-pack-targets.test.js +3 -1
- package/dist/backend/runtime-pack-targets.test.js.map +1 -1
- package/dist/backend/runtime-pack.d.ts +7 -0
- package/dist/backend/runtime-pack.js +25 -3
- package/dist/backend/runtime-pack.js.map +1 -1
- package/dist/backend/runtime-pack.test.js +3 -11
- package/dist/backend/runtime-pack.test.js.map +1 -1
- package/dist/backend/vendor-archives.d.ts +4 -1
- package/dist/backend/vendor-archives.js +264 -3
- package/dist/backend/vendor-archives.js.map +1 -1
- package/dist/backend/vendor-inputs.d.ts +36 -0
- package/dist/backend/vendor-inputs.js +42 -0
- package/dist/backend/vendor-inputs.js.map +1 -1
- package/dist/backend/vendor-inputs.test.js +28 -1
- package/dist/backend/vendor-inputs.test.js.map +1 -1
- package/dist/backend/warm-cache.js +2 -0
- package/dist/backend/warm-cache.js.map +1 -1
- package/dist/compat/fetch-profile.d.ts +7 -1
- package/dist/compat/fetch-profile.js +23 -10
- package/dist/compat/fetch-profile.js.map +1 -1
- package/dist/compile-types.d.ts +7 -0
- package/dist/contracts/check.d.ts +3 -0
- package/dist/contracts/check.js +18 -5
- package/dist/contracts/check.js.map +1 -1
- package/dist/coverage/surface-manifest.js +1 -1
- package/dist/coverage/surface-manifest.js.map +1 -1
- package/dist/diagnostics/codes.d.ts +6 -0
- package/dist/diagnostics/codes.js +6 -0
- package/dist/diagnostics/codes.js.map +1 -1
- package/dist/diagnostics/diagnostic.d.ts +50 -0
- package/dist/diagnostics/diagnostic.js +142 -3
- package/dist/diagnostics/diagnostic.js.map +1 -1
- package/dist/diagnostics/dynamic-tier.js +3 -1
- package/dist/diagnostics/dynamic-tier.js.map +1 -1
- package/dist/executable/executable-cache.d.ts +29 -0
- package/dist/executable/executable-cache.js +18 -0
- package/dist/executable/executable-cache.js.map +1 -1
- package/dist/executable/executable-cache.test.js +5 -1
- package/dist/executable/executable-cache.test.js.map +1 -1
- package/dist/executable/prepare.d.ts +13 -3
- package/dist/executable/prepare.js +271 -18
- package/dist/executable/prepare.js.map +1 -1
- package/dist/frontend/early-errors.d.ts +14 -0
- package/dist/frontend/early-errors.js +305 -0
- package/dist/frontend/early-errors.js.map +1 -0
- package/dist/frontend/early-errors.test.d.ts +1 -0
- package/dist/frontend/early-errors.test.js +42 -0
- package/dist/frontend/early-errors.test.js.map +1 -0
- package/dist/frontend/inferred-js-diagnostics.test.js +23 -0
- package/dist/frontend/inferred-js-diagnostics.test.js.map +1 -1
- package/dist/frontend/input-tracker.d.ts +47 -0
- package/dist/frontend/input-tracker.js +173 -36
- package/dist/frontend/input-tracker.js.map +1 -1
- package/dist/frontend/input-tracker.test.js +86 -2
- package/dist/frontend/input-tracker.test.js.map +1 -1
- package/dist/frontend/js-inference.d.ts +2 -0
- package/dist/frontend/js-inference.js +18 -0
- package/dist/frontend/js-inference.js.map +1 -0
- package/dist/frontend/lowering/binding-analysis.d.ts +2 -1
- package/dist/frontend/lowering/binding-analysis.js +65 -1
- package/dist/frontend/lowering/binding-analysis.js.map +1 -1
- package/dist/frontend/lowering/builtin-calls.js +9 -0
- package/dist/frontend/lowering/builtin-calls.js.map +1 -1
- package/dist/frontend/lowering/builtin-namespaces.d.ts +1 -1
- package/dist/frontend/lowering/builtin-namespaces.js +19 -2
- package/dist/frontend/lowering/builtin-namespaces.js.map +1 -1
- package/dist/frontend/lowering/builtins/child-process-methods.d.ts +7 -0
- package/dist/frontend/lowering/builtins/child-process-methods.js +50 -10
- package/dist/frontend/lowering/builtins/child-process-methods.js.map +1 -1
- package/dist/frontend/lowering/builtins/child-process.js +5 -1
- package/dist/frontend/lowering/builtins/child-process.js.map +1 -1
- package/dist/frontend/lowering/builtins/dates.d.ts +1 -1
- package/dist/frontend/lowering/builtins/dates.js +23 -1
- package/dist/frontend/lowering/builtins/dates.js.map +1 -1
- package/dist/frontend/lowering/builtins/environment.d.ts +55 -0
- package/dist/frontend/lowering/builtins/environment.js +213 -2
- package/dist/frontend/lowering/builtins/environment.js.map +1 -1
- package/dist/frontend/lowering/builtins/filesystem-calls.js +47 -16
- package/dist/frontend/lowering/builtins/filesystem-calls.js.map +1 -1
- package/dist/frontend/lowering/builtins/filesystem.d.ts +25 -7
- package/dist/frontend/lowering/builtins/filesystem.js +185 -16
- package/dist/frontend/lowering/builtins/filesystem.js.map +1 -1
- package/dist/frontend/lowering/builtins/module-calls.js +39 -2
- package/dist/frontend/lowering/builtins/module-calls.js.map +1 -1
- package/dist/frontend/lowering/builtins/module-resolution.d.ts +8 -0
- package/dist/frontend/lowering/builtins/module-resolution.js +31 -5
- package/dist/frontend/lowering/builtins/module-resolution.js.map +1 -1
- package/dist/frontend/lowering/builtins/operating-system.d.ts +3 -2
- package/dist/frontend/lowering/builtins/operating-system.js +5 -4
- package/dist/frontend/lowering/builtins/operating-system.js.map +1 -1
- package/dist/frontend/lowering/builtins/process.d.ts +17 -1
- package/dist/frontend/lowering/builtins/process.js +285 -19
- package/dist/frontend/lowering/builtins/process.js.map +1 -1
- package/dist/frontend/lowering/builtins/querystring.d.ts +8 -0
- package/dist/frontend/lowering/builtins/querystring.js +202 -18
- package/dist/frontend/lowering/builtins/querystring.js.map +1 -1
- package/dist/frontend/lowering/builtins/readline.js +21 -3
- package/dist/frontend/lowering/builtins/readline.js.map +1 -1
- package/dist/frontend/lowering/builtins/reflection.js +60 -1
- package/dist/frontend/lowering/builtins/reflection.js.map +1 -1
- package/dist/frontend/lowering/builtins/text-codecs.js +208 -59
- package/dist/frontend/lowering/builtins/text-codecs.js.map +1 -1
- package/dist/frontend/lowering/builtins/url.js +20 -1
- package/dist/frontend/lowering/builtins/url.js.map +1 -1
- package/dist/frontend/lowering/builtins/v8.d.ts +5 -5
- package/dist/frontend/lowering/builtins/v8.js +7 -5
- package/dist/frontend/lowering/builtins/v8.js.map +1 -1
- package/dist/frontend/lowering/builtins/web-streams-dyn.d.ts +17 -2
- package/dist/frontend/lowering/builtins/web-streams-dyn.js +97 -9
- package/dist/frontend/lowering/builtins/web-streams-dyn.js.map +1 -1
- package/dist/frontend/lowering/call-signatures.js +77 -0
- package/dist/frontend/lowering/call-signatures.js.map +1 -1
- package/dist/frontend/lowering/cjs-exports-object.d.ts +3 -0
- package/dist/frontend/lowering/cjs-exports-object.js +1 -1
- package/dist/frontend/lowering/cjs-exports-object.js.map +1 -1
- package/dist/frontend/lowering/cjs-inline-require.js +5 -0
- package/dist/frontend/lowering/cjs-inline-require.js.map +1 -1
- package/dist/frontend/lowering/class-dynamic-dispatch.d.ts +5 -0
- package/dist/frontend/lowering/class-dynamic-dispatch.js +114 -0
- package/dist/frontend/lowering/class-dynamic-dispatch.js.map +1 -1
- package/dist/frontend/lowering/class-protocols.js +59 -10
- package/dist/frontend/lowering/class-protocols.js.map +1 -1
- package/dist/frontend/lowering/class-runtime-statics.js +15 -0
- package/dist/frontend/lowering/class-runtime-statics.js.map +1 -1
- package/dist/frontend/lowering/class-views.d.ts +13 -0
- package/dist/frontend/lowering/class-views.js +51 -0
- package/dist/frontend/lowering/class-views.js.map +1 -0
- package/dist/frontend/lowering/coercions/function-adapters.d.ts +15 -1
- package/dist/frontend/lowering/coercions/function-adapters.js +54 -10
- package/dist/frontend/lowering/coercions/function-adapters.js.map +1 -1
- package/dist/frontend/lowering/coercions/state.d.ts +7 -0
- package/dist/frontend/lowering/coercions/state.js +7 -0
- package/dist/frontend/lowering/coercions/state.js.map +1 -1
- package/dist/frontend/lowering/coercions/structural-plans.js +60 -3
- package/dist/frontend/lowering/coercions/structural-plans.js.map +1 -1
- package/dist/frontend/lowering/coercions/structural.js +29 -1
- package/dist/frontend/lowering/coercions/structural.js.map +1 -1
- package/dist/frontend/lowering/containers/array-callbacks.d.ts +8 -1
- package/dist/frontend/lowering/containers/array-callbacks.js +132 -28
- package/dist/frontend/lowering/containers/array-callbacks.js.map +1 -1
- package/dist/frontend/lowering/containers/array-construction.js +16 -5
- package/dist/frontend/lowering/containers/array-construction.js.map +1 -1
- package/dist/frontend/lowering/containers/array-methods.js +16 -0
- package/dist/frontend/lowering/containers/array-methods.js.map +1 -1
- package/dist/frontend/lowering/containers/bytes.js +4 -0
- package/dist/frontend/lowering/containers/bytes.js.map +1 -1
- package/dist/frontend/lowering/containers/callback-arguments.d.ts +11 -0
- package/dist/frontend/lowering/containers/callback-arguments.js +53 -0
- package/dist/frontend/lowering/containers/callback-arguments.js.map +1 -1
- package/dist/frontend/lowering/containers/filter-predicates.d.ts +10 -0
- package/dist/frontend/lowering/containers/filter-predicates.js +69 -3
- package/dist/frontend/lowering/containers/filter-predicates.js.map +1 -1
- package/dist/frontend/lowering/containers/indexed-objects.js +46 -2
- package/dist/frontend/lowering/containers/indexed-objects.js.map +1 -1
- package/dist/frontend/lowering/expressions/array-literals.d.ts +14 -0
- package/dist/frontend/lowering/expressions/array-literals.js +26 -10
- package/dist/frontend/lowering/expressions/array-literals.js.map +1 -1
- package/dist/frontend/lowering/expressions/binary.js +104 -12
- package/dist/frontend/lowering/expressions/binary.js.map +1 -1
- package/dist/frontend/lowering/expressions/element-access.js +121 -4
- package/dist/frontend/lowering/expressions/element-access.js.map +1 -1
- package/dist/frontend/lowering/expressions/identifiers.js +143 -3
- package/dist/frontend/lowering/expressions/identifiers.js.map +1 -1
- package/dist/frontend/lowering/expressions/keyed-field-targets.d.ts +11 -1
- package/dist/frontend/lowering/expressions/keyed-field-targets.js +22 -1
- package/dist/frontend/lowering/expressions/keyed-field-targets.js.map +1 -1
- package/dist/frontend/lowering/expressions/narrowing.js +25 -1
- package/dist/frontend/lowering/expressions/narrowing.js.map +1 -1
- package/dist/frontend/lowering/expressions/object-literals.d.ts +5 -1
- package/dist/frontend/lowering/expressions/object-literals.js +778 -229
- package/dist/frontend/lowering/expressions/object-literals.js.map +1 -1
- package/dist/frontend/lowering/expressions/optional-chains.js +66 -20
- package/dist/frontend/lowering/expressions/optional-chains.js.map +1 -1
- package/dist/frontend/lowering/expressions/property-access.d.ts +31 -0
- package/dist/frontend/lowering/expressions/property-access.js +796 -12
- package/dist/frontend/lowering/expressions/property-access.js.map +1 -1
- package/dist/frontend/lowering/expressions/relational.js +29 -1
- package/dist/frontend/lowering/expressions/relational.js.map +1 -1
- package/dist/frontend/lowering/expressions/typeof.js +17 -0
- package/dist/frontend/lowering/expressions/typeof.js.map +1 -1
- package/dist/frontend/lowering/expressions/updates.js +132 -17
- package/dist/frontend/lowering/expressions/updates.js.map +1 -1
- package/dist/frontend/lowering/frozen-records.d.ts +6 -0
- package/dist/frontend/lowering/frozen-records.js +10 -4
- package/dist/frontend/lowering/frozen-records.js.map +1 -1
- package/dist/frontend/lowering/frozen-records.test.d.ts +1 -0
- package/dist/frontend/lowering/frozen-records.test.js +44 -0
- package/dist/frontend/lowering/frozen-records.test.js.map +1 -0
- package/dist/frontend/lowering/function-names.d.ts +9 -0
- package/dist/frontend/lowering/function-names.js +95 -0
- package/dist/frontend/lowering/function-names.js.map +1 -0
- package/dist/frontend/lowering/function-returns.js +5 -3
- package/dist/frontend/lowering/function-returns.js.map +1 -1
- package/dist/frontend/lowering/generic-functions.d.ts +49 -0
- package/dist/frontend/lowering/generic-functions.js +365 -7
- package/dist/frontend/lowering/generic-functions.js.map +1 -1
- package/dist/frontend/lowering/global-values.d.ts +9 -0
- package/dist/frontend/lowering/global-values.js +44 -0
- package/dist/frontend/lowering/global-values.js.map +1 -1
- package/dist/frontend/lowering/handle-properties.js +34 -1
- package/dist/frontend/lowering/handle-properties.js.map +1 -1
- package/dist/frontend/lowering/key-order-witness.d.ts +54 -0
- package/dist/frontend/lowering/key-order-witness.js +546 -5
- package/dist/frontend/lowering/key-order-witness.js.map +1 -1
- package/dist/frontend/lowering/lib-boundary.js +14 -0
- package/dist/frontend/lowering/lib-boundary.js.map +1 -1
- package/dist/frontend/lowering/lower-assert.js +110 -1
- package/dist/frontend/lowering/lower-assert.js.map +1 -1
- package/dist/frontend/lowering/lower-builtin-values.d.ts +36 -6
- package/dist/frontend/lowering/lower-builtin-values.js +332 -58
- package/dist/frontend/lowering/lower-builtin-values.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.d.ts +22 -1
- package/dist/frontend/lowering/lower-calls.js +427 -48
- package/dist/frontend/lowering/lower-calls.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.test.d.ts +1 -0
- package/dist/frontend/lowering/lower-calls.test.js +78 -0
- package/dist/frontend/lowering/lower-calls.test.js.map +1 -0
- package/dist/frontend/lowering/lower-classes.d.ts +16 -5
- package/dist/frontend/lowering/lower-classes.js +168 -51
- package/dist/frontend/lowering/lower-classes.js.map +1 -1
- package/dist/frontend/lowering/lower-event-emitter.d.ts +9 -0
- package/dist/frontend/lowering/lower-event-emitter.js +383 -41
- package/dist/frontend/lowering/lower-event-emitter.js.map +1 -1
- package/dist/frontend/lowering/lower-exprs.d.ts +14 -0
- package/dist/frontend/lowering/lower-exprs.js +25 -0
- package/dist/frontend/lowering/lower-exprs.js.map +1 -1
- package/dist/frontend/lowering/lower-functions.js +2 -0
- package/dist/frontend/lowering/lower-functions.js.map +1 -1
- package/dist/frontend/lowering/lower-inspect.js +80 -33
- package/dist/frontend/lowering/lower-inspect.js.map +1 -1
- package/dist/frontend/lowering/lower-modules.js +87 -25
- package/dist/frontend/lowering/lower-modules.js.map +1 -1
- package/dist/frontend/lowering/lower-node-island.d.ts +35 -4
- package/dist/frontend/lowering/lower-node-island.js +456 -61
- package/dist/frontend/lowering/lower-node-island.js.map +1 -1
- package/dist/frontend/lowering/lower-server.js +160 -9
- package/dist/frontend/lowering/lower-server.js.map +1 -1
- package/dist/frontend/lowering/lower-shared-modules.js +13 -1
- package/dist/frontend/lowering/lower-shared-modules.js.map +1 -1
- package/dist/frontend/lowering/lower-stdlib.d.ts +3 -2
- package/dist/frontend/lowering/lower-stdlib.js +32 -18
- package/dist/frontend/lowering/lower-stdlib.js.map +1 -1
- package/dist/frontend/lowering/lower-stmts.d.ts +21 -4
- package/dist/frontend/lowering/lower-stmts.js +580 -103
- package/dist/frontend/lowering/lower-stmts.js.map +1 -1
- package/dist/frontend/lowering/lower-stream.js +126 -8
- package/dist/frontend/lowering/lower-stream.js.map +1 -1
- package/dist/frontend/lowering/lower-timers.js +133 -21
- package/dist/frontend/lowering/lower-timers.js.map +1 -1
- package/dist/frontend/lowering/lowerer.d.ts +139 -3
- package/dist/frontend/lowering/lowerer.js +579 -43
- package/dist/frontend/lowering/lowerer.js.map +1 -1
- package/dist/frontend/lowering/lowerer.test.js +1 -1
- package/dist/frontend/lowering/lowerer.test.js.map +1 -1
- package/dist/frontend/lowering/module-namespace-elements.js +15 -0
- package/dist/frontend/lowering/module-namespace-elements.js.map +1 -1
- package/dist/frontend/lowering/new-target.js +2 -2
- package/dist/frontend/lowering/nullish-empty-pattern.d.ts +17 -0
- package/dist/frontend/lowering/nullish-empty-pattern.js +118 -0
- package/dist/frontend/lowering/nullish-empty-pattern.js.map +1 -0
- package/dist/frontend/lowering/partial-assertions.d.ts +39 -0
- package/dist/frontend/lowering/partial-assertions.js +195 -0
- package/dist/frontend/lowering/partial-assertions.js.map +1 -0
- package/dist/frontend/lowering/primitive-wrappers.d.ts +34 -0
- package/dist/frontend/lowering/primitive-wrappers.js +220 -0
- package/dist/frontend/lowering/primitive-wrappers.js.map +1 -0
- package/dist/frontend/lowering/private-statics.d.ts +46 -0
- package/dist/frontend/lowering/private-statics.js +322 -0
- package/dist/frontend/lowering/private-statics.js.map +1 -0
- package/dist/frontend/lowering/record-sources.d.ts +12 -1
- package/dist/frontend/lowering/record-sources.js +60 -0
- package/dist/frontend/lowering/record-sources.js.map +1 -1
- package/dist/frontend/lowering/strict-equality.d.ts +4 -0
- package/dist/frontend/lowering/strict-equality.js +14 -0
- package/dist/frontend/lowering/strict-equality.js.map +1 -1
- package/dist/frontend/lowering/surfaces.d.ts +27 -0
- package/dist/frontend/lowering/surfaces.js +135 -62
- package/dist/frontend/lowering/surfaces.js.map +1 -1
- package/dist/frontend/lowering/unit-journal.d.ts +128 -17
- package/dist/frontend/lowering/unit-journal.js +310 -53
- package/dist/frontend/lowering/unit-journal.js.map +1 -1
- package/dist/frontend/lowering/unit-journal.test.js +91 -3
- package/dist/frontend/lowering/unit-journal.test.js.map +1 -1
- package/dist/frontend/lowering/unit-reuse.d.ts +92 -0
- package/dist/frontend/lowering/unit-reuse.js +1008 -0
- package/dist/frontend/lowering/unit-reuse.js.map +1 -0
- package/dist/frontend/lowering/width-lift.d.ts +12 -0
- package/dist/frontend/npm-file-import.test.d.ts +1 -0
- package/dist/frontend/npm-file-import.test.js +76 -0
- package/dist/frontend/npm-file-import.test.js.map +1 -0
- package/dist/frontend/npm-static.js +17 -2
- package/dist/frontend/npm-static.js.map +1 -1
- package/dist/frontend/npm.d.ts +9 -0
- package/dist/frontend/npm.js +82 -0
- package/dist/frontend/npm.js.map +1 -1
- package/dist/frontend/pipeline-native.js +2 -1
- package/dist/frontend/pipeline-native.js.map +1 -1
- package/dist/frontend/pipeline.d.ts +4 -0
- package/dist/frontend/pipeline.js +68 -7
- package/dist/frontend/pipeline.js.map +1 -1
- package/dist/frontend/program-node.d.ts +3 -0
- package/dist/frontend/program-node.js +13 -6
- package/dist/frontend/program-node.js.map +1 -1
- package/dist/frontend/program.d.ts +9 -0
- package/dist/frontend/program.js +159 -7
- package/dist/frontend/program.js.map +1 -1
- package/dist/frontend/provenance-core.js +4 -0
- package/dist/frontend/provenance-core.js.map +1 -1
- package/dist/frontend/services.d.ts +14 -0
- package/dist/frontend/services.js +52 -2
- package/dist/frontend/services.js.map +1 -1
- package/dist/frontend/services.test.js +61 -1
- package/dist/frontend/services.test.js.map +1 -1
- package/dist/frontend/shape-inference/analyze.d.ts +5 -0
- package/dist/frontend/shape-inference/analyze.js +104 -4
- package/dist/frontend/shape-inference/analyze.js.map +1 -1
- package/dist/frontend/shape-inference/domain.js +0 -1
- package/dist/frontend/shape-inference/domain.js.map +1 -1
- package/dist/frontend/shape-inference/index.js +5 -1
- package/dist/frontend/shape-inference/index.js.map +1 -1
- package/dist/frontend/shape-inference/memo.d.ts +2 -1
- package/dist/frontend/shape-inference/memo.js +6 -2
- package/dist/frontend/shape-inference/memo.js.map +1 -1
- package/dist/frontend/shape-inference/overlay.d.ts +1 -1
- package/dist/frontend/shape-inference/overlay.js +116 -2
- package/dist/frontend/shape-inference/overlay.js.map +1 -1
- package/dist/frontend/shape-inference/static-objects.js +11 -6
- package/dist/frontend/shape-inference/static-objects.js.map +1 -1
- package/dist/frontend/source-phase-imports.test.d.ts +1 -0
- package/dist/frontend/source-phase-imports.test.js +37 -0
- package/dist/frontend/source-phase-imports.test.js.map +1 -0
- package/dist/frontend/ts7/ast-node.d.ts +6 -1
- package/dist/frontend/ts7/ast-node.js +12 -0
- package/dist/frontend/ts7/ast-node.js.map +1 -1
- package/dist/frontend/ts7/ast-wire-protocols.test.js +11 -3
- package/dist/frontend/ts7/ast-wire-protocols.test.js.map +1 -1
- package/dist/frontend/ts7/ast-wire.js +3 -5
- package/dist/frontend/ts7/ast-wire.js.map +1 -1
- package/dist/frontend/ts7/checker-backend.d.ts +13 -0
- package/dist/frontend/ts7/checker-backend.js +84 -2
- package/dist/frontend/ts7/checker-backend.js.map +1 -1
- package/dist/frontend/ts7/checker-backend.test.js +126 -2
- package/dist/frontend/ts7/checker-backend.test.js.map +1 -1
- package/dist/frontend/ts7/program-host.d.ts +22 -1
- package/dist/frontend/ts7/program-host.js +49 -4
- package/dist/frontend/ts7/program-host.js.map +1 -1
- package/dist/frontend/ts7/program-host.test.js +83 -0
- package/dist/frontend/ts7/program-host.test.js.map +1 -1
- package/dist/frontend/ts7/rpc-process.d.ts +16 -1
- package/dist/frontend/ts7/rpc-process.js +170 -92
- package/dist/frontend/ts7/rpc-process.js.map +1 -1
- package/dist/frontend/ts7/rpc-process.test.js +49 -21
- package/dist/frontend/ts7/rpc-process.test.js.map +1 -1
- package/dist/frontend/tsc-codes.js +70 -0
- package/dist/frontend/tsc-codes.js.map +1 -1
- package/dist/frontend/type-mapper.d.ts +7 -2
- package/dist/frontend/type-mapper.js +148 -1
- package/dist/frontend/type-mapper.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +152 -8
- package/dist/index.js.map +1 -1
- package/dist/ir/api.d.ts +1 -1
- package/dist/ir/api.js +1 -1
- package/dist/ir/api.js.map +1 -1
- package/dist/ir/build.d.ts +3 -2
- package/dist/ir/build.js +4 -2
- package/dist/ir/build.js.map +1 -1
- package/dist/ir/builtin-effects.js +53 -0
- package/dist/ir/builtin-effects.js.map +1 -1
- package/dist/ir/builtin-signatures.d.ts +1 -1
- package/dist/ir/builtin-signatures.js +211 -10
- package/dist/ir/builtin-signatures.js.map +1 -1
- package/dist/ir/codec.d.ts +82 -0
- package/dist/ir/codec.generated.d.ts +13 -0
- package/dist/ir/codec.generated.js +5274 -0
- package/dist/ir/codec.generated.js.map +1 -0
- package/dist/ir/codec.js +325 -0
- package/dist/ir/codec.js.map +1 -0
- package/dist/ir/codec.test.d.ts +1 -0
- package/dist/ir/codec.test.js +225 -0
- package/dist/ir/codec.test.js.map +1 -0
- package/dist/ir/fields.generated.d.ts +20 -10
- package/dist/ir/fields.generated.js +1031 -11
- package/dist/ir/fields.generated.js.map +1 -1
- package/dist/ir/fields.test.js +46 -2
- package/dist/ir/fields.test.js.map +1 -1
- package/dist/ir/function-references.d.ts +5 -4
- package/dist/ir/function-references.js +8 -4
- package/dist/ir/function-references.js.map +1 -1
- package/dist/ir/function-references.test.js +7 -0
- package/dist/ir/function-references.test.js.map +1 -1
- package/dist/ir/inline-array-sources.js +4 -1
- package/dist/ir/inline-array-sources.js.map +1 -1
- package/dist/ir/inline-array-views.d.ts +13 -0
- package/dist/ir/inline-array-views.js +944 -0
- package/dist/ir/inline-array-views.js.map +1 -0
- package/dist/ir/inline-arrays.d.ts +7 -0
- package/dist/ir/inline-arrays.js +190 -55
- package/dist/ir/inline-arrays.js.map +1 -1
- package/dist/ir/inline-arrays.test.js +140 -2
- package/dist/ir/inline-arrays.test.js.map +1 -1
- package/dist/ir/integer-ranges.js +16 -6
- package/dist/ir/integer-ranges.js.map +1 -1
- package/dist/ir/ir.d.ts +75 -44
- package/dist/ir/ir.js.map +1 -1
- package/dist/ir/js-ic.d.ts +10 -9
- package/dist/ir/js-ic.js +28 -20
- package/dist/ir/js-ic.js.map +1 -1
- package/dist/ir/js-ic.test.js +10 -2
- package/dist/ir/js-ic.test.js.map +1 -1
- package/dist/ir/jsval.js +374 -63
- package/dist/ir/jsval.js.map +1 -1
- package/dist/ir/jsval.test.js +96 -2
- package/dist/ir/jsval.test.js.map +1 -1
- package/dist/ir/loop-entry-ranges.js +112 -9
- package/dist/ir/loop-entry-ranges.js.map +1 -1
- package/dist/ir/loop-entry-ranges.test.js +40 -0
- package/dist/ir/loop-entry-ranges.test.js.map +1 -1
- package/dist/ir/parameter-versions.d.ts +2 -1
- package/dist/ir/parameter-versions.js +3 -1
- package/dist/ir/parameter-versions.js.map +1 -1
- package/dist/ir/receiver-readers.js +58 -2
- package/dist/ir/receiver-readers.js.map +1 -1
- package/dist/ir/runtime-features.d.ts +60 -1
- package/dist/ir/runtime-features.js +277 -2
- package/dist/ir/runtime-features.js.map +1 -1
- package/dist/ir/runtime-features.test.js +165 -1
- package/dist/ir/runtime-features.test.js.map +1 -1
- package/dist/ir/saturating-loop-jams.d.ts +8 -1
- package/dist/ir/saturating-loop-jams.js +46 -7
- package/dist/ir/saturating-loop-jams.js.map +1 -1
- package/dist/ir/saturating-loop-jams.test.js +39 -1
- package/dist/ir/saturating-loop-jams.test.js.map +1 -1
- package/dist/ir/self-captures.js +8 -1
- package/dist/ir/self-captures.js.map +1 -1
- package/dist/ir/self-captures.test.js +15 -0
- package/dist/ir/self-captures.test.js.map +1 -1
- package/dist/ir/serialize.d.ts +3 -2
- package/dist/ir/serialize.js +6 -2
- package/dist/ir/serialize.js.map +1 -1
- package/dist/ir/validate.js +82 -4
- package/dist/ir/validate.js.map +1 -1
- package/dist/ir/validate.test.js +46 -0
- package/dist/ir/validate.test.js.map +1 -1
- package/dist/library/ir-policy.js +3 -0
- package/dist/library/ir-policy.js.map +1 -1
- package/dist/native/cache.js +2 -0
- package/dist/native/cache.js.map +1 -1
- package/dist/native/cli.js +2 -0
- package/dist/native/cli.js.map +1 -1
- package/dist/native/compiler.js +8 -2
- package/dist/native/compiler.js.map +1 -1
- package/dist/native/prepare.js +32 -3
- package/dist/native/prepare.js.map +1 -1
- package/dist/native/sanitizer.js +53 -3
- package/dist/native/sanitizer.js.map +1 -1
- package/dist/native/sanitizer.test.js +88 -2
- package/dist/native/sanitizer.test.js.map +1 -1
- package/dist/native/toolchain.js +9 -2
- package/dist/native/toolchain.js.map +1 -1
- package/dist/node-islands/boundary.d.ts +25 -1
- package/dist/node-islands/boundary.js +28 -2
- package/dist/node-islands/boundary.js.map +1 -1
- package/dist/node-islands/detect.d.ts +18 -1
- package/dist/node-islands/detect.js +365 -40
- package/dist/node-islands/detect.js.map +1 -1
- package/dist/node-islands/detect.test.js +151 -4
- package/dist/node-islands/detect.test.js.map +1 -1
- package/dist/node-islands/effect-gate.js +30 -20
- package/dist/node-islands/effect-gate.js.map +1 -1
- package/dist/node-islands/effect-gate.test.js +4 -1
- package/dist/node-islands/effect-gate.test.js.map +1 -1
- package/dist/node-islands/libnode.d.ts +1 -1
- package/dist/node-islands/libnode.js +1 -1
- package/dist/node-islands/libnode.js.map +1 -1
- package/dist/node-islands/modules.d.ts +28 -0
- package/dist/node-islands/modules.js +156 -0
- package/dist/node-islands/modules.js.map +1 -1
- package/dist/node-islands/modules.test.js +105 -1
- package/dist/node-islands/modules.test.js.map +1 -1
- package/dist/node-islands/policy.js +2 -3
- package/dist/node-islands/policy.js.map +1 -1
- package/dist/node-islands/probe-recorder.d.ts +1 -0
- package/dist/node-islands/probe-recorder.js +596 -0
- package/dist/node-islands/probe-recorder.js.map +1 -0
- package/dist/node-islands/probe-recorder.test.d.ts +1 -0
- package/dist/node-islands/probe-recorder.test.js +80 -0
- package/dist/node-islands/probe-recorder.test.js.map +1 -0
- package/dist/node-islands/report.test.js +2 -0
- package/dist/node-islands/report.test.js.map +1 -1
- package/dist/node-islands/rules.js +4 -0
- package/dist/node-islands/rules.js.map +1 -1
- package/dist/node-islands/scan.d.ts +7 -1
- package/dist/node-islands/scan.js +51 -2
- package/dist/node-islands/scan.js.map +1 -1
- package/dist/node-islands/snapshot.d.ts +38 -1
- package/dist/node-islands/snapshot.js +165 -161
- package/dist/node-islands/snapshot.js.map +1 -1
- package/dist/node-islands/snapshot.test.js +63 -2
- package/dist/node-islands/snapshot.test.js.map +1 -1
- package/dist/node-islands/summary.js +8 -0
- package/dist/node-islands/summary.js.map +1 -1
- package/dist/node-islands/type-strip.d.ts +11 -0
- package/dist/node-islands/type-strip.js +157 -0
- package/dist/node-islands/type-strip.js.map +1 -0
- package/dist/node-islands/type-strip.test.d.ts +1 -0
- package/dist/node-islands/type-strip.test.js +31 -0
- package/dist/node-islands/type-strip.test.js.map +1 -0
- package/dist/project-config.d.ts +4 -0
- package/dist/project-config.js +19 -0
- package/dist/project-config.js.map +1 -1
- package/dist/project-config.test.js +10 -0
- package/dist/project-config.test.js.map +1 -1
- package/package.json +20 -20
- package/surface-manifest.json +43 -11
|
@@ -0,0 +1,596 @@
|
|
|
1
|
+
/* The build-time load recorder of deferred Node islands (scope-B NI-7b).
|
|
2
|
+
* It runs inside libnode in the probe host (snapshot.ts writes it next to
|
|
3
|
+
* the host and the bootstrap requires it), loads every candidate island
|
|
4
|
+
* module once and records, for each:
|
|
5
|
+
*
|
|
6
|
+
* - inputs: reads of values that can differ between the build and a run,
|
|
7
|
+
* or between the import position and a later evaluation: process.env
|
|
8
|
+
* keys (guarded at boot), process.env enumeration, stdio TTY state
|
|
9
|
+
* (`isTTY` is guarded at boot; window size and colour depth are not),
|
|
10
|
+
* argv, execPath, cwd, uid/gid, the file system, os information, and
|
|
11
|
+
* the clock and random numbers (volatile: allowed, but then no
|
|
12
|
+
* constants are snapshotted);
|
|
13
|
+
* - effects: output, warnings, process listeners and exits, timers,
|
|
14
|
+
* immediates, ticks, microtasks and any other async resource created
|
|
15
|
+
* during the load (promises included), child processes, the network,
|
|
16
|
+
* workers, vm, the inspector, native addons (process.dlopen), writes
|
|
17
|
+
* to process.env;
|
|
18
|
+
* - mutations of builtin state: globalThis, the builtin prototypes and
|
|
19
|
+
* constructors, `process`, and the exports of common builtin modules
|
|
20
|
+
* (island-local, since native code has its own builtins, but
|
|
21
|
+
* observable by other island modules evaluated out of order);
|
|
22
|
+
* - every file the load required (the module's closure), and a throw;
|
|
23
|
+
* a load that resolves a file outside every node_modules directory (the
|
|
24
|
+
* program's own source) throws before that file evaluates, and its
|
|
25
|
+
* record is that throw even when the load catches it;
|
|
26
|
+
*
|
|
27
|
+
* and takes the interface snapshot of the module's value (snapshot.ts).
|
|
28
|
+
* Calls made by Node's own internals (the module loader reading files,
|
|
29
|
+
* for instance) are not the module's: a record is kept only when the
|
|
30
|
+
* nearest caller outside this file is not `node:internal/`.
|
|
31
|
+
*
|
|
32
|
+
* Determinism argument: a load that read no input runs the same way at
|
|
33
|
+
* any time in any run (with the same pack and the same files, which the
|
|
34
|
+
* boot guards check), so one recorded run is the whole truth about its
|
|
35
|
+
* effects, and evaluating it later is unobservable when that run had
|
|
36
|
+
* none. Volatile values (pid, clock, random) do not change between the
|
|
37
|
+
* import position and a later evaluation in the same process except the
|
|
38
|
+
* clock and random numbers, which no run of Node reproduces either. */
|
|
39
|
+
export const PROBE_RECORDER = String.raw `"use strict";
|
|
40
|
+
const types = require("node:util").types;
|
|
41
|
+
const Module = require("node:module");
|
|
42
|
+
const { createRequire } = Module;
|
|
43
|
+
const asyncHooks = require("node:async_hooks");
|
|
44
|
+
const SELF = __filename;
|
|
45
|
+
|
|
46
|
+
let lastCaller = "";
|
|
47
|
+
// The closure of the module being loaded (files its load resolved), and
|
|
48
|
+
// its package directory: code in other files (an earlier module that
|
|
49
|
+
// wrapped a builtin, as graceful-fs wraps fs.closeSync) acts for its caller.
|
|
50
|
+
let currentFiles = null;
|
|
51
|
+
let currentPackageDir = null;
|
|
52
|
+
function frameFile(line) {
|
|
53
|
+
const m = /\(([^()]+):\d+:\d+\)\s*$/.exec(line) || /at ([^ ()]+):\d+:\d+\s*$/.exec(line);
|
|
54
|
+
if (m === null) return null;
|
|
55
|
+
let f = m[1];
|
|
56
|
+
if (f.startsWith("file://")) { try { f = require("node:url").fileURLToPath(f); } catch {} }
|
|
57
|
+
return f;
|
|
58
|
+
}
|
|
59
|
+
// Whose call this is: walking out from the recorder's frames, the first
|
|
60
|
+
// frame of the module loader (node:internal/modules/) makes it the
|
|
61
|
+
// loader's (reading a module's files); the first frame of other code
|
|
62
|
+
// (an island module, outside node:) makes it the module's. Other builtin
|
|
63
|
+
// frames (console, streams, a public builtin calling its own exports) act
|
|
64
|
+
// for their caller.
|
|
65
|
+
function internalCaller() {
|
|
66
|
+
const limit = Error.stackTraceLimit;
|
|
67
|
+
Error.stackTraceLimit = 64;
|
|
68
|
+
const lines = new Error().stack.split("\n");
|
|
69
|
+
Error.stackTraceLimit = limit;
|
|
70
|
+
for (let i = 1; i < lines.length; i++) {
|
|
71
|
+
const line = lines[i];
|
|
72
|
+
if (line.includes(SELF)) continue;
|
|
73
|
+
if (line.includes("node:internal/modules/")) return true;
|
|
74
|
+
if (/[( ]node:/.test(line)) continue;
|
|
75
|
+
const file = frameFile(line);
|
|
76
|
+
if (currentFiles !== null && file !== null && !currentFiles.has(file)) continue;
|
|
77
|
+
lastCaller = line.trim().replace(/^at /, "");
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const fnToString = Function.prototype.toString;
|
|
84
|
+
const hasOwn = Object.prototype.hasOwnProperty;
|
|
85
|
+
// A getter that only reads a binding (esbuild's and tsc's export getters):
|
|
86
|
+
// reading it again reads the same binding. A member read ('a.b', 'a[b]')
|
|
87
|
+
// can invoke another accessor that runs code on every read, so only a bare
|
|
88
|
+
// identifier qualifies. Any other getter can also run code on every read,
|
|
89
|
+
// so its member is not snapshotted.
|
|
90
|
+
const BINDING_GETTER = /^(?:\(\)\s*=>\s*[A-Za-z_$][\w$]*|function\s*[\w$]*\s*\(\)\s*\{\s*return\s+[A-Za-z_$][\w$]*\s*;?\s*\}|get\s+[\w$]+\s*\(\)\s*\{\s*return\s+[A-Za-z_$][\w$]*\s*;?\s*\})$/;
|
|
91
|
+
function bindingGetter(fn) {
|
|
92
|
+
let source = "";
|
|
93
|
+
try { source = fnToString.call(fn); } catch { return false; }
|
|
94
|
+
return BINDING_GETTER.test(source.trim());
|
|
95
|
+
}
|
|
96
|
+
function isConstructor(f) {
|
|
97
|
+
try { Reflect.construct(String, [], f); return true; } catch { return false; }
|
|
98
|
+
}
|
|
99
|
+
function plainClass(f) {
|
|
100
|
+
// instanceof reads the prototype: without an object there, it throws.
|
|
101
|
+
const proto = Object.getOwnPropertyDescriptor(f, "prototype");
|
|
102
|
+
if (proto === undefined || !("value" in proto)) return false;
|
|
103
|
+
if (proto.value === null || (typeof proto.value !== "object" && typeof proto.value !== "function"))
|
|
104
|
+
return false;
|
|
105
|
+
let source = "";
|
|
106
|
+
try { source = fnToString.call(f); } catch { return false; }
|
|
107
|
+
if (/\[native code\]\s*\}$/.test(source)) return false;
|
|
108
|
+
for (let o = f; o !== null && o !== Function.prototype; o = Object.getPrototypeOf(o))
|
|
109
|
+
if (hasOwn.call(o, Symbol.hasInstance)) return false;
|
|
110
|
+
return true;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const builtinObjects = new Set();
|
|
114
|
+
for (const name of ["assert", "buffer", "child_process", "constants", "crypto", "dns", "events", "fs",
|
|
115
|
+
"fs/promises", "http", "https", "module", "net", "os", "path", "querystring", "readline", "stream",
|
|
116
|
+
"stream/promises", "string_decoder", "timers", "tty", "url", "util", "util/types", "zlib"]) {
|
|
117
|
+
try { builtinObjects.add(require(name)); } catch {}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
exports.probe = function probe(input) {
|
|
121
|
+
const objects = {};
|
|
122
|
+
const oids = new Map();
|
|
123
|
+
let next = 1;
|
|
124
|
+
const value = (v, depth) => {
|
|
125
|
+
if (v === undefined) return { u: 1 };
|
|
126
|
+
if (v === null) return { l: 1 };
|
|
127
|
+
switch (typeof v) {
|
|
128
|
+
case "boolean": return { b: v };
|
|
129
|
+
case "number": return { n: Object.is(v, -0) ? "-0" : String(v) };
|
|
130
|
+
case "string": return v.isWellFormed() ? { s: v } : { x: 1 };
|
|
131
|
+
case "symbol": return object(v, 2, depth);
|
|
132
|
+
case "function":
|
|
133
|
+
if (types.isProxy(v)) return { x: 1 };
|
|
134
|
+
return object(v, 1 | (isConstructor(v) ? 32 : 0), depth);
|
|
135
|
+
case "object":
|
|
136
|
+
if (types.isProxy(v) || types.isPromise(v) || types.isNativeError(v) ||
|
|
137
|
+
ArrayBuffer.isView(v) || types.isExternal(v) || builtinObjects.has(v)) return { x: 1 };
|
|
138
|
+
return object(v, Array.isArray(v) ? 8 : 0, depth);
|
|
139
|
+
default: return { x: 1 };
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
const object = (v, flags, depth) => {
|
|
143
|
+
if (oids.has(v)) return { o: oids.get(v) };
|
|
144
|
+
const id = next++;
|
|
145
|
+
oids.set(v, id);
|
|
146
|
+
const entry = { f: flags, p: (flags & 1) !== 0 && plainClass(v), m: [] };
|
|
147
|
+
objects[id] = entry;
|
|
148
|
+
if (typeof v === "symbol") return { o: id };
|
|
149
|
+
const keys = depth === 0 || (depth === 1 && typeof v !== "function")
|
|
150
|
+
? Object.getOwnPropertyNames(v)
|
|
151
|
+
: typeof v === "function" ? ["name", "length"] : [];
|
|
152
|
+
for (const key of keys) {
|
|
153
|
+
let d;
|
|
154
|
+
try { d = Object.getOwnPropertyDescriptor(v, key); } catch { continue; }
|
|
155
|
+
if (d === undefined) continue;
|
|
156
|
+
if (!("value" in d)) {
|
|
157
|
+
// The module value's getters (esbuild's __export): read once, under
|
|
158
|
+
// the recording, as Node reads CommonJS named exports after the
|
|
159
|
+
// module evaluated.
|
|
160
|
+
if (depth !== 0 || typeof d.get !== "function" || !bindingGetter(d.get)) continue;
|
|
161
|
+
// A getter that reads inputs or has effects (esbuild's lazy __esm
|
|
162
|
+
// inits) is left out: its member starts Node, and its work happens
|
|
163
|
+
// when the program reads the member, eager or deferred alike (Node
|
|
164
|
+
// reads every CommonJS named export at import; scriptc reads the
|
|
165
|
+
// ones the program imports). It is not part of the load.
|
|
166
|
+
const marks = [inputs.length, volatile.length, envKeys.size, tty.size, effects.length];
|
|
167
|
+
const keysBefore = new Set(envKeys.keys());
|
|
168
|
+
const ttyBefore = new Set(tty.keys());
|
|
169
|
+
let got, ok = true;
|
|
170
|
+
recording = true;
|
|
171
|
+
try { got = d.get.call(v); } catch { ok = false; }
|
|
172
|
+
recording = false;
|
|
173
|
+
const readInput = inputs.length > marks[0] || volatile.length > marks[1] ||
|
|
174
|
+
envKeys.size > marks[2] || tty.size > marks[3] || effects.length > marks[4];
|
|
175
|
+
if (readInput) {
|
|
176
|
+
inputs.length = marks[0];
|
|
177
|
+
volatile.length = marks[1];
|
|
178
|
+
effects.length = marks[4];
|
|
179
|
+
for (const k of [...envKeys.keys()]) if (!keysBefore.has(k)) envKeys.delete(k);
|
|
180
|
+
for (const k of [...tty.keys()]) if (!ttyBefore.has(k)) tty.delete(k);
|
|
181
|
+
}
|
|
182
|
+
if (ok && !readInput) entry.m.push([key, value(got, depth + 1)]);
|
|
183
|
+
continue;
|
|
184
|
+
}
|
|
185
|
+
entry.m.push([key, value(d.value, depth + 1)]);
|
|
186
|
+
}
|
|
187
|
+
return { o: id };
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
// ── the recorder ──
|
|
191
|
+
const inputs = [], volatile = [], effects = [], tty = new Map(), envKeys = new Map();
|
|
192
|
+
const files = new Set();
|
|
193
|
+
let recording = false;
|
|
194
|
+
// The first program file the current load asked for (the resolve hook),
|
|
195
|
+
// and, for every file a load with a refusal evaluated, that program file:
|
|
196
|
+
// the module cache keeps what such a file exported without it.
|
|
197
|
+
let refused = null;
|
|
198
|
+
const refusedBy = new Map();
|
|
199
|
+
const note = (list, what) => {
|
|
200
|
+
if (recording && !internalCaller()) list.push(list === volatile ? what : what + " (" + lastCaller + ")");
|
|
201
|
+
};
|
|
202
|
+
const undo = [];
|
|
203
|
+
const wrapFn = (owner, key, list, label) => {
|
|
204
|
+
let original;
|
|
205
|
+
try { original = owner[key]; } catch { return; }
|
|
206
|
+
if (typeof original !== "function") return;
|
|
207
|
+
const wrapped = function (...a) {
|
|
208
|
+
note(list, label);
|
|
209
|
+
return new.target ? Reflect.construct(original, a, new.target) : original.apply(this, a);
|
|
210
|
+
};
|
|
211
|
+
try {
|
|
212
|
+
Object.defineProperty(wrapped, "name", { value: original.name });
|
|
213
|
+
Object.defineProperty(wrapped, "length", { value: original.length });
|
|
214
|
+
for (const k of Reflect.ownKeys(original))
|
|
215
|
+
if (!hasOwn.call(wrapped, k)) Object.defineProperty(wrapped, k, Object.getOwnPropertyDescriptor(original, k));
|
|
216
|
+
owner[key] = wrapped;
|
|
217
|
+
} catch { return; }
|
|
218
|
+
undo.push(() => { try { owner[key] = original; } catch {} });
|
|
219
|
+
};
|
|
220
|
+
const wrapGetter = (owner, key, label, onRead) => {
|
|
221
|
+
const d = Object.getOwnPropertyDescriptor(owner, key);
|
|
222
|
+
if (d !== undefined && !d.configurable) return;
|
|
223
|
+
// Without an own property (a pipe's isTTY), reads go to the prototype.
|
|
224
|
+
const own = d !== undefined;
|
|
225
|
+
let shadow;
|
|
226
|
+
Object.defineProperty(owner, key, {
|
|
227
|
+
configurable: true,
|
|
228
|
+
enumerable: own ? d.enumerable : false,
|
|
229
|
+
get() {
|
|
230
|
+
const v = own
|
|
231
|
+
? (d.get ? d.get.call(this) : d.value)
|
|
232
|
+
: shadow !== undefined ? shadow.v : Reflect.get(Object.getPrototypeOf(owner), key, this);
|
|
233
|
+
if (recording && !internalCaller()) onRead(v);
|
|
234
|
+
return v;
|
|
235
|
+
},
|
|
236
|
+
set(v) {
|
|
237
|
+
note(effects, "a write of " + label);
|
|
238
|
+
if (!own) shadow = { v };
|
|
239
|
+
else if (d.set) d.set.call(this, v);
|
|
240
|
+
else d.value = v;
|
|
241
|
+
},
|
|
242
|
+
});
|
|
243
|
+
undo.push(() => {
|
|
244
|
+
if (own) Object.defineProperty(owner, key, d);
|
|
245
|
+
else delete owner[key];
|
|
246
|
+
});
|
|
247
|
+
};
|
|
248
|
+
const realEnv = process.env;
|
|
249
|
+
const readKey = (t, k) => {
|
|
250
|
+
if (recording && typeof k === "string" && !envKeys.has(k) && !internalCaller())
|
|
251
|
+
envKeys.set(k, t[k] === undefined ? null : String(t[k]));
|
|
252
|
+
};
|
|
253
|
+
process.env = new Proxy(realEnv, {
|
|
254
|
+
get(t, k) { readKey(t, k); return t[k]; },
|
|
255
|
+
has(t, k) { readKey(t, k); return k in t; },
|
|
256
|
+
getOwnPropertyDescriptor(t, k) { readKey(t, k); return Reflect.getOwnPropertyDescriptor(t, k); },
|
|
257
|
+
ownKeys(t) { note(inputs, "an enumeration of process.env"); return Reflect.ownKeys(t); },
|
|
258
|
+
set(t, k, v) { note(effects, "a write of process.env." + String(k)); t[k] = v; return true; },
|
|
259
|
+
defineProperty(t, k, d) { note(effects, "a write of process.env." + String(k)); return Reflect.defineProperty(t, k, d); },
|
|
260
|
+
deleteProperty(t, k) { note(effects, "a delete of process.env." + String(k)); delete t[k]; return true; },
|
|
261
|
+
});
|
|
262
|
+
undo.push(() => { process.env = realEnv; });
|
|
263
|
+
for (const k of ["argv", "execArgv", "execPath", "title", "argv0", "debugPort", "exitCode"])
|
|
264
|
+
wrapGetter(process, k, "process." + k, () => note(inputs, "process." + k));
|
|
265
|
+
for (const k of ["pid", "ppid"]) wrapGetter(process, k, "process." + k, () => note(volatile, "process." + k));
|
|
266
|
+
for (const k of ["cwd", "getuid", "getgid", "geteuid", "getegid", "getgroups", "umask", "getActiveResourcesInfo", "resourceUsage", "availableMemory", "constrainedMemory"])
|
|
267
|
+
wrapFn(process, k, inputs, "process." + k + "()");
|
|
268
|
+
for (const k of ["uptime", "hrtime", "memoryUsage", "cpuUsage"]) wrapFn(process, k, volatile, "process." + k + "()");
|
|
269
|
+
if (process.hrtime) wrapFn(process.hrtime, "bigint", volatile, "process.hrtime.bigint()");
|
|
270
|
+
for (const k of ["exit", "reallyExit", "abort", "kill", "chdir", "setuid", "setgid", "seteuid", "setegid", "setgroups", "dlopen", "binding", "_linkedBinding", "emitWarning", "on", "addListener", "once", "prependListener", "prependOnceListener", "removeListener", "off", "removeAllListeners", "setMaxListeners", "nextTick", "setUncaughtExceptionCaptureCallback", "setSourceMapsEnabled", "send", "disconnect"])
|
|
271
|
+
wrapFn(process, k, effects, "process." + k + "()");
|
|
272
|
+
for (const [fd, s] of [[0, "stdin"], [1, "stdout"], [2, "stderr"]]) {
|
|
273
|
+
let stream;
|
|
274
|
+
try { stream = process[s]; } catch { continue; }
|
|
275
|
+
for (const k of ["write", "on", "once", "addListener", "prependListener", "end", "setRawMode", "resume", "pause", "read", "cork", "uncork", "destroy", "pipe"])
|
|
276
|
+
wrapFn(stream, k, effects, "process." + s + "." + k + "()");
|
|
277
|
+
wrapGetter(stream, "isTTY", "process." + s + ".isTTY", (v) => { if (!tty.has(fd)) tty.set(fd, v === true); });
|
|
278
|
+
for (const k of ["columns", "rows"]) wrapGetter(stream, k, "process." + s + "." + k, () => note(inputs, "process." + s + "." + k));
|
|
279
|
+
for (const k of ["getColorDepth", "hasColors", "getWindowSize"]) wrapFn(stream, k, inputs, "process." + s + "." + k + "()");
|
|
280
|
+
}
|
|
281
|
+
for (const k of ["queueMicrotask", "fetch"]) wrapFn(globalThis, k, effects, k + "()");
|
|
282
|
+
// Timers: one the load sets and clears again, and a clear of nothing
|
|
283
|
+
// (undefined, null), leave nothing behind (NI-7d).
|
|
284
|
+
const pendingTimers = new Map();
|
|
285
|
+
for (const k of ["setTimeout", "setInterval", "setImmediate"]) {
|
|
286
|
+
const original = globalThis[k];
|
|
287
|
+
const wrapped = function (...a) {
|
|
288
|
+
const handle = original.apply(this, a);
|
|
289
|
+
if (recording && !internalCaller()) {
|
|
290
|
+
effects.push(k + "() (" + lastCaller + ")");
|
|
291
|
+
pendingTimers.set(handle, effects.length - 1);
|
|
292
|
+
}
|
|
293
|
+
return handle;
|
|
294
|
+
};
|
|
295
|
+
Object.defineProperty(wrapped, "name", { value: original.name });
|
|
296
|
+
globalThis[k] = wrapped;
|
|
297
|
+
undo.push(() => { globalThis[k] = original; });
|
|
298
|
+
}
|
|
299
|
+
for (const k of ["clearTimeout", "clearInterval", "clearImmediate"]) {
|
|
300
|
+
const original = globalThis[k];
|
|
301
|
+
const wrapped = function (handle) {
|
|
302
|
+
if (recording && !internalCaller()) {
|
|
303
|
+
if (pendingTimers.has(handle)) {
|
|
304
|
+
effects[pendingTimers.get(handle)] = null;
|
|
305
|
+
pendingTimers.delete(handle);
|
|
306
|
+
} else if (handle !== undefined && handle !== null) {
|
|
307
|
+
effects.push(k + "() of a timer the load did not set (" + lastCaller + ")");
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
return original.apply(this, arguments);
|
|
311
|
+
};
|
|
312
|
+
Object.defineProperty(wrapped, "name", { value: original.name });
|
|
313
|
+
globalThis[k] = wrapped;
|
|
314
|
+
undo.push(() => { globalThis[k] = original; });
|
|
315
|
+
}
|
|
316
|
+
wrapFn(Date, "now", volatile, "Date.now()");
|
|
317
|
+
wrapFn(Math, "random", volatile, "Math.random()");
|
|
318
|
+
wrapFn(globalThis, "Date", volatile, "new Date()");
|
|
319
|
+
const whole = {
|
|
320
|
+
fs: inputs, os: inputs, child_process: effects, net: effects, dgram: effects, dns: effects,
|
|
321
|
+
http: effects, https: effects, http2: effects, tls: effects, worker_threads: effects,
|
|
322
|
+
cluster: effects, vm: effects, inspector: effects, tty: inputs, readline: effects, timers: effects,
|
|
323
|
+
perf_hooks: volatile, crypto: volatile, v8: effects, repl: effects, trace_events: effects,
|
|
324
|
+
async_hooks: effects, diagnostics_channel: effects,
|
|
325
|
+
};
|
|
326
|
+
// os.homedir() and os.tmpdir() are functions of the environment on POSIX:
|
|
327
|
+
// HOME (when set), and TMPDIR, TMP, TEMP. Their keys become env guards.
|
|
328
|
+
const osModule = require("node:os");
|
|
329
|
+
for (const [k, keys] of [["homedir", ["HOME"]], ["tmpdir", ["TMPDIR", "TMP", "TEMP"]]]) {
|
|
330
|
+
const original = osModule[k];
|
|
331
|
+
osModule[k] = function () {
|
|
332
|
+
const result = original.apply(this, arguments);
|
|
333
|
+
if (recording && !internalCaller()) {
|
|
334
|
+
if (process.platform === "win32" || (k === "homedir" && realEnv.HOME === undefined))
|
|
335
|
+
inputs.push("os." + k + "()");
|
|
336
|
+
else for (const key of keys) if (!envKeys.has(key)) envKeys.set(key, realEnv[key] === undefined ? null : String(realEnv[key]));
|
|
337
|
+
}
|
|
338
|
+
return result;
|
|
339
|
+
};
|
|
340
|
+
undo.push(() => { osModule[k] = original; });
|
|
341
|
+
}
|
|
342
|
+
const pureFns = new Set(["os.platform", "os.homedir", "os.tmpdir", "os.type", "os.arch", "os.machine", "os.endianness",
|
|
343
|
+
"crypto.createHash", "crypto.createHmac", "crypto.getHashes", "crypto.getCiphers", "crypto.getCurves",
|
|
344
|
+
"crypto.createCipheriv", "crypto.createDecipheriv", "vm.isContext", "fs.existsSync__never",
|
|
345
|
+
"async_hooks.AsyncLocalStorage", "async_hooks.AsyncResource", "diagnostics_channel.channel",
|
|
346
|
+
"diagnostics_channel.tracingChannel", "diagnostics_channel.hasSubscribers"]);
|
|
347
|
+
// Synchronous reads of the module's own package (its files are boot
|
|
348
|
+
// guards, by size and mtime) are guarded inputs, not inputs.
|
|
349
|
+
const fsModule = require("node:fs");
|
|
350
|
+
const guardedFds = new Set();
|
|
351
|
+
const ownPath = (p) => {
|
|
352
|
+
if (currentPackageDir === null) return null;
|
|
353
|
+
let f = p;
|
|
354
|
+
if (f instanceof URL) { try { f = require("node:url").fileURLToPath(f); } catch { return null; } }
|
|
355
|
+
if (Buffer.isBuffer(f)) f = f.toString();
|
|
356
|
+
if (typeof f !== "string") return null;
|
|
357
|
+
const abs = require("node:path").resolve(f);
|
|
358
|
+
return abs === currentPackageDir || abs.startsWith(currentPackageDir + "/") ? abs : null;
|
|
359
|
+
};
|
|
360
|
+
const readOnlyFlags = (flags) => flags === undefined || flags === "r" || flags === "rs" || flags === fsModule.constants.O_RDONLY;
|
|
361
|
+
for (const key of ["readFileSync", "existsSync", "statSync", "lstatSync", "readdirSync", "realpathSync", "accessSync", "readlinkSync", "openSync"]) {
|
|
362
|
+
const original = fsModule[key];
|
|
363
|
+
if (typeof original !== "function") continue;
|
|
364
|
+
const wrapped = function (target, flags) {
|
|
365
|
+
let result;
|
|
366
|
+
try {
|
|
367
|
+
result = original.apply(this, arguments);
|
|
368
|
+
} catch (e) {
|
|
369
|
+
// A file that is not there has no boot guard: its absence is an input.
|
|
370
|
+
if (recording && !internalCaller()) inputs.push("fs." + key + "() (" + lastCaller + ")");
|
|
371
|
+
throw e;
|
|
372
|
+
}
|
|
373
|
+
if (recording && !internalCaller()) {
|
|
374
|
+
const own = ownPath(target);
|
|
375
|
+
if (key === "existsSync" && result === false) {
|
|
376
|
+
inputs.push("fs." + key + "() (" + lastCaller + ")");
|
|
377
|
+
} else if (own !== null && (key !== "openSync" || readOnlyFlags(flags))) {
|
|
378
|
+
files.add(own);
|
|
379
|
+
if (key === "openSync") guardedFds.add(result);
|
|
380
|
+
} else {
|
|
381
|
+
inputs.push("fs." + key + "() (" + lastCaller + ")");
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
return result;
|
|
385
|
+
};
|
|
386
|
+
for (const k of Reflect.ownKeys(original)) if (!hasOwn.call(wrapped, k)) { try { Object.defineProperty(wrapped, k, Object.getOwnPropertyDescriptor(original, k)); } catch {} }
|
|
387
|
+
fsModule[key] = wrapped;
|
|
388
|
+
undo.push(() => { fsModule[key] = original; });
|
|
389
|
+
}
|
|
390
|
+
for (const key of ["readSync", "fstatSync", "closeSync"]) {
|
|
391
|
+
const original = fsModule[key];
|
|
392
|
+
const wrapped = function (fd) {
|
|
393
|
+
const result = original.apply(this, arguments);
|
|
394
|
+
if (recording && !internalCaller()) {
|
|
395
|
+
if (!guardedFds.has(fd)) inputs.push("fs." + key + "() (" + lastCaller + ")");
|
|
396
|
+
else if (key === "closeSync") guardedFds.delete(fd);
|
|
397
|
+
}
|
|
398
|
+
return result;
|
|
399
|
+
};
|
|
400
|
+
fsModule[key] = wrapped;
|
|
401
|
+
undo.push(() => { fsModule[key] = original; });
|
|
402
|
+
}
|
|
403
|
+
const guardedFsFns = new Set(["readFileSync", "existsSync", "statSync", "lstatSync", "readdirSync", "realpathSync", "accessSync", "readlinkSync", "openSync", "readSync", "fstatSync", "closeSync"]);
|
|
404
|
+
for (const [name, list] of Object.entries(whole)) {
|
|
405
|
+
let m;
|
|
406
|
+
try { m = require(name); } catch { continue; }
|
|
407
|
+
for (const key of Object.keys(m)) {
|
|
408
|
+
if (name === "fs" && guardedFsFns.has(key)) continue;
|
|
409
|
+
if (pureFns.has(name + "." + key) || key === "promises" || /^[A-Z]/.test(key) && name !== "worker_threads" && name !== "child_process") continue;
|
|
410
|
+
wrapFn(m, key, list, name + "." + key + "()");
|
|
411
|
+
}
|
|
412
|
+
if (name === "fs" && m.promises)
|
|
413
|
+
for (const key of Object.keys(m.promises)) wrapFn(m.promises, key, inputs, "fs.promises." + key + "()");
|
|
414
|
+
}
|
|
415
|
+
wrapFn(require("worker_threads"), "Worker", effects, "new Worker()");
|
|
416
|
+
// Async resources the load creates. A promise alone is no work (an async
|
|
417
|
+
// function that returns at once creates one); a reaction to a promise
|
|
418
|
+
// the load created (then/catch/finally, an await) is.
|
|
419
|
+
const loadPromises = new Set();
|
|
420
|
+
const hook = asyncHooks.createHook({
|
|
421
|
+
init(id, type, trigger) {
|
|
422
|
+
// Timers and immediates are the timer wrappers' to account for.
|
|
423
|
+
if (type === "Timeout" || type === "Immediate" || !recording) return;
|
|
424
|
+
if (type === "PROMISE") {
|
|
425
|
+
if (loadPromises.has(trigger)) {
|
|
426
|
+
internalCaller();
|
|
427
|
+
effects.push("a promise reaction (" + lastCaller + ")");
|
|
428
|
+
} else if (!internalCaller()) {
|
|
429
|
+
loadPromises.add(id);
|
|
430
|
+
}
|
|
431
|
+
return;
|
|
432
|
+
}
|
|
433
|
+
if (!internalCaller()) effects.push("async work (" + type + ", " + lastCaller + ")");
|
|
434
|
+
},
|
|
435
|
+
});
|
|
436
|
+
hook.enable();
|
|
437
|
+
undo.push(() => hook.disable());
|
|
438
|
+
// The closure: a resolve hook (no frame of ours stays on the stack while
|
|
439
|
+
// modules evaluate, so Node's node_modules checks see the real callers).
|
|
440
|
+
// The probe evaluates installed packages only: a file outside every
|
|
441
|
+
// node_modules directory is the program's own source (a program module,
|
|
442
|
+
// or a project file a package requires), and its load throws before the
|
|
443
|
+
// file evaluates, so the module that asked for it stays eager.
|
|
444
|
+
const hooks = Module.registerHooks({
|
|
445
|
+
resolve(specifier, context, nextResolve) {
|
|
446
|
+
const result = nextResolve(specifier, context);
|
|
447
|
+
if (recording && typeof result.url === "string" && result.url.startsWith("file:")) {
|
|
448
|
+
const file = require("node:url").fileURLToPath(result.url);
|
|
449
|
+
if (!/[\\/]node_modules[\\/]/.test(file)) {
|
|
450
|
+
if (refused === null) refused = file;
|
|
451
|
+
throw new Error("the build does not evaluate " + file + ", a file of the program");
|
|
452
|
+
}
|
|
453
|
+
files.add(file);
|
|
454
|
+
}
|
|
455
|
+
return result;
|
|
456
|
+
},
|
|
457
|
+
});
|
|
458
|
+
undo.push(() => hooks.deregister());
|
|
459
|
+
const watched = [
|
|
460
|
+
["globalThis", globalThis], ["Object", Object], ["Object.prototype", Object.prototype],
|
|
461
|
+
["Function.prototype", Function.prototype], ["Array", Array], ["Array.prototype", Array.prototype],
|
|
462
|
+
["String.prototype", String.prototype], ["Number.prototype", Number.prototype],
|
|
463
|
+
["Boolean.prototype", Boolean.prototype], ["Symbol", Symbol], ["Symbol.prototype", Symbol.prototype],
|
|
464
|
+
["Promise", Promise], ["Promise.prototype", Promise.prototype], ["Error", Error],
|
|
465
|
+
["Error.prototype", Error.prototype], ["RegExp.prototype", RegExp.prototype],
|
|
466
|
+
["Map.prototype", Map.prototype], ["Set.prototype", Set.prototype], ["JSON", JSON],
|
|
467
|
+
["Math", Math], ["Reflect", Reflect], ["process", process], ["Buffer", Buffer],
|
|
468
|
+
["Buffer.prototype", Buffer.prototype],
|
|
469
|
+
];
|
|
470
|
+
for (const name of ["fs", "path", "events", "stream", "util", "os", "child_process", "http", "https",
|
|
471
|
+
"net", "url", "buffer", "crypto", "zlib", "module", "assert", "string_decoder", "timers", "tty",
|
|
472
|
+
"fs/promises", "stream/promises", "util/types", "constants", "querystring", "readline"]) {
|
|
473
|
+
try { watched.push([name, require(name)]); } catch {}
|
|
474
|
+
}
|
|
475
|
+
try { watched.push(["events.prototype", require("events").prototype]); } catch {}
|
|
476
|
+
try { watched.push(["stream.prototype", require("stream").prototype]); } catch {}
|
|
477
|
+
const shot = () => watched.map(([name, o]) => {
|
|
478
|
+
const m = new Map();
|
|
479
|
+
for (const k of Reflect.ownKeys(o)) {
|
|
480
|
+
const d = Object.getOwnPropertyDescriptor(o, k);
|
|
481
|
+
m.set(k, d === undefined ? undefined : "value" in d ? d.value : d.get);
|
|
482
|
+
}
|
|
483
|
+
return [name, m];
|
|
484
|
+
});
|
|
485
|
+
|
|
486
|
+
// What a member of a module value reads now: a data property's value, or
|
|
487
|
+
// a binding getter's (esbuild's and tsc's export getters). Any other
|
|
488
|
+
// accessor can run code, so it is not part of a shape.
|
|
489
|
+
const MISSING = {};
|
|
490
|
+
const memberValue = (o, k) => {
|
|
491
|
+
const d = Object.getOwnPropertyDescriptor(o, k);
|
|
492
|
+
if (d === undefined) return MISSING;
|
|
493
|
+
if ("value" in d) return d.value;
|
|
494
|
+
if (typeof d.get !== "function" || !bindingGetter(d.get)) return MISSING;
|
|
495
|
+
try { return d.get.call(o); } catch { return MISSING; }
|
|
496
|
+
};
|
|
497
|
+
|
|
498
|
+
// A module's exported values right after its load, at the depth the
|
|
499
|
+
// snapshot covers (the module value's members, and theirs for objects).
|
|
500
|
+
const exportShape = (v) => {
|
|
501
|
+
const shape = [];
|
|
502
|
+
if (v === null || (typeof v !== "object" && typeof v !== "function")) return shape;
|
|
503
|
+
for (const k of Reflect.ownKeys(v)) {
|
|
504
|
+
const m = memberValue(v, k);
|
|
505
|
+
if (m === MISSING) continue;
|
|
506
|
+
shape.push([v, k, m]);
|
|
507
|
+
if (m !== null && typeof m === "object")
|
|
508
|
+
for (const k2 of Reflect.ownKeys(m)) {
|
|
509
|
+
const m2 = memberValue(m, k2);
|
|
510
|
+
if (m2 !== MISSING) shape.push([m, k2, m2]);
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
return shape;
|
|
514
|
+
};
|
|
515
|
+
const shapes = new Map();
|
|
516
|
+
const results = [];
|
|
517
|
+
for (const path of input.modules) {
|
|
518
|
+
inputs.length = volatile.length = effects.length = 0;
|
|
519
|
+
pendingTimers.clear();
|
|
520
|
+
loadPromises.clear();
|
|
521
|
+
tty.clear(); envKeys.clear(); files.clear();
|
|
522
|
+
refused = null;
|
|
523
|
+
files.add(path);
|
|
524
|
+
currentFiles = files;
|
|
525
|
+
currentPackageDir = null;
|
|
526
|
+
for (let d = require("node:path").dirname(path); d !== require("node:path").dirname(d); d = require("node:path").dirname(d)) {
|
|
527
|
+
if (require("node:fs").existsSync(d + "/package.json")) { currentPackageDir = d; break; }
|
|
528
|
+
}
|
|
529
|
+
const before = shot();
|
|
530
|
+
let exportsValue, threw;
|
|
531
|
+
recording = true;
|
|
532
|
+
try { exportsValue = createRequire(path)(path); } catch (e) { threw = String((e && e.message) || e); }
|
|
533
|
+
recording = false;
|
|
534
|
+
// A load that catches the refusal evaluates a fallback the executable
|
|
535
|
+
// never runs: its exports are not the module's, and neither are those of
|
|
536
|
+
// a later load that reaches one of its files through the module cache.
|
|
537
|
+
if (refused === null)
|
|
538
|
+
for (const f of files) if (refusedBy.has(f)) { refused = refusedBy.get(f); break; }
|
|
539
|
+
if (refused !== null) {
|
|
540
|
+
threw = "the build does not evaluate " + refused + ", a file of the program";
|
|
541
|
+
for (const f of files) if (!refusedBy.has(f)) refusedBy.set(f, refused);
|
|
542
|
+
}
|
|
543
|
+
const after = shot();
|
|
544
|
+
const root = threw === undefined ? value(exportsValue, 0) : undefined;
|
|
545
|
+
const mutations = [];
|
|
546
|
+
for (let i = 0; i < before.length; i++) {
|
|
547
|
+
const [name, b] = before[i];
|
|
548
|
+
const a = after[i][1];
|
|
549
|
+
for (const [k, v] of a) if (!b.has(k) || !Object.is(b.get(k), v)) mutations.push(name + "." + String(k));
|
|
550
|
+
for (const k of b.keys()) if (!a.has(k)) mutations.push("delete " + name + "." + String(k));
|
|
551
|
+
}
|
|
552
|
+
// Node's own undici creates its global-dispatcher symbol lazily, at
|
|
553
|
+
// times unrelated to the module; only code that names it can set it.
|
|
554
|
+
const names = (key) => {
|
|
555
|
+
for (const f of files) {
|
|
556
|
+
try { if (require("node:fs").readFileSync(f, "utf8").includes(key)) return true; } catch {}
|
|
557
|
+
}
|
|
558
|
+
return false;
|
|
559
|
+
};
|
|
560
|
+
for (let i = mutations.length - 1; i >= 0; i--) {
|
|
561
|
+
const m = /^globalThis\.Symbol\((undici\.globalDispatcher\.\d+)\)$/.exec(mutations[i]);
|
|
562
|
+
if (m !== null && !names("undici.globalDispatcher")) mutations.splice(i, 1);
|
|
563
|
+
}
|
|
564
|
+
const record = {
|
|
565
|
+
path,
|
|
566
|
+
inputs: [...new Set(inputs)],
|
|
567
|
+
volatile: [...new Set(volatile)],
|
|
568
|
+
effects: [...new Set(effects.filter((x) => x !== null))],
|
|
569
|
+
mutations,
|
|
570
|
+
env: [...envKeys],
|
|
571
|
+
tty: [...tty],
|
|
572
|
+
files: [...files],
|
|
573
|
+
};
|
|
574
|
+
if (threw !== undefined) { record.throws = threw; results.push(record); continue; }
|
|
575
|
+
if (!("o" in root)) { record.reason = "its value is not an object"; results.push(record); continue; }
|
|
576
|
+
record.root = root.o;
|
|
577
|
+
// This load changed what an earlier module exports: neither defers (the
|
|
578
|
+
// earlier snapshot no longer holds, and this load's change has to happen
|
|
579
|
+
// where the program imports it).
|
|
580
|
+
for (const [earlier, shape] of shapes) {
|
|
581
|
+
const changed = shape.some(([o, k, v]) => !Object.is(memberValue(o, k), v));
|
|
582
|
+
if (!changed) continue;
|
|
583
|
+
delete earlier.root;
|
|
584
|
+
earlier.reason = "a later island module's load changes its exports";
|
|
585
|
+
delete record.root;
|
|
586
|
+
record.reason = "its load changes another island module's exports";
|
|
587
|
+
shapes.delete(earlier);
|
|
588
|
+
}
|
|
589
|
+
if (record.root !== undefined) shapes.set(record, exportShape(exportsValue));
|
|
590
|
+
results.push(record);
|
|
591
|
+
}
|
|
592
|
+
for (const u of undo.reverse()) u();
|
|
593
|
+
return { results, objects };
|
|
594
|
+
};
|
|
595
|
+
`;
|
|
596
|
+
//# sourceMappingURL=probe-recorder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"probe-recorder.js","sourceRoot":"","sources":["../../src/node-islands/probe-recorder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uEAqCuE;AACvE,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4iBvC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|