@pnpm/exe 12.8.2 → 12.9.0
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/bin/pnpm.mjs +5 -1
- package/bin/pnpx.mjs +1 -1
- package/dist/node_modules/.pnpm-workspace-state-v1.json +6 -2
- package/dist/wasm/LICENSE +22 -0
- package/dist/wasm/README.md +140 -0
- package/dist/wasm/THIRD-PARTY-NOTICES.md +42 -0
- package/dist/wasm/host/atomic-waits.mjs +43 -0
- package/dist/wasm/host/cancellation.mjs +6 -0
- package/dist/wasm/host/executable-mode.mjs +8 -0
- package/dist/wasm/host/file-locks.mjs +40 -0
- package/dist/wasm/host/filesystem.mjs +318 -0
- package/dist/wasm/host/guest-imports.mjs +45 -0
- package/dist/wasm/host/guest-operations.mjs +148 -0
- package/dist/wasm/host/lock-registry.mjs +167 -0
- package/dist/wasm/host/network.mjs +76 -0
- package/dist/wasm/host/operations.mjs +67 -0
- package/dist/wasm/host/poll.mjs +74 -0
- package/dist/wasm/host/process-stdio.mjs +41 -0
- package/dist/wasm/host/process-tree.mjs +54 -0
- package/dist/wasm/host/process.mjs +126 -0
- package/dist/wasm/host/protocol.mjs +1 -0
- package/dist/wasm/host/resources.mjs +76 -0
- package/dist/wasm/host/shell-runner.mjs +8 -0
- package/dist/wasm/host/shell.mjs +19 -0
- package/dist/wasm/host/signals.mjs +49 -0
- package/dist/wasm/host/terminal-input.mjs +7 -0
- package/dist/wasm/host/terminal-password.mjs +32 -0
- package/dist/wasm/host/terminal-session.mjs +114 -0
- package/dist/wasm/host/terminal.mjs +61 -0
- package/dist/wasm/host/thread-spawn.mjs +21 -0
- package/dist/wasm/host/upload.mjs +21 -0
- package/dist/wasm/host/wait-for-reply.mjs +7 -0
- package/dist/wasm/host/wasi-errno.mjs +81 -0
- package/dist/wasm/host/wasi-imports.mjs +58 -0
- package/dist/wasm/node_modules/.bin/js-yaml +91 -0
- package/dist/wasm/node_modules/.bin/node-which +91 -0
- package/dist/wasm/node_modules/.bin/shell +91 -0
- package/dist/wasm/node_modules/.pnpm-workspace-state-v1.json +355 -0
- package/dist/wasm/node_modules/@emnapi/wasi-threads/LICENSE +21 -0
- package/dist/wasm/node_modules/@emnapi/wasi-threads/README.md +203 -0
- package/dist/wasm/node_modules/@emnapi/wasi-threads/dist/wasi-threads.cjs.js +894 -0
- package/dist/wasm/node_modules/@emnapi/wasi-threads/dist/wasi-threads.cjs.min.d.ts +272 -0
- package/dist/wasm/node_modules/@emnapi/wasi-threads/dist/wasi-threads.cjs.min.js +1 -0
- package/dist/wasm/node_modules/@emnapi/wasi-threads/dist/wasi-threads.d.mts +272 -0
- package/dist/wasm/node_modules/@emnapi/wasi-threads/dist/wasi-threads.d.ts +274 -0
- package/dist/wasm/node_modules/@emnapi/wasi-threads/dist/wasi-threads.esm-bundler.js +942 -0
- package/dist/wasm/node_modules/@emnapi/wasi-threads/dist/wasi-threads.js +954 -0
- package/dist/wasm/node_modules/@emnapi/wasi-threads/dist/wasi-threads.min.d.mts +272 -0
- package/dist/wasm/node_modules/@emnapi/wasi-threads/dist/wasi-threads.min.js +1 -0
- package/dist/wasm/node_modules/@emnapi/wasi-threads/dist/wasi-threads.min.mjs +1 -0
- package/dist/wasm/node_modules/@emnapi/wasi-threads/dist/wasi-threads.mjs +889 -0
- package/dist/wasm/node_modules/@emnapi/wasi-threads/index.js +5 -0
- package/dist/wasm/node_modules/@emnapi/wasi-threads/package.json +50 -0
- package/dist/wasm/node_modules/@nodelib/fs.scandir/LICENSE +21 -0
- package/dist/wasm/node_modules/@nodelib/fs.scandir/README.md +171 -0
- package/dist/wasm/node_modules/@nodelib/fs.scandir/out/adapters/fs.d.ts +20 -0
- package/dist/wasm/node_modules/@nodelib/fs.scandir/out/adapters/fs.js +19 -0
- package/dist/wasm/node_modules/@nodelib/fs.scandir/out/constants.d.ts +4 -0
- package/dist/wasm/node_modules/@nodelib/fs.scandir/out/constants.js +17 -0
- package/dist/wasm/node_modules/@nodelib/fs.scandir/out/index.d.ts +12 -0
- package/dist/wasm/node_modules/@nodelib/fs.scandir/out/index.js +26 -0
- package/dist/wasm/node_modules/@nodelib/fs.scandir/out/providers/async.d.ts +7 -0
- package/dist/wasm/node_modules/@nodelib/fs.scandir/out/providers/async.js +104 -0
- package/dist/wasm/node_modules/@nodelib/fs.scandir/out/providers/common.d.ts +1 -0
- package/dist/wasm/node_modules/@nodelib/fs.scandir/out/providers/common.js +13 -0
- package/dist/wasm/node_modules/@nodelib/fs.scandir/out/providers/sync.d.ts +5 -0
- package/dist/wasm/node_modules/@nodelib/fs.scandir/out/providers/sync.js +54 -0
- package/dist/wasm/node_modules/@nodelib/fs.scandir/out/settings.d.ts +20 -0
- package/dist/wasm/node_modules/@nodelib/fs.scandir/out/settings.js +24 -0
- package/dist/wasm/node_modules/@nodelib/fs.scandir/out/types/index.d.ts +20 -0
- package/dist/wasm/node_modules/@nodelib/fs.scandir/out/types/index.js +2 -0
- package/dist/wasm/node_modules/@nodelib/fs.scandir/out/utils/fs.d.ts +2 -0
- package/dist/wasm/node_modules/@nodelib/fs.scandir/out/utils/fs.js +19 -0
- package/dist/wasm/node_modules/@nodelib/fs.scandir/out/utils/index.d.ts +2 -0
- package/dist/wasm/node_modules/@nodelib/fs.scandir/out/utils/index.js +5 -0
- package/dist/wasm/node_modules/@nodelib/fs.scandir/package.json +44 -0
- package/dist/wasm/node_modules/@nodelib/fs.stat/LICENSE +21 -0
- package/dist/wasm/node_modules/@nodelib/fs.stat/README.md +126 -0
- package/dist/wasm/node_modules/@nodelib/fs.stat/out/adapters/fs.d.ts +13 -0
- package/dist/wasm/node_modules/@nodelib/fs.stat/out/adapters/fs.js +17 -0
- package/dist/wasm/node_modules/@nodelib/fs.stat/out/index.d.ts +12 -0
- package/dist/wasm/node_modules/@nodelib/fs.stat/out/index.js +26 -0
- package/dist/wasm/node_modules/@nodelib/fs.stat/out/providers/async.d.ts +4 -0
- package/dist/wasm/node_modules/@nodelib/fs.stat/out/providers/async.js +36 -0
- package/dist/wasm/node_modules/@nodelib/fs.stat/out/providers/sync.d.ts +3 -0
- package/dist/wasm/node_modules/@nodelib/fs.stat/out/providers/sync.js +23 -0
- package/dist/wasm/node_modules/@nodelib/fs.stat/out/settings.d.ts +16 -0
- package/dist/wasm/node_modules/@nodelib/fs.stat/out/settings.js +16 -0
- package/dist/wasm/node_modules/@nodelib/fs.stat/out/types/index.d.ts +4 -0
- package/dist/wasm/node_modules/@nodelib/fs.stat/out/types/index.js +2 -0
- package/dist/wasm/node_modules/@nodelib/fs.stat/package.json +37 -0
- package/dist/wasm/node_modules/@nodelib/fs.walk/LICENSE +21 -0
- package/dist/wasm/node_modules/@nodelib/fs.walk/README.md +215 -0
- package/dist/wasm/node_modules/@nodelib/fs.walk/out/index.d.ts +14 -0
- package/dist/wasm/node_modules/@nodelib/fs.walk/out/index.js +34 -0
- package/dist/wasm/node_modules/@nodelib/fs.walk/out/providers/async.d.ts +12 -0
- package/dist/wasm/node_modules/@nodelib/fs.walk/out/providers/async.js +30 -0
- package/dist/wasm/node_modules/@nodelib/fs.walk/out/providers/index.d.ts +4 -0
- package/dist/wasm/node_modules/@nodelib/fs.walk/out/providers/index.js +9 -0
- package/dist/wasm/node_modules/@nodelib/fs.walk/out/providers/stream.d.ts +12 -0
- package/dist/wasm/node_modules/@nodelib/fs.walk/out/providers/stream.js +34 -0
- package/dist/wasm/node_modules/@nodelib/fs.walk/out/providers/sync.d.ts +10 -0
- package/dist/wasm/node_modules/@nodelib/fs.walk/out/providers/sync.js +14 -0
- package/dist/wasm/node_modules/@nodelib/fs.walk/out/readers/async.d.ts +30 -0
- package/dist/wasm/node_modules/@nodelib/fs.walk/out/readers/async.js +97 -0
- package/dist/wasm/node_modules/@nodelib/fs.walk/out/readers/common.d.ts +7 -0
- package/dist/wasm/node_modules/@nodelib/fs.walk/out/readers/common.js +31 -0
- package/dist/wasm/node_modules/@nodelib/fs.walk/out/readers/reader.d.ts +6 -0
- package/dist/wasm/node_modules/@nodelib/fs.walk/out/readers/reader.js +11 -0
- package/dist/wasm/node_modules/@nodelib/fs.walk/out/readers/sync.d.ts +15 -0
- package/dist/wasm/node_modules/@nodelib/fs.walk/out/readers/sync.js +59 -0
- package/dist/wasm/node_modules/@nodelib/fs.walk/out/settings.d.ts +30 -0
- package/dist/wasm/node_modules/@nodelib/fs.walk/out/settings.js +26 -0
- package/dist/wasm/node_modules/@nodelib/fs.walk/out/types/index.d.ts +8 -0
- package/dist/wasm/node_modules/@nodelib/fs.walk/out/types/index.js +2 -0
- package/dist/wasm/node_modules/@nodelib/fs.walk/package.json +44 -0
- package/dist/wasm/node_modules/@tybys/wasm-util/LICENSE +21 -0
- package/dist/wasm/node_modules/@tybys/wasm-util/README.md +193 -0
- package/dist/wasm/node_modules/@tybys/wasm-util/dist/tsdoc-metadata.json +11 -0
- package/dist/wasm/node_modules/@tybys/wasm-util/dist/wasm-util.d.ts +423 -0
- package/dist/wasm/node_modules/@tybys/wasm-util/dist/wasm-util.esm-bundler.js +2932 -0
- package/dist/wasm/node_modules/@tybys/wasm-util/dist/wasm-util.esm.js +2932 -0
- package/dist/wasm/node_modules/@tybys/wasm-util/dist/wasm-util.esm.min.js +1 -0
- package/dist/wasm/node_modules/@tybys/wasm-util/dist/wasm-util.js +2954 -0
- package/dist/wasm/node_modules/@tybys/wasm-util/dist/wasm-util.min.js +1 -0
- package/dist/wasm/node_modules/@tybys/wasm-util/lib/cjs/asyncify.js +158 -0
- package/dist/wasm/node_modules/@tybys/wasm-util/lib/cjs/index.js +13 -0
- package/dist/wasm/node_modules/@tybys/wasm-util/lib/cjs/jspi.js +46 -0
- package/dist/wasm/node_modules/@tybys/wasm-util/lib/cjs/load.js +97 -0
- package/dist/wasm/node_modules/@tybys/wasm-util/lib/cjs/memory.js +35 -0
- package/dist/wasm/node_modules/@tybys/wasm-util/lib/cjs/wasi/error.js +103 -0
- package/dist/wasm/node_modules/@tybys/wasm-util/lib/cjs/wasi/fd.js +268 -0
- package/dist/wasm/node_modules/@tybys/wasm-util/lib/cjs/wasi/fs.js +3 -0
- package/dist/wasm/node_modules/@tybys/wasm-util/lib/cjs/wasi/index.js +192 -0
- package/dist/wasm/node_modules/@tybys/wasm-util/lib/cjs/wasi/path.js +316 -0
- package/dist/wasm/node_modules/@tybys/wasm-util/lib/cjs/wasi/preview1.js +1599 -0
- package/dist/wasm/node_modules/@tybys/wasm-util/lib/cjs/wasi/rights.js +141 -0
- package/dist/wasm/node_modules/@tybys/wasm-util/lib/cjs/wasi/types.js +220 -0
- package/dist/wasm/node_modules/@tybys/wasm-util/lib/cjs/wasi/util.js +128 -0
- package/dist/wasm/node_modules/@tybys/wasm-util/lib/cjs/webassembly.js +13 -0
- package/dist/wasm/node_modules/@tybys/wasm-util/lib/mjs/asyncify.mjs +153 -0
- package/dist/wasm/node_modules/@tybys/wasm-util/lib/mjs/index.mjs +9 -0
- package/dist/wasm/node_modules/@tybys/wasm-util/lib/mjs/jspi.mjs +39 -0
- package/dist/wasm/node_modules/@tybys/wasm-util/lib/mjs/load.mjs +89 -0
- package/dist/wasm/node_modules/@tybys/wasm-util/lib/mjs/memory.mjs +28 -0
- package/dist/wasm/node_modules/@tybys/wasm-util/lib/mjs/wasi/error.mjs +97 -0
- package/dist/wasm/node_modules/@tybys/wasm-util/lib/mjs/wasi/fd.mjs +256 -0
- package/dist/wasm/node_modules/@tybys/wasm-util/lib/mjs/wasi/fs.mjs +1 -0
- package/dist/wasm/node_modules/@tybys/wasm-util/lib/mjs/wasi/index.mjs +186 -0
- package/dist/wasm/node_modules/@tybys/wasm-util/lib/mjs/wasi/path.mjs +310 -0
- package/dist/wasm/node_modules/@tybys/wasm-util/lib/mjs/wasi/preview1.mjs +1593 -0
- package/dist/wasm/node_modules/@tybys/wasm-util/lib/mjs/wasi/rights.mjs +135 -0
- package/dist/wasm/node_modules/@tybys/wasm-util/lib/mjs/wasi/types.mjs +216 -0
- package/dist/wasm/node_modules/@tybys/wasm-util/lib/mjs/wasi/util.mjs +113 -0
- package/dist/wasm/node_modules/@tybys/wasm-util/lib/mjs/webassembly.mjs +9 -0
- package/dist/wasm/node_modules/@tybys/wasm-util/package.json +58 -0
- package/dist/wasm/node_modules/@types/braces/LICENSE +21 -0
- package/dist/wasm/node_modules/@types/braces/README.md +15 -0
- package/dist/wasm/node_modules/@types/braces/index.d.ts +100 -0
- package/dist/wasm/node_modules/@types/braces/package.json +36 -0
- package/dist/wasm/node_modules/@types/micromatch/LICENSE +21 -0
- package/dist/wasm/node_modules/@types/micromatch/README.md +15 -0
- package/dist/wasm/node_modules/@types/micromatch/index.d.ts +670 -0
- package/dist/wasm/node_modules/@types/micromatch/package.json +28 -0
- package/dist/wasm/node_modules/@yarnpkg/fslib/README.md +17 -0
- package/dist/wasm/node_modules/@yarnpkg/fslib/lib/AliasFS.d.ts +16 -0
- package/dist/wasm/node_modules/@yarnpkg/fslib/lib/AliasFS.js +24 -0
- package/dist/wasm/node_modules/@yarnpkg/fslib/lib/CwdFS.d.ts +15 -0
- package/dist/wasm/node_modules/@yarnpkg/fslib/lib/CwdFS.js +36 -0
- package/dist/wasm/node_modules/@yarnpkg/fslib/lib/FakeFS.d.ts +398 -0
- package/dist/wasm/node_modules/@yarnpkg/fslib/lib/FakeFS.js +451 -0
- package/dist/wasm/node_modules/@yarnpkg/fslib/lib/JailFS.d.ts +16 -0
- package/dist/wasm/node_modules/@yarnpkg/fslib/lib/JailFS.js +35 -0
- package/dist/wasm/node_modules/@yarnpkg/fslib/lib/LazyFS.d.ts +13 -0
- package/dist/wasm/node_modules/@yarnpkg/fslib/lib/LazyFS.js +26 -0
- package/dist/wasm/node_modules/@yarnpkg/fslib/lib/MountFS.d.ts +278 -0
- package/dist/wasm/node_modules/@yarnpkg/fslib/lib/MountFS.js +873 -0
- package/dist/wasm/node_modules/@yarnpkg/fslib/lib/NoFS.d.ts +78 -0
- package/dist/wasm/node_modules/@yarnpkg/fslib/lib/NoFS.js +229 -0
- package/dist/wasm/node_modules/@yarnpkg/fslib/lib/NodeFS.d.ts +223 -0
- package/dist/wasm/node_modules/@yarnpkg/fslib/lib/NodeFS.js +476 -0
- package/dist/wasm/node_modules/@yarnpkg/fslib/lib/NodePathFS.d.ts +18 -0
- package/dist/wasm/node_modules/@yarnpkg/fslib/lib/NodePathFS.js +47 -0
- package/dist/wasm/node_modules/@yarnpkg/fslib/lib/PosixFS.d.ts +9 -0
- package/dist/wasm/node_modules/@yarnpkg/fslib/lib/PosixFS.js +18 -0
- package/dist/wasm/node_modules/@yarnpkg/fslib/lib/ProxiedFS.d.ts +229 -0
- package/dist/wasm/node_modules/@yarnpkg/fslib/lib/ProxiedFS.js +255 -0
- package/dist/wasm/node_modules/@yarnpkg/fslib/lib/VirtualFS.d.ts +19 -0
- package/dist/wasm/node_modules/@yarnpkg/fslib/lib/VirtualFS.js +89 -0
- package/dist/wasm/node_modules/@yarnpkg/fslib/lib/algorithms/copyPromise.d.ts +19 -0
- package/dist/wasm/node_modules/@yarnpkg/fslib/lib/algorithms/copyPromise.js +271 -0
- package/dist/wasm/node_modules/@yarnpkg/fslib/lib/algorithms/opendir.d.ts +22 -0
- package/dist/wasm/node_modules/@yarnpkg/fslib/lib/algorithms/opendir.js +65 -0
- package/dist/wasm/node_modules/@yarnpkg/fslib/lib/algorithms/watchFile/CustomStatWatcher.d.ts +59 -0
- package/dist/wasm/node_modules/@yarnpkg/fslib/lib/algorithms/watchFile/CustomStatWatcher.js +139 -0
- package/dist/wasm/node_modules/@yarnpkg/fslib/lib/algorithms/watchFile.d.ts +6 -0
- package/dist/wasm/node_modules/@yarnpkg/fslib/lib/algorithms/watchFile.js +67 -0
- package/dist/wasm/node_modules/@yarnpkg/fslib/lib/constants.d.ts +13 -0
- package/dist/wasm/node_modules/@yarnpkg/fslib/lib/constants.js +16 -0
- package/dist/wasm/node_modules/@yarnpkg/fslib/lib/errors.d.ts +36 -0
- package/dist/wasm/node_modules/@yarnpkg/fslib/lib/errors.js +54 -0
- package/dist/wasm/node_modules/@yarnpkg/fslib/lib/index.d.ts +48 -0
- package/dist/wasm/node_modules/@yarnpkg/fslib/lib/index.js +55 -0
- package/dist/wasm/node_modules/@yarnpkg/fslib/lib/patchFs/FileHandle.d.ts +81 -0
- package/dist/wasm/node_modules/@yarnpkg/fslib/lib/patchFs/FileHandle.js +254 -0
- package/dist/wasm/node_modules/@yarnpkg/fslib/lib/patchFs/patchFs.d.ts +5 -0
- package/dist/wasm/node_modules/@yarnpkg/fslib/lib/patchFs/patchFs.js +265 -0
- package/dist/wasm/node_modules/@yarnpkg/fslib/lib/path.d.ts +84 -0
- package/dist/wasm/node_modules/@yarnpkg/fslib/lib/path.js +103 -0
- package/dist/wasm/node_modules/@yarnpkg/fslib/lib/statUtils.d.ts +81 -0
- package/dist/wasm/node_modules/@yarnpkg/fslib/lib/statUtils.js +238 -0
- package/dist/wasm/node_modules/@yarnpkg/fslib/lib/xfs.d.ts +18 -0
- package/dist/wasm/node_modules/@yarnpkg/fslib/lib/xfs.js +123 -0
- package/dist/wasm/node_modules/@yarnpkg/fslib/package.json +42 -0
- package/dist/wasm/node_modules/@yarnpkg/parsers/lib/grammars/resolution.d.ts +1 -0
- package/dist/wasm/node_modules/@yarnpkg/parsers/lib/grammars/resolution.js +530 -0
- package/dist/wasm/node_modules/@yarnpkg/parsers/lib/grammars/resolution.pegjs +17 -0
- package/dist/wasm/node_modules/@yarnpkg/parsers/lib/grammars/shell.d.ts +92 -0
- package/dist/wasm/node_modules/@yarnpkg/parsers/lib/grammars/shell.js +3653 -0
- package/dist/wasm/node_modules/@yarnpkg/parsers/lib/grammars/shell.pegjs +189 -0
- package/dist/wasm/node_modules/@yarnpkg/parsers/lib/grammars/syml.d.ts +1 -0
- package/dist/wasm/node_modules/@yarnpkg/parsers/lib/grammars/syml.js +1911 -0
- package/dist/wasm/node_modules/@yarnpkg/parsers/lib/grammars/syml.pegjs +125 -0
- package/dist/wasm/node_modules/@yarnpkg/parsers/lib/index.d.ts +6 -0
- package/dist/wasm/node_modules/@yarnpkg/parsers/lib/index.js +24 -0
- package/dist/wasm/node_modules/@yarnpkg/parsers/lib/resolution.d.ts +12 -0
- package/dist/wasm/node_modules/@yarnpkg/parsers/lib/resolution.js +31 -0
- package/dist/wasm/node_modules/@yarnpkg/parsers/lib/shell.d.ts +19 -0
- package/dist/wasm/node_modules/@yarnpkg/parsers/lib/shell.js +170 -0
- package/dist/wasm/node_modules/@yarnpkg/parsers/lib/syml.d.ts +11 -0
- package/dist/wasm/node_modules/@yarnpkg/parsers/lib/syml.js +132 -0
- package/dist/wasm/node_modules/@yarnpkg/parsers/package.json +46 -0
- package/dist/wasm/node_modules/@yarnpkg/shell/README.md +38 -0
- package/dist/wasm/node_modules/@yarnpkg/shell/lib/boot-cli-dev.js +3 -0
- package/dist/wasm/node_modules/@yarnpkg/shell/lib/cli.d.ts +2 -0
- package/dist/wasm/node_modules/@yarnpkg/shell/lib/cli.js +19 -0
- package/dist/wasm/node_modules/@yarnpkg/shell/lib/commands/entry.d.ts +8 -0
- package/dist/wasm/node_modules/@yarnpkg/shell/lib/commands/entry.js +60 -0
- package/dist/wasm/node_modules/@yarnpkg/shell/lib/errors.d.ts +6 -0
- package/dist/wasm/node_modules/@yarnpkg/shell/lib/errors.js +13 -0
- package/dist/wasm/node_modules/@yarnpkg/shell/lib/globUtils.d.ts +23 -0
- package/dist/wasm/node_modules/@yarnpkg/shell/lib/globUtils.js +47 -0
- package/dist/wasm/node_modules/@yarnpkg/shell/lib/index.d.ts +56 -0
- package/dist/wasm/node_modules/@yarnpkg/shell/lib/index.js +926 -0
- package/dist/wasm/node_modules/@yarnpkg/shell/lib/pipe.d.ts +54 -0
- package/dist/wasm/node_modules/@yarnpkg/shell/lib/pipe.js +281 -0
- package/dist/wasm/node_modules/@yarnpkg/shell/package.json +54 -0
- package/dist/wasm/node_modules/ansi-styles/index.d.ts +345 -0
- package/dist/wasm/node_modules/ansi-styles/index.js +163 -0
- package/dist/wasm/node_modules/ansi-styles/license +9 -0
- package/dist/wasm/node_modules/ansi-styles/package.json +56 -0
- package/dist/wasm/node_modules/ansi-styles/readme.md +152 -0
- package/dist/wasm/node_modules/argparse/CHANGELOG.md +216 -0
- package/dist/wasm/node_modules/argparse/LICENSE +254 -0
- package/dist/wasm/node_modules/argparse/README.md +84 -0
- package/dist/wasm/node_modules/argparse/argparse.js +3707 -0
- package/dist/wasm/node_modules/argparse/lib/sub.js +67 -0
- package/dist/wasm/node_modules/argparse/lib/textwrap.js +440 -0
- package/dist/wasm/node_modules/argparse/package.json +31 -0
- package/dist/wasm/node_modules/braces/LICENSE +21 -0
- package/dist/wasm/node_modules/braces/README.md +586 -0
- package/dist/wasm/node_modules/braces/index.js +170 -0
- package/dist/wasm/node_modules/braces/lib/compile.js +60 -0
- package/dist/wasm/node_modules/braces/lib/constants.js +57 -0
- package/dist/wasm/node_modules/braces/lib/expand.js +113 -0
- package/dist/wasm/node_modules/braces/lib/parse.js +331 -0
- package/dist/wasm/node_modules/braces/lib/stringify.js +32 -0
- package/dist/wasm/node_modules/braces/lib/utils.js +122 -0
- package/dist/wasm/node_modules/braces/package.json +77 -0
- package/dist/wasm/node_modules/chalk/index.d.ts +415 -0
- package/dist/wasm/node_modules/chalk/license +9 -0
- package/dist/wasm/node_modules/chalk/package.json +68 -0
- package/dist/wasm/node_modules/chalk/readme.md +341 -0
- package/dist/wasm/node_modules/chalk/source/index.js +229 -0
- package/dist/wasm/node_modules/chalk/source/templates.js +134 -0
- package/dist/wasm/node_modules/chalk/source/util.js +39 -0
- package/dist/wasm/node_modules/clipanion/README.md +98 -0
- package/dist/wasm/node_modules/clipanion/lib/advanced/Cli.d.ts +225 -0
- package/dist/wasm/node_modules/clipanion/lib/advanced/Cli.js +406 -0
- package/dist/wasm/node_modules/clipanion/lib/advanced/Cli.mjs +398 -0
- package/dist/wasm/node_modules/clipanion/lib/advanced/Command.d.ts +144 -0
- package/dist/wasm/node_modules/clipanion/lib/advanced/Command.js +91 -0
- package/dist/wasm/node_modules/clipanion/lib/advanced/Command.mjs +67 -0
- package/dist/wasm/node_modules/clipanion/lib/advanced/HelpCommand.d.ts +11 -0
- package/dist/wasm/node_modules/clipanion/lib/advanced/HelpCommand.js +54 -0
- package/dist/wasm/node_modules/clipanion/lib/advanced/HelpCommand.mjs +50 -0
- package/dist/wasm/node_modules/clipanion/lib/advanced/builtins/definitions.d.ts +8 -0
- package/dist/wasm/node_modules/clipanion/lib/advanced/builtins/definitions.js +17 -0
- package/dist/wasm/node_modules/clipanion/lib/advanced/builtins/definitions.mjs +13 -0
- package/dist/wasm/node_modules/clipanion/lib/advanced/builtins/help.d.ts +10 -0
- package/dist/wasm/node_modules/clipanion/lib/advanced/builtins/help.js +19 -0
- package/dist/wasm/node_modules/clipanion/lib/advanced/builtins/help.mjs +15 -0
- package/dist/wasm/node_modules/clipanion/lib/advanced/builtins/index.d.ts +3 -0
- package/dist/wasm/node_modules/clipanion/lib/advanced/builtins/index.js +13 -0
- package/dist/wasm/node_modules/clipanion/lib/advanced/builtins/index.mjs +3 -0
- package/dist/wasm/node_modules/clipanion/lib/advanced/builtins/version.d.ts +10 -0
- package/dist/wasm/node_modules/clipanion/lib/advanced/builtins/version.js +20 -0
- package/dist/wasm/node_modules/clipanion/lib/advanced/builtins/version.mjs +16 -0
- package/dist/wasm/node_modules/clipanion/lib/advanced/index.d.ts +7 -0
- package/dist/wasm/node_modules/clipanion/lib/advanced/index.js +19 -0
- package/dist/wasm/node_modules/clipanion/lib/advanced/index.mjs +8 -0
- package/dist/wasm/node_modules/clipanion/lib/advanced/options/Array.d.ts +17 -0
- package/dist/wasm/node_modules/clipanion/lib/advanced/options/Array.js +37 -0
- package/dist/wasm/node_modules/clipanion/lib/advanced/options/Array.mjs +33 -0
- package/dist/wasm/node_modules/clipanion/lib/advanced/options/Boolean.d.ts +14 -0
- package/dist/wasm/node_modules/clipanion/lib/advanced/options/Boolean.js +34 -0
- package/dist/wasm/node_modules/clipanion/lib/advanced/options/Boolean.mjs +30 -0
- package/dist/wasm/node_modules/clipanion/lib/advanced/options/Counter.d.ts +15 -0
- package/dist/wasm/node_modules/clipanion/lib/advanced/options/Counter.js +41 -0
- package/dist/wasm/node_modules/clipanion/lib/advanced/options/Counter.mjs +37 -0
- package/dist/wasm/node_modules/clipanion/lib/advanced/options/Proxy.d.ts +18 -0
- package/dist/wasm/node_modules/clipanion/lib/advanced/options/Proxy.js +35 -0
- package/dist/wasm/node_modules/clipanion/lib/advanced/options/Proxy.mjs +31 -0
- package/dist/wasm/node_modules/clipanion/lib/advanced/options/Rest.d.ts +18 -0
- package/dist/wasm/node_modules/clipanion/lib/advanced/options/Rest.js +51 -0
- package/dist/wasm/node_modules/clipanion/lib/advanced/options/Rest.mjs +47 -0
- package/dist/wasm/node_modules/clipanion/lib/advanced/options/String.d.ts +49 -0
- package/dist/wasm/node_modules/clipanion/lib/advanced/options/String.js +84 -0
- package/dist/wasm/node_modules/clipanion/lib/advanced/options/String.mjs +80 -0
- package/dist/wasm/node_modules/clipanion/lib/advanced/options/index.d.ts +7 -0
- package/dist/wasm/node_modules/clipanion/lib/advanced/options/index.js +26 -0
- package/dist/wasm/node_modules/clipanion/lib/advanced/options/index.mjs +7 -0
- package/dist/wasm/node_modules/clipanion/lib/advanced/options/utils.d.ts +25 -0
- package/dist/wasm/node_modules/clipanion/lib/advanced/options/utils.js +59 -0
- package/dist/wasm/node_modules/clipanion/lib/advanced/options/utils.mjs +50 -0
- package/dist/wasm/node_modules/clipanion/lib/constants.d.ts +11 -0
- package/dist/wasm/node_modules/clipanion/lib/constants.js +27 -0
- package/dist/wasm/node_modules/clipanion/lib/constants.mjs +13 -0
- package/dist/wasm/node_modules/clipanion/lib/core.d.ts +462 -0
- package/dist/wasm/node_modules/clipanion/lib/core.js +827 -0
- package/dist/wasm/node_modules/clipanion/lib/core.mjs +800 -0
- package/dist/wasm/node_modules/clipanion/lib/demos/advanced.d.ts +22 -0
- package/dist/wasm/node_modules/clipanion/lib/errors.d.ts +52 -0
- package/dist/wasm/node_modules/clipanion/lib/errors.js +70 -0
- package/dist/wasm/node_modules/clipanion/lib/errors.mjs +64 -0
- package/dist/wasm/node_modules/clipanion/lib/format.d.ts +19 -0
- package/dist/wasm/node_modules/clipanion/lib/format.js +74 -0
- package/dist/wasm/node_modules/clipanion/lib/format.mjs +68 -0
- package/dist/wasm/node_modules/clipanion/package.json +68 -0
- package/dist/wasm/node_modules/color-convert/CHANGELOG.md +54 -0
- package/dist/wasm/node_modules/color-convert/LICENSE +21 -0
- package/dist/wasm/node_modules/color-convert/README.md +68 -0
- package/dist/wasm/node_modules/color-convert/conversions.js +839 -0
- package/dist/wasm/node_modules/color-convert/index.js +81 -0
- package/dist/wasm/node_modules/color-convert/package.json +48 -0
- package/dist/wasm/node_modules/color-convert/route.js +97 -0
- package/dist/wasm/node_modules/color-name/LICENSE +8 -0
- package/dist/wasm/node_modules/color-name/README.md +11 -0
- package/dist/wasm/node_modules/color-name/index.js +152 -0
- package/dist/wasm/node_modules/color-name/package.json +28 -0
- package/dist/wasm/node_modules/cross-spawn/LICENSE +21 -0
- package/dist/wasm/node_modules/cross-spawn/README.md +89 -0
- package/dist/wasm/node_modules/cross-spawn/index.js +39 -0
- package/dist/wasm/node_modules/cross-spawn/lib/enoent.js +59 -0
- package/dist/wasm/node_modules/cross-spawn/lib/parse.js +91 -0
- package/dist/wasm/node_modules/cross-spawn/lib/util/escape.js +47 -0
- package/dist/wasm/node_modules/cross-spawn/lib/util/readShebang.js +23 -0
- package/dist/wasm/node_modules/cross-spawn/lib/util/resolveCommand.js +52 -0
- package/dist/wasm/node_modules/cross-spawn/package.json +73 -0
- package/dist/wasm/node_modules/fast-glob/LICENSE +21 -0
- package/dist/wasm/node_modules/fast-glob/README.md +830 -0
- package/dist/wasm/node_modules/fast-glob/out/index.d.ts +40 -0
- package/dist/wasm/node_modules/fast-glob/out/index.js +102 -0
- package/dist/wasm/node_modules/fast-glob/out/managers/tasks.d.ts +22 -0
- package/dist/wasm/node_modules/fast-glob/out/managers/tasks.js +110 -0
- package/dist/wasm/node_modules/fast-glob/out/providers/async.d.ts +9 -0
- package/dist/wasm/node_modules/fast-glob/out/providers/async.js +23 -0
- package/dist/wasm/node_modules/fast-glob/out/providers/filters/deep.d.ts +16 -0
- package/dist/wasm/node_modules/fast-glob/out/providers/filters/deep.js +62 -0
- package/dist/wasm/node_modules/fast-glob/out/providers/filters/entry.d.ts +17 -0
- package/dist/wasm/node_modules/fast-glob/out/providers/filters/entry.js +85 -0
- package/dist/wasm/node_modules/fast-glob/out/providers/filters/error.d.ts +8 -0
- package/dist/wasm/node_modules/fast-glob/out/providers/filters/error.js +15 -0
- package/dist/wasm/node_modules/fast-glob/out/providers/matchers/matcher.d.ts +33 -0
- package/dist/wasm/node_modules/fast-glob/out/providers/matchers/matcher.js +45 -0
- package/dist/wasm/node_modules/fast-glob/out/providers/matchers/partial.d.ts +4 -0
- package/dist/wasm/node_modules/fast-glob/out/providers/matchers/partial.js +38 -0
- package/dist/wasm/node_modules/fast-glob/out/providers/provider.d.ts +19 -0
- package/dist/wasm/node_modules/fast-glob/out/providers/provider.js +48 -0
- package/dist/wasm/node_modules/fast-glob/out/providers/stream.d.ts +11 -0
- package/dist/wasm/node_modules/fast-glob/out/providers/stream.js +31 -0
- package/dist/wasm/node_modules/fast-glob/out/providers/sync.d.ts +9 -0
- package/dist/wasm/node_modules/fast-glob/out/providers/sync.js +23 -0
- package/dist/wasm/node_modules/fast-glob/out/providers/transformers/entry.d.ts +8 -0
- package/dist/wasm/node_modules/fast-glob/out/providers/transformers/entry.js +26 -0
- package/dist/wasm/node_modules/fast-glob/out/readers/async.d.ts +10 -0
- package/dist/wasm/node_modules/fast-glob/out/readers/async.js +35 -0
- package/dist/wasm/node_modules/fast-glob/out/readers/reader.d.ts +15 -0
- package/dist/wasm/node_modules/fast-glob/out/readers/reader.js +33 -0
- package/dist/wasm/node_modules/fast-glob/out/readers/stream.d.ts +14 -0
- package/dist/wasm/node_modules/fast-glob/out/readers/stream.js +55 -0
- package/dist/wasm/node_modules/fast-glob/out/readers/sync.d.ts +12 -0
- package/dist/wasm/node_modules/fast-glob/out/readers/sync.js +43 -0
- package/dist/wasm/node_modules/fast-glob/out/settings.d.ts +164 -0
- package/dist/wasm/node_modules/fast-glob/out/settings.js +59 -0
- package/dist/wasm/node_modules/fast-glob/out/types/index.d.ts +31 -0
- package/dist/wasm/node_modules/fast-glob/out/types/index.js +2 -0
- package/dist/wasm/node_modules/fast-glob/out/utils/array.d.ts +2 -0
- package/dist/wasm/node_modules/fast-glob/out/utils/array.js +22 -0
- package/dist/wasm/node_modules/fast-glob/out/utils/errno.d.ts +2 -0
- package/dist/wasm/node_modules/fast-glob/out/utils/errno.js +7 -0
- package/dist/wasm/node_modules/fast-glob/out/utils/fs.d.ts +4 -0
- package/dist/wasm/node_modules/fast-glob/out/utils/fs.js +19 -0
- package/dist/wasm/node_modules/fast-glob/out/utils/index.d.ts +8 -0
- package/dist/wasm/node_modules/fast-glob/out/utils/index.js +17 -0
- package/dist/wasm/node_modules/fast-glob/out/utils/path.d.ts +13 -0
- package/dist/wasm/node_modules/fast-glob/out/utils/path.js +68 -0
- package/dist/wasm/node_modules/fast-glob/out/utils/pattern.d.ts +49 -0
- package/dist/wasm/node_modules/fast-glob/out/utils/pattern.js +206 -0
- package/dist/wasm/node_modules/fast-glob/out/utils/stream.d.ts +4 -0
- package/dist/wasm/node_modules/fast-glob/out/utils/stream.js +17 -0
- package/dist/wasm/node_modules/fast-glob/out/utils/string.d.ts +2 -0
- package/dist/wasm/node_modules/fast-glob/out/utils/string.js +11 -0
- package/dist/wasm/node_modules/fast-glob/package.json +81 -0
- package/dist/wasm/node_modules/fastq/LICENSE +13 -0
- package/dist/wasm/node_modules/fastq/README.md +310 -0
- package/dist/wasm/node_modules/fastq/SECURITY.md +15 -0
- package/dist/wasm/node_modules/fastq/bench.js +66 -0
- package/dist/wasm/node_modules/fastq/eslint.config.js +11 -0
- package/dist/wasm/node_modules/fastq/example.js +14 -0
- package/dist/wasm/node_modules/fastq/example.mjs +9 -0
- package/dist/wasm/node_modules/fastq/index.d.ts +59 -0
- package/dist/wasm/node_modules/fastq/package.json +49 -0
- package/dist/wasm/node_modules/fastq/queue.js +348 -0
- package/dist/wasm/node_modules/fastq/test/example.ts +83 -0
- package/dist/wasm/node_modules/fastq/test/promise.js +356 -0
- package/dist/wasm/node_modules/fastq/test/test.js +808 -0
- package/dist/wasm/node_modules/fastq/test/tsconfig.json +11 -0
- package/dist/wasm/node_modules/fill-range/LICENSE +21 -0
- package/dist/wasm/node_modules/fill-range/README.md +237 -0
- package/dist/wasm/node_modules/fill-range/index.js +248 -0
- package/dist/wasm/node_modules/fill-range/package.json +74 -0
- package/dist/wasm/node_modules/glob-parent/CHANGELOG.md +110 -0
- package/dist/wasm/node_modules/glob-parent/LICENSE +15 -0
- package/dist/wasm/node_modules/glob-parent/README.md +137 -0
- package/dist/wasm/node_modules/glob-parent/index.js +42 -0
- package/dist/wasm/node_modules/glob-parent/package.json +48 -0
- package/dist/wasm/node_modules/has-flag/index.d.ts +39 -0
- package/dist/wasm/node_modules/has-flag/index.js +8 -0
- package/dist/wasm/node_modules/has-flag/license +9 -0
- package/dist/wasm/node_modules/has-flag/package.json +46 -0
- package/dist/wasm/node_modules/has-flag/readme.md +89 -0
- package/dist/wasm/node_modules/is-extglob/LICENSE +21 -0
- package/dist/wasm/node_modules/is-extglob/README.md +107 -0
- package/dist/wasm/node_modules/is-extglob/index.js +20 -0
- package/dist/wasm/node_modules/is-extglob/package.json +69 -0
- package/dist/wasm/node_modules/is-glob/LICENSE +21 -0
- package/dist/wasm/node_modules/is-glob/README.md +206 -0
- package/dist/wasm/node_modules/is-glob/index.js +150 -0
- package/dist/wasm/node_modules/is-glob/package.json +81 -0
- package/dist/wasm/node_modules/is-number/LICENSE +21 -0
- package/dist/wasm/node_modules/is-number/README.md +187 -0
- package/dist/wasm/node_modules/is-number/index.js +18 -0
- package/dist/wasm/node_modules/is-number/package.json +82 -0
- package/dist/wasm/node_modules/isexe/.npmignore +2 -0
- package/dist/wasm/node_modules/isexe/LICENSE +15 -0
- package/dist/wasm/node_modules/isexe/README.md +51 -0
- package/dist/wasm/node_modules/isexe/index.js +57 -0
- package/dist/wasm/node_modules/isexe/mode.js +41 -0
- package/dist/wasm/node_modules/isexe/package.json +31 -0
- package/dist/wasm/node_modules/isexe/test/basic.js +221 -0
- package/dist/wasm/node_modules/isexe/windows.js +42 -0
- package/dist/wasm/node_modules/js-yaml/LICENSE +21 -0
- package/dist/wasm/node_modules/js-yaml/README.md +246 -0
- package/dist/wasm/node_modules/js-yaml/bin/js-yaml.js +126 -0
- package/dist/wasm/node_modules/js-yaml/dist/js-yaml.js +3874 -0
- package/dist/wasm/node_modules/js-yaml/dist/js-yaml.min.js +2 -0
- package/dist/wasm/node_modules/js-yaml/dist/js-yaml.mjs +3851 -0
- package/dist/wasm/node_modules/js-yaml/index.js +30 -0
- package/dist/wasm/node_modules/js-yaml/lib/common.js +59 -0
- package/dist/wasm/node_modules/js-yaml/lib/dumper.js +979 -0
- package/dist/wasm/node_modules/js-yaml/lib/exception.js +55 -0
- package/dist/wasm/node_modules/js-yaml/lib/loader.js +1733 -0
- package/dist/wasm/node_modules/js-yaml/lib/schema/core.js +11 -0
- package/dist/wasm/node_modules/js-yaml/lib/schema/default.js +22 -0
- package/dist/wasm/node_modules/js-yaml/lib/schema/failsafe.js +17 -0
- package/dist/wasm/node_modules/js-yaml/lib/schema/json.js +19 -0
- package/dist/wasm/node_modules/js-yaml/lib/schema.js +121 -0
- package/dist/wasm/node_modules/js-yaml/lib/snippet.js +101 -0
- package/dist/wasm/node_modules/js-yaml/lib/type/binary.js +125 -0
- package/dist/wasm/node_modules/js-yaml/lib/type/bool.js +35 -0
- package/dist/wasm/node_modules/js-yaml/lib/type/float.js +97 -0
- package/dist/wasm/node_modules/js-yaml/lib/type/int.js +156 -0
- package/dist/wasm/node_modules/js-yaml/lib/type/map.js +8 -0
- package/dist/wasm/node_modules/js-yaml/lib/type/merge.js +12 -0
- package/dist/wasm/node_modules/js-yaml/lib/type/null.js +35 -0
- package/dist/wasm/node_modules/js-yaml/lib/type/omap.js +44 -0
- package/dist/wasm/node_modules/js-yaml/lib/type/pairs.js +53 -0
- package/dist/wasm/node_modules/js-yaml/lib/type/seq.js +8 -0
- package/dist/wasm/node_modules/js-yaml/lib/type/set.js +29 -0
- package/dist/wasm/node_modules/js-yaml/lib/type/str.js +8 -0
- package/dist/wasm/node_modules/js-yaml/lib/type/timestamp.js +88 -0
- package/dist/wasm/node_modules/js-yaml/lib/type.js +65 -0
- package/dist/wasm/node_modules/js-yaml/package.json +65 -0
- package/dist/wasm/node_modules/merge2/LICENSE +21 -0
- package/dist/wasm/node_modules/merge2/README.md +144 -0
- package/dist/wasm/node_modules/merge2/index.js +144 -0
- package/dist/wasm/node_modules/merge2/package.json +43 -0
- package/dist/wasm/node_modules/micromatch/LICENSE +21 -0
- package/dist/wasm/node_modules/micromatch/README.md +1024 -0
- package/dist/wasm/node_modules/micromatch/index.js +474 -0
- package/dist/wasm/node_modules/micromatch/package.json +119 -0
- package/dist/wasm/node_modules/path-key/index.d.ts +40 -0
- package/dist/wasm/node_modules/path-key/index.js +16 -0
- package/dist/wasm/node_modules/path-key/license +9 -0
- package/dist/wasm/node_modules/path-key/package.json +39 -0
- package/dist/wasm/node_modules/path-key/readme.md +61 -0
- package/dist/wasm/node_modules/picomatch/LICENSE +21 -0
- package/dist/wasm/node_modules/picomatch/README.md +716 -0
- package/dist/wasm/node_modules/picomatch/index.js +3 -0
- package/dist/wasm/node_modules/picomatch/lib/constants.js +184 -0
- package/dist/wasm/node_modules/picomatch/lib/parse.js +1392 -0
- package/dist/wasm/node_modules/picomatch/lib/picomatch.js +342 -0
- package/dist/wasm/node_modules/picomatch/lib/scan.js +391 -0
- package/dist/wasm/node_modules/picomatch/lib/utils.js +64 -0
- package/dist/wasm/node_modules/picomatch/package.json +81 -0
- package/dist/wasm/node_modules/queue-microtask/LICENSE +20 -0
- package/dist/wasm/node_modules/queue-microtask/README.md +90 -0
- package/dist/wasm/node_modules/queue-microtask/index.d.ts +2 -0
- package/dist/wasm/node_modules/queue-microtask/index.js +9 -0
- package/dist/wasm/node_modules/queue-microtask/package.json +55 -0
- package/dist/wasm/node_modules/reusify/.github/dependabot.yml +7 -0
- package/dist/wasm/node_modules/reusify/.github/workflows/ci.yml +96 -0
- package/dist/wasm/node_modules/reusify/LICENSE +22 -0
- package/dist/wasm/node_modules/reusify/README.md +139 -0
- package/dist/wasm/node_modules/reusify/SECURITY.md +15 -0
- package/dist/wasm/node_modules/reusify/benchmarks/createNoCodeFunction.js +30 -0
- package/dist/wasm/node_modules/reusify/benchmarks/fib.js +13 -0
- package/dist/wasm/node_modules/reusify/benchmarks/reuseNoCodeFunction.js +38 -0
- package/dist/wasm/node_modules/reusify/eslint.config.js +14 -0
- package/dist/wasm/node_modules/reusify/package.json +50 -0
- package/dist/wasm/node_modules/reusify/reusify.d.ts +14 -0
- package/dist/wasm/node_modules/reusify/reusify.js +33 -0
- package/dist/wasm/node_modules/reusify/test.js +66 -0
- package/dist/wasm/node_modules/reusify/tsconfig.json +11 -0
- package/dist/wasm/node_modules/run-parallel/LICENSE +20 -0
- package/dist/wasm/node_modules/run-parallel/README.md +85 -0
- package/dist/wasm/node_modules/run-parallel/index.js +51 -0
- package/dist/wasm/node_modules/run-parallel/package.json +58 -0
- package/dist/wasm/node_modules/shebang-command/index.js +19 -0
- package/dist/wasm/node_modules/shebang-command/license +9 -0
- package/dist/wasm/node_modules/shebang-command/package.json +34 -0
- package/dist/wasm/node_modules/shebang-command/readme.md +34 -0
- package/dist/wasm/node_modules/shebang-regex/index.d.ts +22 -0
- package/dist/wasm/node_modules/shebang-regex/index.js +2 -0
- package/dist/wasm/node_modules/shebang-regex/license +9 -0
- package/dist/wasm/node_modules/shebang-regex/package.json +35 -0
- package/dist/wasm/node_modules/shebang-regex/readme.md +33 -0
- package/dist/wasm/node_modules/supports-color/browser.js +5 -0
- package/dist/wasm/node_modules/supports-color/index.js +135 -0
- package/dist/wasm/node_modules/supports-color/license +9 -0
- package/dist/wasm/node_modules/supports-color/package.json +53 -0
- package/dist/wasm/node_modules/supports-color/readme.md +76 -0
- package/dist/wasm/node_modules/to-regex-range/LICENSE +21 -0
- package/dist/wasm/node_modules/to-regex-range/README.md +305 -0
- package/dist/wasm/node_modules/to-regex-range/index.js +288 -0
- package/dist/wasm/node_modules/to-regex-range/package.json +88 -0
- package/dist/wasm/node_modules/tslib/CopyrightNotice.txt +15 -0
- package/dist/wasm/node_modules/tslib/LICENSE.txt +12 -0
- package/dist/wasm/node_modules/tslib/README.md +164 -0
- package/dist/wasm/node_modules/tslib/SECURITY.md +41 -0
- package/dist/wasm/node_modules/tslib/modules/index.d.ts +38 -0
- package/dist/wasm/node_modules/tslib/modules/index.js +70 -0
- package/dist/wasm/node_modules/tslib/modules/package.json +3 -0
- package/dist/wasm/node_modules/tslib/package.json +47 -0
- package/dist/wasm/node_modules/tslib/tslib.d.ts +460 -0
- package/dist/wasm/node_modules/tslib/tslib.es6.html +1 -0
- package/dist/wasm/node_modules/tslib/tslib.es6.js +402 -0
- package/dist/wasm/node_modules/tslib/tslib.es6.mjs +401 -0
- package/dist/wasm/node_modules/tslib/tslib.html +1 -0
- package/dist/wasm/node_modules/tslib/tslib.js +484 -0
- package/dist/wasm/node_modules/typanion/README.md +117 -0
- package/dist/wasm/node_modules/typanion/lib/index.d.ts +5 -0
- package/dist/wasm/node_modules/typanion/lib/index.js +1305 -0
- package/dist/wasm/node_modules/typanion/lib/index.mjs +1249 -0
- package/dist/wasm/node_modules/typanion/lib/internal/format.d.ts +5 -0
- package/dist/wasm/node_modules/typanion/lib/internal/regexps.d.ts +5 -0
- package/dist/wasm/node_modules/typanion/lib/internal/tools.d.ts +5 -0
- package/dist/wasm/node_modules/typanion/lib/predicates/cascadingPredicates.d.ts +114 -0
- package/dist/wasm/node_modules/typanion/lib/predicates/helperPredicates.d.ts +80 -0
- package/dist/wasm/node_modules/typanion/lib/predicates/typePredicates.d.ts +205 -0
- package/dist/wasm/node_modules/typanion/lib/tools.d.ts +90 -0
- package/dist/wasm/node_modules/typanion/lib/types.d.ts +22 -0
- package/dist/wasm/node_modules/typanion/package.json +40 -0
- package/dist/wasm/node_modules/which/CHANGELOG.md +166 -0
- package/dist/wasm/node_modules/which/LICENSE +15 -0
- package/dist/wasm/node_modules/which/README.md +54 -0
- package/dist/wasm/node_modules/which/bin/node-which +52 -0
- package/dist/wasm/node_modules/which/package.json +43 -0
- package/dist/wasm/node_modules/which/which.js +125 -0
- package/dist/wasm/package.json +10 -0
- package/dist/wasm/pnpm.mjs +8 -0
- package/dist/wasm/pnpm.wasm +4 -0
- package/dist/wasm/pnpx.mjs +8 -0
- package/dist/wasm/run.mjs +147 -0
- package/dist/wasm/worker.mjs +56 -0
- package/install.js +18 -21
- package/package.json +15 -15
- package/pn +2 -74
- package/pnpm +2 -94
- package/pnpx +2 -74
- package/pnx +2 -74
|
@@ -0,0 +1,1599 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WASI = exports.ensureMemoryFor = void 0;
|
|
4
|
+
const webassembly_1 = require("../webassembly");
|
|
5
|
+
const path_1 = require("./path");
|
|
6
|
+
// Linux fcntl flag bits ↔ Windows libuv flag bits. `pathOpen()` builds
|
|
7
|
+
// `flagsRes` using Linux constants (O_CREAT=0x40, O_EXCL=0x80,
|
|
8
|
+
// O_APPEND=0x400). Windows libuv expects different bits (O_CREAT=0x100,
|
|
9
|
+
// O_EXCL=0x400, O_APPEND=0x8). Without translation,
|
|
10
|
+
// `fs.openSync(path, 0x241 /* L:WRONLY|CREAT|TRUNC */)` is rejected
|
|
11
|
+
// with EINVAL because Linux's 0x40 happens to mean O_TEMPORARY on
|
|
12
|
+
// Windows — and O_TEMPORARY without O_CREAT is invalid.
|
|
13
|
+
const _isWin32Flags = typeof process !== 'undefined' && process.platform === 'win32';
|
|
14
|
+
function _toWinOpenFlags(f) {
|
|
15
|
+
let r = f & 3; // RDONLY/WRONLY/RDWR — same on both
|
|
16
|
+
if ((f & 0x40) !== 0)
|
|
17
|
+
r |= 0x100; // O_CREAT: Linux 0x40 -> Windows 0x100
|
|
18
|
+
if ((f & 0x80) !== 0)
|
|
19
|
+
r |= 0x400; // O_EXCL: Linux 0x80 -> Windows 0x400
|
|
20
|
+
if ((f & 0x200) !== 0)
|
|
21
|
+
r |= 0x200; // O_TRUNC: same value on both
|
|
22
|
+
if ((f & 0x400) !== 0)
|
|
23
|
+
r |= 0x8; // O_APPEND: Linux 0x400 -> Windows 0x8
|
|
24
|
+
return r;
|
|
25
|
+
}
|
|
26
|
+
const types_1 = require("./types");
|
|
27
|
+
const fd_1 = require("./fd");
|
|
28
|
+
const error_1 = require("./error");
|
|
29
|
+
const util_1 = require("./util");
|
|
30
|
+
const rights_1 = require("./rights");
|
|
31
|
+
const memory_1 = require("../memory");
|
|
32
|
+
const jspi_1 = require("../jspi");
|
|
33
|
+
function copyMemory(targets, src) {
|
|
34
|
+
if (targets.length === 0 || src.length === 0)
|
|
35
|
+
return 0;
|
|
36
|
+
let copied = 0;
|
|
37
|
+
let left = src.length - copied;
|
|
38
|
+
for (let i = 0; i < targets.length; ++i) {
|
|
39
|
+
const target = targets[i];
|
|
40
|
+
if (left < target.length) {
|
|
41
|
+
target.set(src.subarray(copied, copied + left), 0);
|
|
42
|
+
copied += left;
|
|
43
|
+
left = 0;
|
|
44
|
+
return copied;
|
|
45
|
+
}
|
|
46
|
+
target.set(src.subarray(copied, copied + target.length), 0);
|
|
47
|
+
copied += target.length;
|
|
48
|
+
left -= target.length;
|
|
49
|
+
}
|
|
50
|
+
return copied;
|
|
51
|
+
}
|
|
52
|
+
const _memory = new WeakMap();
|
|
53
|
+
const _wasi = new WeakMap();
|
|
54
|
+
const _fs = new WeakMap();
|
|
55
|
+
function ensureMemoryFor(memory, end) {
|
|
56
|
+
let buffer = memory.buffer;
|
|
57
|
+
if (end > buffer.byteLength) {
|
|
58
|
+
memory.grow(0);
|
|
59
|
+
buffer = memory.buffer;
|
|
60
|
+
}
|
|
61
|
+
return buffer;
|
|
62
|
+
}
|
|
63
|
+
exports.ensureMemoryFor = ensureMemoryFor;
|
|
64
|
+
function getMemory(wasi, end = 0) {
|
|
65
|
+
const memory = _memory.get(wasi);
|
|
66
|
+
ensureMemoryFor(memory, end);
|
|
67
|
+
return memory;
|
|
68
|
+
}
|
|
69
|
+
function getFs(wasi) {
|
|
70
|
+
const fs = _fs.get(wasi);
|
|
71
|
+
if (!fs)
|
|
72
|
+
throw new Error('filesystem is unavailable');
|
|
73
|
+
return fs;
|
|
74
|
+
}
|
|
75
|
+
function handleError(err) {
|
|
76
|
+
if (err instanceof error_1.WasiError) {
|
|
77
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
78
|
+
console.warn(err);
|
|
79
|
+
}
|
|
80
|
+
return err.errno;
|
|
81
|
+
}
|
|
82
|
+
switch (err.code) {
|
|
83
|
+
case 'ENOENT': return types_1.WasiErrno.ENOENT;
|
|
84
|
+
case 'EBADF': return types_1.WasiErrno.EBADF;
|
|
85
|
+
case 'EINVAL': return types_1.WasiErrno.EINVAL;
|
|
86
|
+
case 'EPERM': return types_1.WasiErrno.EPERM;
|
|
87
|
+
case 'EPROTO': return types_1.WasiErrno.EPROTO;
|
|
88
|
+
case 'EEXIST': return types_1.WasiErrno.EEXIST;
|
|
89
|
+
case 'ENOTDIR': return types_1.WasiErrno.ENOTDIR;
|
|
90
|
+
case 'EMFILE': return types_1.WasiErrno.EMFILE;
|
|
91
|
+
case 'EACCES': return types_1.WasiErrno.EACCES;
|
|
92
|
+
case 'EISDIR': return types_1.WasiErrno.EISDIR;
|
|
93
|
+
case 'ENOTEMPTY': return types_1.WasiErrno.ENOTEMPTY;
|
|
94
|
+
case 'ENOSYS': return types_1.WasiErrno.ENOSYS;
|
|
95
|
+
}
|
|
96
|
+
throw err;
|
|
97
|
+
}
|
|
98
|
+
function defineName(name, f) {
|
|
99
|
+
Object.defineProperty(f, 'name', { value: name });
|
|
100
|
+
return f;
|
|
101
|
+
}
|
|
102
|
+
function tryCall(f, wasi, args) {
|
|
103
|
+
let r;
|
|
104
|
+
try {
|
|
105
|
+
r = f.apply(wasi, args);
|
|
106
|
+
}
|
|
107
|
+
catch (err) {
|
|
108
|
+
return handleError(err);
|
|
109
|
+
}
|
|
110
|
+
if ((0, util_1.isPromiseLike)(r)) {
|
|
111
|
+
return r.then(_ => _, handleError);
|
|
112
|
+
}
|
|
113
|
+
return r;
|
|
114
|
+
}
|
|
115
|
+
function syscallWrap(self, name, f) {
|
|
116
|
+
let debug = false;
|
|
117
|
+
const NODE_DEBUG_NATIVE = (() => {
|
|
118
|
+
try {
|
|
119
|
+
return process.env.NODE_DEBUG_NATIVE;
|
|
120
|
+
}
|
|
121
|
+
catch (_) {
|
|
122
|
+
return undefined;
|
|
123
|
+
}
|
|
124
|
+
})();
|
|
125
|
+
if (typeof NODE_DEBUG_NATIVE === 'string' && NODE_DEBUG_NATIVE.split(',').includes('wasi')) {
|
|
126
|
+
debug = true;
|
|
127
|
+
}
|
|
128
|
+
return debug
|
|
129
|
+
? defineName(name, function () {
|
|
130
|
+
const args = Array.prototype.slice.call(arguments);
|
|
131
|
+
let debugArgs = [`${name}(${Array.from({ length: arguments.length }).map(() => '%d').join(', ')})`];
|
|
132
|
+
debugArgs = debugArgs.concat(args);
|
|
133
|
+
console.debug.apply(console, debugArgs);
|
|
134
|
+
return tryCall(f, self, args);
|
|
135
|
+
})
|
|
136
|
+
: defineName(name, function () {
|
|
137
|
+
return tryCall(f, self, arguments);
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
function resolvePathSync(fs, fileDescriptor, path, flags) {
|
|
141
|
+
let resolvedPath = (0, path_1.resolve)(fileDescriptor.realPath, path);
|
|
142
|
+
if ((flags & 1) === 1) {
|
|
143
|
+
try {
|
|
144
|
+
resolvedPath = fs.readlinkSync(resolvedPath);
|
|
145
|
+
}
|
|
146
|
+
catch (err) {
|
|
147
|
+
if (err.code !== 'EINVAL' && err.code !== 'ENOENT') {
|
|
148
|
+
throw err;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return resolvedPath;
|
|
153
|
+
}
|
|
154
|
+
async function resolvePathAsync(fs, fileDescriptor, path, flags) {
|
|
155
|
+
let resolvedPath = (0, path_1.resolve)(fileDescriptor.realPath, path);
|
|
156
|
+
if ((flags & 1) === 1) {
|
|
157
|
+
try {
|
|
158
|
+
resolvedPath = await fs.promises.readlink(resolvedPath);
|
|
159
|
+
}
|
|
160
|
+
catch (err) {
|
|
161
|
+
if (err.code !== 'EINVAL' && err.code !== 'ENOENT') {
|
|
162
|
+
throw err;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
return resolvedPath;
|
|
167
|
+
}
|
|
168
|
+
// eslint-disable-next-line spaced-comment
|
|
169
|
+
const encoder = /*#__PURE__*/ new TextEncoder();
|
|
170
|
+
// eslint-disable-next-line spaced-comment
|
|
171
|
+
const decoder = /*#__PURE__*/ new TextDecoder();
|
|
172
|
+
const INT64_MAX = (BigInt(1) << BigInt(63)) - BigInt(1);
|
|
173
|
+
function readStdin() {
|
|
174
|
+
const value = window.prompt();
|
|
175
|
+
if (value === null)
|
|
176
|
+
return new Uint8Array();
|
|
177
|
+
const buffer = new TextEncoder().encode(value + '\n');
|
|
178
|
+
return buffer;
|
|
179
|
+
}
|
|
180
|
+
function validateFstFlagsOrReturn(flags) {
|
|
181
|
+
return (Boolean((flags) & ~(types_1.WasiFstFlag.SET_ATIM | types_1.WasiFstFlag.SET_ATIM_NOW |
|
|
182
|
+
types_1.WasiFstFlag.SET_MTIM | types_1.WasiFstFlag.SET_MTIM_NOW)) ||
|
|
183
|
+
((flags) & (types_1.WasiFstFlag.SET_ATIM | types_1.WasiFstFlag.SET_ATIM_NOW)) ===
|
|
184
|
+
(types_1.WasiFstFlag.SET_ATIM | types_1.WasiFstFlag.SET_ATIM_NOW) ||
|
|
185
|
+
((flags) & (types_1.WasiFstFlag.SET_MTIM | types_1.WasiFstFlag.SET_MTIM_NOW)) ===
|
|
186
|
+
(types_1.WasiFstFlag.SET_MTIM | types_1.WasiFstFlag.SET_MTIM_NOW));
|
|
187
|
+
}
|
|
188
|
+
class WASI {
|
|
189
|
+
constructor(args, env, fds, asyncFs, fs, asyncify) {
|
|
190
|
+
this.args_get = syscallWrap(this, 'args_get', function (argv, argv_buf) {
|
|
191
|
+
argv = Number(argv);
|
|
192
|
+
argv_buf = Number(argv_buf);
|
|
193
|
+
if (argv === 0 || argv_buf === 0) {
|
|
194
|
+
return types_1.WasiErrno.EINVAL;
|
|
195
|
+
}
|
|
196
|
+
const wasi = _wasi.get(this);
|
|
197
|
+
const args = wasi.args;
|
|
198
|
+
const argsSize = encoder.encode(args.join('\0') + '\0').length;
|
|
199
|
+
const { HEAPU8, view } = getMemory(this, Math.max(argv + args.length * 4, argv_buf + argsSize));
|
|
200
|
+
for (let i = 0; i < args.length; ++i) {
|
|
201
|
+
const arg = args[i];
|
|
202
|
+
view.setInt32(argv, argv_buf, true);
|
|
203
|
+
argv += 4;
|
|
204
|
+
const data = encoder.encode(arg + '\0');
|
|
205
|
+
HEAPU8.set(data, argv_buf);
|
|
206
|
+
argv_buf += data.length;
|
|
207
|
+
}
|
|
208
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
209
|
+
});
|
|
210
|
+
this.args_sizes_get = syscallWrap(this, 'args_sizes_get', function (argc, argv_buf_size) {
|
|
211
|
+
argc = Number(argc);
|
|
212
|
+
argv_buf_size = Number(argv_buf_size);
|
|
213
|
+
if (argc === 0 || argv_buf_size === 0) {
|
|
214
|
+
return types_1.WasiErrno.EINVAL;
|
|
215
|
+
}
|
|
216
|
+
const { view } = getMemory(this, Math.max(argc + 4, argv_buf_size + 4));
|
|
217
|
+
const wasi = _wasi.get(this);
|
|
218
|
+
const args = wasi.args;
|
|
219
|
+
view.setUint32(argc, args.length, true);
|
|
220
|
+
view.setUint32(argv_buf_size, encoder.encode(args.join('\0') + '\0').length, true);
|
|
221
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
222
|
+
});
|
|
223
|
+
this.environ_get = syscallWrap(this, 'environ_get', function (environ, environ_buf) {
|
|
224
|
+
environ = Number(environ);
|
|
225
|
+
environ_buf = Number(environ_buf);
|
|
226
|
+
if (environ === 0 || environ_buf === 0) {
|
|
227
|
+
return types_1.WasiErrno.EINVAL;
|
|
228
|
+
}
|
|
229
|
+
const wasi = _wasi.get(this);
|
|
230
|
+
const env = wasi.env;
|
|
231
|
+
const envSize = encoder.encode(env.join('\0') + '\0').length;
|
|
232
|
+
const { HEAPU8, view } = getMemory(this, Math.max(environ + env.length * 4, environ_buf + envSize));
|
|
233
|
+
for (let i = 0; i < env.length; ++i) {
|
|
234
|
+
const pair = env[i];
|
|
235
|
+
view.setInt32(environ, environ_buf, true);
|
|
236
|
+
environ += 4;
|
|
237
|
+
const data = encoder.encode(pair + '\0');
|
|
238
|
+
HEAPU8.set(data, environ_buf);
|
|
239
|
+
environ_buf += data.length;
|
|
240
|
+
}
|
|
241
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
242
|
+
});
|
|
243
|
+
this.environ_sizes_get = syscallWrap(this, 'environ_sizes_get', function (len, buflen) {
|
|
244
|
+
len = Number(len);
|
|
245
|
+
buflen = Number(buflen);
|
|
246
|
+
if (len === 0 || buflen === 0) {
|
|
247
|
+
return types_1.WasiErrno.EINVAL;
|
|
248
|
+
}
|
|
249
|
+
const { view } = getMemory(this, Math.max(len + 4, buflen + 4));
|
|
250
|
+
const wasi = _wasi.get(this);
|
|
251
|
+
view.setUint32(len, wasi.env.length, true);
|
|
252
|
+
view.setUint32(buflen, encoder.encode(wasi.env.join('\0') + '\0').length, true);
|
|
253
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
254
|
+
});
|
|
255
|
+
this.clock_res_get = syscallWrap(this, 'clock_res_get', function (id, resolution) {
|
|
256
|
+
resolution = Number(resolution);
|
|
257
|
+
if (resolution === 0) {
|
|
258
|
+
return types_1.WasiErrno.EINVAL;
|
|
259
|
+
}
|
|
260
|
+
const { view } = getMemory(this, resolution + 8);
|
|
261
|
+
switch (id) {
|
|
262
|
+
case types_1.WasiClockid.REALTIME:
|
|
263
|
+
view.setBigUint64(resolution, BigInt(1000000), true);
|
|
264
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
265
|
+
case types_1.WasiClockid.MONOTONIC:
|
|
266
|
+
case types_1.WasiClockid.PROCESS_CPUTIME_ID:
|
|
267
|
+
case types_1.WasiClockid.THREAD_CPUTIME_ID:
|
|
268
|
+
view.setBigUint64(resolution, BigInt(1000), true);
|
|
269
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
270
|
+
default: return types_1.WasiErrno.EINVAL;
|
|
271
|
+
}
|
|
272
|
+
});
|
|
273
|
+
this.clock_time_get = syscallWrap(this, 'clock_time_get', function (id, _percision, time) {
|
|
274
|
+
time = Number(time);
|
|
275
|
+
if (time === 0) {
|
|
276
|
+
return types_1.WasiErrno.EINVAL;
|
|
277
|
+
}
|
|
278
|
+
const { view } = getMemory(this, time + 8);
|
|
279
|
+
switch (id) {
|
|
280
|
+
case types_1.WasiClockid.REALTIME:
|
|
281
|
+
view.setBigUint64(time, BigInt(Date.now()) * BigInt(1000000), true);
|
|
282
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
283
|
+
case types_1.WasiClockid.MONOTONIC:
|
|
284
|
+
case types_1.WasiClockid.PROCESS_CPUTIME_ID:
|
|
285
|
+
case types_1.WasiClockid.THREAD_CPUTIME_ID: {
|
|
286
|
+
const t = performance.now() / 1000;
|
|
287
|
+
const s = Math.trunc(t);
|
|
288
|
+
const ms = Math.floor((t - s) * 1000);
|
|
289
|
+
const result = BigInt(s) * BigInt(1000000000) + BigInt(ms) * BigInt(1000000);
|
|
290
|
+
view.setBigUint64(time, result, true);
|
|
291
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
292
|
+
}
|
|
293
|
+
default: return types_1.WasiErrno.EINVAL;
|
|
294
|
+
}
|
|
295
|
+
});
|
|
296
|
+
this.fd_advise = syscallWrap(this, 'fd_advise', function (_fd, _offset, _len, _advice) {
|
|
297
|
+
return types_1.WasiErrno.ENOSYS;
|
|
298
|
+
});
|
|
299
|
+
this.fd_fdstat_get = syscallWrap(this, 'fd_fdstat_get', function (fd, fdstat) {
|
|
300
|
+
fdstat = Number(fdstat);
|
|
301
|
+
if (fdstat === 0) {
|
|
302
|
+
return types_1.WasiErrno.EINVAL;
|
|
303
|
+
}
|
|
304
|
+
const wasi = _wasi.get(this);
|
|
305
|
+
const fileDescriptor = wasi.fds.get(fd, BigInt(0), BigInt(0));
|
|
306
|
+
const { view } = getMemory(this, fdstat + 24);
|
|
307
|
+
view.setUint16(fdstat, fileDescriptor.type, true);
|
|
308
|
+
view.setUint16(fdstat + 2, 0, true);
|
|
309
|
+
view.setBigUint64(fdstat + 8, fileDescriptor.rightsBase, true);
|
|
310
|
+
view.setBigUint64(fdstat + 16, fileDescriptor.rightsInheriting, true);
|
|
311
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
312
|
+
});
|
|
313
|
+
this.fd_fdstat_set_flags = syscallWrap(this, 'fd_fdstat_set_flags', function (_fd, _flags) {
|
|
314
|
+
return types_1.WasiErrno.ENOSYS;
|
|
315
|
+
});
|
|
316
|
+
this.fd_fdstat_set_rights = syscallWrap(this, 'fd_fdstat_set_rights', function (fd, rightsBase, rightsInheriting) {
|
|
317
|
+
const wasi = _wasi.get(this);
|
|
318
|
+
const fileDescriptor = wasi.fds.get(fd, BigInt(0), BigInt(0));
|
|
319
|
+
if ((rightsBase | fileDescriptor.rightsBase) > fileDescriptor.rightsBase) {
|
|
320
|
+
return types_1.WasiErrno.ENOTCAPABLE;
|
|
321
|
+
}
|
|
322
|
+
if ((rightsInheriting | fileDescriptor.rightsInheriting) >
|
|
323
|
+
fileDescriptor.rightsInheriting) {
|
|
324
|
+
return types_1.WasiErrno.ENOTCAPABLE;
|
|
325
|
+
}
|
|
326
|
+
fileDescriptor.rightsBase = rightsBase;
|
|
327
|
+
fileDescriptor.rightsInheriting = rightsInheriting;
|
|
328
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
329
|
+
});
|
|
330
|
+
this.fd_prestat_get = syscallWrap(this, 'fd_prestat_get', function (fd, prestat) {
|
|
331
|
+
prestat = Number(prestat);
|
|
332
|
+
if (prestat === 0) {
|
|
333
|
+
return types_1.WasiErrno.EINVAL;
|
|
334
|
+
}
|
|
335
|
+
const wasi = _wasi.get(this);
|
|
336
|
+
let fileDescriptor;
|
|
337
|
+
try {
|
|
338
|
+
fileDescriptor = wasi.fds.get(fd, BigInt(0), BigInt(0));
|
|
339
|
+
}
|
|
340
|
+
catch (err) {
|
|
341
|
+
if (err instanceof error_1.WasiError)
|
|
342
|
+
return err.errno;
|
|
343
|
+
throw err;
|
|
344
|
+
}
|
|
345
|
+
if (fileDescriptor.preopen !== 1)
|
|
346
|
+
return types_1.WasiErrno.EINVAL;
|
|
347
|
+
const { view } = getMemory(this, prestat + 8);
|
|
348
|
+
// preopen type is dir(0)
|
|
349
|
+
view.setUint32(prestat, 0, true);
|
|
350
|
+
view.setUint32(prestat + 4, encoder.encode(fileDescriptor.path).length, true);
|
|
351
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
352
|
+
});
|
|
353
|
+
this.fd_prestat_dir_name = syscallWrap(this, 'fd_prestat_dir_name', function (fd, path, path_len) {
|
|
354
|
+
path = Number(path);
|
|
355
|
+
path_len = Number(path_len);
|
|
356
|
+
if (path === 0) {
|
|
357
|
+
return types_1.WasiErrno.EINVAL;
|
|
358
|
+
}
|
|
359
|
+
const wasi = _wasi.get(this);
|
|
360
|
+
const fileDescriptor = wasi.fds.get(fd, BigInt(0), BigInt(0));
|
|
361
|
+
if (fileDescriptor.preopen !== 1)
|
|
362
|
+
return types_1.WasiErrno.EBADF;
|
|
363
|
+
const buffer = encoder.encode(fileDescriptor.path);
|
|
364
|
+
const size = buffer.length;
|
|
365
|
+
if (size > path_len)
|
|
366
|
+
return types_1.WasiErrno.ENOBUFS;
|
|
367
|
+
const { HEAPU8 } = getMemory(this, path + size);
|
|
368
|
+
HEAPU8.set(buffer, path);
|
|
369
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
370
|
+
});
|
|
371
|
+
this.fd_seek = syscallWrap(this, 'fd_seek', function (fd, offset, whence, newOffset) {
|
|
372
|
+
newOffset = Number(newOffset);
|
|
373
|
+
if (newOffset === 0) {
|
|
374
|
+
return types_1.WasiErrno.EINVAL;
|
|
375
|
+
}
|
|
376
|
+
if (fd === 0 || fd === 1 || fd === 2)
|
|
377
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
378
|
+
const wasi = _wasi.get(this);
|
|
379
|
+
const fileDescriptor = wasi.fds.get(fd, types_1.WasiRights.FD_SEEK, BigInt(0));
|
|
380
|
+
const r = fileDescriptor.seek(offset, whence);
|
|
381
|
+
const { view } = getMemory(this, newOffset + 8);
|
|
382
|
+
view.setBigUint64(newOffset, r, true);
|
|
383
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
384
|
+
});
|
|
385
|
+
this.fd_tell = syscallWrap(this, 'fd_tell', function (fd, offset) {
|
|
386
|
+
const wasi = _wasi.get(this);
|
|
387
|
+
const fileDescriptor = wasi.fds.get(fd, types_1.WasiRights.FD_TELL, BigInt(0));
|
|
388
|
+
const pos = BigInt(fileDescriptor.pos);
|
|
389
|
+
const { view } = getMemory(this, Number(offset) + 8);
|
|
390
|
+
view.setBigUint64(Number(offset), pos, true);
|
|
391
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
392
|
+
});
|
|
393
|
+
this.poll_oneoff = syscallWrap(this, 'poll_oneoff', function (in_ptr, out_ptr, nsubscriptions, nevents) {
|
|
394
|
+
in_ptr = Number(in_ptr);
|
|
395
|
+
out_ptr = Number(out_ptr);
|
|
396
|
+
nevents = Number(nevents);
|
|
397
|
+
nsubscriptions = Number(nsubscriptions);
|
|
398
|
+
nsubscriptions = nsubscriptions >>> 0;
|
|
399
|
+
if (in_ptr === 0 || out_ptr === 0 || nsubscriptions === 0 || nevents === 0) {
|
|
400
|
+
return types_1.WasiErrno.EINVAL;
|
|
401
|
+
}
|
|
402
|
+
const { view } = getMemory(this, Math.max(in_ptr + nsubscriptions * 48, out_ptr + nsubscriptions * 32, nevents + 4));
|
|
403
|
+
view.setUint32(nevents, 0, true);
|
|
404
|
+
let i = 0;
|
|
405
|
+
let timer_userdata = BigInt(0);
|
|
406
|
+
let cur_timeout = BigInt(0);
|
|
407
|
+
let has_timeout = 0;
|
|
408
|
+
let min_timeout = BigInt(0);
|
|
409
|
+
let sub;
|
|
410
|
+
const subscriptions = Array(nsubscriptions);
|
|
411
|
+
for (i = 0; i < nsubscriptions; i++) {
|
|
412
|
+
sub = in_ptr + i * 48;
|
|
413
|
+
const userdata = view.getBigUint64(sub, true);
|
|
414
|
+
const type = view.getUint8(sub + 8);
|
|
415
|
+
const clockIdOrFd = view.getUint32(sub + 16, true);
|
|
416
|
+
const timeout = view.getBigUint64(sub + 24, true);
|
|
417
|
+
const precision = view.getBigUint64(sub + 32, true);
|
|
418
|
+
const flags = view.getUint16(sub + 40, true);
|
|
419
|
+
subscriptions[i] = {
|
|
420
|
+
userdata,
|
|
421
|
+
type,
|
|
422
|
+
u: {
|
|
423
|
+
clock: {
|
|
424
|
+
clock_id: clockIdOrFd,
|
|
425
|
+
timeout,
|
|
426
|
+
precision,
|
|
427
|
+
flags
|
|
428
|
+
},
|
|
429
|
+
fd_readwrite: {
|
|
430
|
+
fd: clockIdOrFd
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
};
|
|
434
|
+
}
|
|
435
|
+
const fdevents = [];
|
|
436
|
+
for (i = 0; i < nsubscriptions; i++) {
|
|
437
|
+
sub = subscriptions[i];
|
|
438
|
+
switch (sub.type) {
|
|
439
|
+
case types_1.WasiEventType.CLOCK: {
|
|
440
|
+
if (sub.u.clock.flags === types_1.WasiSubclockflags.ABSTIME) {
|
|
441
|
+
/* Convert absolute time to relative delay. */
|
|
442
|
+
const now = BigInt(Date.now()) * BigInt(1000000);
|
|
443
|
+
cur_timeout = sub.u.clock.timeout - now;
|
|
444
|
+
}
|
|
445
|
+
else {
|
|
446
|
+
cur_timeout = sub.u.clock.timeout;
|
|
447
|
+
}
|
|
448
|
+
if (has_timeout === 0 || cur_timeout < min_timeout) {
|
|
449
|
+
min_timeout = cur_timeout;
|
|
450
|
+
timer_userdata = sub.userdata;
|
|
451
|
+
has_timeout = 1;
|
|
452
|
+
}
|
|
453
|
+
break;
|
|
454
|
+
}
|
|
455
|
+
case types_1.WasiEventType.FD_READ:
|
|
456
|
+
case types_1.WasiEventType.FD_WRITE:
|
|
457
|
+
fdevents.push(sub);
|
|
458
|
+
break;
|
|
459
|
+
default: return types_1.WasiErrno.EINVAL;
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
if (fdevents.length > 0) {
|
|
463
|
+
for (i = 0; i < fdevents.length; i++) {
|
|
464
|
+
const fdevent = fdevents[i];
|
|
465
|
+
const event = out_ptr + 32 * i;
|
|
466
|
+
view.setBigUint64(event, fdevent.userdata, true);
|
|
467
|
+
view.setUint32(event + 8, types_1.WasiErrno.ENOSYS, true);
|
|
468
|
+
view.setUint32(event + 12, fdevent.type, true);
|
|
469
|
+
view.setBigUint64(event + 16, BigInt(0), true);
|
|
470
|
+
view.setUint16(event + 24, 0, true);
|
|
471
|
+
view.setUint32(nevents, 1, true);
|
|
472
|
+
}
|
|
473
|
+
view.setUint32(nevents, fdevents.length, true);
|
|
474
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
475
|
+
}
|
|
476
|
+
if (has_timeout) {
|
|
477
|
+
const delay = Number(min_timeout / BigInt(1000000));
|
|
478
|
+
// if (isMainThread || typeof SharedArrayBuffer !== 'function') {
|
|
479
|
+
(0, util_1.sleepBreakIf)(delay, () => false);
|
|
480
|
+
// } else {
|
|
481
|
+
// const buf = new SharedArrayBuffer(4)
|
|
482
|
+
// const arr = new Int32Array(buf)
|
|
483
|
+
// postMsg({
|
|
484
|
+
// __tybys_wasm_util_wasi__: {
|
|
485
|
+
// type: 'set-timeout',
|
|
486
|
+
// payload: {
|
|
487
|
+
// buffer: buf,
|
|
488
|
+
// delay
|
|
489
|
+
// }
|
|
490
|
+
// }
|
|
491
|
+
// })
|
|
492
|
+
// Atomics.wait(arr, 0, 0)
|
|
493
|
+
// }
|
|
494
|
+
const event = out_ptr;
|
|
495
|
+
view.setBigUint64(event, timer_userdata, true);
|
|
496
|
+
view.setUint32(event + 8, types_1.WasiErrno.ESUCCESS, true);
|
|
497
|
+
view.setUint32(event + 12, types_1.WasiEventType.CLOCK, true);
|
|
498
|
+
view.setUint32(nevents, 1, true);
|
|
499
|
+
}
|
|
500
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
501
|
+
});
|
|
502
|
+
this.proc_exit = syscallWrap(this, 'proc_exit', function (rval) {
|
|
503
|
+
if ((typeof process === 'object') && (process !== null) && (typeof process.exit === 'function')) {
|
|
504
|
+
process.exit(rval);
|
|
505
|
+
}
|
|
506
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
507
|
+
});
|
|
508
|
+
this.proc_raise = syscallWrap(this, 'proc_raise', function (_sig) {
|
|
509
|
+
return types_1.WasiErrno.ENOSYS;
|
|
510
|
+
});
|
|
511
|
+
this.sched_yield = syscallWrap(this, 'sched_yield', function () {
|
|
512
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
513
|
+
});
|
|
514
|
+
this.random_get = typeof crypto !== 'undefined' && typeof crypto.getRandomValues === 'function'
|
|
515
|
+
? syscallWrap(this, 'random_get', function (buf, buf_len) {
|
|
516
|
+
buf = Number(buf);
|
|
517
|
+
if (buf === 0) {
|
|
518
|
+
return types_1.WasiErrno.EINVAL;
|
|
519
|
+
}
|
|
520
|
+
buf_len = Number(buf_len);
|
|
521
|
+
const { HEAPU8, view } = getMemory(this, buf + buf_len);
|
|
522
|
+
if ((typeof SharedArrayBuffer === 'function' && HEAPU8.buffer instanceof SharedArrayBuffer) ||
|
|
523
|
+
(Object.prototype.toString.call(HEAPU8.buffer) === '[object SharedArrayBuffer]')) {
|
|
524
|
+
for (let i = buf; i < buf + buf_len; ++i) {
|
|
525
|
+
view.setUint8(i, Math.floor(Math.random() * 256));
|
|
526
|
+
}
|
|
527
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
528
|
+
}
|
|
529
|
+
let pos;
|
|
530
|
+
const stride = 65536;
|
|
531
|
+
for (pos = 0; pos + stride < buf_len; pos += stride) {
|
|
532
|
+
crypto.getRandomValues(HEAPU8.subarray(buf + pos, buf + pos + stride));
|
|
533
|
+
}
|
|
534
|
+
crypto.getRandomValues(HEAPU8.subarray(buf + pos, buf + buf_len));
|
|
535
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
536
|
+
})
|
|
537
|
+
: syscallWrap(this, 'random_get', function (buf, buf_len) {
|
|
538
|
+
buf = Number(buf);
|
|
539
|
+
if (buf === 0) {
|
|
540
|
+
return types_1.WasiErrno.EINVAL;
|
|
541
|
+
}
|
|
542
|
+
buf_len = Number(buf_len);
|
|
543
|
+
const { view } = getMemory(this, buf + buf_len);
|
|
544
|
+
for (let i = buf; i < buf + buf_len; ++i) {
|
|
545
|
+
view.setUint8(i, Math.floor(Math.random() * 256));
|
|
546
|
+
}
|
|
547
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
548
|
+
});
|
|
549
|
+
this.sock_recv = syscallWrap(this, 'sock_recv', function () {
|
|
550
|
+
return types_1.WasiErrno.ENOTSUP;
|
|
551
|
+
});
|
|
552
|
+
this.sock_send = syscallWrap(this, 'sock_send', function () {
|
|
553
|
+
return types_1.WasiErrno.ENOTSUP;
|
|
554
|
+
});
|
|
555
|
+
this.sock_shutdown = syscallWrap(this, 'sock_shutdown', function () {
|
|
556
|
+
return types_1.WasiErrno.ENOTSUP;
|
|
557
|
+
});
|
|
558
|
+
this.sock_accept = syscallWrap(this, 'sock_accept', function () {
|
|
559
|
+
return types_1.WasiErrno.ENOTSUP;
|
|
560
|
+
});
|
|
561
|
+
_wasi.set(this, {
|
|
562
|
+
fds,
|
|
563
|
+
args,
|
|
564
|
+
env
|
|
565
|
+
});
|
|
566
|
+
if (fs)
|
|
567
|
+
_fs.set(this, fs);
|
|
568
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
569
|
+
const _this = this;
|
|
570
|
+
function defineImport(name, syncVersion, asyncVersion, parameterType, returnType) {
|
|
571
|
+
if (asyncFs) {
|
|
572
|
+
if (asyncify) {
|
|
573
|
+
_this[name] = asyncify.wrapImportFunction(syscallWrap(_this, name, asyncVersion));
|
|
574
|
+
}
|
|
575
|
+
else {
|
|
576
|
+
_this[name] = (0, jspi_1.wrapAsyncImport)(syscallWrap(_this, name, asyncVersion), parameterType, returnType);
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
else {
|
|
580
|
+
_this[name] = syscallWrap(_this, name, syncVersion);
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
defineImport('fd_allocate', function fd_allocate(fd, offset, len) {
|
|
584
|
+
const wasi = _wasi.get(this);
|
|
585
|
+
const fs = getFs(this);
|
|
586
|
+
const fileDescriptor = wasi.fds.get(fd, types_1.WasiRights.FD_ALLOCATE, BigInt(0));
|
|
587
|
+
const stat = fs.fstatSync(fileDescriptor.fd, { bigint: true });
|
|
588
|
+
if (stat.size < offset + len) {
|
|
589
|
+
fs.ftruncateSync(fileDescriptor.fd, Number(offset + len));
|
|
590
|
+
}
|
|
591
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
592
|
+
}, async function fd_allocate(fd, offset, len) {
|
|
593
|
+
const wasi = _wasi.get(this);
|
|
594
|
+
const fileDescriptor = wasi.fds.get(fd, types_1.WasiRights.FD_ALLOCATE, BigInt(0));
|
|
595
|
+
const h = fileDescriptor.fd;
|
|
596
|
+
const stat = await h.stat({ bigint: true });
|
|
597
|
+
if (stat.size < offset + len) {
|
|
598
|
+
await h.truncate(Number(offset + len));
|
|
599
|
+
}
|
|
600
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
601
|
+
}, ['i32', 'i64', 'f64'], ['i32']);
|
|
602
|
+
defineImport('fd_close', function fd_close(fd) {
|
|
603
|
+
const wasi = _wasi.get(this);
|
|
604
|
+
const fileDescriptor = wasi.fds.get(fd, BigInt(0), BigInt(0));
|
|
605
|
+
const fs = getFs(this);
|
|
606
|
+
fs.closeSync(fileDescriptor.fd);
|
|
607
|
+
wasi.fds.remove(fd);
|
|
608
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
609
|
+
}, async function fd_close(fd) {
|
|
610
|
+
const wasi = _wasi.get(this);
|
|
611
|
+
const fileDescriptor = wasi.fds.get(fd, BigInt(0), BigInt(0));
|
|
612
|
+
await fileDescriptor.fd.close();
|
|
613
|
+
wasi.fds.remove(fd);
|
|
614
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
615
|
+
}, ['i32'], ['i32']);
|
|
616
|
+
defineImport('fd_datasync', function fd_datasync(fd) {
|
|
617
|
+
const wasi = _wasi.get(this);
|
|
618
|
+
const fileDescriptor = wasi.fds.get(fd, types_1.WasiRights.FD_DATASYNC, BigInt(0));
|
|
619
|
+
const fs = getFs(this);
|
|
620
|
+
fs.fdatasyncSync(fileDescriptor.fd);
|
|
621
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
622
|
+
}, async function fd_datasync(fd) {
|
|
623
|
+
const wasi = _wasi.get(this);
|
|
624
|
+
const fileDescriptor = wasi.fds.get(fd, types_1.WasiRights.FD_DATASYNC, BigInt(0));
|
|
625
|
+
await fileDescriptor.fd.datasync();
|
|
626
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
627
|
+
}, ['i32'], ['i32']);
|
|
628
|
+
defineImport('fd_filestat_get', function fd_filestat_get(fd, buf) {
|
|
629
|
+
buf = Number(buf);
|
|
630
|
+
if (buf === 0)
|
|
631
|
+
return types_1.WasiErrno.EINVAL;
|
|
632
|
+
const wasi = _wasi.get(this);
|
|
633
|
+
const fileDescriptor = wasi.fds.get(fd, types_1.WasiRights.FD_FILESTAT_GET, BigInt(0));
|
|
634
|
+
const fs = getFs(this);
|
|
635
|
+
const stat = fs.fstatSync(fileDescriptor.fd, { bigint: true });
|
|
636
|
+
const { view } = getMemory(this, buf + 64);
|
|
637
|
+
(0, fd_1.toFileStat)(view, buf, stat);
|
|
638
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
639
|
+
}, async function fd_filestat_get(fd, buf) {
|
|
640
|
+
buf = Number(buf);
|
|
641
|
+
if (buf === 0)
|
|
642
|
+
return types_1.WasiErrno.EINVAL;
|
|
643
|
+
const wasi = _wasi.get(this);
|
|
644
|
+
const fileDescriptor = wasi.fds.get(fd, types_1.WasiRights.FD_FILESTAT_GET, BigInt(0));
|
|
645
|
+
const h = fileDescriptor.fd;
|
|
646
|
+
const stat = await h.stat({ bigint: true });
|
|
647
|
+
const { view } = getMemory(this, buf + 64);
|
|
648
|
+
(0, fd_1.toFileStat)(view, buf, stat);
|
|
649
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
650
|
+
}, ['i32', 'i32'], ['i32']);
|
|
651
|
+
defineImport('fd_filestat_set_size', function fd_filestat_set_size(fd, size) {
|
|
652
|
+
const wasi = _wasi.get(this);
|
|
653
|
+
const fileDescriptor = wasi.fds.get(fd, types_1.WasiRights.FD_FILESTAT_SET_SIZE, BigInt(0));
|
|
654
|
+
const fs = getFs(this);
|
|
655
|
+
fs.ftruncateSync(fileDescriptor.fd, Number(size));
|
|
656
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
657
|
+
}, async function fd_filestat_set_size(fd, size) {
|
|
658
|
+
const wasi = _wasi.get(this);
|
|
659
|
+
const fileDescriptor = wasi.fds.get(fd, types_1.WasiRights.FD_FILESTAT_SET_SIZE, BigInt(0));
|
|
660
|
+
const h = fileDescriptor.fd;
|
|
661
|
+
await h.truncate(Number(size));
|
|
662
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
663
|
+
}, ['i32', 'i64'], ['i32']);
|
|
664
|
+
function fdFilestatGetTimes(fd, atim, mtim, flags) {
|
|
665
|
+
const wasi = _wasi.get(this);
|
|
666
|
+
const fileDescriptor = wasi.fds.get(fd, types_1.WasiRights.FD_FILESTAT_SET_TIMES, BigInt(0));
|
|
667
|
+
if ((flags & types_1.WasiFstFlag.SET_ATIM_NOW) === types_1.WasiFstFlag.SET_ATIM_NOW) {
|
|
668
|
+
atim = BigInt(Date.now() * 1000000);
|
|
669
|
+
}
|
|
670
|
+
if ((flags & types_1.WasiFstFlag.SET_MTIM_NOW) === types_1.WasiFstFlag.SET_MTIM_NOW) {
|
|
671
|
+
mtim = BigInt(Date.now() * 1000000);
|
|
672
|
+
}
|
|
673
|
+
return { fileDescriptor, atim, mtim };
|
|
674
|
+
}
|
|
675
|
+
defineImport('fd_filestat_set_times', function fd_filestat_set_times(fd, atim, mtim, flags) {
|
|
676
|
+
if (validateFstFlagsOrReturn(flags)) {
|
|
677
|
+
return types_1.WasiErrno.EINVAL;
|
|
678
|
+
}
|
|
679
|
+
const { fileDescriptor, atim: atimRes, mtim: mtimRes } = fdFilestatGetTimes.call(this, fd, atim, mtim, flags);
|
|
680
|
+
const fs = getFs(this);
|
|
681
|
+
fs.futimesSync(fileDescriptor.fd, Number(atimRes), Number(mtimRes));
|
|
682
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
683
|
+
}, async function fd_filestat_set_times(fd, atim, mtim, flags) {
|
|
684
|
+
if (validateFstFlagsOrReturn(flags)) {
|
|
685
|
+
return types_1.WasiErrno.EINVAL;
|
|
686
|
+
}
|
|
687
|
+
const { fileDescriptor, atim: atimRes, mtim: mtimRes } = fdFilestatGetTimes.call(this, fd, atim, mtim, flags);
|
|
688
|
+
const h = fileDescriptor.fd;
|
|
689
|
+
await h.utimes(Number(atimRes), Number(mtimRes));
|
|
690
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
691
|
+
}, ['i32', 'i64', 'i64', 'i32'], ['i32']);
|
|
692
|
+
defineImport('fd_pread', function fd_pread(fd, iovs, iovslen, offset, size) {
|
|
693
|
+
iovs = Number(iovs);
|
|
694
|
+
size = Number(size);
|
|
695
|
+
if ((iovs === 0 && iovslen) || size === 0 || offset > INT64_MAX) {
|
|
696
|
+
return types_1.WasiErrno.EINVAL;
|
|
697
|
+
}
|
|
698
|
+
const { HEAPU8, view } = getMemory(this, Math.max(iovs + Number(iovslen) * 8, size + 4));
|
|
699
|
+
const wasi = _wasi.get(this);
|
|
700
|
+
const fileDescriptor = wasi.fds.get(fd, types_1.WasiRights.FD_READ | types_1.WasiRights.FD_SEEK, BigInt(0));
|
|
701
|
+
if (!iovslen) {
|
|
702
|
+
view.setUint32(size, 0, true);
|
|
703
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
704
|
+
}
|
|
705
|
+
let totalSize = 0;
|
|
706
|
+
const ioVecs = Array.from({ length: Number(iovslen) }, (_, i) => {
|
|
707
|
+
const offset = iovs + (i * 8);
|
|
708
|
+
const buf = view.getInt32(offset, true);
|
|
709
|
+
const bufLen = view.getUint32(offset + 4, true);
|
|
710
|
+
totalSize += bufLen;
|
|
711
|
+
return HEAPU8.subarray(buf, buf + bufLen);
|
|
712
|
+
});
|
|
713
|
+
let nread = 0;
|
|
714
|
+
const buffer = (() => {
|
|
715
|
+
try {
|
|
716
|
+
return new Uint8Array(new SharedArrayBuffer(totalSize));
|
|
717
|
+
}
|
|
718
|
+
catch (_) {
|
|
719
|
+
return new Uint8Array(totalSize);
|
|
720
|
+
}
|
|
721
|
+
})();
|
|
722
|
+
buffer._isBuffer = true;
|
|
723
|
+
const fs = getFs(this);
|
|
724
|
+
const bytesRead = fs.readSync(fileDescriptor.fd, buffer, 0, buffer.length, Number(offset));
|
|
725
|
+
nread = buffer ? copyMemory(ioVecs, buffer.subarray(0, bytesRead)) : 0;
|
|
726
|
+
view.setUint32(size, nread, true);
|
|
727
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
728
|
+
}, async function (fd, iovs, iovslen, offset, size) {
|
|
729
|
+
iovs = Number(iovs);
|
|
730
|
+
size = Number(size);
|
|
731
|
+
if ((iovs === 0 && iovslen) || size === 0 || offset > INT64_MAX) {
|
|
732
|
+
return types_1.WasiErrno.EINVAL;
|
|
733
|
+
}
|
|
734
|
+
const { HEAPU8, view } = getMemory(this, Math.max(iovs + Number(iovslen) * 8, size + 4));
|
|
735
|
+
const wasi = _wasi.get(this);
|
|
736
|
+
const fileDescriptor = wasi.fds.get(fd, types_1.WasiRights.FD_READ | types_1.WasiRights.FD_SEEK, BigInt(0));
|
|
737
|
+
if (!iovslen) {
|
|
738
|
+
view.setUint32(size, 0, true);
|
|
739
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
740
|
+
}
|
|
741
|
+
let totalSize = 0;
|
|
742
|
+
const ioVecs = Array.from({ length: Number(iovslen) }, (_, i) => {
|
|
743
|
+
const offset = iovs + (i * 8);
|
|
744
|
+
const buf = view.getInt32(offset, true);
|
|
745
|
+
const bufLen = view.getUint32(offset + 4, true);
|
|
746
|
+
totalSize += bufLen;
|
|
747
|
+
return HEAPU8.subarray(buf, buf + bufLen);
|
|
748
|
+
});
|
|
749
|
+
let nread = 0;
|
|
750
|
+
const buffer = new Uint8Array(totalSize);
|
|
751
|
+
buffer._isBuffer = true;
|
|
752
|
+
const { bytesRead } = await fileDescriptor.fd.read(buffer, 0, buffer.length, Number(offset));
|
|
753
|
+
nread = buffer ? copyMemory(ioVecs, buffer.subarray(0, bytesRead)) : 0;
|
|
754
|
+
view.setUint32(size, nread, true);
|
|
755
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
756
|
+
}, ['i32', 'i32', 'i32', 'i64', 'i32'], ['i32']);
|
|
757
|
+
defineImport('fd_pwrite', function fd_pwrite(fd, iovs, iovslen, offset, size) {
|
|
758
|
+
iovs = Number(iovs);
|
|
759
|
+
size = Number(size);
|
|
760
|
+
if ((iovs === 0 && iovslen) || size === 0 || offset > INT64_MAX) {
|
|
761
|
+
return types_1.WasiErrno.EINVAL;
|
|
762
|
+
}
|
|
763
|
+
const { HEAPU8, view } = getMemory(this, Math.max(iovs + Number(iovslen) * 8, size + 4));
|
|
764
|
+
const wasi = _wasi.get(this);
|
|
765
|
+
const fileDescriptor = wasi.fds.get(fd, types_1.WasiRights.FD_WRITE | types_1.WasiRights.FD_SEEK, BigInt(0));
|
|
766
|
+
if (!iovslen) {
|
|
767
|
+
view.setUint32(size, 0, true);
|
|
768
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
769
|
+
}
|
|
770
|
+
const buffer = (0, fd_1.concatBuffer)(Array.from({ length: Number(iovslen) }, (_, i) => {
|
|
771
|
+
const offset = iovs + (i * 8);
|
|
772
|
+
const buf = view.getInt32(offset, true);
|
|
773
|
+
const bufLen = view.getUint32(offset + 4, true);
|
|
774
|
+
return HEAPU8.subarray(buf, buf + bufLen);
|
|
775
|
+
}));
|
|
776
|
+
const fs = getFs(this);
|
|
777
|
+
const nwritten = fs.writeSync(fileDescriptor.fd, buffer, 0, buffer.length, Number(offset));
|
|
778
|
+
view.setUint32(size, nwritten, true);
|
|
779
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
780
|
+
}, async function fd_pwrite(fd, iovs, iovslen, offset, size) {
|
|
781
|
+
iovs = Number(iovs);
|
|
782
|
+
size = Number(size);
|
|
783
|
+
if ((iovs === 0 && iovslen) || size === 0 || offset > INT64_MAX) {
|
|
784
|
+
return types_1.WasiErrno.EINVAL;
|
|
785
|
+
}
|
|
786
|
+
const { HEAPU8, view } = getMemory(this, Math.max(iovs + Number(iovslen) * 8, size + 4));
|
|
787
|
+
const wasi = _wasi.get(this);
|
|
788
|
+
const fileDescriptor = wasi.fds.get(fd, types_1.WasiRights.FD_WRITE | types_1.WasiRights.FD_SEEK, BigInt(0));
|
|
789
|
+
if (!iovslen) {
|
|
790
|
+
view.setUint32(size, 0, true);
|
|
791
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
792
|
+
}
|
|
793
|
+
const buffer = (0, fd_1.concatBuffer)(Array.from({ length: Number(iovslen) }, (_, i) => {
|
|
794
|
+
const offset = iovs + (i * 8);
|
|
795
|
+
const buf = view.getInt32(offset, true);
|
|
796
|
+
const bufLen = view.getUint32(offset + 4, true);
|
|
797
|
+
return HEAPU8.subarray(buf, buf + bufLen);
|
|
798
|
+
}));
|
|
799
|
+
const { bytesWritten } = await fileDescriptor.fd.write(buffer, 0, buffer.length, Number(offset));
|
|
800
|
+
view.setUint32(size, bytesWritten, true);
|
|
801
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
802
|
+
}, ['i32', 'i32', 'i32', 'i64', 'i32'], ['i32']);
|
|
803
|
+
defineImport('fd_read', function fd_read(fd, iovs, iovslen, size) {
|
|
804
|
+
iovs = Number(iovs);
|
|
805
|
+
size = Number(size);
|
|
806
|
+
if ((iovs === 0 && iovslen) || size === 0) {
|
|
807
|
+
return types_1.WasiErrno.EINVAL;
|
|
808
|
+
}
|
|
809
|
+
const { HEAPU8, view } = getMemory(this, Math.max(iovs + Number(iovslen) * 8, size + 4));
|
|
810
|
+
const wasi = _wasi.get(this);
|
|
811
|
+
const fileDescriptor = wasi.fds.get(fd, types_1.WasiRights.FD_READ, BigInt(0));
|
|
812
|
+
if (!iovslen) {
|
|
813
|
+
view.setUint32(size, 0, true);
|
|
814
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
815
|
+
}
|
|
816
|
+
let totalSize = 0;
|
|
817
|
+
const ioVecs = Array.from({ length: Number(iovslen) }, (_, i) => {
|
|
818
|
+
const offset = iovs + (i * 8);
|
|
819
|
+
const buf = view.getInt32(offset, true);
|
|
820
|
+
const bufLen = view.getUint32(offset + 4, true);
|
|
821
|
+
totalSize += bufLen;
|
|
822
|
+
return HEAPU8.subarray(buf, buf + bufLen);
|
|
823
|
+
});
|
|
824
|
+
let buffer;
|
|
825
|
+
let nread = 0;
|
|
826
|
+
if (fd === 0) {
|
|
827
|
+
if (typeof window === 'undefined' || typeof window.prompt !== 'function') {
|
|
828
|
+
return types_1.WasiErrno.ENOTSUP;
|
|
829
|
+
}
|
|
830
|
+
buffer = readStdin();
|
|
831
|
+
nread = buffer ? copyMemory(ioVecs, buffer) : 0;
|
|
832
|
+
}
|
|
833
|
+
else {
|
|
834
|
+
buffer = (() => {
|
|
835
|
+
try {
|
|
836
|
+
return new Uint8Array(new SharedArrayBuffer(totalSize));
|
|
837
|
+
}
|
|
838
|
+
catch (_) {
|
|
839
|
+
return new Uint8Array(totalSize);
|
|
840
|
+
}
|
|
841
|
+
})();
|
|
842
|
+
buffer._isBuffer = true;
|
|
843
|
+
const fs = getFs(this);
|
|
844
|
+
const bytesRead = fs.readSync(fileDescriptor.fd, buffer, 0, buffer.length, Number(fileDescriptor.pos));
|
|
845
|
+
nread = buffer ? copyMemory(ioVecs, buffer.subarray(0, bytesRead)) : 0;
|
|
846
|
+
fileDescriptor.pos += BigInt(nread);
|
|
847
|
+
}
|
|
848
|
+
view.setUint32(size, nread, true);
|
|
849
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
850
|
+
}, async function fd_read(fd, iovs, iovslen, size) {
|
|
851
|
+
iovs = Number(iovs);
|
|
852
|
+
size = Number(size);
|
|
853
|
+
if ((iovs === 0 && iovslen) || size === 0) {
|
|
854
|
+
return types_1.WasiErrno.EINVAL;
|
|
855
|
+
}
|
|
856
|
+
const { HEAPU8, view } = getMemory(this, Math.max(iovs + Number(iovslen) * 8, size + 4));
|
|
857
|
+
const wasi = _wasi.get(this);
|
|
858
|
+
const fileDescriptor = wasi.fds.get(fd, types_1.WasiRights.FD_READ, BigInt(0));
|
|
859
|
+
if (!iovslen) {
|
|
860
|
+
view.setUint32(size, 0, true);
|
|
861
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
862
|
+
}
|
|
863
|
+
let totalSize = 0;
|
|
864
|
+
const ioVecs = Array.from({ length: Number(iovslen) }, (_, i) => {
|
|
865
|
+
const offset = iovs + (i * 8);
|
|
866
|
+
const buf = view.getInt32(offset, true);
|
|
867
|
+
const bufLen = view.getUint32(offset + 4, true);
|
|
868
|
+
totalSize += bufLen;
|
|
869
|
+
return HEAPU8.subarray(buf, buf + bufLen);
|
|
870
|
+
});
|
|
871
|
+
let buffer;
|
|
872
|
+
let nread = 0;
|
|
873
|
+
if (fd === 0) {
|
|
874
|
+
if (typeof window === 'undefined' || typeof window.prompt !== 'function') {
|
|
875
|
+
return types_1.WasiErrno.ENOTSUP;
|
|
876
|
+
}
|
|
877
|
+
buffer = readStdin();
|
|
878
|
+
nread = buffer ? copyMemory(ioVecs, buffer) : 0;
|
|
879
|
+
}
|
|
880
|
+
else {
|
|
881
|
+
buffer = new Uint8Array(totalSize);
|
|
882
|
+
buffer._isBuffer = true;
|
|
883
|
+
const { bytesRead } = await fileDescriptor.fd.read(buffer, 0, buffer.length, Number(fileDescriptor.pos));
|
|
884
|
+
nread = buffer ? copyMemory(ioVecs, buffer.subarray(0, bytesRead)) : 0;
|
|
885
|
+
fileDescriptor.pos += BigInt(nread);
|
|
886
|
+
}
|
|
887
|
+
view.setUint32(size, nread, true);
|
|
888
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
889
|
+
}, ['i32', 'i32', 'i32', 'i32'], ['i32']);
|
|
890
|
+
defineImport('fd_readdir', function fd_readdir(fd, buf, buf_len, cookie, bufused) {
|
|
891
|
+
buf = Number(buf);
|
|
892
|
+
buf_len = Number(buf_len);
|
|
893
|
+
bufused = Number(bufused);
|
|
894
|
+
if (buf === 0 || bufused === 0)
|
|
895
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
896
|
+
const wasi = _wasi.get(this);
|
|
897
|
+
const fileDescriptor = wasi.fds.get(fd, types_1.WasiRights.FD_READDIR, BigInt(0));
|
|
898
|
+
const fs = getFs(this);
|
|
899
|
+
const entries = fs.readdirSync(fileDescriptor.realPath, { withFileTypes: true });
|
|
900
|
+
const { HEAPU8, view } = getMemory(this, Math.max(buf + buf_len, bufused + 4));
|
|
901
|
+
let bufferUsed = 0;
|
|
902
|
+
for (let i = Number(cookie); i < entries.length; i++) {
|
|
903
|
+
const nameData = encoder.encode(entries[i].name);
|
|
904
|
+
const entryInfo = fs.statSync((0, path_1.resolve)(fileDescriptor.realPath, entries[i].name), { bigint: true });
|
|
905
|
+
const entryData = new Uint8Array(24 + nameData.byteLength);
|
|
906
|
+
const entryView = new DataView(entryData.buffer);
|
|
907
|
+
entryView.setBigUint64(0, BigInt(i + 1), true);
|
|
908
|
+
entryView.setBigUint64(8, BigInt(entryInfo.ino ? entryInfo.ino : 0), true);
|
|
909
|
+
entryView.setUint32(16, nameData.byteLength, true);
|
|
910
|
+
let type;
|
|
911
|
+
if (entries[i].isFile()) {
|
|
912
|
+
type = types_1.WasiFileType.REGULAR_FILE;
|
|
913
|
+
}
|
|
914
|
+
else if (entries[i].isDirectory()) {
|
|
915
|
+
type = types_1.WasiFileType.DIRECTORY;
|
|
916
|
+
}
|
|
917
|
+
else if (entries[i].isSymbolicLink()) {
|
|
918
|
+
type = types_1.WasiFileType.SYMBOLIC_LINK;
|
|
919
|
+
}
|
|
920
|
+
else if (entries[i].isCharacterDevice()) {
|
|
921
|
+
type = types_1.WasiFileType.CHARACTER_DEVICE;
|
|
922
|
+
}
|
|
923
|
+
else if (entries[i].isBlockDevice()) {
|
|
924
|
+
type = types_1.WasiFileType.BLOCK_DEVICE;
|
|
925
|
+
}
|
|
926
|
+
else if (entries[i].isSocket()) {
|
|
927
|
+
type = types_1.WasiFileType.SOCKET_STREAM;
|
|
928
|
+
}
|
|
929
|
+
else {
|
|
930
|
+
type = types_1.WasiFileType.UNKNOWN;
|
|
931
|
+
}
|
|
932
|
+
entryView.setUint8(20, type);
|
|
933
|
+
entryData.set(nameData, 24);
|
|
934
|
+
const data = entryData.slice(0, Math.min(entryData.length, buf_len - bufferUsed));
|
|
935
|
+
HEAPU8.set(data, buf + bufferUsed);
|
|
936
|
+
bufferUsed += data.byteLength;
|
|
937
|
+
}
|
|
938
|
+
view.setUint32(bufused, bufferUsed, true);
|
|
939
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
940
|
+
}, async function fd_readdir(fd, buf, buf_len, cookie, bufused) {
|
|
941
|
+
buf = Number(buf);
|
|
942
|
+
buf_len = Number(buf_len);
|
|
943
|
+
bufused = Number(bufused);
|
|
944
|
+
if (buf === 0 || bufused === 0)
|
|
945
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
946
|
+
const wasi = _wasi.get(this);
|
|
947
|
+
const fileDescriptor = wasi.fds.get(fd, types_1.WasiRights.FD_READDIR, BigInt(0));
|
|
948
|
+
const fs = getFs(this);
|
|
949
|
+
const entries = await fs.promises.readdir(fileDescriptor.realPath, { withFileTypes: true });
|
|
950
|
+
const { HEAPU8, view } = getMemory(this, Math.max(buf + buf_len, bufused + 4));
|
|
951
|
+
let bufferUsed = 0;
|
|
952
|
+
for (let i = Number(cookie); i < entries.length; i++) {
|
|
953
|
+
const nameData = encoder.encode(entries[i].name);
|
|
954
|
+
const entryInfo = await fs.promises.stat((0, path_1.resolve)(fileDescriptor.realPath, entries[i].name), { bigint: true });
|
|
955
|
+
const entryData = new Uint8Array(24 + nameData.byteLength);
|
|
956
|
+
const entryView = new DataView(entryData.buffer);
|
|
957
|
+
entryView.setBigUint64(0, BigInt(i + 1), true);
|
|
958
|
+
entryView.setBigUint64(8, BigInt(entryInfo.ino ? entryInfo.ino : 0), true);
|
|
959
|
+
entryView.setUint32(16, nameData.byteLength, true);
|
|
960
|
+
let type;
|
|
961
|
+
if (entries[i].isFile()) {
|
|
962
|
+
type = types_1.WasiFileType.REGULAR_FILE;
|
|
963
|
+
}
|
|
964
|
+
else if (entries[i].isDirectory()) {
|
|
965
|
+
type = types_1.WasiFileType.DIRECTORY;
|
|
966
|
+
}
|
|
967
|
+
else if (entries[i].isSymbolicLink()) {
|
|
968
|
+
type = types_1.WasiFileType.SYMBOLIC_LINK;
|
|
969
|
+
}
|
|
970
|
+
else if (entries[i].isCharacterDevice()) {
|
|
971
|
+
type = types_1.WasiFileType.CHARACTER_DEVICE;
|
|
972
|
+
}
|
|
973
|
+
else if (entries[i].isBlockDevice()) {
|
|
974
|
+
type = types_1.WasiFileType.BLOCK_DEVICE;
|
|
975
|
+
}
|
|
976
|
+
else if (entries[i].isSocket()) {
|
|
977
|
+
type = types_1.WasiFileType.SOCKET_STREAM;
|
|
978
|
+
}
|
|
979
|
+
else {
|
|
980
|
+
type = types_1.WasiFileType.UNKNOWN;
|
|
981
|
+
}
|
|
982
|
+
entryView.setUint8(20, type);
|
|
983
|
+
entryData.set(nameData, 24);
|
|
984
|
+
const data = entryData.slice(0, Math.min(entryData.length, buf_len - bufferUsed));
|
|
985
|
+
HEAPU8.set(data, buf + bufferUsed);
|
|
986
|
+
bufferUsed += data.byteLength;
|
|
987
|
+
}
|
|
988
|
+
view.setUint32(bufused, bufferUsed, true);
|
|
989
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
990
|
+
}, ['i32', 'i32', 'i32', 'i64', 'i32'], ['i32']);
|
|
991
|
+
defineImport('fd_renumber', function fd_renumber(from, to) {
|
|
992
|
+
const wasi = _wasi.get(this);
|
|
993
|
+
wasi.fds.renumber(to, from);
|
|
994
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
995
|
+
}, async function fd_renumber(from, to) {
|
|
996
|
+
const wasi = _wasi.get(this);
|
|
997
|
+
await wasi.fds.renumber(to, from);
|
|
998
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
999
|
+
}, ['i32', 'i32'], ['i32']);
|
|
1000
|
+
defineImport('fd_sync', function fd_sync(fd) {
|
|
1001
|
+
const wasi = _wasi.get(this);
|
|
1002
|
+
const fileDescriptor = wasi.fds.get(fd, types_1.WasiRights.FD_SYNC, BigInt(0));
|
|
1003
|
+
const fs = getFs(this);
|
|
1004
|
+
fs.fsyncSync(fileDescriptor.fd);
|
|
1005
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
1006
|
+
}, async function fd_sync(fd) {
|
|
1007
|
+
const wasi = _wasi.get(this);
|
|
1008
|
+
const fileDescriptor = wasi.fds.get(fd, types_1.WasiRights.FD_SYNC, BigInt(0));
|
|
1009
|
+
await fileDescriptor.fd.sync();
|
|
1010
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
1011
|
+
}, ['i32'], ['i32']);
|
|
1012
|
+
defineImport('fd_write', function fd_write(fd, iovs, iovslen, size) {
|
|
1013
|
+
iovs = Number(iovs);
|
|
1014
|
+
size = Number(size);
|
|
1015
|
+
if ((iovs === 0 && iovslen) || size === 0) {
|
|
1016
|
+
return types_1.WasiErrno.EINVAL;
|
|
1017
|
+
}
|
|
1018
|
+
const { HEAPU8, view } = getMemory(this, Math.max(iovs + Number(iovslen) * 8, size + 4));
|
|
1019
|
+
const wasi = _wasi.get(this);
|
|
1020
|
+
const fileDescriptor = wasi.fds.get(fd, types_1.WasiRights.FD_WRITE, BigInt(0));
|
|
1021
|
+
if (!iovslen) {
|
|
1022
|
+
view.setUint32(size, 0, true);
|
|
1023
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
1024
|
+
}
|
|
1025
|
+
const buffer = (0, fd_1.concatBuffer)(Array.from({ length: Number(iovslen) }, (_, i) => {
|
|
1026
|
+
const offset = iovs + (i * 8);
|
|
1027
|
+
const buf = view.getInt32(offset, true);
|
|
1028
|
+
const bufLen = view.getUint32(offset + 4, true);
|
|
1029
|
+
return HEAPU8.subarray(buf, buf + bufLen);
|
|
1030
|
+
}));
|
|
1031
|
+
let nwritten;
|
|
1032
|
+
if (fd === 1 || fd === 2) {
|
|
1033
|
+
nwritten = fileDescriptor.write(buffer);
|
|
1034
|
+
}
|
|
1035
|
+
else {
|
|
1036
|
+
const fs = getFs(this);
|
|
1037
|
+
nwritten = fs.writeSync(fileDescriptor.fd, buffer, 0, buffer.length, Number(fileDescriptor.pos));
|
|
1038
|
+
fileDescriptor.pos += BigInt(nwritten);
|
|
1039
|
+
}
|
|
1040
|
+
view.setUint32(size, nwritten, true);
|
|
1041
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
1042
|
+
}, async function fd_write(fd, iovs, iovslen, size) {
|
|
1043
|
+
iovs = Number(iovs);
|
|
1044
|
+
size = Number(size);
|
|
1045
|
+
if ((iovs === 0 && iovslen) || size === 0) {
|
|
1046
|
+
return types_1.WasiErrno.EINVAL;
|
|
1047
|
+
}
|
|
1048
|
+
const { HEAPU8, view } = getMemory(this, Math.max(iovs + Number(iovslen) * 8, size + 4));
|
|
1049
|
+
const wasi = _wasi.get(this);
|
|
1050
|
+
const fileDescriptor = wasi.fds.get(fd, types_1.WasiRights.FD_WRITE, BigInt(0));
|
|
1051
|
+
if (!iovslen) {
|
|
1052
|
+
view.setUint32(size, 0, true);
|
|
1053
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
1054
|
+
}
|
|
1055
|
+
const buffer = (0, fd_1.concatBuffer)(Array.from({ length: Number(iovslen) }, (_, i) => {
|
|
1056
|
+
const offset = iovs + (i * 8);
|
|
1057
|
+
const buf = view.getInt32(offset, true);
|
|
1058
|
+
const bufLen = view.getUint32(offset + 4, true);
|
|
1059
|
+
return HEAPU8.subarray(buf, buf + bufLen);
|
|
1060
|
+
}));
|
|
1061
|
+
let nwritten;
|
|
1062
|
+
if (fd === 1 || fd === 2) {
|
|
1063
|
+
nwritten = fileDescriptor.write(buffer);
|
|
1064
|
+
}
|
|
1065
|
+
else {
|
|
1066
|
+
nwritten = await (await (fileDescriptor.fd.write(buffer, 0, buffer.length, Number(fileDescriptor.pos)))).bytesWritten;
|
|
1067
|
+
fileDescriptor.pos += BigInt(nwritten);
|
|
1068
|
+
}
|
|
1069
|
+
view.setUint32(size, nwritten, true);
|
|
1070
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
1071
|
+
}, ['i32', 'i32', 'i32', 'i32'], ['i32']);
|
|
1072
|
+
defineImport('path_create_directory', function path_create_directory(fd, path, path_len) {
|
|
1073
|
+
path = Number(path);
|
|
1074
|
+
path_len = Number(path_len);
|
|
1075
|
+
if (path === 0) {
|
|
1076
|
+
return types_1.WasiErrno.EINVAL;
|
|
1077
|
+
}
|
|
1078
|
+
const { HEAPU8 } = getMemory(this, path + path_len);
|
|
1079
|
+
const wasi = _wasi.get(this);
|
|
1080
|
+
const fileDescriptor = wasi.fds.get(fd, types_1.WasiRights.PATH_CREATE_DIRECTORY, BigInt(0));
|
|
1081
|
+
let pathString = decoder.decode((0, util_1.unsharedSlice)(HEAPU8, path, path + path_len));
|
|
1082
|
+
pathString = (0, path_1.resolve)(fileDescriptor.realPath, pathString);
|
|
1083
|
+
const fs = getFs(this);
|
|
1084
|
+
fs.mkdirSync(pathString);
|
|
1085
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
1086
|
+
}, async function path_create_directory(fd, path, path_len) {
|
|
1087
|
+
path = Number(path);
|
|
1088
|
+
path_len = Number(path_len);
|
|
1089
|
+
if (path === 0) {
|
|
1090
|
+
return types_1.WasiErrno.EINVAL;
|
|
1091
|
+
}
|
|
1092
|
+
const { HEAPU8 } = getMemory(this, path + path_len);
|
|
1093
|
+
const wasi = _wasi.get(this);
|
|
1094
|
+
const fileDescriptor = wasi.fds.get(fd, types_1.WasiRights.PATH_CREATE_DIRECTORY, BigInt(0));
|
|
1095
|
+
let pathString = decoder.decode((0, util_1.unsharedSlice)(HEAPU8, path, path + path_len));
|
|
1096
|
+
pathString = (0, path_1.resolve)(fileDescriptor.realPath, pathString);
|
|
1097
|
+
const fs = getFs(this);
|
|
1098
|
+
await fs.promises.mkdir(pathString);
|
|
1099
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
1100
|
+
}, ['i32', 'i32', 'i32'], ['i32']);
|
|
1101
|
+
defineImport('path_filestat_get', function path_filestat_get(fd, flags, path, path_len, filestat) {
|
|
1102
|
+
path = Number(path);
|
|
1103
|
+
path_len = Number(path_len);
|
|
1104
|
+
filestat = Number(filestat);
|
|
1105
|
+
if (path === 0 || filestat === 0) {
|
|
1106
|
+
return types_1.WasiErrno.EINVAL;
|
|
1107
|
+
}
|
|
1108
|
+
const { HEAPU8, view } = getMemory(this, Math.max(path + path_len, filestat + 64));
|
|
1109
|
+
const wasi = _wasi.get(this);
|
|
1110
|
+
const fileDescriptor = wasi.fds.get(fd, types_1.WasiRights.PATH_FILESTAT_GET, BigInt(0));
|
|
1111
|
+
let pathString = decoder.decode((0, util_1.unsharedSlice)(HEAPU8, path, path + path_len));
|
|
1112
|
+
const fs = getFs(this);
|
|
1113
|
+
pathString = (0, path_1.resolve)(fileDescriptor.realPath, pathString);
|
|
1114
|
+
let stat;
|
|
1115
|
+
if ((flags & 1) === 1) {
|
|
1116
|
+
stat = fs.statSync(pathString, { bigint: true });
|
|
1117
|
+
}
|
|
1118
|
+
else {
|
|
1119
|
+
stat = fs.lstatSync(pathString, { bigint: true });
|
|
1120
|
+
}
|
|
1121
|
+
(0, fd_1.toFileStat)(view, filestat, stat);
|
|
1122
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
1123
|
+
}, async function path_filestat_get(fd, flags, path, path_len, filestat) {
|
|
1124
|
+
path = Number(path);
|
|
1125
|
+
path_len = Number(path_len);
|
|
1126
|
+
filestat = Number(filestat);
|
|
1127
|
+
if (path === 0 || filestat === 0) {
|
|
1128
|
+
return types_1.WasiErrno.EINVAL;
|
|
1129
|
+
}
|
|
1130
|
+
const { HEAPU8, view } = getMemory(this, Math.max(path + path_len, filestat + 64));
|
|
1131
|
+
const wasi = _wasi.get(this);
|
|
1132
|
+
const fileDescriptor = wasi.fds.get(fd, types_1.WasiRights.PATH_FILESTAT_GET, BigInt(0));
|
|
1133
|
+
let pathString = decoder.decode((0, util_1.unsharedSlice)(HEAPU8, path, path + path_len));
|
|
1134
|
+
const fs = getFs(this);
|
|
1135
|
+
pathString = (0, path_1.resolve)(fileDescriptor.realPath, pathString);
|
|
1136
|
+
let stat;
|
|
1137
|
+
if ((flags & 1) === 1) {
|
|
1138
|
+
stat = await fs.promises.stat(pathString, { bigint: true });
|
|
1139
|
+
}
|
|
1140
|
+
else {
|
|
1141
|
+
stat = await fs.promises.lstat(pathString, { bigint: true });
|
|
1142
|
+
}
|
|
1143
|
+
(0, fd_1.toFileStat)(view, filestat, stat);
|
|
1144
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
1145
|
+
}, ['i32', 'i32', 'i32', 'i32', 'i32'], ['i32']);
|
|
1146
|
+
defineImport('path_filestat_set_times', function path_filestat_set_times(fd, flags, path, path_len, atim, mtim, fst_flags) {
|
|
1147
|
+
path = Number(path);
|
|
1148
|
+
path_len = Number(path_len);
|
|
1149
|
+
if (path === 0)
|
|
1150
|
+
return types_1.WasiErrno.EINVAL;
|
|
1151
|
+
const { HEAPU8 } = getMemory(this, path + path_len);
|
|
1152
|
+
const wasi = _wasi.get(this);
|
|
1153
|
+
const fileDescriptor = wasi.fds.get(fd, types_1.WasiRights.PATH_FILESTAT_SET_TIMES, BigInt(0));
|
|
1154
|
+
if (validateFstFlagsOrReturn(fst_flags)) {
|
|
1155
|
+
return types_1.WasiErrno.EINVAL;
|
|
1156
|
+
}
|
|
1157
|
+
const fs = getFs(this);
|
|
1158
|
+
const resolvedPath = resolvePathSync(fs, fileDescriptor, decoder.decode((0, util_1.unsharedSlice)(HEAPU8, path, path + path_len)), flags);
|
|
1159
|
+
if ((fst_flags & types_1.WasiFstFlag.SET_ATIM_NOW) === types_1.WasiFstFlag.SET_ATIM_NOW) {
|
|
1160
|
+
atim = BigInt(Date.now() * 1000000);
|
|
1161
|
+
}
|
|
1162
|
+
if ((fst_flags & types_1.WasiFstFlag.SET_MTIM_NOW) === types_1.WasiFstFlag.SET_MTIM_NOW) {
|
|
1163
|
+
mtim = BigInt(Date.now() * 1000000);
|
|
1164
|
+
}
|
|
1165
|
+
fs.utimesSync(resolvedPath, Number(atim), Number(mtim));
|
|
1166
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
1167
|
+
}, async function path_filestat_set_times(fd, flags, path, path_len, atim, mtim, fst_flags) {
|
|
1168
|
+
path = Number(path);
|
|
1169
|
+
path_len = Number(path_len);
|
|
1170
|
+
if (path === 0)
|
|
1171
|
+
return types_1.WasiErrno.EINVAL;
|
|
1172
|
+
const { HEAPU8 } = getMemory(this, path + path_len);
|
|
1173
|
+
const wasi = _wasi.get(this);
|
|
1174
|
+
const fileDescriptor = wasi.fds.get(fd, types_1.WasiRights.PATH_FILESTAT_SET_TIMES, BigInt(0));
|
|
1175
|
+
if (validateFstFlagsOrReturn(fst_flags)) {
|
|
1176
|
+
return types_1.WasiErrno.EINVAL;
|
|
1177
|
+
}
|
|
1178
|
+
const fs = getFs(this);
|
|
1179
|
+
const resolvedPath = await resolvePathAsync(fs, fileDescriptor, decoder.decode((0, util_1.unsharedSlice)(HEAPU8, path, path + path_len)), flags);
|
|
1180
|
+
if ((fst_flags & types_1.WasiFstFlag.SET_ATIM_NOW) === types_1.WasiFstFlag.SET_ATIM_NOW) {
|
|
1181
|
+
atim = BigInt(Date.now() * 1000000);
|
|
1182
|
+
}
|
|
1183
|
+
if ((fst_flags & types_1.WasiFstFlag.SET_MTIM_NOW) === types_1.WasiFstFlag.SET_MTIM_NOW) {
|
|
1184
|
+
mtim = BigInt(Date.now() * 1000000);
|
|
1185
|
+
}
|
|
1186
|
+
await fs.promises.utimes(resolvedPath, Number(atim), Number(mtim));
|
|
1187
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
1188
|
+
}, ['i32', 'i32', 'i32', 'i32', 'i64', 'i64', 'i32'], ['i32']);
|
|
1189
|
+
defineImport('path_link', function path_link(old_fd, old_flags, old_path, old_path_len, new_fd, new_path, new_path_len) {
|
|
1190
|
+
old_path = Number(old_path);
|
|
1191
|
+
old_path_len = Number(old_path_len);
|
|
1192
|
+
new_path = Number(new_path);
|
|
1193
|
+
new_path_len = Number(new_path_len);
|
|
1194
|
+
if (old_path === 0 || new_path === 0) {
|
|
1195
|
+
return types_1.WasiErrno.EINVAL;
|
|
1196
|
+
}
|
|
1197
|
+
const wasi = _wasi.get(this);
|
|
1198
|
+
let oldWrap;
|
|
1199
|
+
let newWrap;
|
|
1200
|
+
if (old_fd === new_fd) {
|
|
1201
|
+
oldWrap = newWrap = wasi.fds.get(old_fd, types_1.WasiRights.PATH_LINK_SOURCE | types_1.WasiRights.PATH_LINK_TARGET, BigInt(0));
|
|
1202
|
+
}
|
|
1203
|
+
else {
|
|
1204
|
+
oldWrap = wasi.fds.get(old_fd, types_1.WasiRights.PATH_LINK_SOURCE, BigInt(0));
|
|
1205
|
+
newWrap = wasi.fds.get(new_fd, types_1.WasiRights.PATH_LINK_TARGET, BigInt(0));
|
|
1206
|
+
}
|
|
1207
|
+
const { HEAPU8 } = getMemory(this, Math.max(old_path + old_path_len, new_path + new_path_len));
|
|
1208
|
+
const fs = getFs(this);
|
|
1209
|
+
const resolvedOldPath = resolvePathSync(fs, oldWrap, decoder.decode((0, util_1.unsharedSlice)(HEAPU8, old_path, old_path + old_path_len)), old_flags);
|
|
1210
|
+
const resolvedNewPath = (0, path_1.resolve)(newWrap.realPath, decoder.decode((0, util_1.unsharedSlice)(HEAPU8, new_path, new_path + new_path_len)));
|
|
1211
|
+
fs.linkSync(resolvedOldPath, resolvedNewPath);
|
|
1212
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
1213
|
+
}, async function path_link(old_fd, old_flags, old_path, old_path_len, new_fd, new_path, new_path_len) {
|
|
1214
|
+
old_path = Number(old_path);
|
|
1215
|
+
old_path_len = Number(old_path_len);
|
|
1216
|
+
new_path = Number(new_path);
|
|
1217
|
+
new_path_len = Number(new_path_len);
|
|
1218
|
+
if (old_path === 0 || new_path === 0) {
|
|
1219
|
+
return types_1.WasiErrno.EINVAL;
|
|
1220
|
+
}
|
|
1221
|
+
const wasi = _wasi.get(this);
|
|
1222
|
+
let oldWrap;
|
|
1223
|
+
let newWrap;
|
|
1224
|
+
if (old_fd === new_fd) {
|
|
1225
|
+
oldWrap = newWrap = wasi.fds.get(old_fd, types_1.WasiRights.PATH_LINK_SOURCE | types_1.WasiRights.PATH_LINK_TARGET, BigInt(0));
|
|
1226
|
+
}
|
|
1227
|
+
else {
|
|
1228
|
+
oldWrap = wasi.fds.get(old_fd, types_1.WasiRights.PATH_LINK_SOURCE, BigInt(0));
|
|
1229
|
+
newWrap = wasi.fds.get(new_fd, types_1.WasiRights.PATH_LINK_TARGET, BigInt(0));
|
|
1230
|
+
}
|
|
1231
|
+
const { HEAPU8 } = getMemory(this, Math.max(old_path + old_path_len, new_path + new_path_len));
|
|
1232
|
+
const fs = getFs(this);
|
|
1233
|
+
const resolvedOldPath = await resolvePathAsync(fs, oldWrap, decoder.decode((0, util_1.unsharedSlice)(HEAPU8, old_path, old_path + old_path_len)), old_flags);
|
|
1234
|
+
const resolvedNewPath = (0, path_1.resolve)(newWrap.realPath, decoder.decode((0, util_1.unsharedSlice)(HEAPU8, new_path, new_path + new_path_len)));
|
|
1235
|
+
await fs.promises.link(resolvedOldPath, resolvedNewPath);
|
|
1236
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
1237
|
+
}, ['i32', 'i32', 'i32', 'i32', 'i32', 'i32', 'i32'], ['i32']);
|
|
1238
|
+
function pathOpen(o_flags, fs_rights_base, fs_rights_inheriting, fs_flags) {
|
|
1239
|
+
const read = (fs_rights_base & (types_1.WasiRights.FD_READ |
|
|
1240
|
+
types_1.WasiRights.FD_READDIR)) !== BigInt(0);
|
|
1241
|
+
const write = (fs_rights_base & (types_1.WasiRights.FD_DATASYNC |
|
|
1242
|
+
types_1.WasiRights.FD_WRITE |
|
|
1243
|
+
types_1.WasiRights.FD_ALLOCATE |
|
|
1244
|
+
types_1.WasiRights.FD_FILESTAT_SET_SIZE)) !== BigInt(0);
|
|
1245
|
+
let flags = write ? read ? types_1.FileControlFlag.O_RDWR : types_1.FileControlFlag.O_WRONLY : types_1.FileControlFlag.O_RDONLY;
|
|
1246
|
+
let needed_base = types_1.WasiRights.PATH_OPEN;
|
|
1247
|
+
let needed_inheriting = fs_rights_base | fs_rights_inheriting;
|
|
1248
|
+
if ((o_flags & types_1.WasiFileControlFlag.O_CREAT) !== 0) {
|
|
1249
|
+
flags |= types_1.FileControlFlag.O_CREAT;
|
|
1250
|
+
needed_base |= types_1.WasiRights.PATH_CREATE_FILE;
|
|
1251
|
+
}
|
|
1252
|
+
if ((o_flags & types_1.WasiFileControlFlag.O_DIRECTORY) !== 0) {
|
|
1253
|
+
flags |= types_1.FileControlFlag.O_DIRECTORY;
|
|
1254
|
+
}
|
|
1255
|
+
if ((o_flags & types_1.WasiFileControlFlag.O_EXCL) !== 0) {
|
|
1256
|
+
flags |= types_1.FileControlFlag.O_EXCL;
|
|
1257
|
+
}
|
|
1258
|
+
if ((o_flags & types_1.WasiFileControlFlag.O_TRUNC) !== 0) {
|
|
1259
|
+
flags |= types_1.FileControlFlag.O_TRUNC;
|
|
1260
|
+
needed_base |= types_1.WasiRights.PATH_FILESTAT_SET_SIZE;
|
|
1261
|
+
}
|
|
1262
|
+
if ((fs_flags & types_1.WasiFdFlag.APPEND) !== 0) {
|
|
1263
|
+
flags |= types_1.FileControlFlag.O_APPEND;
|
|
1264
|
+
}
|
|
1265
|
+
if ((fs_flags & types_1.WasiFdFlag.DSYNC) !== 0) {
|
|
1266
|
+
// flags |= FileControlFlag.O_DSYNC;
|
|
1267
|
+
needed_inheriting |= types_1.WasiRights.FD_DATASYNC;
|
|
1268
|
+
}
|
|
1269
|
+
if ((fs_flags & types_1.WasiFdFlag.NONBLOCK) !== 0) {
|
|
1270
|
+
flags |= types_1.FileControlFlag.O_NONBLOCK;
|
|
1271
|
+
}
|
|
1272
|
+
if ((fs_flags & types_1.WasiFdFlag.RSYNC) !== 0) {
|
|
1273
|
+
flags |= types_1.FileControlFlag.O_SYNC;
|
|
1274
|
+
needed_inheriting |= types_1.WasiRights.FD_SYNC;
|
|
1275
|
+
}
|
|
1276
|
+
if ((fs_flags & types_1.WasiFdFlag.SYNC) !== 0) {
|
|
1277
|
+
flags |= types_1.FileControlFlag.O_SYNC;
|
|
1278
|
+
needed_inheriting |= types_1.WasiRights.FD_SYNC;
|
|
1279
|
+
}
|
|
1280
|
+
if (write && (flags & (types_1.FileControlFlag.O_APPEND | types_1.FileControlFlag.O_TRUNC)) === 0) {
|
|
1281
|
+
needed_inheriting |= types_1.WasiRights.FD_SEEK;
|
|
1282
|
+
}
|
|
1283
|
+
return { flags, needed_base, needed_inheriting };
|
|
1284
|
+
}
|
|
1285
|
+
defineImport('path_open', function path_open(dirfd, dirflags, path, path_len, o_flags, fs_rights_base, fs_rights_inheriting, fs_flags, fd) {
|
|
1286
|
+
path = Number(path);
|
|
1287
|
+
fd = Number(fd);
|
|
1288
|
+
if (path === 0 || fd === 0) {
|
|
1289
|
+
return types_1.WasiErrno.EINVAL;
|
|
1290
|
+
}
|
|
1291
|
+
path_len = Number(path_len);
|
|
1292
|
+
fs_rights_base = BigInt(fs_rights_base);
|
|
1293
|
+
fs_rights_inheriting = BigInt(fs_rights_inheriting);
|
|
1294
|
+
const { flags: flagsRes, needed_base: neededBase, needed_inheriting: neededInheriting } = pathOpen(o_flags, fs_rights_base, fs_rights_inheriting, fs_flags);
|
|
1295
|
+
const wasi = _wasi.get(this);
|
|
1296
|
+
const fileDescriptor = wasi.fds.get(dirfd, neededBase, neededInheriting);
|
|
1297
|
+
const memory = getMemory(this, Math.max(path + path_len, fd + 4));
|
|
1298
|
+
const HEAPU8 = memory.HEAPU8;
|
|
1299
|
+
const pathString = decoder.decode((0, util_1.unsharedSlice)(HEAPU8, path, path + path_len));
|
|
1300
|
+
const fs = getFs(this);
|
|
1301
|
+
const resolved_path = resolvePathSync(fs, fileDescriptor, pathString, dirflags);
|
|
1302
|
+
const r = fs.openSync(resolved_path, _isWin32Flags ? _toWinOpenFlags(flagsRes) : flagsRes, 0o666);
|
|
1303
|
+
const filetype = wasi.fds.getFileTypeByFd(r);
|
|
1304
|
+
if ((filetype !== types_1.WasiFileType.DIRECTORY) &&
|
|
1305
|
+
((o_flags & types_1.WasiFileControlFlag.O_DIRECTORY) !== 0 ||
|
|
1306
|
+
(resolved_path.endsWith('/')))) {
|
|
1307
|
+
return types_1.WasiErrno.ENOTDIR;
|
|
1308
|
+
}
|
|
1309
|
+
const { base: max_base, inheriting: max_inheriting } = (0, rights_1.getRights)(wasi.fds.stdio, r, flagsRes, filetype);
|
|
1310
|
+
const wrap = wasi.fds.insert(r, resolved_path, resolved_path, filetype, fs_rights_base & max_base, fs_rights_inheriting & max_inheriting, 0);
|
|
1311
|
+
const stat = fs.fstatSync(r, { bigint: true });
|
|
1312
|
+
if (stat.isFile()) {
|
|
1313
|
+
wrap.size = stat.size;
|
|
1314
|
+
if ((flagsRes & types_1.FileControlFlag.O_APPEND) !== 0) {
|
|
1315
|
+
wrap.pos = stat.size;
|
|
1316
|
+
}
|
|
1317
|
+
}
|
|
1318
|
+
const view = memory.view;
|
|
1319
|
+
view.setInt32(fd, wrap.id, true);
|
|
1320
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
1321
|
+
}, async function path_open(dirfd, dirflags, path, path_len, o_flags, fs_rights_base, fs_rights_inheriting, fs_flags, fd) {
|
|
1322
|
+
path = Number(path);
|
|
1323
|
+
fd = Number(fd);
|
|
1324
|
+
if (path === 0 || fd === 0) {
|
|
1325
|
+
return types_1.WasiErrno.EINVAL;
|
|
1326
|
+
}
|
|
1327
|
+
path_len = Number(path_len);
|
|
1328
|
+
fs_rights_base = BigInt(fs_rights_base);
|
|
1329
|
+
fs_rights_inheriting = BigInt(fs_rights_inheriting);
|
|
1330
|
+
const { flags: flagsRes, needed_base: neededBase, needed_inheriting: neededInheriting } = pathOpen(o_flags, fs_rights_base, fs_rights_inheriting, fs_flags);
|
|
1331
|
+
const wasi = _wasi.get(this);
|
|
1332
|
+
const fileDescriptor = wasi.fds.get(dirfd, neededBase, neededInheriting);
|
|
1333
|
+
const memory = getMemory(this, Math.max(path + path_len, fd + 4));
|
|
1334
|
+
const HEAPU8 = memory.HEAPU8;
|
|
1335
|
+
const pathString = decoder.decode((0, util_1.unsharedSlice)(HEAPU8, path, path + path_len));
|
|
1336
|
+
const fs = getFs(this);
|
|
1337
|
+
const resolved_path = await resolvePathAsync(fs, fileDescriptor, pathString, dirflags);
|
|
1338
|
+
const r = await fs.promises.open(resolved_path, _isWin32Flags ? _toWinOpenFlags(flagsRes) : flagsRes, 0o666);
|
|
1339
|
+
const filetype = await wasi.fds.getFileTypeByFd(r);
|
|
1340
|
+
if ((o_flags & types_1.WasiFileControlFlag.O_DIRECTORY) !== 0 && filetype !== types_1.WasiFileType.DIRECTORY) {
|
|
1341
|
+
return types_1.WasiErrno.ENOTDIR;
|
|
1342
|
+
}
|
|
1343
|
+
const { base: max_base, inheriting: max_inheriting } = (0, rights_1.getRights)(wasi.fds.stdio, r.fd, flagsRes, filetype);
|
|
1344
|
+
const wrap = wasi.fds.insert(r, resolved_path, resolved_path, filetype, fs_rights_base & max_base, fs_rights_inheriting & max_inheriting, 0);
|
|
1345
|
+
const stat = await r.stat({ bigint: true });
|
|
1346
|
+
if (stat.isFile()) {
|
|
1347
|
+
wrap.size = stat.size;
|
|
1348
|
+
if ((flagsRes & types_1.FileControlFlag.O_APPEND) !== 0) {
|
|
1349
|
+
wrap.pos = stat.size;
|
|
1350
|
+
}
|
|
1351
|
+
}
|
|
1352
|
+
const view = memory.view;
|
|
1353
|
+
view.setInt32(fd, wrap.id, true);
|
|
1354
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
1355
|
+
}, ['i32', 'i32', 'i32', 'i32', 'i32', 'i64', 'i64', 'i32', 'i32'], ['i32']);
|
|
1356
|
+
defineImport('path_readlink', function path_readlink(fd, path, path_len, buf, buf_len, bufused) {
|
|
1357
|
+
path = Number(path);
|
|
1358
|
+
path_len = Number(path_len);
|
|
1359
|
+
buf = Number(buf);
|
|
1360
|
+
buf_len = Number(buf_len);
|
|
1361
|
+
bufused = Number(bufused);
|
|
1362
|
+
if (path === 0 || buf === 0 || bufused === 0) {
|
|
1363
|
+
return types_1.WasiErrno.EINVAL;
|
|
1364
|
+
}
|
|
1365
|
+
const { HEAPU8, view } = getMemory(this, Math.max(path + path_len, buf + buf_len, bufused + 4));
|
|
1366
|
+
const wasi = _wasi.get(this);
|
|
1367
|
+
const fileDescriptor = wasi.fds.get(fd, types_1.WasiRights.PATH_READLINK, BigInt(0));
|
|
1368
|
+
let pathString = decoder.decode((0, util_1.unsharedSlice)(HEAPU8, path, path + path_len));
|
|
1369
|
+
pathString = (0, path_1.resolve)(fileDescriptor.realPath, pathString);
|
|
1370
|
+
const fs = getFs(this);
|
|
1371
|
+
const link = fs.readlinkSync(pathString);
|
|
1372
|
+
const linkData = encoder.encode(link);
|
|
1373
|
+
const len = Math.min(linkData.length, buf_len);
|
|
1374
|
+
if (len >= buf_len)
|
|
1375
|
+
return types_1.WasiErrno.ENOBUFS;
|
|
1376
|
+
HEAPU8.set(linkData.subarray(0, len), buf);
|
|
1377
|
+
HEAPU8[buf + len] = 0;
|
|
1378
|
+
view.setUint32(bufused, len, true);
|
|
1379
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
1380
|
+
}, async function path_readlink(fd, path, path_len, buf, buf_len, bufused) {
|
|
1381
|
+
path = Number(path);
|
|
1382
|
+
path_len = Number(path_len);
|
|
1383
|
+
buf = Number(buf);
|
|
1384
|
+
buf_len = Number(buf_len);
|
|
1385
|
+
bufused = Number(bufused);
|
|
1386
|
+
if (path === 0 || buf === 0 || bufused === 0) {
|
|
1387
|
+
return types_1.WasiErrno.EINVAL;
|
|
1388
|
+
}
|
|
1389
|
+
const { HEAPU8, view } = getMemory(this, Math.max(path + path_len, buf + buf_len, bufused + 4));
|
|
1390
|
+
const wasi = _wasi.get(this);
|
|
1391
|
+
const fileDescriptor = wasi.fds.get(fd, types_1.WasiRights.PATH_READLINK, BigInt(0));
|
|
1392
|
+
let pathString = decoder.decode((0, util_1.unsharedSlice)(HEAPU8, path, path + path_len));
|
|
1393
|
+
pathString = (0, path_1.resolve)(fileDescriptor.realPath, pathString);
|
|
1394
|
+
const fs = getFs(this);
|
|
1395
|
+
const link = await fs.promises.readlink(pathString);
|
|
1396
|
+
const linkData = encoder.encode(link);
|
|
1397
|
+
const len = Math.min(linkData.length, buf_len);
|
|
1398
|
+
if (len >= buf_len)
|
|
1399
|
+
return types_1.WasiErrno.ENOBUFS;
|
|
1400
|
+
HEAPU8.set(linkData.subarray(0, len), buf);
|
|
1401
|
+
HEAPU8[buf + len] = 0;
|
|
1402
|
+
view.setUint32(bufused, len, true);
|
|
1403
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
1404
|
+
}, ['i32', 'i32', 'i32', 'i32', 'i32', 'i32'], ['i32']);
|
|
1405
|
+
defineImport('path_remove_directory', function path_remove_directory(fd, path, path_len) {
|
|
1406
|
+
path = Number(path);
|
|
1407
|
+
path_len = Number(path_len);
|
|
1408
|
+
if (path === 0) {
|
|
1409
|
+
return types_1.WasiErrno.EINVAL;
|
|
1410
|
+
}
|
|
1411
|
+
const { HEAPU8 } = getMemory(this, path + path_len);
|
|
1412
|
+
const wasi = _wasi.get(this);
|
|
1413
|
+
const fileDescriptor = wasi.fds.get(fd, types_1.WasiRights.PATH_REMOVE_DIRECTORY, BigInt(0));
|
|
1414
|
+
let pathString = decoder.decode((0, util_1.unsharedSlice)(HEAPU8, path, path + path_len));
|
|
1415
|
+
pathString = (0, path_1.resolve)(fileDescriptor.realPath, pathString);
|
|
1416
|
+
const fs = getFs(this);
|
|
1417
|
+
fs.rmdirSync(pathString);
|
|
1418
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
1419
|
+
}, async function path_remove_directory(fd, path, path_len) {
|
|
1420
|
+
path = Number(path);
|
|
1421
|
+
path_len = Number(path_len);
|
|
1422
|
+
if (path === 0) {
|
|
1423
|
+
return types_1.WasiErrno.EINVAL;
|
|
1424
|
+
}
|
|
1425
|
+
const { HEAPU8 } = getMemory(this, path + path_len);
|
|
1426
|
+
const wasi = _wasi.get(this);
|
|
1427
|
+
const fileDescriptor = wasi.fds.get(fd, types_1.WasiRights.PATH_REMOVE_DIRECTORY, BigInt(0));
|
|
1428
|
+
let pathString = decoder.decode((0, util_1.unsharedSlice)(HEAPU8, path, path + path_len));
|
|
1429
|
+
pathString = (0, path_1.resolve)(fileDescriptor.realPath, pathString);
|
|
1430
|
+
const fs = getFs(this);
|
|
1431
|
+
await fs.promises.rmdir(pathString);
|
|
1432
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
1433
|
+
}, ['i32', 'i32', 'i32'], ['i32']);
|
|
1434
|
+
defineImport('path_rename', function path_rename(old_fd, old_path, old_path_len, new_fd, new_path, new_path_len) {
|
|
1435
|
+
old_path = Number(old_path);
|
|
1436
|
+
old_path_len = Number(old_path_len);
|
|
1437
|
+
new_path = Number(new_path);
|
|
1438
|
+
new_path_len = Number(new_path_len);
|
|
1439
|
+
if (old_path === 0 || new_path === 0) {
|
|
1440
|
+
return types_1.WasiErrno.EINVAL;
|
|
1441
|
+
}
|
|
1442
|
+
const wasi = _wasi.get(this);
|
|
1443
|
+
let oldWrap;
|
|
1444
|
+
let newWrap;
|
|
1445
|
+
if (old_fd === new_fd) {
|
|
1446
|
+
oldWrap = newWrap = wasi.fds.get(old_fd, types_1.WasiRights.PATH_RENAME_SOURCE | types_1.WasiRights.PATH_RENAME_TARGET, BigInt(0));
|
|
1447
|
+
}
|
|
1448
|
+
else {
|
|
1449
|
+
oldWrap = wasi.fds.get(old_fd, types_1.WasiRights.PATH_RENAME_SOURCE, BigInt(0));
|
|
1450
|
+
newWrap = wasi.fds.get(new_fd, types_1.WasiRights.PATH_RENAME_TARGET, BigInt(0));
|
|
1451
|
+
}
|
|
1452
|
+
const { HEAPU8 } = getMemory(this, Math.max(old_path + old_path_len, new_path + new_path_len));
|
|
1453
|
+
const resolvedOldPath = (0, path_1.resolve)(oldWrap.realPath, decoder.decode((0, util_1.unsharedSlice)(HEAPU8, old_path, old_path + old_path_len)));
|
|
1454
|
+
const resolvedNewPath = (0, path_1.resolve)(newWrap.realPath, decoder.decode((0, util_1.unsharedSlice)(HEAPU8, new_path, new_path + new_path_len)));
|
|
1455
|
+
const fs = getFs(this);
|
|
1456
|
+
fs.renameSync(resolvedOldPath, resolvedNewPath);
|
|
1457
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
1458
|
+
}, async function path_rename(old_fd, old_path, old_path_len, new_fd, new_path, new_path_len) {
|
|
1459
|
+
old_path = Number(old_path);
|
|
1460
|
+
old_path_len = Number(old_path_len);
|
|
1461
|
+
new_path = Number(new_path);
|
|
1462
|
+
new_path_len = Number(new_path_len);
|
|
1463
|
+
if (old_path === 0 || new_path === 0) {
|
|
1464
|
+
return types_1.WasiErrno.EINVAL;
|
|
1465
|
+
}
|
|
1466
|
+
const wasi = _wasi.get(this);
|
|
1467
|
+
let oldWrap;
|
|
1468
|
+
let newWrap;
|
|
1469
|
+
if (old_fd === new_fd) {
|
|
1470
|
+
oldWrap = newWrap = wasi.fds.get(old_fd, types_1.WasiRights.PATH_RENAME_SOURCE | types_1.WasiRights.PATH_RENAME_TARGET, BigInt(0));
|
|
1471
|
+
}
|
|
1472
|
+
else {
|
|
1473
|
+
oldWrap = wasi.fds.get(old_fd, types_1.WasiRights.PATH_RENAME_SOURCE, BigInt(0));
|
|
1474
|
+
newWrap = wasi.fds.get(new_fd, types_1.WasiRights.PATH_RENAME_TARGET, BigInt(0));
|
|
1475
|
+
}
|
|
1476
|
+
const { HEAPU8 } = getMemory(this, Math.max(old_path + old_path_len, new_path + new_path_len));
|
|
1477
|
+
const resolvedOldPath = (0, path_1.resolve)(oldWrap.realPath, decoder.decode((0, util_1.unsharedSlice)(HEAPU8, old_path, old_path + old_path_len)));
|
|
1478
|
+
const resolvedNewPath = (0, path_1.resolve)(newWrap.realPath, decoder.decode((0, util_1.unsharedSlice)(HEAPU8, new_path, new_path + new_path_len)));
|
|
1479
|
+
const fs = getFs(this);
|
|
1480
|
+
await fs.promises.rename(resolvedOldPath, resolvedNewPath);
|
|
1481
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
1482
|
+
}, ['i32', 'i32', 'i32', 'i32', 'i32', 'i32'], ['i32']);
|
|
1483
|
+
defineImport('path_symlink', function path_symlink(old_path, old_path_len, fd, new_path, new_path_len) {
|
|
1484
|
+
old_path = Number(old_path);
|
|
1485
|
+
old_path_len = Number(old_path_len);
|
|
1486
|
+
new_path = Number(new_path);
|
|
1487
|
+
new_path_len = Number(new_path_len);
|
|
1488
|
+
if (old_path === 0 || new_path === 0) {
|
|
1489
|
+
return types_1.WasiErrno.EINVAL;
|
|
1490
|
+
}
|
|
1491
|
+
const { HEAPU8 } = getMemory(this, Math.max(old_path + old_path_len, new_path + new_path_len));
|
|
1492
|
+
const wasi = _wasi.get(this);
|
|
1493
|
+
const fileDescriptor = wasi.fds.get(fd, types_1.WasiRights.PATH_SYMLINK, BigInt(0));
|
|
1494
|
+
const oldPath = decoder.decode((0, util_1.unsharedSlice)(HEAPU8, old_path, old_path + old_path_len));
|
|
1495
|
+
if (oldPath.length > 0 && oldPath[0] === '/') {
|
|
1496
|
+
return types_1.WasiErrno.EPERM;
|
|
1497
|
+
}
|
|
1498
|
+
let newPath = decoder.decode((0, util_1.unsharedSlice)(HEAPU8, new_path, new_path + new_path_len));
|
|
1499
|
+
newPath = (0, path_1.resolve)(fileDescriptor.realPath, newPath);
|
|
1500
|
+
const fs = getFs(this);
|
|
1501
|
+
fs.symlinkSync(oldPath, newPath);
|
|
1502
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
1503
|
+
}, async function path_symlink(old_path, old_path_len, fd, new_path, new_path_len) {
|
|
1504
|
+
old_path = Number(old_path);
|
|
1505
|
+
old_path_len = Number(old_path_len);
|
|
1506
|
+
new_path = Number(new_path);
|
|
1507
|
+
new_path_len = Number(new_path_len);
|
|
1508
|
+
if (old_path === 0 || new_path === 0) {
|
|
1509
|
+
return types_1.WasiErrno.EINVAL;
|
|
1510
|
+
}
|
|
1511
|
+
const { HEAPU8 } = getMemory(this, Math.max(old_path + old_path_len, new_path + new_path_len));
|
|
1512
|
+
const wasi = _wasi.get(this);
|
|
1513
|
+
const fileDescriptor = wasi.fds.get(fd, types_1.WasiRights.PATH_SYMLINK, BigInt(0));
|
|
1514
|
+
const oldPath = decoder.decode((0, util_1.unsharedSlice)(HEAPU8, old_path, old_path + old_path_len));
|
|
1515
|
+
let newPath = decoder.decode((0, util_1.unsharedSlice)(HEAPU8, new_path, new_path + new_path_len));
|
|
1516
|
+
newPath = (0, path_1.resolve)(fileDescriptor.realPath, newPath);
|
|
1517
|
+
const fs = getFs(this);
|
|
1518
|
+
await fs.promises.symlink(oldPath, newPath);
|
|
1519
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
1520
|
+
}, ['i32', 'i32', 'i32', 'i32', 'i32'], ['i32']);
|
|
1521
|
+
defineImport('path_unlink_file', function path_unlink_file(fd, path, path_len) {
|
|
1522
|
+
path = Number(path);
|
|
1523
|
+
path_len = Number(path_len);
|
|
1524
|
+
if (path === 0) {
|
|
1525
|
+
return types_1.WasiErrno.EINVAL;
|
|
1526
|
+
}
|
|
1527
|
+
const { HEAPU8 } = getMemory(this, path + path_len);
|
|
1528
|
+
const wasi = _wasi.get(this);
|
|
1529
|
+
const fileDescriptor = wasi.fds.get(fd, types_1.WasiRights.PATH_UNLINK_FILE, BigInt(0));
|
|
1530
|
+
let pathString = decoder.decode((0, util_1.unsharedSlice)(HEAPU8, path, path + path_len));
|
|
1531
|
+
pathString = (0, path_1.resolve)(fileDescriptor.realPath, pathString);
|
|
1532
|
+
const fs = getFs(this);
|
|
1533
|
+
fs.unlinkSync(pathString);
|
|
1534
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
1535
|
+
}, async function path_unlink_file(fd, path, path_len) {
|
|
1536
|
+
path = Number(path);
|
|
1537
|
+
path_len = Number(path_len);
|
|
1538
|
+
if (path === 0) {
|
|
1539
|
+
return types_1.WasiErrno.EINVAL;
|
|
1540
|
+
}
|
|
1541
|
+
const { HEAPU8 } = getMemory(this, path + path_len);
|
|
1542
|
+
const wasi = _wasi.get(this);
|
|
1543
|
+
const fileDescriptor = wasi.fds.get(fd, types_1.WasiRights.PATH_UNLINK_FILE, BigInt(0));
|
|
1544
|
+
let pathString = decoder.decode((0, util_1.unsharedSlice)(HEAPU8, path, path + path_len));
|
|
1545
|
+
pathString = (0, path_1.resolve)(fileDescriptor.realPath, pathString);
|
|
1546
|
+
const fs = getFs(this);
|
|
1547
|
+
await fs.promises.unlink(pathString);
|
|
1548
|
+
return types_1.WasiErrno.ESUCCESS;
|
|
1549
|
+
}, ['i32', 'i32', 'i32'], ['i32']);
|
|
1550
|
+
this._setMemory = function setMemory(m) {
|
|
1551
|
+
if (!(m instanceof webassembly_1._WebAssembly.Memory)) {
|
|
1552
|
+
throw new TypeError('"instance.exports.memory" property must be a WebAssembly.Memory');
|
|
1553
|
+
}
|
|
1554
|
+
_memory.set(_this, (0, memory_1.extendMemory)(m));
|
|
1555
|
+
};
|
|
1556
|
+
}
|
|
1557
|
+
static createSync(args, env, preopens, stdio, fs, print, printErr) {
|
|
1558
|
+
const fds = new fd_1.SyncTable({
|
|
1559
|
+
size: 3,
|
|
1560
|
+
in: stdio[0],
|
|
1561
|
+
out: stdio[1],
|
|
1562
|
+
err: stdio[2],
|
|
1563
|
+
fs,
|
|
1564
|
+
print,
|
|
1565
|
+
printErr
|
|
1566
|
+
});
|
|
1567
|
+
const _this = new WASI(args, env, fds, false, fs);
|
|
1568
|
+
if (preopens.length > 0) {
|
|
1569
|
+
for (let i = 0; i < preopens.length; ++i) {
|
|
1570
|
+
const realPath = fs.realpathSync(preopens[i].realPath, 'utf8');
|
|
1571
|
+
const fd = fs.openSync(realPath, 'r', 0o666);
|
|
1572
|
+
fds.insertPreopen(fd, preopens[i].mappedPath, realPath);
|
|
1573
|
+
}
|
|
1574
|
+
}
|
|
1575
|
+
return _this;
|
|
1576
|
+
}
|
|
1577
|
+
static async createAsync(args, env, preopens, stdio, fs, print, printErr, asyncify) {
|
|
1578
|
+
const fds = new fd_1.AsyncTable({
|
|
1579
|
+
size: 3,
|
|
1580
|
+
in: stdio[0],
|
|
1581
|
+
out: stdio[1],
|
|
1582
|
+
err: stdio[2],
|
|
1583
|
+
print,
|
|
1584
|
+
printErr
|
|
1585
|
+
});
|
|
1586
|
+
const _this = new WASI(args, env, fds, true, fs, asyncify);
|
|
1587
|
+
if (preopens.length > 0) {
|
|
1588
|
+
for (let i = 0; i < preopens.length; ++i) {
|
|
1589
|
+
const entry = preopens[i];
|
|
1590
|
+
const realPath = await fs.promises.realpath(entry.realPath);
|
|
1591
|
+
const fd = await fs.promises.open(realPath, 'r', 0o666);
|
|
1592
|
+
await fds.insertPreopen(fd, entry.mappedPath, realPath);
|
|
1593
|
+
}
|
|
1594
|
+
}
|
|
1595
|
+
return _this;
|
|
1596
|
+
}
|
|
1597
|
+
}
|
|
1598
|
+
exports.WASI = WASI;
|
|
1599
|
+
//# sourceMappingURL=preview1.js.map
|