@sveltejs/kit 1.0.0-next.98 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -1
- package/package.json +91 -77
- package/postinstall.js +47 -0
- package/src/cli.js +44 -0
- package/src/constants.js +5 -0
- package/src/core/adapt/builder.js +221 -0
- package/src/core/adapt/index.js +31 -0
- package/src/core/config/default-error.html +56 -0
- package/src/core/config/index.js +100 -0
- package/src/core/config/options.js +387 -0
- package/src/core/config/types.d.ts +1 -0
- package/src/core/env.js +138 -0
- package/src/core/generate_manifest/index.js +116 -0
- package/src/core/prerender/crawl.js +207 -0
- package/src/core/prerender/entities.js +2252 -0
- package/src/core/prerender/fallback.js +43 -0
- package/src/core/prerender/prerender.js +459 -0
- package/src/core/prerender/queue.js +80 -0
- package/src/core/sync/create_manifest_data/conflict.js +0 -0
- package/src/core/sync/create_manifest_data/index.js +523 -0
- package/src/core/sync/create_manifest_data/sort.js +161 -0
- package/src/core/sync/create_manifest_data/types.d.ts +37 -0
- package/src/core/sync/sync.js +59 -0
- package/src/core/sync/utils.js +33 -0
- package/src/core/sync/write_ambient.js +58 -0
- package/src/core/sync/write_client_manifest.js +107 -0
- package/src/core/sync/write_matchers.js +25 -0
- package/src/core/sync/write_root.js +91 -0
- package/src/core/sync/write_tsconfig.js +195 -0
- package/src/core/sync/write_types/index.js +809 -0
- package/src/core/utils.js +67 -0
- package/src/exports/hooks/index.js +1 -0
- package/src/exports/hooks/sequence.js +44 -0
- package/src/exports/index.js +55 -0
- package/src/exports/node/index.js +172 -0
- package/src/exports/node/polyfills.js +28 -0
- package/src/exports/vite/build/build_server.js +359 -0
- package/src/exports/vite/build/build_service_worker.js +85 -0
- package/src/exports/vite/build/utils.js +230 -0
- package/src/exports/vite/dev/index.js +597 -0
- package/src/exports/vite/graph_analysis/index.js +99 -0
- package/src/exports/vite/graph_analysis/types.d.ts +5 -0
- package/src/exports/vite/graph_analysis/utils.js +6 -0
- package/src/exports/vite/index.js +708 -0
- package/src/exports/vite/preview/index.js +194 -0
- package/src/exports/vite/types.d.ts +3 -0
- package/src/exports/vite/utils.js +184 -0
- package/src/runtime/app/env.js +1 -0
- package/src/runtime/app/environment.js +13 -0
- package/src/runtime/app/forms.js +135 -0
- package/src/runtime/app/navigation.js +22 -0
- package/src/runtime/app/paths.js +1 -0
- package/src/runtime/app/stores.js +57 -0
- package/src/runtime/client/ambient.d.ts +30 -0
- package/src/runtime/client/client.js +1725 -0
- package/src/runtime/client/constants.js +10 -0
- package/src/runtime/client/fetcher.js +127 -0
- package/src/runtime/client/parse.js +60 -0
- package/src/runtime/client/singletons.js +21 -0
- package/src/runtime/client/start.js +45 -0
- package/src/runtime/client/types.d.ts +86 -0
- package/src/runtime/client/utils.js +257 -0
- package/src/runtime/components/error.svelte +6 -0
- package/{assets → src/runtime}/components/layout.svelte +0 -0
- package/src/runtime/control.js +45 -0
- package/src/runtime/env/dynamic/private.js +1 -0
- package/src/runtime/env/dynamic/public.js +1 -0
- package/src/runtime/env-private.js +6 -0
- package/src/runtime/env-public.js +6 -0
- package/src/runtime/env.js +12 -0
- package/src/runtime/hash.js +20 -0
- package/src/runtime/paths.js +11 -0
- package/src/runtime/server/cookie.js +228 -0
- package/src/runtime/server/data/index.js +158 -0
- package/src/runtime/server/endpoint.js +86 -0
- package/src/runtime/server/fetch.js +175 -0
- package/src/runtime/server/index.js +405 -0
- package/src/runtime/server/page/actions.js +267 -0
- package/src/runtime/server/page/crypto.js +239 -0
- package/src/runtime/server/page/csp.js +250 -0
- package/src/runtime/server/page/index.js +326 -0
- package/src/runtime/server/page/load_data.js +270 -0
- package/src/runtime/server/page/render.js +393 -0
- package/src/runtime/server/page/respond_with_error.js +103 -0
- package/src/runtime/server/page/serialize_data.js +87 -0
- package/src/runtime/server/page/types.d.ts +35 -0
- package/src/runtime/server/utils.js +179 -0
- package/src/utils/array.js +9 -0
- package/src/utils/error.js +22 -0
- package/src/utils/escape.js +46 -0
- package/src/utils/exports.js +54 -0
- package/src/utils/filesystem.js +178 -0
- package/src/utils/functions.js +16 -0
- package/src/utils/http.js +72 -0
- package/src/utils/misc.js +1 -0
- package/src/utils/promises.js +17 -0
- package/src/utils/routing.js +201 -0
- package/src/utils/unit_test.js +11 -0
- package/src/utils/url.js +161 -0
- package/svelte-kit.js +1 -1
- package/types/ambient.d.ts +451 -0
- package/types/index.d.ts +1168 -5
- package/types/internal.d.ts +348 -160
- package/types/private.d.ts +237 -0
- package/types/synthetic/$env+dynamic+private.md +10 -0
- package/types/synthetic/$env+dynamic+public.md +8 -0
- package/types/synthetic/$env+static+private.md +19 -0
- package/types/synthetic/$env+static+public.md +7 -0
- package/types/synthetic/$lib.md +5 -0
- package/CHANGELOG.md +0 -819
- package/assets/components/error.svelte +0 -21
- package/assets/runtime/app/env.js +0 -16
- package/assets/runtime/app/navigation.js +0 -53
- package/assets/runtime/app/paths.js +0 -1
- package/assets/runtime/app/stores.js +0 -87
- package/assets/runtime/chunks/utils.js +0 -13
- package/assets/runtime/env.js +0 -8
- package/assets/runtime/internal/singletons.js +0 -20
- package/assets/runtime/internal/start.js +0 -1061
- package/assets/runtime/paths.js +0 -12
- package/dist/chunks/_commonjsHelpers.js +0 -8
- package/dist/chunks/cert.js +0 -29079
- package/dist/chunks/constants.js +0 -3
- package/dist/chunks/index.js +0 -3526
- package/dist/chunks/index2.js +0 -583
- package/dist/chunks/index3.js +0 -31
- package/dist/chunks/index4.js +0 -1005
- package/dist/chunks/index5.js +0 -327
- package/dist/chunks/index6.js +0 -325
- package/dist/chunks/standard.js +0 -99
- package/dist/chunks/utils.js +0 -149
- package/dist/cli.js +0 -711
- package/dist/http.js +0 -66
- package/dist/install-fetch.js +0 -1699
- package/dist/ssr.js +0 -1529
- package/types/ambient-modules.d.ts +0 -115
- package/types/config.d.ts +0 -101
- package/types/endpoint.d.ts +0 -23
- package/types/helper.d.ts +0 -19
- package/types/hooks.d.ts +0 -23
- package/types/page.d.ts +0 -30
|
@@ -0,0 +1,451 @@
|
|
|
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 Error {}
|
|
9
|
+
* interface Locals {}
|
|
10
|
+
* interface PageData {}
|
|
11
|
+
* interface Platform {}
|
|
12
|
+
* }
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* By populating these interfaces, you will gain type safety when using `event.locals`, `event.platform`, and `data` from `load` functions.
|
|
16
|
+
*
|
|
17
|
+
* Note that since it's an ambient declaration file, you have to be careful when using `import` statements. Once you add an `import`
|
|
18
|
+
* at the top level, the declaration file is no longer considered ambient and you lose access to these typings in other files.
|
|
19
|
+
* To avoid this, either use the `import(...)` function:
|
|
20
|
+
*
|
|
21
|
+
* ```ts
|
|
22
|
+
* interface Locals {
|
|
23
|
+
* user: import('$lib/types').User;
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
* Or wrap the namespace with `declare global`:
|
|
27
|
+
* ```ts
|
|
28
|
+
* import { User } from '$lib/types';
|
|
29
|
+
*
|
|
30
|
+
* declare global {
|
|
31
|
+
* namespace App {
|
|
32
|
+
* interface Locals {
|
|
33
|
+
* user: User;
|
|
34
|
+
* }
|
|
35
|
+
* // ...
|
|
36
|
+
* }
|
|
37
|
+
* }
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
*/
|
|
41
|
+
declare namespace App {
|
|
42
|
+
/**
|
|
43
|
+
* Defines the common shape of expected and unexpected errors. Expected errors are thrown using the `error` function. Unexpected errors are handled by the `handleError` hooks which should return this shape.
|
|
44
|
+
*/
|
|
45
|
+
export interface Error {
|
|
46
|
+
message: string;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* The interface that defines `event.locals`, which can be accessed in [hooks](https://kit.svelte.dev/docs/hooks) (`handle`, and `handleError`), server-only `load` functions, and `+server.js` files.
|
|
51
|
+
*/
|
|
52
|
+
export interface Locals {}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Defines the common shape of the [$page.data store](https://kit.svelte.dev/docs/modules#$app-stores-page) - that is, the data that is shared between all pages.
|
|
56
|
+
* The `Load` and `ServerLoad` functions in `./$types` will be narrowed accordingly.
|
|
57
|
+
* Use optional properties for data that is only present on specific pages. Do not add an index signature (`[key: string]: any`).
|
|
58
|
+
*/
|
|
59
|
+
export interface PageData {}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* If your adapter provides [platform-specific context](https://kit.svelte.dev/docs/adapters#supported-environments-platform-specific-context) via `event.platform`, you can specify it here.
|
|
63
|
+
*/
|
|
64
|
+
export interface Platform {}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
declare module '$app/environment' {
|
|
68
|
+
/**
|
|
69
|
+
* `true` if the app is running in the browser.
|
|
70
|
+
*/
|
|
71
|
+
export const browser: boolean;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* SvelteKit analyses your app during the `build` step by running it. During this process, `building` is `true`. This also applies during prerendering.
|
|
75
|
+
*/
|
|
76
|
+
export const building: boolean;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Whether the dev server is running. This is not guaranteed to correspond to `NODE_ENV` or `MODE`.
|
|
80
|
+
*/
|
|
81
|
+
export const dev: boolean;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* The value of `config.kit.version.name`.
|
|
85
|
+
*/
|
|
86
|
+
export const version: string;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
declare module '$app/forms' {
|
|
90
|
+
import type { ActionResult } from '@sveltejs/kit';
|
|
91
|
+
|
|
92
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
93
|
+
|
|
94
|
+
// this is duplicated in @sveltejs/kit because create-svelte tests fail
|
|
95
|
+
// if we use the imported version. See https://github.com/sveltejs/kit/pull/7003#issuecomment-1330921789
|
|
96
|
+
// for why this happens (it's likely a bug in TypeScript, but one that is so rare that it's unlikely to be fixed)
|
|
97
|
+
type SubmitFunction<
|
|
98
|
+
Success extends Record<string, unknown> | undefined = Record<string, any>,
|
|
99
|
+
Invalid extends Record<string, unknown> | undefined = Record<string, any>
|
|
100
|
+
> = (input: {
|
|
101
|
+
action: URL;
|
|
102
|
+
data: FormData;
|
|
103
|
+
form: HTMLFormElement;
|
|
104
|
+
controller: AbortController;
|
|
105
|
+
cancel(): void;
|
|
106
|
+
}) => MaybePromise<
|
|
107
|
+
| void
|
|
108
|
+
| ((opts: {
|
|
109
|
+
form: HTMLFormElement;
|
|
110
|
+
action: URL;
|
|
111
|
+
result: ActionResult<Success, Invalid>;
|
|
112
|
+
/**
|
|
113
|
+
* Call this to get the default behavior of a form submission response.
|
|
114
|
+
* @param options Set `reset: false` if you don't want the `<form>` values to be reset after a successful submission.
|
|
115
|
+
*/
|
|
116
|
+
update(options?: { reset: boolean }): Promise<void>;
|
|
117
|
+
}) => void)
|
|
118
|
+
>;
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* This action enhances a `<form>` element that otherwise would work without JavaScript.
|
|
122
|
+
* @param form The form element
|
|
123
|
+
* @param options Callbacks for different states of the form lifecycle
|
|
124
|
+
*/
|
|
125
|
+
export function enhance<
|
|
126
|
+
Success extends Record<string, unknown> | undefined = Record<string, any>,
|
|
127
|
+
Invalid extends Record<string, unknown> | undefined = Record<string, any>
|
|
128
|
+
>(
|
|
129
|
+
form: HTMLFormElement,
|
|
130
|
+
/**
|
|
131
|
+
* Called upon submission with the given FormData and the `action` that should be triggered.
|
|
132
|
+
* If `cancel` is called, the form will not be submitted.
|
|
133
|
+
* You can use the abort `controller` to cancel the submission in case another one starts.
|
|
134
|
+
* If a function is returned, that function is called with the response from the server.
|
|
135
|
+
* If nothing is returned, the fallback will be used.
|
|
136
|
+
*
|
|
137
|
+
* If this function or its return value isn't set, it
|
|
138
|
+
* - falls back to updating the `form` prop with the returned data if the action is one same page as the form
|
|
139
|
+
* - updates `$page.status`
|
|
140
|
+
* - resets the `<form>` element and invalidates all data in case of successful submission with no redirect response
|
|
141
|
+
* - redirects in case of a redirect response
|
|
142
|
+
* - redirects to the nearest error page in case of an unexpected error
|
|
143
|
+
*
|
|
144
|
+
* If you provide a custom function with a callback and want to use the default behavior, invoke `update` in your callback.
|
|
145
|
+
*/
|
|
146
|
+
submit?: SubmitFunction<Success, Invalid>
|
|
147
|
+
): { destroy(): void };
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* This action updates the `form` property of the current page with the given data and updates `$page.status`.
|
|
151
|
+
* In case of an error, it redirects to the nearest error page.
|
|
152
|
+
*/
|
|
153
|
+
export function applyAction<
|
|
154
|
+
Success extends Record<string, unknown> | undefined = Record<string, any>,
|
|
155
|
+
Invalid extends Record<string, unknown> | undefined = Record<string, any>
|
|
156
|
+
>(result: ActionResult<Success, Invalid>): Promise<void>;
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Use this function to deserialize the response from a form submission.
|
|
160
|
+
* Usage:
|
|
161
|
+
*
|
|
162
|
+
* ```js
|
|
163
|
+
* import { deserialize } from '$app/forms';
|
|
164
|
+
*
|
|
165
|
+
* async function handleSubmit(event) {
|
|
166
|
+
* const response = await fetch('/form?/action', {
|
|
167
|
+
* method: 'POST',
|
|
168
|
+
* body: new FormData(event.target)
|
|
169
|
+
* });
|
|
170
|
+
*
|
|
171
|
+
* const result = deserialize(await response.text());
|
|
172
|
+
* // ...
|
|
173
|
+
* }
|
|
174
|
+
* ```
|
|
175
|
+
*/
|
|
176
|
+
export function deserialize<
|
|
177
|
+
Success extends Record<string, unknown> | undefined = Record<string, any>,
|
|
178
|
+
Invalid extends Record<string, unknown> | undefined = Record<string, any>
|
|
179
|
+
>(serialized: string): ActionResult<Success, Invalid>;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
declare module '$app/navigation' {
|
|
183
|
+
import { BeforeNavigate, AfterNavigate } from '@sveltejs/kit';
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* If called when the page is being updated following a navigation (in `onMount` or `afterNavigate` or an action, for example), this disables SvelteKit's built-in scroll handling.
|
|
187
|
+
* This is generally discouraged, since it breaks user expectations.
|
|
188
|
+
*/
|
|
189
|
+
export function disableScrollHandling(): void;
|
|
190
|
+
/**
|
|
191
|
+
* Returns a Promise that resolves when SvelteKit navigates (or fails to navigate, in which case the promise rejects) to the specified `url`.
|
|
192
|
+
*
|
|
193
|
+
* @param url Where to navigate to. Note that if you've set [`config.kit.paths.base`](https://kit.svelte.dev/docs/configuration#paths) and the URL is root-relative, you need to prepend the base path if you want to navigate within the app.
|
|
194
|
+
* @param opts Options related to the navigation
|
|
195
|
+
*/
|
|
196
|
+
export function goto(
|
|
197
|
+
url: string | URL,
|
|
198
|
+
opts?: {
|
|
199
|
+
/**
|
|
200
|
+
* If `true`, will replace the current `history` entry rather than creating a new one with `pushState`
|
|
201
|
+
*/
|
|
202
|
+
replaceState?: boolean;
|
|
203
|
+
/**
|
|
204
|
+
* If `true`, the browser will maintain its scroll position rather than scrolling to the top of the page after navigation
|
|
205
|
+
*/
|
|
206
|
+
noScroll?: boolean;
|
|
207
|
+
/**
|
|
208
|
+
* If `true`, the currently focused element will retain focus after navigation. Otherwise, focus will be reset to the body
|
|
209
|
+
*/
|
|
210
|
+
keepFocus?: boolean;
|
|
211
|
+
/**
|
|
212
|
+
* The state of the new/updated history entry
|
|
213
|
+
*/
|
|
214
|
+
state?: any;
|
|
215
|
+
/**
|
|
216
|
+
* If `true`, all `load` functions of the page will be rerun. See https://kit.svelte.dev/docs/load#invalidation for more info on invalidation.
|
|
217
|
+
*/
|
|
218
|
+
invalidateAll?: boolean;
|
|
219
|
+
}
|
|
220
|
+
): Promise<void>;
|
|
221
|
+
/**
|
|
222
|
+
* Causes any `load` functions belonging to the currently active page to re-run if they depend on the `url` in question, via `fetch` or `depends`. Returns a `Promise` that resolves when the page is subsequently updated.
|
|
223
|
+
*
|
|
224
|
+
* If the argument is given as a `string` or `URL`, it must resolve to the same URL that was passed to `fetch` or `depends` (including query parameters).
|
|
225
|
+
* To create a custom identifier, use a string beginning with `[a-z]+:` (e.g. `custom:state`) — this is a valid URL.
|
|
226
|
+
*
|
|
227
|
+
* The `function` argument can be used define a custom predicate. It receives the full `URL` and causes `load` to rerun if `true` is returned.
|
|
228
|
+
* This can be useful if you want to invalidate based on a pattern instead of a exact match.
|
|
229
|
+
*
|
|
230
|
+
* ```ts
|
|
231
|
+
* // Example: Match '/path' regardless of the query parameters
|
|
232
|
+
* import { invalidate } from '$app/navigation';
|
|
233
|
+
*
|
|
234
|
+
* invalidate((url) => url.pathname === '/path');
|
|
235
|
+
* ```
|
|
236
|
+
* @param url The invalidated URL
|
|
237
|
+
*/
|
|
238
|
+
export function invalidate(url: string | URL | ((url: URL) => boolean)): Promise<void>;
|
|
239
|
+
/**
|
|
240
|
+
* Causes all `load` functions belonging to the currently active page to re-run. Returns a `Promise` that resolves when the page is subsequently updated.
|
|
241
|
+
*/
|
|
242
|
+
export function invalidateAll(): Promise<void>;
|
|
243
|
+
/**
|
|
244
|
+
* Programmatically preloads the given page, which means
|
|
245
|
+
* 1. ensuring that the code for the page is loaded, and
|
|
246
|
+
* 2. calling the page's load function with the appropriate options.
|
|
247
|
+
*
|
|
248
|
+
* This is the same behaviour that SvelteKit triggers when the user taps or mouses over an `<a>` element with `data-sveltekit-preload-data`.
|
|
249
|
+
* If the next navigation is to `href`, the values returned from load will be used, making navigation instantaneous.
|
|
250
|
+
* Returns a Promise that resolves when the preload is complete.
|
|
251
|
+
*
|
|
252
|
+
* @param href Page to preload
|
|
253
|
+
*/
|
|
254
|
+
export function preloadData(href: string): Promise<void>;
|
|
255
|
+
/**
|
|
256
|
+
* Programmatically imports the code for routes that haven't yet been fetched.
|
|
257
|
+
* Typically, you might call this to speed up subsequent navigation.
|
|
258
|
+
*
|
|
259
|
+
* You can specify routes by any matching pathname such as `/about` (to match `src/routes/about.svelte`) or `/blog/*` (to match `src/routes/blog/[slug].svelte`).
|
|
260
|
+
*
|
|
261
|
+
* Unlike `preloadData`, this won't call `load` functions.
|
|
262
|
+
* Returns a Promise that resolves when the modules have been imported.
|
|
263
|
+
*/
|
|
264
|
+
export function preloadCode(...urls: string[]): Promise<void>;
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* A navigation interceptor that triggers before we navigate to a new URL, whether by clicking a link, calling `goto(...)`, or using the browser back/forward controls.
|
|
268
|
+
* Calling `cancel()` will prevent the navigation from completing.
|
|
269
|
+
*
|
|
270
|
+
* When a navigation isn't client side, `navigation.to.route.id` will be `null`.
|
|
271
|
+
*
|
|
272
|
+
* `beforeNavigate` must be called during a component initialization. It remains active as long as the component is mounted.
|
|
273
|
+
*/
|
|
274
|
+
export function beforeNavigate(callback: (navigation: BeforeNavigate) => void): void;
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* A lifecycle function that runs the supplied `callback` when the current component mounts, and also whenever we navigate to a new URL.
|
|
278
|
+
*
|
|
279
|
+
* `afterNavigate` must be called during a component initialization. It remains active as long as the component is mounted.
|
|
280
|
+
*/
|
|
281
|
+
export function afterNavigate(callback: (navigation: AfterNavigate) => void): void;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
declare module '$app/paths' {
|
|
285
|
+
/**
|
|
286
|
+
* A string that matches [`config.kit.paths.base`](https://kit.svelte.dev/docs/configuration#paths).
|
|
287
|
+
*
|
|
288
|
+
* Example usage: `<a href="{base}/your-page">Link</a>`
|
|
289
|
+
*/
|
|
290
|
+
export const base: `/${string}`;
|
|
291
|
+
/**
|
|
292
|
+
* An absolute path that matches [`config.kit.paths.assets`](https://kit.svelte.dev/docs/configuration#paths).
|
|
293
|
+
*
|
|
294
|
+
* > If a value for `config.kit.paths.assets` is specified, it will be replaced with `'/_svelte_kit_assets'` during `vite dev` or `vite preview`, since the assets don't yet live at their eventual URL.
|
|
295
|
+
*/
|
|
296
|
+
export const assets: `https://${string}` | `http://${string}`;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* Stores on the server are _contextual_ — they are added to the [context](https://svelte.dev/tutorial/context-api) of your root component. This means that `page` is unique to each request, rather than shared between multiple requests handled by the same server simultaneously.
|
|
301
|
+
*
|
|
302
|
+
* 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.
|
|
303
|
+
*
|
|
304
|
+
* In the browser, we don't need to worry about this, and stores can be accessed from anywhere. Code that will only ever run on the browser can refer to (or subscribe to) any of these stores at any time.
|
|
305
|
+
*/
|
|
306
|
+
declare module '$app/stores' {
|
|
307
|
+
import { Readable } from 'svelte/store';
|
|
308
|
+
import { Navigation, Page } from '@sveltejs/kit';
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* A readable store whose value contains page data.
|
|
312
|
+
*/
|
|
313
|
+
export const page: Readable<Page>;
|
|
314
|
+
/**
|
|
315
|
+
* A readable store.
|
|
316
|
+
* When navigating starts, its value is a `Navigation` object with `from`, `to`, `type` and (if `type === 'popstate'`) `delta` properties.
|
|
317
|
+
* When navigating finishes, its value reverts to `null`.
|
|
318
|
+
*/
|
|
319
|
+
export const navigating: Readable<Navigation | null>;
|
|
320
|
+
/**
|
|
321
|
+
* A readable store whose initial value is `false`. If [`version.pollInterval`](https://kit.svelte.dev/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.
|
|
322
|
+
*/
|
|
323
|
+
export const updated: Readable<boolean> & { check(): boolean };
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* A function that returns all of the contextual stores. On the server, this must be called during component initialization.
|
|
327
|
+
* Only use this if you need to defer store subscription until after the component has mounted, for some reason.
|
|
328
|
+
*/
|
|
329
|
+
export function getStores(): {
|
|
330
|
+
navigating: typeof navigating;
|
|
331
|
+
page: typeof page;
|
|
332
|
+
updated: typeof updated;
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* This module is only available to [service workers](https://kit.svelte.dev/docs/service-workers).
|
|
338
|
+
*/
|
|
339
|
+
declare module '$service-worker' {
|
|
340
|
+
/**
|
|
341
|
+
* An array of URL strings representing the files generated by Vite, suitable for caching with `cache.addAll(build)`.
|
|
342
|
+
* During development, this is an empty array.
|
|
343
|
+
*/
|
|
344
|
+
export const build: string[];
|
|
345
|
+
/**
|
|
346
|
+
* 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`](https://kit.svelte.dev/docs/configuration)
|
|
347
|
+
*/
|
|
348
|
+
export const files: string[];
|
|
349
|
+
/**
|
|
350
|
+
* An array of pathnames corresponding to prerendered pages and endpoints.
|
|
351
|
+
* During development, this is an empty array.
|
|
352
|
+
*/
|
|
353
|
+
export const prerendered: string[];
|
|
354
|
+
/**
|
|
355
|
+
* See [`config.kit.version`](https://kit.svelte.dev/docs/configuration#version). It's useful for generating unique cache names inside your service worker, so that a later deployment of your app can invalidate old caches.
|
|
356
|
+
*/
|
|
357
|
+
export const version: string;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
declare module '@sveltejs/kit/hooks' {
|
|
361
|
+
import { Handle } from '@sveltejs/kit';
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* A helper function for sequencing multiple `handle` calls in a middleware-like manner.
|
|
365
|
+
*
|
|
366
|
+
* ```js
|
|
367
|
+
* /// file: src/hooks.server.js
|
|
368
|
+
* import { sequence } from '@sveltejs/kit/hooks';
|
|
369
|
+
*
|
|
370
|
+
* /// type: import('@sveltejs/kit').Handle
|
|
371
|
+
* async function first({ event, resolve }) {
|
|
372
|
+
* console.log('first pre-processing');
|
|
373
|
+
* const result = await resolve(event, {
|
|
374
|
+
* transformPageChunk: ({ html }) => {
|
|
375
|
+
* // transforms are applied in reverse order
|
|
376
|
+
* console.log('first transform');
|
|
377
|
+
* return html;
|
|
378
|
+
* }
|
|
379
|
+
* });
|
|
380
|
+
* console.log('first post-processing');
|
|
381
|
+
* return result;
|
|
382
|
+
* }
|
|
383
|
+
*
|
|
384
|
+
* /// type: import('@sveltejs/kit').Handle
|
|
385
|
+
* async function second({ event, resolve }) {
|
|
386
|
+
* console.log('second pre-processing');
|
|
387
|
+
* const result = await resolve(event, {
|
|
388
|
+
* transformPageChunk: ({ html }) => {
|
|
389
|
+
* console.log('second transform');
|
|
390
|
+
* return html;
|
|
391
|
+
* }
|
|
392
|
+
* });
|
|
393
|
+
* console.log('second post-processing');
|
|
394
|
+
* return result;
|
|
395
|
+
* }
|
|
396
|
+
*
|
|
397
|
+
* export const handle = sequence(first, second);
|
|
398
|
+
* ```
|
|
399
|
+
*
|
|
400
|
+
* The example above would print:
|
|
401
|
+
*
|
|
402
|
+
* ```
|
|
403
|
+
* first pre-processing
|
|
404
|
+
* second pre-processing
|
|
405
|
+
* second transform
|
|
406
|
+
* first transform
|
|
407
|
+
* second post-processing
|
|
408
|
+
* first post-processing
|
|
409
|
+
* ```
|
|
410
|
+
*
|
|
411
|
+
* @param handlers The chain of `handle` functions
|
|
412
|
+
*/
|
|
413
|
+
export function sequence(...handlers: Handle[]): Handle;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
/**
|
|
417
|
+
* A polyfill for `fetch` and its related interfaces, used by adapters for environments that don't provide a native implementation.
|
|
418
|
+
*/
|
|
419
|
+
declare module '@sveltejs/kit/node/polyfills' {
|
|
420
|
+
/**
|
|
421
|
+
* Make various web APIs available as globals:
|
|
422
|
+
* - `crypto`
|
|
423
|
+
* - `fetch`
|
|
424
|
+
* - `Headers`
|
|
425
|
+
* - `Request`
|
|
426
|
+
* - `Response`
|
|
427
|
+
*/
|
|
428
|
+
export function installPolyfills(): void;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
/**
|
|
432
|
+
* Utilities used by adapters for Node-like environments.
|
|
433
|
+
*/
|
|
434
|
+
declare module '@sveltejs/kit/node' {
|
|
435
|
+
export function getRequest(opts: {
|
|
436
|
+
base: string;
|
|
437
|
+
request: import('http').IncomingMessage;
|
|
438
|
+
bodySizeLimit?: number;
|
|
439
|
+
}): Promise<Request>;
|
|
440
|
+
export function setResponse(res: import('http').ServerResponse, response: Response): void;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
declare module '@sveltejs/kit/vite' {
|
|
444
|
+
import { Plugin } from 'vite';
|
|
445
|
+
|
|
446
|
+
/**
|
|
447
|
+
* Returns the SvelteKit Vite plugins.
|
|
448
|
+
*/
|
|
449
|
+
export function sveltekit(): Promise<Plugin[]>;
|
|
450
|
+
export { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
|
|
451
|
+
}
|