rahad-all-downloader 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- package/.cache/nix/binary-cache-v6.sqlite +0 -0
- package/.cache/nix/binary-cache-v6.sqlite-journal +0 -0
- package/.cache/replit/__replit_disk_meta.json +1 -0
- package/.cache/replit/modules/nodejs-20.res +1 -0
- package/.cache/replit/modules/replit.res +1 -0
- package/.cache/replit/modules.stamp +0 -0
- package/.cache/replit/nix/env.json +1 -0
- package/.cache/typescript/5.0/node_modules/.package-lock.json +12 -0
- package/.cache/typescript/5.0/node_modules/types-registry/README.md +2 -0
- package/.cache/typescript/5.0/node_modules/types-registry/index.json +1 -0
- package/.cache/typescript/5.0/node_modules/types-registry/package.json +20 -0
- package/.cache/typescript/5.0/package-lock.json +17 -0
- package/.cache/typescript/5.0/package.json +1 -0
- package/.cache/typescript/5.3/node_modules/.package-lock.json +99 -0
- package/.cache/typescript/5.3/node_modules/@types/node/LICENSE +21 -0
- package/.cache/typescript/5.3/node_modules/@types/node/README.md +15 -0
- package/.cache/typescript/5.3/node_modules/@types/node/assert/strict.d.ts +8 -0
- package/.cache/typescript/5.3/node_modules/@types/node/assert.d.ts +996 -0
- package/.cache/typescript/5.3/node_modules/@types/node/async_hooks.d.ts +539 -0
- package/.cache/typescript/5.3/node_modules/@types/node/buffer.d.ts +2362 -0
- package/.cache/typescript/5.3/node_modules/@types/node/child_process.d.ts +1540 -0
- package/.cache/typescript/5.3/node_modules/@types/node/cluster.d.ts +432 -0
- package/.cache/typescript/5.3/node_modules/@types/node/console.d.ts +415 -0
- package/.cache/typescript/5.3/node_modules/@types/node/constants.d.ts +19 -0
- package/.cache/typescript/5.3/node_modules/@types/node/crypto.d.ts +4456 -0
- package/.cache/typescript/5.3/node_modules/@types/node/dgram.d.ts +586 -0
- package/.cache/typescript/5.3/node_modules/@types/node/diagnostics_channel.d.ts +191 -0
- package/.cache/typescript/5.3/node_modules/@types/node/dns/promises.d.ts +425 -0
- package/.cache/typescript/5.3/node_modules/@types/node/dns.d.ts +809 -0
- package/.cache/typescript/5.3/node_modules/@types/node/dom-events.d.ts +122 -0
- package/.cache/typescript/5.3/node_modules/@types/node/domain.d.ts +170 -0
- package/.cache/typescript/5.3/node_modules/@types/node/events.d.ts +879 -0
- package/.cache/typescript/5.3/node_modules/@types/node/fs/promises.d.ts +1239 -0
- package/.cache/typescript/5.3/node_modules/@types/node/fs.d.ts +4291 -0
- package/.cache/typescript/5.3/node_modules/@types/node/globals.d.ts +385 -0
- package/.cache/typescript/5.3/node_modules/@types/node/globals.global.d.ts +1 -0
- package/.cache/typescript/5.3/node_modules/@types/node/http.d.ts +1888 -0
- package/.cache/typescript/5.3/node_modules/@types/node/http2.d.ts +2382 -0
- package/.cache/typescript/5.3/node_modules/@types/node/https.d.ts +550 -0
- package/.cache/typescript/5.3/node_modules/@types/node/index.d.ts +88 -0
- package/.cache/typescript/5.3/node_modules/@types/node/inspector.d.ts +2747 -0
- package/.cache/typescript/5.3/node_modules/@types/node/module.d.ts +301 -0
- package/.cache/typescript/5.3/node_modules/@types/node/net.d.ts +949 -0
- package/.cache/typescript/5.3/node_modules/@types/node/os.d.ts +478 -0
- package/.cache/typescript/5.3/node_modules/@types/node/package.json +230 -0
- package/.cache/typescript/5.3/node_modules/@types/node/path.d.ts +191 -0
- package/.cache/typescript/5.3/node_modules/@types/node/perf_hooks.d.ts +639 -0
- package/.cache/typescript/5.3/node_modules/@types/node/process.d.ts +1539 -0
- package/.cache/typescript/5.3/node_modules/@types/node/punycode.d.ts +117 -0
- package/.cache/typescript/5.3/node_modules/@types/node/querystring.d.ts +141 -0
- package/.cache/typescript/5.3/node_modules/@types/node/readline/promises.d.ts +150 -0
- package/.cache/typescript/5.3/node_modules/@types/node/readline.d.ts +539 -0
- package/.cache/typescript/5.3/node_modules/@types/node/repl.d.ts +430 -0
- package/.cache/typescript/5.3/node_modules/@types/node/stream/consumers.d.ts +12 -0
- package/.cache/typescript/5.3/node_modules/@types/node/stream/promises.d.ts +83 -0
- package/.cache/typescript/5.3/node_modules/@types/node/stream/web.d.ts +350 -0
- package/.cache/typescript/5.3/node_modules/@types/node/stream.d.ts +1701 -0
- package/.cache/typescript/5.3/node_modules/@types/node/string_decoder.d.ts +67 -0
- package/.cache/typescript/5.3/node_modules/@types/node/test.d.ts +1382 -0
- package/.cache/typescript/5.3/node_modules/@types/node/timers/promises.d.ts +93 -0
- package/.cache/typescript/5.3/node_modules/@types/node/timers.d.ts +240 -0
- package/.cache/typescript/5.3/node_modules/@types/node/tls.d.ts +1210 -0
- package/.cache/typescript/5.3/node_modules/@types/node/trace_events.d.ts +182 -0
- package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/assert/strict.d.ts +8 -0
- package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/assert.d.ts +996 -0
- package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/async_hooks.d.ts +539 -0
- package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/buffer.d.ts +2362 -0
- package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/child_process.d.ts +1540 -0
- package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/cluster.d.ts +432 -0
- package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/console.d.ts +415 -0
- package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/constants.d.ts +19 -0
- package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/crypto.d.ts +4455 -0
- package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/dgram.d.ts +586 -0
- package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/diagnostics_channel.d.ts +191 -0
- package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/dns/promises.d.ts +425 -0
- package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/dns.d.ts +809 -0
- package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/dom-events.d.ts +122 -0
- package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/domain.d.ts +170 -0
- package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/events.d.ts +879 -0
- package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/fs/promises.d.ts +1239 -0
- package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/fs.d.ts +4291 -0
- package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/globals.d.ts +385 -0
- package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/globals.global.d.ts +1 -0
- package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/http.d.ts +1888 -0
- package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/http2.d.ts +2382 -0
- package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/https.d.ts +550 -0
- package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/index.d.ts +88 -0
- package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/inspector.d.ts +2747 -0
- package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/module.d.ts +301 -0
- package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/net.d.ts +949 -0
- package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/os.d.ts +478 -0
- package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/path.d.ts +191 -0
- package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/perf_hooks.d.ts +639 -0
- package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/process.d.ts +1539 -0
- package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/punycode.d.ts +117 -0
- package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/querystring.d.ts +141 -0
- package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/readline/promises.d.ts +150 -0
- package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/readline.d.ts +539 -0
- package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/repl.d.ts +430 -0
- package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/stream/consumers.d.ts +12 -0
- package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/stream/promises.d.ts +83 -0
- package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/stream/web.d.ts +350 -0
- package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/stream.d.ts +1701 -0
- package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/string_decoder.d.ts +67 -0
- package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/test.d.ts +1382 -0
- package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/timers/promises.d.ts +93 -0
- package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/timers.d.ts +240 -0
- package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/tls.d.ts +1210 -0
- package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/trace_events.d.ts +182 -0
- package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/tty.d.ts +208 -0
- package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/url.d.ts +927 -0
- package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/util.d.ts +2183 -0
- package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/v8.d.ts +635 -0
- package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/vm.d.ts +903 -0
- package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/wasi.d.ts +158 -0
- package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/worker_threads.d.ts +691 -0
- package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/zlib.d.ts +517 -0
- package/.cache/typescript/5.3/node_modules/@types/node/tty.d.ts +208 -0
- package/.cache/typescript/5.3/node_modules/@types/node/url.d.ts +927 -0
- package/.cache/typescript/5.3/node_modules/@types/node/util.d.ts +2183 -0
- package/.cache/typescript/5.3/node_modules/@types/node/v8.d.ts +635 -0
- package/.cache/typescript/5.3/node_modules/@types/node/vm.d.ts +903 -0
- package/.cache/typescript/5.3/node_modules/@types/node/wasi.d.ts +158 -0
- package/.cache/typescript/5.3/node_modules/@types/node/worker_threads.d.ts +691 -0
- package/.cache/typescript/5.3/node_modules/@types/node/zlib.d.ts +517 -0
- package/.cache/typescript/5.3/node_modules/@types/node-fetch/LICENSE +21 -0
- package/.cache/typescript/5.3/node_modules/@types/node-fetch/README.md +15 -0
- package/.cache/typescript/5.3/node_modules/@types/node-fetch/externals.d.ts +32 -0
- package/.cache/typescript/5.3/node_modules/@types/node-fetch/index.d.ts +214 -0
- package/.cache/typescript/5.3/node_modules/@types/node-fetch/package.json +83 -0
- package/.cache/typescript/5.3/node_modules/asynckit/LICENSE +21 -0
- package/.cache/typescript/5.3/node_modules/asynckit/README.md +233 -0
- package/.cache/typescript/5.3/node_modules/asynckit/bench.js +76 -0
- package/.cache/typescript/5.3/node_modules/asynckit/index.js +6 -0
- package/.cache/typescript/5.3/node_modules/asynckit/lib/abort.js +29 -0
- package/.cache/typescript/5.3/node_modules/asynckit/lib/async.js +34 -0
- package/.cache/typescript/5.3/node_modules/asynckit/lib/defer.js +26 -0
- package/.cache/typescript/5.3/node_modules/asynckit/lib/iterate.js +75 -0
- package/.cache/typescript/5.3/node_modules/asynckit/lib/readable_asynckit.js +91 -0
- package/.cache/typescript/5.3/node_modules/asynckit/lib/readable_parallel.js +25 -0
- package/.cache/typescript/5.3/node_modules/asynckit/lib/readable_serial.js +25 -0
- package/.cache/typescript/5.3/node_modules/asynckit/lib/readable_serial_ordered.js +29 -0
- package/.cache/typescript/5.3/node_modules/asynckit/lib/state.js +37 -0
- package/.cache/typescript/5.3/node_modules/asynckit/lib/streamify.js +141 -0
- package/.cache/typescript/5.3/node_modules/asynckit/lib/terminator.js +29 -0
- package/.cache/typescript/5.3/node_modules/asynckit/package.json +63 -0
- package/.cache/typescript/5.3/node_modules/asynckit/parallel.js +43 -0
- package/.cache/typescript/5.3/node_modules/asynckit/serial.js +17 -0
- package/.cache/typescript/5.3/node_modules/asynckit/serialOrdered.js +75 -0
- package/.cache/typescript/5.3/node_modules/asynckit/stream.js +21 -0
- package/.cache/typescript/5.3/node_modules/combined-stream/License +19 -0
- package/.cache/typescript/5.3/node_modules/combined-stream/Readme.md +138 -0
- package/.cache/typescript/5.3/node_modules/combined-stream/lib/combined_stream.js +208 -0
- package/.cache/typescript/5.3/node_modules/combined-stream/package.json +25 -0
- package/.cache/typescript/5.3/node_modules/combined-stream/yarn.lock +17 -0
- package/.cache/typescript/5.3/node_modules/delayed-stream/License +19 -0
- package/.cache/typescript/5.3/node_modules/delayed-stream/Makefile +7 -0
- package/.cache/typescript/5.3/node_modules/delayed-stream/Readme.md +141 -0
- package/.cache/typescript/5.3/node_modules/delayed-stream/lib/delayed_stream.js +107 -0
- package/.cache/typescript/5.3/node_modules/delayed-stream/package.json +27 -0
- package/.cache/typescript/5.3/node_modules/form-data/License +19 -0
- package/.cache/typescript/5.3/node_modules/form-data/README.md.bak +358 -0
- package/.cache/typescript/5.3/node_modules/form-data/Readme.md +358 -0
- package/.cache/typescript/5.3/node_modules/form-data/index.d.ts +62 -0
- package/.cache/typescript/5.3/node_modules/form-data/lib/browser.js +2 -0
- package/.cache/typescript/5.3/node_modules/form-data/lib/form_data.js +501 -0
- package/.cache/typescript/5.3/node_modules/form-data/lib/populate.js +10 -0
- package/.cache/typescript/5.3/node_modules/form-data/package.json +68 -0
- package/.cache/typescript/5.3/node_modules/mime-db/HISTORY.md +507 -0
- package/.cache/typescript/5.3/node_modules/mime-db/LICENSE +23 -0
- package/.cache/typescript/5.3/node_modules/mime-db/README.md +100 -0
- package/.cache/typescript/5.3/node_modules/mime-db/db.json +8519 -0
- package/.cache/typescript/5.3/node_modules/mime-db/index.js +12 -0
- package/.cache/typescript/5.3/node_modules/mime-db/package.json +60 -0
- package/.cache/typescript/5.3/node_modules/mime-types/HISTORY.md +397 -0
- package/.cache/typescript/5.3/node_modules/mime-types/LICENSE +23 -0
- package/.cache/typescript/5.3/node_modules/mime-types/README.md +113 -0
- package/.cache/typescript/5.3/node_modules/mime-types/index.js +188 -0
- package/.cache/typescript/5.3/node_modules/mime-types/package.json +44 -0
- package/.cache/typescript/5.3/node_modules/types-registry/README.md +2 -0
- package/.cache/typescript/5.3/node_modules/types-registry/index.json +1 -0
- package/.cache/typescript/5.3/node_modules/types-registry/package.json +20 -0
- package/.cache/typescript/5.3/node_modules/undici-types/README.md +6 -0
- package/.cache/typescript/5.3/node_modules/undici-types/agent.d.ts +31 -0
- package/.cache/typescript/5.3/node_modules/undici-types/api.d.ts +43 -0
- package/.cache/typescript/5.3/node_modules/undici-types/balanced-pool.d.ts +18 -0
- package/.cache/typescript/5.3/node_modules/undici-types/cache.d.ts +36 -0
- package/.cache/typescript/5.3/node_modules/undici-types/client.d.ts +97 -0
- package/.cache/typescript/5.3/node_modules/undici-types/connector.d.ts +34 -0
- package/.cache/typescript/5.3/node_modules/undici-types/content-type.d.ts +21 -0
- package/.cache/typescript/5.3/node_modules/undici-types/cookies.d.ts +28 -0
- package/.cache/typescript/5.3/node_modules/undici-types/diagnostics-channel.d.ts +67 -0
- package/.cache/typescript/5.3/node_modules/undici-types/dispatcher.d.ts +241 -0
- package/.cache/typescript/5.3/node_modules/undici-types/errors.d.ts +128 -0
- package/.cache/typescript/5.3/node_modules/undici-types/fetch.d.ts +209 -0
- package/.cache/typescript/5.3/node_modules/undici-types/file.d.ts +39 -0
- package/.cache/typescript/5.3/node_modules/undici-types/filereader.d.ts +54 -0
- package/.cache/typescript/5.3/node_modules/undici-types/formdata.d.ts +108 -0
- package/.cache/typescript/5.3/node_modules/undici-types/global-dispatcher.d.ts +9 -0
- package/.cache/typescript/5.3/node_modules/undici-types/global-origin.d.ts +7 -0
- package/.cache/typescript/5.3/node_modules/undici-types/handlers.d.ts +9 -0
- package/.cache/typescript/5.3/node_modules/undici-types/header.d.ts +4 -0
- package/.cache/typescript/5.3/node_modules/undici-types/index.d.ts +63 -0
- package/.cache/typescript/5.3/node_modules/undici-types/interceptors.d.ts +5 -0
- package/.cache/typescript/5.3/node_modules/undici-types/mock-agent.d.ts +50 -0
- package/.cache/typescript/5.3/node_modules/undici-types/mock-client.d.ts +25 -0
- package/.cache/typescript/5.3/node_modules/undici-types/mock-errors.d.ts +12 -0
- package/.cache/typescript/5.3/node_modules/undici-types/mock-interceptor.d.ts +93 -0
- package/.cache/typescript/5.3/node_modules/undici-types/mock-pool.d.ts +25 -0
- package/.cache/typescript/5.3/node_modules/undici-types/package.json +55 -0
- package/.cache/typescript/5.3/node_modules/undici-types/patch.d.ts +71 -0
- package/.cache/typescript/5.3/node_modules/undici-types/pool-stats.d.ts +19 -0
- package/.cache/typescript/5.3/node_modules/undici-types/pool.d.ts +28 -0
- package/.cache/typescript/5.3/node_modules/undici-types/proxy-agent.d.ts +30 -0
- package/.cache/typescript/5.3/node_modules/undici-types/readable.d.ts +61 -0
- package/.cache/typescript/5.3/node_modules/undici-types/webidl.d.ts +220 -0
- package/.cache/typescript/5.3/node_modules/undici-types/websocket.d.ts +131 -0
- package/.cache/typescript/5.3/package-lock.json +107 -0
- package/.cache/typescript/5.3/package.json +1 -0
- package/.cache/typescript/5.4/node_modules/.package-lock.json +115 -0
- package/.cache/typescript/5.4/node_modules/@types/body-parser/LICENSE +21 -0
- package/.cache/typescript/5.4/node_modules/@types/body-parser/README.md +15 -0
- package/.cache/typescript/5.4/node_modules/@types/body-parser/index.d.ts +95 -0
- package/.cache/typescript/5.4/node_modules/@types/body-parser/package.json +58 -0
- package/.cache/typescript/5.4/node_modules/@types/connect/LICENSE +21 -0
- package/.cache/typescript/5.4/node_modules/@types/connect/README.md +15 -0
- package/.cache/typescript/5.4/node_modules/@types/connect/index.d.ts +91 -0
- package/.cache/typescript/5.4/node_modules/@types/connect/package.json +32 -0
- package/.cache/typescript/5.4/node_modules/@types/express/LICENSE +21 -0
- package/.cache/typescript/5.4/node_modules/@types/express/README.md +15 -0
- package/.cache/typescript/5.4/node_modules/@types/express/index.d.ts +128 -0
- package/.cache/typescript/5.4/node_modules/@types/express/package.json +45 -0
- package/.cache/typescript/5.4/node_modules/@types/express-serve-static-core/LICENSE +21 -0
- package/.cache/typescript/5.4/node_modules/@types/express-serve-static-core/README.md +15 -0
- package/.cache/typescript/5.4/node_modules/@types/express-serve-static-core/index.d.ts +1295 -0
- package/.cache/typescript/5.4/node_modules/@types/express-serve-static-core/package.json +50 -0
- package/.cache/typescript/5.4/node_modules/@types/http-errors/LICENSE +21 -0
- package/.cache/typescript/5.4/node_modules/@types/http-errors/README.md +15 -0
- package/.cache/typescript/5.4/node_modules/@types/http-errors/index.d.ts +77 -0
- package/.cache/typescript/5.4/node_modules/@types/http-errors/package.json +30 -0
- package/.cache/typescript/5.4/node_modules/@types/mime/LICENSE +21 -0
- package/.cache/typescript/5.4/node_modules/@types/mime/Mime.d.ts +10 -0
- package/.cache/typescript/5.4/node_modules/@types/mime/README.md +15 -0
- package/.cache/typescript/5.4/node_modules/@types/mime/index.d.ts +31 -0
- package/.cache/typescript/5.4/node_modules/@types/mime/lite.d.ts +7 -0
- package/.cache/typescript/5.4/node_modules/@types/mime/package.json +30 -0
- package/.cache/typescript/5.4/node_modules/@types/node/LICENSE +21 -0
- package/.cache/typescript/5.4/node_modules/@types/node/README.md +15 -0
- package/.cache/typescript/5.4/node_modules/@types/node/assert/strict.d.ts +8 -0
- package/.cache/typescript/5.4/node_modules/@types/node/assert.d.ts +1040 -0
- package/.cache/typescript/5.4/node_modules/@types/node/async_hooks.d.ts +541 -0
- package/.cache/typescript/5.4/node_modules/@types/node/buffer.d.ts +2363 -0
- package/.cache/typescript/5.4/node_modules/@types/node/child_process.d.ts +1544 -0
- package/.cache/typescript/5.4/node_modules/@types/node/cluster.d.ts +578 -0
- package/.cache/typescript/5.4/node_modules/@types/node/console.d.ts +452 -0
- package/.cache/typescript/5.4/node_modules/@types/node/constants.d.ts +19 -0
- package/.cache/typescript/5.4/node_modules/@types/node/crypto.d.ts +4523 -0
- package/.cache/typescript/5.4/node_modules/@types/node/dgram.d.ts +596 -0
- package/.cache/typescript/5.4/node_modules/@types/node/diagnostics_channel.d.ts +554 -0
- package/.cache/typescript/5.4/node_modules/@types/node/dns/promises.d.ts +474 -0
- package/.cache/typescript/5.4/node_modules/@types/node/dns.d.ts +864 -0
- package/.cache/typescript/5.4/node_modules/@types/node/dom-events.d.ts +124 -0
- package/.cache/typescript/5.4/node_modules/@types/node/domain.d.ts +170 -0
- package/.cache/typescript/5.4/node_modules/@types/node/events.d.ts +909 -0
- package/.cache/typescript/5.4/node_modules/@types/node/fs/promises.d.ts +1245 -0
- package/.cache/typescript/5.4/node_modules/@types/node/fs.d.ts +4317 -0
- package/.cache/typescript/5.4/node_modules/@types/node/globals.d.ts +411 -0
- package/.cache/typescript/5.4/node_modules/@types/node/globals.global.d.ts +1 -0
- package/.cache/typescript/5.4/node_modules/@types/node/http.d.ts +1908 -0
- package/.cache/typescript/5.4/node_modules/@types/node/http2.d.ts +2418 -0
- package/.cache/typescript/5.4/node_modules/@types/node/https.d.ts +550 -0
- package/.cache/typescript/5.4/node_modules/@types/node/index.d.ts +89 -0
- package/.cache/typescript/5.4/node_modules/@types/node/inspector.d.ts +2746 -0
- package/.cache/typescript/5.4/node_modules/@types/node/module.d.ts +315 -0
- package/.cache/typescript/5.4/node_modules/@types/node/net.d.ts +999 -0
- package/.cache/typescript/5.4/node_modules/@types/node/os.d.ts +495 -0
- package/.cache/typescript/5.4/node_modules/@types/node/package.json +217 -0
- package/.cache/typescript/5.4/node_modules/@types/node/path.d.ts +191 -0
- package/.cache/typescript/5.4/node_modules/@types/node/perf_hooks.d.ts +905 -0
- package/.cache/typescript/5.4/node_modules/@types/node/process.d.ts +1754 -0
- package/.cache/typescript/5.4/node_modules/@types/node/punycode.d.ts +117 -0
- package/.cache/typescript/5.4/node_modules/@types/node/querystring.d.ts +153 -0
- package/.cache/typescript/5.4/node_modules/@types/node/readline/promises.d.ts +150 -0
- package/.cache/typescript/5.4/node_modules/@types/node/readline.d.ts +540 -0
- package/.cache/typescript/5.4/node_modules/@types/node/repl.d.ts +430 -0
- package/.cache/typescript/5.4/node_modules/@types/node/sea.d.ts +153 -0
- package/.cache/typescript/5.4/node_modules/@types/node/stream/consumers.d.ts +12 -0
- package/.cache/typescript/5.4/node_modules/@types/node/stream/promises.d.ts +83 -0
- package/.cache/typescript/5.4/node_modules/@types/node/stream/web.d.ts +367 -0
- package/.cache/typescript/5.4/node_modules/@types/node/stream.d.ts +1707 -0
- package/.cache/typescript/5.4/node_modules/@types/node/string_decoder.d.ts +67 -0
- package/.cache/typescript/5.4/node_modules/@types/node/test.d.ts +1718 -0
- package/.cache/typescript/5.4/node_modules/@types/node/timers/promises.d.ts +97 -0
- package/.cache/typescript/5.4/node_modules/@types/node/timers.d.ts +240 -0
- package/.cache/typescript/5.4/node_modules/@types/node/tls.d.ts +1217 -0
- package/.cache/typescript/5.4/node_modules/@types/node/trace_events.d.ts +197 -0
- package/.cache/typescript/5.4/node_modules/@types/node/tty.d.ts +208 -0
- package/.cache/typescript/5.4/node_modules/@types/node/url.d.ts +952 -0
- package/.cache/typescript/5.4/node_modules/@types/node/util.d.ts +2292 -0
- package/.cache/typescript/5.4/node_modules/@types/node/v8.d.ts +808 -0
- package/.cache/typescript/5.4/node_modules/@types/node/vm.d.ts +924 -0
- package/.cache/typescript/5.4/node_modules/@types/node/wasi.d.ts +181 -0
- package/.cache/typescript/5.4/node_modules/@types/node/worker_threads.d.ts +691 -0
- package/.cache/typescript/5.4/node_modules/@types/node/zlib.d.ts +530 -0
- package/.cache/typescript/5.4/node_modules/@types/qs/LICENSE +21 -0
- package/.cache/typescript/5.4/node_modules/@types/qs/README.md +15 -0
- package/.cache/typescript/5.4/node_modules/@types/qs/index.d.ts +79 -0
- package/.cache/typescript/5.4/node_modules/@types/qs/package.json +65 -0
- package/.cache/typescript/5.4/node_modules/@types/range-parser/LICENSE +21 -0
- package/.cache/typescript/5.4/node_modules/@types/range-parser/README.md +53 -0
- package/.cache/typescript/5.4/node_modules/@types/range-parser/index.d.ts +34 -0
- package/.cache/typescript/5.4/node_modules/@types/range-parser/package.json +25 -0
- package/.cache/typescript/5.4/node_modules/@types/send/LICENSE +21 -0
- package/.cache/typescript/5.4/node_modules/@types/send/README.md +15 -0
- package/.cache/typescript/5.4/node_modules/@types/send/index.d.ts +225 -0
- package/.cache/typescript/5.4/node_modules/@types/send/package.json +33 -0
- package/.cache/typescript/5.4/node_modules/@types/serve-static/LICENSE +21 -0
- package/.cache/typescript/5.4/node_modules/@types/serve-static/README.md +15 -0
- package/.cache/typescript/5.4/node_modules/@types/serve-static/index.d.ts +107 -0
- package/.cache/typescript/5.4/node_modules/@types/serve-static/package.json +39 -0
- package/.cache/typescript/5.4/node_modules/types-registry/README.md +2 -0
- package/.cache/typescript/5.4/node_modules/types-registry/index.json +1 -0
- package/.cache/typescript/5.4/node_modules/types-registry/package.json +20 -0
- package/.cache/typescript/5.4/node_modules/undici-types/README.md +6 -0
- package/.cache/typescript/5.4/node_modules/undici-types/agent.d.ts +31 -0
- package/.cache/typescript/5.4/node_modules/undici-types/api.d.ts +43 -0
- package/.cache/typescript/5.4/node_modules/undici-types/balanced-pool.d.ts +18 -0
- package/.cache/typescript/5.4/node_modules/undici-types/cache.d.ts +36 -0
- package/.cache/typescript/5.4/node_modules/undici-types/client.d.ts +97 -0
- package/.cache/typescript/5.4/node_modules/undici-types/connector.d.ts +34 -0
- package/.cache/typescript/5.4/node_modules/undici-types/content-type.d.ts +21 -0
- package/.cache/typescript/5.4/node_modules/undici-types/cookies.d.ts +28 -0
- package/.cache/typescript/5.4/node_modules/undici-types/diagnostics-channel.d.ts +67 -0
- package/.cache/typescript/5.4/node_modules/undici-types/dispatcher.d.ts +241 -0
- package/.cache/typescript/5.4/node_modules/undici-types/errors.d.ts +128 -0
- package/.cache/typescript/5.4/node_modules/undici-types/fetch.d.ts +209 -0
- package/.cache/typescript/5.4/node_modules/undici-types/file.d.ts +39 -0
- package/.cache/typescript/5.4/node_modules/undici-types/filereader.d.ts +54 -0
- package/.cache/typescript/5.4/node_modules/undici-types/formdata.d.ts +108 -0
- package/.cache/typescript/5.4/node_modules/undici-types/global-dispatcher.d.ts +9 -0
- package/.cache/typescript/5.4/node_modules/undici-types/global-origin.d.ts +7 -0
- package/.cache/typescript/5.4/node_modules/undici-types/handlers.d.ts +9 -0
- package/.cache/typescript/5.4/node_modules/undici-types/header.d.ts +4 -0
- package/.cache/typescript/5.4/node_modules/undici-types/index.d.ts +63 -0
- package/.cache/typescript/5.4/node_modules/undici-types/interceptors.d.ts +5 -0
- package/.cache/typescript/5.4/node_modules/undici-types/mock-agent.d.ts +50 -0
- package/.cache/typescript/5.4/node_modules/undici-types/mock-client.d.ts +25 -0
- package/.cache/typescript/5.4/node_modules/undici-types/mock-errors.d.ts +12 -0
- package/.cache/typescript/5.4/node_modules/undici-types/mock-interceptor.d.ts +93 -0
- package/.cache/typescript/5.4/node_modules/undici-types/mock-pool.d.ts +25 -0
- package/.cache/typescript/5.4/node_modules/undici-types/package.json +55 -0
- package/.cache/typescript/5.4/node_modules/undici-types/patch.d.ts +71 -0
- package/.cache/typescript/5.4/node_modules/undici-types/pool-stats.d.ts +19 -0
- package/.cache/typescript/5.4/node_modules/undici-types/pool.d.ts +28 -0
- package/.cache/typescript/5.4/node_modules/undici-types/proxy-agent.d.ts +30 -0
- package/.cache/typescript/5.4/node_modules/undici-types/readable.d.ts +61 -0
- package/.cache/typescript/5.4/node_modules/undici-types/webidl.d.ts +220 -0
- package/.cache/typescript/5.4/node_modules/undici-types/websocket.d.ts +131 -0
- package/.cache/typescript/5.4/package-lock.json +124 -0
- package/.cache/typescript/5.4/package.json +1 -0
- package/.replit +21 -0
- package/.upm/store.json +1 -0
- package/README.md +71 -0
- package/index.js +1 -0
- package/package.json +40 -0
- package/replit.nix +3 -0
@@ -0,0 +1,924 @@
|
|
1
|
+
/**
|
2
|
+
* The `node:vm` module enables compiling and running code within V8 Virtual
|
3
|
+
* Machine contexts.
|
4
|
+
*
|
5
|
+
* **The `node:vm` module is not a security**
|
6
|
+
* **mechanism. Do not use it to run untrusted code.**
|
7
|
+
*
|
8
|
+
* JavaScript code can be compiled and run immediately or
|
9
|
+
* compiled, saved, and run later.
|
10
|
+
*
|
11
|
+
* A common use case is to run the code in a different V8 Context. This means
|
12
|
+
* invoked code has a different global object than the invoking code.
|
13
|
+
*
|
14
|
+
* One can provide the context by `contextifying` an
|
15
|
+
* object. The invoked code treats any property in the context like a
|
16
|
+
* global variable. Any changes to global variables caused by the invoked
|
17
|
+
* code are reflected in the context object.
|
18
|
+
*
|
19
|
+
* ```js
|
20
|
+
* const vm = require('node:vm');
|
21
|
+
*
|
22
|
+
* const x = 1;
|
23
|
+
*
|
24
|
+
* const context = { x: 2 };
|
25
|
+
* vm.createContext(context); // Contextify the object.
|
26
|
+
*
|
27
|
+
* const code = 'x += 40; var y = 17;';
|
28
|
+
* // `x` and `y` are global variables in the context.
|
29
|
+
* // Initially, x has the value 2 because that is the value of context.x.
|
30
|
+
* vm.runInContext(code, context);
|
31
|
+
*
|
32
|
+
* console.log(context.x); // 42
|
33
|
+
* console.log(context.y); // 17
|
34
|
+
*
|
35
|
+
* console.log(x); // 1; y is not defined.
|
36
|
+
* ```
|
37
|
+
* @see [source](https://github.com/nodejs/node/blob/v20.13.1/lib/vm.js)
|
38
|
+
*/
|
39
|
+
declare module "vm" {
|
40
|
+
import { ImportAttributes } from "node:module";
|
41
|
+
interface Context extends NodeJS.Dict<any> {}
|
42
|
+
interface BaseOptions {
|
43
|
+
/**
|
44
|
+
* Specifies the filename used in stack traces produced by this script.
|
45
|
+
* @default ''
|
46
|
+
*/
|
47
|
+
filename?: string | undefined;
|
48
|
+
/**
|
49
|
+
* Specifies the line number offset that is displayed in stack traces produced by this script.
|
50
|
+
* @default 0
|
51
|
+
*/
|
52
|
+
lineOffset?: number | undefined;
|
53
|
+
/**
|
54
|
+
* Specifies the column number offset that is displayed in stack traces produced by this script.
|
55
|
+
* @default 0
|
56
|
+
*/
|
57
|
+
columnOffset?: number | undefined;
|
58
|
+
}
|
59
|
+
interface ScriptOptions extends BaseOptions {
|
60
|
+
/**
|
61
|
+
* V8's code cache data for the supplied source.
|
62
|
+
*/
|
63
|
+
cachedData?: Buffer | NodeJS.ArrayBufferView | undefined;
|
64
|
+
/** @deprecated in favor of `script.createCachedData()` */
|
65
|
+
produceCachedData?: boolean | undefined;
|
66
|
+
/**
|
67
|
+
* Used to specify how the modules should be loaded during the evaluation of this script when `import()` is called. This option is
|
68
|
+
* part of the experimental modules API. We do not recommend using it in a production environment. For detailed information, see
|
69
|
+
* [Support of dynamic `import()` in compilation APIs](https://nodejs.org/docs/latest-v20.x/api/vm.html#support-of-dynamic-import-in-compilation-apis).
|
70
|
+
*/
|
71
|
+
importModuleDynamically?:
|
72
|
+
| ((specifier: string, script: Script, importAttributes: ImportAttributes) => Module)
|
73
|
+
| typeof constants.USE_MAIN_CONTEXT_DEFAULT_LOADER
|
74
|
+
| undefined;
|
75
|
+
}
|
76
|
+
interface RunningScriptOptions extends BaseOptions {
|
77
|
+
/**
|
78
|
+
* When `true`, if an `Error` occurs while compiling the `code`, the line of code causing the error is attached to the stack trace.
|
79
|
+
* @default true
|
80
|
+
*/
|
81
|
+
displayErrors?: boolean | undefined;
|
82
|
+
/**
|
83
|
+
* Specifies the number of milliseconds to execute code before terminating execution.
|
84
|
+
* If execution is terminated, an `Error` will be thrown. This value must be a strictly positive integer.
|
85
|
+
*/
|
86
|
+
timeout?: number | undefined;
|
87
|
+
/**
|
88
|
+
* If `true`, the execution will be terminated when `SIGINT` (Ctrl+C) is received.
|
89
|
+
* Existing handlers for the event that have been attached via `process.on('SIGINT')` will be disabled during script execution, but will continue to work after that.
|
90
|
+
* If execution is terminated, an `Error` will be thrown.
|
91
|
+
* @default false
|
92
|
+
*/
|
93
|
+
breakOnSigint?: boolean | undefined;
|
94
|
+
}
|
95
|
+
interface RunningScriptInNewContextOptions extends RunningScriptOptions {
|
96
|
+
/**
|
97
|
+
* Human-readable name of the newly created context.
|
98
|
+
*/
|
99
|
+
contextName?: CreateContextOptions["name"];
|
100
|
+
/**
|
101
|
+
* Origin corresponding to the newly created context for display purposes. The origin should be formatted like a URL,
|
102
|
+
* but with only the scheme, host, and port (if necessary), like the value of the `url.origin` property of a `URL` object.
|
103
|
+
* Most notably, this string should omit the trailing slash, as that denotes a path.
|
104
|
+
*/
|
105
|
+
contextOrigin?: CreateContextOptions["origin"];
|
106
|
+
contextCodeGeneration?: CreateContextOptions["codeGeneration"];
|
107
|
+
/**
|
108
|
+
* If set to `afterEvaluate`, microtasks will be run immediately after the script has run.
|
109
|
+
*/
|
110
|
+
microtaskMode?: CreateContextOptions["microtaskMode"];
|
111
|
+
}
|
112
|
+
interface RunningCodeOptions extends RunningScriptOptions {
|
113
|
+
cachedData?: ScriptOptions["cachedData"];
|
114
|
+
importModuleDynamically?: ScriptOptions["importModuleDynamically"];
|
115
|
+
}
|
116
|
+
interface RunningCodeInNewContextOptions extends RunningScriptInNewContextOptions {
|
117
|
+
cachedData?: ScriptOptions["cachedData"];
|
118
|
+
importModuleDynamically?: ScriptOptions["importModuleDynamically"];
|
119
|
+
}
|
120
|
+
interface CompileFunctionOptions extends BaseOptions {
|
121
|
+
/**
|
122
|
+
* Provides an optional data with V8's code cache data for the supplied source.
|
123
|
+
*/
|
124
|
+
cachedData?: Buffer | undefined;
|
125
|
+
/**
|
126
|
+
* Specifies whether to produce new cache data.
|
127
|
+
* @default false
|
128
|
+
*/
|
129
|
+
produceCachedData?: boolean | undefined;
|
130
|
+
/**
|
131
|
+
* The sandbox/context in which the said function should be compiled in.
|
132
|
+
*/
|
133
|
+
parsingContext?: Context | undefined;
|
134
|
+
/**
|
135
|
+
* An array containing a collection of context extensions (objects wrapping the current scope) to be applied while compiling
|
136
|
+
*/
|
137
|
+
contextExtensions?: Object[] | undefined;
|
138
|
+
}
|
139
|
+
interface CreateContextOptions {
|
140
|
+
/**
|
141
|
+
* Human-readable name of the newly created context.
|
142
|
+
* @default 'VM Context i' Where i is an ascending numerical index of the created context.
|
143
|
+
*/
|
144
|
+
name?: string | undefined;
|
145
|
+
/**
|
146
|
+
* Corresponds to the newly created context for display purposes.
|
147
|
+
* The origin should be formatted like a `URL`, but with only the scheme, host, and port (if necessary),
|
148
|
+
* like the value of the `url.origin` property of a URL object.
|
149
|
+
* Most notably, this string should omit the trailing slash, as that denotes a path.
|
150
|
+
* @default ''
|
151
|
+
*/
|
152
|
+
origin?: string | undefined;
|
153
|
+
codeGeneration?:
|
154
|
+
| {
|
155
|
+
/**
|
156
|
+
* If set to false any calls to eval or function constructors (Function, GeneratorFunction, etc)
|
157
|
+
* will throw an EvalError.
|
158
|
+
* @default true
|
159
|
+
*/
|
160
|
+
strings?: boolean | undefined;
|
161
|
+
/**
|
162
|
+
* If set to false any attempt to compile a WebAssembly module will throw a WebAssembly.CompileError.
|
163
|
+
* @default true
|
164
|
+
*/
|
165
|
+
wasm?: boolean | undefined;
|
166
|
+
}
|
167
|
+
| undefined;
|
168
|
+
/**
|
169
|
+
* If set to `afterEvaluate`, microtasks will be run immediately after the script has run.
|
170
|
+
*/
|
171
|
+
microtaskMode?: "afterEvaluate" | undefined;
|
172
|
+
}
|
173
|
+
type MeasureMemoryMode = "summary" | "detailed";
|
174
|
+
interface MeasureMemoryOptions {
|
175
|
+
/**
|
176
|
+
* @default 'summary'
|
177
|
+
*/
|
178
|
+
mode?: MeasureMemoryMode | undefined;
|
179
|
+
/**
|
180
|
+
* @default 'default'
|
181
|
+
*/
|
182
|
+
execution?: "default" | "eager" | undefined;
|
183
|
+
}
|
184
|
+
interface MemoryMeasurement {
|
185
|
+
total: {
|
186
|
+
jsMemoryEstimate: number;
|
187
|
+
jsMemoryRange: [number, number];
|
188
|
+
};
|
189
|
+
}
|
190
|
+
/**
|
191
|
+
* Instances of the `vm.Script` class contain precompiled scripts that can be
|
192
|
+
* executed in specific contexts.
|
193
|
+
* @since v0.3.1
|
194
|
+
*/
|
195
|
+
class Script {
|
196
|
+
constructor(code: string, options?: ScriptOptions | string);
|
197
|
+
/**
|
198
|
+
* Runs the compiled code contained by the `vm.Script` object within the given `contextifiedObject` and returns the result. Running code does not have access
|
199
|
+
* to local scope.
|
200
|
+
*
|
201
|
+
* The following example compiles code that increments a global variable, sets
|
202
|
+
* the value of another global variable, then execute the code multiple times.
|
203
|
+
* The globals are contained in the `context` object.
|
204
|
+
*
|
205
|
+
* ```js
|
206
|
+
* const vm = require('node:vm');
|
207
|
+
*
|
208
|
+
* const context = {
|
209
|
+
* animal: 'cat',
|
210
|
+
* count: 2,
|
211
|
+
* };
|
212
|
+
*
|
213
|
+
* const script = new vm.Script('count += 1; name = "kitty";');
|
214
|
+
*
|
215
|
+
* vm.createContext(context);
|
216
|
+
* for (let i = 0; i < 10; ++i) {
|
217
|
+
* script.runInContext(context);
|
218
|
+
* }
|
219
|
+
*
|
220
|
+
* console.log(context);
|
221
|
+
* // Prints: { animal: 'cat', count: 12, name: 'kitty' }
|
222
|
+
* ```
|
223
|
+
*
|
224
|
+
* Using the `timeout` or `breakOnSigint` options will result in new event loops
|
225
|
+
* and corresponding threads being started, which have a non-zero performance
|
226
|
+
* overhead.
|
227
|
+
* @since v0.3.1
|
228
|
+
* @param contextifiedObject A `contextified` object as returned by the `vm.createContext()` method.
|
229
|
+
* @return the result of the very last statement executed in the script.
|
230
|
+
*/
|
231
|
+
runInContext(contextifiedObject: Context, options?: RunningScriptOptions): any;
|
232
|
+
/**
|
233
|
+
* First contextifies the given `contextObject`, runs the compiled code contained
|
234
|
+
* by the `vm.Script` object within the created context, and returns the result.
|
235
|
+
* Running code does not have access to local scope.
|
236
|
+
*
|
237
|
+
* The following example compiles code that sets a global variable, then executes
|
238
|
+
* the code multiple times in different contexts. The globals are set on and
|
239
|
+
* contained within each individual `context`.
|
240
|
+
*
|
241
|
+
* ```js
|
242
|
+
* const vm = require('node:vm');
|
243
|
+
*
|
244
|
+
* const script = new vm.Script('globalVar = "set"');
|
245
|
+
*
|
246
|
+
* const contexts = [{}, {}, {}];
|
247
|
+
* contexts.forEach((context) => {
|
248
|
+
* script.runInNewContext(context);
|
249
|
+
* });
|
250
|
+
*
|
251
|
+
* console.log(contexts);
|
252
|
+
* // Prints: [{ globalVar: 'set' }, { globalVar: 'set' }, { globalVar: 'set' }]
|
253
|
+
* ```
|
254
|
+
* @since v0.3.1
|
255
|
+
* @param contextObject An object that will be `contextified`. If `undefined`, a new object will be created.
|
256
|
+
* @return the result of the very last statement executed in the script.
|
257
|
+
*/
|
258
|
+
runInNewContext(contextObject?: Context, options?: RunningScriptInNewContextOptions): any;
|
259
|
+
/**
|
260
|
+
* Runs the compiled code contained by the `vm.Script` within the context of the
|
261
|
+
* current `global` object. Running code does not have access to local scope, but _does_ have access to the current `global` object.
|
262
|
+
*
|
263
|
+
* The following example compiles code that increments a `global` variable then
|
264
|
+
* executes that code multiple times:
|
265
|
+
*
|
266
|
+
* ```js
|
267
|
+
* const vm = require('node:vm');
|
268
|
+
*
|
269
|
+
* global.globalVar = 0;
|
270
|
+
*
|
271
|
+
* const script = new vm.Script('globalVar += 1', { filename: 'myfile.vm' });
|
272
|
+
*
|
273
|
+
* for (let i = 0; i < 1000; ++i) {
|
274
|
+
* script.runInThisContext();
|
275
|
+
* }
|
276
|
+
*
|
277
|
+
* console.log(globalVar);
|
278
|
+
*
|
279
|
+
* // 1000
|
280
|
+
* ```
|
281
|
+
* @since v0.3.1
|
282
|
+
* @return the result of the very last statement executed in the script.
|
283
|
+
*/
|
284
|
+
runInThisContext(options?: RunningScriptOptions): any;
|
285
|
+
/**
|
286
|
+
* Creates a code cache that can be used with the `Script` constructor's `cachedData` option. Returns a `Buffer`. This method may be called at any
|
287
|
+
* time and any number of times.
|
288
|
+
*
|
289
|
+
* The code cache of the `Script` doesn't contain any JavaScript observable
|
290
|
+
* states. The code cache is safe to be saved along side the script source and
|
291
|
+
* used to construct new `Script` instances multiple times.
|
292
|
+
*
|
293
|
+
* Functions in the `Script` source can be marked as lazily compiled and they are
|
294
|
+
* not compiled at construction of the `Script`. These functions are going to be
|
295
|
+
* compiled when they are invoked the first time. The code cache serializes the
|
296
|
+
* metadata that V8 currently knows about the `Script` that it can use to speed up
|
297
|
+
* future compilations.
|
298
|
+
*
|
299
|
+
* ```js
|
300
|
+
* const script = new vm.Script(`
|
301
|
+
* function add(a, b) {
|
302
|
+
* return a + b;
|
303
|
+
* }
|
304
|
+
*
|
305
|
+
* const x = add(1, 2);
|
306
|
+
* `);
|
307
|
+
*
|
308
|
+
* const cacheWithoutAdd = script.createCachedData();
|
309
|
+
* // In `cacheWithoutAdd` the function `add()` is marked for full compilation
|
310
|
+
* // upon invocation.
|
311
|
+
*
|
312
|
+
* script.runInThisContext();
|
313
|
+
*
|
314
|
+
* const cacheWithAdd = script.createCachedData();
|
315
|
+
* // `cacheWithAdd` contains fully compiled function `add()`.
|
316
|
+
* ```
|
317
|
+
* @since v10.6.0
|
318
|
+
*/
|
319
|
+
createCachedData(): Buffer;
|
320
|
+
/** @deprecated in favor of `script.createCachedData()` */
|
321
|
+
cachedDataProduced?: boolean | undefined;
|
322
|
+
/**
|
323
|
+
* When `cachedData` is supplied to create the `vm.Script`, this value will be set
|
324
|
+
* to either `true` or `false` depending on acceptance of the data by V8.
|
325
|
+
* Otherwise the value is `undefined`.
|
326
|
+
* @since v5.7.0
|
327
|
+
*/
|
328
|
+
cachedDataRejected?: boolean | undefined;
|
329
|
+
cachedData?: Buffer | undefined;
|
330
|
+
/**
|
331
|
+
* When the script is compiled from a source that contains a source map magic
|
332
|
+
* comment, this property will be set to the URL of the source map.
|
333
|
+
*
|
334
|
+
* ```js
|
335
|
+
* import vm from 'node:vm';
|
336
|
+
*
|
337
|
+
* const script = new vm.Script(`
|
338
|
+
* function myFunc() {}
|
339
|
+
* //# sourceMappingURL=sourcemap.json
|
340
|
+
* `);
|
341
|
+
*
|
342
|
+
* console.log(script.sourceMapURL);
|
343
|
+
* // Prints: sourcemap.json
|
344
|
+
* ```
|
345
|
+
* @since v19.1.0, v18.13.0
|
346
|
+
*/
|
347
|
+
sourceMapURL?: string | undefined;
|
348
|
+
}
|
349
|
+
/**
|
350
|
+
* If given a `contextObject`, the `vm.createContext()` method will
|
351
|
+
* [prepare that object](https://nodejs.org/docs/latest-v20.x/api/vm.html#what-does-it-mean-to-contextify-an-object)
|
352
|
+
* and return a reference to it so that it can be used in `{@link runInContext}` or
|
353
|
+
* [`script.runInContext()`](https://nodejs.org/docs/latest-v20.x/api/vm.html#scriptrunincontextcontextifiedobject-options). Inside such
|
354
|
+
* scripts, the `contextObject` will be the global object, retaining all of its
|
355
|
+
* existing properties but also having the built-in objects and functions any
|
356
|
+
* standard [global object](https://es5.github.io/#x15.1) has. Outside of scripts run by the vm module, global
|
357
|
+
* variables will remain unchanged.
|
358
|
+
*
|
359
|
+
* ```js
|
360
|
+
* const vm = require('node:vm');
|
361
|
+
*
|
362
|
+
* global.globalVar = 3;
|
363
|
+
*
|
364
|
+
* const context = { globalVar: 1 };
|
365
|
+
* vm.createContext(context);
|
366
|
+
*
|
367
|
+
* vm.runInContext('globalVar *= 2;', context);
|
368
|
+
*
|
369
|
+
* console.log(context);
|
370
|
+
* // Prints: { globalVar: 2 }
|
371
|
+
*
|
372
|
+
* console.log(global.globalVar);
|
373
|
+
* // Prints: 3
|
374
|
+
* ```
|
375
|
+
*
|
376
|
+
* If `contextObject` is omitted (or passed explicitly as `undefined`), a new,
|
377
|
+
* empty `contextified` object will be returned.
|
378
|
+
*
|
379
|
+
* The `vm.createContext()` method is primarily useful for creating a single
|
380
|
+
* context that can be used to run multiple scripts. For instance, if emulating a
|
381
|
+
* web browser, the method can be used to create a single context representing a
|
382
|
+
* window's global object, then run all `<script>` tags together within that
|
383
|
+
* context.
|
384
|
+
*
|
385
|
+
* The provided `name` and `origin` of the context are made visible through the
|
386
|
+
* Inspector API.
|
387
|
+
* @since v0.3.1
|
388
|
+
* @return contextified object.
|
389
|
+
*/
|
390
|
+
function createContext(sandbox?: Context, options?: CreateContextOptions): Context;
|
391
|
+
/**
|
392
|
+
* Returns `true` if the given `object` object has been `contextified` using {@link createContext}.
|
393
|
+
* @since v0.11.7
|
394
|
+
*/
|
395
|
+
function isContext(sandbox: Context): boolean;
|
396
|
+
/**
|
397
|
+
* The `vm.runInContext()` method compiles `code`, runs it within the context of
|
398
|
+
* the `contextifiedObject`, then returns the result. Running code does not have
|
399
|
+
* access to the local scope. The `contextifiedObject` object _must_ have been
|
400
|
+
* previously `contextified` using the {@link createContext} method.
|
401
|
+
*
|
402
|
+
* If `options` is a string, then it specifies the filename.
|
403
|
+
*
|
404
|
+
* The following example compiles and executes different scripts using a single `contextified` object:
|
405
|
+
*
|
406
|
+
* ```js
|
407
|
+
* const vm = require('node:vm');
|
408
|
+
*
|
409
|
+
* const contextObject = { globalVar: 1 };
|
410
|
+
* vm.createContext(contextObject);
|
411
|
+
*
|
412
|
+
* for (let i = 0; i < 10; ++i) {
|
413
|
+
* vm.runInContext('globalVar *= 2;', contextObject);
|
414
|
+
* }
|
415
|
+
* console.log(contextObject);
|
416
|
+
* // Prints: { globalVar: 1024 }
|
417
|
+
* ```
|
418
|
+
* @since v0.3.1
|
419
|
+
* @param code The JavaScript code to compile and run.
|
420
|
+
* @param contextifiedObject The `contextified` object that will be used as the `global` when the `code` is compiled and run.
|
421
|
+
* @return the result of the very last statement executed in the script.
|
422
|
+
*/
|
423
|
+
function runInContext(code: string, contextifiedObject: Context, options?: RunningCodeOptions | string): any;
|
424
|
+
/**
|
425
|
+
* The `vm.runInNewContext()` first contextifies the given `contextObject` (or
|
426
|
+
* creates a new `contextObject` if passed as `undefined`), compiles the `code`,
|
427
|
+
* runs it within the created context, then returns the result. Running code
|
428
|
+
* does not have access to the local scope.
|
429
|
+
*
|
430
|
+
* If `options` is a string, then it specifies the filename.
|
431
|
+
*
|
432
|
+
* The following example compiles and executes code that increments a global
|
433
|
+
* variable and sets a new one. These globals are contained in the `contextObject`.
|
434
|
+
*
|
435
|
+
* ```js
|
436
|
+
* const vm = require('node:vm');
|
437
|
+
*
|
438
|
+
* const contextObject = {
|
439
|
+
* animal: 'cat',
|
440
|
+
* count: 2,
|
441
|
+
* };
|
442
|
+
*
|
443
|
+
* vm.runInNewContext('count += 1; name = "kitty"', contextObject);
|
444
|
+
* console.log(contextObject);
|
445
|
+
* // Prints: { animal: 'cat', count: 3, name: 'kitty' }
|
446
|
+
* ```
|
447
|
+
* @since v0.3.1
|
448
|
+
* @param code The JavaScript code to compile and run.
|
449
|
+
* @param contextObject An object that will be `contextified`. If `undefined`, a new object will be created.
|
450
|
+
* @return the result of the very last statement executed in the script.
|
451
|
+
*/
|
452
|
+
function runInNewContext(
|
453
|
+
code: string,
|
454
|
+
contextObject?: Context,
|
455
|
+
options?: RunningCodeInNewContextOptions | string,
|
456
|
+
): any;
|
457
|
+
/**
|
458
|
+
* `vm.runInThisContext()` compiles `code`, runs it within the context of the
|
459
|
+
* current `global` and returns the result. Running code does not have access to
|
460
|
+
* local scope, but does have access to the current `global` object.
|
461
|
+
*
|
462
|
+
* If `options` is a string, then it specifies the filename.
|
463
|
+
*
|
464
|
+
* The following example illustrates using both `vm.runInThisContext()` and
|
465
|
+
* the JavaScript [`eval()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval) function to run the same code:
|
466
|
+
*
|
467
|
+
* ```js
|
468
|
+
* const vm = require('node:vm');
|
469
|
+
* let localVar = 'initial value';
|
470
|
+
*
|
471
|
+
* const vmResult = vm.runInThisContext('localVar = "vm";');
|
472
|
+
* console.log(`vmResult: '${vmResult}', localVar: '${localVar}'`);
|
473
|
+
* // Prints: vmResult: 'vm', localVar: 'initial value'
|
474
|
+
*
|
475
|
+
* const evalResult = eval('localVar = "eval";');
|
476
|
+
* console.log(`evalResult: '${evalResult}', localVar: '${localVar}'`);
|
477
|
+
* // Prints: evalResult: 'eval', localVar: 'eval'
|
478
|
+
* ```
|
479
|
+
*
|
480
|
+
* Because `vm.runInThisContext()` does not have access to the local scope, `localVar` is unchanged. In contrast,
|
481
|
+
* [`eval()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval) _does_ have access to the
|
482
|
+
* local scope, so the value `localVar` is changed. In this way `vm.runInThisContext()` is much like an [indirect `eval()` call](https://es5.github.io/#x10.4.2), e.g.`(0,eval)('code')`.
|
483
|
+
*
|
484
|
+
* ## Example: Running an HTTP server within a VM
|
485
|
+
*
|
486
|
+
* When using either `script.runInThisContext()` or {@link runInThisContext}, the code is executed within the current V8 global
|
487
|
+
* context. The code passed to this VM context will have its own isolated scope.
|
488
|
+
*
|
489
|
+
* In order to run a simple web server using the `node:http` module the code passed
|
490
|
+
* to the context must either call `require('node:http')` on its own, or have a
|
491
|
+
* reference to the `node:http` module passed to it. For instance:
|
492
|
+
*
|
493
|
+
* ```js
|
494
|
+
* 'use strict';
|
495
|
+
* const vm = require('node:vm');
|
496
|
+
*
|
497
|
+
* const code = `
|
498
|
+
* ((require) => {
|
499
|
+
* const http = require('node:http');
|
500
|
+
*
|
501
|
+
* http.createServer((request, response) => {
|
502
|
+
* response.writeHead(200, { 'Content-Type': 'text/plain' });
|
503
|
+
* response.end('Hello World\\n');
|
504
|
+
* }).listen(8124);
|
505
|
+
*
|
506
|
+
* console.log('Server running at http://127.0.0.1:8124/');
|
507
|
+
* })`;
|
508
|
+
*
|
509
|
+
* vm.runInThisContext(code)(require);
|
510
|
+
* ```
|
511
|
+
*
|
512
|
+
* The `require()` in the above case shares the state with the context it is
|
513
|
+
* passed from. This may introduce risks when untrusted code is executed, e.g.
|
514
|
+
* altering objects in the context in unwanted ways.
|
515
|
+
* @since v0.3.1
|
516
|
+
* @param code The JavaScript code to compile and run.
|
517
|
+
* @return the result of the very last statement executed in the script.
|
518
|
+
*/
|
519
|
+
function runInThisContext(code: string, options?: RunningCodeOptions | string): any;
|
520
|
+
/**
|
521
|
+
* Compiles the given code into the provided context (if no context is
|
522
|
+
* supplied, the current context is used), and returns it wrapped inside a
|
523
|
+
* function with the given `params`.
|
524
|
+
* @since v10.10.0
|
525
|
+
* @param code The body of the function to compile.
|
526
|
+
* @param params An array of strings containing all parameters for the function.
|
527
|
+
*/
|
528
|
+
function compileFunction(
|
529
|
+
code: string,
|
530
|
+
params?: readonly string[],
|
531
|
+
options?: CompileFunctionOptions,
|
532
|
+
): Function & {
|
533
|
+
cachedData?: Script["cachedData"] | undefined;
|
534
|
+
cachedDataProduced?: Script["cachedDataProduced"] | undefined;
|
535
|
+
cachedDataRejected?: Script["cachedDataRejected"] | undefined;
|
536
|
+
};
|
537
|
+
/**
|
538
|
+
* Measure the memory known to V8 and used by all contexts known to the
|
539
|
+
* current V8 isolate, or the main context.
|
540
|
+
*
|
541
|
+
* The format of the object that the returned Promise may resolve with is
|
542
|
+
* specific to the V8 engine and may change from one version of V8 to the next.
|
543
|
+
*
|
544
|
+
* The returned result is different from the statistics returned by `v8.getHeapSpaceStatistics()` in that `vm.measureMemory()` measure the
|
545
|
+
* memory reachable by each V8 specific contexts in the current instance of
|
546
|
+
* the V8 engine, while the result of `v8.getHeapSpaceStatistics()` measure
|
547
|
+
* the memory occupied by each heap space in the current V8 instance.
|
548
|
+
*
|
549
|
+
* ```js
|
550
|
+
* const vm = require('node:vm');
|
551
|
+
* // Measure the memory used by the main context.
|
552
|
+
* vm.measureMemory({ mode: 'summary' })
|
553
|
+
* // This is the same as vm.measureMemory()
|
554
|
+
* .then((result) => {
|
555
|
+
* // The current format is:
|
556
|
+
* // {
|
557
|
+
* // total: {
|
558
|
+
* // jsMemoryEstimate: 2418479, jsMemoryRange: [ 2418479, 2745799 ]
|
559
|
+
* // }
|
560
|
+
* // }
|
561
|
+
* console.log(result);
|
562
|
+
* });
|
563
|
+
*
|
564
|
+
* const context = vm.createContext({ a: 1 });
|
565
|
+
* vm.measureMemory({ mode: 'detailed', execution: 'eager' })
|
566
|
+
* .then((result) => {
|
567
|
+
* // Reference the context here so that it won't be GC'ed
|
568
|
+
* // until the measurement is complete.
|
569
|
+
* console.log(context.a);
|
570
|
+
* // {
|
571
|
+
* // total: {
|
572
|
+
* // jsMemoryEstimate: 2574732,
|
573
|
+
* // jsMemoryRange: [ 2574732, 2904372 ]
|
574
|
+
* // },
|
575
|
+
* // current: {
|
576
|
+
* // jsMemoryEstimate: 2438996,
|
577
|
+
* // jsMemoryRange: [ 2438996, 2768636 ]
|
578
|
+
* // },
|
579
|
+
* // other: [
|
580
|
+
* // {
|
581
|
+
* // jsMemoryEstimate: 135736,
|
582
|
+
* // jsMemoryRange: [ 135736, 465376 ]
|
583
|
+
* // }
|
584
|
+
* // ]
|
585
|
+
* // }
|
586
|
+
* console.log(result);
|
587
|
+
* });
|
588
|
+
* ```
|
589
|
+
* @since v13.10.0
|
590
|
+
* @experimental
|
591
|
+
*/
|
592
|
+
function measureMemory(options?: MeasureMemoryOptions): Promise<MemoryMeasurement>;
|
593
|
+
interface ModuleEvaluateOptions {
|
594
|
+
timeout?: RunningScriptOptions["timeout"] | undefined;
|
595
|
+
breakOnSigint?: RunningScriptOptions["breakOnSigint"] | undefined;
|
596
|
+
}
|
597
|
+
type ModuleLinker = (
|
598
|
+
specifier: string,
|
599
|
+
referencingModule: Module,
|
600
|
+
extra: {
|
601
|
+
/** @deprecated Use `attributes` instead */
|
602
|
+
assert: ImportAttributes;
|
603
|
+
attributes: ImportAttributes;
|
604
|
+
},
|
605
|
+
) => Module | Promise<Module>;
|
606
|
+
type ModuleStatus = "unlinked" | "linking" | "linked" | "evaluating" | "evaluated" | "errored";
|
607
|
+
/**
|
608
|
+
* This feature is only available with the `--experimental-vm-modules` command
|
609
|
+
* flag enabled.
|
610
|
+
*
|
611
|
+
* The `vm.Module` class provides a low-level interface for using
|
612
|
+
* ECMAScript modules in VM contexts. It is the counterpart of the `vm.Script` class that closely mirrors [Module Record](https://262.ecma-international.org/14.0/#sec-abstract-module-records) s as
|
613
|
+
* defined in the ECMAScript
|
614
|
+
* specification.
|
615
|
+
*
|
616
|
+
* Unlike `vm.Script` however, every `vm.Module` object is bound to a context from
|
617
|
+
* its creation. Operations on `vm.Module` objects are intrinsically asynchronous,
|
618
|
+
* in contrast with the synchronous nature of `vm.Script` objects. The use of
|
619
|
+
* 'async' functions can help with manipulating `vm.Module` objects.
|
620
|
+
*
|
621
|
+
* Using a `vm.Module` object requires three distinct steps: creation/parsing,
|
622
|
+
* linking, and evaluation. These three steps are illustrated in the following
|
623
|
+
* example.
|
624
|
+
*
|
625
|
+
* This implementation lies at a lower level than the `ECMAScript Module
|
626
|
+
* loader`. There is also no way to interact with the Loader yet, though
|
627
|
+
* support is planned.
|
628
|
+
*
|
629
|
+
* ```js
|
630
|
+
* import vm from 'node:vm';
|
631
|
+
*
|
632
|
+
* const contextifiedObject = vm.createContext({
|
633
|
+
* secret: 42,
|
634
|
+
* print: console.log,
|
635
|
+
* });
|
636
|
+
*
|
637
|
+
* // Step 1
|
638
|
+
* //
|
639
|
+
* // Create a Module by constructing a new `vm.SourceTextModule` object. This
|
640
|
+
* // parses the provided source text, throwing a `SyntaxError` if anything goes
|
641
|
+
* // wrong. By default, a Module is created in the top context. But here, we
|
642
|
+
* // specify `contextifiedObject` as the context this Module belongs to.
|
643
|
+
* //
|
644
|
+
* // Here, we attempt to obtain the default export from the module "foo", and
|
645
|
+
* // put it into local binding "secret".
|
646
|
+
*
|
647
|
+
* const bar = new vm.SourceTextModule(`
|
648
|
+
* import s from 'foo';
|
649
|
+
* s;
|
650
|
+
* print(s);
|
651
|
+
* `, { context: contextifiedObject });
|
652
|
+
*
|
653
|
+
* // Step 2
|
654
|
+
* //
|
655
|
+
* // "Link" the imported dependencies of this Module to it.
|
656
|
+
* //
|
657
|
+
* // The provided linking callback (the "linker") accepts two arguments: the
|
658
|
+
* // parent module (`bar` in this case) and the string that is the specifier of
|
659
|
+
* // the imported module. The callback is expected to return a Module that
|
660
|
+
* // corresponds to the provided specifier, with certain requirements documented
|
661
|
+
* // in `module.link()`.
|
662
|
+
* //
|
663
|
+
* // If linking has not started for the returned Module, the same linker
|
664
|
+
* // callback will be called on the returned Module.
|
665
|
+
* //
|
666
|
+
* // Even top-level Modules without dependencies must be explicitly linked. The
|
667
|
+
* // callback provided would never be called, however.
|
668
|
+
* //
|
669
|
+
* // The link() method returns a Promise that will be resolved when all the
|
670
|
+
* // Promises returned by the linker resolve.
|
671
|
+
* //
|
672
|
+
* // Note: This is a contrived example in that the linker function creates a new
|
673
|
+
* // "foo" module every time it is called. In a full-fledged module system, a
|
674
|
+
* // cache would probably be used to avoid duplicated modules.
|
675
|
+
*
|
676
|
+
* async function linker(specifier, referencingModule) {
|
677
|
+
* if (specifier === 'foo') {
|
678
|
+
* return new vm.SourceTextModule(`
|
679
|
+
* // The "secret" variable refers to the global variable we added to
|
680
|
+
* // "contextifiedObject" when creating the context.
|
681
|
+
* export default secret;
|
682
|
+
* `, { context: referencingModule.context });
|
683
|
+
*
|
684
|
+
* // Using `contextifiedObject` instead of `referencingModule.context`
|
685
|
+
* // here would work as well.
|
686
|
+
* }
|
687
|
+
* throw new Error(`Unable to resolve dependency: ${specifier}`);
|
688
|
+
* }
|
689
|
+
* await bar.link(linker);
|
690
|
+
*
|
691
|
+
* // Step 3
|
692
|
+
* //
|
693
|
+
* // Evaluate the Module. The evaluate() method returns a promise which will
|
694
|
+
* // resolve after the module has finished evaluating.
|
695
|
+
*
|
696
|
+
* // Prints 42.
|
697
|
+
* await bar.evaluate();
|
698
|
+
* ```
|
699
|
+
* @since v13.0.0, v12.16.0
|
700
|
+
* @experimental
|
701
|
+
*/
|
702
|
+
class Module {
|
703
|
+
/**
|
704
|
+
* The specifiers of all dependencies of this module. The returned array is frozen
|
705
|
+
* to disallow any changes to it.
|
706
|
+
*
|
707
|
+
* Corresponds to the `[[RequestedModules]]` field of [Cyclic Module Record](https://tc39.es/ecma262/#sec-cyclic-module-records) s in
|
708
|
+
* the ECMAScript specification.
|
709
|
+
*/
|
710
|
+
dependencySpecifiers: readonly string[];
|
711
|
+
/**
|
712
|
+
* If the `module.status` is `'errored'`, this property contains the exception
|
713
|
+
* thrown by the module during evaluation. If the status is anything else,
|
714
|
+
* accessing this property will result in a thrown exception.
|
715
|
+
*
|
716
|
+
* The value `undefined` cannot be used for cases where there is not a thrown
|
717
|
+
* exception due to possible ambiguity with `throw undefined;`.
|
718
|
+
*
|
719
|
+
* Corresponds to the `[[EvaluationError]]` field of [Cyclic Module Record](https://tc39.es/ecma262/#sec-cyclic-module-records) s
|
720
|
+
* in the ECMAScript specification.
|
721
|
+
*/
|
722
|
+
error: any;
|
723
|
+
/**
|
724
|
+
* The identifier of the current module, as set in the constructor.
|
725
|
+
*/
|
726
|
+
identifier: string;
|
727
|
+
context: Context;
|
728
|
+
/**
|
729
|
+
* The namespace object of the module. This is only available after linking
|
730
|
+
* (`module.link()`) has completed.
|
731
|
+
*
|
732
|
+
* Corresponds to the [GetModuleNamespace](https://tc39.es/ecma262/#sec-getmodulenamespace) abstract operation in the ECMAScript
|
733
|
+
* specification.
|
734
|
+
*/
|
735
|
+
namespace: Object;
|
736
|
+
/**
|
737
|
+
* The current status of the module. Will be one of:
|
738
|
+
*
|
739
|
+
* * `'unlinked'`: `module.link()` has not yet been called.
|
740
|
+
* * `'linking'`: `module.link()` has been called, but not all Promises returned
|
741
|
+
* by the linker function have been resolved yet.
|
742
|
+
* * `'linked'`: The module has been linked successfully, and all of its
|
743
|
+
* dependencies are linked, but `module.evaluate()` has not yet been called.
|
744
|
+
* * `'evaluating'`: The module is being evaluated through a `module.evaluate()` on
|
745
|
+
* itself or a parent module.
|
746
|
+
* * `'evaluated'`: The module has been successfully evaluated.
|
747
|
+
* * `'errored'`: The module has been evaluated, but an exception was thrown.
|
748
|
+
*
|
749
|
+
* Other than `'errored'`, this status string corresponds to the specification's [Cyclic Module Record](https://tc39.es/ecma262/#sec-cyclic-module-records)'s `[[Status]]` field. `'errored'`
|
750
|
+
* corresponds to `'evaluated'` in the specification, but with `[[EvaluationError]]` set to a
|
751
|
+
* value that is not `undefined`.
|
752
|
+
*/
|
753
|
+
status: ModuleStatus;
|
754
|
+
/**
|
755
|
+
* Evaluate the module.
|
756
|
+
*
|
757
|
+
* This must be called after the module has been linked; otherwise it will reject.
|
758
|
+
* It could be called also when the module has already been evaluated, in which
|
759
|
+
* case it will either do nothing if the initial evaluation ended in success
|
760
|
+
* (`module.status` is `'evaluated'`) or it will re-throw the exception that the
|
761
|
+
* initial evaluation resulted in (`module.status` is `'errored'`).
|
762
|
+
*
|
763
|
+
* This method cannot be called while the module is being evaluated
|
764
|
+
* (`module.status` is `'evaluating'`).
|
765
|
+
*
|
766
|
+
* Corresponds to the [Evaluate() concrete method](https://tc39.es/ecma262/#sec-moduleevaluation) field of [Cyclic Module Record](https://tc39.es/ecma262/#sec-cyclic-module-records) s in the
|
767
|
+
* ECMAScript specification.
|
768
|
+
* @return Fulfills with `undefined` upon success.
|
769
|
+
*/
|
770
|
+
evaluate(options?: ModuleEvaluateOptions): Promise<void>;
|
771
|
+
/**
|
772
|
+
* Link module dependencies. This method must be called before evaluation, and
|
773
|
+
* can only be called once per module.
|
774
|
+
*
|
775
|
+
* The function is expected to return a `Module` object or a `Promise` that
|
776
|
+
* eventually resolves to a `Module` object. The returned `Module` must satisfy the
|
777
|
+
* following two invariants:
|
778
|
+
*
|
779
|
+
* * It must belong to the same context as the parent `Module`.
|
780
|
+
* * Its `status` must not be `'errored'`.
|
781
|
+
*
|
782
|
+
* If the returned `Module`'s `status` is `'unlinked'`, this method will be
|
783
|
+
* recursively called on the returned `Module` with the same provided `linker` function.
|
784
|
+
*
|
785
|
+
* `link()` returns a `Promise` that will either get resolved when all linking
|
786
|
+
* instances resolve to a valid `Module`, or rejected if the linker function either
|
787
|
+
* throws an exception or returns an invalid `Module`.
|
788
|
+
*
|
789
|
+
* The linker function roughly corresponds to the implementation-defined [HostResolveImportedModule](https://tc39.es/ecma262/#sec-hostresolveimportedmodule) abstract operation in the
|
790
|
+
* ECMAScript
|
791
|
+
* specification, with a few key differences:
|
792
|
+
*
|
793
|
+
* * The linker function is allowed to be asynchronous while [HostResolveImportedModule](https://tc39.es/ecma262/#sec-hostresolveimportedmodule) is synchronous.
|
794
|
+
*
|
795
|
+
* The actual [HostResolveImportedModule](https://tc39.es/ecma262/#sec-hostresolveimportedmodule) implementation used during module
|
796
|
+
* linking is one that returns the modules linked during linking. Since at
|
797
|
+
* that point all modules would have been fully linked already, the [HostResolveImportedModule](https://tc39.es/ecma262/#sec-hostresolveimportedmodule) implementation is fully synchronous per
|
798
|
+
* specification.
|
799
|
+
*
|
800
|
+
* Corresponds to the [Link() concrete method](https://tc39.es/ecma262/#sec-moduledeclarationlinking) field of [Cyclic Module Record](https://tc39.es/ecma262/#sec-cyclic-module-records) s in
|
801
|
+
* the ECMAScript specification.
|
802
|
+
*/
|
803
|
+
link(linker: ModuleLinker): Promise<void>;
|
804
|
+
}
|
805
|
+
interface SourceTextModuleOptions {
|
806
|
+
/**
|
807
|
+
* String used in stack traces.
|
808
|
+
* @default 'vm:module(i)' where i is a context-specific ascending index.
|
809
|
+
*/
|
810
|
+
identifier?: string | undefined;
|
811
|
+
cachedData?: ScriptOptions["cachedData"] | undefined;
|
812
|
+
context?: Context | undefined;
|
813
|
+
lineOffset?: BaseOptions["lineOffset"] | undefined;
|
814
|
+
columnOffset?: BaseOptions["columnOffset"] | undefined;
|
815
|
+
/**
|
816
|
+
* Called during evaluation of this module to initialize the `import.meta`.
|
817
|
+
*/
|
818
|
+
initializeImportMeta?: ((meta: ImportMeta, module: SourceTextModule) => void) | undefined;
|
819
|
+
importModuleDynamically?: ScriptOptions["importModuleDynamically"] | undefined;
|
820
|
+
}
|
821
|
+
/**
|
822
|
+
* This feature is only available with the `--experimental-vm-modules` command
|
823
|
+
* flag enabled.
|
824
|
+
*
|
825
|
+
* The `vm.SourceTextModule` class provides the [Source Text Module Record](https://tc39.es/ecma262/#sec-source-text-module-records) as
|
826
|
+
* defined in the ECMAScript specification.
|
827
|
+
* @since v9.6.0
|
828
|
+
* @experimental
|
829
|
+
*/
|
830
|
+
class SourceTextModule extends Module {
|
831
|
+
/**
|
832
|
+
* Creates a new `SourceTextModule` instance.
|
833
|
+
* @param code JavaScript Module code to parse
|
834
|
+
*/
|
835
|
+
constructor(code: string, options?: SourceTextModuleOptions);
|
836
|
+
}
|
837
|
+
interface SyntheticModuleOptions {
|
838
|
+
/**
|
839
|
+
* String used in stack traces.
|
840
|
+
* @default 'vm:module(i)' where i is a context-specific ascending index.
|
841
|
+
*/
|
842
|
+
identifier?: string | undefined;
|
843
|
+
/**
|
844
|
+
* The contextified object as returned by the `vm.createContext()` method, to compile and evaluate this module in.
|
845
|
+
*/
|
846
|
+
context?: Context | undefined;
|
847
|
+
}
|
848
|
+
/**
|
849
|
+
* This feature is only available with the `--experimental-vm-modules` command
|
850
|
+
* flag enabled.
|
851
|
+
*
|
852
|
+
* The `vm.SyntheticModule` class provides the [Synthetic Module Record](https://heycam.github.io/webidl/#synthetic-module-records) as
|
853
|
+
* defined in the WebIDL specification. The purpose of synthetic modules is to
|
854
|
+
* provide a generic interface for exposing non-JavaScript sources to ECMAScript
|
855
|
+
* module graphs.
|
856
|
+
*
|
857
|
+
* ```js
|
858
|
+
* const vm = require('node:vm');
|
859
|
+
*
|
860
|
+
* const source = '{ "a": 1 }';
|
861
|
+
* const module = new vm.SyntheticModule(['default'], function() {
|
862
|
+
* const obj = JSON.parse(source);
|
863
|
+
* this.setExport('default', obj);
|
864
|
+
* });
|
865
|
+
*
|
866
|
+
* // Use `module` in linking...
|
867
|
+
* ```
|
868
|
+
* @since v13.0.0, v12.16.0
|
869
|
+
* @experimental
|
870
|
+
*/
|
871
|
+
class SyntheticModule extends Module {
|
872
|
+
/**
|
873
|
+
* Creates a new `SyntheticModule` instance.
|
874
|
+
* @param exportNames Array of names that will be exported from the module.
|
875
|
+
* @param evaluateCallback Called when the module is evaluated.
|
876
|
+
*/
|
877
|
+
constructor(
|
878
|
+
exportNames: string[],
|
879
|
+
evaluateCallback: (this: SyntheticModule) => void,
|
880
|
+
options?: SyntheticModuleOptions,
|
881
|
+
);
|
882
|
+
/**
|
883
|
+
* This method is used after the module is linked to set the values of exports. If
|
884
|
+
* it is called before the module is linked, an `ERR_VM_MODULE_STATUS` error
|
885
|
+
* will be thrown.
|
886
|
+
*
|
887
|
+
* ```js
|
888
|
+
* import vm from 'node:vm';
|
889
|
+
*
|
890
|
+
* const m = new vm.SyntheticModule(['x'], () => {
|
891
|
+
* m.setExport('x', 1);
|
892
|
+
* });
|
893
|
+
*
|
894
|
+
* await m.link(() => {});
|
895
|
+
* await m.evaluate();
|
896
|
+
*
|
897
|
+
* assert.strictEqual(m.namespace.x, 1);
|
898
|
+
* ```
|
899
|
+
* @since v13.0.0, v12.16.0
|
900
|
+
* @param name Name of the export to set.
|
901
|
+
* @param value The value to set the export to.
|
902
|
+
*/
|
903
|
+
setExport(name: string, value: any): void;
|
904
|
+
}
|
905
|
+
/**
|
906
|
+
* Returns an object containing commonly used constants for VM operations.
|
907
|
+
* @since v20.12.0
|
908
|
+
*/
|
909
|
+
namespace constants {
|
910
|
+
/**
|
911
|
+
* Stability: 1.1 - Active development
|
912
|
+
*
|
913
|
+
* A constant that can be used as the `importModuleDynamically` option to `vm.Script`
|
914
|
+
* and `vm.compileFunction()` so that Node.js uses the default ESM loader from the main
|
915
|
+
* context to load the requested module.
|
916
|
+
*
|
917
|
+
* For detailed information, see [Support of dynamic `import()` in compilation APIs](https://nodejs.org/docs/latest-v20.x/api/vm.html#support-of-dynamic-import-in-compilation-apis).
|
918
|
+
*/
|
919
|
+
const USE_MAIN_CONTEXT_DEFAULT_LOADER: number;
|
920
|
+
}
|
921
|
+
}
|
922
|
+
declare module "node:vm" {
|
923
|
+
export * from "vm";
|
924
|
+
}
|