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.
Files changed (596) hide show
  1. package/LICENSE +21 -0
  2. package/LLM.md +17312 -2139
  3. package/README.md +397 -605
  4. package/bin/devflare.js +30 -14
  5. package/dist/_chunks/account-Csog80ie.js +462 -0
  6. package/dist/_chunks/account-resources-CsmVowJp.js +159 -0
  7. package/dist/_chunks/ai-CBEuLdoP.js +322 -0
  8. package/dist/_chunks/api-TzdliH-6.js +568 -0
  9. package/dist/_chunks/build-Ccza8VQz.js +24 -0
  10. package/dist/_chunks/build-artifacts-BNssqhxE.js +483 -0
  11. package/dist/_chunks/cli-CU7wSG1-.js +1163 -0
  12. package/dist/_chunks/cloudflare-BaloqI3H.js +157 -0
  13. package/dist/_chunks/colors-DiK6wPJ5.js +13 -0
  14. package/dist/_chunks/command-utils-_bGRraDR.js +45 -0
  15. package/dist/_chunks/compiler-BtLp9T9N.js +500 -0
  16. package/dist/_chunks/config-QU8UEWmA.js +78 -0
  17. package/dist/_chunks/config-path-1yI7BiDU.js +42 -0
  18. package/dist/_chunks/context-CX50Y2Kb.js +2250 -0
  19. package/dist/_chunks/decorators-QmV57ixr.js +19 -0
  20. package/dist/_chunks/dependencies-C2oxFjU_.js +57 -0
  21. package/dist/_chunks/deploy-aifBaMVv.js +1032 -0
  22. package/dist/_chunks/dev-DF_3baGr.js +3483 -0
  23. package/dist/_chunks/doctor-tR9kGT_Z.js +219 -0
  24. package/dist/_chunks/durable-object-DMtH0XYX.js +234 -0
  25. package/dist/_chunks/env-S0_nMVz1.js +125 -0
  26. package/dist/_chunks/family-DKPp4wqj.js +143 -0
  27. package/dist/_chunks/generated-artifacts-dMJY4KAt.js +32 -0
  28. package/dist/_chunks/glob-CmQOvunB.js +56 -0
  29. package/dist/_chunks/init-DnkJOmpW.js +165 -0
  30. package/dist/_chunks/loader-OQ2AWpqm.js +1308 -0
  31. package/dist/_chunks/local-dev-vars-CTSa-wvF.js +81 -0
  32. package/dist/_chunks/local-hyperdrive-CJ90j46O.js +119 -0
  33. package/dist/_chunks/local-media-bindings-DsAW4AMF.js +335 -0
  34. package/dist/_chunks/local-secrets-CYoHfvQ1.js +123 -0
  35. package/dist/_chunks/local-workflow-entrypoints-8d_mXh8T.js +90 -0
  36. package/dist/_chunks/login-rVWUZOKC.js +51 -0
  37. package/dist/_chunks/package-metadata-DjHBLB-z.js +39 -0
  38. package/dist/_chunks/preferences-BKp_7XJx.js +241 -0
  39. package/dist/_chunks/preview-C3Cdr8an.js +462 -0
  40. package/dist/_chunks/preview-registry-ClAbLTHH.js +1186 -0
  41. package/dist/_chunks/preview-resources-DRWR0gaB.js +359 -0
  42. package/dist/_chunks/previews-BxNq8Y_J.js +1134 -0
  43. package/dist/_chunks/productions-DK7xwbEs.js +411 -0
  44. package/dist/_chunks/ref-CYJNAAe_.js +178 -0
  45. package/dist/_chunks/remote-CZnP-HLJ.js +79 -0
  46. package/dist/_chunks/remote-config-D39BY9ji.js +132 -0
  47. package/dist/_chunks/resolve-package-qizBfCIm.js +152 -0
  48. package/dist/_chunks/rolldown-runtime-CvQ6eiug.js +14 -0
  49. package/dist/_chunks/routes-B6XiI8Sa.js +851 -0
  50. package/dist/_chunks/runtime-DL-Nz3k8.js +550 -0
  51. package/dist/_chunks/schema-normalization-GjhTATHL.js +666 -0
  52. package/dist/_chunks/secrets-qT1JaBGt.js +95 -0
  53. package/dist/_chunks/tail-CuWI04BL.js +239 -0
  54. package/dist/_chunks/token-Dmi0KXyX.js +333 -0
  55. package/dist/_chunks/tokens-iVcgNXi-.js +221 -0
  56. package/dist/_chunks/types-BquPXsFg.js +484 -0
  57. package/dist/_chunks/ui-BUoZApvE.js +103 -0
  58. package/dist/_chunks/usage-BBTGzjon.js +272 -0
  59. package/dist/_chunks/vite-D_wLDGBs.js +1267 -0
  60. package/dist/_chunks/vite-utils-OVLMV605.js +183 -0
  61. package/dist/_chunks/worker-DEF-e8LL.js +410 -0
  62. package/dist/_chunks/worker-bundler-dTTnYU3n.js +458 -0
  63. package/dist/_chunks/worker-entrypoint-CQW77lG8.js +247 -0
  64. package/dist/_chunks/workerName-CFJsLZA-.js +23 -0
  65. package/dist/bridge/client.d.ts +49 -7
  66. package/dist/bridge/client.d.ts.map +1 -1
  67. package/dist/bridge/gateway-runtime.d.ts +8 -0
  68. package/dist/bridge/gateway-runtime.d.ts.map +1 -0
  69. package/dist/bridge/index.d.ts +6 -6
  70. package/dist/bridge/index.d.ts.map +1 -1
  71. package/dist/bridge/log.d.ts +5 -0
  72. package/dist/bridge/log.d.ts.map +1 -0
  73. package/dist/bridge/miniflare.d.ts +85 -2
  74. package/dist/bridge/miniflare.d.ts.map +1 -1
  75. package/dist/bridge/proxy.d.ts +12 -11
  76. package/dist/bridge/proxy.d.ts.map +1 -1
  77. package/dist/bridge/server.d.ts +2 -1
  78. package/dist/bridge/server.d.ts.map +1 -1
  79. package/dist/bridge/v2/body-streams.d.ts +53 -0
  80. package/dist/bridge/v2/body-streams.d.ts.map +1 -0
  81. package/dist/bridge/v2/codec.d.ts +106 -0
  82. package/dist/bridge/v2/codec.d.ts.map +1 -0
  83. package/dist/bridge/v2/control-messages.d.ts +46 -0
  84. package/dist/bridge/v2/control-messages.d.ts.map +1 -0
  85. package/dist/bridge/v2/frames.d.ts +109 -0
  86. package/dist/bridge/v2/frames.d.ts.map +1 -0
  87. package/dist/bridge/v2/index.d.ts +11 -0
  88. package/dist/bridge/v2/index.d.ts.map +1 -0
  89. package/dist/bridge/v2/serialization.d.ts +48 -0
  90. package/dist/bridge/v2/serialization.d.ts.map +1 -0
  91. package/dist/bridge/v2/transport.d.ts +31 -0
  92. package/dist/bridge/v2/transport.d.ts.map +1 -0
  93. package/dist/bridge/v2/value-codec.d.ts +61 -0
  94. package/dist/bridge/v2/value-codec.d.ts.map +1 -0
  95. package/dist/bridge/{serialization.d.ts → v2/value-serialization.d.ts} +40 -18
  96. package/dist/bridge/v2/value-serialization.d.ts.map +1 -0
  97. package/dist/bridge/{protocol.d.ts → v2/wire.d.ts} +32 -8
  98. package/dist/bridge/v2/wire.d.ts.map +1 -0
  99. package/dist/bridge/v2/ws-relay.d.ts +53 -0
  100. package/dist/bridge/v2/ws-relay.d.ts.map +1 -0
  101. package/dist/browser-shim/handler.d.ts +2 -2
  102. package/dist/browser-shim/handler.d.ts.map +1 -1
  103. package/dist/browser-shim/index.d.ts +2 -2
  104. package/dist/browser-shim/server.d.ts +63 -0
  105. package/dist/browser-shim/server.d.ts.map +1 -1
  106. package/dist/browser.d.ts +5705 -0
  107. package/dist/browser.d.ts.map +1 -0
  108. package/dist/browser.js +80 -0
  109. package/dist/bundler/defaults.d.ts +23 -0
  110. package/dist/bundler/defaults.d.ts.map +1 -0
  111. package/dist/bundler/do-bundler.d.ts +7 -0
  112. package/dist/bundler/do-bundler.d.ts.map +1 -1
  113. package/dist/bundler/index.d.ts +3 -1
  114. package/dist/bundler/index.d.ts.map +1 -1
  115. package/dist/bundler/rolldown-shared.d.ts +53 -0
  116. package/dist/bundler/rolldown-shared.d.ts.map +1 -0
  117. package/dist/bundler/worker-bundler.d.ts +13 -0
  118. package/dist/bundler/worker-bundler.d.ts.map +1 -0
  119. package/dist/bundler/worker-compat.d.ts +4 -0
  120. package/dist/bundler/worker-compat.d.ts.map +1 -0
  121. package/dist/cli/build-manifest.d.ts +66 -0
  122. package/dist/cli/build-manifest.d.ts.map +1 -0
  123. package/dist/cli/command-utils.d.ts +18 -0
  124. package/dist/cli/command-utils.d.ts.map +1 -0
  125. package/dist/cli/commands/account.d.ts +2 -2
  126. package/dist/cli/commands/account.d.ts.map +1 -1
  127. package/dist/cli/commands/ai.d.ts +1 -1
  128. package/dist/cli/commands/ai.d.ts.map +1 -1
  129. package/dist/cli/commands/build-artifacts.d.ts +40 -0
  130. package/dist/cli/commands/build-artifacts.d.ts.map +1 -0
  131. package/dist/cli/commands/build.d.ts +2 -2
  132. package/dist/cli/commands/build.d.ts.map +1 -1
  133. package/dist/cli/commands/config.d.ts +4 -0
  134. package/dist/cli/commands/config.d.ts.map +1 -0
  135. package/dist/cli/commands/deploy/metadata.d.ts +18 -0
  136. package/dist/cli/commands/deploy/metadata.d.ts.map +1 -0
  137. package/dist/cli/commands/deploy/prepare.d.ts +23 -0
  138. package/dist/cli/commands/deploy/prepare.d.ts.map +1 -0
  139. package/dist/cli/commands/deploy/runtime.d.ts +4 -0
  140. package/dist/cli/commands/deploy/runtime.d.ts.map +1 -0
  141. package/dist/cli/commands/deploy/verification.d.ts +36 -0
  142. package/dist/cli/commands/deploy/verification.d.ts.map +1 -0
  143. package/dist/cli/commands/deploy.d.ts +2 -2
  144. package/dist/cli/commands/deploy.d.ts.map +1 -1
  145. package/dist/cli/commands/dev.d.ts +9 -1
  146. package/dist/cli/commands/dev.d.ts.map +1 -1
  147. package/dist/cli/commands/doctor.d.ts +2 -2
  148. package/dist/cli/commands/doctor.d.ts.map +1 -1
  149. package/dist/cli/commands/init.d.ts +2 -2
  150. package/dist/cli/commands/init.d.ts.map +1 -1
  151. package/dist/cli/commands/login.d.ts +4 -0
  152. package/dist/cli/commands/login.d.ts.map +1 -0
  153. package/dist/cli/commands/previews-support/cleanup.d.ts +9 -0
  154. package/dist/cli/commands/previews-support/cleanup.d.ts.map +1 -0
  155. package/dist/cli/commands/previews-support/family.d.ts +10 -0
  156. package/dist/cli/commands/previews-support/family.d.ts.map +1 -0
  157. package/dist/cli/commands/previews-support/render.d.ts +8 -0
  158. package/dist/cli/commands/previews-support/render.d.ts.map +1 -0
  159. package/dist/cli/commands/previews-support/theme.d.ts +10 -0
  160. package/dist/cli/commands/previews-support/theme.d.ts.map +1 -0
  161. package/dist/cli/commands/previews-support/types.d.ts +70 -0
  162. package/dist/cli/commands/previews-support/types.d.ts.map +1 -0
  163. package/dist/cli/commands/previews.d.ts +4 -0
  164. package/dist/cli/commands/previews.d.ts.map +1 -0
  165. package/dist/cli/commands/productions.d.ts +4 -0
  166. package/dist/cli/commands/productions.d.ts.map +1 -0
  167. package/dist/cli/commands/remote.d.ts +1 -1
  168. package/dist/cli/commands/remote.d.ts.map +1 -1
  169. package/dist/cli/commands/secrets.d.ts +4 -0
  170. package/dist/cli/commands/secrets.d.ts.map +1 -0
  171. package/dist/cli/commands/tail.d.ts +44 -0
  172. package/dist/cli/commands/tail.d.ts.map +1 -0
  173. package/dist/cli/commands/token.d.ts +4 -0
  174. package/dist/cli/commands/token.d.ts.map +1 -0
  175. package/dist/cli/commands/type-generation/discovery.d.ts +7 -0
  176. package/dist/cli/commands/type-generation/discovery.d.ts.map +1 -0
  177. package/dist/cli/commands/type-generation/generator.d.ts +121 -0
  178. package/dist/cli/commands/type-generation/generator.d.ts.map +1 -0
  179. package/dist/cli/commands/type-generation/models.d.ts +27 -0
  180. package/dist/cli/commands/type-generation/models.d.ts.map +1 -0
  181. package/dist/cli/commands/types.d.ts +2 -2
  182. package/dist/cli/commands/types.d.ts.map +1 -1
  183. package/dist/cli/commands/worker.d.ts +4 -0
  184. package/dist/cli/commands/worker.d.ts.map +1 -0
  185. package/dist/cli/config-path.d.ts +6 -0
  186. package/dist/cli/config-path.d.ts.map +1 -0
  187. package/dist/cli/dependencies.d.ts +2 -1
  188. package/dist/cli/dependencies.d.ts.map +1 -1
  189. package/dist/cli/deploy-strategy.d.ts +17 -0
  190. package/dist/cli/deploy-strategy.d.ts.map +1 -0
  191. package/dist/cli/deploy-target.d.ts +17 -0
  192. package/dist/cli/deploy-target.d.ts.map +1 -0
  193. package/dist/cli/generated-artifacts.d.ts +12 -0
  194. package/dist/cli/generated-artifacts.d.ts.map +1 -0
  195. package/dist/cli/gradual-deploy.d.ts +49 -0
  196. package/dist/cli/gradual-deploy.d.ts.map +1 -0
  197. package/dist/cli/help-pages/pages/account.d.ts +3 -0
  198. package/dist/cli/help-pages/pages/account.d.ts.map +1 -0
  199. package/dist/cli/help-pages/pages/core.d.ts +4 -0
  200. package/dist/cli/help-pages/pages/core.d.ts.map +1 -0
  201. package/dist/cli/help-pages/pages/index.d.ts +3 -0
  202. package/dist/cli/help-pages/pages/index.d.ts.map +1 -0
  203. package/dist/cli/help-pages/pages/misc.d.ts +3 -0
  204. package/dist/cli/help-pages/pages/misc.d.ts.map +1 -0
  205. package/dist/cli/help-pages/pages/previews.d.ts +3 -0
  206. package/dist/cli/help-pages/pages/previews.d.ts.map +1 -0
  207. package/dist/cli/help-pages/pages/productions.d.ts +3 -0
  208. package/dist/cli/help-pages/pages/productions.d.ts.map +1 -0
  209. package/dist/cli/help-pages/render.d.ts +12 -0
  210. package/dist/cli/help-pages/render.d.ts.map +1 -0
  211. package/dist/cli/help-pages/shared.d.ts +15 -0
  212. package/dist/cli/help-pages/shared.d.ts.map +1 -0
  213. package/dist/cli/help-pages/types.d.ts +23 -0
  214. package/dist/cli/help-pages/types.d.ts.map +1 -0
  215. package/dist/cli/help.d.ts +6 -0
  216. package/dist/cli/help.d.ts.map +1 -0
  217. package/dist/cli/index.d.ts +1 -0
  218. package/dist/cli/index.d.ts.map +1 -1
  219. package/dist/cli/index.js +2 -0
  220. package/dist/cli/package-metadata.d.ts +16 -0
  221. package/dist/cli/package-metadata.d.ts.map +1 -0
  222. package/dist/cli/preview-bindings.d.ts +49 -0
  223. package/dist/cli/preview-bindings.d.ts.map +1 -0
  224. package/dist/cli/preview.d.ts +10 -0
  225. package/dist/cli/preview.d.ts.map +1 -0
  226. package/dist/cli/ui.d.ts +37 -0
  227. package/dist/cli/ui.d.ts.map +1 -0
  228. package/dist/cli/workspace-build-guard.d.ts +14 -0
  229. package/dist/cli/workspace-build-guard.d.ts.map +1 -0
  230. package/dist/cli/wrangler-auth.d.ts +1 -1
  231. package/dist/cloudflare/account-core.d.ts +6 -0
  232. package/dist/cloudflare/account-core.d.ts.map +1 -0
  233. package/dist/cloudflare/account-resources.d.ts +40 -0
  234. package/dist/cloudflare/account-resources.d.ts.map +1 -0
  235. package/dist/cloudflare/account-status.d.ts +11 -0
  236. package/dist/cloudflare/account-status.d.ts.map +1 -0
  237. package/dist/cloudflare/account-workers.d.ts +14 -0
  238. package/dist/cloudflare/account-workers.d.ts.map +1 -0
  239. package/dist/cloudflare/account.d.ts +7 -64
  240. package/dist/cloudflare/account.d.ts.map +1 -1
  241. package/dist/cloudflare/api.d.ts +71 -3
  242. package/dist/cloudflare/api.d.ts.map +1 -1
  243. package/dist/cloudflare/auth.d.ts +1 -1
  244. package/dist/cloudflare/auth.d.ts.map +1 -1
  245. package/dist/cloudflare/index.d.ts +61 -6
  246. package/dist/cloudflare/index.d.ts.map +1 -1
  247. package/dist/cloudflare/index.js +4 -13
  248. package/dist/cloudflare/known-permission-group-ids.generated.d.ts +10 -0
  249. package/dist/cloudflare/known-permission-group-ids.generated.d.ts.map +1 -0
  250. package/dist/cloudflare/kv-namespace.d.ts +4 -0
  251. package/dist/cloudflare/kv-namespace.d.ts.map +1 -0
  252. package/dist/cloudflare/preferences.d.ts +7 -0
  253. package/dist/cloudflare/preferences.d.ts.map +1 -1
  254. package/dist/cloudflare/preview-registry-cache.d.ts +6 -0
  255. package/dist/cloudflare/preview-registry-cache.d.ts.map +1 -0
  256. package/dist/cloudflare/preview-registry-inference.d.ts +14 -0
  257. package/dist/cloudflare/preview-registry-inference.d.ts.map +1 -0
  258. package/dist/cloudflare/preview-registry-records.d.ts +4 -0
  259. package/dist/cloudflare/preview-registry-records.d.ts.map +1 -0
  260. package/dist/cloudflare/preview-registry-shape.d.ts +47 -0
  261. package/dist/cloudflare/preview-registry-shape.d.ts.map +1 -0
  262. package/dist/cloudflare/preview-registry-store.d.ts +14 -0
  263. package/dist/cloudflare/preview-registry-store.d.ts.map +1 -0
  264. package/dist/cloudflare/preview-registry-transport.d.ts +4 -0
  265. package/dist/cloudflare/preview-registry-transport.d.ts.map +1 -0
  266. package/dist/cloudflare/preview-registry-types.d.ts +103 -0
  267. package/dist/cloudflare/preview-registry-types.d.ts.map +1 -0
  268. package/dist/cloudflare/preview-registry.d.ts +42 -0
  269. package/dist/cloudflare/preview-registry.d.ts.map +1 -0
  270. package/dist/cloudflare/preview-urls.d.ts +3 -0
  271. package/dist/cloudflare/preview-urls.d.ts.map +1 -0
  272. package/dist/cloudflare/registry-schema.d.ts +253 -0
  273. package/dist/cloudflare/registry-schema.d.ts.map +1 -0
  274. package/dist/cloudflare/remote-config.d.ts.map +1 -1
  275. package/dist/cloudflare/tokens.d.ts +44 -0
  276. package/dist/cloudflare/tokens.d.ts.map +1 -0
  277. package/dist/cloudflare/types.d.ts +124 -7
  278. package/dist/cloudflare/types.d.ts.map +1 -1
  279. package/dist/cloudflare/usage.d.ts +31 -3
  280. package/dist/cloudflare/usage.d.ts.map +1 -1
  281. package/dist/config/binding-resolution-helpers.d.ts +41 -0
  282. package/dist/config/binding-resolution-helpers.d.ts.map +1 -0
  283. package/dist/config/compatibility.d.ts +3 -0
  284. package/dist/config/compatibility.d.ts.map +1 -0
  285. package/dist/config/compiler/bindings.d.ts +14 -0
  286. package/dist/config/compiler/bindings.d.ts.map +1 -0
  287. package/dist/config/compiler/core-helpers.d.ts +6 -0
  288. package/dist/config/compiler/core-helpers.d.ts.map +1 -0
  289. package/dist/config/compiler/do-workers.d.ts +34 -0
  290. package/dist/config/compiler/do-workers.d.ts.map +1 -0
  291. package/dist/config/compiler/paths.d.ts +18 -0
  292. package/dist/config/compiler/paths.d.ts.map +1 -0
  293. package/dist/config/compiler/types.d.ts +309 -0
  294. package/dist/config/compiler/types.d.ts.map +1 -0
  295. package/dist/config/compiler.d.ts +22 -134
  296. package/dist/config/compiler.d.ts.map +1 -1
  297. package/dist/config/cron.d.ts +19 -0
  298. package/dist/config/cron.d.ts.map +1 -0
  299. package/dist/config/define.d.ts +8 -5
  300. package/dist/config/define.d.ts.map +1 -1
  301. package/dist/config/deploy-resources.d.ts +58 -0
  302. package/dist/config/deploy-resources.d.ts.map +1 -0
  303. package/dist/config/env-vars.d.ts +309 -0
  304. package/dist/config/env-vars.d.ts.map +1 -0
  305. package/dist/config/framework-providers.d.ts +9 -0
  306. package/dist/config/framework-providers.d.ts.map +1 -0
  307. package/dist/config/index.d.ts +12 -5
  308. package/dist/config/index.d.ts.map +1 -1
  309. package/dist/config/loader.d.ts +2 -1
  310. package/dist/config/loader.d.ts.map +1 -1
  311. package/dist/config/local-dev-vars.d.ts +15 -0
  312. package/dist/config/local-dev-vars.d.ts.map +1 -0
  313. package/dist/config/preview-resources.d.ts +83 -0
  314. package/dist/config/preview-resources.d.ts.map +1 -0
  315. package/dist/config/preview.d.ts +29 -0
  316. package/dist/config/preview.d.ts.map +1 -0
  317. package/dist/config/ref.d.ts +16 -25
  318. package/dist/config/ref.d.ts.map +1 -1
  319. package/dist/config/resolve-phased.d.ts +72 -0
  320. package/dist/config/resolve-phased.d.ts.map +1 -0
  321. package/dist/config/resolve.d.ts +11 -0
  322. package/dist/config/resolve.d.ts.map +1 -0
  323. package/dist/config/resource-resolution.d.ts +80 -0
  324. package/dist/config/resource-resolution.d.ts.map +1 -0
  325. package/dist/config/schema-bindings.d.ts +2087 -0
  326. package/dist/config/schema-bindings.d.ts.map +1 -0
  327. package/dist/config/schema-build.d.ts +67 -0
  328. package/dist/config/schema-build.d.ts.map +1 -0
  329. package/dist/config/schema-env.d.ts +3771 -0
  330. package/dist/config/schema-env.d.ts.map +1 -0
  331. package/dist/config/schema-normalization.d.ts +267 -0
  332. package/dist/config/schema-normalization.d.ts.map +1 -0
  333. package/dist/config/schema-runtime.d.ts +557 -0
  334. package/dist/config/schema-runtime.d.ts.map +1 -0
  335. package/dist/config/schema-types-bindings-platform.d.ts +520 -0
  336. package/dist/config/schema-types-bindings-platform.d.ts.map +1 -0
  337. package/dist/config/schema-types-bindings-resources.d.ts +802 -0
  338. package/dist/config/schema-types-bindings-resources.d.ts.map +1 -0
  339. package/dist/config/schema-types-bindings.d.ts +293 -0
  340. package/dist/config/schema-types-bindings.d.ts.map +1 -0
  341. package/dist/config/schema-types-build.d.ts +86 -0
  342. package/dist/config/schema-types-build.d.ts.map +1 -0
  343. package/dist/config/schema-types-runtime-server.d.ts +122 -0
  344. package/dist/config/schema-types-runtime-server.d.ts.map +1 -0
  345. package/dist/config/schema-types-runtime.d.ts +913 -0
  346. package/dist/config/schema-types-runtime.d.ts.map +1 -0
  347. package/dist/config/schema-types.d.ts +458 -0
  348. package/dist/config/schema-types.d.ts.map +1 -0
  349. package/dist/config/schema.d.ts +5699 -2021
  350. package/dist/config/schema.d.ts.map +1 -1
  351. package/dist/config/service-bindings-validation.d.ts +36 -0
  352. package/dist/config/service-bindings-validation.d.ts.map +1 -0
  353. package/dist/config-entry.d.ts +7 -0
  354. package/dist/config-entry.d.ts.map +1 -0
  355. package/dist/config-entry.js +3 -0
  356. package/dist/decorators/durable-object.d.ts.map +1 -1
  357. package/dist/decorators/index.d.ts +2 -2
  358. package/dist/decorators/index.js +2 -9
  359. package/dist/dev-server/d1-migrations.d.ts +36 -0
  360. package/dist/dev-server/d1-migrations.d.ts.map +1 -0
  361. package/dist/dev-server/dev-server-state.d.ts +59 -0
  362. package/dist/dev-server/dev-server-state.d.ts.map +1 -0
  363. package/dist/dev-server/gateway-script.d.ts +21 -0
  364. package/dist/dev-server/gateway-script.d.ts.map +1 -0
  365. package/dist/dev-server/index.d.ts +1 -1
  366. package/dist/dev-server/miniflare-bindings.d.ts +90 -0
  367. package/dist/dev-server/miniflare-bindings.d.ts.map +1 -0
  368. package/dist/dev-server/miniflare-dev-config.d.ts +36 -0
  369. package/dist/dev-server/miniflare-dev-config.d.ts.map +1 -0
  370. package/dist/dev-server/miniflare-log.d.ts +20 -0
  371. package/dist/dev-server/miniflare-log.d.ts.map +1 -0
  372. package/dist/dev-server/miniflare-worker-config.d.ts +93 -0
  373. package/dist/dev-server/miniflare-worker-config.d.ts.map +1 -0
  374. package/dist/dev-server/reload-queue.d.ts +13 -0
  375. package/dist/dev-server/reload-queue.d.ts.map +1 -0
  376. package/dist/dev-server/runtime-stdio.d.ts +8 -0
  377. package/dist/dev-server/runtime-stdio.d.ts.map +1 -0
  378. package/dist/dev-server/server-startup-helpers.d.ts +84 -0
  379. package/dist/dev-server/server-startup-helpers.d.ts.map +1 -0
  380. package/dist/dev-server/server.d.ts +2 -0
  381. package/dist/dev-server/server.d.ts.map +1 -1
  382. package/dist/dev-server/vite-process.d.ts +15 -0
  383. package/dist/dev-server/vite-process.d.ts.map +1 -0
  384. package/dist/dev-server/vite-utils.d.ts +19 -1
  385. package/dist/dev-server/vite-utils.d.ts.map +1 -1
  386. package/dist/dev-server/worker-source-watcher.d.ts +17 -0
  387. package/dist/dev-server/worker-source-watcher.d.ts.map +1 -0
  388. package/dist/dev-server/worker-surface-paths.d.ts +6 -0
  389. package/dist/dev-server/worker-surface-paths.d.ts.map +1 -0
  390. package/dist/env.d.ts +10 -0
  391. package/dist/env.d.ts.map +1 -1
  392. package/dist/index.d.ts +8 -12
  393. package/dist/index.d.ts.map +1 -1
  394. package/dist/index.js +9 -298
  395. package/dist/runtime/context-events.d.ts +13 -0
  396. package/dist/runtime/context-events.d.ts.map +1 -0
  397. package/dist/runtime/context-types.d.ts +82 -0
  398. package/dist/runtime/context-types.d.ts.map +1 -0
  399. package/dist/runtime/context.d.ts +20 -44
  400. package/dist/runtime/context.d.ts.map +1 -1
  401. package/dist/runtime/exports.d.ts +70 -55
  402. package/dist/runtime/exports.d.ts.map +1 -1
  403. package/dist/runtime/index.d.ts +10 -3
  404. package/dist/runtime/index.d.ts.map +1 -1
  405. package/dist/runtime/index.js +5 -111
  406. package/dist/runtime/middleware.d.ts +119 -67
  407. package/dist/runtime/middleware.d.ts.map +1 -1
  408. package/dist/runtime/router/index.d.ts +7 -0
  409. package/dist/runtime/router/index.d.ts.map +1 -0
  410. package/dist/runtime/router/types.d.ts +24 -0
  411. package/dist/runtime/router/types.d.ts.map +1 -0
  412. package/dist/runtime/validation.d.ts +18 -4
  413. package/dist/runtime/validation.d.ts.map +1 -1
  414. package/dist/secrets/local-secrets.d.ts +46 -0
  415. package/dist/secrets/local-secrets.d.ts.map +1 -0
  416. package/dist/shims/local-hyperdrive.d.ts +12 -0
  417. package/dist/shims/local-hyperdrive.d.ts.map +1 -0
  418. package/dist/shims/local-media-bindings.d.ts +19 -0
  419. package/dist/shims/local-media-bindings.d.ts.map +1 -0
  420. package/dist/shims/local-worker-loader.d.ts +3 -0
  421. package/dist/shims/local-worker-loader.d.ts.map +1 -0
  422. package/dist/sveltekit/index.d.ts +1 -1
  423. package/dist/sveltekit/index.d.ts.map +1 -1
  424. package/dist/sveltekit/index.js +313 -167
  425. package/dist/sveltekit/local-bindings.d.ts +4 -0
  426. package/dist/sveltekit/local-bindings.d.ts.map +1 -0
  427. package/dist/sveltekit/platform.d.ts +20 -2
  428. package/dist/sveltekit/platform.d.ts.map +1 -1
  429. package/dist/test/ai-search.d.ts +39 -0
  430. package/dist/test/ai-search.d.ts.map +1 -0
  431. package/dist/test/alarm.d.ts +55 -0
  432. package/dist/test/alarm.d.ts.map +1 -0
  433. package/dist/test/binding-hints.d.ts +10 -0
  434. package/dist/test/binding-hints.d.ts.map +1 -0
  435. package/dist/test/cf.d.ts +71 -35
  436. package/dist/test/cf.d.ts.map +1 -1
  437. package/dist/test/containers.d.ts +87 -0
  438. package/dist/test/containers.d.ts.map +1 -0
  439. package/dist/test/email.d.ts +16 -7
  440. package/dist/test/email.d.ts.map +1 -1
  441. package/dist/test/index.d.ts +20 -21
  442. package/dist/test/index.d.ts.map +1 -1
  443. package/dist/test/index.js +4981 -70
  444. package/dist/test/offline-bindings.d.ts +115 -0
  445. package/dist/test/offline-bindings.d.ts.map +1 -0
  446. package/dist/test/queue.d.ts.map +1 -1
  447. package/dist/test/remote-ai.d.ts.map +1 -1
  448. package/dist/test/remote-cloudflare.d.ts +13 -0
  449. package/dist/test/remote-cloudflare.d.ts.map +1 -0
  450. package/dist/test/remote-vectorize.d.ts.map +1 -1
  451. package/dist/test/resolve-service-bindings.d.ts +64 -4
  452. package/dist/test/resolve-service-bindings.d.ts.map +1 -1
  453. package/dist/test/scheduled.d.ts.map +1 -1
  454. package/dist/test/should-skip.d.ts +14 -18
  455. package/dist/test/should-skip.d.ts.map +1 -1
  456. package/dist/test/simple-context-bindings.d.ts +13 -0
  457. package/dist/test/simple-context-bindings.d.ts.map +1 -0
  458. package/dist/test/simple-context-durable-objects.d.ts +6 -0
  459. package/dist/test/simple-context-durable-objects.d.ts.map +1 -0
  460. package/dist/test/simple-context-env.d.ts +35 -0
  461. package/dist/test/simple-context-env.d.ts.map +1 -0
  462. package/dist/test/simple-context-gateway-script.d.ts +2 -0
  463. package/dist/test/simple-context-gateway-script.d.ts.map +1 -0
  464. package/dist/test/simple-context-handlers.d.ts +12 -0
  465. package/dist/test/simple-context-handlers.d.ts.map +1 -0
  466. package/dist/test/simple-context-lifecycle.d.ts +32 -0
  467. package/dist/test/simple-context-lifecycle.d.ts.map +1 -0
  468. package/dist/test/simple-context-mfconfig.d.ts +10 -0
  469. package/dist/test/simple-context-mfconfig.d.ts.map +1 -0
  470. package/dist/test/simple-context-multi-worker.d.ts +16 -0
  471. package/dist/test/simple-context-multi-worker.d.ts.map +1 -0
  472. package/dist/test/simple-context-paths.d.ts +40 -0
  473. package/dist/test/simple-context-paths.d.ts.map +1 -0
  474. package/dist/test/simple-context-runtime.d.ts +19 -0
  475. package/dist/test/simple-context-runtime.d.ts.map +1 -0
  476. package/dist/test/simple-context-startup.d.ts +11 -0
  477. package/dist/test/simple-context-startup.d.ts.map +1 -0
  478. package/dist/test/simple-context-transport.d.ts +14 -0
  479. package/dist/test/simple-context-transport.d.ts.map +1 -0
  480. package/dist/test/simple-context.d.ts +8 -27
  481. package/dist/test/simple-context.d.ts.map +1 -1
  482. package/dist/test/tail.d.ts +3 -2
  483. package/dist/test/tail.d.ts.map +1 -1
  484. package/dist/test/utilities/analytics-engine.d.ts +22 -0
  485. package/dist/test/utilities/analytics-engine.d.ts.map +1 -0
  486. package/dist/test/utilities/artifacts.d.ts +11 -0
  487. package/dist/test/utilities/artifacts.d.ts.map +1 -0
  488. package/dist/test/utilities/context.d.ts +39 -0
  489. package/dist/test/utilities/context.d.ts.map +1 -0
  490. package/dist/test/utilities/d1.d.ts +21 -0
  491. package/dist/test/utilities/d1.d.ts.map +1 -0
  492. package/dist/test/utilities/env.d.ts +43 -0
  493. package/dist/test/utilities/env.d.ts.map +1 -0
  494. package/dist/test/utilities/kv.d.ts +11 -0
  495. package/dist/test/utilities/kv.d.ts.map +1 -0
  496. package/dist/test/utilities/media.d.ts +16 -0
  497. package/dist/test/utilities/media.d.ts.map +1 -0
  498. package/dist/test/utilities/platform.d.ts +41 -0
  499. package/dist/test/utilities/platform.d.ts.map +1 -0
  500. package/dist/test/utilities/queue.d.ts +5 -0
  501. package/dist/test/utilities/queue.d.ts.map +1 -0
  502. package/dist/test/utilities/r2.d.ts +2 -0
  503. package/dist/test/utilities/r2.d.ts.map +1 -0
  504. package/dist/test/utilities/stream-flagship.d.ts +27 -0
  505. package/dist/test/utilities/stream-flagship.d.ts.map +1 -0
  506. package/dist/test/utilities/vectorize.d.ts +38 -0
  507. package/dist/test/utilities/vectorize.d.ts.map +1 -0
  508. package/dist/test/utilities/workflows.d.ts +26 -0
  509. package/dist/test/utilities/workflows.d.ts.map +1 -0
  510. package/dist/test/utilities.d.ts +13 -98
  511. package/dist/test/utilities.d.ts.map +1 -1
  512. package/dist/test/worker.d.ts +6 -0
  513. package/dist/test/worker.d.ts.map +1 -1
  514. package/dist/transform/durable-object.d.ts.map +1 -1
  515. package/dist/transform/index.d.ts +2 -2
  516. package/dist/transform/worker-entrypoint.d.ts +5 -0
  517. package/dist/transform/worker-entrypoint.d.ts.map +1 -1
  518. package/dist/utils/entrypoint-discovery.d.ts +6 -3
  519. package/dist/utils/entrypoint-discovery.d.ts.map +1 -1
  520. package/dist/utils/glob.d.ts.map +1 -1
  521. package/dist/utils/resolve-package.d.ts.map +1 -1
  522. package/dist/utils/send-email.d.ts +15 -0
  523. package/dist/utils/send-email.d.ts.map +1 -0
  524. package/dist/utils/send-email.js +163 -0
  525. package/dist/vite/config-file.d.ts +25 -0
  526. package/dist/vite/config-file.d.ts.map +1 -0
  527. package/dist/vite/index.d.ts +3 -2
  528. package/dist/vite/index.d.ts.map +1 -1
  529. package/dist/vite/index.js +2 -339
  530. package/dist/vite/plugin-config-hook.d.ts +28 -0
  531. package/dist/vite/plugin-config-hook.d.ts.map +1 -0
  532. package/dist/vite/plugin-context.d.ts +27 -0
  533. package/dist/vite/plugin-context.d.ts.map +1 -0
  534. package/dist/vite/plugin-durable-objects.d.ts +18 -0
  535. package/dist/vite/plugin-durable-objects.d.ts.map +1 -0
  536. package/dist/vite/plugin-programmatic.d.ts +44 -0
  537. package/dist/vite/plugin-programmatic.d.ts.map +1 -0
  538. package/dist/vite/plugin-service-bindings.d.ts +13 -0
  539. package/dist/vite/plugin-service-bindings.d.ts.map +1 -0
  540. package/dist/vite/plugin-transform.d.ts +41 -0
  541. package/dist/vite/plugin-transform.d.ts.map +1 -0
  542. package/dist/vite/plugin.d.ts +10 -41
  543. package/dist/vite/plugin.d.ts.map +1 -1
  544. package/dist/worker-entry/composed-worker.d.ts +7 -0
  545. package/dist/worker-entry/composed-worker.d.ts.map +1 -0
  546. package/dist/worker-entry/durable-object-discovery.d.ts +20 -0
  547. package/dist/worker-entry/durable-object-discovery.d.ts.map +1 -0
  548. package/dist/worker-entry/extensions.d.ts +5 -0
  549. package/dist/worker-entry/extensions.d.ts.map +1 -0
  550. package/dist/worker-entry/routes.d.ts +22 -0
  551. package/dist/worker-entry/routes.d.ts.map +1 -0
  552. package/dist/worker-entry/surface-paths.d.ts +26 -0
  553. package/dist/worker-entry/surface-paths.d.ts.map +1 -0
  554. package/dist/worker-entry/validate-fetch-style.d.ts +12 -0
  555. package/dist/worker-entry/validate-fetch-style.d.ts.map +1 -0
  556. package/dist/workflows/local-workflow-entrypoints.d.ts +7 -0
  557. package/dist/workflows/local-workflow-entrypoints.d.ts.map +1 -0
  558. package/package.json +159 -116
  559. package/R2.md +0 -170
  560. package/dist/account-rvrj687w.js +0 -397
  561. package/dist/ai-dx4fr9jh.js +0 -107
  562. package/dist/bridge/protocol.d.ts.map +0 -1
  563. package/dist/bridge/serialization.d.ts.map +0 -1
  564. package/dist/browser-shim/worker.d.ts +0 -14
  565. package/dist/browser-shim/worker.d.ts.map +0 -1
  566. package/dist/build-mnf6v8gd.js +0 -53
  567. package/dist/deploy-nhceck39.js +0 -70
  568. package/dist/dev-b9dmrj7b.js +0 -2417
  569. package/dist/doctor-fmgb3d28.js +0 -190
  570. package/dist/durable-object-t4kbb0yt.js +0 -13
  571. package/dist/index-07q6yxyc.js +0 -168
  572. package/dist/index-18hvb6gb.js +0 -194
  573. package/dist/index-1xpj0m4r.js +0 -57
  574. package/dist/index-37x76zdn.js +0 -4
  575. package/dist/index-3t6rypgc.js +0 -13
  576. package/dist/index-67qcae0f.js +0 -183
  577. package/dist/index-a855bdsx.js +0 -18
  578. package/dist/index-d8bdkx2h.js +0 -109
  579. package/dist/index-ep3445yc.js +0 -2225
  580. package/dist/index-gz1gndna.js +0 -307
  581. package/dist/index-hcex3rgh.js +0 -266
  582. package/dist/index-m2q41jwa.js +0 -462
  583. package/dist/index-n7rs26ft.js +0 -77
  584. package/dist/index-pf5s73n9.js +0 -1413
  585. package/dist/index-rbht7m9r.js +0 -36
  586. package/dist/index-tfyxa77h.js +0 -850
  587. package/dist/index-tk6ej9dj.js +0 -94
  588. package/dist/index-z14anrqp.js +0 -226
  589. package/dist/init-f9mgmew3.js +0 -186
  590. package/dist/remote-q59qk463.js +0 -97
  591. package/dist/test/bridge-context.d.ts +0 -76
  592. package/dist/test/bridge-context.d.ts.map +0 -1
  593. package/dist/test/multi-worker-context.d.ts +0 -114
  594. package/dist/test/multi-worker-context.d.ts.map +0 -1
  595. package/dist/types-5nyrz1sz.js +0 -454
  596. package/dist/worker-entrypoint-m9th0rg0.js +0 -13
@@ -0,0 +1,851 @@
1
+ import { d as configSchema } from "./loader-OQ2AWpqm.js";
2
+ import { _ as normalizeSecretsStoreBinding, c as normalizeFlagshipBinding, f as normalizeMediaBinding, g as normalizeR2Binding, h as normalizeQueueProducer, i as normalizeArtifactsBinding, l as normalizeHyperdriveBinding, m as normalizePipelineBinding, n as getLocalKVNamespaceIdentifier, o as normalizeDOBinding, p as normalizeMtlsCertificateBinding, s as normalizeDispatchNamespaceBinding, t as getLocalD1DatabaseIdentifier, u as normalizeImagesBinding, v as normalizeStreamBinding, x as normalizeWorkflowBinding } from "./schema-normalization-GjhTATHL.js";
3
+ import { n as findDurableObjectClasses } from "./durable-object-DMtH0XYX.js";
4
+ import { r as SUPPORTED_WORKER_EXTENSIONS, t as transformWorkerEntrypoint } from "./worker-entrypoint-CQW77lG8.js";
5
+ import { a as findFilesSync, i as findFiles, t as DEFAULT_DO_PATTERN } from "./glob-CmQOvunB.js";
6
+ import { r as discoverEntrypointsSync, t as resolvePackageSpecifier } from "./resolve-package-qizBfCIm.js";
7
+ import { relative, resolve } from "pathe";
8
+ import { existsSync, readFileSync } from "fs";
9
+ import { dirname as dirname$1, join as join$1, resolve as resolve$1 } from "path";
10
+ //#region src/dev-server/miniflare-bindings.ts
11
+ function buildQueueProducers(bindings) {
12
+ if (!bindings.queues?.producers) return;
13
+ const producers = {};
14
+ for (const [bindingName, producer] of Object.entries(bindings.queues.producers)) {
15
+ const normalized = normalizeQueueProducer(producer);
16
+ producers[bindingName] = {
17
+ queueName: normalized.queue,
18
+ ...normalized.deliveryDelay !== void 0 && { deliveryDelay: normalized.deliveryDelay }
19
+ };
20
+ }
21
+ return producers;
22
+ }
23
+ function buildQueueConsumers(bindings) {
24
+ if (!bindings.queues?.consumers || bindings.queues.consumers.length === 0) return;
25
+ const consumers = {};
26
+ for (const consumer of bindings.queues.consumers) consumers[consumer.queue] = {
27
+ ...consumer.maxBatchSize !== void 0 && { maxBatchSize: consumer.maxBatchSize },
28
+ ...consumer.maxBatchTimeout !== void 0 && { maxBatchTimeout: consumer.maxBatchTimeout },
29
+ ...consumer.maxRetries !== void 0 && { maxRetries: consumer.maxRetries },
30
+ ...consumer.deadLetterQueue && { deadLetterQueue: consumer.deadLetterQueue },
31
+ ...consumer.maxConcurrency !== void 0 && { maxConcurrency: consumer.maxConcurrency },
32
+ ...consumer.retryDelay !== void 0 && { retryDelay: consumer.retryDelay }
33
+ };
34
+ return consumers;
35
+ }
36
+ function buildRateLimitsConfig(bindings) {
37
+ if (!bindings.rateLimits) return;
38
+ return Object.fromEntries(Object.entries(bindings.rateLimits).map(([name, binding]) => [name, { simple: {
39
+ limit: binding.simple.limit,
40
+ period: binding.simple.period
41
+ } }]));
42
+ }
43
+ function buildVersionMetadataConfig(bindings) {
44
+ return bindings.versionMetadata?.binding;
45
+ }
46
+ function buildWorkerLoadersConfig(bindings) {
47
+ if (!bindings.workerLoaders) return;
48
+ return Object.fromEntries(Object.keys(bindings.workerLoaders).map((bindingName) => [bindingName, {}]));
49
+ }
50
+ function buildMtlsCertificatesConfig(bindings) {
51
+ if (!bindings.mtlsCertificates) return;
52
+ return Object.fromEntries(Object.entries(bindings.mtlsCertificates).map(([bindingName, binding]) => {
53
+ const normalized = normalizeMtlsCertificateBinding(binding);
54
+ return [bindingName, {
55
+ certificate_id: normalized.certificateId,
56
+ ...normalized.remote !== void 0 && { remote: normalized.remote }
57
+ }];
58
+ }));
59
+ }
60
+ function buildDispatchNamespacesConfig(bindings) {
61
+ if (!bindings.dispatchNamespaces) return;
62
+ return Object.fromEntries(Object.entries(bindings.dispatchNamespaces).map(([bindingName, binding]) => {
63
+ return [bindingName, { namespace: normalizeDispatchNamespaceBinding(binding).namespace }];
64
+ }));
65
+ }
66
+ function buildWorkflowsConfig(bindings) {
67
+ if (!bindings.workflows) return;
68
+ return Object.fromEntries(Object.entries(bindings.workflows).map(([bindingName, binding]) => {
69
+ const normalized = normalizeWorkflowBinding(binding);
70
+ return [bindingName, {
71
+ name: normalized.name,
72
+ className: normalized.className,
73
+ ...normalized.scriptName && { scriptName: normalized.scriptName },
74
+ ...normalized.limits && { stepLimit: normalized.limits.steps }
75
+ }];
76
+ }));
77
+ }
78
+ function buildPipelinesConfig(bindings) {
79
+ if (!bindings.pipelines) return;
80
+ return Object.fromEntries(Object.entries(bindings.pipelines).map(([bindingName, binding]) => {
81
+ const normalized = normalizePipelineBinding(binding);
82
+ return [bindingName, typeof binding === "string" ? normalized.pipeline : { pipeline: normalized.pipeline }];
83
+ }));
84
+ }
85
+ function getHyperdriveLocalConnectionString(bindingName, binding) {
86
+ const cloudflareEnvName = `CLOUDFLARE_HYPERDRIVE_LOCAL_CONNECTION_STRING_${bindingName}`;
87
+ const wranglerEnvName = `WRANGLER_HYPERDRIVE_LOCAL_CONNECTION_STRING_${bindingName}`;
88
+ const envValue = process.env[cloudflareEnvName] ?? process.env[wranglerEnvName];
89
+ if (envValue?.trim()) return envValue;
90
+ return normalizeHyperdriveBinding(binding).localConnectionString;
91
+ }
92
+ function buildHyperdrivesConfig(bindings) {
93
+ if (!bindings.hyperdrive) return;
94
+ const hyperdrives = Object.fromEntries(Object.entries(bindings.hyperdrive).map(([bindingName, binding]) => {
95
+ const localConnectionString = getHyperdriveLocalConnectionString(bindingName, binding);
96
+ return localConnectionString ? [bindingName, localConnectionString] : null;
97
+ }).filter((entry) => entry !== null));
98
+ return Object.keys(hyperdrives).length > 0 ? hyperdrives : void 0;
99
+ }
100
+ function buildImagesConfig(bindings) {
101
+ if (!bindings.images) return;
102
+ const [entry] = Object.entries(bindings.images);
103
+ if (!entry) return;
104
+ const [bindingName, binding] = entry;
105
+ return { binding: normalizeImagesBinding(bindingName, binding).binding };
106
+ }
107
+ function buildMediaConfig(bindings) {
108
+ if (!bindings.media) return;
109
+ const [entry] = Object.entries(bindings.media);
110
+ if (!entry) return;
111
+ const [bindingName, binding] = entry;
112
+ return { binding: normalizeMediaBinding(bindingName, binding).binding };
113
+ }
114
+ function buildStreamConfig(bindings) {
115
+ if (!bindings.stream) return;
116
+ const [entry] = Object.entries(bindings.stream);
117
+ if (!entry) return;
118
+ const [bindingName, binding] = entry;
119
+ return { binding: normalizeStreamBinding(bindingName, binding).binding };
120
+ }
121
+ function buildFlagshipConfig(bindings) {
122
+ if (!bindings.flagship) return;
123
+ return Object.fromEntries(Object.entries(bindings.flagship).map(([bindingName, binding]) => {
124
+ return [bindingName, { app_id: normalizeFlagshipBinding(binding).appId }];
125
+ }));
126
+ }
127
+ function buildAnalyticsEngineConfig(bindings) {
128
+ if (!bindings.analyticsEngine) return;
129
+ return Object.fromEntries(Object.entries(bindings.analyticsEngine).map(([bindingName, binding]) => [bindingName, { dataset: binding.dataset }]));
130
+ }
131
+ function buildArtifactsConfig(bindings) {
132
+ if (!bindings.artifacts) return;
133
+ return Object.fromEntries(Object.entries(bindings.artifacts).map(([bindingName, binding]) => {
134
+ return [bindingName, { namespace: normalizeArtifactsBinding(binding).namespace }];
135
+ }));
136
+ }
137
+ function buildAiSearchNamespacesConfig(bindings) {
138
+ if (!bindings.aiSearchNamespaces) return;
139
+ return Object.fromEntries(Object.entries(bindings.aiSearchNamespaces).map(([bindingName, binding]) => [bindingName, { namespace: binding.namespace }]));
140
+ }
141
+ function buildAiSearchInstancesConfig(bindings) {
142
+ if (!bindings.aiSearch) return;
143
+ return Object.fromEntries(Object.entries(bindings.aiSearch).map(([bindingName, binding]) => [bindingName, { instance_name: binding.instanceName }]));
144
+ }
145
+ function buildSecretsStoreConfig(bindings, defaultSecretsStoreId, excludedBindingNames = /* @__PURE__ */ new Set()) {
146
+ if (!bindings.secretsStore) return;
147
+ const entries = Object.entries(bindings.secretsStore).flatMap(([bindingName, binding]) => {
148
+ if (excludedBindingNames.has(bindingName)) return [];
149
+ const normalized = normalizeSecretsStoreBinding(binding, defaultSecretsStoreId, bindingName);
150
+ return [[bindingName, {
151
+ store_id: normalized.storeId,
152
+ secret_name: normalized.secretName
153
+ }]];
154
+ });
155
+ return entries.length > 0 ? Object.fromEntries(entries) : void 0;
156
+ }
157
+ function buildSendEmailConfig(bindings) {
158
+ if (!bindings.sendEmail) return;
159
+ return { send_email: Object.entries(bindings.sendEmail).map(([name, binding]) => ({
160
+ name,
161
+ ...binding.destinationAddress && { destination_address: binding.destinationAddress },
162
+ ...binding.allowedDestinationAddresses && { allowed_destination_addresses: binding.allowedDestinationAddresses },
163
+ ...binding.allowedSenderAddresses && { allowed_sender_addresses: binding.allowedSenderAddresses },
164
+ ...binding.remote !== void 0 && { remote: binding.remote }
165
+ })) };
166
+ }
167
+ /**
168
+ * Translate the top-level `tailConsumers` config into Miniflare's per-worker
169
+ * `tails` option (an array of service designators). Each tail consumer points
170
+ * at ANOTHER Worker by service name; Miniflare delivers tail events to that
171
+ * Worker only when it is present in the same Miniflare `workers` array. In
172
+ * single-worker local dev the consumer Worker is typically absent, in which
173
+ * case the designator simply resolves to nothing — local delivery degrades
174
+ * cleanly (no crash) and live delivery works only when the consumer Worker is
175
+ * also run locally. The tail *handler* on a Worker is wired separately and is
176
+ * always testable (`cf.tail.trigger()`).
177
+ */
178
+ function buildTailConsumersConfig(config) {
179
+ if (!config.tailConsumers || config.tailConsumers.length === 0) return;
180
+ const tails = config.tailConsumers.map((consumer) => typeof consumer === "string" ? consumer : consumer.service);
181
+ return tails.length > 0 ? tails : void 0;
182
+ }
183
+ /**
184
+ * Translate the top-level `streamingTailConsumers` config into Miniflare's
185
+ * per-worker `streamingTails` option (an array of service designators). This is
186
+ * the streaming twin of {@link buildTailConsumersConfig}; the same
187
+ * present-only-when-the-consumer-Worker-is-run-locally delivery semantics apply.
188
+ */
189
+ function buildStreamingTailConsumersConfig(config) {
190
+ if (!config.streamingTailConsumers || config.streamingTailConsumers.length === 0) return;
191
+ const streamingTails = config.streamingTailConsumers.map((consumer) => typeof consumer === "string" ? consumer : consumer.service);
192
+ return streamingTails.length > 0 ? streamingTails : void 0;
193
+ }
194
+ //#endregion
195
+ //#region src/test/resolve-service-bindings.ts
196
+ function getBunRuntime() {
197
+ const g = globalThis;
198
+ if (typeof g.Bun === "object" && g.Bun !== null) return g.Bun;
199
+ }
200
+ /**
201
+ * Discover DO files matching do.*.ts/js pattern recursively in a directory
202
+ * Uses the same glob pattern as the rest of the codebase for consistency.
203
+ * Returns map of className -> filePath
204
+ */
205
+ function discoverDOFilesSync(dir, pattern = DEFAULT_DO_PATTERN) {
206
+ const classToPath = /* @__PURE__ */ new Map();
207
+ try {
208
+ const files = findFilesSync(pattern, { cwd: dir });
209
+ for (const filePath of files) try {
210
+ const classNames = findDurableObjectClasses(readFileSync(filePath, "utf-8"));
211
+ for (const className of classNames) if (!classToPath.has(className)) classToPath.set(className, filePath);
212
+ } catch {}
213
+ } catch {}
214
+ return classToPath;
215
+ }
216
+ /**
217
+ * Cache for bundled worker scripts to avoid re-bundling in repeated test runs.
218
+ * Key: entryPath + entrypoint, Value: bundled script code
219
+ */
220
+ const bundleCache = /* @__PURE__ */ new Map();
221
+ /**
222
+ * Clear the bundle cache (useful between test suites)
223
+ */
224
+ function clearBundleCache() {
225
+ bundleCache.clear();
226
+ }
227
+ function findDefaultServiceWorkerEntrypoint(refConfigDir) {
228
+ for (const candidate of [
229
+ "worker.ts",
230
+ "worker.js",
231
+ "src/worker.ts",
232
+ "src/worker.js"
233
+ ]) {
234
+ const absolutePath = resolve$1(refConfigDir, candidate);
235
+ if (existsSync(absolutePath)) return absolutePath;
236
+ }
237
+ return null;
238
+ }
239
+ function buildRawServiceBindings(services) {
240
+ if (!services || Object.keys(services).length === 0) return;
241
+ return Object.fromEntries(Object.entries(services).map(([bindingName, binding]) => [bindingName, {
242
+ name: binding.service,
243
+ ...binding.entrypoint && { entrypoint: binding.entrypoint }
244
+ }]));
245
+ }
246
+ function buildReferencedWorkerRuntimeConfig(config) {
247
+ const bindings = config.bindings ?? {};
248
+ const queueProducers = buildQueueProducers(bindings);
249
+ const queueConsumers = buildQueueConsumers(bindings);
250
+ const rateLimits = buildRateLimitsConfig(bindings);
251
+ const versionMetadata = buildVersionMetadataConfig(bindings);
252
+ const workerLoaders = buildWorkerLoadersConfig(bindings);
253
+ const mtlsCertificates = buildMtlsCertificatesConfig(bindings);
254
+ const dispatchNamespaces = buildDispatchNamespacesConfig(bindings);
255
+ const workflows = buildWorkflowsConfig(bindings);
256
+ const pipelines = buildPipelinesConfig(bindings);
257
+ const hyperdrives = buildHyperdrivesConfig(bindings);
258
+ const media = buildMediaConfig(bindings);
259
+ const artifacts = buildArtifactsConfig(bindings);
260
+ const aiSearchNamespaces = buildAiSearchNamespacesConfig(bindings);
261
+ const aiSearchInstances = buildAiSearchInstancesConfig(bindings);
262
+ const secretsStoreSecrets = buildSecretsStoreConfig(bindings, config.secretsStoreId);
263
+ const email = buildSendEmailConfig(bindings);
264
+ const serviceBindings = buildRawServiceBindings(bindings.services);
265
+ return {
266
+ ...config.compatibilityFlags && { compatibilityFlags: config.compatibilityFlags },
267
+ ...config.vars && { bindings: config.vars },
268
+ ...bindings.kv && { kvNamespaces: Object.fromEntries(Object.entries(bindings.kv).map(([bindingName, bindingConfig]) => [bindingName, getLocalKVNamespaceIdentifier(bindingConfig)])) },
269
+ ...bindings.r2 && { r2Buckets: Object.fromEntries(Object.entries(bindings.r2).map(([bindingName, bindingConfig]) => [bindingName, normalizeR2Binding(bindingConfig).bucketName])) },
270
+ ...bindings.d1 && { d1Databases: Object.fromEntries(Object.entries(bindings.d1).map(([bindingName, bindingConfig]) => [bindingName, getLocalD1DatabaseIdentifier(bindingConfig)])) },
271
+ ...queueProducers && { queueProducers },
272
+ ...queueConsumers && { queueConsumers },
273
+ ...rateLimits && { ratelimits: rateLimits },
274
+ ...versionMetadata && { versionMetadata },
275
+ ...workerLoaders && { workerLoaders },
276
+ ...mtlsCertificates && { mtlsCertificates },
277
+ ...dispatchNamespaces && { dispatchNamespaces },
278
+ ...workflows && { workflows },
279
+ ...pipelines && { pipelines },
280
+ ...hyperdrives && { hyperdrives },
281
+ ...media && { media },
282
+ ...artifacts && { artifacts },
283
+ ...aiSearchNamespaces && { aiSearchNamespaces },
284
+ ...aiSearchInstances && { aiSearchInstances },
285
+ ...secretsStoreSecrets && { secretsStoreSecrets },
286
+ ...email && { email },
287
+ ...serviceBindings && { serviceBindings }
288
+ };
289
+ }
290
+ function normalizeReferencedConfig(config) {
291
+ return configSchema.parse(config);
292
+ }
293
+ function resolveReferencedConfigDir(ref, parentConfigDir) {
294
+ const configPath = ref.configPath;
295
+ if (!configPath || configPath === "<resolved>") return null;
296
+ return dirname$1(resolvePackageSpecifier(configPath, parentConfigDir));
297
+ }
298
+ async function resolveReferencedLocalDurableObjects(config, configDir, workerName, serviceBindings = {}) {
299
+ const doPattern = config.files?.durableObjects;
300
+ const dosConfig = config.bindings?.durableObjects;
301
+ if (typeof doPattern !== "string" || !dosConfig || Object.keys(dosConfig).length === 0) return {
302
+ workers: [],
303
+ bindings: {}
304
+ };
305
+ const discoveredDOs = discoverDOFilesSync(configDir, doPattern);
306
+ const doClasses = [];
307
+ for (const [bindingName, rawDoConfig] of Object.entries(dosConfig)) {
308
+ const doConfig = normalizeDOBinding(rawDoConfig);
309
+ if (doConfig.kind !== "local") continue;
310
+ const scriptPath = discoveredDOs.get(doConfig.className);
311
+ if (!scriptPath) {
312
+ console.warn(`[devflare] DO "${bindingName}" (class: ${doConfig.className}) not found in files.durableObjects for "${workerName}"`);
313
+ continue;
314
+ }
315
+ doClasses.push({
316
+ bindingName,
317
+ className: doConfig.className,
318
+ scriptPath
319
+ });
320
+ }
321
+ if (doClasses.length === 0) return {
322
+ workers: [],
323
+ bindings: {}
324
+ };
325
+ const doWorkerName = `${workerName}-durable-objects`;
326
+ const script = await bundleDOClasses(doClasses, doWorkerName);
327
+ if (!script) return {
328
+ workers: [],
329
+ bindings: {}
330
+ };
331
+ const durableObjects = Object.fromEntries(doClasses.map((do_) => [do_.bindingName, do_.className]));
332
+ const runtimeConfig = buildReferencedWorkerRuntimeConfig(config);
333
+ const doRuntimeConfig = { ...runtimeConfig };
334
+ delete doRuntimeConfig.queueConsumers;
335
+ const mergedServiceBindings = {
336
+ ...runtimeConfig.serviceBindings ?? {},
337
+ ...serviceBindings
338
+ };
339
+ return {
340
+ workers: [{
341
+ name: doWorkerName,
342
+ script,
343
+ modules: true,
344
+ compatibilityDate: config.compatibilityDate,
345
+ ...doRuntimeConfig,
346
+ ...Object.keys(mergedServiceBindings).length > 0 && { serviceBindings: mergedServiceBindings },
347
+ durableObjects
348
+ }],
349
+ bindings: Object.fromEntries(doClasses.map((do_) => [do_.bindingName, {
350
+ className: do_.className,
351
+ scriptName: doWorkerName
352
+ }]))
353
+ };
354
+ }
355
+ /**
356
+ * Check if a config has service bindings that need multi-worker setup
357
+ */
358
+ function hasServiceBindings(config) {
359
+ const services = config.bindings?.services;
360
+ if (!services) return false;
361
+ return Object.keys(services).length > 0;
362
+ }
363
+ /**
364
+ * Resolve service bindings from a config
365
+ * Returns the workers array and service bindings for Miniflare setup
366
+ */
367
+ async function resolveServiceBindings(config, configDir, seenWorkers = /* @__PURE__ */ new Set()) {
368
+ const services = config.bindings?.services;
369
+ if (!services) return {
370
+ workers: [],
371
+ primaryServiceBindings: {}
372
+ };
373
+ const workersByName = /* @__PURE__ */ new Map();
374
+ const primaryServiceBindings = {};
375
+ for (const [bindingName, binding] of Object.entries(services)) {
376
+ const workerBinding = binding;
377
+ const ref = workerBinding.__ref;
378
+ if (ref) {
379
+ if ("__import" in ref && typeof ref.__import === "function") await ref.resolve();
380
+ const workerName = ref.name;
381
+ const entrypoint = workerBinding.entrypoint;
382
+ if (!workersByName.has(workerName) && !seenWorkers.has(workerName)) {
383
+ const refConfig = normalizeReferencedConfig(ref.config);
384
+ const worker = await resolveRefWorker(ref, entrypoint, configDir, refConfig);
385
+ if (worker) {
386
+ const refConfigDir = resolveReferencedConfigDir(ref, configDir);
387
+ if (ref.config && refConfigDir) {
388
+ const nested = await resolveServiceBindings(refConfig, refConfigDir, new Set([...seenWorkers, workerName]));
389
+ worker.serviceBindings = {
390
+ ...worker.serviceBindings ?? {},
391
+ ...nested.primaryServiceBindings
392
+ };
393
+ for (const nestedWorker of nested.workers) if (!workersByName.has(nestedWorker.name)) workersByName.set(nestedWorker.name, nestedWorker);
394
+ const localDOs = await resolveReferencedLocalDurableObjects(refConfig, refConfigDir, workerName, nested.primaryServiceBindings);
395
+ worker.durableObjects = {
396
+ ...worker.durableObjects ?? {},
397
+ ...localDOs.bindings
398
+ };
399
+ for (const doWorker of localDOs.workers) if (!workersByName.has(doWorker.name)) workersByName.set(doWorker.name, doWorker);
400
+ }
401
+ workersByName.set(workerName, worker);
402
+ }
403
+ }
404
+ primaryServiceBindings[bindingName] = {
405
+ name: workerName,
406
+ ...entrypoint && { entrypoint }
407
+ };
408
+ } else primaryServiceBindings[bindingName] = {
409
+ name: workerBinding.service,
410
+ ...workerBinding.entrypoint && { entrypoint: workerBinding.entrypoint }
411
+ };
412
+ }
413
+ return {
414
+ workers: [...workersByName.values()],
415
+ primaryServiceBindings
416
+ };
417
+ }
418
+ /**
419
+ * Resolve a referenced worker config to a bundled script.
420
+ * Bundles the default `worker.{ts,js}` (root) or `src/worker.{ts,js}` RPC
421
+ * surface plus any named entrypoints discovered from `files.entrypoints` into a
422
+ * single script.
423
+ */
424
+ async function resolveRefWorker(ref, _entrypoint, parentConfigDir, resolvedConfig) {
425
+ const config = resolvedConfig ?? normalizeReferencedConfig(ref.config);
426
+ if (!config) return null;
427
+ const refConfigDir = resolveReferencedConfigDir(ref, parentConfigDir);
428
+ if (!refConfigDir) {
429
+ console.warn(`[devflare] Cannot resolve worker "${ref.name}" - configPath not available`);
430
+ return null;
431
+ }
432
+ const entrypoints = [];
433
+ const workerEntrypointPath = findDefaultServiceWorkerEntrypoint(refConfigDir);
434
+ if (workerEntrypointPath) entrypoints.push({
435
+ path: workerEntrypointPath,
436
+ className: "Worker",
437
+ isWorkerTs: true
438
+ });
439
+ if (config.files?.entrypoints !== false) {
440
+ const discoveredEntrypoints = discoverEntrypointsSync(refConfigDir, typeof config.files?.entrypoints === "string" ? config.files.entrypoints : void 0);
441
+ for (const ep of discoveredEntrypoints) entrypoints.push({
442
+ path: ep.filePath,
443
+ className: ep.className,
444
+ isWorkerTs: false
445
+ });
446
+ }
447
+ if (entrypoints.length === 0) {
448
+ console.warn(`[devflare] Worker "${ref.name}" has no entry points`);
449
+ return null;
450
+ }
451
+ const script = await bundleAllEntrypoints(entrypoints, ref.name);
452
+ if (!script) return null;
453
+ return {
454
+ name: ref.name,
455
+ script,
456
+ modules: true,
457
+ compatibilityDate: config.compatibilityDate ?? "2025-01-01",
458
+ ...buildReferencedWorkerRuntimeConfig(config)
459
+ };
460
+ }
461
+ /**
462
+ * Bundle multiple entrypoints into a single worker script
463
+ */
464
+ async function bundleAllEntrypoints(entrypoints, workerName) {
465
+ const cacheKey = entrypoints.map((ep) => `${ep.path}::${ep.className}`).join("|");
466
+ const cached = bundleCache.get(cacheKey);
467
+ if (cached) return cached;
468
+ const bun = getBunRuntime();
469
+ if (!bun) {
470
+ console.warn(`[devflare] Cannot bundle service worker "${workerName}" — the Bun runtime is required to bundle worker scripts, but this process is not running under Bun. The service binding will be left unresolved. Run your tests with \`bun test\` (or the devflare test runner) to enable multi-worker service bindings.`);
471
+ return null;
472
+ }
473
+ try {
474
+ const { readFileSync, writeFileSync, mkdirSync, unlinkSync } = await import("fs");
475
+ const imports = [];
476
+ const exports = [];
477
+ let defaultExportClass = null;
478
+ for (let i = 0; i < entrypoints.length; i++) {
479
+ const ep = entrypoints[i];
480
+ const sourceCode = readFileSync(ep.path, "utf-8");
481
+ if (ep.isWorkerTs) {
482
+ const result = transformWorkerEntrypoint(sourceCode, ep.path, {
483
+ className: ep.className,
484
+ injectContext: false
485
+ });
486
+ if (result) {
487
+ const tempDir = join$1(dirname$1(ep.path), ".devflare");
488
+ mkdirSync(tempDir, { recursive: true });
489
+ const tempPath = join$1(tempDir, `__${ep.className}_${i}.ts`);
490
+ writeFileSync(tempPath, result.code);
491
+ imports.push(`import { ${ep.className} } from '${tempPath.replace(/\\/g, "/")}'`);
492
+ exports.push(ep.className);
493
+ if (!defaultExportClass) defaultExportClass = ep.className;
494
+ }
495
+ } else {
496
+ imports.push(`import { ${ep.className} } from '${ep.path.replace(/\\/g, "/")}'`);
497
+ exports.push(ep.className);
498
+ }
499
+ }
500
+ const defaultExport = defaultExportClass ? `\nexport default ${defaultExportClass}` : "";
501
+ const entryCode = `
502
+ ${imports.join("\n")}
503
+ export { ${exports.join(", ")} }${defaultExport}
504
+ `;
505
+ const tempDir = join$1(dirname$1(entrypoints[0].path), ".devflare");
506
+ mkdirSync(tempDir, { recursive: true });
507
+ const entryPath = join$1(tempDir, `__entry_${workerName}.ts`);
508
+ writeFileSync(entryPath, entryCode);
509
+ try {
510
+ const result = await bun.build({
511
+ entrypoints: [entryPath],
512
+ target: "browser",
513
+ format: "esm",
514
+ minify: false,
515
+ external: ["cloudflare:workers", "cloudflare:*"]
516
+ });
517
+ if (!result.success) {
518
+ console.warn(`[devflare] Failed to bundle worker "${workerName}": ${result.logs.join("\n")}`);
519
+ return null;
520
+ }
521
+ const bundledCode = await result.outputs[0].text();
522
+ bundleCache.set(cacheKey, bundledCode);
523
+ return bundledCode;
524
+ } finally {
525
+ try {
526
+ unlinkSync(entryPath);
527
+ } catch {}
528
+ }
529
+ } catch (error) {
530
+ console.warn(`[devflare] Error bundling worker "${workerName}":`, error);
531
+ return null;
532
+ }
533
+ }
534
+ /**
535
+ * Check if a config has cross-worker DO bindings
536
+ */
537
+ function hasCrossWorkerDOs(config) {
538
+ const dos = config.bindings?.durableObjects;
539
+ if (!dos) return false;
540
+ for (const doConfig of Object.values(dos)) if (normalizeDOBinding(doConfig).__ref) return true;
541
+ return false;
542
+ }
543
+ /**
544
+ * Resolve cross-worker DO bindings
545
+ * Returns workers to set up and DO bindings for the primary worker
546
+ */
547
+ async function resolveDOBindings(config, configDir) {
548
+ const dos = config.bindings?.durableObjects;
549
+ if (!dos) return {
550
+ workers: [],
551
+ crossWorkerDOBindings: {}
552
+ };
553
+ const workersByName = /* @__PURE__ */ new Map();
554
+ const crossWorkerDOBindings = {};
555
+ for (const [bindingName, rawDoConfig] of Object.entries(dos)) {
556
+ if (!(typeof rawDoConfig === "object" && "__ref" in rawDoConfig)) continue;
557
+ const ref = rawDoConfig.__ref;
558
+ if ("__import" in ref && typeof ref.__import === "function") await ref.resolve();
559
+ const doConfig = normalizeDOBinding(rawDoConfig);
560
+ const workerName = ref.name;
561
+ if (!workersByName.has(workerName)) {
562
+ const worker = await resolveDORefWorker(ref, configDir);
563
+ if (worker) workersByName.set(workerName, worker);
564
+ }
565
+ crossWorkerDOBindings[bindingName] = {
566
+ className: doConfig.className,
567
+ scriptName: workerName
568
+ };
569
+ }
570
+ return {
571
+ workers: [...workersByName.values()],
572
+ crossWorkerDOBindings
573
+ };
574
+ }
575
+ /**
576
+ * Resolve a referenced worker for DO hosting
577
+ * Bundles the DO classes with RPC wrappers
578
+ */
579
+ async function resolveDORefWorker(ref, parentConfigDir) {
580
+ const config = ref.config;
581
+ if (!config) return null;
582
+ const configPath = ref.configPath;
583
+ if (!configPath || configPath === "<resolved>") {
584
+ console.warn(`[devflare] Cannot resolve DO worker "${ref.name}" - configPath not available`);
585
+ return null;
586
+ }
587
+ const refConfigDir = dirname$1(resolvePackageSpecifier(configPath, parentConfigDir));
588
+ const dosConfig = config.bindings?.durableObjects;
589
+ if (!dosConfig || Object.keys(dosConfig).length === 0) {
590
+ console.warn(`[devflare] Referenced worker "${ref.name}" has no Durable Objects`);
591
+ return null;
592
+ }
593
+ const discoveredDOs = discoverDOFilesSync(refConfigDir);
594
+ const doClasses = [];
595
+ for (const [bindingName, rawDoConfig] of Object.entries(dosConfig)) {
596
+ const doConfig = normalizeDOBinding(rawDoConfig);
597
+ const className = doConfig.className;
598
+ const scriptName = doConfig.scriptName;
599
+ if (scriptName) {
600
+ const scriptPath = resolve$1(refConfigDir, "src", scriptName);
601
+ if (!existsSync(scriptPath)) {
602
+ const altPath = resolve$1(refConfigDir, scriptName);
603
+ if (!existsSync(altPath)) {
604
+ console.warn(`[devflare] DO script not found: ${scriptPath} or ${altPath}`);
605
+ continue;
606
+ }
607
+ doClasses.push({
608
+ bindingName,
609
+ className,
610
+ scriptPath: altPath
611
+ });
612
+ } else doClasses.push({
613
+ bindingName,
614
+ className,
615
+ scriptPath
616
+ });
617
+ } else {
618
+ const discoveredPath = discoveredDOs.get(className);
619
+ if (discoveredPath) doClasses.push({
620
+ bindingName,
621
+ className,
622
+ scriptPath: discoveredPath
623
+ });
624
+ else console.warn(`[devflare] DO "${bindingName}" (class: ${className}) not found in do.*.ts files in "${ref.name}"`);
625
+ }
626
+ }
627
+ if (doClasses.length === 0) {
628
+ console.warn(`[devflare] No valid DO classes found in "${ref.name}"`);
629
+ return null;
630
+ }
631
+ const script = await bundleDOClasses(doClasses, ref.name);
632
+ if (!script) return null;
633
+ const durableObjects = {};
634
+ for (const do_ of doClasses) durableObjects[do_.bindingName] = do_.className;
635
+ return {
636
+ name: ref.name,
637
+ script,
638
+ modules: true,
639
+ compatibilityDate: config.compatibilityDate ?? "2025-01-01",
640
+ durableObjects
641
+ };
642
+ }
643
+ /**
644
+ * Bundle DO classes with RPC wrappers for Miniflare
645
+ */
646
+ async function bundleDOClasses(doClasses, workerName) {
647
+ const cacheKey = `do:${doClasses.map((d) => `${d.scriptPath}::${d.className}`).join("|")}`;
648
+ const cached = bundleCache.get(cacheKey);
649
+ if (cached) return cached;
650
+ const bun = getBunRuntime();
651
+ if (!bun) {
652
+ console.warn(`[devflare] Cannot bundle Durable Object worker "${workerName}" — the Bun runtime is required to bundle DO classes, but this process is not running under Bun. The Durable Object binding will be left unresolved. Run your tests with \`bun test\` (or the devflare test runner) to enable cross-worker Durable Objects.`);
653
+ return null;
654
+ }
655
+ try {
656
+ const { writeFileSync, mkdirSync, unlinkSync } = await import("fs");
657
+ const entryCode = `
658
+ ${doClasses.map((d) => `import { ${d.className} } from '${d.scriptPath.replace(/\\/g, "/")}'`).join("\n")}
659
+
660
+ // Re-export DO classes for Miniflare binding
661
+ export { ${doClasses.map((d) => d.className).join(", ")} }
662
+
663
+ // Default export with fetch handler
664
+ export default {
665
+ async fetch(request, env) {
666
+ return new Response('DO Worker: ${workerName}')
667
+ }
668
+ }
669
+ `;
670
+ const tempDir = join$1(dirname$1(doClasses[0].scriptPath), ".devflare");
671
+ mkdirSync(tempDir, { recursive: true });
672
+ const entryPath = join$1(tempDir, `__do_entry_${workerName}.ts`);
673
+ writeFileSync(entryPath, entryCode);
674
+ try {
675
+ const result = await bun.build({
676
+ entrypoints: [entryPath],
677
+ target: "browser",
678
+ format: "esm",
679
+ minify: false,
680
+ external: ["cloudflare:workers", "cloudflare:*"]
681
+ });
682
+ if (!result.success) {
683
+ console.warn(`[devflare] Failed to bundle DO worker "${workerName}": ${result.logs.join("\n")}`);
684
+ return null;
685
+ }
686
+ const bundledCode = await result.outputs[0].text();
687
+ bundleCache.set(cacheKey, bundledCode);
688
+ return bundledCode;
689
+ } finally {
690
+ try {
691
+ unlinkSync(entryPath);
692
+ } catch {}
693
+ }
694
+ } catch (error) {
695
+ console.warn(`[devflare] Error bundling DO worker "${workerName}":`, error);
696
+ return null;
697
+ }
698
+ }
699
+ const DEFAULT_ROUTE_FILE_PATTERNS = SUPPORTED_WORKER_EXTENSIONS.map((ext) => `**/*${ext}`);
700
+ function normalizeRoutePrefix(prefix) {
701
+ if (!prefix || prefix === "/") return "";
702
+ return (prefix.startsWith("/") ? prefix : `/${prefix}`).replace(/\/+$/g, "");
703
+ }
704
+ function createStaticSegmentsFromPrefix(prefix) {
705
+ if (!prefix) return [];
706
+ return prefix.split("/").filter(Boolean).map((value) => ({
707
+ type: "static",
708
+ value
709
+ }));
710
+ }
711
+ function shouldIgnoreRouteFile(relativePath) {
712
+ return relativePath.split("/").some((segment) => segment.startsWith("_"));
713
+ }
714
+ function toRoutePath(segments) {
715
+ if (segments.length === 0) return "/";
716
+ return `/${segments.map((segment) => {
717
+ if (segment.type === "static") return segment.value;
718
+ if (segment.type === "param") return `[${segment.name}]`;
719
+ if (segment.type === "rest") return `[...${segment.name}]`;
720
+ return `[[...${segment.name}]]`;
721
+ }).join("/")}`;
722
+ }
723
+ function getRouteSignature(segments) {
724
+ if (segments.length === 0) return "/";
725
+ return segments.map((segment) => {
726
+ if (segment.type === "static") return `static:${segment.value}`;
727
+ if (segment.type === "param") return "param";
728
+ if (segment.type === "rest") return "rest";
729
+ return "optional-rest";
730
+ }).join("/");
731
+ }
732
+ function getSegmentPriority(segment) {
733
+ if (segment.type === "static") return 4;
734
+ if (segment.type === "param") return 3;
735
+ if (segment.type === "rest") return 1;
736
+ return 0;
737
+ }
738
+ function compareRoutes(a, b) {
739
+ const maxLength = Math.max(a.segments.length, b.segments.length);
740
+ for (let index = 0; index < maxLength; index += 1) {
741
+ const left = a.segments[index];
742
+ const right = b.segments[index];
743
+ if (!left && !right) break;
744
+ if (!left) return 1;
745
+ if (!right) return -1;
746
+ const priorityDifference = getSegmentPriority(right) - getSegmentPriority(left);
747
+ if (priorityDifference !== 0) return priorityDifference;
748
+ if (left.type === "static" && right.type === "static") {
749
+ const lexicalDifference = left.value.localeCompare(right.value);
750
+ if (lexicalDifference !== 0) return lexicalDifference;
751
+ }
752
+ }
753
+ return a.filePath.localeCompare(b.filePath);
754
+ }
755
+ function parseRouteSegments(relativePath, prefixSegments) {
756
+ const rawSegments = relativePath.replace(/\.[^.]+$/u, "").split("/").filter(Boolean);
757
+ const routeSegments = [...prefixSegments];
758
+ for (let index = 0; index < rawSegments.length; index += 1) {
759
+ const segment = rawSegments[index];
760
+ const isLastSegment = index === rawSegments.length - 1;
761
+ if (segment === "index" && isLastSegment) continue;
762
+ const optionalRestMatch = segment.match(/^\[\[\.\.\.(.+)\]\]$/u);
763
+ if (optionalRestMatch) {
764
+ if (!isLastSegment) throw new Error(`Optional rest segment must be the final segment: ${relativePath}`);
765
+ routeSegments.push({
766
+ type: "optional-rest",
767
+ name: optionalRestMatch[1]
768
+ });
769
+ continue;
770
+ }
771
+ const restMatch = segment.match(/^\[\.\.\.(.+)\]$/u);
772
+ if (restMatch) {
773
+ if (!isLastSegment) throw new Error(`Rest segment must be the final segment: ${relativePath}`);
774
+ routeSegments.push({
775
+ type: "rest",
776
+ name: restMatch[1]
777
+ });
778
+ continue;
779
+ }
780
+ const dynamicMatch = segment.match(/^\[(.+)\]$/u);
781
+ if (dynamicMatch) {
782
+ routeSegments.push({
783
+ type: "param",
784
+ name: dynamicMatch[1]
785
+ });
786
+ continue;
787
+ }
788
+ routeSegments.push({
789
+ type: "static",
790
+ value: segment
791
+ });
792
+ }
793
+ return routeSegments;
794
+ }
795
+ async function directoryExists(dirPath) {
796
+ const fs = await import("node:fs/promises");
797
+ try {
798
+ return (await fs.stat(dirPath)).isDirectory();
799
+ } catch {
800
+ return false;
801
+ }
802
+ }
803
+ function getRouteDirectoryCandidate(cwd, config) {
804
+ const routesConfig = config.files?.routes;
805
+ if (routesConfig === false) return null;
806
+ const dir = routesConfig?.dir ?? "src/routes";
807
+ return {
808
+ dir,
809
+ absoluteDir: resolve(cwd, dir),
810
+ prefix: normalizeRoutePrefix(routesConfig?.prefix)
811
+ };
812
+ }
813
+ async function discoverRoutes(cwd, config) {
814
+ const routeDirectory = getRouteDirectoryCandidate(cwd, config);
815
+ if (!routeDirectory) return null;
816
+ if (!await directoryExists(routeDirectory.absoluteDir)) return null;
817
+ const prefixSegments = createStaticSegmentsFromPrefix(routeDirectory.prefix);
818
+ const files = await findFiles(DEFAULT_ROUTE_FILE_PATTERNS, {
819
+ cwd: routeDirectory.absoluteDir,
820
+ absolute: true
821
+ });
822
+ const discoveredRoutes = [];
823
+ const routeSignatures = /* @__PURE__ */ new Map();
824
+ for (const absolutePath of files) {
825
+ const relativeToRouteDir = relative(routeDirectory.absoluteDir, absolutePath).replace(/\\/g, "/");
826
+ if (shouldIgnoreRouteFile(relativeToRouteDir)) continue;
827
+ const segments = parseRouteSegments(relativeToRouteDir, prefixSegments);
828
+ const routePath = toRoutePath(segments);
829
+ const filePath = relative(cwd, absolutePath).replace(/\\/g, "/");
830
+ const signature = getRouteSignature(segments);
831
+ const existingFilePath = routeSignatures.get(signature);
832
+ if (existingFilePath) throw new Error(`Conflicting file routes detected for "${routePath}". Both "${existingFilePath}" and "${filePath}" resolve to the same route.`);
833
+ routeSignatures.set(signature, filePath);
834
+ discoveredRoutes.push({
835
+ absolutePath,
836
+ filePath,
837
+ routePath,
838
+ segments
839
+ });
840
+ }
841
+ if (discoveredRoutes.length === 0) return null;
842
+ discoveredRoutes.sort(compareRoutes);
843
+ return {
844
+ dir: routeDirectory.dir,
845
+ absoluteDir: routeDirectory.absoluteDir,
846
+ prefix: routeDirectory.prefix,
847
+ routes: discoveredRoutes
848
+ };
849
+ }
850
+ //#endregion
851
+ export { buildSendEmailConfig as C, buildVersionMetadataConfig as D, buildTailConsumersConfig as E, buildWorkerLoadersConfig as O, buildSecretsStoreConfig as S, buildStreamingTailConsumersConfig as T, buildMtlsCertificatesConfig as _, hasServiceBindings as a, buildQueueProducers as b, buildAiSearchInstancesConfig as c, buildArtifactsConfig as d, buildDispatchNamespacesConfig as f, buildMediaConfig as g, buildImagesConfig as h, hasCrossWorkerDOs as i, buildWorkflowsConfig as k, buildAiSearchNamespacesConfig as l, buildHyperdrivesConfig as m, getRouteDirectoryCandidate as n, resolveDOBindings as o, buildFlagshipConfig as p, clearBundleCache as r, resolveServiceBindings as s, discoverRoutes as t, buildAnalyticsEngineConfig as u, buildPipelinesConfig as v, buildStreamConfig as w, buildRateLimitsConfig as x, buildQueueConsumers as y };