claude-mux 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.beads/README.md +81 -0
- package/.beads/config.yaml +62 -0
- package/.beads/interactions.jsonl +0 -0
- package/.beads/issues.jsonl +5 -0
- package/.beads/metadata.json +4 -0
- package/.eslintrc.json +25 -0
- package/.gitattributes +3 -0
- package/.prettierrc +7 -0
- package/CLAUDE.md +123 -0
- package/LICENSE +21 -0
- package/PLAN-beads-integration.md +250 -0
- package/README.md +366 -0
- package/dist/app.d.ts +2 -0
- package/dist/app.d.ts.map +1 -0
- package/dist/app.js +147 -0
- package/dist/app.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +65 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/index.d.ts +5 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/index.js +5 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/commands/serve.d.ts +8 -0
- package/dist/commands/serve.d.ts.map +1 -0
- package/dist/commands/serve.js +59 -0
- package/dist/commands/serve.js.map +1 -0
- package/dist/commands/setup.d.ts +4 -0
- package/dist/commands/setup.d.ts.map +1 -0
- package/dist/commands/setup.js +12 -0
- package/dist/commands/setup.js.map +1 -0
- package/dist/commands/tui.d.ts +9 -0
- package/dist/commands/tui.d.ts.map +1 -0
- package/dist/commands/tui.js +234 -0
- package/dist/commands/tui.js.map +1 -0
- package/dist/commands/uninstall.d.ts +4 -0
- package/dist/commands/uninstall.d.ts.map +1 -0
- package/dist/commands/uninstall.js +12 -0
- package/dist/commands/uninstall.js.map +1 -0
- package/dist/components/Header.d.ts +7 -0
- package/dist/components/Header.d.ts.map +1 -0
- package/dist/components/Header.js +14 -0
- package/dist/components/Header.js.map +1 -0
- package/dist/components/HelpDialog.d.ts +6 -0
- package/dist/components/HelpDialog.d.ts.map +1 -0
- package/dist/components/HelpDialog.js +14 -0
- package/dist/components/HelpDialog.js.map +1 -0
- package/dist/components/SessionEntry.d.ts +17 -0
- package/dist/components/SessionEntry.d.ts.map +1 -0
- package/dist/components/SessionEntry.js +102 -0
- package/dist/components/SessionEntry.js.map +1 -0
- package/dist/components/SessionList.d.ts +14 -0
- package/dist/components/SessionList.d.ts.map +1 -0
- package/dist/components/SessionList.js +57 -0
- package/dist/components/SessionList.js.map +1 -0
- package/dist/components/StatusBar.d.ts +6 -0
- package/dist/components/StatusBar.d.ts.map +1 -0
- package/dist/components/StatusBar.js +7 -0
- package/dist/components/StatusBar.js.map +1 -0
- package/dist/components/index.d.ts +6 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +6 -0
- package/dist/components/index.js.map +1 -0
- package/dist/db/index.d.ts +2 -0
- package/dist/db/index.d.ts.map +1 -0
- package/dist/db/index.js +3 -0
- package/dist/db/index.js.map +1 -0
- package/dist/db/schema.d.ts +4 -0
- package/dist/db/schema.d.ts.map +1 -0
- package/dist/db/schema.js +23 -0
- package/dist/db/schema.js.map +1 -0
- package/dist/db/sessions-json.d.ts +85 -0
- package/dist/db/sessions-json.d.ts.map +1 -0
- package/dist/db/sessions-json.js +242 -0
- package/dist/db/sessions-json.js.map +1 -0
- package/dist/db/sessions.d.ts +38 -0
- package/dist/db/sessions.d.ts.map +1 -0
- package/dist/db/sessions.js +87 -0
- package/dist/db/sessions.js.map +1 -0
- package/dist/hooks/claude-mux-hook.d.ts +15 -0
- package/dist/hooks/claude-mux-hook.d.ts.map +1 -0
- package/dist/hooks/claude-mux-hook.js +396 -0
- package/dist/hooks/claude-mux-hook.js.map +1 -0
- package/dist/hooks/claude-watch-hook.d.ts +15 -0
- package/dist/hooks/claude-watch-hook.d.ts.map +1 -0
- package/dist/hooks/claude-watch-hook.js +396 -0
- package/dist/hooks/claude-watch-hook.js.map +1 -0
- package/dist/server/custom-server.d.ts +13 -0
- package/dist/server/custom-server.d.ts.map +1 -0
- package/dist/server/custom-server.js +63 -0
- package/dist/server/custom-server.js.map +1 -0
- package/dist/server/index.d.ts +9 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +1143 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/middleware/cors.d.ts +2 -0
- package/dist/server/middleware/cors.d.ts.map +1 -0
- package/dist/server/middleware/cors.js +11 -0
- package/dist/server/middleware/cors.js.map +1 -0
- package/dist/server/routes/sessions.d.ts +3 -0
- package/dist/server/routes/sessions.d.ts.map +1 -0
- package/dist/server/routes/sessions.js +78 -0
- package/dist/server/routes/sessions.js.map +1 -0
- package/dist/server/routes/stream.d.ts +3 -0
- package/dist/server/routes/stream.d.ts.map +1 -0
- package/dist/server/routes/stream.js +45 -0
- package/dist/server/routes/stream.js.map +1 -0
- package/dist/server/types.d.ts +28 -0
- package/dist/server/types.d.ts.map +1 -0
- package/dist/server/types.js +2 -0
- package/dist/server/types.js.map +1 -0
- package/dist/server/watcher.d.ts +22 -0
- package/dist/server/watcher.d.ts.map +1 -0
- package/dist/server/watcher.js +119 -0
- package/dist/server/watcher.js.map +1 -0
- package/dist/server/websocket.d.ts +51 -0
- package/dist/server/websocket.d.ts.map +1 -0
- package/dist/server/websocket.js +156 -0
- package/dist/server/websocket.js.map +1 -0
- package/dist/server/ws-handlers.d.ts +174 -0
- package/dist/server/ws-handlers.d.ts.map +1 -0
- package/dist/server/ws-handlers.js +695 -0
- package/dist/server/ws-handlers.js.map +1 -0
- package/dist/setup/hooks.d.ts +44 -0
- package/dist/setup/hooks.d.ts.map +1 -0
- package/dist/setup/hooks.js +267 -0
- package/dist/setup/hooks.js.map +1 -0
- package/dist/setup/index.d.ts +3 -0
- package/dist/setup/index.d.ts.map +1 -0
- package/dist/setup/index.js +3 -0
- package/dist/setup/index.js.map +1 -0
- package/dist/setup/wizard.d.ts +4 -0
- package/dist/setup/wizard.d.ts.map +1 -0
- package/dist/setup/wizard.js +72 -0
- package/dist/setup/wizard.js.map +1 -0
- package/dist/tmux/detect.d.ts +25 -0
- package/dist/tmux/detect.d.ts.map +1 -0
- package/dist/tmux/detect.js +71 -0
- package/dist/tmux/detect.js.map +1 -0
- package/dist/tmux/navigate.d.ts +13 -0
- package/dist/tmux/navigate.d.ts.map +1 -0
- package/dist/tmux/navigate.js +41 -0
- package/dist/tmux/navigate.js.map +1 -0
- package/dist/tmux/pane.d.ts +57 -0
- package/dist/tmux/pane.d.ts.map +1 -0
- package/dist/tmux/pane.js +156 -0
- package/dist/tmux/pane.js.map +1 -0
- package/dist/tmux/resize.d.ts +10 -0
- package/dist/tmux/resize.d.ts.map +1 -0
- package/dist/tmux/resize.js +25 -0
- package/dist/tmux/resize.js.map +1 -0
- package/dist/utils/paths.d.ts +7 -0
- package/dist/utils/paths.d.ts.map +1 -0
- package/dist/utils/paths.js +9 -0
- package/dist/utils/paths.js.map +1 -0
- package/dist/utils/pid.d.ts +5 -0
- package/dist/utils/pid.d.ts.map +1 -0
- package/dist/utils/pid.js +14 -0
- package/dist/utils/pid.js.map +1 -0
- package/dist/utils/version.d.ts +6 -0
- package/dist/utils/version.d.ts.map +1 -0
- package/dist/utils/version.js +6 -0
- package/dist/utils/version.js.map +1 -0
- package/dist/web/client/_app/immutable/assets/0.WptSHSUl.css +1 -0
- package/dist/web/client/_app/immutable/assets/2.s6Kx4oz1.css +1 -0
- package/dist/web/client/_app/immutable/assets/4.DoNWy7tW.css +1 -0
- package/dist/web/client/_app/immutable/assets/AllSessionsPanel.CGHY3HLy.css +1 -0
- package/dist/web/client/_app/immutable/chunks/-3mUPuLP.js +1 -0
- package/dist/web/client/_app/immutable/chunks/B5U4_V3d.js +1 -0
- package/dist/web/client/_app/immutable/chunks/BHwiZXRv.js +1 -0
- package/dist/web/client/_app/immutable/chunks/C9P-coqM.js +1 -0
- package/dist/web/client/_app/immutable/chunks/Cegv0r8x.js +1 -0
- package/dist/web/client/_app/immutable/chunks/DU91Ml7U.js +3 -0
- package/dist/web/client/_app/immutable/chunks/DmdO6ygw.js +1 -0
- package/dist/web/client/_app/immutable/chunks/HKNo9LID.js +5 -0
- package/dist/web/client/_app/immutable/chunks/U4ip-C0d.js +2 -0
- package/dist/web/client/_app/immutable/chunks/cgUjKIhX.js +2 -0
- package/dist/web/client/_app/immutable/entry/app.CGIBnoln.js +2 -0
- package/dist/web/client/_app/immutable/entry/start.CJk8zB1j.js +1 -0
- package/dist/web/client/_app/immutable/nodes/0.CqlJ9a31.js +1 -0
- package/dist/web/client/_app/immutable/nodes/1.BQUZh2-w.js +1 -0
- package/dist/web/client/_app/immutable/nodes/2.CCV1YdgF.js +1 -0
- package/dist/web/client/_app/immutable/nodes/3.D9tDCdq8.js +1 -0
- package/dist/web/client/_app/immutable/nodes/4.BqPyNkFA.js +6 -0
- package/dist/web/client/_app/version.json +1 -0
- package/dist/web/client/robots.txt +3 -0
- package/dist/web/env.js +32 -0
- package/dist/web/handler.js +744 -0
- package/dist/web/index.js +49 -0
- package/dist/web/server/chunks/0-BHWsmCJv.js +23 -0
- package/dist/web/server/chunks/0-BHWsmCJv.js.map +1 -0
- package/dist/web/server/chunks/1-YRx6A8Tm.js +17 -0
- package/dist/web/server/chunks/1-YRx6A8Tm.js.map +1 -0
- package/dist/web/server/chunks/2-eC6JuGAo.js +22 -0
- package/dist/web/server/chunks/2-eC6JuGAo.js.map +1 -0
- package/dist/web/server/chunks/3-Bk-wV20p.js +32 -0
- package/dist/web/server/chunks/3-Bk-wV20p.js.map +1 -0
- package/dist/web/server/chunks/4-nteBgDrW.js +21 -0
- package/dist/web/server/chunks/4-nteBgDrW.js.map +1 -0
- package/dist/web/server/chunks/AllSessionsPanel.svelte_svelte_type_style_lang-Bt4B0-oi.js +35 -0
- package/dist/web/server/chunks/AllSessionsPanel.svelte_svelte_type_style_lang-Bt4B0-oi.js.map +1 -0
- package/dist/web/server/chunks/_layout.svelte-BIF9eZCY.js +453 -0
- package/dist/web/server/chunks/_layout.svelte-BIF9eZCY.js.map +1 -0
- package/dist/web/server/chunks/_page.svelte-Be6iabRn.js +34 -0
- package/dist/web/server/chunks/_page.svelte-Be6iabRn.js.map +1 -0
- package/dist/web/server/chunks/_page.svelte-C_fGJVSE.js +576 -0
- package/dist/web/server/chunks/_page.svelte-C_fGJVSE.js.map +1 -0
- package/dist/web/server/chunks/_page.svelte-CnfJk6cu.js +2722 -0
- package/dist/web/server/chunks/_page.svelte-CnfJk6cu.js.map +1 -0
- package/dist/web/server/chunks/_server.ts-3WAmKvn2.js +34 -0
- package/dist/web/server/chunks/_server.ts-3WAmKvn2.js.map +1 -0
- package/dist/web/server/chunks/_server.ts-BAWJCSFb.js +29 -0
- package/dist/web/server/chunks/_server.ts-BAWJCSFb.js.map +1 -0
- package/dist/web/server/chunks/_server.ts-BPpMOZCm.js +24 -0
- package/dist/web/server/chunks/_server.ts-BPpMOZCm.js.map +1 -0
- package/dist/web/server/chunks/_server.ts-BUKgRb6U.js +13 -0
- package/dist/web/server/chunks/_server.ts-BUKgRb6U.js.map +1 -0
- package/dist/web/server/chunks/_server.ts-BVHUS8fm.js +41 -0
- package/dist/web/server/chunks/_server.ts-BVHUS8fm.js.map +1 -0
- package/dist/web/server/chunks/_server.ts-BrF3od0O.js +45 -0
- package/dist/web/server/chunks/_server.ts-BrF3od0O.js.map +1 -0
- package/dist/web/server/chunks/_server.ts-C4oPmOJR.js +38 -0
- package/dist/web/server/chunks/_server.ts-C4oPmOJR.js.map +1 -0
- package/dist/web/server/chunks/_server.ts-CDAUUmG_.js +21 -0
- package/dist/web/server/chunks/_server.ts-CDAUUmG_.js.map +1 -0
- package/dist/web/server/chunks/_server.ts-CR0uWvpz.js +24 -0
- package/dist/web/server/chunks/_server.ts-CR0uWvpz.js.map +1 -0
- package/dist/web/server/chunks/_server.ts-CSqdCNGi.js +21 -0
- package/dist/web/server/chunks/_server.ts-CSqdCNGi.js.map +1 -0
- package/dist/web/server/chunks/_server.ts-DI9fzUo9.js +52 -0
- package/dist/web/server/chunks/_server.ts-DI9fzUo9.js.map +1 -0
- package/dist/web/server/chunks/_server.ts-DNjJTClI.js +46 -0
- package/dist/web/server/chunks/_server.ts-DNjJTClI.js.map +1 -0
- package/dist/web/server/chunks/_server.ts-DdbOAkOj.js +22 -0
- package/dist/web/server/chunks/_server.ts-DdbOAkOj.js.map +1 -0
- package/dist/web/server/chunks/_server.ts-Df2isGQc.js +41 -0
- package/dist/web/server/chunks/_server.ts-Df2isGQc.js.map +1 -0
- package/dist/web/server/chunks/_server.ts-Vpw25_-3.js +12 -0
- package/dist/web/server/chunks/_server.ts-Vpw25_-3.js.map +1 -0
- package/dist/web/server/chunks/_server.ts-WldRpSRi.js +26 -0
- package/dist/web/server/chunks/_server.ts-WldRpSRi.js.map +1 -0
- package/dist/web/server/chunks/alert-dialog-description-DDA6u-nS.js +2890 -0
- package/dist/web/server/chunks/alert-dialog-description-DDA6u-nS.js.map +1 -0
- package/dist/web/server/chunks/auth-DrUf-v4J.js +51 -0
- package/dist/web/server/chunks/auth-DrUf-v4J.js.map +1 -0
- package/dist/web/server/chunks/button-D6xS9rHt.js +2335 -0
- package/dist/web/server/chunks/button-D6xS9rHt.js.map +1 -0
- package/dist/web/server/chunks/chunk-EKzHsMy_.js +42 -0
- package/dist/web/server/chunks/chunks-DmdqVYC7.js +58 -0
- package/dist/web/server/chunks/chunks-DmdqVYC7.js.map +1 -0
- package/dist/web/server/chunks/client-CUrSQijh.js +18 -0
- package/dist/web/server/chunks/client-CUrSQijh.js.map +1 -0
- package/dist/web/server/chunks/clsx-FzI4_gi0.js +332 -0
- package/dist/web/server/chunks/clsx-FzI4_gi0.js.map +1 -0
- package/dist/web/server/chunks/error.svelte-D-c-9pTE.js +27 -0
- package/dist/web/server/chunks/error.svelte-D-c-9pTE.js.map +1 -0
- package/dist/web/server/chunks/events-BDBlYddw.js +89 -0
- package/dist/web/server/chunks/events-BDBlYddw.js.map +1 -0
- package/dist/web/server/chunks/exports-CCurQ-Tl.js +131 -0
- package/dist/web/server/chunks/exports-CCurQ-Tl.js.map +1 -0
- package/dist/web/server/chunks/hooks.server-BK1bopsh.js +86 -0
- package/dist/web/server/chunks/hooks.server-BK1bopsh.js.map +1 -0
- package/dist/web/server/chunks/index2-BQnysSj-.js +2588 -0
- package/dist/web/server/chunks/index2-BQnysSj-.js.map +1 -0
- package/dist/web/server/chunks/internal-DLENj6YI.js +61 -0
- package/dist/web/server/chunks/internal-DLENj6YI.js.map +1 -0
- package/dist/web/server/chunks/pane-Dg3pKvsm.js +94 -0
- package/dist/web/server/chunks/pane-Dg3pKvsm.js.map +1 -0
- package/dist/web/server/chunks/sessions-json-DgfkCLO7.js +107 -0
- package/dist/web/server/chunks/sessions-json-DgfkCLO7.js.map +1 -0
- package/dist/web/server/chunks/sessions.svelte-Ds82MvkB.js +178 -0
- package/dist/web/server/chunks/sessions.svelte-Ds82MvkB.js.map +1 -0
- package/dist/web/server/chunks/state.svelte-xeAZvWZ6.js +7 -0
- package/dist/web/server/chunks/state.svelte-xeAZvWZ6.js.map +1 -0
- package/dist/web/server/chunks/ws-handlers-B4r5eSP2.js +733 -0
- package/dist/web/server/chunks/ws-handlers-B4r5eSP2.js.map +1 -0
- package/dist/web/server/index.js +4907 -0
- package/dist/web/server/index.js.map +1 -0
- package/dist/web/server/manifest.js +233 -0
- package/dist/web/server/manifest.js.map +1 -0
- package/docs/images/desktop-dashboard.png +0 -0
- package/docs/images/desktop-session.png +0 -0
- package/docs/images/mobile-dashboard.png +0 -0
- package/docs/images/mobile-session.png +0 -0
- package/docs/release-checklist.md +228 -0
- package/docs/removing-hooks.md +135 -0
- package/docs/state-transitions.md +109 -0
- package/package.json +71 -0
- package/src/app.tsx +188 -0
- package/src/cli.ts +83 -0
- package/src/commands/index.ts +4 -0
- package/src/commands/serve.ts +75 -0
- package/src/commands/setup.ts +13 -0
- package/src/commands/tui.ts +255 -0
- package/src/commands/uninstall.ts +13 -0
- package/src/components/Header.tsx +32 -0
- package/src/components/HelpDialog.tsx +45 -0
- package/src/components/SessionEntry.tsx +202 -0
- package/src/components/SessionList.tsx +98 -0
- package/src/components/StatusBar.tsx +26 -0
- package/src/components/index.ts +5 -0
- package/src/db/index.ts +20 -0
- package/src/db/sessions-json.ts +314 -0
- package/src/hooks/claude-mux-hook.ts +498 -0
- package/src/server/watcher.ts +128 -0
- package/src/server/ws-handlers.ts +922 -0
- package/src/setup/hooks.ts +333 -0
- package/src/setup/index.ts +2 -0
- package/src/setup/wizard.ts +81 -0
- package/src/tmux/detect.ts +87 -0
- package/src/tmux/navigate.ts +42 -0
- package/src/tmux/pane.ts +167 -0
- package/src/tmux/resize.ts +28 -0
- package/src/utils/paths.ts +11 -0
- package/src/utils/pid.ts +12 -0
- package/src/utils/version.ts +5 -0
- package/tests/components/Header.test.tsx +42 -0
- package/tests/components/SessionEntry-extended.test.tsx +165 -0
- package/tests/components/SessionEntry.test.tsx +138 -0
- package/tests/components/SessionList.test.tsx +110 -0
- package/tests/components/StatusBar.test.tsx +31 -0
- package/tests/db/index.test.ts +78 -0
- package/tests/db/sessions.test.ts +230 -0
- package/tests/server/integration.test.ts +319 -0
- package/tests/server/sessions.test.ts +114 -0
- package/tests/setup/hooks-integration.test.ts +148 -0
- package/tests/setup/hooks.test.ts +123 -0
- package/tests/tmux/detect.test.ts +54 -0
- package/tests/tmux/navigate.test.ts +30 -0
- package/tests/utils/pid.test.ts +17 -0
- package/tsconfig.cli.json +9 -0
- package/tsconfig.json +22 -0
- package/vitest.config.ts +29 -0
- package/web/.svelte-kit/adapter-bun/.vite/manifest.json +408 -0
- package/web/.svelte-kit/adapter-bun/_app/immutable/assets/AllSessionsPanel.BKhqOrbV.css +1 -0
- package/web/.svelte-kit/adapter-bun/_app/immutable/assets/_layout.WptSHSUl.css +1 -0
- package/web/.svelte-kit/adapter-bun/_app/immutable/assets/_page.DldLgTc-.css +1 -0
- package/web/.svelte-kit/adapter-bun/_app/immutable/assets/_page.DoNWy7tW.css +1 -0
- package/web/.svelte-kit/adapter-bun/chunks/AllSessionsPanel.svelte_svelte_type_style_lang.js +49 -0
- package/web/.svelte-kit/adapter-bun/chunks/alert-dialog-description.js +2670 -0
- package/web/.svelte-kit/adapter-bun/chunks/auth.js +59 -0
- package/web/.svelte-kit/adapter-bun/chunks/button.js +82 -0
- package/web/.svelte-kit/adapter-bun/chunks/client.js +29 -0
- package/web/.svelte-kit/adapter-bun/chunks/context.js +133 -0
- package/web/.svelte-kit/adapter-bun/chunks/environment.js +34 -0
- package/web/.svelte-kit/adapter-bun/chunks/events.js +121 -0
- package/web/.svelte-kit/adapter-bun/chunks/exports.js +174 -0
- package/web/.svelte-kit/adapter-bun/chunks/false.js +4 -0
- package/web/.svelte-kit/adapter-bun/chunks/index.js +59 -0
- package/web/.svelte-kit/adapter-bun/chunks/index2.js +2828 -0
- package/web/.svelte-kit/adapter-bun/chunks/internal.js +920 -0
- package/web/.svelte-kit/adapter-bun/chunks/pane.js +82 -0
- package/web/.svelte-kit/adapter-bun/chunks/sessions-json.js +124 -0
- package/web/.svelte-kit/adapter-bun/chunks/sessions.svelte.js +229 -0
- package/web/.svelte-kit/adapter-bun/chunks/shared.js +542 -0
- package/web/.svelte-kit/adapter-bun/chunks/state.svelte.js +16 -0
- package/web/.svelte-kit/adapter-bun/chunks/utils.js +43 -0
- package/web/.svelte-kit/adapter-bun/chunks/ws-handlers.js +782 -0
- package/web/.svelte-kit/adapter-bun/entries/endpoints/api/auth/login/_server.ts.js +22 -0
- package/web/.svelte-kit/adapter-bun/entries/endpoints/api/auth/logout/_server.ts.js +9 -0
- package/web/.svelte-kit/adapter-bun/entries/endpoints/api/beads/_server.ts.js +22 -0
- package/web/.svelte-kit/adapter-bun/entries/endpoints/api/browse/_server.ts.js +50 -0
- package/web/.svelte-kit/adapter-bun/entries/endpoints/api/chrome/_server.ts.js +30 -0
- package/web/.svelte-kit/adapter-bun/entries/endpoints/api/files/image/_server.ts.js +53 -0
- package/web/.svelte-kit/adapter-bun/entries/endpoints/api/health/_server.ts.js +7 -0
- package/web/.svelte-kit/adapter-bun/entries/endpoints/api/projects/new-session/_server.ts.js +44 -0
- package/web/.svelte-kit/adapter-bun/entries/endpoints/api/sessions/_id_/_server.ts.js +20 -0
- package/web/.svelte-kit/adapter-bun/entries/endpoints/api/sessions/_id_/kill/_server.ts.js +36 -0
- package/web/.svelte-kit/adapter-bun/entries/endpoints/api/sessions/_id_/restart/_server.ts.js +40 -0
- package/web/.svelte-kit/adapter-bun/entries/endpoints/api/sessions/_id_/screenshots/_server.ts.js +28 -0
- package/web/.svelte-kit/adapter-bun/entries/endpoints/api/sessions/_id_/send/_server.ts.js +29 -0
- package/web/.svelte-kit/adapter-bun/entries/endpoints/api/sessions/_server.ts.js +49 -0
- package/web/.svelte-kit/adapter-bun/entries/endpoints/api/sessions/_target_/output/_server.ts.js +14 -0
- package/web/.svelte-kit/adapter-bun/entries/endpoints/api/tmux/panes/_server.ts.js +21 -0
- package/web/.svelte-kit/adapter-bun/entries/fallbacks/error.svelte.js +27 -0
- package/web/.svelte-kit/adapter-bun/entries/hooks.server.js +105 -0
- package/web/.svelte-kit/adapter-bun/entries/pages/_layout.svelte.js +499 -0
- package/web/.svelte-kit/adapter-bun/entries/pages/_page.svelte.js +3057 -0
- package/web/.svelte-kit/adapter-bun/entries/pages/login/_page.server.ts.js +15 -0
- package/web/.svelte-kit/adapter-bun/entries/pages/login/_page.svelte.js +37 -0
- package/web/.svelte-kit/adapter-bun/entries/pages/session/_target_/_page.svelte.js +653 -0
- package/web/.svelte-kit/adapter-bun/index.js +3864 -0
- package/web/.svelte-kit/adapter-bun/internal.js +13 -0
- package/web/.svelte-kit/adapter-bun/manifest-full.js +167 -0
- package/web/.svelte-kit/adapter-bun/manifest.js +171 -0
- package/web/.svelte-kit/adapter-bun/nodes/0.js +8 -0
- package/web/.svelte-kit/adapter-bun/nodes/1.js +8 -0
- package/web/.svelte-kit/adapter-bun/nodes/2.js +8 -0
- package/web/.svelte-kit/adapter-bun/nodes/3.js +10 -0
- package/web/.svelte-kit/adapter-bun/nodes/4.js +8 -0
- package/web/.svelte-kit/adapter-bun/remote-entry.js +541 -0
- package/web/.svelte-kit/adapter-node/.vite/manifest.json +223 -0
- package/web/.svelte-kit/adapter-node/_app/immutable/assets/_layout.4NiX29PU.css +1 -0
- package/web/.svelte-kit/adapter-node/_app/immutable/assets/_page.BEMzYUGV.css +1 -0
- package/web/.svelte-kit/adapter-node/_app/immutable/assets/_page.DOJn7TG7.css +1 -0
- package/web/.svelte-kit/adapter-node/chunks/context.js +121 -0
- package/web/.svelte-kit/adapter-node/chunks/environment.js +34 -0
- package/web/.svelte-kit/adapter-node/chunks/exports.js +174 -0
- package/web/.svelte-kit/adapter-node/chunks/false.js +4 -0
- package/web/.svelte-kit/adapter-node/chunks/index.js +59 -0
- package/web/.svelte-kit/adapter-node/chunks/index2.js +2710 -0
- package/web/.svelte-kit/adapter-node/chunks/internal.js +1005 -0
- package/web/.svelte-kit/adapter-node/chunks/sessions-json.js +109 -0
- package/web/.svelte-kit/adapter-node/chunks/sessions.svelte.js +67 -0
- package/web/.svelte-kit/adapter-node/chunks/shared.js +542 -0
- package/web/.svelte-kit/adapter-node/chunks/state.svelte.js +16 -0
- package/web/.svelte-kit/adapter-node/chunks/utils.js +43 -0
- package/web/.svelte-kit/adapter-node/entries/endpoints/api/browse/_server.ts.js +50 -0
- package/web/.svelte-kit/adapter-node/entries/endpoints/api/health/_server.ts.js +7 -0
- package/web/.svelte-kit/adapter-node/entries/endpoints/api/projects/new-session/_server.ts.js +44 -0
- package/web/.svelte-kit/adapter-node/entries/endpoints/api/sessions/_id_/_server.ts.js +20 -0
- package/web/.svelte-kit/adapter-node/entries/endpoints/api/sessions/_id_/kill/_server.ts.js +30 -0
- package/web/.svelte-kit/adapter-node/entries/endpoints/api/sessions/_id_/send/_server.ts.js +22 -0
- package/web/.svelte-kit/adapter-node/entries/endpoints/api/sessions/_server.ts.js +126 -0
- package/web/.svelte-kit/adapter-node/entries/endpoints/api/sessions/_target_/output/_server.ts.js +14 -0
- package/web/.svelte-kit/adapter-node/entries/fallbacks/error.svelte.js +44 -0
- package/web/.svelte-kit/adapter-node/entries/pages/_layout.svelte.js +12 -0
- package/web/.svelte-kit/adapter-node/entries/pages/_page.svelte.js +87 -0
- package/web/.svelte-kit/adapter-node/entries/pages/session/_target_/_page.svelte.js +76 -0
- package/web/.svelte-kit/adapter-node/index.js +3864 -0
- package/web/.svelte-kit/adapter-node/internal.js +13 -0
- package/web/.svelte-kit/adapter-node/manifest-full.js +103 -0
- package/web/.svelte-kit/adapter-node/manifest.js +107 -0
- package/web/.svelte-kit/adapter-node/nodes/0.js +8 -0
- package/web/.svelte-kit/adapter-node/nodes/1.js +8 -0
- package/web/.svelte-kit/adapter-node/nodes/2.js +8 -0
- package/web/.svelte-kit/adapter-node/nodes/3.js +8 -0
- package/web/.svelte-kit/adapter-node/remote-entry.js +541 -0
- package/web/.svelte-kit/ambient.d.ts +187 -0
- package/web/.svelte-kit/generated/client/app.js +33 -0
- package/web/.svelte-kit/generated/client/matchers.js +1 -0
- package/web/.svelte-kit/generated/client/nodes/0.js +1 -0
- package/web/.svelte-kit/generated/client/nodes/1.js +1 -0
- package/web/.svelte-kit/generated/client/nodes/2.js +1 -0
- package/web/.svelte-kit/generated/client/nodes/3.js +1 -0
- package/web/.svelte-kit/generated/client/nodes/4.js +1 -0
- package/web/.svelte-kit/generated/client-optimized/app.js +33 -0
- package/web/.svelte-kit/generated/client-optimized/matchers.js +1 -0
- package/web/.svelte-kit/generated/client-optimized/nodes/0.js +1 -0
- package/web/.svelte-kit/generated/client-optimized/nodes/1.js +1 -0
- package/web/.svelte-kit/generated/client-optimized/nodes/2.js +1 -0
- package/web/.svelte-kit/generated/client-optimized/nodes/3.js +1 -0
- package/web/.svelte-kit/generated/client-optimized/nodes/4.js +1 -0
- package/web/.svelte-kit/generated/root.js +3 -0
- package/web/.svelte-kit/generated/root.svelte +68 -0
- package/web/.svelte-kit/generated/server/internal.js +53 -0
- package/web/.svelte-kit/non-ambient.d.ts +73 -0
- package/web/.svelte-kit/output/client/.vite/manifest.json +203 -0
- package/web/.svelte-kit/output/client/_app/immutable/assets/0.WptSHSUl.css +1 -0
- package/web/.svelte-kit/output/client/_app/immutable/assets/2.s6Kx4oz1.css +1 -0
- package/web/.svelte-kit/output/client/_app/immutable/assets/4.DoNWy7tW.css +1 -0
- package/web/.svelte-kit/output/client/_app/immutable/assets/AllSessionsPanel.CGHY3HLy.css +1 -0
- package/web/.svelte-kit/output/client/_app/immutable/chunks/-3mUPuLP.js +1 -0
- package/web/.svelte-kit/output/client/_app/immutable/chunks/B5U4_V3d.js +1 -0
- package/web/.svelte-kit/output/client/_app/immutable/chunks/BHwiZXRv.js +1 -0
- package/web/.svelte-kit/output/client/_app/immutable/chunks/C9P-coqM.js +1 -0
- package/web/.svelte-kit/output/client/_app/immutable/chunks/Cegv0r8x.js +1 -0
- package/web/.svelte-kit/output/client/_app/immutable/chunks/DU91Ml7U.js +3 -0
- package/web/.svelte-kit/output/client/_app/immutable/chunks/DmdO6ygw.js +1 -0
- package/web/.svelte-kit/output/client/_app/immutable/chunks/HKNo9LID.js +5 -0
- package/web/.svelte-kit/output/client/_app/immutable/chunks/U4ip-C0d.js +2 -0
- package/web/.svelte-kit/output/client/_app/immutable/chunks/cgUjKIhX.js +2 -0
- package/web/.svelte-kit/output/client/_app/immutable/entry/app.CGIBnoln.js +2 -0
- package/web/.svelte-kit/output/client/_app/immutable/entry/start.CJk8zB1j.js +1 -0
- package/web/.svelte-kit/output/client/_app/immutable/nodes/0.CqlJ9a31.js +1 -0
- package/web/.svelte-kit/output/client/_app/immutable/nodes/1.BQUZh2-w.js +1 -0
- package/web/.svelte-kit/output/client/_app/immutable/nodes/2.CCV1YdgF.js +1 -0
- package/web/.svelte-kit/output/client/_app/immutable/nodes/3.D9tDCdq8.js +1 -0
- package/web/.svelte-kit/output/client/_app/immutable/nodes/4.BqPyNkFA.js +6 -0
- package/web/.svelte-kit/output/client/_app/version.json +1 -0
- package/web/.svelte-kit/output/client/robots.txt +3 -0
- package/web/.svelte-kit/output/server/.vite/manifest.json +408 -0
- package/web/.svelte-kit/output/server/_app/immutable/assets/AllSessionsPanel.BKhqOrbV.css +1 -0
- package/web/.svelte-kit/output/server/_app/immutable/assets/_layout.WptSHSUl.css +1 -0
- package/web/.svelte-kit/output/server/_app/immutable/assets/_page.DldLgTc-.css +1 -0
- package/web/.svelte-kit/output/server/_app/immutable/assets/_page.DoNWy7tW.css +1 -0
- package/web/.svelte-kit/output/server/chunks/AllSessionsPanel.svelte_svelte_type_style_lang.js +49 -0
- package/web/.svelte-kit/output/server/chunks/alert-dialog-description.js +2670 -0
- package/web/.svelte-kit/output/server/chunks/auth.js +59 -0
- package/web/.svelte-kit/output/server/chunks/button.js +82 -0
- package/web/.svelte-kit/output/server/chunks/client.js +29 -0
- package/web/.svelte-kit/output/server/chunks/context.js +133 -0
- package/web/.svelte-kit/output/server/chunks/environment.js +34 -0
- package/web/.svelte-kit/output/server/chunks/events.js +121 -0
- package/web/.svelte-kit/output/server/chunks/exports.js +174 -0
- package/web/.svelte-kit/output/server/chunks/false.js +4 -0
- package/web/.svelte-kit/output/server/chunks/index.js +59 -0
- package/web/.svelte-kit/output/server/chunks/index2.js +2828 -0
- package/web/.svelte-kit/output/server/chunks/internal.js +920 -0
- package/web/.svelte-kit/output/server/chunks/pane.js +82 -0
- package/web/.svelte-kit/output/server/chunks/sessions-json.js +124 -0
- package/web/.svelte-kit/output/server/chunks/sessions.svelte.js +229 -0
- package/web/.svelte-kit/output/server/chunks/shared.js +542 -0
- package/web/.svelte-kit/output/server/chunks/state.svelte.js +16 -0
- package/web/.svelte-kit/output/server/chunks/utils.js +43 -0
- package/web/.svelte-kit/output/server/chunks/ws-handlers.js +782 -0
- package/web/.svelte-kit/output/server/entries/endpoints/api/auth/login/_server.ts.js +22 -0
- package/web/.svelte-kit/output/server/entries/endpoints/api/auth/logout/_server.ts.js +9 -0
- package/web/.svelte-kit/output/server/entries/endpoints/api/beads/_server.ts.js +22 -0
- package/web/.svelte-kit/output/server/entries/endpoints/api/browse/_server.ts.js +50 -0
- package/web/.svelte-kit/output/server/entries/endpoints/api/chrome/_server.ts.js +30 -0
- package/web/.svelte-kit/output/server/entries/endpoints/api/files/image/_server.ts.js +53 -0
- package/web/.svelte-kit/output/server/entries/endpoints/api/health/_server.ts.js +7 -0
- package/web/.svelte-kit/output/server/entries/endpoints/api/projects/new-session/_server.ts.js +44 -0
- package/web/.svelte-kit/output/server/entries/endpoints/api/sessions/_id_/_server.ts.js +20 -0
- package/web/.svelte-kit/output/server/entries/endpoints/api/sessions/_id_/kill/_server.ts.js +36 -0
- package/web/.svelte-kit/output/server/entries/endpoints/api/sessions/_id_/restart/_server.ts.js +40 -0
- package/web/.svelte-kit/output/server/entries/endpoints/api/sessions/_id_/screenshots/_server.ts.js +28 -0
- package/web/.svelte-kit/output/server/entries/endpoints/api/sessions/_id_/send/_server.ts.js +29 -0
- package/web/.svelte-kit/output/server/entries/endpoints/api/sessions/_server.ts.js +49 -0
- package/web/.svelte-kit/output/server/entries/endpoints/api/sessions/_target_/output/_server.ts.js +14 -0
- package/web/.svelte-kit/output/server/entries/endpoints/api/tmux/panes/_server.ts.js +21 -0
- package/web/.svelte-kit/output/server/entries/fallbacks/error.svelte.js +27 -0
- package/web/.svelte-kit/output/server/entries/hooks.server.js +105 -0
- package/web/.svelte-kit/output/server/entries/pages/_layout.svelte.js +499 -0
- package/web/.svelte-kit/output/server/entries/pages/_page.svelte.js +3057 -0
- package/web/.svelte-kit/output/server/entries/pages/login/_page.server.ts.js +15 -0
- package/web/.svelte-kit/output/server/entries/pages/login/_page.svelte.js +37 -0
- package/web/.svelte-kit/output/server/entries/pages/session/_target_/_page.svelte.js +653 -0
- package/web/.svelte-kit/output/server/index.js +3864 -0
- package/web/.svelte-kit/output/server/internal.js +13 -0
- package/web/.svelte-kit/output/server/manifest-full.js +167 -0
- package/web/.svelte-kit/output/server/manifest.js +167 -0
- package/web/.svelte-kit/output/server/nodes/0.js +8 -0
- package/web/.svelte-kit/output/server/nodes/1.js +8 -0
- package/web/.svelte-kit/output/server/nodes/2.js +8 -0
- package/web/.svelte-kit/output/server/nodes/3.js +10 -0
- package/web/.svelte-kit/output/server/nodes/4.js +8 -0
- package/web/.svelte-kit/output/server/remote-entry.js +541 -0
- package/web/.svelte-kit/tsconfig.json +58 -0
- package/web/.svelte-kit/types/route_meta_data.json +55 -0
- package/web/.svelte-kit/types/src/routes/$types.d.ts +24 -0
- package/web/.svelte-kit/types/src/routes/api/auth/login/$types.d.ts +10 -0
- package/web/.svelte-kit/types/src/routes/api/auth/logout/$types.d.ts +10 -0
- package/web/.svelte-kit/types/src/routes/api/beads/$types.d.ts +10 -0
- package/web/.svelte-kit/types/src/routes/api/browse/$types.d.ts +10 -0
- package/web/.svelte-kit/types/src/routes/api/chrome/$types.d.ts +10 -0
- package/web/.svelte-kit/types/src/routes/api/files/image/$types.d.ts +10 -0
- package/web/.svelte-kit/types/src/routes/api/health/$types.d.ts +10 -0
- package/web/.svelte-kit/types/src/routes/api/projects/new-session/$types.d.ts +10 -0
- package/web/.svelte-kit/types/src/routes/api/sessions/$types.d.ts +10 -0
- package/web/.svelte-kit/types/src/routes/api/sessions/[id]/$types.d.ts +11 -0
- package/web/.svelte-kit/types/src/routes/api/sessions/[id]/kill/$types.d.ts +11 -0
- package/web/.svelte-kit/types/src/routes/api/sessions/[id]/restart/$types.d.ts +11 -0
- package/web/.svelte-kit/types/src/routes/api/sessions/[id]/screenshots/$types.d.ts +11 -0
- package/web/.svelte-kit/types/src/routes/api/sessions/[id]/send/$types.d.ts +11 -0
- package/web/.svelte-kit/types/src/routes/api/sessions/[target]/output/$types.d.ts +11 -0
- package/web/.svelte-kit/types/src/routes/api/tmux/panes/$types.d.ts +10 -0
- package/web/.svelte-kit/types/src/routes/login/$types.d.ts +25 -0
- package/web/.svelte-kit/types/src/routes/login/proxy+page.server.ts +19 -0
- package/web/.svelte-kit/types/src/routes/session/[target]/$types.d.ts +19 -0
- package/web/README.md +42 -0
- package/web/components.json +16 -0
- package/web/package.json +35 -0
- package/web/src/app.css +128 -0
- package/web/src/app.d.ts +13 -0
- package/web/src/app.html +11 -0
- package/web/src/hooks.server.ts +156 -0
- package/web/src/lib/assets/favicon.svg +1 -0
- package/web/src/lib/components/AllSessionsPanel.svelte +789 -0
- package/web/src/lib/components/BeadsPanel.svelte +146 -0
- package/web/src/lib/components/IssueItem.svelte +287 -0
- package/web/src/lib/components/ScreenshotsPanel.svelte +336 -0
- package/web/src/lib/components/SessionsSidebar.svelte +312 -0
- package/web/src/lib/components/TerminalRenderer.svelte +189 -0
- package/web/src/lib/components/ui/alert-dialog/alert-dialog-action.svelte +18 -0
- package/web/src/lib/components/ui/alert-dialog/alert-dialog-cancel.svelte +18 -0
- package/web/src/lib/components/ui/alert-dialog/alert-dialog-content.svelte +29 -0
- package/web/src/lib/components/ui/alert-dialog/alert-dialog-description.svelte +17 -0
- package/web/src/lib/components/ui/alert-dialog/alert-dialog-footer.svelte +20 -0
- package/web/src/lib/components/ui/alert-dialog/alert-dialog-header.svelte +20 -0
- package/web/src/lib/components/ui/alert-dialog/alert-dialog-overlay.svelte +20 -0
- package/web/src/lib/components/ui/alert-dialog/alert-dialog-portal.svelte +7 -0
- package/web/src/lib/components/ui/alert-dialog/alert-dialog-title.svelte +17 -0
- package/web/src/lib/components/ui/alert-dialog/alert-dialog-trigger.svelte +7 -0
- package/web/src/lib/components/ui/alert-dialog/alert-dialog.svelte +7 -0
- package/web/src/lib/components/ui/alert-dialog/index.ts +37 -0
- package/web/src/lib/components/ui/badge/badge.svelte +50 -0
- package/web/src/lib/components/ui/badge/index.ts +2 -0
- package/web/src/lib/components/ui/button/button.svelte +86 -0
- package/web/src/lib/components/ui/button/index.ts +17 -0
- package/web/src/lib/components/ui/checkbox/checkbox.svelte +36 -0
- package/web/src/lib/components/ui/checkbox/index.ts +6 -0
- package/web/src/lib/components/ui/dialog/dialog-close.svelte +7 -0
- package/web/src/lib/components/ui/dialog/dialog-content.svelte +45 -0
- package/web/src/lib/components/ui/dialog/dialog-description.svelte +17 -0
- package/web/src/lib/components/ui/dialog/dialog-footer.svelte +20 -0
- package/web/src/lib/components/ui/dialog/dialog-header.svelte +20 -0
- package/web/src/lib/components/ui/dialog/dialog-overlay.svelte +20 -0
- package/web/src/lib/components/ui/dialog/dialog-portal.svelte +7 -0
- package/web/src/lib/components/ui/dialog/dialog-title.svelte +17 -0
- package/web/src/lib/components/ui/dialog/dialog-trigger.svelte +7 -0
- package/web/src/lib/components/ui/dialog/dialog.svelte +7 -0
- package/web/src/lib/components/ui/dialog/index.ts +34 -0
- package/web/src/lib/components/ui/scroll-area/index.ts +10 -0
- package/web/src/lib/components/ui/scroll-area/scroll-area-scrollbar.svelte +31 -0
- package/web/src/lib/components/ui/scroll-area/scroll-area.svelte +43 -0
- package/web/src/lib/components/ui/textarea/index.ts +7 -0
- package/web/src/lib/components/ui/textarea/textarea.svelte +23 -0
- package/web/src/lib/index.ts +1 -0
- package/web/src/lib/server/auth.ts +90 -0
- package/web/src/lib/stores/beads.svelte.ts +163 -0
- package/web/src/lib/stores/input-injection.svelte.ts +39 -0
- package/web/src/lib/stores/preferences.svelte.ts +55 -0
- package/web/src/lib/stores/sessions.svelte.ts +108 -0
- package/web/src/lib/stores/terminal.svelte.ts +96 -0
- package/web/src/lib/stores/websocket-base.svelte.ts +209 -0
- package/web/src/lib/types/terminal.ts +31 -0
- package/web/src/lib/utils/terminal-parser.ts +239 -0
- package/web/src/lib/utils.ts +13 -0
- package/web/src/routes/+layout.svelte +450 -0
- package/web/src/routes/+page.svelte +19 -0
- package/web/src/routes/api/auth/login/+server.ts +34 -0
- package/web/src/routes/api/auth/logout/+server.ts +10 -0
- package/web/src/routes/api/beads/+server.ts +28 -0
- package/web/src/routes/api/browse/+server.ts +59 -0
- package/web/src/routes/api/chrome/+server.ts +35 -0
- package/web/src/routes/api/files/image/+server.ts +64 -0
- package/web/src/routes/api/health/+server.ts +6 -0
- package/web/src/routes/api/projects/new-session/+server.ts +50 -0
- package/web/src/routes/api/sessions/+server.ts +62 -0
- package/web/src/routes/api/sessions/[id]/+server.ts +19 -0
- package/web/src/routes/api/sessions/[id]/kill/+server.ts +46 -0
- package/web/src/routes/api/sessions/[id]/restart/+server.ts +59 -0
- package/web/src/routes/api/sessions/[id]/screenshots/+server.ts +32 -0
- package/web/src/routes/api/sessions/[id]/send/+server.ts +31 -0
- package/web/src/routes/api/sessions/[target]/output/+server.ts +13 -0
- package/web/src/routes/api/tmux/panes/+server.ts +32 -0
- package/web/src/routes/login/+page.server.ts +18 -0
- package/web/src/routes/login/+page.svelte +69 -0
- package/web/src/routes/session/[target]/+page.svelte +450 -0
- package/web/static/robots.txt +3 -0
- package/web/svelte.config.js +20 -0
- package/web/tsconfig.json +20 -0
- package/web/vite.config.ts +154 -0
|
@@ -0,0 +1,4907 @@
|
|
|
1
|
+
import { r as __toESM, t as __commonJSMin } from "./chunks/chunk-EKzHsMy_.js";
|
|
2
|
+
import { $ as queue_micro_task, A as destroy_effect, B as hydration_failed, C as clear_text_content, Ct as stringify_string, D as create_text, E as component_root, F as get, G as is_passive_event, H as init_operations, I as get_first_child, J as mutable_source, L as get_next_sibling, O as defer_effect, P as flushSync, Q as push, R as handle_error, S as branch, St as stringify_key, T as component_context, U as internal_set, V as increment, W as invoke_error_boundary, X as pop, Y as pause_effect, _t as DevalueError, a as DIRTY, at as set_active_reaction, bt as is_plain_object, c as HYDRATION_END, ct as source, d as HYDRATION_START_ELSE, et as render, f as LEGACY_PROPS, ft as svelte_boundary_reset_onerror, gt as uneval, h as active_reaction, i as COMMENT_NODE, it as set_active_effect, j as effect_tracking, l as HYDRATION_ERROR, m as active_effect, mt as untrack, n as BOUNDARY_EFFECT, nt as schedule_effect, o as EFFECT_PRESERVED, ot as set_component_context, p as MAYBE_DIRTY, q as move_effect, r as Batch, rt as set, s as EFFECT_TRANSPARENT, st as set_signal_status, tt as render_effect, u as HYDRATION_START, vt as enumerable_symbols, wt as BROWSER, x as block, xt as is_primitive, yt as get_type } from "./chunks/index2-BQnysSj-.js";
|
|
3
|
+
import { i as SvelteKitError, n as HttpError, r as Redirect, t as ActionFailure } from "./chunks/internal-DLENj6YI.js";
|
|
4
|
+
import { i as text, n as json, t as error } from "./chunks/exports-CCurQ-Tl.js";
|
|
5
|
+
import { A as disable_search, B as get_relative_path, F as validate_layout_server_exports, H as text_encoder, I as validate_page_exports, L as validate_page_server_exports, M as normalize_path, N as resolve, O as decode_params, P as validate_layout_exports, R as base64_decode, T as setContext, U as merge_tracing, V as text_decoder, W as with_request_store, a as define_property, j as make_trackable, k as decode_pathname, n as array_from, z as base64_encode } from "./chunks/clsx-FzI4_gi0.js";
|
|
6
|
+
import { n as writable, t as readable } from "./chunks/chunks-DmdqVYC7.js";
|
|
7
|
+
import { i as root_event_handles, n as handle_event_propagation, t as all_registered_events } from "./chunks/events-BDBlYddw.js";
|
|
8
|
+
|
|
9
|
+
//#region .svelte-kit/adapter-bun/chunks/environment.js
|
|
10
|
+
let base = "";
|
|
11
|
+
let assets = base;
|
|
12
|
+
const app_dir = "_app";
|
|
13
|
+
const relative = true;
|
|
14
|
+
const initial = {
|
|
15
|
+
base,
|
|
16
|
+
assets
|
|
17
|
+
};
|
|
18
|
+
function override(paths) {
|
|
19
|
+
base = paths.base;
|
|
20
|
+
assets = paths.assets;
|
|
21
|
+
}
|
|
22
|
+
function reset() {
|
|
23
|
+
base = initial.base;
|
|
24
|
+
assets = initial.assets;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region ../node_modules/devalue/src/base64.js
|
|
29
|
+
/**
|
|
30
|
+
* Base64 Encodes an arraybuffer
|
|
31
|
+
* @param {ArrayBuffer} arraybuffer
|
|
32
|
+
* @returns {string}
|
|
33
|
+
*/
|
|
34
|
+
function encode64(arraybuffer) {
|
|
35
|
+
const dv = new DataView(arraybuffer);
|
|
36
|
+
let binaryString = "";
|
|
37
|
+
for (let i = 0; i < arraybuffer.byteLength; i++) binaryString += String.fromCharCode(dv.getUint8(i));
|
|
38
|
+
return binaryToAscii(binaryString);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Decodes a base64 string into an arraybuffer
|
|
42
|
+
* @param {string} string
|
|
43
|
+
* @returns {ArrayBuffer}
|
|
44
|
+
*/
|
|
45
|
+
function decode64(string) {
|
|
46
|
+
const binaryString = asciiToBinary(string);
|
|
47
|
+
const arraybuffer = new ArrayBuffer(binaryString.length);
|
|
48
|
+
const dv = new DataView(arraybuffer);
|
|
49
|
+
for (let i = 0; i < arraybuffer.byteLength; i++) dv.setUint8(i, binaryString.charCodeAt(i));
|
|
50
|
+
return arraybuffer;
|
|
51
|
+
}
|
|
52
|
+
const KEY_STRING = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
53
|
+
/**
|
|
54
|
+
* Substitute for atob since it's deprecated in node.
|
|
55
|
+
* Does not do any input validation.
|
|
56
|
+
*
|
|
57
|
+
* @see https://github.com/jsdom/abab/blob/master/lib/atob.js
|
|
58
|
+
*
|
|
59
|
+
* @param {string} data
|
|
60
|
+
* @returns {string}
|
|
61
|
+
*/
|
|
62
|
+
function asciiToBinary(data) {
|
|
63
|
+
if (data.length % 4 === 0) data = data.replace(/==?$/, "");
|
|
64
|
+
let output = "";
|
|
65
|
+
let buffer = 0;
|
|
66
|
+
let accumulatedBits = 0;
|
|
67
|
+
for (let i = 0; i < data.length; i++) {
|
|
68
|
+
buffer <<= 6;
|
|
69
|
+
buffer |= KEY_STRING.indexOf(data[i]);
|
|
70
|
+
accumulatedBits += 6;
|
|
71
|
+
if (accumulatedBits === 24) {
|
|
72
|
+
output += String.fromCharCode((buffer & 16711680) >> 16);
|
|
73
|
+
output += String.fromCharCode((buffer & 65280) >> 8);
|
|
74
|
+
output += String.fromCharCode(buffer & 255);
|
|
75
|
+
buffer = accumulatedBits = 0;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
if (accumulatedBits === 12) {
|
|
79
|
+
buffer >>= 4;
|
|
80
|
+
output += String.fromCharCode(buffer);
|
|
81
|
+
} else if (accumulatedBits === 18) {
|
|
82
|
+
buffer >>= 2;
|
|
83
|
+
output += String.fromCharCode((buffer & 65280) >> 8);
|
|
84
|
+
output += String.fromCharCode(buffer & 255);
|
|
85
|
+
}
|
|
86
|
+
return output;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Substitute for btoa since it's deprecated in node.
|
|
90
|
+
* Does not do any input validation.
|
|
91
|
+
*
|
|
92
|
+
* @see https://github.com/jsdom/abab/blob/master/lib/btoa.js
|
|
93
|
+
*
|
|
94
|
+
* @param {string} str
|
|
95
|
+
* @returns {string}
|
|
96
|
+
*/
|
|
97
|
+
function binaryToAscii(str) {
|
|
98
|
+
let out = "";
|
|
99
|
+
for (let i = 0; i < str.length; i += 3) {
|
|
100
|
+
/** @type {[number, number, number, number]} */
|
|
101
|
+
const groupsOfSix = [
|
|
102
|
+
void 0,
|
|
103
|
+
void 0,
|
|
104
|
+
void 0,
|
|
105
|
+
void 0
|
|
106
|
+
];
|
|
107
|
+
groupsOfSix[0] = str.charCodeAt(i) >> 2;
|
|
108
|
+
groupsOfSix[1] = (str.charCodeAt(i) & 3) << 4;
|
|
109
|
+
if (str.length > i + 1) {
|
|
110
|
+
groupsOfSix[1] |= str.charCodeAt(i + 1) >> 4;
|
|
111
|
+
groupsOfSix[2] = (str.charCodeAt(i + 1) & 15) << 2;
|
|
112
|
+
}
|
|
113
|
+
if (str.length > i + 2) {
|
|
114
|
+
groupsOfSix[2] |= str.charCodeAt(i + 2) >> 6;
|
|
115
|
+
groupsOfSix[3] = str.charCodeAt(i + 2) & 63;
|
|
116
|
+
}
|
|
117
|
+
for (let j = 0; j < groupsOfSix.length; j++) if (typeof groupsOfSix[j] === "undefined") out += "=";
|
|
118
|
+
else out += KEY_STRING[groupsOfSix[j]];
|
|
119
|
+
}
|
|
120
|
+
return out;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
//#endregion
|
|
124
|
+
//#region ../node_modules/devalue/src/constants.js
|
|
125
|
+
const UNDEFINED = -1;
|
|
126
|
+
const HOLE = -2;
|
|
127
|
+
const NAN = -3;
|
|
128
|
+
const POSITIVE_INFINITY = -4;
|
|
129
|
+
const NEGATIVE_INFINITY = -5;
|
|
130
|
+
const NEGATIVE_ZERO = -6;
|
|
131
|
+
|
|
132
|
+
//#endregion
|
|
133
|
+
//#region ../node_modules/devalue/src/parse.js
|
|
134
|
+
/**
|
|
135
|
+
* Revive a value serialized with `devalue.stringify`
|
|
136
|
+
* @param {string} serialized
|
|
137
|
+
* @param {Record<string, (value: any) => any>} [revivers]
|
|
138
|
+
*/
|
|
139
|
+
function parse$1(serialized, revivers) {
|
|
140
|
+
return unflatten(JSON.parse(serialized), revivers);
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Revive a value flattened with `devalue.stringify`
|
|
144
|
+
* @param {number | any[]} parsed
|
|
145
|
+
* @param {Record<string, (value: any) => any>} [revivers]
|
|
146
|
+
*/
|
|
147
|
+
function unflatten(parsed, revivers) {
|
|
148
|
+
if (typeof parsed === "number") return hydrate(parsed, true);
|
|
149
|
+
if (!Array.isArray(parsed) || parsed.length === 0) throw new Error("Invalid input");
|
|
150
|
+
const values = parsed;
|
|
151
|
+
const hydrated = Array(values.length);
|
|
152
|
+
/**
|
|
153
|
+
* A set of values currently being hydrated with custom revivers,
|
|
154
|
+
* used to detect invalid cyclical dependencies
|
|
155
|
+
* @type {Set<number> | null}
|
|
156
|
+
*/
|
|
157
|
+
let hydrating = null;
|
|
158
|
+
/**
|
|
159
|
+
* @param {number} index
|
|
160
|
+
* @returns {any}
|
|
161
|
+
*/
|
|
162
|
+
function hydrate(index, standalone = false) {
|
|
163
|
+
if (index === UNDEFINED) return void 0;
|
|
164
|
+
if (index === NAN) return NaN;
|
|
165
|
+
if (index === POSITIVE_INFINITY) return Infinity;
|
|
166
|
+
if (index === NEGATIVE_INFINITY) return -Infinity;
|
|
167
|
+
if (index === NEGATIVE_ZERO) return -0;
|
|
168
|
+
if (standalone || typeof index !== "number") throw new Error(`Invalid input`);
|
|
169
|
+
if (index in hydrated) return hydrated[index];
|
|
170
|
+
const value = values[index];
|
|
171
|
+
if (!value || typeof value !== "object") hydrated[index] = value;
|
|
172
|
+
else if (Array.isArray(value)) if (typeof value[0] === "string") {
|
|
173
|
+
const type = value[0];
|
|
174
|
+
const reviver = revivers && Object.hasOwn(revivers, type) ? revivers[type] : void 0;
|
|
175
|
+
if (reviver) {
|
|
176
|
+
let i = value[1];
|
|
177
|
+
if (typeof i !== "number") i = values.push(value[1]) - 1;
|
|
178
|
+
hydrating ??= /* @__PURE__ */ new Set();
|
|
179
|
+
if (hydrating.has(i)) throw new Error("Invalid circular reference");
|
|
180
|
+
hydrating.add(i);
|
|
181
|
+
hydrated[index] = reviver(hydrate(i));
|
|
182
|
+
hydrating.delete(i);
|
|
183
|
+
return hydrated[index];
|
|
184
|
+
}
|
|
185
|
+
switch (type) {
|
|
186
|
+
case "Date":
|
|
187
|
+
hydrated[index] = new Date(value[1]);
|
|
188
|
+
break;
|
|
189
|
+
case "Set":
|
|
190
|
+
const set = /* @__PURE__ */ new Set();
|
|
191
|
+
hydrated[index] = set;
|
|
192
|
+
for (let i = 1; i < value.length; i += 1) set.add(hydrate(value[i]));
|
|
193
|
+
break;
|
|
194
|
+
case "Map":
|
|
195
|
+
const map = /* @__PURE__ */ new Map();
|
|
196
|
+
hydrated[index] = map;
|
|
197
|
+
for (let i = 1; i < value.length; i += 2) map.set(hydrate(value[i]), hydrate(value[i + 1]));
|
|
198
|
+
break;
|
|
199
|
+
case "RegExp":
|
|
200
|
+
hydrated[index] = new RegExp(value[1], value[2]);
|
|
201
|
+
break;
|
|
202
|
+
case "Object":
|
|
203
|
+
hydrated[index] = Object(value[1]);
|
|
204
|
+
break;
|
|
205
|
+
case "BigInt":
|
|
206
|
+
hydrated[index] = BigInt(value[1]);
|
|
207
|
+
break;
|
|
208
|
+
case "null":
|
|
209
|
+
const obj = Object.create(null);
|
|
210
|
+
hydrated[index] = obj;
|
|
211
|
+
for (let i = 1; i < value.length; i += 2) obj[value[i]] = hydrate(value[i + 1]);
|
|
212
|
+
break;
|
|
213
|
+
case "Int8Array":
|
|
214
|
+
case "Uint8Array":
|
|
215
|
+
case "Uint8ClampedArray":
|
|
216
|
+
case "Int16Array":
|
|
217
|
+
case "Uint16Array":
|
|
218
|
+
case "Int32Array":
|
|
219
|
+
case "Uint32Array":
|
|
220
|
+
case "Float32Array":
|
|
221
|
+
case "Float64Array":
|
|
222
|
+
case "BigInt64Array":
|
|
223
|
+
case "BigUint64Array": {
|
|
224
|
+
if (values[value[1]][0] !== "ArrayBuffer") throw new Error("Invalid data");
|
|
225
|
+
const TypedArrayConstructor = globalThis[type];
|
|
226
|
+
const typedArray = new TypedArrayConstructor(hydrate(value[1]));
|
|
227
|
+
hydrated[index] = value[2] !== void 0 ? typedArray.subarray(value[2], value[3]) : typedArray;
|
|
228
|
+
break;
|
|
229
|
+
}
|
|
230
|
+
case "ArrayBuffer": {
|
|
231
|
+
const base64 = value[1];
|
|
232
|
+
if (typeof base64 !== "string") throw new Error("Invalid ArrayBuffer encoding");
|
|
233
|
+
hydrated[index] = decode64(base64);
|
|
234
|
+
break;
|
|
235
|
+
}
|
|
236
|
+
case "Temporal.Duration":
|
|
237
|
+
case "Temporal.Instant":
|
|
238
|
+
case "Temporal.PlainDate":
|
|
239
|
+
case "Temporal.PlainTime":
|
|
240
|
+
case "Temporal.PlainDateTime":
|
|
241
|
+
case "Temporal.PlainMonthDay":
|
|
242
|
+
case "Temporal.PlainYearMonth":
|
|
243
|
+
case "Temporal.ZonedDateTime": {
|
|
244
|
+
const temporalName = type.slice(9);
|
|
245
|
+
hydrated[index] = Temporal[temporalName].from(value[1]);
|
|
246
|
+
break;
|
|
247
|
+
}
|
|
248
|
+
case "URL":
|
|
249
|
+
hydrated[index] = new URL(value[1]);
|
|
250
|
+
break;
|
|
251
|
+
case "URLSearchParams":
|
|
252
|
+
hydrated[index] = new URLSearchParams(value[1]);
|
|
253
|
+
break;
|
|
254
|
+
default: throw new Error(`Unknown type ${type}`);
|
|
255
|
+
}
|
|
256
|
+
} else {
|
|
257
|
+
const array = new Array(value.length);
|
|
258
|
+
hydrated[index] = array;
|
|
259
|
+
for (let i = 0; i < value.length; i += 1) {
|
|
260
|
+
const n = value[i];
|
|
261
|
+
if (n === HOLE) continue;
|
|
262
|
+
array[i] = hydrate(n);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
else {
|
|
266
|
+
/** @type {Record<string, any>} */
|
|
267
|
+
const object = {};
|
|
268
|
+
hydrated[index] = object;
|
|
269
|
+
for (const key in value) {
|
|
270
|
+
if (key === "__proto__") throw new Error("Cannot parse an object with a `__proto__` property");
|
|
271
|
+
const n = value[key];
|
|
272
|
+
object[key] = hydrate(n);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
return hydrated[index];
|
|
276
|
+
}
|
|
277
|
+
return hydrate(0);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
//#endregion
|
|
281
|
+
//#region ../node_modules/devalue/src/stringify.js
|
|
282
|
+
/**
|
|
283
|
+
* Turn a value into a JSON string that can be parsed with `devalue.parse`
|
|
284
|
+
* @param {any} value
|
|
285
|
+
* @param {Record<string, (value: any) => any>} [reducers]
|
|
286
|
+
*/
|
|
287
|
+
function stringify$1(value, reducers) {
|
|
288
|
+
/** @type {any[]} */
|
|
289
|
+
const stringified = [];
|
|
290
|
+
/** @type {Map<any, number>} */
|
|
291
|
+
const indexes = /* @__PURE__ */ new Map();
|
|
292
|
+
/** @type {Array<{ key: string, fn: (value: any) => any }>} */
|
|
293
|
+
const custom = [];
|
|
294
|
+
if (reducers) for (const key of Object.getOwnPropertyNames(reducers)) custom.push({
|
|
295
|
+
key,
|
|
296
|
+
fn: reducers[key]
|
|
297
|
+
});
|
|
298
|
+
/** @type {string[]} */
|
|
299
|
+
const keys = [];
|
|
300
|
+
let p = 0;
|
|
301
|
+
/** @param {any} thing */
|
|
302
|
+
function flatten(thing) {
|
|
303
|
+
if (thing === void 0) return UNDEFINED;
|
|
304
|
+
if (Number.isNaN(thing)) return NAN;
|
|
305
|
+
if (thing === Infinity) return POSITIVE_INFINITY;
|
|
306
|
+
if (thing === -Infinity) return NEGATIVE_INFINITY;
|
|
307
|
+
if (thing === 0 && 1 / thing < 0) return NEGATIVE_ZERO;
|
|
308
|
+
if (indexes.has(thing)) return indexes.get(thing);
|
|
309
|
+
const index = p++;
|
|
310
|
+
indexes.set(thing, index);
|
|
311
|
+
for (const { key, fn } of custom) {
|
|
312
|
+
const value = fn(thing);
|
|
313
|
+
if (value) {
|
|
314
|
+
stringified[index] = `["${key}",${flatten(value)}]`;
|
|
315
|
+
return index;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
if (typeof thing === "function") throw new DevalueError(`Cannot stringify a function`, keys, thing, value);
|
|
319
|
+
let str = "";
|
|
320
|
+
if (is_primitive(thing)) str = stringify_primitive(thing);
|
|
321
|
+
else {
|
|
322
|
+
const type = get_type(thing);
|
|
323
|
+
switch (type) {
|
|
324
|
+
case "Number":
|
|
325
|
+
case "String":
|
|
326
|
+
case "Boolean":
|
|
327
|
+
str = `["Object",${stringify_primitive(thing)}]`;
|
|
328
|
+
break;
|
|
329
|
+
case "BigInt":
|
|
330
|
+
str = `["BigInt",${thing}]`;
|
|
331
|
+
break;
|
|
332
|
+
case "Date":
|
|
333
|
+
str = `["Date","${!isNaN(thing.getDate()) ? thing.toISOString() : ""}"]`;
|
|
334
|
+
break;
|
|
335
|
+
case "URL":
|
|
336
|
+
str = `["URL",${stringify_string(thing.toString())}]`;
|
|
337
|
+
break;
|
|
338
|
+
case "URLSearchParams":
|
|
339
|
+
str = `["URLSearchParams",${stringify_string(thing.toString())}]`;
|
|
340
|
+
break;
|
|
341
|
+
case "RegExp":
|
|
342
|
+
const { source, flags } = thing;
|
|
343
|
+
str = flags ? `["RegExp",${stringify_string(source)},"${flags}"]` : `["RegExp",${stringify_string(source)}]`;
|
|
344
|
+
break;
|
|
345
|
+
case "Array":
|
|
346
|
+
str = "[";
|
|
347
|
+
for (let i = 0; i < thing.length; i += 1) {
|
|
348
|
+
if (i > 0) str += ",";
|
|
349
|
+
if (i in thing) {
|
|
350
|
+
keys.push(`[${i}]`);
|
|
351
|
+
str += flatten(thing[i]);
|
|
352
|
+
keys.pop();
|
|
353
|
+
} else str += HOLE;
|
|
354
|
+
}
|
|
355
|
+
str += "]";
|
|
356
|
+
break;
|
|
357
|
+
case "Set":
|
|
358
|
+
str = "[\"Set\"";
|
|
359
|
+
for (const value of thing) str += `,${flatten(value)}`;
|
|
360
|
+
str += "]";
|
|
361
|
+
break;
|
|
362
|
+
case "Map":
|
|
363
|
+
str = "[\"Map\"";
|
|
364
|
+
for (const [key, value] of thing) {
|
|
365
|
+
keys.push(`.get(${is_primitive(key) ? stringify_primitive(key) : "..."})`);
|
|
366
|
+
str += `,${flatten(key)},${flatten(value)}`;
|
|
367
|
+
keys.pop();
|
|
368
|
+
}
|
|
369
|
+
str += "]";
|
|
370
|
+
break;
|
|
371
|
+
case "Int8Array":
|
|
372
|
+
case "Uint8Array":
|
|
373
|
+
case "Uint8ClampedArray":
|
|
374
|
+
case "Int16Array":
|
|
375
|
+
case "Uint16Array":
|
|
376
|
+
case "Int32Array":
|
|
377
|
+
case "Uint32Array":
|
|
378
|
+
case "Float32Array":
|
|
379
|
+
case "Float64Array":
|
|
380
|
+
case "BigInt64Array":
|
|
381
|
+
case "BigUint64Array": {
|
|
382
|
+
/** @type {import("./types.js").TypedArray} */
|
|
383
|
+
const typedArray = thing;
|
|
384
|
+
str = "[\"" + type + "\"," + flatten(typedArray.buffer);
|
|
385
|
+
const a = thing.byteOffset;
|
|
386
|
+
const b = a + thing.byteLength;
|
|
387
|
+
if (a > 0 || b !== typedArray.buffer.byteLength) {
|
|
388
|
+
const m = +/(\d+)/.exec(type)[1] / 8;
|
|
389
|
+
str += `,${a / m},${b / m}`;
|
|
390
|
+
}
|
|
391
|
+
str += "]";
|
|
392
|
+
break;
|
|
393
|
+
}
|
|
394
|
+
case "ArrayBuffer":
|
|
395
|
+
str = `["ArrayBuffer","${encode64(thing)}"]`;
|
|
396
|
+
break;
|
|
397
|
+
case "Temporal.Duration":
|
|
398
|
+
case "Temporal.Instant":
|
|
399
|
+
case "Temporal.PlainDate":
|
|
400
|
+
case "Temporal.PlainTime":
|
|
401
|
+
case "Temporal.PlainDateTime":
|
|
402
|
+
case "Temporal.PlainMonthDay":
|
|
403
|
+
case "Temporal.PlainYearMonth":
|
|
404
|
+
case "Temporal.ZonedDateTime":
|
|
405
|
+
str = `["${type}",${stringify_string(thing.toString())}]`;
|
|
406
|
+
break;
|
|
407
|
+
default:
|
|
408
|
+
if (!is_plain_object(thing)) throw new DevalueError(`Cannot stringify arbitrary non-POJOs`, keys, thing, value);
|
|
409
|
+
if (enumerable_symbols(thing).length > 0) throw new DevalueError(`Cannot stringify POJOs with symbolic keys`, keys, thing, value);
|
|
410
|
+
if (Object.getPrototypeOf(thing) === null) {
|
|
411
|
+
str = "[\"null\"";
|
|
412
|
+
for (const key in thing) {
|
|
413
|
+
keys.push(stringify_key(key));
|
|
414
|
+
str += `,${stringify_string(key)},${flatten(thing[key])}`;
|
|
415
|
+
keys.pop();
|
|
416
|
+
}
|
|
417
|
+
str += "]";
|
|
418
|
+
} else {
|
|
419
|
+
str = "{";
|
|
420
|
+
let started = false;
|
|
421
|
+
for (const key in thing) {
|
|
422
|
+
if (started) str += ",";
|
|
423
|
+
started = true;
|
|
424
|
+
keys.push(stringify_key(key));
|
|
425
|
+
str += `${stringify_string(key)}:${flatten(thing[key])}`;
|
|
426
|
+
keys.pop();
|
|
427
|
+
}
|
|
428
|
+
str += "}";
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
stringified[index] = str;
|
|
433
|
+
return index;
|
|
434
|
+
}
|
|
435
|
+
const index = flatten(value);
|
|
436
|
+
if (index < 0) return `${index}`;
|
|
437
|
+
return `[${stringified.join(",")}]`;
|
|
438
|
+
}
|
|
439
|
+
/**
|
|
440
|
+
* @param {any} thing
|
|
441
|
+
* @returns {string}
|
|
442
|
+
*/
|
|
443
|
+
function stringify_primitive(thing) {
|
|
444
|
+
const type = typeof thing;
|
|
445
|
+
if (type === "string") return stringify_string(thing);
|
|
446
|
+
if (thing instanceof String) return stringify_string(thing.toString());
|
|
447
|
+
if (thing === void 0) return UNDEFINED.toString();
|
|
448
|
+
if (thing === 0 && 1 / thing < 0) return NEGATIVE_ZERO.toString();
|
|
449
|
+
if (type === "bigint") return `["BigInt","${thing}"]`;
|
|
450
|
+
return String(thing);
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
//#endregion
|
|
454
|
+
//#region .svelte-kit/adapter-bun/chunks/shared.js
|
|
455
|
+
function set_nested_value(object, path_string, value) {
|
|
456
|
+
if (path_string.startsWith("n:")) {
|
|
457
|
+
path_string = path_string.slice(2);
|
|
458
|
+
value = value === "" ? void 0 : parseFloat(value);
|
|
459
|
+
} else if (path_string.startsWith("b:")) {
|
|
460
|
+
path_string = path_string.slice(2);
|
|
461
|
+
value = value === "on";
|
|
462
|
+
}
|
|
463
|
+
deep_set(object, split_path(path_string), value);
|
|
464
|
+
}
|
|
465
|
+
function convert_formdata(data) {
|
|
466
|
+
const result = {};
|
|
467
|
+
for (let key of data.keys()) {
|
|
468
|
+
const is_array = key.endsWith("[]");
|
|
469
|
+
let values = data.getAll(key);
|
|
470
|
+
if (is_array) key = key.slice(0, -2);
|
|
471
|
+
if (values.length > 1 && !is_array) throw new Error(`Form cannot contain duplicated keys — "${key}" has ${values.length} values`);
|
|
472
|
+
values = values.filter((entry) => typeof entry === "string" || entry.name !== "" || entry.size > 0);
|
|
473
|
+
if (key.startsWith("n:")) {
|
|
474
|
+
key = key.slice(2);
|
|
475
|
+
values = values.map((v) => v === "" ? void 0 : parseFloat(
|
|
476
|
+
/** @type {string} */
|
|
477
|
+
v
|
|
478
|
+
));
|
|
479
|
+
} else if (key.startsWith("b:")) {
|
|
480
|
+
key = key.slice(2);
|
|
481
|
+
values = values.map((v) => v === "on");
|
|
482
|
+
}
|
|
483
|
+
set_nested_value(result, key, is_array ? values : values[0]);
|
|
484
|
+
}
|
|
485
|
+
return result;
|
|
486
|
+
}
|
|
487
|
+
const BINARY_FORM_CONTENT_TYPE = "application/x-sveltekit-formdata";
|
|
488
|
+
const BINARY_FORM_VERSION = 0;
|
|
489
|
+
const HEADER_BYTES = 7;
|
|
490
|
+
async function deserialize_binary_form(request) {
|
|
491
|
+
if (request.headers.get("content-type") !== BINARY_FORM_CONTENT_TYPE) {
|
|
492
|
+
const form_data = await request.formData();
|
|
493
|
+
return {
|
|
494
|
+
data: convert_formdata(form_data),
|
|
495
|
+
meta: {},
|
|
496
|
+
form_data
|
|
497
|
+
};
|
|
498
|
+
}
|
|
499
|
+
if (!request.body) throw deserialize_error("no body");
|
|
500
|
+
const content_length = parseInt(request.headers.get("content-length") ?? "");
|
|
501
|
+
if (Number.isNaN(content_length)) throw deserialize_error("invalid Content-Length header");
|
|
502
|
+
const reader = request.body.getReader();
|
|
503
|
+
const chunks = [];
|
|
504
|
+
function get_chunk(index) {
|
|
505
|
+
if (index in chunks) return chunks[index];
|
|
506
|
+
let i = chunks.length;
|
|
507
|
+
while (i <= index) {
|
|
508
|
+
chunks[i] = reader.read().then((chunk) => chunk.value);
|
|
509
|
+
i++;
|
|
510
|
+
}
|
|
511
|
+
return chunks[index];
|
|
512
|
+
}
|
|
513
|
+
async function get_buffer(offset, length) {
|
|
514
|
+
let start_chunk;
|
|
515
|
+
let chunk_start = 0;
|
|
516
|
+
let chunk_index;
|
|
517
|
+
for (chunk_index = 0;; chunk_index++) {
|
|
518
|
+
const chunk = await get_chunk(chunk_index);
|
|
519
|
+
if (!chunk) return null;
|
|
520
|
+
const chunk_end = chunk_start + chunk.byteLength;
|
|
521
|
+
if (offset >= chunk_start && offset < chunk_end) {
|
|
522
|
+
start_chunk = chunk;
|
|
523
|
+
break;
|
|
524
|
+
}
|
|
525
|
+
chunk_start = chunk_end;
|
|
526
|
+
}
|
|
527
|
+
if (offset + length <= chunk_start + start_chunk.byteLength) return start_chunk.subarray(offset - chunk_start, offset + length - chunk_start);
|
|
528
|
+
const chunks2 = [start_chunk.subarray(offset - chunk_start)];
|
|
529
|
+
let cursor = start_chunk.byteLength - offset + chunk_start;
|
|
530
|
+
while (cursor < length) {
|
|
531
|
+
chunk_index++;
|
|
532
|
+
let chunk = await get_chunk(chunk_index);
|
|
533
|
+
if (!chunk) return null;
|
|
534
|
+
if (chunk.byteLength > length - cursor) chunk = chunk.subarray(0, length - cursor);
|
|
535
|
+
chunks2.push(chunk);
|
|
536
|
+
cursor += chunk.byteLength;
|
|
537
|
+
}
|
|
538
|
+
const buffer = new Uint8Array(length);
|
|
539
|
+
cursor = 0;
|
|
540
|
+
for (const chunk of chunks2) {
|
|
541
|
+
buffer.set(chunk, cursor);
|
|
542
|
+
cursor += chunk.byteLength;
|
|
543
|
+
}
|
|
544
|
+
return buffer;
|
|
545
|
+
}
|
|
546
|
+
const header = await get_buffer(0, HEADER_BYTES);
|
|
547
|
+
if (!header) throw deserialize_error("too short");
|
|
548
|
+
if (header[0] !== BINARY_FORM_VERSION) throw deserialize_error(`got version ${header[0]}, expected version ${BINARY_FORM_VERSION}`);
|
|
549
|
+
const header_view = new DataView(header.buffer, header.byteOffset, header.byteLength);
|
|
550
|
+
const data_length = header_view.getUint32(1, true);
|
|
551
|
+
if (HEADER_BYTES + data_length > content_length) throw deserialize_error("data overflow");
|
|
552
|
+
const file_offsets_length = header_view.getUint16(5, true);
|
|
553
|
+
if (HEADER_BYTES + data_length + file_offsets_length > content_length) throw deserialize_error("file offset table overflow");
|
|
554
|
+
const data_buffer = await get_buffer(HEADER_BYTES, data_length);
|
|
555
|
+
if (!data_buffer) throw deserialize_error("data too short");
|
|
556
|
+
let file_offsets;
|
|
557
|
+
let files_start_offset;
|
|
558
|
+
if (file_offsets_length > 0) {
|
|
559
|
+
const file_offsets_buffer = await get_buffer(HEADER_BYTES + data_length, file_offsets_length);
|
|
560
|
+
if (!file_offsets_buffer) throw deserialize_error("file offset table too short");
|
|
561
|
+
file_offsets = JSON.parse(text_decoder.decode(file_offsets_buffer));
|
|
562
|
+
files_start_offset = HEADER_BYTES + data_length + file_offsets_length;
|
|
563
|
+
}
|
|
564
|
+
const [data, meta] = parse$1(text_decoder.decode(data_buffer), { File: ([name, type, size, last_modified, index]) => {
|
|
565
|
+
if (files_start_offset + file_offsets[index] + size > content_length) throw deserialize_error("file data overflow");
|
|
566
|
+
return new Proxy(new LazyFile(name, type, size, last_modified, get_chunk, files_start_offset + file_offsets[index]), { getPrototypeOf() {
|
|
567
|
+
return File.prototype;
|
|
568
|
+
} });
|
|
569
|
+
} });
|
|
570
|
+
(async () => {
|
|
571
|
+
let has_more = true;
|
|
572
|
+
while (has_more) has_more = !!await get_chunk(chunks.length);
|
|
573
|
+
})();
|
|
574
|
+
return {
|
|
575
|
+
data,
|
|
576
|
+
meta,
|
|
577
|
+
form_data: null
|
|
578
|
+
};
|
|
579
|
+
}
|
|
580
|
+
function deserialize_error(message) {
|
|
581
|
+
return new SvelteKitError(400, "Bad Request", `Could not deserialize binary form: ${message}`);
|
|
582
|
+
}
|
|
583
|
+
var LazyFile = class LazyFile {
|
|
584
|
+
/** @type {(index: number) => Promise<Uint8Array<ArrayBuffer> | undefined>} */
|
|
585
|
+
#get_chunk;
|
|
586
|
+
/** @type {number} */
|
|
587
|
+
#offset;
|
|
588
|
+
/**
|
|
589
|
+
* @param {string} name
|
|
590
|
+
* @param {string} type
|
|
591
|
+
* @param {number} size
|
|
592
|
+
* @param {number} last_modified
|
|
593
|
+
* @param {(index: number) => Promise<Uint8Array<ArrayBuffer> | undefined>} get_chunk
|
|
594
|
+
* @param {number} offset
|
|
595
|
+
*/
|
|
596
|
+
constructor(name, type, size, last_modified, get_chunk, offset) {
|
|
597
|
+
this.name = name;
|
|
598
|
+
this.type = type;
|
|
599
|
+
this.size = size;
|
|
600
|
+
this.lastModified = last_modified;
|
|
601
|
+
this.webkitRelativePath = "";
|
|
602
|
+
this.#get_chunk = get_chunk;
|
|
603
|
+
this.#offset = offset;
|
|
604
|
+
this.arrayBuffer = this.arrayBuffer.bind(this);
|
|
605
|
+
this.bytes = this.bytes.bind(this);
|
|
606
|
+
this.slice = this.slice.bind(this);
|
|
607
|
+
this.stream = this.stream.bind(this);
|
|
608
|
+
this.text = this.text.bind(this);
|
|
609
|
+
}
|
|
610
|
+
/** @type {ArrayBuffer | undefined} */
|
|
611
|
+
#buffer;
|
|
612
|
+
async arrayBuffer() {
|
|
613
|
+
this.#buffer ??= await new Response(this.stream()).arrayBuffer();
|
|
614
|
+
return this.#buffer;
|
|
615
|
+
}
|
|
616
|
+
async bytes() {
|
|
617
|
+
return new Uint8Array(await this.arrayBuffer());
|
|
618
|
+
}
|
|
619
|
+
/**
|
|
620
|
+
* @param {number=} start
|
|
621
|
+
* @param {number=} end
|
|
622
|
+
* @param {string=} contentType
|
|
623
|
+
*/
|
|
624
|
+
slice(start = 0, end = this.size, contentType = this.type) {
|
|
625
|
+
if (start < 0) start = Math.max(this.size + start, 0);
|
|
626
|
+
else start = Math.min(start, this.size);
|
|
627
|
+
if (end < 0) end = Math.max(this.size + end, 0);
|
|
628
|
+
else end = Math.min(end, this.size);
|
|
629
|
+
const size = Math.max(end - start, 0);
|
|
630
|
+
return new LazyFile(this.name, contentType, size, this.lastModified, this.#get_chunk, this.#offset + start);
|
|
631
|
+
}
|
|
632
|
+
stream() {
|
|
633
|
+
let cursor = 0;
|
|
634
|
+
let chunk_index = 0;
|
|
635
|
+
return new ReadableStream({
|
|
636
|
+
start: async (controller) => {
|
|
637
|
+
let chunk_start = 0;
|
|
638
|
+
let start_chunk = null;
|
|
639
|
+
for (chunk_index = 0;; chunk_index++) {
|
|
640
|
+
const chunk = await this.#get_chunk(chunk_index);
|
|
641
|
+
if (!chunk) return null;
|
|
642
|
+
const chunk_end = chunk_start + chunk.byteLength;
|
|
643
|
+
if (this.#offset >= chunk_start && this.#offset < chunk_end) {
|
|
644
|
+
start_chunk = chunk;
|
|
645
|
+
break;
|
|
646
|
+
}
|
|
647
|
+
chunk_start = chunk_end;
|
|
648
|
+
}
|
|
649
|
+
if (this.#offset + this.size <= chunk_start + start_chunk.byteLength) {
|
|
650
|
+
controller.enqueue(start_chunk.subarray(this.#offset - chunk_start, this.#offset + this.size - chunk_start));
|
|
651
|
+
controller.close();
|
|
652
|
+
} else {
|
|
653
|
+
controller.enqueue(start_chunk.subarray(this.#offset - chunk_start));
|
|
654
|
+
cursor = start_chunk.byteLength - this.#offset + chunk_start;
|
|
655
|
+
}
|
|
656
|
+
},
|
|
657
|
+
pull: async (controller) => {
|
|
658
|
+
chunk_index++;
|
|
659
|
+
let chunk = await this.#get_chunk(chunk_index);
|
|
660
|
+
if (!chunk) {
|
|
661
|
+
controller.error("incomplete file data");
|
|
662
|
+
controller.close();
|
|
663
|
+
return;
|
|
664
|
+
}
|
|
665
|
+
if (chunk.byteLength > this.size - cursor) chunk = chunk.subarray(0, this.size - cursor);
|
|
666
|
+
controller.enqueue(chunk);
|
|
667
|
+
cursor += chunk.byteLength;
|
|
668
|
+
if (cursor >= this.size) controller.close();
|
|
669
|
+
}
|
|
670
|
+
});
|
|
671
|
+
}
|
|
672
|
+
async text() {
|
|
673
|
+
return text_decoder.decode(await this.arrayBuffer());
|
|
674
|
+
}
|
|
675
|
+
};
|
|
676
|
+
const path_regex = /^[a-zA-Z_$]\w*(\.[a-zA-Z_$]\w*|\[\d+\])*$/;
|
|
677
|
+
function split_path(path) {
|
|
678
|
+
if (!path_regex.test(path)) throw new Error(`Invalid path ${path}`);
|
|
679
|
+
return path.split(/\.|\[|\]/).filter(Boolean);
|
|
680
|
+
}
|
|
681
|
+
function check_prototype_pollution(key) {
|
|
682
|
+
if (key === "__proto__" || key === "constructor" || key === "prototype") throw new Error(`Invalid key "${key}"`);
|
|
683
|
+
}
|
|
684
|
+
function deep_set(object, keys, value) {
|
|
685
|
+
let current = object;
|
|
686
|
+
for (let i = 0; i < keys.length - 1; i += 1) {
|
|
687
|
+
const key = keys[i];
|
|
688
|
+
check_prototype_pollution(key);
|
|
689
|
+
const is_array = /^\d+$/.test(keys[i + 1]);
|
|
690
|
+
const exists = Object.hasOwn(current, key);
|
|
691
|
+
const inner = current[key];
|
|
692
|
+
if (exists && is_array !== Array.isArray(inner)) throw new Error(`Invalid array key ${keys[i + 1]}`);
|
|
693
|
+
if (!exists) current[key] = is_array ? [] : {};
|
|
694
|
+
current = current[key];
|
|
695
|
+
}
|
|
696
|
+
const final_key = keys[keys.length - 1];
|
|
697
|
+
check_prototype_pollution(final_key);
|
|
698
|
+
current[final_key] = value;
|
|
699
|
+
}
|
|
700
|
+
const INVALIDATED_PARAM = "x-sveltekit-invalidated";
|
|
701
|
+
const TRAILING_SLASH_PARAM = "x-sveltekit-trailing-slash";
|
|
702
|
+
function stringify(data, transport) {
|
|
703
|
+
const encoders = Object.fromEntries(Object.entries(transport).map(([k, v]) => [k, v.encode]));
|
|
704
|
+
return stringify$1(data, encoders);
|
|
705
|
+
}
|
|
706
|
+
function parse_remote_arg(string, transport) {
|
|
707
|
+
if (!string) return void 0;
|
|
708
|
+
const json_string = text_decoder.decode(base64_decode(string.replaceAll("-", "+").replaceAll("_", "/")));
|
|
709
|
+
const decoders = Object.fromEntries(Object.entries(transport).map(([k, v]) => [k, v.decode]));
|
|
710
|
+
return parse$1(json_string, decoders);
|
|
711
|
+
}
|
|
712
|
+
function create_remote_key(id, payload) {
|
|
713
|
+
return id + "/" + payload;
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
//#endregion
|
|
717
|
+
//#region .svelte-kit/adapter-bun/chunks/internal.js
|
|
718
|
+
let public_env = {};
|
|
719
|
+
function set_private_env(environment) {}
|
|
720
|
+
function set_public_env(environment) {
|
|
721
|
+
public_env = environment;
|
|
722
|
+
}
|
|
723
|
+
function hydration_mismatch(location) {
|
|
724
|
+
console.warn(`https://svelte.dev/e/hydration_mismatch`);
|
|
725
|
+
}
|
|
726
|
+
function svelte_boundary_reset_noop() {
|
|
727
|
+
console.warn(`https://svelte.dev/e/svelte_boundary_reset_noop`);
|
|
728
|
+
}
|
|
729
|
+
let hydrating = false;
|
|
730
|
+
function set_hydrating(value) {
|
|
731
|
+
hydrating = value;
|
|
732
|
+
}
|
|
733
|
+
let hydrate_node;
|
|
734
|
+
function set_hydrate_node(node) {
|
|
735
|
+
if (node === null) {
|
|
736
|
+
hydration_mismatch();
|
|
737
|
+
throw HYDRATION_ERROR;
|
|
738
|
+
}
|
|
739
|
+
return hydrate_node = node;
|
|
740
|
+
}
|
|
741
|
+
function hydrate_next() {
|
|
742
|
+
return set_hydrate_node(get_next_sibling(hydrate_node));
|
|
743
|
+
}
|
|
744
|
+
function next(count = 1) {
|
|
745
|
+
if (hydrating) {
|
|
746
|
+
var i = count;
|
|
747
|
+
var node = hydrate_node;
|
|
748
|
+
while (i--) node = get_next_sibling(node);
|
|
749
|
+
hydrate_node = node;
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
function skip_nodes(remove = true) {
|
|
753
|
+
var depth = 0;
|
|
754
|
+
var node = hydrate_node;
|
|
755
|
+
while (true) {
|
|
756
|
+
if (node.nodeType === COMMENT_NODE) {
|
|
757
|
+
var data = node.data;
|
|
758
|
+
if (data === HYDRATION_END) {
|
|
759
|
+
if (depth === 0) return node;
|
|
760
|
+
depth -= 1;
|
|
761
|
+
} else if (data === HYDRATION_START || data === HYDRATION_START_ELSE) depth += 1;
|
|
762
|
+
}
|
|
763
|
+
var next2 = get_next_sibling(node);
|
|
764
|
+
if (remove) node.remove();
|
|
765
|
+
node = next2;
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
function createSubscriber(start) {
|
|
769
|
+
let subscribers = 0;
|
|
770
|
+
let version = source(0);
|
|
771
|
+
let stop;
|
|
772
|
+
return () => {
|
|
773
|
+
if (effect_tracking()) {
|
|
774
|
+
get(version);
|
|
775
|
+
render_effect(() => {
|
|
776
|
+
if (subscribers === 0) stop = untrack(() => start(() => increment(version)));
|
|
777
|
+
subscribers += 1;
|
|
778
|
+
return () => {
|
|
779
|
+
queue_micro_task(() => {
|
|
780
|
+
subscribers -= 1;
|
|
781
|
+
if (subscribers === 0) {
|
|
782
|
+
stop?.();
|
|
783
|
+
stop = void 0;
|
|
784
|
+
increment(version);
|
|
785
|
+
}
|
|
786
|
+
});
|
|
787
|
+
};
|
|
788
|
+
});
|
|
789
|
+
}
|
|
790
|
+
};
|
|
791
|
+
}
|
|
792
|
+
var flags = EFFECT_TRANSPARENT | EFFECT_PRESERVED | BOUNDARY_EFFECT;
|
|
793
|
+
function boundary(node, props, children) {
|
|
794
|
+
new Boundary(node, props, children);
|
|
795
|
+
}
|
|
796
|
+
var Boundary = class {
|
|
797
|
+
/** @type {Boundary | null} */
|
|
798
|
+
parent;
|
|
799
|
+
is_pending = false;
|
|
800
|
+
/** @type {TemplateNode} */
|
|
801
|
+
#anchor;
|
|
802
|
+
/** @type {TemplateNode | null} */
|
|
803
|
+
#hydrate_open = hydrating ? hydrate_node : null;
|
|
804
|
+
/** @type {BoundaryProps} */
|
|
805
|
+
#props;
|
|
806
|
+
/** @type {((anchor: Node) => void)} */
|
|
807
|
+
#children;
|
|
808
|
+
/** @type {Effect} */
|
|
809
|
+
#effect;
|
|
810
|
+
/** @type {Effect | null} */
|
|
811
|
+
#main_effect = null;
|
|
812
|
+
/** @type {Effect | null} */
|
|
813
|
+
#pending_effect = null;
|
|
814
|
+
/** @type {Effect | null} */
|
|
815
|
+
#failed_effect = null;
|
|
816
|
+
/** @type {DocumentFragment | null} */
|
|
817
|
+
#offscreen_fragment = null;
|
|
818
|
+
/** @type {TemplateNode | null} */
|
|
819
|
+
#pending_anchor = null;
|
|
820
|
+
#local_pending_count = 0;
|
|
821
|
+
#pending_count = 0;
|
|
822
|
+
#pending_count_update_queued = false;
|
|
823
|
+
#is_creating_fallback = false;
|
|
824
|
+
/** @type {Set<Effect>} */
|
|
825
|
+
#dirty_effects = /* @__PURE__ */ new Set();
|
|
826
|
+
/** @type {Set<Effect>} */
|
|
827
|
+
#maybe_dirty_effects = /* @__PURE__ */ new Set();
|
|
828
|
+
/**
|
|
829
|
+
* A source containing the number of pending async deriveds/expressions.
|
|
830
|
+
* Only created if `$effect.pending()` is used inside the boundary,
|
|
831
|
+
* otherwise updating the source results in needless `Batch.ensure()`
|
|
832
|
+
* calls followed by no-op flushes
|
|
833
|
+
* @type {Source<number> | null}
|
|
834
|
+
*/
|
|
835
|
+
#effect_pending = null;
|
|
836
|
+
#effect_pending_subscriber = createSubscriber(() => {
|
|
837
|
+
this.#effect_pending = source(this.#local_pending_count);
|
|
838
|
+
return () => {
|
|
839
|
+
this.#effect_pending = null;
|
|
840
|
+
};
|
|
841
|
+
});
|
|
842
|
+
/**
|
|
843
|
+
* @param {TemplateNode} node
|
|
844
|
+
* @param {BoundaryProps} props
|
|
845
|
+
* @param {((anchor: Node) => void)} children
|
|
846
|
+
*/
|
|
847
|
+
constructor(node, props, children) {
|
|
848
|
+
this.#anchor = node;
|
|
849
|
+
this.#props = props;
|
|
850
|
+
this.#children = children;
|
|
851
|
+
this.parent = active_effect.b;
|
|
852
|
+
this.is_pending = !!this.#props.pending;
|
|
853
|
+
this.#effect = block(() => {
|
|
854
|
+
active_effect.b = this;
|
|
855
|
+
if (hydrating) {
|
|
856
|
+
const comment = this.#hydrate_open;
|
|
857
|
+
hydrate_next();
|
|
858
|
+
if (comment.nodeType === COMMENT_NODE && comment.data === HYDRATION_START_ELSE) this.#hydrate_pending_content();
|
|
859
|
+
else {
|
|
860
|
+
this.#hydrate_resolved_content();
|
|
861
|
+
if (this.#pending_count === 0) this.is_pending = false;
|
|
862
|
+
}
|
|
863
|
+
} else {
|
|
864
|
+
var anchor = this.#get_anchor();
|
|
865
|
+
try {
|
|
866
|
+
this.#main_effect = branch(() => children(anchor));
|
|
867
|
+
} catch (error) {
|
|
868
|
+
this.error(error);
|
|
869
|
+
}
|
|
870
|
+
if (this.#pending_count > 0) this.#show_pending_snippet();
|
|
871
|
+
else this.is_pending = false;
|
|
872
|
+
}
|
|
873
|
+
return () => {
|
|
874
|
+
this.#pending_anchor?.remove();
|
|
875
|
+
};
|
|
876
|
+
}, flags);
|
|
877
|
+
if (hydrating) this.#anchor = hydrate_node;
|
|
878
|
+
}
|
|
879
|
+
#hydrate_resolved_content() {
|
|
880
|
+
try {
|
|
881
|
+
this.#main_effect = branch(() => this.#children(this.#anchor));
|
|
882
|
+
} catch (error) {
|
|
883
|
+
this.error(error);
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
#hydrate_pending_content() {
|
|
887
|
+
const pending = this.#props.pending;
|
|
888
|
+
if (!pending) return;
|
|
889
|
+
this.#pending_effect = branch(() => pending(this.#anchor));
|
|
890
|
+
queue_micro_task(() => {
|
|
891
|
+
var anchor = this.#get_anchor();
|
|
892
|
+
this.#main_effect = this.#run(() => {
|
|
893
|
+
Batch.ensure();
|
|
894
|
+
return branch(() => this.#children(anchor));
|
|
895
|
+
});
|
|
896
|
+
if (this.#pending_count > 0) this.#show_pending_snippet();
|
|
897
|
+
else {
|
|
898
|
+
pause_effect(
|
|
899
|
+
/** @type {Effect} */
|
|
900
|
+
this.#pending_effect,
|
|
901
|
+
() => {
|
|
902
|
+
this.#pending_effect = null;
|
|
903
|
+
}
|
|
904
|
+
);
|
|
905
|
+
this.is_pending = false;
|
|
906
|
+
}
|
|
907
|
+
});
|
|
908
|
+
}
|
|
909
|
+
#get_anchor() {
|
|
910
|
+
var anchor = this.#anchor;
|
|
911
|
+
if (this.is_pending) {
|
|
912
|
+
this.#pending_anchor = create_text();
|
|
913
|
+
this.#anchor.before(this.#pending_anchor);
|
|
914
|
+
anchor = this.#pending_anchor;
|
|
915
|
+
}
|
|
916
|
+
return anchor;
|
|
917
|
+
}
|
|
918
|
+
/**
|
|
919
|
+
* Defer an effect inside a pending boundary until the boundary resolves
|
|
920
|
+
* @param {Effect} effect
|
|
921
|
+
*/
|
|
922
|
+
defer_effect(effect) {
|
|
923
|
+
defer_effect(effect, this.#dirty_effects, this.#maybe_dirty_effects);
|
|
924
|
+
}
|
|
925
|
+
/**
|
|
926
|
+
* Returns `false` if the effect exists inside a boundary whose pending snippet is shown
|
|
927
|
+
* @returns {boolean}
|
|
928
|
+
*/
|
|
929
|
+
is_rendered() {
|
|
930
|
+
return !this.is_pending && (!this.parent || this.parent.is_rendered());
|
|
931
|
+
}
|
|
932
|
+
has_pending_snippet() {
|
|
933
|
+
return !!this.#props.pending;
|
|
934
|
+
}
|
|
935
|
+
/**
|
|
936
|
+
* @param {() => Effect | null} fn
|
|
937
|
+
*/
|
|
938
|
+
#run(fn) {
|
|
939
|
+
var previous_effect = active_effect;
|
|
940
|
+
var previous_reaction = active_reaction;
|
|
941
|
+
var previous_ctx = component_context;
|
|
942
|
+
set_active_effect(this.#effect);
|
|
943
|
+
set_active_reaction(this.#effect);
|
|
944
|
+
set_component_context(this.#effect.ctx);
|
|
945
|
+
try {
|
|
946
|
+
return fn();
|
|
947
|
+
} catch (e) {
|
|
948
|
+
handle_error(e);
|
|
949
|
+
return null;
|
|
950
|
+
} finally {
|
|
951
|
+
set_active_effect(previous_effect);
|
|
952
|
+
set_active_reaction(previous_reaction);
|
|
953
|
+
set_component_context(previous_ctx);
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
#show_pending_snippet() {
|
|
957
|
+
const pending = this.#props.pending;
|
|
958
|
+
if (this.#main_effect !== null) {
|
|
959
|
+
this.#offscreen_fragment = document.createDocumentFragment();
|
|
960
|
+
this.#offscreen_fragment.append(
|
|
961
|
+
/** @type {TemplateNode} */
|
|
962
|
+
this.#pending_anchor
|
|
963
|
+
);
|
|
964
|
+
move_effect(this.#main_effect, this.#offscreen_fragment);
|
|
965
|
+
}
|
|
966
|
+
if (this.#pending_effect === null) this.#pending_effect = branch(() => pending(this.#anchor));
|
|
967
|
+
}
|
|
968
|
+
/**
|
|
969
|
+
* Updates the pending count associated with the currently visible pending snippet,
|
|
970
|
+
* if any, such that we can replace the snippet with content once work is done
|
|
971
|
+
* @param {1 | -1} d
|
|
972
|
+
*/
|
|
973
|
+
#update_pending_count(d) {
|
|
974
|
+
if (!this.has_pending_snippet()) {
|
|
975
|
+
if (this.parent) this.parent.#update_pending_count(d);
|
|
976
|
+
return;
|
|
977
|
+
}
|
|
978
|
+
this.#pending_count += d;
|
|
979
|
+
if (this.#pending_count === 0) {
|
|
980
|
+
this.is_pending = false;
|
|
981
|
+
for (const e of this.#dirty_effects) {
|
|
982
|
+
set_signal_status(e, DIRTY);
|
|
983
|
+
schedule_effect(e);
|
|
984
|
+
}
|
|
985
|
+
for (const e of this.#maybe_dirty_effects) {
|
|
986
|
+
set_signal_status(e, MAYBE_DIRTY);
|
|
987
|
+
schedule_effect(e);
|
|
988
|
+
}
|
|
989
|
+
this.#dirty_effects.clear();
|
|
990
|
+
this.#maybe_dirty_effects.clear();
|
|
991
|
+
if (this.#pending_effect) pause_effect(this.#pending_effect, () => {
|
|
992
|
+
this.#pending_effect = null;
|
|
993
|
+
});
|
|
994
|
+
if (this.#offscreen_fragment) {
|
|
995
|
+
this.#anchor.before(this.#offscreen_fragment);
|
|
996
|
+
this.#offscreen_fragment = null;
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
/**
|
|
1001
|
+
* Update the source that powers `$effect.pending()` inside this boundary,
|
|
1002
|
+
* and controls when the current `pending` snippet (if any) is removed.
|
|
1003
|
+
* Do not call from inside the class
|
|
1004
|
+
* @param {1 | -1} d
|
|
1005
|
+
*/
|
|
1006
|
+
update_pending_count(d) {
|
|
1007
|
+
this.#update_pending_count(d);
|
|
1008
|
+
this.#local_pending_count += d;
|
|
1009
|
+
if (!this.#effect_pending || this.#pending_count_update_queued) return;
|
|
1010
|
+
this.#pending_count_update_queued = true;
|
|
1011
|
+
queue_micro_task(() => {
|
|
1012
|
+
this.#pending_count_update_queued = false;
|
|
1013
|
+
if (this.#effect_pending) internal_set(this.#effect_pending, this.#local_pending_count);
|
|
1014
|
+
});
|
|
1015
|
+
}
|
|
1016
|
+
get_effect_pending() {
|
|
1017
|
+
this.#effect_pending_subscriber();
|
|
1018
|
+
return get(
|
|
1019
|
+
/** @type {Source<number>} */
|
|
1020
|
+
this.#effect_pending
|
|
1021
|
+
);
|
|
1022
|
+
}
|
|
1023
|
+
/** @param {unknown} error */
|
|
1024
|
+
error(error) {
|
|
1025
|
+
var onerror = this.#props.onerror;
|
|
1026
|
+
let failed = this.#props.failed;
|
|
1027
|
+
if (this.#is_creating_fallback || !onerror && !failed) throw error;
|
|
1028
|
+
if (this.#main_effect) {
|
|
1029
|
+
destroy_effect(this.#main_effect);
|
|
1030
|
+
this.#main_effect = null;
|
|
1031
|
+
}
|
|
1032
|
+
if (this.#pending_effect) {
|
|
1033
|
+
destroy_effect(this.#pending_effect);
|
|
1034
|
+
this.#pending_effect = null;
|
|
1035
|
+
}
|
|
1036
|
+
if (this.#failed_effect) {
|
|
1037
|
+
destroy_effect(this.#failed_effect);
|
|
1038
|
+
this.#failed_effect = null;
|
|
1039
|
+
}
|
|
1040
|
+
if (hydrating) {
|
|
1041
|
+
set_hydrate_node(
|
|
1042
|
+
/** @type {TemplateNode} */
|
|
1043
|
+
this.#hydrate_open
|
|
1044
|
+
);
|
|
1045
|
+
next();
|
|
1046
|
+
set_hydrate_node(skip_nodes());
|
|
1047
|
+
}
|
|
1048
|
+
var did_reset = false;
|
|
1049
|
+
var calling_on_error = false;
|
|
1050
|
+
const reset = () => {
|
|
1051
|
+
if (did_reset) {
|
|
1052
|
+
svelte_boundary_reset_noop();
|
|
1053
|
+
return;
|
|
1054
|
+
}
|
|
1055
|
+
did_reset = true;
|
|
1056
|
+
if (calling_on_error) svelte_boundary_reset_onerror();
|
|
1057
|
+
Batch.ensure();
|
|
1058
|
+
this.#local_pending_count = 0;
|
|
1059
|
+
if (this.#failed_effect !== null) pause_effect(this.#failed_effect, () => {
|
|
1060
|
+
this.#failed_effect = null;
|
|
1061
|
+
});
|
|
1062
|
+
this.is_pending = this.has_pending_snippet();
|
|
1063
|
+
this.#main_effect = this.#run(() => {
|
|
1064
|
+
this.#is_creating_fallback = false;
|
|
1065
|
+
return branch(() => this.#children(this.#anchor));
|
|
1066
|
+
});
|
|
1067
|
+
if (this.#pending_count > 0) this.#show_pending_snippet();
|
|
1068
|
+
else this.is_pending = false;
|
|
1069
|
+
};
|
|
1070
|
+
queue_micro_task(() => {
|
|
1071
|
+
try {
|
|
1072
|
+
calling_on_error = true;
|
|
1073
|
+
onerror?.(error, reset);
|
|
1074
|
+
calling_on_error = false;
|
|
1075
|
+
} catch (error2) {
|
|
1076
|
+
invoke_error_boundary(error2, this.#effect && this.#effect.parent);
|
|
1077
|
+
}
|
|
1078
|
+
if (failed) this.#failed_effect = this.#run(() => {
|
|
1079
|
+
Batch.ensure();
|
|
1080
|
+
this.#is_creating_fallback = true;
|
|
1081
|
+
try {
|
|
1082
|
+
return branch(() => {
|
|
1083
|
+
failed(this.#anchor, () => error, () => reset);
|
|
1084
|
+
});
|
|
1085
|
+
} catch (error2) {
|
|
1086
|
+
invoke_error_boundary(
|
|
1087
|
+
error2,
|
|
1088
|
+
/** @type {Effect} */
|
|
1089
|
+
this.#effect.parent
|
|
1090
|
+
);
|
|
1091
|
+
return null;
|
|
1092
|
+
} finally {
|
|
1093
|
+
this.#is_creating_fallback = false;
|
|
1094
|
+
}
|
|
1095
|
+
});
|
|
1096
|
+
});
|
|
1097
|
+
}
|
|
1098
|
+
};
|
|
1099
|
+
function assign_nodes(start, end) {
|
|
1100
|
+
var effect = active_effect;
|
|
1101
|
+
if (effect.nodes === null) effect.nodes = {
|
|
1102
|
+
start,
|
|
1103
|
+
end,
|
|
1104
|
+
a: null,
|
|
1105
|
+
t: null
|
|
1106
|
+
};
|
|
1107
|
+
}
|
|
1108
|
+
function mount(component, options2) {
|
|
1109
|
+
return _mount(component, options2);
|
|
1110
|
+
}
|
|
1111
|
+
function hydrate(component, options2) {
|
|
1112
|
+
init_operations();
|
|
1113
|
+
options2.intro = options2.intro ?? false;
|
|
1114
|
+
const target = options2.target;
|
|
1115
|
+
const was_hydrating = hydrating;
|
|
1116
|
+
const previous_hydrate_node = hydrate_node;
|
|
1117
|
+
try {
|
|
1118
|
+
var anchor = get_first_child(target);
|
|
1119
|
+
while (anchor && (anchor.nodeType !== COMMENT_NODE || anchor.data !== HYDRATION_START)) anchor = get_next_sibling(anchor);
|
|
1120
|
+
if (!anchor) throw HYDRATION_ERROR;
|
|
1121
|
+
set_hydrating(true);
|
|
1122
|
+
set_hydrate_node(
|
|
1123
|
+
/** @type {Comment} */
|
|
1124
|
+
anchor
|
|
1125
|
+
);
|
|
1126
|
+
const instance = _mount(component, {
|
|
1127
|
+
...options2,
|
|
1128
|
+
anchor
|
|
1129
|
+
});
|
|
1130
|
+
set_hydrating(false);
|
|
1131
|
+
return instance;
|
|
1132
|
+
} catch (error) {
|
|
1133
|
+
if (error instanceof Error && error.message.split("\n").some((line) => line.startsWith("https://svelte.dev/e/"))) throw error;
|
|
1134
|
+
if (error !== HYDRATION_ERROR) console.warn("Failed to hydrate: ", error);
|
|
1135
|
+
if (options2.recover === false) hydration_failed();
|
|
1136
|
+
init_operations();
|
|
1137
|
+
clear_text_content(target);
|
|
1138
|
+
set_hydrating(false);
|
|
1139
|
+
return mount(component, options2);
|
|
1140
|
+
} finally {
|
|
1141
|
+
set_hydrating(was_hydrating);
|
|
1142
|
+
set_hydrate_node(previous_hydrate_node);
|
|
1143
|
+
}
|
|
1144
|
+
}
|
|
1145
|
+
const document_listeners = /* @__PURE__ */ new Map();
|
|
1146
|
+
function _mount(Component, { target, anchor, props = {}, events, context, intro = true }) {
|
|
1147
|
+
init_operations();
|
|
1148
|
+
var registered_events = /* @__PURE__ */ new Set();
|
|
1149
|
+
var event_handle = (events2) => {
|
|
1150
|
+
for (var i = 0; i < events2.length; i++) {
|
|
1151
|
+
var event_name = events2[i];
|
|
1152
|
+
if (registered_events.has(event_name)) continue;
|
|
1153
|
+
registered_events.add(event_name);
|
|
1154
|
+
var passive = is_passive_event(event_name);
|
|
1155
|
+
target.addEventListener(event_name, handle_event_propagation, { passive });
|
|
1156
|
+
var n = document_listeners.get(event_name);
|
|
1157
|
+
if (n === void 0) {
|
|
1158
|
+
document.addEventListener(event_name, handle_event_propagation, { passive });
|
|
1159
|
+
document_listeners.set(event_name, 1);
|
|
1160
|
+
} else document_listeners.set(event_name, n + 1);
|
|
1161
|
+
}
|
|
1162
|
+
};
|
|
1163
|
+
event_handle(array_from(all_registered_events));
|
|
1164
|
+
root_event_handles.add(event_handle);
|
|
1165
|
+
var component = void 0;
|
|
1166
|
+
var unmount2 = component_root(() => {
|
|
1167
|
+
var anchor_node = anchor ?? target.appendChild(create_text());
|
|
1168
|
+
boundary(
|
|
1169
|
+
/** @type {TemplateNode} */
|
|
1170
|
+
anchor_node,
|
|
1171
|
+
{ pending: () => {} },
|
|
1172
|
+
(anchor_node2) => {
|
|
1173
|
+
if (context) {
|
|
1174
|
+
push({});
|
|
1175
|
+
var ctx = component_context;
|
|
1176
|
+
ctx.c = context;
|
|
1177
|
+
}
|
|
1178
|
+
if (events) props.$$events = events;
|
|
1179
|
+
if (hydrating) assign_nodes(
|
|
1180
|
+
/** @type {TemplateNode} */
|
|
1181
|
+
anchor_node2,
|
|
1182
|
+
null
|
|
1183
|
+
);
|
|
1184
|
+
component = Component(anchor_node2, props) || {};
|
|
1185
|
+
if (hydrating) {
|
|
1186
|
+
active_effect.nodes.end = hydrate_node;
|
|
1187
|
+
if (hydrate_node === null || hydrate_node.nodeType !== COMMENT_NODE || hydrate_node.data !== HYDRATION_END) {
|
|
1188
|
+
hydration_mismatch();
|
|
1189
|
+
throw HYDRATION_ERROR;
|
|
1190
|
+
}
|
|
1191
|
+
}
|
|
1192
|
+
if (context) pop();
|
|
1193
|
+
}
|
|
1194
|
+
);
|
|
1195
|
+
return () => {
|
|
1196
|
+
for (var event_name of registered_events) {
|
|
1197
|
+
target.removeEventListener(event_name, handle_event_propagation);
|
|
1198
|
+
var n = document_listeners.get(event_name);
|
|
1199
|
+
if (--n === 0) {
|
|
1200
|
+
document.removeEventListener(event_name, handle_event_propagation);
|
|
1201
|
+
document_listeners.delete(event_name);
|
|
1202
|
+
} else document_listeners.set(event_name, n);
|
|
1203
|
+
}
|
|
1204
|
+
root_event_handles.delete(event_handle);
|
|
1205
|
+
if (anchor_node !== anchor) anchor_node.parentNode?.removeChild(anchor_node);
|
|
1206
|
+
};
|
|
1207
|
+
});
|
|
1208
|
+
mounted_components.set(component, unmount2);
|
|
1209
|
+
return component;
|
|
1210
|
+
}
|
|
1211
|
+
let mounted_components = /* @__PURE__ */ new WeakMap();
|
|
1212
|
+
function unmount(component, options2) {
|
|
1213
|
+
const fn = mounted_components.get(component);
|
|
1214
|
+
if (fn) {
|
|
1215
|
+
mounted_components.delete(component);
|
|
1216
|
+
return fn(options2);
|
|
1217
|
+
}
|
|
1218
|
+
return Promise.resolve();
|
|
1219
|
+
}
|
|
1220
|
+
function asClassComponent$1(component) {
|
|
1221
|
+
return class extends Svelte4Component {
|
|
1222
|
+
/** @param {any} options */
|
|
1223
|
+
constructor(options2) {
|
|
1224
|
+
super({
|
|
1225
|
+
component,
|
|
1226
|
+
...options2
|
|
1227
|
+
});
|
|
1228
|
+
}
|
|
1229
|
+
};
|
|
1230
|
+
}
|
|
1231
|
+
var Svelte4Component = class {
|
|
1232
|
+
/** @type {any} */
|
|
1233
|
+
#events;
|
|
1234
|
+
/** @type {Record<string, any>} */
|
|
1235
|
+
#instance;
|
|
1236
|
+
/**
|
|
1237
|
+
* @param {ComponentConstructorOptions & {
|
|
1238
|
+
* component: any;
|
|
1239
|
+
* }} options
|
|
1240
|
+
*/
|
|
1241
|
+
constructor(options2) {
|
|
1242
|
+
var sources = /* @__PURE__ */ new Map();
|
|
1243
|
+
var add_source = (key, value) => {
|
|
1244
|
+
var s = mutable_source(value, false, false);
|
|
1245
|
+
sources.set(key, s);
|
|
1246
|
+
return s;
|
|
1247
|
+
};
|
|
1248
|
+
const props = new Proxy({
|
|
1249
|
+
...options2.props || {},
|
|
1250
|
+
$$events: {}
|
|
1251
|
+
}, {
|
|
1252
|
+
get(target, prop) {
|
|
1253
|
+
return get(sources.get(prop) ?? add_source(prop, Reflect.get(target, prop)));
|
|
1254
|
+
},
|
|
1255
|
+
has(target, prop) {
|
|
1256
|
+
if (prop === LEGACY_PROPS) return true;
|
|
1257
|
+
get(sources.get(prop) ?? add_source(prop, Reflect.get(target, prop)));
|
|
1258
|
+
return Reflect.has(target, prop);
|
|
1259
|
+
},
|
|
1260
|
+
set(target, prop, value) {
|
|
1261
|
+
set(sources.get(prop) ?? add_source(prop, value), value);
|
|
1262
|
+
return Reflect.set(target, prop, value);
|
|
1263
|
+
}
|
|
1264
|
+
});
|
|
1265
|
+
this.#instance = (options2.hydrate ? hydrate : mount)(options2.component, {
|
|
1266
|
+
target: options2.target,
|
|
1267
|
+
anchor: options2.anchor,
|
|
1268
|
+
props,
|
|
1269
|
+
context: options2.context,
|
|
1270
|
+
intro: options2.intro ?? false,
|
|
1271
|
+
recover: options2.recover
|
|
1272
|
+
});
|
|
1273
|
+
if (!options2?.props?.$$host || options2.sync === false) flushSync();
|
|
1274
|
+
this.#events = props.$$events;
|
|
1275
|
+
for (const key of Object.keys(this.#instance)) {
|
|
1276
|
+
if (key === "$set" || key === "$destroy" || key === "$on") continue;
|
|
1277
|
+
define_property(this, key, {
|
|
1278
|
+
get() {
|
|
1279
|
+
return this.#instance[key];
|
|
1280
|
+
},
|
|
1281
|
+
set(value) {
|
|
1282
|
+
this.#instance[key] = value;
|
|
1283
|
+
},
|
|
1284
|
+
enumerable: true
|
|
1285
|
+
});
|
|
1286
|
+
}
|
|
1287
|
+
this.#instance.$set = (next2) => {
|
|
1288
|
+
Object.assign(props, next2);
|
|
1289
|
+
};
|
|
1290
|
+
this.#instance.$destroy = () => {
|
|
1291
|
+
unmount(this.#instance);
|
|
1292
|
+
};
|
|
1293
|
+
}
|
|
1294
|
+
/** @param {Record<string, any>} props */
|
|
1295
|
+
$set(props) {
|
|
1296
|
+
this.#instance.$set(props);
|
|
1297
|
+
}
|
|
1298
|
+
/**
|
|
1299
|
+
* @param {string} event
|
|
1300
|
+
* @param {(...args: any[]) => any} callback
|
|
1301
|
+
* @returns {any}
|
|
1302
|
+
*/
|
|
1303
|
+
$on(event, callback) {
|
|
1304
|
+
this.#events[event] = this.#events[event] || [];
|
|
1305
|
+
const cb = (...args) => callback.call(this, ...args);
|
|
1306
|
+
this.#events[event].push(cb);
|
|
1307
|
+
return () => {
|
|
1308
|
+
this.#events[event] = this.#events[event].filter(
|
|
1309
|
+
/** @param {any} fn */
|
|
1310
|
+
(fn) => fn !== cb
|
|
1311
|
+
);
|
|
1312
|
+
};
|
|
1313
|
+
}
|
|
1314
|
+
$destroy() {
|
|
1315
|
+
this.#instance.$destroy();
|
|
1316
|
+
}
|
|
1317
|
+
};
|
|
1318
|
+
let read_implementation = null;
|
|
1319
|
+
function set_read_implementation(fn) {
|
|
1320
|
+
read_implementation = fn;
|
|
1321
|
+
}
|
|
1322
|
+
function asClassComponent(component) {
|
|
1323
|
+
const component_constructor = asClassComponent$1(component);
|
|
1324
|
+
const _render = (props, { context, csp } = {}) => {
|
|
1325
|
+
const result = render(component, {
|
|
1326
|
+
props,
|
|
1327
|
+
context,
|
|
1328
|
+
csp
|
|
1329
|
+
});
|
|
1330
|
+
const munged = Object.defineProperties(
|
|
1331
|
+
/** @type {LegacyRenderResult & PromiseLike<LegacyRenderResult>} */
|
|
1332
|
+
{},
|
|
1333
|
+
{
|
|
1334
|
+
css: { value: {
|
|
1335
|
+
code: "",
|
|
1336
|
+
map: null
|
|
1337
|
+
} },
|
|
1338
|
+
head: { get: () => result.head },
|
|
1339
|
+
html: { get: () => result.body },
|
|
1340
|
+
then: { value: (onfulfilled, onrejected) => {
|
|
1341
|
+
{
|
|
1342
|
+
const user_result = onfulfilled({
|
|
1343
|
+
css: munged.css,
|
|
1344
|
+
head: munged.head,
|
|
1345
|
+
html: munged.html
|
|
1346
|
+
});
|
|
1347
|
+
return Promise.resolve(user_result);
|
|
1348
|
+
}
|
|
1349
|
+
} }
|
|
1350
|
+
}
|
|
1351
|
+
);
|
|
1352
|
+
return munged;
|
|
1353
|
+
};
|
|
1354
|
+
component_constructor.render = _render;
|
|
1355
|
+
return component_constructor;
|
|
1356
|
+
}
|
|
1357
|
+
function Root($$renderer, $$props) {
|
|
1358
|
+
$$renderer.component(($$renderer2) => {
|
|
1359
|
+
let { stores, page, constructors, components = [], form, data_0 = null, data_1 = null } = $$props;
|
|
1360
|
+
setContext("__svelte__", stores);
|
|
1361
|
+
stores.page.set(page);
|
|
1362
|
+
const Pyramid_1 = constructors[1];
|
|
1363
|
+
if (constructors[1]) {
|
|
1364
|
+
$$renderer2.push("<!--[-->");
|
|
1365
|
+
const Pyramid_0 = constructors[0];
|
|
1366
|
+
$$renderer2.push(`<!---->`);
|
|
1367
|
+
Pyramid_0?.($$renderer2, {
|
|
1368
|
+
data: data_0,
|
|
1369
|
+
form,
|
|
1370
|
+
params: page.params,
|
|
1371
|
+
children: ($$renderer3) => {
|
|
1372
|
+
$$renderer3.push(`<!---->`);
|
|
1373
|
+
Pyramid_1?.($$renderer3, {
|
|
1374
|
+
data: data_1,
|
|
1375
|
+
form,
|
|
1376
|
+
params: page.params
|
|
1377
|
+
});
|
|
1378
|
+
$$renderer3.push(`<!---->`);
|
|
1379
|
+
},
|
|
1380
|
+
$$slots: { default: true }
|
|
1381
|
+
});
|
|
1382
|
+
$$renderer2.push(`<!---->`);
|
|
1383
|
+
} else {
|
|
1384
|
+
$$renderer2.push("<!--[!-->");
|
|
1385
|
+
const Pyramid_0 = constructors[0];
|
|
1386
|
+
$$renderer2.push(`<!---->`);
|
|
1387
|
+
Pyramid_0?.($$renderer2, {
|
|
1388
|
+
data: data_0,
|
|
1389
|
+
form,
|
|
1390
|
+
params: page.params
|
|
1391
|
+
});
|
|
1392
|
+
$$renderer2.push(`<!---->`);
|
|
1393
|
+
}
|
|
1394
|
+
$$renderer2.push(`<!--]--> `);
|
|
1395
|
+
$$renderer2.push("<!--[!-->");
|
|
1396
|
+
$$renderer2.push(`<!--]-->`);
|
|
1397
|
+
});
|
|
1398
|
+
}
|
|
1399
|
+
const root = asClassComponent(Root);
|
|
1400
|
+
const options = {
|
|
1401
|
+
app_template_contains_nonce: false,
|
|
1402
|
+
async: false,
|
|
1403
|
+
csp: {
|
|
1404
|
+
"mode": "auto",
|
|
1405
|
+
"directives": {
|
|
1406
|
+
"upgrade-insecure-requests": false,
|
|
1407
|
+
"block-all-mixed-content": false
|
|
1408
|
+
},
|
|
1409
|
+
"reportOnly": {
|
|
1410
|
+
"upgrade-insecure-requests": false,
|
|
1411
|
+
"block-all-mixed-content": false
|
|
1412
|
+
}
|
|
1413
|
+
},
|
|
1414
|
+
csrf_check_origin: true,
|
|
1415
|
+
csrf_trusted_origins: [],
|
|
1416
|
+
embedded: false,
|
|
1417
|
+
env_public_prefix: "PUBLIC_",
|
|
1418
|
+
env_private_prefix: "",
|
|
1419
|
+
hash_routing: false,
|
|
1420
|
+
hooks: null,
|
|
1421
|
+
preload_strategy: "modulepreload",
|
|
1422
|
+
root,
|
|
1423
|
+
service_worker: false,
|
|
1424
|
+
service_worker_options: void 0,
|
|
1425
|
+
templates: {
|
|
1426
|
+
app: ({ head, body, assets, nonce, env }) => "<!doctype html>\n<html lang=\"en\" class=\"dark\">\n <head>\n <meta charset=\"utf-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n " + head + "\n </head>\n <body data-sveltekit-preload-data=\"hover\">\n <div style=\"display: contents\">" + body + "</div>\n </body>\n</html>\n",
|
|
1427
|
+
error: ({ status, message }) => "<!doctype html>\n<html lang=\"en\">\n <head>\n <meta charset=\"utf-8\" />\n <title>" + message + `</title>
|
|
1428
|
+
|
|
1429
|
+
<style>
|
|
1430
|
+
body {
|
|
1431
|
+
--bg: white;
|
|
1432
|
+
--fg: #222;
|
|
1433
|
+
--divider: #ccc;
|
|
1434
|
+
background: var(--bg);
|
|
1435
|
+
color: var(--fg);
|
|
1436
|
+
font-family:
|
|
1437
|
+
system-ui,
|
|
1438
|
+
-apple-system,
|
|
1439
|
+
BlinkMacSystemFont,
|
|
1440
|
+
'Segoe UI',
|
|
1441
|
+
Roboto,
|
|
1442
|
+
Oxygen,
|
|
1443
|
+
Ubuntu,
|
|
1444
|
+
Cantarell,
|
|
1445
|
+
'Open Sans',
|
|
1446
|
+
'Helvetica Neue',
|
|
1447
|
+
sans-serif;
|
|
1448
|
+
display: flex;
|
|
1449
|
+
align-items: center;
|
|
1450
|
+
justify-content: center;
|
|
1451
|
+
height: 100vh;
|
|
1452
|
+
margin: 0;
|
|
1453
|
+
}
|
|
1454
|
+
|
|
1455
|
+
.error {
|
|
1456
|
+
display: flex;
|
|
1457
|
+
align-items: center;
|
|
1458
|
+
max-width: 32rem;
|
|
1459
|
+
margin: 0 1rem;
|
|
1460
|
+
}
|
|
1461
|
+
|
|
1462
|
+
.status {
|
|
1463
|
+
font-weight: 200;
|
|
1464
|
+
font-size: 3rem;
|
|
1465
|
+
line-height: 1;
|
|
1466
|
+
position: relative;
|
|
1467
|
+
top: -0.05rem;
|
|
1468
|
+
}
|
|
1469
|
+
|
|
1470
|
+
.message {
|
|
1471
|
+
border-left: 1px solid var(--divider);
|
|
1472
|
+
padding: 0 0 0 1rem;
|
|
1473
|
+
margin: 0 0 0 1rem;
|
|
1474
|
+
min-height: 2.5rem;
|
|
1475
|
+
display: flex;
|
|
1476
|
+
align-items: center;
|
|
1477
|
+
}
|
|
1478
|
+
|
|
1479
|
+
.message h1 {
|
|
1480
|
+
font-weight: 400;
|
|
1481
|
+
font-size: 1em;
|
|
1482
|
+
margin: 0;
|
|
1483
|
+
}
|
|
1484
|
+
|
|
1485
|
+
@media (prefers-color-scheme: dark) {
|
|
1486
|
+
body {
|
|
1487
|
+
--bg: #222;
|
|
1488
|
+
--fg: #ddd;
|
|
1489
|
+
--divider: #666;
|
|
1490
|
+
}
|
|
1491
|
+
}
|
|
1492
|
+
</style>
|
|
1493
|
+
</head>
|
|
1494
|
+
<body>
|
|
1495
|
+
<div class="error">
|
|
1496
|
+
<span class="status">` + status + "</span>\n <div class=\"message\">\n <h1>" + message + "</h1>\n </div>\n </div>\n </body>\n</html>\n"
|
|
1497
|
+
},
|
|
1498
|
+
version_hash: "iy513l"
|
|
1499
|
+
};
|
|
1500
|
+
async function get_hooks() {let websocket;
|
|
1501
|
+
let handle;
|
|
1502
|
+
let handleFetch;
|
|
1503
|
+
let handleError;
|
|
1504
|
+
let handleValidationError;
|
|
1505
|
+
let init;
|
|
1506
|
+
({handle,websocket, handleFetch, handleError, handleValidationError, init} = await import("./chunks/hooks.server-BK1bopsh.js"));
|
|
1507
|
+
let reroute;
|
|
1508
|
+
let transport;
|
|
1509
|
+
return {websocket,
|
|
1510
|
+
handle,
|
|
1511
|
+
handleFetch,
|
|
1512
|
+
handleError,
|
|
1513
|
+
handleValidationError,
|
|
1514
|
+
init,
|
|
1515
|
+
reroute,
|
|
1516
|
+
transport
|
|
1517
|
+
};
|
|
1518
|
+
}
|
|
1519
|
+
|
|
1520
|
+
//#endregion
|
|
1521
|
+
//#region ../node_modules/cookie/index.js
|
|
1522
|
+
/*!
|
|
1523
|
+
* cookie
|
|
1524
|
+
* Copyright(c) 2012-2014 Roman Shtylman
|
|
1525
|
+
* Copyright(c) 2015 Douglas Christopher Wilson
|
|
1526
|
+
* MIT Licensed
|
|
1527
|
+
*/
|
|
1528
|
+
var require_cookie = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
1529
|
+
/**
|
|
1530
|
+
* Module exports.
|
|
1531
|
+
* @public
|
|
1532
|
+
*/
|
|
1533
|
+
exports.parse = parse;
|
|
1534
|
+
exports.serialize = serialize;
|
|
1535
|
+
/**
|
|
1536
|
+
* Module variables.
|
|
1537
|
+
* @private
|
|
1538
|
+
*/
|
|
1539
|
+
var __toString = Object.prototype.toString;
|
|
1540
|
+
/**
|
|
1541
|
+
* RegExp to match field-content in RFC 7230 sec 3.2
|
|
1542
|
+
*
|
|
1543
|
+
* field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ]
|
|
1544
|
+
* field-vchar = VCHAR / obs-text
|
|
1545
|
+
* obs-text = %x80-FF
|
|
1546
|
+
*/
|
|
1547
|
+
var fieldContentRegExp = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;
|
|
1548
|
+
/**
|
|
1549
|
+
* Parse a cookie header.
|
|
1550
|
+
*
|
|
1551
|
+
* Parse the given cookie header string into an object
|
|
1552
|
+
* The object has the various cookies as keys(names) => values
|
|
1553
|
+
*
|
|
1554
|
+
* @param {string} str
|
|
1555
|
+
* @param {object} [options]
|
|
1556
|
+
* @return {object}
|
|
1557
|
+
* @public
|
|
1558
|
+
*/
|
|
1559
|
+
function parse(str, options) {
|
|
1560
|
+
if (typeof str !== "string") throw new TypeError("argument str must be a string");
|
|
1561
|
+
var obj = {};
|
|
1562
|
+
var dec = (options || {}).decode || decode;
|
|
1563
|
+
var index = 0;
|
|
1564
|
+
while (index < str.length) {
|
|
1565
|
+
var eqIdx = str.indexOf("=", index);
|
|
1566
|
+
if (eqIdx === -1) break;
|
|
1567
|
+
var endIdx = str.indexOf(";", index);
|
|
1568
|
+
if (endIdx === -1) endIdx = str.length;
|
|
1569
|
+
else if (endIdx < eqIdx) {
|
|
1570
|
+
index = str.lastIndexOf(";", eqIdx - 1) + 1;
|
|
1571
|
+
continue;
|
|
1572
|
+
}
|
|
1573
|
+
var key = str.slice(index, eqIdx).trim();
|
|
1574
|
+
if (void 0 === obj[key]) {
|
|
1575
|
+
var val = str.slice(eqIdx + 1, endIdx).trim();
|
|
1576
|
+
if (val.charCodeAt(0) === 34) val = val.slice(1, -1);
|
|
1577
|
+
obj[key] = tryDecode(val, dec);
|
|
1578
|
+
}
|
|
1579
|
+
index = endIdx + 1;
|
|
1580
|
+
}
|
|
1581
|
+
return obj;
|
|
1582
|
+
}
|
|
1583
|
+
/**
|
|
1584
|
+
* Serialize data into a cookie header.
|
|
1585
|
+
*
|
|
1586
|
+
* Serialize the a name value pair into a cookie string suitable for
|
|
1587
|
+
* http headers. An optional options object specified cookie parameters.
|
|
1588
|
+
*
|
|
1589
|
+
* serialize('foo', 'bar', { httpOnly: true })
|
|
1590
|
+
* => "foo=bar; httpOnly"
|
|
1591
|
+
*
|
|
1592
|
+
* @param {string} name
|
|
1593
|
+
* @param {string} val
|
|
1594
|
+
* @param {object} [options]
|
|
1595
|
+
* @return {string}
|
|
1596
|
+
* @public
|
|
1597
|
+
*/
|
|
1598
|
+
function serialize(name, val, options) {
|
|
1599
|
+
var opt = options || {};
|
|
1600
|
+
var enc = opt.encode || encode;
|
|
1601
|
+
if (typeof enc !== "function") throw new TypeError("option encode is invalid");
|
|
1602
|
+
if (!fieldContentRegExp.test(name)) throw new TypeError("argument name is invalid");
|
|
1603
|
+
var value = enc(val);
|
|
1604
|
+
if (value && !fieldContentRegExp.test(value)) throw new TypeError("argument val is invalid");
|
|
1605
|
+
var str = name + "=" + value;
|
|
1606
|
+
if (null != opt.maxAge) {
|
|
1607
|
+
var maxAge = opt.maxAge - 0;
|
|
1608
|
+
if (isNaN(maxAge) || !isFinite(maxAge)) throw new TypeError("option maxAge is invalid");
|
|
1609
|
+
str += "; Max-Age=" + Math.floor(maxAge);
|
|
1610
|
+
}
|
|
1611
|
+
if (opt.domain) {
|
|
1612
|
+
if (!fieldContentRegExp.test(opt.domain)) throw new TypeError("option domain is invalid");
|
|
1613
|
+
str += "; Domain=" + opt.domain;
|
|
1614
|
+
}
|
|
1615
|
+
if (opt.path) {
|
|
1616
|
+
if (!fieldContentRegExp.test(opt.path)) throw new TypeError("option path is invalid");
|
|
1617
|
+
str += "; Path=" + opt.path;
|
|
1618
|
+
}
|
|
1619
|
+
if (opt.expires) {
|
|
1620
|
+
var expires = opt.expires;
|
|
1621
|
+
if (!isDate(expires) || isNaN(expires.valueOf())) throw new TypeError("option expires is invalid");
|
|
1622
|
+
str += "; Expires=" + expires.toUTCString();
|
|
1623
|
+
}
|
|
1624
|
+
if (opt.httpOnly) str += "; HttpOnly";
|
|
1625
|
+
if (opt.secure) str += "; Secure";
|
|
1626
|
+
if (opt.partitioned) str += "; Partitioned";
|
|
1627
|
+
if (opt.priority) switch (typeof opt.priority === "string" ? opt.priority.toLowerCase() : opt.priority) {
|
|
1628
|
+
case "low":
|
|
1629
|
+
str += "; Priority=Low";
|
|
1630
|
+
break;
|
|
1631
|
+
case "medium":
|
|
1632
|
+
str += "; Priority=Medium";
|
|
1633
|
+
break;
|
|
1634
|
+
case "high":
|
|
1635
|
+
str += "; Priority=High";
|
|
1636
|
+
break;
|
|
1637
|
+
default: throw new TypeError("option priority is invalid");
|
|
1638
|
+
}
|
|
1639
|
+
if (opt.sameSite) switch (typeof opt.sameSite === "string" ? opt.sameSite.toLowerCase() : opt.sameSite) {
|
|
1640
|
+
case true:
|
|
1641
|
+
str += "; SameSite=Strict";
|
|
1642
|
+
break;
|
|
1643
|
+
case "lax":
|
|
1644
|
+
str += "; SameSite=Lax";
|
|
1645
|
+
break;
|
|
1646
|
+
case "strict":
|
|
1647
|
+
str += "; SameSite=Strict";
|
|
1648
|
+
break;
|
|
1649
|
+
case "none":
|
|
1650
|
+
str += "; SameSite=None";
|
|
1651
|
+
break;
|
|
1652
|
+
default: throw new TypeError("option sameSite is invalid");
|
|
1653
|
+
}
|
|
1654
|
+
return str;
|
|
1655
|
+
}
|
|
1656
|
+
/**
|
|
1657
|
+
* URL-decode string value. Optimized to skip native call when no %.
|
|
1658
|
+
*
|
|
1659
|
+
* @param {string} str
|
|
1660
|
+
* @returns {string}
|
|
1661
|
+
*/
|
|
1662
|
+
function decode(str) {
|
|
1663
|
+
return str.indexOf("%") !== -1 ? decodeURIComponent(str) : str;
|
|
1664
|
+
}
|
|
1665
|
+
/**
|
|
1666
|
+
* URL-encode value.
|
|
1667
|
+
*
|
|
1668
|
+
* @param {string} val
|
|
1669
|
+
* @returns {string}
|
|
1670
|
+
*/
|
|
1671
|
+
function encode(val) {
|
|
1672
|
+
return encodeURIComponent(val);
|
|
1673
|
+
}
|
|
1674
|
+
/**
|
|
1675
|
+
* Determine if value is a Date.
|
|
1676
|
+
*
|
|
1677
|
+
* @param {*} val
|
|
1678
|
+
* @private
|
|
1679
|
+
*/
|
|
1680
|
+
function isDate(val) {
|
|
1681
|
+
return __toString.call(val) === "[object Date]" || val instanceof Date;
|
|
1682
|
+
}
|
|
1683
|
+
/**
|
|
1684
|
+
* Try decoding a string using a decoding function.
|
|
1685
|
+
*
|
|
1686
|
+
* @param {string} str
|
|
1687
|
+
* @param {function} decode
|
|
1688
|
+
* @private
|
|
1689
|
+
*/
|
|
1690
|
+
function tryDecode(str, decode) {
|
|
1691
|
+
try {
|
|
1692
|
+
return decode(str);
|
|
1693
|
+
} catch (e) {
|
|
1694
|
+
return str;
|
|
1695
|
+
}
|
|
1696
|
+
}
|
|
1697
|
+
}));
|
|
1698
|
+
|
|
1699
|
+
//#endregion
|
|
1700
|
+
//#region ../node_modules/set-cookie-parser/lib/set-cookie.js
|
|
1701
|
+
var require_set_cookie = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1702
|
+
var defaultParseOptions = {
|
|
1703
|
+
decodeValues: true,
|
|
1704
|
+
map: false,
|
|
1705
|
+
silent: false
|
|
1706
|
+
};
|
|
1707
|
+
function isForbiddenKey(key) {
|
|
1708
|
+
return typeof key !== "string" || key in {};
|
|
1709
|
+
}
|
|
1710
|
+
function createNullObj() {
|
|
1711
|
+
return Object.create(null);
|
|
1712
|
+
}
|
|
1713
|
+
function isNonEmptyString(str) {
|
|
1714
|
+
return typeof str === "string" && !!str.trim();
|
|
1715
|
+
}
|
|
1716
|
+
function parseString(setCookieValue, options) {
|
|
1717
|
+
var parts = setCookieValue.split(";").filter(isNonEmptyString);
|
|
1718
|
+
var parsed = parseNameValuePair(parts.shift());
|
|
1719
|
+
var name = parsed.name;
|
|
1720
|
+
var value = parsed.value;
|
|
1721
|
+
options = options ? Object.assign({}, defaultParseOptions, options) : defaultParseOptions;
|
|
1722
|
+
if (isForbiddenKey(name)) return null;
|
|
1723
|
+
try {
|
|
1724
|
+
value = options.decodeValues ? decodeURIComponent(value) : value;
|
|
1725
|
+
} catch (e) {
|
|
1726
|
+
console.error("set-cookie-parser: failed to decode cookie value. Set options.decodeValues=false to disable decoding.", e);
|
|
1727
|
+
}
|
|
1728
|
+
var cookie = createNullObj();
|
|
1729
|
+
cookie.name = name;
|
|
1730
|
+
cookie.value = value;
|
|
1731
|
+
parts.forEach(function(part) {
|
|
1732
|
+
var sides = part.split("=");
|
|
1733
|
+
var key = sides.shift().trimLeft().toLowerCase();
|
|
1734
|
+
if (isForbiddenKey(key)) return;
|
|
1735
|
+
var value = sides.join("=");
|
|
1736
|
+
if (key === "expires") cookie.expires = new Date(value);
|
|
1737
|
+
else if (key === "max-age") {
|
|
1738
|
+
var n = parseInt(value, 10);
|
|
1739
|
+
if (!Number.isNaN(n)) cookie.maxAge = n;
|
|
1740
|
+
} else if (key === "secure") cookie.secure = true;
|
|
1741
|
+
else if (key === "httponly") cookie.httpOnly = true;
|
|
1742
|
+
else if (key === "samesite") cookie.sameSite = value;
|
|
1743
|
+
else if (key === "partitioned") cookie.partitioned = true;
|
|
1744
|
+
else if (key) cookie[key] = value;
|
|
1745
|
+
});
|
|
1746
|
+
return cookie;
|
|
1747
|
+
}
|
|
1748
|
+
function parseNameValuePair(nameValuePairStr) {
|
|
1749
|
+
var name = "";
|
|
1750
|
+
var value = "";
|
|
1751
|
+
var nameValueArr = nameValuePairStr.split("=");
|
|
1752
|
+
if (nameValueArr.length > 1) {
|
|
1753
|
+
name = nameValueArr.shift();
|
|
1754
|
+
value = nameValueArr.join("=");
|
|
1755
|
+
} else value = nameValuePairStr;
|
|
1756
|
+
return {
|
|
1757
|
+
name,
|
|
1758
|
+
value
|
|
1759
|
+
};
|
|
1760
|
+
}
|
|
1761
|
+
function parse(input, options) {
|
|
1762
|
+
options = options ? Object.assign({}, defaultParseOptions, options) : defaultParseOptions;
|
|
1763
|
+
if (!input) if (!options.map) return [];
|
|
1764
|
+
else return createNullObj();
|
|
1765
|
+
if (input.headers) if (typeof input.headers.getSetCookie === "function") input = input.headers.getSetCookie();
|
|
1766
|
+
else if (input.headers["set-cookie"]) input = input.headers["set-cookie"];
|
|
1767
|
+
else {
|
|
1768
|
+
var sch = input.headers[Object.keys(input.headers).find(function(key) {
|
|
1769
|
+
return key.toLowerCase() === "set-cookie";
|
|
1770
|
+
})];
|
|
1771
|
+
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.");
|
|
1772
|
+
input = sch;
|
|
1773
|
+
}
|
|
1774
|
+
if (!Array.isArray(input)) input = [input];
|
|
1775
|
+
if (!options.map) return input.filter(isNonEmptyString).map(function(str) {
|
|
1776
|
+
return parseString(str, options);
|
|
1777
|
+
}).filter(Boolean);
|
|
1778
|
+
else {
|
|
1779
|
+
var cookies = createNullObj();
|
|
1780
|
+
return input.filter(isNonEmptyString).reduce(function(cookies, str) {
|
|
1781
|
+
var cookie = parseString(str, options);
|
|
1782
|
+
if (cookie && !isForbiddenKey(cookie.name)) cookies[cookie.name] = cookie;
|
|
1783
|
+
return cookies;
|
|
1784
|
+
}, cookies);
|
|
1785
|
+
}
|
|
1786
|
+
}
|
|
1787
|
+
function splitCookiesString(cookiesString) {
|
|
1788
|
+
if (Array.isArray(cookiesString)) return cookiesString;
|
|
1789
|
+
if (typeof cookiesString !== "string") return [];
|
|
1790
|
+
var cookiesStrings = [];
|
|
1791
|
+
var pos = 0;
|
|
1792
|
+
var start;
|
|
1793
|
+
var ch;
|
|
1794
|
+
var lastComma;
|
|
1795
|
+
var nextStart;
|
|
1796
|
+
var cookiesSeparatorFound;
|
|
1797
|
+
function skipWhitespace() {
|
|
1798
|
+
while (pos < cookiesString.length && /\s/.test(cookiesString.charAt(pos))) pos += 1;
|
|
1799
|
+
return pos < cookiesString.length;
|
|
1800
|
+
}
|
|
1801
|
+
function notSpecialChar() {
|
|
1802
|
+
ch = cookiesString.charAt(pos);
|
|
1803
|
+
return ch !== "=" && ch !== ";" && ch !== ",";
|
|
1804
|
+
}
|
|
1805
|
+
while (pos < cookiesString.length) {
|
|
1806
|
+
start = pos;
|
|
1807
|
+
cookiesSeparatorFound = false;
|
|
1808
|
+
while (skipWhitespace()) {
|
|
1809
|
+
ch = cookiesString.charAt(pos);
|
|
1810
|
+
if (ch === ",") {
|
|
1811
|
+
lastComma = pos;
|
|
1812
|
+
pos += 1;
|
|
1813
|
+
skipWhitespace();
|
|
1814
|
+
nextStart = pos;
|
|
1815
|
+
while (pos < cookiesString.length && notSpecialChar()) pos += 1;
|
|
1816
|
+
if (pos < cookiesString.length && cookiesString.charAt(pos) === "=") {
|
|
1817
|
+
cookiesSeparatorFound = true;
|
|
1818
|
+
pos = nextStart;
|
|
1819
|
+
cookiesStrings.push(cookiesString.substring(start, lastComma));
|
|
1820
|
+
start = pos;
|
|
1821
|
+
} else pos = lastComma + 1;
|
|
1822
|
+
} else pos += 1;
|
|
1823
|
+
}
|
|
1824
|
+
if (!cookiesSeparatorFound || pos >= cookiesString.length) cookiesStrings.push(cookiesString.substring(start, cookiesString.length));
|
|
1825
|
+
}
|
|
1826
|
+
return cookiesStrings;
|
|
1827
|
+
}
|
|
1828
|
+
module.exports = parse;
|
|
1829
|
+
module.exports.parse = parse;
|
|
1830
|
+
module.exports.parseString = parseString;
|
|
1831
|
+
module.exports.splitCookiesString = splitCookiesString;
|
|
1832
|
+
}));
|
|
1833
|
+
|
|
1834
|
+
//#endregion
|
|
1835
|
+
//#region .svelte-kit/adapter-bun/index.js
|
|
1836
|
+
var import_cookie = require_cookie();
|
|
1837
|
+
var import_set_cookie = /* @__PURE__ */ __toESM(require_set_cookie(), 1);
|
|
1838
|
+
function with_resolvers() {
|
|
1839
|
+
let resolve2;
|
|
1840
|
+
let reject;
|
|
1841
|
+
return {
|
|
1842
|
+
promise: new Promise((res, rej) => {
|
|
1843
|
+
resolve2 = res;
|
|
1844
|
+
reject = rej;
|
|
1845
|
+
}),
|
|
1846
|
+
resolve: resolve2,
|
|
1847
|
+
reject
|
|
1848
|
+
};
|
|
1849
|
+
}
|
|
1850
|
+
const NULL_BODY_STATUS = [
|
|
1851
|
+
101,
|
|
1852
|
+
103,
|
|
1853
|
+
204,
|
|
1854
|
+
205,
|
|
1855
|
+
304
|
|
1856
|
+
];
|
|
1857
|
+
const IN_WEBCONTAINER = !!globalThis.process?.versions?.webcontainer;
|
|
1858
|
+
const SVELTE_KIT_ASSETS = "/_svelte_kit_assets";
|
|
1859
|
+
const ENDPOINT_METHODS = [
|
|
1860
|
+
"GET",
|
|
1861
|
+
"POST",
|
|
1862
|
+
"PUT",
|
|
1863
|
+
"PATCH",
|
|
1864
|
+
"DELETE",
|
|
1865
|
+
"OPTIONS",
|
|
1866
|
+
"HEAD"
|
|
1867
|
+
];
|
|
1868
|
+
const PAGE_METHODS = [
|
|
1869
|
+
"GET",
|
|
1870
|
+
"POST",
|
|
1871
|
+
"HEAD"
|
|
1872
|
+
];
|
|
1873
|
+
function negotiate(accept, types) {
|
|
1874
|
+
const parts = [];
|
|
1875
|
+
accept.split(",").forEach((str, i) => {
|
|
1876
|
+
const match = /([^/ \t]+)\/([^; \t]+)[ \t]*(?:;[ \t]*q=([0-9.]+))?/.exec(str);
|
|
1877
|
+
if (match) {
|
|
1878
|
+
const [, type, subtype, q = "1"] = match;
|
|
1879
|
+
parts.push({
|
|
1880
|
+
type,
|
|
1881
|
+
subtype,
|
|
1882
|
+
q: +q,
|
|
1883
|
+
i
|
|
1884
|
+
});
|
|
1885
|
+
}
|
|
1886
|
+
});
|
|
1887
|
+
parts.sort((a, b) => {
|
|
1888
|
+
if (a.q !== b.q) return b.q - a.q;
|
|
1889
|
+
if (a.subtype === "*" !== (b.subtype === "*")) return a.subtype === "*" ? 1 : -1;
|
|
1890
|
+
if (a.type === "*" !== (b.type === "*")) return a.type === "*" ? 1 : -1;
|
|
1891
|
+
return a.i - b.i;
|
|
1892
|
+
});
|
|
1893
|
+
let accepted;
|
|
1894
|
+
let min_priority = Infinity;
|
|
1895
|
+
for (const mimetype of types) {
|
|
1896
|
+
const [type, subtype] = mimetype.split("/");
|
|
1897
|
+
const priority = parts.findIndex((part) => (part.type === type || part.type === "*") && (part.subtype === subtype || part.subtype === "*"));
|
|
1898
|
+
if (priority !== -1 && priority < min_priority) {
|
|
1899
|
+
accepted = mimetype;
|
|
1900
|
+
min_priority = priority;
|
|
1901
|
+
}
|
|
1902
|
+
}
|
|
1903
|
+
return accepted;
|
|
1904
|
+
}
|
|
1905
|
+
function is_content_type(request, ...types) {
|
|
1906
|
+
const type = request.headers.get("content-type")?.split(";", 1)[0].trim() ?? "";
|
|
1907
|
+
return types.includes(type.toLowerCase());
|
|
1908
|
+
}
|
|
1909
|
+
function is_form_content_type(request) {
|
|
1910
|
+
return is_content_type(request, "application/x-www-form-urlencoded", "multipart/form-data", "text/plain", BINARY_FORM_CONTENT_TYPE);
|
|
1911
|
+
}
|
|
1912
|
+
function coalesce_to_error(err) {
|
|
1913
|
+
return err instanceof Error || err && err.name && err.message ? err : new Error(JSON.stringify(err));
|
|
1914
|
+
}
|
|
1915
|
+
function normalize_error(error2) {
|
|
1916
|
+
return error2;
|
|
1917
|
+
}
|
|
1918
|
+
function get_status(error2) {
|
|
1919
|
+
return error2 instanceof HttpError || error2 instanceof SvelteKitError ? error2.status : 500;
|
|
1920
|
+
}
|
|
1921
|
+
function get_message(error2) {
|
|
1922
|
+
return error2 instanceof SvelteKitError ? error2.text : "Internal Error";
|
|
1923
|
+
}
|
|
1924
|
+
const escape_html_attr_dict = {
|
|
1925
|
+
"&": "&",
|
|
1926
|
+
"\"": """
|
|
1927
|
+
};
|
|
1928
|
+
const escape_html_dict = {
|
|
1929
|
+
"&": "&",
|
|
1930
|
+
"<": "<"
|
|
1931
|
+
};
|
|
1932
|
+
const escape_html_attr_regex = new RegExp(`[${Object.keys(escape_html_attr_dict).join("")}]|[\\ud800-\\udbff](?![\\udc00-\\udfff])|[\\ud800-\\udbff][\\udc00-\\udfff]|[\\udc00-\\udfff]`, "g");
|
|
1933
|
+
const escape_html_regex = new RegExp(`[${Object.keys(escape_html_dict).join("")}]|[\\ud800-\\udbff](?![\\udc00-\\udfff])|[\\ud800-\\udbff][\\udc00-\\udfff]|[\\udc00-\\udfff]`, "g");
|
|
1934
|
+
function escape_html(str, is_attr) {
|
|
1935
|
+
const dict = is_attr ? escape_html_attr_dict : escape_html_dict;
|
|
1936
|
+
return str.replace(is_attr ? escape_html_attr_regex : escape_html_regex, (match) => {
|
|
1937
|
+
if (match.length === 2) return match;
|
|
1938
|
+
return dict[match] ?? `&#${match.charCodeAt(0)};`;
|
|
1939
|
+
});
|
|
1940
|
+
}
|
|
1941
|
+
function method_not_allowed(mod, method) {
|
|
1942
|
+
return text(`${method} method not allowed`, {
|
|
1943
|
+
status: 405,
|
|
1944
|
+
headers: { allow: allowed_methods(mod).join(", ") }
|
|
1945
|
+
});
|
|
1946
|
+
}
|
|
1947
|
+
function allowed_methods(mod) {
|
|
1948
|
+
const allowed = ENDPOINT_METHODS.filter((method) => method in mod);
|
|
1949
|
+
if ("GET" in mod && !("HEAD" in mod)) allowed.push("HEAD");
|
|
1950
|
+
return allowed;
|
|
1951
|
+
}
|
|
1952
|
+
function get_global_name(options2) {
|
|
1953
|
+
return `__sveltekit_${options2.version_hash}`;
|
|
1954
|
+
}
|
|
1955
|
+
function static_error_page(options2, status, message) {
|
|
1956
|
+
return text(options2.templates.error({
|
|
1957
|
+
status,
|
|
1958
|
+
message: escape_html(message)
|
|
1959
|
+
}), {
|
|
1960
|
+
headers: { "content-type": "text/html; charset=utf-8" },
|
|
1961
|
+
status
|
|
1962
|
+
});
|
|
1963
|
+
}
|
|
1964
|
+
async function handle_fatal_error(event, state, options2, error2) {
|
|
1965
|
+
error2 = error2 instanceof HttpError ? error2 : coalesce_to_error(error2);
|
|
1966
|
+
const status = get_status(error2);
|
|
1967
|
+
const body2 = await handle_error_and_jsonify(event, state, options2, error2);
|
|
1968
|
+
const type = negotiate(event.request.headers.get("accept") || "text/html", ["application/json", "text/html"]);
|
|
1969
|
+
if (event.isDataRequest || type === "application/json") return json(body2, { status });
|
|
1970
|
+
return static_error_page(options2, status, body2.message);
|
|
1971
|
+
}
|
|
1972
|
+
async function handle_error_and_jsonify(event, state, options2, error2) {
|
|
1973
|
+
if (error2 instanceof HttpError) return {
|
|
1974
|
+
message: "Unknown Error",
|
|
1975
|
+
...error2.body
|
|
1976
|
+
};
|
|
1977
|
+
const status = get_status(error2);
|
|
1978
|
+
const message = get_message(error2);
|
|
1979
|
+
return await with_request_store({
|
|
1980
|
+
event,
|
|
1981
|
+
state
|
|
1982
|
+
}, () => options2.hooks.handleError({
|
|
1983
|
+
error: error2,
|
|
1984
|
+
event,
|
|
1985
|
+
status,
|
|
1986
|
+
message
|
|
1987
|
+
})) ?? { message };
|
|
1988
|
+
}
|
|
1989
|
+
function redirect_response(status, location) {
|
|
1990
|
+
return new Response(void 0, {
|
|
1991
|
+
status,
|
|
1992
|
+
headers: { location }
|
|
1993
|
+
});
|
|
1994
|
+
}
|
|
1995
|
+
function clarify_devalue_error(event, error2) {
|
|
1996
|
+
if (error2.path) return `Data returned from \`load\` while rendering ${event.route.id} is not serializable: ${error2.message} (${error2.path}). If you need to serialize/deserialize custom types, use transport hooks: https://svelte.dev/docs/kit/hooks#Universal-hooks-transport.`;
|
|
1997
|
+
if (error2.path === "") return `Data returned from \`load\` while rendering ${event.route.id} is not a plain object`;
|
|
1998
|
+
return error2.message;
|
|
1999
|
+
}
|
|
2000
|
+
function serialize_uses(node) {
|
|
2001
|
+
const uses = {};
|
|
2002
|
+
if (node.uses && node.uses.dependencies.size > 0) uses.dependencies = Array.from(node.uses.dependencies);
|
|
2003
|
+
if (node.uses && node.uses.search_params.size > 0) uses.search_params = Array.from(node.uses.search_params);
|
|
2004
|
+
if (node.uses && node.uses.params.size > 0) uses.params = Array.from(node.uses.params);
|
|
2005
|
+
if (node.uses?.parent) uses.parent = 1;
|
|
2006
|
+
if (node.uses?.route) uses.route = 1;
|
|
2007
|
+
if (node.uses?.url) uses.url = 1;
|
|
2008
|
+
return uses;
|
|
2009
|
+
}
|
|
2010
|
+
function has_prerendered_path(manifest, pathname) {
|
|
2011
|
+
return manifest._.prerendered_routes.has(pathname) || pathname.at(-1) === "/" && manifest._.prerendered_routes.has(pathname.slice(0, -1));
|
|
2012
|
+
}
|
|
2013
|
+
function format_server_error(status, error2, event) {
|
|
2014
|
+
const formatted_text = `
|
|
2015
|
+
\x1B[1;31m[${status}] ${event.request.method} ${event.url.pathname}\x1B[0m`;
|
|
2016
|
+
if (status === 404) return formatted_text;
|
|
2017
|
+
return `${formatted_text}
|
|
2018
|
+
${error2.stack}`;
|
|
2019
|
+
}
|
|
2020
|
+
function get_node_type(node_id) {
|
|
2021
|
+
const filename = (node_id?.split("/"))?.at(-1);
|
|
2022
|
+
if (!filename) return "unknown";
|
|
2023
|
+
return filename.split(".").slice(0, -1).join(".");
|
|
2024
|
+
}
|
|
2025
|
+
async function render_endpoint(event, event_state, mod, state) {
|
|
2026
|
+
const method = event.request.method;
|
|
2027
|
+
let handler = mod[method] || mod.fallback;
|
|
2028
|
+
if (method === "HEAD" && !mod.HEAD && mod.GET) handler = mod.GET;
|
|
2029
|
+
if (!handler) return method_not_allowed(mod, method);
|
|
2030
|
+
const prerender = mod.prerender ?? state.prerender_default;
|
|
2031
|
+
if (prerender && (mod.POST || mod.PATCH || mod.PUT || mod.DELETE)) throw new Error("Cannot prerender endpoints that have mutative methods");
|
|
2032
|
+
if (state.prerendering && !state.prerendering.inside_reroute && !prerender) if (state.depth > 0) throw new Error(`${event.route.id} is not prerenderable`);
|
|
2033
|
+
else return new Response(void 0, { status: 204 });
|
|
2034
|
+
event_state.is_endpoint_request = true;
|
|
2035
|
+
try {
|
|
2036
|
+
const response = await with_request_store({
|
|
2037
|
+
event,
|
|
2038
|
+
state: event_state
|
|
2039
|
+
}, () => handler(
|
|
2040
|
+
/** @type {import('@sveltejs/kit').RequestEvent<Record<string, any>>} */
|
|
2041
|
+
event
|
|
2042
|
+
));
|
|
2043
|
+
if (!(response instanceof Response)) throw new Error(`Invalid response from route ${event.url.pathname}: handler should return a Response object`);
|
|
2044
|
+
if (state.prerendering && (!state.prerendering.inside_reroute || prerender)) {
|
|
2045
|
+
const cloned = new Response(response.clone().body, {
|
|
2046
|
+
status: response.status,
|
|
2047
|
+
statusText: response.statusText,
|
|
2048
|
+
headers: new Headers(response.headers)
|
|
2049
|
+
});
|
|
2050
|
+
cloned.headers.set("x-sveltekit-prerender", String(prerender));
|
|
2051
|
+
if (state.prerendering.inside_reroute && prerender) {
|
|
2052
|
+
cloned.headers.set("x-sveltekit-routeid", encodeURI(
|
|
2053
|
+
/** @type {string} */
|
|
2054
|
+
event.route.id
|
|
2055
|
+
));
|
|
2056
|
+
state.prerendering.dependencies.set(event.url.pathname, {
|
|
2057
|
+
response: cloned,
|
|
2058
|
+
body: null
|
|
2059
|
+
});
|
|
2060
|
+
} else return cloned;
|
|
2061
|
+
}
|
|
2062
|
+
return response;
|
|
2063
|
+
} catch (e) {
|
|
2064
|
+
if (e instanceof Redirect) return new Response(void 0, {
|
|
2065
|
+
status: e.status,
|
|
2066
|
+
headers: { location: e.location }
|
|
2067
|
+
});
|
|
2068
|
+
throw e;
|
|
2069
|
+
}
|
|
2070
|
+
}
|
|
2071
|
+
function is_endpoint_request(event) {
|
|
2072
|
+
const { method, headers: headers2 } = event.request;
|
|
2073
|
+
if (ENDPOINT_METHODS.includes(method) && !PAGE_METHODS.includes(method)) return true;
|
|
2074
|
+
if (method === "POST" && headers2.get("x-sveltekit-action") === "true") return false;
|
|
2075
|
+
return negotiate(event.request.headers.get("accept") ?? "*/*", ["*", "text/html"]) !== "text/html";
|
|
2076
|
+
}
|
|
2077
|
+
function compact(arr) {
|
|
2078
|
+
return arr.filter(
|
|
2079
|
+
/** @returns {val is NonNullable<T>} */
|
|
2080
|
+
(val) => val != null
|
|
2081
|
+
);
|
|
2082
|
+
}
|
|
2083
|
+
const DATA_SUFFIX = "/__data.json";
|
|
2084
|
+
const HTML_DATA_SUFFIX = ".html__data.json";
|
|
2085
|
+
function has_data_suffix(pathname) {
|
|
2086
|
+
return pathname.endsWith(DATA_SUFFIX) || pathname.endsWith(HTML_DATA_SUFFIX);
|
|
2087
|
+
}
|
|
2088
|
+
function add_data_suffix(pathname) {
|
|
2089
|
+
if (pathname.endsWith(".html")) return pathname.replace(/\.html$/, HTML_DATA_SUFFIX);
|
|
2090
|
+
return pathname.replace(/\/$/, "") + DATA_SUFFIX;
|
|
2091
|
+
}
|
|
2092
|
+
function strip_data_suffix(pathname) {
|
|
2093
|
+
if (pathname.endsWith(HTML_DATA_SUFFIX)) return pathname.slice(0, -16) + ".html";
|
|
2094
|
+
return pathname.slice(0, -12);
|
|
2095
|
+
}
|
|
2096
|
+
const ROUTE_SUFFIX = "/__route.js";
|
|
2097
|
+
function has_resolution_suffix(pathname) {
|
|
2098
|
+
return pathname.endsWith(ROUTE_SUFFIX);
|
|
2099
|
+
}
|
|
2100
|
+
function add_resolution_suffix(pathname) {
|
|
2101
|
+
return pathname.replace(/\/$/, "") + ROUTE_SUFFIX;
|
|
2102
|
+
}
|
|
2103
|
+
function strip_resolution_suffix(pathname) {
|
|
2104
|
+
return pathname.slice(0, -11);
|
|
2105
|
+
}
|
|
2106
|
+
const noop_span = {
|
|
2107
|
+
spanContext() {
|
|
2108
|
+
return noop_span_context;
|
|
2109
|
+
},
|
|
2110
|
+
setAttribute() {
|
|
2111
|
+
return this;
|
|
2112
|
+
},
|
|
2113
|
+
setAttributes() {
|
|
2114
|
+
return this;
|
|
2115
|
+
},
|
|
2116
|
+
addEvent() {
|
|
2117
|
+
return this;
|
|
2118
|
+
},
|
|
2119
|
+
setStatus() {
|
|
2120
|
+
return this;
|
|
2121
|
+
},
|
|
2122
|
+
updateName() {
|
|
2123
|
+
return this;
|
|
2124
|
+
},
|
|
2125
|
+
end() {
|
|
2126
|
+
return this;
|
|
2127
|
+
},
|
|
2128
|
+
isRecording() {
|
|
2129
|
+
return false;
|
|
2130
|
+
},
|
|
2131
|
+
recordException() {
|
|
2132
|
+
return this;
|
|
2133
|
+
},
|
|
2134
|
+
addLink() {
|
|
2135
|
+
return this;
|
|
2136
|
+
},
|
|
2137
|
+
addLinks() {
|
|
2138
|
+
return this;
|
|
2139
|
+
}
|
|
2140
|
+
};
|
|
2141
|
+
const noop_span_context = {
|
|
2142
|
+
traceId: "",
|
|
2143
|
+
spanId: "",
|
|
2144
|
+
traceFlags: 0
|
|
2145
|
+
};
|
|
2146
|
+
async function record_span({ name, attributes, fn }) {
|
|
2147
|
+
return fn(noop_span);
|
|
2148
|
+
}
|
|
2149
|
+
function is_action_json_request(event) {
|
|
2150
|
+
return negotiate(event.request.headers.get("accept") ?? "*/*", ["application/json", "text/html"]) === "application/json" && event.request.method === "POST";
|
|
2151
|
+
}
|
|
2152
|
+
async function handle_action_json_request(event, event_state, options2, server) {
|
|
2153
|
+
const actions = server?.actions;
|
|
2154
|
+
if (!actions) {
|
|
2155
|
+
const no_actions_error = new SvelteKitError(405, "Method Not Allowed", `POST method not allowed. No form actions exist for this page`);
|
|
2156
|
+
return action_json({
|
|
2157
|
+
type: "error",
|
|
2158
|
+
error: await handle_error_and_jsonify(event, event_state, options2, no_actions_error)
|
|
2159
|
+
}, {
|
|
2160
|
+
status: no_actions_error.status,
|
|
2161
|
+
headers: { allow: "GET" }
|
|
2162
|
+
});
|
|
2163
|
+
}
|
|
2164
|
+
check_named_default_separate(actions);
|
|
2165
|
+
try {
|
|
2166
|
+
const data = await call_action(event, event_state, actions);
|
|
2167
|
+
if (BROWSER);
|
|
2168
|
+
if (data instanceof ActionFailure) return action_json({
|
|
2169
|
+
type: "failure",
|
|
2170
|
+
status: data.status,
|
|
2171
|
+
data: stringify_action_response(
|
|
2172
|
+
data.data,
|
|
2173
|
+
/** @type {string} */
|
|
2174
|
+
event.route.id,
|
|
2175
|
+
options2.hooks.transport
|
|
2176
|
+
)
|
|
2177
|
+
});
|
|
2178
|
+
else return action_json({
|
|
2179
|
+
type: "success",
|
|
2180
|
+
status: data ? 200 : 204,
|
|
2181
|
+
data: stringify_action_response(
|
|
2182
|
+
data,
|
|
2183
|
+
/** @type {string} */
|
|
2184
|
+
event.route.id,
|
|
2185
|
+
options2.hooks.transport
|
|
2186
|
+
)
|
|
2187
|
+
});
|
|
2188
|
+
} catch (e) {
|
|
2189
|
+
const err = normalize_error(e);
|
|
2190
|
+
if (err instanceof Redirect) return action_json_redirect(err);
|
|
2191
|
+
return action_json({
|
|
2192
|
+
type: "error",
|
|
2193
|
+
error: await handle_error_and_jsonify(event, event_state, options2, check_incorrect_fail_use(err))
|
|
2194
|
+
}, { status: get_status(err) });
|
|
2195
|
+
}
|
|
2196
|
+
}
|
|
2197
|
+
function check_incorrect_fail_use(error2) {
|
|
2198
|
+
return error2 instanceof ActionFailure ? /* @__PURE__ */ new Error("Cannot \"throw fail()\". Use \"return fail()\"") : error2;
|
|
2199
|
+
}
|
|
2200
|
+
function action_json_redirect(redirect) {
|
|
2201
|
+
return action_json({
|
|
2202
|
+
type: "redirect",
|
|
2203
|
+
status: redirect.status,
|
|
2204
|
+
location: redirect.location
|
|
2205
|
+
});
|
|
2206
|
+
}
|
|
2207
|
+
function action_json(data, init2) {
|
|
2208
|
+
return json(data, init2);
|
|
2209
|
+
}
|
|
2210
|
+
function is_action_request(event) {
|
|
2211
|
+
return event.request.method === "POST";
|
|
2212
|
+
}
|
|
2213
|
+
async function handle_action_request(event, event_state, server) {
|
|
2214
|
+
const actions = server?.actions;
|
|
2215
|
+
if (!actions) {
|
|
2216
|
+
event.setHeaders({ allow: "GET" });
|
|
2217
|
+
return {
|
|
2218
|
+
type: "error",
|
|
2219
|
+
error: new SvelteKitError(405, "Method Not Allowed", `POST method not allowed. No form actions exist for this page`)
|
|
2220
|
+
};
|
|
2221
|
+
}
|
|
2222
|
+
check_named_default_separate(actions);
|
|
2223
|
+
try {
|
|
2224
|
+
const data = await call_action(event, event_state, actions);
|
|
2225
|
+
if (BROWSER);
|
|
2226
|
+
if (data instanceof ActionFailure) return {
|
|
2227
|
+
type: "failure",
|
|
2228
|
+
status: data.status,
|
|
2229
|
+
data: data.data
|
|
2230
|
+
};
|
|
2231
|
+
else return {
|
|
2232
|
+
type: "success",
|
|
2233
|
+
status: 200,
|
|
2234
|
+
data
|
|
2235
|
+
};
|
|
2236
|
+
} catch (e) {
|
|
2237
|
+
const err = normalize_error(e);
|
|
2238
|
+
if (err instanceof Redirect) return {
|
|
2239
|
+
type: "redirect",
|
|
2240
|
+
status: err.status,
|
|
2241
|
+
location: err.location
|
|
2242
|
+
};
|
|
2243
|
+
return {
|
|
2244
|
+
type: "error",
|
|
2245
|
+
error: check_incorrect_fail_use(err)
|
|
2246
|
+
};
|
|
2247
|
+
}
|
|
2248
|
+
}
|
|
2249
|
+
function check_named_default_separate(actions) {
|
|
2250
|
+
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");
|
|
2251
|
+
}
|
|
2252
|
+
async function call_action(event, event_state, actions) {
|
|
2253
|
+
const url = new URL(event.request.url);
|
|
2254
|
+
let name = "default";
|
|
2255
|
+
for (const param of url.searchParams) if (param[0].startsWith("/")) {
|
|
2256
|
+
name = param[0].slice(1);
|
|
2257
|
+
if (name === "default") throw new Error("Cannot use reserved action name \"default\"");
|
|
2258
|
+
break;
|
|
2259
|
+
}
|
|
2260
|
+
const action = actions[name];
|
|
2261
|
+
if (!action) throw new SvelteKitError(404, "Not Found", `No action with name '${name}' found`);
|
|
2262
|
+
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")}`);
|
|
2263
|
+
return record_span({
|
|
2264
|
+
name: "sveltekit.form_action",
|
|
2265
|
+
attributes: { "http.route": event.route.id || "unknown" },
|
|
2266
|
+
fn: async (current2) => {
|
|
2267
|
+
const traced_event = merge_tracing(event, current2);
|
|
2268
|
+
const result = await with_request_store({
|
|
2269
|
+
event: traced_event,
|
|
2270
|
+
state: event_state
|
|
2271
|
+
}, () => action(traced_event));
|
|
2272
|
+
if (result instanceof ActionFailure) current2.setAttributes({
|
|
2273
|
+
"sveltekit.form_action.result.type": "failure",
|
|
2274
|
+
"sveltekit.form_action.result.status": result.status
|
|
2275
|
+
});
|
|
2276
|
+
return result;
|
|
2277
|
+
}
|
|
2278
|
+
});
|
|
2279
|
+
}
|
|
2280
|
+
function uneval_action_response(data, route_id, transport) {
|
|
2281
|
+
const replacer = (thing) => {
|
|
2282
|
+
for (const key2 in transport) {
|
|
2283
|
+
const encoded = transport[key2].encode(thing);
|
|
2284
|
+
if (encoded) return `app.decode('${key2}', ${uneval(encoded, replacer)})`;
|
|
2285
|
+
}
|
|
2286
|
+
};
|
|
2287
|
+
return try_serialize(data, (value) => uneval(value, replacer), route_id);
|
|
2288
|
+
}
|
|
2289
|
+
function stringify_action_response(data, route_id, transport) {
|
|
2290
|
+
const encoders = Object.fromEntries(Object.entries(transport).map(([key2, value]) => [key2, value.encode]));
|
|
2291
|
+
return try_serialize(data, (value) => stringify$1(value, encoders), route_id);
|
|
2292
|
+
}
|
|
2293
|
+
function try_serialize(data, fn, route_id) {
|
|
2294
|
+
try {
|
|
2295
|
+
return fn(data);
|
|
2296
|
+
} catch (e) {
|
|
2297
|
+
const error2 = e;
|
|
2298
|
+
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" });`);
|
|
2299
|
+
if ("path" in error2) {
|
|
2300
|
+
let message = `Data returned from action inside ${route_id} is not serializable: ${error2.message}`;
|
|
2301
|
+
if (error2.path !== "") message += ` (data.${error2.path})`;
|
|
2302
|
+
throw new Error(message);
|
|
2303
|
+
}
|
|
2304
|
+
throw error2;
|
|
2305
|
+
}
|
|
2306
|
+
}
|
|
2307
|
+
function create_async_iterator() {
|
|
2308
|
+
let resolved = -1;
|
|
2309
|
+
let returned = -1;
|
|
2310
|
+
const deferred = [];
|
|
2311
|
+
return {
|
|
2312
|
+
iterate: (transform = (x) => x) => {
|
|
2313
|
+
return { [Symbol.asyncIterator]() {
|
|
2314
|
+
return { next: async () => {
|
|
2315
|
+
const next = deferred[++returned];
|
|
2316
|
+
if (!next) return {
|
|
2317
|
+
value: null,
|
|
2318
|
+
done: true
|
|
2319
|
+
};
|
|
2320
|
+
return {
|
|
2321
|
+
value: transform(await next.promise),
|
|
2322
|
+
done: false
|
|
2323
|
+
};
|
|
2324
|
+
} };
|
|
2325
|
+
} };
|
|
2326
|
+
},
|
|
2327
|
+
add: (promise) => {
|
|
2328
|
+
deferred.push(with_resolvers());
|
|
2329
|
+
promise.then((value) => {
|
|
2330
|
+
deferred[++resolved].resolve(value);
|
|
2331
|
+
});
|
|
2332
|
+
}
|
|
2333
|
+
};
|
|
2334
|
+
}
|
|
2335
|
+
function server_data_serializer(event, event_state, options2) {
|
|
2336
|
+
let promise_id = 1;
|
|
2337
|
+
let max_nodes = -1;
|
|
2338
|
+
const iterator = create_async_iterator();
|
|
2339
|
+
const global = get_global_name(options2);
|
|
2340
|
+
function get_replacer(index) {
|
|
2341
|
+
return function replacer(thing) {
|
|
2342
|
+
if (typeof thing?.then === "function") {
|
|
2343
|
+
const id = promise_id++;
|
|
2344
|
+
const promise = thing.then(
|
|
2345
|
+
/** @param {any} data */
|
|
2346
|
+
(data) => ({ data })
|
|
2347
|
+
).catch(
|
|
2348
|
+
/** @param {any} error */
|
|
2349
|
+
async (error2) => ({ error: await handle_error_and_jsonify(event, event_state, options2, error2) })
|
|
2350
|
+
).then(
|
|
2351
|
+
/**
|
|
2352
|
+
* @param {{data: any; error: any}} result
|
|
2353
|
+
*/
|
|
2354
|
+
async ({ data, error: error2 }) => {
|
|
2355
|
+
let str;
|
|
2356
|
+
try {
|
|
2357
|
+
str = uneval(error2 ? [, error2] : [data], replacer);
|
|
2358
|
+
} catch {
|
|
2359
|
+
error2 = await handle_error_and_jsonify(event, event_state, options2, /* @__PURE__ */ new Error(`Failed to serialize promise while rendering ${event.route.id}`));
|
|
2360
|
+
data = void 0;
|
|
2361
|
+
str = uneval([, error2], replacer);
|
|
2362
|
+
}
|
|
2363
|
+
return {
|
|
2364
|
+
index,
|
|
2365
|
+
str: `${global}.resolve(${id}, ${str.includes("app.decode") ? `(app) => ${str}` : `() => ${str}`})`
|
|
2366
|
+
};
|
|
2367
|
+
}
|
|
2368
|
+
);
|
|
2369
|
+
iterator.add(promise);
|
|
2370
|
+
return `${global}.defer(${id})`;
|
|
2371
|
+
} else for (const key2 in options2.hooks.transport) {
|
|
2372
|
+
const encoded = options2.hooks.transport[key2].encode(thing);
|
|
2373
|
+
if (encoded) return `app.decode('${key2}', ${uneval(encoded, replacer)})`;
|
|
2374
|
+
}
|
|
2375
|
+
};
|
|
2376
|
+
}
|
|
2377
|
+
const strings = [];
|
|
2378
|
+
return {
|
|
2379
|
+
set_max_nodes(i) {
|
|
2380
|
+
max_nodes = i;
|
|
2381
|
+
},
|
|
2382
|
+
add_node(i, node) {
|
|
2383
|
+
try {
|
|
2384
|
+
if (!node) {
|
|
2385
|
+
strings[i] = "null";
|
|
2386
|
+
return;
|
|
2387
|
+
}
|
|
2388
|
+
const payload = {
|
|
2389
|
+
type: "data",
|
|
2390
|
+
data: node.data,
|
|
2391
|
+
uses: serialize_uses(node)
|
|
2392
|
+
};
|
|
2393
|
+
if (node.slash) payload.slash = node.slash;
|
|
2394
|
+
strings[i] = uneval(payload, get_replacer(i));
|
|
2395
|
+
} catch (e) {
|
|
2396
|
+
e.path = e.path.slice(1);
|
|
2397
|
+
throw new Error(clarify_devalue_error(
|
|
2398
|
+
event,
|
|
2399
|
+
/** @type {any} */
|
|
2400
|
+
e
|
|
2401
|
+
));
|
|
2402
|
+
}
|
|
2403
|
+
},
|
|
2404
|
+
get_data(csp) {
|
|
2405
|
+
const open = `<script${csp.script_needs_nonce ? ` nonce="${csp.nonce}"` : ""}>`;
|
|
2406
|
+
const close = `<\/script>
|
|
2407
|
+
`;
|
|
2408
|
+
return {
|
|
2409
|
+
data: `[${compact(max_nodes > -1 ? strings.slice(0, max_nodes) : strings).join(",")}]`,
|
|
2410
|
+
chunks: promise_id > 1 ? iterator.iterate(({ index, str }) => {
|
|
2411
|
+
if (max_nodes > -1 && index >= max_nodes) return "";
|
|
2412
|
+
return open + str + close;
|
|
2413
|
+
}) : null
|
|
2414
|
+
};
|
|
2415
|
+
}
|
|
2416
|
+
};
|
|
2417
|
+
}
|
|
2418
|
+
function server_data_serializer_json(event, event_state, options2) {
|
|
2419
|
+
let promise_id = 1;
|
|
2420
|
+
const iterator = create_async_iterator();
|
|
2421
|
+
const reducers = {
|
|
2422
|
+
...Object.fromEntries(Object.entries(options2.hooks.transport).map(([key2, value]) => [key2, value.encode])),
|
|
2423
|
+
Promise: (thing) => {
|
|
2424
|
+
if (typeof thing?.then !== "function") return;
|
|
2425
|
+
const id = promise_id++;
|
|
2426
|
+
let key2 = "data";
|
|
2427
|
+
const promise = thing.catch(
|
|
2428
|
+
/** @param {any} e */
|
|
2429
|
+
async (e) => {
|
|
2430
|
+
key2 = "error";
|
|
2431
|
+
return handle_error_and_jsonify(
|
|
2432
|
+
event,
|
|
2433
|
+
event_state,
|
|
2434
|
+
options2,
|
|
2435
|
+
/** @type {any} */
|
|
2436
|
+
e
|
|
2437
|
+
);
|
|
2438
|
+
}
|
|
2439
|
+
).then(
|
|
2440
|
+
/** @param {any} value */
|
|
2441
|
+
async (value) => {
|
|
2442
|
+
let str;
|
|
2443
|
+
try {
|
|
2444
|
+
str = stringify$1(value, reducers);
|
|
2445
|
+
} catch {
|
|
2446
|
+
const error2 = await handle_error_and_jsonify(event, event_state, options2, /* @__PURE__ */ new Error(`Failed to serialize promise while rendering ${event.route.id}`));
|
|
2447
|
+
key2 = "error";
|
|
2448
|
+
str = stringify$1(error2, reducers);
|
|
2449
|
+
}
|
|
2450
|
+
return `{"type":"chunk","id":${id},"${key2}":${str}}
|
|
2451
|
+
`;
|
|
2452
|
+
}
|
|
2453
|
+
);
|
|
2454
|
+
iterator.add(promise);
|
|
2455
|
+
return id;
|
|
2456
|
+
}
|
|
2457
|
+
};
|
|
2458
|
+
const strings = [];
|
|
2459
|
+
return {
|
|
2460
|
+
add_node(i, node) {
|
|
2461
|
+
try {
|
|
2462
|
+
if (!node) {
|
|
2463
|
+
strings[i] = "null";
|
|
2464
|
+
return;
|
|
2465
|
+
}
|
|
2466
|
+
if (node.type === "error" || node.type === "skip") {
|
|
2467
|
+
strings[i] = JSON.stringify(node);
|
|
2468
|
+
return;
|
|
2469
|
+
}
|
|
2470
|
+
strings[i] = `{"type":"data","data":${stringify$1(node.data, reducers)},"uses":${JSON.stringify(serialize_uses(node))}${node.slash ? `,"slash":${JSON.stringify(node.slash)}` : ""}}`;
|
|
2471
|
+
} catch (e) {
|
|
2472
|
+
e.path = "data" + e.path;
|
|
2473
|
+
throw new Error(clarify_devalue_error(
|
|
2474
|
+
event,
|
|
2475
|
+
/** @type {any} */
|
|
2476
|
+
e
|
|
2477
|
+
));
|
|
2478
|
+
}
|
|
2479
|
+
},
|
|
2480
|
+
get_data() {
|
|
2481
|
+
return {
|
|
2482
|
+
data: `{"type":"data","nodes":[${strings.join(",")}]}
|
|
2483
|
+
`,
|
|
2484
|
+
chunks: promise_id > 1 ? iterator.iterate() : null
|
|
2485
|
+
};
|
|
2486
|
+
}
|
|
2487
|
+
};
|
|
2488
|
+
}
|
|
2489
|
+
async function load_server_data({ event, event_state, state, node, parent }) {
|
|
2490
|
+
if (!node?.server) return null;
|
|
2491
|
+
let is_tracking = true;
|
|
2492
|
+
const uses = {
|
|
2493
|
+
dependencies: /* @__PURE__ */ new Set(),
|
|
2494
|
+
params: /* @__PURE__ */ new Set(),
|
|
2495
|
+
parent: false,
|
|
2496
|
+
route: false,
|
|
2497
|
+
url: false,
|
|
2498
|
+
search_params: /* @__PURE__ */ new Set()
|
|
2499
|
+
};
|
|
2500
|
+
const load = node.server.load;
|
|
2501
|
+
const slash = node.server.trailingSlash;
|
|
2502
|
+
if (!load) return {
|
|
2503
|
+
type: "data",
|
|
2504
|
+
data: null,
|
|
2505
|
+
uses,
|
|
2506
|
+
slash
|
|
2507
|
+
};
|
|
2508
|
+
const url = make_trackable(event.url, () => {
|
|
2509
|
+
if (is_tracking) uses.url = true;
|
|
2510
|
+
}, (param) => {
|
|
2511
|
+
if (is_tracking) uses.search_params.add(param);
|
|
2512
|
+
});
|
|
2513
|
+
if (state.prerendering) disable_search(url);
|
|
2514
|
+
return {
|
|
2515
|
+
type: "data",
|
|
2516
|
+
data: await record_span({
|
|
2517
|
+
name: "sveltekit.load",
|
|
2518
|
+
attributes: {
|
|
2519
|
+
"sveltekit.load.node_id": node.server_id || "unknown",
|
|
2520
|
+
"sveltekit.load.node_type": get_node_type(node.server_id),
|
|
2521
|
+
"http.route": event.route.id || "unknown"
|
|
2522
|
+
},
|
|
2523
|
+
fn: async (current2) => {
|
|
2524
|
+
const traced_event = merge_tracing(event, current2);
|
|
2525
|
+
return await with_request_store({
|
|
2526
|
+
event: traced_event,
|
|
2527
|
+
state: event_state
|
|
2528
|
+
}, () => load.call(null, {
|
|
2529
|
+
...traced_event,
|
|
2530
|
+
fetch: (info, init2) => {
|
|
2531
|
+
new URL(info instanceof Request ? info.url : info, event.url);
|
|
2532
|
+
return event.fetch(info, init2);
|
|
2533
|
+
},
|
|
2534
|
+
depends: (...deps) => {
|
|
2535
|
+
for (const dep of deps) {
|
|
2536
|
+
const { href } = new URL(dep, event.url);
|
|
2537
|
+
uses.dependencies.add(href);
|
|
2538
|
+
}
|
|
2539
|
+
},
|
|
2540
|
+
params: new Proxy(event.params, { get: (target, key2) => {
|
|
2541
|
+
if (is_tracking) uses.params.add(key2);
|
|
2542
|
+
return target[key2];
|
|
2543
|
+
} }),
|
|
2544
|
+
parent: async () => {
|
|
2545
|
+
if (is_tracking) uses.parent = true;
|
|
2546
|
+
return parent();
|
|
2547
|
+
},
|
|
2548
|
+
route: new Proxy(event.route, { get: (target, key2) => {
|
|
2549
|
+
if (is_tracking) uses.route = true;
|
|
2550
|
+
return target[key2];
|
|
2551
|
+
} }),
|
|
2552
|
+
url,
|
|
2553
|
+
untrack(fn) {
|
|
2554
|
+
is_tracking = false;
|
|
2555
|
+
try {
|
|
2556
|
+
return fn();
|
|
2557
|
+
} finally {
|
|
2558
|
+
is_tracking = true;
|
|
2559
|
+
}
|
|
2560
|
+
}
|
|
2561
|
+
}));
|
|
2562
|
+
}
|
|
2563
|
+
}) ?? null,
|
|
2564
|
+
uses,
|
|
2565
|
+
slash
|
|
2566
|
+
};
|
|
2567
|
+
}
|
|
2568
|
+
async function load_data({ event, event_state, fetched, node, parent, server_data_promise, state, resolve_opts, csr }) {
|
|
2569
|
+
const server_data_node = await server_data_promise;
|
|
2570
|
+
const load = node?.universal?.load;
|
|
2571
|
+
if (!load) return server_data_node?.data ?? null;
|
|
2572
|
+
return await record_span({
|
|
2573
|
+
name: "sveltekit.load",
|
|
2574
|
+
attributes: {
|
|
2575
|
+
"sveltekit.load.node_id": node.universal_id || "unknown",
|
|
2576
|
+
"sveltekit.load.node_type": get_node_type(node.universal_id),
|
|
2577
|
+
"http.route": event.route.id || "unknown"
|
|
2578
|
+
},
|
|
2579
|
+
fn: async (current2) => {
|
|
2580
|
+
const traced_event = merge_tracing(event, current2);
|
|
2581
|
+
return await with_request_store({
|
|
2582
|
+
event: traced_event,
|
|
2583
|
+
state: event_state
|
|
2584
|
+
}, () => load.call(null, {
|
|
2585
|
+
url: event.url,
|
|
2586
|
+
params: event.params,
|
|
2587
|
+
data: server_data_node?.data ?? null,
|
|
2588
|
+
route: event.route,
|
|
2589
|
+
fetch: create_universal_fetch(event, state, fetched, csr, resolve_opts),
|
|
2590
|
+
setHeaders: event.setHeaders,
|
|
2591
|
+
depends: () => {},
|
|
2592
|
+
parent,
|
|
2593
|
+
untrack: (fn) => fn(),
|
|
2594
|
+
tracing: traced_event.tracing
|
|
2595
|
+
}));
|
|
2596
|
+
}
|
|
2597
|
+
}) ?? null;
|
|
2598
|
+
}
|
|
2599
|
+
function create_universal_fetch(event, state, fetched, csr, resolve_opts) {
|
|
2600
|
+
const universal_fetch = async (input, init2) => {
|
|
2601
|
+
const cloned_body = input instanceof Request && input.body ? input.clone().body : null;
|
|
2602
|
+
const cloned_headers = input instanceof Request && [...input.headers].length ? new Headers(input.headers) : init2?.headers;
|
|
2603
|
+
let response = await event.fetch(input, init2);
|
|
2604
|
+
const url = new URL(input instanceof Request ? input.url : input, event.url);
|
|
2605
|
+
const same_origin = url.origin === event.url.origin;
|
|
2606
|
+
let dependency;
|
|
2607
|
+
if (same_origin) {
|
|
2608
|
+
if (state.prerendering) {
|
|
2609
|
+
dependency = {
|
|
2610
|
+
response,
|
|
2611
|
+
body: null
|
|
2612
|
+
};
|
|
2613
|
+
state.prerendering.dependencies.set(url.pathname, dependency);
|
|
2614
|
+
}
|
|
2615
|
+
} else if (url.protocol === "https:" || url.protocol === "http:") if ((input instanceof Request ? input.mode : init2?.mode ?? "cors") === "no-cors") response = new Response("", {
|
|
2616
|
+
status: response.status,
|
|
2617
|
+
statusText: response.statusText,
|
|
2618
|
+
headers: response.headers
|
|
2619
|
+
});
|
|
2620
|
+
else {
|
|
2621
|
+
const acao = response.headers.get("access-control-allow-origin");
|
|
2622
|
+
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`);
|
|
2623
|
+
}
|
|
2624
|
+
let teed_body;
|
|
2625
|
+
const proxy = new Proxy(response, { get(response2, key2, receiver) {
|
|
2626
|
+
async function push_fetched(body2, is_b64) {
|
|
2627
|
+
const status_number = Number(response2.status);
|
|
2628
|
+
if (isNaN(status_number)) throw new Error(`response.status is not a number. value: "${response2.status}" type: ${typeof response2.status}`);
|
|
2629
|
+
fetched.push({
|
|
2630
|
+
url: same_origin ? url.href.slice(event.url.origin.length) : url.href,
|
|
2631
|
+
method: event.request.method,
|
|
2632
|
+
request_body: input instanceof Request && cloned_body ? await stream_to_string(cloned_body) : init2?.body,
|
|
2633
|
+
request_headers: cloned_headers,
|
|
2634
|
+
response_body: body2,
|
|
2635
|
+
response: response2,
|
|
2636
|
+
is_b64
|
|
2637
|
+
});
|
|
2638
|
+
}
|
|
2639
|
+
if (key2 === "body") {
|
|
2640
|
+
if (response2.body === null) return null;
|
|
2641
|
+
if (teed_body) return teed_body;
|
|
2642
|
+
const [a, b] = response2.body.tee();
|
|
2643
|
+
(async () => {
|
|
2644
|
+
let result = new Uint8Array();
|
|
2645
|
+
for await (const chunk of a) {
|
|
2646
|
+
const combined = new Uint8Array(result.length + chunk.length);
|
|
2647
|
+
combined.set(result, 0);
|
|
2648
|
+
combined.set(chunk, result.length);
|
|
2649
|
+
result = combined;
|
|
2650
|
+
}
|
|
2651
|
+
if (dependency) dependency.body = new Uint8Array(result);
|
|
2652
|
+
push_fetched(base64_encode(result), true);
|
|
2653
|
+
})();
|
|
2654
|
+
return teed_body = b;
|
|
2655
|
+
}
|
|
2656
|
+
if (key2 === "arrayBuffer") return async () => {
|
|
2657
|
+
const buffer = await response2.arrayBuffer();
|
|
2658
|
+
const bytes = new Uint8Array(buffer);
|
|
2659
|
+
if (dependency) dependency.body = bytes;
|
|
2660
|
+
if (buffer instanceof ArrayBuffer) await push_fetched(base64_encode(bytes), true);
|
|
2661
|
+
return buffer;
|
|
2662
|
+
};
|
|
2663
|
+
async function text2() {
|
|
2664
|
+
const body2 = await response2.text();
|
|
2665
|
+
if (body2 === "" && NULL_BODY_STATUS.includes(response2.status)) {
|
|
2666
|
+
await push_fetched(void 0, false);
|
|
2667
|
+
return;
|
|
2668
|
+
}
|
|
2669
|
+
if (!body2 || typeof body2 === "string") await push_fetched(body2, false);
|
|
2670
|
+
if (dependency) dependency.body = body2;
|
|
2671
|
+
return body2;
|
|
2672
|
+
}
|
|
2673
|
+
if (key2 === "text") return text2;
|
|
2674
|
+
if (key2 === "json") return async () => {
|
|
2675
|
+
const body2 = await text2();
|
|
2676
|
+
return body2 ? JSON.parse(body2) : void 0;
|
|
2677
|
+
};
|
|
2678
|
+
const value = Reflect.get(response2, key2, response2);
|
|
2679
|
+
if (value instanceof Function) return Object.defineProperties(
|
|
2680
|
+
/**
|
|
2681
|
+
* @this {any}
|
|
2682
|
+
*/
|
|
2683
|
+
function() {
|
|
2684
|
+
return Reflect.apply(value, this === receiver ? response2 : this, arguments);
|
|
2685
|
+
},
|
|
2686
|
+
{
|
|
2687
|
+
name: { value: value.name },
|
|
2688
|
+
length: { value: value.length }
|
|
2689
|
+
}
|
|
2690
|
+
);
|
|
2691
|
+
return value;
|
|
2692
|
+
} });
|
|
2693
|
+
if (csr) {
|
|
2694
|
+
const get = response.headers.get;
|
|
2695
|
+
response.headers.get = (key2) => {
|
|
2696
|
+
const lower = key2.toLowerCase();
|
|
2697
|
+
const value = get.call(response.headers, lower);
|
|
2698
|
+
if (value && !lower.startsWith("x-sveltekit-")) {
|
|
2699
|
+
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})`);
|
|
2700
|
+
}
|
|
2701
|
+
return value;
|
|
2702
|
+
};
|
|
2703
|
+
}
|
|
2704
|
+
return proxy;
|
|
2705
|
+
};
|
|
2706
|
+
return (input, init2) => {
|
|
2707
|
+
const response = universal_fetch(input, init2);
|
|
2708
|
+
response.catch(() => {});
|
|
2709
|
+
return response;
|
|
2710
|
+
};
|
|
2711
|
+
}
|
|
2712
|
+
async function stream_to_string(stream) {
|
|
2713
|
+
let result = "";
|
|
2714
|
+
const reader = stream.getReader();
|
|
2715
|
+
while (true) {
|
|
2716
|
+
const { done, value } = await reader.read();
|
|
2717
|
+
if (done) break;
|
|
2718
|
+
result += text_decoder.decode(value);
|
|
2719
|
+
}
|
|
2720
|
+
return result;
|
|
2721
|
+
}
|
|
2722
|
+
function hash(...values) {
|
|
2723
|
+
let hash2 = 5381;
|
|
2724
|
+
for (const value of values) if (typeof value === "string") {
|
|
2725
|
+
let i = value.length;
|
|
2726
|
+
while (i) hash2 = hash2 * 33 ^ value.charCodeAt(--i);
|
|
2727
|
+
} else if (ArrayBuffer.isView(value)) {
|
|
2728
|
+
const buffer = new Uint8Array(value.buffer, value.byteOffset, value.byteLength);
|
|
2729
|
+
let i = buffer.length;
|
|
2730
|
+
while (i) hash2 = hash2 * 33 ^ buffer[--i];
|
|
2731
|
+
} else throw new TypeError("value must be a string or TypedArray");
|
|
2732
|
+
return (hash2 >>> 0).toString(36);
|
|
2733
|
+
}
|
|
2734
|
+
const replacements = {
|
|
2735
|
+
"<": "\\u003C",
|
|
2736
|
+
"\u2028": "\\u2028",
|
|
2737
|
+
"\u2029": "\\u2029"
|
|
2738
|
+
};
|
|
2739
|
+
const pattern = new RegExp(`[${Object.keys(replacements).join("")}]`, "g");
|
|
2740
|
+
function serialize_data(fetched, filter, prerendering = false) {
|
|
2741
|
+
const headers2 = {};
|
|
2742
|
+
let cache_control = null;
|
|
2743
|
+
let age = null;
|
|
2744
|
+
let varyAny = false;
|
|
2745
|
+
for (const [key2, value] of fetched.response.headers) {
|
|
2746
|
+
if (filter(key2, value)) headers2[key2] = value;
|
|
2747
|
+
if (key2 === "cache-control") cache_control = value;
|
|
2748
|
+
else if (key2 === "age") age = value;
|
|
2749
|
+
else if (key2 === "vary" && value.trim() === "*") varyAny = true;
|
|
2750
|
+
}
|
|
2751
|
+
const payload = {
|
|
2752
|
+
status: fetched.response.status,
|
|
2753
|
+
statusText: fetched.response.statusText,
|
|
2754
|
+
headers: headers2,
|
|
2755
|
+
body: fetched.response_body
|
|
2756
|
+
};
|
|
2757
|
+
const safe_payload = JSON.stringify(payload).replace(pattern, (match) => replacements[match]);
|
|
2758
|
+
const attrs = [
|
|
2759
|
+
"type=\"application/json\"",
|
|
2760
|
+
"data-sveltekit-fetched",
|
|
2761
|
+
`data-url="${escape_html(fetched.url, true)}"`
|
|
2762
|
+
];
|
|
2763
|
+
if (fetched.is_b64) attrs.push("data-b64");
|
|
2764
|
+
if (fetched.request_headers || fetched.request_body) {
|
|
2765
|
+
const values = [];
|
|
2766
|
+
if (fetched.request_headers) values.push([...new Headers(fetched.request_headers)].join(","));
|
|
2767
|
+
if (fetched.request_body) values.push(fetched.request_body);
|
|
2768
|
+
attrs.push(`data-hash="${hash(...values)}"`);
|
|
2769
|
+
}
|
|
2770
|
+
if (!prerendering && fetched.method === "GET" && cache_control && !varyAny) {
|
|
2771
|
+
const match = /s-maxage=(\d+)/g.exec(cache_control) ?? /max-age=(\d+)/g.exec(cache_control);
|
|
2772
|
+
if (match) {
|
|
2773
|
+
const ttl = +match[1] - +(age ?? "0");
|
|
2774
|
+
attrs.push(`data-ttl="${ttl}"`);
|
|
2775
|
+
}
|
|
2776
|
+
}
|
|
2777
|
+
return `<script ${attrs.join(" ")}>${safe_payload}<\/script>`;
|
|
2778
|
+
}
|
|
2779
|
+
const s = JSON.stringify;
|
|
2780
|
+
function sha256(data) {
|
|
2781
|
+
if (!key[0]) precompute();
|
|
2782
|
+
const out = init.slice(0);
|
|
2783
|
+
const array2 = encode(data);
|
|
2784
|
+
for (let i = 0; i < array2.length; i += 16) {
|
|
2785
|
+
const w = array2.subarray(i, i + 16);
|
|
2786
|
+
let tmp;
|
|
2787
|
+
let a;
|
|
2788
|
+
let b;
|
|
2789
|
+
let out0 = out[0];
|
|
2790
|
+
let out1 = out[1];
|
|
2791
|
+
let out2 = out[2];
|
|
2792
|
+
let out3 = out[3];
|
|
2793
|
+
let out4 = out[4];
|
|
2794
|
+
let out5 = out[5];
|
|
2795
|
+
let out6 = out[6];
|
|
2796
|
+
let out7 = out[7];
|
|
2797
|
+
for (let i2 = 0; i2 < 64; i2++) {
|
|
2798
|
+
if (i2 < 16) tmp = w[i2];
|
|
2799
|
+
else {
|
|
2800
|
+
a = w[i2 + 1 & 15];
|
|
2801
|
+
b = w[i2 + 14 & 15];
|
|
2802
|
+
tmp = w[i2 & 15] = (a >>> 7 ^ a >>> 18 ^ a >>> 3 ^ a << 25 ^ a << 14) + (b >>> 17 ^ b >>> 19 ^ b >>> 10 ^ b << 15 ^ b << 13) + w[i2 & 15] + w[i2 + 9 & 15] | 0;
|
|
2803
|
+
}
|
|
2804
|
+
tmp = tmp + out7 + (out4 >>> 6 ^ out4 >>> 11 ^ out4 >>> 25 ^ out4 << 26 ^ out4 << 21 ^ out4 << 7) + (out6 ^ out4 & (out5 ^ out6)) + key[i2];
|
|
2805
|
+
out7 = out6;
|
|
2806
|
+
out6 = out5;
|
|
2807
|
+
out5 = out4;
|
|
2808
|
+
out4 = out3 + tmp | 0;
|
|
2809
|
+
out3 = out2;
|
|
2810
|
+
out2 = out1;
|
|
2811
|
+
out1 = out0;
|
|
2812
|
+
out0 = tmp + (out1 & out2 ^ out3 & (out1 ^ out2)) + (out1 >>> 2 ^ out1 >>> 13 ^ out1 >>> 22 ^ out1 << 30 ^ out1 << 19 ^ out1 << 10) | 0;
|
|
2813
|
+
}
|
|
2814
|
+
out[0] = out[0] + out0 | 0;
|
|
2815
|
+
out[1] = out[1] + out1 | 0;
|
|
2816
|
+
out[2] = out[2] + out2 | 0;
|
|
2817
|
+
out[3] = out[3] + out3 | 0;
|
|
2818
|
+
out[4] = out[4] + out4 | 0;
|
|
2819
|
+
out[5] = out[5] + out5 | 0;
|
|
2820
|
+
out[6] = out[6] + out6 | 0;
|
|
2821
|
+
out[7] = out[7] + out7 | 0;
|
|
2822
|
+
}
|
|
2823
|
+
const bytes = new Uint8Array(out.buffer);
|
|
2824
|
+
reverse_endianness(bytes);
|
|
2825
|
+
return btoa(String.fromCharCode(...bytes));
|
|
2826
|
+
}
|
|
2827
|
+
const init = new Uint32Array(8);
|
|
2828
|
+
const key = new Uint32Array(64);
|
|
2829
|
+
function precompute() {
|
|
2830
|
+
function frac(x) {
|
|
2831
|
+
return (x - Math.floor(x)) * 4294967296;
|
|
2832
|
+
}
|
|
2833
|
+
let prime = 2;
|
|
2834
|
+
for (let i = 0; i < 64; prime++) {
|
|
2835
|
+
let is_prime = true;
|
|
2836
|
+
for (let factor = 2; factor * factor <= prime; factor++) if (prime % factor === 0) {
|
|
2837
|
+
is_prime = false;
|
|
2838
|
+
break;
|
|
2839
|
+
}
|
|
2840
|
+
if (is_prime) {
|
|
2841
|
+
if (i < 8) init[i] = frac(prime ** (1 / 2));
|
|
2842
|
+
key[i] = frac(prime ** (1 / 3));
|
|
2843
|
+
i++;
|
|
2844
|
+
}
|
|
2845
|
+
}
|
|
2846
|
+
}
|
|
2847
|
+
function reverse_endianness(bytes) {
|
|
2848
|
+
for (let i = 0; i < bytes.length; i += 4) {
|
|
2849
|
+
const a = bytes[i + 0];
|
|
2850
|
+
const b = bytes[i + 1];
|
|
2851
|
+
const c = bytes[i + 2];
|
|
2852
|
+
const d = bytes[i + 3];
|
|
2853
|
+
bytes[i + 0] = d;
|
|
2854
|
+
bytes[i + 1] = c;
|
|
2855
|
+
bytes[i + 2] = b;
|
|
2856
|
+
bytes[i + 3] = a;
|
|
2857
|
+
}
|
|
2858
|
+
}
|
|
2859
|
+
function encode(str) {
|
|
2860
|
+
const encoded = text_encoder.encode(str);
|
|
2861
|
+
const length = encoded.length * 8;
|
|
2862
|
+
const size = 512 * Math.ceil((length + 65) / 512);
|
|
2863
|
+
const bytes = new Uint8Array(size / 8);
|
|
2864
|
+
bytes.set(encoded);
|
|
2865
|
+
bytes[encoded.length] = 128;
|
|
2866
|
+
reverse_endianness(bytes);
|
|
2867
|
+
const words = new Uint32Array(bytes.buffer);
|
|
2868
|
+
words[words.length - 2] = Math.floor(length / 4294967296);
|
|
2869
|
+
words[words.length - 1] = length;
|
|
2870
|
+
return words;
|
|
2871
|
+
}
|
|
2872
|
+
const array = new Uint8Array(16);
|
|
2873
|
+
function generate_nonce() {
|
|
2874
|
+
crypto.getRandomValues(array);
|
|
2875
|
+
return btoa(String.fromCharCode(...array));
|
|
2876
|
+
}
|
|
2877
|
+
const quoted = /* @__PURE__ */ new Set([
|
|
2878
|
+
"self",
|
|
2879
|
+
"unsafe-eval",
|
|
2880
|
+
"unsafe-hashes",
|
|
2881
|
+
"unsafe-inline",
|
|
2882
|
+
"none",
|
|
2883
|
+
"strict-dynamic",
|
|
2884
|
+
"report-sample",
|
|
2885
|
+
"wasm-unsafe-eval",
|
|
2886
|
+
"script"
|
|
2887
|
+
]);
|
|
2888
|
+
const crypto_pattern = /^(nonce|sha\d\d\d)-/;
|
|
2889
|
+
var BaseProvider = class {
|
|
2890
|
+
/** @type {boolean} */
|
|
2891
|
+
#use_hashes;
|
|
2892
|
+
/** @type {boolean} */
|
|
2893
|
+
#script_needs_csp;
|
|
2894
|
+
/** @type {boolean} */
|
|
2895
|
+
#script_src_needs_csp;
|
|
2896
|
+
/** @type {boolean} */
|
|
2897
|
+
#script_src_elem_needs_csp;
|
|
2898
|
+
/** @type {boolean} */
|
|
2899
|
+
#style_needs_csp;
|
|
2900
|
+
/** @type {boolean} */
|
|
2901
|
+
#style_src_needs_csp;
|
|
2902
|
+
/** @type {boolean} */
|
|
2903
|
+
#style_src_attr_needs_csp;
|
|
2904
|
+
/** @type {boolean} */
|
|
2905
|
+
#style_src_elem_needs_csp;
|
|
2906
|
+
/** @type {import('types').CspDirectives} */
|
|
2907
|
+
#directives;
|
|
2908
|
+
/** @type {import('types').Csp.Source[]} */
|
|
2909
|
+
#script_src;
|
|
2910
|
+
/** @type {import('types').Csp.Source[]} */
|
|
2911
|
+
#script_src_elem;
|
|
2912
|
+
/** @type {import('types').Csp.Source[]} */
|
|
2913
|
+
#style_src;
|
|
2914
|
+
/** @type {import('types').Csp.Source[]} */
|
|
2915
|
+
#style_src_attr;
|
|
2916
|
+
/** @type {import('types').Csp.Source[]} */
|
|
2917
|
+
#style_src_elem;
|
|
2918
|
+
/** @type {string} */
|
|
2919
|
+
#nonce;
|
|
2920
|
+
/**
|
|
2921
|
+
* @param {boolean} use_hashes
|
|
2922
|
+
* @param {import('types').CspDirectives} directives
|
|
2923
|
+
* @param {string} nonce
|
|
2924
|
+
*/
|
|
2925
|
+
constructor(use_hashes, directives, nonce) {
|
|
2926
|
+
this.#use_hashes = use_hashes;
|
|
2927
|
+
this.#directives = directives;
|
|
2928
|
+
const d = this.#directives;
|
|
2929
|
+
this.#script_src = [];
|
|
2930
|
+
this.#script_src_elem = [];
|
|
2931
|
+
this.#style_src = [];
|
|
2932
|
+
this.#style_src_attr = [];
|
|
2933
|
+
this.#style_src_elem = [];
|
|
2934
|
+
const effective_script_src = d["script-src"] || d["default-src"];
|
|
2935
|
+
const script_src_elem = d["script-src-elem"];
|
|
2936
|
+
const effective_style_src = d["style-src"] || d["default-src"];
|
|
2937
|
+
const style_src_attr = d["style-src-attr"];
|
|
2938
|
+
const style_src_elem = d["style-src-elem"];
|
|
2939
|
+
const needs_csp = (directive) => !!directive && !directive.some((value) => value === "unsafe-inline");
|
|
2940
|
+
this.#script_src_needs_csp = needs_csp(effective_script_src);
|
|
2941
|
+
this.#script_src_elem_needs_csp = needs_csp(script_src_elem);
|
|
2942
|
+
this.#style_src_needs_csp = needs_csp(effective_style_src);
|
|
2943
|
+
this.#style_src_attr_needs_csp = needs_csp(style_src_attr);
|
|
2944
|
+
this.#style_src_elem_needs_csp = needs_csp(style_src_elem);
|
|
2945
|
+
this.#script_needs_csp = this.#script_src_needs_csp || this.#script_src_elem_needs_csp;
|
|
2946
|
+
this.#style_needs_csp = this.#style_src_needs_csp || this.#style_src_attr_needs_csp || this.#style_src_elem_needs_csp;
|
|
2947
|
+
this.script_needs_nonce = this.#script_needs_csp && !this.#use_hashes;
|
|
2948
|
+
this.style_needs_nonce = this.#style_needs_csp && !this.#use_hashes;
|
|
2949
|
+
this.#nonce = nonce;
|
|
2950
|
+
}
|
|
2951
|
+
/** @param {string} content */
|
|
2952
|
+
add_script(content) {
|
|
2953
|
+
if (!this.#script_needs_csp) return;
|
|
2954
|
+
const source = this.#use_hashes ? `sha256-${sha256(content)}` : `nonce-${this.#nonce}`;
|
|
2955
|
+
if (this.#script_src_needs_csp) this.#script_src.push(source);
|
|
2956
|
+
if (this.#script_src_elem_needs_csp) this.#script_src_elem.push(source);
|
|
2957
|
+
}
|
|
2958
|
+
/** @param {string} content */
|
|
2959
|
+
add_style(content) {
|
|
2960
|
+
if (!this.#style_needs_csp) return;
|
|
2961
|
+
const source = this.#use_hashes ? `sha256-${sha256(content)}` : `nonce-${this.#nonce}`;
|
|
2962
|
+
if (this.#style_src_needs_csp) this.#style_src.push(source);
|
|
2963
|
+
if (this.#style_src_attr_needs_csp) this.#style_src_attr.push(source);
|
|
2964
|
+
if (this.#style_src_elem_needs_csp) {
|
|
2965
|
+
const sha256_empty_comment_hash = "sha256-9OlNO0DNEeaVzHL4RZwCLsBHA8WBQ8toBp/4F5XV2nc=";
|
|
2966
|
+
const d = this.#directives;
|
|
2967
|
+
if (d["style-src-elem"] && !d["style-src-elem"].includes(sha256_empty_comment_hash) && !this.#style_src_elem.includes(sha256_empty_comment_hash)) this.#style_src_elem.push(sha256_empty_comment_hash);
|
|
2968
|
+
if (source !== sha256_empty_comment_hash) this.#style_src_elem.push(source);
|
|
2969
|
+
}
|
|
2970
|
+
}
|
|
2971
|
+
/**
|
|
2972
|
+
* @param {boolean} [is_meta]
|
|
2973
|
+
*/
|
|
2974
|
+
get_header(is_meta = false) {
|
|
2975
|
+
const header = [];
|
|
2976
|
+
const directives = { ...this.#directives };
|
|
2977
|
+
if (this.#style_src.length > 0) directives["style-src"] = [...directives["style-src"] || directives["default-src"] || [], ...this.#style_src];
|
|
2978
|
+
if (this.#style_src_attr.length > 0) directives["style-src-attr"] = [...directives["style-src-attr"] || [], ...this.#style_src_attr];
|
|
2979
|
+
if (this.#style_src_elem.length > 0) directives["style-src-elem"] = [...directives["style-src-elem"] || [], ...this.#style_src_elem];
|
|
2980
|
+
if (this.#script_src.length > 0) directives["script-src"] = [...directives["script-src"] || directives["default-src"] || [], ...this.#script_src];
|
|
2981
|
+
if (this.#script_src_elem.length > 0) directives["script-src-elem"] = [...directives["script-src-elem"] || [], ...this.#script_src_elem];
|
|
2982
|
+
for (const key2 in directives) {
|
|
2983
|
+
if (is_meta && (key2 === "frame-ancestors" || key2 === "report-uri" || key2 === "sandbox")) continue;
|
|
2984
|
+
const value = directives[key2];
|
|
2985
|
+
if (!value) continue;
|
|
2986
|
+
const directive = [key2];
|
|
2987
|
+
if (Array.isArray(value)) value.forEach((value2) => {
|
|
2988
|
+
if (quoted.has(value2) || crypto_pattern.test(value2)) directive.push(`'${value2}'`);
|
|
2989
|
+
else directive.push(value2);
|
|
2990
|
+
});
|
|
2991
|
+
header.push(directive.join(" "));
|
|
2992
|
+
}
|
|
2993
|
+
return header.join("; ");
|
|
2994
|
+
}
|
|
2995
|
+
};
|
|
2996
|
+
var CspProvider = class extends BaseProvider {
|
|
2997
|
+
get_meta() {
|
|
2998
|
+
const content = this.get_header(true);
|
|
2999
|
+
if (!content) return;
|
|
3000
|
+
return `<meta http-equiv="content-security-policy" content="${escape_html(content, true)}">`;
|
|
3001
|
+
}
|
|
3002
|
+
};
|
|
3003
|
+
var CspReportOnlyProvider = class extends BaseProvider {
|
|
3004
|
+
/**
|
|
3005
|
+
* @param {boolean} use_hashes
|
|
3006
|
+
* @param {import('types').CspDirectives} directives
|
|
3007
|
+
* @param {string} nonce
|
|
3008
|
+
*/
|
|
3009
|
+
constructor(use_hashes, directives, nonce) {
|
|
3010
|
+
super(use_hashes, directives, nonce);
|
|
3011
|
+
if (Object.values(directives).filter((v) => !!v).length > 0) {
|
|
3012
|
+
const has_report_to = directives["report-to"]?.length ?? false;
|
|
3013
|
+
const has_report_uri = directives["report-uri"]?.length ?? false;
|
|
3014
|
+
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");
|
|
3015
|
+
}
|
|
3016
|
+
}
|
|
3017
|
+
};
|
|
3018
|
+
var Csp = class {
|
|
3019
|
+
/** @readonly */
|
|
3020
|
+
nonce = generate_nonce();
|
|
3021
|
+
/** @type {CspProvider} */
|
|
3022
|
+
csp_provider;
|
|
3023
|
+
/** @type {CspReportOnlyProvider} */
|
|
3024
|
+
report_only_provider;
|
|
3025
|
+
/**
|
|
3026
|
+
* @param {import('./types.js').CspConfig} config
|
|
3027
|
+
* @param {import('./types.js').CspOpts} opts
|
|
3028
|
+
*/
|
|
3029
|
+
constructor({ mode, directives, reportOnly }, { prerender }) {
|
|
3030
|
+
const use_hashes = mode === "hash" || mode === "auto" && prerender;
|
|
3031
|
+
this.csp_provider = new CspProvider(use_hashes, directives, this.nonce);
|
|
3032
|
+
this.report_only_provider = new CspReportOnlyProvider(use_hashes, reportOnly, this.nonce);
|
|
3033
|
+
}
|
|
3034
|
+
get script_needs_nonce() {
|
|
3035
|
+
return this.csp_provider.script_needs_nonce || this.report_only_provider.script_needs_nonce;
|
|
3036
|
+
}
|
|
3037
|
+
get style_needs_nonce() {
|
|
3038
|
+
return this.csp_provider.style_needs_nonce || this.report_only_provider.style_needs_nonce;
|
|
3039
|
+
}
|
|
3040
|
+
/** @param {string} content */
|
|
3041
|
+
add_script(content) {
|
|
3042
|
+
this.csp_provider.add_script(content);
|
|
3043
|
+
this.report_only_provider.add_script(content);
|
|
3044
|
+
}
|
|
3045
|
+
/** @param {string} content */
|
|
3046
|
+
add_style(content) {
|
|
3047
|
+
this.csp_provider.add_style(content);
|
|
3048
|
+
this.report_only_provider.add_style(content);
|
|
3049
|
+
}
|
|
3050
|
+
};
|
|
3051
|
+
function exec(match, params, matchers) {
|
|
3052
|
+
const result = {};
|
|
3053
|
+
const values = match.slice(1);
|
|
3054
|
+
const values_needing_match = values.filter((value) => value !== void 0);
|
|
3055
|
+
let buffered = 0;
|
|
3056
|
+
for (let i = 0; i < params.length; i += 1) {
|
|
3057
|
+
const param = params[i];
|
|
3058
|
+
let value = values[i - buffered];
|
|
3059
|
+
if (param.chained && param.rest && buffered) {
|
|
3060
|
+
value = values.slice(i - buffered, i + 1).filter((s2) => s2).join("/");
|
|
3061
|
+
buffered = 0;
|
|
3062
|
+
}
|
|
3063
|
+
if (value === void 0) {
|
|
3064
|
+
if (param.rest) result[param.name] = "";
|
|
3065
|
+
continue;
|
|
3066
|
+
}
|
|
3067
|
+
if (!param.matcher || matchers[param.matcher](value)) {
|
|
3068
|
+
result[param.name] = value;
|
|
3069
|
+
const next_param = params[i + 1];
|
|
3070
|
+
const next_value = values[i + 1];
|
|
3071
|
+
if (next_param && !next_param.rest && next_param.optional && next_value && param.chained) buffered = 0;
|
|
3072
|
+
if (!next_param && !next_value && Object.keys(result).length === values_needing_match.length) buffered = 0;
|
|
3073
|
+
continue;
|
|
3074
|
+
}
|
|
3075
|
+
if (param.optional && param.chained) {
|
|
3076
|
+
buffered++;
|
|
3077
|
+
continue;
|
|
3078
|
+
}
|
|
3079
|
+
return;
|
|
3080
|
+
}
|
|
3081
|
+
if (buffered) return;
|
|
3082
|
+
return result;
|
|
3083
|
+
}
|
|
3084
|
+
function generate_route_object(route, url, manifest) {
|
|
3085
|
+
const { errors, layouts, leaf } = route;
|
|
3086
|
+
const nodes = [
|
|
3087
|
+
...errors,
|
|
3088
|
+
...layouts.map((l) => l?.[1]),
|
|
3089
|
+
leaf[1]
|
|
3090
|
+
].filter((n) => typeof n === "number").map((n) => `'${n}': () => ${create_client_import(manifest._.client.nodes?.[n], url)}`).join(",\n ");
|
|
3091
|
+
return [
|
|
3092
|
+
`{
|
|
3093
|
+
id: ${s(route.id)}`,
|
|
3094
|
+
`errors: ${s(route.errors)}`,
|
|
3095
|
+
`layouts: ${s(route.layouts)}`,
|
|
3096
|
+
`leaf: ${s(route.leaf)}`,
|
|
3097
|
+
`nodes: {
|
|
3098
|
+
${nodes}
|
|
3099
|
+
}
|
|
3100
|
+
}`
|
|
3101
|
+
].join(",\n ");
|
|
3102
|
+
}
|
|
3103
|
+
function create_client_import(import_path, url) {
|
|
3104
|
+
if (!import_path) return "Promise.resolve({})";
|
|
3105
|
+
if (import_path[0] === "/") return `import('${import_path}')`;
|
|
3106
|
+
if (assets !== "") return `import('${assets}/${import_path}')`;
|
|
3107
|
+
let path = get_relative_path(url.pathname, `${base}/${import_path}`);
|
|
3108
|
+
if (path[0] !== ".") path = `./${path}`;
|
|
3109
|
+
return `import('${path}')`;
|
|
3110
|
+
}
|
|
3111
|
+
async function resolve_route(resolved_path, url, manifest) {
|
|
3112
|
+
if (!manifest._.client.routes) return text("Server-side route resolution disabled", { status: 400 });
|
|
3113
|
+
let route = null;
|
|
3114
|
+
let params = {};
|
|
3115
|
+
const matchers = await manifest._.matchers();
|
|
3116
|
+
for (const candidate of manifest._.client.routes) {
|
|
3117
|
+
const match = candidate.pattern.exec(resolved_path);
|
|
3118
|
+
if (!match) continue;
|
|
3119
|
+
const matched = exec(match, candidate.params, matchers);
|
|
3120
|
+
if (matched) {
|
|
3121
|
+
route = candidate;
|
|
3122
|
+
params = decode_params(matched);
|
|
3123
|
+
break;
|
|
3124
|
+
}
|
|
3125
|
+
}
|
|
3126
|
+
return create_server_routing_response(route, params, url, manifest).response;
|
|
3127
|
+
}
|
|
3128
|
+
function create_server_routing_response(route, params, url, manifest) {
|
|
3129
|
+
const headers2 = new Headers({ "content-type": "application/javascript; charset=utf-8" });
|
|
3130
|
+
if (route) {
|
|
3131
|
+
const csr_route = generate_route_object(route, url, manifest);
|
|
3132
|
+
const body2 = `${create_css_import(route, url, manifest)}
|
|
3133
|
+
export const route = ${csr_route}; export const params = ${JSON.stringify(params)};`;
|
|
3134
|
+
return {
|
|
3135
|
+
response: text(body2, { headers: headers2 }),
|
|
3136
|
+
body: body2
|
|
3137
|
+
};
|
|
3138
|
+
} else return {
|
|
3139
|
+
response: text("", { headers: headers2 }),
|
|
3140
|
+
body: ""
|
|
3141
|
+
};
|
|
3142
|
+
}
|
|
3143
|
+
function create_css_import(route, url, manifest) {
|
|
3144
|
+
const { errors, layouts, leaf } = route;
|
|
3145
|
+
let css = "";
|
|
3146
|
+
for (const node of [
|
|
3147
|
+
...errors,
|
|
3148
|
+
...layouts.map((l) => l?.[1]),
|
|
3149
|
+
leaf[1]
|
|
3150
|
+
]) {
|
|
3151
|
+
if (typeof node !== "number") continue;
|
|
3152
|
+
const node_css = manifest._.client.css?.[node];
|
|
3153
|
+
for (const css_path of node_css ?? []) css += `'${assets || base}/${css_path}',`;
|
|
3154
|
+
}
|
|
3155
|
+
if (!css) return "";
|
|
3156
|
+
return `${create_client_import(
|
|
3157
|
+
/** @type {string} */
|
|
3158
|
+
manifest._.client.start,
|
|
3159
|
+
url
|
|
3160
|
+
)}.then(x => x.load_css([${css}]));`;
|
|
3161
|
+
}
|
|
3162
|
+
const updated = {
|
|
3163
|
+
...readable(false),
|
|
3164
|
+
check: () => false
|
|
3165
|
+
};
|
|
3166
|
+
async function render_response({ branch, fetched, options: options2, manifest, state, page_config, status, error: error2 = null, event, event_state, resolve_opts, action_result, data_serializer }) {
|
|
3167
|
+
if (state.prerendering) {
|
|
3168
|
+
if (options2.csp.mode === "nonce") throw new Error("Cannot use prerendering if config.kit.csp.mode === \"nonce\"");
|
|
3169
|
+
if (options2.app_template_contains_nonce) throw new Error("Cannot use prerendering if page template contains %sveltekit.nonce%");
|
|
3170
|
+
}
|
|
3171
|
+
const { client } = manifest._;
|
|
3172
|
+
const modulepreloads = new Set(client.imports);
|
|
3173
|
+
const stylesheets = new Set(client.stylesheets);
|
|
3174
|
+
const fonts = new Set(client.fonts);
|
|
3175
|
+
const link_headers = /* @__PURE__ */ new Set();
|
|
3176
|
+
const link_tags = /* @__PURE__ */ new Set();
|
|
3177
|
+
const inline_styles = /* @__PURE__ */ new Map();
|
|
3178
|
+
let rendered;
|
|
3179
|
+
const form_value = action_result?.type === "success" || action_result?.type === "failure" ? action_result.data ?? null : null;
|
|
3180
|
+
let base$1 = base;
|
|
3181
|
+
let assets$1 = assets;
|
|
3182
|
+
let base_expression = s(base);
|
|
3183
|
+
if (!state.prerendering?.fallback) {
|
|
3184
|
+
base$1 = event.url.pathname.slice(base.length).split("/").slice(2).map(() => "..").join("/") || ".";
|
|
3185
|
+
base_expression = `new URL(${s(base$1)}, location).pathname.slice(0, -1)`;
|
|
3186
|
+
if (!assets || assets[0] === "/" && assets !== SVELTE_KIT_ASSETS) assets$1 = base$1;
|
|
3187
|
+
} else if (options2.hash_routing) base_expression = "new URL('.', location).pathname.slice(0, -1)";
|
|
3188
|
+
if (page_config.ssr) {
|
|
3189
|
+
const props = {
|
|
3190
|
+
stores: {
|
|
3191
|
+
page: writable(null),
|
|
3192
|
+
navigating: writable(null),
|
|
3193
|
+
updated
|
|
3194
|
+
},
|
|
3195
|
+
constructors: await Promise.all(branch.map(({ node }) => {
|
|
3196
|
+
if (!node.component) throw new Error(`Missing +page.svelte component for route ${event.route.id}`);
|
|
3197
|
+
return node.component();
|
|
3198
|
+
})),
|
|
3199
|
+
form: form_value
|
|
3200
|
+
};
|
|
3201
|
+
let data2 = {};
|
|
3202
|
+
for (let i = 0; i < branch.length; i += 1) {
|
|
3203
|
+
data2 = {
|
|
3204
|
+
...data2,
|
|
3205
|
+
...branch[i].data
|
|
3206
|
+
};
|
|
3207
|
+
props[`data_${i}`] = data2;
|
|
3208
|
+
}
|
|
3209
|
+
props.page = {
|
|
3210
|
+
error: error2,
|
|
3211
|
+
params: event.params,
|
|
3212
|
+
route: event.route,
|
|
3213
|
+
status,
|
|
3214
|
+
url: event.url,
|
|
3215
|
+
data: data2,
|
|
3216
|
+
form: form_value,
|
|
3217
|
+
state: {}
|
|
3218
|
+
};
|
|
3219
|
+
const render_opts = { context: /* @__PURE__ */ new Map([["__request__", { page: props.page }]]) };
|
|
3220
|
+
globalThis.fetch;
|
|
3221
|
+
try {
|
|
3222
|
+
if (BROWSER);
|
|
3223
|
+
rendered = await with_request_store({
|
|
3224
|
+
event,
|
|
3225
|
+
state: event_state
|
|
3226
|
+
}, async () => {
|
|
3227
|
+
if (relative) override({
|
|
3228
|
+
base: base$1,
|
|
3229
|
+
assets: assets$1
|
|
3230
|
+
});
|
|
3231
|
+
const maybe_promise = options2.root.render(props, render_opts);
|
|
3232
|
+
const rendered2 = options2.async && "then" in maybe_promise ? maybe_promise.then((r) => r) : maybe_promise;
|
|
3233
|
+
if (options2.async) reset();
|
|
3234
|
+
const { head: head2, html: html2, css } = options2.async ? await rendered2 : rendered2;
|
|
3235
|
+
return {
|
|
3236
|
+
head: head2,
|
|
3237
|
+
html: html2,
|
|
3238
|
+
css
|
|
3239
|
+
};
|
|
3240
|
+
});
|
|
3241
|
+
} finally {
|
|
3242
|
+
reset();
|
|
3243
|
+
}
|
|
3244
|
+
for (const { node } of branch) {
|
|
3245
|
+
for (const url of node.imports) modulepreloads.add(url);
|
|
3246
|
+
for (const url of node.stylesheets) stylesheets.add(url);
|
|
3247
|
+
for (const url of node.fonts) fonts.add(url);
|
|
3248
|
+
if (node.inline_styles && !client.inline) Object.entries(await node.inline_styles()).forEach(([k, v]) => inline_styles.set(k, v));
|
|
3249
|
+
}
|
|
3250
|
+
} else rendered = {
|
|
3251
|
+
head: "",
|
|
3252
|
+
html: "",
|
|
3253
|
+
css: {
|
|
3254
|
+
code: "",
|
|
3255
|
+
map: null
|
|
3256
|
+
}
|
|
3257
|
+
};
|
|
3258
|
+
let head = "";
|
|
3259
|
+
let body2 = rendered.html;
|
|
3260
|
+
const csp = new Csp(options2.csp, { prerender: !!state.prerendering });
|
|
3261
|
+
const prefixed = (path) => {
|
|
3262
|
+
if (path.startsWith("/")) return base + path;
|
|
3263
|
+
return `${assets$1}/${path}`;
|
|
3264
|
+
};
|
|
3265
|
+
const style = client.inline ? client.inline?.style : Array.from(inline_styles.values()).join("\n");
|
|
3266
|
+
if (style) {
|
|
3267
|
+
const attributes = [];
|
|
3268
|
+
if (csp.style_needs_nonce) attributes.push(` nonce="${csp.nonce}"`);
|
|
3269
|
+
csp.add_style(style);
|
|
3270
|
+
head += `
|
|
3271
|
+
<style${attributes.join("")}>${style}</style>`;
|
|
3272
|
+
}
|
|
3273
|
+
for (const dep of stylesheets) {
|
|
3274
|
+
const path = prefixed(dep);
|
|
3275
|
+
const attributes = ["rel=\"stylesheet\""];
|
|
3276
|
+
if (inline_styles.has(dep)) attributes.push("disabled", "media=\"(max-width: 0)\"");
|
|
3277
|
+
else if (resolve_opts.preload({
|
|
3278
|
+
type: "css",
|
|
3279
|
+
path
|
|
3280
|
+
})) link_headers.add(`<${encodeURI(path)}>; rel="preload"; as="style"; nopush`);
|
|
3281
|
+
head += `
|
|
3282
|
+
<link href="${path}" ${attributes.join(" ")}>`;
|
|
3283
|
+
}
|
|
3284
|
+
for (const dep of fonts) {
|
|
3285
|
+
const path = prefixed(dep);
|
|
3286
|
+
if (resolve_opts.preload({
|
|
3287
|
+
type: "font",
|
|
3288
|
+
path
|
|
3289
|
+
})) {
|
|
3290
|
+
const ext = dep.slice(dep.lastIndexOf(".") + 1);
|
|
3291
|
+
link_tags.add(`<link rel="preload" as="font" type="font/${ext}" href="${path}" crossorigin>`);
|
|
3292
|
+
link_headers.add(`<${encodeURI(path)}>; rel="preload"; as="font"; type="font/${ext}"; crossorigin; nopush`);
|
|
3293
|
+
}
|
|
3294
|
+
}
|
|
3295
|
+
const global = get_global_name(options2);
|
|
3296
|
+
const { data, chunks } = data_serializer.get_data(csp);
|
|
3297
|
+
if (page_config.ssr && page_config.csr) body2 += `
|
|
3298
|
+
${fetched.map((item) => serialize_data(item, resolve_opts.filterSerializedResponseHeaders, !!state.prerendering)).join("\n ")}`;
|
|
3299
|
+
if (page_config.csr) {
|
|
3300
|
+
const route = manifest._.client.routes?.find((r) => r.id === event.route.id) ?? null;
|
|
3301
|
+
if (client.uses_env_dynamic_public && state.prerendering) modulepreloads.add(`${app_dir}/env.js`);
|
|
3302
|
+
if (!client.inline) {
|
|
3303
|
+
const included_modulepreloads = Array.from(modulepreloads, (dep) => prefixed(dep)).filter((path) => resolve_opts.preload({
|
|
3304
|
+
type: "js",
|
|
3305
|
+
path
|
|
3306
|
+
}));
|
|
3307
|
+
for (const path of included_modulepreloads) {
|
|
3308
|
+
link_headers.add(`<${encodeURI(path)}>; rel="modulepreload"; nopush`);
|
|
3309
|
+
if (options2.preload_strategy !== "modulepreload") head += `
|
|
3310
|
+
<link rel="preload" as="script" crossorigin="anonymous" href="${path}">`;
|
|
3311
|
+
else link_tags.add(`<link rel="modulepreload" href="${path}">`);
|
|
3312
|
+
}
|
|
3313
|
+
}
|
|
3314
|
+
if (state.prerendering && link_tags.size > 0) head += Array.from(link_tags).map((tag) => `
|
|
3315
|
+
${tag}`).join("");
|
|
3316
|
+
if (manifest._.client.routes && state.prerendering && !state.prerendering.fallback) {
|
|
3317
|
+
const pathname = add_resolution_suffix(event.url.pathname);
|
|
3318
|
+
state.prerendering.dependencies.set(pathname, create_server_routing_response(route, event.params, new URL(pathname, event.url), manifest));
|
|
3319
|
+
}
|
|
3320
|
+
const blocks = [];
|
|
3321
|
+
const load_env_eagerly = client.uses_env_dynamic_public && state.prerendering;
|
|
3322
|
+
const properties = [`base: ${base_expression}`];
|
|
3323
|
+
if (assets) properties.push(`assets: ${s(assets)}`);
|
|
3324
|
+
if (client.uses_env_dynamic_public) properties.push(`env: ${load_env_eagerly ? "null" : s(public_env)}`);
|
|
3325
|
+
if (chunks) {
|
|
3326
|
+
blocks.push("const deferred = new Map();");
|
|
3327
|
+
properties.push(`defer: (id) => new Promise((fulfil, reject) => {
|
|
3328
|
+
deferred.set(id, { fulfil, reject });
|
|
3329
|
+
})`);
|
|
3330
|
+
let app_declaration = "";
|
|
3331
|
+
if (Object.keys(options2.hooks.transport).length > 0) if (client.inline) app_declaration = `const app = __sveltekit_${options2.version_hash}.app.app;`;
|
|
3332
|
+
else if (client.app) app_declaration = `const app = await import(${s(prefixed(client.app))});`;
|
|
3333
|
+
else app_declaration = `const { app } = await import(${s(prefixed(client.start))});`;
|
|
3334
|
+
const prelude = app_declaration ? `${app_declaration}
|
|
3335
|
+
const [data, error] = fn(app);` : `const [data, error] = fn();`;
|
|
3336
|
+
properties.push(`resolve: async (id, fn) => {
|
|
3337
|
+
${prelude}
|
|
3338
|
+
|
|
3339
|
+
const try_to_resolve = () => {
|
|
3340
|
+
if (!deferred.has(id)) {
|
|
3341
|
+
setTimeout(try_to_resolve, 0);
|
|
3342
|
+
return;
|
|
3343
|
+
}
|
|
3344
|
+
const { fulfil, reject } = deferred.get(id);
|
|
3345
|
+
deferred.delete(id);
|
|
3346
|
+
if (error) reject(error);
|
|
3347
|
+
else fulfil(data);
|
|
3348
|
+
}
|
|
3349
|
+
try_to_resolve();
|
|
3350
|
+
}`);
|
|
3351
|
+
}
|
|
3352
|
+
blocks.push(`${global} = {
|
|
3353
|
+
${properties.join(",\n ")}
|
|
3354
|
+
};`);
|
|
3355
|
+
const args = ["element"];
|
|
3356
|
+
blocks.push("const element = document.currentScript.parentElement;");
|
|
3357
|
+
if (page_config.ssr) {
|
|
3358
|
+
const serialized = {
|
|
3359
|
+
form: "null",
|
|
3360
|
+
error: "null"
|
|
3361
|
+
};
|
|
3362
|
+
if (form_value) serialized.form = uneval_action_response(
|
|
3363
|
+
form_value,
|
|
3364
|
+
/** @type {string} */
|
|
3365
|
+
event.route.id,
|
|
3366
|
+
options2.hooks.transport
|
|
3367
|
+
);
|
|
3368
|
+
if (error2) serialized.error = uneval(error2);
|
|
3369
|
+
const hydrate = [
|
|
3370
|
+
`node_ids: [${branch.map(({ node }) => node.index).join(", ")}]`,
|
|
3371
|
+
`data: ${data}`,
|
|
3372
|
+
`form: ${serialized.form}`,
|
|
3373
|
+
`error: ${serialized.error}`
|
|
3374
|
+
];
|
|
3375
|
+
if (status !== 200) hydrate.push(`status: ${status}`);
|
|
3376
|
+
if (manifest._.client.routes) {
|
|
3377
|
+
if (route) {
|
|
3378
|
+
const stringified = generate_route_object(route, event.url, manifest).replaceAll("\n", "\n ");
|
|
3379
|
+
hydrate.push(`params: ${uneval(event.params)}`, `server_route: ${stringified}`);
|
|
3380
|
+
}
|
|
3381
|
+
} else if (options2.embedded) hydrate.push(`params: ${uneval(event.params)}`, `route: ${s(event.route)}`);
|
|
3382
|
+
const indent = " ".repeat(load_env_eagerly ? 7 : 6);
|
|
3383
|
+
args.push(`{
|
|
3384
|
+
${indent} ${hydrate.join(`,
|
|
3385
|
+
${indent} `)}
|
|
3386
|
+
${indent}}`);
|
|
3387
|
+
}
|
|
3388
|
+
const { remote_data: remote_cache } = event_state;
|
|
3389
|
+
let serialized_remote_data = "";
|
|
3390
|
+
if (remote_cache) {
|
|
3391
|
+
const remote = {};
|
|
3392
|
+
for (const [info, cache] of remote_cache) {
|
|
3393
|
+
if (!info.id) continue;
|
|
3394
|
+
for (const key2 in cache) remote[create_remote_key(info.id, key2)] = await cache[key2];
|
|
3395
|
+
}
|
|
3396
|
+
const replacer = (thing) => {
|
|
3397
|
+
for (const key2 in options2.hooks.transport) {
|
|
3398
|
+
const encoded = options2.hooks.transport[key2].encode(thing);
|
|
3399
|
+
if (encoded) return `app.decode('${key2}', ${uneval(encoded, replacer)})`;
|
|
3400
|
+
}
|
|
3401
|
+
};
|
|
3402
|
+
serialized_remote_data = `${global}.data = ${uneval(remote, replacer)};
|
|
3403
|
+
|
|
3404
|
+
`;
|
|
3405
|
+
}
|
|
3406
|
+
const boot = client.inline ? `${client.inline.script}
|
|
3407
|
+
|
|
3408
|
+
${serialized_remote_data}${global}.app.start(${args.join(", ")});` : client.app ? `Promise.all([
|
|
3409
|
+
import(${s(prefixed(client.start))}),
|
|
3410
|
+
import(${s(prefixed(client.app))})
|
|
3411
|
+
]).then(([kit, app]) => {
|
|
3412
|
+
${serialized_remote_data}kit.start(app, ${args.join(", ")});
|
|
3413
|
+
});` : `import(${s(prefixed(client.start))}).then((app) => {
|
|
3414
|
+
${serialized_remote_data}app.start(${args.join(", ")})
|
|
3415
|
+
});`;
|
|
3416
|
+
if (load_env_eagerly) blocks.push(`import(${s(`${base$1}/${app_dir}/env.js`)}).then(({ env }) => {
|
|
3417
|
+
${global}.env = env;
|
|
3418
|
+
|
|
3419
|
+
${boot.replace(/\n/g, "\n ")}
|
|
3420
|
+
});`);
|
|
3421
|
+
else blocks.push(boot);
|
|
3422
|
+
if (options2.service_worker) {
|
|
3423
|
+
let opts = "";
|
|
3424
|
+
if (options2.service_worker_options != null) opts = `, ${s({ ...options2.service_worker_options })}`;
|
|
3425
|
+
blocks.push(`if ('serviceWorker' in navigator) {
|
|
3426
|
+
addEventListener('load', function () {
|
|
3427
|
+
navigator.serviceWorker.register('${prefixed("service-worker.js")}'${opts});
|
|
3428
|
+
});
|
|
3429
|
+
}`);
|
|
3430
|
+
}
|
|
3431
|
+
const init_app = `
|
|
3432
|
+
{
|
|
3433
|
+
${blocks.join("\n\n ")}
|
|
3434
|
+
}
|
|
3435
|
+
`;
|
|
3436
|
+
csp.add_script(init_app);
|
|
3437
|
+
body2 += `
|
|
3438
|
+
<script${csp.script_needs_nonce ? ` nonce="${csp.nonce}"` : ""}>${init_app}<\/script>
|
|
3439
|
+
`;
|
|
3440
|
+
}
|
|
3441
|
+
const headers2 = new Headers({
|
|
3442
|
+
"x-sveltekit-page": "true",
|
|
3443
|
+
"content-type": "text/html"
|
|
3444
|
+
});
|
|
3445
|
+
if (state.prerendering) {
|
|
3446
|
+
const http_equiv = [];
|
|
3447
|
+
const csp_headers = csp.csp_provider.get_meta();
|
|
3448
|
+
if (csp_headers) http_equiv.push(csp_headers);
|
|
3449
|
+
if (state.prerendering.cache) http_equiv.push(`<meta http-equiv="cache-control" content="${state.prerendering.cache}">`);
|
|
3450
|
+
if (http_equiv.length > 0) head = http_equiv.join("\n") + head;
|
|
3451
|
+
} else {
|
|
3452
|
+
const csp_header = csp.csp_provider.get_header();
|
|
3453
|
+
if (csp_header) headers2.set("content-security-policy", csp_header);
|
|
3454
|
+
const report_only_header = csp.report_only_provider.get_header();
|
|
3455
|
+
if (report_only_header) headers2.set("content-security-policy-report-only", report_only_header);
|
|
3456
|
+
if (link_headers.size) headers2.set("link", Array.from(link_headers).join(", "));
|
|
3457
|
+
}
|
|
3458
|
+
head += rendered.head;
|
|
3459
|
+
const html = options2.templates.app({
|
|
3460
|
+
head,
|
|
3461
|
+
body: body2,
|
|
3462
|
+
assets: assets$1,
|
|
3463
|
+
nonce: csp.nonce,
|
|
3464
|
+
env: public_env
|
|
3465
|
+
});
|
|
3466
|
+
const transformed = await resolve_opts.transformPageChunk({
|
|
3467
|
+
html,
|
|
3468
|
+
done: true
|
|
3469
|
+
}) || "";
|
|
3470
|
+
if (!chunks) headers2.set("etag", `"${hash(transformed)}"`);
|
|
3471
|
+
return !chunks ? text(transformed, {
|
|
3472
|
+
status,
|
|
3473
|
+
headers: headers2
|
|
3474
|
+
}) : new Response(new ReadableStream({
|
|
3475
|
+
async start(controller) {
|
|
3476
|
+
controller.enqueue(text_encoder.encode(transformed + "\n"));
|
|
3477
|
+
for await (const chunk of chunks) if (chunk.length) controller.enqueue(text_encoder.encode(chunk));
|
|
3478
|
+
controller.close();
|
|
3479
|
+
},
|
|
3480
|
+
type: "bytes"
|
|
3481
|
+
}), { headers: headers2 });
|
|
3482
|
+
}
|
|
3483
|
+
var PageNodes = class {
|
|
3484
|
+
data;
|
|
3485
|
+
/**
|
|
3486
|
+
* @param {Array<import('types').SSRNode | undefined>} nodes
|
|
3487
|
+
*/
|
|
3488
|
+
constructor(nodes) {
|
|
3489
|
+
this.data = nodes;
|
|
3490
|
+
}
|
|
3491
|
+
layouts() {
|
|
3492
|
+
return this.data.slice(0, -1);
|
|
3493
|
+
}
|
|
3494
|
+
page() {
|
|
3495
|
+
return this.data.at(-1);
|
|
3496
|
+
}
|
|
3497
|
+
validate() {
|
|
3498
|
+
for (const layout of this.layouts()) if (layout) {
|
|
3499
|
+
validate_layout_server_exports(
|
|
3500
|
+
layout.server,
|
|
3501
|
+
/** @type {string} */
|
|
3502
|
+
layout.server_id
|
|
3503
|
+
);
|
|
3504
|
+
validate_layout_exports(
|
|
3505
|
+
layout.universal,
|
|
3506
|
+
/** @type {string} */
|
|
3507
|
+
layout.universal_id
|
|
3508
|
+
);
|
|
3509
|
+
}
|
|
3510
|
+
const page = this.page();
|
|
3511
|
+
if (page) {
|
|
3512
|
+
validate_page_server_exports(
|
|
3513
|
+
page.server,
|
|
3514
|
+
/** @type {string} */
|
|
3515
|
+
page.server_id
|
|
3516
|
+
);
|
|
3517
|
+
validate_page_exports(
|
|
3518
|
+
page.universal,
|
|
3519
|
+
/** @type {string} */
|
|
3520
|
+
page.universal_id
|
|
3521
|
+
);
|
|
3522
|
+
}
|
|
3523
|
+
}
|
|
3524
|
+
/**
|
|
3525
|
+
* @template {'prerender' | 'ssr' | 'csr' | 'trailingSlash'} Option
|
|
3526
|
+
* @param {Option} option
|
|
3527
|
+
* @returns {Value | undefined}
|
|
3528
|
+
*/
|
|
3529
|
+
#get_option(option) {
|
|
3530
|
+
return this.data.reduce(
|
|
3531
|
+
(value, node) => {
|
|
3532
|
+
return node?.universal?.[option] ?? node?.server?.[option] ?? value;
|
|
3533
|
+
},
|
|
3534
|
+
/** @type {Value | undefined} */
|
|
3535
|
+
void 0
|
|
3536
|
+
);
|
|
3537
|
+
}
|
|
3538
|
+
csr() {
|
|
3539
|
+
return this.#get_option("csr") ?? true;
|
|
3540
|
+
}
|
|
3541
|
+
ssr() {
|
|
3542
|
+
return this.#get_option("ssr") ?? true;
|
|
3543
|
+
}
|
|
3544
|
+
prerender() {
|
|
3545
|
+
return this.#get_option("prerender") ?? false;
|
|
3546
|
+
}
|
|
3547
|
+
trailing_slash() {
|
|
3548
|
+
return this.#get_option("trailingSlash") ?? "never";
|
|
3549
|
+
}
|
|
3550
|
+
get_config() {
|
|
3551
|
+
let current2 = {};
|
|
3552
|
+
for (const node of this.data) {
|
|
3553
|
+
if (!node?.universal?.config && !node?.server?.config) continue;
|
|
3554
|
+
current2 = {
|
|
3555
|
+
...current2,
|
|
3556
|
+
...node?.universal?.config,
|
|
3557
|
+
...node?.server?.config
|
|
3558
|
+
};
|
|
3559
|
+
}
|
|
3560
|
+
return Object.keys(current2).length ? current2 : void 0;
|
|
3561
|
+
}
|
|
3562
|
+
should_prerender_data() {
|
|
3563
|
+
return this.data.some((node) => node?.server?.load || node?.server?.trailingSlash !== void 0);
|
|
3564
|
+
}
|
|
3565
|
+
};
|
|
3566
|
+
async function respond_with_error({ event, event_state, options: options2, manifest, state, status, error: error2, resolve_opts }) {
|
|
3567
|
+
if (event.request.headers.get("x-sveltekit-error")) return static_error_page(
|
|
3568
|
+
options2,
|
|
3569
|
+
status,
|
|
3570
|
+
/** @type {Error} */
|
|
3571
|
+
error2.message
|
|
3572
|
+
);
|
|
3573
|
+
const fetched = [];
|
|
3574
|
+
try {
|
|
3575
|
+
const branch = [];
|
|
3576
|
+
const default_layout = await manifest._.nodes[0]();
|
|
3577
|
+
const nodes = new PageNodes([default_layout]);
|
|
3578
|
+
const ssr = nodes.ssr();
|
|
3579
|
+
const csr = nodes.csr();
|
|
3580
|
+
const data_serializer = server_data_serializer(event, event_state, options2);
|
|
3581
|
+
if (ssr) {
|
|
3582
|
+
state.error = true;
|
|
3583
|
+
const server_data_promise = load_server_data({
|
|
3584
|
+
event,
|
|
3585
|
+
event_state,
|
|
3586
|
+
state,
|
|
3587
|
+
node: default_layout,
|
|
3588
|
+
parent: async () => ({})
|
|
3589
|
+
});
|
|
3590
|
+
const server_data = await server_data_promise;
|
|
3591
|
+
data_serializer.add_node(0, server_data);
|
|
3592
|
+
const data = await load_data({
|
|
3593
|
+
event,
|
|
3594
|
+
event_state,
|
|
3595
|
+
fetched,
|
|
3596
|
+
node: default_layout,
|
|
3597
|
+
parent: async () => ({}),
|
|
3598
|
+
resolve_opts,
|
|
3599
|
+
server_data_promise,
|
|
3600
|
+
state,
|
|
3601
|
+
csr
|
|
3602
|
+
});
|
|
3603
|
+
branch.push({
|
|
3604
|
+
node: default_layout,
|
|
3605
|
+
server_data,
|
|
3606
|
+
data
|
|
3607
|
+
}, {
|
|
3608
|
+
node: await manifest._.nodes[1](),
|
|
3609
|
+
data: null,
|
|
3610
|
+
server_data: null
|
|
3611
|
+
});
|
|
3612
|
+
}
|
|
3613
|
+
return await render_response({
|
|
3614
|
+
options: options2,
|
|
3615
|
+
manifest,
|
|
3616
|
+
state,
|
|
3617
|
+
page_config: {
|
|
3618
|
+
ssr,
|
|
3619
|
+
csr
|
|
3620
|
+
},
|
|
3621
|
+
status,
|
|
3622
|
+
error: await handle_error_and_jsonify(event, event_state, options2, error2),
|
|
3623
|
+
branch,
|
|
3624
|
+
fetched,
|
|
3625
|
+
event,
|
|
3626
|
+
event_state,
|
|
3627
|
+
resolve_opts,
|
|
3628
|
+
data_serializer
|
|
3629
|
+
});
|
|
3630
|
+
} catch (e) {
|
|
3631
|
+
if (e instanceof Redirect) return redirect_response(e.status, e.location);
|
|
3632
|
+
return static_error_page(options2, get_status(e), (await handle_error_and_jsonify(event, event_state, options2, e)).message);
|
|
3633
|
+
}
|
|
3634
|
+
}
|
|
3635
|
+
async function handle_remote_call(event, state, options2, manifest, id) {
|
|
3636
|
+
return record_span({
|
|
3637
|
+
name: "sveltekit.remote.call",
|
|
3638
|
+
attributes: {},
|
|
3639
|
+
fn: (current2) => {
|
|
3640
|
+
const traced_event = merge_tracing(event, current2);
|
|
3641
|
+
return with_request_store({
|
|
3642
|
+
event: traced_event,
|
|
3643
|
+
state
|
|
3644
|
+
}, () => handle_remote_call_internal(traced_event, state, options2, manifest, id));
|
|
3645
|
+
}
|
|
3646
|
+
});
|
|
3647
|
+
}
|
|
3648
|
+
async function handle_remote_call_internal(event, state, options2, manifest, id) {
|
|
3649
|
+
const [hash2, name, additional_args] = id.split("/");
|
|
3650
|
+
const remotes = manifest._.remotes;
|
|
3651
|
+
if (!remotes[hash2]) error(404);
|
|
3652
|
+
const fn = (await remotes[hash2]()).default[name];
|
|
3653
|
+
if (!fn) error(404);
|
|
3654
|
+
const info = fn.__;
|
|
3655
|
+
const transport = options2.hooks.transport;
|
|
3656
|
+
event.tracing.current.setAttributes({
|
|
3657
|
+
"sveltekit.remote.call.type": info.type,
|
|
3658
|
+
"sveltekit.remote.call.name": info.name
|
|
3659
|
+
});
|
|
3660
|
+
let form_client_refreshes;
|
|
3661
|
+
try {
|
|
3662
|
+
if (info.type === "query_batch") {
|
|
3663
|
+
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}`);
|
|
3664
|
+
const { payloads } = await event.request.json();
|
|
3665
|
+
const args = payloads.map((payload2) => parse_remote_arg(payload2, transport));
|
|
3666
|
+
const get_result = await with_request_store({
|
|
3667
|
+
event,
|
|
3668
|
+
state
|
|
3669
|
+
}, () => info.run(args));
|
|
3670
|
+
return json(
|
|
3671
|
+
/** @type {RemoteFunctionResponse} */
|
|
3672
|
+
{
|
|
3673
|
+
type: "result",
|
|
3674
|
+
result: stringify(await Promise.all(args.map(async (arg, i) => {
|
|
3675
|
+
try {
|
|
3676
|
+
return {
|
|
3677
|
+
type: "result",
|
|
3678
|
+
data: get_result(arg, i)
|
|
3679
|
+
};
|
|
3680
|
+
} catch (error2) {
|
|
3681
|
+
return {
|
|
3682
|
+
type: "error",
|
|
3683
|
+
error: await handle_error_and_jsonify(event, state, options2, error2),
|
|
3684
|
+
status: error2 instanceof HttpError || error2 instanceof SvelteKitError ? error2.status : 500
|
|
3685
|
+
};
|
|
3686
|
+
}
|
|
3687
|
+
})), transport)
|
|
3688
|
+
}
|
|
3689
|
+
);
|
|
3690
|
+
}
|
|
3691
|
+
if (info.type === "form") {
|
|
3692
|
+
if (event.request.method !== "POST") throw new SvelteKitError(405, "Method Not Allowed", `\`form\` functions must be invoked via POST request, not ${event.request.method}`);
|
|
3693
|
+
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")}`);
|
|
3694
|
+
const { data: data2, meta, form_data } = await deserialize_binary_form(event.request);
|
|
3695
|
+
if (additional_args && !("id" in data2)) data2.id = JSON.parse(decodeURIComponent(additional_args));
|
|
3696
|
+
const fn2 = info.fn;
|
|
3697
|
+
const result = await with_request_store({
|
|
3698
|
+
event,
|
|
3699
|
+
state
|
|
3700
|
+
}, () => fn2(data2, meta, form_data));
|
|
3701
|
+
return json(
|
|
3702
|
+
/** @type {RemoteFunctionResponse} */
|
|
3703
|
+
{
|
|
3704
|
+
type: "result",
|
|
3705
|
+
result: stringify(result, transport),
|
|
3706
|
+
refreshes: result.issues ? void 0 : await serialize_refreshes(meta.remote_refreshes)
|
|
3707
|
+
}
|
|
3708
|
+
);
|
|
3709
|
+
}
|
|
3710
|
+
if (info.type === "command") {
|
|
3711
|
+
const { payload: payload2, refreshes } = await event.request.json();
|
|
3712
|
+
const arg = parse_remote_arg(payload2, transport);
|
|
3713
|
+
return json(
|
|
3714
|
+
/** @type {RemoteFunctionResponse} */
|
|
3715
|
+
{
|
|
3716
|
+
type: "result",
|
|
3717
|
+
result: stringify(await with_request_store({
|
|
3718
|
+
event,
|
|
3719
|
+
state
|
|
3720
|
+
}, () => fn(arg)), transport),
|
|
3721
|
+
refreshes: await serialize_refreshes(refreshes)
|
|
3722
|
+
}
|
|
3723
|
+
);
|
|
3724
|
+
}
|
|
3725
|
+
const payload = info.type === "prerender" ? additional_args : new URL(event.request.url).searchParams.get("payload");
|
|
3726
|
+
return json(
|
|
3727
|
+
/** @type {RemoteFunctionResponse} */
|
|
3728
|
+
{
|
|
3729
|
+
type: "result",
|
|
3730
|
+
result: stringify(await with_request_store({
|
|
3731
|
+
event,
|
|
3732
|
+
state
|
|
3733
|
+
}, () => fn(parse_remote_arg(payload, transport))), transport)
|
|
3734
|
+
}
|
|
3735
|
+
);
|
|
3736
|
+
} catch (error2) {
|
|
3737
|
+
if (error2 instanceof Redirect) return json(
|
|
3738
|
+
/** @type {RemoteFunctionResponse} */
|
|
3739
|
+
{
|
|
3740
|
+
type: "redirect",
|
|
3741
|
+
location: error2.location,
|
|
3742
|
+
refreshes: await serialize_refreshes(form_client_refreshes)
|
|
3743
|
+
}
|
|
3744
|
+
);
|
|
3745
|
+
const status = error2 instanceof HttpError || error2 instanceof SvelteKitError ? error2.status : 500;
|
|
3746
|
+
return json(
|
|
3747
|
+
/** @type {RemoteFunctionResponse} */
|
|
3748
|
+
{
|
|
3749
|
+
type: "error",
|
|
3750
|
+
error: await handle_error_and_jsonify(event, state, options2, error2),
|
|
3751
|
+
status
|
|
3752
|
+
},
|
|
3753
|
+
{
|
|
3754
|
+
status: state.prerendering ? status : void 0,
|
|
3755
|
+
headers: { "cache-control": "private, no-store" }
|
|
3756
|
+
}
|
|
3757
|
+
);
|
|
3758
|
+
}
|
|
3759
|
+
async function serialize_refreshes(client_refreshes) {
|
|
3760
|
+
const refreshes = state.refreshes ?? {};
|
|
3761
|
+
if (client_refreshes) for (const key2 of client_refreshes) {
|
|
3762
|
+
if (refreshes[key2] !== void 0) continue;
|
|
3763
|
+
const [hash3, name2, payload] = key2.split("/");
|
|
3764
|
+
const loader = manifest._.remotes[hash3];
|
|
3765
|
+
const fn2 = (await loader?.())?.default?.[name2];
|
|
3766
|
+
if (!fn2) error(400, "Bad Request");
|
|
3767
|
+
refreshes[key2] = with_request_store({
|
|
3768
|
+
event,
|
|
3769
|
+
state
|
|
3770
|
+
}, () => fn2(parse_remote_arg(payload, transport)));
|
|
3771
|
+
}
|
|
3772
|
+
if (Object.keys(refreshes).length === 0) return;
|
|
3773
|
+
return stringify(Object.fromEntries(await Promise.all(Object.entries(refreshes).map(async ([key2, promise]) => [key2, await promise]))), transport);
|
|
3774
|
+
}
|
|
3775
|
+
}
|
|
3776
|
+
async function handle_remote_form_post(event, state, manifest, id) {
|
|
3777
|
+
return record_span({
|
|
3778
|
+
name: "sveltekit.remote.form.post",
|
|
3779
|
+
attributes: {},
|
|
3780
|
+
fn: (current2) => {
|
|
3781
|
+
const traced_event = merge_tracing(event, current2);
|
|
3782
|
+
return with_request_store({
|
|
3783
|
+
event: traced_event,
|
|
3784
|
+
state
|
|
3785
|
+
}, () => handle_remote_form_post_internal(traced_event, state, manifest, id));
|
|
3786
|
+
}
|
|
3787
|
+
});
|
|
3788
|
+
}
|
|
3789
|
+
async function handle_remote_form_post_internal(event, state, manifest, id) {
|
|
3790
|
+
const [hash2, name, action_id] = id.split("/");
|
|
3791
|
+
let form = (await manifest._.remotes[hash2]?.())?.default[name];
|
|
3792
|
+
if (!form) {
|
|
3793
|
+
event.setHeaders({ allow: "GET" });
|
|
3794
|
+
return {
|
|
3795
|
+
type: "error",
|
|
3796
|
+
error: new SvelteKitError(405, "Method Not Allowed", `POST method not allowed. No form actions exist for this page`)
|
|
3797
|
+
};
|
|
3798
|
+
}
|
|
3799
|
+
if (action_id) form = with_request_store({
|
|
3800
|
+
event,
|
|
3801
|
+
state
|
|
3802
|
+
}, () => form.for(JSON.parse(action_id)));
|
|
3803
|
+
try {
|
|
3804
|
+
const fn = form.__.fn;
|
|
3805
|
+
const { data, meta, form_data } = await deserialize_binary_form(event.request);
|
|
3806
|
+
if (action_id && !("id" in data)) data.id = JSON.parse(decodeURIComponent(action_id));
|
|
3807
|
+
await with_request_store({
|
|
3808
|
+
event,
|
|
3809
|
+
state
|
|
3810
|
+
}, () => fn(data, meta, form_data));
|
|
3811
|
+
return {
|
|
3812
|
+
type: "success",
|
|
3813
|
+
status: 200
|
|
3814
|
+
};
|
|
3815
|
+
} catch (e) {
|
|
3816
|
+
const err = normalize_error(e);
|
|
3817
|
+
if (err instanceof Redirect) return {
|
|
3818
|
+
type: "redirect",
|
|
3819
|
+
status: err.status,
|
|
3820
|
+
location: err.location
|
|
3821
|
+
};
|
|
3822
|
+
return {
|
|
3823
|
+
type: "error",
|
|
3824
|
+
error: check_incorrect_fail_use(err)
|
|
3825
|
+
};
|
|
3826
|
+
}
|
|
3827
|
+
}
|
|
3828
|
+
function get_remote_id(url) {
|
|
3829
|
+
return url.pathname.startsWith(`${base}/${app_dir}/remote/`) && url.pathname.replace(`${base}/${app_dir}/remote/`, "");
|
|
3830
|
+
}
|
|
3831
|
+
function get_remote_action(url) {
|
|
3832
|
+
return url.searchParams.get("/remote");
|
|
3833
|
+
}
|
|
3834
|
+
const MAX_DEPTH = 10;
|
|
3835
|
+
async function render_page(event, event_state, page, options2, manifest, state, nodes, resolve_opts) {
|
|
3836
|
+
if (state.depth > MAX_DEPTH) return text(`Not found: ${event.url.pathname}`, { status: 404 });
|
|
3837
|
+
if (is_action_json_request(event)) return handle_action_json_request(event, event_state, options2, (await manifest._.nodes[page.leaf]())?.server);
|
|
3838
|
+
try {
|
|
3839
|
+
const leaf_node = nodes.page();
|
|
3840
|
+
let status = 200;
|
|
3841
|
+
let action_result = void 0;
|
|
3842
|
+
if (is_action_request(event)) {
|
|
3843
|
+
const remote_id = get_remote_action(event.url);
|
|
3844
|
+
if (remote_id) action_result = await handle_remote_form_post(event, event_state, manifest, remote_id);
|
|
3845
|
+
else action_result = await handle_action_request(event, event_state, leaf_node.server);
|
|
3846
|
+
if (action_result?.type === "redirect") return redirect_response(action_result.status, action_result.location);
|
|
3847
|
+
if (action_result?.type === "error") status = get_status(action_result.error);
|
|
3848
|
+
if (action_result?.type === "failure") status = action_result.status;
|
|
3849
|
+
}
|
|
3850
|
+
const should_prerender = nodes.prerender();
|
|
3851
|
+
if (should_prerender) {
|
|
3852
|
+
if (leaf_node.server?.actions) throw new Error("Cannot prerender pages with actions");
|
|
3853
|
+
} else if (state.prerendering) return new Response(void 0, { status: 204 });
|
|
3854
|
+
state.prerender_default = should_prerender;
|
|
3855
|
+
const should_prerender_data = nodes.should_prerender_data();
|
|
3856
|
+
const data_pathname = add_data_suffix(event.url.pathname);
|
|
3857
|
+
const fetched = [];
|
|
3858
|
+
const ssr = nodes.ssr();
|
|
3859
|
+
const csr = nodes.csr();
|
|
3860
|
+
if (ssr === false && !(state.prerendering && should_prerender_data)) {
|
|
3861
|
+
if (BROWSER && action_result && !event.request.headers.has("x-sveltekit-action"));
|
|
3862
|
+
return await render_response({
|
|
3863
|
+
branch: [],
|
|
3864
|
+
fetched,
|
|
3865
|
+
page_config: {
|
|
3866
|
+
ssr: false,
|
|
3867
|
+
csr
|
|
3868
|
+
},
|
|
3869
|
+
status,
|
|
3870
|
+
error: null,
|
|
3871
|
+
event,
|
|
3872
|
+
event_state,
|
|
3873
|
+
options: options2,
|
|
3874
|
+
manifest,
|
|
3875
|
+
state,
|
|
3876
|
+
resolve_opts,
|
|
3877
|
+
data_serializer: server_data_serializer(event, event_state, options2)
|
|
3878
|
+
});
|
|
3879
|
+
}
|
|
3880
|
+
const branch = [];
|
|
3881
|
+
let load_error = null;
|
|
3882
|
+
const data_serializer = server_data_serializer(event, event_state, options2);
|
|
3883
|
+
const data_serializer_json = state.prerendering && should_prerender_data ? server_data_serializer_json(event, event_state, options2) : null;
|
|
3884
|
+
const server_promises = nodes.data.map((node, i) => {
|
|
3885
|
+
if (load_error) throw load_error;
|
|
3886
|
+
return Promise.resolve().then(async () => {
|
|
3887
|
+
try {
|
|
3888
|
+
if (node === leaf_node && action_result?.type === "error") throw action_result.error;
|
|
3889
|
+
const server_data = await load_server_data({
|
|
3890
|
+
event,
|
|
3891
|
+
event_state,
|
|
3892
|
+
state,
|
|
3893
|
+
node,
|
|
3894
|
+
parent: async () => {
|
|
3895
|
+
const data = {};
|
|
3896
|
+
for (let j = 0; j < i; j += 1) {
|
|
3897
|
+
const parent = await server_promises[j];
|
|
3898
|
+
if (parent) Object.assign(data, parent.data);
|
|
3899
|
+
}
|
|
3900
|
+
return data;
|
|
3901
|
+
}
|
|
3902
|
+
});
|
|
3903
|
+
if (node) data_serializer.add_node(i, server_data);
|
|
3904
|
+
data_serializer_json?.add_node(i, server_data);
|
|
3905
|
+
return server_data;
|
|
3906
|
+
} catch (e) {
|
|
3907
|
+
load_error = e;
|
|
3908
|
+
throw load_error;
|
|
3909
|
+
}
|
|
3910
|
+
});
|
|
3911
|
+
});
|
|
3912
|
+
const load_promises = nodes.data.map((node, i) => {
|
|
3913
|
+
if (load_error) throw load_error;
|
|
3914
|
+
return Promise.resolve().then(async () => {
|
|
3915
|
+
try {
|
|
3916
|
+
return await load_data({
|
|
3917
|
+
event,
|
|
3918
|
+
event_state,
|
|
3919
|
+
fetched,
|
|
3920
|
+
node,
|
|
3921
|
+
parent: async () => {
|
|
3922
|
+
const data = {};
|
|
3923
|
+
for (let j = 0; j < i; j += 1) Object.assign(data, await load_promises[j]);
|
|
3924
|
+
return data;
|
|
3925
|
+
},
|
|
3926
|
+
resolve_opts,
|
|
3927
|
+
server_data_promise: server_promises[i],
|
|
3928
|
+
state,
|
|
3929
|
+
csr
|
|
3930
|
+
});
|
|
3931
|
+
} catch (e) {
|
|
3932
|
+
load_error = e;
|
|
3933
|
+
throw load_error;
|
|
3934
|
+
}
|
|
3935
|
+
});
|
|
3936
|
+
});
|
|
3937
|
+
for (const p of server_promises) p.catch(() => {});
|
|
3938
|
+
for (const p of load_promises) p.catch(() => {});
|
|
3939
|
+
for (let i = 0; i < nodes.data.length; i += 1) {
|
|
3940
|
+
const node = nodes.data[i];
|
|
3941
|
+
if (node) try {
|
|
3942
|
+
const server_data = await server_promises[i];
|
|
3943
|
+
const data = await load_promises[i];
|
|
3944
|
+
branch.push({
|
|
3945
|
+
node,
|
|
3946
|
+
server_data,
|
|
3947
|
+
data
|
|
3948
|
+
});
|
|
3949
|
+
} catch (e) {
|
|
3950
|
+
const err = normalize_error(e);
|
|
3951
|
+
if (err instanceof Redirect) {
|
|
3952
|
+
if (state.prerendering && should_prerender_data) {
|
|
3953
|
+
const body2 = JSON.stringify({
|
|
3954
|
+
type: "redirect",
|
|
3955
|
+
location: err.location
|
|
3956
|
+
});
|
|
3957
|
+
state.prerendering.dependencies.set(data_pathname, {
|
|
3958
|
+
response: text(body2),
|
|
3959
|
+
body: body2
|
|
3960
|
+
});
|
|
3961
|
+
}
|
|
3962
|
+
return redirect_response(err.status, err.location);
|
|
3963
|
+
}
|
|
3964
|
+
const status2 = get_status(err);
|
|
3965
|
+
const error2 = await handle_error_and_jsonify(event, event_state, options2, err);
|
|
3966
|
+
while (i--) if (page.errors[i]) {
|
|
3967
|
+
const index = page.errors[i];
|
|
3968
|
+
const node2 = await manifest._.nodes[index]();
|
|
3969
|
+
let j = i;
|
|
3970
|
+
while (!branch[j]) j -= 1;
|
|
3971
|
+
data_serializer.set_max_nodes(j + 1);
|
|
3972
|
+
const layouts = compact(branch.slice(0, j + 1));
|
|
3973
|
+
const nodes2 = new PageNodes(layouts.map((layout) => layout.node));
|
|
3974
|
+
return await render_response({
|
|
3975
|
+
event,
|
|
3976
|
+
event_state,
|
|
3977
|
+
options: options2,
|
|
3978
|
+
manifest,
|
|
3979
|
+
state,
|
|
3980
|
+
resolve_opts,
|
|
3981
|
+
page_config: {
|
|
3982
|
+
ssr: nodes2.ssr(),
|
|
3983
|
+
csr: nodes2.csr()
|
|
3984
|
+
},
|
|
3985
|
+
status: status2,
|
|
3986
|
+
error: error2,
|
|
3987
|
+
branch: layouts.concat({
|
|
3988
|
+
node: node2,
|
|
3989
|
+
data: null,
|
|
3990
|
+
server_data: null
|
|
3991
|
+
}),
|
|
3992
|
+
fetched,
|
|
3993
|
+
data_serializer
|
|
3994
|
+
});
|
|
3995
|
+
}
|
|
3996
|
+
return static_error_page(options2, status2, error2.message);
|
|
3997
|
+
}
|
|
3998
|
+
else branch.push(null);
|
|
3999
|
+
}
|
|
4000
|
+
if (state.prerendering && data_serializer_json) {
|
|
4001
|
+
let { data, chunks } = data_serializer_json.get_data();
|
|
4002
|
+
if (chunks) for await (const chunk of chunks) data += chunk;
|
|
4003
|
+
state.prerendering.dependencies.set(data_pathname, {
|
|
4004
|
+
response: text(data),
|
|
4005
|
+
body: data
|
|
4006
|
+
});
|
|
4007
|
+
}
|
|
4008
|
+
return await render_response({
|
|
4009
|
+
event,
|
|
4010
|
+
event_state,
|
|
4011
|
+
options: options2,
|
|
4012
|
+
manifest,
|
|
4013
|
+
state,
|
|
4014
|
+
resolve_opts,
|
|
4015
|
+
page_config: {
|
|
4016
|
+
csr,
|
|
4017
|
+
ssr
|
|
4018
|
+
},
|
|
4019
|
+
status,
|
|
4020
|
+
error: null,
|
|
4021
|
+
branch: ssr === false ? [] : compact(branch),
|
|
4022
|
+
action_result,
|
|
4023
|
+
fetched,
|
|
4024
|
+
data_serializer: ssr === false ? server_data_serializer(event, event_state, options2) : data_serializer
|
|
4025
|
+
});
|
|
4026
|
+
} catch (e) {
|
|
4027
|
+
return await respond_with_error({
|
|
4028
|
+
event,
|
|
4029
|
+
event_state,
|
|
4030
|
+
options: options2,
|
|
4031
|
+
manifest,
|
|
4032
|
+
state,
|
|
4033
|
+
status: 500,
|
|
4034
|
+
error: e,
|
|
4035
|
+
resolve_opts
|
|
4036
|
+
});
|
|
4037
|
+
}
|
|
4038
|
+
}
|
|
4039
|
+
function once(fn) {
|
|
4040
|
+
let done = false;
|
|
4041
|
+
let result;
|
|
4042
|
+
return () => {
|
|
4043
|
+
if (done) return result;
|
|
4044
|
+
done = true;
|
|
4045
|
+
return result = fn();
|
|
4046
|
+
};
|
|
4047
|
+
}
|
|
4048
|
+
async function render_data(event, event_state, route, options2, manifest, state, invalidated_data_nodes, trailing_slash) {
|
|
4049
|
+
if (!route.page) return new Response(void 0, { status: 404 });
|
|
4050
|
+
try {
|
|
4051
|
+
const node_ids = [...route.page.layouts, route.page.leaf];
|
|
4052
|
+
const invalidated = invalidated_data_nodes ?? node_ids.map(() => true);
|
|
4053
|
+
let aborted = false;
|
|
4054
|
+
const url = new URL(event.url);
|
|
4055
|
+
url.pathname = normalize_path(url.pathname, trailing_slash);
|
|
4056
|
+
const new_event = {
|
|
4057
|
+
...event,
|
|
4058
|
+
url
|
|
4059
|
+
};
|
|
4060
|
+
const functions = node_ids.map((n, i) => {
|
|
4061
|
+
return once(async () => {
|
|
4062
|
+
try {
|
|
4063
|
+
if (aborted) return (
|
|
4064
|
+
/** @type {import('types').ServerDataSkippedNode} */
|
|
4065
|
+
{ type: "skip" });
|
|
4066
|
+
return load_server_data({
|
|
4067
|
+
event: new_event,
|
|
4068
|
+
event_state,
|
|
4069
|
+
state,
|
|
4070
|
+
node: n == void 0 ? n : await manifest._.nodes[n](),
|
|
4071
|
+
parent: async () => {
|
|
4072
|
+
const data2 = {};
|
|
4073
|
+
for (let j = 0; j < i; j += 1) {
|
|
4074
|
+
const parent = await functions[j]();
|
|
4075
|
+
if (parent) Object.assign(data2, parent.data);
|
|
4076
|
+
}
|
|
4077
|
+
return data2;
|
|
4078
|
+
}
|
|
4079
|
+
});
|
|
4080
|
+
} catch (e) {
|
|
4081
|
+
aborted = true;
|
|
4082
|
+
throw e;
|
|
4083
|
+
}
|
|
4084
|
+
});
|
|
4085
|
+
});
|
|
4086
|
+
const promises = functions.map(async (fn, i) => {
|
|
4087
|
+
if (!invalidated[i]) return (
|
|
4088
|
+
/** @type {import('types').ServerDataSkippedNode} */
|
|
4089
|
+
{ type: "skip" });
|
|
4090
|
+
return fn();
|
|
4091
|
+
});
|
|
4092
|
+
let length = promises.length;
|
|
4093
|
+
const nodes = await Promise.all(promises.map((p, i) => p.catch(async (error2) => {
|
|
4094
|
+
if (error2 instanceof Redirect) throw error2;
|
|
4095
|
+
length = Math.min(length, i + 1);
|
|
4096
|
+
return (
|
|
4097
|
+
/** @type {import('types').ServerErrorNode} */
|
|
4098
|
+
{
|
|
4099
|
+
type: "error",
|
|
4100
|
+
error: await handle_error_and_jsonify(event, event_state, options2, error2),
|
|
4101
|
+
status: error2 instanceof HttpError || error2 instanceof SvelteKitError ? error2.status : void 0
|
|
4102
|
+
});
|
|
4103
|
+
})));
|
|
4104
|
+
const data_serializer = server_data_serializer_json(event, event_state, options2);
|
|
4105
|
+
for (let i = 0; i < nodes.length; i++) data_serializer.add_node(i, nodes[i]);
|
|
4106
|
+
const { data, chunks } = data_serializer.get_data();
|
|
4107
|
+
if (!chunks) return json_response(data);
|
|
4108
|
+
return new Response(new ReadableStream({
|
|
4109
|
+
async start(controller) {
|
|
4110
|
+
controller.enqueue(text_encoder.encode(data));
|
|
4111
|
+
for await (const chunk of chunks) controller.enqueue(text_encoder.encode(chunk));
|
|
4112
|
+
controller.close();
|
|
4113
|
+
},
|
|
4114
|
+
type: "bytes"
|
|
4115
|
+
}), { headers: {
|
|
4116
|
+
"content-type": "text/sveltekit-data",
|
|
4117
|
+
"cache-control": "private, no-store"
|
|
4118
|
+
} });
|
|
4119
|
+
} catch (e) {
|
|
4120
|
+
const error2 = normalize_error(e);
|
|
4121
|
+
if (error2 instanceof Redirect) return redirect_json_response(error2);
|
|
4122
|
+
else return json_response(await handle_error_and_jsonify(event, event_state, options2, error2), 500);
|
|
4123
|
+
}
|
|
4124
|
+
}
|
|
4125
|
+
function json_response(json2, status = 200) {
|
|
4126
|
+
return text(typeof json2 === "string" ? json2 : JSON.stringify(json2), {
|
|
4127
|
+
status,
|
|
4128
|
+
headers: {
|
|
4129
|
+
"content-type": "application/json",
|
|
4130
|
+
"cache-control": "private, no-store"
|
|
4131
|
+
}
|
|
4132
|
+
});
|
|
4133
|
+
}
|
|
4134
|
+
function redirect_json_response(redirect) {
|
|
4135
|
+
return json_response(
|
|
4136
|
+
/** @type {import('types').ServerRedirectNode} */
|
|
4137
|
+
{
|
|
4138
|
+
type: "redirect",
|
|
4139
|
+
location: redirect.location
|
|
4140
|
+
}
|
|
4141
|
+
);
|
|
4142
|
+
}
|
|
4143
|
+
const INVALID_COOKIE_CHARACTER_REGEX = /[\x00-\x1F\x7F()<>@,;:"/[\]?={} \t]/;
|
|
4144
|
+
function validate_options(options2) {
|
|
4145
|
+
if (options2?.path === void 0) throw new Error("You must specify a `path` when setting, deleting or serializing cookies");
|
|
4146
|
+
}
|
|
4147
|
+
function generate_cookie_key(domain, path, name) {
|
|
4148
|
+
return `${domain || ""}${path}?${encodeURIComponent(name)}`;
|
|
4149
|
+
}
|
|
4150
|
+
function get_cookies(request, url) {
|
|
4151
|
+
const header = request.headers.get("cookie") ?? "";
|
|
4152
|
+
const initial_cookies = (0, import_cookie.parse)(header, { decode: (value) => value });
|
|
4153
|
+
let normalized_url;
|
|
4154
|
+
const new_cookies = /* @__PURE__ */ new Map();
|
|
4155
|
+
const defaults = {
|
|
4156
|
+
httpOnly: true,
|
|
4157
|
+
sameSite: "lax",
|
|
4158
|
+
secure: url.hostname === "localhost" && url.protocol === "http:" ? false : true
|
|
4159
|
+
};
|
|
4160
|
+
const cookies = {
|
|
4161
|
+
get(name, opts) {
|
|
4162
|
+
const best_match = Array.from(new_cookies.values()).filter((c) => {
|
|
4163
|
+
return c.name === name && domain_matches(url.hostname, c.options.domain) && path_matches(url.pathname, c.options.path);
|
|
4164
|
+
}).sort((a, b) => b.options.path.length - a.options.path.length)[0];
|
|
4165
|
+
if (best_match) return best_match.options.maxAge === 0 ? void 0 : best_match.value;
|
|
4166
|
+
return (0, import_cookie.parse)(header, { decode: opts?.decode })[name];
|
|
4167
|
+
},
|
|
4168
|
+
getAll(opts) {
|
|
4169
|
+
const cookies2 = (0, import_cookie.parse)(header, { decode: opts?.decode });
|
|
4170
|
+
const lookup = /* @__PURE__ */ new Map();
|
|
4171
|
+
for (const c of new_cookies.values()) if (domain_matches(url.hostname, c.options.domain) && path_matches(url.pathname, c.options.path)) {
|
|
4172
|
+
const existing = lookup.get(c.name);
|
|
4173
|
+
if (!existing || c.options.path.length > existing.options.path.length) lookup.set(c.name, c);
|
|
4174
|
+
}
|
|
4175
|
+
for (const c of lookup.values()) cookies2[c.name] = c.value;
|
|
4176
|
+
return Object.entries(cookies2).map(([name, value]) => ({
|
|
4177
|
+
name,
|
|
4178
|
+
value
|
|
4179
|
+
}));
|
|
4180
|
+
},
|
|
4181
|
+
set(name, value, options2) {
|
|
4182
|
+
const illegal_characters = name.match(INVALID_COOKIE_CHARACTER_REGEX);
|
|
4183
|
+
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`);
|
|
4184
|
+
validate_options(options2);
|
|
4185
|
+
set_internal(name, value, {
|
|
4186
|
+
...defaults,
|
|
4187
|
+
...options2
|
|
4188
|
+
});
|
|
4189
|
+
},
|
|
4190
|
+
delete(name, options2) {
|
|
4191
|
+
validate_options(options2);
|
|
4192
|
+
cookies.set(name, "", {
|
|
4193
|
+
...options2,
|
|
4194
|
+
maxAge: 0
|
|
4195
|
+
});
|
|
4196
|
+
},
|
|
4197
|
+
serialize(name, value, options2) {
|
|
4198
|
+
validate_options(options2);
|
|
4199
|
+
let path = options2.path;
|
|
4200
|
+
if (!options2.domain || options2.domain === url.hostname) {
|
|
4201
|
+
if (!normalized_url) throw new Error("Cannot serialize cookies until after the route is determined");
|
|
4202
|
+
path = resolve(normalized_url, path);
|
|
4203
|
+
}
|
|
4204
|
+
return (0, import_cookie.serialize)(name, value, {
|
|
4205
|
+
...defaults,
|
|
4206
|
+
...options2,
|
|
4207
|
+
path
|
|
4208
|
+
});
|
|
4209
|
+
}
|
|
4210
|
+
};
|
|
4211
|
+
function get_cookie_header(destination, header2) {
|
|
4212
|
+
const combined_cookies = { ...initial_cookies };
|
|
4213
|
+
for (const cookie of new_cookies.values()) {
|
|
4214
|
+
if (!domain_matches(destination.hostname, cookie.options.domain)) continue;
|
|
4215
|
+
if (!path_matches(destination.pathname, cookie.options.path)) continue;
|
|
4216
|
+
const encoder = cookie.options.encode || encodeURIComponent;
|
|
4217
|
+
combined_cookies[cookie.name] = encoder(cookie.value);
|
|
4218
|
+
}
|
|
4219
|
+
if (header2) {
|
|
4220
|
+
const parsed = (0, import_cookie.parse)(header2, { decode: (value) => value });
|
|
4221
|
+
for (const name in parsed) combined_cookies[name] = parsed[name];
|
|
4222
|
+
}
|
|
4223
|
+
return Object.entries(combined_cookies).map(([name, value]) => `${name}=${value}`).join("; ");
|
|
4224
|
+
}
|
|
4225
|
+
const internal_queue = [];
|
|
4226
|
+
function set_internal(name, value, options2) {
|
|
4227
|
+
if (!normalized_url) {
|
|
4228
|
+
internal_queue.push(() => set_internal(name, value, options2));
|
|
4229
|
+
return;
|
|
4230
|
+
}
|
|
4231
|
+
let path = options2.path;
|
|
4232
|
+
if (!options2.domain || options2.domain === url.hostname) path = resolve(normalized_url, path);
|
|
4233
|
+
const cookie_key = generate_cookie_key(options2.domain, path, name);
|
|
4234
|
+
const cookie = {
|
|
4235
|
+
name,
|
|
4236
|
+
value,
|
|
4237
|
+
options: {
|
|
4238
|
+
...options2,
|
|
4239
|
+
path
|
|
4240
|
+
}
|
|
4241
|
+
};
|
|
4242
|
+
new_cookies.set(cookie_key, cookie);
|
|
4243
|
+
}
|
|
4244
|
+
function set_trailing_slash(trailing_slash) {
|
|
4245
|
+
normalized_url = normalize_path(url.pathname, trailing_slash);
|
|
4246
|
+
internal_queue.forEach((fn) => fn());
|
|
4247
|
+
}
|
|
4248
|
+
return {
|
|
4249
|
+
cookies,
|
|
4250
|
+
new_cookies,
|
|
4251
|
+
get_cookie_header,
|
|
4252
|
+
set_internal,
|
|
4253
|
+
set_trailing_slash
|
|
4254
|
+
};
|
|
4255
|
+
}
|
|
4256
|
+
function domain_matches(hostname, constraint) {
|
|
4257
|
+
if (!constraint) return true;
|
|
4258
|
+
const normalized = constraint[0] === "." ? constraint.slice(1) : constraint;
|
|
4259
|
+
if (hostname === normalized) return true;
|
|
4260
|
+
return hostname.endsWith("." + normalized);
|
|
4261
|
+
}
|
|
4262
|
+
function path_matches(path, constraint) {
|
|
4263
|
+
if (!constraint) return true;
|
|
4264
|
+
const normalized = constraint.endsWith("/") ? constraint.slice(0, -1) : constraint;
|
|
4265
|
+
if (path === normalized) return true;
|
|
4266
|
+
return path.startsWith(normalized + "/");
|
|
4267
|
+
}
|
|
4268
|
+
function add_cookies_to_headers(headers2, cookies) {
|
|
4269
|
+
for (const new_cookie of cookies) {
|
|
4270
|
+
const { name, value, options: options2 } = new_cookie;
|
|
4271
|
+
headers2.append("set-cookie", (0, import_cookie.serialize)(name, value, options2));
|
|
4272
|
+
if (options2.path.endsWith(".html")) {
|
|
4273
|
+
const path = add_data_suffix(options2.path);
|
|
4274
|
+
headers2.append("set-cookie", (0, import_cookie.serialize)(name, value, {
|
|
4275
|
+
...options2,
|
|
4276
|
+
path
|
|
4277
|
+
}));
|
|
4278
|
+
}
|
|
4279
|
+
}
|
|
4280
|
+
}
|
|
4281
|
+
function create_fetch({ event, options: options2, manifest, state, get_cookie_header, set_internal }) {
|
|
4282
|
+
const server_fetch = async (info, init2) => {
|
|
4283
|
+
const original_request = normalize_fetch_input(info, init2, event.url);
|
|
4284
|
+
let mode = (info instanceof Request ? info.mode : init2?.mode) ?? "cors";
|
|
4285
|
+
let credentials = (info instanceof Request ? info.credentials : init2?.credentials) ?? "same-origin";
|
|
4286
|
+
return options2.hooks.handleFetch({
|
|
4287
|
+
event,
|
|
4288
|
+
request: original_request,
|
|
4289
|
+
fetch: async (info2, init3) => {
|
|
4290
|
+
const request = normalize_fetch_input(info2, init3, event.url);
|
|
4291
|
+
const url = new URL(request.url);
|
|
4292
|
+
if (!request.headers.has("origin")) request.headers.set("origin", event.url.origin);
|
|
4293
|
+
if (info2 !== original_request) {
|
|
4294
|
+
mode = (info2 instanceof Request ? info2.mode : init3?.mode) ?? "cors";
|
|
4295
|
+
credentials = (info2 instanceof Request ? info2.credentials : init3?.credentials) ?? "same-origin";
|
|
4296
|
+
}
|
|
4297
|
+
if ((request.method === "GET" || request.method === "HEAD") && (mode === "no-cors" && url.origin !== event.url.origin || url.origin === event.url.origin)) request.headers.delete("origin");
|
|
4298
|
+
if (url.origin !== event.url.origin) {
|
|
4299
|
+
if (`.${url.hostname}`.endsWith(`.${event.url.hostname}`) && credentials !== "omit") {
|
|
4300
|
+
const cookie = get_cookie_header(url, request.headers.get("cookie"));
|
|
4301
|
+
if (cookie) request.headers.set("cookie", cookie);
|
|
4302
|
+
}
|
|
4303
|
+
return fetch(request);
|
|
4304
|
+
}
|
|
4305
|
+
const prefix = assets || base;
|
|
4306
|
+
const decoded = decodeURIComponent(url.pathname);
|
|
4307
|
+
const filename = (decoded.startsWith(prefix) ? decoded.slice(prefix.length) : decoded).slice(1);
|
|
4308
|
+
const filename_html = `${filename}/index.html`;
|
|
4309
|
+
const is_asset = manifest.assets.has(filename) || filename in manifest._.server_assets;
|
|
4310
|
+
const is_asset_html = manifest.assets.has(filename_html) || filename_html in manifest._.server_assets;
|
|
4311
|
+
if (is_asset || is_asset_html) {
|
|
4312
|
+
const file = is_asset ? filename : filename_html;
|
|
4313
|
+
if (state.read) {
|
|
4314
|
+
const type = is_asset ? manifest.mimeTypes[filename.slice(filename.lastIndexOf("."))] : "text/html";
|
|
4315
|
+
return new Response(state.read(file), { headers: type ? { "content-type": type } : {} });
|
|
4316
|
+
} else if (read_implementation && file in manifest._.server_assets) {
|
|
4317
|
+
const length = manifest._.server_assets[file];
|
|
4318
|
+
const type = manifest.mimeTypes[file.slice(file.lastIndexOf("."))];
|
|
4319
|
+
return new Response(read_implementation(file), { headers: {
|
|
4320
|
+
"Content-Length": "" + length,
|
|
4321
|
+
"Content-Type": type
|
|
4322
|
+
} });
|
|
4323
|
+
}
|
|
4324
|
+
return await fetch(request);
|
|
4325
|
+
}
|
|
4326
|
+
if (has_prerendered_path(manifest, base + decoded)) return await fetch(request);
|
|
4327
|
+
if (credentials !== "omit") {
|
|
4328
|
+
const cookie = get_cookie_header(url, request.headers.get("cookie"));
|
|
4329
|
+
if (cookie) request.headers.set("cookie", cookie);
|
|
4330
|
+
const authorization = event.request.headers.get("authorization");
|
|
4331
|
+
if (authorization && !request.headers.has("authorization")) request.headers.set("authorization", authorization);
|
|
4332
|
+
}
|
|
4333
|
+
if (!request.headers.has("accept")) request.headers.set("accept", "*/*");
|
|
4334
|
+
if (!request.headers.has("accept-language")) request.headers.set(
|
|
4335
|
+
"accept-language",
|
|
4336
|
+
/** @type {string} */
|
|
4337
|
+
event.request.headers.get("accept-language")
|
|
4338
|
+
);
|
|
4339
|
+
const response = await internal_fetch(request, options2, manifest, state);
|
|
4340
|
+
const set_cookie = response.headers.get("set-cookie");
|
|
4341
|
+
if (set_cookie) for (const str of import_set_cookie.splitCookiesString(set_cookie)) {
|
|
4342
|
+
const { name, value, ...options3 } = import_set_cookie.parseString(str, { decodeValues: false });
|
|
4343
|
+
set_internal(name, value, {
|
|
4344
|
+
path: options3.path ?? (url.pathname.split("/").slice(0, -1).join("/") || "/"),
|
|
4345
|
+
encode: (value2) => value2,
|
|
4346
|
+
...options3
|
|
4347
|
+
});
|
|
4348
|
+
}
|
|
4349
|
+
return response;
|
|
4350
|
+
}
|
|
4351
|
+
});
|
|
4352
|
+
};
|
|
4353
|
+
return (input, init2) => {
|
|
4354
|
+
const response = server_fetch(input, init2);
|
|
4355
|
+
response.catch(() => {});
|
|
4356
|
+
return response;
|
|
4357
|
+
};
|
|
4358
|
+
}
|
|
4359
|
+
function normalize_fetch_input(info, init2, url) {
|
|
4360
|
+
if (info instanceof Request) return info;
|
|
4361
|
+
return new Request(typeof info === "string" ? new URL(info, url) : info, init2);
|
|
4362
|
+
}
|
|
4363
|
+
async function internal_fetch(request, options2, manifest, state) {
|
|
4364
|
+
if (request.signal) {
|
|
4365
|
+
if (request.signal.aborted) throw new DOMException("The operation was aborted.", "AbortError");
|
|
4366
|
+
let remove_abort_listener = () => {};
|
|
4367
|
+
const abort_promise = new Promise((_, reject) => {
|
|
4368
|
+
const on_abort = () => {
|
|
4369
|
+
reject(new DOMException("The operation was aborted.", "AbortError"));
|
|
4370
|
+
};
|
|
4371
|
+
request.signal.addEventListener("abort", on_abort, { once: true });
|
|
4372
|
+
remove_abort_listener = () => request.signal.removeEventListener("abort", on_abort);
|
|
4373
|
+
});
|
|
4374
|
+
const result = await Promise.race([respond(request, options2, manifest, {
|
|
4375
|
+
...state,
|
|
4376
|
+
depth: state.depth + 1
|
|
4377
|
+
}), abort_promise]);
|
|
4378
|
+
remove_abort_listener();
|
|
4379
|
+
return result;
|
|
4380
|
+
} else return await respond(request, options2, manifest, {
|
|
4381
|
+
...state,
|
|
4382
|
+
depth: state.depth + 1
|
|
4383
|
+
});
|
|
4384
|
+
}
|
|
4385
|
+
let body;
|
|
4386
|
+
let etag;
|
|
4387
|
+
let headers;
|
|
4388
|
+
function get_public_env(request) {
|
|
4389
|
+
body ??= `export const env=${JSON.stringify(public_env)}`;
|
|
4390
|
+
etag ??= `W/${Date.now()}`;
|
|
4391
|
+
headers ??= new Headers({
|
|
4392
|
+
"content-type": "application/javascript; charset=utf-8",
|
|
4393
|
+
etag
|
|
4394
|
+
});
|
|
4395
|
+
if (request.headers.get("if-none-match") === etag) return new Response(void 0, {
|
|
4396
|
+
status: 304,
|
|
4397
|
+
headers
|
|
4398
|
+
});
|
|
4399
|
+
return new Response(body, { headers });
|
|
4400
|
+
}
|
|
4401
|
+
const default_transform = ({ html }) => html;
|
|
4402
|
+
const default_filter = () => false;
|
|
4403
|
+
const default_preload = ({ type }) => type === "js" || type === "css";
|
|
4404
|
+
const page_methods = /* @__PURE__ */ new Set([
|
|
4405
|
+
"GET",
|
|
4406
|
+
"HEAD",
|
|
4407
|
+
"POST"
|
|
4408
|
+
]);
|
|
4409
|
+
const allowed_page_methods = /* @__PURE__ */ new Set([
|
|
4410
|
+
"GET",
|
|
4411
|
+
"HEAD",
|
|
4412
|
+
"OPTIONS"
|
|
4413
|
+
]);
|
|
4414
|
+
const respond = propagate_context(internal_respond);
|
|
4415
|
+
async function internal_respond(request, options2, manifest, state) {
|
|
4416
|
+
const url = new URL(request.url);
|
|
4417
|
+
const is_route_resolution_request = has_resolution_suffix(url.pathname);
|
|
4418
|
+
const is_data_request = has_data_suffix(url.pathname);
|
|
4419
|
+
const remote_id = get_remote_id(url);
|
|
4420
|
+
{
|
|
4421
|
+
const request_origin = request.headers.get("origin");
|
|
4422
|
+
if (remote_id) {
|
|
4423
|
+
if (request.method !== "GET" && request_origin !== url.origin) return json({ message: "Cross-site remote requests are forbidden" }, { status: 403 });
|
|
4424
|
+
} else if (options2.csrf_check_origin) {
|
|
4425
|
+
if (is_form_content_type(request) && (request.method === "POST" || request.method === "PUT" || request.method === "PATCH" || request.method === "DELETE") && request_origin !== url.origin && (!request_origin || !options2.csrf_trusted_origins.includes(request_origin))) {
|
|
4426
|
+
const message = `Cross-site ${request.method} form submissions are forbidden`;
|
|
4427
|
+
const opts = { status: 403 };
|
|
4428
|
+
if (request.headers.get("accept") === "application/json") return json({ message }, opts);
|
|
4429
|
+
return text(message, opts);
|
|
4430
|
+
}
|
|
4431
|
+
}
|
|
4432
|
+
}
|
|
4433
|
+
if (options2.hash_routing && url.pathname !== base + "/" && url.pathname !== "/[fallback]") return text("Not found", { status: 404 });
|
|
4434
|
+
let invalidated_data_nodes;
|
|
4435
|
+
if (is_route_resolution_request) url.pathname = strip_resolution_suffix(url.pathname);
|
|
4436
|
+
else if (is_data_request) {
|
|
4437
|
+
url.pathname = strip_data_suffix(url.pathname) + (url.searchParams.get(TRAILING_SLASH_PARAM) === "1" ? "/" : "") || "/";
|
|
4438
|
+
url.searchParams.delete(TRAILING_SLASH_PARAM);
|
|
4439
|
+
invalidated_data_nodes = url.searchParams.get(INVALIDATED_PARAM)?.split("").map((node) => node === "1");
|
|
4440
|
+
url.searchParams.delete(INVALIDATED_PARAM);
|
|
4441
|
+
} else if (remote_id) {
|
|
4442
|
+
url.pathname = request.headers.get("x-sveltekit-pathname") ?? base;
|
|
4443
|
+
url.search = request.headers.get("x-sveltekit-search") ?? "";
|
|
4444
|
+
}
|
|
4445
|
+
const headers2 = {};
|
|
4446
|
+
const { cookies, new_cookies, get_cookie_header, set_internal, set_trailing_slash } = get_cookies(request, url);
|
|
4447
|
+
const event_state = {
|
|
4448
|
+
prerendering: state.prerendering,
|
|
4449
|
+
transport: options2.hooks.transport,
|
|
4450
|
+
handleValidationError: options2.hooks.handleValidationError,
|
|
4451
|
+
tracing: { record_span },
|
|
4452
|
+
is_in_remote_function: false
|
|
4453
|
+
};
|
|
4454
|
+
const event = {
|
|
4455
|
+
cookies,
|
|
4456
|
+
fetch: null,
|
|
4457
|
+
getClientAddress: state.getClientAddress || (() => {
|
|
4458
|
+
throw new Error(`svelte-adapter-bun does not specify getClientAddress. Please raise an issue`);
|
|
4459
|
+
}),
|
|
4460
|
+
locals: {},
|
|
4461
|
+
params: {},
|
|
4462
|
+
platform: state.platform,
|
|
4463
|
+
request,
|
|
4464
|
+
route: { id: null },
|
|
4465
|
+
setHeaders: (new_headers) => {
|
|
4466
|
+
for (const key2 in new_headers) {
|
|
4467
|
+
const lower = key2.toLowerCase();
|
|
4468
|
+
const value = new_headers[key2];
|
|
4469
|
+
if (lower === "set-cookie") throw new Error("Use `event.cookies.set(name, value, options)` instead of `event.setHeaders` to set cookies");
|
|
4470
|
+
else if (lower in headers2) if (lower === "server-timing") headers2[lower] += ", " + value;
|
|
4471
|
+
else throw new Error(`"${key2}" header is already set`);
|
|
4472
|
+
else {
|
|
4473
|
+
headers2[lower] = value;
|
|
4474
|
+
if (state.prerendering && lower === "cache-control") state.prerendering.cache = value;
|
|
4475
|
+
}
|
|
4476
|
+
}
|
|
4477
|
+
},
|
|
4478
|
+
url,
|
|
4479
|
+
isDataRequest: is_data_request,
|
|
4480
|
+
isSubRequest: state.depth > 0,
|
|
4481
|
+
isRemoteRequest: !!remote_id
|
|
4482
|
+
};
|
|
4483
|
+
event.fetch = create_fetch({
|
|
4484
|
+
event,
|
|
4485
|
+
options: options2,
|
|
4486
|
+
manifest,
|
|
4487
|
+
state,
|
|
4488
|
+
get_cookie_header,
|
|
4489
|
+
set_internal
|
|
4490
|
+
});
|
|
4491
|
+
if (state.emulator?.platform) event.platform = await state.emulator.platform({
|
|
4492
|
+
config: {},
|
|
4493
|
+
prerender: !!state.prerendering?.fallback
|
|
4494
|
+
});
|
|
4495
|
+
let resolved_path = url.pathname;
|
|
4496
|
+
if (!remote_id) {
|
|
4497
|
+
const prerendering_reroute_state = state.prerendering?.inside_reroute;
|
|
4498
|
+
try {
|
|
4499
|
+
if (state.prerendering) state.prerendering.inside_reroute = true;
|
|
4500
|
+
resolved_path = await options2.hooks.reroute({
|
|
4501
|
+
url: new URL(url),
|
|
4502
|
+
fetch: event.fetch
|
|
4503
|
+
}) ?? url.pathname;
|
|
4504
|
+
} catch {
|
|
4505
|
+
return text("Internal Server Error", { status: 500 });
|
|
4506
|
+
} finally {
|
|
4507
|
+
if (state.prerendering) state.prerendering.inside_reroute = prerendering_reroute_state;
|
|
4508
|
+
}
|
|
4509
|
+
}
|
|
4510
|
+
try {
|
|
4511
|
+
resolved_path = decode_pathname(resolved_path);
|
|
4512
|
+
} catch {
|
|
4513
|
+
return text("Malformed URI", { status: 400 });
|
|
4514
|
+
}
|
|
4515
|
+
if (resolved_path !== decode_pathname(url.pathname) && !state.prerendering?.fallback && has_prerendered_path(manifest, resolved_path)) {
|
|
4516
|
+
const url2 = new URL(request.url);
|
|
4517
|
+
url2.pathname = is_data_request ? add_data_suffix(resolved_path) : is_route_resolution_request ? add_resolution_suffix(resolved_path) : resolved_path;
|
|
4518
|
+
try {
|
|
4519
|
+
const response = await fetch(url2, request);
|
|
4520
|
+
const headers22 = new Headers(response.headers);
|
|
4521
|
+
if (headers22.has("content-encoding")) {
|
|
4522
|
+
headers22.delete("content-encoding");
|
|
4523
|
+
headers22.delete("content-length");
|
|
4524
|
+
}
|
|
4525
|
+
return new Response(response.body, {
|
|
4526
|
+
headers: headers22,
|
|
4527
|
+
status: response.status,
|
|
4528
|
+
statusText: response.statusText
|
|
4529
|
+
});
|
|
4530
|
+
} catch (error2) {
|
|
4531
|
+
return await handle_fatal_error(event, event_state, options2, error2);
|
|
4532
|
+
}
|
|
4533
|
+
}
|
|
4534
|
+
let route = null;
|
|
4535
|
+
if (base && !state.prerendering?.fallback) {
|
|
4536
|
+
if (!resolved_path.startsWith(base)) return text("Not found", { status: 404 });
|
|
4537
|
+
resolved_path = resolved_path.slice(base.length) || "/";
|
|
4538
|
+
}
|
|
4539
|
+
if (is_route_resolution_request) return resolve_route(resolved_path, new URL(request.url), manifest);
|
|
4540
|
+
if (resolved_path === `/${app_dir}/env.js`) return get_public_env(request);
|
|
4541
|
+
if (!remote_id && resolved_path.startsWith(`/${app_dir}`)) {
|
|
4542
|
+
const headers22 = new Headers();
|
|
4543
|
+
headers22.set("cache-control", "public, max-age=0, must-revalidate");
|
|
4544
|
+
return text("Not found", {
|
|
4545
|
+
status: 404,
|
|
4546
|
+
headers: headers22
|
|
4547
|
+
});
|
|
4548
|
+
}
|
|
4549
|
+
if (!state.prerendering?.fallback) {
|
|
4550
|
+
const matchers = await manifest._.matchers();
|
|
4551
|
+
for (const candidate of manifest._.routes) {
|
|
4552
|
+
const match = candidate.pattern.exec(resolved_path);
|
|
4553
|
+
if (!match) continue;
|
|
4554
|
+
const matched = exec(match, candidate.params, matchers);
|
|
4555
|
+
if (matched) {
|
|
4556
|
+
route = candidate;
|
|
4557
|
+
event.route = { id: route.id };
|
|
4558
|
+
event.params = decode_params(matched);
|
|
4559
|
+
break;
|
|
4560
|
+
}
|
|
4561
|
+
}
|
|
4562
|
+
}
|
|
4563
|
+
let resolve_opts = {
|
|
4564
|
+
transformPageChunk: default_transform,
|
|
4565
|
+
filterSerializedResponseHeaders: default_filter,
|
|
4566
|
+
preload: default_preload
|
|
4567
|
+
};
|
|
4568
|
+
let trailing_slash = "never";
|
|
4569
|
+
try {
|
|
4570
|
+
const page_nodes = route?.page ? new PageNodes(await load_page_nodes(route.page, manifest)) : void 0;
|
|
4571
|
+
if (route && !remote_id) {
|
|
4572
|
+
if (url.pathname === base || url.pathname === base + "/") trailing_slash = "always";
|
|
4573
|
+
else if (page_nodes) {
|
|
4574
|
+
if (BROWSER);
|
|
4575
|
+
trailing_slash = page_nodes.trailing_slash();
|
|
4576
|
+
} else if (route.endpoint) {
|
|
4577
|
+
trailing_slash = (await route.endpoint()).trailingSlash ?? "never";
|
|
4578
|
+
if (BROWSER);
|
|
4579
|
+
}
|
|
4580
|
+
if (!is_data_request) {
|
|
4581
|
+
const normalized = normalize_path(url.pathname, trailing_slash);
|
|
4582
|
+
if (normalized !== url.pathname && !state.prerendering?.fallback) return new Response(void 0, {
|
|
4583
|
+
status: 308,
|
|
4584
|
+
headers: {
|
|
4585
|
+
"x-sveltekit-normalize": "1",
|
|
4586
|
+
location: (normalized.startsWith("//") ? url.origin + normalized : normalized) + (url.search === "?" ? "" : url.search)
|
|
4587
|
+
}
|
|
4588
|
+
});
|
|
4589
|
+
}
|
|
4590
|
+
if (state.before_handle || state.emulator?.platform) {
|
|
4591
|
+
let config = {};
|
|
4592
|
+
let prerender = false;
|
|
4593
|
+
if (route.endpoint) {
|
|
4594
|
+
const node = await route.endpoint();
|
|
4595
|
+
config = node.config ?? config;
|
|
4596
|
+
prerender = node.prerender ?? prerender;
|
|
4597
|
+
} else if (page_nodes) {
|
|
4598
|
+
config = page_nodes.get_config() ?? config;
|
|
4599
|
+
prerender = page_nodes.prerender();
|
|
4600
|
+
}
|
|
4601
|
+
if (state.before_handle) state.before_handle(event, config, prerender);
|
|
4602
|
+
if (state.emulator?.platform) event.platform = await state.emulator.platform({
|
|
4603
|
+
config,
|
|
4604
|
+
prerender
|
|
4605
|
+
});
|
|
4606
|
+
}
|
|
4607
|
+
}
|
|
4608
|
+
set_trailing_slash(trailing_slash);
|
|
4609
|
+
if (state.prerendering && !state.prerendering.fallback && !state.prerendering.inside_reroute) disable_search(url);
|
|
4610
|
+
const response = await record_span({
|
|
4611
|
+
name: "sveltekit.handle.root",
|
|
4612
|
+
attributes: {
|
|
4613
|
+
"http.route": event.route.id || "unknown",
|
|
4614
|
+
"http.method": event.request.method,
|
|
4615
|
+
"http.url": event.url.href,
|
|
4616
|
+
"sveltekit.is_data_request": is_data_request,
|
|
4617
|
+
"sveltekit.is_sub_request": event.isSubRequest
|
|
4618
|
+
},
|
|
4619
|
+
fn: async (root_span) => {
|
|
4620
|
+
const traced_event = {
|
|
4621
|
+
...event,
|
|
4622
|
+
tracing: {
|
|
4623
|
+
enabled: false,
|
|
4624
|
+
root: root_span,
|
|
4625
|
+
current: root_span
|
|
4626
|
+
}
|
|
4627
|
+
};
|
|
4628
|
+
return await with_request_store({
|
|
4629
|
+
event: traced_event,
|
|
4630
|
+
state: event_state
|
|
4631
|
+
}, () => options2.hooks.handle({
|
|
4632
|
+
event: traced_event,
|
|
4633
|
+
resolve: (event2, opts) => {
|
|
4634
|
+
return record_span({
|
|
4635
|
+
name: "sveltekit.resolve",
|
|
4636
|
+
attributes: { "http.route": event2.route.id || "unknown" },
|
|
4637
|
+
fn: (resolve_span) => {
|
|
4638
|
+
return with_request_store(null, () => resolve2(merge_tracing(event2, resolve_span), page_nodes, opts).then((response2) => {
|
|
4639
|
+
for (const key2 in headers2) {
|
|
4640
|
+
const value = headers2[key2];
|
|
4641
|
+
response2.headers.set(
|
|
4642
|
+
key2,
|
|
4643
|
+
/** @type {string} */
|
|
4644
|
+
value
|
|
4645
|
+
);
|
|
4646
|
+
}
|
|
4647
|
+
add_cookies_to_headers(response2.headers, new_cookies.values());
|
|
4648
|
+
if (state.prerendering && event2.route.id !== null) response2.headers.set("x-sveltekit-routeid", encodeURI(event2.route.id));
|
|
4649
|
+
resolve_span.setAttributes({
|
|
4650
|
+
"http.response.status_code": response2.status,
|
|
4651
|
+
"http.response.body.size": response2.headers.get("content-length") || "unknown"
|
|
4652
|
+
});
|
|
4653
|
+
return response2;
|
|
4654
|
+
}));
|
|
4655
|
+
}
|
|
4656
|
+
});
|
|
4657
|
+
}
|
|
4658
|
+
}));
|
|
4659
|
+
}
|
|
4660
|
+
});
|
|
4661
|
+
if (response.status === 200 && response.headers.has("etag")) {
|
|
4662
|
+
let if_none_match_value = request.headers.get("if-none-match");
|
|
4663
|
+
if (if_none_match_value?.startsWith("W/\"")) if_none_match_value = if_none_match_value.substring(2);
|
|
4664
|
+
const etag2 = response.headers.get("etag");
|
|
4665
|
+
if (if_none_match_value === etag2) {
|
|
4666
|
+
const headers22 = new Headers({ etag: etag2 });
|
|
4667
|
+
for (const key2 of [
|
|
4668
|
+
"cache-control",
|
|
4669
|
+
"content-location",
|
|
4670
|
+
"date",
|
|
4671
|
+
"expires",
|
|
4672
|
+
"vary",
|
|
4673
|
+
"set-cookie"
|
|
4674
|
+
]) {
|
|
4675
|
+
const value = response.headers.get(key2);
|
|
4676
|
+
if (value) headers22.set(key2, value);
|
|
4677
|
+
}
|
|
4678
|
+
return new Response(void 0, {
|
|
4679
|
+
status: 304,
|
|
4680
|
+
headers: headers22
|
|
4681
|
+
});
|
|
4682
|
+
}
|
|
4683
|
+
}
|
|
4684
|
+
if (is_data_request && response.status >= 300 && response.status <= 308) {
|
|
4685
|
+
const location = response.headers.get("location");
|
|
4686
|
+
if (location) return redirect_json_response(new Redirect(
|
|
4687
|
+
/** @type {any} */
|
|
4688
|
+
response.status,
|
|
4689
|
+
location
|
|
4690
|
+
));
|
|
4691
|
+
}
|
|
4692
|
+
return response;
|
|
4693
|
+
} catch (e) {
|
|
4694
|
+
if (e instanceof Redirect) {
|
|
4695
|
+
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);
|
|
4696
|
+
add_cookies_to_headers(response.headers, new_cookies.values());
|
|
4697
|
+
return response;
|
|
4698
|
+
}
|
|
4699
|
+
return await handle_fatal_error(event, event_state, options2, e);
|
|
4700
|
+
}
|
|
4701
|
+
async function resolve2(event2, page_nodes, opts) {
|
|
4702
|
+
try {
|
|
4703
|
+
if (opts) resolve_opts = {
|
|
4704
|
+
transformPageChunk: opts.transformPageChunk || default_transform,
|
|
4705
|
+
filterSerializedResponseHeaders: opts.filterSerializedResponseHeaders || default_filter,
|
|
4706
|
+
preload: opts.preload || default_preload
|
|
4707
|
+
};
|
|
4708
|
+
if (options2.hash_routing || state.prerendering?.fallback) return await render_response({
|
|
4709
|
+
event: event2,
|
|
4710
|
+
event_state,
|
|
4711
|
+
options: options2,
|
|
4712
|
+
manifest,
|
|
4713
|
+
state,
|
|
4714
|
+
page_config: {
|
|
4715
|
+
ssr: false,
|
|
4716
|
+
csr: true
|
|
4717
|
+
},
|
|
4718
|
+
status: 200,
|
|
4719
|
+
error: null,
|
|
4720
|
+
branch: [],
|
|
4721
|
+
fetched: [],
|
|
4722
|
+
resolve_opts,
|
|
4723
|
+
data_serializer: server_data_serializer(event2, event_state, options2)
|
|
4724
|
+
});
|
|
4725
|
+
if (remote_id) return await handle_remote_call(event2, event_state, options2, manifest, remote_id);
|
|
4726
|
+
if (route) {
|
|
4727
|
+
const method = event2.request.method;
|
|
4728
|
+
let response2;
|
|
4729
|
+
if (is_data_request) response2 = await render_data(event2, event_state, route, options2, manifest, state, invalidated_data_nodes, trailing_slash);
|
|
4730
|
+
else if (route.endpoint && (!route.page || is_endpoint_request(event2))) response2 = await render_endpoint(event2, event_state, await route.endpoint(), state);
|
|
4731
|
+
else if (route.page) if (!page_nodes) throw new Error("page_nodes not found. This should never happen");
|
|
4732
|
+
else if (page_methods.has(method)) response2 = await render_page(event2, event_state, route.page, options2, manifest, state, page_nodes, resolve_opts);
|
|
4733
|
+
else {
|
|
4734
|
+
const allowed_methods2 = new Set(allowed_page_methods);
|
|
4735
|
+
if ((await manifest._.nodes[route.page.leaf]())?.server?.actions) allowed_methods2.add("POST");
|
|
4736
|
+
if (method === "OPTIONS") response2 = new Response(null, {
|
|
4737
|
+
status: 204,
|
|
4738
|
+
headers: { allow: Array.from(allowed_methods2.values()).join(", ") }
|
|
4739
|
+
});
|
|
4740
|
+
else response2 = method_not_allowed([...allowed_methods2].reduce(
|
|
4741
|
+
(acc, curr) => {
|
|
4742
|
+
acc[curr] = true;
|
|
4743
|
+
return acc;
|
|
4744
|
+
},
|
|
4745
|
+
/** @type {Record<string, any>} */
|
|
4746
|
+
{}
|
|
4747
|
+
), method);
|
|
4748
|
+
}
|
|
4749
|
+
else throw new Error("Route is neither page nor endpoint. This should never happen");
|
|
4750
|
+
if (request.method === "GET" && route.page && route.endpoint) {
|
|
4751
|
+
const vary = response2.headers.get("vary")?.split(",")?.map((v) => v.trim().toLowerCase());
|
|
4752
|
+
if (!(vary?.includes("accept") || vary?.includes("*"))) {
|
|
4753
|
+
response2 = new Response(response2.body, {
|
|
4754
|
+
status: response2.status,
|
|
4755
|
+
statusText: response2.statusText,
|
|
4756
|
+
headers: new Headers(response2.headers)
|
|
4757
|
+
});
|
|
4758
|
+
response2.headers.append("Vary", "Accept");
|
|
4759
|
+
}
|
|
4760
|
+
}
|
|
4761
|
+
return response2;
|
|
4762
|
+
}
|
|
4763
|
+
if (state.error && event2.isSubRequest) {
|
|
4764
|
+
const headers22 = new Headers(request.headers);
|
|
4765
|
+
headers22.set("x-sveltekit-error", "true");
|
|
4766
|
+
return await fetch(request, { headers: headers22 });
|
|
4767
|
+
}
|
|
4768
|
+
if (state.error) return text("Internal Server Error", { status: 500 });
|
|
4769
|
+
if (state.depth === 0) {
|
|
4770
|
+
if (BROWSER && event2.url.pathname === "/.well-known/appspecific/com.chrome.devtools.json");
|
|
4771
|
+
return await respond_with_error({
|
|
4772
|
+
event: event2,
|
|
4773
|
+
event_state,
|
|
4774
|
+
options: options2,
|
|
4775
|
+
manifest,
|
|
4776
|
+
state,
|
|
4777
|
+
status: 404,
|
|
4778
|
+
error: new SvelteKitError(404, "Not Found", `Not found: ${event2.url.pathname}`),
|
|
4779
|
+
resolve_opts
|
|
4780
|
+
});
|
|
4781
|
+
}
|
|
4782
|
+
if (state.prerendering) return text("not found", { status: 404 });
|
|
4783
|
+
const response = await fetch(request);
|
|
4784
|
+
return new Response(response.body, response);
|
|
4785
|
+
} catch (e) {
|
|
4786
|
+
return await handle_fatal_error(event2, event_state, options2, e);
|
|
4787
|
+
} finally {
|
|
4788
|
+
event2.cookies.set = () => {
|
|
4789
|
+
throw new Error("Cannot use `cookies.set(...)` after the response has been generated");
|
|
4790
|
+
};
|
|
4791
|
+
event2.setHeaders = () => {
|
|
4792
|
+
throw new Error("Cannot use `setHeaders(...)` after the response has been generated");
|
|
4793
|
+
};
|
|
4794
|
+
}
|
|
4795
|
+
}
|
|
4796
|
+
}
|
|
4797
|
+
function load_page_nodes(page, manifest) {
|
|
4798
|
+
return Promise.all([...page.layouts.map((n) => n == void 0 ? n : manifest._.nodes[n]()), manifest._.nodes[page.leaf]()]);
|
|
4799
|
+
}
|
|
4800
|
+
function propagate_context(fn) {
|
|
4801
|
+
return async (req, ...rest) => {
|
|
4802
|
+
return fn(req, ...rest);
|
|
4803
|
+
};
|
|
4804
|
+
}
|
|
4805
|
+
function filter_env(env, allowed, disallowed) {
|
|
4806
|
+
return Object.fromEntries(Object.entries(env).filter(([k]) => k.startsWith(allowed) && (disallowed === "" || !k.startsWith(disallowed))));
|
|
4807
|
+
}
|
|
4808
|
+
function set_app(value) {}
|
|
4809
|
+
let init_promise;
|
|
4810
|
+
let current = null;
|
|
4811
|
+
var Server = class {
|
|
4812
|
+
/** @type {import('types').SSROptions} */
|
|
4813
|
+
#options;
|
|
4814
|
+
/** @type {import('@sveltejs/kit').SSRManifest} */
|
|
4815
|
+
#manifest;
|
|
4816
|
+
/** @param {import('@sveltejs/kit').SSRManifest} manifest */
|
|
4817
|
+
constructor(manifest) {
|
|
4818
|
+
this.#options = options;
|
|
4819
|
+
this.#manifest = manifest;
|
|
4820
|
+
if (IN_WEBCONTAINER) {
|
|
4821
|
+
const respond2 = this.respond.bind(this);
|
|
4822
|
+
this.respond = async (...args) => {
|
|
4823
|
+
const { promise, resolve: resolve2 } = with_resolvers();
|
|
4824
|
+
const previous = current;
|
|
4825
|
+
current = promise;
|
|
4826
|
+
await previous;
|
|
4827
|
+
return respond2(...args).finally(resolve2);
|
|
4828
|
+
};
|
|
4829
|
+
}
|
|
4830
|
+
}
|
|
4831
|
+
/**
|
|
4832
|
+
* @param {import('@sveltejs/kit').ServerInitOptions} opts
|
|
4833
|
+
*/
|
|
4834
|
+
websocket() {return this.#options.hooks.websocket}
|
|
4835
|
+
async init({ env, read }) {
|
|
4836
|
+
const { env_public_prefix, env_private_prefix } = this.#options;
|
|
4837
|
+
set_private_env(filter_env(env, env_private_prefix, env_public_prefix));
|
|
4838
|
+
set_public_env(filter_env(env, env_public_prefix, env_private_prefix));
|
|
4839
|
+
if (read) {
|
|
4840
|
+
const wrapped_read = (file) => {
|
|
4841
|
+
const result = read(file);
|
|
4842
|
+
if (result instanceof ReadableStream) return result;
|
|
4843
|
+
else return new ReadableStream({ async start(controller) {
|
|
4844
|
+
try {
|
|
4845
|
+
const stream = await Promise.resolve(result);
|
|
4846
|
+
if (!stream) {
|
|
4847
|
+
controller.close();
|
|
4848
|
+
return;
|
|
4849
|
+
}
|
|
4850
|
+
const reader = stream.getReader();
|
|
4851
|
+
while (true) {
|
|
4852
|
+
const { done, value } = await reader.read();
|
|
4853
|
+
if (done) break;
|
|
4854
|
+
controller.enqueue(value);
|
|
4855
|
+
}
|
|
4856
|
+
controller.close();
|
|
4857
|
+
} catch (error2) {
|
|
4858
|
+
controller.error(error2);
|
|
4859
|
+
}
|
|
4860
|
+
} });
|
|
4861
|
+
};
|
|
4862
|
+
set_read_implementation(wrapped_read);
|
|
4863
|
+
}
|
|
4864
|
+
await (init_promise ??= (async () => {
|
|
4865
|
+
try {
|
|
4866
|
+
const module = await get_hooks();this.#options.hooks = {websocket: module.websocket || null,
|
|
4867
|
+
handle: module.handle || (({ event, resolve: resolve2 }) => resolve2(event)),
|
|
4868
|
+
handleError: module.handleError || (({ status, error: error2, event }) => {
|
|
4869
|
+
const error_message = format_server_error(
|
|
4870
|
+
status,
|
|
4871
|
+
/** @type {Error} */
|
|
4872
|
+
error2,
|
|
4873
|
+
event
|
|
4874
|
+
);
|
|
4875
|
+
console.error(error_message);
|
|
4876
|
+
}),
|
|
4877
|
+
handleFetch: module.handleFetch || (({ request, fetch: fetch2 }) => fetch2(request)),
|
|
4878
|
+
handleValidationError: module.handleValidationError || (({ issues }) => {
|
|
4879
|
+
console.error("Remote function schema validation failed:", issues);
|
|
4880
|
+
return { message: "Bad Request" };
|
|
4881
|
+
}),
|
|
4882
|
+
reroute: module.reroute || (() => {}),
|
|
4883
|
+
transport: module.transport || {}
|
|
4884
|
+
};
|
|
4885
|
+
set_app({ decoders: module.transport ? Object.fromEntries(Object.entries(module.transport).map(([k, v]) => [k, v.decode])) : {} });
|
|
4886
|
+
if (module.init) await module.init();
|
|
4887
|
+
} catch (e) {
|
|
4888
|
+
throw e;
|
|
4889
|
+
}
|
|
4890
|
+
})());
|
|
4891
|
+
}
|
|
4892
|
+
/**
|
|
4893
|
+
* @param {Request} request
|
|
4894
|
+
* @param {import('types').RequestOptions} options
|
|
4895
|
+
*/
|
|
4896
|
+
async respond(request, options2) {
|
|
4897
|
+
return respond(request, this.#options, this.#manifest, {
|
|
4898
|
+
...options2,
|
|
4899
|
+
error: false,
|
|
4900
|
+
depth: 0
|
|
4901
|
+
});
|
|
4902
|
+
}
|
|
4903
|
+
};
|
|
4904
|
+
|
|
4905
|
+
//#endregion
|
|
4906
|
+
export { Server };
|
|
4907
|
+
//# sourceMappingURL=index.js.map
|