devflare 1.0.0-next.24 → 1.0.0-next.27

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