devflare 1.0.0-next.5 → 1.0.0-next.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/LLM.md +17312 -2139
- package/README.md +397 -605
- package/bin/devflare.js +30 -14
- package/dist/_chunks/account-Csog80ie.js +462 -0
- package/dist/_chunks/account-resources-CsmVowJp.js +159 -0
- package/dist/_chunks/ai-CBEuLdoP.js +322 -0
- package/dist/_chunks/api-TzdliH-6.js +568 -0
- package/dist/_chunks/build-Ccza8VQz.js +24 -0
- package/dist/_chunks/build-artifacts-BNssqhxE.js +483 -0
- package/dist/_chunks/cli-CU7wSG1-.js +1163 -0
- package/dist/_chunks/cloudflare-BaloqI3H.js +157 -0
- package/dist/_chunks/colors-DiK6wPJ5.js +13 -0
- package/dist/_chunks/command-utils-_bGRraDR.js +45 -0
- package/dist/_chunks/compiler-BtLp9T9N.js +500 -0
- package/dist/_chunks/config-QU8UEWmA.js +78 -0
- package/dist/_chunks/config-path-1yI7BiDU.js +42 -0
- package/dist/_chunks/context-CX50Y2Kb.js +2250 -0
- package/dist/_chunks/decorators-QmV57ixr.js +19 -0
- package/dist/_chunks/dependencies-C2oxFjU_.js +57 -0
- package/dist/_chunks/deploy-aifBaMVv.js +1032 -0
- package/dist/_chunks/dev-DF_3baGr.js +3483 -0
- package/dist/_chunks/doctor-tR9kGT_Z.js +219 -0
- package/dist/_chunks/durable-object-DMtH0XYX.js +234 -0
- package/dist/_chunks/env-S0_nMVz1.js +125 -0
- package/dist/_chunks/family-DKPp4wqj.js +143 -0
- package/dist/_chunks/generated-artifacts-dMJY4KAt.js +32 -0
- package/dist/_chunks/glob-CmQOvunB.js +56 -0
- package/dist/_chunks/init-DnkJOmpW.js +165 -0
- package/dist/_chunks/loader-OQ2AWpqm.js +1308 -0
- package/dist/_chunks/local-dev-vars-CTSa-wvF.js +81 -0
- package/dist/_chunks/local-hyperdrive-CJ90j46O.js +119 -0
- package/dist/_chunks/local-media-bindings-DsAW4AMF.js +335 -0
- package/dist/_chunks/local-secrets-CYoHfvQ1.js +123 -0
- package/dist/_chunks/local-workflow-entrypoints-8d_mXh8T.js +90 -0
- package/dist/_chunks/login-rVWUZOKC.js +51 -0
- package/dist/_chunks/package-metadata-DjHBLB-z.js +39 -0
- package/dist/_chunks/preferences-BKp_7XJx.js +241 -0
- package/dist/_chunks/preview-C3Cdr8an.js +462 -0
- package/dist/_chunks/preview-registry-ClAbLTHH.js +1186 -0
- package/dist/_chunks/preview-resources-DRWR0gaB.js +359 -0
- package/dist/_chunks/previews-BxNq8Y_J.js +1134 -0
- package/dist/_chunks/productions-DK7xwbEs.js +411 -0
- package/dist/_chunks/ref-CYJNAAe_.js +178 -0
- package/dist/_chunks/remote-CZnP-HLJ.js +79 -0
- package/dist/_chunks/remote-config-D39BY9ji.js +132 -0
- package/dist/_chunks/resolve-package-qizBfCIm.js +152 -0
- package/dist/_chunks/rolldown-runtime-CvQ6eiug.js +14 -0
- package/dist/_chunks/routes-B6XiI8Sa.js +851 -0
- package/dist/_chunks/runtime-DL-Nz3k8.js +550 -0
- package/dist/_chunks/schema-normalization-GjhTATHL.js +666 -0
- package/dist/_chunks/secrets-qT1JaBGt.js +95 -0
- package/dist/_chunks/tail-CuWI04BL.js +239 -0
- package/dist/_chunks/token-Dmi0KXyX.js +333 -0
- package/dist/_chunks/tokens-iVcgNXi-.js +221 -0
- package/dist/_chunks/types-BquPXsFg.js +484 -0
- package/dist/_chunks/ui-BUoZApvE.js +103 -0
- package/dist/_chunks/usage-BBTGzjon.js +272 -0
- package/dist/_chunks/vite-D_wLDGBs.js +1267 -0
- package/dist/_chunks/vite-utils-OVLMV605.js +183 -0
- package/dist/_chunks/worker-DEF-e8LL.js +410 -0
- package/dist/_chunks/worker-bundler-dTTnYU3n.js +458 -0
- package/dist/_chunks/worker-entrypoint-CQW77lG8.js +247 -0
- package/dist/_chunks/workerName-CFJsLZA-.js +23 -0
- package/dist/bridge/client.d.ts +49 -7
- package/dist/bridge/client.d.ts.map +1 -1
- package/dist/bridge/gateway-runtime.d.ts +8 -0
- package/dist/bridge/gateway-runtime.d.ts.map +1 -0
- package/dist/bridge/index.d.ts +6 -6
- package/dist/bridge/index.d.ts.map +1 -1
- package/dist/bridge/log.d.ts +5 -0
- package/dist/bridge/log.d.ts.map +1 -0
- package/dist/bridge/miniflare.d.ts +85 -2
- package/dist/bridge/miniflare.d.ts.map +1 -1
- package/dist/bridge/proxy.d.ts +12 -11
- package/dist/bridge/proxy.d.ts.map +1 -1
- package/dist/bridge/server.d.ts +2 -1
- package/dist/bridge/server.d.ts.map +1 -1
- package/dist/bridge/v2/body-streams.d.ts +53 -0
- package/dist/bridge/v2/body-streams.d.ts.map +1 -0
- package/dist/bridge/v2/codec.d.ts +106 -0
- package/dist/bridge/v2/codec.d.ts.map +1 -0
- package/dist/bridge/v2/control-messages.d.ts +46 -0
- package/dist/bridge/v2/control-messages.d.ts.map +1 -0
- package/dist/bridge/v2/frames.d.ts +109 -0
- package/dist/bridge/v2/frames.d.ts.map +1 -0
- package/dist/bridge/v2/index.d.ts +11 -0
- package/dist/bridge/v2/index.d.ts.map +1 -0
- package/dist/bridge/v2/serialization.d.ts +48 -0
- package/dist/bridge/v2/serialization.d.ts.map +1 -0
- package/dist/bridge/v2/transport.d.ts +31 -0
- package/dist/bridge/v2/transport.d.ts.map +1 -0
- package/dist/bridge/v2/value-codec.d.ts +61 -0
- package/dist/bridge/v2/value-codec.d.ts.map +1 -0
- package/dist/bridge/{serialization.d.ts → v2/value-serialization.d.ts} +40 -18
- package/dist/bridge/v2/value-serialization.d.ts.map +1 -0
- package/dist/bridge/{protocol.d.ts → v2/wire.d.ts} +32 -8
- package/dist/bridge/v2/wire.d.ts.map +1 -0
- package/dist/bridge/v2/ws-relay.d.ts +53 -0
- package/dist/bridge/v2/ws-relay.d.ts.map +1 -0
- package/dist/browser-shim/handler.d.ts +2 -2
- package/dist/browser-shim/handler.d.ts.map +1 -1
- package/dist/browser-shim/index.d.ts +2 -2
- package/dist/browser-shim/server.d.ts +63 -0
- package/dist/browser-shim/server.d.ts.map +1 -1
- package/dist/browser.d.ts +5705 -0
- package/dist/browser.d.ts.map +1 -0
- package/dist/browser.js +80 -0
- package/dist/bundler/defaults.d.ts +23 -0
- package/dist/bundler/defaults.d.ts.map +1 -0
- package/dist/bundler/do-bundler.d.ts +7 -0
- package/dist/bundler/do-bundler.d.ts.map +1 -1
- package/dist/bundler/index.d.ts +3 -1
- package/dist/bundler/index.d.ts.map +1 -1
- package/dist/bundler/rolldown-shared.d.ts +53 -0
- package/dist/bundler/rolldown-shared.d.ts.map +1 -0
- package/dist/bundler/worker-bundler.d.ts +13 -0
- package/dist/bundler/worker-bundler.d.ts.map +1 -0
- package/dist/bundler/worker-compat.d.ts +4 -0
- package/dist/bundler/worker-compat.d.ts.map +1 -0
- package/dist/cli/build-manifest.d.ts +66 -0
- package/dist/cli/build-manifest.d.ts.map +1 -0
- package/dist/cli/command-utils.d.ts +18 -0
- package/dist/cli/command-utils.d.ts.map +1 -0
- package/dist/cli/commands/account.d.ts +2 -2
- package/dist/cli/commands/account.d.ts.map +1 -1
- package/dist/cli/commands/ai.d.ts +1 -1
- package/dist/cli/commands/ai.d.ts.map +1 -1
- package/dist/cli/commands/build-artifacts.d.ts +40 -0
- package/dist/cli/commands/build-artifacts.d.ts.map +1 -0
- package/dist/cli/commands/build.d.ts +2 -2
- package/dist/cli/commands/build.d.ts.map +1 -1
- package/dist/cli/commands/config.d.ts +4 -0
- package/dist/cli/commands/config.d.ts.map +1 -0
- package/dist/cli/commands/deploy/metadata.d.ts +18 -0
- package/dist/cli/commands/deploy/metadata.d.ts.map +1 -0
- package/dist/cli/commands/deploy/prepare.d.ts +23 -0
- package/dist/cli/commands/deploy/prepare.d.ts.map +1 -0
- package/dist/cli/commands/deploy/runtime.d.ts +4 -0
- package/dist/cli/commands/deploy/runtime.d.ts.map +1 -0
- package/dist/cli/commands/deploy/verification.d.ts +36 -0
- package/dist/cli/commands/deploy/verification.d.ts.map +1 -0
- package/dist/cli/commands/deploy.d.ts +2 -2
- package/dist/cli/commands/deploy.d.ts.map +1 -1
- package/dist/cli/commands/dev.d.ts +9 -1
- package/dist/cli/commands/dev.d.ts.map +1 -1
- package/dist/cli/commands/doctor.d.ts +2 -2
- package/dist/cli/commands/doctor.d.ts.map +1 -1
- package/dist/cli/commands/init.d.ts +2 -2
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/login.d.ts +4 -0
- package/dist/cli/commands/login.d.ts.map +1 -0
- package/dist/cli/commands/previews-support/cleanup.d.ts +9 -0
- package/dist/cli/commands/previews-support/cleanup.d.ts.map +1 -0
- package/dist/cli/commands/previews-support/family.d.ts +10 -0
- package/dist/cli/commands/previews-support/family.d.ts.map +1 -0
- package/dist/cli/commands/previews-support/render.d.ts +8 -0
- package/dist/cli/commands/previews-support/render.d.ts.map +1 -0
- package/dist/cli/commands/previews-support/theme.d.ts +10 -0
- package/dist/cli/commands/previews-support/theme.d.ts.map +1 -0
- package/dist/cli/commands/previews-support/types.d.ts +70 -0
- package/dist/cli/commands/previews-support/types.d.ts.map +1 -0
- package/dist/cli/commands/previews.d.ts +4 -0
- package/dist/cli/commands/previews.d.ts.map +1 -0
- package/dist/cli/commands/productions.d.ts +4 -0
- package/dist/cli/commands/productions.d.ts.map +1 -0
- package/dist/cli/commands/remote.d.ts +1 -1
- package/dist/cli/commands/remote.d.ts.map +1 -1
- package/dist/cli/commands/secrets.d.ts +4 -0
- package/dist/cli/commands/secrets.d.ts.map +1 -0
- package/dist/cli/commands/tail.d.ts +44 -0
- package/dist/cli/commands/tail.d.ts.map +1 -0
- package/dist/cli/commands/token.d.ts +4 -0
- package/dist/cli/commands/token.d.ts.map +1 -0
- package/dist/cli/commands/type-generation/discovery.d.ts +7 -0
- package/dist/cli/commands/type-generation/discovery.d.ts.map +1 -0
- package/dist/cli/commands/type-generation/generator.d.ts +121 -0
- package/dist/cli/commands/type-generation/generator.d.ts.map +1 -0
- package/dist/cli/commands/type-generation/models.d.ts +27 -0
- package/dist/cli/commands/type-generation/models.d.ts.map +1 -0
- package/dist/cli/commands/types.d.ts +2 -2
- package/dist/cli/commands/types.d.ts.map +1 -1
- package/dist/cli/commands/worker.d.ts +4 -0
- package/dist/cli/commands/worker.d.ts.map +1 -0
- package/dist/cli/config-path.d.ts +6 -0
- package/dist/cli/config-path.d.ts.map +1 -0
- package/dist/cli/dependencies.d.ts +2 -1
- package/dist/cli/dependencies.d.ts.map +1 -1
- package/dist/cli/deploy-strategy.d.ts +17 -0
- package/dist/cli/deploy-strategy.d.ts.map +1 -0
- package/dist/cli/deploy-target.d.ts +17 -0
- package/dist/cli/deploy-target.d.ts.map +1 -0
- package/dist/cli/generated-artifacts.d.ts +12 -0
- package/dist/cli/generated-artifacts.d.ts.map +1 -0
- package/dist/cli/gradual-deploy.d.ts +49 -0
- package/dist/cli/gradual-deploy.d.ts.map +1 -0
- package/dist/cli/help-pages/pages/account.d.ts +3 -0
- package/dist/cli/help-pages/pages/account.d.ts.map +1 -0
- package/dist/cli/help-pages/pages/core.d.ts +4 -0
- package/dist/cli/help-pages/pages/core.d.ts.map +1 -0
- package/dist/cli/help-pages/pages/index.d.ts +3 -0
- package/dist/cli/help-pages/pages/index.d.ts.map +1 -0
- package/dist/cli/help-pages/pages/misc.d.ts +3 -0
- package/dist/cli/help-pages/pages/misc.d.ts.map +1 -0
- package/dist/cli/help-pages/pages/previews.d.ts +3 -0
- package/dist/cli/help-pages/pages/previews.d.ts.map +1 -0
- package/dist/cli/help-pages/pages/productions.d.ts +3 -0
- package/dist/cli/help-pages/pages/productions.d.ts.map +1 -0
- package/dist/cli/help-pages/render.d.ts +12 -0
- package/dist/cli/help-pages/render.d.ts.map +1 -0
- package/dist/cli/help-pages/shared.d.ts +15 -0
- package/dist/cli/help-pages/shared.d.ts.map +1 -0
- package/dist/cli/help-pages/types.d.ts +23 -0
- package/dist/cli/help-pages/types.d.ts.map +1 -0
- package/dist/cli/help.d.ts +6 -0
- package/dist/cli/help.d.ts.map +1 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +2 -0
- package/dist/cli/package-metadata.d.ts +16 -0
- package/dist/cli/package-metadata.d.ts.map +1 -0
- package/dist/cli/preview-bindings.d.ts +49 -0
- package/dist/cli/preview-bindings.d.ts.map +1 -0
- package/dist/cli/preview.d.ts +10 -0
- package/dist/cli/preview.d.ts.map +1 -0
- package/dist/cli/ui.d.ts +37 -0
- package/dist/cli/ui.d.ts.map +1 -0
- package/dist/cli/workspace-build-guard.d.ts +14 -0
- package/dist/cli/workspace-build-guard.d.ts.map +1 -0
- package/dist/cli/wrangler-auth.d.ts +1 -1
- package/dist/cloudflare/account-core.d.ts +6 -0
- package/dist/cloudflare/account-core.d.ts.map +1 -0
- package/dist/cloudflare/account-resources.d.ts +40 -0
- package/dist/cloudflare/account-resources.d.ts.map +1 -0
- package/dist/cloudflare/account-status.d.ts +11 -0
- package/dist/cloudflare/account-status.d.ts.map +1 -0
- package/dist/cloudflare/account-workers.d.ts +14 -0
- package/dist/cloudflare/account-workers.d.ts.map +1 -0
- package/dist/cloudflare/account.d.ts +7 -64
- package/dist/cloudflare/account.d.ts.map +1 -1
- package/dist/cloudflare/api.d.ts +71 -3
- package/dist/cloudflare/api.d.ts.map +1 -1
- package/dist/cloudflare/auth.d.ts +1 -1
- package/dist/cloudflare/auth.d.ts.map +1 -1
- package/dist/cloudflare/index.d.ts +61 -6
- package/dist/cloudflare/index.d.ts.map +1 -1
- package/dist/cloudflare/index.js +4 -13
- package/dist/cloudflare/known-permission-group-ids.generated.d.ts +10 -0
- package/dist/cloudflare/known-permission-group-ids.generated.d.ts.map +1 -0
- package/dist/cloudflare/kv-namespace.d.ts +4 -0
- package/dist/cloudflare/kv-namespace.d.ts.map +1 -0
- package/dist/cloudflare/preferences.d.ts +7 -0
- package/dist/cloudflare/preferences.d.ts.map +1 -1
- package/dist/cloudflare/preview-registry-cache.d.ts +6 -0
- package/dist/cloudflare/preview-registry-cache.d.ts.map +1 -0
- package/dist/cloudflare/preview-registry-inference.d.ts +14 -0
- package/dist/cloudflare/preview-registry-inference.d.ts.map +1 -0
- package/dist/cloudflare/preview-registry-records.d.ts +4 -0
- package/dist/cloudflare/preview-registry-records.d.ts.map +1 -0
- package/dist/cloudflare/preview-registry-shape.d.ts +47 -0
- package/dist/cloudflare/preview-registry-shape.d.ts.map +1 -0
- package/dist/cloudflare/preview-registry-store.d.ts +14 -0
- package/dist/cloudflare/preview-registry-store.d.ts.map +1 -0
- package/dist/cloudflare/preview-registry-transport.d.ts +4 -0
- package/dist/cloudflare/preview-registry-transport.d.ts.map +1 -0
- package/dist/cloudflare/preview-registry-types.d.ts +103 -0
- package/dist/cloudflare/preview-registry-types.d.ts.map +1 -0
- package/dist/cloudflare/preview-registry.d.ts +42 -0
- package/dist/cloudflare/preview-registry.d.ts.map +1 -0
- package/dist/cloudflare/preview-urls.d.ts +3 -0
- package/dist/cloudflare/preview-urls.d.ts.map +1 -0
- package/dist/cloudflare/registry-schema.d.ts +253 -0
- package/dist/cloudflare/registry-schema.d.ts.map +1 -0
- package/dist/cloudflare/remote-config.d.ts.map +1 -1
- package/dist/cloudflare/tokens.d.ts +44 -0
- package/dist/cloudflare/tokens.d.ts.map +1 -0
- package/dist/cloudflare/types.d.ts +124 -7
- package/dist/cloudflare/types.d.ts.map +1 -1
- package/dist/cloudflare/usage.d.ts +31 -3
- package/dist/cloudflare/usage.d.ts.map +1 -1
- package/dist/config/binding-resolution-helpers.d.ts +41 -0
- package/dist/config/binding-resolution-helpers.d.ts.map +1 -0
- package/dist/config/compatibility.d.ts +3 -0
- package/dist/config/compatibility.d.ts.map +1 -0
- package/dist/config/compiler/bindings.d.ts +14 -0
- package/dist/config/compiler/bindings.d.ts.map +1 -0
- package/dist/config/compiler/core-helpers.d.ts +6 -0
- package/dist/config/compiler/core-helpers.d.ts.map +1 -0
- package/dist/config/compiler/do-workers.d.ts +34 -0
- package/dist/config/compiler/do-workers.d.ts.map +1 -0
- package/dist/config/compiler/paths.d.ts +18 -0
- package/dist/config/compiler/paths.d.ts.map +1 -0
- package/dist/config/compiler/types.d.ts +309 -0
- package/dist/config/compiler/types.d.ts.map +1 -0
- package/dist/config/compiler.d.ts +22 -134
- package/dist/config/compiler.d.ts.map +1 -1
- package/dist/config/cron.d.ts +19 -0
- package/dist/config/cron.d.ts.map +1 -0
- package/dist/config/define.d.ts +8 -5
- package/dist/config/define.d.ts.map +1 -1
- package/dist/config/deploy-resources.d.ts +58 -0
- package/dist/config/deploy-resources.d.ts.map +1 -0
- package/dist/config/env-vars.d.ts +309 -0
- package/dist/config/env-vars.d.ts.map +1 -0
- package/dist/config/framework-providers.d.ts +9 -0
- package/dist/config/framework-providers.d.ts.map +1 -0
- package/dist/config/index.d.ts +12 -5
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/loader.d.ts +2 -1
- package/dist/config/loader.d.ts.map +1 -1
- package/dist/config/local-dev-vars.d.ts +15 -0
- package/dist/config/local-dev-vars.d.ts.map +1 -0
- package/dist/config/preview-resources.d.ts +83 -0
- package/dist/config/preview-resources.d.ts.map +1 -0
- package/dist/config/preview.d.ts +29 -0
- package/dist/config/preview.d.ts.map +1 -0
- package/dist/config/ref.d.ts +16 -25
- package/dist/config/ref.d.ts.map +1 -1
- package/dist/config/resolve-phased.d.ts +72 -0
- package/dist/config/resolve-phased.d.ts.map +1 -0
- package/dist/config/resolve.d.ts +11 -0
- package/dist/config/resolve.d.ts.map +1 -0
- package/dist/config/resource-resolution.d.ts +80 -0
- package/dist/config/resource-resolution.d.ts.map +1 -0
- package/dist/config/schema-bindings.d.ts +2087 -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 +3771 -0
- package/dist/config/schema-env.d.ts.map +1 -0
- package/dist/config/schema-normalization.d.ts +267 -0
- package/dist/config/schema-normalization.d.ts.map +1 -0
- package/dist/config/schema-runtime.d.ts +557 -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 +122 -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 +5699 -2021
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/config/service-bindings-validation.d.ts +36 -0
- package/dist/config/service-bindings-validation.d.ts.map +1 -0
- package/dist/config-entry.d.ts +7 -0
- package/dist/config-entry.d.ts.map +1 -0
- package/dist/config-entry.js +3 -0
- package/dist/decorators/durable-object.d.ts.map +1 -1
- package/dist/decorators/index.d.ts +2 -2
- package/dist/decorators/index.js +2 -9
- package/dist/dev-server/d1-migrations.d.ts +36 -0
- package/dist/dev-server/d1-migrations.d.ts.map +1 -0
- package/dist/dev-server/dev-server-state.d.ts +59 -0
- package/dist/dev-server/dev-server-state.d.ts.map +1 -0
- package/dist/dev-server/gateway-script.d.ts +21 -0
- package/dist/dev-server/gateway-script.d.ts.map +1 -0
- package/dist/dev-server/index.d.ts +1 -1
- package/dist/dev-server/miniflare-bindings.d.ts +90 -0
- package/dist/dev-server/miniflare-bindings.d.ts.map +1 -0
- package/dist/dev-server/miniflare-dev-config.d.ts +36 -0
- package/dist/dev-server/miniflare-dev-config.d.ts.map +1 -0
- package/dist/dev-server/miniflare-log.d.ts +20 -0
- package/dist/dev-server/miniflare-log.d.ts.map +1 -0
- package/dist/dev-server/miniflare-worker-config.d.ts +93 -0
- package/dist/dev-server/miniflare-worker-config.d.ts.map +1 -0
- package/dist/dev-server/reload-queue.d.ts +13 -0
- package/dist/dev-server/reload-queue.d.ts.map +1 -0
- package/dist/dev-server/runtime-stdio.d.ts +8 -0
- package/dist/dev-server/runtime-stdio.d.ts.map +1 -0
- package/dist/dev-server/server-startup-helpers.d.ts +84 -0
- package/dist/dev-server/server-startup-helpers.d.ts.map +1 -0
- package/dist/dev-server/server.d.ts +2 -0
- package/dist/dev-server/server.d.ts.map +1 -1
- package/dist/dev-server/vite-process.d.ts +15 -0
- package/dist/dev-server/vite-process.d.ts.map +1 -0
- package/dist/dev-server/vite-utils.d.ts +19 -1
- package/dist/dev-server/vite-utils.d.ts.map +1 -1
- package/dist/dev-server/worker-source-watcher.d.ts +17 -0
- package/dist/dev-server/worker-source-watcher.d.ts.map +1 -0
- package/dist/dev-server/worker-surface-paths.d.ts +6 -0
- package/dist/dev-server/worker-surface-paths.d.ts.map +1 -0
- package/dist/env.d.ts +10 -0
- package/dist/env.d.ts.map +1 -1
- package/dist/index.d.ts +8 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -298
- package/dist/runtime/context-events.d.ts +13 -0
- package/dist/runtime/context-events.d.ts.map +1 -0
- package/dist/runtime/context-types.d.ts +82 -0
- package/dist/runtime/context-types.d.ts.map +1 -0
- package/dist/runtime/context.d.ts +20 -44
- package/dist/runtime/context.d.ts.map +1 -1
- package/dist/runtime/exports.d.ts +70 -55
- package/dist/runtime/exports.d.ts.map +1 -1
- package/dist/runtime/index.d.ts +10 -3
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +5 -111
- package/dist/runtime/middleware.d.ts +119 -67
- package/dist/runtime/middleware.d.ts.map +1 -1
- package/dist/runtime/router/index.d.ts +7 -0
- package/dist/runtime/router/index.d.ts.map +1 -0
- package/dist/runtime/router/types.d.ts +24 -0
- package/dist/runtime/router/types.d.ts.map +1 -0
- package/dist/runtime/validation.d.ts +18 -4
- package/dist/runtime/validation.d.ts.map +1 -1
- package/dist/secrets/local-secrets.d.ts +46 -0
- package/dist/secrets/local-secrets.d.ts.map +1 -0
- package/dist/shims/local-hyperdrive.d.ts +12 -0
- package/dist/shims/local-hyperdrive.d.ts.map +1 -0
- package/dist/shims/local-media-bindings.d.ts +19 -0
- package/dist/shims/local-media-bindings.d.ts.map +1 -0
- package/dist/shims/local-worker-loader.d.ts +3 -0
- package/dist/shims/local-worker-loader.d.ts.map +1 -0
- package/dist/sveltekit/index.d.ts +1 -1
- package/dist/sveltekit/index.d.ts.map +1 -1
- package/dist/sveltekit/index.js +313 -167
- package/dist/sveltekit/local-bindings.d.ts +4 -0
- package/dist/sveltekit/local-bindings.d.ts.map +1 -0
- package/dist/sveltekit/platform.d.ts +20 -2
- package/dist/sveltekit/platform.d.ts.map +1 -1
- package/dist/test/ai-search.d.ts +39 -0
- package/dist/test/ai-search.d.ts.map +1 -0
- package/dist/test/alarm.d.ts +55 -0
- package/dist/test/alarm.d.ts.map +1 -0
- package/dist/test/binding-hints.d.ts +10 -0
- package/dist/test/binding-hints.d.ts.map +1 -0
- package/dist/test/cf.d.ts +71 -35
- package/dist/test/cf.d.ts.map +1 -1
- package/dist/test/containers.d.ts +87 -0
- package/dist/test/containers.d.ts.map +1 -0
- package/dist/test/email.d.ts +16 -7
- package/dist/test/email.d.ts.map +1 -1
- package/dist/test/index.d.ts +20 -21
- package/dist/test/index.d.ts.map +1 -1
- package/dist/test/index.js +4981 -70
- package/dist/test/offline-bindings.d.ts +115 -0
- package/dist/test/offline-bindings.d.ts.map +1 -0
- package/dist/test/queue.d.ts.map +1 -1
- package/dist/test/remote-ai.d.ts.map +1 -1
- package/dist/test/remote-cloudflare.d.ts +13 -0
- package/dist/test/remote-cloudflare.d.ts.map +1 -0
- package/dist/test/remote-vectorize.d.ts.map +1 -1
- package/dist/test/resolve-service-bindings.d.ts +64 -4
- package/dist/test/resolve-service-bindings.d.ts.map +1 -1
- package/dist/test/scheduled.d.ts.map +1 -1
- package/dist/test/should-skip.d.ts +14 -18
- package/dist/test/should-skip.d.ts.map +1 -1
- package/dist/test/simple-context-bindings.d.ts +13 -0
- package/dist/test/simple-context-bindings.d.ts.map +1 -0
- package/dist/test/simple-context-durable-objects.d.ts +6 -0
- package/dist/test/simple-context-durable-objects.d.ts.map +1 -0
- package/dist/test/simple-context-env.d.ts +35 -0
- package/dist/test/simple-context-env.d.ts.map +1 -0
- package/dist/test/simple-context-gateway-script.d.ts +2 -0
- package/dist/test/simple-context-gateway-script.d.ts.map +1 -0
- package/dist/test/simple-context-handlers.d.ts +12 -0
- package/dist/test/simple-context-handlers.d.ts.map +1 -0
- package/dist/test/simple-context-lifecycle.d.ts +32 -0
- package/dist/test/simple-context-lifecycle.d.ts.map +1 -0
- package/dist/test/simple-context-mfconfig.d.ts +10 -0
- package/dist/test/simple-context-mfconfig.d.ts.map +1 -0
- package/dist/test/simple-context-multi-worker.d.ts +16 -0
- package/dist/test/simple-context-multi-worker.d.ts.map +1 -0
- package/dist/test/simple-context-paths.d.ts +40 -0
- package/dist/test/simple-context-paths.d.ts.map +1 -0
- package/dist/test/simple-context-runtime.d.ts +19 -0
- package/dist/test/simple-context-runtime.d.ts.map +1 -0
- package/dist/test/simple-context-startup.d.ts +11 -0
- package/dist/test/simple-context-startup.d.ts.map +1 -0
- package/dist/test/simple-context-transport.d.ts +14 -0
- package/dist/test/simple-context-transport.d.ts.map +1 -0
- package/dist/test/simple-context.d.ts +8 -27
- package/dist/test/simple-context.d.ts.map +1 -1
- package/dist/test/tail.d.ts +3 -2
- package/dist/test/tail.d.ts.map +1 -1
- package/dist/test/utilities/analytics-engine.d.ts +22 -0
- package/dist/test/utilities/analytics-engine.d.ts.map +1 -0
- package/dist/test/utilities/artifacts.d.ts +11 -0
- package/dist/test/utilities/artifacts.d.ts.map +1 -0
- package/dist/test/utilities/context.d.ts +39 -0
- package/dist/test/utilities/context.d.ts.map +1 -0
- package/dist/test/utilities/d1.d.ts +21 -0
- package/dist/test/utilities/d1.d.ts.map +1 -0
- package/dist/test/utilities/env.d.ts +43 -0
- package/dist/test/utilities/env.d.ts.map +1 -0
- package/dist/test/utilities/kv.d.ts +11 -0
- package/dist/test/utilities/kv.d.ts.map +1 -0
- package/dist/test/utilities/media.d.ts +16 -0
- package/dist/test/utilities/media.d.ts.map +1 -0
- package/dist/test/utilities/platform.d.ts +41 -0
- package/dist/test/utilities/platform.d.ts.map +1 -0
- package/dist/test/utilities/queue.d.ts +5 -0
- package/dist/test/utilities/queue.d.ts.map +1 -0
- package/dist/test/utilities/r2.d.ts +2 -0
- package/dist/test/utilities/r2.d.ts.map +1 -0
- package/dist/test/utilities/stream-flagship.d.ts +27 -0
- package/dist/test/utilities/stream-flagship.d.ts.map +1 -0
- package/dist/test/utilities/vectorize.d.ts +38 -0
- package/dist/test/utilities/vectorize.d.ts.map +1 -0
- package/dist/test/utilities/workflows.d.ts +26 -0
- package/dist/test/utilities/workflows.d.ts.map +1 -0
- package/dist/test/utilities.d.ts +13 -98
- package/dist/test/utilities.d.ts.map +1 -1
- package/dist/test/worker.d.ts +6 -0
- package/dist/test/worker.d.ts.map +1 -1
- package/dist/transform/durable-object.d.ts.map +1 -1
- package/dist/transform/index.d.ts +2 -2
- package/dist/transform/worker-entrypoint.d.ts +5 -0
- package/dist/transform/worker-entrypoint.d.ts.map +1 -1
- package/dist/utils/entrypoint-discovery.d.ts +6 -3
- package/dist/utils/entrypoint-discovery.d.ts.map +1 -1
- package/dist/utils/glob.d.ts.map +1 -1
- package/dist/utils/resolve-package.d.ts.map +1 -1
- package/dist/utils/send-email.d.ts +15 -0
- package/dist/utils/send-email.d.ts.map +1 -0
- package/dist/utils/send-email.js +163 -0
- package/dist/vite/config-file.d.ts +25 -0
- package/dist/vite/config-file.d.ts.map +1 -0
- package/dist/vite/index.d.ts +3 -2
- package/dist/vite/index.d.ts.map +1 -1
- package/dist/vite/index.js +2 -339
- package/dist/vite/plugin-config-hook.d.ts +28 -0
- package/dist/vite/plugin-config-hook.d.ts.map +1 -0
- package/dist/vite/plugin-context.d.ts +27 -0
- package/dist/vite/plugin-context.d.ts.map +1 -0
- package/dist/vite/plugin-durable-objects.d.ts +18 -0
- package/dist/vite/plugin-durable-objects.d.ts.map +1 -0
- package/dist/vite/plugin-programmatic.d.ts +44 -0
- package/dist/vite/plugin-programmatic.d.ts.map +1 -0
- package/dist/vite/plugin-service-bindings.d.ts +13 -0
- package/dist/vite/plugin-service-bindings.d.ts.map +1 -0
- package/dist/vite/plugin-transform.d.ts +41 -0
- package/dist/vite/plugin-transform.d.ts.map +1 -0
- package/dist/vite/plugin.d.ts +10 -41
- package/dist/vite/plugin.d.ts.map +1 -1
- package/dist/worker-entry/composed-worker.d.ts +7 -0
- package/dist/worker-entry/composed-worker.d.ts.map +1 -0
- package/dist/worker-entry/durable-object-discovery.d.ts +20 -0
- package/dist/worker-entry/durable-object-discovery.d.ts.map +1 -0
- package/dist/worker-entry/extensions.d.ts +5 -0
- package/dist/worker-entry/extensions.d.ts.map +1 -0
- package/dist/worker-entry/routes.d.ts +22 -0
- package/dist/worker-entry/routes.d.ts.map +1 -0
- package/dist/worker-entry/surface-paths.d.ts +26 -0
- package/dist/worker-entry/surface-paths.d.ts.map +1 -0
- package/dist/worker-entry/validate-fetch-style.d.ts +12 -0
- package/dist/worker-entry/validate-fetch-style.d.ts.map +1 -0
- package/dist/workflows/local-workflow-entrypoints.d.ts +7 -0
- package/dist/workflows/local-workflow-entrypoints.d.ts.map +1 -0
- package/package.json +159 -116
- package/R2.md +0 -170
- package/dist/account-rvrj687w.js +0 -397
- package/dist/ai-dx4fr9jh.js +0 -107
- package/dist/bridge/protocol.d.ts.map +0 -1
- package/dist/bridge/serialization.d.ts.map +0 -1
- package/dist/browser-shim/worker.d.ts +0 -14
- package/dist/browser-shim/worker.d.ts.map +0 -1
- package/dist/build-mnf6v8gd.js +0 -53
- package/dist/deploy-nhceck39.js +0 -70
- package/dist/dev-b9dmrj7b.js +0 -2417
- package/dist/doctor-fmgb3d28.js +0 -190
- package/dist/durable-object-t4kbb0yt.js +0 -13
- package/dist/index-07q6yxyc.js +0 -168
- package/dist/index-18hvb6gb.js +0 -194
- package/dist/index-1xpj0m4r.js +0 -57
- package/dist/index-37x76zdn.js +0 -4
- package/dist/index-3t6rypgc.js +0 -13
- package/dist/index-67qcae0f.js +0 -183
- package/dist/index-a855bdsx.js +0 -18
- package/dist/index-d8bdkx2h.js +0 -109
- package/dist/index-ep3445yc.js +0 -2225
- package/dist/index-gz1gndna.js +0 -307
- package/dist/index-hcex3rgh.js +0 -266
- package/dist/index-m2q41jwa.js +0 -462
- package/dist/index-n7rs26ft.js +0 -77
- package/dist/index-pf5s73n9.js +0 -1413
- package/dist/index-rbht7m9r.js +0 -36
- package/dist/index-tfyxa77h.js +0 -850
- package/dist/index-tk6ej9dj.js +0 -94
- package/dist/index-z14anrqp.js +0 -226
- package/dist/init-f9mgmew3.js +0 -186
- package/dist/remote-q59qk463.js +0 -97
- package/dist/test/bridge-context.d.ts +0 -76
- package/dist/test/bridge-context.d.ts.map +0 -1
- package/dist/test/multi-worker-context.d.ts +0 -114
- package/dist/test/multi-worker-context.d.ts.map +0 -1
- package/dist/types-5nyrz1sz.js +0 -454
- package/dist/worker-entrypoint-m9th0rg0.js +0 -13
|
@@ -0,0 +1,458 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { dirname, resolve } from "pathe";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import MagicString from "magic-string";
|
|
5
|
+
import ts from "typescript";
|
|
6
|
+
//#region src/bundler/defaults.ts
|
|
7
|
+
function createWorkerdBundlerDefaults() {
|
|
8
|
+
return {
|
|
9
|
+
platform: "browser",
|
|
10
|
+
defaultTsconfigMode: "if-present",
|
|
11
|
+
sourcemap: false,
|
|
12
|
+
minify: false
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/bundler/worker-compat.ts
|
|
17
|
+
const WORKER_DYNAMIC_IMPORT_ERROR = "Devflare worker bundles cannot contain unresolved dynamic import() expressions because Miniflare/workerd reject dynamic module specifiers";
|
|
18
|
+
function getScriptKind(id) {
|
|
19
|
+
if (id.endsWith(".tsx")) return ts.ScriptKind.TSX;
|
|
20
|
+
if (id.endsWith(".ts") || id.endsWith(".mts") || id.endsWith(".cts")) return ts.ScriptKind.TS;
|
|
21
|
+
if (id.endsWith(".jsx")) return ts.ScriptKind.JSX;
|
|
22
|
+
return ts.ScriptKind.JS;
|
|
23
|
+
}
|
|
24
|
+
function createSourceFile(code, id) {
|
|
25
|
+
return ts.createSourceFile(id, code, ts.ScriptTarget.Latest, true, getScriptKind(id));
|
|
26
|
+
}
|
|
27
|
+
function hasExportModifier(node) {
|
|
28
|
+
if (!ts.canHaveModifiers(node)) return false;
|
|
29
|
+
return ts.getModifiers(node)?.some((modifier) => modifier.kind === ts.SyntaxKind.ExportKeyword) ?? false;
|
|
30
|
+
}
|
|
31
|
+
function isConstVariableStatement(statement) {
|
|
32
|
+
return ts.isVariableStatement(statement) && (statement.declarationList.flags & ts.NodeFlags.Const) !== 0;
|
|
33
|
+
}
|
|
34
|
+
function quoteString(value) {
|
|
35
|
+
return `'${value.replace(/\\/g, "\\\\").replace(/'/g, `\\'`)}'`;
|
|
36
|
+
}
|
|
37
|
+
function resolveLiteralImportSpecifier(expression, constStrings) {
|
|
38
|
+
if (ts.isStringLiteral(expression) || ts.isNoSubstitutionTemplateLiteral(expression)) return expression.text;
|
|
39
|
+
if (ts.isParenthesizedExpression(expression)) return resolveLiteralImportSpecifier(expression.expression, constStrings);
|
|
40
|
+
if (ts.isIdentifier(expression)) return constStrings.get(expression.text) ?? null;
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
function collectTopLevelConstStrings(sourceFile) {
|
|
44
|
+
const constStrings = /* @__PURE__ */ new Map();
|
|
45
|
+
for (const statement of sourceFile.statements) {
|
|
46
|
+
if (!isConstVariableStatement(statement)) continue;
|
|
47
|
+
for (const declaration of statement.declarationList.declarations) {
|
|
48
|
+
if (!ts.isIdentifier(declaration.name) || !declaration.initializer) continue;
|
|
49
|
+
const literal = resolveLiteralImportSpecifier(declaration.initializer, constStrings);
|
|
50
|
+
if (literal !== null) constStrings.set(declaration.name.text, literal);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return constStrings;
|
|
54
|
+
}
|
|
55
|
+
function unwrapDynamicImportExpression(expression) {
|
|
56
|
+
if (ts.isParenthesizedExpression(expression)) return unwrapDynamicImportExpression(expression.expression);
|
|
57
|
+
if (ts.isAwaitExpression(expression)) return unwrapDynamicImportExpression(expression.expression);
|
|
58
|
+
if (!ts.isCallExpression(expression) || expression.expression.kind !== ts.SyntaxKind.ImportKeyword) return null;
|
|
59
|
+
return expression;
|
|
60
|
+
}
|
|
61
|
+
function getWrapperBodyExpression(body) {
|
|
62
|
+
if (!body) return null;
|
|
63
|
+
if (!ts.isBlock(body)) return body;
|
|
64
|
+
if (body.statements.length !== 1) return null;
|
|
65
|
+
const [statement] = body.statements;
|
|
66
|
+
if (!ts.isReturnStatement(statement) || !statement.expression) return null;
|
|
67
|
+
return statement.expression;
|
|
68
|
+
}
|
|
69
|
+
function createImportWrapper(name, parameterName, body, sourceFile) {
|
|
70
|
+
const bodyExpression = getWrapperBodyExpression(body);
|
|
71
|
+
if (!bodyExpression) return null;
|
|
72
|
+
const importExpression = unwrapDynamicImportExpression(bodyExpression);
|
|
73
|
+
if (!importExpression || importExpression.arguments.length < 1) return null;
|
|
74
|
+
const [importArgument] = importExpression.arguments;
|
|
75
|
+
if (!ts.isIdentifier(importArgument) || importArgument.text !== parameterName || !body) return null;
|
|
76
|
+
return {
|
|
77
|
+
name,
|
|
78
|
+
parameterName,
|
|
79
|
+
bodyStart: body.getStart(sourceFile),
|
|
80
|
+
bodyEnd: body.getEnd(),
|
|
81
|
+
specifiers: /* @__PURE__ */ new Set(),
|
|
82
|
+
hasUnsupportedCalls: false
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
function collectImportWrappers(sourceFile) {
|
|
86
|
+
const wrappers = /* @__PURE__ */ new Map();
|
|
87
|
+
for (const statement of sourceFile.statements) {
|
|
88
|
+
if (ts.isFunctionDeclaration(statement) && statement.name && !hasExportModifier(statement) && statement.parameters.length === 1 && ts.isIdentifier(statement.parameters[0]?.name)) {
|
|
89
|
+
const wrapper = createImportWrapper(statement.name.text, statement.parameters[0].name.text, statement.body, sourceFile);
|
|
90
|
+
if (wrapper) wrappers.set(wrapper.name, wrapper);
|
|
91
|
+
}
|
|
92
|
+
if (!isConstVariableStatement(statement) || hasExportModifier(statement)) continue;
|
|
93
|
+
for (const declaration of statement.declarationList.declarations) {
|
|
94
|
+
if (!ts.isIdentifier(declaration.name) || !declaration.initializer) continue;
|
|
95
|
+
if (!ts.isArrowFunction(declaration.initializer) && !ts.isFunctionExpression(declaration.initializer)) continue;
|
|
96
|
+
if (declaration.initializer.parameters.length !== 1 || !ts.isIdentifier(declaration.initializer.parameters[0]?.name)) continue;
|
|
97
|
+
const wrapper = createImportWrapper(declaration.name.text, declaration.initializer.parameters[0].name.text, declaration.initializer.body, sourceFile);
|
|
98
|
+
if (wrapper) wrappers.set(wrapper.name, wrapper);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return wrappers;
|
|
102
|
+
}
|
|
103
|
+
function collectWrapperCallSpecifiers(sourceFile, wrappers, constStrings) {
|
|
104
|
+
function visit(node) {
|
|
105
|
+
if (ts.isCallExpression(node) && ts.isIdentifier(node.expression)) {
|
|
106
|
+
const wrapper = wrappers.get(node.expression.text);
|
|
107
|
+
if (wrapper) if (node.arguments.length !== 1) wrapper.hasUnsupportedCalls = true;
|
|
108
|
+
else {
|
|
109
|
+
const specifier = resolveLiteralImportSpecifier(node.arguments[0], constStrings);
|
|
110
|
+
if (specifier === null) wrapper.hasUnsupportedCalls = true;
|
|
111
|
+
else wrapper.specifiers.add(specifier);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
ts.forEachChild(node, visit);
|
|
115
|
+
}
|
|
116
|
+
visit(sourceFile);
|
|
117
|
+
}
|
|
118
|
+
function createImportIdentifier(specifierToIdentifier, specifier) {
|
|
119
|
+
const existing = specifierToIdentifier.get(specifier);
|
|
120
|
+
if (existing) return existing;
|
|
121
|
+
const identifier = `__devflareDynamicImport${specifierToIdentifier.size}`;
|
|
122
|
+
specifierToIdentifier.set(specifier, identifier);
|
|
123
|
+
return identifier;
|
|
124
|
+
}
|
|
125
|
+
function buildWrapperBody(wrapper, specifierToIdentifier) {
|
|
126
|
+
const cases = Array.from(wrapper.specifiers).sort((left, right) => left.localeCompare(right)).map((specifier) => {
|
|
127
|
+
const identifier = createImportIdentifier(specifierToIdentifier, specifier);
|
|
128
|
+
return `\t\tcase ${quoteString(specifier)}:\n\t\t\treturn Promise.resolve(${identifier})`;
|
|
129
|
+
}).join("\n");
|
|
130
|
+
return `{
|
|
131
|
+
switch (${wrapper.parameterName}) {
|
|
132
|
+
${cases}
|
|
133
|
+
default:
|
|
134
|
+
return Promise.reject(new Error(\`Unsupported dynamic import in Devflare worker bundle: \${${wrapper.parameterName}}\`))
|
|
135
|
+
}
|
|
136
|
+
}`;
|
|
137
|
+
}
|
|
138
|
+
function findContainingWrapper(callExpression, wrappers, sourceFile) {
|
|
139
|
+
const start = callExpression.getStart(sourceFile);
|
|
140
|
+
const end = callExpression.getEnd();
|
|
141
|
+
for (const wrapper of wrappers) if (start >= wrapper.bodyStart && end <= wrapper.bodyEnd) return wrapper;
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
144
|
+
function transformWorkerDynamicImports(code, id) {
|
|
145
|
+
const sourceFile = createSourceFile(code, id);
|
|
146
|
+
const constStrings = collectTopLevelConstStrings(sourceFile);
|
|
147
|
+
const wrappers = collectImportWrappers(sourceFile);
|
|
148
|
+
collectWrapperCallSpecifiers(sourceFile, wrappers, constStrings);
|
|
149
|
+
const transformableWrappers = Array.from(wrappers.values()).filter((wrapper) => {
|
|
150
|
+
return !wrapper.hasUnsupportedCalls && wrapper.specifiers.size > 0;
|
|
151
|
+
});
|
|
152
|
+
const replacements = [];
|
|
153
|
+
const specifierToIdentifier = /* @__PURE__ */ new Map();
|
|
154
|
+
function visit(node) {
|
|
155
|
+
if (ts.isCallExpression(node) && node.expression.kind === ts.SyntaxKind.ImportKeyword) {
|
|
156
|
+
const containingWrapper = findContainingWrapper(node, transformableWrappers, sourceFile);
|
|
157
|
+
if (containingWrapper && node.arguments.length === 1 && ts.isIdentifier(node.arguments[0]) && node.arguments[0].text === containingWrapper.parameterName) return;
|
|
158
|
+
const [argument] = node.arguments;
|
|
159
|
+
if (!argument) return;
|
|
160
|
+
const specifier = resolveLiteralImportSpecifier(argument, constStrings);
|
|
161
|
+
if (specifier !== null) replacements.push({
|
|
162
|
+
start: node.getStart(sourceFile),
|
|
163
|
+
end: node.getEnd(),
|
|
164
|
+
text: `Promise.resolve(${createImportIdentifier(specifierToIdentifier, specifier)})`
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
ts.forEachChild(node, visit);
|
|
168
|
+
}
|
|
169
|
+
visit(sourceFile);
|
|
170
|
+
if (replacements.length === 0 && transformableWrappers.length === 0) return null;
|
|
171
|
+
const s = new MagicString(code);
|
|
172
|
+
for (const replacement of replacements.sort((left, right) => right.start - left.start)) s.overwrite(replacement.start, replacement.end, replacement.text);
|
|
173
|
+
for (const wrapper of transformableWrappers.sort((left, right) => right.bodyStart - left.bodyStart)) s.overwrite(wrapper.bodyStart, wrapper.bodyEnd, buildWrapperBody(wrapper, specifierToIdentifier));
|
|
174
|
+
if (specifierToIdentifier.size > 0) {
|
|
175
|
+
const importBlock = Array.from(specifierToIdentifier.entries()).map(([specifier, identifier]) => `import * as ${identifier} from ${quoteString(specifier)}`).join("\n");
|
|
176
|
+
if (code.startsWith("#!")) {
|
|
177
|
+
const newlineIndex = code.indexOf("\n");
|
|
178
|
+
if (newlineIndex === -1) s.appendRight(code.length, `\n${importBlock}\n`);
|
|
179
|
+
else s.appendLeft(newlineIndex + 1, `${importBlock}\n`);
|
|
180
|
+
} else s.appendLeft(0, `${importBlock}\n`);
|
|
181
|
+
}
|
|
182
|
+
return {
|
|
183
|
+
code: s.toString(),
|
|
184
|
+
map: s.generateMap({
|
|
185
|
+
source: id,
|
|
186
|
+
file: `${id}.map`,
|
|
187
|
+
includeContent: true
|
|
188
|
+
})
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
function findDynamicImportCalls(sourceFile) {
|
|
192
|
+
const calls = [];
|
|
193
|
+
function visit(node) {
|
|
194
|
+
if (ts.isCallExpression(node) && node.expression.kind === ts.SyntaxKind.ImportKeyword) calls.push(node);
|
|
195
|
+
ts.forEachChild(node, visit);
|
|
196
|
+
}
|
|
197
|
+
visit(sourceFile);
|
|
198
|
+
return calls;
|
|
199
|
+
}
|
|
200
|
+
async function assertWorkerBundleHasNoDynamicImports(bundlePath) {
|
|
201
|
+
const code = await (await import("node:fs/promises")).readFile(bundlePath, "utf-8");
|
|
202
|
+
const sourceFile = createSourceFile(code, bundlePath);
|
|
203
|
+
const dynamicImports = findDynamicImportCalls(sourceFile);
|
|
204
|
+
if (dynamicImports.length === 0) return;
|
|
205
|
+
const examples = dynamicImports.slice(0, 3).map((callExpression) => {
|
|
206
|
+
const start = callExpression.getStart(sourceFile);
|
|
207
|
+
const { line, character } = sourceFile.getLineAndCharacterOfPosition(start);
|
|
208
|
+
const snippet = code.slice(start, callExpression.getEnd()).replace(/\s+/g, " ").trim();
|
|
209
|
+
return `- ${line + 1}:${character + 1} ${snippet}`;
|
|
210
|
+
}).join("\n");
|
|
211
|
+
throw new Error([
|
|
212
|
+
WORKER_DYNAMIC_IMPORT_ERROR,
|
|
213
|
+
`Bundle: ${bundlePath}`,
|
|
214
|
+
`Examples:\n${examples}`,
|
|
215
|
+
"Devflare can normalize literal import() calls and simple helper wrappers whose call sites are literal strings, but truly runtime-computed specifiers must be converted to static imports for worker bundles."
|
|
216
|
+
].join("\n\n"));
|
|
217
|
+
}
|
|
218
|
+
function createWorkerDynamicImportPlugin() {
|
|
219
|
+
return {
|
|
220
|
+
name: "devflare-worker-dynamic-imports",
|
|
221
|
+
transform(code, id) {
|
|
222
|
+
return transformWorkerDynamicImports(code, id) ?? null;
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
//#endregion
|
|
227
|
+
//#region src/bundler/rolldown-shared.ts
|
|
228
|
+
const DEFAULT_EXTERNAL_MODULES = [
|
|
229
|
+
/^cloudflare:/,
|
|
230
|
+
/^node:/,
|
|
231
|
+
"buffer",
|
|
232
|
+
"crypto",
|
|
233
|
+
"events",
|
|
234
|
+
"http",
|
|
235
|
+
"https",
|
|
236
|
+
"net",
|
|
237
|
+
"os",
|
|
238
|
+
"path",
|
|
239
|
+
"stream",
|
|
240
|
+
"tls",
|
|
241
|
+
"url",
|
|
242
|
+
"util",
|
|
243
|
+
"zlib",
|
|
244
|
+
"fs",
|
|
245
|
+
"child_process",
|
|
246
|
+
"async_hooks",
|
|
247
|
+
"querystring",
|
|
248
|
+
"string_decoder",
|
|
249
|
+
"assert",
|
|
250
|
+
"dns"
|
|
251
|
+
];
|
|
252
|
+
function toArray(value) {
|
|
253
|
+
return Array.isArray(value) ? value : [value];
|
|
254
|
+
}
|
|
255
|
+
function matchesExternalPattern(pattern, id) {
|
|
256
|
+
if (pattern instanceof RegExp) {
|
|
257
|
+
pattern.lastIndex = 0;
|
|
258
|
+
return pattern.test(id);
|
|
259
|
+
}
|
|
260
|
+
return pattern === id;
|
|
261
|
+
}
|
|
262
|
+
function matchesExternalOption(option, id, parentId, isResolved) {
|
|
263
|
+
if (!option) return false;
|
|
264
|
+
if (typeof option === "function") return option(id, parentId, isResolved) ?? false;
|
|
265
|
+
return toArray(option).some((pattern) => matchesExternalPattern(pattern, id));
|
|
266
|
+
}
|
|
267
|
+
function mergeExternalOptions(base, user) {
|
|
268
|
+
if (!base) return user;
|
|
269
|
+
if (!user) return base;
|
|
270
|
+
if (typeof base !== "function" && typeof user !== "function") return [...toArray(base), ...toArray(user)];
|
|
271
|
+
return (id, parentId, isResolved) => {
|
|
272
|
+
return matchesExternalOption(base, id, parentId, isResolved) || matchesExternalOption(user, id, parentId, isResolved) || false;
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
function mergePluginOptions(base, user) {
|
|
276
|
+
if (!base) return user;
|
|
277
|
+
if (!user) return base;
|
|
278
|
+
return [base, user];
|
|
279
|
+
}
|
|
280
|
+
function aliasKey(find) {
|
|
281
|
+
return find instanceof RegExp ? `re:${find.source}:${find.flags}` : `str:${find}`;
|
|
282
|
+
}
|
|
283
|
+
function normalizeAliasEntries(input) {
|
|
284
|
+
if (!input) return [];
|
|
285
|
+
if (Array.isArray(input)) return input.filter((entry) => {
|
|
286
|
+
return Boolean(entry) && typeof entry.replacement === "string";
|
|
287
|
+
});
|
|
288
|
+
return Object.entries(input).filter(([, replacement]) => typeof replacement === "string").map(([find, replacement]) => ({
|
|
289
|
+
find,
|
|
290
|
+
replacement
|
|
291
|
+
}));
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Merge framework-default aliases with user-provided aliases.
|
|
295
|
+
*
|
|
296
|
+
* Contract:
|
|
297
|
+
* - Framework defaults are emitted first, then user entries, so on duplicate
|
|
298
|
+
* `find` keys the user entry wins (object-spread / last-wins semantics).
|
|
299
|
+
* - Entries are deduplicated by the normalized `find` key (string value or
|
|
300
|
+
* `RegExp.source` + flags).
|
|
301
|
+
* - Ordering of user entries is preserved so regex specificity remains
|
|
302
|
+
* predictable.
|
|
303
|
+
*/
|
|
304
|
+
function mergeAliases(userAliases, frameworkDefaults) {
|
|
305
|
+
const userKeys = new Set(userAliases.map((entry) => aliasKey(entry.find)));
|
|
306
|
+
const frameworkFiltered = frameworkDefaults.filter((entry) => {
|
|
307
|
+
return !userKeys.has(aliasKey(entry.find));
|
|
308
|
+
});
|
|
309
|
+
const seenUserKeys = /* @__PURE__ */ new Set();
|
|
310
|
+
const dedupedUser = [];
|
|
311
|
+
for (let index = userAliases.length - 1; index >= 0; index--) {
|
|
312
|
+
const entry = userAliases[index];
|
|
313
|
+
const key = aliasKey(entry.find);
|
|
314
|
+
if (seenUserKeys.has(key)) continue;
|
|
315
|
+
seenUserKeys.add(key);
|
|
316
|
+
dedupedUser.unshift(entry);
|
|
317
|
+
}
|
|
318
|
+
return [...frameworkFiltered, ...dedupedUser];
|
|
319
|
+
}
|
|
320
|
+
function aliasEntriesToRolldownRecord(entries) {
|
|
321
|
+
const record = {};
|
|
322
|
+
for (const entry of entries) {
|
|
323
|
+
if (entry.find instanceof RegExp) continue;
|
|
324
|
+
record[entry.find] = entry.replacement;
|
|
325
|
+
}
|
|
326
|
+
return record;
|
|
327
|
+
}
|
|
328
|
+
function mergeResolveOptions(base, user) {
|
|
329
|
+
if (!base && !user) return;
|
|
330
|
+
const frameworkEntries = normalizeAliasEntries(base?.alias);
|
|
331
|
+
const mergedEntries = mergeAliases(normalizeAliasEntries(user?.alias), frameworkEntries);
|
|
332
|
+
const mergedAlias = aliasEntriesToRolldownRecord(mergedEntries);
|
|
333
|
+
return {
|
|
334
|
+
...user ?? {},
|
|
335
|
+
...base ?? {},
|
|
336
|
+
...mergedEntries.length > 0 ? { alias: mergedAlias } : {}
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
function resolveTsconfigOption(options) {
|
|
340
|
+
if (options.userTsconfig) return { tsconfig: options.userTsconfig };
|
|
341
|
+
const defaultTsconfigPath = resolve(options.cwd, "tsconfig.json");
|
|
342
|
+
if (options.defaultMode === "always" || existsSync(defaultTsconfigPath)) return { tsconfig: defaultTsconfigPath };
|
|
343
|
+
return {};
|
|
344
|
+
}
|
|
345
|
+
async function ensureDebugShim(outDir) {
|
|
346
|
+
const fs = await import("node:fs/promises");
|
|
347
|
+
const debugShimCode = `
|
|
348
|
+
// Debug module shim for local development
|
|
349
|
+
const createDebug = (namespace) => {
|
|
350
|
+
const logger = (...args) => {
|
|
351
|
+
if (createDebug.enabled) console.debug(\`[\${namespace}]\`, ...args)
|
|
352
|
+
}
|
|
353
|
+
logger.enabled = false
|
|
354
|
+
logger.namespace = namespace
|
|
355
|
+
logger.extend = (sub) => createDebug(\`\${namespace}:\${sub}\`)
|
|
356
|
+
return logger
|
|
357
|
+
}
|
|
358
|
+
createDebug.enabled = false
|
|
359
|
+
createDebug.formatters = {}
|
|
360
|
+
export default createDebug
|
|
361
|
+
`;
|
|
362
|
+
const debugShimPath = resolve(outDir, "_debug_shim.js");
|
|
363
|
+
await fs.writeFile(debugShimPath, debugShimCode, "utf-8");
|
|
364
|
+
return debugShimPath;
|
|
365
|
+
}
|
|
366
|
+
function resolveWorkerCompatibleRolldownConfig(options) {
|
|
367
|
+
const { output: userOutputOptions, input: _ignoredInput, cwd: _ignoredCwd, platform: _ignoredPlatform, target: _ignoredTarget, watch: _ignoredWatch, external: userExternal, plugins: userPlugins, resolve: userResolve, tsconfig: userTsconfig, ...userInputOptions } = options.rolldownOptions ?? {};
|
|
368
|
+
const { codeSplitting: _ignoredCodeSplitting, dir: _ignoredDir, file: _ignoredFile, format: _ignoredFormat, inlineDynamicImports: _ignoredInlineDynamicImports, ...safeUserOutputOptions } = userOutputOptions ?? {};
|
|
369
|
+
return {
|
|
370
|
+
inputOptions: {
|
|
371
|
+
...userInputOptions,
|
|
372
|
+
input: options.inputFile,
|
|
373
|
+
cwd: options.cwd,
|
|
374
|
+
platform: options.platform,
|
|
375
|
+
...resolveTsconfigOption({
|
|
376
|
+
cwd: options.cwd,
|
|
377
|
+
userTsconfig,
|
|
378
|
+
defaultMode: options.defaultTsconfigMode
|
|
379
|
+
}),
|
|
380
|
+
external: mergeExternalOptions(DEFAULT_EXTERNAL_MODULES, userExternal),
|
|
381
|
+
plugins: mergePluginOptions(createWorkerDynamicImportPlugin(), userPlugins),
|
|
382
|
+
resolve: mergeResolveOptions(options.alias ? { alias: options.alias } : void 0, userResolve)
|
|
383
|
+
},
|
|
384
|
+
outputOptions: {
|
|
385
|
+
...safeUserOutputOptions,
|
|
386
|
+
file: options.outFile,
|
|
387
|
+
format: "esm",
|
|
388
|
+
sourcemap: safeUserOutputOptions.sourcemap ?? options.sourcemap ?? false,
|
|
389
|
+
minify: safeUserOutputOptions.minify ?? options.minify,
|
|
390
|
+
codeSplitting: false,
|
|
391
|
+
...options.inlineDynamicImports !== void 0 ? { inlineDynamicImports: options.inlineDynamicImports } : {}
|
|
392
|
+
}
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
async function writeWorkerCompatibleBundle(options) {
|
|
396
|
+
const { rolldown } = await import("rolldown");
|
|
397
|
+
const bundle = await rolldown(options.inputOptions);
|
|
398
|
+
try {
|
|
399
|
+
await bundle.write(options.outputOptions);
|
|
400
|
+
await assertWorkerBundleHasNoDynamicImports(options.outFile);
|
|
401
|
+
} finally {
|
|
402
|
+
await bundle.close();
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
//#endregion
|
|
406
|
+
//#region src/bundler/worker-bundler.ts
|
|
407
|
+
async function resolveInternalModuleEntry(relativeCandidates) {
|
|
408
|
+
const fs = await import("node:fs/promises");
|
|
409
|
+
const currentFileDir = dirname(fileURLToPath(import.meta.url));
|
|
410
|
+
for (const candidate of relativeCandidates) {
|
|
411
|
+
const absolutePath = resolve(currentFileDir, candidate);
|
|
412
|
+
try {
|
|
413
|
+
await fs.access(absolutePath);
|
|
414
|
+
return absolutePath;
|
|
415
|
+
} catch {}
|
|
416
|
+
}
|
|
417
|
+
return null;
|
|
418
|
+
}
|
|
419
|
+
async function resolveInternalAliasMap(outDir) {
|
|
420
|
+
const debugShimPath = await ensureDebugShim(outDir);
|
|
421
|
+
const runtimeEntry = await resolveInternalModuleEntry(["../runtime/index.ts", "../runtime/index.js"]);
|
|
422
|
+
const packageEntry = await resolveInternalModuleEntry(["../browser.ts", "../browser.js"]);
|
|
423
|
+
return {
|
|
424
|
+
debug: debugShimPath,
|
|
425
|
+
...runtimeEntry ? { "devflare/runtime": runtimeEntry } : {},
|
|
426
|
+
...packageEntry ? { devflare: packageEntry } : {}
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
async function bundleWorkerEntry(options) {
|
|
430
|
+
const fs = await import("node:fs/promises");
|
|
431
|
+
const outDir = dirname(options.outFile);
|
|
432
|
+
await fs.mkdir(outDir, { recursive: true });
|
|
433
|
+
await fs.rm(options.outFile, { force: true });
|
|
434
|
+
await fs.rm(`${options.outFile}.map`, { force: true });
|
|
435
|
+
const alias = await resolveInternalAliasMap(outDir);
|
|
436
|
+
const defaults = createWorkerdBundlerDefaults();
|
|
437
|
+
const { inputOptions, outputOptions } = resolveWorkerCompatibleRolldownConfig({
|
|
438
|
+
cwd: options.cwd,
|
|
439
|
+
inputFile: options.inputFile,
|
|
440
|
+
outFile: options.outFile,
|
|
441
|
+
alias,
|
|
442
|
+
...defaults,
|
|
443
|
+
platform: "browser",
|
|
444
|
+
rolldownOptions: options.rolldownOptions,
|
|
445
|
+
sourcemap: options.sourcemap ?? defaults.sourcemap,
|
|
446
|
+
minify: options.minify ?? defaults.minify,
|
|
447
|
+
defaultTsconfigMode: "if-present"
|
|
448
|
+
});
|
|
449
|
+
options.logger?.debug(`Bundling main worker → ${options.outFile}`);
|
|
450
|
+
await writeWorkerCompatibleBundle({
|
|
451
|
+
inputOptions,
|
|
452
|
+
outputOptions,
|
|
453
|
+
outFile: options.outFile
|
|
454
|
+
});
|
|
455
|
+
return options.outFile;
|
|
456
|
+
}
|
|
457
|
+
//#endregion
|
|
458
|
+
export { createWorkerdBundlerDefaults as a, writeWorkerCompatibleBundle as i, ensureDebugShim as n, resolveWorkerCompatibleRolldownConfig as r, bundleWorkerEntry as t };
|