@openpalm/ui 0.11.0-rc.2
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.
- package/README.md +129 -0
- package/build/.openpalm-ui-version +1 -0
- package/build/client/_app/immutable/assets/0.BK7X4bPu.css +1 -0
- package/build/client/_app/immutable/assets/0.BK7X4bPu.css.br +0 -0
- package/build/client/_app/immutable/assets/0.BK7X4bPu.css.gz +0 -0
- package/build/client/_app/immutable/assets/4.D9MwgTDo.css +1 -0
- package/build/client/_app/immutable/assets/4.D9MwgTDo.css.br +0 -0
- package/build/client/_app/immutable/assets/4.D9MwgTDo.css.gz +0 -0
- package/build/client/_app/immutable/assets/5.Cj0Mk9Gn.css +1 -0
- package/build/client/_app/immutable/assets/5.Cj0Mk9Gn.css.br +0 -0
- package/build/client/_app/immutable/assets/5.Cj0Mk9Gn.css.gz +0 -0
- package/build/client/_app/immutable/assets/6.DJenXolA.css +1 -0
- package/build/client/_app/immutable/assets/6.DJenXolA.css.br +0 -0
- package/build/client/_app/immutable/assets/6.DJenXolA.css.gz +0 -0
- package/build/client/_app/immutable/assets/7.BHUsSUvX.css +1 -0
- package/build/client/_app/immutable/assets/7.BHUsSUvX.css.br +0 -0
- package/build/client/_app/immutable/assets/7.BHUsSUvX.css.gz +0 -0
- package/build/client/_app/immutable/assets/8.DjrHy5wu.css +1 -0
- package/build/client/_app/immutable/assets/8.DjrHy5wu.css.br +0 -0
- package/build/client/_app/immutable/assets/8.DjrHy5wu.css.gz +0 -0
- package/build/client/_app/immutable/assets/AuthGate.BtJV-xXj.css +1 -0
- package/build/client/_app/immutable/assets/AuthGate.BtJV-xXj.css.br +0 -0
- package/build/client/_app/immutable/assets/AuthGate.BtJV-xXj.css.gz +0 -0
- package/build/client/_app/immutable/assets/VoiceProfileSelector.Dp7tWdKe.css +1 -0
- package/build/client/_app/immutable/assets/VoiceProfileSelector.Dp7tWdKe.css.br +0 -0
- package/build/client/_app/immutable/assets/VoiceProfileSelector.Dp7tWdKe.css.gz +0 -0
- package/build/client/_app/immutable/chunks/BuFlayix.js +1 -0
- package/build/client/_app/immutable/chunks/BuFlayix.js.br +0 -0
- package/build/client/_app/immutable/chunks/BuFlayix.js.gz +0 -0
- package/build/client/_app/immutable/chunks/BwTF6U35.js +3 -0
- package/build/client/_app/immutable/chunks/BwTF6U35.js.br +0 -0
- package/build/client/_app/immutable/chunks/BwTF6U35.js.gz +0 -0
- package/build/client/_app/immutable/chunks/C8qMxft1.js +1 -0
- package/build/client/_app/immutable/chunks/C8qMxft1.js.br +0 -0
- package/build/client/_app/immutable/chunks/C8qMxft1.js.gz +0 -0
- package/build/client/_app/immutable/chunks/Cb_i8bV9.js +1 -0
- package/build/client/_app/immutable/chunks/Cb_i8bV9.js.br +0 -0
- package/build/client/_app/immutable/chunks/Cb_i8bV9.js.gz +0 -0
- package/build/client/_app/immutable/chunks/CzXGhlNF.js +1 -0
- package/build/client/_app/immutable/chunks/CzXGhlNF.js.br +0 -0
- package/build/client/_app/immutable/chunks/CzXGhlNF.js.gz +0 -0
- package/build/client/_app/immutable/chunks/DYskO3Sk.js +5 -0
- package/build/client/_app/immutable/chunks/DYskO3Sk.js.br +0 -0
- package/build/client/_app/immutable/chunks/DYskO3Sk.js.gz +0 -0
- package/build/client/_app/immutable/chunks/ak2ISc8B.js +1 -0
- package/build/client/_app/immutable/chunks/ak2ISc8B.js.br +0 -0
- package/build/client/_app/immutable/chunks/ak2ISc8B.js.gz +0 -0
- package/build/client/_app/immutable/chunks/kNaey6uv.js +1 -0
- package/build/client/_app/immutable/chunks/kNaey6uv.js.br +0 -0
- package/build/client/_app/immutable/chunks/kNaey6uv.js.gz +0 -0
- package/build/client/_app/immutable/chunks/os2NZ37U.js +1 -0
- package/build/client/_app/immutable/chunks/os2NZ37U.js.br +1 -0
- package/build/client/_app/immutable/chunks/os2NZ37U.js.gz +0 -0
- package/build/client/_app/immutable/chunks/xihTtKlq.js +1 -0
- package/build/client/_app/immutable/chunks/xihTtKlq.js.br +1 -0
- package/build/client/_app/immutable/chunks/xihTtKlq.js.gz +0 -0
- package/build/client/_app/immutable/entry/app.C_eSlUyi.js +2 -0
- package/build/client/_app/immutable/entry/app.C_eSlUyi.js.br +0 -0
- package/build/client/_app/immutable/entry/app.C_eSlUyi.js.gz +0 -0
- package/build/client/_app/immutable/entry/start.BAta_Cih.js +1 -0
- package/build/client/_app/immutable/entry/start.BAta_Cih.js.br +0 -0
- package/build/client/_app/immutable/entry/start.BAta_Cih.js.gz +0 -0
- package/build/client/_app/immutable/nodes/0.Bi_of0So.js +1 -0
- package/build/client/_app/immutable/nodes/0.Bi_of0So.js.br +0 -0
- package/build/client/_app/immutable/nodes/0.Bi_of0So.js.gz +0 -0
- package/build/client/_app/immutable/nodes/1.qjZsjpWC.js +1 -0
- package/build/client/_app/immutable/nodes/1.qjZsjpWC.js.br +0 -0
- package/build/client/_app/immutable/nodes/1.qjZsjpWC.js.gz +0 -0
- package/build/client/_app/immutable/nodes/2.ojh8oE7F.js +1 -0
- package/build/client/_app/immutable/nodes/2.ojh8oE7F.js.br +0 -0
- package/build/client/_app/immutable/nodes/2.ojh8oE7F.js.gz +0 -0
- package/build/client/_app/immutable/nodes/3.DeAC3yVJ.js +1 -0
- package/build/client/_app/immutable/nodes/3.DeAC3yVJ.js.br +0 -0
- package/build/client/_app/immutable/nodes/3.DeAC3yVJ.js.gz +0 -0
- package/build/client/_app/immutable/nodes/4.BYtA2xx-.js +19 -0
- package/build/client/_app/immutable/nodes/4.BYtA2xx-.js.br +0 -0
- package/build/client/_app/immutable/nodes/4.BYtA2xx-.js.gz +0 -0
- package/build/client/_app/immutable/nodes/5.ChSoAFFd.js +4 -0
- package/build/client/_app/immutable/nodes/5.ChSoAFFd.js.br +0 -0
- package/build/client/_app/immutable/nodes/5.ChSoAFFd.js.gz +0 -0
- package/build/client/_app/immutable/nodes/6.BRG0vYmH.js +1 -0
- package/build/client/_app/immutable/nodes/6.BRG0vYmH.js.br +0 -0
- package/build/client/_app/immutable/nodes/6.BRG0vYmH.js.gz +0 -0
- package/build/client/_app/immutable/nodes/7.BVvy1f_p.js +15 -0
- package/build/client/_app/immutable/nodes/7.BVvy1f_p.js.br +0 -0
- package/build/client/_app/immutable/nodes/7.BVvy1f_p.js.gz +0 -0
- package/build/client/_app/immutable/nodes/8.Cb4MWMah.js +2 -0
- package/build/client/_app/immutable/nodes/8.Cb4MWMah.js.br +0 -0
- package/build/client/_app/immutable/nodes/8.Cb4MWMah.js.gz +0 -0
- package/build/client/_app/version.json +1 -0
- package/build/client/_app/version.json.br +0 -0
- package/build/client/_app/version.json.gz +0 -0
- package/build/client/banner.png +0 -0
- package/build/client/fu-128.png +0 -0
- package/build/client/fu.png +0 -0
- package/build/client/logo-128.png +0 -0
- package/build/client/logo.png +0 -0
- package/build/client/setup/wizard.css +1639 -0
- package/build/client/setup/wizard.css.br +0 -0
- package/build/client/setup/wizard.css.gz +0 -0
- package/build/client/wizard-128.png +0 -0
- package/build/client/wizard.png +0 -0
- package/build/env.js +94 -0
- package/build/handler.js +1494 -0
- package/build/index.js +345 -0
- package/build/server/chunks/0-Dk6RRhi2.js +9 -0
- package/build/server/chunks/0-Dk6RRhi2.js.map +1 -0
- package/build/server/chunks/1-CWcY3PRs.js +9 -0
- package/build/server/chunks/1-CWcY3PRs.js.map +1 -0
- package/build/server/chunks/2-C2y4ydWU.js +9 -0
- package/build/server/chunks/2-C2y4ydWU.js.map +1 -0
- package/build/server/chunks/3-BgeGdVvT.js +23 -0
- package/build/server/chunks/3-BgeGdVvT.js.map +1 -0
- package/build/server/chunks/4-DeAt_mYc.js +9 -0
- package/build/server/chunks/4-DeAt_mYc.js.map +1 -0
- package/build/server/chunks/5-qTXiNPEM.js +9 -0
- package/build/server/chunks/5-qTXiNPEM.js.map +1 -0
- package/build/server/chunks/6-C444Mr69.js +9 -0
- package/build/server/chunks/6-C444Mr69.js.map +1 -0
- package/build/server/chunks/7-Dg_sVly5.js +9 -0
- package/build/server/chunks/7-Dg_sVly5.js.map +1 -0
- package/build/server/chunks/8-CF5kn4AY.js +9 -0
- package/build/server/chunks/8-CF5kn4AY.js.map +1 -0
- package/build/server/chunks/AuthGate-keg7G6rX.js +707 -0
- package/build/server/chunks/AuthGate-keg7G6rX.js.map +1 -0
- package/build/server/chunks/_helpers-B_lb4-jB.js +74 -0
- package/build/server/chunks/_helpers-B_lb4-jB.js.map +1 -0
- package/build/server/chunks/_layout.svelte-B93aaRP_.js +11 -0
- package/build/server/chunks/_layout.svelte-B93aaRP_.js.map +1 -0
- package/build/server/chunks/_layout.svelte-BNWepgTx.js +58 -0
- package/build/server/chunks/_layout.svelte-BNWepgTx.js.map +1 -0
- package/build/server/chunks/_page.svelte-BP2EdQl3.js +5 -0
- package/build/server/chunks/_page.svelte-BP2EdQl3.js.map +1 -0
- package/build/server/chunks/_page.svelte-BdYSYjmj.js +67 -0
- package/build/server/chunks/_page.svelte-BdYSYjmj.js.map +1 -0
- package/build/server/chunks/_page.svelte-BiKY57wg.js +533 -0
- package/build/server/chunks/_page.svelte-BiKY57wg.js.map +1 -0
- package/build/server/chunks/_page.svelte-CtX_8pMq.js +5528 -0
- package/build/server/chunks/_page.svelte-CtX_8pMq.js.map +1 -0
- package/build/server/chunks/_page.svelte-D0gMlmzQ.js +104 -0
- package/build/server/chunks/_page.svelte-D0gMlmzQ.js.map +1 -0
- package/build/server/chunks/_page.svelte-DwMiUmq6.js +107 -0
- package/build/server/chunks/_page.svelte-DwMiUmq6.js.map +1 -0
- package/build/server/chunks/_server.ts-0FuXkx70.js +56 -0
- package/build/server/chunks/_server.ts-0FuXkx70.js.map +1 -0
- package/build/server/chunks/_server.ts-33LuQvHu.js +19 -0
- package/build/server/chunks/_server.ts-33LuQvHu.js.map +1 -0
- package/build/server/chunks/_server.ts-5Q0J3F4-.js +55 -0
- package/build/server/chunks/_server.ts-5Q0J3F4-.js.map +1 -0
- package/build/server/chunks/_server.ts-AJk0xBLJ.js +46 -0
- package/build/server/chunks/_server.ts-AJk0xBLJ.js.map +1 -0
- package/build/server/chunks/_server.ts-AQe1PIYE.js +68 -0
- package/build/server/chunks/_server.ts-AQe1PIYE.js.map +1 -0
- package/build/server/chunks/_server.ts-B0N2Nj7L.js +44 -0
- package/build/server/chunks/_server.ts-B0N2Nj7L.js.map +1 -0
- package/build/server/chunks/_server.ts-BDBJ6fxs.js +67 -0
- package/build/server/chunks/_server.ts-BDBJ6fxs.js.map +1 -0
- package/build/server/chunks/_server.ts-BEeaI665.js +79 -0
- package/build/server/chunks/_server.ts-BEeaI665.js.map +1 -0
- package/build/server/chunks/_server.ts-BM4QuGQf.js +53 -0
- package/build/server/chunks/_server.ts-BM4QuGQf.js.map +1 -0
- package/build/server/chunks/_server.ts-BSIZMZVn.js +50 -0
- package/build/server/chunks/_server.ts-BSIZMZVn.js.map +1 -0
- package/build/server/chunks/_server.ts-BV-6Mum8.js +54 -0
- package/build/server/chunks/_server.ts-BV-6Mum8.js.map +1 -0
- package/build/server/chunks/_server.ts-BdnJF23z.js +44 -0
- package/build/server/chunks/_server.ts-BdnJF23z.js.map +1 -0
- package/build/server/chunks/_server.ts-Bfy4RFhe.js +41 -0
- package/build/server/chunks/_server.ts-Bfy4RFhe.js.map +1 -0
- package/build/server/chunks/_server.ts-Bhh33s6N.js +149 -0
- package/build/server/chunks/_server.ts-Bhh33s6N.js.map +1 -0
- package/build/server/chunks/_server.ts-BiSuK8jN.js +41 -0
- package/build/server/chunks/_server.ts-BiSuK8jN.js.map +1 -0
- package/build/server/chunks/_server.ts-BjiyoKWK.js +41 -0
- package/build/server/chunks/_server.ts-BjiyoKWK.js.map +1 -0
- package/build/server/chunks/_server.ts-BnEeEd9g.js +57 -0
- package/build/server/chunks/_server.ts-BnEeEd9g.js.map +1 -0
- package/build/server/chunks/_server.ts-Bq2dkWvj.js +33 -0
- package/build/server/chunks/_server.ts-Bq2dkWvj.js.map +1 -0
- package/build/server/chunks/_server.ts-Br16AqpO.js +82 -0
- package/build/server/chunks/_server.ts-Br16AqpO.js.map +1 -0
- package/build/server/chunks/_server.ts-BsZrddQT.js +200 -0
- package/build/server/chunks/_server.ts-BsZrddQT.js.map +1 -0
- package/build/server/chunks/_server.ts-Btbzy89u.js +65 -0
- package/build/server/chunks/_server.ts-Btbzy89u.js.map +1 -0
- package/build/server/chunks/_server.ts-BudQlGOx.js +70 -0
- package/build/server/chunks/_server.ts-BudQlGOx.js.map +1 -0
- package/build/server/chunks/_server.ts-BxPYakCb.js +59 -0
- package/build/server/chunks/_server.ts-BxPYakCb.js.map +1 -0
- package/build/server/chunks/_server.ts-ByyRcwFy.js +79 -0
- package/build/server/chunks/_server.ts-ByyRcwFy.js.map +1 -0
- package/build/server/chunks/_server.ts-C7rtn3mH.js +103 -0
- package/build/server/chunks/_server.ts-C7rtn3mH.js.map +1 -0
- package/build/server/chunks/_server.ts-C88qd-ju.js +46 -0
- package/build/server/chunks/_server.ts-C88qd-ju.js.map +1 -0
- package/build/server/chunks/_server.ts-CD6LeslU.js +55 -0
- package/build/server/chunks/_server.ts-CD6LeslU.js.map +1 -0
- package/build/server/chunks/_server.ts-CDlWxA5S.js +60 -0
- package/build/server/chunks/_server.ts-CDlWxA5S.js.map +1 -0
- package/build/server/chunks/_server.ts-CGqrfNlv.js +514 -0
- package/build/server/chunks/_server.ts-CGqrfNlv.js.map +1 -0
- package/build/server/chunks/_server.ts-CGwYZUuw.js +759 -0
- package/build/server/chunks/_server.ts-CGwYZUuw.js.map +1 -0
- package/build/server/chunks/_server.ts-CHVs0yya.js +54 -0
- package/build/server/chunks/_server.ts-CHVs0yya.js.map +1 -0
- package/build/server/chunks/_server.ts-CMEY6oQe.js +121 -0
- package/build/server/chunks/_server.ts-CMEY6oQe.js.map +1 -0
- package/build/server/chunks/_server.ts-CS73tiTY.js +63 -0
- package/build/server/chunks/_server.ts-CS73tiTY.js.map +1 -0
- package/build/server/chunks/_server.ts-CWwgmo8z.js +33 -0
- package/build/server/chunks/_server.ts-CWwgmo8z.js.map +1 -0
- package/build/server/chunks/_server.ts-CXzZeGlQ.js +55 -0
- package/build/server/chunks/_server.ts-CXzZeGlQ.js.map +1 -0
- package/build/server/chunks/_server.ts-C_kseo_y.js +72 -0
- package/build/server/chunks/_server.ts-C_kseo_y.js.map +1 -0
- package/build/server/chunks/_server.ts-Cbk-UThV.js +73 -0
- package/build/server/chunks/_server.ts-Cbk-UThV.js.map +1 -0
- package/build/server/chunks/_server.ts-CboRRTK1.js +139 -0
- package/build/server/chunks/_server.ts-CboRRTK1.js.map +1 -0
- package/build/server/chunks/_server.ts-CgD8-EFl.js +52 -0
- package/build/server/chunks/_server.ts-CgD8-EFl.js.map +1 -0
- package/build/server/chunks/_server.ts-Ci-q0BiD.js +79 -0
- package/build/server/chunks/_server.ts-Ci-q0BiD.js.map +1 -0
- package/build/server/chunks/_server.ts-Cn7ahHlk.js +44 -0
- package/build/server/chunks/_server.ts-Cn7ahHlk.js.map +1 -0
- package/build/server/chunks/_server.ts-Cy36-qGT.js +60 -0
- package/build/server/chunks/_server.ts-Cy36-qGT.js.map +1 -0
- package/build/server/chunks/_server.ts-CyFZ9OZQ.js +97 -0
- package/build/server/chunks/_server.ts-CyFZ9OZQ.js.map +1 -0
- package/build/server/chunks/_server.ts-D-UAqhor.js +33 -0
- package/build/server/chunks/_server.ts-D-UAqhor.js.map +1 -0
- package/build/server/chunks/_server.ts-D1cb1hmF.js +90 -0
- package/build/server/chunks/_server.ts-D1cb1hmF.js.map +1 -0
- package/build/server/chunks/_server.ts-D33gvU5B.js +65 -0
- package/build/server/chunks/_server.ts-D33gvU5B.js.map +1 -0
- package/build/server/chunks/_server.ts-DDwiNChJ.js +88 -0
- package/build/server/chunks/_server.ts-DDwiNChJ.js.map +1 -0
- package/build/server/chunks/_server.ts-DEnxvwcJ.js +46 -0
- package/build/server/chunks/_server.ts-DEnxvwcJ.js.map +1 -0
- package/build/server/chunks/_server.ts-DHXmcRrP.js +41 -0
- package/build/server/chunks/_server.ts-DHXmcRrP.js.map +1 -0
- package/build/server/chunks/_server.ts-DQxY-pHZ.js +64 -0
- package/build/server/chunks/_server.ts-DQxY-pHZ.js.map +1 -0
- package/build/server/chunks/_server.ts-DXNJ2LJu.js +83 -0
- package/build/server/chunks/_server.ts-DXNJ2LJu.js.map +1 -0
- package/build/server/chunks/_server.ts-Dbly1Fe-.js +96 -0
- package/build/server/chunks/_server.ts-Dbly1Fe-.js.map +1 -0
- package/build/server/chunks/_server.ts-DffjWMNC.js +53 -0
- package/build/server/chunks/_server.ts-DffjWMNC.js.map +1 -0
- package/build/server/chunks/_server.ts-Di-8UJYw.js +40 -0
- package/build/server/chunks/_server.ts-Di-8UJYw.js.map +1 -0
- package/build/server/chunks/_server.ts-DsEzCr9k.js +109 -0
- package/build/server/chunks/_server.ts-DsEzCr9k.js.map +1 -0
- package/build/server/chunks/_server.ts-DwXd92Ow.js +63 -0
- package/build/server/chunks/_server.ts-DwXd92Ow.js.map +1 -0
- package/build/server/chunks/_server.ts-DwjjO7L5.js +41 -0
- package/build/server/chunks/_server.ts-DwjjO7L5.js.map +1 -0
- package/build/server/chunks/_server.ts-DyEbcQS0.js +62 -0
- package/build/server/chunks/_server.ts-DyEbcQS0.js.map +1 -0
- package/build/server/chunks/_server.ts-HxcM6xQA.js +70 -0
- package/build/server/chunks/_server.ts-HxcM6xQA.js.map +1 -0
- package/build/server/chunks/_server.ts-JItoNB1Z.js +57 -0
- package/build/server/chunks/_server.ts-JItoNB1Z.js.map +1 -0
- package/build/server/chunks/_server.ts-KpT_vKKo.js +77 -0
- package/build/server/chunks/_server.ts-KpT_vKKo.js.map +1 -0
- package/build/server/chunks/_server.ts-WbY7XmtT.js +157 -0
- package/build/server/chunks/_server.ts-WbY7XmtT.js.map +1 -0
- package/build/server/chunks/_server.ts-Yy0BWsSd.js +70 -0
- package/build/server/chunks/_server.ts-Yy0BWsSd.js.map +1 -0
- package/build/server/chunks/_server.ts-b9yNYKW6.js +49 -0
- package/build/server/chunks/_server.ts-b9yNYKW6.js.map +1 -0
- package/build/server/chunks/_server.ts-bAJXjaCc.js +42 -0
- package/build/server/chunks/_server.ts-bAJXjaCc.js.map +1 -0
- package/build/server/chunks/_server.ts-cwRl-tZ-.js +40 -0
- package/build/server/chunks/_server.ts-cwRl-tZ-.js.map +1 -0
- package/build/server/chunks/_server.ts-hMTx0DC3.js +159 -0
- package/build/server/chunks/_server.ts-hMTx0DC3.js.map +1 -0
- package/build/server/chunks/_server.ts-l_HoZ2_I.js +163 -0
- package/build/server/chunks/_server.ts-l_HoZ2_I.js.map +1 -0
- package/build/server/chunks/_server.ts-uLRX2uy0.js +107 -0
- package/build/server/chunks/_server.ts-uLRX2uy0.js.map +1 -0
- package/build/server/chunks/_server.ts-uWfb47S6.js +204 -0
- package/build/server/chunks/_server.ts-uWfb47S6.js.map +1 -0
- package/build/server/chunks/addon-helpers-Bnj3aKJ2.js +49 -0
- package/build/server/chunks/addon-helpers-Bnj3aKJ2.js.map +1 -0
- package/build/server/chunks/chunk-CLZ62Ad-.js +18 -0
- package/build/server/chunks/chunk-CLZ62Ad-.js.map +1 -0
- package/build/server/chunks/coercion-TNFJisCC.js +34 -0
- package/build/server/chunks/coercion-TNFJisCC.js.map +1 -0
- package/build/server/chunks/config-CEYPfvQh.js +121 -0
- package/build/server/chunks/config-CEYPfvQh.js.map +1 -0
- package/build/server/chunks/dev-DjANv7AF.js +4389 -0
- package/build/server/chunks/dev-DjANv7AF.js.map +1 -0
- package/build/server/chunks/docker-sGFTjRfy.js +20 -0
- package/build/server/chunks/docker-sGFTjRfy.js.map +1 -0
- package/build/server/chunks/endpoints-L7Wjvq44.js +340 -0
- package/build/server/chunks/endpoints-L7Wjvq44.js.map +1 -0
- package/build/server/chunks/environment-BnT49Gi3.js +36 -0
- package/build/server/chunks/environment-BnT49Gi3.js.map +1 -0
- package/build/server/chunks/error.svelte-PJnhZZCy.js +16 -0
- package/build/server/chunks/error.svelte-PJnhZZCy.js.map +1 -0
- package/build/server/chunks/exports-D1quPX8S.js +124 -0
- package/build/server/chunks/exports-D1quPX8S.js.map +1 -0
- package/build/server/chunks/helpers-5jd3ccud.js +226 -0
- package/build/server/chunks/helpers-5jd3ccud.js.map +1 -0
- package/build/server/chunks/hooks.server-Al9-eO5K.js +82 -0
- package/build/server/chunks/hooks.server-Al9-eO5K.js.map +1 -0
- package/build/server/chunks/http-D5xo_m60.js +31 -0
- package/build/server/chunks/http-D5xo_m60.js.map +1 -0
- package/build/server/chunks/internal-CJBOAkaQ.js +1544 -0
- package/build/server/chunks/internal-CJBOAkaQ.js.map +1 -0
- package/build/server/chunks/serial-queue-D9FEpYVv.js +22 -0
- package/build/server/chunks/serial-queue-D9FEpYVv.js.map +1 -0
- package/build/server/chunks/setup-deploy-UKTSVAC0.js +529 -0
- package/build/server/chunks/setup-deploy-UKTSVAC0.js.map +1 -0
- package/build/server/chunks/src-FpMyngcw.js +14064 -0
- package/build/server/chunks/src-FpMyngcw.js.map +1 -0
- package/build/server/chunks/state-BI-lJPhE.js +203 -0
- package/build/server/chunks/state-BI-lJPhE.js.map +1 -0
- package/build/server/chunks/utils-BSRjJDrZ.js +150 -0
- package/build/server/chunks/utils-BSRjJDrZ.js.map +1 -0
- package/build/server/chunks/voice-state.svelte-CQp8u0bn.js +437 -0
- package/build/server/chunks/voice-state.svelte-CQp8u0bn.js.map +1 -0
- package/build/server/index.js +4359 -0
- package/build/server/index.js.map +1 -0
- package/build/server/manifest.js +570 -0
- package/build/server/manifest.js.map +1 -0
- package/build/shims.js +32 -0
- package/package.json +61 -0
|
@@ -0,0 +1,4359 @@
|
|
|
1
|
+
import { _ as __commonJSMin } from './chunks/chunk-CLZ62Ad-.js';
|
|
2
|
+
import { c as coalesce_to_error, j as get_status, i as get_message, F as with_request_store, t as parse, s as options, a as IN_WEBCONTAINER, h as get_hooks, n as noop, T as TRAILING_SLASH_PARAM, I as INVALIDATED_PARAM, e as decode_pathname, g as find_route, q as normalize_path, f as disable_search, C as validate_layout_server_exports, B as validate_layout_exports, E as validate_page_server_exports, D as validate_page_exports, o as noop_span, w as resolve, v as read_implementation, l as merge_tracing, x as set_read_implementation, d as create_remote_key, k as hash, b as compact, r as once, p as normalize_error, m as make_trackable, u as parse_remote_arg, z as stringify, A as stringify$1, y as split_remote_key, N as NULL_BODY_STATUS } from './chunks/internal-CJBOAkaQ.js';
|
|
3
|
+
import { H as HttpError, S as SvelteKitError, e as has_resolution_suffix, h as has_data_suffix, f as strip_resolution_suffix, s as strip_data_suffix, a as add_data_suffix, b as add_resolution_suffix, R as Redirect, g as get_relative_path, t as text_encoder, A as ActionFailure, d as base64_encode } from './chunks/utils-BSRjJDrZ.js';
|
|
4
|
+
import { j as json, t as text, i as isRedirect, e as error } from './chunks/exports-D1quPX8S.js';
|
|
5
|
+
import { s as set_private_env, d as set_public_env, c as base, p as public_env, o as override, b as assets, r as reset, a as app_dir } from './chunks/environment-BnT49Gi3.js';
|
|
6
|
+
import { a9 as uneval, ab as writable, X as readable } from './chunks/dev-DjANv7AF.js';
|
|
7
|
+
import 'node:module';
|
|
8
|
+
|
|
9
|
+
var ENDPOINT_METHODS = [
|
|
10
|
+
"GET",
|
|
11
|
+
"POST",
|
|
12
|
+
"PUT",
|
|
13
|
+
"PATCH",
|
|
14
|
+
"DELETE",
|
|
15
|
+
"OPTIONS",
|
|
16
|
+
"HEAD"
|
|
17
|
+
];
|
|
18
|
+
var PAGE_METHODS = [
|
|
19
|
+
"GET",
|
|
20
|
+
"POST",
|
|
21
|
+
"HEAD"
|
|
22
|
+
];
|
|
23
|
+
//#endregion
|
|
24
|
+
//#region ../../node_modules/.bun/@sveltejs+kit@2.61.0+aeb06e9cf8e23ab6/node_modules/@sveltejs/kit/src/runtime/form-utils.js
|
|
25
|
+
/** @import { RemoteForm } from '@sveltejs/kit' */
|
|
26
|
+
/** @import { BinaryFormMeta, InternalRemoteFormIssue } from 'types' */
|
|
27
|
+
/** @import { StandardSchemaV1 } from '@standard-schema/spec' */
|
|
28
|
+
var decoder = new TextDecoder();
|
|
29
|
+
/**
|
|
30
|
+
* Sets a value in a nested object using a path string, mutating the original object
|
|
31
|
+
* @param {Record<string, any>} object
|
|
32
|
+
* @param {string} path_string
|
|
33
|
+
* @param {any} value
|
|
34
|
+
*/
|
|
35
|
+
function set_nested_value(object, path_string, value) {
|
|
36
|
+
if (path_string.startsWith("n:")) {
|
|
37
|
+
path_string = path_string.slice(2);
|
|
38
|
+
value = value === "" ? void 0 : parseFloat(value);
|
|
39
|
+
} else if (path_string.startsWith("b:")) {
|
|
40
|
+
path_string = path_string.slice(2);
|
|
41
|
+
value = value === "on";
|
|
42
|
+
}
|
|
43
|
+
deep_set(object, split_path(path_string), value);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Convert `FormData` into a POJO
|
|
47
|
+
* @param {FormData} data
|
|
48
|
+
*/
|
|
49
|
+
function convert_formdata(data) {
|
|
50
|
+
/** @type {Record<string, any>} */
|
|
51
|
+
const result = {};
|
|
52
|
+
for (let key of data.keys()) {
|
|
53
|
+
const is_array = key.endsWith("[]");
|
|
54
|
+
/** @type {any[]} */
|
|
55
|
+
let values = data.getAll(key);
|
|
56
|
+
if (is_array) key = key.slice(0, -2);
|
|
57
|
+
if (values.length > 1 && !is_array) throw new Error(`Form cannot contain duplicated keys — "${key}" has ${values.length} values`);
|
|
58
|
+
values = values.filter((entry) => typeof entry === "string" || entry.name !== "" || entry.size > 0);
|
|
59
|
+
if (key.startsWith("n:")) {
|
|
60
|
+
key = key.slice(2);
|
|
61
|
+
values = values.map((v) => v === "" ? void 0 : parseFloat(v));
|
|
62
|
+
} else if (key.startsWith("b:")) {
|
|
63
|
+
key = key.slice(2);
|
|
64
|
+
values = values.map((v) => v === "on");
|
|
65
|
+
}
|
|
66
|
+
set_nested_value(result, key, is_array ? values : values[0]);
|
|
67
|
+
}
|
|
68
|
+
return result;
|
|
69
|
+
}
|
|
70
|
+
var BINARY_FORM_CONTENT_TYPE = "application/x-sveltekit-formdata";
|
|
71
|
+
var BINARY_FORM_VERSION = 0;
|
|
72
|
+
var HEADER_BYTES = 7;
|
|
73
|
+
/**
|
|
74
|
+
* @param {Request} request
|
|
75
|
+
* @returns {Promise<{ data: Record<string, any>; meta: BinaryFormMeta; form_data: FormData | null }>}
|
|
76
|
+
*/
|
|
77
|
+
async function deserialize_binary_form(request) {
|
|
78
|
+
if (request.headers.get("content-type") !== "application/x-sveltekit-formdata") {
|
|
79
|
+
const form_data = await request.formData();
|
|
80
|
+
return {
|
|
81
|
+
data: convert_formdata(form_data),
|
|
82
|
+
meta: {},
|
|
83
|
+
form_data
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
if (!request.body) throw deserialize_error("no body");
|
|
87
|
+
const reader = request.body.getReader();
|
|
88
|
+
/** @type {Array<Promise<Uint8Array<ArrayBuffer> | undefined>>} */
|
|
89
|
+
const chunks = [];
|
|
90
|
+
/**
|
|
91
|
+
* @param {number} index
|
|
92
|
+
* @returns {Promise<Uint8Array<ArrayBuffer> | undefined>}
|
|
93
|
+
*/
|
|
94
|
+
function get_chunk(index) {
|
|
95
|
+
if (index in chunks) return chunks[index];
|
|
96
|
+
let i = chunks.length;
|
|
97
|
+
while (i <= index) {
|
|
98
|
+
chunks[i] = reader.read().then((chunk) => chunk.value);
|
|
99
|
+
i++;
|
|
100
|
+
}
|
|
101
|
+
return chunks[index];
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* @param {number} offset
|
|
105
|
+
* @param {number} length
|
|
106
|
+
* @returns {Promise<Uint8Array | null>}
|
|
107
|
+
*/
|
|
108
|
+
async function get_buffer(offset, length) {
|
|
109
|
+
/** @type {Uint8Array} */
|
|
110
|
+
let start_chunk;
|
|
111
|
+
let chunk_start = 0;
|
|
112
|
+
/** @type {number} */
|
|
113
|
+
let chunk_index;
|
|
114
|
+
for (chunk_index = 0;; chunk_index++) {
|
|
115
|
+
const chunk = await get_chunk(chunk_index);
|
|
116
|
+
if (!chunk) return null;
|
|
117
|
+
const chunk_end = chunk_start + chunk.byteLength;
|
|
118
|
+
if (offset >= chunk_start && offset < chunk_end) {
|
|
119
|
+
start_chunk = chunk;
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
chunk_start = chunk_end;
|
|
123
|
+
}
|
|
124
|
+
if (offset + length <= chunk_start + start_chunk.byteLength) return start_chunk.subarray(offset - chunk_start, offset + length - chunk_start);
|
|
125
|
+
const chunks = [start_chunk.subarray(offset - chunk_start)];
|
|
126
|
+
let cursor = start_chunk.byteLength - offset + chunk_start;
|
|
127
|
+
while (cursor < length) {
|
|
128
|
+
chunk_index++;
|
|
129
|
+
let chunk = await get_chunk(chunk_index);
|
|
130
|
+
if (!chunk) return null;
|
|
131
|
+
if (chunk.byteLength > length - cursor) chunk = chunk.subarray(0, length - cursor);
|
|
132
|
+
chunks.push(chunk);
|
|
133
|
+
cursor += chunk.byteLength;
|
|
134
|
+
}
|
|
135
|
+
const buffer = new Uint8Array(length);
|
|
136
|
+
cursor = 0;
|
|
137
|
+
for (const chunk of chunks) {
|
|
138
|
+
buffer.set(chunk, cursor);
|
|
139
|
+
cursor += chunk.byteLength;
|
|
140
|
+
}
|
|
141
|
+
return buffer;
|
|
142
|
+
}
|
|
143
|
+
const header = await get_buffer(0, HEADER_BYTES);
|
|
144
|
+
if (!header) throw deserialize_error("too short");
|
|
145
|
+
if (header[0] !== BINARY_FORM_VERSION) throw deserialize_error(`got version ${header[0]}, expected version ${BINARY_FORM_VERSION}`);
|
|
146
|
+
const header_view = new DataView(header.buffer, header.byteOffset, header.byteLength);
|
|
147
|
+
const data_length = header_view.getUint32(1, true);
|
|
148
|
+
const file_offsets_length = header_view.getUint16(5, true);
|
|
149
|
+
const data_buffer = await get_buffer(HEADER_BYTES, data_length);
|
|
150
|
+
if (!data_buffer) throw deserialize_error("data too short");
|
|
151
|
+
/** @type {Array<number | undefined>} */
|
|
152
|
+
let file_offsets;
|
|
153
|
+
/** @type {number} */
|
|
154
|
+
let files_start_offset;
|
|
155
|
+
if (file_offsets_length > 0) {
|
|
156
|
+
const file_offsets_buffer = await get_buffer(HEADER_BYTES + data_length, file_offsets_length);
|
|
157
|
+
if (!file_offsets_buffer) throw deserialize_error("file offset table too short");
|
|
158
|
+
const parsed_offsets = JSON.parse(decoder.decode(file_offsets_buffer));
|
|
159
|
+
if (!Array.isArray(parsed_offsets) || parsed_offsets.some((n) => typeof n !== "number" || !Number.isInteger(n) || n < 0)) throw deserialize_error("invalid file offset table");
|
|
160
|
+
file_offsets = parsed_offsets;
|
|
161
|
+
files_start_offset = HEADER_BYTES + data_length + file_offsets_length;
|
|
162
|
+
}
|
|
163
|
+
/** @type {Array<{ offset: number, size: number }>} */
|
|
164
|
+
const file_spans = [];
|
|
165
|
+
const [data, meta] = parse(decoder.decode(data_buffer), { File: ([name, type, size, last_modified, index]) => {
|
|
166
|
+
if (typeof name !== "string" || typeof type !== "string" || typeof size !== "number" || typeof last_modified !== "number" || typeof index !== "number") throw deserialize_error("invalid file metadata");
|
|
167
|
+
let offset = file_offsets[index];
|
|
168
|
+
if (offset === void 0) throw deserialize_error("duplicate file offset table index");
|
|
169
|
+
file_offsets[index] = void 0;
|
|
170
|
+
offset += files_start_offset;
|
|
171
|
+
file_spans.push({
|
|
172
|
+
offset,
|
|
173
|
+
size
|
|
174
|
+
});
|
|
175
|
+
return new Proxy(new LazyFile(name, type, size, last_modified, get_chunk, offset), { getPrototypeOf() {
|
|
176
|
+
return File.prototype;
|
|
177
|
+
} });
|
|
178
|
+
} });
|
|
179
|
+
file_spans.sort((a, b) => a.offset - b.offset || a.size - b.size);
|
|
180
|
+
for (let i = 1; i < file_spans.length; i++) {
|
|
181
|
+
const previous = file_spans[i - 1];
|
|
182
|
+
const current = file_spans[i];
|
|
183
|
+
const previous_end = previous.offset + previous.size;
|
|
184
|
+
if (previous_end < current.offset) throw deserialize_error("gaps in file data");
|
|
185
|
+
if (previous_end > current.offset) throw deserialize_error("overlapping file data");
|
|
186
|
+
}
|
|
187
|
+
(async () => {
|
|
188
|
+
let has_more = true;
|
|
189
|
+
while (has_more) has_more = !!await get_chunk(chunks.length);
|
|
190
|
+
})();
|
|
191
|
+
return {
|
|
192
|
+
data,
|
|
193
|
+
meta,
|
|
194
|
+
form_data: null
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* @param {string} message
|
|
199
|
+
*/
|
|
200
|
+
function deserialize_error(message) {
|
|
201
|
+
return new SvelteKitError(400, "Bad Request", `Could not deserialize binary form: ${message}`);
|
|
202
|
+
}
|
|
203
|
+
/** @implements {File} */
|
|
204
|
+
var LazyFile = class LazyFile {
|
|
205
|
+
/** @type {(index: number) => Promise<Uint8Array<ArrayBuffer> | undefined>} */
|
|
206
|
+
#get_chunk;
|
|
207
|
+
/** @type {number} */
|
|
208
|
+
#offset;
|
|
209
|
+
/**
|
|
210
|
+
* @param {string} name
|
|
211
|
+
* @param {string} type
|
|
212
|
+
* @param {number} size
|
|
213
|
+
* @param {number} last_modified
|
|
214
|
+
* @param {(index: number) => Promise<Uint8Array<ArrayBuffer> | undefined>} get_chunk
|
|
215
|
+
* @param {number} offset
|
|
216
|
+
*/
|
|
217
|
+
constructor(name, type, size, last_modified, get_chunk, offset) {
|
|
218
|
+
this.name = name;
|
|
219
|
+
this.type = type;
|
|
220
|
+
this.size = size;
|
|
221
|
+
this.lastModified = last_modified;
|
|
222
|
+
this.webkitRelativePath = "";
|
|
223
|
+
this.#get_chunk = get_chunk;
|
|
224
|
+
this.#offset = offset;
|
|
225
|
+
this.arrayBuffer = this.arrayBuffer.bind(this);
|
|
226
|
+
this.bytes = this.bytes.bind(this);
|
|
227
|
+
this.slice = this.slice.bind(this);
|
|
228
|
+
this.stream = this.stream.bind(this);
|
|
229
|
+
this.text = this.text.bind(this);
|
|
230
|
+
}
|
|
231
|
+
/** @type {ArrayBuffer | undefined} */
|
|
232
|
+
#buffer;
|
|
233
|
+
async arrayBuffer() {
|
|
234
|
+
this.#buffer ??= await new Response(this.stream()).arrayBuffer();
|
|
235
|
+
return this.#buffer;
|
|
236
|
+
}
|
|
237
|
+
async bytes() {
|
|
238
|
+
return new Uint8Array(await this.arrayBuffer());
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* @param {number=} start
|
|
242
|
+
* @param {number=} end
|
|
243
|
+
* @param {string=} contentType
|
|
244
|
+
*/
|
|
245
|
+
slice(start = 0, end = this.size, contentType = this.type) {
|
|
246
|
+
if (start < 0) start = Math.max(this.size + start, 0);
|
|
247
|
+
else start = Math.min(start, this.size);
|
|
248
|
+
if (end < 0) end = Math.max(this.size + end, 0);
|
|
249
|
+
else end = Math.min(end, this.size);
|
|
250
|
+
const size = Math.max(end - start, 0);
|
|
251
|
+
return new LazyFile(this.name, contentType, size, this.lastModified, this.#get_chunk, this.#offset + start);
|
|
252
|
+
}
|
|
253
|
+
stream() {
|
|
254
|
+
let cursor = 0;
|
|
255
|
+
let chunk_index = 0;
|
|
256
|
+
return new ReadableStream({
|
|
257
|
+
start: async (controller) => {
|
|
258
|
+
let chunk_start = 0;
|
|
259
|
+
/** @type {Uint8Array} */
|
|
260
|
+
let start_chunk;
|
|
261
|
+
for (chunk_index = 0;; chunk_index++) {
|
|
262
|
+
const chunk = await this.#get_chunk(chunk_index);
|
|
263
|
+
if (!chunk) return null;
|
|
264
|
+
const chunk_end = chunk_start + chunk.byteLength;
|
|
265
|
+
if (this.#offset >= chunk_start && this.#offset < chunk_end) {
|
|
266
|
+
start_chunk = chunk;
|
|
267
|
+
break;
|
|
268
|
+
}
|
|
269
|
+
chunk_start = chunk_end;
|
|
270
|
+
}
|
|
271
|
+
if (this.#offset + this.size <= chunk_start + start_chunk.byteLength) {
|
|
272
|
+
controller.enqueue(start_chunk.subarray(this.#offset - chunk_start, this.#offset + this.size - chunk_start));
|
|
273
|
+
controller.close();
|
|
274
|
+
} else {
|
|
275
|
+
controller.enqueue(start_chunk.subarray(this.#offset - chunk_start));
|
|
276
|
+
cursor = start_chunk.byteLength - this.#offset + chunk_start;
|
|
277
|
+
}
|
|
278
|
+
},
|
|
279
|
+
pull: async (controller) => {
|
|
280
|
+
chunk_index++;
|
|
281
|
+
let chunk = await this.#get_chunk(chunk_index);
|
|
282
|
+
if (!chunk) {
|
|
283
|
+
controller.error("incomplete file data");
|
|
284
|
+
controller.close();
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
if (chunk.byteLength > this.size - cursor) chunk = chunk.subarray(0, this.size - cursor);
|
|
288
|
+
controller.enqueue(chunk);
|
|
289
|
+
cursor += chunk.byteLength;
|
|
290
|
+
if (cursor >= this.size) controller.close();
|
|
291
|
+
}
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
async text() {
|
|
295
|
+
return decoder.decode(await this.arrayBuffer());
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
var path_regex = /^[a-zA-Z_$]\w*(\.[a-zA-Z_$]\w*|\[\d+\])*$/;
|
|
299
|
+
/**
|
|
300
|
+
* @param {string} path
|
|
301
|
+
*/
|
|
302
|
+
function split_path(path) {
|
|
303
|
+
if (!path_regex.test(path)) throw new Error(`Invalid path ${path}`);
|
|
304
|
+
return path.split(/\.|\[|\]/).filter(Boolean);
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Check if a property key is dangerous and could lead to prototype pollution
|
|
308
|
+
* @param {string} key
|
|
309
|
+
*/
|
|
310
|
+
function check_prototype_pollution(key) {
|
|
311
|
+
if (key === "__proto__" || key === "constructor" || key === "prototype") throw new Error(`Invalid key "${key}"`);
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Sets a value in a nested object using an array of keys, mutating the original object.
|
|
315
|
+
* @param {Record<string, any>} object
|
|
316
|
+
* @param {string[]} keys
|
|
317
|
+
* @param {any} value
|
|
318
|
+
*/
|
|
319
|
+
function deep_set(object, keys, value) {
|
|
320
|
+
let current = object;
|
|
321
|
+
for (let i = 0; i < keys.length - 1; i += 1) {
|
|
322
|
+
const key = keys[i];
|
|
323
|
+
check_prototype_pollution(key);
|
|
324
|
+
const is_array = /^\d+$/.test(keys[i + 1]);
|
|
325
|
+
const inner = Object.hasOwn(current, key) ? current[key] : void 0;
|
|
326
|
+
const exists = inner != null;
|
|
327
|
+
if (exists && is_array !== Array.isArray(inner)) throw new Error(`Invalid array key ${keys[i + 1]}`);
|
|
328
|
+
if (!exists) current[key] = is_array ? [] : {};
|
|
329
|
+
current = current[key];
|
|
330
|
+
}
|
|
331
|
+
const final_key = keys[keys.length - 1];
|
|
332
|
+
check_prototype_pollution(final_key);
|
|
333
|
+
current[final_key] = value;
|
|
334
|
+
}
|
|
335
|
+
//#endregion
|
|
336
|
+
//#region ../../node_modules/.bun/@sveltejs+kit@2.61.0+aeb06e9cf8e23ab6/node_modules/@sveltejs/kit/src/utils/http.js
|
|
337
|
+
/**
|
|
338
|
+
* Given an Accept header and a list of possible content types, pick
|
|
339
|
+
* the most suitable one to respond with
|
|
340
|
+
* @param {string} accept
|
|
341
|
+
* @param {string[]} types
|
|
342
|
+
*/
|
|
343
|
+
function negotiate(accept, types) {
|
|
344
|
+
/** @type {Array<{ type: string, subtype: string, q: number, i: number }>} */
|
|
345
|
+
const parts = [];
|
|
346
|
+
accept.split(",").forEach((str, i) => {
|
|
347
|
+
const match = /([^/ \t]+)\/([^; \t]+)[ \t]*(?:;[ \t]*q=([0-9.]+))?/.exec(str);
|
|
348
|
+
if (match) {
|
|
349
|
+
const [, type, subtype, q = "1"] = match;
|
|
350
|
+
parts.push({
|
|
351
|
+
type,
|
|
352
|
+
subtype,
|
|
353
|
+
q: +q,
|
|
354
|
+
i
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
});
|
|
358
|
+
parts.sort((a, b) => {
|
|
359
|
+
if (a.q !== b.q) return b.q - a.q;
|
|
360
|
+
if (a.subtype === "*" !== (b.subtype === "*")) return a.subtype === "*" ? 1 : -1;
|
|
361
|
+
if (a.type === "*" !== (b.type === "*")) return a.type === "*" ? 1 : -1;
|
|
362
|
+
return a.i - b.i;
|
|
363
|
+
});
|
|
364
|
+
let accepted;
|
|
365
|
+
let min_priority = Infinity;
|
|
366
|
+
for (const mimetype of types) {
|
|
367
|
+
const [type, subtype] = mimetype.split("/");
|
|
368
|
+
const priority = parts.findIndex((part) => (part.type === type || part.type === "*") && (part.subtype === subtype || part.subtype === "*"));
|
|
369
|
+
if (priority !== -1 && priority < min_priority) {
|
|
370
|
+
accepted = mimetype;
|
|
371
|
+
min_priority = priority;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
return accepted;
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* Returns `true` if the request contains a `content-type` header with the given type
|
|
378
|
+
* @param {Request} request
|
|
379
|
+
* @param {...string} types
|
|
380
|
+
*/
|
|
381
|
+
function is_content_type(request, ...types) {
|
|
382
|
+
const type = request.headers.get("content-type")?.split(";", 1)[0].trim() ?? "";
|
|
383
|
+
return types.includes(type.toLowerCase());
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* @param {Request} request
|
|
387
|
+
*/
|
|
388
|
+
function is_form_content_type(request) {
|
|
389
|
+
return is_content_type(request, "application/x-www-form-urlencoded", "multipart/form-data", "text/plain", BINARY_FORM_CONTENT_TYPE);
|
|
390
|
+
}
|
|
391
|
+
//#endregion
|
|
392
|
+
//#region ../../node_modules/.bun/@sveltejs+kit@2.61.0+aeb06e9cf8e23ab6/node_modules/@sveltejs/kit/src/utils/misc.js
|
|
393
|
+
var s = JSON.stringify;
|
|
394
|
+
//#endregion
|
|
395
|
+
//#region ../../node_modules/.bun/@sveltejs+kit@2.61.0+aeb06e9cf8e23ab6/node_modules/@sveltejs/kit/src/utils/escape.js
|
|
396
|
+
/**
|
|
397
|
+
* When inside a double-quoted attribute value, only `&` and `"` hold special meaning.
|
|
398
|
+
* @see https://html.spec.whatwg.org/multipage/parsing.html#attribute-value-(double-quoted)-state
|
|
399
|
+
* @type {Record<string, string>}
|
|
400
|
+
*/
|
|
401
|
+
var escape_html_attr_dict = {
|
|
402
|
+
"&": "&",
|
|
403
|
+
"\"": """
|
|
404
|
+
};
|
|
405
|
+
/**
|
|
406
|
+
* @type {Record<string, string>}
|
|
407
|
+
*/
|
|
408
|
+
var escape_html_dict = {
|
|
409
|
+
"&": "&",
|
|
410
|
+
"<": "<"
|
|
411
|
+
};
|
|
412
|
+
var escape_html_attr_regex = new RegExp(`[${Object.keys(escape_html_attr_dict).join("")}]|[\\ud800-\\udbff](?![\\udc00-\\udfff])|[\\ud800-\\udbff][\\udc00-\\udfff]|[\\udc00-\\udfff]`, "g");
|
|
413
|
+
var escape_html_regex = new RegExp(`[${Object.keys(escape_html_dict).join("")}]|[\\ud800-\\udbff](?![\\udc00-\\udfff])|[\\ud800-\\udbff][\\udc00-\\udfff]|[\\udc00-\\udfff]`, "g");
|
|
414
|
+
/**
|
|
415
|
+
* Escapes unpaired surrogates (which are allowed in js strings but invalid in HTML) and
|
|
416
|
+
* escapes characters that are special.
|
|
417
|
+
*
|
|
418
|
+
* @param {string} str
|
|
419
|
+
* @param {boolean} [is_attr]
|
|
420
|
+
* @returns {string} escaped string
|
|
421
|
+
* @example const html = `<tag data-value="${escape_html('value', true)}">...</tag>`;
|
|
422
|
+
*/
|
|
423
|
+
function escape_html(str, is_attr) {
|
|
424
|
+
const dict = is_attr ? escape_html_attr_dict : escape_html_dict;
|
|
425
|
+
return str.replace(is_attr ? escape_html_attr_regex : escape_html_regex, (match) => {
|
|
426
|
+
if (match.length === 2) return match;
|
|
427
|
+
return dict[match] ?? `&#${match.charCodeAt(0)};`;
|
|
428
|
+
});
|
|
429
|
+
}
|
|
430
|
+
//#endregion
|
|
431
|
+
//#region ../../node_modules/.bun/@sveltejs+kit@2.61.0+aeb06e9cf8e23ab6/node_modules/@sveltejs/kit/src/runtime/server/utils.js
|
|
432
|
+
/** @import { ServerHooks } from 'types' */
|
|
433
|
+
/**
|
|
434
|
+
* @param {Partial<Record<import('types').HttpMethod, any>>} mod
|
|
435
|
+
* @param {import('types').HttpMethod} method
|
|
436
|
+
*/
|
|
437
|
+
function method_not_allowed(mod, method) {
|
|
438
|
+
return text(`${method} method not allowed`, {
|
|
439
|
+
status: 405,
|
|
440
|
+
headers: { allow: allowed_methods(mod).join(", ") }
|
|
441
|
+
});
|
|
442
|
+
}
|
|
443
|
+
/** @param {Partial<Record<import('types').HttpMethod, any>>} mod */
|
|
444
|
+
function allowed_methods(mod) {
|
|
445
|
+
const allowed = ENDPOINT_METHODS.filter((method) => method in mod);
|
|
446
|
+
if ("GET" in mod && !("HEAD" in mod)) allowed.push("HEAD");
|
|
447
|
+
return allowed;
|
|
448
|
+
}
|
|
449
|
+
/**
|
|
450
|
+
* @param {import('types').SSROptions} options
|
|
451
|
+
*/
|
|
452
|
+
function get_global_name(options) {
|
|
453
|
+
return `__sveltekit_${options.version_hash}`;
|
|
454
|
+
}
|
|
455
|
+
/**
|
|
456
|
+
* Return as a response that renders the error.html
|
|
457
|
+
*
|
|
458
|
+
* @param {import('types').SSROptions} options
|
|
459
|
+
* @param {number} status
|
|
460
|
+
* @param {string} message
|
|
461
|
+
*/
|
|
462
|
+
function static_error_page(options, status, message) {
|
|
463
|
+
return text(options.templates.error({
|
|
464
|
+
status,
|
|
465
|
+
message: escape_html(message)
|
|
466
|
+
}), {
|
|
467
|
+
headers: { "content-type": "text/html; charset=utf-8" },
|
|
468
|
+
status
|
|
469
|
+
});
|
|
470
|
+
}
|
|
471
|
+
/**
|
|
472
|
+
* @param {import('@sveltejs/kit').RequestEvent} event
|
|
473
|
+
* @param {import('types').RequestState} state
|
|
474
|
+
* @param {import('types').SSROptions} options
|
|
475
|
+
* @param {unknown} error
|
|
476
|
+
*/
|
|
477
|
+
async function handle_fatal_error(event, state, options, error) {
|
|
478
|
+
error = error instanceof HttpError ? error : coalesce_to_error(error);
|
|
479
|
+
const status = get_status(error);
|
|
480
|
+
const body = await handle_error_and_jsonify(event, state, options, error);
|
|
481
|
+
const type = negotiate(event.request.headers.get("accept") || "text/html", ["application/json", "text/html"]);
|
|
482
|
+
if (event.isDataRequest || type === "application/json") return json(body, { status });
|
|
483
|
+
return static_error_page(options, status, body.message);
|
|
484
|
+
}
|
|
485
|
+
/**
|
|
486
|
+
* @param {import('@sveltejs/kit').RequestEvent} event
|
|
487
|
+
* @param {import('types').RequestState} state
|
|
488
|
+
* @param {import('types').SSROptions} options
|
|
489
|
+
* @param {any} error
|
|
490
|
+
* @returns {Promise<App.Error>}
|
|
491
|
+
*/
|
|
492
|
+
async function handle_error_and_jsonify(event, state, options, error) {
|
|
493
|
+
if (error instanceof HttpError) return {
|
|
494
|
+
message: "Unknown Error",
|
|
495
|
+
...error.body
|
|
496
|
+
};
|
|
497
|
+
const status = get_status(error);
|
|
498
|
+
const message = get_message(error);
|
|
499
|
+
return await with_request_store({
|
|
500
|
+
event,
|
|
501
|
+
state
|
|
502
|
+
}, () => options.hooks.handleError({
|
|
503
|
+
error,
|
|
504
|
+
event,
|
|
505
|
+
status,
|
|
506
|
+
message
|
|
507
|
+
})) ?? { message };
|
|
508
|
+
}
|
|
509
|
+
/**
|
|
510
|
+
* @param {number} status
|
|
511
|
+
* @param {string} location
|
|
512
|
+
*/
|
|
513
|
+
function redirect_response(status, location) {
|
|
514
|
+
return new Response(void 0, {
|
|
515
|
+
status,
|
|
516
|
+
headers: { location }
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
/**
|
|
520
|
+
* @param {import('@sveltejs/kit').RequestEvent} event
|
|
521
|
+
* @param {Error & { path: string }} error
|
|
522
|
+
*/
|
|
523
|
+
function clarify_devalue_error(event, error) {
|
|
524
|
+
if (error.path) return `Data returned from \`load\` while rendering ${event.route.id} is not serializable: ${error.message} (${error.path}). If you need to serialize/deserialize custom types, use transport hooks: https://svelte.dev/docs/kit/hooks#Universal-hooks-transport.`;
|
|
525
|
+
if (error.path === "") return `Data returned from \`load\` while rendering ${event.route.id} is not a plain object`;
|
|
526
|
+
return error.message;
|
|
527
|
+
}
|
|
528
|
+
/**
|
|
529
|
+
* @param {import('types').ServerDataNode} node
|
|
530
|
+
*/
|
|
531
|
+
function serialize_uses(node) {
|
|
532
|
+
const uses = {};
|
|
533
|
+
if (node.uses && node.uses.dependencies.size > 0) uses.dependencies = Array.from(node.uses.dependencies);
|
|
534
|
+
if (node.uses && node.uses.search_params.size > 0) uses.search_params = Array.from(node.uses.search_params);
|
|
535
|
+
if (node.uses && node.uses.params.size > 0) uses.params = Array.from(node.uses.params);
|
|
536
|
+
if (node.uses?.parent) uses.parent = 1;
|
|
537
|
+
if (node.uses?.route) uses.route = 1;
|
|
538
|
+
if (node.uses?.url) uses.url = 1;
|
|
539
|
+
return uses;
|
|
540
|
+
}
|
|
541
|
+
/**
|
|
542
|
+
* Returns `true` if the given path was prerendered
|
|
543
|
+
* @param {import('@sveltejs/kit').SSRManifest} manifest
|
|
544
|
+
* @param {string} pathname Should include the base and be decoded
|
|
545
|
+
*/
|
|
546
|
+
function has_prerendered_path(manifest, pathname) {
|
|
547
|
+
return manifest._.prerendered_routes.has(pathname) || pathname.at(-1) === "/" && manifest._.prerendered_routes.has(pathname.slice(0, -1));
|
|
548
|
+
}
|
|
549
|
+
/**
|
|
550
|
+
* Formats the error into a nice message with sanitized stack trace
|
|
551
|
+
* @param {number} status
|
|
552
|
+
* @param {Error} error
|
|
553
|
+
* @param {import('@sveltejs/kit').RequestEvent} event
|
|
554
|
+
*/
|
|
555
|
+
function format_server_error(status, error, event) {
|
|
556
|
+
const formatted_text = `\n\x1b[1;31m[${status}] ${event.request.method} ${event.url.pathname}\x1b[0m`;
|
|
557
|
+
if (status === 404) return formatted_text;
|
|
558
|
+
return `${formatted_text}\n${error.stack}`;
|
|
559
|
+
}
|
|
560
|
+
/**
|
|
561
|
+
* Returns the filename without the extension. e.g., `+page.server`, `+page`, etc.
|
|
562
|
+
* @param {string | undefined} node_id
|
|
563
|
+
* @returns {string}
|
|
564
|
+
*/
|
|
565
|
+
function get_node_type(node_id) {
|
|
566
|
+
const filename = (node_id?.split("/"))?.at(-1);
|
|
567
|
+
if (!filename) return "unknown";
|
|
568
|
+
return filename.split(".").slice(0, -1).join(".");
|
|
569
|
+
}
|
|
570
|
+
/**
|
|
571
|
+
* Creates a serialiser for non-arbitrary POJOs using the app's transport hook
|
|
572
|
+
* @param {ServerHooks['transport']} transport
|
|
573
|
+
* @returns {(thing: unknown) => string | undefined}
|
|
574
|
+
*/
|
|
575
|
+
function create_replacer(transport) {
|
|
576
|
+
/** @param {unknown} thing */
|
|
577
|
+
const replacer = (thing) => {
|
|
578
|
+
for (const key in transport) {
|
|
579
|
+
const encoded = transport[key].encode(thing);
|
|
580
|
+
if (encoded) return `app.decode('${key}', ${uneval(encoded, replacer)})`;
|
|
581
|
+
}
|
|
582
|
+
};
|
|
583
|
+
return replacer;
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
//#region ../../node_modules/.bun/@sveltejs+kit@2.61.0+aeb06e9cf8e23ab6/node_modules/@sveltejs/kit/src/utils/promise.js
|
|
587
|
+
/** @see https://github.com/microsoft/TypeScript/blob/904e7dd97dc8da1352c8e05d70829dff17c73214/src/lib/es2024.promise.d.ts */
|
|
588
|
+
/**
|
|
589
|
+
* @template T
|
|
590
|
+
* @typedef {{
|
|
591
|
+
* promise: Promise<T>;
|
|
592
|
+
* resolve: (value: T | PromiseLike<T>) => void;
|
|
593
|
+
* reject: (reason?: any) => void;
|
|
594
|
+
* }} PromiseWithResolvers<T>
|
|
595
|
+
*/
|
|
596
|
+
/**
|
|
597
|
+
* TODO: Whenever Node >21 is minimum supported version, we can use `Promise.withResolvers` to avoid this ceremony
|
|
598
|
+
*
|
|
599
|
+
* @template T
|
|
600
|
+
* @returns {PromiseWithResolvers<T>}
|
|
601
|
+
*/
|
|
602
|
+
function with_resolvers() {
|
|
603
|
+
let resolve;
|
|
604
|
+
let reject;
|
|
605
|
+
return {
|
|
606
|
+
promise: new Promise((res, rej) => {
|
|
607
|
+
resolve = res;
|
|
608
|
+
reject = rej;
|
|
609
|
+
}),
|
|
610
|
+
resolve,
|
|
611
|
+
reject
|
|
612
|
+
};
|
|
613
|
+
}
|
|
614
|
+
//#endregion
|
|
615
|
+
//#region ../../node_modules/.bun/@sveltejs+kit@2.61.0+aeb06e9cf8e23ab6/node_modules/@sveltejs/kit/src/runtime/server/endpoint.js
|
|
616
|
+
/**
|
|
617
|
+
* @param {import('@sveltejs/kit').RequestEvent} event
|
|
618
|
+
* @param {import('types').RequestState} event_state
|
|
619
|
+
* @param {import('types').SSREndpoint} mod
|
|
620
|
+
* @param {import('types').SSRState} state
|
|
621
|
+
* @returns {Promise<Response>}
|
|
622
|
+
*/
|
|
623
|
+
async function render_endpoint(event, event_state, mod, state) {
|
|
624
|
+
const method = event.request.method;
|
|
625
|
+
let handler = mod[method] || mod.fallback;
|
|
626
|
+
if (method === "HEAD" && !mod.HEAD && mod.GET) handler = mod.GET;
|
|
627
|
+
if (!handler) return method_not_allowed(mod, method);
|
|
628
|
+
const prerender = mod.prerender ?? state.prerender_default;
|
|
629
|
+
if (prerender && (mod.POST || mod.PATCH || mod.PUT || mod.DELETE)) throw new Error("Cannot prerender endpoints that have mutative methods");
|
|
630
|
+
if (state.prerendering && !state.prerendering.inside_reroute && !prerender) if (state.depth > 0) throw new Error(`${event.route.id} is not prerenderable`);
|
|
631
|
+
else return new Response(void 0, { status: 204 });
|
|
632
|
+
try {
|
|
633
|
+
const response = await with_request_store({
|
|
634
|
+
event,
|
|
635
|
+
state: event_state
|
|
636
|
+
}, () => handler(event));
|
|
637
|
+
if (!(response instanceof Response)) throw new Error(`Invalid response from route ${event.url.pathname}: handler should return a Response object`);
|
|
638
|
+
if (state.prerendering && (!state.prerendering.inside_reroute || prerender)) {
|
|
639
|
+
const cloned = new Response(response.clone().body, {
|
|
640
|
+
status: response.status,
|
|
641
|
+
statusText: response.statusText,
|
|
642
|
+
headers: new Headers(response.headers)
|
|
643
|
+
});
|
|
644
|
+
cloned.headers.set("x-sveltekit-prerender", String(prerender));
|
|
645
|
+
if (state.prerendering.inside_reroute && prerender) {
|
|
646
|
+
cloned.headers.set("x-sveltekit-routeid", encodeURI(event.route.id));
|
|
647
|
+
state.prerendering.dependencies.set(event.url.pathname, {
|
|
648
|
+
response: cloned,
|
|
649
|
+
body: null
|
|
650
|
+
});
|
|
651
|
+
} else return cloned;
|
|
652
|
+
}
|
|
653
|
+
return response;
|
|
654
|
+
} catch (e) {
|
|
655
|
+
if (e instanceof Redirect) return new Response(void 0, {
|
|
656
|
+
status: e.status,
|
|
657
|
+
headers: { location: e.location }
|
|
658
|
+
});
|
|
659
|
+
throw e;
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
/**
|
|
663
|
+
* @param {import('@sveltejs/kit').RequestEvent} event
|
|
664
|
+
*/
|
|
665
|
+
function is_endpoint_request(event) {
|
|
666
|
+
const { method, headers } = event.request;
|
|
667
|
+
if (ENDPOINT_METHODS.includes(method) && !PAGE_METHODS.includes(method)) return true;
|
|
668
|
+
if (method === "POST" && headers.get("x-sveltekit-action") === "true") return false;
|
|
669
|
+
return negotiate(event.request.headers.get("accept") ?? "*/*", ["*", "text/html"]) !== "text/html";
|
|
670
|
+
}
|
|
671
|
+
//#endregion
|
|
672
|
+
//#region ../../node_modules/.bun/@sveltejs+kit@2.61.0+aeb06e9cf8e23ab6/node_modules/@sveltejs/kit/src/runtime/telemetry/record_span.js
|
|
673
|
+
/** @import { RecordSpan } from 'types' */
|
|
674
|
+
/** @type {RecordSpan} */
|
|
675
|
+
async function record_span({ name, attributes, fn }) {
|
|
676
|
+
return fn(noop_span);
|
|
677
|
+
}
|
|
678
|
+
//#endregion
|
|
679
|
+
//#region ../../node_modules/.bun/@sveltejs+kit@2.61.0+aeb06e9cf8e23ab6/node_modules/@sveltejs/kit/src/runtime/server/page/actions.js
|
|
680
|
+
/** @import { RequestEvent, ActionResult, Actions } from '@sveltejs/kit' */
|
|
681
|
+
/** @import { SSROptions, SSRNode, ServerNode, ServerHooks } from 'types' */
|
|
682
|
+
/** @param {RequestEvent} event */
|
|
683
|
+
function is_action_json_request(event) {
|
|
684
|
+
return negotiate(event.request.headers.get("accept") ?? "*/*", ["application/json", "text/html"]) === "application/json" && event.request.method === "POST";
|
|
685
|
+
}
|
|
686
|
+
/**
|
|
687
|
+
* @param {RequestEvent} event
|
|
688
|
+
* @param {import('types').RequestState} event_state
|
|
689
|
+
* @param {SSROptions} options
|
|
690
|
+
* @param {SSRNode['server'] | undefined} server
|
|
691
|
+
*/
|
|
692
|
+
async function handle_action_json_request(event, event_state, options, server) {
|
|
693
|
+
const actions = server?.actions;
|
|
694
|
+
if (!actions) {
|
|
695
|
+
const no_actions_error = new SvelteKitError(405, "Method Not Allowed", `POST method not allowed. No form actions exist for this page`);
|
|
696
|
+
return action_json({
|
|
697
|
+
type: "error",
|
|
698
|
+
error: await handle_error_and_jsonify(event, event_state, options, no_actions_error)
|
|
699
|
+
}, {
|
|
700
|
+
status: no_actions_error.status,
|
|
701
|
+
headers: { allow: "GET" }
|
|
702
|
+
});
|
|
703
|
+
}
|
|
704
|
+
check_named_default_separate(actions);
|
|
705
|
+
try {
|
|
706
|
+
const data = await call_action(event, event_state, actions);
|
|
707
|
+
if (data instanceof ActionFailure) return action_json({
|
|
708
|
+
type: "failure",
|
|
709
|
+
status: data.status,
|
|
710
|
+
data: stringify_action_response(data.data, event.route.id, options.hooks.transport)
|
|
711
|
+
});
|
|
712
|
+
else return action_json({
|
|
713
|
+
type: "success",
|
|
714
|
+
status: data ? 200 : 204,
|
|
715
|
+
data: stringify_action_response(data, event.route.id, options.hooks.transport)
|
|
716
|
+
});
|
|
717
|
+
} catch (e) {
|
|
718
|
+
const err = normalize_error(e);
|
|
719
|
+
if (err instanceof Redirect) return action_json_redirect(err);
|
|
720
|
+
return action_json({
|
|
721
|
+
type: "error",
|
|
722
|
+
error: await handle_error_and_jsonify(event, event_state, options, check_incorrect_fail_use(err))
|
|
723
|
+
}, { status: get_status(err) });
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
/**
|
|
727
|
+
* @param {HttpError | Error} error
|
|
728
|
+
*/
|
|
729
|
+
function check_incorrect_fail_use(error) {
|
|
730
|
+
return error instanceof ActionFailure ? /* @__PURE__ */ new Error("Cannot \"throw fail()\". Use \"return fail()\"") : error;
|
|
731
|
+
}
|
|
732
|
+
/**
|
|
733
|
+
* @param {Redirect} redirect
|
|
734
|
+
*/
|
|
735
|
+
function action_json_redirect(redirect) {
|
|
736
|
+
return action_json({
|
|
737
|
+
type: "redirect",
|
|
738
|
+
status: redirect.status,
|
|
739
|
+
location: redirect.location
|
|
740
|
+
});
|
|
741
|
+
}
|
|
742
|
+
/**
|
|
743
|
+
* @param {ActionResult} data
|
|
744
|
+
* @param {ResponseInit} [init]
|
|
745
|
+
*/
|
|
746
|
+
function action_json(data, init) {
|
|
747
|
+
return json(data, init);
|
|
748
|
+
}
|
|
749
|
+
/**
|
|
750
|
+
* @param {RequestEvent} event
|
|
751
|
+
*/
|
|
752
|
+
function is_action_request(event) {
|
|
753
|
+
return event.request.method === "POST";
|
|
754
|
+
}
|
|
755
|
+
/**
|
|
756
|
+
* @param {RequestEvent} event
|
|
757
|
+
* @param {import('types').RequestState} event_state
|
|
758
|
+
* @param {SSRNode['server'] | undefined} server
|
|
759
|
+
* @returns {Promise<ActionResult>}
|
|
760
|
+
*/
|
|
761
|
+
async function handle_action_request(event, event_state, server) {
|
|
762
|
+
const actions = server?.actions;
|
|
763
|
+
if (!actions) {
|
|
764
|
+
event.setHeaders({ allow: "GET" });
|
|
765
|
+
return {
|
|
766
|
+
type: "error",
|
|
767
|
+
error: new SvelteKitError(405, "Method Not Allowed", `POST method not allowed. No form actions exist for this page`)
|
|
768
|
+
};
|
|
769
|
+
}
|
|
770
|
+
check_named_default_separate(actions);
|
|
771
|
+
try {
|
|
772
|
+
const data = await call_action(event, event_state, actions);
|
|
773
|
+
if (data instanceof ActionFailure) return {
|
|
774
|
+
type: "failure",
|
|
775
|
+
status: data.status,
|
|
776
|
+
data: data.data
|
|
777
|
+
};
|
|
778
|
+
else return {
|
|
779
|
+
type: "success",
|
|
780
|
+
status: 200,
|
|
781
|
+
data
|
|
782
|
+
};
|
|
783
|
+
} catch (e) {
|
|
784
|
+
const err = normalize_error(e);
|
|
785
|
+
if (err instanceof Redirect) return {
|
|
786
|
+
type: "redirect",
|
|
787
|
+
status: err.status,
|
|
788
|
+
location: err.location
|
|
789
|
+
};
|
|
790
|
+
return {
|
|
791
|
+
type: "error",
|
|
792
|
+
error: check_incorrect_fail_use(err)
|
|
793
|
+
};
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
/**
|
|
797
|
+
* @param {Actions} actions
|
|
798
|
+
*/
|
|
799
|
+
function check_named_default_separate(actions) {
|
|
800
|
+
if (actions.default && Object.keys(actions).length > 1) throw new Error("When using named actions, the default action cannot be used. See the docs for more info: https://svelte.dev/docs/kit/form-actions#named-actions");
|
|
801
|
+
}
|
|
802
|
+
/**
|
|
803
|
+
* @param {RequestEvent} event
|
|
804
|
+
* @param {import('types').RequestState} event_state
|
|
805
|
+
* @param {NonNullable<ServerNode['actions']>} actions
|
|
806
|
+
* @throws {Redirect | HttpError | SvelteKitError | Error}
|
|
807
|
+
*/
|
|
808
|
+
async function call_action(event, event_state, actions) {
|
|
809
|
+
const url = new URL(event.request.url);
|
|
810
|
+
let name = "default";
|
|
811
|
+
for (const param of url.searchParams) if (param[0].startsWith("/")) {
|
|
812
|
+
name = param[0].slice(1);
|
|
813
|
+
if (name === "default") throw new Error("Cannot use reserved action name \"default\"");
|
|
814
|
+
break;
|
|
815
|
+
}
|
|
816
|
+
const action = actions[name];
|
|
817
|
+
if (!action) throw new SvelteKitError(404, "Not Found", `No action with name '${name}' found`);
|
|
818
|
+
if (!is_form_content_type(event.request)) throw new SvelteKitError(415, "Unsupported Media Type", `Form actions expect form-encoded data — received ${event.request.headers.get("content-type")}`);
|
|
819
|
+
return record_span({
|
|
820
|
+
name: "sveltekit.form_action",
|
|
821
|
+
attributes: {
|
|
822
|
+
"http.route": event.route.id || "unknown"
|
|
823
|
+
},
|
|
824
|
+
fn: async (current) => {
|
|
825
|
+
const traced_event = merge_tracing(event, current);
|
|
826
|
+
const result = await with_request_store({
|
|
827
|
+
event: traced_event,
|
|
828
|
+
state: event_state
|
|
829
|
+
}, () => action(traced_event));
|
|
830
|
+
if (result instanceof ActionFailure) current.setAttributes({
|
|
831
|
+
"sveltekit.form_action.result.type": "failure",
|
|
832
|
+
"sveltekit.form_action.result.status": result.status
|
|
833
|
+
});
|
|
834
|
+
return result;
|
|
835
|
+
}
|
|
836
|
+
});
|
|
837
|
+
}
|
|
838
|
+
/**
|
|
839
|
+
* Try to `devalue.uneval` the data object, and if it fails, return a proper Error with context
|
|
840
|
+
* @param {any} data
|
|
841
|
+
* @param {string} route_id
|
|
842
|
+
* @param {ServerHooks['transport']} transport
|
|
843
|
+
*/
|
|
844
|
+
function uneval_action_response(data, route_id, transport) {
|
|
845
|
+
const replacer = create_replacer(transport);
|
|
846
|
+
return try_serialize(data, (value) => uneval(value, replacer), route_id);
|
|
847
|
+
}
|
|
848
|
+
/**
|
|
849
|
+
* Try to `devalue.stringify` the data object, and if it fails, return a proper Error with context
|
|
850
|
+
* @param {any} data
|
|
851
|
+
* @param {string} route_id
|
|
852
|
+
* @param {ServerHooks['transport']} transport
|
|
853
|
+
*/
|
|
854
|
+
function stringify_action_response(data, route_id, transport) {
|
|
855
|
+
const encoders = Object.fromEntries(Object.entries(transport).map(([key, value]) => [key, value.encode]));
|
|
856
|
+
return try_serialize(data, (value) => stringify$1(value, encoders), route_id);
|
|
857
|
+
}
|
|
858
|
+
/**
|
|
859
|
+
* @param {any} data
|
|
860
|
+
* @param {(data: any) => string} fn
|
|
861
|
+
* @param {string} route_id
|
|
862
|
+
*/
|
|
863
|
+
function try_serialize(data, fn, route_id) {
|
|
864
|
+
try {
|
|
865
|
+
return fn(data);
|
|
866
|
+
} catch (e) {
|
|
867
|
+
const error = e;
|
|
868
|
+
if (data instanceof Response) throw new Error(`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" });`, { cause: e });
|
|
869
|
+
if ("path" in error) {
|
|
870
|
+
let message = `Data returned from action inside ${route_id} is not serializable: ${error.message}`;
|
|
871
|
+
if (error.path !== "") message += ` (data.${error.path})`;
|
|
872
|
+
throw new Error(message, { cause: e });
|
|
873
|
+
}
|
|
874
|
+
throw error;
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
//#endregion
|
|
878
|
+
//#region ../../node_modules/.bun/@sveltejs+kit@2.61.0+aeb06e9cf8e23ab6/node_modules/@sveltejs/kit/src/utils/streaming.js
|
|
879
|
+
/**
|
|
880
|
+
* Create an async iterator and a function to push values into it
|
|
881
|
+
* @template T
|
|
882
|
+
* @returns {{
|
|
883
|
+
* iterate: (transform?: (input: T) => T) => AsyncIterable<T>;
|
|
884
|
+
* add: (promise: Promise<T>) => void;
|
|
885
|
+
* }}
|
|
886
|
+
*/
|
|
887
|
+
function create_async_iterator() {
|
|
888
|
+
let resolved = -1;
|
|
889
|
+
let returned = -1;
|
|
890
|
+
/** @type {import('./promise.js').PromiseWithResolvers<T>[]} */
|
|
891
|
+
const deferred = [];
|
|
892
|
+
return {
|
|
893
|
+
iterate: (transform = (x) => x) => {
|
|
894
|
+
return { [Symbol.asyncIterator]() {
|
|
895
|
+
return { next: async () => {
|
|
896
|
+
const next = deferred[++returned];
|
|
897
|
+
if (!next) return {
|
|
898
|
+
value: null,
|
|
899
|
+
done: true
|
|
900
|
+
};
|
|
901
|
+
return {
|
|
902
|
+
value: transform(await next.promise),
|
|
903
|
+
done: false
|
|
904
|
+
};
|
|
905
|
+
} };
|
|
906
|
+
} };
|
|
907
|
+
},
|
|
908
|
+
add: (promise) => {
|
|
909
|
+
deferred.push(with_resolvers());
|
|
910
|
+
promise.then((value) => {
|
|
911
|
+
deferred[++resolved].resolve(value);
|
|
912
|
+
});
|
|
913
|
+
}
|
|
914
|
+
};
|
|
915
|
+
}
|
|
916
|
+
//#endregion
|
|
917
|
+
//#region ../../node_modules/.bun/@sveltejs+kit@2.61.0+aeb06e9cf8e23ab6/node_modules/@sveltejs/kit/src/runtime/server/page/data_serializer.js
|
|
918
|
+
/**
|
|
919
|
+
* If the serialized data contains promises, `chunks` will be an
|
|
920
|
+
* async iterable containing their resolutions
|
|
921
|
+
* @param {import('@sveltejs/kit').RequestEvent} event
|
|
922
|
+
* @param {import('types').RequestState} event_state
|
|
923
|
+
* @param {import('types').SSROptions} options
|
|
924
|
+
* @returns {import('./types.js').ServerDataSerializer}
|
|
925
|
+
*/
|
|
926
|
+
function server_data_serializer(event, event_state, options) {
|
|
927
|
+
let promise_id = 1;
|
|
928
|
+
let max_nodes = -1;
|
|
929
|
+
const iterator = create_async_iterator();
|
|
930
|
+
const global = get_global_name(options);
|
|
931
|
+
/** @param {number} index */
|
|
932
|
+
function get_replacer(index) {
|
|
933
|
+
/** @param {any} thing */
|
|
934
|
+
return function replacer(thing) {
|
|
935
|
+
if (typeof thing?.then === "function") {
|
|
936
|
+
const id = promise_id++;
|
|
937
|
+
const promise = thing.then(
|
|
938
|
+
/** @param {any} data */
|
|
939
|
+
(data) => ({ data })
|
|
940
|
+
).catch(
|
|
941
|
+
/** @param {any} error */
|
|
942
|
+
async (error) => ({ error: await handle_error_and_jsonify(event, event_state, options, error) })
|
|
943
|
+
).then(
|
|
944
|
+
/**
|
|
945
|
+
* @param {{data: any; error: any}} result
|
|
946
|
+
*/
|
|
947
|
+
async ({ data, error }) => {
|
|
948
|
+
let str;
|
|
949
|
+
try {
|
|
950
|
+
str = uneval(error ? [, error] : [data], replacer);
|
|
951
|
+
} catch {
|
|
952
|
+
error = await handle_error_and_jsonify(event, event_state, options, /* @__PURE__ */ new Error(`Failed to serialize promise while rendering ${event.route.id}`));
|
|
953
|
+
str = uneval([, error], replacer);
|
|
954
|
+
}
|
|
955
|
+
return {
|
|
956
|
+
index,
|
|
957
|
+
str: `${global}.resolve(${id}, ${str.includes("app.decode") ? `(app) => ${str}` : `() => ${str}`})`
|
|
958
|
+
};
|
|
959
|
+
}
|
|
960
|
+
);
|
|
961
|
+
iterator.add(promise);
|
|
962
|
+
return `${global}.defer(${id})`;
|
|
963
|
+
} else for (const key in options.hooks.transport) {
|
|
964
|
+
const encoded = options.hooks.transport[key].encode(thing);
|
|
965
|
+
if (encoded) return `app.decode('${key}', ${uneval(encoded, replacer)})`;
|
|
966
|
+
}
|
|
967
|
+
};
|
|
968
|
+
}
|
|
969
|
+
const strings = [];
|
|
970
|
+
return {
|
|
971
|
+
set_max_nodes(i) {
|
|
972
|
+
max_nodes = i;
|
|
973
|
+
},
|
|
974
|
+
add_node(i, node) {
|
|
975
|
+
try {
|
|
976
|
+
if (!node) {
|
|
977
|
+
strings[i] = "null";
|
|
978
|
+
return;
|
|
979
|
+
}
|
|
980
|
+
/** @type {any} */
|
|
981
|
+
const payload = {
|
|
982
|
+
type: "data",
|
|
983
|
+
data: node.data,
|
|
984
|
+
uses: serialize_uses(node)
|
|
985
|
+
};
|
|
986
|
+
if (node.slash) payload.slash = node.slash;
|
|
987
|
+
strings[i] = uneval(payload, get_replacer(i));
|
|
988
|
+
} catch (e) {
|
|
989
|
+
e.path = e.path.slice(1);
|
|
990
|
+
throw new Error(clarify_devalue_error(event, e), { cause: e });
|
|
991
|
+
}
|
|
992
|
+
},
|
|
993
|
+
get_data(csp) {
|
|
994
|
+
const open = `<script${csp.script_needs_nonce ? ` nonce="${csp.nonce}"` : ""}>`;
|
|
995
|
+
const close = `<\/script>\n`;
|
|
996
|
+
return {
|
|
997
|
+
data: `[${compact(max_nodes > -1 ? strings.slice(0, max_nodes) : strings).join(",")}]`,
|
|
998
|
+
chunks: promise_id > 1 ? iterator.iterate(({ index, str }) => {
|
|
999
|
+
if (max_nodes > -1 && index >= max_nodes) return "";
|
|
1000
|
+
return open + str + close;
|
|
1001
|
+
}) : null
|
|
1002
|
+
};
|
|
1003
|
+
}
|
|
1004
|
+
};
|
|
1005
|
+
}
|
|
1006
|
+
/**
|
|
1007
|
+
* If the serialized data contains promises, `chunks` will be an
|
|
1008
|
+
* async iterable containing their resolutions
|
|
1009
|
+
* @param {import('@sveltejs/kit').RequestEvent} event
|
|
1010
|
+
* @param {import('types').RequestState} event_state
|
|
1011
|
+
* @param {import('types').SSROptions} options
|
|
1012
|
+
* @returns {import('./types.js').ServerDataSerializerJson}
|
|
1013
|
+
*/
|
|
1014
|
+
function server_data_serializer_json(event, event_state, options) {
|
|
1015
|
+
let promise_id = 1;
|
|
1016
|
+
const iterator = create_async_iterator();
|
|
1017
|
+
const reducers = {
|
|
1018
|
+
...Object.fromEntries(Object.entries(options.hooks.transport).map(([key, value]) => [key, value.encode])),
|
|
1019
|
+
/** @param {any} thing */
|
|
1020
|
+
Promise: (thing) => {
|
|
1021
|
+
if (typeof thing?.then !== "function") return;
|
|
1022
|
+
const id = promise_id++;
|
|
1023
|
+
/** @type {'data' | 'error'} */
|
|
1024
|
+
let key = "data";
|
|
1025
|
+
const promise = thing.catch(
|
|
1026
|
+
/** @param {any} e */
|
|
1027
|
+
async (e) => {
|
|
1028
|
+
key = "error";
|
|
1029
|
+
return handle_error_and_jsonify(event, event_state, options, e);
|
|
1030
|
+
}
|
|
1031
|
+
).then(
|
|
1032
|
+
/** @param {any} value */
|
|
1033
|
+
async (value) => {
|
|
1034
|
+
let str;
|
|
1035
|
+
try {
|
|
1036
|
+
str = stringify$1(value, reducers);
|
|
1037
|
+
} catch {
|
|
1038
|
+
const error = await handle_error_and_jsonify(event, event_state, options, /* @__PURE__ */ new Error(`Failed to serialize promise while rendering ${event.route.id}`));
|
|
1039
|
+
key = "error";
|
|
1040
|
+
str = stringify$1(error, reducers);
|
|
1041
|
+
}
|
|
1042
|
+
return `{"type":"chunk","id":${id},"${key}":${str}}\n`;
|
|
1043
|
+
}
|
|
1044
|
+
);
|
|
1045
|
+
iterator.add(promise);
|
|
1046
|
+
return id;
|
|
1047
|
+
}
|
|
1048
|
+
};
|
|
1049
|
+
const strings = [];
|
|
1050
|
+
return {
|
|
1051
|
+
add_node(i, node) {
|
|
1052
|
+
try {
|
|
1053
|
+
if (!node) {
|
|
1054
|
+
strings[i] = "null";
|
|
1055
|
+
return;
|
|
1056
|
+
}
|
|
1057
|
+
if (node.type === "error" || node.type === "skip") {
|
|
1058
|
+
strings[i] = JSON.stringify(node);
|
|
1059
|
+
return;
|
|
1060
|
+
}
|
|
1061
|
+
strings[i] = `{"type":"data","data":${stringify$1(node.data, reducers)},"uses":${JSON.stringify(serialize_uses(node))}${node.slash ? `,"slash":${JSON.stringify(node.slash)}` : ""}}`;
|
|
1062
|
+
} catch (e) {
|
|
1063
|
+
e.path = "data" + e.path;
|
|
1064
|
+
throw new Error(clarify_devalue_error(event, e), { cause: e });
|
|
1065
|
+
}
|
|
1066
|
+
},
|
|
1067
|
+
get_data() {
|
|
1068
|
+
return {
|
|
1069
|
+
data: `{"type":"data","nodes":[${strings.join(",")}]}\n`,
|
|
1070
|
+
chunks: promise_id > 1 ? iterator.iterate() : null
|
|
1071
|
+
};
|
|
1072
|
+
}
|
|
1073
|
+
};
|
|
1074
|
+
}
|
|
1075
|
+
//#endregion
|
|
1076
|
+
//#region ../../node_modules/.bun/@sveltejs+kit@2.61.0+aeb06e9cf8e23ab6/node_modules/@sveltejs/kit/src/runtime/server/page/load_data.js
|
|
1077
|
+
/**
|
|
1078
|
+
* Calls the user's server `load` function.
|
|
1079
|
+
* @param {{
|
|
1080
|
+
* event: import('@sveltejs/kit').RequestEvent;
|
|
1081
|
+
* event_state: import('types').RequestState;
|
|
1082
|
+
* state: import('types').SSRState;
|
|
1083
|
+
* node: import('types').SSRNode | undefined;
|
|
1084
|
+
* parent: () => Promise<Record<string, any>>;
|
|
1085
|
+
* }} opts
|
|
1086
|
+
* @returns {Promise<import('types').ServerDataNode | null>}
|
|
1087
|
+
*/
|
|
1088
|
+
async function load_server_data({ event, event_state, state, node, parent }) {
|
|
1089
|
+
if (!node?.server) return null;
|
|
1090
|
+
let is_tracking = true;
|
|
1091
|
+
const uses = {
|
|
1092
|
+
dependencies: /* @__PURE__ */ new Set(),
|
|
1093
|
+
params: /* @__PURE__ */ new Set(),
|
|
1094
|
+
parent: false,
|
|
1095
|
+
route: false,
|
|
1096
|
+
url: false,
|
|
1097
|
+
search_params: /* @__PURE__ */ new Set()
|
|
1098
|
+
};
|
|
1099
|
+
const load = node.server.load;
|
|
1100
|
+
const slash = node.server.trailingSlash;
|
|
1101
|
+
if (!load) return {
|
|
1102
|
+
type: "data",
|
|
1103
|
+
data: null,
|
|
1104
|
+
uses,
|
|
1105
|
+
slash
|
|
1106
|
+
};
|
|
1107
|
+
const url = make_trackable(event.url, () => {
|
|
1108
|
+
if (is_tracking) uses.url = true;
|
|
1109
|
+
}, (param) => {
|
|
1110
|
+
if (is_tracking) uses.search_params.add(param);
|
|
1111
|
+
});
|
|
1112
|
+
if (state.prerendering) disable_search(url);
|
|
1113
|
+
return {
|
|
1114
|
+
type: "data",
|
|
1115
|
+
data: await record_span({
|
|
1116
|
+
name: "sveltekit.load",
|
|
1117
|
+
attributes: {
|
|
1118
|
+
"sveltekit.load.node_id": node.server_id || "unknown",
|
|
1119
|
+
"sveltekit.load.node_type": get_node_type(node.server_id),
|
|
1120
|
+
"http.route": event.route.id || "unknown"
|
|
1121
|
+
},
|
|
1122
|
+
fn: async (current) => {
|
|
1123
|
+
const traced_event = merge_tracing(event, current);
|
|
1124
|
+
return await with_request_store({
|
|
1125
|
+
event: traced_event,
|
|
1126
|
+
state: event_state
|
|
1127
|
+
}, () => load.call(null, {
|
|
1128
|
+
...traced_event,
|
|
1129
|
+
fetch: (info, init) => {
|
|
1130
|
+
new URL(info instanceof Request ? info.url : info, event.url);
|
|
1131
|
+
return event.fetch(info, init);
|
|
1132
|
+
},
|
|
1133
|
+
/** @param {string[]} deps */
|
|
1134
|
+
depends: (...deps) => {
|
|
1135
|
+
for (const dep of deps) {
|
|
1136
|
+
const { href } = new URL(dep, event.url);
|
|
1137
|
+
uses.dependencies.add(href);
|
|
1138
|
+
}
|
|
1139
|
+
},
|
|
1140
|
+
params: new Proxy(event.params, { get: (target, key) => {
|
|
1141
|
+
if (is_tracking) uses.params.add(key);
|
|
1142
|
+
return target[key];
|
|
1143
|
+
} }),
|
|
1144
|
+
parent: async () => {
|
|
1145
|
+
if (is_tracking) uses.parent = true;
|
|
1146
|
+
return parent();
|
|
1147
|
+
},
|
|
1148
|
+
route: new Proxy(event.route, { get: (target, key) => {
|
|
1149
|
+
if (is_tracking) uses.route = true;
|
|
1150
|
+
return target[key];
|
|
1151
|
+
} }),
|
|
1152
|
+
url,
|
|
1153
|
+
untrack(fn) {
|
|
1154
|
+
is_tracking = false;
|
|
1155
|
+
try {
|
|
1156
|
+
return fn();
|
|
1157
|
+
} finally {
|
|
1158
|
+
is_tracking = true;
|
|
1159
|
+
}
|
|
1160
|
+
}
|
|
1161
|
+
}));
|
|
1162
|
+
}
|
|
1163
|
+
}) ?? null,
|
|
1164
|
+
uses,
|
|
1165
|
+
slash
|
|
1166
|
+
};
|
|
1167
|
+
}
|
|
1168
|
+
/**
|
|
1169
|
+
* Calls the user's `load` function.
|
|
1170
|
+
* @param {{
|
|
1171
|
+
* event: import('@sveltejs/kit').RequestEvent;
|
|
1172
|
+
* event_state: import('types').RequestState;
|
|
1173
|
+
* fetched: import('./types.js').Fetched[];
|
|
1174
|
+
* node: import('types').SSRNode | undefined;
|
|
1175
|
+
* parent: () => Promise<Record<string, any>>;
|
|
1176
|
+
* resolve_opts: import('types').RequiredResolveOptions;
|
|
1177
|
+
* server_data_promise: Promise<import('types').ServerDataNode | null>;
|
|
1178
|
+
* state: import('types').SSRState;
|
|
1179
|
+
* csr: boolean;
|
|
1180
|
+
* }} opts
|
|
1181
|
+
* @returns {Promise<Record<string, any | Promise<any>> | null>}
|
|
1182
|
+
*/
|
|
1183
|
+
async function load_data({ event, event_state, fetched, node, parent, server_data_promise, state, resolve_opts, csr }) {
|
|
1184
|
+
const server_data_node = await server_data_promise;
|
|
1185
|
+
const load = node?.universal?.load;
|
|
1186
|
+
if (!load) return server_data_node?.data ?? null;
|
|
1187
|
+
return await record_span({
|
|
1188
|
+
name: "sveltekit.load",
|
|
1189
|
+
attributes: {
|
|
1190
|
+
"sveltekit.load.node_id": node.universal_id || "unknown",
|
|
1191
|
+
"sveltekit.load.node_type": get_node_type(node.universal_id),
|
|
1192
|
+
"http.route": event.route.id || "unknown"
|
|
1193
|
+
},
|
|
1194
|
+
fn: async (current) => {
|
|
1195
|
+
const traced_event = merge_tracing(event, current);
|
|
1196
|
+
return await with_request_store({
|
|
1197
|
+
event: traced_event,
|
|
1198
|
+
state: {
|
|
1199
|
+
...event_state,
|
|
1200
|
+
is_in_universal_load: true
|
|
1201
|
+
}
|
|
1202
|
+
}, () => load.call(null, {
|
|
1203
|
+
url: event.url,
|
|
1204
|
+
params: event.params,
|
|
1205
|
+
data: server_data_node?.data ?? null,
|
|
1206
|
+
route: event.route,
|
|
1207
|
+
fetch: create_universal_fetch(event, state, fetched, csr, resolve_opts),
|
|
1208
|
+
setHeaders: event.setHeaders,
|
|
1209
|
+
depends: noop,
|
|
1210
|
+
parent,
|
|
1211
|
+
untrack: (fn) => fn(),
|
|
1212
|
+
tracing: traced_event.tracing
|
|
1213
|
+
}));
|
|
1214
|
+
}
|
|
1215
|
+
}) ?? null;
|
|
1216
|
+
}
|
|
1217
|
+
/**
|
|
1218
|
+
* @param {Pick<import('@sveltejs/kit').RequestEvent, 'fetch' | 'url' | 'request' | 'route'>} event
|
|
1219
|
+
* @param {import('types').SSRState} state
|
|
1220
|
+
* @param {import('./types.js').Fetched[]} fetched
|
|
1221
|
+
* @param {boolean} csr
|
|
1222
|
+
* @param {Pick<Required<import('@sveltejs/kit').ResolveOptions>, 'filterSerializedResponseHeaders'>} resolve_opts
|
|
1223
|
+
* @returns {typeof fetch}
|
|
1224
|
+
*/
|
|
1225
|
+
function create_universal_fetch(event, state, fetched, csr, resolve_opts) {
|
|
1226
|
+
/**
|
|
1227
|
+
* @param {URL | RequestInfo} input
|
|
1228
|
+
* @param {RequestInit} [init]
|
|
1229
|
+
*/
|
|
1230
|
+
const universal_fetch = async (input, init) => {
|
|
1231
|
+
const cloned_body = input instanceof Request && input.body ? input.clone().body : null;
|
|
1232
|
+
const cloned_headers = input instanceof Request && [...input.headers].length ? new Headers(input.headers) : init?.headers;
|
|
1233
|
+
let response = await event.fetch(input, init);
|
|
1234
|
+
const url = new URL(input instanceof Request ? input.url : input, event.url);
|
|
1235
|
+
const same_origin = url.origin === event.url.origin;
|
|
1236
|
+
/** @type {import('types').PrerenderDependency} */
|
|
1237
|
+
let dependency;
|
|
1238
|
+
if (same_origin) {
|
|
1239
|
+
if (state.prerendering) {
|
|
1240
|
+
dependency = {
|
|
1241
|
+
response,
|
|
1242
|
+
body: null
|
|
1243
|
+
};
|
|
1244
|
+
state.prerendering.dependencies.set(url.pathname, dependency);
|
|
1245
|
+
}
|
|
1246
|
+
} else if (url.protocol === "https:" || url.protocol === "http:") if ((input instanceof Request ? input.mode : init?.mode ?? "cors") === "no-cors") response = new Response("", {
|
|
1247
|
+
status: response.status,
|
|
1248
|
+
statusText: response.statusText,
|
|
1249
|
+
headers: response.headers
|
|
1250
|
+
});
|
|
1251
|
+
else {
|
|
1252
|
+
const acao = response.headers.get("access-control-allow-origin");
|
|
1253
|
+
if (!acao || acao !== event.url.origin && acao !== "*") throw new Error(`CORS error: ${acao ? "Incorrect" : "No"} 'Access-Control-Allow-Origin' header is present on the requested resource`);
|
|
1254
|
+
}
|
|
1255
|
+
/** @type {ReadableStream<Uint8Array>} */
|
|
1256
|
+
let teed_body;
|
|
1257
|
+
const proxy = new Proxy(response, { get(response, key, receiver) {
|
|
1258
|
+
/**
|
|
1259
|
+
* @param {string | undefined} body
|
|
1260
|
+
* @param {boolean} is_b64
|
|
1261
|
+
*/
|
|
1262
|
+
async function push_fetched(body, is_b64) {
|
|
1263
|
+
const status_number = Number(response.status);
|
|
1264
|
+
if (isNaN(status_number)) throw new Error(`response.status is not a number. value: "${response.status}" type: ${typeof response.status}`);
|
|
1265
|
+
fetched.push({
|
|
1266
|
+
url: same_origin ? url.href.slice(event.url.origin.length) : url.href,
|
|
1267
|
+
method: event.request.method,
|
|
1268
|
+
request_body: input instanceof Request && cloned_body ? await stream_to_string(cloned_body) : init?.body,
|
|
1269
|
+
request_headers: cloned_headers,
|
|
1270
|
+
response_body: body,
|
|
1271
|
+
response,
|
|
1272
|
+
is_b64
|
|
1273
|
+
});
|
|
1274
|
+
}
|
|
1275
|
+
if (key === "body") {
|
|
1276
|
+
if (response.body === null) return null;
|
|
1277
|
+
if (teed_body) return teed_body;
|
|
1278
|
+
const [a, b] = response.body.tee();
|
|
1279
|
+
(async () => {
|
|
1280
|
+
let result = new Uint8Array();
|
|
1281
|
+
for await (const chunk of a) {
|
|
1282
|
+
const combined = new Uint8Array(result.length + chunk.length);
|
|
1283
|
+
combined.set(result, 0);
|
|
1284
|
+
combined.set(chunk, result.length);
|
|
1285
|
+
result = combined;
|
|
1286
|
+
}
|
|
1287
|
+
if (dependency) dependency.body = new Uint8Array(result);
|
|
1288
|
+
push_fetched(base64_encode(result), true);
|
|
1289
|
+
})();
|
|
1290
|
+
return teed_body = b;
|
|
1291
|
+
}
|
|
1292
|
+
if (key === "arrayBuffer") return async () => {
|
|
1293
|
+
const buffer = await response.arrayBuffer();
|
|
1294
|
+
const bytes = new Uint8Array(buffer);
|
|
1295
|
+
if (dependency) dependency.body = bytes;
|
|
1296
|
+
if (buffer instanceof ArrayBuffer) await push_fetched(base64_encode(bytes), true);
|
|
1297
|
+
return buffer;
|
|
1298
|
+
};
|
|
1299
|
+
async function text() {
|
|
1300
|
+
const body = await response.text();
|
|
1301
|
+
if (body === "" && NULL_BODY_STATUS.includes(response.status)) {
|
|
1302
|
+
await push_fetched(void 0, false);
|
|
1303
|
+
return;
|
|
1304
|
+
}
|
|
1305
|
+
if (!body || typeof body === "string") await push_fetched(body, false);
|
|
1306
|
+
if (dependency) dependency.body = body;
|
|
1307
|
+
return body;
|
|
1308
|
+
}
|
|
1309
|
+
if (key === "text") return text;
|
|
1310
|
+
if (key === "json") return async () => {
|
|
1311
|
+
const body = await text();
|
|
1312
|
+
return body ? JSON.parse(body) : void 0;
|
|
1313
|
+
};
|
|
1314
|
+
const value = Reflect.get(response, key, response);
|
|
1315
|
+
if (value instanceof Function) return Object.defineProperties(
|
|
1316
|
+
/**
|
|
1317
|
+
* @this {any}
|
|
1318
|
+
*/
|
|
1319
|
+
function() {
|
|
1320
|
+
return Reflect.apply(value, this === receiver ? response : this, arguments);
|
|
1321
|
+
},
|
|
1322
|
+
{
|
|
1323
|
+
name: { value: value.name },
|
|
1324
|
+
length: { value: value.length }
|
|
1325
|
+
}
|
|
1326
|
+
);
|
|
1327
|
+
return value;
|
|
1328
|
+
} });
|
|
1329
|
+
if (csr) {
|
|
1330
|
+
const get = response.headers.get;
|
|
1331
|
+
response.headers.get = (key) => {
|
|
1332
|
+
const lower = key.toLowerCase();
|
|
1333
|
+
const value = get.call(response.headers, lower);
|
|
1334
|
+
if (value && !lower.startsWith("x-sveltekit-")) {
|
|
1335
|
+
if (!resolve_opts.filterSerializedResponseHeaders(lower, value)) throw new Error(`Failed to get response header "${lower}" — it must be included by the \`filterSerializedResponseHeaders\` option: https://svelte.dev/docs/kit/hooks#Server-hooks-handle (at ${event.route.id})`);
|
|
1336
|
+
}
|
|
1337
|
+
return value;
|
|
1338
|
+
};
|
|
1339
|
+
}
|
|
1340
|
+
return proxy;
|
|
1341
|
+
};
|
|
1342
|
+
return (input, init) => {
|
|
1343
|
+
const response = universal_fetch(input, init);
|
|
1344
|
+
response.catch(noop);
|
|
1345
|
+
return response;
|
|
1346
|
+
};
|
|
1347
|
+
}
|
|
1348
|
+
/**
|
|
1349
|
+
* @param {ReadableStream<Uint8Array>} stream
|
|
1350
|
+
*/
|
|
1351
|
+
async function stream_to_string(stream) {
|
|
1352
|
+
let result = "";
|
|
1353
|
+
const reader = stream.getReader();
|
|
1354
|
+
const decoder = new TextDecoder();
|
|
1355
|
+
while (true) {
|
|
1356
|
+
const { done, value } = await reader.read();
|
|
1357
|
+
if (done) {
|
|
1358
|
+
result += decoder.decode();
|
|
1359
|
+
break;
|
|
1360
|
+
}
|
|
1361
|
+
result += decoder.decode(value, { stream: true });
|
|
1362
|
+
}
|
|
1363
|
+
return result;
|
|
1364
|
+
}
|
|
1365
|
+
//#endregion
|
|
1366
|
+
//#region ../../node_modules/.bun/@sveltejs+kit@2.61.0+aeb06e9cf8e23ab6/node_modules/@sveltejs/kit/src/runtime/server/page/serialize_data.js
|
|
1367
|
+
/**
|
|
1368
|
+
* Inside a script element, only `<\/script` and `<!--` hold special meaning to the HTML parser.
|
|
1369
|
+
*
|
|
1370
|
+
* The first closes the script element, so everything after is treated as raw HTML.
|
|
1371
|
+
* The second disables further parsing until `-->`, so the script element might be unexpectedly
|
|
1372
|
+
* kept open up until an unrelated HTML comment in the page.
|
|
1373
|
+
*
|
|
1374
|
+
* U+2028 LINE SEPARATOR and U+2029 PARAGRAPH SEPARATOR are escaped for the sake of pre-2018
|
|
1375
|
+
* browsers.
|
|
1376
|
+
*
|
|
1377
|
+
* @see tests for unsafe parsing examples.
|
|
1378
|
+
* @see https://html.spec.whatwg.org/multipage/scripting.html#restrictions-for-contents-of-script-elements
|
|
1379
|
+
* @see https://html.spec.whatwg.org/multipage/syntax.html#cdata-rcdata-restrictions
|
|
1380
|
+
* @see https://html.spec.whatwg.org/multipage/parsing.html#script-data-state
|
|
1381
|
+
* @see https://html.spec.whatwg.org/multipage/parsing.html#script-data-double-escaped-state
|
|
1382
|
+
* @see https://github.com/tc39/proposal-json-superset
|
|
1383
|
+
* @type {Record<string, string>}
|
|
1384
|
+
*/
|
|
1385
|
+
var replacements = {
|
|
1386
|
+
"<": "\\u003C",
|
|
1387
|
+
"\u2028": "\\u2028",
|
|
1388
|
+
"\u2029": "\\u2029"
|
|
1389
|
+
};
|
|
1390
|
+
var pattern = new RegExp(`[${Object.keys(replacements).join("")}]`, "g");
|
|
1391
|
+
/**
|
|
1392
|
+
* Generates a raw HTML string containing a safe script element carrying data and associated attributes.
|
|
1393
|
+
*
|
|
1394
|
+
* It escapes all the special characters needed to guarantee the element is unbroken, but care must
|
|
1395
|
+
* be taken to ensure it is inserted in the document at an acceptable position for a script element,
|
|
1396
|
+
* and that the resulting string isn't further modified.
|
|
1397
|
+
*
|
|
1398
|
+
* @param {import('./types.js').Fetched} fetched
|
|
1399
|
+
* @param {(name: string, value: string) => boolean} filter
|
|
1400
|
+
* @param {boolean} [prerendering]
|
|
1401
|
+
* @returns {string} The raw HTML of a script element carrying the JSON payload.
|
|
1402
|
+
* @example const html = serialize_data('/data.json', null, { foo: 'bar' });
|
|
1403
|
+
*/
|
|
1404
|
+
function serialize_data(fetched, filter, prerendering = false) {
|
|
1405
|
+
/** @type {Record<string, string>} */
|
|
1406
|
+
const headers = {};
|
|
1407
|
+
let cache_control = null;
|
|
1408
|
+
let age = null;
|
|
1409
|
+
let varyAny = false;
|
|
1410
|
+
for (const [key, value] of fetched.response.headers) {
|
|
1411
|
+
if (filter(key, value)) headers[key] = value;
|
|
1412
|
+
if (key === "cache-control") cache_control = value;
|
|
1413
|
+
else if (key === "age") age = value;
|
|
1414
|
+
else if (key === "vary" && value.trim() === "*") varyAny = true;
|
|
1415
|
+
}
|
|
1416
|
+
const payload = {
|
|
1417
|
+
status: fetched.response.status,
|
|
1418
|
+
statusText: fetched.response.statusText,
|
|
1419
|
+
headers,
|
|
1420
|
+
body: fetched.response_body
|
|
1421
|
+
};
|
|
1422
|
+
const safe_payload = JSON.stringify(payload).replace(pattern, (match) => replacements[match]);
|
|
1423
|
+
const attrs = [
|
|
1424
|
+
"type=\"application/json\"",
|
|
1425
|
+
"data-sveltekit-fetched",
|
|
1426
|
+
`data-url="${escape_html(fetched.url, true)}"`
|
|
1427
|
+
];
|
|
1428
|
+
if (fetched.is_b64) attrs.push("data-b64");
|
|
1429
|
+
if (fetched.request_headers || fetched.request_body) {
|
|
1430
|
+
/** @type {import('types').StrictBody[]} */
|
|
1431
|
+
const values = [];
|
|
1432
|
+
if (fetched.request_headers) values.push([...new Headers(fetched.request_headers)].join(","));
|
|
1433
|
+
if (fetched.request_body) values.push(fetched.request_body);
|
|
1434
|
+
attrs.push(`data-hash="${hash(...values)}"`);
|
|
1435
|
+
}
|
|
1436
|
+
if (!prerendering && fetched.method === "GET" && cache_control && !varyAny) {
|
|
1437
|
+
const match = /s-maxage=(\d+)/g.exec(cache_control) ?? /max-age=(\d+)/g.exec(cache_control);
|
|
1438
|
+
if (match) {
|
|
1439
|
+
const ttl = +match[1] - +(age ?? "0");
|
|
1440
|
+
attrs.push(`data-ttl="${ttl}"`);
|
|
1441
|
+
}
|
|
1442
|
+
}
|
|
1443
|
+
return `<script ${attrs.join(" ")}>${safe_payload}<\/script>`;
|
|
1444
|
+
}
|
|
1445
|
+
//#endregion
|
|
1446
|
+
//#region ../../node_modules/.bun/@sveltejs+kit@2.61.0+aeb06e9cf8e23ab6/node_modules/@sveltejs/kit/src/runtime/server/page/crypto.js
|
|
1447
|
+
/**
|
|
1448
|
+
* SHA-256 hashing function adapted from https://bitwiseshiftleft.github.io/sjcl
|
|
1449
|
+
* modified and redistributed under BSD license
|
|
1450
|
+
* @param {string} data
|
|
1451
|
+
*/
|
|
1452
|
+
function sha256(data) {
|
|
1453
|
+
if (!key[0]) precompute();
|
|
1454
|
+
const out = init.slice(0);
|
|
1455
|
+
const array = encode(data);
|
|
1456
|
+
for (let i = 0; i < array.length; i += 16) {
|
|
1457
|
+
const w = array.subarray(i, i + 16);
|
|
1458
|
+
let tmp;
|
|
1459
|
+
let a;
|
|
1460
|
+
let b;
|
|
1461
|
+
let out0 = out[0];
|
|
1462
|
+
let out1 = out[1];
|
|
1463
|
+
let out2 = out[2];
|
|
1464
|
+
let out3 = out[3];
|
|
1465
|
+
let out4 = out[4];
|
|
1466
|
+
let out5 = out[5];
|
|
1467
|
+
let out6 = out[6];
|
|
1468
|
+
let out7 = out[7];
|
|
1469
|
+
for (let i = 0; i < 64; i++) {
|
|
1470
|
+
if (i < 16) tmp = w[i];
|
|
1471
|
+
else {
|
|
1472
|
+
a = w[i + 1 & 15];
|
|
1473
|
+
b = w[i + 14 & 15];
|
|
1474
|
+
tmp = w[i & 15] = (a >>> 7 ^ a >>> 18 ^ a >>> 3 ^ a << 25 ^ a << 14) + (b >>> 17 ^ b >>> 19 ^ b >>> 10 ^ b << 15 ^ b << 13) + w[i & 15] + w[i + 9 & 15] | 0;
|
|
1475
|
+
}
|
|
1476
|
+
tmp = tmp + out7 + (out4 >>> 6 ^ out4 >>> 11 ^ out4 >>> 25 ^ out4 << 26 ^ out4 << 21 ^ out4 << 7) + (out6 ^ out4 & (out5 ^ out6)) + key[i];
|
|
1477
|
+
out7 = out6;
|
|
1478
|
+
out6 = out5;
|
|
1479
|
+
out5 = out4;
|
|
1480
|
+
out4 = out3 + tmp | 0;
|
|
1481
|
+
out3 = out2;
|
|
1482
|
+
out2 = out1;
|
|
1483
|
+
out1 = out0;
|
|
1484
|
+
out0 = tmp + (out1 & out2 ^ out3 & (out1 ^ out2)) + (out1 >>> 2 ^ out1 >>> 13 ^ out1 >>> 22 ^ out1 << 30 ^ out1 << 19 ^ out1 << 10) | 0;
|
|
1485
|
+
}
|
|
1486
|
+
out[0] = out[0] + out0 | 0;
|
|
1487
|
+
out[1] = out[1] + out1 | 0;
|
|
1488
|
+
out[2] = out[2] + out2 | 0;
|
|
1489
|
+
out[3] = out[3] + out3 | 0;
|
|
1490
|
+
out[4] = out[4] + out4 | 0;
|
|
1491
|
+
out[5] = out[5] + out5 | 0;
|
|
1492
|
+
out[6] = out[6] + out6 | 0;
|
|
1493
|
+
out[7] = out[7] + out7 | 0;
|
|
1494
|
+
}
|
|
1495
|
+
const bytes = new Uint8Array(out.buffer);
|
|
1496
|
+
reverse_endianness(bytes);
|
|
1497
|
+
return btoa(String.fromCharCode(...bytes));
|
|
1498
|
+
}
|
|
1499
|
+
/** The SHA-256 initialization vector */
|
|
1500
|
+
var init = new Uint32Array(8);
|
|
1501
|
+
/** The SHA-256 hash key */
|
|
1502
|
+
var key = new Uint32Array(64);
|
|
1503
|
+
/** Function to precompute init and key. */
|
|
1504
|
+
function precompute() {
|
|
1505
|
+
/** @param {number} x */
|
|
1506
|
+
function frac(x) {
|
|
1507
|
+
return (x - Math.floor(x)) * 4294967296;
|
|
1508
|
+
}
|
|
1509
|
+
let prime = 2;
|
|
1510
|
+
for (let i = 0; i < 64; prime++) {
|
|
1511
|
+
let is_prime = true;
|
|
1512
|
+
for (let factor = 2; factor * factor <= prime; factor++) if (prime % factor === 0) {
|
|
1513
|
+
is_prime = false;
|
|
1514
|
+
break;
|
|
1515
|
+
}
|
|
1516
|
+
if (is_prime) {
|
|
1517
|
+
if (i < 8) init[i] = frac(prime ** (1 / 2));
|
|
1518
|
+
key[i] = frac(prime ** (1 / 3));
|
|
1519
|
+
i++;
|
|
1520
|
+
}
|
|
1521
|
+
}
|
|
1522
|
+
}
|
|
1523
|
+
/** @param {Uint8Array} bytes */
|
|
1524
|
+
function reverse_endianness(bytes) {
|
|
1525
|
+
for (let i = 0; i < bytes.length; i += 4) {
|
|
1526
|
+
const a = bytes[i + 0];
|
|
1527
|
+
const b = bytes[i + 1];
|
|
1528
|
+
const c = bytes[i + 2];
|
|
1529
|
+
const d = bytes[i + 3];
|
|
1530
|
+
bytes[i + 0] = d;
|
|
1531
|
+
bytes[i + 1] = c;
|
|
1532
|
+
bytes[i + 2] = b;
|
|
1533
|
+
bytes[i + 3] = a;
|
|
1534
|
+
}
|
|
1535
|
+
}
|
|
1536
|
+
/** @param {string} str */
|
|
1537
|
+
function encode(str) {
|
|
1538
|
+
const encoded = text_encoder.encode(str);
|
|
1539
|
+
const length = encoded.length * 8;
|
|
1540
|
+
const size = 512 * Math.ceil((length + 65) / 512);
|
|
1541
|
+
const bytes = new Uint8Array(size / 8);
|
|
1542
|
+
bytes.set(encoded);
|
|
1543
|
+
bytes[encoded.length] = 128;
|
|
1544
|
+
reverse_endianness(bytes);
|
|
1545
|
+
const words = new Uint32Array(bytes.buffer);
|
|
1546
|
+
words[words.length - 2] = Math.floor(length / 4294967296);
|
|
1547
|
+
words[words.length - 1] = length;
|
|
1548
|
+
return words;
|
|
1549
|
+
}
|
|
1550
|
+
//#endregion
|
|
1551
|
+
//#region ../../node_modules/.bun/@sveltejs+kit@2.61.0+aeb06e9cf8e23ab6/node_modules/@sveltejs/kit/src/runtime/server/page/csp.js
|
|
1552
|
+
var array = new Uint8Array(16);
|
|
1553
|
+
function generate_nonce() {
|
|
1554
|
+
crypto.getRandomValues(array);
|
|
1555
|
+
return btoa(String.fromCharCode(...array));
|
|
1556
|
+
}
|
|
1557
|
+
var quoted = new Set([
|
|
1558
|
+
"self",
|
|
1559
|
+
"unsafe-eval",
|
|
1560
|
+
"unsafe-hashes",
|
|
1561
|
+
"unsafe-inline",
|
|
1562
|
+
"none",
|
|
1563
|
+
"strict-dynamic",
|
|
1564
|
+
"report-sample",
|
|
1565
|
+
"wasm-unsafe-eval",
|
|
1566
|
+
"script"
|
|
1567
|
+
]);
|
|
1568
|
+
var crypto_pattern = /^(nonce|sha\d\d\d)-/;
|
|
1569
|
+
var BaseProvider = class {
|
|
1570
|
+
/** @type {boolean} */
|
|
1571
|
+
#use_hashes;
|
|
1572
|
+
/** @type {boolean} */
|
|
1573
|
+
#script_needs_csp;
|
|
1574
|
+
/** @type {boolean} */
|
|
1575
|
+
#script_src_needs_csp;
|
|
1576
|
+
/** @type {boolean} */
|
|
1577
|
+
#script_src_elem_needs_csp;
|
|
1578
|
+
/** @type {boolean} */
|
|
1579
|
+
#style_needs_csp;
|
|
1580
|
+
/** @type {boolean} */
|
|
1581
|
+
#style_src_needs_csp;
|
|
1582
|
+
/** @type {boolean} */
|
|
1583
|
+
#style_src_attr_needs_csp;
|
|
1584
|
+
/** @type {boolean} */
|
|
1585
|
+
#style_src_elem_needs_csp;
|
|
1586
|
+
/** @type {import('types').CspDirectives} */
|
|
1587
|
+
#directives;
|
|
1588
|
+
/** @type {Set<import('types').Csp.Source>} */
|
|
1589
|
+
#script_src;
|
|
1590
|
+
/** @type {Set<import('types').Csp.Source>} */
|
|
1591
|
+
#script_src_elem;
|
|
1592
|
+
/** @type {Set<import('types').Csp.Source>} */
|
|
1593
|
+
#style_src;
|
|
1594
|
+
/** @type {Set<import('types').Csp.Source>} */
|
|
1595
|
+
#style_src_attr;
|
|
1596
|
+
/** @type {Set<import('types').Csp.Source>} */
|
|
1597
|
+
#style_src_elem;
|
|
1598
|
+
/** @type {boolean} */
|
|
1599
|
+
script_needs_nonce;
|
|
1600
|
+
/** @type {boolean} */
|
|
1601
|
+
style_needs_nonce;
|
|
1602
|
+
/** @type {boolean} */
|
|
1603
|
+
script_needs_hash;
|
|
1604
|
+
/** @type {string} */
|
|
1605
|
+
#nonce;
|
|
1606
|
+
/**
|
|
1607
|
+
* @param {boolean} use_hashes
|
|
1608
|
+
* @param {import('types').CspDirectives} directives
|
|
1609
|
+
* @param {string} nonce
|
|
1610
|
+
*/
|
|
1611
|
+
constructor(use_hashes, directives, nonce) {
|
|
1612
|
+
this.#use_hashes = use_hashes;
|
|
1613
|
+
this.#directives = directives;
|
|
1614
|
+
const d = this.#directives;
|
|
1615
|
+
this.#script_src = /* @__PURE__ */ new Set();
|
|
1616
|
+
this.#script_src_elem = /* @__PURE__ */ new Set();
|
|
1617
|
+
this.#style_src = /* @__PURE__ */ new Set();
|
|
1618
|
+
this.#style_src_attr = /* @__PURE__ */ new Set();
|
|
1619
|
+
this.#style_src_elem = /* @__PURE__ */ new Set();
|
|
1620
|
+
const effective_script_src = d["script-src"] || d["default-src"];
|
|
1621
|
+
const script_src_elem = d["script-src-elem"];
|
|
1622
|
+
const effective_style_src = d["style-src"] || d["default-src"];
|
|
1623
|
+
const style_src_attr = d["style-src-attr"];
|
|
1624
|
+
const style_src_elem = d["style-src-elem"];
|
|
1625
|
+
/** @param {(import('types').Csp.Source | import('types').Csp.ActionSource)[] | undefined} directive */
|
|
1626
|
+
const style_needs_csp = (directive) => !!directive && !directive.some((value) => value === "unsafe-inline");
|
|
1627
|
+
/** @param {(import('types').Csp.Source | import('types').Csp.ActionSource)[] | undefined} directive */
|
|
1628
|
+
const script_needs_csp = (directive) => !!directive && (!directive.some((value) => value === "unsafe-inline") || directive.some((value) => value === "strict-dynamic"));
|
|
1629
|
+
this.#script_src_needs_csp = script_needs_csp(effective_script_src);
|
|
1630
|
+
this.#script_src_elem_needs_csp = script_needs_csp(script_src_elem);
|
|
1631
|
+
this.#style_src_needs_csp = style_needs_csp(effective_style_src);
|
|
1632
|
+
this.#style_src_attr_needs_csp = style_needs_csp(style_src_attr);
|
|
1633
|
+
this.#style_src_elem_needs_csp = style_needs_csp(style_src_elem);
|
|
1634
|
+
this.#script_needs_csp = this.#script_src_needs_csp || this.#script_src_elem_needs_csp;
|
|
1635
|
+
this.#style_needs_csp = this.#style_src_needs_csp || this.#style_src_attr_needs_csp || this.#style_src_elem_needs_csp;
|
|
1636
|
+
this.script_needs_nonce = this.#script_needs_csp && !this.#use_hashes;
|
|
1637
|
+
this.style_needs_nonce = this.#style_needs_csp && !this.#use_hashes;
|
|
1638
|
+
this.script_needs_hash = this.#script_needs_csp && this.#use_hashes;
|
|
1639
|
+
this.#nonce = nonce;
|
|
1640
|
+
}
|
|
1641
|
+
/** @param {string} content */
|
|
1642
|
+
add_script(content) {
|
|
1643
|
+
if (!this.#script_needs_csp) return;
|
|
1644
|
+
/** @type {`nonce-${string}` | `sha256-${string}`} */
|
|
1645
|
+
const source = this.#use_hashes ? `sha256-${sha256(content)}` : `nonce-${this.#nonce}`;
|
|
1646
|
+
if (this.#script_src_needs_csp) this.#script_src.add(source);
|
|
1647
|
+
if (this.#script_src_elem_needs_csp) this.#script_src_elem.add(source);
|
|
1648
|
+
}
|
|
1649
|
+
/** @param {`sha256-${string}`[]} hashes */
|
|
1650
|
+
add_script_hashes(hashes) {
|
|
1651
|
+
for (const hash of hashes) {
|
|
1652
|
+
if (this.#script_src_needs_csp) this.#script_src.add(hash);
|
|
1653
|
+
if (this.#script_src_elem_needs_csp) this.#script_src_elem.add(hash);
|
|
1654
|
+
}
|
|
1655
|
+
}
|
|
1656
|
+
/** @param {string} content */
|
|
1657
|
+
add_style(content) {
|
|
1658
|
+
if (!this.#style_needs_csp) return;
|
|
1659
|
+
/** @type {`nonce-${string}` | `sha256-${string}`} */
|
|
1660
|
+
const source = this.#use_hashes ? `sha256-${sha256(content)}` : `nonce-${this.#nonce}`;
|
|
1661
|
+
if (this.#style_src_needs_csp) this.#style_src.add(source);
|
|
1662
|
+
if (this.#style_src_attr_needs_csp) this.#style_src_attr.add(source);
|
|
1663
|
+
if (this.#style_src_elem_needs_csp) {
|
|
1664
|
+
const sha256_empty_comment_hash = "sha256-9OlNO0DNEeaVzHL4RZwCLsBHA8WBQ8toBp/4F5XV2nc=";
|
|
1665
|
+
const d = this.#directives;
|
|
1666
|
+
if (d["style-src-elem"] && !d["style-src-elem"].includes(sha256_empty_comment_hash) && !this.#style_src_elem.has(sha256_empty_comment_hash)) this.#style_src_elem.add(sha256_empty_comment_hash);
|
|
1667
|
+
if (source !== sha256_empty_comment_hash) this.#style_src_elem.add(source);
|
|
1668
|
+
}
|
|
1669
|
+
}
|
|
1670
|
+
/**
|
|
1671
|
+
* @param {boolean} [is_meta]
|
|
1672
|
+
*/
|
|
1673
|
+
get_header(is_meta = false) {
|
|
1674
|
+
const header = [];
|
|
1675
|
+
const directives = { ...this.#directives };
|
|
1676
|
+
if (this.#style_src.size > 0) directives["style-src"] = [...directives["style-src"] || directives["default-src"] || [], ...this.#style_src];
|
|
1677
|
+
if (this.#style_src_attr.size > 0) directives["style-src-attr"] = [...directives["style-src-attr"] || [], ...this.#style_src_attr];
|
|
1678
|
+
if (this.#style_src_elem.size > 0) directives["style-src-elem"] = [...directives["style-src-elem"] || [], ...this.#style_src_elem];
|
|
1679
|
+
if (this.#script_src.size > 0) directives["script-src"] = [...directives["script-src"] || directives["default-src"] || [], ...this.#script_src];
|
|
1680
|
+
if (this.#script_src_elem.size > 0) directives["script-src-elem"] = [...directives["script-src-elem"] || [], ...this.#script_src_elem];
|
|
1681
|
+
for (const key in directives) {
|
|
1682
|
+
if (is_meta && (key === "frame-ancestors" || key === "report-uri" || key === "sandbox")) continue;
|
|
1683
|
+
const value = directives[key];
|
|
1684
|
+
if (!value) continue;
|
|
1685
|
+
const directive = [key];
|
|
1686
|
+
if (Array.isArray(value)) value.forEach((value) => {
|
|
1687
|
+
if (quoted.has(value) || crypto_pattern.test(value)) directive.push(`'${value}'`);
|
|
1688
|
+
else directive.push(value);
|
|
1689
|
+
});
|
|
1690
|
+
header.push(directive.join(" "));
|
|
1691
|
+
}
|
|
1692
|
+
return header.join("; ");
|
|
1693
|
+
}
|
|
1694
|
+
};
|
|
1695
|
+
var CspProvider = class extends BaseProvider {
|
|
1696
|
+
get_meta() {
|
|
1697
|
+
const content = this.get_header(true);
|
|
1698
|
+
if (!content) return;
|
|
1699
|
+
return `<meta http-equiv="content-security-policy" content="${escape_html(content, true)}">`;
|
|
1700
|
+
}
|
|
1701
|
+
};
|
|
1702
|
+
var CspReportOnlyProvider = class extends BaseProvider {
|
|
1703
|
+
/**
|
|
1704
|
+
* @param {boolean} use_hashes
|
|
1705
|
+
* @param {import('types').CspDirectives} directives
|
|
1706
|
+
* @param {string} nonce
|
|
1707
|
+
*/
|
|
1708
|
+
constructor(use_hashes, directives, nonce) {
|
|
1709
|
+
super(use_hashes, directives, nonce);
|
|
1710
|
+
if (Object.values(directives).filter((v) => !!v).length > 0) {
|
|
1711
|
+
const has_report_to = directives["report-to"]?.length ?? false;
|
|
1712
|
+
const has_report_uri = directives["report-uri"]?.length ?? false;
|
|
1713
|
+
if (!has_report_to && !has_report_uri) throw Error("`content-security-policy-report-only` must be specified with either the `report-to` or `report-uri` directives, or both");
|
|
1714
|
+
}
|
|
1715
|
+
}
|
|
1716
|
+
};
|
|
1717
|
+
var Csp = class {
|
|
1718
|
+
/** @readonly */
|
|
1719
|
+
nonce = generate_nonce();
|
|
1720
|
+
/** @type {CspProvider} */
|
|
1721
|
+
csp_provider;
|
|
1722
|
+
/** @type {CspReportOnlyProvider} */
|
|
1723
|
+
report_only_provider;
|
|
1724
|
+
/**
|
|
1725
|
+
* @param {import('./types.js').CspConfig} config
|
|
1726
|
+
* @param {import('./types.js').CspOpts} opts
|
|
1727
|
+
*/
|
|
1728
|
+
constructor({ mode, directives, reportOnly }, { prerender }) {
|
|
1729
|
+
const use_hashes = mode === "hash" || mode === "auto" && prerender;
|
|
1730
|
+
this.csp_provider = new CspProvider(use_hashes, directives, this.nonce);
|
|
1731
|
+
this.report_only_provider = new CspReportOnlyProvider(use_hashes, reportOnly, this.nonce);
|
|
1732
|
+
}
|
|
1733
|
+
get script_needs_hash() {
|
|
1734
|
+
return this.csp_provider.script_needs_hash || this.report_only_provider.script_needs_hash;
|
|
1735
|
+
}
|
|
1736
|
+
get script_needs_nonce() {
|
|
1737
|
+
return this.csp_provider.script_needs_nonce || this.report_only_provider.script_needs_nonce;
|
|
1738
|
+
}
|
|
1739
|
+
get style_needs_nonce() {
|
|
1740
|
+
return this.csp_provider.style_needs_nonce || this.report_only_provider.style_needs_nonce;
|
|
1741
|
+
}
|
|
1742
|
+
/** @param {string} content */
|
|
1743
|
+
add_script(content) {
|
|
1744
|
+
this.csp_provider.add_script(content);
|
|
1745
|
+
this.report_only_provider.add_script(content);
|
|
1746
|
+
}
|
|
1747
|
+
/** @param {`sha256-${string}`[]} hashes */
|
|
1748
|
+
add_script_hashes(hashes) {
|
|
1749
|
+
this.csp_provider.add_script_hashes(hashes);
|
|
1750
|
+
this.report_only_provider.add_script_hashes(hashes);
|
|
1751
|
+
}
|
|
1752
|
+
/** @param {string} content */
|
|
1753
|
+
add_style(content) {
|
|
1754
|
+
this.csp_provider.add_style(content);
|
|
1755
|
+
this.report_only_provider.add_style(content);
|
|
1756
|
+
}
|
|
1757
|
+
};
|
|
1758
|
+
//#endregion
|
|
1759
|
+
//#region ../../node_modules/.bun/@sveltejs+kit@2.61.0+aeb06e9cf8e23ab6/node_modules/@sveltejs/kit/src/runtime/server/page/server_routing.js
|
|
1760
|
+
/**
|
|
1761
|
+
* @param {import('types').SSRClientRoute} route
|
|
1762
|
+
* @param {URL} url
|
|
1763
|
+
* @param {import('@sveltejs/kit').SSRManifest} manifest
|
|
1764
|
+
* @returns {string}
|
|
1765
|
+
*/
|
|
1766
|
+
function generate_route_object(route, url, manifest) {
|
|
1767
|
+
const { errors, layouts, leaf } = route;
|
|
1768
|
+
const nodes = [
|
|
1769
|
+
...errors,
|
|
1770
|
+
...layouts.map((l) => l?.[1]),
|
|
1771
|
+
leaf[1]
|
|
1772
|
+
].filter((n) => typeof n === "number").map((n) => `'${n}': () => ${create_client_import(manifest._.client.nodes?.[n], url)}`).join(",\n ");
|
|
1773
|
+
/** @type {import('types').CSRRouteServer} */
|
|
1774
|
+
return [
|
|
1775
|
+
`{\n\tid: ${s(route.id)}`,
|
|
1776
|
+
`errors: ${s(route.errors)}`,
|
|
1777
|
+
`layouts: ${s(route.layouts)}`,
|
|
1778
|
+
`leaf: ${s(route.leaf)}`,
|
|
1779
|
+
`nodes: {\n\t\t${nodes}\n\t}\n}`
|
|
1780
|
+
].join(",\n ");
|
|
1781
|
+
}
|
|
1782
|
+
/**
|
|
1783
|
+
* @param {string | undefined} import_path
|
|
1784
|
+
* @param {URL} url
|
|
1785
|
+
*/
|
|
1786
|
+
function create_client_import(import_path, url) {
|
|
1787
|
+
if (!import_path) return "Promise.resolve({})";
|
|
1788
|
+
if (import_path[0] === "/") return `import('${import_path}')`;
|
|
1789
|
+
if (assets !== "") return `import('${assets}/${import_path}')`;
|
|
1790
|
+
let path = get_relative_path(url.pathname, `${base}/${import_path}`);
|
|
1791
|
+
if (path[0] !== ".") path = `./${path}`;
|
|
1792
|
+
return `import('${path}')`;
|
|
1793
|
+
}
|
|
1794
|
+
/**
|
|
1795
|
+
* @param {string} resolved_path
|
|
1796
|
+
* @param {URL} url
|
|
1797
|
+
* @param {import('@sveltejs/kit').SSRManifest} manifest
|
|
1798
|
+
* @returns {Promise<Response>}
|
|
1799
|
+
*/
|
|
1800
|
+
async function resolve_route(resolved_path, url, manifest) {
|
|
1801
|
+
if (!manifest._.client.routes) return text("Server-side route resolution disabled", { status: 400 });
|
|
1802
|
+
const matchers = await manifest._.matchers();
|
|
1803
|
+
const result = find_route(resolved_path, manifest._.client.routes, matchers);
|
|
1804
|
+
return create_server_routing_response(result?.route ?? null, result?.params ?? {}, url, manifest).response;
|
|
1805
|
+
}
|
|
1806
|
+
/**
|
|
1807
|
+
* @param {import('types').SSRClientRoute | null} route
|
|
1808
|
+
* @param {Partial<Record<string, string>>} params
|
|
1809
|
+
* @param {URL} url
|
|
1810
|
+
* @param {import('@sveltejs/kit').SSRManifest} manifest
|
|
1811
|
+
* @returns {{response: Response, body: string}}
|
|
1812
|
+
*/
|
|
1813
|
+
function create_server_routing_response(route, params, url, manifest) {
|
|
1814
|
+
const headers = new Headers({ "content-type": "application/javascript; charset=utf-8" });
|
|
1815
|
+
if (route) {
|
|
1816
|
+
const csr_route = generate_route_object(route, url, manifest);
|
|
1817
|
+
const body = `${create_css_import(route, url, manifest)}\nexport const route = ${csr_route}; export const params = ${JSON.stringify(params)};`;
|
|
1818
|
+
return {
|
|
1819
|
+
response: text(body, { headers }),
|
|
1820
|
+
body
|
|
1821
|
+
};
|
|
1822
|
+
} else return {
|
|
1823
|
+
response: text("", { headers }),
|
|
1824
|
+
body: ""
|
|
1825
|
+
};
|
|
1826
|
+
}
|
|
1827
|
+
/**
|
|
1828
|
+
* This function generates the client-side import for the CSS files that are
|
|
1829
|
+
* associated with the current route. Vite takes care of that when using
|
|
1830
|
+
* client-side route resolution, but for server-side resolution it does
|
|
1831
|
+
* not know about the CSS files automatically.
|
|
1832
|
+
*
|
|
1833
|
+
* @param {import('types').SSRClientRoute} route
|
|
1834
|
+
* @param {URL} url
|
|
1835
|
+
* @param {import('@sveltejs/kit').SSRManifest} manifest
|
|
1836
|
+
* @returns {string}
|
|
1837
|
+
*/
|
|
1838
|
+
function create_css_import(route, url, manifest) {
|
|
1839
|
+
const { errors, layouts, leaf } = route;
|
|
1840
|
+
let css = "";
|
|
1841
|
+
for (const node of [
|
|
1842
|
+
...errors,
|
|
1843
|
+
...layouts.map((l) => l?.[1]),
|
|
1844
|
+
leaf[1]
|
|
1845
|
+
]) {
|
|
1846
|
+
if (typeof node !== "number") continue;
|
|
1847
|
+
const node_css = manifest._.client.css?.[node];
|
|
1848
|
+
for (const css_path of node_css ?? []) css += `'${assets || base}/${css_path}',`;
|
|
1849
|
+
}
|
|
1850
|
+
if (!css) return "";
|
|
1851
|
+
return `${create_client_import(manifest._.client.start, url)}.then(x => x.load_css([${css}]));`;
|
|
1852
|
+
}
|
|
1853
|
+
//#endregion
|
|
1854
|
+
//#region ../../node_modules/.bun/@sveltejs+kit@2.61.0+aeb06e9cf8e23ab6/node_modules/@sveltejs/kit/src/runtime/server/page/render.js
|
|
1855
|
+
var updated = {
|
|
1856
|
+
...readable(false),
|
|
1857
|
+
check: () => false
|
|
1858
|
+
};
|
|
1859
|
+
/**
|
|
1860
|
+
* Creates the HTML response.
|
|
1861
|
+
* @param {{
|
|
1862
|
+
* branch: Array<import('./types.js').Loaded>;
|
|
1863
|
+
* fetched: Array<import('./types.js').Fetched>;
|
|
1864
|
+
* options: import('types').SSROptions;
|
|
1865
|
+
* manifest: import('@sveltejs/kit').SSRManifest;
|
|
1866
|
+
* state: import('types').SSRState;
|
|
1867
|
+
* page_config: { ssr: boolean; csr: boolean };
|
|
1868
|
+
* status: number;
|
|
1869
|
+
* error: App.Error | null;
|
|
1870
|
+
* event: import('@sveltejs/kit').RequestEvent;
|
|
1871
|
+
* event_state: import('types').RequestState;
|
|
1872
|
+
* resolve_opts: import('types').RequiredResolveOptions;
|
|
1873
|
+
* action_result?: import('@sveltejs/kit').ActionResult;
|
|
1874
|
+
* data_serializer: import('./types.js').ServerDataSerializer;
|
|
1875
|
+
* error_components?: Array<import('types').SSRComponent | undefined>
|
|
1876
|
+
* }} opts
|
|
1877
|
+
*/
|
|
1878
|
+
async function render_response({ branch, fetched, options, manifest, state, page_config, status, error = null, event, event_state, resolve_opts, action_result, data_serializer, error_components }) {
|
|
1879
|
+
if (state.prerendering) {
|
|
1880
|
+
if (options.csp.mode === "nonce") throw new Error("Cannot use prerendering if config.kit.csp.mode === \"nonce\"");
|
|
1881
|
+
if (options.app_template_contains_nonce) throw new Error("Cannot use prerendering if page template contains %sveltekit.nonce%");
|
|
1882
|
+
}
|
|
1883
|
+
const { client } = manifest._;
|
|
1884
|
+
const modulepreloads = new Set(client.imports);
|
|
1885
|
+
const stylesheets = new Set(client.stylesheets);
|
|
1886
|
+
const fonts = new Set(client.fonts);
|
|
1887
|
+
/**
|
|
1888
|
+
* The value of the Link header that is added to the response when not prerendering
|
|
1889
|
+
* @type {Set<string>}
|
|
1890
|
+
*/
|
|
1891
|
+
const link_headers = /* @__PURE__ */ new Set();
|
|
1892
|
+
/** @type {Map<string, string>} */
|
|
1893
|
+
const inline_styles = /* @__PURE__ */ new Map();
|
|
1894
|
+
/** @type {ReturnType<typeof options.root.render>} */
|
|
1895
|
+
let rendered;
|
|
1896
|
+
const form_value = action_result?.type === "success" || action_result?.type === "failure" ? action_result.data ?? null : null;
|
|
1897
|
+
/** @type {string} */
|
|
1898
|
+
let base$1 = base;
|
|
1899
|
+
/** @type {string} */
|
|
1900
|
+
let assets$1 = assets;
|
|
1901
|
+
/**
|
|
1902
|
+
* An expression that will evaluate in the client to determine the resolved base path.
|
|
1903
|
+
* We use a relative path when possible to support IPFS, the internet archive, etc.
|
|
1904
|
+
*/
|
|
1905
|
+
let base_expression = s(base);
|
|
1906
|
+
const csp = new Csp(options.csp, { prerender: !!state.prerendering });
|
|
1907
|
+
if (!state.prerendering?.fallback) {
|
|
1908
|
+
base$1 = event.url.pathname.slice(base.length).split("/").slice(2).map(() => "..").join("/") || ".";
|
|
1909
|
+
base_expression = `new URL(${s(base$1)}, location).pathname.slice(0, -1)`;
|
|
1910
|
+
if (!assets || assets[0] === "/" && assets !== "/_svelte_kit_assets") assets$1 = base$1;
|
|
1911
|
+
} else if (options.hash_routing) base_expression = "new URL('.', location).pathname.slice(0, -1)";
|
|
1912
|
+
if (page_config.ssr) {
|
|
1913
|
+
/** @type {Record<string, any>} */
|
|
1914
|
+
const props = {
|
|
1915
|
+
stores: {
|
|
1916
|
+
page: writable(null),
|
|
1917
|
+
navigating: writable(null),
|
|
1918
|
+
updated
|
|
1919
|
+
},
|
|
1920
|
+
constructors: await Promise.all(branch.map(({ node }) => {
|
|
1921
|
+
if (!node.component) throw new Error(`Missing +page.svelte component for route ${event.route.id}`);
|
|
1922
|
+
return node.component();
|
|
1923
|
+
})),
|
|
1924
|
+
form: form_value
|
|
1925
|
+
};
|
|
1926
|
+
if (error_components) {
|
|
1927
|
+
if (error) props.error = error;
|
|
1928
|
+
props.errors = error_components;
|
|
1929
|
+
}
|
|
1930
|
+
let data = {};
|
|
1931
|
+
for (let i = 0; i < branch.length; i += 1) {
|
|
1932
|
+
data = {
|
|
1933
|
+
...data,
|
|
1934
|
+
...branch[i].data
|
|
1935
|
+
};
|
|
1936
|
+
props[`data_${i}`] = data;
|
|
1937
|
+
}
|
|
1938
|
+
props.page = {
|
|
1939
|
+
error,
|
|
1940
|
+
params: event.params,
|
|
1941
|
+
route: event.route,
|
|
1942
|
+
status,
|
|
1943
|
+
url: event.url,
|
|
1944
|
+
data,
|
|
1945
|
+
form: form_value,
|
|
1946
|
+
state: {}
|
|
1947
|
+
};
|
|
1948
|
+
const render_opts = {
|
|
1949
|
+
context: new Map([["__request__", { page: props.page }]]),
|
|
1950
|
+
csp: csp.script_needs_nonce ? { nonce: csp.nonce } : { hash: csp.script_needs_hash },
|
|
1951
|
+
transformError: error_components ? async (e) => {
|
|
1952
|
+
if (isRedirect(e)) throw e;
|
|
1953
|
+
const transformed = await handle_error_and_jsonify(event, event_state, options, e);
|
|
1954
|
+
props.page.error = props.error = error = transformed;
|
|
1955
|
+
props.page.status = status = get_status(e);
|
|
1956
|
+
return transformed;
|
|
1957
|
+
} : void 0
|
|
1958
|
+
};
|
|
1959
|
+
try {
|
|
1960
|
+
rendered = await with_request_store({
|
|
1961
|
+
event,
|
|
1962
|
+
state: {
|
|
1963
|
+
...event_state,
|
|
1964
|
+
is_in_render: true
|
|
1965
|
+
}
|
|
1966
|
+
}, async () => {
|
|
1967
|
+
override({
|
|
1968
|
+
base: base$1,
|
|
1969
|
+
assets: assets$1
|
|
1970
|
+
});
|
|
1971
|
+
const maybe_promise = options.root.render(props, render_opts);
|
|
1972
|
+
const rendered = options.async && "then" in maybe_promise ? maybe_promise.then((r) => r) : maybe_promise;
|
|
1973
|
+
if (options.async) reset();
|
|
1974
|
+
const { head, html, css, hashes } = options.async ? await rendered : rendered;
|
|
1975
|
+
if (hashes) csp.add_script_hashes(hashes.script);
|
|
1976
|
+
return {
|
|
1977
|
+
head,
|
|
1978
|
+
html,
|
|
1979
|
+
css,
|
|
1980
|
+
hashes
|
|
1981
|
+
};
|
|
1982
|
+
});
|
|
1983
|
+
} finally {
|
|
1984
|
+
reset();
|
|
1985
|
+
}
|
|
1986
|
+
} else rendered = {
|
|
1987
|
+
head: "",
|
|
1988
|
+
html: "",
|
|
1989
|
+
css: {
|
|
1990
|
+
code: "",
|
|
1991
|
+
map: null
|
|
1992
|
+
},
|
|
1993
|
+
hashes: { script: [] }
|
|
1994
|
+
};
|
|
1995
|
+
for (const { node } of branch) {
|
|
1996
|
+
for (const url of node.imports) modulepreloads.add(url);
|
|
1997
|
+
for (const url of node.stylesheets) stylesheets.add(url);
|
|
1998
|
+
for (const url of node.fonts) fonts.add(url);
|
|
1999
|
+
if (node.inline_styles && !client.inline) Object.entries(await node.inline_styles()).forEach(([filename, css]) => {
|
|
2000
|
+
if (typeof css === "string") {
|
|
2001
|
+
inline_styles.set(filename, css);
|
|
2002
|
+
return;
|
|
2003
|
+
}
|
|
2004
|
+
inline_styles.set(filename, css(`${assets$1}/${app_dir}/immutable/assets`, assets$1));
|
|
2005
|
+
});
|
|
2006
|
+
}
|
|
2007
|
+
const head = new Head(rendered.head, !!state.prerendering);
|
|
2008
|
+
let body = rendered.html;
|
|
2009
|
+
/** @param {string} path */
|
|
2010
|
+
const prefixed = (path) => {
|
|
2011
|
+
if (path.startsWith("/")) return base + path;
|
|
2012
|
+
return `${assets$1}/${path}`;
|
|
2013
|
+
};
|
|
2014
|
+
const style = client.inline ? client.inline?.style : Array.from(inline_styles.values()).join("\n");
|
|
2015
|
+
if (style) {
|
|
2016
|
+
const attributes = [];
|
|
2017
|
+
if (csp.style_needs_nonce) attributes.push(`nonce="${csp.nonce}"`);
|
|
2018
|
+
csp.add_style(style);
|
|
2019
|
+
head.add_style(style, attributes);
|
|
2020
|
+
}
|
|
2021
|
+
for (const dep of stylesheets) {
|
|
2022
|
+
const path = prefixed(dep);
|
|
2023
|
+
const attributes = ["rel=\"stylesheet\""];
|
|
2024
|
+
if (inline_styles.has(dep)) attributes.push("disabled", "media=\"(max-width: 0)\"");
|
|
2025
|
+
else if (resolve_opts.preload({
|
|
2026
|
+
type: "css",
|
|
2027
|
+
path
|
|
2028
|
+
})) link_headers.add(`<${encodeURI(path)}>; rel="preload"; as="style"; nopush`);
|
|
2029
|
+
head.add_stylesheet(path, attributes);
|
|
2030
|
+
}
|
|
2031
|
+
for (const dep of fonts) {
|
|
2032
|
+
const path = prefixed(dep);
|
|
2033
|
+
if (resolve_opts.preload({
|
|
2034
|
+
type: "font",
|
|
2035
|
+
path
|
|
2036
|
+
})) {
|
|
2037
|
+
const ext = dep.slice(dep.lastIndexOf(".") + 1);
|
|
2038
|
+
head.add_link_tag(path, [
|
|
2039
|
+
"rel=\"preload\"",
|
|
2040
|
+
"as=\"font\"",
|
|
2041
|
+
`type="font/${ext}"`,
|
|
2042
|
+
"crossorigin"
|
|
2043
|
+
]);
|
|
2044
|
+
link_headers.add(`<${encodeURI(path)}>; rel="preload"; as="font"; type="font/${ext}"; crossorigin; nopush`);
|
|
2045
|
+
}
|
|
2046
|
+
}
|
|
2047
|
+
const global = get_global_name(options);
|
|
2048
|
+
const { data, chunks } = data_serializer.get_data(csp);
|
|
2049
|
+
if (page_config.ssr && page_config.csr) body += `\n\t\t\t${fetched.map((item) => serialize_data(item, resolve_opts.filterSerializedResponseHeaders, !!state.prerendering)).join("\n ")}`;
|
|
2050
|
+
if (page_config.csr) {
|
|
2051
|
+
const route = manifest._.client.routes?.find((r) => r.id === event.route.id) ?? null;
|
|
2052
|
+
if (client.uses_env_dynamic_public && state.prerendering) modulepreloads.add(`${app_dir}/env.js`);
|
|
2053
|
+
if (!client.inline) {
|
|
2054
|
+
const included_modulepreloads = Array.from(modulepreloads, (dep) => prefixed(dep)).filter((path) => resolve_opts.preload({
|
|
2055
|
+
type: "js",
|
|
2056
|
+
path
|
|
2057
|
+
}));
|
|
2058
|
+
for (const path of included_modulepreloads) {
|
|
2059
|
+
link_headers.add(`<${encodeURI(path)}>; rel="modulepreload"; nopush`);
|
|
2060
|
+
if (options.preload_strategy !== "modulepreload") head.add_script_preload(path);
|
|
2061
|
+
else head.add_link_tag(path, ["rel=\"modulepreload\""]);
|
|
2062
|
+
}
|
|
2063
|
+
}
|
|
2064
|
+
if (manifest._.client.routes && state.prerendering && !state.prerendering.fallback) {
|
|
2065
|
+
const pathname = add_resolution_suffix(event.url.pathname);
|
|
2066
|
+
state.prerendering.dependencies.set(pathname, create_server_routing_response(route, event.params, new URL(pathname, event.url), manifest));
|
|
2067
|
+
}
|
|
2068
|
+
const blocks = [];
|
|
2069
|
+
const load_env_eagerly = client.uses_env_dynamic_public && state.prerendering;
|
|
2070
|
+
const properties = [`base: ${base_expression}`];
|
|
2071
|
+
if (assets) properties.push(`assets: ${s(assets)}`);
|
|
2072
|
+
if (client.uses_env_dynamic_public) properties.push(`env: ${load_env_eagerly ? "null" : s(public_env)}`);
|
|
2073
|
+
if (chunks) {
|
|
2074
|
+
blocks.push("const deferred = new Map();");
|
|
2075
|
+
properties.push(`defer: (id) => new Promise((fulfil, reject) => {
|
|
2076
|
+
deferred.set(id, { fulfil, reject });
|
|
2077
|
+
})`);
|
|
2078
|
+
let app_declaration = "";
|
|
2079
|
+
if (Object.keys(options.hooks.transport).length > 0) if (client.inline) app_declaration = `const app = __sveltekit_${options.version_hash}.app.app;`;
|
|
2080
|
+
else if (client.app) app_declaration = `const app = await import(${s(prefixed(client.app))});`;
|
|
2081
|
+
else app_declaration = `const { app } = await import(${s(prefixed(client.start))});`;
|
|
2082
|
+
const prelude = app_declaration ? `${app_declaration}
|
|
2083
|
+
const [data, error] = fn(app);` : `const [data, error] = fn();`;
|
|
2084
|
+
properties.push(`resolve: async (id, fn) => {
|
|
2085
|
+
${prelude}
|
|
2086
|
+
|
|
2087
|
+
const try_to_resolve = () => {
|
|
2088
|
+
if (!deferred.has(id)) {
|
|
2089
|
+
setTimeout(try_to_resolve, 0);
|
|
2090
|
+
return;
|
|
2091
|
+
}
|
|
2092
|
+
const { fulfil, reject } = deferred.get(id);
|
|
2093
|
+
deferred.delete(id);
|
|
2094
|
+
if (error) reject(error);
|
|
2095
|
+
else fulfil(data);
|
|
2096
|
+
}
|
|
2097
|
+
try_to_resolve();
|
|
2098
|
+
}`);
|
|
2099
|
+
}
|
|
2100
|
+
blocks.push(`${global} = {
|
|
2101
|
+
${properties.join(",\n ")}
|
|
2102
|
+
};`);
|
|
2103
|
+
const args = ["element"];
|
|
2104
|
+
blocks.push("const element = document.currentScript.parentElement;");
|
|
2105
|
+
if (page_config.ssr) {
|
|
2106
|
+
const serialized = {
|
|
2107
|
+
form: "null",
|
|
2108
|
+
error: "null"
|
|
2109
|
+
};
|
|
2110
|
+
if (form_value) serialized.form = uneval_action_response(form_value, event.route.id, options.hooks.transport);
|
|
2111
|
+
if (error) serialized.error = uneval(error);
|
|
2112
|
+
const hydrate = [
|
|
2113
|
+
`node_ids: [${branch.map(({ node }) => node.index).join(", ")}]`,
|
|
2114
|
+
`data: ${data}`,
|
|
2115
|
+
`form: ${serialized.form}`,
|
|
2116
|
+
`error: ${serialized.error}`
|
|
2117
|
+
];
|
|
2118
|
+
if (status !== 200) hydrate.push(`status: ${status}`);
|
|
2119
|
+
if (manifest._.client.routes) {
|
|
2120
|
+
if (route) {
|
|
2121
|
+
const stringified = generate_route_object(route, event.url, manifest).replaceAll("\n", "\n ");
|
|
2122
|
+
hydrate.push(`params: ${uneval(event.params)}`, `server_route: ${stringified}`);
|
|
2123
|
+
}
|
|
2124
|
+
} else if (options.embedded) hydrate.push(`params: ${uneval(event.params)}`, `route: ${s(event.route)}`);
|
|
2125
|
+
const indent = " ".repeat(load_env_eagerly ? 7 : 6);
|
|
2126
|
+
args.push(`{\n${indent}\t${hydrate.join(`,\n${indent}\t`)}\n${indent}}`);
|
|
2127
|
+
}
|
|
2128
|
+
const { remote } = event_state;
|
|
2129
|
+
let serialized_query_data = "";
|
|
2130
|
+
let serialized_prerender_data = "";
|
|
2131
|
+
if (remote.data) {
|
|
2132
|
+
/** @type {Record<string, any>} */
|
|
2133
|
+
const query = {};
|
|
2134
|
+
/** @type {Record<string, any>} */
|
|
2135
|
+
const prerender = {};
|
|
2136
|
+
for (const [internals, cache] of remote.data) {
|
|
2137
|
+
if (!internals.id) continue;
|
|
2138
|
+
for (const key in cache) {
|
|
2139
|
+
const entry = cache[key];
|
|
2140
|
+
if (!entry.serialize) continue;
|
|
2141
|
+
const remote_key = create_remote_key(internals.id, key);
|
|
2142
|
+
const store = internals.type === "prerender" ? prerender : query;
|
|
2143
|
+
if (event_state.remote.refreshes?.has(remote_key) || event_state.remote.reconnects?.has(remote_key)) store[remote_key] = await entry.data;
|
|
2144
|
+
else {
|
|
2145
|
+
const result = await Promise.race([Promise.resolve(entry.data).then((v) => ({
|
|
2146
|
+
settled: true,
|
|
2147
|
+
value: v
|
|
2148
|
+
}), (e) => ({
|
|
2149
|
+
settled: true,
|
|
2150
|
+
error: e
|
|
2151
|
+
})), new Promise((resolve) => {
|
|
2152
|
+
queueMicrotask(() => resolve({ settled: false }));
|
|
2153
|
+
})]);
|
|
2154
|
+
if (result.settled) {
|
|
2155
|
+
if ("error" in result) throw result.error;
|
|
2156
|
+
store[remote_key] = result.value;
|
|
2157
|
+
}
|
|
2158
|
+
}
|
|
2159
|
+
}
|
|
2160
|
+
}
|
|
2161
|
+
const replacer = create_replacer(options.hooks.transport);
|
|
2162
|
+
if (Object.keys(query).length > 0) serialized_query_data = `${global}.query = ${uneval(query, replacer)};\n\n\t\t\t\t\t\t`;
|
|
2163
|
+
if (Object.keys(prerender).length > 0) serialized_prerender_data = `${global}.prerender = ${uneval(prerender, replacer)};\n\n\t\t\t\t\t\t`;
|
|
2164
|
+
}
|
|
2165
|
+
const serialized_remote_data = `${serialized_query_data}${serialized_prerender_data}`;
|
|
2166
|
+
const boot = client.inline ? `${client.inline.script}
|
|
2167
|
+
|
|
2168
|
+
${serialized_remote_data}${global}.app.start(${args.join(", ")});` : client.app ? `Promise.all([
|
|
2169
|
+
import(${s(prefixed(client.start))}),
|
|
2170
|
+
import(${s(prefixed(client.app))})
|
|
2171
|
+
]).then(([kit, app]) => {
|
|
2172
|
+
${serialized_remote_data}kit.start(app, ${args.join(", ")});
|
|
2173
|
+
});` : `import(${s(prefixed(client.start))}).then((app) => {
|
|
2174
|
+
${serialized_remote_data}app.start(${args.join(", ")})
|
|
2175
|
+
});`;
|
|
2176
|
+
if (load_env_eagerly) blocks.push(`import(${s(`${base$1}/${app_dir}/env.js`)}).then(({ env }) => {
|
|
2177
|
+
${global}.env = env;
|
|
2178
|
+
|
|
2179
|
+
${boot.replace(/\n/g, "\n ")}
|
|
2180
|
+
});`);
|
|
2181
|
+
else blocks.push(boot);
|
|
2182
|
+
if (options.service_worker) {
|
|
2183
|
+
let opts = "";
|
|
2184
|
+
if (options.service_worker_options != null) opts = `, ${s({ ...options.service_worker_options })}`;
|
|
2185
|
+
blocks.push(`if ('serviceWorker' in navigator) {
|
|
2186
|
+
const script_url = '${prefixed("service-worker.js")}';
|
|
2187
|
+
const policy = globalThis?.window?.trustedTypes?.createPolicy(
|
|
2188
|
+
'sveltekit-trusted-url',
|
|
2189
|
+
{ createScriptURL(url) { return url; } }
|
|
2190
|
+
);
|
|
2191
|
+
const sanitised = policy?.createScriptURL(script_url) ?? script_url;
|
|
2192
|
+
addEventListener('load', function () {
|
|
2193
|
+
navigator.serviceWorker.register(sanitised${opts});
|
|
2194
|
+
});
|
|
2195
|
+
}`);
|
|
2196
|
+
}
|
|
2197
|
+
const init_app = `
|
|
2198
|
+
{
|
|
2199
|
+
${blocks.join("\n\n ")}
|
|
2200
|
+
}
|
|
2201
|
+
`;
|
|
2202
|
+
csp.add_script(init_app);
|
|
2203
|
+
body += `\n\t\t\t<script${csp.script_needs_nonce ? ` nonce="${csp.nonce}"` : ""}>${init_app}<\/script>\n\t\t`;
|
|
2204
|
+
}
|
|
2205
|
+
const headers = new Headers({
|
|
2206
|
+
"x-sveltekit-page": "true",
|
|
2207
|
+
"content-type": "text/html"
|
|
2208
|
+
});
|
|
2209
|
+
if (state.prerendering) {
|
|
2210
|
+
const csp_headers = csp.csp_provider.get_meta();
|
|
2211
|
+
if (csp_headers) head.add_http_equiv(csp_headers);
|
|
2212
|
+
if (state.prerendering.cache) head.add_http_equiv(`<meta http-equiv="cache-control" content="${state.prerendering.cache}">`);
|
|
2213
|
+
} else {
|
|
2214
|
+
const csp_header = csp.csp_provider.get_header();
|
|
2215
|
+
if (csp_header) headers.set("content-security-policy", csp_header);
|
|
2216
|
+
const report_only_header = csp.report_only_provider.get_header();
|
|
2217
|
+
if (report_only_header) headers.set("content-security-policy-report-only", report_only_header);
|
|
2218
|
+
if (link_headers.size) headers.set("link", Array.from(link_headers).join(", "));
|
|
2219
|
+
}
|
|
2220
|
+
const html = options.templates.app({
|
|
2221
|
+
head: head.build(),
|
|
2222
|
+
body,
|
|
2223
|
+
assets: assets$1,
|
|
2224
|
+
nonce: csp.nonce,
|
|
2225
|
+
env: public_env
|
|
2226
|
+
});
|
|
2227
|
+
const transformed = await resolve_opts.transformPageChunk({
|
|
2228
|
+
html,
|
|
2229
|
+
done: true
|
|
2230
|
+
}) || "";
|
|
2231
|
+
if (!chunks) headers.set("etag", `"${hash(transformed)}"`);
|
|
2232
|
+
return !chunks ? text(transformed, {
|
|
2233
|
+
status,
|
|
2234
|
+
headers
|
|
2235
|
+
}) : new Response(new ReadableStream({
|
|
2236
|
+
async start(controller) {
|
|
2237
|
+
controller.enqueue(text_encoder.encode(transformed + "\n"));
|
|
2238
|
+
for await (const chunk of chunks) if (chunk.length) controller.enqueue(text_encoder.encode(chunk));
|
|
2239
|
+
controller.close();
|
|
2240
|
+
},
|
|
2241
|
+
type: "bytes"
|
|
2242
|
+
}), { headers });
|
|
2243
|
+
}
|
|
2244
|
+
var Head = class {
|
|
2245
|
+
#rendered;
|
|
2246
|
+
#prerendering;
|
|
2247
|
+
/** @type {string[]} */
|
|
2248
|
+
#http_equiv = [];
|
|
2249
|
+
/** @type {string[]} */
|
|
2250
|
+
#link_tags = [];
|
|
2251
|
+
/** @type {string[]} */
|
|
2252
|
+
#script_preloads = [];
|
|
2253
|
+
/** @type {string[]} */
|
|
2254
|
+
#style_tags = [];
|
|
2255
|
+
/** @type {string[]} */
|
|
2256
|
+
#stylesheet_links = [];
|
|
2257
|
+
/**
|
|
2258
|
+
* @param {string} rendered
|
|
2259
|
+
* @param {boolean} prerendering
|
|
2260
|
+
*/
|
|
2261
|
+
constructor(rendered, prerendering) {
|
|
2262
|
+
this.#rendered = rendered;
|
|
2263
|
+
this.#prerendering = prerendering;
|
|
2264
|
+
}
|
|
2265
|
+
build() {
|
|
2266
|
+
return [
|
|
2267
|
+
...this.#http_equiv,
|
|
2268
|
+
...this.#link_tags,
|
|
2269
|
+
...this.#script_preloads,
|
|
2270
|
+
this.#rendered,
|
|
2271
|
+
...this.#style_tags,
|
|
2272
|
+
...this.#stylesheet_links
|
|
2273
|
+
].join("\n ");
|
|
2274
|
+
}
|
|
2275
|
+
/**
|
|
2276
|
+
* @param {string} style
|
|
2277
|
+
* @param {string[]} attributes
|
|
2278
|
+
*/
|
|
2279
|
+
add_style(style, attributes) {
|
|
2280
|
+
this.#style_tags.push(`<style${attributes.length ? " " + attributes.join(" ") : ""}>${style}</style>`);
|
|
2281
|
+
}
|
|
2282
|
+
/**
|
|
2283
|
+
* @param {string} href
|
|
2284
|
+
* @param {string[]} attributes
|
|
2285
|
+
*/
|
|
2286
|
+
add_stylesheet(href, attributes) {
|
|
2287
|
+
this.#stylesheet_links.push(`<link href="${href}" ${attributes.join(" ")}>`);
|
|
2288
|
+
}
|
|
2289
|
+
/** @param {string} href */
|
|
2290
|
+
add_script_preload(href) {
|
|
2291
|
+
this.#script_preloads.push(`<link rel="preload" as="script" crossorigin="anonymous" href="${href}">`);
|
|
2292
|
+
}
|
|
2293
|
+
/**
|
|
2294
|
+
* @param {string} href
|
|
2295
|
+
* @param {string[]} attributes
|
|
2296
|
+
*/
|
|
2297
|
+
add_link_tag(href, attributes) {
|
|
2298
|
+
if (!this.#prerendering) return;
|
|
2299
|
+
this.#link_tags.push(`<link href="${href}" ${attributes.join(" ")}>`);
|
|
2300
|
+
}
|
|
2301
|
+
/** @param {string} tag */
|
|
2302
|
+
add_http_equiv(tag) {
|
|
2303
|
+
if (!this.#prerendering) return;
|
|
2304
|
+
this.#http_equiv.push(tag);
|
|
2305
|
+
}
|
|
2306
|
+
};
|
|
2307
|
+
//#endregion
|
|
2308
|
+
//#region ../../node_modules/.bun/@sveltejs+kit@2.61.0+aeb06e9cf8e23ab6/node_modules/@sveltejs/kit/src/utils/page_nodes.js
|
|
2309
|
+
var PageNodes = class {
|
|
2310
|
+
/** All layout nodes and the page node, if any */
|
|
2311
|
+
data;
|
|
2312
|
+
/**
|
|
2313
|
+
* @param {Array<import('types').SSRNode | undefined>} nodes
|
|
2314
|
+
*/
|
|
2315
|
+
constructor(nodes) {
|
|
2316
|
+
this.data = nodes;
|
|
2317
|
+
}
|
|
2318
|
+
layouts() {
|
|
2319
|
+
return this.data.slice(0, -1);
|
|
2320
|
+
}
|
|
2321
|
+
page() {
|
|
2322
|
+
return this.data.at(-1);
|
|
2323
|
+
}
|
|
2324
|
+
validate() {
|
|
2325
|
+
for (const layout of this.layouts()) if (layout) {
|
|
2326
|
+
validate_layout_server_exports(layout.server, layout.server_id);
|
|
2327
|
+
validate_layout_exports(layout.universal, layout.universal_id);
|
|
2328
|
+
}
|
|
2329
|
+
const page = this.page();
|
|
2330
|
+
if (page) {
|
|
2331
|
+
validate_page_server_exports(page.server, page.server_id);
|
|
2332
|
+
validate_page_exports(page.universal, page.universal_id);
|
|
2333
|
+
}
|
|
2334
|
+
}
|
|
2335
|
+
/**
|
|
2336
|
+
* @template {'prerender' | 'ssr' | 'csr' | 'trailingSlash'} Option
|
|
2337
|
+
* @param {Option} option
|
|
2338
|
+
* @returns {Value | undefined}
|
|
2339
|
+
*/
|
|
2340
|
+
#get_option(option) {
|
|
2341
|
+
/** @typedef {(import('types').UniversalNode | import('types').ServerNode)[Option]} Value */
|
|
2342
|
+
return this.data.reduce((value, node) => {
|
|
2343
|
+
return node?.universal?.[option] ?? node?.server?.[option] ?? value;
|
|
2344
|
+
}, void 0);
|
|
2345
|
+
}
|
|
2346
|
+
csr() {
|
|
2347
|
+
return this.#get_option("csr") ?? true;
|
|
2348
|
+
}
|
|
2349
|
+
ssr() {
|
|
2350
|
+
return this.#get_option("ssr") ?? true;
|
|
2351
|
+
}
|
|
2352
|
+
prerender() {
|
|
2353
|
+
return this.#get_option("prerender") ?? false;
|
|
2354
|
+
}
|
|
2355
|
+
trailing_slash() {
|
|
2356
|
+
return this.#get_option("trailingSlash") ?? "never";
|
|
2357
|
+
}
|
|
2358
|
+
get_config() {
|
|
2359
|
+
/** @type {any} */
|
|
2360
|
+
let current = {};
|
|
2361
|
+
for (const node of this.data) {
|
|
2362
|
+
if (!node?.universal?.config && !node?.server?.config) continue;
|
|
2363
|
+
current = {
|
|
2364
|
+
...current,
|
|
2365
|
+
...node?.universal?.config,
|
|
2366
|
+
...node?.server?.config
|
|
2367
|
+
};
|
|
2368
|
+
}
|
|
2369
|
+
return Object.keys(current).length ? current : void 0;
|
|
2370
|
+
}
|
|
2371
|
+
should_prerender_data() {
|
|
2372
|
+
return this.data.some((node) => node?.server?.load || node?.server?.trailingSlash !== void 0);
|
|
2373
|
+
}
|
|
2374
|
+
};
|
|
2375
|
+
//#endregion
|
|
2376
|
+
//#region ../../node_modules/.bun/@sveltejs+kit@2.61.0+aeb06e9cf8e23ab6/node_modules/@sveltejs/kit/src/runtime/server/page/respond_with_error.js
|
|
2377
|
+
/**
|
|
2378
|
+
* @typedef {import('./types.js').Loaded} Loaded
|
|
2379
|
+
*/
|
|
2380
|
+
/**
|
|
2381
|
+
* @param {{
|
|
2382
|
+
* event: import('@sveltejs/kit').RequestEvent;
|
|
2383
|
+
* event_state: import('types').RequestState;
|
|
2384
|
+
* options: import('types').SSROptions;
|
|
2385
|
+
* manifest: import('@sveltejs/kit').SSRManifest;
|
|
2386
|
+
* state: import('types').SSRState;
|
|
2387
|
+
* status: number;
|
|
2388
|
+
* error: unknown;
|
|
2389
|
+
* resolve_opts: import('types').RequiredResolveOptions;
|
|
2390
|
+
* }} opts
|
|
2391
|
+
*/
|
|
2392
|
+
async function respond_with_error({ event, event_state, options, manifest, state, status, error, resolve_opts }) {
|
|
2393
|
+
if (event.request.headers.get("x-sveltekit-error")) return static_error_page(
|
|
2394
|
+
options,
|
|
2395
|
+
status,
|
|
2396
|
+
/** @type {Error} */
|
|
2397
|
+
error.message
|
|
2398
|
+
);
|
|
2399
|
+
/** @type {import('./types.js').Fetched[]} */
|
|
2400
|
+
const fetched = [];
|
|
2401
|
+
try {
|
|
2402
|
+
const branch = [];
|
|
2403
|
+
const default_layout = await manifest._.nodes[0]();
|
|
2404
|
+
const nodes = new PageNodes([default_layout]);
|
|
2405
|
+
const ssr = nodes.ssr();
|
|
2406
|
+
const csr = nodes.csr();
|
|
2407
|
+
const data_serializer = server_data_serializer(event, event_state, options);
|
|
2408
|
+
if (ssr) {
|
|
2409
|
+
state.error = true;
|
|
2410
|
+
const server_data_promise = load_server_data({
|
|
2411
|
+
event,
|
|
2412
|
+
event_state,
|
|
2413
|
+
state,
|
|
2414
|
+
node: default_layout,
|
|
2415
|
+
parent: async () => ({})
|
|
2416
|
+
});
|
|
2417
|
+
const server_data = await server_data_promise;
|
|
2418
|
+
data_serializer.add_node(0, server_data);
|
|
2419
|
+
const data = await load_data({
|
|
2420
|
+
event,
|
|
2421
|
+
event_state,
|
|
2422
|
+
fetched,
|
|
2423
|
+
node: default_layout,
|
|
2424
|
+
parent: async () => ({}),
|
|
2425
|
+
resolve_opts,
|
|
2426
|
+
server_data_promise,
|
|
2427
|
+
state,
|
|
2428
|
+
csr
|
|
2429
|
+
});
|
|
2430
|
+
branch.push({
|
|
2431
|
+
node: default_layout,
|
|
2432
|
+
server_data,
|
|
2433
|
+
data
|
|
2434
|
+
}, {
|
|
2435
|
+
node: await manifest._.nodes[1](),
|
|
2436
|
+
data: null,
|
|
2437
|
+
server_data: null
|
|
2438
|
+
});
|
|
2439
|
+
}
|
|
2440
|
+
return await render_response({
|
|
2441
|
+
options,
|
|
2442
|
+
manifest,
|
|
2443
|
+
state,
|
|
2444
|
+
page_config: {
|
|
2445
|
+
ssr,
|
|
2446
|
+
csr
|
|
2447
|
+
},
|
|
2448
|
+
status,
|
|
2449
|
+
error: await handle_error_and_jsonify(event, event_state, options, error),
|
|
2450
|
+
branch,
|
|
2451
|
+
error_components: [],
|
|
2452
|
+
fetched,
|
|
2453
|
+
event,
|
|
2454
|
+
event_state,
|
|
2455
|
+
resolve_opts,
|
|
2456
|
+
data_serializer
|
|
2457
|
+
});
|
|
2458
|
+
} catch (e) {
|
|
2459
|
+
if (e instanceof Redirect) return redirect_response(e.status, e.location);
|
|
2460
|
+
return static_error_page(options, get_status(e), (await handle_error_and_jsonify(event, event_state, options, e)).message);
|
|
2461
|
+
}
|
|
2462
|
+
}
|
|
2463
|
+
//#endregion
|
|
2464
|
+
//#region ../../node_modules/.bun/@sveltejs+kit@2.61.0+aeb06e9cf8e23ab6/node_modules/@sveltejs/kit/src/runtime/server/remote.js
|
|
2465
|
+
/** @import { ActionResult, RemoteForm, RequestEvent, SSRManifest } from '@sveltejs/kit' */
|
|
2466
|
+
/** @import { RemoteFormInternals, RemoteFunctionResponse, RemoteInternals, RequestState, SSROptions } from 'types' */
|
|
2467
|
+
/** @type {typeof handle_remote_call_internal} */
|
|
2468
|
+
async function handle_remote_call(event, state, options, manifest, id) {
|
|
2469
|
+
return record_span({
|
|
2470
|
+
name: "sveltekit.remote.call",
|
|
2471
|
+
attributes: { },
|
|
2472
|
+
fn: (current) => {
|
|
2473
|
+
const traced_event = merge_tracing(event, current);
|
|
2474
|
+
return with_request_store({
|
|
2475
|
+
event: traced_event,
|
|
2476
|
+
state
|
|
2477
|
+
}, () => handle_remote_call_internal(traced_event, state, options, manifest, id));
|
|
2478
|
+
}
|
|
2479
|
+
});
|
|
2480
|
+
}
|
|
2481
|
+
/**
|
|
2482
|
+
* @param {RequestEvent} event
|
|
2483
|
+
* @param {RequestState} state
|
|
2484
|
+
* @param {SSROptions} options
|
|
2485
|
+
* @param {SSRManifest} manifest
|
|
2486
|
+
* @param {string} id
|
|
2487
|
+
*/
|
|
2488
|
+
async function handle_remote_call_internal(event, state, options, manifest, id) {
|
|
2489
|
+
const [hash, name, additional_args] = id.split("/");
|
|
2490
|
+
const remotes = manifest._.remotes;
|
|
2491
|
+
if (!remotes[hash]) error(404);
|
|
2492
|
+
const fn = (await remotes[hash]()).default[name];
|
|
2493
|
+
if (!fn) error(404);
|
|
2494
|
+
/** @type {RemoteInternals} */
|
|
2495
|
+
const internals = fn.__;
|
|
2496
|
+
const transport = options.hooks.transport;
|
|
2497
|
+
event.tracing.current.setAttributes({
|
|
2498
|
+
"sveltekit.remote.call.type": internals.type,
|
|
2499
|
+
"sveltekit.remote.call.name": internals.name
|
|
2500
|
+
});
|
|
2501
|
+
try {
|
|
2502
|
+
if (internals.type === "query_batch") {
|
|
2503
|
+
if (event.request.method !== "POST") throw new SvelteKitError(405, "Method Not Allowed", `\`query.batch\` functions must be invoked via POST request, not ${event.request.method}`);
|
|
2504
|
+
/** @type {{ payloads: string[] }} */
|
|
2505
|
+
const { payloads } = await event.request.json();
|
|
2506
|
+
const args = await Promise.all(payloads.map((payload) => parse_remote_arg(payload, transport)));
|
|
2507
|
+
return json({
|
|
2508
|
+
type: "result",
|
|
2509
|
+
result: stringify(await with_request_store({
|
|
2510
|
+
event,
|
|
2511
|
+
state
|
|
2512
|
+
}, () => internals.run(args, options)), transport)
|
|
2513
|
+
});
|
|
2514
|
+
}
|
|
2515
|
+
if (internals.type === "form") {
|
|
2516
|
+
if (event.request.method !== "POST") throw new SvelteKitError(405, "Method Not Allowed", `\`form\` functions must be invoked via POST request, not ${event.request.method}`);
|
|
2517
|
+
if (!is_form_content_type(event.request)) throw new SvelteKitError(415, "Unsupported Media Type", `\`form\` functions expect form-encoded data — received ${event.request.headers.get("content-type")}`);
|
|
2518
|
+
const { data, meta, form_data } = await deserialize_binary_form(event.request);
|
|
2519
|
+
state.remote.requested = create_requested_map(meta.remote_refreshes);
|
|
2520
|
+
if (additional_args && !("id" in data)) data.id = JSON.parse(decodeURIComponent(additional_args));
|
|
2521
|
+
const fn = internals.fn;
|
|
2522
|
+
const result = await with_request_store({
|
|
2523
|
+
event,
|
|
2524
|
+
state
|
|
2525
|
+
}, () => fn(data, meta, form_data));
|
|
2526
|
+
return json({
|
|
2527
|
+
type: "result",
|
|
2528
|
+
result: stringify(result, transport),
|
|
2529
|
+
refreshes: result.issues ? void 0 : await serialize_singleflight(state.remote.refreshes),
|
|
2530
|
+
reconnects: result.issues ? void 0 : await serialize_singleflight(state.remote.reconnects)
|
|
2531
|
+
});
|
|
2532
|
+
}
|
|
2533
|
+
if (internals.type === "command") {
|
|
2534
|
+
/** @type {{ payload: string, refreshes?: string[] }} */
|
|
2535
|
+
const { payload, refreshes } = await event.request.json();
|
|
2536
|
+
state.remote.requested = create_requested_map(refreshes);
|
|
2537
|
+
const arg = parse_remote_arg(payload, transport);
|
|
2538
|
+
return json({
|
|
2539
|
+
type: "result",
|
|
2540
|
+
result: stringify(await with_request_store({
|
|
2541
|
+
event,
|
|
2542
|
+
state
|
|
2543
|
+
}, () => fn(arg)), transport),
|
|
2544
|
+
refreshes: await serialize_singleflight(state.remote.refreshes),
|
|
2545
|
+
reconnects: await serialize_singleflight(state.remote.reconnects)
|
|
2546
|
+
});
|
|
2547
|
+
}
|
|
2548
|
+
if (internals.type === "query_live") {
|
|
2549
|
+
if (event.request.method !== "GET") throw new SvelteKitError(405, "Method Not Allowed", `\`query.live\` functions must be invoked via GET request, not ${event.request.method}`);
|
|
2550
|
+
const payload = new URL(event.request.url).searchParams.get("payload");
|
|
2551
|
+
const generator = internals.run(event, state, parse_remote_arg(payload, transport));
|
|
2552
|
+
const encoder = new TextEncoder();
|
|
2553
|
+
/**
|
|
2554
|
+
* @param {ReadableStreamDefaultController} controller
|
|
2555
|
+
* @param {any} payload
|
|
2556
|
+
*/
|
|
2557
|
+
function send(controller, payload) {
|
|
2558
|
+
controller.enqueue(encoder.encode(JSON.stringify(payload) + "\n"));
|
|
2559
|
+
}
|
|
2560
|
+
let closed = false;
|
|
2561
|
+
/** @type {string | undefined} */
|
|
2562
|
+
let result = void 0;
|
|
2563
|
+
async function cancel() {
|
|
2564
|
+
if (closed) return;
|
|
2565
|
+
closed = true;
|
|
2566
|
+
await generator.return(void 0);
|
|
2567
|
+
}
|
|
2568
|
+
event.request.signal.addEventListener("abort", cancel, { once: true });
|
|
2569
|
+
return new Response(new ReadableStream({
|
|
2570
|
+
async pull(controller) {
|
|
2571
|
+
if (event.request.signal.aborted) {
|
|
2572
|
+
await cancel();
|
|
2573
|
+
controller.close();
|
|
2574
|
+
return;
|
|
2575
|
+
}
|
|
2576
|
+
try {
|
|
2577
|
+
while (true) {
|
|
2578
|
+
const { value, done } = await generator.next();
|
|
2579
|
+
if (done) {
|
|
2580
|
+
await cancel();
|
|
2581
|
+
controller.close();
|
|
2582
|
+
return;
|
|
2583
|
+
}
|
|
2584
|
+
if (result !== (result = stringify(value, transport))) {
|
|
2585
|
+
send(controller, {
|
|
2586
|
+
type: "result",
|
|
2587
|
+
result
|
|
2588
|
+
});
|
|
2589
|
+
return;
|
|
2590
|
+
}
|
|
2591
|
+
}
|
|
2592
|
+
} catch (error) {
|
|
2593
|
+
if (!event.request.signal.aborted) if (error instanceof Redirect) send(controller, {
|
|
2594
|
+
type: "redirect",
|
|
2595
|
+
location: error.location
|
|
2596
|
+
});
|
|
2597
|
+
else {
|
|
2598
|
+
const status = error instanceof HttpError || error instanceof SvelteKitError ? error.status : 500;
|
|
2599
|
+
send(controller, {
|
|
2600
|
+
type: "error",
|
|
2601
|
+
error: await handle_error_and_jsonify(event, state, options, error),
|
|
2602
|
+
status
|
|
2603
|
+
});
|
|
2604
|
+
}
|
|
2605
|
+
await cancel();
|
|
2606
|
+
controller.close();
|
|
2607
|
+
}
|
|
2608
|
+
},
|
|
2609
|
+
cancel
|
|
2610
|
+
}), { headers: {
|
|
2611
|
+
"cache-control": "private, no-store",
|
|
2612
|
+
"content-type": "application/x-ndjson"
|
|
2613
|
+
} });
|
|
2614
|
+
}
|
|
2615
|
+
const payload = internals.type === "prerender" ? additional_args : new URL(event.request.url).searchParams.get("payload");
|
|
2616
|
+
return json({
|
|
2617
|
+
type: "result",
|
|
2618
|
+
result: stringify(await with_request_store({
|
|
2619
|
+
event,
|
|
2620
|
+
state
|
|
2621
|
+
}, () => fn(parse_remote_arg(payload, transport))), transport)
|
|
2622
|
+
});
|
|
2623
|
+
} catch (error) {
|
|
2624
|
+
if (error instanceof Redirect) return json({
|
|
2625
|
+
type: "redirect",
|
|
2626
|
+
location: error.location,
|
|
2627
|
+
refreshes: await serialize_singleflight(state.remote.refreshes),
|
|
2628
|
+
reconnects: await serialize_singleflight(state.remote.reconnects)
|
|
2629
|
+
});
|
|
2630
|
+
const status = error instanceof HttpError || error instanceof SvelteKitError ? error.status : 500;
|
|
2631
|
+
return json({
|
|
2632
|
+
type: "error",
|
|
2633
|
+
error: await handle_error_and_jsonify(event, state, options, error),
|
|
2634
|
+
status
|
|
2635
|
+
}, {
|
|
2636
|
+
status: state.prerendering ? status : void 0,
|
|
2637
|
+
headers: { "cache-control": "private, no-store" }
|
|
2638
|
+
});
|
|
2639
|
+
}
|
|
2640
|
+
/** @param {Map<string, Promise<any>> | null} map */
|
|
2641
|
+
async function serialize_singleflight(map) {
|
|
2642
|
+
if (!map || map.size === 0) return;
|
|
2643
|
+
const results = await Promise.all(Array.from(map, async ([key, promise]) => {
|
|
2644
|
+
try {
|
|
2645
|
+
return [key, {
|
|
2646
|
+
type: "result",
|
|
2647
|
+
data: await promise
|
|
2648
|
+
}];
|
|
2649
|
+
} catch (error) {
|
|
2650
|
+
return [key, {
|
|
2651
|
+
type: "error",
|
|
2652
|
+
status: error instanceof HttpError || error instanceof SvelteKitError ? error.status : 500,
|
|
2653
|
+
error: await handle_error_and_jsonify(event, state, options, error)
|
|
2654
|
+
}];
|
|
2655
|
+
}
|
|
2656
|
+
}));
|
|
2657
|
+
return stringify(Object.fromEntries(results), transport);
|
|
2658
|
+
}
|
|
2659
|
+
}
|
|
2660
|
+
/**
|
|
2661
|
+
* @param {string[] | undefined} refreshes
|
|
2662
|
+
*/
|
|
2663
|
+
function create_requested_map(refreshes) {
|
|
2664
|
+
/** @type {Map<string, string[]>} */
|
|
2665
|
+
const requested = /* @__PURE__ */ new Map();
|
|
2666
|
+
for (const key of refreshes ?? []) {
|
|
2667
|
+
const parts = split_remote_key(key);
|
|
2668
|
+
const existing = requested.get(parts.id);
|
|
2669
|
+
if (existing) existing.push(parts.payload);
|
|
2670
|
+
else requested.set(parts.id, [parts.payload]);
|
|
2671
|
+
}
|
|
2672
|
+
return requested;
|
|
2673
|
+
}
|
|
2674
|
+
/** @type {typeof handle_remote_form_post_internal} */
|
|
2675
|
+
async function handle_remote_form_post(event, state, manifest, id) {
|
|
2676
|
+
return record_span({
|
|
2677
|
+
name: "sveltekit.remote.form.post",
|
|
2678
|
+
attributes: { },
|
|
2679
|
+
fn: (current) => {
|
|
2680
|
+
const traced_event = merge_tracing(event, current);
|
|
2681
|
+
return with_request_store({
|
|
2682
|
+
event: traced_event,
|
|
2683
|
+
state
|
|
2684
|
+
}, () => handle_remote_form_post_internal(traced_event, state, manifest, id));
|
|
2685
|
+
}
|
|
2686
|
+
});
|
|
2687
|
+
}
|
|
2688
|
+
/**
|
|
2689
|
+
* @param {RequestEvent} event
|
|
2690
|
+
* @param {RequestState} state
|
|
2691
|
+
* @param {SSRManifest} manifest
|
|
2692
|
+
* @param {string} id
|
|
2693
|
+
* @returns {Promise<ActionResult>}
|
|
2694
|
+
*/
|
|
2695
|
+
async function handle_remote_form_post_internal(event, state, manifest, id) {
|
|
2696
|
+
const [hash, name, action_id] = id.split("/");
|
|
2697
|
+
let form = (await manifest._.remotes[hash]?.())?.default[name];
|
|
2698
|
+
if (!form) {
|
|
2699
|
+
event.setHeaders({ allow: "GET" });
|
|
2700
|
+
return {
|
|
2701
|
+
type: "error",
|
|
2702
|
+
error: new SvelteKitError(405, "Method Not Allowed", `POST method not allowed. No form actions exist for this page`)
|
|
2703
|
+
};
|
|
2704
|
+
}
|
|
2705
|
+
if (action_id) form = with_request_store({
|
|
2706
|
+
event,
|
|
2707
|
+
state
|
|
2708
|
+
}, () => form.for(JSON.parse(action_id)));
|
|
2709
|
+
try {
|
|
2710
|
+
const fn = form.__.fn;
|
|
2711
|
+
const { data, meta, form_data } = await deserialize_binary_form(event.request);
|
|
2712
|
+
if (action_id && !("id" in data)) data.id = JSON.parse(decodeURIComponent(action_id));
|
|
2713
|
+
await with_request_store({
|
|
2714
|
+
event,
|
|
2715
|
+
state
|
|
2716
|
+
}, () => fn(data, meta, form_data));
|
|
2717
|
+
return {
|
|
2718
|
+
type: "success",
|
|
2719
|
+
status: 200
|
|
2720
|
+
};
|
|
2721
|
+
} catch (e) {
|
|
2722
|
+
const err = normalize_error(e);
|
|
2723
|
+
if (err instanceof Redirect) return {
|
|
2724
|
+
type: "redirect",
|
|
2725
|
+
status: err.status,
|
|
2726
|
+
location: err.location
|
|
2727
|
+
};
|
|
2728
|
+
return {
|
|
2729
|
+
type: "error",
|
|
2730
|
+
error: check_incorrect_fail_use(err)
|
|
2731
|
+
};
|
|
2732
|
+
}
|
|
2733
|
+
}
|
|
2734
|
+
/**
|
|
2735
|
+
* @param {URL} url
|
|
2736
|
+
*/
|
|
2737
|
+
function get_remote_id(url) {
|
|
2738
|
+
return url.pathname.startsWith(`${base}/_app/remote/`) && url.pathname.replace(`${base}/_app/remote/`, "");
|
|
2739
|
+
}
|
|
2740
|
+
/**
|
|
2741
|
+
* @param {URL} url
|
|
2742
|
+
*/
|
|
2743
|
+
function get_remote_action(url) {
|
|
2744
|
+
return url.searchParams.get("/remote");
|
|
2745
|
+
}
|
|
2746
|
+
//#endregion
|
|
2747
|
+
//#region ../../node_modules/.bun/@sveltejs+kit@2.61.0+aeb06e9cf8e23ab6/node_modules/@sveltejs/kit/src/runtime/server/page/index.js
|
|
2748
|
+
/** @import { ActionResult, RequestEvent, SSRManifest } from '@sveltejs/kit' */
|
|
2749
|
+
/** @import { PageNodeIndexes, RequestState, RequiredResolveOptions, ServerDataNode, SSRComponent, SSRNode, SSROptions, SSRState } from 'types' */
|
|
2750
|
+
/**
|
|
2751
|
+
* The maximum request depth permitted before assuming we're stuck in an infinite loop
|
|
2752
|
+
*/
|
|
2753
|
+
var MAX_DEPTH = 10;
|
|
2754
|
+
/**
|
|
2755
|
+
* @param {RequestEvent} event
|
|
2756
|
+
* @param {RequestState} event_state
|
|
2757
|
+
* @param {PageNodeIndexes} page
|
|
2758
|
+
* @param {SSROptions} options
|
|
2759
|
+
* @param {SSRManifest} manifest
|
|
2760
|
+
* @param {SSRState} state
|
|
2761
|
+
* @param {import('../../../utils/page_nodes.js').PageNodes} nodes
|
|
2762
|
+
* @param {RequiredResolveOptions} resolve_opts
|
|
2763
|
+
* @returns {Promise<Response>}
|
|
2764
|
+
*/
|
|
2765
|
+
async function render_page(event, event_state, page, options, manifest, state, nodes, resolve_opts) {
|
|
2766
|
+
if (state.depth > MAX_DEPTH) return text(`Not found: ${event.url.pathname}`, { status: 404 });
|
|
2767
|
+
if (is_action_json_request(event)) return handle_action_json_request(event, event_state, options, (await manifest._.nodes[page.leaf]())?.server);
|
|
2768
|
+
try {
|
|
2769
|
+
const leaf_node = nodes.page();
|
|
2770
|
+
let status = 200;
|
|
2771
|
+
/** @type {ActionResult | undefined} */
|
|
2772
|
+
let action_result = void 0;
|
|
2773
|
+
if (is_action_request(event)) {
|
|
2774
|
+
const remote_id = get_remote_action(event.url);
|
|
2775
|
+
if (remote_id) action_result = await handle_remote_form_post(event, event_state, manifest, remote_id);
|
|
2776
|
+
else action_result = await handle_action_request(event, event_state, leaf_node.server);
|
|
2777
|
+
if (action_result?.type === "redirect") return redirect_response(action_result.status, action_result.location);
|
|
2778
|
+
if (action_result?.type === "error") status = get_status(action_result.error);
|
|
2779
|
+
if (action_result?.type === "failure") status = action_result.status;
|
|
2780
|
+
}
|
|
2781
|
+
const should_prerender = nodes.prerender();
|
|
2782
|
+
if (should_prerender) {
|
|
2783
|
+
if (leaf_node.server?.actions) throw new Error("Cannot prerender pages with actions");
|
|
2784
|
+
} else if (state.prerendering) return new Response(void 0, { status: 204 });
|
|
2785
|
+
state.prerender_default = should_prerender;
|
|
2786
|
+
const should_prerender_data = nodes.should_prerender_data();
|
|
2787
|
+
const data_pathname = add_data_suffix(event.url.pathname);
|
|
2788
|
+
/** @type {import('./types.js').Fetched[]} */
|
|
2789
|
+
const fetched = [];
|
|
2790
|
+
const ssr = nodes.ssr();
|
|
2791
|
+
const csr = nodes.csr();
|
|
2792
|
+
if (ssr === false && !(state.prerendering && should_prerender_data)) return await render_response({
|
|
2793
|
+
branch: compact(nodes.data).map((node) => {
|
|
2794
|
+
return {
|
|
2795
|
+
node,
|
|
2796
|
+
data: null,
|
|
2797
|
+
server_data: null
|
|
2798
|
+
};
|
|
2799
|
+
}),
|
|
2800
|
+
fetched,
|
|
2801
|
+
page_config: {
|
|
2802
|
+
ssr: false,
|
|
2803
|
+
csr
|
|
2804
|
+
},
|
|
2805
|
+
status,
|
|
2806
|
+
error: null,
|
|
2807
|
+
event,
|
|
2808
|
+
event_state,
|
|
2809
|
+
options,
|
|
2810
|
+
manifest,
|
|
2811
|
+
state,
|
|
2812
|
+
resolve_opts,
|
|
2813
|
+
data_serializer: server_data_serializer(event, event_state, options)
|
|
2814
|
+
});
|
|
2815
|
+
/** @type {Array<import('./types.js').Loaded | null>} */
|
|
2816
|
+
const branch = [];
|
|
2817
|
+
/** @type {Error | null} */
|
|
2818
|
+
let load_error = null;
|
|
2819
|
+
const data_serializer = server_data_serializer(event, event_state, options);
|
|
2820
|
+
const data_serializer_json = state.prerendering && should_prerender_data ? server_data_serializer_json(event, event_state, options) : null;
|
|
2821
|
+
/** @type {Array<Promise<ServerDataNode | null>>} */
|
|
2822
|
+
const server_promises = nodes.data.map((node, i) => {
|
|
2823
|
+
if (load_error) throw load_error;
|
|
2824
|
+
return Promise.resolve().then(async () => {
|
|
2825
|
+
try {
|
|
2826
|
+
if (node === leaf_node && action_result?.type === "error") throw action_result.error;
|
|
2827
|
+
const server_data = await load_server_data({
|
|
2828
|
+
event,
|
|
2829
|
+
event_state,
|
|
2830
|
+
state,
|
|
2831
|
+
node,
|
|
2832
|
+
parent: async () => {
|
|
2833
|
+
/** @type {Record<string, any>} */
|
|
2834
|
+
const data = {};
|
|
2835
|
+
for (let j = 0; j < i; j += 1) {
|
|
2836
|
+
const parent = await server_promises[j];
|
|
2837
|
+
if (parent) Object.assign(data, parent.data);
|
|
2838
|
+
}
|
|
2839
|
+
return data;
|
|
2840
|
+
}
|
|
2841
|
+
});
|
|
2842
|
+
if (node) data_serializer.add_node(i, server_data);
|
|
2843
|
+
data_serializer_json?.add_node(i, server_data);
|
|
2844
|
+
return server_data;
|
|
2845
|
+
} catch (e) {
|
|
2846
|
+
load_error = e;
|
|
2847
|
+
throw load_error;
|
|
2848
|
+
}
|
|
2849
|
+
});
|
|
2850
|
+
});
|
|
2851
|
+
/** @type {Array<Promise<Record<string, any> | null>>} */
|
|
2852
|
+
const load_promises = nodes.data.map((node, i) => {
|
|
2853
|
+
if (load_error) throw load_error;
|
|
2854
|
+
return Promise.resolve().then(async () => {
|
|
2855
|
+
try {
|
|
2856
|
+
return await load_data({
|
|
2857
|
+
event,
|
|
2858
|
+
event_state,
|
|
2859
|
+
fetched,
|
|
2860
|
+
node,
|
|
2861
|
+
parent: async () => {
|
|
2862
|
+
const data = {};
|
|
2863
|
+
for (let j = 0; j < i; j += 1) Object.assign(data, await load_promises[j]);
|
|
2864
|
+
return data;
|
|
2865
|
+
},
|
|
2866
|
+
resolve_opts,
|
|
2867
|
+
server_data_promise: server_promises[i],
|
|
2868
|
+
state,
|
|
2869
|
+
csr
|
|
2870
|
+
});
|
|
2871
|
+
} catch (e) {
|
|
2872
|
+
load_error = e;
|
|
2873
|
+
throw load_error;
|
|
2874
|
+
}
|
|
2875
|
+
});
|
|
2876
|
+
});
|
|
2877
|
+
for (const p of server_promises) p.catch(noop);
|
|
2878
|
+
for (const p of load_promises) p.catch(noop);
|
|
2879
|
+
for (let i = 0; i < nodes.data.length; i += 1) {
|
|
2880
|
+
const node = nodes.data[i];
|
|
2881
|
+
if (node) try {
|
|
2882
|
+
const server_data = await server_promises[i];
|
|
2883
|
+
const data = await load_promises[i];
|
|
2884
|
+
branch.push({
|
|
2885
|
+
node,
|
|
2886
|
+
server_data,
|
|
2887
|
+
data
|
|
2888
|
+
});
|
|
2889
|
+
} catch (e) {
|
|
2890
|
+
const err = normalize_error(e);
|
|
2891
|
+
if (err instanceof Redirect) {
|
|
2892
|
+
if (state.prerendering && should_prerender_data) {
|
|
2893
|
+
const body = JSON.stringify({
|
|
2894
|
+
type: "redirect",
|
|
2895
|
+
location: err.location
|
|
2896
|
+
});
|
|
2897
|
+
state.prerendering.dependencies.set(data_pathname, {
|
|
2898
|
+
response: text(body),
|
|
2899
|
+
body
|
|
2900
|
+
});
|
|
2901
|
+
}
|
|
2902
|
+
return redirect_response(err.status, err.location);
|
|
2903
|
+
}
|
|
2904
|
+
const status = get_status(err);
|
|
2905
|
+
const error = await handle_error_and_jsonify(event, event_state, options, err);
|
|
2906
|
+
while (i--) if (page.errors[i]) {
|
|
2907
|
+
const index = page.errors[i];
|
|
2908
|
+
const node = await manifest._.nodes[index]();
|
|
2909
|
+
let j = i;
|
|
2910
|
+
while (!branch[j]) j -= 1;
|
|
2911
|
+
data_serializer.set_max_nodes(j + 1);
|
|
2912
|
+
const layouts = compact(branch.slice(0, j + 1));
|
|
2913
|
+
const nodes = new PageNodes(layouts.map((layout) => layout.node));
|
|
2914
|
+
const error_branch = layouts.concat({
|
|
2915
|
+
node,
|
|
2916
|
+
data: null,
|
|
2917
|
+
server_data: null
|
|
2918
|
+
});
|
|
2919
|
+
return await render_response({
|
|
2920
|
+
event,
|
|
2921
|
+
event_state,
|
|
2922
|
+
options,
|
|
2923
|
+
manifest,
|
|
2924
|
+
state,
|
|
2925
|
+
resolve_opts,
|
|
2926
|
+
page_config: {
|
|
2927
|
+
ssr: nodes.ssr(),
|
|
2928
|
+
csr: nodes.csr()
|
|
2929
|
+
},
|
|
2930
|
+
status,
|
|
2931
|
+
error,
|
|
2932
|
+
error_components: await load_error_components(options, ssr, error_branch, page, manifest),
|
|
2933
|
+
branch: error_branch,
|
|
2934
|
+
fetched,
|
|
2935
|
+
data_serializer
|
|
2936
|
+
});
|
|
2937
|
+
}
|
|
2938
|
+
return static_error_page(options, status, error.message);
|
|
2939
|
+
}
|
|
2940
|
+
else branch.push(null);
|
|
2941
|
+
}
|
|
2942
|
+
if (state.prerendering && data_serializer_json) {
|
|
2943
|
+
let { data, chunks } = data_serializer_json.get_data();
|
|
2944
|
+
if (chunks) for await (const chunk of chunks) data += chunk;
|
|
2945
|
+
state.prerendering.dependencies.set(data_pathname, {
|
|
2946
|
+
response: text(data),
|
|
2947
|
+
body: data
|
|
2948
|
+
});
|
|
2949
|
+
}
|
|
2950
|
+
return await render_response({
|
|
2951
|
+
event,
|
|
2952
|
+
event_state,
|
|
2953
|
+
options,
|
|
2954
|
+
manifest,
|
|
2955
|
+
state,
|
|
2956
|
+
resolve_opts,
|
|
2957
|
+
page_config: {
|
|
2958
|
+
csr,
|
|
2959
|
+
ssr
|
|
2960
|
+
},
|
|
2961
|
+
status,
|
|
2962
|
+
error: null,
|
|
2963
|
+
branch: compact(branch),
|
|
2964
|
+
action_result,
|
|
2965
|
+
fetched,
|
|
2966
|
+
data_serializer: !ssr ? server_data_serializer(event, event_state, options) : data_serializer,
|
|
2967
|
+
error_components: await load_error_components(options, ssr, branch, page, manifest)
|
|
2968
|
+
});
|
|
2969
|
+
} catch (e) {
|
|
2970
|
+
if (e instanceof Redirect) return redirect_response(e.status, e.location);
|
|
2971
|
+
return await respond_with_error({
|
|
2972
|
+
event,
|
|
2973
|
+
event_state,
|
|
2974
|
+
options,
|
|
2975
|
+
manifest,
|
|
2976
|
+
state,
|
|
2977
|
+
status: e instanceof HttpError ? e.status : 500,
|
|
2978
|
+
error: e,
|
|
2979
|
+
resolve_opts
|
|
2980
|
+
});
|
|
2981
|
+
}
|
|
2982
|
+
}
|
|
2983
|
+
/**
|
|
2984
|
+
*
|
|
2985
|
+
* @param {SSROptions} options
|
|
2986
|
+
* @param {boolean} ssr
|
|
2987
|
+
* @param {Array<import('./types.js').Loaded | null>} branch
|
|
2988
|
+
* @param {PageNodeIndexes} page
|
|
2989
|
+
* @param {SSRManifest} manifest
|
|
2990
|
+
*/
|
|
2991
|
+
async function load_error_components(options, ssr, branch, page, manifest) {
|
|
2992
|
+
/** @type {Array<SSRComponent | undefined> | undefined} */
|
|
2993
|
+
let error_components;
|
|
2994
|
+
if (options.server_error_boundaries && ssr) {
|
|
2995
|
+
let last_idx = -1;
|
|
2996
|
+
error_components = await Promise.all(branch.map((b, i) => {
|
|
2997
|
+
if (i === 0) return void 0;
|
|
2998
|
+
if (!b) return null;
|
|
2999
|
+
i--;
|
|
3000
|
+
while (i > last_idx + 1 && page.errors[i] === void 0) i -= 1;
|
|
3001
|
+
last_idx = i;
|
|
3002
|
+
const idx = page.errors[i];
|
|
3003
|
+
if (idx == null) return void 0;
|
|
3004
|
+
return manifest._.nodes[idx]?.().then((e) => e.component?.()).catch(() => void 0);
|
|
3005
|
+
}).filter((e) => e !== null));
|
|
3006
|
+
}
|
|
3007
|
+
return error_components;
|
|
3008
|
+
}
|
|
3009
|
+
//#endregion
|
|
3010
|
+
//#region ../../node_modules/.bun/@sveltejs+kit@2.61.0+aeb06e9cf8e23ab6/node_modules/@sveltejs/kit/src/runtime/server/data/index.js
|
|
3011
|
+
/**
|
|
3012
|
+
* @param {import('@sveltejs/kit').RequestEvent} event
|
|
3013
|
+
* @param {import('types').RequestState} event_state
|
|
3014
|
+
* @param {import('types').SSRRoute} route
|
|
3015
|
+
* @param {import('types').SSROptions} options
|
|
3016
|
+
* @param {import('@sveltejs/kit').SSRManifest} manifest
|
|
3017
|
+
* @param {import('types').SSRState} state
|
|
3018
|
+
* @param {boolean[] | undefined} invalidated_data_nodes
|
|
3019
|
+
* @param {import('types').TrailingSlash} trailing_slash
|
|
3020
|
+
* @returns {Promise<Response>}
|
|
3021
|
+
*/
|
|
3022
|
+
async function render_data(event, event_state, route, options, manifest, state, invalidated_data_nodes, trailing_slash) {
|
|
3023
|
+
if (!route.page) return new Response(void 0, { status: 404 });
|
|
3024
|
+
try {
|
|
3025
|
+
const node_ids = [...route.page.layouts, route.page.leaf];
|
|
3026
|
+
const invalidated = invalidated_data_nodes ?? node_ids.map(() => true);
|
|
3027
|
+
let aborted = false;
|
|
3028
|
+
const url = new URL(event.url);
|
|
3029
|
+
url.pathname = normalize_path(url.pathname, trailing_slash);
|
|
3030
|
+
const new_event = {
|
|
3031
|
+
...event,
|
|
3032
|
+
url
|
|
3033
|
+
};
|
|
3034
|
+
const functions = node_ids.map((n, i) => {
|
|
3035
|
+
return once(async () => {
|
|
3036
|
+
try {
|
|
3037
|
+
if (aborted) return { type: "skip" };
|
|
3038
|
+
return load_server_data({
|
|
3039
|
+
event: new_event,
|
|
3040
|
+
event_state,
|
|
3041
|
+
state,
|
|
3042
|
+
node: n == void 0 ? n : await manifest._.nodes[n](),
|
|
3043
|
+
parent: async () => {
|
|
3044
|
+
/** @type {Record<string, any>} */
|
|
3045
|
+
const data = {};
|
|
3046
|
+
for (let j = 0; j < i; j += 1) {
|
|
3047
|
+
const parent = await functions[j]();
|
|
3048
|
+
if (parent) Object.assign(data, parent.data);
|
|
3049
|
+
}
|
|
3050
|
+
return data;
|
|
3051
|
+
}
|
|
3052
|
+
});
|
|
3053
|
+
} catch (e) {
|
|
3054
|
+
aborted = true;
|
|
3055
|
+
throw e;
|
|
3056
|
+
}
|
|
3057
|
+
});
|
|
3058
|
+
});
|
|
3059
|
+
const promises = functions.map(async (fn, i) => {
|
|
3060
|
+
if (!invalidated[i]) return { type: "skip" };
|
|
3061
|
+
return fn();
|
|
3062
|
+
});
|
|
3063
|
+
let length = promises.length;
|
|
3064
|
+
const nodes = await Promise.all(promises.map((p, i) => p.catch(async (error) => {
|
|
3065
|
+
if (error instanceof Redirect) throw error;
|
|
3066
|
+
length = Math.min(length, i + 1);
|
|
3067
|
+
return {
|
|
3068
|
+
type: "error",
|
|
3069
|
+
error: await handle_error_and_jsonify(event, event_state, options, error),
|
|
3070
|
+
status: error instanceof HttpError || error instanceof SvelteKitError ? error.status : void 0
|
|
3071
|
+
};
|
|
3072
|
+
})));
|
|
3073
|
+
const data_serializer = server_data_serializer_json(event, event_state, options);
|
|
3074
|
+
for (let i = 0; i < nodes.length; i++) data_serializer.add_node(i, nodes[i]);
|
|
3075
|
+
const { data, chunks } = data_serializer.get_data();
|
|
3076
|
+
if (!chunks) return json_response(data);
|
|
3077
|
+
return new Response(new ReadableStream({
|
|
3078
|
+
async start(controller) {
|
|
3079
|
+
controller.enqueue(text_encoder.encode(data));
|
|
3080
|
+
for await (const chunk of chunks) controller.enqueue(text_encoder.encode(chunk));
|
|
3081
|
+
controller.close();
|
|
3082
|
+
},
|
|
3083
|
+
type: "bytes"
|
|
3084
|
+
}), { headers: {
|
|
3085
|
+
"content-type": "text/sveltekit-data",
|
|
3086
|
+
"cache-control": "private, no-store"
|
|
3087
|
+
} });
|
|
3088
|
+
} catch (e) {
|
|
3089
|
+
const error = normalize_error(e);
|
|
3090
|
+
if (error instanceof Redirect) return redirect_json_response(error);
|
|
3091
|
+
else return json_response(await handle_error_and_jsonify(event, event_state, options, error), 500);
|
|
3092
|
+
}
|
|
3093
|
+
}
|
|
3094
|
+
/**
|
|
3095
|
+
* @param {Record<string, any> | string} json
|
|
3096
|
+
* @param {number} [status]
|
|
3097
|
+
*/
|
|
3098
|
+
function json_response(json, status = 200) {
|
|
3099
|
+
return text(typeof json === "string" ? json : JSON.stringify(json), {
|
|
3100
|
+
status,
|
|
3101
|
+
headers: {
|
|
3102
|
+
"content-type": "application/json",
|
|
3103
|
+
"cache-control": "private, no-store"
|
|
3104
|
+
}
|
|
3105
|
+
});
|
|
3106
|
+
}
|
|
3107
|
+
/**
|
|
3108
|
+
* @param {Redirect} redirect
|
|
3109
|
+
*/
|
|
3110
|
+
function redirect_json_response(redirect) {
|
|
3111
|
+
return json_response({
|
|
3112
|
+
type: "redirect",
|
|
3113
|
+
location: redirect.location
|
|
3114
|
+
});
|
|
3115
|
+
}
|
|
3116
|
+
/*!
|
|
3117
|
+
* cookie
|
|
3118
|
+
* Copyright(c) 2012-2014 Roman Shtylman
|
|
3119
|
+
* Copyright(c) 2015 Douglas Christopher Wilson
|
|
3120
|
+
* MIT Licensed
|
|
3121
|
+
*/
|
|
3122
|
+
//#endregion
|
|
3123
|
+
//#region ../../node_modules/.bun/@sveltejs+kit@2.61.0+aeb06e9cf8e23ab6/node_modules/@sveltejs/kit/src/runtime/server/cookie.js
|
|
3124
|
+
var import_cookie = (/* @__PURE__ */ __commonJSMin(((exports) => {
|
|
3125
|
+
/**
|
|
3126
|
+
* Module exports.
|
|
3127
|
+
* @public
|
|
3128
|
+
*/
|
|
3129
|
+
exports.parse = parse;
|
|
3130
|
+
exports.serialize = serialize;
|
|
3131
|
+
/**
|
|
3132
|
+
* Module variables.
|
|
3133
|
+
* @private
|
|
3134
|
+
*/
|
|
3135
|
+
var __toString = Object.prototype.toString;
|
|
3136
|
+
/**
|
|
3137
|
+
* RegExp to match field-content in RFC 7230 sec 3.2
|
|
3138
|
+
*
|
|
3139
|
+
* field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ]
|
|
3140
|
+
* field-vchar = VCHAR / obs-text
|
|
3141
|
+
* obs-text = %x80-FF
|
|
3142
|
+
*/
|
|
3143
|
+
var fieldContentRegExp = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;
|
|
3144
|
+
/**
|
|
3145
|
+
* Parse a cookie header.
|
|
3146
|
+
*
|
|
3147
|
+
* Parse the given cookie header string into an object
|
|
3148
|
+
* The object has the various cookies as keys(names) => values
|
|
3149
|
+
*
|
|
3150
|
+
* @param {string} str
|
|
3151
|
+
* @param {object} [options]
|
|
3152
|
+
* @return {object}
|
|
3153
|
+
* @public
|
|
3154
|
+
*/
|
|
3155
|
+
function parse(str, options) {
|
|
3156
|
+
if (typeof str !== "string") throw new TypeError("argument str must be a string");
|
|
3157
|
+
var obj = {};
|
|
3158
|
+
var dec = (options || {}).decode || decode;
|
|
3159
|
+
var index = 0;
|
|
3160
|
+
while (index < str.length) {
|
|
3161
|
+
var eqIdx = str.indexOf("=", index);
|
|
3162
|
+
if (eqIdx === -1) break;
|
|
3163
|
+
var endIdx = str.indexOf(";", index);
|
|
3164
|
+
if (endIdx === -1) endIdx = str.length;
|
|
3165
|
+
else if (endIdx < eqIdx) {
|
|
3166
|
+
index = str.lastIndexOf(";", eqIdx - 1) + 1;
|
|
3167
|
+
continue;
|
|
3168
|
+
}
|
|
3169
|
+
var key = str.slice(index, eqIdx).trim();
|
|
3170
|
+
if (void 0 === obj[key]) {
|
|
3171
|
+
var val = str.slice(eqIdx + 1, endIdx).trim();
|
|
3172
|
+
if (val.charCodeAt(0) === 34) val = val.slice(1, -1);
|
|
3173
|
+
obj[key] = tryDecode(val, dec);
|
|
3174
|
+
}
|
|
3175
|
+
index = endIdx + 1;
|
|
3176
|
+
}
|
|
3177
|
+
return obj;
|
|
3178
|
+
}
|
|
3179
|
+
/**
|
|
3180
|
+
* Serialize data into a cookie header.
|
|
3181
|
+
*
|
|
3182
|
+
* Serialize the a name value pair into a cookie string suitable for
|
|
3183
|
+
* http headers. An optional options object specified cookie parameters.
|
|
3184
|
+
*
|
|
3185
|
+
* serialize('foo', 'bar', { httpOnly: true })
|
|
3186
|
+
* => "foo=bar; httpOnly"
|
|
3187
|
+
*
|
|
3188
|
+
* @param {string} name
|
|
3189
|
+
* @param {string} val
|
|
3190
|
+
* @param {object} [options]
|
|
3191
|
+
* @return {string}
|
|
3192
|
+
* @public
|
|
3193
|
+
*/
|
|
3194
|
+
function serialize(name, val, options) {
|
|
3195
|
+
var opt = options || {};
|
|
3196
|
+
var enc = opt.encode || encode;
|
|
3197
|
+
if (typeof enc !== "function") throw new TypeError("option encode is invalid");
|
|
3198
|
+
if (!fieldContentRegExp.test(name)) throw new TypeError("argument name is invalid");
|
|
3199
|
+
var value = enc(val);
|
|
3200
|
+
if (value && !fieldContentRegExp.test(value)) throw new TypeError("argument val is invalid");
|
|
3201
|
+
var str = name + "=" + value;
|
|
3202
|
+
if (null != opt.maxAge) {
|
|
3203
|
+
var maxAge = opt.maxAge - 0;
|
|
3204
|
+
if (isNaN(maxAge) || !isFinite(maxAge)) throw new TypeError("option maxAge is invalid");
|
|
3205
|
+
str += "; Max-Age=" + Math.floor(maxAge);
|
|
3206
|
+
}
|
|
3207
|
+
if (opt.domain) {
|
|
3208
|
+
if (!fieldContentRegExp.test(opt.domain)) throw new TypeError("option domain is invalid");
|
|
3209
|
+
str += "; Domain=" + opt.domain;
|
|
3210
|
+
}
|
|
3211
|
+
if (opt.path) {
|
|
3212
|
+
if (!fieldContentRegExp.test(opt.path)) throw new TypeError("option path is invalid");
|
|
3213
|
+
str += "; Path=" + opt.path;
|
|
3214
|
+
}
|
|
3215
|
+
if (opt.expires) {
|
|
3216
|
+
var expires = opt.expires;
|
|
3217
|
+
if (!isDate(expires) || isNaN(expires.valueOf())) throw new TypeError("option expires is invalid");
|
|
3218
|
+
str += "; Expires=" + expires.toUTCString();
|
|
3219
|
+
}
|
|
3220
|
+
if (opt.httpOnly) str += "; HttpOnly";
|
|
3221
|
+
if (opt.secure) str += "; Secure";
|
|
3222
|
+
if (opt.partitioned) str += "; Partitioned";
|
|
3223
|
+
if (opt.priority) switch (typeof opt.priority === "string" ? opt.priority.toLowerCase() : opt.priority) {
|
|
3224
|
+
case "low":
|
|
3225
|
+
str += "; Priority=Low";
|
|
3226
|
+
break;
|
|
3227
|
+
case "medium":
|
|
3228
|
+
str += "; Priority=Medium";
|
|
3229
|
+
break;
|
|
3230
|
+
case "high":
|
|
3231
|
+
str += "; Priority=High";
|
|
3232
|
+
break;
|
|
3233
|
+
default: throw new TypeError("option priority is invalid");
|
|
3234
|
+
}
|
|
3235
|
+
if (opt.sameSite) switch (typeof opt.sameSite === "string" ? opt.sameSite.toLowerCase() : opt.sameSite) {
|
|
3236
|
+
case true:
|
|
3237
|
+
str += "; SameSite=Strict";
|
|
3238
|
+
break;
|
|
3239
|
+
case "lax":
|
|
3240
|
+
str += "; SameSite=Lax";
|
|
3241
|
+
break;
|
|
3242
|
+
case "strict":
|
|
3243
|
+
str += "; SameSite=Strict";
|
|
3244
|
+
break;
|
|
3245
|
+
case "none":
|
|
3246
|
+
str += "; SameSite=None";
|
|
3247
|
+
break;
|
|
3248
|
+
default: throw new TypeError("option sameSite is invalid");
|
|
3249
|
+
}
|
|
3250
|
+
return str;
|
|
3251
|
+
}
|
|
3252
|
+
/**
|
|
3253
|
+
* URL-decode string value. Optimized to skip native call when no %.
|
|
3254
|
+
*
|
|
3255
|
+
* @param {string} str
|
|
3256
|
+
* @returns {string}
|
|
3257
|
+
*/
|
|
3258
|
+
function decode(str) {
|
|
3259
|
+
return str.indexOf("%") !== -1 ? decodeURIComponent(str) : str;
|
|
3260
|
+
}
|
|
3261
|
+
/**
|
|
3262
|
+
* URL-encode value.
|
|
3263
|
+
*
|
|
3264
|
+
* @param {string} val
|
|
3265
|
+
* @returns {string}
|
|
3266
|
+
*/
|
|
3267
|
+
function encode(val) {
|
|
3268
|
+
return encodeURIComponent(val);
|
|
3269
|
+
}
|
|
3270
|
+
/**
|
|
3271
|
+
* Determine if value is a Date.
|
|
3272
|
+
*
|
|
3273
|
+
* @param {*} val
|
|
3274
|
+
* @private
|
|
3275
|
+
*/
|
|
3276
|
+
function isDate(val) {
|
|
3277
|
+
return __toString.call(val) === "[object Date]" || val instanceof Date;
|
|
3278
|
+
}
|
|
3279
|
+
/**
|
|
3280
|
+
* Try decoding a string using a decoding function.
|
|
3281
|
+
*
|
|
3282
|
+
* @param {string} str
|
|
3283
|
+
* @param {function} decode
|
|
3284
|
+
* @private
|
|
3285
|
+
*/
|
|
3286
|
+
function tryDecode(str, decode) {
|
|
3287
|
+
try {
|
|
3288
|
+
return decode(str);
|
|
3289
|
+
} catch (e) {
|
|
3290
|
+
return str;
|
|
3291
|
+
}
|
|
3292
|
+
}
|
|
3293
|
+
})))();
|
|
3294
|
+
var INVALID_COOKIE_CHARACTER_REGEX = /[\x00-\x1F\x7F()<>@,;:"/[\]?={} \t]/;
|
|
3295
|
+
/** @param {import('./page/types.js').Cookie['options']} options */
|
|
3296
|
+
function validate_options(options) {
|
|
3297
|
+
if (options?.path === void 0) throw new Error("You must specify a `path` when setting, deleting or serializing cookies");
|
|
3298
|
+
}
|
|
3299
|
+
/**
|
|
3300
|
+
* Generates a unique key for a cookie based on its domain, path, and name in
|
|
3301
|
+
* the format: `<domain>/<path>?<name>`.
|
|
3302
|
+
* If domain is undefined, it will be omitted.
|
|
3303
|
+
* For example: `/?name`, `example.com/foo?name`.
|
|
3304
|
+
*
|
|
3305
|
+
* @param {string | undefined} domain
|
|
3306
|
+
* @param {string} path
|
|
3307
|
+
* @param {string} name
|
|
3308
|
+
* @returns {string}
|
|
3309
|
+
*/
|
|
3310
|
+
function generate_cookie_key(domain, path, name) {
|
|
3311
|
+
return `${domain || ""}${path}?${encodeURIComponent(name)}`;
|
|
3312
|
+
}
|
|
3313
|
+
/**
|
|
3314
|
+
* @param {Request} request
|
|
3315
|
+
* @param {URL} url
|
|
3316
|
+
*/
|
|
3317
|
+
function get_cookies(request, url) {
|
|
3318
|
+
const header = request.headers.get("cookie") ?? "";
|
|
3319
|
+
const initial_cookies = (0, import_cookie.parse)(header, { decode: (value) => value });
|
|
3320
|
+
/** @type {string | undefined} */
|
|
3321
|
+
let normalized_url;
|
|
3322
|
+
/** @type {Map<string, import('./page/types.js').Cookie>} */
|
|
3323
|
+
const new_cookies = /* @__PURE__ */ new Map();
|
|
3324
|
+
/** @type {import('cookie').CookieSerializeOptions} */
|
|
3325
|
+
const defaults = {
|
|
3326
|
+
httpOnly: true,
|
|
3327
|
+
sameSite: "lax",
|
|
3328
|
+
secure: url.hostname === "localhost" && url.protocol === "http:" ? false : true
|
|
3329
|
+
};
|
|
3330
|
+
/** @type {import('@sveltejs/kit').Cookies} */
|
|
3331
|
+
const cookies = {
|
|
3332
|
+
/**
|
|
3333
|
+
* @param {string} name
|
|
3334
|
+
* @param {import('cookie').CookieParseOptions} [opts]
|
|
3335
|
+
*/
|
|
3336
|
+
get(name, opts) {
|
|
3337
|
+
const best_match = Array.from(new_cookies.values()).filter((c) => {
|
|
3338
|
+
return c.name === name && domain_matches(url.hostname, c.options.domain) && path_matches(url.pathname, c.options.path);
|
|
3339
|
+
}).sort((a, b) => b.options.path.length - a.options.path.length)[0];
|
|
3340
|
+
if (best_match) return best_match.options.maxAge === 0 ? void 0 : best_match.value;
|
|
3341
|
+
return (0, import_cookie.parse)(header, { decode: opts?.decode })[name];
|
|
3342
|
+
},
|
|
3343
|
+
/**
|
|
3344
|
+
* @param {import('cookie').CookieParseOptions} [opts]
|
|
3345
|
+
*/
|
|
3346
|
+
getAll(opts) {
|
|
3347
|
+
const cookies = (0, import_cookie.parse)(header, { decode: opts?.decode });
|
|
3348
|
+
const lookup = /* @__PURE__ */ new Map();
|
|
3349
|
+
for (const c of new_cookies.values()) if (domain_matches(url.hostname, c.options.domain) && path_matches(url.pathname, c.options.path)) {
|
|
3350
|
+
const existing = lookup.get(c.name);
|
|
3351
|
+
if (!existing || c.options.path.length > existing.options.path.length) lookup.set(c.name, c);
|
|
3352
|
+
}
|
|
3353
|
+
for (const c of lookup.values()) cookies[c.name] = c.value;
|
|
3354
|
+
return Object.entries(cookies).map(([name, value]) => ({
|
|
3355
|
+
name,
|
|
3356
|
+
value
|
|
3357
|
+
}));
|
|
3358
|
+
},
|
|
3359
|
+
/**
|
|
3360
|
+
* @param {string} name
|
|
3361
|
+
* @param {string} value
|
|
3362
|
+
* @param {import('./page/types.js').Cookie['options']} options
|
|
3363
|
+
*/
|
|
3364
|
+
set(name, value, options) {
|
|
3365
|
+
const illegal_characters = name.match(INVALID_COOKIE_CHARACTER_REGEX);
|
|
3366
|
+
if (illegal_characters) console.warn(`The cookie name "${name}" will be invalid in SvelteKit 3.0 as it contains ${illegal_characters.join(" and ")}. See RFC 2616 for more details https://datatracker.ietf.org/doc/html/rfc2616#section-2.2`);
|
|
3367
|
+
validate_options(options);
|
|
3368
|
+
set_internal(name, value, {
|
|
3369
|
+
...defaults,
|
|
3370
|
+
...options
|
|
3371
|
+
});
|
|
3372
|
+
},
|
|
3373
|
+
/**
|
|
3374
|
+
* @param {string} name
|
|
3375
|
+
* @param {import('./page/types.js').Cookie['options']} options
|
|
3376
|
+
*/
|
|
3377
|
+
delete(name, options) {
|
|
3378
|
+
validate_options(options);
|
|
3379
|
+
cookies.set(name, "", {
|
|
3380
|
+
...options,
|
|
3381
|
+
maxAge: 0
|
|
3382
|
+
});
|
|
3383
|
+
},
|
|
3384
|
+
/**
|
|
3385
|
+
* @param {string} name
|
|
3386
|
+
* @param {string} value
|
|
3387
|
+
* @param {import('./page/types.js').Cookie['options']} options
|
|
3388
|
+
*/
|
|
3389
|
+
serialize(name, value, options) {
|
|
3390
|
+
validate_options(options);
|
|
3391
|
+
let path = options.path;
|
|
3392
|
+
if (!options.domain || options.domain === url.hostname) {
|
|
3393
|
+
if (!normalized_url) throw new Error("Cannot serialize cookies until after the route is determined");
|
|
3394
|
+
path = resolve(normalized_url, path);
|
|
3395
|
+
}
|
|
3396
|
+
return (0, import_cookie.serialize)(name, value, {
|
|
3397
|
+
...defaults,
|
|
3398
|
+
...options,
|
|
3399
|
+
path
|
|
3400
|
+
});
|
|
3401
|
+
}
|
|
3402
|
+
};
|
|
3403
|
+
/**
|
|
3404
|
+
* @param {URL} destination
|
|
3405
|
+
* @param {string | null} header
|
|
3406
|
+
*/
|
|
3407
|
+
function get_cookie_header(destination, header) {
|
|
3408
|
+
/** @type {Record<string, string>} */
|
|
3409
|
+
const combined_cookies = { ...initial_cookies };
|
|
3410
|
+
for (const cookie of new_cookies.values()) {
|
|
3411
|
+
if (!domain_matches(destination.hostname, cookie.options.domain)) continue;
|
|
3412
|
+
if (!path_matches(destination.pathname, cookie.options.path)) continue;
|
|
3413
|
+
const encoder = cookie.options.encode || encodeURIComponent;
|
|
3414
|
+
combined_cookies[cookie.name] = encoder(cookie.value);
|
|
3415
|
+
}
|
|
3416
|
+
if (header) {
|
|
3417
|
+
const parsed = (0, import_cookie.parse)(header, { decode: (value) => value });
|
|
3418
|
+
for (const name in parsed) combined_cookies[name] = parsed[name];
|
|
3419
|
+
}
|
|
3420
|
+
return Object.entries(combined_cookies).map(([name, value]) => `${name}=${value}`).join("; ");
|
|
3421
|
+
}
|
|
3422
|
+
/** @type {Array<() => void>} */
|
|
3423
|
+
const internal_queue = [];
|
|
3424
|
+
/**
|
|
3425
|
+
* @param {string} name
|
|
3426
|
+
* @param {string} value
|
|
3427
|
+
* @param {import('./page/types.js').Cookie['options']} options
|
|
3428
|
+
*/
|
|
3429
|
+
function set_internal(name, value, options) {
|
|
3430
|
+
if (!normalized_url) {
|
|
3431
|
+
internal_queue.push(() => set_internal(name, value, options));
|
|
3432
|
+
return;
|
|
3433
|
+
}
|
|
3434
|
+
let path = options.path;
|
|
3435
|
+
if (!options.domain || options.domain === url.hostname) path = resolve(normalized_url, path);
|
|
3436
|
+
const cookie_key = generate_cookie_key(options.domain, path, name);
|
|
3437
|
+
const cookie = {
|
|
3438
|
+
name,
|
|
3439
|
+
value,
|
|
3440
|
+
options: {
|
|
3441
|
+
...options,
|
|
3442
|
+
path
|
|
3443
|
+
}
|
|
3444
|
+
};
|
|
3445
|
+
new_cookies.set(cookie_key, cookie);
|
|
3446
|
+
}
|
|
3447
|
+
/**
|
|
3448
|
+
* @param {import('types').TrailingSlash} trailing_slash
|
|
3449
|
+
*/
|
|
3450
|
+
function set_trailing_slash(trailing_slash) {
|
|
3451
|
+
normalized_url = normalize_path(url.pathname, trailing_slash);
|
|
3452
|
+
internal_queue.forEach((fn) => fn());
|
|
3453
|
+
}
|
|
3454
|
+
return {
|
|
3455
|
+
cookies,
|
|
3456
|
+
new_cookies,
|
|
3457
|
+
get_cookie_header,
|
|
3458
|
+
set_internal,
|
|
3459
|
+
set_trailing_slash
|
|
3460
|
+
};
|
|
3461
|
+
}
|
|
3462
|
+
/**
|
|
3463
|
+
* @param {string} hostname
|
|
3464
|
+
* @param {string} [constraint]
|
|
3465
|
+
*/
|
|
3466
|
+
function domain_matches(hostname, constraint) {
|
|
3467
|
+
if (!constraint) return true;
|
|
3468
|
+
const normalized = constraint[0] === "." ? constraint.slice(1) : constraint;
|
|
3469
|
+
if (hostname === normalized) return true;
|
|
3470
|
+
return hostname.endsWith("." + normalized);
|
|
3471
|
+
}
|
|
3472
|
+
/**
|
|
3473
|
+
* @param {string} path
|
|
3474
|
+
* @param {string} [constraint]
|
|
3475
|
+
*/
|
|
3476
|
+
function path_matches(path, constraint) {
|
|
3477
|
+
if (!constraint) return true;
|
|
3478
|
+
const normalized = constraint.endsWith("/") ? constraint.slice(0, -1) : constraint;
|
|
3479
|
+
if (path === normalized) return true;
|
|
3480
|
+
return path.startsWith(normalized + "/");
|
|
3481
|
+
}
|
|
3482
|
+
/**
|
|
3483
|
+
* @param {Headers} headers
|
|
3484
|
+
* @param {MapIterator<import('./page/types.js').Cookie>} cookies
|
|
3485
|
+
*/
|
|
3486
|
+
function add_cookies_to_headers(headers, cookies) {
|
|
3487
|
+
for (const new_cookie of cookies) {
|
|
3488
|
+
const { name, value, options } = new_cookie;
|
|
3489
|
+
headers.append("set-cookie", (0, import_cookie.serialize)(name, value, options));
|
|
3490
|
+
if (options.path.endsWith(".html")) {
|
|
3491
|
+
const path = add_data_suffix(options.path);
|
|
3492
|
+
headers.append("set-cookie", (0, import_cookie.serialize)(name, value, {
|
|
3493
|
+
...options,
|
|
3494
|
+
path
|
|
3495
|
+
}));
|
|
3496
|
+
}
|
|
3497
|
+
}
|
|
3498
|
+
}
|
|
3499
|
+
//#endregion
|
|
3500
|
+
//#region ../../node_modules/.bun/set-cookie-parser@3.1.0/node_modules/set-cookie-parser/lib/set-cookie.js
|
|
3501
|
+
var defaultParseOptions = {
|
|
3502
|
+
decodeValues: true,
|
|
3503
|
+
map: false,
|
|
3504
|
+
silent: false,
|
|
3505
|
+
split: "auto"
|
|
3506
|
+
};
|
|
3507
|
+
function isForbiddenKey(key) {
|
|
3508
|
+
return typeof key !== "string" || key in {};
|
|
3509
|
+
}
|
|
3510
|
+
function createNullObj() {
|
|
3511
|
+
return Object.create(null);
|
|
3512
|
+
}
|
|
3513
|
+
function isNonEmptyString(str) {
|
|
3514
|
+
return typeof str === "string" && !!str.trim();
|
|
3515
|
+
}
|
|
3516
|
+
function parseString(setCookieValue, options) {
|
|
3517
|
+
var parts = setCookieValue.split(";").filter(isNonEmptyString);
|
|
3518
|
+
var parsed = parseNameValuePair(parts.shift());
|
|
3519
|
+
var name = parsed.name;
|
|
3520
|
+
var value = parsed.value;
|
|
3521
|
+
options = options ? Object.assign({}, defaultParseOptions, options) : defaultParseOptions;
|
|
3522
|
+
if (isForbiddenKey(name)) return null;
|
|
3523
|
+
try {
|
|
3524
|
+
value = options.decodeValues ? decodeURIComponent(value) : value;
|
|
3525
|
+
} catch (e) {
|
|
3526
|
+
console.error("set-cookie-parser: failed to decode cookie value. Set options.decodeValues=false to disable decoding.", e);
|
|
3527
|
+
}
|
|
3528
|
+
var cookie = createNullObj();
|
|
3529
|
+
cookie.name = name;
|
|
3530
|
+
cookie.value = value;
|
|
3531
|
+
parts.forEach(function(part) {
|
|
3532
|
+
var sides = part.split("=");
|
|
3533
|
+
var key = sides.shift().trimLeft().toLowerCase();
|
|
3534
|
+
if (isForbiddenKey(key)) return;
|
|
3535
|
+
var value = sides.join("=");
|
|
3536
|
+
if (key === "expires") cookie.expires = new Date(value);
|
|
3537
|
+
else if (key === "max-age") {
|
|
3538
|
+
var n = parseInt(value, 10);
|
|
3539
|
+
if (!Number.isNaN(n)) cookie.maxAge = n;
|
|
3540
|
+
} else if (key === "secure") cookie.secure = true;
|
|
3541
|
+
else if (key === "httponly") cookie.httpOnly = true;
|
|
3542
|
+
else if (key === "samesite") cookie.sameSite = value;
|
|
3543
|
+
else if (key === "partitioned") cookie.partitioned = true;
|
|
3544
|
+
else if (key) cookie[key] = value;
|
|
3545
|
+
});
|
|
3546
|
+
return cookie;
|
|
3547
|
+
}
|
|
3548
|
+
function parseNameValuePair(nameValuePairStr) {
|
|
3549
|
+
var name = "";
|
|
3550
|
+
var value = "";
|
|
3551
|
+
var nameValueArr = nameValuePairStr.split("=");
|
|
3552
|
+
if (nameValueArr.length > 1) {
|
|
3553
|
+
name = nameValueArr.shift();
|
|
3554
|
+
value = nameValueArr.join("=");
|
|
3555
|
+
} else value = nameValuePairStr;
|
|
3556
|
+
return {
|
|
3557
|
+
name,
|
|
3558
|
+
value
|
|
3559
|
+
};
|
|
3560
|
+
}
|
|
3561
|
+
function parseSetCookie(input, options) {
|
|
3562
|
+
options = options ? Object.assign({}, defaultParseOptions, options) : defaultParseOptions;
|
|
3563
|
+
if (!input) if (!options.map) return [];
|
|
3564
|
+
else return createNullObj();
|
|
3565
|
+
if (input.headers) if (typeof input.headers.getSetCookie === "function") input = input.headers.getSetCookie();
|
|
3566
|
+
else if (input.headers["set-cookie"]) input = input.headers["set-cookie"];
|
|
3567
|
+
else {
|
|
3568
|
+
var sch = input.headers[Object.keys(input.headers).find(function(key) {
|
|
3569
|
+
return key.toLowerCase() === "set-cookie";
|
|
3570
|
+
})];
|
|
3571
|
+
if (!sch && input.headers.cookie && !options.silent) console.warn("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.");
|
|
3572
|
+
input = sch;
|
|
3573
|
+
}
|
|
3574
|
+
var split = options.split;
|
|
3575
|
+
var isArray = Array.isArray(input);
|
|
3576
|
+
if (split === "auto") split = !isArray;
|
|
3577
|
+
if (!isArray) input = [input];
|
|
3578
|
+
input = input.filter(isNonEmptyString);
|
|
3579
|
+
if (split) input = input.map(splitCookiesString).flat();
|
|
3580
|
+
if (!options.map) return input.map(function(str) {
|
|
3581
|
+
return parseString(str, options);
|
|
3582
|
+
}).filter(Boolean);
|
|
3583
|
+
else {
|
|
3584
|
+
var cookies = createNullObj();
|
|
3585
|
+
return input.reduce(function(cookies, str) {
|
|
3586
|
+
var cookie = parseString(str, options);
|
|
3587
|
+
if (cookie && !isForbiddenKey(cookie.name)) cookies[cookie.name] = cookie;
|
|
3588
|
+
return cookies;
|
|
3589
|
+
}, cookies);
|
|
3590
|
+
}
|
|
3591
|
+
}
|
|
3592
|
+
function splitCookiesString(cookiesString) {
|
|
3593
|
+
if (Array.isArray(cookiesString)) return cookiesString;
|
|
3594
|
+
if (typeof cookiesString !== "string") return [];
|
|
3595
|
+
var cookiesStrings = [];
|
|
3596
|
+
var pos = 0;
|
|
3597
|
+
var start;
|
|
3598
|
+
var ch;
|
|
3599
|
+
var lastComma;
|
|
3600
|
+
var nextStart;
|
|
3601
|
+
var cookiesSeparatorFound;
|
|
3602
|
+
function skipWhitespace() {
|
|
3603
|
+
while (pos < cookiesString.length && /\s/.test(cookiesString.charAt(pos))) pos += 1;
|
|
3604
|
+
return pos < cookiesString.length;
|
|
3605
|
+
}
|
|
3606
|
+
function notSpecialChar() {
|
|
3607
|
+
ch = cookiesString.charAt(pos);
|
|
3608
|
+
return ch !== "=" && ch !== ";" && ch !== ",";
|
|
3609
|
+
}
|
|
3610
|
+
while (pos < cookiesString.length) {
|
|
3611
|
+
start = pos;
|
|
3612
|
+
cookiesSeparatorFound = false;
|
|
3613
|
+
while (skipWhitespace()) {
|
|
3614
|
+
ch = cookiesString.charAt(pos);
|
|
3615
|
+
if (ch === ",") {
|
|
3616
|
+
lastComma = pos;
|
|
3617
|
+
pos += 1;
|
|
3618
|
+
skipWhitespace();
|
|
3619
|
+
nextStart = pos;
|
|
3620
|
+
while (pos < cookiesString.length && notSpecialChar()) pos += 1;
|
|
3621
|
+
if (pos < cookiesString.length && cookiesString.charAt(pos) === "=") {
|
|
3622
|
+
cookiesSeparatorFound = true;
|
|
3623
|
+
pos = nextStart;
|
|
3624
|
+
cookiesStrings.push(cookiesString.substring(start, lastComma));
|
|
3625
|
+
start = pos;
|
|
3626
|
+
} else pos = lastComma + 1;
|
|
3627
|
+
} else pos += 1;
|
|
3628
|
+
}
|
|
3629
|
+
if (!cookiesSeparatorFound || pos >= cookiesString.length) cookiesStrings.push(cookiesString.substring(start, cookiesString.length));
|
|
3630
|
+
}
|
|
3631
|
+
return cookiesStrings;
|
|
3632
|
+
}
|
|
3633
|
+
parseSetCookie.parseSetCookie = parseSetCookie;
|
|
3634
|
+
parseSetCookie.parse = parseSetCookie;
|
|
3635
|
+
parseSetCookie.parseString = parseString;
|
|
3636
|
+
parseSetCookie.splitCookiesString = splitCookiesString;
|
|
3637
|
+
//#endregion
|
|
3638
|
+
//#region ../../node_modules/.bun/@sveltejs+kit@2.61.0+aeb06e9cf8e23ab6/node_modules/@sveltejs/kit/src/runtime/server/fetch.js
|
|
3639
|
+
/**
|
|
3640
|
+
* @param {{
|
|
3641
|
+
* event: import('@sveltejs/kit').RequestEvent;
|
|
3642
|
+
* options: import('types').SSROptions;
|
|
3643
|
+
* manifest: import('@sveltejs/kit').SSRManifest;
|
|
3644
|
+
* state: import('types').SSRState;
|
|
3645
|
+
* get_cookie_header: (url: URL, header: string | null) => string;
|
|
3646
|
+
* set_internal: (name: string, value: string, opts: import('./page/types.js').Cookie['options']) => void;
|
|
3647
|
+
* }} opts
|
|
3648
|
+
* @returns {typeof fetch}
|
|
3649
|
+
*/
|
|
3650
|
+
function create_fetch({ event, options, manifest, state, get_cookie_header, set_internal }) {
|
|
3651
|
+
/**
|
|
3652
|
+
* @type {typeof fetch}
|
|
3653
|
+
*/
|
|
3654
|
+
const server_fetch = async (info, init) => {
|
|
3655
|
+
const original_request = normalize_fetch_input(info, init, event.url);
|
|
3656
|
+
let mode = (info instanceof Request ? info.mode : init?.mode) ?? "cors";
|
|
3657
|
+
let credentials = (info instanceof Request ? info.credentials : init?.credentials) ?? "same-origin";
|
|
3658
|
+
return options.hooks.handleFetch({
|
|
3659
|
+
event,
|
|
3660
|
+
request: original_request,
|
|
3661
|
+
fetch: async (info, init) => {
|
|
3662
|
+
const request = normalize_fetch_input(info, init, event.url);
|
|
3663
|
+
const url = new URL(request.url);
|
|
3664
|
+
if (!request.headers.has("origin")) request.headers.set("origin", event.url.origin);
|
|
3665
|
+
if (info !== original_request) {
|
|
3666
|
+
mode = (info instanceof Request ? info.mode : init?.mode) ?? "cors";
|
|
3667
|
+
credentials = (info instanceof Request ? info.credentials : init?.credentials) ?? "same-origin";
|
|
3668
|
+
}
|
|
3669
|
+
if ((request.method === "GET" || request.method === "HEAD") && (mode === "no-cors" && url.origin !== event.url.origin || url.origin === event.url.origin)) request.headers.delete("origin");
|
|
3670
|
+
const decoded = decodeURIComponent(url.pathname);
|
|
3671
|
+
if (url.origin !== event.url.origin || base && decoded !== base && !decoded.startsWith(`${base}/`)) {
|
|
3672
|
+
if (`.${url.hostname}`.endsWith(`.${event.url.hostname}`) && credentials !== "omit") {
|
|
3673
|
+
const cookie = get_cookie_header(url, request.headers.get("cookie"));
|
|
3674
|
+
if (cookie) request.headers.set("cookie", cookie);
|
|
3675
|
+
}
|
|
3676
|
+
return fetch(request);
|
|
3677
|
+
}
|
|
3678
|
+
const prefix = assets || base;
|
|
3679
|
+
const filename = (decoded.startsWith(prefix) ? decoded.slice(prefix.length) : decoded).slice(1);
|
|
3680
|
+
const filename_html = `${filename}/index.html`;
|
|
3681
|
+
const is_asset = manifest.assets.has(filename) || filename in manifest._.server_assets;
|
|
3682
|
+
const is_asset_html = manifest.assets.has(filename_html) || filename_html in manifest._.server_assets;
|
|
3683
|
+
if (is_asset || is_asset_html) {
|
|
3684
|
+
const file = is_asset ? filename : filename_html;
|
|
3685
|
+
if (state.read) {
|
|
3686
|
+
const type = is_asset ? manifest.mimeTypes[filename.slice(filename.lastIndexOf("."))] : "text/html";
|
|
3687
|
+
return new Response(state.read(file), { headers: type ? { "content-type": type } : {} });
|
|
3688
|
+
} else if (read_implementation && file in manifest._.server_assets) {
|
|
3689
|
+
const length = manifest._.server_assets[file];
|
|
3690
|
+
const type = manifest.mimeTypes[file.slice(file.lastIndexOf("."))];
|
|
3691
|
+
return new Response(read_implementation(file), { headers: {
|
|
3692
|
+
"Content-Length": "" + length,
|
|
3693
|
+
"Content-Type": type
|
|
3694
|
+
} });
|
|
3695
|
+
}
|
|
3696
|
+
return await fetch(request);
|
|
3697
|
+
}
|
|
3698
|
+
if (has_prerendered_path(manifest, base + decoded)) return await fetch(request);
|
|
3699
|
+
if (credentials !== "omit") {
|
|
3700
|
+
const cookie = get_cookie_header(url, request.headers.get("cookie"));
|
|
3701
|
+
if (cookie) request.headers.set("cookie", cookie);
|
|
3702
|
+
const authorization = event.request.headers.get("authorization");
|
|
3703
|
+
if (authorization && !request.headers.has("authorization")) request.headers.set("authorization", authorization);
|
|
3704
|
+
}
|
|
3705
|
+
if (!request.headers.has("accept")) request.headers.set("accept", "*/*");
|
|
3706
|
+
if (!request.headers.has("accept-language")) request.headers.set("accept-language", event.request.headers.get("accept-language"));
|
|
3707
|
+
const response = await internal_fetch(request, options, manifest, state);
|
|
3708
|
+
const set_cookie = response.headers.get("set-cookie");
|
|
3709
|
+
if (set_cookie) for (const str of splitCookiesString(set_cookie)) {
|
|
3710
|
+
const { name, value, ...options } = parseString(str, { decodeValues: false });
|
|
3711
|
+
set_internal(name, value, {
|
|
3712
|
+
path: options.path ?? (url.pathname.split("/").slice(0, -1).join("/") || "/"),
|
|
3713
|
+
encode: (value) => value,
|
|
3714
|
+
...options
|
|
3715
|
+
});
|
|
3716
|
+
}
|
|
3717
|
+
return response;
|
|
3718
|
+
}
|
|
3719
|
+
});
|
|
3720
|
+
};
|
|
3721
|
+
return (input, init) => {
|
|
3722
|
+
const response = server_fetch(input, init);
|
|
3723
|
+
response.catch(noop);
|
|
3724
|
+
return response;
|
|
3725
|
+
};
|
|
3726
|
+
}
|
|
3727
|
+
/**
|
|
3728
|
+
* @param {RequestInfo | URL} info
|
|
3729
|
+
* @param {RequestInit | undefined} init
|
|
3730
|
+
* @param {URL} url
|
|
3731
|
+
*/
|
|
3732
|
+
function normalize_fetch_input(info, init, url) {
|
|
3733
|
+
if (info instanceof Request) return info;
|
|
3734
|
+
return new Request(typeof info === "string" ? new URL(info, url) : info, init);
|
|
3735
|
+
}
|
|
3736
|
+
/**
|
|
3737
|
+
* @param {Request} request
|
|
3738
|
+
* @param {import('types').SSROptions} options
|
|
3739
|
+
* @param {import('@sveltejs/kit').SSRManifest} manifest
|
|
3740
|
+
* @param {import('types').SSRState} state
|
|
3741
|
+
* @returns {Promise<Response>}
|
|
3742
|
+
*/
|
|
3743
|
+
async function internal_fetch(request, options, manifest, state) {
|
|
3744
|
+
if (request.signal) {
|
|
3745
|
+
if (request.signal.aborted) throw new DOMException("The operation was aborted.", "AbortError");
|
|
3746
|
+
let remove_abort_listener = noop;
|
|
3747
|
+
/** @type {Promise<never>} */
|
|
3748
|
+
const abort_promise = new Promise((_, reject) => {
|
|
3749
|
+
const on_abort = () => {
|
|
3750
|
+
reject(new DOMException("The operation was aborted.", "AbortError"));
|
|
3751
|
+
};
|
|
3752
|
+
request.signal.addEventListener("abort", on_abort, { once: true });
|
|
3753
|
+
remove_abort_listener = () => request.signal.removeEventListener("abort", on_abort);
|
|
3754
|
+
});
|
|
3755
|
+
const result = await Promise.race([respond(request, options, manifest, {
|
|
3756
|
+
...state,
|
|
3757
|
+
depth: state.depth + 1
|
|
3758
|
+
}), abort_promise]);
|
|
3759
|
+
remove_abort_listener();
|
|
3760
|
+
return result;
|
|
3761
|
+
} else return await respond(request, options, manifest, {
|
|
3762
|
+
...state,
|
|
3763
|
+
depth: state.depth + 1
|
|
3764
|
+
});
|
|
3765
|
+
}
|
|
3766
|
+
//#endregion
|
|
3767
|
+
//#region ../../node_modules/.bun/@sveltejs+kit@2.61.0+aeb06e9cf8e23ab6/node_modules/@sveltejs/kit/src/runtime/server/env_module.js
|
|
3768
|
+
/** @type {string} */
|
|
3769
|
+
var body;
|
|
3770
|
+
/** @type {string} */
|
|
3771
|
+
var etag;
|
|
3772
|
+
/** @type {Headers} */
|
|
3773
|
+
var headers;
|
|
3774
|
+
/**
|
|
3775
|
+
* @param {Request} request
|
|
3776
|
+
* @returns {Response}
|
|
3777
|
+
*/
|
|
3778
|
+
function get_public_env(request) {
|
|
3779
|
+
body ??= `export const env=${JSON.stringify(public_env)}`;
|
|
3780
|
+
etag ??= `W/${Date.now()}`;
|
|
3781
|
+
headers ??= new Headers({
|
|
3782
|
+
"content-type": "application/javascript; charset=utf-8",
|
|
3783
|
+
etag
|
|
3784
|
+
});
|
|
3785
|
+
if (request.headers.get("if-none-match") === etag) return new Response(void 0, {
|
|
3786
|
+
status: 304,
|
|
3787
|
+
headers
|
|
3788
|
+
});
|
|
3789
|
+
return new Response(body, { headers });
|
|
3790
|
+
}
|
|
3791
|
+
//#endregion
|
|
3792
|
+
//#region ../../node_modules/.bun/@sveltejs+kit@2.61.0+aeb06e9cf8e23ab6/node_modules/@sveltejs/kit/src/runtime/server/respond.js
|
|
3793
|
+
/** @import { RequestState, SSRNode } from 'types' */
|
|
3794
|
+
/** @type {import('types').RequiredResolveOptions['transformPageChunk']} */
|
|
3795
|
+
var default_transform = ({ html }) => html;
|
|
3796
|
+
/** @type {import('types').RequiredResolveOptions['filterSerializedResponseHeaders']} */
|
|
3797
|
+
var default_filter = () => false;
|
|
3798
|
+
/** @type {import('types').RequiredResolveOptions['preload']} */
|
|
3799
|
+
var default_preload = ({ type }) => type === "js" || type === "css";
|
|
3800
|
+
var page_methods = new Set([
|
|
3801
|
+
"GET",
|
|
3802
|
+
"HEAD",
|
|
3803
|
+
"POST"
|
|
3804
|
+
]);
|
|
3805
|
+
var allowed_page_methods = new Set([
|
|
3806
|
+
"GET",
|
|
3807
|
+
"HEAD",
|
|
3808
|
+
"OPTIONS"
|
|
3809
|
+
]);
|
|
3810
|
+
var respond = propagate_context(internal_respond);
|
|
3811
|
+
/**
|
|
3812
|
+
* @param {Request} request
|
|
3813
|
+
* @param {import('types').SSROptions} options
|
|
3814
|
+
* @param {import('@sveltejs/kit').SSRManifest} manifest
|
|
3815
|
+
* @param {import('types').SSRState} state
|
|
3816
|
+
* @returns {Promise<Response>}
|
|
3817
|
+
*/
|
|
3818
|
+
async function internal_respond(request, options, manifest, state) {
|
|
3819
|
+
/** URL but stripped from the potential `/__data.json` suffix and its search param */
|
|
3820
|
+
const url = new URL(request.url);
|
|
3821
|
+
const is_route_resolution_request = has_resolution_suffix(url.pathname);
|
|
3822
|
+
const is_data_request = has_data_suffix(url.pathname);
|
|
3823
|
+
const remote_id = get_remote_id(url);
|
|
3824
|
+
{
|
|
3825
|
+
const request_origin = request.headers.get("origin");
|
|
3826
|
+
if (remote_id) {
|
|
3827
|
+
if (request.method !== "GET" && request_origin !== url.origin) return json({ message: "Cross-site remote requests are forbidden" }, { status: 403 });
|
|
3828
|
+
} else if (options.csrf_check_origin) {
|
|
3829
|
+
if (is_form_content_type(request) && (request.method === "POST" || request.method === "PUT" || request.method === "PATCH" || request.method === "DELETE") && request_origin !== url.origin && (!request_origin || !options.csrf_trusted_origins.includes(request_origin))) {
|
|
3830
|
+
const message = `Cross-site ${request.method} form submissions are forbidden`;
|
|
3831
|
+
const opts = { status: 403 };
|
|
3832
|
+
if (request.headers.get("accept") === "application/json") return json({ message }, opts);
|
|
3833
|
+
return text(message, opts);
|
|
3834
|
+
}
|
|
3835
|
+
}
|
|
3836
|
+
}
|
|
3837
|
+
if (options.hash_routing && url.pathname !== base + "/" && url.pathname !== "/[fallback]") return text("Not found", { status: 404 });
|
|
3838
|
+
/** @type {boolean[] | undefined} */
|
|
3839
|
+
let invalidated_data_nodes;
|
|
3840
|
+
if (is_route_resolution_request)
|
|
3841
|
+
/**
|
|
3842
|
+
* If the request is for a route resolution, first modify the URL, then continue as normal
|
|
3843
|
+
* for path resolution, then return the route object as a JS file.
|
|
3844
|
+
*/
|
|
3845
|
+
url.pathname = strip_resolution_suffix(url.pathname);
|
|
3846
|
+
else if (is_data_request) {
|
|
3847
|
+
url.pathname = strip_data_suffix(url.pathname) + (url.searchParams.get("x-sveltekit-trailing-slash") === "1" ? "/" : "") || "/";
|
|
3848
|
+
url.searchParams.delete(TRAILING_SLASH_PARAM);
|
|
3849
|
+
invalidated_data_nodes = url.searchParams.get(INVALIDATED_PARAM)?.split("").map((node) => node === "1");
|
|
3850
|
+
url.searchParams.delete(INVALIDATED_PARAM);
|
|
3851
|
+
} else if (remote_id) {
|
|
3852
|
+
url.pathname = request.headers.get("x-sveltekit-pathname") ?? base;
|
|
3853
|
+
url.search = request.headers.get("x-sveltekit-search") ?? "";
|
|
3854
|
+
}
|
|
3855
|
+
/** @type {Record<string, string>} */
|
|
3856
|
+
const headers = {};
|
|
3857
|
+
const { cookies, new_cookies, get_cookie_header, set_internal, set_trailing_slash } = get_cookies(request, url);
|
|
3858
|
+
/** @type {RequestState} */
|
|
3859
|
+
const event_state = {
|
|
3860
|
+
prerendering: state.prerendering,
|
|
3861
|
+
transport: options.hooks.transport,
|
|
3862
|
+
handleValidationError: options.hooks.handleValidationError,
|
|
3863
|
+
tracing: { record_span },
|
|
3864
|
+
remote: {
|
|
3865
|
+
data: null,
|
|
3866
|
+
forms: null,
|
|
3867
|
+
refreshes: null,
|
|
3868
|
+
requested: null,
|
|
3869
|
+
reconnects: null,
|
|
3870
|
+
batches: null,
|
|
3871
|
+
live_iterators: null
|
|
3872
|
+
},
|
|
3873
|
+
is_in_remote_function: false,
|
|
3874
|
+
is_in_render: false,
|
|
3875
|
+
is_in_universal_load: false
|
|
3876
|
+
};
|
|
3877
|
+
/** @type {import('@sveltejs/kit').RequestEvent} */
|
|
3878
|
+
const event = {
|
|
3879
|
+
cookies,
|
|
3880
|
+
fetch: null,
|
|
3881
|
+
getClientAddress: state.getClientAddress || (() => {
|
|
3882
|
+
throw new Error(`@sveltejs/adapter-node does not specify getClientAddress. Please raise an issue`);
|
|
3883
|
+
}),
|
|
3884
|
+
locals: {},
|
|
3885
|
+
params: {},
|
|
3886
|
+
platform: state.platform,
|
|
3887
|
+
request,
|
|
3888
|
+
route: { id: null },
|
|
3889
|
+
setHeaders: (new_headers) => {
|
|
3890
|
+
for (const key in new_headers) {
|
|
3891
|
+
const lower = key.toLowerCase();
|
|
3892
|
+
const value = new_headers[key];
|
|
3893
|
+
if (lower === "set-cookie") throw new Error("Use `event.cookies.set(name, value, options)` instead of `event.setHeaders` to set cookies");
|
|
3894
|
+
else if (lower in headers) if (lower === "server-timing") headers[lower] += ", " + value;
|
|
3895
|
+
else throw new Error(`"${key}" header is already set`);
|
|
3896
|
+
else {
|
|
3897
|
+
headers[lower] = value;
|
|
3898
|
+
if (state.prerendering && lower === "cache-control") state.prerendering.cache = value;
|
|
3899
|
+
}
|
|
3900
|
+
}
|
|
3901
|
+
},
|
|
3902
|
+
url,
|
|
3903
|
+
isDataRequest: is_data_request,
|
|
3904
|
+
isSubRequest: state.depth > 0,
|
|
3905
|
+
isRemoteRequest: !!remote_id
|
|
3906
|
+
};
|
|
3907
|
+
event.fetch = create_fetch({
|
|
3908
|
+
event,
|
|
3909
|
+
options,
|
|
3910
|
+
manifest,
|
|
3911
|
+
state,
|
|
3912
|
+
get_cookie_header,
|
|
3913
|
+
set_internal
|
|
3914
|
+
});
|
|
3915
|
+
if (state.emulator?.platform) event.platform = await state.emulator.platform({
|
|
3916
|
+
config: {},
|
|
3917
|
+
prerender: !!state.prerendering?.fallback
|
|
3918
|
+
});
|
|
3919
|
+
/** @type {string | null} */
|
|
3920
|
+
let resolved_path = url.pathname;
|
|
3921
|
+
if (!remote_id) {
|
|
3922
|
+
const prerendering_reroute_state = state.prerendering?.inside_reroute;
|
|
3923
|
+
try {
|
|
3924
|
+
if (state.prerendering) state.prerendering.inside_reroute = true;
|
|
3925
|
+
resolved_path = await options.hooks.reroute({
|
|
3926
|
+
url: new URL(url),
|
|
3927
|
+
fetch: event.fetch
|
|
3928
|
+
}) ?? url.pathname;
|
|
3929
|
+
} catch {
|
|
3930
|
+
return text("Internal Server Error", { status: 500 });
|
|
3931
|
+
} finally {
|
|
3932
|
+
if (state.prerendering) state.prerendering.inside_reroute = prerendering_reroute_state;
|
|
3933
|
+
}
|
|
3934
|
+
}
|
|
3935
|
+
/** @type {import('types').RequiredResolveOptions} */
|
|
3936
|
+
let resolve_opts = {
|
|
3937
|
+
transformPageChunk: default_transform,
|
|
3938
|
+
filterSerializedResponseHeaders: default_filter,
|
|
3939
|
+
preload: default_preload
|
|
3940
|
+
};
|
|
3941
|
+
/** @type {import('types').TrailingSlash} */
|
|
3942
|
+
let trailing_slash = "never";
|
|
3943
|
+
/** @type {PageNodes | undefined} */
|
|
3944
|
+
let page_nodes;
|
|
3945
|
+
try {
|
|
3946
|
+
resolved_path = decode_pathname(resolved_path);
|
|
3947
|
+
} catch {
|
|
3948
|
+
resolved_path = null;
|
|
3949
|
+
return await handle();
|
|
3950
|
+
}
|
|
3951
|
+
if (resolved_path !== decode_pathname(url.pathname) && !state.prerendering?.fallback && has_prerendered_path(manifest, resolved_path)) {
|
|
3952
|
+
const url = new URL(request.url);
|
|
3953
|
+
url.pathname = is_data_request ? add_data_suffix(resolved_path) : is_route_resolution_request ? add_resolution_suffix(resolved_path) : resolved_path;
|
|
3954
|
+
try {
|
|
3955
|
+
const response = await fetch(url, request);
|
|
3956
|
+
const headers = new Headers(response.headers);
|
|
3957
|
+
if (headers.has("content-encoding")) {
|
|
3958
|
+
headers.delete("content-encoding");
|
|
3959
|
+
headers.delete("content-length");
|
|
3960
|
+
}
|
|
3961
|
+
return new Response(response.body, {
|
|
3962
|
+
headers,
|
|
3963
|
+
status: response.status,
|
|
3964
|
+
statusText: response.statusText
|
|
3965
|
+
});
|
|
3966
|
+
} catch (error) {
|
|
3967
|
+
return await handle_fatal_error(event, event_state, options, error);
|
|
3968
|
+
}
|
|
3969
|
+
}
|
|
3970
|
+
/** @type {import('types').SSRRoute | null} */
|
|
3971
|
+
let route = null;
|
|
3972
|
+
if (base && !state.prerendering?.fallback) {
|
|
3973
|
+
if (!resolved_path.startsWith(base)) return text("Not found", { status: 404 });
|
|
3974
|
+
resolved_path = resolved_path.slice(base.length) || "/";
|
|
3975
|
+
}
|
|
3976
|
+
if (is_route_resolution_request) return resolve_route(resolved_path, new URL(request.url), manifest);
|
|
3977
|
+
if (resolved_path === `/_app/env.js`) return get_public_env(request);
|
|
3978
|
+
if (!remote_id && resolved_path.startsWith(`/_app`)) {
|
|
3979
|
+
const headers = new Headers();
|
|
3980
|
+
headers.set("cache-control", "public, max-age=0, must-revalidate");
|
|
3981
|
+
return text("Not found", {
|
|
3982
|
+
status: 404,
|
|
3983
|
+
headers
|
|
3984
|
+
});
|
|
3985
|
+
}
|
|
3986
|
+
if (!state.prerendering?.fallback) {
|
|
3987
|
+
const matchers = await manifest._.matchers();
|
|
3988
|
+
const result = find_route(resolved_path, manifest._.routes, matchers);
|
|
3989
|
+
if (result) {
|
|
3990
|
+
route = result.route;
|
|
3991
|
+
event.route = { id: route.id };
|
|
3992
|
+
event.params = result.params;
|
|
3993
|
+
}
|
|
3994
|
+
}
|
|
3995
|
+
try {
|
|
3996
|
+
page_nodes = route?.page ? new PageNodes(await load_page_nodes(route.page, manifest)) : void 0;
|
|
3997
|
+
if (route && !remote_id) {
|
|
3998
|
+
if (url.pathname === base || url.pathname === base + "/") trailing_slash = "always";
|
|
3999
|
+
else if (page_nodes) trailing_slash = page_nodes.trailing_slash();
|
|
4000
|
+
else if (route.endpoint) trailing_slash = (await route.endpoint()).trailingSlash ?? "never";
|
|
4001
|
+
if (!is_data_request) {
|
|
4002
|
+
const normalized = normalize_path(url.pathname, trailing_slash);
|
|
4003
|
+
if (normalized !== url.pathname && !state.prerendering?.fallback) return new Response(void 0, {
|
|
4004
|
+
status: 308,
|
|
4005
|
+
headers: {
|
|
4006
|
+
"x-sveltekit-normalize": "1",
|
|
4007
|
+
location: (normalized.startsWith("//") ? url.origin + normalized : normalized) + (url.search === "?" ? "" : url.search)
|
|
4008
|
+
}
|
|
4009
|
+
});
|
|
4010
|
+
}
|
|
4011
|
+
if (state.before_handle || state.emulator?.platform) {
|
|
4012
|
+
let config = {};
|
|
4013
|
+
/** @type {import('types').PrerenderOption} */
|
|
4014
|
+
let prerender = false;
|
|
4015
|
+
if (route.endpoint) {
|
|
4016
|
+
const node = await route.endpoint();
|
|
4017
|
+
config = node.config ?? config;
|
|
4018
|
+
prerender = node.prerender ?? prerender;
|
|
4019
|
+
} else if (page_nodes) {
|
|
4020
|
+
config = page_nodes.get_config() ?? config;
|
|
4021
|
+
prerender = page_nodes.prerender();
|
|
4022
|
+
}
|
|
4023
|
+
if (state.emulator?.platform) event.platform = await state.emulator.platform({
|
|
4024
|
+
config,
|
|
4025
|
+
prerender
|
|
4026
|
+
});
|
|
4027
|
+
if (state.before_handle) return await state.before_handle(event, config, prerender, handle);
|
|
4028
|
+
}
|
|
4029
|
+
}
|
|
4030
|
+
return await handle();
|
|
4031
|
+
} catch (e) {
|
|
4032
|
+
if (e instanceof Redirect) try {
|
|
4033
|
+
const response = is_data_request || remote_id ? redirect_json_response(e) : route?.page && is_action_json_request(event) ? action_json_redirect(e) : redirect_response(e.status, e.location);
|
|
4034
|
+
add_cookies_to_headers(response.headers, new_cookies.values());
|
|
4035
|
+
return response;
|
|
4036
|
+
} catch (err) {
|
|
4037
|
+
return await handle_fatal_error(event, event_state, options, err);
|
|
4038
|
+
}
|
|
4039
|
+
return await handle_fatal_error(event, event_state, options, e);
|
|
4040
|
+
}
|
|
4041
|
+
async function handle() {
|
|
4042
|
+
set_trailing_slash(trailing_slash);
|
|
4043
|
+
if (state.prerendering && !state.prerendering.fallback && !state.prerendering.inside_reroute) disable_search(url);
|
|
4044
|
+
const response = await record_span({
|
|
4045
|
+
name: "sveltekit.handle.root",
|
|
4046
|
+
attributes: {
|
|
4047
|
+
"http.route": event.route.id || "unknown",
|
|
4048
|
+
"http.method": event.request.method,
|
|
4049
|
+
"http.url": event.url.href,
|
|
4050
|
+
"sveltekit.is_sub_request": event.isSubRequest
|
|
4051
|
+
},
|
|
4052
|
+
fn: async (root_span) => {
|
|
4053
|
+
const traced_event = {
|
|
4054
|
+
...event,
|
|
4055
|
+
tracing: {
|
|
4056
|
+
enabled: false,
|
|
4057
|
+
root: root_span,
|
|
4058
|
+
current: root_span
|
|
4059
|
+
}
|
|
4060
|
+
};
|
|
4061
|
+
return await with_request_store({
|
|
4062
|
+
event: traced_event,
|
|
4063
|
+
state: event_state
|
|
4064
|
+
}, () => options.hooks.handle({
|
|
4065
|
+
event: traced_event,
|
|
4066
|
+
resolve: (event, opts) => {
|
|
4067
|
+
return record_span({
|
|
4068
|
+
name: "sveltekit.resolve",
|
|
4069
|
+
attributes: { "http.route": event.route.id || "unknown" },
|
|
4070
|
+
fn: (resolve_span) => {
|
|
4071
|
+
return with_request_store(null, () => resolve(merge_tracing(event, resolve_span), page_nodes, opts).then((response) => {
|
|
4072
|
+
for (const key in headers) {
|
|
4073
|
+
const value = headers[key];
|
|
4074
|
+
response.headers.set(key, value);
|
|
4075
|
+
}
|
|
4076
|
+
add_cookies_to_headers(response.headers, new_cookies.values());
|
|
4077
|
+
if (state.prerendering && event.route.id !== null) response.headers.set("x-sveltekit-routeid", encodeURI(event.route.id));
|
|
4078
|
+
resolve_span.setAttributes({
|
|
4079
|
+
"http.response.status_code": response.status,
|
|
4080
|
+
"http.response.body.size": response.headers.get("content-length") || "unknown"
|
|
4081
|
+
});
|
|
4082
|
+
return response;
|
|
4083
|
+
}));
|
|
4084
|
+
}
|
|
4085
|
+
});
|
|
4086
|
+
}
|
|
4087
|
+
}));
|
|
4088
|
+
}
|
|
4089
|
+
});
|
|
4090
|
+
if (response.status === 200 && response.headers.has("etag")) {
|
|
4091
|
+
let if_none_match_value = request.headers.get("if-none-match");
|
|
4092
|
+
if (if_none_match_value?.startsWith("W/\"")) if_none_match_value = if_none_match_value.substring(2);
|
|
4093
|
+
const etag = response.headers.get("etag");
|
|
4094
|
+
if (if_none_match_value === etag) {
|
|
4095
|
+
const headers = new Headers({ etag });
|
|
4096
|
+
for (const key of [
|
|
4097
|
+
"cache-control",
|
|
4098
|
+
"content-location",
|
|
4099
|
+
"date",
|
|
4100
|
+
"expires",
|
|
4101
|
+
"vary",
|
|
4102
|
+
"set-cookie"
|
|
4103
|
+
]) {
|
|
4104
|
+
const value = response.headers.get(key);
|
|
4105
|
+
if (value) headers.set(key, value);
|
|
4106
|
+
}
|
|
4107
|
+
return new Response(void 0, {
|
|
4108
|
+
status: 304,
|
|
4109
|
+
headers
|
|
4110
|
+
});
|
|
4111
|
+
}
|
|
4112
|
+
}
|
|
4113
|
+
if (is_data_request && response.status >= 300 && response.status <= 308) {
|
|
4114
|
+
const location = response.headers.get("location");
|
|
4115
|
+
if (location) return redirect_json_response(new Redirect(response.status, location));
|
|
4116
|
+
}
|
|
4117
|
+
return response;
|
|
4118
|
+
}
|
|
4119
|
+
/**
|
|
4120
|
+
* @param {import('@sveltejs/kit').RequestEvent} event
|
|
4121
|
+
* @param {PageNodes | undefined} page_nodes
|
|
4122
|
+
* @param {import('@sveltejs/kit').ResolveOptions} [opts]
|
|
4123
|
+
*/
|
|
4124
|
+
async function resolve(event, page_nodes, opts) {
|
|
4125
|
+
try {
|
|
4126
|
+
if (opts) resolve_opts = {
|
|
4127
|
+
transformPageChunk: opts.transformPageChunk || default_transform,
|
|
4128
|
+
filterSerializedResponseHeaders: opts.filterSerializedResponseHeaders || default_filter,
|
|
4129
|
+
preload: opts.preload || default_preload
|
|
4130
|
+
};
|
|
4131
|
+
if (resolved_path === null) return await respond_with_error({
|
|
4132
|
+
event,
|
|
4133
|
+
event_state,
|
|
4134
|
+
options,
|
|
4135
|
+
manifest,
|
|
4136
|
+
state,
|
|
4137
|
+
status: 400,
|
|
4138
|
+
error: new SvelteKitError(400, "Malformed URI", `Failed to decode URI: ${event.url.pathname}`),
|
|
4139
|
+
resolve_opts
|
|
4140
|
+
});
|
|
4141
|
+
if (options.hash_routing || state.prerendering?.fallback) return await render_response({
|
|
4142
|
+
event,
|
|
4143
|
+
event_state,
|
|
4144
|
+
options,
|
|
4145
|
+
manifest,
|
|
4146
|
+
state,
|
|
4147
|
+
page_config: {
|
|
4148
|
+
ssr: false,
|
|
4149
|
+
csr: true
|
|
4150
|
+
},
|
|
4151
|
+
status: 200,
|
|
4152
|
+
error: null,
|
|
4153
|
+
branch: [{
|
|
4154
|
+
node: await manifest._.nodes[0](),
|
|
4155
|
+
data: null,
|
|
4156
|
+
server_data: null
|
|
4157
|
+
}],
|
|
4158
|
+
fetched: [],
|
|
4159
|
+
resolve_opts,
|
|
4160
|
+
data_serializer: server_data_serializer(event, event_state, options)
|
|
4161
|
+
});
|
|
4162
|
+
if (remote_id) return await handle_remote_call(event, event_state, options, manifest, remote_id);
|
|
4163
|
+
if (route) {
|
|
4164
|
+
const method = event.request.method;
|
|
4165
|
+
/** @type {Response} */
|
|
4166
|
+
let response;
|
|
4167
|
+
if (is_data_request) response = await render_data(event, event_state, route, options, manifest, state, invalidated_data_nodes, trailing_slash);
|
|
4168
|
+
else if (route.endpoint && (!route.page || is_endpoint_request(event))) response = await render_endpoint(event, event_state, await route.endpoint(), state);
|
|
4169
|
+
else if (route.page) if (!page_nodes) throw new Error("page_nodes not found. This should never happen");
|
|
4170
|
+
else if (page_methods.has(method)) response = await render_page(event, event_state, route.page, options, manifest, state, page_nodes, resolve_opts);
|
|
4171
|
+
else {
|
|
4172
|
+
const allowed_methods = new Set(allowed_page_methods);
|
|
4173
|
+
if ((await manifest._.nodes[route.page.leaf]())?.server?.actions) allowed_methods.add("POST");
|
|
4174
|
+
if (method === "OPTIONS") response = new Response(null, {
|
|
4175
|
+
status: 204,
|
|
4176
|
+
headers: { allow: Array.from(allowed_methods.values()).join(", ") }
|
|
4177
|
+
});
|
|
4178
|
+
else response = method_not_allowed([...allowed_methods].reduce((acc, curr) => {
|
|
4179
|
+
acc[curr] = true;
|
|
4180
|
+
return acc;
|
|
4181
|
+
}, {}), method);
|
|
4182
|
+
}
|
|
4183
|
+
else throw new Error("Route is neither page nor endpoint. This should never happen");
|
|
4184
|
+
if (request.method === "GET" && route.page && route.endpoint) {
|
|
4185
|
+
const vary = response.headers.get("vary")?.split(",")?.map((v) => v.trim().toLowerCase());
|
|
4186
|
+
if (!(vary?.includes("accept") || vary?.includes("*"))) {
|
|
4187
|
+
response = new Response(response.body, {
|
|
4188
|
+
status: response.status,
|
|
4189
|
+
statusText: response.statusText,
|
|
4190
|
+
headers: new Headers(response.headers)
|
|
4191
|
+
});
|
|
4192
|
+
response.headers.append("Vary", "Accept");
|
|
4193
|
+
}
|
|
4194
|
+
}
|
|
4195
|
+
return response;
|
|
4196
|
+
}
|
|
4197
|
+
if (state.error && event.isSubRequest) {
|
|
4198
|
+
const headers = new Headers(request.headers);
|
|
4199
|
+
headers.set("x-sveltekit-error", "true");
|
|
4200
|
+
return await fetch(request, { headers });
|
|
4201
|
+
}
|
|
4202
|
+
if (state.error) return text("Internal Server Error", { status: 500 });
|
|
4203
|
+
if (state.depth === 0) return await respond_with_error({
|
|
4204
|
+
event,
|
|
4205
|
+
event_state,
|
|
4206
|
+
options,
|
|
4207
|
+
manifest,
|
|
4208
|
+
state,
|
|
4209
|
+
status: 404,
|
|
4210
|
+
error: new SvelteKitError(404, "Not Found", `Not found: ${event.url.pathname}`),
|
|
4211
|
+
resolve_opts
|
|
4212
|
+
});
|
|
4213
|
+
if (state.prerendering) return text("not found", { status: 404 });
|
|
4214
|
+
const response = await fetch(request);
|
|
4215
|
+
return new Response(response.body, response);
|
|
4216
|
+
} catch (e) {
|
|
4217
|
+
return await handle_fatal_error(event, event_state, options, e);
|
|
4218
|
+
} finally {
|
|
4219
|
+
event.cookies.set = () => {
|
|
4220
|
+
throw new Error("Cannot use `cookies.set(...)` after the response has been generated");
|
|
4221
|
+
};
|
|
4222
|
+
event.setHeaders = () => {
|
|
4223
|
+
throw new Error("Cannot use `setHeaders(...)` after the response has been generated");
|
|
4224
|
+
};
|
|
4225
|
+
}
|
|
4226
|
+
}
|
|
4227
|
+
}
|
|
4228
|
+
/**
|
|
4229
|
+
* @param {import('types').PageNodeIndexes} page
|
|
4230
|
+
* @param {import('@sveltejs/kit').SSRManifest} manifest
|
|
4231
|
+
*/
|
|
4232
|
+
function load_page_nodes(page, manifest) {
|
|
4233
|
+
return Promise.all([...page.layouts.map((n) => n == void 0 ? n : manifest._.nodes[n]()), manifest._.nodes[page.leaf]()]);
|
|
4234
|
+
}
|
|
4235
|
+
/**
|
|
4236
|
+
* It's likely that, in a distributed system, there are spans starting outside the SvelteKit server -- eg.
|
|
4237
|
+
* started on the frontend client, or in a service that calls the SvelteKit server. There are standardized
|
|
4238
|
+
* ways to represent this context in HTTP headers, so we can extract that context and run our tracing inside of it
|
|
4239
|
+
* so that when our traces are exported, they are associated with the correct parent context.
|
|
4240
|
+
* @param {typeof internal_respond} fn
|
|
4241
|
+
* @returns {typeof internal_respond}
|
|
4242
|
+
*/
|
|
4243
|
+
function propagate_context(fn) {
|
|
4244
|
+
return async (req, ...rest) => {
|
|
4245
|
+
return fn(req, ...rest);
|
|
4246
|
+
};
|
|
4247
|
+
}
|
|
4248
|
+
//#endregion
|
|
4249
|
+
//#region ../../node_modules/.bun/@sveltejs+kit@2.61.0+aeb06e9cf8e23ab6/node_modules/@sveltejs/kit/src/utils/env.js
|
|
4250
|
+
/**
|
|
4251
|
+
* @param {Record<string, string>} env
|
|
4252
|
+
* @param {string} allowed
|
|
4253
|
+
* @param {string} disallowed
|
|
4254
|
+
* @returns {Record<string, string>}
|
|
4255
|
+
*/
|
|
4256
|
+
function filter_env(env, allowed, disallowed) {
|
|
4257
|
+
return Object.fromEntries(Object.entries(env).filter(([k]) => k.startsWith(allowed) && (disallowed === "" || !k.startsWith(disallowed))));
|
|
4258
|
+
}
|
|
4259
|
+
//#endregion
|
|
4260
|
+
//#region ../../node_modules/.bun/@sveltejs+kit@2.61.0+aeb06e9cf8e23ab6/node_modules/@sveltejs/kit/src/runtime/server/index.js
|
|
4261
|
+
/** @import { PromiseWithResolvers } from '../../utils/promise.js' */
|
|
4262
|
+
/** @type {Promise<any>} */
|
|
4263
|
+
var init_promise;
|
|
4264
|
+
/** @type {Promise<void> | null} */
|
|
4265
|
+
var current = null;
|
|
4266
|
+
var Server = class {
|
|
4267
|
+
/** @type {import('types').SSROptions} */
|
|
4268
|
+
#options;
|
|
4269
|
+
/** @type {import('@sveltejs/kit').SSRManifest} */
|
|
4270
|
+
#manifest;
|
|
4271
|
+
/** @param {import('@sveltejs/kit').SSRManifest} manifest */
|
|
4272
|
+
constructor(manifest) {
|
|
4273
|
+
/** @type {import('types').SSROptions} */
|
|
4274
|
+
this.#options = options;
|
|
4275
|
+
this.#manifest = manifest;
|
|
4276
|
+
if (IN_WEBCONTAINER) {
|
|
4277
|
+
const respond = this.respond.bind(this);
|
|
4278
|
+
/** @type {typeof respond} */
|
|
4279
|
+
this.respond = async (...args) => {
|
|
4280
|
+
const { promise, resolve } = with_resolvers();
|
|
4281
|
+
const previous = current;
|
|
4282
|
+
current = promise;
|
|
4283
|
+
await previous;
|
|
4284
|
+
return respond(...args).finally(resolve);
|
|
4285
|
+
};
|
|
4286
|
+
}
|
|
4287
|
+
}
|
|
4288
|
+
/**
|
|
4289
|
+
* @param {import('@sveltejs/kit').ServerInitOptions} opts
|
|
4290
|
+
*/
|
|
4291
|
+
async init({ env, read }) {
|
|
4292
|
+
const { env_public_prefix, env_private_prefix } = this.#options;
|
|
4293
|
+
set_private_env(filter_env(env, env_private_prefix, env_public_prefix));
|
|
4294
|
+
set_public_env(filter_env(env, env_public_prefix, env_private_prefix));
|
|
4295
|
+
if (read) {
|
|
4296
|
+
/** @param {string} file */
|
|
4297
|
+
const wrapped_read = (file) => {
|
|
4298
|
+
const result = read(file);
|
|
4299
|
+
if (result instanceof ReadableStream) return result;
|
|
4300
|
+
else return new ReadableStream({ async start(controller) {
|
|
4301
|
+
try {
|
|
4302
|
+
const stream = await Promise.resolve(result);
|
|
4303
|
+
if (!stream) {
|
|
4304
|
+
controller.close();
|
|
4305
|
+
return;
|
|
4306
|
+
}
|
|
4307
|
+
const reader = stream.getReader();
|
|
4308
|
+
while (true) {
|
|
4309
|
+
const { done, value } = await reader.read();
|
|
4310
|
+
if (done) break;
|
|
4311
|
+
controller.enqueue(value);
|
|
4312
|
+
}
|
|
4313
|
+
controller.close();
|
|
4314
|
+
} catch (error) {
|
|
4315
|
+
controller.error(error);
|
|
4316
|
+
}
|
|
4317
|
+
} });
|
|
4318
|
+
};
|
|
4319
|
+
set_read_implementation(wrapped_read);
|
|
4320
|
+
}
|
|
4321
|
+
await (init_promise ??= (async () => {
|
|
4322
|
+
try {
|
|
4323
|
+
const module = await get_hooks();
|
|
4324
|
+
this.#options.hooks = {
|
|
4325
|
+
handle: module.handle || (({ event, resolve }) => resolve(event)),
|
|
4326
|
+
handleError: module.handleError || (({ status, error, event }) => {
|
|
4327
|
+
const error_message = format_server_error(status, error, event);
|
|
4328
|
+
console.error(error_message);
|
|
4329
|
+
}),
|
|
4330
|
+
handleFetch: module.handleFetch || (({ request, fetch }) => fetch(request)),
|
|
4331
|
+
handleValidationError: module.handleValidationError || (({ issues }) => {
|
|
4332
|
+
console.error("Remote function schema validation failed:", issues);
|
|
4333
|
+
return { message: "Bad Request" };
|
|
4334
|
+
}),
|
|
4335
|
+
reroute: module.reroute || noop,
|
|
4336
|
+
transport: module.transport || {}
|
|
4337
|
+
};
|
|
4338
|
+
module.transport && Object.fromEntries(Object.entries(module.transport).map(([k, v]) => [k, v.decode]));
|
|
4339
|
+
if (module.init) await module.init();
|
|
4340
|
+
} catch (e) {
|
|
4341
|
+
throw e;
|
|
4342
|
+
}
|
|
4343
|
+
})());
|
|
4344
|
+
}
|
|
4345
|
+
/**
|
|
4346
|
+
* @param {Request} request
|
|
4347
|
+
* @param {import('types').RequestOptions} options
|
|
4348
|
+
*/
|
|
4349
|
+
async respond(request, options) {
|
|
4350
|
+
return respond(request, this.#options, this.#manifest, {
|
|
4351
|
+
...options,
|
|
4352
|
+
error: false,
|
|
4353
|
+
depth: 0
|
|
4354
|
+
});
|
|
4355
|
+
}
|
|
4356
|
+
};
|
|
4357
|
+
|
|
4358
|
+
export { Server };
|
|
4359
|
+
//# sourceMappingURL=index.js.map
|