devflare 1.0.0-next.4 → 1.0.0-next.40

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