devflare 1.0.0-next.5 → 1.0.0-next.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/LLM.md +17312 -2139
- package/README.md +394 -605
- package/bin/devflare.js +30 -14
- package/dist/_chunks/account-BI3WZMDy.js +462 -0
- package/dist/_chunks/account-resources-CsmVowJp.js +159 -0
- package/dist/_chunks/ai-CBEuLdoP.js +322 -0
- package/dist/_chunks/api-TzdliH-6.js +568 -0
- package/dist/_chunks/build-artifacts-DU5V0J0Z.js +483 -0
- package/dist/_chunks/build-e0KR38-4.js +24 -0
- package/dist/_chunks/cli-DuUz10Mn.js +1163 -0
- package/dist/_chunks/cloudflare-BaloqI3H.js +157 -0
- package/dist/_chunks/colors-DiK6wPJ5.js +13 -0
- package/dist/_chunks/command-utils-DA0Qx9_K.js +45 -0
- package/dist/_chunks/compiler-Zw16C9Pi.js +489 -0
- package/dist/_chunks/config-Brju62xy.js +78 -0
- package/dist/_chunks/config-path-DaL1ylZ_.js +42 -0
- package/dist/_chunks/context-CX50Y2Kb.js +2250 -0
- package/dist/_chunks/decorators-QmV57ixr.js +19 -0
- package/dist/_chunks/dependencies-C2oxFjU_.js +57 -0
- package/dist/_chunks/deploy-B-Kku1Vk.js +1032 -0
- package/dist/_chunks/dev-D4e_RRZn.js +3471 -0
- package/dist/_chunks/doctor-jm_K4dxL.js +219 -0
- package/dist/_chunks/durable-object-DMtH0XYX.js +234 -0
- package/dist/_chunks/env-S0_nMVz1.js +125 -0
- package/dist/_chunks/family-_9-mGSfO.js +143 -0
- package/dist/_chunks/generated-artifacts-dMJY4KAt.js +32 -0
- package/dist/_chunks/glob-CmQOvunB.js +56 -0
- package/dist/_chunks/init-DnkJOmpW.js +165 -0
- package/dist/_chunks/loader-Cr0_OWPy.js +1288 -0
- package/dist/_chunks/local-dev-vars-CTSa-wvF.js +81 -0
- package/dist/_chunks/local-hyperdrive-CJ90j46O.js +119 -0
- package/dist/_chunks/local-media-bindings-DsAW4AMF.js +335 -0
- package/dist/_chunks/local-secrets-DMPkmOn3.js +123 -0
- package/dist/_chunks/local-workflow-entrypoints-Cq_WJajd.js +90 -0
- package/dist/_chunks/login-FjTAAQbi.js +51 -0
- package/dist/_chunks/package-metadata-DjHBLB-z.js +39 -0
- package/dist/_chunks/preferences-BKp_7XJx.js +241 -0
- package/dist/_chunks/preview-C3Cdr8an.js +462 -0
- package/dist/_chunks/preview-registry-ClAbLTHH.js +1186 -0
- package/dist/_chunks/preview-resources-CGMBjsYB.js +359 -0
- package/dist/_chunks/previews-C7hs9-BT.js +1134 -0
- package/dist/_chunks/productions-T9Als4fE.js +411 -0
- package/dist/_chunks/ref-CYJNAAe_.js +178 -0
- package/dist/_chunks/remote-CZnP-HLJ.js +79 -0
- package/dist/_chunks/remote-config-D39BY9ji.js +132 -0
- package/dist/_chunks/resolve-package-qizBfCIm.js +152 -0
- package/dist/_chunks/rolldown-runtime-CvQ6eiug.js +14 -0
- package/dist/_chunks/routes-BFYCqHb-.js +833 -0
- package/dist/_chunks/runtime-DL-Nz3k8.js +550 -0
- package/dist/_chunks/schema-normalization-BCwTLTGp.js +660 -0
- package/dist/_chunks/secrets-DIpJGe6C.js +95 -0
- package/dist/_chunks/tail-IY-ijYmv.js +239 -0
- package/dist/_chunks/token-Dmi0KXyX.js +333 -0
- package/dist/_chunks/tokens-iVcgNXi-.js +221 -0
- package/dist/_chunks/types-DoKsMYfm.js +484 -0
- package/dist/_chunks/ui-BUoZApvE.js +103 -0
- package/dist/_chunks/usage-BBTGzjon.js +272 -0
- package/dist/_chunks/vite-CGtVNf5E.js +1267 -0
- package/dist/_chunks/vite-utils-OVLMV605.js +183 -0
- package/dist/_chunks/worker-BEZI4od1.js +410 -0
- package/dist/_chunks/worker-bundler-dTTnYU3n.js +458 -0
- package/dist/_chunks/worker-entrypoint-CQW77lG8.js +247 -0
- package/dist/_chunks/workerName-CFJsLZA-.js +23 -0
- package/dist/bridge/client.d.ts +49 -7
- 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 +6 -6
- package/dist/bridge/index.d.ts.map +1 -1
- package/dist/bridge/log.d.ts +5 -0
- package/dist/bridge/log.d.ts.map +1 -0
- package/dist/bridge/miniflare.d.ts +82 -2
- package/dist/bridge/miniflare.d.ts.map +1 -1
- package/dist/bridge/proxy.d.ts +12 -11
- package/dist/bridge/proxy.d.ts.map +1 -1
- package/dist/bridge/server.d.ts +2 -1
- package/dist/bridge/server.d.ts.map +1 -1
- package/dist/bridge/v2/body-streams.d.ts +53 -0
- package/dist/bridge/v2/body-streams.d.ts.map +1 -0
- package/dist/bridge/v2/codec.d.ts +106 -0
- package/dist/bridge/v2/codec.d.ts.map +1 -0
- package/dist/bridge/v2/control-messages.d.ts +46 -0
- package/dist/bridge/v2/control-messages.d.ts.map +1 -0
- package/dist/bridge/v2/frames.d.ts +109 -0
- package/dist/bridge/v2/frames.d.ts.map +1 -0
- package/dist/bridge/v2/index.d.ts +11 -0
- package/dist/bridge/v2/index.d.ts.map +1 -0
- package/dist/bridge/v2/serialization.d.ts +48 -0
- package/dist/bridge/v2/serialization.d.ts.map +1 -0
- package/dist/bridge/v2/transport.d.ts +31 -0
- package/dist/bridge/v2/transport.d.ts.map +1 -0
- package/dist/bridge/v2/value-codec.d.ts +61 -0
- package/dist/bridge/v2/value-codec.d.ts.map +1 -0
- package/dist/bridge/{serialization.d.ts → v2/value-serialization.d.ts} +40 -18
- package/dist/bridge/v2/value-serialization.d.ts.map +1 -0
- package/dist/bridge/{protocol.d.ts → v2/wire.d.ts} +32 -8
- package/dist/bridge/v2/wire.d.ts.map +1 -0
- package/dist/bridge/v2/ws-relay.d.ts +53 -0
- package/dist/bridge/v2/ws-relay.d.ts.map +1 -0
- package/dist/browser-shim/handler.d.ts +2 -2
- package/dist/browser-shim/handler.d.ts.map +1 -1
- package/dist/browser-shim/index.d.ts +2 -2
- package/dist/browser-shim/server.d.ts +63 -0
- package/dist/browser-shim/server.d.ts.map +1 -1
- package/dist/browser.d.ts +5411 -0
- package/dist/browser.d.ts.map +1 -0
- package/dist/browser.js +80 -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 +3 -1
- 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 +2 -2
- package/dist/cli/commands/account.d.ts.map +1 -1
- package/dist/cli/commands/ai.d.ts +1 -1
- package/dist/cli/commands/ai.d.ts.map +1 -1
- package/dist/cli/commands/build-artifacts.d.ts +40 -0
- package/dist/cli/commands/build-artifacts.d.ts.map +1 -0
- package/dist/cli/commands/build.d.ts +2 -2
- package/dist/cli/commands/build.d.ts.map +1 -1
- package/dist/cli/commands/config.d.ts +4 -0
- package/dist/cli/commands/config.d.ts.map +1 -0
- package/dist/cli/commands/deploy/metadata.d.ts +18 -0
- package/dist/cli/commands/deploy/metadata.d.ts.map +1 -0
- package/dist/cli/commands/deploy/prepare.d.ts +23 -0
- package/dist/cli/commands/deploy/prepare.d.ts.map +1 -0
- package/dist/cli/commands/deploy/runtime.d.ts +4 -0
- package/dist/cli/commands/deploy/runtime.d.ts.map +1 -0
- package/dist/cli/commands/deploy/verification.d.ts +36 -0
- package/dist/cli/commands/deploy/verification.d.ts.map +1 -0
- package/dist/cli/commands/deploy.d.ts +2 -2
- package/dist/cli/commands/deploy.d.ts.map +1 -1
- package/dist/cli/commands/dev.d.ts +9 -1
- package/dist/cli/commands/dev.d.ts.map +1 -1
- package/dist/cli/commands/doctor.d.ts +2 -2
- package/dist/cli/commands/doctor.d.ts.map +1 -1
- package/dist/cli/commands/init.d.ts +2 -2
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/login.d.ts +4 -0
- package/dist/cli/commands/login.d.ts.map +1 -0
- package/dist/cli/commands/previews-support/cleanup.d.ts +9 -0
- package/dist/cli/commands/previews-support/cleanup.d.ts.map +1 -0
- package/dist/cli/commands/previews-support/family.d.ts +10 -0
- package/dist/cli/commands/previews-support/family.d.ts.map +1 -0
- package/dist/cli/commands/previews-support/render.d.ts +8 -0
- package/dist/cli/commands/previews-support/render.d.ts.map +1 -0
- package/dist/cli/commands/previews-support/theme.d.ts +10 -0
- package/dist/cli/commands/previews-support/theme.d.ts.map +1 -0
- package/dist/cli/commands/previews-support/types.d.ts +70 -0
- package/dist/cli/commands/previews-support/types.d.ts.map +1 -0
- package/dist/cli/commands/previews.d.ts +4 -0
- package/dist/cli/commands/previews.d.ts.map +1 -0
- package/dist/cli/commands/productions.d.ts +4 -0
- package/dist/cli/commands/productions.d.ts.map +1 -0
- package/dist/cli/commands/remote.d.ts +1 -1
- package/dist/cli/commands/remote.d.ts.map +1 -1
- package/dist/cli/commands/secrets.d.ts +4 -0
- package/dist/cli/commands/secrets.d.ts.map +1 -0
- package/dist/cli/commands/tail.d.ts +44 -0
- package/dist/cli/commands/tail.d.ts.map +1 -0
- package/dist/cli/commands/token.d.ts +4 -0
- package/dist/cli/commands/token.d.ts.map +1 -0
- package/dist/cli/commands/type-generation/discovery.d.ts +7 -0
- package/dist/cli/commands/type-generation/discovery.d.ts.map +1 -0
- package/dist/cli/commands/type-generation/generator.d.ts +121 -0
- package/dist/cli/commands/type-generation/generator.d.ts.map +1 -0
- package/dist/cli/commands/type-generation/models.d.ts +27 -0
- package/dist/cli/commands/type-generation/models.d.ts.map +1 -0
- package/dist/cli/commands/types.d.ts +2 -2
- package/dist/cli/commands/types.d.ts.map +1 -1
- package/dist/cli/commands/worker.d.ts +4 -0
- package/dist/cli/commands/worker.d.ts.map +1 -0
- package/dist/cli/config-path.d.ts +6 -0
- package/dist/cli/config-path.d.ts.map +1 -0
- package/dist/cli/dependencies.d.ts +2 -1
- package/dist/cli/dependencies.d.ts.map +1 -1
- package/dist/cli/deploy-strategy.d.ts +17 -0
- package/dist/cli/deploy-strategy.d.ts.map +1 -0
- package/dist/cli/deploy-target.d.ts +17 -0
- package/dist/cli/deploy-target.d.ts.map +1 -0
- package/dist/cli/generated-artifacts.d.ts +12 -0
- package/dist/cli/generated-artifacts.d.ts.map +1 -0
- package/dist/cli/gradual-deploy.d.ts +49 -0
- package/dist/cli/gradual-deploy.d.ts.map +1 -0
- package/dist/cli/help-pages/pages/account.d.ts +3 -0
- package/dist/cli/help-pages/pages/account.d.ts.map +1 -0
- package/dist/cli/help-pages/pages/core.d.ts +4 -0
- package/dist/cli/help-pages/pages/core.d.ts.map +1 -0
- package/dist/cli/help-pages/pages/index.d.ts +3 -0
- package/dist/cli/help-pages/pages/index.d.ts.map +1 -0
- package/dist/cli/help-pages/pages/misc.d.ts +3 -0
- package/dist/cli/help-pages/pages/misc.d.ts.map +1 -0
- package/dist/cli/help-pages/pages/previews.d.ts +3 -0
- package/dist/cli/help-pages/pages/previews.d.ts.map +1 -0
- package/dist/cli/help-pages/pages/productions.d.ts +3 -0
- package/dist/cli/help-pages/pages/productions.d.ts.map +1 -0
- package/dist/cli/help-pages/render.d.ts +12 -0
- package/dist/cli/help-pages/render.d.ts.map +1 -0
- package/dist/cli/help-pages/shared.d.ts +15 -0
- package/dist/cli/help-pages/shared.d.ts.map +1 -0
- package/dist/cli/help-pages/types.d.ts +23 -0
- package/dist/cli/help-pages/types.d.ts.map +1 -0
- package/dist/cli/help.d.ts +6 -0
- package/dist/cli/help.d.ts.map +1 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +2 -0
- package/dist/cli/package-metadata.d.ts +16 -0
- package/dist/cli/package-metadata.d.ts.map +1 -0
- package/dist/cli/preview-bindings.d.ts +49 -0
- package/dist/cli/preview-bindings.d.ts.map +1 -0
- package/dist/cli/preview.d.ts +10 -0
- package/dist/cli/preview.d.ts.map +1 -0
- package/dist/cli/ui.d.ts +37 -0
- package/dist/cli/ui.d.ts.map +1 -0
- package/dist/cli/workspace-build-guard.d.ts +14 -0
- package/dist/cli/workspace-build-guard.d.ts.map +1 -0
- package/dist/cli/wrangler-auth.d.ts +1 -1
- package/dist/cloudflare/account-core.d.ts +6 -0
- package/dist/cloudflare/account-core.d.ts.map +1 -0
- package/dist/cloudflare/account-resources.d.ts +40 -0
- package/dist/cloudflare/account-resources.d.ts.map +1 -0
- package/dist/cloudflare/account-status.d.ts +11 -0
- package/dist/cloudflare/account-status.d.ts.map +1 -0
- package/dist/cloudflare/account-workers.d.ts +14 -0
- package/dist/cloudflare/account-workers.d.ts.map +1 -0
- package/dist/cloudflare/account.d.ts +7 -64
- package/dist/cloudflare/account.d.ts.map +1 -1
- package/dist/cloudflare/api.d.ts +71 -3
- package/dist/cloudflare/api.d.ts.map +1 -1
- package/dist/cloudflare/auth.d.ts +1 -1
- package/dist/cloudflare/auth.d.ts.map +1 -1
- package/dist/cloudflare/index.d.ts +61 -6
- package/dist/cloudflare/index.d.ts.map +1 -1
- package/dist/cloudflare/index.js +4 -13
- package/dist/cloudflare/known-permission-group-ids.generated.d.ts +10 -0
- package/dist/cloudflare/known-permission-group-ids.generated.d.ts.map +1 -0
- package/dist/cloudflare/kv-namespace.d.ts +4 -0
- package/dist/cloudflare/kv-namespace.d.ts.map +1 -0
- package/dist/cloudflare/preferences.d.ts +7 -0
- package/dist/cloudflare/preferences.d.ts.map +1 -1
- package/dist/cloudflare/preview-registry-cache.d.ts +6 -0
- package/dist/cloudflare/preview-registry-cache.d.ts.map +1 -0
- package/dist/cloudflare/preview-registry-inference.d.ts +14 -0
- package/dist/cloudflare/preview-registry-inference.d.ts.map +1 -0
- package/dist/cloudflare/preview-registry-records.d.ts +4 -0
- package/dist/cloudflare/preview-registry-records.d.ts.map +1 -0
- package/dist/cloudflare/preview-registry-shape.d.ts +47 -0
- package/dist/cloudflare/preview-registry-shape.d.ts.map +1 -0
- package/dist/cloudflare/preview-registry-store.d.ts +14 -0
- package/dist/cloudflare/preview-registry-store.d.ts.map +1 -0
- package/dist/cloudflare/preview-registry-transport.d.ts +4 -0
- package/dist/cloudflare/preview-registry-transport.d.ts.map +1 -0
- package/dist/cloudflare/preview-registry-types.d.ts +103 -0
- package/dist/cloudflare/preview-registry-types.d.ts.map +1 -0
- package/dist/cloudflare/preview-registry.d.ts +42 -0
- package/dist/cloudflare/preview-registry.d.ts.map +1 -0
- package/dist/cloudflare/preview-urls.d.ts +3 -0
- package/dist/cloudflare/preview-urls.d.ts.map +1 -0
- package/dist/cloudflare/registry-schema.d.ts +253 -0
- package/dist/cloudflare/registry-schema.d.ts.map +1 -0
- package/dist/cloudflare/remote-config.d.ts.map +1 -1
- package/dist/cloudflare/tokens.d.ts +44 -0
- package/dist/cloudflare/tokens.d.ts.map +1 -0
- package/dist/cloudflare/types.d.ts +124 -7
- package/dist/cloudflare/types.d.ts.map +1 -1
- package/dist/cloudflare/usage.d.ts +31 -3
- package/dist/cloudflare/usage.d.ts.map +1 -1
- package/dist/config/binding-resolution-helpers.d.ts +41 -0
- package/dist/config/binding-resolution-helpers.d.ts.map +1 -0
- package/dist/config/compatibility.d.ts +3 -0
- package/dist/config/compatibility.d.ts.map +1 -0
- package/dist/config/compiler/bindings.d.ts +14 -0
- package/dist/config/compiler/bindings.d.ts.map +1 -0
- package/dist/config/compiler/core-helpers.d.ts +6 -0
- package/dist/config/compiler/core-helpers.d.ts.map +1 -0
- package/dist/config/compiler/do-workers.d.ts +34 -0
- package/dist/config/compiler/do-workers.d.ts.map +1 -0
- package/dist/config/compiler/paths.d.ts +18 -0
- package/dist/config/compiler/paths.d.ts.map +1 -0
- package/dist/config/compiler/types.d.ts +298 -0
- package/dist/config/compiler/types.d.ts.map +1 -0
- package/dist/config/compiler.d.ts +22 -134
- package/dist/config/compiler.d.ts.map +1 -1
- package/dist/config/cron.d.ts +19 -0
- package/dist/config/cron.d.ts.map +1 -0
- package/dist/config/define.d.ts +8 -5
- package/dist/config/define.d.ts.map +1 -1
- package/dist/config/deploy-resources.d.ts +58 -0
- package/dist/config/deploy-resources.d.ts.map +1 -0
- package/dist/config/env-vars.d.ts +309 -0
- package/dist/config/env-vars.d.ts.map +1 -0
- package/dist/config/framework-providers.d.ts +9 -0
- package/dist/config/framework-providers.d.ts.map +1 -0
- package/dist/config/index.d.ts +12 -5
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/loader.d.ts +2 -1
- package/dist/config/loader.d.ts.map +1 -1
- package/dist/config/local-dev-vars.d.ts +15 -0
- package/dist/config/local-dev-vars.d.ts.map +1 -0
- package/dist/config/preview-resources.d.ts +83 -0
- package/dist/config/preview-resources.d.ts.map +1 -0
- package/dist/config/preview.d.ts +29 -0
- package/dist/config/preview.d.ts.map +1 -0
- package/dist/config/ref.d.ts +16 -25
- package/dist/config/ref.d.ts.map +1 -1
- package/dist/config/resolve-phased.d.ts +72 -0
- package/dist/config/resolve-phased.d.ts.map +1 -0
- package/dist/config/resolve.d.ts +11 -0
- package/dist/config/resolve.d.ts.map +1 -0
- package/dist/config/resource-resolution.d.ts +80 -0
- package/dist/config/resource-resolution.d.ts.map +1 -0
- package/dist/config/schema-bindings.d.ts +2025 -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 +3579 -0
- package/dist/config/schema-env.d.ts.map +1 -0
- package/dist/config/schema-normalization.d.ts +265 -0
- package/dist/config/schema-normalization.d.ts.map +1 -0
- package/dist/config/schema-runtime.d.ts +508 -0
- package/dist/config/schema-runtime.d.ts.map +1 -0
- package/dist/config/schema-types-bindings-platform.d.ts +508 -0
- package/dist/config/schema-types-bindings-platform.d.ts.map +1 -0
- package/dist/config/schema-types-bindings-resources.d.ts +767 -0
- package/dist/config/schema-types-bindings-resources.d.ts.map +1 -0
- package/dist/config/schema-types-bindings.d.ts +293 -0
- package/dist/config/schema-types-bindings.d.ts.map +1 -0
- package/dist/config/schema-types-build.d.ts +86 -0
- package/dist/config/schema-types-build.d.ts.map +1 -0
- package/dist/config/schema-types-runtime.d.ts +917 -0
- package/dist/config/schema-types-runtime.d.ts.map +1 -0
- package/dist/config/schema-types.d.ts +424 -0
- package/dist/config/schema-types.d.ts.map +1 -0
- package/dist/config/schema.d.ts +5324 -2011
- 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-entry.d.ts +7 -0
- package/dist/config-entry.d.ts.map +1 -0
- package/dist/config-entry.js +3 -0
- package/dist/decorators/durable-object.d.ts.map +1 -1
- package/dist/decorators/index.d.ts +2 -2
- package/dist/decorators/index.js +2 -9
- package/dist/dev-server/d1-migrations.d.ts +36 -0
- package/dist/dev-server/d1-migrations.d.ts.map +1 -0
- package/dist/dev-server/dev-server-state.d.ts +59 -0
- package/dist/dev-server/dev-server-state.d.ts.map +1 -0
- package/dist/dev-server/gateway-script.d.ts +21 -0
- package/dist/dev-server/gateway-script.d.ts.map +1 -0
- package/dist/dev-server/index.d.ts +1 -1
- package/dist/dev-server/miniflare-bindings.d.ts +81 -0
- package/dist/dev-server/miniflare-bindings.d.ts.map +1 -0
- package/dist/dev-server/miniflare-dev-config.d.ts +36 -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 +82 -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 +19 -1
- package/dist/dev-server/vite-utils.d.ts.map +1 -1
- package/dist/dev-server/worker-source-watcher.d.ts +17 -0
- package/dist/dev-server/worker-source-watcher.d.ts.map +1 -0
- package/dist/dev-server/worker-surface-paths.d.ts +6 -0
- package/dist/dev-server/worker-surface-paths.d.ts.map +1 -0
- package/dist/env.d.ts +10 -0
- package/dist/env.d.ts.map +1 -1
- package/dist/index.d.ts +8 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -298
- package/dist/runtime/context-events.d.ts +13 -0
- package/dist/runtime/context-events.d.ts.map +1 -0
- package/dist/runtime/context-types.d.ts +82 -0
- package/dist/runtime/context-types.d.ts.map +1 -0
- package/dist/runtime/context.d.ts +20 -44
- package/dist/runtime/context.d.ts.map +1 -1
- package/dist/runtime/exports.d.ts +70 -55
- package/dist/runtime/exports.d.ts.map +1 -1
- package/dist/runtime/index.d.ts +10 -3
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +5 -111
- package/dist/runtime/middleware.d.ts +119 -67
- 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/validation.d.ts +18 -4
- package/dist/runtime/validation.d.ts.map +1 -1
- package/dist/secrets/local-secrets.d.ts +46 -0
- package/dist/secrets/local-secrets.d.ts.map +1 -0
- package/dist/shims/local-hyperdrive.d.ts +12 -0
- package/dist/shims/local-hyperdrive.d.ts.map +1 -0
- package/dist/shims/local-media-bindings.d.ts +19 -0
- package/dist/shims/local-media-bindings.d.ts.map +1 -0
- package/dist/shims/local-worker-loader.d.ts +3 -0
- package/dist/shims/local-worker-loader.d.ts.map +1 -0
- package/dist/sveltekit/index.d.ts +1 -1
- package/dist/sveltekit/index.d.ts.map +1 -1
- package/dist/sveltekit/index.js +313 -167
- 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 +20 -2
- package/dist/sveltekit/platform.d.ts.map +1 -1
- package/dist/test/ai-search.d.ts +39 -0
- package/dist/test/ai-search.d.ts.map +1 -0
- package/dist/test/alarm.d.ts +55 -0
- package/dist/test/alarm.d.ts.map +1 -0
- package/dist/test/binding-hints.d.ts +10 -0
- package/dist/test/binding-hints.d.ts.map +1 -0
- package/dist/test/cf.d.ts +71 -35
- package/dist/test/cf.d.ts.map +1 -1
- package/dist/test/containers.d.ts +87 -0
- package/dist/test/containers.d.ts.map +1 -0
- package/dist/test/email.d.ts +16 -7
- package/dist/test/email.d.ts.map +1 -1
- package/dist/test/index.d.ts +20 -21
- package/dist/test/index.d.ts.map +1 -1
- package/dist/test/index.js +4971 -70
- package/dist/test/offline-bindings.d.ts +115 -0
- package/dist/test/offline-bindings.d.ts.map +1 -0
- package/dist/test/queue.d.ts.map +1 -1
- package/dist/test/remote-ai.d.ts.map +1 -1
- package/dist/test/remote-cloudflare.d.ts +13 -0
- package/dist/test/remote-cloudflare.d.ts.map +1 -0
- package/dist/test/remote-vectorize.d.ts.map +1 -1
- package/dist/test/resolve-service-bindings.d.ts +64 -4
- package/dist/test/resolve-service-bindings.d.ts.map +1 -1
- package/dist/test/scheduled.d.ts.map +1 -1
- package/dist/test/should-skip.d.ts +14 -18
- package/dist/test/should-skip.d.ts.map +1 -1
- package/dist/test/simple-context-bindings.d.ts +13 -0
- package/dist/test/simple-context-bindings.d.ts.map +1 -0
- package/dist/test/simple-context-durable-objects.d.ts +6 -0
- package/dist/test/simple-context-durable-objects.d.ts.map +1 -0
- package/dist/test/simple-context-env.d.ts +35 -0
- package/dist/test/simple-context-env.d.ts.map +1 -0
- package/dist/test/simple-context-gateway-script.d.ts +2 -0
- package/dist/test/simple-context-gateway-script.d.ts.map +1 -0
- package/dist/test/simple-context-handlers.d.ts +12 -0
- package/dist/test/simple-context-handlers.d.ts.map +1 -0
- package/dist/test/simple-context-lifecycle.d.ts +32 -0
- package/dist/test/simple-context-lifecycle.d.ts.map +1 -0
- package/dist/test/simple-context-mfconfig.d.ts +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 +8 -27
- package/dist/test/simple-context.d.ts.map +1 -1
- package/dist/test/tail.d.ts +3 -2
- package/dist/test/tail.d.ts.map +1 -1
- package/dist/test/utilities/analytics-engine.d.ts +22 -0
- package/dist/test/utilities/analytics-engine.d.ts.map +1 -0
- package/dist/test/utilities/artifacts.d.ts +11 -0
- package/dist/test/utilities/artifacts.d.ts.map +1 -0
- package/dist/test/utilities/context.d.ts +39 -0
- package/dist/test/utilities/context.d.ts.map +1 -0
- package/dist/test/utilities/d1.d.ts +21 -0
- package/dist/test/utilities/d1.d.ts.map +1 -0
- package/dist/test/utilities/env.d.ts +43 -0
- package/dist/test/utilities/env.d.ts.map +1 -0
- package/dist/test/utilities/kv.d.ts +11 -0
- package/dist/test/utilities/kv.d.ts.map +1 -0
- package/dist/test/utilities/media.d.ts +16 -0
- package/dist/test/utilities/media.d.ts.map +1 -0
- package/dist/test/utilities/platform.d.ts +41 -0
- package/dist/test/utilities/platform.d.ts.map +1 -0
- package/dist/test/utilities/queue.d.ts +5 -0
- package/dist/test/utilities/queue.d.ts.map +1 -0
- package/dist/test/utilities/r2.d.ts +2 -0
- package/dist/test/utilities/r2.d.ts.map +1 -0
- package/dist/test/utilities/stream-flagship.d.ts +27 -0
- package/dist/test/utilities/stream-flagship.d.ts.map +1 -0
- package/dist/test/utilities/vectorize.d.ts +38 -0
- package/dist/test/utilities/vectorize.d.ts.map +1 -0
- package/dist/test/utilities/workflows.d.ts +26 -0
- package/dist/test/utilities/workflows.d.ts.map +1 -0
- package/dist/test/utilities.d.ts +13 -98
- package/dist/test/utilities.d.ts.map +1 -1
- package/dist/test/worker.d.ts +6 -0
- package/dist/test/worker.d.ts.map +1 -1
- package/dist/transform/durable-object.d.ts.map +1 -1
- package/dist/transform/index.d.ts +2 -2
- package/dist/transform/worker-entrypoint.d.ts +5 -0
- package/dist/transform/worker-entrypoint.d.ts.map +1 -1
- package/dist/utils/entrypoint-discovery.d.ts +6 -3
- package/dist/utils/entrypoint-discovery.d.ts.map +1 -1
- package/dist/utils/glob.d.ts.map +1 -1
- package/dist/utils/resolve-package.d.ts.map +1 -1
- package/dist/utils/send-email.d.ts +15 -0
- package/dist/utils/send-email.d.ts.map +1 -0
- package/dist/utils/send-email.js +163 -0
- package/dist/vite/config-file.d.ts +25 -0
- package/dist/vite/config-file.d.ts.map +1 -0
- package/dist/vite/index.d.ts +3 -2
- package/dist/vite/index.d.ts.map +1 -1
- package/dist/vite/index.js +2 -339
- package/dist/vite/plugin-config-hook.d.ts +28 -0
- package/dist/vite/plugin-config-hook.d.ts.map +1 -0
- package/dist/vite/plugin-context.d.ts +27 -0
- package/dist/vite/plugin-context.d.ts.map +1 -0
- package/dist/vite/plugin-durable-objects.d.ts +18 -0
- package/dist/vite/plugin-durable-objects.d.ts.map +1 -0
- package/dist/vite/plugin-programmatic.d.ts +44 -0
- package/dist/vite/plugin-programmatic.d.ts.map +1 -0
- package/dist/vite/plugin-service-bindings.d.ts +13 -0
- package/dist/vite/plugin-service-bindings.d.ts.map +1 -0
- package/dist/vite/plugin-transform.d.ts +41 -0
- package/dist/vite/plugin-transform.d.ts.map +1 -0
- package/dist/vite/plugin.d.ts +10 -41
- package/dist/vite/plugin.d.ts.map +1 -1
- package/dist/worker-entry/composed-worker.d.ts +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-entry/validate-fetch-style.d.ts +12 -0
- package/dist/worker-entry/validate-fetch-style.d.ts.map +1 -0
- package/dist/workflows/local-workflow-entrypoints.d.ts +7 -0
- package/dist/workflows/local-workflow-entrypoints.d.ts.map +1 -0
- package/package.json +159 -116
- package/R2.md +0 -170
- package/dist/account-rvrj687w.js +0 -397
- package/dist/ai-dx4fr9jh.js +0 -107
- package/dist/bridge/protocol.d.ts.map +0 -1
- package/dist/bridge/serialization.d.ts.map +0 -1
- package/dist/browser-shim/worker.d.ts +0 -14
- package/dist/browser-shim/worker.d.ts.map +0 -1
- package/dist/build-mnf6v8gd.js +0 -53
- package/dist/deploy-nhceck39.js +0 -70
- package/dist/dev-b9dmrj7b.js +0 -2417
- package/dist/doctor-fmgb3d28.js +0 -190
- package/dist/durable-object-t4kbb0yt.js +0 -13
- package/dist/index-07q6yxyc.js +0 -168
- package/dist/index-18hvb6gb.js +0 -194
- package/dist/index-1xpj0m4r.js +0 -57
- package/dist/index-37x76zdn.js +0 -4
- package/dist/index-3t6rypgc.js +0 -13
- package/dist/index-67qcae0f.js +0 -183
- package/dist/index-a855bdsx.js +0 -18
- package/dist/index-d8bdkx2h.js +0 -109
- package/dist/index-ep3445yc.js +0 -2225
- package/dist/index-gz1gndna.js +0 -307
- package/dist/index-hcex3rgh.js +0 -266
- package/dist/index-m2q41jwa.js +0 -462
- package/dist/index-n7rs26ft.js +0 -77
- package/dist/index-pf5s73n9.js +0 -1413
- package/dist/index-rbht7m9r.js +0 -36
- package/dist/index-tfyxa77h.js +0 -850
- package/dist/index-tk6ej9dj.js +0 -94
- package/dist/index-z14anrqp.js +0 -226
- package/dist/init-f9mgmew3.js +0 -186
- package/dist/remote-q59qk463.js +0 -97
- package/dist/test/bridge-context.d.ts +0 -76
- package/dist/test/bridge-context.d.ts.map +0 -1
- package/dist/test/multi-worker-context.d.ts +0 -114
- package/dist/test/multi-worker-context.d.ts.map +0 -1
- package/dist/types-5nyrz1sz.js +0 -454
- package/dist/worker-entrypoint-m9th0rg0.js +0 -13
|
@@ -0,0 +1,550 @@
|
|
|
1
|
+
import { D as createFetchEvent, b as createContextProxy, n as getContextOrNull, v as runWithEventContext } from "./context-CX50Y2Kb.js";
|
|
2
|
+
//#region src/runtime/exports.ts
|
|
3
|
+
/**
|
|
4
|
+
* Creates a readonly proxy that throws on mutation attempts. Thin wrapper
|
|
5
|
+
* over {@link createContextProxy} with `mutable: false`.
|
|
6
|
+
*/
|
|
7
|
+
function createReadonlyProxy(getter, name) {
|
|
8
|
+
return createContextProxy(getter, name, { mutable: false });
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Access environment bindings (KV, D1, R2, etc.) and variables
|
|
12
|
+
*
|
|
13
|
+
* @remarks
|
|
14
|
+
* This is readonly - bindings cannot be reassigned at runtime.
|
|
15
|
+
* Available only within an active Devflare-managed handler or middleware call trail.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* import { env, type FetchEvent } from 'devflare/runtime'
|
|
20
|
+
*
|
|
21
|
+
* export async function fetch(event: FetchEvent) {
|
|
22
|
+
* const value = await env.MY_KV.get('key')
|
|
23
|
+
* const dbResult = await env.DB.prepare('SELECT * FROM users').all()
|
|
24
|
+
* return new Response(JSON.stringify({
|
|
25
|
+
* path: event.url.pathname,
|
|
26
|
+
* value,
|
|
27
|
+
* dbResult
|
|
28
|
+
* }))
|
|
29
|
+
* }
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* @throws {ContextAccessError} When accessed outside an active Devflare-managed handler trail
|
|
33
|
+
*/
|
|
34
|
+
const env = createReadonlyProxy(() => getContextOrNull()?.env, "env");
|
|
35
|
+
/**
|
|
36
|
+
* Access typed runtime variables declared with `defineConfig({ vars })`.
|
|
37
|
+
*
|
|
38
|
+
* @remarks
|
|
39
|
+
* This proxy reads from the active Worker environment object, just like
|
|
40
|
+
* {@link env}, but its type is generated from the `vars` config lane. Nested
|
|
41
|
+
* values are preserved, so `vars.mongo.database` works when config declares a
|
|
42
|
+
* nested object.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```ts
|
|
46
|
+
* import { vars } from 'devflare/runtime'
|
|
47
|
+
*
|
|
48
|
+
* export async function fetch() {
|
|
49
|
+
* return Response.json({
|
|
50
|
+
* database: vars.mongo.database
|
|
51
|
+
* })
|
|
52
|
+
* }
|
|
53
|
+
* ```
|
|
54
|
+
*
|
|
55
|
+
* @throws {ContextAccessError} When accessed outside an active Devflare-managed handler trail
|
|
56
|
+
*/
|
|
57
|
+
const vars = createReadonlyProxy(() => getContextOrNull()?.env, "vars");
|
|
58
|
+
/**
|
|
59
|
+
* Access the ExecutionContext for background tasks
|
|
60
|
+
*
|
|
61
|
+
* @remarks
|
|
62
|
+
* Provides `waitUntil()` for background processing and
|
|
63
|
+
* `passThroughOnException()` for error handling on worker surfaces.
|
|
64
|
+
* When running inside a Durable Object, this proxy exposes the current
|
|
65
|
+
* `DurableObjectState` instead.
|
|
66
|
+
* This is readonly.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```ts
|
|
70
|
+
* import { ctx, type FetchEvent } from 'devflare/runtime'
|
|
71
|
+
*
|
|
72
|
+
* export async function fetch(event: FetchEvent) {
|
|
73
|
+
* const response = new Response('OK')
|
|
74
|
+
* ctx.waitUntil(analytics.track(event.url.pathname))
|
|
75
|
+
* return response
|
|
76
|
+
* }
|
|
77
|
+
* ```
|
|
78
|
+
*
|
|
79
|
+
* @throws {ContextAccessError} When accessed outside an active Devflare-managed handler trail
|
|
80
|
+
*/
|
|
81
|
+
const ctx = createReadonlyProxy(() => getContextOrNull()?.ctx, "ctx");
|
|
82
|
+
/**
|
|
83
|
+
* Access the current event object.
|
|
84
|
+
*
|
|
85
|
+
* @remarks
|
|
86
|
+
* This is the generic event proxy for the active AsyncLocalStorage context.
|
|
87
|
+
*
|
|
88
|
+
* For strong per-surface typing, prefer `getFetchEvent()`, `getQueueEvent()`,
|
|
89
|
+
* `getScheduledEvent()`, `getEmailEvent()`, and the Durable Object getters
|
|
90
|
+
* from `devflare/runtime`.
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```ts
|
|
94
|
+
* import { event as runtimeEvent, type FetchEvent, type ScheduledEvent } from 'devflare/runtime'
|
|
95
|
+
*
|
|
96
|
+
* export async function fetch(event: FetchEvent) {
|
|
97
|
+
* console.log(runtimeEvent.type)
|
|
98
|
+
* console.log(event.url.pathname)
|
|
99
|
+
* }
|
|
100
|
+
*
|
|
101
|
+
* export async function scheduled(event: ScheduledEvent) {
|
|
102
|
+
* console.log(runtimeEvent.type)
|
|
103
|
+
* console.log(event.cron)
|
|
104
|
+
* }
|
|
105
|
+
* ```
|
|
106
|
+
*
|
|
107
|
+
* @throws {ContextAccessError} When accessed outside an active Devflare-managed handler trail
|
|
108
|
+
*/
|
|
109
|
+
const event = createReadonlyProxy(() => getContextOrNull()?.event, "event");
|
|
110
|
+
/**
|
|
111
|
+
* Mutable request-scoped storage for sharing data between middleware
|
|
112
|
+
*
|
|
113
|
+
* @remarks
|
|
114
|
+
* Unlike `env` and `ctx`, locals can be mutated. Each request gets
|
|
115
|
+
* a fresh locals object. Use this for:
|
|
116
|
+
* - Authentication state
|
|
117
|
+
* - Parsed request data
|
|
118
|
+
* - Computed values shared across middleware
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* ```ts
|
|
122
|
+
* import { locals, type FetchEvent } from 'devflare/runtime'
|
|
123
|
+
*
|
|
124
|
+
* // In auth middleware
|
|
125
|
+
* const authMiddleware = async (event: FetchEvent, next: () => Promise<Response>) => {
|
|
126
|
+
* locals.user = await validateToken(event.request?.headers.get('Authorization'))
|
|
127
|
+
* return next()
|
|
128
|
+
* }
|
|
129
|
+
*
|
|
130
|
+
* // In handler
|
|
131
|
+
* export async function fetch(event: FetchEvent) {
|
|
132
|
+
* void event
|
|
133
|
+
* console.log(locals.user)
|
|
134
|
+
* }
|
|
135
|
+
* ```
|
|
136
|
+
*
|
|
137
|
+
* @throws {ContextAccessError} When accessed outside an active Devflare-managed handler trail
|
|
138
|
+
*/
|
|
139
|
+
const locals = createContextProxy(() => getContextOrNull()?.locals, "locals");
|
|
140
|
+
//#endregion
|
|
141
|
+
//#region src/runtime/middleware.ts
|
|
142
|
+
const FETCH_SEQUENCE_SYMBOL = Symbol.for("devflare.fetch-sequence");
|
|
143
|
+
const FETCH_RESOLVE_STYLE_SYMBOL = Symbol.for("devflare.fetch-resolve-style");
|
|
144
|
+
const FETCH_WORKER_STYLE_SYMBOL = Symbol.for("devflare.fetch-worker-style");
|
|
145
|
+
const QUEUE_WORKER_STYLE_SYMBOL = Symbol.for("devflare.queue-worker-style");
|
|
146
|
+
const SCHEDULED_WORKER_STYLE_SYMBOL = Symbol.for("devflare.scheduled-worker-style");
|
|
147
|
+
function createNotFoundResponse() {
|
|
148
|
+
return new Response("Not Found", { status: 404 });
|
|
149
|
+
}
|
|
150
|
+
function isFunction(value) {
|
|
151
|
+
return typeof value === "function";
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Tag a handler as resolve-style: `(event, resolve) => Response`.
|
|
155
|
+
*
|
|
156
|
+
* Attaches `FETCH_RESOLVE_STYLE_SYMBOL` so detection survives minification
|
|
157
|
+
* (which rewrites parameter names and function source output).
|
|
158
|
+
*/
|
|
159
|
+
function markResolveStyle(handler) {
|
|
160
|
+
Object.defineProperty(handler, FETCH_RESOLVE_STYLE_SYMBOL, {
|
|
161
|
+
value: true,
|
|
162
|
+
enumerable: false,
|
|
163
|
+
configurable: true,
|
|
164
|
+
writable: false
|
|
165
|
+
});
|
|
166
|
+
return handler;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Tag a handler as worker-style: `(request, env)` or `(request, env, ctx)`.
|
|
170
|
+
*
|
|
171
|
+
* Required for 2-argument worker-style handlers because devflare can no
|
|
172
|
+
* longer disambiguate `(event, resolve)` vs `(request, env)` from arity
|
|
173
|
+
* alone — the parameter-name fallback was removed in R1-strict.
|
|
174
|
+
*/
|
|
175
|
+
function markWorkerStyle(handler) {
|
|
176
|
+
Object.defineProperty(handler, FETCH_WORKER_STYLE_SYMBOL, {
|
|
177
|
+
value: true,
|
|
178
|
+
enumerable: false,
|
|
179
|
+
configurable: true,
|
|
180
|
+
writable: false
|
|
181
|
+
});
|
|
182
|
+
return handler;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Explicit escape hatch for declaring a handler's calling convention.
|
|
186
|
+
*
|
|
187
|
+
* - `options.style === 'resolve'` marks the handler so it is dispatched as
|
|
188
|
+
* `(event, resolve) => Response`.
|
|
189
|
+
* - `options.style === 'worker'` marks the handler so it is dispatched as
|
|
190
|
+
* `(request, env[, ctx]) => Response`.
|
|
191
|
+
*
|
|
192
|
+
* The marker is required for 2-argument handlers; 1-arg `(event)` and
|
|
193
|
+
* 3-arg `(request, env, ctx)` handlers do not need to be wrapped.
|
|
194
|
+
*/
|
|
195
|
+
function defineFetchHandler(handler, options) {
|
|
196
|
+
if (options?.style === "resolve") return markResolveStyle(handler);
|
|
197
|
+
if (options?.style === "worker") return markWorkerStyle(handler);
|
|
198
|
+
return handler;
|
|
199
|
+
}
|
|
200
|
+
function hasResolveStyleMarker(handler) {
|
|
201
|
+
const record = handler;
|
|
202
|
+
return Boolean(record[FETCH_RESOLVE_STYLE_SYMBOL] || record[FETCH_SEQUENCE_SYMBOL]);
|
|
203
|
+
}
|
|
204
|
+
function hasWorkerStyleMarker(handler) {
|
|
205
|
+
return Boolean(handler[FETCH_WORKER_STYLE_SYMBOL]);
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Detect resolve-style `(event, resolve) => Response` handlers.
|
|
209
|
+
*
|
|
210
|
+
* Symbol-based only — the previous parameter-name fallback was removed in
|
|
211
|
+
* R1-strict. Callers that rely on a 2-argument resolve-style handler must
|
|
212
|
+
* wrap it with `markResolveStyle`, `defineFetchHandler({ style: 'resolve' })`,
|
|
213
|
+
* or compose it via `sequence(...)`.
|
|
214
|
+
*/
|
|
215
|
+
function isResolveStyleFunction(handler) {
|
|
216
|
+
return hasResolveStyleMarker(handler);
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Throw a clear error for ambiguous unmarked 2-argument fetch handlers.
|
|
220
|
+
*
|
|
221
|
+
* In R1-strict, devflare no longer guesses the calling convention from
|
|
222
|
+
* parameter names. 2-arg handlers must be marked with
|
|
223
|
+
* `defineFetchHandler(fn, { style: 'resolve' | 'worker' })` (or wrapped via
|
|
224
|
+
* `markResolveStyle` / `markWorkerStyle` / `sequence(...)`) so dispatch is
|
|
225
|
+
* unambiguous and minification-safe.
|
|
226
|
+
*/
|
|
227
|
+
function assertExplicit2ArgStyle(handler) {
|
|
228
|
+
if (handler.length !== 2) return;
|
|
229
|
+
if (hasResolveStyleMarker(handler) || hasWorkerStyleMarker(handler)) return;
|
|
230
|
+
throw new Error("[devflare] Ambiguous 2-argument fetch handler. The calling convention must be declared explicitly via `defineFetchHandler(fn, { style: 'resolve' })` (for `(event, resolve) => Response`) or `defineFetchHandler(fn, { style: 'worker' })` (for `(request, env) => Response`). Single-arg `(event) => Response` and 3-arg worker-style `(request, env, ctx) => Response` handlers do not require wrapping.");
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Tag a queue handler as worker-style: `(batch, env)` or `(batch, env, ctx)`.
|
|
234
|
+
*
|
|
235
|
+
* Required for 2-argument worker-style queue handlers because devflare can
|
|
236
|
+
* no longer disambiguate `(event)` vs `(batch, env)` from arity alone in
|
|
237
|
+
* R1-strict.
|
|
238
|
+
*/
|
|
239
|
+
function defineQueueHandler(handler) {
|
|
240
|
+
Object.defineProperty(handler, QUEUE_WORKER_STYLE_SYMBOL, {
|
|
241
|
+
value: true,
|
|
242
|
+
enumerable: false,
|
|
243
|
+
configurable: true,
|
|
244
|
+
writable: false
|
|
245
|
+
});
|
|
246
|
+
return handler;
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Tag a scheduled handler as worker-style: `(controller, env)` or
|
|
250
|
+
* `(controller, env, ctx)`.
|
|
251
|
+
*/
|
|
252
|
+
function defineScheduledHandler(handler) {
|
|
253
|
+
Object.defineProperty(handler, SCHEDULED_WORKER_STYLE_SYMBOL, {
|
|
254
|
+
value: true,
|
|
255
|
+
enumerable: false,
|
|
256
|
+
configurable: true,
|
|
257
|
+
writable: false
|
|
258
|
+
});
|
|
259
|
+
return handler;
|
|
260
|
+
}
|
|
261
|
+
function hasQueueWorkerStyleMarker(handler) {
|
|
262
|
+
return Boolean(handler[QUEUE_WORKER_STYLE_SYMBOL]);
|
|
263
|
+
}
|
|
264
|
+
function hasScheduledWorkerStyleMarker(handler) {
|
|
265
|
+
return Boolean(handler[SCHEDULED_WORKER_STYLE_SYMBOL]);
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Throw a clear error for ambiguous unmarked 2-argument queue handlers.
|
|
269
|
+
*
|
|
270
|
+
* Mirrors `assertExplicit2ArgStyle` for the queue surface. 2-arg handlers
|
|
271
|
+
* must be wrapped with `defineQueueHandler(fn)` so dispatch is unambiguous
|
|
272
|
+
* and minification-safe; 1-arg `(event)` and 3-arg `(batch, env, ctx)` do
|
|
273
|
+
* not require wrapping.
|
|
274
|
+
*/
|
|
275
|
+
function assertExplicitQueueHandlerStyle(handler) {
|
|
276
|
+
if (handler.length !== 2) return;
|
|
277
|
+
if (hasQueueWorkerStyleMarker(handler)) return;
|
|
278
|
+
throw new Error("[devflare] Ambiguous 2-argument queue handler. The calling convention must be declared explicitly via `defineQueueHandler(fn)` for `(batch, env) => void` worker-style handlers. Single-arg `(event) => void` and 3-arg `(batch, env, ctx) => void` handlers do not require wrapping.");
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Throw a clear error for ambiguous unmarked 2-argument scheduled handlers.
|
|
282
|
+
*/
|
|
283
|
+
function assertExplicitScheduledHandlerStyle(handler) {
|
|
284
|
+
if (handler.length !== 2) return;
|
|
285
|
+
if (hasScheduledWorkerStyleMarker(handler)) return;
|
|
286
|
+
throw new Error("[devflare] Ambiguous 2-argument scheduled handler. The calling convention must be declared explicitly via `defineScheduledHandler(fn)` for `(controller, env) => void` worker-style handlers. Single-arg `(event) => void` and 3-arg `(controller, env, ctx) => void` handlers do not require wrapping.");
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Detect Cloudflare Worker-style `fetch(request, env[, ctx])` handlers.
|
|
290
|
+
*
|
|
291
|
+
* Returns true when:
|
|
292
|
+
* - arity is `>= 3` (unambiguous worker signature), or
|
|
293
|
+
* - the handler is explicitly marked worker-style via `markWorkerStyle` or
|
|
294
|
+
* `defineFetchHandler({ style: 'worker' })`.
|
|
295
|
+
*
|
|
296
|
+
* In R1-strict, 2-argument worker-style handlers must be marked — there is
|
|
297
|
+
* no parameter-name fallback. Unmarked 2-arg handlers throw via
|
|
298
|
+
* `assertExplicit2ArgStyle` when invoked.
|
|
299
|
+
*/
|
|
300
|
+
function isWorkerStyleFetchFunction(handler) {
|
|
301
|
+
if (isResolveStyleFunction(handler)) return false;
|
|
302
|
+
if (handler.length >= 3) return true;
|
|
303
|
+
return hasWorkerStyleMarker(handler);
|
|
304
|
+
}
|
|
305
|
+
function invokeWorkerStyleFetchFunction(handler, event) {
|
|
306
|
+
return handler(event.request, event.env, event.ctx);
|
|
307
|
+
}
|
|
308
|
+
function bindMethod(target, key) {
|
|
309
|
+
if (!target || typeof target !== "object") return null;
|
|
310
|
+
const value = target[key];
|
|
311
|
+
if (!isFunction(value)) return null;
|
|
312
|
+
const boundHandler = value.bind(target);
|
|
313
|
+
if (isResolveStyleFunction(value)) markResolveStyle(boundHandler);
|
|
314
|
+
if (hasWorkerStyleMarker(value)) markWorkerStyle(boundHandler);
|
|
315
|
+
return boundHandler;
|
|
316
|
+
}
|
|
317
|
+
function createFetchSequence(middlewares) {
|
|
318
|
+
return async (event, resolve = async () => createNotFoundResponse()) => {
|
|
319
|
+
const executeMiddleware = async (index, activeEvent) => {
|
|
320
|
+
if (index >= middlewares.length) return resolve(activeEvent);
|
|
321
|
+
const middleware = middlewares[index];
|
|
322
|
+
return middleware(activeEvent, async (nextEvent = activeEvent) => {
|
|
323
|
+
return executeMiddleware(index + 1, nextEvent);
|
|
324
|
+
});
|
|
325
|
+
};
|
|
326
|
+
return executeMiddleware(0, event);
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Compose request-wide middleware into a single fetch surface.
|
|
331
|
+
*/
|
|
332
|
+
function sequence(...middlewares) {
|
|
333
|
+
const composed = createFetchSequence(middlewares);
|
|
334
|
+
Object.defineProperty(composed, FETCH_SEQUENCE_SYMBOL, {
|
|
335
|
+
value: true,
|
|
336
|
+
enumerable: false,
|
|
337
|
+
configurable: false,
|
|
338
|
+
writable: false
|
|
339
|
+
});
|
|
340
|
+
return markResolveStyle(composed);
|
|
341
|
+
}
|
|
342
|
+
function getDefaultHandleHandler(module) {
|
|
343
|
+
return bindMethod(module.default, "handle");
|
|
344
|
+
}
|
|
345
|
+
function getDefaultFetchHandler(module) {
|
|
346
|
+
const defaultExport = module.default;
|
|
347
|
+
if (isFunction(defaultExport)) return defaultExport;
|
|
348
|
+
return bindMethod(defaultExport, "fetch");
|
|
349
|
+
}
|
|
350
|
+
function getPrimaryFetchEntryCandidates(module) {
|
|
351
|
+
const candidates = [];
|
|
352
|
+
const namedHandle = isFunction(module.handle) ? module.handle : null;
|
|
353
|
+
if (namedHandle) candidates.push({
|
|
354
|
+
name: "handle",
|
|
355
|
+
handler: namedHandle
|
|
356
|
+
});
|
|
357
|
+
const namedFetch = isFunction(module.fetch) ? module.fetch : null;
|
|
358
|
+
if (namedFetch) candidates.push({
|
|
359
|
+
name: "fetch",
|
|
360
|
+
handler: namedFetch
|
|
361
|
+
});
|
|
362
|
+
const defaultHandle = getDefaultHandleHandler(module);
|
|
363
|
+
if (defaultHandle) candidates.push({
|
|
364
|
+
name: "default.handle",
|
|
365
|
+
handler: defaultHandle
|
|
366
|
+
});
|
|
367
|
+
const defaultFetch = getDefaultFetchHandler(module);
|
|
368
|
+
if (defaultFetch) candidates.push({
|
|
369
|
+
name: isFunction(module.default) ? "default" : "default.fetch",
|
|
370
|
+
handler: defaultFetch
|
|
371
|
+
});
|
|
372
|
+
return candidates;
|
|
373
|
+
}
|
|
374
|
+
function assertSinglePrimaryFetchEntry(candidates) {
|
|
375
|
+
if (candidates.length <= 1) return;
|
|
376
|
+
const foundEntries = candidates.map(({ name }) => `"${name}"`).join(", ");
|
|
377
|
+
throw new Error(`Ambiguous fetch entry module. Export exactly one primary fetch entry per module. Use either "fetch" or "handle" (or one default equivalent), not both. Found: ${foundEntries}`);
|
|
378
|
+
}
|
|
379
|
+
function resolveMethodHandler(module, method) {
|
|
380
|
+
const normalizedMethod = method.toUpperCase();
|
|
381
|
+
const directHandler = isFunction(module[normalizedMethod]) ? module[normalizedMethod] : bindMethod(module.default, normalizedMethod);
|
|
382
|
+
if (directHandler) return {
|
|
383
|
+
handler: directHandler,
|
|
384
|
+
stripBody: false
|
|
385
|
+
};
|
|
386
|
+
if (normalizedMethod === "HEAD") {
|
|
387
|
+
const getHandler = isFunction(module.GET) ? module.GET : bindMethod(module.default, "GET");
|
|
388
|
+
if (getHandler) return {
|
|
389
|
+
handler: getHandler,
|
|
390
|
+
stripBody: true
|
|
391
|
+
};
|
|
392
|
+
}
|
|
393
|
+
const allHandler = isFunction(module.ALL) ? module.ALL : bindMethod(module.default, "ALL");
|
|
394
|
+
if (allHandler) return {
|
|
395
|
+
handler: allHandler,
|
|
396
|
+
stripBody: false
|
|
397
|
+
};
|
|
398
|
+
return null;
|
|
399
|
+
}
|
|
400
|
+
async function invokeResolvedFetchHandler(handler, event) {
|
|
401
|
+
if (isResolveStyleFunction(handler)) return handler(event, async () => createNotFoundResponse());
|
|
402
|
+
if (isWorkerStyleFetchFunction(handler)) return invokeWorkerStyleFetchFunction(handler, event);
|
|
403
|
+
assertExplicit2ArgStyle(handler);
|
|
404
|
+
return handler(event);
|
|
405
|
+
}
|
|
406
|
+
/**
|
|
407
|
+
* Resolve the primary fetch surface for a module.
|
|
408
|
+
*
|
|
409
|
+
* `fetch` and `handle` are treated as aliases for the same primary fetch
|
|
410
|
+
* entry. Exporting more than one primary entry from the same module is
|
|
411
|
+
* rejected as ambiguous.
|
|
412
|
+
*/
|
|
413
|
+
function resolveFetchHandler(module) {
|
|
414
|
+
const candidates = getPrimaryFetchEntryCandidates(module);
|
|
415
|
+
assertSinglePrimaryFetchEntry(candidates);
|
|
416
|
+
return candidates[0]?.handler ?? null;
|
|
417
|
+
}
|
|
418
|
+
/**
|
|
419
|
+
* Invoke a fetch entry handler with the supported calling conventions.
|
|
420
|
+
*
|
|
421
|
+
* This supports:
|
|
422
|
+
* - `fetch(request)`
|
|
423
|
+
* - `fetch(request, env)`
|
|
424
|
+
* - `fetch(request, env, ctx)`
|
|
425
|
+
* - `fetch(event)`
|
|
426
|
+
* - `fetch(event, resolve)` / `handle(event, resolve)`
|
|
427
|
+
*/
|
|
428
|
+
async function invokeFetchHandler(handler, event, resolve = async () => createNotFoundResponse()) {
|
|
429
|
+
if (!isFunction(handler)) return resolve(event);
|
|
430
|
+
if (isResolveStyleFunction(handler)) return await handler(event, resolve) ?? createNotFoundResponse();
|
|
431
|
+
if (isWorkerStyleFetchFunction(handler)) return await invokeWorkerStyleFetchFunction(handler, event) ?? createNotFoundResponse();
|
|
432
|
+
assertExplicit2ArgStyle(handler);
|
|
433
|
+
return await handler(event) ?? createNotFoundResponse();
|
|
434
|
+
}
|
|
435
|
+
/**
|
|
436
|
+
* Create a SvelteKit-style `resolve(event)` callback for a fetch module.
|
|
437
|
+
*
|
|
438
|
+
* Resolution order is:
|
|
439
|
+
* - matching HTTP method export such as `GET()` / `POST()` / `ALL()`
|
|
440
|
+
* - 404 response
|
|
441
|
+
*/
|
|
442
|
+
function createResolveFetch(module, _currentEntry, initialEvent, options = {}) {
|
|
443
|
+
return async (nextEvent = initialEvent) => {
|
|
444
|
+
return runWithEventContext(nextEvent, async () => {
|
|
445
|
+
const methodResolution = resolveMethodHandler(module, nextEvent.request.method);
|
|
446
|
+
if (methodResolution) {
|
|
447
|
+
const finalResponse = await invokeResolvedFetchHandler(methodResolution.handler, nextEvent) ?? createNotFoundResponse();
|
|
448
|
+
if (methodResolution.stripBody) return new Response(null, finalResponse);
|
|
449
|
+
return finalResponse;
|
|
450
|
+
}
|
|
451
|
+
if (options.fallbackResolve) return options.fallbackResolve(nextEvent);
|
|
452
|
+
return createNotFoundResponse();
|
|
453
|
+
});
|
|
454
|
+
};
|
|
455
|
+
}
|
|
456
|
+
/**
|
|
457
|
+
* Invoke the resolved fetch surface for a module.
|
|
458
|
+
*
|
|
459
|
+
* This lets runtime wrappers support a single request-wide `handle` or
|
|
460
|
+
* `fetch` export, default exports, and same-module method handlers such as
|
|
461
|
+
* `GET()`.
|
|
462
|
+
*/
|
|
463
|
+
async function invokeFetchModule(module, event, fallbackResolve) {
|
|
464
|
+
const handler = resolveFetchHandler(module);
|
|
465
|
+
if (!handler) return createResolveFetch(module, null, event, { fallbackResolve })(event);
|
|
466
|
+
return invokeFetchHandler(handler, event, createResolveFetch(module, handler, event, { fallbackResolve }));
|
|
467
|
+
}
|
|
468
|
+
//#endregion
|
|
469
|
+
//#region src/runtime/router/index.ts
|
|
470
|
+
function normalizePathname(pathname) {
|
|
471
|
+
if (!pathname || pathname === "/") return "/";
|
|
472
|
+
const trimmed = (pathname.startsWith("/") ? pathname : `/${pathname}`).replace(/\/+$|\/+$/g, "");
|
|
473
|
+
return trimmed === "" ? "/" : trimmed;
|
|
474
|
+
}
|
|
475
|
+
function decodePathSegment(segment) {
|
|
476
|
+
try {
|
|
477
|
+
return decodeURIComponent(segment);
|
|
478
|
+
} catch {
|
|
479
|
+
return segment;
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
function getPathSegments(pathname) {
|
|
483
|
+
const normalizedPathname = normalizePathname(pathname);
|
|
484
|
+
if (normalizedPathname === "/") return [];
|
|
485
|
+
return normalizedPathname.slice(1).split("/").filter(Boolean).map(decodePathSegment);
|
|
486
|
+
}
|
|
487
|
+
function getMatchPathname(input) {
|
|
488
|
+
if (input instanceof Request) return new URL(input.url).pathname;
|
|
489
|
+
if (input instanceof URL) return input.pathname;
|
|
490
|
+
if (input.includes("://")) return new URL(input).pathname;
|
|
491
|
+
return input;
|
|
492
|
+
}
|
|
493
|
+
function matchRouteSegments(routeSegments, pathnameSegments) {
|
|
494
|
+
if (routeSegments.length === 0) return pathnameSegments.length === 0 ? {} : null;
|
|
495
|
+
const params = {};
|
|
496
|
+
let routeIndex = 0;
|
|
497
|
+
let pathIndex = 0;
|
|
498
|
+
while (routeIndex < routeSegments.length) {
|
|
499
|
+
const routeSegment = routeSegments[routeIndex];
|
|
500
|
+
if (routeSegment.type === "optional-rest") {
|
|
501
|
+
params[routeSegment.name] = pathnameSegments.slice(pathIndex).join("/");
|
|
502
|
+
pathIndex = pathnameSegments.length;
|
|
503
|
+
routeIndex += 1;
|
|
504
|
+
continue;
|
|
505
|
+
}
|
|
506
|
+
if (routeSegment.type === "rest") {
|
|
507
|
+
if (pathIndex >= pathnameSegments.length) return null;
|
|
508
|
+
params[routeSegment.name] = pathnameSegments.slice(pathIndex).join("/");
|
|
509
|
+
pathIndex = pathnameSegments.length;
|
|
510
|
+
routeIndex += 1;
|
|
511
|
+
continue;
|
|
512
|
+
}
|
|
513
|
+
const pathnameSegment = pathnameSegments[pathIndex];
|
|
514
|
+
if (pathnameSegment === void 0) return null;
|
|
515
|
+
if (routeSegment.type === "static") {
|
|
516
|
+
if (pathnameSegment !== routeSegment.value) return null;
|
|
517
|
+
} else params[routeSegment.name] = pathnameSegment;
|
|
518
|
+
pathIndex += 1;
|
|
519
|
+
routeIndex += 1;
|
|
520
|
+
}
|
|
521
|
+
if (pathIndex !== pathnameSegments.length) return null;
|
|
522
|
+
return params;
|
|
523
|
+
}
|
|
524
|
+
function matchFetchRoute(routes, input) {
|
|
525
|
+
const pathnameSegments = getPathSegments(getMatchPathname(input));
|
|
526
|
+
for (const route of routes) {
|
|
527
|
+
const params = matchRouteSegments(route.segments, pathnameSegments);
|
|
528
|
+
if (params) return {
|
|
529
|
+
route,
|
|
530
|
+
params
|
|
531
|
+
};
|
|
532
|
+
}
|
|
533
|
+
return null;
|
|
534
|
+
}
|
|
535
|
+
async function invokeRouteModules(routes, event) {
|
|
536
|
+
const match = matchFetchRoute(routes, event.request);
|
|
537
|
+
if (!match) return new Response("Not Found", { status: 404 });
|
|
538
|
+
const routeEvent = createFetchEvent(event.request, event.env, event.ctx, {
|
|
539
|
+
params: match.params,
|
|
540
|
+
locals: event.locals
|
|
541
|
+
});
|
|
542
|
+
return runWithEventContext(routeEvent, () => invokeFetchModule(match.route.module, routeEvent));
|
|
543
|
+
}
|
|
544
|
+
function createRouteResolve(routes, initialEvent) {
|
|
545
|
+
return async (nextEvent = initialEvent) => {
|
|
546
|
+
return invokeRouteModules(routes, nextEvent);
|
|
547
|
+
};
|
|
548
|
+
}
|
|
549
|
+
//#endregion
|
|
550
|
+
export { ctx as _, assertExplicitQueueHandlerStyle as a, locals as b, defineFetchHandler as c, invokeFetchHandler as d, invokeFetchModule as f, sequence as g, resolveFetchHandler as h, assertExplicit2ArgStyle as i, defineQueueHandler as l, markWorkerStyle as m, invokeRouteModules as n, assertExplicitScheduledHandlerStyle as o, markResolveStyle as p, matchFetchRoute as r, createResolveFetch as s, createRouteResolve as t, defineScheduledHandler as u, env as v, vars as x, event as y };
|