@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,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* cirrus-plugin-react.generated.ts — AUTO-GENERATED by
|
|
3
|
+
* scripts/bundle-plugin-react.mjs. DO NOT EDIT.
|
|
4
|
+
*
|
|
5
|
+
* Self-contained @vitejs/plugin-react@4.3.4 bundle with
|
|
6
|
+
* @babel/core + react-refresh/babel + jsx-self/source plugins inlined.
|
|
7
|
+
* Module-top fs.readFileSync calls for refreshUtils.js and
|
|
8
|
+
* react-refresh-runtime.development.js are pre-resolved to string
|
|
9
|
+
* constants at bundle time.
|
|
10
|
+
*
|
|
11
|
+
* Consumed by src/cirrus-real.ts at facet spawn — injected as a
|
|
12
|
+
* LOADER module named 'cirrus-plugin-react.js'. User vite.config.ts'
|
|
13
|
+
* `import react from '@vitejs/plugin-react'` is rewritten to point
|
|
14
|
+
* at that module.
|
|
15
|
+
*
|
|
16
|
+
* [sdk-phase-1] The bundle string ships via the ASSETS binding instead
|
|
17
|
+
* of inline. Use {@link getCirrusPluginReactBundle}. Version constant
|
|
18
|
+
* stays inline.
|
|
19
|
+
*/
|
|
20
|
+
import { type AssetsFetcher } from './runtime/assets-loader.js';
|
|
21
|
+
export declare const CIRRUS_PLUGIN_REACT_VERSION = "4.3.4";
|
|
22
|
+
/** Asset path for the bundle. Use {@link getCirrusPluginReactBundle}. */
|
|
23
|
+
export declare const CIRRUS_PLUGIN_REACT_BUNDLE_PATH = "/_assets/cirrus-plugin-react.bundle.js";
|
|
24
|
+
/**
|
|
25
|
+
* Fetch the bundle string from the ASSETS binding. Cached per-isolate.
|
|
26
|
+
*
|
|
27
|
+
* @param env Object with the `ASSETS` binding.
|
|
28
|
+
* @returns The plugin-react bundle as a UTF-8 string.
|
|
29
|
+
* @throws {NimbusAssetLoadError} when binding missing or fetch fails.
|
|
30
|
+
*/
|
|
31
|
+
export declare function getCirrusPluginReactBundle(env: {
|
|
32
|
+
ASSETS: AssetsFetcher;
|
|
33
|
+
}): Promise<string>;
|
|
34
|
+
//# sourceMappingURL=cirrus-plugin-react.generated.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cirrus-plugin-react.generated.d.ts","sourceRoot":"","sources":["../src/cirrus-plugin-react.generated.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAiB,KAAK,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE/E,eAAO,MAAM,2BAA2B,UAAU,CAAC;AAEnD,yEAAyE;AACzE,eAAO,MAAM,+BAA+B,2CAA2C,CAAC;AAExF;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CAAC,GAAG,EAAE;IAAE,MAAM,EAAE,aAAa,CAAA;CAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAE1F"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* cirrus-plugin-react.generated.ts — AUTO-GENERATED by
|
|
3
|
+
* scripts/bundle-plugin-react.mjs. DO NOT EDIT.
|
|
4
|
+
*
|
|
5
|
+
* Self-contained @vitejs/plugin-react@4.3.4 bundle with
|
|
6
|
+
* @babel/core + react-refresh/babel + jsx-self/source plugins inlined.
|
|
7
|
+
* Module-top fs.readFileSync calls for refreshUtils.js and
|
|
8
|
+
* react-refresh-runtime.development.js are pre-resolved to string
|
|
9
|
+
* constants at bundle time.
|
|
10
|
+
*
|
|
11
|
+
* Consumed by src/cirrus-real.ts at facet spawn — injected as a
|
|
12
|
+
* LOADER module named 'cirrus-plugin-react.js'. User vite.config.ts'
|
|
13
|
+
* `import react from '@vitejs/plugin-react'` is rewritten to point
|
|
14
|
+
* at that module.
|
|
15
|
+
*
|
|
16
|
+
* [sdk-phase-1] The bundle string ships via the ASSETS binding instead
|
|
17
|
+
* of inline. Use {@link getCirrusPluginReactBundle}. Version constant
|
|
18
|
+
* stays inline.
|
|
19
|
+
*/
|
|
20
|
+
import { loadAssetText } from './runtime/assets-loader.js';
|
|
21
|
+
export const CIRRUS_PLUGIN_REACT_VERSION = "4.3.4";
|
|
22
|
+
/** Asset path for the bundle. Use {@link getCirrusPluginReactBundle}. */
|
|
23
|
+
export const CIRRUS_PLUGIN_REACT_BUNDLE_PATH = "/_assets/cirrus-plugin-react.bundle.js";
|
|
24
|
+
/**
|
|
25
|
+
* Fetch the bundle string from the ASSETS binding. Cached per-isolate.
|
|
26
|
+
*
|
|
27
|
+
* @param env Object with the `ASSETS` binding.
|
|
28
|
+
* @returns The plugin-react bundle as a UTF-8 string.
|
|
29
|
+
* @throws {NimbusAssetLoadError} when binding missing or fetch fails.
|
|
30
|
+
*/
|
|
31
|
+
export function getCirrusPluginReactBundle(env) {
|
|
32
|
+
return loadAssetText(env.ASSETS, CIRRUS_PLUGIN_REACT_BUNDLE_PATH);
|
|
33
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* constants.ts — Single source of truth for all Nimbus configuration.
|
|
3
|
+
*/
|
|
4
|
+
export declare const NIMBUS_VERSION = "2.0.0";
|
|
5
|
+
export declare const NODE_VERSION = "v22.11.0";
|
|
6
|
+
export declare const NODE_VERSIONS: {
|
|
7
|
+
node: string;
|
|
8
|
+
v8: string;
|
|
9
|
+
modules: string;
|
|
10
|
+
};
|
|
11
|
+
export declare const ESBUILD_VERSION = "0.24.2";
|
|
12
|
+
export declare const CHUNK_SIZE = 65536;
|
|
13
|
+
export declare const LRU_MAX_ENTRIES = 512;
|
|
14
|
+
export declare const BATCH_SIZE = 64;
|
|
15
|
+
export declare const VFS_CAPACITY: number;
|
|
16
|
+
export declare const FACET_TIMEOUT_MS = 30000;
|
|
17
|
+
export declare const VFS_BUNDLE_MAX_FILES = 4000;
|
|
18
|
+
export declare const VFS_BUNDLE_MAX_BYTES: number;
|
|
19
|
+
export declare const BUNDLE_MAX_ENCODED_BYTES: number;
|
|
20
|
+
export declare const NPM_REGISTRY = "https://registry.npmjs.org";
|
|
21
|
+
export declare const NPM_CONCURRENCY = 12;
|
|
22
|
+
export declare const NPM_DECOMPRESS_TIMEOUT = 15000;
|
|
23
|
+
export declare const DEFAULT_VITE_PORT = 5173;
|
|
24
|
+
export declare const DEFAULT_PREVIEW_BASE = "/preview";
|
|
25
|
+
export declare const DEFAULT_WORKER_BASE = "/worker";
|
|
26
|
+
export declare const WRANGLER_DEBOUNCE_MS = 250;
|
|
27
|
+
export declare const CF_COMPAT_DATE = "2026-04-01";
|
|
28
|
+
export declare const SUPERVISOR_HEAP_CEILING_BYTES: number;
|
|
29
|
+
export declare const DEFAULT_HOSTNAME = "nimbus";
|
|
30
|
+
export declare const DEFAULT_HOME = "/home/user";
|
|
31
|
+
export declare const DEFAULT_USER = "user";
|
|
32
|
+
export declare const DEFAULT_SHELL = "/bin/sh";
|
|
33
|
+
export declare const DEFAULT_MOUNT_POINTS: string[];
|
|
34
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,eAAO,MAAM,cAAc,UAAU,CAAC;AA+BtC,eAAO,MAAM,YAAY,aAAa,CAAC;AACvC,eAAO,MAAM,aAAa;;;;CAAyD,CAAC;AACpF,eAAO,MAAM,eAAe,WAAW,CAAC;AAGxC,eAAO,MAAM,UAAU,QAAS,CAAC;AACjC,eAAO,MAAM,eAAe,MAAM,CAAC;AACnC,eAAO,MAAM,UAAU,KAAK,CAAC;AAC7B,eAAO,MAAM,YAAY,QAA0B,CAAC;AAGpD,eAAO,MAAM,gBAAgB,QAAS,CAAC;AA0BvC,eAAO,MAAM,oBAAoB,OAAO,CAAC;AACzC,eAAO,MAAM,oBAAoB,QAAmB,CAAC;AACrD,eAAO,MAAM,wBAAwB,QAAmB,CAAC;AAGzD,eAAO,MAAM,YAAY,+BAA+B,CAAC;AACzD,eAAO,MAAM,eAAe,KAAK,CAAC;AAClC,eAAO,MAAM,sBAAsB,QAAS,CAAC;AAG7C,eAAO,MAAM,iBAAiB,OAAO,CAAC;AACtC,eAAO,MAAM,oBAAoB,aAAa,CAAC;AAC/C,eAAO,MAAM,mBAAmB,YAAY,CAAC;AAC7C,eAAO,MAAM,oBAAoB,MAAM,CAAC;AAGxC,eAAO,MAAM,cAAc,eAAe,CAAC;AA2B3C,eAAO,MAAM,6BAA6B,QAAmB,CAAC;AAG9D,eAAO,MAAM,gBAAgB,WAAW,CAAC;AACzC,eAAO,MAAM,YAAY,eAAe,CAAC;AACzC,eAAO,MAAM,YAAY,SAAS,CAAC;AACnC,eAAO,MAAM,aAAa,YAAY,CAAC;AACvC,eAAO,MAAM,oBAAoB,UAAqD,CAAC"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* constants.ts — Single source of truth for all Nimbus configuration.
|
|
3
|
+
*/
|
|
4
|
+
// ── Versions ────────────────────────────────────────────────────────────
|
|
5
|
+
export const NIMBUS_VERSION = '2.0.0';
|
|
6
|
+
//
|
|
7
|
+
// Node version reported by Nimbus's node-shim layer (process.version,
|
|
8
|
+
// process.versions.node). Bumped from v20.0.0 → v22.11.0 (Node 22 LTS
|
|
9
|
+
// "Jod") because Node 20 fell out of support upstream and several
|
|
10
|
+
// scaffolders (create-astro is the canonical example) refuse to run on
|
|
11
|
+
// majors < 22 with the literal preflight:
|
|
12
|
+
//
|
|
13
|
+
// const currentVersion = process.versions.node;
|
|
14
|
+
// const requiredMajorVersion = Number.parseInt(currentVersion.split('.')[0], 10);
|
|
15
|
+
// if (requiredMajorVersion < minimumMajorVersion /* 22 */) {
|
|
16
|
+
// console.error('Node.js v' + currentVersion + ' is out-of-date');
|
|
17
|
+
// process.exit(1);
|
|
18
|
+
// }
|
|
19
|
+
//
|
|
20
|
+
// The version is a fingerprint, not a feature claim. Node 22-only APIs
|
|
21
|
+
// that user code may touch:
|
|
22
|
+
// - util.styleText → shimmed (primitives wave, see node-shims.ts)
|
|
23
|
+
// - util.parseEnv → unshimmed; throws clear ENOENT-style Error
|
|
24
|
+
// (verified non-breaking for the framework
|
|
25
|
+
// probes — none of remix/nuxt/astro/sveltekit/
|
|
26
|
+
// markflow scaffold reach it during create or
|
|
27
|
+
// dev-start phases)
|
|
28
|
+
// - import.meta.dirname → ESM-only, mirrored by Vite in dev mode
|
|
29
|
+
// - WebSocket global → already provided by workerd
|
|
30
|
+
// - Promise.withResolvers / Object.groupBy / Map.groupBy → V8 builtins,
|
|
31
|
+
// already available in workerd's V8 runtime
|
|
32
|
+
//
|
|
33
|
+
// ABI numbers (v8, modules) are mostly cosmetic but mirrored to v22.11.0
|
|
34
|
+
// for fingerprint consistency. v8 12.4 ships with Node 22.x; modules
|
|
35
|
+
// (NODE_MODULE_VERSION) is 127 for the v22 line.
|
|
36
|
+
export const NODE_VERSION = 'v22.11.0';
|
|
37
|
+
export const NODE_VERSIONS = { node: '22.11.0', v8: '12.4.254.21', modules: '127' };
|
|
38
|
+
export const ESBUILD_VERSION = '0.24.2';
|
|
39
|
+
// ── VFS Constants ───────────────────────────────────────────────────────
|
|
40
|
+
export const CHUNK_SIZE = 65_536; // 64KB per content chunk
|
|
41
|
+
export const LRU_MAX_ENTRIES = 512; // 512 × 64KB = 32MB hot cache
|
|
42
|
+
export const BATCH_SIZE = 64; // rows per batch INSERT
|
|
43
|
+
export const VFS_CAPACITY = 10 * 1024 * 1024 * 1024; // 10 GB
|
|
44
|
+
// ── Facet Constants ─────────────────────────────────────────────────────
|
|
45
|
+
export const FACET_TIMEOUT_MS = 30_000; // 30s execution timeout
|
|
46
|
+
//
|
|
47
|
+
// W2.6a: bundle-size budget is gated on the JSON-ENCODED UTF-8 BYTE
|
|
48
|
+
// length of the final {bundle, manifest} payload, not on raw content
|
|
49
|
+
// byte sum. The dynamic worker module embeds the bundle as
|
|
50
|
+
// `const __MODULE_VFS_BUNDLE = ${JSON.stringify(bundle)}`, so workerd's
|
|
51
|
+
// per-module text-size limit applies to the JSON-escaped form (each
|
|
52
|
+
// `\n` / `\"` / `\u` adds bytes, plus the per-key string-quote overhead).
|
|
53
|
+
// Empirical W2.5b sweep (audit/sections/W2.6-plan.md §2.2) showed 6 MiB
|
|
54
|
+
// raw → boots, 8 MiB raw → fails. Encoded as JSON that's roughly 18-25 MiB
|
|
55
|
+
// of module text. We target 22 MiB encoded as the hard ceiling, leaving
|
|
56
|
+
// ~2-3 MiB of headroom for the rest of the worker module (shims, runner
|
|
57
|
+
// boot code) and any minor drift in the eviction loop's accounting.
|
|
58
|
+
//
|
|
59
|
+
// facet-manager.ts:buildPrefetchBundle uses TextEncoder().encode().length
|
|
60
|
+
// to measure exact UTF-8 bytes (not JS string .length, which counts UTF-16
|
|
61
|
+
// code units and undercounts non-ASCII content).
|
|
62
|
+
//
|
|
63
|
+
// VFS_BUNDLE_MAX_BYTES (raw) is retained as a cheap pre-check so we
|
|
64
|
+
// don't waste cycles building a bundle that will obviously blow the
|
|
65
|
+
// encoded ceiling. 24 MiB raw will JSON-encode to roughly 30-50 MiB,
|
|
66
|
+
// so we keep the raw cap a comfortable margin under the encoded one.
|
|
67
|
+
// VFS_BUNDLE_MAX_FILES is retained for prefetch-side recursion safety.
|
|
68
|
+
// VFS_BUNDLE_MAX_DEPTH dropped — the prefetch walk is bounded by the
|
|
69
|
+
// require() graph itself; manifest pass uses MANIFEST_MAX_DEPTH (local
|
|
70
|
+
// to facet-manager.ts).
|
|
71
|
+
export const VFS_BUNDLE_MAX_FILES = 4000;
|
|
72
|
+
export const VFS_BUNDLE_MAX_BYTES = 24 * 1024 * 1024; // 24 MiB raw
|
|
73
|
+
export const BUNDLE_MAX_ENCODED_BYTES = 22 * 1024 * 1024; // 22 MiB JSON-encoded UTF-8
|
|
74
|
+
// ── npm Constants ───────────────────────────────────────────────────────
|
|
75
|
+
export const NPM_REGISTRY = 'https://registry.npmjs.org';
|
|
76
|
+
export const NPM_CONCURRENCY = 12;
|
|
77
|
+
export const NPM_DECOMPRESS_TIMEOUT = 15_000;
|
|
78
|
+
// ── Dev Server Constants ────────────────────────────────────────────────
|
|
79
|
+
export const DEFAULT_VITE_PORT = 5173;
|
|
80
|
+
export const DEFAULT_PREVIEW_BASE = '/preview';
|
|
81
|
+
export const DEFAULT_WORKER_BASE = '/worker';
|
|
82
|
+
export const WRANGLER_DEBOUNCE_MS = 250;
|
|
83
|
+
// ── Compatibility ───────────────────────────────────────────────────────
|
|
84
|
+
export const CF_COMPAT_DATE = '2026-04-01';
|
|
85
|
+
// ── Supervisor heap budget [C'.1] ───────────────────────────────────────
|
|
86
|
+
//
|
|
87
|
+
// The supervisor isolate's 128 MiB workerd cap is a HARD platform ceiling
|
|
88
|
+
// (per docs/research/cf-primitives-dossier.md §6 invariant I1 — 128 MiB
|
|
89
|
+
// per V8 isolate, may be shared across same-class peer DOs co-tenanting in
|
|
90
|
+
// one process). Nimbus targets HALF of that as a self-imposed soft ceiling
|
|
91
|
+
// so the supervisor always has runway when workerd LRU-evicts neighbours
|
|
92
|
+
// or AIR (Asynchronous Isolate Recreation) folds growing isolates.
|
|
93
|
+
//
|
|
94
|
+
// 64 MiB is a budget, not a measurement. Every supervisor allocation
|
|
95
|
+
// site is accounted for in src/observability/heap-estimate.ts which sums
|
|
96
|
+
// known contributors (VFS LRU, in-flight writes, resolver, pre-bundle
|
|
97
|
+
// slice, esbuild residency, supervisor baseline). When the estimator
|
|
98
|
+
// surpasses this ceiling, plan §3 Track A' has a target to chase down.
|
|
99
|
+
//
|
|
100
|
+
// Components that contribute (current architecture, before A'):
|
|
101
|
+
// supervisorBaselineBytes ~30 MiB ← static module bundle + runtime
|
|
102
|
+
// esbuildResidentBytes ~16 MiB ← addressed by A'.5 (move to R2)
|
|
103
|
+
// vfsLruBytes (max) ~32 MiB ← LRU_MAX_ENTRIES × CHUNK_SIZE
|
|
104
|
+
// vfsInFlightBytes (peak) ~few MiB ← bounded by SqliteVFS batch size
|
|
105
|
+
// resolverInFlightBytes ~few MiB ← addressed by A'.1 (facet-only)
|
|
106
|
+
// preBundleSliceBytes (max) 28 MiB ← addressed by A'.2 (streaming)
|
|
107
|
+
//
|
|
108
|
+
// Pre-A' worst-case: 30 + 16 + 32 + 28 ≈ 106 MiB → over budget. Phase 2
|
|
109
|
+
// A' brings it under 64 MiB by removing supervisor-resident components.
|
|
110
|
+
export const SUPERVISOR_HEAP_CEILING_BYTES = 64 * 1024 * 1024;
|
|
111
|
+
// ── OS Defaults ─────────────────────────────────────────────────────────
|
|
112
|
+
export const DEFAULT_HOSTNAME = 'nimbus';
|
|
113
|
+
export const DEFAULT_HOME = '/home/user';
|
|
114
|
+
export const DEFAULT_USER = 'user';
|
|
115
|
+
export const DEFAULT_SHELL = '/bin/sh';
|
|
116
|
+
export const DEFAULT_MOUNT_POINTS = ['bin', 'etc', 'home', 'tmp', 'var', 'usr', 'opt'];
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* esbuild-wasm-bundle.generated.ts — AUTO-GENERATED by scripts/bundle-esbuild-wasm.mjs
|
|
3
|
+
* DO NOT EDIT.
|
|
4
|
+
*
|
|
5
|
+
* Bundled esbuild-wasm 0.24.2 adapter for use inside NimbusLoaderPool
|
|
6
|
+
* isolates. Only the JS adapter is bundled here (~117 KiB); the wasm
|
|
7
|
+
* binary itself lives in the static-assets layer at
|
|
8
|
+
* public/_assets/esbuild-0.24.2.wasm and is fetched on demand by
|
|
9
|
+
* src/esbuild-wasm-bytes.ts.
|
|
10
|
+
*
|
|
11
|
+
* Phase 2 A'.5 moved the base64 wasm string OUT of the supervisor
|
|
12
|
+
* bundle (was 16 MiB UTF-8 → 21 MiB UTF-16 in JS string overhead).
|
|
13
|
+
* If you're reading this and wondering where the bytes are: env.ASSETS.
|
|
14
|
+
*/
|
|
15
|
+
export declare const ESBUILD_WASM_VERSION: string;
|
|
16
|
+
/**
|
|
17
|
+
* Function body that, when wrapped in `new Function(...)()`, returns
|
|
18
|
+
* the esbuild-wasm namespace (build, transform, initialize, ...).
|
|
19
|
+
*
|
|
20
|
+
* Source: node_modules/esbuild-wasm/esm/browser.js with the trailing
|
|
21
|
+
* `export { ... }` rewritten to `return { ... };`. Why the browser
|
|
22
|
+
* build:
|
|
23
|
+
* - Pure ESM with no `createRequire`, no `require("fs")`, and
|
|
24
|
+
* no `process.binding` — safe to evaluate inside a workerd
|
|
25
|
+
* dynamic-worker isolate.
|
|
26
|
+
* - The supported public surface for "esbuild inside a worker" is
|
|
27
|
+
* exactly this build.
|
|
28
|
+
*
|
|
29
|
+
* Why `new Function(body)()` (rather than `import('data:...')`):
|
|
30
|
+
* - data: URL imports across workerd versions are not contractual
|
|
31
|
+
* and we don't want a deploy that worked yesterday to silently
|
|
32
|
+
* break tomorrow when the runtime is upgraded.
|
|
33
|
+
* - new Function is documented as supported inside dynamic workers
|
|
34
|
+
* (src/facet-manager.ts has been doing this since 2025).
|
|
35
|
+
*
|
|
36
|
+
* The bundle script verifies the file does NOT contain the forbidden
|
|
37
|
+
* patterns (createRequire / dynamic node-builtin require / process.binding)
|
|
38
|
+
* and bails loud if a future release reintroduces them.
|
|
39
|
+
*/
|
|
40
|
+
export declare const ESBUILD_WASM_JS_FN_BODY: string;
|
|
41
|
+
//# sourceMappingURL=esbuild-wasm-bundle.generated.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"esbuild-wasm-bundle.generated.d.ts","sourceRoot":"","sources":["../src/esbuild-wasm-bundle.generated.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,eAAO,MAAM,oBAAoB,EAAE,MAAiB,CAAC;AAErD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,uBAAuB,EAAE,MAA4+xH,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* esbuild-wasm-bundle.generated.ts — AUTO-GENERATED by scripts/bundle-esbuild-wasm.mjs
|
|
3
|
+
* DO NOT EDIT.
|
|
4
|
+
*
|
|
5
|
+
* Bundled esbuild-wasm 0.24.2 adapter for use inside NimbusLoaderPool
|
|
6
|
+
* isolates. Only the JS adapter is bundled here (~117 KiB); the wasm
|
|
7
|
+
* binary itself lives in the static-assets layer at
|
|
8
|
+
* public/_assets/esbuild-0.24.2.wasm and is fetched on demand by
|
|
9
|
+
* src/esbuild-wasm-bytes.ts.
|
|
10
|
+
*
|
|
11
|
+
* Phase 2 A'.5 moved the base64 wasm string OUT of the supervisor
|
|
12
|
+
* bundle (was 16 MiB UTF-8 → 21 MiB UTF-16 in JS string overhead).
|
|
13
|
+
* If you're reading this and wondering where the bytes are: env.ASSETS.
|
|
14
|
+
*/
|
|
15
|
+
export const ESBUILD_WASM_VERSION = "0.24.2";
|
|
16
|
+
/**
|
|
17
|
+
* Function body that, when wrapped in `new Function(...)()`, returns
|
|
18
|
+
* the esbuild-wasm namespace (build, transform, initialize, ...).
|
|
19
|
+
*
|
|
20
|
+
* Source: node_modules/esbuild-wasm/esm/browser.js with the trailing
|
|
21
|
+
* `export { ... }` rewritten to `return { ... };`. Why the browser
|
|
22
|
+
* build:
|
|
23
|
+
* - Pure ESM with no `createRequire`, no `require("fs")`, and
|
|
24
|
+
* no `process.binding` — safe to evaluate inside a workerd
|
|
25
|
+
* dynamic-worker isolate.
|
|
26
|
+
* - The supported public surface for "esbuild inside a worker" is
|
|
27
|
+
* exactly this build.
|
|
28
|
+
*
|
|
29
|
+
* Why `new Function(body)()` (rather than `import('data:...')`):
|
|
30
|
+
* - data: URL imports across workerd versions are not contractual
|
|
31
|
+
* and we don't want a deploy that worked yesterday to silently
|
|
32
|
+
* break tomorrow when the runtime is upgraded.
|
|
33
|
+
* - new Function is documented as supported inside dynamic workers
|
|
34
|
+
* (src/facet-manager.ts has been doing this since 2025).
|
|
35
|
+
*
|
|
36
|
+
* The bundle script verifies the file does NOT contain the forbidden
|
|
37
|
+
* patterns (createRequire / dynamic node-builtin require / process.binding)
|
|
38
|
+
* and bails loud if a future release reintroduces them.
|
|
39
|
+
*/
|
|
40
|
+
export const ESBUILD_WASM_JS_FN_BODY = "var __defProp = Object.defineProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\n\n// lib/npm/browser.ts\nvar browser_exports = {};\n__export(browser_exports, {\n analyzeMetafile: () => analyzeMetafile,\n analyzeMetafileSync: () => analyzeMetafileSync,\n build: () => build,\n buildSync: () => buildSync,\n context: () => context,\n default: () => browser_default,\n formatMessages: () => formatMessages,\n formatMessagesSync: () => formatMessagesSync,\n initialize: () => initialize,\n stop: () => stop,\n transform: () => transform,\n transformSync: () => transformSync,\n version: () => version\n});\n\n// lib/shared/stdio_protocol.ts\nfunction encodePacket(packet) {\n let visit = (value) => {\n if (value === null) {\n bb.write8(0);\n } else if (typeof value === \"boolean\") {\n bb.write8(1);\n bb.write8(+value);\n } else if (typeof value === \"number\") {\n bb.write8(2);\n bb.write32(value | 0);\n } else if (typeof value === \"string\") {\n bb.write8(3);\n bb.write(encodeUTF8(value));\n } else if (value instanceof Uint8Array) {\n bb.write8(4);\n bb.write(value);\n } else if (value instanceof Array) {\n bb.write8(5);\n bb.write32(value.length);\n for (let item of value) {\n visit(item);\n }\n } else {\n let keys = Object.keys(value);\n bb.write8(6);\n bb.write32(keys.length);\n for (let key of keys) {\n bb.write(encodeUTF8(key));\n visit(value[key]);\n }\n }\n };\n let bb = new ByteBuffer();\n bb.write32(0);\n bb.write32(packet.id << 1 | +!packet.isRequest);\n visit(packet.value);\n writeUInt32LE(bb.buf, bb.len - 4, 0);\n return bb.buf.subarray(0, bb.len);\n}\nfunction decodePacket(bytes) {\n let visit = () => {\n switch (bb.read8()) {\n case 0:\n return null;\n case 1:\n return !!bb.read8();\n case 2:\n return bb.read32();\n case 3:\n return decodeUTF8(bb.read());\n case 4:\n return bb.read();\n case 5: {\n let count = bb.read32();\n let value2 = [];\n for (let i = 0; i < count; i++) {\n value2.push(visit());\n }\n return value2;\n }\n case 6: {\n let count = bb.read32();\n let value2 = {};\n for (let i = 0; i < count; i++) {\n value2[decodeUTF8(bb.read())] = visit();\n }\n return value2;\n }\n default:\n throw new Error(\"Invalid packet\");\n }\n };\n let bb = new ByteBuffer(bytes);\n let id = bb.read32();\n let isRequest = (id & 1) === 0;\n id >>>= 1;\n let value = visit();\n if (bb.ptr !== bytes.length) {\n throw new Error(\"Invalid packet\");\n }\n return { id, isRequest, value };\n}\nvar ByteBuffer = class {\n constructor(buf = new Uint8Array(1024)) {\n this.buf = buf;\n this.len = 0;\n this.ptr = 0;\n }\n _write(delta) {\n if (this.len + delta > this.buf.length) {\n let clone = new Uint8Array((this.len + delta) * 2);\n clone.set(this.buf);\n this.buf = clone;\n }\n this.len += delta;\n return this.len - delta;\n }\n write8(value) {\n let offset = this._write(1);\n this.buf[offset] = value;\n }\n write32(value) {\n let offset = this._write(4);\n writeUInt32LE(this.buf, value, offset);\n }\n write(bytes) {\n let offset = this._write(4 + bytes.length);\n writeUInt32LE(this.buf, bytes.length, offset);\n this.buf.set(bytes, offset + 4);\n }\n _read(delta) {\n if (this.ptr + delta > this.buf.length) {\n throw new Error(\"Invalid packet\");\n }\n this.ptr += delta;\n return this.ptr - delta;\n }\n read8() {\n return this.buf[this._read(1)];\n }\n read32() {\n return readUInt32LE(this.buf, this._read(4));\n }\n read() {\n let length = this.read32();\n let bytes = new Uint8Array(length);\n let ptr = this._read(bytes.length);\n bytes.set(this.buf.subarray(ptr, ptr + length));\n return bytes;\n }\n};\nvar encodeUTF8;\nvar decodeUTF8;\nvar encodeInvariant;\nif (typeof TextEncoder !== \"undefined\" && typeof TextDecoder !== \"undefined\") {\n let encoder = new TextEncoder();\n let decoder = new TextDecoder();\n encodeUTF8 = (text) => encoder.encode(text);\n decodeUTF8 = (bytes) => decoder.decode(bytes);\n encodeInvariant = 'new TextEncoder().encode(\"\")';\n} else if (typeof Buffer !== \"undefined\") {\n encodeUTF8 = (text) => Buffer.from(text);\n decodeUTF8 = (bytes) => {\n let { buffer, byteOffset, byteLength } = bytes;\n return Buffer.from(buffer, byteOffset, byteLength).toString();\n };\n encodeInvariant = 'Buffer.from(\"\")';\n} else {\n throw new Error(\"No UTF-8 codec found\");\n}\nif (!(encodeUTF8(\"\") instanceof Uint8Array))\n throw new Error(`Invariant violation: \"${encodeInvariant} instanceof Uint8Array\" is incorrectly false\n\nThis indicates that your JavaScript environment is broken. You cannot use\nesbuild in this environment because esbuild relies on this invariant. This\nis not a problem with esbuild. You need to fix your environment instead.\n`);\nfunction readUInt32LE(buffer, offset) {\n return buffer[offset++] | buffer[offset++] << 8 | buffer[offset++] << 16 | buffer[offset++] << 24;\n}\nfunction writeUInt32LE(buffer, value, offset) {\n buffer[offset++] = value;\n buffer[offset++] = value >> 8;\n buffer[offset++] = value >> 16;\n buffer[offset++] = value >> 24;\n}\n\n// lib/shared/common.ts\nvar quote = JSON.stringify;\nvar buildLogLevelDefault = \"warning\";\nvar transformLogLevelDefault = \"silent\";\nfunction validateTarget(target) {\n validateStringValue(target, \"target\");\n if (target.indexOf(\",\") >= 0) throw new Error(`Invalid target: ${target}`);\n return target;\n}\nvar canBeAnything = () => null;\nvar mustBeBoolean = (value) => typeof value === \"boolean\" ? null : \"a boolean\";\nvar mustBeString = (value) => typeof value === \"string\" ? null : \"a string\";\nvar mustBeRegExp = (value) => value instanceof RegExp ? null : \"a RegExp object\";\nvar mustBeInteger = (value) => typeof value === \"number\" && value === (value | 0) ? null : \"an integer\";\nvar mustBeFunction = (value) => typeof value === \"function\" ? null : \"a function\";\nvar mustBeArray = (value) => Array.isArray(value) ? null : \"an array\";\nvar mustBeObject = (value) => typeof value === \"object\" && value !== null && !Array.isArray(value) ? null : \"an object\";\nvar mustBeEntryPoints = (value) => typeof value === \"object\" && value !== null ? null : \"an array or an object\";\nvar mustBeWebAssemblyModule = (value) => value instanceof WebAssembly.Module ? null : \"a WebAssembly.Module\";\nvar mustBeObjectOrNull = (value) => typeof value === \"object\" && !Array.isArray(value) ? null : \"an object or null\";\nvar mustBeStringOrBoolean = (value) => typeof value === \"string\" || typeof value === \"boolean\" ? null : \"a string or a boolean\";\nvar mustBeStringOrObject = (value) => typeof value === \"string\" || typeof value === \"object\" && value !== null && !Array.isArray(value) ? null : \"a string or an object\";\nvar mustBeStringOrArray = (value) => typeof value === \"string\" || Array.isArray(value) ? null : \"a string or an array\";\nvar mustBeStringOrUint8Array = (value) => typeof value === \"string\" || value instanceof Uint8Array ? null : \"a string or a Uint8Array\";\nvar mustBeStringOrURL = (value) => typeof value === \"string\" || value instanceof URL ? null : \"a string or a URL\";\nfunction getFlag(object, keys, key, mustBeFn) {\n let value = object[key];\n keys[key + \"\"] = true;\n if (value === void 0) return void 0;\n let mustBe = mustBeFn(value);\n if (mustBe !== null) throw new Error(`${quote(key)} must be ${mustBe}`);\n return value;\n}\nfunction checkForInvalidFlags(object, keys, where) {\n for (let key in object) {\n if (!(key in keys)) {\n throw new Error(`Invalid option ${where}: ${quote(key)}`);\n }\n }\n}\nfunction validateInitializeOptions(options) {\n let keys = /* @__PURE__ */ Object.create(null);\n let wasmURL = getFlag(options, keys, \"wasmURL\", mustBeStringOrURL);\n let wasmModule = getFlag(options, keys, \"wasmModule\", mustBeWebAssemblyModule);\n let worker = getFlag(options, keys, \"worker\", mustBeBoolean);\n checkForInvalidFlags(options, keys, \"in initialize() call\");\n return {\n wasmURL,\n wasmModule,\n worker\n };\n}\nfunction validateMangleCache(mangleCache) {\n let validated;\n if (mangleCache !== void 0) {\n validated = /* @__PURE__ */ Object.create(null);\n for (let key in mangleCache) {\n let value = mangleCache[key];\n if (typeof value === \"string\" || value === false) {\n validated[key] = value;\n } else {\n throw new Error(`Expected ${quote(key)} in mangle cache to map to either a string or false`);\n }\n }\n }\n return validated;\n}\nfunction pushLogFlags(flags, options, keys, isTTY, logLevelDefault) {\n let color = getFlag(options, keys, \"color\", mustBeBoolean);\n let logLevel = getFlag(options, keys, \"logLevel\", mustBeString);\n let logLimit = getFlag(options, keys, \"logLimit\", mustBeInteger);\n if (color !== void 0) flags.push(`--color=${color}`);\n else if (isTTY) flags.push(`--color=true`);\n flags.push(`--log-level=${logLevel || logLevelDefault}`);\n flags.push(`--log-limit=${logLimit || 0}`);\n}\nfunction validateStringValue(value, what, key) {\n if (typeof value !== \"string\") {\n throw new Error(`Expected value for ${what}${key !== void 0 ? \" \" + quote(key) : \"\"} to be a string, got ${typeof value} instead`);\n }\n return value;\n}\nfunction pushCommonFlags(flags, options, keys) {\n let legalComments = getFlag(options, keys, \"legalComments\", mustBeString);\n let sourceRoot = getFlag(options, keys, \"sourceRoot\", mustBeString);\n let sourcesContent = getFlag(options, keys, \"sourcesContent\", mustBeBoolean);\n let target = getFlag(options, keys, \"target\", mustBeStringOrArray);\n let format = getFlag(options, keys, \"format\", mustBeString);\n let globalName = getFlag(options, keys, \"globalName\", mustBeString);\n let mangleProps = getFlag(options, keys, \"mangleProps\", mustBeRegExp);\n let reserveProps = getFlag(options, keys, \"reserveProps\", mustBeRegExp);\n let mangleQuoted = getFlag(options, keys, \"mangleQuoted\", mustBeBoolean);\n let minify = getFlag(options, keys, \"minify\", mustBeBoolean);\n let minifySyntax = getFlag(options, keys, \"minifySyntax\", mustBeBoolean);\n let minifyWhitespace = getFlag(options, keys, \"minifyWhitespace\", mustBeBoolean);\n let minifyIdentifiers = getFlag(options, keys, \"minifyIdentifiers\", mustBeBoolean);\n let lineLimit = getFlag(options, keys, \"lineLimit\", mustBeInteger);\n let drop = getFlag(options, keys, \"drop\", mustBeArray);\n let dropLabels = getFlag(options, keys, \"dropLabels\", mustBeArray);\n let charset = getFlag(options, keys, \"charset\", mustBeString);\n let treeShaking = getFlag(options, keys, \"treeShaking\", mustBeBoolean);\n let ignoreAnnotations = getFlag(options, keys, \"ignoreAnnotations\", mustBeBoolean);\n let jsx = getFlag(options, keys, \"jsx\", mustBeString);\n let jsxFactory = getFlag(options, keys, \"jsxFactory\", mustBeString);\n let jsxFragment = getFlag(options, keys, \"jsxFragment\", mustBeString);\n let jsxImportSource = getFlag(options, keys, \"jsxImportSource\", mustBeString);\n let jsxDev = getFlag(options, keys, \"jsxDev\", mustBeBoolean);\n let jsxSideEffects = getFlag(options, keys, \"jsxSideEffects\", mustBeBoolean);\n let define = getFlag(options, keys, \"define\", mustBeObject);\n let logOverride = getFlag(options, keys, \"logOverride\", mustBeObject);\n let supported = getFlag(options, keys, \"supported\", mustBeObject);\n let pure = getFlag(options, keys, \"pure\", mustBeArray);\n let keepNames = getFlag(options, keys, \"keepNames\", mustBeBoolean);\n let platform = getFlag(options, keys, \"platform\", mustBeString);\n let tsconfigRaw = getFlag(options, keys, \"tsconfigRaw\", mustBeStringOrObject);\n if (legalComments) flags.push(`--legal-comments=${legalComments}`);\n if (sourceRoot !== void 0) flags.push(`--source-root=${sourceRoot}`);\n if (sourcesContent !== void 0) flags.push(`--sources-content=${sourcesContent}`);\n if (target) {\n if (Array.isArray(target)) flags.push(`--target=${Array.from(target).map(validateTarget).join(\",\")}`);\n else flags.push(`--target=${validateTarget(target)}`);\n }\n if (format) flags.push(`--format=${format}`);\n if (globalName) flags.push(`--global-name=${globalName}`);\n if (platform) flags.push(`--platform=${platform}`);\n if (tsconfigRaw) flags.push(`--tsconfig-raw=${typeof tsconfigRaw === \"string\" ? tsconfigRaw : JSON.stringify(tsconfigRaw)}`);\n if (minify) flags.push(\"--minify\");\n if (minifySyntax) flags.push(\"--minify-syntax\");\n if (minifyWhitespace) flags.push(\"--minify-whitespace\");\n if (minifyIdentifiers) flags.push(\"--minify-identifiers\");\n if (lineLimit) flags.push(`--line-limit=${lineLimit}`);\n if (charset) flags.push(`--charset=${charset}`);\n if (treeShaking !== void 0) flags.push(`--tree-shaking=${treeShaking}`);\n if (ignoreAnnotations) flags.push(`--ignore-annotations`);\n if (drop) for (let what of drop) flags.push(`--drop:${validateStringValue(what, \"drop\")}`);\n if (dropLabels) flags.push(`--drop-labels=${Array.from(dropLabels).map((what) => validateStringValue(what, \"dropLabels\")).join(\",\")}`);\n if (mangleProps) flags.push(`--mangle-props=${mangleProps.source}`);\n if (reserveProps) flags.push(`--reserve-props=${reserveProps.source}`);\n if (mangleQuoted !== void 0) flags.push(`--mangle-quoted=${mangleQuoted}`);\n if (jsx) flags.push(`--jsx=${jsx}`);\n if (jsxFactory) flags.push(`--jsx-factory=${jsxFactory}`);\n if (jsxFragment) flags.push(`--jsx-fragment=${jsxFragment}`);\n if (jsxImportSource) flags.push(`--jsx-import-source=${jsxImportSource}`);\n if (jsxDev) flags.push(`--jsx-dev`);\n if (jsxSideEffects) flags.push(`--jsx-side-effects`);\n if (define) {\n for (let key in define) {\n if (key.indexOf(\"=\") >= 0) throw new Error(`Invalid define: ${key}`);\n flags.push(`--define:${key}=${validateStringValue(define[key], \"define\", key)}`);\n }\n }\n if (logOverride) {\n for (let key in logOverride) {\n if (key.indexOf(\"=\") >= 0) throw new Error(`Invalid log override: ${key}`);\n flags.push(`--log-override:${key}=${validateStringValue(logOverride[key], \"log override\", key)}`);\n }\n }\n if (supported) {\n for (let key in supported) {\n if (key.indexOf(\"=\") >= 0) throw new Error(`Invalid supported: ${key}`);\n const value = supported[key];\n if (typeof value !== \"boolean\") throw new Error(`Expected value for supported ${quote(key)} to be a boolean, got ${typeof value} instead`);\n flags.push(`--supported:${key}=${value}`);\n }\n }\n if (pure) for (let fn of pure) flags.push(`--pure:${validateStringValue(fn, \"pure\")}`);\n if (keepNames) flags.push(`--keep-names`);\n}\nfunction flagsForBuildOptions(callName, options, isTTY, logLevelDefault, writeDefault) {\n var _a;\n let flags = [];\n let entries = [];\n let keys = /* @__PURE__ */ Object.create(null);\n let stdinContents = null;\n let stdinResolveDir = null;\n pushLogFlags(flags, options, keys, isTTY, logLevelDefault);\n pushCommonFlags(flags, options, keys);\n let sourcemap = getFlag(options, keys, \"sourcemap\", mustBeStringOrBoolean);\n let bundle = getFlag(options, keys, \"bundle\", mustBeBoolean);\n let splitting = getFlag(options, keys, \"splitting\", mustBeBoolean);\n let preserveSymlinks = getFlag(options, keys, \"preserveSymlinks\", mustBeBoolean);\n let metafile = getFlag(options, keys, \"metafile\", mustBeBoolean);\n let outfile = getFlag(options, keys, \"outfile\", mustBeString);\n let outdir = getFlag(options, keys, \"outdir\", mustBeString);\n let outbase = getFlag(options, keys, \"outbase\", mustBeString);\n let tsconfig = getFlag(options, keys, \"tsconfig\", mustBeString);\n let resolveExtensions = getFlag(options, keys, \"resolveExtensions\", mustBeArray);\n let nodePathsInput = getFlag(options, keys, \"nodePaths\", mustBeArray);\n let mainFields = getFlag(options, keys, \"mainFields\", mustBeArray);\n let conditions = getFlag(options, keys, \"conditions\", mustBeArray);\n let external = getFlag(options, keys, \"external\", mustBeArray);\n let packages = getFlag(options, keys, \"packages\", mustBeString);\n let alias = getFlag(options, keys, \"alias\", mustBeObject);\n let loader = getFlag(options, keys, \"loader\", mustBeObject);\n let outExtension = getFlag(options, keys, \"outExtension\", mustBeObject);\n let publicPath = getFlag(options, keys, \"publicPath\", mustBeString);\n let entryNames = getFlag(options, keys, \"entryNames\", mustBeString);\n let chunkNames = getFlag(options, keys, \"chunkNames\", mustBeString);\n let assetNames = getFlag(options, keys, \"assetNames\", mustBeString);\n let inject = getFlag(options, keys, \"inject\", mustBeArray);\n let banner = getFlag(options, keys, \"banner\", mustBeObject);\n let footer = getFlag(options, keys, \"footer\", mustBeObject);\n let entryPoints = getFlag(options, keys, \"entryPoints\", mustBeEntryPoints);\n let absWorkingDir = getFlag(options, keys, \"absWorkingDir\", mustBeString);\n let stdin = getFlag(options, keys, \"stdin\", mustBeObject);\n let write = (_a = getFlag(options, keys, \"write\", mustBeBoolean)) != null ? _a : writeDefault;\n let allowOverwrite = getFlag(options, keys, \"allowOverwrite\", mustBeBoolean);\n let mangleCache = getFlag(options, keys, \"mangleCache\", mustBeObject);\n keys.plugins = true;\n checkForInvalidFlags(options, keys, `in ${callName}() call`);\n if (sourcemap) flags.push(`--sourcemap${sourcemap === true ? \"\" : `=${sourcemap}`}`);\n if (bundle) flags.push(\"--bundle\");\n if (allowOverwrite) flags.push(\"--allow-overwrite\");\n if (splitting) flags.push(\"--splitting\");\n if (preserveSymlinks) flags.push(\"--preserve-symlinks\");\n if (metafile) flags.push(`--metafile`);\n if (outfile) flags.push(`--outfile=${outfile}`);\n if (outdir) flags.push(`--outdir=${outdir}`);\n if (outbase) flags.push(`--outbase=${outbase}`);\n if (tsconfig) flags.push(`--tsconfig=${tsconfig}`);\n if (packages) flags.push(`--packages=${packages}`);\n if (resolveExtensions) {\n let values = [];\n for (let value of resolveExtensions) {\n validateStringValue(value, \"resolve extension\");\n if (value.indexOf(\",\") >= 0) throw new Error(`Invalid resolve extension: ${value}`);\n values.push(value);\n }\n flags.push(`--resolve-extensions=${values.join(\",\")}`);\n }\n if (publicPath) flags.push(`--public-path=${publicPath}`);\n if (entryNames) flags.push(`--entry-names=${entryNames}`);\n if (chunkNames) flags.push(`--chunk-names=${chunkNames}`);\n if (assetNames) flags.push(`--asset-names=${assetNames}`);\n if (mainFields) {\n let values = [];\n for (let value of mainFields) {\n validateStringValue(value, \"main field\");\n if (value.indexOf(\",\") >= 0) throw new Error(`Invalid main field: ${value}`);\n values.push(value);\n }\n flags.push(`--main-fields=${values.join(\",\")}`);\n }\n if (conditions) {\n let values = [];\n for (let value of conditions) {\n validateStringValue(value, \"condition\");\n if (value.indexOf(\",\") >= 0) throw new Error(`Invalid condition: ${value}`);\n values.push(value);\n }\n flags.push(`--conditions=${values.join(\",\")}`);\n }\n if (external) for (let name of external) flags.push(`--external:${validateStringValue(name, \"external\")}`);\n if (alias) {\n for (let old in alias) {\n if (old.indexOf(\"=\") >= 0) throw new Error(`Invalid package name in alias: ${old}`);\n flags.push(`--alias:${old}=${validateStringValue(alias[old], \"alias\", old)}`);\n }\n }\n if (banner) {\n for (let type in banner) {\n if (type.indexOf(\"=\") >= 0) throw new Error(`Invalid banner file type: ${type}`);\n flags.push(`--banner:${type}=${validateStringValue(banner[type], \"banner\", type)}`);\n }\n }\n if (footer) {\n for (let type in footer) {\n if (type.indexOf(\"=\") >= 0) throw new Error(`Invalid footer file type: ${type}`);\n flags.push(`--footer:${type}=${validateStringValue(footer[type], \"footer\", type)}`);\n }\n }\n if (inject) for (let path of inject) flags.push(`--inject:${validateStringValue(path, \"inject\")}`);\n if (loader) {\n for (let ext in loader) {\n if (ext.indexOf(\"=\") >= 0) throw new Error(`Invalid loader extension: ${ext}`);\n flags.push(`--loader:${ext}=${validateStringValue(loader[ext], \"loader\", ext)}`);\n }\n }\n if (outExtension) {\n for (let ext in outExtension) {\n if (ext.indexOf(\"=\") >= 0) throw new Error(`Invalid out extension: ${ext}`);\n flags.push(`--out-extension:${ext}=${validateStringValue(outExtension[ext], \"out extension\", ext)}`);\n }\n }\n if (entryPoints) {\n if (Array.isArray(entryPoints)) {\n for (let i = 0, n = entryPoints.length; i < n; i++) {\n let entryPoint = entryPoints[i];\n if (typeof entryPoint === \"object\" && entryPoint !== null) {\n let entryPointKeys = /* @__PURE__ */ Object.create(null);\n let input = getFlag(entryPoint, entryPointKeys, \"in\", mustBeString);\n let output = getFlag(entryPoint, entryPointKeys, \"out\", mustBeString);\n checkForInvalidFlags(entryPoint, entryPointKeys, \"in entry point at index \" + i);\n if (input === void 0) throw new Error('Missing property \"in\" for entry point at index ' + i);\n if (output === void 0) throw new Error('Missing property \"out\" for entry point at index ' + i);\n entries.push([output, input]);\n } else {\n entries.push([\"\", validateStringValue(entryPoint, \"entry point at index \" + i)]);\n }\n }\n } else {\n for (let key in entryPoints) {\n entries.push([key, validateStringValue(entryPoints[key], \"entry point\", key)]);\n }\n }\n }\n if (stdin) {\n let stdinKeys = /* @__PURE__ */ Object.create(null);\n let contents = getFlag(stdin, stdinKeys, \"contents\", mustBeStringOrUint8Array);\n let resolveDir = getFlag(stdin, stdinKeys, \"resolveDir\", mustBeString);\n let sourcefile = getFlag(stdin, stdinKeys, \"sourcefile\", mustBeString);\n let loader2 = getFlag(stdin, stdinKeys, \"loader\", mustBeString);\n checkForInvalidFlags(stdin, stdinKeys, 'in \"stdin\" object');\n if (sourcefile) flags.push(`--sourcefile=${sourcefile}`);\n if (loader2) flags.push(`--loader=${loader2}`);\n if (resolveDir) stdinResolveDir = resolveDir;\n if (typeof contents === \"string\") stdinContents = encodeUTF8(contents);\n else if (contents instanceof Uint8Array) stdinContents = contents;\n }\n let nodePaths = [];\n if (nodePathsInput) {\n for (let value of nodePathsInput) {\n value += \"\";\n nodePaths.push(value);\n }\n }\n return {\n entries,\n flags,\n write,\n stdinContents,\n stdinResolveDir,\n absWorkingDir,\n nodePaths,\n mangleCache: validateMangleCache(mangleCache)\n };\n}\nfunction flagsForTransformOptions(callName, options, isTTY, logLevelDefault) {\n let flags = [];\n let keys = /* @__PURE__ */ Object.create(null);\n pushLogFlags(flags, options, keys, isTTY, logLevelDefault);\n pushCommonFlags(flags, options, keys);\n let sourcemap = getFlag(options, keys, \"sourcemap\", mustBeStringOrBoolean);\n let sourcefile = getFlag(options, keys, \"sourcefile\", mustBeString);\n let loader = getFlag(options, keys, \"loader\", mustBeString);\n let banner = getFlag(options, keys, \"banner\", mustBeString);\n let footer = getFlag(options, keys, \"footer\", mustBeString);\n let mangleCache = getFlag(options, keys, \"mangleCache\", mustBeObject);\n checkForInvalidFlags(options, keys, `in ${callName}() call`);\n if (sourcemap) flags.push(`--sourcemap=${sourcemap === true ? \"external\" : sourcemap}`);\n if (sourcefile) flags.push(`--sourcefile=${sourcefile}`);\n if (loader) flags.push(`--loader=${loader}`);\n if (banner) flags.push(`--banner=${banner}`);\n if (footer) flags.push(`--footer=${footer}`);\n return {\n flags,\n mangleCache: validateMangleCache(mangleCache)\n };\n}\nfunction createChannel(streamIn) {\n const requestCallbacksByKey = {};\n const closeData = { didClose: false, reason: \"\" };\n let responseCallbacks = {};\n let nextRequestID = 0;\n let nextBuildKey = 0;\n let stdout = new Uint8Array(16 * 1024);\n let stdoutUsed = 0;\n let readFromStdout = (chunk) => {\n let limit = stdoutUsed + chunk.length;\n if (limit > stdout.length) {\n let swap = new Uint8Array(limit * 2);\n swap.set(stdout);\n stdout = swap;\n }\n stdout.set(chunk, stdoutUsed);\n stdoutUsed += chunk.length;\n let offset = 0;\n while (offset + 4 <= stdoutUsed) {\n let length = readUInt32LE(stdout, offset);\n if (offset + 4 + length > stdoutUsed) {\n break;\n }\n offset += 4;\n handleIncomingPacket(stdout.subarray(offset, offset + length));\n offset += length;\n }\n if (offset > 0) {\n stdout.copyWithin(0, offset, stdoutUsed);\n stdoutUsed -= offset;\n }\n };\n let afterClose = (error) => {\n closeData.didClose = true;\n if (error) closeData.reason = \": \" + (error.message || error);\n const text = \"The service was stopped\" + closeData.reason;\n for (let id in responseCallbacks) {\n responseCallbacks[id](text, null);\n }\n responseCallbacks = {};\n };\n let sendRequest = (refs, value, callback) => {\n if (closeData.didClose) return callback(\"The service is no longer running\" + closeData.reason, null);\n let id = nextRequestID++;\n responseCallbacks[id] = (error, response) => {\n try {\n callback(error, response);\n } finally {\n if (refs) refs.unref();\n }\n };\n if (refs) refs.ref();\n streamIn.writeToStdin(encodePacket({ id, isRequest: true, value }));\n };\n let sendResponse = (id, value) => {\n if (closeData.didClose) throw new Error(\"The service is no longer running\" + closeData.reason);\n streamIn.writeToStdin(encodePacket({ id, isRequest: false, value }));\n };\n let handleRequest = async (id, request) => {\n try {\n if (request.command === \"ping\") {\n sendResponse(id, {});\n return;\n }\n if (typeof request.key === \"number\") {\n const requestCallbacks = requestCallbacksByKey[request.key];\n if (!requestCallbacks) {\n return;\n }\n const callback = requestCallbacks[request.command];\n if (callback) {\n await callback(id, request);\n return;\n }\n }\n throw new Error(`Invalid command: ` + request.command);\n } catch (e) {\n const errors = [extractErrorMessageV8(e, streamIn, null, void 0, \"\")];\n try {\n sendResponse(id, { errors });\n } catch (e2) {\n }\n }\n };\n let isFirstPacket = true;\n let handleIncomingPacket = (bytes) => {\n if (isFirstPacket) {\n isFirstPacket = false;\n let binaryVersion = String.fromCharCode(...bytes);\n if (binaryVersion !== \"0.24.2\") {\n throw new Error(`Cannot start service: Host version \"${\"0.24.2\"}\" does not match binary version ${quote(binaryVersion)}`);\n }\n return;\n }\n let packet = decodePacket(bytes);\n if (packet.isRequest) {\n handleRequest(packet.id, packet.value);\n } else {\n let callback = responseCallbacks[packet.id];\n delete responseCallbacks[packet.id];\n if (packet.value.error) callback(packet.value.error, {});\n else callback(null, packet.value);\n }\n };\n let buildOrContext = ({ callName, refs, options, isTTY, defaultWD, callback }) => {\n let refCount = 0;\n const buildKey = nextBuildKey++;\n const requestCallbacks = {};\n const buildRefs = {\n ref() {\n if (++refCount === 1) {\n if (refs) refs.ref();\n }\n },\n unref() {\n if (--refCount === 0) {\n delete requestCallbacksByKey[buildKey];\n if (refs) refs.unref();\n }\n }\n };\n requestCallbacksByKey[buildKey] = requestCallbacks;\n buildRefs.ref();\n buildOrContextImpl(\n callName,\n buildKey,\n sendRequest,\n sendResponse,\n buildRefs,\n streamIn,\n requestCallbacks,\n options,\n isTTY,\n defaultWD,\n (err, res) => {\n try {\n callback(err, res);\n } finally {\n buildRefs.unref();\n }\n }\n );\n };\n let transform2 = ({ callName, refs, input, options, isTTY, fs, callback }) => {\n const details = createObjectStash();\n let start = (inputPath) => {\n try {\n if (typeof input !== \"string\" && !(input instanceof Uint8Array))\n throw new Error('The input to \"transform\" must be a string or a Uint8Array');\n let {\n flags,\n mangleCache\n } = flagsForTransformOptions(callName, options, isTTY, transformLogLevelDefault);\n let request = {\n command: \"transform\",\n flags,\n inputFS: inputPath !== null,\n input: inputPath !== null ? encodeUTF8(inputPath) : typeof input === \"string\" ? encodeUTF8(input) : input\n };\n if (mangleCache) request.mangleCache = mangleCache;\n sendRequest(refs, request, (error, response) => {\n if (error) return callback(new Error(error), null);\n let errors = replaceDetailsInMessages(response.errors, details);\n let warnings = replaceDetailsInMessages(response.warnings, details);\n let outstanding = 1;\n let next = () => {\n if (--outstanding === 0) {\n let result = {\n warnings,\n code: response.code,\n map: response.map,\n mangleCache: void 0,\n legalComments: void 0\n };\n if (\"legalComments\" in response) result.legalComments = response == null ? void 0 : response.legalComments;\n if (response.mangleCache) result.mangleCache = response == null ? void 0 : response.mangleCache;\n callback(null, result);\n }\n };\n if (errors.length > 0) return callback(failureErrorWithLog(\"Transform failed\", errors, warnings), null);\n if (response.codeFS) {\n outstanding++;\n fs.readFile(response.code, (err, contents) => {\n if (err !== null) {\n callback(err, null);\n } else {\n response.code = contents;\n next();\n }\n });\n }\n if (response.mapFS) {\n outstanding++;\n fs.readFile(response.map, (err, contents) => {\n if (err !== null) {\n callback(err, null);\n } else {\n response.map = contents;\n next();\n }\n });\n }\n next();\n });\n } catch (e) {\n let flags = [];\n try {\n pushLogFlags(flags, options, {}, isTTY, transformLogLevelDefault);\n } catch (e2) {\n }\n const error = extractErrorMessageV8(e, streamIn, details, void 0, \"\");\n sendRequest(refs, { command: \"error\", flags, error }, () => {\n error.detail = details.load(error.detail);\n callback(failureErrorWithLog(\"Transform failed\", [error], []), null);\n });\n }\n };\n if ((typeof input === \"string\" || input instanceof Uint8Array) && input.length > 1024 * 1024) {\n let next = start;\n start = () => fs.writeFile(input, next);\n }\n start(null);\n };\n let formatMessages2 = ({ callName, refs, messages, options, callback }) => {\n if (!options) throw new Error(`Missing second argument in ${callName}() call`);\n let keys = {};\n let kind = getFlag(options, keys, \"kind\", mustBeString);\n let color = getFlag(options, keys, \"color\", mustBeBoolean);\n let terminalWidth = getFlag(options, keys, \"terminalWidth\", mustBeInteger);\n checkForInvalidFlags(options, keys, `in ${callName}() call`);\n if (kind === void 0) throw new Error(`Missing \"kind\" in ${callName}() call`);\n if (kind !== \"error\" && kind !== \"warning\") throw new Error(`Expected \"kind\" to be \"error\" or \"warning\" in ${callName}() call`);\n let request = {\n command: \"format-msgs\",\n messages: sanitizeMessages(messages, \"messages\", null, \"\", terminalWidth),\n isWarning: kind === \"warning\"\n };\n if (color !== void 0) request.color = color;\n if (terminalWidth !== void 0) request.terminalWidth = terminalWidth;\n sendRequest(refs, request, (error, response) => {\n if (error) return callback(new Error(error), null);\n callback(null, response.messages);\n });\n };\n let analyzeMetafile2 = ({ callName, refs, metafile, options, callback }) => {\n if (options === void 0) options = {};\n let keys = {};\n let color = getFlag(options, keys, \"color\", mustBeBoolean);\n let verbose = getFlag(options, keys, \"verbose\", mustBeBoolean);\n checkForInvalidFlags(options, keys, `in ${callName}() call`);\n let request = {\n command: \"analyze-metafile\",\n metafile\n };\n if (color !== void 0) request.color = color;\n if (verbose !== void 0) request.verbose = verbose;\n sendRequest(refs, request, (error, response) => {\n if (error) return callback(new Error(error), null);\n callback(null, response.result);\n });\n };\n return {\n readFromStdout,\n afterClose,\n service: {\n buildOrContext,\n transform: transform2,\n formatMessages: formatMessages2,\n analyzeMetafile: analyzeMetafile2\n }\n };\n}\nfunction buildOrContextImpl(callName, buildKey, sendRequest, sendResponse, refs, streamIn, requestCallbacks, options, isTTY, defaultWD, callback) {\n const details = createObjectStash();\n const isContext = callName === \"context\";\n const handleError = (e, pluginName) => {\n const flags = [];\n try {\n pushLogFlags(flags, options, {}, isTTY, buildLogLevelDefault);\n } catch (e2) {\n }\n const message = extractErrorMessageV8(e, streamIn, details, void 0, pluginName);\n sendRequest(refs, { command: \"error\", flags, error: message }, () => {\n message.detail = details.load(message.detail);\n callback(failureErrorWithLog(isContext ? \"Context failed\" : \"Build failed\", [message], []), null);\n });\n };\n let plugins;\n if (typeof options === \"object\") {\n const value = options.plugins;\n if (value !== void 0) {\n if (!Array.isArray(value)) return handleError(new Error(`\"plugins\" must be an array`), \"\");\n plugins = value;\n }\n }\n if (plugins && plugins.length > 0) {\n if (streamIn.isSync) return handleError(new Error(\"Cannot use plugins in synchronous API calls\"), \"\");\n handlePlugins(\n buildKey,\n sendRequest,\n sendResponse,\n refs,\n streamIn,\n requestCallbacks,\n options,\n plugins,\n details\n ).then(\n (result) => {\n if (!result.ok) return handleError(result.error, result.pluginName);\n try {\n buildOrContextContinue(result.requestPlugins, result.runOnEndCallbacks, result.scheduleOnDisposeCallbacks);\n } catch (e) {\n handleError(e, \"\");\n }\n },\n (e) => handleError(e, \"\")\n );\n return;\n }\n try {\n buildOrContextContinue(null, (result, done) => done([], []), () => {\n });\n } catch (e) {\n handleError(e, \"\");\n }\n function buildOrContextContinue(requestPlugins, runOnEndCallbacks, scheduleOnDisposeCallbacks) {\n const writeDefault = streamIn.hasFS;\n const {\n entries,\n flags,\n write,\n stdinContents,\n stdinResolveDir,\n absWorkingDir,\n nodePaths,\n mangleCache\n } = flagsForBuildOptions(callName, options, isTTY, buildLogLevelDefault, writeDefault);\n if (write && !streamIn.hasFS) throw new Error(`The \"write\" option is unavailable in this environment`);\n const request = {\n command: \"build\",\n key: buildKey,\n entries,\n flags,\n write,\n stdinContents,\n stdinResolveDir,\n absWorkingDir: absWorkingDir || defaultWD,\n nodePaths,\n context: isContext\n };\n if (requestPlugins) request.plugins = requestPlugins;\n if (mangleCache) request.mangleCache = mangleCache;\n const buildResponseToResult = (response, callback2) => {\n const result = {\n errors: replaceDetailsInMessages(response.errors, details),\n warnings: replaceDetailsInMessages(response.warnings, details),\n outputFiles: void 0,\n metafile: void 0,\n mangleCache: void 0\n };\n const originalErrors = result.errors.slice();\n const originalWarnings = result.warnings.slice();\n if (response.outputFiles) result.outputFiles = response.outputFiles.map(convertOutputFiles);\n if (response.metafile) result.metafile = JSON.parse(response.metafile);\n if (response.mangleCache) result.mangleCache = response.mangleCache;\n if (response.writeToStdout !== void 0) console.log(decodeUTF8(response.writeToStdout).replace(/\\n$/, \"\"));\n runOnEndCallbacks(result, (onEndErrors, onEndWarnings) => {\n if (originalErrors.length > 0 || onEndErrors.length > 0) {\n const error = failureErrorWithLog(\"Build failed\", originalErrors.concat(onEndErrors), originalWarnings.concat(onEndWarnings));\n return callback2(error, null, onEndErrors, onEndWarnings);\n }\n callback2(null, result, onEndErrors, onEndWarnings);\n });\n };\n let latestResultPromise;\n let provideLatestResult;\n if (isContext)\n requestCallbacks[\"on-end\"] = (id, request2) => new Promise((resolve) => {\n buildResponseToResult(request2, (err, result, onEndErrors, onEndWarnings) => {\n const response = {\n errors: onEndErrors,\n warnings: onEndWarnings\n };\n if (provideLatestResult) provideLatestResult(err, result);\n latestResultPromise = void 0;\n provideLatestResult = void 0;\n sendResponse(id, response);\n resolve();\n });\n });\n sendRequest(refs, request, (error, response) => {\n if (error) return callback(new Error(error), null);\n if (!isContext) {\n return buildResponseToResult(response, (err, res) => {\n scheduleOnDisposeCallbacks();\n return callback(err, res);\n });\n }\n if (response.errors.length > 0) {\n return callback(failureErrorWithLog(\"Context failed\", response.errors, response.warnings), null);\n }\n let didDispose = false;\n const result = {\n rebuild: () => {\n if (!latestResultPromise) latestResultPromise = new Promise((resolve, reject) => {\n let settlePromise;\n provideLatestResult = (err, result2) => {\n if (!settlePromise) settlePromise = () => err ? reject(err) : resolve(result2);\n };\n const triggerAnotherBuild = () => {\n const request2 = {\n command: \"rebuild\",\n key: buildKey\n };\n sendRequest(refs, request2, (error2, response2) => {\n if (error2) {\n reject(new Error(error2));\n } else if (settlePromise) {\n settlePromise();\n } else {\n triggerAnotherBuild();\n }\n });\n };\n triggerAnotherBuild();\n });\n return latestResultPromise;\n },\n watch: (options2 = {}) => new Promise((resolve, reject) => {\n if (!streamIn.hasFS) throw new Error(`Cannot use the \"watch\" API in this environment`);\n const keys = {};\n checkForInvalidFlags(options2, keys, `in watch() call`);\n const request2 = {\n command: \"watch\",\n key: buildKey\n };\n sendRequest(refs, request2, (error2) => {\n if (error2) reject(new Error(error2));\n else resolve(void 0);\n });\n }),\n serve: (options2 = {}) => new Promise((resolve, reject) => {\n if (!streamIn.hasFS) throw new Error(`Cannot use the \"serve\" API in this environment`);\n const keys = {};\n const port = getFlag(options2, keys, \"port\", mustBeInteger);\n const host = getFlag(options2, keys, \"host\", mustBeString);\n const servedir = getFlag(options2, keys, \"servedir\", mustBeString);\n const keyfile = getFlag(options2, keys, \"keyfile\", mustBeString);\n const certfile = getFlag(options2, keys, \"certfile\", mustBeString);\n const fallback = getFlag(options2, keys, \"fallback\", mustBeString);\n const onRequest = getFlag(options2, keys, \"onRequest\", mustBeFunction);\n checkForInvalidFlags(options2, keys, `in serve() call`);\n const request2 = {\n command: \"serve\",\n key: buildKey,\n onRequest: !!onRequest\n };\n if (port !== void 0) request2.port = port;\n if (host !== void 0) request2.host = host;\n if (servedir !== void 0) request2.servedir = servedir;\n if (keyfile !== void 0) request2.keyfile = keyfile;\n if (certfile !== void 0) request2.certfile = certfile;\n if (fallback !== void 0) request2.fallback = fallback;\n sendRequest(refs, request2, (error2, response2) => {\n if (error2) return reject(new Error(error2));\n if (onRequest) {\n requestCallbacks[\"serve-request\"] = (id, request3) => {\n onRequest(request3.args);\n sendResponse(id, {});\n };\n }\n resolve(response2);\n });\n }),\n cancel: () => new Promise((resolve) => {\n if (didDispose) return resolve();\n const request2 = {\n command: \"cancel\",\n key: buildKey\n };\n sendRequest(refs, request2, () => {\n resolve();\n });\n }),\n dispose: () => new Promise((resolve) => {\n if (didDispose) return resolve();\n didDispose = true;\n const request2 = {\n command: \"dispose\",\n key: buildKey\n };\n sendRequest(refs, request2, () => {\n resolve();\n scheduleOnDisposeCallbacks();\n refs.unref();\n });\n })\n };\n refs.ref();\n callback(null, result);\n });\n }\n}\nvar handlePlugins = async (buildKey, sendRequest, sendResponse, refs, streamIn, requestCallbacks, initialOptions, plugins, details) => {\n let onStartCallbacks = [];\n let onEndCallbacks = [];\n let onResolveCallbacks = {};\n let onLoadCallbacks = {};\n let onDisposeCallbacks = [];\n let nextCallbackID = 0;\n let i = 0;\n let requestPlugins = [];\n let isSetupDone = false;\n plugins = [...plugins];\n for (let item of plugins) {\n let keys = {};\n if (typeof item !== \"object\") throw new Error(`Plugin at index ${i} must be an object`);\n const name = getFlag(item, keys, \"name\", mustBeString);\n if (typeof name !== \"string\" || name === \"\") throw new Error(`Plugin at index ${i} is missing a name`);\n try {\n let setup = getFlag(item, keys, \"setup\", mustBeFunction);\n if (typeof setup !== \"function\") throw new Error(`Plugin is missing a setup function`);\n checkForInvalidFlags(item, keys, `on plugin ${quote(name)}`);\n let plugin = {\n name,\n onStart: false,\n onEnd: false,\n onResolve: [],\n onLoad: []\n };\n i++;\n let resolve = (path, options = {}) => {\n if (!isSetupDone) throw new Error('Cannot call \"resolve\" before plugin setup has completed');\n if (typeof path !== \"string\") throw new Error(`The path to resolve must be a string`);\n let keys2 = /* @__PURE__ */ Object.create(null);\n let pluginName = getFlag(options, keys2, \"pluginName\", mustBeString);\n let importer = getFlag(options, keys2, \"importer\", mustBeString);\n let namespace = getFlag(options, keys2, \"namespace\", mustBeString);\n let resolveDir = getFlag(options, keys2, \"resolveDir\", mustBeString);\n let kind = getFlag(options, keys2, \"kind\", mustBeString);\n let pluginData = getFlag(options, keys2, \"pluginData\", canBeAnything);\n let importAttributes = getFlag(options, keys2, \"with\", mustBeObject);\n checkForInvalidFlags(options, keys2, \"in resolve() call\");\n return new Promise((resolve2, reject) => {\n const request = {\n command: \"resolve\",\n path,\n key: buildKey,\n pluginName: name\n };\n if (pluginName != null) request.pluginName = pluginName;\n if (importer != null) request.importer = importer;\n if (namespace != null) request.namespace = namespace;\n if (resolveDir != null) request.resolveDir = resolveDir;\n if (kind != null) request.kind = kind;\n else throw new Error(`Must specify \"kind\" when calling \"resolve\"`);\n if (pluginData != null) request.pluginData = details.store(pluginData);\n if (importAttributes != null) request.with = sanitizeStringMap(importAttributes, \"with\");\n sendRequest(refs, request, (error, response) => {\n if (error !== null) reject(new Error(error));\n else resolve2({\n errors: replaceDetailsInMessages(response.errors, details),\n warnings: replaceDetailsInMessages(response.warnings, details),\n path: response.path,\n external: response.external,\n sideEffects: response.sideEffects,\n namespace: response.namespace,\n suffix: response.suffix,\n pluginData: details.load(response.pluginData)\n });\n });\n });\n };\n let promise = setup({\n initialOptions,\n resolve,\n onStart(callback) {\n let registeredText = `This error came from the \"onStart\" callback registered here:`;\n let registeredNote = extractCallerV8(new Error(registeredText), streamIn, \"onStart\");\n onStartCallbacks.push({ name, callback, note: registeredNote });\n plugin.onStart = true;\n },\n onEnd(callback) {\n let registeredText = `This error came from the \"onEnd\" callback registered here:`;\n let registeredNote = extractCallerV8(new Error(registeredText), streamIn, \"onEnd\");\n onEndCallbacks.push({ name, callback, note: registeredNote });\n plugin.onEnd = true;\n },\n onResolve(options, callback) {\n let registeredText = `This error came from the \"onResolve\" callback registered here:`;\n let registeredNote = extractCallerV8(new Error(registeredText), streamIn, \"onResolve\");\n let keys2 = {};\n let filter = getFlag(options, keys2, \"filter\", mustBeRegExp);\n let namespace = getFlag(options, keys2, \"namespace\", mustBeString);\n checkForInvalidFlags(options, keys2, `in onResolve() call for plugin ${quote(name)}`);\n if (filter == null) throw new Error(`onResolve() call is missing a filter`);\n let id = nextCallbackID++;\n onResolveCallbacks[id] = { name, callback, note: registeredNote };\n plugin.onResolve.push({ id, filter: filter.source, namespace: namespace || \"\" });\n },\n onLoad(options, callback) {\n let registeredText = `This error came from the \"onLoad\" callback registered here:`;\n let registeredNote = extractCallerV8(new Error(registeredText), streamIn, \"onLoad\");\n let keys2 = {};\n let filter = getFlag(options, keys2, \"filter\", mustBeRegExp);\n let namespace = getFlag(options, keys2, \"namespace\", mustBeString);\n checkForInvalidFlags(options, keys2, `in onLoad() call for plugin ${quote(name)}`);\n if (filter == null) throw new Error(`onLoad() call is missing a filter`);\n let id = nextCallbackID++;\n onLoadCallbacks[id] = { name, callback, note: registeredNote };\n plugin.onLoad.push({ id, filter: filter.source, namespace: namespace || \"\" });\n },\n onDispose(callback) {\n onDisposeCallbacks.push(callback);\n },\n esbuild: streamIn.esbuild\n });\n if (promise) await promise;\n requestPlugins.push(plugin);\n } catch (e) {\n return { ok: false, error: e, pluginName: name };\n }\n }\n requestCallbacks[\"on-start\"] = async (id, request) => {\n details.clear();\n let response = { errors: [], warnings: [] };\n await Promise.all(onStartCallbacks.map(async ({ name, callback, note }) => {\n try {\n let result = await callback();\n if (result != null) {\n if (typeof result !== \"object\") throw new Error(`Expected onStart() callback in plugin ${quote(name)} to return an object`);\n let keys = {};\n let errors = getFlag(result, keys, \"errors\", mustBeArray);\n let warnings = getFlag(result, keys, \"warnings\", mustBeArray);\n checkForInvalidFlags(result, keys, `from onStart() callback in plugin ${quote(name)}`);\n if (errors != null) response.errors.push(...sanitizeMessages(errors, \"errors\", details, name, void 0));\n if (warnings != null) response.warnings.push(...sanitizeMessages(warnings, \"warnings\", details, name, void 0));\n }\n } catch (e) {\n response.errors.push(extractErrorMessageV8(e, streamIn, details, note && note(), name));\n }\n }));\n sendResponse(id, response);\n };\n requestCallbacks[\"on-resolve\"] = async (id, request) => {\n let response = {}, name = \"\", callback, note;\n for (let id2 of request.ids) {\n try {\n ({ name, callback, note } = onResolveCallbacks[id2]);\n let result = await callback({\n path: request.path,\n importer: request.importer,\n namespace: request.namespace,\n resolveDir: request.resolveDir,\n kind: request.kind,\n pluginData: details.load(request.pluginData),\n with: request.with\n });\n if (result != null) {\n if (typeof result !== \"object\") throw new Error(`Expected onResolve() callback in plugin ${quote(name)} to return an object`);\n let keys = {};\n let pluginName = getFlag(result, keys, \"pluginName\", mustBeString);\n let path = getFlag(result, keys, \"path\", mustBeString);\n let namespace = getFlag(result, keys, \"namespace\", mustBeString);\n let suffix = getFlag(result, keys, \"suffix\", mustBeString);\n let external = getFlag(result, keys, \"external\", mustBeBoolean);\n let sideEffects = getFlag(result, keys, \"sideEffects\", mustBeBoolean);\n let pluginData = getFlag(result, keys, \"pluginData\", canBeAnything);\n let errors = getFlag(result, keys, \"errors\", mustBeArray);\n let warnings = getFlag(result, keys, \"warnings\", mustBeArray);\n let watchFiles = getFlag(result, keys, \"watchFiles\", mustBeArray);\n let watchDirs = getFlag(result, keys, \"watchDirs\", mustBeArray);\n checkForInvalidFlags(result, keys, `from onResolve() callback in plugin ${quote(name)}`);\n response.id = id2;\n if (pluginName != null) response.pluginName = pluginName;\n if (path != null) response.path = path;\n if (namespace != null) response.namespace = namespace;\n if (suffix != null) response.suffix = suffix;\n if (external != null) response.external = external;\n if (sideEffects != null) response.sideEffects = sideEffects;\n if (pluginData != null) response.pluginData = details.store(pluginData);\n if (errors != null) response.errors = sanitizeMessages(errors, \"errors\", details, name, void 0);\n if (warnings != null) response.warnings = sanitizeMessages(warnings, \"warnings\", details, name, void 0);\n if (watchFiles != null) response.watchFiles = sanitizeStringArray(watchFiles, \"watchFiles\");\n if (watchDirs != null) response.watchDirs = sanitizeStringArray(watchDirs, \"watchDirs\");\n break;\n }\n } catch (e) {\n response = { id: id2, errors: [extractErrorMessageV8(e, streamIn, details, note && note(), name)] };\n break;\n }\n }\n sendResponse(id, response);\n };\n requestCallbacks[\"on-load\"] = async (id, request) => {\n let response = {}, name = \"\", callback, note;\n for (let id2 of request.ids) {\n try {\n ({ name, callback, note } = onLoadCallbacks[id2]);\n let result = await callback({\n path: request.path,\n namespace: request.namespace,\n suffix: request.suffix,\n pluginData: details.load(request.pluginData),\n with: request.with\n });\n if (result != null) {\n if (typeof result !== \"object\") throw new Error(`Expected onLoad() callback in plugin ${quote(name)} to return an object`);\n let keys = {};\n let pluginName = getFlag(result, keys, \"pluginName\", mustBeString);\n let contents = getFlag(result, keys, \"contents\", mustBeStringOrUint8Array);\n let resolveDir = getFlag(result, keys, \"resolveDir\", mustBeString);\n let pluginData = getFlag(result, keys, \"pluginData\", canBeAnything);\n let loader = getFlag(result, keys, \"loader\", mustBeString);\n let errors = getFlag(result, keys, \"errors\", mustBeArray);\n let warnings = getFlag(result, keys, \"warnings\", mustBeArray);\n let watchFiles = getFlag(result, keys, \"watchFiles\", mustBeArray);\n let watchDirs = getFlag(result, keys, \"watchDirs\", mustBeArray);\n checkForInvalidFlags(result, keys, `from onLoad() callback in plugin ${quote(name)}`);\n response.id = id2;\n if (pluginName != null) response.pluginName = pluginName;\n if (contents instanceof Uint8Array) response.contents = contents;\n else if (contents != null) response.contents = encodeUTF8(contents);\n if (resolveDir != null) response.resolveDir = resolveDir;\n if (pluginData != null) response.pluginData = details.store(pluginData);\n if (loader != null) response.loader = loader;\n if (errors != null) response.errors = sanitizeMessages(errors, \"errors\", details, name, void 0);\n if (warnings != null) response.warnings = sanitizeMessages(warnings, \"warnings\", details, name, void 0);\n if (watchFiles != null) response.watchFiles = sanitizeStringArray(watchFiles, \"watchFiles\");\n if (watchDirs != null) response.watchDirs = sanitizeStringArray(watchDirs, \"watchDirs\");\n break;\n }\n } catch (e) {\n response = { id: id2, errors: [extractErrorMessageV8(e, streamIn, details, note && note(), name)] };\n break;\n }\n }\n sendResponse(id, response);\n };\n let runOnEndCallbacks = (result, done) => done([], []);\n if (onEndCallbacks.length > 0) {\n runOnEndCallbacks = (result, done) => {\n (async () => {\n const onEndErrors = [];\n const onEndWarnings = [];\n for (const { name, callback, note } of onEndCallbacks) {\n let newErrors;\n let newWarnings;\n try {\n const value = await callback(result);\n if (value != null) {\n if (typeof value !== \"object\") throw new Error(`Expected onEnd() callback in plugin ${quote(name)} to return an object`);\n let keys = {};\n let errors = getFlag(value, keys, \"errors\", mustBeArray);\n let warnings = getFlag(value, keys, \"warnings\", mustBeArray);\n checkForInvalidFlags(value, keys, `from onEnd() callback in plugin ${quote(name)}`);\n if (errors != null) newErrors = sanitizeMessages(errors, \"errors\", details, name, void 0);\n if (warnings != null) newWarnings = sanitizeMessages(warnings, \"warnings\", details, name, void 0);\n }\n } catch (e) {\n newErrors = [extractErrorMessageV8(e, streamIn, details, note && note(), name)];\n }\n if (newErrors) {\n onEndErrors.push(...newErrors);\n try {\n result.errors.push(...newErrors);\n } catch (e) {\n }\n }\n if (newWarnings) {\n onEndWarnings.push(...newWarnings);\n try {\n result.warnings.push(...newWarnings);\n } catch (e) {\n }\n }\n }\n done(onEndErrors, onEndWarnings);\n })();\n };\n }\n let scheduleOnDisposeCallbacks = () => {\n for (const cb of onDisposeCallbacks) {\n setTimeout(() => cb(), 0);\n }\n };\n isSetupDone = true;\n return {\n ok: true,\n requestPlugins,\n runOnEndCallbacks,\n scheduleOnDisposeCallbacks\n };\n};\nfunction createObjectStash() {\n const map = /* @__PURE__ */ new Map();\n let nextID = 0;\n return {\n clear() {\n map.clear();\n },\n load(id) {\n return map.get(id);\n },\n store(value) {\n if (value === void 0) return -1;\n const id = nextID++;\n map.set(id, value);\n return id;\n }\n };\n}\nfunction extractCallerV8(e, streamIn, ident) {\n let note;\n let tried = false;\n return () => {\n if (tried) return note;\n tried = true;\n try {\n let lines = (e.stack + \"\").split(\"\\n\");\n lines.splice(1, 1);\n let location2 = parseStackLinesV8(streamIn, lines, ident);\n if (location2) {\n note = { text: e.message, location: location2 };\n return note;\n }\n } catch (e2) {\n }\n };\n}\nfunction extractErrorMessageV8(e, streamIn, stash, note, pluginName) {\n let text = \"Internal error\";\n let location2 = null;\n try {\n text = (e && e.message || e) + \"\";\n } catch (e2) {\n }\n try {\n location2 = parseStackLinesV8(streamIn, (e.stack + \"\").split(\"\\n\"), \"\");\n } catch (e2) {\n }\n return { id: \"\", pluginName, text, location: location2, notes: note ? [note] : [], detail: stash ? stash.store(e) : -1 };\n}\nfunction parseStackLinesV8(streamIn, lines, ident) {\n let at = \" at \";\n if (streamIn.readFileSync && !lines[0].startsWith(at) && lines[1].startsWith(at)) {\n for (let i = 1; i < lines.length; i++) {\n let line = lines[i];\n if (!line.startsWith(at)) continue;\n line = line.slice(at.length);\n while (true) {\n let match = /^(?:new |async )?\\S+ \\((.*)\\)$/.exec(line);\n if (match) {\n line = match[1];\n continue;\n }\n match = /^eval at \\S+ \\((.*)\\)(?:, \\S+:\\d+:\\d+)?$/.exec(line);\n if (match) {\n line = match[1];\n continue;\n }\n match = /^(\\S+):(\\d+):(\\d+)$/.exec(line);\n if (match) {\n let contents;\n try {\n contents = streamIn.readFileSync(match[1], \"utf8\");\n } catch (e) {\n break;\n }\n let lineText = contents.split(/\\r\\n|\\r|\\n|\\u2028|\\u2029/)[+match[2] - 1] || \"\";\n let column = +match[3] - 1;\n let length = lineText.slice(column, column + ident.length) === ident ? ident.length : 0;\n return {\n file: match[1],\n namespace: \"file\",\n line: +match[2],\n column: encodeUTF8(lineText.slice(0, column)).length,\n length: encodeUTF8(lineText.slice(column, column + length)).length,\n lineText: lineText + \"\\n\" + lines.slice(1).join(\"\\n\"),\n suggestion: \"\"\n };\n }\n break;\n }\n }\n }\n return null;\n}\nfunction failureErrorWithLog(text, errors, warnings) {\n let limit = 5;\n text += errors.length < 1 ? \"\" : ` with ${errors.length} error${errors.length < 2 ? \"\" : \"s\"}:` + errors.slice(0, limit + 1).map((e, i) => {\n if (i === limit) return \"\\n...\";\n if (!e.location) return `\nerror: ${e.text}`;\n let { file, line, column } = e.location;\n let pluginText = e.pluginName ? `[plugin: ${e.pluginName}] ` : \"\";\n return `\n${file}:${line}:${column}: ERROR: ${pluginText}${e.text}`;\n }).join(\"\");\n let error = new Error(text);\n for (const [key, value] of [[\"errors\", errors], [\"warnings\", warnings]]) {\n Object.defineProperty(error, key, {\n configurable: true,\n enumerable: true,\n get: () => value,\n set: (value2) => Object.defineProperty(error, key, {\n configurable: true,\n enumerable: true,\n value: value2\n })\n });\n }\n return error;\n}\nfunction replaceDetailsInMessages(messages, stash) {\n for (const message of messages) {\n message.detail = stash.load(message.detail);\n }\n return messages;\n}\nfunction sanitizeLocation(location2, where, terminalWidth) {\n if (location2 == null) return null;\n let keys = {};\n let file = getFlag(location2, keys, \"file\", mustBeString);\n let namespace = getFlag(location2, keys, \"namespace\", mustBeString);\n let line = getFlag(location2, keys, \"line\", mustBeInteger);\n let column = getFlag(location2, keys, \"column\", mustBeInteger);\n let length = getFlag(location2, keys, \"length\", mustBeInteger);\n let lineText = getFlag(location2, keys, \"lineText\", mustBeString);\n let suggestion = getFlag(location2, keys, \"suggestion\", mustBeString);\n checkForInvalidFlags(location2, keys, where);\n if (lineText) {\n const relevantASCII = lineText.slice(\n 0,\n (column && column > 0 ? column : 0) + (length && length > 0 ? length : 0) + (terminalWidth && terminalWidth > 0 ? terminalWidth : 80)\n );\n if (!/[\\x7F-\\uFFFF]/.test(relevantASCII) && !/\\n/.test(lineText)) {\n lineText = relevantASCII;\n }\n }\n return {\n file: file || \"\",\n namespace: namespace || \"\",\n line: line || 0,\n column: column || 0,\n length: length || 0,\n lineText: lineText || \"\",\n suggestion: suggestion || \"\"\n };\n}\nfunction sanitizeMessages(messages, property, stash, fallbackPluginName, terminalWidth) {\n let messagesClone = [];\n let index = 0;\n for (const message of messages) {\n let keys = {};\n let id = getFlag(message, keys, \"id\", mustBeString);\n let pluginName = getFlag(message, keys, \"pluginName\", mustBeString);\n let text = getFlag(message, keys, \"text\", mustBeString);\n let location2 = getFlag(message, keys, \"location\", mustBeObjectOrNull);\n let notes = getFlag(message, keys, \"notes\", mustBeArray);\n let detail = getFlag(message, keys, \"detail\", canBeAnything);\n let where = `in element ${index} of \"${property}\"`;\n checkForInvalidFlags(message, keys, where);\n let notesClone = [];\n if (notes) {\n for (const note of notes) {\n let noteKeys = {};\n let noteText = getFlag(note, noteKeys, \"text\", mustBeString);\n let noteLocation = getFlag(note, noteKeys, \"location\", mustBeObjectOrNull);\n checkForInvalidFlags(note, noteKeys, where);\n notesClone.push({\n text: noteText || \"\",\n location: sanitizeLocation(noteLocation, where, terminalWidth)\n });\n }\n }\n messagesClone.push({\n id: id || \"\",\n pluginName: pluginName || fallbackPluginName,\n text: text || \"\",\n location: sanitizeLocation(location2, where, terminalWidth),\n notes: notesClone,\n detail: stash ? stash.store(detail) : -1\n });\n index++;\n }\n return messagesClone;\n}\nfunction sanitizeStringArray(values, property) {\n const result = [];\n for (const value of values) {\n if (typeof value !== \"string\") throw new Error(`${quote(property)} must be an array of strings`);\n result.push(value);\n }\n return result;\n}\nfunction sanitizeStringMap(map, property) {\n const result = /* @__PURE__ */ Object.create(null);\n for (const key in map) {\n const value = map[key];\n if (typeof value !== \"string\") throw new Error(`key ${quote(key)} in object ${quote(property)} must be a string`);\n result[key] = value;\n }\n return result;\n}\nfunction convertOutputFiles({ path, contents, hash }) {\n let text = null;\n return {\n path,\n contents,\n hash,\n get text() {\n const binary = this.contents;\n if (text === null || binary !== contents) {\n contents = binary;\n text = decodeUTF8(binary);\n }\n return text;\n }\n };\n}\n\n// lib/npm/browser.ts\nvar version = \"0.24.2\";\nvar build = (options) => ensureServiceIsRunning().build(options);\nvar context = (options) => ensureServiceIsRunning().context(options);\nvar transform = (input, options) => ensureServiceIsRunning().transform(input, options);\nvar formatMessages = (messages, options) => ensureServiceIsRunning().formatMessages(messages, options);\nvar analyzeMetafile = (metafile, options) => ensureServiceIsRunning().analyzeMetafile(metafile, options);\nvar buildSync = () => {\n throw new Error(`The \"buildSync\" API only works in node`);\n};\nvar transformSync = () => {\n throw new Error(`The \"transformSync\" API only works in node`);\n};\nvar formatMessagesSync = () => {\n throw new Error(`The \"formatMessagesSync\" API only works in node`);\n};\nvar analyzeMetafileSync = () => {\n throw new Error(`The \"analyzeMetafileSync\" API only works in node`);\n};\nvar stop = () => {\n if (stopService) stopService();\n return Promise.resolve();\n};\nvar initializePromise;\nvar stopService;\nvar longLivedService;\nvar ensureServiceIsRunning = () => {\n if (longLivedService) return longLivedService;\n if (initializePromise) throw new Error('You need to wait for the promise returned from \"initialize\" to be resolved before calling this');\n throw new Error('You need to call \"initialize\" before calling this');\n};\nvar initialize = (options) => {\n options = validateInitializeOptions(options || {});\n let wasmURL = options.wasmURL;\n let wasmModule = options.wasmModule;\n let useWorker = options.worker !== false;\n if (!wasmURL && !wasmModule) throw new Error('Must provide either the \"wasmURL\" option or the \"wasmModule\" option');\n if (initializePromise) throw new Error('Cannot call \"initialize\" more than once');\n initializePromise = startRunningService(wasmURL || \"\", wasmModule, useWorker);\n initializePromise.catch(() => {\n initializePromise = void 0;\n });\n return initializePromise;\n};\nvar startRunningService = async (wasmURL, wasmModule, useWorker) => {\n let worker;\n let rejectAllWith;\n const rejectAllPromise = new Promise((resolve) => rejectAllWith = resolve);\n if (useWorker) {\n let blob = new Blob([`onmessage=${'((postMessage) => {\\n // Copyright 2018 The Go Authors. All rights reserved.\\n // Use of this source code is governed by a BSD-style\\n // license that can be found in the LICENSE file.\\n let onmessage;\\n let globalThis = {};\\n for (let o = self; o; o = Object.getPrototypeOf(o))\\n for (let k of Object.getOwnPropertyNames(o))\\n if (!(k in globalThis))\\n Object.defineProperty(globalThis, k, { get: () => self[k] });\\n \"use strict\";\\n (() => {\\n const enosys = () => {\\n const err = new Error(\"not implemented\");\\n err.code = \"ENOSYS\";\\n return err;\\n };\\n if (!globalThis.fs) {\\n let outputBuf = \"\";\\n globalThis.fs = {\\n constants: { O_WRONLY: -1, O_RDWR: -1, O_CREAT: -1, O_TRUNC: -1, O_APPEND: -1, O_EXCL: -1 },\\n // unused\\n writeSync(fd, buf) {\\n outputBuf += decoder.decode(buf);\\n const nl = outputBuf.lastIndexOf(\"\\\\n\");\\n if (nl != -1) {\\n console.log(outputBuf.substring(0, nl));\\n outputBuf = outputBuf.substring(nl + 1);\\n }\\n return buf.length;\\n },\\n write(fd, buf, offset, length, position, callback) {\\n if (offset !== 0 || length !== buf.length || position !== null) {\\n callback(enosys());\\n return;\\n }\\n const n = this.writeSync(fd, buf);\\n callback(null, n);\\n },\\n chmod(path, mode, callback) {\\n callback(enosys());\\n },\\n chown(path, uid, gid, callback) {\\n callback(enosys());\\n },\\n close(fd, callback) {\\n callback(enosys());\\n },\\n fchmod(fd, mode, callback) {\\n callback(enosys());\\n },\\n fchown(fd, uid, gid, callback) {\\n callback(enosys());\\n },\\n fstat(fd, callback) {\\n callback(enosys());\\n },\\n fsync(fd, callback) {\\n callback(null);\\n },\\n ftruncate(fd, length, callback) {\\n callback(enosys());\\n },\\n lchown(path, uid, gid, callback) {\\n callback(enosys());\\n },\\n link(path, link, callback) {\\n callback(enosys());\\n },\\n lstat(path, callback) {\\n callback(enosys());\\n },\\n mkdir(path, perm, callback) {\\n callback(enosys());\\n },\\n open(path, flags, mode, callback) {\\n callback(enosys());\\n },\\n read(fd, buffer, offset, length, position, callback) {\\n callback(enosys());\\n },\\n readdir(path, callback) {\\n callback(enosys());\\n },\\n readlink(path, callback) {\\n callback(enosys());\\n },\\n rename(from, to, callback) {\\n callback(enosys());\\n },\\n rmdir(path, callback) {\\n callback(enosys());\\n },\\n stat(path, callback) {\\n callback(enosys());\\n },\\n symlink(path, link, callback) {\\n callback(enosys());\\n },\\n truncate(path, length, callback) {\\n callback(enosys());\\n },\\n unlink(path, callback) {\\n callback(enosys());\\n },\\n utimes(path, atime, mtime, callback) {\\n callback(enosys());\\n }\\n };\\n }\\n if (!globalThis.process) {\\n globalThis.process = {\\n getuid() {\\n return -1;\\n },\\n getgid() {\\n return -1;\\n },\\n geteuid() {\\n return -1;\\n },\\n getegid() {\\n return -1;\\n },\\n getgroups() {\\n throw enosys();\\n },\\n pid: -1,\\n ppid: -1,\\n umask() {\\n throw enosys();\\n },\\n cwd() {\\n throw enosys();\\n },\\n chdir() {\\n throw enosys();\\n }\\n };\\n }\\n if (!globalThis.crypto) {\\n throw new Error(\"globalThis.crypto is not available, polyfill required (crypto.getRandomValues only)\");\\n }\\n if (!globalThis.performance) {\\n throw new Error(\"globalThis.performance is not available, polyfill required (performance.now only)\");\\n }\\n if (!globalThis.TextEncoder) {\\n throw new Error(\"globalThis.TextEncoder is not available, polyfill required\");\\n }\\n if (!globalThis.TextDecoder) {\\n throw new Error(\"globalThis.TextDecoder is not available, polyfill required\");\\n }\\n const encoder = new TextEncoder(\"utf-8\");\\n const decoder = new TextDecoder(\"utf-8\");\\n globalThis.Go = class {\\n constructor() {\\n this.argv = [\"js\"];\\n this.env = {};\\n this.exit = (code) => {\\n if (code !== 0) {\\n console.warn(\"exit code:\", code);\\n }\\n };\\n this._exitPromise = new Promise((resolve) => {\\n this._resolveExitPromise = resolve;\\n });\\n this._pendingEvent = null;\\n this._scheduledTimeouts = /* @__PURE__ */ new Map();\\n this._nextCallbackTimeoutID = 1;\\n const setInt64 = (addr, v) => {\\n this.mem.setUint32(addr + 0, v, true);\\n this.mem.setUint32(addr + 4, Math.floor(v / 4294967296), true);\\n };\\n const setInt32 = (addr, v) => {\\n this.mem.setUint32(addr + 0, v, true);\\n };\\n const getInt64 = (addr) => {\\n const low = this.mem.getUint32(addr + 0, true);\\n const high = this.mem.getInt32(addr + 4, true);\\n return low + high * 4294967296;\\n };\\n const loadValue = (addr) => {\\n const f = this.mem.getFloat64(addr, true);\\n if (f === 0) {\\n return void 0;\\n }\\n if (!isNaN(f)) {\\n return f;\\n }\\n const id = this.mem.getUint32(addr, true);\\n return this._values[id];\\n };\\n const storeValue = (addr, v) => {\\n const nanHead = 2146959360;\\n if (typeof v === \"number\" && v !== 0) {\\n if (isNaN(v)) {\\n this.mem.setUint32(addr + 4, nanHead, true);\\n this.mem.setUint32(addr, 0, true);\\n return;\\n }\\n this.mem.setFloat64(addr, v, true);\\n return;\\n }\\n if (v === void 0) {\\n this.mem.setFloat64(addr, 0, true);\\n return;\\n }\\n let id = this._ids.get(v);\\n if (id === void 0) {\\n id = this._idPool.pop();\\n if (id === void 0) {\\n id = this._values.length;\\n }\\n this._values[id] = v;\\n this._goRefCounts[id] = 0;\\n this._ids.set(v, id);\\n }\\n this._goRefCounts[id]++;\\n let typeFlag = 0;\\n switch (typeof v) {\\n case \"object\":\\n if (v !== null) {\\n typeFlag = 1;\\n }\\n break;\\n case \"string\":\\n typeFlag = 2;\\n break;\\n case \"symbol\":\\n typeFlag = 3;\\n break;\\n case \"function\":\\n typeFlag = 4;\\n break;\\n }\\n this.mem.setUint32(addr + 4, nanHead | typeFlag, true);\\n this.mem.setUint32(addr, id, true);\\n };\\n const loadSlice = (addr) => {\\n const array = getInt64(addr + 0);\\n const len = getInt64(addr + 8);\\n return new Uint8Array(this._inst.exports.mem.buffer, array, len);\\n };\\n const loadSliceOfValues = (addr) => {\\n const array = getInt64(addr + 0);\\n const len = getInt64(addr + 8);\\n const a = new Array(len);\\n for (let i = 0; i < len; i++) {\\n a[i] = loadValue(array + i * 8);\\n }\\n return a;\\n };\\n const loadString = (addr) => {\\n const saddr = getInt64(addr + 0);\\n const len = getInt64(addr + 8);\\n return decoder.decode(new DataView(this._inst.exports.mem.buffer, saddr, len));\\n };\\n const timeOrigin = Date.now() - performance.now();\\n this.importObject = {\\n _gotest: {\\n add: (a, b) => a + b\\n },\\n gojs: {\\n // Go\\'s SP does not change as long as no Go code is running. Some operations (e.g. calls, getters and setters)\\n // may synchronously trigger a Go event handler. This makes Go code get executed in the middle of the imported\\n // function. A goroutine can switch to a new stack if the current stack is too small (see morestack function).\\n // This changes the SP, thus we have to update the SP used by the imported function.\\n // func wasmExit(code int32)\\n \"runtime.wasmExit\": (sp) => {\\n sp >>>= 0;\\n const code = this.mem.getInt32(sp + 8, true);\\n this.exited = true;\\n delete this._inst;\\n delete this._values;\\n delete this._goRefCounts;\\n delete this._ids;\\n delete this._idPool;\\n this.exit(code);\\n },\\n // func wasmWrite(fd uintptr, p unsafe.Pointer, n int32)\\n \"runtime.wasmWrite\": (sp) => {\\n sp >>>= 0;\\n const fd = getInt64(sp + 8);\\n const p = getInt64(sp + 16);\\n const n = this.mem.getInt32(sp + 24, true);\\n globalThis.fs.writeSync(fd, new Uint8Array(this._inst.exports.mem.buffer, p, n));\\n },\\n // func resetMemoryDataView()\\n \"runtime.resetMemoryDataView\": (sp) => {\\n sp >>>= 0;\\n this.mem = new DataView(this._inst.exports.mem.buffer);\\n },\\n // func nanotime1() int64\\n \"runtime.nanotime1\": (sp) => {\\n sp >>>= 0;\\n setInt64(sp + 8, (timeOrigin + performance.now()) * 1e6);\\n },\\n // func walltime() (sec int64, nsec int32)\\n \"runtime.walltime\": (sp) => {\\n sp >>>= 0;\\n const msec = (/* @__PURE__ */ new Date()).getTime();\\n setInt64(sp + 8, msec / 1e3);\\n this.mem.setInt32(sp + 16, msec % 1e3 * 1e6, true);\\n },\\n // func scheduleTimeoutEvent(delay int64) int32\\n \"runtime.scheduleTimeoutEvent\": (sp) => {\\n sp >>>= 0;\\n const id = this._nextCallbackTimeoutID;\\n this._nextCallbackTimeoutID++;\\n this._scheduledTimeouts.set(id, setTimeout(\\n () => {\\n this._resume();\\n while (this._scheduledTimeouts.has(id)) {\\n console.warn(\"scheduleTimeoutEvent: missed timeout event\");\\n this._resume();\\n }\\n },\\n getInt64(sp + 8)\\n ));\\n this.mem.setInt32(sp + 16, id, true);\\n },\\n // func clearTimeoutEvent(id int32)\\n \"runtime.clearTimeoutEvent\": (sp) => {\\n sp >>>= 0;\\n const id = this.mem.getInt32(sp + 8, true);\\n clearTimeout(this._scheduledTimeouts.get(id));\\n this._scheduledTimeouts.delete(id);\\n },\\n // func getRandomData(r []byte)\\n \"runtime.getRandomData\": (sp) => {\\n sp >>>= 0;\\n crypto.getRandomValues(loadSlice(sp + 8));\\n },\\n // func finalizeRef(v ref)\\n \"syscall/js.finalizeRef\": (sp) => {\\n sp >>>= 0;\\n const id = this.mem.getUint32(sp + 8, true);\\n this._goRefCounts[id]--;\\n if (this._goRefCounts[id] === 0) {\\n const v = this._values[id];\\n this._values[id] = null;\\n this._ids.delete(v);\\n this._idPool.push(id);\\n }\\n },\\n // func stringVal(value string) ref\\n \"syscall/js.stringVal\": (sp) => {\\n sp >>>= 0;\\n storeValue(sp + 24, loadString(sp + 8));\\n },\\n // func valueGet(v ref, p string) ref\\n \"syscall/js.valueGet\": (sp) => {\\n sp >>>= 0;\\n const result = Reflect.get(loadValue(sp + 8), loadString(sp + 16));\\n sp = this._inst.exports.getsp() >>> 0;\\n storeValue(sp + 32, result);\\n },\\n // func valueSet(v ref, p string, x ref)\\n \"syscall/js.valueSet\": (sp) => {\\n sp >>>= 0;\\n Reflect.set(loadValue(sp + 8), loadString(sp + 16), loadValue(sp + 32));\\n },\\n // func valueDelete(v ref, p string)\\n \"syscall/js.valueDelete\": (sp) => {\\n sp >>>= 0;\\n Reflect.deleteProperty(loadValue(sp + 8), loadString(sp + 16));\\n },\\n // func valueIndex(v ref, i int) ref\\n \"syscall/js.valueIndex\": (sp) => {\\n sp >>>= 0;\\n storeValue(sp + 24, Reflect.get(loadValue(sp + 8), getInt64(sp + 16)));\\n },\\n // valueSetIndex(v ref, i int, x ref)\\n \"syscall/js.valueSetIndex\": (sp) => {\\n sp >>>= 0;\\n Reflect.set(loadValue(sp + 8), getInt64(sp + 16), loadValue(sp + 24));\\n },\\n // func valueCall(v ref, m string, args []ref) (ref, bool)\\n \"syscall/js.valueCall\": (sp) => {\\n sp >>>= 0;\\n try {\\n const v = loadValue(sp + 8);\\n const m = Reflect.get(v, loadString(sp + 16));\\n const args = loadSliceOfValues(sp + 32);\\n const result = Reflect.apply(m, v, args);\\n sp = this._inst.exports.getsp() >>> 0;\\n storeValue(sp + 56, result);\\n this.mem.setUint8(sp + 64, 1);\\n } catch (err) {\\n sp = this._inst.exports.getsp() >>> 0;\\n storeValue(sp + 56, err);\\n this.mem.setUint8(sp + 64, 0);\\n }\\n },\\n // func valueInvoke(v ref, args []ref) (ref, bool)\\n \"syscall/js.valueInvoke\": (sp) => {\\n sp >>>= 0;\\n try {\\n const v = loadValue(sp + 8);\\n const args = loadSliceOfValues(sp + 16);\\n const result = Reflect.apply(v, void 0, args);\\n sp = this._inst.exports.getsp() >>> 0;\\n storeValue(sp + 40, result);\\n this.mem.setUint8(sp + 48, 1);\\n } catch (err) {\\n sp = this._inst.exports.getsp() >>> 0;\\n storeValue(sp + 40, err);\\n this.mem.setUint8(sp + 48, 0);\\n }\\n },\\n // func valueNew(v ref, args []ref) (ref, bool)\\n \"syscall/js.valueNew\": (sp) => {\\n sp >>>= 0;\\n try {\\n const v = loadValue(sp + 8);\\n const args = loadSliceOfValues(sp + 16);\\n const result = Reflect.construct(v, args);\\n sp = this._inst.exports.getsp() >>> 0;\\n storeValue(sp + 40, result);\\n this.mem.setUint8(sp + 48, 1);\\n } catch (err) {\\n sp = this._inst.exports.getsp() >>> 0;\\n storeValue(sp + 40, err);\\n this.mem.setUint8(sp + 48, 0);\\n }\\n },\\n // func valueLength(v ref) int\\n \"syscall/js.valueLength\": (sp) => {\\n sp >>>= 0;\\n setInt64(sp + 16, parseInt(loadValue(sp + 8).length));\\n },\\n // valuePrepareString(v ref) (ref, int)\\n \"syscall/js.valuePrepareString\": (sp) => {\\n sp >>>= 0;\\n const str = encoder.encode(String(loadValue(sp + 8)));\\n storeValue(sp + 16, str);\\n setInt64(sp + 24, str.length);\\n },\\n // valueLoadString(v ref, b []byte)\\n \"syscall/js.valueLoadString\": (sp) => {\\n sp >>>= 0;\\n const str = loadValue(sp + 8);\\n loadSlice(sp + 16).set(str);\\n },\\n // func valueInstanceOf(v ref, t ref) bool\\n \"syscall/js.valueInstanceOf\": (sp) => {\\n sp >>>= 0;\\n this.mem.setUint8(sp + 24, loadValue(sp + 8) instanceof loadValue(sp + 16) ? 1 : 0);\\n },\\n // func copyBytesToGo(dst []byte, src ref) (int, bool)\\n \"syscall/js.copyBytesToGo\": (sp) => {\\n sp >>>= 0;\\n const dst = loadSlice(sp + 8);\\n const src = loadValue(sp + 32);\\n if (!(src instanceof Uint8Array || src instanceof Uint8ClampedArray)) {\\n this.mem.setUint8(sp + 48, 0);\\n return;\\n }\\n const toCopy = src.subarray(0, dst.length);\\n dst.set(toCopy);\\n setInt64(sp + 40, toCopy.length);\\n this.mem.setUint8(sp + 48, 1);\\n },\\n // func copyBytesToJS(dst ref, src []byte) (int, bool)\\n \"syscall/js.copyBytesToJS\": (sp) => {\\n sp >>>= 0;\\n const dst = loadValue(sp + 8);\\n const src = loadSlice(sp + 16);\\n if (!(dst instanceof Uint8Array || dst instanceof Uint8ClampedArray)) {\\n this.mem.setUint8(sp + 48, 0);\\n return;\\n }\\n const toCopy = src.subarray(0, dst.length);\\n dst.set(toCopy);\\n setInt64(sp + 40, toCopy.length);\\n this.mem.setUint8(sp + 48, 1);\\n },\\n \"debug\": (value) => {\\n console.log(value);\\n }\\n }\\n };\\n }\\n async run(instance) {\\n if (!(instance instanceof WebAssembly.Instance)) {\\n throw new Error(\"Go.run: WebAssembly.Instance expected\");\\n }\\n this._inst = instance;\\n this.mem = new DataView(this._inst.exports.mem.buffer);\\n this._values = [\\n // JS values that Go currently has references to, indexed by reference id\\n NaN,\\n 0,\\n null,\\n true,\\n false,\\n globalThis,\\n this\\n ];\\n this._goRefCounts = new Array(this._values.length).fill(Infinity);\\n this._ids = /* @__PURE__ */ new Map([\\n // mapping from JS values to reference ids\\n [0, 1],\\n [null, 2],\\n [true, 3],\\n [false, 4],\\n [globalThis, 5],\\n [this, 6]\\n ]);\\n this._idPool = [];\\n this.exited = false;\\n let offset = 4096;\\n const strPtr = (str) => {\\n const ptr = offset;\\n const bytes = encoder.encode(str + \"\\\\0\");\\n new Uint8Array(this.mem.buffer, offset, bytes.length).set(bytes);\\n offset += bytes.length;\\n if (offset % 8 !== 0) {\\n offset += 8 - offset % 8;\\n }\\n return ptr;\\n };\\n const argc = this.argv.length;\\n const argvPtrs = [];\\n this.argv.forEach((arg) => {\\n argvPtrs.push(strPtr(arg));\\n });\\n argvPtrs.push(0);\\n const keys = Object.keys(this.env).sort();\\n keys.forEach((key) => {\\n argvPtrs.push(strPtr(`${key}=${this.env[key]}`));\\n });\\n argvPtrs.push(0);\\n const argv = offset;\\n argvPtrs.forEach((ptr) => {\\n this.mem.setUint32(offset, ptr, true);\\n this.mem.setUint32(offset + 4, 0, true);\\n offset += 8;\\n });\\n const wasmMinDataAddr = 4096 + 8192;\\n if (offset >= wasmMinDataAddr) {\\n throw new Error(\"total length of command line and environment variables exceeds limit\");\\n }\\n this._inst.exports.run(argc, argv);\\n if (this.exited) {\\n this._resolveExitPromise();\\n }\\n await this._exitPromise;\\n }\\n _resume() {\\n if (this.exited) {\\n throw new Error(\"Go program has already exited\");\\n }\\n this._inst.exports.resume();\\n if (this.exited) {\\n this._resolveExitPromise();\\n }\\n }\\n _makeFuncWrapper(id) {\\n const go = this;\\n return function() {\\n const event = { id, this: this, args: arguments };\\n go._pendingEvent = event;\\n go._resume();\\n return event.result;\\n };\\n }\\n };\\n })();\\n onmessage = ({ data: wasm }) => {\\n let decoder = new TextDecoder();\\n let fs = globalThis.fs;\\n let stderr = \"\";\\n fs.writeSync = (fd, buffer) => {\\n if (fd === 1) {\\n postMessage(buffer);\\n } else if (fd === 2) {\\n stderr += decoder.decode(buffer);\\n let parts = stderr.split(\"\\\\n\");\\n if (parts.length > 1) console.log(parts.slice(0, -1).join(\"\\\\n\"));\\n stderr = parts[parts.length - 1];\\n } else {\\n throw new Error(\"Bad write\");\\n }\\n return buffer.length;\\n };\\n let stdin = [];\\n let resumeStdin;\\n let stdinPos = 0;\\n onmessage = ({ data }) => {\\n if (data.length > 0) {\\n stdin.push(data);\\n if (resumeStdin) resumeStdin();\\n }\\n return go;\\n };\\n fs.read = (fd, buffer, offset, length, position, callback) => {\\n if (fd !== 0 || offset !== 0 || length !== buffer.length || position !== null) {\\n throw new Error(\"Bad read\");\\n }\\n if (stdin.length === 0) {\\n resumeStdin = () => fs.read(fd, buffer, offset, length, position, callback);\\n return;\\n }\\n let first = stdin[0];\\n let count = Math.max(0, Math.min(length, first.length - stdinPos));\\n buffer.set(first.subarray(stdinPos, stdinPos + count), offset);\\n stdinPos += count;\\n if (stdinPos === first.length) {\\n stdin.shift();\\n stdinPos = 0;\\n }\\n callback(null, count);\\n };\\n let go = new globalThis.Go();\\n go.argv = [\"\", `--service=${\"0.24.2\"}`];\\n tryToInstantiateModule(wasm, go).then(\\n (instance) => {\\n postMessage(null);\\n go.run(instance);\\n },\\n (error) => {\\n postMessage(error);\\n }\\n );\\n return go;\\n };\\n async function tryToInstantiateModule(wasm, go) {\\n if (wasm instanceof WebAssembly.Module) {\\n return WebAssembly.instantiate(wasm, go.importObject);\\n }\\n const res = await fetch(wasm);\\n if (!res.ok) throw new Error(`Failed to download ${JSON.stringify(wasm)}`);\\n if (\"instantiateStreaming\" in WebAssembly && /^application\\\\/wasm($|;)/i.test(res.headers.get(\"Content-Type\") || \"\")) {\\n const result2 = await WebAssembly.instantiateStreaming(res, go.importObject);\\n return result2.instance;\\n }\\n const bytes = await res.arrayBuffer();\\n const result = await WebAssembly.instantiate(bytes, go.importObject);\\n return result.instance;\\n }\\n return (m) => onmessage(m);\\n })'}(postMessage)`], { type: \"text/javascript\" });\n worker = new Worker(URL.createObjectURL(blob));\n } else {\n let onmessage = ((postMessage) => {\n // Copyright 2018 The Go Authors. All rights reserved.\n // Use of this source code is governed by a BSD-style\n // license that can be found in the LICENSE file.\n let onmessage;\n let globalThis = {};\n for (let o = self; o; o = Object.getPrototypeOf(o))\n for (let k of Object.getOwnPropertyNames(o))\n if (!(k in globalThis))\n Object.defineProperty(globalThis, k, { get: () => self[k] });\n \"use strict\";\n (() => {\n const enosys = () => {\n const err = new Error(\"not implemented\");\n err.code = \"ENOSYS\";\n return err;\n };\n if (!globalThis.fs) {\n let outputBuf = \"\";\n globalThis.fs = {\n constants: { O_WRONLY: -1, O_RDWR: -1, O_CREAT: -1, O_TRUNC: -1, O_APPEND: -1, O_EXCL: -1 },\n // unused\n writeSync(fd, buf) {\n outputBuf += decoder.decode(buf);\n const nl = outputBuf.lastIndexOf(\"\\n\");\n if (nl != -1) {\n console.log(outputBuf.substring(0, nl));\n outputBuf = outputBuf.substring(nl + 1);\n }\n return buf.length;\n },\n write(fd, buf, offset, length, position, callback) {\n if (offset !== 0 || length !== buf.length || position !== null) {\n callback(enosys());\n return;\n }\n const n = this.writeSync(fd, buf);\n callback(null, n);\n },\n chmod(path, mode, callback) {\n callback(enosys());\n },\n chown(path, uid, gid, callback) {\n callback(enosys());\n },\n close(fd, callback) {\n callback(enosys());\n },\n fchmod(fd, mode, callback) {\n callback(enosys());\n },\n fchown(fd, uid, gid, callback) {\n callback(enosys());\n },\n fstat(fd, callback) {\n callback(enosys());\n },\n fsync(fd, callback) {\n callback(null);\n },\n ftruncate(fd, length, callback) {\n callback(enosys());\n },\n lchown(path, uid, gid, callback) {\n callback(enosys());\n },\n link(path, link, callback) {\n callback(enosys());\n },\n lstat(path, callback) {\n callback(enosys());\n },\n mkdir(path, perm, callback) {\n callback(enosys());\n },\n open(path, flags, mode, callback) {\n callback(enosys());\n },\n read(fd, buffer, offset, length, position, callback) {\n callback(enosys());\n },\n readdir(path, callback) {\n callback(enosys());\n },\n readlink(path, callback) {\n callback(enosys());\n },\n rename(from, to, callback) {\n callback(enosys());\n },\n rmdir(path, callback) {\n callback(enosys());\n },\n stat(path, callback) {\n callback(enosys());\n },\n symlink(path, link, callback) {\n callback(enosys());\n },\n truncate(path, length, callback) {\n callback(enosys());\n },\n unlink(path, callback) {\n callback(enosys());\n },\n utimes(path, atime, mtime, callback) {\n callback(enosys());\n }\n };\n }\n if (!globalThis.process) {\n globalThis.process = {\n getuid() {\n return -1;\n },\n getgid() {\n return -1;\n },\n geteuid() {\n return -1;\n },\n getegid() {\n return -1;\n },\n getgroups() {\n throw enosys();\n },\n pid: -1,\n ppid: -1,\n umask() {\n throw enosys();\n },\n cwd() {\n throw enosys();\n },\n chdir() {\n throw enosys();\n }\n };\n }\n if (!globalThis.crypto) {\n throw new Error(\"globalThis.crypto is not available, polyfill required (crypto.getRandomValues only)\");\n }\n if (!globalThis.performance) {\n throw new Error(\"globalThis.performance is not available, polyfill required (performance.now only)\");\n }\n if (!globalThis.TextEncoder) {\n throw new Error(\"globalThis.TextEncoder is not available, polyfill required\");\n }\n if (!globalThis.TextDecoder) {\n throw new Error(\"globalThis.TextDecoder is not available, polyfill required\");\n }\n const encoder = new TextEncoder(\"utf-8\");\n const decoder = new TextDecoder(\"utf-8\");\n globalThis.Go = class {\n constructor() {\n this.argv = [\"js\"];\n this.env = {};\n this.exit = (code) => {\n if (code !== 0) {\n console.warn(\"exit code:\", code);\n }\n };\n this._exitPromise = new Promise((resolve) => {\n this._resolveExitPromise = resolve;\n });\n this._pendingEvent = null;\n this._scheduledTimeouts = /* @__PURE__ */ new Map();\n this._nextCallbackTimeoutID = 1;\n const setInt64 = (addr, v) => {\n this.mem.setUint32(addr + 0, v, true);\n this.mem.setUint32(addr + 4, Math.floor(v / 4294967296), true);\n };\n const setInt32 = (addr, v) => {\n this.mem.setUint32(addr + 0, v, true);\n };\n const getInt64 = (addr) => {\n const low = this.mem.getUint32(addr + 0, true);\n const high = this.mem.getInt32(addr + 4, true);\n return low + high * 4294967296;\n };\n const loadValue = (addr) => {\n const f = this.mem.getFloat64(addr, true);\n if (f === 0) {\n return void 0;\n }\n if (!isNaN(f)) {\n return f;\n }\n const id = this.mem.getUint32(addr, true);\n return this._values[id];\n };\n const storeValue = (addr, v) => {\n const nanHead = 2146959360;\n if (typeof v === \"number\" && v !== 0) {\n if (isNaN(v)) {\n this.mem.setUint32(addr + 4, nanHead, true);\n this.mem.setUint32(addr, 0, true);\n return;\n }\n this.mem.setFloat64(addr, v, true);\n return;\n }\n if (v === void 0) {\n this.mem.setFloat64(addr, 0, true);\n return;\n }\n let id = this._ids.get(v);\n if (id === void 0) {\n id = this._idPool.pop();\n if (id === void 0) {\n id = this._values.length;\n }\n this._values[id] = v;\n this._goRefCounts[id] = 0;\n this._ids.set(v, id);\n }\n this._goRefCounts[id]++;\n let typeFlag = 0;\n switch (typeof v) {\n case \"object\":\n if (v !== null) {\n typeFlag = 1;\n }\n break;\n case \"string\":\n typeFlag = 2;\n break;\n case \"symbol\":\n typeFlag = 3;\n break;\n case \"function\":\n typeFlag = 4;\n break;\n }\n this.mem.setUint32(addr + 4, nanHead | typeFlag, true);\n this.mem.setUint32(addr, id, true);\n };\n const loadSlice = (addr) => {\n const array = getInt64(addr + 0);\n const len = getInt64(addr + 8);\n return new Uint8Array(this._inst.exports.mem.buffer, array, len);\n };\n const loadSliceOfValues = (addr) => {\n const array = getInt64(addr + 0);\n const len = getInt64(addr + 8);\n const a = new Array(len);\n for (let i = 0; i < len; i++) {\n a[i] = loadValue(array + i * 8);\n }\n return a;\n };\n const loadString = (addr) => {\n const saddr = getInt64(addr + 0);\n const len = getInt64(addr + 8);\n return decoder.decode(new DataView(this._inst.exports.mem.buffer, saddr, len));\n };\n const timeOrigin = Date.now() - performance.now();\n this.importObject = {\n _gotest: {\n add: (a, b) => a + b\n },\n gojs: {\n // Go's SP does not change as long as no Go code is running. Some operations (e.g. calls, getters and setters)\n // may synchronously trigger a Go event handler. This makes Go code get executed in the middle of the imported\n // function. A goroutine can switch to a new stack if the current stack is too small (see morestack function).\n // This changes the SP, thus we have to update the SP used by the imported function.\n // func wasmExit(code int32)\n \"runtime.wasmExit\": (sp) => {\n sp >>>= 0;\n const code = this.mem.getInt32(sp + 8, true);\n this.exited = true;\n delete this._inst;\n delete this._values;\n delete this._goRefCounts;\n delete this._ids;\n delete this._idPool;\n this.exit(code);\n },\n // func wasmWrite(fd uintptr, p unsafe.Pointer, n int32)\n \"runtime.wasmWrite\": (sp) => {\n sp >>>= 0;\n const fd = getInt64(sp + 8);\n const p = getInt64(sp + 16);\n const n = this.mem.getInt32(sp + 24, true);\n globalThis.fs.writeSync(fd, new Uint8Array(this._inst.exports.mem.buffer, p, n));\n },\n // func resetMemoryDataView()\n \"runtime.resetMemoryDataView\": (sp) => {\n sp >>>= 0;\n this.mem = new DataView(this._inst.exports.mem.buffer);\n },\n // func nanotime1() int64\n \"runtime.nanotime1\": (sp) => {\n sp >>>= 0;\n setInt64(sp + 8, (timeOrigin + performance.now()) * 1e6);\n },\n // func walltime() (sec int64, nsec int32)\n \"runtime.walltime\": (sp) => {\n sp >>>= 0;\n const msec = (/* @__PURE__ */ new Date()).getTime();\n setInt64(sp + 8, msec / 1e3);\n this.mem.setInt32(sp + 16, msec % 1e3 * 1e6, true);\n },\n // func scheduleTimeoutEvent(delay int64) int32\n \"runtime.scheduleTimeoutEvent\": (sp) => {\n sp >>>= 0;\n const id = this._nextCallbackTimeoutID;\n this._nextCallbackTimeoutID++;\n this._scheduledTimeouts.set(id, setTimeout(\n () => {\n this._resume();\n while (this._scheduledTimeouts.has(id)) {\n console.warn(\"scheduleTimeoutEvent: missed timeout event\");\n this._resume();\n }\n },\n getInt64(sp + 8)\n ));\n this.mem.setInt32(sp + 16, id, true);\n },\n // func clearTimeoutEvent(id int32)\n \"runtime.clearTimeoutEvent\": (sp) => {\n sp >>>= 0;\n const id = this.mem.getInt32(sp + 8, true);\n clearTimeout(this._scheduledTimeouts.get(id));\n this._scheduledTimeouts.delete(id);\n },\n // func getRandomData(r []byte)\n \"runtime.getRandomData\": (sp) => {\n sp >>>= 0;\n crypto.getRandomValues(loadSlice(sp + 8));\n },\n // func finalizeRef(v ref)\n \"syscall/js.finalizeRef\": (sp) => {\n sp >>>= 0;\n const id = this.mem.getUint32(sp + 8, true);\n this._goRefCounts[id]--;\n if (this._goRefCounts[id] === 0) {\n const v = this._values[id];\n this._values[id] = null;\n this._ids.delete(v);\n this._idPool.push(id);\n }\n },\n // func stringVal(value string) ref\n \"syscall/js.stringVal\": (sp) => {\n sp >>>= 0;\n storeValue(sp + 24, loadString(sp + 8));\n },\n // func valueGet(v ref, p string) ref\n \"syscall/js.valueGet\": (sp) => {\n sp >>>= 0;\n const result = Reflect.get(loadValue(sp + 8), loadString(sp + 16));\n sp = this._inst.exports.getsp() >>> 0;\n storeValue(sp + 32, result);\n },\n // func valueSet(v ref, p string, x ref)\n \"syscall/js.valueSet\": (sp) => {\n sp >>>= 0;\n Reflect.set(loadValue(sp + 8), loadString(sp + 16), loadValue(sp + 32));\n },\n // func valueDelete(v ref, p string)\n \"syscall/js.valueDelete\": (sp) => {\n sp >>>= 0;\n Reflect.deleteProperty(loadValue(sp + 8), loadString(sp + 16));\n },\n // func valueIndex(v ref, i int) ref\n \"syscall/js.valueIndex\": (sp) => {\n sp >>>= 0;\n storeValue(sp + 24, Reflect.get(loadValue(sp + 8), getInt64(sp + 16)));\n },\n // valueSetIndex(v ref, i int, x ref)\n \"syscall/js.valueSetIndex\": (sp) => {\n sp >>>= 0;\n Reflect.set(loadValue(sp + 8), getInt64(sp + 16), loadValue(sp + 24));\n },\n // func valueCall(v ref, m string, args []ref) (ref, bool)\n \"syscall/js.valueCall\": (sp) => {\n sp >>>= 0;\n try {\n const v = loadValue(sp + 8);\n const m = Reflect.get(v, loadString(sp + 16));\n const args = loadSliceOfValues(sp + 32);\n const result = Reflect.apply(m, v, args);\n sp = this._inst.exports.getsp() >>> 0;\n storeValue(sp + 56, result);\n this.mem.setUint8(sp + 64, 1);\n } catch (err) {\n sp = this._inst.exports.getsp() >>> 0;\n storeValue(sp + 56, err);\n this.mem.setUint8(sp + 64, 0);\n }\n },\n // func valueInvoke(v ref, args []ref) (ref, bool)\n \"syscall/js.valueInvoke\": (sp) => {\n sp >>>= 0;\n try {\n const v = loadValue(sp + 8);\n const args = loadSliceOfValues(sp + 16);\n const result = Reflect.apply(v, void 0, args);\n sp = this._inst.exports.getsp() >>> 0;\n storeValue(sp + 40, result);\n this.mem.setUint8(sp + 48, 1);\n } catch (err) {\n sp = this._inst.exports.getsp() >>> 0;\n storeValue(sp + 40, err);\n this.mem.setUint8(sp + 48, 0);\n }\n },\n // func valueNew(v ref, args []ref) (ref, bool)\n \"syscall/js.valueNew\": (sp) => {\n sp >>>= 0;\n try {\n const v = loadValue(sp + 8);\n const args = loadSliceOfValues(sp + 16);\n const result = Reflect.construct(v, args);\n sp = this._inst.exports.getsp() >>> 0;\n storeValue(sp + 40, result);\n this.mem.setUint8(sp + 48, 1);\n } catch (err) {\n sp = this._inst.exports.getsp() >>> 0;\n storeValue(sp + 40, err);\n this.mem.setUint8(sp + 48, 0);\n }\n },\n // func valueLength(v ref) int\n \"syscall/js.valueLength\": (sp) => {\n sp >>>= 0;\n setInt64(sp + 16, parseInt(loadValue(sp + 8).length));\n },\n // valuePrepareString(v ref) (ref, int)\n \"syscall/js.valuePrepareString\": (sp) => {\n sp >>>= 0;\n const str = encoder.encode(String(loadValue(sp + 8)));\n storeValue(sp + 16, str);\n setInt64(sp + 24, str.length);\n },\n // valueLoadString(v ref, b []byte)\n \"syscall/js.valueLoadString\": (sp) => {\n sp >>>= 0;\n const str = loadValue(sp + 8);\n loadSlice(sp + 16).set(str);\n },\n // func valueInstanceOf(v ref, t ref) bool\n \"syscall/js.valueInstanceOf\": (sp) => {\n sp >>>= 0;\n this.mem.setUint8(sp + 24, loadValue(sp + 8) instanceof loadValue(sp + 16) ? 1 : 0);\n },\n // func copyBytesToGo(dst []byte, src ref) (int, bool)\n \"syscall/js.copyBytesToGo\": (sp) => {\n sp >>>= 0;\n const dst = loadSlice(sp + 8);\n const src = loadValue(sp + 32);\n if (!(src instanceof Uint8Array || src instanceof Uint8ClampedArray)) {\n this.mem.setUint8(sp + 48, 0);\n return;\n }\n const toCopy = src.subarray(0, dst.length);\n dst.set(toCopy);\n setInt64(sp + 40, toCopy.length);\n this.mem.setUint8(sp + 48, 1);\n },\n // func copyBytesToJS(dst ref, src []byte) (int, bool)\n \"syscall/js.copyBytesToJS\": (sp) => {\n sp >>>= 0;\n const dst = loadValue(sp + 8);\n const src = loadSlice(sp + 16);\n if (!(dst instanceof Uint8Array || dst instanceof Uint8ClampedArray)) {\n this.mem.setUint8(sp + 48, 0);\n return;\n }\n const toCopy = src.subarray(0, dst.length);\n dst.set(toCopy);\n setInt64(sp + 40, toCopy.length);\n this.mem.setUint8(sp + 48, 1);\n },\n \"debug\": (value) => {\n console.log(value);\n }\n }\n };\n }\n async run(instance) {\n if (!(instance instanceof WebAssembly.Instance)) {\n throw new Error(\"Go.run: WebAssembly.Instance expected\");\n }\n this._inst = instance;\n this.mem = new DataView(this._inst.exports.mem.buffer);\n this._values = [\n // JS values that Go currently has references to, indexed by reference id\n NaN,\n 0,\n null,\n true,\n false,\n globalThis,\n this\n ];\n this._goRefCounts = new Array(this._values.length).fill(Infinity);\n this._ids = /* @__PURE__ */ new Map([\n // mapping from JS values to reference ids\n [0, 1],\n [null, 2],\n [true, 3],\n [false, 4],\n [globalThis, 5],\n [this, 6]\n ]);\n this._idPool = [];\n this.exited = false;\n let offset = 4096;\n const strPtr = (str) => {\n const ptr = offset;\n const bytes = encoder.encode(str + \"\\0\");\n new Uint8Array(this.mem.buffer, offset, bytes.length).set(bytes);\n offset += bytes.length;\n if (offset % 8 !== 0) {\n offset += 8 - offset % 8;\n }\n return ptr;\n };\n const argc = this.argv.length;\n const argvPtrs = [];\n this.argv.forEach((arg) => {\n argvPtrs.push(strPtr(arg));\n });\n argvPtrs.push(0);\n const keys = Object.keys(this.env).sort();\n keys.forEach((key) => {\n argvPtrs.push(strPtr(`${key}=${this.env[key]}`));\n });\n argvPtrs.push(0);\n const argv = offset;\n argvPtrs.forEach((ptr) => {\n this.mem.setUint32(offset, ptr, true);\n this.mem.setUint32(offset + 4, 0, true);\n offset += 8;\n });\n const wasmMinDataAddr = 4096 + 8192;\n if (offset >= wasmMinDataAddr) {\n throw new Error(\"total length of command line and environment variables exceeds limit\");\n }\n this._inst.exports.run(argc, argv);\n if (this.exited) {\n this._resolveExitPromise();\n }\n await this._exitPromise;\n }\n _resume() {\n if (this.exited) {\n throw new Error(\"Go program has already exited\");\n }\n this._inst.exports.resume();\n if (this.exited) {\n this._resolveExitPromise();\n }\n }\n _makeFuncWrapper(id) {\n const go = this;\n return function() {\n const event = { id, this: this, args: arguments };\n go._pendingEvent = event;\n go._resume();\n return event.result;\n };\n }\n };\n })();\n onmessage = ({ data: wasm }) => {\n let decoder = new TextDecoder();\n let fs = globalThis.fs;\n let stderr = \"\";\n fs.writeSync = (fd, buffer) => {\n if (fd === 1) {\n postMessage(buffer);\n } else if (fd === 2) {\n stderr += decoder.decode(buffer);\n let parts = stderr.split(\"\\n\");\n if (parts.length > 1) console.log(parts.slice(0, -1).join(\"\\n\"));\n stderr = parts[parts.length - 1];\n } else {\n throw new Error(\"Bad write\");\n }\n return buffer.length;\n };\n let stdin = [];\n let resumeStdin;\n let stdinPos = 0;\n onmessage = ({ data }) => {\n if (data.length > 0) {\n stdin.push(data);\n if (resumeStdin) resumeStdin();\n }\n return go;\n };\n fs.read = (fd, buffer, offset, length, position, callback) => {\n if (fd !== 0 || offset !== 0 || length !== buffer.length || position !== null) {\n throw new Error(\"Bad read\");\n }\n if (stdin.length === 0) {\n resumeStdin = () => fs.read(fd, buffer, offset, length, position, callback);\n return;\n }\n let first = stdin[0];\n let count = Math.max(0, Math.min(length, first.length - stdinPos));\n buffer.set(first.subarray(stdinPos, stdinPos + count), offset);\n stdinPos += count;\n if (stdinPos === first.length) {\n stdin.shift();\n stdinPos = 0;\n }\n callback(null, count);\n };\n let go = new globalThis.Go();\n go.argv = [\"\", `--service=${\"0.24.2\"}`];\n tryToInstantiateModule(wasm, go).then(\n (instance) => {\n postMessage(null);\n go.run(instance);\n },\n (error) => {\n postMessage(error);\n }\n );\n return go;\n };\n async function tryToInstantiateModule(wasm, go) {\n if (wasm instanceof WebAssembly.Module) {\n return WebAssembly.instantiate(wasm, go.importObject);\n }\n const res = await fetch(wasm);\n if (!res.ok) throw new Error(`Failed to download ${JSON.stringify(wasm)}`);\n if (\"instantiateStreaming\" in WebAssembly && /^application\\/wasm($|;)/i.test(res.headers.get(\"Content-Type\") || \"\")) {\n const result2 = await WebAssembly.instantiateStreaming(res, go.importObject);\n return result2.instance;\n }\n const bytes = await res.arrayBuffer();\n const result = await WebAssembly.instantiate(bytes, go.importObject);\n return result.instance;\n }\n return (m) => onmessage(m);\n })((data) => worker.onmessage({ data }));\n let go;\n worker = {\n onmessage: null,\n postMessage: (data) => setTimeout(() => {\n try {\n go = onmessage({ data });\n } catch (error) {\n rejectAllWith(error);\n }\n }),\n terminate() {\n if (go)\n for (let timeout of go._scheduledTimeouts.values())\n clearTimeout(timeout);\n }\n };\n }\n let firstMessageResolve;\n let firstMessageReject;\n const firstMessagePromise = new Promise((resolve, reject) => {\n firstMessageResolve = resolve;\n firstMessageReject = reject;\n });\n worker.onmessage = ({ data: error }) => {\n worker.onmessage = ({ data }) => readFromStdout(data);\n if (error) firstMessageReject(error);\n else firstMessageResolve();\n };\n worker.postMessage(wasmModule || new URL(wasmURL, location.href).toString());\n let { readFromStdout, service } = createChannel({\n writeToStdin(bytes) {\n worker.postMessage(bytes);\n },\n isSync: false,\n hasFS: false,\n esbuild: browser_exports\n });\n await firstMessagePromise;\n stopService = () => {\n worker.terminate();\n initializePromise = void 0;\n stopService = void 0;\n longLivedService = void 0;\n };\n longLivedService = {\n build: (options) => new Promise((resolve, reject) => {\n rejectAllPromise.then(reject);\n service.buildOrContext({\n callName: \"build\",\n refs: null,\n options,\n isTTY: false,\n defaultWD: \"/\",\n callback: (err, res) => err ? reject(err) : resolve(res)\n });\n }),\n context: (options) => new Promise((resolve, reject) => {\n rejectAllPromise.then(reject);\n service.buildOrContext({\n callName: \"context\",\n refs: null,\n options,\n isTTY: false,\n defaultWD: \"/\",\n callback: (err, res) => err ? reject(err) : resolve(res)\n });\n }),\n transform: (input, options) => new Promise((resolve, reject) => {\n rejectAllPromise.then(reject);\n service.transform({\n callName: \"transform\",\n refs: null,\n input,\n options: options || {},\n isTTY: false,\n fs: {\n readFile(_, callback) {\n callback(new Error(\"Internal error\"), null);\n },\n writeFile(_, callback) {\n callback(null);\n }\n },\n callback: (err, res) => err ? reject(err) : resolve(res)\n });\n }),\n formatMessages: (messages, options) => new Promise((resolve, reject) => {\n rejectAllPromise.then(reject);\n service.formatMessages({\n callName: \"formatMessages\",\n refs: null,\n messages,\n options,\n callback: (err, res) => err ? reject(err) : resolve(res)\n });\n }),\n analyzeMetafile: (metafile, options) => new Promise((resolve, reject) => {\n rejectAllPromise.then(reject);\n service.analyzeMetafile({\n callName: \"analyzeMetafile\",\n refs: null,\n metafile: typeof metafile === \"string\" ? metafile : JSON.stringify(metafile),\n options,\n callback: (err, res) => err ? reject(err) : resolve(res)\n });\n })\n };\n};\nvar browser_default = browser_exports;\n\nreturn { analyzeMetafile, analyzeMetafileSync, build, buildSync, context, default: browser_default, formatMessages, formatMessagesSync, initialize, stop, transform, transformSync, version };\n";
|