@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,402 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* streams.ts — Node.js-compatible stream classes for Nimbus v2.0.
|
|
3
|
+
*
|
|
4
|
+
* These are generated as raw JS strings (like node-shims.ts) and
|
|
5
|
+
* embedded in the dynamic worker code. They implement the Node
|
|
6
|
+
* stream contract: Readable, Writable, Transform, Duplex, PassThrough,
|
|
7
|
+
* pipeline(), and finished().
|
|
8
|
+
*
|
|
9
|
+
* Backpressure: write() returns false when the internal buffer exceeds
|
|
10
|
+
* highWaterMark, and emits 'drain' when the buffer is flushed.
|
|
11
|
+
*/
|
|
12
|
+
export function generateStreamsCode() {
|
|
13
|
+
return `
|
|
14
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
15
|
+
// ── Node-compatible Streams (Nimbus v2.0) ───────────────────────────
|
|
16
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
17
|
+
|
|
18
|
+
const __streamMod = (() => {
|
|
19
|
+
const _enc = new TextEncoder();
|
|
20
|
+
const _dec = new TextDecoder();
|
|
21
|
+
|
|
22
|
+
// ── Readable ────────────────────────────────────────────────────────
|
|
23
|
+
class Readable extends __eventsMod {
|
|
24
|
+
constructor(opts) {
|
|
25
|
+
super();
|
|
26
|
+
this._readableState = {
|
|
27
|
+
buffer: [],
|
|
28
|
+
ended: false,
|
|
29
|
+
endEmitted: false,
|
|
30
|
+
flowing: null,
|
|
31
|
+
highWaterMark: opts?.highWaterMark ?? 16384,
|
|
32
|
+
encoding: opts?.encoding || null,
|
|
33
|
+
objectMode: opts?.objectMode ?? false,
|
|
34
|
+
destroyed: false,
|
|
35
|
+
readableLength: 0,
|
|
36
|
+
};
|
|
37
|
+
this.readable = true;
|
|
38
|
+
if (opts?.read) this._read = opts.read.bind(this);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
_read(size) { /* override in subclass */ }
|
|
42
|
+
|
|
43
|
+
read(size) {
|
|
44
|
+
const state = this._readableState;
|
|
45
|
+
if (state.buffer.length === 0) {
|
|
46
|
+
if (state.ended) return null;
|
|
47
|
+
this._read(size || state.highWaterMark);
|
|
48
|
+
return state.buffer.length > 0 ? state.buffer.shift() : null;
|
|
49
|
+
}
|
|
50
|
+
const chunk = state.buffer.shift();
|
|
51
|
+
state.readableLength -= (chunk?.length || 0);
|
|
52
|
+
if (state.buffer.length === 0 && state.ended && !state.endEmitted) {
|
|
53
|
+
state.endEmitted = true;
|
|
54
|
+
queueMicrotask(() => this.emit('end'));
|
|
55
|
+
}
|
|
56
|
+
return chunk;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
push(chunk, encoding) {
|
|
60
|
+
const state = this._readableState;
|
|
61
|
+
if (chunk === null) {
|
|
62
|
+
state.ended = true;
|
|
63
|
+
if (state.buffer.length === 0 && !state.endEmitted) {
|
|
64
|
+
state.endEmitted = true;
|
|
65
|
+
queueMicrotask(() => this.emit('end'));
|
|
66
|
+
}
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
if (typeof chunk === 'string' && !state.objectMode) {
|
|
70
|
+
chunk = _enc.encode(chunk);
|
|
71
|
+
}
|
|
72
|
+
state.buffer.push(chunk);
|
|
73
|
+
state.readableLength += (chunk?.length || 0);
|
|
74
|
+
if (state.flowing) {
|
|
75
|
+
queueMicrotask(() => {
|
|
76
|
+
while (state.buffer.length > 0 && state.flowing) {
|
|
77
|
+
const c = state.buffer.shift();
|
|
78
|
+
state.readableLength -= (c?.length || 0);
|
|
79
|
+
this.emit('data', c);
|
|
80
|
+
}
|
|
81
|
+
// After draining, fire 'end' if push(null) was queued but
|
|
82
|
+
// deferred because the buffer was non-empty at the time.
|
|
83
|
+
// Guarded by endEmitted so a concurrent .read() drain doesn't
|
|
84
|
+
// double-fire (W8 fix: real Node uses an endEmitted flag).
|
|
85
|
+
if (state.ended && state.buffer.length === 0 && !state.endEmitted) {
|
|
86
|
+
state.endEmitted = true;
|
|
87
|
+
this.emit('end');
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
return state.readableLength < state.highWaterMark;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
pipe(dest, opts) {
|
|
95
|
+
this.on('data', (chunk) => {
|
|
96
|
+
const canContinue = dest.write(chunk);
|
|
97
|
+
if (!canContinue) {
|
|
98
|
+
this.pause();
|
|
99
|
+
dest.once('drain', () => this.resume());
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
this.on('end', () => {
|
|
103
|
+
if (opts?.end !== false) dest.end();
|
|
104
|
+
});
|
|
105
|
+
this.resume();
|
|
106
|
+
return dest;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
unpipe(dest) {
|
|
110
|
+
this.removeAllListeners('data');
|
|
111
|
+
return this;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
resume() {
|
|
115
|
+
const state = this._readableState;
|
|
116
|
+
if (!state.flowing) {
|
|
117
|
+
state.flowing = true;
|
|
118
|
+
queueMicrotask(() => {
|
|
119
|
+
while (state.buffer.length > 0 && state.flowing) {
|
|
120
|
+
const chunk = state.buffer.shift();
|
|
121
|
+
state.readableLength -= (chunk?.length || 0);
|
|
122
|
+
this.emit('data', chunk);
|
|
123
|
+
}
|
|
124
|
+
if (state.ended && state.buffer.length === 0 && !state.endEmitted) {
|
|
125
|
+
state.endEmitted = true;
|
|
126
|
+
this.emit('end');
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
return this;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
pause() {
|
|
134
|
+
this._readableState.flowing = false;
|
|
135
|
+
return this;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
setEncoding(enc) {
|
|
139
|
+
this._readableState.encoding = enc;
|
|
140
|
+
return this;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
destroy(err) {
|
|
144
|
+
if (this._readableState.destroyed) return this;
|
|
145
|
+
this._readableState.destroyed = true;
|
|
146
|
+
if (err) this.emit('error', err);
|
|
147
|
+
this.emit('close');
|
|
148
|
+
return this;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
get readableEnded() { return this._readableState.ended; }
|
|
152
|
+
get readableLength() { return this._readableState.readableLength; }
|
|
153
|
+
get readableFlowing() { return this._readableState.flowing; }
|
|
154
|
+
|
|
155
|
+
[Symbol.asyncIterator]() {
|
|
156
|
+
const self = this;
|
|
157
|
+
return {
|
|
158
|
+
next() {
|
|
159
|
+
return new Promise((resolve) => {
|
|
160
|
+
const chunk = self.read();
|
|
161
|
+
if (chunk !== null) return resolve({ value: chunk, done: false });
|
|
162
|
+
if (self._readableState.ended) return resolve({ value: undefined, done: true });
|
|
163
|
+
const onData = (c) => { self.off('end', onEnd); resolve({ value: c, done: false }); };
|
|
164
|
+
const onEnd = () => { self.off('data', onData); resolve({ value: undefined, done: true }); };
|
|
165
|
+
self.once('data', onData);
|
|
166
|
+
self.once('end', onEnd);
|
|
167
|
+
});
|
|
168
|
+
},
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// ── Writable ────────────────────────────────────────────────────────
|
|
174
|
+
class Writable extends __eventsMod {
|
|
175
|
+
constructor(opts) {
|
|
176
|
+
super();
|
|
177
|
+
this._writableState = {
|
|
178
|
+
buffer: [],
|
|
179
|
+
ended: false,
|
|
180
|
+
finished: false,
|
|
181
|
+
highWaterMark: opts?.highWaterMark ?? 16384,
|
|
182
|
+
needDrain: false,
|
|
183
|
+
destroyed: false,
|
|
184
|
+
corked: 0,
|
|
185
|
+
bufferedLength: 0,
|
|
186
|
+
};
|
|
187
|
+
this.writable = true;
|
|
188
|
+
if (opts?.write) this._write = opts.write.bind(this);
|
|
189
|
+
if (opts?.final) this._final = opts.final.bind(this);
|
|
190
|
+
if (opts?.destroy) this._destroy = opts.destroy.bind(this);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
_write(chunk, encoding, callback) { callback(); }
|
|
194
|
+
_final(callback) { callback(); }
|
|
195
|
+
|
|
196
|
+
write(chunk, encoding, callback) {
|
|
197
|
+
if (typeof encoding === 'function') { callback = encoding; encoding = undefined; }
|
|
198
|
+
const state = this._writableState;
|
|
199
|
+
if (state.ended) {
|
|
200
|
+
const err = new Error('write after end');
|
|
201
|
+
if (callback) callback(err);
|
|
202
|
+
this.emit('error', err);
|
|
203
|
+
return false;
|
|
204
|
+
}
|
|
205
|
+
if (typeof chunk === 'string') chunk = _enc.encode(chunk);
|
|
206
|
+
|
|
207
|
+
if (state.corked > 0) {
|
|
208
|
+
state.buffer.push({ chunk, callback });
|
|
209
|
+
state.bufferedLength += (chunk?.length || 0);
|
|
210
|
+
return state.bufferedLength < state.highWaterMark;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
state.bufferedLength += (chunk?.length || 0);
|
|
214
|
+
this._write(chunk, encoding, (err) => {
|
|
215
|
+
state.bufferedLength -= (chunk?.length || 0);
|
|
216
|
+
if (err) { if (callback) callback(err); this.emit('error', err); return; }
|
|
217
|
+
if (callback) callback();
|
|
218
|
+
if (state.needDrain && state.bufferedLength < state.highWaterMark) {
|
|
219
|
+
state.needDrain = false;
|
|
220
|
+
this.emit('drain');
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
if (state.bufferedLength >= state.highWaterMark) {
|
|
225
|
+
state.needDrain = true;
|
|
226
|
+
return false;
|
|
227
|
+
}
|
|
228
|
+
return true;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
end(chunk, encoding, callback) {
|
|
232
|
+
if (typeof chunk === 'function') { callback = chunk; chunk = undefined; }
|
|
233
|
+
if (typeof encoding === 'function') { callback = encoding; encoding = undefined; }
|
|
234
|
+
const state = this._writableState;
|
|
235
|
+
if (chunk !== undefined && chunk !== null) this.write(chunk, encoding);
|
|
236
|
+
state.ended = true;
|
|
237
|
+
this._final((err) => {
|
|
238
|
+
state.finished = true;
|
|
239
|
+
if (err) this.emit('error', err);
|
|
240
|
+
this.emit('finish');
|
|
241
|
+
if (callback) callback(err);
|
|
242
|
+
});
|
|
243
|
+
return this;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
cork() { this._writableState.corked++; }
|
|
247
|
+
|
|
248
|
+
uncork() {
|
|
249
|
+
const state = this._writableState;
|
|
250
|
+
if (state.corked > 0) state.corked--;
|
|
251
|
+
if (state.corked === 0 && state.buffer.length > 0) {
|
|
252
|
+
const buf = [...state.buffer];
|
|
253
|
+
state.buffer = [];
|
|
254
|
+
for (const { chunk, callback } of buf) {
|
|
255
|
+
this._write(chunk, undefined, (err) => {
|
|
256
|
+
state.bufferedLength -= (chunk?.length || 0);
|
|
257
|
+
if (callback) callback(err);
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
destroy(err) {
|
|
264
|
+
if (this._writableState.destroyed) return this;
|
|
265
|
+
this._writableState.destroyed = true;
|
|
266
|
+
if (err) this.emit('error', err);
|
|
267
|
+
this.emit('close');
|
|
268
|
+
return this;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
get writableEnded() { return this._writableState.ended; }
|
|
272
|
+
get writableFinished() { return this._writableState.finished; }
|
|
273
|
+
get writableLength() { return this._writableState.bufferedLength; }
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
// ── Duplex ──────────────────────────────────────────────────────────
|
|
277
|
+
class Duplex extends Readable {
|
|
278
|
+
constructor(opts) {
|
|
279
|
+
super(opts);
|
|
280
|
+
// Mixin Writable state
|
|
281
|
+
this._writableState = {
|
|
282
|
+
buffer: [],
|
|
283
|
+
ended: false,
|
|
284
|
+
finished: false,
|
|
285
|
+
highWaterMark: opts?.writableHighWaterMark ?? opts?.highWaterMark ?? 16384,
|
|
286
|
+
needDrain: false,
|
|
287
|
+
destroyed: false,
|
|
288
|
+
corked: 0,
|
|
289
|
+
bufferedLength: 0,
|
|
290
|
+
};
|
|
291
|
+
this.writable = true;
|
|
292
|
+
if (opts?.write) this._write = opts.write.bind(this);
|
|
293
|
+
if (opts?.final) this._final = opts.final.bind(this);
|
|
294
|
+
}
|
|
295
|
+
_write(chunk, encoding, callback) { callback(); }
|
|
296
|
+
_final(callback) { callback(); }
|
|
297
|
+
write(chunk, encoding, callback) { return Writable.prototype.write.call(this, chunk, encoding, callback); }
|
|
298
|
+
end(chunk, encoding, callback) { return Writable.prototype.end.call(this, chunk, encoding, callback); }
|
|
299
|
+
cork() { Writable.prototype.cork.call(this); }
|
|
300
|
+
uncork() { Writable.prototype.uncork.call(this); }
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
// ── Transform ───────────────────────────────────────────────────────
|
|
304
|
+
class Transform extends Duplex {
|
|
305
|
+
constructor(opts) {
|
|
306
|
+
super(opts);
|
|
307
|
+
if (opts?.transform) this._transform = opts.transform.bind(this);
|
|
308
|
+
if (opts?.flush) this._flush = opts.flush.bind(this);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
_transform(chunk, encoding, callback) { callback(null, chunk); }
|
|
312
|
+
_flush(callback) { callback(); }
|
|
313
|
+
|
|
314
|
+
_write(chunk, encoding, callback) {
|
|
315
|
+
this._transform(chunk, encoding, (err, data) => {
|
|
316
|
+
if (err) return callback(err);
|
|
317
|
+
if (data !== null && data !== undefined) this.push(data);
|
|
318
|
+
callback();
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
_final(callback) {
|
|
323
|
+
this._flush((err, data) => {
|
|
324
|
+
if (err) return callback(err);
|
|
325
|
+
if (data !== null && data !== undefined) this.push(data);
|
|
326
|
+
this.push(null);
|
|
327
|
+
callback();
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
// ── PassThrough ─────────────────────────────────────────────────────
|
|
333
|
+
class PassThrough extends Transform {
|
|
334
|
+
constructor(opts) { super(opts); }
|
|
335
|
+
_transform(chunk, encoding, callback) { callback(null, chunk); }
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
// ── pipeline ────────────────────────────────────────────────────────
|
|
339
|
+
function pipeline(...args) {
|
|
340
|
+
const callback = typeof args[args.length - 1] === 'function' ? args.pop() : null;
|
|
341
|
+
const streams = args;
|
|
342
|
+
if (streams.length < 2) {
|
|
343
|
+
if (callback) callback(new Error('pipeline requires at least 2 streams'));
|
|
344
|
+
return streams[0];
|
|
345
|
+
}
|
|
346
|
+
let error = null;
|
|
347
|
+
for (let i = 0; i < streams.length - 1; i++) {
|
|
348
|
+
const src = streams[i];
|
|
349
|
+
const dst = streams[i + 1];
|
|
350
|
+
src.pipe(dst);
|
|
351
|
+
src.on('error', (e) => { error = e; dst.destroy(e); });
|
|
352
|
+
}
|
|
353
|
+
const last = streams[streams.length - 1];
|
|
354
|
+
last.on('finish', () => { if (callback) callback(error); });
|
|
355
|
+
last.on('error', (e) => { if (!error) { error = e; } if (callback) callback(error); });
|
|
356
|
+
return last;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
// ── finished ────────────────────────────────────────────────────────
|
|
360
|
+
function finished(stream, opts, callback) {
|
|
361
|
+
if (typeof opts === 'function') { callback = opts; opts = {}; }
|
|
362
|
+
const onFinish = () => { cleanup(); if (callback) callback(null); };
|
|
363
|
+
const onEnd = () => { cleanup(); if (callback) callback(null); };
|
|
364
|
+
const onError = (err) => { cleanup(); if (callback) callback(err); };
|
|
365
|
+
const onClose = () => { cleanup(); if (callback) callback(null); };
|
|
366
|
+
stream.on('finish', onFinish);
|
|
367
|
+
stream.on('end', onEnd);
|
|
368
|
+
stream.on('error', onError);
|
|
369
|
+
stream.on('close', onClose);
|
|
370
|
+
function cleanup() {
|
|
371
|
+
stream.off('finish', onFinish);
|
|
372
|
+
stream.off('end', onEnd);
|
|
373
|
+
stream.off('error', onError);
|
|
374
|
+
stream.off('close', onClose);
|
|
375
|
+
}
|
|
376
|
+
return cleanup;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
// X.5-Z5 Defect-A fix: real Node's \`require('stream')\` returns the
|
|
380
|
+
// legacy Stream class (a function) with Readable/Writable/etc. as own
|
|
381
|
+
// properties. Userland code (notably readable-stream@2's
|
|
382
|
+
// _stream_writable.js:96 and \`send/index.js\`'s util.inherits(SendStream,
|
|
383
|
+
// require('stream'))) reads \`Stream.prototype\` for prototype chaining.
|
|
384
|
+
// Our namespace-object shape lacks it, so Object.create(stream.prototype, ...)
|
|
385
|
+
// throws "Object prototype may only be an Object or null: undefined".
|
|
386
|
+
// Plant a non-enumerable .prototype pointing at Readable.prototype to
|
|
387
|
+
// satisfy that contract without breaking any other access pattern.
|
|
388
|
+
// See audit/sections/X5Z5-plan.md §1.3 Primary fix.
|
|
389
|
+
const __streamMod = {
|
|
390
|
+
Readable, Writable, Duplex, Transform, PassThrough,
|
|
391
|
+
Stream: Readable,
|
|
392
|
+
pipeline, finished,
|
|
393
|
+
// Aliases for compatibility
|
|
394
|
+
_Readable: Readable, _Writable: Writable, _Transform: Transform,
|
|
395
|
+
};
|
|
396
|
+
Object.defineProperty(__streamMod, 'prototype', {
|
|
397
|
+
value: Readable.prototype, enumerable: false,
|
|
398
|
+
});
|
|
399
|
+
return __streamMod;
|
|
400
|
+
})();
|
|
401
|
+
`;
|
|
402
|
+
}
|