-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cbc3c0c
commit 0d67cfb
Showing
23 changed files
with
1,904 additions
and
363 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<script context="module"> | ||
/** @type {import('@sveltejs/kit').ErrorLoad} */ | ||
export function load({ error, status }) { | ||
return { | ||
props: { error, status }, | ||
}; | ||
} | ||
</script> | ||
|
||
<script> | ||
/** @type {number} */ | ||
export let status; | ||
/** @type {Error} */ | ||
export let error; | ||
</script> | ||
|
||
<h1>{status}</h1> | ||
|
||
<p>{error.message}</p> | ||
|
||
<!-- TODO figure out what to do with stacktraces in prod --> | ||
{#if error.stack} | ||
<pre>{error.stack}</pre> | ||
{/if} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<slot /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
const c = [ | ||
() => import('../components/layout.svelte'), | ||
() => import('../components/error.svelte'), | ||
() => import('../../../pages/index.svelte'), | ||
() => import('../../../pages/embed-previewer/index.svelte'), | ||
() => import('../../../pages/embeds/en/chart.svelte'), | ||
() => import('../../../pages/embeds/en/page.svelte'), | ||
]; | ||
|
||
const d = decodeURIComponent; | ||
|
||
export const routes = [ | ||
// pages/index.svelte | ||
[/^\/$/, [c[0], c[2]], [c[1]]], | ||
|
||
// pages/embed-previewer/index.svelte | ||
[/^\/embed-previewer\/?$/, [c[0], c[3]], [c[1]]], | ||
|
||
// pages/embeds/en/chart.svelte | ||
[/^\/embeds\/en\/chart\/?$/, [c[0], c[4]], [c[1]]], | ||
|
||
// pages/embeds/en/page.svelte | ||
[/^\/embeds\/en\/page\/?$/, [c[0], c[5]], [c[1]]], | ||
]; | ||
|
||
export const fallback = [c[0](), c[1]()]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<!-- This file is generated by @sveltejs/kit — do not edit it! --> | ||
<script> | ||
import { setContext, afterUpdate, onMount } from 'svelte'; | ||
// stores | ||
export let stores; | ||
export let page; | ||
export let components; | ||
export let props_0 = null; | ||
export let props_1 = null; | ||
export let props_2 = null; | ||
setContext('__svelte__', stores); | ||
$: stores.page.set(page); | ||
afterUpdate(stores.page.notify); | ||
let mounted = false; | ||
let navigated = false; | ||
let title = null; | ||
onMount(() => { | ||
const unsubscribe = stores.page.subscribe(() => { | ||
if (mounted) { | ||
navigated = true; | ||
title = document.title || 'untitled page'; | ||
} | ||
}); | ||
mounted = true; | ||
return unsubscribe; | ||
}); | ||
</script> | ||
|
||
<svelte:component this="{components[0]}" {...props_0 || {}}> | ||
{#if components[1]} | ||
<svelte:component this="{components[1]}" {...props_1 || {}}> | ||
{#if components[2]} | ||
<svelte:component this="{components[2]}" {...props_2 || {}} /> | ||
{/if} | ||
</svelte:component> | ||
{/if} | ||
</svelte:component> | ||
|
||
{#if mounted} | ||
<div id="svelte-announcer" aria-live="assertive" aria-atomic="true"> | ||
{#if navigated} | ||
{title} | ||
{/if} | ||
</div> | ||
{/if} | ||
|
||
<style> | ||
#svelte-announcer { | ||
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; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
export { prerendering } from '../env.js'; | ||
|
||
/** | ||
* @type {import('$app/env').browser} | ||
*/ | ||
const browser = !import.meta.env.SSR; | ||
/** | ||
* @type {import('$app/env').dev} | ||
*/ | ||
const dev = !!import.meta.env.DEV; | ||
/** | ||
* @type {import('$app/env').amp} | ||
*/ | ||
const amp = !!import.meta.env.VITE_SVELTEKIT_AMP; | ||
|
||
export { amp, browser, dev }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { router } from '../internal/singletons.js'; | ||
import { g as get_base_uri } from '../chunks/utils.js'; | ||
|
||
/** | ||
* @param {string} name | ||
*/ | ||
function guard(name) { | ||
return () => { | ||
throw new Error(`Cannot call ${name}(...) on the server`); | ||
}; | ||
} | ||
|
||
const goto = import.meta.env.SSR ? guard('goto') : goto_; | ||
const invalidate = import.meta.env.SSR ? guard('invalidate') : invalidate_; | ||
const prefetch = import.meta.env.SSR ? guard('prefetch') : prefetch_; | ||
const prefetchRoutes = import.meta.env.SSR | ||
? guard('prefetchRoutes') | ||
: prefetchRoutes_; | ||
|
||
/** | ||
* @type {import('$app/navigation').goto} | ||
*/ | ||
async function goto_(href, opts) { | ||
return router.goto(href, opts, []); | ||
} | ||
|
||
/** | ||
* @type {import('$app/navigation').invalidate} | ||
*/ | ||
async function invalidate_(resource) { | ||
const { href } = new URL(resource, location.href); | ||
return router.renderer.invalidate(href); | ||
} | ||
|
||
/** | ||
* @type {import('$app/navigation').prefetch} | ||
*/ | ||
function prefetch_(href) { | ||
return router.prefetch(new URL(href, get_base_uri(document))); | ||
} | ||
|
||
/** | ||
* @type {import('$app/navigation').prefetchRoutes} | ||
*/ | ||
async function prefetchRoutes_(pathnames) { | ||
const matching = pathnames | ||
? router.routes.filter((route) => | ||
pathnames.some((pathname) => route[0].test(pathname)) | ||
) | ||
: router.routes; | ||
|
||
const promises = matching.map( | ||
(r) => r.length !== 1 && Promise.all(r[1].map((load) => load())) | ||
); | ||
|
||
await Promise.all(promises); | ||
} | ||
|
||
export { goto, invalidate, prefetch, prefetchRoutes }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { assets, base } from '../paths.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import { getContext } from 'svelte'; | ||
|
||
// const ssr = (import.meta as any).env.SSR; | ||
const ssr = typeof window === 'undefined'; // TODO why doesn't previous line work in build? | ||
|
||
// TODO remove this (for 1.0? after 1.0?) | ||
let warned = false; | ||
function stores() { | ||
if (!warned) { | ||
console.error('stores() is deprecated; use getStores() instead'); | ||
warned = true; | ||
} | ||
return getStores(); | ||
} | ||
|
||
/** | ||
* @type {import('$app/stores').getStores} | ||
*/ | ||
const getStores = () => { | ||
const stores = getContext('__svelte__'); | ||
|
||
return { | ||
page: { | ||
subscribe: stores.page.subscribe, | ||
}, | ||
navigating: { | ||
subscribe: stores.navigating.subscribe, | ||
}, | ||
// @ts-ignore - deprecated, not part of type definitions, but still callable | ||
get preloading() { | ||
console.error( | ||
'stores.preloading is deprecated; use stores.navigating instead' | ||
); | ||
return { | ||
subscribe: stores.navigating.subscribe, | ||
}; | ||
}, | ||
session: stores.session, | ||
}; | ||
}; | ||
|
||
/** @type {typeof import('$app/stores').page} */ | ||
const page = { | ||
/** @param {(value: any) => void} fn */ | ||
subscribe(fn) { | ||
const store = getStores().page; | ||
return store.subscribe(fn); | ||
}, | ||
}; | ||
|
||
/** @type {typeof import('$app/stores').navigating} */ | ||
const navigating = { | ||
/** @param {(value: any) => void} fn */ | ||
subscribe(fn) { | ||
const store = getStores().navigating; | ||
return store.subscribe(fn); | ||
}, | ||
}; | ||
|
||
/** @param {string} verb */ | ||
const error = (verb) => { | ||
throw new Error( | ||
ssr | ||
? `Can only ${verb} session store in browser` | ||
: `Cannot ${verb} session store before subscribing` | ||
); | ||
}; | ||
|
||
/** @type {typeof import('$app/stores').session} */ | ||
const session = { | ||
subscribe(fn) { | ||
const store = getStores().session; | ||
|
||
if (!ssr) { | ||
session.set = store.set; | ||
session.update = store.update; | ||
} | ||
|
||
return store.subscribe(fn); | ||
}, | ||
set: (value) => { | ||
error('set'); | ||
}, | ||
update: (updater) => { | ||
error('update'); | ||
}, | ||
}; | ||
|
||
export { getStores, navigating, page, session, stores }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/** @param {HTMLDocument} doc */ | ||
function get_base_uri(doc) { | ||
let baseURI = doc.baseURI; | ||
|
||
if (!baseURI) { | ||
const baseTags = doc.getElementsByTagName('base'); | ||
baseURI = baseTags.length ? baseTags[0].href : doc.URL; | ||
} | ||
|
||
return baseURI; | ||
} | ||
|
||
export { get_base_uri as g }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
let prerendering = false; | ||
|
||
/** @param {boolean} value */ | ||
function set_prerendering(value) { | ||
prerendering = value; | ||
} | ||
|
||
export { prerendering, set_prerendering }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/** @type {import('./router').Router} */ | ||
let router; | ||
|
||
/** @type {string} */ | ||
let base = ''; | ||
|
||
/** @type {string} */ | ||
let assets = '/.'; | ||
|
||
/** @param {import('./router').Router} _ */ | ||
function init(_) { | ||
router = _; | ||
} | ||
|
||
/** @param {{ base: string, assets: string }} paths */ | ||
function set_paths(paths) { | ||
({ base, assets } = paths); | ||
} | ||
|
||
export { assets, base, init, router, set_paths }; |
Oops, something went wrong.