devflare 1.0.0-next.24 → 1.0.0-next.28

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