void 0.22.0 → 0.23.0

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 (276) hide show
  1. package/README.md +5 -1
  2. package/dist/{account-cmd-CjyxcGkM.mjs → account-cmd-C84Ee8cO.mjs} +4 -4
  3. package/dist/{scan-ClYmX3sa.mjs → application-analysis-BVsVqc11.mjs} +135 -18
  4. package/dist/application-routing-B7QEjqSR.mjs +27 -0
  5. package/dist/{auth-CZuiVsFh.mjs → auth-CCjt0hcq.mjs} +1 -1
  6. package/dist/{auth-DLNN0D3Z.mjs → auth-CSkdO2Bb.mjs} +4 -47
  7. package/dist/{auth-link-BLO4ptzo.mjs → auth-link-CioEg6uY.mjs} +4 -4
  8. package/dist/{auth-router-ZUg9MF_U.mjs → auth-router-BsR981d4.mjs} +4 -4
  9. package/dist/{better-auth-shared-rsBGBvWJ.mjs → better-auth-shared-hy6RPh9W.mjs} +13 -2
  10. package/dist/{build-cmd-BxR5FROK.mjs → build-cmd-LzvNJORH.mjs} +17 -5
  11. package/dist/{cache-D0sWhgKI.mjs → cache-C4MvnrMH.mjs} +2 -2
  12. package/dist/{cancel-deploy-D4NUqFbi.mjs → cancel-deploy-abUxpP2n.mjs} +2 -2
  13. package/dist/{cf-build-output-BJ6yGEIS.mjs → cf-build-output-BPqOT964.mjs} +2 -1
  14. package/dist/cf-build-output-_0HNWysu.mjs +2 -0
  15. package/dist/cli/cli.mjs +80 -455
  16. package/dist/cli/{cf-compat.mjs → cloudflare-operation-process.mjs} +442 -421
  17. package/dist/cli/env-schema-probe.d.mts +2 -1
  18. package/dist/cli/env-schema-probe.mjs +3 -3
  19. package/dist/client-Cu7jWiF1.mjs +2 -0
  20. package/dist/{client-BTZ3XkrB.mjs → client-RV8NVeB8.mjs} +140 -21
  21. package/dist/{cloudflare-auth-DQkqoMYa.mjs → cloudflare-auth-Qdc7tw8F.mjs} +41 -38
  22. package/dist/{cloudflare-cmd-BKlfGHAy.mjs → cloudflare-cmd-BcrVyTmJ.mjs} +5 -5
  23. package/dist/cloudflare-config-Bktvwtpf.mjs +182 -0
  24. package/dist/{cloudflare-connect-Ctmrw579.mjs → cloudflare-connect-B8uPZ4nx.mjs} +3 -3
  25. package/dist/{cloudflare-operations-BT6OWFBk.mjs → cloudflare-operations-AiWashgg.mjs} +1 -1
  26. package/dist/{cloudflare-operations-B9tzgjmf.mjs → cloudflare-operations-fxHb-byx.mjs} +116 -172
  27. package/dist/{preset-UHj9ARyP.mjs → cloudflare-process-B-wekeR6.mjs} +93 -6
  28. package/dist/{config-VavjpDnp.d.mts → config-BMHb8RCj.d.mts} +1 -0
  29. package/dist/config-C_XRIPx2.mjs +89 -0
  30. package/dist/config-entry.d.mts +1 -1
  31. package/dist/{connect-Dg-WkW-C.mjs → connect-Bd4kJd9U.mjs} +5 -5
  32. package/dist/{create-project-DdoqwFLF.mjs → create-project-Boczwj5r.mjs} +1 -1
  33. package/dist/{create-project-l9J7pbtm.mjs → create-project-bMf6ffLZ.mjs} +2 -2
  34. package/dist/{db-gp2sCXyN.mjs → db-8uG64XLl.mjs} +21 -21
  35. package/dist/{delete-TTedbH6B.mjs → delete-NvbiyeJf.mjs} +2 -2
  36. package/dist/{deploy-CH-o2CaZ.mjs → deploy-DzAIwqNU.mjs} +908 -582
  37. package/dist/{deploy-B19L2Bra.mjs → deploy-bjXdFCtn.mjs} +1 -1
  38. package/dist/{domain-JRF59P_r.mjs → domain-y5Tvydvo.mjs} +3 -3
  39. package/dist/{email-Bo6G9LOZ.mjs → email-B3umsW75.mjs} +13 -28
  40. package/dist/{env-BYOrWQnv.mjs → env-BS6qYHDb.mjs} +4 -4
  41. package/dist/{env-public-BxU_0yTL.d.mts → env-public-BX_r8HR6.d.mts} +1 -1
  42. package/dist/{env-validation-BB4GkLxn.mjs → env-validation-BPn7vk-V.mjs} +18 -71
  43. package/dist/{env-validation-BXge7uyK.mjs → env-validation-DbTg7-ar.mjs} +1 -1
  44. package/dist/{fetch-CXDChK7B.mjs → fetch-BIZJh7vR.mjs} +2 -2
  45. package/dist/{fetch-stream-AOByI7Ki.mjs → fetch-stream-IvCYKyQL.mjs} +24 -4
  46. package/dist/{gen-sCtlCOdA.mjs → gen-B580--vC.mjs} +2 -2
  47. package/dist/gen-BVaUUumi.mjs +2 -0
  48. package/dist/{github-cmd-0-7PexDq.mjs → github-cmd-v45BdfKX.mjs} +2 -2
  49. package/dist/{handler-HEcZsaij.d.mts → handler-CZ4nAylQ.d.mts} +1 -1
  50. package/dist/help-DofyZuY7.mjs +2 -0
  51. package/dist/{help-GKtwl07I.mjs → help-daGKjXGk.mjs} +229 -747
  52. package/dist/index.d.mts +1 -1
  53. package/dist/index.mjs +288 -1502
  54. package/dist/info-B97bTX9N.mjs +113 -0
  55. package/dist/{init-FZx3Elvz.mjs → init-Bvy7zrBo.mjs} +46 -15
  56. package/dist/limits-Bq5LG8Id.d.mts +27 -0
  57. package/dist/limits-Cjuk2VPm.mjs +68 -0
  58. package/dist/{link-BrQfb_CU.mjs → link-CDqqCjFl.mjs} +3 -3
  59. package/dist/{list-D44jmIAM.mjs → list-CZj0dzKY.mjs} +3 -3
  60. package/dist/{live-CKJlvlNp.d.mts → live-Chw1eIMv.d.mts} +1 -1
  61. package/dist/{local-d1-Bg9OzEEO.mjs → local-d1-2CMnpuW_.mjs} +2 -2
  62. package/dist/login-DYt_An22.mjs +2 -0
  63. package/dist/{login-CAsAsQ-_.mjs → login-UZKFM_u7.mjs} +3 -3
  64. package/dist/{logs-BjKvFnVM.mjs → logs-CUZ6t9t3.mjs} +3 -3
  65. package/dist/migrate-8_2u55MD.mjs +2 -0
  66. package/dist/{migrate-BPITvDJN.mjs → migrate-DHul7PRV.mjs} +2 -1
  67. package/dist/{node-Dt7z256D.mjs → node-BkyRWRx8.mjs} +1 -1
  68. package/dist/operator-args-CLgKGlwU.mjs +690 -0
  69. package/dist/{operator-cmd-BK5CCiT9.mjs → operator-cmd-DBA6dl0m.mjs} +68 -22
  70. package/dist/pages/client.d.mts +34 -2
  71. package/dist/pages/client.mjs +59 -3
  72. package/dist/pages/index.d.mts +1 -1
  73. package/dist/pages/index.mjs +1 -1
  74. package/dist/pages/islands-plugin.mjs +1 -1
  75. package/dist/pages/protocol.d.mts +2 -2
  76. package/dist/pages/protocol.mjs +2 -308
  77. package/dist/{parse-filename-DioPHiR9.mjs → parse-filename-CUbj-1MP.mjs} +35 -1
  78. package/dist/plan-D1Q5rf-r.mjs +2 -0
  79. package/dist/plan-NPpwZ_kc.mjs +58 -0
  80. package/dist/platform-args-BJdRtlLq.mjs +506 -0
  81. package/dist/platform-args-D3RXyR6h.mjs +2 -0
  82. package/dist/{platform-auth-config-BlN8xTdD.mjs → platform-auth-config-B56E9YP1.mjs} +3 -3
  83. package/dist/{platform-auth-protection-7d5aV2Jg.mjs → platform-auth-protection-BDWO_aER.mjs} +2 -2
  84. package/dist/{platform-auth-recovery-Dxij8ZbR.mjs → platform-auth-recovery-1gg4CSRe.mjs} +3 -3
  85. package/dist/{platform-cmd-E0FuL212.mjs → platform-cmd-Bt-1w6pY.mjs} +1 -1
  86. package/dist/{platform-cmd-B3hwKrFK.mjs → platform-cmd-DMcQStSc.mjs} +24 -3
  87. package/dist/{platform-domain-D6Xcy9ZX.mjs → platform-domain-BNkcz0OB.mjs} +2 -2
  88. package/dist/{platform-lifecycle-k0E0xoxx.mjs → platform-lifecycle-9OyBALhH.mjs} +327 -215
  89. package/dist/{platform-lifecycle-DMh_qrry.mjs → platform-lifecycle-BE6C_jxh.mjs} +1 -1
  90. package/dist/{platform-management-Brz_BDiT.mjs → platform-management-CjwLVQwN.mjs} +6 -3
  91. package/dist/{platform-management-DOtss0BN.mjs → platform-management-CnyTdcWX.mjs} +1 -1
  92. package/dist/platform-plans-config-BNGKGr4P.mjs +359 -0
  93. package/dist/{platform-recovery-BvtcXON5.mjs → platform-recovery-D6KSpuFm.mjs} +2 -2
  94. package/dist/{plugin-inference-BMfKRSqE.mjs → plugin-inference-CXWnn79A.mjs} +174 -64
  95. package/dist/{prepare-C-6YZyyg.mjs → prepare-B5Mkic5u.mjs} +1 -1
  96. package/dist/{prepare-CRhJbVrG.mjs → prepare-DOsL0CC9.mjs} +4 -20
  97. package/dist/prepare-cgvDMtSb.mjs +2 -0
  98. package/dist/{project-cmd-BZLCqOqw.mjs → project-cmd-CNzrqvBv.mjs} +16 -16
  99. package/dist/{project-team-BvgM0WoX.mjs → project-team-DQOWPfQT.mjs} +2 -2
  100. package/dist/{project-token-l5DqK6Az.mjs → project-token-CTDYU0Cc.mjs} +2 -2
  101. package/dist/{project-zero-trust-v6Mvpp8y.mjs → project-zero-trust-BNAkW-_0.mjs} +2 -2
  102. package/dist/{protocol-BBa6cstI.d.mts → protocol-CjF_iI9X.d.mts} +2 -2
  103. package/dist/protocol-U7bfjHmA.mjs +331 -0
  104. package/dist/{provision-Fr9pRqce.mjs → provision-C4ORE7G7.mjs} +1 -1
  105. package/dist/{provision-C4IGqkBf.mjs → provision-CJFgTZY8.mjs} +89 -198
  106. package/dist/{requests-DN-BbNiM.mjs → requests-MhxYnau8.mjs} +2 -2
  107. package/dist/resource-name-C7LVpcRm.mjs +11 -0
  108. package/dist/{rollback-D7rzSaZM.mjs → rollback-CJ6iSDoU.mjs} +3 -3
  109. package/dist/route-url-CG7U-cRN.mjs +15 -0
  110. package/dist/{runner-B8wXwWlo.mjs → runner-CXA9Fh8h.mjs} +1 -1
  111. package/dist/{runner-p-dMs2UN.mjs → runner-Ol0TNjk6.mjs} +2 -2
  112. package/dist/runtime/ai.d.mts +12 -8
  113. package/dist/runtime/ai.mjs +84 -17
  114. package/dist/runtime/better-auth-mysql.mjs +1 -1
  115. package/dist/runtime/better-auth-pg.mjs +1 -1
  116. package/dist/runtime/better-auth.mjs +1 -1
  117. package/dist/runtime/client-react.mjs +2 -2
  118. package/dist/runtime/client-solid.mjs +2 -2
  119. package/dist/runtime/client-svelte.mjs +2 -2
  120. package/dist/runtime/client-vue.mjs +2 -2
  121. package/dist/runtime/client.mjs +2 -2
  122. package/dist/runtime/durable.d.mts +3 -1
  123. package/dist/runtime/durable.mjs +4 -1
  124. package/dist/runtime/email/testing.mjs +1 -1
  125. package/dist/runtime/env-public.d.mts +1 -1
  126. package/dist/runtime/fetch-stream.mjs +1 -1
  127. package/dist/runtime/fetch.mjs +1 -1
  128. package/dist/runtime/handler.d.mts +1 -1
  129. package/dist/runtime/kv.mjs +0 -1
  130. package/dist/runtime/limits.d.mts +2 -0
  131. package/dist/runtime/limits.mjs +2 -0
  132. package/dist/runtime/live-client.d.mts +1 -1
  133. package/dist/runtime/live-server.mjs +25 -16
  134. package/dist/runtime/live.d.mts +1 -1
  135. package/dist/runtime/migration-handler.mjs +62 -42
  136. package/dist/runtime/route-url.d.mts +4 -0
  137. package/dist/runtime/route-url.mjs +2 -0
  138. package/dist/runtime/routing.d.mts +180 -0
  139. package/dist/runtime/routing.mjs +1082 -0
  140. package/dist/runtime/sandbox-container.d.mts +1 -1
  141. package/dist/runtime/sandbox-container.mjs +1 -1
  142. package/dist/runtime/sandbox.d.mts +3 -3
  143. package/dist/runtime/sandbox.mjs +75 -45
  144. package/dist/runtime/sse.mjs +1 -1
  145. package/dist/runtime/validator.d.mts +1 -1
  146. package/dist/runtime/ws-server.d.mts +4 -2
  147. package/dist/runtime/ws-server.mjs +27 -2
  148. package/dist/runtime/ws.d.mts +2 -2
  149. package/dist/runtime/ws.mjs +8 -6
  150. package/dist/{sandbox-qpNBT8a3.d.mts → sandbox-XZAqzFlG.d.mts} +11 -8
  151. package/dist/{sandbox-container-DdNEBfCc.d.mts → sandbox-container-Bo0eiFKz.d.mts} +2 -1
  152. package/dist/{sandbox-container-4fdqLnyb.mjs → sandbox-container-C6ItmVuN.mjs} +4 -2
  153. package/dist/{scan-4tfN-PSn.mjs → scan-C7okrLyM.mjs} +4 -35
  154. package/dist/{secret-BOtOl_cb.mjs → secret-Dli5fP0B.mjs} +4 -4
  155. package/dist/{sse-BaC1jXko.mjs → sse-CQNaDFFV.mjs} +6 -3
  156. package/dist/validate-Dq_L3s0S.mjs +2 -0
  157. package/dist/{validate-CIUwFpjB.mjs → validate-ctOrgiS3.mjs} +2 -1
  158. package/dist/{wrangler-DQF1vKyf.mjs → wrangler-7K-bW_DL.mjs} +8 -239
  159. package/dist/{ws-BoY7vQML.d.mts → ws-CL1w7GXU.d.mts} +13 -2
  160. package/package.json +15 -8
  161. package/skills/migrate-vite-cloudflare-to-void/SKILL.md +34 -157
  162. package/skills/void/SKILL.md +50 -135
  163. package/skills/void/docs/guide/ai.md +94 -84
  164. package/skills/void/docs/guide/app-types.md +3 -32
  165. package/skills/void/docs/guide/auth.md +12 -116
  166. package/skills/void/docs/guide/database/d1.md +9 -54
  167. package/skills/void/docs/guide/database/mysql.md +1 -1
  168. package/skills/void/docs/guide/database/postgresql.md +5 -26
  169. package/skills/void/docs/guide/database.md +23 -75
  170. package/skills/void/docs/guide/deployment.md +27 -113
  171. package/skills/void/docs/guide/durable-state.md +43 -18
  172. package/skills/void/docs/guide/edge/headers.md +3 -47
  173. package/skills/void/docs/guide/edge/prerendering.md +5 -20
  174. package/skills/void/docs/guide/edge/redirects.md +11 -64
  175. package/skills/void/docs/guide/edge/revalidation.md +5 -18
  176. package/skills/void/docs/guide/edge/rewrites.md +56 -284
  177. package/skills/void/docs/guide/edge/static-assets.md +22 -72
  178. package/skills/void/docs/guide/email/domains.md +112 -0
  179. package/skills/void/docs/guide/email/receiving.md +139 -0
  180. package/skills/void/docs/guide/email/sending.md +231 -0
  181. package/skills/void/docs/guide/email.md +13 -619
  182. package/skills/void/docs/guide/env-migration.md +11 -11
  183. package/skills/void/docs/guide/env-vars.md +9 -29
  184. package/skills/void/docs/guide/index.md +0 -15
  185. package/skills/void/docs/guide/jobs.md +3 -18
  186. package/skills/void/docs/guide/kv.md +5 -11
  187. package/skills/void/docs/guide/live.md +5 -56
  188. package/skills/void/docs/guide/pages-routing/actions-and-forms.md +78 -125
  189. package/skills/void/docs/guide/pages-routing/head.md +10 -10
  190. package/skills/void/docs/guide/pages-routing/islands.md +6 -36
  191. package/skills/void/docs/guide/pages-routing/layouts.md +6 -128
  192. package/skills/void/docs/guide/pages-routing/loaders.md +3 -19
  193. package/skills/void/docs/guide/pages-routing/markdown.md +13 -171
  194. package/skills/void/docs/guide/pages-routing/overview.md +7 -17
  195. package/skills/void/docs/guide/pages-routing/view-transitions.md +1 -1
  196. package/skills/void/docs/guide/platform/administration/access.md +1 -4
  197. package/skills/void/docs/guide/platform/administration/email.md +35 -8
  198. package/skills/void/docs/guide/platform/administration/operations.md +26 -4
  199. package/skills/void/docs/guide/platform/administration/plans.md +126 -0
  200. package/skills/void/docs/guide/platform/administration/projects.md +5 -2
  201. package/skills/void/docs/guide/platform/administration/zero-trust.md +23 -152
  202. package/skills/void/docs/guide/platform/development/runtime.md +3 -13
  203. package/skills/void/docs/guide/platform/development/schema-ci.md +0 -58
  204. package/skills/void/docs/guide/platform/installation/credentials.md +6 -4
  205. package/skills/void/docs/guide/platform/installation/domains.md +30 -2
  206. package/skills/void/docs/guide/platform/installation/first-deployment.md +2 -0
  207. package/skills/void/docs/guide/platform/installation/maintenance.md +3 -1
  208. package/skills/void/docs/guide/platform/installation/prerequisites.md +20 -15
  209. package/skills/void/docs/guide/platform/installation/setup.md +9 -5
  210. package/skills/void/docs/guide/platform-administration.md +1 -0
  211. package/skills/void/docs/guide/queues.md +7 -9
  212. package/skills/void/docs/guide/quickstart.md +38 -37
  213. package/skills/void/docs/guide/remote-dev.md +4 -9
  214. package/skills/void/docs/guide/sandboxes.md +29 -21
  215. package/skills/void/docs/guide/server-routing.md +9 -72
  216. package/skills/void/docs/guide/sse.md +4 -18
  217. package/skills/void/docs/guide/ssg.md +3 -15
  218. package/skills/void/docs/guide/ssr.md +14 -62
  219. package/skills/void/docs/guide/storage.md +9 -4
  220. package/skills/void/docs/guide/type-safety.md +3 -14
  221. package/skills/void/docs/guide/typed-fetch.md +3 -7
  222. package/skills/void/docs/guide/websockets.md +68 -40
  223. package/skills/void/docs/integrations/agents.md +3 -3
  224. package/skills/void/docs/integrations/cloudflare.md +85 -316
  225. package/skills/void/docs/integrations/frameworks/analog.md +5 -64
  226. package/skills/void/docs/integrations/frameworks/astro.md +4 -73
  227. package/skills/void/docs/integrations/frameworks/nuxt.md +5 -62
  228. package/skills/void/docs/integrations/frameworks/overview.md +11 -54
  229. package/skills/void/docs/integrations/frameworks/react-router.md +5 -60
  230. package/skills/void/docs/integrations/frameworks/sveltekit.md +6 -65
  231. package/skills/void/docs/integrations/frameworks/tanstack-start.md +4 -62
  232. package/skills/void/docs/integrations/nodejs-bun-deno.md +5 -69
  233. package/skills/void/docs/reference/api/auth.md +156 -0
  234. package/skills/void/docs/reference/api/client.md +87 -0
  235. package/skills/void/docs/reference/api/database.md +95 -0
  236. package/skills/void/docs/reference/api/durable.md +46 -0
  237. package/skills/void/docs/reference/api/env.md +50 -0
  238. package/skills/void/docs/reference/api/handlers.md +254 -0
  239. package/skills/void/docs/reference/api/pages.md +241 -0
  240. package/skills/void/docs/reference/api/plugin.md +39 -0
  241. package/skills/void/docs/reference/api/resources.md +109 -0
  242. package/skills/void/docs/reference/api/rewrites.md +76 -0
  243. package/skills/void/docs/reference/api/types.md +92 -0
  244. package/skills/void/docs/reference/api.md +56 -1218
  245. package/skills/void/docs/reference/cli/auth.md +88 -0
  246. package/skills/void/docs/reference/cli/database.md +128 -0
  247. package/skills/void/docs/reference/cli/deploy.md +85 -0
  248. package/skills/void/docs/reference/cli/domains.md +41 -0
  249. package/skills/void/docs/reference/cli/email.md +129 -0
  250. package/skills/void/docs/reference/cli/generate.md +116 -0
  251. package/skills/void/docs/reference/cli/github.md +189 -0
  252. package/skills/void/docs/reference/cli/platform-config.md +92 -0
  253. package/skills/void/docs/reference/cli/platform-email.md +81 -0
  254. package/skills/void/docs/reference/cli/platform-installation.md +127 -0
  255. package/skills/void/docs/reference/cli/platform-operations.md +90 -0
  256. package/skills/void/docs/reference/cli/platform-users.md +89 -0
  257. package/skills/void/docs/reference/cli/platform-zero-trust.md +45 -0
  258. package/skills/void/docs/reference/cli/platform.md +70 -0
  259. package/skills/void/docs/reference/cli/project.md +214 -0
  260. package/skills/void/docs/reference/cli/secrets.md +76 -0
  261. package/skills/void/docs/reference/cli/setup.md +70 -0
  262. package/skills/void/docs/reference/cli.md +32 -1682
  263. package/skills/void/docs/reference/config.md +12 -18
  264. package/skills/void/docs/reference/resource-inference.md +3 -58
  265. package/skills/void/docs/reference/structure.md +14 -41
  266. package/dist/canonical-json-DuDiiUsQ.mjs +0 -13
  267. package/dist/client-Czz8o5jP.mjs +0 -2
  268. package/dist/gen-CNJ62MM7.mjs +0 -2
  269. package/dist/help-CmZzxUba.mjs +0 -2
  270. package/dist/login-CGcRKEoi.mjs +0 -2
  271. package/dist/migrate-CYfbKkXh.mjs +0 -2
  272. package/dist/plan-BEZ8VJW0.mjs +0 -256
  273. package/dist/plan-DpuOr14e.mjs +0 -2
  274. package/dist/prepare-Bm3iq-u4.mjs +0 -2
  275. package/dist/validate-EKmJWxmy.mjs +0 -2
  276. /package/dist/cli/{cf-compat.d.mts → cloudflare-operation-process.d.mts} +0 -0
@@ -0,0 +1,1082 @@
1
+ import { t as convertReturnValue } from "../response-Tn7rU0MV.mjs";
2
+ import { t as VoidAssetRewriteError } from "../handler-DghKr6dU.mjs";
3
+ import { n as handlePageGet, r as handlePageMutation } from "../protocol-U7bfjHmA.mjs";
4
+ import { compilePattern, mergeQueryIntoLocation, substituteParams } from "@void/edge";
5
+ import { AsyncLocalStorage } from "node:async_hooks";
6
+ //#region src/runtime/routing-errors.ts
7
+ const __VOID_ERROR_PAGE_FONT_STACK = "system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, sans-serif";
8
+ const errorStack = Error;
9
+ /** Error rendering is shared by generated Pages apps; production never includes exception details. */
10
+ function createErrorRenderer(options) {
11
+ const __VOID_DEV = options.dev === true;
12
+ const __VOID_PROJECT_ROOT = options.projectRoot;
13
+ const __VOID_HOME_DIR = options.homeDir;
14
+ function __voidEscapeHtml(value) {
15
+ return String(value).replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll("\"", "&quot;");
16
+ }
17
+ function __voidShouldServeHtmlErrorPage(request) {
18
+ if (request.method !== "GET" && request.method !== "HEAD") return false;
19
+ const url = new URL(request.url);
20
+ if (url.pathname === "/api" || url.pathname.startsWith("/api/")) return false;
21
+ if (/\/[^/]+\.[^/]+$/.test(url.pathname)) return false;
22
+ const destination = request.headers.get("sec-fetch-dest");
23
+ if (destination && destination !== "document" && destination !== "empty") return false;
24
+ const accept = request.headers.get("accept");
25
+ return !accept || accept.includes("text/html") || accept.includes("*/*");
26
+ }
27
+ function __voidNormalizeFsPath(value) {
28
+ return typeof value === "string" ? value.replaceAll("\\", "/") : "";
29
+ }
30
+ function __voidIsAbsolutePath(value) {
31
+ return value.startsWith("/") || /^[A-Za-z]:\//.test(value);
32
+ }
33
+ function __voidDisplayPath(value) {
34
+ const path = __voidNormalizeFsPath(value);
35
+ const homeDir = __voidNormalizeFsPath(__VOID_HOME_DIR);
36
+ const projectRoot = __voidNormalizeFsPath(__VOID_PROJECT_ROOT);
37
+ if (!path) return "";
38
+ if (projectRoot && (path === projectRoot || path.startsWith(projectRoot + "/"))) {
39
+ const suffix = path.slice(projectRoot.length).replace(/^\/?/, "");
40
+ return suffix ? "./" + suffix : "./";
41
+ }
42
+ if (homeDir && (path === homeDir || path.startsWith(homeDir + "/"))) {
43
+ const suffix = path.slice(homeDir.length).replace(/^\/?/, "");
44
+ return suffix ? "~/" + suffix : "~/";
45
+ }
46
+ return path;
47
+ }
48
+ function __voidEditorHref(value, line, column) {
49
+ const path = __voidNormalizeFsPath(value);
50
+ if (!__voidIsAbsolutePath(path)) return "";
51
+ return "vscode://file/" + encodeURI(path).replaceAll("#", "%23").replaceAll("?", "%3F") + ":" + String(line) + ":" + String(column);
52
+ }
53
+ function __voidCreateStackFrame(functionName, file, line, column, raw) {
54
+ const normalizedFile = __voidNormalizeFsPath(file);
55
+ const lineNumber = Number(line);
56
+ const columnNumber = Number(column);
57
+ if (!normalizedFile || !Number.isFinite(lineNumber) || lineNumber <= 0) return null;
58
+ const safeColumn = Number.isFinite(columnNumber) && columnNumber > 0 ? columnNumber : 1;
59
+ return {
60
+ functionName: functionName || "",
61
+ file: normalizedFile,
62
+ line: lineNumber,
63
+ column: safeColumn,
64
+ displayPath: __voidDisplayPath(normalizedFile),
65
+ href: __voidEditorHref(normalizedFile, lineNumber, safeColumn),
66
+ raw: raw || ""
67
+ };
68
+ }
69
+ function __voidParseFrameLocation(value) {
70
+ const match = value.match(/^(.*):(\d+):(\d+)$/);
71
+ if (!match) return null;
72
+ return __voidCreateStackFrame("", match[1], Number(match[2]), Number(match[3]), value);
73
+ }
74
+ function __voidParseStackFrames(stack) {
75
+ if (!stack) return [];
76
+ const frames = [];
77
+ for (const rawLine of stack.split(/\n+/)) {
78
+ const line = rawLine.trim();
79
+ if (!line) continue;
80
+ let frame = null;
81
+ let match = line.match(/^at\s+(?:async\s+)?(.+?)\s+\((.+)\)$/);
82
+ if (match) {
83
+ const location = __voidParseFrameLocation(match[2]);
84
+ frame = location ? {
85
+ ...location,
86
+ functionName: match[1]
87
+ } : null;
88
+ } else {
89
+ match = line.match(/^at\s+(.+)$/);
90
+ if (match) frame = __voidParseFrameLocation(match[1]);
91
+ else {
92
+ match = line.match(/^(.*?)@(.+)$/);
93
+ if (match) {
94
+ const location = __voidParseFrameLocation(match[2]);
95
+ frame = location ? {
96
+ ...location,
97
+ functionName: match[1]
98
+ } : null;
99
+ }
100
+ }
101
+ }
102
+ if (frame) frames.push({
103
+ ...frame,
104
+ raw: line
105
+ });
106
+ }
107
+ return frames;
108
+ }
109
+ function __voidGetStackFrames(error) {
110
+ if (!(error instanceof Error)) return [];
111
+ if (!error.stack && typeof errorStack.captureStackTrace === "function") try {
112
+ errorStack.captureStackTrace(error, __voidGetStackFrames);
113
+ } catch {}
114
+ const originalPrepareStackTrace = errorStack.prepareStackTrace;
115
+ try {
116
+ errorStack.prepareStackTrace = (_, callSites) => callSites;
117
+ const structured = error.stack;
118
+ if (Array.isArray(structured)) {
119
+ const frames = [];
120
+ for (const callSite of structured) try {
121
+ const fileName = callSite.getFileName?.() || callSite.getScriptNameOrSourceURL?.();
122
+ const line = callSite.getLineNumber?.();
123
+ const column = callSite.getColumnNumber?.();
124
+ const frame = __voidCreateStackFrame(callSite.getFunctionName?.() || callSite.getMethodName?.() || "", fileName || "", line, column, String(callSite));
125
+ if (frame) frames.push(frame);
126
+ } catch {}
127
+ if (frames.length > 0) return frames;
128
+ }
129
+ } catch {} finally {
130
+ errorStack.prepareStackTrace = originalPrepareStackTrace;
131
+ }
132
+ return __voidParseStackFrames(typeof error.stack === "string" ? error.stack : "");
133
+ }
134
+ function __voidDescribeThrownValue(value) {
135
+ if (value instanceof Error) return {
136
+ name: value.name || "Error",
137
+ message: value.message || "",
138
+ stack: typeof value.stack === "string" ? value.stack : "",
139
+ frames: __voidGetStackFrames(value)
140
+ };
141
+ if (typeof value === "string") return {
142
+ name: "Thrown value",
143
+ message: value,
144
+ stack: "",
145
+ frames: []
146
+ };
147
+ let message = "";
148
+ try {
149
+ if (typeof value === "object" && value !== null) message = JSON.stringify(value, null, 2) ?? String(value);
150
+ else message = String(value);
151
+ } catch {
152
+ message = String(value);
153
+ }
154
+ return {
155
+ name: "Thrown value",
156
+ message,
157
+ stack: "",
158
+ frames: []
159
+ };
160
+ }
161
+ function __voidRenderStack(entry) {
162
+ if (Array.isArray(entry.frames) && entry.frames.length > 0) return `<div class="__void-error-stack"><div class="__void-error-stack-label">Stack trace</div><div class="__void-error-frames">${entry.frames.map((frame) => {
163
+ const name = frame.functionName || "(anonymous)";
164
+ const location = frame.displayPath + ":" + frame.line + ":" + frame.column;
165
+ const body = `<span class="__void-error-frame-function">${__voidEscapeHtml(name)}</span><span class="__void-error-frame-location">${__voidEscapeHtml(location)}</span>`;
166
+ if (frame.href) return `<a class="__void-error-frame" href="${__voidEscapeHtml(frame.href)}">${body}</a>`;
167
+ return `<div class="__void-error-frame is-static">${body}</div>`;
168
+ }).join("")}</div></div>`;
169
+ if (!entry.stack) return "";
170
+ return `<div class="__void-error-stack"><div class="__void-error-stack-label">Stack trace</div><pre>${__voidEscapeHtml(entry.stack)}</pre></div>`;
171
+ }
172
+ function __voidCollectErrorChain(error) {
173
+ const chain = [];
174
+ const seen = /* @__PURE__ */ new Set();
175
+ let current = error;
176
+ let depth = 0;
177
+ while (current != null && depth < 8 && !seen.has(current)) {
178
+ seen.add(current);
179
+ const entry = __voidDescribeThrownValue(current);
180
+ chain.push({
181
+ label: depth === 0 ? "Error" : "Cause " + depth,
182
+ ...entry
183
+ });
184
+ current = current instanceof Error ? current.cause : void 0;
185
+ depth += 1;
186
+ }
187
+ if (current != null) chain.push({
188
+ label: "Cause " + depth,
189
+ name: "Truncated",
190
+ message: "Additional nested causes were omitted.",
191
+ stack: "",
192
+ frames: []
193
+ });
194
+ if (chain.length === 0) chain.push({
195
+ label: "Error",
196
+ name: "Unknown error",
197
+ message: "No error details were available.",
198
+ stack: "",
199
+ frames: []
200
+ });
201
+ return chain;
202
+ }
203
+ function __voidRenderDevErrorOverlay(request, status, title, error) {
204
+ const chain = __voidCollectErrorChain(error);
205
+ const errorCountLabel = chain.length + (chain.length === 1 ? " Error" : " Errors");
206
+ const sections = chain.map((entry, index) => {
207
+ const heading = entry.name || (index === 0 ? title : "Cause");
208
+ const message = entry.message || title;
209
+ const stack = __voidRenderStack(entry);
210
+ if (index === 0) return `<section class="__void-error-section is-root"><p class="__void-error-message">${__voidEscapeHtml(message)}</p>${stack}</section>`;
211
+ return `<section class="__void-error-section"><div class="__void-error-kicker">${__voidEscapeHtml(entry.label)}</div><h2>${__voidEscapeHtml(heading)}</h2><p>${__voidEscapeHtml(message)}</p>${stack}</section>`;
212
+ }).join("");
213
+ return `<style>
214
+ .__void-error-overlay {
215
+ position: fixed;
216
+ inset: 0;
217
+ z-index: 2147483647;
218
+ pointer-events: none;
219
+ font-family: ${__VOID_ERROR_PAGE_FONT_STACK};
220
+ color: #f5f5f5;
221
+ }
222
+ .__void-error-backdrop {
223
+ position: absolute;
224
+ inset: 0;
225
+ background: rgba(10, 10, 10, 0.52);
226
+ backdrop-filter: blur(4px);
227
+ transition: opacity 180ms ease;
228
+ }
229
+ .__void-error-panel {
230
+ position: absolute;
231
+ inset: auto auto 24px 24px;
232
+ inline-size: min(760px, calc(100vw - 48px));
233
+ max-block-size: min(80dvh, 920px);
234
+ overflow: auto;
235
+ pointer-events: auto;
236
+ border-radius: 32px;
237
+ corner-shape: squircle;
238
+ border: 1px solid rgba(255, 255, 255, 0.14);
239
+ background: linear-gradient(180deg, rgba(24, 24, 27, 0.98), rgba(9, 9, 11, 0.98));
240
+ box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
241
+ padding: 12px 16px;
242
+ transition: transform 180ms ease, opacity 180ms ease;
243
+ transform-origin: bottom left;
244
+ }
245
+ .__void-error-close {
246
+ position: absolute;
247
+ inset: 12px 12px auto auto;
248
+ inline-size: 36px;
249
+ block-size: 36px;
250
+ border: 0;
251
+ border-radius: 999px;
252
+ background: rgba(255, 255, 255, 0.08);
253
+ color: #fafafa;
254
+ cursor: pointer;
255
+ display: grid;
256
+ place-items: center;
257
+ padding: 0;
258
+ }
259
+ .__void-error-close:hover {
260
+ background: rgba(255, 255, 255, 0.14);
261
+ }
262
+ .__void-error-close svg {
263
+ inline-size: 16px;
264
+ block-size: 16px;
265
+ display: block;
266
+ }
267
+ .__void-error-minimized {
268
+ position: absolute;
269
+ inset: auto auto 24px 24px;
270
+ pointer-events: none;
271
+ opacity: 0;
272
+ transform: scale(0.92);
273
+ transform-origin: bottom left;
274
+ border: 1px solid rgba(248, 113, 113, 0.35);
275
+ border-radius: 32px;
276
+ corner-shape: squircle;
277
+ background: rgba(24, 24, 27, 0.96);
278
+ color: #fca5a5;
279
+ padding: 12px 8px;
280
+ box-shadow: 0 18px 36px rgba(0, 0, 0, 0.28);
281
+ cursor: pointer;
282
+ font: 700 13px/1 ${__VOID_ERROR_PAGE_FONT_STACK};
283
+ letter-spacing: 0.04em;
284
+ text-transform: uppercase;
285
+ transition: transform 180ms ease, opacity 180ms ease;
286
+ }
287
+ .__void-error-header {
288
+ display: flex;
289
+ flex-direction: column;
290
+ gap: 6px;
291
+ margin-block-end: 0;
292
+ padding-right: 52px;
293
+ }
294
+ .__void-error-status {
295
+ margin: 0;
296
+ color: #fca5a5;
297
+ font-size: 12px;
298
+ font-weight: 700;
299
+ letter-spacing: 0.12em;
300
+ text-transform: uppercase;
301
+ }
302
+ .__void-error-section {
303
+ border-top: 1px solid rgba(255, 255, 255, 0.08);
304
+ padding-top: 16px;
305
+ margin-top: 16px;
306
+ }
307
+ .__void-error-section.is-root {
308
+ border-top: 0;
309
+ padding-top: 0;
310
+ margin-top: 0;
311
+ }
312
+ .__void-error-message {
313
+ margin: 0;
314
+ color: #fff;
315
+ font-size: 1.7rem;
316
+ line-height: 1.15;
317
+ letter-spacing: -0.03em;
318
+ white-space: pre-wrap;
319
+ word-break: break-word;
320
+ }
321
+ .__void-error-kicker {
322
+ margin-bottom: 6px;
323
+ color: #fda4af;
324
+ font-size: 12px;
325
+ font-weight: 700;
326
+ letter-spacing: 0.08em;
327
+ text-transform: uppercase;
328
+ }
329
+ .__void-error-section h2 {
330
+ margin: 0 0 8px;
331
+ font-size: 1.05rem;
332
+ color: #fff;
333
+ }
334
+ .__void-error-section p {
335
+ margin: 0;
336
+ color: #e4e4e7;
337
+ white-space: pre-wrap;
338
+ word-break: break-word;
339
+ }
340
+ .__void-error-stack {
341
+ margin-top: 18px;
342
+ border: 1px solid rgba(255, 255, 255, 0.08);
343
+ border-radius: 32px;
344
+ background: rgba(255, 255, 255, 0.03);
345
+ corner-shape: squircle;
346
+ overflow: hidden;
347
+ }
348
+ .__void-error-stack-label {
349
+ padding: 12px 14px 10px;
350
+ color: #f4f4f5;
351
+ font-size: 12px;
352
+ font-weight: 700;
353
+ letter-spacing: 0.08em;
354
+ text-transform: uppercase;
355
+ border-bottom: 1px solid rgba(255, 255, 255, 0.08);
356
+ }
357
+ .__void-error-frames {
358
+ display: flex;
359
+ flex-direction: column;
360
+ }
361
+ .__void-error-frame {
362
+ display: flex;
363
+ align-items: baseline;
364
+ justify-content: space-between;
365
+ gap: 16px;
366
+ padding: 12px 14px;
367
+ color: inherit;
368
+ text-decoration: none;
369
+ border-top: 1px solid rgba(255, 255, 255, 0.06);
370
+ }
371
+ .__void-error-frame:first-child {
372
+ border-top: 0;
373
+ }
374
+ .__void-error-frame:hover {
375
+ background: rgba(255, 255, 255, 0.05);
376
+ }
377
+ .__void-error-frame.is-static {
378
+ cursor: default;
379
+ }
380
+ .__void-error-frame-function {
381
+ flex: 1 1 auto;
382
+ min-width: 0;
383
+ color: #fafafa;
384
+ font: 600 12px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
385
+ white-space: nowrap;
386
+ overflow: hidden;
387
+ text-overflow: ellipsis;
388
+ }
389
+ .__void-error-frame-location {
390
+ flex: 0 1 52%;
391
+ min-width: 0;
392
+ color: #fda4af;
393
+ font: 500 12px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
394
+ text-align: right;
395
+ white-space: nowrap;
396
+ overflow: hidden;
397
+ text-overflow: ellipsis;
398
+ }
399
+ .__void-error-section pre {
400
+ margin: 0;
401
+ padding: 12px 14px;
402
+ overflow: auto;
403
+ color: #e4e4e7;
404
+ font: 500 12px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
405
+ white-space: pre-wrap;
406
+ word-break: break-word;
407
+ }
408
+ .__void-error-overlay.is-minimized .__void-error-backdrop {
409
+ opacity: 0;
410
+ pointer-events: none;
411
+ }
412
+ .__void-error-overlay.is-minimized .__void-error-panel {
413
+ opacity: 0;
414
+ pointer-events: none;
415
+ transform: scale(0.92);
416
+ }
417
+ .__void-error-overlay.is-minimized .__void-error-minimized {
418
+ opacity: 1;
419
+ pointer-events: auto;
420
+ transform: scale(1);
421
+ }
422
+ @media (max-width: 720px) {
423
+ .__void-error-panel {
424
+ inset: auto 12px 12px 12px;
425
+ inline-size: auto;
426
+ max-block-size: min(70dvh, 920px);
427
+ padding: 16px;
428
+ }
429
+ .__void-error-minimized {
430
+ inset: auto auto 12px 12px;
431
+ }
432
+ .__void-error-frame {
433
+ flex-direction: column;
434
+ align-items: flex-start;
435
+ }
436
+ .__void-error-frame-location {
437
+ text-align: left;
438
+ }
439
+ }
440
+ </style>
441
+ <aside class="__void-error-overlay" data-void-error-overlay role="dialog" aria-label="Void dev error overlay"><div class="__void-error-backdrop" data-void-error-backdrop></div><section class="__void-error-panel"><button type="button" class="__void-error-close" data-void-error-close aria-label="Minimize error overlay"><svg viewBox="0 0 16 16" aria-hidden="true" focusable="false"><path d="M3.757 3.757 12.243 12.243M12.243 3.757 3.757 12.243" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round"/></svg></button><header class="__void-error-header"><p class="__void-error-status">${__voidEscapeHtml(String(status) + ": " + title)}</p></header>${sections}</section><button type="button" class="__void-error-minimized" data-void-error-toggle aria-label="Show dev error overlay" aria-expanded="true">${__voidEscapeHtml(errorCountLabel)}</button><script>(function(){const script=document.currentScript;if(!(script instanceof HTMLScriptElement))return;const root=script.closest("[data-void-error-overlay]");if(!(root instanceof HTMLElement))return;const backdrop=root.querySelector("[data-void-error-backdrop]");const closeButton=root.querySelector("[data-void-error-close]");const toggle=root.querySelector("[data-void-error-toggle]");const setMinimized=(minimized)=>{root.classList.toggle("is-minimized", minimized);if(toggle instanceof HTMLElement)toggle.setAttribute("aria-expanded", minimized ? "false" : "true");};if(backdrop instanceof HTMLElement)backdrop.addEventListener("click",()=>setMinimized(true));if(closeButton instanceof HTMLElement)closeButton.addEventListener("click",()=>setMinimized(true));if(toggle instanceof HTMLElement)toggle.addEventListener("click",()=>setMinimized(false));})();<\/script></aside>`;
442
+ }
443
+ function __voidInjectDevErrorOverlay(html, overlay) {
444
+ return /<\/body\s*>/i.test(html) ? html.replace(/<\/body\s*>/i, overlay + "</body>") : html + overlay;
445
+ }
446
+ function __voidGetErrorAssetCss(error) {
447
+ const tags = error && (typeof error === "object" || typeof error === "function") && "__voidPageAssetTags" in error ? error.__voidPageAssetTags : null;
448
+ return tags && typeof tags === "object" && "css" in tags && typeof tags.css === "string" ? tags.css : "";
449
+ }
450
+ function __voidInjectErrorAssetCss(html, css) {
451
+ if (!css) return html;
452
+ return /<\/head\s*>/i.test(html) ? html.replace(/<\/head\s*>/i, css + "</head>") : css + html;
453
+ }
454
+ function __voidRenderErrorPage(request, status, title, error) {
455
+ const heading = status + ": " + title;
456
+ const prefix = status + ": ";
457
+ const overlay = __VOID_DEV && status === 500 && error ? __voidRenderDevErrorOverlay(request, status, title, error) : "";
458
+ return `<!doctype html>
459
+ <html lang="en">
460
+ <head>
461
+ <meta charset="utf-8">
462
+ <meta name="viewport" content="width=device-width, initial-scale=1">
463
+ <title>${__voidEscapeHtml(heading)}</title>
464
+ ${__voidGetErrorAssetCss(error)}
465
+ <style>
466
+ :root {
467
+ color-scheme: light dark;
468
+ font-family: ${__VOID_ERROR_PAGE_FONT_STACK};
469
+ background: #f5f5f5;
470
+ color: #171717;
471
+ }
472
+ * { box-sizing: border-box; }
473
+ body {
474
+ margin: 0;
475
+ min-block-size: 100dvh;
476
+ display: grid;
477
+ place-items: center;
478
+ padding: 24px;
479
+ background: radial-gradient(circle at top, rgba(255, 255, 255, 0.96), rgba(245, 245, 245, 0.96) 52%), linear-gradient(180deg, #fafafa 0%, #f1f1f1 100%);
480
+ font: 500 16px/1.5 ${__VOID_ERROR_PAGE_FONT_STACK};
481
+ }
482
+ main {
483
+ inline-size: min(100%, 560px);
484
+ padding: 32px 36px;
485
+ border: 1px solid #d4d4d8;
486
+ border-radius: 32px;
487
+ corner-shape: squircle;
488
+ background: rgba(255, 255, 255, 0.88);
489
+ text-align: center;
490
+ backdrop-filter: blur(12px);
491
+ }
492
+ h1 {
493
+ margin: 0;
494
+ font: 400 clamp(1.5rem, 1.2rem + 1vw, 2rem) / 1.1 ${__VOID_ERROR_PAGE_FONT_STACK};
495
+ letter-spacing: -0.03em;
496
+ }
497
+ strong {
498
+ font-weight: 600;
499
+ }
500
+ @media (prefers-color-scheme: dark) {
501
+ :root {
502
+ background: #0a0a0a;
503
+ color: #f5f5f5;
504
+ }
505
+ body {
506
+ background: radial-gradient(circle at top, rgba(38, 38, 38, 0.96), rgba(10, 10, 10, 0.96) 52%), linear-gradient(180deg, #171717 0%, #0a0a0a 100%);
507
+ }
508
+ main {
509
+ border-color: #27272a;
510
+ background: rgba(23, 23, 23, 0.88);
511
+ }
512
+ }
513
+ </style>
514
+ </head>
515
+ <body>
516
+ <main>
517
+ <h1><strong>${__voidEscapeHtml(prefix)}</strong>${__voidEscapeHtml(title)}</h1>
518
+ </main>
519
+ ${overlay}
520
+ </body>
521
+ </html>`;
522
+ }
523
+ function __voidCreateErrorResponse(request, status, title, error) {
524
+ if (!__voidShouldServeHtmlErrorPage(request)) return new Response(title, { status });
525
+ return new Response(request.method === "HEAD" ? null : __voidRenderErrorPage(request, status, title, error), {
526
+ status,
527
+ headers: { "content-type": "text/html; charset=utf-8" }
528
+ });
529
+ }
530
+ async function serveCustomPage(c, status, fallbackText, error) {
531
+ try {
532
+ const assets = c.env?.ASSETS;
533
+ if (assets && typeof assets.fetch === "function") {
534
+ const request = new Request(new URL("/" + status + ".html", c.req.url));
535
+ const response = await assets.fetch(request);
536
+ if (response.ok) {
537
+ const assetCss = __voidGetErrorAssetCss(error);
538
+ if (assetCss) {
539
+ const html = __voidInjectErrorAssetCss(await response.text(), assetCss);
540
+ const body = __VOID_DEV && status === 500 && error && __voidShouldServeHtmlErrorPage(c.req.raw) ? __voidInjectDevErrorOverlay(html, __voidRenderDevErrorOverlay(c.req.raw, status, fallbackText, error)) : html;
541
+ return new Response(c.req.method === "HEAD" ? null : body, {
542
+ status,
543
+ headers: { "content-type": "text/html; charset=utf-8" }
544
+ });
545
+ }
546
+ if (__VOID_DEV && status === 500 && error && __voidShouldServeHtmlErrorPage(c.req.raw)) {
547
+ const overlay = __voidRenderDevErrorOverlay(c.req.raw, status, fallbackText, error);
548
+ const html = await response.text();
549
+ return new Response(c.req.method === "HEAD" ? null : __voidInjectDevErrorOverlay(html, overlay), {
550
+ status,
551
+ headers: { "content-type": "text/html; charset=utf-8" }
552
+ });
553
+ }
554
+ return new Response(response.body, {
555
+ status,
556
+ headers: { "content-type": "text/html; charset=utf-8" }
557
+ });
558
+ }
559
+ }
560
+ } catch {}
561
+ return __voidCreateErrorResponse(c.req.raw, status, fallbackText, error);
562
+ }
563
+ return {
564
+ createResponse: __voidCreateErrorResponse,
565
+ serveCustomPage,
566
+ onError: (error, c) => {
567
+ if (error && typeof error === "object" && "getResponse" in error && typeof error.getResponse === "function") return error.getResponse();
568
+ console.error(error);
569
+ return serveCustomPage(c, 500, "Internal Server Error", error);
570
+ }
571
+ };
572
+ }
573
+ //#endregion
574
+ //#region src/runtime/routing-assets.ts
575
+ function createManifestLoader() {
576
+ let cached = null;
577
+ return async (request, env) => {
578
+ if (cached) return cached;
579
+ const injected = globalThis.__VITE_MANIFEST__;
580
+ if (typeof injected === "object" && injected) {
581
+ cached = injected;
582
+ return cached;
583
+ }
584
+ const assets = env?.ASSETS;
585
+ if (!assets || typeof assets.fetch !== "function") return null;
586
+ const response = await assets.fetch(new Request(new URL("/.vite/manifest.json", request.url).toString()));
587
+ if (!response.ok) return null;
588
+ cached = await response.json();
589
+ return cached;
590
+ };
591
+ }
592
+ const BINDING_HINT_SCRIPT = "<script type=\"module\" src=\"/@id/virtual:void/binding-hint\"><\/script>";
593
+ const REACT_REFRESH_SCRIPT = `<script type="module">
594
+ import RefreshRuntime from "/@react-refresh";
595
+ RefreshRuntime.injectIntoGlobalHook(window);
596
+ window.$RefreshReg$ = () => {};
597
+ window.$RefreshSig$ = () => (type) => type;
598
+ window.__vite_plugin_react_preamble_installed__ = true;
599
+ <\/script>`;
600
+ const escapeAttribute = (value) => String(value).replace(/"/g, "&quot;");
601
+ const script = (url) => `<script type="module" src="${escapeAttribute(url)}"><\/script>`;
602
+ function collectManifestFiles(manifest, entryId, depthFirst) {
603
+ const seen = /* @__PURE__ */ new Set();
604
+ const pending = [entryId];
605
+ for (let index = 0; depthFirst ? pending.length > 0 : index < pending.length;) {
606
+ const id = depthFirst ? pending.pop() : pending[index++];
607
+ if (seen.has(id)) continue;
608
+ seen.add(id);
609
+ const imports = manifest[id]?.imports;
610
+ if (Array.isArray(imports)) pending.push(...imports);
611
+ }
612
+ return [...seen];
613
+ }
614
+ function collectRouteCss(manifest, roots) {
615
+ const css = /* @__PURE__ */ new Set();
616
+ const visited = /* @__PURE__ */ new Set();
617
+ const visit = (id) => {
618
+ if (visited.has(id)) return;
619
+ visited.add(id);
620
+ const chunk = manifest[id];
621
+ if (!chunk) return;
622
+ if (Array.isArray(chunk.css)) for (const file of chunk.css) css.add(file);
623
+ if (Array.isArray(chunk.imports)) for (const imported of chunk.imports) visit(imported);
624
+ };
625
+ for (const root of roots) visit(root);
626
+ return css;
627
+ }
628
+ /** Frameworks supply only client entry IDs and active layout/page roots. */
629
+ function createClientAssetTags(options, loadManifest = createManifestLoader()) {
630
+ return async (request, env, componentId = "") => {
631
+ const empty = {
632
+ css: "",
633
+ preloads: "",
634
+ body: ""
635
+ };
636
+ const manifest = await loadManifest(request, env);
637
+ if (!manifest || typeof manifest !== "object") {
638
+ if (!options.dev) return empty;
639
+ const preloads = [script("/@vite/client"), BINDING_HINT_SCRIPT];
640
+ if (options.kind === "ssr" && options.reactRefresh) preloads.push(REACT_REFRESH_SCRIPT);
641
+ let body = script(options.entryUrl);
642
+ if (options.extraEntryUrl) body += "\n" + script(options.extraEntryUrl);
643
+ const tags = {
644
+ css: "",
645
+ preloads: preloads.join("\n"),
646
+ body
647
+ };
648
+ if (options.devCss && options.kind !== "ssr") {
649
+ const css = await options.devCss(request, env, {
650
+ kind: options.kind,
651
+ componentId,
652
+ rootPhases: options.devRootPhases?.[componentId] || [[options.entryUrl]]
653
+ });
654
+ tags.devCss = Array.isArray(css) ? css : [];
655
+ }
656
+ return tags;
657
+ }
658
+ const entry = manifest[options.entryId];
659
+ if (!entry || typeof entry !== "object" || typeof entry.file !== "string") return empty;
660
+ const ids = collectManifestFiles(manifest, options.entryId, options.kind === "ssr");
661
+ const extraEntry = options.extraEntryId ? manifest[options.extraEntryId] : void 0;
662
+ const hasExtra = extraEntry && typeof extraEntry.file === "string";
663
+ if (hasExtra) ids.push(...collectManifestFiles(manifest, options.extraEntryId, false));
664
+ const css = options.kind === "ssr" ? /* @__PURE__ */ new Set() : collectRouteCss(manifest, [options.entryId, ...options.pageCssKeys?.[componentId] ?? []]);
665
+ if (hasExtra) for (const file of collectRouteCss(manifest, [options.extraEntryId])) css.add(file);
666
+ const preloads = /* @__PURE__ */ new Set();
667
+ for (const id of ids) {
668
+ const chunk = manifest[id];
669
+ if (!chunk || typeof chunk !== "object") continue;
670
+ if (options.kind === "ssr" && Array.isArray(chunk.css)) for (const file of chunk.css) css.add(file);
671
+ if (id !== options.entryId && id !== options.extraEntryId && typeof chunk.file === "string") preloads.add(chunk.file);
672
+ }
673
+ let body = script("/" + entry.file);
674
+ if (hasExtra) body += "\n" + script("/" + extraEntry.file);
675
+ return {
676
+ css: [...css].map((file) => `<link rel="stylesheet" href="/${escapeAttribute(file)}">`).join("\n"),
677
+ preloads: [...preloads].map((file) => `<link rel="modulepreload" href="/${escapeAttribute(file)}">`).join("\n"),
678
+ body
679
+ };
680
+ };
681
+ }
682
+ //#endregion
683
+ //#region src/runtime/routing-worker.ts
684
+ const ASSET_CONTENT_TYPES = {
685
+ ".avif": "image/avif",
686
+ ".css": "text/css; charset=utf-8",
687
+ ".gif": "image/gif",
688
+ ".html": "text/html; charset=utf-8",
689
+ ".ico": "image/x-icon",
690
+ ".jpeg": "image/jpeg",
691
+ ".jpg": "image/jpeg",
692
+ ".js": "text/javascript; charset=utf-8",
693
+ ".json": "application/json; charset=utf-8",
694
+ ".mjs": "text/javascript; charset=utf-8",
695
+ ".png": "image/png",
696
+ ".svg": "image/svg+xml",
697
+ ".txt": "text/plain; charset=utf-8",
698
+ ".wasm": "application/wasm",
699
+ ".webp": "image/webp",
700
+ ".woff": "font/woff",
701
+ ".woff2": "font/woff2"
702
+ };
703
+ /** Apply native static policy before application middleware adds authored headers. */
704
+ function applyAssetCachePolicy(request, asset, assetsDir = "assets", fingerprinted = false) {
705
+ if (!["GET", "HEAD"].includes(request.method) || ![
706
+ 200,
707
+ 206,
708
+ 304
709
+ ].includes(asset.status)) return asset;
710
+ const pathname = new URL(request.url).pathname;
711
+ const filename = pathname.slice(pathname.lastIndexOf("/") + 1);
712
+ const extension = filename.slice(filename.lastIndexOf(".")).toLowerCase();
713
+ const headers = new Headers(asset.headers);
714
+ if (!headers.has("Content-Type") && ASSET_CONTENT_TYPES[extension]) headers.set("Content-Type", ASSET_CONTENT_TYPES[extension]);
715
+ const policy = headers.get("Cache-Control");
716
+ const providerDefault = (policy ?? "").toLowerCase().split(",").map((part) => part.trim()).sort().join(",") === "max-age=0,must-revalidate,public";
717
+ const hashed = fingerprinted && pathname.startsWith("/" + assetsDir.replace(/^\/+|\/+$/g, "") + "/") && extension !== ".html" && !(headers.get("Content-Type") ?? "").toLowerCase().includes("text/html");
718
+ if (!headers.has("Set-Cookie") && hashed && (!policy || providerDefault)) headers.set("Cache-Control", "public, max-age=31536000, immutable");
719
+ else if (!policy) headers.set("Cache-Control", "no-store");
720
+ return new Response(asset.body, {
721
+ status: asset.status,
722
+ statusText: asset.statusText,
723
+ headers
724
+ });
725
+ }
726
+ /** Public filenames are never evidence of a content fingerprint. */
727
+ function createAssetCachePolicy(assetsDir, loadManifest = createManifestLoader()) {
728
+ let files;
729
+ return async (request, env, asset) => {
730
+ const path = new URL(request.url).pathname;
731
+ if (!["GET", "HEAD"].includes(request.method) || ![
732
+ 200,
733
+ 206,
734
+ 304
735
+ ].includes(asset.status) || !path.startsWith("/" + (assetsDir ?? "assets").replace(/^\/+|\/+$/g, "") + "/")) return applyAssetCachePolicy(request, asset, assetsDir);
736
+ if (!files) files = loadManifest(request, env).then((manifest) => new Set(Object.values(manifest ?? {}).flatMap((entry) => Array.isArray(entry?.immutableFiles) ? entry.immutableFiles : [])), () => /* @__PURE__ */ new Set());
737
+ return applyAssetCachePolicy(request, asset, assetsDir, (await files).has(path.slice(1)));
738
+ };
739
+ }
740
+ function createAssetFallback(options = {}) {
741
+ const cachePolicy = createAssetCachePolicy(options.assetsDir);
742
+ return async (request, env, response) => {
743
+ if (response.status !== 404 || !env.ASSETS || request.method !== "GET" && request.method !== "HEAD") return response;
744
+ const asset = await env.ASSETS.fetch(new Request(request.url, {
745
+ method: request.method,
746
+ headers: request.headers
747
+ }));
748
+ if (asset.status !== 404) return cachePolicy(request, env, asset);
749
+ const accept = request.headers.get("accept") ?? "";
750
+ if (options.serveSpaFallback && accept.includes("text/html")) {
751
+ const url = new URL("/index.html", request.url);
752
+ const index = await env.ASSETS.fetch(new Request(url, { method: request.method }));
753
+ if (index.status === 200) {
754
+ const res = new Response(index.body, {
755
+ status: 200,
756
+ headers: index.headers
757
+ });
758
+ res.headers.set("Cache-Control", "no-store");
759
+ res.headers.set("Content-Type", "text/html; charset=utf-8");
760
+ return res;
761
+ }
762
+ } else if (!options.serveSpaFallback && options.notFound === "404-page" && accept.includes("text/html") && (asset.headers.get("content-type") ?? "").includes("text/html")) {
763
+ const res = new Response(asset.body, asset);
764
+ res.headers.set("Cache-Control", "no-store");
765
+ return res;
766
+ }
767
+ return response;
768
+ };
769
+ }
770
+ /** Hide platform capabilities without copying bindings or changing application bindings. */
771
+ function filterInternalBindings(env, prefixes, exactNames = []) {
772
+ const hidden = (key) => typeof key === "string" && (prefixes.some((prefix) => key.startsWith(prefix)) || exactNames.includes(key));
773
+ return new Proxy(env, {
774
+ get: (target, prop, receiver) => hidden(prop) ? void 0 : Reflect.get(target, prop, receiver),
775
+ has: (target, prop) => !hidden(prop) && Reflect.has(target, prop),
776
+ ownKeys: (target) => Reflect.ownKeys(target).filter((key) => !hidden(key)),
777
+ getOwnPropertyDescriptor: (target, prop) => hidden(prop) ? void 0 : Reflect.getOwnPropertyDescriptor(target, prop)
778
+ });
779
+ }
780
+ function createWorkerFetch(options) {
781
+ return async (request, originalEnv, ctx) => {
782
+ const url = new URL(request.url);
783
+ const discovery = request.method === "POST" && url.pathname === "/__void/prerender-paths";
784
+ if (options.validateEnv && !discovery) await options.validateEnv(originalEnv);
785
+ const env = options.remoteEnv && originalEnv.__VOID_REMOTE === "1" ? options.remoteEnv(originalEnv) : originalEnv;
786
+ if (options.isr) {
787
+ env.__VOID_ISR_DEPLOYMENT_ID ??= options.isr.deploymentId;
788
+ env.__VOID_ISR_HOST = url.hostname;
789
+ }
790
+ return options.withRawEnv(env, () => options.withRuntimeEnv(env, async () => {
791
+ if (options.emailReceipt && url.pathname === "/__void/email/receipt/v1") return options.emailReceipt(request, env, ctx);
792
+ if (request.method === "GET" && url.pathname === "/__void/ready") {
793
+ const metadata = options.versionMetadataBinding ? env[options.versionMetadataBinding] : void 0;
794
+ return Response.json({
795
+ ready: true,
796
+ ...options.versionMetadataBinding ? { versionId: metadata?.id } : {}
797
+ }, options.versionMetadataBinding ? { headers: { "cache-control": "no-store" } } : void 0);
798
+ }
799
+ const internal = await options.internalRoute(request, env, ctx);
800
+ if (internal) return internal;
801
+ if (discovery) {
802
+ const expected = env.__VOID_PROXY_TOKEN;
803
+ if (expected) {
804
+ const token = request.headers.get("x-void-internal");
805
+ if (!token || token !== expected) return Response.json({ error: "unauthorized" }, { status: 401 });
806
+ }
807
+ return Response.json({ paths: await options.collectPrerenderPaths(request, env, ctx) });
808
+ }
809
+ const userEnv = options.filterBindings(env);
810
+ const render = async (req) => options.assets(req, env, await options.app.fetch(req, userEnv, ctx));
811
+ if (options.isr && env.ISR_CACHE && request.headers.get("upgrade")?.toLowerCase() !== "websocket") {
812
+ const cached = await options.isr.handle(request, env, ctx, render);
813
+ if (cached) return cached;
814
+ }
815
+ return render(request);
816
+ }));
817
+ };
818
+ }
819
+ //#endregion
820
+ //#region src/runtime/routing-pages.ts
821
+ function createPageGetHandler(options) {
822
+ return async (context) => {
823
+ const mod = options.load ? await options.load() : { head: options.head };
824
+ return handlePageGet(mod.loader, mod.head, context, options.componentId, options.render, options.assets, options.headConfig ?? void 0, options.renderOptions);
825
+ };
826
+ }
827
+ function createPageMutationHandler(options) {
828
+ return async (context) => {
829
+ const mod = options.load ? await options.load() : {};
830
+ const actionName = options.namedActions ? new URL(context.req.url).searchParams.keys().next().value : void 0;
831
+ const handler = options.namedActions ? mod.actions?.[actionName || "default"] : mod.action;
832
+ if (options.namedActions && !handler) return new Response("Unknown action" + (actionName ? ": " + actionName : ""), { status: 404 });
833
+ return handlePageMutation(handler, mod.loader, mod.head, context, options.componentId, options.render, options.assets, options.headConfig ?? void 0, options.renderOptions);
834
+ };
835
+ }
836
+ function createPagesFallback(options) {
837
+ const cachePolicy = createAssetCachePolicy(options.assetsDir);
838
+ return async (c) => {
839
+ const path = c.req.path;
840
+ if (path === "/api" || path.startsWith("/api/") || c.req.method !== "GET" && c.req.method !== "HEAD") return c.text("Not Found", 404);
841
+ const assets = c.env?.ASSETS;
842
+ const assetResponse = assets && typeof assets.fetch === "function" ? await assets.fetch(c.req.raw) : options.routing.markNoMatch(c.req.raw, new Response("Not Found", { status: 404 }));
843
+ if (assetResponse.status !== 404) return cachePolicy(c.req.raw, c.env, assetResponse);
844
+ const fallback = options.fallbackRules ? await options.routing.applyFallback(c, options.fallbackRules) : void 0;
845
+ if (fallback) return fallback;
846
+ if (path.includes("/.") || path.substring(path.lastIndexOf("/") + 1).includes(".")) return options.errors.serveCustomPage(c, 404, "Not Found");
847
+ if (path !== "/" && path.endsWith("/")) {
848
+ const url = new URL(c.req.url);
849
+ url.pathname = path.slice(0, -1);
850
+ return Response.redirect(url.href, 301);
851
+ }
852
+ return options.routing.markNoMatch(c.req.raw, await options.errors.serveCustomPage(c, 404, "Not Found"));
853
+ };
854
+ }
855
+ function createSsrFallback(options) {
856
+ const cachePolicy = createAssetCachePolicy(options.assetsDir);
857
+ const fetchAssets = async (c) => {
858
+ const binding = c.env?.ASSETS;
859
+ if (!binding || typeof binding.fetch !== "function") return options.routing.markNoMatch(c.req.raw, new Response("Not Found", { status: 404 }));
860
+ const response = await binding.fetch(c.req.raw);
861
+ return response.status === 404 ? options.routing.markNoMatch(c.req.raw, new Response("Not Found", { status: 404 })) : cachePolicy(c.req.raw, c.env, response);
862
+ };
863
+ return async (c) => {
864
+ if (options.nodeTarget && options.fallbackRules) {
865
+ const fallback = await options.routing.applyFallback(c, options.fallbackRules);
866
+ if (fallback) return fallback;
867
+ }
868
+ const path = c.req.path;
869
+ const destination = c.req.header("sec-fetch-dest");
870
+ if (path === "/api" || path.startsWith("/api/") || /\/[^/]+\.[^/]+$/.test(path) || destination && destination !== "document" && destination !== "empty") {
871
+ const response = await fetchAssets(c);
872
+ if (!options.nodeTarget && options.fallbackRules && response.status === 404) {
873
+ const fallback = await options.routing.applyFallback(c, options.fallbackRules);
874
+ if (fallback) return fallback;
875
+ }
876
+ return response;
877
+ }
878
+ const mod = await options.load();
879
+ const render = typeof mod.render === "function" ? mod.render : mod.default;
880
+ if (typeof render !== "function") throw new Error("ssr: Invalid entry. Export render(c, assetTags).");
881
+ return render(c, await options.assets(c.req.raw, c.env));
882
+ };
883
+ }
884
+ function createAssetNotFound(options) {
885
+ const cachePolicy = createAssetCachePolicy(options.assetsDir);
886
+ return async (c) => {
887
+ if (!options.nodeTarget) {
888
+ const assets = c.env?.ASSETS;
889
+ if (assets && typeof assets.fetch === "function") {
890
+ const response = await assets.fetch(c.req.raw);
891
+ if (response.status !== 404) return cachePolicy(c.req.raw, c.env, response);
892
+ }
893
+ }
894
+ return (options.fallbackRules ? await options.routing.applyFallback(c, options.fallbackRules) : void 0) ?? options.routing.markNoMatch(c.req.raw, new Response("Not Found", { status: 404 }));
895
+ };
896
+ }
897
+ //#endregion
898
+ //#region src/runtime/routing.ts
899
+ /** One state owner per generated app: recursive dispatch shares rewrite and fallback guards. */
900
+ function createRoutingRuntime(app, options = {}) {
901
+ const originalUrls = options.originalUrls ?? /* @__PURE__ */ new WeakMap();
902
+ const fallbackHandled = /* @__PURE__ */ new WeakSet();
903
+ const warnedPatterns = /* @__PURE__ */ new Set();
904
+ const requestContext = new AsyncLocalStorage();
905
+ const assetExtensions = options.blockedAssetExtensions ?? DEFAULT_ASSET_EXTENSIONS;
906
+ const assetExtensionRE = assetExtensions.length ? new RegExp(`\\.(${assetExtensions.join("|")})$`, "i") : /(?!)/;
907
+ const annotate = (response, trace) => {
908
+ if (!options.dev) return response;
909
+ const headers = new Headers(response.headers);
910
+ headers.set("X-Void-Routing", trace);
911
+ return new Response(response.body, {
912
+ status: response.status,
913
+ statusText: response.statusText,
914
+ headers
915
+ });
916
+ };
917
+ const dispatch = (request, c) => Promise.resolve(options.nodeTarget ? app.fetch(request, c.env) : app.fetch(request, c.env, c.executionCtx));
918
+ const rememberOriginal = (request, c) => {
919
+ originalUrls.set(request, originalUrls.get(c.req.raw) ?? new URL(c.req.url));
920
+ };
921
+ const warn = (pattern, error, kind) => {
922
+ if (warnedPatterns.has(pattern)) return;
923
+ warnedPatterns.add(pattern);
924
+ const detail = error instanceof Error ? error.message : String(error);
925
+ console.warn(kind === "routing" ? `[void] skipping routing rule with invalid source ${JSON.stringify(pattern)}: ${detail}` : `[void] failed to compile route pattern ${JSON.stringify(pattern)}: ${detail}`);
926
+ };
927
+ const applyRules = async (c, rules, fallback) => {
928
+ const url = new URL(c.req.url);
929
+ for (const rule of rules) {
930
+ if (rule.host && rule.host !== url.hostname) continue;
931
+ let match;
932
+ try {
933
+ match = compilePattern(rule.source).regex.exec(url.pathname);
934
+ } catch (error) {
935
+ warn(rule.source, error, "routing");
936
+ continue;
937
+ }
938
+ if (!match) continue;
939
+ const destination = substituteParams(rule.destination, match.groups ?? {});
940
+ if (rule.status === 200) {
941
+ const q = destination.indexOf("?");
942
+ const rewriteUrl = new URL(c.req.url);
943
+ rewriteUrl.pathname = q === -1 ? destination : destination.slice(0, q);
944
+ const search = q === -1 ? "" : destination.slice(q);
945
+ if (search) rewriteUrl.search = search;
946
+ const request = new Request(rewriteUrl.toString(), c.req.raw);
947
+ rememberOriginal(request, c);
948
+ if (fallback) fallbackHandled.add(request);
949
+ const response = await dispatch(request, c);
950
+ const kind = rule.force === true ? "rewrite" : "fallback";
951
+ return annotate(response, `${kind}[${rule.source}] -> ${destination} (${rule.origin || "unknown"})`);
952
+ }
953
+ const location = mergeQueryIntoLocation(destination, url.search);
954
+ return annotate(c.redirect(location, rule.status), `redirect[${rule.source}] -> ${destination} ${rule.status} (${rule.origin || "unknown"})`);
955
+ }
956
+ };
957
+ const contextMiddleware = async (context, next) => {
958
+ const c = context;
959
+ if (options.managedDispatch && !originalUrls.has(c.req.raw)) {
960
+ const original = c.req.raw.headers.get("X-Void-Original-URL");
961
+ if (original != null) try {
962
+ originalUrls.set(c.req.raw, new URL(original));
963
+ } catch {}
964
+ }
965
+ c.rewrite = (path) => {
966
+ if (!path.startsWith("/") || path.startsWith("//")) throw new Error("c.rewrite() only accepts internal, path-absolute destinations — they must start with a single \"/\" (a leading \"//\" parses as protocol-relative and would proxy cross-origin); use fetch() for external URLs");
967
+ const q = path.indexOf("?");
968
+ const h = path.indexOf("#");
969
+ const first = q === -1 ? h : h === -1 ? q : Math.min(q, h);
970
+ const pathname = first === -1 ? path : path.slice(0, first);
971
+ if (assetExtensionRE.test(pathname)) throw new VoidAssetRewriteError(path);
972
+ const search = q === -1 ? "" : path.slice(q, h === -1 ? path.length : h);
973
+ const url = new URL(c.req.url);
974
+ url.pathname = pathname;
975
+ if (search) url.search = search;
976
+ const request = new Request(url.toString(), c.req.raw);
977
+ rememberOriginal(request, c);
978
+ return dispatch(request, c).then((response) => annotate(response, `c.rewrite -> ${path} (middleware)`));
979
+ };
980
+ const redirect = c.redirect.bind(c);
981
+ c.redirect = (location, status) => {
982
+ if (typeof location === "string" && location.startsWith("/") && !location.startsWith("//")) return redirect(mergeQueryIntoLocation(location, new URL(c.req.raw.url).search), status);
983
+ return redirect(location, status);
984
+ };
985
+ c.originalUrl = () => originalUrls.get(c.req.raw) ?? null;
986
+ c.isRewritten = () => originalUrls.has(c.req.raw);
987
+ await next();
988
+ };
989
+ return {
990
+ requestContext,
991
+ originalUrls,
992
+ contextMiddleware,
993
+ requestMiddleware: async (c, next) => {
994
+ await requestContext.run(options.nodeTarget ? { request: c.req.raw } : {
995
+ request: c.req.raw,
996
+ executionCtx: c.executionCtx
997
+ }, next);
998
+ },
999
+ routingMiddleware: (rules) => async (c, next) => {
1000
+ if (originalUrls.has(c.req.raw)) return next();
1001
+ const response = await applyRules(c, rules, false);
1002
+ if (response) return response;
1003
+ await next();
1004
+ if (options.dev && c.res && !c.res.headers.has("X-Void-Routing")) try {
1005
+ c.res.headers.set("X-Void-Routing", "pass-through");
1006
+ } catch {}
1007
+ },
1008
+ headerMiddleware: (rules) => async (c, next) => {
1009
+ await next();
1010
+ const pathname = new URL(c.req.url).pathname;
1011
+ const matched = [];
1012
+ for (const rule of rules) try {
1013
+ if (compilePattern(rule.pattern).regex.test(pathname)) matched.push(...rule.headers);
1014
+ } catch (error) {
1015
+ warn(rule.pattern, error, "header");
1016
+ }
1017
+ if (!matched.length) return;
1018
+ const headers = new Headers(c.res.headers);
1019
+ for (const [name, value] of matched) headers.set(name, value);
1020
+ c.res = new Response(c.res.body, {
1021
+ headers,
1022
+ status: c.res.status,
1023
+ statusText: c.res.statusText
1024
+ });
1025
+ },
1026
+ applyFallback: (c, rules) => fallbackHandled.has(c.req.raw) ? Promise.resolve(void 0) : applyRules(c, rules, true),
1027
+ markNoMatch
1028
+ };
1029
+ }
1030
+ const DEFAULT_ASSET_EXTENSIONS = [
1031
+ "png",
1032
+ "jpg",
1033
+ "jpeg",
1034
+ "gif",
1035
+ "webp",
1036
+ "avif",
1037
+ "svg",
1038
+ "ico",
1039
+ "css",
1040
+ "js",
1041
+ "mjs",
1042
+ "cjs",
1043
+ "woff",
1044
+ "woff2",
1045
+ "ttf",
1046
+ "otf",
1047
+ "eot",
1048
+ "mp4",
1049
+ "webm",
1050
+ "mp3",
1051
+ "wav",
1052
+ "pdf",
1053
+ "txt",
1054
+ "xml",
1055
+ "json",
1056
+ "wasm",
1057
+ "map"
1058
+ ];
1059
+ function markNoMatch(request, response) {
1060
+ const url = new URL(request.url);
1061
+ if (response.status !== 404 || request.method !== "GET" && request.method !== "HEAD" || url.pathname === "/api" || url.pathname.startsWith("/api/") || /\/[^/]+\.[^/]+$/.test(url.pathname)) return response;
1062
+ const headers = new Headers(response.headers);
1063
+ headers.set("X-Void-No-Match", "1");
1064
+ return new Response(response.body, {
1065
+ status: response.status,
1066
+ statusText: response.statusText,
1067
+ headers
1068
+ });
1069
+ }
1070
+ function createHttpRouteHandler(load, method) {
1071
+ return async (c) => convertReturnValue(await (await load())[method](c));
1072
+ }
1073
+ function createModuleLoader(load, cache = true) {
1074
+ let module;
1075
+ return async () => {
1076
+ if (!cache) return load();
1077
+ if (!module) module = await load();
1078
+ return module;
1079
+ };
1080
+ }
1081
+ //#endregion
1082
+ export { DEFAULT_ASSET_EXTENSIONS, createAssetFallback, createAssetNotFound, createClientAssetTags, createErrorRenderer, createHttpRouteHandler, createManifestLoader, createModuleLoader, createPageGetHandler, createPageMutationHandler, createPagesFallback, createRoutingRuntime, createSsrFallback, createWorkerFetch, filterInternalBindings, markNoMatch };