@sveltejs/kit 1.0.0-next.284 → 1.0.0-next.287
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/client/start.js +14 -15
- package/assets/server/index.js +0 -2
- package/dist/chunks/index.js +30 -6
- package/dist/chunks/index5.js +2 -2
- package/dist/chunks/index6.js +2 -2
- package/dist/cli.js +3 -3
- package/dist/install-fetch.js +2 -2
- package/dist/node.js +3 -4
- package/package.json +4 -3
- package/types/ambient.d.ts +162 -69
- package/types/index.d.ts +28 -271
- package/types/internal.d.ts +18 -81
- package/types/private.d.ts +337 -0
package/assets/client/start.js
CHANGED
|
@@ -445,20 +445,13 @@ class Router {
|
|
|
445
445
|
|
|
446
446
|
accepted();
|
|
447
447
|
|
|
448
|
-
if (!this.navigating) {
|
|
449
|
-
dispatchEvent(new CustomEvent('sveltekit:navigation-start'));
|
|
450
|
-
}
|
|
451
448
|
this.navigating++;
|
|
452
449
|
|
|
453
450
|
const pathname = normalize_path(url.pathname, this.trailing_slash);
|
|
454
451
|
|
|
455
452
|
info.url = new URL(url.origin + pathname + url.search + url.hash);
|
|
456
453
|
|
|
457
|
-
|
|
458
|
-
const change = details.replaceState ? 0 : 1;
|
|
459
|
-
details.state['sveltekit:index'] = this.current_history_index += change;
|
|
460
|
-
history[details.replaceState ? 'replaceState' : 'pushState'](details.state, '', info.url);
|
|
461
|
-
}
|
|
454
|
+
const token = (this.navigating_token = {});
|
|
462
455
|
|
|
463
456
|
await this.renderer.handle_navigation(info, chain, false, {
|
|
464
457
|
scroll,
|
|
@@ -466,12 +459,19 @@ class Router {
|
|
|
466
459
|
});
|
|
467
460
|
|
|
468
461
|
this.navigating--;
|
|
469
|
-
if (!this.navigating) {
|
|
470
|
-
dispatchEvent(new CustomEvent('sveltekit:navigation-end'));
|
|
471
462
|
|
|
463
|
+
// navigation was aborted
|
|
464
|
+
if (this.navigating_token !== token) return;
|
|
465
|
+
if (!this.navigating) {
|
|
472
466
|
const navigation = { from, to: url };
|
|
473
467
|
this.callbacks.after_navigate.forEach((fn) => fn(navigation));
|
|
474
468
|
}
|
|
469
|
+
|
|
470
|
+
if (details) {
|
|
471
|
+
const change = details.replaceState ? 0 : 1;
|
|
472
|
+
details.state['sveltekit:index'] = this.current_history_index += change;
|
|
473
|
+
history[details.replaceState ? 'replaceState' : 'pushState'](details.state, '', info.url);
|
|
474
|
+
}
|
|
475
475
|
}
|
|
476
476
|
}
|
|
477
477
|
|
|
@@ -898,11 +898,10 @@ class Renderer {
|
|
|
898
898
|
});
|
|
899
899
|
} else {
|
|
900
900
|
if (this.router) {
|
|
901
|
-
this.router.goto(
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
);
|
|
901
|
+
this.router.goto(new URL(navigation_result.redirect, info.url).href, {}, [
|
|
902
|
+
...chain,
|
|
903
|
+
info.url.pathname
|
|
904
|
+
]);
|
|
906
905
|
} else {
|
|
907
906
|
location.href = new URL(navigation_result.redirect, location.href).href;
|
|
908
907
|
}
|
package/assets/server/index.js
CHANGED
package/dist/chunks/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { r as runtime, S as SVELTE_KIT_ASSETS, a as resolve_entry, $, b as SVELT
|
|
|
6
6
|
import fs__default from 'fs';
|
|
7
7
|
import { URL } from 'url';
|
|
8
8
|
import { s as sirv } from './build.js';
|
|
9
|
-
import {
|
|
9
|
+
import { installFetch } from '../install-fetch.js';
|
|
10
10
|
import { getRequest, setResponse } from '../node.js';
|
|
11
11
|
import { sequence } from '../hooks.js';
|
|
12
12
|
import './misc.js';
|
|
@@ -46,7 +46,7 @@ async function create_plugin(config, cwd) {
|
|
|
46
46
|
name: 'vite-plugin-svelte-kit',
|
|
47
47
|
|
|
48
48
|
configureServer(vite) {
|
|
49
|
-
|
|
49
|
+
installFetch();
|
|
50
50
|
|
|
51
51
|
/** @type {import('types').SSRManifest} */
|
|
52
52
|
let manifest;
|
|
@@ -144,6 +144,24 @@ async function create_plugin(config, cwd) {
|
|
|
144
144
|
};
|
|
145
145
|
}
|
|
146
146
|
|
|
147
|
+
/** @param {Error} error */
|
|
148
|
+
function fix_stack_trace(error) {
|
|
149
|
+
// TODO https://github.com/vitejs/vite/issues/7045
|
|
150
|
+
|
|
151
|
+
// ideally vite would expose ssrRewriteStacktrace, but
|
|
152
|
+
// in lieu of that, we can implement it ourselves. we
|
|
153
|
+
// don't want to mutate the error object, because
|
|
154
|
+
// the stack trace could be 'fixed' multiple times,
|
|
155
|
+
// and Vite will fix stack traces before we even
|
|
156
|
+
// see them if they occur during ssrLoadModule
|
|
157
|
+
const original = error.stack;
|
|
158
|
+
vite.ssrFixStacktrace(error);
|
|
159
|
+
const fixed = error.stack;
|
|
160
|
+
error.stack = original;
|
|
161
|
+
|
|
162
|
+
return fixed;
|
|
163
|
+
}
|
|
164
|
+
|
|
147
165
|
update_manifest();
|
|
148
166
|
|
|
149
167
|
vite.watcher.on('add', update_manifest);
|
|
@@ -248,13 +266,19 @@ async function create_plugin(config, cwd) {
|
|
|
248
266
|
dev: true,
|
|
249
267
|
floc: config.kit.floc,
|
|
250
268
|
get_stack: (error) => {
|
|
251
|
-
|
|
252
|
-
return error.stack;
|
|
269
|
+
return fix_stack_trace(error);
|
|
253
270
|
},
|
|
254
271
|
handle_error: (error, event) => {
|
|
255
|
-
vite.ssrFixStacktrace(error);
|
|
256
272
|
hooks.handleError({
|
|
257
|
-
error,
|
|
273
|
+
error: new Proxy(error, {
|
|
274
|
+
get: (target, property) => {
|
|
275
|
+
if (property === 'stack') {
|
|
276
|
+
return fix_stack_trace(error);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
return Reflect.get(target, property, target);
|
|
280
|
+
}
|
|
281
|
+
}),
|
|
258
282
|
event,
|
|
259
283
|
|
|
260
284
|
// TODO remove for 1.0
|
package/dist/chunks/index5.js
CHANGED
|
@@ -2,7 +2,7 @@ import { b as SVELTE_KIT, m as mkdirp, h as rimraf, i as copy, $, j as logger }
|
|
|
2
2
|
import { readFileSync, writeFileSync } from 'fs';
|
|
3
3
|
import { resolve as resolve$1, join, dirname } from 'path';
|
|
4
4
|
import { pathToFileURL, URL } from 'url';
|
|
5
|
-
import {
|
|
5
|
+
import { installFetch } from '../install-fetch.js';
|
|
6
6
|
import { g as generate_manifest } from './index4.js';
|
|
7
7
|
import 'sade';
|
|
8
8
|
import 'child_process';
|
|
@@ -458,7 +458,7 @@ async function prerender({ cwd, out, log, config, build_data, fallback, all }) {
|
|
|
458
458
|
return prerendered;
|
|
459
459
|
}
|
|
460
460
|
|
|
461
|
-
|
|
461
|
+
installFetch();
|
|
462
462
|
|
|
463
463
|
const server_root = resolve$1(cwd, `${SVELTE_KIT}/output`);
|
|
464
464
|
|
package/dist/chunks/index6.js
CHANGED
|
@@ -5,7 +5,7 @@ import { resolve, join } from 'path';
|
|
|
5
5
|
import { s as sirv } from './build.js';
|
|
6
6
|
import { pathToFileURL } from 'url';
|
|
7
7
|
import { getRequest, setResponse } from '../node.js';
|
|
8
|
-
import {
|
|
8
|
+
import { installFetch } from '../install-fetch.js';
|
|
9
9
|
import { b as SVELTE_KIT, S as SVELTE_KIT_ASSETS } from '../cli.js';
|
|
10
10
|
import 'querystring';
|
|
11
11
|
import 'stream';
|
|
@@ -43,7 +43,7 @@ async function preview({
|
|
|
43
43
|
https: use_https = false,
|
|
44
44
|
cwd = process.cwd()
|
|
45
45
|
}) {
|
|
46
|
-
|
|
46
|
+
installFetch();
|
|
47
47
|
|
|
48
48
|
const index_file = resolve(cwd, `${SVELTE_KIT}/output/server/index.js`);
|
|
49
49
|
const manifest_file = resolve(cwd, `${SVELTE_KIT}/output/server/manifest.js`);
|
package/dist/cli.js
CHANGED
|
@@ -422,7 +422,7 @@ function get_mime_lookup(manifest_data) {
|
|
|
422
422
|
return mime;
|
|
423
423
|
}
|
|
424
424
|
|
|
425
|
-
/** @param {import('
|
|
425
|
+
/** @param {import('types').ValidatedConfig} config */
|
|
426
426
|
function get_aliases(config) {
|
|
427
427
|
const alias = {
|
|
428
428
|
__GENERATED__: path__default.posix.resolve(`${SVELTE_KIT}/generated`),
|
|
@@ -998,7 +998,7 @@ async function launch(port, https) {
|
|
|
998
998
|
exec(`${cmd} ${https ? 'https' : 'http'}://localhost:${port}`);
|
|
999
999
|
}
|
|
1000
1000
|
|
|
1001
|
-
const prog = sade('svelte-kit').version('1.0.0-next.
|
|
1001
|
+
const prog = sade('svelte-kit').version('1.0.0-next.287');
|
|
1002
1002
|
|
|
1003
1003
|
prog
|
|
1004
1004
|
.command('dev')
|
|
@@ -1156,7 +1156,7 @@ async function check_port(port) {
|
|
|
1156
1156
|
function welcome({ port, host, https, open, loose, allow, cwd }) {
|
|
1157
1157
|
if (open) launch(port, https);
|
|
1158
1158
|
|
|
1159
|
-
console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.
|
|
1159
|
+
console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.287'}\n`));
|
|
1160
1160
|
|
|
1161
1161
|
const protocol = https ? 'https:' : 'http:';
|
|
1162
1162
|
const exposed = typeof host !== 'undefined' && host !== 'localhost' && host !== '127.0.0.1';
|
package/dist/install-fetch.js
CHANGED
|
@@ -6490,7 +6490,7 @@ function fixResponseChunkedTransferBadEnding(request, errorCallback) {
|
|
|
6490
6490
|
}
|
|
6491
6491
|
|
|
6492
6492
|
// exported for dev/preview and node environments
|
|
6493
|
-
function
|
|
6493
|
+
function installFetch() {
|
|
6494
6494
|
Object.defineProperties(globalThis, {
|
|
6495
6495
|
fetch: {
|
|
6496
6496
|
enumerable: true,
|
|
@@ -6515,4 +6515,4 @@ function __fetch_polyfill() {
|
|
|
6515
6515
|
});
|
|
6516
6516
|
}
|
|
6517
6517
|
|
|
6518
|
-
export { FormData as F,
|
|
6518
|
+
export { FormData as F, File as a, commonjsGlobal as c, installFetch };
|
package/dist/node.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Readable } from 'stream';
|
|
2
2
|
|
|
3
|
-
/** @
|
|
3
|
+
/** @param {import('http').IncomingMessage} req */
|
|
4
4
|
function get_raw_body(req) {
|
|
5
5
|
return new Promise((fulfil, reject) => {
|
|
6
6
|
const h = req.headers;
|
|
@@ -50,7 +50,7 @@ function get_raw_body(req) {
|
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
/** @type {import('@sveltejs/kit/node').
|
|
53
|
+
/** @type {import('@sveltejs/kit/node').getRequest} */
|
|
54
54
|
async function getRequest(base, req) {
|
|
55
55
|
let headers = /** @type {Record<string, string>} */ (req.headers);
|
|
56
56
|
if (req.httpVersionMajor === 2) {
|
|
@@ -69,9 +69,8 @@ async function getRequest(base, req) {
|
|
|
69
69
|
});
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
/** @type {import('@sveltejs/kit/node').
|
|
72
|
+
/** @type {import('@sveltejs/kit/node').setResponse} */
|
|
73
73
|
async function setResponse(res, response) {
|
|
74
|
-
/** @type {import('types').ResponseHeaders} */
|
|
75
74
|
const headers = Object.fromEntries(response.headers);
|
|
76
75
|
|
|
77
76
|
if (response.headers.has('set-cookie')) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sveltejs/kit",
|
|
3
|
-
"version": "1.0.0-next.
|
|
3
|
+
"version": "1.0.0-next.287",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/sveltejs/kit",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"vite": "^2.8.0"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"@playwright/test": "^1.
|
|
18
|
+
"@playwright/test": "^1.19.1",
|
|
19
19
|
"@rollup/plugin-replace": "^4.0.0",
|
|
20
20
|
"@types/amphtml-validator": "^1.0.1",
|
|
21
21
|
"@types/cookie": "^0.4.1",
|
|
@@ -82,8 +82,9 @@
|
|
|
82
82
|
"check": "tsc && svelte-check --ignore test/prerendering,src/packaging/test",
|
|
83
83
|
"format": "npm run check-format -- --write",
|
|
84
84
|
"check-format": "prettier --check . --config ../../.prettierrc --ignore-path .gitignore",
|
|
85
|
-
"test": "npm run test:unit && npm run test:packaging && npm run test:prerendering && npm run test:integration",
|
|
85
|
+
"test": "npm run test:unit && npm run test:typings && npm run test:packaging && npm run test:prerendering && npm run test:integration",
|
|
86
86
|
"test:unit": "uvu src \"(spec\\.js|test[\\\\/]index\\.js)\" -i packaging",
|
|
87
|
+
"test:typings": "tsc --project test/typings",
|
|
87
88
|
"test:prerendering": "pnpm test:prerendering:basics && pnpm test:prerendering:options",
|
|
88
89
|
"test:prerendering:basics": "cd test/prerendering/basics && pnpm test",
|
|
89
90
|
"test:prerendering:options": "cd test/prerendering/options && pnpm test",
|
package/types/ambient.d.ts
CHANGED
|
@@ -1,13 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* It's possible to tell SvelteKit how to type objects inside your app by declaring the `App` namespace. By default, a new project will have a file called `src/app.d.ts` containing the following:
|
|
3
|
+
*
|
|
4
|
+
* ```ts
|
|
5
|
+
* /// <reference types="@sveltejs/kit" />
|
|
6
|
+
*
|
|
7
|
+
* declare namespace App {
|
|
8
|
+
* interface Locals {}
|
|
9
|
+
*
|
|
10
|
+
* interface Platform {}
|
|
11
|
+
*
|
|
12
|
+
* interface Session {}
|
|
13
|
+
*
|
|
14
|
+
* interface Stuff {}
|
|
15
|
+
* }
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* By populating these interfaces, you will gain type safety when using `event.locals`, `event.platform`, `session` and `stuff`:
|
|
19
|
+
*/
|
|
1
20
|
declare namespace App {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
interface
|
|
21
|
+
/**
|
|
22
|
+
* The interface that defines `event.locals`, which can be accessed in [hooks](/docs/hooks) (`handle`, `handleError` and `getSession`) and [endpoints](/docs/routing#endpoints).
|
|
23
|
+
*/
|
|
24
|
+
export interface Locals {}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* If your adapter provides [platform-specific context](/docs/adapters#supported-environments-platform-specific-context) via `event.platform`, you can specify it here.
|
|
28
|
+
*/
|
|
29
|
+
export interface Platform {}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* The interface that defines `session`, both as an argument to [`load`](/docs/loading) functions and the value of the [session store](/docs/modules#$app-stores).
|
|
33
|
+
*/
|
|
34
|
+
export interface Session {}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* The interface that defines `stuff`, as input or output to [`load`](/docs/loading) or as the value of the `stuff` property of the [page store](/docs/modules#$app-stores).
|
|
38
|
+
*/
|
|
39
|
+
export interface Stuff {}
|
|
6
40
|
}
|
|
7
41
|
|
|
42
|
+
/**
|
|
43
|
+
* ```ts
|
|
44
|
+
* import { amp, browser, dev, mode, prerendering } from '$app/env';
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
8
47
|
declare module '$app/env' {
|
|
9
48
|
/**
|
|
10
|
-
* Whether or not app is in AMP mode.
|
|
49
|
+
* Whether or not the app is running in [AMP mode](/docs/seo#manual-setup-amp).
|
|
11
50
|
*/
|
|
12
51
|
export const amp: boolean;
|
|
13
52
|
/**
|
|
@@ -30,14 +69,27 @@ declare module '$app/env' {
|
|
|
30
69
|
export const mode: string;
|
|
31
70
|
}
|
|
32
71
|
|
|
72
|
+
/**
|
|
73
|
+
* ```ts
|
|
74
|
+
* import {
|
|
75
|
+
* afterNavigate,
|
|
76
|
+
* beforeNavigate,
|
|
77
|
+
* disableScrollHandling,
|
|
78
|
+
* goto,
|
|
79
|
+
* invalidate,
|
|
80
|
+
* prefetch,
|
|
81
|
+
* prefetchRoutes
|
|
82
|
+
* } from '$app/navigation';
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
33
85
|
declare module '$app/navigation' {
|
|
34
86
|
/**
|
|
35
|
-
*
|
|
87
|
+
* If called when the page is being updated following a navigation (in `onMount` or an action, for example), this disables SvelteKit's built-in scroll handling.
|
|
36
88
|
* This is generally discouraged, since it breaks user expectations.
|
|
37
89
|
*/
|
|
38
90
|
export function disableScrollHandling(): void;
|
|
39
91
|
/**
|
|
40
|
-
* Returns a Promise that resolves when SvelteKit navigates (or fails to navigate, in which case the promise rejects) to the specified href
|
|
92
|
+
* Returns a Promise that resolves when SvelteKit navigates (or fails to navigate, in which case the promise rejects) to the specified `href`.
|
|
41
93
|
*
|
|
42
94
|
* @param href Where to navigate to
|
|
43
95
|
* @param opts.replaceState If `true`, will replace the current `history` entry rather than creating a new one with `pushState`
|
|
@@ -48,12 +100,12 @@ declare module '$app/navigation' {
|
|
|
48
100
|
export function goto(
|
|
49
101
|
href: string,
|
|
50
102
|
opts?: { replaceState?: boolean; noscroll?: boolean; keepfocus?: boolean; state?: any }
|
|
51
|
-
): Promise<
|
|
103
|
+
): Promise<void>;
|
|
52
104
|
/**
|
|
53
|
-
*
|
|
105
|
+
* Causes any `load` functions belonging to the currently active page to re-run if they `fetch` the resource in question. Returns a `Promise` that resolves when the page is subsequently updated.
|
|
54
106
|
* @param href The invalidated resource
|
|
55
107
|
*/
|
|
56
|
-
export function invalidate(href: string): Promise<
|
|
108
|
+
export function invalidate(href: string): Promise<void>;
|
|
57
109
|
/**
|
|
58
110
|
* Programmatically prefetches the given page, which means
|
|
59
111
|
* 1. ensuring that the code for the page is loaded, and
|
|
@@ -65,7 +117,7 @@ declare module '$app/navigation' {
|
|
|
65
117
|
*
|
|
66
118
|
* @param href Page to prefetch
|
|
67
119
|
*/
|
|
68
|
-
export function prefetch(href: string): Promise<
|
|
120
|
+
export function prefetch(href: string): Promise<void>;
|
|
69
121
|
/**
|
|
70
122
|
* Programmatically prefetches the code for routes that haven't yet been fetched.
|
|
71
123
|
* Typically, you might call this to speed up subsequent navigation.
|
|
@@ -76,92 +128,108 @@ declare module '$app/navigation' {
|
|
|
76
128
|
* Unlike prefetch, this won't call preload for individual pages.
|
|
77
129
|
* Returns a Promise that resolves when the routes have been prefetched.
|
|
78
130
|
*/
|
|
79
|
-
export function prefetchRoutes(routes?: string[]): Promise<
|
|
131
|
+
export function prefetchRoutes(routes?: string[]): Promise<void>;
|
|
80
132
|
|
|
81
133
|
/**
|
|
82
|
-
* A navigation interceptor that triggers before we navigate to a new
|
|
134
|
+
* A navigation interceptor that triggers before we navigate to a new URL (internal or external) whether by clicking a link, calling `goto`, or using the browser back/forward controls.
|
|
83
135
|
* This is helpful if we want to conditionally prevent a navigation from completing or lookup the upcoming url.
|
|
84
136
|
*/
|
|
85
137
|
export function beforeNavigate(
|
|
86
|
-
fn: (
|
|
87
|
-
):
|
|
138
|
+
fn: (navigation: { from: URL; to: URL | null; cancel: () => void }) => void
|
|
139
|
+
): void;
|
|
88
140
|
|
|
89
141
|
/**
|
|
90
142
|
* A lifecycle function that runs when the page mounts, and also whenever SvelteKit navigates to a new URL but stays on this component.
|
|
91
143
|
*/
|
|
92
|
-
export function afterNavigate(fn: (
|
|
144
|
+
export function afterNavigate(fn: (navigation: { from: URL | null; to: URL }) => void): void;
|
|
93
145
|
}
|
|
94
146
|
|
|
147
|
+
/**
|
|
148
|
+
* ```ts
|
|
149
|
+
* import { base, assets } from '$app/paths';
|
|
150
|
+
* ```
|
|
151
|
+
*/
|
|
95
152
|
declare module '$app/paths' {
|
|
96
153
|
/**
|
|
97
|
-
* A
|
|
154
|
+
* A string that matches [`config.kit.paths.base`](/docs/configuration#paths). It must begin, but not end, with a `/`.
|
|
98
155
|
*/
|
|
99
|
-
export const base: string
|
|
156
|
+
export const base: `/${string}`;
|
|
100
157
|
/**
|
|
101
|
-
*
|
|
158
|
+
* An absolute path that matches [`config.kit.paths.assets`](/docs/configuration#paths).
|
|
159
|
+
*
|
|
160
|
+
* > If a value for `config.kit.paths.assets` is specified, it will be replaced with `'/_svelte_kit_assets'` during [`svelte-kit dev`](/docs/cli#svelte-kit-dev) or [`svelte-kit preview`](/docs/cli#svelte-kit-preview), since the assets don't yet live at their eventual URL.
|
|
102
161
|
*/
|
|
103
|
-
export const assets: string
|
|
162
|
+
export const assets: `https://${string}` | `http://${string}`;
|
|
104
163
|
}
|
|
105
164
|
|
|
165
|
+
/**
|
|
166
|
+
* ```ts
|
|
167
|
+
* import { getStores, navigating, page, session, updated } from '$app/stores';
|
|
168
|
+
* ```
|
|
169
|
+
*
|
|
170
|
+
* Stores are _contextual_ — they are added to the [context](https://svelte.dev/tutorial/context-api) of your root component. This means that `session` and `page` are unique to each request on the server, rather than shared between multiple requests handled by the same server simultaneously, which is what makes it safe to include user-specific data in `session`.
|
|
171
|
+
*
|
|
172
|
+
* Because of that, you must subscribe to the stores during component initialization (which happens automatically if you reference the store value, e.g. as `$page`, in a component) before you can use them.
|
|
173
|
+
*/
|
|
106
174
|
declare module '$app/stores' {
|
|
107
175
|
import { Readable, Writable } from 'svelte/store';
|
|
108
|
-
|
|
176
|
+
import { Navigation, Page } from '@sveltejs/kit';
|
|
109
177
|
|
|
110
178
|
/**
|
|
111
|
-
* A convenience function around `getContext
|
|
112
|
-
*
|
|
179
|
+
* A convenience function around `getContext`. Must be called during component initialization.
|
|
180
|
+
* Only use this if you need to defer store subscription until after the component has mounted, for some reason.
|
|
113
181
|
*/
|
|
114
182
|
export function getStores(): {
|
|
115
183
|
navigating: typeof navigating;
|
|
116
184
|
page: typeof page;
|
|
117
|
-
session:
|
|
185
|
+
session: typeof session;
|
|
118
186
|
updated: typeof updated;
|
|
119
187
|
};
|
|
188
|
+
|
|
120
189
|
/**
|
|
121
190
|
* A readable store whose value contains page data.
|
|
122
191
|
*/
|
|
123
|
-
export const page: Readable<
|
|
124
|
-
url: URL;
|
|
125
|
-
params: Record<string, string>;
|
|
126
|
-
stuff: App.Stuff;
|
|
127
|
-
status: number;
|
|
128
|
-
error: Error | null;
|
|
129
|
-
}>;
|
|
192
|
+
export const page: Readable<Page>;
|
|
130
193
|
/**
|
|
131
194
|
* A readable store.
|
|
132
|
-
* When navigating starts, its value is `{ from: URL, to: URL }
|
|
195
|
+
* When navigating starts, its value is `{ from: URL, to: URL }`,
|
|
133
196
|
* When navigating finishes, its value reverts to `null`.
|
|
134
197
|
*/
|
|
135
|
-
export const navigating: Readable<
|
|
198
|
+
export const navigating: Readable<Navigation | null>;
|
|
136
199
|
/**
|
|
137
|
-
* A writable store whose initial value is whatever was returned from `getSession
|
|
200
|
+
* A writable store whose initial value is whatever was returned from [`getSession`](/docs/hooks#getsession).
|
|
138
201
|
* It can be written to, but this will not cause changes to persist on the server — this is something you must implement yourself.
|
|
139
202
|
*/
|
|
140
203
|
export const session: Writable<App.Session>;
|
|
141
204
|
/**
|
|
142
|
-
*
|
|
143
|
-
* It can be written to when custom logic is required to detect updates.
|
|
205
|
+
* A readable store whose initial value is `false`. If [`version.pollInterval`](/docs/configuration#version) is a non-zero value, SvelteKit will poll for new versions of the app and update the store value to `true` when it detects one. `updated.check()` will force an immediate check, regardless of polling.
|
|
144
206
|
*/
|
|
145
207
|
export const updated: Readable<boolean> & { check: () => boolean };
|
|
146
208
|
}
|
|
147
209
|
|
|
210
|
+
/**
|
|
211
|
+
* This is a simple alias to `src/lib`, or whatever directory is specified as [`config.kit.files.lib`](/docs/configuration#files). It allows you to access common components and utility modules without `../../../../` nonsense.
|
|
212
|
+
*/
|
|
213
|
+
declare module '$lib' {}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* ```ts
|
|
217
|
+
* import { build, files, timestamp } from '$service-worker';
|
|
218
|
+
* ```
|
|
219
|
+
*
|
|
220
|
+
* This module is only available to [service workers](/docs/service-workers).
|
|
221
|
+
*/
|
|
148
222
|
declare module '$service-worker' {
|
|
149
223
|
/**
|
|
150
224
|
* An array of URL strings representing the files generated by Vite, suitable for caching with `cache.addAll(build)`.
|
|
151
|
-
* This is only available to service workers.
|
|
152
225
|
*/
|
|
153
226
|
export const build: string[];
|
|
154
227
|
/**
|
|
155
|
-
* An array of URL strings representing the files in your static directory,
|
|
156
|
-
* or whatever directory is specified by `config.kit.files.assets`.
|
|
157
|
-
* This is only available to service workers.
|
|
228
|
+
* An array of URL strings representing the files in your static directory, or whatever directory is specified by `config.kit.files.assets`. You can customize which files are included from `static` directory using [`config.kit.serviceWorker.files`](/docs/configuration)
|
|
158
229
|
*/
|
|
159
230
|
export const files: string[];
|
|
160
231
|
/**
|
|
161
|
-
* The result of calling `Date.now()` at build time.
|
|
162
|
-
* It's useful for generating unique cache names inside your service worker,
|
|
163
|
-
* so that a later deployment of your app can invalidate old caches.
|
|
164
|
-
* This is only available to service workers.
|
|
232
|
+
* The result of calling `Date.now()` at build time. It's useful for generating unique cache names inside your service worker, so that a later deployment of your app can invalidate old caches.
|
|
165
233
|
*/
|
|
166
234
|
export const timestamp: number;
|
|
167
235
|
}
|
|
@@ -170,37 +238,62 @@ declare module '@sveltejs/kit/hooks' {
|
|
|
170
238
|
import { Handle } from '@sveltejs/kit';
|
|
171
239
|
|
|
172
240
|
/**
|
|
173
|
-
*
|
|
174
|
-
*
|
|
241
|
+
* A helper function for sequencing multiple `handle` calls in a middleware-like manner.
|
|
242
|
+
*
|
|
243
|
+
* ```js
|
|
244
|
+
* /// file: src/hooks.js
|
|
245
|
+
* import { sequence } from '@sveltejs/kit/hooks';
|
|
246
|
+
*
|
|
247
|
+
* /** @type {import('@sveltejs/kit').Handle} *\/
|
|
248
|
+
* async function first({ event, resolve }) {
|
|
249
|
+
* console.log('first pre-processing');
|
|
250
|
+
* const result = await resolve(event);
|
|
251
|
+
* console.log('first post-processing');
|
|
252
|
+
* return result;
|
|
253
|
+
* }
|
|
254
|
+
*
|
|
255
|
+
* /** @type {import('@sveltejs/kit').Handle} *\/
|
|
256
|
+
* async function second({ event, resolve }) {
|
|
257
|
+
* console.log('second pre-processing');
|
|
258
|
+
* const result = await resolve(event);
|
|
259
|
+
* console.log('second post-processing');
|
|
260
|
+
* return result;
|
|
261
|
+
* }
|
|
262
|
+
*
|
|
263
|
+
* export const handle = sequence(first, second);
|
|
264
|
+
* ```
|
|
265
|
+
*
|
|
266
|
+
* The example above would print:
|
|
267
|
+
*
|
|
268
|
+
* ```
|
|
269
|
+
* first pre-processing
|
|
270
|
+
* second pre-processing
|
|
271
|
+
* second post-processing
|
|
272
|
+
* first post-processing
|
|
273
|
+
* ```
|
|
175
274
|
*
|
|
176
275
|
* @param handlers The chain of `handle` functions
|
|
177
276
|
*/
|
|
178
277
|
export function sequence(...handlers: Handle[]): Handle;
|
|
179
278
|
}
|
|
180
279
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
export interface GetRawBody {
|
|
185
|
-
(request: IncomingMessage): Promise<Uint8Array | null>;
|
|
186
|
-
}
|
|
187
|
-
export const getRawBody: GetRawBody;
|
|
188
|
-
|
|
189
|
-
export interface GetRequest {
|
|
190
|
-
(base: string, request: IncomingMessage): Promise<Request>;
|
|
191
|
-
}
|
|
192
|
-
export const getRequest: GetRequest;
|
|
193
|
-
|
|
194
|
-
export interface SetResponse {
|
|
195
|
-
(res: ServerResponse, response: Response): void;
|
|
196
|
-
}
|
|
197
|
-
export const setResponse: SetResponse;
|
|
198
|
-
}
|
|
199
|
-
|
|
280
|
+
/**
|
|
281
|
+
* A polyfill for `fetch` and its related interfaces, used by adapters for environments that don't provide a native implementation.
|
|
282
|
+
*/
|
|
200
283
|
declare module '@sveltejs/kit/install-fetch' {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
284
|
+
/**
|
|
285
|
+
* Make `fetch`, `Headers`, `Request` and `Response` available as globals, via `node-fetch`
|
|
286
|
+
*/
|
|
287
|
+
export function installFetch(): void;
|
|
288
|
+
}
|
|
204
289
|
|
|
205
|
-
|
|
290
|
+
/**
|
|
291
|
+
* Utilities used by adapters for Node-like environments.
|
|
292
|
+
*/
|
|
293
|
+
declare module '@sveltejs/kit/node' {
|
|
294
|
+
export function getRequest(
|
|
295
|
+
base: string,
|
|
296
|
+
request: import('http').IncomingMessage
|
|
297
|
+
): Promise<Request>;
|
|
298
|
+
export function setResponse(res: import('http').ServerResponse, response: Response): void;
|
|
206
299
|
}
|