@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,284 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* exports-resolver.ts — Single source of truth for `package.json#exports` /
|
|
3
|
+
* `package.json#imports` resolution per the Node.js spec.
|
|
4
|
+
*
|
|
5
|
+
* Used in three contexts:
|
|
6
|
+
*
|
|
7
|
+
* 1. Install-time supervisor (TS) — `src/npm-resolver.ts` re-exports the
|
|
8
|
+
* typed functions for tree resolution.
|
|
9
|
+
*
|
|
10
|
+
* 2. NimbusLoaderPool isolates (JS string) — `src/parallel/pre-bundle-preamble.ts`
|
|
11
|
+
* embeds `getExportsResolverJS()` as part of the pool preamble so the
|
|
12
|
+
* pre-bundle facet uses identical resolution semantics to the supervisor.
|
|
13
|
+
*
|
|
14
|
+
* 3. User-shell `node` runtime (JS string) — `src/node-shims.ts` embeds
|
|
15
|
+
* the same JS source so `require()` from inside a user's `node` script
|
|
16
|
+
* sees the same exports map as the install pipeline.
|
|
17
|
+
*
|
|
18
|
+
* Audit reference: audit/sections/03-resolver-gaps.md §3.1, §3.2.
|
|
19
|
+
*
|
|
20
|
+
* Spec features supported:
|
|
21
|
+
* - String shorthand: "exports": "./dist/index.mjs"
|
|
22
|
+
* - Subpath maps: { ".": "...", "./client": "..." }
|
|
23
|
+
* - Conditional maps (top-level): { "import": "...", "require": "..." }
|
|
24
|
+
* - Nested conditions: { ".": { "node": { "default": "..." } } }
|
|
25
|
+
* - Subpath wildcards: { "./*": "./dist/*.js" }
|
|
26
|
+
* - Array fallbacks: [ "./esm.js", "./cjs.js" ]
|
|
27
|
+
* - `imports` field (`#name`): same shape, same impl (re-uses resolveExports)
|
|
28
|
+
* - Null-target enforcement: { "./private/*": null } — returns null, blocks fallback
|
|
29
|
+
*
|
|
30
|
+
* Caller-controlled `conditions` lets the same impl serve:
|
|
31
|
+
* - install/ESM/browser → ['import', 'module', 'browser', 'default']
|
|
32
|
+
* - runtime CJS → ['require', 'node', 'default']
|
|
33
|
+
*/
|
|
34
|
+
/** Default conditions for ESM/install/browser resolution. */
|
|
35
|
+
export const DEFAULT_ESM_CONDITIONS = ['import', 'module', 'browser', 'default'];
|
|
36
|
+
/** Default conditions for CJS runtime resolution (user-shell node). */
|
|
37
|
+
export const DEFAULT_CJS_CONDITIONS = ['require', 'node', 'default'];
|
|
38
|
+
/**
|
|
39
|
+
* Resolve `package.json#exports` (or `#imports`) per Node spec.
|
|
40
|
+
*
|
|
41
|
+
* @param exportsField Raw value from package.json#exports or #imports
|
|
42
|
+
* @param subpath '.' for root, './foo' for subpath, '#name' for imports
|
|
43
|
+
* @param conditions Active conditions, in priority order
|
|
44
|
+
* @returns Relative path target string, or null if not found / forbidden
|
|
45
|
+
*/
|
|
46
|
+
export function resolveExports(exportsField, subpath = '.', conditions = DEFAULT_ESM_CONDITIONS) {
|
|
47
|
+
if (exportsField === undefined || exportsField === null)
|
|
48
|
+
return null;
|
|
49
|
+
// String shorthand — only valid for root entry
|
|
50
|
+
if (typeof exportsField === 'string') {
|
|
51
|
+
return subpath === '.' ? exportsField : null;
|
|
52
|
+
}
|
|
53
|
+
// Array fallback — try each in order
|
|
54
|
+
if (Array.isArray(exportsField)) {
|
|
55
|
+
for (const item of exportsField) {
|
|
56
|
+
const r = resolveExports(item, subpath, conditions);
|
|
57
|
+
if (r)
|
|
58
|
+
return r;
|
|
59
|
+
}
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
if (typeof exportsField !== 'object')
|
|
63
|
+
return null;
|
|
64
|
+
const keys = Object.keys(exportsField);
|
|
65
|
+
if (keys.length === 0)
|
|
66
|
+
return null;
|
|
67
|
+
// Subpath-map detection: keys begin with "." (exports) or "#" (imports)
|
|
68
|
+
const isSubpathMap = keys[0].startsWith('.') || keys[0].startsWith('#');
|
|
69
|
+
if (isSubpathMap) {
|
|
70
|
+
// Exact match first
|
|
71
|
+
if (subpath in exportsField) {
|
|
72
|
+
const target = exportsField[subpath];
|
|
73
|
+
// Null target — forbidden subpath, returns null and BLOCKS fallback
|
|
74
|
+
if (target === null)
|
|
75
|
+
return null;
|
|
76
|
+
return resolveConditionValue(target, conditions);
|
|
77
|
+
}
|
|
78
|
+
// Wildcard pattern match — try most-specific (longest prefix) first
|
|
79
|
+
const wildcardKeys = keys
|
|
80
|
+
.filter(k => k.includes('*'))
|
|
81
|
+
.sort((a, b) => b.length - a.length); // longest pattern wins
|
|
82
|
+
for (const pattern of wildcardKeys) {
|
|
83
|
+
const target = exportsField[pattern];
|
|
84
|
+
const starIdx = pattern.indexOf('*');
|
|
85
|
+
const prefix = pattern.slice(0, starIdx);
|
|
86
|
+
const suffix = pattern.slice(starIdx + 1);
|
|
87
|
+
if (subpath.startsWith(prefix) &&
|
|
88
|
+
(suffix ? subpath.endsWith(suffix) : true) &&
|
|
89
|
+
subpath.length >= prefix.length + suffix.length) {
|
|
90
|
+
// Null target on wildcard — forbidden, BLOCK fallback
|
|
91
|
+
if (target === null)
|
|
92
|
+
return null;
|
|
93
|
+
const matched = subpath.slice(prefix.length, suffix ? subpath.length - suffix.length : undefined);
|
|
94
|
+
const resolved = resolveConditionValue(target, conditions);
|
|
95
|
+
if (resolved)
|
|
96
|
+
return resolved.split('*').join(matched);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
// Condition map (no subpath map keys) — only valid for root entry
|
|
102
|
+
if (subpath !== '.')
|
|
103
|
+
return null;
|
|
104
|
+
return resolveConditionValue(exportsField, conditions);
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Resolve a condition target. Recurses through nested condition objects
|
|
108
|
+
* and array fallbacks. Honours `default` even if not in the conditions
|
|
109
|
+
* array (Node spec).
|
|
110
|
+
*/
|
|
111
|
+
function resolveConditionValue(target, conditions) {
|
|
112
|
+
if (target === null || target === undefined)
|
|
113
|
+
return null;
|
|
114
|
+
if (typeof target === 'string')
|
|
115
|
+
return target;
|
|
116
|
+
if (Array.isArray(target)) {
|
|
117
|
+
for (const item of target) {
|
|
118
|
+
const r = resolveConditionValue(item, conditions);
|
|
119
|
+
if (r)
|
|
120
|
+
return r;
|
|
121
|
+
}
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
if (typeof target !== 'object')
|
|
125
|
+
return null;
|
|
126
|
+
// Try each requested condition in priority order
|
|
127
|
+
for (const cond of conditions) {
|
|
128
|
+
if (cond in target) {
|
|
129
|
+
const r = resolveConditionValue(target[cond], conditions);
|
|
130
|
+
if (r)
|
|
131
|
+
return r;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
// Spec: `default` is always a valid fallback
|
|
135
|
+
if (!conditions.includes('default') && 'default' in target) {
|
|
136
|
+
return resolveConditionValue(target.default, conditions);
|
|
137
|
+
}
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Resolve a package's entry-point file relative to its directory.
|
|
142
|
+
* Priority: exports → module → main → null.
|
|
143
|
+
* For non-root subpaths without an `exports` field, returns the subpath
|
|
144
|
+
* itself (caller probes filesystem with extension-list).
|
|
145
|
+
*/
|
|
146
|
+
export function resolvePackageEntry(pkg, subpath = '.', conditions = DEFAULT_ESM_CONDITIONS) {
|
|
147
|
+
// 1. exports field
|
|
148
|
+
if (pkg.exports !== undefined && pkg.exports !== null) {
|
|
149
|
+
const entry = resolveExports(pkg.exports, subpath, conditions);
|
|
150
|
+
if (entry)
|
|
151
|
+
return entry;
|
|
152
|
+
// If exports is defined but yields nothing for this subpath,
|
|
153
|
+
// Node spec is: this is an error (subpath isn't exposed).
|
|
154
|
+
// We return null to let caller decide (some callers fall back to
|
|
155
|
+
// direct filesystem probing for compatibility with packages that
|
|
156
|
+
// mis-declare exports).
|
|
157
|
+
}
|
|
158
|
+
// 2. Root entry: module → main
|
|
159
|
+
if (subpath === '.') {
|
|
160
|
+
if (pkg.module)
|
|
161
|
+
return pkg.module;
|
|
162
|
+
if (pkg.main)
|
|
163
|
+
return pkg.main;
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
166
|
+
// 3. Non-root subpath without exports — caller probes raw subpath
|
|
167
|
+
return subpath;
|
|
168
|
+
}
|
|
169
|
+
// ─── JS-source emission for embedding into facet preambles ───────────────
|
|
170
|
+
/**
|
|
171
|
+
* Returns the resolver source as plain JavaScript (no TypeScript syntax),
|
|
172
|
+
* suitable for embedding into a generated worker preamble or shim string.
|
|
173
|
+
*
|
|
174
|
+
* The emitted source declares three top-level functions in scope:
|
|
175
|
+
* - resolveExports(exports, subpath, conditions)
|
|
176
|
+
* - resolveConditionValue(target, conditions) (helper)
|
|
177
|
+
* - resolvePackageEntry(pkg, subpath, conditions)
|
|
178
|
+
*
|
|
179
|
+
* It also declares two arrays:
|
|
180
|
+
* - DEFAULT_ESM_CONDITIONS
|
|
181
|
+
* - DEFAULT_CJS_CONDITIONS
|
|
182
|
+
*
|
|
183
|
+
* This source must be byte-equivalent to the TS impl above (modulo type
|
|
184
|
+
* annotations and `export` keywords). Keep them in sync — there is one
|
|
185
|
+
* verification probe in audit/probes that compares parity.
|
|
186
|
+
*/
|
|
187
|
+
export function getExportsResolverJS() {
|
|
188
|
+
return `
|
|
189
|
+
// ── exports-resolver.js (auto-generated; keep in sync with src/_shared/exports-resolver.ts) ──
|
|
190
|
+
const DEFAULT_ESM_CONDITIONS = ['import', 'module', 'browser', 'default'];
|
|
191
|
+
const DEFAULT_CJS_CONDITIONS = ['require', 'node', 'default'];
|
|
192
|
+
|
|
193
|
+
function resolveExports(exportsField, subpath, conditions) {
|
|
194
|
+
if (subpath === undefined) subpath = '.';
|
|
195
|
+
if (!conditions) conditions = DEFAULT_ESM_CONDITIONS;
|
|
196
|
+
if (exportsField === undefined || exportsField === null) return null;
|
|
197
|
+
if (typeof exportsField === 'string') {
|
|
198
|
+
return subpath === '.' ? exportsField : null;
|
|
199
|
+
}
|
|
200
|
+
if (Array.isArray(exportsField)) {
|
|
201
|
+
for (const item of exportsField) {
|
|
202
|
+
const r = resolveExports(item, subpath, conditions);
|
|
203
|
+
if (r) return r;
|
|
204
|
+
}
|
|
205
|
+
return null;
|
|
206
|
+
}
|
|
207
|
+
if (typeof exportsField !== 'object') return null;
|
|
208
|
+
const keys = Object.keys(exportsField);
|
|
209
|
+
if (keys.length === 0) return null;
|
|
210
|
+
const isSubpathMap = keys[0].startsWith('.') || keys[0].startsWith('#');
|
|
211
|
+
if (isSubpathMap) {
|
|
212
|
+
if (subpath in exportsField) {
|
|
213
|
+
const target = exportsField[subpath];
|
|
214
|
+
if (target === null) return null;
|
|
215
|
+
return resolveConditionValue(target, conditions);
|
|
216
|
+
}
|
|
217
|
+
const wildcardKeys = keys
|
|
218
|
+
.filter(k => k.includes('*'))
|
|
219
|
+
.sort((a, b) => b.length - a.length);
|
|
220
|
+
for (const pattern of wildcardKeys) {
|
|
221
|
+
const target = exportsField[pattern];
|
|
222
|
+
const starIdx = pattern.indexOf('*');
|
|
223
|
+
const prefix = pattern.slice(0, starIdx);
|
|
224
|
+
const suffix = pattern.slice(starIdx + 1);
|
|
225
|
+
if (
|
|
226
|
+
subpath.startsWith(prefix) &&
|
|
227
|
+
(suffix ? subpath.endsWith(suffix) : true) &&
|
|
228
|
+
subpath.length >= prefix.length + suffix.length
|
|
229
|
+
) {
|
|
230
|
+
if (target === null) return null;
|
|
231
|
+
const matched = subpath.slice(
|
|
232
|
+
prefix.length,
|
|
233
|
+
suffix ? subpath.length - suffix.length : undefined,
|
|
234
|
+
);
|
|
235
|
+
const resolved = resolveConditionValue(target, conditions);
|
|
236
|
+
if (resolved) return resolved.split('*').join(matched);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
return null;
|
|
240
|
+
}
|
|
241
|
+
if (subpath !== '.') return null;
|
|
242
|
+
return resolveConditionValue(exportsField, conditions);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
function resolveConditionValue(target, conditions) {
|
|
246
|
+
if (target === null || target === undefined) return null;
|
|
247
|
+
if (typeof target === 'string') return target;
|
|
248
|
+
if (Array.isArray(target)) {
|
|
249
|
+
for (const item of target) {
|
|
250
|
+
const r = resolveConditionValue(item, conditions);
|
|
251
|
+
if (r) return r;
|
|
252
|
+
}
|
|
253
|
+
return null;
|
|
254
|
+
}
|
|
255
|
+
if (typeof target !== 'object') return null;
|
|
256
|
+
for (const cond of conditions) {
|
|
257
|
+
if (cond in target) {
|
|
258
|
+
const r = resolveConditionValue(target[cond], conditions);
|
|
259
|
+
if (r) return r;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
if (!conditions.includes('default') && 'default' in target) {
|
|
263
|
+
return resolveConditionValue(target.default, conditions);
|
|
264
|
+
}
|
|
265
|
+
return null;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
function resolvePackageEntry(pkg, subpath, conditions) {
|
|
269
|
+
if (subpath === undefined) subpath = '.';
|
|
270
|
+
if (!conditions) conditions = DEFAULT_ESM_CONDITIONS;
|
|
271
|
+
if (pkg.exports !== undefined && pkg.exports !== null) {
|
|
272
|
+
const entry = resolveExports(pkg.exports, subpath, conditions);
|
|
273
|
+
if (entry) return entry;
|
|
274
|
+
}
|
|
275
|
+
if (subpath === '.') {
|
|
276
|
+
if (pkg.module) return pkg.module;
|
|
277
|
+
if (pkg.main) return pkg.main;
|
|
278
|
+
return null;
|
|
279
|
+
}
|
|
280
|
+
return subpath;
|
|
281
|
+
}
|
|
282
|
+
// ── end exports-resolver.js ────────────────────────────────────────────
|
|
283
|
+
`;
|
|
284
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* _shared/install-phase.ts — single source of truth for the npm-install
|
|
3
|
+
* state-machine phase enum.
|
|
4
|
+
*
|
|
5
|
+
* History: CLN-1 (2026-05-11) — consolidated from two diverged copies.
|
|
6
|
+
* - `npm/installer.ts:93-95` was the progress-event variant. Included
|
|
7
|
+
* 'lock-check' (a real progress event emitted while parsing
|
|
8
|
+
* package-lock.json) but lacked 'idle'.
|
|
9
|
+
* - `observability/diag-counters.ts:33-35` was the counter-state variant.
|
|
10
|
+
* Included 'idle' (the resting state when no install is in flight)
|
|
11
|
+
* but lacked 'lock-check'. The diag-counter's `setInstallPhase()`
|
|
12
|
+
* was actually called with 'idle' (installer.ts:184,201) — passing
|
|
13
|
+
* a value not declared in installer.ts's local type. The type check
|
|
14
|
+
* fell through to diag-counters' type because installer.ts imports
|
|
15
|
+
* setInstallPhase from there; the local `InstallPhase` definition
|
|
16
|
+
* in installer.ts was only used by `InstallProgress.phase`.
|
|
17
|
+
*
|
|
18
|
+
* Going forward both consumers import from this module; any new phase
|
|
19
|
+
* value added here is automatically available everywhere.
|
|
20
|
+
*
|
|
21
|
+
* Phase semantics (chronological order for a single install run):
|
|
22
|
+
*
|
|
23
|
+
* idle resting state, no install in flight
|
|
24
|
+
* ↓
|
|
25
|
+
* lock-check parsing existing package-lock.json (if present)
|
|
26
|
+
* ↓
|
|
27
|
+
* resolve walking the dep tree, fetching packuments
|
|
28
|
+
* ↓
|
|
29
|
+
* hoist hoisting peer-deps + flattening node_modules
|
|
30
|
+
* ↓
|
|
31
|
+
* diff comparing target tree against current install state
|
|
32
|
+
* ↓
|
|
33
|
+
* fetch downloading missing tarballs
|
|
34
|
+
* ↓
|
|
35
|
+
* write extracting tarballs into the VFS
|
|
36
|
+
* ↓
|
|
37
|
+
* link-bins creating bin/ symlinks
|
|
38
|
+
* ↓
|
|
39
|
+
* bundle (post-install) pre-bundling for esbuild fast path
|
|
40
|
+
* ↓
|
|
41
|
+
* done install complete; about to return to 'idle'
|
|
42
|
+
*
|
|
43
|
+
* The phase strings are surfaced via /api/_diag/install-pipeline and
|
|
44
|
+
* displayed in the install-progress UI; treat them as a public API.
|
|
45
|
+
*/
|
|
46
|
+
export type InstallPhase = 'idle' | 'lock-check' | 'resolve' | 'hoist' | 'diff' | 'fetch' | 'write' | 'link-bins' | 'bundle' | 'done';
|
|
47
|
+
//# sourceMappingURL=install-phase.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"install-phase.d.ts","sourceRoot":"","sources":["../../src/_shared/install-phase.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,MAAM,MAAM,YAAY,GACpB,MAAM,GACN,YAAY,GACZ,SAAS,GACT,OAAO,GACP,MAAM,GACN,OAAO,GACP,OAAO,GACP,WAAW,GACX,QAAQ,GACR,MAAM,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* real-node-imports.ts — single source of truth for the static
|
|
3
|
+
* `import * as __real_X from 'node:X'` block that the generated facet
|
|
4
|
+
* code prepends so the SHIMS string can forward to workerd's real
|
|
5
|
+
* `node:*` builtins.
|
|
6
|
+
*
|
|
7
|
+
* Used by:
|
|
8
|
+
* - src/facet-manager.ts:generateFacetCode (NodeProcess template)
|
|
9
|
+
* - src/facet-manager.ts: LOADER.load fallback template
|
|
10
|
+
*
|
|
11
|
+
* Symmetry constraint (W3 plan §3): both templates MUST consume this
|
|
12
|
+
* helper to prevent drift. If you add a new `import * as __real_X`,
|
|
13
|
+
* also wire it into the matching shim block in node-shims.ts.
|
|
14
|
+
*
|
|
15
|
+
* Why this lives in _shared/ alongside exports-resolver.ts: same
|
|
16
|
+
* pattern — JS-string emitter consumed by the facet-code generators
|
|
17
|
+
* that can't `import` at runtime because the surrounding code is a
|
|
18
|
+
* raw string template.
|
|
19
|
+
*
|
|
20
|
+
* Workerd availability matrix (probe-verified 2026-05-04 at compat
|
|
21
|
+
* date 2026-04-01, flag `nodejs_compat`):
|
|
22
|
+
* - node:crypto — full Node 20 surface
|
|
23
|
+
* - node:tls — connect/TLSSocket/createSecureContext/...
|
|
24
|
+
* - node:async_hooks — AsyncLocalStorage + AsyncResource + createHook
|
|
25
|
+
* - node:fs/promises — full surface (BUT operates on real-host FS,
|
|
26
|
+
* not our VFS, so we shim VFS-backed instead
|
|
27
|
+
* of forwarding fs/promises)
|
|
28
|
+
* - node:diagnostics_channel — full surface incl. tracingChannel +
|
|
29
|
+
* Channel.runStores (fastify-critical)
|
|
30
|
+
* - node:repl — surface stub (start/REPLServer)
|
|
31
|
+
* - node:vm — surface stub: classes/constants present BUT
|
|
32
|
+
* every code-running method throws
|
|
33
|
+
* ERR_METHOD_NOT_IMPLEMENTED. Hybrid shim:
|
|
34
|
+
* forward surface, wrap eval methods with
|
|
35
|
+
* honest error.
|
|
36
|
+
*/
|
|
37
|
+
export declare function getRealNodeImportsCode(): string;
|
|
38
|
+
//# sourceMappingURL=real-node-imports.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"real-node-imports.d.ts","sourceRoot":"","sources":["../../src/_shared/real-node-imports.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,wBAAgB,sBAAsB,IAAI,MAAM,CAS/C"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* real-node-imports.ts — single source of truth for the static
|
|
3
|
+
* `import * as __real_X from 'node:X'` block that the generated facet
|
|
4
|
+
* code prepends so the SHIMS string can forward to workerd's real
|
|
5
|
+
* `node:*` builtins.
|
|
6
|
+
*
|
|
7
|
+
* Used by:
|
|
8
|
+
* - src/facet-manager.ts:generateFacetCode (NodeProcess template)
|
|
9
|
+
* - src/facet-manager.ts: LOADER.load fallback template
|
|
10
|
+
*
|
|
11
|
+
* Symmetry constraint (W3 plan §3): both templates MUST consume this
|
|
12
|
+
* helper to prevent drift. If you add a new `import * as __real_X`,
|
|
13
|
+
* also wire it into the matching shim block in node-shims.ts.
|
|
14
|
+
*
|
|
15
|
+
* Why this lives in _shared/ alongside exports-resolver.ts: same
|
|
16
|
+
* pattern — JS-string emitter consumed by the facet-code generators
|
|
17
|
+
* that can't `import` at runtime because the surrounding code is a
|
|
18
|
+
* raw string template.
|
|
19
|
+
*
|
|
20
|
+
* Workerd availability matrix (probe-verified 2026-05-04 at compat
|
|
21
|
+
* date 2026-04-01, flag `nodejs_compat`):
|
|
22
|
+
* - node:crypto — full Node 20 surface
|
|
23
|
+
* - node:tls — connect/TLSSocket/createSecureContext/...
|
|
24
|
+
* - node:async_hooks — AsyncLocalStorage + AsyncResource + createHook
|
|
25
|
+
* - node:fs/promises — full surface (BUT operates on real-host FS,
|
|
26
|
+
* not our VFS, so we shim VFS-backed instead
|
|
27
|
+
* of forwarding fs/promises)
|
|
28
|
+
* - node:diagnostics_channel — full surface incl. tracingChannel +
|
|
29
|
+
* Channel.runStores (fastify-critical)
|
|
30
|
+
* - node:repl — surface stub (start/REPLServer)
|
|
31
|
+
* - node:vm — surface stub: classes/constants present BUT
|
|
32
|
+
* every code-running method throws
|
|
33
|
+
* ERR_METHOD_NOT_IMPLEMENTED. Hybrid shim:
|
|
34
|
+
* forward surface, wrap eval methods with
|
|
35
|
+
* honest error.
|
|
36
|
+
*/
|
|
37
|
+
export function getRealNodeImportsCode() {
|
|
38
|
+
return `
|
|
39
|
+
import * as __real_crypto from 'node:crypto';
|
|
40
|
+
import * as __real_tls from 'node:tls';
|
|
41
|
+
import * as __real_async_hooks from 'node:async_hooks';
|
|
42
|
+
import * as __real_diagnostics_channel from 'node:diagnostics_channel';
|
|
43
|
+
import * as __real_repl from 'node:repl';
|
|
44
|
+
import * as __real_vm from 'node:vm';
|
|
45
|
+
`.trim();
|
|
46
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* retry.ts — small, dependency-free retry helper for flaky HTTP GETs.
|
|
3
|
+
*
|
|
4
|
+
* The npm path (resolver packument fetches + tarball fetches) talks to
|
|
5
|
+
* registry.npmjs.org via Cloudflare's edge. Either hop can produce a
|
|
6
|
+
* transient 5xx — we've seen HTTP 503 on a single tarball out of 456
|
|
7
|
+
* kill a whole install. npm's client retries 5xx by default; we didn't,
|
|
8
|
+
* until this file. Any single transient failure across hundreds of
|
|
9
|
+
* packages = whole install dead.
|
|
10
|
+
*
|
|
11
|
+
* Scope:
|
|
12
|
+
* - Retries on 5xx (500/502/503/504 especially) and network errors
|
|
13
|
+
* (fetch rejection, AbortError timeout, etc.).
|
|
14
|
+
* - Does NOT retry on 4xx (those are hard: 404 means the package or
|
|
15
|
+
* version genuinely doesn't exist; retrying is wrong and wastes time).
|
|
16
|
+
* - Budget: 3 retries with jittered exponential backoff (500/1500/4500 ms
|
|
17
|
+
* ±25% jitter). Worst-case added latency per package ≈ 6.5 s in the
|
|
18
|
+
* fully-degraded path. Tighter than npm's ~5×60s because dev iteration
|
|
19
|
+
* speed matters more than absolute resilience here.
|
|
20
|
+
*
|
|
21
|
+
* Intentionally NOT exported to the facet isolate: the facet serializes
|
|
22
|
+
* its task function via fn.toString() and can't cross a module boundary,
|
|
23
|
+
* so `src/npm-install-facet.ts` duplicates this retry loop inline inside
|
|
24
|
+
* `fetchAndStagePackage`. Keep the two in sync if behaviour changes.
|
|
25
|
+
*/
|
|
26
|
+
/** Default retry count AFTER the first attempt (3 = up to 4 total attempts). */
|
|
27
|
+
export declare const DEFAULT_RETRIES = 3;
|
|
28
|
+
/** Base backoff delays in ms. Index = retry attempt (0-indexed). */
|
|
29
|
+
export declare const BACKOFF_MS: readonly number[];
|
|
30
|
+
/** Jitter ±25% of the base delay, uniformly distributed. */
|
|
31
|
+
export declare function jittered(baseMs: number): number;
|
|
32
|
+
/** True if an HTTP status should trigger a retry. */
|
|
33
|
+
export declare function isRetriableStatus(status: number): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Signature of a fetch-compatible callable. Lets callers inject a proxy
|
|
36
|
+
* (e.g. the Nimbus supervisor-fetch RPC) without forcing global fetch.
|
|
37
|
+
*/
|
|
38
|
+
export type FetchCallable = (url: string, init?: RequestInit) => Promise<Response>;
|
|
39
|
+
export interface RetryableFetchOptions {
|
|
40
|
+
/**
|
|
41
|
+
* Retries AFTER the initial attempt. Default DEFAULT_RETRIES (3).
|
|
42
|
+
* 0 = behave as a plain fetch.
|
|
43
|
+
*/
|
|
44
|
+
retries?: number;
|
|
45
|
+
/**
|
|
46
|
+
* Fetch implementation. Defaults to globalThis.fetch. Pass a proxy
|
|
47
|
+
* fetch (e.g. env.SUPERVISOR-backed fetchFn) to route through it while
|
|
48
|
+
* keeping the retry semantics.
|
|
49
|
+
*/
|
|
50
|
+
fetchImpl?: FetchCallable;
|
|
51
|
+
/**
|
|
52
|
+
* Human-readable name for the resource (used only in log messages).
|
|
53
|
+
* Typically "<pkg>@<version>" for npm or the URL.
|
|
54
|
+
*/
|
|
55
|
+
name?: string;
|
|
56
|
+
/**
|
|
57
|
+
* Per-attempt timeout in ms. A fresh AbortController is used per attempt
|
|
58
|
+
* so a slow-to-fail upstream doesn't eat the whole retry budget on a
|
|
59
|
+
* single hang. Merges with any caller-provided `init.signal` (both are
|
|
60
|
+
* honored: whichever aborts first wins).
|
|
61
|
+
*
|
|
62
|
+
* Default: undefined (no timeout; caller is responsible for its own
|
|
63
|
+
* signal if it wants one).
|
|
64
|
+
*/
|
|
65
|
+
perAttemptTimeoutMs?: number;
|
|
66
|
+
/**
|
|
67
|
+
* Optional logger called on each retry decision. Signature:
|
|
68
|
+
* onRetry(attempt /* 1-indexed *\/, totalRetries, delayMs, reason)
|
|
69
|
+
*
|
|
70
|
+
* Caller uses this to surface visible progress ("retry 1/3 after 500ms
|
|
71
|
+
* (HTTP 503)") rather than have the whole install silently hang for
|
|
72
|
+
* several seconds.
|
|
73
|
+
*/
|
|
74
|
+
onRetry?: (attempt: number, totalRetries: number, delayMs: number, reason: string) => void;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* fetch() wrapper with 5xx + network-error retry and jittered backoff.
|
|
78
|
+
*
|
|
79
|
+
* On a 4xx response, returns the Response object as-is (caller decides
|
|
80
|
+
* whether that's an error). On a 5xx or network-level failure, retries
|
|
81
|
+
* up to `retries` times with BACKOFF_MS[attempt] ± 25% jitter.
|
|
82
|
+
*
|
|
83
|
+
* When retries are exhausted, either:
|
|
84
|
+
* - Returns the last (5xx) Response, so the caller can read .status for
|
|
85
|
+
* error reporting, OR
|
|
86
|
+
* - Re-throws the last network error (caller never sees a Response).
|
|
87
|
+
*
|
|
88
|
+
* Callers that previously did `if (!resp.ok) throw ...` retain that shape;
|
|
89
|
+
* the only change is that transient failures are recovered before the
|
|
90
|
+
* throw instead of killing the whole install on the first hiccup.
|
|
91
|
+
*/
|
|
92
|
+
export declare function retryableFetch(url: string, init?: RequestInit, opts?: RetryableFetchOptions): Promise<Response>;
|
|
93
|
+
//# sourceMappingURL=retry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../../src/_shared/retry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,gFAAgF;AAChF,eAAO,MAAM,eAAe,IAAI,CAAC;AAEjC,oEAAoE;AACpE,eAAO,MAAM,UAAU,EAAE,SAAS,MAAM,EAAsB,CAAC;AAE/D,4DAA4D;AAC5D,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAM/C;AAED,qDAAqD;AACrD,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAOzD;AAED;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;AAEnF,MAAM,WAAW,qBAAqB;IACpC;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;;;;;OAQG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B;;;;;;;OAOG;IACH,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;CAC5F;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,cAAc,CAClC,GAAG,EAAE,MAAM,EACX,IAAI,CAAC,EAAE,WAAW,EAClB,IAAI,CAAC,EAAE,qBAAqB,GAC3B,OAAO,CAAC,QAAQ,CAAC,CAyFnB"}
|