devflare 1.0.0-next.2 → 1.0.0-next.20

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 (1411) hide show
  1. package/LLM.md +15738 -1751
  2. package/README.md +375 -605
  3. package/bin/devflare.js +14 -4
  4. package/dist/account-05zgta47.js +475 -0
  5. package/dist/account-0evqkmnc.js +475 -0
  6. package/dist/account-0v11zbzk.js +475 -0
  7. package/dist/account-2w85efas.js +475 -0
  8. package/dist/account-61gw9s7t.js +475 -0
  9. package/dist/account-65sk9q34.js +475 -0
  10. package/dist/account-77vx7q2f.js +475 -0
  11. package/dist/account-7z38mgqf.js +475 -0
  12. package/dist/account-8wgprpbt.js +475 -0
  13. package/dist/account-9gt3tej1.js +475 -0
  14. package/dist/account-b2ag1esh.js +475 -0
  15. package/dist/account-bxtcz61a.js +475 -0
  16. package/dist/account-d43d1eqs.js +475 -0
  17. package/dist/account-dtndtbad.js +475 -0
  18. package/dist/account-e95v7f4s.js +475 -0
  19. package/dist/account-fbyyptg7.js +475 -0
  20. package/dist/account-gnzhz1c9.js +475 -0
  21. package/dist/account-gyfqg964.js +475 -0
  22. package/dist/account-m6jq6fnp.js +475 -0
  23. package/dist/account-mvnfagh9.js +475 -0
  24. package/dist/account-p0crq2gh.js +475 -0
  25. package/dist/account-q6pvs9d9.js +475 -0
  26. package/dist/account-qkcevx7a.js +475 -0
  27. package/dist/account-rp4zbvw1.js +475 -0
  28. package/dist/account-txwqg1rx.js +475 -0
  29. package/dist/account-w5n5bjh2.js +475 -0
  30. package/dist/account-zd61t0ey.js +475 -0
  31. package/dist/api-11gkk043.js +33 -0
  32. package/dist/api-2n6dd2ws.js +33 -0
  33. package/dist/api-dbxvch9h.js +33 -0
  34. package/dist/api-p9hf69kr.js +33 -0
  35. package/dist/api-r10j00ev.js +33 -0
  36. package/dist/api-senf2569.js +33 -0
  37. package/dist/api-swcgnp72.js +33 -0
  38. package/dist/api-th82mps4.js +27 -0
  39. package/dist/bridge/client.d.ts +34 -6
  40. package/dist/bridge/client.d.ts.map +1 -1
  41. package/dist/bridge/gateway-runtime.d.ts +8 -0
  42. package/dist/bridge/gateway-runtime.d.ts.map +1 -0
  43. package/dist/bridge/index.d.ts +3 -3
  44. package/dist/bridge/index.d.ts.map +1 -1
  45. package/dist/bridge/log.d.ts +5 -0
  46. package/dist/bridge/log.d.ts.map +1 -0
  47. package/dist/bridge/miniflare.d.ts +73 -0
  48. package/dist/bridge/miniflare.d.ts.map +1 -1
  49. package/dist/bridge/protocol.d.ts +1 -1
  50. package/dist/bridge/protocol.d.ts.map +1 -1
  51. package/dist/bridge/proxy.d.ts +9 -11
  52. package/dist/bridge/proxy.d.ts.map +1 -1
  53. package/dist/bridge/serialization.d.ts +36 -16
  54. package/dist/bridge/serialization.d.ts.map +1 -1
  55. package/dist/bridge/server.d.ts +2 -1
  56. package/dist/bridge/server.d.ts.map +1 -1
  57. package/dist/bridge/v2/body-streams.d.ts +53 -0
  58. package/dist/bridge/v2/body-streams.d.ts.map +1 -0
  59. package/dist/bridge/v2/codec.d.ts +106 -0
  60. package/dist/bridge/v2/codec.d.ts.map +1 -0
  61. package/dist/bridge/v2/control-messages.d.ts +51 -0
  62. package/dist/bridge/v2/control-messages.d.ts.map +1 -0
  63. package/dist/bridge/v2/frames.d.ts +109 -0
  64. package/dist/bridge/v2/frames.d.ts.map +1 -0
  65. package/dist/bridge/v2/index.d.ts +11 -0
  66. package/dist/bridge/v2/index.d.ts.map +1 -0
  67. package/dist/bridge/v2/legacy-protocol.d.ts +146 -0
  68. package/dist/bridge/v2/legacy-protocol.d.ts.map +1 -0
  69. package/dist/bridge/v2/legacy-serialization.d.ts +103 -0
  70. package/dist/bridge/v2/legacy-serialization.d.ts.map +1 -0
  71. package/dist/bridge/v2/serialization.d.ts +48 -0
  72. package/dist/bridge/v2/serialization.d.ts.map +1 -0
  73. package/dist/bridge/v2/transport.d.ts +31 -0
  74. package/dist/bridge/v2/transport.d.ts.map +1 -0
  75. package/dist/bridge/v2/value-codec.d.ts +61 -0
  76. package/dist/bridge/v2/value-codec.d.ts.map +1 -0
  77. package/dist/bridge/v2/value-serialization.d.ts +103 -0
  78. package/dist/bridge/v2/value-serialization.d.ts.map +1 -0
  79. package/dist/bridge/v2/wire.d.ts +170 -0
  80. package/dist/bridge/v2/wire.d.ts.map +1 -0
  81. package/dist/bridge/v2/ws-relay.d.ts +53 -0
  82. package/dist/bridge/v2/ws-relay.d.ts.map +1 -0
  83. package/dist/browser-shim/handler.d.ts +1 -1
  84. package/dist/browser-shim/handler.d.ts.map +1 -1
  85. package/dist/browser-shim/server.d.ts +63 -0
  86. package/dist/browser-shim/server.d.ts.map +1 -1
  87. package/dist/browser.d.ts +4505 -0
  88. package/dist/browser.d.ts.map +1 -0
  89. package/dist/browser.js +145 -0
  90. package/dist/build-07mjrvsn.js +53 -0
  91. package/dist/build-0rfr8k1s.js +53 -0
  92. package/dist/build-1313sg73.js +52 -0
  93. package/dist/build-1hnntbks.js +53 -0
  94. package/dist/build-1r3myv0k.js +53 -0
  95. package/dist/build-28561w5v.js +54 -0
  96. package/dist/build-2s5paw5p.js +54 -0
  97. package/dist/build-4c350cp7.js +54 -0
  98. package/dist/build-50yqpwb3.js +54 -0
  99. package/dist/build-55z8psd6.js +53 -0
  100. package/dist/build-5b9wj2p0.js +53 -0
  101. package/dist/build-5frhzh1m.js +53 -0
  102. package/dist/build-6ye9vnab.js +52 -0
  103. package/dist/build-8gv18jrq.js +52 -0
  104. package/dist/build-9bgqypy6.js +53 -0
  105. package/dist/build-9em4ymqn.js +52 -0
  106. package/dist/build-e7wym63t.js +54 -0
  107. package/dist/build-eh3x12qc.js +52 -0
  108. package/dist/build-emhyycp7.js +53 -0
  109. package/dist/build-f1m9jn7b.js +53 -0
  110. package/dist/build-ffe72jjv.js +54 -0
  111. package/dist/build-fx90y6za.js +53 -0
  112. package/dist/build-ge6qp3t4.js +54 -0
  113. package/dist/build-h31egsze.js +53 -0
  114. package/dist/build-hpczwagb.js +53 -0
  115. package/dist/build-hpkbanpw.js +54 -0
  116. package/dist/build-j2re91xe.js +54 -0
  117. package/dist/build-j78389rg.js +52 -0
  118. package/dist/build-m3kckn5g.js +53 -0
  119. package/dist/build-mf3thcjm.js +53 -0
  120. package/dist/build-n3n5bv37.js +52 -0
  121. package/dist/build-ngfy4v5x.js +53 -0
  122. package/dist/build-pr843h0d.js +52 -0
  123. package/dist/build-qyg2b45p.js +52 -0
  124. package/dist/build-r6884kyt.js +53 -0
  125. package/dist/build-re370wkf.js +53 -0
  126. package/dist/build-ta8c6t11.js +54 -0
  127. package/dist/build-vvndgwg0.js +52 -0
  128. package/dist/build-wp559jkf.js +54 -0
  129. package/dist/build-wvjj8f28.js +54 -0
  130. package/dist/build-x4r67275.js +52 -0
  131. package/dist/build-xp4pfhvv.js +52 -0
  132. package/dist/build-y489r2h9.js +54 -0
  133. package/dist/build-y6g4bvx5.js +52 -0
  134. package/dist/build-ypg6f2kw.js +54 -0
  135. package/dist/build-yts8wwgf.js +54 -0
  136. package/dist/build-yvn0yhwx.js +52 -0
  137. package/dist/build-yzkdqexs.js +54 -0
  138. package/dist/build-z4vmhs5c.js +53 -0
  139. package/dist/bundler/defaults.d.ts +23 -0
  140. package/dist/bundler/defaults.d.ts.map +1 -0
  141. package/dist/bundler/do-bundler.d.ts +7 -0
  142. package/dist/bundler/do-bundler.d.ts.map +1 -1
  143. package/dist/bundler/index.d.ts +2 -0
  144. package/dist/bundler/index.d.ts.map +1 -1
  145. package/dist/bundler/rolldown-shared.d.ts +53 -0
  146. package/dist/bundler/rolldown-shared.d.ts.map +1 -0
  147. package/dist/bundler/worker-bundler.d.ts +13 -0
  148. package/dist/bundler/worker-bundler.d.ts.map +1 -0
  149. package/dist/bundler/worker-compat.d.ts +4 -0
  150. package/dist/bundler/worker-compat.d.ts.map +1 -0
  151. package/dist/cli/build-manifest.d.ts +66 -0
  152. package/dist/cli/build-manifest.d.ts.map +1 -0
  153. package/dist/cli/command-utils.d.ts +18 -0
  154. package/dist/cli/command-utils.d.ts.map +1 -0
  155. package/dist/cli/commands/account.d.ts +1 -1
  156. package/dist/cli/commands/account.d.ts.map +1 -1
  157. package/dist/cli/commands/build-artifacts.d.ts +40 -0
  158. package/dist/cli/commands/build-artifacts.d.ts.map +1 -0
  159. package/dist/cli/commands/build.d.ts.map +1 -1
  160. package/dist/cli/commands/config.d.ts +4 -0
  161. package/dist/cli/commands/config.d.ts.map +1 -0
  162. package/dist/cli/commands/deploy/metadata.d.ts +18 -0
  163. package/dist/cli/commands/deploy/metadata.d.ts.map +1 -0
  164. package/dist/cli/commands/deploy/prepare.d.ts +23 -0
  165. package/dist/cli/commands/deploy/prepare.d.ts.map +1 -0
  166. package/dist/cli/commands/deploy/runtime.d.ts +4 -0
  167. package/dist/cli/commands/deploy/runtime.d.ts.map +1 -0
  168. package/dist/cli/commands/deploy/verification.d.ts +36 -0
  169. package/dist/cli/commands/deploy/verification.d.ts.map +1 -0
  170. package/dist/cli/commands/deploy.d.ts +2 -2
  171. package/dist/cli/commands/deploy.d.ts.map +1 -1
  172. package/dist/cli/commands/dev.d.ts.map +1 -1
  173. package/dist/cli/commands/doctor.d.ts.map +1 -1
  174. package/dist/cli/commands/init.d.ts.map +1 -1
  175. package/dist/cli/commands/login.d.ts +4 -0
  176. package/dist/cli/commands/login.d.ts.map +1 -0
  177. package/dist/cli/commands/previews-support/cleanup.d.ts +9 -0
  178. package/dist/cli/commands/previews-support/cleanup.d.ts.map +1 -0
  179. package/dist/cli/commands/previews-support/family.d.ts +10 -0
  180. package/dist/cli/commands/previews-support/family.d.ts.map +1 -0
  181. package/dist/cli/commands/previews-support/render.d.ts +8 -0
  182. package/dist/cli/commands/previews-support/render.d.ts.map +1 -0
  183. package/dist/cli/commands/previews-support/theme.d.ts +10 -0
  184. package/dist/cli/commands/previews-support/theme.d.ts.map +1 -0
  185. package/dist/cli/commands/previews-support/types.d.ts +70 -0
  186. package/dist/cli/commands/previews-support/types.d.ts.map +1 -0
  187. package/dist/cli/commands/previews.d.ts +4 -0
  188. package/dist/cli/commands/previews.d.ts.map +1 -0
  189. package/dist/cli/commands/productions.d.ts +4 -0
  190. package/dist/cli/commands/productions.d.ts.map +1 -0
  191. package/dist/cli/commands/secrets.d.ts +4 -0
  192. package/dist/cli/commands/secrets.d.ts.map +1 -0
  193. package/dist/cli/commands/token.d.ts +4 -0
  194. package/dist/cli/commands/token.d.ts.map +1 -0
  195. package/dist/cli/commands/type-generation/discovery.d.ts +7 -0
  196. package/dist/cli/commands/type-generation/discovery.d.ts.map +1 -0
  197. package/dist/cli/commands/type-generation/generator.d.ts +110 -0
  198. package/dist/cli/commands/type-generation/generator.d.ts.map +1 -0
  199. package/dist/cli/commands/type-generation/models.d.ts +27 -0
  200. package/dist/cli/commands/type-generation/models.d.ts.map +1 -0
  201. package/dist/cli/commands/types.d.ts.map +1 -1
  202. package/dist/cli/commands/worker.d.ts +4 -0
  203. package/dist/cli/commands/worker.d.ts.map +1 -0
  204. package/dist/cli/config-path.d.ts +6 -0
  205. package/dist/cli/config-path.d.ts.map +1 -0
  206. package/dist/cli/dependencies.d.ts +1 -0
  207. package/dist/cli/dependencies.d.ts.map +1 -1
  208. package/dist/cli/deploy-strategy.d.ts +17 -0
  209. package/dist/cli/deploy-strategy.d.ts.map +1 -0
  210. package/dist/cli/deploy-target.d.ts +17 -0
  211. package/dist/cli/deploy-target.d.ts.map +1 -0
  212. package/dist/cli/generated-artifacts.d.ts +12 -0
  213. package/dist/cli/generated-artifacts.d.ts.map +1 -0
  214. package/dist/cli/help-pages/pages/account.d.ts +3 -0
  215. package/dist/cli/help-pages/pages/account.d.ts.map +1 -0
  216. package/dist/cli/help-pages/pages/core.d.ts +4 -0
  217. package/dist/cli/help-pages/pages/core.d.ts.map +1 -0
  218. package/dist/cli/help-pages/pages/index.d.ts +3 -0
  219. package/dist/cli/help-pages/pages/index.d.ts.map +1 -0
  220. package/dist/cli/help-pages/pages/misc.d.ts +3 -0
  221. package/dist/cli/help-pages/pages/misc.d.ts.map +1 -0
  222. package/dist/cli/help-pages/pages/previews.d.ts +3 -0
  223. package/dist/cli/help-pages/pages/previews.d.ts.map +1 -0
  224. package/dist/cli/help-pages/pages/productions.d.ts +3 -0
  225. package/dist/cli/help-pages/pages/productions.d.ts.map +1 -0
  226. package/dist/cli/help-pages/render.d.ts +12 -0
  227. package/dist/cli/help-pages/render.d.ts.map +1 -0
  228. package/dist/cli/help-pages/shared.d.ts +15 -0
  229. package/dist/cli/help-pages/shared.d.ts.map +1 -0
  230. package/dist/cli/help-pages/types.d.ts +23 -0
  231. package/dist/cli/help-pages/types.d.ts.map +1 -0
  232. package/dist/cli/help.d.ts +6 -0
  233. package/dist/cli/help.d.ts.map +1 -0
  234. package/dist/cli/index.d.ts +1 -0
  235. package/dist/cli/index.d.ts.map +1 -1
  236. package/dist/cli/index.js +12 -0
  237. package/dist/cli/package-metadata.d.ts +16 -0
  238. package/dist/cli/package-metadata.d.ts.map +1 -0
  239. package/dist/cli/preview-bindings.d.ts +49 -0
  240. package/dist/cli/preview-bindings.d.ts.map +1 -0
  241. package/dist/cli/preview.d.ts +10 -0
  242. package/dist/cli/preview.d.ts.map +1 -0
  243. package/dist/cli/ui.d.ts +37 -0
  244. package/dist/cli/ui.d.ts.map +1 -0
  245. package/dist/cli/workspace-build-guard.d.ts +14 -0
  246. package/dist/cli/workspace-build-guard.d.ts.map +1 -0
  247. package/dist/cloudflare/account-core.d.ts +6 -0
  248. package/dist/cloudflare/account-core.d.ts.map +1 -0
  249. package/dist/cloudflare/account-resources.d.ts +40 -0
  250. package/dist/cloudflare/account-resources.d.ts.map +1 -0
  251. package/dist/cloudflare/account-status.d.ts +11 -0
  252. package/dist/cloudflare/account-status.d.ts.map +1 -0
  253. package/dist/cloudflare/account-workers.d.ts +14 -0
  254. package/dist/cloudflare/account-workers.d.ts.map +1 -0
  255. package/dist/cloudflare/account.d.ts +7 -64
  256. package/dist/cloudflare/account.d.ts.map +1 -1
  257. package/dist/cloudflare/api.d.ts +71 -3
  258. package/dist/cloudflare/api.d.ts.map +1 -1
  259. package/dist/cloudflare/auth.d.ts.map +1 -1
  260. package/dist/cloudflare/index.d.ts +57 -2
  261. package/dist/cloudflare/index.d.ts.map +1 -1
  262. package/dist/cloudflare/index.js +49 -2
  263. package/dist/cloudflare/known-permission-group-ids.generated.d.ts +10 -0
  264. package/dist/cloudflare/known-permission-group-ids.generated.d.ts.map +1 -0
  265. package/dist/cloudflare/kv-namespace.d.ts +4 -0
  266. package/dist/cloudflare/kv-namespace.d.ts.map +1 -0
  267. package/dist/cloudflare/preferences.d.ts +7 -0
  268. package/dist/cloudflare/preferences.d.ts.map +1 -1
  269. package/dist/cloudflare/preview-registry-cache.d.ts +6 -0
  270. package/dist/cloudflare/preview-registry-cache.d.ts.map +1 -0
  271. package/dist/cloudflare/preview-registry-inference.d.ts +14 -0
  272. package/dist/cloudflare/preview-registry-inference.d.ts.map +1 -0
  273. package/dist/cloudflare/preview-registry-records.d.ts +4 -0
  274. package/dist/cloudflare/preview-registry-records.d.ts.map +1 -0
  275. package/dist/cloudflare/preview-registry-shape.d.ts +47 -0
  276. package/dist/cloudflare/preview-registry-shape.d.ts.map +1 -0
  277. package/dist/cloudflare/preview-registry-store.d.ts +14 -0
  278. package/dist/cloudflare/preview-registry-store.d.ts.map +1 -0
  279. package/dist/cloudflare/preview-registry-transport.d.ts +4 -0
  280. package/dist/cloudflare/preview-registry-transport.d.ts.map +1 -0
  281. package/dist/cloudflare/preview-registry-types.d.ts +103 -0
  282. package/dist/cloudflare/preview-registry-types.d.ts.map +1 -0
  283. package/dist/cloudflare/preview-registry.d.ts +42 -0
  284. package/dist/cloudflare/preview-registry.d.ts.map +1 -0
  285. package/dist/cloudflare/preview-urls.d.ts +3 -0
  286. package/dist/cloudflare/preview-urls.d.ts.map +1 -0
  287. package/dist/cloudflare/registry-schema.d.ts +253 -0
  288. package/dist/cloudflare/registry-schema.d.ts.map +1 -0
  289. package/dist/cloudflare/tokens.d.ts +41 -0
  290. package/dist/cloudflare/tokens.d.ts.map +1 -0
  291. package/dist/cloudflare/types.d.ts +124 -7
  292. package/dist/cloudflare/types.d.ts.map +1 -1
  293. package/dist/cloudflare/usage.d.ts +30 -2
  294. package/dist/cloudflare/usage.d.ts.map +1 -1
  295. package/dist/config/binding-resolution-helpers.d.ts +41 -0
  296. package/dist/config/binding-resolution-helpers.d.ts.map +1 -0
  297. package/dist/config/compatibility.d.ts +3 -0
  298. package/dist/config/compatibility.d.ts.map +1 -0
  299. package/dist/config/compiler/bindings.d.ts +14 -0
  300. package/dist/config/compiler/bindings.d.ts.map +1 -0
  301. package/dist/config/compiler/core-helpers.d.ts +6 -0
  302. package/dist/config/compiler/core-helpers.d.ts.map +1 -0
  303. package/dist/config/compiler/do-workers.d.ts +34 -0
  304. package/dist/config/compiler/do-workers.d.ts.map +1 -0
  305. package/dist/config/compiler/paths.d.ts +18 -0
  306. package/dist/config/compiler/paths.d.ts.map +1 -0
  307. package/dist/config/compiler/types.d.ts +267 -0
  308. package/dist/config/compiler/types.d.ts.map +1 -0
  309. package/dist/config/compiler.d.ts +22 -134
  310. package/dist/config/compiler.d.ts.map +1 -1
  311. package/dist/config/deploy-resources.d.ts +58 -0
  312. package/dist/config/deploy-resources.d.ts.map +1 -0
  313. package/dist/config/framework-providers.d.ts +9 -0
  314. package/dist/config/framework-providers.d.ts.map +1 -0
  315. package/dist/config/index.d.ts +10 -4
  316. package/dist/config/index.d.ts.map +1 -1
  317. package/dist/config/loader.d.ts +1 -0
  318. package/dist/config/loader.d.ts.map +1 -1
  319. package/dist/config/local-dev-vars.d.ts +15 -0
  320. package/dist/config/local-dev-vars.d.ts.map +1 -0
  321. package/dist/config/preview-resources.d.ts +83 -0
  322. package/dist/config/preview-resources.d.ts.map +1 -0
  323. package/dist/config/preview.d.ts +31 -0
  324. package/dist/config/preview.d.ts.map +1 -0
  325. package/dist/config/ref.d.ts +14 -23
  326. package/dist/config/ref.d.ts.map +1 -1
  327. package/dist/config/resolve-phased.d.ts +72 -0
  328. package/dist/config/resolve-phased.d.ts.map +1 -0
  329. package/dist/config/resolve.d.ts +11 -0
  330. package/dist/config/resolve.d.ts.map +1 -0
  331. package/dist/config/resource-resolution.d.ts +80 -0
  332. package/dist/config/resource-resolution.d.ts.map +1 -0
  333. package/dist/config/schema-bindings.d.ts +1495 -0
  334. package/dist/config/schema-bindings.d.ts.map +1 -0
  335. package/dist/config/schema-build.d.ts +67 -0
  336. package/dist/config/schema-build.d.ts.map +1 -0
  337. package/dist/config/schema-env.d.ts +2949 -0
  338. package/dist/config/schema-env.d.ts.map +1 -0
  339. package/dist/config/schema-normalization.d.ts +184 -0
  340. package/dist/config/schema-normalization.d.ts.map +1 -0
  341. package/dist/config/schema-runtime.d.ts +468 -0
  342. package/dist/config/schema-runtime.d.ts.map +1 -0
  343. package/dist/config/schema.d.ts +4056 -1875
  344. package/dist/config/schema.d.ts.map +1 -1
  345. package/dist/config/service-bindings-validation.d.ts +36 -0
  346. package/dist/config/service-bindings-validation.d.ts.map +1 -0
  347. package/dist/config-1japnjmx.js +59 -0
  348. package/dist/config-287wjn1m.js +59 -0
  349. package/dist/config-4x6vq82e.js +59 -0
  350. package/dist/config-5n0avhcx.js +59 -0
  351. package/dist/config-6m0n7d84.js +59 -0
  352. package/dist/config-70s2ap5j.js +59 -0
  353. package/dist/config-7cf004ag.js +59 -0
  354. package/dist/config-7hge8ze6.js +59 -0
  355. package/dist/config-7rbp7aek.js +59 -0
  356. package/dist/config-b8xbbmta.js +59 -0
  357. package/dist/config-b98dp58n.js +59 -0
  358. package/dist/config-baee5690.js +59 -0
  359. package/dist/config-bczpc1ey.js +59 -0
  360. package/dist/config-cf3djhqy.js +59 -0
  361. package/dist/config-entry.d.ts +5 -0
  362. package/dist/config-entry.d.ts.map +1 -0
  363. package/dist/config-entry.js +14 -0
  364. package/dist/config-fhmwzaw6.js +59 -0
  365. package/dist/config-g9vkfa4x.js +59 -0
  366. package/dist/config-gpexkzth.js +59 -0
  367. package/dist/config-nspw7sgv.js +59 -0
  368. package/dist/config-ntm4x9wt.js +59 -0
  369. package/dist/config-nv6hfpg6.js +59 -0
  370. package/dist/config-pjc33wew.js +59 -0
  371. package/dist/config-pnz2e8s3.js +59 -0
  372. package/dist/config-qts6nh6g.js +59 -0
  373. package/dist/config-sg2xrdt4.js +59 -0
  374. package/dist/config-vzwckat3.js +59 -0
  375. package/dist/config-wa7hm0w9.js +59 -0
  376. package/dist/config-x90dkmm7.js +59 -0
  377. package/dist/decorators/durable-object.d.ts.map +1 -1
  378. package/dist/deploy-1jfagtn9.js +1055 -0
  379. package/dist/deploy-1s6nv5rp.js +921 -0
  380. package/dist/deploy-2afw0jfg.js +1055 -0
  381. package/dist/deploy-2fzj68kq.js +1055 -0
  382. package/dist/deploy-30ph1rrd.js +921 -0
  383. package/dist/deploy-39dmfn9d.js +921 -0
  384. package/dist/deploy-44n2pshy.js +1016 -0
  385. package/dist/deploy-45qxpsfe.js +921 -0
  386. package/dist/deploy-57nzn9wj.js +1045 -0
  387. package/dist/deploy-64e57w1g.js +1040 -0
  388. package/dist/deploy-82j43vta.js +1040 -0
  389. package/dist/deploy-99m8qhpa.js +1041 -0
  390. package/dist/deploy-9twkd32f.js +1040 -0
  391. package/dist/deploy-a2eq2c1n.js +1040 -0
  392. package/dist/deploy-a3pb1qs5.js +921 -0
  393. package/dist/deploy-agbtfm04.js +921 -0
  394. package/dist/deploy-aswbtbf3.js +921 -0
  395. package/dist/deploy-asyryrvm.js +1055 -0
  396. package/dist/deploy-bqf3kxy5.js +972 -0
  397. package/dist/deploy-fv4z648h.js +921 -0
  398. package/dist/deploy-gsybda2f.js +1038 -0
  399. package/dist/deploy-h17nzysm.js +921 -0
  400. package/dist/deploy-hc89h4wg.js +1045 -0
  401. package/dist/deploy-hc927rw6.js +1045 -0
  402. package/dist/deploy-jey5pnqn.js +1040 -0
  403. package/dist/deploy-jv0yfqvk.js +1040 -0
  404. package/dist/deploy-kn3z6spd.js +941 -0
  405. package/dist/deploy-m22xmz9w.js +921 -0
  406. package/dist/deploy-nefp2njy.js +1038 -0
  407. package/dist/deploy-pnnf8tgy.js +1045 -0
  408. package/dist/deploy-ppp8pg6w.js +1038 -0
  409. package/dist/deploy-q33bw715.js +1055 -0
  410. package/dist/deploy-qah2eag6.js +1041 -0
  411. package/dist/deploy-qdq2gpad.js +1045 -0
  412. package/dist/deploy-r1yf8913.js +1038 -0
  413. package/dist/deploy-r8nam9rr.js +1038 -0
  414. package/dist/deploy-rrm4a0xw.js +921 -0
  415. package/dist/deploy-s0tfnc12.js +1040 -0
  416. package/dist/deploy-s636ks9k.js +1041 -0
  417. package/dist/deploy-sany8t54.js +1045 -0
  418. package/dist/deploy-skqn61j3.js +1038 -0
  419. package/dist/deploy-smv2870h.js +921 -0
  420. package/dist/deploy-sp16nxs5.js +972 -0
  421. package/dist/deploy-sr805bvq.js +921 -0
  422. package/dist/deploy-t9dehmn0.js +1041 -0
  423. package/dist/deploy-taxt7njz.js +1041 -0
  424. package/dist/deploy-tmdgecs3.js +1055 -0
  425. package/dist/deploy-tnfvfh9m.js +1040 -0
  426. package/dist/deploy-v0y8kczr.js +1055 -0
  427. package/dist/deploy-w5f8db4s.js +1040 -0
  428. package/dist/deploy-wsxcectr.js +921 -0
  429. package/dist/deploy-xhj6zbcx.js +1055 -0
  430. package/dist/deploy-xyfbhj3v.js +1038 -0
  431. package/dist/deploy-yv1y5xaa.js +921 -0
  432. package/dist/deploy-z3ejw37k.js +1040 -0
  433. package/dist/dev-02tgdc4f.js +2160 -0
  434. package/dist/dev-0tqhveye.js +2314 -0
  435. package/dist/dev-1mvcts8w.js +2515 -0
  436. package/dist/dev-2a283xts.js +2515 -0
  437. package/dist/dev-3dj2gkfq.js +2314 -0
  438. package/dist/dev-3e0etsww.js +2314 -0
  439. package/dist/dev-47dk7c13.js +2314 -0
  440. package/dist/dev-4a2a31cm.js +2314 -0
  441. package/dist/dev-4w1stcn8.js +2427 -0
  442. package/dist/dev-5wkh1z4a.js +2188 -0
  443. package/dist/dev-62nhytf8.js +2505 -0
  444. package/dist/dev-6t22zmey.js +2350 -0
  445. package/dist/dev-75acm2xj.js +2478 -0
  446. package/dist/dev-802rg9dp.js +2515 -0
  447. package/dist/dev-89p1sdv7.js +2395 -0
  448. package/dist/dev-8d1gxjky.js +2427 -0
  449. package/dist/dev-8yawx3cv.js +2314 -0
  450. package/dist/dev-9h4p8a0c.js +2393 -0
  451. package/dist/dev-9xmttj4c.js +2314 -0
  452. package/dist/dev-at6gy2td.js +2427 -0
  453. package/dist/dev-bkbz97z0.js +2314 -0
  454. package/dist/dev-ct3344kv.js +2160 -0
  455. package/dist/dev-d1bb2t0f.js +2515 -0
  456. package/dist/{dev-qnxet3j9.js → dev-dg8dh5c1.js} +947 -809
  457. package/dist/dev-dr5jb965.js +2427 -0
  458. package/dist/dev-dwry8494.js +2489 -0
  459. package/dist/dev-e4sjqtbq.js +2314 -0
  460. package/dist/dev-ecq26mg4.js +2350 -0
  461. package/dist/dev-ef237vgp.js +2324 -0
  462. package/dist/dev-enbdg4st.js +2314 -0
  463. package/dist/dev-g6112y4w.js +2515 -0
  464. package/dist/dev-h2kneh95.js +2496 -0
  465. package/dist/dev-jcrxg8hq.js +2160 -0
  466. package/dist/dev-jk0gqges.js +2432 -0
  467. package/dist/dev-k62936am.js +2314 -0
  468. package/dist/dev-k8ptbvrs.js +2160 -0
  469. package/dist/dev-kqm107h4.js +2422 -0
  470. package/dist/dev-kybq3mwr.js +2489 -0
  471. package/dist/dev-n0gx7eya.js +2350 -0
  472. package/dist/dev-n23m6rtb.js +2314 -0
  473. package/dist/dev-n8qndkyg.js +2512 -0
  474. package/dist/dev-ny8fmkzg.js +2432 -0
  475. package/dist/dev-p1c65cga.js +2386 -0
  476. package/dist/dev-p32fkbwf.js +2489 -0
  477. package/dist/dev-p4fjbb4h.js +2395 -0
  478. package/dist/dev-pnfcv79z.js +2160 -0
  479. package/dist/dev-qm9d4mfh.js +2478 -0
  480. package/dist/dev-qnrrv5ey.js +2393 -0
  481. package/dist/dev-qqysg50t.js +2427 -0
  482. package/dist/dev-r9f3n11q.js +2410 -0
  483. package/dist/dev-rcthnse5.js +2473 -0
  484. package/dist/dev-s0815dw4.js +2427 -0
  485. package/dist/dev-s4tpkg60.js +2314 -0
  486. package/dist/dev-s82fcesg.js +2314 -0
  487. package/dist/dev-s9sz53me.js +2401 -0
  488. package/dist/dev-sdka7z0d.js +2427 -0
  489. package/dist/dev-server/d1-migrations.d.ts +36 -0
  490. package/dist/dev-server/d1-migrations.d.ts.map +1 -0
  491. package/dist/dev-server/dev-server-state.d.ts +57 -0
  492. package/dist/dev-server/dev-server-state.d.ts.map +1 -0
  493. package/dist/dev-server/gateway-script.d.ts +21 -0
  494. package/dist/dev-server/gateway-script.d.ts.map +1 -0
  495. package/dist/dev-server/miniflare-bindings.d.ts +59 -0
  496. package/dist/dev-server/miniflare-bindings.d.ts.map +1 -0
  497. package/dist/dev-server/miniflare-dev-config.d.ts +31 -0
  498. package/dist/dev-server/miniflare-dev-config.d.ts.map +1 -0
  499. package/dist/dev-server/miniflare-log.d.ts +20 -0
  500. package/dist/dev-server/miniflare-log.d.ts.map +1 -0
  501. package/dist/dev-server/miniflare-worker-config.d.ts +74 -0
  502. package/dist/dev-server/miniflare-worker-config.d.ts.map +1 -0
  503. package/dist/dev-server/reload-queue.d.ts +13 -0
  504. package/dist/dev-server/reload-queue.d.ts.map +1 -0
  505. package/dist/dev-server/runtime-stdio.d.ts +8 -0
  506. package/dist/dev-server/runtime-stdio.d.ts.map +1 -0
  507. package/dist/dev-server/server-startup-helpers.d.ts +84 -0
  508. package/dist/dev-server/server-startup-helpers.d.ts.map +1 -0
  509. package/dist/dev-server/server.d.ts +2 -0
  510. package/dist/dev-server/server.d.ts.map +1 -1
  511. package/dist/dev-server/vite-process.d.ts +15 -0
  512. package/dist/dev-server/vite-process.d.ts.map +1 -0
  513. package/dist/dev-server/vite-utils.d.ts +55 -0
  514. package/dist/dev-server/vite-utils.d.ts.map +1 -0
  515. package/dist/dev-server/worker-source-watcher.d.ts +17 -0
  516. package/dist/dev-server/worker-source-watcher.d.ts.map +1 -0
  517. package/dist/dev-server/worker-surface-paths.d.ts +6 -0
  518. package/dist/dev-server/worker-surface-paths.d.ts.map +1 -0
  519. package/dist/dev-t3tjscah.js +2350 -0
  520. package/dist/dev-t50kdb1j.js +2338 -0
  521. package/dist/dev-t5xf55pt.js +2314 -0
  522. package/dist/dev-t63c44bb.js +2314 -0
  523. package/dist/dev-tgwja5mz.js +2496 -0
  524. package/dist/dev-wg3d38sy.js +2433 -0
  525. package/dist/dev-wh4rfgsh.js +2427 -0
  526. package/dist/dev-wjh8gdd1.js +2284 -0
  527. package/dist/dev-xzxy9qvq.js +2314 -0
  528. package/dist/dev-yymaq4ph.js +2392 -0
  529. package/dist/dev-zg2w2ve3.js +2422 -0
  530. package/dist/dev-zsb2xk1x.js +2427 -0
  531. package/dist/dev-zty3yhzg.js +2324 -0
  532. package/dist/doctor-2shhdak6.js +245 -0
  533. package/dist/doctor-3mqavqg3.js +245 -0
  534. package/dist/doctor-5g73w40j.js +245 -0
  535. package/dist/doctor-5nek32fz.js +245 -0
  536. package/dist/doctor-7ra1w0sk.js +245 -0
  537. package/dist/doctor-ak830a0k.js +245 -0
  538. package/dist/doctor-bye3cs8a.js +245 -0
  539. package/dist/doctor-c5m9pmwq.js +245 -0
  540. package/dist/doctor-cqfkgxvw.js +245 -0
  541. package/dist/doctor-e1h9mhzp.js +245 -0
  542. package/dist/doctor-fmqsrafk.js +245 -0
  543. package/dist/doctor-gamefzcs.js +245 -0
  544. package/dist/doctor-hgs7wr5g.js +245 -0
  545. package/dist/doctor-j8ytsy94.js +245 -0
  546. package/dist/doctor-mcmkgp6e.js +245 -0
  547. package/dist/doctor-qb6m2exc.js +245 -0
  548. package/dist/doctor-qq4tsh8q.js +245 -0
  549. package/dist/doctor-rn53ctfs.js +245 -0
  550. package/dist/doctor-tecv869a.js +245 -0
  551. package/dist/doctor-wg0245pe.js +245 -0
  552. package/dist/doctor-z3jfqxtz.js +245 -0
  553. package/dist/{durable-object-t4kbb0yt.js → durable-object-4hey8fgy.js} +1 -1
  554. package/dist/durable-object-v3gsnybk.js +13 -0
  555. package/dist/durable-object-yt8v1dyn.js +13 -0
  556. package/dist/env.d.ts.map +1 -1
  557. package/dist/index-01kehw41.js +348 -0
  558. package/dist/index-06bg0z9y.js +185 -0
  559. package/dist/index-0d7tw5r4.js +136 -0
  560. package/dist/index-0krb65s3.js +215 -0
  561. package/dist/index-0m6e4mxz.js +133 -0
  562. package/dist/index-0mantew0.js +513 -0
  563. package/dist/index-0mezg6ar.js +1372 -0
  564. package/dist/index-0tk2rs0q.js +185 -0
  565. package/dist/index-0vah20er.js +1410 -0
  566. package/dist/index-0wa0ebm1.js +68 -0
  567. package/dist/index-124e9t4t.js +232 -0
  568. package/dist/index-1546yrn0.js +74 -0
  569. package/dist/index-15fpa5tx.js +232 -0
  570. package/dist/index-1714y3cz.js +1410 -0
  571. package/dist/index-18mp5v50.js +538 -0
  572. package/dist/index-195tc6qh.js +1372 -0
  573. package/dist/index-1bg8w2gf.js +52 -0
  574. package/dist/index-1d4jg11n.js +542 -0
  575. package/dist/index-1e2qtrmj.js +188 -0
  576. package/dist/index-1ghhgb9d.js +74 -0
  577. package/dist/index-1nhd9nkd.js +232 -0
  578. package/dist/index-1p814k7s.js +227 -0
  579. package/dist/index-1qs5gcm7.js +895 -0
  580. package/dist/index-1wn8mjep.js +808 -0
  581. package/dist/index-1xhd5czz.js +185 -0
  582. package/dist/index-29k04v43.js +574 -0
  583. package/dist/index-2a2g4fwp.js +993 -0
  584. package/dist/index-2bmtj21z.js +192 -0
  585. package/dist/index-2dpmd14d.js +52 -0
  586. package/dist/index-2fa0afdp.js +1372 -0
  587. package/dist/index-2jywf4pz.js +1372 -0
  588. package/dist/index-2qhk9nbx.js +1372 -0
  589. package/dist/index-2rcrefqd.js +1372 -0
  590. package/dist/index-2t2m5148.js +1372 -0
  591. package/dist/index-2vbzamev.js +437 -0
  592. package/dist/index-2vdep9h0.js +993 -0
  593. package/dist/index-2vq6bveq.js +574 -0
  594. package/dist/index-2y90j9cz.js +74 -0
  595. package/dist/index-33ep0z9x.js +385 -0
  596. package/dist/index-36h8gkhb.js +1088 -0
  597. package/dist/index-37jgbaw6.js +1372 -0
  598. package/dist/index-380ncsqc.js +977 -0
  599. package/dist/index-38fq7pww.js +560 -0
  600. package/dist/index-3bxqn033.js +1410 -0
  601. package/dist/index-3e1x39fc.js +365 -0
  602. package/dist/index-3e7by9sy.js +223 -0
  603. package/dist/index-3egad6wm.js +538 -0
  604. package/dist/index-3f8rzmjw.js +232 -0
  605. package/dist/index-3jme4hgw.js +1234 -0
  606. package/dist/index-3p7s9mk9.js +360 -0
  607. package/dist/index-3vd4r37r.js +1372 -0
  608. package/dist/index-3vgn5e89.js +1682 -0
  609. package/dist/index-3x7k3t0f.js +513 -0
  610. package/dist/index-3xfe2dst.js +399 -0
  611. package/dist/index-464j1zb4.js +513 -0
  612. package/dist/index-47w35sft.js +244 -0
  613. package/dist/index-48rxsj95.js +365 -0
  614. package/dist/index-4bezcdd1.js +385 -0
  615. package/dist/index-4by4c7rm.js +52 -0
  616. package/dist/index-4fp11z9e.js +973 -0
  617. package/dist/index-4knecthc.js +70 -0
  618. package/dist/index-4phjwd6h.js +412 -0
  619. package/dist/index-4z5jrw0j.js +594 -0
  620. package/dist/index-502y7w13.js +538 -0
  621. package/dist/index-50mxxb4q.js +185 -0
  622. package/dist/index-51mzqy0d.js +895 -0
  623. package/dist/index-53pqqpq9.js +74 -0
  624. package/dist/index-5achzspr.js +185 -0
  625. package/dist/index-5ef3jmv7.js +1372 -0
  626. package/dist/index-5enq8ntr.js +1766 -0
  627. package/dist/index-5eswe8yv.js +844 -0
  628. package/dist/index-5fnq9r9m.js +1410 -0
  629. package/dist/index-5gevxfgs.js +513 -0
  630. package/dist/index-5gmf048z.js +817 -0
  631. package/dist/index-5jtkxpjf.js +971 -0
  632. package/dist/index-5m85bd9x.js +168 -0
  633. package/dist/index-5n5nn0a8.js +264 -0
  634. package/dist/index-5p3bgjwr.js +808 -0
  635. package/dist/index-5vzcszr2.js +1230 -0
  636. package/dist/index-5w77r4w9.js +513 -0
  637. package/dist/index-5w9f2b17.js +695 -0
  638. package/dist/index-627srx16.js +45 -0
  639. package/dist/index-62b3gt2g.js +12 -0
  640. package/dist/index-62srkqcm.js +168 -0
  641. package/dist/index-63cgqe43.js +1372 -0
  642. package/dist/index-65e7xx1a.js +19 -0
  643. package/dist/index-65qrje14.js +185 -0
  644. package/dist/index-66sx3b3v.js +385 -0
  645. package/dist/index-678j0n13.js +74 -0
  646. package/dist/index-6bqgf5x8.js +227 -0
  647. package/dist/index-6ftrth7n.js +1218 -0
  648. package/dist/index-6g90pvxa.js +215 -0
  649. package/dist/index-6h8xbs75.js +44 -0
  650. package/dist/index-6j4m5x2d.js +1372 -0
  651. package/dist/index-6jwpke14.js +385 -0
  652. package/dist/index-6knsjvxh.js +1372 -0
  653. package/dist/index-6kwq6yf8.js +979 -0
  654. package/dist/index-6mg4yvc6.js +74 -0
  655. package/dist/index-6phry941.js +133 -0
  656. package/dist/index-6r59wbek.js +232 -0
  657. package/dist/index-6sf815ps.js +74 -0
  658. package/dist/index-6xknvbyk.js +1088 -0
  659. package/dist/index-6zd89k6y.js +1230 -0
  660. package/dist/index-71rwg0cn.js +264 -0
  661. package/dist/index-75ex2m0x.js +695 -0
  662. package/dist/index-79exzs3q.js +1218 -0
  663. package/dist/index-7bxj118m.js +264 -0
  664. package/dist/index-7c6np4mq.js +397 -0
  665. package/dist/index-7cm339qz.js +133 -0
  666. package/dist/index-7e359eb5.js +895 -0
  667. package/dist/index-7ef3ktz5.js +1372 -0
  668. package/dist/index-7eqyr4j8.js +70 -0
  669. package/dist/index-7hpjfdzh.js +185 -0
  670. package/dist/index-7k278fgz.js +273 -0
  671. package/dist/index-7kazxkjt.js +1372 -0
  672. package/dist/index-7m0x8m9r.js +844 -0
  673. package/dist/index-7p74smg8.js +1372 -0
  674. package/dist/index-7q8fke3k.js +188 -0
  675. package/dist/index-7qk6eafn.js +1682 -0
  676. package/dist/index-7r7dfpcm.js +133 -0
  677. package/dist/index-7vbjt6ba.js +805 -0
  678. package/dist/index-7z4b0vgd.js +470 -0
  679. package/dist/index-8052df4m.js +627 -0
  680. package/dist/index-82epjzrr.js +1410 -0
  681. package/dist/index-82f1z98k.js +41 -0
  682. package/dist/index-82xn4azv.js +74 -0
  683. package/dist/index-82z7rvz6.js +1238 -0
  684. package/dist/index-83wns7cz.js +70 -0
  685. package/dist/index-852945d4.js +413 -0
  686. package/dist/index-86rvj79f.js +133 -0
  687. package/dist/index-88tcq0t4.js +542 -0
  688. package/dist/index-8atc1yb9.js +68 -0
  689. package/dist/index-8evn52g1.js +1218 -0
  690. package/dist/index-8jkf4nsd.js +695 -0
  691. package/dist/index-8nx4ce3e.js +133 -0
  692. package/dist/index-8q1bcnrh.js +1372 -0
  693. package/dist/index-8t5gynct.js +971 -0
  694. package/dist/index-8tj0awnv.js +476 -0
  695. package/dist/index-8x745h59.js +1069 -0
  696. package/dist/index-905svbb6.js +470 -0
  697. package/dist/index-94cb0sac.js +1372 -0
  698. package/dist/index-95mmvbw7.js +538 -0
  699. package/dist/index-97x94h0m.js +438 -0
  700. package/dist/index-9an9qqr1.js +728 -0
  701. package/dist/index-9bawzcny.js +574 -0
  702. package/dist/index-9bjjqdfc.js +236 -0
  703. package/dist/index-9d125myk.js +1372 -0
  704. package/dist/index-9d7x3vfr.js +236 -0
  705. package/dist/index-9fbtk7gv.js +817 -0
  706. package/dist/index-9gg0kqw0.js +470 -0
  707. package/dist/index-9nf8zs4p.js +1069 -0
  708. package/dist/index-9ryw7mcw.js +971 -0
  709. package/dist/{index-gz1gndna.js → index-9wt9x09k.js} +42 -62
  710. package/dist/index-a3e13a7m.js +478 -0
  711. package/dist/index-a6j44jmr.js +1372 -0
  712. package/dist/index-a75ejnvt.js +1711 -0
  713. package/dist/index-aabgympv.js +39 -0
  714. package/dist/index-ab2nck1h.js +1372 -0
  715. package/dist/index-abrqnq3e.js +488 -0
  716. package/dist/index-acwbmagz.js +412 -0
  717. package/dist/index-afjbpgb1.js +1218 -0
  718. package/dist/index-aqjdaem7.js +74 -0
  719. package/dist/index-at89fpde.js +470 -0
  720. package/dist/index-awr0tp6p.js +313 -0
  721. package/dist/index-b1be9bdh.js +1372 -0
  722. package/dist/index-b1xs3wc4.js +513 -0
  723. package/dist/index-b50x7seh.js +513 -0
  724. package/dist/index-b5ra8w3q.js +52 -0
  725. package/dist/index-b6448fd0.js +133 -0
  726. package/dist/index-b64sbzgv.js +884 -0
  727. package/dist/index-b7r8ntpm.js +1372 -0
  728. package/dist/index-b9j55r7q.js +240 -0
  729. package/dist/index-ba9gyy13.js +513 -0
  730. package/dist/index-bb66mn7p.js +52 -0
  731. package/dist/index-bc5pvbbd.js +1193 -0
  732. package/dist/index-bdatd1za.js +1372 -0
  733. package/dist/index-bj0mk3dw.js +74 -0
  734. package/dist/index-bj3a8dr0.js +1372 -0
  735. package/dist/index-bk3eez1g.js +513 -0
  736. package/dist/index-btjx137w.js +774 -0
  737. package/dist/index-btrfqp9h.js +133 -0
  738. package/dist/index-bx6gangy.js +402 -0
  739. package/dist/index-c0tc0yts.js +471 -0
  740. package/dist/index-c0whkev9.js +200 -0
  741. package/dist/index-c3nxftnp.js +699 -0
  742. package/dist/index-c643s0gv.js +488 -0
  743. package/dist/index-ca96qkva.js +1372 -0
  744. package/dist/index-cdtzkedk.js +993 -0
  745. package/dist/index-cejgenma.js +1372 -0
  746. package/dist/index-cp8jt5pr.js +52 -0
  747. package/dist/index-cpz69pek.js +1372 -0
  748. package/dist/index-crrdegk5.js +456 -0
  749. package/dist/index-cskszwkx.js +1372 -0
  750. package/dist/index-cxf22a0s.js +74 -0
  751. package/dist/index-cy3c3w81.js +270 -0
  752. package/dist/index-d2md1j3d.js +185 -0
  753. package/dist/index-d5dgb1j6.js +74 -0
  754. package/dist/index-da397xcx.js +1372 -0
  755. package/dist/index-damyy8bw.js +1372 -0
  756. package/dist/index-dbr6bfz6.js +528 -0
  757. package/dist/index-dd1g0g7e.js +360 -0
  758. package/dist/index-dd6fwwmq.js +456 -0
  759. package/dist/index-dh1954bp.js +52 -0
  760. package/dist/index-djp2wd1f.js +1372 -0
  761. package/dist/index-dktb9az5.js +1372 -0
  762. package/dist/index-dm9q84c7.js +360 -0
  763. package/dist/index-dmbdj6va.js +805 -0
  764. package/dist/index-dmf76tac.js +1372 -0
  765. package/dist/index-dphr32gc.js +420 -0
  766. package/dist/index-dxh2qyyw.js +52 -0
  767. package/dist/index-dzayfxjy.js +492 -0
  768. package/dist/index-e05q77kt.js +397 -0
  769. package/dist/index-e11b1fb2.js +495 -0
  770. package/dist/index-e3zvspqj.js +968 -0
  771. package/dist/index-e4tzzbn9.js +1372 -0
  772. package/dist/index-e5ct1gwb.js +1372 -0
  773. package/dist/index-e7ptcz1a.js +1372 -0
  774. package/dist/index-e7wt0203.js +513 -0
  775. package/dist/index-ebwsvf9t.js +365 -0
  776. package/dist/index-ed73jn3d.js +185 -0
  777. package/dist/index-ed7n5d07.js +185 -0
  778. package/dist/index-ejs2a4kd.js +513 -0
  779. package/dist/index-esjrgt3y.js +467 -0
  780. package/dist/index-ev03khsd.js +513 -0
  781. package/dist/index-f1gsqm54.js +168 -0
  782. package/dist/index-f51mkh13.js +1088 -0
  783. package/dist/index-f86n1fpd.js +55 -0
  784. package/dist/index-f90314kt.js +52 -0
  785. package/dist/index-f9mhsept.js +185 -0
  786. package/dist/index-fa6zwffw.js +70 -0
  787. package/dist/index-fama7kpt.js +52 -0
  788. package/dist/index-fgk87mk2.js +1067 -0
  789. package/dist/index-fkyvxe4b.js +968 -0
  790. package/dist/index-fnk0tkw7.js +412 -0
  791. package/dist/index-g0h40xke.js +513 -0
  792. package/dist/index-g0rqh52c.js +385 -0
  793. package/dist/index-g170d619.js +385 -0
  794. package/dist/index-g3qtxkms.js +881 -0
  795. package/dist/index-g5aq66bj.js +1534 -0
  796. package/dist/index-gactvqcs.js +467 -0
  797. package/dist/index-gaew61v4.js +470 -0
  798. package/dist/index-gba371j7.js +542 -0
  799. package/dist/index-gegyyfnw.js +1372 -0
  800. package/dist/index-get7he2s.js +133 -0
  801. package/dist/index-gj5qh491.js +54 -0
  802. package/dist/index-gn5wy09x.js +205 -0
  803. package/dist/index-gq39t0rx.js +895 -0
  804. package/dist/index-gtbgzwfs.js +264 -0
  805. package/dist/index-gtpz0gkz.js +185 -0
  806. package/dist/index-h1s66pmp.js +52 -0
  807. package/dist/index-h5dqna7q.js +1410 -0
  808. package/dist/index-h8r2d8y5.js +366 -0
  809. package/dist/index-heeqwrfd.js +385 -0
  810. package/dist/index-hheb5dyt.js +192 -0
  811. package/dist/index-hjs9j2g9.js +895 -0
  812. package/dist/index-hjz2x9nq.js +441 -0
  813. package/dist/index-hkex7ns5.js +513 -0
  814. package/dist/index-hmbctwv6.js +517 -0
  815. package/dist/index-hn5nbxbt.js +147 -0
  816. package/dist/index-hpjh0qjx.js +1723 -0
  817. package/dist/index-hpzasdhw.js +513 -0
  818. package/dist/index-hqdr9wdm.js +74 -0
  819. package/dist/index-hrvz8d26.js +1372 -0
  820. package/dist/index-hs6ekcfs.js +412 -0
  821. package/dist/index-hyvhnf6r.js +971 -0
  822. package/dist/index-j2kc5rbv.js +895 -0
  823. package/dist/index-j2xdxwsz.js +133 -0
  824. package/dist/index-j47hhb3r.js +694 -0
  825. package/dist/index-j5aphr5x.js +185 -0
  826. package/dist/index-j68v36q1.js +188 -0
  827. package/dist/index-j7cf22x7.js +968 -0
  828. package/dist/index-j7xxrbnr.js +694 -0
  829. package/dist/index-jdzrvnfj.js +52 -0
  830. package/dist/index-jg720mq7.js +476 -0
  831. package/dist/index-jptqxkew.js +470 -0
  832. package/dist/index-jrzddxvt.js +2167 -0
  833. package/dist/index-jsymy3mb.js +781 -0
  834. package/dist/index-jwvy32xk.js +188 -0
  835. package/dist/index-jxe1b19v.js +133 -0
  836. package/dist/index-jz96ry5g.js +513 -0
  837. package/dist/index-k6wtsgs1.js +971 -0
  838. package/dist/index-k7m5f1dg.js +200 -0
  839. package/dist/index-kawa49m8.js +371 -0
  840. package/dist/index-key4e5c9.js +168 -0
  841. package/dist/index-kgstnk6g.js +239 -0
  842. package/dist/index-khbmdrn2.js +884 -0
  843. package/dist/index-khnw972v.js +117 -0
  844. package/dist/index-kpzfwex6.js +264 -0
  845. package/dist/index-kse4gn99.js +74 -0
  846. package/dist/index-ktscz0r2.js +264 -0
  847. package/dist/index-kwqff3ba.js +1410 -0
  848. package/dist/index-kybmjvad.js +1212 -0
  849. package/dist/index-kzm9cea8.js +185 -0
  850. package/dist/index-m2d74gqg.js +808 -0
  851. package/dist/index-m2v0fj08.js +74 -0
  852. package/dist/index-m56w7mjt.js +513 -0
  853. package/dist/index-m95ha3n4.js +264 -0
  854. package/dist/index-ma151p8g.js +264 -0
  855. package/dist/index-mg8vwqxf.js +514 -0
  856. package/dist/index-mhdsywhs.js +264 -0
  857. package/dist/index-mjgx910r.js +895 -0
  858. package/dist/index-mjve6tqn.js +447 -0
  859. package/dist/index-mkrmaea3.js +185 -0
  860. package/dist/index-mkxnyyjn.js +264 -0
  861. package/dist/index-mkxzgn0q.js +1372 -0
  862. package/dist/index-mp5mrst6.js +1372 -0
  863. package/dist/index-ms15cr86.js +513 -0
  864. package/dist/index-mt99xkc6.js +133 -0
  865. package/dist/index-mttv6k25.js +881 -0
  866. package/dist/index-myxfx52v.js +385 -0
  867. package/dist/index-mzmq3v0d.js +1088 -0
  868. package/dist/index-mzw7732t.js +74 -0
  869. package/dist/index-n3mjwz22.js +188 -0
  870. package/dist/index-n3yksgz0.js +1372 -0
  871. package/dist/index-n4jr3dmk.js +484 -0
  872. package/dist/index-n5drt64b.js +74 -0
  873. package/dist/index-n8frmffg.js +264 -0
  874. package/dist/index-n8k8chde.js +694 -0
  875. package/dist/index-na796ka6.js +994 -0
  876. package/dist/index-nbs4q0qg.js +1218 -0
  877. package/dist/index-newpq2zf.js +968 -0
  878. package/dist/index-nexg9p7j.js +1271 -0
  879. package/dist/index-nfm8tb5n.js +74 -0
  880. package/dist/index-ng9n3znd.js +1372 -0
  881. package/dist/index-nga2tg9z.js +1372 -0
  882. package/dist/index-ngbzr9gz.js +805 -0
  883. package/dist/index-nh90nk7j.js +380 -0
  884. package/dist/index-nhbkm2ba.js +467 -0
  885. package/dist/index-njnmfxm5.js +1372 -0
  886. package/dist/index-nqma24j3.js +385 -0
  887. package/dist/index-nrfhk0k5.js +1088 -0
  888. package/dist/index-ntddf5d9.js +993 -0
  889. package/dist/index-nte9n8w9.js +538 -0
  890. package/dist/index-ntxp7ke1.js +264 -0
  891. package/dist/index-nwxnmw41.js +264 -0
  892. package/dist/index-p0zppqxm.js +467 -0
  893. package/dist/index-p1xe5eem.js +513 -0
  894. package/dist/index-p296ban8.js +191 -0
  895. package/dist/index-p477xm52.js +385 -0
  896. package/dist/index-p8nmkrgw.js +470 -0
  897. package/dist/index-p97s12vf.js +904 -0
  898. package/dist/index-p9hvv0yd.js +401 -0
  899. package/dist/index-pac7wv88.js +307 -0
  900. package/dist/index-pkxf6h87.js +895 -0
  901. package/dist/index-pqp4312v.js +52 -0
  902. package/dist/index-ptp2pfq1.js +52 -0
  903. package/dist/index-pw9jn6kz.js +574 -0
  904. package/dist/index-pyeycp3f.js +74 -0
  905. package/dist/index-q23xf3vr.js +479 -0
  906. package/dist/index-q31ne0xa.js +412 -0
  907. package/dist/index-q34rvh5a.js +247 -0
  908. package/dist/index-q5errwrj.js +904 -0
  909. package/dist/index-q5nhzc9m.js +1217 -0
  910. package/dist/index-q8f4kawk.js +204 -0
  911. package/dist/index-qer8zv2r.js +997 -0
  912. package/dist/index-qf2dkqxh.js +249 -0
  913. package/dist/index-qhyy018y.js +467 -0
  914. package/dist/index-qmhdydwy.js +70 -0
  915. package/dist/index-qmtdf7k5.js +639 -0
  916. package/dist/index-qpmvca5j.js +470 -0
  917. package/dist/index-qr96vaj1.js +52 -0
  918. package/dist/index-qtyhg3dn.js +904 -0
  919. package/dist/index-qwgr4q7s.js +37 -0
  920. package/dist/index-qye17gq5.js +264 -0
  921. package/dist/index-r0839f5k.js +133 -0
  922. package/dist/index-r1rqg72v.js +1372 -0
  923. package/dist/index-rab2dfh3.js +494 -0
  924. package/dist/index-rbckga8p.js +971 -0
  925. package/dist/index-rbxb5x2w.js +1372 -0
  926. package/dist/index-rck779bj.js +739 -0
  927. package/dist/index-rfn2gt5f.js +1658 -0
  928. package/dist/index-rg21w26a.js +470 -0
  929. package/dist/index-rgcz45t0.js +1372 -0
  930. package/dist/index-rhnd376q.js +133 -0
  931. package/dist/index-rjc5z3w6.js +971 -0
  932. package/dist/index-rkhtayd6.js +385 -0
  933. package/dist/index-rm8srzmv.js +371 -0
  934. package/dist/index-rmhk5j03.js +968 -0
  935. package/dist/index-rp4t86bt.js +993 -0
  936. package/dist/index-rpq5ktdy.js +264 -0
  937. package/dist/index-rpsmhdd4.js +1218 -0
  938. package/dist/index-rqpakjyr.js +470 -0
  939. package/dist/index-rttk33x6.js +232 -0
  940. package/dist/index-rwa82e89.js +385 -0
  941. package/dist/index-rz185crv.js +695 -0
  942. package/dist/index-rz7rx80s.js +1410 -0
  943. package/dist/index-s22verzj.js +1218 -0
  944. package/dist/index-s2s3g1nt.js +133 -0
  945. package/dist/index-s37h3jgk.js +572 -0
  946. package/dist/index-s7ytytth.js +781 -0
  947. package/dist/index-sb705m7d.js +52 -0
  948. package/dist/index-sefnpzwa.js +185 -0
  949. package/dist/index-sgxw0xzd.js +513 -0
  950. package/dist/index-stc0caq6.js +1009 -0
  951. package/dist/index-stgn34cr.js +148 -0
  952. package/dist/index-svz82w9h.js +513 -0
  953. package/dist/index-sx49e8x9.js +884 -0
  954. package/dist/index-sxadwvw9.js +185 -0
  955. package/dist/index-sxn223fz.js +1372 -0
  956. package/dist/index-sy0c2mh0.js +1372 -0
  957. package/dist/index-syeh1hca.js +264 -0
  958. package/dist/index-syscwrjp.js +1576 -0
  959. package/dist/index-t14zr0ys.js +1063 -0
  960. package/dist/index-t18wyhgf.js +418 -0
  961. package/dist/index-t4fhcx1n.js +71 -0
  962. package/dist/index-td4hbgj5.js +1372 -0
  963. package/dist/index-tjc99447.js +68 -0
  964. package/dist/index-tkvt9mmq.js +484 -0
  965. package/dist/index-tmmcf4m6.js +808 -0
  966. package/dist/index-tpgs5v64.js +366 -0
  967. package/dist/index-tt4fsv91.js +412 -0
  968. package/dist/{index-07q6yxyc.js → index-tte89s31.js} +30 -29
  969. package/dist/index-tvjg7swe.js +1372 -0
  970. package/dist/index-txndxr4w.js +513 -0
  971. package/dist/index-tyh5jc55.js +990 -0
  972. package/dist/index-tyt0wa52.js +470 -0
  973. package/dist/index-tyt3wcfr.js +1372 -0
  974. package/dist/index-v35460hf.js +574 -0
  975. package/dist/index-v3znz08m.js +968 -0
  976. package/dist/index-v78xbj6n.js +808 -0
  977. package/dist/index-v7q00d1e.js +1410 -0
  978. package/dist/index-v915brjk.js +1372 -0
  979. package/dist/index-v922fmsx.js +52 -0
  980. package/dist/index-v9w1bbfe.js +842 -0
  981. package/dist/index-vbbgtm8p.js +513 -0
  982. package/dist/index-vcjgrmzj.js +456 -0
  983. package/dist/{index-pf5s73n9.js → index-vdewcg1r.js} +243 -385
  984. package/dist/index-vhqww6tt.js +307 -0
  985. package/dist/index-vkkmx4xe.js +1372 -0
  986. package/dist/index-vrps1gky.js +2202 -0
  987. package/dist/index-vse8620z.js +1372 -0
  988. package/dist/index-vt803j3b.js +1372 -0
  989. package/dist/index-vtjp46c3.js +52 -0
  990. package/dist/index-vxhxk8mf.js +904 -0
  991. package/dist/index-w3azfsa0.js +695 -0
  992. package/dist/index-w4c9vmvg.js +1517 -0
  993. package/dist/index-w4tq35dn.js +52 -0
  994. package/dist/index-w5qxvxzq.js +991 -0
  995. package/dist/index-w5sedpqn.js +986 -0
  996. package/dist/index-waha3chv.js +1230 -0
  997. package/dist/index-wdxww0kj.js +1006 -0
  998. package/dist/index-wdy5y07x.js +1372 -0
  999. package/dist/index-wf9pnh6j.js +385 -0
  1000. package/dist/{index-z14anrqp.js → index-wfbfz02q.js} +14 -15
  1001. package/dist/index-wnnbbbkt.js +1192 -0
  1002. package/dist/index-wqd8n2qk.js +574 -0
  1003. package/dist/index-wvcmvtjf.js +1372 -0
  1004. package/dist/index-x0jbntp0.js +470 -0
  1005. package/dist/index-x12e6fzy.js +476 -0
  1006. package/dist/index-x6scc3nx.js +70 -0
  1007. package/dist/index-x8e2wsbv.js +971 -0
  1008. package/dist/index-xagpz645.js +2199 -0
  1009. package/dist/index-xbth1r6e.js +572 -0
  1010. package/dist/index-xec4p3v5.js +560 -0
  1011. package/dist/index-xgfyxpfs.js +1218 -0
  1012. package/dist/index-xm9fqhcb.js +447 -0
  1013. package/dist/index-xm9hp9xc.js +1372 -0
  1014. package/dist/index-xp7zkxcx.js +1372 -0
  1015. package/dist/index-xrbj0ebk.js +185 -0
  1016. package/dist/index-xskax7r3.js +50 -0
  1017. package/dist/index-xvk5n96q.js +694 -0
  1018. package/dist/index-xy1jvt4w.js +1229 -0
  1019. package/dist/index-xzg9hhf3.js +470 -0
  1020. package/dist/index-xzpg0kaz.js +70 -0
  1021. package/dist/index-y1d8za14.js +196 -0
  1022. package/dist/index-y3q6qvv3.js +316 -0
  1023. package/dist/index-y44ts1dk.js +52 -0
  1024. package/dist/index-y59hnmd0.js +132 -0
  1025. package/dist/index-y5nt1wjb.js +971 -0
  1026. package/dist/index-y7mkb00x.js +133 -0
  1027. package/dist/index-y82b8w14.js +1372 -0
  1028. package/dist/index-yb07t3c5.js +1372 -0
  1029. package/dist/index-yc3xz3vm.js +431 -0
  1030. package/dist/index-yeaqrevg.js +1372 -0
  1031. package/dist/index-ygwsd1nn.js +438 -0
  1032. package/dist/index-yhdavjk7.js +371 -0
  1033. package/dist/index-yjhns95b.js +188 -0
  1034. package/dist/index-yk23p7he.js +1372 -0
  1035. package/dist/index-ykfgpsmm.js +190 -0
  1036. package/dist/index-ymz3cfab.js +968 -0
  1037. package/dist/index-yq9g1sq7.js +264 -0
  1038. package/dist/index-ys5q9ch9.js +366 -0
  1039. package/dist/index-yt0n4p46.js +973 -0
  1040. package/dist/index-ytq1t9jx.js +232 -0
  1041. package/dist/index-ywmtmf3b.js +513 -0
  1042. package/dist/index-yzb44q6d.js +1372 -0
  1043. package/dist/index-z043xk61.js +133 -0
  1044. package/dist/index-z0gsf674.js +431 -0
  1045. package/dist/index-z32n0ndp.js +1372 -0
  1046. package/dist/index-z40mjts9.js +212 -0
  1047. package/dist/index-z4qgk76w.js +1372 -0
  1048. package/dist/index-z5k5bjc7.js +1218 -0
  1049. package/dist/index-z73sytma.js +895 -0
  1050. package/dist/index-z8njfj2g.js +385 -0
  1051. package/dist/index-z9fjnwa8.js +397 -0
  1052. package/dist/{index-1xpj0m4r.js → index-z9gy8w6b.js} +1 -1
  1053. package/dist/index-zapkc14c.js +264 -0
  1054. package/dist/index-zes6w8yr.js +185 -0
  1055. package/dist/index-zgrqest7.js +695 -0
  1056. package/dist/index-zjv6apef.js +1410 -0
  1057. package/dist/index-zsngz131.js +1372 -0
  1058. package/dist/index-zt22fe2j.js +54 -0
  1059. package/dist/index-zxhc6sb0.js +192 -0
  1060. package/dist/index.d.ts +2 -6
  1061. package/dist/index.d.ts.map +1 -1
  1062. package/dist/index.js +32 -269
  1063. package/dist/{init-f9mgmew3.js → init-cwpergap.js} +63 -69
  1064. package/dist/init-wfh63bfz.js +180 -0
  1065. package/dist/login-1amyp1jy.js +77 -0
  1066. package/dist/login-1cdwn1dj.js +77 -0
  1067. package/dist/login-456h8jk3.js +77 -0
  1068. package/dist/login-4n470c4j.js +77 -0
  1069. package/dist/login-4sh7s849.js +77 -0
  1070. package/dist/login-5dmkf0pz.js +77 -0
  1071. package/dist/login-7yex6ppq.js +77 -0
  1072. package/dist/login-83bjfhvz.js +77 -0
  1073. package/dist/login-88tp4gbb.js +77 -0
  1074. package/dist/login-b51faqpc.js +77 -0
  1075. package/dist/login-bxyjqmbj.js +77 -0
  1076. package/dist/login-c4649qss.js +77 -0
  1077. package/dist/login-d80a2qxd.js +77 -0
  1078. package/dist/login-ddw888xb.js +77 -0
  1079. package/dist/login-dp0napaz.js +77 -0
  1080. package/dist/login-e7pytkdc.js +77 -0
  1081. package/dist/login-fe0brfcr.js +77 -0
  1082. package/dist/login-h7sm5trm.js +77 -0
  1083. package/dist/login-j3r6z2t4.js +77 -0
  1084. package/dist/login-jkfkdjg4.js +77 -0
  1085. package/dist/login-kch6f2yj.js +77 -0
  1086. package/dist/login-pmqh94ws.js +77 -0
  1087. package/dist/login-rc82x5j8.js +77 -0
  1088. package/dist/login-tvppwyx2.js +77 -0
  1089. package/dist/login-vd0m3xr4.js +77 -0
  1090. package/dist/login-w76jx22q.js +77 -0
  1091. package/dist/login-ze7y36rc.js +77 -0
  1092. package/dist/previews-02jmcwft.js +1214 -0
  1093. package/dist/previews-2wfvsjfy.js +1337 -0
  1094. package/dist/previews-31bq82km.js +1225 -0
  1095. package/dist/previews-31feb8r3.js +1337 -0
  1096. package/dist/previews-3w4pxqby.js +1337 -0
  1097. package/dist/previews-62pcvvpe.js +1214 -0
  1098. package/dist/previews-6fepv94a.js +1225 -0
  1099. package/dist/previews-76fxkp59.js +1214 -0
  1100. package/dist/previews-844bp6kf.js +1214 -0
  1101. package/dist/previews-8amn46qv.js +1214 -0
  1102. package/dist/previews-93ttrf5f.js +1337 -0
  1103. package/dist/previews-a5xbkksy.js +1214 -0
  1104. package/dist/previews-bdrefjzx.js +1337 -0
  1105. package/dist/previews-bgnryzav.js +1214 -0
  1106. package/dist/previews-bkhv9dnr.js +1214 -0
  1107. package/dist/previews-c2c64z5m.js +1214 -0
  1108. package/dist/previews-cfcn56b4.js +1337 -0
  1109. package/dist/previews-e4wgscsb.js +1214 -0
  1110. package/dist/previews-ew4reetn.js +1214 -0
  1111. package/dist/previews-hzqke1fg.js +1214 -0
  1112. package/dist/previews-j8wa3sge.js +1214 -0
  1113. package/dist/previews-k5n6vhpm.js +1214 -0
  1114. package/dist/previews-mssq1hrm.js +1337 -0
  1115. package/dist/previews-n4sdyxa5.js +1214 -0
  1116. package/dist/previews-npwrwb0b.js +1214 -0
  1117. package/dist/previews-q8ph9wbe.js +1214 -0
  1118. package/dist/previews-rfswrh7q.js +1214 -0
  1119. package/dist/previews-s0y5yp8s.js +1214 -0
  1120. package/dist/previews-s5b6mnz5.js +1214 -0
  1121. package/dist/previews-sdte4984.js +1200 -0
  1122. package/dist/previews-t5tdm6t0.js +1225 -0
  1123. package/dist/previews-tcaz1gt8.js +1337 -0
  1124. package/dist/previews-tk7vpzj9.js +1214 -0
  1125. package/dist/previews-tqt4pk27.js +1214 -0
  1126. package/dist/previews-vqg4psk2.js +1225 -0
  1127. package/dist/productions-2t9q8f57.js +505 -0
  1128. package/dist/productions-4abj58kx.js +505 -0
  1129. package/dist/productions-4dpec71r.js +505 -0
  1130. package/dist/productions-4h80j2c7.js +505 -0
  1131. package/dist/productions-4nedsanh.js +505 -0
  1132. package/dist/productions-5c58yafp.js +505 -0
  1133. package/dist/productions-5xq5cjhx.js +505 -0
  1134. package/dist/productions-6dr0bmd7.js +505 -0
  1135. package/dist/productions-86jaqt7m.js +505 -0
  1136. package/dist/productions-8f6s8dqr.js +505 -0
  1137. package/dist/productions-a2hcwwzf.js +505 -0
  1138. package/dist/productions-b7svyjp7.js +505 -0
  1139. package/dist/productions-bf2cnr05.js +505 -0
  1140. package/dist/productions-bn2q31my.js +505 -0
  1141. package/dist/productions-dkgry3gv.js +505 -0
  1142. package/dist/productions-dv8g7f6g.js +505 -0
  1143. package/dist/productions-e2m9s4tr.js +505 -0
  1144. package/dist/productions-eqh105tk.js +505 -0
  1145. package/dist/productions-etvcm7yf.js +505 -0
  1146. package/dist/productions-f1zpbmjz.js +505 -0
  1147. package/dist/productions-fgshs1m7.js +505 -0
  1148. package/dist/productions-hphmt68n.js +505 -0
  1149. package/dist/productions-j14pvx93.js +505 -0
  1150. package/dist/productions-j7s1ywvg.js +505 -0
  1151. package/dist/productions-jp3v3q3p.js +505 -0
  1152. package/dist/productions-m9p42amj.js +505 -0
  1153. package/dist/productions-mxbneawa.js +505 -0
  1154. package/dist/productions-np4exh9p.js +505 -0
  1155. package/dist/productions-rr1hqgda.js +505 -0
  1156. package/dist/productions-rtf9ksgg.js +505 -0
  1157. package/dist/productions-vhq7yx86.js +505 -0
  1158. package/dist/productions-w2nzftcz.js +505 -0
  1159. package/dist/productions-wbks5h7e.js +505 -0
  1160. package/dist/productions-y99ayk6h.js +505 -0
  1161. package/dist/productions-zpqyw5gm.js +505 -0
  1162. package/dist/router/types.d.ts +24 -0
  1163. package/dist/router/types.d.ts.map +1 -0
  1164. package/dist/runtime/context-events.d.ts +13 -0
  1165. package/dist/runtime/context-events.d.ts.map +1 -0
  1166. package/dist/runtime/context-types.d.ts +82 -0
  1167. package/dist/runtime/context-types.d.ts.map +1 -0
  1168. package/dist/runtime/context.d.ts +27 -40
  1169. package/dist/runtime/context.d.ts.map +1 -1
  1170. package/dist/runtime/exports.d.ts +47 -55
  1171. package/dist/runtime/exports.d.ts.map +1 -1
  1172. package/dist/runtime/index.d.ts +8 -1
  1173. package/dist/runtime/index.d.ts.map +1 -1
  1174. package/dist/runtime/index.js +108 -99
  1175. package/dist/runtime/middleware.d.ts +102 -60
  1176. package/dist/runtime/middleware.d.ts.map +1 -1
  1177. package/dist/runtime/router/index.d.ts +7 -0
  1178. package/dist/runtime/router/index.d.ts.map +1 -0
  1179. package/dist/runtime/router/types.d.ts +24 -0
  1180. package/dist/runtime/router/types.d.ts.map +1 -0
  1181. package/dist/runtime/router.d.ts +7 -0
  1182. package/dist/runtime/router.d.ts.map +1 -0
  1183. package/dist/runtime/validation.d.ts +10 -2
  1184. package/dist/runtime/validation.d.ts.map +1 -1
  1185. package/dist/secrets/local-secrets.d.ts +46 -0
  1186. package/dist/secrets/local-secrets.d.ts.map +1 -0
  1187. package/dist/secrets-8wcj47nh.js +91 -0
  1188. package/dist/secrets-b2ww34ta.js +91 -0
  1189. package/dist/secrets-b7g4z621.js +91 -0
  1190. package/dist/shims/local-media-bindings.d.ts +19 -0
  1191. package/dist/shims/local-media-bindings.d.ts.map +1 -0
  1192. package/dist/shims/local-worker-loader.d.ts +3 -0
  1193. package/dist/shims/local-worker-loader.d.ts.map +1 -0
  1194. package/dist/sveltekit/index.js +187 -75
  1195. package/dist/sveltekit/local-bindings.d.ts +4 -0
  1196. package/dist/sveltekit/local-bindings.d.ts.map +1 -0
  1197. package/dist/sveltekit/platform.d.ts +19 -1
  1198. package/dist/sveltekit/platform.d.ts.map +1 -1
  1199. package/dist/test/ai-search.d.ts +39 -0
  1200. package/dist/test/ai-search.d.ts.map +1 -0
  1201. package/dist/test/binding-hints.d.ts +11 -0
  1202. package/dist/test/binding-hints.d.ts.map +1 -0
  1203. package/dist/test/bridge-context.d.ts +12 -2
  1204. package/dist/test/bridge-context.d.ts.map +1 -1
  1205. package/dist/test/cf.d.ts +35 -21
  1206. package/dist/test/cf.d.ts.map +1 -1
  1207. package/dist/test/containers.d.ts +87 -0
  1208. package/dist/test/containers.d.ts.map +1 -0
  1209. package/dist/test/email.d.ts +16 -7
  1210. package/dist/test/email.d.ts.map +1 -1
  1211. package/dist/test/index.d.ts +5 -8
  1212. package/dist/test/index.d.ts.map +1 -1
  1213. package/dist/test/index.js +4976 -46
  1214. package/dist/test/local-worker-loader.d.ts +3 -0
  1215. package/dist/test/local-worker-loader.d.ts.map +1 -0
  1216. package/dist/test/offline-bindings.d.ts +65 -0
  1217. package/dist/test/offline-bindings.d.ts.map +1 -0
  1218. package/dist/test/queue.d.ts.map +1 -1
  1219. package/dist/test/remote-ai.d.ts.map +1 -1
  1220. package/dist/test/remote-cloudflare.d.ts +13 -0
  1221. package/dist/test/remote-cloudflare.d.ts.map +1 -0
  1222. package/dist/test/remote-vectorize.d.ts.map +1 -1
  1223. package/dist/test/resolve-service-bindings.d.ts.map +1 -1
  1224. package/dist/test/scheduled.d.ts.map +1 -1
  1225. package/dist/test/should-skip.d.ts +14 -18
  1226. package/dist/test/should-skip.d.ts.map +1 -1
  1227. package/dist/test/simple-context-bindings.d.ts +13 -0
  1228. package/dist/test/simple-context-bindings.d.ts.map +1 -0
  1229. package/dist/test/simple-context-durable-objects.d.ts +6 -0
  1230. package/dist/test/simple-context-durable-objects.d.ts.map +1 -0
  1231. package/dist/test/simple-context-env.d.ts +35 -0
  1232. package/dist/test/simple-context-env.d.ts.map +1 -0
  1233. package/dist/test/simple-context-gateway-script.d.ts +2 -0
  1234. package/dist/test/simple-context-gateway-script.d.ts.map +1 -0
  1235. package/dist/test/simple-context-handlers.d.ts +12 -0
  1236. package/dist/test/simple-context-handlers.d.ts.map +1 -0
  1237. package/dist/test/simple-context-lifecycle.d.ts +32 -0
  1238. package/dist/test/simple-context-lifecycle.d.ts.map +1 -0
  1239. package/dist/test/simple-context-mfconfig.d.ts +10 -0
  1240. package/dist/test/simple-context-mfconfig.d.ts.map +1 -0
  1241. package/dist/test/simple-context-multi-worker.d.ts +16 -0
  1242. package/dist/test/simple-context-multi-worker.d.ts.map +1 -0
  1243. package/dist/test/simple-context-paths.d.ts +40 -0
  1244. package/dist/test/simple-context-paths.d.ts.map +1 -0
  1245. package/dist/test/simple-context-runtime.d.ts +19 -0
  1246. package/dist/test/simple-context-runtime.d.ts.map +1 -0
  1247. package/dist/test/simple-context-startup.d.ts +11 -0
  1248. package/dist/test/simple-context-startup.d.ts.map +1 -0
  1249. package/dist/test/simple-context-transport.d.ts +14 -0
  1250. package/dist/test/simple-context-transport.d.ts.map +1 -0
  1251. package/dist/test/simple-context.d.ts +7 -26
  1252. package/dist/test/simple-context.d.ts.map +1 -1
  1253. package/dist/test/tail.d.ts +2 -1
  1254. package/dist/test/tail.d.ts.map +1 -1
  1255. package/dist/test/utilities/artifacts.d.ts +11 -0
  1256. package/dist/test/utilities/artifacts.d.ts.map +1 -0
  1257. package/dist/test/utilities/context.d.ts +39 -0
  1258. package/dist/test/utilities/context.d.ts.map +1 -0
  1259. package/dist/test/utilities/d1.d.ts +21 -0
  1260. package/dist/test/utilities/d1.d.ts.map +1 -0
  1261. package/dist/test/utilities/env.d.ts +40 -0
  1262. package/dist/test/utilities/env.d.ts.map +1 -0
  1263. package/dist/test/utilities/kv.d.ts +11 -0
  1264. package/dist/test/utilities/kv.d.ts.map +1 -0
  1265. package/dist/test/utilities/media.d.ts +16 -0
  1266. package/dist/test/utilities/media.d.ts.map +1 -0
  1267. package/dist/test/utilities/platform.d.ts +38 -0
  1268. package/dist/test/utilities/platform.d.ts.map +1 -0
  1269. package/dist/test/utilities/queue.d.ts +5 -0
  1270. package/dist/test/utilities/queue.d.ts.map +1 -0
  1271. package/dist/test/utilities/r2.d.ts +12 -0
  1272. package/dist/test/utilities/r2.d.ts.map +1 -0
  1273. package/dist/test/utilities/workflows.d.ts +26 -0
  1274. package/dist/test/utilities/workflows.d.ts.map +1 -0
  1275. package/dist/test/utilities.d.ts +10 -98
  1276. package/dist/test/utilities.d.ts.map +1 -1
  1277. package/dist/test/worker.d.ts +6 -0
  1278. package/dist/test/worker.d.ts.map +1 -1
  1279. package/dist/token-3b9wws58.js +419 -0
  1280. package/dist/token-47kcz18j.js +419 -0
  1281. package/dist/token-a2b38w0z.js +419 -0
  1282. package/dist/token-exz78pth.js +419 -0
  1283. package/dist/token-fcthx92c.js +419 -0
  1284. package/dist/token-grwp8z4q.js +419 -0
  1285. package/dist/token-jkmm44z2.js +419 -0
  1286. package/dist/token-qxtvzm3b.js +419 -0
  1287. package/dist/token-rq8mvtz9.js +419 -0
  1288. package/dist/token-sct51r47.js +419 -0
  1289. package/dist/token-sfgxcgen.js +419 -0
  1290. package/dist/transform/durable-object.d.ts.map +1 -1
  1291. package/dist/transform/worker-entrypoint.d.ts +5 -0
  1292. package/dist/transform/worker-entrypoint.d.ts.map +1 -1
  1293. package/dist/{types-5nyrz1sz.js → types-0qv4xces.js} +266 -148
  1294. package/dist/types-2ejrbba1.js +695 -0
  1295. package/dist/types-2nvrs9jg.js +572 -0
  1296. package/dist/types-2pbe8kzw.js +572 -0
  1297. package/dist/types-2zyt0m43.js +572 -0
  1298. package/dist/types-4xxer9ep.js +572 -0
  1299. package/dist/types-5t5y7a5n.js +572 -0
  1300. package/dist/types-5wd2rygw.js +572 -0
  1301. package/dist/types-7j3ykgx7.js +572 -0
  1302. package/dist/types-7jkbm95a.js +695 -0
  1303. package/dist/types-8g78x34n.js +572 -0
  1304. package/dist/types-a2fk9yns.js +695 -0
  1305. package/dist/types-dyb3c6zw.js +695 -0
  1306. package/dist/types-e2n9f3pd.js +695 -0
  1307. package/dist/types-e6d336q3.js +572 -0
  1308. package/dist/types-hqh2fx0x.js +572 -0
  1309. package/dist/types-j12xmdnd.js +572 -0
  1310. package/dist/types-j4s6qcrc.js +695 -0
  1311. package/dist/types-jqn26et3.js +572 -0
  1312. package/dist/types-n0mxbq26.js +572 -0
  1313. package/dist/types-naz9hvw5.js +572 -0
  1314. package/dist/types-qjcd1jks.js +572 -0
  1315. package/dist/types-r9zb8sw1.js +572 -0
  1316. package/dist/types-rv5xwgsn.js +572 -0
  1317. package/dist/types-t39njdqx.js +572 -0
  1318. package/dist/types-tkgch3xv.js +572 -0
  1319. package/dist/types-vvtb7rrh.js +572 -0
  1320. package/dist/types-w1grncdj.js +572 -0
  1321. package/dist/types-wmw49exb.js +572 -0
  1322. package/dist/types-ymxz9jga.js +572 -0
  1323. package/dist/utils/entrypoint-discovery.d.ts +6 -3
  1324. package/dist/utils/entrypoint-discovery.d.ts.map +1 -1
  1325. package/dist/utils/resolve-package.d.ts.map +1 -1
  1326. package/dist/utils/send-email.d.ts +15 -0
  1327. package/dist/utils/send-email.d.ts.map +1 -0
  1328. package/dist/utils/send-email.js +19 -0
  1329. package/dist/vite/config-file.d.ts +25 -0
  1330. package/dist/vite/config-file.d.ts.map +1 -0
  1331. package/dist/vite/index.d.ts +1 -0
  1332. package/dist/vite/index.d.ts.map +1 -1
  1333. package/dist/vite/index.js +24 -331
  1334. package/dist/vite/plugin-config-hook.d.ts +28 -0
  1335. package/dist/vite/plugin-config-hook.d.ts.map +1 -0
  1336. package/dist/vite/plugin-context.d.ts +25 -0
  1337. package/dist/vite/plugin-context.d.ts.map +1 -0
  1338. package/dist/vite/plugin-durable-objects.d.ts +18 -0
  1339. package/dist/vite/plugin-durable-objects.d.ts.map +1 -0
  1340. package/dist/vite/plugin-programmatic.d.ts +44 -0
  1341. package/dist/vite/plugin-programmatic.d.ts.map +1 -0
  1342. package/dist/vite/plugin-transform.d.ts +41 -0
  1343. package/dist/vite/plugin-transform.d.ts.map +1 -0
  1344. package/dist/vite/plugin.d.ts +6 -39
  1345. package/dist/vite/plugin.d.ts.map +1 -1
  1346. package/dist/worker-18ceqscc.js +513 -0
  1347. package/dist/worker-1yqpwte2.js +513 -0
  1348. package/dist/worker-2aw27zxy.js +513 -0
  1349. package/dist/worker-45tp4a8f.js +513 -0
  1350. package/dist/worker-663em30d.js +513 -0
  1351. package/dist/worker-68zttchg.js +513 -0
  1352. package/dist/worker-729cf3fh.js +513 -0
  1353. package/dist/worker-99tew196.js +513 -0
  1354. package/dist/worker-argxc7fb.js +513 -0
  1355. package/dist/worker-aydzxt4f.js +513 -0
  1356. package/dist/worker-ejdxma7k.js +513 -0
  1357. package/dist/worker-entry/composed-worker.d.ts +7 -0
  1358. package/dist/worker-entry/composed-worker.d.ts.map +1 -0
  1359. package/dist/worker-entry/durable-object-discovery.d.ts +20 -0
  1360. package/dist/worker-entry/durable-object-discovery.d.ts.map +1 -0
  1361. package/dist/worker-entry/extensions.d.ts +5 -0
  1362. package/dist/worker-entry/extensions.d.ts.map +1 -0
  1363. package/dist/worker-entry/routes.d.ts +22 -0
  1364. package/dist/worker-entry/routes.d.ts.map +1 -0
  1365. package/dist/worker-entry/surface-paths.d.ts +26 -0
  1366. package/dist/worker-entry/surface-paths.d.ts.map +1 -0
  1367. package/dist/worker-entrypoint-4xp7msd7.js +16 -0
  1368. package/dist/{worker-entrypoint-m9th0rg0.js → worker-entrypoint-c259fmfs.js} +1 -1
  1369. package/dist/worker-entrypoint-f1v9y4s8.js +15 -0
  1370. package/dist/worker-f6xqjg65.js +513 -0
  1371. package/dist/worker-fcdsnj14.js +513 -0
  1372. package/dist/worker-fdnn62de.js +513 -0
  1373. package/dist/worker-fk42rzse.js +513 -0
  1374. package/dist/worker-frnh95rg.js +513 -0
  1375. package/dist/worker-jkemk8d2.js +513 -0
  1376. package/dist/worker-k55nfrmp.js +513 -0
  1377. package/dist/worker-kqc6w7ry.js +513 -0
  1378. package/dist/worker-ksvcq8be.js +513 -0
  1379. package/dist/worker-m4ze8djx.js +513 -0
  1380. package/dist/worker-mjzfstv5.js +513 -0
  1381. package/dist/worker-p4rtsndj.js +513 -0
  1382. package/dist/worker-p6d53qan.js +513 -0
  1383. package/dist/worker-qh2qbv97.js +513 -0
  1384. package/dist/worker-r234vnv9.js +513 -0
  1385. package/dist/worker-r47bv7gt.js +513 -0
  1386. package/dist/worker-s4nvbqsm.js +513 -0
  1387. package/dist/worker-ttj7vwce.js +513 -0
  1388. package/dist/worker-wnan5dca.js +513 -0
  1389. package/dist/worker-wv4jdneg.js +513 -0
  1390. package/dist/worker-xcbscr75.js +513 -0
  1391. package/dist/worker-yw3atfb1.js +513 -0
  1392. package/dist/worker-ywwkf3cp.js +513 -0
  1393. package/dist/worker-z8wtk0sh.js +513 -0
  1394. package/dist/workflows/local-workflow-entrypoints.d.ts +7 -0
  1395. package/dist/workflows/local-workflow-entrypoints.d.ts.map +1 -0
  1396. package/package.json +140 -115
  1397. package/dist/account-rvrj687w.js +0 -397
  1398. package/dist/browser-shim/worker.d.ts +0 -14
  1399. package/dist/browser-shim/worker.d.ts.map +0 -1
  1400. package/dist/build-mnf6v8gd.js +0 -53
  1401. package/dist/deploy-nhceck39.js +0 -70
  1402. package/dist/doctor-e8fy6fj5.js +0 -186
  1403. package/dist/index-67qcae0f.js +0 -183
  1404. package/dist/index-ep3445yc.js +0 -2225
  1405. package/dist/index-hcex3rgh.js +0 -266
  1406. package/dist/index-m2q41jwa.js +0 -462
  1407. package/dist/index-n7rs26ft.js +0 -77
  1408. package/dist/index-tfyxa77h.js +0 -850
  1409. package/dist/index-tk6ej9dj.js +0 -94
  1410. package/dist/test/multi-worker-context.d.ts +0 -114
  1411. package/dist/test/multi-worker-context.d.ts.map +0 -1
@@ -0,0 +1,2433 @@
1
+ import {
2
+ bundleWorkerEntry,
3
+ createDOBundler
4
+ } from "./index-sx49e8x9.js";
5
+ import {
6
+ detectViteProject,
7
+ resolveViteMode,
8
+ stopSpawnedProcessTree,
9
+ waitForViteReady
10
+ } from "./index-gn5wy09x.js";
11
+ import {
12
+ createCliTheme,
13
+ cyanBold,
14
+ dim,
15
+ logLine,
16
+ yellow
17
+ } from "./index-stgn34cr.js";
18
+ import"./index-3t6rypgc.js";
19
+ import {
20
+ DEFAULT_EMAIL_ENTRY_FILES,
21
+ DEFAULT_FETCH_ENTRY_FILES,
22
+ DEFAULT_QUEUE_ENTRY_FILES,
23
+ DEFAULT_SCHEDULED_ENTRY_FILES,
24
+ hasWorkerSurfacePaths,
25
+ prepareComposedWorkerEntrypoint,
26
+ resolveEffectiveViteProject,
27
+ resolveWorkerSurfacePaths,
28
+ writeGeneratedViteConfig
29
+ } from "./index-ntddf5d9.js";
30
+ import {
31
+ discoverRoutes,
32
+ getRouteDirectoryCandidate
33
+ } from "./index-3e7by9sy.js";
34
+ import"./index-rbht7m9r.js";
35
+ import"./index-65e7xx1a.js";
36
+ import"./index-vhqww6tt.js";
37
+ import {
38
+ GATEWAY_RUNTIME_JS
39
+ } from "./index-852945d4.js";
40
+ import {
41
+ clearLocalSendEmailBindings,
42
+ setLocalSendEmailBindings
43
+ } from "./index-124e9t4t.js";
44
+ import"./index-h8r2d8y5.js";
45
+ import {
46
+ getLocalD1DatabaseIdentifier,
47
+ getLocalKVNamespaceIdentifier,
48
+ getSingleBrowserBindingName,
49
+ loadConfig,
50
+ resolveConfigPath
51
+ } from "./index-bc5pvbbd.js";
52
+ import"./index-gba371j7.js";
53
+ import"./index-abrqnq3e.js";
54
+ import"./index-p296ban8.js";
55
+ import"./index-ykfgpsmm.js";
56
+ import {
57
+ __require
58
+ } from "./index-37x76zdn.js";
59
+
60
+ // src/cli/commands/dev.ts
61
+ import { createConsola } from "consola";
62
+ import { relative, resolve as resolve6 } from "pathe";
63
+
64
+ // src/dev-server/server.ts
65
+ import { resolve as resolve5 } from "pathe";
66
+
67
+ // src/cli/wrangler-auth.ts
68
+ import { exec } from "node:child_process";
69
+ import { promisify } from "node:util";
70
+ var execAsync = promisify(exec);
71
+ function detectRemoteBindings(config) {
72
+ const remoteBindings = [];
73
+ const bindings = config.bindings;
74
+ if (!bindings)
75
+ return remoteBindings;
76
+ if (bindings.ai) {
77
+ remoteBindings.push(`AI (binding: ${bindings.ai.binding})`);
78
+ }
79
+ if (bindings.vectorize) {
80
+ for (const [name] of Object.entries(bindings.vectorize)) {
81
+ remoteBindings.push(`Vectorize (binding: ${name})`);
82
+ }
83
+ }
84
+ return remoteBindings;
85
+ }
86
+ async function checkWranglerAuth() {
87
+ try {
88
+ const { stdout, stderr } = await execAsync("bunx wrangler whoami", {
89
+ timeout: 15000
90
+ });
91
+ const output = stdout + stderr;
92
+ if (output.includes("not authenticated") || output.includes("Not logged in") || output.includes("wrangler login")) {
93
+ return {
94
+ loggedIn: false,
95
+ error: "Not logged in to Wrangler"
96
+ };
97
+ }
98
+ const emailMatch = output.match(/email[:\s]+([^\s!]+)/i);
99
+ const accountMatch = output.match(/Account\s+ID[:\s]+([a-f0-9]+)/i);
100
+ return {
101
+ loggedIn: true,
102
+ email: emailMatch?.[1],
103
+ accountId: accountMatch?.[1]
104
+ };
105
+ } catch (error) {
106
+ const msg = error instanceof Error ? error.message : String(error);
107
+ if (msg.includes("ENOENT") || msg.includes("not found")) {
108
+ return {
109
+ loggedIn: false,
110
+ error: "Wrangler not installed. Run: npm install -g wrangler"
111
+ };
112
+ }
113
+ return {
114
+ loggedIn: false,
115
+ error: msg
116
+ };
117
+ }
118
+ }
119
+ async function checkRemoteBindingRequirements(config) {
120
+ const remoteBindings = detectRemoteBindings(config);
121
+ if (remoteBindings.length === 0) {
122
+ return {
123
+ hasRemoteBindings: false,
124
+ remoteBindings: [],
125
+ missingAccountId: false,
126
+ notLoggedIn: false
127
+ };
128
+ }
129
+ const missingAccountId = !config.accountId;
130
+ const authStatus = await checkWranglerAuth();
131
+ const notLoggedIn = !authStatus.loggedIn;
132
+ return {
133
+ hasRemoteBindings: true,
134
+ remoteBindings,
135
+ missingAccountId,
136
+ notLoggedIn
137
+ };
138
+ }
139
+
140
+ // src/dev-server/d1-migrations.ts
141
+ import { createHash } from "node:crypto";
142
+ import { resolve } from "pathe";
143
+ var MIGRATION_RETRY_DELAYS_MS = [500, 1000, 1500, 2000];
144
+ function collectMigrationStatements(sql) {
145
+ const cleanedSql = sql.split(`
146
+ `).filter((line) => !line.trim().startsWith("--")).join(`
147
+ `);
148
+ return cleanedSql.split(";").map((statement) => statement.trim()).filter((statement) => statement.length > 0);
149
+ }
150
+ function hashSql(sql) {
151
+ return createHash("sha256").update(sql).digest("hex");
152
+ }
153
+ function getErrorMessage(error) {
154
+ return error instanceof Error ? error.message : String(error);
155
+ }
156
+ async function waitForRetry(delayMs) {
157
+ await new Promise((resolvePromise) => setTimeout(resolvePromise, delayMs));
158
+ }
159
+ async function applyMigrationsToBinding(options) {
160
+ const { bindingName, statements, files, miniflarePort, logger } = options;
161
+ let lastError;
162
+ for (let attempt = 0;attempt <= MIGRATION_RETRY_DELAYS_MS.length; attempt++) {
163
+ if (attempt > 0) {
164
+ await waitForRetry(MIGRATION_RETRY_DELAYS_MS[attempt - 1]);
165
+ }
166
+ try {
167
+ const response = await fetch(`http://127.0.0.1:${miniflarePort}/_devflare/migrate`, {
168
+ method: "POST",
169
+ headers: { "Content-Type": "application/json" },
170
+ body: JSON.stringify({ bindingName, statements, files })
171
+ });
172
+ if (!response.ok) {
173
+ const text = await response.text();
174
+ throw new Error(`HTTP ${response.status}: ${text}`);
175
+ }
176
+ const result = await response.json();
177
+ if (result.success) {
178
+ if (Array.isArray(result.warnings)) {
179
+ for (const warning of result.warnings) {
180
+ console.warn(`[devflare] D1 migration file "${warning.filename}" for binding ${bindingName} has changed since it was applied; skipping re-apply to protect existing data.`);
181
+ }
182
+ }
183
+ const appliedCount = result.applied?.length ?? 0;
184
+ const skippedCount = result.skipped?.length ?? 0;
185
+ if (appliedCount > 0 || skippedCount > 0) {
186
+ logger?.success(`D1 migrations for ${bindingName}: ${appliedCount} applied, ${skippedCount} skipped`);
187
+ } else {
188
+ logger?.success(`D1 migrations applied to ${bindingName}`);
189
+ }
190
+ return;
191
+ }
192
+ throw new Error(result.error || "Unknown error");
193
+ } catch (error) {
194
+ lastError = error;
195
+ }
196
+ }
197
+ logger?.warn(`Failed to apply migrations to ${bindingName}: ${getErrorMessage(lastError)}`);
198
+ }
199
+ async function runD1Migrations(options) {
200
+ const { cwd, config, miniflarePort, logger } = options;
201
+ if (!config?.bindings?.d1) {
202
+ return;
203
+ }
204
+ const { existsSync, readdirSync, readFileSync, statSync } = await import("node:fs");
205
+ const migrationsDir = resolve(cwd, "migrations");
206
+ if (!existsSync(migrationsDir)) {
207
+ logger?.debug("No migrations/ directory found, skipping D1 migrations");
208
+ return;
209
+ }
210
+ const sharedFiles = readdirSync(migrationsDir).filter((file) => file.endsWith(".sql")).sort();
211
+ let sharedFileEntries = null;
212
+ if (sharedFiles.length > 0) {
213
+ sharedFileEntries = [];
214
+ for (const file of sharedFiles) {
215
+ const sql = readFileSync(resolve(migrationsDir, file), "utf-8");
216
+ const fileStatements = collectMigrationStatements(sql);
217
+ sharedFileEntries.push({
218
+ filename: file,
219
+ sha256: hashSql(sql),
220
+ statements: fileStatements
221
+ });
222
+ logger?.debug(`Shared file ${file}: ${fileStatements.length} statement(s)`);
223
+ }
224
+ }
225
+ for (const [bindingName] of Object.entries(config.bindings.d1)) {
226
+ const perBindingDir = resolve(migrationsDir, bindingName);
227
+ const hasPerBindingDir = existsSync(perBindingDir) && statSync(perBindingDir).isDirectory();
228
+ let files = [];
229
+ let sourceLabel = "";
230
+ if (hasPerBindingDir) {
231
+ const perBindingFiles = readdirSync(perBindingDir).filter((file) => file.endsWith(".sql")).sort();
232
+ if (perBindingFiles.length === 0) {
233
+ logger?.debug(`No SQL migration files in migrations/${bindingName}/, skipping ${bindingName}`);
234
+ continue;
235
+ }
236
+ for (const file of perBindingFiles) {
237
+ const sql = readFileSync(resolve(perBindingDir, file), "utf-8");
238
+ const fileStatements = collectMigrationStatements(sql);
239
+ files.push({
240
+ filename: file,
241
+ sha256: hashSql(sql),
242
+ statements: fileStatements
243
+ });
244
+ logger?.debug(`File ${bindingName}/${file}: ${fileStatements.length} statement(s)`);
245
+ }
246
+ sourceLabel = `migrations/${bindingName}/`;
247
+ } else if (sharedFileEntries !== null) {
248
+ files = sharedFileEntries;
249
+ sourceLabel = "migrations/ [shared fallback]";
250
+ } else {
251
+ logger?.debug(`No migrations found for ${bindingName}, skipping`);
252
+ continue;
253
+ }
254
+ const statements = files.flatMap((file) => file.statements);
255
+ logger?.info(`Running ${files.length} D1 migration(s) for ${bindingName} (from ${sourceLabel})`);
256
+ if (statements.length === 0) {
257
+ logger?.debug(`No executable D1 migration statements for ${bindingName}`);
258
+ continue;
259
+ }
260
+ await applyMigrationsToBinding({
261
+ bindingName,
262
+ statements,
263
+ files,
264
+ miniflarePort,
265
+ logger
266
+ });
267
+ }
268
+ }
269
+
270
+ // src/dev-server/miniflare-log.ts
271
+ var ANSI_ESCAPE_REGEX = /\u001B\[[0-9;]*m/g;
272
+ var COMPATIBILITY_DATE_FALLBACK_REGEX = /^The latest compatibility date supported by the installed Cloudflare Workers Runtime is "([^"]+)", but you've requested "([^"]+)"\. Falling back to "([^"]+)"\.\.\.$/;
273
+ function normalizeMiniflareMessage(message) {
274
+ return message.replace(ANSI_ESCAPE_REGEX, "").replace(/\s+/g, " ").trim();
275
+ }
276
+ function formatCompatibilityDateFallbackNotice(message) {
277
+ const normalizedMessage = normalizeMiniflareMessage(message);
278
+ const match = COMPATIBILITY_DATE_FALLBACK_REGEX.exec(normalizedMessage);
279
+ if (!match) {
280
+ return null;
281
+ }
282
+ const [, _supportedDate, requestedDate, fallbackDate] = match;
283
+ return `Using latest supported Cloudflare Workers Runtime compatibility date ${fallbackDate} (requested ${requestedDate})`;
284
+ }
285
+ function createCompatibilityAwareMiniflareLog(BaseLog, level, logger) {
286
+ const log = new BaseLog(level);
287
+ const originalWarn = log.warn.bind(log);
288
+ const originalInfo = log.info.bind(log);
289
+ log.warn = (message) => {
290
+ const notice = formatCompatibilityDateFallbackNotice(message);
291
+ if (!notice) {
292
+ originalWarn(message);
293
+ return;
294
+ }
295
+ if (logger) {
296
+ logger.info(notice);
297
+ return;
298
+ }
299
+ originalInfo(notice);
300
+ };
301
+ return log;
302
+ }
303
+
304
+ // src/dev-server/miniflare-dev-config.ts
305
+ import { resolve as resolve3 } from "pathe";
306
+
307
+ // src/browser-shim/binding-worker.ts
308
+ var MAX_CHUNK_SIZE = 1048575;
309
+ function getBrowserBindingScript(browserShimUrl, debug = false) {
310
+ const safeUrl = JSON.stringify(browserShimUrl);
311
+ return `
312
+ // Browser Binding Worker — Proxies puppeteer requests to external browser shim
313
+ // Handles WebSocket upgrades using WebSocketPair for @cloudflare/puppeteer compatibility
314
+
315
+ const BROWSER_SHIM_URL = ${safeUrl}
316
+ const MAX_CHUNK_SIZE = ${MAX_CHUNK_SIZE}
317
+ const DEBUG = ${debug}
318
+ const log = (...args) => DEBUG && console.log('[BrowserBinding]', ...args)
319
+
320
+ export default {
321
+ async fetch(request, env, ctx) {
322
+ const url = new URL(request.url)
323
+ const upgradeHeader = request.headers.get('Upgrade')
324
+ const isWebSocket = upgradeHeader && upgradeHeader.toLowerCase() === 'websocket'
325
+
326
+ log('Request:', url.pathname, isWebSocket ? '(WebSocket)' : '(HTTP)')
327
+
328
+ // Handle WebSocket upgrade for DevTools connection
329
+ if (url.pathname === '/v1/connectDevtools' && isWebSocket) {
330
+ return handleDevToolsWebSocket(request, url)
331
+ }
332
+
333
+ // Proxy all other requests to the browser shim server
334
+ return proxyToBrowserShim(request, url)
335
+ }
336
+ }
337
+
338
+ // Proxy HTTP requests to the external browser shim server
339
+ async function proxyToBrowserShim(request, url) {
340
+ const shimUrl = new URL(url.pathname + url.search, BROWSER_SHIM_URL)
341
+
342
+ log('Proxying to:', shimUrl.toString())
343
+
344
+ const response = await fetch(shimUrl.toString(), {
345
+ method: request.method,
346
+ headers: request.headers,
347
+ body: request.method !== 'GET' && request.method !== 'HEAD' ? request.body : undefined
348
+ })
349
+
350
+ log('Response:', response.status)
351
+
352
+ // Return the response as-is
353
+ return new Response(response.body, {
354
+ status: response.status,
355
+ statusText: response.statusText,
356
+ headers: response.headers
357
+ })
358
+ }
359
+
360
+ // Validate WebSocket close code to be in valid range
361
+ function validateCloseCode(code) {
362
+ if (typeof code !== 'number' || isNaN(code)) return 1000
363
+ if (code < 1000 || code > 4999) return 1000
364
+ return code
365
+ }
366
+
367
+ // Split a message into chunks following @cloudflare/puppeteer protocol
368
+ // First chunk has 4-byte LE length header, subsequent chunks are raw payload
369
+ function messageToChunks(message) {
370
+ const data = typeof message === 'string'
371
+ ? new TextEncoder().encode(message)
372
+ : new Uint8Array(message)
373
+
374
+ const chunks = []
375
+ const totalLength = data.length
376
+ let offset = 0
377
+ let isFirst = true
378
+
379
+ while (offset < totalLength) {
380
+ const remaining = totalLength - offset
381
+ let chunkSize
382
+
383
+ if (isFirst) {
384
+ // First chunk: 4-byte header + payload
385
+ chunkSize = Math.min(remaining, MAX_CHUNK_SIZE - 4)
386
+ const chunk = new Uint8Array(chunkSize + 4)
387
+ new DataView(chunk.buffer).setUint32(0, totalLength, true) // little-endian
388
+ chunk.set(data.subarray(offset, offset + chunkSize), 4)
389
+ chunks.push(chunk)
390
+ isFirst = false
391
+ } else {
392
+ // Subsequent chunks: raw payload only
393
+ chunkSize = Math.min(remaining, MAX_CHUNK_SIZE)
394
+ const chunk = data.subarray(offset, offset + chunkSize)
395
+ chunks.push(chunk)
396
+ }
397
+
398
+ offset += chunkSize
399
+ }
400
+
401
+ return chunks
402
+ }
403
+
404
+ // Reassemble chunks back into a complete message
405
+ // Returns null if more chunks are needed
406
+ function chunksToMessage(chunks) {
407
+ if (chunks.length === 0) return null
408
+
409
+ // First chunk must have 4-byte header
410
+ const firstChunk = chunks[0]
411
+ if (firstChunk.length < 4) return null
412
+
413
+ const expectedLength = new DataView(firstChunk.buffer, firstChunk.byteOffset).getUint32(0, true)
414
+
415
+ // Calculate total received payload
416
+ let totalReceived = firstChunk.length - 4 // first chunk payload (minus header)
417
+ for (let i = 1; i < chunks.length; i++) {
418
+ totalReceived += chunks[i].length
419
+ }
420
+
421
+ if (totalReceived < expectedLength) {
422
+ return null // Need more chunks
423
+ }
424
+
425
+ // Reassemble the message
426
+ const assembled = new Uint8Array(expectedLength)
427
+ let offset = 0
428
+
429
+ // Copy first chunk payload (skip 4-byte header)
430
+ const firstPayload = firstChunk.subarray(4)
431
+ assembled.set(firstPayload, offset)
432
+ offset += firstPayload.length
433
+
434
+ // Copy remaining chunks
435
+ for (let i = 1; i < chunks.length; i++) {
436
+ const chunk = chunks[i]
437
+ const toCopy = Math.min(chunk.length, expectedLength - offset)
438
+ assembled.set(chunk.subarray(0, toCopy), offset)
439
+ offset += toCopy
440
+ }
441
+
442
+ return new TextDecoder().decode(assembled)
443
+ }
444
+
445
+ // Handle WebSocket upgrade for DevTools connection
446
+ // Creates a WebSocketPair and proxies to Chrome's DevTools WebSocket
447
+ async function handleDevToolsWebSocket(request, url) {
448
+ const sessionId = url.searchParams.get('browser_session')
449
+ if (!sessionId) {
450
+ return new Response('browser_session parameter required', { status: 400 })
451
+ }
452
+
453
+ log('DevTools WebSocket request for session:', sessionId)
454
+
455
+ // Get session info from browser shim (includes Chrome's wsEndpoint)
456
+ const sessionUrl = new URL('/v1/session/' + sessionId, BROWSER_SHIM_URL)
457
+
458
+ // Add timeout for session fetch
459
+ const controller = new AbortController()
460
+ const timeout = setTimeout(() => controller.abort(), 5000)
461
+
462
+ let sessionRes
463
+ try {
464
+ sessionRes = await fetch(sessionUrl.toString(), { signal: controller.signal })
465
+ } catch (e) {
466
+ DEBUG && console.error('[BrowserBinding] Session fetch timeout or error:', e.message)
467
+ return new Response('Session fetch timeout', { status: 504 })
468
+ } finally {
469
+ clearTimeout(timeout)
470
+ }
471
+
472
+ if (!sessionRes.ok) {
473
+ DEBUG && console.error('[BrowserBinding] Session not found:', sessionId)
474
+ return new Response('Session not found', { status: 404 })
475
+ }
476
+
477
+ const sessionInfo = await sessionRes.json()
478
+ const wsEndpoint = sessionInfo.wsEndpoint
479
+
480
+ if (!wsEndpoint) {
481
+ DEBUG && console.error('[BrowserBinding] No wsEndpoint in session info')
482
+ return new Response('No wsEndpoint for session', { status: 500 })
483
+ }
484
+
485
+ log('Connecting to Chrome DevTools:', wsEndpoint)
486
+
487
+ // Connect to Chrome's DevTools WebSocket
488
+ // Chrome uses ws:// but fetch expects http:// for WebSocket upgrade
489
+ const chromeUrl = wsEndpoint.replace('ws://', 'http://').replace('wss://', 'https://')
490
+
491
+ const chromeRes = await fetch(chromeUrl, {
492
+ headers: { Upgrade: 'websocket' }
493
+ })
494
+
495
+ if (!chromeRes.webSocket) {
496
+ DEBUG && console.error('[BrowserBinding] Failed to connect to Chrome DevTools')
497
+ return new Response('Failed to connect to Chrome DevTools', { status: 502 })
498
+ }
499
+
500
+ const chromeWs = chromeRes.webSocket
501
+ chromeWs.accept()
502
+
503
+ log('Connected to Chrome DevTools')
504
+
505
+ // Create WebSocketPair for client connection
506
+ const { 0: client, 1: server } = new WebSocketPair()
507
+ server.accept()
508
+
509
+ // Chunk buffer for reassembling multi-chunk messages from puppeteer
510
+ let chunks = []
511
+ const MAX_BUFFER_SIZE = 50 * 1024 * 1024 // 50MB max buffer
512
+ let bufferSize = 0
513
+
514
+ // Proxy messages from client (puppeteer) to Chrome
515
+ // Handle multi-chunk framing protocol
516
+ server.addEventListener('message', (event) => {
517
+ // Keep-alive ping from puppeteer
518
+ if (event.data === 'ping') {
519
+ return
520
+ }
521
+
522
+ // Handle binary data (chunked protocol)
523
+ if (event.data instanceof ArrayBuffer) {
524
+ const chunk = new Uint8Array(event.data)
525
+ bufferSize += chunk.length
526
+
527
+ // Prevent unbounded buffering
528
+ if (bufferSize > MAX_BUFFER_SIZE) {
529
+ DEBUG && console.error('[BrowserBinding] Buffer overflow, closing connection')
530
+ server.close(1009, 'Message too big')
531
+ chromeWs.close(1009, 'Message too big')
532
+ return
533
+ }
534
+
535
+ chunks.push(chunk)
536
+
537
+ // Try to reassemble complete message
538
+ const message = chunksToMessage(chunks)
539
+ if (message !== null) {
540
+ // Send complete message to Chrome
541
+ if (chromeWs.readyState === 1) { // OPEN
542
+ chromeWs.send(message)
543
+ }
544
+ // Clear buffer
545
+ chunks = []
546
+ bufferSize = 0
547
+ }
548
+ } else if (typeof event.data === 'string') {
549
+ // Shouldn't happen in normal protocol, but handle it
550
+ if (chromeWs.readyState === 1) {
551
+ chromeWs.send(event.data)
552
+ }
553
+ }
554
+ })
555
+
556
+ // Proxy messages from Chrome to client (puppeteer)
557
+ // Split into chunks following the multi-chunk protocol
558
+ chromeWs.addEventListener('message', (event) => {
559
+ if (server.readyState !== 1) return // Not OPEN
560
+
561
+ // Split message into chunks
562
+ const outChunks = messageToChunks(event.data)
563
+ for (const chunk of outChunks) {
564
+ server.send(chunk)
565
+ }
566
+ })
567
+
568
+ // Handle close events with validated codes
569
+ server.addEventListener('close', (event) => {
570
+ log('Client WebSocket closed:', event.code)
571
+ const code = validateCloseCode(event.code)
572
+ try {
573
+ if (chromeWs.readyState === 1 || chromeWs.readyState === 0) {
574
+ chromeWs.close(code, event.reason || '')
575
+ }
576
+ } catch {}
577
+ })
578
+
579
+ chromeWs.addEventListener('close', (event) => {
580
+ log('Chrome WebSocket closed:', event.code)
581
+ const code = validateCloseCode(event.code)
582
+ try {
583
+ if (server.readyState === 1 || server.readyState === 0) {
584
+ server.close(code, event.reason || '')
585
+ }
586
+ } catch {}
587
+ })
588
+
589
+ // Handle errors
590
+ server.addEventListener('error', (event) => {
591
+ DEBUG && console.error('[BrowserBinding] Client WebSocket error')
592
+ try { chromeWs.close(1011, 'Client error') } catch {}
593
+ })
594
+
595
+ chromeWs.addEventListener('error', (event) => {
596
+ DEBUG && console.error('[BrowserBinding] Chrome WebSocket error')
597
+ try { server.close(1011, 'Chrome error') } catch {}
598
+ })
599
+
600
+ log('WebSocket proxy established')
601
+
602
+ // Return Cloudflare-style WebSocket response
603
+ return new Response(null, {
604
+ status: 101,
605
+ webSocket: client
606
+ })
607
+ }
608
+ `;
609
+ }
610
+
611
+ // src/dev-server/miniflare-bindings.ts
612
+ function buildQueueProducers(bindings) {
613
+ if (!bindings.queues?.producers) {
614
+ return;
615
+ }
616
+ const producers = {};
617
+ for (const [bindingName, queueName] of Object.entries(bindings.queues.producers)) {
618
+ producers[bindingName] = { queueName };
619
+ }
620
+ return producers;
621
+ }
622
+ function buildQueueConsumers(bindings) {
623
+ if (!bindings.queues?.consumers || bindings.queues.consumers.length === 0) {
624
+ return;
625
+ }
626
+ const consumers = {};
627
+ for (const consumer of bindings.queues.consumers) {
628
+ consumers[consumer.queue] = {
629
+ ...consumer.maxBatchSize !== undefined && { maxBatchSize: consumer.maxBatchSize },
630
+ ...consumer.maxBatchTimeout !== undefined && { maxBatchTimeout: consumer.maxBatchTimeout },
631
+ ...consumer.maxRetries !== undefined && { maxRetries: consumer.maxRetries },
632
+ ...consumer.deadLetterQueue && { deadLetterQueue: consumer.deadLetterQueue },
633
+ ...consumer.maxConcurrency !== undefined && { maxConcurrency: consumer.maxConcurrency },
634
+ ...consumer.retryDelay !== undefined && { retryDelay: consumer.retryDelay }
635
+ };
636
+ }
637
+ return consumers;
638
+ }
639
+ function buildSendEmailConfig(bindings) {
640
+ if (!bindings.sendEmail) {
641
+ return;
642
+ }
643
+ return {
644
+ send_email: Object.entries(bindings.sendEmail).map(([name, binding]) => ({
645
+ name,
646
+ ...binding.destinationAddress && {
647
+ destination_address: binding.destinationAddress
648
+ },
649
+ ...binding.allowedDestinationAddresses && {
650
+ allowed_destination_addresses: binding.allowedDestinationAddresses
651
+ },
652
+ ...binding.allowedSenderAddresses && {
653
+ allowed_sender_addresses: binding.allowedSenderAddresses
654
+ }
655
+ }))
656
+ };
657
+ }
658
+
659
+ // src/dev-server/gateway-script.ts
660
+ function getGatewayScript(wsRoutes = [], debug = false, appServiceBindingName = null) {
661
+ const wsRoutesJson = JSON.stringify(wsRoutes);
662
+ const appServiceBindingJson = JSON.stringify(appServiceBindingName);
663
+ return `
664
+ ${GATEWAY_RUNTIME_JS}
665
+
666
+ // Bridge Gateway Worker — Dev Server
667
+ // Dev-server-specific overlay on top of the shared GATEWAY_RUNTIME_JS:
668
+ // WS route DO forwarding, D1 migration, email ingest, app-worker fallthrough.
669
+
670
+ const DEBUG = ${debug}
671
+ const log = (...args) => DEBUG && console.log('[Gateway]', ...args)
672
+
673
+ const WS_ROUTES = ${wsRoutesJson}
674
+ const APP_SERVICE_BINDING = ${appServiceBindingJson}
675
+
676
+ export default {
677
+ async fetch(request, env, ctx) {
678
+ const url = new URL(request.url)
679
+ const isWebSocket = request.headers.get('Upgrade') === 'websocket'
680
+
681
+ if (isWebSocket) {
682
+ const matchedRoute = matchWsRoute(url.pathname)
683
+ if (matchedRoute) {
684
+ return handleDoWebSocket(request, env, url, matchedRoute)
685
+ }
686
+ return handleBridgeWebSocket(request, env, ctx)
687
+ }
688
+
689
+ if (url.pathname.startsWith('/_devflare/transfer/')) {
690
+ return handleHttpTransfer(request, env, url)
691
+ }
692
+
693
+ if (url.pathname === '/_devflare/migrate' && request.method === 'POST') {
694
+ return handleMigration(request, env)
695
+ }
696
+
697
+ if (url.pathname === '/cdn-cgi/handler/email' && request.method === 'POST') {
698
+ return handleEmailIncoming(request, env, ctx, url)
699
+ }
700
+
701
+ if (url.pathname === '/_devflare/health') {
702
+ return new Response(JSON.stringify({
703
+ ok: true,
704
+ bindings: Object.keys(env),
705
+ wsRoutes: WS_ROUTES
706
+ }), { headers: { 'Content-Type': 'application/json' } })
707
+ }
708
+
709
+ if (APP_SERVICE_BINDING) {
710
+ const appWorker = env[APP_SERVICE_BINDING]
711
+ if (appWorker && typeof appWorker.fetch === 'function') {
712
+ return appWorker.fetch(request)
713
+ }
714
+ }
715
+
716
+ return new Response('Devflare Bridge Gateway', { status: 200 })
717
+ }
718
+ }
719
+
720
+ async function handleMigration(request, env) {
721
+ try {
722
+ const { bindingName, statements, files } = await request.json()
723
+ log('Migration request for binding:', bindingName, 'statements count:', statements?.length, 'files:', files?.length, 'bindings:', Object.keys(env))
724
+ const db = env[bindingName]
725
+ if (!db) {
726
+ return Response.json({ error: 'Binding not found: ' + bindingName }, { status: 404 })
727
+ }
728
+
729
+ // Ledger-aware path: when the client sends per-file metadata, we track
730
+ // applied migrations in a \`_devflare_migrations\` table and skip files
731
+ // whose filename+sha256 is already recorded. Files with a drifting hash
732
+ // are reported as warnings and skipped — we refuse to re-apply to avoid
733
+ // stomping on user data.
734
+ if (Array.isArray(files) && files.length > 0) {
735
+ try {
736
+ await db.prepare(
737
+ 'CREATE TABLE IF NOT EXISTS _devflare_migrations (filename TEXT PRIMARY KEY, applied_at TEXT NOT NULL, sha256 TEXT NOT NULL)'
738
+ ).run()
739
+ } catch (error) {
740
+ const msg = error?.message || String(error)
741
+ log('Failed to ensure migration ledger:', msg)
742
+ return Response.json({ error: 'Failed to ensure migration ledger: ' + msg }, { status: 500 })
743
+ }
744
+
745
+ let ledgerRows = []
746
+ try {
747
+ const ledger = await db.prepare('SELECT filename, sha256 FROM _devflare_migrations').all()
748
+ ledgerRows = ledger?.results || []
749
+ } catch (error) {
750
+ log('Failed to read migration ledger:', error?.message || String(error))
751
+ }
752
+ const ledgerByFilename = new Map()
753
+ for (const row of ledgerRows) {
754
+ ledgerByFilename.set(row.filename, row.sha256)
755
+ }
756
+
757
+ const applied = []
758
+ const skipped = []
759
+ const warnings = []
760
+ const results = []
761
+
762
+ for (const file of files) {
763
+ const existingHash = ledgerByFilename.get(file.filename)
764
+ if (existingHash === file.sha256) {
765
+ skipped.push(file.filename)
766
+ continue
767
+ }
768
+ if (existingHash && existingHash !== file.sha256) {
769
+ warnings.push({
770
+ filename: file.filename,
771
+ message: 'sha256 drifted since last apply; skipped'
772
+ })
773
+ skipped.push(file.filename)
774
+ continue
775
+ }
776
+
777
+ let fileFailed = false
778
+ for (const sql of file.statements || []) {
779
+ try {
780
+ log('Running migration SQL:', sql.slice(0, 80))
781
+ await db.prepare(sql).run()
782
+ results.push({ sql: sql.slice(0, 50), success: true })
783
+ } catch (error) {
784
+ const msg = error?.message || String(error)
785
+ log('Migration SQL error:', msg)
786
+ if (msg.includes('already exists')) {
787
+ results.push({ sql: sql.slice(0, 50), success: true, skipped: true })
788
+ } else {
789
+ results.push({ sql: sql.slice(0, 50), success: false, error: msg })
790
+ fileFailed = true
791
+ }
792
+ }
793
+ }
794
+
795
+ if (!fileFailed) {
796
+ try {
797
+ await db.prepare(
798
+ 'INSERT OR REPLACE INTO _devflare_migrations (filename, applied_at, sha256) VALUES (?, ?, ?)'
799
+ ).bind(file.filename, new Date().toISOString(), file.sha256).run()
800
+ applied.push(file.filename)
801
+ } catch (error) {
802
+ log('Failed to record migration in ledger:', error?.message || String(error))
803
+ }
804
+ }
805
+ }
806
+
807
+ return Response.json({ success: true, results, applied, skipped, warnings })
808
+ }
809
+
810
+ // Legacy path: flat statement list, no ledger tracking.
811
+ const results = []
812
+ for (const sql of statements) {
813
+ try {
814
+ log('Running migration SQL:', sql.slice(0, 80))
815
+ await db.prepare(sql).run()
816
+ results.push({ sql: sql.slice(0, 50), success: true })
817
+ log('Migration SQL succeeded')
818
+ } catch (error) {
819
+ const msg = error?.message || String(error)
820
+ log('Migration SQL error:', msg)
821
+ if (msg.includes('already exists')) {
822
+ results.push({ sql: sql.slice(0, 50), success: true, skipped: true })
823
+ } else {
824
+ results.push({ sql: sql.slice(0, 50), success: false, error: msg })
825
+ }
826
+ }
827
+ }
828
+
829
+ try {
830
+ const tables = await db.prepare("SELECT name FROM sqlite_master WHERE type='table'").all()
831
+ log('Tables after migration:', JSON.stringify(tables))
832
+ } catch (e) {
833
+ log('Error listing tables:', e.message)
834
+ }
835
+
836
+ return Response.json({ success: true, results })
837
+ } catch (error) {
838
+ return Response.json({ error: error?.message || String(error) }, { status: 500 })
839
+ }
840
+ }
841
+
842
+ async function handleEmailIncoming(request, env, ctx, url) {
843
+ try {
844
+ const from = url.searchParams.get('from') || 'unknown@example.com'
845
+ const to = url.searchParams.get('to') || 'worker@example.com'
846
+ const rawBody = await request.text()
847
+
848
+ log('Email incoming:', { from, to, bodyLength: rawBody.length })
849
+
850
+ if (APP_SERVICE_BINDING) {
851
+ const appWorker = env[APP_SERVICE_BINDING]
852
+ if (appWorker && typeof appWorker.fetch === 'function') {
853
+ const response = await appWorker.fetch(new Request('http://devflare.internal/_devflare/internal/email', {
854
+ method: 'POST',
855
+ headers: {
856
+ 'x-devflare-event': 'email',
857
+ 'x-devflare-email-from': from,
858
+ 'x-devflare-email-to': to,
859
+ 'content-type': request.headers.get('content-type') || 'text/plain'
860
+ },
861
+ body: rawBody
862
+ }))
863
+
864
+ if (!response.ok) {
865
+ return response
866
+ }
867
+ }
868
+ }
869
+
870
+ return new Response(JSON.stringify({ ok: true, from, to }), {
871
+ headers: { 'Content-Type': 'application/json' }
872
+ })
873
+ } catch (error) {
874
+ console.error('[Gateway] Email handler error:', error)
875
+ return Response.json({ error: error?.message || String(error) }, { status: 500 })
876
+ }
877
+ }
878
+
879
+ function matchWsRoute(pathname) {
880
+ for (const route of WS_ROUTES) {
881
+ if (pathname === route.pattern || pathname.startsWith(route.pattern + '?')) {
882
+ return route
883
+ }
884
+ }
885
+ return null
886
+ }
887
+
888
+ async function handleDoWebSocket(request, env, url, route) {
889
+ try {
890
+ const namespace = env[route.doNamespace]
891
+ if (!namespace) {
892
+ console.error('[Gateway] DO namespace not found:', route.doNamespace)
893
+ return new Response('DO namespace not found: ' + route.doNamespace, { status: 500 })
894
+ }
895
+
896
+ const idValue = url.searchParams.get(route.idParam) || 'default'
897
+ const doId = namespace.idFromName(idValue)
898
+ const stub = namespace.get(doId)
899
+
900
+ const forwardUrl = new URL(route.forwardPath, url.origin)
901
+ url.searchParams.forEach((v, k) => forwardUrl.searchParams.set(k, v))
902
+
903
+ log('Forwarding WebSocket to DO:', route.doNamespace, 'id:', idValue, 'path:', forwardUrl.pathname)
904
+
905
+ return stub.fetch(forwardUrl.toString(), {
906
+ method: request.method,
907
+ headers: request.headers
908
+ })
909
+ } catch (error) {
910
+ console.error('[Gateway] Error forwarding to DO:', error)
911
+ return new Response('Error forwarding to DO: ' + error.message, { status: 500 })
912
+ }
913
+ }
914
+ `;
915
+ }
916
+
917
+ // src/dev-server/miniflare-worker-config.ts
918
+ function buildServiceBindings(bindings, extraBindings = {}) {
919
+ const serviceBindings = {};
920
+ if (bindings.services) {
921
+ for (const [bindingName, serviceConfig] of Object.entries(bindings.services)) {
922
+ serviceBindings[bindingName] = {
923
+ name: serviceConfig.service,
924
+ ...serviceConfig.entrypoint && { entrypoint: serviceConfig.entrypoint }
925
+ };
926
+ }
927
+ }
928
+ for (const [bindingName, target] of Object.entries(extraBindings)) {
929
+ serviceBindings[bindingName] = target;
930
+ }
931
+ return Object.keys(serviceBindings).length > 0 ? serviceBindings : undefined;
932
+ }
933
+ function makeMiniflareWorker(context, options) {
934
+ const { cwd, loadedConfig, bindings, sendEmailConfig, queueProducers } = context;
935
+ const baseFlags = loadedConfig.compatibilityFlags ?? [];
936
+ const compatFlags = baseFlags.includes("nodejs_compat") ? baseFlags : [...baseFlags, "nodejs_compat"];
937
+ const workerBindings = loadedConfig.vars ?? {};
938
+ const workerConfig = {
939
+ name: options.name,
940
+ modules: true,
941
+ compatibilityDate: loadedConfig.compatibilityDate,
942
+ compatibilityFlags: compatFlags,
943
+ ...bindings.kv && {
944
+ kvNamespaces: Object.fromEntries(Object.entries(bindings.kv).map(([bindingName, bindingConfig]) => {
945
+ return [bindingName, getLocalKVNamespaceIdentifier(bindingConfig)];
946
+ }))
947
+ },
948
+ ...bindings.r2 && { r2Buckets: bindings.r2 },
949
+ ...bindings.d1 && {
950
+ d1Databases: Object.fromEntries(Object.entries(bindings.d1).map(([bindingName, bindingConfig]) => {
951
+ return [bindingName, getLocalD1DatabaseIdentifier(bindingConfig)];
952
+ }))
953
+ },
954
+ ...Object.keys(workerBindings).length > 0 && { bindings: workerBindings },
955
+ ...sendEmailConfig && { email: sendEmailConfig },
956
+ ...queueProducers && { queueProducers },
957
+ ...options.queueConsumers && { queueConsumers: options.queueConsumers },
958
+ ...options.triggers && { triggers: options.triggers }
959
+ };
960
+ if (options.scriptPath) {
961
+ workerConfig.scriptPath = options.scriptPath;
962
+ workerConfig.modulesRoot = cwd;
963
+ workerConfig.modulesRules = [
964
+ { type: "ESModule", include: ["**/*.ts", "**/*.tsx", "**/*.mts", "**/*.mjs"] },
965
+ { type: "CommonJS", include: ["**/*.js", "**/*.cjs"] },
966
+ { type: "ESModule", include: ["**/*.jsx"] }
967
+ ];
968
+ }
969
+ if (options.script) {
970
+ workerConfig.script = options.script;
971
+ }
972
+ if (options.durableObjects && Object.keys(options.durableObjects).length > 0) {
973
+ workerConfig.durableObjects = options.durableObjects;
974
+ }
975
+ if (options.serviceBindings && Object.keys(options.serviceBindings).length > 0) {
976
+ workerConfig.serviceBindings = options.serviceBindings;
977
+ }
978
+ return workerConfig;
979
+ }
980
+
981
+ // src/dev-server/worker-surface-paths.ts
982
+ import { dirname, resolve as resolve2 } from "pathe";
983
+ var DEFAULT_TRANSPORT_ENTRY_FILES = [
984
+ "src/transport.ts",
985
+ "src/transport.js",
986
+ "src/transport.mts",
987
+ "src/transport.mjs"
988
+ ];
989
+ var resolveMainWorkerSurfacePaths = resolveWorkerSurfacePaths;
990
+ function addWorkerWatchRoots(roots, cwd, configuredPath, defaultEntries) {
991
+ if (configuredPath === false || configuredPath === null) {
992
+ return;
993
+ }
994
+ if (typeof configuredPath === "string" && configuredPath) {
995
+ roots.add(dirname(resolve2(cwd, configuredPath)));
996
+ return;
997
+ }
998
+ for (const defaultEntry of defaultEntries) {
999
+ roots.add(dirname(resolve2(cwd, defaultEntry)));
1000
+ }
1001
+ }
1002
+ function collectWorkerWatchRoots(cwd, config, mainWorkerSurfacePaths) {
1003
+ const roots = new Set;
1004
+ for (const surfacePath of Object.values(mainWorkerSurfacePaths)) {
1005
+ if (surfacePath) {
1006
+ roots.add(dirname(surfacePath));
1007
+ }
1008
+ }
1009
+ addWorkerWatchRoots(roots, cwd, config.files?.fetch, DEFAULT_FETCH_ENTRY_FILES);
1010
+ addWorkerWatchRoots(roots, cwd, config.files?.queue, DEFAULT_QUEUE_ENTRY_FILES);
1011
+ addWorkerWatchRoots(roots, cwd, config.files?.scheduled, DEFAULT_SCHEDULED_ENTRY_FILES);
1012
+ addWorkerWatchRoots(roots, cwd, config.files?.email, DEFAULT_EMAIL_ENTRY_FILES);
1013
+ addWorkerWatchRoots(roots, cwd, config.files?.transport, DEFAULT_TRANSPORT_ENTRY_FILES);
1014
+ const routeDirectory = getRouteDirectoryCandidate(cwd, config);
1015
+ if (routeDirectory) {
1016
+ roots.add(routeDirectory.absoluteDir);
1017
+ }
1018
+ return [...roots];
1019
+ }
1020
+
1021
+ // src/dev-server/miniflare-dev-config.ts
1022
+ var INTERNAL_APP_SERVICE_BINDING = "__DEVFLARE_APP";
1023
+ function buildMiniflareDevConfig(input) {
1024
+ const {
1025
+ config: loadedConfig,
1026
+ cwd,
1027
+ miniflarePort,
1028
+ persist,
1029
+ enableVite,
1030
+ debug,
1031
+ mainWorkerSurfacePaths,
1032
+ mainWorkerRoutes,
1033
+ mainWorkerScriptPath,
1034
+ bundledMainWorkerScriptPath,
1035
+ browserShimPort,
1036
+ doResult,
1037
+ logger
1038
+ } = input;
1039
+ const bindings = loadedConfig.bindings ?? {};
1040
+ const persistPath = resolve3(cwd, ".devflare/data");
1041
+ const appWorkerName = loadedConfig.name;
1042
+ const shouldRunMainWorker = !enableVite && (hasWorkerSurfacePaths(mainWorkerSurfacePaths) || Boolean(mainWorkerRoutes?.routes.length));
1043
+ const queueProducers = buildQueueProducers(bindings);
1044
+ const queueConsumers = buildQueueConsumers(bindings);
1045
+ const sharedOptions = {
1046
+ port: miniflarePort,
1047
+ host: "127.0.0.1",
1048
+ kvPersist: persist ? `${persistPath}/kv` : undefined,
1049
+ r2Persist: persist ? `${persistPath}/r2` : undefined,
1050
+ d1Persist: persist ? `${persistPath}/d1` : undefined,
1051
+ durableObjectsPersist: persist ? `${persistPath}/do` : undefined
1052
+ };
1053
+ const createServiceBindings = (extraBindings = {}) => buildServiceBindings(bindings, extraBindings);
1054
+ const sendEmailConfig = buildSendEmailConfig(bindings);
1055
+ const workerContext = {
1056
+ cwd,
1057
+ loadedConfig,
1058
+ bindings,
1059
+ sendEmailConfig,
1060
+ queueProducers
1061
+ };
1062
+ const createWorkerConfig = (options) => makeMiniflareWorker(workerContext, options);
1063
+ const gatewayWorker = createWorkerConfig({
1064
+ name: "gateway",
1065
+ script: getGatewayScript(loadedConfig.wsRoutes, debug, shouldRunMainWorker ? INTERNAL_APP_SERVICE_BINDING : null),
1066
+ serviceBindings: shouldRunMainWorker ? createServiceBindings({
1067
+ [INTERNAL_APP_SERVICE_BINDING]: { name: appWorkerName }
1068
+ }) : createServiceBindings()
1069
+ });
1070
+ gatewayWorker.routes = ["*"];
1071
+ const hasDurableObjectBundles = !!doResult && doResult.bundles.size > 0;
1072
+ const browserBindingName = getSingleBrowserBindingName(bindings.browser);
1073
+ const needsBrowserWorker = Boolean(browserBindingName && (hasDurableObjectBundles || shouldRunMainWorker));
1074
+ if (!shouldRunMainWorker && !hasDurableObjectBundles && !needsBrowserWorker) {
1075
+ return {
1076
+ ...sharedOptions,
1077
+ ...gatewayWorker
1078
+ };
1079
+ }
1080
+ const workers = [];
1081
+ const durableObjects = {};
1082
+ const browserShimUrl = `http://127.0.0.1:${browserShimPort}`;
1083
+ const browserWorkerName = "browser-binding";
1084
+ if (shouldRunMainWorker && mainWorkerScriptPath) {
1085
+ const mainWorkerServiceBindings = createServiceBindings(browserBindingName ? {
1086
+ [browserBindingName]: { name: browserWorkerName }
1087
+ } : {});
1088
+ const mainWorkerConfig = createWorkerConfig({
1089
+ name: appWorkerName,
1090
+ scriptPath: bundledMainWorkerScriptPath ?? mainWorkerScriptPath,
1091
+ serviceBindings: mainWorkerServiceBindings,
1092
+ queueConsumers,
1093
+ triggers: loadedConfig.triggers?.crons?.length ? { crons: loadedConfig.triggers.crons } : undefined
1094
+ });
1095
+ workers.push(mainWorkerConfig);
1096
+ }
1097
+ if (doResult) {
1098
+ for (const [bindingName, bundlePath] of doResult.bundles) {
1099
+ const className = doResult.classes.get(bindingName);
1100
+ if (!className)
1101
+ continue;
1102
+ const workerName = `do-${bindingName.toLowerCase()}`;
1103
+ const workerConfig = createWorkerConfig({
1104
+ name: workerName,
1105
+ scriptPath: bundlePath,
1106
+ durableObjects: {
1107
+ [bindingName]: className
1108
+ },
1109
+ serviceBindings: createServiceBindings(browserBindingName ? {
1110
+ [browserBindingName]: { name: browserWorkerName }
1111
+ } : {})
1112
+ });
1113
+ if (browserBindingName) {
1114
+ logger?.debug(`DO ${workerName} has browser service binding: ${browserBindingName} → ${browserWorkerName}`);
1115
+ }
1116
+ logger?.debug(`DO ${workerName} config:`, JSON.stringify(workerConfig, null, 2));
1117
+ workers.push(workerConfig);
1118
+ durableObjects[bindingName] = {
1119
+ className,
1120
+ scriptName: workerName
1121
+ };
1122
+ }
1123
+ }
1124
+ if (needsBrowserWorker) {
1125
+ const browserWorker = createWorkerConfig({
1126
+ name: browserWorkerName,
1127
+ script: getBrowserBindingScript(browserShimUrl, debug)
1128
+ });
1129
+ workers.push(browserWorker);
1130
+ logger?.info(`Browser binding worker configured: ${browserBindingName} → ${browserShimUrl}`);
1131
+ }
1132
+ if (Object.keys(durableObjects).length > 0) {
1133
+ gatewayWorker.durableObjects = durableObjects;
1134
+ if (shouldRunMainWorker) {
1135
+ const mainWorker = workers.find((worker) => worker.name === appWorkerName);
1136
+ if (mainWorker) {
1137
+ mainWorker.durableObjects = durableObjects;
1138
+ }
1139
+ }
1140
+ }
1141
+ return {
1142
+ ...sharedOptions,
1143
+ workers: [gatewayWorker, ...workers]
1144
+ };
1145
+ }
1146
+
1147
+ // src/dev-server/runtime-stdio.ts
1148
+ import { createInterface } from "node:readline";
1149
+ function writeStdout(logger, message) {
1150
+ if (typeof logger?.log === "function") {
1151
+ logger.log(message);
1152
+ return;
1153
+ }
1154
+ if (typeof logger?.info === "function") {
1155
+ logger.info(message);
1156
+ return;
1157
+ }
1158
+ console.log(message);
1159
+ }
1160
+ function writeStderr(logger, message) {
1161
+ if (typeof logger?.error === "function") {
1162
+ logger.error(message);
1163
+ return;
1164
+ }
1165
+ console.error(message);
1166
+ }
1167
+ function createRuntimeStdioForwarder(logger) {
1168
+ return (stdout, stderr) => {
1169
+ createInterface({ input: stdout }).on("line", (data) => {
1170
+ writeStdout(logger, data);
1171
+ });
1172
+ createInterface({ input: stderr }).on("line", (data) => {
1173
+ writeStderr(logger, data);
1174
+ });
1175
+ };
1176
+ }
1177
+
1178
+ // src/dev-server/vite-process.ts
1179
+ import { spawn } from "node:child_process";
1180
+ async function startViteProcess(options) {
1181
+ const {
1182
+ cwd,
1183
+ vitePort,
1184
+ miniflarePort,
1185
+ generatedViteConfigPath,
1186
+ logger
1187
+ } = options;
1188
+ const args = ["vite", "dev", "--port", String(vitePort)];
1189
+ if (generatedViteConfigPath) {
1190
+ args.push("--config", generatedViteConfigPath);
1191
+ }
1192
+ const viteProcess = spawn("bunx", args, {
1193
+ cwd,
1194
+ stdio: ["inherit", "pipe", "pipe"],
1195
+ windowsHide: true,
1196
+ env: {
1197
+ ...process.env,
1198
+ DEVFLARE_DEV: "true",
1199
+ DEVFLARE_BRIDGE_PORT: String(miniflarePort),
1200
+ FORCE_COLOR: "1"
1201
+ }
1202
+ });
1203
+ const readyUrl = await waitForViteReady(viteProcess, {
1204
+ onStdout(chunk) {
1205
+ process.stdout.write(chunk);
1206
+ },
1207
+ onStderr(chunk) {
1208
+ process.stderr.write(chunk);
1209
+ }
1210
+ });
1211
+ if (readyUrl) {
1212
+ logger?.success(`Vite dev server started on ${readyUrl}`);
1213
+ return viteProcess;
1214
+ }
1215
+ logger?.warn("Vite process started, but the final local URL could not be confirmed yet");
1216
+ return viteProcess;
1217
+ }
1218
+
1219
+ // src/dev-server/reload-queue.ts
1220
+ function createReloadQueue({ reload, logger }) {
1221
+ let running = null;
1222
+ let pending = null;
1223
+ async function runOnce() {
1224
+ try {
1225
+ await reload();
1226
+ } catch (error) {
1227
+ logger?.error("[devflare dev] reload failed:", error);
1228
+ }
1229
+ }
1230
+ function schedule() {
1231
+ if (!running) {
1232
+ running = runOnce().finally(() => {
1233
+ running = null;
1234
+ });
1235
+ return running;
1236
+ }
1237
+ if (!pending) {
1238
+ const runningSnapshot = running;
1239
+ pending = runningSnapshot.then(() => {
1240
+ pending = null;
1241
+ running = runOnce().finally(() => {
1242
+ running = null;
1243
+ });
1244
+ return running;
1245
+ });
1246
+ }
1247
+ return pending;
1248
+ }
1249
+ async function drain() {
1250
+ while (running || pending) {
1251
+ if (pending) {
1252
+ await pending;
1253
+ } else if (running) {
1254
+ await running;
1255
+ }
1256
+ }
1257
+ }
1258
+ return { schedule, drain };
1259
+ }
1260
+
1261
+ // src/dev-server/worker-source-watcher.ts
1262
+ async function startWorkerSourceWatcher(options) {
1263
+ const { watchTargets, resolvedWorkerConfigPath, logger, onConfigChange, onWorkerChange } = options;
1264
+ if (watchTargets.length === 0) {
1265
+ return null;
1266
+ }
1267
+ const chokidar = await import("chokidar");
1268
+ const isWindows = process.platform === "win32";
1269
+ const ignoredSegments = ["/node_modules/", "/.git/", "/.devflare/", "/dist/"];
1270
+ const normalizePath = (filePath) => filePath.replace(/\\/g, "/");
1271
+ const isIgnoredPath = (filePath) => {
1272
+ const normalizedPath = normalizePath(filePath);
1273
+ return ignoredSegments.some((segment) => normalizedPath.includes(segment));
1274
+ };
1275
+ let reloadTimeout = null;
1276
+ let reloadInProgress = false;
1277
+ let pendingReloadPath = null;
1278
+ const flushPendingReload = async () => {
1279
+ if (!pendingReloadPath) {
1280
+ return;
1281
+ }
1282
+ const nextPath = pendingReloadPath;
1283
+ pendingReloadPath = null;
1284
+ await triggerReload(nextPath);
1285
+ };
1286
+ const triggerReload = async (filePath) => {
1287
+ if (reloadInProgress) {
1288
+ pendingReloadPath = filePath;
1289
+ return;
1290
+ }
1291
+ reloadInProgress = true;
1292
+ try {
1293
+ const normalizedConfigPath = resolvedWorkerConfigPath ? normalizePath(resolvedWorkerConfigPath) : null;
1294
+ if (normalizedConfigPath && normalizePath(filePath) === normalizedConfigPath) {
1295
+ logger?.info(`Devflare config changed: ${filePath}`);
1296
+ await onConfigChange();
1297
+ return;
1298
+ }
1299
+ logger?.info(`Worker source changed: ${filePath}`);
1300
+ await onWorkerChange();
1301
+ } catch (error) {
1302
+ logger?.error("Worker source reload failed:", error);
1303
+ } finally {
1304
+ reloadInProgress = false;
1305
+ await flushPendingReload();
1306
+ }
1307
+ };
1308
+ const scheduleReload = (filePath) => {
1309
+ if (reloadTimeout) {
1310
+ clearTimeout(reloadTimeout);
1311
+ }
1312
+ reloadTimeout = setTimeout(() => {
1313
+ reloadTimeout = null;
1314
+ triggerReload(filePath);
1315
+ }, 150);
1316
+ };
1317
+ const watcher = chokidar.watch(watchTargets, {
1318
+ ignoreInitial: true,
1319
+ usePolling: isWindows,
1320
+ interval: isWindows ? 300 : undefined,
1321
+ awaitWriteFinish: {
1322
+ stabilityThreshold: 100,
1323
+ pollInterval: 50
1324
+ },
1325
+ ignored: (filePath) => isIgnoredPath(filePath)
1326
+ });
1327
+ const onFileEvent = (filePath) => {
1328
+ if (isIgnoredPath(filePath)) {
1329
+ return;
1330
+ }
1331
+ scheduleReload(filePath);
1332
+ };
1333
+ watcher.on("change", onFileEvent);
1334
+ watcher.on("add", onFileEvent);
1335
+ watcher.on("unlink", onFileEvent);
1336
+ watcher.on("error", (error) => {
1337
+ logger?.error("Worker source watcher error:", error);
1338
+ });
1339
+ await new Promise((resolvePromise, rejectPromise) => {
1340
+ const handleReady = () => {
1341
+ watcher.off("error", handleInitialError);
1342
+ logger?.info(`Worker source watcher ready (${watchTargets.length} target(s))`);
1343
+ resolvePromise();
1344
+ };
1345
+ const handleInitialError = (error) => {
1346
+ watcher.off("ready", handleReady);
1347
+ rejectPromise(error instanceof Error ? error : new Error(String(error)));
1348
+ };
1349
+ watcher.once("ready", handleReady);
1350
+ watcher.once("error", handleInitialError);
1351
+ });
1352
+ return watcher;
1353
+ }
1354
+ async function applyWatcherTargetDiff(watcher, currentTargets, nextTargets) {
1355
+ const nextSet = new Set(nextTargets);
1356
+ const targetsToRemove = currentTargets.filter((t) => !nextSet.has(t));
1357
+ const targetsToAdd = nextTargets.filter((t) => !currentTargets.includes(t));
1358
+ if (targetsToRemove.length > 0) {
1359
+ await watcher.unwatch(targetsToRemove);
1360
+ }
1361
+ if (targetsToAdd.length > 0) {
1362
+ watcher.add(targetsToAdd);
1363
+ }
1364
+ return nextTargets;
1365
+ }
1366
+
1367
+ // src/dev-server/server-startup-helpers.ts
1368
+ import { resolve as resolve4 } from "pathe";
1369
+
1370
+ // src/browser-shim/server.ts
1371
+ import { homedir } from "node:os";
1372
+ import { join } from "node:path";
1373
+ import { existsSync } from "node:fs";
1374
+ import { createServer } from "node:http";
1375
+ import puppeteerCore from "puppeteer-core";
1376
+ import {
1377
+ install,
1378
+ resolveBuildId,
1379
+ detectBrowserPlatform,
1380
+ Browser as BrowserType
1381
+ } from "@puppeteer/browsers";
1382
+ var cachedExecutablePath = null;
1383
+ var DEFAULT_CHROME_FLAGS = [
1384
+ "--disable-dev-shm-usage",
1385
+ "--disable-gpu",
1386
+ "--disable-software-rasterizer",
1387
+ "--disable-extensions",
1388
+ "--disable-background-networking",
1389
+ "--disable-background-timer-throttling",
1390
+ "--disable-backgrounding-occluded-windows",
1391
+ "--disable-renderer-backgrounding",
1392
+ "--disable-features=TranslateUI",
1393
+ "--disable-ipc-flooding-protection",
1394
+ "--disable-default-apps",
1395
+ "--mute-audio",
1396
+ "--js-flags=--max-old-space-size=4096"
1397
+ ];
1398
+ var NO_SANDBOX_FLAGS = [
1399
+ "--no-sandbox",
1400
+ "--disable-setuid-sandbox"
1401
+ ];
1402
+ function resolveChromeFlags(options = {}) {
1403
+ const flags = [...DEFAULT_CHROME_FLAGS];
1404
+ if (options.allowNoSandbox) {
1405
+ flags.unshift(...NO_SANDBOX_FLAGS);
1406
+ }
1407
+ return flags;
1408
+ }
1409
+ function createDownloadProgressLogger(logger, label = "Chrome") {
1410
+ const state = {
1411
+ started: false,
1412
+ completed: false,
1413
+ progress: { bytesReceived: 0, totalBytes: 0 }
1414
+ };
1415
+ return {
1416
+ onProgress(downloadedBytes, totalBytes) {
1417
+ if (state.completed)
1418
+ return;
1419
+ state.progress.bytesReceived = downloadedBytes;
1420
+ state.progress.totalBytes = totalBytes;
1421
+ if (!state.started) {
1422
+ state.started = true;
1423
+ logger?.info(`[BrowserShim] Downloading ${label}...`);
1424
+ }
1425
+ if (totalBytes > 0 && downloadedBytes >= totalBytes) {
1426
+ state.completed = true;
1427
+ logger?.info(`[BrowserShim] ${label} download complete`);
1428
+ }
1429
+ },
1430
+ finalize() {
1431
+ if (!state.started || state.completed)
1432
+ return;
1433
+ state.completed = true;
1434
+ logger?.info(`[BrowserShim] ${label} download complete`);
1435
+ },
1436
+ get progress() {
1437
+ return state.progress;
1438
+ },
1439
+ get started() {
1440
+ return state.started;
1441
+ },
1442
+ get completed() {
1443
+ return state.completed;
1444
+ }
1445
+ };
1446
+ }
1447
+ async function ensureChrome(cacheDir, logger) {
1448
+ if (cachedExecutablePath && existsSync(cachedExecutablePath)) {
1449
+ return cachedExecutablePath;
1450
+ }
1451
+ const platform = detectBrowserPlatform();
1452
+ if (!platform) {
1453
+ throw new Error("Could not detect browser platform");
1454
+ }
1455
+ const buildId = await resolveBuildId(BrowserType.CHROMEHEADLESSSHELL, platform, "stable");
1456
+ logger?.debug(`[BrowserShim] Resolved Chrome Headless Shell build: ${buildId}`);
1457
+ const progressLogger = createDownloadProgressLogger(logger, "Chrome");
1458
+ const installedBrowser = await install({
1459
+ browser: BrowserType.CHROMEHEADLESSSHELL,
1460
+ buildId,
1461
+ cacheDir,
1462
+ downloadProgressCallback: (downloadedBytes, totalBytes) => {
1463
+ progressLogger.onProgress(downloadedBytes, totalBytes);
1464
+ }
1465
+ });
1466
+ progressLogger.finalize();
1467
+ cachedExecutablePath = installedBrowser.executablePath;
1468
+ logger?.success(`[BrowserShim] Chrome ready: ${installedBrowser.executablePath}`);
1469
+ return installedBrowser.executablePath;
1470
+ }
1471
+ function createBrowserShim(options = {}) {
1472
+ const {
1473
+ port = 8788,
1474
+ host = "127.0.0.1",
1475
+ logger,
1476
+ verbose = false,
1477
+ keepAlive = 60000,
1478
+ cacheDir = join(homedir(), ".devflare", "chrome"),
1479
+ allowNoSandbox = false
1480
+ } = options;
1481
+ const chromeLaunchArgs = resolveChromeFlags({ allowNoSandbox });
1482
+ if (allowNoSandbox) {
1483
+ logger?.warn("[BrowserShim] Launching Chrome with --no-sandbox (allowNoSandbox=true). " + "Only use this in trusted CI/rootless environments.");
1484
+ }
1485
+ let server = null;
1486
+ let executablePath = null;
1487
+ const sessions = new Map;
1488
+ const history = [];
1489
+ let WebSocketServerClass = null;
1490
+ let WebSocketClass = null;
1491
+ const maxRequestBodyBytes = 1024 * 1024;
1492
+ function getRequestOrigin(req) {
1493
+ const origin = req.headers.origin;
1494
+ if (typeof origin === "string") {
1495
+ return origin;
1496
+ }
1497
+ if (Array.isArray(origin) && origin[0]) {
1498
+ return origin[0];
1499
+ }
1500
+ return null;
1501
+ }
1502
+ function isLoopbackOrigin(origin) {
1503
+ try {
1504
+ const url = new URL(origin);
1505
+ return url.hostname === "127.0.0.1" || url.hostname === "localhost" || url.hostname === "::1" || url.hostname === "[::1]";
1506
+ } catch {
1507
+ return false;
1508
+ }
1509
+ }
1510
+ function applyCorsHeaders(req, res) {
1511
+ const origin = getRequestOrigin(req);
1512
+ if (!origin) {
1513
+ return true;
1514
+ }
1515
+ if (!isLoopbackOrigin(origin)) {
1516
+ res.writeHead(403, { "Content-Type": "application/json" });
1517
+ res.end(JSON.stringify({ error: "Forbidden origin" }));
1518
+ return false;
1519
+ }
1520
+ res.setHeader("Access-Control-Allow-Origin", origin);
1521
+ res.setHeader("Access-Control-Allow-Methods", "GET, POST, OPTIONS");
1522
+ res.setHeader("Access-Control-Allow-Headers", "Content-Type");
1523
+ res.setHeader("Vary", "Origin");
1524
+ return true;
1525
+ }
1526
+ async function acquireSession(acquireOptions) {
1527
+ if (!executablePath) {
1528
+ throw new Error("Chrome not initialized");
1529
+ }
1530
+ const browser = await puppeteerCore.launch({
1531
+ executablePath,
1532
+ headless: true,
1533
+ protocolTimeout: 120000,
1534
+ args: chromeLaunchArgs
1535
+ });
1536
+ const wsEndpoint = browser.wsEndpoint();
1537
+ const sessionId = crypto.randomUUID();
1538
+ const session = {
1539
+ sessionId,
1540
+ browser,
1541
+ wsEndpoint,
1542
+ startTime: Date.now()
1543
+ };
1544
+ sessions.set(sessionId, session);
1545
+ const timeout = acquireOptions?.keep_alive ?? keepAlive;
1546
+ if (timeout > 0) {
1547
+ session.idleTimeout = setTimeout(async () => {
1548
+ const s = sessions.get(sessionId);
1549
+ if (s && !s.connectionId) {
1550
+ await closeSession(sessionId, 2, "BrowserIdle");
1551
+ }
1552
+ }, timeout);
1553
+ }
1554
+ if (verbose) {
1555
+ logger?.debug(`[BrowserShim] Acquired session ${sessionId}`);
1556
+ }
1557
+ return { sessionId };
1558
+ }
1559
+ async function closeSession(sessionId, closeReason = 1, closeReasonText = "NormalClosure") {
1560
+ const session = sessions.get(sessionId);
1561
+ if (!session)
1562
+ return;
1563
+ if (session.idleTimeout) {
1564
+ clearTimeout(session.idleTimeout);
1565
+ }
1566
+ try {
1567
+ await session.browser.close();
1568
+ } catch {}
1569
+ sessions.delete(sessionId);
1570
+ history.unshift({
1571
+ sessionId,
1572
+ startTime: session.startTime,
1573
+ endTime: Date.now(),
1574
+ closeReason,
1575
+ closeReasonText
1576
+ });
1577
+ if (history.length > 100) {
1578
+ history.pop();
1579
+ }
1580
+ if (verbose) {
1581
+ logger?.debug(`[BrowserShim] Closed session ${sessionId}: ${closeReasonText}`);
1582
+ }
1583
+ }
1584
+ async function handleRequest(req, res) {
1585
+ const url = new URL(req.url || "/", `http://${host}:${port}`);
1586
+ const method = req.method || "GET";
1587
+ logger?.debug(`[BrowserShim] ${method} ${url.pathname}${url.search ? url.search : ""}`);
1588
+ if (!applyCorsHeaders(req, res)) {
1589
+ return;
1590
+ }
1591
+ if (method === "OPTIONS") {
1592
+ res.writeHead(204);
1593
+ res.end();
1594
+ return;
1595
+ }
1596
+ if (url.pathname === "/v1/acquire" && (method === "POST" || method === "GET")) {
1597
+ try {
1598
+ let acquireOptions = {};
1599
+ if (method === "GET") {
1600
+ const keepAlive2 = url.searchParams.get("keep_alive");
1601
+ if (keepAlive2) {
1602
+ acquireOptions.keep_alive = parseInt(keepAlive2, 10);
1603
+ }
1604
+ } else {
1605
+ try {
1606
+ const body = await readBody(req);
1607
+ acquireOptions = JSON.parse(body);
1608
+ } catch {}
1609
+ }
1610
+ const result = await acquireSession(acquireOptions);
1611
+ sendJson(res, 200, result);
1612
+ } catch (error) {
1613
+ const msg = error instanceof Error ? error.message : "Failed to acquire browser";
1614
+ logger?.error(`[BrowserShim] Acquire failed: ${msg}`);
1615
+ sendJson(res, 500, { error: msg });
1616
+ }
1617
+ return;
1618
+ }
1619
+ if (url.pathname === "/v1/sessions" && method === "GET") {
1620
+ const activeSessions = Array.from(sessions.values()).map((s) => ({
1621
+ sessionId: s.sessionId,
1622
+ startTime: s.startTime,
1623
+ connectionId: s.connectionId,
1624
+ connectionStartTime: s.connectionStartTime
1625
+ }));
1626
+ sendJson(res, 200, activeSessions);
1627
+ return;
1628
+ }
1629
+ if (url.pathname === "/v1/history" && method === "GET") {
1630
+ sendJson(res, 200, history.slice(0, 50));
1631
+ return;
1632
+ }
1633
+ if (url.pathname === "/v1/limits" && method === "GET") {
1634
+ sendJson(res, 200, {
1635
+ activeSessions: Array.from(sessions.keys()).map((id) => ({ id })),
1636
+ allowedBrowserAcquisitions: 10,
1637
+ maxConcurrentSessions: 10,
1638
+ timeUntilNextAllowedBrowserAcquisition: 0
1639
+ });
1640
+ return;
1641
+ }
1642
+ if (url.pathname.startsWith("/v1/session/") && method === "GET") {
1643
+ const sessionId = url.pathname.slice("/v1/session/".length);
1644
+ const session = sessions.get(sessionId);
1645
+ if (!session) {
1646
+ sendJson(res, 404, { error: "Session not found" });
1647
+ return;
1648
+ }
1649
+ sendJson(res, 200, {
1650
+ sessionId: session.sessionId,
1651
+ wsEndpoint: session.wsEndpoint,
1652
+ startTime: session.startTime,
1653
+ connectionId: session.connectionId,
1654
+ connectionStartTime: session.connectionStartTime
1655
+ });
1656
+ return;
1657
+ }
1658
+ if (url.pathname === "/_devflare/browser/health") {
1659
+ sendJson(res, 200, {
1660
+ ok: true,
1661
+ activeSessions: sessions.size,
1662
+ historySize: history.length,
1663
+ executablePath
1664
+ });
1665
+ return;
1666
+ }
1667
+ if (url.pathname === "/v1/connectDevtools") {
1668
+ res.writeHead(426, { "Content-Type": "text/plain" });
1669
+ res.end("WebSocket upgrade required");
1670
+ return;
1671
+ }
1672
+ res.writeHead(404, { "Content-Type": "text/plain" });
1673
+ res.end("Not found");
1674
+ }
1675
+ function readBody(req) {
1676
+ return new Promise((resolve4, reject) => {
1677
+ const chunks = [];
1678
+ let totalBytes = 0;
1679
+ req.on("data", (chunk) => {
1680
+ totalBytes += chunk.length;
1681
+ if (totalBytes > maxRequestBodyBytes) {
1682
+ req.destroy();
1683
+ reject(new Error(`Request body exceeds ${maxRequestBodyBytes} bytes`));
1684
+ return;
1685
+ }
1686
+ chunks.push(chunk);
1687
+ });
1688
+ req.on("end", () => resolve4(Buffer.concat(chunks).toString()));
1689
+ req.on("error", reject);
1690
+ });
1691
+ }
1692
+ function sendJson(res, status, data) {
1693
+ const body = JSON.stringify(data);
1694
+ res.writeHead(status, {
1695
+ "Content-Type": "application/json",
1696
+ "Content-Length": Buffer.byteLength(body)
1697
+ });
1698
+ res.end(body);
1699
+ }
1700
+ async function start() {
1701
+ logger?.info("[BrowserShim] Ensuring Chrome Headless Shell is available...");
1702
+ executablePath = await ensureChrome(cacheDir, logger);
1703
+ try {
1704
+ const wsModule = await import("ws");
1705
+ WebSocketServerClass = wsModule.WebSocketServer || wsModule.default?.WebSocketServer;
1706
+ WebSocketClass = wsModule.WebSocket || wsModule.default?.WebSocket || wsModule.default;
1707
+ } catch {
1708
+ logger?.warn("[BrowserShim] ws package not found, WebSocket proxy disabled");
1709
+ logger?.warn("[BrowserShim] Install with: npm install ws");
1710
+ }
1711
+ server = createServer((req, res) => {
1712
+ handleRequest(req, res).catch((error) => {
1713
+ logger?.error("[BrowserShim] Request error:", error);
1714
+ res.writeHead(500);
1715
+ res.end("Internal server error");
1716
+ });
1717
+ });
1718
+ if (WebSocketServerClass) {
1719
+ const wss = new WebSocketServerClass({ noServer: true });
1720
+ server.on("upgrade", (request, socket, head) => {
1721
+ const origin = getRequestOrigin(request);
1722
+ if (origin && !isLoopbackOrigin(origin)) {
1723
+ socket.write(`HTTP/1.1 403 Forbidden\r
1724
+ \r
1725
+ `);
1726
+ socket.destroy();
1727
+ return;
1728
+ }
1729
+ const url = new URL(request.url || "/", `http://${host}:${port}`);
1730
+ if (url.pathname !== "/v1/connectDevtools") {
1731
+ socket.destroy();
1732
+ return;
1733
+ }
1734
+ const sessionId = url.searchParams.get("browser_session");
1735
+ if (!sessionId) {
1736
+ socket.write(`HTTP/1.1 400 Bad Request\r
1737
+ \r
1738
+ `);
1739
+ socket.destroy();
1740
+ return;
1741
+ }
1742
+ const session = sessions.get(sessionId);
1743
+ if (!session) {
1744
+ socket.write(`HTTP/1.1 404 Not Found\r
1745
+ \r
1746
+ `);
1747
+ socket.destroy();
1748
+ return;
1749
+ }
1750
+ const connectionId = crypto.randomUUID();
1751
+ session.connectionId = connectionId;
1752
+ session.connectionStartTime = Date.now();
1753
+ if (session.idleTimeout) {
1754
+ clearTimeout(session.idleTimeout);
1755
+ session.idleTimeout = undefined;
1756
+ }
1757
+ wss.handleUpgrade(request, socket, head, (ws) => {
1758
+ if (verbose) {
1759
+ logger?.debug(`[BrowserShim] WebSocket connected for session ${sessionId}`);
1760
+ }
1761
+ const chromeWs = new WebSocketClass(session.wsEndpoint);
1762
+ let chromeConnected = false;
1763
+ const connectTimeout = setTimeout(() => {
1764
+ if (!chromeConnected) {
1765
+ logger?.error("[BrowserShim] Chrome connection timeout");
1766
+ try {
1767
+ ws.close(1011, "Chrome connection timeout");
1768
+ chromeWs.close();
1769
+ } catch {}
1770
+ closeSession(sessionId, 5, "ChromeConnectionTimeout").catch(() => {});
1771
+ }
1772
+ }, 1e4);
1773
+ chromeWs.on("open", () => {
1774
+ chromeConnected = true;
1775
+ clearTimeout(connectTimeout);
1776
+ if (verbose) {
1777
+ logger?.debug("[BrowserShim] Connected to Chrome DevTools");
1778
+ }
1779
+ });
1780
+ chromeWs.on("message", (data) => {
1781
+ if (ws.readyState === 1) {
1782
+ ws.send(data);
1783
+ }
1784
+ });
1785
+ chromeWs.on("close", (code, reason) => {
1786
+ if (verbose) {
1787
+ logger?.debug(`[BrowserShim] Chrome WS closed: ${code}`);
1788
+ }
1789
+ const validCode = typeof code === "number" && code >= 1000 && code <= 4999 ? code : 1000;
1790
+ try {
1791
+ ws.close(validCode, reason?.toString?.() || "");
1792
+ } catch {}
1793
+ closeSession(sessionId, 2, "ChromeDisconnected").catch((err) => {
1794
+ logger?.error("[BrowserShim] Error closing session after Chrome disconnect:", err);
1795
+ });
1796
+ });
1797
+ chromeWs.on("error", (error) => {
1798
+ logger?.error("[BrowserShim] Chrome WS error:", error.message);
1799
+ try {
1800
+ ws.close(1011, "Chrome WebSocket error");
1801
+ } catch {}
1802
+ closeSession(sessionId, 4, "ChromeError").catch((err) => {
1803
+ logger?.error("[BrowserShim] Error closing session after Chrome error:", err);
1804
+ });
1805
+ });
1806
+ ws.on("message", (data) => {
1807
+ if (chromeWs.readyState === 1) {
1808
+ chromeWs.send(data);
1809
+ }
1810
+ });
1811
+ ws.on("close", (code, reason) => {
1812
+ if (verbose) {
1813
+ logger?.debug(`[BrowserShim] Client WS closed for session ${sessionId}`);
1814
+ }
1815
+ const validCode = typeof code === "number" && code >= 1000 && code <= 4999 ? code : 1000;
1816
+ try {
1817
+ chromeWs.close(validCode, reason?.toString?.() || "");
1818
+ } catch {}
1819
+ const s = sessions.get(sessionId);
1820
+ if (s && s.connectionId === connectionId) {
1821
+ s.connectionId = undefined;
1822
+ s.connectionStartTime = undefined;
1823
+ closeSession(sessionId, 1, "ClientDisconnected").catch((err) => {
1824
+ logger?.error("[BrowserShim] Error closing session after disconnect:", err);
1825
+ });
1826
+ }
1827
+ });
1828
+ ws.on("error", (error) => {
1829
+ logger?.error("[BrowserShim] Client WS error:", error.message);
1830
+ try {
1831
+ chromeWs.close();
1832
+ } catch {}
1833
+ });
1834
+ });
1835
+ });
1836
+ }
1837
+ await new Promise((resolve4, reject) => {
1838
+ server.on("error", reject);
1839
+ server.listen(port, host, () => {
1840
+ resolve4();
1841
+ });
1842
+ });
1843
+ logger?.success(`Browser shim server ready on http://${host}:${port}`);
1844
+ }
1845
+ async function stop() {
1846
+ for (const sessionId of Array.from(sessions.keys())) {
1847
+ await closeSession(sessionId, 3, "ServerShutdown");
1848
+ }
1849
+ if (server) {
1850
+ await new Promise((resolve4) => {
1851
+ server.close(() => resolve4());
1852
+ });
1853
+ server = null;
1854
+ }
1855
+ logger?.info("Browser shim server stopped");
1856
+ }
1857
+ function getUrl() {
1858
+ return `http://${host}:${port}`;
1859
+ }
1860
+ return {
1861
+ start,
1862
+ stop,
1863
+ getUrl
1864
+ };
1865
+ }
1866
+ // src/dev-server/server-startup-helpers.ts
1867
+ function logWorkerHandlerDetection(logger, enableVite, hasSurface, mainWorkerSurfacePaths, mainWorkerRoutes) {
1868
+ if (enableVite)
1869
+ return;
1870
+ if (hasSurface) {
1871
+ const detectedWorkerHandlers = Object.entries(mainWorkerSurfacePaths).filter(([, surfacePath]) => !!surfacePath).map(([surfaceName, surfacePath]) => `${surfaceName}=${surfacePath}`);
1872
+ const detectedRouteHandlers = mainWorkerRoutes?.routes.map((route) => `route=${route.filePath}`) ?? [];
1873
+ logger?.info(`Worker handlers detected: ${[...detectedWorkerHandlers, ...detectedRouteHandlers].join(", ")}`);
1874
+ } else {
1875
+ logger?.warn("No local worker handler entry was found for worker-only mode");
1876
+ }
1877
+ }
1878
+ function logRemoteBindingRequirements(logger, remoteCheck) {
1879
+ if (!remoteCheck.hasRemoteBindings)
1880
+ return;
1881
+ logger?.info("");
1882
+ logger?.warn("⚠️ Remote-only bindings detected:");
1883
+ for (const binding of remoteCheck.remoteBindings) {
1884
+ logger?.warn(` • ${binding}`);
1885
+ }
1886
+ logger?.info("");
1887
+ if (remoteCheck.missingAccountId) {
1888
+ logger?.warn("⚠️ WARN: accountId is not set in devflare.config.ts");
1889
+ logger?.warn(" Remote bindings (AI, Vectorize) require accountId to charge the correct account.");
1890
+ logger?.warn(" Add: accountId: 'your-cloudflare-account-id'");
1891
+ logger?.info("");
1892
+ }
1893
+ if (remoteCheck.notLoggedIn) {
1894
+ logger?.warn("⚠️ WARN: Not logged in to Wrangler");
1895
+ logger?.warn(" Remote bindings require authentication.");
1896
+ logger?.warn(" Run: bunx wrangler login");
1897
+ logger?.info("");
1898
+ }
1899
+ if (!remoteCheck.missingAccountId && !remoteCheck.notLoggedIn) {
1900
+ logger?.success("✓ Remote binding requirements met");
1901
+ logger?.info("");
1902
+ }
1903
+ }
1904
+ function formatErrorMessage(error) {
1905
+ return error instanceof Error ? error.message : String(error);
1906
+ }
1907
+ async function resolveWorkerConfigWatchPath(cwd, configPath) {
1908
+ if (configPath) {
1909
+ const explicitPath = resolve4(cwd, configPath);
1910
+ const fs = await import("node:fs/promises");
1911
+ try {
1912
+ await fs.access(explicitPath);
1913
+ return explicitPath;
1914
+ } catch {}
1915
+ }
1916
+ return await resolveConfigPath(cwd) ?? null;
1917
+ }
1918
+ function logMiniflareConfigDiagnostics(logger, mfConfig) {
1919
+ logger?.info("=== MINIFLARE CONFIG DEBUG ===");
1920
+ logger?.info("Full config:", JSON.stringify(mfConfig, (key, value) => {
1921
+ if (key === "script" && typeof value === "string" && value.length > 200) {
1922
+ return value.substring(0, 200) + "...[truncated]";
1923
+ }
1924
+ return value;
1925
+ }, 2));
1926
+ if (mfConfig.workers) {
1927
+ logger?.info("Workers order:");
1928
+ for (const w of mfConfig.workers) {
1929
+ logger?.info(` → ${w.name}:`);
1930
+ logger?.info(` script: ${w.script ? "inline" : w.scriptPath}`);
1931
+ logger?.info(` browserRendering: ${JSON.stringify(w.browserRendering)}`);
1932
+ logger?.info(` durableObjects: ${JSON.stringify(w.durableObjects)}`);
1933
+ }
1934
+ }
1935
+ }
1936
+ async function logMiniflareBindingDiagnostics(logger, miniflare, mfConfig) {
1937
+ try {
1938
+ const gatewayBindings = await miniflare.getBindings("gateway");
1939
+ logger?.info("Gateway worker bindings:", Object.keys(gatewayBindings));
1940
+ if (mfConfig.workers) {
1941
+ for (const w of mfConfig.workers) {
1942
+ if (w.name !== "gateway") {
1943
+ try {
1944
+ const doBindings = await miniflare.getBindings(w.name);
1945
+ logger?.info(`${w.name} worker bindings:`, Object.keys(doBindings));
1946
+ if ("BROWSER" in doBindings) {
1947
+ logger?.success(`${w.name} has BROWSER binding!`);
1948
+ } else {
1949
+ logger?.warn(`${w.name} is MISSING BROWSER binding`);
1950
+ }
1951
+ } catch (error) {
1952
+ logger?.debug(`Skipping binding diagnostics for ${w.name}: ${formatErrorMessage(error)}`);
1953
+ }
1954
+ }
1955
+ }
1956
+ }
1957
+ } catch (error) {
1958
+ logger?.debug(`Skipping Miniflare binding diagnostics: ${formatErrorMessage(error)}`);
1959
+ }
1960
+ }
1961
+ async function maybeStartBrowserShim(config, options) {
1962
+ const browserBinding = getSingleBrowserBindingName(config.bindings?.browser);
1963
+ if (!browserBinding)
1964
+ return null;
1965
+ options.logger?.info(`Starting Browser Rendering shim (binding: ${browserBinding})...`);
1966
+ const shim = createBrowserShim({
1967
+ port: options.browserShimPort,
1968
+ host: "127.0.0.1",
1969
+ logger: options.logger,
1970
+ verbose: options.verbose
1971
+ });
1972
+ await shim.start();
1973
+ return shim;
1974
+ }
1975
+ async function maybeStartDOBundler(config, options) {
1976
+ const doPattern = config.files?.durableObjects;
1977
+ if (typeof doPattern !== "string" || !doPattern) {
1978
+ return { bundler: null, result: null };
1979
+ }
1980
+ const outDir = resolve4(options.cwd, ".devflare/do-bundles");
1981
+ const bundler = createDOBundler({
1982
+ cwd: options.cwd,
1983
+ pattern: doPattern,
1984
+ outDir,
1985
+ rolldownOptions: config.rolldown?.options,
1986
+ sourcemap: config.rolldown?.sourcemap,
1987
+ minify: config.rolldown?.minify,
1988
+ logger: options.logger,
1989
+ onRebuild: options.onRebuild
1990
+ });
1991
+ const result = await bundler.build();
1992
+ await bundler.watch();
1993
+ return { bundler, result };
1994
+ }
1995
+ async function resolveViteIntegration(options) {
1996
+ if (!options.enableViteRequested) {
1997
+ return { enableVite: false, generatedViteConfigPath: null };
1998
+ }
1999
+ const viteMode = await resolveViteMode(options.cwd, { requested: true });
2000
+ if (!viteMode.enableVite) {
2001
+ options.logger?.info("Vite disabled: no vite config found for this package");
2002
+ return { enableVite: false, generatedViteConfigPath: null };
2003
+ }
2004
+ const generatedViteConfigPath = await writeGeneratedViteConfig({
2005
+ cwd: options.cwd,
2006
+ configPath: options.configPath,
2007
+ localConfigPath: viteMode.viteConfigPath,
2008
+ bridgePort: options.miniflarePort
2009
+ });
2010
+ options.logger?.debug(`Generated Vite config → ${generatedViteConfigPath}`);
2011
+ return { enableVite: true, generatedViteConfigPath };
2012
+ }
2013
+
2014
+ // src/dev-server/dev-server-state.ts
2015
+ function createDevServerState(initial) {
2016
+ return {
2017
+ enableVite: initial.enableVite,
2018
+ miniflare: null,
2019
+ doBundler: null,
2020
+ workerSourceWatcher: null,
2021
+ workerWatchTargets: [],
2022
+ viteProcess: null,
2023
+ config: null,
2024
+ browserShim: null,
2025
+ browserShimPort: initial.browserShimPort ?? 8788,
2026
+ mainWorkerSurfacePaths: {
2027
+ fetch: null,
2028
+ queue: null,
2029
+ scheduled: null,
2030
+ email: null
2031
+ },
2032
+ resolvedWorkerConfigPath: null,
2033
+ mainWorkerScriptPath: null,
2034
+ bundledMainWorkerScriptPath: null,
2035
+ currentDoResult: null,
2036
+ mainWorkerRoutes: null,
2037
+ generatedViteConfigPath: null
2038
+ };
2039
+ }
2040
+ async function disposeDevServerState(state) {
2041
+ if (state.doBundler) {
2042
+ await state.doBundler.close();
2043
+ state.doBundler = null;
2044
+ }
2045
+ if (state.workerSourceWatcher) {
2046
+ await state.workerSourceWatcher.close();
2047
+ state.workerSourceWatcher = null;
2048
+ }
2049
+ if (state.miniflare) {
2050
+ await state.miniflare.dispose();
2051
+ state.miniflare = null;
2052
+ }
2053
+ if (state.viteProcess) {
2054
+ await stopSpawnedProcessTree(state.viteProcess);
2055
+ state.viteProcess = null;
2056
+ }
2057
+ if (state.browserShim) {
2058
+ await state.browserShim.stop();
2059
+ state.browserShim = null;
2060
+ }
2061
+ clearLocalSendEmailBindings();
2062
+ }
2063
+
2064
+ // src/dev-server/server.ts
2065
+ function createDevServer(options) {
2066
+ const {
2067
+ cwd,
2068
+ configPath,
2069
+ vitePort = 5173,
2070
+ miniflarePort = 8787,
2071
+ enableVite: enableViteRequested = true,
2072
+ persist = true,
2073
+ logger,
2074
+ verbose = false,
2075
+ debug = process.env.DEVFLARE_DEBUG === "true"
2076
+ } = options;
2077
+ const state = createDevServerState({ enableVite: enableViteRequested });
2078
+ const reloadQueue = createReloadQueue({
2079
+ reload: async () => {
2080
+ if (!state.miniflare)
2081
+ return;
2082
+ const { Log, LogLevel } = await import("miniflare");
2083
+ const mfConfig = buildMiniflareConfig(state.currentDoResult);
2084
+ mfConfig.log = createCompatibilityAwareMiniflareLog(Log, LogLevel.DEBUG, logger);
2085
+ mfConfig.handleRuntimeStdio = createRuntimeStdioForwarder(logger);
2086
+ logger?.info("Reloading Miniflare...");
2087
+ await state.miniflare.setOptions(mfConfig);
2088
+ logger?.success("Miniflare reloaded");
2089
+ },
2090
+ logger
2091
+ });
2092
+ async function bundleMainWorker() {
2093
+ if (!state.mainWorkerScriptPath || !state.config) {
2094
+ state.bundledMainWorkerScriptPath = null;
2095
+ return;
2096
+ }
2097
+ state.bundledMainWorkerScriptPath = await bundleWorkerEntry({
2098
+ cwd,
2099
+ inputFile: state.mainWorkerScriptPath,
2100
+ outFile: resolve5(cwd, ".devflare", "worker-entrypoints", "main.js"),
2101
+ rolldownOptions: state.config.rolldown?.options,
2102
+ sourcemap: state.config.rolldown?.sourcemap,
2103
+ minify: state.config.rolldown?.minify,
2104
+ logger
2105
+ });
2106
+ logger?.debug(`Bundled main worker → ${state.bundledMainWorkerScriptPath}`);
2107
+ }
2108
+ function buildMiniflareConfig(doResult) {
2109
+ if (!state.config)
2110
+ throw new Error("Config not loaded");
2111
+ return buildMiniflareDevConfig({
2112
+ config: state.config,
2113
+ cwd,
2114
+ miniflarePort,
2115
+ persist,
2116
+ enableVite: state.enableVite,
2117
+ debug,
2118
+ mainWorkerSurfacePaths: state.mainWorkerSurfacePaths,
2119
+ mainWorkerRoutes: state.mainWorkerRoutes,
2120
+ mainWorkerScriptPath: state.mainWorkerScriptPath,
2121
+ bundledMainWorkerScriptPath: state.bundledMainWorkerScriptPath,
2122
+ browserShimPort: state.browserShimPort,
2123
+ doResult,
2124
+ logger
2125
+ });
2126
+ }
2127
+ async function startMiniflare(doResult) {
2128
+ const { Miniflare, Log, LogLevel } = await import("miniflare");
2129
+ const mfConfig = buildMiniflareConfig(doResult);
2130
+ mfConfig.log = createCompatibilityAwareMiniflareLog(Log, LogLevel.DEBUG, logger);
2131
+ mfConfig.handleRuntimeStdio = createRuntimeStdioForwarder(logger);
2132
+ const shouldLogMiniflareDiagnostics = verbose || debug;
2133
+ if (shouldLogMiniflareDiagnostics) {
2134
+ logMiniflareConfigDiagnostics(logger, mfConfig);
2135
+ }
2136
+ state.miniflare = new Miniflare(mfConfig);
2137
+ await state.miniflare.ready;
2138
+ logger?.success(`Miniflare ready on http://localhost:${miniflarePort}`);
2139
+ if (shouldLogMiniflareDiagnostics) {
2140
+ await logMiniflareBindingDiagnostics(logger, state.miniflare, mfConfig);
2141
+ }
2142
+ }
2143
+ async function reloadMiniflare(doResult) {
2144
+ state.currentDoResult = doResult;
2145
+ await reloadQueue.schedule();
2146
+ }
2147
+ async function refreshWorkerOnlySurfaceState() {
2148
+ if (!state.config) {
2149
+ return;
2150
+ }
2151
+ state.mainWorkerSurfacePaths = await resolveMainWorkerSurfacePaths(cwd, state.config);
2152
+ state.mainWorkerRoutes = await discoverRoutes(cwd, state.config);
2153
+ const composedMainEntry = await prepareComposedWorkerEntrypoint(cwd, state.config, undefined, {
2154
+ devInternalEmail: true
2155
+ });
2156
+ state.mainWorkerScriptPath = composedMainEntry ? composedMainEntry : null;
2157
+ if (state.mainWorkerScriptPath) {
2158
+ await bundleMainWorker();
2159
+ } else {
2160
+ state.bundledMainWorkerScriptPath = null;
2161
+ }
2162
+ await syncWorkerWatchTargets();
2163
+ }
2164
+ function getWorkerWatchTargets() {
2165
+ if (state.enableVite || !state.config) {
2166
+ return [];
2167
+ }
2168
+ const targets = collectWorkerWatchRoots(cwd, state.config, state.mainWorkerSurfacePaths);
2169
+ if (state.resolvedWorkerConfigPath) {
2170
+ targets.push(state.resolvedWorkerConfigPath);
2171
+ }
2172
+ return [...new Set(targets)];
2173
+ }
2174
+ async function syncWorkerWatchTargets() {
2175
+ if (!state.workerSourceWatcher) {
2176
+ return;
2177
+ }
2178
+ state.workerWatchTargets = await applyWatcherTargetDiff(state.workerSourceWatcher, state.workerWatchTargets, getWorkerWatchTargets());
2179
+ }
2180
+ async function reloadWorkerOnlyConfig() {
2181
+ state.config = await loadConfig({ cwd, configFile: configPath });
2182
+ setLocalSendEmailBindings(state.config.bindings?.sendEmail ?? {});
2183
+ state.resolvedWorkerConfigPath = await resolveWorkerConfigWatchPath(cwd, configPath);
2184
+ await refreshWorkerOnlySurfaceState();
2185
+ await reloadMiniflare(state.currentDoResult);
2186
+ }
2187
+ async function startWorkerSourceWatcher2() {
2188
+ if (state.enableVite || !state.config) {
2189
+ return;
2190
+ }
2191
+ const watchTargets = getWorkerWatchTargets();
2192
+ if (watchTargets.length === 0) {
2193
+ return;
2194
+ }
2195
+ state.workerWatchTargets = watchTargets;
2196
+ state.workerSourceWatcher = await startWorkerSourceWatcher({
2197
+ watchTargets,
2198
+ resolvedWorkerConfigPath: state.resolvedWorkerConfigPath,
2199
+ logger,
2200
+ onConfigChange: reloadWorkerOnlyConfig,
2201
+ onWorkerChange: async () => {
2202
+ await refreshWorkerOnlySurfaceState();
2203
+ await reloadMiniflare(state.currentDoResult);
2204
+ }
2205
+ });
2206
+ }
2207
+ async function start() {
2208
+ logger?.info("Starting unified dev server...");
2209
+ state.config = await loadConfig({ cwd, configFile: configPath });
2210
+ setLocalSendEmailBindings(state.config.bindings?.sendEmail ?? {});
2211
+ state.resolvedWorkerConfigPath = await resolveWorkerConfigWatchPath(cwd, configPath);
2212
+ logger?.debug("Loaded config:", state.config.name);
2213
+ const viteIntegration = await resolveViteIntegration({
2214
+ cwd,
2215
+ configPath,
2216
+ miniflarePort,
2217
+ enableViteRequested: state.enableVite,
2218
+ logger
2219
+ });
2220
+ state.enableVite = viteIntegration.enableVite;
2221
+ state.generatedViteConfigPath = viteIntegration.generatedViteConfigPath;
2222
+ await refreshWorkerOnlySurfaceState();
2223
+ if (!state.enableVite && (hasWorkerSurfacePaths(state.mainWorkerSurfacePaths) || Boolean(state.mainWorkerRoutes?.routes.length))) {
2224
+ logWorkerHandlerDetection(logger, state.enableVite, true, state.mainWorkerSurfacePaths, state.mainWorkerRoutes);
2225
+ } else if (!state.enableVite) {
2226
+ logWorkerHandlerDetection(logger, state.enableVite, false, state.mainWorkerSurfacePaths, state.mainWorkerRoutes);
2227
+ }
2228
+ const remoteCheck = await checkRemoteBindingRequirements(state.config);
2229
+ logRemoteBindingRequirements(logger, remoteCheck);
2230
+ state.browserShim = await maybeStartBrowserShim(state.config, { browserShimPort: state.browserShimPort, logger, verbose });
2231
+ const doInit = await maybeStartDOBundler(state.config, {
2232
+ cwd,
2233
+ logger,
2234
+ onRebuild: async (result) => {
2235
+ await reloadMiniflare(result);
2236
+ }
2237
+ });
2238
+ state.doBundler = doInit.bundler;
2239
+ const doResult = doInit.result;
2240
+ state.currentDoResult = doResult;
2241
+ await startMiniflare(doResult);
2242
+ await startWorkerSourceWatcher2();
2243
+ if (state.enableVite) {
2244
+ state.viteProcess = await startViteProcess({
2245
+ cwd,
2246
+ vitePort,
2247
+ miniflarePort,
2248
+ generatedViteConfigPath: state.generatedViteConfigPath,
2249
+ logger
2250
+ });
2251
+ } else {
2252
+ logger?.info("Vite startup skipped (no effective Vite config found for this package)");
2253
+ }
2254
+ await new Promise((r) => setTimeout(r, 1000));
2255
+ await runD1Migrations({ cwd, config: state.config, miniflarePort, logger });
2256
+ }
2257
+ async function stop() {
2258
+ await disposeDevServerState(state);
2259
+ }
2260
+ function getMiniflare() {
2261
+ return state.miniflare;
2262
+ }
2263
+ return {
2264
+ start,
2265
+ stop,
2266
+ getMiniflare
2267
+ };
2268
+ }
2269
+ // src/cli/commands/dev.ts
2270
+ async function createLogWriter(cwd, options) {
2271
+ if (!options.log && !options.logTemp) {
2272
+ return null;
2273
+ }
2274
+ const fs = await import("node:fs");
2275
+ let logPath;
2276
+ if (options.logTemp) {
2277
+ logPath = resolve6(cwd, ".log");
2278
+ } else {
2279
+ const now = new Date;
2280
+ const timestamp = now.toISOString().replace(/[:.]/g, "-").replace("T", "_").slice(0, 19);
2281
+ logPath = resolve6(cwd, `.log-${timestamp}`);
2282
+ }
2283
+ const fileStream = fs.createWriteStream(logPath, { flags: "w" });
2284
+ const ansiRegex = /\x1b\[[0-9;]*m/g;
2285
+ return {
2286
+ path: logPath,
2287
+ write(data, source) {
2288
+ const str = typeof data === "string" ? data : data.toString();
2289
+ if (!str.trim())
2290
+ return;
2291
+ const timestamp = new Date().toISOString().slice(11, 23);
2292
+ const prefix = source ? `[${timestamp}][${source.toUpperCase()}] ` : `[${timestamp}] `;
2293
+ const cleanStr = str.replace(ansiRegex, "");
2294
+ fileStream.write(prefix + cleanStr + (cleanStr.endsWith(`
2295
+ `) ? "" : `
2296
+ `));
2297
+ },
2298
+ close() {
2299
+ fileStream.end();
2300
+ }
2301
+ };
2302
+ }
2303
+ async function runDevCommand(parsed, logger, options) {
2304
+ const cwd = options.cwd || parsed.options.cwd || process.cwd();
2305
+ const configPath = parsed.options.config;
2306
+ const port = parsed.options.port;
2307
+ const logEnabled = parsed.options.log === true;
2308
+ const logTempEnabled = parsed.options["log-temp"] === true;
2309
+ const persistEnabled = parsed.options.persist === true;
2310
+ const debugEnabled = parsed.options.debug === true || process.env.DEVFLARE_DEBUG === "true";
2311
+ const verbose = parsed.options.verbose === true || debugEnabled;
2312
+ const theme = createCliTheme(parsed.options);
2313
+ const config = await loadConfig({ cwd, configFile: configPath });
2314
+ const viteProject = resolveEffectiveViteProject(await detectViteProject(cwd), config);
2315
+ const logWriter = await createLogWriter(cwd, {
2316
+ log: logEnabled,
2317
+ logTemp: logTempEnabled
2318
+ });
2319
+ if (logWriter) {
2320
+ const logFile = relative(cwd, logWriter.path) || ".log";
2321
+ logLine(logger, `${dim("logging", theme)} ${logFile}`);
2322
+ }
2323
+ const devLogger = createConsola({
2324
+ level: verbose ? 4 : 3
2325
+ });
2326
+ if (logWriter) {
2327
+ const wrapLog = (original, prefix = "") => {
2328
+ return (message, ...args) => {
2329
+ original(message, ...args);
2330
+ const formatted = prefix ? `${prefix} ${[message, ...args].join(" ")}` : [message, ...args].join(" ");
2331
+ logWriter.write(formatted);
2332
+ };
2333
+ };
2334
+ Object.assign(devLogger.log, wrapLog(devLogger.log.bind(devLogger)));
2335
+ Object.assign(devLogger.info, wrapLog(devLogger.info.bind(devLogger)));
2336
+ Object.assign(devLogger.error, wrapLog(devLogger.error.bind(devLogger), "[ERROR]"));
2337
+ Object.assign(devLogger.warn, wrapLog(devLogger.warn.bind(devLogger), "[WARN]"));
2338
+ Object.assign(devLogger.success, wrapLog(devLogger.success.bind(devLogger), "[OK]"));
2339
+ Object.assign(devLogger.debug, wrapLog(devLogger.debug.bind(devLogger), "[DEBUG]"));
2340
+ }
2341
+ try {
2342
+ logLine(logger);
2343
+ if (viteProject.shouldStartVite) {
2344
+ logLine(logger, `${cyanBold("dev", theme)} ${dim("Unified Dev Server", theme)}`);
2345
+ logLine(logger, " ├─ Vite: Full HMR for frontend");
2346
+ logLine(logger, " ├─ Miniflare: All Cloudflare bindings");
2347
+ logLine(logger, " ├─ Rolldown: Worker + DO bundling with watch");
2348
+ logLine(logger, " └─ Bridge: WebSocket RPC connection");
2349
+ } else {
2350
+ logLine(logger, `${cyanBold("dev", theme)} ${dim("Worker Dev Server", theme)}`);
2351
+ logLine(logger, " ├─ Miniflare: All Cloudflare bindings");
2352
+ logLine(logger, " ├─ Rolldown: Worker + DO bundling with watch");
2353
+ logLine(logger, " └─ Vite: Disabled (no effective Vite config found)");
2354
+ if (viteProject.wantsViteIntegration) {
2355
+ logger.warn("Vite-related settings were detected, but no effective Vite config was available");
2356
+ logger.warn("Skipping Vite startup and running in worker-only mode");
2357
+ }
2358
+ }
2359
+ logLine(logger);
2360
+ const devServer = createDevServer({
2361
+ cwd,
2362
+ configPath,
2363
+ vitePort: port ? parseInt(port, 10) : 5173,
2364
+ miniflarePort: 8787,
2365
+ enableVite: viteProject.shouldStartVite,
2366
+ persist: persistEnabled,
2367
+ logger: devLogger,
2368
+ verbose,
2369
+ debug: debugEnabled
2370
+ });
2371
+ let isCleaningUp = false;
2372
+ const cleanupHandlers = new Map;
2373
+ const removeCleanupHandlers = () => {
2374
+ for (const [event, handler] of cleanupHandlers) {
2375
+ process.off(event, handler);
2376
+ }
2377
+ cleanupHandlers.clear();
2378
+ };
2379
+ const cleanup = async (exitCode, reason) => {
2380
+ if (isCleaningUp) {
2381
+ return;
2382
+ }
2383
+ isCleaningUp = true;
2384
+ removeCleanupHandlers();
2385
+ if (reason) {
2386
+ const message = reason instanceof Error ? reason.stack ?? reason.message : String(reason);
2387
+ logger.error(message);
2388
+ }
2389
+ logLine(logger);
2390
+ logLine(logger, `${yellow("dev", theme)} ${dim("Shutting down…", theme)}`);
2391
+ try {
2392
+ await devServer.stop();
2393
+ } finally {
2394
+ logWriter?.close();
2395
+ process.exit(exitCode);
2396
+ }
2397
+ };
2398
+ const registerCleanupHandler = (event, handler) => {
2399
+ cleanupHandlers.set(event, handler);
2400
+ process.on(event, handler);
2401
+ };
2402
+ registerCleanupHandler("SIGINT", () => {
2403
+ cleanup(0);
2404
+ });
2405
+ registerCleanupHandler("SIGTERM", () => {
2406
+ cleanup(0);
2407
+ });
2408
+ registerCleanupHandler("SIGHUP", () => {
2409
+ cleanup(0);
2410
+ });
2411
+ registerCleanupHandler("uncaughtException", (error) => {
2412
+ cleanup(1, error);
2413
+ });
2414
+ registerCleanupHandler("unhandledRejection", (reason) => {
2415
+ cleanup(1, reason);
2416
+ });
2417
+ await devServer.start();
2418
+ await new Promise(() => {});
2419
+ return { exitCode: 0 };
2420
+ } catch (error) {
2421
+ logWriter?.close();
2422
+ if (error instanceof Error) {
2423
+ logger.error("Dev server failed:", error.message);
2424
+ if (verbose) {
2425
+ logger.error(error.stack);
2426
+ }
2427
+ }
2428
+ return { exitCode: 1 };
2429
+ }
2430
+ }
2431
+ export {
2432
+ runDevCommand
2433
+ };