@axium/server 0.24.1 → 0.26.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 (389) hide show
  1. package/build/client/_app/immutable/assets/account.dAAx7bby.css +1 -0
  2. package/build/client/_app/immutable/assets/account.dAAx7bby.css.br +0 -0
  3. package/build/client/_app/immutable/assets/account.dAAx7bby.css.gz +0 -0
  4. package/build/client/_app/immutable/assets/list.DVGH0BeP.css +1 -0
  5. package/build/client/_app/immutable/assets/list.DVGH0BeP.css.br +0 -0
  6. package/build/client/_app/immutable/assets/list.DVGH0BeP.css.gz +0 -0
  7. package/build/client/_app/immutable/assets/styles.D8SZ-PeY.css +1 -0
  8. package/build/client/_app/immutable/assets/styles.D8SZ-PeY.css.br +2 -0
  9. package/build/client/_app/immutable/assets/styles.D8SZ-PeY.css.gz +0 -0
  10. package/build/client/_app/immutable/chunks/46qGscyh.js +2 -0
  11. package/build/client/_app/immutable/chunks/46qGscyh.js.br +0 -0
  12. package/build/client/_app/immutable/chunks/46qGscyh.js.gz +0 -0
  13. package/build/client/_app/immutable/chunks/B2Vkpbkw.js +2 -0
  14. package/build/client/_app/immutable/chunks/B2Vkpbkw.js.br +0 -0
  15. package/build/client/_app/immutable/chunks/B2Vkpbkw.js.gz +0 -0
  16. package/build/client/_app/immutable/chunks/BKixenYx.js +1 -0
  17. package/build/client/_app/immutable/chunks/BKixenYx.js.br +0 -0
  18. package/build/client/_app/immutable/chunks/BKixenYx.js.gz +0 -0
  19. package/build/client/_app/immutable/chunks/BLtAtlP3.js +1 -0
  20. package/build/client/_app/immutable/chunks/BLtAtlP3.js.br +2 -0
  21. package/build/client/_app/immutable/chunks/BLtAtlP3.js.gz +0 -0
  22. package/build/client/_app/immutable/chunks/BNTlty5m.js +1 -0
  23. package/build/client/_app/immutable/chunks/BNTlty5m.js.br +0 -0
  24. package/build/client/_app/immutable/chunks/BNTlty5m.js.gz +0 -0
  25. package/build/client/_app/immutable/chunks/Beh6Ec8J.js +1 -0
  26. package/build/client/_app/immutable/chunks/Beh6Ec8J.js.br +0 -0
  27. package/build/client/_app/immutable/chunks/Beh6Ec8J.js.gz +0 -0
  28. package/build/client/_app/immutable/chunks/BrUe-Qen.js +1 -0
  29. package/build/client/_app/immutable/chunks/BrUe-Qen.js.br +0 -0
  30. package/build/client/_app/immutable/chunks/BrUe-Qen.js.gz +0 -0
  31. package/build/client/_app/immutable/chunks/Bs4cD_pX.js +1 -0
  32. package/build/client/_app/immutable/chunks/Bs4cD_pX.js.br +0 -0
  33. package/build/client/_app/immutable/chunks/Bs4cD_pX.js.gz +0 -0
  34. package/build/client/_app/immutable/chunks/C62F-tXu.js +1 -0
  35. package/build/client/_app/immutable/chunks/C62F-tXu.js.br +1 -0
  36. package/build/client/_app/immutable/chunks/C62F-tXu.js.gz +0 -0
  37. package/build/client/_app/immutable/chunks/CUBtP2L9.js +23 -0
  38. package/build/client/_app/immutable/chunks/CUBtP2L9.js.br +0 -0
  39. package/build/client/_app/immutable/chunks/CUBtP2L9.js.gz +0 -0
  40. package/build/client/_app/immutable/chunks/Ch16TNvP.js +1 -0
  41. package/build/client/_app/immutable/chunks/Ch16TNvP.js.br +0 -0
  42. package/build/client/_app/immutable/chunks/Ch16TNvP.js.gz +0 -0
  43. package/build/client/_app/immutable/chunks/CoYD6HNm.js +1 -0
  44. package/build/client/_app/immutable/chunks/CoYD6HNm.js.br +0 -0
  45. package/build/client/_app/immutable/chunks/CoYD6HNm.js.gz +0 -0
  46. package/build/client/_app/immutable/chunks/D40Zn55h.js +1 -0
  47. package/build/client/_app/immutable/chunks/D40Zn55h.js.br +0 -0
  48. package/build/client/_app/immutable/chunks/D40Zn55h.js.gz +0 -0
  49. package/build/client/_app/immutable/chunks/DW7-1esk.js +21 -0
  50. package/build/client/_app/immutable/chunks/DW7-1esk.js.br +0 -0
  51. package/build/client/_app/immutable/chunks/DW7-1esk.js.gz +0 -0
  52. package/build/client/_app/immutable/chunks/DY4fWHx_.js +1 -0
  53. package/build/client/_app/immutable/chunks/DY4fWHx_.js.br +0 -0
  54. package/build/client/_app/immutable/chunks/DY4fWHx_.js.gz +0 -0
  55. package/build/client/_app/immutable/chunks/DvOBbqVY.js +1 -0
  56. package/build/client/_app/immutable/chunks/DvOBbqVY.js.br +0 -0
  57. package/build/client/_app/immutable/chunks/DvOBbqVY.js.gz +0 -0
  58. package/build/client/_app/immutable/chunks/DwZYWemd.js +1 -0
  59. package/build/client/_app/immutable/chunks/DwZYWemd.js.br +0 -0
  60. package/build/client/_app/immutable/chunks/DwZYWemd.js.gz +0 -0
  61. package/build/client/_app/immutable/chunks/Dy2Ho0cF.js +1 -0
  62. package/build/client/_app/immutable/chunks/Dy2Ho0cF.js.br +0 -0
  63. package/build/client/_app/immutable/chunks/Dy2Ho0cF.js.gz +0 -0
  64. package/build/client/_app/immutable/chunks/FTv0qR3w.js +1 -0
  65. package/build/client/_app/immutable/chunks/FTv0qR3w.js.br +0 -0
  66. package/build/client/_app/immutable/chunks/FTv0qR3w.js.gz +0 -0
  67. package/build/client/_app/immutable/chunks/NeK0YGoY.js +1 -0
  68. package/build/client/_app/immutable/chunks/NeK0YGoY.js.br +0 -0
  69. package/build/client/_app/immutable/chunks/NeK0YGoY.js.gz +0 -0
  70. package/build/client/_app/immutable/chunks/aArGsq9c.js +1 -0
  71. package/build/client/_app/immutable/chunks/aArGsq9c.js.br +0 -0
  72. package/build/client/_app/immutable/chunks/aArGsq9c.js.gz +0 -0
  73. package/build/client/_app/immutable/chunks/lH47zGKU.js +1 -0
  74. package/build/client/_app/immutable/chunks/lH47zGKU.js.br +0 -0
  75. package/build/client/_app/immutable/chunks/lH47zGKU.js.gz +0 -0
  76. package/build/client/_app/immutable/chunks/sMHjBQqw.js +1 -0
  77. package/build/client/_app/immutable/chunks/sMHjBQqw.js.br +0 -0
  78. package/build/client/_app/immutable/chunks/sMHjBQqw.js.gz +0 -0
  79. package/build/client/_app/immutable/chunks/vQfHcJV6.js +2 -0
  80. package/build/client/_app/immutable/chunks/vQfHcJV6.js.br +0 -0
  81. package/build/client/_app/immutable/chunks/vQfHcJV6.js.gz +0 -0
  82. package/build/client/_app/immutable/entry/app.pLVZKpSD.js +2 -0
  83. package/build/client/_app/immutable/entry/app.pLVZKpSD.js.br +0 -0
  84. package/build/client/_app/immutable/entry/app.pLVZKpSD.js.gz +0 -0
  85. package/build/client/_app/immutable/entry/start.CUaVsIrY.js +1 -0
  86. package/build/client/_app/immutable/entry/start.CUaVsIrY.js.br +2 -0
  87. package/build/client/_app/immutable/entry/start.CUaVsIrY.js.gz +0 -0
  88. package/build/client/_app/immutable/nodes/0.D7hET-Bq.js +1 -0
  89. package/build/client/_app/immutable/nodes/0.D7hET-Bq.js.br +0 -0
  90. package/build/client/_app/immutable/nodes/0.D7hET-Bq.js.gz +0 -0
  91. package/build/client/_app/immutable/nodes/1.BWU-JJm_.js +1 -0
  92. package/build/client/_app/immutable/nodes/1.BWU-JJm_.js.br +2 -0
  93. package/build/client/_app/immutable/nodes/1.BWU-JJm_.js.gz +0 -0
  94. package/build/client/_app/immutable/nodes/10.C5N2XBee.js +1 -0
  95. package/build/client/_app/immutable/nodes/10.C5N2XBee.js.br +0 -0
  96. package/build/client/_app/immutable/nodes/10.C5N2XBee.js.gz +0 -0
  97. package/build/client/_app/immutable/nodes/11.CerbuSAv.js +1 -0
  98. package/build/client/_app/immutable/nodes/11.CerbuSAv.js.br +0 -0
  99. package/build/client/_app/immutable/nodes/11.CerbuSAv.js.gz +0 -0
  100. package/build/client/_app/immutable/nodes/12.Z4B9zS78.js +1 -0
  101. package/build/client/_app/immutable/nodes/12.Z4B9zS78.js.br +0 -0
  102. package/build/client/_app/immutable/nodes/12.Z4B9zS78.js.gz +0 -0
  103. package/build/client/_app/immutable/nodes/13.CuICShck.js +1 -0
  104. package/build/client/_app/immutable/nodes/13.CuICShck.js.br +0 -0
  105. package/build/client/_app/immutable/nodes/13.CuICShck.js.gz +0 -0
  106. package/build/client/_app/immutable/nodes/14.BSEF5oaF.js +1 -0
  107. package/build/client/_app/immutable/nodes/14.BSEF5oaF.js.br +0 -0
  108. package/build/client/_app/immutable/nodes/14.BSEF5oaF.js.gz +0 -0
  109. package/build/client/_app/immutable/nodes/15.D1nsmo6j.js +1 -0
  110. package/build/client/_app/immutable/nodes/15.D1nsmo6j.js.br +0 -0
  111. package/build/client/_app/immutable/nodes/15.D1nsmo6j.js.gz +0 -0
  112. package/build/client/_app/immutable/nodes/2.DQ1JcYgz.js +1 -0
  113. package/build/client/_app/immutable/nodes/2.DQ1JcYgz.js.br +0 -0
  114. package/build/client/_app/immutable/nodes/2.DQ1JcYgz.js.gz +0 -0
  115. package/build/client/_app/immutable/nodes/3.BJp2JEtW.js +1 -0
  116. package/build/client/_app/immutable/nodes/3.BJp2JEtW.js.br +0 -0
  117. package/build/client/_app/immutable/nodes/3.BJp2JEtW.js.gz +0 -0
  118. package/build/client/_app/immutable/nodes/4.Cvn_QsIx.js +1 -0
  119. package/build/client/_app/immutable/nodes/4.Cvn_QsIx.js.br +0 -0
  120. package/build/client/_app/immutable/nodes/4.Cvn_QsIx.js.gz +0 -0
  121. package/build/client/_app/immutable/nodes/5.DgPP9GX3.js +1 -0
  122. package/build/client/_app/immutable/nodes/5.DgPP9GX3.js.br +0 -0
  123. package/build/client/_app/immutable/nodes/5.DgPP9GX3.js.gz +0 -0
  124. package/build/client/_app/immutable/nodes/6.DKIzms8i.js +2 -0
  125. package/build/client/_app/immutable/nodes/6.DKIzms8i.js.br +0 -0
  126. package/build/client/_app/immutable/nodes/6.DKIzms8i.js.gz +0 -0
  127. package/build/client/_app/immutable/nodes/7.3UigVXV4.js +1 -0
  128. package/build/client/_app/immutable/nodes/7.3UigVXV4.js.br +0 -0
  129. package/build/client/_app/immutable/nodes/7.3UigVXV4.js.gz +0 -0
  130. package/build/client/_app/immutable/nodes/8.B8s2TdNQ.js +1 -0
  131. package/build/client/_app/immutable/nodes/8.B8s2TdNQ.js.br +0 -0
  132. package/build/client/_app/immutable/nodes/8.B8s2TdNQ.js.gz +0 -0
  133. package/build/client/_app/immutable/nodes/9.LBMMe2kc.js +1 -0
  134. package/build/client/_app/immutable/nodes/9.LBMMe2kc.js.br +0 -0
  135. package/build/client/_app/immutable/nodes/9.LBMMe2kc.js.gz +0 -0
  136. package/build/client/_app/version.json +1 -1
  137. package/build/client/_app/version.json.br +0 -0
  138. package/build/client/_app/version.json.gz +0 -0
  139. package/build/client/styles.css +28 -0
  140. package/build/client/styles.css.br +0 -0
  141. package/build/client/styles.css.gz +0 -0
  142. package/build/handler.js +20 -3
  143. package/build/server/chunks/0-CNbALTKz.js +9 -0
  144. package/build/server/chunks/0-CNbALTKz.js.map +1 -0
  145. package/build/server/chunks/1-Dgxy393u.js +9 -0
  146. package/build/server/chunks/1-Dgxy393u.js.map +1 -0
  147. package/build/server/chunks/10-DovmbqKa.js +14 -0
  148. package/build/server/chunks/10-DovmbqKa.js.map +1 -0
  149. package/build/server/chunks/11-CRK_ubcl.js +14 -0
  150. package/build/server/chunks/11-CRK_ubcl.js.map +1 -0
  151. package/build/server/chunks/12-SbQlwMfe.js +9 -0
  152. package/build/server/chunks/12-SbQlwMfe.js.map +1 -0
  153. package/build/server/chunks/13-CbniIW7F.js +14 -0
  154. package/build/server/chunks/13-CbniIW7F.js.map +1 -0
  155. package/build/server/chunks/14-D9Vb_8Yx.js +9 -0
  156. package/build/server/chunks/14-D9Vb_8Yx.js.map +1 -0
  157. package/build/server/chunks/15-D-75Hdef.js +9 -0
  158. package/build/server/chunks/15-D-75Hdef.js.map +1 -0
  159. package/build/server/chunks/2-57exN8ae.js +14 -0
  160. package/build/server/chunks/2-57exN8ae.js.map +1 -0
  161. package/build/server/chunks/3-DNQft-pY.js +9 -0
  162. package/build/server/chunks/{2-CXlrhpR6.js.map → 3-DNQft-pY.js.map} +1 -1
  163. package/build/server/chunks/4-D9Bwp-f8.js +14 -0
  164. package/build/server/chunks/4-D9Bwp-f8.js.map +1 -0
  165. package/build/server/chunks/5-COEQwZNP.js +14 -0
  166. package/build/server/chunks/5-COEQwZNP.js.map +1 -0
  167. package/build/server/chunks/6-RT4yiDcP.js +14 -0
  168. package/build/server/chunks/6-RT4yiDcP.js.map +1 -0
  169. package/build/server/chunks/7-CVqF_r5D.js +14 -0
  170. package/build/server/chunks/7-CVqF_r5D.js.map +1 -0
  171. package/build/server/chunks/8-C5SO-sVH.js +14 -0
  172. package/build/server/chunks/8-C5SO-sVH.js.map +1 -0
  173. package/build/server/chunks/9-DoCOKtY-.js +14 -0
  174. package/build/server/chunks/9-DoCOKtY-.js.map +1 -0
  175. package/build/server/chunks/FormDialog-ZCY0chY1.js +102 -0
  176. package/build/server/chunks/FormDialog-ZCY0chY1.js.map +1 -0
  177. package/build/server/chunks/Icon-BVo9qbDf.js +30 -0
  178. package/build/server/chunks/Icon-BVo9qbDf.js.map +1 -0
  179. package/build/server/chunks/Logout-CmBZgu0j.js +46 -0
  180. package/build/server/chunks/Logout-CmBZgu0j.js.map +1 -0
  181. package/build/server/chunks/_layout.svelte-DuS006VZ.js +33 -0
  182. package/build/server/chunks/_layout.svelte-DuS006VZ.js.map +1 -0
  183. package/build/server/chunks/_page.svelte-BFVobcI7.js +14 -0
  184. package/build/server/chunks/_page.svelte-BFVobcI7.js.map +1 -0
  185. package/build/server/chunks/_page.svelte-B_cvhWJS.js +66 -0
  186. package/build/server/chunks/_page.svelte-B_cvhWJS.js.map +1 -0
  187. package/build/server/chunks/_page.svelte-BriaBR9l.js +28 -0
  188. package/build/server/chunks/_page.svelte-BriaBR9l.js.map +1 -0
  189. package/build/server/chunks/_page.svelte-BtQQzT7H.js +72 -0
  190. package/build/server/chunks/_page.svelte-BtQQzT7H.js.map +1 -0
  191. package/build/server/chunks/_page.svelte-C8D3c3yB.js +64 -0
  192. package/build/server/chunks/_page.svelte-C8D3c3yB.js.map +1 -0
  193. package/build/server/chunks/_page.svelte-CVSb9eHQ.js +24 -0
  194. package/build/server/chunks/_page.svelte-CVSb9eHQ.js.map +1 -0
  195. package/build/server/chunks/_page.svelte-CwRjZqL7.js +107 -0
  196. package/build/server/chunks/_page.svelte-CwRjZqL7.js.map +1 -0
  197. package/build/server/chunks/_page.svelte-D9A9RYjx.js +233 -0
  198. package/build/server/chunks/_page.svelte-D9A9RYjx.js.map +1 -0
  199. package/build/server/chunks/_page.svelte-DGhwqWMM.js +34 -0
  200. package/build/server/chunks/_page.svelte-DGhwqWMM.js.map +1 -0
  201. package/build/server/chunks/_page.svelte-DTvnX95_.js +75 -0
  202. package/build/server/chunks/_page.svelte-DTvnX95_.js.map +1 -0
  203. package/build/server/chunks/_page.svelte-DUfwpXfC.js +122 -0
  204. package/build/server/chunks/_page.svelte-DUfwpXfC.js.map +1 -0
  205. package/build/server/chunks/_page.svelte-DxDoD3rZ.js +37 -0
  206. package/build/server/chunks/_page.svelte-DxDoD3rZ.js.map +1 -0
  207. package/build/server/chunks/_page.svelte-VDBvShZ8.js +6 -0
  208. package/build/server/chunks/_page.svelte-VDBvShZ8.js.map +1 -0
  209. package/build/server/chunks/account-Bf_llRe2.js +446 -0
  210. package/build/server/chunks/account-Bf_llRe2.js.map +1 -0
  211. package/build/server/chunks/auth_redirect-olBYiIF2.js +24 -0
  212. package/build/server/chunks/auth_redirect-olBYiIF2.js.map +1 -0
  213. package/build/server/chunks/color-K_MR7m8s.js +14 -0
  214. package/build/server/chunks/color-K_MR7m8s.js.map +1 -0
  215. package/build/server/chunks/context-R2425nfV.js +64 -0
  216. package/build/server/chunks/context-R2425nfV.js.map +1 -0
  217. package/build/server/chunks/{error.svelte-DNQXZmIO.js → error.svelte-CkSCwrMJ.js} +7 -6
  218. package/build/server/chunks/error.svelte-CkSCwrMJ.js.map +1 -0
  219. package/build/server/chunks/index-CIEcmmdN.js +890 -0
  220. package/build/server/chunks/index-CIEcmmdN.js.map +1 -0
  221. package/build/server/chunks/{index-CvHf_GW2.js → index-Tt4zVDIZ.js} +843 -438
  222. package/build/server/chunks/index-Tt4zVDIZ.js.map +1 -0
  223. package/build/server/chunks/layout.svelte-UxsTmhKc.js +8 -0
  224. package/build/server/chunks/layout.svelte-UxsTmhKc.js.map +1 -0
  225. package/build/server/chunks/{string-DLbvtT1R.js → numbers-DL8C9q4W.js} +1 -71
  226. package/build/server/chunks/numbers-DL8C9q4W.js.map +1 -0
  227. package/build/server/chunks/{FormDialog-CB-2YGWi.js → user2-CRfK67II.js} +12 -206
  228. package/build/server/chunks/user2-CRfK67II.js.map +1 -0
  229. package/build/server/chunks/utils-h74ns7K6.js.map +1 -1
  230. package/build/server/index.js +2304 -1140
  231. package/build/server/index.js.map +1 -1
  232. package/build/server/manifest.js +78 -13
  233. package/build/server/manifest.js.map +1 -1
  234. package/dist/acl.d.ts +1 -2
  235. package/dist/acl.js +1 -1
  236. package/dist/api/acl.js +4 -4
  237. package/dist/api/admin.d.ts +1 -0
  238. package/dist/api/admin.js +152 -0
  239. package/dist/api/index.d.ts +2 -0
  240. package/dist/api/index.js +2 -0
  241. package/dist/api/metadata.js +5 -5
  242. package/dist/api/passkeys.js +10 -10
  243. package/dist/api/register.js +4 -4
  244. package/dist/api/session.js +5 -5
  245. package/dist/api/users.js +52 -49
  246. package/dist/audit.d.ts +8 -39
  247. package/dist/audit.js +13 -16
  248. package/dist/auth.d.ts +4 -11
  249. package/dist/auth.js +4 -4
  250. package/dist/cli.js +515 -559
  251. package/dist/config.d.ts +26 -16
  252. package/dist/config.js +65 -36
  253. package/dist/database.d.ts +3 -4
  254. package/dist/database.js +19 -18
  255. package/dist/internal_requests.d.ts +3 -0
  256. package/dist/internal_requests.js +119 -0
  257. package/dist/io.d.ts +0 -49
  258. package/dist/io.js +23 -171
  259. package/dist/linking.d.ts +0 -1
  260. package/dist/linking.js +5 -8
  261. package/dist/requests.d.ts +10 -6
  262. package/dist/requests.js +17 -15
  263. package/dist/routes.d.ts +6 -10
  264. package/dist/routes.js +7 -8
  265. package/dist/serve.d.ts +7 -2
  266. package/dist/serve.js +170 -13
  267. package/dist/state.js +2 -1
  268. package/package.json +8 -7
  269. package/routes/account/+page.svelte +5 -109
  270. package/routes/admin/+layout.svelte +56 -0
  271. package/routes/admin/+layout.ts +31 -0
  272. package/routes/admin/+page.svelte +39 -0
  273. package/routes/admin/+page.ts +7 -0
  274. package/routes/admin/audit/+page.svelte +158 -0
  275. package/routes/admin/audit/+page.ts +22 -0
  276. package/routes/admin/audit/[id]/+page.svelte +43 -0
  277. package/routes/admin/audit/[id]/+page.ts +9 -0
  278. package/routes/admin/audit/styles.css +31 -0
  279. package/routes/admin/config/+page.svelte +28 -0
  280. package/routes/admin/config/+page.ts +9 -0
  281. package/routes/admin/plugins/+page.svelte +23 -0
  282. package/routes/admin/plugins/+page.ts +7 -0
  283. package/routes/admin/users/+page.svelte +60 -0
  284. package/routes/admin/users/+page.ts +9 -0
  285. package/routes/admin/users/[id]/+page.svelte +108 -0
  286. package/routes/admin/users/[id]/+page.ts +17 -0
  287. package/routes/login/client/+page.svelte +72 -0
  288. package/routes/login/client/+page.ts +27 -0
  289. package/routes/tsconfig.json +1 -1
  290. package/svelte.config.js +4 -10
  291. package/{web/template.html → template.html} +1 -1
  292. package/{web/tsconfig.json → web.tsconfig.json} +2 -2
  293. package/build/client/_app/immutable/chunks/B1E1cVbi.js +0 -1
  294. package/build/client/_app/immutable/chunks/B1E1cVbi.js.br +0 -0
  295. package/build/client/_app/immutable/chunks/B1E1cVbi.js.gz +0 -0
  296. package/build/client/_app/immutable/chunks/CIywFg5g.js +0 -3
  297. package/build/client/_app/immutable/chunks/CIywFg5g.js.br +0 -0
  298. package/build/client/_app/immutable/chunks/CIywFg5g.js.gz +0 -0
  299. package/build/client/_app/immutable/chunks/D3hk2v8y.js +0 -1
  300. package/build/client/_app/immutable/chunks/D3hk2v8y.js.br +0 -2
  301. package/build/client/_app/immutable/chunks/D3hk2v8y.js.gz +0 -0
  302. package/build/client/_app/immutable/chunks/D4Bce_hb.js +0 -1
  303. package/build/client/_app/immutable/chunks/D4Bce_hb.js.br +0 -0
  304. package/build/client/_app/immutable/chunks/D4Bce_hb.js.gz +0 -0
  305. package/build/client/_app/immutable/chunks/D9TfJrfD.js +0 -1
  306. package/build/client/_app/immutable/chunks/D9TfJrfD.js.br +0 -0
  307. package/build/client/_app/immutable/chunks/D9TfJrfD.js.gz +0 -0
  308. package/build/client/_app/immutable/chunks/DJeR1n-B.js +0 -51
  309. package/build/client/_app/immutable/chunks/DJeR1n-B.js.br +0 -0
  310. package/build/client/_app/immutable/chunks/DJeR1n-B.js.gz +0 -0
  311. package/build/client/_app/immutable/chunks/DsnmJJEf.js +0 -1
  312. package/build/client/_app/immutable/chunks/DsnmJJEf.js.br +0 -2
  313. package/build/client/_app/immutable/chunks/DsnmJJEf.js.gz +0 -0
  314. package/build/client/_app/immutable/chunks/Dy1O3iBu.js +0 -2
  315. package/build/client/_app/immutable/chunks/Dy1O3iBu.js.br +0 -0
  316. package/build/client/_app/immutable/chunks/Dy1O3iBu.js.gz +0 -0
  317. package/build/client/_app/immutable/chunks/pba7IodQ.js +0 -1
  318. package/build/client/_app/immutable/chunks/pba7IodQ.js.br +0 -0
  319. package/build/client/_app/immutable/chunks/pba7IodQ.js.gz +0 -0
  320. package/build/client/_app/immutable/entry/app.ChtScU8h.js +0 -2
  321. package/build/client/_app/immutable/entry/app.ChtScU8h.js.br +0 -0
  322. package/build/client/_app/immutable/entry/app.ChtScU8h.js.gz +0 -0
  323. package/build/client/_app/immutable/entry/start.DdjgBKiR.js +0 -1
  324. package/build/client/_app/immutable/entry/start.DdjgBKiR.js.br +0 -2
  325. package/build/client/_app/immutable/entry/start.DdjgBKiR.js.gz +0 -0
  326. package/build/client/_app/immutable/nodes/0.DlE8ZTIF.js +0 -1
  327. package/build/client/_app/immutable/nodes/0.DlE8ZTIF.js.br +0 -0
  328. package/build/client/_app/immutable/nodes/0.DlE8ZTIF.js.gz +0 -0
  329. package/build/client/_app/immutable/nodes/1.DRjfV_5C.js +0 -1
  330. package/build/client/_app/immutable/nodes/1.DRjfV_5C.js.br +0 -0
  331. package/build/client/_app/immutable/nodes/1.DRjfV_5C.js.gz +0 -0
  332. package/build/client/_app/immutable/nodes/2.CvEpuMc7.js +0 -1
  333. package/build/client/_app/immutable/nodes/2.CvEpuMc7.js.br +0 -0
  334. package/build/client/_app/immutable/nodes/2.CvEpuMc7.js.gz +0 -0
  335. package/build/client/_app/immutable/nodes/3.CVudd8x2.js +0 -7
  336. package/build/client/_app/immutable/nodes/3.CVudd8x2.js.br +0 -0
  337. package/build/client/_app/immutable/nodes/3.CVudd8x2.js.gz +0 -0
  338. package/build/client/_app/immutable/nodes/4.Dhj0R0r7.js +0 -1
  339. package/build/client/_app/immutable/nodes/4.Dhj0R0r7.js.br +0 -0
  340. package/build/client/_app/immutable/nodes/4.Dhj0R0r7.js.gz +0 -0
  341. package/build/client/_app/immutable/nodes/5.CGoBaVII.js +0 -1
  342. package/build/client/_app/immutable/nodes/5.CGoBaVII.js.br +0 -0
  343. package/build/client/_app/immutable/nodes/5.CGoBaVII.js.gz +0 -0
  344. package/build/client/_app/immutable/nodes/6.BtB2uWXy.js +0 -1
  345. package/build/client/_app/immutable/nodes/6.BtB2uWXy.js.br +0 -0
  346. package/build/client/_app/immutable/nodes/6.BtB2uWXy.js.gz +0 -0
  347. package/build/server/chunks/0-DgHTujtC.js +0 -9
  348. package/build/server/chunks/0-DgHTujtC.js.map +0 -1
  349. package/build/server/chunks/1-B3zVLOO8.js +0 -9
  350. package/build/server/chunks/1-B3zVLOO8.js.map +0 -1
  351. package/build/server/chunks/2-CXlrhpR6.js +0 -9
  352. package/build/server/chunks/3-CGT4Ugys.js +0 -13
  353. package/build/server/chunks/3-CGT4Ugys.js.map +0 -1
  354. package/build/server/chunks/4-BscEiwUk.js +0 -9
  355. package/build/server/chunks/4-BscEiwUk.js.map +0 -1
  356. package/build/server/chunks/5-H0ePIJBE.js +0 -9
  357. package/build/server/chunks/5-H0ePIJBE.js.map +0 -1
  358. package/build/server/chunks/6-BrPpcagX.js +0 -9
  359. package/build/server/chunks/6-BrPpcagX.js.map +0 -1
  360. package/build/server/chunks/FormDialog-CB-2YGWi.js.map +0 -1
  361. package/build/server/chunks/Logout-LKOt-AST.js +0 -45
  362. package/build/server/chunks/Logout-LKOt-AST.js.map +0 -1
  363. package/build/server/chunks/_page.svelte-B1LK5J87.js +0 -11
  364. package/build/server/chunks/_page.svelte-B1LK5J87.js.map +0 -1
  365. package/build/server/chunks/_page.svelte-CMtkwvbP.js +0 -68
  366. package/build/server/chunks/_page.svelte-CMtkwvbP.js.map +0 -1
  367. package/build/server/chunks/_page.svelte-CbI2KxeA.js +0 -62
  368. package/build/server/chunks/_page.svelte-CbI2KxeA.js.map +0 -1
  369. package/build/server/chunks/_page.svelte-D1_WJoyP.js +0 -6
  370. package/build/server/chunks/_page.svelte-D1_WJoyP.js.map +0 -1
  371. package/build/server/chunks/_page.svelte-d01Hl2Ia.js +0 -639
  372. package/build/server/chunks/_page.svelte-d01Hl2Ia.js.map +0 -1
  373. package/build/server/chunks/error.svelte-DNQXZmIO.js.map +0 -1
  374. package/build/server/chunks/hooks.server-CQhG9POo.js +0 -17298
  375. package/build/server/chunks/hooks.server-CQhG9POo.js.map +0 -1
  376. package/build/server/chunks/index-CvHf_GW2.js.map +0 -1
  377. package/build/server/chunks/index-RTKpMYZ1.js +0 -397
  378. package/build/server/chunks/index-RTKpMYZ1.js.map +0 -1
  379. package/build/server/chunks/layout.svelte-BSvrn-4a.js +0 -8
  380. package/build/server/chunks/layout.svelte-BSvrn-4a.js.map +0 -1
  381. package/build/server/chunks/string-DLbvtT1R.js.map +0 -1
  382. package/dist/apps.d.ts +0 -6
  383. package/dist/apps.js +0 -6
  384. package/dist/plugins.d.ts +0 -49
  385. package/dist/plugins.js +0 -80
  386. package/dist/sveltekit.d.ts +0 -8
  387. package/dist/sveltekit.js +0 -60
  388. package/web/hooks.server.ts +0 -4
  389. /package/{axiumd.service → axium.service} +0 -0
@@ -1,13 +1,15 @@
1
- import { r as render, L as LEGACY_PROPS, U as UNOWNED, E as ERROR_VALUE, C as COMMENT_NODE, H as HYDRATION_START, a as HYDRATION_ERROR, b as HYDRATION_END, S as STATE_SYMBOL, c as UNINITIALIZED, D as DERIVED, d as DIRTY, e as CLEAN, M as MAYBE_DIRTY, f as DISCONNECTED, g as DEV, I as INERT, h as EFFECT, A as ASYNC, B as BLOCK_EFFECT, i as is_passive_event, j as BRANCH_EFFECT, R as ROOT_EFFECT, k as DESTROYED, l as REACTION_IS_UPDATING, m as EFFECT_RAN, n as EFFECT_PRESERVED, o as HEAD_EFFECT, p as BOUNDARY_EFFECT, q as EFFECT_TRANSPARENT, s as INSPECT_EFFECT, t as STALE_REACTION, u as push$1, v as setContext, w as pop$1, x as USER_EFFECT } from './chunks/index-RTKpMYZ1.js';
2
1
  import { json, text, error } from '@sveltejs/kit';
3
2
  import { Redirect, SvelteKitError, HttpError, ActionFailure } from '@sveltejs/kit/internal';
4
3
  import { with_request_store, merge_tracing } from '@sveltejs/kit/internal/server';
5
4
  import { d as define_property, s as safe_equals, o as object_prototype, a as array_prototype, g as get_descriptor, i as is_extensible, b as array_from, e as equals, c as get_prototype_of, f as is_array, h as deferred, r as run_all, j as index_of, t as text_decoder, k as base64_decode, l as decode_pathname, m as decode_params, n as normalize_path, p as disable_search, v as validate_layout_server_exports, q as validate_layout_exports, u as validate_page_server_exports, w as validate_page_exports, x as text_encoder, y as resolve, z as make_trackable, A as get_relative_path, B as base64_encode, C as readable, D as writable } from './chunks/utils-h74ns7K6.js';
6
- import { parse as parse$1, serialize } from 'cookie';
5
+ import { r as render, L as LEGACY_PROPS, U as UNOWNED, E as ERROR_VALUE, C as COMMENT_NODE, H as HYDRATION_START, a as HYDRATION_ERROR, S as STATE_SYMBOL, b as UNINITIALIZED, D as DERIVED, c as DIRTY, d as CLEAN, M as MAYBE_DIRTY, e as DISCONNECTED, I as INERT, B as BOUNDARY_EFFECT, f as EFFECT, g as BLOCK_EFFECT, W as WAS_MARKED, i as is_passive_event, h as BRANCH_EFFECT, R as ROOT_EFFECT, j as DESTROYED, A as ASYNC, k as REACTION_IS_UPDATING, l as EFFECT_RAN, m as EFFECT_PRESERVED, n as EFFECT_TRANSPARENT, o as HEAD_EFFECT, p as EAGER_EFFECT, q as STALE_REACTION, s as HYDRATION_END, t as RENDER_EFFECT, u as HYDRATION_START_ELSE, v as USER_EFFECT } from './chunks/index-CIEcmmdN.js';
6
+ import { s as setContext } from './chunks/context-R2425nfV.js';
7
7
 
8
+ const DEV = false;
8
9
  let base = "";
9
10
  let assets = base;
10
11
  const app_dir = "_app";
12
+ const relative = true;
11
13
  const initial = { base, assets };
12
14
  function override(paths) {
13
15
  base = paths.base;
@@ -61,6 +63,7 @@ function is_plain_object(thing) {
61
63
  return (
62
64
  proto === Object.prototype ||
63
65
  proto === null ||
66
+ Object.getPrototypeOf(proto) === null ||
64
67
  Object.getOwnPropertyNames(proto).sort().join('\0') === object_proto_names
65
68
  );
66
69
  }
@@ -140,7 +143,7 @@ const reserved =
140
143
  /**
141
144
  * Turn a value into the JavaScript that creates an equivalent value
142
145
  * @param {any} value
143
- * @param {(value: any) => string | void} [replacer]
146
+ * @param {(value: any, uneval: (value: any) => string) => string | void} [replacer]
144
147
  */
145
148
  function uneval(value, replacer) {
146
149
  const counts = new Map();
@@ -165,7 +168,7 @@ function uneval(value, replacer) {
165
168
  counts.set(thing, 1);
166
169
 
167
170
  if (replacer) {
168
- const str = replacer(thing);
171
+ const str = replacer(thing, (value) => uneval(value, replacer));
169
172
 
170
173
  if (typeof str === 'string') {
171
174
  custom.set(thing, str);
@@ -182,6 +185,8 @@ function uneval(value, replacer) {
182
185
  case 'Boolean':
183
186
  case 'Date':
184
187
  case 'RegExp':
188
+ case 'URL':
189
+ case 'URLSearchParams':
185
190
  return;
186
191
 
187
192
  case 'Array':
@@ -205,21 +210,32 @@ function uneval(value, replacer) {
205
210
  keys.pop();
206
211
  }
207
212
  break;
208
-
209
- case "Int8Array":
210
- case "Uint8Array":
211
- case "Uint8ClampedArray":
212
- case "Int16Array":
213
- case "Uint16Array":
214
- case "Int32Array":
215
- case "Uint32Array":
216
- case "Float32Array":
217
- case "Float64Array":
218
- case "BigInt64Array":
219
- case "BigUint64Array":
213
+
214
+ case 'Int8Array':
215
+ case 'Uint8Array':
216
+ case 'Uint8ClampedArray':
217
+ case 'Int16Array':
218
+ case 'Uint16Array':
219
+ case 'Int32Array':
220
+ case 'Uint32Array':
221
+ case 'Float32Array':
222
+ case 'Float64Array':
223
+ case 'BigInt64Array':
224
+ case 'BigUint64Array':
225
+ walk(thing.buffer);
226
+ return;
227
+
228
+ case 'ArrayBuffer':
220
229
  return;
221
-
222
- case "ArrayBuffer":
230
+
231
+ case 'Temporal.Duration':
232
+ case 'Temporal.Instant':
233
+ case 'Temporal.PlainDate':
234
+ case 'Temporal.PlainTime':
235
+ case 'Temporal.PlainDateTime':
236
+ case 'Temporal.PlainMonthDay':
237
+ case 'Temporal.PlainYearMonth':
238
+ case 'Temporal.ZonedDateTime':
223
239
  return;
224
240
 
225
241
  default:
@@ -290,6 +306,12 @@ function uneval(value, replacer) {
290
306
  case 'Date':
291
307
  return `new Date(${thing.getTime()})`;
292
308
 
309
+ case 'URL':
310
+ return `new URL(${stringify_string(thing.toString())})`;
311
+
312
+ case 'URLSearchParams':
313
+ return `new URLSearchParams(${stringify_string(thing.toString())})`;
314
+
293
315
  case 'Array':
294
316
  const members = /** @type {any[]} */ (thing).map((v, i) =>
295
317
  i in thing ? stringify(v) : ''
@@ -300,40 +322,67 @@ function uneval(value, replacer) {
300
322
  case 'Set':
301
323
  case 'Map':
302
324
  return `new ${type}([${Array.from(thing).map(stringify).join(',')}])`;
303
-
304
- case "Int8Array":
305
- case "Uint8Array":
306
- case "Uint8ClampedArray":
307
- case "Int16Array":
308
- case "Uint16Array":
309
- case "Int32Array":
310
- case "Uint32Array":
311
- case "Float32Array":
312
- case "Float64Array":
313
- case "BigInt64Array":
314
- case "BigUint64Array": {
315
- /** @type {import("./types.js").TypedArray} */
316
- const typedArray = thing;
317
- return `new ${type}([${typedArray.toString()}])`;
325
+
326
+ case 'Int8Array':
327
+ case 'Uint8Array':
328
+ case 'Uint8ClampedArray':
329
+ case 'Int16Array':
330
+ case 'Uint16Array':
331
+ case 'Int32Array':
332
+ case 'Uint32Array':
333
+ case 'Float32Array':
334
+ case 'Float64Array':
335
+ case 'BigInt64Array':
336
+ case 'BigUint64Array': {
337
+ let str = `new ${type}`;
338
+
339
+ if (counts.get(thing.buffer) === 1) {
340
+ const array = new thing.constructor(thing.buffer);
341
+ str += `([${array}])`;
342
+ } else {
343
+ str += `([${stringify(thing.buffer)}])`;
344
+ }
345
+
346
+ const a = thing.byteOffset;
347
+ const b = a + thing.byteLength;
348
+
349
+ // handle subarrays
350
+ if (a > 0 || b !== thing.buffer.byteLength) {
351
+ const m = +/(\d+)/.exec(type)[1] / 8;
352
+ str += `.subarray(${a / m},${b / m})`;
353
+ }
354
+
355
+ return str;
318
356
  }
319
-
320
- case "ArrayBuffer": {
357
+
358
+ case 'ArrayBuffer': {
321
359
  const ui8 = new Uint8Array(thing);
322
360
  return `new Uint8Array([${ui8.toString()}]).buffer`;
323
361
  }
324
362
 
363
+ case 'Temporal.Duration':
364
+ case 'Temporal.Instant':
365
+ case 'Temporal.PlainDate':
366
+ case 'Temporal.PlainTime':
367
+ case 'Temporal.PlainDateTime':
368
+ case 'Temporal.PlainMonthDay':
369
+ case 'Temporal.PlainYearMonth':
370
+ case 'Temporal.ZonedDateTime':
371
+ return `${type}.from(${stringify_string(thing.toString())})`;
372
+
325
373
  default:
326
- const obj = `{${Object.keys(thing)
374
+ const keys = Object.keys(thing);
375
+ const obj = keys
327
376
  .map((key) => `${safe_key(key)}:${stringify(thing[key])}`)
328
- .join(',')}}`;
377
+ .join(',');
329
378
  const proto = Object.getPrototypeOf(thing);
330
379
  if (proto === null) {
331
- return Object.keys(thing).length > 0
332
- ? `Object.assign(Object.create(null),${obj})`
333
- : `Object.create(null)`;
380
+ return keys.length > 0
381
+ ? `{${obj},__proto__:null}`
382
+ : `{__proto__:null}`;
334
383
  }
335
384
 
336
- return obj;
385
+ return `{${obj}}`;
337
386
  }
338
387
  }
339
388
 
@@ -404,6 +453,12 @@ function uneval(value, replacer) {
404
453
  );
405
454
  break;
406
455
 
456
+ case 'ArrayBuffer':
457
+ values.push(
458
+ `new Uint8Array([${new Uint8Array(thing).join(',')}]).buffer`
459
+ );
460
+ break;
461
+
407
462
  default:
408
463
  values.push(
409
464
  Object.getPrototypeOf(thing) === null ? 'Object.create(null)' : '{}'
@@ -627,7 +682,9 @@ function unflatten(parsed, revivers) {
627
682
  if (index === NEGATIVE_INFINITY) return -Infinity;
628
683
  if (index === NEGATIVE_ZERO) return -0;
629
684
 
630
- if (standalone) throw new Error(`Invalid input`);
685
+ if (standalone || typeof index !== 'number') {
686
+ throw new Error(`Invalid input`);
687
+ }
631
688
 
632
689
  if (index in hydrated) return hydrated[index];
633
690
 
@@ -641,7 +698,13 @@ function unflatten(parsed, revivers) {
641
698
 
642
699
  const reviver = revivers?.[type];
643
700
  if (reviver) {
644
- return (hydrated[index] = reviver(hydrate(value[1])));
701
+ let i = value[1];
702
+ if (typeof i !== 'number') {
703
+ // if it's not a number, it was serialized by a builtin reviver
704
+ // so we need to munge it into the format expected by a custom reviver
705
+ i = values.push(value[1]) - 1;
706
+ }
707
+ return (hydrated[index] = reviver(hydrate(i)));
645
708
  }
646
709
 
647
710
  switch (type) {
@@ -685,31 +748,60 @@ function unflatten(parsed, revivers) {
685
748
  }
686
749
  break;
687
750
 
688
- case "Int8Array":
689
- case "Uint8Array":
690
- case "Uint8ClampedArray":
691
- case "Int16Array":
692
- case "Uint16Array":
693
- case "Int32Array":
694
- case "Uint32Array":
695
- case "Float32Array":
696
- case "Float64Array":
697
- case "BigInt64Array":
698
- case "BigUint64Array": {
699
- const TypedArrayConstructor = globalThis[type];
700
- const base64 = value[1];
701
- const arraybuffer = decode64(base64);
702
- const typedArray = new TypedArrayConstructor(arraybuffer);
703
- hydrated[index] = typedArray;
704
- break;
705
- }
751
+ case 'Int8Array':
752
+ case 'Uint8Array':
753
+ case 'Uint8ClampedArray':
754
+ case 'Int16Array':
755
+ case 'Uint16Array':
756
+ case 'Int32Array':
757
+ case 'Uint32Array':
758
+ case 'Float32Array':
759
+ case 'Float64Array':
760
+ case 'BigInt64Array':
761
+ case 'BigUint64Array': {
762
+ const TypedArrayConstructor = globalThis[type];
763
+ const typedArray = new TypedArrayConstructor(hydrate(value[1]));
764
+
765
+ hydrated[index] =
766
+ value[2] !== undefined
767
+ ? typedArray.subarray(value[2], value[3])
768
+ : typedArray;
706
769
 
707
- case "ArrayBuffer": {
708
- const base64 = value[1];
709
- const arraybuffer = decode64(base64);
710
- hydrated[index] = arraybuffer;
711
- break;
712
- }
770
+ break;
771
+ }
772
+
773
+ case 'ArrayBuffer': {
774
+ const base64 = value[1];
775
+ const arraybuffer = decode64(base64);
776
+ hydrated[index] = arraybuffer;
777
+ break;
778
+ }
779
+
780
+ case 'Temporal.Duration':
781
+ case 'Temporal.Instant':
782
+ case 'Temporal.PlainDate':
783
+ case 'Temporal.PlainTime':
784
+ case 'Temporal.PlainDateTime':
785
+ case 'Temporal.PlainMonthDay':
786
+ case 'Temporal.PlainYearMonth':
787
+ case 'Temporal.ZonedDateTime': {
788
+ const temporalName = type.slice(9);
789
+ // @ts-expect-error TS doesn't know about Temporal yet
790
+ hydrated[index] = Temporal[temporalName].from(value[1]);
791
+ break;
792
+ }
793
+
794
+ case 'URL': {
795
+ const url = new URL(value[1]);
796
+ hydrated[index] = url;
797
+ break;
798
+ }
799
+
800
+ case 'URLSearchParams': {
801
+ const url = new URLSearchParams(value[1]);
802
+ hydrated[index] = url;
803
+ break;
804
+ }
713
805
 
714
806
  default:
715
807
  throw new Error(`Unknown type ${type}`);
@@ -731,6 +823,10 @@ function unflatten(parsed, revivers) {
731
823
  hydrated[index] = object;
732
824
 
733
825
  for (const key in value) {
826
+ if (key === '__proto__') {
827
+ throw new Error('Cannot parse an object with a `__proto__` property');
828
+ }
829
+
734
830
  const n = value[key];
735
831
  object[key] = hydrate(n);
736
832
  }
@@ -773,14 +869,14 @@ function stringify$1(value, reducers) {
773
869
  throw new DevalueError(`Cannot stringify a function`, keys);
774
870
  }
775
871
 
776
- if (indexes.has(thing)) return indexes.get(thing);
777
-
778
872
  if (thing === undefined) return UNDEFINED;
779
873
  if (Number.isNaN(thing)) return NAN;
780
874
  if (thing === Infinity) return POSITIVE_INFINITY;
781
875
  if (thing === -Infinity) return NEGATIVE_INFINITY;
782
876
  if (thing === 0 && 1 / thing < 0) return NEGATIVE_ZERO;
783
877
 
878
+ if (indexes.has(thing)) return indexes.get(thing);
879
+
784
880
  const index = p++;
785
881
  indexes.set(thing, index);
786
882
 
@@ -815,6 +911,14 @@ function stringify$1(value, reducers) {
815
911
  str = `["Date","${valid ? thing.toISOString() : ''}"]`;
816
912
  break;
817
913
 
914
+ case 'URL':
915
+ str = `["URL",${stringify_string(thing.toString())}]`;
916
+ break;
917
+
918
+ case 'URLSearchParams':
919
+ str = `["URLSearchParams",${stringify_string(thing.toString())}]`;
920
+ break;
921
+
818
922
  case 'RegExp':
819
923
  const { source, flags } = thing;
820
924
  str = flags
@@ -865,33 +969,54 @@ function stringify$1(value, reducers) {
865
969
  str += ']';
866
970
  break;
867
971
 
868
- case "Int8Array":
869
- case "Uint8Array":
870
- case "Uint8ClampedArray":
871
- case "Int16Array":
872
- case "Uint16Array":
873
- case "Int32Array":
874
- case "Uint32Array":
875
- case "Float32Array":
876
- case "Float64Array":
877
- case "BigInt64Array":
878
- case "BigUint64Array": {
972
+ case 'Int8Array':
973
+ case 'Uint8Array':
974
+ case 'Uint8ClampedArray':
975
+ case 'Int16Array':
976
+ case 'Uint16Array':
977
+ case 'Int32Array':
978
+ case 'Uint32Array':
979
+ case 'Float32Array':
980
+ case 'Float64Array':
981
+ case 'BigInt64Array':
982
+ case 'BigUint64Array': {
879
983
  /** @type {import("./types.js").TypedArray} */
880
984
  const typedArray = thing;
881
- const base64 = encode64(typedArray.buffer);
882
- str = '["' + type + '","' + base64 + '"]';
985
+ str = '["' + type + '",' + flatten(typedArray.buffer);
986
+
987
+ const a = thing.byteOffset;
988
+ const b = a + thing.byteLength;
989
+
990
+ // handle subarrays
991
+ if (a > 0 || b !== typedArray.buffer.byteLength) {
992
+ const m = +/(\d+)/.exec(type)[1] / 8;
993
+ str += `,${a / m},${b / m}`;
994
+ }
995
+
996
+ str += ']';
883
997
  break;
884
998
  }
885
-
886
- case "ArrayBuffer": {
999
+
1000
+ case 'ArrayBuffer': {
887
1001
  /** @type {ArrayBuffer} */
888
1002
  const arraybuffer = thing;
889
1003
  const base64 = encode64(arraybuffer);
890
-
1004
+
891
1005
  str = `["ArrayBuffer","${base64}"]`;
892
1006
  break;
893
1007
  }
894
-
1008
+
1009
+ case 'Temporal.Duration':
1010
+ case 'Temporal.Instant':
1011
+ case 'Temporal.PlainDate':
1012
+ case 'Temporal.PlainTime':
1013
+ case 'Temporal.PlainDateTime':
1014
+ case 'Temporal.PlainMonthDay':
1015
+ case 'Temporal.PlainYearMonth':
1016
+ case 'Temporal.ZonedDateTime':
1017
+ str = `["${type}",${stringify_string(thing.toString())}]`;
1018
+ break;
1019
+
895
1020
  default:
896
1021
  if (!is_plain_object(thing)) {
897
1022
  throw new DevalueError(
@@ -957,13 +1082,11 @@ function stringify_primitive(thing) {
957
1082
  }
958
1083
 
959
1084
  let public_env = {};
960
- let safe_public_env = {};
1085
+ function set_private_env(environment) {
1086
+ }
961
1087
  function set_public_env(environment) {
962
1088
  public_env = environment;
963
1089
  }
964
- function set_safe_public_env(environment) {
965
- safe_public_env = environment;
966
- }
967
1090
  function effect_update_depth_exceeded() {
968
1091
  {
969
1092
  throw new Error(`https://svelte.dev/e/effect_update_depth_exceeded`);
@@ -989,11 +1112,21 @@ function state_unsafe_mutation() {
989
1112
  throw new Error(`https://svelte.dev/e/state_unsafe_mutation`);
990
1113
  }
991
1114
  }
1115
+ function svelte_boundary_reset_onerror() {
1116
+ {
1117
+ throw new Error(`https://svelte.dev/e/svelte_boundary_reset_onerror`);
1118
+ }
1119
+ }
992
1120
  function hydration_mismatch(location) {
993
1121
  {
994
1122
  console.warn(`https://svelte.dev/e/hydration_mismatch`);
995
1123
  }
996
1124
  }
1125
+ function svelte_boundary_reset_noop() {
1126
+ {
1127
+ console.warn(`https://svelte.dev/e/svelte_boundary_reset_noop`);
1128
+ }
1129
+ }
997
1130
  let hydrating = false;
998
1131
  function set_hydrating(value) {
999
1132
  hydrating = value;
@@ -1012,6 +1145,41 @@ function hydrate_next() {
1012
1145
  /* @__PURE__ */ get_next_sibling(hydrate_node)
1013
1146
  );
1014
1147
  }
1148
+ function next(count = 1) {
1149
+ if (hydrating) {
1150
+ var i = count;
1151
+ var node = hydrate_node;
1152
+ while (i--) {
1153
+ node = /** @type {TemplateNode} */
1154
+ /* @__PURE__ */ get_next_sibling(node);
1155
+ }
1156
+ hydrate_node = node;
1157
+ }
1158
+ }
1159
+ function skip_nodes(remove = true) {
1160
+ var depth = 0;
1161
+ var node = hydrate_node;
1162
+ while (true) {
1163
+ if (node.nodeType === COMMENT_NODE) {
1164
+ var data = (
1165
+ /** @type {Comment} */
1166
+ node.data
1167
+ );
1168
+ if (data === HYDRATION_END) {
1169
+ if (depth === 0) return node;
1170
+ depth -= 1;
1171
+ } else if (data === HYDRATION_START || data === HYDRATION_START_ELSE) {
1172
+ depth += 1;
1173
+ }
1174
+ }
1175
+ var next2 = (
1176
+ /** @type {TemplateNode} */
1177
+ /* @__PURE__ */ get_next_sibling(node)
1178
+ );
1179
+ if (remove) node.remove();
1180
+ node = next2;
1181
+ }
1182
+ }
1015
1183
  let tracing_mode_flag = false;
1016
1184
  let component_context = null;
1017
1185
  function set_component_context(context) {
@@ -1020,6 +1188,7 @@ function set_component_context(context) {
1020
1188
  function push(props, runes = false, fn) {
1021
1189
  component_context = {
1022
1190
  p: component_context,
1191
+ i: false,
1023
1192
  c: null,
1024
1193
  e: null,
1025
1194
  s: props,
@@ -1039,6 +1208,7 @@ function pop(component) {
1039
1208
  create_user_effect(fn);
1040
1209
  }
1041
1210
  }
1211
+ context.i = true;
1042
1212
  component_context = context.p;
1043
1213
  return (
1044
1214
  /** @type {T} */
@@ -1048,7 +1218,26 @@ function pop(component) {
1048
1218
  function is_runes() {
1049
1219
  return true;
1050
1220
  }
1051
- const adjustments = /* @__PURE__ */ new WeakMap();
1221
+ let micro_tasks = [];
1222
+ function run_micro_tasks() {
1223
+ var tasks = micro_tasks;
1224
+ micro_tasks = [];
1225
+ run_all(tasks);
1226
+ }
1227
+ function queue_micro_task(fn) {
1228
+ if (micro_tasks.length === 0 && !is_flushing_sync) {
1229
+ var tasks = micro_tasks;
1230
+ queueMicrotask(() => {
1231
+ if (tasks === micro_tasks) run_micro_tasks();
1232
+ });
1233
+ }
1234
+ micro_tasks.push(fn);
1235
+ }
1236
+ function flush_tasks() {
1237
+ while (micro_tasks.length > 0) {
1238
+ run_micro_tasks();
1239
+ }
1240
+ }
1052
1241
  function handle_error(error) {
1053
1242
  var effect = active_effect;
1054
1243
  if (effect === null) {
@@ -1057,9 +1246,6 @@ function handle_error(error) {
1057
1246
  }
1058
1247
  if ((effect.f & EFFECT_RAN) === 0) {
1059
1248
  if ((effect.f & BOUNDARY_EFFECT) === 0) {
1060
- if (!effect.parent && error instanceof Error) {
1061
- apply_adjustments(error);
1062
- }
1063
1249
  throw error;
1064
1250
  }
1065
1251
  effect.b.error(error);
@@ -1079,117 +1265,17 @@ function invoke_error_boundary(error, effect) {
1079
1265
  }
1080
1266
  effect = effect.parent;
1081
1267
  }
1082
- if (error instanceof Error) {
1083
- apply_adjustments(error);
1084
- }
1085
1268
  throw error;
1086
1269
  }
1087
- function apply_adjustments(error) {
1088
- const adjusted = adjustments.get(error);
1089
- if (adjusted) {
1090
- define_property(error, "message", {
1091
- value: adjusted.message
1092
- });
1093
- define_property(error, "stack", {
1094
- value: adjusted.stack
1095
- });
1096
- }
1097
- }
1098
- let micro_tasks = [];
1099
- let idle_tasks = [];
1100
- function run_micro_tasks() {
1101
- var tasks2 = micro_tasks;
1102
- micro_tasks = [];
1103
- run_all(tasks2);
1104
- }
1105
- function run_idle_tasks() {
1106
- var tasks2 = idle_tasks;
1107
- idle_tasks = [];
1108
- run_all(tasks2);
1109
- }
1110
- function flush_tasks() {
1111
- if (micro_tasks.length > 0) {
1112
- run_micro_tasks();
1113
- }
1114
- if (idle_tasks.length > 0) {
1115
- run_idle_tasks();
1116
- }
1117
- }
1118
- function destroy_derived_effects(derived) {
1119
- var effects = derived.effects;
1120
- if (effects !== null) {
1121
- derived.effects = null;
1122
- for (var i = 0; i < effects.length; i += 1) {
1123
- destroy_effect(
1124
- /** @type {Effect} */
1125
- effects[i]
1126
- );
1127
- }
1128
- }
1129
- }
1130
- function get_derived_parent_effect(derived) {
1131
- var parent = derived.parent;
1132
- while (parent !== null) {
1133
- if ((parent.f & DERIVED) === 0) {
1134
- return (
1135
- /** @type {Effect} */
1136
- parent
1137
- );
1138
- }
1139
- parent = parent.parent;
1140
- }
1141
- return null;
1142
- }
1143
- function execute_derived(derived) {
1144
- var value;
1145
- var prev_active_effect = active_effect;
1146
- set_active_effect(get_derived_parent_effect(derived));
1147
- {
1148
- try {
1149
- destroy_derived_effects(derived);
1150
- value = update_reaction(derived);
1151
- } finally {
1152
- set_active_effect(prev_active_effect);
1153
- }
1154
- }
1155
- return value;
1156
- }
1157
- function update_derived(derived) {
1158
- var value = execute_derived(derived);
1159
- if (!derived.equals(value)) {
1160
- derived.v = value;
1161
- derived.wv = increment_write_version();
1162
- }
1163
- if (is_destroying_effect) {
1164
- return;
1165
- }
1166
- if (batch_deriveds !== null) {
1167
- batch_deriveds.set(derived, derived.v);
1168
- } else {
1169
- var status = (skip_reaction || (derived.f & UNOWNED) !== 0) && derived.deps !== null ? MAYBE_DIRTY : CLEAN;
1170
- set_signal_status(derived, status);
1171
- }
1172
- }
1173
1270
  const batches = /* @__PURE__ */ new Set();
1174
1271
  let current_batch = null;
1175
- let batch_deriveds = null;
1176
- let effect_pending_updates = /* @__PURE__ */ new Set();
1177
- let tasks = [];
1178
- function dequeue() {
1179
- const task = (
1180
- /** @type {() => void} */
1181
- tasks.shift()
1182
- );
1183
- if (tasks.length > 0) {
1184
- queueMicrotask(dequeue);
1185
- }
1186
- task();
1187
- }
1272
+ let batch_values = null;
1188
1273
  let queued_root_effects = [];
1189
1274
  let last_scheduled_effect = null;
1190
1275
  let is_flushing = false;
1191
1276
  let is_flushing_sync = false;
1192
1277
  class Batch {
1278
+ committed = false;
1193
1279
  /**
1194
1280
  * The current values of any sources that are updated in this batch
1195
1281
  * They keys of this map are identical to `this.#previous`
@@ -1201,58 +1287,32 @@ class Batch {
1201
1287
  * They keys of this map are identical to `this.#current`
1202
1288
  * @type {Map<Source, any>}
1203
1289
  */
1204
- #previous = /* @__PURE__ */ new Map();
1290
+ previous = /* @__PURE__ */ new Map();
1205
1291
  /**
1206
1292
  * When the batch is committed (and the DOM is updated), we need to remove old branches
1207
1293
  * and append new ones by calling the functions added inside (if/each/key/etc) blocks
1208
1294
  * @type {Set<() => void>}
1209
1295
  */
1210
- #callbacks = /* @__PURE__ */ new Set();
1296
+ #commit_callbacks = /* @__PURE__ */ new Set();
1297
+ /**
1298
+ * If a fork is discarded, we need to destroy any effects that are no longer needed
1299
+ * @type {Set<(batch: Batch) => void>}
1300
+ */
1301
+ #discard_callbacks = /* @__PURE__ */ new Set();
1211
1302
  /**
1212
1303
  * The number of async effects that are currently in flight
1213
1304
  */
1214
1305
  #pending = 0;
1306
+ /**
1307
+ * The number of async effects that are currently in flight, _not_ inside a pending boundary
1308
+ */
1309
+ #blocking_pending = 0;
1215
1310
  /**
1216
1311
  * A deferred that resolves when the batch is committed, used with `settled()`
1217
1312
  * TODO replace with Promise.withResolvers once supported widely enough
1218
1313
  * @type {{ promise: Promise<void>, resolve: (value?: any) => void, reject: (reason: unknown) => void } | null}
1219
1314
  */
1220
1315
  #deferred = null;
1221
- /**
1222
- * True if an async effect inside this batch resolved and
1223
- * its parent branch was already deleted
1224
- */
1225
- #neutered = false;
1226
- /**
1227
- * Async effects (created inside `async_derived`) encountered during processing.
1228
- * These run after the rest of the batch has updated, since they should
1229
- * always have the latest values
1230
- * @type {Effect[]}
1231
- */
1232
- #async_effects = [];
1233
- /**
1234
- * The same as `#async_effects`, but for effects inside a newly-created
1235
- * `<svelte:boundary>` — these do not prevent the batch from committing
1236
- * @type {Effect[]}
1237
- */
1238
- #boundary_async_effects = [];
1239
- /**
1240
- * Template effects and `$effect.pre` effects, which run when
1241
- * a batch is committed
1242
- * @type {Effect[]}
1243
- */
1244
- #render_effects = [];
1245
- /**
1246
- * The same as `#render_effects`, but for `$effect` (which runs after)
1247
- * @type {Effect[]}
1248
- */
1249
- #effects = [];
1250
- /**
1251
- * Block effects, which may need to re-run on subsequent flushes
1252
- * in order to update internal sources (e.g. each block items)
1253
- * @type {Effect[]}
1254
- */
1255
- #block_effects = [];
1256
1316
  /**
1257
1317
  * Deferred effects (which run after async work has completed) that are DIRTY
1258
1318
  * @type {Effect[]}
@@ -1269,97 +1329,70 @@ class Batch {
1269
1329
  * @type {Set<Effect>}
1270
1330
  */
1271
1331
  skipped_effects = /* @__PURE__ */ new Set();
1332
+ is_fork = false;
1272
1333
  /**
1273
1334
  *
1274
1335
  * @param {Effect[]} root_effects
1275
1336
  */
1276
1337
  process(root_effects) {
1277
1338
  queued_root_effects = [];
1278
- var current_values = null;
1279
- if (batches.size > 1) {
1280
- current_values = /* @__PURE__ */ new Map();
1281
- batch_deriveds = /* @__PURE__ */ new Map();
1282
- for (const [source2, current] of this.current) {
1283
- current_values.set(source2, { v: source2.v, wv: source2.wv });
1284
- source2.v = current;
1285
- }
1286
- for (const batch of batches) {
1287
- if (batch === this) continue;
1288
- for (const [source2, previous] of batch.#previous) {
1289
- if (!current_values.has(source2)) {
1290
- current_values.set(source2, { v: source2.v, wv: source2.wv });
1291
- source2.v = previous;
1292
- }
1293
- }
1294
- }
1295
- }
1339
+ this.apply();
1340
+ var target = {
1341
+ parent: null,
1342
+ effect: null,
1343
+ effects: [],
1344
+ render_effects: [],
1345
+ block_effects: []
1346
+ };
1296
1347
  for (const root2 of root_effects) {
1297
- this.#traverse_effect_tree(root2);
1348
+ this.#traverse_effect_tree(root2, target);
1298
1349
  }
1299
- if (this.#async_effects.length === 0 && this.#pending === 0) {
1300
- this.#commit();
1301
- var render_effects = this.#render_effects;
1302
- var effects = this.#effects;
1303
- this.#render_effects = [];
1304
- this.#effects = [];
1305
- this.#block_effects = [];
1350
+ if (!this.is_fork) {
1351
+ this.#resolve();
1352
+ }
1353
+ if (this.#blocking_pending > 0 || this.is_fork) {
1354
+ this.#defer_effects(target.effects);
1355
+ this.#defer_effects(target.render_effects);
1356
+ this.#defer_effects(target.block_effects);
1357
+ } else {
1306
1358
  current_batch = null;
1307
- flush_queued_effects(render_effects);
1308
- flush_queued_effects(effects);
1309
- if (current_batch === null) {
1310
- current_batch = this;
1311
- } else {
1312
- batches.delete(this);
1313
- }
1359
+ flush_queued_effects(target.render_effects);
1360
+ flush_queued_effects(target.effects);
1314
1361
  this.#deferred?.resolve();
1315
- } else {
1316
- this.#defer_effects(this.#render_effects);
1317
- this.#defer_effects(this.#effects);
1318
- this.#defer_effects(this.#block_effects);
1319
- }
1320
- if (current_values) {
1321
- for (const [source2, { v, wv }] of current_values) {
1322
- if (source2.wv <= wv) {
1323
- source2.v = v;
1324
- }
1325
- }
1326
- batch_deriveds = null;
1327
- }
1328
- for (const effect of this.#async_effects) {
1329
- update_effect(effect);
1330
- }
1331
- for (const effect of this.#boundary_async_effects) {
1332
- update_effect(effect);
1333
1362
  }
1334
- this.#async_effects = [];
1335
- this.#boundary_async_effects = [];
1363
+ batch_values = null;
1336
1364
  }
1337
1365
  /**
1338
1366
  * Traverse the effect tree, executing effects or stashing
1339
1367
  * them for later execution as appropriate
1340
1368
  * @param {Effect} root
1369
+ * @param {EffectTarget} target
1341
1370
  */
1342
- #traverse_effect_tree(root2) {
1371
+ #traverse_effect_tree(root2, target) {
1343
1372
  root2.f ^= CLEAN;
1344
1373
  var effect = root2.first;
1345
1374
  while (effect !== null) {
1346
- var flags = effect.f;
1347
- var is_branch = (flags & (BRANCH_EFFECT | ROOT_EFFECT)) !== 0;
1348
- var is_skippable_branch = is_branch && (flags & CLEAN) !== 0;
1349
- var skip = is_skippable_branch || (flags & INERT) !== 0 || this.skipped_effects.has(effect);
1375
+ var flags2 = effect.f;
1376
+ var is_branch = (flags2 & (BRANCH_EFFECT | ROOT_EFFECT)) !== 0;
1377
+ var is_skippable_branch = is_branch && (flags2 & CLEAN) !== 0;
1378
+ var skip = is_skippable_branch || (flags2 & INERT) !== 0 || this.skipped_effects.has(effect);
1379
+ if ((effect.f & BOUNDARY_EFFECT) !== 0 && effect.b?.is_pending()) {
1380
+ target = {
1381
+ parent: target,
1382
+ effect,
1383
+ effects: [],
1384
+ render_effects: [],
1385
+ block_effects: []
1386
+ };
1387
+ }
1350
1388
  if (!skip && effect.fn !== null) {
1351
1389
  if (is_branch) {
1352
1390
  effect.f ^= CLEAN;
1353
- } else if ((flags & EFFECT) !== 0) {
1354
- this.#effects.push(effect);
1355
- } else if ((flags & CLEAN) === 0) {
1356
- if ((flags & ASYNC) !== 0) {
1357
- var effects = effect.b?.pending ? this.#boundary_async_effects : this.#async_effects;
1358
- effects.push(effect);
1359
- } else if (is_dirty(effect)) {
1360
- if ((effect.f & BLOCK_EFFECT) !== 0) this.#block_effects.push(effect);
1361
- update_effect(effect);
1362
- }
1391
+ } else if ((flags2 & EFFECT) !== 0) {
1392
+ target.effects.push(effect);
1393
+ } else if (is_dirty(effect)) {
1394
+ if ((effect.f & BLOCK_EFFECT) !== 0) target.block_effects.push(effect);
1395
+ update_effect(effect);
1363
1396
  }
1364
1397
  var child = effect.first;
1365
1398
  if (child !== null) {
@@ -1370,6 +1403,13 @@ class Batch {
1370
1403
  var parent = effect.parent;
1371
1404
  effect = effect.next;
1372
1405
  while (effect === null && parent !== null) {
1406
+ if (parent === target.effect) {
1407
+ this.#defer_effects(target.effects);
1408
+ this.#defer_effects(target.render_effects);
1409
+ this.#defer_effects(target.block_effects);
1410
+ target = /** @type {EffectTarget} */
1411
+ target.parent;
1412
+ }
1373
1413
  effect = parent.next;
1374
1414
  parent = parent.parent;
1375
1415
  }
@@ -1384,7 +1424,6 @@ class Batch {
1384
1424
  target.push(e);
1385
1425
  set_signal_status(e, CLEAN);
1386
1426
  }
1387
- effects.length = 0;
1388
1427
  }
1389
1428
  /**
1390
1429
  * Associate a change to a given source with the current
@@ -1393,76 +1432,136 @@ class Batch {
1393
1432
  * @param {any} value
1394
1433
  */
1395
1434
  capture(source2, value) {
1396
- if (!this.#previous.has(source2)) {
1397
- this.#previous.set(source2, value);
1435
+ if (!this.previous.has(source2)) {
1436
+ this.previous.set(source2, value);
1398
1437
  }
1399
1438
  this.current.set(source2, source2.v);
1439
+ batch_values?.set(source2, source2.v);
1400
1440
  }
1401
1441
  activate() {
1402
1442
  current_batch = this;
1403
1443
  }
1404
1444
  deactivate() {
1405
1445
  current_batch = null;
1406
- for (const update of effect_pending_updates) {
1407
- effect_pending_updates.delete(update);
1408
- update();
1409
- if (current_batch !== null) {
1410
- break;
1411
- }
1412
- }
1413
- }
1414
- neuter() {
1415
- this.#neutered = true;
1446
+ batch_values = null;
1416
1447
  }
1417
1448
  flush() {
1449
+ this.activate();
1418
1450
  if (queued_root_effects.length > 0) {
1419
1451
  flush_effects();
1420
- } else {
1421
- this.#commit();
1452
+ if (current_batch !== null && current_batch !== this) {
1453
+ return;
1454
+ }
1455
+ } else if (this.#pending === 0) {
1456
+ this.process([]);
1422
1457
  }
1423
- if (current_batch !== this) {
1424
- return;
1458
+ this.deactivate();
1459
+ }
1460
+ discard() {
1461
+ for (const fn of this.#discard_callbacks) fn(this);
1462
+ this.#discard_callbacks.clear();
1463
+ }
1464
+ #resolve() {
1465
+ if (this.#blocking_pending === 0) {
1466
+ for (const fn of this.#commit_callbacks) fn();
1467
+ this.#commit_callbacks.clear();
1425
1468
  }
1426
1469
  if (this.#pending === 0) {
1427
- batches.delete(this);
1470
+ this.#commit();
1428
1471
  }
1429
- this.deactivate();
1430
1472
  }
1431
- /**
1432
- * Append and remove branches to/from the DOM
1433
- */
1434
1473
  #commit() {
1435
- if (!this.#neutered) {
1436
- for (const fn of this.#callbacks) {
1437
- fn();
1474
+ if (batches.size > 1) {
1475
+ this.previous.clear();
1476
+ var previous_batch_values = batch_values;
1477
+ var is_earlier = true;
1478
+ var dummy_target = {
1479
+ parent: null,
1480
+ effect: null,
1481
+ effects: [],
1482
+ render_effects: [],
1483
+ block_effects: []
1484
+ };
1485
+ for (const batch of batches) {
1486
+ if (batch === this) {
1487
+ is_earlier = false;
1488
+ continue;
1489
+ }
1490
+ const sources = [];
1491
+ for (const [source2, value] of this.current) {
1492
+ if (batch.current.has(source2)) {
1493
+ if (is_earlier && value !== batch.current.get(source2)) {
1494
+ batch.current.set(source2, value);
1495
+ } else {
1496
+ continue;
1497
+ }
1498
+ }
1499
+ sources.push(source2);
1500
+ }
1501
+ if (sources.length === 0) {
1502
+ continue;
1503
+ }
1504
+ const others = [...batch.current.keys()].filter((s) => !this.current.has(s));
1505
+ if (others.length > 0) {
1506
+ const marked = /* @__PURE__ */ new Set();
1507
+ const checked = /* @__PURE__ */ new Map();
1508
+ for (const source2 of sources) {
1509
+ mark_effects(source2, others, marked, checked);
1510
+ }
1511
+ if (queued_root_effects.length > 0) {
1512
+ current_batch = batch;
1513
+ batch.apply();
1514
+ for (const root2 of queued_root_effects) {
1515
+ batch.#traverse_effect_tree(root2, dummy_target);
1516
+ }
1517
+ queued_root_effects = [];
1518
+ batch.deactivate();
1519
+ }
1520
+ }
1438
1521
  }
1522
+ current_batch = null;
1523
+ batch_values = previous_batch_values;
1439
1524
  }
1440
- this.#callbacks.clear();
1525
+ this.committed = true;
1526
+ batches.delete(this);
1441
1527
  }
1442
- increment() {
1528
+ /**
1529
+ *
1530
+ * @param {boolean} blocking
1531
+ */
1532
+ increment(blocking) {
1443
1533
  this.#pending += 1;
1534
+ if (blocking) this.#blocking_pending += 1;
1444
1535
  }
1445
- decrement() {
1536
+ /**
1537
+ *
1538
+ * @param {boolean} blocking
1539
+ */
1540
+ decrement(blocking) {
1446
1541
  this.#pending -= 1;
1447
- if (this.#pending === 0) {
1448
- for (const e of this.#dirty_effects) {
1449
- set_signal_status(e, DIRTY);
1450
- schedule_effect(e);
1451
- }
1452
- for (const e of this.#maybe_dirty_effects) {
1453
- set_signal_status(e, MAYBE_DIRTY);
1454
- schedule_effect(e);
1455
- }
1456
- this.#render_effects = [];
1457
- this.#effects = [];
1458
- this.flush();
1459
- } else {
1460
- this.deactivate();
1542
+ if (blocking) this.#blocking_pending -= 1;
1543
+ this.revive();
1544
+ }
1545
+ revive() {
1546
+ for (const e of this.#dirty_effects) {
1547
+ set_signal_status(e, DIRTY);
1548
+ schedule_effect(e);
1549
+ }
1550
+ for (const e of this.#maybe_dirty_effects) {
1551
+ set_signal_status(e, MAYBE_DIRTY);
1552
+ schedule_effect(e);
1461
1553
  }
1554
+ this.#dirty_effects = [];
1555
+ this.#maybe_dirty_effects = [];
1556
+ this.flush();
1462
1557
  }
1463
1558
  /** @param {() => void} fn */
1464
- add_callback(fn) {
1465
- this.#callbacks.add(fn);
1559
+ oncommit(fn) {
1560
+ this.#commit_callbacks.add(fn);
1561
+ }
1562
+ /** @param {(batch: Batch) => void} fn */
1563
+ ondiscard(fn) {
1564
+ this.#discard_callbacks.add(fn);
1466
1565
  }
1467
1566
  settled() {
1468
1567
  return (this.#deferred ??= deferred()).promise;
@@ -1484,10 +1583,10 @@ class Batch {
1484
1583
  }
1485
1584
  /** @param {() => void} task */
1486
1585
  static enqueue(task) {
1487
- if (tasks.length === 0) {
1488
- queueMicrotask(dequeue);
1489
- }
1490
- tasks.unshift(task);
1586
+ queue_micro_task(task);
1587
+ }
1588
+ apply() {
1589
+ return;
1491
1590
  }
1492
1591
  }
1493
1592
  function flushSync(fn) {
@@ -1551,7 +1650,7 @@ function flush_queued_effects(effects) {
1551
1650
  while (i < length) {
1552
1651
  var effect = effects[i++];
1553
1652
  if ((effect.f & (DESTROYED | INERT)) === 0 && is_dirty(effect)) {
1554
- eager_block_effects = [];
1653
+ eager_block_effects = /* @__PURE__ */ new Set();
1555
1654
  update_effect(effect);
1556
1655
  if (effect.deps === null && effect.first === null && effect.nodes_start === null) {
1557
1656
  if (effect.teardown === null && effect.ac === null) {
@@ -1560,33 +1659,507 @@ function flush_queued_effects(effects) {
1560
1659
  effect.fn = null;
1561
1660
  }
1562
1661
  }
1563
- if (eager_block_effects.length > 0) {
1662
+ if (eager_block_effects?.size > 0) {
1564
1663
  old_values.clear();
1565
1664
  for (const e of eager_block_effects) {
1566
- update_effect(e);
1665
+ if ((e.f & (DESTROYED | INERT)) !== 0) continue;
1666
+ const ordered_effects = [e];
1667
+ let ancestor = e.parent;
1668
+ while (ancestor !== null) {
1669
+ if (eager_block_effects.has(ancestor)) {
1670
+ eager_block_effects.delete(ancestor);
1671
+ ordered_effects.push(ancestor);
1672
+ }
1673
+ ancestor = ancestor.parent;
1674
+ }
1675
+ for (let j = ordered_effects.length - 1; j >= 0; j--) {
1676
+ const e2 = ordered_effects[j];
1677
+ if ((e2.f & (DESTROYED | INERT)) !== 0) continue;
1678
+ update_effect(e2);
1679
+ }
1567
1680
  }
1568
- eager_block_effects = [];
1681
+ eager_block_effects.clear();
1569
1682
  }
1570
1683
  }
1571
1684
  }
1572
1685
  eager_block_effects = null;
1573
1686
  }
1574
- function schedule_effect(signal) {
1687
+ function mark_effects(value, sources, marked, checked) {
1688
+ if (marked.has(value)) return;
1689
+ marked.add(value);
1690
+ if (value.reactions !== null) {
1691
+ for (const reaction of value.reactions) {
1692
+ const flags2 = reaction.f;
1693
+ if ((flags2 & DERIVED) !== 0) {
1694
+ mark_effects(
1695
+ /** @type {Derived} */
1696
+ reaction,
1697
+ sources,
1698
+ marked,
1699
+ checked
1700
+ );
1701
+ } else if ((flags2 & (ASYNC | BLOCK_EFFECT)) !== 0 && (flags2 & DIRTY) === 0 && // we may have scheduled this one already
1702
+ depends_on(reaction, sources, checked)) {
1703
+ set_signal_status(reaction, DIRTY);
1704
+ schedule_effect(
1705
+ /** @type {Effect} */
1706
+ reaction
1707
+ );
1708
+ }
1709
+ }
1710
+ }
1711
+ }
1712
+ function depends_on(reaction, sources, checked) {
1713
+ const depends = checked.get(reaction);
1714
+ if (depends !== void 0) return depends;
1715
+ if (reaction.deps !== null) {
1716
+ for (const dep of reaction.deps) {
1717
+ if (sources.includes(dep)) {
1718
+ return true;
1719
+ }
1720
+ if ((dep.f & DERIVED) !== 0 && depends_on(
1721
+ /** @type {Derived} */
1722
+ dep,
1723
+ sources,
1724
+ checked
1725
+ )) {
1726
+ checked.set(
1727
+ /** @type {Derived} */
1728
+ dep,
1729
+ true
1730
+ );
1731
+ return true;
1732
+ }
1733
+ }
1734
+ }
1735
+ checked.set(reaction, false);
1736
+ return false;
1737
+ }
1738
+ function schedule_effect(signal) {
1575
1739
  var effect = last_scheduled_effect = signal;
1576
1740
  while (effect.parent !== null) {
1577
1741
  effect = effect.parent;
1578
- var flags = effect.f;
1579
- if (is_flushing && effect === active_effect && (flags & BLOCK_EFFECT) !== 0) {
1742
+ var flags2 = effect.f;
1743
+ if (is_flushing && effect === active_effect && (flags2 & BLOCK_EFFECT) !== 0) {
1580
1744
  return;
1581
1745
  }
1582
- if ((flags & (ROOT_EFFECT | BRANCH_EFFECT)) !== 0) {
1583
- if ((flags & CLEAN) === 0) return;
1746
+ if ((flags2 & (ROOT_EFFECT | BRANCH_EFFECT)) !== 0) {
1747
+ if ((flags2 & CLEAN) === 0) return;
1584
1748
  effect.f ^= CLEAN;
1585
1749
  }
1586
1750
  }
1587
1751
  queued_root_effects.push(effect);
1588
1752
  }
1753
+ function createSubscriber(start) {
1754
+ let subscribers = 0;
1755
+ let version = source(0);
1756
+ let stop;
1757
+ return () => {
1758
+ if (effect_tracking()) {
1759
+ get(version);
1760
+ render_effect(() => {
1761
+ if (subscribers === 0) {
1762
+ stop = untrack(() => start(() => increment(version)));
1763
+ }
1764
+ subscribers += 1;
1765
+ return () => {
1766
+ queue_micro_task(() => {
1767
+ subscribers -= 1;
1768
+ if (subscribers === 0) {
1769
+ stop?.();
1770
+ stop = void 0;
1771
+ increment(version);
1772
+ }
1773
+ });
1774
+ };
1775
+ });
1776
+ }
1777
+ };
1778
+ }
1779
+ var flags = EFFECT_TRANSPARENT | EFFECT_PRESERVED | BOUNDARY_EFFECT;
1780
+ function boundary(node, props, children) {
1781
+ new Boundary(node, props, children);
1782
+ }
1783
+ class Boundary {
1784
+ /** @type {Boundary | null} */
1785
+ parent;
1786
+ #pending = false;
1787
+ /** @type {TemplateNode} */
1788
+ #anchor;
1789
+ /** @type {TemplateNode | null} */
1790
+ #hydrate_open = hydrating ? hydrate_node : null;
1791
+ /** @type {BoundaryProps} */
1792
+ #props;
1793
+ /** @type {((anchor: Node) => void)} */
1794
+ #children;
1795
+ /** @type {Effect} */
1796
+ #effect;
1797
+ /** @type {Effect | null} */
1798
+ #main_effect = null;
1799
+ /** @type {Effect | null} */
1800
+ #pending_effect = null;
1801
+ /** @type {Effect | null} */
1802
+ #failed_effect = null;
1803
+ /** @type {DocumentFragment | null} */
1804
+ #offscreen_fragment = null;
1805
+ /** @type {TemplateNode | null} */
1806
+ #pending_anchor = null;
1807
+ #local_pending_count = 0;
1808
+ #pending_count = 0;
1809
+ #is_creating_fallback = false;
1810
+ /**
1811
+ * A source containing the number of pending async deriveds/expressions.
1812
+ * Only created if `$effect.pending()` is used inside the boundary,
1813
+ * otherwise updating the source results in needless `Batch.ensure()`
1814
+ * calls followed by no-op flushes
1815
+ * @type {Source<number> | null}
1816
+ */
1817
+ #effect_pending = null;
1818
+ #effect_pending_subscriber = createSubscriber(() => {
1819
+ this.#effect_pending = source(this.#local_pending_count);
1820
+ return () => {
1821
+ this.#effect_pending = null;
1822
+ };
1823
+ });
1824
+ /**
1825
+ * @param {TemplateNode} node
1826
+ * @param {BoundaryProps} props
1827
+ * @param {((anchor: Node) => void)} children
1828
+ */
1829
+ constructor(node, props, children) {
1830
+ this.#anchor = node;
1831
+ this.#props = props;
1832
+ this.#children = children;
1833
+ this.parent = /** @type {Effect} */
1834
+ active_effect.b;
1835
+ this.#pending = !!this.#props.pending;
1836
+ this.#effect = block(() => {
1837
+ active_effect.b = this;
1838
+ if (hydrating) {
1839
+ const comment = this.#hydrate_open;
1840
+ hydrate_next();
1841
+ const server_rendered_pending = (
1842
+ /** @type {Comment} */
1843
+ comment.nodeType === COMMENT_NODE && /** @type {Comment} */
1844
+ comment.data === HYDRATION_START_ELSE
1845
+ );
1846
+ if (server_rendered_pending) {
1847
+ this.#hydrate_pending_content();
1848
+ } else {
1849
+ this.#hydrate_resolved_content();
1850
+ }
1851
+ } else {
1852
+ var anchor = this.#get_anchor();
1853
+ try {
1854
+ this.#main_effect = branch(() => children(anchor));
1855
+ } catch (error) {
1856
+ this.error(error);
1857
+ }
1858
+ if (this.#pending_count > 0) {
1859
+ this.#show_pending_snippet();
1860
+ } else {
1861
+ this.#pending = false;
1862
+ }
1863
+ }
1864
+ return () => {
1865
+ this.#pending_anchor?.remove();
1866
+ };
1867
+ }, flags);
1868
+ if (hydrating) {
1869
+ this.#anchor = hydrate_node;
1870
+ }
1871
+ }
1872
+ #hydrate_resolved_content() {
1873
+ try {
1874
+ this.#main_effect = branch(() => this.#children(this.#anchor));
1875
+ } catch (error) {
1876
+ this.error(error);
1877
+ }
1878
+ this.#pending = false;
1879
+ }
1880
+ #hydrate_pending_content() {
1881
+ const pending = this.#props.pending;
1882
+ if (!pending) {
1883
+ return;
1884
+ }
1885
+ this.#pending_effect = branch(() => pending(this.#anchor));
1886
+ Batch.enqueue(() => {
1887
+ var anchor = this.#get_anchor();
1888
+ this.#main_effect = this.#run(() => {
1889
+ Batch.ensure();
1890
+ return branch(() => this.#children(anchor));
1891
+ });
1892
+ if (this.#pending_count > 0) {
1893
+ this.#show_pending_snippet();
1894
+ } else {
1895
+ pause_effect(
1896
+ /** @type {Effect} */
1897
+ this.#pending_effect,
1898
+ () => {
1899
+ this.#pending_effect = null;
1900
+ }
1901
+ );
1902
+ this.#pending = false;
1903
+ }
1904
+ });
1905
+ }
1906
+ #get_anchor() {
1907
+ var anchor = this.#anchor;
1908
+ if (this.#pending) {
1909
+ this.#pending_anchor = create_text();
1910
+ this.#anchor.before(this.#pending_anchor);
1911
+ anchor = this.#pending_anchor;
1912
+ }
1913
+ return anchor;
1914
+ }
1915
+ /**
1916
+ * Returns `true` if the effect exists inside a boundary whose pending snippet is shown
1917
+ * @returns {boolean}
1918
+ */
1919
+ is_pending() {
1920
+ return this.#pending || !!this.parent && this.parent.is_pending();
1921
+ }
1922
+ has_pending_snippet() {
1923
+ return !!this.#props.pending;
1924
+ }
1925
+ /**
1926
+ * @param {() => Effect | null} fn
1927
+ */
1928
+ #run(fn) {
1929
+ var previous_effect = active_effect;
1930
+ var previous_reaction = active_reaction;
1931
+ var previous_ctx = component_context;
1932
+ set_active_effect(this.#effect);
1933
+ set_active_reaction(this.#effect);
1934
+ set_component_context(this.#effect.ctx);
1935
+ try {
1936
+ return fn();
1937
+ } catch (e) {
1938
+ handle_error(e);
1939
+ return null;
1940
+ } finally {
1941
+ set_active_effect(previous_effect);
1942
+ set_active_reaction(previous_reaction);
1943
+ set_component_context(previous_ctx);
1944
+ }
1945
+ }
1946
+ #show_pending_snippet() {
1947
+ const pending = (
1948
+ /** @type {(anchor: Node) => void} */
1949
+ this.#props.pending
1950
+ );
1951
+ if (this.#main_effect !== null) {
1952
+ this.#offscreen_fragment = document.createDocumentFragment();
1953
+ this.#offscreen_fragment.append(
1954
+ /** @type {TemplateNode} */
1955
+ this.#pending_anchor
1956
+ );
1957
+ move_effect(this.#main_effect, this.#offscreen_fragment);
1958
+ }
1959
+ if (this.#pending_effect === null) {
1960
+ this.#pending_effect = branch(() => pending(this.#anchor));
1961
+ }
1962
+ }
1963
+ /**
1964
+ * Updates the pending count associated with the currently visible pending snippet,
1965
+ * if any, such that we can replace the snippet with content once work is done
1966
+ * @param {1 | -1} d
1967
+ */
1968
+ #update_pending_count(d) {
1969
+ if (!this.has_pending_snippet()) {
1970
+ if (this.parent) {
1971
+ this.parent.#update_pending_count(d);
1972
+ }
1973
+ return;
1974
+ }
1975
+ this.#pending_count += d;
1976
+ if (this.#pending_count === 0) {
1977
+ this.#pending = false;
1978
+ if (this.#pending_effect) {
1979
+ pause_effect(this.#pending_effect, () => {
1980
+ this.#pending_effect = null;
1981
+ });
1982
+ }
1983
+ if (this.#offscreen_fragment) {
1984
+ this.#anchor.before(this.#offscreen_fragment);
1985
+ this.#offscreen_fragment = null;
1986
+ }
1987
+ }
1988
+ }
1989
+ /**
1990
+ * Update the source that powers `$effect.pending()` inside this boundary,
1991
+ * and controls when the current `pending` snippet (if any) is removed.
1992
+ * Do not call from inside the class
1993
+ * @param {1 | -1} d
1994
+ */
1995
+ update_pending_count(d) {
1996
+ this.#update_pending_count(d);
1997
+ this.#local_pending_count += d;
1998
+ if (this.#effect_pending) {
1999
+ internal_set(this.#effect_pending, this.#local_pending_count);
2000
+ }
2001
+ }
2002
+ get_effect_pending() {
2003
+ this.#effect_pending_subscriber();
2004
+ return get(
2005
+ /** @type {Source<number>} */
2006
+ this.#effect_pending
2007
+ );
2008
+ }
2009
+ /** @param {unknown} error */
2010
+ error(error) {
2011
+ var onerror = this.#props.onerror;
2012
+ let failed = this.#props.failed;
2013
+ if (this.#is_creating_fallback || !onerror && !failed) {
2014
+ throw error;
2015
+ }
2016
+ if (this.#main_effect) {
2017
+ destroy_effect(this.#main_effect);
2018
+ this.#main_effect = null;
2019
+ }
2020
+ if (this.#pending_effect) {
2021
+ destroy_effect(this.#pending_effect);
2022
+ this.#pending_effect = null;
2023
+ }
2024
+ if (this.#failed_effect) {
2025
+ destroy_effect(this.#failed_effect);
2026
+ this.#failed_effect = null;
2027
+ }
2028
+ if (hydrating) {
2029
+ set_hydrate_node(
2030
+ /** @type {TemplateNode} */
2031
+ this.#hydrate_open
2032
+ );
2033
+ next();
2034
+ set_hydrate_node(skip_nodes());
2035
+ }
2036
+ var did_reset = false;
2037
+ var calling_on_error = false;
2038
+ const reset = () => {
2039
+ if (did_reset) {
2040
+ svelte_boundary_reset_noop();
2041
+ return;
2042
+ }
2043
+ did_reset = true;
2044
+ if (calling_on_error) {
2045
+ svelte_boundary_reset_onerror();
2046
+ }
2047
+ Batch.ensure();
2048
+ this.#local_pending_count = 0;
2049
+ if (this.#failed_effect !== null) {
2050
+ pause_effect(this.#failed_effect, () => {
2051
+ this.#failed_effect = null;
2052
+ });
2053
+ }
2054
+ this.#pending = this.has_pending_snippet();
2055
+ this.#main_effect = this.#run(() => {
2056
+ this.#is_creating_fallback = false;
2057
+ return branch(() => this.#children(this.#anchor));
2058
+ });
2059
+ if (this.#pending_count > 0) {
2060
+ this.#show_pending_snippet();
2061
+ } else {
2062
+ this.#pending = false;
2063
+ }
2064
+ };
2065
+ var previous_reaction = active_reaction;
2066
+ try {
2067
+ set_active_reaction(null);
2068
+ calling_on_error = true;
2069
+ onerror?.(error, reset);
2070
+ calling_on_error = false;
2071
+ } catch (error2) {
2072
+ invoke_error_boundary(error2, this.#effect && this.#effect.parent);
2073
+ } finally {
2074
+ set_active_reaction(previous_reaction);
2075
+ }
2076
+ if (failed) {
2077
+ queue_micro_task(() => {
2078
+ this.#failed_effect = this.#run(() => {
2079
+ Batch.ensure();
2080
+ this.#is_creating_fallback = true;
2081
+ try {
2082
+ return branch(() => {
2083
+ failed(
2084
+ this.#anchor,
2085
+ () => error,
2086
+ () => reset
2087
+ );
2088
+ });
2089
+ } catch (error2) {
2090
+ invoke_error_boundary(
2091
+ error2,
2092
+ /** @type {Effect} */
2093
+ this.#effect.parent
2094
+ );
2095
+ return null;
2096
+ } finally {
2097
+ this.#is_creating_fallback = false;
2098
+ }
2099
+ });
2100
+ });
2101
+ }
2102
+ }
2103
+ }
2104
+ function destroy_derived_effects(derived) {
2105
+ var effects = derived.effects;
2106
+ if (effects !== null) {
2107
+ derived.effects = null;
2108
+ for (var i = 0; i < effects.length; i += 1) {
2109
+ destroy_effect(
2110
+ /** @type {Effect} */
2111
+ effects[i]
2112
+ );
2113
+ }
2114
+ }
2115
+ }
2116
+ function get_derived_parent_effect(derived) {
2117
+ var parent = derived.parent;
2118
+ while (parent !== null) {
2119
+ if ((parent.f & DERIVED) === 0) {
2120
+ return (
2121
+ /** @type {Effect} */
2122
+ parent
2123
+ );
2124
+ }
2125
+ parent = parent.parent;
2126
+ }
2127
+ return null;
2128
+ }
2129
+ function execute_derived(derived) {
2130
+ var value;
2131
+ var prev_active_effect = active_effect;
2132
+ set_active_effect(get_derived_parent_effect(derived));
2133
+ {
2134
+ try {
2135
+ derived.f &= ~WAS_MARKED;
2136
+ destroy_derived_effects(derived);
2137
+ value = update_reaction(derived);
2138
+ } finally {
2139
+ set_active_effect(prev_active_effect);
2140
+ }
2141
+ }
2142
+ return value;
2143
+ }
2144
+ function update_derived(derived) {
2145
+ var value = execute_derived(derived);
2146
+ if (!derived.equals(value)) {
2147
+ derived.v = value;
2148
+ derived.wv = increment_write_version();
2149
+ }
2150
+ if (is_destroying_effect) {
2151
+ return;
2152
+ }
2153
+ if (batch_values !== null) {
2154
+ batch_values.set(derived, derived.v);
2155
+ } else {
2156
+ var status = (skip_reaction || (derived.f & UNOWNED) !== 0) && derived.deps !== null ? MAYBE_DIRTY : CLEAN;
2157
+ set_signal_status(derived, status);
2158
+ }
2159
+ }
2160
+ let eager_effects = /* @__PURE__ */ new Set();
1589
2161
  const old_values = /* @__PURE__ */ new Map();
2162
+ let eager_effects_deferred = false;
1590
2163
  function source(v, stack) {
1591
2164
  var signal = {
1592
2165
  f: 0,
@@ -1616,7 +2189,7 @@ function mutable_source(initial_value, immutable = false, trackable = true) {
1616
2189
  function set(source2, value, should_proxy = false) {
1617
2190
  if (active_reaction !== null && // since we are untracking the function inside `$inspect.with` we need to add this check
1618
2191
  // to ensure we error if state is set inside an inspect effect
1619
- (!untracking || (active_reaction.f & INSPECT_EFFECT) !== 0) && is_runes() && (active_reaction.f & (DERIVED | BLOCK_EFFECT | ASYNC | INSPECT_EFFECT)) !== 0 && !current_sources?.includes(source2)) {
2192
+ (!untracking || (active_reaction.f & EAGER_EFFECT) !== 0) && is_runes() && (active_reaction.f & (DERIVED | BLOCK_EFFECT | ASYNC | EAGER_EFFECT)) !== 0 && !current_sources?.includes(source2)) {
1620
2193
  state_unsafe_mutation();
1621
2194
  }
1622
2195
  let new_value = should_proxy ? proxy(value) : value;
@@ -1651,9 +2224,25 @@ function internal_set(source2, value) {
1651
2224
  untracked_writes.push(source2);
1652
2225
  }
1653
2226
  }
2227
+ if (!batch.is_fork && eager_effects.size > 0 && !eager_effects_deferred) {
2228
+ flush_eager_effects();
2229
+ }
1654
2230
  }
1655
2231
  return value;
1656
2232
  }
2233
+ function flush_eager_effects() {
2234
+ eager_effects_deferred = false;
2235
+ const inspects = Array.from(eager_effects);
2236
+ for (const effect of inspects) {
2237
+ if ((effect.f & CLEAN) !== 0) {
2238
+ set_signal_status(effect, MAYBE_DIRTY);
2239
+ }
2240
+ if (is_dirty(effect)) {
2241
+ update_effect(effect);
2242
+ }
2243
+ }
2244
+ eager_effects.clear();
2245
+ }
1657
2246
  function increment(source2) {
1658
2247
  set(source2, source2.v + 1);
1659
2248
  }
@@ -1663,21 +2252,24 @@ function mark_reactions(signal, status) {
1663
2252
  var length = reactions.length;
1664
2253
  for (var i = 0; i < length; i++) {
1665
2254
  var reaction = reactions[i];
1666
- var flags = reaction.f;
1667
- var not_dirty = (flags & DIRTY) === 0;
2255
+ var flags2 = reaction.f;
2256
+ var not_dirty = (flags2 & DIRTY) === 0;
1668
2257
  if (not_dirty) {
1669
2258
  set_signal_status(reaction, status);
1670
2259
  }
1671
- if ((flags & DERIVED) !== 0) {
1672
- mark_reactions(
1673
- /** @type {Derived} */
1674
- reaction,
1675
- MAYBE_DIRTY
1676
- );
2260
+ if ((flags2 & DERIVED) !== 0) {
2261
+ if ((flags2 & WAS_MARKED) === 0) {
2262
+ reaction.f |= WAS_MARKED;
2263
+ mark_reactions(
2264
+ /** @type {Derived} */
2265
+ reaction,
2266
+ MAYBE_DIRTY
2267
+ );
2268
+ }
1677
2269
  } else if (not_dirty) {
1678
- if ((flags & BLOCK_EFFECT) !== 0) {
2270
+ if ((flags2 & BLOCK_EFFECT) !== 0) {
1679
2271
  if (eager_block_effects !== null) {
1680
- eager_block_effects.push(
2272
+ eager_block_effects.add(
1681
2273
  /** @type {Effect} */
1682
2274
  reaction
1683
2275
  );
@@ -1967,34 +2559,47 @@ function create_effect(type, fn, sync, push2 = true) {
1967
2559
  try {
1968
2560
  update_effect(effect);
1969
2561
  effect.f |= EFFECT_RAN;
1970
- } catch (e) {
2562
+ } catch (e2) {
1971
2563
  destroy_effect(effect);
1972
- throw e;
2564
+ throw e2;
1973
2565
  }
1974
2566
  } else if (fn !== null) {
1975
2567
  schedule_effect(effect);
1976
2568
  }
1977
- var inert = sync && effect.deps === null && effect.first === null && effect.nodes_start === null && effect.teardown === null && (effect.f & EFFECT_PRESERVED) === 0;
1978
- if (!inert && push2) {
1979
- if (parent !== null) {
1980
- push_effect(effect, parent);
2569
+ if (push2) {
2570
+ var e = effect;
2571
+ if (sync && e.deps === null && e.teardown === null && e.nodes_start === null && e.first === e.last && // either `null`, or a singular child
2572
+ (e.f & EFFECT_PRESERVED) === 0) {
2573
+ e = e.first;
2574
+ if ((type & BLOCK_EFFECT) !== 0 && (type & EFFECT_TRANSPARENT) !== 0 && e !== null) {
2575
+ e.f |= EFFECT_TRANSPARENT;
2576
+ }
1981
2577
  }
1982
- if (active_reaction !== null && (active_reaction.f & DERIVED) !== 0 && (type & ROOT_EFFECT) === 0) {
1983
- var derived = (
1984
- /** @type {Derived} */
1985
- active_reaction
1986
- );
1987
- (derived.effects ??= []).push(effect);
2578
+ if (e !== null) {
2579
+ e.parent = parent;
2580
+ if (parent !== null) {
2581
+ push_effect(e, parent);
2582
+ }
2583
+ if (active_reaction !== null && (active_reaction.f & DERIVED) !== 0 && (type & ROOT_EFFECT) === 0) {
2584
+ var derived = (
2585
+ /** @type {Derived} */
2586
+ active_reaction
2587
+ );
2588
+ (derived.effects ??= []).push(e);
2589
+ }
1988
2590
  }
1989
2591
  }
1990
2592
  return effect;
1991
2593
  }
2594
+ function effect_tracking() {
2595
+ return active_reaction !== null && !untracking;
2596
+ }
1992
2597
  function create_user_effect(fn) {
1993
2598
  return create_effect(EFFECT | USER_EFFECT, fn, false);
1994
2599
  }
1995
2600
  function component_root(fn) {
1996
2601
  Batch.ensure();
1997
- const effect = create_effect(ROOT_EFFECT, fn, true);
2602
+ const effect = create_effect(ROOT_EFFECT | EFFECT_PRESERVED, fn, true);
1998
2603
  return (options2 = {}) => {
1999
2604
  return new Promise((fulfil) => {
2000
2605
  if (options2.outro) {
@@ -2009,8 +2614,15 @@ function component_root(fn) {
2009
2614
  });
2010
2615
  };
2011
2616
  }
2617
+ function render_effect(fn, flags2 = 0) {
2618
+ return create_effect(RENDER_EFFECT | flags2, fn, true);
2619
+ }
2620
+ function block(fn, flags2 = 0) {
2621
+ var effect = create_effect(BLOCK_EFFECT | flags2, fn, true);
2622
+ return effect;
2623
+ }
2012
2624
  function branch(fn, push2 = true) {
2013
- return create_effect(BRANCH_EFFECT, fn, true, push2);
2625
+ return create_effect(BRANCH_EFFECT | EFFECT_PRESERVED, fn, true, push2);
2014
2626
  }
2015
2627
  function execute_effect_teardown(effect) {
2016
2628
  var teardown = effect.teardown;
@@ -2037,23 +2649,23 @@ function destroy_effect_children(signal, remove_dom = false) {
2037
2649
  controller.abort(STALE_REACTION);
2038
2650
  });
2039
2651
  }
2040
- var next = effect.next;
2652
+ var next2 = effect.next;
2041
2653
  if ((effect.f & ROOT_EFFECT) !== 0) {
2042
2654
  effect.parent = null;
2043
2655
  } else {
2044
2656
  destroy_effect(effect, remove_dom);
2045
2657
  }
2046
- effect = next;
2658
+ effect = next2;
2047
2659
  }
2048
2660
  }
2049
2661
  function destroy_block_effect_children(signal) {
2050
2662
  var effect = signal.first;
2051
2663
  while (effect !== null) {
2052
- var next = effect.next;
2664
+ var next2 = effect.next;
2053
2665
  if ((effect.f & BRANCH_EFFECT) === 0) {
2054
2666
  destroy_effect(effect);
2055
2667
  }
2056
- effect = next;
2668
+ effect = next2;
2057
2669
  }
2058
2670
  }
2059
2671
  function destroy_effect(effect, remove_dom = true) {
@@ -2084,30 +2696,30 @@ function destroy_effect(effect, remove_dom = true) {
2084
2696
  }
2085
2697
  function remove_effect_dom(node, end) {
2086
2698
  while (node !== null) {
2087
- var next = node === end ? null : (
2699
+ var next2 = node === end ? null : (
2088
2700
  /** @type {TemplateNode} */
2089
2701
  /* @__PURE__ */ get_next_sibling(node)
2090
2702
  );
2091
2703
  node.remove();
2092
- node = next;
2704
+ node = next2;
2093
2705
  }
2094
2706
  }
2095
2707
  function unlink_effect(effect) {
2096
2708
  var parent = effect.parent;
2097
2709
  var prev = effect.prev;
2098
- var next = effect.next;
2099
- if (prev !== null) prev.next = next;
2100
- if (next !== null) next.prev = prev;
2710
+ var next2 = effect.next;
2711
+ if (prev !== null) prev.next = next2;
2712
+ if (next2 !== null) next2.prev = prev;
2101
2713
  if (parent !== null) {
2102
- if (parent.first === effect) parent.first = next;
2714
+ if (parent.first === effect) parent.first = next2;
2103
2715
  if (parent.last === effect) parent.last = prev;
2104
2716
  }
2105
2717
  }
2106
- function pause_effect(effect, callback) {
2718
+ function pause_effect(effect, callback, destroy = true) {
2107
2719
  var transitions = [];
2108
2720
  pause_children(effect, transitions, true);
2109
2721
  run_out_transitions(transitions, () => {
2110
- destroy_effect(effect);
2722
+ if (destroy) destroy_effect(effect);
2111
2723
  if (callback) callback();
2112
2724
  });
2113
2725
  }
@@ -2135,11 +2747,26 @@ function pause_children(effect, transitions, local) {
2135
2747
  var child = effect.first;
2136
2748
  while (child !== null) {
2137
2749
  var sibling = child.next;
2138
- var transparent = (child.f & EFFECT_TRANSPARENT) !== 0 || (child.f & BRANCH_EFFECT) !== 0;
2750
+ var transparent = (child.f & EFFECT_TRANSPARENT) !== 0 || // If this is a branch effect without a block effect parent,
2751
+ // it means the parent block effect was pruned. In that case,
2752
+ // transparency information was transferred to the branch effect.
2753
+ (child.f & BRANCH_EFFECT) !== 0 && (effect.f & BLOCK_EFFECT) !== 0;
2139
2754
  pause_children(child, transitions, transparent ? local : false);
2140
2755
  child = sibling;
2141
2756
  }
2142
2757
  }
2758
+ function move_effect(effect, fragment) {
2759
+ var node = effect.nodes_start;
2760
+ var end = effect.nodes_end;
2761
+ while (node !== null) {
2762
+ var next2 = node === end ? null : (
2763
+ /** @type {TemplateNode} */
2764
+ /* @__PURE__ */ get_next_sibling(node)
2765
+ );
2766
+ fragment.append(node);
2767
+ node = next2;
2768
+ }
2769
+ }
2143
2770
  let is_updating_effect = false;
2144
2771
  function set_is_updating_effect(value) {
2145
2772
  is_updating_effect = value;
@@ -2184,17 +2811,20 @@ function increment_write_version() {
2184
2811
  return ++write_version;
2185
2812
  }
2186
2813
  function is_dirty(reaction) {
2187
- var flags = reaction.f;
2188
- if ((flags & DIRTY) !== 0) {
2814
+ var flags2 = reaction.f;
2815
+ if ((flags2 & DIRTY) !== 0) {
2189
2816
  return true;
2190
2817
  }
2191
- if ((flags & MAYBE_DIRTY) !== 0) {
2818
+ if ((flags2 & MAYBE_DIRTY) !== 0) {
2192
2819
  var dependencies = reaction.deps;
2193
- var is_unowned = (flags & UNOWNED) !== 0;
2820
+ var is_unowned = (flags2 & UNOWNED) !== 0;
2821
+ if (flags2 & DERIVED) {
2822
+ reaction.f &= ~WAS_MARKED;
2823
+ }
2194
2824
  if (dependencies !== null) {
2195
2825
  var i;
2196
2826
  var dependency;
2197
- var is_disconnected = (flags & DISCONNECTED) !== 0;
2827
+ var is_disconnected = (flags2 & DISCONNECTED) !== 0;
2198
2828
  var is_unowned_connected = is_unowned && active_effect !== null && !skip_reaction;
2199
2829
  var length = dependencies.length;
2200
2830
  if ((is_disconnected || is_unowned_connected) && (active_effect === null || (active_effect.f & DESTROYED) === 0)) {
@@ -2276,13 +2906,13 @@ function update_reaction(reaction) {
2276
2906
  var previous_component_context = component_context;
2277
2907
  var previous_untracking = untracking;
2278
2908
  var previous_update_version = update_version;
2279
- var flags = reaction.f;
2909
+ var flags2 = reaction.f;
2280
2910
  new_deps = /** @type {null | Value[]} */
2281
2911
  null;
2282
2912
  skipped_deps = 0;
2283
2913
  untracked_writes = null;
2284
- skip_reaction = (flags & UNOWNED) !== 0 && (untracking || !is_updating_effect || active_reaction === null);
2285
- active_reaction = (flags & (BRANCH_EFFECT | ROOT_EFFECT)) === 0 ? reaction : null;
2914
+ skip_reaction = (flags2 & UNOWNED) !== 0 && (untracking || !is_updating_effect || active_reaction === null);
2915
+ active_reaction = (flags2 & (BRANCH_EFFECT | ROOT_EFFECT)) === 0 ? reaction : null;
2286
2916
  current_sources = null;
2287
2917
  set_component_context(reaction.ctx);
2288
2918
  untracking = false;
@@ -2313,7 +2943,7 @@ function update_reaction(reaction) {
2313
2943
  reaction.deps = deps = new_deps;
2314
2944
  }
2315
2945
  if (!skip_reaction || // Deriveds that already have reactions can cleanup, so we still add them as reactions
2316
- (flags & DERIVED) !== 0 && /** @type {import('#client').Derived} */
2946
+ (flags2 & DERIVED) !== 0 && /** @type {import('#client').Derived} */
2317
2947
  reaction.reactions !== null) {
2318
2948
  for (i = skipped_deps; i < deps.length; i++) {
2319
2949
  (deps[i].reactions ??= []).push(reaction);
@@ -2404,8 +3034,8 @@ function remove_reactions(signal, start_index) {
2404
3034
  }
2405
3035
  }
2406
3036
  function update_effect(effect) {
2407
- var flags = effect.f;
2408
- if ((flags & DESTROYED) !== 0) {
3037
+ var flags2 = effect.f;
3038
+ if ((flags2 & DESTROYED) !== 0) {
2409
3039
  return;
2410
3040
  }
2411
3041
  set_signal_status(effect, CLEAN);
@@ -2414,7 +3044,7 @@ function update_effect(effect) {
2414
3044
  active_effect = effect;
2415
3045
  is_updating_effect = true;
2416
3046
  try {
2417
- if ((flags & BLOCK_EFFECT) !== 0) {
3047
+ if ((flags2 & BLOCK_EFFECT) !== 0) {
2418
3048
  destroy_block_effect_children(effect);
2419
3049
  } else {
2420
3050
  destroy_effect_children(effect);
@@ -2431,8 +3061,8 @@ function update_effect(effect) {
2431
3061
  }
2432
3062
  }
2433
3063
  function get(signal) {
2434
- var flags = signal.f;
2435
- var is_derived = (flags & DERIVED) !== 0;
3064
+ var flags2 = signal.f;
3065
+ var is_derived = (flags2 & DERIVED) !== 0;
2436
3066
  if (active_reaction !== null && !untracking) {
2437
3067
  var destroyed = active_effect !== null && (active_effect.f & DESTROYED) !== 0;
2438
3068
  if (!destroyed && !current_sources?.includes(signal)) {
@@ -2487,13 +3117,16 @@ function get(signal) {
2487
3117
  } else if (is_derived) {
2488
3118
  derived = /** @type {Derived} */
2489
3119
  signal;
2490
- if (batch_deriveds?.has(derived)) {
2491
- return batch_deriveds.get(derived);
3120
+ if (batch_values?.has(derived)) {
3121
+ return batch_values.get(derived);
2492
3122
  }
2493
3123
  if (is_dirty(derived)) {
2494
3124
  update_derived(derived);
2495
3125
  }
2496
3126
  }
3127
+ if (batch_values?.has(signal)) {
3128
+ return batch_values.get(signal);
3129
+ }
2497
3130
  if ((signal.f & ERROR_VALUE) !== 0) {
2498
3131
  throw signal.v;
2499
3132
  }
@@ -2515,6 +3148,15 @@ function depends_on_old_values(derived) {
2515
3148
  }
2516
3149
  return false;
2517
3150
  }
3151
+ function untrack(fn) {
3152
+ var previous_untracking = untracking;
3153
+ try {
3154
+ untracking = true;
3155
+ return fn();
3156
+ } finally {
3157
+ untracking = previous_untracking;
3158
+ }
3159
+ }
2518
3160
  const STATUS_MASK = -7169;
2519
3161
  function set_signal_status(signal, status) {
2520
3162
  signal.f = signal.f & STATUS_MASK | status;
@@ -2577,12 +3219,7 @@ function handle_event_propagation(event) {
2577
3219
  current_target.disabled || // DOM could've been updated already by the time this is reached, so we check this as well
2578
3220
  // -> the target could not have been disabled because it emits the event in the first place
2579
3221
  event.target === current_target)) {
2580
- if (is_array(delegated)) {
2581
- var [fn, ...data] = delegated;
2582
- fn.apply(current_target, [event, ...data]);
2583
- } else {
2584
- delegated.call(current_target, event);
2585
- }
3222
+ delegated.call(current_target, event);
2586
3223
  }
2587
3224
  } catch (error) {
2588
3225
  if (throw_error) {
@@ -2648,13 +3285,7 @@ function hydrate(component, options2) {
2648
3285
  /** @type {Comment} */
2649
3286
  anchor
2650
3287
  );
2651
- hydrate_next();
2652
3288
  const instance = _mount(component, { ...options2, anchor });
2653
- if (hydrate_node === null || hydrate_node.nodeType !== COMMENT_NODE || /** @type {Comment} */
2654
- hydrate_node.data !== HYDRATION_END) {
2655
- hydration_mismatch();
2656
- throw HYDRATION_ERROR;
2657
- }
2658
3289
  set_hydrating(false);
2659
3290
  return (
2660
3291
  /** @type {Exports} */
@@ -2704,33 +3335,46 @@ function _mount(Component, { target, anchor, props = {}, events, context, intro
2704
3335
  var component = void 0;
2705
3336
  var unmount2 = component_root(() => {
2706
3337
  var anchor_node = anchor ?? target.appendChild(create_text());
2707
- branch(() => {
2708
- if (context) {
2709
- push({});
2710
- var ctx = (
2711
- /** @type {ComponentContext} */
2712
- component_context
2713
- );
2714
- ctx.c = context;
2715
- }
2716
- if (events) {
2717
- props.$$events = events;
2718
- }
2719
- if (hydrating) {
2720
- assign_nodes(
2721
- /** @type {TemplateNode} */
2722
- anchor_node,
2723
- null
2724
- );
2725
- }
2726
- component = Component(anchor_node, props) || {};
2727
- if (hydrating) {
2728
- active_effect.nodes_end = hydrate_node;
2729
- }
2730
- if (context) {
2731
- pop();
3338
+ boundary(
3339
+ /** @type {TemplateNode} */
3340
+ anchor_node,
3341
+ {
3342
+ pending: () => {
3343
+ }
3344
+ },
3345
+ (anchor_node2) => {
3346
+ if (context) {
3347
+ push({});
3348
+ var ctx = (
3349
+ /** @type {ComponentContext} */
3350
+ component_context
3351
+ );
3352
+ ctx.c = context;
3353
+ }
3354
+ if (events) {
3355
+ props.$$events = events;
3356
+ }
3357
+ if (hydrating) {
3358
+ assign_nodes(
3359
+ /** @type {TemplateNode} */
3360
+ anchor_node2,
3361
+ null
3362
+ );
3363
+ }
3364
+ component = Component(anchor_node2, props) || {};
3365
+ if (hydrating) {
3366
+ active_effect.nodes_end = hydrate_node;
3367
+ if (hydrate_node === null || hydrate_node.nodeType !== COMMENT_NODE || /** @type {Comment} */
3368
+ hydrate_node.data !== HYDRATION_END) {
3369
+ hydration_mismatch();
3370
+ throw HYDRATION_ERROR;
3371
+ }
3372
+ }
3373
+ if (context) {
3374
+ pop();
3375
+ }
2732
3376
  }
2733
- });
3377
+ );
2734
3378
  return () => {
2735
3379
  for (var event_name of registered_events) {
2736
3380
  target.removeEventListener(event_name, handle_event_propagation);
@@ -2834,8 +3478,8 @@ class Svelte4Component {
2834
3478
  });
2835
3479
  }
2836
3480
  this.#instance.$set = /** @param {Record<string, any>} next */
2837
- (next) => {
2838
- Object.assign(props, next);
3481
+ (next2) => {
3482
+ Object.assign(props, next2);
2839
3483
  };
2840
3484
  this.#instance.$destroy = () => {
2841
3485
  unmount(this.#instance);
@@ -2873,68 +3517,123 @@ function asClassComponent(component) {
2873
3517
  const component_constructor = asClassComponent$1(component);
2874
3518
  const _render = (props, { context } = {}) => {
2875
3519
  const result = render(component, { props, context });
2876
- return {
2877
- css: { code: "", map: null },
2878
- head: result.head,
2879
- html: result.body
2880
- };
2881
- };
2882
- component_constructor.render = _render;
2883
- return component_constructor;
2884
- }
2885
- function Root($$payload, $$props) {
2886
- push$1();
2887
- let {
2888
- stores,
2889
- page,
2890
- constructors,
2891
- components = [],
2892
- form,
2893
- data_0 = null,
2894
- data_1 = null
2895
- } = $$props;
2896
- {
2897
- setContext("__svelte__", stores);
2898
- }
2899
- {
2900
- stores.page.set(page);
2901
- }
2902
- const Pyramid_1 = constructors[1];
2903
- if (constructors[1]) {
2904
- $$payload.out.push("<!--[-->");
2905
- const Pyramid_0 = constructors[0];
2906
- $$payload.out.push(`<!---->`);
2907
- Pyramid_0($$payload, {
2908
- data: data_0,
3520
+ const munged = Object.defineProperties(
3521
+ /** @type {LegacyRenderResult & PromiseLike<LegacyRenderResult>} */
3522
+ {},
3523
+ {
3524
+ css: {
3525
+ value: { code: "", map: null }
3526
+ },
3527
+ head: {
3528
+ get: () => result.head
3529
+ },
3530
+ html: {
3531
+ get: () => result.body
3532
+ },
3533
+ then: {
3534
+ /**
3535
+ * this is not type-safe, but honestly it's the best I can do right now, and it's a straightforward function.
3536
+ *
3537
+ * @template TResult1
3538
+ * @template [TResult2=never]
3539
+ * @param { (value: LegacyRenderResult) => TResult1 } onfulfilled
3540
+ * @param { (reason: unknown) => TResult2 } onrejected
3541
+ */
3542
+ value: (onfulfilled, onrejected) => {
3543
+ {
3544
+ const user_result = onfulfilled({
3545
+ css: munged.css,
3546
+ head: munged.head,
3547
+ html: munged.html
3548
+ });
3549
+ return Promise.resolve(user_result);
3550
+ }
3551
+ }
3552
+ }
3553
+ }
3554
+ );
3555
+ return munged;
3556
+ };
3557
+ component_constructor.render = _render;
3558
+ return component_constructor;
3559
+ }
3560
+ function Root($$renderer, $$props) {
3561
+ $$renderer.component(($$renderer2) => {
3562
+ let {
3563
+ stores,
3564
+ page,
3565
+ constructors,
3566
+ components = [],
2909
3567
  form,
2910
- params: page.params,
2911
- children: ($$payload2) => {
2912
- $$payload2.out.push(`<!---->`);
2913
- Pyramid_1($$payload2, { data: data_1, form, params: page.params });
2914
- $$payload2.out.push(`<!---->`);
2915
- },
2916
- $$slots: { default: true }
2917
- });
2918
- $$payload.out.push(`<!---->`);
2919
- } else {
2920
- $$payload.out.push("<!--[!-->");
2921
- const Pyramid_0 = constructors[0];
2922
- $$payload.out.push(`<!---->`);
2923
- Pyramid_0($$payload, { data: data_0, form, params: page.params });
2924
- $$payload.out.push(`<!---->`);
2925
- }
2926
- $$payload.out.push(`<!--]--> `);
2927
- {
2928
- $$payload.out.push("<!--[!-->");
2929
- }
2930
- $$payload.out.push(`<!--]-->`);
2931
- pop$1();
3568
+ data_0 = null,
3569
+ data_1 = null,
3570
+ data_2 = null
3571
+ } = $$props;
3572
+ {
3573
+ setContext("__svelte__", stores);
3574
+ }
3575
+ {
3576
+ stores.page.set(page);
3577
+ }
3578
+ const Pyramid_2 = constructors[2];
3579
+ if (constructors[1]) {
3580
+ $$renderer2.push("<!--[-->");
3581
+ const Pyramid_0 = constructors[0];
3582
+ $$renderer2.push(`<!---->`);
3583
+ Pyramid_0($$renderer2, {
3584
+ data: data_0,
3585
+ form,
3586
+ params: page.params,
3587
+ children: ($$renderer3) => {
3588
+ if (constructors[2]) {
3589
+ $$renderer3.push("<!--[-->");
3590
+ const Pyramid_1 = constructors[1];
3591
+ $$renderer3.push(`<!---->`);
3592
+ Pyramid_1($$renderer3, {
3593
+ data: data_1,
3594
+ form,
3595
+ params: page.params,
3596
+ children: ($$renderer4) => {
3597
+ $$renderer4.push(`<!---->`);
3598
+ Pyramid_2($$renderer4, { data: data_2, form, params: page.params });
3599
+ $$renderer4.push(`<!---->`);
3600
+ },
3601
+ $$slots: { default: true }
3602
+ });
3603
+ $$renderer3.push(`<!---->`);
3604
+ } else {
3605
+ $$renderer3.push("<!--[!-->");
3606
+ const Pyramid_1 = constructors[1];
3607
+ $$renderer3.push(`<!---->`);
3608
+ Pyramid_1($$renderer3, { data: data_1, form, params: page.params });
3609
+ $$renderer3.push(`<!---->`);
3610
+ }
3611
+ $$renderer3.push(`<!--]-->`);
3612
+ },
3613
+ $$slots: { default: true }
3614
+ });
3615
+ $$renderer2.push(`<!---->`);
3616
+ } else {
3617
+ $$renderer2.push("<!--[!-->");
3618
+ const Pyramid_0 = constructors[0];
3619
+ $$renderer2.push(`<!---->`);
3620
+ Pyramid_0($$renderer2, { data: data_0, form, params: page.params });
3621
+ $$renderer2.push(`<!---->`);
3622
+ }
3623
+ $$renderer2.push(`<!--]--> `);
3624
+ {
3625
+ $$renderer2.push("<!--[!-->");
3626
+ }
3627
+ $$renderer2.push(`<!--]-->`);
3628
+ });
2932
3629
  }
2933
3630
  const root = asClassComponent(Root);
2934
3631
  const options = {
2935
3632
  app_template_contains_nonce: false,
3633
+ async: false,
2936
3634
  csp: { "mode": "auto", "directives": { "upgrade-insecure-requests": false, "block-all-mixed-content": false }, "reportOnly": { "upgrade-insecure-requests": false, "block-all-mixed-content": false } },
2937
3635
  csrf_check_origin: true,
3636
+ csrf_trusted_origins: [],
2938
3637
  embedded: false,
2939
3638
  env_public_prefix: "PUBLIC_",
2940
3639
  env_private_prefix: "",
@@ -2946,7 +3645,7 @@ const options = {
2946
3645
  service_worker: false,
2947
3646
  service_worker_options: void 0,
2948
3647
  templates: {
2949
- app: ({ head, body, assets, nonce, env }) => '<!doctype html>\n<html lang="en">\n <head>\n <meta charset="utf-8" />\n <link rel="icon" href="' + assets + '/favicon.svg" />\n <meta name="viewport" content="width=device-width, initial-scale=1" />\n <meta name="color-scheme" content="dark light" />\n <link rel="stylesheet" href="' + assets + '/theme.css" />\n <link rel="stylesheet" href="' + assets + '/styles.css" />\n ' + head + '\n </head>\n\n <body>\n <div style="display: contents">' + body + "</div>\n </body>\n</html>\n",
3648
+ app: ({ head, body, assets, nonce, env }) => '<!doctype html>\n<html lang="en">\n <head>\n <meta charset="utf-8" />\n <link rel="icon" href="' + assets + '/favicon.svg" type="image/svg" />\n <meta name="viewport" content="width=device-width, initial-scale=1" />\n <meta name="color-scheme" content="dark light" />\n <link rel="stylesheet" href="' + assets + '/theme.css" />\n <link rel="stylesheet" href="' + assets + '/styles.css" />\n ' + head + '\n </head>\n\n <body>\n <div style="display: contents">' + body + "</div>\n </body>\n</html>\n",
2950
3649
  error: ({ status, message }) => '<!doctype html>\n<html lang="en">\n <head>\n <meta charset="utf-8" />\n <title>' + message + `</title>
2951
3650
 
2952
3651
  <style>
@@ -3018,7 +3717,7 @@ const options = {
3018
3717
  <div class="error">
3019
3718
  <span class="status">` + status + '</span>\n <div class="message">\n <h1>' + message + "</h1>\n </div>\n </div>\n </body>\n</html>\n"
3020
3719
  },
3021
- version_hash: "1mhgepf"
3720
+ version_hash: "142war7"
3022
3721
  };
3023
3722
  async function get_hooks() {
3024
3723
  let handle;
@@ -3026,7 +3725,6 @@ async function get_hooks() {
3026
3725
  let handleError;
3027
3726
  let handleValidationError;
3028
3727
  let init;
3029
- ({ handle, handleFetch, handleError, handleValidationError, init } = await import('./chunks/hooks.server-CQhG9POo.js'));
3030
3728
  let reroute;
3031
3729
  let transport;
3032
3730
  return {
@@ -3055,6 +3753,294 @@ function parse_remote_arg(string, transport) {
3055
3753
  const decoders = Object.fromEntries(Object.entries(transport).map(([k, v]) => [k, v.decode]));
3056
3754
  return parse(json_string, decoders);
3057
3755
  }
3756
+ function create_remote_cache_key(id, payload) {
3757
+ return id + "/" + payload;
3758
+ }
3759
+
3760
+ var cookie = {};
3761
+
3762
+ /*!
3763
+ * cookie
3764
+ * Copyright(c) 2012-2014 Roman Shtylman
3765
+ * Copyright(c) 2015 Douglas Christopher Wilson
3766
+ * MIT Licensed
3767
+ */
3768
+
3769
+ var hasRequiredCookie;
3770
+
3771
+ function requireCookie () {
3772
+ if (hasRequiredCookie) return cookie;
3773
+ hasRequiredCookie = 1;
3774
+
3775
+ /**
3776
+ * Module exports.
3777
+ * @public
3778
+ */
3779
+
3780
+ cookie.parse = parse;
3781
+ cookie.serialize = serialize;
3782
+
3783
+ /**
3784
+ * Module variables.
3785
+ * @private
3786
+ */
3787
+
3788
+ var __toString = Object.prototype.toString;
3789
+
3790
+ /**
3791
+ * RegExp to match field-content in RFC 7230 sec 3.2
3792
+ *
3793
+ * field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ]
3794
+ * field-vchar = VCHAR / obs-text
3795
+ * obs-text = %x80-FF
3796
+ */
3797
+
3798
+ var fieldContentRegExp = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;
3799
+
3800
+ /**
3801
+ * Parse a cookie header.
3802
+ *
3803
+ * Parse the given cookie header string into an object
3804
+ * The object has the various cookies as keys(names) => values
3805
+ *
3806
+ * @param {string} str
3807
+ * @param {object} [options]
3808
+ * @return {object}
3809
+ * @public
3810
+ */
3811
+
3812
+ function parse(str, options) {
3813
+ if (typeof str !== 'string') {
3814
+ throw new TypeError('argument str must be a string');
3815
+ }
3816
+
3817
+ var obj = {};
3818
+ var opt = options || {};
3819
+ var dec = opt.decode || decode;
3820
+
3821
+ var index = 0;
3822
+ while (index < str.length) {
3823
+ var eqIdx = str.indexOf('=', index);
3824
+
3825
+ // no more cookie pairs
3826
+ if (eqIdx === -1) {
3827
+ break
3828
+ }
3829
+
3830
+ var endIdx = str.indexOf(';', index);
3831
+
3832
+ if (endIdx === -1) {
3833
+ endIdx = str.length;
3834
+ } else if (endIdx < eqIdx) {
3835
+ // backtrack on prior semicolon
3836
+ index = str.lastIndexOf(';', eqIdx - 1) + 1;
3837
+ continue
3838
+ }
3839
+
3840
+ var key = str.slice(index, eqIdx).trim();
3841
+
3842
+ // only assign once
3843
+ if (undefined === obj[key]) {
3844
+ var val = str.slice(eqIdx + 1, endIdx).trim();
3845
+
3846
+ // quoted values
3847
+ if (val.charCodeAt(0) === 0x22) {
3848
+ val = val.slice(1, -1);
3849
+ }
3850
+
3851
+ obj[key] = tryDecode(val, dec);
3852
+ }
3853
+
3854
+ index = endIdx + 1;
3855
+ }
3856
+
3857
+ return obj;
3858
+ }
3859
+
3860
+ /**
3861
+ * Serialize data into a cookie header.
3862
+ *
3863
+ * Serialize the a name value pair into a cookie string suitable for
3864
+ * http headers. An optional options object specified cookie parameters.
3865
+ *
3866
+ * serialize('foo', 'bar', { httpOnly: true })
3867
+ * => "foo=bar; httpOnly"
3868
+ *
3869
+ * @param {string} name
3870
+ * @param {string} val
3871
+ * @param {object} [options]
3872
+ * @return {string}
3873
+ * @public
3874
+ */
3875
+
3876
+ function serialize(name, val, options) {
3877
+ var opt = options || {};
3878
+ var enc = opt.encode || encode;
3879
+
3880
+ if (typeof enc !== 'function') {
3881
+ throw new TypeError('option encode is invalid');
3882
+ }
3883
+
3884
+ if (!fieldContentRegExp.test(name)) {
3885
+ throw new TypeError('argument name is invalid');
3886
+ }
3887
+
3888
+ var value = enc(val);
3889
+
3890
+ if (value && !fieldContentRegExp.test(value)) {
3891
+ throw new TypeError('argument val is invalid');
3892
+ }
3893
+
3894
+ var str = name + '=' + value;
3895
+
3896
+ if (null != opt.maxAge) {
3897
+ var maxAge = opt.maxAge - 0;
3898
+
3899
+ if (isNaN(maxAge) || !isFinite(maxAge)) {
3900
+ throw new TypeError('option maxAge is invalid')
3901
+ }
3902
+
3903
+ str += '; Max-Age=' + Math.floor(maxAge);
3904
+ }
3905
+
3906
+ if (opt.domain) {
3907
+ if (!fieldContentRegExp.test(opt.domain)) {
3908
+ throw new TypeError('option domain is invalid');
3909
+ }
3910
+
3911
+ str += '; Domain=' + opt.domain;
3912
+ }
3913
+
3914
+ if (opt.path) {
3915
+ if (!fieldContentRegExp.test(opt.path)) {
3916
+ throw new TypeError('option path is invalid');
3917
+ }
3918
+
3919
+ str += '; Path=' + opt.path;
3920
+ }
3921
+
3922
+ if (opt.expires) {
3923
+ var expires = opt.expires;
3924
+
3925
+ if (!isDate(expires) || isNaN(expires.valueOf())) {
3926
+ throw new TypeError('option expires is invalid');
3927
+ }
3928
+
3929
+ str += '; Expires=' + expires.toUTCString();
3930
+ }
3931
+
3932
+ if (opt.httpOnly) {
3933
+ str += '; HttpOnly';
3934
+ }
3935
+
3936
+ if (opt.secure) {
3937
+ str += '; Secure';
3938
+ }
3939
+
3940
+ if (opt.partitioned) {
3941
+ str += '; Partitioned';
3942
+ }
3943
+
3944
+ if (opt.priority) {
3945
+ var priority = typeof opt.priority === 'string'
3946
+ ? opt.priority.toLowerCase()
3947
+ : opt.priority;
3948
+
3949
+ switch (priority) {
3950
+ case 'low':
3951
+ str += '; Priority=Low';
3952
+ break
3953
+ case 'medium':
3954
+ str += '; Priority=Medium';
3955
+ break
3956
+ case 'high':
3957
+ str += '; Priority=High';
3958
+ break
3959
+ default:
3960
+ throw new TypeError('option priority is invalid')
3961
+ }
3962
+ }
3963
+
3964
+ if (opt.sameSite) {
3965
+ var sameSite = typeof opt.sameSite === 'string'
3966
+ ? opt.sameSite.toLowerCase() : opt.sameSite;
3967
+
3968
+ switch (sameSite) {
3969
+ case true:
3970
+ str += '; SameSite=Strict';
3971
+ break;
3972
+ case 'lax':
3973
+ str += '; SameSite=Lax';
3974
+ break;
3975
+ case 'strict':
3976
+ str += '; SameSite=Strict';
3977
+ break;
3978
+ case 'none':
3979
+ str += '; SameSite=None';
3980
+ break;
3981
+ default:
3982
+ throw new TypeError('option sameSite is invalid');
3983
+ }
3984
+ }
3985
+
3986
+ return str;
3987
+ }
3988
+
3989
+ /**
3990
+ * URL-decode string value. Optimized to skip native call when no %.
3991
+ *
3992
+ * @param {string} str
3993
+ * @returns {string}
3994
+ */
3995
+
3996
+ function decode (str) {
3997
+ return str.indexOf('%') !== -1
3998
+ ? decodeURIComponent(str)
3999
+ : str
4000
+ }
4001
+
4002
+ /**
4003
+ * URL-encode value.
4004
+ *
4005
+ * @param {string} val
4006
+ * @returns {string}
4007
+ */
4008
+
4009
+ function encode (val) {
4010
+ return encodeURIComponent(val)
4011
+ }
4012
+
4013
+ /**
4014
+ * Determine if value is a Date.
4015
+ *
4016
+ * @param {*} val
4017
+ * @private
4018
+ */
4019
+
4020
+ function isDate (val) {
4021
+ return __toString.call(val) === '[object Date]' ||
4022
+ val instanceof Date
4023
+ }
4024
+
4025
+ /**
4026
+ * Try decoding a string using a decoding function.
4027
+ *
4028
+ * @param {string} str
4029
+ * @param {function} decode
4030
+ * @private
4031
+ */
4032
+
4033
+ function tryDecode(str, decode) {
4034
+ try {
4035
+ return decode(str);
4036
+ } catch (e) {
4037
+ return str;
4038
+ }
4039
+ }
4040
+ return cookie;
4041
+ }
4042
+
4043
+ var cookieExports = requireCookie();
3058
4044
 
3059
4045
  var setCookie = {exports: {}};
3060
4046
 
@@ -3070,6 +4056,14 @@ function requireSetCookie () {
3070
4056
  silent: false,
3071
4057
  };
3072
4058
 
4059
+ function isForbiddenKey(key) {
4060
+ return typeof key !== "string" || key in {};
4061
+ }
4062
+
4063
+ function createNullObj() {
4064
+ return Object.create(null);
4065
+ }
4066
+
3073
4067
  function isNonEmptyString(str) {
3074
4068
  return typeof str === "string" && !!str.trim();
3075
4069
  }
@@ -3086,30 +4080,35 @@ function requireSetCookie () {
3086
4080
  ? Object.assign({}, defaultParseOptions, options)
3087
4081
  : defaultParseOptions;
3088
4082
 
4083
+ if (isForbiddenKey(name)) {
4084
+ return null;
4085
+ }
4086
+
3089
4087
  try {
3090
4088
  value = options.decodeValues ? decodeURIComponent(value) : value; // decode cookie value
3091
4089
  } catch (e) {
3092
4090
  console.error(
3093
- "set-cookie-parser encountered an error while decoding a cookie with value '" +
3094
- value +
3095
- "'. Set options.decodeValues to false to disable this feature.",
4091
+ "set-cookie-parser: failed to decode cookie value. Set options.decodeValues=false to disable decoding.",
3096
4092
  e
3097
4093
  );
3098
4094
  }
3099
4095
 
3100
- var cookie = {
3101
- name: name,
3102
- value: value,
3103
- };
4096
+ var cookie = createNullObj();
4097
+ cookie.name = name;
4098
+ cookie.value = value;
3104
4099
 
3105
4100
  parts.forEach(function (part) {
3106
4101
  var sides = part.split("=");
3107
4102
  var key = sides.shift().trimLeft().toLowerCase();
4103
+ if (isForbiddenKey(key)) {
4104
+ return;
4105
+ }
3108
4106
  var value = sides.join("=");
3109
4107
  if (key === "expires") {
3110
4108
  cookie.expires = new Date(value);
3111
4109
  } else if (key === "max-age") {
3112
- cookie.maxAge = parseInt(value, 10);
4110
+ var n = parseInt(value, 10);
4111
+ if (!Number.isNaN(n)) cookie.maxAge = n;
3113
4112
  } else if (key === "secure") {
3114
4113
  cookie.secure = true;
3115
4114
  } else if (key === "httponly") {
@@ -3118,7 +4117,7 @@ function requireSetCookie () {
3118
4117
  cookie.sameSite = value;
3119
4118
  } else if (key === "partitioned") {
3120
4119
  cookie.partitioned = true;
3121
- } else {
4120
+ } else if (key) {
3122
4121
  cookie[key] = value;
3123
4122
  }
3124
4123
  });
@@ -3151,7 +4150,7 @@ function requireSetCookie () {
3151
4150
  if (!options.map) {
3152
4151
  return [];
3153
4152
  } else {
3154
- return {};
4153
+ return createNullObj();
3155
4154
  }
3156
4155
  }
3157
4156
 
@@ -3161,7 +4160,7 @@ function requireSetCookie () {
3161
4160
  // but getSetCookie returns an uncombined array
3162
4161
  input = input.headers.getSetCookie();
3163
4162
  } else if (input.headers["set-cookie"]) {
3164
- // fast-path for node.js (which automatically normalizes header names to lower-case
4163
+ // fast-path for node.js (which automatically normalizes header names to lower-case)
3165
4164
  input = input.headers["set-cookie"];
3166
4165
  } else {
3167
4166
  // slow-path for other environments - see #25
@@ -3185,14 +4184,19 @@ function requireSetCookie () {
3185
4184
  }
3186
4185
 
3187
4186
  if (!options.map) {
3188
- return input.filter(isNonEmptyString).map(function (str) {
3189
- return parseString(str, options);
3190
- });
4187
+ return input
4188
+ .filter(isNonEmptyString)
4189
+ .map(function (str) {
4190
+ return parseString(str, options);
4191
+ })
4192
+ .filter(Boolean);
3191
4193
  } else {
3192
- var cookies = {};
4194
+ var cookies = createNullObj();
3193
4195
  return input.filter(isNonEmptyString).reduce(function (cookies, str) {
3194
4196
  var cookie = parseString(str, options);
3195
- cookies[cookie.name] = cookie;
4197
+ if (cookie && !isForbiddenKey(cookie.name)) {
4198
+ cookies[cookie.name] = cookie;
4199
+ }
3196
4200
  return cookies;
3197
4201
  }, cookies);
3198
4202
  }
@@ -3291,6 +4295,17 @@ function requireSetCookie () {
3291
4295
 
3292
4296
  var setCookieExports = /*@__PURE__*/ requireSetCookie();
3293
4297
 
4298
+ function with_resolvers() {
4299
+ let resolve2;
4300
+ let reject;
4301
+ const promise = new Promise((res, rej) => {
4302
+ resolve2 = res;
4303
+ reject = rej;
4304
+ });
4305
+ return { promise, resolve: resolve2, reject };
4306
+ }
4307
+ const NULL_BODY_STATUS = [101, 103, 204, 205, 304];
4308
+ const IN_WEBCONTAINER = !!globalThis.process?.versions?.webcontainer;
3294
4309
  const SVELTE_KIT_ASSETS = "/_svelte_kit_assets";
3295
4310
  const ENDPOINT_METHODS = ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS", "HEAD"];
3296
4311
  const PAGE_METHODS = ["GET", "POST", "HEAD"];
@@ -3406,9 +4421,14 @@ function method_not_allowed(mod, method) {
3406
4421
  }
3407
4422
  function allowed_methods(mod) {
3408
4423
  const allowed = ENDPOINT_METHODS.filter((method) => method in mod);
3409
- if ("GET" in mod || "HEAD" in mod) allowed.push("HEAD");
4424
+ if ("GET" in mod && !("HEAD" in mod)) {
4425
+ allowed.push("HEAD");
4426
+ }
3410
4427
  return allowed;
3411
4428
  }
4429
+ function get_global_name(options2) {
4430
+ return `__sveltekit_${options2.version_hash}`;
4431
+ }
3412
4432
  function static_error_page(options2, status, message) {
3413
4433
  let page = options2.templates.error({ status, message: escape_html(message) });
3414
4434
  return text(page, {
@@ -3433,7 +4453,7 @@ async function handle_fatal_error(event, state, options2, error2) {
3433
4453
  }
3434
4454
  async function handle_error_and_jsonify(event, state, options2, error2) {
3435
4455
  if (error2 instanceof HttpError) {
3436
- return error2.body;
4456
+ return { message: "Unknown Error", ...error2.body };
3437
4457
  }
3438
4458
  const status = get_status(error2);
3439
4459
  const message = get_message(error2);
@@ -3477,6 +4497,15 @@ function serialize_uses(node) {
3477
4497
  function has_prerendered_path(manifest, pathname) {
3478
4498
  return manifest._.prerendered_routes.has(pathname) || pathname.at(-1) === "/" && manifest._.prerendered_routes.has(pathname.slice(0, -1));
3479
4499
  }
4500
+ function format_server_error(status, error2, event) {
4501
+ const formatted_text = `
4502
+ \x1B[1;31m[${status}] ${event.request.method} ${event.url.pathname}\x1B[0m`;
4503
+ if (status === 404) {
4504
+ return formatted_text;
4505
+ }
4506
+ return `${formatted_text}
4507
+ ${error2.stack}`;
4508
+ }
3480
4509
  function get_node_type(node_id) {
3481
4510
  const parts = node_id?.split("/");
3482
4511
  const filename = parts?.at(-1);
@@ -3507,6 +4536,7 @@ async function render_endpoint(event, event_state, mod, state) {
3507
4536
  return new Response(void 0, { status: 204 });
3508
4537
  }
3509
4538
  }
4539
+ event_state.is_endpoint_request = true;
3510
4540
  try {
3511
4541
  const response = await with_request_store(
3512
4542
  { event, state: event_state },
@@ -3669,7 +4699,7 @@ async function handle_action_json_request(event, event_state, options2, server)
3669
4699
  check_named_default_separate(actions);
3670
4700
  try {
3671
4701
  const data = await call_action(event, event_state, actions);
3672
- if (false) ;
4702
+ if (DEV) ;
3673
4703
  if (data instanceof ActionFailure) {
3674
4704
  return action_json({
3675
4705
  type: "failure",
@@ -3754,7 +4784,7 @@ async function handle_action_request(event, event_state, server) {
3754
4784
  check_named_default_separate(actions);
3755
4785
  try {
3756
4786
  const data = await call_action(event, event_state, actions);
3757
- if (false) ;
4787
+ if (DEV) ;
3758
4788
  if (data instanceof ActionFailure) {
3759
4789
  return {
3760
4790
  type: "failure",
@@ -3821,14 +4851,14 @@ async function call_action(event, event_state, actions) {
3821
4851
  attributes: {
3822
4852
  "http.route": event.route.id || "unknown"
3823
4853
  },
3824
- fn: async (current) => {
3825
- const traced_event = merge_tracing(event, current);
4854
+ fn: async (current2) => {
4855
+ const traced_event = merge_tracing(event, current2);
3826
4856
  const result = await with_request_store(
3827
4857
  { event: traced_event, state: event_state },
3828
4858
  () => action(traced_event)
3829
4859
  );
3830
4860
  if (result instanceof ActionFailure) {
3831
- current.setAttributes({
4861
+ current2.setAttributes({
3832
4862
  "sveltekit.form_action.result.type": "failure",
3833
4863
  "sveltekit.form_action.result.status": result.status
3834
4864
  });
@@ -3875,62 +4905,270 @@ function try_serialize(data, fn, route_id) {
3875
4905
  throw error2;
3876
4906
  }
3877
4907
  }
3878
- async function load_server_data({ event, event_state, state, node, parent }) {
3879
- if (!node?.server) return null;
3880
- let is_tracking = true;
3881
- const uses = {
3882
- dependencies: /* @__PURE__ */ new Set(),
3883
- params: /* @__PURE__ */ new Set(),
3884
- parent: false,
3885
- route: false,
3886
- url: false,
3887
- search_params: /* @__PURE__ */ new Set()
4908
+ function create_async_iterator() {
4909
+ let resolved = -1;
4910
+ let returned = -1;
4911
+ const deferred = [];
4912
+ return {
4913
+ iterate: (transform = (x) => x) => {
4914
+ return {
4915
+ [Symbol.asyncIterator]() {
4916
+ return {
4917
+ next: async () => {
4918
+ const next = deferred[++returned];
4919
+ if (!next) return { value: null, done: true };
4920
+ const value = await next.promise;
4921
+ return { value: transform(value), done: false };
4922
+ }
4923
+ };
4924
+ }
4925
+ };
4926
+ },
4927
+ add: (promise) => {
4928
+ deferred.push(with_resolvers());
4929
+ void promise.then((value) => {
4930
+ deferred[++resolved].resolve(value);
4931
+ });
4932
+ }
3888
4933
  };
3889
- const load = node.server.load;
3890
- const slash = node.server.trailingSlash;
3891
- if (!load) {
3892
- return { type: "data", data: null, uses, slash };
3893
- }
3894
- const url = make_trackable(
3895
- event.url,
3896
- () => {
3897
- if (is_tracking) {
3898
- uses.url = true;
4934
+ }
4935
+ function server_data_serializer(event, event_state, options2) {
4936
+ let promise_id = 1;
4937
+ let max_nodes = -1;
4938
+ const iterator = create_async_iterator();
4939
+ const global = get_global_name(options2);
4940
+ function get_replacer(index) {
4941
+ return function replacer(thing) {
4942
+ if (typeof thing?.then === "function") {
4943
+ const id = promise_id++;
4944
+ const promise = thing.then(
4945
+ /** @param {any} data */
4946
+ (data) => ({ data })
4947
+ ).catch(
4948
+ /** @param {any} error */
4949
+ async (error2) => ({
4950
+ error: await handle_error_and_jsonify(event, event_state, options2, error2)
4951
+ })
4952
+ ).then(
4953
+ /**
4954
+ * @param {{data: any; error: any}} result
4955
+ */
4956
+ async ({ data, error: error2 }) => {
4957
+ let str;
4958
+ try {
4959
+ str = uneval(error2 ? [, error2] : [data], replacer);
4960
+ } catch {
4961
+ error2 = await handle_error_and_jsonify(
4962
+ event,
4963
+ event_state,
4964
+ options2,
4965
+ new Error(`Failed to serialize promise while rendering ${event.route.id}`)
4966
+ );
4967
+ data = void 0;
4968
+ str = uneval([, error2], replacer);
4969
+ }
4970
+ return {
4971
+ index,
4972
+ str: `${global}.resolve(${id}, ${str.includes("app.decode") ? `(app) => ${str}` : `() => ${str}`})`
4973
+ };
4974
+ }
4975
+ );
4976
+ iterator.add(promise);
4977
+ return `${global}.defer(${id})`;
4978
+ } else {
4979
+ for (const key2 in options2.hooks.transport) {
4980
+ const encoded = options2.hooks.transport[key2].encode(thing);
4981
+ if (encoded) {
4982
+ return `app.decode('${key2}', ${uneval(encoded, replacer)})`;
4983
+ }
4984
+ }
3899
4985
  }
4986
+ };
4987
+ }
4988
+ const strings = (
4989
+ /** @type {string[]} */
4990
+ []
4991
+ );
4992
+ return {
4993
+ set_max_nodes(i) {
4994
+ max_nodes = i;
3900
4995
  },
3901
- (param) => {
3902
- if (is_tracking) {
3903
- uses.search_params.add(param);
4996
+ add_node(i, node) {
4997
+ try {
4998
+ if (!node) {
4999
+ strings[i] = "null";
5000
+ return;
5001
+ }
5002
+ const payload = { type: "data", data: node.data, uses: serialize_uses(node) };
5003
+ if (node.slash) payload.slash = node.slash;
5004
+ strings[i] = uneval(payload, get_replacer(i));
5005
+ } catch (e) {
5006
+ e.path = e.path.slice(1);
5007
+ throw new Error(clarify_devalue_error(
5008
+ event,
5009
+ /** @type {any} */
5010
+ e
5011
+ ));
3904
5012
  }
3905
- }
3906
- );
3907
- if (state.prerendering) {
3908
- disable_search(url);
3909
- }
3910
- const result = await record_span({
3911
- name: "sveltekit.load",
3912
- attributes: {
3913
- "sveltekit.load.node_id": node.server_id || "unknown",
3914
- "sveltekit.load.node_type": get_node_type(node.server_id),
3915
- "http.route": event.route.id || "unknown"
3916
5013
  },
3917
- fn: async (current) => {
3918
- const traced_event = merge_tracing(event, current);
3919
- const result2 = await with_request_store(
3920
- { event: traced_event, state: event_state },
3921
- () => load.call(null, {
3922
- ...traced_event,
3923
- fetch: (info, init2) => {
3924
- new URL(info instanceof Request ? info.url : info, event.url);
3925
- return event.fetch(info, init2);
3926
- },
3927
- /** @param {string[]} deps */
3928
- depends: (...deps) => {
3929
- for (const dep of deps) {
3930
- const { href } = new URL(dep, event.url);
3931
- uses.dependencies.add(href);
3932
- }
3933
- },
5014
+ get_data(csp) {
5015
+ const open = `<script${csp.script_needs_nonce ? ` nonce="${csp.nonce}"` : ""}>`;
5016
+ const close = `<\/script>
5017
+ `;
5018
+ return {
5019
+ data: `[${compact(max_nodes > -1 ? strings.slice(0, max_nodes) : strings).join(",")}]`,
5020
+ chunks: promise_id > 1 ? iterator.iterate(({ index, str }) => {
5021
+ if (max_nodes > -1 && index >= max_nodes) {
5022
+ return "";
5023
+ }
5024
+ return open + str + close;
5025
+ }) : null
5026
+ };
5027
+ }
5028
+ };
5029
+ }
5030
+ function server_data_serializer_json(event, event_state, options2) {
5031
+ let promise_id = 1;
5032
+ const iterator = create_async_iterator();
5033
+ const reducers = {
5034
+ ...Object.fromEntries(
5035
+ Object.entries(options2.hooks.transport).map(([key2, value]) => [key2, value.encode])
5036
+ ),
5037
+ /** @param {any} thing */
5038
+ Promise: (thing) => {
5039
+ if (typeof thing?.then !== "function") {
5040
+ return;
5041
+ }
5042
+ const id = promise_id++;
5043
+ let key2 = "data";
5044
+ const promise = thing.catch(
5045
+ /** @param {any} e */
5046
+ async (e) => {
5047
+ key2 = "error";
5048
+ return handle_error_and_jsonify(
5049
+ event,
5050
+ event_state,
5051
+ options2,
5052
+ /** @type {any} */
5053
+ e
5054
+ );
5055
+ }
5056
+ ).then(
5057
+ /** @param {any} value */
5058
+ async (value) => {
5059
+ let str;
5060
+ try {
5061
+ str = stringify$1(value, reducers);
5062
+ } catch {
5063
+ const error2 = await handle_error_and_jsonify(
5064
+ event,
5065
+ event_state,
5066
+ options2,
5067
+ new Error(`Failed to serialize promise while rendering ${event.route.id}`)
5068
+ );
5069
+ key2 = "error";
5070
+ str = stringify$1(error2, reducers);
5071
+ }
5072
+ return `{"type":"chunk","id":${id},"${key2}":${str}}
5073
+ `;
5074
+ }
5075
+ );
5076
+ iterator.add(promise);
5077
+ return id;
5078
+ }
5079
+ };
5080
+ const strings = (
5081
+ /** @type {string[]} */
5082
+ []
5083
+ );
5084
+ return {
5085
+ add_node(i, node) {
5086
+ try {
5087
+ if (!node) {
5088
+ strings[i] = "null";
5089
+ return;
5090
+ }
5091
+ if (node.type === "error" || node.type === "skip") {
5092
+ strings[i] = JSON.stringify(node);
5093
+ return;
5094
+ }
5095
+ strings[i] = `{"type":"data","data":${stringify$1(node.data, reducers)},"uses":${JSON.stringify(
5096
+ serialize_uses(node)
5097
+ )}${node.slash ? `,"slash":${JSON.stringify(node.slash)}` : ""}}`;
5098
+ } catch (e) {
5099
+ e.path = "data" + e.path;
5100
+ throw new Error(clarify_devalue_error(
5101
+ event,
5102
+ /** @type {any} */
5103
+ e
5104
+ ));
5105
+ }
5106
+ },
5107
+ get_data() {
5108
+ return {
5109
+ data: `{"type":"data","nodes":[${strings.join(",")}]}
5110
+ `,
5111
+ chunks: promise_id > 1 ? iterator.iterate() : null
5112
+ };
5113
+ }
5114
+ };
5115
+ }
5116
+ async function load_server_data({ event, event_state, state, node, parent }) {
5117
+ if (!node?.server) return null;
5118
+ let is_tracking = true;
5119
+ const uses = {
5120
+ dependencies: /* @__PURE__ */ new Set(),
5121
+ params: /* @__PURE__ */ new Set(),
5122
+ parent: false,
5123
+ route: false,
5124
+ url: false,
5125
+ search_params: /* @__PURE__ */ new Set()
5126
+ };
5127
+ const load = node.server.load;
5128
+ const slash = node.server.trailingSlash;
5129
+ if (!load) {
5130
+ return { type: "data", data: null, uses, slash };
5131
+ }
5132
+ const url = make_trackable(
5133
+ event.url,
5134
+ () => {
5135
+ if (is_tracking) {
5136
+ uses.url = true;
5137
+ }
5138
+ },
5139
+ (param) => {
5140
+ if (is_tracking) {
5141
+ uses.search_params.add(param);
5142
+ }
5143
+ }
5144
+ );
5145
+ if (state.prerendering) {
5146
+ disable_search(url);
5147
+ }
5148
+ const result = await record_span({
5149
+ name: "sveltekit.load",
5150
+ attributes: {
5151
+ "sveltekit.load.node_id": node.server_id || "unknown",
5152
+ "sveltekit.load.node_type": get_node_type(node.server_id),
5153
+ "http.route": event.route.id || "unknown"
5154
+ },
5155
+ fn: async (current2) => {
5156
+ const traced_event = merge_tracing(event, current2);
5157
+ const result2 = await with_request_store(
5158
+ { event: traced_event, state: event_state },
5159
+ () => load.call(null, {
5160
+ ...traced_event,
5161
+ fetch: (info, init2) => {
5162
+ new URL(info instanceof Request ? info.url : info, event.url);
5163
+ return event.fetch(info, init2);
5164
+ },
5165
+ /** @param {string[]} deps */
5166
+ depends: (...deps) => {
5167
+ for (const dep of deps) {
5168
+ const { href } = new URL(dep, event.url);
5169
+ uses.dependencies.add(href);
5170
+ }
5171
+ },
3934
5172
  params: new Proxy(event.params, {
3935
5173
  get: (target, key2) => {
3936
5174
  if (is_tracking) {
@@ -4003,8 +5241,8 @@ async function load_data({
4003
5241
  "sveltekit.load.node_type": get_node_type(node.universal_id),
4004
5242
  "http.route": event.route.id || "unknown"
4005
5243
  },
4006
- fn: async (current) => {
4007
- const traced_event = merge_tracing(event, current);
5244
+ fn: async (current2) => {
5245
+ const traced_event = merge_tracing(event, current2);
4008
5246
  return await with_request_store(
4009
5247
  { event: traced_event, state: event_state },
4010
5248
  () => load.call(null, {
@@ -4116,6 +5354,10 @@ function create_universal_fetch(event, state, fetched, csr, resolve_opts) {
4116
5354
  }
4117
5355
  async function text2() {
4118
5356
  const body2 = await response2.text();
5357
+ if (body2 === "" && NULL_BODY_STATUS.includes(response2.status)) {
5358
+ await push_fetched(void 0, false);
5359
+ return void 0;
5360
+ }
4119
5361
  if (!body2 || typeof body2 === "string") {
4120
5362
  await push_fetched(body2, false);
4121
5363
  }
@@ -4129,7 +5371,8 @@ function create_universal_fetch(event, state, fetched, csr, resolve_opts) {
4129
5371
  }
4130
5372
  if (key2 === "json") {
4131
5373
  return async () => {
4132
- return JSON.parse(await text2());
5374
+ const body2 = await text2();
5375
+ return body2 ? JSON.parse(body2) : void 0;
4133
5376
  };
4134
5377
  }
4135
5378
  return Reflect.get(response2, key2, response2);
@@ -4194,7 +5437,7 @@ const replacements = {
4194
5437
  "\u2029": "\\u2029"
4195
5438
  };
4196
5439
  const pattern = new RegExp(`[${Object.keys(replacements).join("")}]`, "g");
4197
- function serialize_data(fetched, filter, prerendering2 = false) {
5440
+ function serialize_data(fetched, filter, prerendering = false) {
4198
5441
  const headers2 = {};
4199
5442
  let cache_control = null;
4200
5443
  let age = null;
@@ -4232,7 +5475,7 @@ function serialize_data(fetched, filter, prerendering2 = false) {
4232
5475
  }
4233
5476
  attrs.push(`data-hash="${hash(...values)}"`);
4234
5477
  }
4235
- if (!prerendering2 && fetched.method === "GET" && cache_control && !varyAny) {
5478
+ if (!prerendering && fetched.method === "GET" && cache_control && !varyAny) {
4236
5479
  const match = /s-maxage=(\d+)/g.exec(cache_control) ?? /max-age=(\d+)/g.exec(cache_control);
4237
5480
  if (match) {
4238
5481
  const ttl = +match[1] - +(age ?? "0");
@@ -4571,41 +5814,6 @@ class Csp {
4571
5814
  this.report_only_provider.add_style(content);
4572
5815
  }
4573
5816
  }
4574
- function defer() {
4575
- let fulfil;
4576
- let reject;
4577
- const promise = new Promise((f, r) => {
4578
- fulfil = f;
4579
- reject = r;
4580
- });
4581
- return { promise, fulfil, reject };
4582
- }
4583
- function create_async_iterator() {
4584
- const deferred = [defer()];
4585
- return {
4586
- iterator: {
4587
- [Symbol.asyncIterator]() {
4588
- return {
4589
- next: async () => {
4590
- const next = await deferred[0].promise;
4591
- if (!next.done) deferred.shift();
4592
- return next;
4593
- }
4594
- };
4595
- }
4596
- },
4597
- push: (value) => {
4598
- deferred[deferred.length - 1].fulfil({
4599
- value,
4600
- done: false
4601
- });
4602
- deferred.push(defer());
4603
- },
4604
- done: () => {
4605
- deferred[deferred.length - 1].fulfil({ done: true });
4606
- }
4607
- };
4608
- }
4609
5817
  function exec(match, params, matchers) {
4610
5818
  const result = {};
4611
5819
  const values = match.slice(1);
@@ -4735,7 +5943,8 @@ async function render_response({
4735
5943
  event,
4736
5944
  event_state,
4737
5945
  resolve_opts,
4738
- action_result
5946
+ action_result,
5947
+ data_serializer
4739
5948
  }) {
4740
5949
  if (state.prerendering) {
4741
5950
  if (options2.csp.mode === "nonce") {
@@ -4749,7 +5958,8 @@ async function render_response({
4749
5958
  const modulepreloads = new Set(client.imports);
4750
5959
  const stylesheets = new Set(client.stylesheets);
4751
5960
  const fonts = new Set(client.fonts);
4752
- const link_header_preloads = /* @__PURE__ */ new Set();
5961
+ const link_headers = /* @__PURE__ */ new Set();
5962
+ const link_tags = /* @__PURE__ */ new Set();
4753
5963
  const inline_styles = /* @__PURE__ */ new Map();
4754
5964
  let rendered;
4755
5965
  const form_value = action_result?.type === "success" || action_result?.type === "failure" ? action_result.data ?? null : null;
@@ -4803,7 +6013,6 @@ async function render_response({
4803
6013
  form: form_value,
4804
6014
  state: {}
4805
6015
  };
4806
- override({ base: base$1, assets: assets$1 });
4807
6016
  const render_opts = {
4808
6017
  context: /* @__PURE__ */ new Map([
4809
6018
  [
@@ -4814,15 +6023,23 @@ async function render_response({
4814
6023
  ]
4815
6024
  ])
4816
6025
  };
4817
- {
4818
- try {
4819
- rendered = with_request_store(
4820
- { event, state: event_state },
4821
- () => options2.root.render(props, render_opts)
4822
- );
4823
- } finally {
4824
- reset();
4825
- }
6026
+ try {
6027
+ if (DEV) ;
6028
+ rendered = await with_request_store({ event, state: event_state }, async () => {
6029
+ if (relative) override({ base: base$1, assets: assets$1 });
6030
+ const maybe_promise = options2.root.render(props, render_opts);
6031
+ const rendered2 = options2.async && "then" in maybe_promise ? (
6032
+ /** @type {ReturnType<typeof options.root.render> & Promise<any>} */
6033
+ maybe_promise.then((r) => r)
6034
+ ) : maybe_promise;
6035
+ if (options2.async) {
6036
+ reset();
6037
+ }
6038
+ const { head: head2, html: html2, css } = options2.async ? await rendered2 : rendered2;
6039
+ return { head: head2, html: html2, css };
6040
+ });
6041
+ } finally {
6042
+ reset();
4826
6043
  }
4827
6044
  for (const { node } of branch) {
4828
6045
  for (const url of node.imports) modulepreloads.add(url);
@@ -4861,8 +6078,7 @@ async function render_response({
4861
6078
  attributes.push("disabled", 'media="(max-width: 0)"');
4862
6079
  } else {
4863
6080
  if (resolve_opts.preload({ type: "css", path })) {
4864
- const preload_atts = ['rel="preload"', 'as="style"'];
4865
- link_header_preloads.add(`<${encodeURI(path)}>; ${preload_atts.join(";")}; nopush`);
6081
+ link_headers.add(`<${encodeURI(path)}>; rel="preload"; as="style"; nopush`);
4866
6082
  }
4867
6083
  }
4868
6084
  head += `
@@ -4872,26 +6088,14 @@ async function render_response({
4872
6088
  const path = prefixed(dep);
4873
6089
  if (resolve_opts.preload({ type: "font", path })) {
4874
6090
  const ext = dep.slice(dep.lastIndexOf(".") + 1);
4875
- const attributes = [
4876
- 'rel="preload"',
4877
- 'as="font"',
4878
- `type="font/${ext}"`,
4879
- `href="${path}"`,
4880
- "crossorigin"
4881
- ];
4882
- head += `
4883
- <link ${attributes.join(" ")}>`;
6091
+ link_tags.add(`<link rel="preload" as="font" type="font/${ext}" href="${path}" crossorigin>`);
6092
+ link_headers.add(
6093
+ `<${encodeURI(path)}>; rel="preload"; as="font"; type="font/${ext}"; crossorigin; nopush`
6094
+ );
4884
6095
  }
4885
6096
  }
4886
- const global = `__sveltekit_${options2.version_hash}`;
4887
- const { data, chunks } = get_data(
4888
- event,
4889
- event_state,
4890
- options2,
4891
- branch.map((b) => b.server_data),
4892
- csp,
4893
- global
4894
- );
6097
+ const global = get_global_name(options2);
6098
+ const { data, chunks } = data_serializer.get_data(csp);
4895
6099
  if (page_config.ssr && page_config.csr) {
4896
6100
  body2 += `
4897
6101
  ${fetched.map(
@@ -4908,16 +6112,19 @@ async function render_response({
4908
6112
  (path) => resolve_opts.preload({ type: "js", path })
4909
6113
  );
4910
6114
  for (const path of included_modulepreloads) {
4911
- link_header_preloads.add(`<${encodeURI(path)}>; rel="modulepreload"; nopush`);
6115
+ link_headers.add(`<${encodeURI(path)}>; rel="modulepreload"; nopush`);
4912
6116
  if (options2.preload_strategy !== "modulepreload") {
4913
6117
  head += `
4914
6118
  <link rel="preload" as="script" crossorigin="anonymous" href="${path}">`;
4915
- } else if (state.prerendering) {
4916
- head += `
4917
- <link rel="modulepreload" href="${path}">`;
6119
+ } else {
6120
+ link_tags.add(`<link rel="modulepreload" href="${path}">`);
4918
6121
  }
4919
6122
  }
4920
6123
  }
6124
+ if (state.prerendering && link_tags.size > 0) {
6125
+ head += Array.from(link_tags).map((tag) => `
6126
+ ${tag}`).join("");
6127
+ }
4921
6128
  if (manifest._.client.routes && state.prerendering && !state.prerendering.fallback) {
4922
6129
  const pathname = add_resolution_suffix(event.url.pathname);
4923
6130
  state.prerendering.dependencies.set(
@@ -4939,7 +6146,21 @@ async function render_response({
4939
6146
  properties.push(`defer: (id) => new Promise((fulfil, reject) => {
4940
6147
  deferred.set(id, { fulfil, reject });
4941
6148
  })`);
4942
- properties.push(`resolve: ({ id, data, error }) => {
6149
+ let app_declaration = "";
6150
+ if (Object.keys(options2.hooks.transport).length > 0) {
6151
+ if (client.inline) {
6152
+ app_declaration = `const app = __sveltekit_${options2.version_hash}.app.app;`;
6153
+ } else if (client.app) {
6154
+ app_declaration = `const app = await import(${s(prefixed(client.app))});`;
6155
+ } else {
6156
+ app_declaration = `const { app } = await import(${s(prefixed(client.start))});`;
6157
+ }
6158
+ }
6159
+ const prelude = app_declaration ? `${app_declaration}
6160
+ const [data, error] = fn(app);` : `const [data, error] = fn();`;
6161
+ properties.push(`resolve: async (id, fn) => {
6162
+ ${prelude}
6163
+
4943
6164
  const try_to_resolve = () => {
4944
6165
  if (!deferred.has(id)) {
4945
6166
  setTimeout(try_to_resolve, 0);
@@ -4953,22 +6174,6 @@ async function render_response({
4953
6174
  try_to_resolve();
4954
6175
  }`);
4955
6176
  }
4956
- const { remote_data } = event_state;
4957
- if (remote_data) {
4958
- const remote = {};
4959
- for (const key2 in remote_data) {
4960
- remote[key2] = await remote_data[key2];
4961
- }
4962
- const replacer = (thing) => {
4963
- for (const key2 in options2.hooks.transport) {
4964
- const encoded = options2.hooks.transport[key2].encode(thing);
4965
- if (encoded) {
4966
- return `app.decode('${key2}', ${uneval(encoded, replacer)})`;
4967
- }
4968
- }
4969
- };
4970
- properties.push(`data: ${uneval(remote, replacer)}`);
4971
- }
4972
6177
  blocks.push(`${global} = {
4973
6178
  ${properties.join(",\n ")}
4974
6179
  };`);
@@ -5013,15 +6218,37 @@ ${indent} ${hydrate.join(`,
5013
6218
  ${indent} `)}
5014
6219
  ${indent}}`);
5015
6220
  }
6221
+ const { remote_data: remote_cache } = event_state;
6222
+ let serialized_remote_data = "";
6223
+ if (remote_cache) {
6224
+ const remote = {};
6225
+ for (const [info, cache] of remote_cache) {
6226
+ if (!info.id) continue;
6227
+ for (const key2 in cache) {
6228
+ remote[create_remote_cache_key(info.id, key2)] = await cache[key2];
6229
+ }
6230
+ }
6231
+ const replacer = (thing) => {
6232
+ for (const key2 in options2.hooks.transport) {
6233
+ const encoded = options2.hooks.transport[key2].encode(thing);
6234
+ if (encoded) {
6235
+ return `app.decode('${key2}', ${uneval(encoded, replacer)})`;
6236
+ }
6237
+ }
6238
+ };
6239
+ serialized_remote_data = `${global}.data = ${uneval(remote, replacer)};
6240
+
6241
+ `;
6242
+ }
5016
6243
  const boot = client.inline ? `${client.inline.script}
5017
6244
 
5018
- __sveltekit_${options2.version_hash}.app.start(${args.join(", ")});` : client.app ? `Promise.all([
6245
+ ${serialized_remote_data}${global}.app.start(${args.join(", ")});` : client.app ? `Promise.all([
5019
6246
  import(${s(prefixed(client.start))}),
5020
6247
  import(${s(prefixed(client.app))})
5021
6248
  ]).then(([kit, app]) => {
5022
- kit.start(app, ${args.join(", ")});
6249
+ ${serialized_remote_data}kit.start(app, ${args.join(", ")});
5023
6250
  });` : `import(${s(prefixed(client.start))}).then((app) => {
5024
- app.start(${args.join(", ")})
6251
+ ${serialized_remote_data}app.start(${args.join(", ")})
5025
6252
  });`;
5026
6253
  if (load_env_eagerly) {
5027
6254
  blocks.push(`import(${s(`${base$1}/${app_dir}/env.js`)}).then(({ env }) => {
@@ -5079,8 +6306,8 @@ ${indent}}`);
5079
6306
  if (report_only_header) {
5080
6307
  headers2.set("content-security-policy-report-only", report_only_header);
5081
6308
  }
5082
- if (link_header_preloads.size) {
5083
- headers2.set("link", Array.from(link_header_preloads).join(", "));
6309
+ if (link_headers.size) {
6310
+ headers2.set("link", Array.from(link_headers).join(", "));
5084
6311
  }
5085
6312
  }
5086
6313
  head += rendered.head;
@@ -5092,7 +6319,7 @@ ${indent}}`);
5092
6319
  /** @type {string} */
5093
6320
  csp.nonce
5094
6321
  ),
5095
- env: safe_public_env
6322
+ env: public_env
5096
6323
  });
5097
6324
  const transformed = await resolve_opts.transformPageChunk({
5098
6325
  html,
@@ -5109,7 +6336,7 @@ ${indent}}`);
5109
6336
  async start(controller) {
5110
6337
  controller.enqueue(text_encoder.encode(transformed + "\n"));
5111
6338
  for await (const chunk of chunks) {
5112
- controller.enqueue(text_encoder.encode(chunk));
6339
+ if (chunk.length) controller.enqueue(text_encoder.encode(chunk));
5113
6340
  }
5114
6341
  controller.close();
5115
6342
  },
@@ -5120,77 +6347,6 @@ ${indent}}`);
5120
6347
  }
5121
6348
  );
5122
6349
  }
5123
- function get_data(event, event_state, options2, nodes, csp, global) {
5124
- let promise_id = 1;
5125
- let count = 0;
5126
- const { iterator, push, done } = create_async_iterator();
5127
- function replacer(thing) {
5128
- if (typeof thing?.then === "function") {
5129
- const id = promise_id++;
5130
- count += 1;
5131
- thing.then(
5132
- /** @param {any} data */
5133
- (data) => ({ data })
5134
- ).catch(
5135
- /** @param {any} error */
5136
- async (error2) => ({
5137
- error: await handle_error_and_jsonify(event, event_state, options2, error2)
5138
- })
5139
- ).then(
5140
- /**
5141
- * @param {{data: any; error: any}} result
5142
- */
5143
- async ({ data, error: error2 }) => {
5144
- count -= 1;
5145
- let str;
5146
- try {
5147
- str = uneval({ id, data, error: error2 }, replacer);
5148
- } catch {
5149
- error2 = await handle_error_and_jsonify(
5150
- event,
5151
- event_state,
5152
- options2,
5153
- new Error(`Failed to serialize promise while rendering ${event.route.id}`)
5154
- );
5155
- data = void 0;
5156
- str = uneval({ id, data, error: error2 }, replacer);
5157
- }
5158
- const nonce = csp.script_needs_nonce ? ` nonce="${csp.nonce}"` : "";
5159
- push(`<script${nonce}>${global}.resolve(${str})<\/script>
5160
- `);
5161
- if (count === 0) done();
5162
- }
5163
- );
5164
- return `${global}.defer(${id})`;
5165
- } else {
5166
- for (const key2 in options2.hooks.transport) {
5167
- const encoded = options2.hooks.transport[key2].encode(thing);
5168
- if (encoded) {
5169
- return `app.decode('${key2}', ${uneval(encoded, replacer)})`;
5170
- }
5171
- }
5172
- }
5173
- }
5174
- try {
5175
- const strings = nodes.map((node) => {
5176
- if (!node) return "null";
5177
- const payload = { type: "data", data: node.data, uses: serialize_uses(node) };
5178
- if (node.slash) payload.slash = node.slash;
5179
- return uneval(payload, replacer);
5180
- });
5181
- return {
5182
- data: `[${strings.join(",")}]`,
5183
- chunks: count > 0 ? iterator : null
5184
- };
5185
- } catch (e) {
5186
- e.path = e.path.slice(1);
5187
- throw new Error(clarify_devalue_error(
5188
- event,
5189
- /** @type {any} */
5190
- e
5191
- ));
5192
- }
5193
- }
5194
6350
  class PageNodes {
5195
6351
  data;
5196
6352
  /**
@@ -5261,17 +6417,17 @@ class PageNodes {
5261
6417
  return this.#get_option("trailingSlash") ?? "never";
5262
6418
  }
5263
6419
  get_config() {
5264
- let current = {};
6420
+ let current2 = {};
5265
6421
  for (const node of this.data) {
5266
6422
  if (!node?.universal?.config && !node?.server?.config) continue;
5267
- current = {
5268
- ...current,
6423
+ current2 = {
6424
+ ...current2,
5269
6425
  // TODO: should we override the server config value with the universal value similar to other page options?
5270
6426
  ...node?.universal?.config,
5271
6427
  ...node?.server?.config
5272
6428
  };
5273
6429
  }
5274
- return Object.keys(current).length ? current : void 0;
6430
+ return Object.keys(current2).length ? current2 : void 0;
5275
6431
  }
5276
6432
  should_prerender_data() {
5277
6433
  return this.data.some(
@@ -5305,6 +6461,7 @@ async function respond_with_error({
5305
6461
  const nodes = new PageNodes([default_layout]);
5306
6462
  const ssr = nodes.ssr();
5307
6463
  const csr = nodes.csr();
6464
+ const data_serializer = server_data_serializer(event, event_state, options2);
5308
6465
  if (ssr) {
5309
6466
  state.error = true;
5310
6467
  const server_data_promise = load_server_data({
@@ -5316,6 +6473,7 @@ async function respond_with_error({
5316
6473
  parent: async () => ({})
5317
6474
  });
5318
6475
  const server_data = await server_data_promise;
6476
+ data_serializer.add_node(0, server_data);
5319
6477
  const data = await load_data({
5320
6478
  event,
5321
6479
  event_state,
@@ -5328,269 +6486,54 @@ async function respond_with_error({
5328
6486
  state,
5329
6487
  csr
5330
6488
  });
5331
- branch.push(
5332
- {
5333
- node: default_layout,
5334
- server_data,
5335
- data
5336
- },
5337
- {
5338
- node: await manifest._.nodes[1](),
5339
- // 1 is always the root error
5340
- data: null,
5341
- server_data: null
5342
- }
5343
- );
5344
- }
5345
- return await render_response({
5346
- options: options2,
5347
- manifest,
5348
- state,
5349
- page_config: {
5350
- ssr,
5351
- csr
5352
- },
5353
- status,
5354
- error: await handle_error_and_jsonify(event, event_state, options2, error2),
5355
- branch,
5356
- fetched,
5357
- event,
5358
- event_state,
5359
- resolve_opts
5360
- });
5361
- } catch (e) {
5362
- if (e instanceof Redirect) {
5363
- return redirect_response(e.status, e.location);
5364
- }
5365
- return static_error_page(
5366
- options2,
5367
- get_status(e),
5368
- (await handle_error_and_jsonify(event, event_state, options2, e)).message
5369
- );
5370
- }
5371
- }
5372
- function once(fn) {
5373
- let done = false;
5374
- let result;
5375
- return () => {
5376
- if (done) return result;
5377
- done = true;
5378
- return result = fn();
5379
- };
5380
- }
5381
- async function render_data(event, event_state, route, options2, manifest, state, invalidated_data_nodes, trailing_slash) {
5382
- if (!route.page) {
5383
- return new Response(void 0, {
5384
- status: 404
5385
- });
5386
- }
5387
- try {
5388
- const node_ids = [...route.page.layouts, route.page.leaf];
5389
- const invalidated = invalidated_data_nodes ?? node_ids.map(() => true);
5390
- let aborted = false;
5391
- const url = new URL(event.url);
5392
- url.pathname = normalize_path(url.pathname, trailing_slash);
5393
- const new_event = { ...event, url };
5394
- const functions = node_ids.map((n, i) => {
5395
- return once(async () => {
5396
- try {
5397
- if (aborted) {
5398
- return (
5399
- /** @type {import('types').ServerDataSkippedNode} */
5400
- {
5401
- type: "skip"
5402
- }
5403
- );
5404
- }
5405
- const node = n == void 0 ? n : await manifest._.nodes[n]();
5406
- return load_server_data({
5407
- event: new_event,
5408
- event_state,
5409
- state,
5410
- node,
5411
- parent: async () => {
5412
- const data2 = {};
5413
- for (let j = 0; j < i; j += 1) {
5414
- const parent = (
5415
- /** @type {import('types').ServerDataNode | null} */
5416
- await functions[j]()
5417
- );
5418
- if (parent) {
5419
- Object.assign(data2, parent.data);
5420
- }
5421
- }
5422
- return data2;
5423
- }
5424
- });
5425
- } catch (e) {
5426
- aborted = true;
5427
- throw e;
5428
- }
5429
- });
5430
- });
5431
- const promises = functions.map(async (fn, i) => {
5432
- if (!invalidated[i]) {
5433
- return (
5434
- /** @type {import('types').ServerDataSkippedNode} */
5435
- {
5436
- type: "skip"
5437
- }
5438
- );
5439
- }
5440
- return fn();
5441
- });
5442
- let length = promises.length;
5443
- const nodes = await Promise.all(
5444
- promises.map(
5445
- (p, i) => p.catch(async (error2) => {
5446
- if (error2 instanceof Redirect) {
5447
- throw error2;
5448
- }
5449
- length = Math.min(length, i + 1);
5450
- return (
5451
- /** @type {import('types').ServerErrorNode} */
5452
- {
5453
- type: "error",
5454
- error: await handle_error_and_jsonify(event, event_state, options2, error2),
5455
- status: error2 instanceof HttpError || error2 instanceof SvelteKitError ? error2.status : void 0
5456
- }
5457
- );
5458
- })
5459
- )
5460
- );
5461
- const { data, chunks } = get_data_json(event, event_state, options2, nodes);
5462
- if (!chunks) {
5463
- return json_response(data);
5464
- }
5465
- return new Response(
5466
- new ReadableStream({
5467
- async start(controller) {
5468
- controller.enqueue(text_encoder.encode(data));
5469
- for await (const chunk of chunks) {
5470
- controller.enqueue(text_encoder.encode(chunk));
5471
- }
5472
- controller.close();
5473
- },
5474
- type: "bytes"
5475
- }),
5476
- {
5477
- headers: {
5478
- // we use a proprietary content type to prevent buffering.
5479
- // the `text` prefix makes it inspectable
5480
- "content-type": "text/sveltekit-data",
5481
- "cache-control": "private, no-store"
5482
- }
5483
- }
5484
- );
5485
- } catch (e) {
5486
- const error2 = normalize_error(e);
5487
- if (error2 instanceof Redirect) {
5488
- return redirect_json_response(error2);
5489
- } else {
5490
- return json_response(await handle_error_and_jsonify(event, event_state, options2, error2), 500);
5491
- }
5492
- }
5493
- }
5494
- function json_response(json2, status = 200) {
5495
- return text(typeof json2 === "string" ? json2 : JSON.stringify(json2), {
5496
- status,
5497
- headers: {
5498
- "content-type": "application/json",
5499
- "cache-control": "private, no-store"
5500
- }
5501
- });
5502
- }
5503
- function redirect_json_response(redirect) {
5504
- return json_response(
5505
- /** @type {import('types').ServerRedirectNode} */
5506
- {
5507
- type: "redirect",
5508
- location: redirect.location
5509
- }
5510
- );
5511
- }
5512
- function get_data_json(event, event_state, options2, nodes) {
5513
- let promise_id = 1;
5514
- let count = 0;
5515
- const { iterator, push, done } = create_async_iterator();
5516
- const reducers = {
5517
- ...Object.fromEntries(
5518
- Object.entries(options2.hooks.transport).map(([key2, value]) => [key2, value.encode])
5519
- ),
5520
- /** @param {any} thing */
5521
- Promise: (thing) => {
5522
- if (typeof thing?.then === "function") {
5523
- const id = promise_id++;
5524
- count += 1;
5525
- let key2 = "data";
5526
- thing.catch(
5527
- /** @param {any} e */
5528
- async (e) => {
5529
- key2 = "error";
5530
- return handle_error_and_jsonify(
5531
- event,
5532
- event_state,
5533
- options2,
5534
- /** @type {any} */
5535
- e
5536
- );
5537
- }
5538
- ).then(
5539
- /** @param {any} value */
5540
- async (value) => {
5541
- let str;
5542
- try {
5543
- str = stringify$1(value, reducers);
5544
- } catch {
5545
- const error2 = await handle_error_and_jsonify(
5546
- event,
5547
- event_state,
5548
- options2,
5549
- new Error(`Failed to serialize promise while rendering ${event.route.id}`)
5550
- );
5551
- key2 = "error";
5552
- str = stringify$1(error2, reducers);
5553
- }
5554
- count -= 1;
5555
- push(`{"type":"chunk","id":${id},"${key2}":${str}}
5556
- `);
5557
- if (count === 0) done();
5558
- }
5559
- );
5560
- return id;
5561
- }
6489
+ branch.push(
6490
+ {
6491
+ node: default_layout,
6492
+ server_data,
6493
+ data
6494
+ },
6495
+ {
6496
+ node: await manifest._.nodes[1](),
6497
+ // 1 is always the root error
6498
+ data: null,
6499
+ server_data: null
6500
+ }
6501
+ );
5562
6502
  }
5563
- };
5564
- try {
5565
- const strings = nodes.map((node) => {
5566
- if (!node) return "null";
5567
- if (node.type === "error" || node.type === "skip") {
5568
- return JSON.stringify(node);
5569
- }
5570
- return `{"type":"data","data":${stringify$1(node.data, reducers)},"uses":${JSON.stringify(
5571
- serialize_uses(node)
5572
- )}${node.slash ? `,"slash":${JSON.stringify(node.slash)}` : ""}}`;
6503
+ return await render_response({
6504
+ options: options2,
6505
+ manifest,
6506
+ state,
6507
+ page_config: {
6508
+ ssr,
6509
+ csr
6510
+ },
6511
+ status,
6512
+ error: await handle_error_and_jsonify(event, event_state, options2, error2),
6513
+ branch,
6514
+ fetched,
6515
+ event,
6516
+ event_state,
6517
+ resolve_opts,
6518
+ data_serializer
5573
6519
  });
5574
- return {
5575
- data: `{"type":"data","nodes":[${strings.join(",")}]}
5576
- `,
5577
- chunks: count > 0 ? iterator : null
5578
- };
5579
6520
  } catch (e) {
5580
- e.path = "data" + e.path;
5581
- throw new Error(clarify_devalue_error(
5582
- event,
5583
- /** @type {any} */
5584
- e
5585
- ));
6521
+ if (e instanceof Redirect) {
6522
+ return redirect_response(e.status, e.location);
6523
+ }
6524
+ return static_error_page(
6525
+ options2,
6526
+ get_status(e),
6527
+ (await handle_error_and_jsonify(event, event_state, options2, e)).message
6528
+ );
5586
6529
  }
5587
6530
  }
5588
6531
  async function handle_remote_call(event, state, options2, manifest, id) {
5589
6532
  return record_span({
5590
6533
  name: "sveltekit.remote.call",
5591
6534
  attributes: {},
5592
- fn: (current) => {
5593
- const traced_event = merge_tracing(event, current);
6535
+ fn: (current2) => {
6536
+ const traced_event = merge_tracing(event, current2);
5594
6537
  return with_request_store(
5595
6538
  { event: traced_event, state },
5596
6539
  () => handle_remote_call_internal(traced_event, state, options2, manifest, id)
@@ -5599,11 +6542,11 @@ async function handle_remote_call(event, state, options2, manifest, id) {
5599
6542
  });
5600
6543
  }
5601
6544
  async function handle_remote_call_internal(event, state, options2, manifest, id) {
5602
- const [hash2, name, prerender_args] = id.split("/");
6545
+ const [hash2, name, additional_args] = id.split("/");
5603
6546
  const remotes = manifest._.remotes;
5604
6547
  if (!remotes[hash2]) error(404);
5605
6548
  const module = await remotes[hash2]();
5606
- const fn = module[name];
6549
+ const fn = module.default[name];
5607
6550
  if (!fn) error(404);
5608
6551
  const info = fn.__;
5609
6552
  const transport = options2.hooks.transport;
@@ -5613,22 +6556,65 @@ async function handle_remote_call_internal(event, state, options2, manifest, id)
5613
6556
  });
5614
6557
  let form_client_refreshes;
5615
6558
  try {
6559
+ if (info.type === "query_batch") {
6560
+ if (event.request.method !== "POST") {
6561
+ throw new SvelteKitError(
6562
+ 405,
6563
+ "Method Not Allowed",
6564
+ `\`query.batch\` functions must be invoked via POST request, not ${event.request.method}`
6565
+ );
6566
+ }
6567
+ const { payloads } = await event.request.json();
6568
+ const args = payloads.map((payload2) => parse_remote_arg(payload2, transport));
6569
+ const get_result = await with_request_store({ event, state }, () => info.run(args));
6570
+ const results = await Promise.all(
6571
+ args.map(async (arg, i) => {
6572
+ try {
6573
+ return { type: "result", data: get_result(arg, i) };
6574
+ } catch (error2) {
6575
+ return {
6576
+ type: "error",
6577
+ error: await handle_error_and_jsonify(event, state, options2, error2),
6578
+ status: error2 instanceof HttpError || error2 instanceof SvelteKitError ? error2.status : 500
6579
+ };
6580
+ }
6581
+ })
6582
+ );
6583
+ return json(
6584
+ /** @type {RemoteFunctionResponse} */
6585
+ {
6586
+ type: "result",
6587
+ result: stringify(results, transport)
6588
+ }
6589
+ );
6590
+ }
5616
6591
  if (info.type === "form") {
6592
+ if (event.request.method !== "POST") {
6593
+ throw new SvelteKitError(
6594
+ 405,
6595
+ "Method Not Allowed",
6596
+ `\`form\` functions must be invoked via POST request, not ${event.request.method}`
6597
+ );
6598
+ }
5617
6599
  if (!is_form_content_type(event.request)) {
5618
6600
  throw new SvelteKitError(
5619
6601
  415,
5620
6602
  "Unsupported Media Type",
5621
- `Form actions expect form-encoded data — received ${event.request.headers.get(
6603
+ `\`form\` functions expect form-encoded data — received ${event.request.headers.get(
5622
6604
  "content-type"
5623
6605
  )}`
5624
6606
  );
5625
6607
  }
5626
6608
  const form_data = await event.request.formData();
5627
- form_client_refreshes = JSON.parse(
6609
+ form_client_refreshes = /** @type {string[]} */
6610
+ JSON.parse(
5628
6611
  /** @type {string} */
5629
6612
  form_data.get("sveltekit:remote_refreshes") ?? "[]"
5630
6613
  );
5631
6614
  form_data.delete("sveltekit:remote_refreshes");
6615
+ if (additional_args) {
6616
+ form_data.set("sveltekit:id", decodeURIComponent(additional_args));
6617
+ }
5632
6618
  const fn2 = info.fn;
5633
6619
  const data2 = await with_request_store({ event, state }, () => fn2(form_data));
5634
6620
  return json(
@@ -5636,10 +6622,7 @@ async function handle_remote_call_internal(event, state, options2, manifest, id)
5636
6622
  {
5637
6623
  type: "result",
5638
6624
  result: stringify(data2, transport),
5639
- refreshes: await serialize_refreshes(
5640
- /** @type {string[]} */
5641
- form_client_refreshes
5642
- )
6625
+ refreshes: data2.issues ? {} : await serialize_refreshes(form_client_refreshes)
5643
6626
  }
5644
6627
  );
5645
6628
  }
@@ -5656,7 +6639,7 @@ async function handle_remote_call_internal(event, state, options2, manifest, id)
5656
6639
  }
5657
6640
  );
5658
6641
  }
5659
- const payload = info.type === "prerender" ? prerender_args : (
6642
+ const payload = info.type === "prerender" ? additional_args : (
5660
6643
  /** @type {string} */
5661
6644
  // new URL(...) necessary because we're hiding the URL from the user in the event object
5662
6645
  new URL(event.request.url).searchParams.get("payload")
@@ -5674,20 +6657,27 @@ async function handle_remote_call_internal(event, state, options2, manifest, id)
5674
6657
  );
5675
6658
  } catch (error2) {
5676
6659
  if (error2 instanceof Redirect) {
5677
- return json({
5678
- type: "redirect",
5679
- location: error2.location,
5680
- refreshes: await serialize_refreshes(form_client_refreshes ?? [])
5681
- });
6660
+ return json(
6661
+ /** @type {RemoteFunctionResponse} */
6662
+ {
6663
+ type: "redirect",
6664
+ location: error2.location,
6665
+ refreshes: await serialize_refreshes(form_client_refreshes ?? [])
6666
+ }
6667
+ );
5682
6668
  }
6669
+ const status = error2 instanceof HttpError || error2 instanceof SvelteKitError ? error2.status : 500;
5683
6670
  return json(
5684
6671
  /** @type {RemoteFunctionResponse} */
5685
6672
  {
5686
6673
  type: "error",
5687
6674
  error: await handle_error_and_jsonify(event, state, options2, error2),
5688
- status: error2 instanceof HttpError || error2 instanceof SvelteKitError ? error2.status : 500
6675
+ status
5689
6676
  },
5690
6677
  {
6678
+ // By setting a non-200 during prerendering we fail the prerender process (unless handleHttpError handles it).
6679
+ // Errors at runtime will be passed to the client and are handled there
6680
+ status: state.prerendering ? status : void 0,
5691
6681
  headers: {
5692
6682
  "cache-control": "private, no-store"
5693
6683
  }
@@ -5695,37 +6685,37 @@ async function handle_remote_call_internal(event, state, options2, manifest, id)
5695
6685
  );
5696
6686
  }
5697
6687
  async function serialize_refreshes(client_refreshes) {
5698
- const refreshes = {
5699
- ...state.refreshes,
5700
- ...Object.fromEntries(
6688
+ const refreshes = state.refreshes ?? {};
6689
+ for (const key2 of client_refreshes) {
6690
+ if (refreshes[key2] !== void 0) continue;
6691
+ const [hash3, name2, payload] = key2.split("/");
6692
+ const loader = manifest._.remotes[hash3];
6693
+ const fn2 = (await loader?.())?.default?.[name2];
6694
+ if (!fn2) error(400, "Bad Request");
6695
+ refreshes[key2] = with_request_store(
6696
+ { event, state },
6697
+ () => fn2(parse_remote_arg(payload, transport))
6698
+ );
6699
+ }
6700
+ if (Object.keys(refreshes).length === 0) {
6701
+ return void 0;
6702
+ }
6703
+ return stringify(
6704
+ Object.fromEntries(
5701
6705
  await Promise.all(
5702
- client_refreshes.map(async (key2) => {
5703
- const [hash3, name2, payload] = key2.split("/");
5704
- const loader = manifest._.remotes[hash3];
5705
- if (!loader) error(400, "Bad Request");
5706
- const module2 = await loader();
5707
- const fn2 = module2[name2];
5708
- if (!fn2) error(400, "Bad Request");
5709
- return [
5710
- key2,
5711
- await with_request_store(
5712
- { event, state },
5713
- () => fn2(parse_remote_arg(payload, transport))
5714
- )
5715
- ];
5716
- })
6706
+ Object.entries(refreshes).map(async ([key2, promise]) => [key2, await promise])
5717
6707
  )
5718
- )
5719
- };
5720
- return Object.keys(refreshes).length > 0 ? stringify(refreshes, transport) : void 0;
6708
+ ),
6709
+ transport
6710
+ );
5721
6711
  }
5722
6712
  }
5723
6713
  async function handle_remote_form_post(event, state, manifest, id) {
5724
6714
  return record_span({
5725
6715
  name: "sveltekit.remote.form.post",
5726
6716
  attributes: {},
5727
- fn: (current) => {
5728
- const traced_event = merge_tracing(event, current);
6717
+ fn: (current2) => {
6718
+ const traced_event = merge_tracing(event, current2);
5729
6719
  return with_request_store(
5730
6720
  { event: traced_event, state },
5731
6721
  () => handle_remote_form_post_internal(traced_event, state, manifest, id)
@@ -5738,8 +6728,8 @@ async function handle_remote_form_post_internal(event, state, manifest, id) {
5738
6728
  const remotes = manifest._.remotes;
5739
6729
  const module = await remotes[hash2]?.();
5740
6730
  let form = (
5741
- /** @type {RemoteForm<any>} */
5742
- module?.[name]
6731
+ /** @type {RemoteForm<any, any>} */
6732
+ module?.default[name]
5743
6733
  );
5744
6734
  if (!form) {
5745
6735
  event.setHeaders({
@@ -5766,6 +6756,9 @@ async function handle_remote_form_post_internal(event, state, manifest, id) {
5766
6756
  /** @type {any} */
5767
6757
  form.__.fn
5768
6758
  );
6759
+ if (action_id && !form_data.has("id")) {
6760
+ form_data.set("sveltekit:id", decodeURIComponent(action_id));
6761
+ }
5769
6762
  await with_request_store({ event, state }, () => fn(form_data));
5770
6763
  return {
5771
6764
  type: "success",
@@ -5861,11 +6854,14 @@ async function render_page(event, event_state, page, options2, manifest, state,
5861
6854
  options: options2,
5862
6855
  manifest,
5863
6856
  state,
5864
- resolve_opts
6857
+ resolve_opts,
6858
+ data_serializer: server_data_serializer(event, event_state, options2)
5865
6859
  });
5866
6860
  }
5867
6861
  const branch = [];
5868
6862
  let load_error = null;
6863
+ const data_serializer = server_data_serializer(event, event_state, options2);
6864
+ const data_serializer_json = state.prerendering && should_prerender_data ? server_data_serializer_json(event, event_state, options2) : null;
5869
6865
  const server_promises = nodes.data.map((node, i) => {
5870
6866
  if (load_error) {
5871
6867
  throw load_error;
@@ -5875,7 +6871,7 @@ async function render_page(event, event_state, page, options2, manifest, state,
5875
6871
  if (node === leaf_node && action_result?.type === "error") {
5876
6872
  throw action_result.error;
5877
6873
  }
5878
- return await load_server_data({
6874
+ const server_data = await load_server_data({
5879
6875
  event,
5880
6876
  event_state,
5881
6877
  state,
@@ -5889,6 +6885,11 @@ async function render_page(event, event_state, page, options2, manifest, state,
5889
6885
  return data;
5890
6886
  }
5891
6887
  });
6888
+ if (node) {
6889
+ data_serializer.add_node(i, server_data);
6890
+ }
6891
+ data_serializer_json?.add_node(i, server_data);
6892
+ return server_data;
5892
6893
  } catch (e) {
5893
6894
  load_error = /** @type {Error} */
5894
6895
  e;
@@ -5961,6 +6962,7 @@ async function render_page(event, event_state, page, options2, manifest, state,
5961
6962
  const node2 = await manifest._.nodes[index]();
5962
6963
  let j = i;
5963
6964
  while (!branch[j]) j -= 1;
6965
+ data_serializer.set_max_nodes(j + 1);
5964
6966
  const layouts = compact(branch.slice(0, j + 1));
5965
6967
  const nodes2 = new PageNodes(layouts.map((layout) => layout.node));
5966
6968
  return await render_response({
@@ -5981,7 +6983,8 @@ async function render_page(event, event_state, page, options2, manifest, state,
5981
6983
  data: null,
5982
6984
  server_data: null
5983
6985
  }),
5984
- fetched
6986
+ fetched,
6987
+ data_serializer
5985
6988
  });
5986
6989
  }
5987
6990
  }
@@ -5991,13 +6994,8 @@ async function render_page(event, event_state, page, options2, manifest, state,
5991
6994
  branch.push(null);
5992
6995
  }
5993
6996
  }
5994
- if (state.prerendering && should_prerender_data) {
5995
- let { data, chunks } = get_data_json(
5996
- event,
5997
- event_state,
5998
- options2,
5999
- branch.map((node) => node?.server_data)
6000
- );
6997
+ if (state.prerendering && data_serializer_json) {
6998
+ let { data, chunks } = data_serializer_json.get_data();
6001
6999
  if (chunks) {
6002
7000
  for await (const chunk of chunks) {
6003
7001
  data += chunk;
@@ -6023,7 +7021,8 @@ async function render_page(event, event_state, page, options2, manifest, state,
6023
7021
  error: null,
6024
7022
  branch: ssr === false ? [] : compact(branch),
6025
7023
  action_result,
6026
- fetched
7024
+ fetched,
7025
+ data_serializer: ssr === false ? server_data_serializer(event, event_state, options2) : data_serializer
6027
7026
  });
6028
7027
  } catch (e) {
6029
7028
  return await respond_with_error({
@@ -6038,17 +7037,162 @@ async function render_page(event, event_state, page, options2, manifest, state,
6038
7037
  });
6039
7038
  }
6040
7039
  }
7040
+ function once(fn) {
7041
+ let done = false;
7042
+ let result;
7043
+ return () => {
7044
+ if (done) return result;
7045
+ done = true;
7046
+ return result = fn();
7047
+ };
7048
+ }
7049
+ async function render_data(event, event_state, route, options2, manifest, state, invalidated_data_nodes, trailing_slash) {
7050
+ if (!route.page) {
7051
+ return new Response(void 0, {
7052
+ status: 404
7053
+ });
7054
+ }
7055
+ try {
7056
+ const node_ids = [...route.page.layouts, route.page.leaf];
7057
+ const invalidated = invalidated_data_nodes ?? node_ids.map(() => true);
7058
+ let aborted = false;
7059
+ const url = new URL(event.url);
7060
+ url.pathname = normalize_path(url.pathname, trailing_slash);
7061
+ const new_event = { ...event, url };
7062
+ const functions = node_ids.map((n, i) => {
7063
+ return once(async () => {
7064
+ try {
7065
+ if (aborted) {
7066
+ return (
7067
+ /** @type {import('types').ServerDataSkippedNode} */
7068
+ {
7069
+ type: "skip"
7070
+ }
7071
+ );
7072
+ }
7073
+ const node = n == void 0 ? n : await manifest._.nodes[n]();
7074
+ return load_server_data({
7075
+ event: new_event,
7076
+ event_state,
7077
+ state,
7078
+ node,
7079
+ parent: async () => {
7080
+ const data2 = {};
7081
+ for (let j = 0; j < i; j += 1) {
7082
+ const parent = (
7083
+ /** @type {import('types').ServerDataNode | null} */
7084
+ await functions[j]()
7085
+ );
7086
+ if (parent) {
7087
+ Object.assign(data2, parent.data);
7088
+ }
7089
+ }
7090
+ return data2;
7091
+ }
7092
+ });
7093
+ } catch (e) {
7094
+ aborted = true;
7095
+ throw e;
7096
+ }
7097
+ });
7098
+ });
7099
+ const promises = functions.map(async (fn, i) => {
7100
+ if (!invalidated[i]) {
7101
+ return (
7102
+ /** @type {import('types').ServerDataSkippedNode} */
7103
+ {
7104
+ type: "skip"
7105
+ }
7106
+ );
7107
+ }
7108
+ return fn();
7109
+ });
7110
+ let length = promises.length;
7111
+ const nodes = await Promise.all(
7112
+ promises.map(
7113
+ (p, i) => p.catch(async (error2) => {
7114
+ if (error2 instanceof Redirect) {
7115
+ throw error2;
7116
+ }
7117
+ length = Math.min(length, i + 1);
7118
+ return (
7119
+ /** @type {import('types').ServerErrorNode} */
7120
+ {
7121
+ type: "error",
7122
+ error: await handle_error_and_jsonify(event, event_state, options2, error2),
7123
+ status: error2 instanceof HttpError || error2 instanceof SvelteKitError ? error2.status : void 0
7124
+ }
7125
+ );
7126
+ })
7127
+ )
7128
+ );
7129
+ const data_serializer = server_data_serializer_json(event, event_state, options2);
7130
+ for (let i = 0; i < nodes.length; i++) data_serializer.add_node(i, nodes[i]);
7131
+ const { data, chunks } = data_serializer.get_data();
7132
+ if (!chunks) {
7133
+ return json_response(data);
7134
+ }
7135
+ return new Response(
7136
+ new ReadableStream({
7137
+ async start(controller) {
7138
+ controller.enqueue(text_encoder.encode(data));
7139
+ for await (const chunk of chunks) {
7140
+ controller.enqueue(text_encoder.encode(chunk));
7141
+ }
7142
+ controller.close();
7143
+ },
7144
+ type: "bytes"
7145
+ }),
7146
+ {
7147
+ headers: {
7148
+ // we use a proprietary content type to prevent buffering.
7149
+ // the `text` prefix makes it inspectable
7150
+ "content-type": "text/sveltekit-data",
7151
+ "cache-control": "private, no-store"
7152
+ }
7153
+ }
7154
+ );
7155
+ } catch (e) {
7156
+ const error2 = normalize_error(e);
7157
+ if (error2 instanceof Redirect) {
7158
+ return redirect_json_response(error2);
7159
+ } else {
7160
+ return json_response(await handle_error_and_jsonify(event, event_state, options2, error2), 500);
7161
+ }
7162
+ }
7163
+ }
7164
+ function json_response(json2, status = 200) {
7165
+ return text(typeof json2 === "string" ? json2 : JSON.stringify(json2), {
7166
+ status,
7167
+ headers: {
7168
+ "content-type": "application/json",
7169
+ "cache-control": "private, no-store"
7170
+ }
7171
+ });
7172
+ }
7173
+ function redirect_json_response(redirect) {
7174
+ return json_response(
7175
+ /** @type {import('types').ServerRedirectNode} */
7176
+ {
7177
+ type: "redirect",
7178
+ location: redirect.location
7179
+ }
7180
+ );
7181
+ }
6041
7182
  const INVALID_COOKIE_CHARACTER_REGEX = /[\x00-\x1F\x7F()<>@,;:"/[\]?={} \t]/;
6042
7183
  function validate_options(options2) {
6043
7184
  if (options2?.path === void 0) {
6044
7185
  throw new Error("You must specify a `path` when setting, deleting or serializing cookies");
6045
7186
  }
6046
7187
  }
7188
+ function generate_cookie_key(domain, path, name) {
7189
+ return `${domain || ""}${path}?${encodeURIComponent(name)}`;
7190
+ }
6047
7191
  function get_cookies(request, url) {
6048
7192
  const header = request.headers.get("cookie") ?? "";
6049
- const initial_cookies = parse$1(header, { decode: (value) => value });
7193
+ const initial_cookies = cookieExports.parse(header, { decode: (value) => value });
6050
7194
  let normalized_url;
6051
- const new_cookies = {};
7195
+ const new_cookies = /* @__PURE__ */ new Map();
6052
7196
  const defaults = {
6053
7197
  httpOnly: true,
6054
7198
  sameSite: "lax",
@@ -6064,11 +7208,13 @@ function get_cookies(request, url) {
6064
7208
  * @param {import('cookie').CookieParseOptions} [opts]
6065
7209
  */
6066
7210
  get(name, opts) {
6067
- const c = new_cookies[name];
6068
- if (c && domain_matches(url.hostname, c.options.domain) && path_matches(url.pathname, c.options.path)) {
6069
- return c.value;
7211
+ const best_match = Array.from(new_cookies.values()).filter((c) => {
7212
+ return c.name === name && domain_matches(url.hostname, c.options.domain) && path_matches(url.pathname, c.options.path);
7213
+ }).sort((a, b) => b.options.path.length - a.options.path.length)[0];
7214
+ if (best_match) {
7215
+ return best_match.options.maxAge === 0 ? void 0 : best_match.value;
6070
7216
  }
6071
- const req_cookies = parse$1(header, { decode: opts?.decode });
7217
+ const req_cookies = cookieExports.parse(header, { decode: opts?.decode });
6072
7218
  const cookie = req_cookies[name];
6073
7219
  return cookie;
6074
7220
  },
@@ -6076,12 +7222,19 @@ function get_cookies(request, url) {
6076
7222
  * @param {import('cookie').CookieParseOptions} [opts]
6077
7223
  */
6078
7224
  getAll(opts) {
6079
- const cookies2 = parse$1(header, { decode: opts?.decode });
6080
- for (const c of Object.values(new_cookies)) {
7225
+ const cookies2 = cookieExports.parse(header, { decode: opts?.decode });
7226
+ const lookup = /* @__PURE__ */ new Map();
7227
+ for (const c of new_cookies.values()) {
6081
7228
  if (domain_matches(url.hostname, c.options.domain) && path_matches(url.pathname, c.options.path)) {
6082
- cookies2[c.name] = c.value;
7229
+ const existing = lookup.get(c.name);
7230
+ if (!existing || c.options.path.length > existing.options.path.length) {
7231
+ lookup.set(c.name, c);
7232
+ }
6083
7233
  }
6084
7234
  }
7235
+ for (const c of lookup.values()) {
7236
+ cookies2[c.name] = c.value;
7237
+ }
6085
7238
  return Object.entries(cookies2).map(([name, value]) => ({ name, value }));
6086
7239
  },
6087
7240
  /**
@@ -6123,7 +7276,7 @@ function get_cookies(request, url) {
6123
7276
  }
6124
7277
  path = resolve(normalized_url, path);
6125
7278
  }
6126
- return serialize(name, value, { ...defaults, ...options2, path });
7279
+ return cookieExports.serialize(name, value, { ...defaults, ...options2, path });
6127
7280
  }
6128
7281
  };
6129
7282
  function get_cookie_header(destination, header2) {
@@ -6131,15 +7284,14 @@ function get_cookies(request, url) {
6131
7284
  // cookies sent by the user agent have lowest precedence
6132
7285
  ...initial_cookies
6133
7286
  };
6134
- for (const key2 in new_cookies) {
6135
- const cookie = new_cookies[key2];
7287
+ for (const cookie of new_cookies.values()) {
6136
7288
  if (!domain_matches(destination.hostname, cookie.options.domain)) continue;
6137
7289
  if (!path_matches(destination.pathname, cookie.options.path)) continue;
6138
7290
  const encoder = cookie.options.encode || encodeURIComponent;
6139
7291
  combined_cookies[cookie.name] = encoder(cookie.value);
6140
7292
  }
6141
7293
  if (header2) {
6142
- const parsed = parse$1(header2, { decode: (value) => value });
7294
+ const parsed = cookieExports.parse(header2, { decode: (value) => value });
6143
7295
  for (const name in parsed) {
6144
7296
  combined_cookies[name] = parsed[name];
6145
7297
  }
@@ -6156,7 +7308,9 @@ function get_cookies(request, url) {
6156
7308
  if (!options2.domain || options2.domain === url.hostname) {
6157
7309
  path = resolve(normalized_url, path);
6158
7310
  }
6159
- new_cookies[name] = { name, value, options: { ...options2, path } };
7311
+ const cookie_key = generate_cookie_key(options2.domain, path, name);
7312
+ const cookie = { name, value, options: { ...options2, path } };
7313
+ new_cookies.set(cookie_key, cookie);
6160
7314
  }
6161
7315
  function set_trailing_slash(trailing_slash) {
6162
7316
  normalized_url = normalize_path(url.pathname, trailing_slash);
@@ -6179,10 +7333,10 @@ function path_matches(path, constraint) {
6179
7333
  function add_cookies_to_headers(headers2, cookies) {
6180
7334
  for (const new_cookie of cookies) {
6181
7335
  const { name, value, options: options2 } = new_cookie;
6182
- headers2.append("set-cookie", serialize(name, value, options2));
7336
+ headers2.append("set-cookie", cookieExports.serialize(name, value, options2));
6183
7337
  if (options2.path.endsWith(".html")) {
6184
7338
  const path = add_data_suffix(options2.path);
6185
- headers2.append("set-cookie", serialize(name, value, { ...options2, path }));
7339
+ headers2.append("set-cookie", cookieExports.serialize(name, value, { ...options2, path }));
6186
7340
  }
6187
7341
  }
6188
7342
  }
@@ -6351,23 +7505,23 @@ async function internal_respond(request, options2, manifest, state) {
6351
7505
  const is_route_resolution_request = has_resolution_suffix(url.pathname);
6352
7506
  const is_data_request = has_data_suffix(url.pathname);
6353
7507
  const remote_id = get_remote_id(url);
6354
- if (options2.csrf_check_origin && request.headers.get("origin") !== url.origin) {
6355
- const opts = { status: 403 };
6356
- if (remote_id && request.method !== "GET") {
6357
- return json(
6358
- {
6359
- message: "Cross-site remote requests are forbidden"
6360
- },
6361
- opts
6362
- );
6363
- }
6364
- const forbidden = is_form_content_type(request) && (request.method === "POST" || request.method === "PUT" || request.method === "PATCH" || request.method === "DELETE");
6365
- if (forbidden) {
6366
- const message = `Cross-site ${request.method} form submissions are forbidden`;
6367
- if (request.headers.get("accept") === "application/json") {
6368
- return json({ message }, opts);
7508
+ {
7509
+ const request_origin = request.headers.get("origin");
7510
+ if (remote_id) {
7511
+ if (request.method !== "GET" && request_origin !== url.origin) {
7512
+ const message = "Cross-site remote requests are forbidden";
7513
+ return json({ message }, { status: 403 });
7514
+ }
7515
+ } else if (options2.csrf_check_origin) {
7516
+ const forbidden = is_form_content_type(request) && (request.method === "POST" || request.method === "PUT" || request.method === "PATCH" || request.method === "DELETE") && request_origin !== url.origin && (!request_origin || !options2.csrf_trusted_origins.includes(request_origin));
7517
+ if (forbidden) {
7518
+ const message = `Cross-site ${request.method} form submissions are forbidden`;
7519
+ const opts = { status: 403 };
7520
+ if (request.headers.get("accept") === "application/json") {
7521
+ return json({ message }, opts);
7522
+ }
7523
+ return text(message, opts);
6369
7524
  }
6370
- return text(message, opts);
6371
7525
  }
6372
7526
  }
6373
7527
  if (options2.hash_routing && url.pathname !== base + "/" && url.pathname !== "/[fallback]") {
@@ -6382,8 +7536,8 @@ async function internal_respond(request, options2, manifest, state) {
6382
7536
  invalidated_data_nodes = url.searchParams.get(INVALIDATED_PARAM)?.split("").map((node) => node === "1");
6383
7537
  url.searchParams.delete(INVALIDATED_PARAM);
6384
7538
  } else if (remote_id) {
6385
- url.pathname = base;
6386
- url.search = "";
7539
+ url.pathname = request.headers.get("x-sveltekit-pathname") ?? base;
7540
+ url.search = request.headers.get("x-sveltekit-search") ?? "";
6387
7541
  }
6388
7542
  const headers2 = {};
6389
7543
  const { cookies, new_cookies, get_cookie_header, set_internal, set_trailing_slash } = get_cookies(
@@ -6396,7 +7550,8 @@ async function internal_respond(request, options2, manifest, state) {
6396
7550
  handleValidationError: options2.hooks.handleValidationError,
6397
7551
  tracing: {
6398
7552
  record_span
6399
- }
7553
+ },
7554
+ is_in_remote_function: false
6400
7555
  };
6401
7556
  const event = {
6402
7557
  cookies,
@@ -6502,7 +7657,7 @@ async function internal_respond(request, options2, manifest, state) {
6502
7657
  headers22.set("cache-control", "public, max-age=0, must-revalidate");
6503
7658
  return text("Not found", { status: 404, headers: headers22 });
6504
7659
  }
6505
- if (!state.prerendering?.fallback && !remote_id) {
7660
+ if (!state.prerendering?.fallback) {
6506
7661
  const matchers = await manifest._.matchers();
6507
7662
  for (const candidate of manifest._.routes) {
6508
7663
  const match = candidate.pattern.exec(resolved_path);
@@ -6524,7 +7679,7 @@ async function internal_respond(request, options2, manifest, state) {
6524
7679
  let trailing_slash = "never";
6525
7680
  try {
6526
7681
  const page_nodes = route?.page ? new PageNodes(await load_page_nodes(route.page, manifest)) : void 0;
6527
- if (route) {
7682
+ if (route && !remote_id) {
6528
7683
  if (url.pathname === base || url.pathname === base + "/") {
6529
7684
  trailing_slash = "always";
6530
7685
  } else if (page_nodes) {
@@ -6614,7 +7769,7 @@ async function internal_respond(request, options2, manifest, state) {
6614
7769
  value
6615
7770
  );
6616
7771
  }
6617
- add_cookies_to_headers(response2.headers, Object.values(new_cookies));
7772
+ add_cookies_to_headers(response2.headers, new_cookies.values());
6618
7773
  if (state.prerendering && event2.route.id !== null) {
6619
7774
  response2.headers.set("x-sveltekit-routeid", encodeURI(event2.route.id));
6620
7775
  }
@@ -6674,8 +7829,8 @@ async function internal_respond(request, options2, manifest, state) {
6674
7829
  return response;
6675
7830
  } catch (e) {
6676
7831
  if (e instanceof Redirect) {
6677
- const response = is_data_request ? redirect_json_response(e) : route?.page && is_action_json_request(event) ? action_json_redirect(e) : redirect_response(e.status, e.location);
6678
- add_cookies_to_headers(response.headers, Object.values(new_cookies));
7832
+ const response = is_data_request || remote_id ? redirect_json_response(e) : route?.page && is_action_json_request(event) ? action_json_redirect(e) : redirect_response(e.status, e.location);
7833
+ add_cookies_to_headers(response.headers, new_cookies.values());
6679
7834
  return response;
6680
7835
  }
6681
7836
  return await handle_fatal_error(event, event_state, options2, e);
@@ -6701,7 +7856,8 @@ async function internal_respond(request, options2, manifest, state) {
6701
7856
  error: null,
6702
7857
  branch: [],
6703
7858
  fetched: [],
6704
- resolve_opts
7859
+ resolve_opts,
7860
+ data_serializer: server_data_serializer(event2, event_state, options2)
6705
7861
  });
6706
7862
  }
6707
7863
  if (remote_id) {
@@ -6712,9 +7868,9 @@ async function internal_respond(request, options2, manifest, state) {
6712
7868
  /** @type {import('types').HttpMethod} */
6713
7869
  event2.request.method
6714
7870
  );
6715
- let response;
7871
+ let response2;
6716
7872
  if (is_data_request) {
6717
- response = await render_data(
7873
+ response2 = await render_data(
6718
7874
  event2,
6719
7875
  event_state,
6720
7876
  route,
@@ -6725,12 +7881,12 @@ async function internal_respond(request, options2, manifest, state) {
6725
7881
  trailing_slash
6726
7882
  );
6727
7883
  } else if (route.endpoint && (!route.page || is_endpoint_request(event2))) {
6728
- response = await render_endpoint(event2, event_state, await route.endpoint(), state);
7884
+ response2 = await render_endpoint(event2, event_state, await route.endpoint(), state);
6729
7885
  } else if (route.page) {
6730
7886
  if (!page_nodes) {
6731
7887
  throw new Error("page_nodes not found. This should never happen");
6732
7888
  } else if (page_methods.has(method)) {
6733
- response = await render_page(
7889
+ response2 = await render_page(
6734
7890
  event2,
6735
7891
  event_state,
6736
7892
  route.page,
@@ -6747,7 +7903,7 @@ async function internal_respond(request, options2, manifest, state) {
6747
7903
  allowed_methods2.add("POST");
6748
7904
  }
6749
7905
  if (method === "OPTIONS") {
6750
- response = new Response(null, {
7906
+ response2 = new Response(null, {
6751
7907
  status: 204,
6752
7908
  headers: {
6753
7909
  allow: Array.from(allowed_methods2.values()).join(", ")
@@ -6762,24 +7918,24 @@ async function internal_respond(request, options2, manifest, state) {
6762
7918
  /** @type {Record<string, any>} */
6763
7919
  {}
6764
7920
  );
6765
- response = method_not_allowed(mod, method);
7921
+ response2 = method_not_allowed(mod, method);
6766
7922
  }
6767
7923
  }
6768
7924
  } else {
6769
7925
  throw new Error("Route is neither page nor endpoint. This should never happen");
6770
7926
  }
6771
7927
  if (request.method === "GET" && route.page && route.endpoint) {
6772
- const vary = response.headers.get("vary")?.split(",")?.map((v) => v.trim().toLowerCase());
7928
+ const vary = response2.headers.get("vary")?.split(",")?.map((v) => v.trim().toLowerCase());
6773
7929
  if (!(vary?.includes("accept") || vary?.includes("*"))) {
6774
- response = new Response(response.body, {
6775
- status: response.status,
6776
- statusText: response.statusText,
6777
- headers: new Headers(response.headers)
7930
+ response2 = new Response(response2.body, {
7931
+ status: response2.status,
7932
+ statusText: response2.statusText,
7933
+ headers: new Headers(response2.headers)
6778
7934
  });
6779
- response.headers.append("Vary", "Accept");
7935
+ response2.headers.append("Vary", "Accept");
6780
7936
  }
6781
7937
  }
6782
- return response;
7938
+ return response2;
6783
7939
  }
6784
7940
  if (state.error && event2.isSubRequest) {
6785
7941
  const headers22 = new Headers(request.headers);
@@ -6807,7 +7963,8 @@ async function internal_respond(request, options2, manifest, state) {
6807
7963
  if (state.prerendering) {
6808
7964
  return text("not found", { status: 404 });
6809
7965
  }
6810
- return await fetch(request);
7966
+ const response = await fetch(request);
7967
+ return new Response(response.body, response);
6811
7968
  } catch (e) {
6812
7969
  return await handle_fatal_error(event2, event_state, options2, e);
6813
7970
  } finally {
@@ -6834,23 +7991,17 @@ function propagate_context(fn) {
6834
7991
  }
6835
7992
  };
6836
7993
  }
6837
- function filter_private_env(env, { public_prefix, private_prefix }) {
6838
- return Object.fromEntries(
6839
- Object.entries(env).filter(
6840
- ([k]) => k.startsWith(private_prefix) && (public_prefix === "" || !k.startsWith(public_prefix))
6841
- )
6842
- );
6843
- }
6844
- function filter_public_env(env, { public_prefix, private_prefix }) {
7994
+ function filter_env(env, allowed, disallowed) {
6845
7995
  return Object.fromEntries(
6846
7996
  Object.entries(env).filter(
6847
- ([k]) => k.startsWith(public_prefix) && (private_prefix === "" || !k.startsWith(private_prefix))
7997
+ ([k]) => k.startsWith(allowed) && (disallowed === "" || !k.startsWith(disallowed))
6848
7998
  )
6849
7999
  );
6850
8000
  }
6851
8001
  function set_app(value) {
6852
8002
  }
6853
8003
  let init_promise;
8004
+ let current = null;
6854
8005
  class Server {
6855
8006
  /** @type {import('types').SSROptions} */
6856
8007
  #options;
@@ -6860,21 +8011,27 @@ class Server {
6860
8011
  constructor(manifest) {
6861
8012
  this.#options = options;
6862
8013
  this.#manifest = manifest;
8014
+ if (IN_WEBCONTAINER) {
8015
+ const respond2 = this.respond.bind(this);
8016
+ this.respond = async (...args) => {
8017
+ const { promise, resolve: resolve2 } = (
8018
+ /** @type {PromiseWithResolvers<void>} */
8019
+ with_resolvers()
8020
+ );
8021
+ const previous = current;
8022
+ current = promise;
8023
+ await previous;
8024
+ return respond2(...args).finally(resolve2);
8025
+ };
8026
+ }
6863
8027
  }
6864
8028
  /**
6865
8029
  * @param {import('@sveltejs/kit').ServerInitOptions} opts
6866
8030
  */
6867
8031
  async init({ env, read }) {
6868
- const prefixes = {
6869
- public_prefix: this.#options.env_public_prefix,
6870
- private_prefix: this.#options.env_private_prefix
6871
- };
6872
- filter_private_env(env, prefixes);
6873
- const public_env2 = filter_public_env(env, prefixes);
6874
- set_public_env(
6875
- public_env2
6876
- );
6877
- set_safe_public_env(public_env2);
8032
+ const { env_public_prefix, env_private_prefix } = this.#options;
8033
+ set_private_env(filter_env(env, env_private_prefix, env_public_prefix));
8034
+ set_public_env(filter_env(env, env_public_prefix, env_private_prefix));
6878
8035
  if (read) {
6879
8036
  const wrapped_read = (file) => {
6880
8037
  const result = read(file);
@@ -6910,8 +8067,15 @@ class Server {
6910
8067
  const module = await get_hooks();
6911
8068
  this.#options.hooks = {
6912
8069
  handle: module.handle || (({ event, resolve: resolve2 }) => resolve2(event)),
6913
- handleError: module.handleError || (({ status, error: error2 }) => console.error(status === 404 && /** @type {Error} */
6914
- error2?.message || error2)),
8070
+ handleError: module.handleError || (({ status, error: error2, event }) => {
8071
+ const error_message = format_server_error(
8072
+ status,
8073
+ /** @type {Error} */
8074
+ error2,
8075
+ event
8076
+ );
8077
+ console.error(error_message);
8078
+ }),
6915
8079
  handleFetch: module.handleFetch || (({ request, fetch: fetch2 }) => fetch2(request)),
6916
8080
  handleValidationError: module.handleValidationError || (({ issues }) => {
6917
8081
  console.error("Remote function schema validation failed:", issues);