devflare 1.0.0-next.7 → 1.0.0-next.71
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/LICENSE +21 -0
- package/LLM.md +17316 -2144
- package/README.md +398 -607
- package/bin/devflare.js +30 -14
- package/dist/_chunks/account-B9ULT9HA.js +462 -0
- package/dist/_chunks/account-resources-BdKj8q1h.js +159 -0
- package/dist/_chunks/ai-DKDn1iys.js +322 -0
- package/dist/_chunks/api-BKClUlUf.js +568 -0
- package/dist/_chunks/build-B9jQtUny.js +24 -0
- package/dist/_chunks/build-artifacts-C7AbI34o.js +484 -0
- package/dist/_chunks/cli-CBRR2-Xr.js +1214 -0
- package/dist/_chunks/cloudflare-D_5UWT84.js +157 -0
- package/dist/_chunks/colors-D0NVzAFN.js +13 -0
- package/dist/_chunks/command-utils-qlsHELwW.js +45 -0
- package/dist/_chunks/compiler-UxXQgEPq.js +521 -0
- package/dist/_chunks/config-CHdi5-5R.js +78 -0
- package/dist/_chunks/config-path-DzZbchb6.js +42 -0
- package/dist/_chunks/context-DGMev2AF.js +2515 -0
- package/dist/_chunks/decorators-eXNZ1S0N.js +19 -0
- package/dist/_chunks/dependencies-HLIhxbIe.js +57 -0
- package/dist/_chunks/deploy-dIZuouRW.js +1033 -0
- package/dist/_chunks/dev-CRW_hBA3.js +953 -0
- package/dist/_chunks/doctor-t8hKA53t.js +219 -0
- package/dist/_chunks/durable-object-DuMPM8re.js +234 -0
- package/dist/_chunks/env-D4uJqqgu.js +125 -0
- package/dist/_chunks/family-DHkROYgX.js +143 -0
- package/dist/_chunks/generated-artifacts-D_VIzDOi.js +31 -0
- package/dist/_chunks/generated-dir-DC2kM-mt.js +33 -0
- package/dist/_chunks/glob-DRw9sbfF.js +56 -0
- package/dist/_chunks/init-B9_QIZcO.js +165 -0
- package/dist/_chunks/loader-BC0skbnH.js +1330 -0
- package/dist/_chunks/local-dev-vars-BFLS-HoI.js +81 -0
- package/dist/_chunks/local-hyperdrive-CcORzo76.js +119 -0
- package/dist/_chunks/local-media-bindings-ZQe-epuw.js +335 -0
- package/dist/_chunks/local-secrets-C0n5oRgI.js +123 -0
- package/dist/_chunks/login-Ctw59McM.js +51 -0
- package/dist/_chunks/package-metadata-CLI488gB.js +39 -0
- package/dist/_chunks/preferences-CbYERA_m.js +241 -0
- package/dist/_chunks/preview-j9Kbx4-G.js +462 -0
- package/dist/_chunks/preview-registry-CTXU4mBc.js +1186 -0
- package/dist/_chunks/preview-resources-BNvfkfqP.js +359 -0
- package/dist/_chunks/previews-DXlf8SaQ.js +1133 -0
- package/dist/_chunks/productions-TkIy7b1Q.js +504 -0
- package/dist/_chunks/r2-presign-runtime-DlgH_FY8.js +291 -0
- package/dist/_chunks/ref-CYJNAAe_.js +178 -0
- package/dist/_chunks/remote-DB8SU7ea.js +79 -0
- package/dist/_chunks/remote-config-Bw6qIVM4.js +132 -0
- package/dist/_chunks/resolve-package-DeJUGxoE.js +152 -0
- package/dist/_chunks/rolldown-runtime-CvQ6eiug.js +14 -0
- package/dist/_chunks/routes-CRXB3-iw.js +851 -0
- package/dist/_chunks/runtime-BlKTWIgD.js +874 -0
- package/dist/_chunks/schema-normalization-CTdiY17P.js +667 -0
- package/dist/_chunks/secrets-CzSWX4-i.js +95 -0
- package/dist/_chunks/tail-DXKaqcPB.js +239 -0
- package/dist/_chunks/token-CEIRtse8.js +333 -0
- package/dist/_chunks/tokens-CE7-gV5E.js +221 -0
- package/dist/_chunks/types-BB15NBqw.js +484 -0
- package/dist/_chunks/ui-BhCdDC2N.js +103 -0
- package/dist/_chunks/usage-rRusKejc.js +272 -0
- package/dist/_chunks/vite-DTz2Pbtm.js +1267 -0
- package/dist/_chunks/vite-process-BhGXJ764.js +2928 -0
- package/dist/_chunks/vite-utils-D_VR07Ks.js +183 -0
- package/dist/_chunks/worker-CgIvLp-D.js +410 -0
- package/dist/_chunks/worker-bundler-CeMqQtBQ.js +457 -0
- package/dist/_chunks/worker-entrypoint-C8j23t6d.js +247 -0
- package/dist/_chunks/workerName-kEXwmV2m.js +23 -0
- package/dist/_chunks/workspace-CbollZBv.js +518 -0
- package/dist/_chunks/workspace-Ds3xMjOE.js +175 -0
- package/dist/bridge/client.d.ts +93 -8
- package/dist/bridge/client.d.ts.map +1 -1
- package/dist/bridge/do-rpc-dispatch.d.ts +23 -0
- package/dist/bridge/do-rpc-dispatch.d.ts.map +1 -0
- package/dist/bridge/do-websocket-connect.d.ts +33 -0
- package/dist/bridge/do-websocket-connect.d.ts.map +1 -0
- package/dist/bridge/gateway-runtime.d.ts +8 -0
- package/dist/bridge/gateway-runtime.d.ts.map +1 -0
- package/dist/bridge/index.d.ts +6 -6
- package/dist/bridge/index.d.ts.map +1 -1
- package/dist/bridge/log.d.ts +5 -0
- package/dist/bridge/log.d.ts.map +1 -0
- package/dist/bridge/miniflare-gateway.d.ts +45 -0
- package/dist/bridge/miniflare-gateway.d.ts.map +1 -0
- package/dist/bridge/miniflare.d.ts +92 -2
- package/dist/bridge/miniflare.d.ts.map +1 -1
- package/dist/bridge/proxy.d.ts +12 -11
- package/dist/bridge/proxy.d.ts.map +1 -1
- package/dist/bridge/r2-presign-runtime.d.ts +9 -0
- package/dist/bridge/r2-presign-runtime.d.ts.map +1 -0
- package/dist/bridge/server.d.ts +2 -1
- package/dist/bridge/server.d.ts.map +1 -1
- package/dist/bridge/v2/body-streams.d.ts +53 -0
- package/dist/bridge/v2/body-streams.d.ts.map +1 -0
- package/dist/bridge/v2/codec.d.ts +106 -0
- package/dist/bridge/v2/codec.d.ts.map +1 -0
- package/dist/bridge/v2/control-messages.d.ts +46 -0
- package/dist/bridge/v2/control-messages.d.ts.map +1 -0
- package/dist/bridge/v2/frames.d.ts +109 -0
- package/dist/bridge/v2/frames.d.ts.map +1 -0
- package/dist/bridge/v2/index.d.ts +11 -0
- package/dist/bridge/v2/index.d.ts.map +1 -0
- package/dist/bridge/v2/serialization.d.ts +48 -0
- package/dist/bridge/v2/serialization.d.ts.map +1 -0
- package/dist/bridge/v2/transport.d.ts +31 -0
- package/dist/bridge/v2/transport.d.ts.map +1 -0
- package/dist/bridge/v2/value-codec.d.ts +61 -0
- package/dist/bridge/v2/value-codec.d.ts.map +1 -0
- package/dist/bridge/v2/value-serialization.d.ts +139 -0
- package/dist/bridge/v2/value-serialization.d.ts.map +1 -0
- package/dist/bridge/{protocol.d.ts → v2/wire.d.ts} +32 -8
- package/dist/bridge/v2/wire.d.ts.map +1 -0
- package/dist/bridge/v2/ws-relay.d.ts +53 -0
- package/dist/bridge/v2/ws-relay.d.ts.map +1 -0
- package/dist/bridge/websocket-constructor.d.ts +38 -0
- package/dist/bridge/websocket-constructor.d.ts.map +1 -0
- package/dist/browser-shim/handler.d.ts +2 -2
- package/dist/browser-shim/handler.d.ts.map +1 -1
- package/dist/browser-shim/index.d.ts +2 -2
- package/dist/browser-shim/server.d.ts +63 -0
- package/dist/browser-shim/server.d.ts.map +1 -1
- package/dist/browser.d.ts +5778 -43
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +73 -142
- package/dist/bundler/defaults.d.ts +23 -0
- package/dist/bundler/defaults.d.ts.map +1 -0
- package/dist/bundler/do-bundler.d.ts +7 -0
- package/dist/bundler/do-bundler.d.ts.map +1 -1
- package/dist/bundler/index.d.ts +3 -1
- package/dist/bundler/index.d.ts.map +1 -1
- package/dist/bundler/rolldown-shared.d.ts +52 -0
- package/dist/bundler/rolldown-shared.d.ts.map +1 -0
- package/dist/bundler/worker-bundler.d.ts +13 -0
- package/dist/bundler/worker-bundler.d.ts.map +1 -0
- package/dist/bundler/worker-compat.d.ts +4 -0
- package/dist/bundler/worker-compat.d.ts.map +1 -0
- package/dist/cli/build-manifest.d.ts +66 -0
- package/dist/cli/build-manifest.d.ts.map +1 -0
- package/dist/cli/command-utils.d.ts +18 -0
- package/dist/cli/command-utils.d.ts.map +1 -0
- package/dist/cli/commands/account.d.ts +2 -2
- package/dist/cli/commands/account.d.ts.map +1 -1
- package/dist/cli/commands/ai.d.ts +1 -1
- package/dist/cli/commands/ai.d.ts.map +1 -1
- package/dist/cli/commands/build-artifacts.d.ts +40 -0
- package/dist/cli/commands/build-artifacts.d.ts.map +1 -0
- package/dist/cli/commands/build.d.ts +2 -2
- package/dist/cli/commands/build.d.ts.map +1 -1
- package/dist/cli/commands/config.d.ts +4 -0
- package/dist/cli/commands/config.d.ts.map +1 -0
- package/dist/cli/commands/deploy/metadata.d.ts +18 -0
- package/dist/cli/commands/deploy/metadata.d.ts.map +1 -0
- package/dist/cli/commands/deploy/prepare.d.ts +23 -0
- package/dist/cli/commands/deploy/prepare.d.ts.map +1 -0
- package/dist/cli/commands/deploy/runtime.d.ts +4 -0
- package/dist/cli/commands/deploy/runtime.d.ts.map +1 -0
- package/dist/cli/commands/deploy/verification.d.ts +36 -0
- package/dist/cli/commands/deploy/verification.d.ts.map +1 -0
- package/dist/cli/commands/deploy.d.ts +2 -2
- package/dist/cli/commands/deploy.d.ts.map +1 -1
- package/dist/cli/commands/dev.d.ts +9 -1
- package/dist/cli/commands/dev.d.ts.map +1 -1
- package/dist/cli/commands/doctor.d.ts +2 -2
- package/dist/cli/commands/doctor.d.ts.map +1 -1
- package/dist/cli/commands/init.d.ts +2 -2
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/login.d.ts +4 -0
- package/dist/cli/commands/login.d.ts.map +1 -0
- package/dist/cli/commands/previews-support/cleanup.d.ts +9 -0
- package/dist/cli/commands/previews-support/cleanup.d.ts.map +1 -0
- package/dist/cli/commands/previews-support/family.d.ts +10 -0
- package/dist/cli/commands/previews-support/family.d.ts.map +1 -0
- package/dist/cli/commands/previews-support/render.d.ts +8 -0
- package/dist/cli/commands/previews-support/render.d.ts.map +1 -0
- package/dist/cli/commands/previews-support/theme.d.ts +10 -0
- package/dist/cli/commands/previews-support/theme.d.ts.map +1 -0
- package/dist/cli/commands/previews-support/types.d.ts +70 -0
- package/dist/cli/commands/previews-support/types.d.ts.map +1 -0
- package/dist/cli/commands/previews.d.ts +4 -0
- package/dist/cli/commands/previews.d.ts.map +1 -0
- package/dist/cli/commands/productions.d.ts +4 -0
- package/dist/cli/commands/productions.d.ts.map +1 -0
- package/dist/cli/commands/remote.d.ts +1 -1
- package/dist/cli/commands/remote.d.ts.map +1 -1
- package/dist/cli/commands/secrets.d.ts +4 -0
- package/dist/cli/commands/secrets.d.ts.map +1 -0
- package/dist/cli/commands/tail.d.ts +44 -0
- package/dist/cli/commands/tail.d.ts.map +1 -0
- package/dist/cli/commands/token.d.ts +4 -0
- package/dist/cli/commands/token.d.ts.map +1 -0
- package/dist/cli/commands/type-generation/discovery.d.ts +7 -0
- package/dist/cli/commands/type-generation/discovery.d.ts.map +1 -0
- package/dist/cli/commands/type-generation/generator.d.ts +121 -0
- package/dist/cli/commands/type-generation/generator.d.ts.map +1 -0
- package/dist/cli/commands/type-generation/models.d.ts +27 -0
- package/dist/cli/commands/type-generation/models.d.ts.map +1 -0
- package/dist/cli/commands/types.d.ts +2 -2
- package/dist/cli/commands/types.d.ts.map +1 -1
- package/dist/cli/commands/worker.d.ts +4 -0
- package/dist/cli/commands/worker.d.ts.map +1 -0
- package/dist/cli/commands/workspace.d.ts +8 -0
- package/dist/cli/commands/workspace.d.ts.map +1 -0
- package/dist/cli/config-path.d.ts +6 -0
- package/dist/cli/config-path.d.ts.map +1 -0
- package/dist/cli/dependencies.d.ts +2 -1
- package/dist/cli/dependencies.d.ts.map +1 -1
- package/dist/cli/deploy-strategy.d.ts +17 -0
- package/dist/cli/deploy-strategy.d.ts.map +1 -0
- package/dist/cli/deploy-target.d.ts +17 -0
- package/dist/cli/deploy-target.d.ts.map +1 -0
- package/dist/cli/generated-artifacts.d.ts +12 -0
- package/dist/cli/generated-artifacts.d.ts.map +1 -0
- package/dist/cli/gradual-deploy.d.ts +49 -0
- package/dist/cli/gradual-deploy.d.ts.map +1 -0
- package/dist/cli/help-pages/pages/account.d.ts +3 -0
- package/dist/cli/help-pages/pages/account.d.ts.map +1 -0
- package/dist/cli/help-pages/pages/core.d.ts +4 -0
- package/dist/cli/help-pages/pages/core.d.ts.map +1 -0
- package/dist/cli/help-pages/pages/index.d.ts +3 -0
- package/dist/cli/help-pages/pages/index.d.ts.map +1 -0
- package/dist/cli/help-pages/pages/misc.d.ts +3 -0
- package/dist/cli/help-pages/pages/misc.d.ts.map +1 -0
- package/dist/cli/help-pages/pages/previews.d.ts +3 -0
- package/dist/cli/help-pages/pages/previews.d.ts.map +1 -0
- package/dist/cli/help-pages/pages/productions.d.ts +3 -0
- package/dist/cli/help-pages/pages/productions.d.ts.map +1 -0
- package/dist/cli/help-pages/render.d.ts +12 -0
- package/dist/cli/help-pages/render.d.ts.map +1 -0
- package/dist/cli/help-pages/shared.d.ts +15 -0
- package/dist/cli/help-pages/shared.d.ts.map +1 -0
- package/dist/cli/help-pages/types.d.ts +23 -0
- package/dist/cli/help-pages/types.d.ts.map +1 -0
- package/dist/cli/help.d.ts +6 -0
- package/dist/cli/help.d.ts.map +1 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +2 -0
- package/dist/cli/package-metadata.d.ts +16 -0
- package/dist/cli/package-metadata.d.ts.map +1 -0
- package/dist/cli/preview-bindings.d.ts +49 -0
- package/dist/cli/preview-bindings.d.ts.map +1 -0
- package/dist/cli/preview.d.ts +10 -0
- package/dist/cli/preview.d.ts.map +1 -0
- package/dist/cli/ui.d.ts +37 -0
- package/dist/cli/ui.d.ts.map +1 -0
- package/dist/cli/workspace-build-guard.d.ts +14 -0
- package/dist/cli/workspace-build-guard.d.ts.map +1 -0
- package/dist/cli/wrangler-auth.d.ts +1 -1
- package/dist/cloudflare/account-core.d.ts +6 -0
- package/dist/cloudflare/account-core.d.ts.map +1 -0
- package/dist/cloudflare/account-resources.d.ts +40 -0
- package/dist/cloudflare/account-resources.d.ts.map +1 -0
- package/dist/cloudflare/account-status.d.ts +11 -0
- package/dist/cloudflare/account-status.d.ts.map +1 -0
- package/dist/cloudflare/account-workers.d.ts +14 -0
- package/dist/cloudflare/account-workers.d.ts.map +1 -0
- package/dist/cloudflare/account.d.ts +7 -64
- package/dist/cloudflare/account.d.ts.map +1 -1
- package/dist/cloudflare/api.d.ts +71 -3
- package/dist/cloudflare/api.d.ts.map +1 -1
- package/dist/cloudflare/auth.d.ts +1 -1
- package/dist/cloudflare/auth.d.ts.map +1 -1
- package/dist/cloudflare/index.d.ts +61 -6
- package/dist/cloudflare/index.d.ts.map +1 -1
- package/dist/cloudflare/index.js +4 -13
- package/dist/cloudflare/known-permission-group-ids.generated.d.ts +10 -0
- package/dist/cloudflare/known-permission-group-ids.generated.d.ts.map +1 -0
- package/dist/cloudflare/kv-namespace.d.ts +4 -0
- package/dist/cloudflare/kv-namespace.d.ts.map +1 -0
- package/dist/cloudflare/preferences.d.ts +7 -0
- package/dist/cloudflare/preferences.d.ts.map +1 -1
- package/dist/cloudflare/preview-registry-cache.d.ts +6 -0
- package/dist/cloudflare/preview-registry-cache.d.ts.map +1 -0
- package/dist/cloudflare/preview-registry-inference.d.ts +14 -0
- package/dist/cloudflare/preview-registry-inference.d.ts.map +1 -0
- package/dist/cloudflare/preview-registry-records.d.ts +4 -0
- package/dist/cloudflare/preview-registry-records.d.ts.map +1 -0
- package/dist/cloudflare/preview-registry-shape.d.ts +47 -0
- package/dist/cloudflare/preview-registry-shape.d.ts.map +1 -0
- package/dist/cloudflare/preview-registry-store.d.ts +14 -0
- package/dist/cloudflare/preview-registry-store.d.ts.map +1 -0
- package/dist/cloudflare/preview-registry-transport.d.ts +4 -0
- package/dist/cloudflare/preview-registry-transport.d.ts.map +1 -0
- package/dist/cloudflare/preview-registry-types.d.ts +103 -0
- package/dist/cloudflare/preview-registry-types.d.ts.map +1 -0
- package/dist/cloudflare/preview-registry.d.ts +42 -0
- package/dist/cloudflare/preview-registry.d.ts.map +1 -0
- package/dist/cloudflare/preview-urls.d.ts +3 -0
- package/dist/cloudflare/preview-urls.d.ts.map +1 -0
- package/dist/cloudflare/registry-schema.d.ts +253 -0
- package/dist/cloudflare/registry-schema.d.ts.map +1 -0
- package/dist/cloudflare/remote-config.d.ts.map +1 -1
- package/dist/cloudflare/tokens.d.ts +44 -0
- package/dist/cloudflare/tokens.d.ts.map +1 -0
- package/dist/cloudflare/types.d.ts +124 -7
- package/dist/cloudflare/types.d.ts.map +1 -1
- package/dist/cloudflare/usage.d.ts +31 -3
- package/dist/cloudflare/usage.d.ts.map +1 -1
- package/dist/config/binding-resolution-helpers.d.ts +41 -0
- package/dist/config/binding-resolution-helpers.d.ts.map +1 -0
- package/dist/config/compatibility.d.ts +3 -0
- package/dist/config/compatibility.d.ts.map +1 -0
- package/dist/config/compiler/bindings.d.ts +14 -0
- package/dist/config/compiler/bindings.d.ts.map +1 -0
- package/dist/config/compiler/core-helpers.d.ts +6 -0
- package/dist/config/compiler/core-helpers.d.ts.map +1 -0
- package/dist/config/compiler/do-workers.d.ts +34 -0
- package/dist/config/compiler/do-workers.d.ts.map +1 -0
- package/dist/config/compiler/paths.d.ts +18 -0
- package/dist/config/compiler/paths.d.ts.map +1 -0
- package/dist/config/compiler/types.d.ts +308 -0
- package/dist/config/compiler/types.d.ts.map +1 -0
- package/dist/config/compiler.d.ts +22 -134
- package/dist/config/compiler.d.ts.map +1 -1
- package/dist/config/cron.d.ts +19 -0
- package/dist/config/cron.d.ts.map +1 -0
- package/dist/config/define.d.ts +8 -5
- package/dist/config/define.d.ts.map +1 -1
- package/dist/config/deploy-resources.d.ts +58 -0
- package/dist/config/deploy-resources.d.ts.map +1 -0
- package/dist/config/env-vars.d.ts +309 -0
- package/dist/config/env-vars.d.ts.map +1 -0
- package/dist/config/framework-providers.d.ts +9 -0
- package/dist/config/framework-providers.d.ts.map +1 -0
- package/dist/config/index.d.ts +13 -5
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/loader.d.ts +2 -1
- package/dist/config/loader.d.ts.map +1 -1
- package/dist/config/local-dev-vars.d.ts +15 -0
- package/dist/config/local-dev-vars.d.ts.map +1 -0
- package/dist/config/preview-resources.d.ts +83 -0
- package/dist/config/preview-resources.d.ts.map +1 -0
- package/dist/config/preview.d.ts +29 -0
- package/dist/config/preview.d.ts.map +1 -0
- package/dist/config/ref.d.ts +16 -25
- package/dist/config/ref.d.ts.map +1 -1
- package/dist/config/resolve-phased.d.ts +72 -0
- package/dist/config/resolve-phased.d.ts.map +1 -0
- package/dist/config/resolve.d.ts +11 -0
- package/dist/config/resolve.d.ts.map +1 -0
- package/dist/config/resource-resolution.d.ts +80 -0
- package/dist/config/resource-resolution.d.ts.map +1 -0
- package/dist/config/schema-bindings.d.ts +2124 -0
- package/dist/config/schema-bindings.d.ts.map +1 -0
- package/dist/config/schema-build.d.ts +67 -0
- package/dist/config/schema-build.d.ts.map +1 -0
- package/dist/config/schema-env.d.ts +3821 -0
- package/dist/config/schema-env.d.ts.map +1 -0
- package/dist/config/schema-normalization.d.ts +272 -0
- package/dist/config/schema-normalization.d.ts.map +1 -0
- package/dist/config/schema-runtime.d.ts +597 -0
- package/dist/config/schema-runtime.d.ts.map +1 -0
- package/dist/config/schema-types-bindings-platform.d.ts +520 -0
- package/dist/config/schema-types-bindings-platform.d.ts.map +1 -0
- package/dist/config/schema-types-bindings-resources.d.ts +802 -0
- package/dist/config/schema-types-bindings-resources.d.ts.map +1 -0
- package/dist/config/schema-types-bindings.d.ts +293 -0
- package/dist/config/schema-types-bindings.d.ts.map +1 -0
- package/dist/config/schema-types-build.d.ts +86 -0
- package/dist/config/schema-types-build.d.ts.map +1 -0
- package/dist/config/schema-types-runtime-server.d.ts +196 -0
- package/dist/config/schema-types-runtime-server.d.ts.map +1 -0
- package/dist/config/schema-types-runtime.d.ts +913 -0
- package/dist/config/schema-types-runtime.d.ts.map +1 -0
- package/dist/config/schema-types.d.ts +458 -0
- package/dist/config/schema-types.d.ts.map +1 -0
- package/dist/config/schema.d.ts +5796 -2023
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/config/service-bindings-validation.d.ts +36 -0
- package/dist/config/service-bindings-validation.d.ts.map +1 -0
- package/dist/config/workspace.d.ts +282 -0
- package/dist/config/workspace.d.ts.map +1 -0
- package/dist/config-entry.d.ts +7 -0
- package/dist/config-entry.d.ts.map +1 -0
- package/dist/config-entry.js +3 -0
- package/dist/decorators/durable-object.d.ts.map +1 -1
- package/dist/decorators/index.d.ts +2 -2
- package/dist/decorators/index.js +2 -9
- package/dist/dev-server/d1-migrations.d.ts +36 -0
- package/dist/dev-server/d1-migrations.d.ts.map +1 -0
- package/dist/dev-server/dev-server-state.d.ts +59 -0
- package/dist/dev-server/dev-server-state.d.ts.map +1 -0
- package/dist/dev-server/gateway-script.d.ts +22 -0
- package/dist/dev-server/gateway-script.d.ts.map +1 -0
- package/dist/dev-server/index.d.ts +1 -1
- package/dist/dev-server/miniflare-bindings.d.ts +90 -0
- package/dist/dev-server/miniflare-bindings.d.ts.map +1 -0
- package/dist/dev-server/miniflare-dev-config.d.ts +57 -0
- package/dist/dev-server/miniflare-dev-config.d.ts.map +1 -0
- package/dist/dev-server/miniflare-log.d.ts +20 -0
- package/dist/dev-server/miniflare-log.d.ts.map +1 -0
- package/dist/dev-server/miniflare-worker-config.d.ts +100 -0
- package/dist/dev-server/miniflare-worker-config.d.ts.map +1 -0
- package/dist/dev-server/reload-queue.d.ts +13 -0
- package/dist/dev-server/reload-queue.d.ts.map +1 -0
- package/dist/dev-server/runtime-health.d.ts +79 -0
- package/dist/dev-server/runtime-health.d.ts.map +1 -0
- package/dist/dev-server/runtime-stdio.d.ts +8 -0
- package/dist/dev-server/runtime-stdio.d.ts.map +1 -0
- package/dist/dev-server/server-startup-helpers.d.ts +84 -0
- package/dist/dev-server/server-startup-helpers.d.ts.map +1 -0
- package/dist/dev-server/server.d.ts +2 -0
- package/dist/dev-server/server.d.ts.map +1 -1
- package/dist/dev-server/vite-process.d.ts +24 -0
- package/dist/dev-server/vite-process.d.ts.map +1 -0
- package/dist/dev-server/vite-utils.d.ts +19 -1
- package/dist/dev-server/vite-utils.d.ts.map +1 -1
- package/dist/dev-server/worker-source-watcher.d.ts +17 -0
- package/dist/dev-server/worker-source-watcher.d.ts.map +1 -0
- package/dist/dev-server/worker-surface-paths.d.ts +6 -0
- package/dist/dev-server/worker-surface-paths.d.ts.map +1 -0
- package/dist/dev-server/workspace/merge-config.d.ts +81 -0
- package/dist/dev-server/workspace/merge-config.d.ts.map +1 -0
- package/dist/dev-server/workspace/prepare-app.d.ts +84 -0
- package/dist/dev-server/workspace/prepare-app.d.ts.map +1 -0
- package/dist/dev-server/workspace/server.d.ts +47 -0
- package/dist/dev-server/workspace/server.d.ts.map +1 -0
- package/dist/env.d.ts +10 -0
- package/dist/env.d.ts.map +1 -1
- package/dist/index.d.ts +8 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -297
- package/dist/runtime/context-events.d.ts +13 -0
- package/dist/runtime/context-events.d.ts.map +1 -0
- package/dist/runtime/context-types.d.ts +82 -0
- package/dist/runtime/context-types.d.ts.map +1 -0
- package/dist/runtime/context.d.ts +20 -44
- package/dist/runtime/context.d.ts.map +1 -1
- package/dist/runtime/exports.d.ts +70 -55
- package/dist/runtime/exports.d.ts.map +1 -1
- package/dist/runtime/index.d.ts +11 -5
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +5 -184
- package/dist/runtime/middleware.d.ts +119 -67
- package/dist/runtime/middleware.d.ts.map +1 -1
- package/dist/runtime/r2-presign.d.ts +164 -0
- package/dist/runtime/r2-presign.d.ts.map +1 -0
- package/dist/runtime/router/index.d.ts +7 -0
- package/dist/runtime/router/index.d.ts.map +1 -0
- package/dist/runtime/router/types.d.ts +24 -0
- package/dist/runtime/router/types.d.ts.map +1 -0
- package/dist/runtime/validation.d.ts +18 -4
- package/dist/runtime/validation.d.ts.map +1 -1
- package/dist/secrets/local-secrets.d.ts +46 -0
- package/dist/secrets/local-secrets.d.ts.map +1 -0
- package/dist/shims/local-hyperdrive.d.ts +12 -0
- package/dist/shims/local-hyperdrive.d.ts.map +1 -0
- package/dist/shims/local-media-bindings.d.ts +19 -0
- package/dist/shims/local-media-bindings.d.ts.map +1 -0
- package/dist/shims/local-worker-loader.d.ts +3 -0
- package/dist/shims/local-worker-loader.d.ts.map +1 -0
- package/dist/sveltekit/index.d.ts +1 -1
- package/dist/sveltekit/index.d.ts.map +1 -1
- package/dist/sveltekit/index.js +377 -169
- package/dist/sveltekit/local-bindings.d.ts +4 -0
- package/dist/sveltekit/local-bindings.d.ts.map +1 -0
- package/dist/sveltekit/platform.d.ts +42 -2
- package/dist/sveltekit/platform.d.ts.map +1 -1
- package/dist/test/ai-search.d.ts +39 -0
- package/dist/test/ai-search.d.ts.map +1 -0
- package/dist/test/alarm.d.ts +55 -0
- package/dist/test/alarm.d.ts.map +1 -0
- package/dist/test/binding-hints.d.ts +10 -0
- package/dist/test/binding-hints.d.ts.map +1 -0
- package/dist/test/cf.d.ts +71 -35
- package/dist/test/cf.d.ts.map +1 -1
- package/dist/test/containers.d.ts +87 -0
- package/dist/test/containers.d.ts.map +1 -0
- package/dist/test/email.d.ts +16 -7
- package/dist/test/email.d.ts.map +1 -1
- package/dist/test/index.d.ts +20 -21
- package/dist/test/index.d.ts.map +1 -1
- package/dist/test/index.js +5115 -75
- package/dist/test/offline-bindings.d.ts +124 -0
- package/dist/test/offline-bindings.d.ts.map +1 -0
- package/dist/test/queue.d.ts.map +1 -1
- package/dist/test/remote-ai.d.ts.map +1 -1
- package/dist/test/remote-cloudflare.d.ts +13 -0
- package/dist/test/remote-cloudflare.d.ts.map +1 -0
- package/dist/test/remote-vectorize.d.ts.map +1 -1
- package/dist/test/resolve-service-bindings.d.ts +64 -4
- package/dist/test/resolve-service-bindings.d.ts.map +1 -1
- package/dist/test/scheduled.d.ts.map +1 -1
- package/dist/test/should-skip.d.ts +14 -18
- package/dist/test/should-skip.d.ts.map +1 -1
- package/dist/test/simple-context-bindings.d.ts +13 -0
- package/dist/test/simple-context-bindings.d.ts.map +1 -0
- package/dist/test/simple-context-durable-objects.d.ts +6 -0
- package/dist/test/simple-context-durable-objects.d.ts.map +1 -0
- package/dist/test/simple-context-env.d.ts +35 -0
- package/dist/test/simple-context-env.d.ts.map +1 -0
- package/dist/test/simple-context-gateway-script.d.ts +2 -0
- package/dist/test/simple-context-gateway-script.d.ts.map +1 -0
- package/dist/test/simple-context-handlers.d.ts +12 -0
- package/dist/test/simple-context-handlers.d.ts.map +1 -0
- package/dist/test/simple-context-lifecycle.d.ts +32 -0
- package/dist/test/simple-context-lifecycle.d.ts.map +1 -0
- package/dist/test/simple-context-mfconfig.d.ts +18 -0
- package/dist/test/simple-context-mfconfig.d.ts.map +1 -0
- package/dist/test/simple-context-multi-worker.d.ts +16 -0
- package/dist/test/simple-context-multi-worker.d.ts.map +1 -0
- package/dist/test/simple-context-paths.d.ts +40 -0
- package/dist/test/simple-context-paths.d.ts.map +1 -0
- package/dist/test/simple-context-runtime.d.ts +19 -0
- package/dist/test/simple-context-runtime.d.ts.map +1 -0
- package/dist/test/simple-context-startup.d.ts +11 -0
- package/dist/test/simple-context-startup.d.ts.map +1 -0
- package/dist/test/simple-context-transport.d.ts +14 -0
- package/dist/test/simple-context-transport.d.ts.map +1 -0
- package/dist/test/simple-context.d.ts +8 -27
- package/dist/test/simple-context.d.ts.map +1 -1
- package/dist/test/tail.d.ts +3 -2
- package/dist/test/tail.d.ts.map +1 -1
- package/dist/test/utilities/analytics-engine.d.ts +22 -0
- package/dist/test/utilities/analytics-engine.d.ts.map +1 -0
- package/dist/test/utilities/artifacts.d.ts +11 -0
- package/dist/test/utilities/artifacts.d.ts.map +1 -0
- package/dist/test/utilities/context.d.ts +39 -0
- package/dist/test/utilities/context.d.ts.map +1 -0
- package/dist/test/utilities/d1.d.ts +21 -0
- package/dist/test/utilities/d1.d.ts.map +1 -0
- package/dist/test/utilities/env.d.ts +45 -0
- package/dist/test/utilities/env.d.ts.map +1 -0
- package/dist/test/utilities/kv.d.ts +11 -0
- package/dist/test/utilities/kv.d.ts.map +1 -0
- package/dist/test/utilities/media.d.ts +16 -0
- package/dist/test/utilities/media.d.ts.map +1 -0
- package/dist/test/utilities/platform.d.ts +41 -0
- package/dist/test/utilities/platform.d.ts.map +1 -0
- package/dist/test/utilities/queue.d.ts +5 -0
- package/dist/test/utilities/queue.d.ts.map +1 -0
- package/dist/test/utilities/r2.d.ts +2 -0
- package/dist/test/utilities/r2.d.ts.map +1 -0
- package/dist/test/utilities/send-email.d.ts +27 -0
- package/dist/test/utilities/send-email.d.ts.map +1 -0
- package/dist/test/utilities/stream-flagship.d.ts +27 -0
- package/dist/test/utilities/stream-flagship.d.ts.map +1 -0
- package/dist/test/utilities/vectorize.d.ts +38 -0
- package/dist/test/utilities/vectorize.d.ts.map +1 -0
- package/dist/test/utilities/workflows.d.ts +26 -0
- package/dist/test/utilities/workflows.d.ts.map +1 -0
- package/dist/test/utilities.d.ts +14 -98
- package/dist/test/utilities.d.ts.map +1 -1
- package/dist/test/worker.d.ts +6 -0
- package/dist/test/worker.d.ts.map +1 -1
- package/dist/transform/durable-object.d.ts.map +1 -1
- package/dist/transform/index.d.ts +2 -2
- package/dist/transform/worker-entrypoint.d.ts +5 -0
- package/dist/transform/worker-entrypoint.d.ts.map +1 -1
- package/dist/utils/entrypoint-discovery.d.ts +6 -3
- package/dist/utils/entrypoint-discovery.d.ts.map +1 -1
- package/dist/utils/generated-dir.d.ts +25 -0
- package/dist/utils/generated-dir.d.ts.map +1 -0
- package/dist/utils/glob.d.ts.map +1 -1
- package/dist/utils/resolve-package.d.ts.map +1 -1
- package/dist/utils/send-email.d.ts +15 -0
- package/dist/utils/send-email.d.ts.map +1 -0
- package/dist/utils/send-email.js +163 -0
- package/dist/vite/config-file.d.ts +25 -0
- package/dist/vite/config-file.d.ts.map +1 -0
- package/dist/vite/index.d.ts +3 -2
- package/dist/vite/index.d.ts.map +1 -1
- package/dist/vite/index.js +2 -407
- package/dist/vite/plugin-config-hook.d.ts +28 -0
- package/dist/vite/plugin-config-hook.d.ts.map +1 -0
- package/dist/vite/plugin-context.d.ts +27 -0
- package/dist/vite/plugin-context.d.ts.map +1 -0
- package/dist/vite/plugin-durable-objects.d.ts +18 -0
- package/dist/vite/plugin-durable-objects.d.ts.map +1 -0
- package/dist/vite/plugin-programmatic.d.ts +44 -0
- package/dist/vite/plugin-programmatic.d.ts.map +1 -0
- package/dist/vite/plugin-service-bindings.d.ts +13 -0
- package/dist/vite/plugin-service-bindings.d.ts.map +1 -0
- package/dist/vite/plugin-transform.d.ts +41 -0
- package/dist/vite/plugin-transform.d.ts.map +1 -0
- package/dist/vite/plugin.d.ts +10 -41
- package/dist/vite/plugin.d.ts.map +1 -1
- package/dist/worker-entry/composed-worker.d.ts +5 -8
- package/dist/worker-entry/composed-worker.d.ts.map +1 -1
- package/dist/worker-entry/durable-object-discovery.d.ts +20 -0
- package/dist/worker-entry/durable-object-discovery.d.ts.map +1 -0
- package/dist/worker-entry/extensions.d.ts +5 -0
- package/dist/worker-entry/extensions.d.ts.map +1 -0
- package/dist/worker-entry/routes.d.ts +22 -0
- package/dist/worker-entry/routes.d.ts.map +1 -0
- package/dist/worker-entry/surface-paths.d.ts +26 -0
- package/dist/worker-entry/surface-paths.d.ts.map +1 -0
- package/dist/worker-entry/validate-fetch-style.d.ts +12 -0
- package/dist/worker-entry/validate-fetch-style.d.ts.map +1 -0
- package/dist/workflows/local-workflow-entrypoints.d.ts +7 -0
- package/dist/workflows/local-workflow-entrypoints.d.ts.map +1 -0
- package/package.json +160 -117
- package/R2.md +0 -170
- package/dist/account-rvrj687w.js +0 -397
- package/dist/ai-dx4fr9jh.js +0 -107
- package/dist/bridge/protocol.d.ts.map +0 -1
- package/dist/bridge/serialization.d.ts +0 -83
- package/dist/bridge/serialization.d.ts.map +0 -1
- package/dist/browser-shim/worker.d.ts +0 -14
- package/dist/browser-shim/worker.d.ts.map +0 -1
- package/dist/build-9myaxf07.js +0 -70
- package/dist/deploy-h1wz5p7m.js +0 -86
- package/dist/dev-rsdssknb.js +0 -2707
- package/dist/doctor-v7jy4s3r.js +0 -190
- package/dist/durable-object-t4kbb0yt.js +0 -13
- package/dist/index-18hvb6gb.js +0 -194
- package/dist/index-1xpj0m4r.js +0 -57
- package/dist/index-37x76zdn.js +0 -4
- package/dist/index-3t6rypgc.js +0 -13
- package/dist/index-62b3gt2g.js +0 -12
- package/dist/index-67qcae0f.js +0 -183
- package/dist/index-9ats0s83.js +0 -70
- package/dist/index-a0fjkq68.js +0 -198
- package/dist/index-a855bdsx.js +0 -18
- package/dist/index-ccrh4w3t.js +0 -1133
- package/dist/index-d8bdkx2h.js +0 -109
- package/dist/index-f8qh2tyh.js +0 -2152
- package/dist/index-gz1gndna.js +0 -307
- package/dist/index-hcex3rgh.js +0 -266
- package/dist/index-k7r18na8.js +0 -0
- package/dist/index-n3np2d6t.js +0 -462
- package/dist/index-n7rs26ft.js +0 -77
- package/dist/index-npc1c8jx.js +0 -44
- package/dist/index-p7g30wd2.js +0 -281
- package/dist/index-rbht7m9r.js +0 -36
- package/dist/index-tfyxa77h.js +0 -850
- package/dist/index-tk6ej9dj.js +0 -94
- package/dist/index-v8vvsn9x.js +0 -169
- package/dist/index-z14anrqp.js +0 -226
- package/dist/init-f9mgmew3.js +0 -186
- package/dist/remote-q59qk463.js +0 -97
- package/dist/test/bridge-context.d.ts +0 -76
- package/dist/test/bridge-context.d.ts.map +0 -1
- package/dist/test/multi-worker-context.d.ts +0 -114
- package/dist/test/multi-worker-context.d.ts.map +0 -1
- package/dist/types-wdcpnfvy.js +0 -487
- package/dist/worker-entrypoint-m9th0rg0.js +0 -13
|
@@ -0,0 +1,953 @@
|
|
|
1
|
+
import { c as getDevflareDotenvPaths, d as resolveConfigEnvVars, o as EnvVarResolutionError } from "./preview-j9Kbx4-G.js";
|
|
2
|
+
import { r as loadConfig } from "./loader-BC0skbnH.js";
|
|
3
|
+
import { t as applyLocalDevVarsToConfig } from "./local-dev-vars-BFLS-HoI.js";
|
|
4
|
+
import { a as cyanBold, f as logLine, g as yellow, o as dim, r as createCliTheme } from "./ui-BhCdDC2N.js";
|
|
5
|
+
import { clearLocalSendEmailBindings, setLocalSendEmailBindings } from "../utils/send-email.js";
|
|
6
|
+
import { s as resolveServiceBindings, t as discoverRoutes } from "./routes-CRXB3-iw.js";
|
|
7
|
+
import { l as prepareComposedWorkerEntrypoint, m as hasWorkerSurfacePaths, n as resolveEffectiveViteProject } from "./vite-DTz2Pbtm.js";
|
|
8
|
+
import { t as bundleWorkerEntry } from "./worker-bundler-CeMqQtBQ.js";
|
|
9
|
+
import { _ as createMiniflareLog, a as logWorkerHandlerDetection, c as resolveViteIntegration, d as createRuntimeStdioForwarder, f as buildMiniflareDevConfig, g as runD1Migrations, h as resolveMainWorkerSurfacePaths, i as logRemoteBindingRequirements, l as resolveWorkerConfigWatchPath, m as collectWorkerWatchRoots, n as logMiniflareBindingDiagnostics, o as maybeStartBrowserShim, p as resolveR2PresignOrigin, r as logMiniflareConfigDiagnostics, s as maybeStartDOBundler, t as startViteProcess } from "./vite-process-BhGXJ764.js";
|
|
10
|
+
import { n as bundleWorkflowEntrypointScript } from "./r2-presign-runtime-DlgH_FY8.js";
|
|
11
|
+
import { t as generatedDir } from "./generated-dir-DC2kM-mt.js";
|
|
12
|
+
import { r as stopSpawnedProcessTree, t as detectViteProject } from "./vite-utils-D_VR07Ks.js";
|
|
13
|
+
import { dirname, relative, resolve } from "pathe";
|
|
14
|
+
import { exec } from "node:child_process";
|
|
15
|
+
import { createConsola } from "consola";
|
|
16
|
+
import { connect } from "node:net";
|
|
17
|
+
import { promisify } from "node:util";
|
|
18
|
+
//#region src/bridge/miniflare.ts
|
|
19
|
+
function isIgnorableMiniflareDisposeError(error) {
|
|
20
|
+
if (!(error instanceof Error)) return false;
|
|
21
|
+
const details = error;
|
|
22
|
+
return details.code === "EBADF" && details.syscall === "kill";
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region src/cli/wrangler-auth.ts
|
|
26
|
+
const execAsync = promisify(exec);
|
|
27
|
+
/**
|
|
28
|
+
* Check if the config contains any bindings that require remote access
|
|
29
|
+
*/
|
|
30
|
+
function detectRemoteBindings(config) {
|
|
31
|
+
const remoteBindings = [];
|
|
32
|
+
const bindings = config.bindings;
|
|
33
|
+
if (!bindings) return remoteBindings;
|
|
34
|
+
if (bindings.ai) remoteBindings.push(`AI (binding: ${bindings.ai.binding})`);
|
|
35
|
+
if (bindings.vectorize) for (const [name] of Object.entries(bindings.vectorize)) remoteBindings.push(`Vectorize (binding: ${name})`);
|
|
36
|
+
return remoteBindings;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Check if wrangler is logged in by running `wrangler whoami`
|
|
40
|
+
*
|
|
41
|
+
* Returns:
|
|
42
|
+
* - loggedIn: true if user is authenticated
|
|
43
|
+
* - accountId: the account ID if available
|
|
44
|
+
* - email: the email if available
|
|
45
|
+
* - error: error message if check failed
|
|
46
|
+
*/
|
|
47
|
+
async function checkWranglerAuth() {
|
|
48
|
+
try {
|
|
49
|
+
const { stdout, stderr } = await execAsync("bunx wrangler whoami", { timeout: 15e3 });
|
|
50
|
+
const output = stdout + stderr;
|
|
51
|
+
if (output.includes("not authenticated") || output.includes("Not logged in") || output.includes("wrangler login")) return {
|
|
52
|
+
loggedIn: false,
|
|
53
|
+
error: "Not logged in to Wrangler"
|
|
54
|
+
};
|
|
55
|
+
const emailMatch = output.match(/email[:\s]+([^\s!]+)/i);
|
|
56
|
+
const accountMatch = output.match(/Account\s+ID[:\s]+([a-f0-9]+)/i);
|
|
57
|
+
return {
|
|
58
|
+
loggedIn: true,
|
|
59
|
+
email: emailMatch?.[1],
|
|
60
|
+
accountId: accountMatch?.[1]
|
|
61
|
+
};
|
|
62
|
+
} catch (error) {
|
|
63
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
64
|
+
if (msg.includes("ENOENT") || msg.includes("not found")) return {
|
|
65
|
+
loggedIn: false,
|
|
66
|
+
error: "Wrangler not installed. Run: npm install -g wrangler"
|
|
67
|
+
};
|
|
68
|
+
return {
|
|
69
|
+
loggedIn: false,
|
|
70
|
+
error: msg
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Check if remote bindings are properly configured
|
|
76
|
+
*
|
|
77
|
+
* Returns warnings if:
|
|
78
|
+
* - Config has remote-only bindings but no accountId
|
|
79
|
+
* - Config has remote-only bindings but user is not logged in to wrangler
|
|
80
|
+
*/
|
|
81
|
+
async function checkRemoteBindingRequirements(config) {
|
|
82
|
+
const remoteBindings = detectRemoteBindings(config);
|
|
83
|
+
if (remoteBindings.length === 0) return {
|
|
84
|
+
hasRemoteBindings: false,
|
|
85
|
+
remoteBindings: [],
|
|
86
|
+
missingAccountId: false,
|
|
87
|
+
notLoggedIn: false
|
|
88
|
+
};
|
|
89
|
+
return {
|
|
90
|
+
hasRemoteBindings: true,
|
|
91
|
+
remoteBindings,
|
|
92
|
+
missingAccountId: !config.accountId,
|
|
93
|
+
notLoggedIn: !(await checkWranglerAuth()).loggedIn
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
//#endregion
|
|
97
|
+
//#region src/dev-server/dev-server-state.ts
|
|
98
|
+
/**
|
|
99
|
+
* Build a fresh `DevServerState` with all handles in their not-yet-started
|
|
100
|
+
* positions. `enableVite` is the user's request — `start()` may downgrade it
|
|
101
|
+
* later via `resolveViteIntegration`.
|
|
102
|
+
*/
|
|
103
|
+
function createDevServerState(initial) {
|
|
104
|
+
return {
|
|
105
|
+
enableVite: initial.enableVite,
|
|
106
|
+
miniflare: null,
|
|
107
|
+
doBundler: null,
|
|
108
|
+
workerSourceWatcher: null,
|
|
109
|
+
workerWatchTargets: [],
|
|
110
|
+
viteProcess: null,
|
|
111
|
+
config: null,
|
|
112
|
+
serviceBindingResolution: null,
|
|
113
|
+
browserShim: null,
|
|
114
|
+
browserShimPort: initial.browserShimPort ?? 8788,
|
|
115
|
+
mainWorkerSurfacePaths: {
|
|
116
|
+
fetch: null,
|
|
117
|
+
queue: null,
|
|
118
|
+
scheduled: null,
|
|
119
|
+
email: null,
|
|
120
|
+
tail: null
|
|
121
|
+
},
|
|
122
|
+
resolvedWorkerConfigPath: null,
|
|
123
|
+
mainWorkerScriptPath: null,
|
|
124
|
+
bundledMainWorkerScriptPath: null,
|
|
125
|
+
workflowEntrypointScript: "",
|
|
126
|
+
currentDoResult: null,
|
|
127
|
+
mainWorkerRoutes: null,
|
|
128
|
+
generatedViteConfigPath: null
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Tear down everything in `state` in the same order the legacy `stop()`
|
|
133
|
+
* function used. After this returns, every handle on `state` is `null` again
|
|
134
|
+
* and the local sendEmail bindings have been cleared.
|
|
135
|
+
*
|
|
136
|
+
* Order is important and intentionally mirrors the production sequence:
|
|
137
|
+
* 1. DO bundler (stop rebuilds before Miniflare goes away)
|
|
138
|
+
* 2. Worker source watcher (stop FS callbacks before Miniflare disposal)
|
|
139
|
+
* 3. Miniflare itself
|
|
140
|
+
* 4. Vite child process (after Miniflare so requests cannot race shutdown)
|
|
141
|
+
* 5. Browser shim
|
|
142
|
+
* 6. Local sendEmail registry reset
|
|
143
|
+
*/
|
|
144
|
+
async function disposeDevServerState(state) {
|
|
145
|
+
if (state.doBundler) {
|
|
146
|
+
await state.doBundler.close();
|
|
147
|
+
state.doBundler = null;
|
|
148
|
+
}
|
|
149
|
+
if (state.workerSourceWatcher) {
|
|
150
|
+
await state.workerSourceWatcher.close();
|
|
151
|
+
state.workerSourceWatcher = null;
|
|
152
|
+
}
|
|
153
|
+
if (state.miniflare) {
|
|
154
|
+
try {
|
|
155
|
+
await state.miniflare.dispose();
|
|
156
|
+
} catch (error) {
|
|
157
|
+
if (!isIgnorableMiniflareDisposeError(error)) throw error;
|
|
158
|
+
}
|
|
159
|
+
state.miniflare = null;
|
|
160
|
+
}
|
|
161
|
+
if (state.viteProcess) {
|
|
162
|
+
await stopSpawnedProcessTree(state.viteProcess);
|
|
163
|
+
state.viteProcess = null;
|
|
164
|
+
}
|
|
165
|
+
if (state.browserShim) {
|
|
166
|
+
await state.browserShim.stop();
|
|
167
|
+
state.browserShim = null;
|
|
168
|
+
}
|
|
169
|
+
clearLocalSendEmailBindings();
|
|
170
|
+
}
|
|
171
|
+
//#endregion
|
|
172
|
+
//#region src/dev-server/reload-queue.ts
|
|
173
|
+
function createReloadQueue({ reload, logger }) {
|
|
174
|
+
let running = null;
|
|
175
|
+
let pending = null;
|
|
176
|
+
async function runOnce() {
|
|
177
|
+
try {
|
|
178
|
+
await reload();
|
|
179
|
+
} catch (error) {
|
|
180
|
+
logger?.error("[devflare dev] reload failed:", error);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
function schedule() {
|
|
184
|
+
if (!running) {
|
|
185
|
+
running = runOnce().finally(() => {
|
|
186
|
+
running = null;
|
|
187
|
+
});
|
|
188
|
+
return running;
|
|
189
|
+
}
|
|
190
|
+
if (!pending) pending = running.then(() => {
|
|
191
|
+
pending = null;
|
|
192
|
+
running = runOnce().finally(() => {
|
|
193
|
+
running = null;
|
|
194
|
+
});
|
|
195
|
+
return running;
|
|
196
|
+
});
|
|
197
|
+
return pending;
|
|
198
|
+
}
|
|
199
|
+
async function drain() {
|
|
200
|
+
while (running || pending) if (pending) await pending;
|
|
201
|
+
else if (running) await running;
|
|
202
|
+
}
|
|
203
|
+
return {
|
|
204
|
+
schedule,
|
|
205
|
+
drain
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
//#endregion
|
|
209
|
+
//#region src/dev-server/runtime-health.ts
|
|
210
|
+
/** How often the runtime is probed. Cheap enough to be free, quick enough to catch a death between requests. */
|
|
211
|
+
const RUNTIME_PROBE_INTERVAL_MS = 2e3;
|
|
212
|
+
/** How long a single probe waits for the connection before counting as a failure. */
|
|
213
|
+
const RUNTIME_PROBE_TIMEOUT_MS = 1e3;
|
|
214
|
+
/**
|
|
215
|
+
* Whether something is accepting connections at this address.
|
|
216
|
+
*
|
|
217
|
+
* A plain TCP connect, deliberately: the bridge only needs the listener to exist, and an HTTP request
|
|
218
|
+
* would need a route that is meaningful for every app shape — a worker that 500s, hangs, or has no
|
|
219
|
+
* matching route would then read as "dead" and have its runtime rebuilt underneath it. The tradeoff
|
|
220
|
+
* is that a FOREIGN listener on the same port reads as alive; that only matters if something else
|
|
221
|
+
* seizes the port while the runtime is down, in which case the rebuild fails on the address anyway
|
|
222
|
+
* and the attempt limit reports it.
|
|
223
|
+
*
|
|
224
|
+
* @param options - `host`/`port` of the runtime, and how long to wait before giving up on the connect.
|
|
225
|
+
* @returns true when the connection was accepted.
|
|
226
|
+
*/
|
|
227
|
+
function probeTcpReachable(options) {
|
|
228
|
+
const { host, port, timeoutMs = RUNTIME_PROBE_TIMEOUT_MS } = options;
|
|
229
|
+
return new Promise((resolve) => {
|
|
230
|
+
let settled = false;
|
|
231
|
+
const settle = (reachable) => {
|
|
232
|
+
if (settled) return;
|
|
233
|
+
settled = true;
|
|
234
|
+
socket.destroy();
|
|
235
|
+
resolve(reachable);
|
|
236
|
+
};
|
|
237
|
+
const socket = connect({
|
|
238
|
+
host,
|
|
239
|
+
port
|
|
240
|
+
});
|
|
241
|
+
socket.setTimeout(timeoutMs);
|
|
242
|
+
socket.once("connect", () => settle(true));
|
|
243
|
+
socket.once("timeout", () => settle(false));
|
|
244
|
+
socket.on("error", () => settle(false));
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* A connect target that is dialable regardless of the address the runtime was bound to.
|
|
249
|
+
*
|
|
250
|
+
* A wildcard bind is not itself a valid destination on every platform, so probe the loopback address
|
|
251
|
+
* of the SAME family. The families do not cross: a `::` bind is reachable on `::1` and NOT on
|
|
252
|
+
* `127.0.0.1`, so collapsing both wildcards to the IPv4 loopback makes a healthy IPv6 runtime look
|
|
253
|
+
* dead — and the watchdog would then kill and rebuild it on a loop.
|
|
254
|
+
*
|
|
255
|
+
* @param host - the configured Miniflare host.
|
|
256
|
+
* @returns a host that can be connected to.
|
|
257
|
+
*/
|
|
258
|
+
function dialableHost(host) {
|
|
259
|
+
if (host === "::") return "::1";
|
|
260
|
+
if (host === "0.0.0.0") return "127.0.0.1";
|
|
261
|
+
return host;
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Watch a runtime and report it lost when it stops answering.
|
|
265
|
+
*
|
|
266
|
+
* The next probe is scheduled only once the previous one (and any rebuild it triggered) has finished,
|
|
267
|
+
* so a slow rebuild cannot stack up signals. Reaching the threshold resets the failure count, which
|
|
268
|
+
* spaces successive rebuild attempts a full threshold apart instead of firing on every probe.
|
|
269
|
+
*
|
|
270
|
+
* @param options - see {@link RuntimeWatchdogOptions}.
|
|
271
|
+
* @returns a handle whose `stop()` ends the watch.
|
|
272
|
+
*/
|
|
273
|
+
function createRuntimeWatchdog(options) {
|
|
274
|
+
const { probe, onRuntimeLost, intervalMs = RUNTIME_PROBE_INTERVAL_MS, failureThreshold = 3, recoveryAttemptLimit = 3, setTimer = (fn, ms) => setTimeout(fn, ms), clearTimer = (handle) => clearTimeout(handle), logger } = options;
|
|
275
|
+
let stopped = false;
|
|
276
|
+
let timer = null;
|
|
277
|
+
let consecutiveFailures = 0;
|
|
278
|
+
let recoveryAttempts = 0;
|
|
279
|
+
function scheduleNext() {
|
|
280
|
+
if (stopped) return;
|
|
281
|
+
timer = setTimer(() => {
|
|
282
|
+
tick();
|
|
283
|
+
}, intervalMs);
|
|
284
|
+
}
|
|
285
|
+
async function tick() {
|
|
286
|
+
if (stopped) return;
|
|
287
|
+
const reachable = await probe().catch(() => false);
|
|
288
|
+
if (stopped) return;
|
|
289
|
+
if (reachable) {
|
|
290
|
+
consecutiveFailures = 0;
|
|
291
|
+
recoveryAttempts = 0;
|
|
292
|
+
scheduleNext();
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
consecutiveFailures++;
|
|
296
|
+
if (consecutiveFailures < failureThreshold) {
|
|
297
|
+
scheduleNext();
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
recoveryAttempts++;
|
|
301
|
+
if (recoveryAttempts > recoveryAttemptLimit) {
|
|
302
|
+
logger?.error(`The local runtime keeps going away after ${recoveryAttemptLimit} rebuild attempts. Giving up so the real error stays visible — restart \`devflare dev\` once it is resolved.`);
|
|
303
|
+
stop();
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
try {
|
|
307
|
+
await onRuntimeLost();
|
|
308
|
+
} catch (error) {
|
|
309
|
+
logger?.error("[devflare dev] runtime rebuild failed:", error);
|
|
310
|
+
}
|
|
311
|
+
consecutiveFailures = 0;
|
|
312
|
+
scheduleNext();
|
|
313
|
+
}
|
|
314
|
+
function stop() {
|
|
315
|
+
if (stopped) return;
|
|
316
|
+
stopped = true;
|
|
317
|
+
if (timer !== null) {
|
|
318
|
+
clearTimer(timer);
|
|
319
|
+
timer = null;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
scheduleNext();
|
|
323
|
+
return { stop };
|
|
324
|
+
}
|
|
325
|
+
//#endregion
|
|
326
|
+
//#region src/dev-server/worker-source-watcher.ts
|
|
327
|
+
async function startWorkerSourceWatcher(options) {
|
|
328
|
+
const { watchTargets, resolvedWorkerConfigPath, logger, onConfigChange, onWorkerChange } = options;
|
|
329
|
+
if (watchTargets.length === 0) return null;
|
|
330
|
+
const chokidar = await import("chokidar");
|
|
331
|
+
const isWindows = process.platform === "win32";
|
|
332
|
+
const ignoredSegments = [
|
|
333
|
+
"/node_modules/",
|
|
334
|
+
"/.git/",
|
|
335
|
+
"/.devflare/",
|
|
336
|
+
"/dist/"
|
|
337
|
+
];
|
|
338
|
+
const normalizePath = (filePath) => filePath.replace(/\\/g, "/");
|
|
339
|
+
const isIgnoredPath = (filePath) => {
|
|
340
|
+
const normalizedPath = normalizePath(filePath);
|
|
341
|
+
return ignoredSegments.some((segment) => normalizedPath.includes(segment));
|
|
342
|
+
};
|
|
343
|
+
let reloadTimeout = null;
|
|
344
|
+
let reloadInProgress = false;
|
|
345
|
+
let pendingReloadPath = null;
|
|
346
|
+
const flushPendingReload = async () => {
|
|
347
|
+
if (!pendingReloadPath) return;
|
|
348
|
+
const nextPath = pendingReloadPath;
|
|
349
|
+
pendingReloadPath = null;
|
|
350
|
+
await triggerReload(nextPath);
|
|
351
|
+
};
|
|
352
|
+
const triggerReload = async (filePath) => {
|
|
353
|
+
if (reloadInProgress) {
|
|
354
|
+
pendingReloadPath = filePath;
|
|
355
|
+
return;
|
|
356
|
+
}
|
|
357
|
+
reloadInProgress = true;
|
|
358
|
+
try {
|
|
359
|
+
const normalizedConfigPath = resolvedWorkerConfigPath ? normalizePath(resolvedWorkerConfigPath) : null;
|
|
360
|
+
if (normalizedConfigPath && normalizePath(filePath) === normalizedConfigPath) {
|
|
361
|
+
logger?.info(`Devflare config changed: ${filePath}`);
|
|
362
|
+
await onConfigChange();
|
|
363
|
+
return;
|
|
364
|
+
}
|
|
365
|
+
logger?.info(`Worker source changed: ${filePath}`);
|
|
366
|
+
await onWorkerChange();
|
|
367
|
+
} catch (error) {
|
|
368
|
+
logger?.error("Worker source reload failed:", error);
|
|
369
|
+
} finally {
|
|
370
|
+
reloadInProgress = false;
|
|
371
|
+
await flushPendingReload();
|
|
372
|
+
}
|
|
373
|
+
};
|
|
374
|
+
const scheduleReload = (filePath) => {
|
|
375
|
+
if (reloadTimeout) clearTimeout(reloadTimeout);
|
|
376
|
+
reloadTimeout = setTimeout(() => {
|
|
377
|
+
reloadTimeout = null;
|
|
378
|
+
triggerReload(filePath);
|
|
379
|
+
}, 150);
|
|
380
|
+
};
|
|
381
|
+
const watcher = chokidar.watch(watchTargets, {
|
|
382
|
+
ignoreInitial: true,
|
|
383
|
+
usePolling: isWindows,
|
|
384
|
+
interval: isWindows ? 300 : void 0,
|
|
385
|
+
awaitWriteFinish: {
|
|
386
|
+
stabilityThreshold: 100,
|
|
387
|
+
pollInterval: 50
|
|
388
|
+
},
|
|
389
|
+
ignored: (filePath) => isIgnoredPath(filePath)
|
|
390
|
+
});
|
|
391
|
+
const onFileEvent = (filePath) => {
|
|
392
|
+
if (isIgnoredPath(filePath)) return;
|
|
393
|
+
scheduleReload(filePath);
|
|
394
|
+
};
|
|
395
|
+
watcher.on("change", onFileEvent);
|
|
396
|
+
watcher.on("add", onFileEvent);
|
|
397
|
+
watcher.on("unlink", onFileEvent);
|
|
398
|
+
watcher.on("error", (error) => {
|
|
399
|
+
logger?.error("Worker source watcher error:", error);
|
|
400
|
+
});
|
|
401
|
+
await new Promise((resolvePromise, rejectPromise) => {
|
|
402
|
+
const handleReady = () => {
|
|
403
|
+
watcher.off("error", handleInitialError);
|
|
404
|
+
logger?.info(`Worker source watcher ready (${watchTargets.length} target(s))`);
|
|
405
|
+
resolvePromise();
|
|
406
|
+
};
|
|
407
|
+
const handleInitialError = (error) => {
|
|
408
|
+
watcher.off("ready", handleReady);
|
|
409
|
+
rejectPromise(error instanceof Error ? error : new Error(String(error)));
|
|
410
|
+
};
|
|
411
|
+
watcher.once("ready", handleReady);
|
|
412
|
+
watcher.once("error", handleInitialError);
|
|
413
|
+
});
|
|
414
|
+
return watcher;
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* Compute the diff between current and next watch-target lists and apply it
|
|
418
|
+
* to the given watcher. Returns the deduped next-targets array which the
|
|
419
|
+
* caller should store as the new "current" state.
|
|
420
|
+
*/
|
|
421
|
+
async function applyWatcherTargetDiff(watcher, currentTargets, nextTargets) {
|
|
422
|
+
const nextSet = new Set(nextTargets);
|
|
423
|
+
const targetsToRemove = currentTargets.filter((t) => !nextSet.has(t));
|
|
424
|
+
const targetsToAdd = nextTargets.filter((t) => !currentTargets.includes(t));
|
|
425
|
+
if (targetsToRemove.length > 0) await watcher.unwatch(targetsToRemove);
|
|
426
|
+
if (targetsToAdd.length > 0) watcher.add(targetsToAdd);
|
|
427
|
+
return nextTargets;
|
|
428
|
+
}
|
|
429
|
+
//#endregion
|
|
430
|
+
//#region src/dev-server/server.ts
|
|
431
|
+
function createDevServer(options) {
|
|
432
|
+
const { cwd, configPath, vitePort = 5173, miniflarePort = 8787, miniflareHost = "127.0.0.1", enableVite: enableViteRequested = true, persist = true, logger, verbose = false, debug = process.env.DEVFLARE_DEBUG === "true" } = options;
|
|
433
|
+
const state = createDevServerState({ enableVite: enableViteRequested });
|
|
434
|
+
const r2PresignSecret = `${crypto.randomUUID()}${crypto.randomUUID()}`;
|
|
435
|
+
/** Whether the local runtime is still accepting connections. */
|
|
436
|
+
async function isRuntimeReachable() {
|
|
437
|
+
return probeTcpReachable({
|
|
438
|
+
host: dialableHost(miniflareHost),
|
|
439
|
+
port: miniflarePort
|
|
440
|
+
});
|
|
441
|
+
}
|
|
442
|
+
/**
|
|
443
|
+
* Drop a runtime that has already gone away.
|
|
444
|
+
*
|
|
445
|
+
* Disposing a dead Miniflare routinely throws (its runtime is not there to talk to), which is not a
|
|
446
|
+
* reason to abandon the rebuild — so anything unrecognised is logged rather than propagated.
|
|
447
|
+
*/
|
|
448
|
+
async function discardDeadMiniflare() {
|
|
449
|
+
if (!state.miniflare) return;
|
|
450
|
+
try {
|
|
451
|
+
await state.miniflare.dispose();
|
|
452
|
+
} catch (error) {
|
|
453
|
+
if (!isIgnorableMiniflareDisposeError(error)) logger?.debug("Disposing the dead Miniflare threw (continuing with the rebuild):", error);
|
|
454
|
+
}
|
|
455
|
+
state.miniflare = null;
|
|
456
|
+
}
|
|
457
|
+
/**
|
|
458
|
+
* Set once {@link stop} begins. A rebuild started just before shutdown would otherwise construct a
|
|
459
|
+
* fresh Miniflare AFTER the teardown disposed the old one, leaking a runtime that outlives the
|
|
460
|
+
* server — which shows up as the next thing to use the port hanging.
|
|
461
|
+
*/
|
|
462
|
+
let isStopping = false;
|
|
463
|
+
/**
|
|
464
|
+
* Set once the runtime has come up at least once. Gates the rebuild path so a reload that arrives
|
|
465
|
+
* before the first start cannot mistake "not started yet" for "died".
|
|
466
|
+
*/
|
|
467
|
+
let hasStartedRuntime = false;
|
|
468
|
+
const reloadQueue = createReloadQueue({
|
|
469
|
+
reload: async () => {
|
|
470
|
+
if (isStopping) return;
|
|
471
|
+
if (hasStartedRuntime && !await isRuntimeReachable()) {
|
|
472
|
+
if (isStopping) return;
|
|
473
|
+
logger?.warn("Local runtime stopped responding — rebuilding it");
|
|
474
|
+
await discardDeadMiniflare();
|
|
475
|
+
await startMiniflare(state.currentDoResult);
|
|
476
|
+
await runD1Migrations({
|
|
477
|
+
cwd,
|
|
478
|
+
config: state.config,
|
|
479
|
+
miniflarePort,
|
|
480
|
+
logger
|
|
481
|
+
});
|
|
482
|
+
return;
|
|
483
|
+
}
|
|
484
|
+
if (!state.miniflare) return;
|
|
485
|
+
const { Log, LogLevel } = await import("miniflare");
|
|
486
|
+
const mfConfig = buildMiniflareConfig(state.currentDoResult);
|
|
487
|
+
const log = createMiniflareLog(Log, LogLevel, "DEBUG", logger);
|
|
488
|
+
if (log) mfConfig.log = log;
|
|
489
|
+
mfConfig.handleRuntimeStdio = createRuntimeStdioForwarder(logger);
|
|
490
|
+
logger?.info("Reloading Miniflare...");
|
|
491
|
+
await state.miniflare.setOptions(mfConfig);
|
|
492
|
+
logger?.success("Miniflare reloaded");
|
|
493
|
+
},
|
|
494
|
+
logger
|
|
495
|
+
});
|
|
496
|
+
/**
|
|
497
|
+
* Watches the runtime for the rest of the process's life, once it is first up.
|
|
498
|
+
*
|
|
499
|
+
* Held here rather than on {@link DevServerState} because it is pure server orchestration — it owns
|
|
500
|
+
* no resource the teardown sequence has to order around, only a timer.
|
|
501
|
+
*/
|
|
502
|
+
let runtimeWatchdog = null;
|
|
503
|
+
/**
|
|
504
|
+
* Begin watching the runtime, if it is not already being watched.
|
|
505
|
+
*
|
|
506
|
+
* Deliberately idempotent, because `startMiniflare` also runs on the REBUILD path — replacing the
|
|
507
|
+
* watchdog there would hand each rebuild a fresh recovery budget, so a probe that is wrong about a
|
|
508
|
+
* healthy runtime could rebuild it forever without the attempt limit ever biting. One watchdog for
|
|
509
|
+
* the server's lifetime keeps that budget meaningful; only a successful probe clears it.
|
|
510
|
+
*/
|
|
511
|
+
function watchRuntimeHealth() {
|
|
512
|
+
if (isStopping || runtimeWatchdog) return;
|
|
513
|
+
runtimeWatchdog = createRuntimeWatchdog({
|
|
514
|
+
probe: isRuntimeReachable,
|
|
515
|
+
onRuntimeLost: () => reloadQueue.schedule(),
|
|
516
|
+
logger
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
async function bundleMainWorker() {
|
|
520
|
+
if (!state.mainWorkerScriptPath || !state.config) {
|
|
521
|
+
state.bundledMainWorkerScriptPath = null;
|
|
522
|
+
return;
|
|
523
|
+
}
|
|
524
|
+
state.bundledMainWorkerScriptPath = await bundleWorkerEntry({
|
|
525
|
+
cwd,
|
|
526
|
+
inputFile: state.mainWorkerScriptPath,
|
|
527
|
+
outFile: generatedDir(cwd, "worker-entrypoints", "main.js"),
|
|
528
|
+
rolldownOptions: state.config.rolldown?.options,
|
|
529
|
+
sourcemap: state.config.rolldown?.sourcemap,
|
|
530
|
+
minify: state.config.rolldown?.minify,
|
|
531
|
+
logger
|
|
532
|
+
});
|
|
533
|
+
logger?.debug(`Bundled main worker → ${state.bundledMainWorkerScriptPath}`);
|
|
534
|
+
}
|
|
535
|
+
function buildMiniflareConfig(doResult) {
|
|
536
|
+
if (!state.config) throw new Error("Config not loaded");
|
|
537
|
+
return buildMiniflareDevConfig({
|
|
538
|
+
config: state.config,
|
|
539
|
+
cwd,
|
|
540
|
+
miniflarePort,
|
|
541
|
+
miniflareHost,
|
|
542
|
+
persist,
|
|
543
|
+
enableVite: state.enableVite,
|
|
544
|
+
debug,
|
|
545
|
+
mainWorkerSurfacePaths: state.mainWorkerSurfacePaths,
|
|
546
|
+
mainWorkerRoutes: state.mainWorkerRoutes,
|
|
547
|
+
mainWorkerScriptPath: state.mainWorkerScriptPath,
|
|
548
|
+
bundledMainWorkerScriptPath: state.bundledMainWorkerScriptPath,
|
|
549
|
+
workflowEntrypointScript: state.workflowEntrypointScript,
|
|
550
|
+
browserShimPort: state.browserShimPort,
|
|
551
|
+
doResult,
|
|
552
|
+
serviceBindingResolution: state.serviceBindingResolution,
|
|
553
|
+
r2PresignSecret,
|
|
554
|
+
logger
|
|
555
|
+
});
|
|
556
|
+
}
|
|
557
|
+
async function bundleWorkflowEntrypoints() {
|
|
558
|
+
if (!state.config) {
|
|
559
|
+
state.workflowEntrypointScript = "";
|
|
560
|
+
return;
|
|
561
|
+
}
|
|
562
|
+
state.workflowEntrypointScript = await bundleWorkflowEntrypointScript(state.config, cwd, { logger });
|
|
563
|
+
}
|
|
564
|
+
/**
|
|
565
|
+
* Start Miniflare with current config
|
|
566
|
+
*/
|
|
567
|
+
async function startMiniflare(doResult) {
|
|
568
|
+
const { Miniflare, Log, LogLevel } = await import("miniflare");
|
|
569
|
+
const mfConfig = buildMiniflareConfig(doResult);
|
|
570
|
+
const log = createMiniflareLog(Log, LogLevel, "DEBUG", logger);
|
|
571
|
+
if (log) mfConfig.log = log;
|
|
572
|
+
mfConfig.handleRuntimeStdio = createRuntimeStdioForwarder(logger);
|
|
573
|
+
const shouldLogMiniflareDiagnostics = verbose || debug;
|
|
574
|
+
if (shouldLogMiniflareDiagnostics) logMiniflareConfigDiagnostics(logger, mfConfig);
|
|
575
|
+
const miniflare = new Miniflare(mfConfig);
|
|
576
|
+
state.miniflare = miniflare;
|
|
577
|
+
await miniflare.ready;
|
|
578
|
+
const displayHost = miniflareHost === "0.0.0.0" || miniflareHost === "::" ? "localhost" : miniflareHost;
|
|
579
|
+
logger?.success(`Miniflare ready on http://${displayHost}:${miniflarePort}`);
|
|
580
|
+
hasStartedRuntime = true;
|
|
581
|
+
watchRuntimeHealth();
|
|
582
|
+
if (shouldLogMiniflareDiagnostics) await logMiniflareBindingDiagnostics(logger, state.miniflare, mfConfig);
|
|
583
|
+
}
|
|
584
|
+
/**
|
|
585
|
+
* Reload Miniflare with updated DO bundles
|
|
586
|
+
*/
|
|
587
|
+
async function reloadMiniflare(doResult) {
|
|
588
|
+
state.currentDoResult = doResult;
|
|
589
|
+
await reloadQueue.schedule();
|
|
590
|
+
}
|
|
591
|
+
async function refreshWorkerOnlySurfaceState() {
|
|
592
|
+
if (!state.config) return;
|
|
593
|
+
state.mainWorkerSurfacePaths = await resolveMainWorkerSurfacePaths(cwd, state.config);
|
|
594
|
+
state.mainWorkerRoutes = await discoverRoutes(cwd, state.config);
|
|
595
|
+
const composedMainEntry = await prepareComposedWorkerEntrypoint(cwd, state.config, void 0, { devInternalEmail: true });
|
|
596
|
+
state.mainWorkerScriptPath = composedMainEntry ? composedMainEntry : null;
|
|
597
|
+
if (state.mainWorkerScriptPath) await bundleMainWorker();
|
|
598
|
+
else state.bundledMainWorkerScriptPath = null;
|
|
599
|
+
await syncWorkerWatchTargets();
|
|
600
|
+
}
|
|
601
|
+
function getWorkerWatchTargets() {
|
|
602
|
+
if (state.enableVite || !state.config) return [];
|
|
603
|
+
const targets = collectWorkerWatchRoots(cwd, state.config, state.mainWorkerSurfacePaths);
|
|
604
|
+
if (state.resolvedWorkerConfigPath) targets.push(state.resolvedWorkerConfigPath);
|
|
605
|
+
return [...new Set(targets)];
|
|
606
|
+
}
|
|
607
|
+
async function syncWorkerWatchTargets() {
|
|
608
|
+
if (!state.workerSourceWatcher) return;
|
|
609
|
+
state.workerWatchTargets = await applyWatcherTargetDiff(state.workerSourceWatcher, state.workerWatchTargets, getWorkerWatchTargets());
|
|
610
|
+
}
|
|
611
|
+
async function reloadWorkerOnlyConfig() {
|
|
612
|
+
await loadRuntimeConfigWhenEnvReady();
|
|
613
|
+
if (!state.config) return;
|
|
614
|
+
setLocalSendEmailBindings(state.config.bindings?.sendEmail ?? {});
|
|
615
|
+
await bundleWorkflowEntrypoints();
|
|
616
|
+
await refreshWorkerOnlySurfaceState();
|
|
617
|
+
await reloadMiniflare(state.currentDoResult);
|
|
618
|
+
}
|
|
619
|
+
async function loadRuntimeConfig() {
|
|
620
|
+
state.resolvedWorkerConfigPath = await resolveWorkerConfigWatchPath(cwd, configPath);
|
|
621
|
+
state.config = await applyLocalDevVarsToConfig(await resolveConfigEnvVars(await loadConfig({
|
|
622
|
+
cwd,
|
|
623
|
+
configFile: configPath
|
|
624
|
+
}), {
|
|
625
|
+
cwd,
|
|
626
|
+
configPath: state.resolvedWorkerConfigPath ?? configPath,
|
|
627
|
+
mode: "dev"
|
|
628
|
+
}), {
|
|
629
|
+
cwd,
|
|
630
|
+
configPath: state.resolvedWorkerConfigPath ?? void 0
|
|
631
|
+
});
|
|
632
|
+
state.serviceBindingResolution = state.config.bindings?.services ? await resolveServiceBindings(state.config, state.resolvedWorkerConfigPath ? dirname(state.resolvedWorkerConfigPath) : cwd) : null;
|
|
633
|
+
}
|
|
634
|
+
async function waitForDotenvChange() {
|
|
635
|
+
const configWatchPath = state.resolvedWorkerConfigPath ?? await resolveWorkerConfigWatchPath(cwd, configPath);
|
|
636
|
+
const watchPaths = getDevflareDotenvPaths(configWatchPath ? dirname(configWatchPath) : cwd);
|
|
637
|
+
const { watch } = await import("chokidar");
|
|
638
|
+
await new Promise((resolveWait, rejectWait) => {
|
|
639
|
+
const watcher = watch(watchPaths, {
|
|
640
|
+
ignoreInitial: true,
|
|
641
|
+
awaitWriteFinish: {
|
|
642
|
+
stabilityThreshold: 100,
|
|
643
|
+
pollInterval: 25
|
|
644
|
+
}
|
|
645
|
+
});
|
|
646
|
+
const finish = () => {
|
|
647
|
+
watcher.close().then(resolveWait, rejectWait);
|
|
648
|
+
};
|
|
649
|
+
watcher.on("add", finish);
|
|
650
|
+
watcher.on("change", finish);
|
|
651
|
+
watcher.on("unlink", finish);
|
|
652
|
+
watcher.on("error", rejectWait);
|
|
653
|
+
});
|
|
654
|
+
}
|
|
655
|
+
async function loadRuntimeConfigWhenEnvReady() {
|
|
656
|
+
while (true) try {
|
|
657
|
+
await loadRuntimeConfig();
|
|
658
|
+
return;
|
|
659
|
+
} catch (error) {
|
|
660
|
+
if (!(error instanceof EnvVarResolutionError)) throw error;
|
|
661
|
+
logger?.warn(error.message);
|
|
662
|
+
logger?.info("Devflare dev is waiting for .env or .env.dev to change before starting.");
|
|
663
|
+
await waitForDotenvChange();
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
async function startWorkerSourceWatcher$1() {
|
|
667
|
+
if (state.enableVite || !state.config) return;
|
|
668
|
+
const watchTargets = getWorkerWatchTargets();
|
|
669
|
+
if (watchTargets.length === 0) return;
|
|
670
|
+
state.workerWatchTargets = watchTargets;
|
|
671
|
+
state.workerSourceWatcher = await startWorkerSourceWatcher({
|
|
672
|
+
watchTargets,
|
|
673
|
+
resolvedWorkerConfigPath: state.resolvedWorkerConfigPath,
|
|
674
|
+
logger,
|
|
675
|
+
onConfigChange: reloadWorkerOnlyConfig,
|
|
676
|
+
onWorkerChange: async () => {
|
|
677
|
+
await refreshWorkerOnlySurfaceState();
|
|
678
|
+
await reloadMiniflare(state.currentDoResult);
|
|
679
|
+
}
|
|
680
|
+
});
|
|
681
|
+
}
|
|
682
|
+
/**
|
|
683
|
+
* Start the complete dev server
|
|
684
|
+
*/
|
|
685
|
+
async function start() {
|
|
686
|
+
logger?.info("Starting unified dev server...");
|
|
687
|
+
await loadRuntimeConfigWhenEnvReady();
|
|
688
|
+
if (!state.config) throw new Error("Config not loaded");
|
|
689
|
+
setLocalSendEmailBindings(state.config.bindings?.sendEmail ?? {});
|
|
690
|
+
logger?.debug("Loaded config:", state.config.name);
|
|
691
|
+
await bundleWorkflowEntrypoints();
|
|
692
|
+
const viteIntegration = await resolveViteIntegration({
|
|
693
|
+
cwd,
|
|
694
|
+
configPath,
|
|
695
|
+
miniflarePort,
|
|
696
|
+
enableViteRequested: state.enableVite,
|
|
697
|
+
logger
|
|
698
|
+
});
|
|
699
|
+
state.enableVite = viteIntegration.enableVite;
|
|
700
|
+
state.generatedViteConfigPath = viteIntegration.generatedViteConfigPath;
|
|
701
|
+
await refreshWorkerOnlySurfaceState();
|
|
702
|
+
if (!state.enableVite && (hasWorkerSurfacePaths(state.mainWorkerSurfacePaths) || Boolean(state.mainWorkerRoutes?.routes.length))) logWorkerHandlerDetection(logger, state.enableVite, true, state.mainWorkerSurfacePaths, state.mainWorkerRoutes);
|
|
703
|
+
else if (!state.enableVite) logWorkerHandlerDetection(logger, state.enableVite, false, state.mainWorkerSurfacePaths, state.mainWorkerRoutes);
|
|
704
|
+
logRemoteBindingRequirements(logger, await checkRemoteBindingRequirements(state.config));
|
|
705
|
+
state.browserShim = await maybeStartBrowserShim(state.config, {
|
|
706
|
+
browserShimPort: state.browserShimPort,
|
|
707
|
+
logger,
|
|
708
|
+
verbose
|
|
709
|
+
});
|
|
710
|
+
const doInit = await maybeStartDOBundler(state.config, {
|
|
711
|
+
cwd,
|
|
712
|
+
logger,
|
|
713
|
+
onRebuild: async (result) => {
|
|
714
|
+
await reloadMiniflare(result);
|
|
715
|
+
}
|
|
716
|
+
});
|
|
717
|
+
state.doBundler = doInit.bundler;
|
|
718
|
+
const doResult = doInit.result;
|
|
719
|
+
state.currentDoResult = doResult;
|
|
720
|
+
await startMiniflare(doResult);
|
|
721
|
+
await startWorkerSourceWatcher$1();
|
|
722
|
+
if (state.enableVite) state.viteProcess = await startViteProcess({
|
|
723
|
+
cwd,
|
|
724
|
+
configPath,
|
|
725
|
+
vitePort,
|
|
726
|
+
miniflarePort,
|
|
727
|
+
generatedViteConfigPath: state.generatedViteConfigPath,
|
|
728
|
+
r2Presign: state.config.bindings?.r2 ? {
|
|
729
|
+
secret: r2PresignSecret,
|
|
730
|
+
origin: resolveR2PresignOrigin(state.config.server, miniflareHost, miniflarePort)
|
|
731
|
+
} : null,
|
|
732
|
+
logger
|
|
733
|
+
});
|
|
734
|
+
else logger?.info("Vite startup skipped (no effective Vite config found for this package)");
|
|
735
|
+
await new Promise((r) => setTimeout(r, 1e3));
|
|
736
|
+
await runD1Migrations({
|
|
737
|
+
cwd,
|
|
738
|
+
config: state.config,
|
|
739
|
+
miniflarePort,
|
|
740
|
+
logger
|
|
741
|
+
});
|
|
742
|
+
}
|
|
743
|
+
/**
|
|
744
|
+
* Stop the dev server
|
|
745
|
+
*/
|
|
746
|
+
async function stop() {
|
|
747
|
+
isStopping = true;
|
|
748
|
+
runtimeWatchdog?.stop();
|
|
749
|
+
runtimeWatchdog = null;
|
|
750
|
+
await reloadQueue.drain();
|
|
751
|
+
await disposeDevServerState(state);
|
|
752
|
+
}
|
|
753
|
+
/**
|
|
754
|
+
* Get Miniflare instance
|
|
755
|
+
*/
|
|
756
|
+
function getMiniflare() {
|
|
757
|
+
return state.miniflare;
|
|
758
|
+
}
|
|
759
|
+
return {
|
|
760
|
+
start,
|
|
761
|
+
stop,
|
|
762
|
+
getMiniflare
|
|
763
|
+
};
|
|
764
|
+
}
|
|
765
|
+
//#endregion
|
|
766
|
+
//#region src/cli/commands/dev.ts
|
|
767
|
+
function readStringOption(value) {
|
|
768
|
+
return typeof value === "string" ? value : void 0;
|
|
769
|
+
}
|
|
770
|
+
function parsePort(value, source) {
|
|
771
|
+
const port = Number(value);
|
|
772
|
+
if (!Number.isInteger(port) || port <= 0 || port > 65535) throw new Error(`${source} must be an integer between 1 and 65535`);
|
|
773
|
+
return port;
|
|
774
|
+
}
|
|
775
|
+
function resolveSinglePort(runtimePort, bridgePort, source) {
|
|
776
|
+
if (runtimePort && bridgePort && runtimePort !== bridgePort) throw new Error(`Conflicting Devflare runtime ports: ${source} runtime port is ${runtimePort}, but bridge port is ${bridgePort}. Use one value for both.`);
|
|
777
|
+
const value = runtimePort ?? bridgePort;
|
|
778
|
+
return value ? parsePort(value, source) : void 0;
|
|
779
|
+
}
|
|
780
|
+
function resolveDevRuntimePort(options, env = process.env, configPort) {
|
|
781
|
+
return resolveSinglePort(readStringOption(options["runtime-port"]), readStringOption(options["bridge-port"]), "CLI") ?? resolveSinglePort(env.DEVFLARE_RUNTIME_PORT, env.DEVFLARE_BRIDGE_PORT, "environment") ?? configPort ?? 8787;
|
|
782
|
+
}
|
|
783
|
+
/**
|
|
784
|
+
* Resolve the host the local Miniflare runtime instance binds to.
|
|
785
|
+
*
|
|
786
|
+
* Precedence: `--runtime-host` CLI flag > `DEVFLARE_RUNTIME_HOST` env var >
|
|
787
|
+
* `server.host` config value > `127.0.0.1`.
|
|
788
|
+
*/
|
|
789
|
+
function resolveDevRuntimeHost(options, env = process.env, configHost) {
|
|
790
|
+
const envHost = env.DEVFLARE_RUNTIME_HOST?.trim();
|
|
791
|
+
return readStringOption(options["runtime-host"]) ?? (envHost ? envHost : void 0) ?? configHost ?? "127.0.0.1";
|
|
792
|
+
}
|
|
793
|
+
/**
|
|
794
|
+
* Create a log writer that writes to both terminal and file
|
|
795
|
+
*/
|
|
796
|
+
async function createLogWriter(cwd, options) {
|
|
797
|
+
if (!options.log && !options.logTemp) return null;
|
|
798
|
+
const fs = await import("node:fs");
|
|
799
|
+
let logPath;
|
|
800
|
+
if (options.logTemp) logPath = resolve(cwd, ".log");
|
|
801
|
+
else logPath = resolve(cwd, `.log-${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-").replace("T", "_").slice(0, 19)}`);
|
|
802
|
+
const fileStream = fs.createWriteStream(logPath, { flags: "w" });
|
|
803
|
+
const ansiRegex = /\x1b\[[0-9;]*m/g;
|
|
804
|
+
return {
|
|
805
|
+
path: logPath,
|
|
806
|
+
write(data, source) {
|
|
807
|
+
const str = typeof data === "string" ? data : data.toString();
|
|
808
|
+
if (!str.trim()) return;
|
|
809
|
+
const timestamp = (/* @__PURE__ */ new Date()).toISOString().slice(11, 23);
|
|
810
|
+
const prefix = source ? `[${timestamp}][${source.toUpperCase()}] ` : `[${timestamp}] `;
|
|
811
|
+
const cleanStr = str.replace(ansiRegex, "");
|
|
812
|
+
fileStream.write(prefix + cleanStr + (cleanStr.endsWith("\n") ? "" : "\n"));
|
|
813
|
+
},
|
|
814
|
+
close() {
|
|
815
|
+
fileStream.end();
|
|
816
|
+
}
|
|
817
|
+
};
|
|
818
|
+
}
|
|
819
|
+
async function runDevCommand(parsed, logger, options) {
|
|
820
|
+
const cwd = options.cwd || parsed.options.cwd || process.cwd();
|
|
821
|
+
const configPath = parsed.options.config;
|
|
822
|
+
const port = parsed.options.port;
|
|
823
|
+
const logEnabled = parsed.options.log === true;
|
|
824
|
+
const logTempEnabled = parsed.options["log-temp"] === true;
|
|
825
|
+
const persistEnabled = parsed.options.persist === true;
|
|
826
|
+
const debugEnabled = parsed.options.debug === true || process.env.DEVFLARE_DEBUG === "true";
|
|
827
|
+
const verbose = parsed.options.verbose === true || debugEnabled;
|
|
828
|
+
const theme = createCliTheme(parsed.options);
|
|
829
|
+
const config = await loadConfig({
|
|
830
|
+
cwd,
|
|
831
|
+
configFile: configPath
|
|
832
|
+
});
|
|
833
|
+
let miniflarePort;
|
|
834
|
+
let miniflareHost;
|
|
835
|
+
try {
|
|
836
|
+
miniflarePort = resolveDevRuntimePort(parsed.options, process.env, config.server?.port);
|
|
837
|
+
miniflareHost = resolveDevRuntimeHost(parsed.options, process.env, config.server?.host);
|
|
838
|
+
} catch (error) {
|
|
839
|
+
logger.error(error instanceof Error ? error.message : String(error));
|
|
840
|
+
return { exitCode: 1 };
|
|
841
|
+
}
|
|
842
|
+
const viteProject = resolveEffectiveViteProject(await detectViteProject(cwd), config);
|
|
843
|
+
const logWriter = await createLogWriter(cwd, {
|
|
844
|
+
log: logEnabled,
|
|
845
|
+
logTemp: logTempEnabled
|
|
846
|
+
});
|
|
847
|
+
if (logWriter) {
|
|
848
|
+
const logFile = relative(cwd, logWriter.path) || ".log";
|
|
849
|
+
logLine(logger, `${dim("logging", theme)} ${logFile}`);
|
|
850
|
+
}
|
|
851
|
+
const devLogger = createConsola({ level: verbose ? 4 : 3 });
|
|
852
|
+
if (logWriter) {
|
|
853
|
+
const wrapLog = (original, prefix = "") => {
|
|
854
|
+
return (message, ...args) => {
|
|
855
|
+
original(message, ...args);
|
|
856
|
+
const formatted = prefix ? `${prefix} ${[message, ...args].join(" ")}` : [message, ...args].join(" ");
|
|
857
|
+
logWriter.write(formatted);
|
|
858
|
+
};
|
|
859
|
+
};
|
|
860
|
+
Object.assign(devLogger.log, wrapLog(devLogger.log.bind(devLogger)));
|
|
861
|
+
Object.assign(devLogger.info, wrapLog(devLogger.info.bind(devLogger)));
|
|
862
|
+
Object.assign(devLogger.error, wrapLog(devLogger.error.bind(devLogger), "[ERROR]"));
|
|
863
|
+
Object.assign(devLogger.warn, wrapLog(devLogger.warn.bind(devLogger), "[WARN]"));
|
|
864
|
+
Object.assign(devLogger.success, wrapLog(devLogger.success.bind(devLogger), "[OK]"));
|
|
865
|
+
Object.assign(devLogger.debug, wrapLog(devLogger.debug.bind(devLogger), "[DEBUG]"));
|
|
866
|
+
}
|
|
867
|
+
try {
|
|
868
|
+
logLine(logger);
|
|
869
|
+
if (viteProject.shouldStartVite) {
|
|
870
|
+
logLine(logger, `${cyanBold("dev", theme)} ${dim("Unified Dev Server", theme)}`);
|
|
871
|
+
logLine(logger, " ├─ Vite: Full HMR for frontend");
|
|
872
|
+
logLine(logger, " ├─ Miniflare: All Cloudflare bindings");
|
|
873
|
+
logLine(logger, " ├─ Rolldown: Worker + DO bundling with watch");
|
|
874
|
+
logLine(logger, " └─ Bridge: WebSocket RPC connection");
|
|
875
|
+
} else {
|
|
876
|
+
logLine(logger, `${cyanBold("dev", theme)} ${dim("Worker Dev Server", theme)}`);
|
|
877
|
+
logLine(logger, " ├─ Miniflare: All Cloudflare bindings");
|
|
878
|
+
logLine(logger, " ├─ Rolldown: Worker + DO bundling with watch");
|
|
879
|
+
logLine(logger, " └─ Vite: Disabled (no effective Vite config found)");
|
|
880
|
+
if (viteProject.wantsViteIntegration) {
|
|
881
|
+
logger.warn("Vite-related settings were detected, but no effective Vite config was available");
|
|
882
|
+
logger.warn("Skipping Vite startup and running in worker-only mode");
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
logLine(logger);
|
|
886
|
+
const devServer = createDevServer({
|
|
887
|
+
cwd,
|
|
888
|
+
configPath,
|
|
889
|
+
vitePort: port ? Number.parseInt(port, 10) : 5173,
|
|
890
|
+
miniflarePort,
|
|
891
|
+
miniflareHost,
|
|
892
|
+
enableVite: viteProject.shouldStartVite,
|
|
893
|
+
persist: persistEnabled,
|
|
894
|
+
logger: devLogger,
|
|
895
|
+
verbose,
|
|
896
|
+
debug: debugEnabled
|
|
897
|
+
});
|
|
898
|
+
let isCleaningUp = false;
|
|
899
|
+
const cleanupHandlers = /* @__PURE__ */ new Map();
|
|
900
|
+
const removeCleanupHandlers = () => {
|
|
901
|
+
for (const [event, handler] of cleanupHandlers) process.off(event, handler);
|
|
902
|
+
cleanupHandlers.clear();
|
|
903
|
+
};
|
|
904
|
+
const cleanup = async (exitCode, reason) => {
|
|
905
|
+
if (isCleaningUp) return;
|
|
906
|
+
isCleaningUp = true;
|
|
907
|
+
removeCleanupHandlers();
|
|
908
|
+
if (reason) {
|
|
909
|
+
const message = reason instanceof Error ? reason.stack ?? reason.message : String(reason);
|
|
910
|
+
logger.error(message);
|
|
911
|
+
}
|
|
912
|
+
logLine(logger);
|
|
913
|
+
logLine(logger, `${yellow("dev", theme)} ${dim("Shutting down…", theme)}`);
|
|
914
|
+
try {
|
|
915
|
+
await devServer.stop();
|
|
916
|
+
} finally {
|
|
917
|
+
logWriter?.close();
|
|
918
|
+
process.exit(exitCode);
|
|
919
|
+
}
|
|
920
|
+
};
|
|
921
|
+
const registerCleanupHandler = (event, handler) => {
|
|
922
|
+
cleanupHandlers.set(event, handler);
|
|
923
|
+
process.on(event, handler);
|
|
924
|
+
};
|
|
925
|
+
registerCleanupHandler("SIGINT", () => {
|
|
926
|
+
cleanup(0);
|
|
927
|
+
});
|
|
928
|
+
registerCleanupHandler("SIGTERM", () => {
|
|
929
|
+
cleanup(0);
|
|
930
|
+
});
|
|
931
|
+
registerCleanupHandler("SIGHUP", () => {
|
|
932
|
+
cleanup(0);
|
|
933
|
+
});
|
|
934
|
+
registerCleanupHandler("uncaughtException", (error) => {
|
|
935
|
+
cleanup(1, error);
|
|
936
|
+
});
|
|
937
|
+
registerCleanupHandler("unhandledRejection", (reason) => {
|
|
938
|
+
cleanup(1, reason);
|
|
939
|
+
});
|
|
940
|
+
await devServer.start();
|
|
941
|
+
await new Promise(() => {});
|
|
942
|
+
return { exitCode: 0 };
|
|
943
|
+
} catch (error) {
|
|
944
|
+
logWriter?.close();
|
|
945
|
+
if (error instanceof Error) {
|
|
946
|
+
logger.error("Dev server failed:", error.message);
|
|
947
|
+
if (verbose) logger.error(error.stack);
|
|
948
|
+
}
|
|
949
|
+
return { exitCode: 1 };
|
|
950
|
+
}
|
|
951
|
+
}
|
|
952
|
+
//#endregion
|
|
953
|
+
export { runDevCommand };
|