@nimbus-sh/worker 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/README.md +219 -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 +146 -0
- package/dist/_shared/cache-stats.d.ts.map +1 -0
- package/dist/_shared/cache-stats.js +162 -0
- package/dist/_shared/exports-resolver.d.ts +76 -0
- package/dist/_shared/exports-resolver.d.ts.map +1 -0
- package/dist/_shared/exports-resolver.js +284 -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/real-node-imports.d.ts +38 -0
- package/dist/_shared/real-node-imports.d.ts.map +1 -0
- package/dist/_shared/real-node-imports.js +46 -0
- package/dist/_shared/retry.d.ts +93 -0
- package/dist/_shared/retry.d.ts.map +1 -0
- package/dist/_shared/retry.js +161 -0
- package/dist/_shared/session-id.d.ts +39 -0
- package/dist/_shared/session-id.d.ts.map +1 -0
- package/dist/_shared/session-id.js +127 -0
- package/dist/_shared/session-router.d.ts +104 -0
- package/dist/_shared/session-router.d.ts.map +1 -0
- package/dist/_shared/session-router.js +165 -0
- package/dist/_shared/w7-frame.d.ts +93 -0
- package/dist/_shared/w7-frame.d.ts.map +1 -0
- package/dist/_shared/w7-frame.js +402 -0
- package/dist/auth/index.d.ts +16 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +15 -0
- package/dist/auth/middleware.d.ts +85 -0
- package/dist/auth/middleware.d.ts.map +1 -0
- package/dist/auth/middleware.js +150 -0
- package/dist/auth/token.d.ts +96 -0
- package/dist/auth/token.d.ts.map +1 -0
- package/dist/auth/token.js +226 -0
- package/dist/auth/types.d.ts +141 -0
- package/dist/auth/types.d.ts.map +1 -0
- package/dist/auth/types.js +114 -0
- package/dist/bindings/d1.d.ts +102 -0
- package/dist/bindings/d1.d.ts.map +1 -0
- package/dist/bindings/d1.js +549 -0
- package/dist/bindings/kv.d.ts +82 -0
- package/dist/bindings/kv.d.ts.map +1 -0
- package/dist/bindings/kv.js +290 -0
- package/dist/bindings/r2.d.ts +137 -0
- package/dist/bindings/r2.d.ts.map +1 -0
- package/dist/bindings/r2.js +379 -0
- package/dist/cirrus-npm-cjs.generated.d.ts +17 -0
- package/dist/cirrus-npm-cjs.generated.d.ts.map +1 -0
- package/dist/cirrus-npm-cjs.generated.js +41 -0
- package/dist/cirrus-plugin-react.generated.d.ts +34 -0
- package/dist/cirrus-plugin-react.generated.d.ts.map +1 -0
- package/dist/cirrus-plugin-react.generated.js +33 -0
- package/dist/constants.d.ts +34 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +116 -0
- package/dist/esbuild-wasm-bundle.generated.d.ts +41 -0
- package/dist/esbuild-wasm-bundle.generated.d.ts.map +1 -0
- package/dist/esbuild-wasm-bundle.generated.js +40 -0
- package/dist/facets/cirrus-real.d.ts +147 -0
- package/dist/facets/cirrus-real.d.ts.map +1 -0
- package/dist/facets/cirrus-real.js +981 -0
- package/dist/facets/inner-do-registry.d.ts +41 -0
- package/dist/facets/inner-do-registry.d.ts.map +1 -0
- package/dist/facets/inner-do-registry.js +51 -0
- package/dist/facets/manager.d.ts +314 -0
- package/dist/facets/manager.d.ts.map +1 -0
- package/dist/facets/manager.js +2681 -0
- package/dist/facets/process.d.ts +318 -0
- package/dist/facets/process.d.ts.map +1 -0
- package/dist/facets/process.js +567 -0
- package/dist/facets/real-vite-fs-shim.d.ts +151 -0
- package/dist/facets/real-vite-fs-shim.d.ts.map +1 -0
- package/dist/facets/real-vite-fs-shim.js +1279 -0
- package/dist/facets/real-vite-hmr.d.ts +142 -0
- package/dist/facets/real-vite-hmr.d.ts.map +1 -0
- package/dist/facets/real-vite-hmr.js +476 -0
- package/dist/facets/vite-dev-server.d.ts +293 -0
- package/dist/facets/vite-dev-server.d.ts.map +1 -0
- package/dist/facets/vite-dev-server.js +2580 -0
- package/dist/facets/wasm-swap-registry.d.ts +261 -0
- package/dist/facets/wasm-swap-registry.d.ts.map +1 -0
- package/dist/facets/wasm-swap-registry.js +551 -0
- package/dist/facets/ws-terminal.d.ts +107 -0
- package/dist/facets/ws-terminal.d.ts.map +1 -0
- package/dist/facets/ws-terminal.js +207 -0
- package/dist/git/commands.d.ts +13 -0
- package/dist/git/commands.d.ts.map +1 -0
- package/dist/git/commands.js +633 -0
- package/dist/git/network-facet.d.ts +61 -0
- package/dist/git/network-facet.d.ts.map +1 -0
- package/dist/git/network-facet.js +700 -0
- package/dist/git-bundle.generated.d.ts +16 -0
- package/dist/git-bundle.generated.d.ts.map +1 -0
- package/dist/git-bundle.generated.js +15 -0
- package/dist/index.d.ts +41 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +73 -0
- package/dist/loaders/child-process/spawn-facet.d.ts +90 -0
- package/dist/loaders/child-process/spawn-facet.d.ts.map +1 -0
- package/dist/loaders/child-process/spawn-facet.js +103 -0
- package/dist/loaders/child-process/spawn-pool.d.ts +110 -0
- package/dist/loaders/child-process/spawn-pool.d.ts.map +1 -0
- package/dist/loaders/child-process/spawn-pool.js +161 -0
- package/dist/loaders/fanout-pool.d.ts +195 -0
- package/dist/loaders/fanout-pool.d.ts.map +1 -0
- package/dist/loaders/fanout-pool.js +326 -0
- package/dist/loaders/generated-workers.d.ts +26 -0
- package/dist/loaders/generated-workers.d.ts.map +1 -0
- package/dist/loaders/generated-workers.js +25 -0
- package/dist/loaders/index.d.ts +15 -0
- package/dist/loaders/index.d.ts.map +1 -0
- package/dist/loaders/index.js +13 -0
- package/dist/loaders/loader-pool.d.ts +273 -0
- package/dist/loaders/loader-pool.d.ts.map +1 -0
- package/dist/loaders/loader-pool.js +624 -0
- package/dist/loaders/npm-resolve-preamble.d.ts +34 -0
- package/dist/loaders/npm-resolve-preamble.d.ts.map +1 -0
- package/dist/loaders/npm-resolve-preamble.js +237 -0
- package/dist/loaders/pre-bundle-preamble.d.ts +41 -0
- package/dist/loaders/pre-bundle-preamble.d.ts.map +1 -0
- package/dist/loaders/pre-bundle-preamble.js +114 -0
- package/dist/loaders/vendor/codegen.d.ts +24 -0
- package/dist/loaders/vendor/codegen.d.ts.map +1 -0
- package/dist/loaders/vendor/codegen.js +44 -0
- package/dist/loaders/vendor/errors.d.ts +24 -0
- package/dist/loaders/vendor/errors.d.ts.map +1 -0
- package/dist/loaders/vendor/errors.js +46 -0
- package/dist/loaders/vendor/index.d.ts +16 -0
- package/dist/loaders/vendor/index.d.ts.map +1 -0
- package/dist/loaders/vendor/index.js +11 -0
- package/dist/loaders/vendor/pool.d.ts +88 -0
- package/dist/loaders/vendor/pool.d.ts.map +1 -0
- package/dist/loaders/vendor/pool.js +353 -0
- package/dist/loaders/vendor/primitives.d.ts +11 -0
- package/dist/loaders/vendor/primitives.d.ts.map +1 -0
- package/dist/loaders/vendor/primitives.js +33 -0
- package/dist/loaders/vendor/serialize.d.ts +3 -0
- package/dist/loaders/vendor/serialize.d.ts.map +1 -0
- package/dist/loaders/vendor/serialize.js +25 -0
- package/dist/loaders/vendor/types.d.ts +60 -0
- package/dist/loaders/vendor/types.d.ts.map +1 -0
- package/dist/loaders/vendor/types.js +4 -0
- package/dist/npm/cache.d.ts +136 -0
- package/dist/npm/cache.d.ts.map +1 -0
- package/dist/npm/cache.js +429 -0
- package/dist/npm/install-batch-facet.d.ts +129 -0
- package/dist/npm/install-batch-facet.d.ts.map +1 -0
- package/dist/npm/install-batch-facet.js +598 -0
- package/dist/npm/install-facet.d.ts +29 -0
- package/dist/npm/install-facet.d.ts.map +1 -0
- package/dist/npm/install-facet.js +9 -0
- package/dist/npm/installer.d.ts +239 -0
- package/dist/npm/installer.d.ts.map +1 -0
- package/dist/npm/installer.js +2022 -0
- package/dist/npm/npx-install.d.ts +74 -0
- package/dist/npm/npx-install.d.ts.map +1 -0
- package/dist/npm/npx-install.js +302 -0
- package/dist/npm/pre-bundle-facet.d.ts +168 -0
- package/dist/npm/pre-bundle-facet.d.ts.map +1 -0
- package/dist/npm/pre-bundle-facet.js +653 -0
- package/dist/npm/r2-cache.d.ts +286 -0
- package/dist/npm/r2-cache.d.ts.map +1 -0
- package/dist/npm/r2-cache.js +506 -0
- package/dist/npm/resolve-facet.d.ts +202 -0
- package/dist/npm/resolve-facet.d.ts.map +1 -0
- package/dist/npm/resolve-facet.js +833 -0
- package/dist/npm/resolve-one-facet.d.ts +204 -0
- package/dist/npm/resolve-one-facet.d.ts.map +1 -0
- package/dist/npm/resolve-one-facet.js +437 -0
- package/dist/npm/resolver.d.ts +109 -0
- package/dist/npm/resolver.d.ts.map +1 -0
- package/dist/npm/resolver.js +899 -0
- package/dist/npm/tarball-stream.d.ts +85 -0
- package/dist/npm/tarball-stream.d.ts.map +1 -0
- package/dist/npm/tarball-stream.js +205 -0
- package/dist/npm/tarball.d.ts +51 -0
- package/dist/npm/tarball.d.ts.map +1 -0
- package/dist/npm/tarball.js +185 -0
- package/dist/observability/diag-counters.d.ts +292 -0
- package/dist/observability/diag-counters.d.ts.map +1 -0
- package/dist/observability/diag-counters.js +302 -0
- package/dist/observability/heap-estimate.d.ts +166 -0
- package/dist/observability/heap-estimate.d.ts.map +1 -0
- package/dist/observability/heap-estimate.js +192 -0
- package/dist/observability/heavy-alloc-coord.d.ts +95 -0
- package/dist/observability/heavy-alloc-coord.d.ts.map +1 -0
- package/dist/observability/heavy-alloc-coord.js +149 -0
- package/dist/observability/oom-classify.d.ts +56 -0
- package/dist/observability/oom-classify.d.ts.map +1 -0
- package/dist/observability/oom-classify.js +118 -0
- package/dist/observability/oom-discriminator.d.ts +192 -0
- package/dist/observability/oom-discriminator.d.ts.map +1 -0
- package/dist/observability/oom-discriminator.js +233 -0
- package/dist/real-vite-bundle.generated.d.ts +46 -0
- package/dist/real-vite-bundle.generated.d.ts.map +1 -0
- package/dist/real-vite-bundle.generated.js +53 -0
- package/dist/replica/routing.d.ts +171 -0
- package/dist/replica/routing.d.ts.map +1 -0
- package/dist/replica/routing.js +288 -0
- package/dist/replica/suspension.d.ts +36 -0
- package/dist/replica/suspension.d.ts.map +1 -0
- package/dist/replica/suspension.js +49 -0
- package/dist/router/index.d.ts +156 -0
- package/dist/router/index.d.ts.map +1 -0
- package/dist/router/index.js +220 -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 +128 -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/barrel-synthesizer.d.ts +181 -0
- package/dist/runtime/barrel-synthesizer.d.ts.map +1 -0
- package/dist/runtime/barrel-synthesizer.js +541 -0
- package/dist/runtime/bun-repl.d.ts +46 -0
- package/dist/runtime/bun-repl.d.ts.map +1 -0
- package/dist/runtime/bun-repl.js +326 -0
- package/dist/runtime/bun-runner.d.ts +66 -0
- package/dist/runtime/bun-runner.d.ts.map +1 -0
- package/dist/runtime/bun-runner.js +219 -0
- package/dist/runtime/clang-runner.d.ts +38 -0
- package/dist/runtime/clang-runner.d.ts.map +1 -0
- package/dist/runtime/clang-runner.js +1033 -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/esbuild-service.d.ts +201 -0
- package/dist/runtime/esbuild-service.d.ts.map +1 -0
- package/dist/runtime/esbuild-service.js +1444 -0
- package/dist/runtime/esbuild-wasm-bytes.d.ts +87 -0
- package/dist/runtime/esbuild-wasm-bytes.d.ts.map +1 -0
- package/dist/runtime/esbuild-wasm-bytes.js +131 -0
- package/dist/runtime/framework-detect.d.ts +71 -0
- package/dist/runtime/framework-detect.d.ts.map +1 -0
- package/dist/runtime/framework-detect.js +178 -0
- package/dist/runtime/long-running-handle.d.ts +133 -0
- package/dist/runtime/long-running-handle.d.ts.map +1 -0
- package/dist/runtime/long-running-handle.js +192 -0
- package/dist/runtime/node-repl.d.ts +36 -0
- package/dist/runtime/node-repl.d.ts.map +1 -0
- package/dist/runtime/node-repl.js +293 -0
- package/dist/runtime/node-runner.d.ts +111 -0
- package/dist/runtime/node-runner.d.ts.map +1 -0
- package/dist/runtime/node-runner.js +194 -0
- package/dist/runtime/node-shims.d.ts +24 -0
- package/dist/runtime/node-shims.d.ts.map +1 -0
- package/dist/runtime/node-shims.js +3019 -0
- package/dist/runtime/package-manager.d.ts +118 -0
- package/dist/runtime/package-manager.d.ts.map +1 -0
- package/dist/runtime/package-manager.js +420 -0
- package/dist/runtime/port-registry.d.ts +80 -0
- package/dist/runtime/port-registry.d.ts.map +1 -0
- package/dist/runtime/port-registry.js +166 -0
- package/dist/runtime/process-logs-api.d.ts +102 -0
- package/dist/runtime/process-logs-api.d.ts.map +1 -0
- package/dist/runtime/process-logs-api.js +253 -0
- package/dist/runtime/process-logs.d.ts +311 -0
- package/dist/runtime/process-logs.d.ts.map +1 -0
- package/dist/runtime/process-logs.js +656 -0
- package/dist/runtime/process-table.d.ts +65 -0
- package/dist/runtime/process-table.d.ts.map +1 -0
- package/dist/runtime/process-table.js +107 -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-repl.d.ts +66 -0
- package/dist/runtime/python-repl.d.ts.map +1 -0
- package/dist/runtime/python-repl.js +563 -0
- package/dist/runtime/python-runner.d.ts +50 -0
- package/dist/runtime/python-runner.d.ts.map +1 -0
- package/dist/runtime/python-runner.js +870 -0
- package/dist/runtime/repl-session.d.ts +160 -0
- package/dist/runtime/repl-session.d.ts.map +1 -0
- package/dist/runtime/repl-session.js +393 -0
- package/dist/runtime/require-resolver.d.ts +52 -0
- package/dist/runtime/require-resolver.d.ts.map +1 -0
- package/dist/runtime/require-resolver.js +690 -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-repl.d.ts +43 -0
- package/dist/runtime/ruby-repl.d.ts.map +1 -0
- package/dist/runtime/ruby-repl.js +229 -0
- package/dist/runtime/ruby-runner.d.ts +62 -0
- package/dist/runtime/ruby-runner.d.ts.map +1 -0
- package/dist/runtime/ruby-runner.js +737 -0
- package/dist/runtime/runtime-catalog.d.ts +99 -0
- package/dist/runtime/runtime-catalog.d.ts.map +1 -0
- package/dist/runtime/runtime-catalog.js +183 -0
- package/dist/runtime/runtime-registry.d.ts +136 -0
- package/dist/runtime/runtime-registry.d.ts.map +1 -0
- package/dist/runtime/runtime-registry.js +318 -0
- package/dist/runtime/streams.d.ts +13 -0
- package/dist/runtime/streams.d.ts.map +1 -0
- package/dist/runtime/streams.js +402 -0
- package/dist/runtime/wasi-instance.d.ts +190 -0
- package/dist/runtime/wasi-instance.d.ts.map +1 -0
- package/dist/runtime/wasi-instance.js +2044 -0
- package/dist/runtime/wasm-runner.d.ts +117 -0
- package/dist/runtime/wasm-runner.d.ts.map +1 -0
- package/dist/runtime/wasm-runner.js +705 -0
- package/dist/session/bindings.d.ts +168 -0
- package/dist/session/bindings.d.ts.map +1 -0
- package/dist/session/bindings.js +524 -0
- package/dist/session/ctx-exports.d.ts +16 -0
- package/dist/session/ctx-exports.d.ts.map +1 -0
- package/dist/session/ctx-exports.js +22 -0
- package/dist/session/diag.d.ts +62 -0
- package/dist/session/diag.d.ts.map +1 -0
- package/dist/session/diag.js +118 -0
- package/dist/session/fs-watch.d.ts +132 -0
- package/dist/session/fs-watch.d.ts.map +1 -0
- package/dist/session/fs-watch.js +255 -0
- package/dist/session/helpers.d.ts +150 -0
- package/dist/session/helpers.d.ts.map +1 -0
- package/dist/session/helpers.js +472 -0
- package/dist/session/hibernation.d.ts +145 -0
- package/dist/session/hibernation.d.ts.map +1 -0
- package/dist/session/hibernation.js +385 -0
- package/dist/session/init-phases.d.ts +87 -0
- package/dist/session/init-phases.d.ts.map +1 -0
- package/dist/session/init-phases.js +137 -0
- package/dist/session/init.d.ts +46 -0
- package/dist/session/init.d.ts.map +1 -0
- package/dist/session/init.js +3579 -0
- package/dist/session/keys.d.ts +56 -0
- package/dist/session/keys.d.ts.map +1 -0
- package/dist/session/keys.js +55 -0
- package/dist/session/nimbus-session.d.ts +434 -0
- package/dist/session/nimbus-session.d.ts.map +1 -0
- package/dist/session/nimbus-session.js +1084 -0
- package/dist/session/programmatic.d.ts +105 -0
- package/dist/session/programmatic.d.ts.map +1 -0
- package/dist/session/programmatic.js +326 -0
- package/dist/session/replica-routes.d.ts +68 -0
- package/dist/session/replica-routes.d.ts.map +1 -0
- package/dist/session/replica-routes.js +77 -0
- package/dist/session/routes.d.ts +29 -0
- package/dist/session/routes.d.ts.map +1 -0
- package/dist/session/routes.js +1331 -0
- package/dist/session/rpc.d.ts +323 -0
- package/dist/session/rpc.d.ts.map +1 -0
- package/dist/session/rpc.js +808 -0
- package/dist/session/state-store.d.ts +210 -0
- package/dist/session/state-store.d.ts.map +1 -0
- package/dist/session/state-store.js +459 -0
- package/dist/session/supervisor-rpc.d.ts +269 -0
- package/dist/session/supervisor-rpc.d.ts.map +1 -0
- package/dist/session/supervisor-rpc.js +437 -0
- package/dist/session/ws-hibernation-config.d.ts +64 -0
- package/dist/session/ws-hibernation-config.d.ts.map +1 -0
- package/dist/session/ws-hibernation-config.js +89 -0
- package/dist/session/ws.d.ts +95 -0
- package/dist/session/ws.d.ts.map +1 -0
- package/dist/session/ws.js +395 -0
- package/dist/shell/features.d.ts +410 -0
- package/dist/shell/features.d.ts.map +1 -0
- package/dist/shell/features.js +1885 -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 +3703 -0
- package/dist/stubs/lifo-ui.d.ts +10 -0
- package/dist/stubs/lifo-ui.d.ts.map +1 -0
- package/dist/stubs/lifo-ui.js +1 -0
- package/dist/tailwind-play.generated.d.ts +19 -0
- package/dist/tailwind-play.generated.d.ts.map +1 -0
- package/dist/tailwind-play.generated.js +18 -0
- package/dist/vfs/dev-provider.d.ts +64 -0
- package/dist/vfs/dev-provider.d.ts.map +1 -0
- package/dist/vfs/dev-provider.js +191 -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 +30 -0
- package/dist/vfs/path.d.ts.map +1 -0
- package/dist/vfs/path.js +41 -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 +1045 -0
- package/dist/vfs/sqlite-vfs.d.ts +435 -0
- package/dist/vfs/sqlite-vfs.d.ts.map +1 -0
- package/dist/vfs/sqlite-vfs.js +1670 -0
- package/dist/vfs/symlink-registry.d.ts +64 -0
- package/dist/vfs/symlink-registry.d.ts.map +1 -0
- package/dist/vfs/symlink-registry.js +137 -0
- package/dist/wrangler/nimbus-wrangler.d.ts +157 -0
- package/dist/wrangler/nimbus-wrangler.d.ts.map +1 -0
- package/dist/wrangler/nimbus-wrangler.js +931 -0
- package/package.json +77 -0
- package/public/_assets/cirrus-plugin-react.bundle.js +70740 -0
- package/public/_assets/esbuild-0.24.2.wasm +0 -0
- package/public/_assets/real-vite-bundle.js +101478 -0
- package/public/_assets/rollup.wasm +0 -0
- package/public/favicon.svg +8 -0
- package/public/index.html +565 -0
- package/public/s/index.html +2379 -0
- package/scripts/bundle-esbuild-wasm.mjs +244 -0
- package/scripts/bundle-facet-workers.mjs +137 -0
- package/scripts/bundle-git.mjs +118 -0
- package/scripts/bundle-npm-cjs.mjs +363 -0
- package/scripts/bundle-plugin-react.mjs +480 -0
- package/scripts/bundle-real-vite.mjs +959 -0
- package/scripts/bundle-runtime.mjs +600 -0
- package/scripts/bundle-tailwind-play.mjs +130 -0
- package/scripts/patch-lifo-ui.mjs +131 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* npx-install.ts — Nimbus-native npx implementation.
|
|
3
|
+
*
|
|
4
|
+
* Replaces @lifo-sh/core's createNpxCommand (which uses a too-narrow
|
|
5
|
+
* semver-range detector that misses major-only ranges like `'1'`, `'2'`,
|
|
6
|
+
* `'1.0'`). The core's `ic()` regex `/[\^~>=<|*x]/.test(r)` flagged
|
|
7
|
+
* caret/tilde/comparator/x ranges correctly but treated `'1'` as a
|
|
8
|
+
* literal version → fetched `/wrappy/1` → 404 → silently skipped.
|
|
9
|
+
*
|
|
10
|
+
* Symptom captured by tests/behavioral/install/transitive-dep-resolution.mjs:
|
|
11
|
+
* `npx --yes rimraf@3.0.2 --help` →
|
|
12
|
+
* warn: could not install wrappy: Package 'wrappy@1' not found in registry
|
|
13
|
+
* warn: could not install inherits: Package 'inherits@2' not found in registry
|
|
14
|
+
* Cannot find module './' (from /tmp/.npx-cache/node_modules/rimraf)
|
|
15
|
+
*
|
|
16
|
+
* Fix: route the npx install step through Nimbus's NpmInstaller, which
|
|
17
|
+
* uses always-fetch-packument + RESOLVE_VERSION-style version-pick path
|
|
18
|
+
* (resolve-one-facet.ts:264 + RESOLVE_VERSION). Handles all semver-range
|
|
19
|
+
* syntax including major-only and major.minor.
|
|
20
|
+
*
|
|
21
|
+
* Binary-lookup and execution stay closer to the @lifo-sh/core flow:
|
|
22
|
+
* 1. Check cwd/node_modules/.bin/<cmd>
|
|
23
|
+
* 2. Check /tmp/.npx-cache/node_modules/.bin/<cmd>
|
|
24
|
+
* 3. Check global registry (built-ins like vite, esbuild — handled by
|
|
25
|
+
* caller; this module is only invoked when registry resolution failed)
|
|
26
|
+
* 4. Install package via NpmInstaller into /tmp/.npx-cache
|
|
27
|
+
* 5. Locate <pkg>/package.json#bin → resolve absolute path
|
|
28
|
+
* 6. Invoke via Nimbus's `node` registry command (preserves PID
|
|
29
|
+
* tracking, log buffer, process table membership)
|
|
30
|
+
*/
|
|
31
|
+
import type { NpmInstaller } from './installer.js';
|
|
32
|
+
import type { SqliteVFS } from '../vfs/sqlite-vfs.js';
|
|
33
|
+
/** Path where npx caches packages it installs. Matches the constant
|
|
34
|
+
* in @lifo-sh/core (Vs in dist/index-Djm2onjx.js) so any other code
|
|
35
|
+
* reading this dir (e.g. tooling that introspects npx state) sees the
|
|
36
|
+
* same layout. */
|
|
37
|
+
export declare const NPX_CACHE_DIR = "/tmp/.npx-cache";
|
|
38
|
+
/**
|
|
39
|
+
* Result of a Nimbus-native npx invocation.
|
|
40
|
+
*
|
|
41
|
+
* ok=true: the binary was located AND about to be invoked. The
|
|
42
|
+
* caller dispatches via the `node` registry handler with
|
|
43
|
+
* { args: [binPath, ...binArgs] }.
|
|
44
|
+
* ok=false: bin not found OR install failed OR arg parse error.
|
|
45
|
+
* `error` is a human-readable message; caller prints to
|
|
46
|
+
* stderr and returns exit code.
|
|
47
|
+
*/
|
|
48
|
+
export interface NpxResolveResult {
|
|
49
|
+
ok: boolean;
|
|
50
|
+
binPath?: string;
|
|
51
|
+
binArgs?: string[];
|
|
52
|
+
error?: string;
|
|
53
|
+
/** Diagnostic: which path located the bin (project-nm / npx-cache /
|
|
54
|
+
* fresh-install). Useful in logs. */
|
|
55
|
+
source?: 'project-nm' | 'npx-cache' | 'fresh-install';
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Resolve a binary for `npx <args>` by:
|
|
59
|
+
* 1. Parsing args.
|
|
60
|
+
* 2. Checking node_modules/.bin/<binName> in cwd, then NPX cache.
|
|
61
|
+
* 3. If absent, installing the package via NpmInstaller into
|
|
62
|
+
* /tmp/.npx-cache, then re-checking.
|
|
63
|
+
*
|
|
64
|
+
* The caller is responsible for actually invoking the resulting binPath
|
|
65
|
+
* via Nimbus's `node` command — keeping this module pure (no process
|
|
66
|
+
* spawning) makes it testable.
|
|
67
|
+
*
|
|
68
|
+
* Note: deliberately does NOT honor `--version`/`--help` for npx
|
|
69
|
+
* itself (those are caller's job); they bubble up as `error` markers
|
|
70
|
+
* so the caller can format the usage banner consistently with the
|
|
71
|
+
* rest of the shell.
|
|
72
|
+
*/
|
|
73
|
+
export declare function resolveNpxBinary(installer: NpmInstaller, vfs: SqliteVFS, cwd: string, rawArgs: string[], log: (msg: string) => void): Promise<NpxResolveResult>;
|
|
74
|
+
//# sourceMappingURL=npx-install.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"npx-install.d.ts","sourceRoot":"","sources":["../../src/npm/npx-install.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEtD;;;mBAGmB;AACnB,eAAO,MAAM,aAAa,oBAAoB,CAAC;AAiN/C;;;;;;;;;GASG;AACH,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,OAAO,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;0CACsC;IACtC,MAAM,CAAC,EAAE,YAAY,GAAG,WAAW,GAAG,eAAe,CAAC;CACvD;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,gBAAgB,CACpC,SAAS,EAAE,YAAY,EACvB,GAAG,EAAE,SAAS,EACd,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,EAAE,EACjB,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,GACzB,OAAO,CAAC,gBAAgB,CAAC,CAgE3B"}
|
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* npx-install.ts — Nimbus-native npx implementation.
|
|
3
|
+
*
|
|
4
|
+
* Replaces @lifo-sh/core's createNpxCommand (which uses a too-narrow
|
|
5
|
+
* semver-range detector that misses major-only ranges like `'1'`, `'2'`,
|
|
6
|
+
* `'1.0'`). The core's `ic()` regex `/[\^~>=<|*x]/.test(r)` flagged
|
|
7
|
+
* caret/tilde/comparator/x ranges correctly but treated `'1'` as a
|
|
8
|
+
* literal version → fetched `/wrappy/1` → 404 → silently skipped.
|
|
9
|
+
*
|
|
10
|
+
* Symptom captured by tests/behavioral/install/transitive-dep-resolution.mjs:
|
|
11
|
+
* `npx --yes rimraf@3.0.2 --help` →
|
|
12
|
+
* warn: could not install wrappy: Package 'wrappy@1' not found in registry
|
|
13
|
+
* warn: could not install inherits: Package 'inherits@2' not found in registry
|
|
14
|
+
* Cannot find module './' (from /tmp/.npx-cache/node_modules/rimraf)
|
|
15
|
+
*
|
|
16
|
+
* Fix: route the npx install step through Nimbus's NpmInstaller, which
|
|
17
|
+
* uses always-fetch-packument + RESOLVE_VERSION-style version-pick path
|
|
18
|
+
* (resolve-one-facet.ts:264 + RESOLVE_VERSION). Handles all semver-range
|
|
19
|
+
* syntax including major-only and major.minor.
|
|
20
|
+
*
|
|
21
|
+
* Binary-lookup and execution stay closer to the @lifo-sh/core flow:
|
|
22
|
+
* 1. Check cwd/node_modules/.bin/<cmd>
|
|
23
|
+
* 2. Check /tmp/.npx-cache/node_modules/.bin/<cmd>
|
|
24
|
+
* 3. Check global registry (built-ins like vite, esbuild — handled by
|
|
25
|
+
* caller; this module is only invoked when registry resolution failed)
|
|
26
|
+
* 4. Install package via NpmInstaller into /tmp/.npx-cache
|
|
27
|
+
* 5. Locate <pkg>/package.json#bin → resolve absolute path
|
|
28
|
+
* 6. Invoke via Nimbus's `node` registry command (preserves PID
|
|
29
|
+
* tracking, log buffer, process table membership)
|
|
30
|
+
*/
|
|
31
|
+
/** Path where npx caches packages it installs. Matches the constant
|
|
32
|
+
* in @lifo-sh/core (Vs in dist/index-Djm2onjx.js) so any other code
|
|
33
|
+
* reading this dir (e.g. tooling that introspects npx state) sees the
|
|
34
|
+
* same layout. */
|
|
35
|
+
export const NPX_CACHE_DIR = '/tmp/.npx-cache';
|
|
36
|
+
const NPX_CACHE_NM = `${NPX_CACHE_DIR}/node_modules`;
|
|
37
|
+
/**
|
|
38
|
+
* SqliteVFS uses absolute paths WITHOUT a leading slash (e.g. it stores
|
|
39
|
+
* `tmp/.npx-cache/node_modules/foo/package.json`, not `/tmp/...`). The
|
|
40
|
+
* NpmInstaller's `install()` entry strips the leading slash from its
|
|
41
|
+
* `projectDir` arg, then propagates the slashless form into all
|
|
42
|
+
* downstream pkgDirs and inode keys. To check existence post-install,
|
|
43
|
+
* we MUST strip the same way; `vfs.exists('/...')` always returns false.
|
|
44
|
+
*
|
|
45
|
+
* Mirror of `_strip` in src/runtime/node-shims.ts:204.
|
|
46
|
+
*/
|
|
47
|
+
function _vfsKey(p) {
|
|
48
|
+
return p.replace(/^\/+/, '');
|
|
49
|
+
}
|
|
50
|
+
function parseNpxArgs(rawArgs) {
|
|
51
|
+
let pkgOverride = null;
|
|
52
|
+
const consumed = [];
|
|
53
|
+
let yes = false;
|
|
54
|
+
let i = 0;
|
|
55
|
+
while (i < rawArgs.length) {
|
|
56
|
+
const a = rawArgs[i];
|
|
57
|
+
if (a === '-y' || a === '--yes') {
|
|
58
|
+
yes = true;
|
|
59
|
+
i++;
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
if (a === '--package' && i + 1 < rawArgs.length) {
|
|
63
|
+
pkgOverride = rawArgs[i + 1];
|
|
64
|
+
i += 2;
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
if (a.startsWith('--package=')) {
|
|
68
|
+
pkgOverride = a.slice('--package='.length);
|
|
69
|
+
i++;
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
if (a === '--version' || a === '-v' || a === '--help' || a === '-h') {
|
|
73
|
+
// Pass-through to surface npx's own version/help. Caller (init.ts
|
|
74
|
+
// npx handler) is the one that prints these; this module returns
|
|
75
|
+
// an error so the caller can branch.
|
|
76
|
+
return { error: a };
|
|
77
|
+
}
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
const first = rawArgs[i];
|
|
81
|
+
if (!first)
|
|
82
|
+
return { error: 'missing-cmd' };
|
|
83
|
+
consumed.push(...rawArgs.slice(i + 1));
|
|
84
|
+
// If --package=<pkg>, the positional arg is the BIN name; the package
|
|
85
|
+
// installs `<pkg>` and we look for the binary `<first>`.
|
|
86
|
+
// Else, the positional arg is `<name>[@<version>]`; binary is the
|
|
87
|
+
// last path segment of `<name>`.
|
|
88
|
+
let pkgSpec;
|
|
89
|
+
let binName;
|
|
90
|
+
if (pkgOverride) {
|
|
91
|
+
pkgSpec = pkgOverride;
|
|
92
|
+
binName = first;
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
pkgSpec = first;
|
|
96
|
+
const namePart = splitSpec(first).name;
|
|
97
|
+
binName = namePart.split('/').pop() || namePart;
|
|
98
|
+
}
|
|
99
|
+
const { name: pkgName } = splitSpec(pkgSpec);
|
|
100
|
+
return { pkgSpec, pkgName, binName, binArgs: consumed, yes };
|
|
101
|
+
}
|
|
102
|
+
/** Split `name@version` (or scoped `@scope/name@version`) into parts. */
|
|
103
|
+
function splitSpec(spec) {
|
|
104
|
+
if (spec.startsWith('@')) {
|
|
105
|
+
const at = spec.indexOf('@', 1);
|
|
106
|
+
if (at === -1)
|
|
107
|
+
return { name: spec, version: null };
|
|
108
|
+
return { name: spec.slice(0, at), version: spec.slice(at + 1) };
|
|
109
|
+
}
|
|
110
|
+
const at = spec.indexOf('@');
|
|
111
|
+
if (at === -1)
|
|
112
|
+
return { name: spec, version: null };
|
|
113
|
+
return { name: spec.slice(0, at), version: spec.slice(at + 1) };
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Find the absolute path of a binary inside a package's directory.
|
|
117
|
+
*
|
|
118
|
+
* package.json#bin can be:
|
|
119
|
+
* - `string` → single bin named after the package itself
|
|
120
|
+
* - `Record<string, string>` → multiple bins
|
|
121
|
+
*
|
|
122
|
+
* Returns the resolved absolute path (rooted at packageDir) if a
|
|
123
|
+
* matching bin name is found, else null. Matches @lifo-sh/core's
|
|
124
|
+
* `Ht()` helper at dist/index-Djm2onjx.js:11707.
|
|
125
|
+
*/
|
|
126
|
+
function findBinInPackage(vfs, packageDir, binName) {
|
|
127
|
+
const pkgJsonPath = `${packageDir}/package.json`;
|
|
128
|
+
// SqliteVFS stores keys without leading slash. Check via the stripped
|
|
129
|
+
// key form to match the installer's write convention.
|
|
130
|
+
if (!vfs.exists(_vfsKey(pkgJsonPath)))
|
|
131
|
+
return null;
|
|
132
|
+
let pkgJson;
|
|
133
|
+
try {
|
|
134
|
+
pkgJson = JSON.parse(vfs.readFileString(_vfsKey(pkgJsonPath)));
|
|
135
|
+
}
|
|
136
|
+
catch {
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
const binField = pkgJson.bin;
|
|
140
|
+
if (!binField)
|
|
141
|
+
return null;
|
|
142
|
+
let resolved = null;
|
|
143
|
+
if (typeof binField === 'string') {
|
|
144
|
+
// Single-bin shorthand: bin name is package name's last segment.
|
|
145
|
+
const expected = String(pkgJson.name || '').split('/').pop();
|
|
146
|
+
if (expected === binName)
|
|
147
|
+
resolved = binField;
|
|
148
|
+
}
|
|
149
|
+
else if (typeof binField === 'object') {
|
|
150
|
+
const candidate = binField[binName];
|
|
151
|
+
if (typeof candidate === 'string') {
|
|
152
|
+
resolved = candidate;
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
// Fall back to the FIRST bin entry — matches @lifo-sh/core's
|
|
156
|
+
// `Object.values(i)[0]` behavior at dist/index-Djm2onjx.js:11710.
|
|
157
|
+
const first = Object.values(binField)[0];
|
|
158
|
+
if (typeof first === 'string')
|
|
159
|
+
resolved = first;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
if (!resolved)
|
|
163
|
+
return null;
|
|
164
|
+
// Strip leading "./" if present and join with packageDir. Return
|
|
165
|
+
// the absolute path (with leading slash) — the `node` registry
|
|
166
|
+
// command expects an absolute filesystem path as the first arg.
|
|
167
|
+
// The vfs.exists checks against _vfsKey internally.
|
|
168
|
+
const rel = resolved.startsWith('./') ? resolved.slice(2) : resolved;
|
|
169
|
+
return `${packageDir}/${rel}`;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Locate a binary by name across the standard search paths npx uses:
|
|
173
|
+
* 1. cwd/node_modules/.bin/<binName> (project-local install)
|
|
174
|
+
* 2. NPX_CACHE_NM/<pkgName>/... (npx-cache install)
|
|
175
|
+
*
|
|
176
|
+
* Returns the absolute path on hit, null on miss.
|
|
177
|
+
*/
|
|
178
|
+
function locateBinary(vfs, cwd, pkgName, binName) {
|
|
179
|
+
// 1. Project-local node_modules. The packageDir is cwd/node_modules/<pkgName>.
|
|
180
|
+
const projPkgDir = `${cwd}/node_modules/${pkgName}`;
|
|
181
|
+
const projHit = findBinInPackage(vfs, projPkgDir, binName);
|
|
182
|
+
if (projHit && vfs.exists(_vfsKey(projHit)))
|
|
183
|
+
return projHit;
|
|
184
|
+
// 2. NPX cache.
|
|
185
|
+
const npxPkgDir = `${NPX_CACHE_NM}/${pkgName}`;
|
|
186
|
+
const npxHit = findBinInPackage(vfs, npxPkgDir, binName);
|
|
187
|
+
if (npxHit && vfs.exists(_vfsKey(npxHit)))
|
|
188
|
+
return npxHit;
|
|
189
|
+
return null;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Ensure /tmp/.npx-cache/package.json exists with the requested spec
|
|
193
|
+
* in its dependencies. NpmInstaller reads package.json from projectDir
|
|
194
|
+
* to determine what to install; we synthesize one for the npx cache.
|
|
195
|
+
*
|
|
196
|
+
* Idempotent: if the file already exists and has the spec in deps,
|
|
197
|
+
* leaves it alone. Returns the deps object after the write (useful
|
|
198
|
+
* for the caller's log line).
|
|
199
|
+
*/
|
|
200
|
+
function ensureNpxCachePackageJson(vfs, pkgName, pkgRange) {
|
|
201
|
+
const pkgJsonPath = `${NPX_CACHE_DIR}/package.json`;
|
|
202
|
+
const pkgJsonKey = _vfsKey(pkgJsonPath);
|
|
203
|
+
let existing = { name: 'npx-cache', version: '0.0.0', dependencies: {} };
|
|
204
|
+
if (vfs.exists(pkgJsonKey)) {
|
|
205
|
+
try {
|
|
206
|
+
existing = JSON.parse(vfs.readFileString(pkgJsonKey));
|
|
207
|
+
if (!existing.dependencies)
|
|
208
|
+
existing.dependencies = {};
|
|
209
|
+
}
|
|
210
|
+
catch {
|
|
211
|
+
// Corrupted — overwrite with fresh content below.
|
|
212
|
+
existing = { name: 'npx-cache', version: '0.0.0', dependencies: {} };
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
else {
|
|
216
|
+
// Ensure the parent dir exists. SqliteVFS auto-creates parent
|
|
217
|
+
// dirs in writeFile, but mkdir defensively for symmetry with
|
|
218
|
+
// @lifo-sh/core's flow.
|
|
219
|
+
try {
|
|
220
|
+
vfs.mkdir(_vfsKey(NPX_CACHE_DIR), { recursive: true });
|
|
221
|
+
}
|
|
222
|
+
catch { /* dir exists */ }
|
|
223
|
+
}
|
|
224
|
+
existing.dependencies[pkgName] = pkgRange;
|
|
225
|
+
vfs.writeFile(pkgJsonKey, JSON.stringify(existing, null, 2) + '\n');
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Resolve a binary for `npx <args>` by:
|
|
229
|
+
* 1. Parsing args.
|
|
230
|
+
* 2. Checking node_modules/.bin/<binName> in cwd, then NPX cache.
|
|
231
|
+
* 3. If absent, installing the package via NpmInstaller into
|
|
232
|
+
* /tmp/.npx-cache, then re-checking.
|
|
233
|
+
*
|
|
234
|
+
* The caller is responsible for actually invoking the resulting binPath
|
|
235
|
+
* via Nimbus's `node` command — keeping this module pure (no process
|
|
236
|
+
* spawning) makes it testable.
|
|
237
|
+
*
|
|
238
|
+
* Note: deliberately does NOT honor `--version`/`--help` for npx
|
|
239
|
+
* itself (those are caller's job); they bubble up as `error` markers
|
|
240
|
+
* so the caller can format the usage banner consistently with the
|
|
241
|
+
* rest of the shell.
|
|
242
|
+
*/
|
|
243
|
+
export async function resolveNpxBinary(installer, vfs, cwd, rawArgs, log) {
|
|
244
|
+
const parsed = parseNpxArgs(rawArgs);
|
|
245
|
+
if ('error' in parsed) {
|
|
246
|
+
return { ok: false, error: parsed.error };
|
|
247
|
+
}
|
|
248
|
+
// 1. Check project + NPX cache for pre-installed bin.
|
|
249
|
+
const existing = locateBinary(vfs, cwd, parsed.pkgName, parsed.binName);
|
|
250
|
+
if (existing) {
|
|
251
|
+
return {
|
|
252
|
+
ok: true,
|
|
253
|
+
binPath: existing,
|
|
254
|
+
binArgs: parsed.binArgs,
|
|
255
|
+
source: cwd && existing.startsWith(cwd) ? 'project-nm' : 'npx-cache',
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
// 2. Not found anywhere — install into NPX cache via NpmInstaller.
|
|
259
|
+
// Use the package's `<pkgSpec>` directly; NpmInstaller parses the
|
|
260
|
+
// `<name>@<version>` form same as `npm install <pkgSpec>`.
|
|
261
|
+
log(` ${parsed.pkgSpec}...`);
|
|
262
|
+
const { name: instName, version: instVer } = splitSpec(parsed.pkgSpec);
|
|
263
|
+
const installSpec = instVer ? `${instName}@${instVer}` : instName;
|
|
264
|
+
// Synthesize npx-cache package.json so NpmInstaller has a project
|
|
265
|
+
// root. The deps map is the source of truth for the install set.
|
|
266
|
+
ensureNpxCachePackageJson(vfs, instName, instVer || 'latest');
|
|
267
|
+
try {
|
|
268
|
+
const result = await installer.install(NPX_CACHE_DIR, {
|
|
269
|
+
packages: [installSpec],
|
|
270
|
+
});
|
|
271
|
+
if ((result.failed?.length || 0) > 0) {
|
|
272
|
+
// Partial install — some package failed to resolve. The fix is
|
|
273
|
+
// designed to handle major-only ranges; a residual failure here
|
|
274
|
+
// means a genuinely missing package or an unrelated transitive
|
|
275
|
+
// gap. Surface it as the error.
|
|
276
|
+
return {
|
|
277
|
+
ok: false,
|
|
278
|
+
error: `npx: install partially failed: ${result.failed.join(', ')}`,
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
catch (e) {
|
|
283
|
+
return {
|
|
284
|
+
ok: false,
|
|
285
|
+
error: `npx: install failed: ${e?.message ?? String(e)}`,
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
// 3. Re-check NPX cache after install.
|
|
289
|
+
const installed = locateBinary(vfs, cwd, parsed.pkgName, parsed.binName);
|
|
290
|
+
if (installed) {
|
|
291
|
+
return {
|
|
292
|
+
ok: true,
|
|
293
|
+
binPath: installed,
|
|
294
|
+
binArgs: parsed.binArgs,
|
|
295
|
+
source: 'fresh-install',
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
return {
|
|
299
|
+
ok: false,
|
|
300
|
+
error: `npx: installed ${parsed.pkgSpec} but could not locate binary '${parsed.binName}' in ${NPX_CACHE_NM}/${parsed.pkgName}`,
|
|
301
|
+
};
|
|
302
|
+
}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* pre-bundle-facet.ts — NimbusLoaderPool entry for esbuild pre-bundling.
|
|
3
|
+
*
|
|
4
|
+
* Why this exists
|
|
5
|
+
* ───────────────
|
|
6
|
+
* Pre-bundling npm packages (the `Pre-bundling N modules…` step in
|
|
7
|
+
* src/npm-installer.ts:704) used to call `EsbuildService.build(...)`
|
|
8
|
+
* inside the supervisor DO isolate. Each `esbuild.build` allocates
|
|
9
|
+
* 30–80 MiB of WASM linear memory plus the input/output graph; against
|
|
10
|
+
* the 128 MB DO heap cap this OOM-killed the supervisor on installs
|
|
11
|
+
* touching large React libraries (motion, framer-motion, etc.). The
|
|
12
|
+
* symptom was a banner re-print after `npm install` succeeded —
|
|
13
|
+
* NimbusSession's constructor running again because workerd had killed
|
|
14
|
+
* the previous isolate.
|
|
15
|
+
*
|
|
16
|
+
* The fix is to dispatch each per-specifier `esbuild.build` to a
|
|
17
|
+
* NimbusLoaderPool isolate. Each facet has its own 128 MB budget and
|
|
18
|
+
* stable-slot reuse keeps the warm-up cost amortized across the 8
|
|
19
|
+
* concurrent specs of a typical install. Same pattern as
|
|
20
|
+
* src/npm-install-facet.ts (tarball extraction).
|
|
21
|
+
*
|
|
22
|
+
* File-slice strategy (zero per-read RPC)
|
|
23
|
+
* ──────────────────────────────────────
|
|
24
|
+
* esbuild's VFS plugin would naturally call back to the supervisor for
|
|
25
|
+
* every onLoad / onResolve hit. With workerd's ~5–20 ms RPC latency and
|
|
26
|
+
* 50–200 reads per bundle × 8 specs that's 4–32 seconds of pure RPC
|
|
27
|
+
* overhead per install — measurably worse than the current OOM-y path.
|
|
28
|
+
*
|
|
29
|
+
* Instead the supervisor walks the spec's transitive non-external
|
|
30
|
+
* dependency tree once (fast — direct VFS access) and ships the
|
|
31
|
+
* entire `{path → bytes}` slice as part of the spec. The facet's VFS
|
|
32
|
+
* plugin reads from this in-memory map. Zero RPC during bundling.
|
|
33
|
+
*
|
|
34
|
+
* Stability invariants
|
|
35
|
+
* ───────────────────
|
|
36
|
+
* cloudflare-parallel serializes the function via `fn.toString()`.
|
|
37
|
+
* - No `this` references (arrow / anonymous async).
|
|
38
|
+
* - No free variables other than preamble names + explicit args.
|
|
39
|
+
* - Module-level constants the function references must come from
|
|
40
|
+
* the preamble (src/parallel/pre-bundle-preamble.ts) — see
|
|
41
|
+
* `ESBUILD_PRELOAD_PREAMBLE`.
|
|
42
|
+
*
|
|
43
|
+
* The supervisor RPC surface (env.SUPERVISOR) is available for emergency
|
|
44
|
+
* fallbacks but the bundle path MUST NOT use it — slice-up-front is the
|
|
45
|
+
* contract.
|
|
46
|
+
*/
|
|
47
|
+
import type { SqliteVFS } from '../vfs/sqlite-vfs.js';
|
|
48
|
+
import type { ResolvedPackage } from './resolver.js';
|
|
49
|
+
import { BUNDLER_VERSION } from '../runtime/esbuild-service.js';
|
|
50
|
+
/**
|
|
51
|
+
* One file inside a facet spec's slice. `bytes` is a Uint8Array — esbuild's
|
|
52
|
+
* loader inferences (js/ts/css/binary) need raw bytes for binary entries
|
|
53
|
+
* and TextDecoder produces lossless text for source code.
|
|
54
|
+
*
|
|
55
|
+
* RPC serialisation: workerd transmits Uint8Array via structured-clone with
|
|
56
|
+
* zero-copy semantics across same-process isolates. Memory cost on the
|
|
57
|
+
* facet side equals the spec's slice size; cost on the supervisor side is
|
|
58
|
+
* the same (the slice was just built from VFS reads).
|
|
59
|
+
*/
|
|
60
|
+
export interface SlicedFile {
|
|
61
|
+
path: string;
|
|
62
|
+
bytes: Uint8Array;
|
|
63
|
+
isDir: false;
|
|
64
|
+
}
|
|
65
|
+
export interface SlicedDir {
|
|
66
|
+
path: string;
|
|
67
|
+
isDir: true;
|
|
68
|
+
}
|
|
69
|
+
export type SliceEntry = SlicedFile | SlicedDir;
|
|
70
|
+
/** What the supervisor sends per pre-bundle dispatch. */
|
|
71
|
+
export interface PrebundleSpec {
|
|
72
|
+
/** Bare specifier being bundled, e.g. "framer-motion" or "react/jsx-runtime". */
|
|
73
|
+
specifier: string;
|
|
74
|
+
/** VFS path of the entry point, e.g. "/home/user/app/node_modules/framer-motion/dist/es/index.mjs". */
|
|
75
|
+
entryPath: string;
|
|
76
|
+
/** External specifiers (from getSharedRuntimeExternals). */
|
|
77
|
+
externals: string[];
|
|
78
|
+
/**
|
|
79
|
+
* Slice: every file/dir the bundler may need for this spec. Computed
|
|
80
|
+
* supervisor-side via a transitive-dependency walk. Includes:
|
|
81
|
+
* - Every file under node_modules/<spec-pkg>/
|
|
82
|
+
* - Every file under node_modules/<dep>/ for each transitive dep
|
|
83
|
+
* NOT marked external by `externals`.
|
|
84
|
+
*/
|
|
85
|
+
slice: SliceEntry[];
|
|
86
|
+
/** Stamp written into pkg_esm_bundles.bundle_hash; matches BUNDLER_VERSION. */
|
|
87
|
+
bundlerVersion: string;
|
|
88
|
+
/** Optional esbuild `define` map. Used by the on-demand bundler path
|
|
89
|
+
* (vite-dev-server) to inject process.env.NODE_ENV, import.meta.env.*,
|
|
90
|
+
* global → globalThis, etc. The pre-bundle path leaves this undefined
|
|
91
|
+
* (browser-target build needs no define replacement). */
|
|
92
|
+
define?: Record<string, string>;
|
|
93
|
+
}
|
|
94
|
+
/** What the facet returns. */
|
|
95
|
+
export interface PrebundleResult {
|
|
96
|
+
specifier: string;
|
|
97
|
+
ok: boolean;
|
|
98
|
+
/** ESM bundle output as a UTF-8 string. Empty when ok=false. */
|
|
99
|
+
esmCode: string;
|
|
100
|
+
/** First esbuild error message; populated when ok=false. */
|
|
101
|
+
errorText?: string;
|
|
102
|
+
/** Wall-clock ms inside the facet (bundling only, excludes RPC roundtrip). */
|
|
103
|
+
elapsed: number;
|
|
104
|
+
/** Non-fatal warnings the supervisor should surface. */
|
|
105
|
+
warnings: string[];
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Walk node_modules to collect every file the pre-bundle of `specifier`
|
|
109
|
+
* may read. Runs in the supervisor (cheap — direct VFS access).
|
|
110
|
+
*
|
|
111
|
+
* Algorithm:
|
|
112
|
+
* 1. Compute the externals via getSharedRuntimeExternals(specifier).
|
|
113
|
+
* These are the bare specifiers esbuild will leave external; their
|
|
114
|
+
* files do NOT need to be in the slice.
|
|
115
|
+
* 2. Resolve the spec's package directory and add every file beneath
|
|
116
|
+
* it to the slice.
|
|
117
|
+
* 3. Read its package.json `dependencies` and recurse into each one
|
|
118
|
+
* that is NOT in the externals set. Deps that walked up are
|
|
119
|
+
* visited at most once (visited set).
|
|
120
|
+
*
|
|
121
|
+
* Lives here (alongside the facet function) so changes to the slice
|
|
122
|
+
* shape touch one file — the supervisor caller in npm-installer.ts is
|
|
123
|
+
* a thin orchestrator.
|
|
124
|
+
*/
|
|
125
|
+
export interface BuildSliceOptions {
|
|
126
|
+
/** Cap on total bytes shipped to the facet. 24 MiB leaves headroom under
|
|
127
|
+
* the 32 MiB workerd RPC cap. Returns `null` if the cap is exceeded so
|
|
128
|
+
* the caller can decide whether to bail or split (bf41d1c precedent).
|
|
129
|
+
*/
|
|
130
|
+
maxBytes?: number;
|
|
131
|
+
}
|
|
132
|
+
export declare function buildSliceForSpecifier(vfs: SqliteVFS, specifier: string, nmDir: string): {
|
|
133
|
+
slice: SliceEntry[];
|
|
134
|
+
totalBytes: number;
|
|
135
|
+
} | null;
|
|
136
|
+
export declare function buildSliceForSpecifierWithCap(vfs: SqliteVFS, specifier: string, nmDir: string, capBytes: number): {
|
|
137
|
+
slice: SliceEntry[];
|
|
138
|
+
totalBytes: number;
|
|
139
|
+
} | null;
|
|
140
|
+
/**
|
|
141
|
+
* Choose the externals list for a specifier, exported so the supervisor
|
|
142
|
+
* can compute the same value when building the spec without re-pulling
|
|
143
|
+
* the helper from esbuild-service.ts on the call site.
|
|
144
|
+
*/
|
|
145
|
+
export declare function externalsForSpecifier(specifier: string): string[];
|
|
146
|
+
/**
|
|
147
|
+
* Bundle one specifier in a facet isolate. Returns the ESM bundle output
|
|
148
|
+
* to the supervisor; bundle bytes flow through `pool.map`'s return value
|
|
149
|
+
* (no RPC writeBatch — pkg_esm_bundles is supervisor-side SQLite, not VFS).
|
|
150
|
+
*
|
|
151
|
+
* Memory plan (verified by /api/_diag/memory after the rollout):
|
|
152
|
+
* - Slice retained in facet memory: ~3–10 MiB per typical React lib.
|
|
153
|
+
* - esbuild WASM linear memory: ~30–80 MiB during build.
|
|
154
|
+
* - Output bundle: usually <2 MiB.
|
|
155
|
+
* - Peak in the facet: ~100 MiB worst case (well under 128 MB cap).
|
|
156
|
+
*
|
|
157
|
+
* The supervisor never holds more than the spec arg + result return at
|
|
158
|
+
* once, so its peak stays in the low tens of MiB during the entire
|
|
159
|
+
* pre-bundle phase.
|
|
160
|
+
*/
|
|
161
|
+
export declare const prebundleOne: (spec: PrebundleSpec, _env: {
|
|
162
|
+
SUPERVISOR: {
|
|
163
|
+
readFile(p: string): Promise<string | null>;
|
|
164
|
+
};
|
|
165
|
+
}) => Promise<PrebundleResult>;
|
|
166
|
+
export { BUNDLER_VERSION };
|
|
167
|
+
export type _ResolvedPackage = ResolvedPackage;
|
|
168
|
+
//# sourceMappingURL=pre-bundle-facet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pre-bundle-facet.d.ts","sourceRoot":"","sources":["../../src/npm/pre-bundle-facet.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAA6B,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAgB3F;;;;;;;;;GASG;AACH,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,UAAU,CAAC;IAClB,KAAK,EAAE,KAAK,CAAC;CACd;AACD,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,IAAI,CAAC;CACb;AACD,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG,SAAS,CAAC;AAEhD,yDAAyD;AACzD,MAAM,WAAW,aAAa;IAC5B,iFAAiF;IACjF,SAAS,EAAE,MAAM,CAAC;IAClB,uGAAuG;IACvG,SAAS,EAAE,MAAM,CAAC;IAClB,4DAA4D;IAC5D,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB;;;;;;OAMG;IACH,KAAK,EAAE,UAAU,EAAE,CAAC;IACpB,+EAA+E;IAC/E,cAAc,EAAE,MAAM,CAAC;IACvB;;;8DAG0D;IAC1D,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACjC;AAED,8BAA8B;AAC9B,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,EAAE,EAAE,OAAO,CAAC;IACZ,gEAAgE;IAChE,OAAO,EAAE,MAAM,CAAC;IAChB,4DAA4D;IAC5D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,8EAA8E;IAC9E,OAAO,EAAE,MAAM,CAAC;IAChB,wDAAwD;IACxD,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAID;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AACD,wBAAgB,sBAAsB,CACpC,GAAG,EAAE,SAAS,EACd,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,GACZ;IAAE,KAAK,EAAE,UAAU,EAAE,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAEpD;AAED,wBAAgB,6BAA6B,CAC3C,GAAG,EAAE,SAAS,EACd,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,GACf;IAAE,KAAK,EAAE,UAAU,EAAE,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CA4GpD;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,CAEjE;AAmBD;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,YAAY,GACvB,MAAM,aAAa,EACnB,MAAM;IACJ,UAAU,EAAE;QAAE,QAAQ,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAA;KAAE,CAAC;CAC7D,KACA,OAAO,CAAC,eAAe,CAgazB,CAAC;AAGF,OAAO,EAAE,eAAe,EAAE,CAAC;AAE3B,MAAM,MAAM,gBAAgB,GAAG,eAAe,CAAC"}
|