void 1.7.0 → 1.8.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 (277) hide show
  1. package/dist/{account-cmd-BfkJ_1PC.mjs → account-cmd-CZKntRH2.mjs} +5 -5
  2. package/dist/action-key-ByZ6DDld.mjs +64 -0
  3. package/dist/{application-analysis-OV0CBJ80.mjs → application-analysis-CyTagJQM.mjs} +25 -5
  4. package/dist/{application-routing-QpyC5G8z.mjs → application-routing-BLrMVpqi.mjs} +1 -1
  5. package/dist/{auth-CZrthGxs.d.mts → auth-Bk9VGtQW.d.mts} +1 -1
  6. package/dist/{auth-link-CW1Zh6FM.mjs → auth-link-BOaQWMKw.mjs} +5 -5
  7. package/dist/{auth-router-CNBKnEZi.mjs → auth-router-D0-VcmDs.mjs} +3 -3
  8. package/dist/{better-auth-shared-C-0uZg8-.d.mts → better-auth-shared-CQFdtguU.d.mts} +2 -2
  9. package/dist/boundary-plans-CRmWH68v.d.mts +25 -0
  10. package/dist/{build-cmd-C9qOKW9W.mjs → build-cmd-JTsXXf2F.mjs} +4 -4
  11. package/dist/{cache-DVBBbWQL.mjs → cache-D0m3Z_Xf.mjs} +4 -4
  12. package/dist/{cancel-deploy-COavnjud.mjs → cancel-deploy-Ce6Os4fa.mjs} +3 -3
  13. package/dist/cli/cli.mjs +1 -1
  14. package/dist/cli/cloudflare-operation-process.mjs +92 -19
  15. package/dist/cli/env-schema-probe.d.mts +1 -1
  16. package/dist/cli/env-schema-probe.mjs +2 -2
  17. package/dist/{cli-main-DFteHrJI.mjs → cli-main-rkrJy2Ge.mjs} +32 -32
  18. package/dist/client-D1Vz1Zep.mjs +1 -0
  19. package/dist/{client-BEZmTP6p.mjs → client-SZPyj4X_.mjs} +1 -1
  20. package/dist/{cloudflare-auth-DGIivpTb.mjs → cloudflare-auth-7jTqy9Bx.mjs} +1 -1
  21. package/dist/{cloudflare-cmd-DJaxC-bc.mjs → cloudflare-cmd-ChPLQcTP.mjs} +4 -4
  22. package/dist/{cloudflare-connect-BjpWmglw.mjs → cloudflare-connect-Co93VYTo.mjs} +2 -2
  23. package/dist/{cloudflare-operations-k7wYUv56.mjs → cloudflare-operations-CXaDKYj2.mjs} +4 -4
  24. package/dist/{cloudflare-operations-CZkjFrzH.mjs → cloudflare-operations-DATekLwI.mjs} +1 -1
  25. package/dist/{cloudflare-process-BcPvlMFd.mjs → cloudflare-process-DmTxZR-N.mjs} +1 -1
  26. package/dist/{connect-j1F1C_rW.mjs → connect-DlvXt1JR.mjs} +6 -6
  27. package/dist/{create-project-CE3jOmd5.mjs → create-project-CC_7hmYJ.mjs} +4 -4
  28. package/dist/{create-project-DZH3aYGQ.mjs → create-project-DzY05xqC.mjs} +1 -1
  29. package/dist/{db-DyLzzxvM.mjs → db-FhyYGcJJ.mjs} +13 -13
  30. package/dist/{db-types-DdHHUVPy.mjs → db-types-sVwEpyPR.mjs} +3 -1
  31. package/dist/{delete-Dey6YoMA.mjs → delete-CModjyOC.mjs} +4 -4
  32. package/dist/{deploy-Ccw2D2lw.mjs → deploy-Cz9TEzZy.mjs} +34 -24
  33. package/dist/deploy-DMieisRu.mjs +2 -0
  34. package/dist/{deploy-managed-static-BBVtpuGv.mjs → deploy-managed-static-DlxxXkAM.mjs} +10 -10
  35. package/dist/{deploy-transport-Dt0IvSVW.mjs → deploy-transport-DUvm6-CR.mjs} +2 -2
  36. package/dist/deploy.mjs +5 -5
  37. package/dist/{dispatch-pYaww76u.mjs → dispatch-CCiaAnSK.mjs} +4 -4
  38. package/dist/{dist-DeTdhbZc.mjs → dist-Cp4b1_T9.mjs} +1 -1
  39. package/dist/{dist-BQdgCVQF.mjs → dist-STQXl8ck.mjs} +86 -138
  40. package/dist/{domain-Dh3mG8Vs.mjs → domain-DvdZPA50.mjs} +5 -5
  41. package/dist/{drizzle-C8MPqt5m.mjs → drizzle-D4V_06-B.mjs} +1 -1
  42. package/dist/{drizzle-lFdzSEa9.mjs → drizzle-DBSpPpU1.mjs} +34 -8
  43. package/dist/{email-DKyMjOYM.mjs → email-ASpNrfLd.mjs} +7 -7
  44. package/dist/{email-cloudflare-CTt2n_W2.mjs → email-cloudflare-kqoN9jst.mjs} +13 -8
  45. package/dist/{entry-Bw-G1VVx.mjs → entry-BweGTCgj.mjs} +1 -1
  46. package/dist/{env-DkZzh_Dd.mjs → env-Bpkg3G5i.mjs} +5 -5
  47. package/dist/{env-CuzZZyjB.mjs → env-UqS-21xi.mjs} +8 -1
  48. package/dist/{env-public-CeNeO_AT.d.mts → env-public-DtJL_hZq.d.mts} +8 -7
  49. package/dist/{env-validation-1snjKtDX.mjs → env-validation-BpCCQE_6.mjs} +3 -3
  50. package/dist/{env-validation-C8NL3lEH.mjs → env-validation-CN386Utu.mjs} +1 -1
  51. package/dist/gen-M5fNQKfH.mjs +1 -0
  52. package/dist/{gen-BZmFOGDQ.mjs → gen-upKJChvd.mjs} +3 -3
  53. package/dist/{github-cmd-7Oky9qgH.mjs → github-cmd-BvMOlb8Z.mjs} +4 -4
  54. package/dist/{handler-DjqciiDc.d.mts → handler-BO7Od-z9.d.mts} +3 -2
  55. package/dist/{headers-CimYIfQI.mjs → headers-COGEDoMN.mjs} +10 -1
  56. package/dist/help-CItQVDL4.mjs +1 -0
  57. package/dist/{help-CNuUb47C.mjs → help-TPCjTu6e.mjs} +3 -3
  58. package/dist/index.d.mts +3 -3
  59. package/dist/index.mjs +247 -178
  60. package/dist/{info-DwB8IWIx.mjs → info-EsDyihwf.mjs} +2 -2
  61. package/dist/{init-CUGSmcED.mjs → init-a4lVagrb.mjs} +13 -14
  62. package/dist/{link-BlRTGHan.mjs → link-CE55DDzS.mjs} +5 -5
  63. package/dist/{list-iCg7d5Pa.mjs → list-CxRthQks.mjs} +5 -5
  64. package/dist/{live-zKGbRT4h.d.mts → live-Kc55iuOQ.d.mts} +2 -2
  65. package/dist/{login-TA51e5Fw.mjs → login-AfcSGSmE.mjs} +4 -4
  66. package/dist/login-ZHsAm-I6.mjs +1 -0
  67. package/dist/{logs-BlyAxlvx.mjs → logs-BgRJuvb1.mjs} +4 -4
  68. package/dist/{migrate-BH6LCr00.mjs → migrate-BNAh6m_C.mjs} +2 -2
  69. package/dist/migrate-BflbbZQK.mjs +1 -0
  70. package/dist/nitro.mjs +2 -2
  71. package/dist/{node-B0otYjDv.mjs → node-CXFUw0Uz.mjs} +2 -2
  72. package/dist/{operator-args-DuKAQ3Ks.mjs → operator-args-DGTuCdSE.mjs} +8 -0
  73. package/dist/{operator-cmd-CoHlJjcT.mjs → operator-cmd-C-viB7Si.mjs} +4 -4
  74. package/dist/operator-cmd-D6qNuJ_z.mjs +1 -0
  75. package/dist/output-BsdnNpxa.mjs +1 -0
  76. package/dist/{output-CXJTIAtF.mjs → output-DNVILSz2.mjs} +1 -1
  77. package/dist/pages/client.d.mts +28 -3
  78. package/dist/pages/client.mjs +132 -15
  79. package/dist/pages/index.d.mts +3 -2
  80. package/dist/pages/index.mjs +2 -2
  81. package/dist/pages/islands-plugin.d.mts +1 -1
  82. package/dist/pages/islands-plugin.mjs +13 -2
  83. package/dist/pages/protocol.d.mts +2 -2
  84. package/dist/pages/protocol.mjs +1 -1
  85. package/dist/{platform-args-DfT8yQBF.mjs → platform-args-CiYeZmc5.mjs} +1 -1
  86. package/dist/platform-args-DJvF1-kl.mjs +1 -0
  87. package/dist/{platform-auth-config-MO0VdVs9.mjs → platform-auth-config-Dt2qEc2w.mjs} +6 -6
  88. package/dist/{platform-auth-protection-Dv208eyL.mjs → platform-auth-protection-B7TaF-PZ.mjs} +4 -4
  89. package/dist/{platform-auth-recovery-DvAQ674F.mjs → platform-auth-recovery-suXSteJ6.mjs} +4 -4
  90. package/dist/{platform-cmd-dlSxrcQ7.mjs → platform-cmd-9rvYBBtr.mjs} +7 -7
  91. package/dist/{platform-cmd-BpUA19r_.mjs → platform-cmd-DuAsIxbU.mjs} +1 -1
  92. package/dist/{platform-domain-DSO4eUEw.mjs → platform-domain-DhH_vDr6.mjs} +4 -4
  93. package/dist/{platform-lifecycle-CfcFygHb.mjs → platform-lifecycle-3uI-E2bF.mjs} +1 -1
  94. package/dist/{platform-lifecycle-BSvsyB_x.mjs → platform-lifecycle-CXmXe2xt.mjs} +13 -13
  95. package/dist/{platform-management-CrP1XhVd.mjs → platform-management-BBCHfwji.mjs} +3 -3
  96. package/dist/{platform-management-BMdyt667.mjs → platform-management-PdrgDQTe.mjs} +1 -1
  97. package/dist/{platform-plans-config-CgDiwflR.mjs → platform-plans-config-BGwkXYDM.mjs} +2 -2
  98. package/dist/{platform-recovery-CHWwXVZ6.mjs → platform-recovery-C8NxXGRR.mjs} +2 -2
  99. package/dist/{platform-setup-BTQVbnTC.mjs → platform-setup-Casiffqj.mjs} +2 -2
  100. package/dist/{plugin-inference-g66Q1Mx9.mjs → plugin-inference-CErfTgEx.mjs} +3 -3
  101. package/dist/{prepare-DXduEwQp.mjs → prepare-BDKWZgfL.mjs} +5 -5
  102. package/dist/{prepare-DJYHjpzq.mjs → prepare-BLrzXjIl.mjs} +3 -3
  103. package/dist/prepare-a1_5usAn.mjs +1 -0
  104. package/dist/{prerender-render-BN9Lmebs.mjs → prerender-render-BAdYhivW.mjs} +15 -2
  105. package/dist/prerender-render.d.mts +2 -0
  106. package/dist/prerender-render.mjs +1 -1
  107. package/dist/{project-cmd-Dfb1Sg8w.mjs → project-cmd-DzGvxXKH.mjs} +17 -17
  108. package/dist/{project-team-BO2dyc7S.mjs → project-team-C5XtHbZk.mjs} +4 -4
  109. package/dist/{project-token-ByO2mEI2.mjs → project-token-B4D5yhHQ.mjs} +4 -4
  110. package/dist/{project-zero-trust-CoQfwRBR.mjs → project-zero-trust--0LvktDg.mjs} +4 -4
  111. package/dist/{protocol-yxdHxFLN.mjs → protocol-B1Tvc9-x.mjs} +191 -69
  112. package/dist/{protocol-xZMvWsrg.d.mts → protocol-Cg2I81NA.d.mts} +9 -2
  113. package/dist/{provision-D5q-ptD3.mjs → provision-C3yiHdld.mjs} +1 -1
  114. package/dist/{provision-CMH4-8ri.mjs → provision-CAcrauvr.mjs} +1 -1
  115. package/dist/{requests-CPOiDkjh.mjs → requests-CrRiTgQA.mjs} +3 -3
  116. package/dist/resolve-project-C5wC-Hoi.mjs +1 -0
  117. package/dist/{resolve-project-ClvLMTI9.mjs → resolve-project-Da3OgCU1.mjs} +1 -1
  118. package/dist/{rollback-BfCs2la4.mjs → rollback-BsmQyj-Q.mjs} +4 -4
  119. package/dist/{route-types-Cl3x0Q8B.mjs → route-types-CgtlFCDz.mjs} +3 -2
  120. package/dist/routes-stub.d.mts +4 -3
  121. package/dist/runtime/auth.d.mts +1 -1
  122. package/dist/runtime/better-auth-mysql.d.mts +1 -1
  123. package/dist/runtime/better-auth-pg.d.mts +1 -1
  124. package/dist/runtime/better-auth.d.mts +1 -1
  125. package/dist/runtime/client-react.d.mts +1 -1
  126. package/dist/runtime/client-solid.d.mts +1 -1
  127. package/dist/runtime/client-svelte.d.mts +1 -1
  128. package/dist/runtime/client-vue.d.mts +1 -1
  129. package/dist/runtime/client.d.mts +1 -1
  130. package/dist/runtime/db.d.mts +6 -3
  131. package/dist/runtime/db.mjs +2 -2
  132. package/dist/runtime/env-public.d.mts +1 -1
  133. package/dist/runtime/env-public.mjs +53 -39
  134. package/dist/runtime/handler.d.mts +1 -1
  135. package/dist/runtime/live-client.d.mts +1 -1
  136. package/dist/runtime/live.d.mts +1 -1
  137. package/dist/runtime/routing.d.mts +8 -3
  138. package/dist/runtime/routing.mjs +161 -21
  139. package/dist/runtime/validator.d.mts +1 -1
  140. package/dist/runtime/ws-server.d.mts +3 -3
  141. package/dist/runtime/ws.d.mts +1 -1
  142. package/dist/{scan-L8OSv1f7.mjs → scan-BJ3bj6aP.mjs} +228 -27
  143. package/dist/{secret-CuI6LTpD.mjs → secret-D0g5oBsP.mjs} +6 -6
  144. package/dist/{skills-BBO9wMjB.mjs → skills-CoBB9_Ao.mjs} +1 -1
  145. package/dist/{ast-bindings-BkivMJIo.mjs → static-exports-DFkzL-NX.mjs} +96 -33
  146. package/dist/{subcommand-prompt-BZMnCA8T.mjs → subcommand-prompt-0yIARXf2.mjs} +2 -2
  147. package/dist/{types-agfx0alu.d.mts → types-IPut3_Yx.d.mts} +15 -1
  148. package/dist/{wrapper-BGsi_uHs.mjs → wrapper-CVMZarxf.mjs} +1 -1
  149. package/dist/{ws-DB8Feytg.d.mts → ws--U7QicYy.d.mts} +2 -2
  150. package/docs/guide/ai.md +1 -0
  151. package/docs/guide/app-types.md +1 -0
  152. package/docs/guide/auth.md +1 -0
  153. package/docs/guide/database/d1.md +16 -1
  154. package/docs/guide/database/mysql.md +1 -0
  155. package/docs/guide/database/postgresql.md +1 -0
  156. package/docs/guide/database.md +1 -0
  157. package/docs/guide/deployment.md +1 -0
  158. package/docs/guide/durable-state.md +1 -0
  159. package/docs/guide/edge/headers.md +1 -0
  160. package/docs/guide/edge/prerendering.md +1 -0
  161. package/docs/guide/edge/redirects.md +1 -0
  162. package/docs/guide/edge/revalidation.md +3 -0
  163. package/docs/guide/edge/rewrites.md +1 -0
  164. package/docs/guide/edge/static-assets.md +1 -0
  165. package/docs/guide/email/domains.md +1 -0
  166. package/docs/guide/email/receiving.md +3 -2
  167. package/docs/guide/email/sending.md +3 -2
  168. package/docs/guide/email.md +1 -0
  169. package/docs/guide/env-vars.md +4 -0
  170. package/docs/guide/index.md +1 -0
  171. package/docs/guide/jobs.md +1 -0
  172. package/docs/guide/kv.md +1 -0
  173. package/docs/guide/live.md +1 -0
  174. package/docs/guide/pages-routing/actions-and-forms.md +36 -18
  175. package/docs/guide/pages-routing/errors.md +101 -0
  176. package/docs/guide/pages-routing/head.md +1 -0
  177. package/docs/guide/pages-routing/islands.md +1 -0
  178. package/docs/guide/pages-routing/layouts.md +3 -0
  179. package/docs/guide/pages-routing/loaders.md +1 -0
  180. package/docs/guide/pages-routing/markdown.md +1 -1
  181. package/docs/guide/pages-routing/overview.md +3 -0
  182. package/docs/guide/pages-routing/view-transitions.md +1 -0
  183. package/docs/guide/platform/administration/access.md +1 -0
  184. package/docs/guide/platform/administration/connected-apps.md +4 -0
  185. package/docs/guide/platform/administration/email.md +1 -0
  186. package/docs/guide/platform/administration/operations.md +1 -0
  187. package/docs/guide/platform/administration/plans.md +1 -0
  188. package/docs/guide/platform/administration/projects.md +11 -0
  189. package/docs/guide/platform/administration/zero-trust.md +1 -0
  190. package/docs/guide/platform/development/local.md +1 -0
  191. package/docs/guide/platform/development/runtime.md +1 -0
  192. package/docs/guide/platform/development/schema-ci.md +1 -0
  193. package/docs/guide/platform/installation/ci.md +1 -0
  194. package/docs/guide/platform/installation/credentials.md +1 -0
  195. package/docs/guide/platform/installation/domains.md +1 -0
  196. package/docs/guide/platform/installation/first-deployment.md +1 -0
  197. package/docs/guide/platform/installation/maintenance.md +1 -0
  198. package/docs/guide/platform/installation/prerequisites.md +1 -0
  199. package/docs/guide/platform/installation/setup.md +1 -0
  200. package/docs/guide/platform/installation/uninstall.md +1 -0
  201. package/docs/guide/platform-administration.md +1 -0
  202. package/docs/guide/platform-development.md +1 -0
  203. package/docs/guide/project-collaboration.md +1 -0
  204. package/docs/guide/queues.md +3 -0
  205. package/docs/guide/quickstart.md +3 -2
  206. package/docs/guide/remote-dev.md +1 -0
  207. package/docs/guide/sandboxes.md +1 -0
  208. package/docs/guide/self-hosted-platform.md +1 -0
  209. package/docs/guide/server-routing.md +1 -0
  210. package/docs/guide/sse.md +1 -0
  211. package/docs/guide/ssg.md +1 -0
  212. package/docs/guide/ssr.md +1 -0
  213. package/docs/guide/storage.md +1 -0
  214. package/docs/guide/testing.md +62 -0
  215. package/docs/guide/type-safety.md +1 -0
  216. package/docs/guide/typed-fetch.md +1 -0
  217. package/docs/guide/websockets.md +1 -0
  218. package/docs/index.md +1 -0
  219. package/docs/integrations/agents.md +1 -0
  220. package/docs/integrations/cloudflare.md +1 -0
  221. package/docs/integrations/frameworks/analog.md +1 -0
  222. package/docs/integrations/frameworks/astro.md +1 -0
  223. package/docs/integrations/frameworks/nuxt.md +1 -0
  224. package/docs/integrations/frameworks/overview.md +1 -0
  225. package/docs/integrations/frameworks/react-router.md +1 -0
  226. package/docs/integrations/frameworks/sveltekit.md +1 -0
  227. package/docs/integrations/frameworks/tanstack-start.md +1 -0
  228. package/docs/integrations/hono.md +1 -0
  229. package/docs/integrations/nodejs-bun-deno.md +1 -0
  230. package/docs/reference/api/auth.md +1 -0
  231. package/docs/reference/api/client.md +1 -0
  232. package/docs/reference/api/database.md +24 -1
  233. package/docs/reference/api/deploy.md +4 -0
  234. package/docs/reference/api/durable.md +1 -0
  235. package/docs/reference/api/env.md +1 -0
  236. package/docs/reference/api/handlers.md +1 -0
  237. package/docs/reference/api/pages.md +22 -4
  238. package/docs/reference/api/plugin.md +1 -0
  239. package/docs/reference/api/resources.md +1 -0
  240. package/docs/reference/api/rewrites.md +2 -1
  241. package/docs/reference/api/types.md +1 -0
  242. package/docs/reference/api.md +1 -0
  243. package/docs/reference/cli/auth.md +1 -0
  244. package/docs/reference/cli/database.md +1 -0
  245. package/docs/reference/cli/deploy.md +1 -0
  246. package/docs/reference/cli/domains.md +1 -0
  247. package/docs/reference/cli/email.md +1 -0
  248. package/docs/reference/cli/generate.md +1 -0
  249. package/docs/reference/cli/github.md +1 -0
  250. package/docs/reference/cli/platform-config.md +1 -0
  251. package/docs/reference/cli/platform-email.md +1 -0
  252. package/docs/reference/cli/platform-installation.md +1 -0
  253. package/docs/reference/cli/platform-operations.md +1 -0
  254. package/docs/reference/cli/platform-users.md +23 -0
  255. package/docs/reference/cli/platform-zero-trust.md +1 -0
  256. package/docs/reference/cli/platform.md +1 -0
  257. package/docs/reference/cli/project.md +1 -0
  258. package/docs/reference/cli/secrets.md +1 -0
  259. package/docs/reference/cli/setup.md +1 -0
  260. package/docs/reference/cli.md +3 -0
  261. package/docs/reference/config.md +1 -0
  262. package/docs/reference/resource-inference.md +1 -0
  263. package/docs/reference/structure.md +1 -0
  264. package/package.json +25 -25
  265. package/skills/void/SKILL.md +2 -0
  266. package/dist/action-key-XtKKbbsi.mjs +0 -25
  267. package/dist/client-BAxLpSKv.mjs +0 -1
  268. package/dist/deploy-DEZkUS77.mjs +0 -2
  269. package/dist/gen-C6iknRdI.mjs +0 -1
  270. package/dist/help-C_cqTByy.mjs +0 -1
  271. package/dist/login-C4q1S-5b.mjs +0 -1
  272. package/dist/migrate-CVBsSFhC.mjs +0 -1
  273. package/dist/operator-cmd-DnaCnCSP.mjs +0 -1
  274. package/dist/output-CNsMDEd2.mjs +0 -1
  275. package/dist/platform-args-B7-wQ0_B.mjs +0 -1
  276. package/dist/prepare-Bx4a8cb1.mjs +0 -1
  277. package/dist/resolve-project-BALVa9q0.mjs +0 -1
@@ -35,17 +35,14 @@ const ENV_REGISTRY_SYMBOL = Symbol.for("void.env.registry");
35
35
  const registryGlobal = globalThis;
36
36
  const registry = registryGlobal[ENV_REGISTRY_SYMBOL] ??= {
37
37
  schema: null,
38
- hasDefineEnvBeenCalled: false,
39
- bootValidation: null
38
+ hasDefineEnvBeenCalled: false
40
39
  };
41
- const validatedCache = /* @__PURE__ */ new WeakMap();
42
- const cacheList = [];
40
+ let validatedCache = /* @__PURE__ */ new WeakMap();
43
41
  function getValidatedCache(rawEnv) {
44
42
  let cache = validatedCache.get(rawEnv);
45
43
  if (!cache) {
46
44
  cache = /* @__PURE__ */ new Map();
47
45
  validatedCache.set(rawEnv, cache);
48
- cacheList.push(cache);
49
46
  }
50
47
  return cache;
51
48
  }
@@ -68,51 +65,66 @@ function getClientEnvValues() {
68
65
  function defineEnv(schema) {
69
66
  registry.schema = schema;
70
67
  registry.hasDefineEnvBeenCalled = true;
71
- for (const map of cacheList) map.clear();
72
- registry.bootValidation = null;
68
+ validatedCache = /* @__PURE__ */ new WeakMap();
69
+ registry.validation = null;
73
70
  return env;
74
71
  }
75
72
  /**
76
- * Internal: validate the whole schema against the worker env once per isolate,
77
- * from the generated worker entry. Catches remote-secret values the deploy CLI
78
- * cannot see. Async validators are awaited here and their values cached, so
79
- * later synchronous `env.X` reads can serve them.
73
+ * Internal: validate the whole schema against the worker env, from the generated
74
+ * worker entry. Catches remote-secret values the deploy CLI cannot see. A
75
+ * completed validation is reused for the same raw values; an env with other
76
+ * values is validated again. Async validators are awaited here, and their values
77
+ * serve later synchronous `env.X` reads of the env this call receives, and of any
78
+ * other env that holds the same raw values.
80
79
  */
81
80
  async function _validateEnvOnce(envValues) {
82
- if (registry.bootValidation) {
83
- if (!registry.bootValidation.ok) throw registry.bootValidation.error;
84
- return;
85
- }
86
- if (!registry.schema) {
87
- registry.bootValidation = { ok: true };
88
- return;
81
+ const schema = registry.schema;
82
+ if (!schema) return;
83
+ const inputs = readSchemaInputs(schema, envValues);
84
+ const last = registry.validation;
85
+ let state;
86
+ if (last && sameInputs(last.inputs, inputs)) state = last.state;
87
+ else {
88
+ state = await validateSchema(schema, inputs);
89
+ if (registry.schema !== schema) return _validateEnvOnce(envValues);
90
+ registry.validation = {
91
+ inputs,
92
+ state
93
+ };
89
94
  }
90
- const values = {
91
- ...envValues ?? {},
92
- ...getClientEnvValues()
95
+ if (!state.ok) throw state.error;
96
+ seedValidated(envValues, state.values);
97
+ }
98
+ /** The raw value of each schema key that `readKey` would validate for this env. */
99
+ function readSchemaInputs(schema, envValues) {
100
+ const values = typeof envValues === "object" && envValues !== null ? envValues : {};
101
+ const clientValues = getClientEnvValues();
102
+ return new Map(Object.keys(schema).map((key) => [key, Object.hasOwn(clientValues, key) ? clientValues[key] : values[key]]));
103
+ }
104
+ function sameInputs(a, b) {
105
+ if (a.size !== b.size) return false;
106
+ for (const [key, value] of a) if (!b.has(key) || !Object.is(b.get(key), value)) return false;
107
+ return true;
108
+ }
109
+ async function validateSchema(schema, inputs) {
110
+ const report = await validateAllEnvWithValues(schema, Object.fromEntries(inputs));
111
+ if (report.valid) return {
112
+ ok: true,
113
+ values: report.values
93
114
  };
94
- const report = await validateAllEnvWithValues(registry.schema, values);
95
- if (report.valid) {
96
- try {
97
- const cacheKey = getRawRuntimeEnv();
98
- const cache = getValidatedCache(cacheKey);
99
- for (const [key, value] of report.values) {
100
- if (isInternalBinding(key, cacheKey)) continue;
101
- if (!cache.has(key)) cache.set(key, value);
102
- }
103
- } catch {}
104
- registry.bootValidation = { ok: true };
105
- return;
106
- }
107
115
  const lines = ["Env validation failed at worker boot:"];
108
116
  for (const key of report.missing) lines.push(` • ${key} is required but missing`);
109
117
  for (const { key, messages } of report.invalid) lines.push(` • ${key}: ${messages.join("; ")}`);
110
- const error = new EnvValidationError("__init__", [{ message: lines.join("\n") }]);
111
- registry.bootValidation = {
118
+ return {
112
119
  ok: false,
113
- error
120
+ error: new EnvValidationError("__init__", [{ message: lines.join("\n") }])
114
121
  };
115
- throw error;
122
+ }
123
+ /** Seed the per-key cache of `rawEnv`, where `readKey` looks first, with values validated for it. */
124
+ function seedValidated(rawEnv, values) {
125
+ if (typeof rawEnv !== "object" || rawEnv === null || values.size === 0) return;
126
+ const cache = getValidatedCache(rawEnv);
127
+ for (const [key, value] of values) if (!isInternalBinding(key, rawEnv) && !cache.has(key)) cache.set(key, value);
116
128
  }
117
129
  /** Internal: framework-only access to the registered schema (for plugin/CLI). */
118
130
  function _getRegisteredSchema() {
@@ -178,6 +190,8 @@ function readKey(key) {
178
190
  if (!validator) return rawValue;
179
191
  const cache = getValidatedCache(rawEnv);
180
192
  if (cache.has(key)) return cache.get(key);
193
+ const latest = registry.validation;
194
+ if (latest?.state.ok && latest.state.values.has(key) && Object.is(latest.inputs.get(key), rawValue)) return latest.state.values.get(key);
181
195
  const result = validator["~standard"].validate(rawValue);
182
196
  if (result instanceof Promise) throw new Error(`env: Async validator for '${key}' cannot be resolved synchronously. Proxy property access is synchronous, so async Standard Schema validators must be pre-resolved by calling \`_validateEnvOnce(env)\` at worker boot (Void splices this into the generated entry) or by awaiting \`validateAllEnv(env)\` before the first \`env.${key}\` read. Once pre-validated, the resolved value is cached and served synchronously here.`);
183
197
  if (result.issues) {
@@ -235,7 +249,7 @@ async function validateAllEnv(envValues) {
235
249
  }
236
250
  /**
237
251
  * Internal: shared core that validates a schema against values and also
238
- * returns the resolved values (for cache seeding).
252
+ * returns the resolved values (for sync reads).
239
253
  */
240
254
  async function validateAllEnvWithValues(schema, envValues) {
241
255
  const report = {
@@ -1,3 +1,3 @@
1
1
  /// <reference types="@cloudflare/workers-types" />
2
- import { C as defer, E as ValidatorSlots, S as InferProps, T as HandlerInput, _ as defineQueue, a as CloudEnv, b as Deferred, c as QueueRetryOptions, d as TypedQueueHandler, f as VoidAssetRewriteError, g as defineMiddleware, h as defineHead, i as CloudContextVariables, l as RenderAssetTags, m as defineHandler, n as CloudBindings, o as QueueBatch, p as basicAuth, r as CloudContext, s as QueueMessage, t as BasicAuthOptions, u as TypedHandler, v as defineRender, w as ValidationError, y as defineScheduled } from "../handler-DjqciiDc.mjs";
2
+ import { C as defer, E as ValidatorSlots, S as InferProps, T as HandlerInput, _ as defineQueue, a as CloudEnv, b as Deferred, c as QueueRetryOptions, d as TypedQueueHandler, f as VoidAssetRewriteError, g as defineMiddleware, h as defineHead, i as CloudContextVariables, l as RenderAssetTags, m as defineHandler, n as CloudBindings, o as QueueBatch, p as basicAuth, r as CloudContext, s as QueueMessage, t as BasicAuthOptions, u as TypedHandler, v as defineRender, w as ValidationError, y as defineScheduled } from "../handler-BO7Od-z9.mjs";
3
3
  export { BasicAuthOptions, CloudBindings, CloudContext, CloudContextVariables, CloudEnv, type Deferred, type HandlerInput, type InferProps, QueueBatch, QueueMessage, QueueRetryOptions, RenderAssetTags, TypedHandler, TypedQueueHandler, ValidationError, type ValidatorSlots, VoidAssetRewriteError, basicAuth, defer, defineHandler, defineHead, defineMiddleware, defineQueue, defineRender, defineScheduled };
@@ -1,4 +1,4 @@
1
- import { t as LiveClientEvent } from "../live-zKGbRT4h.mjs";
1
+ import { t as LiveClientEvent } from "../live-Kc55iuOQ.mjs";
2
2
  import { n as RequestUrl } from "../route-url-C3JwYrER.mjs";
3
3
  export type LiveSubscribeOptions<Data = unknown> = {
4
4
  id: string;
@@ -1,3 +1,3 @@
1
1
  /// <reference types="@cloudflare/workers-types" />
2
- import { _ as __getLiveBindingName, a as LiveControlErrorCode, b as defineLiveStream, c as LiveControlOptions, d as LiveHookContext, f as LiveLimits, g as LiveSubscribeHookContext, h as LiveStreamOptions, i as LiveControlError, l as LiveControlRequest, m as LiveStream, n as LiveConnectHookContext, o as LiveControlOperation, p as LivePublishOptions, r as LiveConnectOptions, s as LiveControlOperationResult, t as LiveClientEvent, u as LiveControlResponse, v as __setLiveBindingName, y as __setLiveDev } from "../live-zKGbRT4h.mjs";
2
+ import { _ as __getLiveBindingName, a as LiveControlErrorCode, b as defineLiveStream, c as LiveControlOptions, d as LiveHookContext, f as LiveLimits, g as LiveSubscribeHookContext, h as LiveStreamOptions, i as LiveControlError, l as LiveControlRequest, m as LiveStream, n as LiveConnectHookContext, o as LiveControlOperation, p as LivePublishOptions, r as LiveConnectOptions, s as LiveControlOperationResult, t as LiveClientEvent, u as LiveControlResponse, v as __setLiveBindingName, y as __setLiveDev } from "../live-Kc55iuOQ.mjs";
3
3
  export { LiveClientEvent, LiveConnectHookContext, LiveConnectOptions, LiveControlError, LiveControlErrorCode, LiveControlOperation, LiveControlOperationResult, LiveControlOptions, LiveControlRequest, LiveControlResponse, LiveHookContext, LiveLimits, LivePublishOptions, LiveStream, LiveStreamOptions, LiveSubscribeHookContext, __getLiveBindingName, __setLiveBindingName, __setLiveDev, defineLiveStream };
@@ -1,7 +1,7 @@
1
- import { A as filterInternalBindings, M as ClientAssetTags, N as createClientAssetTags, O as createAssetFallback, P as createManifestLoader, j as prerenderPathsResponse, k as createWorkerFetch, r as CloudContext } from "../handler-DjqciiDc.mjs";
2
- import { a as handlePageMutation, i as handlePageGet } from "../protocol-xZMvWsrg.mjs";
1
+ import { A as filterInternalBindings, M as ClientAssetTags, N as createClientAssetTags, O as createAssetFallback, P as createManifestLoader, j as prerenderPathsResponse, k as createWorkerFetch, r as CloudContext } from "../handler-BO7Od-z9.mjs";
2
+ import { a as handlePageMutation, i as handlePageGet } from "../protocol-Cg2I81NA.mjs";
3
3
  import { AsyncLocalStorage } from "node:async_hooks";
4
- import { Context, Hono, MiddlewareHandler, TypedResponse } from "hono";
4
+ import { Context, Hono, MiddlewareHandler, NotFoundHandler, TypedResponse } from "hono";
5
5
  import { RouteDestination, RouteUrlInput } from "void/routes";
6
6
  import { RedirectStatusCode } from "hono/utils/http-status";
7
7
  type ErrorPageStatus = 404 | 500;
@@ -50,8 +50,11 @@ export declare function createNamedActionMarker(matchedRoutes: (c: Context) => A
50
50
  handler: Function;
51
51
  }>): MiddlewareHandler;
52
52
  export declare function createPageGetHandler(options: PageRouteOptions): (c: Context) => Promise<Response>;
53
+ /** Build-only rendering bypasses application middleware and serializes no request data. */
54
+ export declare function createStaticNotFound(options: PageRouteOptions): (request: Request, env: Record<string, unknown>) => Promise<Response>;
53
55
  export declare function createPageMutationHandler(options: PageRouteOptions): (c: Context) => Promise<Response>;
54
56
  export declare function createPagesFallback(options: {
57
+ pageNotFound?: (c: Context) => Promise<Response>;
55
58
  trailingSlash?: boolean;
56
59
  pagePatterns?: Array<RegExp>;
57
60
  routing: RoutingRuntime;
@@ -109,6 +112,8 @@ export type RoutingContext = Context & {
109
112
  export type RoutingRuntime = {
110
113
  requestContext: AsyncLocalStorage<RequestContextStore>;
111
114
  contextMiddleware: MiddlewareHandler;
115
+ trackNotFound: (handler?: NotFoundHandler) => NotFoundHandler;
116
+ preserveNotFound: (response: Response) => Response;
112
117
  requestMiddleware: MiddlewareHandler;
113
118
  routingMiddleware: (rules: Array<RoutingRule>) => MiddlewareHandler;
114
119
  headerMiddleware: (rules: Array<RoutingHeaderRule>, phase?: "auth-error") => MiddlewareHandler;
@@ -1,15 +1,17 @@
1
- import { i as searchWithoutActionKey, n as hasActionKey, r as markActionKey, t as actionKeySegment } from "../action-key-XtKKbbsi.mjs";
1
+ import { a as queryKey, i as markActionKey, n as actionKeySegment, o as searchWithoutActionKey, r as hasActionKey, s as searchWithoutPreservedQuery, t as PRESERVED_QUERY_HEADER } from "../action-key-ByZ6DDld.mjs";
2
2
  import { i as authDependentRequests, n as markStaticAsset, r as SHARED_CACHE_HEADERS, t as isUnchangedStaticAsset } from "../static-asset-marker-DsQKz6lt.mjs";
3
3
  import { t as VoidAssetRewriteError } from "../handler-C9SnmeW1.mjs";
4
4
  import { t as convertReturnValue } from "../response-HmNjB30w.mjs";
5
5
  import { r as toUrlString, t as interpolateRouteParams } from "../route-url-CfCR4oMj.mjs";
6
6
  import { n as createClientAssetTags, r as createManifestLoader, t as ASSET_EXTENSIONS } from "../routing-assets-DJIVOrCh.mjs";
7
- import { n as handlePageGet, r as handlePageMutation } from "../protocol-yxdHxFLN.mjs";
7
+ import { a as handlesPageLoaderNotFound, n as handlePageGet, r as handlePageMutation } from "../protocol-B1Tvc9-x.mjs";
8
8
  import { t as decodePagePath } from "../url-CuoEn0o3.mjs";
9
9
  import { t as renderDefaultErrorPage } from "../error-pages-COVBnzK7.mjs";
10
10
  import { AsyncLocalStorage } from "node:async_hooks";
11
11
  import { compilePattern, matchPattern, matchPatternCaptures, mergeQueryIntoLocation, redirectToHttps, substituteParams } from "@void/edge";
12
+ import { Context } from "hono";
12
13
  // src/runtime/routing-worker.ts
14
+ const intentionalNotFoundRequests = /* @__PURE__ */ new WeakSet();
13
15
  const ASSET_CONTENT_TYPES = {
14
16
  ".avif": "image/avif",
15
17
  ".css": "text/css; charset=utf-8",
@@ -69,7 +71,7 @@ function createAssetCachePolicy(assetsDir, loadManifest = createManifestLoader()
69
71
  function createAssetFallback(options = {}) {
70
72
  const cachePolicy = createAssetCachePolicy(options.assetsDir);
71
73
  return async (request, env, response) => {
72
- if (response.status !== 404 || !env.ASSETS || request.method !== "GET" && request.method !== "HEAD") return response;
74
+ if (response.status !== 404 || intentionalNotFoundRequests.has(request) || !env.ASSETS || request.method !== "GET" && request.method !== "HEAD") return response;
73
75
  const asset = await env.ASSETS.fetch(new Request(request.url, {
74
76
  method: request.method,
75
77
  headers: request.headers
@@ -121,7 +123,8 @@ function createWorkerFetch(options) {
121
123
  return async (request, originalEnv, ctx) => {
122
124
  const url = new URL(request.url);
123
125
  const discovery = request.method === "POST" && url.pathname === "/__void/prerender-paths" && originalEnv.__VOID_PRERENDER === "1";
124
- if (options.validateEnv && !discovery) await options.validateEnv(originalEnv);
126
+ const staticNotFound = request.method === "GET" && url.pathname === "/__void/static-not-found" && originalEnv.__VOID_PRERENDER === "1";
127
+ if (options.validateEnv && !discovery && !staticNotFound) await options.validateEnv(originalEnv);
125
128
  const env = options.remoteEnv && originalEnv.__VOID_REMOTE === "1" ? options.remoteEnv(originalEnv) : originalEnv;
126
129
  if (options.isr) {
127
130
  env.__VOID_ISR_DEPLOYMENT_ID ??= options.isr.deploymentId;
@@ -136,6 +139,7 @@ function createWorkerFetch(options) {
136
139
  ...options.versionMetadataBinding ? { versionId: metadata?.id } : {}
137
140
  }, options.versionMetadataBinding ? { headers: { "cache-control": "no-store" } } : void 0);
138
141
  }
142
+ if (staticNotFound) return options.staticNotFound ? options.staticNotFound(request, env) : new Response(null, { status: 204 });
139
143
  const internal = await options.internalRoute(request, env, ctx);
140
144
  if (internal) return internal;
141
145
  if (discovery) return prerenderPathsResponse(() => options.collectPrerenderPaths(request, env, ctx));
@@ -164,8 +168,9 @@ function preparePageRequest(c, options) {
164
168
  }
165
169
  return true;
166
170
  }
167
- function actionNameOf(url) {
168
- return new URL(url).searchParams.keys().next().value;
171
+ function actionNameOf(request) {
172
+ const search = searchWithoutPreservedQuery(new URL(request.url).search, request.headers.get(PRESERVED_QUERY_HEADER));
173
+ return new URLSearchParams(search).keys().next().value;
169
174
  }
170
175
  const routeHandlers = /* @__PURE__ */ new WeakSet();
171
176
  const namedActionHandlers = /* @__PURE__ */ new WeakSet();
@@ -185,22 +190,48 @@ function markRouteHandler(handler) {
185
190
  function createNamedActionMarker(matchedRoutes) {
186
191
  return async (c, next) => {
187
192
  const answer = matchedRoutes(c).slice(c.req.routeIndex + 1).find((route) => routeHandlers.has(route.handler));
188
- if (answer && namedActionHandlers.has(answer.handler) && actionNameOf(c.req.url)) markActionKey(c.req.raw);
193
+ if (answer && namedActionHandlers.has(answer.handler) && actionNameOf(c.req.raw)) markActionKey(c.req.raw);
189
194
  await next();
190
195
  };
191
196
  }
192
197
  function createPageGetHandler(options) {
193
198
  return markRouteHandler(async (context) => {
194
199
  if (!preparePageRequest(context, options)) return context.notFound();
195
- const mod = options.load ? await options.load() : { head: options.head };
200
+ let mod;
201
+ try {
202
+ mod = options.load ? await options.load() : { head: options.head };
203
+ } catch (error) {
204
+ mod = { loader: () => {
205
+ throw error;
206
+ } };
207
+ }
196
208
  return handlePageGet(mod.loader, mod.head, context, options.componentId, options.render, options.assets, options.headConfig ?? void 0, options.renderOptions);
197
209
  });
198
210
  }
211
+ /** Build-only rendering bypasses application middleware and serializes no request data. */
212
+ function createStaticNotFound(options) {
213
+ const handle = createPageGetHandler({
214
+ ...options,
215
+ renderOptions: {
216
+ ...options.renderOptions,
217
+ renderMode: "server"
218
+ },
219
+ render: (page, assets, url) => options.render({
220
+ ...page,
221
+ documentOnly: true
222
+ }, {
223
+ ...assets,
224
+ body: "",
225
+ preloads: ""
226
+ }, url)
227
+ });
228
+ return (request, env) => handle(new Context(new Request(new URL("/404", request.url)), { env }));
229
+ }
199
230
  function createPageMutationHandler(options) {
200
231
  const mutationHandler = async (context) => {
201
232
  if (!preparePageRequest(context, options)) return context.notFound();
202
233
  const mod = options.load ? await options.load() : {};
203
- const actionName = options.namedActions ? actionNameOf(context.req.url) : void 0;
234
+ const actionName = options.namedActions ? actionNameOf(context.req.raw) : void 0;
204
235
  const name = actionName || "default";
205
236
  const named = mod.actions;
206
237
  const candidate = named && Object.hasOwn(named, name) ? named[name] : void 0;
@@ -215,6 +246,7 @@ function createPageMutationHandler(options) {
215
246
  function createPagesFallback(options) {
216
247
  const cachePolicy = createAssetCachePolicy(options.assetsDir);
217
248
  return async (c) => {
249
+ if (handlesPageLoaderNotFound(c)) return c.newResponse(null, 404);
218
250
  const path = c.req.path;
219
251
  if (path === "/api" || path.startsWith("/api/") || c.req.method !== "GET" && c.req.method !== "HEAD") return c.text("Not Found", 404);
220
252
  const assets = c.env?.ASSETS;
@@ -249,7 +281,10 @@ function createPagesFallback(options) {
249
281
  url.pathname = options.trailingSlash ? `${path}/` : path.slice(0, -1);
250
282
  return Response.redirect(url.href, 301);
251
283
  }
252
- return options.routing.markNoMatch(c.req.raw, await options.errors.serveCustomPage(c, 404, "Not Found"));
284
+ const destination = c.req.header("Sec-Fetch-Dest");
285
+ const accept = c.req.header("Accept");
286
+ const pageRequest = c.req.header("X-VoidPages") === "true" || (!destination || destination === "document" || destination === "empty") && (!accept || accept.includes("text/html") || accept.includes("*/*"));
287
+ return options.routing.markNoMatch(c.req.raw, await (options.pageNotFound && pageRequest ? options.pageNotFound(c) : options.errors.serveCustomPage(c, 404, "Not Found")));
253
288
  };
254
289
  }
255
290
  function createSsrFallback(options) {
@@ -278,7 +313,7 @@ function createSsrFallback(options) {
278
313
  const mod = await options.load();
279
314
  const render = typeof mod.render === "function" ? mod.render : mod.default;
280
315
  if (typeof render !== "function") throw new Error("ssr: Invalid entry. Export render(c, assetTags).");
281
- return render(c, await options.assets(c.req.raw, c.env));
316
+ return options.routing.preserveNotFound(await render(c, await options.assets(c.req.raw, c.env)));
282
317
  };
283
318
  }
284
319
  function createAssetNotFound(options) {
@@ -831,6 +866,79 @@ function createRoutingRuntime(app, options = {}) {
831
866
  const fallbackHandled = /* @__PURE__ */ new WeakSet();
832
867
  const fallbackServed = /* @__PURE__ */ new WeakSet();
833
868
  const headerApplied = /* @__PURE__ */ new WeakSet();
869
+ const explicitNotFound = /* @__PURE__ */ new WeakSet();
870
+ let trackAssetMisses = false;
871
+ const intentionalResponses = /* @__PURE__ */ new WeakSet();
872
+ const routeMisses = /* @__PURE__ */ new WeakMap();
873
+ const missBodies = /* @__PURE__ */ new WeakMap();
874
+ const trackMissBody = (c, body) => {
875
+ if (!body) return;
876
+ let bodies = missBodies.get(c);
877
+ if (!bodies) {
878
+ bodies = /* @__PURE__ */ new WeakSet();
879
+ missBodies.set(c, bodies);
880
+ }
881
+ if (bodies.has(body)) return;
882
+ bodies.add(body);
883
+ if (Object.isExtensible(body)) {
884
+ const pipeThrough = body.pipeThrough;
885
+ Object.defineProperty(body, "pipeThrough", {
886
+ configurable: true,
887
+ writable: true,
888
+ value(...args) {
889
+ const transformed = pipeThrough.apply(this, args);
890
+ if (this === body) trackMissBody(c, transformed);
891
+ return transformed;
892
+ }
893
+ });
894
+ }
895
+ };
896
+ const recordMiss = (c, response) => {
897
+ const misses = routeMisses.get(c) ?? [];
898
+ if (misses.includes(response)) return;
899
+ misses.push(response);
900
+ routeMisses.set(c, misses);
901
+ trackMissBody(c, response.body);
902
+ trackResponseCopies(c);
903
+ if (Object.isExtensible(response)) {
904
+ const clone = response.clone;
905
+ Object.defineProperty(response, "clone", {
906
+ configurable: true,
907
+ writable: true,
908
+ value() {
909
+ const copy = clone.call(this);
910
+ if (this === response) {
911
+ trackMissBody(c, this.body);
912
+ recordMiss(c, copy);
913
+ }
914
+ return copy;
915
+ }
916
+ });
917
+ }
918
+ };
919
+ const isRouteMiss = (c, response) => routeMisses.get(c)?.some((miss) => miss === response || miss.body !== null && miss.body === response.body) === true || response.body !== null && missBodies.get(c)?.has(response.body) === true;
920
+ const tracksResponseCopies = /* @__PURE__ */ new WeakSet();
921
+ const trackResponseCopies = (c) => {
922
+ if (tracksResponseCopies.has(c)) return;
923
+ tracksResponseCopies.add(c);
924
+ const descriptor = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(c), "res");
925
+ if (descriptor?.get && descriptor.set) {
926
+ const set = descriptor.set;
927
+ Object.defineProperty(c, "res", {
928
+ ...descriptor,
929
+ set(response) {
930
+ set.call(c, response);
931
+ if (response && isRouteMiss(c, response) && c.res !== response) recordMiss(c, c.res);
932
+ }
933
+ });
934
+ }
935
+ const header = c.header.bind(c);
936
+ c.header = (...args) => {
937
+ const before = c.finalized ? c.res : void 0;
938
+ header(...args);
939
+ if (before && c.res !== before && isRouteMiss(c, before)) recordMiss(c, c.res);
940
+ };
941
+ };
834
942
  const warnedPatterns = /* @__PURE__ */ new Set();
835
943
  const requestContext = new AsyncLocalStorage();
836
944
  const assetExtensions = options.blockedAssetExtensions ?? ASSET_EXTENSIONS;
@@ -848,6 +956,10 @@ function createRoutingRuntime(app, options = {}) {
848
956
  const dispatch = async (request, c, trace) => {
849
957
  const response = annotate(await (options.nodeTarget ? app.fetch(request, c.env) : app.fetch(request, c.env, c.executionCtx)), trace);
850
958
  if (authDependentRequests.has(request)) authDependentRequests.add(c.req.raw);
959
+ if (trackAssetMisses && response.status === 404) {
960
+ if (intentionalNotFoundRequests.has(request)) intentionalResponses.add(response);
961
+ else recordMiss(c, response);
962
+ }
851
963
  return response;
852
964
  };
853
965
  const rememberOriginal = (request, c) => {
@@ -880,7 +992,7 @@ function createRoutingRuntime(app, options = {}) {
880
992
  if (search) rewriteUrl.search = search;
881
993
  const request = new Request(rewriteUrl.toString(), c.req.raw);
882
994
  rememberOriginal(request, c);
883
- keepActionKey(c.req.raw, request, search);
995
+ keepActionQuery(c.req.raw, request, search);
884
996
  if (fallback) {
885
997
  fallbackHandled.add(request);
886
998
  fallbackServed.add(c.req.raw);
@@ -894,6 +1006,18 @@ function createRoutingRuntime(app, options = {}) {
894
1006
  };
895
1007
  const contextMiddleware = async (context, next) => {
896
1008
  const c = context;
1009
+ if (trackAssetMisses) {
1010
+ intentionalNotFoundRequests.delete(c.req.raw);
1011
+ const notFound = c.notFound.bind(c);
1012
+ c.notFound = () => {
1013
+ explicitNotFound.add(c);
1014
+ try {
1015
+ return notFound();
1016
+ } finally {
1017
+ explicitNotFound.delete(c);
1018
+ }
1019
+ };
1020
+ }
897
1021
  if (options.managedDispatch && !originalUrls.has(c.req.raw)) {
898
1022
  const original = c.req.raw.headers.get("X-Void-Original-URL");
899
1023
  if (original != null) try {
@@ -914,7 +1038,7 @@ function createRoutingRuntime(app, options = {}) {
914
1038
  if (search) url.search = search;
915
1039
  const request = new Request(url.toString(), c.req.raw);
916
1040
  rememberOriginal(request, c);
917
- keepActionKey(c.req.raw, request, search);
1041
+ keepActionQuery(c.req.raw, request, search);
918
1042
  return dispatch(request, c, `c.rewrite -> ${path} (middleware)`);
919
1043
  };
920
1044
  const redirect = context.redirect.bind(context);
@@ -926,10 +1050,28 @@ function createRoutingRuntime(app, options = {}) {
926
1050
  c.originalUrl = () => originalUrls.get(c.req.raw) ?? null;
927
1051
  c.isRewritten = () => originalUrls.has(c.req.raw);
928
1052
  await next();
1053
+ if (!trackAssetMisses) return;
1054
+ if (c.res.status === 404 && !isRouteMiss(c, c.res)) intentionalNotFoundRequests.add(c.req.raw);
929
1055
  };
930
1056
  return {
931
1057
  requestContext,
932
1058
  contextMiddleware,
1059
+ trackNotFound: (handler = (c) => c.text("404 Not Found", 404)) => {
1060
+ trackAssetMisses = true;
1061
+ return (c) => {
1062
+ const explicit = explicitNotFound.has(c);
1063
+ const response = handler(c);
1064
+ if (explicit) return response;
1065
+ return Promise.resolve(response).then((miss) => {
1066
+ if (miss.status === 404 && !intentionalResponses.has(miss)) recordMiss(c, miss);
1067
+ return miss;
1068
+ });
1069
+ };
1070
+ },
1071
+ preserveNotFound: (response) => {
1072
+ if (trackAssetMisses && response.status === 404) intentionalResponses.add(response);
1073
+ return response;
1074
+ },
933
1075
  requestMiddleware: async (c, next) => {
934
1076
  await requestContext.run(options.nodeTarget ? { request: c.req.raw } : {
935
1077
  request: c.req.raw,
@@ -986,7 +1128,7 @@ function createRoutingRuntime(app, options = {}) {
986
1128
  }
987
1129
  function redirectLocation(request, location, status) {
988
1130
  const url = new URL(request.url);
989
- const search = url.search;
1131
+ const search = searchWithoutPreservedQuery(url.search, request.headers.get(PRESERVED_QUERY_HEADER));
990
1132
  if (!hasActionKey(request)) return mergeQueryIntoLocation(location, search);
991
1133
  if (status === 303 || (status === void 0 || status === 301 || status === 302) && request.method === "POST") return mergeQueryIntoLocation(location, searchWithoutActionKey(search));
992
1134
  const hash = location.indexOf("#");
@@ -1007,12 +1149,10 @@ function redirectLocation(request, location, status) {
1007
1149
  const rest = segments.join("&");
1008
1150
  return base.slice(0, q === -1 ? base.length : q) + "?" + first + (rest ? "&" + rest : "") + fragment;
1009
1151
  }
1010
- function queryKey(segment) {
1011
- return new URLSearchParams(segment).keys().next().value;
1012
- }
1013
- /** A rewrite that keeps the query keeps the action key in it too. */
1014
- function keepActionKey(from, to, destinationSearch) {
1015
- if (!destinationSearch && hasActionKey(from)) markActionKey(to);
1152
+ /** Action metadata follows a rewrite only when it keeps the request query. */
1153
+ function keepActionQuery(from, to, destinationSearch) {
1154
+ if (destinationSearch) to.headers.delete(PRESERVED_QUERY_HEADER);
1155
+ else if (hasActionKey(from)) markActionKey(to);
1016
1156
  }
1017
1157
  function markNoMatch(request, response) {
1018
1158
  const url = new URL(request.url);
@@ -1036,4 +1176,4 @@ function createModuleLoader(load, cache = true) {
1036
1176
  return module;
1037
1177
  };
1038
1178
  }
1039
- export { buildPrerenderPath, createAssetFallback, createAssetNotFound, createClientAssetTags, createErrorRenderer, createHttpRouteHandler, createManifestLoader, createModuleLoader, createNamedActionMarker, createPageGetHandler, createPageMutationHandler, createPagesFallback, createRoutingRuntime, createSsrFallback, createWorkerFetch, filterInternalBindings, markNoMatch, markRouteHandler, prerenderPathsResponse };
1179
+ export { buildPrerenderPath, createAssetFallback, createAssetNotFound, createClientAssetTags, createErrorRenderer, createHttpRouteHandler, createManifestLoader, createModuleLoader, createNamedActionMarker, createPageGetHandler, createPageMutationHandler, createPagesFallback, createRoutingRuntime, createSsrFallback, createStaticNotFound, createWorkerFetch, filterInternalBindings, markNoMatch, markRouteHandler, prerenderPathsResponse };
@@ -1,2 +1,2 @@
1
- import { D as runValidation, E as ValidatorSlots, T as HandlerInput } from "../handler-DjqciiDc.mjs";
1
+ import { D as runValidation, E as ValidatorSlots, T as HandlerInput } from "../handler-BO7Od-z9.mjs";
2
2
  export { HandlerInput, ValidatorSlots, runValidation };
@@ -1,6 +1,6 @@
1
- import { r as AuthState } from "../auth-CZrthGxs.mjs";
2
- import { r as VoidAuthRuntimeOptions, t as VoidAuthEnv } from "../better-auth-shared-C-0uZg8-.mjs";
3
- import { f as WebSocketInstanceKey, t as AnyWebSocketDefinition } from "../ws-DB8Feytg.mjs";
1
+ import { r as AuthState } from "../auth-Bk9VGtQW.mjs";
2
+ import { r as VoidAuthRuntimeOptions, t as VoidAuthEnv } from "../better-auth-shared-CQFdtguU.mjs";
3
+ import { f as WebSocketInstanceKey, t as AnyWebSocketDefinition } from "../ws--U7QicYy.mjs";
4
4
  export type WebSocketRouteMeta = {
5
5
  name?: string;
6
6
  key?: WebSocketInstanceKey;
@@ -1,2 +1,2 @@
1
- import { a as RoomDefinition, c as VoidSocket, d as WebSocketConnection, f as WebSocketInstanceKey, h as defineWebSocket, i as RoomController, l as VoidSocketCloseEvent, m as defineRoom, n as ConnectCommonOptions, o as SocketContext, p as connect, r as RoomContext, s as SocketDefinition, t as AnyWebSocketDefinition, u as WebSocketBaseContext } from "../ws-DB8Feytg.mjs";
1
+ import { a as RoomDefinition, c as VoidSocket, d as WebSocketConnection, f as WebSocketInstanceKey, h as defineWebSocket, i as RoomController, l as VoidSocketCloseEvent, m as defineRoom, n as ConnectCommonOptions, o as SocketContext, p as connect, r as RoomContext, s as SocketDefinition, t as AnyWebSocketDefinition, u as WebSocketBaseContext } from "../ws--U7QicYy.mjs";
2
2
  export { AnyWebSocketDefinition, ConnectCommonOptions, RoomContext, RoomController, RoomDefinition, SocketContext, SocketDefinition, VoidSocket, VoidSocketCloseEvent, WebSocketBaseContext, WebSocketConnection, WebSocketInstanceKey, connect, defineRoom, defineWebSocket };