@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,1470 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EsbuildService — TypeScript/JSX transform + bundling via esbuild-wasm.
|
|
3
|
+
*
|
|
4
|
+
* Architecture:
|
|
5
|
+
* - esbuild-wasm is imported directly in the supervisor bundle
|
|
6
|
+
* - WASM is compiled during module evaluation (startup phase) — allowed
|
|
7
|
+
* - transform() runs in the supervisor's isolate (fast, no facet needed)
|
|
8
|
+
* - build() also runs in supervisor with a VFS resolver plugin
|
|
9
|
+
*
|
|
10
|
+
* Why not a facet? The esbuild-wasm WASM binary needs to be compiled
|
|
11
|
+
* during module startup (not request time). Dynamic workers created via
|
|
12
|
+
* LOADER.load() have the same restriction. Since esbuild-wasm is bundled
|
|
13
|
+
* into the supervisor, it initializes once at startup and stays warm.
|
|
14
|
+
*
|
|
15
|
+
* Memory: esbuild-wasm uses ~15-20MB heap. Within the DO's 128MB budget
|
|
16
|
+
* this is acceptable for Phase 3. Phase 4+ can move it to a dedicated
|
|
17
|
+
* facet once wasm module passing to dynamic workers is stable.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import type { CredentialedVfs, SqliteVFS } from '../vfs/sqlite-vfs.js';
|
|
21
|
+
import { CRED_KERNEL } from './os-contracts.js';
|
|
22
|
+
import { resolvePackageEntry, resolveExports } from '../_shared/exports-resolver.js';
|
|
23
|
+
import { normalizeVfsPath, stripLeadingSlashes } from '../vfs/path.js';
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Bundler version tag. BUMP THIS whenever bundling semantics change —
|
|
27
|
+
* the esbuild plugin's resolver logic, the shared-externals rules, the
|
|
28
|
+
* post-processing pipeline, or anything that would invalidate cached
|
|
29
|
+
* pre-bundles. The version is stored in pkg_esm_bundles.bundle_hash and
|
|
30
|
+
* checked on read; cache entries with a different version are treated
|
|
31
|
+
* as missing and rebuilt from scratch.
|
|
32
|
+
*
|
|
33
|
+
* History:
|
|
34
|
+
* v1 — initial pre-bundling
|
|
35
|
+
* v2 — shared React externals, CJS named exports
|
|
36
|
+
* v3 — Node subpath imports (#foo) support for vfile/unified ecosystem
|
|
37
|
+
* v4 — legacy flat-subpath resolution (pkg/sub without exports field);
|
|
38
|
+
* CDN fallback wrapper no longer crashes on modules without default
|
|
39
|
+
* v5 — normalize `../` segments in joined entry paths (react-remove-scroll-bar
|
|
40
|
+
* style: nested package.json with "module": "../dist/es2015/foo.js")
|
|
41
|
+
* v6 — externals enforced via plugin onResolve only (top-level `external:`
|
|
42
|
+
* dropped). Fixes dual-React-instance bug where jsx-runtime and
|
|
43
|
+
* react-dom/client were inlining their own copy of react because
|
|
44
|
+
* esbuild's entry-point external check rejected the externals when
|
|
45
|
+
* passed at the top level. v5 cache entries are wrong (contain
|
|
46
|
+
* embedded react copies) and must be invalidated.
|
|
47
|
+
* v7 — barrel-package bundles include a named-import signature in
|
|
48
|
+
* pkg_esm_bundles.input_hash. Prevents reusing a lucide-react
|
|
49
|
+
* bundle synthesized for one icon set after user source imports
|
|
50
|
+
* additional icons.
|
|
51
|
+
* v8 — pkg_esm_bundles now stores RAW esbuild output (base-independent);
|
|
52
|
+
* the module-URL rewrite that used to be baked in is applied per
|
|
53
|
+
* request at serve time so one bundle serves every mount base. v7
|
|
54
|
+
* rows hold post-rewrite text and must be re-bundled. user_module_
|
|
55
|
+
* transforms is likewise re-keyed by mount base.
|
|
56
|
+
*/
|
|
57
|
+
export const BUNDLER_VERSION = 'v8';
|
|
58
|
+
|
|
59
|
+
// ── Shared-runtime externals ────────────────────────────────────────────
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Returns the list of specifiers that must be marked `external` when bundling
|
|
63
|
+
* `specifier` so that React / React-DOM / Scheduler share a single instance
|
|
64
|
+
* across all /@modules/ bundles.
|
|
65
|
+
*
|
|
66
|
+
* Why: React uses an internal module-scoped singleton
|
|
67
|
+
* (`__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED`) for current dispatcher,
|
|
68
|
+
* owner, etc. If two bundles each contain their own embedded React, they each
|
|
69
|
+
* have their own singleton, and `createRoot` from one bundle sees JSX elements
|
|
70
|
+
* created by the other as "alien" — silent render failure (root stays empty).
|
|
71
|
+
*
|
|
72
|
+
* The fix: when bundling react-dom/*, mark react/* and scheduler as external.
|
|
73
|
+
* The bundler leaves `import {...} from "react"` in the output; the browser
|
|
74
|
+
* then fetches /preview/@modules/react, which is the SAME URL the jsx-runtime
|
|
75
|
+
* bundle imports — so both react-dom and jsx-runtime share ONE React instance.
|
|
76
|
+
*
|
|
77
|
+
* Similarly for react/jsx-runtime and react/jsx-dev-runtime (they must share
|
|
78
|
+
* react's internals), we externalize `react` (but not `scheduler` — jsx-runtime
|
|
79
|
+
* doesn't need it).
|
|
80
|
+
*/
|
|
81
|
+
export function getSharedRuntimeExternals(specifier: string): string[] {
|
|
82
|
+
// react: the canonical bundle. No externals — it's the source of truth.
|
|
83
|
+
if (specifier === 'react') return [];
|
|
84
|
+
|
|
85
|
+
// react/jsx-runtime, react/jsx-dev-runtime: import from react's
|
|
86
|
+
// ReactSharedInternals to use the dispatcher. Externalize `react` so
|
|
87
|
+
// the jsx-runtime bundle is just the JSX helpers (~5 KiB) sharing
|
|
88
|
+
// ONE React instance via the browser's module loader.
|
|
89
|
+
if (specifier === 'react/jsx-runtime' || specifier === 'react/jsx-dev-runtime') {
|
|
90
|
+
return ['react'];
|
|
91
|
+
}
|
|
92
|
+
// Other react/* subpaths (e.g., react/server) — externalize react.
|
|
93
|
+
if (specifier.startsWith('react/')) {
|
|
94
|
+
return ['react'];
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// EVERYTHING ELSE — react-dom, framer-motion, lucide-react, zustand,
|
|
98
|
+
// @radix-ui/*, react-router, etc. — must share react's singleton. If any
|
|
99
|
+
// of these embeds its own React copy, elements tagged by that copy get
|
|
100
|
+
// rejected as "alien" by the createRoot from the OTHER React copy
|
|
101
|
+
// (silent render fail / "Objects are not valid as a React child" with
|
|
102
|
+
// $$typeof spelled out). Externalize the entire React runtime.
|
|
103
|
+
//
|
|
104
|
+
// We DO NOT use `react/*` glob here because that has historically tripped
|
|
105
|
+
// esbuild's entry-point check. Instead we list the specific subpath
|
|
106
|
+
// imports React's ecosystem actually emits: jsx-runtime + jsx-dev-runtime.
|
|
107
|
+
// (react-dom subpaths are handled below by 'react-dom/*'.)
|
|
108
|
+
//
|
|
109
|
+
// Filter out patterns that match the spec being bundled — when
|
|
110
|
+
// bundling 'react-dom', drop 'react-dom' / 'react-dom/*' from the list
|
|
111
|
+
// so the entry can be bundled.
|
|
112
|
+
const all = [
|
|
113
|
+
'react',
|
|
114
|
+
'react/jsx-runtime',
|
|
115
|
+
'react/jsx-dev-runtime',
|
|
116
|
+
'react-dom',
|
|
117
|
+
'react-dom/*',
|
|
118
|
+
'scheduler',
|
|
119
|
+
];
|
|
120
|
+
// Determine the package name for the spec being bundled (handles
|
|
121
|
+
// scoped packages and subpaths: 'react-dom/client' → 'react-dom').
|
|
122
|
+
const specPkg = specifier.startsWith('@')
|
|
123
|
+
? specifier.split('/').slice(0, 2).join('/')
|
|
124
|
+
: specifier.split('/')[0];
|
|
125
|
+
|
|
126
|
+
return all.filter((pat) => {
|
|
127
|
+
if (pat === specifier) return false;
|
|
128
|
+
if (pat.endsWith('/*')) {
|
|
129
|
+
const prefix = pat.slice(0, -1); // e.g. 'react-dom/'
|
|
130
|
+
const pkgName = pat.slice(0, -2); // e.g. 'react-dom'
|
|
131
|
+
if (specifier.startsWith(prefix)) return false;
|
|
132
|
+
if (specifier === pkgName) return false;
|
|
133
|
+
if (specPkg === pkgName) return false;
|
|
134
|
+
} else {
|
|
135
|
+
// Plain (non-glob) external. Drop if the spec being bundled is
|
|
136
|
+
// a subpath of this external's package.
|
|
137
|
+
if (specPkg === pat) return false;
|
|
138
|
+
}
|
|
139
|
+
return true;
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Detect top-level await in source. Used by `EsbuildService.transform`
|
|
145
|
+
* to decide whether to async-IIFE-wrap CJS-target sources (see
|
|
146
|
+
* transform()'s header comment).
|
|
147
|
+
*
|
|
148
|
+
* Token scan over a comment-and-string-stripped source. Tracks paren
|
|
149
|
+
* depth AND function-body depth so a `{` inside a parameter list (a
|
|
150
|
+
* default-value object literal — `async function f(opts = {})`) is NOT
|
|
151
|
+
* mistaken for the function body. The earlier heuristic lacked the paren
|
|
152
|
+
* guard: the `= {}` braces consumed the body-tracking slot, leaving the
|
|
153
|
+
* real body untracked so an internal `await` read as top-level. That
|
|
154
|
+
* wrongly routed such files (e.g. @bluwy/giget-core's
|
|
155
|
+
* download-template.js, reached by create-astro) into the two-pass
|
|
156
|
+
* ESM→require rewrite, whose assembled output still carried export/import
|
|
157
|
+
* statements → "Cannot use import statement outside a module" at startup.
|
|
158
|
+
*
|
|
159
|
+
* Arrow bodies are distinguished from arrow expression bodies (the
|
|
160
|
+
* `arrowPending` flag): only a `{` immediately following `=>` opens a
|
|
161
|
+
* function scope. The idiomatic object-returning arrow `x => ({ ... })`
|
|
162
|
+
* has its `{` at parenDepth 1, so it opens no body slot — otherwise the
|
|
163
|
+
* leaked slot would be consumed by a later top-level `{ ... }` block,
|
|
164
|
+
* making a real top-level `await` inside it read as non-TLA (false
|
|
165
|
+
* negative) and routing genuine ESM-with-TLA into the wrong transform.
|
|
166
|
+
*
|
|
167
|
+
* A regex/token scan (not acorn) is kept here deliberately: pulling
|
|
168
|
+
* acorn into the esbuild-service bundle chunk duplicates its ~15 KiB
|
|
169
|
+
* Unicode identifier tables.
|
|
170
|
+
*/
|
|
171
|
+
export function hasTopLevelAwait(src: string): boolean {
|
|
172
|
+
if (!src || src.indexOf('await') === -1) return false;
|
|
173
|
+
const stripped = stripCommentsAndStrings(src);
|
|
174
|
+
// Tokens: keywords, arrow, and each bracket kind. `parenDepth` rises
|
|
175
|
+
// inside `(...)`; a `{` only opens a function body when a `function`/
|
|
176
|
+
// `=>` is pending AND we're at parenDepth 0 (past the param list).
|
|
177
|
+
const re = /\b(await|function|class)\b|=>|\{|\}|\(|\)/g;
|
|
178
|
+
let m: RegExpExecArray | null;
|
|
179
|
+
const fnEntryDepths: number[] = [];
|
|
180
|
+
let depth = 0;
|
|
181
|
+
let parenDepth = 0;
|
|
182
|
+
let pendingFn = 0;
|
|
183
|
+
// An arrow can have either a block body (`=> { ... }`) — which opens a
|
|
184
|
+
// function scope — or an expression body (`=> expr`), which does not.
|
|
185
|
+
// We can only tell which by looking at the token right after `=>`: a
|
|
186
|
+
// block body has `{` as its very next token. `arrowPending` carries
|
|
187
|
+
// that "the next `{` (and only an immediately-following `{`) is this
|
|
188
|
+
// arrow's body" intent, separately from `pendingFn` so the idiomatic
|
|
189
|
+
// `x => ({ ... })` (object-returning expression body, `{` at parenDepth
|
|
190
|
+
// 1) does not leak a body slot onto a later top-level block.
|
|
191
|
+
let arrowPending = false;
|
|
192
|
+
while ((m = re.exec(stripped)) !== null) {
|
|
193
|
+
const tok = m[0];
|
|
194
|
+
if (arrowPending && tok !== '{') arrowPending = false;
|
|
195
|
+
if (tok === '(') { parenDepth++; }
|
|
196
|
+
else if (tok === ')') { if (parenDepth > 0) parenDepth--; }
|
|
197
|
+
else if (tok === '{') {
|
|
198
|
+
depth++;
|
|
199
|
+
if (arrowPending) { fnEntryDepths.push(depth); arrowPending = false; }
|
|
200
|
+
else if (pendingFn > 0 && parenDepth === 0) { fnEntryDepths.push(depth); pendingFn--; }
|
|
201
|
+
} else if (tok === '}') {
|
|
202
|
+
if (fnEntryDepths.length > 0 && fnEntryDepths[fnEntryDepths.length - 1] === depth) fnEntryDepths.pop();
|
|
203
|
+
depth--;
|
|
204
|
+
} else if (tok === 'function' || tok === 'class') {
|
|
205
|
+
pendingFn++;
|
|
206
|
+
} else if (tok === '=>') {
|
|
207
|
+
arrowPending = true;
|
|
208
|
+
} else if (tok === 'await') {
|
|
209
|
+
if (fnEntryDepths.length === 0) return true;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
return false;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Cheap heuristic: does the source contain a top-level ESM `import`
|
|
217
|
+
* statement? Used by `EsbuildService.transform` to detect sources that
|
|
218
|
+
* cannot be IIFE-wrapped as-is.
|
|
219
|
+
*
|
|
220
|
+
* Bug history (nuxt-esm-in-cjs wave):
|
|
221
|
+
* ─────────────────────────────────
|
|
222
|
+
* The TLA fix (framework-gaps-fix P2) wraps CJS-target sources in an
|
|
223
|
+
* async IIFE:
|
|
224
|
+
*
|
|
225
|
+
* ;(async () => { <source> })().catch(...);
|
|
226
|
+
*
|
|
227
|
+
* For sources with TLA-only, that works: `await` becomes legal inside
|
|
228
|
+
* the async function body. But for sources with BOTH TLA AND ESM
|
|
229
|
+
* `import` statements (real-world example: nuxi's `bin/nuxi.mjs`), the
|
|
230
|
+
* wrap moves `import` statements into a function body — and ESM
|
|
231
|
+
* `import` syntax is only legal at module top-level. esbuild rejects
|
|
232
|
+
* the wrapped source with `Unexpected "<binding>"` at line 3 of stdin
|
|
233
|
+
* (the wrap's line 1 is `;(async () =>...`, line 2 is the open brace,
|
|
234
|
+
* line 3 is the first user import).
|
|
235
|
+
*
|
|
236
|
+
* When TLA AND ESM imports coexist we must extract the imports first,
|
|
237
|
+
* rewrite them as `const X = require(...)` shims at top-level (above
|
|
238
|
+
* the IIFE), then wrap the rest. See `convertEsmImportsToRequire` for
|
|
239
|
+
* the rewrite contract and `transform()` for the integration site.
|
|
240
|
+
*
|
|
241
|
+
* Heuristic match: any of `import "..."` / `import x from "..."` /
|
|
242
|
+
* `import { ... } from "..."` / `import * as ns from "..."` / `import
|
|
243
|
+
* x, { ... } from "..."` appearing on a line whose first non-whitespace
|
|
244
|
+
* token is the `import` keyword. Dynamic `import(...)` calls are
|
|
245
|
+
* EXCLUDED — those are expressions, legal anywhere including IIFE
|
|
246
|
+
* bodies, and need no rewrite.
|
|
247
|
+
*
|
|
248
|
+
* Operates on the comment-and-string-stripped source so commented-out
|
|
249
|
+
* imports and "import" appearing inside string literals don't trigger.
|
|
250
|
+
* We reuse the comment/string stripper from `hasTopLevelAwait`'s pass
|
|
251
|
+
* — see `stripCommentsAndStrings` below.
|
|
252
|
+
*/
|
|
253
|
+
function hasEsmImports(src: string): boolean {
|
|
254
|
+
if (!src || src.indexOf('import') === -1) return false;
|
|
255
|
+
const stripped = stripCommentsAndStrings(src);
|
|
256
|
+
// Top-level `import ... from "..."` OR side-effect `import "..."`.
|
|
257
|
+
// Negative lookbehind for `.` (avoids `something.import` member
|
|
258
|
+
// access) is unsupported in some JS engines; we match start-of-line
|
|
259
|
+
// (after whitespace) + the keyword. dynamic import() is matched as
|
|
260
|
+
// `import(` and excluded by negative lookahead.
|
|
261
|
+
const re = /^[ \t]*import\b(?!\s*\()/m;
|
|
262
|
+
return re.test(stripped);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
function hasEsmExports(src: string): boolean {
|
|
266
|
+
if (!src || src.indexOf('export') === -1) return false;
|
|
267
|
+
const stripped = stripCommentsAndStrings(src);
|
|
268
|
+
return /^[ \t]*export\b/m.test(stripped);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Strip `//` and `/* * /` comments and string / template literals from
|
|
273
|
+
* source, replacing each with a single space. The result is byte-aligned
|
|
274
|
+
* with the input on a per-line basis (newlines are preserved), so error
|
|
275
|
+
* line numbers from downstream parsers still align with the original.
|
|
276
|
+
*
|
|
277
|
+
* Shared by `hasTopLevelAwait` (which had this inline) and
|
|
278
|
+
* `hasEsmImports`. Pure function — no caching needed for the small
|
|
279
|
+
* inputs we see (typical .mjs entry-point: <2KiB).
|
|
280
|
+
*/
|
|
281
|
+
function stripCommentsAndStrings(src: string): string {
|
|
282
|
+
let stripped = '';
|
|
283
|
+
let i = 0;
|
|
284
|
+
const N = src.length;
|
|
285
|
+
// Track the last non-whitespace non-comment output character so we
|
|
286
|
+
// can disambiguate `/` as division (after identifier/literal/`)`/`]`)
|
|
287
|
+
// vs regex-literal opener (after operator / punctuator / keyword /
|
|
288
|
+
// start-of-file). Pre-fix the stripper had no regex awareness, so
|
|
289
|
+
// patterns like `var X = /^(?:'…)/` contained an unmatched `'` that
|
|
290
|
+
// bit it as a string opener that didn't close until many lines
|
|
291
|
+
// later — corrupting every downstream classifier (export-scanner,
|
|
292
|
+
// hasEsmImports, hasTopLevelAwait). Real-world bite: sv-utils@0.0.3
|
|
293
|
+
// index.mjs has dozens of these regex literals.
|
|
294
|
+
let lastNonWsChar = '';
|
|
295
|
+
const recordOut = (ch: string) => {
|
|
296
|
+
if (ch !== ' ' && ch !== '\t' && ch !== '\n' && ch !== '\r') {
|
|
297
|
+
lastNonWsChar = ch;
|
|
298
|
+
}
|
|
299
|
+
};
|
|
300
|
+
// Identifier-suffix detection on lastNonWsChar: any of these means
|
|
301
|
+
// `/` is division. Anything else means `/` opens a regex.
|
|
302
|
+
// Includes ascii word chars + `)` `]` to cover `foo()/x` `a[i]/y`.
|
|
303
|
+
const DIVISION_AFTER = /[A-Za-z0-9_$\)\]]/;
|
|
304
|
+
while (i < N) {
|
|
305
|
+
const c = src[i];
|
|
306
|
+
if (c === '/' && src[i + 1] === '/') {
|
|
307
|
+
while (i < N && src[i] !== '\n') i++;
|
|
308
|
+
stripped += ' ';
|
|
309
|
+
continue;
|
|
310
|
+
}
|
|
311
|
+
if (c === '/' && src[i + 1] === '*') {
|
|
312
|
+
i += 2;
|
|
313
|
+
while (i < N && !(src[i] === '*' && src[i + 1] === '/')) {
|
|
314
|
+
// Preserve newlines so line numbers stay aligned.
|
|
315
|
+
if (src[i] === '\n') stripped += '\n';
|
|
316
|
+
i++;
|
|
317
|
+
}
|
|
318
|
+
i += 2;
|
|
319
|
+
stripped += ' ';
|
|
320
|
+
continue;
|
|
321
|
+
}
|
|
322
|
+
// Regex literal: `/` not followed by `/` or `*` (already handled
|
|
323
|
+
// above), AND preceded by something that makes regex valid here.
|
|
324
|
+
// The classifier looks at lastNonWsChar — for `(`, `,`, `=`, `;`,
|
|
325
|
+
// `{`, `[`, `:`, `!`, `&`, `|`, `?`, operators, or start-of-file,
|
|
326
|
+
// a slash is a regex opener.
|
|
327
|
+
if (c === '/' && !DIVISION_AFTER.test(lastNonWsChar)) {
|
|
328
|
+
stripped += ' ';
|
|
329
|
+
i++;
|
|
330
|
+
while (i < N) {
|
|
331
|
+
const rc = src[i];
|
|
332
|
+
if (rc === '\\') { i += 2; continue; }
|
|
333
|
+
// Regex character class [...]: `/` inside it is content.
|
|
334
|
+
if (rc === '[') {
|
|
335
|
+
i++;
|
|
336
|
+
while (i < N && src[i] !== ']') {
|
|
337
|
+
if (src[i] === '\\') { i += 2; continue; }
|
|
338
|
+
if (src[i] === '\n') { stripped += '\n'; }
|
|
339
|
+
i++;
|
|
340
|
+
}
|
|
341
|
+
if (i < N) i++; // consume ']'
|
|
342
|
+
continue;
|
|
343
|
+
}
|
|
344
|
+
if (rc === '/') { i++; break; }
|
|
345
|
+
if (rc === '\n') {
|
|
346
|
+
// Regex literals can't span newlines. If we hit one without
|
|
347
|
+
// finding the closing `/`, this was probably NOT a regex —
|
|
348
|
+
// bail out gracefully (rare in practice; better than getting
|
|
349
|
+
// stuck in a wrong state).
|
|
350
|
+
break;
|
|
351
|
+
}
|
|
352
|
+
i++;
|
|
353
|
+
}
|
|
354
|
+
// Skip regex flags (g, i, m, s, u, y, d).
|
|
355
|
+
while (i < N && /[gimsuyd]/.test(src[i])) i++;
|
|
356
|
+
recordOut('/');
|
|
357
|
+
continue;
|
|
358
|
+
}
|
|
359
|
+
if (c === '"' || c === "'" || c === '`') {
|
|
360
|
+
const q = c;
|
|
361
|
+
stripped += ' ';
|
|
362
|
+
i++;
|
|
363
|
+
while (i < N) {
|
|
364
|
+
const cc = src[i];
|
|
365
|
+
if (cc === '\\') { i += 2; continue; }
|
|
366
|
+
if (cc === q) { i++; break; }
|
|
367
|
+
// Template interpolation: ${...} — preserve the inner
|
|
368
|
+
// expression as raw code so the caller's depth-tracker can
|
|
369
|
+
// see `await` etc. inside it. Strip the wrapping `${`/`}`
|
|
370
|
+
// (those don't affect brace-depth from the caller's POV).
|
|
371
|
+
//
|
|
372
|
+
// CRITICAL: inside the interpolation expression, we must
|
|
373
|
+
// recognise NESTED strings (`'}'`, `"}"`, `` `${...}` ``) so
|
|
374
|
+
// their internal `}` characters don't decrement the depth
|
|
375
|
+
// counter — otherwise we exit the interpolation early and
|
|
376
|
+
// start consuming code as string content, eventually parsing
|
|
377
|
+
// the rest of the file as one massive unclosed string. This
|
|
378
|
+
// bit sv-utils/dist/index.mjs: multi-line backticks with
|
|
379
|
+
// `${url.replace('}', '_')}`-style interpolations corrupted
|
|
380
|
+
// line classification downstream. Recursive-by-loop here.
|
|
381
|
+
if (q === '`' && cc === '$' && src[i + 1] === '{') {
|
|
382
|
+
stripped += '${';
|
|
383
|
+
i += 2;
|
|
384
|
+
let depth = 1;
|
|
385
|
+
while (i < N && depth > 0) {
|
|
386
|
+
const ic = src[i];
|
|
387
|
+
// Nested string inside interpolation: skip its content.
|
|
388
|
+
if (ic === '"' || ic === "'" || ic === '`') {
|
|
389
|
+
const iq = ic;
|
|
390
|
+
stripped += ' ';
|
|
391
|
+
i++;
|
|
392
|
+
while (i < N) {
|
|
393
|
+
const icc = src[i];
|
|
394
|
+
if (icc === '\\') { i += 2; continue; }
|
|
395
|
+
if (icc === iq) { i++; break; }
|
|
396
|
+
// Nested template inside interpolation can also have its
|
|
397
|
+
// own ${...} — recurse once more (the practical depth
|
|
398
|
+
// observed in real code never exceeds 2; deeper nesting
|
|
399
|
+
// falls back to brace counting which is a best-effort).
|
|
400
|
+
if (iq === '`' && icc === '$' && src[i + 1] === '{') {
|
|
401
|
+
stripped += '${'; i += 2;
|
|
402
|
+
let d2 = 1;
|
|
403
|
+
while (i < N && d2 > 0) {
|
|
404
|
+
const i2 = src[i];
|
|
405
|
+
if (i2 === '{') d2++;
|
|
406
|
+
else if (i2 === '}') d2--;
|
|
407
|
+
if (d2 > 0) stripped += i2;
|
|
408
|
+
i++;
|
|
409
|
+
}
|
|
410
|
+
stripped += '}';
|
|
411
|
+
continue;
|
|
412
|
+
}
|
|
413
|
+
if (icc === '\n') stripped += '\n';
|
|
414
|
+
i++;
|
|
415
|
+
}
|
|
416
|
+
continue;
|
|
417
|
+
}
|
|
418
|
+
if (ic === '{') depth++;
|
|
419
|
+
else if (ic === '}') depth--;
|
|
420
|
+
if (depth > 0) stripped += ic;
|
|
421
|
+
i++;
|
|
422
|
+
}
|
|
423
|
+
stripped += '}';
|
|
424
|
+
continue;
|
|
425
|
+
}
|
|
426
|
+
if (cc === '\n') stripped += '\n';
|
|
427
|
+
i++;
|
|
428
|
+
}
|
|
429
|
+
continue;
|
|
430
|
+
}
|
|
431
|
+
stripped += c;
|
|
432
|
+
recordOut(c);
|
|
433
|
+
i++;
|
|
434
|
+
}
|
|
435
|
+
return stripped;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
/**
|
|
439
|
+
* Convert ESM `import` statements at the top of `src` to CJS
|
|
440
|
+
* `require()` declarations, returning `{ requires, body }` where
|
|
441
|
+
* `requires` is the require-shim block (a single string of newline-
|
|
442
|
+
* separated declarations) and `body` is the source with the imports
|
|
443
|
+
* removed.
|
|
444
|
+
*
|
|
445
|
+
* Operates on the OUTPUT of an esbuild `format: 'esm'` pre-pass, NOT
|
|
446
|
+
* on raw user source. esbuild normalises imports onto single lines and
|
|
447
|
+
* canonicalises the binding shape, which means a small regex over the
|
|
448
|
+
* normalised output is reliable. Specifically:
|
|
449
|
+
* - Multi-line imports are collapsed to one line per import
|
|
450
|
+
* - `import x from 'm';` always has the semicolon
|
|
451
|
+
* - String quotes are normalised to double-quotes
|
|
452
|
+
* - Whitespace is canonical
|
|
453
|
+
*
|
|
454
|
+
* Supported import shapes (after esbuild normalisation):
|
|
455
|
+
* 1. `import "m";` side-effect
|
|
456
|
+
* 2. `import x from "m";` default
|
|
457
|
+
* 3. `import * as ns from "m";` namespace
|
|
458
|
+
* 4. `import { a, b as c } from "m";` named (with optional rename)
|
|
459
|
+
* 5. `import x, { a } from "m";` default + named
|
|
460
|
+
* 6. `import x, * as ns from "m";` default + namespace
|
|
461
|
+
*
|
|
462
|
+
* Rewrites:
|
|
463
|
+
* 1. `require("m");`
|
|
464
|
+
* 2. `const x = (() => { const _m = require("m"); return _m && _m.__esModule ? _m.default : _m; })();`
|
|
465
|
+
* 3. `const ns = require("m");`
|
|
466
|
+
* 4. `const { a, b: c } = require("m");`
|
|
467
|
+
* 5. `const _m_<n> = require("m"); const x = _m_<n>.__esModule ? _m_<n>.default : _m_<n>; const { a } = _m_<n>;`
|
|
468
|
+
* 6. `const ns = require("m"); const x = ns.__esModule ? ns.default : ns;`
|
|
469
|
+
*
|
|
470
|
+
* Default-binding compat: ESM `import x from "m"` binds the module's
|
|
471
|
+
* default export, OR the whole module if there is no default. Real
|
|
472
|
+
* Node + esbuild's __esModule interop check handle this with the
|
|
473
|
+
* `__esModule ? .default : whole` pattern reproduced above. Same as
|
|
474
|
+
* what esbuild emits inline when targeting CJS for a no-TLA source
|
|
475
|
+
* (verified empirically against `esbuild-wasm 0.24.2`).
|
|
476
|
+
*
|
|
477
|
+
* Unknown shapes are left in `body` unchanged — esbuild will reject
|
|
478
|
+
* them on the second pass and the caller surfaces a clear error.
|
|
479
|
+
* That's the safe failure mode.
|
|
480
|
+
*/
|
|
481
|
+
function convertEsmImportsToRequire(src: string): { requires: string; body: string } {
|
|
482
|
+
const lines = src.split('\n');
|
|
483
|
+
// Strip comments + string/template literals so the line scanner only
|
|
484
|
+
// sees real syntax. Without this, import-shaped lines INSIDE template
|
|
485
|
+
// literals (real-world: sv@0.15.3's engine.mjs scaffolds SvelteKit
|
|
486
|
+
// project files via templates containing `import { redirect } from
|
|
487
|
+
// '@sveltejs/kit';`) get parsed as actual imports — emitted twice into
|
|
488
|
+
// the requires block → duplicate const declaration → SyntaxError at
|
|
489
|
+
// facet pre-compile ("Identifier 'redirect' has already been declared").
|
|
490
|
+
//
|
|
491
|
+
// stripCommentsAndStrings preserves newlines, so line indices align
|
|
492
|
+
// between `src` and `strippedLines`. We use the stripped line to
|
|
493
|
+
// CLASSIFY (is this an import line?) and the original line to
|
|
494
|
+
// EXTRACT the actual import shape (specifier, bindings).
|
|
495
|
+
//
|
|
496
|
+
const strippedLines = stripCommentsAndStrings(src).split('\n');
|
|
497
|
+
const requires: string[] = [];
|
|
498
|
+
const bodyLines: string[] = [];
|
|
499
|
+
let counter = 0;
|
|
500
|
+
for (let li = 0; li < lines.length; li++) {
|
|
501
|
+
const line = lines[li];
|
|
502
|
+
const cls = strippedLines[li] ?? '';
|
|
503
|
+
// Classification check: is this line a real top-level import?
|
|
504
|
+
// The stripped version masks string content, so import-shaped
|
|
505
|
+
// template-literal lines are now whitespace.
|
|
506
|
+
if (!/^[ \t]*import\b/.test(cls)) {
|
|
507
|
+
bodyLines.push(line);
|
|
508
|
+
continue;
|
|
509
|
+
}
|
|
510
|
+
// Side-effect import: `import "m";` / `import 'm';`
|
|
511
|
+
let m = line.match(/^[ \t]*import\s+["']([^"']+)["']\s*;?\s*$/);
|
|
512
|
+
if (m) { requires.push(`require(${JSON.stringify(m[1])});`); continue; }
|
|
513
|
+
// Identifier class: JS spec allows `$` and `_` in addition to `\w`
|
|
514
|
+
// (letters/digits/underscore). esbuild's ESM-pass-1 emits `process$1`
|
|
515
|
+
// when colliding with a global (e.g. `import process from 'node:process'`
|
|
516
|
+
// becomes `process$1`). Pre-fix `\w+` truncated at `$`, all the regexes
|
|
517
|
+
// below missed → line fell through to bodyLines → top-level `import`
|
|
518
|
+
// statement survived into the async-IIFE wrap → SyntaxError
|
|
519
|
+
// "import statement outside module" at facet pre-compile.
|
|
520
|
+
// Default + namespace: `import x, * as ns from "m";`
|
|
521
|
+
m = line.match(/^[ \t]*import\s+([\w$]+)\s*,\s*\*\s+as\s+([\w$]+)\s+from\s+["']([^"']+)["']\s*;?\s*$/);
|
|
522
|
+
if (m) {
|
|
523
|
+
const def = m[1], ns = m[2], mod = m[3];
|
|
524
|
+
requires.push(`const ${ns} = require(${JSON.stringify(mod)}); const ${def} = ${ns}.__esModule ? ${ns}.default : ${ns};`);
|
|
525
|
+
continue;
|
|
526
|
+
}
|
|
527
|
+
// Default + named: `import x, { a, b as c } from "m";`
|
|
528
|
+
m = line.match(/^[ \t]*import\s+([\w$]+)\s*,\s*\{([^}]+)\}\s+from\s+["']([^"']+)["']\s*;?\s*$/);
|
|
529
|
+
if (m) {
|
|
530
|
+
const def = m[1], bindings = m[2], mod = m[3];
|
|
531
|
+
const tmp = `_nimbus_m_${counter++}`;
|
|
532
|
+
const named = bindings.split(',').map((b) => {
|
|
533
|
+
const am = b.trim().match(/^([\w$]+)(?:\s+as\s+([\w$]+))?$/);
|
|
534
|
+
if (!am) return b.trim();
|
|
535
|
+
return am[2] ? `${am[1]}: ${am[2]}` : am[1];
|
|
536
|
+
}).join(', ');
|
|
537
|
+
requires.push(`const ${tmp} = require(${JSON.stringify(mod)}); const ${def} = ${tmp}.__esModule ? ${tmp}.default : ${tmp}; const { ${named} } = ${tmp};`);
|
|
538
|
+
continue;
|
|
539
|
+
}
|
|
540
|
+
// Namespace: `import * as ns from "m";`
|
|
541
|
+
m = line.match(/^[ \t]*import\s+\*\s+as\s+([\w$]+)\s+from\s+["']([^"']+)["']\s*;?\s*$/);
|
|
542
|
+
if (m) { requires.push(`const ${m[1]} = require(${JSON.stringify(m[2])});`); continue; }
|
|
543
|
+
// Named only: `import { a, b as c } from "m";`
|
|
544
|
+
m = line.match(/^[ \t]*import\s+\{([^}]+)\}\s+from\s+["']([^"']+)["']\s*;?\s*$/);
|
|
545
|
+
if (m) {
|
|
546
|
+
const bindings = m[1], mod = m[2];
|
|
547
|
+
const named = bindings.split(',').map((b) => {
|
|
548
|
+
const am = b.trim().match(/^([\w$]+)(?:\s+as\s+([\w$]+))?$/);
|
|
549
|
+
if (!am) return b.trim();
|
|
550
|
+
return am[2] ? `${am[1]}: ${am[2]}` : am[1];
|
|
551
|
+
}).join(', ');
|
|
552
|
+
requires.push(`const { ${named} } = require(${JSON.stringify(mod)});`);
|
|
553
|
+
continue;
|
|
554
|
+
}
|
|
555
|
+
// Default only: `import x from "m";`
|
|
556
|
+
m = line.match(/^[ \t]*import\s+([\w$]+)\s+from\s+["']([^"']+)["']\s*;?\s*$/);
|
|
557
|
+
if (m) {
|
|
558
|
+
const def = m[1], mod = m[2];
|
|
559
|
+
requires.push(`const ${def} = (() => { const _m = require(${JSON.stringify(mod)}); return _m && _m.__esModule ? _m.default : _m; })();`);
|
|
560
|
+
continue;
|
|
561
|
+
}
|
|
562
|
+
// Stripped-line claimed this was an import, but none of the shape
|
|
563
|
+
// regexes matched. Unknown import form (e.g. multi-line import that
|
|
564
|
+
// esbuild's pass-1 normalization didn't collapse, or a future-syntax
|
|
565
|
+
// variant). Keep in body — esbuild's pass-2 will reject it with a
|
|
566
|
+
// clear error if it's actually invalid, or accept it if it's a form
|
|
567
|
+
// we don't yet recognise.
|
|
568
|
+
bodyLines.push(line);
|
|
569
|
+
}
|
|
570
|
+
// ── Pass 2: scan bodyLines for top-level `export` statements. ──────
|
|
571
|
+
//
|
|
572
|
+
// After import-stripping, the body still has every `export` statement
|
|
573
|
+
// verbatim. The async-IIFE wrap (the caller wraps body in
|
|
574
|
+
// `;(async () => { ... })();`) makes those exports illegal grammar
|
|
575
|
+
// ('export' is module-only, not legal in function bodies) →
|
|
576
|
+
// SyntaxError "Unexpected token 'export'" at facet pre-compile.
|
|
577
|
+
//
|
|
578
|
+
// Rewrite each top-level export to a CJS-compatible equivalent (see
|
|
579
|
+
// Same defences as imports:
|
|
580
|
+
// - String-content masking (template-literal exports don't trigger)
|
|
581
|
+
// - $-aware identifier regex ([\w$]+, esbuild emits foo$1 ids)
|
|
582
|
+
//
|
|
583
|
+
// Multi-line `export { ... }` lists are coalesced before shape match.
|
|
584
|
+
const bodySrc = bodyLines.join('\n');
|
|
585
|
+
const bodyLines2 = bodySrc.split('\n');
|
|
586
|
+
const strippedBody = stripCommentsAndStrings(bodySrc).split('\n');
|
|
587
|
+
const out: string[] = [];
|
|
588
|
+
let i = 0;
|
|
589
|
+
let exportCounter = 0;
|
|
590
|
+
while (i < bodyLines2.length) {
|
|
591
|
+
const line = bodyLines2[i];
|
|
592
|
+
const cls = strippedBody[i] ?? '';
|
|
593
|
+
if (!/^[ \t]*export\b/.test(cls)) {
|
|
594
|
+
out.push(line);
|
|
595
|
+
i++;
|
|
596
|
+
continue;
|
|
597
|
+
}
|
|
598
|
+
// Multi-line collector: if the stripped line opens a `{` for an
|
|
599
|
+
// `export { ... }` list and doesn't close it on the same line,
|
|
600
|
+
// accumulate subsequent lines until the matching `}` (tracked on
|
|
601
|
+
// the stripped lines so string `}`s don't trip us).
|
|
602
|
+
let coalesced = line;
|
|
603
|
+
let coalescedCls = cls;
|
|
604
|
+
if (/^[ \t]*export\s*\{/.test(cls) && !/\}/.test(cls)) {
|
|
605
|
+
let j = i + 1;
|
|
606
|
+
while (j < bodyLines2.length) {
|
|
607
|
+
coalesced += ' ' + bodyLines2[j];
|
|
608
|
+
coalescedCls += ' ' + (strippedBody[j] ?? '');
|
|
609
|
+
if (/\}/.test(strippedBody[j] ?? '')) { j++; break; }
|
|
610
|
+
j++;
|
|
611
|
+
}
|
|
612
|
+
i = j;
|
|
613
|
+
} else {
|
|
614
|
+
i++;
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
// Helper: emit a `__esModule = true` marker exactly once.
|
|
618
|
+
// (Mirrors esbuild's own emit; consumers using the __esModule check
|
|
619
|
+
// in convertEsmImportsToRequire's default-import shim then pick
|
|
620
|
+
// .default correctly.)
|
|
621
|
+
const ensureEsmMarker = (() => {
|
|
622
|
+
let emitted = false;
|
|
623
|
+
return () => {
|
|
624
|
+
if (emitted) return '';
|
|
625
|
+
emitted = true;
|
|
626
|
+
return 'module.exports.__esModule = true; ';
|
|
627
|
+
};
|
|
628
|
+
})();
|
|
629
|
+
|
|
630
|
+
// Shape regexes operate on the COALESCED ORIGINAL line. We use the
|
|
631
|
+
// stripped version only for classification (already done above).
|
|
632
|
+
let m: RegExpMatchArray | null;
|
|
633
|
+
|
|
634
|
+
// export default function/class — declaration form
|
|
635
|
+
// `export default function foo(args){...}` (named declaration)
|
|
636
|
+
m = coalesced.match(/^([ \t]*)export\s+default\s+(async\s+)?function\s*([\w$]+)\s*([\s\S]*)$/);
|
|
637
|
+
if (m) {
|
|
638
|
+
const indent = m[1], asyncKw = m[2] || '', name = m[3], rest = m[4];
|
|
639
|
+
out.push(`${indent}${asyncKw}function ${name} ${rest}`);
|
|
640
|
+
out.push(`${ensureEsmMarker()}module.exports.default = ${name};`);
|
|
641
|
+
continue;
|
|
642
|
+
}
|
|
643
|
+
// export default class K {...}
|
|
644
|
+
m = coalesced.match(/^([ \t]*)export\s+default\s+class\s+([\w$]+)\s*([\s\S]*)$/);
|
|
645
|
+
if (m) {
|
|
646
|
+
const indent = m[1], name = m[2], rest = m[3];
|
|
647
|
+
out.push(`${indent}class ${name} ${rest}`);
|
|
648
|
+
out.push(`${ensureEsmMarker()}module.exports.default = ${name};`);
|
|
649
|
+
continue;
|
|
650
|
+
}
|
|
651
|
+
// export default <anonymous-function | anonymous-class | expression>
|
|
652
|
+
// Match any remaining `export default …` shape and emit as assignment.
|
|
653
|
+
m = coalesced.match(/^([ \t]*)export\s+default\s+([\s\S]*)$/);
|
|
654
|
+
if (m) {
|
|
655
|
+
const indent = m[1];
|
|
656
|
+
let rest = m[2];
|
|
657
|
+
// Strip trailing semicolon (we add our own).
|
|
658
|
+
rest = rest.replace(/;\s*$/, '');
|
|
659
|
+
out.push(`${indent}${ensureEsmMarker()}module.exports.default = (${rest});`);
|
|
660
|
+
continue;
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
// export named-declaration: const/let/var
|
|
664
|
+
m = coalesced.match(/^([ \t]*)export\s+(const|let|var)\s+([\w$]+)\s*=\s*([\s\S]*)$/);
|
|
665
|
+
if (m) {
|
|
666
|
+
const indent = m[1], kw = m[2], name = m[3];
|
|
667
|
+
let rest = m[4];
|
|
668
|
+
rest = rest.replace(/;\s*$/, '');
|
|
669
|
+
out.push(`${indent}${kw} ${name} = ${rest};`);
|
|
670
|
+
out.push(`${ensureEsmMarker()}module.exports.${name} = ${name};`);
|
|
671
|
+
continue;
|
|
672
|
+
}
|
|
673
|
+
// export function NAME(...) {...}
|
|
674
|
+
m = coalesced.match(/^([ \t]*)export\s+(async\s+)?function\s*\*?\s*([\w$]+)\s*([\s\S]*)$/);
|
|
675
|
+
if (m) {
|
|
676
|
+
const indent = m[1], asyncKw = m[2] || '', name = m[3], rest = m[4];
|
|
677
|
+
// Preserve generator-star if present (function\s*\*).
|
|
678
|
+
const generatorStar = /^export\s+(?:async\s+)?function\s*\*/.test(coalesced.replace(/^[ \t]+/, '')) ? '*' : '';
|
|
679
|
+
out.push(`${indent}${asyncKw}function${generatorStar} ${name} ${rest}`);
|
|
680
|
+
out.push(`${ensureEsmMarker()}module.exports.${name} = ${name};`);
|
|
681
|
+
continue;
|
|
682
|
+
}
|
|
683
|
+
// export class NAME { ... } / export class NAME extends X { ... }
|
|
684
|
+
m = coalesced.match(/^([ \t]*)export\s+class\s+([\w$]+)\s*([\s\S]*)$/);
|
|
685
|
+
if (m) {
|
|
686
|
+
const indent = m[1], name = m[2], rest = m[3];
|
|
687
|
+
out.push(`${indent}class ${name} ${rest}`);
|
|
688
|
+
out.push(`${ensureEsmMarker()}module.exports.${name} = ${name};`);
|
|
689
|
+
continue;
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
// export { x, y as z } from 'm' / export * from 'm' / export * as ns from 'm'
|
|
693
|
+
m = coalesced.match(/^([ \t]*)export\s*\*\s+as\s+([\w$]+)\s+from\s+["']([^"']+)["']\s*;?\s*$/);
|
|
694
|
+
if (m) {
|
|
695
|
+
const indent = m[1], ns = m[2], mod = m[3];
|
|
696
|
+
out.push(`${indent}${ensureEsmMarker()}module.exports.${ns} = require(${JSON.stringify(mod)});`);
|
|
697
|
+
continue;
|
|
698
|
+
}
|
|
699
|
+
m = coalesced.match(/^([ \t]*)export\s*\*\s+from\s+["']([^"']+)["']\s*;?\s*$/);
|
|
700
|
+
if (m) {
|
|
701
|
+
const indent = m[1], mod = m[2];
|
|
702
|
+
const tmp = `_nimbus_re_${exportCounter++}`;
|
|
703
|
+
out.push(`${indent}${ensureEsmMarker()}{ const ${tmp} = require(${JSON.stringify(mod)}); for (const _k in ${tmp}) { if (_k !== "default" && _k !== "__esModule") module.exports[_k] = ${tmp}[_k]; } }`);
|
|
704
|
+
continue;
|
|
705
|
+
}
|
|
706
|
+
m = coalesced.match(/^([ \t]*)export\s*\{([^}]*)\}\s+from\s+["']([^"']+)["']\s*;?\s*$/);
|
|
707
|
+
if (m) {
|
|
708
|
+
const indent = m[1], bindings = m[2], mod = m[3];
|
|
709
|
+
const tmp = `_nimbus_re_${exportCounter++}`;
|
|
710
|
+
const parts = bindings.split(',').map((b) => b.trim()).filter(Boolean);
|
|
711
|
+
const assigns: string[] = [];
|
|
712
|
+
for (const p of parts) {
|
|
713
|
+
const am = p.match(/^([\w$]+)(?:\s+as\s+([\w$]+))?$/);
|
|
714
|
+
if (!am) continue;
|
|
715
|
+
const src = am[1], dst = am[2] || am[1];
|
|
716
|
+
assigns.push(`module.exports.${dst} = ${tmp}.${src};`);
|
|
717
|
+
}
|
|
718
|
+
out.push(`${indent}${ensureEsmMarker()}{ const ${tmp} = require(${JSON.stringify(mod)}); ${assigns.join(' ')} }`);
|
|
719
|
+
continue;
|
|
720
|
+
}
|
|
721
|
+
// export { x, y as z } (binding-only list — no `from`)
|
|
722
|
+
m = coalesced.match(/^([ \t]*)export\s*\{([^}]*)\}\s*;?\s*$/);
|
|
723
|
+
if (m) {
|
|
724
|
+
const indent = m[1], bindings = m[2];
|
|
725
|
+
const parts = bindings.split(',').map((b) => b.trim()).filter(Boolean);
|
|
726
|
+
const assigns: string[] = [];
|
|
727
|
+
for (const p of parts) {
|
|
728
|
+
const am = p.match(/^([\w$]+)(?:\s+as\s+([\w$]+))?$/);
|
|
729
|
+
if (!am) continue;
|
|
730
|
+
const src = am[1], dst = am[2] || am[1];
|
|
731
|
+
assigns.push(`module.exports.${dst} = ${src};`);
|
|
732
|
+
}
|
|
733
|
+
out.push(`${indent}${ensureEsmMarker()}${assigns.join(' ')}`);
|
|
734
|
+
continue;
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
// Unknown export shape — leave in body (esbuild will surface a clear
|
|
738
|
+
// error at the next pass, or this is a future-syntax variant we
|
|
739
|
+
// don't yet recognise).
|
|
740
|
+
out.push(coalesced);
|
|
741
|
+
}
|
|
742
|
+
return { requires: requires.join('\n'), body: out.join('\n') };
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
// ── esbuild-wasm imports ────────────────────────────────────────────────
|
|
746
|
+
//
|
|
747
|
+
// We must NOT eagerly import('esbuild-wasm') at module evaluation.
|
|
748
|
+
// esbuild-wasm's CJS `lib/main.js` runs `createRequire(import.meta.url)('fs')`
|
|
749
|
+
// at module-init, which workerd rejects with:
|
|
750
|
+
// "Dynamic require of \"fs\" is not supported"
|
|
751
|
+
// on dynamic-worker instances (nodejs_compat only satisfies static
|
|
752
|
+
// `import 'node:fs'`, NOT runtime __require2-style CJS requires).
|
|
753
|
+
//
|
|
754
|
+
// Types are imported type-only so TypeScript sees `esbuild.Plugin` /
|
|
755
|
+
// `esbuild.Loader` without emitting a runtime require. The actual
|
|
756
|
+
// namespace is loaded lazily by `loadEsbuild()` below, triggered on
|
|
757
|
+
// the first transform/build/initialize call. If no caller ever runs
|
|
758
|
+
// esbuild (e.g. an inner Nimbus that only serves its shell), the
|
|
759
|
+
// module never loads and `__require2('fs')` is never hit.
|
|
760
|
+
//
|
|
761
|
+
// The .wasm import is a compile-time asset binding (wrangler resolves
|
|
762
|
+
// it to a WebAssembly.Module) — it does NOT execute esbuild-wasm's
|
|
763
|
+
// main.js, so it's safe to keep at the top level.
|
|
764
|
+
import type * as esbuild from 'esbuild-wasm';
|
|
765
|
+
import esbuildWasmUrl from 'esbuild-wasm/esbuild.wasm';
|
|
766
|
+
|
|
767
|
+
/**
|
|
768
|
+
* Cached reference to the esbuild namespace. Populated on first
|
|
769
|
+
* `loadEsbuild()` call; nullable until then so module-load code paths
|
|
770
|
+
* that never touch bundling can complete without ever evaluating
|
|
771
|
+
* `esbuild-wasm/lib/main.js`.
|
|
772
|
+
*/
|
|
773
|
+
let _esbuildMod: typeof esbuild | null = null;
|
|
774
|
+
let _esbuildLoadPromise: Promise<typeof esbuild> | null = null;
|
|
775
|
+
|
|
776
|
+
/**
|
|
777
|
+
* Lazily load the esbuild-wasm namespace. Safe to call many times;
|
|
778
|
+
* concurrent callers share a single in-flight Promise. Throws if the
|
|
779
|
+
* CJS main module itself can't run (i.e. the runtime doesn't support
|
|
780
|
+
* the require('fs') pattern esbuild-wasm uses) — callers should catch
|
|
781
|
+
* and surface a helpful error rather than crash the Worker.
|
|
782
|
+
*/
|
|
783
|
+
async function loadEsbuild(): Promise<typeof esbuild> {
|
|
784
|
+
if (_esbuildMod) return _esbuildMod;
|
|
785
|
+
if (_esbuildLoadPromise) return _esbuildLoadPromise;
|
|
786
|
+
_esbuildLoadPromise = (async () => {
|
|
787
|
+
const mod = await import('esbuild-wasm');
|
|
788
|
+
_esbuildMod = mod as unknown as typeof esbuild;
|
|
789
|
+
return _esbuildMod;
|
|
790
|
+
})();
|
|
791
|
+
try {
|
|
792
|
+
return await _esbuildLoadPromise;
|
|
793
|
+
} catch (e) {
|
|
794
|
+
// Reset so a future call can retry (e.g., after the caller has done
|
|
795
|
+
// environment setup we didn't anticipate).
|
|
796
|
+
_esbuildLoadPromise = null;
|
|
797
|
+
throw e;
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
// ── Types ───────────────────────────────────────────────────────────────
|
|
802
|
+
|
|
803
|
+
export interface TransformResult {
|
|
804
|
+
code: string;
|
|
805
|
+
map: string;
|
|
806
|
+
warnings: { text: string; location?: any }[];
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
export interface BuildOutputFile {
|
|
810
|
+
path: string;
|
|
811
|
+
contents: string;
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
export interface BuildResult {
|
|
815
|
+
outputFiles: BuildOutputFile[];
|
|
816
|
+
errors: { text: string; location?: any }[];
|
|
817
|
+
warnings: { text: string; location?: any }[];
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
// ── EsbuildService ──────────────────────────────────────────────────────
|
|
821
|
+
|
|
822
|
+
export class EsbuildService {
|
|
823
|
+
private vfs: CredentialedVfs;
|
|
824
|
+
private initialized = false;
|
|
825
|
+
private initPromise: Promise<void> | null = null;
|
|
826
|
+
/** Resolved esbuild namespace — populated by ensureInit() after loadEsbuild(). */
|
|
827
|
+
private _esbuild: typeof esbuild | null = null;
|
|
828
|
+
|
|
829
|
+
constructor(vfs: SqliteVFS) {
|
|
830
|
+
this.vfs = vfs.as(CRED_KERNEL);
|
|
831
|
+
}
|
|
832
|
+
|
|
833
|
+
/**
|
|
834
|
+
* Initialize esbuild-wasm (lazy, on first use). Loads the namespace
|
|
835
|
+
* via `loadEsbuild()` (which itself is deferred) and caches it on
|
|
836
|
+
* `this._esbuild` so subsequent calls don't pay the dynamic-import
|
|
837
|
+
* overhead. All call sites that previously used the top-level
|
|
838
|
+
* `esbuild` namespace now use `this._esbuild!` after `await this.ensureInit()`.
|
|
839
|
+
*/
|
|
840
|
+
private async ensureInit(): Promise<void> {
|
|
841
|
+
if (this.initialized && this._esbuild) return;
|
|
842
|
+
if (this.initPromise) return this.initPromise;
|
|
843
|
+
|
|
844
|
+
this.initPromise = (async () => {
|
|
845
|
+
try {
|
|
846
|
+
const esb = await loadEsbuild();
|
|
847
|
+
this._esbuild = esb;
|
|
848
|
+
// The supervisor loads esbuild-wasm via wrangler's static-import
|
|
849
|
+
// resolution (`import esbuildWasmUrl from 'esbuild-wasm/esbuild.wasm'`
|
|
850
|
+
// at the top of this file). At deploy time wrangler bundles the
|
|
851
|
+
// .wasm bytes INTO the worker and resolves the import to a
|
|
852
|
+
// WebAssembly.Module value. If the import didn't resolve to a
|
|
853
|
+
// module — for example, a future bundler regression — we used
|
|
854
|
+
// to silently fall back to fetching from cdn.jsdelivr.net. That
|
|
855
|
+
// fallback violated the 100% edge contract: the supervisor
|
|
856
|
+
// would issue a third-party CDN request mid-request to bring
|
|
857
|
+
// up its bundler. Removed.
|
|
858
|
+
//
|
|
859
|
+
// If the bundled import is missing, fail loud with a clear
|
|
860
|
+
// remediation (rebuild the worker with the wasm asset). The
|
|
861
|
+
// supervisor's pre-bundle path also embeds esbuild-wasm via
|
|
862
|
+
// src/esbuild-wasm-bundle.generated.ts, so a complete loss of
|
|
863
|
+
// wasm support would surface there too.
|
|
864
|
+
if (!esbuildWasmUrl || typeof esbuildWasmUrl !== 'object') {
|
|
865
|
+
throw new Error(
|
|
866
|
+
'esbuild-wasm bundled import is not a WebAssembly.Module. ' +
|
|
867
|
+
'Rebuild the worker so wrangler resolves ' +
|
|
868
|
+
'`esbuild-wasm/esbuild.wasm` at bundle time. ' +
|
|
869
|
+
'NO CDN fallback (100% edge contract).',
|
|
870
|
+
);
|
|
871
|
+
}
|
|
872
|
+
// [WRANGLER-DEV-HANG P0b] Time-bound esb.initialize. Workerd
|
|
873
|
+
// has historically had cases where wasm init blocks indefinitely;
|
|
874
|
+
// 30 s is well above the typical ~200 ms init time.
|
|
875
|
+
const INIT_TIMEOUT_MS = 30_000;
|
|
876
|
+
let initTimeout: ReturnType<typeof setTimeout> | null = null;
|
|
877
|
+
await Promise.race([
|
|
878
|
+
esb.initialize({
|
|
879
|
+
wasmModule: esbuildWasmUrl as any,
|
|
880
|
+
worker: false,
|
|
881
|
+
}),
|
|
882
|
+
new Promise<never>((_, reject) => {
|
|
883
|
+
initTimeout = setTimeout(() => {
|
|
884
|
+
reject(new Error(
|
|
885
|
+
`esbuild init exceeded ${INIT_TIMEOUT_MS / 1000}s. ` +
|
|
886
|
+
`wasmModule type=${typeof esbuildWasmUrl}; ` +
|
|
887
|
+
`Likely cause: WebAssembly compile/init stall in workerd.`
|
|
888
|
+
));
|
|
889
|
+
}, INIT_TIMEOUT_MS);
|
|
890
|
+
}),
|
|
891
|
+
]).finally(() => { if (initTimeout) clearTimeout(initTimeout); });
|
|
892
|
+
this.initialized = true;
|
|
893
|
+
} catch (e: any) {
|
|
894
|
+
// "Cannot call initialize more than once" means it's already ready
|
|
895
|
+
if (e?.message?.includes('more than once')) {
|
|
896
|
+
this.initialized = true;
|
|
897
|
+
return;
|
|
898
|
+
}
|
|
899
|
+
this.initPromise = null;
|
|
900
|
+
throw new Error('esbuild init failed: ' + (e?.message || e));
|
|
901
|
+
}
|
|
902
|
+
})();
|
|
903
|
+
|
|
904
|
+
return this.initPromise;
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
/**
|
|
908
|
+
* Transform a single code string (TS→JS, JSX→JS, minify, etc.)
|
|
909
|
+
*
|
|
910
|
+
* Top-level await note (gap #2 in framework-gaps-fix):
|
|
911
|
+
* ─────────────────────────────────────────────────────
|
|
912
|
+
* esbuild rejects top-level await when output format is 'cjs' or
|
|
913
|
+
* 'iife' — neither has a runtime primitive for it. Real Node
|
|
914
|
+
* supports TLA only in ESM. Nimbus's facet wrapper executes the
|
|
915
|
+
* transformed code via `new Function(...)` which is CJS-shaped.
|
|
916
|
+
*
|
|
917
|
+
* Several modern CLIs (nuxi, vite-cli, oclif's lazy-load bootstrap,
|
|
918
|
+
* many ESM-only-by-default tools) use TLA at the entry point. With
|
|
919
|
+
* format:'cjs' those would crash with "Top-level await is currently
|
|
920
|
+
* not supported with the 'cjs' output format" — an esbuild
|
|
921
|
+
* SyntaxError surfaced as a Nimbus diagnostic. The user can't
|
|
922
|
+
* fix this without rewriting upstream.
|
|
923
|
+
*
|
|
924
|
+
* Fix: when caller asks for format 'cjs' AND the source has a
|
|
925
|
+
* top-level await, wrap the source in an async IIFE and return its
|
|
926
|
+
* Promise to the facet runner:
|
|
927
|
+
*
|
|
928
|
+
* return (async () => {
|
|
929
|
+
* <original-source>
|
|
930
|
+
* })();
|
|
931
|
+
*
|
|
932
|
+
* Inside the IIFE, await is legal. Returning the Promise is required:
|
|
933
|
+
* the facet runner awaits promise-returning entry functions so
|
|
934
|
+
* sequential TLA execution cannot race process teardown or VFS flushes.
|
|
935
|
+
*
|
|
936
|
+
* ESM-imports-in-CJS note (nuxt-esm-in-cjs wave):
|
|
937
|
+
* ─────────────────────────────────────────────────
|
|
938
|
+
* The IIFE wrap above moves the user source INTO a function body.
|
|
939
|
+
* Top-level ESM `import` statements are LEGAL only at module top
|
|
940
|
+
* level — inside a function body they're a SyntaxError. Real-world
|
|
941
|
+
* trigger: nuxi's `bin/nuxi.mjs` opens with `import { performance }
|
|
942
|
+
* from "node:perf_hooks"` and ends with `const { runMain } = await
|
|
943
|
+
* import("./dist/index.mjs"); runMain()` — both ESM imports AND TLA.
|
|
944
|
+
* Pre-fix the IIFE wrap caused esbuild to fail with
|
|
945
|
+
* `Unexpected "<binding>"` at line 3 of stdin.
|
|
946
|
+
*
|
|
947
|
+
* Fix: when TLA AND ESM imports coexist, run a two-stage transform:
|
|
948
|
+
* 1. Pass 1: `esbuild.transform(code, { format: 'esm', ... })` —
|
|
949
|
+
* esbuild accepts TLA + imports cleanly when emitting ESM.
|
|
950
|
+
* Output is JS-canonicalised: multi-line imports collapsed,
|
|
951
|
+
* bindings normalised, etc.
|
|
952
|
+
* 2. Extract top-level imports from the pass-1 output and rewrite
|
|
953
|
+
* them as `const X = require(...)` shims (see
|
|
954
|
+
* `convertEsmImportsToRequire` for the contract / shape).
|
|
955
|
+
* 3. Wrap the remaining body in a returned async IIFE.
|
|
956
|
+
* 4. Return the assembled string as the transform result.
|
|
957
|
+
*
|
|
958
|
+
* The require-shim emits the standard `__esModule` interop check
|
|
959
|
+
* (matches what esbuild itself emits for ESM→CJS conversions), so
|
|
960
|
+
* default-export binding semantics are preserved.
|
|
961
|
+
*
|
|
962
|
+
* If TLA but no ESM imports → existing single-pass IIFE wrap.
|
|
963
|
+
* If ESM imports but no TLA → existing single-pass esbuild
|
|
964
|
+
* format:cjs (it auto-converts ESM→CJS gracefully).
|
|
965
|
+
*
|
|
966
|
+
* This is bytes-stable for sources outside the TLA+ESM-imports
|
|
967
|
+
* intersection.
|
|
968
|
+
*/
|
|
969
|
+
async transform(
|
|
970
|
+
code: string,
|
|
971
|
+
options?: {
|
|
972
|
+
loader?: 'ts' | 'tsx' | 'jsx' | 'js' | 'css' | 'json';
|
|
973
|
+
format?: 'esm' | 'cjs' | 'iife';
|
|
974
|
+
target?: string;
|
|
975
|
+
sourcemap?: boolean | 'inline' | 'external';
|
|
976
|
+
minify?: boolean;
|
|
977
|
+
jsx?: 'transform' | 'preserve' | 'automatic';
|
|
978
|
+
jsxFactory?: string;
|
|
979
|
+
jsxFragment?: string;
|
|
980
|
+
tsconfigRaw?: string;
|
|
981
|
+
define?: Record<string, string>;
|
|
982
|
+
},
|
|
983
|
+
): Promise<TransformResult> {
|
|
984
|
+
await this.ensureInit();
|
|
985
|
+
|
|
986
|
+
const format = options?.format || 'esm';
|
|
987
|
+
const loader = options?.loader || 'ts';
|
|
988
|
+
|
|
989
|
+
// ── CJS + TLA + ESM module syntax: two-pass with module rewrite ──
|
|
990
|
+
// This precedes the simple TLA-only IIFE wrap. We test ESM module
|
|
991
|
+
// syntax first because the IIFE wrap is incompatible with import
|
|
992
|
+
// and export statements; if both conditions hold we MUST go through
|
|
993
|
+
// the rewrite path.
|
|
994
|
+
if (format === 'cjs' && hasTopLevelAwait(code) && (hasEsmImports(code) || hasEsmExports(code))) {
|
|
995
|
+
// Pass 1: emit ESM so esbuild accepts TLA + imports without complaint.
|
|
996
|
+
// We use the same loader/target so TS/JSX is handled here too.
|
|
997
|
+
const pass1 = await this._esbuild!.transform(code, {
|
|
998
|
+
loader,
|
|
999
|
+
format: 'esm',
|
|
1000
|
+
target: options?.target || 'esnext',
|
|
1001
|
+
sourcemap: false, // pass-1 source map is discarded; pass-2 doesn't run esbuild
|
|
1002
|
+
minify: false, // minify only on the final output if requested
|
|
1003
|
+
jsx: options?.jsx,
|
|
1004
|
+
jsxFactory: options?.jsxFactory,
|
|
1005
|
+
jsxFragment: options?.jsxFragment,
|
|
1006
|
+
tsconfigRaw: options?.tsconfigRaw,
|
|
1007
|
+
define: options?.define,
|
|
1008
|
+
// Dynamic-import lowering: rewrites `import(x)` to
|
|
1009
|
+
// `Promise.resolve().then(() => __toESM(require(x)))` so the
|
|
1010
|
+
// call routes through Nimbus's scopedRequire → VFS lookup
|
|
1011
|
+
// instead of workerd's worker-module-map resolver (which only
|
|
1012
|
+
// knows {'runner.js': workerCode}). Without this, every user
|
|
1013
|
+
// dynamic import() rejects with "No such module ..." — and if
|
|
1014
|
+
// user code has no .catch() (e.g. create-astro.mjs's
|
|
1015
|
+
// `import('./dist/index.js').then(({main}) => main())`), the
|
|
1016
|
+
// rejection is unhandled and the facet exits silently
|
|
1017
|
+
supported: { 'dynamic-import': false },
|
|
1018
|
+
});
|
|
1019
|
+
const { requires, body } = convertEsmImportsToRequire(pass1.code);
|
|
1020
|
+
const assembled =
|
|
1021
|
+
requires + '\n' +
|
|
1022
|
+
'return (async () => {\n' +
|
|
1023
|
+
body +
|
|
1024
|
+
'\n})();\n';
|
|
1025
|
+
return {
|
|
1026
|
+
code: assembled,
|
|
1027
|
+
map: '',
|
|
1028
|
+
warnings: pass1.warnings?.map((w) => ({
|
|
1029
|
+
text: w.text,
|
|
1030
|
+
location: w.location,
|
|
1031
|
+
})) || [],
|
|
1032
|
+
};
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1035
|
+
// ── CJS + TLA (no ESM imports): single-pass IIFE wrap (P2 fix) ──
|
|
1036
|
+
let sourceToTransform = code;
|
|
1037
|
+
if (format === 'cjs' && hasTopLevelAwait(code)) {
|
|
1038
|
+
sourceToTransform =
|
|
1039
|
+
'return (async () => {\n' +
|
|
1040
|
+
code +
|
|
1041
|
+
'\n})();\n';
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
const result = await this._esbuild!.transform(sourceToTransform, {
|
|
1045
|
+
loader,
|
|
1046
|
+
format,
|
|
1047
|
+
target: options?.target || 'esnext',
|
|
1048
|
+
sourcemap: options?.sourcemap ?? false,
|
|
1049
|
+
minify: options?.minify ?? false,
|
|
1050
|
+
jsx: options?.jsx,
|
|
1051
|
+
jsxFactory: options?.jsxFactory,
|
|
1052
|
+
jsxFragment: options?.jsxFragment,
|
|
1053
|
+
tsconfigRaw: options?.tsconfigRaw,
|
|
1054
|
+
define: options?.define,
|
|
1055
|
+
// Dynamic-import lowering — see two-pass branch above for rationale.
|
|
1056
|
+
supported: { 'dynamic-import': false },
|
|
1057
|
+
});
|
|
1058
|
+
|
|
1059
|
+
return {
|
|
1060
|
+
code: result.code,
|
|
1061
|
+
map: result.map || '',
|
|
1062
|
+
warnings: result.warnings?.map(w => ({
|
|
1063
|
+
text: w.text,
|
|
1064
|
+
location: w.location,
|
|
1065
|
+
})) || [],
|
|
1066
|
+
};
|
|
1067
|
+
}
|
|
1068
|
+
|
|
1069
|
+
/**
|
|
1070
|
+
* Bundle entry points from the VFS.
|
|
1071
|
+
*/
|
|
1072
|
+
async build(
|
|
1073
|
+
entryPoints: string[],
|
|
1074
|
+
options?: {
|
|
1075
|
+
bundle?: boolean;
|
|
1076
|
+
format?: 'esm' | 'cjs' | 'iife';
|
|
1077
|
+
target?: string;
|
|
1078
|
+
platform?: 'browser' | 'node' | 'neutral';
|
|
1079
|
+
outdir?: string;
|
|
1080
|
+
outfile?: string;
|
|
1081
|
+
sourcemap?: boolean | 'inline' | 'external';
|
|
1082
|
+
minify?: boolean;
|
|
1083
|
+
external?: string[];
|
|
1084
|
+
define?: Record<string, string>;
|
|
1085
|
+
globalName?: string;
|
|
1086
|
+
tsconfigRaw?: string;
|
|
1087
|
+
alias?: Record<string, string>;
|
|
1088
|
+
keepNames?: boolean;
|
|
1089
|
+
},
|
|
1090
|
+
): Promise<BuildResult> {
|
|
1091
|
+
await this.ensureInit();
|
|
1092
|
+
|
|
1093
|
+
// VFS plugin reads directly from VFS (synchronous, co-located)
|
|
1094
|
+
const vfsPlugin = this.makeVfsPlugin();
|
|
1095
|
+
|
|
1096
|
+
const result = await this._esbuild!.build({
|
|
1097
|
+
entryPoints: entryPoints.map(ep => ep.startsWith('/') ? ep : '/' + ep),
|
|
1098
|
+
bundle: options?.bundle ?? true,
|
|
1099
|
+
write: false,
|
|
1100
|
+
format: options?.format || 'esm',
|
|
1101
|
+
target: options?.target || 'esnext',
|
|
1102
|
+
platform: options?.platform || 'browser',
|
|
1103
|
+
outdir: options?.outdir || (options?.outfile ? undefined : '/dist'),
|
|
1104
|
+
outfile: options?.outfile,
|
|
1105
|
+
sourcemap: options?.sourcemap ?? false,
|
|
1106
|
+
minify: options?.minify ?? false,
|
|
1107
|
+
external: options?.external,
|
|
1108
|
+
define: options?.define,
|
|
1109
|
+
globalName: options?.globalName,
|
|
1110
|
+
tsconfigRaw: options?.tsconfigRaw,
|
|
1111
|
+
alias: options?.alias,
|
|
1112
|
+
keepNames: options?.keepNames,
|
|
1113
|
+
// Prefer ESM builds and modern module fields. This matters for packages
|
|
1114
|
+
// like zustand that ship both CJS (main) and ESM (module / exports.import).
|
|
1115
|
+
// Without these, esbuild falls back to CJS which wraps everything in
|
|
1116
|
+
// __commonJS and only emits `export default`, losing named exports.
|
|
1117
|
+
conditions: ['import', 'module', 'browser', 'default'],
|
|
1118
|
+
mainFields: ['module', 'browser', 'main'],
|
|
1119
|
+
plugins: [vfsPlugin],
|
|
1120
|
+
});
|
|
1121
|
+
|
|
1122
|
+
return {
|
|
1123
|
+
outputFiles: (result.outputFiles || []).map(f => ({
|
|
1124
|
+
path: f.path,
|
|
1125
|
+
contents: f.text,
|
|
1126
|
+
})),
|
|
1127
|
+
errors: result.errors?.map(e => ({ text: e.text, location: e.location })) || [],
|
|
1128
|
+
warnings: result.warnings?.map(w => ({ text: w.text, location: w.location })) || [],
|
|
1129
|
+
};
|
|
1130
|
+
}
|
|
1131
|
+
|
|
1132
|
+
/**
|
|
1133
|
+
* VFS resolver plugin for esbuild.
|
|
1134
|
+
* Reads directly from the SqliteVFS (synchronous, co-located — no snapshot needed).
|
|
1135
|
+
* Handles: absolute paths, relative paths, bare specifiers (node_modules).
|
|
1136
|
+
*/
|
|
1137
|
+
private makeVfsPlugin(): esbuild.Plugin {
|
|
1138
|
+
const vfs = this.vfs;
|
|
1139
|
+
const EXTS = ['', '.ts', '.tsx', '.js', '.jsx', '.mts', '.mjs', '.cjs', '.json', '.css'];
|
|
1140
|
+
const INDEX_FILES = ['index.ts', 'index.tsx', 'index.js', 'index.jsx', 'index.mjs'];
|
|
1141
|
+
|
|
1142
|
+
// Path helpers shared with git-commands via ./vfs-path.ts.
|
|
1143
|
+
// Local aliases preserve the existing call-site readability inside this
|
|
1144
|
+
// closure; behavior is identical (the canonical normalizeVfsPath has a
|
|
1145
|
+
// bounds check on `..` that the previous local `normalize` lacked, but
|
|
1146
|
+
// for the well-formed paths esbuild produces this is a no-op).
|
|
1147
|
+
const strip = stripLeadingSlashes;
|
|
1148
|
+
const normalize = normalizeVfsPath;
|
|
1149
|
+
|
|
1150
|
+
/**
|
|
1151
|
+
* Try to resolve a VFS path with extension/index fallbacks.
|
|
1152
|
+
*
|
|
1153
|
+
* Resolution order (first match wins):
|
|
1154
|
+
* 1. Exact path as given (covers `.ts`, `.js`, `.json`, `.css`, and
|
|
1155
|
+
* any extension on disk) — via `''` being first in EXTS.
|
|
1156
|
+
* 2. Append-extension candidates from EXTS (`.ts`, `.tsx`, `.js`, …)
|
|
1157
|
+
* for extensionless imports like `./foo`.
|
|
1158
|
+
* 3. TypeScript/ESM `moduleResolution: "bundler"` compatibility:
|
|
1159
|
+
* if the input ends in `.js` / `.mjs` / `.cjs` / `.jsx` and
|
|
1160
|
+
* NO file matched above, swap the extension to the TS
|
|
1161
|
+
* equivalent and try those. This is the idiomatic
|
|
1162
|
+
* `import {X} from './y.js'` pattern where on-disk it's `y.ts`.
|
|
1163
|
+
* Order (TS spec): `.ts` → `.tsx` for `.js`/`.jsx`;
|
|
1164
|
+
* `.mts` for `.mjs`;
|
|
1165
|
+
* `.cts` for `.cjs`.
|
|
1166
|
+
* Exact-match (step 1) happens first so a real `.js` on disk
|
|
1167
|
+
* takes precedence over a co-located `.ts` — we never pretend
|
|
1168
|
+
* a `.ts` is canonical when a `.js` actually exists.
|
|
1169
|
+
* 4. Directory index files (e.g. `./foo/index.ts`) as a last step.
|
|
1170
|
+
*/
|
|
1171
|
+
function tryResolve(base: string): string | null {
|
|
1172
|
+
const norm = normalize(base);
|
|
1173
|
+
for (const ext of EXTS) {
|
|
1174
|
+
const candidate = norm + ext;
|
|
1175
|
+
if (vfs.exists(strip(candidate)) && !vfs.isDirectory(strip(candidate))) {
|
|
1176
|
+
return '/' + strip(candidate);
|
|
1177
|
+
}
|
|
1178
|
+
}
|
|
1179
|
+
// Step 3: TypeScript-bundler extension swap. Only runs when no
|
|
1180
|
+
// exact / extension-append match succeeded above — so real `.js`
|
|
1181
|
+
// files on disk always win.
|
|
1182
|
+
const jsExtMatch = norm.match(/\.(js|mjs|cjs|jsx)$/);
|
|
1183
|
+
if (jsExtMatch) {
|
|
1184
|
+
const withoutExt = norm.slice(0, norm.length - jsExtMatch[0].length);
|
|
1185
|
+
const swapMap: Record<string, string[]> = {
|
|
1186
|
+
js: ['.ts', '.tsx'],
|
|
1187
|
+
jsx: ['.tsx', '.ts'],
|
|
1188
|
+
mjs: ['.mts', '.ts'],
|
|
1189
|
+
cjs: ['.cts', '.ts'],
|
|
1190
|
+
};
|
|
1191
|
+
const swaps = swapMap[jsExtMatch[1]] || [];
|
|
1192
|
+
for (const tsExt of swaps) {
|
|
1193
|
+
const candidate = withoutExt + tsExt;
|
|
1194
|
+
if (vfs.exists(strip(candidate)) && !vfs.isDirectory(strip(candidate))) {
|
|
1195
|
+
return '/' + strip(candidate);
|
|
1196
|
+
}
|
|
1197
|
+
}
|
|
1198
|
+
}
|
|
1199
|
+
// Step 4: directory index fallback.
|
|
1200
|
+
if (vfs.exists(strip(norm)) && vfs.isDirectory(strip(norm))) {
|
|
1201
|
+
for (const idx of INDEX_FILES) {
|
|
1202
|
+
const candidate = norm + '/' + idx;
|
|
1203
|
+
if (vfs.exists(strip(candidate))) return '/' + strip(candidate);
|
|
1204
|
+
}
|
|
1205
|
+
}
|
|
1206
|
+
return null;
|
|
1207
|
+
}
|
|
1208
|
+
|
|
1209
|
+
/**
|
|
1210
|
+
* Resolve a Node.js subpath import (`#foo`).
|
|
1211
|
+
*
|
|
1212
|
+
* Per https://nodejs.org/api/packages.html#subpath-imports, a specifier
|
|
1213
|
+
* starting with `#` is looked up in the closest ancestor package.json's
|
|
1214
|
+
* `imports` field (not `exports`). This is used by packages like `vfile`
|
|
1215
|
+
* to switch between node and browser implementations:
|
|
1216
|
+
*
|
|
1217
|
+
* "imports": {
|
|
1218
|
+
* "#minpath": {
|
|
1219
|
+
* "node": "./lib/minpath.js",
|
|
1220
|
+
* "default": "./lib/minpath.browser.js"
|
|
1221
|
+
* }
|
|
1222
|
+
* }
|
|
1223
|
+
*
|
|
1224
|
+
* We walk up from the importer's directory looking for package.json.
|
|
1225
|
+
* Once found, we resolve the subpath using the same condition algorithm
|
|
1226
|
+
* as `exports` (with `import`, `module`, `browser`, `default` — skipping
|
|
1227
|
+
* `node` since we're bundling for the browser).
|
|
1228
|
+
*
|
|
1229
|
+
* The resolved value is a path relative to the owning package root, which
|
|
1230
|
+
* we turn back into a VFS path for esbuild to load.
|
|
1231
|
+
*/
|
|
1232
|
+
function resolvePackageImport(specifier: string, fromDir: string): string | null {
|
|
1233
|
+
let dir = strip(fromDir);
|
|
1234
|
+
const visited = new Set<string>();
|
|
1235
|
+
while (dir && !visited.has(dir)) {
|
|
1236
|
+
visited.add(dir);
|
|
1237
|
+
|
|
1238
|
+
const pkgJsonPath = dir + '/package.json';
|
|
1239
|
+
if (vfs.exists(strip(pkgJsonPath))) {
|
|
1240
|
+
try {
|
|
1241
|
+
const pkgJson = JSON.parse(vfs.readFileString(strip(pkgJsonPath)));
|
|
1242
|
+
if (pkgJson.imports) {
|
|
1243
|
+
// resolveExports happens to work for the imports field too —
|
|
1244
|
+
// both are subpath→condition maps using the same format. We
|
|
1245
|
+
// reuse it. The specifier (`#minpath`) IS the subpath key.
|
|
1246
|
+
const resolved = resolveExports(pkgJson.imports, specifier);
|
|
1247
|
+
if (resolved) {
|
|
1248
|
+
// Resolved value is relative to the owning package root
|
|
1249
|
+
const pkgRoot = dir;
|
|
1250
|
+
const absPath = pkgRoot + '/' + resolved.replace(/^\.\//, '');
|
|
1251
|
+
const finalPath = tryResolve(absPath);
|
|
1252
|
+
if (finalPath) return finalPath;
|
|
1253
|
+
}
|
|
1254
|
+
}
|
|
1255
|
+
} catch { /* malformed package.json — try parent */ }
|
|
1256
|
+
}
|
|
1257
|
+
|
|
1258
|
+
// Stop at node_modules boundary — subpath imports only resolve against
|
|
1259
|
+
// the consuming package's own package.json, not its dependencies'.
|
|
1260
|
+
// But DO go up through node_modules/<pkg>/ to find <pkg>/package.json.
|
|
1261
|
+
if (dir.endsWith('/node_modules') || dir === 'node_modules') break;
|
|
1262
|
+
|
|
1263
|
+
const lastSlash = dir.lastIndexOf('/');
|
|
1264
|
+
if (lastSlash <= 0) break;
|
|
1265
|
+
dir = dir.substring(0, lastSlash);
|
|
1266
|
+
}
|
|
1267
|
+
return null;
|
|
1268
|
+
}
|
|
1269
|
+
|
|
1270
|
+
// Conditions per-resolution. CJS `require('X')` callers need the
|
|
1271
|
+
// `require` condition selected so packages that ship a dual-export
|
|
1272
|
+
// CJS trick (e.g. @babel/runtime/helpers/X — `module.exports = fn;
|
|
1273
|
+
// module.exports.default = module.exports;`) resolve to the CJS
|
|
1274
|
+
// file. The ESM helper file declares only `export { fn as default }`,
|
|
1275
|
+
// which esbuild's __toCommonJS wrap surfaces to CJS callers as
|
|
1276
|
+
// `{ default: fn }` — and the downstream callsite calls the
|
|
1277
|
+
// namespace as a function and crashes with
|
|
1278
|
+
// `_objectWithoutPropertiesLoose2 is not a function`.
|
|
1279
|
+
//
|
|
1280
|
+
// This affects every CJS-shipping npm package that depends on
|
|
1281
|
+
// `@babel/runtime/helpers/*` (thousands — anything compiled with
|
|
1282
|
+
// `@babel/preset-env`'s `transform-runtime`).
|
|
1283
|
+
// See pre-bundle-facet.ts for the matching fix in the install-time
|
|
1284
|
+
// pre-bundle plugin. Both code paths must agree.
|
|
1285
|
+
const ESM_CONDITIONS = ['import', 'module', 'browser', 'default'];
|
|
1286
|
+
const CJS_CONDITIONS = ['require', 'node', 'browser', 'default'];
|
|
1287
|
+
|
|
1288
|
+
/**
|
|
1289
|
+
* Resolve bare specifier (npm package) by walking up node_modules.
|
|
1290
|
+
* Uses the full Node.js exports-field algorithm. `conditions` is
|
|
1291
|
+
* passed through so caller can request CJS-flavoured resolution
|
|
1292
|
+
* (for `require()` calls in bundled CJS code).
|
|
1293
|
+
*/
|
|
1294
|
+
function resolveBarePkg(specifier: string, fromDir: string, conditions: string[]): string | null {
|
|
1295
|
+
// Split scoped packages: @scope/pkg → ["@scope/pkg"]
|
|
1296
|
+
// Split subpath imports: pkg/sub/path → pkg, sub/path
|
|
1297
|
+
let pkgName: string;
|
|
1298
|
+
let subpath: string;
|
|
1299
|
+
if (specifier.startsWith('@')) {
|
|
1300
|
+
const parts = specifier.split('/');
|
|
1301
|
+
pkgName = parts.slice(0, 2).join('/');
|
|
1302
|
+
subpath = parts.slice(2).join('/');
|
|
1303
|
+
} else {
|
|
1304
|
+
const parts = specifier.split('/');
|
|
1305
|
+
pkgName = parts[0];
|
|
1306
|
+
subpath = parts.slice(1).join('/');
|
|
1307
|
+
}
|
|
1308
|
+
|
|
1309
|
+
// Walk up directories looking for node_modules/<pkg>
|
|
1310
|
+
let dir = strip(fromDir);
|
|
1311
|
+
const visited = new Set<string>();
|
|
1312
|
+
while (dir && !visited.has(dir)) {
|
|
1313
|
+
visited.add(dir);
|
|
1314
|
+
const nmDir = dir + '/node_modules/' + pkgName;
|
|
1315
|
+
if (vfs.exists(strip(nmDir)) && vfs.isDirectory(strip(nmDir))) {
|
|
1316
|
+
// Read package.json so we can consult the exports field.
|
|
1317
|
+
const pkgJsonPath = nmDir + '/package.json';
|
|
1318
|
+
let pkgJson: any = null;
|
|
1319
|
+
if (vfs.exists(strip(pkgJsonPath))) {
|
|
1320
|
+
try { pkgJson = JSON.parse(vfs.readFileString(strip(pkgJsonPath))); } catch {}
|
|
1321
|
+
}
|
|
1322
|
+
|
|
1323
|
+
if (pkgJson) {
|
|
1324
|
+
// Use the full exports-field resolution. Conditions are
|
|
1325
|
+
// caller-supplied so `require()` and `import` get distinct
|
|
1326
|
+
// resolutions per Node spec.
|
|
1327
|
+
const subpathKey = subpath ? './' + subpath : '.';
|
|
1328
|
+
const entry = resolvePackageEntry(pkgJson, subpathKey, conditions);
|
|
1329
|
+
if (entry) {
|
|
1330
|
+
const resolved = tryResolve(nmDir + '/' + entry.replace(/^\.\//, ''));
|
|
1331
|
+
if (resolved) return resolved;
|
|
1332
|
+
}
|
|
1333
|
+
}
|
|
1334
|
+
|
|
1335
|
+
// Fallback for subpath: try direct file resolution (e.g. pkg/lib/foo).
|
|
1336
|
+
if (subpath) {
|
|
1337
|
+
const resolved = tryResolve(nmDir + '/' + subpath);
|
|
1338
|
+
if (resolved) return resolved;
|
|
1339
|
+
}
|
|
1340
|
+
|
|
1341
|
+
// Fallback for root: try index files directly
|
|
1342
|
+
const resolved = tryResolve(nmDir + '/index');
|
|
1343
|
+
if (resolved) return resolved;
|
|
1344
|
+
}
|
|
1345
|
+
// Move up one directory
|
|
1346
|
+
const lastSlash = dir.lastIndexOf('/');
|
|
1347
|
+
if (lastSlash <= 0) break;
|
|
1348
|
+
dir = dir.substring(0, lastSlash);
|
|
1349
|
+
}
|
|
1350
|
+
return null;
|
|
1351
|
+
}
|
|
1352
|
+
|
|
1353
|
+
function inferLoader(path: string): esbuild.Loader {
|
|
1354
|
+
if (path.endsWith('.ts') || path.endsWith('.mts') || path.endsWith('.cts')) return 'ts';
|
|
1355
|
+
if (path.endsWith('.tsx')) return 'tsx';
|
|
1356
|
+
if (path.endsWith('.jsx')) return 'jsx';
|
|
1357
|
+
if (path.endsWith('.json')) return 'json';
|
|
1358
|
+
if (path.endsWith('.css')) return 'css';
|
|
1359
|
+
// Native binaries — load as base64 blobs instead of parsing as JS.
|
|
1360
|
+
// Defense-in-depth: the npm-installer pre-bundler also skips these,
|
|
1361
|
+
// but on-demand bundling or direct `import 'foo.wasm'` could still
|
|
1362
|
+
// hand us a raw WASM/native-addon path.
|
|
1363
|
+
if (path.endsWith('.wasm')) return 'binary';
|
|
1364
|
+
if (path.endsWith('.node')) return 'binary';
|
|
1365
|
+
return 'js';
|
|
1366
|
+
}
|
|
1367
|
+
|
|
1368
|
+
return {
|
|
1369
|
+
name: 'nimbus-vfs',
|
|
1370
|
+
setup(build) {
|
|
1371
|
+
// Pre-compile the external list into exact matches and prefix patterns.
|
|
1372
|
+
// esbuild's `external` supports glob-like patterns (`react/*`) — we
|
|
1373
|
+
// reproduce that here so our plugin doesn't override the user's
|
|
1374
|
+
// external directive by resolving packages that should stay external.
|
|
1375
|
+
const externalList = build.initialOptions.external || [];
|
|
1376
|
+
const externalExact = new Set<string>();
|
|
1377
|
+
const externalPrefixes: string[] = [];
|
|
1378
|
+
for (const pat of externalList) {
|
|
1379
|
+
if (pat.endsWith('/*')) {
|
|
1380
|
+
externalPrefixes.push(pat.slice(0, -1)); // "react/" prefix (for "react/*")
|
|
1381
|
+
} else {
|
|
1382
|
+
externalExact.add(pat);
|
|
1383
|
+
}
|
|
1384
|
+
}
|
|
1385
|
+
const isExternal = (spec: string): boolean => {
|
|
1386
|
+
if (externalExact.has(spec)) return true;
|
|
1387
|
+
for (const pre of externalPrefixes) {
|
|
1388
|
+
if (spec.startsWith(pre)) return true;
|
|
1389
|
+
}
|
|
1390
|
+
return false;
|
|
1391
|
+
};
|
|
1392
|
+
|
|
1393
|
+
build.onResolve({ filter: /.*/ }, (args) => {
|
|
1394
|
+
// 1. Subpath imports (#foo) — Node.js package.json `imports` field.
|
|
1395
|
+
// These MUST be resolved against the owning package's package.json,
|
|
1396
|
+
// not node_modules. Used by vfile, unified, and others to switch
|
|
1397
|
+
// between node/browser implementations.
|
|
1398
|
+
if (args.path.startsWith('#') && args.resolveDir) {
|
|
1399
|
+
const resolved = resolvePackageImport(args.path, strip(args.resolveDir));
|
|
1400
|
+
if (resolved) return { path: resolved, namespace: 'nimbus-vfs' };
|
|
1401
|
+
// If we can't resolve it, fall through — better to leak a bare
|
|
1402
|
+
// import that fails loudly than to pretend it's external.
|
|
1403
|
+
}
|
|
1404
|
+
|
|
1405
|
+
// 2. Bare specifier + external → leave as-is so the browser resolves
|
|
1406
|
+
// via its own module resolver (which hits /preview/@modules/...).
|
|
1407
|
+
// This MUST come before any vfs resolution, otherwise we'd embed
|
|
1408
|
+
// the package into the bundle and break single-instance invariants
|
|
1409
|
+
// for react/react-dom.
|
|
1410
|
+
if (!args.path.startsWith('/') && !args.path.startsWith('.') && !args.path.startsWith('#')) {
|
|
1411
|
+
if (isExternal(args.path)) return { external: true };
|
|
1412
|
+
}
|
|
1413
|
+
// 3. Absolute paths
|
|
1414
|
+
if (args.path.startsWith('/')) {
|
|
1415
|
+
const resolved = tryResolve(args.path);
|
|
1416
|
+
if (resolved) return { path: resolved, namespace: 'nimbus-vfs' };
|
|
1417
|
+
}
|
|
1418
|
+
// 4. Relative paths
|
|
1419
|
+
if (args.path.startsWith('.') && args.resolveDir) {
|
|
1420
|
+
const dir = strip(args.resolveDir);
|
|
1421
|
+
const resolved = tryResolve(dir + '/' + args.path);
|
|
1422
|
+
if (resolved) return { path: resolved, namespace: 'nimbus-vfs' };
|
|
1423
|
+
}
|
|
1424
|
+
// 5. Bare specifier (npm package)
|
|
1425
|
+
if (!args.path.startsWith('/') && !args.path.startsWith('.') && !args.path.startsWith('#')) {
|
|
1426
|
+
const fromDir = args.resolveDir || '/home/user';
|
|
1427
|
+
// Per Node spec: `require()` triggers the 'require' condition,
|
|
1428
|
+
// `import` triggers 'import'. esbuild surfaces this via
|
|
1429
|
+
// args.kind. Without this, packages that ship a dual-export
|
|
1430
|
+
// CJS file alongside a bare ESM file (e.g. @babel/runtime/
|
|
1431
|
+
// helpers/*) get resolved to the ESM variant for CJS callers,
|
|
1432
|
+
// and the `__toCommonJS` wrapper surfaces `{ default: fn }`
|
|
1433
|
+
// to a callsite that expects the function directly — runtime
|
|
1434
|
+
// crash with "<helper>2 is not a function" on the first
|
|
1435
|
+
// route that uses the affected package.
|
|
1436
|
+
const conditions = args.kind === 'require-call' || args.kind === 'require-resolve'
|
|
1437
|
+
? CJS_CONDITIONS
|
|
1438
|
+
: ESM_CONDITIONS;
|
|
1439
|
+
const resolved = resolveBarePkg(args.path, fromDir, conditions);
|
|
1440
|
+
if (resolved) return { path: resolved, namespace: 'nimbus-vfs' };
|
|
1441
|
+
// Mark as external if not found (common for Node built-ins)
|
|
1442
|
+
return { external: true };
|
|
1443
|
+
}
|
|
1444
|
+
return { external: true };
|
|
1445
|
+
});
|
|
1446
|
+
|
|
1447
|
+
build.onLoad({ filter: /.*/, namespace: 'nimbus-vfs' }, (args) => {
|
|
1448
|
+
const stripped = strip(args.path);
|
|
1449
|
+
try {
|
|
1450
|
+
const loader = inferLoader(args.path);
|
|
1451
|
+
const lastSlash = stripped.lastIndexOf('/');
|
|
1452
|
+
const resolveDir = lastSlash > 0 ? '/' + stripped.substring(0, lastSlash) : '/';
|
|
1453
|
+
// Binary loaders (wasm, native addons) must receive raw bytes.
|
|
1454
|
+
// TextDecoder would corrupt them with U+FFFD replacement chars.
|
|
1455
|
+
if (loader === 'binary') {
|
|
1456
|
+
const bytes = vfs.readFile(stripped);
|
|
1457
|
+
return { contents: bytes, loader, resolveDir };
|
|
1458
|
+
}
|
|
1459
|
+
const contents = vfs.readFileString(stripped);
|
|
1460
|
+
return { contents, loader, resolveDir };
|
|
1461
|
+
} catch {
|
|
1462
|
+
return { errors: [{ text: 'File not found in VFS: ' + args.path }] };
|
|
1463
|
+
}
|
|
1464
|
+
});
|
|
1465
|
+
},
|
|
1466
|
+
};
|
|
1467
|
+
}
|
|
1468
|
+
|
|
1469
|
+
get isInitialized() { return this.initialized; }
|
|
1470
|
+
}
|