devflare 1.0.0-next.7 → 1.0.0-next.70
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 +17315 -2144
- package/README.md +398 -607
- package/bin/devflare.js +30 -14
- package/dist/_chunks/account-BHY3fvrA.js +462 -0
- package/dist/_chunks/account-resources-BdKj8q1h.js +159 -0
- package/dist/_chunks/ai-CN_SREim.js +322 -0
- package/dist/_chunks/api-BKClUlUf.js +568 -0
- package/dist/_chunks/build-DplSo6Gc.js +24 -0
- package/dist/_chunks/build-artifacts-CkwCap5N.js +483 -0
- package/dist/_chunks/cli-ZJYtm-lW.js +1214 -0
- package/dist/_chunks/cloudflare-Ic5ubQza.js +157 -0
- package/dist/_chunks/colors-D0NVzAFN.js +13 -0
- package/dist/_chunks/command-utils-DjaaMQX7.js +45 -0
- package/dist/_chunks/compiler-UxXQgEPq.js +521 -0
- package/dist/_chunks/config-path-CYGlwKDs.js +42 -0
- package/dist/_chunks/config-zQd4jmXU.js +78 -0
- package/dist/_chunks/context-DGMev2AF.js +2515 -0
- package/dist/_chunks/decorators-eXNZ1S0N.js +19 -0
- package/dist/_chunks/dependencies-wKqrxKV_.js +57 -0
- package/dist/_chunks/deploy-z1_wbNn2.js +1032 -0
- package/dist/_chunks/dev-BagtFegV.js +952 -0
- package/dist/_chunks/doctor-CAsJ-rSZ.js +219 -0
- package/dist/_chunks/durable-object-DuMPM8re.js +234 -0
- package/dist/_chunks/env-D4uJqqgu.js +125 -0
- package/dist/_chunks/family-BTTpTwUk.js +143 -0
- package/dist/_chunks/generated-artifacts-Bb13pGUG.js +32 -0
- package/dist/_chunks/glob-DRw9sbfF.js +56 -0
- package/dist/_chunks/init-DJ5y3mu5.js +165 -0
- package/dist/_chunks/loader-BC0skbnH.js +1330 -0
- package/dist/_chunks/local-dev-vars-BFLS-HoI.js +81 -0
- package/dist/_chunks/local-hyperdrive-CcORzo76.js +119 -0
- package/dist/_chunks/local-media-bindings-ZQe-epuw.js +335 -0
- package/dist/_chunks/local-secrets-C0n5oRgI.js +123 -0
- package/dist/_chunks/login-CgNcbpEq.js +51 -0
- package/dist/_chunks/package-metadata-CLI488gB.js +39 -0
- package/dist/_chunks/preferences-CbYERA_m.js +241 -0
- package/dist/_chunks/preview-j9Kbx4-G.js +462 -0
- package/dist/_chunks/preview-registry-CTXU4mBc.js +1186 -0
- package/dist/_chunks/preview-resources-CQIu2-NY.js +359 -0
- package/dist/_chunks/previews-BIaw6NVC.js +1133 -0
- package/dist/_chunks/productions-CF8oQcX7.js +504 -0
- package/dist/_chunks/r2-presign-runtime-C75FkLMd.js +291 -0
- package/dist/_chunks/ref-CYJNAAe_.js +178 -0
- package/dist/_chunks/remote-8jEHLVGg.js +79 -0
- package/dist/_chunks/remote-config-Bw6qIVM4.js +132 -0
- package/dist/_chunks/resolve-package-DeJUGxoE.js +152 -0
- package/dist/_chunks/rolldown-runtime-CvQ6eiug.js +14 -0
- package/dist/_chunks/routes-CRXB3-iw.js +851 -0
- package/dist/_chunks/runtime-BlKTWIgD.js +874 -0
- package/dist/_chunks/schema-normalization-CTdiY17P.js +667 -0
- package/dist/_chunks/secrets-BJuEa9Jz.js +95 -0
- package/dist/_chunks/tail-DjGRt8gw.js +239 -0
- package/dist/_chunks/token-wmeF8-IQ.js +333 -0
- package/dist/_chunks/tokens-KaEr4B8e.js +221 -0
- package/dist/_chunks/types-BLGfxIq-.js +484 -0
- package/dist/_chunks/ui-BhCdDC2N.js +103 -0
- package/dist/_chunks/usage-rRusKejc.js +272 -0
- package/dist/_chunks/vite-Bml-Whp8.js +1267 -0
- package/dist/_chunks/vite-process-CDa3yQui.js +2929 -0
- package/dist/_chunks/vite-utils-D8kPPxUy.js +183 -0
- package/dist/_chunks/worker-DgczaXVW.js +410 -0
- package/dist/_chunks/worker-bundler-Isj5jiW6.js +458 -0
- package/dist/_chunks/worker-entrypoint-C8j23t6d.js +247 -0
- package/dist/_chunks/workerName-kEXwmV2m.js +23 -0
- package/dist/_chunks/workspace-CrvqPLTX.js +517 -0
- package/dist/_chunks/workspace-Ds3xMjOE.js +175 -0
- package/dist/bridge/client.d.ts +93 -8
- package/dist/bridge/client.d.ts.map +1 -1
- package/dist/bridge/do-rpc-dispatch.d.ts +23 -0
- package/dist/bridge/do-rpc-dispatch.d.ts.map +1 -0
- package/dist/bridge/do-websocket-connect.d.ts +33 -0
- package/dist/bridge/do-websocket-connect.d.ts.map +1 -0
- package/dist/bridge/gateway-runtime.d.ts +8 -0
- package/dist/bridge/gateway-runtime.d.ts.map +1 -0
- package/dist/bridge/index.d.ts +6 -6
- package/dist/bridge/index.d.ts.map +1 -1
- package/dist/bridge/log.d.ts +5 -0
- package/dist/bridge/log.d.ts.map +1 -0
- package/dist/bridge/miniflare-gateway.d.ts +45 -0
- package/dist/bridge/miniflare-gateway.d.ts.map +1 -0
- package/dist/bridge/miniflare.d.ts +92 -2
- package/dist/bridge/miniflare.d.ts.map +1 -1
- package/dist/bridge/proxy.d.ts +12 -11
- package/dist/bridge/proxy.d.ts.map +1 -1
- package/dist/bridge/r2-presign-runtime.d.ts +9 -0
- package/dist/bridge/r2-presign-runtime.d.ts.map +1 -0
- package/dist/bridge/server.d.ts +2 -1
- package/dist/bridge/server.d.ts.map +1 -1
- package/dist/bridge/v2/body-streams.d.ts +53 -0
- package/dist/bridge/v2/body-streams.d.ts.map +1 -0
- package/dist/bridge/v2/codec.d.ts +106 -0
- package/dist/bridge/v2/codec.d.ts.map +1 -0
- package/dist/bridge/v2/control-messages.d.ts +46 -0
- package/dist/bridge/v2/control-messages.d.ts.map +1 -0
- package/dist/bridge/v2/frames.d.ts +109 -0
- package/dist/bridge/v2/frames.d.ts.map +1 -0
- package/dist/bridge/v2/index.d.ts +11 -0
- package/dist/bridge/v2/index.d.ts.map +1 -0
- package/dist/bridge/v2/serialization.d.ts +48 -0
- package/dist/bridge/v2/serialization.d.ts.map +1 -0
- package/dist/bridge/v2/transport.d.ts +31 -0
- package/dist/bridge/v2/transport.d.ts.map +1 -0
- package/dist/bridge/v2/value-codec.d.ts +61 -0
- package/dist/bridge/v2/value-codec.d.ts.map +1 -0
- package/dist/bridge/v2/value-serialization.d.ts +139 -0
- package/dist/bridge/v2/value-serialization.d.ts.map +1 -0
- package/dist/bridge/{protocol.d.ts → v2/wire.d.ts} +32 -8
- package/dist/bridge/v2/wire.d.ts.map +1 -0
- package/dist/bridge/v2/ws-relay.d.ts +53 -0
- package/dist/bridge/v2/ws-relay.d.ts.map +1 -0
- package/dist/bridge/websocket-constructor.d.ts +38 -0
- package/dist/bridge/websocket-constructor.d.ts.map +1 -0
- package/dist/browser-shim/handler.d.ts +2 -2
- package/dist/browser-shim/handler.d.ts.map +1 -1
- package/dist/browser-shim/index.d.ts +2 -2
- package/dist/browser-shim/server.d.ts +63 -0
- package/dist/browser-shim/server.d.ts.map +1 -1
- package/dist/browser.d.ts +5778 -43
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +73 -142
- package/dist/bundler/defaults.d.ts +23 -0
- package/dist/bundler/defaults.d.ts.map +1 -0
- package/dist/bundler/do-bundler.d.ts +7 -0
- package/dist/bundler/do-bundler.d.ts.map +1 -1
- package/dist/bundler/index.d.ts +3 -1
- package/dist/bundler/index.d.ts.map +1 -1
- package/dist/bundler/rolldown-shared.d.ts +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/commands/workspace.d.ts +8 -0
- package/dist/cli/commands/workspace.d.ts.map +1 -0
- package/dist/cli/config-path.d.ts +6 -0
- package/dist/cli/config-path.d.ts.map +1 -0
- package/dist/cli/dependencies.d.ts +2 -1
- package/dist/cli/dependencies.d.ts.map +1 -1
- package/dist/cli/deploy-strategy.d.ts +17 -0
- package/dist/cli/deploy-strategy.d.ts.map +1 -0
- package/dist/cli/deploy-target.d.ts +17 -0
- package/dist/cli/deploy-target.d.ts.map +1 -0
- package/dist/cli/generated-artifacts.d.ts +12 -0
- package/dist/cli/generated-artifacts.d.ts.map +1 -0
- package/dist/cli/gradual-deploy.d.ts +49 -0
- package/dist/cli/gradual-deploy.d.ts.map +1 -0
- package/dist/cli/help-pages/pages/account.d.ts +3 -0
- package/dist/cli/help-pages/pages/account.d.ts.map +1 -0
- package/dist/cli/help-pages/pages/core.d.ts +4 -0
- package/dist/cli/help-pages/pages/core.d.ts.map +1 -0
- package/dist/cli/help-pages/pages/index.d.ts +3 -0
- package/dist/cli/help-pages/pages/index.d.ts.map +1 -0
- package/dist/cli/help-pages/pages/misc.d.ts +3 -0
- package/dist/cli/help-pages/pages/misc.d.ts.map +1 -0
- package/dist/cli/help-pages/pages/previews.d.ts +3 -0
- package/dist/cli/help-pages/pages/previews.d.ts.map +1 -0
- package/dist/cli/help-pages/pages/productions.d.ts +3 -0
- package/dist/cli/help-pages/pages/productions.d.ts.map +1 -0
- package/dist/cli/help-pages/render.d.ts +12 -0
- package/dist/cli/help-pages/render.d.ts.map +1 -0
- package/dist/cli/help-pages/shared.d.ts +15 -0
- package/dist/cli/help-pages/shared.d.ts.map +1 -0
- package/dist/cli/help-pages/types.d.ts +23 -0
- package/dist/cli/help-pages/types.d.ts.map +1 -0
- package/dist/cli/help.d.ts +6 -0
- package/dist/cli/help.d.ts.map +1 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +2 -0
- package/dist/cli/package-metadata.d.ts +16 -0
- package/dist/cli/package-metadata.d.ts.map +1 -0
- package/dist/cli/preview-bindings.d.ts +49 -0
- package/dist/cli/preview-bindings.d.ts.map +1 -0
- package/dist/cli/preview.d.ts +10 -0
- package/dist/cli/preview.d.ts.map +1 -0
- package/dist/cli/ui.d.ts +37 -0
- package/dist/cli/ui.d.ts.map +1 -0
- package/dist/cli/workspace-build-guard.d.ts +14 -0
- package/dist/cli/workspace-build-guard.d.ts.map +1 -0
- package/dist/cli/wrangler-auth.d.ts +1 -1
- package/dist/cloudflare/account-core.d.ts +6 -0
- package/dist/cloudflare/account-core.d.ts.map +1 -0
- package/dist/cloudflare/account-resources.d.ts +40 -0
- package/dist/cloudflare/account-resources.d.ts.map +1 -0
- package/dist/cloudflare/account-status.d.ts +11 -0
- package/dist/cloudflare/account-status.d.ts.map +1 -0
- package/dist/cloudflare/account-workers.d.ts +14 -0
- package/dist/cloudflare/account-workers.d.ts.map +1 -0
- package/dist/cloudflare/account.d.ts +7 -64
- package/dist/cloudflare/account.d.ts.map +1 -1
- package/dist/cloudflare/api.d.ts +71 -3
- package/dist/cloudflare/api.d.ts.map +1 -1
- package/dist/cloudflare/auth.d.ts +1 -1
- package/dist/cloudflare/auth.d.ts.map +1 -1
- package/dist/cloudflare/index.d.ts +61 -6
- package/dist/cloudflare/index.d.ts.map +1 -1
- package/dist/cloudflare/index.js +4 -13
- package/dist/cloudflare/known-permission-group-ids.generated.d.ts +10 -0
- package/dist/cloudflare/known-permission-group-ids.generated.d.ts.map +1 -0
- package/dist/cloudflare/kv-namespace.d.ts +4 -0
- package/dist/cloudflare/kv-namespace.d.ts.map +1 -0
- package/dist/cloudflare/preferences.d.ts +7 -0
- package/dist/cloudflare/preferences.d.ts.map +1 -1
- package/dist/cloudflare/preview-registry-cache.d.ts +6 -0
- package/dist/cloudflare/preview-registry-cache.d.ts.map +1 -0
- package/dist/cloudflare/preview-registry-inference.d.ts +14 -0
- package/dist/cloudflare/preview-registry-inference.d.ts.map +1 -0
- package/dist/cloudflare/preview-registry-records.d.ts +4 -0
- package/dist/cloudflare/preview-registry-records.d.ts.map +1 -0
- package/dist/cloudflare/preview-registry-shape.d.ts +47 -0
- package/dist/cloudflare/preview-registry-shape.d.ts.map +1 -0
- package/dist/cloudflare/preview-registry-store.d.ts +14 -0
- package/dist/cloudflare/preview-registry-store.d.ts.map +1 -0
- package/dist/cloudflare/preview-registry-transport.d.ts +4 -0
- package/dist/cloudflare/preview-registry-transport.d.ts.map +1 -0
- package/dist/cloudflare/preview-registry-types.d.ts +103 -0
- package/dist/cloudflare/preview-registry-types.d.ts.map +1 -0
- package/dist/cloudflare/preview-registry.d.ts +42 -0
- package/dist/cloudflare/preview-registry.d.ts.map +1 -0
- package/dist/cloudflare/preview-urls.d.ts +3 -0
- package/dist/cloudflare/preview-urls.d.ts.map +1 -0
- package/dist/cloudflare/registry-schema.d.ts +253 -0
- package/dist/cloudflare/registry-schema.d.ts.map +1 -0
- package/dist/cloudflare/remote-config.d.ts.map +1 -1
- package/dist/cloudflare/tokens.d.ts +44 -0
- package/dist/cloudflare/tokens.d.ts.map +1 -0
- package/dist/cloudflare/types.d.ts +124 -7
- package/dist/cloudflare/types.d.ts.map +1 -1
- package/dist/cloudflare/usage.d.ts +31 -3
- package/dist/cloudflare/usage.d.ts.map +1 -1
- package/dist/config/binding-resolution-helpers.d.ts +41 -0
- package/dist/config/binding-resolution-helpers.d.ts.map +1 -0
- package/dist/config/compatibility.d.ts +3 -0
- package/dist/config/compatibility.d.ts.map +1 -0
- package/dist/config/compiler/bindings.d.ts +14 -0
- package/dist/config/compiler/bindings.d.ts.map +1 -0
- package/dist/config/compiler/core-helpers.d.ts +6 -0
- package/dist/config/compiler/core-helpers.d.ts.map +1 -0
- package/dist/config/compiler/do-workers.d.ts +34 -0
- package/dist/config/compiler/do-workers.d.ts.map +1 -0
- package/dist/config/compiler/paths.d.ts +18 -0
- package/dist/config/compiler/paths.d.ts.map +1 -0
- package/dist/config/compiler/types.d.ts +308 -0
- package/dist/config/compiler/types.d.ts.map +1 -0
- package/dist/config/compiler.d.ts +22 -134
- package/dist/config/compiler.d.ts.map +1 -1
- package/dist/config/cron.d.ts +19 -0
- package/dist/config/cron.d.ts.map +1 -0
- package/dist/config/define.d.ts +8 -5
- package/dist/config/define.d.ts.map +1 -1
- package/dist/config/deploy-resources.d.ts +58 -0
- package/dist/config/deploy-resources.d.ts.map +1 -0
- package/dist/config/env-vars.d.ts +309 -0
- package/dist/config/env-vars.d.ts.map +1 -0
- package/dist/config/framework-providers.d.ts +9 -0
- package/dist/config/framework-providers.d.ts.map +1 -0
- package/dist/config/index.d.ts +13 -5
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/loader.d.ts +2 -1
- package/dist/config/loader.d.ts.map +1 -1
- package/dist/config/local-dev-vars.d.ts +15 -0
- package/dist/config/local-dev-vars.d.ts.map +1 -0
- package/dist/config/preview-resources.d.ts +83 -0
- package/dist/config/preview-resources.d.ts.map +1 -0
- package/dist/config/preview.d.ts +29 -0
- package/dist/config/preview.d.ts.map +1 -0
- package/dist/config/ref.d.ts +16 -25
- package/dist/config/ref.d.ts.map +1 -1
- package/dist/config/resolve-phased.d.ts +72 -0
- package/dist/config/resolve-phased.d.ts.map +1 -0
- package/dist/config/resolve.d.ts +11 -0
- package/dist/config/resolve.d.ts.map +1 -0
- package/dist/config/resource-resolution.d.ts +80 -0
- package/dist/config/resource-resolution.d.ts.map +1 -0
- package/dist/config/schema-bindings.d.ts +2124 -0
- package/dist/config/schema-bindings.d.ts.map +1 -0
- package/dist/config/schema-build.d.ts +67 -0
- package/dist/config/schema-build.d.ts.map +1 -0
- package/dist/config/schema-env.d.ts +3821 -0
- package/dist/config/schema-env.d.ts.map +1 -0
- package/dist/config/schema-normalization.d.ts +272 -0
- package/dist/config/schema-normalization.d.ts.map +1 -0
- package/dist/config/schema-runtime.d.ts +597 -0
- package/dist/config/schema-runtime.d.ts.map +1 -0
- package/dist/config/schema-types-bindings-platform.d.ts +520 -0
- package/dist/config/schema-types-bindings-platform.d.ts.map +1 -0
- package/dist/config/schema-types-bindings-resources.d.ts +802 -0
- package/dist/config/schema-types-bindings-resources.d.ts.map +1 -0
- package/dist/config/schema-types-bindings.d.ts +293 -0
- package/dist/config/schema-types-bindings.d.ts.map +1 -0
- package/dist/config/schema-types-build.d.ts +86 -0
- package/dist/config/schema-types-build.d.ts.map +1 -0
- package/dist/config/schema-types-runtime-server.d.ts +196 -0
- package/dist/config/schema-types-runtime-server.d.ts.map +1 -0
- package/dist/config/schema-types-runtime.d.ts +913 -0
- package/dist/config/schema-types-runtime.d.ts.map +1 -0
- package/dist/config/schema-types.d.ts +458 -0
- package/dist/config/schema-types.d.ts.map +1 -0
- package/dist/config/schema.d.ts +5796 -2023
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/config/service-bindings-validation.d.ts +36 -0
- package/dist/config/service-bindings-validation.d.ts.map +1 -0
- package/dist/config/workspace.d.ts +282 -0
- package/dist/config/workspace.d.ts.map +1 -0
- package/dist/config-entry.d.ts +7 -0
- package/dist/config-entry.d.ts.map +1 -0
- package/dist/config-entry.js +3 -0
- package/dist/decorators/durable-object.d.ts.map +1 -1
- package/dist/decorators/index.d.ts +2 -2
- package/dist/decorators/index.js +2 -9
- package/dist/dev-server/d1-migrations.d.ts +36 -0
- package/dist/dev-server/d1-migrations.d.ts.map +1 -0
- package/dist/dev-server/dev-server-state.d.ts +59 -0
- package/dist/dev-server/dev-server-state.d.ts.map +1 -0
- package/dist/dev-server/gateway-script.d.ts +22 -0
- package/dist/dev-server/gateway-script.d.ts.map +1 -0
- package/dist/dev-server/index.d.ts +1 -1
- package/dist/dev-server/miniflare-bindings.d.ts +90 -0
- package/dist/dev-server/miniflare-bindings.d.ts.map +1 -0
- package/dist/dev-server/miniflare-dev-config.d.ts +57 -0
- package/dist/dev-server/miniflare-dev-config.d.ts.map +1 -0
- package/dist/dev-server/miniflare-log.d.ts +20 -0
- package/dist/dev-server/miniflare-log.d.ts.map +1 -0
- package/dist/dev-server/miniflare-worker-config.d.ts +100 -0
- package/dist/dev-server/miniflare-worker-config.d.ts.map +1 -0
- package/dist/dev-server/reload-queue.d.ts +13 -0
- package/dist/dev-server/reload-queue.d.ts.map +1 -0
- package/dist/dev-server/runtime-health.d.ts +79 -0
- package/dist/dev-server/runtime-health.d.ts.map +1 -0
- package/dist/dev-server/runtime-stdio.d.ts +8 -0
- package/dist/dev-server/runtime-stdio.d.ts.map +1 -0
- package/dist/dev-server/server-startup-helpers.d.ts +84 -0
- package/dist/dev-server/server-startup-helpers.d.ts.map +1 -0
- package/dist/dev-server/server.d.ts +2 -0
- package/dist/dev-server/server.d.ts.map +1 -1
- package/dist/dev-server/vite-process.d.ts +24 -0
- package/dist/dev-server/vite-process.d.ts.map +1 -0
- package/dist/dev-server/vite-utils.d.ts +19 -1
- package/dist/dev-server/vite-utils.d.ts.map +1 -1
- package/dist/dev-server/worker-source-watcher.d.ts +17 -0
- package/dist/dev-server/worker-source-watcher.d.ts.map +1 -0
- package/dist/dev-server/worker-surface-paths.d.ts +6 -0
- package/dist/dev-server/worker-surface-paths.d.ts.map +1 -0
- package/dist/dev-server/workspace/merge-config.d.ts +81 -0
- package/dist/dev-server/workspace/merge-config.d.ts.map +1 -0
- package/dist/dev-server/workspace/prepare-app.d.ts +84 -0
- package/dist/dev-server/workspace/prepare-app.d.ts.map +1 -0
- package/dist/dev-server/workspace/server.d.ts +47 -0
- package/dist/dev-server/workspace/server.d.ts.map +1 -0
- package/dist/env.d.ts +10 -0
- package/dist/env.d.ts.map +1 -1
- package/dist/index.d.ts +8 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -297
- package/dist/runtime/context-events.d.ts +13 -0
- package/dist/runtime/context-events.d.ts.map +1 -0
- package/dist/runtime/context-types.d.ts +82 -0
- package/dist/runtime/context-types.d.ts.map +1 -0
- package/dist/runtime/context.d.ts +20 -44
- package/dist/runtime/context.d.ts.map +1 -1
- package/dist/runtime/exports.d.ts +70 -55
- package/dist/runtime/exports.d.ts.map +1 -1
- package/dist/runtime/index.d.ts +11 -5
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +5 -184
- package/dist/runtime/middleware.d.ts +119 -67
- package/dist/runtime/middleware.d.ts.map +1 -1
- package/dist/runtime/r2-presign.d.ts +164 -0
- package/dist/runtime/r2-presign.d.ts.map +1 -0
- package/dist/runtime/router/index.d.ts +7 -0
- package/dist/runtime/router/index.d.ts.map +1 -0
- package/dist/runtime/router/types.d.ts +24 -0
- package/dist/runtime/router/types.d.ts.map +1 -0
- package/dist/runtime/validation.d.ts +18 -4
- package/dist/runtime/validation.d.ts.map +1 -1
- package/dist/secrets/local-secrets.d.ts +46 -0
- package/dist/secrets/local-secrets.d.ts.map +1 -0
- package/dist/shims/local-hyperdrive.d.ts +12 -0
- package/dist/shims/local-hyperdrive.d.ts.map +1 -0
- package/dist/shims/local-media-bindings.d.ts +19 -0
- package/dist/shims/local-media-bindings.d.ts.map +1 -0
- package/dist/shims/local-worker-loader.d.ts +3 -0
- package/dist/shims/local-worker-loader.d.ts.map +1 -0
- package/dist/sveltekit/index.d.ts +1 -1
- package/dist/sveltekit/index.d.ts.map +1 -1
- package/dist/sveltekit/index.js +377 -169
- package/dist/sveltekit/local-bindings.d.ts +4 -0
- package/dist/sveltekit/local-bindings.d.ts.map +1 -0
- package/dist/sveltekit/platform.d.ts +42 -2
- package/dist/sveltekit/platform.d.ts.map +1 -1
- package/dist/test/ai-search.d.ts +39 -0
- package/dist/test/ai-search.d.ts.map +1 -0
- package/dist/test/alarm.d.ts +55 -0
- package/dist/test/alarm.d.ts.map +1 -0
- package/dist/test/binding-hints.d.ts +10 -0
- package/dist/test/binding-hints.d.ts.map +1 -0
- package/dist/test/cf.d.ts +71 -35
- package/dist/test/cf.d.ts.map +1 -1
- package/dist/test/containers.d.ts +87 -0
- package/dist/test/containers.d.ts.map +1 -0
- package/dist/test/email.d.ts +16 -7
- package/dist/test/email.d.ts.map +1 -1
- package/dist/test/index.d.ts +20 -21
- package/dist/test/index.d.ts.map +1 -1
- package/dist/test/index.js +5115 -75
- package/dist/test/offline-bindings.d.ts +124 -0
- package/dist/test/offline-bindings.d.ts.map +1 -0
- package/dist/test/queue.d.ts.map +1 -1
- package/dist/test/remote-ai.d.ts.map +1 -1
- package/dist/test/remote-cloudflare.d.ts +13 -0
- package/dist/test/remote-cloudflare.d.ts.map +1 -0
- package/dist/test/remote-vectorize.d.ts.map +1 -1
- package/dist/test/resolve-service-bindings.d.ts +64 -4
- package/dist/test/resolve-service-bindings.d.ts.map +1 -1
- package/dist/test/scheduled.d.ts.map +1 -1
- package/dist/test/should-skip.d.ts +14 -18
- package/dist/test/should-skip.d.ts.map +1 -1
- package/dist/test/simple-context-bindings.d.ts +13 -0
- package/dist/test/simple-context-bindings.d.ts.map +1 -0
- package/dist/test/simple-context-durable-objects.d.ts +6 -0
- package/dist/test/simple-context-durable-objects.d.ts.map +1 -0
- package/dist/test/simple-context-env.d.ts +35 -0
- package/dist/test/simple-context-env.d.ts.map +1 -0
- package/dist/test/simple-context-gateway-script.d.ts +2 -0
- package/dist/test/simple-context-gateway-script.d.ts.map +1 -0
- package/dist/test/simple-context-handlers.d.ts +12 -0
- package/dist/test/simple-context-handlers.d.ts.map +1 -0
- package/dist/test/simple-context-lifecycle.d.ts +32 -0
- package/dist/test/simple-context-lifecycle.d.ts.map +1 -0
- package/dist/test/simple-context-mfconfig.d.ts +18 -0
- package/dist/test/simple-context-mfconfig.d.ts.map +1 -0
- package/dist/test/simple-context-multi-worker.d.ts +16 -0
- package/dist/test/simple-context-multi-worker.d.ts.map +1 -0
- package/dist/test/simple-context-paths.d.ts +40 -0
- package/dist/test/simple-context-paths.d.ts.map +1 -0
- package/dist/test/simple-context-runtime.d.ts +19 -0
- package/dist/test/simple-context-runtime.d.ts.map +1 -0
- package/dist/test/simple-context-startup.d.ts +11 -0
- package/dist/test/simple-context-startup.d.ts.map +1 -0
- package/dist/test/simple-context-transport.d.ts +14 -0
- package/dist/test/simple-context-transport.d.ts.map +1 -0
- package/dist/test/simple-context.d.ts +8 -27
- package/dist/test/simple-context.d.ts.map +1 -1
- package/dist/test/tail.d.ts +3 -2
- package/dist/test/tail.d.ts.map +1 -1
- package/dist/test/utilities/analytics-engine.d.ts +22 -0
- package/dist/test/utilities/analytics-engine.d.ts.map +1 -0
- package/dist/test/utilities/artifacts.d.ts +11 -0
- package/dist/test/utilities/artifacts.d.ts.map +1 -0
- package/dist/test/utilities/context.d.ts +39 -0
- package/dist/test/utilities/context.d.ts.map +1 -0
- package/dist/test/utilities/d1.d.ts +21 -0
- package/dist/test/utilities/d1.d.ts.map +1 -0
- package/dist/test/utilities/env.d.ts +45 -0
- package/dist/test/utilities/env.d.ts.map +1 -0
- package/dist/test/utilities/kv.d.ts +11 -0
- package/dist/test/utilities/kv.d.ts.map +1 -0
- package/dist/test/utilities/media.d.ts +16 -0
- package/dist/test/utilities/media.d.ts.map +1 -0
- package/dist/test/utilities/platform.d.ts +41 -0
- package/dist/test/utilities/platform.d.ts.map +1 -0
- package/dist/test/utilities/queue.d.ts +5 -0
- package/dist/test/utilities/queue.d.ts.map +1 -0
- package/dist/test/utilities/r2.d.ts +2 -0
- package/dist/test/utilities/r2.d.ts.map +1 -0
- package/dist/test/utilities/send-email.d.ts +27 -0
- package/dist/test/utilities/send-email.d.ts.map +1 -0
- package/dist/test/utilities/stream-flagship.d.ts +27 -0
- package/dist/test/utilities/stream-flagship.d.ts.map +1 -0
- package/dist/test/utilities/vectorize.d.ts +38 -0
- package/dist/test/utilities/vectorize.d.ts.map +1 -0
- package/dist/test/utilities/workflows.d.ts +26 -0
- package/dist/test/utilities/workflows.d.ts.map +1 -0
- package/dist/test/utilities.d.ts +14 -98
- package/dist/test/utilities.d.ts.map +1 -1
- package/dist/test/worker.d.ts +6 -0
- package/dist/test/worker.d.ts.map +1 -1
- package/dist/transform/durable-object.d.ts.map +1 -1
- package/dist/transform/index.d.ts +2 -2
- package/dist/transform/worker-entrypoint.d.ts +5 -0
- package/dist/transform/worker-entrypoint.d.ts.map +1 -1
- package/dist/utils/entrypoint-discovery.d.ts +6 -3
- package/dist/utils/entrypoint-discovery.d.ts.map +1 -1
- package/dist/utils/glob.d.ts.map +1 -1
- package/dist/utils/resolve-package.d.ts.map +1 -1
- package/dist/utils/send-email.d.ts +15 -0
- package/dist/utils/send-email.d.ts.map +1 -0
- package/dist/utils/send-email.js +163 -0
- package/dist/vite/config-file.d.ts +25 -0
- package/dist/vite/config-file.d.ts.map +1 -0
- package/dist/vite/index.d.ts +3 -2
- package/dist/vite/index.d.ts.map +1 -1
- package/dist/vite/index.js +2 -407
- package/dist/vite/plugin-config-hook.d.ts +28 -0
- package/dist/vite/plugin-config-hook.d.ts.map +1 -0
- package/dist/vite/plugin-context.d.ts +27 -0
- package/dist/vite/plugin-context.d.ts.map +1 -0
- package/dist/vite/plugin-durable-objects.d.ts +18 -0
- package/dist/vite/plugin-durable-objects.d.ts.map +1 -0
- package/dist/vite/plugin-programmatic.d.ts +44 -0
- package/dist/vite/plugin-programmatic.d.ts.map +1 -0
- package/dist/vite/plugin-service-bindings.d.ts +13 -0
- package/dist/vite/plugin-service-bindings.d.ts.map +1 -0
- package/dist/vite/plugin-transform.d.ts +41 -0
- package/dist/vite/plugin-transform.d.ts.map +1 -0
- package/dist/vite/plugin.d.ts +10 -41
- package/dist/vite/plugin.d.ts.map +1 -1
- package/dist/worker-entry/composed-worker.d.ts +5 -8
- package/dist/worker-entry/composed-worker.d.ts.map +1 -1
- package/dist/worker-entry/durable-object-discovery.d.ts +20 -0
- package/dist/worker-entry/durable-object-discovery.d.ts.map +1 -0
- package/dist/worker-entry/extensions.d.ts +5 -0
- package/dist/worker-entry/extensions.d.ts.map +1 -0
- package/dist/worker-entry/routes.d.ts +22 -0
- package/dist/worker-entry/routes.d.ts.map +1 -0
- package/dist/worker-entry/surface-paths.d.ts +26 -0
- package/dist/worker-entry/surface-paths.d.ts.map +1 -0
- package/dist/worker-entry/validate-fetch-style.d.ts +12 -0
- package/dist/worker-entry/validate-fetch-style.d.ts.map +1 -0
- package/dist/workflows/local-workflow-entrypoints.d.ts +7 -0
- package/dist/workflows/local-workflow-entrypoints.d.ts.map +1 -0
- package/package.json +160 -117
- package/R2.md +0 -170
- package/dist/account-rvrj687w.js +0 -397
- package/dist/ai-dx4fr9jh.js +0 -107
- package/dist/bridge/protocol.d.ts.map +0 -1
- package/dist/bridge/serialization.d.ts +0 -83
- package/dist/bridge/serialization.d.ts.map +0 -1
- package/dist/browser-shim/worker.d.ts +0 -14
- package/dist/browser-shim/worker.d.ts.map +0 -1
- package/dist/build-9myaxf07.js +0 -70
- package/dist/deploy-h1wz5p7m.js +0 -86
- package/dist/dev-rsdssknb.js +0 -2707
- package/dist/doctor-v7jy4s3r.js +0 -190
- package/dist/durable-object-t4kbb0yt.js +0 -13
- package/dist/index-18hvb6gb.js +0 -194
- package/dist/index-1xpj0m4r.js +0 -57
- package/dist/index-37x76zdn.js +0 -4
- package/dist/index-3t6rypgc.js +0 -13
- package/dist/index-62b3gt2g.js +0 -12
- package/dist/index-67qcae0f.js +0 -183
- package/dist/index-9ats0s83.js +0 -70
- package/dist/index-a0fjkq68.js +0 -198
- package/dist/index-a855bdsx.js +0 -18
- package/dist/index-ccrh4w3t.js +0 -1133
- package/dist/index-d8bdkx2h.js +0 -109
- package/dist/index-f8qh2tyh.js +0 -2152
- package/dist/index-gz1gndna.js +0 -307
- package/dist/index-hcex3rgh.js +0 -266
- package/dist/index-k7r18na8.js +0 -0
- package/dist/index-n3np2d6t.js +0 -462
- package/dist/index-n7rs26ft.js +0 -77
- package/dist/index-npc1c8jx.js +0 -44
- package/dist/index-p7g30wd2.js +0 -281
- package/dist/index-rbht7m9r.js +0 -36
- package/dist/index-tfyxa77h.js +0 -850
- package/dist/index-tk6ej9dj.js +0 -94
- package/dist/index-v8vvsn9x.js +0 -169
- package/dist/index-z14anrqp.js +0 -226
- package/dist/init-f9mgmew3.js +0 -186
- package/dist/remote-q59qk463.js +0 -97
- package/dist/test/bridge-context.d.ts +0 -76
- package/dist/test/bridge-context.d.ts.map +0 -1
- package/dist/test/multi-worker-context.d.ts +0 -114
- package/dist/test/multi-worker-context.d.ts.map +0 -1
- package/dist/types-wdcpnfvy.js +0 -487
- package/dist/worker-entrypoint-m9th0rg0.js +0 -13
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
import { x as normalizeWorkflowBinding } from "./schema-normalization-CTdiY17P.js";
|
|
2
|
+
import { i as findFiles, r as DEFAULT_WORKFLOW_PATTERN } from "./glob-DRw9sbfF.js";
|
|
3
|
+
import { t as bundleWorkerEntry } from "./worker-bundler-Isj5jiW6.js";
|
|
4
|
+
import { join, relative, resolve } from "pathe";
|
|
5
|
+
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
6
|
+
//#region src/workflows/local-workflow-entrypoints.ts
|
|
7
|
+
function findExportedClasses(code) {
|
|
8
|
+
const classes = [];
|
|
9
|
+
const classPattern = /export\s+class\s+(\w+)/g;
|
|
10
|
+
let match = classPattern.exec(code);
|
|
11
|
+
while (match !== null) {
|
|
12
|
+
classes.push(match[1]);
|
|
13
|
+
match = classPattern.exec(code);
|
|
14
|
+
}
|
|
15
|
+
return classes;
|
|
16
|
+
}
|
|
17
|
+
function toImportSpecifier(fromDir, filePath) {
|
|
18
|
+
const relativePath = relative(fromDir, filePath).replace(/\\/g, "/");
|
|
19
|
+
return relativePath.startsWith(".") ? relativePath : `./${relativePath}`;
|
|
20
|
+
}
|
|
21
|
+
async function discoverWorkflowClasses(config, configDir) {
|
|
22
|
+
const classToFilePath = /* @__PURE__ */ new Map();
|
|
23
|
+
const workflowPatternConfig = config.files?.workflows;
|
|
24
|
+
const workflowPattern = typeof workflowPatternConfig === "string" ? workflowPatternConfig : DEFAULT_WORKFLOW_PATTERN;
|
|
25
|
+
if (workflowPatternConfig === false) return classToFilePath;
|
|
26
|
+
const files = await findFiles(workflowPattern, { cwd: configDir });
|
|
27
|
+
for (const filePath of files) try {
|
|
28
|
+
const code = await readFile(filePath, "utf-8");
|
|
29
|
+
for (const className of findExportedClasses(code)) classToFilePath.set(className, filePath);
|
|
30
|
+
} catch {}
|
|
31
|
+
return classToFilePath;
|
|
32
|
+
}
|
|
33
|
+
async function resolveLocalWorkflowEntrypoints(config, configDir) {
|
|
34
|
+
const workflows = config.bindings?.workflows;
|
|
35
|
+
if (!workflows || Object.keys(workflows).length === 0) return [];
|
|
36
|
+
const classToFilePath = await discoverWorkflowClasses(config, configDir);
|
|
37
|
+
const entrypoints = [];
|
|
38
|
+
for (const [bindingName, binding] of Object.entries(workflows)) {
|
|
39
|
+
const normalized = normalizeWorkflowBinding(binding);
|
|
40
|
+
if (normalized.scriptName) continue;
|
|
41
|
+
const scriptPath = classToFilePath.get(normalized.className);
|
|
42
|
+
if (!scriptPath) throw new Error(`Workflow binding ${bindingName} (className: '${normalized.className}') not found.\nEither set files.workflows to match the workflow source file, or set scriptName when the workflow lives in another worker.`);
|
|
43
|
+
entrypoints.push({
|
|
44
|
+
bindingName,
|
|
45
|
+
className: normalized.className,
|
|
46
|
+
scriptPath
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
return entrypoints;
|
|
50
|
+
}
|
|
51
|
+
function buildWorkflowVirtualEntry(entrypoints, entryDir) {
|
|
52
|
+
const imports = entrypoints.map((entrypoint, index) => {
|
|
53
|
+
const importName = `__DevflareWorkflow${index}`;
|
|
54
|
+
const importPath = toImportSpecifier(entryDir, entrypoint.scriptPath);
|
|
55
|
+
return {
|
|
56
|
+
importName,
|
|
57
|
+
className: entrypoint.className,
|
|
58
|
+
line: `import { ${entrypoint.className} as ${importName} } from '${importPath}'`
|
|
59
|
+
};
|
|
60
|
+
});
|
|
61
|
+
const exports = imports.map((entrypoint) => {
|
|
62
|
+
return `export { ${entrypoint.importName} as ${entrypoint.className} }`;
|
|
63
|
+
});
|
|
64
|
+
return [
|
|
65
|
+
...imports.map((entrypoint) => entrypoint.line),
|
|
66
|
+
"",
|
|
67
|
+
...exports
|
|
68
|
+
].join("\n");
|
|
69
|
+
}
|
|
70
|
+
async function bundleWorkflowEntrypointScript(config, configDir, options = {}) {
|
|
71
|
+
const entrypoints = await resolveLocalWorkflowEntrypoints(config, configDir);
|
|
72
|
+
if (entrypoints.length === 0) return "";
|
|
73
|
+
const entryDir = resolve(configDir, ".devflare", "workflow-entrypoints");
|
|
74
|
+
const entryPath = join(entryDir, "__entry.ts");
|
|
75
|
+
const outFile = join(entryDir, "index.js");
|
|
76
|
+
await mkdir(entryDir, { recursive: true });
|
|
77
|
+
await writeFile(entryPath, buildWorkflowVirtualEntry(entrypoints, entryDir));
|
|
78
|
+
await bundleWorkerEntry({
|
|
79
|
+
cwd: configDir,
|
|
80
|
+
inputFile: entryPath,
|
|
81
|
+
outFile,
|
|
82
|
+
rolldownOptions: config.rolldown?.options,
|
|
83
|
+
sourcemap: config.rolldown?.sourcemap,
|
|
84
|
+
minify: config.rolldown?.minify,
|
|
85
|
+
logger: options.logger
|
|
86
|
+
});
|
|
87
|
+
return await readFile(outFile, "utf-8");
|
|
88
|
+
}
|
|
89
|
+
//#endregion
|
|
90
|
+
//#region src/bridge/r2-presign-runtime.ts
|
|
91
|
+
/**
|
|
92
|
+
* Inline JS defining `__devflareR2PresignHandle(request, env, url)`, which
|
|
93
|
+
* returns a `Response` when the request targets the local presign endpoint
|
|
94
|
+
* and `null` otherwise. Enforces signature, expiry, method, content type and
|
|
95
|
+
* size against the per-boot secret in `env.DEVFLARE_R2_PRESIGN_SECRET`, then
|
|
96
|
+
* executes the object operation on the local R2 binding.
|
|
97
|
+
*/
|
|
98
|
+
const R2_PRESIGN_RUNTIME_JS = `
|
|
99
|
+
const __devflareR2PresignPrefix = '/_devflare/r2/presigned/'
|
|
100
|
+
|
|
101
|
+
const __devflareR2PresignCors = {
|
|
102
|
+
'Access-Control-Allow-Origin': '*',
|
|
103
|
+
'Access-Control-Allow-Methods': 'GET, HEAD, PUT, OPTIONS',
|
|
104
|
+
'Access-Control-Allow-Headers': 'Content-Type',
|
|
105
|
+
'Access-Control-Expose-Headers': 'ETag, Content-Type, Content-Length'
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function __devflareR2PresignError(status, code, message) {
|
|
109
|
+
return new Response(JSON.stringify({ error: { code, message } }), {
|
|
110
|
+
status,
|
|
111
|
+
headers: { 'Content-Type': 'application/json', ...__devflareR2PresignCors }
|
|
112
|
+
})
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
async function __devflareR2PresignHmacHex(secret, message) {
|
|
116
|
+
const encoder = new TextEncoder()
|
|
117
|
+
const key = await crypto.subtle.importKey(
|
|
118
|
+
'raw',
|
|
119
|
+
encoder.encode(secret),
|
|
120
|
+
{ name: 'HMAC', hash: 'SHA-256' },
|
|
121
|
+
false,
|
|
122
|
+
['sign']
|
|
123
|
+
)
|
|
124
|
+
const signature = await crypto.subtle.sign('HMAC', key, encoder.encode(message))
|
|
125
|
+
return [...new Uint8Array(signature)].map((b) => b.toString(16).padStart(2, '0')).join('')
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// Constant-time hex comparison (uses workerd's timingSafeEqual when present).
|
|
129
|
+
function __devflareR2PresignEqual(expectedHex, actualHex) {
|
|
130
|
+
if (typeof actualHex !== 'string' || actualHex.length !== expectedHex.length) return false
|
|
131
|
+
const encoder = new TextEncoder()
|
|
132
|
+
const expected = encoder.encode(expectedHex)
|
|
133
|
+
const actual = encoder.encode(actualHex)
|
|
134
|
+
const subtle = crypto.subtle
|
|
135
|
+
if (subtle && typeof subtle.timingSafeEqual === 'function') {
|
|
136
|
+
return subtle.timingSafeEqual(expected, actual)
|
|
137
|
+
}
|
|
138
|
+
let diff = 0
|
|
139
|
+
for (let i = 0; i < expected.length; i++) diff |= expected[i] ^ actual[i]
|
|
140
|
+
return diff === 0
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// MUST match buildLocalCanonicalString in src/runtime/r2-presign.ts.
|
|
144
|
+
function __devflareR2PresignCanonical(method, binding, key, expires, contentType, contentLength, maxSize) {
|
|
145
|
+
return [
|
|
146
|
+
'devflare:r2-presign:v1',
|
|
147
|
+
method,
|
|
148
|
+
binding,
|
|
149
|
+
key,
|
|
150
|
+
expires,
|
|
151
|
+
contentType || '',
|
|
152
|
+
contentLength || '',
|
|
153
|
+
maxSize || ''
|
|
154
|
+
].join('\\n')
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Handle a request to the local presigned R2 endpoint; returns null when the
|
|
159
|
+
* path does not match so gateways can fall through to their other routes.
|
|
160
|
+
*/
|
|
161
|
+
async function __devflareR2PresignHandle(request, env, url) {
|
|
162
|
+
if (!url.pathname.startsWith(__devflareR2PresignPrefix)) return null
|
|
163
|
+
|
|
164
|
+
if (request.method === 'OPTIONS') {
|
|
165
|
+
return new Response(null, {
|
|
166
|
+
status: 204,
|
|
167
|
+
headers: { ...__devflareR2PresignCors, 'Access-Control-Max-Age': '86400' }
|
|
168
|
+
})
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
const rest = url.pathname.slice(__devflareR2PresignPrefix.length)
|
|
172
|
+
const slashIndex = rest.indexOf('/')
|
|
173
|
+
if (slashIndex <= 0 || slashIndex === rest.length - 1) {
|
|
174
|
+
return __devflareR2PresignError(400, 'bad_request', 'Expected /_devflare/r2/presigned/<binding>/<key>.')
|
|
175
|
+
}
|
|
176
|
+
const binding = decodeURIComponent(rest.slice(0, slashIndex))
|
|
177
|
+
const key = rest
|
|
178
|
+
.slice(slashIndex + 1)
|
|
179
|
+
.split('/')
|
|
180
|
+
.map((segment) => decodeURIComponent(segment))
|
|
181
|
+
.join('/')
|
|
182
|
+
|
|
183
|
+
const secret = env.DEVFLARE_R2_PRESIGN_SECRET
|
|
184
|
+
if (typeof secret !== 'string' || secret.length === 0) {
|
|
185
|
+
return __devflareR2PresignError(
|
|
186
|
+
500,
|
|
187
|
+
'presign_unconfigured',
|
|
188
|
+
'DEVFLARE_R2_PRESIGN_SECRET is not configured on the devflare gateway. '
|
|
189
|
+
+ 'This endpoint is only served for configs with R2 bindings.'
|
|
190
|
+
)
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
const params = url.searchParams
|
|
194
|
+
const signedMethod = params.get('X-Devflare-Method')
|
|
195
|
+
const expires = params.get('X-Devflare-Expires')
|
|
196
|
+
const providedSignature = params.get('X-Devflare-Signature')
|
|
197
|
+
const signedContentType = params.get('X-Devflare-Content-Type')
|
|
198
|
+
const signedContentLength = params.get('X-Devflare-Content-Length')
|
|
199
|
+
const signedMaxSize = params.get('X-Devflare-Max-Size')
|
|
200
|
+
|
|
201
|
+
if (!signedMethod || !expires || !providedSignature) {
|
|
202
|
+
return __devflareR2PresignError(403, 'missing_parameters', 'Missing presign query parameters.')
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
const expectedSignature = await __devflareR2PresignHmacHex(
|
|
206
|
+
secret,
|
|
207
|
+
__devflareR2PresignCanonical(
|
|
208
|
+
signedMethod, binding, key, expires, signedContentType, signedContentLength, signedMaxSize
|
|
209
|
+
)
|
|
210
|
+
)
|
|
211
|
+
if (!__devflareR2PresignEqual(expectedSignature, providedSignature)) {
|
|
212
|
+
return __devflareR2PresignError(403, 'invalid_signature', 'Presigned URL signature mismatch.')
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
if (Math.floor(Date.now() / 1000) > Number(expires)) {
|
|
216
|
+
return __devflareR2PresignError(403, 'expired', 'Presigned URL has expired.')
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
const methodAllowed = signedMethod === 'GET'
|
|
220
|
+
? request.method === 'GET' || request.method === 'HEAD'
|
|
221
|
+
: request.method === signedMethod
|
|
222
|
+
if (!methodAllowed) {
|
|
223
|
+
return __devflareR2PresignError(
|
|
224
|
+
403,
|
|
225
|
+
'method_mismatch',
|
|
226
|
+
'URL was presigned for ' + signedMethod + ', got ' + request.method + '.'
|
|
227
|
+
)
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
const bucket = env[binding]
|
|
231
|
+
if (!bucket || typeof bucket.put !== 'function' || typeof bucket.head !== 'function') {
|
|
232
|
+
return __devflareR2PresignError(404, 'unknown_binding', 'R2 binding not found: ' + binding)
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
if (request.method === 'PUT') {
|
|
236
|
+
const sentContentType = request.headers.get('Content-Type')
|
|
237
|
+
if (signedContentType !== null && sentContentType !== signedContentType) {
|
|
238
|
+
return __devflareR2PresignError(
|
|
239
|
+
403,
|
|
240
|
+
'content_type_mismatch',
|
|
241
|
+
'URL was presigned for Content-Type "' + signedContentType + '", got "' + sentContentType + '".'
|
|
242
|
+
)
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
const body = await request.arrayBuffer()
|
|
246
|
+
if (signedContentLength !== null && body.byteLength !== Number(signedContentLength)) {
|
|
247
|
+
return __devflareR2PresignError(
|
|
248
|
+
403,
|
|
249
|
+
'content_length_mismatch',
|
|
250
|
+
'URL was presigned for exactly ' + signedContentLength + ' bytes, got ' + body.byteLength + '.'
|
|
251
|
+
)
|
|
252
|
+
}
|
|
253
|
+
if (signedMaxSize !== null && body.byteLength > Number(signedMaxSize)) {
|
|
254
|
+
return __devflareR2PresignError(
|
|
255
|
+
413,
|
|
256
|
+
'too_large',
|
|
257
|
+
'Body of ' + body.byteLength + ' bytes exceeds the presigned maximum of ' + signedMaxSize + '.'
|
|
258
|
+
)
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
const putContentType = sentContentType || signedContentType || undefined
|
|
262
|
+
const result = await bucket.put(key, body, {
|
|
263
|
+
...(putContentType && { httpMetadata: { contentType: putContentType } })
|
|
264
|
+
})
|
|
265
|
+
return new Response(null, {
|
|
266
|
+
status: 200,
|
|
267
|
+
headers: { ...__devflareR2PresignCors, ...(result?.httpEtag && { ETag: result.httpEtag }) }
|
|
268
|
+
})
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
// GET / HEAD
|
|
272
|
+
const objectHeaders = (object) => ({
|
|
273
|
+
...__devflareR2PresignCors,
|
|
274
|
+
'Content-Type': object.httpMetadata?.contentType || 'application/octet-stream',
|
|
275
|
+
'Content-Length': String(object.size),
|
|
276
|
+
...(object.httpEtag && { ETag: object.httpEtag })
|
|
277
|
+
})
|
|
278
|
+
|
|
279
|
+
if (request.method === 'HEAD') {
|
|
280
|
+
const object = await bucket.head(key)
|
|
281
|
+
if (!object) return __devflareR2PresignError(404, 'not_found', 'Object not found: ' + key)
|
|
282
|
+
return new Response(null, { status: 200, headers: objectHeaders(object) })
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
const object = await bucket.get(key)
|
|
286
|
+
if (!object) return __devflareR2PresignError(404, 'not_found', 'Object not found: ' + key)
|
|
287
|
+
return new Response(object.body, { status: 200, headers: objectHeaders(object) })
|
|
288
|
+
}
|
|
289
|
+
`;
|
|
290
|
+
//#endregion
|
|
291
|
+
export { bundleWorkflowEntrypointScript as n, R2_PRESIGN_RUNTIME_JS as t };
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
//#region src/config/define.ts
|
|
2
|
+
function defineConfig(config) {
|
|
3
|
+
if (typeof config === "function") {
|
|
4
|
+
const result = config();
|
|
5
|
+
if (result instanceof Promise) return result;
|
|
6
|
+
return result;
|
|
7
|
+
}
|
|
8
|
+
return config;
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region src/config/ref.ts
|
|
12
|
+
const resolvedCache = /* @__PURE__ */ new WeakMap();
|
|
13
|
+
const pendingResolutions = /* @__PURE__ */ new WeakMap();
|
|
14
|
+
const PENDING_REF_VALUE = "<pending>";
|
|
15
|
+
/**
|
|
16
|
+
* Extract the import specifier string from an import-thunk function's source.
|
|
17
|
+
*
|
|
18
|
+
* Uses a narrow regex over `fn.toString()`. To avoid returning bogus paths for
|
|
19
|
+
* minified or hand-written functions that do not contain a parseable
|
|
20
|
+
* `import(...)` call, the result is validated before being returned.
|
|
21
|
+
*
|
|
22
|
+
* Throws a clear error instead of returning a silent placeholder when the
|
|
23
|
+
* function source is not in a recognized shape.
|
|
24
|
+
*/
|
|
25
|
+
function extractConfigPathFromImportFn(fn) {
|
|
26
|
+
let source;
|
|
27
|
+
try {
|
|
28
|
+
source = Function.prototype.toString.call(fn);
|
|
29
|
+
} catch {
|
|
30
|
+
return PENDING_REF_VALUE;
|
|
31
|
+
}
|
|
32
|
+
if (!/import\s*\(/.test(source)) return PENDING_REF_VALUE;
|
|
33
|
+
const match = source.match(/import\s*\(\s*(['"`])([^'"`]+)\1\s*\)/);
|
|
34
|
+
const raw = match?.[2];
|
|
35
|
+
if (!raw || raw.length === 0) throw new Error("ref() could not extract a config path from the import function source. The specifier must be a static string literal — dynamic or computed specifiers (e.g. template literals with expressions) are not supported. If this input has been minified, pass an unminified config source.");
|
|
36
|
+
if (match?.[1] === "`" && /\$\{/.test(raw)) throw new Error("ref() import specifier is a template literal with an embedded expression. The specifier must be a static string literal so the config path can be resolved ahead of time.");
|
|
37
|
+
if (raw.length < 2 && !/[./]/.test(raw)) throw new Error(`ref() extracted a suspiciously short config path (${JSON.stringify(raw)}). This usually indicates a minified bundle where the original specifier was rewritten. Pass an unminified config source.`);
|
|
38
|
+
return raw;
|
|
39
|
+
}
|
|
40
|
+
function ref(nameOrImport, maybeImport) {
|
|
41
|
+
const nameOverride = typeof nameOrImport === "string" ? nameOrImport : void 0;
|
|
42
|
+
let importFn;
|
|
43
|
+
if (typeof nameOrImport === "function") importFn = nameOrImport;
|
|
44
|
+
else if (typeof maybeImport === "function") importFn = maybeImport;
|
|
45
|
+
if (!importFn) throw new Error("ref() requires an import function");
|
|
46
|
+
const resolvedImportFn = importFn;
|
|
47
|
+
const configPath = extractConfigPathFromImportFn(resolvedImportFn);
|
|
48
|
+
const doBindingCache = /* @__PURE__ */ new Map();
|
|
49
|
+
async function doResolve() {
|
|
50
|
+
const cached = resolvedCache.get(proxy);
|
|
51
|
+
if (cached) return cached;
|
|
52
|
+
const pending = pendingResolutions.get(proxy);
|
|
53
|
+
if (pending) return pending;
|
|
54
|
+
const trackedPromise = (async () => {
|
|
55
|
+
const module = await resolvedImportFn();
|
|
56
|
+
const config = "default" in module ? module.default : module;
|
|
57
|
+
if (!config.name && !nameOverride) throw new Error("Referenced config must have a \"name\" property");
|
|
58
|
+
const resolved = {
|
|
59
|
+
name: nameOverride ?? config.name,
|
|
60
|
+
config,
|
|
61
|
+
configPath
|
|
62
|
+
};
|
|
63
|
+
resolvedCache.set(proxy, resolved);
|
|
64
|
+
return resolved;
|
|
65
|
+
})().finally(() => {
|
|
66
|
+
pendingResolutions.delete(proxy);
|
|
67
|
+
});
|
|
68
|
+
pendingResolutions.set(proxy, trackedPromise);
|
|
69
|
+
return trackedPromise;
|
|
70
|
+
}
|
|
71
|
+
function getResolved() {
|
|
72
|
+
const cached = resolvedCache.get(proxy);
|
|
73
|
+
if (cached) return cached;
|
|
74
|
+
throw new Error("ref() not yet resolved. Call ref().resolve() first, or use top-level await in your config file to resolve all refs before exporting.");
|
|
75
|
+
}
|
|
76
|
+
function createWorkerBinding(entrypoint) {
|
|
77
|
+
return {
|
|
78
|
+
get service() {
|
|
79
|
+
const cached = resolvedCache.get(proxy);
|
|
80
|
+
if (cached) return cached.name;
|
|
81
|
+
if (nameOverride) return nameOverride;
|
|
82
|
+
return PENDING_REF_VALUE;
|
|
83
|
+
},
|
|
84
|
+
entrypoint,
|
|
85
|
+
__ref: proxy
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
const workerAccessor = new Proxy((entrypoint) => createWorkerBinding(entrypoint), { get(target, prop) {
|
|
89
|
+
if (prop === "service") {
|
|
90
|
+
const cached = resolvedCache.get(proxy);
|
|
91
|
+
if (cached) return cached.name;
|
|
92
|
+
if (nameOverride) return nameOverride;
|
|
93
|
+
return PENDING_REF_VALUE;
|
|
94
|
+
}
|
|
95
|
+
if (prop === "entrypoint") return void 0;
|
|
96
|
+
if (prop === "__ref") return proxy;
|
|
97
|
+
return Reflect.get(target, prop);
|
|
98
|
+
} });
|
|
99
|
+
function createDOBinding(bindingName) {
|
|
100
|
+
const cachedBinding = doBindingCache.get(bindingName);
|
|
101
|
+
if (cachedBinding) return cachedBinding;
|
|
102
|
+
const doBinding = {
|
|
103
|
+
get className() {
|
|
104
|
+
const cached = resolvedCache.get(proxy);
|
|
105
|
+
if (cached?.config.bindings?.durableObjects) {
|
|
106
|
+
const doConfig = cached.config.bindings.durableObjects[bindingName];
|
|
107
|
+
if (typeof doConfig === "string") return doConfig;
|
|
108
|
+
if (doConfig && typeof doConfig === "object" && "className" in doConfig) return doConfig.className;
|
|
109
|
+
}
|
|
110
|
+
return PENDING_REF_VALUE;
|
|
111
|
+
},
|
|
112
|
+
get scriptName() {
|
|
113
|
+
const cached = resolvedCache.get(proxy);
|
|
114
|
+
if (cached) return cached.name;
|
|
115
|
+
if (nameOverride) return nameOverride;
|
|
116
|
+
return PENDING_REF_VALUE;
|
|
117
|
+
},
|
|
118
|
+
kind: "cross-worker",
|
|
119
|
+
__ref: proxy
|
|
120
|
+
};
|
|
121
|
+
doBindingCache.set(bindingName, doBinding);
|
|
122
|
+
return doBinding;
|
|
123
|
+
}
|
|
124
|
+
const knownProps = new Set([
|
|
125
|
+
"name",
|
|
126
|
+
"config",
|
|
127
|
+
"configPath",
|
|
128
|
+
"worker",
|
|
129
|
+
"__import",
|
|
130
|
+
"__nameOverride",
|
|
131
|
+
"resolve",
|
|
132
|
+
"then"
|
|
133
|
+
]);
|
|
134
|
+
const proxy = new Proxy({
|
|
135
|
+
get name() {
|
|
136
|
+
return getResolved().name;
|
|
137
|
+
},
|
|
138
|
+
get config() {
|
|
139
|
+
return getResolved().config;
|
|
140
|
+
},
|
|
141
|
+
configPath,
|
|
142
|
+
worker: workerAccessor,
|
|
143
|
+
__import: resolvedImportFn,
|
|
144
|
+
__nameOverride: nameOverride,
|
|
145
|
+
resolve: doResolve
|
|
146
|
+
}, {
|
|
147
|
+
get(target, prop) {
|
|
148
|
+
if (typeof prop === "string" && knownProps.has(prop)) return Reflect.get(target, prop);
|
|
149
|
+
if (typeof prop === "symbol") return Reflect.get(target, prop);
|
|
150
|
+
if (typeof prop === "string" && /^[A-Z][A-Z0-9_]*$/.test(prop)) {
|
|
151
|
+
const cached = resolvedCache.get(proxy);
|
|
152
|
+
if (cached) {
|
|
153
|
+
const doBindings = cached.config.bindings?.durableObjects;
|
|
154
|
+
if (!doBindings || !(prop in doBindings)) return;
|
|
155
|
+
}
|
|
156
|
+
return createDOBinding(prop);
|
|
157
|
+
}
|
|
158
|
+
return Reflect.get(target, prop);
|
|
159
|
+
},
|
|
160
|
+
has(target, prop) {
|
|
161
|
+
if (typeof prop === "string") {
|
|
162
|
+
if (knownProps.has(prop)) return true;
|
|
163
|
+
if (/^[A-Z][A-Z0-9_]*$/.test(prop)) {
|
|
164
|
+
const cached = resolvedCache.get(proxy);
|
|
165
|
+
if (cached) {
|
|
166
|
+
const doBindings = cached.config.bindings?.durableObjects;
|
|
167
|
+
return !!doBindings && prop in doBindings;
|
|
168
|
+
}
|
|
169
|
+
return true;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
return Reflect.has(target, prop);
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
return proxy;
|
|
176
|
+
}
|
|
177
|
+
//#endregion
|
|
178
|
+
export { defineConfig as n, ref as t };
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { a as DIM, c as RESET, n as BOLD, o as GREEN, s as RED, u as YELLOW } from "./colors-D0NVzAFN.js";
|
|
2
|
+
import { n as enableRemoteMode, r as getEffectiveRemoteModeStatus, t as disableRemoteMode } from "./remote-config-Bw6qIVM4.js";
|
|
3
|
+
//#region src/cli/commands/remote.ts
|
|
4
|
+
function log(message = "") {
|
|
5
|
+
console.log(message);
|
|
6
|
+
}
|
|
7
|
+
function showStatus() {
|
|
8
|
+
const status = getEffectiveRemoteModeStatus();
|
|
9
|
+
log();
|
|
10
|
+
log(`${BOLD}Remote Test Mode${RESET}`);
|
|
11
|
+
log();
|
|
12
|
+
if (status.isActive) {
|
|
13
|
+
log(` ${GREEN}●${RESET} ${BOLD}Enabled${RESET}`);
|
|
14
|
+
if (status.source === "env") {
|
|
15
|
+
log(` Source: ${YELLOW}DEVFLARE_REMOTE${RESET} environment variable`);
|
|
16
|
+
log(` ${DIM}(unset the variable to disable)${RESET}`);
|
|
17
|
+
} else {
|
|
18
|
+
log(` Expires in ${status.remainingMinutes} minute(s)`);
|
|
19
|
+
log(` ${DIM}At: ${status.expiresAt?.toLocaleTimeString()}${RESET}`);
|
|
20
|
+
}
|
|
21
|
+
} else {
|
|
22
|
+
log(` ${DIM}○${RESET} Disabled`);
|
|
23
|
+
log(` ${DIM}Remote-only tests (AI, Vectorize) will be skipped${RESET}`);
|
|
24
|
+
}
|
|
25
|
+
log();
|
|
26
|
+
log(`${DIM}Commands:${RESET}`);
|
|
27
|
+
log(` devflare remote enable [minutes] Enable for N minutes (default: 30)`);
|
|
28
|
+
log(` devflare remote disable Disable immediately`);
|
|
29
|
+
log(` devflare remote status Show current status`);
|
|
30
|
+
log();
|
|
31
|
+
}
|
|
32
|
+
function enable(inputMinutes) {
|
|
33
|
+
const actualMinutes = enableRemoteMode(inputMinutes);
|
|
34
|
+
const status = getEffectiveRemoteModeStatus();
|
|
35
|
+
log();
|
|
36
|
+
if (inputMinutes !== actualMinutes) log(`${YELLOW}⚠${RESET} Invalid duration, using ${actualMinutes} minute(s)`);
|
|
37
|
+
log(`${GREEN}✓${RESET} Remote test mode ${BOLD}enabled${RESET} for ${actualMinutes} minute(s)`);
|
|
38
|
+
log(` Expires at: ${status.expiresAt?.toLocaleTimeString()}`);
|
|
39
|
+
log();
|
|
40
|
+
log(`${YELLOW}⚠${RESET} Remote tests use real Cloudflare infrastructure and may incur costs.`);
|
|
41
|
+
log(` Run ${DIM}devflare remote disable${RESET} when done.`);
|
|
42
|
+
log();
|
|
43
|
+
}
|
|
44
|
+
function disable() {
|
|
45
|
+
const statusBefore = getEffectiveRemoteModeStatus();
|
|
46
|
+
disableRemoteMode();
|
|
47
|
+
log();
|
|
48
|
+
log(`${GREEN}✓${RESET} Remote test mode ${BOLD}disabled${RESET}`);
|
|
49
|
+
if (statusBefore.envVarSet) {
|
|
50
|
+
log();
|
|
51
|
+
log(`${YELLOW}⚠${RESET} Note: ${BOLD}DEVFLARE_REMOTE${RESET} environment variable is still set.`);
|
|
52
|
+
log(` Remote mode will remain active until you unset it.`);
|
|
53
|
+
} else log(` Remote-only tests (AI, Vectorize) will now be skipped.`);
|
|
54
|
+
log();
|
|
55
|
+
}
|
|
56
|
+
function runRemoteCommand(parsed, _logger, _options) {
|
|
57
|
+
const subcommand = parsed.args[0];
|
|
58
|
+
const arg = parsed.args[1];
|
|
59
|
+
switch (subcommand) {
|
|
60
|
+
case "enable": {
|
|
61
|
+
const minutes = arg ? Number.parseInt(arg, 10) : 30;
|
|
62
|
+
enable(Number.isNaN(minutes) ? 30 : minutes);
|
|
63
|
+
return { exitCode: 0 };
|
|
64
|
+
}
|
|
65
|
+
case "disable":
|
|
66
|
+
disable();
|
|
67
|
+
return { exitCode: 0 };
|
|
68
|
+
case "status":
|
|
69
|
+
case void 0:
|
|
70
|
+
showStatus();
|
|
71
|
+
return { exitCode: 0 };
|
|
72
|
+
default:
|
|
73
|
+
log(`${RED}Unknown subcommand:${RESET} ${subcommand}`);
|
|
74
|
+
log(`Run ${DIM}devflare remote${RESET} for usage.`);
|
|
75
|
+
return { exitCode: 1 };
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
//#endregion
|
|
79
|
+
export { runRemoteCommand };
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, unlinkSync, writeFileSync } from "fs";
|
|
2
|
+
import { join } from "path";
|
|
3
|
+
import { homedir } from "os";
|
|
4
|
+
//#region src/cloudflare/remote-config.ts
|
|
5
|
+
/** Minimum duration in minutes */
|
|
6
|
+
const MIN_MINUTES = 1;
|
|
7
|
+
/** Maximum duration in minutes (24 hours) */
|
|
8
|
+
const MAX_MINUTES = 1440;
|
|
9
|
+
function getConfigDir() {
|
|
10
|
+
return join(homedir(), ".devflare");
|
|
11
|
+
}
|
|
12
|
+
function getConfigPath() {
|
|
13
|
+
return join(getConfigDir(), "remote.json");
|
|
14
|
+
}
|
|
15
|
+
function readConfig() {
|
|
16
|
+
const path = getConfigPath();
|
|
17
|
+
if (!existsSync(path)) return null;
|
|
18
|
+
try {
|
|
19
|
+
const content = readFileSync(path, "utf-8");
|
|
20
|
+
return JSON.parse(content);
|
|
21
|
+
} catch {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function writeConfig(config) {
|
|
26
|
+
const dir = getConfigDir();
|
|
27
|
+
if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
|
|
28
|
+
writeFileSync(getConfigPath(), JSON.stringify(config, null, " "));
|
|
29
|
+
}
|
|
30
|
+
function deleteConfig() {
|
|
31
|
+
const path = getConfigPath();
|
|
32
|
+
if (existsSync(path)) try {
|
|
33
|
+
unlinkSync(path);
|
|
34
|
+
} catch {}
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Enable remote mode for a given duration.
|
|
38
|
+
* @param minutes Duration in minutes (default: 30, clamped to 1-1440)
|
|
39
|
+
* @returns The validated minutes value actually used
|
|
40
|
+
*/
|
|
41
|
+
function enableRemoteMode(minutes = 30) {
|
|
42
|
+
const validMinutes = Math.max(MIN_MINUTES, Math.min(MAX_MINUTES, Math.floor(minutes) || 30));
|
|
43
|
+
const now = Date.now();
|
|
44
|
+
writeConfig({
|
|
45
|
+
enabledAt: now,
|
|
46
|
+
expiresAt: now + validMinutes * 60 * 1e3,
|
|
47
|
+
durationMinutes: validMinutes
|
|
48
|
+
});
|
|
49
|
+
return validMinutes;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Disable remote mode immediately.
|
|
53
|
+
*/
|
|
54
|
+
function disableRemoteMode() {
|
|
55
|
+
deleteConfig();
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Get the current remote mode status from stored config.
|
|
59
|
+
* Note: Use getEffectiveRemoteModeStatus() to also include env var override.
|
|
60
|
+
* @returns Status object with isEnabled, remainingMinutes, and expiresAt
|
|
61
|
+
*/
|
|
62
|
+
function getRemoteModeStatus() {
|
|
63
|
+
const config = readConfig();
|
|
64
|
+
if (!config) return {
|
|
65
|
+
isEnabled: false,
|
|
66
|
+
remainingMinutes: 0,
|
|
67
|
+
expiresAt: null
|
|
68
|
+
};
|
|
69
|
+
const now = Date.now();
|
|
70
|
+
if (now >= config.expiresAt) {
|
|
71
|
+
deleteConfig();
|
|
72
|
+
return {
|
|
73
|
+
isEnabled: false,
|
|
74
|
+
remainingMinutes: 0,
|
|
75
|
+
expiresAt: null
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
const remainingMs = config.expiresAt - now;
|
|
79
|
+
return {
|
|
80
|
+
isEnabled: true,
|
|
81
|
+
remainingMinutes: Math.ceil(remainingMs / 6e4),
|
|
82
|
+
expiresAt: new Date(config.expiresAt)
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Get the effective remote mode status including env var override.
|
|
87
|
+
* @returns Status object with isActive, source, and config details
|
|
88
|
+
*/
|
|
89
|
+
function getEffectiveRemoteModeStatus() {
|
|
90
|
+
const envValue = process.env.DEVFLARE_REMOTE ?? "";
|
|
91
|
+
if ([
|
|
92
|
+
"1",
|
|
93
|
+
"true",
|
|
94
|
+
"yes"
|
|
95
|
+
].includes(envValue.toLowerCase())) return {
|
|
96
|
+
isActive: true,
|
|
97
|
+
source: "env",
|
|
98
|
+
remainingMinutes: Number.POSITIVE_INFINITY,
|
|
99
|
+
expiresAt: null,
|
|
100
|
+
envVarSet: true
|
|
101
|
+
};
|
|
102
|
+
const status = getRemoteModeStatus();
|
|
103
|
+
if (status.isEnabled) return {
|
|
104
|
+
isActive: true,
|
|
105
|
+
source: "config",
|
|
106
|
+
remainingMinutes: status.remainingMinutes,
|
|
107
|
+
expiresAt: status.expiresAt,
|
|
108
|
+
envVarSet: false
|
|
109
|
+
};
|
|
110
|
+
return {
|
|
111
|
+
isActive: false,
|
|
112
|
+
source: "none",
|
|
113
|
+
remainingMinutes: 0,
|
|
114
|
+
expiresAt: null,
|
|
115
|
+
envVarSet: false
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Check if remote mode is currently enabled.
|
|
120
|
+
* Checks both env var (DEVFLARE_REMOTE=1) and stored config.
|
|
121
|
+
*/
|
|
122
|
+
function isRemoteModeActive() {
|
|
123
|
+
const envValue = process.env.DEVFLARE_REMOTE ?? "";
|
|
124
|
+
if ([
|
|
125
|
+
"1",
|
|
126
|
+
"true",
|
|
127
|
+
"yes"
|
|
128
|
+
].includes(envValue.toLowerCase())) return true;
|
|
129
|
+
return getRemoteModeStatus().isEnabled;
|
|
130
|
+
}
|
|
131
|
+
//#endregion
|
|
132
|
+
export { isRemoteModeActive as a, getRemoteModeStatus as i, enableRemoteMode as n, getEffectiveRemoteModeStatus as r, disableRemoteMode as t };
|