-
-
Notifications
You must be signed in to change notification settings - Fork 2k
/
Copy pathstart.js
46 lines (40 loc) · 1.01 KB
/
start.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import { create_client } from './client.js';
import { init } from './singletons.js';
import { set_paths } from '../paths.js';
export { set_public_env } from '../env-public.js';
/**
* @param {{
* paths: {
* assets: string;
* base: string;
* },
* target: Element;
* route: boolean;
* spa: boolean;
* trailing_slash: import('types').TrailingSlash;
* hydrate: {
* status: number;
* error: Error | (import('../server/page/types').SerializedHttpError);
* node_ids: number[];
* params: Record<string, string>;
* routeId: string | null;
* };
* }} opts
*/
export async function start({ paths, target, route, spa, trailing_slash, hydrate }) {
const client = create_client({
target,
base: paths.base,
trailing_slash
});
init({ client });
set_paths(paths);
if (hydrate) {
await client._hydrate(hydrate);
}
if (route) {
if (spa) client.goto(location.href, { replaceState: true });
client._start_router();
}
dispatchEvent(new CustomEvent('sveltekit:start'));
}