@juspay/shooter 1.0.0 → 1.2.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 (488) hide show
  1. package/.claude/hooks/notifier.cjs +117 -33
  2. package/.claude/settings.json +14 -14
  3. package/README.md +116 -84
  4. package/bin/shooter.cjs +471 -102
  5. package/build/client/_app/immutable/assets/{0.CM9Hl6d-.css → 0.BhZOCxO4.css} +1 -1
  6. package/build/client/_app/immutable/assets/0.BhZOCxO4.css.br +0 -0
  7. package/build/client/_app/immutable/assets/0.BhZOCxO4.css.gz +0 -0
  8. package/build/client/_app/immutable/assets/1.BYutk3aU.css +1 -0
  9. package/build/client/_app/immutable/assets/1.BYutk3aU.css.br +0 -0
  10. package/build/client/_app/immutable/assets/1.BYutk3aU.css.gz +0 -0
  11. package/build/client/_app/immutable/assets/2.CAShZ7lQ.css.gz +0 -0
  12. package/build/client/_app/immutable/assets/3.DGDHCVnW.css +1 -0
  13. package/build/client/_app/immutable/assets/3.DGDHCVnW.css.br +0 -0
  14. package/build/client/_app/immutable/assets/3.DGDHCVnW.css.gz +0 -0
  15. package/build/client/_app/immutable/assets/4.BFUut--w.css +1 -0
  16. package/build/client/_app/immutable/assets/4.BFUut--w.css.br +0 -0
  17. package/build/client/_app/immutable/assets/4.BFUut--w.css.gz +0 -0
  18. package/build/client/_app/immutable/assets/5.BTOx7yt7.css +1 -0
  19. package/build/client/_app/immutable/assets/5.BTOx7yt7.css.br +0 -0
  20. package/build/client/_app/immutable/assets/5.BTOx7yt7.css.gz +0 -0
  21. package/build/client/_app/immutable/assets/6.eZGZN-BF.css +1 -0
  22. package/build/client/_app/immutable/assets/6.eZGZN-BF.css.br +0 -0
  23. package/build/client/_app/immutable/assets/6.eZGZN-BF.css.gz +0 -0
  24. package/build/client/_app/immutable/assets/7.DwS5ZHBh.css +1 -0
  25. package/build/client/_app/immutable/assets/7.DwS5ZHBh.css.br +0 -0
  26. package/build/client/_app/immutable/assets/7.DwS5ZHBh.css.gz +0 -0
  27. package/build/client/_app/immutable/assets/ChatView.CwWbzIL-.css +1 -0
  28. package/build/client/_app/immutable/assets/ChatView.CwWbzIL-.css.br +0 -0
  29. package/build/client/_app/immutable/assets/ChatView.CwWbzIL-.css.gz +0 -0
  30. package/build/client/_app/immutable/assets/Phone.FQEfwCX2.css +1 -0
  31. package/build/client/_app/immutable/assets/Phone.FQEfwCX2.css.br +0 -0
  32. package/build/client/_app/immutable/assets/Phone.FQEfwCX2.css.gz +0 -0
  33. package/build/client/_app/immutable/assets/markdown.Dc-OSJWY.css +1 -0
  34. package/build/client/_app/immutable/assets/markdown.Dc-OSJWY.css.br +0 -0
  35. package/build/client/_app/immutable/assets/markdown.Dc-OSJWY.css.gz +0 -0
  36. package/build/client/_app/immutable/assets/xterm.DFuMZ0ql.css.gz +0 -0
  37. package/build/client/_app/immutable/chunks/B-K5Sh65.js +1 -0
  38. package/build/client/_app/immutable/chunks/B-K5Sh65.js.br +0 -0
  39. package/build/client/_app/immutable/chunks/B-K5Sh65.js.gz +0 -0
  40. package/build/client/_app/immutable/chunks/B5NAKyil.js +20 -0
  41. package/build/client/_app/immutable/chunks/B5NAKyil.js.br +0 -0
  42. package/build/client/_app/immutable/chunks/B5NAKyil.js.gz +0 -0
  43. package/build/client/_app/immutable/chunks/B8XegpSE.js +1 -0
  44. package/build/client/_app/immutable/chunks/B8XegpSE.js.br +0 -0
  45. package/build/client/_app/immutable/chunks/B8XegpSE.js.gz +0 -0
  46. package/build/client/_app/immutable/chunks/B8zoBsv3.js +6 -0
  47. package/build/client/_app/immutable/chunks/B8zoBsv3.js.br +0 -0
  48. package/build/client/_app/immutable/chunks/B8zoBsv3.js.gz +0 -0
  49. package/build/client/_app/immutable/chunks/BLszSzTT.js +1 -0
  50. package/build/client/_app/immutable/chunks/BLszSzTT.js.br +0 -0
  51. package/build/client/_app/immutable/chunks/BLszSzTT.js.gz +0 -0
  52. package/build/client/_app/immutable/chunks/BOYo8yTr.js +1 -0
  53. package/build/client/_app/immutable/chunks/BOYo8yTr.js.br +0 -0
  54. package/build/client/_app/immutable/chunks/BOYo8yTr.js.gz +0 -0
  55. package/build/client/_app/immutable/chunks/BTGVxaYV.js.gz +0 -0
  56. package/build/client/_app/immutable/chunks/BYqGCrTe.js +1 -0
  57. package/build/client/_app/immutable/chunks/BYqGCrTe.js.br +0 -0
  58. package/build/client/_app/immutable/chunks/BYqGCrTe.js.gz +0 -0
  59. package/build/client/_app/immutable/chunks/BlxrFPDK.js.gz +0 -0
  60. package/build/client/_app/immutable/chunks/Bu1aqm5j.js +1 -0
  61. package/build/client/_app/immutable/chunks/Bu1aqm5j.js.br +0 -0
  62. package/build/client/_app/immutable/chunks/Bu1aqm5j.js.gz +0 -0
  63. package/build/client/_app/immutable/chunks/C4mLaWWx.js +1 -0
  64. package/build/client/_app/immutable/chunks/C4mLaWWx.js.br +0 -0
  65. package/build/client/_app/immutable/chunks/C4mLaWWx.js.gz +0 -0
  66. package/build/client/_app/immutable/chunks/CQjSATpv.js +61 -0
  67. package/build/client/_app/immutable/chunks/CQjSATpv.js.br +0 -0
  68. package/build/client/_app/immutable/chunks/CQjSATpv.js.gz +0 -0
  69. package/build/client/_app/immutable/chunks/CSoRdFvv.js +1 -0
  70. package/build/client/_app/immutable/chunks/CSoRdFvv.js.br +0 -0
  71. package/build/client/_app/immutable/chunks/CSoRdFvv.js.gz +0 -0
  72. package/build/client/_app/immutable/chunks/CZHsSL_X.js +1 -0
  73. package/build/client/_app/immutable/chunks/CZHsSL_X.js.br +0 -0
  74. package/build/client/_app/immutable/chunks/CZHsSL_X.js.gz +0 -0
  75. package/build/client/_app/immutable/chunks/DLu6yJIZ.js.gz +0 -0
  76. package/build/client/_app/immutable/chunks/DSU1n5N_.js +1 -0
  77. package/build/client/_app/immutable/chunks/DSU1n5N_.js.br +0 -0
  78. package/build/client/_app/immutable/chunks/DSU1n5N_.js.gz +0 -0
  79. package/build/client/_app/immutable/chunks/DVkn4r72.js +1 -0
  80. package/build/client/_app/immutable/chunks/DVkn4r72.js.br +0 -0
  81. package/build/client/_app/immutable/chunks/DVkn4r72.js.gz +0 -0
  82. package/build/client/_app/immutable/chunks/DjsDGxCa.js +41 -0
  83. package/build/client/_app/immutable/chunks/DjsDGxCa.js.br +0 -0
  84. package/build/client/_app/immutable/chunks/DjsDGxCa.js.gz +0 -0
  85. package/build/client/_app/immutable/chunks/PPVm8Dsz.js.gz +0 -0
  86. package/build/client/_app/immutable/chunks/UJOiqIYE.js +1 -0
  87. package/build/client/_app/immutable/chunks/UJOiqIYE.js.br +0 -0
  88. package/build/client/_app/immutable/chunks/UJOiqIYE.js.gz +0 -0
  89. package/build/client/_app/immutable/chunks/r0JawsZc.js +2 -0
  90. package/build/client/_app/immutable/chunks/r0JawsZc.js.br +0 -0
  91. package/build/client/_app/immutable/chunks/r0JawsZc.js.gz +0 -0
  92. package/build/client/_app/immutable/entry/app.Z3zMnuSx.js +2 -0
  93. package/build/client/_app/immutable/entry/app.Z3zMnuSx.js.br +0 -0
  94. package/build/client/_app/immutable/entry/app.Z3zMnuSx.js.gz +0 -0
  95. package/build/client/_app/immutable/entry/start.Dd-gIP4y.js +1 -0
  96. package/build/client/_app/immutable/entry/start.Dd-gIP4y.js.br +2 -0
  97. package/build/client/_app/immutable/entry/start.Dd-gIP4y.js.gz +0 -0
  98. package/build/client/_app/immutable/nodes/0.D2YR8tTD.js +1 -0
  99. package/build/client/_app/immutable/nodes/0.D2YR8tTD.js.br +0 -0
  100. package/build/client/_app/immutable/nodes/0.D2YR8tTD.js.gz +0 -0
  101. package/build/client/_app/immutable/nodes/1.B3m6rO4C.js +1 -0
  102. package/build/client/_app/immutable/nodes/1.B3m6rO4C.js.br +0 -0
  103. package/build/client/_app/immutable/nodes/1.B3m6rO4C.js.gz +0 -0
  104. package/build/client/_app/immutable/nodes/2.CyRB2euU.js +1 -0
  105. package/build/client/_app/immutable/nodes/2.CyRB2euU.js.br +0 -0
  106. package/build/client/_app/immutable/nodes/2.CyRB2euU.js.gz +0 -0
  107. package/build/client/_app/immutable/nodes/3.3yohCM25.js +3 -0
  108. package/build/client/_app/immutable/nodes/3.3yohCM25.js.br +0 -0
  109. package/build/client/_app/immutable/nodes/3.3yohCM25.js.gz +0 -0
  110. package/build/client/_app/immutable/nodes/4.DEAcwl7l.js +1 -0
  111. package/build/client/_app/immutable/nodes/4.DEAcwl7l.js.br +0 -0
  112. package/build/client/_app/immutable/nodes/4.DEAcwl7l.js.gz +0 -0
  113. package/build/client/_app/immutable/nodes/5.C6bLGWQR.js +4 -0
  114. package/build/client/_app/immutable/nodes/5.C6bLGWQR.js.br +0 -0
  115. package/build/client/_app/immutable/nodes/5.C6bLGWQR.js.gz +0 -0
  116. package/build/client/_app/immutable/nodes/6.ByTzlA2D.js +2 -0
  117. package/build/client/_app/immutable/nodes/6.ByTzlA2D.js.br +0 -0
  118. package/build/client/_app/immutable/nodes/6.ByTzlA2D.js.gz +0 -0
  119. package/build/client/_app/immutable/nodes/7.BPMfwzd2.js +2 -0
  120. package/build/client/_app/immutable/nodes/7.BPMfwzd2.js.br +0 -0
  121. package/build/client/_app/immutable/nodes/7.BPMfwzd2.js.gz +0 -0
  122. package/build/client/_app/version.json +1 -1
  123. package/build/client/_app/version.json.br +0 -0
  124. package/build/client/_app/version.json.gz +0 -0
  125. package/build/client/favicon.svg.gz +0 -0
  126. package/build/client/manifest.json +13 -0
  127. package/build/client/manifest.json.br +0 -0
  128. package/build/client/manifest.json.gz +0 -0
  129. package/build/pty-holder.cjs +37 -8
  130. package/build/server/chunks/0-Vk38tI2J.js +9 -0
  131. package/build/server/chunks/0-Vk38tI2J.js.map +1 -0
  132. package/build/server/chunks/1-BvYQX5MR.js +9 -0
  133. package/build/server/chunks/1-BvYQX5MR.js.map +1 -0
  134. package/build/server/chunks/2-Cl7R4Qk2.js +9 -0
  135. package/build/server/chunks/2-Cl7R4Qk2.js.map +1 -0
  136. package/build/server/chunks/3-Ck7ewhOX.js +9 -0
  137. package/build/server/chunks/3-Ck7ewhOX.js.map +1 -0
  138. package/build/server/chunks/4-CnDeRm2Z.js +9 -0
  139. package/build/server/chunks/4-CnDeRm2Z.js.map +1 -0
  140. package/build/server/chunks/5-IxitzEvN.js +9 -0
  141. package/build/server/chunks/5-IxitzEvN.js.map +1 -0
  142. package/build/server/chunks/6-CyZ3r1iS.js +9 -0
  143. package/build/server/chunks/6-CyZ3r1iS.js.map +1 -0
  144. package/build/server/chunks/7-BmI7du46.js +9 -0
  145. package/build/server/chunks/7-BmI7du46.js.map +1 -0
  146. package/build/server/chunks/Button-Cs1aE6ka.js +80 -0
  147. package/build/server/chunks/Button-Cs1aE6ka.js.map +1 -0
  148. package/build/server/chunks/EmptyState-DDFH1K8g.js +26 -0
  149. package/build/server/chunks/EmptyState-DDFH1K8g.js.map +1 -0
  150. package/build/server/chunks/Icon-CEUrotA6.js +36 -0
  151. package/build/server/chunks/Icon-CEUrotA6.js.map +1 -0
  152. package/build/server/chunks/Shimmer-DB8W1zt6.js +10 -0
  153. package/build/server/chunks/Shimmer-DB8W1zt6.js.map +1 -0
  154. package/build/server/chunks/_error.svelte-uCOJNxvr.js +39 -0
  155. package/build/server/chunks/_error.svelte-uCOJNxvr.js.map +1 -0
  156. package/build/server/chunks/_layout.svelte-CtWmEJwe.js +56 -0
  157. package/build/server/chunks/_layout.svelte-CtWmEJwe.js.map +1 -0
  158. package/build/server/chunks/_page.svelte-BcZaKdX9.js +45 -0
  159. package/build/server/chunks/_page.svelte-BcZaKdX9.js.map +1 -0
  160. package/build/server/chunks/_page.svelte-BdYynOck.js +85 -0
  161. package/build/server/chunks/_page.svelte-BdYynOck.js.map +1 -0
  162. package/build/server/chunks/_page.svelte-BgevQjq1.js +101 -0
  163. package/build/server/chunks/_page.svelte-BgevQjq1.js.map +1 -0
  164. package/build/server/chunks/_page.svelte-CVq6tRb3.js +550 -0
  165. package/build/server/chunks/_page.svelte-CVq6tRb3.js.map +1 -0
  166. package/build/server/chunks/_page.svelte-CxWcQ0Am.js +651 -0
  167. package/build/server/chunks/_page.svelte-CxWcQ0Am.js.map +1 -0
  168. package/build/server/chunks/_page.svelte-DO4oa_LY.js +44 -0
  169. package/build/server/chunks/_page.svelte-DO4oa_LY.js.map +1 -0
  170. package/build/server/chunks/{_server.ts-CbDRDIoP.js → _server.ts-BStnNIcq.js} +9 -11
  171. package/build/server/chunks/_server.ts-BStnNIcq.js.map +1 -0
  172. package/build/server/chunks/{_server.ts-DRVbgm6k.js → _server.ts-CAxsWKvS.js} +22 -25
  173. package/build/server/chunks/_server.ts-CAxsWKvS.js.map +1 -0
  174. package/build/server/chunks/{_server.ts-CPa6DgIt.js → _server.ts-COu0vNpd.js} +6 -6
  175. package/build/server/chunks/_server.ts-COu0vNpd.js.map +1 -0
  176. package/build/server/chunks/{_server.ts-C29xzfaw.js → _server.ts-CTpcLUH8.js} +10 -10
  177. package/build/server/chunks/_server.ts-CTpcLUH8.js.map +1 -0
  178. package/build/server/chunks/{_server.ts-D4MNi4cD.js → _server.ts-Cf84YIaW.js} +3 -3
  179. package/build/server/chunks/{_server.ts-D4MNi4cD.js.map → _server.ts-Cf84YIaW.js.map} +1 -1
  180. package/build/server/chunks/{_server.ts-BL2FGb5Z.js → _server.ts-Ch-6iOHp.js} +99 -53
  181. package/build/server/chunks/_server.ts-Ch-6iOHp.js.map +1 -0
  182. package/build/server/chunks/_server.ts-CtH0dhUp.js +71 -0
  183. package/build/server/chunks/_server.ts-CtH0dhUp.js.map +1 -0
  184. package/build/server/chunks/_server.ts-DB_Kg97c.js +73 -0
  185. package/build/server/chunks/_server.ts-DB_Kg97c.js.map +1 -0
  186. package/build/server/chunks/{_server.ts-DfajWaqh.js → _server.ts-DV8zTCF9.js} +7 -9
  187. package/build/server/chunks/_server.ts-DV8zTCF9.js.map +1 -0
  188. package/build/server/chunks/_server.ts-DYpJImqd.js +99 -0
  189. package/build/server/chunks/_server.ts-DYpJImqd.js.map +1 -0
  190. package/build/server/chunks/{_server.ts-ColfDHW8.js → _server.ts-DYvb9ijZ.js} +21 -10
  191. package/build/server/chunks/_server.ts-DYvb9ijZ.js.map +1 -0
  192. package/build/server/chunks/{_server.ts-Cv_OrRuL.js → _server.ts-Deok2y88.js} +209 -34
  193. package/build/server/chunks/_server.ts-Deok2y88.js.map +1 -0
  194. package/build/server/chunks/{_server.ts-y9-WYDMa.js → _server.ts-WhTJBEJy.js} +5 -4
  195. package/build/server/chunks/{_server.ts-y9-WYDMa.js.map → _server.ts-WhTJBEJy.js.map} +1 -1
  196. package/build/server/chunks/{_server.ts-BjOJsoy4.js → _server.ts-XzT2UHM1.js} +6 -5
  197. package/build/server/chunks/_server.ts-XzT2UHM1.js.map +1 -0
  198. package/build/server/chunks/{_server.ts-BgdjBZco.js → _server.ts-tSpgyl1D.js} +7 -5
  199. package/build/server/chunks/_server.ts-tSpgyl1D.js.map +1 -0
  200. package/build/server/chunks/{_server.ts-BihKSdj_.js → _server.ts-vekTmWAx.js} +8 -8
  201. package/build/server/chunks/_server.ts-vekTmWAx.js.map +1 -0
  202. package/build/server/chunks/{auth-CEgFis71.js → auth-DeCdZ83n.js} +2 -2
  203. package/build/server/chunks/{auth-CEgFis71.js.map → auth-DeCdZ83n.js.map} +1 -1
  204. package/build/server/chunks/client-BdGHe_hY.js +25 -0
  205. package/build/server/chunks/client-BdGHe_hY.js.map +1 -0
  206. package/build/server/chunks/client2-CCBGA-2V.js +7 -0
  207. package/build/server/chunks/client2-CCBGA-2V.js.map +1 -0
  208. package/build/server/chunks/error-DDXB3duW.js +12 -0
  209. package/build/server/chunks/error-DDXB3duW.js.map +1 -0
  210. package/build/server/chunks/{exports-CJ0Q5XmL.js → index-DwaY1cAm.js} +1111 -1634
  211. package/build/server/chunks/index-DwaY1cAm.js.map +1 -0
  212. package/build/server/chunks/index-server-CrDaL06Y.js +9 -0
  213. package/build/server/chunks/index-server-CrDaL06Y.js.map +1 -0
  214. package/build/server/chunks/index2-CgclKpUj.js +58 -0
  215. package/build/server/chunks/index2-CgclKpUj.js.map +1 -0
  216. package/build/server/chunks/{library-apns-BHxLmuIx.js → library-apns-BqJbvSKh.js} +4 -4
  217. package/build/server/chunks/library-apns-BqJbvSKh.js.map +1 -0
  218. package/build/server/chunks/markdown-W_mTBct0.js +8 -0
  219. package/build/server/chunks/markdown-W_mTBct0.js.map +1 -0
  220. package/build/server/chunks/opencode-db-path-DcfhJtJy.js +15 -0
  221. package/build/server/chunks/opencode-db-path-DcfhJtJy.js.map +1 -0
  222. package/build/server/chunks/{pty-manager-C0FhBiVq.js → pty-manager-BQVB7IVj.js} +155 -326
  223. package/build/server/chunks/pty-manager-BQVB7IVj.js.map +1 -0
  224. package/build/server/chunks/root-DDSnEAZv.js +1171 -0
  225. package/build/server/chunks/root-DDSnEAZv.js.map +1 -0
  226. package/build/server/chunks/{shared-server-BDY8jh20.js → shared-server-sSGG17Df.js} +2 -3
  227. package/build/server/chunks/{shared-server-BDY8jh20.js.map → shared-server-sSGG17Df.js.map} +1 -1
  228. package/build/server/chunks/state.svelte-hBbXlUak.js +11 -0
  229. package/build/server/chunks/state.svelte-hBbXlUak.js.map +1 -0
  230. package/build/server/chunks/stores-DHNzYNpX.js +28 -0
  231. package/build/server/chunks/stores-DHNzYNpX.js.map +1 -0
  232. package/build/server/index.js +1085 -2242
  233. package/build/server/index.js.map +1 -1
  234. package/build/server/manifest.js +39 -25
  235. package/build/server/manifest.js.map +1 -1
  236. package/package.json +32 -9
  237. package/scripts/fix-generated-types.sh +37 -0
  238. package/scripts/homebrew/shooter.rb +51 -0
  239. package/scripts/install.sh +348 -186
  240. package/scripts/setup.cjs +215 -45
  241. package/server.ts +114 -71
  242. package/src/app.css +12 -3
  243. package/src/app.d.ts +13 -20
  244. package/src/app.html +3 -2
  245. package/src/generated/types/API.ts +280 -0
  246. package/src/generated/types/APN.ts +186 -203
  247. package/src/generated/types/CLI.ts +18 -25
  248. package/src/generated/types/Client.ts +589 -0
  249. package/src/generated/types/Config.ts +53 -0
  250. package/src/generated/types/Holder.ts +638 -0
  251. package/src/generated/types/JWT.ts +39 -50
  252. package/src/generated/types/Notification.ts +426 -0
  253. package/src/generated/types/OpenCode.ts +356 -0
  254. package/src/generated/types/Sessions.ts +570 -0
  255. package/src/generated/types/Terminal.ts +2184 -2071
  256. package/src/generated/types/WsProtocol.ts +2004 -0
  257. package/src/generated/types/index.ts +9 -3
  258. package/src/lib/env.ts +29 -0
  259. package/src/lib/modules/client/common/cache.ts +10 -2
  260. package/src/lib/modules/client/common/config-guard.ts +37 -5
  261. package/src/lib/modules/client/common/error.ts +10 -0
  262. package/src/lib/modules/client/common/index.ts +6 -5
  263. package/src/lib/modules/client/common/markdown.ts +22 -1
  264. package/src/lib/modules/client/common/native-bridge.ts +28 -20
  265. package/src/lib/modules/client/common/time.ts +13 -11
  266. package/src/lib/modules/client/terminal/ChatView.svelte +354 -74
  267. package/src/lib/modules/client/terminal/CommandPalette.svelte +3 -2
  268. package/src/lib/modules/client/terminal/ConnectionStatus.svelte +7 -1
  269. package/src/lib/modules/client/terminal/LaunchSheet.svelte +147 -84
  270. package/src/lib/modules/client/terminal/QuickKeys.svelte +3 -1
  271. package/src/lib/modules/client/terminal/ShortcutsHelp.svelte +2 -5
  272. package/src/lib/modules/client/terminal/keyboard-shortcuts.ts +27 -24
  273. package/src/lib/modules/client/terminal/xterm-wrapper.ts +74 -45
  274. package/src/lib/modules/server/apn/library-apns.ts +3 -2
  275. package/src/lib/modules/server/apn/notification-history.ts +2 -13
  276. package/src/lib/modules/server/apn/notification-sessions.ts +3 -13
  277. package/src/lib/modules/server/apn/pending-requests.ts +3 -8
  278. package/src/lib/modules/server/apn/types.ts +5 -4
  279. package/src/lib/modules/server/cli/index.ts +3 -2
  280. package/src/lib/modules/server/fcm/fcm-service.ts +8 -6
  281. package/src/lib/modules/server/sessions/jsonl-parser.ts +3 -3
  282. package/src/lib/modules/server/sessions/jsonl-reader.ts +86 -26
  283. package/src/lib/modules/server/sessions/opencode-db-path.ts +26 -0
  284. package/src/lib/modules/server/sessions/opencode-reader.ts +13 -15
  285. package/src/lib/modules/server/sessions/process-detector.ts +103 -0
  286. package/src/lib/modules/server/sessions/types.ts +11 -22
  287. package/src/lib/modules/server/terminal/holder-client.ts +272 -248
  288. package/src/lib/modules/server/terminal/opencode-watcher.ts +547 -556
  289. package/src/lib/modules/server/terminal/pty-holder.cjs +37 -8
  290. package/src/lib/modules/server/terminal/pty-manager.ts +157 -115
  291. package/src/lib/modules/server/terminal/session-watcher.ts +6 -4
  292. package/src/lib/modules/server/terminal/terminal-store.ts +131 -128
  293. package/src/lib/modules/server/utils/error.ts +9 -0
  294. package/src/lib/modules/server/ws/events-handler.ts +12 -6
  295. package/src/lib/modules/server/ws/keepalive.ts +86 -69
  296. package/src/lib/modules/server/ws/server.ts +43 -37
  297. package/src/lib/modules/server/ws/session-handler.ts +332 -147
  298. package/src/lib/modules/server/ws/terminal-handler.ts +29 -17
  299. package/src/lib/modules/server/ws/ticket-store.ts +29 -26
  300. package/src/lib/theme.css +30 -0
  301. package/src/lib/types/config.ts +1 -6
  302. package/src/routes/+error.svelte +94 -0
  303. package/src/routes/+layout.svelte +66 -31
  304. package/src/routes/+page.svelte +25 -22
  305. package/src/routes/api/debug/+server.ts +3 -1
  306. package/src/routes/api/device-token/+server.ts +60 -60
  307. package/src/routes/api/health/+server.ts +81 -73
  308. package/src/routes/api/notify/+server.ts +115 -68
  309. package/src/routes/api/qr-config/+server.ts +30 -32
  310. package/src/routes/api/response/+server.ts +9 -4
  311. package/src/routes/api/sessions/+server.ts +15 -5
  312. package/src/routes/api/sessions/connect/+server.ts +125 -0
  313. package/src/routes/api/sessions/detect/+server.ts +27 -0
  314. package/src/routes/api/terminals/+server.ts +26 -24
  315. package/src/routes/api/terminals/[id]/+server.ts +13 -7
  316. package/src/routes/api/terminals/[id]/paste-image/+server.ts +54 -52
  317. package/src/routes/api/terminals/[id]/resize/+server.ts +6 -3
  318. package/src/routes/api/webhook/+server.ts +8 -10
  319. package/src/routes/api/ws-status/+server.ts +7 -5
  320. package/src/routes/api/ws-ticket/+server.ts +42 -41
  321. package/src/routes/config/+page.svelte +149 -75
  322. package/src/routes/project/+page.svelte +165 -35
  323. package/src/routes/session/[id]/+page.svelte +479 -283
  324. package/src/routes/terminals/+page.svelte +58 -45
  325. package/src/routes/terminals/[id]/+page.svelte +223 -91
  326. package/build/client/_app/immutable/assets/0.CM9Hl6d-.css.br +0 -0
  327. package/build/client/_app/immutable/assets/0.CM9Hl6d-.css.gz +0 -0
  328. package/build/client/_app/immutable/assets/3.C0uFg0IS.css +0 -1
  329. package/build/client/_app/immutable/assets/3.C0uFg0IS.css.br +0 -0
  330. package/build/client/_app/immutable/assets/3.C0uFg0IS.css.gz +0 -0
  331. package/build/client/_app/immutable/assets/4.cJuCkJKZ.css +0 -1
  332. package/build/client/_app/immutable/assets/4.cJuCkJKZ.css.br +0 -0
  333. package/build/client/_app/immutable/assets/4.cJuCkJKZ.css.gz +0 -0
  334. package/build/client/_app/immutable/assets/5.DRjApZQW.css +0 -1
  335. package/build/client/_app/immutable/assets/5.DRjApZQW.css.br +0 -0
  336. package/build/client/_app/immutable/assets/5.DRjApZQW.css.gz +0 -0
  337. package/build/client/_app/immutable/assets/6.AraZrY8I.css +0 -1
  338. package/build/client/_app/immutable/assets/6.AraZrY8I.css.br +0 -0
  339. package/build/client/_app/immutable/assets/6.AraZrY8I.css.gz +0 -0
  340. package/build/client/_app/immutable/assets/7.BCJ1IuMx.css +0 -1
  341. package/build/client/_app/immutable/assets/7.BCJ1IuMx.css.br +0 -0
  342. package/build/client/_app/immutable/assets/7.BCJ1IuMx.css.gz +0 -0
  343. package/build/client/_app/immutable/assets/ChatView.CsdBAOKx.css +0 -1
  344. package/build/client/_app/immutable/assets/ChatView.CsdBAOKx.css.br +0 -0
  345. package/build/client/_app/immutable/assets/ChatView.CsdBAOKx.css.gz +0 -0
  346. package/build/client/_app/immutable/assets/markdown.B0b5w2tq.css +0 -1
  347. package/build/client/_app/immutable/assets/markdown.B0b5w2tq.css.br +0 -0
  348. package/build/client/_app/immutable/assets/markdown.B0b5w2tq.css.gz +0 -0
  349. package/build/client/_app/immutable/chunks/BNJphC1q.js +0 -56
  350. package/build/client/_app/immutable/chunks/BNJphC1q.js.br +0 -0
  351. package/build/client/_app/immutable/chunks/BNJphC1q.js.gz +0 -0
  352. package/build/client/_app/immutable/chunks/Bvk7mfPM.js +0 -1
  353. package/build/client/_app/immutable/chunks/Bvk7mfPM.js.br +0 -0
  354. package/build/client/_app/immutable/chunks/Bvk7mfPM.js.gz +0 -0
  355. package/build/client/_app/immutable/chunks/CAokzuPQ.js +0 -1
  356. package/build/client/_app/immutable/chunks/CAokzuPQ.js.br +0 -0
  357. package/build/client/_app/immutable/chunks/CAokzuPQ.js.gz +0 -0
  358. package/build/client/_app/immutable/chunks/CGLrx-H5.js +0 -1
  359. package/build/client/_app/immutable/chunks/CGLrx-H5.js.br +0 -0
  360. package/build/client/_app/immutable/chunks/CGLrx-H5.js.gz +0 -0
  361. package/build/client/_app/immutable/chunks/CgCpWzEA.js +0 -1
  362. package/build/client/_app/immutable/chunks/CgCpWzEA.js.br +0 -0
  363. package/build/client/_app/immutable/chunks/CgCpWzEA.js.gz +0 -0
  364. package/build/client/_app/immutable/chunks/Cjwk_cGO.js +0 -6
  365. package/build/client/_app/immutable/chunks/Cjwk_cGO.js.br +0 -0
  366. package/build/client/_app/immutable/chunks/Cjwk_cGO.js.gz +0 -0
  367. package/build/client/_app/immutable/chunks/CtQ8EED1.js +0 -11
  368. package/build/client/_app/immutable/chunks/CtQ8EED1.js.br +0 -0
  369. package/build/client/_app/immutable/chunks/CtQ8EED1.js.gz +0 -0
  370. package/build/client/_app/immutable/chunks/DERQCisl.js +0 -1
  371. package/build/client/_app/immutable/chunks/DERQCisl.js.br +0 -0
  372. package/build/client/_app/immutable/chunks/DERQCisl.js.gz +0 -0
  373. package/build/client/_app/immutable/chunks/DKrg8TQs.js +0 -1
  374. package/build/client/_app/immutable/chunks/DKrg8TQs.js.br +0 -0
  375. package/build/client/_app/immutable/chunks/DKrg8TQs.js.gz +0 -0
  376. package/build/client/_app/immutable/chunks/Dkkpz_4D.js +0 -126
  377. package/build/client/_app/immutable/chunks/Dkkpz_4D.js.br +0 -0
  378. package/build/client/_app/immutable/chunks/Dkkpz_4D.js.gz +0 -0
  379. package/build/client/_app/immutable/chunks/DoczjQhA.js +0 -1
  380. package/build/client/_app/immutable/chunks/DoczjQhA.js.br +0 -0
  381. package/build/client/_app/immutable/chunks/DoczjQhA.js.gz +0 -0
  382. package/build/client/_app/immutable/chunks/RpcNruLP.js +0 -2
  383. package/build/client/_app/immutable/chunks/RpcNruLP.js.br +0 -0
  384. package/build/client/_app/immutable/chunks/RpcNruLP.js.gz +0 -0
  385. package/build/client/_app/immutable/chunks/a-St0Zwo.js +0 -1
  386. package/build/client/_app/immutable/chunks/a-St0Zwo.js.br +0 -0
  387. package/build/client/_app/immutable/chunks/a-St0Zwo.js.gz +0 -0
  388. package/build/client/_app/immutable/chunks/bo70OQUZ.js +0 -1
  389. package/build/client/_app/immutable/chunks/bo70OQUZ.js.br +0 -0
  390. package/build/client/_app/immutable/chunks/bo70OQUZ.js.gz +0 -0
  391. package/build/client/_app/immutable/entry/app.QvGgdvTI.js +0 -2
  392. package/build/client/_app/immutable/entry/app.QvGgdvTI.js.br +0 -0
  393. package/build/client/_app/immutable/entry/app.QvGgdvTI.js.gz +0 -0
  394. package/build/client/_app/immutable/entry/start.BntDNRMC.js +0 -1
  395. package/build/client/_app/immutable/entry/start.BntDNRMC.js.br +0 -0
  396. package/build/client/_app/immutable/entry/start.BntDNRMC.js.gz +0 -0
  397. package/build/client/_app/immutable/nodes/0.CzkdvJ7j.js +0 -1
  398. package/build/client/_app/immutable/nodes/0.CzkdvJ7j.js.br +0 -0
  399. package/build/client/_app/immutable/nodes/0.CzkdvJ7j.js.gz +0 -0
  400. package/build/client/_app/immutable/nodes/1.MG1QhfrI.js +0 -1
  401. package/build/client/_app/immutable/nodes/1.MG1QhfrI.js.br +0 -0
  402. package/build/client/_app/immutable/nodes/1.MG1QhfrI.js.gz +0 -0
  403. package/build/client/_app/immutable/nodes/2.B4MlOSh6.js +0 -1
  404. package/build/client/_app/immutable/nodes/2.B4MlOSh6.js.br +0 -0
  405. package/build/client/_app/immutable/nodes/2.B4MlOSh6.js.gz +0 -0
  406. package/build/client/_app/immutable/nodes/3.DIwYkjDn.js +0 -3
  407. package/build/client/_app/immutable/nodes/3.DIwYkjDn.js.br +0 -0
  408. package/build/client/_app/immutable/nodes/3.DIwYkjDn.js.gz +0 -0
  409. package/build/client/_app/immutable/nodes/4.D-cIe70D.js +0 -1
  410. package/build/client/_app/immutable/nodes/4.D-cIe70D.js.br +0 -0
  411. package/build/client/_app/immutable/nodes/4.D-cIe70D.js.gz +0 -0
  412. package/build/client/_app/immutable/nodes/5.D7zPRe3L.js +0 -1
  413. package/build/client/_app/immutable/nodes/5.D7zPRe3L.js.br +0 -0
  414. package/build/client/_app/immutable/nodes/5.D7zPRe3L.js.gz +0 -0
  415. package/build/client/_app/immutable/nodes/6.BB7QE48r.js +0 -2
  416. package/build/client/_app/immutable/nodes/6.BB7QE48r.js.br +0 -0
  417. package/build/client/_app/immutable/nodes/6.BB7QE48r.js.gz +0 -0
  418. package/build/client/_app/immutable/nodes/7.D8mqsrZG.js +0 -2
  419. package/build/client/_app/immutable/nodes/7.D8mqsrZG.js.br +0 -0
  420. package/build/client/_app/immutable/nodes/7.D8mqsrZG.js.gz +0 -0
  421. package/build/client/manifest.webmanifest +0 -1
  422. package/build/client/registerSW.js +0 -1
  423. package/build/client/registerSW.js.br +0 -0
  424. package/build/client/registerSW.js.gz +0 -0
  425. package/build/client/sw.js +0 -222
  426. package/build/client/sw.js.br +0 -0
  427. package/build/client/sw.js.gz +0 -0
  428. package/build/client/workbox-5119daf5.js +0 -3395
  429. package/build/client/workbox-5119daf5.js.br +0 -0
  430. package/build/client/workbox-5119daf5.js.gz +0 -0
  431. package/build/server/chunks/0-q2IUp76Y.js +0 -9
  432. package/build/server/chunks/0-q2IUp76Y.js.map +0 -1
  433. package/build/server/chunks/1-CU50G5wZ.js +0 -9
  434. package/build/server/chunks/1-CU50G5wZ.js.map +0 -1
  435. package/build/server/chunks/2-D01t9s8T.js +0 -9
  436. package/build/server/chunks/2-D01t9s8T.js.map +0 -1
  437. package/build/server/chunks/3-5PUQ04wC.js +0 -9
  438. package/build/server/chunks/3-5PUQ04wC.js.map +0 -1
  439. package/build/server/chunks/4-e7gywnSG.js +0 -9
  440. package/build/server/chunks/4-e7gywnSG.js.map +0 -1
  441. package/build/server/chunks/5-CA1SA6KZ.js +0 -9
  442. package/build/server/chunks/5-CA1SA6KZ.js.map +0 -1
  443. package/build/server/chunks/6-71H221sV.js +0 -9
  444. package/build/server/chunks/6-71H221sV.js.map +0 -1
  445. package/build/server/chunks/7-Bo-vmdyz.js +0 -9
  446. package/build/server/chunks/7-Bo-vmdyz.js.map +0 -1
  447. package/build/server/chunks/_layout.svelte-SFHOxs74.js +0 -132
  448. package/build/server/chunks/_layout.svelte-SFHOxs74.js.map +0 -1
  449. package/build/server/chunks/_page.svelte-B4w-2wD-.js +0 -120
  450. package/build/server/chunks/_page.svelte-B4w-2wD-.js.map +0 -1
  451. package/build/server/chunks/_page.svelte-B_qAXjkh.js +0 -213
  452. package/build/server/chunks/_page.svelte-B_qAXjkh.js.map +0 -1
  453. package/build/server/chunks/_page.svelte-CsF1_TRG.js +0 -50
  454. package/build/server/chunks/_page.svelte-CsF1_TRG.js.map +0 -1
  455. package/build/server/chunks/_page.svelte-DJC6U-P0.js +0 -68
  456. package/build/server/chunks/_page.svelte-DJC6U-P0.js.map +0 -1
  457. package/build/server/chunks/_page.svelte-DQ6HBtsz.js +0 -407
  458. package/build/server/chunks/_page.svelte-DQ6HBtsz.js.map +0 -1
  459. package/build/server/chunks/_page.svelte-LbhhjP21.js +0 -148
  460. package/build/server/chunks/_page.svelte-LbhhjP21.js.map +0 -1
  461. package/build/server/chunks/_server.ts-BL2FGb5Z.js.map +0 -1
  462. package/build/server/chunks/_server.ts-BgdjBZco.js.map +0 -1
  463. package/build/server/chunks/_server.ts-BihKSdj_.js.map +0 -1
  464. package/build/server/chunks/_server.ts-BjOJsoy4.js.map +0 -1
  465. package/build/server/chunks/_server.ts-C29xzfaw.js.map +0 -1
  466. package/build/server/chunks/_server.ts-CPa6DgIt.js.map +0 -1
  467. package/build/server/chunks/_server.ts-CbDRDIoP.js.map +0 -1
  468. package/build/server/chunks/_server.ts-Cl1OEWL4.js +0 -54
  469. package/build/server/chunks/_server.ts-Cl1OEWL4.js.map +0 -1
  470. package/build/server/chunks/_server.ts-ColfDHW8.js.map +0 -1
  471. package/build/server/chunks/_server.ts-Cv_OrRuL.js.map +0 -1
  472. package/build/server/chunks/_server.ts-DRVbgm6k.js.map +0 -1
  473. package/build/server/chunks/_server.ts-DfajWaqh.js.map +0 -1
  474. package/build/server/chunks/client-CxCatAKr.js +0 -255
  475. package/build/server/chunks/client-CxCatAKr.js.map +0 -1
  476. package/build/server/chunks/error.svelte-BqdwMWdK.js +0 -26
  477. package/build/server/chunks/error.svelte-BqdwMWdK.js.map +0 -1
  478. package/build/server/chunks/exports-CJ0Q5XmL.js.map +0 -1
  479. package/build/server/chunks/index2-DAxIoAO-.js +0 -36
  480. package/build/server/chunks/index2-DAxIoAO-.js.map +0 -1
  481. package/build/server/chunks/jsonl-parser-dmZU_Hyu.js +0 -137
  482. package/build/server/chunks/jsonl-parser-dmZU_Hyu.js.map +0 -1
  483. package/build/server/chunks/library-apns-BHxLmuIx.js.map +0 -1
  484. package/build/server/chunks/markdown-Bxrl3cCF.js +0 -1241
  485. package/build/server/chunks/markdown-Bxrl3cCF.js.map +0 -1
  486. package/build/server/chunks/pty-manager-C0FhBiVq.js.map +0 -1
  487. package/build/server/chunks/stores-D0HorpgL.js +0 -36
  488. package/build/server/chunks/stores-D0HorpgL.js.map +0 -1
@@ -1,5 +1,7 @@
1
- import { D as DevalueError, i as is_primitive, g as get_type, a as is_plain_object, e as enumerable_symbols, s as stringify_key, b as stringify_string, w as with_request_store, t as text_decoder, c as base64_decode, r as render, d as set, L as LEGACY_PROPS, f as get, h as flushSync, j as define_property, m as mutable_source, k as init_operations, l as get_first_child, C as COMMENT_NODE, H as HYDRATION_START, n as get_next_sibling, o as HYDRATION_ERROR, p as hydration_failed, q as clear_text_content, S as STATE_SYMBOL, u as state_proxy_unmount, v as lifecycle_double_unmount, x as hydration_mismatch, y as array_from, z as component_root, A as set_active_reaction, B as set_active_effect, E as active_effect, F as active_reaction, G as is_passive_event, I as create_text, J as FILENAME, K as setContext, M as prevent_snippet_stringification, N as block, O as branch, P as queue_micro_task, Q as Batch, R as pause_effect, T as defer_effect, U as set_component_context, V as handle_error, W as component_context, X as move_effect, Y as set_signal_status, Z as DIRTY, _ as schedule_effect, $ as MAYBE_DIRTY, a0 as internal_set, a1 as destroy_effect, a2 as invoke_error_boundary, a3 as svelte_boundary_reset_onerror, a4 as tag, a5 as effect_tracking, a6 as render_effect, a7 as HYDRATION_END, a8 as svelte_boundary_reset_noop, a9 as source, aa as HYDRATION_START_ELSE, ab as untrack, ac as increment, ad as push$1, ae as pop$1, af as EFFECT_TRANSPARENT, ag as EFFECT_PRESERVED, ah as BOUNDARY_EFFECT, ai as decode_pathname, aj as decode_params, ak as DEV, al as validate_server_exports, am as normalize_path, an as disable_search, ao as validate_layout_server_exports, ap as validate_layout_exports, aq as validate_page_server_exports, ar as validate_page_exports, as as uneval, at as text_encoder, au as resolve, av as make_trackable, aw as get_relative_path, ax as base64_encode, ay as SCHEME, az as try_get_request_store, aA as writable, aB as readable } from './chunks/exports-CJ0Q5XmL.js';
2
- import { H as HttpError, j as json, t as text, S as SvelteKitError, f as fix_stack_trace, s as set_private_env, a as set_public_env, R as Redirect, p as public_env, e as error, A as ActionFailure } from './chunks/shared-server-BDY8jh20.js';
1
+ import { D as DevalueError, i as is_primitive, g as get_type, a as is_plain_object, e as enumerable_symbols, s as stringify_key, b as stringify_string, v as valid_array_indices, c as browser, u as uneval } from './chunks/index-DwaY1cAm.js';
2
+ import { H as HttpError, j as json, t as text, S as SvelteKitError, s as set_private_env, a as set_public_env, R as Redirect, p as public_env, e as error, A as ActionFailure } from './chunks/shared-server-sSGG17Df.js';
3
+ import { w as with_request_store, t as text_decoder, b as base64_decode, r as root, d as decode_pathname, n as normalize_path, a as disable_search, c as decode_params, v as validate_layout_server_exports, e as validate_layout_exports, f as validate_page_server_exports, g as validate_page_exports, h as text_encoder, i as resolve, m as make_trackable, j as get_relative_path, k as base64_encode } from './chunks/root-DDSnEAZv.js';
4
+ import { w as writable, r as readable } from './chunks/index2-CgclKpUj.js';
3
5
 
4
6
  /**
5
7
  * @template {{ tracing: { enabled: boolean, root: import('@opentelemetry/api').Span, current: import('@opentelemetry/api').Span } }} T
@@ -20,7 +22,7 @@ function merge_tracing(event_like, current) {
20
22
  let base = "";
21
23
  let assets = base;
22
24
  const app_dir = "_app";
23
- const relative$1 = true;
25
+ const relative = true;
24
26
  const initial = { base, assets };
25
27
  function override(paths) {
26
28
  base = paths.base;
@@ -31,68 +33,43 @@ function reset() {
31
33
  assets = initial.assets;
32
34
  }
33
35
 
34
- /**
35
- * Base64 Encodes an arraybuffer
36
- * @param {ArrayBuffer} arraybuffer
37
- * @returns {string}
38
- */
36
+ const SVELTE_KIT_ASSETS = "/_svelte_kit_assets";
37
+ const ENDPOINT_METHODS = ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS", "HEAD"];
38
+ const MUTATIVE_METHODS = ["POST", "PUT", "PATCH", "DELETE"];
39
+ const PAGE_METHODS = ["GET", "POST", "HEAD"];
39
40
  function encode64(arraybuffer) {
40
41
  const dv = new DataView(arraybuffer);
41
42
  let binaryString = "";
42
-
43
43
  for (let i = 0; i < arraybuffer.byteLength; i++) {
44
44
  binaryString += String.fromCharCode(dv.getUint8(i));
45
45
  }
46
-
47
46
  return binaryToAscii(binaryString);
48
47
  }
49
-
50
- /**
51
- * Decodes a base64 string into an arraybuffer
52
- * @param {string} string
53
- * @returns {ArrayBuffer}
54
- */
55
48
  function decode64(string) {
56
49
  const binaryString = asciiToBinary(string);
57
50
  const arraybuffer = new ArrayBuffer(binaryString.length);
58
51
  const dv = new DataView(arraybuffer);
59
-
60
52
  for (let i = 0; i < arraybuffer.byteLength; i++) {
61
53
  dv.setUint8(i, binaryString.charCodeAt(i));
62
54
  }
63
-
64
55
  return arraybuffer;
65
56
  }
66
-
67
- const KEY_STRING =
68
- "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
69
-
70
- /**
71
- * Substitute for atob since it's deprecated in node.
72
- * Does not do any input validation.
73
- *
74
- * @see https://github.com/jsdom/abab/blob/master/lib/atob.js
75
- *
76
- * @param {string} data
77
- * @returns {string}
78
- */
57
+ const KEY_STRING = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
79
58
  function asciiToBinary(data) {
80
59
  if (data.length % 4 === 0) {
81
60
  data = data.replace(/==?$/, "");
82
61
  }
83
-
84
62
  let output = "";
85
63
  let buffer = 0;
86
64
  let accumulatedBits = 0;
87
-
88
65
  for (let i = 0; i < data.length; i++) {
89
66
  buffer <<= 6;
90
67
  buffer |= KEY_STRING.indexOf(data[i]);
91
68
  accumulatedBits += 6;
92
69
  if (accumulatedBits === 24) {
93
- output += String.fromCharCode((buffer & 0xff0000) >> 16);
94
- output += String.fromCharCode((buffer & 0xff00) >> 8);
95
- output += String.fromCharCode(buffer & 0xff);
70
+ output += String.fromCharCode((buffer & 16711680) >> 16);
71
+ output += String.fromCharCode((buffer & 65280) >> 8);
72
+ output += String.fromCharCode(buffer & 255);
96
73
  buffer = accumulatedBits = 0;
97
74
  }
98
75
  }
@@ -101,35 +78,24 @@ function asciiToBinary(data) {
101
78
  output += String.fromCharCode(buffer);
102
79
  } else if (accumulatedBits === 18) {
103
80
  buffer >>= 2;
104
- output += String.fromCharCode((buffer & 0xff00) >> 8);
105
- output += String.fromCharCode(buffer & 0xff);
81
+ output += String.fromCharCode((buffer & 65280) >> 8);
82
+ output += String.fromCharCode(buffer & 255);
106
83
  }
107
84
  return output;
108
85
  }
109
-
110
- /**
111
- * Substitute for btoa since it's deprecated in node.
112
- * Does not do any input validation.
113
- *
114
- * @see https://github.com/jsdom/abab/blob/master/lib/btoa.js
115
- *
116
- * @param {string} str
117
- * @returns {string}
118
- */
119
86
  function binaryToAscii(str) {
120
87
  let out = "";
121
88
  for (let i = 0; i < str.length; i += 3) {
122
- /** @type {[number, number, number, number]} */
123
- const groupsOfSix = [undefined, undefined, undefined, undefined];
89
+ const groupsOfSix = [void 0, void 0, void 0, void 0];
124
90
  groupsOfSix[0] = str.charCodeAt(i) >> 2;
125
- groupsOfSix[1] = (str.charCodeAt(i) & 0x03) << 4;
91
+ groupsOfSix[1] = (str.charCodeAt(i) & 3) << 4;
126
92
  if (str.length > i + 1) {
127
93
  groupsOfSix[1] |= str.charCodeAt(i + 1) >> 4;
128
- groupsOfSix[2] = (str.charCodeAt(i + 1) & 0x0f) << 2;
94
+ groupsOfSix[2] = (str.charCodeAt(i + 1) & 15) << 2;
129
95
  }
130
96
  if (str.length > i + 2) {
131
97
  groupsOfSix[2] |= str.charCodeAt(i + 2) >> 6;
132
- groupsOfSix[3] = str.charCodeAt(i + 2) & 0x3f;
98
+ groupsOfSix[3] = str.charCodeAt(i + 2) & 63;
133
99
  }
134
100
  for (let j = 0; j < groupsOfSix.length; j++) {
135
101
  if (typeof groupsOfSix[j] === "undefined") {
@@ -141,108 +107,99 @@ function binaryToAscii(str) {
141
107
  }
142
108
  return out;
143
109
  }
144
-
145
110
  const UNDEFINED = -1;
146
111
  const HOLE = -2;
147
112
  const NAN = -3;
148
113
  const POSITIVE_INFINITY = -4;
149
114
  const NEGATIVE_INFINITY = -5;
150
115
  const NEGATIVE_ZERO = -6;
151
-
152
- /**
153
- * Revive a value serialized with `devalue.stringify`
154
- * @param {string} serialized
155
- * @param {Record<string, (value: any) => any>} [revivers]
156
- */
116
+ const SPARSE = -7;
157
117
  function parse(serialized, revivers) {
158
- return unflatten(JSON.parse(serialized), revivers);
118
+ return unflatten(JSON.parse(serialized), revivers);
159
119
  }
160
-
161
- /**
162
- * Revive a value flattened with `devalue.stringify`
163
- * @param {number | any[]} parsed
164
- * @param {Record<string, (value: any) => any>} [revivers]
165
- */
166
120
  function unflatten(parsed, revivers) {
167
- if (typeof parsed === 'number') return hydrate(parsed, true);
168
-
169
- if (!Array.isArray(parsed) || parsed.length === 0) {
170
- throw new Error('Invalid input');
171
- }
172
-
173
- const values = /** @type {any[]} */ (parsed);
174
-
175
- const hydrated = Array(values.length);
176
-
177
- /**
178
- * @param {number} index
179
- * @returns {any}
180
- */
181
- function hydrate(index, standalone = false) {
182
- if (index === UNDEFINED) return undefined;
183
- if (index === NAN) return NaN;
184
- if (index === POSITIVE_INFINITY) return Infinity;
185
- if (index === NEGATIVE_INFINITY) return -Infinity;
186
- if (index === NEGATIVE_ZERO) return -0;
187
-
188
- if (standalone) throw new Error(`Invalid input`);
189
-
190
- if (index in hydrated) return hydrated[index];
191
-
192
- const value = values[index];
193
-
194
- if (!value || typeof value !== 'object') {
195
- hydrated[index] = value;
196
- } else if (Array.isArray(value)) {
197
- if (typeof value[0] === 'string') {
198
- const type = value[0];
199
-
200
- const reviver = revivers?.[type];
201
- if (reviver) {
202
- return (hydrated[index] = reviver(hydrate(value[1])));
203
- }
204
-
205
- switch (type) {
206
- case 'Date':
207
- hydrated[index] = new Date(value[1]);
208
- break;
209
-
210
- case 'Set':
211
- const set = new Set();
212
- hydrated[index] = set;
213
- for (let i = 1; i < value.length; i += 1) {
214
- set.add(hydrate(value[i]));
215
- }
216
- break;
217
-
218
- case 'Map':
219
- const map = new Map();
220
- hydrated[index] = map;
221
- for (let i = 1; i < value.length; i += 2) {
222
- map.set(hydrate(value[i]), hydrate(value[i + 1]));
223
- }
224
- break;
225
-
226
- case 'RegExp':
227
- hydrated[index] = new RegExp(value[1], value[2]);
228
- break;
229
-
230
- case 'Object':
231
- hydrated[index] = Object(value[1]);
232
- break;
233
-
234
- case 'BigInt':
235
- hydrated[index] = BigInt(value[1]);
236
- break;
237
-
238
- case 'null':
239
- const obj = Object.create(null);
240
- hydrated[index] = obj;
241
- for (let i = 1; i < value.length; i += 2) {
242
- obj[value[i]] = hydrate(value[i + 1]);
243
- }
244
- break;
245
-
121
+ if (typeof parsed === "number") return hydrate(parsed, true);
122
+ if (!Array.isArray(parsed) || parsed.length === 0) {
123
+ throw new Error("Invalid input");
124
+ }
125
+ const values = (
126
+ /** @type {any[]} */
127
+ parsed
128
+ );
129
+ const hydrated = Array(values.length);
130
+ let hydrating = null;
131
+ function hydrate(index, standalone = false) {
132
+ if (index === UNDEFINED) return void 0;
133
+ if (index === NAN) return NaN;
134
+ if (index === POSITIVE_INFINITY) return Infinity;
135
+ if (index === NEGATIVE_INFINITY) return -Infinity;
136
+ if (index === NEGATIVE_ZERO) return -0;
137
+ if (standalone || typeof index !== "number") {
138
+ throw new Error(`Invalid input`);
139
+ }
140
+ if (index in hydrated) return hydrated[index];
141
+ const value = values[index];
142
+ if (!value || typeof value !== "object") {
143
+ hydrated[index] = value;
144
+ } else if (Array.isArray(value)) {
145
+ if (typeof value[0] === "string") {
146
+ const type = value[0];
147
+ const reviver = revivers && Object.hasOwn(revivers, type) ? revivers[type] : void 0;
148
+ if (reviver) {
149
+ let i = value[1];
150
+ if (typeof i !== "number") {
151
+ i = values.push(value[1]) - 1;
152
+ }
153
+ hydrating ??= /* @__PURE__ */ new Set();
154
+ if (hydrating.has(i)) {
155
+ throw new Error("Invalid circular reference");
156
+ }
157
+ hydrating.add(i);
158
+ hydrated[index] = reviver(hydrate(i));
159
+ hydrating.delete(i);
160
+ return hydrated[index];
161
+ }
162
+ switch (type) {
163
+ case "Date":
164
+ hydrated[index] = new Date(value[1]);
165
+ break;
166
+ case "Set":
167
+ const set = /* @__PURE__ */ new Set();
168
+ hydrated[index] = set;
169
+ for (let i = 1; i < value.length; i += 1) {
170
+ set.add(hydrate(value[i]));
171
+ }
172
+ break;
173
+ case "Map":
174
+ const map = /* @__PURE__ */ new Map();
175
+ hydrated[index] = map;
176
+ for (let i = 1; i < value.length; i += 2) {
177
+ map.set(hydrate(value[i]), hydrate(value[i + 1]));
178
+ }
179
+ break;
180
+ case "RegExp":
181
+ hydrated[index] = new RegExp(value[1], value[2]);
182
+ break;
183
+ case "Object":
184
+ const object = Object(value[1]);
185
+ if (Object.hasOwn(object, "__proto__")) {
186
+ throw new Error("Cannot parse an object with a `__proto__` property");
187
+ }
188
+ hydrated[index] = object;
189
+ break;
190
+ case "BigInt":
191
+ hydrated[index] = BigInt(value[1]);
192
+ break;
193
+ case "null":
194
+ const obj = /* @__PURE__ */ Object.create(null);
195
+ hydrated[index] = obj;
196
+ for (let i = 1; i < value.length; i += 2) {
197
+ if (value[i] === "__proto__") {
198
+ throw new Error("Cannot parse an object with a `__proto__` property");
199
+ }
200
+ obj[value[i]] = hydrate(value[i + 1]);
201
+ }
202
+ break;
246
203
  case "Int8Array":
247
204
  case "Uint8Array":
248
205
  case "Uint8ClampedArray":
@@ -254,269 +211,310 @@ function unflatten(parsed, revivers) {
254
211
  case "Float64Array":
255
212
  case "BigInt64Array":
256
213
  case "BigUint64Array": {
214
+ if (values[value[1]][0] !== "ArrayBuffer") {
215
+ throw new Error("Invalid data");
216
+ }
257
217
  const TypedArrayConstructor = globalThis[type];
258
- const base64 = value[1];
259
- const arraybuffer = decode64(base64);
260
- const typedArray = new TypedArrayConstructor(arraybuffer);
261
- hydrated[index] = typedArray;
218
+ const buffer = hydrate(value[1]);
219
+ const typedArray = new TypedArrayConstructor(buffer);
220
+ hydrated[index] = value[2] !== void 0 ? typedArray.subarray(value[2], value[3]) : typedArray;
262
221
  break;
263
222
  }
264
-
265
223
  case "ArrayBuffer": {
266
224
  const base64 = value[1];
225
+ if (typeof base64 !== "string") {
226
+ throw new Error("Invalid ArrayBuffer encoding");
227
+ }
267
228
  const arraybuffer = decode64(base64);
268
229
  hydrated[index] = arraybuffer;
269
230
  break;
270
231
  }
271
-
272
- default:
273
- throw new Error(`Unknown type ${type}`);
274
- }
275
- } else {
276
- const array = new Array(value.length);
277
- hydrated[index] = array;
278
-
279
- for (let i = 0; i < value.length; i += 1) {
280
- const n = value[i];
281
- if (n === HOLE) continue;
282
-
283
- array[i] = hydrate(n);
284
- }
285
- }
286
- } else {
287
- /** @type {Record<string, any>} */
288
- const object = {};
289
- hydrated[index] = object;
290
-
291
- for (const key in value) {
292
- const n = value[key];
293
- object[key] = hydrate(n);
294
- }
295
- }
296
-
297
- return hydrated[index];
298
- }
299
-
300
- return hydrate(0);
232
+ case "Temporal.Duration":
233
+ case "Temporal.Instant":
234
+ case "Temporal.PlainDate":
235
+ case "Temporal.PlainTime":
236
+ case "Temporal.PlainDateTime":
237
+ case "Temporal.PlainMonthDay":
238
+ case "Temporal.PlainYearMonth":
239
+ case "Temporal.ZonedDateTime": {
240
+ const temporalName = type.slice(9);
241
+ hydrated[index] = Temporal[temporalName].from(value[1]);
242
+ break;
243
+ }
244
+ case "URL": {
245
+ const url = new URL(value[1]);
246
+ hydrated[index] = url;
247
+ break;
248
+ }
249
+ case "URLSearchParams": {
250
+ const url = new URLSearchParams(value[1]);
251
+ hydrated[index] = url;
252
+ break;
253
+ }
254
+ default:
255
+ throw new Error(`Unknown type ${type}`);
256
+ }
257
+ } else if (value[0] === SPARSE) {
258
+ const len = value[1];
259
+ if (!Number.isInteger(len) || len < 0) {
260
+ throw new Error("Invalid input");
261
+ }
262
+ const array = new Array(len);
263
+ hydrated[index] = array;
264
+ for (let i = 2; i < value.length; i += 2) {
265
+ const idx = value[i];
266
+ if (!Number.isInteger(idx) || idx < 0 || idx >= len) {
267
+ throw new Error("Invalid input");
268
+ }
269
+ array[idx] = hydrate(value[i + 1]);
270
+ }
271
+ } else {
272
+ const array = new Array(value.length);
273
+ hydrated[index] = array;
274
+ for (let i = 0; i < value.length; i += 1) {
275
+ const n = value[i];
276
+ if (n === HOLE) continue;
277
+ array[i] = hydrate(n);
278
+ }
279
+ }
280
+ } else {
281
+ const object = {};
282
+ hydrated[index] = object;
283
+ for (const key of Object.keys(value)) {
284
+ if (key === "__proto__") {
285
+ throw new Error("Cannot parse an object with a `__proto__` property");
286
+ }
287
+ const n = value[key];
288
+ object[key] = hydrate(n);
289
+ }
290
+ }
291
+ return hydrated[index];
292
+ }
293
+ return hydrate(0);
301
294
  }
302
-
303
- /**
304
- * Turn a value into a JSON string that can be parsed with `devalue.parse`
305
- * @param {any} value
306
- * @param {Record<string, (value: any) => any>} [reducers]
307
- */
308
295
  function stringify$1(value, reducers) {
309
- /** @type {any[]} */
310
- const stringified = [];
311
-
312
- /** @type {Map<any, number>} */
313
- const indexes = new Map();
314
-
315
- /** @type {Array<{ key: string, fn: (value: any) => any }>} */
316
- const custom = [];
317
- if (reducers) {
318
- for (const key of Object.getOwnPropertyNames(reducers)) {
319
- custom.push({ key, fn: reducers[key] });
320
- }
321
- }
322
-
323
- /** @type {string[]} */
324
- const keys = [];
325
-
326
- let p = 0;
327
-
328
- /** @param {any} thing */
329
- function flatten(thing) {
330
- if (typeof thing === 'function') {
331
- throw new DevalueError(`Cannot stringify a function`, keys);
332
- }
333
-
334
- if (indexes.has(thing)) return indexes.get(thing);
335
-
336
- if (thing === undefined) return UNDEFINED;
337
- if (Number.isNaN(thing)) return NAN;
338
- if (thing === Infinity) return POSITIVE_INFINITY;
339
- if (thing === -Infinity) return NEGATIVE_INFINITY;
340
- if (thing === 0 && 1 / thing < 0) return NEGATIVE_ZERO;
341
-
342
- const index = p++;
343
- indexes.set(thing, index);
344
-
345
- for (const { key, fn } of custom) {
346
- const value = fn(thing);
347
- if (value) {
348
- stringified[index] = `["${key}",${flatten(value)}]`;
349
- return index;
350
- }
351
- }
352
-
353
- let str = '';
354
-
355
- if (is_primitive(thing)) {
356
- str = stringify_primitive(thing);
357
- } else {
358
- const type = get_type(thing);
359
-
360
- switch (type) {
361
- case 'Number':
362
- case 'String':
363
- case 'Boolean':
364
- str = `["Object",${stringify_primitive(thing)}]`;
365
- break;
366
-
367
- case 'BigInt':
368
- str = `["BigInt",${thing}]`;
369
- break;
370
-
371
- case 'Date':
372
- const valid = !isNaN(thing.getDate());
373
- str = `["Date","${valid ? thing.toISOString() : ''}"]`;
374
- break;
375
-
376
- case 'RegExp':
377
- const { source, flags } = thing;
378
- str = flags
379
- ? `["RegExp",${stringify_string(source)},"${flags}"]`
380
- : `["RegExp",${stringify_string(source)}]`;
381
- break;
382
-
383
- case 'Array':
384
- str = '[';
385
-
386
- for (let i = 0; i < thing.length; i += 1) {
387
- if (i > 0) str += ',';
388
-
389
- if (i in thing) {
390
- keys.push(`[${i}]`);
391
- str += flatten(thing[i]);
392
- keys.pop();
393
- } else {
394
- str += HOLE;
395
- }
396
- }
397
-
398
- str += ']';
399
-
400
- break;
401
-
402
- case 'Set':
403
- str = '["Set"';
404
-
405
- for (const value of thing) {
406
- str += `,${flatten(value)}`;
407
- }
408
-
409
- str += ']';
410
- break;
411
-
412
- case 'Map':
413
- str = '["Map"';
414
-
415
- for (const [key, value] of thing) {
416
- keys.push(
417
- `.get(${is_primitive(key) ? stringify_primitive(key) : '...'})`
418
- );
419
- str += `,${flatten(key)},${flatten(value)}`;
420
- keys.pop();
421
- }
422
-
423
- str += ']';
424
- break;
425
-
426
- case "Int8Array":
427
- case "Uint8Array":
428
- case "Uint8ClampedArray":
429
- case "Int16Array":
430
- case "Uint16Array":
431
- case "Int32Array":
432
- case "Uint32Array":
433
- case "Float32Array":
434
- case "Float64Array":
435
- case "BigInt64Array":
436
- case "BigUint64Array": {
437
- /** @type {import("./types.js").TypedArray} */
438
- const typedArray = thing;
439
- const base64 = encode64(typedArray.buffer);
440
- str = '["' + type + '","' + base64 + '"]';
441
- break;
442
- }
443
-
444
- case "ArrayBuffer": {
445
- /** @type {ArrayBuffer} */
446
- const arraybuffer = thing;
447
- const base64 = encode64(arraybuffer);
448
-
449
- str = `["ArrayBuffer","${base64}"]`;
450
- break;
451
- }
452
-
453
- default:
454
- if (!is_plain_object(thing)) {
455
- throw new DevalueError(
456
- `Cannot stringify arbitrary non-POJOs`,
457
- keys
458
- );
459
- }
460
-
461
- if (enumerable_symbols(thing).length > 0) {
462
- throw new DevalueError(
463
- `Cannot stringify POJOs with symbolic keys`,
464
- keys
465
- );
466
- }
467
-
468
- if (Object.getPrototypeOf(thing) === null) {
469
- str = '["null"';
470
- for (const key in thing) {
471
- keys.push(stringify_key(key));
472
- str += `,${stringify_string(key)},${flatten(thing[key])}`;
473
- keys.pop();
474
- }
475
- str += ']';
476
- } else {
477
- str = '{';
478
- let started = false;
479
- for (const key in thing) {
480
- if (started) str += ',';
481
- started = true;
482
- keys.push(stringify_key(key));
483
- str += `${stringify_string(key)}:${flatten(thing[key])}`;
484
- keys.pop();
485
- }
486
- str += '}';
487
- }
488
- }
489
- }
490
-
491
- stringified[index] = str;
492
- return index;
493
- }
494
-
495
- const index = flatten(value);
496
-
497
- // special case — value is represented as a negative index
498
- if (index < 0) return `${index}`;
499
-
500
- return `[${stringified.join(',')}]`;
296
+ const stringified = [];
297
+ const indexes = /* @__PURE__ */ new Map();
298
+ const custom = [];
299
+ if (reducers) {
300
+ for (const key of Object.getOwnPropertyNames(reducers)) {
301
+ custom.push({ key, fn: reducers[key] });
302
+ }
303
+ }
304
+ const keys = [];
305
+ let p = 0;
306
+ function flatten(thing) {
307
+ if (thing === void 0) return UNDEFINED;
308
+ if (Number.isNaN(thing)) return NAN;
309
+ if (thing === Infinity) return POSITIVE_INFINITY;
310
+ if (thing === -Infinity) return NEGATIVE_INFINITY;
311
+ if (thing === 0 && 1 / thing < 0) return NEGATIVE_ZERO;
312
+ if (indexes.has(thing)) return indexes.get(thing);
313
+ const index2 = p++;
314
+ indexes.set(thing, index2);
315
+ for (const { key, fn } of custom) {
316
+ const value2 = fn(thing);
317
+ if (value2) {
318
+ stringified[index2] = `["${key}",${flatten(value2)}]`;
319
+ return index2;
320
+ }
321
+ }
322
+ if (typeof thing === "function") {
323
+ throw new DevalueError(`Cannot stringify a function`, keys, thing, value);
324
+ }
325
+ let str = "";
326
+ if (is_primitive(thing)) {
327
+ str = stringify_primitive(thing);
328
+ } else {
329
+ const type = get_type(thing);
330
+ switch (type) {
331
+ case "Number":
332
+ case "String":
333
+ case "Boolean":
334
+ str = `["Object",${stringify_primitive(thing)}]`;
335
+ break;
336
+ case "BigInt":
337
+ str = `["BigInt",${thing}]`;
338
+ break;
339
+ case "Date":
340
+ const valid = !isNaN(thing.getDate());
341
+ str = `["Date","${valid ? thing.toISOString() : ""}"]`;
342
+ break;
343
+ case "URL":
344
+ str = `["URL",${stringify_string(thing.toString())}]`;
345
+ break;
346
+ case "URLSearchParams":
347
+ str = `["URLSearchParams",${stringify_string(thing.toString())}]`;
348
+ break;
349
+ case "RegExp":
350
+ const { source, flags } = thing;
351
+ str = flags ? `["RegExp",${stringify_string(source)},"${flags}"]` : `["RegExp",${stringify_string(source)}]`;
352
+ break;
353
+ case "Array": {
354
+ let mostly_dense = false;
355
+ str = "[";
356
+ for (let i = 0; i < thing.length; i += 1) {
357
+ if (i > 0) str += ",";
358
+ if (Object.hasOwn(thing, i)) {
359
+ keys.push(`[${i}]`);
360
+ str += flatten(thing[i]);
361
+ keys.pop();
362
+ } else if (mostly_dense) {
363
+ str += HOLE;
364
+ } else {
365
+ const populated_keys = valid_array_indices(
366
+ /** @type {any[]} */
367
+ thing
368
+ );
369
+ const population = populated_keys.length;
370
+ const d = String(thing.length).length;
371
+ const hole_cost = (thing.length - population) * 3;
372
+ const sparse_cost = 4 + d + population * (d + 1);
373
+ if (hole_cost > sparse_cost) {
374
+ str = "[" + SPARSE + "," + thing.length;
375
+ for (let j = 0; j < populated_keys.length; j++) {
376
+ const key = populated_keys[j];
377
+ keys.push(`[${key}]`);
378
+ str += "," + key + "," + flatten(thing[key]);
379
+ keys.pop();
380
+ }
381
+ break;
382
+ } else {
383
+ mostly_dense = true;
384
+ str += HOLE;
385
+ }
386
+ }
387
+ }
388
+ str += "]";
389
+ break;
390
+ }
391
+ case "Set":
392
+ str = '["Set"';
393
+ for (const value2 of thing) {
394
+ str += `,${flatten(value2)}`;
395
+ }
396
+ str += "]";
397
+ break;
398
+ case "Map":
399
+ str = '["Map"';
400
+ for (const [key, value2] of thing) {
401
+ keys.push(
402
+ `.get(${is_primitive(key) ? stringify_primitive(key) : "..."})`
403
+ );
404
+ str += `,${flatten(key)},${flatten(value2)}`;
405
+ keys.pop();
406
+ }
407
+ str += "]";
408
+ break;
409
+ case "Int8Array":
410
+ case "Uint8Array":
411
+ case "Uint8ClampedArray":
412
+ case "Int16Array":
413
+ case "Uint16Array":
414
+ case "Int32Array":
415
+ case "Uint32Array":
416
+ case "Float32Array":
417
+ case "Float64Array":
418
+ case "BigInt64Array":
419
+ case "BigUint64Array": {
420
+ const typedArray = thing;
421
+ str = '["' + type + '",' + flatten(typedArray.buffer);
422
+ const a = thing.byteOffset;
423
+ const b = a + thing.byteLength;
424
+ if (a > 0 || b !== typedArray.buffer.byteLength) {
425
+ const m = +/(\d+)/.exec(type)[1] / 8;
426
+ str += `,${a / m},${b / m}`;
427
+ }
428
+ str += "]";
429
+ break;
430
+ }
431
+ case "ArrayBuffer": {
432
+ const arraybuffer = thing;
433
+ const base64 = encode64(arraybuffer);
434
+ str = `["ArrayBuffer","${base64}"]`;
435
+ break;
436
+ }
437
+ case "Temporal.Duration":
438
+ case "Temporal.Instant":
439
+ case "Temporal.PlainDate":
440
+ case "Temporal.PlainTime":
441
+ case "Temporal.PlainDateTime":
442
+ case "Temporal.PlainMonthDay":
443
+ case "Temporal.PlainYearMonth":
444
+ case "Temporal.ZonedDateTime":
445
+ str = `["${type}",${stringify_string(thing.toString())}]`;
446
+ break;
447
+ default:
448
+ if (!is_plain_object(thing)) {
449
+ throw new DevalueError(
450
+ `Cannot stringify arbitrary non-POJOs`,
451
+ keys,
452
+ thing,
453
+ value
454
+ );
455
+ }
456
+ if (enumerable_symbols(thing).length > 0) {
457
+ throw new DevalueError(
458
+ `Cannot stringify POJOs with symbolic keys`,
459
+ keys,
460
+ thing,
461
+ value
462
+ );
463
+ }
464
+ if (Object.getPrototypeOf(thing) === null) {
465
+ str = '["null"';
466
+ for (const key of Object.keys(thing)) {
467
+ if (key === "__proto__") {
468
+ throw new DevalueError(
469
+ `Cannot stringify objects with __proto__ keys`,
470
+ keys,
471
+ thing,
472
+ value
473
+ );
474
+ }
475
+ keys.push(stringify_key(key));
476
+ str += `,${stringify_string(key)},${flatten(thing[key])}`;
477
+ keys.pop();
478
+ }
479
+ str += "]";
480
+ } else {
481
+ str = "{";
482
+ let started = false;
483
+ for (const key of Object.keys(thing)) {
484
+ if (key === "__proto__") {
485
+ throw new DevalueError(
486
+ `Cannot stringify objects with __proto__ keys`,
487
+ keys,
488
+ thing,
489
+ value
490
+ );
491
+ }
492
+ if (started) str += ",";
493
+ started = true;
494
+ keys.push(stringify_key(key));
495
+ str += `${stringify_string(key)}:${flatten(thing[key])}`;
496
+ keys.pop();
497
+ }
498
+ str += "}";
499
+ }
500
+ }
501
+ }
502
+ stringified[index2] = str;
503
+ return index2;
504
+ }
505
+ const index = flatten(value);
506
+ if (index < 0) return `${index}`;
507
+ return `[${stringified.join(",")}]`;
501
508
  }
502
-
503
- /**
504
- * @param {any} thing
505
- * @returns {string}
506
- */
507
509
  function stringify_primitive(thing) {
508
- const type = typeof thing;
509
- if (type === 'string') return stringify_string(thing);
510
- if (thing instanceof String) return stringify_string(thing.toString());
511
- if (thing === void 0) return UNDEFINED.toString();
512
- if (thing === 0 && 1 / thing < 0) return NEGATIVE_ZERO.toString();
513
- if (type === 'bigint') return `["BigInt","${thing}"]`;
514
- return String(thing);
510
+ const type = typeof thing;
511
+ if (type === "string") return stringify_string(thing);
512
+ if (thing instanceof String) return stringify_string(thing.toString());
513
+ if (thing === void 0) return UNDEFINED.toString();
514
+ if (thing === 0 && 1 / thing < 0) return NEGATIVE_ZERO.toString();
515
+ if (type === "bigint") return `["BigInt","${thing}"]`;
516
+ return String(thing);
515
517
  }
516
-
517
- const SVELTE_KIT_ASSETS = "/_svelte_kit_assets";
518
- const ENDPOINT_METHODS = ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS", "HEAD"];
519
- const PAGE_METHODS = ["GET", "POST", "HEAD"];
520
518
  function set_nested_value(object, path_string, value) {
521
519
  if (path_string.startsWith("n:")) {
522
520
  path_string = path_string.slice(2);
@@ -637,32 +635,49 @@ async function deserialize_binary_form(request) {
637
635
  if (file_offsets_length > 0) {
638
636
  const file_offsets_buffer = await get_buffer(HEADER_BYTES + data_length, file_offsets_length);
639
637
  if (!file_offsets_buffer) throw deserialize_error("file offset table too short");
638
+ const parsed_offsets = JSON.parse(text_decoder.decode(file_offsets_buffer));
639
+ if (!Array.isArray(parsed_offsets) || parsed_offsets.some((n) => typeof n !== "number" || !Number.isInteger(n) || n < 0)) {
640
+ throw deserialize_error("invalid file offset table");
641
+ }
640
642
  file_offsets = /** @type {Array<number>} */
641
- JSON.parse(text_decoder.decode(file_offsets_buffer));
643
+ parsed_offsets;
642
644
  files_start_offset = HEADER_BYTES + data_length + file_offsets_length;
643
645
  }
646
+ const file_spans = [];
644
647
  const [data, meta] = parse(text_decoder.decode(data_buffer), {
645
648
  File: ([name, type, size, last_modified, index]) => {
646
- if (files_start_offset + file_offsets[index] + size > content_length) {
649
+ if (typeof name !== "string" || typeof type !== "string" || typeof size !== "number" || typeof last_modified !== "number" || typeof index !== "number") {
650
+ throw deserialize_error("invalid file metadata");
651
+ }
652
+ let offset = file_offsets[index];
653
+ if (offset === void 0) {
654
+ throw deserialize_error("duplicate file offset table index");
655
+ }
656
+ file_offsets[index] = void 0;
657
+ offset += files_start_offset;
658
+ if (offset + size > content_length) {
647
659
  throw deserialize_error("file data overflow");
648
660
  }
649
- return new Proxy(
650
- new LazyFile(
651
- name,
652
- type,
653
- size,
654
- last_modified,
655
- get_chunk,
656
- files_start_offset + file_offsets[index]
657
- ),
658
- {
659
- getPrototypeOf() {
660
- return File.prototype;
661
- }
661
+ file_spans.push({ offset, size });
662
+ return new Proxy(new LazyFile(name, type, size, last_modified, get_chunk, offset), {
663
+ getPrototypeOf() {
664
+ return File.prototype;
662
665
  }
663
- );
666
+ });
664
667
  }
665
668
  });
669
+ file_spans.sort((a, b) => a.offset - b.offset || a.size - b.size);
670
+ for (let i = 1; i < file_spans.length; i++) {
671
+ const previous = file_spans[i - 1];
672
+ const current = file_spans[i];
673
+ const previous_end = previous.offset + previous.size;
674
+ if (previous_end < current.offset) {
675
+ throw deserialize_error("gaps in file data");
676
+ }
677
+ if (previous_end > current.offset) {
678
+ throw deserialize_error("overlapping file data");
679
+ }
680
+ }
666
681
  void (async () => {
667
682
  let has_more = true;
668
683
  while (has_more) {
@@ -744,7 +759,7 @@ class LazyFile {
744
759
  return new ReadableStream({
745
760
  start: async (controller) => {
746
761
  let chunk_start = 0;
747
- let start_chunk = null;
762
+ let start_chunk;
748
763
  for (chunk_index = 0; ; chunk_index++) {
749
764
  const chunk = await this.#get_chunk(chunk_index);
750
765
  if (!chunk) return null;
@@ -798,7 +813,7 @@ function split_path(path) {
798
813
  function check_prototype_pollution(key) {
799
814
  if (key === "__proto__" || key === "constructor" || key === "prototype") {
800
815
  throw new Error(
801
- `Invalid key "${key}": This key is not allowed to prevent prototype pollution.`
816
+ `Invalid key "${key}"`
802
817
  );
803
818
  }
804
819
  }
@@ -941,13 +956,10 @@ function allowed_methods(mod) {
941
956
  return allowed;
942
957
  }
943
958
  function get_global_name(options) {
944
- return "__sveltekit_dev";
959
+ return `__sveltekit_${options.version_hash}`;
945
960
  }
946
961
  function static_error_page(options, status, message) {
947
962
  let page = options.templates.error({ status, message: escape_html(message) });
948
- {
949
- page = page.replace("</head>", '<script type="module" src="/@vite/client"><\/script></head>');
950
- }
951
963
  return text(page, {
952
964
  headers: { "content-type": "text/html; charset=utf-8" },
953
965
  status
@@ -972,9 +984,6 @@ async function handle_error_and_jsonify(event, state, options, error) {
972
984
  if (error instanceof HttpError) {
973
985
  return { message: "Unknown Error", ...error.body };
974
986
  }
975
- if (typeof error == "object") {
976
- fix_stack_trace(error);
977
- }
978
987
  const status = get_status(error);
979
988
  const message = get_message(error);
980
989
  return await with_request_store(
@@ -1024,26 +1033,7 @@ function format_server_error(status, error, event) {
1024
1033
  return formatted_text;
1025
1034
  }
1026
1035
  return `${formatted_text}
1027
- ${clean_up_stack_trace(error)}`;
1028
- }
1029
- let relative = (file) => file;
1030
- {
1031
- try {
1032
- const path = await import('node:path');
1033
- const process = await import('node:process');
1034
- relative = (file) => path.relative(process.cwd(), file);
1035
- } catch {
1036
- }
1037
- }
1038
- function clean_up_stack_trace(error) {
1039
- const stack_trace = (error.stack?.split("\n") ?? []).map((line) => {
1040
- return line.replace(/\((.+)(:\d+:\d+)\)$/, (_, file, loc) => `(${relative(file)}${loc})`);
1041
- });
1042
- const last_line_from_src_code = stack_trace.findLastIndex((line) => /\(src[\\/]/.test(line));
1043
- if (last_line_from_src_code === -1) {
1044
- return error.stack;
1045
- }
1046
- return stack_trace.slice(0, last_line_from_src_code + 1).join("\n");
1036
+ ${error.stack}`;
1047
1037
  }
1048
1038
  function get_node_type(node_id) {
1049
1039
  const parts = node_id?.split("/");
@@ -1052,23 +1042,8 @@ function get_node_type(node_id) {
1052
1042
  const dot_parts = filename.split(".");
1053
1043
  return dot_parts.slice(0, -1).join(".");
1054
1044
  }
1055
- function validate_depends(route_id, dep) {
1056
- const match = /^(moz-icon|view-source|jar):/.exec(dep);
1057
- if (match) {
1058
- console.warn(
1059
- `${route_id}: Calling \`depends('${dep}')\` will throw an error in Firefox because \`${match[1]}\` is a special URI scheme`
1060
- );
1061
- }
1062
- }
1063
1045
  const INVALIDATED_PARAM = "x-sveltekit-invalidated";
1064
1046
  const TRAILING_SLASH_PARAM = "x-sveltekit-trailing-slash";
1065
- function validate_load_response(data, location_description) {
1066
- if (data != null && Object.getPrototypeOf(data) !== Object.prototype) {
1067
- throw new Error(
1068
- `a load function ${location_description} returned ${typeof data !== "object" ? `a ${typeof data}` : data instanceof Response ? "a Response object" : Array.isArray(data) ? "an array" : "a non-plain object"}, but must return a plain object at the top level (i.e. \`return {...}\`)`
1069
- );
1070
- }
1071
- }
1072
1047
  function stringify(data, transport) {
1073
1048
  const encoders = Object.fromEntries(Object.entries(transport).map(([k, v]) => [k, v.encode]));
1074
1049
  return stringify$1(data, encoders);
@@ -1082,1414 +1057,14 @@ function parse_remote_arg(string, transport) {
1082
1057
  const decoders = Object.fromEntries(Object.entries(transport).map(([k, v]) => [k, v.decode]));
1083
1058
  return parse(json_string, decoders);
1084
1059
  }
1085
- function create_remote_key(id, payload) {
1086
- return id + "/" + payload;
1087
- }
1088
-
1089
- var cookie = {};
1090
-
1091
- /*!
1092
- * cookie
1093
- * Copyright(c) 2012-2014 Roman Shtylman
1094
- * Copyright(c) 2015 Douglas Christopher Wilson
1095
- * MIT Licensed
1096
- */
1097
-
1098
- var hasRequiredCookie;
1099
-
1100
- function requireCookie () {
1101
- if (hasRequiredCookie) return cookie;
1102
- hasRequiredCookie = 1;
1103
-
1104
- /**
1105
- * Module exports.
1106
- * @public
1107
- */
1108
-
1109
- cookie.parse = parse;
1110
- cookie.serialize = serialize;
1111
-
1112
- /**
1113
- * Module variables.
1114
- * @private
1115
- */
1116
-
1117
- var __toString = Object.prototype.toString;
1118
-
1119
- /**
1120
- * RegExp to match field-content in RFC 7230 sec 3.2
1121
- *
1122
- * field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ]
1123
- * field-vchar = VCHAR / obs-text
1124
- * obs-text = %x80-FF
1125
- */
1126
-
1127
- var fieldContentRegExp = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;
1128
-
1129
- /**
1130
- * Parse a cookie header.
1131
- *
1132
- * Parse the given cookie header string into an object
1133
- * The object has the various cookies as keys(names) => values
1134
- *
1135
- * @param {string} str
1136
- * @param {object} [options]
1137
- * @return {object}
1138
- * @public
1139
- */
1140
-
1141
- function parse(str, options) {
1142
- if (typeof str !== 'string') {
1143
- throw new TypeError('argument str must be a string');
1144
- }
1145
-
1146
- var obj = {};
1147
- var opt = options || {};
1148
- var dec = opt.decode || decode;
1149
-
1150
- var index = 0;
1151
- while (index < str.length) {
1152
- var eqIdx = str.indexOf('=', index);
1153
-
1154
- // no more cookie pairs
1155
- if (eqIdx === -1) {
1156
- break
1157
- }
1158
-
1159
- var endIdx = str.indexOf(';', index);
1160
-
1161
- if (endIdx === -1) {
1162
- endIdx = str.length;
1163
- } else if (endIdx < eqIdx) {
1164
- // backtrack on prior semicolon
1165
- index = str.lastIndexOf(';', eqIdx - 1) + 1;
1166
- continue
1167
- }
1168
-
1169
- var key = str.slice(index, eqIdx).trim();
1170
-
1171
- // only assign once
1172
- if (undefined === obj[key]) {
1173
- var val = str.slice(eqIdx + 1, endIdx).trim();
1174
-
1175
- // quoted values
1176
- if (val.charCodeAt(0) === 0x22) {
1177
- val = val.slice(1, -1);
1178
- }
1179
-
1180
- obj[key] = tryDecode(val, dec);
1181
- }
1182
-
1183
- index = endIdx + 1;
1184
- }
1185
-
1186
- return obj;
1187
- }
1188
-
1189
- /**
1190
- * Serialize data into a cookie header.
1191
- *
1192
- * Serialize the a name value pair into a cookie string suitable for
1193
- * http headers. An optional options object specified cookie parameters.
1194
- *
1195
- * serialize('foo', 'bar', { httpOnly: true })
1196
- * => "foo=bar; httpOnly"
1197
- *
1198
- * @param {string} name
1199
- * @param {string} val
1200
- * @param {object} [options]
1201
- * @return {string}
1202
- * @public
1203
- */
1204
-
1205
- function serialize(name, val, options) {
1206
- var opt = options || {};
1207
- var enc = opt.encode || encode;
1208
-
1209
- if (typeof enc !== 'function') {
1210
- throw new TypeError('option encode is invalid');
1211
- }
1212
-
1213
- if (!fieldContentRegExp.test(name)) {
1214
- throw new TypeError('argument name is invalid');
1215
- }
1216
-
1217
- var value = enc(val);
1218
-
1219
- if (value && !fieldContentRegExp.test(value)) {
1220
- throw new TypeError('argument val is invalid');
1221
- }
1222
-
1223
- var str = name + '=' + value;
1224
-
1225
- if (null != opt.maxAge) {
1226
- var maxAge = opt.maxAge - 0;
1227
-
1228
- if (isNaN(maxAge) || !isFinite(maxAge)) {
1229
- throw new TypeError('option maxAge is invalid')
1230
- }
1231
-
1232
- str += '; Max-Age=' + Math.floor(maxAge);
1233
- }
1234
-
1235
- if (opt.domain) {
1236
- if (!fieldContentRegExp.test(opt.domain)) {
1237
- throw new TypeError('option domain is invalid');
1238
- }
1239
-
1240
- str += '; Domain=' + opt.domain;
1241
- }
1242
-
1243
- if (opt.path) {
1244
- if (!fieldContentRegExp.test(opt.path)) {
1245
- throw new TypeError('option path is invalid');
1246
- }
1247
-
1248
- str += '; Path=' + opt.path;
1249
- }
1250
-
1251
- if (opt.expires) {
1252
- var expires = opt.expires;
1253
-
1254
- if (!isDate(expires) || isNaN(expires.valueOf())) {
1255
- throw new TypeError('option expires is invalid');
1256
- }
1257
-
1258
- str += '; Expires=' + expires.toUTCString();
1259
- }
1260
-
1261
- if (opt.httpOnly) {
1262
- str += '; HttpOnly';
1263
- }
1264
-
1265
- if (opt.secure) {
1266
- str += '; Secure';
1267
- }
1268
-
1269
- if (opt.partitioned) {
1270
- str += '; Partitioned';
1271
- }
1272
-
1273
- if (opt.priority) {
1274
- var priority = typeof opt.priority === 'string'
1275
- ? opt.priority.toLowerCase()
1276
- : opt.priority;
1277
-
1278
- switch (priority) {
1279
- case 'low':
1280
- str += '; Priority=Low';
1281
- break
1282
- case 'medium':
1283
- str += '; Priority=Medium';
1284
- break
1285
- case 'high':
1286
- str += '; Priority=High';
1287
- break
1288
- default:
1289
- throw new TypeError('option priority is invalid')
1290
- }
1291
- }
1292
-
1293
- if (opt.sameSite) {
1294
- var sameSite = typeof opt.sameSite === 'string'
1295
- ? opt.sameSite.toLowerCase() : opt.sameSite;
1296
-
1297
- switch (sameSite) {
1298
- case true:
1299
- str += '; SameSite=Strict';
1300
- break;
1301
- case 'lax':
1302
- str += '; SameSite=Lax';
1303
- break;
1304
- case 'strict':
1305
- str += '; SameSite=Strict';
1306
- break;
1307
- case 'none':
1308
- str += '; SameSite=None';
1309
- break;
1310
- default:
1311
- throw new TypeError('option sameSite is invalid');
1312
- }
1313
- }
1314
-
1315
- return str;
1316
- }
1317
-
1318
- /**
1319
- * URL-decode string value. Optimized to skip native call when no %.
1320
- *
1321
- * @param {string} str
1322
- * @returns {string}
1323
- */
1324
-
1325
- function decode (str) {
1326
- return str.indexOf('%') !== -1
1327
- ? decodeURIComponent(str)
1328
- : str
1329
- }
1330
-
1331
- /**
1332
- * URL-encode value.
1333
- *
1334
- * @param {string} val
1335
- * @returns {string}
1336
- */
1337
-
1338
- function encode (val) {
1339
- return encodeURIComponent(val)
1340
- }
1341
-
1342
- /**
1343
- * Determine if value is a Date.
1344
- *
1345
- * @param {*} val
1346
- * @private
1347
- */
1348
-
1349
- function isDate (val) {
1350
- return __toString.call(val) === '[object Date]' ||
1351
- val instanceof Date
1352
- }
1353
-
1354
- /**
1355
- * Try decoding a string using a decoding function.
1356
- *
1357
- * @param {string} str
1358
- * @param {function} decode
1359
- * @private
1360
- */
1361
-
1362
- function tryDecode(str, decode) {
1363
- try {
1364
- return decode(str);
1365
- } catch (e) {
1366
- return str;
1367
- }
1368
- }
1369
- return cookie;
1370
- }
1371
-
1372
- var cookieExports = requireCookie();
1373
-
1374
- var setCookie = {exports: {}};
1375
-
1376
- var hasRequiredSetCookie;
1377
-
1378
- function requireSetCookie () {
1379
- if (hasRequiredSetCookie) return setCookie.exports;
1380
- hasRequiredSetCookie = 1;
1381
-
1382
- var defaultParseOptions = {
1383
- decodeValues: true,
1384
- map: false,
1385
- silent: false,
1386
- };
1387
-
1388
- function isNonEmptyString(str) {
1389
- return typeof str === "string" && !!str.trim();
1390
- }
1391
-
1392
- function parseString(setCookieValue, options) {
1393
- var parts = setCookieValue.split(";").filter(isNonEmptyString);
1394
-
1395
- var nameValuePairStr = parts.shift();
1396
- var parsed = parseNameValuePair(nameValuePairStr);
1397
- var name = parsed.name;
1398
- var value = parsed.value;
1399
-
1400
- options = options
1401
- ? Object.assign({}, defaultParseOptions, options)
1402
- : defaultParseOptions;
1403
-
1404
- try {
1405
- value = options.decodeValues ? decodeURIComponent(value) : value; // decode cookie value
1406
- } catch (e) {
1407
- console.error(
1408
- "set-cookie-parser encountered an error while decoding a cookie with value '" +
1409
- value +
1410
- "'. Set options.decodeValues to false to disable this feature.",
1411
- e
1412
- );
1413
- }
1414
-
1415
- var cookie = {
1416
- name: name,
1417
- value: value,
1418
- };
1419
-
1420
- parts.forEach(function (part) {
1421
- var sides = part.split("=");
1422
- var key = sides.shift().trimLeft().toLowerCase();
1423
- var value = sides.join("=");
1424
- if (key === "expires") {
1425
- cookie.expires = new Date(value);
1426
- } else if (key === "max-age") {
1427
- cookie.maxAge = parseInt(value, 10);
1428
- } else if (key === "secure") {
1429
- cookie.secure = true;
1430
- } else if (key === "httponly") {
1431
- cookie.httpOnly = true;
1432
- } else if (key === "samesite") {
1433
- cookie.sameSite = value;
1434
- } else if (key === "partitioned") {
1435
- cookie.partitioned = true;
1436
- } else {
1437
- cookie[key] = value;
1438
- }
1439
- });
1440
-
1441
- return cookie;
1442
- }
1443
-
1444
- function parseNameValuePair(nameValuePairStr) {
1445
- // Parses name-value-pair according to rfc6265bis draft
1446
-
1447
- var name = "";
1448
- var value = "";
1449
- var nameValueArr = nameValuePairStr.split("=");
1450
- if (nameValueArr.length > 1) {
1451
- name = nameValueArr.shift();
1452
- value = nameValueArr.join("="); // everything after the first =, joined by a "=" if there was more than one part
1453
- } else {
1454
- value = nameValuePairStr;
1455
- }
1456
-
1457
- return { name: name, value: value };
1458
- }
1459
-
1460
- function parse(input, options) {
1461
- options = options
1462
- ? Object.assign({}, defaultParseOptions, options)
1463
- : defaultParseOptions;
1464
-
1465
- if (!input) {
1466
- if (!options.map) {
1467
- return [];
1468
- } else {
1469
- return {};
1470
- }
1471
- }
1472
-
1473
- if (input.headers) {
1474
- if (typeof input.headers.getSetCookie === "function") {
1475
- // for fetch responses - they combine headers of the same type in the headers array,
1476
- // but getSetCookie returns an uncombined array
1477
- input = input.headers.getSetCookie();
1478
- } else if (input.headers["set-cookie"]) {
1479
- // fast-path for node.js (which automatically normalizes header names to lower-case
1480
- input = input.headers["set-cookie"];
1481
- } else {
1482
- // slow-path for other environments - see #25
1483
- var sch =
1484
- input.headers[
1485
- Object.keys(input.headers).find(function (key) {
1486
- return key.toLowerCase() === "set-cookie";
1487
- })
1488
- ];
1489
- // warn if called on a request-like object with a cookie header rather than a set-cookie header - see #34, 36
1490
- if (!sch && input.headers.cookie && !options.silent) {
1491
- console.warn(
1492
- "Warning: set-cookie-parser appears to have been called on a request object. It is designed to parse Set-Cookie headers from responses, not Cookie headers from requests. Set the option {silent: true} to suppress this warning."
1493
- );
1494
- }
1495
- input = sch;
1496
- }
1497
- }
1498
- if (!Array.isArray(input)) {
1499
- input = [input];
1500
- }
1501
-
1502
- if (!options.map) {
1503
- return input.filter(isNonEmptyString).map(function (str) {
1504
- return parseString(str, options);
1505
- });
1506
- } else {
1507
- var cookies = {};
1508
- return input.filter(isNonEmptyString).reduce(function (cookies, str) {
1509
- var cookie = parseString(str, options);
1510
- cookies[cookie.name] = cookie;
1511
- return cookies;
1512
- }, cookies);
1513
- }
1514
- }
1515
-
1516
- /*
1517
- Set-Cookie header field-values are sometimes comma joined in one string. This splits them without choking on commas
1518
- that are within a single set-cookie field-value, such as in the Expires portion.
1519
-
1520
- This is uncommon, but explicitly allowed - see https://tools.ietf.org/html/rfc2616#section-4.2
1521
- Node.js does this for every header *except* set-cookie - see https://github.com/nodejs/node/blob/d5e363b77ebaf1caf67cd7528224b651c86815c1/lib/_http_incoming.js#L128
1522
- React Native's fetch does this for *every* header, including set-cookie.
1523
-
1524
- Based on: https://github.com/google/j2objc/commit/16820fdbc8f76ca0c33472810ce0cb03d20efe25
1525
- Credits to: https://github.com/tomball for original and https://github.com/chrusart for JavaScript implementation
1526
- */
1527
- function splitCookiesString(cookiesString) {
1528
- if (Array.isArray(cookiesString)) {
1529
- return cookiesString;
1530
- }
1531
- if (typeof cookiesString !== "string") {
1532
- return [];
1533
- }
1534
-
1535
- var cookiesStrings = [];
1536
- var pos = 0;
1537
- var start;
1538
- var ch;
1539
- var lastComma;
1540
- var nextStart;
1541
- var cookiesSeparatorFound;
1542
-
1543
- function skipWhitespace() {
1544
- while (pos < cookiesString.length && /\s/.test(cookiesString.charAt(pos))) {
1545
- pos += 1;
1546
- }
1547
- return pos < cookiesString.length;
1548
- }
1549
-
1550
- function notSpecialChar() {
1551
- ch = cookiesString.charAt(pos);
1552
-
1553
- return ch !== "=" && ch !== ";" && ch !== ",";
1554
- }
1555
-
1556
- while (pos < cookiesString.length) {
1557
- start = pos;
1558
- cookiesSeparatorFound = false;
1559
-
1560
- while (skipWhitespace()) {
1561
- ch = cookiesString.charAt(pos);
1562
- if (ch === ",") {
1563
- // ',' is a cookie separator if we have later first '=', not ';' or ','
1564
- lastComma = pos;
1565
- pos += 1;
1566
-
1567
- skipWhitespace();
1568
- nextStart = pos;
1569
-
1570
- while (pos < cookiesString.length && notSpecialChar()) {
1571
- pos += 1;
1572
- }
1573
-
1574
- // currently special character
1575
- if (pos < cookiesString.length && cookiesString.charAt(pos) === "=") {
1576
- // we found cookies separator
1577
- cookiesSeparatorFound = true;
1578
- // pos is inside the next cookie, so back up and return it.
1579
- pos = nextStart;
1580
- cookiesStrings.push(cookiesString.substring(start, lastComma));
1581
- start = pos;
1582
- } else {
1583
- // in param ',' or param separator ';',
1584
- // we continue from that comma
1585
- pos = lastComma + 1;
1586
- }
1587
- } else {
1588
- pos += 1;
1589
- }
1590
- }
1591
-
1592
- if (!cookiesSeparatorFound || pos >= cookiesString.length) {
1593
- cookiesStrings.push(cookiesString.substring(start, cookiesString.length));
1594
- }
1595
- }
1596
-
1597
- return cookiesStrings;
1598
- }
1599
-
1600
- setCookie.exports = parse;
1601
- setCookie.exports.parse = parse;
1602
- setCookie.exports.parseString = parseString;
1603
- setCookie.exports.splitCookiesString = splitCookiesString;
1604
- return setCookie.exports;
1605
- }
1606
-
1607
- var setCookieExports = /*@__PURE__*/ requireSetCookie();
1608
-
1609
- let hydrating = false;
1610
- function set_hydrating(value) {
1611
- hydrating = value;
1612
- }
1613
- let hydrate_node;
1614
- function set_hydrate_node(node) {
1615
- if (node === null) {
1616
- hydration_mismatch();
1617
- throw HYDRATION_ERROR;
1618
- }
1619
- return hydrate_node = node;
1620
- }
1621
- function hydrate_next() {
1622
- return set_hydrate_node(get_next_sibling(hydrate_node));
1623
- }
1624
- function next(count = 1) {
1625
- if (hydrating) {
1626
- var i = count;
1627
- var node = hydrate_node;
1628
- while (i--) {
1629
- node = /** @type {TemplateNode} */
1630
- get_next_sibling(node);
1631
- }
1632
- hydrate_node = node;
1633
- }
1634
- }
1635
- function skip_nodes(remove = true) {
1636
- var depth = 0;
1637
- var node = hydrate_node;
1638
- while (true) {
1639
- if (node.nodeType === COMMENT_NODE) {
1640
- var data = (
1641
- /** @type {Comment} */
1642
- node.data
1643
- );
1644
- if (data === HYDRATION_END) {
1645
- if (depth === 0) return node;
1646
- depth -= 1;
1647
- } else if (data === HYDRATION_START || data === HYDRATION_START_ELSE) {
1648
- depth += 1;
1649
- }
1650
- }
1651
- var next2 = (
1652
- /** @type {TemplateNode} */
1653
- get_next_sibling(node)
1654
- );
1655
- if (remove) node.remove();
1656
- node = next2;
1657
- }
1658
- }
1659
- function createSubscriber(start) {
1660
- let subscribers = 0;
1661
- let version = source(0);
1662
- let stop;
1663
- {
1664
- tag(version, "createSubscriber version");
1665
- }
1666
- return () => {
1667
- if (effect_tracking()) {
1668
- get(version);
1669
- render_effect(() => {
1670
- if (subscribers === 0) {
1671
- stop = untrack(() => start(() => increment(version)));
1672
- }
1673
- subscribers += 1;
1674
- return () => {
1675
- queue_micro_task(() => {
1676
- subscribers -= 1;
1677
- if (subscribers === 0) {
1678
- stop?.();
1679
- stop = void 0;
1680
- increment(version);
1681
- }
1682
- });
1683
- };
1684
- });
1685
- }
1686
- };
1687
- }
1688
- var flags = EFFECT_TRANSPARENT | EFFECT_PRESERVED | BOUNDARY_EFFECT;
1689
- function boundary(node, props, children) {
1690
- new Boundary(node, props, children);
1691
- }
1692
- class Boundary {
1693
- /** @type {Boundary | null} */
1694
- parent;
1695
- is_pending = false;
1696
- /** @type {TemplateNode} */
1697
- #anchor;
1698
- /** @type {TemplateNode | null} */
1699
- #hydrate_open = hydrating ? hydrate_node : null;
1700
- /** @type {BoundaryProps} */
1701
- #props;
1702
- /** @type {((anchor: Node) => void)} */
1703
- #children;
1704
- /** @type {Effect} */
1705
- #effect;
1706
- /** @type {Effect | null} */
1707
- #main_effect = null;
1708
- /** @type {Effect | null} */
1709
- #pending_effect = null;
1710
- /** @type {Effect | null} */
1711
- #failed_effect = null;
1712
- /** @type {DocumentFragment | null} */
1713
- #offscreen_fragment = null;
1714
- /** @type {TemplateNode | null} */
1715
- #pending_anchor = null;
1716
- #local_pending_count = 0;
1717
- #pending_count = 0;
1718
- #pending_count_update_queued = false;
1719
- #is_creating_fallback = false;
1720
- /** @type {Set<Effect>} */
1721
- #dirty_effects = /* @__PURE__ */ new Set();
1722
- /** @type {Set<Effect>} */
1723
- #maybe_dirty_effects = /* @__PURE__ */ new Set();
1724
- /**
1725
- * A source containing the number of pending async deriveds/expressions.
1726
- * Only created if `$effect.pending()` is used inside the boundary,
1727
- * otherwise updating the source results in needless `Batch.ensure()`
1728
- * calls followed by no-op flushes
1729
- * @type {Source<number> | null}
1730
- */
1731
- #effect_pending = null;
1732
- #effect_pending_subscriber = createSubscriber(() => {
1733
- this.#effect_pending = source(this.#local_pending_count);
1734
- {
1735
- tag(this.#effect_pending, "$effect.pending()");
1736
- }
1737
- return () => {
1738
- this.#effect_pending = null;
1739
- };
1740
- });
1741
- /**
1742
- * @param {TemplateNode} node
1743
- * @param {BoundaryProps} props
1744
- * @param {((anchor: Node) => void)} children
1745
- */
1746
- constructor(node, props, children) {
1747
- this.#anchor = node;
1748
- this.#props = props;
1749
- this.#children = children;
1750
- this.parent = /** @type {Effect} */
1751
- active_effect.b;
1752
- this.is_pending = !!this.#props.pending;
1753
- this.#effect = block(() => {
1754
- active_effect.b = this;
1755
- if (hydrating) {
1756
- const comment = this.#hydrate_open;
1757
- hydrate_next();
1758
- const server_rendered_pending = (
1759
- /** @type {Comment} */
1760
- comment.nodeType === COMMENT_NODE && /** @type {Comment} */
1761
- comment.data === HYDRATION_START_ELSE
1762
- );
1763
- if (server_rendered_pending) {
1764
- this.#hydrate_pending_content();
1765
- } else {
1766
- this.#hydrate_resolved_content();
1767
- if (this.#pending_count === 0) {
1768
- this.is_pending = false;
1769
- }
1770
- }
1771
- } else {
1772
- var anchor = this.#get_anchor();
1773
- try {
1774
- this.#main_effect = branch(() => children(anchor));
1775
- } catch (error) {
1776
- this.error(error);
1777
- }
1778
- if (this.#pending_count > 0) {
1779
- this.#show_pending_snippet();
1780
- } else {
1781
- this.is_pending = false;
1782
- }
1783
- }
1784
- return () => {
1785
- this.#pending_anchor?.remove();
1786
- };
1787
- }, flags);
1788
- if (hydrating) {
1789
- this.#anchor = hydrate_node;
1790
- }
1791
- }
1792
- #hydrate_resolved_content() {
1793
- try {
1794
- this.#main_effect = branch(() => this.#children(this.#anchor));
1795
- } catch (error) {
1796
- this.error(error);
1797
- }
1798
- }
1799
- #hydrate_pending_content() {
1800
- const pending = this.#props.pending;
1801
- if (!pending) return;
1802
- this.#pending_effect = branch(() => pending(this.#anchor));
1803
- queue_micro_task(() => {
1804
- var anchor = this.#get_anchor();
1805
- this.#main_effect = this.#run(() => {
1806
- Batch.ensure();
1807
- return branch(() => this.#children(anchor));
1808
- });
1809
- if (this.#pending_count > 0) {
1810
- this.#show_pending_snippet();
1811
- } else {
1812
- pause_effect(
1813
- /** @type {Effect} */
1814
- this.#pending_effect,
1815
- () => {
1816
- this.#pending_effect = null;
1817
- }
1818
- );
1819
- this.is_pending = false;
1820
- }
1821
- });
1822
- }
1823
- #get_anchor() {
1824
- var anchor = this.#anchor;
1825
- if (this.is_pending) {
1826
- this.#pending_anchor = create_text();
1827
- this.#anchor.before(this.#pending_anchor);
1828
- anchor = this.#pending_anchor;
1829
- }
1830
- return anchor;
1831
- }
1832
- /**
1833
- * Defer an effect inside a pending boundary until the boundary resolves
1834
- * @param {Effect} effect
1835
- */
1836
- defer_effect(effect) {
1837
- defer_effect(effect, this.#dirty_effects, this.#maybe_dirty_effects);
1838
- }
1839
- /**
1840
- * Returns `false` if the effect exists inside a boundary whose pending snippet is shown
1841
- * @returns {boolean}
1842
- */
1843
- is_rendered() {
1844
- return !this.is_pending && (!this.parent || this.parent.is_rendered());
1845
- }
1846
- has_pending_snippet() {
1847
- return !!this.#props.pending;
1848
- }
1849
- /**
1850
- * @param {() => Effect | null} fn
1851
- */
1852
- #run(fn) {
1853
- var previous_effect = active_effect;
1854
- var previous_reaction = active_reaction;
1855
- var previous_ctx = component_context;
1856
- set_active_effect(this.#effect);
1857
- set_active_reaction(this.#effect);
1858
- set_component_context(this.#effect.ctx);
1859
- try {
1860
- return fn();
1861
- } catch (e) {
1862
- handle_error(e);
1863
- return null;
1864
- } finally {
1865
- set_active_effect(previous_effect);
1866
- set_active_reaction(previous_reaction);
1867
- set_component_context(previous_ctx);
1868
- }
1869
- }
1870
- #show_pending_snippet() {
1871
- const pending = (
1872
- /** @type {(anchor: Node) => void} */
1873
- this.#props.pending
1874
- );
1875
- if (this.#main_effect !== null) {
1876
- this.#offscreen_fragment = document.createDocumentFragment();
1877
- this.#offscreen_fragment.append(
1878
- /** @type {TemplateNode} */
1879
- this.#pending_anchor
1880
- );
1881
- move_effect(this.#main_effect, this.#offscreen_fragment);
1882
- }
1883
- if (this.#pending_effect === null) {
1884
- this.#pending_effect = branch(() => pending(this.#anchor));
1885
- }
1886
- }
1887
- /**
1888
- * Updates the pending count associated with the currently visible pending snippet,
1889
- * if any, such that we can replace the snippet with content once work is done
1890
- * @param {1 | -1} d
1891
- */
1892
- #update_pending_count(d) {
1893
- if (!this.has_pending_snippet()) {
1894
- if (this.parent) {
1895
- this.parent.#update_pending_count(d);
1896
- }
1897
- return;
1898
- }
1899
- this.#pending_count += d;
1900
- if (this.#pending_count === 0) {
1901
- this.is_pending = false;
1902
- for (const e of this.#dirty_effects) {
1903
- set_signal_status(e, DIRTY);
1904
- schedule_effect(e);
1905
- }
1906
- for (const e of this.#maybe_dirty_effects) {
1907
- set_signal_status(e, MAYBE_DIRTY);
1908
- schedule_effect(e);
1909
- }
1910
- this.#dirty_effects.clear();
1911
- this.#maybe_dirty_effects.clear();
1912
- if (this.#pending_effect) {
1913
- pause_effect(this.#pending_effect, () => {
1914
- this.#pending_effect = null;
1915
- });
1916
- }
1917
- if (this.#offscreen_fragment) {
1918
- this.#anchor.before(this.#offscreen_fragment);
1919
- this.#offscreen_fragment = null;
1920
- }
1921
- }
1922
- }
1923
- /**
1924
- * Update the source that powers `$effect.pending()` inside this boundary,
1925
- * and controls when the current `pending` snippet (if any) is removed.
1926
- * Do not call from inside the class
1927
- * @param {1 | -1} d
1928
- */
1929
- update_pending_count(d) {
1930
- this.#update_pending_count(d);
1931
- this.#local_pending_count += d;
1932
- if (!this.#effect_pending || this.#pending_count_update_queued) return;
1933
- this.#pending_count_update_queued = true;
1934
- queue_micro_task(() => {
1935
- this.#pending_count_update_queued = false;
1936
- if (this.#effect_pending) {
1937
- internal_set(this.#effect_pending, this.#local_pending_count);
1938
- }
1939
- });
1940
- }
1941
- get_effect_pending() {
1942
- this.#effect_pending_subscriber();
1943
- return get(
1944
- /** @type {Source<number>} */
1945
- this.#effect_pending
1946
- );
1947
- }
1948
- /** @param {unknown} error */
1949
- error(error) {
1950
- var onerror = this.#props.onerror;
1951
- let failed = this.#props.failed;
1952
- if (this.#is_creating_fallback || !onerror && !failed) {
1953
- throw error;
1954
- }
1955
- if (this.#main_effect) {
1956
- destroy_effect(this.#main_effect);
1957
- this.#main_effect = null;
1958
- }
1959
- if (this.#pending_effect) {
1960
- destroy_effect(this.#pending_effect);
1961
- this.#pending_effect = null;
1962
- }
1963
- if (this.#failed_effect) {
1964
- destroy_effect(this.#failed_effect);
1965
- this.#failed_effect = null;
1966
- }
1967
- if (hydrating) {
1968
- set_hydrate_node(
1969
- /** @type {TemplateNode} */
1970
- this.#hydrate_open
1971
- );
1972
- next();
1973
- set_hydrate_node(skip_nodes());
1974
- }
1975
- var did_reset = false;
1976
- var calling_on_error = false;
1977
- const reset = () => {
1978
- if (did_reset) {
1979
- svelte_boundary_reset_noop();
1980
- return;
1981
- }
1982
- did_reset = true;
1983
- if (calling_on_error) {
1984
- svelte_boundary_reset_onerror();
1985
- }
1986
- Batch.ensure();
1987
- this.#local_pending_count = 0;
1988
- if (this.#failed_effect !== null) {
1989
- pause_effect(this.#failed_effect, () => {
1990
- this.#failed_effect = null;
1991
- });
1992
- }
1993
- this.is_pending = this.has_pending_snippet();
1994
- this.#main_effect = this.#run(() => {
1995
- this.#is_creating_fallback = false;
1996
- return branch(() => this.#children(this.#anchor));
1997
- });
1998
- if (this.#pending_count > 0) {
1999
- this.#show_pending_snippet();
2000
- } else {
2001
- this.is_pending = false;
2002
- }
2003
- };
2004
- queue_micro_task(() => {
2005
- try {
2006
- calling_on_error = true;
2007
- onerror?.(error, reset);
2008
- calling_on_error = false;
2009
- } catch (error2) {
2010
- invoke_error_boundary(error2, this.#effect && this.#effect.parent);
2011
- }
2012
- if (failed) {
2013
- this.#failed_effect = this.#run(() => {
2014
- Batch.ensure();
2015
- this.#is_creating_fallback = true;
2016
- try {
2017
- return branch(() => {
2018
- failed(
2019
- this.#anchor,
2020
- () => error,
2021
- () => reset
2022
- );
2023
- });
2024
- } catch (error2) {
2025
- invoke_error_boundary(
2026
- error2,
2027
- /** @type {Effect} */
2028
- this.#effect.parent
2029
- );
2030
- return null;
2031
- } finally {
2032
- this.#is_creating_fallback = false;
2033
- }
2034
- });
2035
- }
2036
- });
2037
- }
2038
- }
2039
- const all_registered_events = /* @__PURE__ */ new Set();
2040
- const root_event_handles = /* @__PURE__ */ new Set();
2041
- let last_propagated_event = null;
2042
- function handle_event_propagation(event) {
2043
- var handler_element = this;
2044
- var owner_document = (
2045
- /** @type {Node} */
2046
- handler_element.ownerDocument
2047
- );
2048
- var event_name = event.type;
2049
- var path = event.composedPath?.() || [];
2050
- var current_target = (
2051
- /** @type {null | Element} */
2052
- path[0] || event.target
2053
- );
2054
- last_propagated_event = event;
2055
- var path_idx = 0;
2056
- var handled_at = last_propagated_event === event && event.__root;
2057
- if (handled_at) {
2058
- var at_idx = path.indexOf(handled_at);
2059
- if (at_idx !== -1 && (handler_element === document || handler_element === /** @type {any} */
2060
- window)) {
2061
- event.__root = handler_element;
2062
- return;
2063
- }
2064
- var handler_idx = path.indexOf(handler_element);
2065
- if (handler_idx === -1) {
2066
- return;
2067
- }
2068
- if (at_idx <= handler_idx) {
2069
- path_idx = at_idx;
2070
- }
2071
- }
2072
- current_target = /** @type {Element} */
2073
- path[path_idx] || event.target;
2074
- if (current_target === handler_element) return;
2075
- define_property(event, "currentTarget", {
2076
- configurable: true,
2077
- get() {
2078
- return current_target || owner_document;
2079
- }
2080
- });
2081
- var previous_reaction = active_reaction;
2082
- var previous_effect = active_effect;
2083
- set_active_reaction(null);
2084
- set_active_effect(null);
2085
- try {
2086
- var throw_error;
2087
- var other_errors = [];
2088
- while (current_target !== null) {
2089
- var parent_element = current_target.assignedSlot || current_target.parentNode || /** @type {any} */
2090
- current_target.host || null;
2091
- try {
2092
- var delegated = current_target["__" + event_name];
2093
- if (delegated != null && (!/** @type {any} */
2094
- current_target.disabled || // DOM could've been updated already by the time this is reached, so we check this as well
2095
- // -> the target could not have been disabled because it emits the event in the first place
2096
- event.target === current_target)) {
2097
- delegated.call(current_target, event);
2098
- }
2099
- } catch (error) {
2100
- if (throw_error) {
2101
- other_errors.push(error);
2102
- } else {
2103
- throw_error = error;
2104
- }
2105
- }
2106
- if (event.cancelBubble || parent_element === handler_element || parent_element === null) {
2107
- break;
2108
- }
2109
- current_target = parent_element;
2110
- }
2111
- if (throw_error) {
2112
- for (let error of other_errors) {
2113
- queueMicrotask(() => {
2114
- throw error;
2115
- });
2116
- }
2117
- throw throw_error;
2118
- }
2119
- } finally {
2120
- event.__root = handler_element;
2121
- delete event.currentTarget;
2122
- set_active_reaction(previous_reaction);
2123
- set_active_effect(previous_effect);
2124
- }
2125
- }
2126
- function assign_nodes(start, end) {
2127
- var effect = (
2128
- /** @type {Effect} */
2129
- active_effect
2130
- );
2131
- if (effect.nodes === null) {
2132
- effect.nodes = { start, end, a: null, t: null };
2133
- }
2134
- }
2135
- function mount(component, options2) {
2136
- return _mount(component, options2);
2137
- }
2138
- function hydrate(component, options2) {
2139
- init_operations();
2140
- options2.intro = options2.intro ?? false;
2141
- const target = options2.target;
2142
- const was_hydrating = hydrating;
2143
- const previous_hydrate_node = hydrate_node;
2144
- try {
2145
- var anchor = get_first_child(target);
2146
- while (anchor && (anchor.nodeType !== COMMENT_NODE || /** @type {Comment} */
2147
- anchor.data !== HYDRATION_START)) {
2148
- anchor = get_next_sibling(anchor);
2149
- }
2150
- if (!anchor) {
2151
- throw HYDRATION_ERROR;
2152
- }
2153
- set_hydrating(true);
2154
- set_hydrate_node(
2155
- /** @type {Comment} */
2156
- anchor
2157
- );
2158
- const instance = _mount(component, { ...options2, anchor });
2159
- set_hydrating(false);
2160
- return (
2161
- /** @type {Exports} */
2162
- instance
2163
- );
2164
- } catch (error) {
2165
- if (error instanceof Error && error.message.split("\n").some((line) => line.startsWith("https://svelte.dev/e/"))) {
2166
- throw error;
2167
- }
2168
- if (error !== HYDRATION_ERROR) {
2169
- console.warn("Failed to hydrate: ", error);
2170
- }
2171
- if (options2.recover === false) {
2172
- hydration_failed();
2173
- }
2174
- init_operations();
2175
- clear_text_content(target);
2176
- set_hydrating(false);
2177
- return mount(component, options2);
2178
- } finally {
2179
- set_hydrating(was_hydrating);
2180
- set_hydrate_node(previous_hydrate_node);
2181
- }
2182
- }
2183
- const document_listeners = /* @__PURE__ */ new Map();
2184
- function _mount(Component, { target, anchor, props = {}, events, context, intro = true }) {
2185
- init_operations();
2186
- var registered_events = /* @__PURE__ */ new Set();
2187
- var event_handle = (events2) => {
2188
- for (var i = 0; i < events2.length; i++) {
2189
- var event_name = events2[i];
2190
- if (registered_events.has(event_name)) continue;
2191
- registered_events.add(event_name);
2192
- var passive = is_passive_event(event_name);
2193
- target.addEventListener(event_name, handle_event_propagation, { passive });
2194
- var n = document_listeners.get(event_name);
2195
- if (n === void 0) {
2196
- document.addEventListener(event_name, handle_event_propagation, { passive });
2197
- document_listeners.set(event_name, 1);
2198
- } else {
2199
- document_listeners.set(event_name, n + 1);
2200
- }
2201
- }
2202
- };
2203
- event_handle(array_from(all_registered_events));
2204
- root_event_handles.add(event_handle);
2205
- var component = void 0;
2206
- var unmount2 = component_root(() => {
2207
- var anchor_node = anchor ?? target.appendChild(create_text());
2208
- boundary(
2209
- /** @type {TemplateNode} */
2210
- anchor_node,
2211
- {
2212
- pending: () => {
2213
- }
2214
- },
2215
- (anchor_node2) => {
2216
- if (context) {
2217
- push$1({});
2218
- var ctx = (
2219
- /** @type {ComponentContext} */
2220
- component_context
2221
- );
2222
- ctx.c = context;
2223
- }
2224
- if (events) {
2225
- props.$$events = events;
2226
- }
2227
- if (hydrating) {
2228
- assign_nodes(
2229
- /** @type {TemplateNode} */
2230
- anchor_node2,
2231
- null
2232
- );
2233
- }
2234
- component = Component(anchor_node2, props) || {};
2235
- if (hydrating) {
2236
- active_effect.nodes.end = hydrate_node;
2237
- if (hydrate_node === null || hydrate_node.nodeType !== COMMENT_NODE || /** @type {Comment} */
2238
- hydrate_node.data !== HYDRATION_END) {
2239
- hydration_mismatch();
2240
- throw HYDRATION_ERROR;
2241
- }
2242
- }
2243
- if (context) {
2244
- pop$1();
2245
- }
2246
- }
2247
- );
2248
- return () => {
2249
- for (var event_name of registered_events) {
2250
- target.removeEventListener(event_name, handle_event_propagation);
2251
- var n = (
2252
- /** @type {number} */
2253
- document_listeners.get(event_name)
2254
- );
2255
- if (--n === 0) {
2256
- document.removeEventListener(event_name, handle_event_propagation);
2257
- document_listeners.delete(event_name);
2258
- } else {
2259
- document_listeners.set(event_name, n);
2260
- }
2261
- }
2262
- root_event_handles.delete(event_handle);
2263
- if (anchor_node !== anchor) {
2264
- anchor_node.parentNode?.removeChild(anchor_node);
2265
- }
2266
- };
2267
- });
2268
- mounted_components.set(component, unmount2);
2269
- return component;
2270
- }
2271
- let mounted_components = /* @__PURE__ */ new WeakMap();
2272
- function unmount(component, options2) {
2273
- const fn = mounted_components.get(component);
2274
- if (fn) {
2275
- mounted_components.delete(component);
2276
- return fn(options2);
2277
- }
2278
- {
2279
- if (STATE_SYMBOL in component) {
2280
- state_proxy_unmount();
2281
- } else {
2282
- lifecycle_double_unmount();
2283
- }
2284
- }
2285
- return Promise.resolve();
2286
- }
2287
- function asClassComponent$1(component) {
2288
- return class extends Svelte4Component {
2289
- /** @param {any} options */
2290
- constructor(options2) {
2291
- super({
2292
- component,
2293
- ...options2
2294
- });
2295
- }
2296
- };
2297
- }
2298
- class Svelte4Component {
2299
- /** @type {any} */
2300
- #events;
2301
- /** @type {Record<string, any>} */
2302
- #instance;
2303
- /**
2304
- * @param {ComponentConstructorOptions & {
2305
- * component: any;
2306
- * }} options
2307
- */
2308
- constructor(options2) {
2309
- var sources = /* @__PURE__ */ new Map();
2310
- var add_source = (key, value) => {
2311
- var s = mutable_source(value, false, false);
2312
- sources.set(key, s);
2313
- return s;
2314
- };
2315
- const props = new Proxy(
2316
- { ...options2.props || {}, $$events: {} },
2317
- {
2318
- get(target, prop) {
2319
- return get(sources.get(prop) ?? add_source(prop, Reflect.get(target, prop)));
2320
- },
2321
- has(target, prop) {
2322
- if (prop === LEGACY_PROPS) return true;
2323
- get(sources.get(prop) ?? add_source(prop, Reflect.get(target, prop)));
2324
- return Reflect.has(target, prop);
2325
- },
2326
- set(target, prop, value) {
2327
- set(sources.get(prop) ?? add_source(prop, value), value);
2328
- return Reflect.set(target, prop, value);
2329
- }
2330
- }
2331
- );
2332
- this.#instance = (options2.hydrate ? hydrate : mount)(options2.component, {
2333
- target: options2.target,
2334
- anchor: options2.anchor,
2335
- props,
2336
- context: options2.context,
2337
- intro: options2.intro ?? false,
2338
- recover: options2.recover
2339
- });
2340
- if (!options2?.props?.$$host || options2.sync === false) {
2341
- flushSync();
2342
- }
2343
- this.#events = props.$$events;
2344
- for (const key of Object.keys(this.#instance)) {
2345
- if (key === "$set" || key === "$destroy" || key === "$on") continue;
2346
- define_property(this, key, {
2347
- get() {
2348
- return this.#instance[key];
2349
- },
2350
- /** @param {any} value */
2351
- set(value) {
2352
- this.#instance[key] = value;
2353
- },
2354
- enumerable: true
2355
- });
2356
- }
2357
- this.#instance.$set = /** @param {Record<string, any>} next */
2358
- (next2) => {
2359
- Object.assign(props, next2);
2360
- };
2361
- this.#instance.$destroy = () => {
2362
- unmount(this.#instance);
2363
- };
2364
- }
2365
- /** @param {Record<string, any>} props */
2366
- $set(props) {
2367
- this.#instance.$set(props);
2368
- }
2369
- /**
2370
- * @param {string} event
2371
- * @param {(...args: any[]) => any} callback
2372
- * @returns {any}
2373
- */
2374
- $on(event, callback) {
2375
- this.#events[event] = this.#events[event] || [];
2376
- const cb = (...args) => callback.call(this, ...args);
2377
- this.#events[event].push(cb);
2378
- return () => {
2379
- this.#events[event] = this.#events[event].filter(
2380
- /** @param {any} fn */
2381
- (fn) => fn !== cb
2382
- );
2383
- };
2384
- }
2385
- $destroy() {
2386
- this.#instance.$destroy();
2387
- }
2388
- }
2389
- let read_implementation = null;
2390
- function set_read_implementation(fn) {
2391
- read_implementation = fn;
2392
- }
2393
- function asClassComponent(component) {
2394
- const component_constructor = asClassComponent$1(component);
2395
- const _render = (props, { context, csp } = {}) => {
2396
- const result = render(component, { props, context, csp });
2397
- const munged = Object.defineProperties(
2398
- /** @type {LegacyRenderResult & PromiseLike<LegacyRenderResult>} */
2399
- {},
2400
- {
2401
- css: {
2402
- value: { code: "", map: null }
2403
- },
2404
- head: {
2405
- get: () => result.head
2406
- },
2407
- html: {
2408
- get: () => result.body
2409
- },
2410
- then: {
2411
- /**
2412
- * this is not type-safe, but honestly it's the best I can do right now, and it's a straightforward function.
2413
- *
2414
- * @template TResult1
2415
- * @template [TResult2=never]
2416
- * @param { (value: LegacyRenderResult) => TResult1 } onfulfilled
2417
- * @param { (reason: unknown) => TResult2 } onrejected
2418
- */
2419
- value: (onfulfilled, onrejected) => {
2420
- {
2421
- const user_result = onfulfilled({
2422
- css: munged.css,
2423
- head: munged.head,
2424
- html: munged.html
2425
- });
2426
- return Promise.resolve(user_result);
2427
- }
2428
- }
2429
- }
2430
- }
2431
- );
2432
- return munged;
2433
- };
2434
- component_constructor.render = _render;
2435
- return component_constructor;
2436
- }
2437
- Root[FILENAME] = ".svelte-kit/generated/root.svelte";
2438
- function Root($$renderer, $$props) {
2439
- $$renderer.component(
2440
- ($$renderer2) => {
2441
- let {
2442
- stores,
2443
- page,
2444
- constructors,
2445
- components = [],
2446
- form,
2447
- data_0 = null,
2448
- data_1 = null
2449
- } = $$props;
2450
- {
2451
- setContext("__svelte__", stores);
2452
- }
2453
- {
2454
- stores.page.set(page);
2455
- }
2456
- const Pyramid_1 = constructors[1];
2457
- if (constructors[1]) {
2458
- $$renderer2.push("<!--[-->");
2459
- const Pyramid_0 = constructors[0];
2460
- $$renderer2.push(`<!---->`);
2461
- Pyramid_0?.($$renderer2, {
2462
- data: data_0,
2463
- form,
2464
- params: page.params,
2465
- children: prevent_snippet_stringification(($$renderer3) => {
2466
- $$renderer3.push(`<!---->`);
2467
- Pyramid_1?.($$renderer3, { data: data_1, form, params: page.params });
2468
- $$renderer3.push(`<!---->`);
2469
- }),
2470
- $$slots: { default: true }
2471
- });
2472
- $$renderer2.push(`<!---->`);
2473
- } else {
2474
- $$renderer2.push("<!--[!-->");
2475
- const Pyramid_0 = constructors[0];
2476
- $$renderer2.push(`<!---->`);
2477
- Pyramid_0?.($$renderer2, { data: data_0, form, params: page.params });
2478
- $$renderer2.push(`<!---->`);
2479
- }
2480
- $$renderer2.push(`<!--]--> `);
2481
- {
2482
- $$renderer2.push("<!--[!-->");
2483
- }
2484
- $$renderer2.push(`<!--]-->`);
2485
- },
2486
- Root
2487
- );
1060
+ function create_remote_key(id, payload) {
1061
+ return id + "/" + payload;
1062
+ }
1063
+
1064
+ let read_implementation = null;
1065
+ function set_read_implementation(fn) {
1066
+ read_implementation = fn;
2488
1067
  }
2489
- Root.render = function() {
2490
- throw new Error("Component.render(...) is no longer valid in Svelte 5. See https://svelte.dev/docs/svelte/v5-migration-guide#Components-are-no-longer-classes for more information");
2491
- };
2492
- const root = asClassComponent(Root);
2493
1068
  const options = {
2494
1069
  app_template_contains_nonce: false,
2495
1070
  async: false,
@@ -2506,8 +1081,9 @@ const options = {
2506
1081
  root,
2507
1082
  service_worker: false,
2508
1083
  service_worker_options: null,
1084
+ server_error_boundaries: false,
2509
1085
  templates: {
2510
- app: ({ head, body, assets, nonce, env }) => '<!doctype html>\n<html lang="en">\n <head>\n <meta charset="utf-8" />\n <link rel="icon" type="image/svg+xml" href="' + assets + '/favicon.svg" />\n <link rel="icon" type="image/png" href="' + assets + '/favicon.png" />\n <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />\n <meta name="theme-color" content="#0a0a0a" />\n <link rel="apple-touch-icon" href="' + assets + '/apple-touch-icon.png" />\n <link rel="manifest" href="' + assets + '/manifest.webmanifest" />\n <title>Shooter</title>\n <link rel="preconnect" href="https://fonts.googleapis.com" />\n <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />\n <link\n href="https://fonts.googleapis.com/css2?family=Geist:wght@400;500;600;700&family=Geist+Mono:wght@400;500&display=swap"\n rel="stylesheet"\n />\n ' + head + '\n </head>\n <body data-sveltekit-preload-data="hover">\n <div style="display: contents">' + body + '</div>\n <script src="' + assets + '/registerSW.js"><\/script>\n </body>\n</html>\n',
1086
+ app: ({ head, body, assets, nonce, env }) => '<!doctype html>\n<html lang="en">\n <head>\n <meta charset="utf-8" />\n <link rel="icon" type="image/svg+xml" href="' + assets + '/favicon.svg" />\n <link rel="icon" type="image/png" href="' + assets + '/favicon.png" />\n <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />\n <meta name="theme-color" content="#0a0a0a" />\n <link rel="apple-touch-icon" href="' + assets + '/apple-touch-icon.png" />\n <link rel="manifest" href="' + assets + '/manifest.json" />\n <meta name="apple-mobile-web-app-capable" content="yes" />\n <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />\n <title>Shooter</title>\n <link rel="preconnect" href="https://fonts.googleapis.com" />\n <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />\n <link\n href="https://fonts.googleapis.com/css2?family=Geist:wght@400;500;600;700&family=Geist+Mono:wght@400;500&display=swap"\n rel="stylesheet"\n />\n ' + head + '\n </head>\n <body data-sveltekit-preload-data="hover">\n <div style="display: contents">' + body + "</div>\n </body>\n</html>\n",
2511
1087
  error: ({ status, message }) => '<!doctype html>\n<html lang="en">\n <head>\n <meta charset="utf-8" />\n <title>' + message + `</title>
2512
1088
 
2513
1089
  <style>
@@ -2579,7 +1155,7 @@ const options = {
2579
1155
  <div class="error">
2580
1156
  <span class="status">` + status + '</span>\n <div class="message">\n <h1>' + message + "</h1>\n </div>\n </div>\n </body>\n</html>\n"
2581
1157
  },
2582
- version_hash: "r8soke"
1158
+ version_hash: "19bb7ro"
2583
1159
  };
2584
1160
  async function get_hooks() {
2585
1161
  let handle;
@@ -2634,8 +1210,8 @@ async function render_endpoint(event, event_state, mod, state) {
2634
1210
  return new Response(void 0, { status: 204 });
2635
1211
  }
2636
1212
  }
2637
- event_state.is_endpoint_request = true;
2638
1213
  try {
1214
+ event_state.allows_commands = true;
2639
1215
  const response = await with_request_store(
2640
1216
  { event, state: event_state },
2641
1217
  () => handler(
@@ -2777,7 +1353,7 @@ async function handle_action_json_request(event, event_state, options2, server)
2777
1353
  const no_actions_error = new SvelteKitError(
2778
1354
  405,
2779
1355
  "Method Not Allowed",
2780
- `POST method not allowed. No form actions exist for ${`the page at ${event.route.id}`}`
1356
+ `POST method not allowed. No form actions exist for ${"this page"}`
2781
1357
  );
2782
1358
  return action_json(
2783
1359
  {
@@ -2797,9 +1373,7 @@ async function handle_action_json_request(event, event_state, options2, server)
2797
1373
  check_named_default_separate(actions);
2798
1374
  try {
2799
1375
  const data = await call_action(event, event_state, actions);
2800
- if (DEV) {
2801
- validate_action_return(data);
2802
- }
1376
+ if (browser) ;
2803
1377
  if (data instanceof ActionFailure) {
2804
1378
  return action_json({
2805
1379
  type: "failure",
@@ -2877,16 +1451,14 @@ async function handle_action_request(event, event_state, server) {
2877
1451
  error: new SvelteKitError(
2878
1452
  405,
2879
1453
  "Method Not Allowed",
2880
- `POST method not allowed. No form actions exist for ${`the page at ${event.route.id}`}`
1454
+ `POST method not allowed. No form actions exist for ${"this page"}`
2881
1455
  )
2882
1456
  };
2883
1457
  }
2884
1458
  check_named_default_separate(actions);
2885
1459
  try {
2886
1460
  const data = await call_action(event, event_state, actions);
2887
- if (DEV) {
2888
- validate_action_return(data);
2889
- }
1461
+ if (browser) ;
2890
1462
  if (data instanceof ActionFailure) {
2891
1463
  return {
2892
1464
  type: "failure",
@@ -2955,6 +1527,7 @@ async function call_action(event, event_state, actions) {
2955
1527
  },
2956
1528
  fn: async (current2) => {
2957
1529
  const traced_event = merge_tracing(event, current2);
1530
+ event_state.allows_commands = true;
2958
1531
  const result = await with_request_store(
2959
1532
  { event: traced_event, state: event_state },
2960
1533
  () => action(traced_event)
@@ -2969,14 +1542,6 @@ async function call_action(event, event_state, actions) {
2969
1542
  }
2970
1543
  });
2971
1544
  }
2972
- function validate_action_return(data) {
2973
- if (data instanceof Redirect) {
2974
- throw new Error("Cannot `return redirect(...)` — use `redirect(...)` instead");
2975
- }
2976
- if (data instanceof HttpError) {
2977
- throw new Error("Cannot `return error(...)` — use `error(...)` or `return fail(...)` instead");
2978
- }
2979
- }
2980
1545
  function uneval_action_response(data, route_id, transport) {
2981
1546
  const replacer = (thing) => {
2982
1547
  for (const key2 in transport) {
@@ -3004,13 +1569,14 @@ function try_serialize(data, fn, route_id) {
3004
1569
  );
3005
1570
  if (data instanceof Response) {
3006
1571
  throw new Error(
3007
- `Data returned from action inside ${route_id} is not serializable. Form actions need to return plain objects or fail(). E.g. return { success: true } or return fail(400, { message: "invalid" });`
1572
+ `Data returned from action inside ${route_id} is not serializable. Form actions need to return plain objects or fail(). E.g. return { success: true } or return fail(400, { message: "invalid" });`,
1573
+ { cause: e }
3008
1574
  );
3009
1575
  }
3010
1576
  if ("path" in error2) {
3011
1577
  let message = `Data returned from action inside ${route_id} is not serializable: ${error2.message}`;
3012
1578
  if (error2.path !== "") message += ` (data.${error2.path})`;
3013
- throw new Error(message);
1579
+ throw new Error(message, { cause: e });
3014
1580
  }
3015
1581
  throw error2;
3016
1582
  }
@@ -3046,7 +1612,7 @@ function server_data_serializer(event, event_state, options2) {
3046
1612
  let promise_id = 1;
3047
1613
  let max_nodes = -1;
3048
1614
  const iterator = create_async_iterator();
3049
- const global = get_global_name();
1615
+ const global = get_global_name(options2);
3050
1616
  function get_replacer(index) {
3051
1617
  return function replacer(thing) {
3052
1618
  if (typeof thing?.then === "function") {
@@ -3074,7 +1640,6 @@ function server_data_serializer(event, event_state, options2) {
3074
1640
  options2,
3075
1641
  new Error(`Failed to serialize promise while rendering ${event.route.id}`)
3076
1642
  );
3077
- data = void 0;
3078
1643
  str = uneval([, error2], replacer);
3079
1644
  }
3080
1645
  return {
@@ -3118,7 +1683,7 @@ function server_data_serializer(event, event_state, options2) {
3118
1683
  event,
3119
1684
  /** @type {any} */
3120
1685
  e
3121
- ));
1686
+ ), { cause: e });
3122
1687
  }
3123
1688
  },
3124
1689
  get_data(csp) {
@@ -3211,7 +1776,7 @@ function server_data_serializer_json(event, event_state, options2) {
3211
1776
  event,
3212
1777
  /** @type {any} */
3213
1778
  e
3214
- ));
1779
+ ), { cause: e });
3215
1780
  }
3216
1781
  },
3217
1782
  get_data() {
@@ -3242,21 +1807,11 @@ async function load_server_data({ event, event_state, state, node, parent }) {
3242
1807
  const url = make_trackable(
3243
1808
  event.url,
3244
1809
  () => {
3245
- if (done && !uses.url) {
3246
- console.warn(
3247
- `${node.server_id}: Accessing URL properties in a promise handler after \`load(...)\` has returned will not cause the function to re-run when the URL changes`
3248
- );
3249
- }
3250
1810
  if (is_tracking) {
3251
1811
  uses.url = true;
3252
1812
  }
3253
1813
  },
3254
1814
  (param) => {
3255
- if (done && !uses.search_params.has(param)) {
3256
- console.warn(
3257
- `${node.server_id}: Accessing URL properties in a promise handler after \`load(...)\` has returned will not cause the function to re-run when the URL changes`
3258
- );
3259
- }
3260
1815
  if (is_tracking) {
3261
1816
  uses.search_params.add(param);
3262
1817
  }
@@ -3265,7 +1820,6 @@ async function load_server_data({ event, event_state, state, node, parent }) {
3265
1820
  if (state.prerendering) {
3266
1821
  disable_search(url);
3267
1822
  }
3268
- let done = false;
3269
1823
  const result = await record_span({
3270
1824
  name: "sveltekit.load",
3271
1825
  attributes: {
@@ -3280,38 +1834,18 @@ async function load_server_data({ event, event_state, state, node, parent }) {
3280
1834
  () => load.call(null, {
3281
1835
  ...traced_event,
3282
1836
  fetch: (info, init2) => {
3283
- const url2 = new URL(info instanceof Request ? info.url : info, event.url);
3284
- if (done && !uses.dependencies.has(url2.href)) {
3285
- console.warn(
3286
- `${node.server_id}: Calling \`event.fetch(...)\` in a promise handler after \`load(...)\` has returned will not cause the function to re-run when the dependency is invalidated`
3287
- );
3288
- }
1837
+ new URL(info instanceof Request ? info.url : info, event.url);
3289
1838
  return event.fetch(info, init2);
3290
1839
  },
3291
1840
  /** @param {string[]} deps */
3292
1841
  depends: (...deps) => {
3293
1842
  for (const dep of deps) {
3294
1843
  const { href } = new URL(dep, event.url);
3295
- {
3296
- validate_depends(node.server_id || "missing route ID", dep);
3297
- if (done && !uses.dependencies.has(href)) {
3298
- console.warn(
3299
- `${node.server_id}: Calling \`depends(...)\` in a promise handler after \`load(...)\` has returned will not cause the function to re-run when the dependency is invalidated`
3300
- );
3301
- }
3302
- }
3303
1844
  uses.dependencies.add(href);
3304
1845
  }
3305
1846
  },
3306
1847
  params: new Proxy(event.params, {
3307
1848
  get: (target, key2) => {
3308
- if (done && typeof key2 === "string" && !uses.params.has(key2)) {
3309
- console.warn(
3310
- `${node.server_id}: Accessing \`params.${String(
3311
- key2
3312
- )}\` in a promise handler after \`load(...)\` has returned will not cause the function to re-run when the param changes`
3313
- );
3314
- }
3315
1849
  if (is_tracking) {
3316
1850
  uses.params.add(key2);
3317
1851
  }
@@ -3322,11 +1856,6 @@ async function load_server_data({ event, event_state, state, node, parent }) {
3322
1856
  }
3323
1857
  }),
3324
1858
  parent: async () => {
3325
- if (done && !uses.parent) {
3326
- console.warn(
3327
- `${node.server_id}: Calling \`parent(...)\` in a promise handler after \`load(...)\` has returned will not cause the function to re-run when parent data changes`
3328
- );
3329
- }
3330
1859
  if (is_tracking) {
3331
1860
  uses.parent = true;
3332
1861
  }
@@ -3334,13 +1863,6 @@ async function load_server_data({ event, event_state, state, node, parent }) {
3334
1863
  },
3335
1864
  route: new Proxy(event.route, {
3336
1865
  get: (target, key2) => {
3337
- if (done && typeof key2 === "string" && !uses.route) {
3338
- console.warn(
3339
- `${node.server_id}: Accessing \`route.${String(
3340
- key2
3341
- )}\` in a promise handler after \`load(...)\` has returned will not cause the function to re-run when the route changes`
3342
- );
3343
- }
3344
1866
  if (is_tracking) {
3345
1867
  uses.route = true;
3346
1868
  }
@@ -3364,10 +1886,6 @@ async function load_server_data({ event, event_state, state, node, parent }) {
3364
1886
  return result2;
3365
1887
  }
3366
1888
  });
3367
- {
3368
- validate_load_response(result, `in ${node.server_id}`);
3369
- }
3370
- done = true;
3371
1889
  return {
3372
1890
  type: "data",
3373
1891
  data: result ?? null,
@@ -3418,9 +1936,6 @@ async function load_data({
3418
1936
  );
3419
1937
  }
3420
1938
  });
3421
- {
3422
- validate_load_response(result, `in ${node.universal_id}`);
3423
- }
3424
1939
  return result ?? null;
3425
1940
  }
3426
1941
  function create_universal_fetch(event, state, fetched, csr, resolve_opts) {
@@ -3793,16 +2308,22 @@ class BaseProvider {
3793
2308
  #style_src_elem_needs_csp;
3794
2309
  /** @type {import('types').CspDirectives} */
3795
2310
  #directives;
3796
- /** @type {import('types').Csp.Source[]} */
2311
+ /** @type {Set<import('types').Csp.Source>} */
3797
2312
  #script_src;
3798
- /** @type {import('types').Csp.Source[]} */
2313
+ /** @type {Set<import('types').Csp.Source>} */
3799
2314
  #script_src_elem;
3800
- /** @type {import('types').Csp.Source[]} */
2315
+ /** @type {Set<import('types').Csp.Source>} */
3801
2316
  #style_src;
3802
- /** @type {import('types').Csp.Source[]} */
2317
+ /** @type {Set<import('types').Csp.Source>} */
3803
2318
  #style_src_attr;
3804
- /** @type {import('types').Csp.Source[]} */
2319
+ /** @type {Set<import('types').Csp.Source>} */
3805
2320
  #style_src_elem;
2321
+ /** @type {boolean} */
2322
+ script_needs_nonce;
2323
+ /** @type {boolean} */
2324
+ style_needs_nonce;
2325
+ /** @type {boolean} */
2326
+ script_needs_hash;
3806
2327
  /** @type {string} */
3807
2328
  #nonce;
3808
2329
  /**
@@ -3812,44 +2333,18 @@ class BaseProvider {
3812
2333
  */
3813
2334
  constructor(use_hashes, directives, nonce) {
3814
2335
  this.#use_hashes = use_hashes;
3815
- this.#directives = { ...directives };
2336
+ this.#directives = directives;
3816
2337
  const d = this.#directives;
3817
- this.#script_src = [];
3818
- this.#script_src_elem = [];
3819
- this.#style_src = [];
3820
- this.#style_src_attr = [];
3821
- this.#style_src_elem = [];
2338
+ this.#script_src = /* @__PURE__ */ new Set();
2339
+ this.#script_src_elem = /* @__PURE__ */ new Set();
2340
+ this.#style_src = /* @__PURE__ */ new Set();
2341
+ this.#style_src_attr = /* @__PURE__ */ new Set();
2342
+ this.#style_src_elem = /* @__PURE__ */ new Set();
3822
2343
  const effective_script_src = d["script-src"] || d["default-src"];
3823
2344
  const script_src_elem = d["script-src-elem"];
3824
2345
  const effective_style_src = d["style-src"] || d["default-src"];
3825
2346
  const style_src_attr = d["style-src-attr"];
3826
2347
  const style_src_elem = d["style-src-elem"];
3827
- {
3828
- if (effective_style_src && !effective_style_src.includes("unsafe-inline")) {
3829
- d["style-src"] = [
3830
- ...effective_style_src.filter(
3831
- (value) => !(value.startsWith("sha256-") || value.startsWith("nonce-"))
3832
- ),
3833
- "unsafe-inline"
3834
- ];
3835
- }
3836
- if (style_src_attr && !style_src_attr.includes("unsafe-inline")) {
3837
- d["style-src-attr"] = [
3838
- ...style_src_attr.filter(
3839
- (value) => !(value.startsWith("sha256-") || value.startsWith("nonce-"))
3840
- ),
3841
- "unsafe-inline"
3842
- ];
3843
- }
3844
- if (style_src_elem && !style_src_elem.includes("unsafe-inline")) {
3845
- d["style-src-elem"] = [
3846
- ...style_src_elem.filter(
3847
- (value) => !(value.startsWith("sha256-") || value.startsWith("nonce-"))
3848
- ),
3849
- "unsafe-inline"
3850
- ];
3851
- }
3852
- }
3853
2348
  const style_needs_csp = (directive) => !!directive && !directive.some((value) => value === "unsafe-inline");
3854
2349
  const script_needs_csp = (directive) => !!directive && (!directive.some((value) => value === "unsafe-inline") || directive.some((value) => value === "strict-dynamic"));
3855
2350
  this.#script_src_needs_csp = script_needs_csp(effective_script_src);
@@ -3858,9 +2353,10 @@ class BaseProvider {
3858
2353
  this.#style_src_attr_needs_csp = style_needs_csp(style_src_attr);
3859
2354
  this.#style_src_elem_needs_csp = style_needs_csp(style_src_elem);
3860
2355
  this.#script_needs_csp = this.#script_src_needs_csp || this.#script_src_elem_needs_csp;
3861
- this.#style_needs_csp = !DEV;
2356
+ this.#style_needs_csp = this.#style_src_needs_csp || this.#style_src_attr_needs_csp || this.#style_src_elem_needs_csp;
3862
2357
  this.script_needs_nonce = this.#script_needs_csp && !this.#use_hashes;
3863
2358
  this.style_needs_nonce = this.#style_needs_csp && !this.#use_hashes;
2359
+ this.script_needs_hash = this.#script_needs_csp && this.#use_hashes;
3864
2360
  this.#nonce = nonce;
3865
2361
  }
3866
2362
  /** @param {string} content */
@@ -3868,10 +2364,21 @@ class BaseProvider {
3868
2364
  if (!this.#script_needs_csp) return;
3869
2365
  const source = this.#use_hashes ? `sha256-${sha256(content)}` : `nonce-${this.#nonce}`;
3870
2366
  if (this.#script_src_needs_csp) {
3871
- this.#script_src.push(source);
2367
+ this.#script_src.add(source);
3872
2368
  }
3873
2369
  if (this.#script_src_elem_needs_csp) {
3874
- this.#script_src_elem.push(source);
2370
+ this.#script_src_elem.add(source);
2371
+ }
2372
+ }
2373
+ /** @param {`sha256-${string}`[]} hashes */
2374
+ add_script_hashes(hashes) {
2375
+ for (const hash2 of hashes) {
2376
+ if (this.#script_src_needs_csp) {
2377
+ this.#script_src.add(hash2);
2378
+ }
2379
+ if (this.#script_src_elem_needs_csp) {
2380
+ this.#script_src_elem.add(hash2);
2381
+ }
3875
2382
  }
3876
2383
  }
3877
2384
  /** @param {string} content */
@@ -3879,19 +2386,19 @@ class BaseProvider {
3879
2386
  if (!this.#style_needs_csp) return;
3880
2387
  const source = this.#use_hashes ? `sha256-${sha256(content)}` : `nonce-${this.#nonce}`;
3881
2388
  if (this.#style_src_needs_csp) {
3882
- this.#style_src.push(source);
2389
+ this.#style_src.add(source);
3883
2390
  }
3884
2391
  if (this.#style_src_attr_needs_csp) {
3885
- this.#style_src_attr.push(source);
2392
+ this.#style_src_attr.add(source);
3886
2393
  }
3887
2394
  if (this.#style_src_elem_needs_csp) {
3888
2395
  const sha256_empty_comment_hash = "sha256-9OlNO0DNEeaVzHL4RZwCLsBHA8WBQ8toBp/4F5XV2nc=";
3889
2396
  const d = this.#directives;
3890
- if (d["style-src-elem"] && !d["style-src-elem"].includes(sha256_empty_comment_hash) && !this.#style_src_elem.includes(sha256_empty_comment_hash)) {
3891
- this.#style_src_elem.push(sha256_empty_comment_hash);
2397
+ if (d["style-src-elem"] && !d["style-src-elem"].includes(sha256_empty_comment_hash) && !this.#style_src_elem.has(sha256_empty_comment_hash)) {
2398
+ this.#style_src_elem.add(sha256_empty_comment_hash);
3892
2399
  }
3893
2400
  if (source !== sha256_empty_comment_hash) {
3894
- this.#style_src_elem.push(source);
2401
+ this.#style_src_elem.add(source);
3895
2402
  }
3896
2403
  }
3897
2404
  }
@@ -3901,31 +2408,31 @@ class BaseProvider {
3901
2408
  get_header(is_meta = false) {
3902
2409
  const header = [];
3903
2410
  const directives = { ...this.#directives };
3904
- if (this.#style_src.length > 0) {
2411
+ if (this.#style_src.size > 0) {
3905
2412
  directives["style-src"] = [
3906
2413
  ...directives["style-src"] || directives["default-src"] || [],
3907
2414
  ...this.#style_src
3908
2415
  ];
3909
2416
  }
3910
- if (this.#style_src_attr.length > 0) {
2417
+ if (this.#style_src_attr.size > 0) {
3911
2418
  directives["style-src-attr"] = [
3912
2419
  ...directives["style-src-attr"] || [],
3913
2420
  ...this.#style_src_attr
3914
2421
  ];
3915
2422
  }
3916
- if (this.#style_src_elem.length > 0) {
2423
+ if (this.#style_src_elem.size > 0) {
3917
2424
  directives["style-src-elem"] = [
3918
2425
  ...directives["style-src-elem"] || [],
3919
2426
  ...this.#style_src_elem
3920
2427
  ];
3921
2428
  }
3922
- if (this.#script_src.length > 0) {
2429
+ if (this.#script_src.size > 0) {
3923
2430
  directives["script-src"] = [
3924
2431
  ...directives["script-src"] || directives["default-src"] || [],
3925
2432
  ...this.#script_src
3926
2433
  ];
3927
2434
  }
3928
- if (this.#script_src_elem.length > 0) {
2435
+ if (this.#script_src_elem.size > 0) {
3929
2436
  directives["script-src-elem"] = [
3930
2437
  ...directives["script-src-elem"] || [],
3931
2438
  ...this.#script_src_elem
@@ -3999,6 +2506,9 @@ class Csp {
3999
2506
  this.csp_provider = new CspProvider(use_hashes, directives, this.nonce);
4000
2507
  this.report_only_provider = new CspReportOnlyProvider(use_hashes, reportOnly, this.nonce);
4001
2508
  }
2509
+ get script_needs_hash() {
2510
+ return this.csp_provider.script_needs_hash || this.report_only_provider.script_needs_hash;
2511
+ }
4002
2512
  get script_needs_nonce() {
4003
2513
  return this.csp_provider.script_needs_nonce || this.report_only_provider.script_needs_nonce;
4004
2514
  }
@@ -4010,6 +2520,11 @@ class Csp {
4010
2520
  this.csp_provider.add_script(content);
4011
2521
  this.report_only_provider.add_script(content);
4012
2522
  }
2523
+ /** @param {`sha256-${string}`[]} hashes */
2524
+ add_script_hashes(hashes) {
2525
+ this.csp_provider.add_script_hashes(hashes);
2526
+ this.report_only_provider.add_script_hashes(hashes);
2527
+ }
4013
2528
  /** @param {string} content */
4014
2529
  add_style(content) {
4015
2530
  this.csp_provider.add_style(content);
@@ -4056,6 +2571,20 @@ function exec(match, params, matchers) {
4056
2571
  if (buffered) return;
4057
2572
  return result;
4058
2573
  }
2574
+ function find_route(path, routes, matchers) {
2575
+ for (const route of routes) {
2576
+ const match = route.pattern.exec(path);
2577
+ if (!match) continue;
2578
+ const matched = exec(match, route.params, matchers);
2579
+ if (matched) {
2580
+ return {
2581
+ route,
2582
+ params: decode_params(matched)
2583
+ };
2584
+ }
2585
+ }
2586
+ return null;
2587
+ }
4059
2588
  function generate_route_object(route, url, manifest) {
4060
2589
  const { errors, layouts, leaf } = route;
4061
2590
  const nodes = [...errors, ...layouts.map((l) => l?.[1]), leaf[1]].filter((n) => typeof n === "number").map((n) => `'${n}': () => ${create_client_import(manifest._.client.nodes?.[n], url)}`).join(",\n ");
@@ -4087,20 +2616,9 @@ async function resolve_route(resolved_path, url, manifest) {
4087
2616
  if (!manifest._.client.routes) {
4088
2617
  return text("Server-side route resolution disabled", { status: 400 });
4089
2618
  }
4090
- let route = null;
4091
- let params = {};
4092
2619
  const matchers = await manifest._.matchers();
4093
- for (const candidate of manifest._.client.routes) {
4094
- const match = candidate.pattern.exec(resolved_path);
4095
- if (!match) continue;
4096
- const matched = exec(match, candidate.params, matchers);
4097
- if (matched) {
4098
- route = candidate;
4099
- params = decode_params(matched);
4100
- break;
4101
- }
4102
- }
4103
- return create_server_routing_response(route, params, url, manifest).response;
2620
+ const result = find_route(resolved_path, manifest._.client.routes, matchers);
2621
+ return create_server_routing_response(result?.route ?? null, result?.params ?? {}, url, manifest).response;
4104
2622
  }
4105
2623
  function create_server_routing_response(route, params, url, manifest) {
4106
2624
  const headers2 = new Headers({
@@ -4149,7 +2667,8 @@ async function render_response({
4149
2667
  event_state,
4150
2668
  resolve_opts,
4151
2669
  action_result,
4152
- data_serializer
2670
+ data_serializer,
2671
+ error_components
4153
2672
  }) {
4154
2673
  if (state.prerendering) {
4155
2674
  if (options2.csp.mode === "nonce") {
@@ -4164,13 +2683,15 @@ async function render_response({
4164
2683
  const stylesheets = new Set(client.stylesheets);
4165
2684
  const fonts = new Set(client.fonts);
4166
2685
  const link_headers = /* @__PURE__ */ new Set();
4167
- const link_tags = /* @__PURE__ */ new Set();
4168
2686
  const inline_styles = /* @__PURE__ */ new Map();
4169
2687
  let rendered;
4170
2688
  const form_value = action_result?.type === "success" || action_result?.type === "failure" ? action_result.data ?? null : null;
4171
2689
  let base$1 = base;
4172
2690
  let assets$1 = assets;
4173
2691
  let base_expression = s(base);
2692
+ const csp = new Csp(options2.csp, {
2693
+ prerender: !!state.prerendering
2694
+ });
4174
2695
  {
4175
2696
  if (!state.prerendering?.fallback) {
4176
2697
  const segments = event.url.pathname.slice(base.length).split("/").slice(2);
@@ -4200,6 +2721,12 @@ async function render_response({
4200
2721
  ),
4201
2722
  form: form_value
4202
2723
  };
2724
+ if (error_components) {
2725
+ if (error2) {
2726
+ props.error = error2;
2727
+ }
2728
+ props.errors = error_components;
2729
+ }
4203
2730
  let data2 = {};
4204
2731
  for (let i = 0; i < branch.length; i += 1) {
4205
2732
  data2 = { ...data2, ...branch[i].data };
@@ -4226,28 +2753,23 @@ async function render_response({
4226
2753
  page: props.page
4227
2754
  }
4228
2755
  ]
4229
- ])
2756
+ ]),
2757
+ csp: csp.script_needs_nonce ? { nonce: csp.nonce } : { hash: csp.script_needs_hash },
2758
+ transformError: error_components ? (
2759
+ /** @param {unknown} e */
2760
+ async (e) => {
2761
+ const transformed2 = await handle_error_and_jsonify(event, event_state, options2, e);
2762
+ props.page.error = props.error = error2 = transformed2;
2763
+ props.page.status = status = get_status(e);
2764
+ return transformed2;
2765
+ }
2766
+ ) : void 0
4230
2767
  };
4231
- const fetch2 = globalThis.fetch;
4232
2768
  try {
4233
- if (DEV) {
4234
- let warned = false;
4235
- globalThis.fetch = (info, init2) => {
4236
- if (typeof info === "string" && !SCHEME.test(info)) {
4237
- throw new Error(
4238
- `Cannot call \`fetch\` eagerly during server-side rendering with relative URL (${info}) — put your \`fetch\` calls inside \`onMount\` or a \`load\` function instead`
4239
- );
4240
- } else if (!warned && !try_get_request_store()?.state.is_in_remote_function) {
4241
- console.warn(
4242
- "Avoid calling `fetch` eagerly during server-side rendering — put your `fetch` calls inside `onMount` or a `load` function instead"
4243
- );
4244
- warned = true;
4245
- }
4246
- return fetch2(info, init2);
4247
- };
4248
- }
2769
+ if (browser) ;
2770
+ event_state.allows_commands = false;
4249
2771
  rendered = await with_request_store({ event, state: event_state }, async () => {
4250
- if (relative$1) override({ base: base$1, assets: assets$1 });
2772
+ if (relative) override({ base: base$1, assets: assets$1 });
4251
2773
  const maybe_promise = options2.root.render(props, render_opts);
4252
2774
  const rendered2 = options2.async && "then" in maybe_promise ? (
4253
2775
  /** @type {ReturnType<typeof options.root.render> & Promise<any>} */
@@ -4256,13 +2778,16 @@ async function render_response({
4256
2778
  if (options2.async) {
4257
2779
  reset();
4258
2780
  }
4259
- const { head: head2, html: html2, css } = options2.async ? await rendered2 : rendered2;
4260
- return { head: head2, html: html2, css };
2781
+ const { head: head2, html: html2, css, hashes } = (
2782
+ /** @type {ReturnType<typeof options.root.render>} */
2783
+ options2.async ? await rendered2 : rendered2
2784
+ );
2785
+ if (hashes) {
2786
+ csp.add_script_hashes(hashes.script);
2787
+ }
2788
+ return { head: head2, html: html2, css, hashes };
4261
2789
  });
4262
2790
  } finally {
4263
- {
4264
- globalThis.fetch = fetch2;
4265
- }
4266
2791
  reset();
4267
2792
  }
4268
2793
  for (const { node } of branch) {
@@ -4280,13 +2805,10 @@ async function render_response({
4280
2805
  }
4281
2806
  }
4282
2807
  } else {
4283
- rendered = { head: "", html: "", css: { code: "", map: null } };
2808
+ rendered = { head: "", html: "", css: { code: "", map: null }, hashes: { script: [] } };
4284
2809
  }
4285
- let head = "";
2810
+ const head = new Head(rendered.head, !!state.prerendering);
4286
2811
  let body2 = rendered.html;
4287
- const csp = new Csp(options2.csp, {
4288
- prerender: !!state.prerendering
4289
- });
4290
2812
  const prefixed = (path) => {
4291
2813
  if (path.startsWith("/")) {
4292
2814
  return base + path;
@@ -4295,11 +2817,10 @@ async function render_response({
4295
2817
  };
4296
2818
  const style = client.inline ? client.inline?.style : Array.from(inline_styles.values()).join("\n");
4297
2819
  if (style) {
4298
- const attributes = [" data-sveltekit"];
4299
- if (csp.style_needs_nonce) attributes.push(` nonce="${csp.nonce}"`);
2820
+ const attributes = [];
2821
+ if (csp.style_needs_nonce) attributes.push(`nonce="${csp.nonce}"`);
4300
2822
  csp.add_style(style);
4301
- head += `
4302
- <style${attributes.join("")}>${style}</style>`;
2823
+ head.add_style(style, attributes);
4303
2824
  }
4304
2825
  for (const dep of stylesheets) {
4305
2826
  const path = prefixed(dep);
@@ -4311,20 +2832,19 @@ async function render_response({
4311
2832
  link_headers.add(`<${encodeURI(path)}>; rel="preload"; as="style"; nopush`);
4312
2833
  }
4313
2834
  }
4314
- head += `
4315
- <link href="${path}" ${attributes.join(" ")}>`;
2835
+ head.add_stylesheet(path, attributes);
4316
2836
  }
4317
2837
  for (const dep of fonts) {
4318
2838
  const path = prefixed(dep);
4319
2839
  if (resolve_opts.preload({ type: "font", path })) {
4320
2840
  const ext = dep.slice(dep.lastIndexOf(".") + 1);
4321
- link_tags.add(`<link rel="preload" as="font" type="font/${ext}" href="${path}" crossorigin>`);
2841
+ head.add_link_tag(path, ['rel="preload"', 'as="font"', `type="font/${ext}"`, "crossorigin"]);
4322
2842
  link_headers.add(
4323
2843
  `<${encodeURI(path)}>; rel="preload"; as="font"; type="font/${ext}"; crossorigin; nopush`
4324
2844
  );
4325
2845
  }
4326
2846
  }
4327
- const global = get_global_name();
2847
+ const global = get_global_name(options2);
4328
2848
  const { data, chunks } = data_serializer.get_data(csp);
4329
2849
  if (page_config.ssr && page_config.csr) {
4330
2850
  body2 += `
@@ -4344,17 +2864,12 @@ async function render_response({
4344
2864
  for (const path of included_modulepreloads) {
4345
2865
  link_headers.add(`<${encodeURI(path)}>; rel="modulepreload"; nopush`);
4346
2866
  if (options2.preload_strategy !== "modulepreload") {
4347
- head += `
4348
- <link rel="preload" as="script" crossorigin="anonymous" href="${path}">`;
2867
+ head.add_script_preload(path);
4349
2868
  } else {
4350
- link_tags.add(`<link rel="modulepreload" href="${path}">`);
2869
+ head.add_link_tag(path, ['rel="modulepreload"']);
4351
2870
  }
4352
2871
  }
4353
2872
  }
4354
- if (state.prerendering && link_tags.size > 0) {
4355
- head += Array.from(link_tags).map((tag) => `
4356
- ${tag}`).join("");
4357
- }
4358
2873
  if (manifest._.client.routes && state.prerendering && !state.prerendering.fallback) {
4359
2874
  const pathname = add_resolution_suffix(event.url.pathname);
4360
2875
  state.prerendering.dependencies.set(
@@ -4455,7 +2970,33 @@ ${indent}}`);
4455
2970
  for (const [info, cache] of remote_cache) {
4456
2971
  if (!info.id) continue;
4457
2972
  for (const key2 in cache) {
4458
- remote[create_remote_key(info.id, key2)] = await cache[key2];
2973
+ const remote_key = create_remote_key(info.id, key2);
2974
+ if (event_state.refreshes?.[remote_key] !== void 0) {
2975
+ remote[remote_key] = await cache[key2];
2976
+ } else {
2977
+ const result = await Promise.race([
2978
+ Promise.resolve(cache[key2]).then(
2979
+ (v) => (
2980
+ /** @type {const} */
2981
+ { settled: true, value: v }
2982
+ ),
2983
+ (e) => (
2984
+ /** @type {const} */
2985
+ { settled: true, error: e }
2986
+ )
2987
+ ),
2988
+ new Promise((resolve2) => {
2989
+ queueMicrotask(() => resolve2(
2990
+ /** @type {const} */
2991
+ { settled: false }
2992
+ ));
2993
+ })
2994
+ ]);
2995
+ if (result.settled) {
2996
+ if ("error" in result) throw result.error;
2997
+ remote[remote_key] = result.value;
2998
+ }
2999
+ }
4459
3000
  }
4460
3001
  }
4461
3002
  const replacer = (thing) => {
@@ -4490,12 +3031,9 @@ ${indent}}`);
4490
3031
  blocks.push(boot);
4491
3032
  }
4492
3033
  if (options2.service_worker) {
4493
- let opts = ", { type: 'module' }";
3034
+ let opts = "";
4494
3035
  if (options2.service_worker_options != null) {
4495
3036
  const service_worker_options = { ...options2.service_worker_options };
4496
- {
4497
- service_worker_options.type = "module";
4498
- }
4499
3037
  opts = `, ${s(service_worker_options)}`;
4500
3038
  }
4501
3039
  blocks.push(`if ('serviceWorker' in navigator) {
@@ -4519,16 +3057,14 @@ ${indent}}`);
4519
3057
  "content-type": "text/html"
4520
3058
  });
4521
3059
  if (state.prerendering) {
4522
- const http_equiv = [];
4523
3060
  const csp_headers = csp.csp_provider.get_meta();
4524
3061
  if (csp_headers) {
4525
- http_equiv.push(csp_headers);
3062
+ head.add_http_equiv(csp_headers);
4526
3063
  }
4527
3064
  if (state.prerendering.cache) {
4528
- http_equiv.push(`<meta http-equiv="cache-control" content="${state.prerendering.cache}">`);
4529
- }
4530
- if (http_equiv.length > 0) {
4531
- head = http_equiv.join("\n") + head;
3065
+ head.add_http_equiv(
3066
+ `<meta http-equiv="cache-control" content="${state.prerendering.cache}">`
3067
+ );
4532
3068
  }
4533
3069
  } else {
4534
3070
  const csp_header = csp.csp_provider.get_header();
@@ -4543,9 +3079,8 @@ ${indent}}`);
4543
3079
  headers2.set("link", Array.from(link_headers).join(", "));
4544
3080
  }
4545
3081
  }
4546
- head += rendered.head;
4547
3082
  const html = options2.templates.app({
4548
- head,
3083
+ head: head.build(),
4549
3084
  body: body2,
4550
3085
  assets: assets$1,
4551
3086
  nonce: (
@@ -4561,21 +3096,6 @@ ${indent}}`);
4561
3096
  if (!chunks) {
4562
3097
  headers2.set("etag", `"${hash(transformed)}"`);
4563
3098
  }
4564
- {
4565
- if (page_config.csr) {
4566
- if (transformed.split("<!--").length < html.split("<!--").length) {
4567
- console.warn(
4568
- "\x1B[1m\x1B[31mRemoving comments in transformPageChunk can break Svelte's hydration\x1B[39m\x1B[22m"
4569
- );
4570
- }
4571
- } else {
4572
- if (chunks) {
4573
- console.warn(
4574
- "\x1B[1m\x1B[31mReturning promises from server `load` functions will only work if `csr === true`\x1B[39m\x1B[22m"
4575
- );
4576
- }
4577
- }
4578
- }
4579
3099
  return !chunks ? text(transformed, {
4580
3100
  status,
4581
3101
  headers: headers2
@@ -4595,6 +3115,73 @@ ${indent}}`);
4595
3115
  }
4596
3116
  );
4597
3117
  }
3118
+ class Head {
3119
+ #rendered;
3120
+ #prerendering;
3121
+ /** @type {string[]} */
3122
+ #http_equiv = [];
3123
+ /** @type {string[]} */
3124
+ #link_tags = [];
3125
+ /** @type {string[]} */
3126
+ #script_preloads = [];
3127
+ /** @type {string[]} */
3128
+ #style_tags = [];
3129
+ /** @type {string[]} */
3130
+ #stylesheet_links = [];
3131
+ /**
3132
+ * @param {string} rendered
3133
+ * @param {boolean} prerendering
3134
+ */
3135
+ constructor(rendered, prerendering) {
3136
+ this.#rendered = rendered;
3137
+ this.#prerendering = prerendering;
3138
+ }
3139
+ build() {
3140
+ return [
3141
+ ...this.#http_equiv,
3142
+ ...this.#link_tags,
3143
+ ...this.#script_preloads,
3144
+ this.#rendered,
3145
+ ...this.#style_tags,
3146
+ ...this.#stylesheet_links
3147
+ ].join("\n ");
3148
+ }
3149
+ /**
3150
+ * @param {string} style
3151
+ * @param {string[]} attributes
3152
+ */
3153
+ add_style(style, attributes) {
3154
+ this.#style_tags.push(
3155
+ `<style${attributes.length ? " " + attributes.join(" ") : ""}>${style}</style>`
3156
+ );
3157
+ }
3158
+ /**
3159
+ * @param {string} href
3160
+ * @param {string[]} attributes
3161
+ */
3162
+ add_stylesheet(href, attributes) {
3163
+ this.#stylesheet_links.push(`<link href="${href}" ${attributes.join(" ")}>`);
3164
+ }
3165
+ /** @param {string} href */
3166
+ add_script_preload(href) {
3167
+ this.#script_preloads.push(
3168
+ `<link rel="preload" as="script" crossorigin="anonymous" href="${href}">`
3169
+ );
3170
+ }
3171
+ /**
3172
+ * @param {string} href
3173
+ * @param {string[]} attributes
3174
+ */
3175
+ add_link_tag(href, attributes) {
3176
+ if (!this.#prerendering) return;
3177
+ this.#link_tags.push(`<link href="${href}" ${attributes.join(" ")}>`);
3178
+ }
3179
+ /** @param {string} tag */
3180
+ add_http_equiv(tag) {
3181
+ if (!this.#prerendering) return;
3182
+ this.#http_equiv.push(tag);
3183
+ }
3184
+ }
4598
3185
  class PageNodes {
4599
3186
  data;
4600
3187
  /**
@@ -4759,6 +3346,7 @@ async function respond_with_error({
4759
3346
  status,
4760
3347
  error: await handle_error_and_jsonify(event, event_state, options2, error2),
4761
3348
  branch,
3349
+ error_components: [],
4762
3350
  fetched,
4763
3351
  event,
4764
3352
  event_state,
@@ -4843,6 +3431,7 @@ async function handle_remote_call_internal(event, state, options2, manifest, id)
4843
3431
  );
4844
3432
  }
4845
3433
  const { data: data2, meta, form_data } = await deserialize_binary_form(event.request);
3434
+ form_client_refreshes = meta.remote_refreshes;
4846
3435
  if (additional_args && !("id" in data2)) {
4847
3436
  data2.id = JSON.parse(decodeURIComponent(additional_args));
4848
3437
  }
@@ -4975,7 +3564,7 @@ async function handle_remote_form_post_internal(event, state, manifest, id) {
4975
3564
  error: new SvelteKitError(
4976
3565
  405,
4977
3566
  "Method Not Allowed",
4978
- `POST method not allowed. No form actions exist for ${`the page at ${event.route.id}`}`
3567
+ `POST method not allowed. No form actions exist for ${"this page"}`
4979
3568
  )
4980
3569
  };
4981
3570
  }
@@ -5072,17 +3661,7 @@ async function render_page(event, event_state, page, options2, manifest, state,
5072
3661
  const ssr = nodes.ssr();
5073
3662
  const csr = nodes.csr();
5074
3663
  if (ssr === false && !(state.prerendering && should_prerender_data)) {
5075
- if (DEV && action_result && !event.request.headers.has("x-sveltekit-action")) {
5076
- if (action_result.type === "error") {
5077
- console.warn(
5078
- "The form action returned an error, but +error.svelte wasn't rendered because SSR is off. To get the error page with CSR, enhance your form with `use:enhance`. See https://svelte.dev/docs/kit/form-actions#progressive-enhancement-use-enhance"
5079
- );
5080
- } else if (action_result.data) {
5081
- console.warn(
5082
- "The form action returned a value, but it isn't available in `page.form`, because SSR is off. To handle the returned value in CSR, enhance your form with `use:enhance`. See https://svelte.dev/docs/kit/form-actions#progressive-enhancement-use-enhance"
5083
- );
5084
- }
5085
- }
3664
+ if (browser && action_result && !event.request.headers.has("x-sveltekit-action")) ;
5086
3665
  return await render_response({
5087
3666
  branch: [],
5088
3667
  fetched,
@@ -5208,6 +3787,11 @@ async function render_page(event, event_state, page, options2, manifest, state,
5208
3787
  data_serializer.set_max_nodes(j + 1);
5209
3788
  const layouts = compact(branch.slice(0, j + 1));
5210
3789
  const nodes2 = new PageNodes(layouts.map((layout) => layout.node));
3790
+ const error_branch = layouts.concat({
3791
+ node: node2,
3792
+ data: null,
3793
+ server_data: null
3794
+ });
5211
3795
  return await render_response({
5212
3796
  event,
5213
3797
  event_state,
@@ -5221,11 +3805,14 @@ async function render_page(event, event_state, page, options2, manifest, state,
5221
3805
  },
5222
3806
  status: status2,
5223
3807
  error: error2,
5224
- branch: layouts.concat({
5225
- node: node2,
5226
- data: null,
5227
- server_data: null
5228
- }),
3808
+ error_components: await load_error_components(
3809
+ options2,
3810
+ ssr,
3811
+ error_branch,
3812
+ page,
3813
+ manifest
3814
+ ),
3815
+ branch: error_branch,
5229
3816
  fetched,
5230
3817
  data_serializer
5231
3818
  });
@@ -5262,24 +3849,48 @@ async function render_page(event, event_state, page, options2, manifest, state,
5262
3849
  },
5263
3850
  status,
5264
3851
  error: null,
5265
- branch: ssr === false ? [] : compact(branch),
3852
+ branch: !ssr ? [] : compact(branch),
5266
3853
  action_result,
5267
3854
  fetched,
5268
- data_serializer: ssr === false ? server_data_serializer(event, event_state, options2) : data_serializer
3855
+ data_serializer: !ssr ? server_data_serializer(event, event_state, options2) : data_serializer,
3856
+ error_components: await load_error_components(options2, ssr, branch, page, manifest)
5269
3857
  });
5270
3858
  } catch (e) {
3859
+ if (e instanceof Redirect) {
3860
+ return redirect_response(e.status, e.location);
3861
+ }
5271
3862
  return await respond_with_error({
5272
3863
  event,
5273
3864
  event_state,
5274
3865
  options: options2,
5275
3866
  manifest,
5276
3867
  state,
5277
- status: 500,
3868
+ status: e instanceof HttpError ? e.status : 500,
5278
3869
  error: e,
5279
3870
  resolve_opts
5280
3871
  });
5281
3872
  }
5282
3873
  }
3874
+ async function load_error_components(options2, ssr, branch, page, manifest) {
3875
+ let error_components;
3876
+ if (options2.server_error_boundaries && ssr) {
3877
+ let last_idx = -1;
3878
+ error_components = await Promise.all(
3879
+ // eslint-disable-next-line @typescript-eslint/await-thenable
3880
+ branch.map((b, i) => {
3881
+ if (i === 0) return void 0;
3882
+ if (!b) return null;
3883
+ i--;
3884
+ while (i > last_idx + 1 && page.errors[i] === void 0) i -= 1;
3885
+ last_idx = i;
3886
+ const idx = page.errors[i];
3887
+ if (idx == null) return void 0;
3888
+ return manifest._.nodes[idx]?.().then((e) => e.component?.()).catch(() => void 0);
3889
+ }).filter((e) => e !== null)
3890
+ );
3891
+ }
3892
+ return error_components;
3893
+ }
5283
3894
  function once(fn) {
5284
3895
  let done = false;
5285
3896
  let result;
@@ -5422,9 +4033,153 @@ function redirect_json_response(redirect) {
5422
4033
  }
5423
4034
  );
5424
4035
  }
4036
+ var cookie = {};
4037
+ var hasRequiredCookie;
4038
+ function requireCookie() {
4039
+ if (hasRequiredCookie) return cookie;
4040
+ hasRequiredCookie = 1;
4041
+ cookie.parse = parse;
4042
+ cookie.serialize = serialize;
4043
+ var __toString = Object.prototype.toString;
4044
+ var fieldContentRegExp = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;
4045
+ function parse(str, options2) {
4046
+ if (typeof str !== "string") {
4047
+ throw new TypeError("argument str must be a string");
4048
+ }
4049
+ var obj = {};
4050
+ var opt = options2 || {};
4051
+ var dec = opt.decode || decode;
4052
+ var index = 0;
4053
+ while (index < str.length) {
4054
+ var eqIdx = str.indexOf("=", index);
4055
+ if (eqIdx === -1) {
4056
+ break;
4057
+ }
4058
+ var endIdx = str.indexOf(";", index);
4059
+ if (endIdx === -1) {
4060
+ endIdx = str.length;
4061
+ } else if (endIdx < eqIdx) {
4062
+ index = str.lastIndexOf(";", eqIdx - 1) + 1;
4063
+ continue;
4064
+ }
4065
+ var key2 = str.slice(index, eqIdx).trim();
4066
+ if (void 0 === obj[key2]) {
4067
+ var val = str.slice(eqIdx + 1, endIdx).trim();
4068
+ if (val.charCodeAt(0) === 34) {
4069
+ val = val.slice(1, -1);
4070
+ }
4071
+ obj[key2] = tryDecode(val, dec);
4072
+ }
4073
+ index = endIdx + 1;
4074
+ }
4075
+ return obj;
4076
+ }
4077
+ function serialize(name, val, options2) {
4078
+ var opt = options2 || {};
4079
+ var enc = opt.encode || encode2;
4080
+ if (typeof enc !== "function") {
4081
+ throw new TypeError("option encode is invalid");
4082
+ }
4083
+ if (!fieldContentRegExp.test(name)) {
4084
+ throw new TypeError("argument name is invalid");
4085
+ }
4086
+ var value = enc(val);
4087
+ if (value && !fieldContentRegExp.test(value)) {
4088
+ throw new TypeError("argument val is invalid");
4089
+ }
4090
+ var str = name + "=" + value;
4091
+ if (null != opt.maxAge) {
4092
+ var maxAge = opt.maxAge - 0;
4093
+ if (isNaN(maxAge) || !isFinite(maxAge)) {
4094
+ throw new TypeError("option maxAge is invalid");
4095
+ }
4096
+ str += "; Max-Age=" + Math.floor(maxAge);
4097
+ }
4098
+ if (opt.domain) {
4099
+ if (!fieldContentRegExp.test(opt.domain)) {
4100
+ throw new TypeError("option domain is invalid");
4101
+ }
4102
+ str += "; Domain=" + opt.domain;
4103
+ }
4104
+ if (opt.path) {
4105
+ if (!fieldContentRegExp.test(opt.path)) {
4106
+ throw new TypeError("option path is invalid");
4107
+ }
4108
+ str += "; Path=" + opt.path;
4109
+ }
4110
+ if (opt.expires) {
4111
+ var expires = opt.expires;
4112
+ if (!isDate(expires) || isNaN(expires.valueOf())) {
4113
+ throw new TypeError("option expires is invalid");
4114
+ }
4115
+ str += "; Expires=" + expires.toUTCString();
4116
+ }
4117
+ if (opt.httpOnly) {
4118
+ str += "; HttpOnly";
4119
+ }
4120
+ if (opt.secure) {
4121
+ str += "; Secure";
4122
+ }
4123
+ if (opt.partitioned) {
4124
+ str += "; Partitioned";
4125
+ }
4126
+ if (opt.priority) {
4127
+ var priority = typeof opt.priority === "string" ? opt.priority.toLowerCase() : opt.priority;
4128
+ switch (priority) {
4129
+ case "low":
4130
+ str += "; Priority=Low";
4131
+ break;
4132
+ case "medium":
4133
+ str += "; Priority=Medium";
4134
+ break;
4135
+ case "high":
4136
+ str += "; Priority=High";
4137
+ break;
4138
+ default:
4139
+ throw new TypeError("option priority is invalid");
4140
+ }
4141
+ }
4142
+ if (opt.sameSite) {
4143
+ var sameSite = typeof opt.sameSite === "string" ? opt.sameSite.toLowerCase() : opt.sameSite;
4144
+ switch (sameSite) {
4145
+ case true:
4146
+ str += "; SameSite=Strict";
4147
+ break;
4148
+ case "lax":
4149
+ str += "; SameSite=Lax";
4150
+ break;
4151
+ case "strict":
4152
+ str += "; SameSite=Strict";
4153
+ break;
4154
+ case "none":
4155
+ str += "; SameSite=None";
4156
+ break;
4157
+ default:
4158
+ throw new TypeError("option sameSite is invalid");
4159
+ }
4160
+ }
4161
+ return str;
4162
+ }
4163
+ function decode(str) {
4164
+ return str.indexOf("%") !== -1 ? decodeURIComponent(str) : str;
4165
+ }
4166
+ function encode2(val) {
4167
+ return encodeURIComponent(val);
4168
+ }
4169
+ function isDate(val) {
4170
+ return __toString.call(val) === "[object Date]" || val instanceof Date;
4171
+ }
4172
+ function tryDecode(str, decode2) {
4173
+ try {
4174
+ return decode2(str);
4175
+ } catch (e) {
4176
+ return str;
4177
+ }
4178
+ }
4179
+ return cookie;
4180
+ }
4181
+ var cookieExports = requireCookie();
5425
4182
  const INVALID_COOKIE_CHARACTER_REGEX = /[\x00-\x1F\x7F()<>@,;:"/[\]?={} \t]/;
5426
- const cookie_paths = {};
5427
- const MAX_COOKIE_SIZE = 4129;
5428
4183
  function validate_options(options2) {
5429
4184
  if (options2?.path === void 0) {
5430
4185
  throw new Error("You must specify a `path` when setting, deleting or serializing cookies");
@@ -5460,19 +4215,8 @@ function get_cookies(request, url) {
5460
4215
  return best_match.options.maxAge === 0 ? void 0 : best_match.value;
5461
4216
  }
5462
4217
  const req_cookies = cookieExports.parse(header, { decode: opts?.decode });
5463
- const cookie = req_cookies[name];
5464
- if (!cookie) {
5465
- const paths = Array.from(cookie_paths[name] ?? []).filter((path) => {
5466
- return path_matches(path, url.pathname) && path !== url.pathname;
5467
- });
5468
- if (paths.length > 0) {
5469
- console.warn(
5470
- // prettier-ignore
5471
- `'${name}' cookie does not exist for ${url.pathname}, but was previously set at ${conjoin([...paths])}. Did you mean to set its 'path' to '/' instead?`
5472
- );
5473
- }
5474
- }
5475
- return cookie;
4218
+ const cookie2 = req_cookies[name];
4219
+ return cookie2;
5476
4220
  },
5477
4221
  /**
5478
4222
  * @param {import('cookie').CookieParseOptions} [opts]
@@ -5540,11 +4284,11 @@ function get_cookies(request, url) {
5540
4284
  // cookies sent by the user agent have lowest precedence
5541
4285
  ...initial_cookies
5542
4286
  };
5543
- for (const cookie of new_cookies.values()) {
5544
- if (!domain_matches(destination.hostname, cookie.options.domain)) continue;
5545
- if (!path_matches(destination.pathname, cookie.options.path)) continue;
5546
- const encoder = cookie.options.encode || encodeURIComponent;
5547
- combined_cookies[cookie.name] = encoder(cookie.value);
4287
+ for (const cookie2 of new_cookies.values()) {
4288
+ if (!domain_matches(destination.hostname, cookie2.options.domain)) continue;
4289
+ if (!path_matches(destination.pathname, cookie2.options.path)) continue;
4290
+ const encoder = cookie2.options.encode || encodeURIComponent;
4291
+ combined_cookies[cookie2.name] = encoder(cookie2.value);
5548
4292
  }
5549
4293
  if (header2) {
5550
4294
  const parsed = cookieExports.parse(header2, { decode: (value) => value });
@@ -5565,20 +4309,8 @@ function get_cookies(request, url) {
5565
4309
  path = resolve(normalized_url, path);
5566
4310
  }
5567
4311
  const cookie_key = generate_cookie_key(options2.domain, path, name);
5568
- const cookie = { name, value, options: { ...options2, path } };
5569
- new_cookies.set(cookie_key, cookie);
5570
- {
5571
- const serialized = cookieExports.serialize(name, value, cookie.options);
5572
- if (text_encoder.encode(serialized).byteLength > MAX_COOKIE_SIZE) {
5573
- throw new Error(`Cookie "${name}" is too large, and will be discarded by the browser`);
5574
- }
5575
- cookie_paths[name] ??= /* @__PURE__ */ new Set();
5576
- if (!value) {
5577
- cookie_paths[name].delete(path);
5578
- } else {
5579
- cookie_paths[name].add(path);
5580
- }
5581
- }
4312
+ const cookie2 = { name, value, options: { ...options2, path } };
4313
+ new_cookies.set(cookie_key, cookie2);
5582
4314
  }
5583
4315
  function set_trailing_slash(trailing_slash) {
5584
4316
  normalized_url = normalize_path(url.pathname, trailing_slash);
@@ -5608,10 +4340,193 @@ function add_cookies_to_headers(headers2, cookies) {
5608
4340
  }
5609
4341
  }
5610
4342
  }
5611
- function conjoin(array2) {
5612
- if (array2.length <= 2) return array2.join(" and ");
5613
- return `${array2.slice(0, -1).join(", ")} and ${array2.at(-1)}`;
4343
+ var defaultParseOptions = {
4344
+ decodeValues: true,
4345
+ map: false,
4346
+ silent: false,
4347
+ split: "auto"
4348
+ // auto = split strings but not arrays
4349
+ };
4350
+ function isForbiddenKey(key2) {
4351
+ return typeof key2 !== "string" || key2 in {};
4352
+ }
4353
+ function createNullObj() {
4354
+ return /* @__PURE__ */ Object.create(null);
4355
+ }
4356
+ function isNonEmptyString(str) {
4357
+ return typeof str === "string" && !!str.trim();
4358
+ }
4359
+ function parseString(setCookieValue, options2) {
4360
+ var parts = setCookieValue.split(";").filter(isNonEmptyString);
4361
+ var nameValuePairStr = parts.shift();
4362
+ var parsed = parseNameValuePair(nameValuePairStr);
4363
+ var name = parsed.name;
4364
+ var value = parsed.value;
4365
+ options2 = options2 ? Object.assign({}, defaultParseOptions, options2) : defaultParseOptions;
4366
+ if (isForbiddenKey(name)) {
4367
+ return null;
4368
+ }
4369
+ try {
4370
+ value = options2.decodeValues ? decodeURIComponent(value) : value;
4371
+ } catch (e) {
4372
+ console.error(
4373
+ "set-cookie-parser: failed to decode cookie value. Set options.decodeValues=false to disable decoding.",
4374
+ e
4375
+ );
4376
+ }
4377
+ var cookie2 = createNullObj();
4378
+ cookie2.name = name;
4379
+ cookie2.value = value;
4380
+ parts.forEach(function(part) {
4381
+ var sides = part.split("=");
4382
+ var key2 = sides.shift().trimLeft().toLowerCase();
4383
+ if (isForbiddenKey(key2)) {
4384
+ return;
4385
+ }
4386
+ var value2 = sides.join("=");
4387
+ if (key2 === "expires") {
4388
+ cookie2.expires = new Date(value2);
4389
+ } else if (key2 === "max-age") {
4390
+ var n = parseInt(value2, 10);
4391
+ if (!Number.isNaN(n)) cookie2.maxAge = n;
4392
+ } else if (key2 === "secure") {
4393
+ cookie2.secure = true;
4394
+ } else if (key2 === "httponly") {
4395
+ cookie2.httpOnly = true;
4396
+ } else if (key2 === "samesite") {
4397
+ cookie2.sameSite = value2;
4398
+ } else if (key2 === "partitioned") {
4399
+ cookie2.partitioned = true;
4400
+ } else if (key2) {
4401
+ cookie2[key2] = value2;
4402
+ }
4403
+ });
4404
+ return cookie2;
4405
+ }
4406
+ function parseNameValuePair(nameValuePairStr) {
4407
+ var name = "";
4408
+ var value = "";
4409
+ var nameValueArr = nameValuePairStr.split("=");
4410
+ if (nameValueArr.length > 1) {
4411
+ name = nameValueArr.shift();
4412
+ value = nameValueArr.join("=");
4413
+ } else {
4414
+ value = nameValuePairStr;
4415
+ }
4416
+ return { name, value };
4417
+ }
4418
+ function parseSetCookie(input, options2) {
4419
+ options2 = options2 ? Object.assign({}, defaultParseOptions, options2) : defaultParseOptions;
4420
+ if (!input) {
4421
+ if (!options2.map) {
4422
+ return [];
4423
+ } else {
4424
+ return createNullObj();
4425
+ }
4426
+ }
4427
+ if (input.headers) {
4428
+ if (typeof input.headers.getSetCookie === "function") {
4429
+ input = input.headers.getSetCookie();
4430
+ } else if (input.headers["set-cookie"]) {
4431
+ input = input.headers["set-cookie"];
4432
+ } else {
4433
+ var sch = input.headers[Object.keys(input.headers).find(function(key2) {
4434
+ return key2.toLowerCase() === "set-cookie";
4435
+ })];
4436
+ if (!sch && input.headers.cookie && !options2.silent) {
4437
+ console.warn(
4438
+ "Warning: set-cookie-parser appears to have been called on a request object. It is designed to parse Set-Cookie headers from responses, not Cookie headers from requests. Set the option {silent: true} to suppress this warning."
4439
+ );
4440
+ }
4441
+ input = sch;
4442
+ }
4443
+ }
4444
+ var split = options2.split;
4445
+ var isArray = Array.isArray(input);
4446
+ if (split === "auto") {
4447
+ split = !isArray;
4448
+ }
4449
+ if (!isArray) {
4450
+ input = [input];
4451
+ }
4452
+ input = input.filter(isNonEmptyString);
4453
+ if (split) {
4454
+ input = input.map(splitCookiesString).flat();
4455
+ }
4456
+ if (!options2.map) {
4457
+ return input.map(function(str) {
4458
+ return parseString(str, options2);
4459
+ }).filter(Boolean);
4460
+ } else {
4461
+ var cookies = createNullObj();
4462
+ return input.reduce(function(cookies2, str) {
4463
+ var cookie2 = parseString(str, options2);
4464
+ if (cookie2 && !isForbiddenKey(cookie2.name)) {
4465
+ cookies2[cookie2.name] = cookie2;
4466
+ }
4467
+ return cookies2;
4468
+ }, cookies);
4469
+ }
4470
+ }
4471
+ function splitCookiesString(cookiesString) {
4472
+ if (Array.isArray(cookiesString)) {
4473
+ return cookiesString;
4474
+ }
4475
+ if (typeof cookiesString !== "string") {
4476
+ return [];
4477
+ }
4478
+ var cookiesStrings = [];
4479
+ var pos = 0;
4480
+ var start;
4481
+ var ch;
4482
+ var lastComma;
4483
+ var nextStart;
4484
+ var cookiesSeparatorFound;
4485
+ function skipWhitespace() {
4486
+ while (pos < cookiesString.length && /\s/.test(cookiesString.charAt(pos))) {
4487
+ pos += 1;
4488
+ }
4489
+ return pos < cookiesString.length;
4490
+ }
4491
+ function notSpecialChar() {
4492
+ ch = cookiesString.charAt(pos);
4493
+ return ch !== "=" && ch !== ";" && ch !== ",";
4494
+ }
4495
+ while (pos < cookiesString.length) {
4496
+ start = pos;
4497
+ cookiesSeparatorFound = false;
4498
+ while (skipWhitespace()) {
4499
+ ch = cookiesString.charAt(pos);
4500
+ if (ch === ",") {
4501
+ lastComma = pos;
4502
+ pos += 1;
4503
+ skipWhitespace();
4504
+ nextStart = pos;
4505
+ while (pos < cookiesString.length && notSpecialChar()) {
4506
+ pos += 1;
4507
+ }
4508
+ if (pos < cookiesString.length && cookiesString.charAt(pos) === "=") {
4509
+ cookiesSeparatorFound = true;
4510
+ pos = nextStart;
4511
+ cookiesStrings.push(cookiesString.substring(start, lastComma));
4512
+ start = pos;
4513
+ } else {
4514
+ pos = lastComma + 1;
4515
+ }
4516
+ } else {
4517
+ pos += 1;
4518
+ }
4519
+ }
4520
+ if (!cookiesSeparatorFound || pos >= cookiesString.length) {
4521
+ cookiesStrings.push(cookiesString.substring(start, cookiesString.length));
4522
+ }
4523
+ }
4524
+ return cookiesStrings;
5614
4525
  }
4526
+ parseSetCookie.parseSetCookie = parseSetCookie;
4527
+ parseSetCookie.parse = parseSetCookie;
4528
+ parseSetCookie.parseString = parseString;
4529
+ parseSetCookie.splitCookiesString = splitCookiesString;
5615
4530
  function create_fetch({ event, options: options2, manifest, state, get_cookie_header, set_internal }) {
5616
4531
  const server_fetch = async (info, init2) => {
5617
4532
  const original_request = normalize_fetch_input(info, init2, event.url);
@@ -5633,15 +4548,15 @@ function create_fetch({ event, options: options2, manifest, state, get_cookie_he
5633
4548
  if ((request.method === "GET" || request.method === "HEAD") && (mode === "no-cors" && url.origin !== event.url.origin || url.origin === event.url.origin)) {
5634
4549
  request.headers.delete("origin");
5635
4550
  }
5636
- if (url.origin !== event.url.origin) {
4551
+ const decoded = decodeURIComponent(url.pathname);
4552
+ if (url.origin !== event.url.origin || base && decoded !== base && !decoded.startsWith(`${base}/`)) {
5637
4553
  if (`.${url.hostname}`.endsWith(`.${event.url.hostname}`) && credentials !== "omit") {
5638
- const cookie = get_cookie_header(url, request.headers.get("cookie"));
5639
- if (cookie) request.headers.set("cookie", cookie);
4554
+ const cookie2 = get_cookie_header(url, request.headers.get("cookie"));
4555
+ if (cookie2) request.headers.set("cookie", cookie2);
5640
4556
  }
5641
4557
  return fetch(request);
5642
4558
  }
5643
4559
  const prefix = assets || base;
5644
- const decoded = decodeURIComponent(url.pathname);
5645
4560
  const filename = (decoded.startsWith(prefix) ? decoded.slice(prefix.length) : decoded).slice(1);
5646
4561
  const filename_html = `${filename}/index.html`;
5647
4562
  const is_asset = manifest.assets.has(filename) || filename in manifest._.server_assets;
@@ -5669,9 +4584,9 @@ function create_fetch({ event, options: options2, manifest, state, get_cookie_he
5669
4584
  return await fetch(request);
5670
4585
  }
5671
4586
  if (credentials !== "omit") {
5672
- const cookie = get_cookie_header(url, request.headers.get("cookie"));
5673
- if (cookie) {
5674
- request.headers.set("cookie", cookie);
4587
+ const cookie2 = get_cookie_header(url, request.headers.get("cookie"));
4588
+ if (cookie2) {
4589
+ request.headers.set("cookie", cookie2);
5675
4590
  }
5676
4591
  const authorization = event.request.headers.get("authorization");
5677
4592
  if (authorization && !request.headers.has("authorization")) {
@@ -5691,8 +4606,8 @@ function create_fetch({ event, options: options2, manifest, state, get_cookie_he
5691
4606
  const response = await internal_fetch(request, options2, manifest, state);
5692
4607
  const set_cookie = response.headers.get("set-cookie");
5693
4608
  if (set_cookie) {
5694
- for (const str of setCookieExports.splitCookiesString(set_cookie)) {
5695
- const { name, value, ...options3 } = setCookieExports.parseString(str, {
4609
+ for (const str of splitCookiesString(set_cookie)) {
4610
+ const { name, value, ...options3 } = parseString(str, {
5696
4611
  decodeValues: false
5697
4612
  });
5698
4613
  const path = options3.path ?? (url.pathname.split("/").slice(0, -1).join("/") || "/");
@@ -5766,71 +4681,36 @@ function get_public_env(request) {
5766
4681
  }
5767
4682
  return new Response(body, { headers });
5768
4683
  }
5769
- const VALID_CACHE_CONTROL_DIRECTIVES = /* @__PURE__ */ new Set([
5770
- "max-age",
5771
- "public",
5772
- "private",
5773
- "no-cache",
5774
- "no-store",
5775
- "must-revalidate",
5776
- "proxy-revalidate",
5777
- "s-maxage",
5778
- "immutable",
5779
- "stale-while-revalidate",
5780
- "stale-if-error",
5781
- "no-transform",
5782
- "only-if-cached",
5783
- "max-stale",
5784
- "min-fresh"
5785
- ]);
5786
- const CONTENT_TYPE_PATTERN = /^(application|audio|example|font|haptics|image|message|model|multipart|text|video|x-[a-z]+)\/[-+.\w]+$/i;
5787
- const HEADER_VALIDATORS = {
5788
- "cache-control": (value) => {
5789
- const error_suffix = `(While parsing "${value}".)`;
5790
- const parts = value.split(",").map((part) => part.trim());
5791
- if (parts.some((part) => !part)) {
5792
- throw new Error(`\`cache-control\` header contains empty directives. ${error_suffix}`);
5793
- }
5794
- const directives = parts.map((part) => part.split("=")[0].toLowerCase());
5795
- const invalid = directives.find((directive) => !VALID_CACHE_CONTROL_DIRECTIVES.has(directive));
5796
- if (invalid) {
5797
- throw new Error(
5798
- `Invalid cache-control directive "${invalid}". Did you mean one of: ${[...VALID_CACHE_CONTROL_DIRECTIVES].join(", ")}? ${error_suffix}`
5799
- );
5800
- }
5801
- },
5802
- "content-type": (value) => {
5803
- const type = value.split(";")[0].trim();
5804
- const error_suffix = `(While parsing "${value}".)`;
5805
- if (!CONTENT_TYPE_PATTERN.test(type)) {
5806
- throw new Error(`Invalid content-type value "${type}". ${error_suffix}`);
5807
- }
5808
- }
5809
- };
5810
- function validateHeaders(headers2) {
5811
- for (const [key2, value] of Object.entries(headers2)) {
5812
- const validator = HEADER_VALIDATORS[key2.toLowerCase()];
5813
- try {
5814
- validator?.(value);
5815
- } catch (error2) {
5816
- if (error2 instanceof Error) {
5817
- console.warn(`[SvelteKit] ${error2.message}`);
5818
- }
5819
- }
5820
- }
5821
- }
5822
4684
  const default_transform = ({ html }) => html;
5823
4685
  const default_filter = () => false;
5824
4686
  const default_preload = ({ type }) => type === "js" || type === "css";
5825
4687
  const page_methods = /* @__PURE__ */ new Set(["GET", "HEAD", "POST"]);
5826
4688
  const allowed_page_methods = /* @__PURE__ */ new Set(["GET", "HEAD", "OPTIONS"]);
5827
- let warned_on_devtools_json_request = false;
5828
4689
  const respond = propagate_context(internal_respond);
5829
4690
  async function internal_respond(request, options2, manifest, state) {
5830
4691
  const url = new URL(request.url);
5831
4692
  const is_route_resolution_request = has_resolution_suffix(url.pathname);
5832
4693
  const is_data_request = has_data_suffix(url.pathname);
5833
4694
  const remote_id = get_remote_id(url);
4695
+ {
4696
+ const request_origin = request.headers.get("origin");
4697
+ if (remote_id) {
4698
+ if (request.method !== "GET" && request_origin !== url.origin) {
4699
+ const message = "Cross-site remote requests are forbidden";
4700
+ return json({ message }, { status: 403 });
4701
+ }
4702
+ } else if (options2.csrf_check_origin) {
4703
+ 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));
4704
+ if (forbidden) {
4705
+ const message = `Cross-site ${request.method} form submissions are forbidden`;
4706
+ const opts = { status: 403 };
4707
+ if (request.headers.get("accept") === "application/json") {
4708
+ return json({ message }, opts);
4709
+ }
4710
+ return text(message, opts);
4711
+ }
4712
+ }
4713
+ }
5834
4714
  if (options2.hash_routing && url.pathname !== base + "/" && url.pathname !== "/[fallback]") {
5835
4715
  return text("Not found", { status: 404 });
5836
4716
  }
@@ -5875,9 +4755,6 @@ async function internal_respond(request, options2, manifest, state) {
5875
4755
  request,
5876
4756
  route: { id: null },
5877
4757
  setHeaders: (new_headers) => {
5878
- {
5879
- validateHeaders(new_headers);
5880
- }
5881
4758
  for (const key2 in new_headers) {
5882
4759
  const lower = key2.toLowerCase();
5883
4760
  const value = new_headers[key2];
@@ -5980,16 +4857,11 @@ async function internal_respond(request, options2, manifest, state) {
5980
4857
  }
5981
4858
  if (!state.prerendering?.fallback) {
5982
4859
  const matchers = await manifest._.matchers();
5983
- for (const candidate of manifest._.routes) {
5984
- const match = candidate.pattern.exec(resolved_path);
5985
- if (!match) continue;
5986
- const matched = exec(match, candidate.params, matchers);
5987
- if (matched) {
5988
- route = candidate;
5989
- event.route = { id: route.id };
5990
- event.params = decode_params(matched);
5991
- break;
5992
- }
4860
+ const result = find_route(resolved_path, manifest._.routes, matchers);
4861
+ if (result) {
4862
+ route = result.route;
4863
+ event.route = { id: route.id };
4864
+ event.params = result.params;
5993
4865
  }
5994
4866
  }
5995
4867
  let resolve_opts = {
@@ -6004,20 +4876,12 @@ async function internal_respond(request, options2, manifest, state) {
6004
4876
  if (url.pathname === base || url.pathname === base + "/") {
6005
4877
  trailing_slash = "always";
6006
4878
  } else if (page_nodes) {
6007
- if (DEV) {
6008
- page_nodes.validate();
6009
- }
4879
+ if (browser) ;
6010
4880
  trailing_slash = page_nodes.trailing_slash();
6011
4881
  } else if (route.endpoint) {
6012
4882
  const node = await route.endpoint();
6013
4883
  trailing_slash = node.trailingSlash ?? "never";
6014
- if (DEV) {
6015
- validate_server_exports(
6016
- node,
6017
- /** @type {string} */
6018
- route.endpoint_id
6019
- );
6020
- }
4884
+ if (browser) ;
6021
4885
  }
6022
4886
  if (!is_data_request) {
6023
4887
  const normalized = normalize_path(url.pathname, trailing_slash);
@@ -6075,6 +4939,7 @@ async function internal_respond(request, options2, manifest, state) {
6075
4939
  current: root_span
6076
4940
  }
6077
4941
  };
4942
+ event_state.allows_commands = MUTATIVE_METHODS.includes(request.method);
6078
4943
  return await with_request_store(
6079
4944
  { event: traced_event, state: event_state },
6080
4945
  () => options2.hooks.handle({
@@ -6277,17 +5142,7 @@ async function internal_respond(request, options2, manifest, state) {
6277
5142
  });
6278
5143
  }
6279
5144
  if (state.depth === 0) {
6280
- if (DEV && event2.url.pathname === "/.well-known/appspecific/com.chrome.devtools.json") {
6281
- if (!warned_on_devtools_json_request) {
6282
- console.log(
6283
- `
6284
- Google Chrome is requesting ${event2.url.pathname} to automatically configure devtools project settings. To learn why, and how to prevent this message, see https://svelte.dev/docs/cli/devtools-json
6285
- `
6286
- );
6287
- warned_on_devtools_json_request = true;
6288
- }
6289
- return new Response(void 0, { status: 404 });
6290
- }
5145
+ if (browser && event2.url.pathname === "/.well-known/appspecific/com.chrome.devtools.json") ;
6291
5146
  return await respond_with_error({
6292
5147
  event: event2,
6293
5148
  event_state,
@@ -6432,19 +5287,7 @@ class Server {
6432
5287
  }
6433
5288
  } catch (e) {
6434
5289
  {
6435
- this.#options.hooks = {
6436
- handle: () => {
6437
- throw e;
6438
- },
6439
- handleError: ({ error: error2 }) => console.error(error2),
6440
- handleFetch: ({ request, fetch: fetch2 }) => fetch2(request),
6441
- handleValidationError: () => {
6442
- return { message: "Bad Request" };
6443
- },
6444
- reroute: () => {
6445
- },
6446
- transport: {}
6447
- };
5290
+ throw e;
6448
5291
  }
6449
5292
  }
6450
5293
  })());