@nimbus-sh/core 0.1.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/dist/_shared/ai-egress.d.ts +73 -0
- package/dist/_shared/ai-egress.d.ts.map +1 -0
- package/dist/_shared/ai-egress.js +88 -0
- package/dist/_shared/byte-stream.d.ts +59 -0
- package/dist/_shared/byte-stream.d.ts.map +1 -0
- package/dist/_shared/byte-stream.js +77 -0
- package/dist/_shared/bytes.d.ts +18 -0
- package/dist/_shared/bytes.d.ts.map +1 -0
- package/dist/_shared/bytes.js +17 -0
- package/dist/_shared/cache-stats.d.ts +145 -0
- package/dist/_shared/cache-stats.d.ts.map +1 -0
- package/dist/_shared/cache-stats.js +161 -0
- package/dist/_shared/crypto.d.ts +17 -0
- package/dist/_shared/crypto.d.ts.map +1 -0
- package/dist/_shared/crypto.js +131 -0
- package/dist/_shared/esbuild-facet-shim.d.ts +21 -0
- package/dist/_shared/esbuild-facet-shim.d.ts.map +1 -0
- package/dist/_shared/esbuild-facet-shim.js +22 -0
- package/dist/_shared/exports-resolver.d.ts +74 -0
- package/dist/_shared/exports-resolver.d.ts.map +1 -0
- package/dist/_shared/exports-resolver.js +284 -0
- package/dist/_shared/facet-vfs-cursor.d.ts +48 -0
- package/dist/_shared/facet-vfs-cursor.d.ts.map +1 -0
- package/dist/_shared/facet-vfs-cursor.js +51 -0
- package/dist/_shared/install-phase.d.ts +47 -0
- package/dist/_shared/install-phase.d.ts.map +1 -0
- package/dist/_shared/install-phase.js +1 -0
- package/dist/_shared/lru-map.d.ts +25 -0
- package/dist/_shared/lru-map.d.ts.map +1 -0
- package/dist/_shared/lru-map.js +57 -0
- package/dist/_shared/real-node-imports.d.ts +43 -0
- package/dist/_shared/real-node-imports.d.ts.map +1 -0
- package/dist/_shared/real-node-imports.js +52 -0
- package/dist/_shared/retry.d.ts +92 -0
- package/dist/_shared/retry.d.ts.map +1 -0
- package/dist/_shared/retry.js +155 -0
- package/dist/_shared/rpc-dispose.d.ts +4 -0
- package/dist/_shared/rpc-dispose.d.ts.map +1 -0
- package/dist/_shared/rpc-dispose.js +30 -0
- package/dist/_shared/terminal.d.ts +2 -0
- package/dist/_shared/terminal.d.ts.map +1 -0
- package/dist/_shared/terminal.js +3 -0
- package/dist/_shared/typescript-specifiers.d.ts +58 -0
- package/dist/_shared/typescript-specifiers.d.ts.map +1 -0
- package/dist/_shared/typescript-specifiers.js +84 -0
- package/dist/_shared/untrusted-request.d.ts +34 -0
- package/dist/_shared/untrusted-request.d.ts.map +1 -0
- package/dist/_shared/untrusted-request.js +74 -0
- package/dist/_shared/vfs-write-ledger.d.ts +3 -0
- package/dist/_shared/vfs-write-ledger.d.ts.map +1 -0
- package/dist/_shared/vfs-write-ledger.js +439 -0
- package/dist/_shared/w7-frame.d.ts +79 -0
- package/dist/_shared/w7-frame.d.ts.map +1 -0
- package/dist/_shared/w7-frame.js +839 -0
- package/dist/_shared/weighted-credit-pool.d.ts +61 -0
- package/dist/_shared/weighted-credit-pool.d.ts.map +1 -0
- package/dist/_shared/weighted-credit-pool.js +196 -0
- package/dist/constants.d.ts +64 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +264 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/observability/diag-counters.d.ts +236 -0
- package/dist/observability/diag-counters.d.ts.map +1 -0
- package/dist/observability/diag-counters.js +195 -0
- package/dist/observability/heap-estimate.d.ts +225 -0
- package/dist/observability/heap-estimate.d.ts.map +1 -0
- package/dist/observability/heap-estimate.js +185 -0
- package/dist/observability/heavy-alloc-coord.d.ts +93 -0
- package/dist/observability/heavy-alloc-coord.d.ts.map +1 -0
- package/dist/observability/heavy-alloc-coord.js +181 -0
- package/dist/observability/oom-classify.d.ts +138 -0
- package/dist/observability/oom-classify.d.ts.map +1 -0
- package/dist/observability/oom-classify.js +261 -0
- package/dist/observability/oom-discriminator.d.ts +176 -0
- package/dist/observability/oom-discriminator.d.ts.map +1 -0
- package/dist/observability/oom-discriminator.js +272 -0
- package/dist/runtime/assets-loader.d.ts +71 -0
- package/dist/runtime/assets-loader.d.ts.map +1 -0
- package/dist/runtime/assets-loader.js +139 -0
- package/dist/runtime/barrel-detect.d.ts +46 -0
- package/dist/runtime/barrel-detect.d.ts.map +1 -0
- package/dist/runtime/barrel-detect.js +73 -0
- package/dist/runtime/bash/preamble.d.ts +2 -0
- package/dist/runtime/bash/preamble.d.ts.map +1 -0
- package/dist/runtime/bash/preamble.js +1849 -0
- package/dist/runtime/bash/types.d.ts +433 -0
- package/dist/runtime/bash/types.d.ts.map +1 -0
- package/dist/runtime/bash/types.js +1 -0
- package/dist/runtime/bundle-profile.d.ts +14 -0
- package/dist/runtime/bundle-profile.d.ts.map +1 -0
- package/dist/runtime/bundle-profile.js +20 -0
- package/dist/runtime/cirrus-vite-config-rewriter.d.ts +2 -0
- package/dist/runtime/cirrus-vite-config-rewriter.d.ts.map +1 -0
- package/dist/runtime/cirrus-vite-config-rewriter.js +28 -0
- package/dist/runtime/cli-flags.d.ts +2 -0
- package/dist/runtime/cli-flags.d.ts.map +1 -0
- package/dist/runtime/cli-flags.js +11 -0
- package/dist/runtime/comment-strip.d.ts +37 -0
- package/dist/runtime/comment-strip.d.ts.map +1 -0
- package/dist/runtime/comment-strip.js +74 -0
- package/dist/runtime/cpython-preamble.d.ts +32 -0
- package/dist/runtime/cpython-preamble.d.ts.map +1 -0
- package/dist/runtime/cpython-preamble.js +296 -0
- package/dist/runtime/esbuild-service.d.ts +242 -0
- package/dist/runtime/esbuild-service.d.ts.map +1 -0
- package/dist/runtime/esbuild-service.js +1452 -0
- package/dist/runtime/framework-detect.d.ts +70 -0
- package/dist/runtime/framework-detect.d.ts.map +1 -0
- package/dist/runtime/framework-detect.js +177 -0
- package/dist/runtime/import-meta-transform.d.ts +3 -0
- package/dist/runtime/import-meta-transform.d.ts.map +1 -0
- package/dist/runtime/import-meta-transform.js +15 -0
- package/dist/runtime/javascript-ast.d.ts +13 -0
- package/dist/runtime/javascript-ast.d.ts.map +1 -0
- package/dist/runtime/javascript-ast.js +57 -0
- package/dist/runtime/long-running-handle.d.ts +119 -0
- package/dist/runtime/long-running-handle.d.ts.map +1 -0
- package/dist/runtime/long-running-handle.js +169 -0
- package/dist/runtime/module-source-rewriter.d.ts +11 -0
- package/dist/runtime/module-source-rewriter.d.ts.map +1 -0
- package/dist/runtime/module-source-rewriter.js +61 -0
- package/dist/runtime/opentui-wasm-backend.d.ts +160 -0
- package/dist/runtime/opentui-wasm-backend.d.ts.map +1 -0
- package/dist/runtime/opentui-wasm-backend.js +416 -0
- package/dist/runtime/os-contracts.d.ts +436 -0
- package/dist/runtime/os-contracts.d.ts.map +1 -0
- package/dist/runtime/os-contracts.js +101 -0
- package/dist/runtime/port-registry.d.ts +100 -0
- package/dist/runtime/port-registry.d.ts.map +1 -0
- package/dist/runtime/port-registry.js +265 -0
- package/dist/runtime/process-input-routing.d.ts +33 -0
- package/dist/runtime/process-input-routing.d.ts.map +1 -0
- package/dist/runtime/process-input-routing.js +59 -0
- package/dist/runtime/process-input.d.ts +39 -0
- package/dist/runtime/process-input.d.ts.map +1 -0
- package/dist/runtime/process-input.js +117 -0
- package/dist/runtime/process-io-protocol.d.ts +90 -0
- package/dist/runtime/process-io-protocol.d.ts.map +1 -0
- package/dist/runtime/process-io-protocol.js +81 -0
- package/dist/runtime/process-logs.d.ts +352 -0
- package/dist/runtime/process-logs.d.ts.map +1 -0
- package/dist/runtime/process-logs.js +750 -0
- package/dist/runtime/process-table.d.ts +101 -0
- package/dist/runtime/process-table.d.ts.map +1 -0
- package/dist/runtime/process-table.js +175 -0
- package/dist/runtime/project-detect.d.ts +21 -0
- package/dist/runtime/project-detect.d.ts.map +1 -0
- package/dist/runtime/project-detect.js +46 -0
- package/dist/runtime/python-server-adapter.d.ts +33 -0
- package/dist/runtime/python-server-adapter.d.ts.map +1 -0
- package/dist/runtime/python-server-adapter.js +132 -0
- package/dist/runtime/require-resolver.d.ts +44 -0
- package/dist/runtime/require-resolver.d.ts.map +1 -0
- package/dist/runtime/require-resolver.js +698 -0
- package/dist/runtime/router-basename.d.ts +36 -0
- package/dist/runtime/router-basename.d.ts.map +1 -0
- package/dist/runtime/router-basename.js +310 -0
- package/dist/runtime/ruby-green-threads.d.ts +136 -0
- package/dist/runtime/ruby-green-threads.d.ts.map +1 -0
- package/dist/runtime/ruby-green-threads.js +904 -0
- package/dist/runtime/ruby-socket-shim.d.ts +2 -0
- package/dist/runtime/ruby-socket-shim.d.ts.map +1 -0
- package/dist/runtime/ruby-socket-shim.js +548 -0
- package/dist/runtime/session-process-supervisor.d.ts +156 -0
- package/dist/runtime/session-process-supervisor.d.ts.map +1 -0
- package/dist/runtime/session-process-supervisor.js +238 -0
- package/dist/runtime/sqlite-runtime-fs-bridge.d.ts +70 -0
- package/dist/runtime/sqlite-runtime-fs-bridge.d.ts.map +1 -0
- package/dist/runtime/sqlite-runtime-fs-bridge.js +425 -0
- package/dist/runtime/streams.d.ts +13 -0
- package/dist/runtime/streams.d.ts.map +1 -0
- package/dist/runtime/streams.js +546 -0
- package/dist/runtime/undici-shim.d.ts +62 -0
- package/dist/runtime/undici-shim.d.ts.map +1 -0
- package/dist/runtime/undici-shim.js +516 -0
- package/dist/runtime/vfs-manifest.d.ts +63 -0
- package/dist/runtime/vfs-manifest.d.ts.map +1 -0
- package/dist/runtime/vfs-manifest.js +141 -0
- package/dist/runtime/vfs-snapshot.d.ts +75 -0
- package/dist/runtime/vfs-snapshot.d.ts.map +1 -0
- package/dist/runtime/vfs-snapshot.js +220 -0
- package/dist/runtime/virtual-socket-kernel.d.ts +252 -0
- package/dist/runtime/virtual-socket-kernel.d.ts.map +1 -0
- package/dist/runtime/virtual-socket-kernel.js +1143 -0
- package/dist/runtime/vite-config-parser.d.ts +13 -0
- package/dist/runtime/vite-config-parser.d.ts.map +1 -0
- package/dist/runtime/vite-config-parser.js +258 -0
- package/dist/runtime/wasi/types.d.ts +347 -0
- package/dist/runtime/wasi/types.d.ts.map +1 -0
- package/dist/runtime/wasi/types.js +1 -0
- package/dist/runtime/wasi-instance.d.ts +215 -0
- package/dist/runtime/wasi-instance.d.ts.map +1 -0
- package/dist/runtime/wasi-instance.generated.d.ts +14 -0
- package/dist/runtime/wasi-instance.generated.d.ts.map +1 -0
- package/dist/runtime/wasi-instance.generated.js +13 -0
- package/dist/runtime/wasi-instance.js +179 -0
- package/dist/runtime/wasi-threads.d.ts +169 -0
- package/dist/runtime/wasi-threads.d.ts.map +1 -0
- package/dist/runtime/wasi-threads.js +669 -0
- package/dist/runtime/wasm-memory.d.ts +84 -0
- package/dist/runtime/wasm-memory.d.ts.map +1 -0
- package/dist/runtime/wasm-memory.js +235 -0
- package/dist/shell/elevation-commands.d.ts +5 -0
- package/dist/shell/elevation-commands.d.ts.map +1 -0
- package/dist/shell/elevation-commands.js +109 -0
- package/dist/shell/exec-dispatch.d.ts +57 -0
- package/dist/shell/exec-dispatch.d.ts.map +1 -0
- package/dist/shell/exec-dispatch.js +181 -0
- package/dist/shell/features.d.ts +154 -0
- package/dist/shell/features.d.ts.map +1 -0
- package/dist/shell/features.js +792 -0
- package/dist/shell/shell-entrypoints.d.ts +55 -0
- package/dist/shell/shell-entrypoints.d.ts.map +1 -0
- package/dist/shell/shell-entrypoints.js +230 -0
- package/dist/shell/shell-invocation.d.ts +36 -0
- package/dist/shell/shell-invocation.d.ts.map +1 -0
- package/dist/shell/shell-invocation.js +148 -0
- package/dist/shell/unix-accounts.d.ts +27 -0
- package/dist/shell/unix-accounts.d.ts.map +1 -0
- package/dist/shell/unix-accounts.js +105 -0
- package/dist/shell/unix-commands.d.ts +15 -0
- package/dist/shell/unix-commands.d.ts.map +1 -0
- package/dist/shell/unix-commands.js +4702 -0
- package/dist/substrate/lifo/commands/archive/gunzip.d.ts +4 -0
- package/dist/substrate/lifo/commands/archive/gunzip.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/archive/gunzip.js +58 -0
- package/dist/substrate/lifo/commands/archive/gzip.d.ts +4 -0
- package/dist/substrate/lifo/commands/archive/gzip.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/archive/gzip.js +73 -0
- package/dist/substrate/lifo/commands/archive/tar.d.ts +4 -0
- package/dist/substrate/lifo/commands/archive/tar.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/archive/tar.js +158 -0
- package/dist/substrate/lifo/commands/archive/unzip.d.ts +4 -0
- package/dist/substrate/lifo/commands/archive/unzip.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/archive/unzip.js +114 -0
- package/dist/substrate/lifo/commands/archive/zip.d.ts +4 -0
- package/dist/substrate/lifo/commands/archive/zip.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/archive/zip.js +58 -0
- package/dist/substrate/lifo/commands/fs/basename.d.ts +4 -0
- package/dist/substrate/lifo/commands/fs/basename.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/fs/basename.js +12 -0
- package/dist/substrate/lifo/commands/fs/cat.d.ts +4 -0
- package/dist/substrate/lifo/commands/fs/cat.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/fs/cat.js +52 -0
- package/dist/substrate/lifo/commands/fs/chmod.d.ts +25 -0
- package/dist/substrate/lifo/commands/fs/chmod.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/fs/chmod.js +97 -0
- package/dist/substrate/lifo/commands/fs/chown.d.ts +4 -0
- package/dist/substrate/lifo/commands/fs/chown.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/fs/chown.js +41 -0
- package/dist/substrate/lifo/commands/fs/cp.d.ts +4 -0
- package/dist/substrate/lifo/commands/fs/cp.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/fs/cp.js +29 -0
- package/dist/substrate/lifo/commands/fs/df.d.ts +4 -0
- package/dist/substrate/lifo/commands/fs/df.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/fs/df.js +52 -0
- package/dist/substrate/lifo/commands/fs/dirname.d.ts +4 -0
- package/dist/substrate/lifo/commands/fs/dirname.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/fs/dirname.js +12 -0
- package/dist/substrate/lifo/commands/fs/du.d.ts +4 -0
- package/dist/substrate/lifo/commands/fs/du.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/fs/du.js +104 -0
- package/dist/substrate/lifo/commands/fs/file.d.ts +4 -0
- package/dist/substrate/lifo/commands/fs/file.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/fs/file.js +84 -0
- package/dist/substrate/lifo/commands/fs/find.d.ts +4 -0
- package/dist/substrate/lifo/commands/fs/find.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/fs/find.js +72 -0
- package/dist/substrate/lifo/commands/fs/ln.d.ts +4 -0
- package/dist/substrate/lifo/commands/fs/ln.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/fs/ln.js +15 -0
- package/dist/substrate/lifo/commands/fs/ls.d.ts +4 -0
- package/dist/substrate/lifo/commands/fs/ls.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/fs/ls.js +146 -0
- package/dist/substrate/lifo/commands/fs/mkdir.d.ts +4 -0
- package/dist/substrate/lifo/commands/fs/mkdir.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/fs/mkdir.js +31 -0
- package/dist/substrate/lifo/commands/fs/mktemp.d.ts +4 -0
- package/dist/substrate/lifo/commands/fs/mktemp.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/fs/mktemp.js +48 -0
- package/dist/substrate/lifo/commands/fs/mv.d.ts +4 -0
- package/dist/substrate/lifo/commands/fs/mv.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/fs/mv.js +113 -0
- package/dist/substrate/lifo/commands/fs/realpath.d.ts +4 -0
- package/dist/substrate/lifo/commands/fs/realpath.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/fs/realpath.js +27 -0
- package/dist/substrate/lifo/commands/fs/rm.d.ts +4 -0
- package/dist/substrate/lifo/commands/fs/rm.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/fs/rm.js +48 -0
- package/dist/substrate/lifo/commands/fs/rmdir.d.ts +4 -0
- package/dist/substrate/lifo/commands/fs/rmdir.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/fs/rmdir.js +44 -0
- package/dist/substrate/lifo/commands/fs/stat.d.ts +4 -0
- package/dist/substrate/lifo/commands/fs/stat.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/fs/stat.js +35 -0
- package/dist/substrate/lifo/commands/fs/touch.d.ts +4 -0
- package/dist/substrate/lifo/commands/fs/touch.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/fs/touch.js +26 -0
- package/dist/substrate/lifo/commands/fs/tree.d.ts +4 -0
- package/dist/substrate/lifo/commands/fs/tree.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/fs/tree.js +69 -0
- package/dist/substrate/lifo/commands/index.d.ts +3 -0
- package/dist/substrate/lifo/commands/index.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/index.js +1 -0
- package/dist/substrate/lifo/commands/io/dd.d.ts +4 -0
- package/dist/substrate/lifo/commands/io/dd.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/io/dd.js +256 -0
- package/dist/substrate/lifo/commands/io/printf.d.ts +4 -0
- package/dist/substrate/lifo/commands/io/printf.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/io/printf.js +82 -0
- package/dist/substrate/lifo/commands/io/tee.d.ts +4 -0
- package/dist/substrate/lifo/commands/io/tee.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/io/tee.js +31 -0
- package/dist/substrate/lifo/commands/io/xargs.d.ts +4 -0
- package/dist/substrate/lifo/commands/io/xargs.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/io/xargs.js +44 -0
- package/dist/substrate/lifo/commands/io/yes.d.ts +4 -0
- package/dist/substrate/lifo/commands/io/yes.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/io/yes.js +10 -0
- package/dist/substrate/lifo/commands/net/curl.d.ts +6 -0
- package/dist/substrate/lifo/commands/net/curl.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/net/curl.js +617 -0
- package/dist/substrate/lifo/commands/net/dig.d.ts +4 -0
- package/dist/substrate/lifo/commands/net/dig.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/net/dig.js +77 -0
- package/dist/substrate/lifo/commands/net/forward.d.ts +14 -0
- package/dist/substrate/lifo/commands/net/forward.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/net/forward.js +80 -0
- package/dist/substrate/lifo/commands/net/host.d.ts +14 -0
- package/dist/substrate/lifo/commands/net/host.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/net/host.js +160 -0
- package/dist/substrate/lifo/commands/net/ifconfig.d.ts +8 -0
- package/dist/substrate/lifo/commands/net/ifconfig.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/net/ifconfig.js +120 -0
- package/dist/substrate/lifo/commands/net/ip.d.ts +14 -0
- package/dist/substrate/lifo/commands/net/ip.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/net/ip.js +508 -0
- package/dist/substrate/lifo/commands/net/netstat.d.ts +8 -0
- package/dist/substrate/lifo/commands/net/netstat.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/net/netstat.js +94 -0
- package/dist/substrate/lifo/commands/net/ping.d.ts +4 -0
- package/dist/substrate/lifo/commands/net/ping.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/net/ping.js +64 -0
- package/dist/substrate/lifo/commands/net/ports.d.ts +8 -0
- package/dist/substrate/lifo/commands/net/ports.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/net/ports.js +36 -0
- package/dist/substrate/lifo/commands/net/route.d.ts +8 -0
- package/dist/substrate/lifo/commands/net/route.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/net/route.js +128 -0
- package/dist/substrate/lifo/commands/net/tunnel-v2.d.ts +4 -0
- package/dist/substrate/lifo/commands/net/tunnel-v2.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/net/tunnel-v2.js +141 -0
- package/dist/substrate/lifo/commands/net/tunnel.d.ts +6 -0
- package/dist/substrate/lifo/commands/net/tunnel.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/net/tunnel.js +232 -0
- package/dist/substrate/lifo/commands/net/wget.d.ts +4 -0
- package/dist/substrate/lifo/commands/net/wget.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/net/wget.js +78 -0
- package/dist/substrate/lifo/commands/registry.d.ts +15 -0
- package/dist/substrate/lifo/commands/registry.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/registry.js +120 -0
- package/dist/substrate/lifo/commands/signal.d.ts +12 -0
- package/dist/substrate/lifo/commands/signal.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/signal.js +47 -0
- package/dist/substrate/lifo/commands/system/bc.d.ts +4 -0
- package/dist/substrate/lifo/commands/system/bc.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/system/bc.js +243 -0
- package/dist/substrate/lifo/commands/system/cal.d.ts +4 -0
- package/dist/substrate/lifo/commands/system/cal.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/system/cal.js +81 -0
- package/dist/substrate/lifo/commands/system/date.d.ts +4 -0
- package/dist/substrate/lifo/commands/system/date.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/system/date.js +79 -0
- package/dist/substrate/lifo/commands/system/env.d.ts +4 -0
- package/dist/substrate/lifo/commands/system/env.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/system/env.js +7 -0
- package/dist/substrate/lifo/commands/system/fastfetch.d.ts +4 -0
- package/dist/substrate/lifo/commands/system/fastfetch.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/system/fastfetch.js +385 -0
- package/dist/substrate/lifo/commands/system/free.d.ts +4 -0
- package/dist/substrate/lifo/commands/system/free.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/system/free.js +36 -0
- package/dist/substrate/lifo/commands/system/help.d.ts +4 -0
- package/dist/substrate/lifo/commands/system/help.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/system/help.js +46 -0
- package/dist/substrate/lifo/commands/system/hostname.d.ts +4 -0
- package/dist/substrate/lifo/commands/system/hostname.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/system/hostname.js +6 -0
- package/dist/substrate/lifo/commands/system/kill.d.ts +4 -0
- package/dist/substrate/lifo/commands/system/kill.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/system/kill.js +76 -0
- package/dist/substrate/lifo/commands/system/lifo.d.ts +41 -0
- package/dist/substrate/lifo/commands/system/lifo.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/system/lifo.js +446 -0
- package/dist/substrate/lifo/commands/system/logout.d.ts +5 -0
- package/dist/substrate/lifo/commands/system/logout.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/system/logout.js +15 -0
- package/dist/substrate/lifo/commands/system/man.d.ts +4 -0
- package/dist/substrate/lifo/commands/system/man.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/system/man.js +144 -0
- package/dist/substrate/lifo/commands/system/node.d.ts +6 -0
- package/dist/substrate/lifo/commands/system/node.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/system/node.js +1241 -0
- package/dist/substrate/lifo/commands/system/npm.d.ts +26 -0
- package/dist/substrate/lifo/commands/system/npm.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/system/npm.js +934 -0
- package/dist/substrate/lifo/commands/system/pkg.d.ts +4 -0
- package/dist/substrate/lifo/commands/system/pkg.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/system/pkg.js +97 -0
- package/dist/substrate/lifo/commands/system/ps.d.ts +5 -0
- package/dist/substrate/lifo/commands/system/ps.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/system/ps.js +35 -0
- package/dist/substrate/lifo/commands/system/registry-schemas.d.ts +44 -0
- package/dist/substrate/lifo/commands/system/registry-schemas.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/system/registry-schemas.js +28 -0
- package/dist/substrate/lifo/commands/system/sha256sum.d.ts +4 -0
- package/dist/substrate/lifo/commands/system/sha256sum.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/system/sha256sum.js +86 -0
- package/dist/substrate/lifo/commands/system/sl.d.ts +4 -0
- package/dist/substrate/lifo/commands/system/sl.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/system/sl.js +204 -0
- package/dist/substrate/lifo/commands/system/sleep.d.ts +4 -0
- package/dist/substrate/lifo/commands/system/sleep.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/system/sleep.js +27 -0
- package/dist/substrate/lifo/commands/system/stty.d.ts +4 -0
- package/dist/substrate/lifo/commands/system/stty.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/system/stty.js +61 -0
- package/dist/substrate/lifo/commands/system/systemctl.d.ts +4 -0
- package/dist/substrate/lifo/commands/system/systemctl.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/system/systemctl.js +164 -0
- package/dist/substrate/lifo/commands/system/top.d.ts +4 -0
- package/dist/substrate/lifo/commands/system/top.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/system/top.js +38 -0
- package/dist/substrate/lifo/commands/system/uname.d.ts +4 -0
- package/dist/substrate/lifo/commands/system/uname.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/system/uname.js +55 -0
- package/dist/substrate/lifo/commands/system/uptime.d.ts +4 -0
- package/dist/substrate/lifo/commands/system/uptime.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/system/uptime.js +16 -0
- package/dist/substrate/lifo/commands/system/watch.d.ts +4 -0
- package/dist/substrate/lifo/commands/system/watch.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/system/watch.js +53 -0
- package/dist/substrate/lifo/commands/system/which.d.ts +4 -0
- package/dist/substrate/lifo/commands/system/which.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/system/which.js +45 -0
- package/dist/substrate/lifo/commands/system/whoami.d.ts +4 -0
- package/dist/substrate/lifo/commands/system/whoami.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/system/whoami.js +6 -0
- package/dist/substrate/lifo/commands/text/awk.d.ts +4 -0
- package/dist/substrate/lifo/commands/text/awk.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/text/awk.js +200 -0
- package/dist/substrate/lifo/commands/text/base64.d.ts +4 -0
- package/dist/substrate/lifo/commands/text/base64.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/text/base64.js +102 -0
- package/dist/substrate/lifo/commands/text/cut.d.ts +4 -0
- package/dist/substrate/lifo/commands/text/cut.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/text/cut.js +91 -0
- package/dist/substrate/lifo/commands/text/diff.d.ts +4 -0
- package/dist/substrate/lifo/commands/text/diff.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/text/diff.js +292 -0
- package/dist/substrate/lifo/commands/text/grep.d.ts +4 -0
- package/dist/substrate/lifo/commands/text/grep.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/text/grep.js +189 -0
- package/dist/substrate/lifo/commands/text/head.d.ts +4 -0
- package/dist/substrate/lifo/commands/text/head.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/text/head.js +111 -0
- package/dist/substrate/lifo/commands/text/less.d.ts +4 -0
- package/dist/substrate/lifo/commands/text/less.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/text/less.js +335 -0
- package/dist/substrate/lifo/commands/text/nano.d.ts +4 -0
- package/dist/substrate/lifo/commands/text/nano.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/text/nano.js +510 -0
- package/dist/substrate/lifo/commands/text/nl.d.ts +4 -0
- package/dist/substrate/lifo/commands/text/nl.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/text/nl.js +64 -0
- package/dist/substrate/lifo/commands/text/rev.d.ts +4 -0
- package/dist/substrate/lifo/commands/text/rev.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/text/rev.js +41 -0
- package/dist/substrate/lifo/commands/text/sed.d.ts +21 -0
- package/dist/substrate/lifo/commands/text/sed.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/text/sed.js +248 -0
- package/dist/substrate/lifo/commands/text/seq.d.ts +4 -0
- package/dist/substrate/lifo/commands/text/seq.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/text/seq.js +69 -0
- package/dist/substrate/lifo/commands/text/sort.d.ts +4 -0
- package/dist/substrate/lifo/commands/text/sort.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/text/sort.js +90 -0
- package/dist/substrate/lifo/commands/text/strings.d.ts +4 -0
- package/dist/substrate/lifo/commands/text/strings.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/text/strings.js +69 -0
- package/dist/substrate/lifo/commands/text/tac.d.ts +4 -0
- package/dist/substrate/lifo/commands/text/tac.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/text/tac.js +32 -0
- package/dist/substrate/lifo/commands/text/tail.d.ts +4 -0
- package/dist/substrate/lifo/commands/text/tail.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/text/tail.js +64 -0
- package/dist/substrate/lifo/commands/text/tr.d.ts +4 -0
- package/dist/substrate/lifo/commands/text/tr.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/text/tr.js +180 -0
- package/dist/substrate/lifo/commands/text/uniq.d.ts +4 -0
- package/dist/substrate/lifo/commands/text/uniq.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/text/uniq.js +82 -0
- package/dist/substrate/lifo/commands/text/wc.d.ts +4 -0
- package/dist/substrate/lifo/commands/text/wc.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/text/wc.js +107 -0
- package/dist/substrate/lifo/commands/types.d.ts +49 -0
- package/dist/substrate/lifo/commands/types.d.ts.map +1 -0
- package/dist/substrate/lifo/commands/types.js +1 -0
- package/dist/substrate/lifo/index.d.ts +67 -0
- package/dist/substrate/lifo/index.d.ts.map +1 -0
- package/dist/substrate/lifo/index.js +66 -0
- package/dist/substrate/lifo/kernel/ServiceManager.d.ts +51 -0
- package/dist/substrate/lifo/kernel/ServiceManager.d.ts.map +1 -0
- package/dist/substrate/lifo/kernel/ServiceManager.js +302 -0
- package/dist/substrate/lifo/kernel/index.d.ts +40 -0
- package/dist/substrate/lifo/kernel/index.d.ts.map +1 -0
- package/dist/substrate/lifo/kernel/index.js +170 -0
- package/dist/substrate/lifo/kernel/network/Bridge.d.ts +110 -0
- package/dist/substrate/lifo/kernel/network/Bridge.d.ts.map +1 -0
- package/dist/substrate/lifo/kernel/network/Bridge.js +278 -0
- package/dist/substrate/lifo/kernel/network/DNSResolver.d.ts +50 -0
- package/dist/substrate/lifo/kernel/network/DNSResolver.d.ts.map +1 -0
- package/dist/substrate/lifo/kernel/network/DNSResolver.js +135 -0
- package/dist/substrate/lifo/kernel/network/NetworkInterface.d.ts +83 -0
- package/dist/substrate/lifo/kernel/network/NetworkInterface.d.ts.map +1 -0
- package/dist/substrate/lifo/kernel/network/NetworkInterface.js +183 -0
- package/dist/substrate/lifo/kernel/network/NetworkNamespace.d.ts +98 -0
- package/dist/substrate/lifo/kernel/network/NetworkNamespace.d.ts.map +1 -0
- package/dist/substrate/lifo/kernel/network/NetworkNamespace.js +149 -0
- package/dist/substrate/lifo/kernel/network/NetworkStack.d.ts +178 -0
- package/dist/substrate/lifo/kernel/network/NetworkStack.d.ts.map +1 -0
- package/dist/substrate/lifo/kernel/network/NetworkStack.js +460 -0
- package/dist/substrate/lifo/kernel/network/PortBridge.d.ts +44 -0
- package/dist/substrate/lifo/kernel/network/PortBridge.d.ts.map +1 -0
- package/dist/substrate/lifo/kernel/network/PortBridge.js +158 -0
- package/dist/substrate/lifo/kernel/network/RoutingTable.d.ts +55 -0
- package/dist/substrate/lifo/kernel/network/RoutingTable.d.ts.map +1 -0
- package/dist/substrate/lifo/kernel/network/RoutingTable.js +167 -0
- package/dist/substrate/lifo/kernel/network/Socket.d.ts +65 -0
- package/dist/substrate/lifo/kernel/network/Socket.d.ts.map +1 -0
- package/dist/substrate/lifo/kernel/network/Socket.js +201 -0
- package/dist/substrate/lifo/kernel/network/index.d.ts +11 -0
- package/dist/substrate/lifo/kernel/network/index.d.ts.map +1 -0
- package/dist/substrate/lifo/kernel/network/index.js +9 -0
- package/dist/substrate/lifo/kernel/network/tunnel/BaseTunnel.d.ts +55 -0
- package/dist/substrate/lifo/kernel/network/tunnel/BaseTunnel.d.ts.map +1 -0
- package/dist/substrate/lifo/kernel/network/tunnel/BaseTunnel.js +88 -0
- package/dist/substrate/lifo/kernel/network/tunnel/VETHPair.d.ts +71 -0
- package/dist/substrate/lifo/kernel/network/tunnel/VETHPair.d.ts.map +1 -0
- package/dist/substrate/lifo/kernel/network/tunnel/VETHPair.js +191 -0
- package/dist/substrate/lifo/kernel/network/tunnel/WebSocketTunnel.d.ts +89 -0
- package/dist/substrate/lifo/kernel/network/tunnel/WebSocketTunnel.d.ts.map +1 -0
- package/dist/substrate/lifo/kernel/network/tunnel/WebSocketTunnel.js +324 -0
- package/dist/substrate/lifo/kernel/network/types.d.ts +159 -0
- package/dist/substrate/lifo/kernel/network/types.d.ts.map +1 -0
- package/dist/substrate/lifo/kernel/network/types.js +5 -0
- package/dist/substrate/lifo/kernel/persistence/PersistenceManager.d.ts +12 -0
- package/dist/substrate/lifo/kernel/persistence/PersistenceManager.d.ts.map +1 -0
- package/dist/substrate/lifo/kernel/persistence/PersistenceManager.js +47 -0
- package/dist/substrate/lifo/kernel/persistence/backends.d.ts +15 -0
- package/dist/substrate/lifo/kernel/persistence/backends.d.ts.map +1 -0
- package/dist/substrate/lifo/kernel/persistence/backends.js +18 -0
- package/dist/substrate/lifo/kernel/persistence/index.d.ts +6 -0
- package/dist/substrate/lifo/kernel/persistence/index.d.ts.map +1 -0
- package/dist/substrate/lifo/kernel/persistence/index.js +3 -0
- package/dist/substrate/lifo/kernel/persistence/serializer.d.ts +21 -0
- package/dist/substrate/lifo/kernel/persistence/serializer.d.ts.map +1 -0
- package/dist/substrate/lifo/kernel/persistence/serializer.js +99 -0
- package/dist/substrate/lifo/kernel/samples.d.ts +3 -0
- package/dist/substrate/lifo/kernel/samples.d.ts.map +1 -0
- package/dist/substrate/lifo/kernel/samples.js +930 -0
- package/dist/substrate/lifo/kernel/storage/BlobStore.d.ts +22 -0
- package/dist/substrate/lifo/kernel/storage/BlobStore.d.ts.map +1 -0
- package/dist/substrate/lifo/kernel/storage/BlobStore.js +84 -0
- package/dist/substrate/lifo/kernel/storage/ContentStore.d.ts +54 -0
- package/dist/substrate/lifo/kernel/storage/ContentStore.d.ts.map +1 -0
- package/dist/substrate/lifo/kernel/storage/ContentStore.js +120 -0
- package/dist/substrate/lifo/kernel/storage/index.d.ts +6 -0
- package/dist/substrate/lifo/kernel/storage/index.d.ts.map +1 -0
- package/dist/substrate/lifo/kernel/storage/index.js +3 -0
- package/dist/substrate/lifo/kernel/unit-parser.d.ts +22 -0
- package/dist/substrate/lifo/kernel/unit-parser.d.ts.map +1 -0
- package/dist/substrate/lifo/kernel/unit-parser.js +80 -0
- package/dist/substrate/lifo/kernel/vfs/VFS.d.ts +99 -0
- package/dist/substrate/lifo/kernel/vfs/VFS.d.ts.map +1 -0
- package/dist/substrate/lifo/kernel/vfs/VFS.js +679 -0
- package/dist/substrate/lifo/kernel/vfs/index.d.ts +8 -0
- package/dist/substrate/lifo/kernel/vfs/index.d.ts.map +1 -0
- package/dist/substrate/lifo/kernel/vfs/index.js +5 -0
- package/dist/substrate/lifo/kernel/vfs/providers/DevProvider.d.ts +21 -0
- package/dist/substrate/lifo/kernel/vfs/providers/DevProvider.d.ts.map +1 -0
- package/dist/substrate/lifo/kernel/vfs/providers/DevProvider.js +137 -0
- package/dist/substrate/lifo/kernel/vfs/providers/NativeFsProvider.d.ts +63 -0
- package/dist/substrate/lifo/kernel/vfs/providers/NativeFsProvider.d.ts.map +1 -0
- package/dist/substrate/lifo/kernel/vfs/providers/NativeFsProvider.js +175 -0
- package/dist/substrate/lifo/kernel/vfs/providers/ProcProvider.d.ts +14 -0
- package/dist/substrate/lifo/kernel/vfs/providers/ProcProvider.d.ts.map +1 -0
- package/dist/substrate/lifo/kernel/vfs/providers/ProcProvider.js +126 -0
- package/dist/substrate/lifo/kernel/vfs/types.d.ts +117 -0
- package/dist/substrate/lifo/kernel/vfs/types.d.ts.map +1 -0
- package/dist/substrate/lifo/kernel/vfs/types.js +42 -0
- package/dist/substrate/lifo/node-compat/buffer.d.ts +44 -0
- package/dist/substrate/lifo/node-compat/buffer.d.ts.map +1 -0
- package/dist/substrate/lifo/node-compat/buffer.js +331 -0
- package/dist/substrate/lifo/node-compat/child_process.d.ts +10 -0
- package/dist/substrate/lifo/node-compat/child_process.d.ts.map +1 -0
- package/dist/substrate/lifo/node-compat/child_process.js +42 -0
- package/dist/substrate/lifo/node-compat/console.d.ts +21 -0
- package/dist/substrate/lifo/node-compat/console.d.ts.map +1 -0
- package/dist/substrate/lifo/node-compat/console.js +68 -0
- package/dist/substrate/lifo/node-compat/crypto.d.ts +24 -0
- package/dist/substrate/lifo/node-compat/crypto.d.ts.map +1 -0
- package/dist/substrate/lifo/node-compat/crypto.js +216 -0
- package/dist/substrate/lifo/node-compat/dns.d.ts +117 -0
- package/dist/substrate/lifo/node-compat/dns.d.ts.map +1 -0
- package/dist/substrate/lifo/node-compat/dns.js +144 -0
- package/dist/substrate/lifo/node-compat/esbuild.d.ts +10 -0
- package/dist/substrate/lifo/node-compat/esbuild.d.ts.map +1 -0
- package/dist/substrate/lifo/node-compat/esbuild.js +70 -0
- package/dist/substrate/lifo/node-compat/events.d.ts +19 -0
- package/dist/substrate/lifo/node-compat/events.d.ts.map +1 -0
- package/dist/substrate/lifo/node-compat/events.js +83 -0
- package/dist/substrate/lifo/node-compat/fs.d.ts +195 -0
- package/dist/substrate/lifo/node-compat/fs.d.ts.map +1 -0
- package/dist/substrate/lifo/node-compat/fs.js +624 -0
- package/dist/substrate/lifo/node-compat/http.d.ts +133 -0
- package/dist/substrate/lifo/node-compat/http.d.ts.map +1 -0
- package/dist/substrate/lifo/node-compat/http.js +452 -0
- package/dist/substrate/lifo/node-compat/index.d.ts +20 -0
- package/dist/substrate/lifo/node-compat/index.d.ts.map +1 -0
- package/dist/substrate/lifo/node-compat/index.js +291 -0
- package/dist/substrate/lifo/node-compat/module.d.ts +55 -0
- package/dist/substrate/lifo/node-compat/module.d.ts.map +1 -0
- package/dist/substrate/lifo/node-compat/module.js +124 -0
- package/dist/substrate/lifo/node-compat/os.d.ts +39 -0
- package/dist/substrate/lifo/node-compat/os.d.ts.map +1 -0
- package/dist/substrate/lifo/node-compat/os.js +45 -0
- package/dist/substrate/lifo/node-compat/path.d.ts +86 -0
- package/dist/substrate/lifo/node-compat/path.d.ts.map +1 -0
- package/dist/substrate/lifo/node-compat/path.js +49 -0
- package/dist/substrate/lifo/node-compat/process.d.ts +127 -0
- package/dist/substrate/lifo/node-compat/process.d.ts.map +1 -0
- package/dist/substrate/lifo/node-compat/process.js +173 -0
- package/dist/substrate/lifo/node-compat/readline.d.ts +85 -0
- package/dist/substrate/lifo/node-compat/readline.d.ts.map +1 -0
- package/dist/substrate/lifo/node-compat/readline.js +205 -0
- package/dist/substrate/lifo/node-compat/rimraf.d.ts +30 -0
- package/dist/substrate/lifo/node-compat/rimraf.d.ts.map +1 -0
- package/dist/substrate/lifo/node-compat/rimraf.js +63 -0
- package/dist/substrate/lifo/node-compat/stream.d.ts +36 -0
- package/dist/substrate/lifo/node-compat/stream.d.ts.map +1 -0
- package/dist/substrate/lifo/node-compat/stream.js +90 -0
- package/dist/substrate/lifo/node-compat/string_decoder.d.ts +11 -0
- package/dist/substrate/lifo/node-compat/string_decoder.d.ts.map +1 -0
- package/dist/substrate/lifo/node-compat/string_decoder.js +23 -0
- package/dist/substrate/lifo/node-compat/timers.d.ts +16 -0
- package/dist/substrate/lifo/node-compat/timers.d.ts.map +1 -0
- package/dist/substrate/lifo/node-compat/timers.js +18 -0
- package/dist/substrate/lifo/node-compat/tty.d.ts +32 -0
- package/dist/substrate/lifo/node-compat/tty.d.ts.map +1 -0
- package/dist/substrate/lifo/node-compat/tty.js +76 -0
- package/dist/substrate/lifo/node-compat/url.d.ts +37 -0
- package/dist/substrate/lifo/node-compat/url.d.ts.map +1 -0
- package/dist/substrate/lifo/node-compat/url.js +65 -0
- package/dist/substrate/lifo/node-compat/util.d.ts +42 -0
- package/dist/substrate/lifo/node-compat/util.d.ts.map +1 -0
- package/dist/substrate/lifo/node-compat/util.js +132 -0
- package/dist/substrate/lifo/node-compat/zlib.d.ts +66 -0
- package/dist/substrate/lifo/node-compat/zlib.d.ts.map +1 -0
- package/dist/substrate/lifo/node-compat/zlib.js +80 -0
- package/dist/substrate/lifo/pkg/PackageManager.d.ts +19 -0
- package/dist/substrate/lifo/pkg/PackageManager.d.ts.map +1 -0
- package/dist/substrate/lifo/pkg/PackageManager.js +97 -0
- package/dist/substrate/lifo/pkg/lifo-dev.d.ts +38 -0
- package/dist/substrate/lifo/pkg/lifo-dev.d.ts.map +1 -0
- package/dist/substrate/lifo/pkg/lifo-dev.js +98 -0
- package/dist/substrate/lifo/pkg/lifo-runtime.d.ts +44 -0
- package/dist/substrate/lifo/pkg/lifo-runtime.d.ts.map +1 -0
- package/dist/substrate/lifo/pkg/lifo-runtime.js +372 -0
- package/dist/substrate/lifo/pkg/loader.d.ts +4 -0
- package/dist/substrate/lifo/pkg/loader.d.ts.map +1 -0
- package/dist/substrate/lifo/pkg/loader.js +24 -0
- package/dist/substrate/lifo/sandbox/HeadlessTerminal.d.ts +18 -0
- package/dist/substrate/lifo/sandbox/HeadlessTerminal.d.ts.map +1 -0
- package/dist/substrate/lifo/sandbox/HeadlessTerminal.js +28 -0
- package/dist/substrate/lifo/sandbox/Sandbox.d.ts +59 -0
- package/dist/substrate/lifo/sandbox/Sandbox.d.ts.map +1 -0
- package/dist/substrate/lifo/sandbox/Sandbox.js +234 -0
- package/dist/substrate/lifo/sandbox/SandboxCommands.d.ts +18 -0
- package/dist/substrate/lifo/sandbox/SandboxCommands.d.ts.map +1 -0
- package/dist/substrate/lifo/sandbox/SandboxCommands.js +64 -0
- package/dist/substrate/lifo/sandbox/SandboxFs.d.ts +43 -0
- package/dist/substrate/lifo/sandbox/SandboxFs.d.ts.map +1 -0
- package/dist/substrate/lifo/sandbox/SandboxFs.js +136 -0
- package/dist/substrate/lifo/sandbox/index.d.ts +3 -0
- package/dist/substrate/lifo/sandbox/index.d.ts.map +1 -0
- package/dist/substrate/lifo/sandbox/index.js +1 -0
- package/dist/substrate/lifo/sandbox/types.d.ts +116 -0
- package/dist/substrate/lifo/sandbox/types.d.ts.map +1 -0
- package/dist/substrate/lifo/sandbox/types.js +1 -0
- package/dist/substrate/lifo/shell/ProcessRegistry.d.ts +142 -0
- package/dist/substrate/lifo/shell/ProcessRegistry.d.ts.map +1 -0
- package/dist/substrate/lifo/shell/ProcessRegistry.js +256 -0
- package/dist/substrate/lifo/shell/Shell.d.ts +170 -0
- package/dist/substrate/lifo/shell/Shell.d.ts.map +1 -0
- package/dist/substrate/lifo/shell/Shell.js +1863 -0
- package/dist/substrate/lifo/shell/completer.d.ts +19 -0
- package/dist/substrate/lifo/shell/completer.d.ts.map +1 -0
- package/dist/substrate/lifo/shell/completer.js +164 -0
- package/dist/substrate/lifo/shell/default-shell.d.ts +9 -0
- package/dist/substrate/lifo/shell/default-shell.d.ts.map +1 -0
- package/dist/substrate/lifo/shell/default-shell.js +53 -0
- package/dist/substrate/lifo/shell/expander.d.ts +48 -0
- package/dist/substrate/lifo/shell/expander.d.ts.map +1 -0
- package/dist/substrate/lifo/shell/expander.js +1204 -0
- package/dist/substrate/lifo/shell/history.d.ts +22 -0
- package/dist/substrate/lifo/shell/history.d.ts.map +1 -0
- package/dist/substrate/lifo/shell/history.js +121 -0
- package/dist/substrate/lifo/shell/interpreter.d.ts +257 -0
- package/dist/substrate/lifo/shell/interpreter.d.ts.map +1 -0
- package/dist/substrate/lifo/shell/interpreter.js +1490 -0
- package/dist/substrate/lifo/shell/jobs.d.ts +21 -0
- package/dist/substrate/lifo/shell/jobs.d.ts.map +1 -0
- package/dist/substrate/lifo/shell/jobs.js +48 -0
- package/dist/substrate/lifo/shell/lexer.d.ts +13 -0
- package/dist/substrate/lifo/shell/lexer.d.ts.map +1 -0
- package/dist/substrate/lifo/shell/lexer.js +614 -0
- package/dist/substrate/lifo/shell/parser.d.ts +7 -0
- package/dist/substrate/lifo/shell/parser.d.ts.map +1 -0
- package/dist/substrate/lifo/shell/parser.js +573 -0
- package/dist/substrate/lifo/shell/pipe.d.ts +15 -0
- package/dist/substrate/lifo/shell/pipe.d.ts.map +1 -0
- package/dist/substrate/lifo/shell/pipe.js +86 -0
- package/dist/substrate/lifo/shell/signals.d.ts +11 -0
- package/dist/substrate/lifo/shell/signals.d.ts.map +1 -0
- package/dist/substrate/lifo/shell/signals.js +57 -0
- package/dist/substrate/lifo/shell/terminal-stdin.d.ts +28 -0
- package/dist/substrate/lifo/shell/terminal-stdin.d.ts.map +1 -0
- package/dist/substrate/lifo/shell/terminal-stdin.js +100 -0
- package/dist/substrate/lifo/shell/test-builtin.d.ts +16 -0
- package/dist/substrate/lifo/shell/test-builtin.d.ts.map +1 -0
- package/dist/substrate/lifo/shell/test-builtin.js +237 -0
- package/dist/substrate/lifo/shell/types.d.ts +140 -0
- package/dist/substrate/lifo/shell/types.d.ts.map +1 -0
- package/dist/substrate/lifo/shell/types.js +25 -0
- package/dist/substrate/lifo/terminal/ITerminal.d.ts +10 -0
- package/dist/substrate/lifo/terminal/ITerminal.d.ts.map +1 -0
- package/dist/substrate/lifo/terminal/ITerminal.js +1 -0
- package/dist/substrate/lifo/utils/archive.d.ts +28 -0
- package/dist/substrate/lifo/utils/archive.d.ts.map +1 -0
- package/dist/substrate/lifo/utils/archive.js +323 -0
- package/dist/substrate/lifo/utils/args.d.ts +18 -0
- package/dist/substrate/lifo/utils/args.d.ts.map +1 -0
- package/dist/substrate/lifo/utils/args.js +73 -0
- package/dist/substrate/lifo/utils/colors.d.ts +27 -0
- package/dist/substrate/lifo/utils/colors.d.ts.map +1 -0
- package/dist/substrate/lifo/utils/colors.js +26 -0
- package/dist/substrate/lifo/utils/encoding.d.ts +4 -0
- package/dist/substrate/lifo/utils/encoding.d.ts.map +1 -0
- package/dist/substrate/lifo/utils/encoding.js +18 -0
- package/dist/substrate/lifo/utils/glob.d.ts +12 -0
- package/dist/substrate/lifo/utils/glob.d.ts.map +1 -0
- package/dist/substrate/lifo/utils/glob.js +150 -0
- package/dist/substrate/lifo/utils/mime.d.ts +4 -0
- package/dist/substrate/lifo/utils/mime.d.ts.map +1 -0
- package/dist/substrate/lifo/utils/mime.js +107 -0
- package/dist/substrate/lifo/utils/path.d.ts +12 -0
- package/dist/substrate/lifo/utils/path.d.ts.map +1 -0
- package/dist/substrate/lifo/utils/path.js +82 -0
- package/dist/vfs/events.d.ts +51 -0
- package/dist/vfs/events.d.ts.map +1 -0
- package/dist/vfs/events.js +127 -0
- package/dist/vfs/path.d.ts +46 -0
- package/dist/vfs/path.d.ts.map +1 -0
- package/dist/vfs/path.js +69 -0
- package/dist/vfs/seed-project.d.ts +62 -0
- package/dist/vfs/seed-project.d.ts.map +1 -0
- package/dist/vfs/seed-project.js +1054 -0
- package/dist/vfs/sqlite-vfs.d.ts +821 -0
- package/dist/vfs/sqlite-vfs.d.ts.map +1 -0
- package/dist/vfs/sqlite-vfs.js +4135 -0
- package/dist/vfs/symlink-registry.d.ts +60 -0
- package/dist/vfs/symlink-registry.d.ts.map +1 -0
- package/dist/vfs/symlink-registry.js +162 -0
- package/dist/workspace/nimbus-workspace.d.ts +94 -0
- package/dist/workspace/nimbus-workspace.d.ts.map +1 -0
- package/dist/workspace/nimbus-workspace.js +167 -0
- package/package.json +69 -0
- package/src/_shared/ai-egress.ts +91 -0
- package/src/_shared/byte-stream.ts +97 -0
- package/src/_shared/bytes.ts +19 -0
- package/src/_shared/cache-stats.ts +231 -0
- package/src/_shared/crypto.ts +184 -0
- package/src/_shared/esbuild-facet-shim.ts +22 -0
- package/src/_shared/exports-resolver.ts +308 -0
- package/src/_shared/facet-vfs-cursor.ts +58 -0
- package/src/_shared/install-phase.ts +56 -0
- package/src/_shared/lru-map.ts +59 -0
- package/src/_shared/real-node-imports.ts +53 -0
- package/src/_shared/retry.ts +202 -0
- package/src/_shared/rpc-dispose.ts +31 -0
- package/src/_shared/terminal.ts +3 -0
- package/src/_shared/typescript-specifiers.ts +86 -0
- package/src/_shared/untrusted-request.ts +75 -0
- package/src/_shared/vfs-write-ledger.ts +440 -0
- package/src/_shared/w7-frame.ts +1012 -0
- package/src/_shared/weighted-credit-pool.ts +244 -0
- package/src/constants.ts +285 -0
- package/src/index.ts +22 -0
- package/src/observability/diag-counters.ts +343 -0
- package/src/observability/heap-estimate.ts +331 -0
- package/src/observability/heavy-alloc-coord.ts +241 -0
- package/src/observability/oom-classify.ts +253 -0
- package/src/observability/oom-discriminator.ts +405 -0
- package/src/runtime/assets-loader.ts +189 -0
- package/src/runtime/barrel-detect.ts +69 -0
- package/src/runtime/bash/preamble.ts +1519 -0
- package/src/runtime/bash/types.ts +497 -0
- package/src/runtime/bundle-profile.ts +32 -0
- package/src/runtime/cirrus-vite-config-rewriter.ts +28 -0
- package/src/runtime/cli-flags.ts +11 -0
- package/src/runtime/comment-strip.ts +73 -0
- package/src/runtime/cpython-preamble.ts +298 -0
- package/src/runtime/esbuild-service.ts +1470 -0
- package/src/runtime/framework-detect.ts +245 -0
- package/src/runtime/import-meta-transform.ts +16 -0
- package/src/runtime/javascript-ast.ts +66 -0
- package/src/runtime/long-running-handle.ts +185 -0
- package/src/runtime/module-source-rewriter.ts +95 -0
- package/src/runtime/opentui-wasm-backend.ts +608 -0
- package/src/runtime/os-contracts.ts +529 -0
- package/src/runtime/port-registry.ts +298 -0
- package/src/runtime/process-input-routing.ts +92 -0
- package/src/runtime/process-input.ts +148 -0
- package/src/runtime/process-io-protocol.ts +97 -0
- package/src/runtime/process-logs.ts +882 -0
- package/src/runtime/process-table.ts +225 -0
- package/src/runtime/project-detect.ts +42 -0
- package/src/runtime/python-server-adapter.ts +133 -0
- package/src/runtime/require-resolver.ts +760 -0
- package/src/runtime/router-basename.ts +279 -0
- package/src/runtime/ruby-green-threads.ts +904 -0
- package/src/runtime/ruby-socket-shim.ts +548 -0
- package/src/runtime/session-process-supervisor.ts +323 -0
- package/src/runtime/sqlite-runtime-fs-bridge.ts +468 -0
- package/src/runtime/streams.ts +547 -0
- package/src/runtime/undici-shim.ts +517 -0
- package/src/runtime/vfs-manifest.ts +170 -0
- package/src/runtime/vfs-snapshot.ts +273 -0
- package/src/runtime/virtual-socket-kernel.ts +1370 -0
- package/src/runtime/vite-config-parser.ts +273 -0
- package/src/runtime/wasi/types.ts +448 -0
- package/src/runtime/wasi-instance.generated.ts +14 -0
- package/src/runtime/wasi-instance.ts +259 -0
- package/src/runtime/wasi-threads.ts +682 -0
- package/src/runtime/wasm-memory.ts +261 -0
- package/src/shell/elevation-commands.ts +117 -0
- package/src/shell/exec-dispatch.ts +201 -0
- package/src/shell/features.ts +870 -0
- package/src/shell/shell-entrypoints.ts +323 -0
- package/src/shell/shell-invocation.ts +181 -0
- package/src/shell/unix-accounts.ts +128 -0
- package/src/shell/unix-commands.ts +4335 -0
- package/src/substrate/lifo/UPSTREAM.md +14 -0
- package/src/substrate/lifo/commands/archive/gunzip.ts +63 -0
- package/src/substrate/lifo/commands/archive/gzip.ts +76 -0
- package/src/substrate/lifo/commands/archive/tar.ts +157 -0
- package/src/substrate/lifo/commands/archive/unzip.ts +112 -0
- package/src/substrate/lifo/commands/archive/zip.ts +70 -0
- package/src/substrate/lifo/commands/fs/basename.ts +16 -0
- package/src/substrate/lifo/commands/fs/cat.ts +54 -0
- package/src/substrate/lifo/commands/fs/chmod.ts +110 -0
- package/src/substrate/lifo/commands/fs/chown.ts +45 -0
- package/src/substrate/lifo/commands/fs/cp.ts +33 -0
- package/src/substrate/lifo/commands/fs/df.ts +56 -0
- package/src/substrate/lifo/commands/fs/dirname.ts +16 -0
- package/src/substrate/lifo/commands/fs/du.ts +100 -0
- package/src/substrate/lifo/commands/fs/file.ts +90 -0
- package/src/substrate/lifo/commands/fs/find.ts +76 -0
- package/src/substrate/lifo/commands/fs/ln.ts +19 -0
- package/src/substrate/lifo/commands/fs/ls.ts +164 -0
- package/src/substrate/lifo/commands/fs/mkdir.ts +37 -0
- package/src/substrate/lifo/commands/fs/mktemp.ts +56 -0
- package/src/substrate/lifo/commands/fs/mv.ts +111 -0
- package/src/substrate/lifo/commands/fs/realpath.ts +31 -0
- package/src/substrate/lifo/commands/fs/rm.ts +53 -0
- package/src/substrate/lifo/commands/fs/rmdir.ts +50 -0
- package/src/substrate/lifo/commands/fs/stat.ts +39 -0
- package/src/substrate/lifo/commands/fs/touch.ts +30 -0
- package/src/substrate/lifo/commands/fs/tree.ts +76 -0
- package/src/substrate/lifo/commands/index.ts +2 -0
- package/src/substrate/lifo/commands/io/dd.ts +289 -0
- package/src/substrate/lifo/commands/io/printf.ts +78 -0
- package/src/substrate/lifo/commands/io/tee.ts +37 -0
- package/src/substrate/lifo/commands/io/xargs.ts +49 -0
- package/src/substrate/lifo/commands/io/yes.ts +15 -0
- package/src/substrate/lifo/commands/net/curl.ts +739 -0
- package/src/substrate/lifo/commands/net/dig.ts +99 -0
- package/src/substrate/lifo/commands/net/forward.ts +90 -0
- package/src/substrate/lifo/commands/net/host.ts +182 -0
- package/src/substrate/lifo/commands/net/ifconfig.ts +139 -0
- package/src/substrate/lifo/commands/net/ip.ts +633 -0
- package/src/substrate/lifo/commands/net/netstat.ts +106 -0
- package/src/substrate/lifo/commands/net/ping.ts +74 -0
- package/src/substrate/lifo/commands/net/ports.ts +45 -0
- package/src/substrate/lifo/commands/net/route.ts +153 -0
- package/src/substrate/lifo/commands/net/tunnel-v2.ts +183 -0
- package/src/substrate/lifo/commands/net/tunnel.ts +272 -0
- package/src/substrate/lifo/commands/net/wget.ts +88 -0
- package/src/substrate/lifo/commands/registry.ts +141 -0
- package/src/substrate/lifo/commands/signal.ts +65 -0
- package/src/substrate/lifo/commands/system/bc.ts +265 -0
- package/src/substrate/lifo/commands/system/cal.ts +90 -0
- package/src/substrate/lifo/commands/system/date.ts +59 -0
- package/src/substrate/lifo/commands/system/env.ts +10 -0
- package/src/substrate/lifo/commands/system/fastfetch.ts +428 -0
- package/src/substrate/lifo/commands/system/free.ts +38 -0
- package/src/substrate/lifo/commands/system/help.ts +53 -0
- package/src/substrate/lifo/commands/system/hostname.ts +9 -0
- package/src/substrate/lifo/commands/system/kill.ts +89 -0
- package/src/substrate/lifo/commands/system/lifo.ts +525 -0
- package/src/substrate/lifo/commands/system/logout.ts +17 -0
- package/src/substrate/lifo/commands/system/man.ts +167 -0
- package/src/substrate/lifo/commands/system/node.ts +1305 -0
- package/src/substrate/lifo/commands/system/npm.ts +1078 -0
- package/src/substrate/lifo/commands/system/pkg.ts +111 -0
- package/src/substrate/lifo/commands/system/ps.ts +46 -0
- package/src/substrate/lifo/commands/system/registry-schemas.ts +33 -0
- package/src/substrate/lifo/commands/system/sha256sum.ts +89 -0
- package/src/substrate/lifo/commands/system/sl.ts +249 -0
- package/src/substrate/lifo/commands/system/sleep.ts +36 -0
- package/src/substrate/lifo/commands/system/stty.ts +69 -0
- package/src/substrate/lifo/commands/system/systemctl.ts +184 -0
- package/src/substrate/lifo/commands/system/top.ts +53 -0
- package/src/substrate/lifo/commands/system/uname.ts +59 -0
- package/src/substrate/lifo/commands/system/uptime.ts +19 -0
- package/src/substrate/lifo/commands/system/watch.ts +67 -0
- package/src/substrate/lifo/commands/system/which.ts +51 -0
- package/src/substrate/lifo/commands/system/whoami.ts +9 -0
- package/src/substrate/lifo/commands/text/awk.ts +210 -0
- package/src/substrate/lifo/commands/text/base64.ts +102 -0
- package/src/substrate/lifo/commands/text/cut.ts +92 -0
- package/src/substrate/lifo/commands/text/diff.ts +314 -0
- package/src/substrate/lifo/commands/text/grep.ts +170 -0
- package/src/substrate/lifo/commands/text/head.ts +95 -0
- package/src/substrate/lifo/commands/text/less.ts +335 -0
- package/src/substrate/lifo/commands/text/nano.ts +513 -0
- package/src/substrate/lifo/commands/text/nl.ts +74 -0
- package/src/substrate/lifo/commands/text/rev.ts +46 -0
- package/src/substrate/lifo/commands/text/sed.ts +297 -0
- package/src/substrate/lifo/commands/text/seq.ts +76 -0
- package/src/substrate/lifo/commands/text/sort.ts +88 -0
- package/src/substrate/lifo/commands/text/strings.ts +73 -0
- package/src/substrate/lifo/commands/text/tac.ts +37 -0
- package/src/substrate/lifo/commands/text/tail.ts +63 -0
- package/src/substrate/lifo/commands/text/tr.ts +192 -0
- package/src/substrate/lifo/commands/text/uniq.ts +77 -0
- package/src/substrate/lifo/commands/text/wc.ts +104 -0
- package/src/substrate/lifo/commands/types.ts +58 -0
- package/src/substrate/lifo/index.ts +173 -0
- package/src/substrate/lifo/kernel/ServiceManager.ts +371 -0
- package/src/substrate/lifo/kernel/index.ts +209 -0
- package/src/substrate/lifo/kernel/network/Bridge.ts +336 -0
- package/src/substrate/lifo/kernel/network/DNSResolver.ts +158 -0
- package/src/substrate/lifo/kernel/network/NetworkInterface.ts +235 -0
- package/src/substrate/lifo/kernel/network/NetworkNamespace.ts +182 -0
- package/src/substrate/lifo/kernel/network/NetworkStack.ts +590 -0
- package/src/substrate/lifo/kernel/network/PortBridge.ts +182 -0
- package/src/substrate/lifo/kernel/network/RoutingTable.ts +209 -0
- package/src/substrate/lifo/kernel/network/Socket.ts +245 -0
- package/src/substrate/lifo/kernel/network/index.ts +29 -0
- package/src/substrate/lifo/kernel/network/tunnel/BaseTunnel.ts +124 -0
- package/src/substrate/lifo/kernel/network/tunnel/VETHPair.ts +227 -0
- package/src/substrate/lifo/kernel/network/tunnel/WebSocketTunnel.ts +387 -0
- package/src/substrate/lifo/kernel/network/types.ts +178 -0
- package/src/substrate/lifo/kernel/persistence/PersistenceManager.ts +50 -0
- package/src/substrate/lifo/kernel/persistence/backends.ts +36 -0
- package/src/substrate/lifo/kernel/persistence/index.ts +5 -0
- package/src/substrate/lifo/kernel/persistence/serializer.ts +127 -0
- package/src/substrate/lifo/kernel/samples.ts +966 -0
- package/src/substrate/lifo/kernel/storage/BlobStore.ts +114 -0
- package/src/substrate/lifo/kernel/storage/ContentStore.ts +150 -0
- package/src/substrate/lifo/kernel/storage/index.ts +5 -0
- package/src/substrate/lifo/kernel/unit-parser.ts +95 -0
- package/src/substrate/lifo/kernel/vfs/VFS.ts +768 -0
- package/src/substrate/lifo/kernel/vfs/index.ts +9 -0
- package/src/substrate/lifo/kernel/vfs/providers/DevProvider.ts +172 -0
- package/src/substrate/lifo/kernel/vfs/providers/NativeFsProvider.ts +198 -0
- package/src/substrate/lifo/kernel/vfs/providers/ProcProvider.ts +144 -0
- package/src/substrate/lifo/kernel/vfs/types.ts +145 -0
- package/src/substrate/lifo/node-compat/buffer.ts +357 -0
- package/src/substrate/lifo/node-compat/child_process.ts +52 -0
- package/src/substrate/lifo/node-compat/console.ts +70 -0
- package/src/substrate/lifo/node-compat/crypto.ts +186 -0
- package/src/substrate/lifo/node-compat/dns.ts +214 -0
- package/src/substrate/lifo/node-compat/esbuild.ts +85 -0
- package/src/substrate/lifo/node-compat/events.ts +94 -0
- package/src/substrate/lifo/node-compat/fs.ts +762 -0
- package/src/substrate/lifo/node-compat/http.ts +561 -0
- package/src/substrate/lifo/node-compat/index.ts +300 -0
- package/src/substrate/lifo/node-compat/module.ts +148 -0
- package/src/substrate/lifo/node-compat/os.ts +44 -0
- package/src/substrate/lifo/node-compat/path.ts +74 -0
- package/src/substrate/lifo/node-compat/process.ts +178 -0
- package/src/substrate/lifo/node-compat/readline.ts +244 -0
- package/src/substrate/lifo/node-compat/rimraf.ts +80 -0
- package/src/substrate/lifo/node-compat/stream.ts +98 -0
- package/src/substrate/lifo/node-compat/string_decoder.ts +26 -0
- package/src/substrate/lifo/node-compat/timers.ts +21 -0
- package/src/substrate/lifo/node-compat/tty.ts +83 -0
- package/src/substrate/lifo/node-compat/url.ts +76 -0
- package/src/substrate/lifo/node-compat/util.ts +133 -0
- package/src/substrate/lifo/node-compat/zlib.ts +94 -0
- package/src/substrate/lifo/pkg/PackageManager.ts +105 -0
- package/src/substrate/lifo/pkg/lifo-dev.ts +130 -0
- package/src/substrate/lifo/pkg/lifo-runtime.ts +473 -0
- package/src/substrate/lifo/pkg/loader.ts +33 -0
- package/src/substrate/lifo/platform-globals.d.ts +41 -0
- package/src/substrate/lifo/sandbox/HeadlessTerminal.ts +38 -0
- package/src/substrate/lifo/sandbox/Sandbox.ts +279 -0
- package/src/substrate/lifo/sandbox/SandboxCommands.ts +74 -0
- package/src/substrate/lifo/sandbox/SandboxFs.ts +160 -0
- package/src/substrate/lifo/sandbox/index.ts +8 -0
- package/src/substrate/lifo/sandbox/types.ts +117 -0
- package/src/substrate/lifo/shell/ProcessRegistry.ts +379 -0
- package/src/substrate/lifo/shell/Shell.ts +2048 -0
- package/src/substrate/lifo/shell/completer.ts +212 -0
- package/src/substrate/lifo/shell/default-shell.ts +63 -0
- package/src/substrate/lifo/shell/expander.ts +1349 -0
- package/src/substrate/lifo/shell/history.ts +138 -0
- package/src/substrate/lifo/shell/interpreter.ts +1754 -0
- package/src/substrate/lifo/shell/jobs.ts +64 -0
- package/src/substrate/lifo/shell/lexer.ts +698 -0
- package/src/substrate/lifo/shell/parser.ts +711 -0
- package/src/substrate/lifo/shell/pipe.ts +92 -0
- package/src/substrate/lifo/shell/signals.ts +70 -0
- package/src/substrate/lifo/shell/terminal-stdin.ts +109 -0
- package/src/substrate/lifo/shell/test-builtin.ts +316 -0
- package/src/substrate/lifo/shell/types.ts +166 -0
- package/src/substrate/lifo/terminal/ITerminal.ts +9 -0
- package/src/substrate/lifo/utils/archive.ts +389 -0
- package/src/substrate/lifo/utils/args.ts +89 -0
- package/src/substrate/lifo/utils/colors.ts +29 -0
- package/src/substrate/lifo/utils/encoding.ts +21 -0
- package/src/substrate/lifo/utils/glob.ts +172 -0
- package/src/substrate/lifo/utils/mime.ts +114 -0
- package/src/substrate/lifo/utils/path.ts +83 -0
- package/src/types/assets.d.ts +4 -0
- package/src/vfs/events.ts +134 -0
- package/src/vfs/path.ts +71 -0
- package/src/vfs/seed-project.ts +1094 -0
- package/src/vfs/sqlite-vfs.ts +5035 -0
- package/src/vfs/symlink-registry.ts +172 -0
- package/src/workspace/nimbus-workspace.ts +213 -0
|
@@ -0,0 +1,1241 @@
|
|
|
1
|
+
import { resolve, dirname, join, extname } from '../../utils/path.js';
|
|
2
|
+
import { createModuleMap, ProcessExitError } from '../../node-compat/index.js';
|
|
3
|
+
import { createProcess } from '../../node-compat/process.js';
|
|
4
|
+
import { createConsole } from '../../node-compat/console.js';
|
|
5
|
+
import { Buffer } from '../../node-compat/buffer.js';
|
|
6
|
+
import { VFSError } from '../../kernel/vfs/index.js';
|
|
7
|
+
import { ACTIVE_SERVERS } from '../../node-compat/http.js';
|
|
8
|
+
const NODE_VERSION = 'v20.0.0';
|
|
9
|
+
// ── Rollup / esbuild CJS-ESM interop helpers ──
|
|
10
|
+
// Bundled npm packages (Vite, Rollup, etc.) reference these helpers at the module
|
|
11
|
+
// scope. When our ESM→CJS transform converts imports, the helpers may lose their
|
|
12
|
+
// binding. Making them available on globalThis acts as a fallback – if the module
|
|
13
|
+
// defines its own copy the local declaration naturally shadows the global.
|
|
14
|
+
//
|
|
15
|
+
// Complete set from @rollup/plugin-commonjs interop:
|
|
16
|
+
const _rollupHelpers = {
|
|
17
|
+
getDefaultExportFromCjs(x) {
|
|
18
|
+
const o = x;
|
|
19
|
+
return o && o.__esModule && Object.prototype.hasOwnProperty.call(o, 'default') ? o.default : o;
|
|
20
|
+
},
|
|
21
|
+
getDefaultExportFromNamespaceIfPresent(n) {
|
|
22
|
+
const o = n;
|
|
23
|
+
return o && Object.prototype.hasOwnProperty.call(o, 'default') && Object.keys(o).length === 1 ? o.default : o;
|
|
24
|
+
},
|
|
25
|
+
getAugmentedNamespace(n) {
|
|
26
|
+
const o = n;
|
|
27
|
+
if (o.__esModule)
|
|
28
|
+
return o;
|
|
29
|
+
const a = Object.defineProperty({}, '__esModule', { value: true });
|
|
30
|
+
Object.keys(o).forEach(function (k) {
|
|
31
|
+
const d = Object.getOwnPropertyDescriptor(o, k);
|
|
32
|
+
Object.defineProperty(a, k, d && d.get ? d : { enumerable: true, get() { return o[k]; } });
|
|
33
|
+
});
|
|
34
|
+
a.default = n;
|
|
35
|
+
return Object.freeze(a);
|
|
36
|
+
},
|
|
37
|
+
_mergeNamespaces(n, ...ms) {
|
|
38
|
+
const o = n;
|
|
39
|
+
const modules = ms.flat();
|
|
40
|
+
for (const m of modules) {
|
|
41
|
+
for (const k of Object.keys(m)) {
|
|
42
|
+
if (k !== 'default' && !(k in o)) {
|
|
43
|
+
Object.defineProperty(o, k, { enumerable: true, get: () => m[k] });
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return Object.freeze(o);
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
/** Strip shebang line (e.g. #!/usr/bin/env node) – replace with blank to preserve line numbers */
|
|
51
|
+
function stripShebang(src) {
|
|
52
|
+
if (src.charCodeAt(0) === 0x23 /* # */ && src.charCodeAt(1) === 0x21 /* ! */) {
|
|
53
|
+
const nl = src.indexOf('\n');
|
|
54
|
+
if (nl === -1)
|
|
55
|
+
return '';
|
|
56
|
+
return '\n' + src.slice(nl + 1);
|
|
57
|
+
}
|
|
58
|
+
return src;
|
|
59
|
+
}
|
|
60
|
+
/** Check if source contains ESM import/export syntax */
|
|
61
|
+
function isEsmSource(source) {
|
|
62
|
+
// Match import/export at line start, after semicolon, or minified (import{, import*)
|
|
63
|
+
return /(?:^|\n|;)\s*(?:import\s*[\w{*('".]|export\s+|export\s*\{)/.test(source);
|
|
64
|
+
}
|
|
65
|
+
/** Determine if source should be treated as ESM based on filename, content, and package.json type */
|
|
66
|
+
function shouldTreatAsEsm(source, filename, vfs) {
|
|
67
|
+
const ext = extname(filename);
|
|
68
|
+
if (ext === '.mjs')
|
|
69
|
+
return true;
|
|
70
|
+
if (ext === '.cjs')
|
|
71
|
+
return false;
|
|
72
|
+
// Check nearest package.json "type" field (Node.js semantics)
|
|
73
|
+
if (vfs && ext === '.js') {
|
|
74
|
+
let dir = dirname(filename);
|
|
75
|
+
for (;;) {
|
|
76
|
+
const pkgPath = join(dir, 'package.json');
|
|
77
|
+
if (vfs.exists(pkgPath)) {
|
|
78
|
+
try {
|
|
79
|
+
const pkg = JSON.parse(vfs.readFileString(pkgPath));
|
|
80
|
+
if (pkg.type === 'module')
|
|
81
|
+
return true;
|
|
82
|
+
if (pkg.type === 'commonjs')
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
catch { /* ignore */ }
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
const parent = dirname(dir);
|
|
89
|
+
if (parent === dir)
|
|
90
|
+
break;
|
|
91
|
+
dir = parent;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return isEsmSource(source);
|
|
95
|
+
}
|
|
96
|
+
// Names that collide with the new Function() CJS wrapper parameters.
|
|
97
|
+
// Using `const` for these would throw "Identifier X has already been declared",
|
|
98
|
+
// so we emit `var` instead (var can shadow function params in non-strict mode).
|
|
99
|
+
const CJS_WRAPPER_PARAMS = new Set([
|
|
100
|
+
'exports', 'require', 'module', '__filename', '__dirname',
|
|
101
|
+
'console', 'process', 'Buffer', 'setTimeout', 'setInterval',
|
|
102
|
+
'clearTimeout', 'clearInterval', 'global',
|
|
103
|
+
'__importMetaUrl', '__importMeta', '__importMetaResolve',
|
|
104
|
+
]);
|
|
105
|
+
function cjsDecl(name) {
|
|
106
|
+
return CJS_WRAPPER_PARAMS.has(name) ? 'var' : 'const';
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Mask string/template literals with safe placeholders so that
|
|
110
|
+
* import/export regexes don't match keywords inside string content.
|
|
111
|
+
* Returns the masked source and an array of original literals for restoration.
|
|
112
|
+
*/
|
|
113
|
+
function maskStringLiterals(src) {
|
|
114
|
+
const literals = [];
|
|
115
|
+
let masked = '';
|
|
116
|
+
let i = 0;
|
|
117
|
+
while (i < src.length) {
|
|
118
|
+
const ch = src[i];
|
|
119
|
+
// Skip single-line comments (may contain unmatched quotes)
|
|
120
|
+
if (ch === '/' && i + 1 < src.length && src[i + 1] === '/') {
|
|
121
|
+
const nl = src.indexOf('\n', i);
|
|
122
|
+
const end = nl === -1 ? src.length : nl;
|
|
123
|
+
masked += src.slice(i, end);
|
|
124
|
+
i = end;
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
// Skip multi-line comments
|
|
128
|
+
if (ch === '/' && i + 1 < src.length && src[i + 1] === '*') {
|
|
129
|
+
const end = src.indexOf('*/', i + 2);
|
|
130
|
+
const close = end === -1 ? src.length : end + 2;
|
|
131
|
+
masked += src.slice(i, close);
|
|
132
|
+
i = close;
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
// Regex literals — skip to avoid confusing backticks inside /regex/ with templates
|
|
136
|
+
if (ch === '/' && i + 1 < src.length && src[i + 1] !== '/' && src[i + 1] !== '*') {
|
|
137
|
+
// Heuristic: '/' is a regex if preceded by an operator, keyword, or start-of-line.
|
|
138
|
+
// IMPORTANT: We include ')' and '}' even though they can precede division too,
|
|
139
|
+
// because under-detection is catastrophic: a backtick inside an undetected
|
|
140
|
+
// regex triggers the template-literal parser which can eat the rest of the file.
|
|
141
|
+
// Over-detection is harmless: the regex scanner copies content as-is and stops
|
|
142
|
+
// at newline, so the output is identical either way.
|
|
143
|
+
let k = i - 1;
|
|
144
|
+
while (k >= 0 && (src[k] === ' ' || src[k] === '\t' || src[k] === '\n' || src[k] === '\r'))
|
|
145
|
+
k--;
|
|
146
|
+
const prev = k >= 0 ? src[k] : '\0';
|
|
147
|
+
if ('\0=([{,;!&|^~?:+-*%<>/)]}'.includes(prev) ||
|
|
148
|
+
(k >= 1 && /\b(?:return|typeof|void|delete|throw|new|case|of|in|yield|await)\s*$/.test(src.slice(Math.max(0, k - 11), k + 1)))) {
|
|
149
|
+
const regStart = i;
|
|
150
|
+
i++; // skip opening /
|
|
151
|
+
while (i < src.length && src[i] !== '\n') {
|
|
152
|
+
if (src[i] === '\\') {
|
|
153
|
+
i += 2;
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
if (src[i] === '/') {
|
|
157
|
+
i++;
|
|
158
|
+
break;
|
|
159
|
+
}
|
|
160
|
+
if (src[i] === '[') { // character class — / doesn't end regex inside [...]
|
|
161
|
+
i++;
|
|
162
|
+
while (i < src.length && src[i] !== ']' && src[i] !== '\n') {
|
|
163
|
+
if (src[i] === '\\')
|
|
164
|
+
i++;
|
|
165
|
+
i++;
|
|
166
|
+
}
|
|
167
|
+
if (i < src.length && src[i] === ']')
|
|
168
|
+
i++;
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
171
|
+
i++;
|
|
172
|
+
}
|
|
173
|
+
while (i < src.length && /[gimsuyv]/.test(src[i]))
|
|
174
|
+
i++; // flags
|
|
175
|
+
masked += src.slice(regStart, i);
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
// String/template literals
|
|
180
|
+
if (ch === '"' || ch === "'" || ch === '`') {
|
|
181
|
+
const start = i;
|
|
182
|
+
const quote = ch;
|
|
183
|
+
i++; // skip opening quote
|
|
184
|
+
while (i < src.length) {
|
|
185
|
+
if (src[i] === '\\') {
|
|
186
|
+
i += 2;
|
|
187
|
+
continue;
|
|
188
|
+
}
|
|
189
|
+
if (src[i] === quote) {
|
|
190
|
+
i++;
|
|
191
|
+
break;
|
|
192
|
+
}
|
|
193
|
+
// Template literal ${...} expressions — skip with depth tracking
|
|
194
|
+
if (quote === '`' && src[i] === '$' && i + 1 < src.length && src[i + 1] === '{') {
|
|
195
|
+
let depth = 1;
|
|
196
|
+
i += 2;
|
|
197
|
+
while (i < src.length && depth > 0) {
|
|
198
|
+
if (src[i] === '{')
|
|
199
|
+
depth++;
|
|
200
|
+
else if (src[i] === '}')
|
|
201
|
+
depth--;
|
|
202
|
+
else if (src[i] === '\\')
|
|
203
|
+
i++;
|
|
204
|
+
else if (src[i] === "'" || src[i] === '"') {
|
|
205
|
+
const q = src[i];
|
|
206
|
+
i++;
|
|
207
|
+
while (i < src.length && src[i] !== q) {
|
|
208
|
+
if (src[i] === '\\')
|
|
209
|
+
i++;
|
|
210
|
+
i++;
|
|
211
|
+
}
|
|
212
|
+
if (i < src.length)
|
|
213
|
+
i++; // skip closing quote
|
|
214
|
+
continue;
|
|
215
|
+
}
|
|
216
|
+
else if (src[i] === '`') {
|
|
217
|
+
// Nested template literal inside expression
|
|
218
|
+
i++;
|
|
219
|
+
while (i < src.length && src[i] !== '`') {
|
|
220
|
+
if (src[i] === '\\')
|
|
221
|
+
i++;
|
|
222
|
+
i++;
|
|
223
|
+
}
|
|
224
|
+
if (i < src.length)
|
|
225
|
+
i++;
|
|
226
|
+
continue;
|
|
227
|
+
}
|
|
228
|
+
i++;
|
|
229
|
+
}
|
|
230
|
+
continue;
|
|
231
|
+
}
|
|
232
|
+
i++;
|
|
233
|
+
}
|
|
234
|
+
const literal = src.slice(start, i);
|
|
235
|
+
const idx = literals.length;
|
|
236
|
+
literals.push(literal);
|
|
237
|
+
// Placeholder uses same quote style so import regexes that capture
|
|
238
|
+
// ['"][^'"]+['"] still work (they see e.g. "__LIFO_S0__").
|
|
239
|
+
masked += quote + '__LIFO_S' + idx + '__' + quote;
|
|
240
|
+
continue;
|
|
241
|
+
}
|
|
242
|
+
masked += ch;
|
|
243
|
+
i++;
|
|
244
|
+
}
|
|
245
|
+
return { masked, literals };
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Restore original string/template literals from masked placeholders.
|
|
249
|
+
*/
|
|
250
|
+
function unmaskStringLiterals(src, literals) {
|
|
251
|
+
return src.replace(/(['"`])__LIFO_S(\d+)__\1/g, (_match, _quote, idxStr) => literals[parseInt(idxStr, 10)]);
|
|
252
|
+
}
|
|
253
|
+
/** Transform ESM import/export syntax to CJS require/exports equivalents */
|
|
254
|
+
function transformEsmToCjs(source) {
|
|
255
|
+
// Normalize \r\n → \n so regexes anchored on \n work with Windows line endings
|
|
256
|
+
let result = source.replace(/\r\n/g, '\n').replace(/\r/g, '\n');
|
|
257
|
+
// import.meta.* replacements MUST run before masking.
|
|
258
|
+
// The masker may incorrectly consume code regions (e.g. regex literals with
|
|
259
|
+
// backticks), so import.meta must be replaced on the raw source first.
|
|
260
|
+
// These are safe on raw source: replacements are plain identifiers that won't
|
|
261
|
+
// cause issues even if they accidentally match inside string literals.
|
|
262
|
+
result = result.split('import.meta.url').join('__importMetaUrl');
|
|
263
|
+
result = result.split('import.meta.dirname').join('__dirname');
|
|
264
|
+
result = result.split('import.meta.filename').join('__filename');
|
|
265
|
+
result = result.split('import.meta.require').join('require');
|
|
266
|
+
result = result.split('import.meta.resolve').join('__importMetaResolve');
|
|
267
|
+
// Bare import.meta (catch-all, must come AFTER specific property replacements)
|
|
268
|
+
result = result.split('import.meta').join('__importMeta');
|
|
269
|
+
// Mask string/template literal contents so import/export regexes don't
|
|
270
|
+
// match keywords inside strings (e.g. const HELPERS = `export function ...`)
|
|
271
|
+
const { masked, literals } = maskStringLiterals(result);
|
|
272
|
+
result = masked;
|
|
273
|
+
// Split semicolon-separated import/export onto their own lines
|
|
274
|
+
// so that the (?:^|\n) anchored regexes below can find them in minified code
|
|
275
|
+
result = result.replace(/;([ \t]*(?:import\s*[\w${*('".]|export[\s{*]))/g, ';\n$1');
|
|
276
|
+
const trailingExports = [];
|
|
277
|
+
let hasDefaultExport = false;
|
|
278
|
+
let hasNamedExport = false;
|
|
279
|
+
// Track import sources: localName → { modRef, prop } for live-binding exports
|
|
280
|
+
const importSources = new Map();
|
|
281
|
+
// Scan for export types to decide default export strategy
|
|
282
|
+
hasDefaultExport = /(?:^|\n)\s*export\s+default\s+/.test(result);
|
|
283
|
+
hasNamedExport = /(?:^|\n)\s*export\s+(?:const|let|var|function|class|\{|\*\s+from)/.test(result);
|
|
284
|
+
// --- Import transforms ---
|
|
285
|
+
// NOTE: JS identifiers can contain $ (e.g. fs$8, path$b in esbuild bundles).
|
|
286
|
+
// We use [\w$]+ instead of \w+ throughout to match these correctly.
|
|
287
|
+
// Combined: import X, { a, b as c } from 'mod'
|
|
288
|
+
result = result.replace(/(?:^|\n)([ \t]*)import\s+([\w$]+)\s*,\s*\{([^}]+)\}\s*from\s*(['"][^'"]+['"])[ \t]*;?/g, (match, indent, defaultName, imports, mod) => {
|
|
289
|
+
// Guard: ${ in captured names means regex matched inside a template literal
|
|
290
|
+
if (imports.includes('${'))
|
|
291
|
+
return match;
|
|
292
|
+
const tmp = '__mod_' + defaultName;
|
|
293
|
+
const mapped = imports.split(',').map((s) => {
|
|
294
|
+
const parts = s.trim().split(/\s+as\s+/);
|
|
295
|
+
const sourceProp = parts[0].trim();
|
|
296
|
+
const localName = parts.length === 2 ? parts[1].trim() : sourceProp;
|
|
297
|
+
if (localName)
|
|
298
|
+
importSources.set(localName, { modRef: tmp, prop: sourceProp });
|
|
299
|
+
if (parts.length === 2)
|
|
300
|
+
return `${sourceProp}: ${localName}`;
|
|
301
|
+
return sourceProp;
|
|
302
|
+
}).filter((s) => s).join(', ');
|
|
303
|
+
return `\n${indent}${cjsDecl(tmp)} ${tmp} = require(${mod});\n${indent}${cjsDecl(defaultName)} ${defaultName} = ${tmp}.default || ${tmp};\n${indent}const { ${mapped} } = ${tmp};`;
|
|
304
|
+
});
|
|
305
|
+
// Combined: import X, * as Y from 'mod'
|
|
306
|
+
result = result.replace(/(?:^|\n)([ \t]*)import\s+([\w$]+)\s*,\s*\*\s*as\s+([\w$]+)\s+from\s*(['"][^'"]+['"])[ \t]*;?/g, (_match, indent, defaultName, nsName, mod) => {
|
|
307
|
+
return `\n${indent}${cjsDecl(nsName)} ${nsName} = require(${mod});\n${indent}${cjsDecl(defaultName)} ${defaultName} = ${nsName}.default || ${nsName};`;
|
|
308
|
+
});
|
|
309
|
+
// import { a, b as c } from 'mod'
|
|
310
|
+
result = result.replace(/(?:^|\n)([ \t]*)import\s*\{([^}]+)\}\s*from\s*(['"][^'"]+['"])[ \t]*;?/g, (match, indent, imports, mod) => {
|
|
311
|
+
// Guard: ${ in captured names means regex matched inside a template literal
|
|
312
|
+
if (imports.includes('${'))
|
|
313
|
+
return match;
|
|
314
|
+
const modRef = '__imp_' + Math.random().toString(36).slice(2, 8);
|
|
315
|
+
const mapped = imports.split(',').map((s) => {
|
|
316
|
+
const parts = s.trim().split(/\s+as\s+/);
|
|
317
|
+
const sourceProp = parts[0].trim();
|
|
318
|
+
const localName = parts.length === 2 ? parts[1].trim() : sourceProp;
|
|
319
|
+
if (localName)
|
|
320
|
+
importSources.set(localName, { modRef, prop: sourceProp });
|
|
321
|
+
if (parts.length === 2)
|
|
322
|
+
return `${sourceProp}: ${localName}`;
|
|
323
|
+
return sourceProp;
|
|
324
|
+
}).filter((s) => s).join(', ');
|
|
325
|
+
return `\n${indent}const ${modRef} = require(${mod});\n${indent}const { ${mapped} } = ${modRef};`;
|
|
326
|
+
});
|
|
327
|
+
// import * as X from 'mod'
|
|
328
|
+
result = result.replace(/(?:^|\n)([ \t]*)import\s*\*\s*as\s+([\w$]+)\s+from\s*(['"][^'"]+['"])[ \t]*;?/g, (_match, indent, name, mod) => `\n${indent}${cjsDecl(name)} ${name} = require(${mod});`);
|
|
329
|
+
// import X from 'mod' (default import)
|
|
330
|
+
result = result.replace(/(?:^|\n)([ \t]*)import\s+([\w$]+)\s+from\s*(['"][^'"]+['"])[ \t]*;?/g, (_match, indent, name, mod) => `\n${indent}${cjsDecl(name)} ${name} = require(${mod});`);
|
|
331
|
+
// import 'mod' (side-effect)
|
|
332
|
+
result = result.replace(/(?:^|\n)([ \t]*)import\s*(['"][^'"]+['"])[ \t]*;?/g, (_match, indent, mod) => `\n${indent}require(${mod});`);
|
|
333
|
+
// --- Export transforms ---
|
|
334
|
+
// Strip empty export{} (bundler ESM marker, no-op)
|
|
335
|
+
result = result.replace(/(?:^|\n)[ \t]*export\s*\{\s*\}[ \t]*;?/g, '');
|
|
336
|
+
// export * from 'mod' — use getter-based forwarding for live bindings
|
|
337
|
+
result = result.replace(/(?:^|\n)([ \t]*)export\s*\*\s*from\s*(['"][^'"]+['"])[ \t]*;?/g, (_match, indent, mod) => {
|
|
338
|
+
const tmpVar = '__star_' + Math.random().toString(36).slice(2, 8);
|
|
339
|
+
return `\n${indent}const ${tmpVar} = require(${mod});\n${indent}Object.keys(${tmpVar}).forEach(function(k) { if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, { get: function() { return ${tmpVar}[k]; }, enumerable: true, configurable: true }); });`;
|
|
340
|
+
});
|
|
341
|
+
// export { a, b } from 'mod' (re-export) — use getters for live bindings
|
|
342
|
+
// (handles circular dependencies where source module isn't fully populated yet)
|
|
343
|
+
result = result.replace(/(?:^|\n)([ \t]*)export\s*\{([^}]+)\}\s*from\s*(['"][^'"]+['"])[ \t]*;?/g, (match, indent, names, mod) => {
|
|
344
|
+
// Guard: ${ in captured names means regex matched inside a template literal
|
|
345
|
+
if (names.includes('${'))
|
|
346
|
+
return match;
|
|
347
|
+
const tmpVar = '__re_' + Math.random().toString(36).slice(2, 8);
|
|
348
|
+
const assignments = names.split(',').map((s) => {
|
|
349
|
+
const parts = s.trim().split(/\s+as\s+/);
|
|
350
|
+
const local = parts[0].trim();
|
|
351
|
+
const exported = parts.length === 2 ? parts[1].trim() : local;
|
|
352
|
+
return `${indent}Object.defineProperty(exports, '${exported}', { get() { return ${tmpVar}.${local}; }, enumerable: true, configurable: true });`;
|
|
353
|
+
}).join('\n');
|
|
354
|
+
return `\n${indent}const ${tmpVar} = require(${mod});\n${assignments}`;
|
|
355
|
+
});
|
|
356
|
+
// export default <expr> — must come before named export { }
|
|
357
|
+
if (hasDefaultExport && hasNamedExport) {
|
|
358
|
+
result = result.replace(/(?:^|\n)([ \t]*)export\s+default\s+/g, (_match, indent) => `\n${indent}exports.default = `);
|
|
359
|
+
}
|
|
360
|
+
else {
|
|
361
|
+
result = result.replace(/(?:^|\n)([ \t]*)export\s+default\s+/g, (_match, indent) => `\n${indent}module.exports = `);
|
|
362
|
+
}
|
|
363
|
+
// export const/let/var x = ...
|
|
364
|
+
result = result.replace(/(?:^|\n)([ \t]*)export\s+(const|let|var)\s+([\w$]+)\s*=/g, (match, indent, keyword, name) => {
|
|
365
|
+
// Guard: ${ means regex matched inside a template literal
|
|
366
|
+
if (match.includes('${'))
|
|
367
|
+
return match;
|
|
368
|
+
return `\n${indent}${keyword} ${name} = exports.${name} =`;
|
|
369
|
+
});
|
|
370
|
+
// export function f(...) / export async function f(...) / export class C
|
|
371
|
+
result = result.replace(/(?:^|\n)([ \t]*)export\s+(async\s+function\s+([\w$]+)|function\s+([\w$]+)|class\s+([\w$]+))/g, (match, indent, decl, asyncFnName, fnName, className, offset) => {
|
|
372
|
+
// Guard: if char after match is '{', it's a template literal `export function ${fn}`
|
|
373
|
+
// Real exports have '(' after function name or '{' after class + whitespace
|
|
374
|
+
const nextChar = result.charAt(offset + match.length);
|
|
375
|
+
if (nextChar === '{')
|
|
376
|
+
return match;
|
|
377
|
+
const name = asyncFnName || fnName || className;
|
|
378
|
+
trailingExports.push(`exports.${name} = ${name};`);
|
|
379
|
+
return `\n${indent}${decl}`;
|
|
380
|
+
});
|
|
381
|
+
// export { a, b as c } (local exports, no from)
|
|
382
|
+
// Use trailing exports to ensure declarations are fully initialized.
|
|
383
|
+
// For names that were imported from another module, use getters pointing
|
|
384
|
+
// back to the source module reference — this creates ESM-like live bindings
|
|
385
|
+
// that survive circular dependencies.
|
|
386
|
+
result = result.replace(/(?:^|\n)([ \t]*)export\s*\{([^}]+)\}[ \t]*;?/g, (match, _indent, names) => {
|
|
387
|
+
// Guard: ${ in captured names means regex matched inside a template literal
|
|
388
|
+
if (names.includes('${'))
|
|
389
|
+
return match;
|
|
390
|
+
names.split(',').forEach((s) => {
|
|
391
|
+
const parts = s.trim().split(/\s+as\s+/);
|
|
392
|
+
const local = parts[0].trim();
|
|
393
|
+
const exported = parts.length === 2 ? parts[1].trim() : local;
|
|
394
|
+
if (!local)
|
|
395
|
+
return;
|
|
396
|
+
const src = importSources.get(local);
|
|
397
|
+
if (src) {
|
|
398
|
+
// Imported name → lazy getter reading from source module reference
|
|
399
|
+
trailingExports.push(`Object.defineProperty(exports, '${exported}', { get: function() { return ${src.modRef}.${src.prop}; }, enumerable: true, configurable: true });`);
|
|
400
|
+
}
|
|
401
|
+
else {
|
|
402
|
+
// Locally defined → direct assignment at end of file
|
|
403
|
+
trailingExports.push(`exports.${exported} = ${local};`);
|
|
404
|
+
}
|
|
405
|
+
});
|
|
406
|
+
return '';
|
|
407
|
+
});
|
|
408
|
+
// --- Other transforms ---
|
|
409
|
+
// Dynamic import() with string literal → Promise.resolve(require())
|
|
410
|
+
// Negative lookbehind: skip obj.import('...') where '.' precedes import
|
|
411
|
+
result = result.replace(/(?<!\.)(?<!\w)\bimport\s*\(\s*(['"][^'"]+['"])\s*\)/g, (_match, mod) => `Promise.resolve(require(${mod}))`);
|
|
412
|
+
// Dynamic import() with any expression (variables, template literals, nested parens, etc.)
|
|
413
|
+
// Must come AFTER the string-literal version above.
|
|
414
|
+
// Use programmatic paren-balancing since regex can't handle nested parens.
|
|
415
|
+
{
|
|
416
|
+
let i = 0;
|
|
417
|
+
let out = '';
|
|
418
|
+
while (i < result.length) {
|
|
419
|
+
// Look for `import(`
|
|
420
|
+
const importIdx = result.indexOf('import(', i);
|
|
421
|
+
if (importIdx === -1) {
|
|
422
|
+
out += result.slice(i);
|
|
423
|
+
break;
|
|
424
|
+
}
|
|
425
|
+
// Check word boundary: char before 'import' must not be [\w$.] (dot = method call)
|
|
426
|
+
if (importIdx > 0 && /[\w$.]/.test(result[importIdx - 1])) {
|
|
427
|
+
out += result.slice(i, importIdx + 7);
|
|
428
|
+
i = importIdx + 7;
|
|
429
|
+
continue;
|
|
430
|
+
}
|
|
431
|
+
// Skip class/object method definitions like `async import(url) {` or `import(url) {`
|
|
432
|
+
// Method definitions have `) {` after the parameter list (opening method body).
|
|
433
|
+
// Dynamic imports NEVER have `{` directly after `)`.
|
|
434
|
+
{
|
|
435
|
+
let depth = 1;
|
|
436
|
+
let k = importIdx + 7;
|
|
437
|
+
while (k < result.length && depth > 0) {
|
|
438
|
+
if (result[k] === '(')
|
|
439
|
+
depth++;
|
|
440
|
+
else if (result[k] === ')')
|
|
441
|
+
depth--;
|
|
442
|
+
k++;
|
|
443
|
+
}
|
|
444
|
+
if (depth === 0) {
|
|
445
|
+
let afterClose = k;
|
|
446
|
+
while (afterClose < result.length && /[ \t]/.test(result[afterClose]))
|
|
447
|
+
afterClose++;
|
|
448
|
+
if (result[afterClose] === '{') {
|
|
449
|
+
// This is a method/function definition, not a dynamic import — skip
|
|
450
|
+
out += result.slice(i, importIdx + 7);
|
|
451
|
+
i = importIdx + 7;
|
|
452
|
+
continue;
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
out += result.slice(i, importIdx);
|
|
457
|
+
// Find matching close paren with depth tracking
|
|
458
|
+
let depth = 1;
|
|
459
|
+
let j = importIdx + 7; // after 'import('
|
|
460
|
+
while (j < result.length && depth > 0) {
|
|
461
|
+
if (result[j] === '(')
|
|
462
|
+
depth++;
|
|
463
|
+
else if (result[j] === ')')
|
|
464
|
+
depth--;
|
|
465
|
+
j++;
|
|
466
|
+
}
|
|
467
|
+
if (depth === 0) {
|
|
468
|
+
const arg = result.slice(importIdx + 7, j - 1);
|
|
469
|
+
out += `Promise.resolve().then(function() { return require(${arg}); })`;
|
|
470
|
+
}
|
|
471
|
+
else {
|
|
472
|
+
// Unbalanced — leave as-is
|
|
473
|
+
out += result.slice(importIdx, j);
|
|
474
|
+
}
|
|
475
|
+
i = j;
|
|
476
|
+
}
|
|
477
|
+
result = out;
|
|
478
|
+
}
|
|
479
|
+
// --- Final fixups ---
|
|
480
|
+
// Replace const/let declarations of CJS wrapper param names with var.
|
|
481
|
+
// esbuild bundles often emit `const __dirname = ...` which collides with
|
|
482
|
+
// the new Function() wrapper parameters. `var` can shadow them safely.
|
|
483
|
+
result = result.replace(/\b(const|let)\s+(__dirname|__filename|exports|require|module|console|process|Buffer|global)\b/g, (_match, _kw, name) => `var ${name}`);
|
|
484
|
+
// Append trailing exports for exported functions/classes
|
|
485
|
+
if (trailingExports.length > 0) {
|
|
486
|
+
result += '\n' + trailingExports.join('\n');
|
|
487
|
+
}
|
|
488
|
+
// Restore original string/template literal contents
|
|
489
|
+
result = unmaskStringLiterals(result, literals);
|
|
490
|
+
return result;
|
|
491
|
+
}
|
|
492
|
+
function createNodeImpl(kernelOrPortRegistry) {
|
|
493
|
+
return async (ctx) => {
|
|
494
|
+
// Handle -v/--version
|
|
495
|
+
if (ctx.args.length > 0 && (ctx.args[0] === '-v' || ctx.args[0] === '--version')) {
|
|
496
|
+
ctx.stdout.write(NODE_VERSION + '\n');
|
|
497
|
+
return 0;
|
|
498
|
+
}
|
|
499
|
+
// Handle --help
|
|
500
|
+
if (ctx.args.length > 0 && ctx.args[0] === '--help') {
|
|
501
|
+
ctx.stdout.write('Usage: node [-e code] [script.js] [args...]\n');
|
|
502
|
+
ctx.stdout.write(' node -v\n\n');
|
|
503
|
+
ctx.stdout.write('Options:\n');
|
|
504
|
+
ctx.stdout.write(' -e, --eval <code> evaluate code\n');
|
|
505
|
+
ctx.stdout.write(' -v, --version print version\n\n');
|
|
506
|
+
ctx.stdout.write('Limitations:\n');
|
|
507
|
+
ctx.stdout.write(' - ESM support via auto-transform (import/export → require/exports)\n');
|
|
508
|
+
ctx.stdout.write(' - No event loop (top-level async does not settle)\n');
|
|
509
|
+
ctx.stdout.write(' - No native modules\n');
|
|
510
|
+
ctx.stdout.write(' - require() resolves: built-in modules, relative VFS files, installed packages\n');
|
|
511
|
+
return 0;
|
|
512
|
+
}
|
|
513
|
+
let source;
|
|
514
|
+
let filename;
|
|
515
|
+
let scriptArgs;
|
|
516
|
+
// Handle -e / --eval
|
|
517
|
+
if (ctx.args.length > 0 && (ctx.args[0] === '-e' || ctx.args[0] === '--eval')) {
|
|
518
|
+
if (ctx.args.length < 2) {
|
|
519
|
+
ctx.stderr.write('node: -e requires an argument\n');
|
|
520
|
+
return 1;
|
|
521
|
+
}
|
|
522
|
+
source = ctx.args[1];
|
|
523
|
+
filename = '[eval]';
|
|
524
|
+
scriptArgs = ctx.args.slice(2);
|
|
525
|
+
}
|
|
526
|
+
else if (ctx.args.length > 0) {
|
|
527
|
+
// Run script file
|
|
528
|
+
const scriptPath = resolve(ctx.cwd, ctx.args[0]);
|
|
529
|
+
try {
|
|
530
|
+
source = ctx.vfs.readFileString(scriptPath);
|
|
531
|
+
}
|
|
532
|
+
catch (e) {
|
|
533
|
+
if (e instanceof VFSError) {
|
|
534
|
+
ctx.stderr.write(`node: ${ctx.args[0]}: ${e.message}\n`);
|
|
535
|
+
return 1;
|
|
536
|
+
}
|
|
537
|
+
throw e;
|
|
538
|
+
}
|
|
539
|
+
filename = scriptPath;
|
|
540
|
+
scriptArgs = ctx.args.slice(1);
|
|
541
|
+
}
|
|
542
|
+
else {
|
|
543
|
+
// No args -- print usage hint
|
|
544
|
+
ctx.stderr.write('Usage: node [-e code] [script.js] [args...]\n');
|
|
545
|
+
return 1;
|
|
546
|
+
}
|
|
547
|
+
const dir = filename === '[eval]' ? ctx.cwd : dirname(filename);
|
|
548
|
+
// Extract portRegistry from either Kernel or direct Map
|
|
549
|
+
const portRegistry = kernelOrPortRegistry instanceof Map
|
|
550
|
+
? kernelOrPortRegistry
|
|
551
|
+
: kernelOrPortRegistry?.portRegistry;
|
|
552
|
+
const nodeCtx = {
|
|
553
|
+
vfs: ctx.vfs,
|
|
554
|
+
cwd: ctx.cwd,
|
|
555
|
+
env: ctx.env,
|
|
556
|
+
stdout: ctx.stdout,
|
|
557
|
+
stderr: ctx.stderr,
|
|
558
|
+
argv: [filename, ...scriptArgs],
|
|
559
|
+
filename,
|
|
560
|
+
dirname: dir,
|
|
561
|
+
signal: ctx.signal,
|
|
562
|
+
portRegistry,
|
|
563
|
+
routeLoopback: kernelOrPortRegistry instanceof Map
|
|
564
|
+
? undefined
|
|
565
|
+
: kernelOrPortRegistry?.routeLoopback,
|
|
566
|
+
};
|
|
567
|
+
const moduleMap = createModuleMap(nodeCtx);
|
|
568
|
+
const moduleCache = new Map();
|
|
569
|
+
// Stub for @rollup/rollup-* native binary packages (platform-specific NAPI addons).
|
|
570
|
+
// These can't work in a browser environment. Provide shims for the exported functions.
|
|
571
|
+
// Vite's dev server primarily uses es-module-lexer, not rollup's parser, so these
|
|
572
|
+
// may never be called. If they are, hash stubs return safe defaults; parse stubs throw.
|
|
573
|
+
const rollupNativeStub = {
|
|
574
|
+
parse: () => { throw new Error('[lifo] rollup native parser is not available in browser'); },
|
|
575
|
+
parseAsync: () => Promise.reject(new Error('[lifo] rollup native parser is not available in browser')),
|
|
576
|
+
xxhashBase64Url: (data) => {
|
|
577
|
+
// Simple fallback hash — not cryptographically equivalent but sufficient for cache keys
|
|
578
|
+
const s = typeof data === 'string' ? data : String(data);
|
|
579
|
+
let h = 0;
|
|
580
|
+
for (let i = 0; i < s.length; i++)
|
|
581
|
+
h = (Math.imul(31, h) + s.charCodeAt(i)) | 0;
|
|
582
|
+
return (h >>> 0).toString(36);
|
|
583
|
+
},
|
|
584
|
+
xxhashBase36: (data) => {
|
|
585
|
+
const s = typeof data === 'string' ? data : String(data);
|
|
586
|
+
let h = 0;
|
|
587
|
+
for (let i = 0; i < s.length; i++)
|
|
588
|
+
h = (Math.imul(31, h) + s.charCodeAt(i)) | 0;
|
|
589
|
+
return (h >>> 0).toString(36);
|
|
590
|
+
},
|
|
591
|
+
xxhashBase16: (data) => {
|
|
592
|
+
const s = typeof data === 'string' ? data : String(data);
|
|
593
|
+
let h = 0;
|
|
594
|
+
for (let i = 0; i < s.length; i++)
|
|
595
|
+
h = (Math.imul(31, h) + s.charCodeAt(i)) | 0;
|
|
596
|
+
return (h >>> 0).toString(16);
|
|
597
|
+
},
|
|
598
|
+
};
|
|
599
|
+
// Build require function (declared first, module shim overrides below)
|
|
600
|
+
function nodeRequire(name) {
|
|
601
|
+
// Strip node: prefix
|
|
602
|
+
if (name.startsWith('node:'))
|
|
603
|
+
name = name.slice(5);
|
|
604
|
+
// Check cache
|
|
605
|
+
if (moduleCache.has(name))
|
|
606
|
+
return moduleCache.get(name);
|
|
607
|
+
// Built-in modules
|
|
608
|
+
if (moduleMap[name]) {
|
|
609
|
+
const mod = moduleMap[name]();
|
|
610
|
+
moduleCache.set(name, mod);
|
|
611
|
+
return mod;
|
|
612
|
+
}
|
|
613
|
+
// Subpath imports (#specifier)
|
|
614
|
+
if (name.startsWith('#')) {
|
|
615
|
+
const resolved = resolvePackageImport(name, dir);
|
|
616
|
+
if (resolved) {
|
|
617
|
+
const cached = moduleCache.get(resolved.path);
|
|
618
|
+
if (cached)
|
|
619
|
+
return cached;
|
|
620
|
+
const modSource = ctx.vfs.readFileString(resolved.path);
|
|
621
|
+
return executeModule(modSource, resolved.path, resolved.path);
|
|
622
|
+
}
|
|
623
|
+
throw new Error(`Cannot find module '${name}'`);
|
|
624
|
+
}
|
|
625
|
+
// Relative VFS files
|
|
626
|
+
if (name.startsWith('./') || name.startsWith('../') || name.startsWith('/')) {
|
|
627
|
+
const resolved = resolveVfsModule(name, dir);
|
|
628
|
+
if (resolved) {
|
|
629
|
+
const cached = moduleCache.get(resolved.path);
|
|
630
|
+
if (cached)
|
|
631
|
+
return cached;
|
|
632
|
+
if (resolved.path.endsWith('.json')) {
|
|
633
|
+
const content = ctx.vfs.readFileString(resolved.path);
|
|
634
|
+
const parsed = JSON.parse(content);
|
|
635
|
+
moduleCache.set(resolved.path, parsed);
|
|
636
|
+
return parsed;
|
|
637
|
+
}
|
|
638
|
+
const modSource = ctx.vfs.readFileString(resolved.path);
|
|
639
|
+
return executeModule(modSource, resolved.path, resolved.path);
|
|
640
|
+
}
|
|
641
|
+
throw new Error(`Cannot find module '${name}'`);
|
|
642
|
+
}
|
|
643
|
+
// Node-modules resolution (walk up node_modules, global, legacy)
|
|
644
|
+
const nmResolved = resolveNodeModule(name, dir);
|
|
645
|
+
if (nmResolved) {
|
|
646
|
+
const cached = moduleCache.get(nmResolved.path);
|
|
647
|
+
if (cached)
|
|
648
|
+
return cached;
|
|
649
|
+
if (nmResolved.path.endsWith('.json')) {
|
|
650
|
+
const content = ctx.vfs.readFileString(nmResolved.path);
|
|
651
|
+
const parsed = JSON.parse(content);
|
|
652
|
+
moduleCache.set(nmResolved.path, parsed);
|
|
653
|
+
return parsed;
|
|
654
|
+
}
|
|
655
|
+
const modSource = ctx.vfs.readFileString(nmResolved.path);
|
|
656
|
+
return executeModule(modSource, nmResolved.path, nmResolved.path);
|
|
657
|
+
}
|
|
658
|
+
// Stub for rollup native binary packages
|
|
659
|
+
if (name.startsWith('@rollup/rollup-'))
|
|
660
|
+
return rollupNativeStub;
|
|
661
|
+
throw new Error(`Cannot find module '${name}'`);
|
|
662
|
+
}
|
|
663
|
+
// Override module shim so createRequire returns nodeRequire (resolves VFS + node_modules)
|
|
664
|
+
moduleMap.module = () => {
|
|
665
|
+
const createRequire = (_filename) => nodeRequire;
|
|
666
|
+
const builtinNames = Object.keys(moduleMap);
|
|
667
|
+
const isBuiltin = (s) => {
|
|
668
|
+
const n = s.startsWith('node:') ? s.slice(5) : s;
|
|
669
|
+
return builtinNames.includes(n);
|
|
670
|
+
};
|
|
671
|
+
return { createRequire, builtinModules: builtinNames, isBuiltin, default: { createRequire } };
|
|
672
|
+
};
|
|
673
|
+
function resolveVfsModule(name, fromDir) {
|
|
674
|
+
const absPath = resolve(fromDir, name);
|
|
675
|
+
// Try exact path
|
|
676
|
+
if (ctx.vfs.exists(absPath)) {
|
|
677
|
+
try {
|
|
678
|
+
const stat = ctx.vfs.stat(absPath);
|
|
679
|
+
if (stat.type === 'file')
|
|
680
|
+
return { path: absPath };
|
|
681
|
+
// Directory -- try index.js
|
|
682
|
+
const indexPath = join(absPath, 'index.js');
|
|
683
|
+
if (ctx.vfs.exists(indexPath))
|
|
684
|
+
return { path: indexPath };
|
|
685
|
+
}
|
|
686
|
+
catch { /* fall through */ }
|
|
687
|
+
}
|
|
688
|
+
// Try .js extension
|
|
689
|
+
if (!extname(absPath) && ctx.vfs.exists(absPath + '.js')) {
|
|
690
|
+
return { path: absPath + '.js' };
|
|
691
|
+
}
|
|
692
|
+
// Try .mjs extension
|
|
693
|
+
if (!extname(absPath) && ctx.vfs.exists(absPath + '.mjs')) {
|
|
694
|
+
return { path: absPath + '.mjs' };
|
|
695
|
+
}
|
|
696
|
+
// Try .json extension
|
|
697
|
+
if (!extname(absPath) && ctx.vfs.exists(absPath + '.json')) {
|
|
698
|
+
return { path: absPath + '.json' };
|
|
699
|
+
}
|
|
700
|
+
return null;
|
|
701
|
+
}
|
|
702
|
+
// ── Subpath imports (#specifier) resolution ──
|
|
703
|
+
// Node.js package.json "imports" field: #name → conditional file path
|
|
704
|
+
function resolvePackageImport(name, fromDir) {
|
|
705
|
+
// Walk up to find the nearest package.json with an "imports" field
|
|
706
|
+
let current = fromDir;
|
|
707
|
+
for (;;) {
|
|
708
|
+
const pkgPath = join(current, 'package.json');
|
|
709
|
+
if (ctx.vfs.exists(pkgPath)) {
|
|
710
|
+
try {
|
|
711
|
+
const pkg = JSON.parse(ctx.vfs.readFileString(pkgPath));
|
|
712
|
+
if (pkg.imports && typeof pkg.imports === 'object') {
|
|
713
|
+
const importsMap = pkg.imports;
|
|
714
|
+
if (name in importsMap) {
|
|
715
|
+
const target = resolveExportsCondition(importsMap[name]);
|
|
716
|
+
if (target) {
|
|
717
|
+
return resolveVfsModule(target, current);
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
catch { /* ignore parse errors */ }
|
|
723
|
+
break; // Stop at nearest package.json (Node.js semantics)
|
|
724
|
+
}
|
|
725
|
+
const parent = dirname(current);
|
|
726
|
+
if (parent === current)
|
|
727
|
+
break;
|
|
728
|
+
current = parent;
|
|
729
|
+
}
|
|
730
|
+
return null;
|
|
731
|
+
}
|
|
732
|
+
// ── Node-modules resolution (walk up, global, legacy) ──
|
|
733
|
+
function resolveNodeModule(name, fromDir) {
|
|
734
|
+
// Parse package name and optional subpath
|
|
735
|
+
let packageName;
|
|
736
|
+
let subpath = null;
|
|
737
|
+
if (name.startsWith('@')) {
|
|
738
|
+
const parts = name.split('/');
|
|
739
|
+
if (parts.length < 2)
|
|
740
|
+
return null;
|
|
741
|
+
packageName = parts[0] + '/' + parts[1];
|
|
742
|
+
if (parts.length > 2)
|
|
743
|
+
subpath = parts.slice(2).join('/');
|
|
744
|
+
}
|
|
745
|
+
else {
|
|
746
|
+
const slashIdx = name.indexOf('/');
|
|
747
|
+
if (slashIdx !== -1) {
|
|
748
|
+
packageName = name.slice(0, slashIdx);
|
|
749
|
+
subpath = name.slice(slashIdx + 1);
|
|
750
|
+
}
|
|
751
|
+
else {
|
|
752
|
+
packageName = name;
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
// Walk up from fromDir
|
|
756
|
+
let current = fromDir;
|
|
757
|
+
for (;;) {
|
|
758
|
+
const candidate = join(current, 'node_modules', packageName);
|
|
759
|
+
if (ctx.vfs.exists(candidate)) {
|
|
760
|
+
const resolved = resolvePackageEntry(candidate, subpath);
|
|
761
|
+
if (resolved)
|
|
762
|
+
return resolved;
|
|
763
|
+
}
|
|
764
|
+
const parent = dirname(current);
|
|
765
|
+
if (parent === current)
|
|
766
|
+
break;
|
|
767
|
+
current = parent;
|
|
768
|
+
}
|
|
769
|
+
// Global modules
|
|
770
|
+
const globalCandidate = join('/usr/lib/node_modules', packageName);
|
|
771
|
+
if (ctx.vfs.exists(globalCandidate)) {
|
|
772
|
+
const resolved = resolvePackageEntry(globalCandidate, subpath);
|
|
773
|
+
if (resolved)
|
|
774
|
+
return resolved;
|
|
775
|
+
}
|
|
776
|
+
// Legacy location (pkg command)
|
|
777
|
+
const legacyCandidate = join('/usr/share/pkg/node_modules', packageName);
|
|
778
|
+
if (ctx.vfs.exists(legacyCandidate)) {
|
|
779
|
+
const resolved = resolvePackageEntry(legacyCandidate, subpath);
|
|
780
|
+
if (resolved)
|
|
781
|
+
return resolved;
|
|
782
|
+
}
|
|
783
|
+
return null;
|
|
784
|
+
}
|
|
785
|
+
/** Resolve a conditional exports value (string | { require, import, default, ... }) */
|
|
786
|
+
function resolveExportsCondition(value) {
|
|
787
|
+
if (typeof value === 'string')
|
|
788
|
+
return value;
|
|
789
|
+
if (value && typeof value === 'object' && !Array.isArray(value)) {
|
|
790
|
+
const cond = value;
|
|
791
|
+
// Prefer require (CJS), then default, then import (ESM)
|
|
792
|
+
if (typeof cond.require === 'string')
|
|
793
|
+
return cond.require;
|
|
794
|
+
if (typeof cond.default === 'string')
|
|
795
|
+
return cond.default;
|
|
796
|
+
if (typeof cond.import === 'string')
|
|
797
|
+
return cond.import;
|
|
798
|
+
// Recurse into nested conditions (e.g. { node: { require: ... } })
|
|
799
|
+
for (const key of Object.keys(cond)) {
|
|
800
|
+
if (key === 'types')
|
|
801
|
+
continue; // skip TS declarations
|
|
802
|
+
const nested = resolveExportsCondition(cond[key]);
|
|
803
|
+
if (nested)
|
|
804
|
+
return nested;
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
return null;
|
|
808
|
+
}
|
|
809
|
+
function resolvePackageEntry(pkgDir, subpath) {
|
|
810
|
+
const pkgJsonPath = join(pkgDir, 'package.json');
|
|
811
|
+
let pkgJson = null;
|
|
812
|
+
if (ctx.vfs.exists(pkgJsonPath)) {
|
|
813
|
+
try {
|
|
814
|
+
pkgJson = JSON.parse(ctx.vfs.readFileString(pkgJsonPath));
|
|
815
|
+
}
|
|
816
|
+
catch { /* ignore */ }
|
|
817
|
+
}
|
|
818
|
+
// --- Subpath resolution (e.g. require('rollup/parseAst')) ---
|
|
819
|
+
if (subpath) {
|
|
820
|
+
// 1. Check exports map first (Node.js subpath exports)
|
|
821
|
+
if (pkgJson?.exports && typeof pkgJson.exports === 'object') {
|
|
822
|
+
const exportsMap = pkgJson.exports;
|
|
823
|
+
const key = './' + subpath;
|
|
824
|
+
if (key in exportsMap) {
|
|
825
|
+
const target = resolveExportsCondition(exportsMap[key]);
|
|
826
|
+
if (target) {
|
|
827
|
+
const resolved = resolveVfsModule(target, pkgDir);
|
|
828
|
+
if (resolved)
|
|
829
|
+
return resolved;
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
// Also try wildcard/glob patterns like "./dist/*": "./dist/*"
|
|
833
|
+
for (const pattern of Object.keys(exportsMap)) {
|
|
834
|
+
if (pattern.endsWith('/*') && key.startsWith(pattern.slice(0, -1))) {
|
|
835
|
+
const targetPattern = resolveExportsCondition(exportsMap[pattern]);
|
|
836
|
+
if (targetPattern && targetPattern.endsWith('/*')) {
|
|
837
|
+
const suffix = key.slice(pattern.length - 1);
|
|
838
|
+
const target = targetPattern.slice(0, -1) + suffix;
|
|
839
|
+
const resolved = resolveVfsModule(target, pkgDir);
|
|
840
|
+
if (resolved)
|
|
841
|
+
return resolved;
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
// 2. Fall back to direct file resolution
|
|
847
|
+
return resolveVfsModule('./' + subpath, pkgDir);
|
|
848
|
+
}
|
|
849
|
+
// --- Root resolution (e.g. require('rollup')) ---
|
|
850
|
+
// 1. Check exports["."] first
|
|
851
|
+
if (pkgJson?.exports) {
|
|
852
|
+
const exportsVal = pkgJson.exports;
|
|
853
|
+
let rootExport = null;
|
|
854
|
+
if (typeof exportsVal === 'string') {
|
|
855
|
+
rootExport = exportsVal;
|
|
856
|
+
}
|
|
857
|
+
else if (typeof exportsVal === 'object' && !Array.isArray(exportsVal)) {
|
|
858
|
+
const exportsMap = exportsVal;
|
|
859
|
+
rootExport = exportsMap['.'] ?? null;
|
|
860
|
+
// Handle case where exports IS the condition map (no "." key)
|
|
861
|
+
if (!rootExport && ('require' in exportsMap || 'import' in exportsMap || 'default' in exportsMap)) {
|
|
862
|
+
rootExport = exportsMap;
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
if (rootExport) {
|
|
866
|
+
const target = resolveExportsCondition(rootExport);
|
|
867
|
+
if (target) {
|
|
868
|
+
const resolved = resolveVfsModule(target, pkgDir);
|
|
869
|
+
if (resolved)
|
|
870
|
+
return resolved;
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
// 2. Check main field
|
|
875
|
+
if (pkgJson?.main && typeof pkgJson.main === 'string') {
|
|
876
|
+
const resolved = resolveVfsModule('./' + pkgJson.main, pkgDir);
|
|
877
|
+
if (resolved)
|
|
878
|
+
return resolved;
|
|
879
|
+
}
|
|
880
|
+
// 3. Default to index.js
|
|
881
|
+
const indexPath = join(pkgDir, 'index.js');
|
|
882
|
+
if (ctx.vfs.exists(indexPath))
|
|
883
|
+
return { path: indexPath };
|
|
884
|
+
return null;
|
|
885
|
+
}
|
|
886
|
+
function executeModule(modSource, modFilename, cacheAs) {
|
|
887
|
+
const modDir = dirname(modFilename);
|
|
888
|
+
const modModule = { exports: {} };
|
|
889
|
+
const modExports = modModule.exports;
|
|
890
|
+
// Pre-cache to handle circular dependencies (Node.js behaviour)
|
|
891
|
+
if (cacheAs) {
|
|
892
|
+
moduleCache.set(cacheAs, modExports);
|
|
893
|
+
}
|
|
894
|
+
const modNodeCtx = { ...nodeCtx, filename: modFilename, dirname: modDir };
|
|
895
|
+
const modModuleMap = createModuleMap(modNodeCtx);
|
|
896
|
+
const modProcess = createProcess({
|
|
897
|
+
argv: nodeCtx.argv,
|
|
898
|
+
env: nodeCtx.env,
|
|
899
|
+
cwd: nodeCtx.cwd,
|
|
900
|
+
stdout: ctx.stdout,
|
|
901
|
+
stderr: ctx.stderr,
|
|
902
|
+
});
|
|
903
|
+
const modConsole = createConsole(ctx.stdout, ctx.stderr);
|
|
904
|
+
function modRequire(name) {
|
|
905
|
+
// Strip node: prefix
|
|
906
|
+
if (name.startsWith('node:'))
|
|
907
|
+
name = name.slice(5);
|
|
908
|
+
// Built-in modules from child context
|
|
909
|
+
if (modModuleMap[name]) {
|
|
910
|
+
const cached = moduleCache.get(name);
|
|
911
|
+
if (cached)
|
|
912
|
+
return cached;
|
|
913
|
+
const mod = modModuleMap[name]();
|
|
914
|
+
moduleCache.set(name, mod);
|
|
915
|
+
return mod;
|
|
916
|
+
}
|
|
917
|
+
// Subpath imports (#specifier)
|
|
918
|
+
if (name.startsWith('#')) {
|
|
919
|
+
const resolved = resolvePackageImport(name, modDir);
|
|
920
|
+
if (resolved) {
|
|
921
|
+
const cached = moduleCache.get(resolved.path);
|
|
922
|
+
if (cached)
|
|
923
|
+
return cached;
|
|
924
|
+
const childSource = ctx.vfs.readFileString(resolved.path);
|
|
925
|
+
return executeModule(childSource, resolved.path, resolved.path);
|
|
926
|
+
}
|
|
927
|
+
throw new Error(`Cannot find module '${name}'`);
|
|
928
|
+
}
|
|
929
|
+
if (name.startsWith('./') || name.startsWith('../') || name.startsWith('/')) {
|
|
930
|
+
const resolved = resolveVfsModule(name, modDir);
|
|
931
|
+
if (resolved) {
|
|
932
|
+
const cached = moduleCache.get(resolved.path);
|
|
933
|
+
if (cached)
|
|
934
|
+
return cached;
|
|
935
|
+
if (resolved.path.endsWith('.json')) {
|
|
936
|
+
const content = ctx.vfs.readFileString(resolved.path);
|
|
937
|
+
const parsed = JSON.parse(content);
|
|
938
|
+
moduleCache.set(resolved.path, parsed);
|
|
939
|
+
return parsed;
|
|
940
|
+
}
|
|
941
|
+
const childSource = ctx.vfs.readFileString(resolved.path);
|
|
942
|
+
return executeModule(childSource, resolved.path, resolved.path);
|
|
943
|
+
}
|
|
944
|
+
throw new Error(`Cannot find module '${name}'`);
|
|
945
|
+
}
|
|
946
|
+
// Node-modules resolution from this module's directory
|
|
947
|
+
const nmResolved = resolveNodeModule(name, modDir);
|
|
948
|
+
if (nmResolved) {
|
|
949
|
+
const cached = moduleCache.get(nmResolved.path);
|
|
950
|
+
if (cached)
|
|
951
|
+
return cached;
|
|
952
|
+
if (nmResolved.path.endsWith('.json')) {
|
|
953
|
+
const content = ctx.vfs.readFileString(nmResolved.path);
|
|
954
|
+
const parsed = JSON.parse(content);
|
|
955
|
+
moduleCache.set(nmResolved.path, parsed);
|
|
956
|
+
return parsed;
|
|
957
|
+
}
|
|
958
|
+
const childSource = ctx.vfs.readFileString(nmResolved.path);
|
|
959
|
+
return executeModule(childSource, nmResolved.path, nmResolved.path);
|
|
960
|
+
}
|
|
961
|
+
// Stub for rollup native binary packages
|
|
962
|
+
if (name.startsWith('@rollup/rollup-'))
|
|
963
|
+
return rollupNativeStub;
|
|
964
|
+
throw new Error(`Cannot find module '${name}'`);
|
|
965
|
+
}
|
|
966
|
+
// Override module shim so createRequire returns modRequire (resolves VFS + node_modules too)
|
|
967
|
+
modModuleMap.module = () => {
|
|
968
|
+
const createRequire = (_filename) => modRequire;
|
|
969
|
+
const builtinNames = Object.keys(modModuleMap);
|
|
970
|
+
const isBuiltin = (s) => {
|
|
971
|
+
const n = s.startsWith('node:') ? s.slice(5) : s;
|
|
972
|
+
return builtinNames.includes(n);
|
|
973
|
+
};
|
|
974
|
+
return { createRequire, builtinModules: builtinNames, isBuiltin, default: { createRequire } };
|
|
975
|
+
};
|
|
976
|
+
let cleanSource = stripShebang(modSource);
|
|
977
|
+
if (shouldTreatAsEsm(cleanSource, modFilename, ctx.vfs)) {
|
|
978
|
+
cleanSource = transformEsmToCjs(cleanSource);
|
|
979
|
+
}
|
|
980
|
+
const wrapped = `(function(exports, require, module, __filename, __dirname, console, process, Buffer, setTimeout, setInterval, clearTimeout, clearInterval, global, __importMetaUrl, __importMeta, __importMetaResolve) {\n${cleanSource}\n})`;
|
|
981
|
+
let fn;
|
|
982
|
+
try {
|
|
983
|
+
fn = new Function('return ' + wrapped)();
|
|
984
|
+
}
|
|
985
|
+
catch (e) {
|
|
986
|
+
const err = e instanceof Error ? e : new Error(String(e));
|
|
987
|
+
ctx.stderr.write(`[ESM-FAIL] file=${modFilename} srcLen=${modSource.length} err=${err.message}\n`);
|
|
988
|
+
// Binary search for exact error location, matching specific error
|
|
989
|
+
const lines = cleanSource.split('\n');
|
|
990
|
+
const targetErr = err.message;
|
|
991
|
+
let lo = 0, hi = lines.length;
|
|
992
|
+
while (hi - lo > 3) {
|
|
993
|
+
const mid = (lo + hi) >>> 1;
|
|
994
|
+
const partial = lines.slice(0, mid).join('\n');
|
|
995
|
+
try {
|
|
996
|
+
new Function(partial);
|
|
997
|
+
lo = mid;
|
|
998
|
+
}
|
|
999
|
+
catch (e2) {
|
|
1000
|
+
if (e2 instanceof Error && e2.message === targetErr)
|
|
1001
|
+
hi = mid;
|
|
1002
|
+
else
|
|
1003
|
+
lo = mid; // Different error (e.g. unclosed), keep going
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
1006
|
+
ctx.stderr.write(`[ESM-FAIL] error at L${lo}-${hi}, showing L${Math.max(1, lo - 25)} to L${hi + 3}:\n`);
|
|
1007
|
+
for (let li = Math.max(0, lo - 25); li < Math.min(lines.length, hi + 3); li++) {
|
|
1008
|
+
ctx.stderr.write(`[ESM-FAIL] ${li + 1 === lo || li + 1 === hi ? '>>>' : ' '} L${li + 1}: ${lines[li]?.slice(0, 200)}\n`);
|
|
1009
|
+
}
|
|
1010
|
+
err.message = `[${modFilename}] ${err.message}`;
|
|
1011
|
+
throw err;
|
|
1012
|
+
}
|
|
1013
|
+
const global = { process: modProcess, Buffer, console: modConsole };
|
|
1014
|
+
// Many npm bundles access globalThis.process directly (not the wrapper param).
|
|
1015
|
+
// Only override in browser-like envs; skip in real Node.js (test runner).
|
|
1016
|
+
const ga = globalThis;
|
|
1017
|
+
const isRealNode = typeof ga.process?.pid === 'number';
|
|
1018
|
+
const savedProcess = ga.process;
|
|
1019
|
+
const savedBuffer = ga.Buffer;
|
|
1020
|
+
const savedConsole = ga.console;
|
|
1021
|
+
if (!isRealNode) {
|
|
1022
|
+
ga.process = modProcess;
|
|
1023
|
+
ga.Buffer = Buffer;
|
|
1024
|
+
ga.console = modConsole;
|
|
1025
|
+
}
|
|
1026
|
+
// Inject Rollup/esbuild interop helpers so bundled npm packages can find them
|
|
1027
|
+
const savedHelpers = {};
|
|
1028
|
+
for (const k of Object.keys(_rollupHelpers)) {
|
|
1029
|
+
savedHelpers[k] = ga[k];
|
|
1030
|
+
ga[k] = _rollupHelpers[k];
|
|
1031
|
+
}
|
|
1032
|
+
const importMetaUrl = 'file://' + modFilename;
|
|
1033
|
+
const importMeta = { url: importMetaUrl, dirname: modDir, filename: modFilename };
|
|
1034
|
+
const importMetaResolve = (specifier) => { throw new Error(`import.meta.resolve('${specifier}') is not supported`); };
|
|
1035
|
+
try {
|
|
1036
|
+
fn(modExports, modRequire, modModule, modFilename, modDir, modConsole, modProcess, Buffer, globalThis.setTimeout, globalThis.setInterval, globalThis.clearTimeout, globalThis.clearInterval, global, importMetaUrl, importMeta, importMetaResolve);
|
|
1037
|
+
}
|
|
1038
|
+
catch (e) {
|
|
1039
|
+
if (e instanceof ProcessExitError)
|
|
1040
|
+
throw e;
|
|
1041
|
+
const err = e instanceof Error ? e : new Error(String(e));
|
|
1042
|
+
if (!err.message.includes('[/')) {
|
|
1043
|
+
err.message = `[${modFilename}] ${err.message}`;
|
|
1044
|
+
}
|
|
1045
|
+
throw err;
|
|
1046
|
+
}
|
|
1047
|
+
finally {
|
|
1048
|
+
for (const k of Object.keys(savedHelpers))
|
|
1049
|
+
ga[k] = savedHelpers[k];
|
|
1050
|
+
if (!isRealNode) {
|
|
1051
|
+
ga.process = savedProcess;
|
|
1052
|
+
ga.Buffer = savedBuffer;
|
|
1053
|
+
ga.console = savedConsole;
|
|
1054
|
+
}
|
|
1055
|
+
}
|
|
1056
|
+
// Update cache if module.exports was reassigned (not just mutated)
|
|
1057
|
+
if (cacheAs && modModule.exports !== modExports) {
|
|
1058
|
+
moduleCache.set(cacheAs, modModule.exports);
|
|
1059
|
+
}
|
|
1060
|
+
return modModule.exports;
|
|
1061
|
+
}
|
|
1062
|
+
// Execute main script
|
|
1063
|
+
const process = createProcess({
|
|
1064
|
+
argv: nodeCtx.argv,
|
|
1065
|
+
env: nodeCtx.env,
|
|
1066
|
+
cwd: nodeCtx.cwd,
|
|
1067
|
+
stdout: ctx.stdout,
|
|
1068
|
+
stderr: ctx.stderr,
|
|
1069
|
+
});
|
|
1070
|
+
const nodeConsole = createConsole(ctx.stdout, ctx.stderr);
|
|
1071
|
+
const module = { exports: {} };
|
|
1072
|
+
const exports = module.exports;
|
|
1073
|
+
const global = { process, Buffer, console: nodeConsole };
|
|
1074
|
+
let cleanMainSource = stripShebang(source);
|
|
1075
|
+
const isEsm = shouldTreatAsEsm(cleanMainSource, filename, ctx.vfs);
|
|
1076
|
+
if (isEsm) {
|
|
1077
|
+
cleanMainSource = transformEsmToCjs(cleanMainSource);
|
|
1078
|
+
}
|
|
1079
|
+
// Use async IIFE for ESM (supports top-level await)
|
|
1080
|
+
const wrapped = isEsm
|
|
1081
|
+
? `(async function(exports, require, module, __filename, __dirname, console, process, Buffer, setTimeout, setInterval, clearTimeout, clearInterval, global, __importMetaUrl, __importMeta, __importMetaResolve) {\n${cleanMainSource}\n})`
|
|
1082
|
+
: `(function(exports, require, module, __filename, __dirname, console, process, Buffer, setTimeout, setInterval, clearTimeout, clearInterval, global, __importMetaUrl, __importMeta, __importMetaResolve) {\n${cleanMainSource}\n})`;
|
|
1083
|
+
// Many npm bundles access globalThis.process directly (not the wrapper param).
|
|
1084
|
+
// Only override in browser-like envs; skip in real Node.js (test runner).
|
|
1085
|
+
const ga = globalThis;
|
|
1086
|
+
const isRealNode = typeof ga.process?.pid === 'number';
|
|
1087
|
+
const savedProcess = ga.process;
|
|
1088
|
+
const savedBuffer = ga.Buffer;
|
|
1089
|
+
const savedConsole = ga.console;
|
|
1090
|
+
if (!isRealNode) {
|
|
1091
|
+
ga.process = process;
|
|
1092
|
+
ga.Buffer = Buffer;
|
|
1093
|
+
ga.console = nodeConsole;
|
|
1094
|
+
}
|
|
1095
|
+
// Inject Rollup/esbuild interop helpers so bundled npm packages can find them
|
|
1096
|
+
const savedHelpers = {};
|
|
1097
|
+
for (const k of Object.keys(_rollupHelpers)) {
|
|
1098
|
+
savedHelpers[k] = ga[k];
|
|
1099
|
+
ga[k] = _rollupHelpers[k];
|
|
1100
|
+
}
|
|
1101
|
+
// Capture unhandled promise rejections from fire-and-forget async actions
|
|
1102
|
+
let pendingRejection = null;
|
|
1103
|
+
const rejectionHandler = (event) => {
|
|
1104
|
+
pendingRejection = event.reason;
|
|
1105
|
+
event.preventDefault(); // prevent browser default logging
|
|
1106
|
+
ctx.stderr.write(`Unhandled promise rejection: ${event.reason instanceof Error ? event.reason.stack || event.reason.message : String(event.reason)}\n`);
|
|
1107
|
+
};
|
|
1108
|
+
if (typeof globalThis.addEventListener === 'function') {
|
|
1109
|
+
globalThis.addEventListener('unhandledrejection', rejectionHandler);
|
|
1110
|
+
}
|
|
1111
|
+
const mainImportMetaUrl = 'file://' + filename;
|
|
1112
|
+
const mainImportMeta = { url: mainImportMetaUrl, dirname: dir, filename };
|
|
1113
|
+
const mainImportMetaResolve = (specifier) => { throw new Error(`import.meta.resolve('${specifier}') is not supported`); };
|
|
1114
|
+
try {
|
|
1115
|
+
const fn = new Function('return ' + wrapped)();
|
|
1116
|
+
const result = fn(exports, nodeRequire, module, filename, dir, nodeConsole, process, Buffer, globalThis.setTimeout, globalThis.setInterval, globalThis.clearTimeout, globalThis.clearInterval, global, mainImportMetaUrl, mainImportMeta, mainImportMetaResolve);
|
|
1117
|
+
// Await if ESM (async IIFE returns a promise)
|
|
1118
|
+
if (isEsm && result && typeof result.then === 'function') {
|
|
1119
|
+
await result;
|
|
1120
|
+
}
|
|
1121
|
+
// Check if any servers were started (long-running process).
|
|
1122
|
+
// Many CLI tools (e.g. vite) fire async actions from cli.parse() whose
|
|
1123
|
+
// promises are discarded. We poll briefly to let those async chains
|
|
1124
|
+
// progress and create servers before deciding the process is done.
|
|
1125
|
+
// Only poll if http was actually loaded (indicating server intent).
|
|
1126
|
+
const getActiveServers = () => {
|
|
1127
|
+
const httpMod = moduleCache.get('http');
|
|
1128
|
+
return httpMod?.[ACTIVE_SERVERS];
|
|
1129
|
+
};
|
|
1130
|
+
let activeServers = getActiveServers();
|
|
1131
|
+
if ((!activeServers || activeServers.length === 0) && isEsm) {
|
|
1132
|
+
// ESM scripts may have fire-and-forget async actions (e.g. vite's
|
|
1133
|
+
// cli.parse() triggers an async action whose promise is discarded).
|
|
1134
|
+
// Yield briefly to let those chains start, then poll for servers.
|
|
1135
|
+
// Phase 1: Quick yield — watch for new modules being loaded, which
|
|
1136
|
+
// indicates async work is in progress. Stop early if nothing changes.
|
|
1137
|
+
let prevCacheSize = moduleCache.size;
|
|
1138
|
+
let staleCount = 0;
|
|
1139
|
+
const quickDeadline = Date.now() + 2000;
|
|
1140
|
+
while (Date.now() < quickDeadline) {
|
|
1141
|
+
await new Promise((r) => setTimeout(r, 30));
|
|
1142
|
+
activeServers = getActiveServers();
|
|
1143
|
+
if (activeServers && activeServers.length > 0)
|
|
1144
|
+
break;
|
|
1145
|
+
if (ctx.signal.aborted || pendingRejection)
|
|
1146
|
+
break;
|
|
1147
|
+
// If new modules are loading, async work is progressing
|
|
1148
|
+
const newSize = moduleCache.size;
|
|
1149
|
+
if (newSize > prevCacheSize) {
|
|
1150
|
+
staleCount = 0;
|
|
1151
|
+
prevCacheSize = newSize;
|
|
1152
|
+
}
|
|
1153
|
+
else {
|
|
1154
|
+
staleCount++;
|
|
1155
|
+
// No new modules for 5 ticks (150ms) — async chain likely done
|
|
1156
|
+
if (staleCount >= 5)
|
|
1157
|
+
break;
|
|
1158
|
+
}
|
|
1159
|
+
}
|
|
1160
|
+
// Phase 2: If http was loaded during Phase 1 (indicating server intent)
|
|
1161
|
+
// but no servers yet, keep polling up to 10s for the full server startup.
|
|
1162
|
+
if ((!activeServers || activeServers.length === 0) && moduleCache.has('http')) {
|
|
1163
|
+
const longDeadline = Date.now() + 10000;
|
|
1164
|
+
while (Date.now() < longDeadline) {
|
|
1165
|
+
await new Promise((r) => setTimeout(r, 50));
|
|
1166
|
+
activeServers = getActiveServers();
|
|
1167
|
+
if (activeServers && activeServers.length > 0)
|
|
1168
|
+
break;
|
|
1169
|
+
if (ctx.signal.aborted || pendingRejection)
|
|
1170
|
+
break;
|
|
1171
|
+
}
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1174
|
+
if (activeServers && activeServers.length > 0) {
|
|
1175
|
+
// Collect all server promises
|
|
1176
|
+
const serverPromises = activeServers
|
|
1177
|
+
.map((s) => s.getPromise())
|
|
1178
|
+
.filter((p) => p !== null);
|
|
1179
|
+
if (serverPromises.length > 0) {
|
|
1180
|
+
// Wait for all servers to close OR for abort signal
|
|
1181
|
+
const abortPromise = new Promise((resolve) => {
|
|
1182
|
+
if (ctx.signal.aborted) {
|
|
1183
|
+
resolve();
|
|
1184
|
+
return;
|
|
1185
|
+
}
|
|
1186
|
+
ctx.signal.addEventListener('abort', () => resolve(), { once: true });
|
|
1187
|
+
});
|
|
1188
|
+
await Promise.race([
|
|
1189
|
+
Promise.all(serverPromises),
|
|
1190
|
+
abortPromise,
|
|
1191
|
+
]);
|
|
1192
|
+
// On abort, close all active servers
|
|
1193
|
+
if (ctx.signal.aborted) {
|
|
1194
|
+
for (const server of [...activeServers]) {
|
|
1195
|
+
server.close();
|
|
1196
|
+
}
|
|
1197
|
+
}
|
|
1198
|
+
}
|
|
1199
|
+
}
|
|
1200
|
+
// If an async action failed (e.g. unhandled rejection from ProcessExitError)
|
|
1201
|
+
if (pendingRejection) {
|
|
1202
|
+
if (pendingRejection instanceof ProcessExitError)
|
|
1203
|
+
return pendingRejection.exitCode;
|
|
1204
|
+
return 1;
|
|
1205
|
+
}
|
|
1206
|
+
return 0;
|
|
1207
|
+
}
|
|
1208
|
+
catch (e) {
|
|
1209
|
+
if (e instanceof ProcessExitError) {
|
|
1210
|
+
return e.exitCode;
|
|
1211
|
+
}
|
|
1212
|
+
if (e instanceof Error) {
|
|
1213
|
+
ctx.stderr.write(`${e.stack || e.message}\n`);
|
|
1214
|
+
}
|
|
1215
|
+
else {
|
|
1216
|
+
ctx.stderr.write(`${String(e)}\n`);
|
|
1217
|
+
}
|
|
1218
|
+
return 1;
|
|
1219
|
+
}
|
|
1220
|
+
finally {
|
|
1221
|
+
for (const k of Object.keys(savedHelpers))
|
|
1222
|
+
ga[k] = savedHelpers[k];
|
|
1223
|
+
if (!isRealNode) {
|
|
1224
|
+
ga.process = savedProcess;
|
|
1225
|
+
ga.Buffer = savedBuffer;
|
|
1226
|
+
ga.console = savedConsole;
|
|
1227
|
+
}
|
|
1228
|
+
// Remove unhandled rejection listener
|
|
1229
|
+
if (typeof globalThis.removeEventListener === 'function') {
|
|
1230
|
+
globalThis.removeEventListener('unhandledrejection', rejectionHandler);
|
|
1231
|
+
}
|
|
1232
|
+
}
|
|
1233
|
+
};
|
|
1234
|
+
}
|
|
1235
|
+
export function createNodeCommand(kernel) {
|
|
1236
|
+
return createNodeImpl(kernel);
|
|
1237
|
+
}
|
|
1238
|
+
// Default command with a shared portRegistry so http.createServer works
|
|
1239
|
+
const defaultPortRegistry = new Map();
|
|
1240
|
+
const command = createNodeImpl(defaultPortRegistry);
|
|
1241
|
+
export default command;
|