Spaces:
Running
Running
pngwn
commited on
Commit
·
5fd8183
1
Parent(s):
e61a59a
tweak
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- .DS_Store +0 -0
- .gitignore +1 -0
- .pnpm-debug.log +22 -0
- .svelte-kit/build/app.js +77 -0
- .svelte-kit/build/components/error.svelte +29 -0
- .svelte-kit/build/components/layout.svelte +1 -0
- .svelte-kit/build/generated/manifest.js +28 -0
- .svelte-kit/build/generated/root.svelte +70 -0
- .svelte-kit/build/kit.js +1921 -0
- .svelte-kit/build/runtime/app/env.js +20 -0
- .svelte-kit/build/runtime/app/navigation.js +65 -0
- .svelte-kit/build/runtime/app/paths.js +1 -0
- .svelte-kit/build/runtime/app/stores.js +84 -0
- .svelte-kit/build/runtime/chunks/utils.js +13 -0
- .svelte-kit/build/runtime/env.js +8 -0
- .svelte-kit/build/runtime/internal/singletons.js +18 -0
- .svelte-kit/build/runtime/internal/start.js +1219 -0
- .svelte-kit/build/runtime/paths.js +13 -0
- {_app → .svelte-kit/output/client/_app}/assets/fira-mono-all-400-normal-0d19eb5d.woff +0 -0
- {_app → .svelte-kit/output/client/_app}/assets/fira-mono-cyrillic-400-normal-046b609f.woff2 +0 -0
- {_app → .svelte-kit/output/client/_app}/assets/fira-mono-cyrillic-ext-400-normal-b3140dd3.woff2 +0 -0
- {_app → .svelte-kit/output/client/_app}/assets/fira-mono-greek-400-normal-1f8b3a07.woff2 +0 -0
- {_app → .svelte-kit/output/client/_app}/assets/fira-mono-greek-ext-400-normal-8659ae46.woff2 +0 -0
- {_app → .svelte-kit/output/client/_app}/assets/fira-mono-latin-400-normal-a2f9dbe8.woff2 +0 -0
- {_app → .svelte-kit/output/client/_app}/assets/fira-mono-latin-ext-400-normal-b6331a25.woff2 +0 -0
- .svelte-kit/output/client/_app/assets/pages/__layout.svelte-343606d7.css +1 -0
- {_app → .svelte-kit/output/client/_app}/assets/pages/about.svelte-bf4528fa.css +0 -0
- {_app → .svelte-kit/output/client/_app}/assets/pages/index.svelte-c63fe1c6.css +0 -0
- {_app → .svelte-kit/output/client/_app}/assets/pages/todos/index.svelte-784042c1.css +0 -0
- {_app → .svelte-kit/output/client/_app}/assets/start-61d1577b.css +0 -0
- {_app → .svelte-kit/output/client/_app}/assets/svelte-logo-87df40b8.svg +0 -0
- {_app → .svelte-kit/output/client/_app}/chunks/vendor-d68c61c2.js +0 -0
- {_app → .svelte-kit/output/client/_app}/error.svelte-97b7e85d.js +0 -0
- {_app → .svelte-kit/output/client/_app}/manifest.json +2 -2
- .svelte-kit/output/client/_app/pages/__layout.svelte-2dd96704.js +1 -0
- {_app → .svelte-kit/output/client/_app}/pages/about.svelte-a7982a52.js +0 -0
- {_app → .svelte-kit/output/client/_app}/pages/index.svelte-934bb81d.js +0 -0
- {_app → .svelte-kit/output/client/_app}/pages/todos/index.svelte-82693d56.js +0 -0
- .svelte-kit/output/client/_app/start-2ccc875c.js +1 -0
- .svelte-kit/output/server/app.js +1473 -0
- .svelte-kit/output/server/chunks/_api-cf43c630.js +26 -0
- .svelte-kit/output/server/chunks/index-c7a03ab5.js +159 -0
- .svelte-kit/output/server/entries/endpoints/todos/_uid_.json.js +11 -0
- .svelte-kit/output/server/entries/endpoints/todos/index.json.js +15 -0
- .svelte-kit/output/server/entries/pages/__layout.svelte.js +63 -0
- .svelte-kit/output/server/entries/pages/about.svelte.js +35 -0
- .svelte-kit/output/server/entries/pages/error.svelte.js +21 -0
- .svelte-kit/output/server/entries/pages/index.svelte.js +190 -0
- .svelte-kit/output/server/entries/pages/todos/index.svelte.js +37 -0
- .svelte-kit/output/server/manifest.js +53 -0
.DS_Store
ADDED
|
Binary file (6.15 kB). View file
|
|
|
.gitignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
node_modules
|
.pnpm-debug.log
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"0 debug pnpm:scope": {
|
| 3 |
+
"selected": 1
|
| 4 |
+
},
|
| 5 |
+
"1 error pnpm": {
|
| 6 |
+
"code": "ELIFECYCLE",
|
| 7 |
+
"errno": "ENOENT",
|
| 8 |
+
"syscall": "spawn",
|
| 9 |
+
"file": "sh",
|
| 10 |
+
"pkgid": "[email protected]",
|
| 11 |
+
"stage": "build",
|
| 12 |
+
"script": "svelte-kit build",
|
| 13 |
+
"pkgname": "my-app",
|
| 14 |
+
"err": {
|
| 15 |
+
"name": "pnpm",
|
| 16 |
+
"message": "[email protected] build: `svelte-kit build`\nspawn ENOENT",
|
| 17 |
+
"code": "ELIFECYCLE",
|
| 18 |
+
"stack": "pnpm: [email protected] build: `svelte-kit build`\nspawn ENOENT\n at ChildProcess.<anonymous> (/Users/peterallen/.volta/tools/image/packages/pnpm/lib/node_modules/pnpm/dist/pnpm.cjs:91465:22)\n at ChildProcess.emit (node:events:390:28)\n at maybeClose (node:internal/child_process:1064:16)\n at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)"
|
| 19 |
+
}
|
| 20 |
+
},
|
| 21 |
+
"2 warn pnpm:global": " Local package.json exists, but node_modules missing, did you mean to install?"
|
| 22 |
+
}
|
.svelte-kit/build/app.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
import { respond } from './kit.js';
|
| 3 |
+
import root from './generated/root.svelte';
|
| 4 |
+
import { set_paths, assets, base } from './runtime/paths.js';
|
| 5 |
+
import { set_prerendering } from './runtime/env.js';
|
| 6 |
+
import * as user_hooks from "../../src/hooks.js";
|
| 7 |
+
|
| 8 |
+
const template = ({ head, body, assets }) => "<!DOCTYPE html>\n<html lang=\"en\">\n\t<head>\n\t\t<meta charset=\"utf-8\" />\n\t\t<meta name=\"description\" content=\"Svelte demo app\" />\n\t\t<link rel=\"icon\" href=\"" + assets + "/favicon.png\" />\n\t\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n\t\t" + head + "\n\t</head>\n\t<body>\n\t\t<div id=\"svelte\">" + body + "</div>\n\t</body>\n</html>\n";
|
| 9 |
+
|
| 10 |
+
let read = null;
|
| 11 |
+
|
| 12 |
+
set_paths({"base":"/staticspaceiframe/spaces/pngwn/static-test","assets":""});
|
| 13 |
+
|
| 14 |
+
// this looks redundant, but the indirection allows us to access
|
| 15 |
+
// named imports without triggering Rollup's missing import detection
|
| 16 |
+
const get_hooks = hooks => ({
|
| 17 |
+
getSession: hooks.getSession || (() => ({})),
|
| 18 |
+
handle: hooks.handle || (({ request, resolve }) => resolve(request)),
|
| 19 |
+
handleError: hooks.handleError || (({ error }) => console.error(error.stack)),
|
| 20 |
+
externalFetch: hooks.externalFetch || fetch
|
| 21 |
+
});
|
| 22 |
+
|
| 23 |
+
let default_protocol = 'https';
|
| 24 |
+
|
| 25 |
+
// allow paths to be globally overridden
|
| 26 |
+
// in svelte-kit preview and in prerendering
|
| 27 |
+
export function override(settings) {
|
| 28 |
+
default_protocol = settings.protocol || default_protocol;
|
| 29 |
+
set_paths(settings.paths);
|
| 30 |
+
set_prerendering(settings.prerendering);
|
| 31 |
+
read = settings.read;
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
export class App {
|
| 35 |
+
constructor(manifest) {
|
| 36 |
+
const hooks = get_hooks(user_hooks);
|
| 37 |
+
|
| 38 |
+
this.options = {
|
| 39 |
+
amp: false,
|
| 40 |
+
dev: false,
|
| 41 |
+
floc: false,
|
| 42 |
+
get_stack: error => String(error), // for security
|
| 43 |
+
handle_error: (error, request) => {
|
| 44 |
+
hooks.handleError({ error, request });
|
| 45 |
+
error.stack = this.options.get_stack(error);
|
| 46 |
+
},
|
| 47 |
+
hooks,
|
| 48 |
+
hydrate: true,
|
| 49 |
+
manifest,
|
| 50 |
+
paths: { base, assets },
|
| 51 |
+
prefix: assets + '/_app/',
|
| 52 |
+
prerender: true,
|
| 53 |
+
read,
|
| 54 |
+
root,
|
| 55 |
+
service_worker: null,
|
| 56 |
+
router: true,
|
| 57 |
+
ssr: true,
|
| 58 |
+
target: "#svelte",
|
| 59 |
+
template,
|
| 60 |
+
trailing_slash: "never"
|
| 61 |
+
};
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
render(request, {
|
| 65 |
+
prerender
|
| 66 |
+
} = {}) {
|
| 67 |
+
// TODO remove this for 1.0
|
| 68 |
+
if (Object.keys(request).sort().join() !== 'headers,method,rawBody,url') {
|
| 69 |
+
throw new Error('Adapters should call app.render({ url, method, headers, rawBody })');
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
const host = request.headers["host"];
|
| 73 |
+
const protocol = default_protocol;
|
| 74 |
+
|
| 75 |
+
return respond({ ...request, url: new URL(request.url, protocol + '://' + host) }, this.options, { prerender });
|
| 76 |
+
}
|
| 77 |
+
}
|
.svelte-kit/build/components/error.svelte
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script context="module">
|
| 2 |
+
/** @type {import('@sveltejs/kit').ErrorLoad} */
|
| 3 |
+
export function load({ error, status }) {
|
| 4 |
+
return {
|
| 5 |
+
props: { error, status }
|
| 6 |
+
};
|
| 7 |
+
}
|
| 8 |
+
</script>
|
| 9 |
+
|
| 10 |
+
<script>
|
| 11 |
+
/** @type {number} */
|
| 12 |
+
export let status;
|
| 13 |
+
|
| 14 |
+
/** @type {Error & {frame?: string} & {loc?: object}} */
|
| 15 |
+
export let error;
|
| 16 |
+
</script>
|
| 17 |
+
|
| 18 |
+
<h1>{status}</h1>
|
| 19 |
+
|
| 20 |
+
<pre>{error.message}</pre>
|
| 21 |
+
|
| 22 |
+
<!-- TODO figure out what to do with frames/stacktraces in prod -->
|
| 23 |
+
<!-- frame is populated by Svelte in its CompileError and is a Rollup/Vite convention -->
|
| 24 |
+
{#if error.frame}
|
| 25 |
+
<pre>{error.frame}</pre>
|
| 26 |
+
{/if}
|
| 27 |
+
{#if error.stack}
|
| 28 |
+
<pre>{error.stack}</pre>
|
| 29 |
+
{/if}
|
.svelte-kit/build/components/layout.svelte
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
<slot></slot>
|
.svelte-kit/build/generated/manifest.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const c = [
|
| 2 |
+
() => import("../../../src/routes/__layout.svelte"),
|
| 3 |
+
() => import("../components/error.svelte"),
|
| 4 |
+
() => import("../../../src/routes/index.svelte"),
|
| 5 |
+
() => import("../../../src/routes/about.svelte"),
|
| 6 |
+
() => import("../../../src/routes/todos/index.svelte")
|
| 7 |
+
];
|
| 8 |
+
|
| 9 |
+
const d = decodeURIComponent;
|
| 10 |
+
|
| 11 |
+
export const routes = [
|
| 12 |
+
// src/routes/index.svelte
|
| 13 |
+
[/^\/$/, [c[0], c[2]], [c[1]]],
|
| 14 |
+
|
| 15 |
+
// src/routes/about.svelte
|
| 16 |
+
[/^\/about\/?$/, [c[0], c[3]], [c[1]]],
|
| 17 |
+
|
| 18 |
+
,
|
| 19 |
+
|
| 20 |
+
// src/routes/todos/index.svelte
|
| 21 |
+
[/^\/todos\/?$/, [c[0], c[4]], [c[1]]],
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
];
|
| 25 |
+
|
| 26 |
+
// we import the root layout/error components eagerly, so that
|
| 27 |
+
// connectivity errors after initialisation don't nuke the app
|
| 28 |
+
export const fallback = [c[0](), c[1]()];
|
.svelte-kit/build/generated/root.svelte
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!-- This file is generated by @sveltejs/kit — do not edit it! -->
|
| 2 |
+
<script>
|
| 3 |
+
import { setContext, afterUpdate, onMount } from 'svelte';
|
| 4 |
+
|
| 5 |
+
// stores
|
| 6 |
+
export let stores;
|
| 7 |
+
export let page;
|
| 8 |
+
|
| 9 |
+
export let components;
|
| 10 |
+
export let props_0 = null;
|
| 11 |
+
export let props_1 = null;
|
| 12 |
+
export let props_2 = null;
|
| 13 |
+
|
| 14 |
+
setContext('__svelte__', stores);
|
| 15 |
+
|
| 16 |
+
$: stores.page.set(page);
|
| 17 |
+
afterUpdate(stores.page.notify);
|
| 18 |
+
|
| 19 |
+
let mounted = false;
|
| 20 |
+
let navigated = false;
|
| 21 |
+
let title = null;
|
| 22 |
+
|
| 23 |
+
onMount(() => {
|
| 24 |
+
const unsubscribe = stores.page.subscribe(() => {
|
| 25 |
+
if (mounted) {
|
| 26 |
+
navigated = true;
|
| 27 |
+
title = document.title || 'untitled page';
|
| 28 |
+
}
|
| 29 |
+
});
|
| 30 |
+
|
| 31 |
+
mounted = true;
|
| 32 |
+
return unsubscribe;
|
| 33 |
+
});
|
| 34 |
+
</script>
|
| 35 |
+
|
| 36 |
+
{#if components[1]}
|
| 37 |
+
<svelte:component this={components[0]} {...(props_0 || {})}>
|
| 38 |
+
{#if components[2]}
|
| 39 |
+
<svelte:component this={components[1]} {...(props_1 || {})}>
|
| 40 |
+
<svelte:component this={components[2]} {...(props_2 || {})}/>
|
| 41 |
+
</svelte:component>
|
| 42 |
+
{:else}
|
| 43 |
+
<svelte:component this={components[1]} {...(props_1 || {})} />
|
| 44 |
+
{/if}
|
| 45 |
+
</svelte:component>
|
| 46 |
+
{:else}
|
| 47 |
+
<svelte:component this={components[0]} {...(props_0 || {})} />
|
| 48 |
+
{/if}
|
| 49 |
+
|
| 50 |
+
{#if mounted}
|
| 51 |
+
<div id="svelte-announcer" aria-live="assertive" aria-atomic="true">
|
| 52 |
+
{#if navigated}
|
| 53 |
+
{title}
|
| 54 |
+
{/if}
|
| 55 |
+
</div>
|
| 56 |
+
{/if}
|
| 57 |
+
|
| 58 |
+
<style>
|
| 59 |
+
#svelte-announcer {
|
| 60 |
+
position: absolute;
|
| 61 |
+
left: 0;
|
| 62 |
+
top: 0;
|
| 63 |
+
clip: rect(0 0 0 0);
|
| 64 |
+
clip-path: inset(50%);
|
| 65 |
+
overflow: hidden;
|
| 66 |
+
white-space: nowrap;
|
| 67 |
+
width: 1px;
|
| 68 |
+
height: 1px;
|
| 69 |
+
}
|
| 70 |
+
</style>
|
.svelte-kit/build/kit.js
ADDED
|
@@ -0,0 +1,1921 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* @param {Record<string, string | string[] | undefined>} headers
|
| 3 |
+
* @param {string} key
|
| 4 |
+
* @returns {string | undefined}
|
| 5 |
+
* @throws {Error}
|
| 6 |
+
*/
|
| 7 |
+
function get_single_valued_header(headers, key) {
|
| 8 |
+
const value = headers[key];
|
| 9 |
+
if (Array.isArray(value)) {
|
| 10 |
+
if (value.length === 0) {
|
| 11 |
+
return undefined;
|
| 12 |
+
}
|
| 13 |
+
if (value.length > 1) {
|
| 14 |
+
throw new Error(
|
| 15 |
+
`Multiple headers provided for ${key}. Multiple may be provided only for set-cookie`
|
| 16 |
+
);
|
| 17 |
+
}
|
| 18 |
+
return value[0];
|
| 19 |
+
}
|
| 20 |
+
return value;
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
/** @param {Record<string, any>} obj */
|
| 24 |
+
function lowercase_keys(obj) {
|
| 25 |
+
/** @type {Record<string, any>} */
|
| 26 |
+
const clone = {};
|
| 27 |
+
|
| 28 |
+
for (const key in obj) {
|
| 29 |
+
clone[key.toLowerCase()] = obj[key];
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
return clone;
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
/** @param {Record<string, string>} params */
|
| 36 |
+
function decode_params(params) {
|
| 37 |
+
for (const key in params) {
|
| 38 |
+
// input has already been decoded by decodeURI
|
| 39 |
+
// now handle the rest that decodeURIComponent would do
|
| 40 |
+
params[key] = params[key]
|
| 41 |
+
.replace(/%23/g, '#')
|
| 42 |
+
.replace(/%3[Bb]/g, ';')
|
| 43 |
+
.replace(/%2[Cc]/g, ',')
|
| 44 |
+
.replace(/%2[Ff]/g, '/')
|
| 45 |
+
.replace(/%3[Ff]/g, '?')
|
| 46 |
+
.replace(/%3[Aa]/g, ':')
|
| 47 |
+
.replace(/%40/g, '@')
|
| 48 |
+
.replace(/%26/g, '&')
|
| 49 |
+
.replace(/%3[Dd]/g, '=')
|
| 50 |
+
.replace(/%2[Bb]/g, '+')
|
| 51 |
+
.replace(/%24/g, '$');
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
return params;
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
/** @param {string} body */
|
| 58 |
+
function error(body) {
|
| 59 |
+
return {
|
| 60 |
+
status: 500,
|
| 61 |
+
body,
|
| 62 |
+
headers: {}
|
| 63 |
+
};
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
/** @param {unknown} s */
|
| 67 |
+
function is_string(s) {
|
| 68 |
+
return typeof s === 'string' || s instanceof String;
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
const text_types = new Set([
|
| 72 |
+
'application/xml',
|
| 73 |
+
'application/json',
|
| 74 |
+
'application/x-www-form-urlencoded',
|
| 75 |
+
'multipart/form-data'
|
| 76 |
+
]);
|
| 77 |
+
|
| 78 |
+
/**
|
| 79 |
+
* Decides how the body should be parsed based on its mime type. Should match what's in parse_body
|
| 80 |
+
*
|
| 81 |
+
* @param {string | undefined | null} content_type The `content-type` header of a request/response.
|
| 82 |
+
* @returns {boolean}
|
| 83 |
+
*/
|
| 84 |
+
function is_text(content_type) {
|
| 85 |
+
if (!content_type) return true; // defaults to json
|
| 86 |
+
const type = content_type.split(';')[0].toLowerCase(); // get the mime type
|
| 87 |
+
|
| 88 |
+
return type.startsWith('text/') || type.endsWith('+xml') || text_types.has(type);
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
/**
|
| 92 |
+
* @param {import('types/hooks').ServerRequest} request
|
| 93 |
+
* @param {import('types/internal').SSREndpoint} route
|
| 94 |
+
* @param {RegExpExecArray} match
|
| 95 |
+
* @returns {Promise<import('types/hooks').ServerResponse | undefined>}
|
| 96 |
+
*/
|
| 97 |
+
async function render_endpoint(request, route, match) {
|
| 98 |
+
const mod = await route.load();
|
| 99 |
+
|
| 100 |
+
/** @type {import('types/endpoint').RequestHandler} */
|
| 101 |
+
const handler = mod[request.method.toLowerCase().replace('delete', 'del')]; // 'delete' is a reserved word
|
| 102 |
+
|
| 103 |
+
if (!handler) {
|
| 104 |
+
return;
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
// we're mutating `request` so that we don't have to do { ...request, params }
|
| 108 |
+
// on the next line, since that breaks the getters that replace path, query and
|
| 109 |
+
// origin. We could revert that once we remove the getters
|
| 110 |
+
request.params = route.params ? decode_params(route.params(match)) : {};
|
| 111 |
+
|
| 112 |
+
const response = await handler(request);
|
| 113 |
+
const preface = `Invalid response from route ${request.url.pathname}`;
|
| 114 |
+
|
| 115 |
+
if (!response) {
|
| 116 |
+
return;
|
| 117 |
+
}
|
| 118 |
+
if (typeof response !== 'object') {
|
| 119 |
+
return error(`${preface}: expected an object, got ${typeof response}`);
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
let { status = 200, body, headers = {} } = response;
|
| 123 |
+
|
| 124 |
+
headers = lowercase_keys(headers);
|
| 125 |
+
const type = get_single_valued_header(headers, 'content-type');
|
| 126 |
+
|
| 127 |
+
if (!is_text(type) && !(body instanceof Uint8Array || is_string(body))) {
|
| 128 |
+
return error(
|
| 129 |
+
`${preface}: body must be an instance of string or Uint8Array if content-type is not a supported textual content-type`
|
| 130 |
+
);
|
| 131 |
+
}
|
| 132 |
+
|
| 133 |
+
/** @type {import('types/hooks').StrictBody} */
|
| 134 |
+
let normalized_body;
|
| 135 |
+
|
| 136 |
+
// ensure the body is an object
|
| 137 |
+
if (
|
| 138 |
+
(typeof body === 'object' || typeof body === 'undefined') &&
|
| 139 |
+
!(body instanceof Uint8Array) &&
|
| 140 |
+
(!type || type.startsWith('application/json'))
|
| 141 |
+
) {
|
| 142 |
+
headers = { ...headers, 'content-type': 'application/json; charset=utf-8' };
|
| 143 |
+
normalized_body = JSON.stringify(typeof body === 'undefined' ? {} : body);
|
| 144 |
+
} else {
|
| 145 |
+
normalized_body = /** @type {import('types/hooks').StrictBody} */ (body);
|
| 146 |
+
}
|
| 147 |
+
|
| 148 |
+
return { status, body: normalized_body, headers };
|
| 149 |
+
}
|
| 150 |
+
|
| 151 |
+
var chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_$';
|
| 152 |
+
var unsafeChars = /[<>\b\f\n\r\t\0\u2028\u2029]/g;
|
| 153 |
+
var reserved = /^(?:do|if|in|for|int|let|new|try|var|byte|case|char|else|enum|goto|long|this|void|with|await|break|catch|class|const|final|float|short|super|throw|while|yield|delete|double|export|import|native|return|switch|throws|typeof|boolean|default|extends|finally|package|private|abstract|continue|debugger|function|volatile|interface|protected|transient|implements|instanceof|synchronized)$/;
|
| 154 |
+
var escaped = {
|
| 155 |
+
'<': '\\u003C',
|
| 156 |
+
'>': '\\u003E',
|
| 157 |
+
'/': '\\u002F',
|
| 158 |
+
'\\': '\\\\',
|
| 159 |
+
'\b': '\\b',
|
| 160 |
+
'\f': '\\f',
|
| 161 |
+
'\n': '\\n',
|
| 162 |
+
'\r': '\\r',
|
| 163 |
+
'\t': '\\t',
|
| 164 |
+
'\0': '\\0',
|
| 165 |
+
'\u2028': '\\u2028',
|
| 166 |
+
'\u2029': '\\u2029'
|
| 167 |
+
};
|
| 168 |
+
var objectProtoOwnPropertyNames = Object.getOwnPropertyNames(Object.prototype).sort().join('\0');
|
| 169 |
+
function devalue(value) {
|
| 170 |
+
var counts = new Map();
|
| 171 |
+
function walk(thing) {
|
| 172 |
+
if (typeof thing === 'function') {
|
| 173 |
+
throw new Error("Cannot stringify a function");
|
| 174 |
+
}
|
| 175 |
+
if (counts.has(thing)) {
|
| 176 |
+
counts.set(thing, counts.get(thing) + 1);
|
| 177 |
+
return;
|
| 178 |
+
}
|
| 179 |
+
counts.set(thing, 1);
|
| 180 |
+
if (!isPrimitive(thing)) {
|
| 181 |
+
var type = getType(thing);
|
| 182 |
+
switch (type) {
|
| 183 |
+
case 'Number':
|
| 184 |
+
case 'String':
|
| 185 |
+
case 'Boolean':
|
| 186 |
+
case 'Date':
|
| 187 |
+
case 'RegExp':
|
| 188 |
+
return;
|
| 189 |
+
case 'Array':
|
| 190 |
+
thing.forEach(walk);
|
| 191 |
+
break;
|
| 192 |
+
case 'Set':
|
| 193 |
+
case 'Map':
|
| 194 |
+
Array.from(thing).forEach(walk);
|
| 195 |
+
break;
|
| 196 |
+
default:
|
| 197 |
+
var proto = Object.getPrototypeOf(thing);
|
| 198 |
+
if (proto !== Object.prototype &&
|
| 199 |
+
proto !== null &&
|
| 200 |
+
Object.getOwnPropertyNames(proto).sort().join('\0') !== objectProtoOwnPropertyNames) {
|
| 201 |
+
throw new Error("Cannot stringify arbitrary non-POJOs");
|
| 202 |
+
}
|
| 203 |
+
if (Object.getOwnPropertySymbols(thing).length > 0) {
|
| 204 |
+
throw new Error("Cannot stringify POJOs with symbolic keys");
|
| 205 |
+
}
|
| 206 |
+
Object.keys(thing).forEach(function (key) { return walk(thing[key]); });
|
| 207 |
+
}
|
| 208 |
+
}
|
| 209 |
+
}
|
| 210 |
+
walk(value);
|
| 211 |
+
var names = new Map();
|
| 212 |
+
Array.from(counts)
|
| 213 |
+
.filter(function (entry) { return entry[1] > 1; })
|
| 214 |
+
.sort(function (a, b) { return b[1] - a[1]; })
|
| 215 |
+
.forEach(function (entry, i) {
|
| 216 |
+
names.set(entry[0], getName(i));
|
| 217 |
+
});
|
| 218 |
+
function stringify(thing) {
|
| 219 |
+
if (names.has(thing)) {
|
| 220 |
+
return names.get(thing);
|
| 221 |
+
}
|
| 222 |
+
if (isPrimitive(thing)) {
|
| 223 |
+
return stringifyPrimitive(thing);
|
| 224 |
+
}
|
| 225 |
+
var type = getType(thing);
|
| 226 |
+
switch (type) {
|
| 227 |
+
case 'Number':
|
| 228 |
+
case 'String':
|
| 229 |
+
case 'Boolean':
|
| 230 |
+
return "Object(" + stringify(thing.valueOf()) + ")";
|
| 231 |
+
case 'RegExp':
|
| 232 |
+
return "new RegExp(" + stringifyString(thing.source) + ", \"" + thing.flags + "\")";
|
| 233 |
+
case 'Date':
|
| 234 |
+
return "new Date(" + thing.getTime() + ")";
|
| 235 |
+
case 'Array':
|
| 236 |
+
var members = thing.map(function (v, i) { return i in thing ? stringify(v) : ''; });
|
| 237 |
+
var tail = thing.length === 0 || (thing.length - 1 in thing) ? '' : ',';
|
| 238 |
+
return "[" + members.join(',') + tail + "]";
|
| 239 |
+
case 'Set':
|
| 240 |
+
case 'Map':
|
| 241 |
+
return "new " + type + "([" + Array.from(thing).map(stringify).join(',') + "])";
|
| 242 |
+
default:
|
| 243 |
+
var obj = "{" + Object.keys(thing).map(function (key) { return safeKey(key) + ":" + stringify(thing[key]); }).join(',') + "}";
|
| 244 |
+
var proto = Object.getPrototypeOf(thing);
|
| 245 |
+
if (proto === null) {
|
| 246 |
+
return Object.keys(thing).length > 0
|
| 247 |
+
? "Object.assign(Object.create(null)," + obj + ")"
|
| 248 |
+
: "Object.create(null)";
|
| 249 |
+
}
|
| 250 |
+
return obj;
|
| 251 |
+
}
|
| 252 |
+
}
|
| 253 |
+
var str = stringify(value);
|
| 254 |
+
if (names.size) {
|
| 255 |
+
var params_1 = [];
|
| 256 |
+
var statements_1 = [];
|
| 257 |
+
var values_1 = [];
|
| 258 |
+
names.forEach(function (name, thing) {
|
| 259 |
+
params_1.push(name);
|
| 260 |
+
if (isPrimitive(thing)) {
|
| 261 |
+
values_1.push(stringifyPrimitive(thing));
|
| 262 |
+
return;
|
| 263 |
+
}
|
| 264 |
+
var type = getType(thing);
|
| 265 |
+
switch (type) {
|
| 266 |
+
case 'Number':
|
| 267 |
+
case 'String':
|
| 268 |
+
case 'Boolean':
|
| 269 |
+
values_1.push("Object(" + stringify(thing.valueOf()) + ")");
|
| 270 |
+
break;
|
| 271 |
+
case 'RegExp':
|
| 272 |
+
values_1.push(thing.toString());
|
| 273 |
+
break;
|
| 274 |
+
case 'Date':
|
| 275 |
+
values_1.push("new Date(" + thing.getTime() + ")");
|
| 276 |
+
break;
|
| 277 |
+
case 'Array':
|
| 278 |
+
values_1.push("Array(" + thing.length + ")");
|
| 279 |
+
thing.forEach(function (v, i) {
|
| 280 |
+
statements_1.push(name + "[" + i + "]=" + stringify(v));
|
| 281 |
+
});
|
| 282 |
+
break;
|
| 283 |
+
case 'Set':
|
| 284 |
+
values_1.push("new Set");
|
| 285 |
+
statements_1.push(name + "." + Array.from(thing).map(function (v) { return "add(" + stringify(v) + ")"; }).join('.'));
|
| 286 |
+
break;
|
| 287 |
+
case 'Map':
|
| 288 |
+
values_1.push("new Map");
|
| 289 |
+
statements_1.push(name + "." + Array.from(thing).map(function (_a) {
|
| 290 |
+
var k = _a[0], v = _a[1];
|
| 291 |
+
return "set(" + stringify(k) + ", " + stringify(v) + ")";
|
| 292 |
+
}).join('.'));
|
| 293 |
+
break;
|
| 294 |
+
default:
|
| 295 |
+
values_1.push(Object.getPrototypeOf(thing) === null ? 'Object.create(null)' : '{}');
|
| 296 |
+
Object.keys(thing).forEach(function (key) {
|
| 297 |
+
statements_1.push("" + name + safeProp(key) + "=" + stringify(thing[key]));
|
| 298 |
+
});
|
| 299 |
+
}
|
| 300 |
+
});
|
| 301 |
+
statements_1.push("return " + str);
|
| 302 |
+
return "(function(" + params_1.join(',') + "){" + statements_1.join(';') + "}(" + values_1.join(',') + "))";
|
| 303 |
+
}
|
| 304 |
+
else {
|
| 305 |
+
return str;
|
| 306 |
+
}
|
| 307 |
+
}
|
| 308 |
+
function getName(num) {
|
| 309 |
+
var name = '';
|
| 310 |
+
do {
|
| 311 |
+
name = chars[num % chars.length] + name;
|
| 312 |
+
num = ~~(num / chars.length) - 1;
|
| 313 |
+
} while (num >= 0);
|
| 314 |
+
return reserved.test(name) ? name + "_" : name;
|
| 315 |
+
}
|
| 316 |
+
function isPrimitive(thing) {
|
| 317 |
+
return Object(thing) !== thing;
|
| 318 |
+
}
|
| 319 |
+
function stringifyPrimitive(thing) {
|
| 320 |
+
if (typeof thing === 'string')
|
| 321 |
+
return stringifyString(thing);
|
| 322 |
+
if (thing === void 0)
|
| 323 |
+
return 'void 0';
|
| 324 |
+
if (thing === 0 && 1 / thing < 0)
|
| 325 |
+
return '-0';
|
| 326 |
+
var str = String(thing);
|
| 327 |
+
if (typeof thing === 'number')
|
| 328 |
+
return str.replace(/^(-)?0\./, '$1.');
|
| 329 |
+
return str;
|
| 330 |
+
}
|
| 331 |
+
function getType(thing) {
|
| 332 |
+
return Object.prototype.toString.call(thing).slice(8, -1);
|
| 333 |
+
}
|
| 334 |
+
function escapeUnsafeChar(c) {
|
| 335 |
+
return escaped[c] || c;
|
| 336 |
+
}
|
| 337 |
+
function escapeUnsafeChars(str) {
|
| 338 |
+
return str.replace(unsafeChars, escapeUnsafeChar);
|
| 339 |
+
}
|
| 340 |
+
function safeKey(key) {
|
| 341 |
+
return /^[_$a-zA-Z][_$a-zA-Z0-9]*$/.test(key) ? key : escapeUnsafeChars(JSON.stringify(key));
|
| 342 |
+
}
|
| 343 |
+
function safeProp(key) {
|
| 344 |
+
return /^[_$a-zA-Z][_$a-zA-Z0-9]*$/.test(key) ? "." + key : "[" + escapeUnsafeChars(JSON.stringify(key)) + "]";
|
| 345 |
+
}
|
| 346 |
+
function stringifyString(str) {
|
| 347 |
+
var result = '"';
|
| 348 |
+
for (var i = 0; i < str.length; i += 1) {
|
| 349 |
+
var char = str.charAt(i);
|
| 350 |
+
var code = char.charCodeAt(0);
|
| 351 |
+
if (char === '"') {
|
| 352 |
+
result += '\\"';
|
| 353 |
+
}
|
| 354 |
+
else if (char in escaped) {
|
| 355 |
+
result += escaped[char];
|
| 356 |
+
}
|
| 357 |
+
else if (code >= 0xd800 && code <= 0xdfff) {
|
| 358 |
+
var next = str.charCodeAt(i + 1);
|
| 359 |
+
// If this is the beginning of a [high, low] surrogate pair,
|
| 360 |
+
// add the next two characters, otherwise escape
|
| 361 |
+
if (code <= 0xdbff && (next >= 0xdc00 && next <= 0xdfff)) {
|
| 362 |
+
result += char + str[++i];
|
| 363 |
+
}
|
| 364 |
+
else {
|
| 365 |
+
result += "\\u" + code.toString(16).toUpperCase();
|
| 366 |
+
}
|
| 367 |
+
}
|
| 368 |
+
else {
|
| 369 |
+
result += char;
|
| 370 |
+
}
|
| 371 |
+
}
|
| 372 |
+
result += '"';
|
| 373 |
+
return result;
|
| 374 |
+
}
|
| 375 |
+
|
| 376 |
+
function noop() { }
|
| 377 |
+
function safe_not_equal(a, b) {
|
| 378 |
+
return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function');
|
| 379 |
+
}
|
| 380 |
+
Promise.resolve();
|
| 381 |
+
|
| 382 |
+
const subscriber_queue = [];
|
| 383 |
+
/**
|
| 384 |
+
* Create a `Writable` store that allows both updating and reading by subscription.
|
| 385 |
+
* @param {*=}value initial value
|
| 386 |
+
* @param {StartStopNotifier=}start start and stop notifications for subscriptions
|
| 387 |
+
*/
|
| 388 |
+
function writable(value, start = noop) {
|
| 389 |
+
let stop;
|
| 390 |
+
const subscribers = new Set();
|
| 391 |
+
function set(new_value) {
|
| 392 |
+
if (safe_not_equal(value, new_value)) {
|
| 393 |
+
value = new_value;
|
| 394 |
+
if (stop) { // store is ready
|
| 395 |
+
const run_queue = !subscriber_queue.length;
|
| 396 |
+
for (const subscriber of subscribers) {
|
| 397 |
+
subscriber[1]();
|
| 398 |
+
subscriber_queue.push(subscriber, value);
|
| 399 |
+
}
|
| 400 |
+
if (run_queue) {
|
| 401 |
+
for (let i = 0; i < subscriber_queue.length; i += 2) {
|
| 402 |
+
subscriber_queue[i][0](subscriber_queue[i + 1]);
|
| 403 |
+
}
|
| 404 |
+
subscriber_queue.length = 0;
|
| 405 |
+
}
|
| 406 |
+
}
|
| 407 |
+
}
|
| 408 |
+
}
|
| 409 |
+
function update(fn) {
|
| 410 |
+
set(fn(value));
|
| 411 |
+
}
|
| 412 |
+
function subscribe(run, invalidate = noop) {
|
| 413 |
+
const subscriber = [run, invalidate];
|
| 414 |
+
subscribers.add(subscriber);
|
| 415 |
+
if (subscribers.size === 1) {
|
| 416 |
+
stop = start(set) || noop;
|
| 417 |
+
}
|
| 418 |
+
run(value);
|
| 419 |
+
return () => {
|
| 420 |
+
subscribers.delete(subscriber);
|
| 421 |
+
if (subscribers.size === 0) {
|
| 422 |
+
stop();
|
| 423 |
+
stop = null;
|
| 424 |
+
}
|
| 425 |
+
};
|
| 426 |
+
}
|
| 427 |
+
return { set, update, subscribe };
|
| 428 |
+
}
|
| 429 |
+
|
| 430 |
+
/**
|
| 431 |
+
* @param {unknown} err
|
| 432 |
+
* @return {Error}
|
| 433 |
+
*/
|
| 434 |
+
function coalesce_to_error(err) {
|
| 435 |
+
return err instanceof Error ||
|
| 436 |
+
(err && /** @type {any} */ (err).name && /** @type {any} */ (err).message)
|
| 437 |
+
? /** @type {Error} */ (err)
|
| 438 |
+
: new Error(JSON.stringify(err));
|
| 439 |
+
}
|
| 440 |
+
|
| 441 |
+
/**
|
| 442 |
+
* Hash using djb2
|
| 443 |
+
* @param {import('types/hooks').StrictBody} value
|
| 444 |
+
*/
|
| 445 |
+
function hash(value) {
|
| 446 |
+
let hash = 5381;
|
| 447 |
+
let i = value.length;
|
| 448 |
+
|
| 449 |
+
if (typeof value === 'string') {
|
| 450 |
+
while (i) hash = (hash * 33) ^ value.charCodeAt(--i);
|
| 451 |
+
} else {
|
| 452 |
+
while (i) hash = (hash * 33) ^ value[--i];
|
| 453 |
+
}
|
| 454 |
+
|
| 455 |
+
return (hash >>> 0).toString(36);
|
| 456 |
+
}
|
| 457 |
+
|
| 458 |
+
/** @type {Record<string, string>} */
|
| 459 |
+
const escape_json_string_in_html_dict = {
|
| 460 |
+
'"': '\\"',
|
| 461 |
+
'<': '\\u003C',
|
| 462 |
+
'>': '\\u003E',
|
| 463 |
+
'/': '\\u002F',
|
| 464 |
+
'\\': '\\\\',
|
| 465 |
+
'\b': '\\b',
|
| 466 |
+
'\f': '\\f',
|
| 467 |
+
'\n': '\\n',
|
| 468 |
+
'\r': '\\r',
|
| 469 |
+
'\t': '\\t',
|
| 470 |
+
'\0': '\\0',
|
| 471 |
+
'\u2028': '\\u2028',
|
| 472 |
+
'\u2029': '\\u2029'
|
| 473 |
+
};
|
| 474 |
+
|
| 475 |
+
/** @param {string} str */
|
| 476 |
+
function escape_json_string_in_html(str) {
|
| 477 |
+
return escape(
|
| 478 |
+
str,
|
| 479 |
+
escape_json_string_in_html_dict,
|
| 480 |
+
(code) => `\\u${code.toString(16).toUpperCase()}`
|
| 481 |
+
);
|
| 482 |
+
}
|
| 483 |
+
|
| 484 |
+
/** @type {Record<string, string>} */
|
| 485 |
+
const escape_html_attr_dict = {
|
| 486 |
+
'<': '<',
|
| 487 |
+
'>': '>',
|
| 488 |
+
'"': '"'
|
| 489 |
+
};
|
| 490 |
+
|
| 491 |
+
/**
|
| 492 |
+
* use for escaping string values to be used html attributes on the page
|
| 493 |
+
* e.g.
|
| 494 |
+
* <script data-url="here">
|
| 495 |
+
*
|
| 496 |
+
* @param {string} str
|
| 497 |
+
* @returns string escaped string
|
| 498 |
+
*/
|
| 499 |
+
function escape_html_attr(str) {
|
| 500 |
+
return '"' + escape(str, escape_html_attr_dict, (code) => `&#${code};`) + '"';
|
| 501 |
+
}
|
| 502 |
+
|
| 503 |
+
/**
|
| 504 |
+
*
|
| 505 |
+
* @param str {string} string to escape
|
| 506 |
+
* @param dict {Record<string, string>} dictionary of character replacements
|
| 507 |
+
* @param unicode_encoder {function(number): string} encoder to use for high unicode characters
|
| 508 |
+
* @returns {string}
|
| 509 |
+
*/
|
| 510 |
+
function escape(str, dict, unicode_encoder) {
|
| 511 |
+
let result = '';
|
| 512 |
+
|
| 513 |
+
for (let i = 0; i < str.length; i += 1) {
|
| 514 |
+
const char = str.charAt(i);
|
| 515 |
+
const code = char.charCodeAt(0);
|
| 516 |
+
|
| 517 |
+
if (char in dict) {
|
| 518 |
+
result += dict[char];
|
| 519 |
+
} else if (code >= 0xd800 && code <= 0xdfff) {
|
| 520 |
+
const next = str.charCodeAt(i + 1);
|
| 521 |
+
|
| 522 |
+
// If this is the beginning of a [high, low] surrogate pair,
|
| 523 |
+
// add the next two characters, otherwise escape
|
| 524 |
+
if (code <= 0xdbff && next >= 0xdc00 && next <= 0xdfff) {
|
| 525 |
+
result += char + str[++i];
|
| 526 |
+
} else {
|
| 527 |
+
result += unicode_encoder(code);
|
| 528 |
+
}
|
| 529 |
+
} else {
|
| 530 |
+
result += char;
|
| 531 |
+
}
|
| 532 |
+
}
|
| 533 |
+
|
| 534 |
+
return result;
|
| 535 |
+
}
|
| 536 |
+
|
| 537 |
+
const s = JSON.stringify;
|
| 538 |
+
|
| 539 |
+
// TODO rename this function/module
|
| 540 |
+
|
| 541 |
+
/**
|
| 542 |
+
* @param {{
|
| 543 |
+
* branch: Array<import('./types').Loaded>;
|
| 544 |
+
* options: import('types/internal').SSRRenderOptions;
|
| 545 |
+
* $session: any;
|
| 546 |
+
* page_config: { hydrate: boolean, router: boolean, ssr: boolean };
|
| 547 |
+
* status: number;
|
| 548 |
+
* error?: Error,
|
| 549 |
+
* url: URL;
|
| 550 |
+
* params: Record<string, string>
|
| 551 |
+
* }} opts
|
| 552 |
+
*/
|
| 553 |
+
async function render_response({
|
| 554 |
+
branch,
|
| 555 |
+
options,
|
| 556 |
+
$session,
|
| 557 |
+
page_config,
|
| 558 |
+
status,
|
| 559 |
+
error,
|
| 560 |
+
url,
|
| 561 |
+
params
|
| 562 |
+
}) {
|
| 563 |
+
const css = new Set(options.manifest._.entry.css);
|
| 564 |
+
const js = new Set(options.manifest._.entry.js);
|
| 565 |
+
const styles = new Set();
|
| 566 |
+
|
| 567 |
+
/** @type {Array<{ url: string, body: string, json: string }>} */
|
| 568 |
+
const serialized_data = [];
|
| 569 |
+
|
| 570 |
+
let rendered;
|
| 571 |
+
|
| 572 |
+
let is_private = false;
|
| 573 |
+
let maxage;
|
| 574 |
+
|
| 575 |
+
if (error) {
|
| 576 |
+
error.stack = options.get_stack(error);
|
| 577 |
+
}
|
| 578 |
+
|
| 579 |
+
if (page_config.ssr) {
|
| 580 |
+
branch.forEach(({ node, loaded, fetched, uses_credentials }) => {
|
| 581 |
+
if (node.css) node.css.forEach((url) => css.add(url));
|
| 582 |
+
if (node.js) node.js.forEach((url) => js.add(url));
|
| 583 |
+
if (node.styles) node.styles.forEach((content) => styles.add(content));
|
| 584 |
+
|
| 585 |
+
// TODO probably better if `fetched` wasn't populated unless `hydrate`
|
| 586 |
+
if (fetched && page_config.hydrate) serialized_data.push(...fetched);
|
| 587 |
+
|
| 588 |
+
if (uses_credentials) is_private = true;
|
| 589 |
+
|
| 590 |
+
maxage = loaded.maxage;
|
| 591 |
+
});
|
| 592 |
+
|
| 593 |
+
const session = writable($session);
|
| 594 |
+
|
| 595 |
+
/** @type {Record<string, any>} */
|
| 596 |
+
const props = {
|
| 597 |
+
stores: {
|
| 598 |
+
page: writable(null),
|
| 599 |
+
navigating: writable(null),
|
| 600 |
+
session
|
| 601 |
+
},
|
| 602 |
+
page: { url, params, status, error },
|
| 603 |
+
components: branch.map(({ node }) => node.module.default)
|
| 604 |
+
};
|
| 605 |
+
|
| 606 |
+
// TODO remove this for 1.0
|
| 607 |
+
/**
|
| 608 |
+
* @param {string} property
|
| 609 |
+
* @param {string} replacement
|
| 610 |
+
*/
|
| 611 |
+
const print_error = (property, replacement) => {
|
| 612 |
+
Object.defineProperty(props.page, property, {
|
| 613 |
+
get: () => {
|
| 614 |
+
throw new Error(`$page.${property} has been replaced by $page.url.${replacement}`);
|
| 615 |
+
}
|
| 616 |
+
});
|
| 617 |
+
};
|
| 618 |
+
|
| 619 |
+
print_error('origin', 'origin');
|
| 620 |
+
print_error('path', 'pathname');
|
| 621 |
+
print_error('query', 'searchParams');
|
| 622 |
+
|
| 623 |
+
// props_n (instead of props[n]) makes it easy to avoid
|
| 624 |
+
// unnecessary updates for layout components
|
| 625 |
+
for (let i = 0; i < branch.length; i += 1) {
|
| 626 |
+
props[`props_${i}`] = await branch[i].loaded.props;
|
| 627 |
+
}
|
| 628 |
+
|
| 629 |
+
let session_tracking_active = false;
|
| 630 |
+
const unsubscribe = session.subscribe(() => {
|
| 631 |
+
if (session_tracking_active) is_private = true;
|
| 632 |
+
});
|
| 633 |
+
session_tracking_active = true;
|
| 634 |
+
|
| 635 |
+
try {
|
| 636 |
+
rendered = options.root.render(props);
|
| 637 |
+
} finally {
|
| 638 |
+
unsubscribe();
|
| 639 |
+
}
|
| 640 |
+
} else {
|
| 641 |
+
rendered = { head: '', html: '', css: { code: '', map: null } };
|
| 642 |
+
}
|
| 643 |
+
|
| 644 |
+
const include_js = page_config.router || page_config.hydrate;
|
| 645 |
+
if (!include_js) js.clear();
|
| 646 |
+
|
| 647 |
+
// TODO strip the AMP stuff out of the build if not relevant
|
| 648 |
+
const links = options.amp
|
| 649 |
+
? styles.size > 0 || rendered.css.code.length > 0
|
| 650 |
+
? `<style amp-custom>${Array.from(styles).concat(rendered.css.code).join('\n')}</style>`
|
| 651 |
+
: ''
|
| 652 |
+
: [
|
| 653 |
+
// From https://web.dev/priority-hints/:
|
| 654 |
+
// Generally, preloads will load in the order the parser gets to them for anything above "Medium" priority
|
| 655 |
+
// Thus, we should list CSS first
|
| 656 |
+
...Array.from(css).map((dep) => `<link rel="stylesheet" href="${options.prefix}${dep}">`),
|
| 657 |
+
...Array.from(js).map((dep) => `<link rel="modulepreload" href="${options.prefix}${dep}">`)
|
| 658 |
+
].join('\n\t\t');
|
| 659 |
+
|
| 660 |
+
/** @type {string} */
|
| 661 |
+
let init = '';
|
| 662 |
+
|
| 663 |
+
if (options.amp) {
|
| 664 |
+
init = `
|
| 665 |
+
<style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style>
|
| 666 |
+
<noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style></noscript>
|
| 667 |
+
<script async src="https://cdn.ampproject.org/v0.js"></script>`;
|
| 668 |
+
init += options.service_worker
|
| 669 |
+
? '<script async custom-element="amp-install-serviceworker" src="https://cdn.ampproject.org/v0/amp-install-serviceworker-0.1.js"></script>'
|
| 670 |
+
: '';
|
| 671 |
+
} else if (include_js) {
|
| 672 |
+
// prettier-ignore
|
| 673 |
+
init = `<script type="module">
|
| 674 |
+
import { start } from ${s(options.prefix + options.manifest._.entry.file)};
|
| 675 |
+
start({
|
| 676 |
+
target: ${options.target ? `document.querySelector(${s(options.target)})` : 'document.body'},
|
| 677 |
+
paths: ${s(options.paths)},
|
| 678 |
+
session: ${try_serialize($session, (error) => {
|
| 679 |
+
throw new Error(`Failed to serialize session data: ${error.message}`);
|
| 680 |
+
})},
|
| 681 |
+
route: ${!!page_config.router},
|
| 682 |
+
spa: ${!page_config.ssr},
|
| 683 |
+
trailing_slash: ${s(options.trailing_slash)},
|
| 684 |
+
hydrate: ${page_config.ssr && page_config.hydrate ? `{
|
| 685 |
+
status: ${status},
|
| 686 |
+
error: ${serialize_error(error)},
|
| 687 |
+
nodes: [
|
| 688 |
+
${(branch || [])
|
| 689 |
+
.map(({ node }) => `import(${s(options.prefix + node.entry)})`)
|
| 690 |
+
.join(',\n\t\t\t\t\t\t')}
|
| 691 |
+
],
|
| 692 |
+
url: new URL(${s(url.href)}),
|
| 693 |
+
params: ${devalue(params)}
|
| 694 |
+
}` : 'null'}
|
| 695 |
+
});
|
| 696 |
+
</script>`;
|
| 697 |
+
}
|
| 698 |
+
|
| 699 |
+
if (options.service_worker && !options.amp) {
|
| 700 |
+
init += `<script>
|
| 701 |
+
if ('serviceWorker' in navigator) {
|
| 702 |
+
navigator.serviceWorker.register('${options.service_worker}');
|
| 703 |
+
}
|
| 704 |
+
</script>`;
|
| 705 |
+
}
|
| 706 |
+
|
| 707 |
+
const head = [
|
| 708 |
+
rendered.head,
|
| 709 |
+
styles.size && !options.amp
|
| 710 |
+
? `<style data-svelte>${Array.from(styles).join('\n')}</style>`
|
| 711 |
+
: '',
|
| 712 |
+
links,
|
| 713 |
+
init
|
| 714 |
+
].join('\n\n\t\t');
|
| 715 |
+
|
| 716 |
+
let body = rendered.html;
|
| 717 |
+
if (options.amp) {
|
| 718 |
+
if (options.service_worker) {
|
| 719 |
+
body += `<amp-install-serviceworker src="${options.service_worker}" layout="nodisplay"></amp-install-serviceworker>`;
|
| 720 |
+
}
|
| 721 |
+
} else {
|
| 722 |
+
body += serialized_data
|
| 723 |
+
.map(({ url, body, json }) => {
|
| 724 |
+
let attributes = `type="application/json" data-type="svelte-data" data-url=${escape_html_attr(
|
| 725 |
+
url
|
| 726 |
+
)}`;
|
| 727 |
+
if (body) attributes += ` data-body="${hash(body)}"`;
|
| 728 |
+
|
| 729 |
+
return `<script ${attributes}>${json}</script>`;
|
| 730 |
+
})
|
| 731 |
+
.join('\n\n\t');
|
| 732 |
+
}
|
| 733 |
+
|
| 734 |
+
/** @type {import('types/helper').ResponseHeaders} */
|
| 735 |
+
const headers = {
|
| 736 |
+
'content-type': 'text/html'
|
| 737 |
+
};
|
| 738 |
+
|
| 739 |
+
if (maxage) {
|
| 740 |
+
headers['cache-control'] = `${is_private ? 'private' : 'public'}, max-age=${maxage}`;
|
| 741 |
+
}
|
| 742 |
+
|
| 743 |
+
if (!options.floc) {
|
| 744 |
+
headers['permissions-policy'] = 'interest-cohort=()';
|
| 745 |
+
}
|
| 746 |
+
|
| 747 |
+
const segments = url.pathname.slice(options.paths.base.length).split('/').slice(2);
|
| 748 |
+
const assets =
|
| 749 |
+
options.paths.assets || (segments.length > 0 ? segments.map(() => '..').join('/') : '.');
|
| 750 |
+
|
| 751 |
+
return {
|
| 752 |
+
status,
|
| 753 |
+
headers,
|
| 754 |
+
body: options.template({
|
| 755 |
+
head,
|
| 756 |
+
body,
|
| 757 |
+
assets
|
| 758 |
+
})
|
| 759 |
+
};
|
| 760 |
+
}
|
| 761 |
+
|
| 762 |
+
/**
|
| 763 |
+
* @param {any} data
|
| 764 |
+
* @param {(error: Error) => void} [fail]
|
| 765 |
+
*/
|
| 766 |
+
function try_serialize(data, fail) {
|
| 767 |
+
try {
|
| 768 |
+
return devalue(data);
|
| 769 |
+
} catch (err) {
|
| 770 |
+
if (fail) fail(coalesce_to_error(err));
|
| 771 |
+
return null;
|
| 772 |
+
}
|
| 773 |
+
}
|
| 774 |
+
|
| 775 |
+
// Ensure we return something truthy so the client will not re-render the page over the error
|
| 776 |
+
|
| 777 |
+
/** @param {(Error & {frame?: string} & {loc?: object}) | undefined | null} error */
|
| 778 |
+
function serialize_error(error) {
|
| 779 |
+
if (!error) return null;
|
| 780 |
+
let serialized = try_serialize(error);
|
| 781 |
+
if (!serialized) {
|
| 782 |
+
const { name, message, stack } = error;
|
| 783 |
+
serialized = try_serialize({ ...error, name, message, stack });
|
| 784 |
+
}
|
| 785 |
+
if (!serialized) {
|
| 786 |
+
serialized = '{}';
|
| 787 |
+
}
|
| 788 |
+
return serialized;
|
| 789 |
+
}
|
| 790 |
+
|
| 791 |
+
/**
|
| 792 |
+
* @param {import('types/page').LoadOutput} loaded
|
| 793 |
+
* @returns {import('types/internal').NormalizedLoadOutput}
|
| 794 |
+
*/
|
| 795 |
+
function normalize(loaded) {
|
| 796 |
+
const has_error_status =
|
| 797 |
+
loaded.status && loaded.status >= 400 && loaded.status <= 599 && !loaded.redirect;
|
| 798 |
+
if (loaded.error || has_error_status) {
|
| 799 |
+
const status = loaded.status;
|
| 800 |
+
|
| 801 |
+
if (!loaded.error && has_error_status) {
|
| 802 |
+
return {
|
| 803 |
+
status: status || 500,
|
| 804 |
+
error: new Error()
|
| 805 |
+
};
|
| 806 |
+
}
|
| 807 |
+
|
| 808 |
+
const error = typeof loaded.error === 'string' ? new Error(loaded.error) : loaded.error;
|
| 809 |
+
|
| 810 |
+
if (!(error instanceof Error)) {
|
| 811 |
+
return {
|
| 812 |
+
status: 500,
|
| 813 |
+
error: new Error(
|
| 814 |
+
`"error" property returned from load() must be a string or instance of Error, received type "${typeof error}"`
|
| 815 |
+
)
|
| 816 |
+
};
|
| 817 |
+
}
|
| 818 |
+
|
| 819 |
+
if (!status || status < 400 || status > 599) {
|
| 820 |
+
console.warn('"error" returned from load() without a valid status code — defaulting to 500');
|
| 821 |
+
return { status: 500, error };
|
| 822 |
+
}
|
| 823 |
+
|
| 824 |
+
return { status, error };
|
| 825 |
+
}
|
| 826 |
+
|
| 827 |
+
if (loaded.redirect) {
|
| 828 |
+
if (!loaded.status || Math.floor(loaded.status / 100) !== 3) {
|
| 829 |
+
return {
|
| 830 |
+
status: 500,
|
| 831 |
+
error: new Error(
|
| 832 |
+
'"redirect" property returned from load() must be accompanied by a 3xx status code'
|
| 833 |
+
)
|
| 834 |
+
};
|
| 835 |
+
}
|
| 836 |
+
|
| 837 |
+
if (typeof loaded.redirect !== 'string') {
|
| 838 |
+
return {
|
| 839 |
+
status: 500,
|
| 840 |
+
error: new Error('"redirect" property returned from load() must be a string')
|
| 841 |
+
};
|
| 842 |
+
}
|
| 843 |
+
}
|
| 844 |
+
|
| 845 |
+
// TODO remove before 1.0
|
| 846 |
+
if (/** @type {any} */ (loaded).context) {
|
| 847 |
+
throw new Error(
|
| 848 |
+
'You are returning "context" from a load function. ' +
|
| 849 |
+
'"context" was renamed to "stuff", please adjust your code accordingly.'
|
| 850 |
+
);
|
| 851 |
+
}
|
| 852 |
+
|
| 853 |
+
return /** @type {import('types/internal').NormalizedLoadOutput} */ (loaded);
|
| 854 |
+
}
|
| 855 |
+
|
| 856 |
+
const absolute = /^([a-z]+:)?\/?\//;
|
| 857 |
+
const scheme = /^[a-z]+:/;
|
| 858 |
+
|
| 859 |
+
/**
|
| 860 |
+
* @param {string} base
|
| 861 |
+
* @param {string} path
|
| 862 |
+
*/
|
| 863 |
+
function resolve(base, path) {
|
| 864 |
+
if (scheme.test(path)) return path;
|
| 865 |
+
|
| 866 |
+
const base_match = absolute.exec(base);
|
| 867 |
+
const path_match = absolute.exec(path);
|
| 868 |
+
|
| 869 |
+
if (!base_match) {
|
| 870 |
+
throw new Error(`bad base path: "${base}"`);
|
| 871 |
+
}
|
| 872 |
+
|
| 873 |
+
const baseparts = path_match ? [] : base.slice(base_match[0].length).split('/');
|
| 874 |
+
const pathparts = path_match ? path.slice(path_match[0].length).split('/') : path.split('/');
|
| 875 |
+
|
| 876 |
+
baseparts.pop();
|
| 877 |
+
|
| 878 |
+
for (let i = 0; i < pathparts.length; i += 1) {
|
| 879 |
+
const part = pathparts[i];
|
| 880 |
+
if (part === '.') continue;
|
| 881 |
+
else if (part === '..') baseparts.pop();
|
| 882 |
+
else baseparts.push(part);
|
| 883 |
+
}
|
| 884 |
+
|
| 885 |
+
const prefix = (path_match && path_match[0]) || (base_match && base_match[0]) || '';
|
| 886 |
+
|
| 887 |
+
return `${prefix}${baseparts.join('/')}`;
|
| 888 |
+
}
|
| 889 |
+
|
| 890 |
+
/** @param {string} path */
|
| 891 |
+
function is_root_relative(path) {
|
| 892 |
+
return path[0] === '/' && path[1] !== '/';
|
| 893 |
+
}
|
| 894 |
+
|
| 895 |
+
/**
|
| 896 |
+
* @param {{
|
| 897 |
+
* request: import('types/hooks').ServerRequest;
|
| 898 |
+
* options: import('types/internal').SSRRenderOptions;
|
| 899 |
+
* state: import('types/internal').SSRRenderState;
|
| 900 |
+
* route: import('types/internal').SSRPage | null;
|
| 901 |
+
* url: URL;
|
| 902 |
+
* params: Record<string, string>;
|
| 903 |
+
* node: import('types/internal').SSRNode;
|
| 904 |
+
* $session: any;
|
| 905 |
+
* stuff: Record<string, any>;
|
| 906 |
+
* prerender_enabled: boolean;
|
| 907 |
+
* is_leaf: boolean;
|
| 908 |
+
* is_error: boolean;
|
| 909 |
+
* status?: number;
|
| 910 |
+
* error?: Error;
|
| 911 |
+
* }} opts
|
| 912 |
+
* @returns {Promise<import('./types').Loaded | undefined>} undefined for fallthrough
|
| 913 |
+
*/
|
| 914 |
+
async function load_node({
|
| 915 |
+
request,
|
| 916 |
+
options,
|
| 917 |
+
state,
|
| 918 |
+
route,
|
| 919 |
+
url,
|
| 920 |
+
params,
|
| 921 |
+
node,
|
| 922 |
+
$session,
|
| 923 |
+
stuff,
|
| 924 |
+
prerender_enabled,
|
| 925 |
+
is_leaf,
|
| 926 |
+
is_error,
|
| 927 |
+
status,
|
| 928 |
+
error
|
| 929 |
+
}) {
|
| 930 |
+
const { module } = node;
|
| 931 |
+
|
| 932 |
+
let uses_credentials = false;
|
| 933 |
+
|
| 934 |
+
/**
|
| 935 |
+
* @type {Array<{
|
| 936 |
+
* url: string;
|
| 937 |
+
* body: string;
|
| 938 |
+
* json: string;
|
| 939 |
+
* }>}
|
| 940 |
+
*/
|
| 941 |
+
const fetched = [];
|
| 942 |
+
|
| 943 |
+
/**
|
| 944 |
+
* @type {string[]}
|
| 945 |
+
*/
|
| 946 |
+
let set_cookie_headers = [];
|
| 947 |
+
|
| 948 |
+
let loaded;
|
| 949 |
+
|
| 950 |
+
const url_proxy = new Proxy(url, {
|
| 951 |
+
get: (target, prop, receiver) => {
|
| 952 |
+
if (prerender_enabled && (prop === 'search' || prop === 'searchParams')) {
|
| 953 |
+
throw new Error('Cannot access query on a page with prerendering enabled');
|
| 954 |
+
}
|
| 955 |
+
return Reflect.get(target, prop, receiver);
|
| 956 |
+
}
|
| 957 |
+
});
|
| 958 |
+
|
| 959 |
+
if (module.load) {
|
| 960 |
+
/** @type {import('types/page').LoadInput | import('types/page').ErrorLoadInput} */
|
| 961 |
+
const load_input = {
|
| 962 |
+
url: url_proxy,
|
| 963 |
+
params,
|
| 964 |
+
get session() {
|
| 965 |
+
uses_credentials = true;
|
| 966 |
+
return $session;
|
| 967 |
+
},
|
| 968 |
+
/**
|
| 969 |
+
* @param {RequestInfo} resource
|
| 970 |
+
* @param {RequestInit} opts
|
| 971 |
+
*/
|
| 972 |
+
fetch: async (resource, opts = {}) => {
|
| 973 |
+
/** @type {string} */
|
| 974 |
+
let requested;
|
| 975 |
+
|
| 976 |
+
if (typeof resource === 'string') {
|
| 977 |
+
requested = resource;
|
| 978 |
+
} else {
|
| 979 |
+
requested = resource.url;
|
| 980 |
+
|
| 981 |
+
opts = {
|
| 982 |
+
method: resource.method,
|
| 983 |
+
headers: resource.headers,
|
| 984 |
+
body: resource.body,
|
| 985 |
+
mode: resource.mode,
|
| 986 |
+
credentials: resource.credentials,
|
| 987 |
+
cache: resource.cache,
|
| 988 |
+
redirect: resource.redirect,
|
| 989 |
+
referrer: resource.referrer,
|
| 990 |
+
integrity: resource.integrity,
|
| 991 |
+
...opts
|
| 992 |
+
};
|
| 993 |
+
}
|
| 994 |
+
|
| 995 |
+
opts.headers = new Headers(opts.headers);
|
| 996 |
+
|
| 997 |
+
const resolved = resolve(request.url.pathname, requested.split('?')[0]);
|
| 998 |
+
|
| 999 |
+
let response;
|
| 1000 |
+
|
| 1001 |
+
// handle fetch requests for static assets. e.g. prebaked data, etc.
|
| 1002 |
+
// we need to support everything the browser's fetch supports
|
| 1003 |
+
const prefix = options.paths.assets || options.paths.base;
|
| 1004 |
+
const filename = (
|
| 1005 |
+
resolved.startsWith(prefix) ? resolved.slice(prefix.length) : resolved
|
| 1006 |
+
).slice(1);
|
| 1007 |
+
const filename_html = `${filename}/index.html`; // path may also match path/index.html
|
| 1008 |
+
|
| 1009 |
+
const is_asset = options.manifest.assets.has(filename);
|
| 1010 |
+
const is_asset_html = options.manifest.assets.has(filename_html);
|
| 1011 |
+
|
| 1012 |
+
if (is_asset || is_asset_html) {
|
| 1013 |
+
const file = is_asset ? filename : filename_html;
|
| 1014 |
+
|
| 1015 |
+
if (options.read) {
|
| 1016 |
+
const type = is_asset
|
| 1017 |
+
? options.manifest._.mime[filename.slice(filename.lastIndexOf('.'))]
|
| 1018 |
+
: 'text/html';
|
| 1019 |
+
|
| 1020 |
+
response = new Response(options.read(file), {
|
| 1021 |
+
headers: type ? { 'content-type': type } : {}
|
| 1022 |
+
});
|
| 1023 |
+
} else {
|
| 1024 |
+
response = await fetch(`${url.origin}/${file}`, /** @type {RequestInit} */ (opts));
|
| 1025 |
+
}
|
| 1026 |
+
} else if (is_root_relative(resolved)) {
|
| 1027 |
+
const relative = resolved;
|
| 1028 |
+
|
| 1029 |
+
// TODO: fix type https://github.com/node-fetch/node-fetch/issues/1113
|
| 1030 |
+
if (opts.credentials !== 'omit') {
|
| 1031 |
+
uses_credentials = true;
|
| 1032 |
+
|
| 1033 |
+
if (request.headers.cookie) {
|
| 1034 |
+
opts.headers.set('cookie', request.headers.cookie);
|
| 1035 |
+
}
|
| 1036 |
+
|
| 1037 |
+
if (request.headers.authorization && !opts.headers.has('authorization')) {
|
| 1038 |
+
opts.headers.set('authorization', request.headers.authorization);
|
| 1039 |
+
}
|
| 1040 |
+
}
|
| 1041 |
+
|
| 1042 |
+
if (opts.body && typeof opts.body !== 'string') {
|
| 1043 |
+
// per https://developer.mozilla.org/en-US/docs/Web/API/Request/Request, this can be a
|
| 1044 |
+
// Blob, BufferSource, FormData, URLSearchParams, USVString, or ReadableStream object.
|
| 1045 |
+
// non-string bodies are irksome to deal with, but luckily aren't particularly useful
|
| 1046 |
+
// in this context anyway, so we take the easy route and ban them
|
| 1047 |
+
throw new Error('Request body must be a string');
|
| 1048 |
+
}
|
| 1049 |
+
|
| 1050 |
+
const rendered = await respond(
|
| 1051 |
+
{
|
| 1052 |
+
url: new URL(requested, request.url),
|
| 1053 |
+
method: opts.method || 'GET',
|
| 1054 |
+
headers: Object.fromEntries(opts.headers),
|
| 1055 |
+
rawBody: opts.body == null ? null : new TextEncoder().encode(opts.body)
|
| 1056 |
+
},
|
| 1057 |
+
options,
|
| 1058 |
+
{
|
| 1059 |
+
fetched: requested,
|
| 1060 |
+
initiator: route
|
| 1061 |
+
}
|
| 1062 |
+
);
|
| 1063 |
+
|
| 1064 |
+
if (rendered) {
|
| 1065 |
+
if (state.prerender) {
|
| 1066 |
+
state.prerender.dependencies.set(relative, rendered);
|
| 1067 |
+
}
|
| 1068 |
+
|
| 1069 |
+
// Set-Cookie must be filtered out (done below) and that's the only header value that
|
| 1070 |
+
// can be an array so we know we have only simple values
|
| 1071 |
+
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie
|
| 1072 |
+
response = new Response(rendered.body, {
|
| 1073 |
+
status: rendered.status,
|
| 1074 |
+
headers: /** @type {Record<string, string>} */ (rendered.headers)
|
| 1075 |
+
});
|
| 1076 |
+
} else {
|
| 1077 |
+
// we can't load the endpoint from our own manifest,
|
| 1078 |
+
// so we need to make an actual HTTP request
|
| 1079 |
+
return fetch(new URL(requested, request.url).href, {
|
| 1080 |
+
method: opts.method || 'GET',
|
| 1081 |
+
headers: opts.headers
|
| 1082 |
+
});
|
| 1083 |
+
}
|
| 1084 |
+
} else {
|
| 1085 |
+
// external
|
| 1086 |
+
if (resolved.startsWith('//')) {
|
| 1087 |
+
throw new Error(
|
| 1088 |
+
`Cannot request protocol-relative URL (${requested}) in server-side fetch`
|
| 1089 |
+
);
|
| 1090 |
+
}
|
| 1091 |
+
|
| 1092 |
+
// external fetch
|
| 1093 |
+
// allow cookie passthrough for "same-origin"
|
| 1094 |
+
// if SvelteKit is serving my.domain.com:
|
| 1095 |
+
// - domain.com WILL NOT receive cookies
|
| 1096 |
+
// - my.domain.com WILL receive cookies
|
| 1097 |
+
// - api.domain.dom WILL NOT receive cookies
|
| 1098 |
+
// - sub.my.domain.com WILL receive cookies
|
| 1099 |
+
// ports do not affect the resolution
|
| 1100 |
+
// leading dot prevents mydomain.com matching domain.com
|
| 1101 |
+
if (
|
| 1102 |
+
`.${new URL(requested).hostname}`.endsWith(`.${request.url.hostname}`) &&
|
| 1103 |
+
opts.credentials !== 'omit'
|
| 1104 |
+
) {
|
| 1105 |
+
uses_credentials = true;
|
| 1106 |
+
opts.headers.set('cookie', request.headers.cookie);
|
| 1107 |
+
}
|
| 1108 |
+
|
| 1109 |
+
const external_request = new Request(requested, /** @type {RequestInit} */ (opts));
|
| 1110 |
+
response = await options.hooks.externalFetch.call(null, external_request);
|
| 1111 |
+
}
|
| 1112 |
+
|
| 1113 |
+
if (response) {
|
| 1114 |
+
const proxy = new Proxy(response, {
|
| 1115 |
+
get(response, key, _receiver) {
|
| 1116 |
+
async function text() {
|
| 1117 |
+
const body = await response.text();
|
| 1118 |
+
|
| 1119 |
+
/** @type {import('types/helper').ResponseHeaders} */
|
| 1120 |
+
const headers = {};
|
| 1121 |
+
for (const [key, value] of response.headers) {
|
| 1122 |
+
if (key === 'set-cookie') {
|
| 1123 |
+
set_cookie_headers = set_cookie_headers.concat(value);
|
| 1124 |
+
} else if (key !== 'etag') {
|
| 1125 |
+
headers[key] = value;
|
| 1126 |
+
}
|
| 1127 |
+
}
|
| 1128 |
+
|
| 1129 |
+
if (!opts.body || typeof opts.body === 'string') {
|
| 1130 |
+
// prettier-ignore
|
| 1131 |
+
fetched.push({
|
| 1132 |
+
url: requested,
|
| 1133 |
+
body: /** @type {string} */ (opts.body),
|
| 1134 |
+
json: `{"status":${response.status},"statusText":${s(response.statusText)},"headers":${s(headers)},"body":"${escape_json_string_in_html(body)}"}`
|
| 1135 |
+
});
|
| 1136 |
+
}
|
| 1137 |
+
|
| 1138 |
+
return body;
|
| 1139 |
+
}
|
| 1140 |
+
|
| 1141 |
+
if (key === 'text') {
|
| 1142 |
+
return text;
|
| 1143 |
+
}
|
| 1144 |
+
|
| 1145 |
+
if (key === 'json') {
|
| 1146 |
+
return async () => {
|
| 1147 |
+
return JSON.parse(await text());
|
| 1148 |
+
};
|
| 1149 |
+
}
|
| 1150 |
+
|
| 1151 |
+
// TODO arrayBuffer?
|
| 1152 |
+
|
| 1153 |
+
return Reflect.get(response, key, response);
|
| 1154 |
+
}
|
| 1155 |
+
});
|
| 1156 |
+
|
| 1157 |
+
return proxy;
|
| 1158 |
+
}
|
| 1159 |
+
|
| 1160 |
+
return (
|
| 1161 |
+
response ||
|
| 1162 |
+
new Response('Not found', {
|
| 1163 |
+
status: 404
|
| 1164 |
+
})
|
| 1165 |
+
);
|
| 1166 |
+
},
|
| 1167 |
+
stuff: { ...stuff }
|
| 1168 |
+
};
|
| 1169 |
+
|
| 1170 |
+
if (options.dev) {
|
| 1171 |
+
// TODO remove this for 1.0
|
| 1172 |
+
Object.defineProperty(load_input, 'page', {
|
| 1173 |
+
get: () => {
|
| 1174 |
+
throw new Error('`page` in `load` functions has been replaced by `url` and `params`');
|
| 1175 |
+
}
|
| 1176 |
+
});
|
| 1177 |
+
}
|
| 1178 |
+
|
| 1179 |
+
if (is_error) {
|
| 1180 |
+
/** @type {import('types/page').ErrorLoadInput} */ (load_input).status = status;
|
| 1181 |
+
/** @type {import('types/page').ErrorLoadInput} */ (load_input).error = error;
|
| 1182 |
+
}
|
| 1183 |
+
|
| 1184 |
+
loaded = await module.load.call(null, load_input);
|
| 1185 |
+
} else {
|
| 1186 |
+
loaded = {};
|
| 1187 |
+
}
|
| 1188 |
+
|
| 1189 |
+
// if leaf node (i.e. page component) has a load function
|
| 1190 |
+
// that returns nothing, we fall through to the next one
|
| 1191 |
+
if (!loaded && is_leaf && !is_error) return;
|
| 1192 |
+
|
| 1193 |
+
if (!loaded) {
|
| 1194 |
+
throw new Error(`${node.entry} - load must return a value except for page fall through`);
|
| 1195 |
+
}
|
| 1196 |
+
|
| 1197 |
+
return {
|
| 1198 |
+
node,
|
| 1199 |
+
loaded: normalize(loaded),
|
| 1200 |
+
stuff: loaded.stuff || stuff,
|
| 1201 |
+
fetched,
|
| 1202 |
+
set_cookie_headers,
|
| 1203 |
+
uses_credentials
|
| 1204 |
+
};
|
| 1205 |
+
}
|
| 1206 |
+
|
| 1207 |
+
/**
|
| 1208 |
+
* @typedef {import('./types.js').Loaded} Loaded
|
| 1209 |
+
* @typedef {import('types/internal').SSRNode} SSRNode
|
| 1210 |
+
* @typedef {import('types/internal').SSRRenderOptions} SSRRenderOptions
|
| 1211 |
+
* @typedef {import('types/internal').SSRRenderState} SSRRenderState
|
| 1212 |
+
*/
|
| 1213 |
+
|
| 1214 |
+
/**
|
| 1215 |
+
* @param {{
|
| 1216 |
+
* request: import('types/hooks').ServerRequest;
|
| 1217 |
+
* options: SSRRenderOptions;
|
| 1218 |
+
* state: SSRRenderState;
|
| 1219 |
+
* $session: any;
|
| 1220 |
+
* status: number;
|
| 1221 |
+
* error: Error;
|
| 1222 |
+
* }} opts
|
| 1223 |
+
*/
|
| 1224 |
+
async function respond_with_error({ request, options, state, $session, status, error }) {
|
| 1225 |
+
const default_layout = await options.manifest._.nodes[0](); // 0 is always the root layout
|
| 1226 |
+
const default_error = await options.manifest._.nodes[1](); // 1 is always the root error
|
| 1227 |
+
|
| 1228 |
+
/** @type {Record<string, string>} */
|
| 1229 |
+
const params = {}; // error page has no params
|
| 1230 |
+
|
| 1231 |
+
// error pages don't fall through, so we know it's not undefined
|
| 1232 |
+
const loaded = /** @type {Loaded} */ (
|
| 1233 |
+
await load_node({
|
| 1234 |
+
request,
|
| 1235 |
+
options,
|
| 1236 |
+
state,
|
| 1237 |
+
route: null,
|
| 1238 |
+
url: request.url, // TODO this is redundant, no?
|
| 1239 |
+
params,
|
| 1240 |
+
node: default_layout,
|
| 1241 |
+
$session,
|
| 1242 |
+
stuff: {},
|
| 1243 |
+
prerender_enabled: is_prerender_enabled(options, default_error, state),
|
| 1244 |
+
is_leaf: false,
|
| 1245 |
+
is_error: false
|
| 1246 |
+
})
|
| 1247 |
+
);
|
| 1248 |
+
|
| 1249 |
+
const branch = [
|
| 1250 |
+
loaded,
|
| 1251 |
+
/** @type {Loaded} */ (
|
| 1252 |
+
await load_node({
|
| 1253 |
+
request,
|
| 1254 |
+
options,
|
| 1255 |
+
state,
|
| 1256 |
+
route: null,
|
| 1257 |
+
url: request.url,
|
| 1258 |
+
params,
|
| 1259 |
+
node: default_error,
|
| 1260 |
+
$session,
|
| 1261 |
+
stuff: loaded ? loaded.stuff : {},
|
| 1262 |
+
prerender_enabled: is_prerender_enabled(options, default_error, state),
|
| 1263 |
+
is_leaf: false,
|
| 1264 |
+
is_error: true,
|
| 1265 |
+
status,
|
| 1266 |
+
error
|
| 1267 |
+
})
|
| 1268 |
+
)
|
| 1269 |
+
];
|
| 1270 |
+
|
| 1271 |
+
try {
|
| 1272 |
+
return await render_response({
|
| 1273 |
+
options,
|
| 1274 |
+
$session,
|
| 1275 |
+
page_config: {
|
| 1276 |
+
hydrate: options.hydrate,
|
| 1277 |
+
router: options.router,
|
| 1278 |
+
ssr: options.ssr
|
| 1279 |
+
},
|
| 1280 |
+
status,
|
| 1281 |
+
error,
|
| 1282 |
+
branch,
|
| 1283 |
+
url: request.url,
|
| 1284 |
+
params
|
| 1285 |
+
});
|
| 1286 |
+
} catch (err) {
|
| 1287 |
+
const error = coalesce_to_error(err);
|
| 1288 |
+
|
| 1289 |
+
options.handle_error(error, request);
|
| 1290 |
+
|
| 1291 |
+
return {
|
| 1292 |
+
status: 500,
|
| 1293 |
+
headers: {},
|
| 1294 |
+
body: error.stack
|
| 1295 |
+
};
|
| 1296 |
+
}
|
| 1297 |
+
}
|
| 1298 |
+
|
| 1299 |
+
/**
|
| 1300 |
+
* @param {SSRRenderOptions} options
|
| 1301 |
+
* @param {SSRNode} node
|
| 1302 |
+
* @param {SSRRenderState} state
|
| 1303 |
+
*/
|
| 1304 |
+
function is_prerender_enabled(options, node, state) {
|
| 1305 |
+
return (
|
| 1306 |
+
options.prerender && (!!node.module.prerender || (!!state.prerender && state.prerender.all))
|
| 1307 |
+
);
|
| 1308 |
+
}
|
| 1309 |
+
|
| 1310 |
+
/**
|
| 1311 |
+
* @typedef {import('./types.js').Loaded} Loaded
|
| 1312 |
+
* @typedef {import('types/hooks').ServerResponse} ServerResponse
|
| 1313 |
+
* @typedef {import('types/internal').SSRNode} SSRNode
|
| 1314 |
+
* @typedef {import('types/internal').SSRRenderOptions} SSRRenderOptions
|
| 1315 |
+
* @typedef {import('types/internal').SSRRenderState} SSRRenderState
|
| 1316 |
+
*/
|
| 1317 |
+
|
| 1318 |
+
/**
|
| 1319 |
+
* @param {{
|
| 1320 |
+
* request: import('types/hooks').ServerRequest;
|
| 1321 |
+
* options: SSRRenderOptions;
|
| 1322 |
+
* state: SSRRenderState;
|
| 1323 |
+
* $session: any;
|
| 1324 |
+
* route: import('types/internal').SSRPage;
|
| 1325 |
+
* params: Record<string, string>;
|
| 1326 |
+
* }} opts
|
| 1327 |
+
* @returns {Promise<ServerResponse | undefined>}
|
| 1328 |
+
*/
|
| 1329 |
+
async function respond$1(opts) {
|
| 1330 |
+
const { request, options, state, $session, route } = opts;
|
| 1331 |
+
|
| 1332 |
+
/** @type {Array<SSRNode | undefined>} */
|
| 1333 |
+
let nodes;
|
| 1334 |
+
|
| 1335 |
+
try {
|
| 1336 |
+
nodes = await Promise.all(
|
| 1337 |
+
route.a.map((n) => options.manifest._.nodes[n] && options.manifest._.nodes[n]())
|
| 1338 |
+
);
|
| 1339 |
+
} catch (err) {
|
| 1340 |
+
const error = coalesce_to_error(err);
|
| 1341 |
+
|
| 1342 |
+
options.handle_error(error, request);
|
| 1343 |
+
|
| 1344 |
+
return await respond_with_error({
|
| 1345 |
+
request,
|
| 1346 |
+
options,
|
| 1347 |
+
state,
|
| 1348 |
+
$session,
|
| 1349 |
+
status: 500,
|
| 1350 |
+
error
|
| 1351 |
+
});
|
| 1352 |
+
}
|
| 1353 |
+
|
| 1354 |
+
// the leaf node will be present. only layouts may be undefined
|
| 1355 |
+
const leaf = /** @type {SSRNode} */ (nodes[nodes.length - 1]).module;
|
| 1356 |
+
|
| 1357 |
+
let page_config = get_page_config(leaf, options);
|
| 1358 |
+
|
| 1359 |
+
if (!leaf.prerender && state.prerender && !state.prerender.all) {
|
| 1360 |
+
// if the page has `export const prerender = true`, continue,
|
| 1361 |
+
// otherwise bail out at this point
|
| 1362 |
+
return {
|
| 1363 |
+
status: 204,
|
| 1364 |
+
headers: {}
|
| 1365 |
+
};
|
| 1366 |
+
}
|
| 1367 |
+
|
| 1368 |
+
/** @type {Array<Loaded>} */
|
| 1369 |
+
let branch = [];
|
| 1370 |
+
|
| 1371 |
+
/** @type {number} */
|
| 1372 |
+
let status = 200;
|
| 1373 |
+
|
| 1374 |
+
/** @type {Error|undefined} */
|
| 1375 |
+
let error;
|
| 1376 |
+
|
| 1377 |
+
/** @type {string[]} */
|
| 1378 |
+
let set_cookie_headers = [];
|
| 1379 |
+
|
| 1380 |
+
ssr: if (page_config.ssr) {
|
| 1381 |
+
let stuff = {};
|
| 1382 |
+
|
| 1383 |
+
for (let i = 0; i < nodes.length; i += 1) {
|
| 1384 |
+
const node = nodes[i];
|
| 1385 |
+
|
| 1386 |
+
/** @type {Loaded | undefined} */
|
| 1387 |
+
let loaded;
|
| 1388 |
+
|
| 1389 |
+
if (node) {
|
| 1390 |
+
try {
|
| 1391 |
+
loaded = await load_node({
|
| 1392 |
+
...opts,
|
| 1393 |
+
url: request.url,
|
| 1394 |
+
node,
|
| 1395 |
+
stuff,
|
| 1396 |
+
prerender_enabled: is_prerender_enabled(options, node, state),
|
| 1397 |
+
is_leaf: i === nodes.length - 1,
|
| 1398 |
+
is_error: false
|
| 1399 |
+
});
|
| 1400 |
+
|
| 1401 |
+
if (!loaded) return;
|
| 1402 |
+
|
| 1403 |
+
set_cookie_headers = set_cookie_headers.concat(loaded.set_cookie_headers);
|
| 1404 |
+
|
| 1405 |
+
if (loaded.loaded.redirect) {
|
| 1406 |
+
return with_cookies(
|
| 1407 |
+
{
|
| 1408 |
+
status: loaded.loaded.status,
|
| 1409 |
+
headers: {
|
| 1410 |
+
location: encodeURI(loaded.loaded.redirect)
|
| 1411 |
+
}
|
| 1412 |
+
},
|
| 1413 |
+
set_cookie_headers
|
| 1414 |
+
);
|
| 1415 |
+
}
|
| 1416 |
+
|
| 1417 |
+
if (loaded.loaded.error) {
|
| 1418 |
+
({ status, error } = loaded.loaded);
|
| 1419 |
+
}
|
| 1420 |
+
} catch (err) {
|
| 1421 |
+
const e = coalesce_to_error(err);
|
| 1422 |
+
|
| 1423 |
+
options.handle_error(e, request);
|
| 1424 |
+
|
| 1425 |
+
status = 500;
|
| 1426 |
+
error = e;
|
| 1427 |
+
}
|
| 1428 |
+
|
| 1429 |
+
if (loaded && !error) {
|
| 1430 |
+
branch.push(loaded);
|
| 1431 |
+
}
|
| 1432 |
+
|
| 1433 |
+
if (error) {
|
| 1434 |
+
while (i--) {
|
| 1435 |
+
if (route.b[i]) {
|
| 1436 |
+
const error_node = await options.manifest._.nodes[route.b[i]]();
|
| 1437 |
+
|
| 1438 |
+
/** @type {Loaded} */
|
| 1439 |
+
let node_loaded;
|
| 1440 |
+
let j = i;
|
| 1441 |
+
while (!(node_loaded = branch[j])) {
|
| 1442 |
+
j -= 1;
|
| 1443 |
+
}
|
| 1444 |
+
|
| 1445 |
+
try {
|
| 1446 |
+
// there's no fallthough on an error page, so we know it's not undefined
|
| 1447 |
+
const error_loaded = /** @type {import('./types').Loaded} */ (
|
| 1448 |
+
await load_node({
|
| 1449 |
+
...opts,
|
| 1450 |
+
url: request.url,
|
| 1451 |
+
node: error_node,
|
| 1452 |
+
stuff: node_loaded.stuff,
|
| 1453 |
+
prerender_enabled: is_prerender_enabled(options, error_node, state),
|
| 1454 |
+
is_leaf: false,
|
| 1455 |
+
is_error: true,
|
| 1456 |
+
status,
|
| 1457 |
+
error
|
| 1458 |
+
})
|
| 1459 |
+
);
|
| 1460 |
+
|
| 1461 |
+
if (error_loaded.loaded.error) {
|
| 1462 |
+
continue;
|
| 1463 |
+
}
|
| 1464 |
+
|
| 1465 |
+
page_config = get_page_config(error_node.module, options);
|
| 1466 |
+
branch = branch.slice(0, j + 1).concat(error_loaded);
|
| 1467 |
+
break ssr;
|
| 1468 |
+
} catch (err) {
|
| 1469 |
+
const e = coalesce_to_error(err);
|
| 1470 |
+
|
| 1471 |
+
options.handle_error(e, request);
|
| 1472 |
+
|
| 1473 |
+
continue;
|
| 1474 |
+
}
|
| 1475 |
+
}
|
| 1476 |
+
}
|
| 1477 |
+
|
| 1478 |
+
// TODO backtrack until we find an __error.svelte component
|
| 1479 |
+
// that we can use as the leaf node
|
| 1480 |
+
// for now just return regular error page
|
| 1481 |
+
return with_cookies(
|
| 1482 |
+
await respond_with_error({
|
| 1483 |
+
request,
|
| 1484 |
+
options,
|
| 1485 |
+
state,
|
| 1486 |
+
$session,
|
| 1487 |
+
status,
|
| 1488 |
+
error
|
| 1489 |
+
}),
|
| 1490 |
+
set_cookie_headers
|
| 1491 |
+
);
|
| 1492 |
+
}
|
| 1493 |
+
}
|
| 1494 |
+
|
| 1495 |
+
if (loaded && loaded.loaded.stuff) {
|
| 1496 |
+
stuff = {
|
| 1497 |
+
...stuff,
|
| 1498 |
+
...loaded.loaded.stuff
|
| 1499 |
+
};
|
| 1500 |
+
}
|
| 1501 |
+
}
|
| 1502 |
+
}
|
| 1503 |
+
|
| 1504 |
+
try {
|
| 1505 |
+
return with_cookies(
|
| 1506 |
+
await render_response({
|
| 1507 |
+
...opts,
|
| 1508 |
+
url: request.url,
|
| 1509 |
+
page_config,
|
| 1510 |
+
status,
|
| 1511 |
+
error,
|
| 1512 |
+
branch: branch.filter(Boolean)
|
| 1513 |
+
}),
|
| 1514 |
+
set_cookie_headers
|
| 1515 |
+
);
|
| 1516 |
+
} catch (err) {
|
| 1517 |
+
const error = coalesce_to_error(err);
|
| 1518 |
+
|
| 1519 |
+
options.handle_error(error, request);
|
| 1520 |
+
|
| 1521 |
+
return with_cookies(
|
| 1522 |
+
await respond_with_error({
|
| 1523 |
+
...opts,
|
| 1524 |
+
status: 500,
|
| 1525 |
+
error
|
| 1526 |
+
}),
|
| 1527 |
+
set_cookie_headers
|
| 1528 |
+
);
|
| 1529 |
+
}
|
| 1530 |
+
}
|
| 1531 |
+
|
| 1532 |
+
/**
|
| 1533 |
+
* @param {import('types/internal').SSRComponent} leaf
|
| 1534 |
+
* @param {SSRRenderOptions} options
|
| 1535 |
+
*/
|
| 1536 |
+
function get_page_config(leaf, options) {
|
| 1537 |
+
return {
|
| 1538 |
+
ssr: 'ssr' in leaf ? !!leaf.ssr : options.ssr,
|
| 1539 |
+
router: 'router' in leaf ? !!leaf.router : options.router,
|
| 1540 |
+
hydrate: 'hydrate' in leaf ? !!leaf.hydrate : options.hydrate
|
| 1541 |
+
};
|
| 1542 |
+
}
|
| 1543 |
+
|
| 1544 |
+
/**
|
| 1545 |
+
* @param {ServerResponse} response
|
| 1546 |
+
* @param {string[]} set_cookie_headers
|
| 1547 |
+
*/
|
| 1548 |
+
function with_cookies(response, set_cookie_headers) {
|
| 1549 |
+
if (set_cookie_headers.length) {
|
| 1550 |
+
response.headers['set-cookie'] = set_cookie_headers;
|
| 1551 |
+
}
|
| 1552 |
+
return response;
|
| 1553 |
+
}
|
| 1554 |
+
|
| 1555 |
+
/**
|
| 1556 |
+
* @param {import('types/hooks').ServerRequest} request
|
| 1557 |
+
* @param {import('types/internal').SSRPage} route
|
| 1558 |
+
* @param {RegExpExecArray} match
|
| 1559 |
+
* @param {import('types/internal').SSRRenderOptions} options
|
| 1560 |
+
* @param {import('types/internal').SSRRenderState} state
|
| 1561 |
+
* @returns {Promise<import('types/hooks').ServerResponse | undefined>}
|
| 1562 |
+
*/
|
| 1563 |
+
async function render_page(request, route, match, options, state) {
|
| 1564 |
+
if (state.initiator === route) {
|
| 1565 |
+
// infinite request cycle detected
|
| 1566 |
+
return {
|
| 1567 |
+
status: 404,
|
| 1568 |
+
headers: {},
|
| 1569 |
+
body: `Not found: ${request.url.pathname}`
|
| 1570 |
+
};
|
| 1571 |
+
}
|
| 1572 |
+
|
| 1573 |
+
const params = route.params ? decode_params(route.params(match)) : {};
|
| 1574 |
+
|
| 1575 |
+
const $session = await options.hooks.getSession(request);
|
| 1576 |
+
|
| 1577 |
+
const response = await respond$1({
|
| 1578 |
+
request,
|
| 1579 |
+
options,
|
| 1580 |
+
state,
|
| 1581 |
+
$session,
|
| 1582 |
+
route,
|
| 1583 |
+
params
|
| 1584 |
+
});
|
| 1585 |
+
|
| 1586 |
+
if (response) {
|
| 1587 |
+
return response;
|
| 1588 |
+
}
|
| 1589 |
+
|
| 1590 |
+
if (state.fetched) {
|
| 1591 |
+
// we came here because of a bad request in a `load` function.
|
| 1592 |
+
// rather than render the error page — which could lead to an
|
| 1593 |
+
// infinite loop, if the `load` belonged to the root layout,
|
| 1594 |
+
// we respond with a bare-bones 500
|
| 1595 |
+
return {
|
| 1596 |
+
status: 500,
|
| 1597 |
+
headers: {},
|
| 1598 |
+
body: `Bad request in load function: failed to fetch ${state.fetched}`
|
| 1599 |
+
};
|
| 1600 |
+
}
|
| 1601 |
+
}
|
| 1602 |
+
|
| 1603 |
+
function read_only_form_data() {
|
| 1604 |
+
/** @type {Map<string, string[]>} */
|
| 1605 |
+
const map = new Map();
|
| 1606 |
+
|
| 1607 |
+
return {
|
| 1608 |
+
/**
|
| 1609 |
+
* @param {string} key
|
| 1610 |
+
* @param {string} value
|
| 1611 |
+
*/
|
| 1612 |
+
append(key, value) {
|
| 1613 |
+
if (map.has(key)) {
|
| 1614 |
+
(map.get(key) || []).push(value);
|
| 1615 |
+
} else {
|
| 1616 |
+
map.set(key, [value]);
|
| 1617 |
+
}
|
| 1618 |
+
},
|
| 1619 |
+
|
| 1620 |
+
data: new ReadOnlyFormData(map)
|
| 1621 |
+
};
|
| 1622 |
+
}
|
| 1623 |
+
|
| 1624 |
+
class ReadOnlyFormData {
|
| 1625 |
+
/** @type {Map<string, string[]>} */
|
| 1626 |
+
#map;
|
| 1627 |
+
|
| 1628 |
+
/** @param {Map<string, string[]>} map */
|
| 1629 |
+
constructor(map) {
|
| 1630 |
+
this.#map = map;
|
| 1631 |
+
}
|
| 1632 |
+
|
| 1633 |
+
/** @param {string} key */
|
| 1634 |
+
get(key) {
|
| 1635 |
+
const value = this.#map.get(key);
|
| 1636 |
+
return value && value[0];
|
| 1637 |
+
}
|
| 1638 |
+
|
| 1639 |
+
/** @param {string} key */
|
| 1640 |
+
getAll(key) {
|
| 1641 |
+
return this.#map.get(key);
|
| 1642 |
+
}
|
| 1643 |
+
|
| 1644 |
+
/** @param {string} key */
|
| 1645 |
+
has(key) {
|
| 1646 |
+
return this.#map.has(key);
|
| 1647 |
+
}
|
| 1648 |
+
|
| 1649 |
+
*[Symbol.iterator]() {
|
| 1650 |
+
for (const [key, value] of this.#map) {
|
| 1651 |
+
for (let i = 0; i < value.length; i += 1) {
|
| 1652 |
+
yield [key, value[i]];
|
| 1653 |
+
}
|
| 1654 |
+
}
|
| 1655 |
+
}
|
| 1656 |
+
|
| 1657 |
+
*entries() {
|
| 1658 |
+
for (const [key, value] of this.#map) {
|
| 1659 |
+
for (let i = 0; i < value.length; i += 1) {
|
| 1660 |
+
yield [key, value[i]];
|
| 1661 |
+
}
|
| 1662 |
+
}
|
| 1663 |
+
}
|
| 1664 |
+
|
| 1665 |
+
*keys() {
|
| 1666 |
+
for (const [key] of this.#map) yield key;
|
| 1667 |
+
}
|
| 1668 |
+
|
| 1669 |
+
*values() {
|
| 1670 |
+
for (const [, value] of this.#map) {
|
| 1671 |
+
for (let i = 0; i < value.length; i += 1) {
|
| 1672 |
+
yield value[i];
|
| 1673 |
+
}
|
| 1674 |
+
}
|
| 1675 |
+
}
|
| 1676 |
+
}
|
| 1677 |
+
|
| 1678 |
+
/**
|
| 1679 |
+
* @param {import('types/app').RawBody} raw
|
| 1680 |
+
* @param {import('types/helper').RequestHeaders} headers
|
| 1681 |
+
*/
|
| 1682 |
+
function parse_body(raw, headers) {
|
| 1683 |
+
if (!raw) return raw;
|
| 1684 |
+
|
| 1685 |
+
const content_type = headers['content-type'];
|
| 1686 |
+
const [type, ...directives] = content_type ? content_type.split(/;\s*/) : [];
|
| 1687 |
+
|
| 1688 |
+
const text = () => new TextDecoder(headers['content-encoding'] || 'utf-8').decode(raw);
|
| 1689 |
+
|
| 1690 |
+
switch (type) {
|
| 1691 |
+
case 'text/plain':
|
| 1692 |
+
return text();
|
| 1693 |
+
|
| 1694 |
+
case 'application/json':
|
| 1695 |
+
return JSON.parse(text());
|
| 1696 |
+
|
| 1697 |
+
case 'application/x-www-form-urlencoded':
|
| 1698 |
+
return get_urlencoded(text());
|
| 1699 |
+
|
| 1700 |
+
case 'multipart/form-data': {
|
| 1701 |
+
const boundary = directives.find((directive) => directive.startsWith('boundary='));
|
| 1702 |
+
if (!boundary) throw new Error('Missing boundary');
|
| 1703 |
+
return get_multipart(text(), boundary.slice('boundary='.length));
|
| 1704 |
+
}
|
| 1705 |
+
default:
|
| 1706 |
+
return raw;
|
| 1707 |
+
}
|
| 1708 |
+
}
|
| 1709 |
+
|
| 1710 |
+
/** @param {string} text */
|
| 1711 |
+
function get_urlencoded(text) {
|
| 1712 |
+
const { data, append } = read_only_form_data();
|
| 1713 |
+
|
| 1714 |
+
text
|
| 1715 |
+
.replace(/\+/g, ' ')
|
| 1716 |
+
.split('&')
|
| 1717 |
+
.forEach((str) => {
|
| 1718 |
+
const [key, value] = str.split('=');
|
| 1719 |
+
append(decodeURIComponent(key), decodeURIComponent(value));
|
| 1720 |
+
});
|
| 1721 |
+
|
| 1722 |
+
return data;
|
| 1723 |
+
}
|
| 1724 |
+
|
| 1725 |
+
/**
|
| 1726 |
+
* @param {string} text
|
| 1727 |
+
* @param {string} boundary
|
| 1728 |
+
*/
|
| 1729 |
+
function get_multipart(text, boundary) {
|
| 1730 |
+
const parts = text.split(`--${boundary}`);
|
| 1731 |
+
|
| 1732 |
+
if (parts[0] !== '' || parts[parts.length - 1].trim() !== '--') {
|
| 1733 |
+
throw new Error('Malformed form data');
|
| 1734 |
+
}
|
| 1735 |
+
|
| 1736 |
+
const { data, append } = read_only_form_data();
|
| 1737 |
+
|
| 1738 |
+
parts.slice(1, -1).forEach((part) => {
|
| 1739 |
+
const match = /\s*([\s\S]+?)\r\n\r\n([\s\S]*)\s*/.exec(part);
|
| 1740 |
+
if (!match) {
|
| 1741 |
+
throw new Error('Malformed form data');
|
| 1742 |
+
}
|
| 1743 |
+
const raw_headers = match[1];
|
| 1744 |
+
const body = match[2].trim();
|
| 1745 |
+
|
| 1746 |
+
let key;
|
| 1747 |
+
|
| 1748 |
+
/** @type {Record<string, string>} */
|
| 1749 |
+
const headers = {};
|
| 1750 |
+
raw_headers.split('\r\n').forEach((str) => {
|
| 1751 |
+
const [raw_header, ...raw_directives] = str.split('; ');
|
| 1752 |
+
let [name, value] = raw_header.split(': ');
|
| 1753 |
+
|
| 1754 |
+
name = name.toLowerCase();
|
| 1755 |
+
headers[name] = value;
|
| 1756 |
+
|
| 1757 |
+
/** @type {Record<string, string>} */
|
| 1758 |
+
const directives = {};
|
| 1759 |
+
raw_directives.forEach((raw_directive) => {
|
| 1760 |
+
const [name, value] = raw_directive.split('=');
|
| 1761 |
+
directives[name] = JSON.parse(value); // TODO is this right?
|
| 1762 |
+
});
|
| 1763 |
+
|
| 1764 |
+
if (name === 'content-disposition') {
|
| 1765 |
+
if (value !== 'form-data') throw new Error('Malformed form data');
|
| 1766 |
+
|
| 1767 |
+
if (directives.filename) {
|
| 1768 |
+
// TODO we probably don't want to do this automatically
|
| 1769 |
+
throw new Error('File upload is not yet implemented');
|
| 1770 |
+
}
|
| 1771 |
+
|
| 1772 |
+
if (directives.name) {
|
| 1773 |
+
key = directives.name;
|
| 1774 |
+
}
|
| 1775 |
+
}
|
| 1776 |
+
});
|
| 1777 |
+
|
| 1778 |
+
if (!key) throw new Error('Malformed form data');
|
| 1779 |
+
|
| 1780 |
+
append(key, body);
|
| 1781 |
+
});
|
| 1782 |
+
|
| 1783 |
+
return data;
|
| 1784 |
+
}
|
| 1785 |
+
|
| 1786 |
+
/** @type {import('@sveltejs/kit/ssr').Respond} */
|
| 1787 |
+
async function respond(incoming, options, state = {}) {
|
| 1788 |
+
if (incoming.url.pathname !== '/' && options.trailing_slash !== 'ignore') {
|
| 1789 |
+
const has_trailing_slash = incoming.url.pathname.endsWith('/');
|
| 1790 |
+
|
| 1791 |
+
if (
|
| 1792 |
+
(has_trailing_slash && options.trailing_slash === 'never') ||
|
| 1793 |
+
(!has_trailing_slash &&
|
| 1794 |
+
options.trailing_slash === 'always' &&
|
| 1795 |
+
!(incoming.url.pathname.split('/').pop() || '').includes('.'))
|
| 1796 |
+
) {
|
| 1797 |
+
incoming.url.pathname = has_trailing_slash
|
| 1798 |
+
? incoming.url.pathname.slice(0, -1)
|
| 1799 |
+
: incoming.url.pathname + '/';
|
| 1800 |
+
|
| 1801 |
+
if (incoming.url.search === '?') incoming.url.search = '';
|
| 1802 |
+
|
| 1803 |
+
return {
|
| 1804 |
+
status: 301,
|
| 1805 |
+
headers: {
|
| 1806 |
+
location: incoming.url.pathname + incoming.url.search
|
| 1807 |
+
}
|
| 1808 |
+
};
|
| 1809 |
+
}
|
| 1810 |
+
}
|
| 1811 |
+
|
| 1812 |
+
const headers = lowercase_keys(incoming.headers);
|
| 1813 |
+
const request = {
|
| 1814 |
+
...incoming,
|
| 1815 |
+
headers,
|
| 1816 |
+
body: parse_body(incoming.rawBody, headers),
|
| 1817 |
+
params: {},
|
| 1818 |
+
locals: {}
|
| 1819 |
+
};
|
| 1820 |
+
|
| 1821 |
+
// TODO remove this for 1.0
|
| 1822 |
+
/**
|
| 1823 |
+
* @param {string} property
|
| 1824 |
+
* @param {string} replacement
|
| 1825 |
+
*/
|
| 1826 |
+
const print_error = (property, replacement) => {
|
| 1827 |
+
Object.defineProperty(request, property, {
|
| 1828 |
+
get: () => {
|
| 1829 |
+
throw new Error(`request.${property} has been replaced by request.url.${replacement}`);
|
| 1830 |
+
}
|
| 1831 |
+
});
|
| 1832 |
+
};
|
| 1833 |
+
|
| 1834 |
+
print_error('origin', 'origin');
|
| 1835 |
+
print_error('path', 'pathname');
|
| 1836 |
+
print_error('query', 'searchParams');
|
| 1837 |
+
|
| 1838 |
+
try {
|
| 1839 |
+
return await options.hooks.handle({
|
| 1840 |
+
request,
|
| 1841 |
+
resolve: async (request) => {
|
| 1842 |
+
if (state.prerender && state.prerender.fallback) {
|
| 1843 |
+
return await render_response({
|
| 1844 |
+
url: request.url,
|
| 1845 |
+
params: request.params,
|
| 1846 |
+
options,
|
| 1847 |
+
$session: await options.hooks.getSession(request),
|
| 1848 |
+
page_config: { ssr: false, router: true, hydrate: true },
|
| 1849 |
+
status: 200,
|
| 1850 |
+
branch: []
|
| 1851 |
+
});
|
| 1852 |
+
}
|
| 1853 |
+
|
| 1854 |
+
const decoded = decodeURI(request.url.pathname).replace(options.paths.base, '');
|
| 1855 |
+
|
| 1856 |
+
for (const route of options.manifest._.routes) {
|
| 1857 |
+
const match = route.pattern.exec(decoded);
|
| 1858 |
+
if (!match) continue;
|
| 1859 |
+
|
| 1860 |
+
const response =
|
| 1861 |
+
route.type === 'endpoint'
|
| 1862 |
+
? await render_endpoint(request, route, match)
|
| 1863 |
+
: await render_page(request, route, match, options, state);
|
| 1864 |
+
|
| 1865 |
+
if (response) {
|
| 1866 |
+
// inject ETags for 200 responses
|
| 1867 |
+
if (response.status === 200) {
|
| 1868 |
+
const cache_control = get_single_valued_header(response.headers, 'cache-control');
|
| 1869 |
+
if (!cache_control || !/(no-store|immutable)/.test(cache_control)) {
|
| 1870 |
+
let if_none_match_value = request.headers['if-none-match'];
|
| 1871 |
+
// ignore W/ prefix https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-None-Match#directives
|
| 1872 |
+
if (if_none_match_value?.startsWith('W/"')) {
|
| 1873 |
+
if_none_match_value = if_none_match_value.substring(2);
|
| 1874 |
+
}
|
| 1875 |
+
|
| 1876 |
+
const etag = `"${hash(response.body || '')}"`;
|
| 1877 |
+
|
| 1878 |
+
if (if_none_match_value === etag) {
|
| 1879 |
+
return {
|
| 1880 |
+
status: 304,
|
| 1881 |
+
headers: {}
|
| 1882 |
+
};
|
| 1883 |
+
}
|
| 1884 |
+
|
| 1885 |
+
response.headers['etag'] = etag;
|
| 1886 |
+
}
|
| 1887 |
+
}
|
| 1888 |
+
|
| 1889 |
+
return response;
|
| 1890 |
+
}
|
| 1891 |
+
}
|
| 1892 |
+
|
| 1893 |
+
// if this request came direct from the user, rather than
|
| 1894 |
+
// via a `fetch` in a `load`, render a 404 page
|
| 1895 |
+
if (!state.initiator) {
|
| 1896 |
+
const $session = await options.hooks.getSession(request);
|
| 1897 |
+
return await respond_with_error({
|
| 1898 |
+
request,
|
| 1899 |
+
options,
|
| 1900 |
+
state,
|
| 1901 |
+
$session,
|
| 1902 |
+
status: 404,
|
| 1903 |
+
error: new Error(`Not found: ${request.url.pathname}`)
|
| 1904 |
+
});
|
| 1905 |
+
}
|
| 1906 |
+
}
|
| 1907 |
+
});
|
| 1908 |
+
} catch (/** @type {unknown} */ err) {
|
| 1909 |
+
const e = coalesce_to_error(err);
|
| 1910 |
+
|
| 1911 |
+
options.handle_error(e, request);
|
| 1912 |
+
|
| 1913 |
+
return {
|
| 1914 |
+
status: 500,
|
| 1915 |
+
headers: {},
|
| 1916 |
+
body: options.dev ? e.stack : e.message
|
| 1917 |
+
};
|
| 1918 |
+
}
|
| 1919 |
+
}
|
| 1920 |
+
|
| 1921 |
+
export { respond };
|
.svelte-kit/build/runtime/app/env.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export { prerendering } from '../env.js';
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* @type {import('$app/env').browser}
|
| 5 |
+
*/
|
| 6 |
+
const browser = !import.meta.env.SSR;
|
| 7 |
+
/**
|
| 8 |
+
* @type {import('$app/env').dev}
|
| 9 |
+
*/
|
| 10 |
+
const dev = !!import.meta.env.DEV;
|
| 11 |
+
/**
|
| 12 |
+
* @type {import('$app/env').mode}
|
| 13 |
+
*/
|
| 14 |
+
const mode = import.meta.env.MODE;
|
| 15 |
+
/**
|
| 16 |
+
* @type {import('$app/env').amp}
|
| 17 |
+
*/
|
| 18 |
+
const amp = !!import.meta.env.VITE_SVELTEKIT_AMP;
|
| 19 |
+
|
| 20 |
+
export { amp, browser, dev, mode };
|
.svelte-kit/build/runtime/app/navigation.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { renderer, router as router$1 } from '../internal/singletons.js';
|
| 2 |
+
import { g as get_base_uri } from '../chunks/utils.js';
|
| 3 |
+
|
| 4 |
+
const router = /** @type {import('../client/router').Router} */ (router$1);
|
| 5 |
+
|
| 6 |
+
/**
|
| 7 |
+
* @param {string} name
|
| 8 |
+
*/
|
| 9 |
+
function guard(name) {
|
| 10 |
+
return () => {
|
| 11 |
+
throw new Error(`Cannot call ${name}(...) on the server`);
|
| 12 |
+
};
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
const disableScrollHandling = import.meta.env.SSR
|
| 16 |
+
? guard('disableScrollHandling')
|
| 17 |
+
: disableScrollHandling_;
|
| 18 |
+
const goto = import.meta.env.SSR ? guard('goto') : goto_;
|
| 19 |
+
const invalidate = import.meta.env.SSR ? guard('invalidate') : invalidate_;
|
| 20 |
+
const prefetch = import.meta.env.SSR ? guard('prefetch') : prefetch_;
|
| 21 |
+
const prefetchRoutes = import.meta.env.SSR ? guard('prefetchRoutes') : prefetchRoutes_;
|
| 22 |
+
|
| 23 |
+
/**
|
| 24 |
+
* @type {import('$app/navigation').goto}
|
| 25 |
+
*/
|
| 26 |
+
async function disableScrollHandling_() {
|
| 27 |
+
renderer.disable_scroll_handling();
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
/**
|
| 31 |
+
* @type {import('$app/navigation').goto}
|
| 32 |
+
*/
|
| 33 |
+
async function goto_(href, opts) {
|
| 34 |
+
return router.goto(href, opts, []);
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
/**
|
| 38 |
+
* @type {import('$app/navigation').invalidate}
|
| 39 |
+
*/
|
| 40 |
+
async function invalidate_(resource) {
|
| 41 |
+
const { href } = new URL(resource, location.href);
|
| 42 |
+
return router.renderer.invalidate(href);
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
/**
|
| 46 |
+
* @type {import('$app/navigation').prefetch}
|
| 47 |
+
*/
|
| 48 |
+
function prefetch_(href) {
|
| 49 |
+
return router.prefetch(new URL(href, get_base_uri(document)));
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
/**
|
| 53 |
+
* @type {import('$app/navigation').prefetchRoutes}
|
| 54 |
+
*/
|
| 55 |
+
async function prefetchRoutes_(pathnames) {
|
| 56 |
+
const matching = pathnames
|
| 57 |
+
? router.routes.filter((route) => pathnames.some((pathname) => route[0].test(pathname)))
|
| 58 |
+
: router.routes;
|
| 59 |
+
|
| 60 |
+
const promises = matching.map((r) => Promise.all(r[1].map((load) => load())));
|
| 61 |
+
|
| 62 |
+
await Promise.all(promises);
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
export { disableScrollHandling, goto, invalidate, prefetch, prefetchRoutes };
|
.svelte-kit/build/runtime/app/paths.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
export { assets, base } from '../paths.js';
|
.svelte-kit/build/runtime/app/stores.js
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { getContext } from 'svelte';
|
| 2 |
+
import { browser } from './env.js';
|
| 3 |
+
import '../env.js';
|
| 4 |
+
|
| 5 |
+
const ssr = !browser;
|
| 6 |
+
|
| 7 |
+
// TODO remove this (for 1.0? after 1.0?)
|
| 8 |
+
let warned = false;
|
| 9 |
+
function stores() {
|
| 10 |
+
if (!warned) {
|
| 11 |
+
console.error('stores() is deprecated; use getStores() instead');
|
| 12 |
+
warned = true;
|
| 13 |
+
}
|
| 14 |
+
return getStores();
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
/**
|
| 18 |
+
* @type {import('$app/stores').getStores}
|
| 19 |
+
*/
|
| 20 |
+
const getStores = () => {
|
| 21 |
+
const stores = getContext('__svelte__');
|
| 22 |
+
|
| 23 |
+
return {
|
| 24 |
+
page: {
|
| 25 |
+
subscribe: stores.page.subscribe
|
| 26 |
+
},
|
| 27 |
+
navigating: {
|
| 28 |
+
subscribe: stores.navigating.subscribe
|
| 29 |
+
},
|
| 30 |
+
// TODO remove this (for 1.0? after 1.0?)
|
| 31 |
+
// @ts-expect-error - deprecated, not part of type definitions, but still callable
|
| 32 |
+
get preloading() {
|
| 33 |
+
console.error('stores.preloading is deprecated; use stores.navigating instead');
|
| 34 |
+
return {
|
| 35 |
+
subscribe: stores.navigating.subscribe
|
| 36 |
+
};
|
| 37 |
+
},
|
| 38 |
+
session: stores.session
|
| 39 |
+
};
|
| 40 |
+
};
|
| 41 |
+
|
| 42 |
+
/** @type {typeof import('$app/stores').page} */
|
| 43 |
+
const page = {
|
| 44 |
+
/** @param {(value: any) => void} fn */
|
| 45 |
+
subscribe(fn) {
|
| 46 |
+
const store = getStores().page;
|
| 47 |
+
return store.subscribe(fn);
|
| 48 |
+
}
|
| 49 |
+
};
|
| 50 |
+
|
| 51 |
+
/** @type {typeof import('$app/stores').navigating} */
|
| 52 |
+
const navigating = {
|
| 53 |
+
subscribe(fn) {
|
| 54 |
+
const store = getStores().navigating;
|
| 55 |
+
return store.subscribe(fn);
|
| 56 |
+
}
|
| 57 |
+
};
|
| 58 |
+
|
| 59 |
+
/** @param {string} verb */
|
| 60 |
+
const throw_error = (verb) => {
|
| 61 |
+
throw new Error(
|
| 62 |
+
ssr
|
| 63 |
+
? `Can only ${verb} session store in browser`
|
| 64 |
+
: `Cannot ${verb} session store before subscribing`
|
| 65 |
+
);
|
| 66 |
+
};
|
| 67 |
+
|
| 68 |
+
/** @type {typeof import('$app/stores').session} */
|
| 69 |
+
const session = {
|
| 70 |
+
subscribe(fn) {
|
| 71 |
+
const store = getStores().session;
|
| 72 |
+
|
| 73 |
+
if (!ssr) {
|
| 74 |
+
session.set = store.set;
|
| 75 |
+
session.update = store.update;
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
return store.subscribe(fn);
|
| 79 |
+
},
|
| 80 |
+
set: () => throw_error('set'),
|
| 81 |
+
update: () => throw_error('update')
|
| 82 |
+
};
|
| 83 |
+
|
| 84 |
+
export { getStores, navigating, page, session, stores };
|
.svelte-kit/build/runtime/chunks/utils.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/** @param {HTMLDocument} doc */
|
| 2 |
+
function get_base_uri(doc) {
|
| 3 |
+
let baseURI = doc.baseURI;
|
| 4 |
+
|
| 5 |
+
if (!baseURI) {
|
| 6 |
+
const baseTags = doc.getElementsByTagName('base');
|
| 7 |
+
baseURI = baseTags.length ? baseTags[0].href : doc.URL;
|
| 8 |
+
}
|
| 9 |
+
|
| 10 |
+
return baseURI;
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
export { get_base_uri as g };
|
.svelte-kit/build/runtime/env.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
let prerendering = false;
|
| 2 |
+
|
| 3 |
+
/** @param {boolean} value */
|
| 4 |
+
function set_prerendering(value) {
|
| 5 |
+
prerendering = value;
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
export { prerendering, set_prerendering };
|
.svelte-kit/build/runtime/internal/singletons.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/** @type {import('./router').Router?} */
|
| 2 |
+
let router;
|
| 3 |
+
|
| 4 |
+
/** @type {import('./renderer').Renderer} */
|
| 5 |
+
let renderer;
|
| 6 |
+
|
| 7 |
+
/**
|
| 8 |
+
* @param {{
|
| 9 |
+
* router: import('./router').Router?;
|
| 10 |
+
* renderer: import('./renderer').Renderer;
|
| 11 |
+
* }} opts
|
| 12 |
+
*/
|
| 13 |
+
function init(opts) {
|
| 14 |
+
router = opts.router;
|
| 15 |
+
renderer = opts.renderer;
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
export { init, renderer, router };
|
.svelte-kit/build/runtime/internal/start.js
ADDED
|
@@ -0,0 +1,1219 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Root from '../../generated/root.svelte';
|
| 2 |
+
import { fallback, routes } from '../../generated/manifest.js';
|
| 3 |
+
import { g as get_base_uri } from '../chunks/utils.js';
|
| 4 |
+
import { tick } from 'svelte';
|
| 5 |
+
import { writable } from 'svelte/store';
|
| 6 |
+
import { init } from './singletons.js';
|
| 7 |
+
import { set_paths } from '../paths.js';
|
| 8 |
+
|
| 9 |
+
function scroll_state() {
|
| 10 |
+
return {
|
| 11 |
+
x: pageXOffset,
|
| 12 |
+
y: pageYOffset
|
| 13 |
+
};
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
/**
|
| 17 |
+
* @param {Event} event
|
| 18 |
+
* @returns {HTMLAnchorElement | SVGAElement | undefined}
|
| 19 |
+
*/
|
| 20 |
+
function find_anchor(event) {
|
| 21 |
+
const node = event
|
| 22 |
+
.composedPath()
|
| 23 |
+
.find((e) => e instanceof Node && e.nodeName.toUpperCase() === 'A'); // SVG <a> elements have a lowercase name
|
| 24 |
+
return /** @type {HTMLAnchorElement | SVGAElement | undefined} */ (node);
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* @param {HTMLAnchorElement | SVGAElement} node
|
| 29 |
+
* @returns {URL}
|
| 30 |
+
*/
|
| 31 |
+
function get_href(node) {
|
| 32 |
+
return node instanceof SVGAElement
|
| 33 |
+
? new URL(node.href.baseVal, document.baseURI)
|
| 34 |
+
: new URL(node.href);
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
class Router {
|
| 38 |
+
/**
|
| 39 |
+
* @param {{
|
| 40 |
+
* base: string;
|
| 41 |
+
* routes: import('types/internal').CSRRoute[];
|
| 42 |
+
* trailing_slash: import('types/internal').TrailingSlash;
|
| 43 |
+
* renderer: import('./renderer').Renderer
|
| 44 |
+
* }} opts
|
| 45 |
+
*/
|
| 46 |
+
constructor({ base, routes, trailing_slash, renderer }) {
|
| 47 |
+
this.base = base;
|
| 48 |
+
this.routes = routes;
|
| 49 |
+
this.trailing_slash = trailing_slash;
|
| 50 |
+
/** Keeps tracks of multiple navigations caused by redirects during rendering */
|
| 51 |
+
this.navigating = 0;
|
| 52 |
+
|
| 53 |
+
/** @type {import('./renderer').Renderer} */
|
| 54 |
+
this.renderer = renderer;
|
| 55 |
+
renderer.router = this;
|
| 56 |
+
|
| 57 |
+
this.enabled = true;
|
| 58 |
+
|
| 59 |
+
// make it possible to reset focus
|
| 60 |
+
document.body.setAttribute('tabindex', '-1');
|
| 61 |
+
|
| 62 |
+
// create initial history entry, so we can return here
|
| 63 |
+
history.replaceState(history.state || {}, '', location.href);
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
init_listeners() {
|
| 67 |
+
if ('scrollRestoration' in history) {
|
| 68 |
+
history.scrollRestoration = 'manual';
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
// Adopted from Nuxt.js
|
| 72 |
+
// Reset scrollRestoration to auto when leaving page, allowing page reload
|
| 73 |
+
// and back-navigation from other pages to use the browser to restore the
|
| 74 |
+
// scrolling position.
|
| 75 |
+
addEventListener('beforeunload', () => {
|
| 76 |
+
history.scrollRestoration = 'auto';
|
| 77 |
+
});
|
| 78 |
+
|
| 79 |
+
// Setting scrollRestoration to manual again when returning to this page.
|
| 80 |
+
addEventListener('load', () => {
|
| 81 |
+
history.scrollRestoration = 'manual';
|
| 82 |
+
});
|
| 83 |
+
|
| 84 |
+
// There's no API to capture the scroll location right before the user
|
| 85 |
+
// hits the back/forward button, so we listen for scroll events
|
| 86 |
+
|
| 87 |
+
/** @type {NodeJS.Timeout} */
|
| 88 |
+
let scroll_timer;
|
| 89 |
+
addEventListener('scroll', () => {
|
| 90 |
+
clearTimeout(scroll_timer);
|
| 91 |
+
scroll_timer = setTimeout(() => {
|
| 92 |
+
// Store the scroll location in the history
|
| 93 |
+
// This will persist even if we navigate away from the site and come back
|
| 94 |
+
const new_state = {
|
| 95 |
+
...(history.state || {}),
|
| 96 |
+
'sveltekit:scroll': scroll_state()
|
| 97 |
+
};
|
| 98 |
+
history.replaceState(new_state, document.title, window.location.href);
|
| 99 |
+
// iOS scroll event intervals happen between 30-150ms, sometimes around 200ms
|
| 100 |
+
}, 200);
|
| 101 |
+
});
|
| 102 |
+
|
| 103 |
+
/** @param {Event} event */
|
| 104 |
+
const trigger_prefetch = (event) => {
|
| 105 |
+
const a = find_anchor(event);
|
| 106 |
+
if (a && a.href && a.hasAttribute('sveltekit:prefetch')) {
|
| 107 |
+
this.prefetch(get_href(a));
|
| 108 |
+
}
|
| 109 |
+
};
|
| 110 |
+
|
| 111 |
+
/** @type {NodeJS.Timeout} */
|
| 112 |
+
let mousemove_timeout;
|
| 113 |
+
|
| 114 |
+
/** @param {MouseEvent|TouchEvent} event */
|
| 115 |
+
const handle_mousemove = (event) => {
|
| 116 |
+
clearTimeout(mousemove_timeout);
|
| 117 |
+
mousemove_timeout = setTimeout(() => {
|
| 118 |
+
// event.composedPath(), which is used in find_anchor, will be empty if the event is read in a timeout
|
| 119 |
+
// add a layer of indirection to address that
|
| 120 |
+
event.target?.dispatchEvent(
|
| 121 |
+
new CustomEvent('sveltekit:trigger_prefetch', { bubbles: true })
|
| 122 |
+
);
|
| 123 |
+
}, 20);
|
| 124 |
+
};
|
| 125 |
+
|
| 126 |
+
addEventListener('touchstart', trigger_prefetch);
|
| 127 |
+
addEventListener('mousemove', handle_mousemove);
|
| 128 |
+
addEventListener('sveltekit:trigger_prefetch', trigger_prefetch);
|
| 129 |
+
|
| 130 |
+
/** @param {MouseEvent} event */
|
| 131 |
+
addEventListener('click', (event) => {
|
| 132 |
+
if (!this.enabled) return;
|
| 133 |
+
|
| 134 |
+
// Adapted from https://github.com/visionmedia/page.js
|
| 135 |
+
// MIT license https://github.com/visionmedia/page.js#license
|
| 136 |
+
if (event.button || event.which !== 1) return;
|
| 137 |
+
if (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return;
|
| 138 |
+
if (event.defaultPrevented) return;
|
| 139 |
+
|
| 140 |
+
const a = find_anchor(event);
|
| 141 |
+
if (!a) return;
|
| 142 |
+
|
| 143 |
+
if (!a.href) return;
|
| 144 |
+
|
| 145 |
+
const url = get_href(a);
|
| 146 |
+
const url_string = url.toString();
|
| 147 |
+
if (url_string === location.href) {
|
| 148 |
+
if (!location.hash) event.preventDefault();
|
| 149 |
+
return;
|
| 150 |
+
}
|
| 151 |
+
|
| 152 |
+
// Ignore if tag has
|
| 153 |
+
// 1. 'download' attribute
|
| 154 |
+
// 2. 'rel' attribute includes external
|
| 155 |
+
const rel = (a.getAttribute('rel') || '').split(/\s+/);
|
| 156 |
+
|
| 157 |
+
if (a.hasAttribute('download') || (rel && rel.includes('external'))) {
|
| 158 |
+
return;
|
| 159 |
+
}
|
| 160 |
+
|
| 161 |
+
// Ignore if <a> has a target
|
| 162 |
+
if (a instanceof SVGAElement ? a.target.baseVal : a.target) return;
|
| 163 |
+
|
| 164 |
+
if (!this.owns(url)) return;
|
| 165 |
+
|
| 166 |
+
// Check if new url only differs by hash
|
| 167 |
+
if (url.href.split('#')[0] === location.href.split('#')[0]) {
|
| 168 |
+
// Call `pushState` to add url to history so going back works.
|
| 169 |
+
// Also make a delay, otherwise the browser default behaviour would not kick in
|
| 170 |
+
setTimeout(() => history.pushState({}, '', url.href));
|
| 171 |
+
return;
|
| 172 |
+
}
|
| 173 |
+
|
| 174 |
+
history.pushState({}, '', url.href);
|
| 175 |
+
|
| 176 |
+
const noscroll = a.hasAttribute('sveltekit:noscroll');
|
| 177 |
+
this._navigate(url, noscroll ? scroll_state() : null, false, [], url.hash);
|
| 178 |
+
event.preventDefault();
|
| 179 |
+
});
|
| 180 |
+
|
| 181 |
+
addEventListener('popstate', (event) => {
|
| 182 |
+
if (event.state && this.enabled) {
|
| 183 |
+
const url = new URL(location.href);
|
| 184 |
+
this._navigate(url, event.state['sveltekit:scroll'], false, []);
|
| 185 |
+
}
|
| 186 |
+
});
|
| 187 |
+
}
|
| 188 |
+
|
| 189 |
+
/** @param {URL} url */
|
| 190 |
+
owns(url) {
|
| 191 |
+
return url.origin === location.origin && url.pathname.startsWith(this.base);
|
| 192 |
+
}
|
| 193 |
+
|
| 194 |
+
/**
|
| 195 |
+
* @param {URL} url
|
| 196 |
+
* @returns {import('./types').NavigationInfo | undefined}
|
| 197 |
+
*/
|
| 198 |
+
parse(url) {
|
| 199 |
+
if (this.owns(url)) {
|
| 200 |
+
const path = decodeURI(url.pathname.slice(this.base.length) || '/');
|
| 201 |
+
|
| 202 |
+
return {
|
| 203 |
+
id: url.pathname + url.search,
|
| 204 |
+
routes: this.routes.filter(([pattern]) => pattern.test(path)),
|
| 205 |
+
url,
|
| 206 |
+
path
|
| 207 |
+
};
|
| 208 |
+
}
|
| 209 |
+
}
|
| 210 |
+
|
| 211 |
+
/**
|
| 212 |
+
* @typedef {Parameters<typeof import('$app/navigation').goto>} GotoParams
|
| 213 |
+
*
|
| 214 |
+
* @param {GotoParams[0]} href
|
| 215 |
+
* @param {GotoParams[1]} opts
|
| 216 |
+
* @param {string[]} chain
|
| 217 |
+
*/
|
| 218 |
+
async goto(
|
| 219 |
+
href,
|
| 220 |
+
{ noscroll = false, replaceState = false, keepfocus = false, state = {} } = {},
|
| 221 |
+
chain
|
| 222 |
+
) {
|
| 223 |
+
const url = new URL(href, get_base_uri(document));
|
| 224 |
+
|
| 225 |
+
if (this.enabled && this.owns(url)) {
|
| 226 |
+
history[replaceState ? 'replaceState' : 'pushState'](state, '', href);
|
| 227 |
+
return this._navigate(url, noscroll ? scroll_state() : null, keepfocus, chain, url.hash);
|
| 228 |
+
}
|
| 229 |
+
|
| 230 |
+
location.href = url.href;
|
| 231 |
+
return new Promise(() => {
|
| 232 |
+
/* never resolves */
|
| 233 |
+
});
|
| 234 |
+
}
|
| 235 |
+
|
| 236 |
+
enable() {
|
| 237 |
+
this.enabled = true;
|
| 238 |
+
}
|
| 239 |
+
|
| 240 |
+
disable() {
|
| 241 |
+
this.enabled = false;
|
| 242 |
+
}
|
| 243 |
+
|
| 244 |
+
/**
|
| 245 |
+
* @param {URL} url
|
| 246 |
+
* @returns {Promise<import('./types').NavigationResult>}
|
| 247 |
+
*/
|
| 248 |
+
async prefetch(url) {
|
| 249 |
+
const info = this.parse(url);
|
| 250 |
+
|
| 251 |
+
if (!info) {
|
| 252 |
+
throw new Error('Attempted to prefetch a URL that does not belong to this app');
|
| 253 |
+
}
|
| 254 |
+
|
| 255 |
+
return this.renderer.load(info);
|
| 256 |
+
}
|
| 257 |
+
|
| 258 |
+
/**
|
| 259 |
+
* @param {URL} url
|
| 260 |
+
* @param {{ x: number, y: number }?} scroll
|
| 261 |
+
* @param {boolean} keepfocus
|
| 262 |
+
* @param {string[]} chain
|
| 263 |
+
* @param {string} [hash]
|
| 264 |
+
*/
|
| 265 |
+
async _navigate(url, scroll, keepfocus, chain, hash) {
|
| 266 |
+
const info = this.parse(url);
|
| 267 |
+
|
| 268 |
+
if (!info) {
|
| 269 |
+
throw new Error('Attempted to navigate to a URL that does not belong to this app');
|
| 270 |
+
}
|
| 271 |
+
|
| 272 |
+
if (!this.navigating) {
|
| 273 |
+
dispatchEvent(new CustomEvent('sveltekit:navigation-start'));
|
| 274 |
+
}
|
| 275 |
+
this.navigating++;
|
| 276 |
+
|
| 277 |
+
let { pathname } = url;
|
| 278 |
+
|
| 279 |
+
if (this.trailing_slash === 'never') {
|
| 280 |
+
if (pathname !== '/' && pathname.endsWith('/')) pathname = pathname.slice(0, -1);
|
| 281 |
+
} else if (this.trailing_slash === 'always') {
|
| 282 |
+
const is_file = /** @type {string} */ (url.pathname.split('/').pop()).includes('.');
|
| 283 |
+
if (!is_file && !pathname.endsWith('/')) pathname += '/';
|
| 284 |
+
}
|
| 285 |
+
|
| 286 |
+
info.url = new URL(url.origin + pathname + url.search + url.hash);
|
| 287 |
+
history.replaceState({}, '', info.url);
|
| 288 |
+
|
| 289 |
+
await this.renderer.handle_navigation(info, chain, false, { hash, scroll, keepfocus });
|
| 290 |
+
|
| 291 |
+
this.navigating--;
|
| 292 |
+
if (!this.navigating) {
|
| 293 |
+
dispatchEvent(new CustomEvent('sveltekit:navigation-end'));
|
| 294 |
+
}
|
| 295 |
+
}
|
| 296 |
+
}
|
| 297 |
+
|
| 298 |
+
/**
|
| 299 |
+
* @param {unknown} err
|
| 300 |
+
* @return {Error}
|
| 301 |
+
*/
|
| 302 |
+
function coalesce_to_error(err) {
|
| 303 |
+
return err instanceof Error ||
|
| 304 |
+
(err && /** @type {any} */ (err).name && /** @type {any} */ (err).message)
|
| 305 |
+
? /** @type {Error} */ (err)
|
| 306 |
+
: new Error(JSON.stringify(err));
|
| 307 |
+
}
|
| 308 |
+
|
| 309 |
+
/**
|
| 310 |
+
* Hash using djb2
|
| 311 |
+
* @param {import('types/hooks').StrictBody} value
|
| 312 |
+
*/
|
| 313 |
+
function hash(value) {
|
| 314 |
+
let hash = 5381;
|
| 315 |
+
let i = value.length;
|
| 316 |
+
|
| 317 |
+
if (typeof value === 'string') {
|
| 318 |
+
while (i) hash = (hash * 33) ^ value.charCodeAt(--i);
|
| 319 |
+
} else {
|
| 320 |
+
while (i) hash = (hash * 33) ^ value[--i];
|
| 321 |
+
}
|
| 322 |
+
|
| 323 |
+
return (hash >>> 0).toString(36);
|
| 324 |
+
}
|
| 325 |
+
|
| 326 |
+
/**
|
| 327 |
+
* @param {import('types/page').LoadOutput} loaded
|
| 328 |
+
* @returns {import('types/internal').NormalizedLoadOutput}
|
| 329 |
+
*/
|
| 330 |
+
function normalize(loaded) {
|
| 331 |
+
const has_error_status =
|
| 332 |
+
loaded.status && loaded.status >= 400 && loaded.status <= 599 && !loaded.redirect;
|
| 333 |
+
if (loaded.error || has_error_status) {
|
| 334 |
+
const status = loaded.status;
|
| 335 |
+
|
| 336 |
+
if (!loaded.error && has_error_status) {
|
| 337 |
+
return {
|
| 338 |
+
status: status || 500,
|
| 339 |
+
error: new Error()
|
| 340 |
+
};
|
| 341 |
+
}
|
| 342 |
+
|
| 343 |
+
const error = typeof loaded.error === 'string' ? new Error(loaded.error) : loaded.error;
|
| 344 |
+
|
| 345 |
+
if (!(error instanceof Error)) {
|
| 346 |
+
return {
|
| 347 |
+
status: 500,
|
| 348 |
+
error: new Error(
|
| 349 |
+
`"error" property returned from load() must be a string or instance of Error, received type "${typeof error}"`
|
| 350 |
+
)
|
| 351 |
+
};
|
| 352 |
+
}
|
| 353 |
+
|
| 354 |
+
if (!status || status < 400 || status > 599) {
|
| 355 |
+
console.warn('"error" returned from load() without a valid status code — defaulting to 500');
|
| 356 |
+
return { status: 500, error };
|
| 357 |
+
}
|
| 358 |
+
|
| 359 |
+
return { status, error };
|
| 360 |
+
}
|
| 361 |
+
|
| 362 |
+
if (loaded.redirect) {
|
| 363 |
+
if (!loaded.status || Math.floor(loaded.status / 100) !== 3) {
|
| 364 |
+
return {
|
| 365 |
+
status: 500,
|
| 366 |
+
error: new Error(
|
| 367 |
+
'"redirect" property returned from load() must be accompanied by a 3xx status code'
|
| 368 |
+
)
|
| 369 |
+
};
|
| 370 |
+
}
|
| 371 |
+
|
| 372 |
+
if (typeof loaded.redirect !== 'string') {
|
| 373 |
+
return {
|
| 374 |
+
status: 500,
|
| 375 |
+
error: new Error('"redirect" property returned from load() must be a string')
|
| 376 |
+
};
|
| 377 |
+
}
|
| 378 |
+
}
|
| 379 |
+
|
| 380 |
+
// TODO remove before 1.0
|
| 381 |
+
if (/** @type {any} */ (loaded).context) {
|
| 382 |
+
throw new Error(
|
| 383 |
+
'You are returning "context" from a load function. ' +
|
| 384 |
+
'"context" was renamed to "stuff", please adjust your code accordingly.'
|
| 385 |
+
);
|
| 386 |
+
}
|
| 387 |
+
|
| 388 |
+
return /** @type {import('types/internal').NormalizedLoadOutput} */ (loaded);
|
| 389 |
+
}
|
| 390 |
+
|
| 391 |
+
/**
|
| 392 |
+
* @typedef {import('types/internal').CSRComponent} CSRComponent
|
| 393 |
+
* @typedef {{ from: URL; to: URL }} Navigating
|
| 394 |
+
*/
|
| 395 |
+
|
| 396 |
+
/** @param {any} value */
|
| 397 |
+
function notifiable_store(value) {
|
| 398 |
+
const store = writable(value);
|
| 399 |
+
let ready = true;
|
| 400 |
+
|
| 401 |
+
function notify() {
|
| 402 |
+
ready = true;
|
| 403 |
+
store.update((val) => val);
|
| 404 |
+
}
|
| 405 |
+
|
| 406 |
+
/** @param {any} new_value */
|
| 407 |
+
function set(new_value) {
|
| 408 |
+
ready = false;
|
| 409 |
+
store.set(new_value);
|
| 410 |
+
}
|
| 411 |
+
|
| 412 |
+
/** @param {(value: any) => void} run */
|
| 413 |
+
function subscribe(run) {
|
| 414 |
+
/** @type {any} */
|
| 415 |
+
let old_value;
|
| 416 |
+
return store.subscribe((new_value) => {
|
| 417 |
+
if (old_value === undefined || (ready && new_value !== old_value)) {
|
| 418 |
+
run((old_value = new_value));
|
| 419 |
+
}
|
| 420 |
+
});
|
| 421 |
+
}
|
| 422 |
+
|
| 423 |
+
return { notify, set, subscribe };
|
| 424 |
+
}
|
| 425 |
+
|
| 426 |
+
/**
|
| 427 |
+
* @param {RequestInfo} resource
|
| 428 |
+
* @param {RequestInit} [opts]
|
| 429 |
+
*/
|
| 430 |
+
function initial_fetch(resource, opts) {
|
| 431 |
+
const url = typeof resource === 'string' ? resource : resource.url;
|
| 432 |
+
|
| 433 |
+
let selector = `script[data-type="svelte-data"][data-url=${JSON.stringify(url)}]`;
|
| 434 |
+
|
| 435 |
+
if (opts && typeof opts.body === 'string') {
|
| 436 |
+
selector += `[data-body="${hash(opts.body)}"]`;
|
| 437 |
+
}
|
| 438 |
+
|
| 439 |
+
const script = document.querySelector(selector);
|
| 440 |
+
if (script && script.textContent) {
|
| 441 |
+
const { body, ...init } = JSON.parse(script.textContent);
|
| 442 |
+
return Promise.resolve(new Response(body, init));
|
| 443 |
+
}
|
| 444 |
+
|
| 445 |
+
return fetch(resource, opts);
|
| 446 |
+
}
|
| 447 |
+
|
| 448 |
+
class Renderer {
|
| 449 |
+
/**
|
| 450 |
+
* @param {{
|
| 451 |
+
* Root: CSRComponent;
|
| 452 |
+
* fallback: [CSRComponent, CSRComponent];
|
| 453 |
+
* target: Node;
|
| 454 |
+
* session: any;
|
| 455 |
+
* }} opts
|
| 456 |
+
*/
|
| 457 |
+
constructor({ Root, fallback, target, session }) {
|
| 458 |
+
this.Root = Root;
|
| 459 |
+
this.fallback = fallback;
|
| 460 |
+
|
| 461 |
+
/** @type {import('./router').Router | undefined} */
|
| 462 |
+
this.router;
|
| 463 |
+
|
| 464 |
+
this.target = target;
|
| 465 |
+
|
| 466 |
+
this.started = false;
|
| 467 |
+
|
| 468 |
+
this.session_id = 1;
|
| 469 |
+
this.invalid = new Set();
|
| 470 |
+
this.invalidating = null;
|
| 471 |
+
this.autoscroll = true;
|
| 472 |
+
this.updating = false;
|
| 473 |
+
|
| 474 |
+
/** @type {import('./types').NavigationState} */
|
| 475 |
+
this.current = {
|
| 476 |
+
// @ts-ignore - we need the initial value to be null
|
| 477 |
+
url: null,
|
| 478 |
+
session_id: 0,
|
| 479 |
+
branch: []
|
| 480 |
+
};
|
| 481 |
+
|
| 482 |
+
/** @type {Map<string, import('./types').NavigationResult>} */
|
| 483 |
+
this.cache = new Map();
|
| 484 |
+
|
| 485 |
+
/** @type {{id: string | null, promise: Promise<import('./types').NavigationResult> | null}} */
|
| 486 |
+
this.loading = {
|
| 487 |
+
id: null,
|
| 488 |
+
promise: null
|
| 489 |
+
};
|
| 490 |
+
|
| 491 |
+
this.stores = {
|
| 492 |
+
url: notifiable_store({}),
|
| 493 |
+
page: notifiable_store({}),
|
| 494 |
+
navigating: writable(/** @type {Navigating | null} */ (null)),
|
| 495 |
+
session: writable(session)
|
| 496 |
+
};
|
| 497 |
+
|
| 498 |
+
this.$session = null;
|
| 499 |
+
|
| 500 |
+
this.root = null;
|
| 501 |
+
|
| 502 |
+
let ready = false;
|
| 503 |
+
this.stores.session.subscribe(async (value) => {
|
| 504 |
+
this.$session = value;
|
| 505 |
+
|
| 506 |
+
if (!ready || !this.router) return;
|
| 507 |
+
this.session_id += 1;
|
| 508 |
+
|
| 509 |
+
const info = this.router.parse(new URL(location.href));
|
| 510 |
+
if (info) this.update(info, [], true);
|
| 511 |
+
});
|
| 512 |
+
ready = true;
|
| 513 |
+
}
|
| 514 |
+
|
| 515 |
+
disable_scroll_handling() {
|
| 516 |
+
if (import.meta.env.DEV && this.started && !this.updating) {
|
| 517 |
+
throw new Error('Can only disable scroll handling during navigation');
|
| 518 |
+
}
|
| 519 |
+
|
| 520 |
+
if (this.updating || !this.started) {
|
| 521 |
+
this.autoscroll = false;
|
| 522 |
+
}
|
| 523 |
+
}
|
| 524 |
+
|
| 525 |
+
/**
|
| 526 |
+
* @param {{
|
| 527 |
+
* status: number;
|
| 528 |
+
* error: Error;
|
| 529 |
+
* nodes: Array<Promise<CSRComponent>>;
|
| 530 |
+
* url: URL;
|
| 531 |
+
* params: Record<string, string>;
|
| 532 |
+
* }} selected
|
| 533 |
+
*/
|
| 534 |
+
async start({ status, error, nodes, url, params }) {
|
| 535 |
+
/** @type {Array<import('./types').BranchNode | undefined>} */
|
| 536 |
+
const branch = [];
|
| 537 |
+
|
| 538 |
+
/** @type {Record<string, any>} */
|
| 539 |
+
let stuff = {};
|
| 540 |
+
|
| 541 |
+
/** @type {import('./types').NavigationResult | undefined} */
|
| 542 |
+
let result;
|
| 543 |
+
|
| 544 |
+
let error_args;
|
| 545 |
+
|
| 546 |
+
try {
|
| 547 |
+
for (let i = 0; i < nodes.length; i += 1) {
|
| 548 |
+
const is_leaf = i === nodes.length - 1;
|
| 549 |
+
|
| 550 |
+
const node = await this._load_node({
|
| 551 |
+
module: await nodes[i],
|
| 552 |
+
url,
|
| 553 |
+
params,
|
| 554 |
+
stuff,
|
| 555 |
+
status: is_leaf ? status : undefined,
|
| 556 |
+
error: is_leaf ? error : undefined
|
| 557 |
+
});
|
| 558 |
+
|
| 559 |
+
branch.push(node);
|
| 560 |
+
|
| 561 |
+
if (node && node.loaded) {
|
| 562 |
+
if (node.loaded.error) {
|
| 563 |
+
if (error) throw node.loaded.error;
|
| 564 |
+
error_args = {
|
| 565 |
+
status: node.loaded.status,
|
| 566 |
+
error: node.loaded.error,
|
| 567 |
+
url
|
| 568 |
+
};
|
| 569 |
+
} else if (node.loaded.stuff) {
|
| 570 |
+
stuff = {
|
| 571 |
+
...stuff,
|
| 572 |
+
...node.loaded.stuff
|
| 573 |
+
};
|
| 574 |
+
}
|
| 575 |
+
}
|
| 576 |
+
}
|
| 577 |
+
|
| 578 |
+
result = error_args
|
| 579 |
+
? await this._load_error(error_args)
|
| 580 |
+
: await this._get_navigation_result_from_branch({ url, params, branch, status, error });
|
| 581 |
+
} catch (e) {
|
| 582 |
+
if (error) throw e;
|
| 583 |
+
|
| 584 |
+
result = await this._load_error({
|
| 585 |
+
status: 500,
|
| 586 |
+
error: coalesce_to_error(e),
|
| 587 |
+
url
|
| 588 |
+
});
|
| 589 |
+
}
|
| 590 |
+
|
| 591 |
+
if (result.redirect) {
|
| 592 |
+
// this is a real edge case — `load` would need to return
|
| 593 |
+
// a redirect but only in the browser
|
| 594 |
+
location.href = new URL(result.redirect, location.href).href;
|
| 595 |
+
return;
|
| 596 |
+
}
|
| 597 |
+
|
| 598 |
+
this._init(result);
|
| 599 |
+
}
|
| 600 |
+
|
| 601 |
+
/**
|
| 602 |
+
* @param {import('./types').NavigationInfo} info
|
| 603 |
+
* @param {string[]} chain
|
| 604 |
+
* @param {boolean} no_cache
|
| 605 |
+
* @param {{hash?: string, scroll: { x: number, y: number } | null, keepfocus: boolean}} [opts]
|
| 606 |
+
*/
|
| 607 |
+
async handle_navigation(info, chain, no_cache, opts) {
|
| 608 |
+
if (this.started) {
|
| 609 |
+
this.stores.navigating.set({
|
| 610 |
+
from: this.current.url,
|
| 611 |
+
to: info.url
|
| 612 |
+
});
|
| 613 |
+
}
|
| 614 |
+
|
| 615 |
+
await this.update(info, chain, no_cache, opts);
|
| 616 |
+
}
|
| 617 |
+
|
| 618 |
+
/**
|
| 619 |
+
* @param {import('./types').NavigationInfo} info
|
| 620 |
+
* @param {string[]} chain
|
| 621 |
+
* @param {boolean} no_cache
|
| 622 |
+
* @param {{hash?: string, scroll: { x: number, y: number } | null, keepfocus: boolean}} [opts]
|
| 623 |
+
*/
|
| 624 |
+
async update(info, chain, no_cache, opts) {
|
| 625 |
+
const token = (this.token = {});
|
| 626 |
+
let navigation_result = await this._get_navigation_result(info, no_cache);
|
| 627 |
+
|
| 628 |
+
// abort if user navigated during update
|
| 629 |
+
if (token !== this.token) return;
|
| 630 |
+
|
| 631 |
+
this.invalid.clear();
|
| 632 |
+
|
| 633 |
+
if (navigation_result.redirect) {
|
| 634 |
+
if (chain.length > 10 || chain.includes(info.url.pathname)) {
|
| 635 |
+
navigation_result = await this._load_error({
|
| 636 |
+
status: 500,
|
| 637 |
+
error: new Error('Redirect loop'),
|
| 638 |
+
url: info.url
|
| 639 |
+
});
|
| 640 |
+
} else {
|
| 641 |
+
if (this.router) {
|
| 642 |
+
this.router.goto(navigation_result.redirect, { replaceState: true }, [
|
| 643 |
+
...chain,
|
| 644 |
+
info.url.pathname
|
| 645 |
+
]);
|
| 646 |
+
} else {
|
| 647 |
+
location.href = new URL(navigation_result.redirect, location.href).href;
|
| 648 |
+
}
|
| 649 |
+
|
| 650 |
+
return;
|
| 651 |
+
}
|
| 652 |
+
}
|
| 653 |
+
|
| 654 |
+
this.updating = true;
|
| 655 |
+
|
| 656 |
+
if (this.started) {
|
| 657 |
+
this.current = navigation_result.state;
|
| 658 |
+
|
| 659 |
+
this.root.$set(navigation_result.props);
|
| 660 |
+
this.stores.navigating.set(null);
|
| 661 |
+
} else {
|
| 662 |
+
this._init(navigation_result);
|
| 663 |
+
}
|
| 664 |
+
|
| 665 |
+
// opts must be passed if we're navigating
|
| 666 |
+
if (opts) {
|
| 667 |
+
const { hash, scroll, keepfocus } = opts;
|
| 668 |
+
|
| 669 |
+
if (!keepfocus) {
|
| 670 |
+
getSelection()?.removeAllRanges();
|
| 671 |
+
document.body.focus();
|
| 672 |
+
}
|
| 673 |
+
|
| 674 |
+
// need to render the DOM before we can scroll to the rendered elements
|
| 675 |
+
await tick();
|
| 676 |
+
|
| 677 |
+
if (this.autoscroll) {
|
| 678 |
+
const deep_linked = hash && document.getElementById(hash.slice(1));
|
| 679 |
+
if (scroll) {
|
| 680 |
+
scrollTo(scroll.x, scroll.y);
|
| 681 |
+
} else if (deep_linked) {
|
| 682 |
+
// Here we use `scrollIntoView` on the element instead of `scrollTo`
|
| 683 |
+
// because it natively supports the `scroll-margin` and `scroll-behavior`
|
| 684 |
+
// CSS properties.
|
| 685 |
+
deep_linked.scrollIntoView();
|
| 686 |
+
} else {
|
| 687 |
+
scrollTo(0, 0);
|
| 688 |
+
}
|
| 689 |
+
}
|
| 690 |
+
} else {
|
| 691 |
+
// in this case we're simply invalidating
|
| 692 |
+
await tick();
|
| 693 |
+
}
|
| 694 |
+
|
| 695 |
+
this.loading.promise = null;
|
| 696 |
+
this.loading.id = null;
|
| 697 |
+
this.autoscroll = true;
|
| 698 |
+
this.updating = false;
|
| 699 |
+
|
| 700 |
+
if (!this.router) return;
|
| 701 |
+
|
| 702 |
+
const leaf_node = navigation_result.state.branch[navigation_result.state.branch.length - 1];
|
| 703 |
+
if (leaf_node && leaf_node.module.router === false) {
|
| 704 |
+
this.router.disable();
|
| 705 |
+
} else {
|
| 706 |
+
this.router.enable();
|
| 707 |
+
}
|
| 708 |
+
}
|
| 709 |
+
|
| 710 |
+
/**
|
| 711 |
+
* @param {import('./types').NavigationInfo} info
|
| 712 |
+
* @returns {Promise<import('./types').NavigationResult>}
|
| 713 |
+
*/
|
| 714 |
+
load(info) {
|
| 715 |
+
this.loading.promise = this._get_navigation_result(info, false);
|
| 716 |
+
this.loading.id = info.id;
|
| 717 |
+
|
| 718 |
+
return this.loading.promise;
|
| 719 |
+
}
|
| 720 |
+
|
| 721 |
+
/** @param {string} href */
|
| 722 |
+
invalidate(href) {
|
| 723 |
+
this.invalid.add(href);
|
| 724 |
+
|
| 725 |
+
if (!this.invalidating) {
|
| 726 |
+
this.invalidating = Promise.resolve().then(async () => {
|
| 727 |
+
const info = this.router && this.router.parse(new URL(location.href));
|
| 728 |
+
if (info) await this.update(info, [], true);
|
| 729 |
+
|
| 730 |
+
this.invalidating = null;
|
| 731 |
+
});
|
| 732 |
+
}
|
| 733 |
+
|
| 734 |
+
return this.invalidating;
|
| 735 |
+
}
|
| 736 |
+
|
| 737 |
+
/** @param {import('./types').NavigationResult} result */
|
| 738 |
+
_init(result) {
|
| 739 |
+
this.current = result.state;
|
| 740 |
+
|
| 741 |
+
const style = document.querySelector('style[data-svelte]');
|
| 742 |
+
if (style) style.remove();
|
| 743 |
+
|
| 744 |
+
this.root = new this.Root({
|
| 745 |
+
target: this.target,
|
| 746 |
+
props: {
|
| 747 |
+
stores: this.stores,
|
| 748 |
+
...result.props
|
| 749 |
+
},
|
| 750 |
+
hydrate: true
|
| 751 |
+
});
|
| 752 |
+
|
| 753 |
+
this.started = true;
|
| 754 |
+
}
|
| 755 |
+
|
| 756 |
+
/**
|
| 757 |
+
* @param {import('./types').NavigationInfo} info
|
| 758 |
+
* @param {boolean} no_cache
|
| 759 |
+
* @returns {Promise<import('./types').NavigationResult>}
|
| 760 |
+
*/
|
| 761 |
+
async _get_navigation_result(info, no_cache) {
|
| 762 |
+
if (this.loading.id === info.id && this.loading.promise) {
|
| 763 |
+
return this.loading.promise;
|
| 764 |
+
}
|
| 765 |
+
|
| 766 |
+
for (let i = 0; i < info.routes.length; i += 1) {
|
| 767 |
+
const route = info.routes[i];
|
| 768 |
+
|
| 769 |
+
// load code for subsequent routes immediately, if they are as
|
| 770 |
+
// likely to match the current path/query as the current one
|
| 771 |
+
let j = i + 1;
|
| 772 |
+
while (j < info.routes.length) {
|
| 773 |
+
const next = info.routes[j];
|
| 774 |
+
if (next[0].toString() === route[0].toString()) {
|
| 775 |
+
next[1].forEach((loader) => loader());
|
| 776 |
+
j += 1;
|
| 777 |
+
} else {
|
| 778 |
+
break;
|
| 779 |
+
}
|
| 780 |
+
}
|
| 781 |
+
|
| 782 |
+
const result = await this._load(
|
| 783 |
+
{
|
| 784 |
+
route,
|
| 785 |
+
info
|
| 786 |
+
},
|
| 787 |
+
no_cache
|
| 788 |
+
);
|
| 789 |
+
if (result) return result;
|
| 790 |
+
}
|
| 791 |
+
|
| 792 |
+
return await this._load_error({
|
| 793 |
+
status: 404,
|
| 794 |
+
error: new Error(`Not found: ${info.url.pathname}`),
|
| 795 |
+
url: info.url
|
| 796 |
+
});
|
| 797 |
+
}
|
| 798 |
+
|
| 799 |
+
/**
|
| 800 |
+
*
|
| 801 |
+
* @param {{
|
| 802 |
+
* url: URL;
|
| 803 |
+
* params: Record<string, string>;
|
| 804 |
+
* branch: Array<import('./types').BranchNode | undefined>;
|
| 805 |
+
* status: number;
|
| 806 |
+
* error?: Error;
|
| 807 |
+
* }} opts
|
| 808 |
+
*/
|
| 809 |
+
async _get_navigation_result_from_branch({ url, params, branch, status, error }) {
|
| 810 |
+
const filtered = /** @type {import('./types').BranchNode[] } */ (branch.filter(Boolean));
|
| 811 |
+
const redirect = filtered.find((f) => f.loaded && f.loaded.redirect);
|
| 812 |
+
|
| 813 |
+
/** @type {import('./types').NavigationResult} */
|
| 814 |
+
const result = {
|
| 815 |
+
redirect: redirect && redirect.loaded ? redirect.loaded.redirect : undefined,
|
| 816 |
+
state: {
|
| 817 |
+
url,
|
| 818 |
+
params,
|
| 819 |
+
branch,
|
| 820 |
+
session_id: this.session_id
|
| 821 |
+
},
|
| 822 |
+
props: {
|
| 823 |
+
components: filtered.map((node) => node.module.default)
|
| 824 |
+
}
|
| 825 |
+
};
|
| 826 |
+
|
| 827 |
+
for (let i = 0; i < filtered.length; i += 1) {
|
| 828 |
+
const loaded = filtered[i].loaded;
|
| 829 |
+
result.props[`props_${i}`] = loaded ? await loaded.props : null;
|
| 830 |
+
}
|
| 831 |
+
|
| 832 |
+
if (!this.current.url || url.href !== this.current.url.href) {
|
| 833 |
+
result.props.page = { url, params, status, error };
|
| 834 |
+
|
| 835 |
+
// TODO remove this for 1.0
|
| 836 |
+
/**
|
| 837 |
+
* @param {string} property
|
| 838 |
+
* @param {string} replacement
|
| 839 |
+
*/
|
| 840 |
+
const print_error = (property, replacement) => {
|
| 841 |
+
Object.defineProperty(result.props.page, property, {
|
| 842 |
+
get: () => {
|
| 843 |
+
throw new Error(`$page.${property} has been replaced by $page.url.${replacement}`);
|
| 844 |
+
}
|
| 845 |
+
});
|
| 846 |
+
};
|
| 847 |
+
|
| 848 |
+
print_error('origin', 'origin');
|
| 849 |
+
print_error('path', 'pathname');
|
| 850 |
+
print_error('query', 'searchParams');
|
| 851 |
+
}
|
| 852 |
+
|
| 853 |
+
const leaf = filtered[filtered.length - 1];
|
| 854 |
+
const maxage = leaf.loaded && leaf.loaded.maxage;
|
| 855 |
+
|
| 856 |
+
if (maxage) {
|
| 857 |
+
const key = url.pathname + url.search; // omit hash
|
| 858 |
+
let ready = false;
|
| 859 |
+
|
| 860 |
+
const clear = () => {
|
| 861 |
+
if (this.cache.get(key) === result) {
|
| 862 |
+
this.cache.delete(key);
|
| 863 |
+
}
|
| 864 |
+
|
| 865 |
+
unsubscribe();
|
| 866 |
+
clearTimeout(timeout);
|
| 867 |
+
};
|
| 868 |
+
|
| 869 |
+
const timeout = setTimeout(clear, maxage * 1000);
|
| 870 |
+
|
| 871 |
+
const unsubscribe = this.stores.session.subscribe(() => {
|
| 872 |
+
if (ready) clear();
|
| 873 |
+
});
|
| 874 |
+
|
| 875 |
+
ready = true;
|
| 876 |
+
|
| 877 |
+
this.cache.set(key, result);
|
| 878 |
+
}
|
| 879 |
+
|
| 880 |
+
return result;
|
| 881 |
+
}
|
| 882 |
+
|
| 883 |
+
/**
|
| 884 |
+
* @param {{
|
| 885 |
+
* status?: number;
|
| 886 |
+
* error?: Error;
|
| 887 |
+
* module: CSRComponent;
|
| 888 |
+
* url: URL;
|
| 889 |
+
* params: Record<string, string>;
|
| 890 |
+
* stuff: Record<string, any>;
|
| 891 |
+
* }} options
|
| 892 |
+
* @returns
|
| 893 |
+
*/
|
| 894 |
+
async _load_node({ status, error, module, url, params, stuff }) {
|
| 895 |
+
/** @type {import('./types').BranchNode} */
|
| 896 |
+
const node = {
|
| 897 |
+
module,
|
| 898 |
+
uses: {
|
| 899 |
+
params: new Set(),
|
| 900 |
+
url: false,
|
| 901 |
+
session: false,
|
| 902 |
+
stuff: false,
|
| 903 |
+
dependencies: []
|
| 904 |
+
},
|
| 905 |
+
loaded: null,
|
| 906 |
+
stuff
|
| 907 |
+
};
|
| 908 |
+
|
| 909 |
+
/** @type {Record<string, string>} */
|
| 910 |
+
const uses_params = {};
|
| 911 |
+
for (const key in params) {
|
| 912 |
+
Object.defineProperty(uses_params, key, {
|
| 913 |
+
get() {
|
| 914 |
+
node.uses.params.add(key);
|
| 915 |
+
return params[key];
|
| 916 |
+
},
|
| 917 |
+
enumerable: true
|
| 918 |
+
});
|
| 919 |
+
}
|
| 920 |
+
|
| 921 |
+
const session = this.$session;
|
| 922 |
+
|
| 923 |
+
if (module.load) {
|
| 924 |
+
const { started } = this;
|
| 925 |
+
|
| 926 |
+
/** @type {import('types/page').LoadInput | import('types/page').ErrorLoadInput} */
|
| 927 |
+
const load_input = {
|
| 928 |
+
params: uses_params,
|
| 929 |
+
get url() {
|
| 930 |
+
node.uses.url = true;
|
| 931 |
+
return url;
|
| 932 |
+
},
|
| 933 |
+
get session() {
|
| 934 |
+
node.uses.session = true;
|
| 935 |
+
return session;
|
| 936 |
+
},
|
| 937 |
+
get stuff() {
|
| 938 |
+
node.uses.stuff = true;
|
| 939 |
+
return { ...stuff };
|
| 940 |
+
},
|
| 941 |
+
fetch(resource, info) {
|
| 942 |
+
const requested = typeof resource === 'string' ? resource : resource.url;
|
| 943 |
+
const { href } = new URL(requested, url);
|
| 944 |
+
node.uses.dependencies.push(href);
|
| 945 |
+
|
| 946 |
+
return started ? fetch(resource, info) : initial_fetch(resource, info);
|
| 947 |
+
}
|
| 948 |
+
};
|
| 949 |
+
|
| 950 |
+
if (import.meta.env.DEV) {
|
| 951 |
+
// TODO remove this for 1.0
|
| 952 |
+
Object.defineProperty(load_input, 'page', {
|
| 953 |
+
get: () => {
|
| 954 |
+
throw new Error('`page` in `load` functions has been replaced by `url` and `params`');
|
| 955 |
+
}
|
| 956 |
+
});
|
| 957 |
+
}
|
| 958 |
+
|
| 959 |
+
if (error) {
|
| 960 |
+
/** @type {import('types/page').ErrorLoadInput} */ (load_input).status = status;
|
| 961 |
+
/** @type {import('types/page').ErrorLoadInput} */ (load_input).error = error;
|
| 962 |
+
}
|
| 963 |
+
|
| 964 |
+
const loaded = await module.load.call(null, load_input);
|
| 965 |
+
|
| 966 |
+
// if the page component returns nothing from load, fall through
|
| 967 |
+
if (!loaded) return;
|
| 968 |
+
|
| 969 |
+
node.loaded = normalize(loaded);
|
| 970 |
+
if (node.loaded.stuff) node.stuff = node.loaded.stuff;
|
| 971 |
+
}
|
| 972 |
+
|
| 973 |
+
return node;
|
| 974 |
+
}
|
| 975 |
+
|
| 976 |
+
/**
|
| 977 |
+
* @param {import('./types').NavigationCandidate} selected
|
| 978 |
+
* @param {boolean} no_cache
|
| 979 |
+
* @returns {Promise<import('./types').NavigationResult | undefined>} undefined if fallthrough
|
| 980 |
+
*/
|
| 981 |
+
async _load({ route, info: { url, path } }, no_cache) {
|
| 982 |
+
const key = url.pathname + url.search;
|
| 983 |
+
|
| 984 |
+
if (!no_cache) {
|
| 985 |
+
const cached = this.cache.get(key);
|
| 986 |
+
if (cached) return cached;
|
| 987 |
+
}
|
| 988 |
+
|
| 989 |
+
const [pattern, a, b, get_params] = route;
|
| 990 |
+
const params = get_params
|
| 991 |
+
? // the pattern is for the route which we've already matched to this path
|
| 992 |
+
get_params(/** @type {RegExpExecArray} */ (pattern.exec(path)))
|
| 993 |
+
: {};
|
| 994 |
+
|
| 995 |
+
const changed = this.current.url && {
|
| 996 |
+
url: key !== this.current.url.pathname + this.current.url.search,
|
| 997 |
+
params: Object.keys(params).filter((key) => this.current.params[key] !== params[key]),
|
| 998 |
+
session: this.session_id !== this.current.session_id
|
| 999 |
+
};
|
| 1000 |
+
|
| 1001 |
+
/** @type {Array<import('./types').BranchNode | undefined>} */
|
| 1002 |
+
let branch = [];
|
| 1003 |
+
|
| 1004 |
+
/** @type {Record<string, any>} */
|
| 1005 |
+
let stuff = {};
|
| 1006 |
+
let stuff_changed = false;
|
| 1007 |
+
|
| 1008 |
+
/** @type {number | undefined} */
|
| 1009 |
+
let status = 200;
|
| 1010 |
+
|
| 1011 |
+
/** @type {Error | undefined} */
|
| 1012 |
+
let error;
|
| 1013 |
+
|
| 1014 |
+
// preload modules
|
| 1015 |
+
a.forEach((loader) => loader());
|
| 1016 |
+
|
| 1017 |
+
load: for (let i = 0; i < a.length; i += 1) {
|
| 1018 |
+
/** @type {import('./types').BranchNode | undefined} */
|
| 1019 |
+
let node;
|
| 1020 |
+
|
| 1021 |
+
try {
|
| 1022 |
+
if (!a[i]) continue;
|
| 1023 |
+
|
| 1024 |
+
const module = await a[i]();
|
| 1025 |
+
const previous = this.current.branch[i];
|
| 1026 |
+
|
| 1027 |
+
const changed_since_last_render =
|
| 1028 |
+
!previous ||
|
| 1029 |
+
module !== previous.module ||
|
| 1030 |
+
(changed.url && previous.uses.url) ||
|
| 1031 |
+
changed.params.some((param) => previous.uses.params.has(param)) ||
|
| 1032 |
+
(changed.session && previous.uses.session) ||
|
| 1033 |
+
previous.uses.dependencies.some((dep) => this.invalid.has(dep)) ||
|
| 1034 |
+
(stuff_changed && previous.uses.stuff);
|
| 1035 |
+
|
| 1036 |
+
if (changed_since_last_render) {
|
| 1037 |
+
node = await this._load_node({
|
| 1038 |
+
module,
|
| 1039 |
+
url,
|
| 1040 |
+
params,
|
| 1041 |
+
stuff
|
| 1042 |
+
});
|
| 1043 |
+
|
| 1044 |
+
const is_leaf = i === a.length - 1;
|
| 1045 |
+
|
| 1046 |
+
if (node && node.loaded) {
|
| 1047 |
+
if (node.loaded.error) {
|
| 1048 |
+
status = node.loaded.status;
|
| 1049 |
+
error = node.loaded.error;
|
| 1050 |
+
}
|
| 1051 |
+
|
| 1052 |
+
if (node.loaded.redirect) {
|
| 1053 |
+
return {
|
| 1054 |
+
redirect: node.loaded.redirect,
|
| 1055 |
+
props: {},
|
| 1056 |
+
state: this.current
|
| 1057 |
+
};
|
| 1058 |
+
}
|
| 1059 |
+
|
| 1060 |
+
if (node.loaded.stuff) {
|
| 1061 |
+
stuff_changed = true;
|
| 1062 |
+
}
|
| 1063 |
+
} else if (is_leaf && module.load) {
|
| 1064 |
+
// if the leaf node has a `load` function
|
| 1065 |
+
// that returns nothing, fall through
|
| 1066 |
+
return;
|
| 1067 |
+
}
|
| 1068 |
+
} else {
|
| 1069 |
+
node = previous;
|
| 1070 |
+
}
|
| 1071 |
+
} catch (e) {
|
| 1072 |
+
status = 500;
|
| 1073 |
+
error = coalesce_to_error(e);
|
| 1074 |
+
}
|
| 1075 |
+
|
| 1076 |
+
if (error) {
|
| 1077 |
+
while (i--) {
|
| 1078 |
+
if (b[i]) {
|
| 1079 |
+
let error_loaded;
|
| 1080 |
+
|
| 1081 |
+
/** @type {import('./types').BranchNode | undefined} */
|
| 1082 |
+
let node_loaded;
|
| 1083 |
+
let j = i;
|
| 1084 |
+
while (!(node_loaded = branch[j])) {
|
| 1085 |
+
j -= 1;
|
| 1086 |
+
}
|
| 1087 |
+
|
| 1088 |
+
try {
|
| 1089 |
+
error_loaded = await this._load_node({
|
| 1090 |
+
status,
|
| 1091 |
+
error,
|
| 1092 |
+
module: await b[i](),
|
| 1093 |
+
url,
|
| 1094 |
+
params,
|
| 1095 |
+
stuff: node_loaded.stuff
|
| 1096 |
+
});
|
| 1097 |
+
|
| 1098 |
+
if (error_loaded && error_loaded.loaded && error_loaded.loaded.error) {
|
| 1099 |
+
continue;
|
| 1100 |
+
}
|
| 1101 |
+
|
| 1102 |
+
branch = branch.slice(0, j + 1).concat(error_loaded);
|
| 1103 |
+
break load;
|
| 1104 |
+
} catch (e) {
|
| 1105 |
+
continue;
|
| 1106 |
+
}
|
| 1107 |
+
}
|
| 1108 |
+
}
|
| 1109 |
+
|
| 1110 |
+
return await this._load_error({
|
| 1111 |
+
status,
|
| 1112 |
+
error,
|
| 1113 |
+
url
|
| 1114 |
+
});
|
| 1115 |
+
} else {
|
| 1116 |
+
if (node && node.loaded && node.loaded.stuff) {
|
| 1117 |
+
stuff = {
|
| 1118 |
+
...stuff,
|
| 1119 |
+
...node.loaded.stuff
|
| 1120 |
+
};
|
| 1121 |
+
}
|
| 1122 |
+
|
| 1123 |
+
branch.push(node);
|
| 1124 |
+
}
|
| 1125 |
+
}
|
| 1126 |
+
|
| 1127 |
+
return await this._get_navigation_result_from_branch({ url, params, branch, status, error });
|
| 1128 |
+
}
|
| 1129 |
+
|
| 1130 |
+
/**
|
| 1131 |
+
* @param {{
|
| 1132 |
+
* status: number;
|
| 1133 |
+
* error: Error;
|
| 1134 |
+
* url: URL;
|
| 1135 |
+
* }} opts
|
| 1136 |
+
*/
|
| 1137 |
+
async _load_error({ status, error, url }) {
|
| 1138 |
+
/** @type {Record<string, string>} */
|
| 1139 |
+
const params = {}; // error page does not have params
|
| 1140 |
+
|
| 1141 |
+
const node = await this._load_node({
|
| 1142 |
+
module: await this.fallback[0],
|
| 1143 |
+
url,
|
| 1144 |
+
params,
|
| 1145 |
+
stuff: {}
|
| 1146 |
+
});
|
| 1147 |
+
|
| 1148 |
+
const branch = [
|
| 1149 |
+
node,
|
| 1150 |
+
await this._load_node({
|
| 1151 |
+
status,
|
| 1152 |
+
error,
|
| 1153 |
+
module: await this.fallback[1],
|
| 1154 |
+
url,
|
| 1155 |
+
params,
|
| 1156 |
+
stuff: (node && node.loaded && node.loaded.stuff) || {}
|
| 1157 |
+
})
|
| 1158 |
+
];
|
| 1159 |
+
|
| 1160 |
+
return await this._get_navigation_result_from_branch({ url, params, branch, status, error });
|
| 1161 |
+
}
|
| 1162 |
+
}
|
| 1163 |
+
|
| 1164 |
+
// @ts-expect-error - doesn't exist yet. generated by Rollup
|
| 1165 |
+
|
| 1166 |
+
/**
|
| 1167 |
+
* @param {{
|
| 1168 |
+
* paths: {
|
| 1169 |
+
* assets: string;
|
| 1170 |
+
* base: string;
|
| 1171 |
+
* },
|
| 1172 |
+
* target: Node;
|
| 1173 |
+
* session: any;
|
| 1174 |
+
* route: boolean;
|
| 1175 |
+
* spa: boolean;
|
| 1176 |
+
* trailing_slash: import('types/internal').TrailingSlash;
|
| 1177 |
+
* hydrate: {
|
| 1178 |
+
* status: number;
|
| 1179 |
+
* error: Error;
|
| 1180 |
+
* nodes: Array<Promise<import('types/internal').CSRComponent>>;
|
| 1181 |
+
* url: URL;
|
| 1182 |
+
* params: Record<string, string>;
|
| 1183 |
+
* };
|
| 1184 |
+
* }} opts
|
| 1185 |
+
*/
|
| 1186 |
+
async function start({ paths, target, session, route, spa, trailing_slash, hydrate }) {
|
| 1187 |
+
if (import.meta.env.DEV && !target) {
|
| 1188 |
+
throw new Error('Missing target element. See https://kit.svelte.dev/docs#configuration-target');
|
| 1189 |
+
}
|
| 1190 |
+
|
| 1191 |
+
const renderer = new Renderer({
|
| 1192 |
+
Root,
|
| 1193 |
+
fallback,
|
| 1194 |
+
target,
|
| 1195 |
+
session
|
| 1196 |
+
});
|
| 1197 |
+
|
| 1198 |
+
const router = route
|
| 1199 |
+
? new Router({
|
| 1200 |
+
base: paths.base,
|
| 1201 |
+
routes,
|
| 1202 |
+
trailing_slash,
|
| 1203 |
+
renderer
|
| 1204 |
+
})
|
| 1205 |
+
: null;
|
| 1206 |
+
|
| 1207 |
+
init({ router, renderer });
|
| 1208 |
+
set_paths(paths);
|
| 1209 |
+
|
| 1210 |
+
if (hydrate) await renderer.start(hydrate);
|
| 1211 |
+
if (router) {
|
| 1212 |
+
if (spa) router.goto(location.href, { replaceState: true }, []);
|
| 1213 |
+
router.init_listeners();
|
| 1214 |
+
}
|
| 1215 |
+
|
| 1216 |
+
dispatchEvent(new CustomEvent('sveltekit:start'));
|
| 1217 |
+
}
|
| 1218 |
+
|
| 1219 |
+
export { start };
|
.svelte-kit/build/runtime/paths.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/** @type {string} */
|
| 2 |
+
let base = '';
|
| 3 |
+
|
| 4 |
+
/** @type {string} */
|
| 5 |
+
let assets = '';
|
| 6 |
+
|
| 7 |
+
/** @param {{ base: string, assets: string }} paths */
|
| 8 |
+
function set_paths(paths) {
|
| 9 |
+
base = paths.base;
|
| 10 |
+
assets = paths.assets || base;
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
export { assets, base, set_paths };
|
{_app → .svelte-kit/output/client/_app}/assets/fira-mono-all-400-normal-0d19eb5d.woff
RENAMED
|
File without changes
|
{_app → .svelte-kit/output/client/_app}/assets/fira-mono-cyrillic-400-normal-046b609f.woff2
RENAMED
|
File without changes
|
{_app → .svelte-kit/output/client/_app}/assets/fira-mono-cyrillic-ext-400-normal-b3140dd3.woff2
RENAMED
|
File without changes
|
{_app → .svelte-kit/output/client/_app}/assets/fira-mono-greek-400-normal-1f8b3a07.woff2
RENAMED
|
File without changes
|
{_app → .svelte-kit/output/client/_app}/assets/fira-mono-greek-ext-400-normal-8659ae46.woff2
RENAMED
|
File without changes
|
{_app → .svelte-kit/output/client/_app}/assets/fira-mono-latin-400-normal-a2f9dbe8.woff2
RENAMED
|
File without changes
|
{_app → .svelte-kit/output/client/_app}/assets/fira-mono-latin-ext-400-normal-b6331a25.woff2
RENAMED
|
File without changes
|
.svelte-kit/output/client/_app/assets/pages/__layout.svelte-343606d7.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
header.svelte-t2wq17.svelte-t2wq17{display:flex;justify-content:space-between}.corner.svelte-t2wq17.svelte-t2wq17{width:3em;height:3em}.corner.svelte-t2wq17 a.svelte-t2wq17{display:flex;align-items:center;justify-content:center;width:100%;height:100%}.corner.svelte-t2wq17 img.svelte-t2wq17{width:2em;height:2em;object-fit:contain}nav.svelte-t2wq17.svelte-t2wq17{display:flex;justify-content:center;--background:rgba(255, 255, 255, .7)}svg.svelte-t2wq17.svelte-t2wq17{width:2em;height:3em;display:block}path.svelte-t2wq17.svelte-t2wq17{fill:var(--background)}ul.svelte-t2wq17.svelte-t2wq17{position:relative;padding:0;margin:0;height:3em;display:flex;justify-content:center;align-items:center;list-style:none;background:var(--background);background-size:contain}li.svelte-t2wq17.svelte-t2wq17{position:relative;height:100%}li.active.svelte-t2wq17.svelte-t2wq17:before{--size:6px;content:"";width:0;height:0;position:absolute;top:0;left:calc(50% - var(--size));border:var(--size) solid transparent;border-top:var(--size) solid var(--accent-color)}nav.svelte-t2wq17 a.svelte-t2wq17{display:flex;height:100%;align-items:center;padding:0 1em;color:var(--heading-color);font-weight:700;font-size:.8rem;text-transform:uppercase;letter-spacing:.1em;text-decoration:none;transition:color .2s linear}a.svelte-t2wq17.svelte-t2wq17:hover{color:var(--accent-color)}@font-face{font-family:Fira Mono;font-style:normal;font-display:swap;font-weight:400;src:url(/staticspaceiframe/spaces/pngwn/static-test/_app/assets/fira-mono-cyrillic-ext-400-normal-b3140dd3.woff2) format("woff2"),url(/staticspaceiframe/spaces/pngwn/static-test/_app/assets/fira-mono-all-400-normal-0d19eb5d.woff) format("woff");unicode-range:U+0460-052F,U+1C80-1C88,U+20B4,U+2DE0-2DFF,U+A640-A69F,U+FE2E-FE2F}@font-face{font-family:Fira Mono;font-style:normal;font-display:swap;font-weight:400;src:url(/staticspaceiframe/spaces/pngwn/static-test/_app/assets/fira-mono-cyrillic-400-normal-046b609f.woff2) format("woff2"),url(/staticspaceiframe/spaces/pngwn/static-test/_app/assets/fira-mono-all-400-normal-0d19eb5d.woff) format("woff");unicode-range:U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116}@font-face{font-family:Fira Mono;font-style:normal;font-display:swap;font-weight:400;src:url(/staticspaceiframe/spaces/pngwn/static-test/_app/assets/fira-mono-greek-ext-400-normal-8659ae46.woff2) format("woff2"),url(/staticspaceiframe/spaces/pngwn/static-test/_app/assets/fira-mono-all-400-normal-0d19eb5d.woff) format("woff");unicode-range:U+1F00-1FFF}@font-face{font-family:Fira Mono;font-style:normal;font-display:swap;font-weight:400;src:url(/staticspaceiframe/spaces/pngwn/static-test/_app/assets/fira-mono-greek-400-normal-1f8b3a07.woff2) format("woff2"),url(/staticspaceiframe/spaces/pngwn/static-test/_app/assets/fira-mono-all-400-normal-0d19eb5d.woff) format("woff");unicode-range:U+0370-03FF}@font-face{font-family:Fira Mono;font-style:normal;font-display:swap;font-weight:400;src:url(/staticspaceiframe/spaces/pngwn/static-test/_app/assets/fira-mono-latin-ext-400-normal-b6331a25.woff2) format("woff2"),url(/staticspaceiframe/spaces/pngwn/static-test/_app/assets/fira-mono-all-400-normal-0d19eb5d.woff) format("woff");unicode-range:U+0100-024F,U+0259,U+1E00-1EFF,U+2020,U+20A0-20AB,U+20AD-20CF,U+2113,U+2C60-2C7F,U+A720-A7FF}@font-face{font-family:Fira Mono;font-style:normal;font-display:swap;font-weight:400;src:url(/staticspaceiframe/spaces/pngwn/static-test/_app/assets/fira-mono-latin-400-normal-a2f9dbe8.woff2) format("woff2"),url(/staticspaceiframe/spaces/pngwn/static-test/_app/assets/fira-mono-all-400-normal-0d19eb5d.woff) format("woff");unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+2000-206F,U+2074,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}:root{font-family:Arial,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Open Sans,Helvetica Neue,sans-serif;--font-mono: "Fira Mono", monospace;--pure-white: #ffffff;--primary-color: #b9c6d2;--secondary-color: #d0dde9;--tertiary-color: #edf0f8;--accent-color: #ff3e00;--heading-color: rgba(0, 0, 0, .7);--text-color: #444444;--background-without-opacity: rgba(255, 255, 255, .7);--column-width: 42rem;--column-margin-top: 4rem}body{min-height:100vh;margin:0;background-color:var(--primary-color);background:linear-gradient(180deg,var(--primary-color) 0%,var(--secondary-color) 10.45%,var(--tertiary-color) 41.35%)}body:before{content:"";width:80vw;height:100vh;position:absolute;top:0;left:10vw;z-index:-1;background:radial-gradient(50% 50% at 50% 50%,var(--pure-white) 0%,rgba(255,255,255,0) 100%);opacity:.05}#svelte{min-height:100vh;display:flex;flex-direction:column}h1,h2,p{font-weight:400;color:var(--heading-color)}p{line-height:1.5}a{color:var(--accent-color);text-decoration:none}a:hover{text-decoration:underline}h1{font-size:2rem;text-align:center}h2{font-size:1rem}pre{font-size:16px;font-family:var(--font-mono);background-color:#ffffff73;border-radius:3px;box-shadow:2px 2px 6px #ffffff40;padding:.5em;overflow-x:auto;color:var(--text-color)}input,button{font-size:inherit;font-family:inherit}button:focus:not(:focus-visible){outline:none}@media (min-width: 720px){h1{font-size:2.4rem}}main.svelte-1izrdc8.svelte-1izrdc8{flex:1;display:flex;flex-direction:column;padding:1rem;width:100%;max-width:1024px;margin:0 auto;box-sizing:border-box}footer.svelte-1izrdc8.svelte-1izrdc8{display:flex;flex-direction:column;justify-content:center;align-items:center;padding:40px}footer.svelte-1izrdc8 a.svelte-1izrdc8{font-weight:700}@media (min-width: 480px){footer.svelte-1izrdc8.svelte-1izrdc8{padding:40px 0}}
|
{_app → .svelte-kit/output/client/_app}/assets/pages/about.svelte-bf4528fa.css
RENAMED
|
File without changes
|
{_app → .svelte-kit/output/client/_app}/assets/pages/index.svelte-c63fe1c6.css
RENAMED
|
File without changes
|
{_app → .svelte-kit/output/client/_app}/assets/pages/todos/index.svelte-784042c1.css
RENAMED
|
File without changes
|
{_app → .svelte-kit/output/client/_app}/assets/start-61d1577b.css
RENAMED
|
File without changes
|
{_app → .svelte-kit/output/client/_app}/assets/svelte-logo-87df40b8.svg
RENAMED
|
File without changes
|
{_app → .svelte-kit/output/client/_app}/chunks/vendor-d68c61c2.js
RENAMED
|
File without changes
|
{_app → .svelte-kit/output/client/_app}/error.svelte-97b7e85d.js
RENAMED
|
File without changes
|
{_app → .svelte-kit/output/client/_app}/manifest.json
RENAMED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
{
|
| 2 |
".svelte-kit/build/runtime/internal/start.js": {
|
| 3 |
-
"file": "start-
|
| 4 |
"src": ".svelte-kit/build/runtime/internal/start.js",
|
| 5 |
"isEntry": true,
|
| 6 |
"imports": [
|
|
@@ -26,7 +26,7 @@
|
|
| 26 |
"_vendor-d68c61c2.js"
|
| 27 |
],
|
| 28 |
"css": [
|
| 29 |
-
"assets/pages/__layout.svelte-
|
| 30 |
],
|
| 31 |
"assets": [
|
| 32 |
"assets/svelte-logo-87df40b8.svg",
|
|
|
|
| 1 |
{
|
| 2 |
".svelte-kit/build/runtime/internal/start.js": {
|
| 3 |
+
"file": "start-2ccc875c.js",
|
| 4 |
"src": ".svelte-kit/build/runtime/internal/start.js",
|
| 5 |
"isEntry": true,
|
| 6 |
"imports": [
|
|
|
|
| 26 |
"_vendor-d68c61c2.js"
|
| 27 |
],
|
| 28 |
"css": [
|
| 29 |
+
"assets/pages/__layout.svelte-343606d7.css"
|
| 30 |
],
|
| 31 |
"assets": [
|
| 32 |
"assets/svelte-logo-87df40b8.svg",
|
.svelte-kit/output/client/_app/pages/__layout.svelte-2dd96704.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
import{E as ne,S as se,i as ae,s as le,e as u,j as y,F as V,t as z,c as f,a as c,d as l,l as H,G as j,g as D,H as ve,b as e,I as N,f as T,J as s,K as re,L as ue,M as fe,v as _e,w as de,x as he,N as pe,O as me,P as ge,p as oe,n as ie,A as be}from"../chunks/vendor-d68c61c2.js";const we=()=>{const o=ne("__svelte__");return{page:{subscribe:o.page.subscribe},navigating:{subscribe:o.navigating.subscribe},get preloading(){return console.error("stores.preloading is deprecated; use stores.navigating instead"),{subscribe:o.navigating.subscribe}},session:o.session}},Ee={subscribe(o){return we().page.subscribe(o)}};var $e="/staticspaceiframe/spaces/pngwn/static-test/_app/assets/svelte-logo-87df40b8.svg";function qe(o){let a,d,i,n,m,E,p,_,q,S,v,b,r,t,h,$,g,M,x,A,L,F,G,I,B,P,O;return{c(){a=u("header"),d=u("div"),i=u("a"),n=u("img"),E=y(),p=u("nav"),_=V("svg"),q=V("path"),S=y(),v=u("ul"),b=u("li"),r=u("a"),t=z("Home"),h=y(),$=u("li"),g=u("a"),M=z("About"),x=y(),A=u("li"),L=u("a"),F=z("Todos"),G=y(),I=V("svg"),B=V("path"),P=y(),O=u("div"),this.h()},l(k){a=f(k,"HEADER",{class:!0});var w=c(a);d=f(w,"DIV",{class:!0});var R=c(d);i=f(R,"A",{href:!0,class:!0});var Z=c(i);n=f(Z,"IMG",{src:!0,alt:!0,class:!0}),Z.forEach(l),R.forEach(l),E=H(w),p=f(w,"NAV",{class:!0});var C=c(p);_=j(C,"svg",{viewBox:!0,"aria-hidden":!0,class:!0});var J=c(_);q=j(J,"path",{d:!0,class:!0}),c(q).forEach(l),J.forEach(l),S=H(C),v=f(C,"UL",{class:!0});var K=c(v);b=f(K,"LI",{class:!0});var U=c(b);r=f(U,"A",{"sveltekit:prefetch":!0,href:!0,class:!0});var Q=c(r);t=D(Q,"Home"),Q.forEach(l),U.forEach(l),h=H(K),$=f(K,"LI",{class:!0});var W=c($);g=f(W,"A",{"sveltekit:prefetch":!0,href:!0,class:!0});var X=c(g);M=D(X,"About"),X.forEach(l),W.forEach(l),x=H(K),A=f(K,"LI",{class:!0});var Y=c(A);L=f(Y,"A",{"sveltekit:prefetch":!0,href:!0,class:!0});var ee=c(L);F=D(ee,"Todos"),ee.forEach(l),Y.forEach(l),K.forEach(l),G=H(C),I=j(C,"svg",{viewBox:!0,"aria-hidden":!0,class:!0});var te=c(I);B=j(te,"path",{d:!0,class:!0}),c(B).forEach(l),te.forEach(l),C.forEach(l),P=H(w),O=f(w,"DIV",{class:!0});var ce=c(O);ce.forEach(l),w.forEach(l),this.h()},h(){ve(n.src,m=$e)||e(n,"src",m),e(n,"alt","SvelteKit"),e(n,"class","svelte-t2wq17"),e(i,"href","https://kit.svelte.dev"),e(i,"class","svelte-t2wq17"),e(d,"class","corner svelte-t2wq17"),e(q,"d","M0,0 L1,2 C1.5,3 1.5,3 2,3 L2,0 Z"),e(q,"class","svelte-t2wq17"),e(_,"viewBox","0 0 2 3"),e(_,"aria-hidden","true"),e(_,"class","svelte-t2wq17"),e(r,"sveltekit:prefetch",""),e(r,"href","/"),e(r,"class","svelte-t2wq17"),e(b,"class","svelte-t2wq17"),N(b,"active",o[0].url.pathname==="/"),e(g,"sveltekit:prefetch",""),e(g,"href","/about"),e(g,"class","svelte-t2wq17"),e($,"class","svelte-t2wq17"),N($,"active",o[0].url.pathname==="/about"),e(L,"sveltekit:prefetch",""),e(L,"href","/todos"),e(L,"class","svelte-t2wq17"),e(A,"class","svelte-t2wq17"),N(A,"active",o[0].url.pathname==="/todos"),e(v,"class","svelte-t2wq17"),e(B,"d","M0,0 L0,3 C0.5,3 0.5,3 1,2 L2,0 Z"),e(B,"class","svelte-t2wq17"),e(I,"viewBox","0 0 2 3"),e(I,"aria-hidden","true"),e(I,"class","svelte-t2wq17"),e(p,"class","svelte-t2wq17"),e(O,"class","corner svelte-t2wq17"),e(a,"class","svelte-t2wq17")},m(k,w){T(k,a,w),s(a,d),s(d,i),s(i,n),s(a,E),s(a,p),s(p,_),s(_,q),s(p,S),s(p,v),s(v,b),s(b,r),s(r,t),s(v,h),s(v,$),s($,g),s(g,M),s(v,x),s(v,A),s(A,L),s(L,F),s(p,G),s(p,I),s(I,B),s(a,P),s(a,O)},p(k,[w]){w&1&&N(b,"active",k[0].url.pathname==="/"),w&1&&N($,"active",k[0].url.pathname==="/about"),w&1&&N(A,"active",k[0].url.pathname==="/todos")},i:re,o:re,d(k){k&&l(a)}}}function ke(o,a,d){let i;return ue(o,Ee,n=>d(0,i=n)),[i]}class Ae extends se{constructor(a){super();ae(this,a,ke,qe,le,{})}}function Le(o){let a,d,i,n,m,E,p,_,q,S,v;a=new Ae({});const b=o[1].default,r=fe(b,o,o[0],null);return{c(){_e(a.$$.fragment),d=y(),i=u("main"),r&&r.c(),n=y(),m=u("footer"),E=u("p"),p=z("visit "),_=u("a"),q=z("kit.svelte.dev"),S=z(" to learn SvelteKit"),this.h()},l(t){de(a.$$.fragment,t),d=H(t),i=f(t,"MAIN",{class:!0});var h=c(i);r&&r.l(h),h.forEach(l),n=H(t),m=f(t,"FOOTER",{class:!0});var $=c(m);E=f($,"P",{});var g=c(E);p=D(g,"visit "),_=f(g,"A",{href:!0,class:!0});var M=c(_);q=D(M,"kit.svelte.dev"),M.forEach(l),S=D(g," to learn SvelteKit"),g.forEach(l),$.forEach(l),this.h()},h(){e(i,"class","svelte-1izrdc8"),e(_,"href","https://kit.svelte.dev"),e(_,"class","svelte-1izrdc8"),e(m,"class","svelte-1izrdc8")},m(t,h){he(a,t,h),T(t,d,h),T(t,i,h),r&&r.m(i,null),T(t,n,h),T(t,m,h),s(m,E),s(E,p),s(E,_),s(_,q),s(E,S),v=!0},p(t,[h]){r&&r.p&&(!v||h&1)&&pe(r,b,t,t[0],v?ge(b,t[0],h,null):me(t[0]),null)},i(t){v||(oe(a.$$.fragment,t),oe(r,t),v=!0)},o(t){ie(a.$$.fragment,t),ie(r,t),v=!1},d(t){be(a,t),t&&l(d),t&&l(i),r&&r.d(t),t&&l(n),t&&l(m)}}}function Ie(o,a,d){let{$$slots:i={},$$scope:n}=a;return o.$$set=m=>{"$$scope"in m&&d(0,n=m.$$scope)},[n,i]}class He extends se{constructor(a){super();ae(this,a,Ie,Le,le,{})}}export{He as default};
|
{_app → .svelte-kit/output/client/_app}/pages/about.svelte-a7982a52.js
RENAMED
|
File without changes
|
{_app → .svelte-kit/output/client/_app}/pages/index.svelte-934bb81d.js
RENAMED
|
File without changes
|
{_app → .svelte-kit/output/client/_app}/pages/todos/index.svelte-82693d56.js
RENAMED
|
File without changes
|
.svelte-kit/output/client/_app/start-2ccc875c.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
var ne=Object.defineProperty,ie=Object.defineProperties;var ae=Object.getOwnPropertyDescriptors;var B=Object.getOwnPropertySymbols;var J=Object.prototype.hasOwnProperty,G=Object.prototype.propertyIsEnumerable;var M=(n,e,t)=>e in n?ne(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,A=(n,e)=>{for(var t in e||(e={}))J.call(e,t)&&M(n,t,e[t]);if(B)for(var t of B(e))G.call(e,t)&&M(n,t,e[t]);return n},Y=(n,e)=>ie(n,ae(e));var X=(n,e)=>{var t={};for(var r in n)J.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&B)for(var r of B(n))e.indexOf(r)<0&&G.call(n,r)&&(t[r]=n[r]);return t};import{S as oe,i as le,s as ce,e as fe,c as ue,a as he,d as y,b as K,f as k,t as de,g as _e,h as pe,j as me,k as m,l as ge,m as T,n as g,o as j,p as w,q as we,r as be,u as ve,v as E,w as O,x as R,y as C,z as I,A as L,B as V,C as W,D as F}from"./chunks/vendor-d68c61c2.js";function ye(n){let e,t,r;const l=[n[1]||{}];var i=n[0][0];function a(s){let o={};for(let c=0;c<l.length;c+=1)o=V(o,l[c]);return{props:o}}return i&&(e=new i(a())),{c(){e&&E(e.$$.fragment),t=m()},l(s){e&&O(e.$$.fragment,s),t=m()},m(s,o){e&&R(e,s,o),k(s,t,o),r=!0},p(s,o){const c=o&2?C(l,[I(s[1]||{})]):{};if(i!==(i=s[0][0])){if(e){T();const f=e;g(f.$$.fragment,1,0,()=>{L(f,1)}),j()}i?(e=new i(a()),E(e.$$.fragment),w(e.$$.fragment,1),R(e,t.parentNode,t)):e=null}else i&&e.$set(c)},i(s){r||(e&&w(e.$$.fragment,s),r=!0)},o(s){e&&g(e.$$.fragment,s),r=!1},d(s){s&&y(t),e&&L(e,s)}}}function $e(n){let e,t,r;const l=[n[1]||{}];var i=n[0][0];function a(s){let o={$$slots:{default:[Le]},$$scope:{ctx:s}};for(let c=0;c<l.length;c+=1)o=V(o,l[c]);return{props:o}}return i&&(e=new i(a(n))),{c(){e&&E(e.$$.fragment),t=m()},l(s){e&&O(e.$$.fragment,s),t=m()},m(s,o){e&&R(e,s,o),k(s,t,o),r=!0},p(s,o){const c=o&2?C(l,[I(s[1]||{})]):{};if(o&525&&(c.$$scope={dirty:o,ctx:s}),i!==(i=s[0][0])){if(e){T();const f=e;g(f.$$.fragment,1,0,()=>{L(f,1)}),j()}i?(e=new i(a(s)),E(e.$$.fragment),w(e.$$.fragment,1),R(e,t.parentNode,t)):e=null}else i&&e.$set(c)},i(s){r||(e&&w(e.$$.fragment,s),r=!0)},o(s){e&&g(e.$$.fragment,s),r=!1},d(s){s&&y(t),e&&L(e,s)}}}function ke(n){let e,t,r;const l=[n[2]||{}];var i=n[0][1];function a(s){let o={};for(let c=0;c<l.length;c+=1)o=V(o,l[c]);return{props:o}}return i&&(e=new i(a())),{c(){e&&E(e.$$.fragment),t=m()},l(s){e&&O(e.$$.fragment,s),t=m()},m(s,o){e&&R(e,s,o),k(s,t,o),r=!0},p(s,o){const c=o&4?C(l,[I(s[2]||{})]):{};if(i!==(i=s[0][1])){if(e){T();const f=e;g(f.$$.fragment,1,0,()=>{L(f,1)}),j()}i?(e=new i(a()),E(e.$$.fragment),w(e.$$.fragment,1),R(e,t.parentNode,t)):e=null}else i&&e.$set(c)},i(s){r||(e&&w(e.$$.fragment,s),r=!0)},o(s){e&&g(e.$$.fragment,s),r=!1},d(s){s&&y(t),e&&L(e,s)}}}function Ee(n){let e,t,r;const l=[n[2]||{}];var i=n[0][1];function a(s){let o={$$slots:{default:[Re]},$$scope:{ctx:s}};for(let c=0;c<l.length;c+=1)o=V(o,l[c]);return{props:o}}return i&&(e=new i(a(n))),{c(){e&&E(e.$$.fragment),t=m()},l(s){e&&O(e.$$.fragment,s),t=m()},m(s,o){e&&R(e,s,o),k(s,t,o),r=!0},p(s,o){const c=o&4?C(l,[I(s[2]||{})]):{};if(o&521&&(c.$$scope={dirty:o,ctx:s}),i!==(i=s[0][1])){if(e){T();const f=e;g(f.$$.fragment,1,0,()=>{L(f,1)}),j()}i?(e=new i(a(s)),E(e.$$.fragment),w(e.$$.fragment,1),R(e,t.parentNode,t)):e=null}else i&&e.$set(c)},i(s){r||(e&&w(e.$$.fragment,s),r=!0)},o(s){e&&g(e.$$.fragment,s),r=!1},d(s){s&&y(t),e&&L(e,s)}}}function Re(n){let e,t,r;const l=[n[3]||{}];var i=n[0][2];function a(s){let o={};for(let c=0;c<l.length;c+=1)o=V(o,l[c]);return{props:o}}return i&&(e=new i(a())),{c(){e&&E(e.$$.fragment),t=m()},l(s){e&&O(e.$$.fragment,s),t=m()},m(s,o){e&&R(e,s,o),k(s,t,o),r=!0},p(s,o){const c=o&8?C(l,[I(s[3]||{})]):{};if(i!==(i=s[0][2])){if(e){T();const f=e;g(f.$$.fragment,1,0,()=>{L(f,1)}),j()}i?(e=new i(a()),E(e.$$.fragment),w(e.$$.fragment,1),R(e,t.parentNode,t)):e=null}else i&&e.$set(c)},i(s){r||(e&&w(e.$$.fragment,s),r=!0)},o(s){e&&g(e.$$.fragment,s),r=!1},d(s){s&&y(t),e&&L(e,s)}}}function Le(n){let e,t,r,l;const i=[Ee,ke],a=[];function s(o,c){return o[0][2]?0:1}return e=s(n),t=a[e]=i[e](n),{c(){t.c(),r=m()},l(o){t.l(o),r=m()},m(o,c){a[e].m(o,c),k(o,r,c),l=!0},p(o,c){let f=e;e=s(o),e===f?a[e].p(o,c):(T(),g(a[f],1,1,()=>{a[f]=null}),j(),t=a[e],t?t.p(o,c):(t=a[e]=i[e](o),t.c()),w(t,1),t.m(r.parentNode,r))},i(o){l||(w(t),l=!0)},o(o){g(t),l=!1},d(o){a[e].d(o),o&&y(r)}}}function H(n){let e,t=n[5]&&Q(n);return{c(){e=fe("div"),t&&t.c(),this.h()},l(r){e=ue(r,"DIV",{id:!0,"aria-live":!0,"aria-atomic":!0,class:!0});var l=he(e);t&&t.l(l),l.forEach(y),this.h()},h(){K(e,"id","svelte-announcer"),K(e,"aria-live","assertive"),K(e,"aria-atomic","true"),K(e,"class","svelte-1j55zn5")},m(r,l){k(r,e,l),t&&t.m(e,null)},p(r,l){r[5]?t?t.p(r,l):(t=Q(r),t.c(),t.m(e,null)):t&&(t.d(1),t=null)},d(r){r&&y(e),t&&t.d()}}}function Q(n){let e;return{c(){e=de(n[6])},l(t){e=_e(t,n[6])},m(t,r){k(t,e,r)},p(t,r){r&64&&pe(e,t[6])},d(t){t&&y(e)}}}function Se(n){let e,t,r,l,i;const a=[$e,ye],s=[];function o(f,h){return f[0][1]?0:1}e=o(n),t=s[e]=a[e](n);let c=n[4]&&H(n);return{c(){t.c(),r=me(),c&&c.c(),l=m()},l(f){t.l(f),r=ge(f),c&&c.l(f),l=m()},m(f,h){s[e].m(f,h),k(f,r,h),c&&c.m(f,h),k(f,l,h),i=!0},p(f,[h]){let u=e;e=o(f),e===u?s[e].p(f,h):(T(),g(s[u],1,1,()=>{s[u]=null}),j(),t=s[e],t?t.p(f,h):(t=s[e]=a[e](f),t.c()),w(t,1),t.m(r.parentNode,r)),f[4]?c?c.p(f,h):(c=H(f),c.c(),c.m(l.parentNode,l)):c&&(c.d(1),c=null)},i(f){i||(w(t),i=!0)},o(f){g(t),i=!1},d(f){s[e].d(f),f&&y(r),c&&c.d(f),f&&y(l)}}}function Ue(n,e,t){let{stores:r}=e,{page:l}=e,{components:i}=e,{props_0:a=null}=e,{props_1:s=null}=e,{props_2:o=null}=e;we("__svelte__",r),be(r.page.notify);let c=!1,f=!1,h=null;return ve(()=>{const u=r.page.subscribe(()=>{c&&(t(5,f=!0),t(6,h=document.title||"untitled page"))});return t(4,c=!0),u}),n.$$set=u=>{"stores"in u&&t(7,r=u.stores),"page"in u&&t(8,l=u.page),"components"in u&&t(0,i=u.components),"props_0"in u&&t(1,a=u.props_0),"props_1"in u&&t(2,s=u.props_1),"props_2"in u&&t(3,o=u.props_2)},n.$$.update=()=>{n.$$.dirty&384&&r.page.set(l)},[i,a,s,o,c,f,h,r,l]}class Ae extends oe{constructor(e){super();le(this,e,Ue,Se,ce,{stores:7,page:8,components:0,props_0:1,props_1:2,props_2:3})}}const Pe="modulepreload",Z={},Te="/staticspaceiframe/spaces/pngwn/static-test/_app/",D=function(e,t){return!t||t.length===0?e():Promise.all(t.map(r=>{if(r=`${Te}${r}`,r in Z)return;Z[r]=!0;const l=r.endsWith(".css"),i=l?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${r}"]${i}`))return;const a=document.createElement("link");if(a.rel=l?"stylesheet":Pe,l||(a.as="script",a.crossOrigin=""),a.href=r,document.head.appendChild(a),l)return new Promise((s,o)=>{a.addEventListener("load",s),a.addEventListener("error",o)})})).then(()=>e())},$=[()=>D(()=>import("./pages/__layout.svelte-2dd96704.js"),["pages/__layout.svelte-2dd96704.js","assets/pages/__layout.svelte-343606d7.css","chunks/vendor-d68c61c2.js"]),()=>D(()=>import("./error.svelte-97b7e85d.js"),["error.svelte-97b7e85d.js","chunks/vendor-d68c61c2.js"]),()=>D(()=>import("./pages/index.svelte-934bb81d.js"),["pages/index.svelte-934bb81d.js","assets/pages/index.svelte-c63fe1c6.css","chunks/vendor-d68c61c2.js"]),()=>D(()=>import("./pages/about.svelte-a7982a52.js"),["pages/about.svelte-a7982a52.js","assets/pages/about.svelte-bf4528fa.css","chunks/vendor-d68c61c2.js"]),()=>D(()=>import("./pages/todos/index.svelte-82693d56.js"),["pages/todos/index.svelte-82693d56.js","assets/pages/todos/index.svelte-784042c1.css","chunks/vendor-d68c61c2.js"])],je=[[/^\/$/,[$[0],$[2]],[$[1]]],[/^\/about\/?$/,[$[0],$[3]],[$[1]]],,[/^\/todos\/?$/,[$[0],$[4]],[$[1]]]],Ne=[$[0](),$[1]()];function Oe(n){let e=n.baseURI;if(!e){const t=n.getElementsByTagName("base");e=t.length?t[0].href:n.URL}return e}let x="";function Ce(n){x=n.base,n.assets}function z(){return{x:pageXOffset,y:pageYOffset}}function ee(n){return n.composedPath().find(t=>t instanceof Node&&t.nodeName.toUpperCase()==="A")}function te(n){return n instanceof SVGAElement?new URL(n.href.baseVal,document.baseURI):new URL(n.href)}class Ie{constructor({base:e,routes:t,trailing_slash:r,renderer:l}){this.base=e,this.routes=t,this.trailing_slash=r,this.navigating=0,this.renderer=l,l.router=this,this.enabled=!0,document.body.setAttribute("tabindex","-1"),history.replaceState(history.state||{},"",location.href)}init_listeners(){"scrollRestoration"in history&&(history.scrollRestoration="manual"),addEventListener("beforeunload",()=>{history.scrollRestoration="auto"}),addEventListener("load",()=>{history.scrollRestoration="manual"});let e;addEventListener("scroll",()=>{clearTimeout(e),e=setTimeout(()=>{const i=Y(A({},history.state||{}),{"sveltekit:scroll":z()});history.replaceState(i,document.title,window.location.href)},200)});const t=i=>{const a=ee(i);a&&a.href&&a.hasAttribute("sveltekit:prefetch")&&this.prefetch(te(a))};let r;const l=i=>{clearTimeout(r),r=setTimeout(()=>{var a;(a=i.target)==null||a.dispatchEvent(new CustomEvent("sveltekit:trigger_prefetch",{bubbles:!0}))},20)};addEventListener("touchstart",t),addEventListener("mousemove",l),addEventListener("sveltekit:trigger_prefetch",t),addEventListener("click",i=>{if(!this.enabled||i.button||i.which!==1||i.metaKey||i.ctrlKey||i.shiftKey||i.altKey||i.defaultPrevented)return;const a=ee(i);if(!a||!a.href)return;const s=te(a);if(s.toString()===location.href){location.hash||i.preventDefault();return}const c=(a.getAttribute("rel")||"").split(/\s+/);if(a.hasAttribute("download")||c&&c.includes("external")||(a instanceof SVGAElement?a.target.baseVal:a.target)||!this.owns(s))return;if(s.href.split("#")[0]===location.href.split("#")[0]){setTimeout(()=>history.pushState({},"",s.href));return}history.pushState({},"",s.href);const f=a.hasAttribute("sveltekit:noscroll");this._navigate(s,f?z():null,!1,[],s.hash),i.preventDefault()}),addEventListener("popstate",i=>{if(i.state&&this.enabled){const a=new URL(location.href);this._navigate(a,i.state["sveltekit:scroll"],!1,[])}})}owns(e){return e.origin===location.origin&&e.pathname.startsWith(this.base)}parse(e){if(this.owns(e)){const t=decodeURI(e.pathname.slice(this.base.length)||"/");return{id:e.pathname+e.search,routes:this.routes.filter(([r])=>r.test(t)),url:e,path:t}}}async goto(e,{noscroll:t=!1,replaceState:r=!1,keepfocus:l=!1,state:i={}}={},a){const s=new URL(e,Oe(document));return this.enabled&&this.owns(s)?(history[r?"replaceState":"pushState"](i,"",e),this._navigate(s,t?z():null,l,a,s.hash)):(location.href=s.href,new Promise(()=>{}))}enable(){this.enabled=!0}disable(){this.enabled=!1}async prefetch(e){const t=this.parse(e);if(!t)throw new Error("Attempted to prefetch a URL that does not belong to this app");return this.renderer.load(t)}async _navigate(e,t,r,l,i){const a=this.parse(e);if(!a)throw new Error("Attempted to navigate to a URL that does not belong to this app");this.navigating||dispatchEvent(new CustomEvent("sveltekit:navigation-start")),this.navigating++;let{pathname:s}=e;this.trailing_slash==="never"?s!=="/"&&s.endsWith("/")&&(s=s.slice(0,-1)):this.trailing_slash==="always"&&!e.pathname.split("/").pop().includes(".")&&!s.endsWith("/")&&(s+="/"),a.url=new URL(e.origin+s+e.search+e.hash),history.replaceState({},"",a.url),await this.renderer.handle_navigation(a,l,!1,{hash:i,scroll:t,keepfocus:r}),this.navigating--,this.navigating||dispatchEvent(new CustomEvent("sveltekit:navigation-end"))}}function se(n){return n instanceof Error||n&&n.name&&n.message?n:new Error(JSON.stringify(n))}function Ve(n){let e=5381,t=n.length;if(typeof n=="string")for(;t;)e=e*33^n.charCodeAt(--t);else for(;t;)e=e*33^n[--t];return(e>>>0).toString(36)}function De(n){const e=n.status&&n.status>=400&&n.status<=599&&!n.redirect;if(n.error||e){const t=n.status;if(!n.error&&e)return{status:t||500,error:new Error};const r=typeof n.error=="string"?new Error(n.error):n.error;return r instanceof Error?!t||t<400||t>599?(console.warn('"error" returned from load() without a valid status code \u2014 defaulting to 500'),{status:500,error:r}):{status:t,error:r}:{status:500,error:new Error(`"error" property returned from load() must be a string or instance of Error, received type "${typeof r}"`)}}if(n.redirect){if(!n.status||Math.floor(n.status/100)!==3)return{status:500,error:new Error('"redirect" property returned from load() must be accompanied by a 3xx status code')};if(typeof n.redirect!="string")return{status:500,error:new Error('"redirect" property returned from load() must be a string')}}if(n.context)throw new Error('You are returning "context" from a load function. "context" was renamed to "stuff", please adjust your code accordingly.');return n}function re(n){const e=W(n);let t=!0;function r(){t=!0,e.update(a=>a)}function l(a){t=!1,e.set(a)}function i(a){let s;return e.subscribe(o=>{(s===void 0||t&&o!==s)&&a(s=o)})}return{notify:r,set:l,subscribe:i}}function qe(n,e){const t=typeof n=="string"?n:n.url;let r=`script[data-type="svelte-data"][data-url=${JSON.stringify(t)}]`;e&&typeof e.body=="string"&&(r+=`[data-body="${Ve(e.body)}"]`);const l=document.querySelector(r);if(l&&l.textContent){const i=JSON.parse(l.textContent),{body:a}=i,s=X(i,["body"]);return Promise.resolve(new Response(a,s))}return fetch(n,e)}class Be{constructor({Root:e,fallback:t,target:r,session:l}){this.Root=e,this.fallback=t,this.router,this.target=r,this.started=!1,this.session_id=1,this.invalid=new Set,this.invalidating=null,this.autoscroll=!0,this.updating=!1,this.current={url:null,session_id:0,branch:[]},this.cache=new Map,this.loading={id:null,promise:null},this.stores={url:re({}),page:re({}),navigating:W(null),session:W(l)},this.$session=null,this.root=null;let i=!1;this.stores.session.subscribe(async a=>{if(this.$session=a,!i||!this.router)return;this.session_id+=1;const s=this.router.parse(new URL(location.href));s&&this.update(s,[],!0)}),i=!0}disable_scroll_handling(){(this.updating||!this.started)&&(this.autoscroll=!1)}async start({status:e,error:t,nodes:r,url:l,params:i}){const a=[];let s={},o,c;try{for(let f=0;f<r.length;f+=1){const h=f===r.length-1,u=await this._load_node({module:await r[f],url:l,params:i,stuff:s,status:h?e:void 0,error:h?t:void 0});if(a.push(u),u&&u.loaded)if(u.loaded.error){if(t)throw u.loaded.error;c={status:u.loaded.status,error:u.loaded.error,url:l}}else u.loaded.stuff&&(s=A(A({},s),u.loaded.stuff))}o=c?await this._load_error(c):await this._get_navigation_result_from_branch({url:l,params:i,branch:a,status:e,error:t})}catch(f){if(t)throw f;o=await this._load_error({status:500,error:se(f),url:l})}if(o.redirect){location.href=new URL(o.redirect,location.href).href;return}this._init(o)}async handle_navigation(e,t,r,l){this.started&&this.stores.navigating.set({from:this.current.url,to:e.url}),await this.update(e,t,r,l)}async update(e,t,r,l){var o;const i=this.token={};let a=await this._get_navigation_result(e,r);if(i!==this.token)return;if(this.invalid.clear(),a.redirect)if(t.length>10||t.includes(e.url.pathname))a=await this._load_error({status:500,error:new Error("Redirect loop"),url:e.url});else{this.router?this.router.goto(a.redirect,{replaceState:!0},[...t,e.url.pathname]):location.href=new URL(a.redirect,location.href).href;return}if(this.updating=!0,this.started?(this.current=a.state,this.root.$set(a.props),this.stores.navigating.set(null)):this._init(a),l){const{hash:c,scroll:f,keepfocus:h}=l;if(h||((o=getSelection())==null||o.removeAllRanges(),document.body.focus()),await F(),this.autoscroll){const u=c&&document.getElementById(c.slice(1));f?scrollTo(f.x,f.y):u?u.scrollIntoView():scrollTo(0,0)}}else await F();if(this.loading.promise=null,this.loading.id=null,this.autoscroll=!0,this.updating=!1,!this.router)return;const s=a.state.branch[a.state.branch.length-1];s&&s.module.router===!1?this.router.disable():this.router.enable()}load(e){return this.loading.promise=this._get_navigation_result(e,!1),this.loading.id=e.id,this.loading.promise}invalidate(e){return this.invalid.add(e),this.invalidating||(this.invalidating=Promise.resolve().then(async()=>{const t=this.router&&this.router.parse(new URL(location.href));t&&await this.update(t,[],!0),this.invalidating=null})),this.invalidating}_init(e){this.current=e.state;const t=document.querySelector("style[data-svelte]");t&&t.remove(),this.root=new this.Root({target:this.target,props:A({stores:this.stores},e.props),hydrate:!0}),this.started=!0}async _get_navigation_result(e,t){if(this.loading.id===e.id&&this.loading.promise)return this.loading.promise;for(let r=0;r<e.routes.length;r+=1){const l=e.routes[r];let i=r+1;for(;i<e.routes.length;){const s=e.routes[i];if(s[0].toString()===l[0].toString())s[1].forEach(o=>o()),i+=1;else break}const a=await this._load({route:l,info:e},t);if(a)return a}return await this._load_error({status:404,error:new Error(`Not found: ${e.url.pathname}`),url:e.url})}async _get_navigation_result_from_branch({url:e,params:t,branch:r,status:l,error:i}){const a=r.filter(Boolean),s=a.find(h=>h.loaded&&h.loaded.redirect),o={redirect:s&&s.loaded?s.loaded.redirect:void 0,state:{url:e,params:t,branch:r,session_id:this.session_id},props:{components:a.map(h=>h.module.default)}};for(let h=0;h<a.length;h+=1){const u=a[h].loaded;o.props[`props_${h}`]=u?await u.props:null}if(!this.current.url||e.href!==this.current.url.href){o.props.page={url:e,params:t,status:l,error:i};const h=(u,p)=>{Object.defineProperty(o.props.page,u,{get:()=>{throw new Error(`$page.${u} has been replaced by $page.url.${p}`)}})};h("origin","origin"),h("path","pathname"),h("query","searchParams")}const c=a[a.length-1],f=c.loaded&&c.loaded.maxage;if(f){const h=e.pathname+e.search;let u=!1;const p=()=>{this.cache.get(h)===o&&this.cache.delete(h),S(),clearTimeout(P)},P=setTimeout(p,f*1e3),S=this.stores.session.subscribe(()=>{u&&p()});u=!0,this.cache.set(h,o)}return o}async _load_node({status:e,error:t,module:r,url:l,params:i,stuff:a}){const s={module:r,uses:{params:new Set,url:!1,session:!1,stuff:!1,dependencies:[]},loaded:null,stuff:a},o={};for(const f in i)Object.defineProperty(o,f,{get(){return s.uses.params.add(f),i[f]},enumerable:!0});const c=this.$session;if(r.load){const{started:f}=this,h={params:o,get url(){return s.uses.url=!0,l},get session(){return s.uses.session=!0,c},get stuff(){return s.uses.stuff=!0,A({},a)},fetch(p,P){const S=typeof p=="string"?p:p.url,{href:U}=new URL(S,l);return s.uses.dependencies.push(U),f?fetch(p,P):qe(p,P)}};t&&(h.status=e,h.error=t);const u=await r.load.call(null,h);if(!u)return;s.loaded=De(u),s.loaded.stuff&&(s.stuff=s.loaded.stuff)}return s}async _load({route:e,info:{url:t,path:r}},l){const i=t.pathname+t.search;if(!l){const d=this.cache.get(i);if(d)return d}const[a,s,o,c]=e,f=c?c(a.exec(r)):{},h=this.current.url&&{url:i!==this.current.url.pathname+this.current.url.search,params:Object.keys(f).filter(d=>this.current.params[d]!==f[d]),session:this.session_id!==this.current.session_id};let u=[],p={},P=!1,S=200,U;s.forEach(d=>d());e:for(let d=0;d<s.length;d+=1){let _;try{if(!s[d])continue;const b=await s[d](),v=this.current.branch[d];if(!v||b!==v.module||h.url&&v.uses.url||h.params.some(N=>v.uses.params.has(N))||h.session&&v.uses.session||v.uses.dependencies.some(N=>this.invalid.has(N))||P&&v.uses.stuff){_=await this._load_node({module:b,url:t,params:f,stuff:p});const N=d===s.length-1;if(_&&_.loaded){if(_.loaded.error&&(S=_.loaded.status,U=_.loaded.error),_.loaded.redirect)return{redirect:_.loaded.redirect,props:{},state:this.current};_.loaded.stuff&&(P=!0)}else if(N&&b.load)return}else _=v}catch(b){S=500,U=se(b)}if(U){for(;d--;)if(o[d]){let b,v,q=d;for(;!(v=u[q]);)q-=1;try{if(b=await this._load_node({status:S,error:U,module:await o[d](),url:t,params:f,stuff:v.stuff}),b&&b.loaded&&b.loaded.error)continue;u=u.slice(0,q+1).concat(b);break e}catch{continue}}return await this._load_error({status:S,error:U,url:t})}else _&&_.loaded&&_.loaded.stuff&&(p=A(A({},p),_.loaded.stuff)),u.push(_)}return await this._get_navigation_result_from_branch({url:t,params:f,branch:u,status:S,error:U})}async _load_error({status:e,error:t,url:r}){const l={},i=await this._load_node({module:await this.fallback[0],url:r,params:l,stuff:{}}),a=[i,await this._load_node({status:e,error:t,module:await this.fallback[1],url:r,params:l,stuff:i&&i.loaded&&i.loaded.stuff||{}})];return await this._get_navigation_result_from_branch({url:r,params:l,branch:a,status:e,error:t})}}async function ze({paths:n,target:e,session:t,route:r,spa:l,trailing_slash:i,hydrate:a}){const s=new Be({Root:Ae,fallback:Ne,target:e,session:t}),o=r?new Ie({base:n.base,routes:je,trailing_slash:i,renderer:s}):null;Ce(n),a&&await s.start(a),o&&(l&&o.goto(location.href,{replaceState:!0},[]),o.init_listeners()),dispatchEvent(new CustomEvent("sveltekit:start"))}export{ze as start};
|
.svelte-kit/output/server/app.js
ADDED
|
@@ -0,0 +1,1473 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
var __accessCheck = (obj, member, msg) => {
|
| 2 |
+
if (!member.has(obj))
|
| 3 |
+
throw TypeError("Cannot " + msg);
|
| 4 |
+
};
|
| 5 |
+
var __privateGet = (obj, member, getter) => {
|
| 6 |
+
__accessCheck(obj, member, "read from private field");
|
| 7 |
+
return getter ? getter.call(obj) : member.get(obj);
|
| 8 |
+
};
|
| 9 |
+
var __privateAdd = (obj, member, value) => {
|
| 10 |
+
if (member.has(obj))
|
| 11 |
+
throw TypeError("Cannot add the same private member more than once");
|
| 12 |
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
| 13 |
+
};
|
| 14 |
+
var __privateSet = (obj, member, value, setter) => {
|
| 15 |
+
__accessCheck(obj, member, "write to private field");
|
| 16 |
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
| 17 |
+
return value;
|
| 18 |
+
};
|
| 19 |
+
var _map;
|
| 20 |
+
import { c as create_ssr_component, s as setContext, v as validate_component, m as missing_component } from "./chunks/index-c7a03ab5.js";
|
| 21 |
+
import cookie from "cookie";
|
| 22 |
+
import { v4 } from "@lukeed/uuid";
|
| 23 |
+
function get_single_valued_header(headers, key) {
|
| 24 |
+
const value = headers[key];
|
| 25 |
+
if (Array.isArray(value)) {
|
| 26 |
+
if (value.length === 0) {
|
| 27 |
+
return void 0;
|
| 28 |
+
}
|
| 29 |
+
if (value.length > 1) {
|
| 30 |
+
throw new Error(`Multiple headers provided for ${key}. Multiple may be provided only for set-cookie`);
|
| 31 |
+
}
|
| 32 |
+
return value[0];
|
| 33 |
+
}
|
| 34 |
+
return value;
|
| 35 |
+
}
|
| 36 |
+
function lowercase_keys(obj) {
|
| 37 |
+
const clone = {};
|
| 38 |
+
for (const key in obj) {
|
| 39 |
+
clone[key.toLowerCase()] = obj[key];
|
| 40 |
+
}
|
| 41 |
+
return clone;
|
| 42 |
+
}
|
| 43 |
+
function decode_params(params) {
|
| 44 |
+
for (const key in params) {
|
| 45 |
+
params[key] = params[key].replace(/%23/g, "#").replace(/%3[Bb]/g, ";").replace(/%2[Cc]/g, ",").replace(/%2[Ff]/g, "/").replace(/%3[Ff]/g, "?").replace(/%3[Aa]/g, ":").replace(/%40/g, "@").replace(/%26/g, "&").replace(/%3[Dd]/g, "=").replace(/%2[Bb]/g, "+").replace(/%24/g, "$");
|
| 46 |
+
}
|
| 47 |
+
return params;
|
| 48 |
+
}
|
| 49 |
+
function error(body) {
|
| 50 |
+
return {
|
| 51 |
+
status: 500,
|
| 52 |
+
body,
|
| 53 |
+
headers: {}
|
| 54 |
+
};
|
| 55 |
+
}
|
| 56 |
+
function is_string(s2) {
|
| 57 |
+
return typeof s2 === "string" || s2 instanceof String;
|
| 58 |
+
}
|
| 59 |
+
const text_types = new Set([
|
| 60 |
+
"application/xml",
|
| 61 |
+
"application/json",
|
| 62 |
+
"application/x-www-form-urlencoded",
|
| 63 |
+
"multipart/form-data"
|
| 64 |
+
]);
|
| 65 |
+
function is_text(content_type) {
|
| 66 |
+
if (!content_type)
|
| 67 |
+
return true;
|
| 68 |
+
const type = content_type.split(";")[0].toLowerCase();
|
| 69 |
+
return type.startsWith("text/") || type.endsWith("+xml") || text_types.has(type);
|
| 70 |
+
}
|
| 71 |
+
async function render_endpoint(request, route, match) {
|
| 72 |
+
const mod = await route.load();
|
| 73 |
+
const handler = mod[request.method.toLowerCase().replace("delete", "del")];
|
| 74 |
+
if (!handler) {
|
| 75 |
+
return;
|
| 76 |
+
}
|
| 77 |
+
request.params = route.params ? decode_params(route.params(match)) : {};
|
| 78 |
+
const response = await handler(request);
|
| 79 |
+
const preface = `Invalid response from route ${request.url.pathname}`;
|
| 80 |
+
if (!response) {
|
| 81 |
+
return;
|
| 82 |
+
}
|
| 83 |
+
if (typeof response !== "object") {
|
| 84 |
+
return error(`${preface}: expected an object, got ${typeof response}`);
|
| 85 |
+
}
|
| 86 |
+
let { status = 200, body, headers = {} } = response;
|
| 87 |
+
headers = lowercase_keys(headers);
|
| 88 |
+
const type = get_single_valued_header(headers, "content-type");
|
| 89 |
+
if (!is_text(type) && !(body instanceof Uint8Array || is_string(body))) {
|
| 90 |
+
return error(`${preface}: body must be an instance of string or Uint8Array if content-type is not a supported textual content-type`);
|
| 91 |
+
}
|
| 92 |
+
let normalized_body;
|
| 93 |
+
if ((typeof body === "object" || typeof body === "undefined") && !(body instanceof Uint8Array) && (!type || type.startsWith("application/json"))) {
|
| 94 |
+
headers = { ...headers, "content-type": "application/json; charset=utf-8" };
|
| 95 |
+
normalized_body = JSON.stringify(typeof body === "undefined" ? {} : body);
|
| 96 |
+
} else {
|
| 97 |
+
normalized_body = body;
|
| 98 |
+
}
|
| 99 |
+
return { status, body: normalized_body, headers };
|
| 100 |
+
}
|
| 101 |
+
var chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_$";
|
| 102 |
+
var unsafeChars = /[<>\b\f\n\r\t\0\u2028\u2029]/g;
|
| 103 |
+
var reserved = /^(?:do|if|in|for|int|let|new|try|var|byte|case|char|else|enum|goto|long|this|void|with|await|break|catch|class|const|final|float|short|super|throw|while|yield|delete|double|export|import|native|return|switch|throws|typeof|boolean|default|extends|finally|package|private|abstract|continue|debugger|function|volatile|interface|protected|transient|implements|instanceof|synchronized)$/;
|
| 104 |
+
var escaped = {
|
| 105 |
+
"<": "\\u003C",
|
| 106 |
+
">": "\\u003E",
|
| 107 |
+
"/": "\\u002F",
|
| 108 |
+
"\\": "\\\\",
|
| 109 |
+
"\b": "\\b",
|
| 110 |
+
"\f": "\\f",
|
| 111 |
+
"\n": "\\n",
|
| 112 |
+
"\r": "\\r",
|
| 113 |
+
" ": "\\t",
|
| 114 |
+
"\0": "\\0",
|
| 115 |
+
"\u2028": "\\u2028",
|
| 116 |
+
"\u2029": "\\u2029"
|
| 117 |
+
};
|
| 118 |
+
var objectProtoOwnPropertyNames = Object.getOwnPropertyNames(Object.prototype).sort().join("\0");
|
| 119 |
+
function devalue(value) {
|
| 120 |
+
var counts = new Map();
|
| 121 |
+
function walk(thing) {
|
| 122 |
+
if (typeof thing === "function") {
|
| 123 |
+
throw new Error("Cannot stringify a function");
|
| 124 |
+
}
|
| 125 |
+
if (counts.has(thing)) {
|
| 126 |
+
counts.set(thing, counts.get(thing) + 1);
|
| 127 |
+
return;
|
| 128 |
+
}
|
| 129 |
+
counts.set(thing, 1);
|
| 130 |
+
if (!isPrimitive(thing)) {
|
| 131 |
+
var type = getType(thing);
|
| 132 |
+
switch (type) {
|
| 133 |
+
case "Number":
|
| 134 |
+
case "String":
|
| 135 |
+
case "Boolean":
|
| 136 |
+
case "Date":
|
| 137 |
+
case "RegExp":
|
| 138 |
+
return;
|
| 139 |
+
case "Array":
|
| 140 |
+
thing.forEach(walk);
|
| 141 |
+
break;
|
| 142 |
+
case "Set":
|
| 143 |
+
case "Map":
|
| 144 |
+
Array.from(thing).forEach(walk);
|
| 145 |
+
break;
|
| 146 |
+
default:
|
| 147 |
+
var proto = Object.getPrototypeOf(thing);
|
| 148 |
+
if (proto !== Object.prototype && proto !== null && Object.getOwnPropertyNames(proto).sort().join("\0") !== objectProtoOwnPropertyNames) {
|
| 149 |
+
throw new Error("Cannot stringify arbitrary non-POJOs");
|
| 150 |
+
}
|
| 151 |
+
if (Object.getOwnPropertySymbols(thing).length > 0) {
|
| 152 |
+
throw new Error("Cannot stringify POJOs with symbolic keys");
|
| 153 |
+
}
|
| 154 |
+
Object.keys(thing).forEach(function(key) {
|
| 155 |
+
return walk(thing[key]);
|
| 156 |
+
});
|
| 157 |
+
}
|
| 158 |
+
}
|
| 159 |
+
}
|
| 160 |
+
walk(value);
|
| 161 |
+
var names = new Map();
|
| 162 |
+
Array.from(counts).filter(function(entry) {
|
| 163 |
+
return entry[1] > 1;
|
| 164 |
+
}).sort(function(a, b) {
|
| 165 |
+
return b[1] - a[1];
|
| 166 |
+
}).forEach(function(entry, i) {
|
| 167 |
+
names.set(entry[0], getName(i));
|
| 168 |
+
});
|
| 169 |
+
function stringify(thing) {
|
| 170 |
+
if (names.has(thing)) {
|
| 171 |
+
return names.get(thing);
|
| 172 |
+
}
|
| 173 |
+
if (isPrimitive(thing)) {
|
| 174 |
+
return stringifyPrimitive(thing);
|
| 175 |
+
}
|
| 176 |
+
var type = getType(thing);
|
| 177 |
+
switch (type) {
|
| 178 |
+
case "Number":
|
| 179 |
+
case "String":
|
| 180 |
+
case "Boolean":
|
| 181 |
+
return "Object(" + stringify(thing.valueOf()) + ")";
|
| 182 |
+
case "RegExp":
|
| 183 |
+
return "new RegExp(" + stringifyString(thing.source) + ', "' + thing.flags + '")';
|
| 184 |
+
case "Date":
|
| 185 |
+
return "new Date(" + thing.getTime() + ")";
|
| 186 |
+
case "Array":
|
| 187 |
+
var members = thing.map(function(v, i) {
|
| 188 |
+
return i in thing ? stringify(v) : "";
|
| 189 |
+
});
|
| 190 |
+
var tail = thing.length === 0 || thing.length - 1 in thing ? "" : ",";
|
| 191 |
+
return "[" + members.join(",") + tail + "]";
|
| 192 |
+
case "Set":
|
| 193 |
+
case "Map":
|
| 194 |
+
return "new " + type + "([" + Array.from(thing).map(stringify).join(",") + "])";
|
| 195 |
+
default:
|
| 196 |
+
var obj = "{" + Object.keys(thing).map(function(key) {
|
| 197 |
+
return safeKey(key) + ":" + stringify(thing[key]);
|
| 198 |
+
}).join(",") + "}";
|
| 199 |
+
var proto = Object.getPrototypeOf(thing);
|
| 200 |
+
if (proto === null) {
|
| 201 |
+
return Object.keys(thing).length > 0 ? "Object.assign(Object.create(null)," + obj + ")" : "Object.create(null)";
|
| 202 |
+
}
|
| 203 |
+
return obj;
|
| 204 |
+
}
|
| 205 |
+
}
|
| 206 |
+
var str = stringify(value);
|
| 207 |
+
if (names.size) {
|
| 208 |
+
var params_1 = [];
|
| 209 |
+
var statements_1 = [];
|
| 210 |
+
var values_1 = [];
|
| 211 |
+
names.forEach(function(name, thing) {
|
| 212 |
+
params_1.push(name);
|
| 213 |
+
if (isPrimitive(thing)) {
|
| 214 |
+
values_1.push(stringifyPrimitive(thing));
|
| 215 |
+
return;
|
| 216 |
+
}
|
| 217 |
+
var type = getType(thing);
|
| 218 |
+
switch (type) {
|
| 219 |
+
case "Number":
|
| 220 |
+
case "String":
|
| 221 |
+
case "Boolean":
|
| 222 |
+
values_1.push("Object(" + stringify(thing.valueOf()) + ")");
|
| 223 |
+
break;
|
| 224 |
+
case "RegExp":
|
| 225 |
+
values_1.push(thing.toString());
|
| 226 |
+
break;
|
| 227 |
+
case "Date":
|
| 228 |
+
values_1.push("new Date(" + thing.getTime() + ")");
|
| 229 |
+
break;
|
| 230 |
+
case "Array":
|
| 231 |
+
values_1.push("Array(" + thing.length + ")");
|
| 232 |
+
thing.forEach(function(v, i) {
|
| 233 |
+
statements_1.push(name + "[" + i + "]=" + stringify(v));
|
| 234 |
+
});
|
| 235 |
+
break;
|
| 236 |
+
case "Set":
|
| 237 |
+
values_1.push("new Set");
|
| 238 |
+
statements_1.push(name + "." + Array.from(thing).map(function(v) {
|
| 239 |
+
return "add(" + stringify(v) + ")";
|
| 240 |
+
}).join("."));
|
| 241 |
+
break;
|
| 242 |
+
case "Map":
|
| 243 |
+
values_1.push("new Map");
|
| 244 |
+
statements_1.push(name + "." + Array.from(thing).map(function(_a) {
|
| 245 |
+
var k = _a[0], v = _a[1];
|
| 246 |
+
return "set(" + stringify(k) + ", " + stringify(v) + ")";
|
| 247 |
+
}).join("."));
|
| 248 |
+
break;
|
| 249 |
+
default:
|
| 250 |
+
values_1.push(Object.getPrototypeOf(thing) === null ? "Object.create(null)" : "{}");
|
| 251 |
+
Object.keys(thing).forEach(function(key) {
|
| 252 |
+
statements_1.push("" + name + safeProp(key) + "=" + stringify(thing[key]));
|
| 253 |
+
});
|
| 254 |
+
}
|
| 255 |
+
});
|
| 256 |
+
statements_1.push("return " + str);
|
| 257 |
+
return "(function(" + params_1.join(",") + "){" + statements_1.join(";") + "}(" + values_1.join(",") + "))";
|
| 258 |
+
} else {
|
| 259 |
+
return str;
|
| 260 |
+
}
|
| 261 |
+
}
|
| 262 |
+
function getName(num) {
|
| 263 |
+
var name = "";
|
| 264 |
+
do {
|
| 265 |
+
name = chars[num % chars.length] + name;
|
| 266 |
+
num = ~~(num / chars.length) - 1;
|
| 267 |
+
} while (num >= 0);
|
| 268 |
+
return reserved.test(name) ? name + "_" : name;
|
| 269 |
+
}
|
| 270 |
+
function isPrimitive(thing) {
|
| 271 |
+
return Object(thing) !== thing;
|
| 272 |
+
}
|
| 273 |
+
function stringifyPrimitive(thing) {
|
| 274 |
+
if (typeof thing === "string")
|
| 275 |
+
return stringifyString(thing);
|
| 276 |
+
if (thing === void 0)
|
| 277 |
+
return "void 0";
|
| 278 |
+
if (thing === 0 && 1 / thing < 0)
|
| 279 |
+
return "-0";
|
| 280 |
+
var str = String(thing);
|
| 281 |
+
if (typeof thing === "number")
|
| 282 |
+
return str.replace(/^(-)?0\./, "$1.");
|
| 283 |
+
return str;
|
| 284 |
+
}
|
| 285 |
+
function getType(thing) {
|
| 286 |
+
return Object.prototype.toString.call(thing).slice(8, -1);
|
| 287 |
+
}
|
| 288 |
+
function escapeUnsafeChar(c) {
|
| 289 |
+
return escaped[c] || c;
|
| 290 |
+
}
|
| 291 |
+
function escapeUnsafeChars(str) {
|
| 292 |
+
return str.replace(unsafeChars, escapeUnsafeChar);
|
| 293 |
+
}
|
| 294 |
+
function safeKey(key) {
|
| 295 |
+
return /^[_$a-zA-Z][_$a-zA-Z0-9]*$/.test(key) ? key : escapeUnsafeChars(JSON.stringify(key));
|
| 296 |
+
}
|
| 297 |
+
function safeProp(key) {
|
| 298 |
+
return /^[_$a-zA-Z][_$a-zA-Z0-9]*$/.test(key) ? "." + key : "[" + escapeUnsafeChars(JSON.stringify(key)) + "]";
|
| 299 |
+
}
|
| 300 |
+
function stringifyString(str) {
|
| 301 |
+
var result = '"';
|
| 302 |
+
for (var i = 0; i < str.length; i += 1) {
|
| 303 |
+
var char = str.charAt(i);
|
| 304 |
+
var code = char.charCodeAt(0);
|
| 305 |
+
if (char === '"') {
|
| 306 |
+
result += '\\"';
|
| 307 |
+
} else if (char in escaped) {
|
| 308 |
+
result += escaped[char];
|
| 309 |
+
} else if (code >= 55296 && code <= 57343) {
|
| 310 |
+
var next = str.charCodeAt(i + 1);
|
| 311 |
+
if (code <= 56319 && (next >= 56320 && next <= 57343)) {
|
| 312 |
+
result += char + str[++i];
|
| 313 |
+
} else {
|
| 314 |
+
result += "\\u" + code.toString(16).toUpperCase();
|
| 315 |
+
}
|
| 316 |
+
} else {
|
| 317 |
+
result += char;
|
| 318 |
+
}
|
| 319 |
+
}
|
| 320 |
+
result += '"';
|
| 321 |
+
return result;
|
| 322 |
+
}
|
| 323 |
+
function noop() {
|
| 324 |
+
}
|
| 325 |
+
function safe_not_equal(a, b) {
|
| 326 |
+
return a != a ? b == b : a !== b || (a && typeof a === "object" || typeof a === "function");
|
| 327 |
+
}
|
| 328 |
+
Promise.resolve();
|
| 329 |
+
const subscriber_queue = [];
|
| 330 |
+
function writable(value, start = noop) {
|
| 331 |
+
let stop;
|
| 332 |
+
const subscribers = new Set();
|
| 333 |
+
function set(new_value) {
|
| 334 |
+
if (safe_not_equal(value, new_value)) {
|
| 335 |
+
value = new_value;
|
| 336 |
+
if (stop) {
|
| 337 |
+
const run_queue = !subscriber_queue.length;
|
| 338 |
+
for (const subscriber of subscribers) {
|
| 339 |
+
subscriber[1]();
|
| 340 |
+
subscriber_queue.push(subscriber, value);
|
| 341 |
+
}
|
| 342 |
+
if (run_queue) {
|
| 343 |
+
for (let i = 0; i < subscriber_queue.length; i += 2) {
|
| 344 |
+
subscriber_queue[i][0](subscriber_queue[i + 1]);
|
| 345 |
+
}
|
| 346 |
+
subscriber_queue.length = 0;
|
| 347 |
+
}
|
| 348 |
+
}
|
| 349 |
+
}
|
| 350 |
+
}
|
| 351 |
+
function update(fn) {
|
| 352 |
+
set(fn(value));
|
| 353 |
+
}
|
| 354 |
+
function subscribe(run, invalidate = noop) {
|
| 355 |
+
const subscriber = [run, invalidate];
|
| 356 |
+
subscribers.add(subscriber);
|
| 357 |
+
if (subscribers.size === 1) {
|
| 358 |
+
stop = start(set) || noop;
|
| 359 |
+
}
|
| 360 |
+
run(value);
|
| 361 |
+
return () => {
|
| 362 |
+
subscribers.delete(subscriber);
|
| 363 |
+
if (subscribers.size === 0) {
|
| 364 |
+
stop();
|
| 365 |
+
stop = null;
|
| 366 |
+
}
|
| 367 |
+
};
|
| 368 |
+
}
|
| 369 |
+
return { set, update, subscribe };
|
| 370 |
+
}
|
| 371 |
+
function coalesce_to_error(err) {
|
| 372 |
+
return err instanceof Error || err && err.name && err.message ? err : new Error(JSON.stringify(err));
|
| 373 |
+
}
|
| 374 |
+
function hash(value) {
|
| 375 |
+
let hash2 = 5381;
|
| 376 |
+
let i = value.length;
|
| 377 |
+
if (typeof value === "string") {
|
| 378 |
+
while (i)
|
| 379 |
+
hash2 = hash2 * 33 ^ value.charCodeAt(--i);
|
| 380 |
+
} else {
|
| 381 |
+
while (i)
|
| 382 |
+
hash2 = hash2 * 33 ^ value[--i];
|
| 383 |
+
}
|
| 384 |
+
return (hash2 >>> 0).toString(36);
|
| 385 |
+
}
|
| 386 |
+
const escape_json_string_in_html_dict = {
|
| 387 |
+
'"': '\\"',
|
| 388 |
+
"<": "\\u003C",
|
| 389 |
+
">": "\\u003E",
|
| 390 |
+
"/": "\\u002F",
|
| 391 |
+
"\\": "\\\\",
|
| 392 |
+
"\b": "\\b",
|
| 393 |
+
"\f": "\\f",
|
| 394 |
+
"\n": "\\n",
|
| 395 |
+
"\r": "\\r",
|
| 396 |
+
" ": "\\t",
|
| 397 |
+
"\0": "\\0",
|
| 398 |
+
"\u2028": "\\u2028",
|
| 399 |
+
"\u2029": "\\u2029"
|
| 400 |
+
};
|
| 401 |
+
function escape_json_string_in_html(str) {
|
| 402 |
+
return escape(str, escape_json_string_in_html_dict, (code) => `\\u${code.toString(16).toUpperCase()}`);
|
| 403 |
+
}
|
| 404 |
+
const escape_html_attr_dict = {
|
| 405 |
+
"<": "<",
|
| 406 |
+
">": ">",
|
| 407 |
+
'"': """
|
| 408 |
+
};
|
| 409 |
+
function escape_html_attr(str) {
|
| 410 |
+
return '"' + escape(str, escape_html_attr_dict, (code) => `&#${code};`) + '"';
|
| 411 |
+
}
|
| 412 |
+
function escape(str, dict, unicode_encoder) {
|
| 413 |
+
let result = "";
|
| 414 |
+
for (let i = 0; i < str.length; i += 1) {
|
| 415 |
+
const char = str.charAt(i);
|
| 416 |
+
const code = char.charCodeAt(0);
|
| 417 |
+
if (char in dict) {
|
| 418 |
+
result += dict[char];
|
| 419 |
+
} else if (code >= 55296 && code <= 57343) {
|
| 420 |
+
const next = str.charCodeAt(i + 1);
|
| 421 |
+
if (code <= 56319 && next >= 56320 && next <= 57343) {
|
| 422 |
+
result += char + str[++i];
|
| 423 |
+
} else {
|
| 424 |
+
result += unicode_encoder(code);
|
| 425 |
+
}
|
| 426 |
+
} else {
|
| 427 |
+
result += char;
|
| 428 |
+
}
|
| 429 |
+
}
|
| 430 |
+
return result;
|
| 431 |
+
}
|
| 432 |
+
const s = JSON.stringify;
|
| 433 |
+
async function render_response({
|
| 434 |
+
branch,
|
| 435 |
+
options,
|
| 436 |
+
$session,
|
| 437 |
+
page_config,
|
| 438 |
+
status,
|
| 439 |
+
error: error2,
|
| 440 |
+
url,
|
| 441 |
+
params
|
| 442 |
+
}) {
|
| 443 |
+
const css2 = new Set(options.manifest._.entry.css);
|
| 444 |
+
const js = new Set(options.manifest._.entry.js);
|
| 445 |
+
const styles = new Set();
|
| 446 |
+
const serialized_data = [];
|
| 447 |
+
let rendered;
|
| 448 |
+
let is_private = false;
|
| 449 |
+
let maxage;
|
| 450 |
+
if (error2) {
|
| 451 |
+
error2.stack = options.get_stack(error2);
|
| 452 |
+
}
|
| 453 |
+
if (page_config.ssr) {
|
| 454 |
+
branch.forEach(({ node, loaded, fetched, uses_credentials }) => {
|
| 455 |
+
if (node.css)
|
| 456 |
+
node.css.forEach((url2) => css2.add(url2));
|
| 457 |
+
if (node.js)
|
| 458 |
+
node.js.forEach((url2) => js.add(url2));
|
| 459 |
+
if (node.styles)
|
| 460 |
+
node.styles.forEach((content) => styles.add(content));
|
| 461 |
+
if (fetched && page_config.hydrate)
|
| 462 |
+
serialized_data.push(...fetched);
|
| 463 |
+
if (uses_credentials)
|
| 464 |
+
is_private = true;
|
| 465 |
+
maxage = loaded.maxage;
|
| 466 |
+
});
|
| 467 |
+
const session = writable($session);
|
| 468 |
+
const props = {
|
| 469 |
+
stores: {
|
| 470 |
+
page: writable(null),
|
| 471 |
+
navigating: writable(null),
|
| 472 |
+
session
|
| 473 |
+
},
|
| 474 |
+
page: { url, params, status, error: error2 },
|
| 475 |
+
components: branch.map(({ node }) => node.module.default)
|
| 476 |
+
};
|
| 477 |
+
const print_error = (property, replacement) => {
|
| 478 |
+
Object.defineProperty(props.page, property, {
|
| 479 |
+
get: () => {
|
| 480 |
+
throw new Error(`$page.${property} has been replaced by $page.url.${replacement}`);
|
| 481 |
+
}
|
| 482 |
+
});
|
| 483 |
+
};
|
| 484 |
+
print_error("origin", "origin");
|
| 485 |
+
print_error("path", "pathname");
|
| 486 |
+
print_error("query", "searchParams");
|
| 487 |
+
for (let i = 0; i < branch.length; i += 1) {
|
| 488 |
+
props[`props_${i}`] = await branch[i].loaded.props;
|
| 489 |
+
}
|
| 490 |
+
let session_tracking_active = false;
|
| 491 |
+
const unsubscribe = session.subscribe(() => {
|
| 492 |
+
if (session_tracking_active)
|
| 493 |
+
is_private = true;
|
| 494 |
+
});
|
| 495 |
+
session_tracking_active = true;
|
| 496 |
+
try {
|
| 497 |
+
rendered = options.root.render(props);
|
| 498 |
+
} finally {
|
| 499 |
+
unsubscribe();
|
| 500 |
+
}
|
| 501 |
+
} else {
|
| 502 |
+
rendered = { head: "", html: "", css: { code: "", map: null } };
|
| 503 |
+
}
|
| 504 |
+
const include_js = page_config.router || page_config.hydrate;
|
| 505 |
+
if (!include_js)
|
| 506 |
+
js.clear();
|
| 507 |
+
const links = options.amp ? styles.size > 0 || rendered.css.code.length > 0 ? `<style amp-custom>${Array.from(styles).concat(rendered.css.code).join("\n")}</style>` : "" : [
|
| 508 |
+
...Array.from(css2).map((dep) => `<link rel="stylesheet" href="${options.prefix}${dep}">`),
|
| 509 |
+
...Array.from(js).map((dep) => `<link rel="modulepreload" href="${options.prefix}${dep}">`)
|
| 510 |
+
].join("\n ");
|
| 511 |
+
let init = "";
|
| 512 |
+
if (options.amp) {
|
| 513 |
+
init = `
|
| 514 |
+
<style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style>
|
| 515 |
+
<noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style></noscript>
|
| 516 |
+
<script async src="https://cdn.ampproject.org/v0.js"><\/script>`;
|
| 517 |
+
init += options.service_worker ? '<script async custom-element="amp-install-serviceworker" src="https://cdn.ampproject.org/v0/amp-install-serviceworker-0.1.js"><\/script>' : "";
|
| 518 |
+
} else if (include_js) {
|
| 519 |
+
init = `<script type="module">
|
| 520 |
+
import { start } from ${s(options.prefix + options.manifest._.entry.file)};
|
| 521 |
+
start({
|
| 522 |
+
target: ${options.target ? `document.querySelector(${s(options.target)})` : "document.body"},
|
| 523 |
+
paths: ${s(options.paths)},
|
| 524 |
+
session: ${try_serialize($session, (error3) => {
|
| 525 |
+
throw new Error(`Failed to serialize session data: ${error3.message}`);
|
| 526 |
+
})},
|
| 527 |
+
route: ${!!page_config.router},
|
| 528 |
+
spa: ${!page_config.ssr},
|
| 529 |
+
trailing_slash: ${s(options.trailing_slash)},
|
| 530 |
+
hydrate: ${page_config.ssr && page_config.hydrate ? `{
|
| 531 |
+
status: ${status},
|
| 532 |
+
error: ${serialize_error(error2)},
|
| 533 |
+
nodes: [
|
| 534 |
+
${(branch || []).map(({ node }) => `import(${s(options.prefix + node.entry)})`).join(",\n ")}
|
| 535 |
+
],
|
| 536 |
+
url: new URL(${s(url.href)}),
|
| 537 |
+
params: ${devalue(params)}
|
| 538 |
+
}` : "null"}
|
| 539 |
+
});
|
| 540 |
+
<\/script>`;
|
| 541 |
+
}
|
| 542 |
+
if (options.service_worker && !options.amp) {
|
| 543 |
+
init += `<script>
|
| 544 |
+
if ('serviceWorker' in navigator) {
|
| 545 |
+
navigator.serviceWorker.register('${options.service_worker}');
|
| 546 |
+
}
|
| 547 |
+
<\/script>`;
|
| 548 |
+
}
|
| 549 |
+
const head = [
|
| 550 |
+
rendered.head,
|
| 551 |
+
styles.size && !options.amp ? `<style data-svelte>${Array.from(styles).join("\n")}</style>` : "",
|
| 552 |
+
links,
|
| 553 |
+
init
|
| 554 |
+
].join("\n\n ");
|
| 555 |
+
let body = rendered.html;
|
| 556 |
+
if (options.amp) {
|
| 557 |
+
if (options.service_worker) {
|
| 558 |
+
body += `<amp-install-serviceworker src="${options.service_worker}" layout="nodisplay"></amp-install-serviceworker>`;
|
| 559 |
+
}
|
| 560 |
+
} else {
|
| 561 |
+
body += serialized_data.map(({ url: url2, body: body2, json }) => {
|
| 562 |
+
let attributes = `type="application/json" data-type="svelte-data" data-url=${escape_html_attr(url2)}`;
|
| 563 |
+
if (body2)
|
| 564 |
+
attributes += ` data-body="${hash(body2)}"`;
|
| 565 |
+
return `<script ${attributes}>${json}<\/script>`;
|
| 566 |
+
}).join("\n\n ");
|
| 567 |
+
}
|
| 568 |
+
const headers = {
|
| 569 |
+
"content-type": "text/html"
|
| 570 |
+
};
|
| 571 |
+
if (maxage) {
|
| 572 |
+
headers["cache-control"] = `${is_private ? "private" : "public"}, max-age=${maxage}`;
|
| 573 |
+
}
|
| 574 |
+
if (!options.floc) {
|
| 575 |
+
headers["permissions-policy"] = "interest-cohort=()";
|
| 576 |
+
}
|
| 577 |
+
const segments = url.pathname.slice(options.paths.base.length).split("/").slice(2);
|
| 578 |
+
const assets2 = options.paths.assets || (segments.length > 0 ? segments.map(() => "..").join("/") : ".");
|
| 579 |
+
return {
|
| 580 |
+
status,
|
| 581 |
+
headers,
|
| 582 |
+
body: options.template({
|
| 583 |
+
head,
|
| 584 |
+
body,
|
| 585 |
+
assets: assets2
|
| 586 |
+
})
|
| 587 |
+
};
|
| 588 |
+
}
|
| 589 |
+
function try_serialize(data, fail) {
|
| 590 |
+
try {
|
| 591 |
+
return devalue(data);
|
| 592 |
+
} catch (err) {
|
| 593 |
+
if (fail)
|
| 594 |
+
fail(coalesce_to_error(err));
|
| 595 |
+
return null;
|
| 596 |
+
}
|
| 597 |
+
}
|
| 598 |
+
function serialize_error(error2) {
|
| 599 |
+
if (!error2)
|
| 600 |
+
return null;
|
| 601 |
+
let serialized = try_serialize(error2);
|
| 602 |
+
if (!serialized) {
|
| 603 |
+
const { name, message, stack } = error2;
|
| 604 |
+
serialized = try_serialize({ ...error2, name, message, stack });
|
| 605 |
+
}
|
| 606 |
+
if (!serialized) {
|
| 607 |
+
serialized = "{}";
|
| 608 |
+
}
|
| 609 |
+
return serialized;
|
| 610 |
+
}
|
| 611 |
+
function normalize(loaded) {
|
| 612 |
+
const has_error_status = loaded.status && loaded.status >= 400 && loaded.status <= 599 && !loaded.redirect;
|
| 613 |
+
if (loaded.error || has_error_status) {
|
| 614 |
+
const status = loaded.status;
|
| 615 |
+
if (!loaded.error && has_error_status) {
|
| 616 |
+
return {
|
| 617 |
+
status: status || 500,
|
| 618 |
+
error: new Error()
|
| 619 |
+
};
|
| 620 |
+
}
|
| 621 |
+
const error2 = typeof loaded.error === "string" ? new Error(loaded.error) : loaded.error;
|
| 622 |
+
if (!(error2 instanceof Error)) {
|
| 623 |
+
return {
|
| 624 |
+
status: 500,
|
| 625 |
+
error: new Error(`"error" property returned from load() must be a string or instance of Error, received type "${typeof error2}"`)
|
| 626 |
+
};
|
| 627 |
+
}
|
| 628 |
+
if (!status || status < 400 || status > 599) {
|
| 629 |
+
console.warn('"error" returned from load() without a valid status code \u2014 defaulting to 500');
|
| 630 |
+
return { status: 500, error: error2 };
|
| 631 |
+
}
|
| 632 |
+
return { status, error: error2 };
|
| 633 |
+
}
|
| 634 |
+
if (loaded.redirect) {
|
| 635 |
+
if (!loaded.status || Math.floor(loaded.status / 100) !== 3) {
|
| 636 |
+
return {
|
| 637 |
+
status: 500,
|
| 638 |
+
error: new Error('"redirect" property returned from load() must be accompanied by a 3xx status code')
|
| 639 |
+
};
|
| 640 |
+
}
|
| 641 |
+
if (typeof loaded.redirect !== "string") {
|
| 642 |
+
return {
|
| 643 |
+
status: 500,
|
| 644 |
+
error: new Error('"redirect" property returned from load() must be a string')
|
| 645 |
+
};
|
| 646 |
+
}
|
| 647 |
+
}
|
| 648 |
+
if (loaded.context) {
|
| 649 |
+
throw new Error('You are returning "context" from a load function. "context" was renamed to "stuff", please adjust your code accordingly.');
|
| 650 |
+
}
|
| 651 |
+
return loaded;
|
| 652 |
+
}
|
| 653 |
+
const absolute = /^([a-z]+:)?\/?\//;
|
| 654 |
+
const scheme = /^[a-z]+:/;
|
| 655 |
+
function resolve(base2, path) {
|
| 656 |
+
if (scheme.test(path))
|
| 657 |
+
return path;
|
| 658 |
+
const base_match = absolute.exec(base2);
|
| 659 |
+
const path_match = absolute.exec(path);
|
| 660 |
+
if (!base_match) {
|
| 661 |
+
throw new Error(`bad base path: "${base2}"`);
|
| 662 |
+
}
|
| 663 |
+
const baseparts = path_match ? [] : base2.slice(base_match[0].length).split("/");
|
| 664 |
+
const pathparts = path_match ? path.slice(path_match[0].length).split("/") : path.split("/");
|
| 665 |
+
baseparts.pop();
|
| 666 |
+
for (let i = 0; i < pathparts.length; i += 1) {
|
| 667 |
+
const part = pathparts[i];
|
| 668 |
+
if (part === ".")
|
| 669 |
+
continue;
|
| 670 |
+
else if (part === "..")
|
| 671 |
+
baseparts.pop();
|
| 672 |
+
else
|
| 673 |
+
baseparts.push(part);
|
| 674 |
+
}
|
| 675 |
+
const prefix = path_match && path_match[0] || base_match && base_match[0] || "";
|
| 676 |
+
return `${prefix}${baseparts.join("/")}`;
|
| 677 |
+
}
|
| 678 |
+
function is_root_relative(path) {
|
| 679 |
+
return path[0] === "/" && path[1] !== "/";
|
| 680 |
+
}
|
| 681 |
+
async function load_node({
|
| 682 |
+
request,
|
| 683 |
+
options,
|
| 684 |
+
state,
|
| 685 |
+
route,
|
| 686 |
+
url,
|
| 687 |
+
params,
|
| 688 |
+
node,
|
| 689 |
+
$session,
|
| 690 |
+
stuff,
|
| 691 |
+
prerender_enabled,
|
| 692 |
+
is_leaf,
|
| 693 |
+
is_error,
|
| 694 |
+
status,
|
| 695 |
+
error: error2
|
| 696 |
+
}) {
|
| 697 |
+
const { module } = node;
|
| 698 |
+
let uses_credentials = false;
|
| 699 |
+
const fetched = [];
|
| 700 |
+
let set_cookie_headers = [];
|
| 701 |
+
let loaded;
|
| 702 |
+
const url_proxy = new Proxy(url, {
|
| 703 |
+
get: (target, prop, receiver) => {
|
| 704 |
+
if (prerender_enabled && (prop === "search" || prop === "searchParams")) {
|
| 705 |
+
throw new Error("Cannot access query on a page with prerendering enabled");
|
| 706 |
+
}
|
| 707 |
+
return Reflect.get(target, prop, receiver);
|
| 708 |
+
}
|
| 709 |
+
});
|
| 710 |
+
if (module.load) {
|
| 711 |
+
const load_input = {
|
| 712 |
+
url: url_proxy,
|
| 713 |
+
params,
|
| 714 |
+
get session() {
|
| 715 |
+
uses_credentials = true;
|
| 716 |
+
return $session;
|
| 717 |
+
},
|
| 718 |
+
fetch: async (resource, opts = {}) => {
|
| 719 |
+
let requested;
|
| 720 |
+
if (typeof resource === "string") {
|
| 721 |
+
requested = resource;
|
| 722 |
+
} else {
|
| 723 |
+
requested = resource.url;
|
| 724 |
+
opts = {
|
| 725 |
+
method: resource.method,
|
| 726 |
+
headers: resource.headers,
|
| 727 |
+
body: resource.body,
|
| 728 |
+
mode: resource.mode,
|
| 729 |
+
credentials: resource.credentials,
|
| 730 |
+
cache: resource.cache,
|
| 731 |
+
redirect: resource.redirect,
|
| 732 |
+
referrer: resource.referrer,
|
| 733 |
+
integrity: resource.integrity,
|
| 734 |
+
...opts
|
| 735 |
+
};
|
| 736 |
+
}
|
| 737 |
+
opts.headers = new Headers(opts.headers);
|
| 738 |
+
const resolved = resolve(request.url.pathname, requested.split("?")[0]);
|
| 739 |
+
let response;
|
| 740 |
+
const prefix = options.paths.assets || options.paths.base;
|
| 741 |
+
const filename = (resolved.startsWith(prefix) ? resolved.slice(prefix.length) : resolved).slice(1);
|
| 742 |
+
const filename_html = `${filename}/index.html`;
|
| 743 |
+
const is_asset = options.manifest.assets.has(filename);
|
| 744 |
+
const is_asset_html = options.manifest.assets.has(filename_html);
|
| 745 |
+
if (is_asset || is_asset_html) {
|
| 746 |
+
const file = is_asset ? filename : filename_html;
|
| 747 |
+
if (options.read) {
|
| 748 |
+
const type = is_asset ? options.manifest._.mime[filename.slice(filename.lastIndexOf("."))] : "text/html";
|
| 749 |
+
response = new Response(options.read(file), {
|
| 750 |
+
headers: type ? { "content-type": type } : {}
|
| 751 |
+
});
|
| 752 |
+
} else {
|
| 753 |
+
response = await fetch(`${url.origin}/${file}`, opts);
|
| 754 |
+
}
|
| 755 |
+
} else if (is_root_relative(resolved)) {
|
| 756 |
+
const relative = resolved;
|
| 757 |
+
if (opts.credentials !== "omit") {
|
| 758 |
+
uses_credentials = true;
|
| 759 |
+
if (request.headers.cookie) {
|
| 760 |
+
opts.headers.set("cookie", request.headers.cookie);
|
| 761 |
+
}
|
| 762 |
+
if (request.headers.authorization && !opts.headers.has("authorization")) {
|
| 763 |
+
opts.headers.set("authorization", request.headers.authorization);
|
| 764 |
+
}
|
| 765 |
+
}
|
| 766 |
+
if (opts.body && typeof opts.body !== "string") {
|
| 767 |
+
throw new Error("Request body must be a string");
|
| 768 |
+
}
|
| 769 |
+
const rendered = await respond({
|
| 770 |
+
url: new URL(requested, request.url),
|
| 771 |
+
method: opts.method || "GET",
|
| 772 |
+
headers: Object.fromEntries(opts.headers),
|
| 773 |
+
rawBody: opts.body == null ? null : new TextEncoder().encode(opts.body)
|
| 774 |
+
}, options, {
|
| 775 |
+
fetched: requested,
|
| 776 |
+
initiator: route
|
| 777 |
+
});
|
| 778 |
+
if (rendered) {
|
| 779 |
+
if (state.prerender) {
|
| 780 |
+
state.prerender.dependencies.set(relative, rendered);
|
| 781 |
+
}
|
| 782 |
+
response = new Response(rendered.body, {
|
| 783 |
+
status: rendered.status,
|
| 784 |
+
headers: rendered.headers
|
| 785 |
+
});
|
| 786 |
+
} else {
|
| 787 |
+
return fetch(new URL(requested, request.url).href, {
|
| 788 |
+
method: opts.method || "GET",
|
| 789 |
+
headers: opts.headers
|
| 790 |
+
});
|
| 791 |
+
}
|
| 792 |
+
} else {
|
| 793 |
+
if (resolved.startsWith("//")) {
|
| 794 |
+
throw new Error(`Cannot request protocol-relative URL (${requested}) in server-side fetch`);
|
| 795 |
+
}
|
| 796 |
+
if (`.${new URL(requested).hostname}`.endsWith(`.${request.url.hostname}`) && opts.credentials !== "omit") {
|
| 797 |
+
uses_credentials = true;
|
| 798 |
+
opts.headers.set("cookie", request.headers.cookie);
|
| 799 |
+
}
|
| 800 |
+
const external_request = new Request(requested, opts);
|
| 801 |
+
response = await options.hooks.externalFetch.call(null, external_request);
|
| 802 |
+
}
|
| 803 |
+
if (response) {
|
| 804 |
+
const proxy = new Proxy(response, {
|
| 805 |
+
get(response2, key, _receiver) {
|
| 806 |
+
async function text() {
|
| 807 |
+
const body = await response2.text();
|
| 808 |
+
const headers = {};
|
| 809 |
+
for (const [key2, value] of response2.headers) {
|
| 810 |
+
if (key2 === "set-cookie") {
|
| 811 |
+
set_cookie_headers = set_cookie_headers.concat(value);
|
| 812 |
+
} else if (key2 !== "etag") {
|
| 813 |
+
headers[key2] = value;
|
| 814 |
+
}
|
| 815 |
+
}
|
| 816 |
+
if (!opts.body || typeof opts.body === "string") {
|
| 817 |
+
fetched.push({
|
| 818 |
+
url: requested,
|
| 819 |
+
body: opts.body,
|
| 820 |
+
json: `{"status":${response2.status},"statusText":${s(response2.statusText)},"headers":${s(headers)},"body":"${escape_json_string_in_html(body)}"}`
|
| 821 |
+
});
|
| 822 |
+
}
|
| 823 |
+
return body;
|
| 824 |
+
}
|
| 825 |
+
if (key === "text") {
|
| 826 |
+
return text;
|
| 827 |
+
}
|
| 828 |
+
if (key === "json") {
|
| 829 |
+
return async () => {
|
| 830 |
+
return JSON.parse(await text());
|
| 831 |
+
};
|
| 832 |
+
}
|
| 833 |
+
return Reflect.get(response2, key, response2);
|
| 834 |
+
}
|
| 835 |
+
});
|
| 836 |
+
return proxy;
|
| 837 |
+
}
|
| 838 |
+
return response || new Response("Not found", {
|
| 839 |
+
status: 404
|
| 840 |
+
});
|
| 841 |
+
},
|
| 842 |
+
stuff: { ...stuff }
|
| 843 |
+
};
|
| 844 |
+
if (options.dev) {
|
| 845 |
+
Object.defineProperty(load_input, "page", {
|
| 846 |
+
get: () => {
|
| 847 |
+
throw new Error("`page` in `load` functions has been replaced by `url` and `params`");
|
| 848 |
+
}
|
| 849 |
+
});
|
| 850 |
+
}
|
| 851 |
+
if (is_error) {
|
| 852 |
+
load_input.status = status;
|
| 853 |
+
load_input.error = error2;
|
| 854 |
+
}
|
| 855 |
+
loaded = await module.load.call(null, load_input);
|
| 856 |
+
} else {
|
| 857 |
+
loaded = {};
|
| 858 |
+
}
|
| 859 |
+
if (!loaded && is_leaf && !is_error)
|
| 860 |
+
return;
|
| 861 |
+
if (!loaded) {
|
| 862 |
+
throw new Error(`${node.entry} - load must return a value except for page fall through`);
|
| 863 |
+
}
|
| 864 |
+
return {
|
| 865 |
+
node,
|
| 866 |
+
loaded: normalize(loaded),
|
| 867 |
+
stuff: loaded.stuff || stuff,
|
| 868 |
+
fetched,
|
| 869 |
+
set_cookie_headers,
|
| 870 |
+
uses_credentials
|
| 871 |
+
};
|
| 872 |
+
}
|
| 873 |
+
async function respond_with_error({ request, options, state, $session, status, error: error2 }) {
|
| 874 |
+
const default_layout = await options.manifest._.nodes[0]();
|
| 875 |
+
const default_error = await options.manifest._.nodes[1]();
|
| 876 |
+
const params = {};
|
| 877 |
+
const loaded = await load_node({
|
| 878 |
+
request,
|
| 879 |
+
options,
|
| 880 |
+
state,
|
| 881 |
+
route: null,
|
| 882 |
+
url: request.url,
|
| 883 |
+
params,
|
| 884 |
+
node: default_layout,
|
| 885 |
+
$session,
|
| 886 |
+
stuff: {},
|
| 887 |
+
prerender_enabled: is_prerender_enabled(options, default_error, state),
|
| 888 |
+
is_leaf: false,
|
| 889 |
+
is_error: false
|
| 890 |
+
});
|
| 891 |
+
const branch = [
|
| 892 |
+
loaded,
|
| 893 |
+
await load_node({
|
| 894 |
+
request,
|
| 895 |
+
options,
|
| 896 |
+
state,
|
| 897 |
+
route: null,
|
| 898 |
+
url: request.url,
|
| 899 |
+
params,
|
| 900 |
+
node: default_error,
|
| 901 |
+
$session,
|
| 902 |
+
stuff: loaded ? loaded.stuff : {},
|
| 903 |
+
prerender_enabled: is_prerender_enabled(options, default_error, state),
|
| 904 |
+
is_leaf: false,
|
| 905 |
+
is_error: true,
|
| 906 |
+
status,
|
| 907 |
+
error: error2
|
| 908 |
+
})
|
| 909 |
+
];
|
| 910 |
+
try {
|
| 911 |
+
return await render_response({
|
| 912 |
+
options,
|
| 913 |
+
$session,
|
| 914 |
+
page_config: {
|
| 915 |
+
hydrate: options.hydrate,
|
| 916 |
+
router: options.router,
|
| 917 |
+
ssr: options.ssr
|
| 918 |
+
},
|
| 919 |
+
status,
|
| 920 |
+
error: error2,
|
| 921 |
+
branch,
|
| 922 |
+
url: request.url,
|
| 923 |
+
params
|
| 924 |
+
});
|
| 925 |
+
} catch (err) {
|
| 926 |
+
const error3 = coalesce_to_error(err);
|
| 927 |
+
options.handle_error(error3, request);
|
| 928 |
+
return {
|
| 929 |
+
status: 500,
|
| 930 |
+
headers: {},
|
| 931 |
+
body: error3.stack
|
| 932 |
+
};
|
| 933 |
+
}
|
| 934 |
+
}
|
| 935 |
+
function is_prerender_enabled(options, node, state) {
|
| 936 |
+
return options.prerender && (!!node.module.prerender || !!state.prerender && state.prerender.all);
|
| 937 |
+
}
|
| 938 |
+
async function respond$1(opts) {
|
| 939 |
+
const { request, options, state, $session, route } = opts;
|
| 940 |
+
let nodes;
|
| 941 |
+
try {
|
| 942 |
+
nodes = await Promise.all(route.a.map((n) => options.manifest._.nodes[n] && options.manifest._.nodes[n]()));
|
| 943 |
+
} catch (err) {
|
| 944 |
+
const error3 = coalesce_to_error(err);
|
| 945 |
+
options.handle_error(error3, request);
|
| 946 |
+
return await respond_with_error({
|
| 947 |
+
request,
|
| 948 |
+
options,
|
| 949 |
+
state,
|
| 950 |
+
$session,
|
| 951 |
+
status: 500,
|
| 952 |
+
error: error3
|
| 953 |
+
});
|
| 954 |
+
}
|
| 955 |
+
const leaf = nodes[nodes.length - 1].module;
|
| 956 |
+
let page_config = get_page_config(leaf, options);
|
| 957 |
+
if (!leaf.prerender && state.prerender && !state.prerender.all) {
|
| 958 |
+
return {
|
| 959 |
+
status: 204,
|
| 960 |
+
headers: {}
|
| 961 |
+
};
|
| 962 |
+
}
|
| 963 |
+
let branch = [];
|
| 964 |
+
let status = 200;
|
| 965 |
+
let error2;
|
| 966 |
+
let set_cookie_headers = [];
|
| 967 |
+
ssr:
|
| 968 |
+
if (page_config.ssr) {
|
| 969 |
+
let stuff = {};
|
| 970 |
+
for (let i = 0; i < nodes.length; i += 1) {
|
| 971 |
+
const node = nodes[i];
|
| 972 |
+
let loaded;
|
| 973 |
+
if (node) {
|
| 974 |
+
try {
|
| 975 |
+
loaded = await load_node({
|
| 976 |
+
...opts,
|
| 977 |
+
url: request.url,
|
| 978 |
+
node,
|
| 979 |
+
stuff,
|
| 980 |
+
prerender_enabled: is_prerender_enabled(options, node, state),
|
| 981 |
+
is_leaf: i === nodes.length - 1,
|
| 982 |
+
is_error: false
|
| 983 |
+
});
|
| 984 |
+
if (!loaded)
|
| 985 |
+
return;
|
| 986 |
+
set_cookie_headers = set_cookie_headers.concat(loaded.set_cookie_headers);
|
| 987 |
+
if (loaded.loaded.redirect) {
|
| 988 |
+
return with_cookies({
|
| 989 |
+
status: loaded.loaded.status,
|
| 990 |
+
headers: {
|
| 991 |
+
location: encodeURI(loaded.loaded.redirect)
|
| 992 |
+
}
|
| 993 |
+
}, set_cookie_headers);
|
| 994 |
+
}
|
| 995 |
+
if (loaded.loaded.error) {
|
| 996 |
+
({ status, error: error2 } = loaded.loaded);
|
| 997 |
+
}
|
| 998 |
+
} catch (err) {
|
| 999 |
+
const e = coalesce_to_error(err);
|
| 1000 |
+
options.handle_error(e, request);
|
| 1001 |
+
status = 500;
|
| 1002 |
+
error2 = e;
|
| 1003 |
+
}
|
| 1004 |
+
if (loaded && !error2) {
|
| 1005 |
+
branch.push(loaded);
|
| 1006 |
+
}
|
| 1007 |
+
if (error2) {
|
| 1008 |
+
while (i--) {
|
| 1009 |
+
if (route.b[i]) {
|
| 1010 |
+
const error_node = await options.manifest._.nodes[route.b[i]]();
|
| 1011 |
+
let node_loaded;
|
| 1012 |
+
let j = i;
|
| 1013 |
+
while (!(node_loaded = branch[j])) {
|
| 1014 |
+
j -= 1;
|
| 1015 |
+
}
|
| 1016 |
+
try {
|
| 1017 |
+
const error_loaded = await load_node({
|
| 1018 |
+
...opts,
|
| 1019 |
+
url: request.url,
|
| 1020 |
+
node: error_node,
|
| 1021 |
+
stuff: node_loaded.stuff,
|
| 1022 |
+
prerender_enabled: is_prerender_enabled(options, error_node, state),
|
| 1023 |
+
is_leaf: false,
|
| 1024 |
+
is_error: true,
|
| 1025 |
+
status,
|
| 1026 |
+
error: error2
|
| 1027 |
+
});
|
| 1028 |
+
if (error_loaded.loaded.error) {
|
| 1029 |
+
continue;
|
| 1030 |
+
}
|
| 1031 |
+
page_config = get_page_config(error_node.module, options);
|
| 1032 |
+
branch = branch.slice(0, j + 1).concat(error_loaded);
|
| 1033 |
+
break ssr;
|
| 1034 |
+
} catch (err) {
|
| 1035 |
+
const e = coalesce_to_error(err);
|
| 1036 |
+
options.handle_error(e, request);
|
| 1037 |
+
continue;
|
| 1038 |
+
}
|
| 1039 |
+
}
|
| 1040 |
+
}
|
| 1041 |
+
return with_cookies(await respond_with_error({
|
| 1042 |
+
request,
|
| 1043 |
+
options,
|
| 1044 |
+
state,
|
| 1045 |
+
$session,
|
| 1046 |
+
status,
|
| 1047 |
+
error: error2
|
| 1048 |
+
}), set_cookie_headers);
|
| 1049 |
+
}
|
| 1050 |
+
}
|
| 1051 |
+
if (loaded && loaded.loaded.stuff) {
|
| 1052 |
+
stuff = {
|
| 1053 |
+
...stuff,
|
| 1054 |
+
...loaded.loaded.stuff
|
| 1055 |
+
};
|
| 1056 |
+
}
|
| 1057 |
+
}
|
| 1058 |
+
}
|
| 1059 |
+
try {
|
| 1060 |
+
return with_cookies(await render_response({
|
| 1061 |
+
...opts,
|
| 1062 |
+
url: request.url,
|
| 1063 |
+
page_config,
|
| 1064 |
+
status,
|
| 1065 |
+
error: error2,
|
| 1066 |
+
branch: branch.filter(Boolean)
|
| 1067 |
+
}), set_cookie_headers);
|
| 1068 |
+
} catch (err) {
|
| 1069 |
+
const error3 = coalesce_to_error(err);
|
| 1070 |
+
options.handle_error(error3, request);
|
| 1071 |
+
return with_cookies(await respond_with_error({
|
| 1072 |
+
...opts,
|
| 1073 |
+
status: 500,
|
| 1074 |
+
error: error3
|
| 1075 |
+
}), set_cookie_headers);
|
| 1076 |
+
}
|
| 1077 |
+
}
|
| 1078 |
+
function get_page_config(leaf, options) {
|
| 1079 |
+
return {
|
| 1080 |
+
ssr: "ssr" in leaf ? !!leaf.ssr : options.ssr,
|
| 1081 |
+
router: "router" in leaf ? !!leaf.router : options.router,
|
| 1082 |
+
hydrate: "hydrate" in leaf ? !!leaf.hydrate : options.hydrate
|
| 1083 |
+
};
|
| 1084 |
+
}
|
| 1085 |
+
function with_cookies(response, set_cookie_headers) {
|
| 1086 |
+
if (set_cookie_headers.length) {
|
| 1087 |
+
response.headers["set-cookie"] = set_cookie_headers;
|
| 1088 |
+
}
|
| 1089 |
+
return response;
|
| 1090 |
+
}
|
| 1091 |
+
async function render_page(request, route, match, options, state) {
|
| 1092 |
+
if (state.initiator === route) {
|
| 1093 |
+
return {
|
| 1094 |
+
status: 404,
|
| 1095 |
+
headers: {},
|
| 1096 |
+
body: `Not found: ${request.url.pathname}`
|
| 1097 |
+
};
|
| 1098 |
+
}
|
| 1099 |
+
const params = route.params ? decode_params(route.params(match)) : {};
|
| 1100 |
+
const $session = await options.hooks.getSession(request);
|
| 1101 |
+
const response = await respond$1({
|
| 1102 |
+
request,
|
| 1103 |
+
options,
|
| 1104 |
+
state,
|
| 1105 |
+
$session,
|
| 1106 |
+
route,
|
| 1107 |
+
params
|
| 1108 |
+
});
|
| 1109 |
+
if (response) {
|
| 1110 |
+
return response;
|
| 1111 |
+
}
|
| 1112 |
+
if (state.fetched) {
|
| 1113 |
+
return {
|
| 1114 |
+
status: 500,
|
| 1115 |
+
headers: {},
|
| 1116 |
+
body: `Bad request in load function: failed to fetch ${state.fetched}`
|
| 1117 |
+
};
|
| 1118 |
+
}
|
| 1119 |
+
}
|
| 1120 |
+
function read_only_form_data() {
|
| 1121 |
+
const map = new Map();
|
| 1122 |
+
return {
|
| 1123 |
+
append(key, value) {
|
| 1124 |
+
if (map.has(key)) {
|
| 1125 |
+
(map.get(key) || []).push(value);
|
| 1126 |
+
} else {
|
| 1127 |
+
map.set(key, [value]);
|
| 1128 |
+
}
|
| 1129 |
+
},
|
| 1130 |
+
data: new ReadOnlyFormData(map)
|
| 1131 |
+
};
|
| 1132 |
+
}
|
| 1133 |
+
class ReadOnlyFormData {
|
| 1134 |
+
constructor(map) {
|
| 1135 |
+
__privateAdd(this, _map, void 0);
|
| 1136 |
+
__privateSet(this, _map, map);
|
| 1137 |
+
}
|
| 1138 |
+
get(key) {
|
| 1139 |
+
const value = __privateGet(this, _map).get(key);
|
| 1140 |
+
return value && value[0];
|
| 1141 |
+
}
|
| 1142 |
+
getAll(key) {
|
| 1143 |
+
return __privateGet(this, _map).get(key);
|
| 1144 |
+
}
|
| 1145 |
+
has(key) {
|
| 1146 |
+
return __privateGet(this, _map).has(key);
|
| 1147 |
+
}
|
| 1148 |
+
*[Symbol.iterator]() {
|
| 1149 |
+
for (const [key, value] of __privateGet(this, _map)) {
|
| 1150 |
+
for (let i = 0; i < value.length; i += 1) {
|
| 1151 |
+
yield [key, value[i]];
|
| 1152 |
+
}
|
| 1153 |
+
}
|
| 1154 |
+
}
|
| 1155 |
+
*entries() {
|
| 1156 |
+
for (const [key, value] of __privateGet(this, _map)) {
|
| 1157 |
+
for (let i = 0; i < value.length; i += 1) {
|
| 1158 |
+
yield [key, value[i]];
|
| 1159 |
+
}
|
| 1160 |
+
}
|
| 1161 |
+
}
|
| 1162 |
+
*keys() {
|
| 1163 |
+
for (const [key] of __privateGet(this, _map))
|
| 1164 |
+
yield key;
|
| 1165 |
+
}
|
| 1166 |
+
*values() {
|
| 1167 |
+
for (const [, value] of __privateGet(this, _map)) {
|
| 1168 |
+
for (let i = 0; i < value.length; i += 1) {
|
| 1169 |
+
yield value[i];
|
| 1170 |
+
}
|
| 1171 |
+
}
|
| 1172 |
+
}
|
| 1173 |
+
}
|
| 1174 |
+
_map = new WeakMap();
|
| 1175 |
+
function parse_body(raw, headers) {
|
| 1176 |
+
if (!raw)
|
| 1177 |
+
return raw;
|
| 1178 |
+
const content_type = headers["content-type"];
|
| 1179 |
+
const [type, ...directives] = content_type ? content_type.split(/;\s*/) : [];
|
| 1180 |
+
const text = () => new TextDecoder(headers["content-encoding"] || "utf-8").decode(raw);
|
| 1181 |
+
switch (type) {
|
| 1182 |
+
case "text/plain":
|
| 1183 |
+
return text();
|
| 1184 |
+
case "application/json":
|
| 1185 |
+
return JSON.parse(text());
|
| 1186 |
+
case "application/x-www-form-urlencoded":
|
| 1187 |
+
return get_urlencoded(text());
|
| 1188 |
+
case "multipart/form-data": {
|
| 1189 |
+
const boundary = directives.find((directive) => directive.startsWith("boundary="));
|
| 1190 |
+
if (!boundary)
|
| 1191 |
+
throw new Error("Missing boundary");
|
| 1192 |
+
return get_multipart(text(), boundary.slice("boundary=".length));
|
| 1193 |
+
}
|
| 1194 |
+
default:
|
| 1195 |
+
return raw;
|
| 1196 |
+
}
|
| 1197 |
+
}
|
| 1198 |
+
function get_urlencoded(text) {
|
| 1199 |
+
const { data, append } = read_only_form_data();
|
| 1200 |
+
text.replace(/\+/g, " ").split("&").forEach((str) => {
|
| 1201 |
+
const [key, value] = str.split("=");
|
| 1202 |
+
append(decodeURIComponent(key), decodeURIComponent(value));
|
| 1203 |
+
});
|
| 1204 |
+
return data;
|
| 1205 |
+
}
|
| 1206 |
+
function get_multipart(text, boundary) {
|
| 1207 |
+
const parts = text.split(`--${boundary}`);
|
| 1208 |
+
if (parts[0] !== "" || parts[parts.length - 1].trim() !== "--") {
|
| 1209 |
+
throw new Error("Malformed form data");
|
| 1210 |
+
}
|
| 1211 |
+
const { data, append } = read_only_form_data();
|
| 1212 |
+
parts.slice(1, -1).forEach((part) => {
|
| 1213 |
+
const match = /\s*([\s\S]+?)\r\n\r\n([\s\S]*)\s*/.exec(part);
|
| 1214 |
+
if (!match) {
|
| 1215 |
+
throw new Error("Malformed form data");
|
| 1216 |
+
}
|
| 1217 |
+
const raw_headers = match[1];
|
| 1218 |
+
const body = match[2].trim();
|
| 1219 |
+
let key;
|
| 1220 |
+
const headers = {};
|
| 1221 |
+
raw_headers.split("\r\n").forEach((str) => {
|
| 1222 |
+
const [raw_header, ...raw_directives] = str.split("; ");
|
| 1223 |
+
let [name, value] = raw_header.split(": ");
|
| 1224 |
+
name = name.toLowerCase();
|
| 1225 |
+
headers[name] = value;
|
| 1226 |
+
const directives = {};
|
| 1227 |
+
raw_directives.forEach((raw_directive) => {
|
| 1228 |
+
const [name2, value2] = raw_directive.split("=");
|
| 1229 |
+
directives[name2] = JSON.parse(value2);
|
| 1230 |
+
});
|
| 1231 |
+
if (name === "content-disposition") {
|
| 1232 |
+
if (value !== "form-data")
|
| 1233 |
+
throw new Error("Malformed form data");
|
| 1234 |
+
if (directives.filename) {
|
| 1235 |
+
throw new Error("File upload is not yet implemented");
|
| 1236 |
+
}
|
| 1237 |
+
if (directives.name) {
|
| 1238 |
+
key = directives.name;
|
| 1239 |
+
}
|
| 1240 |
+
}
|
| 1241 |
+
});
|
| 1242 |
+
if (!key)
|
| 1243 |
+
throw new Error("Malformed form data");
|
| 1244 |
+
append(key, body);
|
| 1245 |
+
});
|
| 1246 |
+
return data;
|
| 1247 |
+
}
|
| 1248 |
+
async function respond(incoming, options, state = {}) {
|
| 1249 |
+
if (incoming.url.pathname !== "/" && options.trailing_slash !== "ignore") {
|
| 1250 |
+
const has_trailing_slash = incoming.url.pathname.endsWith("/");
|
| 1251 |
+
if (has_trailing_slash && options.trailing_slash === "never" || !has_trailing_slash && options.trailing_slash === "always" && !(incoming.url.pathname.split("/").pop() || "").includes(".")) {
|
| 1252 |
+
incoming.url.pathname = has_trailing_slash ? incoming.url.pathname.slice(0, -1) : incoming.url.pathname + "/";
|
| 1253 |
+
if (incoming.url.search === "?")
|
| 1254 |
+
incoming.url.search = "";
|
| 1255 |
+
return {
|
| 1256 |
+
status: 301,
|
| 1257 |
+
headers: {
|
| 1258 |
+
location: incoming.url.pathname + incoming.url.search
|
| 1259 |
+
}
|
| 1260 |
+
};
|
| 1261 |
+
}
|
| 1262 |
+
}
|
| 1263 |
+
const headers = lowercase_keys(incoming.headers);
|
| 1264 |
+
const request = {
|
| 1265 |
+
...incoming,
|
| 1266 |
+
headers,
|
| 1267 |
+
body: parse_body(incoming.rawBody, headers),
|
| 1268 |
+
params: {},
|
| 1269 |
+
locals: {}
|
| 1270 |
+
};
|
| 1271 |
+
const print_error = (property, replacement) => {
|
| 1272 |
+
Object.defineProperty(request, property, {
|
| 1273 |
+
get: () => {
|
| 1274 |
+
throw new Error(`request.${property} has been replaced by request.url.${replacement}`);
|
| 1275 |
+
}
|
| 1276 |
+
});
|
| 1277 |
+
};
|
| 1278 |
+
print_error("origin", "origin");
|
| 1279 |
+
print_error("path", "pathname");
|
| 1280 |
+
print_error("query", "searchParams");
|
| 1281 |
+
try {
|
| 1282 |
+
return await options.hooks.handle({
|
| 1283 |
+
request,
|
| 1284 |
+
resolve: async (request2) => {
|
| 1285 |
+
if (state.prerender && state.prerender.fallback) {
|
| 1286 |
+
return await render_response({
|
| 1287 |
+
url: request2.url,
|
| 1288 |
+
params: request2.params,
|
| 1289 |
+
options,
|
| 1290 |
+
$session: await options.hooks.getSession(request2),
|
| 1291 |
+
page_config: { ssr: false, router: true, hydrate: true },
|
| 1292 |
+
status: 200,
|
| 1293 |
+
branch: []
|
| 1294 |
+
});
|
| 1295 |
+
}
|
| 1296 |
+
const decoded = decodeURI(request2.url.pathname).replace(options.paths.base, "");
|
| 1297 |
+
for (const route of options.manifest._.routes) {
|
| 1298 |
+
const match = route.pattern.exec(decoded);
|
| 1299 |
+
if (!match)
|
| 1300 |
+
continue;
|
| 1301 |
+
const response = route.type === "endpoint" ? await render_endpoint(request2, route, match) : await render_page(request2, route, match, options, state);
|
| 1302 |
+
if (response) {
|
| 1303 |
+
if (response.status === 200) {
|
| 1304 |
+
const cache_control = get_single_valued_header(response.headers, "cache-control");
|
| 1305 |
+
if (!cache_control || !/(no-store|immutable)/.test(cache_control)) {
|
| 1306 |
+
let if_none_match_value = request2.headers["if-none-match"];
|
| 1307 |
+
if (if_none_match_value?.startsWith('W/"')) {
|
| 1308 |
+
if_none_match_value = if_none_match_value.substring(2);
|
| 1309 |
+
}
|
| 1310 |
+
const etag = `"${hash(response.body || "")}"`;
|
| 1311 |
+
if (if_none_match_value === etag) {
|
| 1312 |
+
return {
|
| 1313 |
+
status: 304,
|
| 1314 |
+
headers: {}
|
| 1315 |
+
};
|
| 1316 |
+
}
|
| 1317 |
+
response.headers["etag"] = etag;
|
| 1318 |
+
}
|
| 1319 |
+
}
|
| 1320 |
+
return response;
|
| 1321 |
+
}
|
| 1322 |
+
}
|
| 1323 |
+
if (!state.initiator) {
|
| 1324 |
+
const $session = await options.hooks.getSession(request2);
|
| 1325 |
+
return await respond_with_error({
|
| 1326 |
+
request: request2,
|
| 1327 |
+
options,
|
| 1328 |
+
state,
|
| 1329 |
+
$session,
|
| 1330 |
+
status: 404,
|
| 1331 |
+
error: new Error(`Not found: ${request2.url.pathname}`)
|
| 1332 |
+
});
|
| 1333 |
+
}
|
| 1334 |
+
}
|
| 1335 |
+
});
|
| 1336 |
+
} catch (err) {
|
| 1337 |
+
const e = coalesce_to_error(err);
|
| 1338 |
+
options.handle_error(e, request);
|
| 1339 |
+
return {
|
| 1340 |
+
status: 500,
|
| 1341 |
+
headers: {},
|
| 1342 |
+
body: options.dev ? e.stack : e.message
|
| 1343 |
+
};
|
| 1344 |
+
}
|
| 1345 |
+
}
|
| 1346 |
+
function afterUpdate() {
|
| 1347 |
+
}
|
| 1348 |
+
var root_svelte_svelte_type_style_lang = "";
|
| 1349 |
+
const css = {
|
| 1350 |
+
code: "#svelte-announcer.svelte-1j55zn5{position:absolute;left:0;top:0;clip:rect(0 0 0 0);clip-path:inset(50%);overflow:hidden;white-space:nowrap;width:1px;height:1px}",
|
| 1351 |
+
map: null
|
| 1352 |
+
};
|
| 1353 |
+
const Root = create_ssr_component(($$result, $$props, $$bindings, slots) => {
|
| 1354 |
+
let { stores } = $$props;
|
| 1355 |
+
let { page } = $$props;
|
| 1356 |
+
let { components } = $$props;
|
| 1357 |
+
let { props_0 = null } = $$props;
|
| 1358 |
+
let { props_1 = null } = $$props;
|
| 1359 |
+
let { props_2 = null } = $$props;
|
| 1360 |
+
setContext("__svelte__", stores);
|
| 1361 |
+
afterUpdate(stores.page.notify);
|
| 1362 |
+
if ($$props.stores === void 0 && $$bindings.stores && stores !== void 0)
|
| 1363 |
+
$$bindings.stores(stores);
|
| 1364 |
+
if ($$props.page === void 0 && $$bindings.page && page !== void 0)
|
| 1365 |
+
$$bindings.page(page);
|
| 1366 |
+
if ($$props.components === void 0 && $$bindings.components && components !== void 0)
|
| 1367 |
+
$$bindings.components(components);
|
| 1368 |
+
if ($$props.props_0 === void 0 && $$bindings.props_0 && props_0 !== void 0)
|
| 1369 |
+
$$bindings.props_0(props_0);
|
| 1370 |
+
if ($$props.props_1 === void 0 && $$bindings.props_1 && props_1 !== void 0)
|
| 1371 |
+
$$bindings.props_1(props_1);
|
| 1372 |
+
if ($$props.props_2 === void 0 && $$bindings.props_2 && props_2 !== void 0)
|
| 1373 |
+
$$bindings.props_2(props_2);
|
| 1374 |
+
$$result.css.add(css);
|
| 1375 |
+
{
|
| 1376 |
+
stores.page.set(page);
|
| 1377 |
+
}
|
| 1378 |
+
return `
|
| 1379 |
+
|
| 1380 |
+
|
| 1381 |
+
${components[1] ? `${validate_component(components[0] || missing_component, "svelte:component").$$render($$result, Object.assign(props_0 || {}), {}, {
|
| 1382 |
+
default: () => `${components[2] ? `${validate_component(components[1] || missing_component, "svelte:component").$$render($$result, Object.assign(props_1 || {}), {}, {
|
| 1383 |
+
default: () => `${validate_component(components[2] || missing_component, "svelte:component").$$render($$result, Object.assign(props_2 || {}), {}, {})}`
|
| 1384 |
+
})}` : `${validate_component(components[1] || missing_component, "svelte:component").$$render($$result, Object.assign(props_1 || {}), {}, {})}`}`
|
| 1385 |
+
})}` : `${validate_component(components[0] || missing_component, "svelte:component").$$render($$result, Object.assign(props_0 || {}), {}, {})}`}
|
| 1386 |
+
|
| 1387 |
+
${``}`;
|
| 1388 |
+
});
|
| 1389 |
+
let base = "";
|
| 1390 |
+
let assets = "";
|
| 1391 |
+
function set_paths(paths) {
|
| 1392 |
+
base = paths.base;
|
| 1393 |
+
assets = paths.assets || base;
|
| 1394 |
+
}
|
| 1395 |
+
function set_prerendering(value) {
|
| 1396 |
+
}
|
| 1397 |
+
const handle = async ({ request, resolve: resolve2 }) => {
|
| 1398 |
+
const cookies = cookie.parse(request.headers.cookie || "");
|
| 1399 |
+
request.locals.userid = cookies.userid || v4();
|
| 1400 |
+
const method = request.url.searchParams.get("_method");
|
| 1401 |
+
if (method) {
|
| 1402 |
+
request.method = method.toUpperCase();
|
| 1403 |
+
}
|
| 1404 |
+
const response = await resolve2(request);
|
| 1405 |
+
if (!cookies.userid) {
|
| 1406 |
+
response.headers["set-cookie"] = cookie.serialize("userid", request.locals.userid, {
|
| 1407 |
+
path: "/",
|
| 1408 |
+
httpOnly: true
|
| 1409 |
+
});
|
| 1410 |
+
}
|
| 1411 |
+
return response;
|
| 1412 |
+
};
|
| 1413 |
+
var user_hooks = /* @__PURE__ */ Object.freeze({
|
| 1414 |
+
__proto__: null,
|
| 1415 |
+
[Symbol.toStringTag]: "Module",
|
| 1416 |
+
handle
|
| 1417 |
+
});
|
| 1418 |
+
const template = ({ head, body, assets: assets2 }) => '<!DOCTYPE html>\n<html lang="en">\n <head>\n <meta charset="utf-8" />\n <meta name="description" content="Svelte demo app" />\n <link rel="icon" href="' + assets2 + '/favicon.png" />\n <meta name="viewport" content="width=device-width, initial-scale=1" />\n ' + head + '\n </head>\n <body>\n <div id="svelte">' + body + "</div>\n </body>\n</html>\n";
|
| 1419 |
+
let read = null;
|
| 1420 |
+
set_paths({ "base": "/staticspaceiframe/spaces/pngwn/static-test", "assets": "" });
|
| 1421 |
+
const get_hooks = (hooks) => ({
|
| 1422 |
+
getSession: hooks.getSession || (() => ({})),
|
| 1423 |
+
handle: hooks.handle || (({ request, resolve: resolve2 }) => resolve2(request)),
|
| 1424 |
+
handleError: hooks.handleError || (({ error: error2 }) => console.error(error2.stack)),
|
| 1425 |
+
externalFetch: hooks.externalFetch || fetch
|
| 1426 |
+
});
|
| 1427 |
+
let default_protocol = "https";
|
| 1428 |
+
function override(settings) {
|
| 1429 |
+
default_protocol = settings.protocol || default_protocol;
|
| 1430 |
+
set_paths(settings.paths);
|
| 1431 |
+
set_prerendering(settings.prerendering);
|
| 1432 |
+
read = settings.read;
|
| 1433 |
+
}
|
| 1434 |
+
class App {
|
| 1435 |
+
constructor(manifest) {
|
| 1436 |
+
const hooks = get_hooks(user_hooks);
|
| 1437 |
+
this.options = {
|
| 1438 |
+
amp: false,
|
| 1439 |
+
dev: false,
|
| 1440 |
+
floc: false,
|
| 1441 |
+
get_stack: (error2) => String(error2),
|
| 1442 |
+
handle_error: (error2, request) => {
|
| 1443 |
+
hooks.handleError({ error: error2, request });
|
| 1444 |
+
error2.stack = this.options.get_stack(error2);
|
| 1445 |
+
},
|
| 1446 |
+
hooks,
|
| 1447 |
+
hydrate: true,
|
| 1448 |
+
manifest,
|
| 1449 |
+
paths: { base, assets },
|
| 1450 |
+
prefix: assets + "/_app/",
|
| 1451 |
+
prerender: true,
|
| 1452 |
+
read,
|
| 1453 |
+
root: Root,
|
| 1454 |
+
service_worker: null,
|
| 1455 |
+
router: true,
|
| 1456 |
+
ssr: true,
|
| 1457 |
+
target: "#svelte",
|
| 1458 |
+
template,
|
| 1459 |
+
trailing_slash: "never"
|
| 1460 |
+
};
|
| 1461 |
+
}
|
| 1462 |
+
render(request, {
|
| 1463 |
+
prerender
|
| 1464 |
+
} = {}) {
|
| 1465 |
+
if (Object.keys(request).sort().join() !== "headers,method,rawBody,url") {
|
| 1466 |
+
throw new Error("Adapters should call app.render({ url, method, headers, rawBody })");
|
| 1467 |
+
}
|
| 1468 |
+
const host = request.headers["host"];
|
| 1469 |
+
const protocol = default_protocol;
|
| 1470 |
+
return respond({ ...request, url: new URL(request.url, protocol + "://" + host) }, this.options, { prerender });
|
| 1471 |
+
}
|
| 1472 |
+
}
|
| 1473 |
+
export { App, override };
|
.svelte-kit/output/server/chunks/_api-cf43c630.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const base = "https://api.svelte.dev";
|
| 2 |
+
async function api(request, resource, data) {
|
| 3 |
+
if (!request.locals.userid) {
|
| 4 |
+
return { status: 401 };
|
| 5 |
+
}
|
| 6 |
+
const res = await fetch(`${base}/${resource}`, {
|
| 7 |
+
method: request.method,
|
| 8 |
+
headers: {
|
| 9 |
+
"content-type": "application/json"
|
| 10 |
+
},
|
| 11 |
+
body: data && JSON.stringify(data)
|
| 12 |
+
});
|
| 13 |
+
if (res.ok && request.method !== "GET" && request.headers.accept !== "application/json") {
|
| 14 |
+
return {
|
| 15 |
+
status: 303,
|
| 16 |
+
headers: {
|
| 17 |
+
location: "/todos"
|
| 18 |
+
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
function noop() {
|
| 2 |
+
}
|
| 3 |
+
function run(fn) {
|
| 4 |
+
return fn();
|
| 5 |
+
}
|
| 6 |
+
function blank_object() {
|
| 7 |
+
return Object.create(null);
|
| 8 |
+
}
|
| 9 |
+
function run_all(fns) {
|
| 10 |
+
fns.forEach(run);
|
| 11 |
+
}
|
| 12 |
+
function safe_not_equal(a, b) {
|
| 13 |
+
return a != a ? b == b : a !== b || (a && typeof a === "object" || typeof a === "function");
|
| 14 |
+
}
|
| 15 |
+
function subscribe(store, ...callbacks) {
|
| 16 |
+
if (store == null) {
|
| 17 |
+
return noop;
|
| 18 |
+
}
|
| 19 |
+
const unsub = store.subscribe(...callbacks);
|
| 20 |
+
return unsub.unsubscribe ? () => unsub.unsubscribe() : unsub;
|
| 21 |
+
}
|
| 22 |
+
const is_client = typeof window !== "undefined";
|
| 23 |
+
let now = is_client ? () => window.performance.now() : () => Date.now();
|
| 24 |
+
let raf = is_client ? (cb) => requestAnimationFrame(cb) : noop;
|
| 25 |
+
const tasks = new Set();
|
| 26 |
+
function run_tasks(now2) {
|
| 27 |
+
tasks.forEach((task) => {
|
| 28 |
+
if (!task.c(now2)) {
|
| 29 |
+
tasks.delete(task);
|
| 30 |
+
task.f();
|
| 31 |
+
}
|
| 32 |
+
});
|
| 33 |
+
if (tasks.size !== 0)
|
| 34 |
+
raf(run_tasks);
|
| 35 |
+
}
|
| 36 |
+
function loop(callback) {
|
| 37 |
+
let task;
|
| 38 |
+
if (tasks.size === 0)
|
| 39 |
+
raf(run_tasks);
|
| 40 |
+
return {
|
| 41 |
+
promise: new Promise((fulfill) => {
|
| 42 |
+
tasks.add(task = { c: callback, f: fulfill });
|
| 43 |
+
}),
|
| 44 |
+
abort() {
|
| 45 |
+
tasks.delete(task);
|
| 46 |
+
}
|
| 47 |
+
};
|
| 48 |
+
}
|
| 49 |
+
let current_component;
|
| 50 |
+
function set_current_component(component) {
|
| 51 |
+
current_component = component;
|
| 52 |
+
}
|
| 53 |
+
function get_current_component() {
|
| 54 |
+
if (!current_component)
|
| 55 |
+
throw new Error("Function called outside component initialization");
|
| 56 |
+
return current_component;
|
| 57 |
+
}
|
| 58 |
+
function setContext(key, context) {
|
| 59 |
+
get_current_component().$$.context.set(key, context);
|
| 60 |
+
}
|
| 61 |
+
function getContext(key) {
|
| 62 |
+
return get_current_component().$$.context.get(key);
|
| 63 |
+
}
|
| 64 |
+
Promise.resolve();
|
| 65 |
+
const boolean_attributes = new Set([
|
| 66 |
+
"allowfullscreen",
|
| 67 |
+
"allowpaymentrequest",
|
| 68 |
+
"async",
|
| 69 |
+
"autofocus",
|
| 70 |
+
"autoplay",
|
| 71 |
+
"checked",
|
| 72 |
+
"controls",
|
| 73 |
+
"default",
|
| 74 |
+
"defer",
|
| 75 |
+
"disabled",
|
| 76 |
+
"formnovalidate",
|
| 77 |
+
"hidden",
|
| 78 |
+
"ismap",
|
| 79 |
+
"loop",
|
| 80 |
+
"multiple",
|
| 81 |
+
"muted",
|
| 82 |
+
"nomodule",
|
| 83 |
+
"novalidate",
|
| 84 |
+
"open",
|
| 85 |
+
"playsinline",
|
| 86 |
+
"readonly",
|
| 87 |
+
"required",
|
| 88 |
+
"reversed",
|
| 89 |
+
"selected"
|
| 90 |
+
]);
|
| 91 |
+
const escaped = {
|
| 92 |
+
'"': """,
|
| 93 |
+
"'": "'",
|
| 94 |
+
"&": "&",
|
| 95 |
+
"<": "<",
|
| 96 |
+
">": ">"
|
| 97 |
+
};
|
| 98 |
+
function escape(html) {
|
| 99 |
+
return String(html).replace(/["'&<>]/g, (match) => escaped[match]);
|
| 100 |
+
}
|
| 101 |
+
function each(items, fn) {
|
| 102 |
+
let str = "";
|
| 103 |
+
for (let i = 0; i < items.length; i += 1) {
|
| 104 |
+
str += fn(items[i], i);
|
| 105 |
+
}
|
| 106 |
+
return str;
|
| 107 |
+
}
|
| 108 |
+
const missing_component = {
|
| 109 |
+
$$render: () => ""
|
| 110 |
+
};
|
| 111 |
+
function validate_component(component, name) {
|
| 112 |
+
if (!component || !component.$$render) {
|
| 113 |
+
if (name === "svelte:component")
|
| 114 |
+
name += " this={...}";
|
| 115 |
+
throw new Error(`<${name}> is not a valid SSR component. You may need to review your build config to ensure that dependencies are compiled, rather than imported as pre-compiled modules`);
|
| 116 |
+
}
|
| 117 |
+
return component;
|
| 118 |
+
}
|
| 119 |
+
let on_destroy;
|
| 120 |
+
function create_ssr_component(fn) {
|
| 121 |
+
function $$render(result, props, bindings, slots, context) {
|
| 122 |
+
const parent_component = current_component;
|
| 123 |
+
const $$ = {
|
| 124 |
+
on_destroy,
|
| 125 |
+
context: new Map(context || (parent_component ? parent_component.$$.context : [])),
|
| 126 |
+
on_mount: [],
|
| 127 |
+
before_update: [],
|
| 128 |
+
after_update: [],
|
| 129 |
+
callbacks: blank_object()
|
| 130 |
+
};
|
| 131 |
+
set_current_component({ $$ });
|
| 132 |
+
const html = fn(result, props, bindings, slots);
|
| 133 |
+
set_current_component(parent_component);
|
| 134 |
+
return html;
|
| 135 |
+
}
|
| 136 |
+
return {
|
| 137 |
+
render: (props = {}, { $$slots = {}, context = new Map() } = {}) => {
|
| 138 |
+
on_destroy = [];
|
| 139 |
+
const result = { title: "", head: "", css: new Set() };
|
| 140 |
+
const html = $$render(result, props, {}, $$slots, context);
|
| 141 |
+
run_all(on_destroy);
|
| 142 |
+
return {
|
| 143 |
+
html,
|
| 144 |
+
css: {
|
| 145 |
+
code: Array.from(result.css).map((css) => css.code).join("\n"),
|
| 146 |
+
map: null
|
| 147 |
+
},
|
| 148 |
+
head: result.title + result.head
|
| 149 |
+
};
|
| 150 |
+
},
|
| 151 |
+
$$render
|
| 152 |
+
};
|
| 153 |
+
}
|
| 154 |
+
function add_attribute(name, value, boolean) {
|
| 155 |
+
if (value == null || boolean && !value)
|
| 156 |
+
return "";
|
| 157 |
+
return ` ${name}${value === true && boolean_attributes.has(name) ? "" : `=${typeof value === "string" ? JSON.stringify(escape(value)) : `"${value}"`}`}`;
|
| 158 |
+
}
|
| 159 |
+
export { subscribe as a, add_attribute as b, create_ssr_component as c, safe_not_equal as d, escape as e, now as f, getContext as g, each as h, loop as l, missing_component as m, noop as n, setContext as s, validate_component as v };
|
.svelte-kit/output/server/entries/endpoints/todos/_uid_.json.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { a as api } from "../../../chunks/_api-cf43c630.js";
|
| 2 |
+
const patch = async (request) => {
|
| 3 |
+
return api(request, `todos/${request.locals.userid}/${request.params.uid}`, {
|
| 4 |
+
text: request.body.get("text"),
|
| 5 |
+
done: request.body.has("done") ? !!request.body.get("done") : void 0
|
| 6 |
+
});
|
| 7 |
+
};
|
| 8 |
+
const del = async (request) => {
|
| 9 |
+
return api(request, `todos/${request.locals.userid}/${request.params.uid}`);
|
| 10 |
+
};
|
| 11 |
+
export { del, patch };
|
.svelte-kit/output/server/entries/endpoints/todos/index.json.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { a as api } from "../../../chunks/_api-cf43c630.js";
|
| 2 |
+
const get = async (request) => {
|
| 3 |
+
const response = await api(request, `todos/${request.locals.userid}`);
|
| 4 |
+
if (response.status === 404) {
|
| 5 |
+
return { body: [] };
|
| 6 |
+
}
|
| 7 |
+
return response;
|
| 8 |
+
};
|
| 9 |
+
const post = async (request) => {
|
| 10 |
+
const response = await api(request, `todos/${request.locals.userid}`, {
|
| 11 |
+
text: request.body.get("text")
|
| 12 |
+
});
|
| 13 |
+
return response;
|
| 14 |
+
};
|
| 15 |
+
export { get, post };
|
.svelte-kit/output/server/entries/pages/__layout.svelte.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { g as getContext, c as create_ssr_component, a as subscribe, b as add_attribute, v as validate_component } from "../../chunks/index-c7a03ab5.js";
|
| 2 |
+
const getStores = () => {
|
| 3 |
+
const stores = getContext("__svelte__");
|
| 4 |
+
return {
|
| 5 |
+
page: {
|
| 6 |
+
subscribe: stores.page.subscribe
|
| 7 |
+
},
|
| 8 |
+
navigating: {
|
| 9 |
+
subscribe: stores.navigating.subscribe
|
| 10 |
+
},
|
| 11 |
+
get preloading() {
|
| 12 |
+
console.error("stores.preloading is deprecated; use stores.navigating instead");
|
| 13 |
+
return {
|
| 14 |
+
subscribe: stores.navigating.subscribe
|
| 15 |
+
};
|
| 16 |
+
},
|
| 17 |
+
session: stores.session
|
| 18 |
+
};
|
| 19 |
+
};
|
| 20 |
+
const page = {
|
| 21 |
+
subscribe(fn) {
|
| 22 |
+
const store = getStores().page;
|
| 23 |
+
return store.subscribe(fn);
|
| 24 |
+
}
|
| 25 |
+
};
|
| 26 |
+
var logo = "/staticspaceiframe/spaces/pngwn/static-test/_app/assets/svelte-logo-87df40b8.svg";
|
| 27 |
+
var Header_svelte_svelte_type_style_lang = "";
|
| 28 |
+
const css$1 = {
|
| 29 |
+
code: "header.svelte-t2wq17.svelte-t2wq17{display:flex;justify-content:space-between}.corner.svelte-t2wq17.svelte-t2wq17{width:3em;height:3em}.corner.svelte-t2wq17 a.svelte-t2wq17{display:flex;align-items:center;justify-content:center;width:100%;height:100%}.corner.svelte-t2wq17 img.svelte-t2wq17{width:2em;height:2em;object-fit:contain}nav.svelte-t2wq17.svelte-t2wq17{display:flex;justify-content:center;--background:rgba(255, 255, 255, 0.7)}svg.svelte-t2wq17.svelte-t2wq17{width:2em;height:3em;display:block}path.svelte-t2wq17.svelte-t2wq17{fill:var(--background)}ul.svelte-t2wq17.svelte-t2wq17{position:relative;padding:0;margin:0;height:3em;display:flex;justify-content:center;align-items:center;list-style:none;background:var(--background);background-size:contain}li.svelte-t2wq17.svelte-t2wq17{position:relative;height:100%}li.active.svelte-t2wq17.svelte-t2wq17::before{--size:6px;content:'';width:0;height:0;position:absolute;top:0;left:calc(50% - var(--size));border:var(--size) solid transparent;border-top:var(--size) solid var(--accent-color)}nav.svelte-t2wq17 a.svelte-t2wq17{display:flex;height:100%;align-items:center;padding:0 1em;color:var(--heading-color);font-weight:700;font-size:0.8rem;text-transform:uppercase;letter-spacing:0.1em;text-decoration:none;transition:color 0.2s linear}a.svelte-t2wq17.svelte-t2wq17:hover{color:var(--accent-color)}",
|
| 30 |
+
map: null
|
| 31 |
+
};
|
| 32 |
+
const Header = create_ssr_component(($$result, $$props, $$bindings, slots) => {
|
| 33 |
+
let $page, $$unsubscribe_page;
|
| 34 |
+
$$unsubscribe_page = subscribe(page, (value) => $page = value);
|
| 35 |
+
$$result.css.add(css$1);
|
| 36 |
+
$$unsubscribe_page();
|
| 37 |
+
return `<header class="${"svelte-t2wq17"}"><div class="${"corner svelte-t2wq17"}"><a href="${"https://kit.svelte.dev"}" class="${"svelte-t2wq17"}"><img${add_attribute("src", logo, 0)} alt="${"SvelteKit"}" class="${"svelte-t2wq17"}"></a></div>
|
| 38 |
+
|
| 39 |
+
<nav class="${"svelte-t2wq17"}"><svg viewBox="${"0 0 2 3"}" aria-hidden="${"true"}" class="${"svelte-t2wq17"}"><path d="${"M0,0 L1,2 C1.5,3 1.5,3 2,3 L2,0 Z"}" class="${"svelte-t2wq17"}"></path></svg>
|
| 40 |
+
<ul class="${"svelte-t2wq17"}"><li class="${["svelte-t2wq17", $page.url.pathname === "/" ? "active" : ""].join(" ").trim()}"><a sveltekit:prefetch href="${"/"}" class="${"svelte-t2wq17"}">Home</a></li>
|
| 41 |
+
<li class="${["svelte-t2wq17", $page.url.pathname === "/about" ? "active" : ""].join(" ").trim()}"><a sveltekit:prefetch href="${"/about"}" class="${"svelte-t2wq17"}">About</a></li>
|
| 42 |
+
<li class="${["svelte-t2wq17", $page.url.pathname === "/todos" ? "active" : ""].join(" ").trim()}"><a sveltekit:prefetch href="${"/todos"}" class="${"svelte-t2wq17"}">Todos</a></li></ul>
|
| 43 |
+
<svg viewBox="${"0 0 2 3"}" aria-hidden="${"true"}" class="${"svelte-t2wq17"}"><path d="${"M0,0 L0,3 C0.5,3 0.5,3 1,2 L2,0 Z"}" class="${"svelte-t2wq17"}"></path></svg></nav>
|
| 44 |
+
|
| 45 |
+
<div class="${"corner svelte-t2wq17"}"></div>
|
| 46 |
+
</header>`;
|
| 47 |
+
});
|
| 48 |
+
var app = "";
|
| 49 |
+
var __layout_svelte_svelte_type_style_lang = "";
|
| 50 |
+
const css = {
|
| 51 |
+
code: "main.svelte-1izrdc8.svelte-1izrdc8{flex:1;display:flex;flex-direction:column;padding:1rem;width:100%;max-width:1024px;margin:0 auto;box-sizing:border-box}footer.svelte-1izrdc8.svelte-1izrdc8{display:flex;flex-direction:column;justify-content:center;align-items:center;padding:40px}footer.svelte-1izrdc8 a.svelte-1izrdc8{font-weight:bold}@media(min-width: 480px){footer.svelte-1izrdc8.svelte-1izrdc8{padding:40px 0}}",
|
| 52 |
+
map: null
|
| 53 |
+
};
|
| 54 |
+
const _layout = create_ssr_component(($$result, $$props, $$bindings, slots) => {
|
| 55 |
+
$$result.css.add(css);
|
| 56 |
+
return `${validate_component(Header, "Header").$$render($$result, {}, {}, {})}
|
| 57 |
+
|
| 58 |
+
<main class="${"svelte-1izrdc8"}">${slots.default ? slots.default({}) : ``}</main>
|
| 59 |
+
|
| 60 |
+
<footer class="${"svelte-1izrdc8"}"><p>visit <a href="${"https://kit.svelte.dev"}" class="${"svelte-1izrdc8"}">kit.svelte.dev</a> to learn SvelteKit</p>
|
| 61 |
+
</footer>`;
|
| 62 |
+
});
|
| 63 |
+
export { _layout as default };
|
.svelte-kit/output/server/entries/pages/about.svelte.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { c as create_ssr_component } from "../../chunks/index-c7a03ab5.js";
|
| 2 |
+
const browser = false;
|
| 3 |
+
const dev = false;
|
| 4 |
+
var about_svelte_svelte_type_style_lang = "";
|
| 5 |
+
const css = {
|
| 6 |
+
code: ".content.svelte-cf77e8{width:100%;max-width:var(--column-width);margin:var(--column-margin-top) auto 0 auto}",
|
| 7 |
+
map: null
|
| 8 |
+
};
|
| 9 |
+
const hydrate = dev;
|
| 10 |
+
const router = browser;
|
| 11 |
+
const prerender = true;
|
| 12 |
+
const About = create_ssr_component(($$result, $$props, $$bindings, slots) => {
|
| 13 |
+
$$result.css.add(css);
|
| 14 |
+
return `${$$result.head += `${$$result.title = `<title>About</title>`, ""}`, ""}
|
| 15 |
+
|
| 16 |
+
<div class="${"content svelte-cf77e8"}"><h1>About this app</h1>
|
| 17 |
+
|
| 18 |
+
<p>This is a <a href="${"https://kit.svelte.dev"}">SvelteKit</a> app. You can make your own by typing the
|
| 19 |
+
following into your command line and following the prompts:
|
| 20 |
+
</p>
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
<pre>npm init svelte@next</pre>
|
| 24 |
+
|
| 25 |
+
<p>The page you're looking at is purely static HTML, with no client-side interactivity needed.
|
| 26 |
+
Because of that, we don't need to load any JavaScript. Try viewing the page's source, or opening
|
| 27 |
+
the devtools network panel and reloading.
|
| 28 |
+
</p>
|
| 29 |
+
|
| 30 |
+
<p>The <a href="${"/todos"}">TODOs</a> page illustrates SvelteKit's data loading and form handling. Try using
|
| 31 |
+
it with JavaScript disabled!
|
| 32 |
+
</p>
|
| 33 |
+
</div>`;
|
| 34 |
+
});
|
| 35 |
+
export { About as default, hydrate, prerender, router };
|
.svelte-kit/output/server/entries/pages/error.svelte.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { c as create_ssr_component, e as escape } from "../../chunks/index-c7a03ab5.js";
|
| 2 |
+
function load({ error, status }) {
|
| 3 |
+
return { props: { error, status } };
|
| 4 |
+
}
|
| 5 |
+
const Error = create_ssr_component(($$result, $$props, $$bindings, slots) => {
|
| 6 |
+
let { status } = $$props;
|
| 7 |
+
let { error } = $$props;
|
| 8 |
+
if ($$props.status === void 0 && $$bindings.status && status !== void 0)
|
| 9 |
+
$$bindings.status(status);
|
| 10 |
+
if ($$props.error === void 0 && $$bindings.error && error !== void 0)
|
| 11 |
+
$$bindings.error(error);
|
| 12 |
+
return `<h1>${escape(status)}</h1>
|
| 13 |
+
|
| 14 |
+
<pre>${escape(error.message)}</pre>
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
${error.frame ? `<pre>${escape(error.frame)}</pre>` : ``}
|
| 19 |
+
${error.stack ? `<pre>${escape(error.stack)}</pre>` : ``}`;
|
| 20 |
+
});
|
| 21 |
+
export { Error as default, load };
|
.svelte-kit/output/server/entries/pages/index.svelte.js
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { n as noop, d as safe_not_equal, f as now, l as loop, c as create_ssr_component, a as subscribe, e as escape, v as validate_component } from "../../chunks/index-c7a03ab5.js";
|
| 2 |
+
const subscriber_queue = [];
|
| 3 |
+
function writable(value, start = noop) {
|
| 4 |
+
let stop;
|
| 5 |
+
const subscribers = new Set();
|
| 6 |
+
function set(new_value) {
|
| 7 |
+
if (safe_not_equal(value, new_value)) {
|
| 8 |
+
value = new_value;
|
| 9 |
+
if (stop) {
|
| 10 |
+
const run_queue = !subscriber_queue.length;
|
| 11 |
+
for (const subscriber of subscribers) {
|
| 12 |
+
subscriber[1]();
|
| 13 |
+
subscriber_queue.push(subscriber, value);
|
| 14 |
+
}
|
| 15 |
+
if (run_queue) {
|
| 16 |
+
for (let i = 0; i < subscriber_queue.length; i += 2) {
|
| 17 |
+
subscriber_queue[i][0](subscriber_queue[i + 1]);
|
| 18 |
+
}
|
| 19 |
+
subscriber_queue.length = 0;
|
| 20 |
+
}
|
| 21 |
+
}
|
| 22 |
+
}
|
| 23 |
+
}
|
| 24 |
+
function update(fn) {
|
| 25 |
+
set(fn(value));
|
| 26 |
+
}
|
| 27 |
+
function subscribe2(run, invalidate = noop) {
|
| 28 |
+
const subscriber = [run, invalidate];
|
| 29 |
+
subscribers.add(subscriber);
|
| 30 |
+
if (subscribers.size === 1) {
|
| 31 |
+
stop = start(set) || noop;
|
| 32 |
+
}
|
| 33 |
+
run(value);
|
| 34 |
+
return () => {
|
| 35 |
+
subscribers.delete(subscriber);
|
| 36 |
+
if (subscribers.size === 0) {
|
| 37 |
+
stop();
|
| 38 |
+
stop = null;
|
| 39 |
+
}
|
| 40 |
+
};
|
| 41 |
+
}
|
| 42 |
+
return { set, update, subscribe: subscribe2 };
|
| 43 |
+
}
|
| 44 |
+
function is_date(obj) {
|
| 45 |
+
return Object.prototype.toString.call(obj) === "[object Date]";
|
| 46 |
+
}
|
| 47 |
+
function tick_spring(ctx, last_value, current_value, target_value) {
|
| 48 |
+
if (typeof current_value === "number" || is_date(current_value)) {
|
| 49 |
+
const delta = target_value - current_value;
|
| 50 |
+
const velocity = (current_value - last_value) / (ctx.dt || 1 / 60);
|
| 51 |
+
const spring2 = ctx.opts.stiffness * delta;
|
| 52 |
+
const damper = ctx.opts.damping * velocity;
|
| 53 |
+
const acceleration = (spring2 - damper) * ctx.inv_mass;
|
| 54 |
+
const d = (velocity + acceleration) * ctx.dt;
|
| 55 |
+
if (Math.abs(d) < ctx.opts.precision && Math.abs(delta) < ctx.opts.precision) {
|
| 56 |
+
return target_value;
|
| 57 |
+
} else {
|
| 58 |
+
ctx.settled = false;
|
| 59 |
+
return is_date(current_value) ? new Date(current_value.getTime() + d) : current_value + d;
|
| 60 |
+
}
|
| 61 |
+
} else if (Array.isArray(current_value)) {
|
| 62 |
+
return current_value.map((_, i) => tick_spring(ctx, last_value[i], current_value[i], target_value[i]));
|
| 63 |
+
} else if (typeof current_value === "object") {
|
| 64 |
+
const next_value = {};
|
| 65 |
+
for (const k in current_value) {
|
| 66 |
+
next_value[k] = tick_spring(ctx, last_value[k], current_value[k], target_value[k]);
|
| 67 |
+
}
|
| 68 |
+
return next_value;
|
| 69 |
+
} else {
|
| 70 |
+
throw new Error(`Cannot spring ${typeof current_value} values`);
|
| 71 |
+
}
|
| 72 |
+
}
|
| 73 |
+
function spring(value, opts = {}) {
|
| 74 |
+
const store = writable(value);
|
| 75 |
+
const { stiffness = 0.15, damping = 0.8, precision = 0.01 } = opts;
|
| 76 |
+
let last_time;
|
| 77 |
+
let task;
|
| 78 |
+
let current_token;
|
| 79 |
+
let last_value = value;
|
| 80 |
+
let target_value = value;
|
| 81 |
+
let inv_mass = 1;
|
| 82 |
+
let inv_mass_recovery_rate = 0;
|
| 83 |
+
let cancel_task = false;
|
| 84 |
+
function set(new_value, opts2 = {}) {
|
| 85 |
+
target_value = new_value;
|
| 86 |
+
const token = current_token = {};
|
| 87 |
+
if (value == null || opts2.hard || spring2.stiffness >= 1 && spring2.damping >= 1) {
|
| 88 |
+
cancel_task = true;
|
| 89 |
+
last_time = now();
|
| 90 |
+
last_value = new_value;
|
| 91 |
+
store.set(value = target_value);
|
| 92 |
+
return Promise.resolve();
|
| 93 |
+
} else if (opts2.soft) {
|
| 94 |
+
const rate = opts2.soft === true ? 0.5 : +opts2.soft;
|
| 95 |
+
inv_mass_recovery_rate = 1 / (rate * 60);
|
| 96 |
+
inv_mass = 0;
|
| 97 |
+
}
|
| 98 |
+
if (!task) {
|
| 99 |
+
last_time = now();
|
| 100 |
+
cancel_task = false;
|
| 101 |
+
task = loop((now2) => {
|
| 102 |
+
if (cancel_task) {
|
| 103 |
+
cancel_task = false;
|
| 104 |
+
task = null;
|
| 105 |
+
return false;
|
| 106 |
+
}
|
| 107 |
+
inv_mass = Math.min(inv_mass + inv_mass_recovery_rate, 1);
|
| 108 |
+
const ctx = {
|
| 109 |
+
inv_mass,
|
| 110 |
+
opts: spring2,
|
| 111 |
+
settled: true,
|
| 112 |
+
dt: (now2 - last_time) * 60 / 1e3
|
| 113 |
+
};
|
| 114 |
+
const next_value = tick_spring(ctx, last_value, value, target_value);
|
| 115 |
+
last_time = now2;
|
| 116 |
+
last_value = value;
|
| 117 |
+
store.set(value = next_value);
|
| 118 |
+
if (ctx.settled) {
|
| 119 |
+
task = null;
|
| 120 |
+
}
|
| 121 |
+
return !ctx.settled;
|
| 122 |
+
});
|
| 123 |
+
}
|
| 124 |
+
return new Promise((fulfil) => {
|
| 125 |
+
task.promise.then(() => {
|
| 126 |
+
if (token === current_token)
|
| 127 |
+
fulfil();
|
| 128 |
+
});
|
| 129 |
+
});
|
| 130 |
+
}
|
| 131 |
+
const spring2 = {
|
| 132 |
+
set,
|
| 133 |
+
update: (fn, opts2) => set(fn(target_value, value), opts2),
|
| 134 |
+
subscribe: store.subscribe,
|
| 135 |
+
stiffness,
|
| 136 |
+
damping,
|
| 137 |
+
precision
|
| 138 |
+
};
|
| 139 |
+
return spring2;
|
| 140 |
+
}
|
| 141 |
+
var Counter_svelte_svelte_type_style_lang = "";
|
| 142 |
+
const css$1 = {
|
| 143 |
+
code: ".counter.svelte-139m1ow.svelte-139m1ow{display:flex;border-top:1px solid rgba(0, 0, 0, 0.1);border-bottom:1px solid rgba(0, 0, 0, 0.1);margin:1rem 0}.counter.svelte-139m1ow button.svelte-139m1ow{width:2em;padding:0;display:flex;align-items:center;justify-content:center;border:0;background-color:transparent;color:var(--text-color);font-size:2rem}.counter.svelte-139m1ow button.svelte-139m1ow:hover{background-color:var(--secondary-color)}svg.svelte-139m1ow.svelte-139m1ow{width:25%;height:25%}path.svelte-139m1ow.svelte-139m1ow{vector-effect:non-scaling-stroke;stroke-width:2px;stroke:var(--text-color)}.counter-viewport.svelte-139m1ow.svelte-139m1ow{width:8em;height:4em;overflow:hidden;text-align:center;position:relative}.counter-viewport.svelte-139m1ow strong.svelte-139m1ow{position:absolute;display:flex;width:100%;height:100%;font-weight:400;color:var(--accent-color);font-size:4rem;align-items:center;justify-content:center}.counter-digits.svelte-139m1ow.svelte-139m1ow{position:absolute;width:100%;height:100%}",
|
| 144 |
+
map: null
|
| 145 |
+
};
|
| 146 |
+
function modulo(n, m) {
|
| 147 |
+
return (n % m + m) % m;
|
| 148 |
+
}
|
| 149 |
+
const Counter = create_ssr_component(($$result, $$props, $$bindings, slots) => {
|
| 150 |
+
let offset;
|
| 151 |
+
let $displayed_count, $$unsubscribe_displayed_count;
|
| 152 |
+
let count = 0;
|
| 153 |
+
const displayed_count = spring();
|
| 154 |
+
$$unsubscribe_displayed_count = subscribe(displayed_count, (value) => $displayed_count = value);
|
| 155 |
+
$$result.css.add(css$1);
|
| 156 |
+
{
|
| 157 |
+
displayed_count.set(count);
|
| 158 |
+
}
|
| 159 |
+
offset = modulo($displayed_count, 1);
|
| 160 |
+
$$unsubscribe_displayed_count();
|
| 161 |
+
return `<div class="${"counter svelte-139m1ow"}"><button aria-label="${"Decrease the counter by one"}" class="${"svelte-139m1ow"}"><svg aria-hidden="${"true"}" viewBox="${"0 0 1 1"}" class="${"svelte-139m1ow"}"><path d="${"M0,0.5 L1,0.5"}" class="${"svelte-139m1ow"}"></path></svg></button>
|
| 162 |
+
|
| 163 |
+
<div class="${"counter-viewport svelte-139m1ow"}"><div class="${"counter-digits svelte-139m1ow"}" style="${"transform: translate(0, " + escape(100 * offset) + "%)"}"><strong style="${"top: -100%"}" aria-hidden="${"true"}" class="${"svelte-139m1ow"}">${escape(Math.floor($displayed_count + 1))}</strong>
|
| 164 |
+
<strong class="${"svelte-139m1ow"}">${escape(Math.floor($displayed_count))}</strong></div></div>
|
| 165 |
+
|
| 166 |
+
<button aria-label="${"Increase the counter by one"}" class="${"svelte-139m1ow"}"><svg aria-hidden="${"true"}" viewBox="${"0 0 1 1"}" class="${"svelte-139m1ow"}"><path d="${"M0,0.5 L1,0.5 M0.5,0 L0.5,1"}" class="${"svelte-139m1ow"}"></path></svg></button>
|
| 167 |
+
</div>`;
|
| 168 |
+
});
|
| 169 |
+
var index_svelte_svelte_type_style_lang = "";
|
| 170 |
+
const css = {
|
| 171 |
+
code: "section.svelte-mjk9ig.svelte-mjk9ig{display:flex;flex-direction:column;justify-content:center;align-items:center;flex:1}h1.svelte-mjk9ig.svelte-mjk9ig{width:100%}.welcome.svelte-mjk9ig.svelte-mjk9ig{position:relative;width:100%;height:0;padding:0 0 calc(100% * 495 / 2048) 0}.welcome.svelte-mjk9ig img.svelte-mjk9ig{position:absolute;width:100%;height:100%;top:0;display:block}",
|
| 172 |
+
map: null
|
| 173 |
+
};
|
| 174 |
+
const prerender = true;
|
| 175 |
+
const Routes = create_ssr_component(($$result, $$props, $$bindings, slots) => {
|
| 176 |
+
$$result.css.add(css);
|
| 177 |
+
return `${$$result.head += `${$$result.title = `<title>Home</title>`, ""}`, ""}
|
| 178 |
+
|
| 179 |
+
<section class="${"svelte-mjk9ig"}"><h1 class="${"svelte-mjk9ig"}"><div class="${"welcome svelte-mjk9ig"}"><picture><source srcset="${"svelte-welcome.webp"}" type="${"image/webp"}">
|
| 180 |
+
<img src="${"svelte-welcome.png"}" alt="${"Welcome"}" class="${"svelte-mjk9ig"}"></picture></div>
|
| 181 |
+
|
| 182 |
+
to your new<br>SvelteKit app
|
| 183 |
+
</h1>
|
| 184 |
+
|
| 185 |
+
<h2>try editing <strong>src/routes/index.svelte</strong></h2>
|
| 186 |
+
|
| 187 |
+
${validate_component(Counter, "Counter").$$render($$result, {}, {}, {})}
|
| 188 |
+
</section>`;
|
| 189 |
+
});
|
| 190 |
+
export { Routes as default, prerender };
|
.svelte-kit/output/server/entries/pages/todos/index.svelte.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { c as create_ssr_component, h as each, e as escape, b as add_attribute } from "../../../chunks/index-c7a03ab5.js";
|
| 2 |
+
var index_svelte_svelte_type_style_lang = "";
|
| 3 |
+
const css = {
|
| 4 |
+
code: `.todos.svelte-dmxqmd.svelte-dmxqmd.svelte-dmxqmd{width:100%;max-width:var(--column-width);margin:var(--column-margin-top) auto 0 auto;line-height:1}.new.svelte-dmxqmd.svelte-dmxqmd.svelte-dmxqmd{margin:0 0 0.5rem 0}input.svelte-dmxqmd.svelte-dmxqmd.svelte-dmxqmd{border:1px solid transparent}input.svelte-dmxqmd.svelte-dmxqmd.svelte-dmxqmd:focus-visible{box-shadow:inset 1px 1px 6px rgba(0, 0, 0, 0.1);border:1px solid #ff3e00 !important;outline:none}.new.svelte-dmxqmd input.svelte-dmxqmd.svelte-dmxqmd{font-size:28px;width:100%;padding:0.5em 1em 0.3em 1em;box-sizing:border-box;background:rgba(255, 255, 255, 0.05);border-radius:8px;text-align:center}.todo.svelte-dmxqmd.svelte-dmxqmd.svelte-dmxqmd{display:grid;grid-template-columns:2rem 1fr 2rem;grid-gap:0.5rem;align-items:center;margin:0 0 0.5rem 0;padding:0.5rem;background-color:white;border-radius:8px;filter:drop-shadow(2px 4px 6px rgba(0, 0, 0, 0.1));transform:translate(-1px, -1px);transition:filter 0.2s, transform 0.2s}.done.svelte-dmxqmd.svelte-dmxqmd.svelte-dmxqmd{transform:none;opacity:0.4;filter:drop-shadow(0px 0px 1px rgba(0, 0, 0, 0.1))}form.text.svelte-dmxqmd.svelte-dmxqmd.svelte-dmxqmd{position:relative;display:flex;align-items:center;flex:1}.todo.svelte-dmxqmd input.svelte-dmxqmd.svelte-dmxqmd{flex:1;padding:0.5em 2em 0.5em 0.8em;border-radius:3px}.todo.svelte-dmxqmd button.svelte-dmxqmd.svelte-dmxqmd{width:2em;height:2em;border:none;background-color:transparent;background-position:50% 50%;background-repeat:no-repeat}button.toggle.svelte-dmxqmd.svelte-dmxqmd.svelte-dmxqmd{border:1px solid rgba(0, 0, 0, 0.2);border-radius:50%;box-sizing:border-box;background-size:1em auto}.done.svelte-dmxqmd .toggle.svelte-dmxqmd.svelte-dmxqmd{background-image:url("data:image/svg+xml,%3Csvg width='22' height='16' viewBox='0 0 22 16' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M20.5 1.5L7.4375 14.5L1.5 8.5909' stroke='%23676778' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")}.delete.svelte-dmxqmd.svelte-dmxqmd.svelte-dmxqmd{background-image:url("data:image/svg+xml,%3Csvg width='24' height='24' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4.5 5V22H19.5V5H4.5Z' fill='%23676778' stroke='%23676778' stroke-width='1.5' stroke-linejoin='round'/%3E%3Cpath d='M10 10V16.5' stroke='white' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3Cpath d='M14 10V16.5' stroke='white' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3Cpath d='M2 5H22' stroke='%23676778' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3Cpath d='M8 5L9.6445 2H14.3885L16 5H8Z' fill='%23676778' stroke='%23676778' stroke-width='1.5' stroke-linejoin='round'/%3E%3C/svg%3E%0A");opacity:0.2}.delete.svelte-dmxqmd.svelte-dmxqmd.svelte-dmxqmd:hover,.delete.svelte-dmxqmd.svelte-dmxqmd.svelte-dmxqmd:focus{transition:opacity 0.2s;opacity:1}.save.svelte-dmxqmd.svelte-dmxqmd.svelte-dmxqmd{position:absolute;right:0;opacity:0;background-image:url("data:image/svg+xml,%3Csvg width='24' height='24' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M20.5 2H3.5C2.67158 2 2 2.67157 2 3.5V20.5C2 21.3284 2.67158 22 3.5 22H20.5C21.3284 22 22 21.3284 22 20.5V3.5C22 2.67157 21.3284 2 20.5 2Z' fill='%23676778' stroke='%23676778' stroke-width='1.5' stroke-linejoin='round'/%3E%3Cpath d='M17 2V11H7.5V2H17Z' fill='white' stroke='white' stroke-width='1.5' stroke-linejoin='round'/%3E%3Cpath d='M13.5 5.5V7.5' stroke='%23676778' stroke-width='1.5' stroke-linecap='round'/%3E%3Cpath d='M5.99844 2H18.4992' stroke='%23676778' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E%0A")}.todo.svelte-dmxqmd input.svelte-dmxqmd:focus+.save.svelte-dmxqmd,.save.svelte-dmxqmd.svelte-dmxqmd.svelte-dmxqmd:focus{transition:opacity 0.2s;opacity:1}`,
|
| 5 |
+
map: null
|
| 6 |
+
};
|
| 7 |
+
const load = async ({ fetch }) => {
|
| 8 |
+
const res = await fetch("/todos.json");
|
| 9 |
+
if (res.ok) {
|
| 10 |
+
const todos = await res.json();
|
| 11 |
+
return { props: { todos } };
|
| 12 |
+
}
|
| 13 |
+
const { message } = await res.json();
|
| 14 |
+
return { error: new Error(message) };
|
| 15 |
+
};
|
| 16 |
+
const Todos = create_ssr_component(($$result, $$props, $$bindings, slots) => {
|
| 17 |
+
let { todos } = $$props;
|
| 18 |
+
if ($$props.todos === void 0 && $$bindings.todos && todos !== void 0)
|
| 19 |
+
$$bindings.todos(todos);
|
| 20 |
+
$$result.css.add(css);
|
| 21 |
+
return `${$$result.head += `${$$result.title = `<title>Todos</title>`, ""}`, ""}
|
| 22 |
+
|
| 23 |
+
<div class="${"todos svelte-dmxqmd"}"><h1>Todos</h1>
|
| 24 |
+
|
| 25 |
+
<form class="${"new svelte-dmxqmd"}" action="${"/todos.json"}" method="${"post"}"><input name="${"text"}" aria-label="${"Add todo"}" placeholder="${"+ tap to add a todo"}" class="${"svelte-dmxqmd"}"></form>
|
| 26 |
+
|
| 27 |
+
${each(todos, (todo) => `<div class="${["todo svelte-dmxqmd", todo.done ? "done" : ""].join(" ").trim()}"><form action="${"/todos/" + escape(todo.uid) + ".json?_method=patch"}" method="${"post"}"><input type="${"hidden"}" name="${"done"}"${add_attribute("value", todo.done ? "" : "true", 0)} class="${"svelte-dmxqmd"}">
|
| 28 |
+
<button class="${"toggle svelte-dmxqmd"}" aria-label="${"Mark todo as " + escape(todo.done ? "not done" : "done")}"></button></form>
|
| 29 |
+
|
| 30 |
+
<form class="${"text svelte-dmxqmd"}" action="${"/todos/" + escape(todo.uid) + ".json?_method=patch"}" method="${"post"}"><input aria-label="${"Edit todo"}" type="${"text"}" name="${"text"}"${add_attribute("value", todo.text, 0)} class="${"svelte-dmxqmd"}">
|
| 31 |
+
<button class="${"save svelte-dmxqmd"}" aria-label="${"Save todo"}"></button></form>
|
| 32 |
+
|
| 33 |
+
<form action="${"/todos/" + escape(todo.uid) + ".json?_method=delete"}" method="${"post"}"><button class="${"delete svelte-dmxqmd"}" aria-label="${"Delete todo"}" ${todo.pending_delete ? "disabled" : ""}></button></form>
|
| 34 |
+
</div>`)}
|
| 35 |
+
</div>`;
|
| 36 |
+
});
|
| 37 |
+
export { Todos as default, load };
|
.svelte-kit/output/server/manifest.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export const manifest = {
|
| 2 |
+
appDir: "_app",
|
| 3 |
+
assets: new Set(["favicon.png","robots.txt","svelte-welcome.png","svelte-welcome.webp"]),
|
| 4 |
+
_: {
|
| 5 |
+
mime: {".png":"image/png",".txt":"text/plain",".webp":"image/webp"},
|
| 6 |
+
entry: {"file":"start-2ccc875c.js","js":["start-2ccc875c.js","chunks/vendor-d68c61c2.js"],"css":["assets/start-61d1577b.css"]},
|
| 7 |
+
nodes: [
|
| 8 |
+
() => import('./nodes/0.js'),
|
| 9 |
+
() => import('./nodes/1.js'),
|
| 10 |
+
() => import('./nodes/2.js'),
|
| 11 |
+
() => import('./nodes/3.js'),
|
| 12 |
+
() => import('./nodes/4.js')
|
| 13 |
+
],
|
| 14 |
+
routes: [
|
| 15 |
+
{
|
| 16 |
+
type: 'page',
|
| 17 |
+
pattern: /^\/$/,
|
| 18 |
+
params: null,
|
| 19 |
+
path: "/",
|
| 20 |
+
a: [0,2],
|
| 21 |
+
b: [1]
|
| 22 |
+
},
|
| 23 |
+
{
|
| 24 |
+
type: 'page',
|
| 25 |
+
pattern: /^\/about\/?$/,
|
| 26 |
+
params: null,
|
| 27 |
+
path: "/about",
|
| 28 |
+
a: [0,3],
|
| 29 |
+
b: [1]
|
| 30 |
+
},
|
| 31 |
+
{
|
| 32 |
+
type: 'endpoint',
|
| 33 |
+
pattern: /^\/todos\.json$/,
|
| 34 |
+
params: null,
|
| 35 |
+
load: () => import('./entries/endpoints/todos/index.json.js')
|
| 36 |
+
},
|
| 37 |
+
{
|
| 38 |
+
type: 'page',
|
| 39 |
+
pattern: /^\/todos\/?$/,
|
| 40 |
+
params: null,
|
| 41 |
+
path: "/todos",
|
| 42 |
+
a: [0,4],
|
| 43 |
+
b: [1]
|
| 44 |
+
},
|
| 45 |
+
{
|
| 46 |
+
type: 'endpoint',
|
| 47 |
+
pattern: /^\/todos\/([^/]+?)\.json$/,
|
| 48 |
+
params: (m) => ({ uid: m[1]}),
|
| 49 |
+
load: () => import('./entries/endpoints/todos/_uid_.json.js')
|
| 50 |
+
}
|
| 51 |
+
]
|
| 52 |
+
}
|
| 53 |
+
};
|