devflare 1.0.0-next.7 → 1.0.0-next.71
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/LLM.md +17316 -2144
- package/README.md +398 -607
- package/bin/devflare.js +30 -14
- package/dist/_chunks/account-B9ULT9HA.js +462 -0
- package/dist/_chunks/account-resources-BdKj8q1h.js +159 -0
- package/dist/_chunks/ai-DKDn1iys.js +322 -0
- package/dist/_chunks/api-BKClUlUf.js +568 -0
- package/dist/_chunks/build-B9jQtUny.js +24 -0
- package/dist/_chunks/build-artifacts-C7AbI34o.js +484 -0
- package/dist/_chunks/cli-CBRR2-Xr.js +1214 -0
- package/dist/_chunks/cloudflare-D_5UWT84.js +157 -0
- package/dist/_chunks/colors-D0NVzAFN.js +13 -0
- package/dist/_chunks/command-utils-qlsHELwW.js +45 -0
- package/dist/_chunks/compiler-UxXQgEPq.js +521 -0
- package/dist/_chunks/config-CHdi5-5R.js +78 -0
- package/dist/_chunks/config-path-DzZbchb6.js +42 -0
- package/dist/_chunks/context-DGMev2AF.js +2515 -0
- package/dist/_chunks/decorators-eXNZ1S0N.js +19 -0
- package/dist/_chunks/dependencies-HLIhxbIe.js +57 -0
- package/dist/_chunks/deploy-dIZuouRW.js +1033 -0
- package/dist/_chunks/dev-CRW_hBA3.js +953 -0
- package/dist/_chunks/doctor-t8hKA53t.js +219 -0
- package/dist/_chunks/durable-object-DuMPM8re.js +234 -0
- package/dist/_chunks/env-D4uJqqgu.js +125 -0
- package/dist/_chunks/family-DHkROYgX.js +143 -0
- package/dist/_chunks/generated-artifacts-D_VIzDOi.js +31 -0
- package/dist/_chunks/generated-dir-DC2kM-mt.js +33 -0
- package/dist/_chunks/glob-DRw9sbfF.js +56 -0
- package/dist/_chunks/init-B9_QIZcO.js +165 -0
- package/dist/_chunks/loader-BC0skbnH.js +1330 -0
- package/dist/_chunks/local-dev-vars-BFLS-HoI.js +81 -0
- package/dist/_chunks/local-hyperdrive-CcORzo76.js +119 -0
- package/dist/_chunks/local-media-bindings-ZQe-epuw.js +335 -0
- package/dist/_chunks/local-secrets-C0n5oRgI.js +123 -0
- package/dist/_chunks/login-Ctw59McM.js +51 -0
- package/dist/_chunks/package-metadata-CLI488gB.js +39 -0
- package/dist/_chunks/preferences-CbYERA_m.js +241 -0
- package/dist/_chunks/preview-j9Kbx4-G.js +462 -0
- package/dist/_chunks/preview-registry-CTXU4mBc.js +1186 -0
- package/dist/_chunks/preview-resources-BNvfkfqP.js +359 -0
- package/dist/_chunks/previews-DXlf8SaQ.js +1133 -0
- package/dist/_chunks/productions-TkIy7b1Q.js +504 -0
- package/dist/_chunks/r2-presign-runtime-DlgH_FY8.js +291 -0
- package/dist/_chunks/ref-CYJNAAe_.js +178 -0
- package/dist/_chunks/remote-DB8SU7ea.js +79 -0
- package/dist/_chunks/remote-config-Bw6qIVM4.js +132 -0
- package/dist/_chunks/resolve-package-DeJUGxoE.js +152 -0
- package/dist/_chunks/rolldown-runtime-CvQ6eiug.js +14 -0
- package/dist/_chunks/routes-CRXB3-iw.js +851 -0
- package/dist/_chunks/runtime-BlKTWIgD.js +874 -0
- package/dist/_chunks/schema-normalization-CTdiY17P.js +667 -0
- package/dist/_chunks/secrets-CzSWX4-i.js +95 -0
- package/dist/_chunks/tail-DXKaqcPB.js +239 -0
- package/dist/_chunks/token-CEIRtse8.js +333 -0
- package/dist/_chunks/tokens-CE7-gV5E.js +221 -0
- package/dist/_chunks/types-BB15NBqw.js +484 -0
- package/dist/_chunks/ui-BhCdDC2N.js +103 -0
- package/dist/_chunks/usage-rRusKejc.js +272 -0
- package/dist/_chunks/vite-DTz2Pbtm.js +1267 -0
- package/dist/_chunks/vite-process-BhGXJ764.js +2928 -0
- package/dist/_chunks/vite-utils-D_VR07Ks.js +183 -0
- package/dist/_chunks/worker-CgIvLp-D.js +410 -0
- package/dist/_chunks/worker-bundler-CeMqQtBQ.js +457 -0
- package/dist/_chunks/worker-entrypoint-C8j23t6d.js +247 -0
- package/dist/_chunks/workerName-kEXwmV2m.js +23 -0
- package/dist/_chunks/workspace-CbollZBv.js +518 -0
- package/dist/_chunks/workspace-Ds3xMjOE.js +175 -0
- package/dist/bridge/client.d.ts +93 -8
- package/dist/bridge/client.d.ts.map +1 -1
- package/dist/bridge/do-rpc-dispatch.d.ts +23 -0
- package/dist/bridge/do-rpc-dispatch.d.ts.map +1 -0
- package/dist/bridge/do-websocket-connect.d.ts +33 -0
- package/dist/bridge/do-websocket-connect.d.ts.map +1 -0
- package/dist/bridge/gateway-runtime.d.ts +8 -0
- package/dist/bridge/gateway-runtime.d.ts.map +1 -0
- package/dist/bridge/index.d.ts +6 -6
- package/dist/bridge/index.d.ts.map +1 -1
- package/dist/bridge/log.d.ts +5 -0
- package/dist/bridge/log.d.ts.map +1 -0
- package/dist/bridge/miniflare-gateway.d.ts +45 -0
- package/dist/bridge/miniflare-gateway.d.ts.map +1 -0
- package/dist/bridge/miniflare.d.ts +92 -2
- package/dist/bridge/miniflare.d.ts.map +1 -1
- package/dist/bridge/proxy.d.ts +12 -11
- package/dist/bridge/proxy.d.ts.map +1 -1
- package/dist/bridge/r2-presign-runtime.d.ts +9 -0
- package/dist/bridge/r2-presign-runtime.d.ts.map +1 -0
- package/dist/bridge/server.d.ts +2 -1
- package/dist/bridge/server.d.ts.map +1 -1
- package/dist/bridge/v2/body-streams.d.ts +53 -0
- package/dist/bridge/v2/body-streams.d.ts.map +1 -0
- package/dist/bridge/v2/codec.d.ts +106 -0
- package/dist/bridge/v2/codec.d.ts.map +1 -0
- package/dist/bridge/v2/control-messages.d.ts +46 -0
- package/dist/bridge/v2/control-messages.d.ts.map +1 -0
- package/dist/bridge/v2/frames.d.ts +109 -0
- package/dist/bridge/v2/frames.d.ts.map +1 -0
- package/dist/bridge/v2/index.d.ts +11 -0
- package/dist/bridge/v2/index.d.ts.map +1 -0
- package/dist/bridge/v2/serialization.d.ts +48 -0
- package/dist/bridge/v2/serialization.d.ts.map +1 -0
- package/dist/bridge/v2/transport.d.ts +31 -0
- package/dist/bridge/v2/transport.d.ts.map +1 -0
- package/dist/bridge/v2/value-codec.d.ts +61 -0
- package/dist/bridge/v2/value-codec.d.ts.map +1 -0
- package/dist/bridge/v2/value-serialization.d.ts +139 -0
- package/dist/bridge/v2/value-serialization.d.ts.map +1 -0
- package/dist/bridge/{protocol.d.ts → v2/wire.d.ts} +32 -8
- package/dist/bridge/v2/wire.d.ts.map +1 -0
- package/dist/bridge/v2/ws-relay.d.ts +53 -0
- package/dist/bridge/v2/ws-relay.d.ts.map +1 -0
- package/dist/bridge/websocket-constructor.d.ts +38 -0
- package/dist/bridge/websocket-constructor.d.ts.map +1 -0
- package/dist/browser-shim/handler.d.ts +2 -2
- package/dist/browser-shim/handler.d.ts.map +1 -1
- package/dist/browser-shim/index.d.ts +2 -2
- package/dist/browser-shim/server.d.ts +63 -0
- package/dist/browser-shim/server.d.ts.map +1 -1
- package/dist/browser.d.ts +5778 -43
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +73 -142
- package/dist/bundler/defaults.d.ts +23 -0
- package/dist/bundler/defaults.d.ts.map +1 -0
- package/dist/bundler/do-bundler.d.ts +7 -0
- package/dist/bundler/do-bundler.d.ts.map +1 -1
- package/dist/bundler/index.d.ts +3 -1
- package/dist/bundler/index.d.ts.map +1 -1
- package/dist/bundler/rolldown-shared.d.ts +52 -0
- package/dist/bundler/rolldown-shared.d.ts.map +1 -0
- package/dist/bundler/worker-bundler.d.ts +13 -0
- package/dist/bundler/worker-bundler.d.ts.map +1 -0
- package/dist/bundler/worker-compat.d.ts +4 -0
- package/dist/bundler/worker-compat.d.ts.map +1 -0
- package/dist/cli/build-manifest.d.ts +66 -0
- package/dist/cli/build-manifest.d.ts.map +1 -0
- package/dist/cli/command-utils.d.ts +18 -0
- package/dist/cli/command-utils.d.ts.map +1 -0
- package/dist/cli/commands/account.d.ts +2 -2
- package/dist/cli/commands/account.d.ts.map +1 -1
- package/dist/cli/commands/ai.d.ts +1 -1
- package/dist/cli/commands/ai.d.ts.map +1 -1
- package/dist/cli/commands/build-artifacts.d.ts +40 -0
- package/dist/cli/commands/build-artifacts.d.ts.map +1 -0
- package/dist/cli/commands/build.d.ts +2 -2
- package/dist/cli/commands/build.d.ts.map +1 -1
- package/dist/cli/commands/config.d.ts +4 -0
- package/dist/cli/commands/config.d.ts.map +1 -0
- package/dist/cli/commands/deploy/metadata.d.ts +18 -0
- package/dist/cli/commands/deploy/metadata.d.ts.map +1 -0
- package/dist/cli/commands/deploy/prepare.d.ts +23 -0
- package/dist/cli/commands/deploy/prepare.d.ts.map +1 -0
- package/dist/cli/commands/deploy/runtime.d.ts +4 -0
- package/dist/cli/commands/deploy/runtime.d.ts.map +1 -0
- package/dist/cli/commands/deploy/verification.d.ts +36 -0
- package/dist/cli/commands/deploy/verification.d.ts.map +1 -0
- package/dist/cli/commands/deploy.d.ts +2 -2
- package/dist/cli/commands/deploy.d.ts.map +1 -1
- package/dist/cli/commands/dev.d.ts +9 -1
- package/dist/cli/commands/dev.d.ts.map +1 -1
- package/dist/cli/commands/doctor.d.ts +2 -2
- package/dist/cli/commands/doctor.d.ts.map +1 -1
- package/dist/cli/commands/init.d.ts +2 -2
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/login.d.ts +4 -0
- package/dist/cli/commands/login.d.ts.map +1 -0
- package/dist/cli/commands/previews-support/cleanup.d.ts +9 -0
- package/dist/cli/commands/previews-support/cleanup.d.ts.map +1 -0
- package/dist/cli/commands/previews-support/family.d.ts +10 -0
- package/dist/cli/commands/previews-support/family.d.ts.map +1 -0
- package/dist/cli/commands/previews-support/render.d.ts +8 -0
- package/dist/cli/commands/previews-support/render.d.ts.map +1 -0
- package/dist/cli/commands/previews-support/theme.d.ts +10 -0
- package/dist/cli/commands/previews-support/theme.d.ts.map +1 -0
- package/dist/cli/commands/previews-support/types.d.ts +70 -0
- package/dist/cli/commands/previews-support/types.d.ts.map +1 -0
- package/dist/cli/commands/previews.d.ts +4 -0
- package/dist/cli/commands/previews.d.ts.map +1 -0
- package/dist/cli/commands/productions.d.ts +4 -0
- package/dist/cli/commands/productions.d.ts.map +1 -0
- package/dist/cli/commands/remote.d.ts +1 -1
- package/dist/cli/commands/remote.d.ts.map +1 -1
- package/dist/cli/commands/secrets.d.ts +4 -0
- package/dist/cli/commands/secrets.d.ts.map +1 -0
- package/dist/cli/commands/tail.d.ts +44 -0
- package/dist/cli/commands/tail.d.ts.map +1 -0
- package/dist/cli/commands/token.d.ts +4 -0
- package/dist/cli/commands/token.d.ts.map +1 -0
- package/dist/cli/commands/type-generation/discovery.d.ts +7 -0
- package/dist/cli/commands/type-generation/discovery.d.ts.map +1 -0
- package/dist/cli/commands/type-generation/generator.d.ts +121 -0
- package/dist/cli/commands/type-generation/generator.d.ts.map +1 -0
- package/dist/cli/commands/type-generation/models.d.ts +27 -0
- package/dist/cli/commands/type-generation/models.d.ts.map +1 -0
- package/dist/cli/commands/types.d.ts +2 -2
- package/dist/cli/commands/types.d.ts.map +1 -1
- package/dist/cli/commands/worker.d.ts +4 -0
- package/dist/cli/commands/worker.d.ts.map +1 -0
- package/dist/cli/commands/workspace.d.ts +8 -0
- package/dist/cli/commands/workspace.d.ts.map +1 -0
- package/dist/cli/config-path.d.ts +6 -0
- package/dist/cli/config-path.d.ts.map +1 -0
- package/dist/cli/dependencies.d.ts +2 -1
- package/dist/cli/dependencies.d.ts.map +1 -1
- package/dist/cli/deploy-strategy.d.ts +17 -0
- package/dist/cli/deploy-strategy.d.ts.map +1 -0
- package/dist/cli/deploy-target.d.ts +17 -0
- package/dist/cli/deploy-target.d.ts.map +1 -0
- package/dist/cli/generated-artifacts.d.ts +12 -0
- package/dist/cli/generated-artifacts.d.ts.map +1 -0
- package/dist/cli/gradual-deploy.d.ts +49 -0
- package/dist/cli/gradual-deploy.d.ts.map +1 -0
- package/dist/cli/help-pages/pages/account.d.ts +3 -0
- package/dist/cli/help-pages/pages/account.d.ts.map +1 -0
- package/dist/cli/help-pages/pages/core.d.ts +4 -0
- package/dist/cli/help-pages/pages/core.d.ts.map +1 -0
- package/dist/cli/help-pages/pages/index.d.ts +3 -0
- package/dist/cli/help-pages/pages/index.d.ts.map +1 -0
- package/dist/cli/help-pages/pages/misc.d.ts +3 -0
- package/dist/cli/help-pages/pages/misc.d.ts.map +1 -0
- package/dist/cli/help-pages/pages/previews.d.ts +3 -0
- package/dist/cli/help-pages/pages/previews.d.ts.map +1 -0
- package/dist/cli/help-pages/pages/productions.d.ts +3 -0
- package/dist/cli/help-pages/pages/productions.d.ts.map +1 -0
- package/dist/cli/help-pages/render.d.ts +12 -0
- package/dist/cli/help-pages/render.d.ts.map +1 -0
- package/dist/cli/help-pages/shared.d.ts +15 -0
- package/dist/cli/help-pages/shared.d.ts.map +1 -0
- package/dist/cli/help-pages/types.d.ts +23 -0
- package/dist/cli/help-pages/types.d.ts.map +1 -0
- package/dist/cli/help.d.ts +6 -0
- package/dist/cli/help.d.ts.map +1 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +2 -0
- package/dist/cli/package-metadata.d.ts +16 -0
- package/dist/cli/package-metadata.d.ts.map +1 -0
- package/dist/cli/preview-bindings.d.ts +49 -0
- package/dist/cli/preview-bindings.d.ts.map +1 -0
- package/dist/cli/preview.d.ts +10 -0
- package/dist/cli/preview.d.ts.map +1 -0
- package/dist/cli/ui.d.ts +37 -0
- package/dist/cli/ui.d.ts.map +1 -0
- package/dist/cli/workspace-build-guard.d.ts +14 -0
- package/dist/cli/workspace-build-guard.d.ts.map +1 -0
- package/dist/cli/wrangler-auth.d.ts +1 -1
- package/dist/cloudflare/account-core.d.ts +6 -0
- package/dist/cloudflare/account-core.d.ts.map +1 -0
- package/dist/cloudflare/account-resources.d.ts +40 -0
- package/dist/cloudflare/account-resources.d.ts.map +1 -0
- package/dist/cloudflare/account-status.d.ts +11 -0
- package/dist/cloudflare/account-status.d.ts.map +1 -0
- package/dist/cloudflare/account-workers.d.ts +14 -0
- package/dist/cloudflare/account-workers.d.ts.map +1 -0
- package/dist/cloudflare/account.d.ts +7 -64
- package/dist/cloudflare/account.d.ts.map +1 -1
- package/dist/cloudflare/api.d.ts +71 -3
- package/dist/cloudflare/api.d.ts.map +1 -1
- package/dist/cloudflare/auth.d.ts +1 -1
- package/dist/cloudflare/auth.d.ts.map +1 -1
- package/dist/cloudflare/index.d.ts +61 -6
- package/dist/cloudflare/index.d.ts.map +1 -1
- package/dist/cloudflare/index.js +4 -13
- package/dist/cloudflare/known-permission-group-ids.generated.d.ts +10 -0
- package/dist/cloudflare/known-permission-group-ids.generated.d.ts.map +1 -0
- package/dist/cloudflare/kv-namespace.d.ts +4 -0
- package/dist/cloudflare/kv-namespace.d.ts.map +1 -0
- package/dist/cloudflare/preferences.d.ts +7 -0
- package/dist/cloudflare/preferences.d.ts.map +1 -1
- package/dist/cloudflare/preview-registry-cache.d.ts +6 -0
- package/dist/cloudflare/preview-registry-cache.d.ts.map +1 -0
- package/dist/cloudflare/preview-registry-inference.d.ts +14 -0
- package/dist/cloudflare/preview-registry-inference.d.ts.map +1 -0
- package/dist/cloudflare/preview-registry-records.d.ts +4 -0
- package/dist/cloudflare/preview-registry-records.d.ts.map +1 -0
- package/dist/cloudflare/preview-registry-shape.d.ts +47 -0
- package/dist/cloudflare/preview-registry-shape.d.ts.map +1 -0
- package/dist/cloudflare/preview-registry-store.d.ts +14 -0
- package/dist/cloudflare/preview-registry-store.d.ts.map +1 -0
- package/dist/cloudflare/preview-registry-transport.d.ts +4 -0
- package/dist/cloudflare/preview-registry-transport.d.ts.map +1 -0
- package/dist/cloudflare/preview-registry-types.d.ts +103 -0
- package/dist/cloudflare/preview-registry-types.d.ts.map +1 -0
- package/dist/cloudflare/preview-registry.d.ts +42 -0
- package/dist/cloudflare/preview-registry.d.ts.map +1 -0
- package/dist/cloudflare/preview-urls.d.ts +3 -0
- package/dist/cloudflare/preview-urls.d.ts.map +1 -0
- package/dist/cloudflare/registry-schema.d.ts +253 -0
- package/dist/cloudflare/registry-schema.d.ts.map +1 -0
- package/dist/cloudflare/remote-config.d.ts.map +1 -1
- package/dist/cloudflare/tokens.d.ts +44 -0
- package/dist/cloudflare/tokens.d.ts.map +1 -0
- package/dist/cloudflare/types.d.ts +124 -7
- package/dist/cloudflare/types.d.ts.map +1 -1
- package/dist/cloudflare/usage.d.ts +31 -3
- package/dist/cloudflare/usage.d.ts.map +1 -1
- package/dist/config/binding-resolution-helpers.d.ts +41 -0
- package/dist/config/binding-resolution-helpers.d.ts.map +1 -0
- package/dist/config/compatibility.d.ts +3 -0
- package/dist/config/compatibility.d.ts.map +1 -0
- package/dist/config/compiler/bindings.d.ts +14 -0
- package/dist/config/compiler/bindings.d.ts.map +1 -0
- package/dist/config/compiler/core-helpers.d.ts +6 -0
- package/dist/config/compiler/core-helpers.d.ts.map +1 -0
- package/dist/config/compiler/do-workers.d.ts +34 -0
- package/dist/config/compiler/do-workers.d.ts.map +1 -0
- package/dist/config/compiler/paths.d.ts +18 -0
- package/dist/config/compiler/paths.d.ts.map +1 -0
- package/dist/config/compiler/types.d.ts +308 -0
- package/dist/config/compiler/types.d.ts.map +1 -0
- package/dist/config/compiler.d.ts +22 -134
- package/dist/config/compiler.d.ts.map +1 -1
- package/dist/config/cron.d.ts +19 -0
- package/dist/config/cron.d.ts.map +1 -0
- package/dist/config/define.d.ts +8 -5
- package/dist/config/define.d.ts.map +1 -1
- package/dist/config/deploy-resources.d.ts +58 -0
- package/dist/config/deploy-resources.d.ts.map +1 -0
- package/dist/config/env-vars.d.ts +309 -0
- package/dist/config/env-vars.d.ts.map +1 -0
- package/dist/config/framework-providers.d.ts +9 -0
- package/dist/config/framework-providers.d.ts.map +1 -0
- package/dist/config/index.d.ts +13 -5
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/loader.d.ts +2 -1
- package/dist/config/loader.d.ts.map +1 -1
- package/dist/config/local-dev-vars.d.ts +15 -0
- package/dist/config/local-dev-vars.d.ts.map +1 -0
- package/dist/config/preview-resources.d.ts +83 -0
- package/dist/config/preview-resources.d.ts.map +1 -0
- package/dist/config/preview.d.ts +29 -0
- package/dist/config/preview.d.ts.map +1 -0
- package/dist/config/ref.d.ts +16 -25
- package/dist/config/ref.d.ts.map +1 -1
- package/dist/config/resolve-phased.d.ts +72 -0
- package/dist/config/resolve-phased.d.ts.map +1 -0
- package/dist/config/resolve.d.ts +11 -0
- package/dist/config/resolve.d.ts.map +1 -0
- package/dist/config/resource-resolution.d.ts +80 -0
- package/dist/config/resource-resolution.d.ts.map +1 -0
- package/dist/config/schema-bindings.d.ts +2124 -0
- package/dist/config/schema-bindings.d.ts.map +1 -0
- package/dist/config/schema-build.d.ts +67 -0
- package/dist/config/schema-build.d.ts.map +1 -0
- package/dist/config/schema-env.d.ts +3821 -0
- package/dist/config/schema-env.d.ts.map +1 -0
- package/dist/config/schema-normalization.d.ts +272 -0
- package/dist/config/schema-normalization.d.ts.map +1 -0
- package/dist/config/schema-runtime.d.ts +597 -0
- package/dist/config/schema-runtime.d.ts.map +1 -0
- package/dist/config/schema-types-bindings-platform.d.ts +520 -0
- package/dist/config/schema-types-bindings-platform.d.ts.map +1 -0
- package/dist/config/schema-types-bindings-resources.d.ts +802 -0
- package/dist/config/schema-types-bindings-resources.d.ts.map +1 -0
- package/dist/config/schema-types-bindings.d.ts +293 -0
- package/dist/config/schema-types-bindings.d.ts.map +1 -0
- package/dist/config/schema-types-build.d.ts +86 -0
- package/dist/config/schema-types-build.d.ts.map +1 -0
- package/dist/config/schema-types-runtime-server.d.ts +196 -0
- package/dist/config/schema-types-runtime-server.d.ts.map +1 -0
- package/dist/config/schema-types-runtime.d.ts +913 -0
- package/dist/config/schema-types-runtime.d.ts.map +1 -0
- package/dist/config/schema-types.d.ts +458 -0
- package/dist/config/schema-types.d.ts.map +1 -0
- package/dist/config/schema.d.ts +5796 -2023
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/config/service-bindings-validation.d.ts +36 -0
- package/dist/config/service-bindings-validation.d.ts.map +1 -0
- package/dist/config/workspace.d.ts +282 -0
- package/dist/config/workspace.d.ts.map +1 -0
- package/dist/config-entry.d.ts +7 -0
- package/dist/config-entry.d.ts.map +1 -0
- package/dist/config-entry.js +3 -0
- package/dist/decorators/durable-object.d.ts.map +1 -1
- package/dist/decorators/index.d.ts +2 -2
- package/dist/decorators/index.js +2 -9
- package/dist/dev-server/d1-migrations.d.ts +36 -0
- package/dist/dev-server/d1-migrations.d.ts.map +1 -0
- package/dist/dev-server/dev-server-state.d.ts +59 -0
- package/dist/dev-server/dev-server-state.d.ts.map +1 -0
- package/dist/dev-server/gateway-script.d.ts +22 -0
- package/dist/dev-server/gateway-script.d.ts.map +1 -0
- package/dist/dev-server/index.d.ts +1 -1
- package/dist/dev-server/miniflare-bindings.d.ts +90 -0
- package/dist/dev-server/miniflare-bindings.d.ts.map +1 -0
- package/dist/dev-server/miniflare-dev-config.d.ts +57 -0
- package/dist/dev-server/miniflare-dev-config.d.ts.map +1 -0
- package/dist/dev-server/miniflare-log.d.ts +20 -0
- package/dist/dev-server/miniflare-log.d.ts.map +1 -0
- package/dist/dev-server/miniflare-worker-config.d.ts +100 -0
- package/dist/dev-server/miniflare-worker-config.d.ts.map +1 -0
- package/dist/dev-server/reload-queue.d.ts +13 -0
- package/dist/dev-server/reload-queue.d.ts.map +1 -0
- package/dist/dev-server/runtime-health.d.ts +79 -0
- package/dist/dev-server/runtime-health.d.ts.map +1 -0
- package/dist/dev-server/runtime-stdio.d.ts +8 -0
- package/dist/dev-server/runtime-stdio.d.ts.map +1 -0
- package/dist/dev-server/server-startup-helpers.d.ts +84 -0
- package/dist/dev-server/server-startup-helpers.d.ts.map +1 -0
- package/dist/dev-server/server.d.ts +2 -0
- package/dist/dev-server/server.d.ts.map +1 -1
- package/dist/dev-server/vite-process.d.ts +24 -0
- package/dist/dev-server/vite-process.d.ts.map +1 -0
- package/dist/dev-server/vite-utils.d.ts +19 -1
- package/dist/dev-server/vite-utils.d.ts.map +1 -1
- package/dist/dev-server/worker-source-watcher.d.ts +17 -0
- package/dist/dev-server/worker-source-watcher.d.ts.map +1 -0
- package/dist/dev-server/worker-surface-paths.d.ts +6 -0
- package/dist/dev-server/worker-surface-paths.d.ts.map +1 -0
- package/dist/dev-server/workspace/merge-config.d.ts +81 -0
- package/dist/dev-server/workspace/merge-config.d.ts.map +1 -0
- package/dist/dev-server/workspace/prepare-app.d.ts +84 -0
- package/dist/dev-server/workspace/prepare-app.d.ts.map +1 -0
- package/dist/dev-server/workspace/server.d.ts +47 -0
- package/dist/dev-server/workspace/server.d.ts.map +1 -0
- package/dist/env.d.ts +10 -0
- package/dist/env.d.ts.map +1 -1
- package/dist/index.d.ts +8 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -297
- package/dist/runtime/context-events.d.ts +13 -0
- package/dist/runtime/context-events.d.ts.map +1 -0
- package/dist/runtime/context-types.d.ts +82 -0
- package/dist/runtime/context-types.d.ts.map +1 -0
- package/dist/runtime/context.d.ts +20 -44
- package/dist/runtime/context.d.ts.map +1 -1
- package/dist/runtime/exports.d.ts +70 -55
- package/dist/runtime/exports.d.ts.map +1 -1
- package/dist/runtime/index.d.ts +11 -5
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +5 -184
- package/dist/runtime/middleware.d.ts +119 -67
- package/dist/runtime/middleware.d.ts.map +1 -1
- package/dist/runtime/r2-presign.d.ts +164 -0
- package/dist/runtime/r2-presign.d.ts.map +1 -0
- package/dist/runtime/router/index.d.ts +7 -0
- package/dist/runtime/router/index.d.ts.map +1 -0
- package/dist/runtime/router/types.d.ts +24 -0
- package/dist/runtime/router/types.d.ts.map +1 -0
- package/dist/runtime/validation.d.ts +18 -4
- package/dist/runtime/validation.d.ts.map +1 -1
- package/dist/secrets/local-secrets.d.ts +46 -0
- package/dist/secrets/local-secrets.d.ts.map +1 -0
- package/dist/shims/local-hyperdrive.d.ts +12 -0
- package/dist/shims/local-hyperdrive.d.ts.map +1 -0
- package/dist/shims/local-media-bindings.d.ts +19 -0
- package/dist/shims/local-media-bindings.d.ts.map +1 -0
- package/dist/shims/local-worker-loader.d.ts +3 -0
- package/dist/shims/local-worker-loader.d.ts.map +1 -0
- package/dist/sveltekit/index.d.ts +1 -1
- package/dist/sveltekit/index.d.ts.map +1 -1
- package/dist/sveltekit/index.js +377 -169
- package/dist/sveltekit/local-bindings.d.ts +4 -0
- package/dist/sveltekit/local-bindings.d.ts.map +1 -0
- package/dist/sveltekit/platform.d.ts +42 -2
- package/dist/sveltekit/platform.d.ts.map +1 -1
- package/dist/test/ai-search.d.ts +39 -0
- package/dist/test/ai-search.d.ts.map +1 -0
- package/dist/test/alarm.d.ts +55 -0
- package/dist/test/alarm.d.ts.map +1 -0
- package/dist/test/binding-hints.d.ts +10 -0
- package/dist/test/binding-hints.d.ts.map +1 -0
- package/dist/test/cf.d.ts +71 -35
- package/dist/test/cf.d.ts.map +1 -1
- package/dist/test/containers.d.ts +87 -0
- package/dist/test/containers.d.ts.map +1 -0
- package/dist/test/email.d.ts +16 -7
- package/dist/test/email.d.ts.map +1 -1
- package/dist/test/index.d.ts +20 -21
- package/dist/test/index.d.ts.map +1 -1
- package/dist/test/index.js +5115 -75
- package/dist/test/offline-bindings.d.ts +124 -0
- package/dist/test/offline-bindings.d.ts.map +1 -0
- package/dist/test/queue.d.ts.map +1 -1
- package/dist/test/remote-ai.d.ts.map +1 -1
- package/dist/test/remote-cloudflare.d.ts +13 -0
- package/dist/test/remote-cloudflare.d.ts.map +1 -0
- package/dist/test/remote-vectorize.d.ts.map +1 -1
- package/dist/test/resolve-service-bindings.d.ts +64 -4
- package/dist/test/resolve-service-bindings.d.ts.map +1 -1
- package/dist/test/scheduled.d.ts.map +1 -1
- package/dist/test/should-skip.d.ts +14 -18
- package/dist/test/should-skip.d.ts.map +1 -1
- package/dist/test/simple-context-bindings.d.ts +13 -0
- package/dist/test/simple-context-bindings.d.ts.map +1 -0
- package/dist/test/simple-context-durable-objects.d.ts +6 -0
- package/dist/test/simple-context-durable-objects.d.ts.map +1 -0
- package/dist/test/simple-context-env.d.ts +35 -0
- package/dist/test/simple-context-env.d.ts.map +1 -0
- package/dist/test/simple-context-gateway-script.d.ts +2 -0
- package/dist/test/simple-context-gateway-script.d.ts.map +1 -0
- package/dist/test/simple-context-handlers.d.ts +12 -0
- package/dist/test/simple-context-handlers.d.ts.map +1 -0
- package/dist/test/simple-context-lifecycle.d.ts +32 -0
- package/dist/test/simple-context-lifecycle.d.ts.map +1 -0
- package/dist/test/simple-context-mfconfig.d.ts +18 -0
- package/dist/test/simple-context-mfconfig.d.ts.map +1 -0
- package/dist/test/simple-context-multi-worker.d.ts +16 -0
- package/dist/test/simple-context-multi-worker.d.ts.map +1 -0
- package/dist/test/simple-context-paths.d.ts +40 -0
- package/dist/test/simple-context-paths.d.ts.map +1 -0
- package/dist/test/simple-context-runtime.d.ts +19 -0
- package/dist/test/simple-context-runtime.d.ts.map +1 -0
- package/dist/test/simple-context-startup.d.ts +11 -0
- package/dist/test/simple-context-startup.d.ts.map +1 -0
- package/dist/test/simple-context-transport.d.ts +14 -0
- package/dist/test/simple-context-transport.d.ts.map +1 -0
- package/dist/test/simple-context.d.ts +8 -27
- package/dist/test/simple-context.d.ts.map +1 -1
- package/dist/test/tail.d.ts +3 -2
- package/dist/test/tail.d.ts.map +1 -1
- package/dist/test/utilities/analytics-engine.d.ts +22 -0
- package/dist/test/utilities/analytics-engine.d.ts.map +1 -0
- package/dist/test/utilities/artifacts.d.ts +11 -0
- package/dist/test/utilities/artifacts.d.ts.map +1 -0
- package/dist/test/utilities/context.d.ts +39 -0
- package/dist/test/utilities/context.d.ts.map +1 -0
- package/dist/test/utilities/d1.d.ts +21 -0
- package/dist/test/utilities/d1.d.ts.map +1 -0
- package/dist/test/utilities/env.d.ts +45 -0
- package/dist/test/utilities/env.d.ts.map +1 -0
- package/dist/test/utilities/kv.d.ts +11 -0
- package/dist/test/utilities/kv.d.ts.map +1 -0
- package/dist/test/utilities/media.d.ts +16 -0
- package/dist/test/utilities/media.d.ts.map +1 -0
- package/dist/test/utilities/platform.d.ts +41 -0
- package/dist/test/utilities/platform.d.ts.map +1 -0
- package/dist/test/utilities/queue.d.ts +5 -0
- package/dist/test/utilities/queue.d.ts.map +1 -0
- package/dist/test/utilities/r2.d.ts +2 -0
- package/dist/test/utilities/r2.d.ts.map +1 -0
- package/dist/test/utilities/send-email.d.ts +27 -0
- package/dist/test/utilities/send-email.d.ts.map +1 -0
- package/dist/test/utilities/stream-flagship.d.ts +27 -0
- package/dist/test/utilities/stream-flagship.d.ts.map +1 -0
- package/dist/test/utilities/vectorize.d.ts +38 -0
- package/dist/test/utilities/vectorize.d.ts.map +1 -0
- package/dist/test/utilities/workflows.d.ts +26 -0
- package/dist/test/utilities/workflows.d.ts.map +1 -0
- package/dist/test/utilities.d.ts +14 -98
- package/dist/test/utilities.d.ts.map +1 -1
- package/dist/test/worker.d.ts +6 -0
- package/dist/test/worker.d.ts.map +1 -1
- package/dist/transform/durable-object.d.ts.map +1 -1
- package/dist/transform/index.d.ts +2 -2
- package/dist/transform/worker-entrypoint.d.ts +5 -0
- package/dist/transform/worker-entrypoint.d.ts.map +1 -1
- package/dist/utils/entrypoint-discovery.d.ts +6 -3
- package/dist/utils/entrypoint-discovery.d.ts.map +1 -1
- package/dist/utils/generated-dir.d.ts +25 -0
- package/dist/utils/generated-dir.d.ts.map +1 -0
- package/dist/utils/glob.d.ts.map +1 -1
- package/dist/utils/resolve-package.d.ts.map +1 -1
- package/dist/utils/send-email.d.ts +15 -0
- package/dist/utils/send-email.d.ts.map +1 -0
- package/dist/utils/send-email.js +163 -0
- package/dist/vite/config-file.d.ts +25 -0
- package/dist/vite/config-file.d.ts.map +1 -0
- package/dist/vite/index.d.ts +3 -2
- package/dist/vite/index.d.ts.map +1 -1
- package/dist/vite/index.js +2 -407
- package/dist/vite/plugin-config-hook.d.ts +28 -0
- package/dist/vite/plugin-config-hook.d.ts.map +1 -0
- package/dist/vite/plugin-context.d.ts +27 -0
- package/dist/vite/plugin-context.d.ts.map +1 -0
- package/dist/vite/plugin-durable-objects.d.ts +18 -0
- package/dist/vite/plugin-durable-objects.d.ts.map +1 -0
- package/dist/vite/plugin-programmatic.d.ts +44 -0
- package/dist/vite/plugin-programmatic.d.ts.map +1 -0
- package/dist/vite/plugin-service-bindings.d.ts +13 -0
- package/dist/vite/plugin-service-bindings.d.ts.map +1 -0
- package/dist/vite/plugin-transform.d.ts +41 -0
- package/dist/vite/plugin-transform.d.ts.map +1 -0
- package/dist/vite/plugin.d.ts +10 -41
- package/dist/vite/plugin.d.ts.map +1 -1
- package/dist/worker-entry/composed-worker.d.ts +5 -8
- package/dist/worker-entry/composed-worker.d.ts.map +1 -1
- package/dist/worker-entry/durable-object-discovery.d.ts +20 -0
- package/dist/worker-entry/durable-object-discovery.d.ts.map +1 -0
- package/dist/worker-entry/extensions.d.ts +5 -0
- package/dist/worker-entry/extensions.d.ts.map +1 -0
- package/dist/worker-entry/routes.d.ts +22 -0
- package/dist/worker-entry/routes.d.ts.map +1 -0
- package/dist/worker-entry/surface-paths.d.ts +26 -0
- package/dist/worker-entry/surface-paths.d.ts.map +1 -0
- package/dist/worker-entry/validate-fetch-style.d.ts +12 -0
- package/dist/worker-entry/validate-fetch-style.d.ts.map +1 -0
- package/dist/workflows/local-workflow-entrypoints.d.ts +7 -0
- package/dist/workflows/local-workflow-entrypoints.d.ts.map +1 -0
- package/package.json +160 -117
- package/R2.md +0 -170
- package/dist/account-rvrj687w.js +0 -397
- package/dist/ai-dx4fr9jh.js +0 -107
- package/dist/bridge/protocol.d.ts.map +0 -1
- package/dist/bridge/serialization.d.ts +0 -83
- package/dist/bridge/serialization.d.ts.map +0 -1
- package/dist/browser-shim/worker.d.ts +0 -14
- package/dist/browser-shim/worker.d.ts.map +0 -1
- package/dist/build-9myaxf07.js +0 -70
- package/dist/deploy-h1wz5p7m.js +0 -86
- package/dist/dev-rsdssknb.js +0 -2707
- package/dist/doctor-v7jy4s3r.js +0 -190
- package/dist/durable-object-t4kbb0yt.js +0 -13
- package/dist/index-18hvb6gb.js +0 -194
- package/dist/index-1xpj0m4r.js +0 -57
- package/dist/index-37x76zdn.js +0 -4
- package/dist/index-3t6rypgc.js +0 -13
- package/dist/index-62b3gt2g.js +0 -12
- package/dist/index-67qcae0f.js +0 -183
- package/dist/index-9ats0s83.js +0 -70
- package/dist/index-a0fjkq68.js +0 -198
- package/dist/index-a855bdsx.js +0 -18
- package/dist/index-ccrh4w3t.js +0 -1133
- package/dist/index-d8bdkx2h.js +0 -109
- package/dist/index-f8qh2tyh.js +0 -2152
- package/dist/index-gz1gndna.js +0 -307
- package/dist/index-hcex3rgh.js +0 -266
- package/dist/index-k7r18na8.js +0 -0
- package/dist/index-n3np2d6t.js +0 -462
- package/dist/index-n7rs26ft.js +0 -77
- package/dist/index-npc1c8jx.js +0 -44
- package/dist/index-p7g30wd2.js +0 -281
- package/dist/index-rbht7m9r.js +0 -36
- package/dist/index-tfyxa77h.js +0 -850
- package/dist/index-tk6ej9dj.js +0 -94
- package/dist/index-v8vvsn9x.js +0 -169
- package/dist/index-z14anrqp.js +0 -226
- package/dist/init-f9mgmew3.js +0 -186
- package/dist/remote-q59qk463.js +0 -97
- package/dist/test/bridge-context.d.ts +0 -76
- package/dist/test/bridge-context.d.ts.map +0 -1
- package/dist/test/multi-worker-context.d.ts +0 -114
- package/dist/test/multi-worker-context.d.ts.map +0 -1
- package/dist/types-wdcpnfvy.js +0 -487
- package/dist/worker-entrypoint-m9th0rg0.js +0 -13
package/dist/index-tk6ej9dj.js
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
DEFAULT_ENTRYPOINT_PATTERN,
|
|
3
|
-
findFiles
|
|
4
|
-
} from "./index-rbht7m9r.js";
|
|
5
|
-
import {
|
|
6
|
-
__require
|
|
7
|
-
} from "./index-37x76zdn.js";
|
|
8
|
-
|
|
9
|
-
// src/utils/entrypoint-discovery.ts
|
|
10
|
-
import { readdirSync, readFileSync } from "fs";
|
|
11
|
-
import { join } from "path";
|
|
12
|
-
var ENTRYPOINT_CLASS_PATTERN = /export\s+class\s+(\w+)\s+extends\s+WorkerEntrypoint/g;
|
|
13
|
-
function findEntrypointClasses(code) {
|
|
14
|
-
const classes = [];
|
|
15
|
-
ENTRYPOINT_CLASS_PATTERN.lastIndex = 0;
|
|
16
|
-
let match;
|
|
17
|
-
while ((match = ENTRYPOINT_CLASS_PATTERN.exec(code)) !== null) {
|
|
18
|
-
classes.push(match[1]);
|
|
19
|
-
}
|
|
20
|
-
return classes;
|
|
21
|
-
}
|
|
22
|
-
var EP_FILE_PATTERN = /^ep\.[^.]+\.ts$/;
|
|
23
|
-
function discoverEntrypointsSync(dir) {
|
|
24
|
-
const discovered = [];
|
|
25
|
-
try {
|
|
26
|
-
const files = readdirSync(dir, { withFileTypes: true });
|
|
27
|
-
for (const file of files) {
|
|
28
|
-
if (file.isFile() && EP_FILE_PATTERN.test(file.name)) {
|
|
29
|
-
const filePath = join(dir, file.name);
|
|
30
|
-
try {
|
|
31
|
-
const code = readFileSync(filePath, "utf-8");
|
|
32
|
-
const classNames = findEntrypointClasses(code);
|
|
33
|
-
for (const className of classNames) {
|
|
34
|
-
discovered.push({ className, filePath });
|
|
35
|
-
}
|
|
36
|
-
} catch {}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
} catch {}
|
|
40
|
-
return discovered;
|
|
41
|
-
}
|
|
42
|
-
async function discoverEntrypointsAsync(cwd, pattern = DEFAULT_ENTRYPOINT_PATTERN) {
|
|
43
|
-
const fs = await import("node:fs/promises");
|
|
44
|
-
const discovered = [];
|
|
45
|
-
const files = await findFiles(pattern, { cwd });
|
|
46
|
-
for (const filePath of files) {
|
|
47
|
-
try {
|
|
48
|
-
const code = await fs.readFile(filePath, "utf-8");
|
|
49
|
-
const classNames = findEntrypointClasses(code);
|
|
50
|
-
for (const className of classNames) {
|
|
51
|
-
discovered.push({ className, filePath });
|
|
52
|
-
}
|
|
53
|
-
} catch {}
|
|
54
|
-
}
|
|
55
|
-
return discovered;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// src/utils/resolve-package.ts
|
|
59
|
-
import { resolve, dirname } from "pathe";
|
|
60
|
-
import { readFileSync as readFileSync2, existsSync } from "node:fs";
|
|
61
|
-
function resolvePackageSpecifier(specifier, fromDir) {
|
|
62
|
-
if (specifier.startsWith(".") || specifier.startsWith("/") || /^[A-Za-z]:/.test(specifier)) {
|
|
63
|
-
return resolve(fromDir, specifier);
|
|
64
|
-
}
|
|
65
|
-
try {
|
|
66
|
-
const parts = specifier.startsWith("@") ? specifier.split("/").slice(0, 2).join("/") : specifier.split("/")[0];
|
|
67
|
-
const subpath = specifier.startsWith("@") ? specifier.split("/").slice(2).join("/") : specifier.split("/").slice(1).join("/");
|
|
68
|
-
const pkgJsonPath = __require.resolve(`${parts}/package.json`, { paths: [fromDir] });
|
|
69
|
-
const pkgDir = dirname(pkgJsonPath);
|
|
70
|
-
if (subpath) {
|
|
71
|
-
const pkgJson = JSON.parse(readFileSync2(pkgJsonPath, "utf-8"));
|
|
72
|
-
const exportPath = pkgJson.exports?.[`./${subpath}`];
|
|
73
|
-
if (exportPath) {
|
|
74
|
-
const targetPath = typeof exportPath === "string" ? exportPath : exportPath.default || exportPath.import;
|
|
75
|
-
return resolve(pkgDir, targetPath);
|
|
76
|
-
}
|
|
77
|
-
const directPath = resolve(pkgDir, `${subpath}.ts`);
|
|
78
|
-
if (existsSync(directPath))
|
|
79
|
-
return directPath;
|
|
80
|
-
const withExt = resolve(pkgDir, subpath);
|
|
81
|
-
if (existsSync(withExt))
|
|
82
|
-
return withExt;
|
|
83
|
-
if (existsSync(`${withExt}.ts`))
|
|
84
|
-
return `${withExt}.ts`;
|
|
85
|
-
if (existsSync(`${withExt}.js`))
|
|
86
|
-
return `${withExt}.js`;
|
|
87
|
-
}
|
|
88
|
-
return pkgDir;
|
|
89
|
-
} catch {
|
|
90
|
-
return resolve(fromDir, specifier);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export { discoverEntrypointsSync, discoverEntrypointsAsync, resolvePackageSpecifier };
|
package/dist/index-v8vvsn9x.js
DELETED
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
// src/config/define.ts
|
|
2
|
-
function defineConfig(config) {
|
|
3
|
-
if (typeof config === "function") {
|
|
4
|
-
const result = config();
|
|
5
|
-
if (result instanceof Promise) {
|
|
6
|
-
return result;
|
|
7
|
-
}
|
|
8
|
-
return result;
|
|
9
|
-
}
|
|
10
|
-
return config;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
// src/config/ref.ts
|
|
14
|
-
var resolvedCache = new WeakMap;
|
|
15
|
-
var pendingResolutions = new WeakMap;
|
|
16
|
-
function ref(nameOrImport, maybeImport) {
|
|
17
|
-
const nameOverride = typeof nameOrImport === "string" ? nameOrImport : undefined;
|
|
18
|
-
const importFn = typeof nameOrImport === "function" ? nameOrImport : maybeImport;
|
|
19
|
-
if (!importFn) {
|
|
20
|
-
throw new Error("ref() requires an import function");
|
|
21
|
-
}
|
|
22
|
-
const fnSource = importFn.toString();
|
|
23
|
-
const importMatch = fnSource.match(/import\s*\(\s*['"]([^'"]+)['"]\s*\)/);
|
|
24
|
-
const configPath = importMatch?.[1] ?? "<pending>";
|
|
25
|
-
async function doResolve() {
|
|
26
|
-
const cached = resolvedCache.get(proxy);
|
|
27
|
-
if (cached)
|
|
28
|
-
return cached;
|
|
29
|
-
const pending = pendingResolutions.get(proxy);
|
|
30
|
-
if (pending)
|
|
31
|
-
return pending;
|
|
32
|
-
const promise = (async () => {
|
|
33
|
-
const module = await importFn();
|
|
34
|
-
const config = "default" in module ? module.default : module;
|
|
35
|
-
if (!config.name && !nameOverride) {
|
|
36
|
-
throw new Error('Referenced config must have a "name" property');
|
|
37
|
-
}
|
|
38
|
-
const resolved = {
|
|
39
|
-
name: nameOverride ?? config.name,
|
|
40
|
-
config,
|
|
41
|
-
configPath
|
|
42
|
-
};
|
|
43
|
-
resolvedCache.set(proxy, resolved);
|
|
44
|
-
return resolved;
|
|
45
|
-
})();
|
|
46
|
-
pendingResolutions.set(proxy, promise);
|
|
47
|
-
return promise;
|
|
48
|
-
}
|
|
49
|
-
function getResolved() {
|
|
50
|
-
const cached = resolvedCache.get(proxy);
|
|
51
|
-
if (cached)
|
|
52
|
-
return cached;
|
|
53
|
-
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.");
|
|
54
|
-
}
|
|
55
|
-
function createWorkerBinding(entrypoint) {
|
|
56
|
-
return {
|
|
57
|
-
get service() {
|
|
58
|
-
const cached = resolvedCache.get(proxy);
|
|
59
|
-
if (cached)
|
|
60
|
-
return cached.name;
|
|
61
|
-
if (nameOverride)
|
|
62
|
-
return nameOverride;
|
|
63
|
-
return "<pending>";
|
|
64
|
-
},
|
|
65
|
-
entrypoint,
|
|
66
|
-
__ref: proxy
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
const workerAccessor = new Proxy((entrypoint) => createWorkerBinding(entrypoint), {
|
|
70
|
-
get(target, prop) {
|
|
71
|
-
if (prop === "service") {
|
|
72
|
-
const cached = resolvedCache.get(proxy);
|
|
73
|
-
if (cached)
|
|
74
|
-
return cached.name;
|
|
75
|
-
if (nameOverride)
|
|
76
|
-
return nameOverride;
|
|
77
|
-
return "<pending>";
|
|
78
|
-
}
|
|
79
|
-
if (prop === "entrypoint")
|
|
80
|
-
return;
|
|
81
|
-
if (prop === "__ref")
|
|
82
|
-
return proxy;
|
|
83
|
-
return Reflect.get(target, prop);
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
function createDOBinding(bindingName) {
|
|
87
|
-
return {
|
|
88
|
-
get className() {
|
|
89
|
-
const cached = resolvedCache.get(proxy);
|
|
90
|
-
if (cached?.config.bindings?.durableObjects) {
|
|
91
|
-
const doBindings = cached.config.bindings.durableObjects;
|
|
92
|
-
const doConfig = doBindings[bindingName];
|
|
93
|
-
if (typeof doConfig === "string") {
|
|
94
|
-
return doConfig;
|
|
95
|
-
} else if (doConfig && typeof doConfig === "object" && "className" in doConfig) {
|
|
96
|
-
return doConfig.className;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
return bindingName;
|
|
100
|
-
},
|
|
101
|
-
get scriptName() {
|
|
102
|
-
const cached = resolvedCache.get(proxy);
|
|
103
|
-
if (cached)
|
|
104
|
-
return cached.name;
|
|
105
|
-
if (nameOverride)
|
|
106
|
-
return nameOverride;
|
|
107
|
-
return "<pending>";
|
|
108
|
-
},
|
|
109
|
-
__ref: proxy
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
const knownProps = new Set(["name", "config", "configPath", "worker", "__import", "__nameOverride", "resolve", "then"]);
|
|
113
|
-
const proxyTarget = {
|
|
114
|
-
get name() {
|
|
115
|
-
return getResolved().name;
|
|
116
|
-
},
|
|
117
|
-
get config() {
|
|
118
|
-
return getResolved().config;
|
|
119
|
-
},
|
|
120
|
-
configPath,
|
|
121
|
-
worker: workerAccessor,
|
|
122
|
-
__import: importFn,
|
|
123
|
-
__nameOverride: nameOverride,
|
|
124
|
-
resolve: doResolve
|
|
125
|
-
};
|
|
126
|
-
const proxy = new Proxy(proxyTarget, {
|
|
127
|
-
get(target, prop) {
|
|
128
|
-
if (typeof prop === "string" && knownProps.has(prop)) {
|
|
129
|
-
return Reflect.get(target, prop);
|
|
130
|
-
}
|
|
131
|
-
if (typeof prop === "symbol") {
|
|
132
|
-
return Reflect.get(target, prop);
|
|
133
|
-
}
|
|
134
|
-
if (typeof prop === "string" && /^[A-Z][A-Z0-9_]*$/.test(prop)) {
|
|
135
|
-
return createDOBinding(prop);
|
|
136
|
-
}
|
|
137
|
-
return Reflect.get(target, prop);
|
|
138
|
-
},
|
|
139
|
-
has(target, prop) {
|
|
140
|
-
if (typeof prop === "string") {
|
|
141
|
-
if (knownProps.has(prop))
|
|
142
|
-
return true;
|
|
143
|
-
if (/^[A-Z][A-Z0-9_]*$/.test(prop))
|
|
144
|
-
return true;
|
|
145
|
-
}
|
|
146
|
-
return Reflect.has(target, prop);
|
|
147
|
-
}
|
|
148
|
-
});
|
|
149
|
-
return proxy;
|
|
150
|
-
}
|
|
151
|
-
async function resolveRef(configImport, options) {
|
|
152
|
-
const result = options?.workerName ? ref(options.workerName, configImport) : ref(configImport);
|
|
153
|
-
await result.resolve();
|
|
154
|
-
return result;
|
|
155
|
-
}
|
|
156
|
-
function serviceBinding(refOrLegacy, options) {
|
|
157
|
-
if ("worker" in refOrLegacy) {
|
|
158
|
-
const entrypoint2 = options?.entrypoint;
|
|
159
|
-
return entrypoint2 ? refOrLegacy.worker(entrypoint2) : refOrLegacy.worker;
|
|
160
|
-
}
|
|
161
|
-
const entrypoint = options?.entrypoint ?? refOrLegacy.entrypoint;
|
|
162
|
-
return {
|
|
163
|
-
service: refOrLegacy.name,
|
|
164
|
-
...entrypoint && { entrypoint },
|
|
165
|
-
__ref: refOrLegacy
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
export { defineConfig, ref, resolveRef, serviceBinding };
|
package/dist/index-z14anrqp.js
DELETED
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
// src/transform/worker-entrypoint.ts
|
|
2
|
-
import ts from "typescript";
|
|
3
|
-
import MagicString from "magic-string";
|
|
4
|
-
function findExportedFunctions(code) {
|
|
5
|
-
const functions = [];
|
|
6
|
-
const sourceFile = ts.createSourceFile("worker.ts", code, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);
|
|
7
|
-
function visit(node) {
|
|
8
|
-
if (ts.isFunctionDeclaration(node) && node.name) {
|
|
9
|
-
const modifiers = ts.getModifiers(node);
|
|
10
|
-
const isExported = modifiers?.some((m) => m.kind === ts.SyntaxKind.ExportKeyword);
|
|
11
|
-
const isDefault = modifiers?.some((m) => m.kind === ts.SyntaxKind.DefaultKeyword);
|
|
12
|
-
if (isExported) {
|
|
13
|
-
const isAsync = modifiers?.some((m) => m.kind === ts.SyntaxKind.AsyncKeyword) ?? false;
|
|
14
|
-
const funcName = isDefault ? "fetch" : node.name.text;
|
|
15
|
-
const params = node.parameters.map((p) => code.substring(p.getStart(sourceFile), p.getEnd())).join(", ");
|
|
16
|
-
const returnType = node.type ? code.substring(node.type.getStart(sourceFile), node.type.getEnd()) : undefined;
|
|
17
|
-
functions.push({
|
|
18
|
-
name: funcName,
|
|
19
|
-
isAsync,
|
|
20
|
-
params,
|
|
21
|
-
returnType,
|
|
22
|
-
start: node.getStart(sourceFile),
|
|
23
|
-
end: node.getEnd(),
|
|
24
|
-
isDefault
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
if (ts.isFunctionDeclaration(node) && !node.name) {
|
|
29
|
-
const modifiers = ts.getModifiers(node);
|
|
30
|
-
const isExported = modifiers?.some((m) => m.kind === ts.SyntaxKind.ExportKeyword);
|
|
31
|
-
const isDefault = modifiers?.some((m) => m.kind === ts.SyntaxKind.DefaultKeyword);
|
|
32
|
-
if (isExported && isDefault) {
|
|
33
|
-
const isAsync = modifiers?.some((m) => m.kind === ts.SyntaxKind.AsyncKeyword) ?? false;
|
|
34
|
-
const params = node.parameters.map((p) => code.substring(p.getStart(sourceFile), p.getEnd())).join(", ");
|
|
35
|
-
const returnType = node.type ? code.substring(node.type.getStart(sourceFile), node.type.getEnd()) : undefined;
|
|
36
|
-
functions.push({
|
|
37
|
-
name: "fetch",
|
|
38
|
-
isAsync,
|
|
39
|
-
params,
|
|
40
|
-
returnType,
|
|
41
|
-
start: node.getStart(sourceFile),
|
|
42
|
-
end: node.getEnd(),
|
|
43
|
-
isDefault: true
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
if (ts.isVariableStatement(node)) {
|
|
48
|
-
const modifiers = ts.getModifiers(node);
|
|
49
|
-
const isExported = modifiers?.some((m) => m.kind === ts.SyntaxKind.ExportKeyword);
|
|
50
|
-
if (isExported) {
|
|
51
|
-
for (const decl of node.declarationList.declarations) {
|
|
52
|
-
if (ts.isIdentifier(decl.name) && decl.initializer) {
|
|
53
|
-
let funcExpr;
|
|
54
|
-
if (ts.isFunctionExpression(decl.initializer)) {
|
|
55
|
-
funcExpr = decl.initializer;
|
|
56
|
-
} else if (ts.isArrowFunction(decl.initializer)) {
|
|
57
|
-
funcExpr = decl.initializer;
|
|
58
|
-
}
|
|
59
|
-
if (funcExpr) {
|
|
60
|
-
const modifiersArr = ts.getModifiers(funcExpr);
|
|
61
|
-
const isAsync = modifiersArr?.some((m) => m.kind === ts.SyntaxKind.AsyncKeyword) ?? (ts.isArrowFunction(funcExpr) && funcExpr.modifiers?.some((m) => m.kind === ts.SyntaxKind.AsyncKeyword)) ?? false;
|
|
62
|
-
const params = funcExpr.parameters.map((p) => code.substring(p.getStart(sourceFile), p.getEnd())).join(", ");
|
|
63
|
-
const returnType = funcExpr.type ? code.substring(funcExpr.type.getStart(sourceFile), funcExpr.type.getEnd()) : undefined;
|
|
64
|
-
functions.push({
|
|
65
|
-
name: decl.name.text,
|
|
66
|
-
isAsync,
|
|
67
|
-
params,
|
|
68
|
-
returnType,
|
|
69
|
-
start: node.getStart(sourceFile),
|
|
70
|
-
end: node.getEnd()
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
ts.forEachChild(node, visit);
|
|
78
|
-
}
|
|
79
|
-
visit(sourceFile);
|
|
80
|
-
return functions;
|
|
81
|
-
}
|
|
82
|
-
function shouldTransformWorker(code, filePath) {
|
|
83
|
-
if (!filePath.endsWith("worker.ts") && !filePath.endsWith("worker.js")) {
|
|
84
|
-
return false;
|
|
85
|
-
}
|
|
86
|
-
const functions = findExportedFunctions(code);
|
|
87
|
-
return functions.length > 0;
|
|
88
|
-
}
|
|
89
|
-
function transformWorkerEntrypoint(code, id, options = {}) {
|
|
90
|
-
const className = options.className ?? "Worker";
|
|
91
|
-
const injectContext = options.injectContext ?? true;
|
|
92
|
-
const functions = findExportedFunctions(code);
|
|
93
|
-
if (functions.length === 0) {
|
|
94
|
-
return null;
|
|
95
|
-
}
|
|
96
|
-
const fetchFn = functions.find((f) => f.name === "fetch");
|
|
97
|
-
const rpcMethods = functions.filter((f) => f.name !== "fetch");
|
|
98
|
-
const s = new MagicString(code);
|
|
99
|
-
const importStatement = `import { WorkerEntrypoint } from 'cloudflare:workers'
|
|
100
|
-
`;
|
|
101
|
-
if (injectContext) {
|
|
102
|
-
s.prepend(`import { runWithContext } from 'devflare/runtime'
|
|
103
|
-
`);
|
|
104
|
-
}
|
|
105
|
-
s.prepend(importStatement);
|
|
106
|
-
for (const fn of functions) {
|
|
107
|
-
const fnCode = code.substring(fn.start, fn.end);
|
|
108
|
-
const internalName = fn.name === "fetch" ? "__originalFetch" : `__original_${fn.name}`;
|
|
109
|
-
if (fn.isDefault) {
|
|
110
|
-
const replacement = fnCode.replace(/^export\s+default\s+(async\s+)?function\s*/, (_, asyncKw) => `const ${internalName} = ${asyncKw || ""}function `);
|
|
111
|
-
s.overwrite(fn.start, fn.end, replacement);
|
|
112
|
-
} else if (fnCode.startsWith("export function") || fnCode.startsWith("export async function")) {
|
|
113
|
-
const replacement = fnCode.replace(/^export\s+(async\s+)?function\s+\w+/, (_, asyncKw) => `${asyncKw || ""}function ${internalName}`);
|
|
114
|
-
s.overwrite(fn.start, fn.end, replacement);
|
|
115
|
-
} else if (fnCode.startsWith("export const")) {
|
|
116
|
-
const replacement = fnCode.replace(/^export\s+const\s+\w+/, () => `const ${internalName}`);
|
|
117
|
-
s.overwrite(fn.start, fn.end, replacement);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
let classBody = `
|
|
121
|
-
|
|
122
|
-
// ============ Devflare WorkerEntrypoint ============
|
|
123
|
-
class ${className} extends WorkerEntrypoint {
|
|
124
|
-
`;
|
|
125
|
-
if (fetchFn) {
|
|
126
|
-
if (injectContext) {
|
|
127
|
-
classBody += ` async fetch(request: Request): Promise<Response> {
|
|
128
|
-
`;
|
|
129
|
-
classBody += ` return runWithContext(
|
|
130
|
-
`;
|
|
131
|
-
classBody += ` this.env,
|
|
132
|
-
`;
|
|
133
|
-
classBody += ` this.ctx,
|
|
134
|
-
`;
|
|
135
|
-
classBody += ` request,
|
|
136
|
-
`;
|
|
137
|
-
classBody += ` () => __originalFetch(request, this.env, this.ctx),
|
|
138
|
-
`;
|
|
139
|
-
classBody += ` 'fetch'
|
|
140
|
-
`;
|
|
141
|
-
classBody += ` )
|
|
142
|
-
`;
|
|
143
|
-
classBody += ` }
|
|
144
|
-
`;
|
|
145
|
-
} else {
|
|
146
|
-
classBody += ` async fetch(request: Request): Promise<Response> {
|
|
147
|
-
`;
|
|
148
|
-
classBody += ` return __originalFetch(request, this.env, this.ctx)
|
|
149
|
-
`;
|
|
150
|
-
classBody += ` }
|
|
151
|
-
`;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
for (const fn of rpcMethods) {
|
|
155
|
-
const asyncPrefix = fn.isAsync ? "async " : "";
|
|
156
|
-
const returnType = fn.returnType ? `: ${fn.returnType}` : "";
|
|
157
|
-
const paramNames = extractParamNames(fn.params);
|
|
158
|
-
classBody += `
|
|
159
|
-
${asyncPrefix}${fn.name}(${fn.params})${returnType} {
|
|
160
|
-
`;
|
|
161
|
-
classBody += ` return __original_${fn.name}(${paramNames})
|
|
162
|
-
`;
|
|
163
|
-
classBody += ` }
|
|
164
|
-
`;
|
|
165
|
-
}
|
|
166
|
-
classBody += `}
|
|
167
|
-
|
|
168
|
-
`;
|
|
169
|
-
classBody += `export { ${className} }
|
|
170
|
-
`;
|
|
171
|
-
classBody += `export { ${className} as default }
|
|
172
|
-
`;
|
|
173
|
-
classBody += `// ============ End Devflare WorkerEntrypoint ============
|
|
174
|
-
`;
|
|
175
|
-
s.append(classBody);
|
|
176
|
-
return {
|
|
177
|
-
code: s.toString(),
|
|
178
|
-
map: s.generateMap({
|
|
179
|
-
source: id,
|
|
180
|
-
file: id + ".map",
|
|
181
|
-
includeContent: true
|
|
182
|
-
}),
|
|
183
|
-
rpcMethods: rpcMethods.map((fn) => fn.name),
|
|
184
|
-
className
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
function extractParamNames(params) {
|
|
188
|
-
if (!params.trim())
|
|
189
|
-
return "";
|
|
190
|
-
const tempCode = `function f(${params}) {}`;
|
|
191
|
-
const sourceFile = ts.createSourceFile("temp.ts", tempCode, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);
|
|
192
|
-
const names = [];
|
|
193
|
-
function visit(node) {
|
|
194
|
-
if (ts.isFunctionDeclaration(node)) {
|
|
195
|
-
for (const param of node.parameters) {
|
|
196
|
-
if (ts.isIdentifier(param.name)) {
|
|
197
|
-
names.push(param.name.text);
|
|
198
|
-
} else if (ts.isObjectBindingPattern(param.name) || ts.isArrayBindingPattern(param.name)) {
|
|
199
|
-
names.push(tempCode.substring(param.name.getStart(sourceFile), param.name.getEnd()));
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
ts.forEachChild(node, visit);
|
|
204
|
-
}
|
|
205
|
-
visit(sourceFile);
|
|
206
|
-
return names.join(", ");
|
|
207
|
-
}
|
|
208
|
-
function generateRpcInterface(functions, interfaceName) {
|
|
209
|
-
const rpcMethods = functions.filter((f) => f.name !== "fetch");
|
|
210
|
-
if (rpcMethods.length === 0) {
|
|
211
|
-
return "";
|
|
212
|
-
}
|
|
213
|
-
let output = `export interface ${interfaceName} {
|
|
214
|
-
`;
|
|
215
|
-
for (const fn of rpcMethods) {
|
|
216
|
-
const returnType = fn.returnType ?? "unknown";
|
|
217
|
-
const promiseReturn = returnType.startsWith("Promise<") ? returnType : `Promise<${returnType}>`;
|
|
218
|
-
output += ` ${fn.name}(${fn.params}): ${promiseReturn}
|
|
219
|
-
`;
|
|
220
|
-
}
|
|
221
|
-
output += `}
|
|
222
|
-
`;
|
|
223
|
-
return output;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
export { findExportedFunctions, shouldTransformWorker, transformWorkerEntrypoint, generateRpcInterface };
|
package/dist/init-f9mgmew3.js
DELETED
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getDependencies
|
|
3
|
-
} from "./index-1xpj0m4r.js";
|
|
4
|
-
import"./index-37x76zdn.js";
|
|
5
|
-
|
|
6
|
-
// src/cli/commands/init.ts
|
|
7
|
-
import { resolve, join } from "pathe";
|
|
8
|
-
var MINIMAL_TEMPLATE = {
|
|
9
|
-
name: "minimal",
|
|
10
|
-
description: "Minimal starter with single handler",
|
|
11
|
-
files: {
|
|
12
|
-
"devflare.config.ts": `import { defineConfig } from 'devflare'
|
|
13
|
-
|
|
14
|
-
export default defineConfig({
|
|
15
|
-
name: '{{PROJECT_NAME}}',
|
|
16
|
-
compatibilityDate: '${new Date().toISOString().split("T")[0]}',
|
|
17
|
-
})
|
|
18
|
-
`,
|
|
19
|
-
"src/index.ts": `import { env, ctx, event, locals } from 'devflare/runtime'
|
|
20
|
-
|
|
21
|
-
export default {
|
|
22
|
-
async fetch(request: Request): Promise<Response> {
|
|
23
|
-
return new Response('Hello from devflare!')
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
`,
|
|
27
|
-
"package.json": `{
|
|
28
|
-
"name": "{{PROJECT_NAME}}",
|
|
29
|
-
"version": "0.0.1",
|
|
30
|
-
"private": true,
|
|
31
|
-
"type": "module",
|
|
32
|
-
"scripts": {
|
|
33
|
-
"dev": "devflare dev",
|
|
34
|
-
"build": "devflare build",
|
|
35
|
-
"deploy": "devflare deploy",
|
|
36
|
-
"types": "devflare types"
|
|
37
|
-
},
|
|
38
|
-
"devDependencies": {
|
|
39
|
-
"devflare": "^0.1.0",
|
|
40
|
-
"typescript": "^5.7.0"
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
`,
|
|
44
|
-
"tsconfig.json": `{
|
|
45
|
-
"compilerOptions": {
|
|
46
|
-
"target": "ESNext",
|
|
47
|
-
"module": "ESNext",
|
|
48
|
-
"moduleResolution": "bundler",
|
|
49
|
-
"strict": true,
|
|
50
|
-
"skipLibCheck": true,
|
|
51
|
-
"types": ["@cloudflare/workers-types"]
|
|
52
|
-
},
|
|
53
|
-
"include": ["src/**/*", "devflare.config.ts"]
|
|
54
|
-
}
|
|
55
|
-
`
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
var API_TEMPLATE = {
|
|
59
|
-
name: "api",
|
|
60
|
-
description: "API starter with middleware and routing",
|
|
61
|
-
files: {
|
|
62
|
-
"devflare.config.ts": `import { defineConfig } from 'devflare'
|
|
63
|
-
|
|
64
|
-
export default defineConfig({
|
|
65
|
-
name: '{{PROJECT_NAME}}',
|
|
66
|
-
compatibilityDate: '${new Date().toISOString().split("T")[0]}',
|
|
67
|
-
bindings: {
|
|
68
|
-
// Add your bindings here
|
|
69
|
-
// kv: [{ binding: 'CACHE' }],
|
|
70
|
-
// d1: [{ binding: 'DB', database_name: 'my-db' }],
|
|
71
|
-
}
|
|
72
|
-
})
|
|
73
|
-
`,
|
|
74
|
-
"src/index.ts": `import { sequence, resolve } from 'devflare/runtime'
|
|
75
|
-
import { corsMiddleware } from './middleware/cors'
|
|
76
|
-
import { apiRouter } from './routes/api'
|
|
77
|
-
|
|
78
|
-
const handler = sequence(
|
|
79
|
-
corsMiddleware
|
|
80
|
-
)(
|
|
81
|
-
resolve(
|
|
82
|
-
apiRouter,
|
|
83
|
-
async () => new Response('Not Found', { status: 404 })
|
|
84
|
-
)
|
|
85
|
-
)
|
|
86
|
-
|
|
87
|
-
export default {
|
|
88
|
-
async fetch(request: Request, env: unknown, ctx: ExecutionContext): Promise<Response> {
|
|
89
|
-
return handler()
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
`,
|
|
93
|
-
"src/middleware/cors.ts": `import type { Middleware } from 'devflare/runtime'
|
|
94
|
-
import { event } from 'devflare/runtime'
|
|
95
|
-
|
|
96
|
-
export const corsMiddleware: Middleware = async (next) => {
|
|
97
|
-
// Handle preflight
|
|
98
|
-
if (event.request?.method === 'OPTIONS') {
|
|
99
|
-
return new Response(null, {
|
|
100
|
-
headers: {
|
|
101
|
-
'Access-Control-Allow-Origin': '*',
|
|
102
|
-
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS',
|
|
103
|
-
'Access-Control-Allow-Headers': 'Content-Type, Authorization',
|
|
104
|
-
}
|
|
105
|
-
})
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
const response = await next()
|
|
109
|
-
const newResponse = new Response(response.body, response)
|
|
110
|
-
newResponse.headers.set('Access-Control-Allow-Origin', '*')
|
|
111
|
-
return newResponse
|
|
112
|
-
}
|
|
113
|
-
`,
|
|
114
|
-
"src/routes/api.ts": `import type { Handler } from 'devflare/runtime'
|
|
115
|
-
import { event, env, locals } from 'devflare/runtime'
|
|
116
|
-
|
|
117
|
-
export const apiRouter: Handler = async () => {
|
|
118
|
-
const request = event.request
|
|
119
|
-
if (!request) return null
|
|
120
|
-
|
|
121
|
-
const url = new URL(request.url)
|
|
122
|
-
|
|
123
|
-
if (url.pathname === '/api/health') {
|
|
124
|
-
return new Response(JSON.stringify({ status: 'ok' }), {
|
|
125
|
-
headers: { 'Content-Type': 'application/json' }
|
|
126
|
-
})
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
if (url.pathname.startsWith('/api/')) {
|
|
130
|
-
return new Response(JSON.stringify({ error: 'Not found' }), {
|
|
131
|
-
status: 404,
|
|
132
|
-
headers: { 'Content-Type': 'application/json' }
|
|
133
|
-
})
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
// Not an API route, pass through
|
|
137
|
-
return null
|
|
138
|
-
}
|
|
139
|
-
`,
|
|
140
|
-
"package.json": MINIMAL_TEMPLATE.files["package.json"],
|
|
141
|
-
"tsconfig.json": MINIMAL_TEMPLATE.files["tsconfig.json"]
|
|
142
|
-
}
|
|
143
|
-
};
|
|
144
|
-
var TEMPLATES = {
|
|
145
|
-
minimal: MINIMAL_TEMPLATE,
|
|
146
|
-
api: API_TEMPLATE
|
|
147
|
-
};
|
|
148
|
-
async function runInitCommand(parsed, logger, options) {
|
|
149
|
-
const projectName = parsed.args[0] || "my-devflare-app";
|
|
150
|
-
const templateName = parsed.options.template || "minimal";
|
|
151
|
-
const cwd = options.cwd || process.cwd();
|
|
152
|
-
logger.info(`Creating new devflare project: ${projectName}`);
|
|
153
|
-
const template = TEMPLATES[templateName];
|
|
154
|
-
if (!template) {
|
|
155
|
-
logger.error(`Unknown template: ${templateName}`);
|
|
156
|
-
logger.info(`Available templates: ${Object.keys(TEMPLATES).join(", ")}`);
|
|
157
|
-
return { exitCode: 1 };
|
|
158
|
-
}
|
|
159
|
-
const projectDir = resolve(cwd, projectName);
|
|
160
|
-
const { fs } = await getDependencies();
|
|
161
|
-
try {
|
|
162
|
-
await fs.access(projectDir);
|
|
163
|
-
logger.error(`Directory already exists: ${projectDir}`);
|
|
164
|
-
return { exitCode: 1 };
|
|
165
|
-
} catch {}
|
|
166
|
-
await fs.mkdir(projectDir, { recursive: true });
|
|
167
|
-
for (const [filePath, content] of Object.entries(template.files)) {
|
|
168
|
-
const fullPath = join(projectDir, filePath);
|
|
169
|
-
const dir = fullPath.substring(0, fullPath.lastIndexOf("/"));
|
|
170
|
-
await fs.mkdir(dir, { recursive: true }).catch(() => {});
|
|
171
|
-
const processedContent = content.replace(/\{\{PROJECT_NAME\}\}/g, projectName);
|
|
172
|
-
await fs.writeFile(fullPath, processedContent, "utf-8");
|
|
173
|
-
logger.info(` Created: ${filePath}`);
|
|
174
|
-
}
|
|
175
|
-
logger.success(`
|
|
176
|
-
Project created successfully!`);
|
|
177
|
-
logger.info(`
|
|
178
|
-
Next steps:`);
|
|
179
|
-
logger.info(` cd ${projectName}`);
|
|
180
|
-
logger.info(` bun install`);
|
|
181
|
-
logger.info(` bun run dev`);
|
|
182
|
-
return { exitCode: 0 };
|
|
183
|
-
}
|
|
184
|
-
export {
|
|
185
|
-
runInitCommand
|
|
186
|
-
};
|