devflare 1.0.0-next.2 → 1.0.0-next.20
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/LLM.md +15738 -1751
- package/README.md +375 -605
- package/bin/devflare.js +14 -4
- package/dist/account-05zgta47.js +475 -0
- package/dist/account-0evqkmnc.js +475 -0
- package/dist/account-0v11zbzk.js +475 -0
- package/dist/account-2w85efas.js +475 -0
- package/dist/account-61gw9s7t.js +475 -0
- package/dist/account-65sk9q34.js +475 -0
- package/dist/account-77vx7q2f.js +475 -0
- package/dist/account-7z38mgqf.js +475 -0
- package/dist/account-8wgprpbt.js +475 -0
- package/dist/account-9gt3tej1.js +475 -0
- package/dist/account-b2ag1esh.js +475 -0
- package/dist/account-bxtcz61a.js +475 -0
- package/dist/account-d43d1eqs.js +475 -0
- package/dist/account-dtndtbad.js +475 -0
- package/dist/account-e95v7f4s.js +475 -0
- package/dist/account-fbyyptg7.js +475 -0
- package/dist/account-gnzhz1c9.js +475 -0
- package/dist/account-gyfqg964.js +475 -0
- package/dist/account-m6jq6fnp.js +475 -0
- package/dist/account-mvnfagh9.js +475 -0
- package/dist/account-p0crq2gh.js +475 -0
- package/dist/account-q6pvs9d9.js +475 -0
- package/dist/account-qkcevx7a.js +475 -0
- package/dist/account-rp4zbvw1.js +475 -0
- package/dist/account-txwqg1rx.js +475 -0
- package/dist/account-w5n5bjh2.js +475 -0
- package/dist/account-zd61t0ey.js +475 -0
- package/dist/api-11gkk043.js +33 -0
- package/dist/api-2n6dd2ws.js +33 -0
- package/dist/api-dbxvch9h.js +33 -0
- package/dist/api-p9hf69kr.js +33 -0
- package/dist/api-r10j00ev.js +33 -0
- package/dist/api-senf2569.js +33 -0
- package/dist/api-swcgnp72.js +33 -0
- package/dist/api-th82mps4.js +27 -0
- package/dist/bridge/client.d.ts +34 -6
- package/dist/bridge/client.d.ts.map +1 -1
- 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 +3 -3
- 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.d.ts +73 -0
- package/dist/bridge/miniflare.d.ts.map +1 -1
- package/dist/bridge/protocol.d.ts +1 -1
- package/dist/bridge/protocol.d.ts.map +1 -1
- package/dist/bridge/proxy.d.ts +9 -11
- package/dist/bridge/proxy.d.ts.map +1 -1
- package/dist/bridge/serialization.d.ts +36 -16
- package/dist/bridge/serialization.d.ts.map +1 -1
- 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 +51 -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/legacy-protocol.d.ts +146 -0
- package/dist/bridge/v2/legacy-protocol.d.ts.map +1 -0
- package/dist/bridge/v2/legacy-serialization.d.ts +103 -0
- package/dist/bridge/v2/legacy-serialization.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 +103 -0
- package/dist/bridge/v2/value-serialization.d.ts.map +1 -0
- package/dist/bridge/v2/wire.d.ts +170 -0
- 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/browser-shim/handler.d.ts +1 -1
- package/dist/browser-shim/handler.d.ts.map +1 -1
- package/dist/browser-shim/server.d.ts +63 -0
- package/dist/browser-shim/server.d.ts.map +1 -1
- package/dist/browser.d.ts +4505 -0
- package/dist/browser.d.ts.map +1 -0
- package/dist/browser.js +145 -0
- package/dist/build-07mjrvsn.js +53 -0
- package/dist/build-0rfr8k1s.js +53 -0
- package/dist/build-1313sg73.js +52 -0
- package/dist/build-1hnntbks.js +53 -0
- package/dist/build-1r3myv0k.js +53 -0
- package/dist/build-28561w5v.js +54 -0
- package/dist/build-2s5paw5p.js +54 -0
- package/dist/build-4c350cp7.js +54 -0
- package/dist/build-50yqpwb3.js +54 -0
- package/dist/build-55z8psd6.js +53 -0
- package/dist/build-5b9wj2p0.js +53 -0
- package/dist/build-5frhzh1m.js +53 -0
- package/dist/build-6ye9vnab.js +52 -0
- package/dist/build-8gv18jrq.js +52 -0
- package/dist/build-9bgqypy6.js +53 -0
- package/dist/build-9em4ymqn.js +52 -0
- package/dist/build-e7wym63t.js +54 -0
- package/dist/build-eh3x12qc.js +52 -0
- package/dist/build-emhyycp7.js +53 -0
- package/dist/build-f1m9jn7b.js +53 -0
- package/dist/build-ffe72jjv.js +54 -0
- package/dist/build-fx90y6za.js +53 -0
- package/dist/build-ge6qp3t4.js +54 -0
- package/dist/build-h31egsze.js +53 -0
- package/dist/build-hpczwagb.js +53 -0
- package/dist/build-hpkbanpw.js +54 -0
- package/dist/build-j2re91xe.js +54 -0
- package/dist/build-j78389rg.js +52 -0
- package/dist/build-m3kckn5g.js +53 -0
- package/dist/build-mf3thcjm.js +53 -0
- package/dist/build-n3n5bv37.js +52 -0
- package/dist/build-ngfy4v5x.js +53 -0
- package/dist/build-pr843h0d.js +52 -0
- package/dist/build-qyg2b45p.js +52 -0
- package/dist/build-r6884kyt.js +53 -0
- package/dist/build-re370wkf.js +53 -0
- package/dist/build-ta8c6t11.js +54 -0
- package/dist/build-vvndgwg0.js +52 -0
- package/dist/build-wp559jkf.js +54 -0
- package/dist/build-wvjj8f28.js +54 -0
- package/dist/build-x4r67275.js +52 -0
- package/dist/build-xp4pfhvv.js +52 -0
- package/dist/build-y489r2h9.js +54 -0
- package/dist/build-y6g4bvx5.js +52 -0
- package/dist/build-ypg6f2kw.js +54 -0
- package/dist/build-yts8wwgf.js +54 -0
- package/dist/build-yvn0yhwx.js +52 -0
- package/dist/build-yzkdqexs.js +54 -0
- package/dist/build-z4vmhs5c.js +53 -0
- 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 +2 -0
- package/dist/bundler/index.d.ts.map +1 -1
- package/dist/bundler/rolldown-shared.d.ts +53 -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 +1 -1
- package/dist/cli/commands/account.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.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.map +1 -1
- package/dist/cli/commands/doctor.d.ts.map +1 -1
- 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/secrets.d.ts +4 -0
- package/dist/cli/commands/secrets.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 +110 -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.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/config-path.d.ts +6 -0
- package/dist/cli/config-path.d.ts.map +1 -0
- package/dist/cli/dependencies.d.ts +1 -0
- 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/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 +12 -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/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.map +1 -1
- package/dist/cloudflare/index.d.ts +57 -2
- package/dist/cloudflare/index.d.ts.map +1 -1
- package/dist/cloudflare/index.js +49 -2
- 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/tokens.d.ts +41 -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 +30 -2
- 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 +267 -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/deploy-resources.d.ts +58 -0
- package/dist/config/deploy-resources.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 +10 -4
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/loader.d.ts +1 -0
- 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 +31 -0
- package/dist/config/preview.d.ts.map +1 -0
- package/dist/config/ref.d.ts +14 -23
- 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 +1495 -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 +2949 -0
- package/dist/config/schema-env.d.ts.map +1 -0
- package/dist/config/schema-normalization.d.ts +184 -0
- package/dist/config/schema-normalization.d.ts.map +1 -0
- package/dist/config/schema-runtime.d.ts +468 -0
- package/dist/config/schema-runtime.d.ts.map +1 -0
- package/dist/config/schema.d.ts +4056 -1875
- 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-1japnjmx.js +59 -0
- package/dist/config-287wjn1m.js +59 -0
- package/dist/config-4x6vq82e.js +59 -0
- package/dist/config-5n0avhcx.js +59 -0
- package/dist/config-6m0n7d84.js +59 -0
- package/dist/config-70s2ap5j.js +59 -0
- package/dist/config-7cf004ag.js +59 -0
- package/dist/config-7hge8ze6.js +59 -0
- package/dist/config-7rbp7aek.js +59 -0
- package/dist/config-b8xbbmta.js +59 -0
- package/dist/config-b98dp58n.js +59 -0
- package/dist/config-baee5690.js +59 -0
- package/dist/config-bczpc1ey.js +59 -0
- package/dist/config-cf3djhqy.js +59 -0
- package/dist/config-entry.d.ts +5 -0
- package/dist/config-entry.d.ts.map +1 -0
- package/dist/config-entry.js +14 -0
- package/dist/config-fhmwzaw6.js +59 -0
- package/dist/config-g9vkfa4x.js +59 -0
- package/dist/config-gpexkzth.js +59 -0
- package/dist/config-nspw7sgv.js +59 -0
- package/dist/config-ntm4x9wt.js +59 -0
- package/dist/config-nv6hfpg6.js +59 -0
- package/dist/config-pjc33wew.js +59 -0
- package/dist/config-pnz2e8s3.js +59 -0
- package/dist/config-qts6nh6g.js +59 -0
- package/dist/config-sg2xrdt4.js +59 -0
- package/dist/config-vzwckat3.js +59 -0
- package/dist/config-wa7hm0w9.js +59 -0
- package/dist/config-x90dkmm7.js +59 -0
- package/dist/decorators/durable-object.d.ts.map +1 -1
- package/dist/deploy-1jfagtn9.js +1055 -0
- package/dist/deploy-1s6nv5rp.js +921 -0
- package/dist/deploy-2afw0jfg.js +1055 -0
- package/dist/deploy-2fzj68kq.js +1055 -0
- package/dist/deploy-30ph1rrd.js +921 -0
- package/dist/deploy-39dmfn9d.js +921 -0
- package/dist/deploy-44n2pshy.js +1016 -0
- package/dist/deploy-45qxpsfe.js +921 -0
- package/dist/deploy-57nzn9wj.js +1045 -0
- package/dist/deploy-64e57w1g.js +1040 -0
- package/dist/deploy-82j43vta.js +1040 -0
- package/dist/deploy-99m8qhpa.js +1041 -0
- package/dist/deploy-9twkd32f.js +1040 -0
- package/dist/deploy-a2eq2c1n.js +1040 -0
- package/dist/deploy-a3pb1qs5.js +921 -0
- package/dist/deploy-agbtfm04.js +921 -0
- package/dist/deploy-aswbtbf3.js +921 -0
- package/dist/deploy-asyryrvm.js +1055 -0
- package/dist/deploy-bqf3kxy5.js +972 -0
- package/dist/deploy-fv4z648h.js +921 -0
- package/dist/deploy-gsybda2f.js +1038 -0
- package/dist/deploy-h17nzysm.js +921 -0
- package/dist/deploy-hc89h4wg.js +1045 -0
- package/dist/deploy-hc927rw6.js +1045 -0
- package/dist/deploy-jey5pnqn.js +1040 -0
- package/dist/deploy-jv0yfqvk.js +1040 -0
- package/dist/deploy-kn3z6spd.js +941 -0
- package/dist/deploy-m22xmz9w.js +921 -0
- package/dist/deploy-nefp2njy.js +1038 -0
- package/dist/deploy-pnnf8tgy.js +1045 -0
- package/dist/deploy-ppp8pg6w.js +1038 -0
- package/dist/deploy-q33bw715.js +1055 -0
- package/dist/deploy-qah2eag6.js +1041 -0
- package/dist/deploy-qdq2gpad.js +1045 -0
- package/dist/deploy-r1yf8913.js +1038 -0
- package/dist/deploy-r8nam9rr.js +1038 -0
- package/dist/deploy-rrm4a0xw.js +921 -0
- package/dist/deploy-s0tfnc12.js +1040 -0
- package/dist/deploy-s636ks9k.js +1041 -0
- package/dist/deploy-sany8t54.js +1045 -0
- package/dist/deploy-skqn61j3.js +1038 -0
- package/dist/deploy-smv2870h.js +921 -0
- package/dist/deploy-sp16nxs5.js +972 -0
- package/dist/deploy-sr805bvq.js +921 -0
- package/dist/deploy-t9dehmn0.js +1041 -0
- package/dist/deploy-taxt7njz.js +1041 -0
- package/dist/deploy-tmdgecs3.js +1055 -0
- package/dist/deploy-tnfvfh9m.js +1040 -0
- package/dist/deploy-v0y8kczr.js +1055 -0
- package/dist/deploy-w5f8db4s.js +1040 -0
- package/dist/deploy-wsxcectr.js +921 -0
- package/dist/deploy-xhj6zbcx.js +1055 -0
- package/dist/deploy-xyfbhj3v.js +1038 -0
- package/dist/deploy-yv1y5xaa.js +921 -0
- package/dist/deploy-z3ejw37k.js +1040 -0
- package/dist/dev-02tgdc4f.js +2160 -0
- package/dist/dev-0tqhveye.js +2314 -0
- package/dist/dev-1mvcts8w.js +2515 -0
- package/dist/dev-2a283xts.js +2515 -0
- package/dist/dev-3dj2gkfq.js +2314 -0
- package/dist/dev-3e0etsww.js +2314 -0
- package/dist/dev-47dk7c13.js +2314 -0
- package/dist/dev-4a2a31cm.js +2314 -0
- package/dist/dev-4w1stcn8.js +2427 -0
- package/dist/dev-5wkh1z4a.js +2188 -0
- package/dist/dev-62nhytf8.js +2505 -0
- package/dist/dev-6t22zmey.js +2350 -0
- package/dist/dev-75acm2xj.js +2478 -0
- package/dist/dev-802rg9dp.js +2515 -0
- package/dist/dev-89p1sdv7.js +2395 -0
- package/dist/dev-8d1gxjky.js +2427 -0
- package/dist/dev-8yawx3cv.js +2314 -0
- package/dist/dev-9h4p8a0c.js +2393 -0
- package/dist/dev-9xmttj4c.js +2314 -0
- package/dist/dev-at6gy2td.js +2427 -0
- package/dist/dev-bkbz97z0.js +2314 -0
- package/dist/dev-ct3344kv.js +2160 -0
- package/dist/dev-d1bb2t0f.js +2515 -0
- package/dist/{dev-qnxet3j9.js → dev-dg8dh5c1.js} +947 -809
- package/dist/dev-dr5jb965.js +2427 -0
- package/dist/dev-dwry8494.js +2489 -0
- package/dist/dev-e4sjqtbq.js +2314 -0
- package/dist/dev-ecq26mg4.js +2350 -0
- package/dist/dev-ef237vgp.js +2324 -0
- package/dist/dev-enbdg4st.js +2314 -0
- package/dist/dev-g6112y4w.js +2515 -0
- package/dist/dev-h2kneh95.js +2496 -0
- package/dist/dev-jcrxg8hq.js +2160 -0
- package/dist/dev-jk0gqges.js +2432 -0
- package/dist/dev-k62936am.js +2314 -0
- package/dist/dev-k8ptbvrs.js +2160 -0
- package/dist/dev-kqm107h4.js +2422 -0
- package/dist/dev-kybq3mwr.js +2489 -0
- package/dist/dev-n0gx7eya.js +2350 -0
- package/dist/dev-n23m6rtb.js +2314 -0
- package/dist/dev-n8qndkyg.js +2512 -0
- package/dist/dev-ny8fmkzg.js +2432 -0
- package/dist/dev-p1c65cga.js +2386 -0
- package/dist/dev-p32fkbwf.js +2489 -0
- package/dist/dev-p4fjbb4h.js +2395 -0
- package/dist/dev-pnfcv79z.js +2160 -0
- package/dist/dev-qm9d4mfh.js +2478 -0
- package/dist/dev-qnrrv5ey.js +2393 -0
- package/dist/dev-qqysg50t.js +2427 -0
- package/dist/dev-r9f3n11q.js +2410 -0
- package/dist/dev-rcthnse5.js +2473 -0
- package/dist/dev-s0815dw4.js +2427 -0
- package/dist/dev-s4tpkg60.js +2314 -0
- package/dist/dev-s82fcesg.js +2314 -0
- package/dist/dev-s9sz53me.js +2401 -0
- package/dist/dev-sdka7z0d.js +2427 -0
- 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 +57 -0
- package/dist/dev-server/dev-server-state.d.ts.map +1 -0
- package/dist/dev-server/gateway-script.d.ts +21 -0
- package/dist/dev-server/gateway-script.d.ts.map +1 -0
- package/dist/dev-server/miniflare-bindings.d.ts +59 -0
- package/dist/dev-server/miniflare-bindings.d.ts.map +1 -0
- package/dist/dev-server/miniflare-dev-config.d.ts +31 -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 +74 -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-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 +15 -0
- package/dist/dev-server/vite-process.d.ts.map +1 -0
- package/dist/dev-server/vite-utils.d.ts +55 -0
- package/dist/dev-server/vite-utils.d.ts.map +1 -0
- 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-t3tjscah.js +2350 -0
- package/dist/dev-t50kdb1j.js +2338 -0
- package/dist/dev-t5xf55pt.js +2314 -0
- package/dist/dev-t63c44bb.js +2314 -0
- package/dist/dev-tgwja5mz.js +2496 -0
- package/dist/dev-wg3d38sy.js +2433 -0
- package/dist/dev-wh4rfgsh.js +2427 -0
- package/dist/dev-wjh8gdd1.js +2284 -0
- package/dist/dev-xzxy9qvq.js +2314 -0
- package/dist/dev-yymaq4ph.js +2392 -0
- package/dist/dev-zg2w2ve3.js +2422 -0
- package/dist/dev-zsb2xk1x.js +2427 -0
- package/dist/dev-zty3yhzg.js +2324 -0
- package/dist/doctor-2shhdak6.js +245 -0
- package/dist/doctor-3mqavqg3.js +245 -0
- package/dist/doctor-5g73w40j.js +245 -0
- package/dist/doctor-5nek32fz.js +245 -0
- package/dist/doctor-7ra1w0sk.js +245 -0
- package/dist/doctor-ak830a0k.js +245 -0
- package/dist/doctor-bye3cs8a.js +245 -0
- package/dist/doctor-c5m9pmwq.js +245 -0
- package/dist/doctor-cqfkgxvw.js +245 -0
- package/dist/doctor-e1h9mhzp.js +245 -0
- package/dist/doctor-fmqsrafk.js +245 -0
- package/dist/doctor-gamefzcs.js +245 -0
- package/dist/doctor-hgs7wr5g.js +245 -0
- package/dist/doctor-j8ytsy94.js +245 -0
- package/dist/doctor-mcmkgp6e.js +245 -0
- package/dist/doctor-qb6m2exc.js +245 -0
- package/dist/doctor-qq4tsh8q.js +245 -0
- package/dist/doctor-rn53ctfs.js +245 -0
- package/dist/doctor-tecv869a.js +245 -0
- package/dist/doctor-wg0245pe.js +245 -0
- package/dist/doctor-z3jfqxtz.js +245 -0
- package/dist/{durable-object-t4kbb0yt.js → durable-object-4hey8fgy.js} +1 -1
- package/dist/durable-object-v3gsnybk.js +13 -0
- package/dist/durable-object-yt8v1dyn.js +13 -0
- package/dist/env.d.ts.map +1 -1
- package/dist/index-01kehw41.js +348 -0
- package/dist/index-06bg0z9y.js +185 -0
- package/dist/index-0d7tw5r4.js +136 -0
- package/dist/index-0krb65s3.js +215 -0
- package/dist/index-0m6e4mxz.js +133 -0
- package/dist/index-0mantew0.js +513 -0
- package/dist/index-0mezg6ar.js +1372 -0
- package/dist/index-0tk2rs0q.js +185 -0
- package/dist/index-0vah20er.js +1410 -0
- package/dist/index-0wa0ebm1.js +68 -0
- package/dist/index-124e9t4t.js +232 -0
- package/dist/index-1546yrn0.js +74 -0
- package/dist/index-15fpa5tx.js +232 -0
- package/dist/index-1714y3cz.js +1410 -0
- package/dist/index-18mp5v50.js +538 -0
- package/dist/index-195tc6qh.js +1372 -0
- package/dist/index-1bg8w2gf.js +52 -0
- package/dist/index-1d4jg11n.js +542 -0
- package/dist/index-1e2qtrmj.js +188 -0
- package/dist/index-1ghhgb9d.js +74 -0
- package/dist/index-1nhd9nkd.js +232 -0
- package/dist/index-1p814k7s.js +227 -0
- package/dist/index-1qs5gcm7.js +895 -0
- package/dist/index-1wn8mjep.js +808 -0
- package/dist/index-1xhd5czz.js +185 -0
- package/dist/index-29k04v43.js +574 -0
- package/dist/index-2a2g4fwp.js +993 -0
- package/dist/index-2bmtj21z.js +192 -0
- package/dist/index-2dpmd14d.js +52 -0
- package/dist/index-2fa0afdp.js +1372 -0
- package/dist/index-2jywf4pz.js +1372 -0
- package/dist/index-2qhk9nbx.js +1372 -0
- package/dist/index-2rcrefqd.js +1372 -0
- package/dist/index-2t2m5148.js +1372 -0
- package/dist/index-2vbzamev.js +437 -0
- package/dist/index-2vdep9h0.js +993 -0
- package/dist/index-2vq6bveq.js +574 -0
- package/dist/index-2y90j9cz.js +74 -0
- package/dist/index-33ep0z9x.js +385 -0
- package/dist/index-36h8gkhb.js +1088 -0
- package/dist/index-37jgbaw6.js +1372 -0
- package/dist/index-380ncsqc.js +977 -0
- package/dist/index-38fq7pww.js +560 -0
- package/dist/index-3bxqn033.js +1410 -0
- package/dist/index-3e1x39fc.js +365 -0
- package/dist/index-3e7by9sy.js +223 -0
- package/dist/index-3egad6wm.js +538 -0
- package/dist/index-3f8rzmjw.js +232 -0
- package/dist/index-3jme4hgw.js +1234 -0
- package/dist/index-3p7s9mk9.js +360 -0
- package/dist/index-3vd4r37r.js +1372 -0
- package/dist/index-3vgn5e89.js +1682 -0
- package/dist/index-3x7k3t0f.js +513 -0
- package/dist/index-3xfe2dst.js +399 -0
- package/dist/index-464j1zb4.js +513 -0
- package/dist/index-47w35sft.js +244 -0
- package/dist/index-48rxsj95.js +365 -0
- package/dist/index-4bezcdd1.js +385 -0
- package/dist/index-4by4c7rm.js +52 -0
- package/dist/index-4fp11z9e.js +973 -0
- package/dist/index-4knecthc.js +70 -0
- package/dist/index-4phjwd6h.js +412 -0
- package/dist/index-4z5jrw0j.js +594 -0
- package/dist/index-502y7w13.js +538 -0
- package/dist/index-50mxxb4q.js +185 -0
- package/dist/index-51mzqy0d.js +895 -0
- package/dist/index-53pqqpq9.js +74 -0
- package/dist/index-5achzspr.js +185 -0
- package/dist/index-5ef3jmv7.js +1372 -0
- package/dist/index-5enq8ntr.js +1766 -0
- package/dist/index-5eswe8yv.js +844 -0
- package/dist/index-5fnq9r9m.js +1410 -0
- package/dist/index-5gevxfgs.js +513 -0
- package/dist/index-5gmf048z.js +817 -0
- package/dist/index-5jtkxpjf.js +971 -0
- package/dist/index-5m85bd9x.js +168 -0
- package/dist/index-5n5nn0a8.js +264 -0
- package/dist/index-5p3bgjwr.js +808 -0
- package/dist/index-5vzcszr2.js +1230 -0
- package/dist/index-5w77r4w9.js +513 -0
- package/dist/index-5w9f2b17.js +695 -0
- package/dist/index-627srx16.js +45 -0
- package/dist/index-62b3gt2g.js +12 -0
- package/dist/index-62srkqcm.js +168 -0
- package/dist/index-63cgqe43.js +1372 -0
- package/dist/index-65e7xx1a.js +19 -0
- package/dist/index-65qrje14.js +185 -0
- package/dist/index-66sx3b3v.js +385 -0
- package/dist/index-678j0n13.js +74 -0
- package/dist/index-6bqgf5x8.js +227 -0
- package/dist/index-6ftrth7n.js +1218 -0
- package/dist/index-6g90pvxa.js +215 -0
- package/dist/index-6h8xbs75.js +44 -0
- package/dist/index-6j4m5x2d.js +1372 -0
- package/dist/index-6jwpke14.js +385 -0
- package/dist/index-6knsjvxh.js +1372 -0
- package/dist/index-6kwq6yf8.js +979 -0
- package/dist/index-6mg4yvc6.js +74 -0
- package/dist/index-6phry941.js +133 -0
- package/dist/index-6r59wbek.js +232 -0
- package/dist/index-6sf815ps.js +74 -0
- package/dist/index-6xknvbyk.js +1088 -0
- package/dist/index-6zd89k6y.js +1230 -0
- package/dist/index-71rwg0cn.js +264 -0
- package/dist/index-75ex2m0x.js +695 -0
- package/dist/index-79exzs3q.js +1218 -0
- package/dist/index-7bxj118m.js +264 -0
- package/dist/index-7c6np4mq.js +397 -0
- package/dist/index-7cm339qz.js +133 -0
- package/dist/index-7e359eb5.js +895 -0
- package/dist/index-7ef3ktz5.js +1372 -0
- package/dist/index-7eqyr4j8.js +70 -0
- package/dist/index-7hpjfdzh.js +185 -0
- package/dist/index-7k278fgz.js +273 -0
- package/dist/index-7kazxkjt.js +1372 -0
- package/dist/index-7m0x8m9r.js +844 -0
- package/dist/index-7p74smg8.js +1372 -0
- package/dist/index-7q8fke3k.js +188 -0
- package/dist/index-7qk6eafn.js +1682 -0
- package/dist/index-7r7dfpcm.js +133 -0
- package/dist/index-7vbjt6ba.js +805 -0
- package/dist/index-7z4b0vgd.js +470 -0
- package/dist/index-8052df4m.js +627 -0
- package/dist/index-82epjzrr.js +1410 -0
- package/dist/index-82f1z98k.js +41 -0
- package/dist/index-82xn4azv.js +74 -0
- package/dist/index-82z7rvz6.js +1238 -0
- package/dist/index-83wns7cz.js +70 -0
- package/dist/index-852945d4.js +413 -0
- package/dist/index-86rvj79f.js +133 -0
- package/dist/index-88tcq0t4.js +542 -0
- package/dist/index-8atc1yb9.js +68 -0
- package/dist/index-8evn52g1.js +1218 -0
- package/dist/index-8jkf4nsd.js +695 -0
- package/dist/index-8nx4ce3e.js +133 -0
- package/dist/index-8q1bcnrh.js +1372 -0
- package/dist/index-8t5gynct.js +971 -0
- package/dist/index-8tj0awnv.js +476 -0
- package/dist/index-8x745h59.js +1069 -0
- package/dist/index-905svbb6.js +470 -0
- package/dist/index-94cb0sac.js +1372 -0
- package/dist/index-95mmvbw7.js +538 -0
- package/dist/index-97x94h0m.js +438 -0
- package/dist/index-9an9qqr1.js +728 -0
- package/dist/index-9bawzcny.js +574 -0
- package/dist/index-9bjjqdfc.js +236 -0
- package/dist/index-9d125myk.js +1372 -0
- package/dist/index-9d7x3vfr.js +236 -0
- package/dist/index-9fbtk7gv.js +817 -0
- package/dist/index-9gg0kqw0.js +470 -0
- package/dist/index-9nf8zs4p.js +1069 -0
- package/dist/index-9ryw7mcw.js +971 -0
- package/dist/{index-gz1gndna.js → index-9wt9x09k.js} +42 -62
- package/dist/index-a3e13a7m.js +478 -0
- package/dist/index-a6j44jmr.js +1372 -0
- package/dist/index-a75ejnvt.js +1711 -0
- package/dist/index-aabgympv.js +39 -0
- package/dist/index-ab2nck1h.js +1372 -0
- package/dist/index-abrqnq3e.js +488 -0
- package/dist/index-acwbmagz.js +412 -0
- package/dist/index-afjbpgb1.js +1218 -0
- package/dist/index-aqjdaem7.js +74 -0
- package/dist/index-at89fpde.js +470 -0
- package/dist/index-awr0tp6p.js +313 -0
- package/dist/index-b1be9bdh.js +1372 -0
- package/dist/index-b1xs3wc4.js +513 -0
- package/dist/index-b50x7seh.js +513 -0
- package/dist/index-b5ra8w3q.js +52 -0
- package/dist/index-b6448fd0.js +133 -0
- package/dist/index-b64sbzgv.js +884 -0
- package/dist/index-b7r8ntpm.js +1372 -0
- package/dist/index-b9j55r7q.js +240 -0
- package/dist/index-ba9gyy13.js +513 -0
- package/dist/index-bb66mn7p.js +52 -0
- package/dist/index-bc5pvbbd.js +1193 -0
- package/dist/index-bdatd1za.js +1372 -0
- package/dist/index-bj0mk3dw.js +74 -0
- package/dist/index-bj3a8dr0.js +1372 -0
- package/dist/index-bk3eez1g.js +513 -0
- package/dist/index-btjx137w.js +774 -0
- package/dist/index-btrfqp9h.js +133 -0
- package/dist/index-bx6gangy.js +402 -0
- package/dist/index-c0tc0yts.js +471 -0
- package/dist/index-c0whkev9.js +200 -0
- package/dist/index-c3nxftnp.js +699 -0
- package/dist/index-c643s0gv.js +488 -0
- package/dist/index-ca96qkva.js +1372 -0
- package/dist/index-cdtzkedk.js +993 -0
- package/dist/index-cejgenma.js +1372 -0
- package/dist/index-cp8jt5pr.js +52 -0
- package/dist/index-cpz69pek.js +1372 -0
- package/dist/index-crrdegk5.js +456 -0
- package/dist/index-cskszwkx.js +1372 -0
- package/dist/index-cxf22a0s.js +74 -0
- package/dist/index-cy3c3w81.js +270 -0
- package/dist/index-d2md1j3d.js +185 -0
- package/dist/index-d5dgb1j6.js +74 -0
- package/dist/index-da397xcx.js +1372 -0
- package/dist/index-damyy8bw.js +1372 -0
- package/dist/index-dbr6bfz6.js +528 -0
- package/dist/index-dd1g0g7e.js +360 -0
- package/dist/index-dd6fwwmq.js +456 -0
- package/dist/index-dh1954bp.js +52 -0
- package/dist/index-djp2wd1f.js +1372 -0
- package/dist/index-dktb9az5.js +1372 -0
- package/dist/index-dm9q84c7.js +360 -0
- package/dist/index-dmbdj6va.js +805 -0
- package/dist/index-dmf76tac.js +1372 -0
- package/dist/index-dphr32gc.js +420 -0
- package/dist/index-dxh2qyyw.js +52 -0
- package/dist/index-dzayfxjy.js +492 -0
- package/dist/index-e05q77kt.js +397 -0
- package/dist/index-e11b1fb2.js +495 -0
- package/dist/index-e3zvspqj.js +968 -0
- package/dist/index-e4tzzbn9.js +1372 -0
- package/dist/index-e5ct1gwb.js +1372 -0
- package/dist/index-e7ptcz1a.js +1372 -0
- package/dist/index-e7wt0203.js +513 -0
- package/dist/index-ebwsvf9t.js +365 -0
- package/dist/index-ed73jn3d.js +185 -0
- package/dist/index-ed7n5d07.js +185 -0
- package/dist/index-ejs2a4kd.js +513 -0
- package/dist/index-esjrgt3y.js +467 -0
- package/dist/index-ev03khsd.js +513 -0
- package/dist/index-f1gsqm54.js +168 -0
- package/dist/index-f51mkh13.js +1088 -0
- package/dist/index-f86n1fpd.js +55 -0
- package/dist/index-f90314kt.js +52 -0
- package/dist/index-f9mhsept.js +185 -0
- package/dist/index-fa6zwffw.js +70 -0
- package/dist/index-fama7kpt.js +52 -0
- package/dist/index-fgk87mk2.js +1067 -0
- package/dist/index-fkyvxe4b.js +968 -0
- package/dist/index-fnk0tkw7.js +412 -0
- package/dist/index-g0h40xke.js +513 -0
- package/dist/index-g0rqh52c.js +385 -0
- package/dist/index-g170d619.js +385 -0
- package/dist/index-g3qtxkms.js +881 -0
- package/dist/index-g5aq66bj.js +1534 -0
- package/dist/index-gactvqcs.js +467 -0
- package/dist/index-gaew61v4.js +470 -0
- package/dist/index-gba371j7.js +542 -0
- package/dist/index-gegyyfnw.js +1372 -0
- package/dist/index-get7he2s.js +133 -0
- package/dist/index-gj5qh491.js +54 -0
- package/dist/index-gn5wy09x.js +205 -0
- package/dist/index-gq39t0rx.js +895 -0
- package/dist/index-gtbgzwfs.js +264 -0
- package/dist/index-gtpz0gkz.js +185 -0
- package/dist/index-h1s66pmp.js +52 -0
- package/dist/index-h5dqna7q.js +1410 -0
- package/dist/index-h8r2d8y5.js +366 -0
- package/dist/index-heeqwrfd.js +385 -0
- package/dist/index-hheb5dyt.js +192 -0
- package/dist/index-hjs9j2g9.js +895 -0
- package/dist/index-hjz2x9nq.js +441 -0
- package/dist/index-hkex7ns5.js +513 -0
- package/dist/index-hmbctwv6.js +517 -0
- package/dist/index-hn5nbxbt.js +147 -0
- package/dist/index-hpjh0qjx.js +1723 -0
- package/dist/index-hpzasdhw.js +513 -0
- package/dist/index-hqdr9wdm.js +74 -0
- package/dist/index-hrvz8d26.js +1372 -0
- package/dist/index-hs6ekcfs.js +412 -0
- package/dist/index-hyvhnf6r.js +971 -0
- package/dist/index-j2kc5rbv.js +895 -0
- package/dist/index-j2xdxwsz.js +133 -0
- package/dist/index-j47hhb3r.js +694 -0
- package/dist/index-j5aphr5x.js +185 -0
- package/dist/index-j68v36q1.js +188 -0
- package/dist/index-j7cf22x7.js +968 -0
- package/dist/index-j7xxrbnr.js +694 -0
- package/dist/index-jdzrvnfj.js +52 -0
- package/dist/index-jg720mq7.js +476 -0
- package/dist/index-jptqxkew.js +470 -0
- package/dist/index-jrzddxvt.js +2167 -0
- package/dist/index-jsymy3mb.js +781 -0
- package/dist/index-jwvy32xk.js +188 -0
- package/dist/index-jxe1b19v.js +133 -0
- package/dist/index-jz96ry5g.js +513 -0
- package/dist/index-k6wtsgs1.js +971 -0
- package/dist/index-k7m5f1dg.js +200 -0
- package/dist/index-kawa49m8.js +371 -0
- package/dist/index-key4e5c9.js +168 -0
- package/dist/index-kgstnk6g.js +239 -0
- package/dist/index-khbmdrn2.js +884 -0
- package/dist/index-khnw972v.js +117 -0
- package/dist/index-kpzfwex6.js +264 -0
- package/dist/index-kse4gn99.js +74 -0
- package/dist/index-ktscz0r2.js +264 -0
- package/dist/index-kwqff3ba.js +1410 -0
- package/dist/index-kybmjvad.js +1212 -0
- package/dist/index-kzm9cea8.js +185 -0
- package/dist/index-m2d74gqg.js +808 -0
- package/dist/index-m2v0fj08.js +74 -0
- package/dist/index-m56w7mjt.js +513 -0
- package/dist/index-m95ha3n4.js +264 -0
- package/dist/index-ma151p8g.js +264 -0
- package/dist/index-mg8vwqxf.js +514 -0
- package/dist/index-mhdsywhs.js +264 -0
- package/dist/index-mjgx910r.js +895 -0
- package/dist/index-mjve6tqn.js +447 -0
- package/dist/index-mkrmaea3.js +185 -0
- package/dist/index-mkxnyyjn.js +264 -0
- package/dist/index-mkxzgn0q.js +1372 -0
- package/dist/index-mp5mrst6.js +1372 -0
- package/dist/index-ms15cr86.js +513 -0
- package/dist/index-mt99xkc6.js +133 -0
- package/dist/index-mttv6k25.js +881 -0
- package/dist/index-myxfx52v.js +385 -0
- package/dist/index-mzmq3v0d.js +1088 -0
- package/dist/index-mzw7732t.js +74 -0
- package/dist/index-n3mjwz22.js +188 -0
- package/dist/index-n3yksgz0.js +1372 -0
- package/dist/index-n4jr3dmk.js +484 -0
- package/dist/index-n5drt64b.js +74 -0
- package/dist/index-n8frmffg.js +264 -0
- package/dist/index-n8k8chde.js +694 -0
- package/dist/index-na796ka6.js +994 -0
- package/dist/index-nbs4q0qg.js +1218 -0
- package/dist/index-newpq2zf.js +968 -0
- package/dist/index-nexg9p7j.js +1271 -0
- package/dist/index-nfm8tb5n.js +74 -0
- package/dist/index-ng9n3znd.js +1372 -0
- package/dist/index-nga2tg9z.js +1372 -0
- package/dist/index-ngbzr9gz.js +805 -0
- package/dist/index-nh90nk7j.js +380 -0
- package/dist/index-nhbkm2ba.js +467 -0
- package/dist/index-njnmfxm5.js +1372 -0
- package/dist/index-nqma24j3.js +385 -0
- package/dist/index-nrfhk0k5.js +1088 -0
- package/dist/index-ntddf5d9.js +993 -0
- package/dist/index-nte9n8w9.js +538 -0
- package/dist/index-ntxp7ke1.js +264 -0
- package/dist/index-nwxnmw41.js +264 -0
- package/dist/index-p0zppqxm.js +467 -0
- package/dist/index-p1xe5eem.js +513 -0
- package/dist/index-p296ban8.js +191 -0
- package/dist/index-p477xm52.js +385 -0
- package/dist/index-p8nmkrgw.js +470 -0
- package/dist/index-p97s12vf.js +904 -0
- package/dist/index-p9hvv0yd.js +401 -0
- package/dist/index-pac7wv88.js +307 -0
- package/dist/index-pkxf6h87.js +895 -0
- package/dist/index-pqp4312v.js +52 -0
- package/dist/index-ptp2pfq1.js +52 -0
- package/dist/index-pw9jn6kz.js +574 -0
- package/dist/index-pyeycp3f.js +74 -0
- package/dist/index-q23xf3vr.js +479 -0
- package/dist/index-q31ne0xa.js +412 -0
- package/dist/index-q34rvh5a.js +247 -0
- package/dist/index-q5errwrj.js +904 -0
- package/dist/index-q5nhzc9m.js +1217 -0
- package/dist/index-q8f4kawk.js +204 -0
- package/dist/index-qer8zv2r.js +997 -0
- package/dist/index-qf2dkqxh.js +249 -0
- package/dist/index-qhyy018y.js +467 -0
- package/dist/index-qmhdydwy.js +70 -0
- package/dist/index-qmtdf7k5.js +639 -0
- package/dist/index-qpmvca5j.js +470 -0
- package/dist/index-qr96vaj1.js +52 -0
- package/dist/index-qtyhg3dn.js +904 -0
- package/dist/index-qwgr4q7s.js +37 -0
- package/dist/index-qye17gq5.js +264 -0
- package/dist/index-r0839f5k.js +133 -0
- package/dist/index-r1rqg72v.js +1372 -0
- package/dist/index-rab2dfh3.js +494 -0
- package/dist/index-rbckga8p.js +971 -0
- package/dist/index-rbxb5x2w.js +1372 -0
- package/dist/index-rck779bj.js +739 -0
- package/dist/index-rfn2gt5f.js +1658 -0
- package/dist/index-rg21w26a.js +470 -0
- package/dist/index-rgcz45t0.js +1372 -0
- package/dist/index-rhnd376q.js +133 -0
- package/dist/index-rjc5z3w6.js +971 -0
- package/dist/index-rkhtayd6.js +385 -0
- package/dist/index-rm8srzmv.js +371 -0
- package/dist/index-rmhk5j03.js +968 -0
- package/dist/index-rp4t86bt.js +993 -0
- package/dist/index-rpq5ktdy.js +264 -0
- package/dist/index-rpsmhdd4.js +1218 -0
- package/dist/index-rqpakjyr.js +470 -0
- package/dist/index-rttk33x6.js +232 -0
- package/dist/index-rwa82e89.js +385 -0
- package/dist/index-rz185crv.js +695 -0
- package/dist/index-rz7rx80s.js +1410 -0
- package/dist/index-s22verzj.js +1218 -0
- package/dist/index-s2s3g1nt.js +133 -0
- package/dist/index-s37h3jgk.js +572 -0
- package/dist/index-s7ytytth.js +781 -0
- package/dist/index-sb705m7d.js +52 -0
- package/dist/index-sefnpzwa.js +185 -0
- package/dist/index-sgxw0xzd.js +513 -0
- package/dist/index-stc0caq6.js +1009 -0
- package/dist/index-stgn34cr.js +148 -0
- package/dist/index-svz82w9h.js +513 -0
- package/dist/index-sx49e8x9.js +884 -0
- package/dist/index-sxadwvw9.js +185 -0
- package/dist/index-sxn223fz.js +1372 -0
- package/dist/index-sy0c2mh0.js +1372 -0
- package/dist/index-syeh1hca.js +264 -0
- package/dist/index-syscwrjp.js +1576 -0
- package/dist/index-t14zr0ys.js +1063 -0
- package/dist/index-t18wyhgf.js +418 -0
- package/dist/index-t4fhcx1n.js +71 -0
- package/dist/index-td4hbgj5.js +1372 -0
- package/dist/index-tjc99447.js +68 -0
- package/dist/index-tkvt9mmq.js +484 -0
- package/dist/index-tmmcf4m6.js +808 -0
- package/dist/index-tpgs5v64.js +366 -0
- package/dist/index-tt4fsv91.js +412 -0
- package/dist/{index-07q6yxyc.js → index-tte89s31.js} +30 -29
- package/dist/index-tvjg7swe.js +1372 -0
- package/dist/index-txndxr4w.js +513 -0
- package/dist/index-tyh5jc55.js +990 -0
- package/dist/index-tyt0wa52.js +470 -0
- package/dist/index-tyt3wcfr.js +1372 -0
- package/dist/index-v35460hf.js +574 -0
- package/dist/index-v3znz08m.js +968 -0
- package/dist/index-v78xbj6n.js +808 -0
- package/dist/index-v7q00d1e.js +1410 -0
- package/dist/index-v915brjk.js +1372 -0
- package/dist/index-v922fmsx.js +52 -0
- package/dist/index-v9w1bbfe.js +842 -0
- package/dist/index-vbbgtm8p.js +513 -0
- package/dist/index-vcjgrmzj.js +456 -0
- package/dist/{index-pf5s73n9.js → index-vdewcg1r.js} +243 -385
- package/dist/index-vhqww6tt.js +307 -0
- package/dist/index-vkkmx4xe.js +1372 -0
- package/dist/index-vrps1gky.js +2202 -0
- package/dist/index-vse8620z.js +1372 -0
- package/dist/index-vt803j3b.js +1372 -0
- package/dist/index-vtjp46c3.js +52 -0
- package/dist/index-vxhxk8mf.js +904 -0
- package/dist/index-w3azfsa0.js +695 -0
- package/dist/index-w4c9vmvg.js +1517 -0
- package/dist/index-w4tq35dn.js +52 -0
- package/dist/index-w5qxvxzq.js +991 -0
- package/dist/index-w5sedpqn.js +986 -0
- package/dist/index-waha3chv.js +1230 -0
- package/dist/index-wdxww0kj.js +1006 -0
- package/dist/index-wdy5y07x.js +1372 -0
- package/dist/index-wf9pnh6j.js +385 -0
- package/dist/{index-z14anrqp.js → index-wfbfz02q.js} +14 -15
- package/dist/index-wnnbbbkt.js +1192 -0
- package/dist/index-wqd8n2qk.js +574 -0
- package/dist/index-wvcmvtjf.js +1372 -0
- package/dist/index-x0jbntp0.js +470 -0
- package/dist/index-x12e6fzy.js +476 -0
- package/dist/index-x6scc3nx.js +70 -0
- package/dist/index-x8e2wsbv.js +971 -0
- package/dist/index-xagpz645.js +2199 -0
- package/dist/index-xbth1r6e.js +572 -0
- package/dist/index-xec4p3v5.js +560 -0
- package/dist/index-xgfyxpfs.js +1218 -0
- package/dist/index-xm9fqhcb.js +447 -0
- package/dist/index-xm9hp9xc.js +1372 -0
- package/dist/index-xp7zkxcx.js +1372 -0
- package/dist/index-xrbj0ebk.js +185 -0
- package/dist/index-xskax7r3.js +50 -0
- package/dist/index-xvk5n96q.js +694 -0
- package/dist/index-xy1jvt4w.js +1229 -0
- package/dist/index-xzg9hhf3.js +470 -0
- package/dist/index-xzpg0kaz.js +70 -0
- package/dist/index-y1d8za14.js +196 -0
- package/dist/index-y3q6qvv3.js +316 -0
- package/dist/index-y44ts1dk.js +52 -0
- package/dist/index-y59hnmd0.js +132 -0
- package/dist/index-y5nt1wjb.js +971 -0
- package/dist/index-y7mkb00x.js +133 -0
- package/dist/index-y82b8w14.js +1372 -0
- package/dist/index-yb07t3c5.js +1372 -0
- package/dist/index-yc3xz3vm.js +431 -0
- package/dist/index-yeaqrevg.js +1372 -0
- package/dist/index-ygwsd1nn.js +438 -0
- package/dist/index-yhdavjk7.js +371 -0
- package/dist/index-yjhns95b.js +188 -0
- package/dist/index-yk23p7he.js +1372 -0
- package/dist/index-ykfgpsmm.js +190 -0
- package/dist/index-ymz3cfab.js +968 -0
- package/dist/index-yq9g1sq7.js +264 -0
- package/dist/index-ys5q9ch9.js +366 -0
- package/dist/index-yt0n4p46.js +973 -0
- package/dist/index-ytq1t9jx.js +232 -0
- package/dist/index-ywmtmf3b.js +513 -0
- package/dist/index-yzb44q6d.js +1372 -0
- package/dist/index-z043xk61.js +133 -0
- package/dist/index-z0gsf674.js +431 -0
- package/dist/index-z32n0ndp.js +1372 -0
- package/dist/index-z40mjts9.js +212 -0
- package/dist/index-z4qgk76w.js +1372 -0
- package/dist/index-z5k5bjc7.js +1218 -0
- package/dist/index-z73sytma.js +895 -0
- package/dist/index-z8njfj2g.js +385 -0
- package/dist/index-z9fjnwa8.js +397 -0
- package/dist/{index-1xpj0m4r.js → index-z9gy8w6b.js} +1 -1
- package/dist/index-zapkc14c.js +264 -0
- package/dist/index-zes6w8yr.js +185 -0
- package/dist/index-zgrqest7.js +695 -0
- package/dist/index-zjv6apef.js +1410 -0
- package/dist/index-zsngz131.js +1372 -0
- package/dist/index-zt22fe2j.js +54 -0
- package/dist/index-zxhc6sb0.js +192 -0
- package/dist/index.d.ts +2 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +32 -269
- package/dist/{init-f9mgmew3.js → init-cwpergap.js} +63 -69
- package/dist/init-wfh63bfz.js +180 -0
- package/dist/login-1amyp1jy.js +77 -0
- package/dist/login-1cdwn1dj.js +77 -0
- package/dist/login-456h8jk3.js +77 -0
- package/dist/login-4n470c4j.js +77 -0
- package/dist/login-4sh7s849.js +77 -0
- package/dist/login-5dmkf0pz.js +77 -0
- package/dist/login-7yex6ppq.js +77 -0
- package/dist/login-83bjfhvz.js +77 -0
- package/dist/login-88tp4gbb.js +77 -0
- package/dist/login-b51faqpc.js +77 -0
- package/dist/login-bxyjqmbj.js +77 -0
- package/dist/login-c4649qss.js +77 -0
- package/dist/login-d80a2qxd.js +77 -0
- package/dist/login-ddw888xb.js +77 -0
- package/dist/login-dp0napaz.js +77 -0
- package/dist/login-e7pytkdc.js +77 -0
- package/dist/login-fe0brfcr.js +77 -0
- package/dist/login-h7sm5trm.js +77 -0
- package/dist/login-j3r6z2t4.js +77 -0
- package/dist/login-jkfkdjg4.js +77 -0
- package/dist/login-kch6f2yj.js +77 -0
- package/dist/login-pmqh94ws.js +77 -0
- package/dist/login-rc82x5j8.js +77 -0
- package/dist/login-tvppwyx2.js +77 -0
- package/dist/login-vd0m3xr4.js +77 -0
- package/dist/login-w76jx22q.js +77 -0
- package/dist/login-ze7y36rc.js +77 -0
- package/dist/previews-02jmcwft.js +1214 -0
- package/dist/previews-2wfvsjfy.js +1337 -0
- package/dist/previews-31bq82km.js +1225 -0
- package/dist/previews-31feb8r3.js +1337 -0
- package/dist/previews-3w4pxqby.js +1337 -0
- package/dist/previews-62pcvvpe.js +1214 -0
- package/dist/previews-6fepv94a.js +1225 -0
- package/dist/previews-76fxkp59.js +1214 -0
- package/dist/previews-844bp6kf.js +1214 -0
- package/dist/previews-8amn46qv.js +1214 -0
- package/dist/previews-93ttrf5f.js +1337 -0
- package/dist/previews-a5xbkksy.js +1214 -0
- package/dist/previews-bdrefjzx.js +1337 -0
- package/dist/previews-bgnryzav.js +1214 -0
- package/dist/previews-bkhv9dnr.js +1214 -0
- package/dist/previews-c2c64z5m.js +1214 -0
- package/dist/previews-cfcn56b4.js +1337 -0
- package/dist/previews-e4wgscsb.js +1214 -0
- package/dist/previews-ew4reetn.js +1214 -0
- package/dist/previews-hzqke1fg.js +1214 -0
- package/dist/previews-j8wa3sge.js +1214 -0
- package/dist/previews-k5n6vhpm.js +1214 -0
- package/dist/previews-mssq1hrm.js +1337 -0
- package/dist/previews-n4sdyxa5.js +1214 -0
- package/dist/previews-npwrwb0b.js +1214 -0
- package/dist/previews-q8ph9wbe.js +1214 -0
- package/dist/previews-rfswrh7q.js +1214 -0
- package/dist/previews-s0y5yp8s.js +1214 -0
- package/dist/previews-s5b6mnz5.js +1214 -0
- package/dist/previews-sdte4984.js +1200 -0
- package/dist/previews-t5tdm6t0.js +1225 -0
- package/dist/previews-tcaz1gt8.js +1337 -0
- package/dist/previews-tk7vpzj9.js +1214 -0
- package/dist/previews-tqt4pk27.js +1214 -0
- package/dist/previews-vqg4psk2.js +1225 -0
- package/dist/productions-2t9q8f57.js +505 -0
- package/dist/productions-4abj58kx.js +505 -0
- package/dist/productions-4dpec71r.js +505 -0
- package/dist/productions-4h80j2c7.js +505 -0
- package/dist/productions-4nedsanh.js +505 -0
- package/dist/productions-5c58yafp.js +505 -0
- package/dist/productions-5xq5cjhx.js +505 -0
- package/dist/productions-6dr0bmd7.js +505 -0
- package/dist/productions-86jaqt7m.js +505 -0
- package/dist/productions-8f6s8dqr.js +505 -0
- package/dist/productions-a2hcwwzf.js +505 -0
- package/dist/productions-b7svyjp7.js +505 -0
- package/dist/productions-bf2cnr05.js +505 -0
- package/dist/productions-bn2q31my.js +505 -0
- package/dist/productions-dkgry3gv.js +505 -0
- package/dist/productions-dv8g7f6g.js +505 -0
- package/dist/productions-e2m9s4tr.js +505 -0
- package/dist/productions-eqh105tk.js +505 -0
- package/dist/productions-etvcm7yf.js +505 -0
- package/dist/productions-f1zpbmjz.js +505 -0
- package/dist/productions-fgshs1m7.js +505 -0
- package/dist/productions-hphmt68n.js +505 -0
- package/dist/productions-j14pvx93.js +505 -0
- package/dist/productions-j7s1ywvg.js +505 -0
- package/dist/productions-jp3v3q3p.js +505 -0
- package/dist/productions-m9p42amj.js +505 -0
- package/dist/productions-mxbneawa.js +505 -0
- package/dist/productions-np4exh9p.js +505 -0
- package/dist/productions-rr1hqgda.js +505 -0
- package/dist/productions-rtf9ksgg.js +505 -0
- package/dist/productions-vhq7yx86.js +505 -0
- package/dist/productions-w2nzftcz.js +505 -0
- package/dist/productions-wbks5h7e.js +505 -0
- package/dist/productions-y99ayk6h.js +505 -0
- package/dist/productions-zpqyw5gm.js +505 -0
- package/dist/router/types.d.ts +24 -0
- package/dist/router/types.d.ts.map +1 -0
- 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 +27 -40
- package/dist/runtime/context.d.ts.map +1 -1
- package/dist/runtime/exports.d.ts +47 -55
- package/dist/runtime/exports.d.ts.map +1 -1
- package/dist/runtime/index.d.ts +8 -1
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +108 -99
- package/dist/runtime/middleware.d.ts +102 -60
- package/dist/runtime/middleware.d.ts.map +1 -1
- 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/router.d.ts +7 -0
- package/dist/runtime/router.d.ts.map +1 -0
- package/dist/runtime/validation.d.ts +10 -2
- 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/secrets-8wcj47nh.js +91 -0
- package/dist/secrets-b2ww34ta.js +91 -0
- package/dist/secrets-b7g4z621.js +91 -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.js +187 -75
- 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 +19 -1
- 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/binding-hints.d.ts +11 -0
- package/dist/test/binding-hints.d.ts.map +1 -0
- package/dist/test/bridge-context.d.ts +12 -2
- package/dist/test/bridge-context.d.ts.map +1 -1
- package/dist/test/cf.d.ts +35 -21
- 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 +5 -8
- package/dist/test/index.d.ts.map +1 -1
- package/dist/test/index.js +4976 -46
- package/dist/test/local-worker-loader.d.ts +3 -0
- package/dist/test/local-worker-loader.d.ts.map +1 -0
- package/dist/test/offline-bindings.d.ts +65 -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.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 +10 -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 +7 -26
- package/dist/test/simple-context.d.ts.map +1 -1
- package/dist/test/tail.d.ts +2 -1
- package/dist/test/tail.d.ts.map +1 -1
- 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 +40 -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 +38 -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 +12 -0
- package/dist/test/utilities/r2.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 +10 -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/token-3b9wws58.js +419 -0
- package/dist/token-47kcz18j.js +419 -0
- package/dist/token-a2b38w0z.js +419 -0
- package/dist/token-exz78pth.js +419 -0
- package/dist/token-fcthx92c.js +419 -0
- package/dist/token-grwp8z4q.js +419 -0
- package/dist/token-jkmm44z2.js +419 -0
- package/dist/token-qxtvzm3b.js +419 -0
- package/dist/token-rq8mvtz9.js +419 -0
- package/dist/token-sct51r47.js +419 -0
- package/dist/token-sfgxcgen.js +419 -0
- package/dist/transform/durable-object.d.ts.map +1 -1
- package/dist/transform/worker-entrypoint.d.ts +5 -0
- package/dist/transform/worker-entrypoint.d.ts.map +1 -1
- package/dist/{types-5nyrz1sz.js → types-0qv4xces.js} +266 -148
- package/dist/types-2ejrbba1.js +695 -0
- package/dist/types-2nvrs9jg.js +572 -0
- package/dist/types-2pbe8kzw.js +572 -0
- package/dist/types-2zyt0m43.js +572 -0
- package/dist/types-4xxer9ep.js +572 -0
- package/dist/types-5t5y7a5n.js +572 -0
- package/dist/types-5wd2rygw.js +572 -0
- package/dist/types-7j3ykgx7.js +572 -0
- package/dist/types-7jkbm95a.js +695 -0
- package/dist/types-8g78x34n.js +572 -0
- package/dist/types-a2fk9yns.js +695 -0
- package/dist/types-dyb3c6zw.js +695 -0
- package/dist/types-e2n9f3pd.js +695 -0
- package/dist/types-e6d336q3.js +572 -0
- package/dist/types-hqh2fx0x.js +572 -0
- package/dist/types-j12xmdnd.js +572 -0
- package/dist/types-j4s6qcrc.js +695 -0
- package/dist/types-jqn26et3.js +572 -0
- package/dist/types-n0mxbq26.js +572 -0
- package/dist/types-naz9hvw5.js +572 -0
- package/dist/types-qjcd1jks.js +572 -0
- package/dist/types-r9zb8sw1.js +572 -0
- package/dist/types-rv5xwgsn.js +572 -0
- package/dist/types-t39njdqx.js +572 -0
- package/dist/types-tkgch3xv.js +572 -0
- package/dist/types-vvtb7rrh.js +572 -0
- package/dist/types-w1grncdj.js +572 -0
- package/dist/types-wmw49exb.js +572 -0
- package/dist/types-ymxz9jga.js +572 -0
- package/dist/utils/entrypoint-discovery.d.ts +6 -3
- package/dist/utils/entrypoint-discovery.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 +19 -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 +1 -0
- package/dist/vite/index.d.ts.map +1 -1
- package/dist/vite/index.js +24 -331
- 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 +25 -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-transform.d.ts +41 -0
- package/dist/vite/plugin-transform.d.ts.map +1 -0
- package/dist/vite/plugin.d.ts +6 -39
- package/dist/vite/plugin.d.ts.map +1 -1
- package/dist/worker-18ceqscc.js +513 -0
- package/dist/worker-1yqpwte2.js +513 -0
- package/dist/worker-2aw27zxy.js +513 -0
- package/dist/worker-45tp4a8f.js +513 -0
- package/dist/worker-663em30d.js +513 -0
- package/dist/worker-68zttchg.js +513 -0
- package/dist/worker-729cf3fh.js +513 -0
- package/dist/worker-99tew196.js +513 -0
- package/dist/worker-argxc7fb.js +513 -0
- package/dist/worker-aydzxt4f.js +513 -0
- package/dist/worker-ejdxma7k.js +513 -0
- package/dist/worker-entry/composed-worker.d.ts +7 -0
- package/dist/worker-entry/composed-worker.d.ts.map +1 -0
- 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-entrypoint-4xp7msd7.js +16 -0
- package/dist/{worker-entrypoint-m9th0rg0.js → worker-entrypoint-c259fmfs.js} +1 -1
- package/dist/worker-entrypoint-f1v9y4s8.js +15 -0
- package/dist/worker-f6xqjg65.js +513 -0
- package/dist/worker-fcdsnj14.js +513 -0
- package/dist/worker-fdnn62de.js +513 -0
- package/dist/worker-fk42rzse.js +513 -0
- package/dist/worker-frnh95rg.js +513 -0
- package/dist/worker-jkemk8d2.js +513 -0
- package/dist/worker-k55nfrmp.js +513 -0
- package/dist/worker-kqc6w7ry.js +513 -0
- package/dist/worker-ksvcq8be.js +513 -0
- package/dist/worker-m4ze8djx.js +513 -0
- package/dist/worker-mjzfstv5.js +513 -0
- package/dist/worker-p4rtsndj.js +513 -0
- package/dist/worker-p6d53qan.js +513 -0
- package/dist/worker-qh2qbv97.js +513 -0
- package/dist/worker-r234vnv9.js +513 -0
- package/dist/worker-r47bv7gt.js +513 -0
- package/dist/worker-s4nvbqsm.js +513 -0
- package/dist/worker-ttj7vwce.js +513 -0
- package/dist/worker-wnan5dca.js +513 -0
- package/dist/worker-wv4jdneg.js +513 -0
- package/dist/worker-xcbscr75.js +513 -0
- package/dist/worker-yw3atfb1.js +513 -0
- package/dist/worker-ywwkf3cp.js +513 -0
- package/dist/worker-z8wtk0sh.js +513 -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 +140 -115
- package/dist/account-rvrj687w.js +0 -397
- package/dist/browser-shim/worker.d.ts +0 -14
- package/dist/browser-shim/worker.d.ts.map +0 -1
- package/dist/build-mnf6v8gd.js +0 -53
- package/dist/deploy-nhceck39.js +0 -70
- package/dist/doctor-e8fy6fj5.js +0 -186
- package/dist/index-67qcae0f.js +0 -183
- package/dist/index-ep3445yc.js +0 -2225
- package/dist/index-hcex3rgh.js +0 -266
- package/dist/index-m2q41jwa.js +0 -462
- package/dist/index-n7rs26ft.js +0 -77
- package/dist/index-tfyxa77h.js +0 -850
- package/dist/index-tk6ej9dj.js +0 -94
- package/dist/test/multi-worker-context.d.ts +0 -114
- package/dist/test/multi-worker-context.d.ts.map +0 -1
|
@@ -0,0 +1,2314 @@
|
|
|
1
|
+
import {
|
|
2
|
+
bundleWorkerEntry,
|
|
3
|
+
createDOBundler
|
|
4
|
+
} from "./index-khbmdrn2.js";
|
|
5
|
+
import {
|
|
6
|
+
detectViteProject,
|
|
7
|
+
resolveViteMode,
|
|
8
|
+
stopSpawnedProcessTree,
|
|
9
|
+
waitForViteReady
|
|
10
|
+
} from "./index-gn5wy09x.js";
|
|
11
|
+
import {
|
|
12
|
+
createCliTheme,
|
|
13
|
+
cyanBold,
|
|
14
|
+
dim,
|
|
15
|
+
logLine,
|
|
16
|
+
yellow
|
|
17
|
+
} from "./index-stgn34cr.js";
|
|
18
|
+
import"./index-3t6rypgc.js";
|
|
19
|
+
import {
|
|
20
|
+
DEFAULT_EMAIL_ENTRY_FILES,
|
|
21
|
+
DEFAULT_FETCH_ENTRY_FILES,
|
|
22
|
+
DEFAULT_QUEUE_ENTRY_FILES,
|
|
23
|
+
DEFAULT_SCHEDULED_ENTRY_FILES,
|
|
24
|
+
hasWorkerSurfacePaths,
|
|
25
|
+
prepareComposedWorkerEntrypoint,
|
|
26
|
+
resolveEffectiveViteProject,
|
|
27
|
+
resolveWorkerSurfacePaths,
|
|
28
|
+
writeGeneratedViteConfig
|
|
29
|
+
} from "./index-rbckga8p.js";
|
|
30
|
+
import {
|
|
31
|
+
discoverRoutes,
|
|
32
|
+
getRouteDirectoryCandidate
|
|
33
|
+
} from "./index-1p814k7s.js";
|
|
34
|
+
import"./index-rbht7m9r.js";
|
|
35
|
+
import"./index-vhqww6tt.js";
|
|
36
|
+
import {
|
|
37
|
+
GATEWAY_RUNTIME_JS
|
|
38
|
+
} from "./index-852945d4.js";
|
|
39
|
+
import {
|
|
40
|
+
clearLocalSendEmailBindings,
|
|
41
|
+
setLocalSendEmailBindings
|
|
42
|
+
} from "./index-124e9t4t.js";
|
|
43
|
+
import"./index-9an9qqr1.js";
|
|
44
|
+
import {
|
|
45
|
+
getLocalD1DatabaseIdentifier,
|
|
46
|
+
getLocalKVNamespaceIdentifier,
|
|
47
|
+
getSingleBrowserBindingName,
|
|
48
|
+
loadConfig,
|
|
49
|
+
resolveConfigPath
|
|
50
|
+
} from "./index-5eswe8yv.js";
|
|
51
|
+
import"./index-gba371j7.js";
|
|
52
|
+
import"./index-abrqnq3e.js";
|
|
53
|
+
import"./index-p296ban8.js";
|
|
54
|
+
import"./index-ykfgpsmm.js";
|
|
55
|
+
import {
|
|
56
|
+
__require
|
|
57
|
+
} from "./index-37x76zdn.js";
|
|
58
|
+
|
|
59
|
+
// src/cli/commands/dev.ts
|
|
60
|
+
import { createConsola } from "consola";
|
|
61
|
+
import { relative, resolve as resolve4 } from "pathe";
|
|
62
|
+
|
|
63
|
+
// src/dev-server/server.ts
|
|
64
|
+
import { resolve as resolve3 } from "pathe";
|
|
65
|
+
|
|
66
|
+
// src/browser-shim/server.ts
|
|
67
|
+
import { homedir } from "node:os";
|
|
68
|
+
import { join } from "node:path";
|
|
69
|
+
import { existsSync } from "node:fs";
|
|
70
|
+
import { createServer } from "node:http";
|
|
71
|
+
import puppeteerCore from "puppeteer-core";
|
|
72
|
+
import {
|
|
73
|
+
install,
|
|
74
|
+
resolveBuildId,
|
|
75
|
+
detectBrowserPlatform,
|
|
76
|
+
Browser as BrowserType
|
|
77
|
+
} from "@puppeteer/browsers";
|
|
78
|
+
var cachedExecutablePath = null;
|
|
79
|
+
var DEFAULT_CHROME_FLAGS = [
|
|
80
|
+
"--disable-dev-shm-usage",
|
|
81
|
+
"--disable-gpu",
|
|
82
|
+
"--disable-software-rasterizer",
|
|
83
|
+
"--disable-extensions",
|
|
84
|
+
"--disable-background-networking",
|
|
85
|
+
"--disable-background-timer-throttling",
|
|
86
|
+
"--disable-backgrounding-occluded-windows",
|
|
87
|
+
"--disable-renderer-backgrounding",
|
|
88
|
+
"--disable-features=TranslateUI",
|
|
89
|
+
"--disable-ipc-flooding-protection",
|
|
90
|
+
"--disable-default-apps",
|
|
91
|
+
"--mute-audio",
|
|
92
|
+
"--js-flags=--max-old-space-size=4096"
|
|
93
|
+
];
|
|
94
|
+
var NO_SANDBOX_FLAGS = [
|
|
95
|
+
"--no-sandbox",
|
|
96
|
+
"--disable-setuid-sandbox"
|
|
97
|
+
];
|
|
98
|
+
function resolveChromeFlags(options = {}) {
|
|
99
|
+
const flags = [...DEFAULT_CHROME_FLAGS];
|
|
100
|
+
if (options.allowNoSandbox) {
|
|
101
|
+
flags.unshift(...NO_SANDBOX_FLAGS);
|
|
102
|
+
}
|
|
103
|
+
return flags;
|
|
104
|
+
}
|
|
105
|
+
function createDownloadProgressLogger(logger, label = "Chrome") {
|
|
106
|
+
const state = {
|
|
107
|
+
started: false,
|
|
108
|
+
completed: false,
|
|
109
|
+
progress: { bytesReceived: 0, totalBytes: 0 }
|
|
110
|
+
};
|
|
111
|
+
return {
|
|
112
|
+
onProgress(downloadedBytes, totalBytes) {
|
|
113
|
+
if (state.completed)
|
|
114
|
+
return;
|
|
115
|
+
state.progress.bytesReceived = downloadedBytes;
|
|
116
|
+
state.progress.totalBytes = totalBytes;
|
|
117
|
+
if (!state.started) {
|
|
118
|
+
state.started = true;
|
|
119
|
+
logger?.info(`[BrowserShim] Downloading ${label}...`);
|
|
120
|
+
}
|
|
121
|
+
if (totalBytes > 0 && downloadedBytes >= totalBytes) {
|
|
122
|
+
state.completed = true;
|
|
123
|
+
logger?.info(`[BrowserShim] ${label} download complete`);
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
finalize() {
|
|
127
|
+
if (!state.started || state.completed)
|
|
128
|
+
return;
|
|
129
|
+
state.completed = true;
|
|
130
|
+
logger?.info(`[BrowserShim] ${label} download complete`);
|
|
131
|
+
},
|
|
132
|
+
get progress() {
|
|
133
|
+
return state.progress;
|
|
134
|
+
},
|
|
135
|
+
get started() {
|
|
136
|
+
return state.started;
|
|
137
|
+
},
|
|
138
|
+
get completed() {
|
|
139
|
+
return state.completed;
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
async function ensureChrome(cacheDir, logger) {
|
|
144
|
+
if (cachedExecutablePath && existsSync(cachedExecutablePath)) {
|
|
145
|
+
return cachedExecutablePath;
|
|
146
|
+
}
|
|
147
|
+
const platform = detectBrowserPlatform();
|
|
148
|
+
if (!platform) {
|
|
149
|
+
throw new Error("Could not detect browser platform");
|
|
150
|
+
}
|
|
151
|
+
const buildId = await resolveBuildId(BrowserType.CHROMEHEADLESSSHELL, platform, "stable");
|
|
152
|
+
logger?.debug(`[BrowserShim] Resolved Chrome Headless Shell build: ${buildId}`);
|
|
153
|
+
const progressLogger = createDownloadProgressLogger(logger, "Chrome");
|
|
154
|
+
const installedBrowser = await install({
|
|
155
|
+
browser: BrowserType.CHROMEHEADLESSSHELL,
|
|
156
|
+
buildId,
|
|
157
|
+
cacheDir,
|
|
158
|
+
downloadProgressCallback: (downloadedBytes, totalBytes) => {
|
|
159
|
+
progressLogger.onProgress(downloadedBytes, totalBytes);
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
progressLogger.finalize();
|
|
163
|
+
cachedExecutablePath = installedBrowser.executablePath;
|
|
164
|
+
logger?.success(`[BrowserShim] Chrome ready: ${installedBrowser.executablePath}`);
|
|
165
|
+
return installedBrowser.executablePath;
|
|
166
|
+
}
|
|
167
|
+
function createBrowserShim(options = {}) {
|
|
168
|
+
const {
|
|
169
|
+
port = 8788,
|
|
170
|
+
host = "127.0.0.1",
|
|
171
|
+
logger,
|
|
172
|
+
verbose = false,
|
|
173
|
+
keepAlive = 60000,
|
|
174
|
+
cacheDir = join(homedir(), ".devflare", "chrome"),
|
|
175
|
+
allowNoSandbox = false
|
|
176
|
+
} = options;
|
|
177
|
+
const chromeLaunchArgs = resolveChromeFlags({ allowNoSandbox });
|
|
178
|
+
if (allowNoSandbox) {
|
|
179
|
+
logger?.warn("[BrowserShim] Launching Chrome with --no-sandbox (allowNoSandbox=true). " + "Only use this in trusted CI/rootless environments.");
|
|
180
|
+
}
|
|
181
|
+
let server = null;
|
|
182
|
+
let executablePath = null;
|
|
183
|
+
const sessions = new Map;
|
|
184
|
+
const history = [];
|
|
185
|
+
let WebSocketServerClass = null;
|
|
186
|
+
let WebSocketClass = null;
|
|
187
|
+
const maxRequestBodyBytes = 1024 * 1024;
|
|
188
|
+
function getRequestOrigin(req) {
|
|
189
|
+
const origin = req.headers.origin;
|
|
190
|
+
if (typeof origin === "string") {
|
|
191
|
+
return origin;
|
|
192
|
+
}
|
|
193
|
+
if (Array.isArray(origin) && origin[0]) {
|
|
194
|
+
return origin[0];
|
|
195
|
+
}
|
|
196
|
+
return null;
|
|
197
|
+
}
|
|
198
|
+
function isLoopbackOrigin(origin) {
|
|
199
|
+
try {
|
|
200
|
+
const url = new URL(origin);
|
|
201
|
+
return url.hostname === "127.0.0.1" || url.hostname === "localhost" || url.hostname === "::1" || url.hostname === "[::1]";
|
|
202
|
+
} catch {
|
|
203
|
+
return false;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
function applyCorsHeaders(req, res) {
|
|
207
|
+
const origin = getRequestOrigin(req);
|
|
208
|
+
if (!origin) {
|
|
209
|
+
return true;
|
|
210
|
+
}
|
|
211
|
+
if (!isLoopbackOrigin(origin)) {
|
|
212
|
+
res.writeHead(403, { "Content-Type": "application/json" });
|
|
213
|
+
res.end(JSON.stringify({ error: "Forbidden origin" }));
|
|
214
|
+
return false;
|
|
215
|
+
}
|
|
216
|
+
res.setHeader("Access-Control-Allow-Origin", origin);
|
|
217
|
+
res.setHeader("Access-Control-Allow-Methods", "GET, POST, OPTIONS");
|
|
218
|
+
res.setHeader("Access-Control-Allow-Headers", "Content-Type");
|
|
219
|
+
res.setHeader("Vary", "Origin");
|
|
220
|
+
return true;
|
|
221
|
+
}
|
|
222
|
+
async function acquireSession(acquireOptions) {
|
|
223
|
+
if (!executablePath) {
|
|
224
|
+
throw new Error("Chrome not initialized");
|
|
225
|
+
}
|
|
226
|
+
const browser = await puppeteerCore.launch({
|
|
227
|
+
executablePath,
|
|
228
|
+
headless: true,
|
|
229
|
+
protocolTimeout: 120000,
|
|
230
|
+
args: chromeLaunchArgs
|
|
231
|
+
});
|
|
232
|
+
const wsEndpoint = browser.wsEndpoint();
|
|
233
|
+
const sessionId = crypto.randomUUID();
|
|
234
|
+
const session = {
|
|
235
|
+
sessionId,
|
|
236
|
+
browser,
|
|
237
|
+
wsEndpoint,
|
|
238
|
+
startTime: Date.now()
|
|
239
|
+
};
|
|
240
|
+
sessions.set(sessionId, session);
|
|
241
|
+
const timeout = acquireOptions?.keep_alive ?? keepAlive;
|
|
242
|
+
if (timeout > 0) {
|
|
243
|
+
session.idleTimeout = setTimeout(async () => {
|
|
244
|
+
const s = sessions.get(sessionId);
|
|
245
|
+
if (s && !s.connectionId) {
|
|
246
|
+
await closeSession(sessionId, 2, "BrowserIdle");
|
|
247
|
+
}
|
|
248
|
+
}, timeout);
|
|
249
|
+
}
|
|
250
|
+
if (verbose) {
|
|
251
|
+
logger?.debug(`[BrowserShim] Acquired session ${sessionId}`);
|
|
252
|
+
}
|
|
253
|
+
return { sessionId };
|
|
254
|
+
}
|
|
255
|
+
async function closeSession(sessionId, closeReason = 1, closeReasonText = "NormalClosure") {
|
|
256
|
+
const session = sessions.get(sessionId);
|
|
257
|
+
if (!session)
|
|
258
|
+
return;
|
|
259
|
+
if (session.idleTimeout) {
|
|
260
|
+
clearTimeout(session.idleTimeout);
|
|
261
|
+
}
|
|
262
|
+
try {
|
|
263
|
+
await session.browser.close();
|
|
264
|
+
} catch {}
|
|
265
|
+
sessions.delete(sessionId);
|
|
266
|
+
history.unshift({
|
|
267
|
+
sessionId,
|
|
268
|
+
startTime: session.startTime,
|
|
269
|
+
endTime: Date.now(),
|
|
270
|
+
closeReason,
|
|
271
|
+
closeReasonText
|
|
272
|
+
});
|
|
273
|
+
if (history.length > 100) {
|
|
274
|
+
history.pop();
|
|
275
|
+
}
|
|
276
|
+
if (verbose) {
|
|
277
|
+
logger?.debug(`[BrowserShim] Closed session ${sessionId}: ${closeReasonText}`);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
async function handleRequest(req, res) {
|
|
281
|
+
const url = new URL(req.url || "/", `http://${host}:${port}`);
|
|
282
|
+
const method = req.method || "GET";
|
|
283
|
+
logger?.debug(`[BrowserShim] ${method} ${url.pathname}${url.search ? url.search : ""}`);
|
|
284
|
+
if (!applyCorsHeaders(req, res)) {
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
if (method === "OPTIONS") {
|
|
288
|
+
res.writeHead(204);
|
|
289
|
+
res.end();
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
292
|
+
if (url.pathname === "/v1/acquire" && (method === "POST" || method === "GET")) {
|
|
293
|
+
try {
|
|
294
|
+
let acquireOptions = {};
|
|
295
|
+
if (method === "GET") {
|
|
296
|
+
const keepAlive2 = url.searchParams.get("keep_alive");
|
|
297
|
+
if (keepAlive2) {
|
|
298
|
+
acquireOptions.keep_alive = parseInt(keepAlive2, 10);
|
|
299
|
+
}
|
|
300
|
+
} else {
|
|
301
|
+
try {
|
|
302
|
+
const body = await readBody(req);
|
|
303
|
+
acquireOptions = JSON.parse(body);
|
|
304
|
+
} catch {}
|
|
305
|
+
}
|
|
306
|
+
const result = await acquireSession(acquireOptions);
|
|
307
|
+
sendJson(res, 200, result);
|
|
308
|
+
} catch (error) {
|
|
309
|
+
const msg = error instanceof Error ? error.message : "Failed to acquire browser";
|
|
310
|
+
logger?.error(`[BrowserShim] Acquire failed: ${msg}`);
|
|
311
|
+
sendJson(res, 500, { error: msg });
|
|
312
|
+
}
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
if (url.pathname === "/v1/sessions" && method === "GET") {
|
|
316
|
+
const activeSessions = Array.from(sessions.values()).map((s) => ({
|
|
317
|
+
sessionId: s.sessionId,
|
|
318
|
+
startTime: s.startTime,
|
|
319
|
+
connectionId: s.connectionId,
|
|
320
|
+
connectionStartTime: s.connectionStartTime
|
|
321
|
+
}));
|
|
322
|
+
sendJson(res, 200, activeSessions);
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
325
|
+
if (url.pathname === "/v1/history" && method === "GET") {
|
|
326
|
+
sendJson(res, 200, history.slice(0, 50));
|
|
327
|
+
return;
|
|
328
|
+
}
|
|
329
|
+
if (url.pathname === "/v1/limits" && method === "GET") {
|
|
330
|
+
sendJson(res, 200, {
|
|
331
|
+
activeSessions: Array.from(sessions.keys()).map((id) => ({ id })),
|
|
332
|
+
allowedBrowserAcquisitions: 10,
|
|
333
|
+
maxConcurrentSessions: 10,
|
|
334
|
+
timeUntilNextAllowedBrowserAcquisition: 0
|
|
335
|
+
});
|
|
336
|
+
return;
|
|
337
|
+
}
|
|
338
|
+
if (url.pathname.startsWith("/v1/session/") && method === "GET") {
|
|
339
|
+
const sessionId = url.pathname.slice("/v1/session/".length);
|
|
340
|
+
const session = sessions.get(sessionId);
|
|
341
|
+
if (!session) {
|
|
342
|
+
sendJson(res, 404, { error: "Session not found" });
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
sendJson(res, 200, {
|
|
346
|
+
sessionId: session.sessionId,
|
|
347
|
+
wsEndpoint: session.wsEndpoint,
|
|
348
|
+
startTime: session.startTime,
|
|
349
|
+
connectionId: session.connectionId,
|
|
350
|
+
connectionStartTime: session.connectionStartTime
|
|
351
|
+
});
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
if (url.pathname === "/_devflare/browser/health") {
|
|
355
|
+
sendJson(res, 200, {
|
|
356
|
+
ok: true,
|
|
357
|
+
activeSessions: sessions.size,
|
|
358
|
+
historySize: history.length,
|
|
359
|
+
executablePath
|
|
360
|
+
});
|
|
361
|
+
return;
|
|
362
|
+
}
|
|
363
|
+
if (url.pathname === "/v1/connectDevtools") {
|
|
364
|
+
res.writeHead(426, { "Content-Type": "text/plain" });
|
|
365
|
+
res.end("WebSocket upgrade required");
|
|
366
|
+
return;
|
|
367
|
+
}
|
|
368
|
+
res.writeHead(404, { "Content-Type": "text/plain" });
|
|
369
|
+
res.end("Not found");
|
|
370
|
+
}
|
|
371
|
+
function readBody(req) {
|
|
372
|
+
return new Promise((resolve, reject) => {
|
|
373
|
+
const chunks = [];
|
|
374
|
+
let totalBytes = 0;
|
|
375
|
+
req.on("data", (chunk) => {
|
|
376
|
+
totalBytes += chunk.length;
|
|
377
|
+
if (totalBytes > maxRequestBodyBytes) {
|
|
378
|
+
req.destroy();
|
|
379
|
+
reject(new Error(`Request body exceeds ${maxRequestBodyBytes} bytes`));
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
382
|
+
chunks.push(chunk);
|
|
383
|
+
});
|
|
384
|
+
req.on("end", () => resolve(Buffer.concat(chunks).toString()));
|
|
385
|
+
req.on("error", reject);
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
function sendJson(res, status, data) {
|
|
389
|
+
const body = JSON.stringify(data);
|
|
390
|
+
res.writeHead(status, {
|
|
391
|
+
"Content-Type": "application/json",
|
|
392
|
+
"Content-Length": Buffer.byteLength(body)
|
|
393
|
+
});
|
|
394
|
+
res.end(body);
|
|
395
|
+
}
|
|
396
|
+
async function start() {
|
|
397
|
+
logger?.info("[BrowserShim] Ensuring Chrome Headless Shell is available...");
|
|
398
|
+
executablePath = await ensureChrome(cacheDir, logger);
|
|
399
|
+
try {
|
|
400
|
+
const wsModule = await import("ws");
|
|
401
|
+
WebSocketServerClass = wsModule.WebSocketServer || wsModule.default?.WebSocketServer;
|
|
402
|
+
WebSocketClass = wsModule.WebSocket || wsModule.default?.WebSocket || wsModule.default;
|
|
403
|
+
} catch {
|
|
404
|
+
logger?.warn("[BrowserShim] ws package not found, WebSocket proxy disabled");
|
|
405
|
+
logger?.warn("[BrowserShim] Install with: npm install ws");
|
|
406
|
+
}
|
|
407
|
+
server = createServer((req, res) => {
|
|
408
|
+
handleRequest(req, res).catch((error) => {
|
|
409
|
+
logger?.error("[BrowserShim] Request error:", error);
|
|
410
|
+
res.writeHead(500);
|
|
411
|
+
res.end("Internal server error");
|
|
412
|
+
});
|
|
413
|
+
});
|
|
414
|
+
if (WebSocketServerClass) {
|
|
415
|
+
const wss = new WebSocketServerClass({ noServer: true });
|
|
416
|
+
server.on("upgrade", (request, socket, head) => {
|
|
417
|
+
const origin = getRequestOrigin(request);
|
|
418
|
+
if (origin && !isLoopbackOrigin(origin)) {
|
|
419
|
+
socket.write(`HTTP/1.1 403 Forbidden\r
|
|
420
|
+
\r
|
|
421
|
+
`);
|
|
422
|
+
socket.destroy();
|
|
423
|
+
return;
|
|
424
|
+
}
|
|
425
|
+
const url = new URL(request.url || "/", `http://${host}:${port}`);
|
|
426
|
+
if (url.pathname !== "/v1/connectDevtools") {
|
|
427
|
+
socket.destroy();
|
|
428
|
+
return;
|
|
429
|
+
}
|
|
430
|
+
const sessionId = url.searchParams.get("browser_session");
|
|
431
|
+
if (!sessionId) {
|
|
432
|
+
socket.write(`HTTP/1.1 400 Bad Request\r
|
|
433
|
+
\r
|
|
434
|
+
`);
|
|
435
|
+
socket.destroy();
|
|
436
|
+
return;
|
|
437
|
+
}
|
|
438
|
+
const session = sessions.get(sessionId);
|
|
439
|
+
if (!session) {
|
|
440
|
+
socket.write(`HTTP/1.1 404 Not Found\r
|
|
441
|
+
\r
|
|
442
|
+
`);
|
|
443
|
+
socket.destroy();
|
|
444
|
+
return;
|
|
445
|
+
}
|
|
446
|
+
const connectionId = crypto.randomUUID();
|
|
447
|
+
session.connectionId = connectionId;
|
|
448
|
+
session.connectionStartTime = Date.now();
|
|
449
|
+
if (session.idleTimeout) {
|
|
450
|
+
clearTimeout(session.idleTimeout);
|
|
451
|
+
session.idleTimeout = undefined;
|
|
452
|
+
}
|
|
453
|
+
wss.handleUpgrade(request, socket, head, (ws) => {
|
|
454
|
+
if (verbose) {
|
|
455
|
+
logger?.debug(`[BrowserShim] WebSocket connected for session ${sessionId}`);
|
|
456
|
+
}
|
|
457
|
+
const chromeWs = new WebSocketClass(session.wsEndpoint);
|
|
458
|
+
let chromeConnected = false;
|
|
459
|
+
const connectTimeout = setTimeout(() => {
|
|
460
|
+
if (!chromeConnected) {
|
|
461
|
+
logger?.error("[BrowserShim] Chrome connection timeout");
|
|
462
|
+
try {
|
|
463
|
+
ws.close(1011, "Chrome connection timeout");
|
|
464
|
+
chromeWs.close();
|
|
465
|
+
} catch {}
|
|
466
|
+
closeSession(sessionId, 5, "ChromeConnectionTimeout").catch(() => {});
|
|
467
|
+
}
|
|
468
|
+
}, 1e4);
|
|
469
|
+
chromeWs.on("open", () => {
|
|
470
|
+
chromeConnected = true;
|
|
471
|
+
clearTimeout(connectTimeout);
|
|
472
|
+
if (verbose) {
|
|
473
|
+
logger?.debug("[BrowserShim] Connected to Chrome DevTools");
|
|
474
|
+
}
|
|
475
|
+
});
|
|
476
|
+
chromeWs.on("message", (data) => {
|
|
477
|
+
if (ws.readyState === 1) {
|
|
478
|
+
ws.send(data);
|
|
479
|
+
}
|
|
480
|
+
});
|
|
481
|
+
chromeWs.on("close", (code, reason) => {
|
|
482
|
+
if (verbose) {
|
|
483
|
+
logger?.debug(`[BrowserShim] Chrome WS closed: ${code}`);
|
|
484
|
+
}
|
|
485
|
+
const validCode = typeof code === "number" && code >= 1000 && code <= 4999 ? code : 1000;
|
|
486
|
+
try {
|
|
487
|
+
ws.close(validCode, reason?.toString?.() || "");
|
|
488
|
+
} catch {}
|
|
489
|
+
closeSession(sessionId, 2, "ChromeDisconnected").catch((err) => {
|
|
490
|
+
logger?.error("[BrowserShim] Error closing session after Chrome disconnect:", err);
|
|
491
|
+
});
|
|
492
|
+
});
|
|
493
|
+
chromeWs.on("error", (error) => {
|
|
494
|
+
logger?.error("[BrowserShim] Chrome WS error:", error.message);
|
|
495
|
+
try {
|
|
496
|
+
ws.close(1011, "Chrome WebSocket error");
|
|
497
|
+
} catch {}
|
|
498
|
+
closeSession(sessionId, 4, "ChromeError").catch((err) => {
|
|
499
|
+
logger?.error("[BrowserShim] Error closing session after Chrome error:", err);
|
|
500
|
+
});
|
|
501
|
+
});
|
|
502
|
+
ws.on("message", (data) => {
|
|
503
|
+
if (chromeWs.readyState === 1) {
|
|
504
|
+
chromeWs.send(data);
|
|
505
|
+
}
|
|
506
|
+
});
|
|
507
|
+
ws.on("close", (code, reason) => {
|
|
508
|
+
if (verbose) {
|
|
509
|
+
logger?.debug(`[BrowserShim] Client WS closed for session ${sessionId}`);
|
|
510
|
+
}
|
|
511
|
+
const validCode = typeof code === "number" && code >= 1000 && code <= 4999 ? code : 1000;
|
|
512
|
+
try {
|
|
513
|
+
chromeWs.close(validCode, reason?.toString?.() || "");
|
|
514
|
+
} catch {}
|
|
515
|
+
const s = sessions.get(sessionId);
|
|
516
|
+
if (s && s.connectionId === connectionId) {
|
|
517
|
+
s.connectionId = undefined;
|
|
518
|
+
s.connectionStartTime = undefined;
|
|
519
|
+
closeSession(sessionId, 1, "ClientDisconnected").catch((err) => {
|
|
520
|
+
logger?.error("[BrowserShim] Error closing session after disconnect:", err);
|
|
521
|
+
});
|
|
522
|
+
}
|
|
523
|
+
});
|
|
524
|
+
ws.on("error", (error) => {
|
|
525
|
+
logger?.error("[BrowserShim] Client WS error:", error.message);
|
|
526
|
+
try {
|
|
527
|
+
chromeWs.close();
|
|
528
|
+
} catch {}
|
|
529
|
+
});
|
|
530
|
+
});
|
|
531
|
+
});
|
|
532
|
+
}
|
|
533
|
+
await new Promise((resolve, reject) => {
|
|
534
|
+
server.on("error", reject);
|
|
535
|
+
server.listen(port, host, () => {
|
|
536
|
+
resolve();
|
|
537
|
+
});
|
|
538
|
+
});
|
|
539
|
+
logger?.success(`Browser shim server ready on http://${host}:${port}`);
|
|
540
|
+
}
|
|
541
|
+
async function stop() {
|
|
542
|
+
for (const sessionId of Array.from(sessions.keys())) {
|
|
543
|
+
await closeSession(sessionId, 3, "ServerShutdown");
|
|
544
|
+
}
|
|
545
|
+
if (server) {
|
|
546
|
+
await new Promise((resolve) => {
|
|
547
|
+
server.close(() => resolve());
|
|
548
|
+
});
|
|
549
|
+
server = null;
|
|
550
|
+
}
|
|
551
|
+
logger?.info("Browser shim server stopped");
|
|
552
|
+
}
|
|
553
|
+
function getUrl() {
|
|
554
|
+
return `http://${host}:${port}`;
|
|
555
|
+
}
|
|
556
|
+
return {
|
|
557
|
+
start,
|
|
558
|
+
stop,
|
|
559
|
+
getUrl
|
|
560
|
+
};
|
|
561
|
+
}
|
|
562
|
+
// src/browser-shim/binding-worker.ts
|
|
563
|
+
var MAX_CHUNK_SIZE = 1048575;
|
|
564
|
+
function getBrowserBindingScript(browserShimUrl, debug = false) {
|
|
565
|
+
const safeUrl = JSON.stringify(browserShimUrl);
|
|
566
|
+
return `
|
|
567
|
+
// Browser Binding Worker — Proxies puppeteer requests to external browser shim
|
|
568
|
+
// Handles WebSocket upgrades using WebSocketPair for @cloudflare/puppeteer compatibility
|
|
569
|
+
|
|
570
|
+
const BROWSER_SHIM_URL = ${safeUrl}
|
|
571
|
+
const MAX_CHUNK_SIZE = ${MAX_CHUNK_SIZE}
|
|
572
|
+
const DEBUG = ${debug}
|
|
573
|
+
const log = (...args) => DEBUG && console.log('[BrowserBinding]', ...args)
|
|
574
|
+
|
|
575
|
+
export default {
|
|
576
|
+
async fetch(request, env, ctx) {
|
|
577
|
+
const url = new URL(request.url)
|
|
578
|
+
const upgradeHeader = request.headers.get('Upgrade')
|
|
579
|
+
const isWebSocket = upgradeHeader && upgradeHeader.toLowerCase() === 'websocket'
|
|
580
|
+
|
|
581
|
+
log('Request:', url.pathname, isWebSocket ? '(WebSocket)' : '(HTTP)')
|
|
582
|
+
|
|
583
|
+
// Handle WebSocket upgrade for DevTools connection
|
|
584
|
+
if (url.pathname === '/v1/connectDevtools' && isWebSocket) {
|
|
585
|
+
return handleDevToolsWebSocket(request, url)
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
// Proxy all other requests to the browser shim server
|
|
589
|
+
return proxyToBrowserShim(request, url)
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
// Proxy HTTP requests to the external browser shim server
|
|
594
|
+
async function proxyToBrowserShim(request, url) {
|
|
595
|
+
const shimUrl = new URL(url.pathname + url.search, BROWSER_SHIM_URL)
|
|
596
|
+
|
|
597
|
+
log('Proxying to:', shimUrl.toString())
|
|
598
|
+
|
|
599
|
+
const response = await fetch(shimUrl.toString(), {
|
|
600
|
+
method: request.method,
|
|
601
|
+
headers: request.headers,
|
|
602
|
+
body: request.method !== 'GET' && request.method !== 'HEAD' ? request.body : undefined
|
|
603
|
+
})
|
|
604
|
+
|
|
605
|
+
log('Response:', response.status)
|
|
606
|
+
|
|
607
|
+
// Return the response as-is
|
|
608
|
+
return new Response(response.body, {
|
|
609
|
+
status: response.status,
|
|
610
|
+
statusText: response.statusText,
|
|
611
|
+
headers: response.headers
|
|
612
|
+
})
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
// Validate WebSocket close code to be in valid range
|
|
616
|
+
function validateCloseCode(code) {
|
|
617
|
+
if (typeof code !== 'number' || isNaN(code)) return 1000
|
|
618
|
+
if (code < 1000 || code > 4999) return 1000
|
|
619
|
+
return code
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
// Split a message into chunks following @cloudflare/puppeteer protocol
|
|
623
|
+
// First chunk has 4-byte LE length header, subsequent chunks are raw payload
|
|
624
|
+
function messageToChunks(message) {
|
|
625
|
+
const data = typeof message === 'string'
|
|
626
|
+
? new TextEncoder().encode(message)
|
|
627
|
+
: new Uint8Array(message)
|
|
628
|
+
|
|
629
|
+
const chunks = []
|
|
630
|
+
const totalLength = data.length
|
|
631
|
+
let offset = 0
|
|
632
|
+
let isFirst = true
|
|
633
|
+
|
|
634
|
+
while (offset < totalLength) {
|
|
635
|
+
const remaining = totalLength - offset
|
|
636
|
+
let chunkSize
|
|
637
|
+
|
|
638
|
+
if (isFirst) {
|
|
639
|
+
// First chunk: 4-byte header + payload
|
|
640
|
+
chunkSize = Math.min(remaining, MAX_CHUNK_SIZE - 4)
|
|
641
|
+
const chunk = new Uint8Array(chunkSize + 4)
|
|
642
|
+
new DataView(chunk.buffer).setUint32(0, totalLength, true) // little-endian
|
|
643
|
+
chunk.set(data.subarray(offset, offset + chunkSize), 4)
|
|
644
|
+
chunks.push(chunk)
|
|
645
|
+
isFirst = false
|
|
646
|
+
} else {
|
|
647
|
+
// Subsequent chunks: raw payload only
|
|
648
|
+
chunkSize = Math.min(remaining, MAX_CHUNK_SIZE)
|
|
649
|
+
const chunk = data.subarray(offset, offset + chunkSize)
|
|
650
|
+
chunks.push(chunk)
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
offset += chunkSize
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
return chunks
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
// Reassemble chunks back into a complete message
|
|
660
|
+
// Returns null if more chunks are needed
|
|
661
|
+
function chunksToMessage(chunks) {
|
|
662
|
+
if (chunks.length === 0) return null
|
|
663
|
+
|
|
664
|
+
// First chunk must have 4-byte header
|
|
665
|
+
const firstChunk = chunks[0]
|
|
666
|
+
if (firstChunk.length < 4) return null
|
|
667
|
+
|
|
668
|
+
const expectedLength = new DataView(firstChunk.buffer, firstChunk.byteOffset).getUint32(0, true)
|
|
669
|
+
|
|
670
|
+
// Calculate total received payload
|
|
671
|
+
let totalReceived = firstChunk.length - 4 // first chunk payload (minus header)
|
|
672
|
+
for (let i = 1; i < chunks.length; i++) {
|
|
673
|
+
totalReceived += chunks[i].length
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
if (totalReceived < expectedLength) {
|
|
677
|
+
return null // Need more chunks
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
// Reassemble the message
|
|
681
|
+
const assembled = new Uint8Array(expectedLength)
|
|
682
|
+
let offset = 0
|
|
683
|
+
|
|
684
|
+
// Copy first chunk payload (skip 4-byte header)
|
|
685
|
+
const firstPayload = firstChunk.subarray(4)
|
|
686
|
+
assembled.set(firstPayload, offset)
|
|
687
|
+
offset += firstPayload.length
|
|
688
|
+
|
|
689
|
+
// Copy remaining chunks
|
|
690
|
+
for (let i = 1; i < chunks.length; i++) {
|
|
691
|
+
const chunk = chunks[i]
|
|
692
|
+
const toCopy = Math.min(chunk.length, expectedLength - offset)
|
|
693
|
+
assembled.set(chunk.subarray(0, toCopy), offset)
|
|
694
|
+
offset += toCopy
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
return new TextDecoder().decode(assembled)
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
// Handle WebSocket upgrade for DevTools connection
|
|
701
|
+
// Creates a WebSocketPair and proxies to Chrome's DevTools WebSocket
|
|
702
|
+
async function handleDevToolsWebSocket(request, url) {
|
|
703
|
+
const sessionId = url.searchParams.get('browser_session')
|
|
704
|
+
if (!sessionId) {
|
|
705
|
+
return new Response('browser_session parameter required', { status: 400 })
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
log('DevTools WebSocket request for session:', sessionId)
|
|
709
|
+
|
|
710
|
+
// Get session info from browser shim (includes Chrome's wsEndpoint)
|
|
711
|
+
const sessionUrl = new URL('/v1/session/' + sessionId, BROWSER_SHIM_URL)
|
|
712
|
+
|
|
713
|
+
// Add timeout for session fetch
|
|
714
|
+
const controller = new AbortController()
|
|
715
|
+
const timeout = setTimeout(() => controller.abort(), 5000)
|
|
716
|
+
|
|
717
|
+
let sessionRes
|
|
718
|
+
try {
|
|
719
|
+
sessionRes = await fetch(sessionUrl.toString(), { signal: controller.signal })
|
|
720
|
+
} catch (e) {
|
|
721
|
+
DEBUG && console.error('[BrowserBinding] Session fetch timeout or error:', e.message)
|
|
722
|
+
return new Response('Session fetch timeout', { status: 504 })
|
|
723
|
+
} finally {
|
|
724
|
+
clearTimeout(timeout)
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
if (!sessionRes.ok) {
|
|
728
|
+
DEBUG && console.error('[BrowserBinding] Session not found:', sessionId)
|
|
729
|
+
return new Response('Session not found', { status: 404 })
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
const sessionInfo = await sessionRes.json()
|
|
733
|
+
const wsEndpoint = sessionInfo.wsEndpoint
|
|
734
|
+
|
|
735
|
+
if (!wsEndpoint) {
|
|
736
|
+
DEBUG && console.error('[BrowserBinding] No wsEndpoint in session info')
|
|
737
|
+
return new Response('No wsEndpoint for session', { status: 500 })
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
log('Connecting to Chrome DevTools:', wsEndpoint)
|
|
741
|
+
|
|
742
|
+
// Connect to Chrome's DevTools WebSocket
|
|
743
|
+
// Chrome uses ws:// but fetch expects http:// for WebSocket upgrade
|
|
744
|
+
const chromeUrl = wsEndpoint.replace('ws://', 'http://').replace('wss://', 'https://')
|
|
745
|
+
|
|
746
|
+
const chromeRes = await fetch(chromeUrl, {
|
|
747
|
+
headers: { Upgrade: 'websocket' }
|
|
748
|
+
})
|
|
749
|
+
|
|
750
|
+
if (!chromeRes.webSocket) {
|
|
751
|
+
DEBUG && console.error('[BrowserBinding] Failed to connect to Chrome DevTools')
|
|
752
|
+
return new Response('Failed to connect to Chrome DevTools', { status: 502 })
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
const chromeWs = chromeRes.webSocket
|
|
756
|
+
chromeWs.accept()
|
|
757
|
+
|
|
758
|
+
log('Connected to Chrome DevTools')
|
|
759
|
+
|
|
760
|
+
// Create WebSocketPair for client connection
|
|
761
|
+
const { 0: client, 1: server } = new WebSocketPair()
|
|
762
|
+
server.accept()
|
|
763
|
+
|
|
764
|
+
// Chunk buffer for reassembling multi-chunk messages from puppeteer
|
|
765
|
+
let chunks = []
|
|
766
|
+
const MAX_BUFFER_SIZE = 50 * 1024 * 1024 // 50MB max buffer
|
|
767
|
+
let bufferSize = 0
|
|
768
|
+
|
|
769
|
+
// Proxy messages from client (puppeteer) to Chrome
|
|
770
|
+
// Handle multi-chunk framing protocol
|
|
771
|
+
server.addEventListener('message', (event) => {
|
|
772
|
+
// Keep-alive ping from puppeteer
|
|
773
|
+
if (event.data === 'ping') {
|
|
774
|
+
return
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
// Handle binary data (chunked protocol)
|
|
778
|
+
if (event.data instanceof ArrayBuffer) {
|
|
779
|
+
const chunk = new Uint8Array(event.data)
|
|
780
|
+
bufferSize += chunk.length
|
|
781
|
+
|
|
782
|
+
// Prevent unbounded buffering
|
|
783
|
+
if (bufferSize > MAX_BUFFER_SIZE) {
|
|
784
|
+
DEBUG && console.error('[BrowserBinding] Buffer overflow, closing connection')
|
|
785
|
+
server.close(1009, 'Message too big')
|
|
786
|
+
chromeWs.close(1009, 'Message too big')
|
|
787
|
+
return
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
chunks.push(chunk)
|
|
791
|
+
|
|
792
|
+
// Try to reassemble complete message
|
|
793
|
+
const message = chunksToMessage(chunks)
|
|
794
|
+
if (message !== null) {
|
|
795
|
+
// Send complete message to Chrome
|
|
796
|
+
if (chromeWs.readyState === 1) { // OPEN
|
|
797
|
+
chromeWs.send(message)
|
|
798
|
+
}
|
|
799
|
+
// Clear buffer
|
|
800
|
+
chunks = []
|
|
801
|
+
bufferSize = 0
|
|
802
|
+
}
|
|
803
|
+
} else if (typeof event.data === 'string') {
|
|
804
|
+
// Shouldn't happen in normal protocol, but handle it
|
|
805
|
+
if (chromeWs.readyState === 1) {
|
|
806
|
+
chromeWs.send(event.data)
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
})
|
|
810
|
+
|
|
811
|
+
// Proxy messages from Chrome to client (puppeteer)
|
|
812
|
+
// Split into chunks following the multi-chunk protocol
|
|
813
|
+
chromeWs.addEventListener('message', (event) => {
|
|
814
|
+
if (server.readyState !== 1) return // Not OPEN
|
|
815
|
+
|
|
816
|
+
// Split message into chunks
|
|
817
|
+
const outChunks = messageToChunks(event.data)
|
|
818
|
+
for (const chunk of outChunks) {
|
|
819
|
+
server.send(chunk)
|
|
820
|
+
}
|
|
821
|
+
})
|
|
822
|
+
|
|
823
|
+
// Handle close events with validated codes
|
|
824
|
+
server.addEventListener('close', (event) => {
|
|
825
|
+
log('Client WebSocket closed:', event.code)
|
|
826
|
+
const code = validateCloseCode(event.code)
|
|
827
|
+
try {
|
|
828
|
+
if (chromeWs.readyState === 1 || chromeWs.readyState === 0) {
|
|
829
|
+
chromeWs.close(code, event.reason || '')
|
|
830
|
+
}
|
|
831
|
+
} catch {}
|
|
832
|
+
})
|
|
833
|
+
|
|
834
|
+
chromeWs.addEventListener('close', (event) => {
|
|
835
|
+
log('Chrome WebSocket closed:', event.code)
|
|
836
|
+
const code = validateCloseCode(event.code)
|
|
837
|
+
try {
|
|
838
|
+
if (server.readyState === 1 || server.readyState === 0) {
|
|
839
|
+
server.close(code, event.reason || '')
|
|
840
|
+
}
|
|
841
|
+
} catch {}
|
|
842
|
+
})
|
|
843
|
+
|
|
844
|
+
// Handle errors
|
|
845
|
+
server.addEventListener('error', (event) => {
|
|
846
|
+
DEBUG && console.error('[BrowserBinding] Client WebSocket error')
|
|
847
|
+
try { chromeWs.close(1011, 'Client error') } catch {}
|
|
848
|
+
})
|
|
849
|
+
|
|
850
|
+
chromeWs.addEventListener('error', (event) => {
|
|
851
|
+
DEBUG && console.error('[BrowserBinding] Chrome WebSocket error')
|
|
852
|
+
try { server.close(1011, 'Chrome error') } catch {}
|
|
853
|
+
})
|
|
854
|
+
|
|
855
|
+
log('WebSocket proxy established')
|
|
856
|
+
|
|
857
|
+
// Return Cloudflare-style WebSocket response
|
|
858
|
+
return new Response(null, {
|
|
859
|
+
status: 101,
|
|
860
|
+
webSocket: client
|
|
861
|
+
})
|
|
862
|
+
}
|
|
863
|
+
`;
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
// src/cli/wrangler-auth.ts
|
|
867
|
+
import { exec } from "node:child_process";
|
|
868
|
+
import { promisify } from "node:util";
|
|
869
|
+
var execAsync = promisify(exec);
|
|
870
|
+
function detectRemoteBindings(config) {
|
|
871
|
+
const remoteBindings = [];
|
|
872
|
+
const bindings = config.bindings;
|
|
873
|
+
if (!bindings)
|
|
874
|
+
return remoteBindings;
|
|
875
|
+
if (bindings.ai) {
|
|
876
|
+
remoteBindings.push(`AI (binding: ${bindings.ai.binding})`);
|
|
877
|
+
}
|
|
878
|
+
if (bindings.vectorize) {
|
|
879
|
+
for (const [name] of Object.entries(bindings.vectorize)) {
|
|
880
|
+
remoteBindings.push(`Vectorize (binding: ${name})`);
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
return remoteBindings;
|
|
884
|
+
}
|
|
885
|
+
async function checkWranglerAuth() {
|
|
886
|
+
try {
|
|
887
|
+
const { stdout, stderr } = await execAsync("bunx wrangler whoami", {
|
|
888
|
+
timeout: 15000
|
|
889
|
+
});
|
|
890
|
+
const output = stdout + stderr;
|
|
891
|
+
if (output.includes("not authenticated") || output.includes("Not logged in") || output.includes("wrangler login")) {
|
|
892
|
+
return {
|
|
893
|
+
loggedIn: false,
|
|
894
|
+
error: "Not logged in to Wrangler"
|
|
895
|
+
};
|
|
896
|
+
}
|
|
897
|
+
const emailMatch = output.match(/email[:\s]+([^\s!]+)/i);
|
|
898
|
+
const accountMatch = output.match(/Account\s+ID[:\s]+([a-f0-9]+)/i);
|
|
899
|
+
return {
|
|
900
|
+
loggedIn: true,
|
|
901
|
+
email: emailMatch?.[1],
|
|
902
|
+
accountId: accountMatch?.[1]
|
|
903
|
+
};
|
|
904
|
+
} catch (error) {
|
|
905
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
906
|
+
if (msg.includes("ENOENT") || msg.includes("not found")) {
|
|
907
|
+
return {
|
|
908
|
+
loggedIn: false,
|
|
909
|
+
error: "Wrangler not installed. Run: npm install -g wrangler"
|
|
910
|
+
};
|
|
911
|
+
}
|
|
912
|
+
return {
|
|
913
|
+
loggedIn: false,
|
|
914
|
+
error: msg
|
|
915
|
+
};
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
async function checkRemoteBindingRequirements(config) {
|
|
919
|
+
const remoteBindings = detectRemoteBindings(config);
|
|
920
|
+
if (remoteBindings.length === 0) {
|
|
921
|
+
return {
|
|
922
|
+
hasRemoteBindings: false,
|
|
923
|
+
remoteBindings: [],
|
|
924
|
+
missingAccountId: false,
|
|
925
|
+
notLoggedIn: false
|
|
926
|
+
};
|
|
927
|
+
}
|
|
928
|
+
const missingAccountId = !config.accountId;
|
|
929
|
+
const authStatus = await checkWranglerAuth();
|
|
930
|
+
const notLoggedIn = !authStatus.loggedIn;
|
|
931
|
+
return {
|
|
932
|
+
hasRemoteBindings: true,
|
|
933
|
+
remoteBindings,
|
|
934
|
+
missingAccountId,
|
|
935
|
+
notLoggedIn
|
|
936
|
+
};
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
// src/dev-server/d1-migrations.ts
|
|
940
|
+
import { createHash } from "node:crypto";
|
|
941
|
+
import { resolve } from "pathe";
|
|
942
|
+
var MIGRATION_RETRY_DELAYS_MS = [500, 1000, 1500, 2000];
|
|
943
|
+
function collectMigrationStatements(sql) {
|
|
944
|
+
const cleanedSql = sql.split(`
|
|
945
|
+
`).filter((line) => !line.trim().startsWith("--")).join(`
|
|
946
|
+
`);
|
|
947
|
+
return cleanedSql.split(";").map((statement) => statement.trim()).filter((statement) => statement.length > 0);
|
|
948
|
+
}
|
|
949
|
+
function hashSql(sql) {
|
|
950
|
+
return createHash("sha256").update(sql).digest("hex");
|
|
951
|
+
}
|
|
952
|
+
function getErrorMessage(error) {
|
|
953
|
+
return error instanceof Error ? error.message : String(error);
|
|
954
|
+
}
|
|
955
|
+
async function waitForRetry(delayMs) {
|
|
956
|
+
await new Promise((resolvePromise) => setTimeout(resolvePromise, delayMs));
|
|
957
|
+
}
|
|
958
|
+
async function applyMigrationsToBinding(options) {
|
|
959
|
+
const { bindingName, statements, files, miniflarePort, logger } = options;
|
|
960
|
+
let lastError;
|
|
961
|
+
for (let attempt = 0;attempt <= MIGRATION_RETRY_DELAYS_MS.length; attempt++) {
|
|
962
|
+
if (attempt > 0) {
|
|
963
|
+
await waitForRetry(MIGRATION_RETRY_DELAYS_MS[attempt - 1]);
|
|
964
|
+
}
|
|
965
|
+
try {
|
|
966
|
+
const response = await fetch(`http://127.0.0.1:${miniflarePort}/_devflare/migrate`, {
|
|
967
|
+
method: "POST",
|
|
968
|
+
headers: { "Content-Type": "application/json" },
|
|
969
|
+
body: JSON.stringify({ bindingName, statements, files })
|
|
970
|
+
});
|
|
971
|
+
if (!response.ok) {
|
|
972
|
+
const text = await response.text();
|
|
973
|
+
throw new Error(`HTTP ${response.status}: ${text}`);
|
|
974
|
+
}
|
|
975
|
+
const result = await response.json();
|
|
976
|
+
if (result.success) {
|
|
977
|
+
if (Array.isArray(result.warnings)) {
|
|
978
|
+
for (const warning of result.warnings) {
|
|
979
|
+
console.warn(`[devflare] D1 migration file "${warning.filename}" for binding ${bindingName} has changed since it was applied; skipping re-apply to protect existing data.`);
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
const appliedCount = result.applied?.length ?? 0;
|
|
983
|
+
const skippedCount = result.skipped?.length ?? 0;
|
|
984
|
+
if (appliedCount > 0 || skippedCount > 0) {
|
|
985
|
+
logger?.success(`D1 migrations for ${bindingName}: ${appliedCount} applied, ${skippedCount} skipped`);
|
|
986
|
+
} else {
|
|
987
|
+
logger?.success(`D1 migrations applied to ${bindingName}`);
|
|
988
|
+
}
|
|
989
|
+
return;
|
|
990
|
+
}
|
|
991
|
+
throw new Error(result.error || "Unknown error");
|
|
992
|
+
} catch (error) {
|
|
993
|
+
lastError = error;
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
logger?.warn(`Failed to apply migrations to ${bindingName}: ${getErrorMessage(lastError)}`);
|
|
997
|
+
}
|
|
998
|
+
async function runD1Migrations(options) {
|
|
999
|
+
const { cwd, config, miniflarePort, logger } = options;
|
|
1000
|
+
if (!config?.bindings?.d1) {
|
|
1001
|
+
return;
|
|
1002
|
+
}
|
|
1003
|
+
const { existsSync: existsSync2, readdirSync, readFileSync, statSync } = await import("node:fs");
|
|
1004
|
+
const migrationsDir = resolve(cwd, "migrations");
|
|
1005
|
+
if (!existsSync2(migrationsDir)) {
|
|
1006
|
+
logger?.debug("No migrations/ directory found, skipping D1 migrations");
|
|
1007
|
+
return;
|
|
1008
|
+
}
|
|
1009
|
+
const sharedFiles = readdirSync(migrationsDir).filter((file) => file.endsWith(".sql")).sort();
|
|
1010
|
+
let sharedFileEntries = null;
|
|
1011
|
+
if (sharedFiles.length > 0) {
|
|
1012
|
+
sharedFileEntries = [];
|
|
1013
|
+
for (const file of sharedFiles) {
|
|
1014
|
+
const sql = readFileSync(resolve(migrationsDir, file), "utf-8");
|
|
1015
|
+
const fileStatements = collectMigrationStatements(sql);
|
|
1016
|
+
sharedFileEntries.push({
|
|
1017
|
+
filename: file,
|
|
1018
|
+
sha256: hashSql(sql),
|
|
1019
|
+
statements: fileStatements
|
|
1020
|
+
});
|
|
1021
|
+
logger?.debug(`Shared file ${file}: ${fileStatements.length} statement(s)`);
|
|
1022
|
+
}
|
|
1023
|
+
}
|
|
1024
|
+
for (const [bindingName] of Object.entries(config.bindings.d1)) {
|
|
1025
|
+
const perBindingDir = resolve(migrationsDir, bindingName);
|
|
1026
|
+
const hasPerBindingDir = existsSync2(perBindingDir) && statSync(perBindingDir).isDirectory();
|
|
1027
|
+
let files = [];
|
|
1028
|
+
let sourceLabel = "";
|
|
1029
|
+
if (hasPerBindingDir) {
|
|
1030
|
+
const perBindingFiles = readdirSync(perBindingDir).filter((file) => file.endsWith(".sql")).sort();
|
|
1031
|
+
if (perBindingFiles.length === 0) {
|
|
1032
|
+
logger?.debug(`No SQL migration files in migrations/${bindingName}/, skipping ${bindingName}`);
|
|
1033
|
+
continue;
|
|
1034
|
+
}
|
|
1035
|
+
for (const file of perBindingFiles) {
|
|
1036
|
+
const sql = readFileSync(resolve(perBindingDir, file), "utf-8");
|
|
1037
|
+
const fileStatements = collectMigrationStatements(sql);
|
|
1038
|
+
files.push({
|
|
1039
|
+
filename: file,
|
|
1040
|
+
sha256: hashSql(sql),
|
|
1041
|
+
statements: fileStatements
|
|
1042
|
+
});
|
|
1043
|
+
logger?.debug(`File ${bindingName}/${file}: ${fileStatements.length} statement(s)`);
|
|
1044
|
+
}
|
|
1045
|
+
sourceLabel = `migrations/${bindingName}/`;
|
|
1046
|
+
} else if (sharedFileEntries !== null) {
|
|
1047
|
+
files = sharedFileEntries;
|
|
1048
|
+
sourceLabel = "migrations/ [shared fallback]";
|
|
1049
|
+
} else {
|
|
1050
|
+
logger?.debug(`No migrations found for ${bindingName}, skipping`);
|
|
1051
|
+
continue;
|
|
1052
|
+
}
|
|
1053
|
+
const statements = files.flatMap((file) => file.statements);
|
|
1054
|
+
logger?.info(`Running ${files.length} D1 migration(s) for ${bindingName} (from ${sourceLabel})`);
|
|
1055
|
+
if (statements.length === 0) {
|
|
1056
|
+
logger?.debug(`No executable D1 migration statements for ${bindingName}`);
|
|
1057
|
+
continue;
|
|
1058
|
+
}
|
|
1059
|
+
await applyMigrationsToBinding({
|
|
1060
|
+
bindingName,
|
|
1061
|
+
statements,
|
|
1062
|
+
files,
|
|
1063
|
+
miniflarePort,
|
|
1064
|
+
logger
|
|
1065
|
+
});
|
|
1066
|
+
}
|
|
1067
|
+
}
|
|
1068
|
+
|
|
1069
|
+
// src/dev-server/gateway-script.ts
|
|
1070
|
+
function getGatewayScript(wsRoutes = [], debug = false, appServiceBindingName = null) {
|
|
1071
|
+
const wsRoutesJson = JSON.stringify(wsRoutes);
|
|
1072
|
+
const appServiceBindingJson = JSON.stringify(appServiceBindingName);
|
|
1073
|
+
return `
|
|
1074
|
+
${GATEWAY_RUNTIME_JS}
|
|
1075
|
+
|
|
1076
|
+
// Bridge Gateway Worker — Dev Server
|
|
1077
|
+
// Dev-server-specific overlay on top of the shared GATEWAY_RUNTIME_JS:
|
|
1078
|
+
// WS route DO forwarding, D1 migration, email ingest, app-worker fallthrough.
|
|
1079
|
+
|
|
1080
|
+
const DEBUG = ${debug}
|
|
1081
|
+
const log = (...args) => DEBUG && console.log('[Gateway]', ...args)
|
|
1082
|
+
|
|
1083
|
+
const WS_ROUTES = ${wsRoutesJson}
|
|
1084
|
+
const APP_SERVICE_BINDING = ${appServiceBindingJson}
|
|
1085
|
+
|
|
1086
|
+
export default {
|
|
1087
|
+
async fetch(request, env, ctx) {
|
|
1088
|
+
const url = new URL(request.url)
|
|
1089
|
+
const isWebSocket = request.headers.get('Upgrade') === 'websocket'
|
|
1090
|
+
|
|
1091
|
+
if (isWebSocket) {
|
|
1092
|
+
const matchedRoute = matchWsRoute(url.pathname)
|
|
1093
|
+
if (matchedRoute) {
|
|
1094
|
+
return handleDoWebSocket(request, env, url, matchedRoute)
|
|
1095
|
+
}
|
|
1096
|
+
return handleBridgeWebSocket(request, env, ctx)
|
|
1097
|
+
}
|
|
1098
|
+
|
|
1099
|
+
if (url.pathname.startsWith('/_devflare/transfer/')) {
|
|
1100
|
+
return handleHttpTransfer(request, env, url)
|
|
1101
|
+
}
|
|
1102
|
+
|
|
1103
|
+
if (url.pathname === '/_devflare/migrate' && request.method === 'POST') {
|
|
1104
|
+
return handleMigration(request, env)
|
|
1105
|
+
}
|
|
1106
|
+
|
|
1107
|
+
if (url.pathname === '/cdn-cgi/handler/email' && request.method === 'POST') {
|
|
1108
|
+
return handleEmailIncoming(request, env, ctx, url)
|
|
1109
|
+
}
|
|
1110
|
+
|
|
1111
|
+
if (url.pathname === '/_devflare/health') {
|
|
1112
|
+
return new Response(JSON.stringify({
|
|
1113
|
+
ok: true,
|
|
1114
|
+
bindings: Object.keys(env),
|
|
1115
|
+
wsRoutes: WS_ROUTES
|
|
1116
|
+
}), { headers: { 'Content-Type': 'application/json' } })
|
|
1117
|
+
}
|
|
1118
|
+
|
|
1119
|
+
if (APP_SERVICE_BINDING) {
|
|
1120
|
+
const appWorker = env[APP_SERVICE_BINDING]
|
|
1121
|
+
if (appWorker && typeof appWorker.fetch === 'function') {
|
|
1122
|
+
return appWorker.fetch(request)
|
|
1123
|
+
}
|
|
1124
|
+
}
|
|
1125
|
+
|
|
1126
|
+
return new Response('Devflare Bridge Gateway', { status: 200 })
|
|
1127
|
+
}
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1130
|
+
async function handleMigration(request, env) {
|
|
1131
|
+
try {
|
|
1132
|
+
const { bindingName, statements, files } = await request.json()
|
|
1133
|
+
log('Migration request for binding:', bindingName, 'statements count:', statements?.length, 'files:', files?.length, 'bindings:', Object.keys(env))
|
|
1134
|
+
const db = env[bindingName]
|
|
1135
|
+
if (!db) {
|
|
1136
|
+
return Response.json({ error: 'Binding not found: ' + bindingName }, { status: 404 })
|
|
1137
|
+
}
|
|
1138
|
+
|
|
1139
|
+
// Ledger-aware path: when the client sends per-file metadata, we track
|
|
1140
|
+
// applied migrations in a \`_devflare_migrations\` table and skip files
|
|
1141
|
+
// whose filename+sha256 is already recorded. Files with a drifting hash
|
|
1142
|
+
// are reported as warnings and skipped — we refuse to re-apply to avoid
|
|
1143
|
+
// stomping on user data.
|
|
1144
|
+
if (Array.isArray(files) && files.length > 0) {
|
|
1145
|
+
try {
|
|
1146
|
+
await db.prepare(
|
|
1147
|
+
'CREATE TABLE IF NOT EXISTS _devflare_migrations (filename TEXT PRIMARY KEY, applied_at TEXT NOT NULL, sha256 TEXT NOT NULL)'
|
|
1148
|
+
).run()
|
|
1149
|
+
} catch (error) {
|
|
1150
|
+
const msg = error?.message || String(error)
|
|
1151
|
+
log('Failed to ensure migration ledger:', msg)
|
|
1152
|
+
return Response.json({ error: 'Failed to ensure migration ledger: ' + msg }, { status: 500 })
|
|
1153
|
+
}
|
|
1154
|
+
|
|
1155
|
+
let ledgerRows = []
|
|
1156
|
+
try {
|
|
1157
|
+
const ledger = await db.prepare('SELECT filename, sha256 FROM _devflare_migrations').all()
|
|
1158
|
+
ledgerRows = ledger?.results || []
|
|
1159
|
+
} catch (error) {
|
|
1160
|
+
log('Failed to read migration ledger:', error?.message || String(error))
|
|
1161
|
+
}
|
|
1162
|
+
const ledgerByFilename = new Map()
|
|
1163
|
+
for (const row of ledgerRows) {
|
|
1164
|
+
ledgerByFilename.set(row.filename, row.sha256)
|
|
1165
|
+
}
|
|
1166
|
+
|
|
1167
|
+
const applied = []
|
|
1168
|
+
const skipped = []
|
|
1169
|
+
const warnings = []
|
|
1170
|
+
const results = []
|
|
1171
|
+
|
|
1172
|
+
for (const file of files) {
|
|
1173
|
+
const existingHash = ledgerByFilename.get(file.filename)
|
|
1174
|
+
if (existingHash === file.sha256) {
|
|
1175
|
+
skipped.push(file.filename)
|
|
1176
|
+
continue
|
|
1177
|
+
}
|
|
1178
|
+
if (existingHash && existingHash !== file.sha256) {
|
|
1179
|
+
warnings.push({
|
|
1180
|
+
filename: file.filename,
|
|
1181
|
+
message: 'sha256 drifted since last apply; skipped'
|
|
1182
|
+
})
|
|
1183
|
+
skipped.push(file.filename)
|
|
1184
|
+
continue
|
|
1185
|
+
}
|
|
1186
|
+
|
|
1187
|
+
let fileFailed = false
|
|
1188
|
+
for (const sql of file.statements || []) {
|
|
1189
|
+
try {
|
|
1190
|
+
log('Running migration SQL:', sql.slice(0, 80))
|
|
1191
|
+
await db.prepare(sql).run()
|
|
1192
|
+
results.push({ sql: sql.slice(0, 50), success: true })
|
|
1193
|
+
} catch (error) {
|
|
1194
|
+
const msg = error?.message || String(error)
|
|
1195
|
+
log('Migration SQL error:', msg)
|
|
1196
|
+
if (msg.includes('already exists')) {
|
|
1197
|
+
results.push({ sql: sql.slice(0, 50), success: true, skipped: true })
|
|
1198
|
+
} else {
|
|
1199
|
+
results.push({ sql: sql.slice(0, 50), success: false, error: msg })
|
|
1200
|
+
fileFailed = true
|
|
1201
|
+
}
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1204
|
+
|
|
1205
|
+
if (!fileFailed) {
|
|
1206
|
+
try {
|
|
1207
|
+
await db.prepare(
|
|
1208
|
+
'INSERT OR REPLACE INTO _devflare_migrations (filename, applied_at, sha256) VALUES (?, ?, ?)'
|
|
1209
|
+
).bind(file.filename, new Date().toISOString(), file.sha256).run()
|
|
1210
|
+
applied.push(file.filename)
|
|
1211
|
+
} catch (error) {
|
|
1212
|
+
log('Failed to record migration in ledger:', error?.message || String(error))
|
|
1213
|
+
}
|
|
1214
|
+
}
|
|
1215
|
+
}
|
|
1216
|
+
|
|
1217
|
+
return Response.json({ success: true, results, applied, skipped, warnings })
|
|
1218
|
+
}
|
|
1219
|
+
|
|
1220
|
+
// Legacy path: flat statement list, no ledger tracking.
|
|
1221
|
+
const results = []
|
|
1222
|
+
for (const sql of statements) {
|
|
1223
|
+
try {
|
|
1224
|
+
log('Running migration SQL:', sql.slice(0, 80))
|
|
1225
|
+
await db.prepare(sql).run()
|
|
1226
|
+
results.push({ sql: sql.slice(0, 50), success: true })
|
|
1227
|
+
log('Migration SQL succeeded')
|
|
1228
|
+
} catch (error) {
|
|
1229
|
+
const msg = error?.message || String(error)
|
|
1230
|
+
log('Migration SQL error:', msg)
|
|
1231
|
+
if (msg.includes('already exists')) {
|
|
1232
|
+
results.push({ sql: sql.slice(0, 50), success: true, skipped: true })
|
|
1233
|
+
} else {
|
|
1234
|
+
results.push({ sql: sql.slice(0, 50), success: false, error: msg })
|
|
1235
|
+
}
|
|
1236
|
+
}
|
|
1237
|
+
}
|
|
1238
|
+
|
|
1239
|
+
try {
|
|
1240
|
+
const tables = await db.prepare("SELECT name FROM sqlite_master WHERE type='table'").all()
|
|
1241
|
+
log('Tables after migration:', JSON.stringify(tables))
|
|
1242
|
+
} catch (e) {
|
|
1243
|
+
log('Error listing tables:', e.message)
|
|
1244
|
+
}
|
|
1245
|
+
|
|
1246
|
+
return Response.json({ success: true, results })
|
|
1247
|
+
} catch (error) {
|
|
1248
|
+
return Response.json({ error: error?.message || String(error) }, { status: 500 })
|
|
1249
|
+
}
|
|
1250
|
+
}
|
|
1251
|
+
|
|
1252
|
+
async function handleEmailIncoming(request, env, ctx, url) {
|
|
1253
|
+
try {
|
|
1254
|
+
const from = url.searchParams.get('from') || 'unknown@example.com'
|
|
1255
|
+
const to = url.searchParams.get('to') || 'worker@example.com'
|
|
1256
|
+
const rawBody = await request.text()
|
|
1257
|
+
|
|
1258
|
+
log('Email incoming:', { from, to, bodyLength: rawBody.length })
|
|
1259
|
+
|
|
1260
|
+
if (APP_SERVICE_BINDING) {
|
|
1261
|
+
const appWorker = env[APP_SERVICE_BINDING]
|
|
1262
|
+
if (appWorker && typeof appWorker.fetch === 'function') {
|
|
1263
|
+
const response = await appWorker.fetch(new Request('http://devflare.internal/_devflare/internal/email', {
|
|
1264
|
+
method: 'POST',
|
|
1265
|
+
headers: {
|
|
1266
|
+
'x-devflare-event': 'email',
|
|
1267
|
+
'x-devflare-email-from': from,
|
|
1268
|
+
'x-devflare-email-to': to,
|
|
1269
|
+
'content-type': request.headers.get('content-type') || 'text/plain'
|
|
1270
|
+
},
|
|
1271
|
+
body: rawBody
|
|
1272
|
+
}))
|
|
1273
|
+
|
|
1274
|
+
if (!response.ok) {
|
|
1275
|
+
return response
|
|
1276
|
+
}
|
|
1277
|
+
}
|
|
1278
|
+
}
|
|
1279
|
+
|
|
1280
|
+
return new Response(JSON.stringify({ ok: true, from, to }), {
|
|
1281
|
+
headers: { 'Content-Type': 'application/json' }
|
|
1282
|
+
})
|
|
1283
|
+
} catch (error) {
|
|
1284
|
+
console.error('[Gateway] Email handler error:', error)
|
|
1285
|
+
return Response.json({ error: error?.message || String(error) }, { status: 500 })
|
|
1286
|
+
}
|
|
1287
|
+
}
|
|
1288
|
+
|
|
1289
|
+
function matchWsRoute(pathname) {
|
|
1290
|
+
for (const route of WS_ROUTES) {
|
|
1291
|
+
if (pathname === route.pattern || pathname.startsWith(route.pattern + '?')) {
|
|
1292
|
+
return route
|
|
1293
|
+
}
|
|
1294
|
+
}
|
|
1295
|
+
return null
|
|
1296
|
+
}
|
|
1297
|
+
|
|
1298
|
+
async function handleDoWebSocket(request, env, url, route) {
|
|
1299
|
+
try {
|
|
1300
|
+
const namespace = env[route.doNamespace]
|
|
1301
|
+
if (!namespace) {
|
|
1302
|
+
console.error('[Gateway] DO namespace not found:', route.doNamespace)
|
|
1303
|
+
return new Response('DO namespace not found: ' + route.doNamespace, { status: 500 })
|
|
1304
|
+
}
|
|
1305
|
+
|
|
1306
|
+
const idValue = url.searchParams.get(route.idParam) || 'default'
|
|
1307
|
+
const doId = namespace.idFromName(idValue)
|
|
1308
|
+
const stub = namespace.get(doId)
|
|
1309
|
+
|
|
1310
|
+
const forwardUrl = new URL(route.forwardPath, url.origin)
|
|
1311
|
+
url.searchParams.forEach((v, k) => forwardUrl.searchParams.set(k, v))
|
|
1312
|
+
|
|
1313
|
+
log('Forwarding WebSocket to DO:', route.doNamespace, 'id:', idValue, 'path:', forwardUrl.pathname)
|
|
1314
|
+
|
|
1315
|
+
return stub.fetch(forwardUrl.toString(), {
|
|
1316
|
+
method: request.method,
|
|
1317
|
+
headers: request.headers
|
|
1318
|
+
})
|
|
1319
|
+
} catch (error) {
|
|
1320
|
+
console.error('[Gateway] Error forwarding to DO:', error)
|
|
1321
|
+
return new Response('Error forwarding to DO: ' + error.message, { status: 500 })
|
|
1322
|
+
}
|
|
1323
|
+
}
|
|
1324
|
+
`;
|
|
1325
|
+
}
|
|
1326
|
+
|
|
1327
|
+
// src/dev-server/miniflare-log.ts
|
|
1328
|
+
var ANSI_ESCAPE_REGEX = /\u001B\[[0-9;]*m/g;
|
|
1329
|
+
var COMPATIBILITY_DATE_FALLBACK_REGEX = /^The latest compatibility date supported by the installed Cloudflare Workers Runtime is "([^"]+)", but you've requested "([^"]+)"\. Falling back to "([^"]+)"\.\.\.$/;
|
|
1330
|
+
function normalizeMiniflareMessage(message) {
|
|
1331
|
+
return message.replace(ANSI_ESCAPE_REGEX, "").replace(/\s+/g, " ").trim();
|
|
1332
|
+
}
|
|
1333
|
+
function formatCompatibilityDateFallbackNotice(message) {
|
|
1334
|
+
const normalizedMessage = normalizeMiniflareMessage(message);
|
|
1335
|
+
const match = COMPATIBILITY_DATE_FALLBACK_REGEX.exec(normalizedMessage);
|
|
1336
|
+
if (!match) {
|
|
1337
|
+
return null;
|
|
1338
|
+
}
|
|
1339
|
+
const [, _supportedDate, requestedDate, fallbackDate] = match;
|
|
1340
|
+
return `Using latest supported Cloudflare Workers Runtime compatibility date ${fallbackDate} (requested ${requestedDate})`;
|
|
1341
|
+
}
|
|
1342
|
+
function createCompatibilityAwareMiniflareLog(BaseLog, level, logger) {
|
|
1343
|
+
const log = new BaseLog(level);
|
|
1344
|
+
const originalWarn = log.warn.bind(log);
|
|
1345
|
+
const originalInfo = log.info.bind(log);
|
|
1346
|
+
log.warn = (message) => {
|
|
1347
|
+
const notice = formatCompatibilityDateFallbackNotice(message);
|
|
1348
|
+
if (!notice) {
|
|
1349
|
+
originalWarn(message);
|
|
1350
|
+
return;
|
|
1351
|
+
}
|
|
1352
|
+
if (logger) {
|
|
1353
|
+
logger.info(notice);
|
|
1354
|
+
return;
|
|
1355
|
+
}
|
|
1356
|
+
originalInfo(notice);
|
|
1357
|
+
};
|
|
1358
|
+
return log;
|
|
1359
|
+
}
|
|
1360
|
+
|
|
1361
|
+
// src/dev-server/runtime-stdio.ts
|
|
1362
|
+
import { createInterface } from "node:readline";
|
|
1363
|
+
function writeStdout(logger, message) {
|
|
1364
|
+
if (typeof logger?.log === "function") {
|
|
1365
|
+
logger.log(message);
|
|
1366
|
+
return;
|
|
1367
|
+
}
|
|
1368
|
+
if (typeof logger?.info === "function") {
|
|
1369
|
+
logger.info(message);
|
|
1370
|
+
return;
|
|
1371
|
+
}
|
|
1372
|
+
console.log(message);
|
|
1373
|
+
}
|
|
1374
|
+
function writeStderr(logger, message) {
|
|
1375
|
+
if (typeof logger?.error === "function") {
|
|
1376
|
+
logger.error(message);
|
|
1377
|
+
return;
|
|
1378
|
+
}
|
|
1379
|
+
console.error(message);
|
|
1380
|
+
}
|
|
1381
|
+
function createRuntimeStdioForwarder(logger) {
|
|
1382
|
+
return (stdout, stderr) => {
|
|
1383
|
+
createInterface({ input: stdout }).on("line", (data) => {
|
|
1384
|
+
writeStdout(logger, data);
|
|
1385
|
+
});
|
|
1386
|
+
createInterface({ input: stderr }).on("line", (data) => {
|
|
1387
|
+
writeStderr(logger, data);
|
|
1388
|
+
});
|
|
1389
|
+
};
|
|
1390
|
+
}
|
|
1391
|
+
|
|
1392
|
+
// src/dev-server/vite-process.ts
|
|
1393
|
+
import { spawn } from "node:child_process";
|
|
1394
|
+
async function startViteProcess(options) {
|
|
1395
|
+
const {
|
|
1396
|
+
cwd,
|
|
1397
|
+
vitePort,
|
|
1398
|
+
miniflarePort,
|
|
1399
|
+
generatedViteConfigPath,
|
|
1400
|
+
logger
|
|
1401
|
+
} = options;
|
|
1402
|
+
const args = ["vite", "dev", "--port", String(vitePort)];
|
|
1403
|
+
if (generatedViteConfigPath) {
|
|
1404
|
+
args.push("--config", generatedViteConfigPath);
|
|
1405
|
+
}
|
|
1406
|
+
const viteProcess = spawn("bunx", args, {
|
|
1407
|
+
cwd,
|
|
1408
|
+
stdio: ["inherit", "pipe", "pipe"],
|
|
1409
|
+
windowsHide: true,
|
|
1410
|
+
env: {
|
|
1411
|
+
...process.env,
|
|
1412
|
+
DEVFLARE_DEV: "true",
|
|
1413
|
+
DEVFLARE_BRIDGE_PORT: String(miniflarePort),
|
|
1414
|
+
FORCE_COLOR: "1"
|
|
1415
|
+
}
|
|
1416
|
+
});
|
|
1417
|
+
const readyUrl = await waitForViteReady(viteProcess, {
|
|
1418
|
+
onStdout(chunk) {
|
|
1419
|
+
process.stdout.write(chunk);
|
|
1420
|
+
},
|
|
1421
|
+
onStderr(chunk) {
|
|
1422
|
+
process.stderr.write(chunk);
|
|
1423
|
+
}
|
|
1424
|
+
});
|
|
1425
|
+
if (readyUrl) {
|
|
1426
|
+
logger?.success(`Vite dev server started on ${readyUrl}`);
|
|
1427
|
+
return viteProcess;
|
|
1428
|
+
}
|
|
1429
|
+
logger?.warn("Vite process started, but the final local URL could not be confirmed yet");
|
|
1430
|
+
return viteProcess;
|
|
1431
|
+
}
|
|
1432
|
+
|
|
1433
|
+
// src/dev-server/reload-queue.ts
|
|
1434
|
+
function createReloadQueue({ reload, logger }) {
|
|
1435
|
+
let running = null;
|
|
1436
|
+
let pending = null;
|
|
1437
|
+
async function runOnce() {
|
|
1438
|
+
try {
|
|
1439
|
+
await reload();
|
|
1440
|
+
} catch (error) {
|
|
1441
|
+
logger?.error("[devflare dev] reload failed:", error);
|
|
1442
|
+
}
|
|
1443
|
+
}
|
|
1444
|
+
function schedule() {
|
|
1445
|
+
if (!running) {
|
|
1446
|
+
running = runOnce().finally(() => {
|
|
1447
|
+
running = null;
|
|
1448
|
+
});
|
|
1449
|
+
return running;
|
|
1450
|
+
}
|
|
1451
|
+
if (!pending) {
|
|
1452
|
+
const runningSnapshot = running;
|
|
1453
|
+
pending = runningSnapshot.then(() => {
|
|
1454
|
+
pending = null;
|
|
1455
|
+
running = runOnce().finally(() => {
|
|
1456
|
+
running = null;
|
|
1457
|
+
});
|
|
1458
|
+
return running;
|
|
1459
|
+
});
|
|
1460
|
+
}
|
|
1461
|
+
return pending;
|
|
1462
|
+
}
|
|
1463
|
+
async function drain() {
|
|
1464
|
+
while (running || pending) {
|
|
1465
|
+
if (pending) {
|
|
1466
|
+
await pending;
|
|
1467
|
+
} else if (running) {
|
|
1468
|
+
await running;
|
|
1469
|
+
}
|
|
1470
|
+
}
|
|
1471
|
+
}
|
|
1472
|
+
return { schedule, drain };
|
|
1473
|
+
}
|
|
1474
|
+
|
|
1475
|
+
// src/dev-server/worker-surface-paths.ts
|
|
1476
|
+
import { dirname, resolve as resolve2 } from "pathe";
|
|
1477
|
+
var DEFAULT_TRANSPORT_ENTRY_FILES = [
|
|
1478
|
+
"src/transport.ts",
|
|
1479
|
+
"src/transport.js",
|
|
1480
|
+
"src/transport.mts",
|
|
1481
|
+
"src/transport.mjs"
|
|
1482
|
+
];
|
|
1483
|
+
var resolveMainWorkerSurfacePaths = resolveWorkerSurfacePaths;
|
|
1484
|
+
function addWorkerWatchRoots(roots, cwd, configuredPath, defaultEntries) {
|
|
1485
|
+
if (configuredPath === false || configuredPath === null) {
|
|
1486
|
+
return;
|
|
1487
|
+
}
|
|
1488
|
+
if (typeof configuredPath === "string" && configuredPath) {
|
|
1489
|
+
roots.add(dirname(resolve2(cwd, configuredPath)));
|
|
1490
|
+
return;
|
|
1491
|
+
}
|
|
1492
|
+
for (const defaultEntry of defaultEntries) {
|
|
1493
|
+
roots.add(dirname(resolve2(cwd, defaultEntry)));
|
|
1494
|
+
}
|
|
1495
|
+
}
|
|
1496
|
+
function collectWorkerWatchRoots(cwd, config, mainWorkerSurfacePaths) {
|
|
1497
|
+
const roots = new Set;
|
|
1498
|
+
for (const surfacePath of Object.values(mainWorkerSurfacePaths)) {
|
|
1499
|
+
if (surfacePath) {
|
|
1500
|
+
roots.add(dirname(surfacePath));
|
|
1501
|
+
}
|
|
1502
|
+
}
|
|
1503
|
+
addWorkerWatchRoots(roots, cwd, config.files?.fetch, DEFAULT_FETCH_ENTRY_FILES);
|
|
1504
|
+
addWorkerWatchRoots(roots, cwd, config.files?.queue, DEFAULT_QUEUE_ENTRY_FILES);
|
|
1505
|
+
addWorkerWatchRoots(roots, cwd, config.files?.scheduled, DEFAULT_SCHEDULED_ENTRY_FILES);
|
|
1506
|
+
addWorkerWatchRoots(roots, cwd, config.files?.email, DEFAULT_EMAIL_ENTRY_FILES);
|
|
1507
|
+
addWorkerWatchRoots(roots, cwd, config.files?.transport, DEFAULT_TRANSPORT_ENTRY_FILES);
|
|
1508
|
+
const routeDirectory = getRouteDirectoryCandidate(cwd, config);
|
|
1509
|
+
if (routeDirectory) {
|
|
1510
|
+
roots.add(routeDirectory.absoluteDir);
|
|
1511
|
+
}
|
|
1512
|
+
return [...roots];
|
|
1513
|
+
}
|
|
1514
|
+
|
|
1515
|
+
// src/dev-server/worker-source-watcher.ts
|
|
1516
|
+
async function startWorkerSourceWatcher(options) {
|
|
1517
|
+
const { watchTargets, resolvedWorkerConfigPath, logger, onConfigChange, onWorkerChange } = options;
|
|
1518
|
+
if (watchTargets.length === 0) {
|
|
1519
|
+
return null;
|
|
1520
|
+
}
|
|
1521
|
+
const chokidar = await import("chokidar");
|
|
1522
|
+
const isWindows = process.platform === "win32";
|
|
1523
|
+
const ignoredSegments = ["/node_modules/", "/.git/", "/.devflare/", "/dist/"];
|
|
1524
|
+
const normalizePath = (filePath) => filePath.replace(/\\/g, "/");
|
|
1525
|
+
const isIgnoredPath = (filePath) => {
|
|
1526
|
+
const normalizedPath = normalizePath(filePath);
|
|
1527
|
+
return ignoredSegments.some((segment) => normalizedPath.includes(segment));
|
|
1528
|
+
};
|
|
1529
|
+
let reloadTimeout = null;
|
|
1530
|
+
let reloadInProgress = false;
|
|
1531
|
+
let pendingReloadPath = null;
|
|
1532
|
+
const flushPendingReload = async () => {
|
|
1533
|
+
if (!pendingReloadPath) {
|
|
1534
|
+
return;
|
|
1535
|
+
}
|
|
1536
|
+
const nextPath = pendingReloadPath;
|
|
1537
|
+
pendingReloadPath = null;
|
|
1538
|
+
await triggerReload(nextPath);
|
|
1539
|
+
};
|
|
1540
|
+
const triggerReload = async (filePath) => {
|
|
1541
|
+
if (reloadInProgress) {
|
|
1542
|
+
pendingReloadPath = filePath;
|
|
1543
|
+
return;
|
|
1544
|
+
}
|
|
1545
|
+
reloadInProgress = true;
|
|
1546
|
+
try {
|
|
1547
|
+
const normalizedConfigPath = resolvedWorkerConfigPath ? normalizePath(resolvedWorkerConfigPath) : null;
|
|
1548
|
+
if (normalizedConfigPath && normalizePath(filePath) === normalizedConfigPath) {
|
|
1549
|
+
logger?.info(`Devflare config changed: ${filePath}`);
|
|
1550
|
+
await onConfigChange();
|
|
1551
|
+
return;
|
|
1552
|
+
}
|
|
1553
|
+
logger?.info(`Worker source changed: ${filePath}`);
|
|
1554
|
+
await onWorkerChange();
|
|
1555
|
+
} catch (error) {
|
|
1556
|
+
logger?.error("Worker source reload failed:", error);
|
|
1557
|
+
} finally {
|
|
1558
|
+
reloadInProgress = false;
|
|
1559
|
+
await flushPendingReload();
|
|
1560
|
+
}
|
|
1561
|
+
};
|
|
1562
|
+
const scheduleReload = (filePath) => {
|
|
1563
|
+
if (reloadTimeout) {
|
|
1564
|
+
clearTimeout(reloadTimeout);
|
|
1565
|
+
}
|
|
1566
|
+
reloadTimeout = setTimeout(() => {
|
|
1567
|
+
reloadTimeout = null;
|
|
1568
|
+
triggerReload(filePath);
|
|
1569
|
+
}, 150);
|
|
1570
|
+
};
|
|
1571
|
+
const watcher = chokidar.watch(watchTargets, {
|
|
1572
|
+
ignoreInitial: true,
|
|
1573
|
+
usePolling: isWindows,
|
|
1574
|
+
interval: isWindows ? 300 : undefined,
|
|
1575
|
+
awaitWriteFinish: {
|
|
1576
|
+
stabilityThreshold: 100,
|
|
1577
|
+
pollInterval: 50
|
|
1578
|
+
},
|
|
1579
|
+
ignored: (filePath) => isIgnoredPath(filePath)
|
|
1580
|
+
});
|
|
1581
|
+
const onFileEvent = (filePath) => {
|
|
1582
|
+
if (isIgnoredPath(filePath)) {
|
|
1583
|
+
return;
|
|
1584
|
+
}
|
|
1585
|
+
scheduleReload(filePath);
|
|
1586
|
+
};
|
|
1587
|
+
watcher.on("change", onFileEvent);
|
|
1588
|
+
watcher.on("add", onFileEvent);
|
|
1589
|
+
watcher.on("unlink", onFileEvent);
|
|
1590
|
+
watcher.on("error", (error) => {
|
|
1591
|
+
logger?.error("Worker source watcher error:", error);
|
|
1592
|
+
});
|
|
1593
|
+
await new Promise((resolvePromise, rejectPromise) => {
|
|
1594
|
+
const handleReady = () => {
|
|
1595
|
+
watcher.off("error", handleInitialError);
|
|
1596
|
+
logger?.info(`Worker source watcher ready (${watchTargets.length} target(s))`);
|
|
1597
|
+
resolvePromise();
|
|
1598
|
+
};
|
|
1599
|
+
const handleInitialError = (error) => {
|
|
1600
|
+
watcher.off("ready", handleReady);
|
|
1601
|
+
rejectPromise(error instanceof Error ? error : new Error(String(error)));
|
|
1602
|
+
};
|
|
1603
|
+
watcher.once("ready", handleReady);
|
|
1604
|
+
watcher.once("error", handleInitialError);
|
|
1605
|
+
});
|
|
1606
|
+
return watcher;
|
|
1607
|
+
}
|
|
1608
|
+
|
|
1609
|
+
// src/dev-server/server.ts
|
|
1610
|
+
var INTERNAL_APP_SERVICE_BINDING = "__DEVFLARE_APP";
|
|
1611
|
+
function formatErrorMessage(error) {
|
|
1612
|
+
return error instanceof Error ? error.message : String(error);
|
|
1613
|
+
}
|
|
1614
|
+
function createDevServer(options) {
|
|
1615
|
+
const {
|
|
1616
|
+
cwd,
|
|
1617
|
+
configPath,
|
|
1618
|
+
vitePort = 5173,
|
|
1619
|
+
miniflarePort = 8787,
|
|
1620
|
+
enableVite: enableViteRequested = true,
|
|
1621
|
+
persist = true,
|
|
1622
|
+
logger,
|
|
1623
|
+
verbose = false,
|
|
1624
|
+
debug = process.env.DEVFLARE_DEBUG === "true"
|
|
1625
|
+
} = options;
|
|
1626
|
+
let enableVite = enableViteRequested;
|
|
1627
|
+
let miniflare = null;
|
|
1628
|
+
let doBundler = null;
|
|
1629
|
+
let workerSourceWatcher = null;
|
|
1630
|
+
let workerWatchTargets = [];
|
|
1631
|
+
let viteProcess = null;
|
|
1632
|
+
let config = null;
|
|
1633
|
+
let browserShim = null;
|
|
1634
|
+
let browserShimPort = 8788;
|
|
1635
|
+
let mainWorkerSurfacePaths = {
|
|
1636
|
+
fetch: null,
|
|
1637
|
+
queue: null,
|
|
1638
|
+
scheduled: null,
|
|
1639
|
+
email: null
|
|
1640
|
+
};
|
|
1641
|
+
let resolvedWorkerConfigPath = null;
|
|
1642
|
+
let mainWorkerScriptPath = null;
|
|
1643
|
+
let bundledMainWorkerScriptPath = null;
|
|
1644
|
+
let currentDoResult = null;
|
|
1645
|
+
let mainWorkerRoutes = null;
|
|
1646
|
+
let generatedViteConfigPath = null;
|
|
1647
|
+
const reloadQueue = createReloadQueue({
|
|
1648
|
+
reload: async () => {
|
|
1649
|
+
if (!miniflare)
|
|
1650
|
+
return;
|
|
1651
|
+
const { Log, LogLevel } = await import("miniflare");
|
|
1652
|
+
const mfConfig = buildMiniflareConfig(currentDoResult);
|
|
1653
|
+
mfConfig.log = createCompatibilityAwareMiniflareLog(Log, LogLevel.DEBUG, logger);
|
|
1654
|
+
mfConfig.handleRuntimeStdio = createRuntimeStdioForwarder(logger);
|
|
1655
|
+
logger?.info("Reloading Miniflare...");
|
|
1656
|
+
await miniflare.setOptions(mfConfig);
|
|
1657
|
+
logger?.success("Miniflare reloaded");
|
|
1658
|
+
},
|
|
1659
|
+
logger
|
|
1660
|
+
});
|
|
1661
|
+
async function bundleMainWorker() {
|
|
1662
|
+
if (!mainWorkerScriptPath || !config) {
|
|
1663
|
+
bundledMainWorkerScriptPath = null;
|
|
1664
|
+
return;
|
|
1665
|
+
}
|
|
1666
|
+
bundledMainWorkerScriptPath = await bundleWorkerEntry({
|
|
1667
|
+
cwd,
|
|
1668
|
+
inputFile: mainWorkerScriptPath,
|
|
1669
|
+
outFile: resolve3(cwd, ".devflare", "worker-entrypoints", "main.js"),
|
|
1670
|
+
rolldownOptions: config.rolldown?.options,
|
|
1671
|
+
sourcemap: config.rolldown?.sourcemap,
|
|
1672
|
+
minify: config.rolldown?.minify,
|
|
1673
|
+
logger
|
|
1674
|
+
});
|
|
1675
|
+
logger?.debug(`Bundled main worker → ${bundledMainWorkerScriptPath}`);
|
|
1676
|
+
}
|
|
1677
|
+
function buildMiniflareConfig(doResult) {
|
|
1678
|
+
if (!config)
|
|
1679
|
+
throw new Error("Config not loaded");
|
|
1680
|
+
const loadedConfig = config;
|
|
1681
|
+
const bindings = loadedConfig.bindings ?? {};
|
|
1682
|
+
const persistPath = resolve3(cwd, ".devflare/data");
|
|
1683
|
+
const appWorkerName = loadedConfig.name;
|
|
1684
|
+
const shouldRunMainWorker = !enableVite && (hasWorkerSurfacePaths(mainWorkerSurfacePaths) || Boolean(mainWorkerRoutes?.routes.length));
|
|
1685
|
+
const queueProducers = (() => {
|
|
1686
|
+
if (!bindings.queues?.producers) {
|
|
1687
|
+
return;
|
|
1688
|
+
}
|
|
1689
|
+
const producers = {};
|
|
1690
|
+
for (const [bindingName, queueName] of Object.entries(bindings.queues.producers)) {
|
|
1691
|
+
producers[bindingName] = { queueName };
|
|
1692
|
+
}
|
|
1693
|
+
return producers;
|
|
1694
|
+
})();
|
|
1695
|
+
const queueConsumers = (() => {
|
|
1696
|
+
if (!bindings.queues?.consumers || bindings.queues.consumers.length === 0) {
|
|
1697
|
+
return;
|
|
1698
|
+
}
|
|
1699
|
+
const consumers = {};
|
|
1700
|
+
for (const consumer of bindings.queues.consumers) {
|
|
1701
|
+
consumers[consumer.queue] = {
|
|
1702
|
+
...consumer.maxBatchSize !== undefined && { maxBatchSize: consumer.maxBatchSize },
|
|
1703
|
+
...consumer.maxBatchTimeout !== undefined && { maxBatchTimeout: consumer.maxBatchTimeout },
|
|
1704
|
+
...consumer.maxRetries !== undefined && { maxRetries: consumer.maxRetries },
|
|
1705
|
+
...consumer.deadLetterQueue && { deadLetterQueue: consumer.deadLetterQueue },
|
|
1706
|
+
...consumer.maxConcurrency !== undefined && { maxConcurrency: consumer.maxConcurrency },
|
|
1707
|
+
...consumer.retryDelay !== undefined && { retryDelay: consumer.retryDelay }
|
|
1708
|
+
};
|
|
1709
|
+
}
|
|
1710
|
+
return consumers;
|
|
1711
|
+
})();
|
|
1712
|
+
const sharedOptions = {
|
|
1713
|
+
port: miniflarePort,
|
|
1714
|
+
host: "127.0.0.1",
|
|
1715
|
+
kvPersist: persist ? `${persistPath}/kv` : undefined,
|
|
1716
|
+
r2Persist: persist ? `${persistPath}/r2` : undefined,
|
|
1717
|
+
d1Persist: persist ? `${persistPath}/d1` : undefined,
|
|
1718
|
+
durableObjectsPersist: persist ? `${persistPath}/do` : undefined
|
|
1719
|
+
};
|
|
1720
|
+
const createServiceBindings = (extraBindings = {}) => {
|
|
1721
|
+
const serviceBindings = {};
|
|
1722
|
+
if (bindings.services) {
|
|
1723
|
+
for (const [bindingName, serviceConfig] of Object.entries(bindings.services)) {
|
|
1724
|
+
serviceBindings[bindingName] = {
|
|
1725
|
+
name: serviceConfig.service,
|
|
1726
|
+
...serviceConfig.entrypoint && { entrypoint: serviceConfig.entrypoint }
|
|
1727
|
+
};
|
|
1728
|
+
}
|
|
1729
|
+
}
|
|
1730
|
+
for (const [bindingName, target] of Object.entries(extraBindings)) {
|
|
1731
|
+
serviceBindings[bindingName] = target;
|
|
1732
|
+
}
|
|
1733
|
+
return Object.keys(serviceBindings).length > 0 ? serviceBindings : undefined;
|
|
1734
|
+
};
|
|
1735
|
+
const sendEmailConfig = bindings.sendEmail ? {
|
|
1736
|
+
send_email: Object.entries(bindings.sendEmail).map(([name, binding]) => ({
|
|
1737
|
+
name,
|
|
1738
|
+
...binding.destinationAddress && {
|
|
1739
|
+
destination_address: binding.destinationAddress
|
|
1740
|
+
},
|
|
1741
|
+
...binding.allowedDestinationAddresses && {
|
|
1742
|
+
allowed_destination_addresses: binding.allowedDestinationAddresses
|
|
1743
|
+
},
|
|
1744
|
+
...binding.allowedSenderAddresses && {
|
|
1745
|
+
allowed_sender_addresses: binding.allowedSenderAddresses
|
|
1746
|
+
}
|
|
1747
|
+
}))
|
|
1748
|
+
} : undefined;
|
|
1749
|
+
const createWorkerConfig = (options2) => {
|
|
1750
|
+
const baseFlags = loadedConfig.compatibilityFlags ?? [];
|
|
1751
|
+
const compatFlags = baseFlags.includes("nodejs_compat") ? baseFlags : [...baseFlags, "nodejs_compat"];
|
|
1752
|
+
const workerBindings = loadedConfig.vars ?? {};
|
|
1753
|
+
const workerConfig = {
|
|
1754
|
+
name: options2.name,
|
|
1755
|
+
modules: true,
|
|
1756
|
+
compatibilityDate: loadedConfig.compatibilityDate,
|
|
1757
|
+
compatibilityFlags: compatFlags,
|
|
1758
|
+
...bindings.kv && {
|
|
1759
|
+
kvNamespaces: Object.fromEntries(Object.entries(bindings.kv).map(([bindingName, bindingConfig]) => {
|
|
1760
|
+
return [bindingName, getLocalKVNamespaceIdentifier(bindingConfig)];
|
|
1761
|
+
}))
|
|
1762
|
+
},
|
|
1763
|
+
...bindings.r2 && { r2Buckets: bindings.r2 },
|
|
1764
|
+
...bindings.d1 && {
|
|
1765
|
+
d1Databases: Object.fromEntries(Object.entries(bindings.d1).map(([bindingName, bindingConfig]) => {
|
|
1766
|
+
return [bindingName, getLocalD1DatabaseIdentifier(bindingConfig)];
|
|
1767
|
+
}))
|
|
1768
|
+
},
|
|
1769
|
+
...Object.keys(workerBindings).length > 0 && { bindings: workerBindings },
|
|
1770
|
+
...sendEmailConfig && { email: sendEmailConfig },
|
|
1771
|
+
...queueProducers && { queueProducers },
|
|
1772
|
+
...options2.queueConsumers && { queueConsumers: options2.queueConsumers },
|
|
1773
|
+
...options2.triggers && { triggers: options2.triggers }
|
|
1774
|
+
};
|
|
1775
|
+
if (options2.scriptPath) {
|
|
1776
|
+
workerConfig.scriptPath = options2.scriptPath;
|
|
1777
|
+
workerConfig.modulesRoot = cwd;
|
|
1778
|
+
workerConfig.modulesRules = [
|
|
1779
|
+
{ type: "ESModule", include: ["**/*.ts", "**/*.tsx", "**/*.mts", "**/*.mjs"] },
|
|
1780
|
+
{ type: "CommonJS", include: ["**/*.js", "**/*.cjs"] },
|
|
1781
|
+
{ type: "ESModule", include: ["**/*.jsx"] }
|
|
1782
|
+
];
|
|
1783
|
+
}
|
|
1784
|
+
if (options2.script) {
|
|
1785
|
+
workerConfig.script = options2.script;
|
|
1786
|
+
}
|
|
1787
|
+
if (options2.durableObjects && Object.keys(options2.durableObjects).length > 0) {
|
|
1788
|
+
workerConfig.durableObjects = options2.durableObjects;
|
|
1789
|
+
}
|
|
1790
|
+
if (options2.serviceBindings && Object.keys(options2.serviceBindings).length > 0) {
|
|
1791
|
+
workerConfig.serviceBindings = options2.serviceBindings;
|
|
1792
|
+
}
|
|
1793
|
+
return workerConfig;
|
|
1794
|
+
};
|
|
1795
|
+
const gatewayWorker = createWorkerConfig({
|
|
1796
|
+
name: "gateway",
|
|
1797
|
+
script: getGatewayScript(loadedConfig.wsRoutes, debug, shouldRunMainWorker ? INTERNAL_APP_SERVICE_BINDING : null),
|
|
1798
|
+
serviceBindings: shouldRunMainWorker ? createServiceBindings({
|
|
1799
|
+
[INTERNAL_APP_SERVICE_BINDING]: { name: appWorkerName }
|
|
1800
|
+
}) : createServiceBindings()
|
|
1801
|
+
});
|
|
1802
|
+
gatewayWorker.routes = ["*"];
|
|
1803
|
+
const hasDurableObjectBundles = !!doResult && doResult.bundles.size > 0;
|
|
1804
|
+
const browserBindingName = getSingleBrowserBindingName(bindings.browser);
|
|
1805
|
+
const needsBrowserWorker = Boolean(browserBindingName && (hasDurableObjectBundles || shouldRunMainWorker));
|
|
1806
|
+
if (!shouldRunMainWorker && !hasDurableObjectBundles && !needsBrowserWorker) {
|
|
1807
|
+
return {
|
|
1808
|
+
...sharedOptions,
|
|
1809
|
+
...gatewayWorker
|
|
1810
|
+
};
|
|
1811
|
+
}
|
|
1812
|
+
const workers = [];
|
|
1813
|
+
const durableObjects = {};
|
|
1814
|
+
const browserShimUrl = `http://127.0.0.1:${browserShimPort}`;
|
|
1815
|
+
const browserWorkerName = "browser-binding";
|
|
1816
|
+
if (shouldRunMainWorker && mainWorkerScriptPath) {
|
|
1817
|
+
const mainWorkerServiceBindings = createServiceBindings(browserBindingName ? {
|
|
1818
|
+
[browserBindingName]: { name: browserWorkerName }
|
|
1819
|
+
} : {});
|
|
1820
|
+
const mainWorkerConfig = createWorkerConfig({
|
|
1821
|
+
name: appWorkerName,
|
|
1822
|
+
scriptPath: bundledMainWorkerScriptPath ?? mainWorkerScriptPath,
|
|
1823
|
+
serviceBindings: mainWorkerServiceBindings,
|
|
1824
|
+
queueConsumers,
|
|
1825
|
+
triggers: loadedConfig.triggers?.crons?.length ? { crons: loadedConfig.triggers.crons } : undefined
|
|
1826
|
+
});
|
|
1827
|
+
workers.push(mainWorkerConfig);
|
|
1828
|
+
}
|
|
1829
|
+
if (doResult) {
|
|
1830
|
+
for (const [bindingName, bundlePath] of doResult.bundles) {
|
|
1831
|
+
const className = doResult.classes.get(bindingName);
|
|
1832
|
+
if (!className)
|
|
1833
|
+
continue;
|
|
1834
|
+
const workerName = `do-${bindingName.toLowerCase()}`;
|
|
1835
|
+
const workerConfig = createWorkerConfig({
|
|
1836
|
+
name: workerName,
|
|
1837
|
+
scriptPath: bundlePath,
|
|
1838
|
+
durableObjects: {
|
|
1839
|
+
[bindingName]: className
|
|
1840
|
+
},
|
|
1841
|
+
serviceBindings: createServiceBindings(browserBindingName ? {
|
|
1842
|
+
[browserBindingName]: { name: browserWorkerName }
|
|
1843
|
+
} : {})
|
|
1844
|
+
});
|
|
1845
|
+
if (browserBindingName) {
|
|
1846
|
+
logger?.debug(`DO ${workerName} has browser service binding: ${browserBindingName} → ${browserWorkerName}`);
|
|
1847
|
+
}
|
|
1848
|
+
logger?.debug(`DO ${workerName} config:`, JSON.stringify(workerConfig, null, 2));
|
|
1849
|
+
workers.push(workerConfig);
|
|
1850
|
+
durableObjects[bindingName] = {
|
|
1851
|
+
className,
|
|
1852
|
+
scriptName: workerName
|
|
1853
|
+
};
|
|
1854
|
+
}
|
|
1855
|
+
}
|
|
1856
|
+
if (needsBrowserWorker) {
|
|
1857
|
+
const browserWorker = createWorkerConfig({
|
|
1858
|
+
name: browserWorkerName,
|
|
1859
|
+
script: getBrowserBindingScript(browserShimUrl, debug)
|
|
1860
|
+
});
|
|
1861
|
+
workers.push(browserWorker);
|
|
1862
|
+
logger?.info(`Browser binding worker configured: ${browserBindingName} → ${browserShimUrl}`);
|
|
1863
|
+
}
|
|
1864
|
+
if (Object.keys(durableObjects).length > 0) {
|
|
1865
|
+
gatewayWorker.durableObjects = durableObjects;
|
|
1866
|
+
if (shouldRunMainWorker) {
|
|
1867
|
+
const mainWorker = workers.find((worker) => worker.name === appWorkerName);
|
|
1868
|
+
if (mainWorker) {
|
|
1869
|
+
mainWorker.durableObjects = durableObjects;
|
|
1870
|
+
}
|
|
1871
|
+
}
|
|
1872
|
+
}
|
|
1873
|
+
return {
|
|
1874
|
+
...sharedOptions,
|
|
1875
|
+
workers: [gatewayWorker, ...workers]
|
|
1876
|
+
};
|
|
1877
|
+
}
|
|
1878
|
+
async function startMiniflare(doResult) {
|
|
1879
|
+
const { Miniflare, Log, LogLevel } = await import("miniflare");
|
|
1880
|
+
const mfConfig = buildMiniflareConfig(doResult);
|
|
1881
|
+
mfConfig.log = createCompatibilityAwareMiniflareLog(Log, LogLevel.DEBUG, logger);
|
|
1882
|
+
mfConfig.handleRuntimeStdio = createRuntimeStdioForwarder(logger);
|
|
1883
|
+
const shouldLogMiniflareDiagnostics = verbose || debug;
|
|
1884
|
+
if (shouldLogMiniflareDiagnostics) {
|
|
1885
|
+
logger?.info("=== MINIFLARE CONFIG DEBUG ===");
|
|
1886
|
+
logger?.info("Full config:", JSON.stringify(mfConfig, (key, value) => {
|
|
1887
|
+
if (key === "script" && typeof value === "string" && value.length > 200) {
|
|
1888
|
+
return value.substring(0, 200) + "...[truncated]";
|
|
1889
|
+
}
|
|
1890
|
+
return value;
|
|
1891
|
+
}, 2));
|
|
1892
|
+
if (mfConfig.workers) {
|
|
1893
|
+
logger?.info("Workers order:");
|
|
1894
|
+
for (const w of mfConfig.workers) {
|
|
1895
|
+
logger?.info(` → ${w.name}:`);
|
|
1896
|
+
logger?.info(` script: ${w.script ? "inline" : w.scriptPath}`);
|
|
1897
|
+
logger?.info(` browserRendering: ${JSON.stringify(w.browserRendering)}`);
|
|
1898
|
+
logger?.info(` durableObjects: ${JSON.stringify(w.durableObjects)}`);
|
|
1899
|
+
}
|
|
1900
|
+
}
|
|
1901
|
+
}
|
|
1902
|
+
miniflare = new Miniflare(mfConfig);
|
|
1903
|
+
await miniflare.ready;
|
|
1904
|
+
logger?.success(`Miniflare ready on http://localhost:${miniflarePort}`);
|
|
1905
|
+
if (shouldLogMiniflareDiagnostics) {
|
|
1906
|
+
try {
|
|
1907
|
+
const gatewayBindings = await miniflare.getBindings("gateway");
|
|
1908
|
+
logger?.info("Gateway worker bindings:", Object.keys(gatewayBindings));
|
|
1909
|
+
if (mfConfig.workers) {
|
|
1910
|
+
for (const w of mfConfig.workers) {
|
|
1911
|
+
if (w.name !== "gateway") {
|
|
1912
|
+
try {
|
|
1913
|
+
const doBindings = await miniflare.getBindings(w.name);
|
|
1914
|
+
logger?.info(`${w.name} worker bindings:`, Object.keys(doBindings));
|
|
1915
|
+
if ("BROWSER" in doBindings) {
|
|
1916
|
+
logger?.success(`${w.name} has BROWSER binding!`);
|
|
1917
|
+
} else {
|
|
1918
|
+
logger?.warn(`${w.name} is MISSING BROWSER binding`);
|
|
1919
|
+
}
|
|
1920
|
+
} catch (error) {
|
|
1921
|
+
logger?.debug(`Skipping binding diagnostics for ${w.name}: ${formatErrorMessage(error)}`);
|
|
1922
|
+
}
|
|
1923
|
+
}
|
|
1924
|
+
}
|
|
1925
|
+
}
|
|
1926
|
+
} catch (error) {
|
|
1927
|
+
logger?.debug(`Skipping Miniflare binding diagnostics: ${formatErrorMessage(error)}`);
|
|
1928
|
+
}
|
|
1929
|
+
}
|
|
1930
|
+
}
|
|
1931
|
+
async function reloadMiniflare(doResult) {
|
|
1932
|
+
currentDoResult = doResult;
|
|
1933
|
+
await reloadQueue.schedule();
|
|
1934
|
+
}
|
|
1935
|
+
async function resolveWorkerConfigWatchPath() {
|
|
1936
|
+
if (configPath) {
|
|
1937
|
+
const explicitPath = resolve3(cwd, configPath);
|
|
1938
|
+
const fs = await import("node:fs/promises");
|
|
1939
|
+
try {
|
|
1940
|
+
await fs.access(explicitPath);
|
|
1941
|
+
return explicitPath;
|
|
1942
|
+
} catch {}
|
|
1943
|
+
}
|
|
1944
|
+
return await resolveConfigPath(cwd) ?? null;
|
|
1945
|
+
}
|
|
1946
|
+
async function refreshWorkerOnlySurfaceState() {
|
|
1947
|
+
if (!config) {
|
|
1948
|
+
return;
|
|
1949
|
+
}
|
|
1950
|
+
mainWorkerSurfacePaths = await resolveMainWorkerSurfacePaths(cwd, config);
|
|
1951
|
+
mainWorkerRoutes = await discoverRoutes(cwd, config);
|
|
1952
|
+
const composedMainEntry = await prepareComposedWorkerEntrypoint(cwd, config, undefined, {
|
|
1953
|
+
devInternalEmail: true
|
|
1954
|
+
});
|
|
1955
|
+
mainWorkerScriptPath = composedMainEntry ? resolve3(cwd, composedMainEntry) : null;
|
|
1956
|
+
if (mainWorkerScriptPath) {
|
|
1957
|
+
await bundleMainWorker();
|
|
1958
|
+
} else {
|
|
1959
|
+
bundledMainWorkerScriptPath = null;
|
|
1960
|
+
}
|
|
1961
|
+
await syncWorkerWatchTargets();
|
|
1962
|
+
}
|
|
1963
|
+
function getWorkerWatchTargets() {
|
|
1964
|
+
if (enableVite || !config) {
|
|
1965
|
+
return [];
|
|
1966
|
+
}
|
|
1967
|
+
const targets = collectWorkerWatchRoots(cwd, config, mainWorkerSurfacePaths);
|
|
1968
|
+
if (resolvedWorkerConfigPath) {
|
|
1969
|
+
targets.push(resolvedWorkerConfigPath);
|
|
1970
|
+
}
|
|
1971
|
+
return [...new Set(targets)];
|
|
1972
|
+
}
|
|
1973
|
+
async function syncWorkerWatchTargets() {
|
|
1974
|
+
if (!workerSourceWatcher) {
|
|
1975
|
+
return;
|
|
1976
|
+
}
|
|
1977
|
+
const nextWatchTargets = getWorkerWatchTargets();
|
|
1978
|
+
const nextWatchTargetSet = new Set(nextWatchTargets);
|
|
1979
|
+
const targetsToRemove = workerWatchTargets.filter((target) => !nextWatchTargetSet.has(target));
|
|
1980
|
+
const targetsToAdd = nextWatchTargets.filter((target) => !workerWatchTargets.includes(target));
|
|
1981
|
+
if (targetsToRemove.length > 0) {
|
|
1982
|
+
await workerSourceWatcher.unwatch(targetsToRemove);
|
|
1983
|
+
}
|
|
1984
|
+
if (targetsToAdd.length > 0) {
|
|
1985
|
+
workerSourceWatcher.add(targetsToAdd);
|
|
1986
|
+
}
|
|
1987
|
+
workerWatchTargets = nextWatchTargets;
|
|
1988
|
+
}
|
|
1989
|
+
async function reloadWorkerOnlyConfig() {
|
|
1990
|
+
config = await loadConfig({ cwd, configFile: configPath });
|
|
1991
|
+
setLocalSendEmailBindings(config.bindings?.sendEmail ?? {});
|
|
1992
|
+
resolvedWorkerConfigPath = await resolveWorkerConfigWatchPath();
|
|
1993
|
+
await refreshWorkerOnlySurfaceState();
|
|
1994
|
+
await reloadMiniflare(currentDoResult);
|
|
1995
|
+
}
|
|
1996
|
+
async function startWorkerSourceWatcher2() {
|
|
1997
|
+
if (enableVite || !config) {
|
|
1998
|
+
return;
|
|
1999
|
+
}
|
|
2000
|
+
const watchTargets = getWorkerWatchTargets();
|
|
2001
|
+
if (watchTargets.length === 0) {
|
|
2002
|
+
return;
|
|
2003
|
+
}
|
|
2004
|
+
workerWatchTargets = watchTargets;
|
|
2005
|
+
workerSourceWatcher = await startWorkerSourceWatcher({
|
|
2006
|
+
watchTargets,
|
|
2007
|
+
resolvedWorkerConfigPath,
|
|
2008
|
+
logger,
|
|
2009
|
+
onConfigChange: reloadWorkerOnlyConfig,
|
|
2010
|
+
onWorkerChange: async () => {
|
|
2011
|
+
await refreshWorkerOnlySurfaceState();
|
|
2012
|
+
await reloadMiniflare(currentDoResult);
|
|
2013
|
+
}
|
|
2014
|
+
});
|
|
2015
|
+
}
|
|
2016
|
+
async function start() {
|
|
2017
|
+
logger?.info("Starting unified dev server...");
|
|
2018
|
+
config = await loadConfig({ cwd, configFile: configPath });
|
|
2019
|
+
setLocalSendEmailBindings(config.bindings?.sendEmail ?? {});
|
|
2020
|
+
resolvedWorkerConfigPath = await resolveWorkerConfigWatchPath();
|
|
2021
|
+
logger?.debug("Loaded config:", config.name);
|
|
2022
|
+
if (enableVite) {
|
|
2023
|
+
const viteMode = await resolveViteMode(cwd, { requested: true });
|
|
2024
|
+
if (!viteMode.enableVite) {
|
|
2025
|
+
logger?.info("Vite disabled: no vite config found for this package");
|
|
2026
|
+
enableVite = false;
|
|
2027
|
+
} else {
|
|
2028
|
+
generatedViteConfigPath = await writeGeneratedViteConfig({
|
|
2029
|
+
cwd,
|
|
2030
|
+
configPath,
|
|
2031
|
+
localConfigPath: viteMode.viteConfigPath,
|
|
2032
|
+
bridgePort: miniflarePort
|
|
2033
|
+
});
|
|
2034
|
+
logger?.debug(`Generated Vite config → ${generatedViteConfigPath}`);
|
|
2035
|
+
}
|
|
2036
|
+
}
|
|
2037
|
+
await refreshWorkerOnlySurfaceState();
|
|
2038
|
+
if (!enableVite && (hasWorkerSurfacePaths(mainWorkerSurfacePaths) || Boolean(mainWorkerRoutes?.routes.length))) {
|
|
2039
|
+
const detectedWorkerHandlers = Object.entries(mainWorkerSurfacePaths).filter(([, surfacePath]) => !!surfacePath).map(([surfaceName, surfacePath]) => `${surfaceName}=${surfacePath}`);
|
|
2040
|
+
const detectedRouteHandlers = mainWorkerRoutes?.routes.map((route) => `route=${route.filePath}`) ?? [];
|
|
2041
|
+
logger?.info(`Worker handlers detected: ${[...detectedWorkerHandlers, ...detectedRouteHandlers].join(", ")}`);
|
|
2042
|
+
} else if (!enableVite) {
|
|
2043
|
+
logger?.warn("No local worker handler entry was found for worker-only mode");
|
|
2044
|
+
}
|
|
2045
|
+
const remoteCheck = await checkRemoteBindingRequirements(config);
|
|
2046
|
+
if (remoteCheck.hasRemoteBindings) {
|
|
2047
|
+
logger?.info("");
|
|
2048
|
+
logger?.warn("⚠️ Remote-only bindings detected:");
|
|
2049
|
+
for (const binding of remoteCheck.remoteBindings) {
|
|
2050
|
+
logger?.warn(` • ${binding}`);
|
|
2051
|
+
}
|
|
2052
|
+
logger?.info("");
|
|
2053
|
+
if (remoteCheck.missingAccountId) {
|
|
2054
|
+
logger?.warn("⚠️ WARN: accountId is not set in devflare.config.ts");
|
|
2055
|
+
logger?.warn(" Remote bindings (AI, Vectorize) require accountId to charge the correct account.");
|
|
2056
|
+
logger?.warn(" Add: accountId: 'your-cloudflare-account-id'");
|
|
2057
|
+
logger?.info("");
|
|
2058
|
+
}
|
|
2059
|
+
if (remoteCheck.notLoggedIn) {
|
|
2060
|
+
logger?.warn("⚠️ WARN: Not logged in to Wrangler");
|
|
2061
|
+
logger?.warn(" Remote bindings require authentication.");
|
|
2062
|
+
logger?.warn(" Run: bunx wrangler login");
|
|
2063
|
+
logger?.info("");
|
|
2064
|
+
}
|
|
2065
|
+
if (!remoteCheck.missingAccountId && !remoteCheck.notLoggedIn) {
|
|
2066
|
+
logger?.success("✓ Remote binding requirements met");
|
|
2067
|
+
logger?.info("");
|
|
2068
|
+
}
|
|
2069
|
+
}
|
|
2070
|
+
const browserBinding = getSingleBrowserBindingName(config.bindings?.browser);
|
|
2071
|
+
if (browserBinding) {
|
|
2072
|
+
logger?.info(`Starting Browser Rendering shim (binding: ${browserBinding})...`);
|
|
2073
|
+
browserShim = createBrowserShim({
|
|
2074
|
+
port: browserShimPort,
|
|
2075
|
+
host: "127.0.0.1",
|
|
2076
|
+
logger,
|
|
2077
|
+
verbose
|
|
2078
|
+
});
|
|
2079
|
+
await browserShim.start();
|
|
2080
|
+
}
|
|
2081
|
+
const doPattern = config.files?.durableObjects;
|
|
2082
|
+
let doResult = null;
|
|
2083
|
+
if (typeof doPattern === "string" && doPattern) {
|
|
2084
|
+
const outDir = resolve3(cwd, ".devflare/do-bundles");
|
|
2085
|
+
doBundler = createDOBundler({
|
|
2086
|
+
cwd,
|
|
2087
|
+
pattern: doPattern,
|
|
2088
|
+
outDir,
|
|
2089
|
+
rolldownOptions: config.rolldown?.options,
|
|
2090
|
+
sourcemap: config.rolldown?.sourcemap,
|
|
2091
|
+
minify: config.rolldown?.minify,
|
|
2092
|
+
logger,
|
|
2093
|
+
onRebuild: async (result) => {
|
|
2094
|
+
await reloadMiniflare(result);
|
|
2095
|
+
}
|
|
2096
|
+
});
|
|
2097
|
+
doResult = await doBundler.build();
|
|
2098
|
+
currentDoResult = doResult;
|
|
2099
|
+
await doBundler.watch();
|
|
2100
|
+
}
|
|
2101
|
+
currentDoResult = doResult;
|
|
2102
|
+
await startMiniflare(doResult);
|
|
2103
|
+
await startWorkerSourceWatcher2();
|
|
2104
|
+
if (enableVite) {
|
|
2105
|
+
viteProcess = await startViteProcess({
|
|
2106
|
+
cwd,
|
|
2107
|
+
vitePort,
|
|
2108
|
+
miniflarePort,
|
|
2109
|
+
generatedViteConfigPath,
|
|
2110
|
+
logger
|
|
2111
|
+
});
|
|
2112
|
+
} else {
|
|
2113
|
+
logger?.info("Vite startup skipped (no effective Vite config found for this package)");
|
|
2114
|
+
}
|
|
2115
|
+
await new Promise((r) => setTimeout(r, 1000));
|
|
2116
|
+
await runD1Migrations({ cwd, config, miniflarePort, logger });
|
|
2117
|
+
}
|
|
2118
|
+
async function stop() {
|
|
2119
|
+
if (doBundler) {
|
|
2120
|
+
await doBundler.close();
|
|
2121
|
+
doBundler = null;
|
|
2122
|
+
}
|
|
2123
|
+
if (workerSourceWatcher) {
|
|
2124
|
+
await workerSourceWatcher.close();
|
|
2125
|
+
workerSourceWatcher = null;
|
|
2126
|
+
}
|
|
2127
|
+
if (miniflare) {
|
|
2128
|
+
await miniflare.dispose();
|
|
2129
|
+
miniflare = null;
|
|
2130
|
+
}
|
|
2131
|
+
if (viteProcess) {
|
|
2132
|
+
await stopSpawnedProcessTree(viteProcess);
|
|
2133
|
+
viteProcess = null;
|
|
2134
|
+
}
|
|
2135
|
+
if (browserShim) {
|
|
2136
|
+
await browserShim.stop();
|
|
2137
|
+
browserShim = null;
|
|
2138
|
+
}
|
|
2139
|
+
clearLocalSendEmailBindings();
|
|
2140
|
+
}
|
|
2141
|
+
function getMiniflare() {
|
|
2142
|
+
return miniflare;
|
|
2143
|
+
}
|
|
2144
|
+
return {
|
|
2145
|
+
start,
|
|
2146
|
+
stop,
|
|
2147
|
+
getMiniflare
|
|
2148
|
+
};
|
|
2149
|
+
}
|
|
2150
|
+
// src/cli/commands/dev.ts
|
|
2151
|
+
async function createLogWriter(cwd, options) {
|
|
2152
|
+
if (!options.log && !options.logTemp) {
|
|
2153
|
+
return null;
|
|
2154
|
+
}
|
|
2155
|
+
const fs = await import("node:fs");
|
|
2156
|
+
let logPath;
|
|
2157
|
+
if (options.logTemp) {
|
|
2158
|
+
logPath = resolve4(cwd, ".log");
|
|
2159
|
+
} else {
|
|
2160
|
+
const now = new Date;
|
|
2161
|
+
const timestamp = now.toISOString().replace(/[:.]/g, "-").replace("T", "_").slice(0, 19);
|
|
2162
|
+
logPath = resolve4(cwd, `.log-${timestamp}`);
|
|
2163
|
+
}
|
|
2164
|
+
const fileStream = fs.createWriteStream(logPath, { flags: "w" });
|
|
2165
|
+
const ansiRegex = /\x1b\[[0-9;]*m/g;
|
|
2166
|
+
return {
|
|
2167
|
+
path: logPath,
|
|
2168
|
+
write(data, source) {
|
|
2169
|
+
const str = typeof data === "string" ? data : data.toString();
|
|
2170
|
+
if (!str.trim())
|
|
2171
|
+
return;
|
|
2172
|
+
const timestamp = new Date().toISOString().slice(11, 23);
|
|
2173
|
+
const prefix = source ? `[${timestamp}][${source.toUpperCase()}] ` : `[${timestamp}] `;
|
|
2174
|
+
const cleanStr = str.replace(ansiRegex, "");
|
|
2175
|
+
fileStream.write(prefix + cleanStr + (cleanStr.endsWith(`
|
|
2176
|
+
`) ? "" : `
|
|
2177
|
+
`));
|
|
2178
|
+
},
|
|
2179
|
+
close() {
|
|
2180
|
+
fileStream.end();
|
|
2181
|
+
}
|
|
2182
|
+
};
|
|
2183
|
+
}
|
|
2184
|
+
async function runDevCommand(parsed, logger, options) {
|
|
2185
|
+
const cwd = options.cwd || parsed.options.cwd || process.cwd();
|
|
2186
|
+
const configPath = parsed.options.config;
|
|
2187
|
+
const port = parsed.options.port;
|
|
2188
|
+
const logEnabled = parsed.options.log === true;
|
|
2189
|
+
const logTempEnabled = parsed.options["log-temp"] === true;
|
|
2190
|
+
const persistEnabled = parsed.options.persist === true;
|
|
2191
|
+
const debugEnabled = parsed.options.debug === true || process.env.DEVFLARE_DEBUG === "true";
|
|
2192
|
+
const verbose = parsed.options.verbose === true || debugEnabled;
|
|
2193
|
+
const theme = createCliTheme(parsed.options);
|
|
2194
|
+
const config = await loadConfig({ cwd, configFile: configPath });
|
|
2195
|
+
const viteProject = resolveEffectiveViteProject(await detectViteProject(cwd), config);
|
|
2196
|
+
const logWriter = await createLogWriter(cwd, {
|
|
2197
|
+
log: logEnabled,
|
|
2198
|
+
logTemp: logTempEnabled
|
|
2199
|
+
});
|
|
2200
|
+
if (logWriter) {
|
|
2201
|
+
const logFile = relative(cwd, logWriter.path) || ".log";
|
|
2202
|
+
logLine(logger, `${dim("logging", theme)} ${logFile}`);
|
|
2203
|
+
}
|
|
2204
|
+
const devLogger = createConsola({
|
|
2205
|
+
level: verbose ? 4 : 3
|
|
2206
|
+
});
|
|
2207
|
+
if (logWriter) {
|
|
2208
|
+
const wrapLog = (original, prefix = "") => {
|
|
2209
|
+
return (message, ...args) => {
|
|
2210
|
+
original(message, ...args);
|
|
2211
|
+
const formatted = prefix ? `${prefix} ${[message, ...args].join(" ")}` : [message, ...args].join(" ");
|
|
2212
|
+
logWriter.write(formatted);
|
|
2213
|
+
};
|
|
2214
|
+
};
|
|
2215
|
+
Object.assign(devLogger.log, wrapLog(devLogger.log.bind(devLogger)));
|
|
2216
|
+
Object.assign(devLogger.info, wrapLog(devLogger.info.bind(devLogger)));
|
|
2217
|
+
Object.assign(devLogger.error, wrapLog(devLogger.error.bind(devLogger), "[ERROR]"));
|
|
2218
|
+
Object.assign(devLogger.warn, wrapLog(devLogger.warn.bind(devLogger), "[WARN]"));
|
|
2219
|
+
Object.assign(devLogger.success, wrapLog(devLogger.success.bind(devLogger), "[OK]"));
|
|
2220
|
+
Object.assign(devLogger.debug, wrapLog(devLogger.debug.bind(devLogger), "[DEBUG]"));
|
|
2221
|
+
}
|
|
2222
|
+
try {
|
|
2223
|
+
logLine(logger);
|
|
2224
|
+
if (viteProject.shouldStartVite) {
|
|
2225
|
+
logLine(logger, `${cyanBold("dev", theme)} ${dim("Unified Dev Server", theme)}`);
|
|
2226
|
+
logLine(logger, " ├─ Vite: Full HMR for frontend");
|
|
2227
|
+
logLine(logger, " ├─ Miniflare: All Cloudflare bindings");
|
|
2228
|
+
logLine(logger, " ├─ Rolldown: Worker + DO bundling with watch");
|
|
2229
|
+
logLine(logger, " └─ Bridge: WebSocket RPC connection");
|
|
2230
|
+
} else {
|
|
2231
|
+
logLine(logger, `${cyanBold("dev", theme)} ${dim("Worker Dev Server", theme)}`);
|
|
2232
|
+
logLine(logger, " ├─ Miniflare: All Cloudflare bindings");
|
|
2233
|
+
logLine(logger, " ├─ Rolldown: Worker + DO bundling with watch");
|
|
2234
|
+
logLine(logger, " └─ Vite: Disabled (no effective Vite config found)");
|
|
2235
|
+
if (viteProject.wantsViteIntegration) {
|
|
2236
|
+
logger.warn("Vite-related settings were detected, but no effective Vite config was available");
|
|
2237
|
+
logger.warn("Skipping Vite startup and running in worker-only mode");
|
|
2238
|
+
}
|
|
2239
|
+
}
|
|
2240
|
+
logLine(logger);
|
|
2241
|
+
const devServer = createDevServer({
|
|
2242
|
+
cwd,
|
|
2243
|
+
configPath,
|
|
2244
|
+
vitePort: port ? parseInt(port, 10) : 5173,
|
|
2245
|
+
miniflarePort: 8787,
|
|
2246
|
+
enableVite: viteProject.shouldStartVite,
|
|
2247
|
+
persist: persistEnabled,
|
|
2248
|
+
logger: devLogger,
|
|
2249
|
+
verbose,
|
|
2250
|
+
debug: debugEnabled
|
|
2251
|
+
});
|
|
2252
|
+
let isCleaningUp = false;
|
|
2253
|
+
const cleanupHandlers = new Map;
|
|
2254
|
+
const removeCleanupHandlers = () => {
|
|
2255
|
+
for (const [event, handler] of cleanupHandlers) {
|
|
2256
|
+
process.off(event, handler);
|
|
2257
|
+
}
|
|
2258
|
+
cleanupHandlers.clear();
|
|
2259
|
+
};
|
|
2260
|
+
const cleanup = async (exitCode, reason) => {
|
|
2261
|
+
if (isCleaningUp) {
|
|
2262
|
+
return;
|
|
2263
|
+
}
|
|
2264
|
+
isCleaningUp = true;
|
|
2265
|
+
removeCleanupHandlers();
|
|
2266
|
+
if (reason) {
|
|
2267
|
+
const message = reason instanceof Error ? reason.stack ?? reason.message : String(reason);
|
|
2268
|
+
logger.error(message);
|
|
2269
|
+
}
|
|
2270
|
+
logLine(logger);
|
|
2271
|
+
logLine(logger, `${yellow("dev", theme)} ${dim("Shutting down…", theme)}`);
|
|
2272
|
+
try {
|
|
2273
|
+
await devServer.stop();
|
|
2274
|
+
} finally {
|
|
2275
|
+
logWriter?.close();
|
|
2276
|
+
process.exit(exitCode);
|
|
2277
|
+
}
|
|
2278
|
+
};
|
|
2279
|
+
const registerCleanupHandler = (event, handler) => {
|
|
2280
|
+
cleanupHandlers.set(event, handler);
|
|
2281
|
+
process.on(event, handler);
|
|
2282
|
+
};
|
|
2283
|
+
registerCleanupHandler("SIGINT", () => {
|
|
2284
|
+
cleanup(0);
|
|
2285
|
+
});
|
|
2286
|
+
registerCleanupHandler("SIGTERM", () => {
|
|
2287
|
+
cleanup(0);
|
|
2288
|
+
});
|
|
2289
|
+
registerCleanupHandler("SIGHUP", () => {
|
|
2290
|
+
cleanup(0);
|
|
2291
|
+
});
|
|
2292
|
+
registerCleanupHandler("uncaughtException", (error) => {
|
|
2293
|
+
cleanup(1, error);
|
|
2294
|
+
});
|
|
2295
|
+
registerCleanupHandler("unhandledRejection", (reason) => {
|
|
2296
|
+
cleanup(1, reason);
|
|
2297
|
+
});
|
|
2298
|
+
await devServer.start();
|
|
2299
|
+
await new Promise(() => {});
|
|
2300
|
+
return { exitCode: 0 };
|
|
2301
|
+
} catch (error) {
|
|
2302
|
+
logWriter?.close();
|
|
2303
|
+
if (error instanceof Error) {
|
|
2304
|
+
logger.error("Dev server failed:", error.message);
|
|
2305
|
+
if (verbose) {
|
|
2306
|
+
logger.error(error.stack);
|
|
2307
|
+
}
|
|
2308
|
+
}
|
|
2309
|
+
return { exitCode: 1 };
|
|
2310
|
+
}
|
|
2311
|
+
}
|
|
2312
|
+
export {
|
|
2313
|
+
runDevCommand
|
|
2314
|
+
};
|