@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,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* esbuild-wasm-bytes.ts — supervisor-side fetcher for the esbuild-wasm
|
|
3
|
+
* binary. The bytes live in the static-assets layer (env.ASSETS); this
|
|
4
|
+
* module hands them to the caller as an ArrayBuffer when needed.
|
|
5
|
+
*
|
|
6
|
+
* Cache strategy
|
|
7
|
+
* ──────────────
|
|
8
|
+
* - NO module-scope cache (would pin 16 MiB in supervisor heap; the
|
|
9
|
+
* reason this module exists, see Phase 2 A'.5 below).
|
|
10
|
+
* - L2 colo cache via `caches.default` (cache-and-scrub W-D): the bytes
|
|
11
|
+
* are version-pinned by URL (`/_assets/esbuild-<ESBUILD_VERSION>.wasm`),
|
|
12
|
+
* so an `immutable` cache entry is correct. The Cache API holds its
|
|
13
|
+
* OWN reference outside the supervisor heap, so this does not
|
|
14
|
+
* re-introduce the residency that A'.5 removed.
|
|
15
|
+
*
|
|
16
|
+
* Why no module-scope cache (Phase 2 A'.5)
|
|
17
|
+
* ────────────────────────────────────────
|
|
18
|
+
* Pre-rebuild this module decoded a 16 MiB base64 string from
|
|
19
|
+
* src/esbuild-wasm-bundle.generated.ts into an ArrayBuffer and cached
|
|
20
|
+
* the result in module scope for the lifetime of the supervisor
|
|
21
|
+
* isolate. The cache contributed 16 MiB resident to the supervisor
|
|
22
|
+
* heap (`esbuildResidentBytes` in src/observability/heap-estimate.ts)
|
|
23
|
+
* AND the base64 string contributed ~21 MiB to the worker bundle
|
|
24
|
+
* baseline.
|
|
25
|
+
*
|
|
26
|
+
* The architecturally correct path is to keep the bytes in the static-
|
|
27
|
+
* assets layer (public/_assets/esbuild-<version>.wasm), fetch on
|
|
28
|
+
* demand, and let workerd's loader own the only long-lived copy
|
|
29
|
+
* (inside dynamic-worker isolates that need it). Cache API entries
|
|
30
|
+
* are stored OUTSIDE the supervisor heap (workerd manages them), so
|
|
31
|
+
* adding L2 wrap doesn't undo this.
|
|
32
|
+
*
|
|
33
|
+
* Each call to `fetchEsbuildWasmBytes(env)` now does:
|
|
34
|
+
* - one `caches.default.match()` — sub-millisecond on hit
|
|
35
|
+
* - on miss: one env.ASSETS.fetch() + one cache write-back
|
|
36
|
+
* - one Response.arrayBuffer() — 12 MiB ArrayBuffer in supervisor
|
|
37
|
+
* heap, briefly, then GC'd
|
|
38
|
+
*
|
|
39
|
+
* Failure model
|
|
40
|
+
* ─────────────
|
|
41
|
+
* Cache lookup failure (any throw) → fall through to ASSETS.
|
|
42
|
+
* ASSETS fetch returning non-200 → throw (deploy bug, surface loudly).
|
|
43
|
+
*/
|
|
44
|
+
/**
|
|
45
|
+
* Path inside env.ASSETS where the esbuild-wasm binary lives.
|
|
46
|
+
* Versioned so a future esbuild-wasm bump produces a different asset
|
|
47
|
+
* name and forces a fresh fetch (no stale-cache risk). The matching
|
|
48
|
+
* file is staged at public/_assets/esbuild-<version>.wasm by
|
|
49
|
+
* scripts/bundle-esbuild-wasm.mjs at predeploy time.
|
|
50
|
+
*/
|
|
51
|
+
export declare const ESBUILD_WASM_ASSET_PATH = "/_assets/esbuild-0.24.2.wasm";
|
|
52
|
+
/**
|
|
53
|
+
* The minimal env shape this module needs. Defined narrowly so the
|
|
54
|
+
* caller can pass any env with an ASSETS Fetcher binding without
|
|
55
|
+
* dragging in the full Workers env type.
|
|
56
|
+
*/
|
|
57
|
+
export interface EsbuildWasmFetchEnv {
|
|
58
|
+
ASSETS: {
|
|
59
|
+
fetch(req: Request): Promise<Response>;
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Synthetic L2 cache key for the esbuild-wasm asset. Versioned via
|
|
64
|
+
* ESBUILD_WASM_ASSET_PATH so each esbuild upgrade lands a fresh entry
|
|
65
|
+
* and old entries naturally evict on TTL.
|
|
66
|
+
*
|
|
67
|
+
* Exported so the test endpoint at /api/_test/cache/wasm/reset can
|
|
68
|
+
* purge the entry between probe runs (otherwise wrangler dev's
|
|
69
|
+
* persistent caches.default.state preserves the L2 hit across sessions
|
|
70
|
+
* and the cold path is unobservable).
|
|
71
|
+
*/
|
|
72
|
+
export declare const ESBUILD_WASM_L2_KEY = "https://nimbus-cache.invalid/_assets/esbuild-0.24.2.wasm";
|
|
73
|
+
/**
|
|
74
|
+
* Fetch the esbuild-wasm bytes from the static-assets layer.
|
|
75
|
+
*
|
|
76
|
+
* The supervisor briefly holds the 12 MiB ArrayBuffer between this
|
|
77
|
+
* call and the caller's hand-off to workerd's LOADER. After the
|
|
78
|
+
* caller's reference goes out of scope, GC reclaims it; supervisor
|
|
79
|
+
* residency drops back to zero.
|
|
80
|
+
*
|
|
81
|
+
* L2 (cache-and-scrub W-D): on hit, returns the bytes from
|
|
82
|
+
* `caches.default` (per-colo, sub-millisecond). On miss, falls through
|
|
83
|
+
* to env.ASSETS and write-back. Cache failures are silent — ASSETS is
|
|
84
|
+
* always the correct source of truth.
|
|
85
|
+
*/
|
|
86
|
+
export declare function fetchEsbuildWasmBytes(env: EsbuildWasmFetchEnv): Promise<ArrayBuffer>;
|
|
87
|
+
//# sourceMappingURL=esbuild-wasm-bytes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"esbuild-wasm-bytes.d.ts","sourceRoot":"","sources":["../../src/runtime/esbuild-wasm-bytes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AAIH;;;;;;GAMG;AACH,eAAO,MAAM,uBAAuB,iCAA6C,CAAC;AAElF;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE;QAAE,KAAK,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAA;KAAE,CAAC;CACpD;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,mBAAmB,6DAAyE,CAAC;AAE1G;;;;;;;;;;;;GAYG;AACH,wBAAsB,qBAAqB,CAAC,GAAG,EAAE,mBAAmB,GAAG,OAAO,CAAC,WAAW,CAAC,CAuD1F"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* esbuild-wasm-bytes.ts — supervisor-side fetcher for the esbuild-wasm
|
|
3
|
+
* binary. The bytes live in the static-assets layer (env.ASSETS); this
|
|
4
|
+
* module hands them to the caller as an ArrayBuffer when needed.
|
|
5
|
+
*
|
|
6
|
+
* Cache strategy
|
|
7
|
+
* ──────────────
|
|
8
|
+
* - NO module-scope cache (would pin 16 MiB in supervisor heap; the
|
|
9
|
+
* reason this module exists, see Phase 2 A'.5 below).
|
|
10
|
+
* - L2 colo cache via `caches.default` (cache-and-scrub W-D): the bytes
|
|
11
|
+
* are version-pinned by URL (`/_assets/esbuild-<ESBUILD_VERSION>.wasm`),
|
|
12
|
+
* so an `immutable` cache entry is correct. The Cache API holds its
|
|
13
|
+
* OWN reference outside the supervisor heap, so this does not
|
|
14
|
+
* re-introduce the residency that A'.5 removed.
|
|
15
|
+
*
|
|
16
|
+
* Why no module-scope cache (Phase 2 A'.5)
|
|
17
|
+
* ────────────────────────────────────────
|
|
18
|
+
* Pre-rebuild this module decoded a 16 MiB base64 string from
|
|
19
|
+
* src/esbuild-wasm-bundle.generated.ts into an ArrayBuffer and cached
|
|
20
|
+
* the result in module scope for the lifetime of the supervisor
|
|
21
|
+
* isolate. The cache contributed 16 MiB resident to the supervisor
|
|
22
|
+
* heap (`esbuildResidentBytes` in src/observability/heap-estimate.ts)
|
|
23
|
+
* AND the base64 string contributed ~21 MiB to the worker bundle
|
|
24
|
+
* baseline.
|
|
25
|
+
*
|
|
26
|
+
* The architecturally correct path is to keep the bytes in the static-
|
|
27
|
+
* assets layer (public/_assets/esbuild-<version>.wasm), fetch on
|
|
28
|
+
* demand, and let workerd's loader own the only long-lived copy
|
|
29
|
+
* (inside dynamic-worker isolates that need it). Cache API entries
|
|
30
|
+
* are stored OUTSIDE the supervisor heap (workerd manages them), so
|
|
31
|
+
* adding L2 wrap doesn't undo this.
|
|
32
|
+
*
|
|
33
|
+
* Each call to `fetchEsbuildWasmBytes(env)` now does:
|
|
34
|
+
* - one `caches.default.match()` — sub-millisecond on hit
|
|
35
|
+
* - on miss: one env.ASSETS.fetch() + one cache write-back
|
|
36
|
+
* - one Response.arrayBuffer() — 12 MiB ArrayBuffer in supervisor
|
|
37
|
+
* heap, briefly, then GC'd
|
|
38
|
+
*
|
|
39
|
+
* Failure model
|
|
40
|
+
* ─────────────
|
|
41
|
+
* Cache lookup failure (any throw) → fall through to ASSETS.
|
|
42
|
+
* ASSETS fetch returning non-200 → throw (deploy bug, surface loudly).
|
|
43
|
+
*/
|
|
44
|
+
import { ESBUILD_VERSION } from '../constants.js';
|
|
45
|
+
/**
|
|
46
|
+
* Path inside env.ASSETS where the esbuild-wasm binary lives.
|
|
47
|
+
* Versioned so a future esbuild-wasm bump produces a different asset
|
|
48
|
+
* name and forces a fresh fetch (no stale-cache risk). The matching
|
|
49
|
+
* file is staged at public/_assets/esbuild-<version>.wasm by
|
|
50
|
+
* scripts/bundle-esbuild-wasm.mjs at predeploy time.
|
|
51
|
+
*/
|
|
52
|
+
export const ESBUILD_WASM_ASSET_PATH = `/_assets/esbuild-${ESBUILD_VERSION}.wasm`;
|
|
53
|
+
/**
|
|
54
|
+
* Synthetic L2 cache key for the esbuild-wasm asset. Versioned via
|
|
55
|
+
* ESBUILD_WASM_ASSET_PATH so each esbuild upgrade lands a fresh entry
|
|
56
|
+
* and old entries naturally evict on TTL.
|
|
57
|
+
*
|
|
58
|
+
* Exported so the test endpoint at /api/_test/cache/wasm/reset can
|
|
59
|
+
* purge the entry between probe runs (otherwise wrangler dev's
|
|
60
|
+
* persistent caches.default.state preserves the L2 hit across sessions
|
|
61
|
+
* and the cold path is unobservable).
|
|
62
|
+
*/
|
|
63
|
+
export const ESBUILD_WASM_L2_KEY = `https://nimbus-cache.invalid/_assets/esbuild-${ESBUILD_VERSION}.wasm`;
|
|
64
|
+
/**
|
|
65
|
+
* Fetch the esbuild-wasm bytes from the static-assets layer.
|
|
66
|
+
*
|
|
67
|
+
* The supervisor briefly holds the 12 MiB ArrayBuffer between this
|
|
68
|
+
* call and the caller's hand-off to workerd's LOADER. After the
|
|
69
|
+
* caller's reference goes out of scope, GC reclaims it; supervisor
|
|
70
|
+
* residency drops back to zero.
|
|
71
|
+
*
|
|
72
|
+
* L2 (cache-and-scrub W-D): on hit, returns the bytes from
|
|
73
|
+
* `caches.default` (per-colo, sub-millisecond). On miss, falls through
|
|
74
|
+
* to env.ASSETS and write-back. Cache failures are silent — ASSETS is
|
|
75
|
+
* always the correct source of truth.
|
|
76
|
+
*/
|
|
77
|
+
export async function fetchEsbuildWasmBytes(env) {
|
|
78
|
+
// ── L2 fast path ────────────────────────────────────────────────
|
|
79
|
+
try {
|
|
80
|
+
const c = globalThis.caches;
|
|
81
|
+
if (c?.default) {
|
|
82
|
+
const hit = await c.default.match(new Request(ESBUILD_WASM_L2_KEY));
|
|
83
|
+
if (hit && hit.ok) {
|
|
84
|
+
return await hit.arrayBuffer();
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
catch { /* fall through to ASSETS */ }
|
|
89
|
+
// ── L4 path (env.ASSETS) ────────────────────────────────────────
|
|
90
|
+
const url = `https://nimbus-internal.invalid${ESBUILD_WASM_ASSET_PATH}`;
|
|
91
|
+
// Construct a synthetic request — env.ASSETS routes by pathname only;
|
|
92
|
+
// the host is ignored. Using `.invalid` per RFC-2606 makes it
|
|
93
|
+
// unambiguous that this URL is internal-binding-only.
|
|
94
|
+
const res = await env.ASSETS.fetch(new Request(url));
|
|
95
|
+
if (!res.ok) {
|
|
96
|
+
throw new Error(`esbuild-wasm asset fetch failed: ${res.status} ${res.statusText} ` +
|
|
97
|
+
`for ${ESBUILD_WASM_ASSET_PATH} — deploy is missing the wasm asset`);
|
|
98
|
+
}
|
|
99
|
+
// Read the bytes once (Response body is a one-shot stream). The
|
|
100
|
+
// caller needs the ArrayBuffer to hand to workerd's LOADER; we
|
|
101
|
+
// also use it to write through to L2.
|
|
102
|
+
const ab = await res.arrayBuffer();
|
|
103
|
+
// ── L2 write-back ──────────────────────────────────────────────
|
|
104
|
+
// Eternal immutable TTL: the URL is version-pinned so a new
|
|
105
|
+
// ESBUILD_VERSION lands a fresh cache entry; the old one naturally
|
|
106
|
+
// evicts on TTL. The cache layer holds its own copy (workerd
|
|
107
|
+
// structured-clones the body during put), so the supervisor's
|
|
108
|
+
// reference to `ab` is unaffected.
|
|
109
|
+
// Best-effort: a write failure does NOT block the caller.
|
|
110
|
+
try {
|
|
111
|
+
const c = globalThis.caches;
|
|
112
|
+
if (c?.default) {
|
|
113
|
+
// We pass a fresh Uint8Array view over the same buffer; the
|
|
114
|
+
// cache stores a copy at put time. Returning `ab` to the
|
|
115
|
+
// caller stays valid because Response constructor doesn't
|
|
116
|
+
// detach the buffer (only ReadableStream consumption would).
|
|
117
|
+
const writeBack = new Response(new Uint8Array(ab), {
|
|
118
|
+
headers: {
|
|
119
|
+
'Content-Type': 'application/wasm',
|
|
120
|
+
'Cache-Control': 'public, max-age=31536000, immutable',
|
|
121
|
+
},
|
|
122
|
+
});
|
|
123
|
+
// Awaited so subsequent reads strictly hit L2 (no
|
|
124
|
+
// double-fetch race). The wasm payload is 12 MiB; workerd
|
|
125
|
+
// structured-clones it into the cache, ~1-5 ms locally.
|
|
126
|
+
await c.default.put(new Request(ESBUILD_WASM_L2_KEY), writeBack);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
catch { /* silent */ }
|
|
130
|
+
return ab;
|
|
131
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* framework-detect.ts — single source of truth for "what kind of project
|
|
3
|
+
* is this?" Pure function — no I/O of its own. Takes a parsed
|
|
4
|
+
* package.json + a set of root-level filenames + (optional) per-file
|
|
5
|
+
* contents and returns a discriminated union.
|
|
6
|
+
*
|
|
7
|
+
* Resolution order (first match wins):
|
|
8
|
+
*
|
|
9
|
+
* 0. Wrangler-on-framework override:
|
|
10
|
+
* `wrangler.{toml,jsonc,json}` at root AND any framework dep present
|
|
11
|
+
* → framework: <fw>, devCommand: 'wrangler-dev'
|
|
12
|
+
* W10's wrangler-dev path loads the framework's CF adapter.
|
|
13
|
+
* MUST come first — Remix-on-CF and SK-on-CF projects have BOTH a
|
|
14
|
+
* framework dep AND a wrangler config; without this rule W10's
|
|
15
|
+
* path never sees them.
|
|
16
|
+
*
|
|
17
|
+
* 1. `next` in deps → 'next'
|
|
18
|
+
* 2. `astro` in deps → 'astro'
|
|
19
|
+
* 3. `nuxt` in deps → 'nuxt'
|
|
20
|
+
* 4. `@remix-run/dev` in deps AND vite.config* references @remix-run/dev
|
|
21
|
+
* → 'remix'
|
|
22
|
+
* 5. `@sveltejs/kit` in deps → 'sveltekit'
|
|
23
|
+
* 6. (rule moved to step 0)
|
|
24
|
+
* 7. `wrangler.{toml,jsonc,json}` alone → 'wrangler'
|
|
25
|
+
* 8. `vite` in deps → 'vite' (generic)
|
|
26
|
+
* 9. else → 'unknown'
|
|
27
|
+
*
|
|
28
|
+
* Bare `@remix-run/react` without `@remix-run/dev` falls through to step 7
|
|
29
|
+
* — it's a runtime dep alone, not a Remix v2 vite-plugin project.
|
|
30
|
+
*
|
|
31
|
+
* See audit/sections/W11-plan.md §4 for the full spec + rationale.
|
|
32
|
+
*/
|
|
33
|
+
export type Framework = 'next' | 'astro' | 'nuxt' | 'remix' | 'sveltekit' | 'vite' | 'wrangler' | 'unknown';
|
|
34
|
+
export type DevCommand = 'next-cli' | 'astro-cli' | 'nuxt-cli' | 'remix-cli' | 'sveltekit-vite' | 'vite-real' | 'wrangler-dev' | 'generic';
|
|
35
|
+
export interface DetectInput {
|
|
36
|
+
pkg: {
|
|
37
|
+
dependencies?: Record<string, string>;
|
|
38
|
+
devDependencies?: Record<string, string>;
|
|
39
|
+
scripts?: Record<string, string>;
|
|
40
|
+
};
|
|
41
|
+
/** Basenames at project root, e.g. {'package.json', 'svelte.config.js'} */
|
|
42
|
+
files: Set<string>;
|
|
43
|
+
/**
|
|
44
|
+
* Optional: file contents keyed by basename. Currently used for:
|
|
45
|
+
* - vite.config.{ts,js,mjs} — Remix gate (must reference @remix-run/dev)
|
|
46
|
+
* If undefined, the Remix gate falls back to dep-presence only with a
|
|
47
|
+
* lower confidence.
|
|
48
|
+
*/
|
|
49
|
+
fileContents?: Record<string, string>;
|
|
50
|
+
}
|
|
51
|
+
export interface DetectResult {
|
|
52
|
+
framework: Framework;
|
|
53
|
+
/** 0..1; ≥0.7 means "act on it without asking". */
|
|
54
|
+
confidence: number;
|
|
55
|
+
/** Human-readable reason, suitable for logging to the user terminal. */
|
|
56
|
+
reason: string;
|
|
57
|
+
/** What the supervisor should treat `npm run dev` as. */
|
|
58
|
+
devCommand: DevCommand;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Detect what framework "owns" this project for purposes of routing
|
|
62
|
+
* `npm run dev`/`npm run build`. Pure; deterministic; no I/O.
|
|
63
|
+
*/
|
|
64
|
+
export declare function detectFramework(input: DetectInput): DetectResult;
|
|
65
|
+
/**
|
|
66
|
+
* Companion helper: detection result is reportable as a one-line MOTD.
|
|
67
|
+
* Used by initSession to print a single boot line:
|
|
68
|
+
* [nimbus] detected framework: sveltekit (sveltekit-vite, conf=0.95)
|
|
69
|
+
*/
|
|
70
|
+
export declare function describeDetect(result: DetectResult): string;
|
|
71
|
+
//# sourceMappingURL=framework-detect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"framework-detect.d.ts","sourceRoot":"","sources":["../../src/runtime/framework-detect.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,MAAM,MAAM,SAAS,GACjB,MAAM,GACN,OAAO,GACP,MAAM,GACN,OAAO,GACP,WAAW,GACX,MAAM,GACN,UAAU,GACV,SAAS,CAAC;AAEd,MAAM,MAAM,UAAU,GAClB,UAAU,GACV,WAAW,GACX,UAAU,GACV,WAAW,GACX,gBAAgB,GAChB,WAAW,GACX,cAAc,GACd,SAAS,CAAC;AAEd,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE;QACH,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACtC,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACzC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KAClC,CAAC;IACF,2EAA2E;IAC3E,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACnB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACvC;AAED,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,SAAS,CAAC;IACrB,mDAAmD;IACnD,UAAU,EAAE,MAAM,CAAC;IACnB,wEAAwE;IACxE,MAAM,EAAE,MAAM,CAAC;IACf,yDAAyD;IACzD,UAAU,EAAE,UAAU,CAAC;CACxB;AA2BD;;;GAGG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,WAAW,GAAG,YAAY,CAsBhE;AAwGD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAK3D"}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* framework-detect.ts — single source of truth for "what kind of project
|
|
3
|
+
* is this?" Pure function — no I/O of its own. Takes a parsed
|
|
4
|
+
* package.json + a set of root-level filenames + (optional) per-file
|
|
5
|
+
* contents and returns a discriminated union.
|
|
6
|
+
*
|
|
7
|
+
* Resolution order (first match wins):
|
|
8
|
+
*
|
|
9
|
+
* 0. Wrangler-on-framework override:
|
|
10
|
+
* `wrangler.{toml,jsonc,json}` at root AND any framework dep present
|
|
11
|
+
* → framework: <fw>, devCommand: 'wrangler-dev'
|
|
12
|
+
* W10's wrangler-dev path loads the framework's CF adapter.
|
|
13
|
+
* MUST come first — Remix-on-CF and SK-on-CF projects have BOTH a
|
|
14
|
+
* framework dep AND a wrangler config; without this rule W10's
|
|
15
|
+
* path never sees them.
|
|
16
|
+
*
|
|
17
|
+
* 1. `next` in deps → 'next'
|
|
18
|
+
* 2. `astro` in deps → 'astro'
|
|
19
|
+
* 3. `nuxt` in deps → 'nuxt'
|
|
20
|
+
* 4. `@remix-run/dev` in deps AND vite.config* references @remix-run/dev
|
|
21
|
+
* → 'remix'
|
|
22
|
+
* 5. `@sveltejs/kit` in deps → 'sveltekit'
|
|
23
|
+
* 6. (rule moved to step 0)
|
|
24
|
+
* 7. `wrangler.{toml,jsonc,json}` alone → 'wrangler'
|
|
25
|
+
* 8. `vite` in deps → 'vite' (generic)
|
|
26
|
+
* 9. else → 'unknown'
|
|
27
|
+
*
|
|
28
|
+
* Bare `@remix-run/react` without `@remix-run/dev` falls through to step 7
|
|
29
|
+
* — it's a runtime dep alone, not a Remix v2 vite-plugin project.
|
|
30
|
+
*
|
|
31
|
+
* See audit/sections/W11-plan.md §4 for the full spec + rationale.
|
|
32
|
+
*/
|
|
33
|
+
const WRANGLER_CONFIG_FILES = ['wrangler.toml', 'wrangler.jsonc', 'wrangler.json'];
|
|
34
|
+
const VITE_CONFIG_FILES = ['vite.config.ts', 'vite.config.js', 'vite.config.mjs', 'vite.config.cjs'];
|
|
35
|
+
function hasDep(pkg, name) {
|
|
36
|
+
return (!!(pkg.dependencies && pkg.dependencies[name]) ||
|
|
37
|
+
!!(pkg.devDependencies && pkg.devDependencies[name]));
|
|
38
|
+
}
|
|
39
|
+
function hasAnyFile(files, candidates) {
|
|
40
|
+
for (const c of candidates) {
|
|
41
|
+
if (files.has(c))
|
|
42
|
+
return c;
|
|
43
|
+
}
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
function readViteConfig(input) {
|
|
47
|
+
if (!input.fileContents)
|
|
48
|
+
return null;
|
|
49
|
+
for (const c of VITE_CONFIG_FILES) {
|
|
50
|
+
if (input.fileContents[c])
|
|
51
|
+
return { name: c, contents: input.fileContents[c] };
|
|
52
|
+
}
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Detect what framework "owns" this project for purposes of routing
|
|
57
|
+
* `npm run dev`/`npm run build`. Pure; deterministic; no I/O.
|
|
58
|
+
*/
|
|
59
|
+
export function detectFramework(input) {
|
|
60
|
+
const { pkg, files } = input;
|
|
61
|
+
// ── Step 0: Wrangler-on-framework override ──────────────────────────
|
|
62
|
+
const wranglerCfg = hasAnyFile(files, WRANGLER_CONFIG_FILES);
|
|
63
|
+
if (wranglerCfg) {
|
|
64
|
+
// Determine the underlying framework first (informational).
|
|
65
|
+
const underlying = detectUnderlyingFramework(input);
|
|
66
|
+
if (underlying.framework !== 'unknown' && underlying.framework !== 'wrangler') {
|
|
67
|
+
return {
|
|
68
|
+
framework: underlying.framework,
|
|
69
|
+
confidence: 0.85,
|
|
70
|
+
reason: `wrangler config (${wranglerCfg}) AND ${underlying.reason} — routing through ` +
|
|
71
|
+
`wrangler-dev so the framework's Cloudflare adapter loads.`,
|
|
72
|
+
devCommand: 'wrangler-dev',
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
// ── Steps 1-5 + 7-9: underlying framework (or generic) ───────────────
|
|
77
|
+
return detectUnderlyingFramework(input);
|
|
78
|
+
}
|
|
79
|
+
function detectUnderlyingFramework(input) {
|
|
80
|
+
const { pkg, files } = input;
|
|
81
|
+
// Step 1: Next.js
|
|
82
|
+
if (hasDep(pkg, 'next')) {
|
|
83
|
+
return {
|
|
84
|
+
framework: 'next',
|
|
85
|
+
confidence: 0.95,
|
|
86
|
+
reason: "found 'next' in dependencies",
|
|
87
|
+
devCommand: 'next-cli',
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
// Step 2: Astro
|
|
91
|
+
if (hasDep(pkg, 'astro')) {
|
|
92
|
+
return {
|
|
93
|
+
framework: 'astro',
|
|
94
|
+
confidence: 0.95,
|
|
95
|
+
reason: "found 'astro' in dependencies",
|
|
96
|
+
devCommand: 'astro-cli',
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
// Step 3: Nuxt
|
|
100
|
+
if (hasDep(pkg, 'nuxt')) {
|
|
101
|
+
return {
|
|
102
|
+
framework: 'nuxt',
|
|
103
|
+
confidence: 0.95,
|
|
104
|
+
reason: "found 'nuxt' in dependencies",
|
|
105
|
+
devCommand: 'nuxt-cli',
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
// Step 4: Remix v2 (vite-plugin path).
|
|
109
|
+
// Gate: @remix-run/dev in deps AND vite.config* references @remix-run/dev.
|
|
110
|
+
if (hasDep(pkg, '@remix-run/dev')) {
|
|
111
|
+
const cfg = readViteConfig(input);
|
|
112
|
+
if (cfg && cfg.contents.includes('@remix-run/dev')) {
|
|
113
|
+
return {
|
|
114
|
+
framework: 'remix',
|
|
115
|
+
confidence: 0.95,
|
|
116
|
+
reason: `found '@remix-run/dev' in deps and ${cfg.name} imports it`,
|
|
117
|
+
devCommand: 'remix-cli',
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
// Lower-confidence fallback: dep present but no contents to verify.
|
|
121
|
+
if (!input.fileContents) {
|
|
122
|
+
return {
|
|
123
|
+
framework: 'remix',
|
|
124
|
+
confidence: 0.7,
|
|
125
|
+
reason: "found '@remix-run/dev' in deps (vite.config contents not inspected)",
|
|
126
|
+
devCommand: 'remix-cli',
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
// Contents inspected and the import is missing — fall through.
|
|
130
|
+
}
|
|
131
|
+
// Step 5: SvelteKit
|
|
132
|
+
if (hasDep(pkg, '@sveltejs/kit')) {
|
|
133
|
+
return {
|
|
134
|
+
framework: 'sveltekit',
|
|
135
|
+
confidence: 0.95,
|
|
136
|
+
reason: "found '@sveltejs/kit' in dependencies",
|
|
137
|
+
devCommand: 'sveltekit-vite',
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
// Step 7: standalone wrangler (no framework deps)
|
|
141
|
+
if (hasAnyFile(files, WRANGLER_CONFIG_FILES) || hasDep(input.pkg, 'wrangler')) {
|
|
142
|
+
return {
|
|
143
|
+
framework: 'wrangler',
|
|
144
|
+
confidence: 0.85,
|
|
145
|
+
reason: "wrangler config or dep present, no framework dep — routing to wrangler-dev",
|
|
146
|
+
devCommand: 'wrangler-dev',
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
// Step 8: generic Vite
|
|
150
|
+
if (hasDep(pkg, 'vite')) {
|
|
151
|
+
return {
|
|
152
|
+
framework: 'vite',
|
|
153
|
+
confidence: 0.7,
|
|
154
|
+
reason: "found 'vite' in dependencies (no specific framework)",
|
|
155
|
+
devCommand: 'vite-real',
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
// Step 9: unknown
|
|
159
|
+
const depCount = Object.keys(pkg.dependencies || {}).length +
|
|
160
|
+
Object.keys(pkg.devDependencies || {}).length;
|
|
161
|
+
return {
|
|
162
|
+
framework: 'unknown',
|
|
163
|
+
confidence: depCount === 0 ? 0.1 : 0.3,
|
|
164
|
+
reason: depCount === 0
|
|
165
|
+
? 'no dependencies declared'
|
|
166
|
+
: 'no recognized framework dep (next/astro/nuxt/remix/sveltekit/vite)',
|
|
167
|
+
devCommand: 'generic',
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Companion helper: detection result is reportable as a one-line MOTD.
|
|
172
|
+
* Used by initSession to print a single boot line:
|
|
173
|
+
* [nimbus] detected framework: sveltekit (sveltekit-vite, conf=0.95)
|
|
174
|
+
*/
|
|
175
|
+
export function describeDetect(result) {
|
|
176
|
+
return (`framework=${result.framework} dev=${result.devCommand} ` +
|
|
177
|
+
`confidence=${result.confidence.toFixed(2)} (${result.reason})`);
|
|
178
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* long-running-handle.ts — generic adapter (primitive #3 + #4).
|
|
3
|
+
*
|
|
4
|
+
* Goal: any long-running thing in a Nimbus session that *behaves* like
|
|
5
|
+
* an HTTP server should plug into the supervisor's port registry the
|
|
6
|
+
* same way, so:
|
|
7
|
+
*
|
|
8
|
+
* - `ps` shows it (via `processTable.spawn` + `setLongRunning`)
|
|
9
|
+
* - `/preview/?port=N` routes to it
|
|
10
|
+
* - `/preview/` routes to the default-target one
|
|
11
|
+
* - `vite stop` / `kill <pid>` tears it down
|
|
12
|
+
*
|
|
13
|
+
* Today, two "long-running things" exist in-process:
|
|
14
|
+
*
|
|
15
|
+
* 1. ViteDevServer (the built-in Cirrus shim)
|
|
16
|
+
* 2. CirrusReal (the experimental real-vite facet)
|
|
17
|
+
*
|
|
18
|
+
* Both already expose a `handleRequest(request, pathname)` method.
|
|
19
|
+
* `PortRegistry` expects facets exposing `handleHttpRequest(request)`
|
|
20
|
+
* (single-arg, full request, with the inner path baked into the URL).
|
|
21
|
+
*
|
|
22
|
+
* `makeLongRunningPortStub` adapts the (request, pathname) shape into
|
|
23
|
+
* the (request) shape, by stripping a configurable `basePath` prefix
|
|
24
|
+
* from `request.url.pathname` and forwarding the rest. It is the ONE
|
|
25
|
+
* hook every future long-running thing will use; we do not write a new
|
|
26
|
+
* adapter per framework.
|
|
27
|
+
*
|
|
28
|
+
* NOTE: this is a SUPERVISOR-LOCAL stub, NOT a `WorkerEntrypoint`
|
|
29
|
+
* RPC stub. The port-registry handler at `routeRequest` happily
|
|
30
|
+
* accepts any object exposing `handleHttpRequest`, including in-DO
|
|
31
|
+
* wrappers. That is by design — a long-running facet is NOT required
|
|
32
|
+
* to live in a separate isolate; the routing primitive is the same
|
|
33
|
+
* either way.
|
|
34
|
+
*/
|
|
35
|
+
/**
|
|
36
|
+
* The minimal shape any long-running HTTP-like thing in a Nimbus
|
|
37
|
+
* session must expose to be registered as a port handler. The first
|
|
38
|
+
* arg is the original Request (in case the handler wants headers /
|
|
39
|
+
* body / method); the second is the inner path with any base-prefix
|
|
40
|
+
* already stripped, plus the original querystring.
|
|
41
|
+
*/
|
|
42
|
+
export interface LongRunningHttpHandler {
|
|
43
|
+
handleRequest(request: Request, innerPath: string): Promise<Response>;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Build a port-registry-compatible stub that forwards into the given
|
|
47
|
+
* handler.
|
|
48
|
+
*
|
|
49
|
+
* The supervisor calls `stub.handleHttpRequest(request)` with a request
|
|
50
|
+
* whose URL pathname is the path relative to the port (`PortRegistry`
|
|
51
|
+
* already strips the `/port/<n>` prefix). We pass that pathname to the
|
|
52
|
+
* underlying handler unchanged.
|
|
53
|
+
*
|
|
54
|
+
* Concretely: `GET /port/3000/api/users?id=42`
|
|
55
|
+
* → port-registry rewrites url to `/api/users?id=42`
|
|
56
|
+
* → stub.handleHttpRequest(req) // req.url has /api/users?id=42
|
|
57
|
+
* → handler.handleRequest(req, "/api/users?id=42")
|
|
58
|
+
*/
|
|
59
|
+
export declare function makeLongRunningPortStub(handler: LongRunningHttpHandler): {
|
|
60
|
+
handleHttpRequest(request: Request): Promise<Response>;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Parse `--port N`, `--port=N`, `-p N`, `-p=N` from argv. Returns the
|
|
64
|
+
* parsed integer, or null. Last-wins (so `--port 3000 --port 4000` →
|
|
65
|
+
* 4000), matching POSIX convention.
|
|
66
|
+
*
|
|
67
|
+
* Out-of-range or non-numeric values are returned as null without
|
|
68
|
+
* throwing — callers fall back to the next source (env, config, default).
|
|
69
|
+
*/
|
|
70
|
+
export declare function parsePortFromArgv(argv: string[]): number | null;
|
|
71
|
+
/**
|
|
72
|
+
* Resolve a final port to bind to, given the various sources in
|
|
73
|
+
* priority order. Returns the first finite source.
|
|
74
|
+
*
|
|
75
|
+
* 1. argv flags (--port / -p)
|
|
76
|
+
* 2. env.PORT (post-shell-expansion; Markflow's `${PORT:-3000}` → 3000)
|
|
77
|
+
* 3. viteConfig.port (explicit `port: NNNN` in vite.config.ts)
|
|
78
|
+
* 4. fallback (caller-provided default, e.g. 5173 for vite, 3000 for express)
|
|
79
|
+
*/
|
|
80
|
+
export declare function resolveLongRunningPort(opts: {
|
|
81
|
+
argv?: string[];
|
|
82
|
+
env?: Record<string, any> | undefined;
|
|
83
|
+
configPort?: number | undefined;
|
|
84
|
+
fallback: number;
|
|
85
|
+
}): number;
|
|
86
|
+
/**
|
|
87
|
+
* Expand shell-style `${VAR}` and `${VAR:-default}` references in a
|
|
88
|
+
* single argv token, against the supplied env map.
|
|
89
|
+
*
|
|
90
|
+
* Nimbus's shell does not expand parameter substitution, so a
|
|
91
|
+
* package.json script line like
|
|
92
|
+
*
|
|
93
|
+
* "dev": "vite --host 0.0.0.0 --port ${PORT:-3000}"
|
|
94
|
+
*
|
|
95
|
+
* arrives at the vite handler as the literal token `${PORT:-3000}`.
|
|
96
|
+
* Without expansion, `--port ${PORT:-3000}` is parsed as a non-numeric
|
|
97
|
+
* port and discarded. With expansion (against `env.PORT` falling back
|
|
98
|
+
* to `3000`), the user gets the port they asked for.
|
|
99
|
+
*
|
|
100
|
+
* Supports the two forms commonly seen in `package.json` scripts:
|
|
101
|
+
*
|
|
102
|
+
* - ${VAR} → env[VAR] || ''
|
|
103
|
+
* - ${VAR:-default} → env[VAR] || default
|
|
104
|
+
* - ${VAR:-other_var} → recursive (one level), so the default may
|
|
105
|
+
* itself reference an env var
|
|
106
|
+
*
|
|
107
|
+
* Does NOT support: command substitution, arithmetic substitution,
|
|
108
|
+
* pattern operators (`${VAR##pat}` etc.), positional params, glob.
|
|
109
|
+
* That is intentional — full shell semantics belong in the shell, not
|
|
110
|
+
* the argv expander; this helper covers ~95% of dev-script usage.
|
|
111
|
+
*/
|
|
112
|
+
export declare function expandShellDefaults(token: string, env: Record<string, any> | undefined): string;
|
|
113
|
+
/**
|
|
114
|
+
* Apply `expandShellDefaults` to every argv token. Used at the top of
|
|
115
|
+
* a long-running handler before argv parsing so flag values are
|
|
116
|
+
* fully resolved.
|
|
117
|
+
*/
|
|
118
|
+
export declare function expandArgvShellDefaults(argv: ReadonlyArray<string>, env: Record<string, any> | undefined): string[];
|
|
119
|
+
/**
|
|
120
|
+
* Pick the default `/preview/` target when no `?port=N` is supplied
|
|
121
|
+
* AND no in-process `viteDevServer` is currently running. The strategy
|
|
122
|
+
* is "first PortRegistry entry, ordered by registration time" — so if
|
|
123
|
+
* a session has only one long-running thing (Markflow's vite on :3000),
|
|
124
|
+
* `/preview/` lands on it without the user supplying a port.
|
|
125
|
+
*
|
|
126
|
+
* Returns null if the registry is empty, in which case the caller
|
|
127
|
+
* surfaces the existing "no dev server running" placeholder.
|
|
128
|
+
*/
|
|
129
|
+
export declare function pickDefaultPreviewPort(ports: ReadonlyArray<{
|
|
130
|
+
port: number;
|
|
131
|
+
registeredAt: number;
|
|
132
|
+
}>): number | null;
|
|
133
|
+
//# sourceMappingURL=long-running-handle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"long-running-handle.d.ts","sourceRoot":"","sources":["../../src/runtime/long-running-handle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH;;;;;;GAMG;AACH,MAAM,WAAW,sBAAsB;IACrC,aAAa,CAAC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;CACvE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,sBAAsB;+BAElC,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC;EAM/D;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,IAAI,CAkB/D;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE;IAC3C,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,SAAS,CAAC;IACtC,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,QAAQ,EAAE,MAAM,CAAC;CAClB,GAAG,MAAM,CAYT;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,SAAS,GACnC,MAAM,CAiBR;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,aAAa,CAAC,MAAM,CAAC,EAC3B,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,SAAS,GACnC,MAAM,EAAE,CAEV;AAED;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,aAAa,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,CAAC,GAC3D,MAAM,GAAG,IAAI,CASf"}
|