@sveltejs/kit 1.0.0-next.49 → 1.0.0-next.490

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.
Files changed (123) hide show
  1. package/README.md +12 -9
  2. package/package.json +93 -66
  3. package/scripts/special-types/$env+dynamic+private.md +10 -0
  4. package/scripts/special-types/$env+dynamic+public.md +8 -0
  5. package/scripts/special-types/$env+static+private.md +19 -0
  6. package/scripts/special-types/$env+static+public.md +7 -0
  7. package/scripts/special-types/$lib.md +5 -0
  8. package/src/cli.js +112 -0
  9. package/src/constants.js +7 -0
  10. package/src/core/adapt/builder.js +206 -0
  11. package/src/core/adapt/index.js +31 -0
  12. package/src/core/config/default-error.html +56 -0
  13. package/src/core/config/index.js +110 -0
  14. package/src/core/config/options.js +504 -0
  15. package/src/core/config/types.d.ts +1 -0
  16. package/src/core/env.js +121 -0
  17. package/src/core/generate_manifest/index.js +92 -0
  18. package/src/core/prerender/crawl.js +198 -0
  19. package/src/core/prerender/entities.js +2252 -0
  20. package/src/core/prerender/prerender.js +431 -0
  21. package/src/core/prerender/queue.js +80 -0
  22. package/src/core/sync/create_manifest_data/index.js +467 -0
  23. package/src/core/sync/create_manifest_data/types.d.ts +37 -0
  24. package/src/core/sync/sync.js +59 -0
  25. package/src/core/sync/utils.js +33 -0
  26. package/src/core/sync/write_ambient.js +53 -0
  27. package/src/core/sync/write_client_manifest.js +106 -0
  28. package/src/core/sync/write_matchers.js +25 -0
  29. package/src/core/sync/write_root.js +91 -0
  30. package/src/core/sync/write_tsconfig.js +195 -0
  31. package/src/core/sync/write_types/index.js +678 -0
  32. package/src/core/utils.js +70 -0
  33. package/src/exports/hooks/index.js +1 -0
  34. package/src/exports/hooks/sequence.js +44 -0
  35. package/src/exports/index.js +45 -0
  36. package/src/exports/node/index.js +168 -0
  37. package/src/exports/node/polyfills.js +41 -0
  38. package/src/exports/vite/build/build_server.js +372 -0
  39. package/src/exports/vite/build/build_service_worker.js +90 -0
  40. package/src/exports/vite/build/utils.js +162 -0
  41. package/src/exports/vite/dev/index.js +576 -0
  42. package/src/exports/vite/graph_analysis/index.js +277 -0
  43. package/src/exports/vite/graph_analysis/types.d.ts +5 -0
  44. package/src/exports/vite/graph_analysis/utils.js +30 -0
  45. package/src/exports/vite/index.js +598 -0
  46. package/src/exports/vite/preview/index.js +189 -0
  47. package/src/exports/vite/types.d.ts +3 -0
  48. package/src/exports/vite/utils.js +157 -0
  49. package/src/runtime/app/env.js +1 -0
  50. package/src/runtime/app/environment.js +11 -0
  51. package/src/runtime/app/forms.js +108 -0
  52. package/src/runtime/app/navigation.js +23 -0
  53. package/src/runtime/app/paths.js +1 -0
  54. package/src/runtime/app/stores.js +102 -0
  55. package/src/runtime/client/ambient.d.ts +26 -0
  56. package/src/runtime/client/client.js +1581 -0
  57. package/src/runtime/client/fetcher.js +107 -0
  58. package/src/runtime/client/parse.js +60 -0
  59. package/src/runtime/client/singletons.js +21 -0
  60. package/src/runtime/client/start.js +37 -0
  61. package/src/runtime/client/types.d.ts +85 -0
  62. package/src/runtime/client/utils.js +159 -0
  63. package/src/runtime/components/error.svelte +16 -0
  64. package/{assets → src/runtime}/components/layout.svelte +0 -0
  65. package/src/runtime/control.js +98 -0
  66. package/src/runtime/env/dynamic/private.js +1 -0
  67. package/src/runtime/env/dynamic/public.js +1 -0
  68. package/src/runtime/env-private.js +6 -0
  69. package/src/runtime/env-public.js +6 -0
  70. package/src/runtime/env.js +6 -0
  71. package/src/runtime/hash.js +16 -0
  72. package/src/runtime/paths.js +11 -0
  73. package/src/runtime/server/cookie.js +115 -0
  74. package/src/runtime/server/data/index.js +136 -0
  75. package/src/runtime/server/endpoint.js +83 -0
  76. package/src/runtime/server/index.js +337 -0
  77. package/src/runtime/server/page/actions.js +243 -0
  78. package/src/runtime/server/page/crypto.js +239 -0
  79. package/src/runtime/server/page/csp.js +249 -0
  80. package/src/runtime/server/page/fetch.js +288 -0
  81. package/src/runtime/server/page/index.js +304 -0
  82. package/src/runtime/server/page/load_data.js +124 -0
  83. package/src/runtime/server/page/render.js +342 -0
  84. package/src/runtime/server/page/respond_with_error.js +104 -0
  85. package/src/runtime/server/page/serialize_data.js +87 -0
  86. package/src/runtime/server/page/types.d.ts +41 -0
  87. package/src/runtime/server/utils.js +179 -0
  88. package/src/utils/array.js +9 -0
  89. package/src/utils/error.js +22 -0
  90. package/src/utils/escape.js +46 -0
  91. package/src/utils/filesystem.js +137 -0
  92. package/src/utils/functions.js +16 -0
  93. package/src/utils/http.js +55 -0
  94. package/src/utils/misc.js +1 -0
  95. package/src/utils/routing.js +117 -0
  96. package/src/utils/unit_test.js +11 -0
  97. package/src/utils/url.js +142 -0
  98. package/svelte-kit.js +1 -1
  99. package/types/ambient.d.ts +426 -0
  100. package/types/index.d.ts +428 -0
  101. package/types/internal.d.ts +378 -0
  102. package/types/private.d.ts +209 -0
  103. package/CHANGELOG.md +0 -476
  104. package/assets/components/error.svelte +0 -13
  105. package/assets/runtime/app/env.js +0 -5
  106. package/assets/runtime/app/navigation.js +0 -44
  107. package/assets/runtime/app/paths.js +0 -1
  108. package/assets/runtime/app/stores.js +0 -93
  109. package/assets/runtime/chunks/utils.js +0 -22
  110. package/assets/runtime/internal/singletons.js +0 -23
  111. package/assets/runtime/internal/start.js +0 -773
  112. package/assets/runtime/paths.js +0 -12
  113. package/dist/chunks/index.js +0 -3517
  114. package/dist/chunks/index2.js +0 -587
  115. package/dist/chunks/index3.js +0 -246
  116. package/dist/chunks/index4.js +0 -530
  117. package/dist/chunks/index5.js +0 -763
  118. package/dist/chunks/index6.js +0 -322
  119. package/dist/chunks/standard.js +0 -99
  120. package/dist/chunks/utils.js +0 -83
  121. package/dist/cli.js +0 -553
  122. package/dist/ssr.js +0 -2584
  123. package/types.d.ts +0 -32
@@ -0,0 +1,142 @@
1
+ const absolute = /^([a-z]+:)?\/?\//;
2
+ const scheme = /^[a-z]+:/;
3
+
4
+ /**
5
+ * @param {string} base
6
+ * @param {string} path
7
+ */
8
+ export function resolve(base, path) {
9
+ if (scheme.test(path)) return path;
10
+
11
+ const base_match = absolute.exec(base);
12
+ const path_match = absolute.exec(path);
13
+
14
+ if (!base_match) {
15
+ throw new Error(`bad base path: "${base}"`);
16
+ }
17
+
18
+ const baseparts = path_match ? [] : base.slice(base_match[0].length).split('/');
19
+ const pathparts = path_match ? path.slice(path_match[0].length).split('/') : path.split('/');
20
+
21
+ baseparts.pop();
22
+
23
+ for (let i = 0; i < pathparts.length; i += 1) {
24
+ const part = pathparts[i];
25
+ if (part === '.') continue;
26
+ else if (part === '..') baseparts.pop();
27
+ else baseparts.push(part);
28
+ }
29
+
30
+ const prefix = (path_match && path_match[0]) || (base_match && base_match[0]) || '';
31
+
32
+ return `${prefix}${baseparts.join('/')}`;
33
+ }
34
+
35
+ /** @param {string} path */
36
+ export function is_root_relative(path) {
37
+ return path[0] === '/' && path[1] !== '/';
38
+ }
39
+
40
+ /**
41
+ * @param {string} path
42
+ * @param {import('types').TrailingSlash} trailing_slash
43
+ */
44
+ export function normalize_path(path, trailing_slash) {
45
+ if (path === '/' || trailing_slash === 'ignore') return path;
46
+
47
+ if (trailing_slash === 'never') {
48
+ return path.endsWith('/') ? path.slice(0, -1) : path;
49
+ } else if (trailing_slash === 'always' && !path.endsWith('/')) {
50
+ return path + '/';
51
+ }
52
+
53
+ return path;
54
+ }
55
+
56
+ /** @param {Record<string, string>} params */
57
+ export function decode_params(params) {
58
+ for (const key in params) {
59
+ // input has already been decoded by decodeURI
60
+ // now handle the rest that decodeURIComponent would do
61
+ params[key] = params[key]
62
+ .replace(/%23/g, '#')
63
+ .replace(/%3[Bb]/g, ';')
64
+ .replace(/%2[Cc]/g, ',')
65
+ .replace(/%2[Ff]/g, '/')
66
+ .replace(/%3[Ff]/g, '?')
67
+ .replace(/%3[Aa]/g, ':')
68
+ .replace(/%40/g, '@')
69
+ .replace(/%26/g, '&')
70
+ .replace(/%3[Dd]/g, '=')
71
+ .replace(/%2[Bb]/g, '+')
72
+ .replace(/%24/g, '$');
73
+ }
74
+
75
+ return params;
76
+ }
77
+
78
+ /**
79
+ * URL properties that could change during the lifetime of the page,
80
+ * which excludes things like `origin`
81
+ * @type {Array<keyof URL>}
82
+ */
83
+ const tracked_url_properties = ['href', 'pathname', 'search', 'searchParams', 'toString', 'toJSON'];
84
+
85
+ /**
86
+ * @param {URL} url
87
+ * @param {() => void} callback
88
+ */
89
+ export function make_trackable(url, callback) {
90
+ const tracked = new URL(url);
91
+
92
+ for (const property of tracked_url_properties) {
93
+ let value = tracked[property];
94
+
95
+ Object.defineProperty(tracked, property, {
96
+ get() {
97
+ callback();
98
+ return value;
99
+ },
100
+
101
+ enumerable: true,
102
+ configurable: true
103
+ });
104
+ }
105
+
106
+ // @ts-ignore
107
+ tracked[Symbol.for('nodejs.util.inspect.custom')] = (depth, opts, inspect) => {
108
+ return inspect(url, opts);
109
+ };
110
+
111
+ disable_hash(tracked);
112
+
113
+ return tracked;
114
+ }
115
+
116
+ /**
117
+ * Disallow access to `url.hash` on the server and in `load`
118
+ * @param {URL} url
119
+ */
120
+ export function disable_hash(url) {
121
+ Object.defineProperty(url, 'hash', {
122
+ get() {
123
+ throw new Error(
124
+ 'Cannot access event.url.hash. Consider using `$page.url.hash` inside a component instead'
125
+ );
126
+ }
127
+ });
128
+ }
129
+
130
+ /**
131
+ * Disallow access to `url.search` and `url.searchParams` during prerendering
132
+ * @param {URL} url
133
+ */
134
+ export function disable_search(url) {
135
+ for (const property of ['search', 'searchParams']) {
136
+ Object.defineProperty(url, property, {
137
+ get() {
138
+ throw new Error(`Cannot access url.${property} on a page with prerendering enabled`);
139
+ }
140
+ });
141
+ }
142
+ }
package/svelte-kit.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import './dist/cli.js';
2
+ import './src/cli.js';
@@ -0,0 +1,426 @@
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 PageData {}
11
+ *
12
+ * interface Platform {}
13
+ * }
14
+ * ```
15
+ *
16
+ * By populating these interfaces, you will gain type safety when using `event.locals`, `event.platform`, and `data` from `load` functions.
17
+ *
18
+ * Note that since it's an ambient declaration file, you have to be careful when using `import` statements. Once you add an `import`
19
+ * at the top level, the declaration file is no longer considered ambient and you lose access to these typings in other files.
20
+ * To avoid this, either use the `import(...)` function:
21
+ *
22
+ * ```ts
23
+ * interface Locals {
24
+ * user: import('$lib/types').User;
25
+ * }
26
+ * ```
27
+ * Or wrap the namespace with `declare global`:
28
+ * ```ts
29
+ * import { User } from '$lib/types';
30
+ *
31
+ * declare global {
32
+ * namespace App {
33
+ * interface Locals {
34
+ * user: User;
35
+ * }
36
+ * // ...
37
+ * }
38
+ * }
39
+ * ```
40
+ *
41
+ */
42
+ declare namespace App {
43
+ /**
44
+ * 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.
45
+ */
46
+ export interface Locals {}
47
+
48
+ /**
49
+ * 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.
50
+ * The `Load` and `ServerLoad` functions in `./$types` will be narrowed accordingly.
51
+ * Use optional properties for data that is only present on specific pages. Do not add an index signature (`[key: string]: any`).
52
+ */
53
+ export interface PageData {}
54
+
55
+ /**
56
+ * 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.
57
+ */
58
+ export interface Platform {}
59
+
60
+ /**
61
+ * 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.
62
+ */
63
+ export interface PageError {
64
+ message: string;
65
+ }
66
+ }
67
+
68
+ /**
69
+ * ```ts
70
+ * import { browser, dev, prerendering } from '$app/environment';
71
+ * ```
72
+ */
73
+ declare module '$app/environment' {
74
+ /**
75
+ * `true` if the app is running in the browser.
76
+ */
77
+ export const browser: boolean;
78
+
79
+ /**
80
+ * Whether the dev server is running. This is not guaranteed to correspond to `NODE_ENV` or `MODE`.
81
+ */
82
+ export const dev: boolean;
83
+
84
+ /**
85
+ * `true` when prerendering, `false` otherwise.
86
+ */
87
+ export const prerendering: boolean;
88
+ }
89
+
90
+ /**
91
+ * ```ts
92
+ * import { enhance, applyAction } from '$app/forms';
93
+ * ```
94
+ */
95
+ declare module '$app/forms' {
96
+ import type { ActionResult } from '@sveltejs/kit';
97
+
98
+ export type SubmitFunction<
99
+ Success extends Record<string, unknown> | undefined = Record<string, any>,
100
+ Invalid extends Record<string, unknown> | undefined = Record<string, any>
101
+ > = (input: {
102
+ action: URL;
103
+ data: FormData;
104
+ form: HTMLFormElement;
105
+ controller: AbortController;
106
+ cancel: () => void;
107
+ }) =>
108
+ | void
109
+ | ((opts: {
110
+ form: HTMLFormElement;
111
+ action: URL;
112
+ result: ActionResult<Success, Invalid>;
113
+ }) => void);
114
+
115
+ /**
116
+ * This action enhances a `<form>` element that otherwise would work without JavaScript.
117
+ * @param form The form element
118
+ * @param options Callbacks for different states of the form lifecycle
119
+ */
120
+ export function enhance<
121
+ Success extends Record<string, unknown> | undefined = Record<string, any>,
122
+ Invalid extends Record<string, unknown> | undefined = Record<string, any>
123
+ >(
124
+ form: HTMLFormElement,
125
+ /**
126
+ * Called upon submission with the given FormData and the `action` that should be triggered.
127
+ * If `cancel` is called, the form will not be submitted.
128
+ * You can use the abort `controller` to cancel the submission in case another one starts.
129
+ * If a function is returned, that function is called with the response from the server.
130
+ * If nothing is returned, the fallback will be used.
131
+ *
132
+ * If this function or its return value isn't set, it
133
+ * - falls back to updating the `form` prop with the returned data if the action is one same page as the form
134
+ * - updates `$page.status`
135
+ * - invalidates all data in case of successful submission with no redirect response
136
+ * - redirects in case of a redirect response
137
+ * - redirects to the nearest error page in case of an unexpected error
138
+ */
139
+ submit?: SubmitFunction<Success, Invalid>
140
+ ): { destroy: () => void };
141
+
142
+ /**
143
+ * This action updates the `form` property of the current page with the given data and updates `$page.status`.
144
+ * In case of an error, it redirects to the nearest error page.
145
+ */
146
+ export function applyAction<
147
+ Success extends Record<string, unknown> | undefined = Record<string, any>,
148
+ Invalid extends Record<string, unknown> | undefined = Record<string, any>
149
+ >(result: ActionResult<Success, Invalid>): Promise<void>;
150
+ }
151
+
152
+ /**
153
+ * ```ts
154
+ * import {
155
+ * afterNavigate,
156
+ * beforeNavigate,
157
+ * disableScrollHandling,
158
+ * goto,
159
+ * invalidate,
160
+ * invalidateAll,
161
+ * prefetch,
162
+ * prefetchRoutes
163
+ * } from '$app/navigation';
164
+ * ```
165
+ */
166
+ declare module '$app/navigation' {
167
+ import { Navigation } from '@sveltejs/kit';
168
+
169
+ /**
170
+ * 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.
171
+ * This is generally discouraged, since it breaks user expectations.
172
+ */
173
+ export function disableScrollHandling(): void;
174
+ /**
175
+ * Returns a Promise that resolves when SvelteKit navigates (or fails to navigate, in which case the promise rejects) to the specified `url`.
176
+ *
177
+ * @param url Where to navigate to
178
+ * @param opts.replaceState If `true`, will replace the current `history` entry rather than creating a new one with `pushState`
179
+ * @param opts.noscroll If `true`, the browser will maintain its scroll position rather than scrolling to the top of the page after navigation
180
+ * @param opts.keepfocus If `true`, the currently focused element will retain focus after navigation. Otherwise, focus will be reset to the body
181
+ * @param opts.state The state of the new/updated history entry
182
+ */
183
+ export function goto(
184
+ url: string | URL,
185
+ opts?: { replaceState?: boolean; noscroll?: boolean; keepfocus?: boolean; state?: any }
186
+ ): Promise<void>;
187
+ /**
188
+ * 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.
189
+ *
190
+ * 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).
191
+ * To create a custom identifier, use a string beginning with `[a-z]+:` (e.g. `custom:state`) — this is a valid URL.
192
+ *
193
+ * The `function` argument can be used define a custom predicate. It receives the full `URL` and causes `load` to rerun if `true` is returned.
194
+ * This can be useful if you want to invalidate based on a pattern instead of a exact match.
195
+ *
196
+ * ```ts
197
+ * // Example: Match '/path' regardless of the query parameters
198
+ * invalidate((url) => url.pathname === '/path');
199
+ * ```
200
+ * @param url The invalidated URL
201
+ */
202
+ export function invalidate(url: string | URL | ((url: URL) => boolean)): Promise<void>;
203
+ /**
204
+ * Causes all `load` functions belonging to the currently active page to re-run. Returns a `Promise` that resolves when the page is subsequently updated.
205
+ */
206
+ export function invalidateAll(): Promise<void>;
207
+ /**
208
+ * Programmatically prefetches the given page, which means
209
+ * 1. ensuring that the code for the page is loaded, and
210
+ * 2. calling the page's load function with the appropriate options.
211
+ *
212
+ * This is the same behaviour that SvelteKit triggers when the user taps or mouses over an `<a>` element with `data-sveltekit-prefetch`.
213
+ * If the next navigation is to `href`, the values returned from load will be used, making navigation instantaneous.
214
+ * Returns a Promise that resolves when the prefetch is complete.
215
+ *
216
+ * @param href Page to prefetch
217
+ */
218
+ export function prefetch(href: string): Promise<void>;
219
+ /**
220
+ * Programmatically prefetches the code for routes that haven't yet been fetched.
221
+ * Typically, you might call this to speed up subsequent navigation.
222
+ *
223
+ * If no argument is given, all routes will be fetched, otherwise you can specify routes by any matching pathname
224
+ * such as `/about` (to match `src/routes/about.svelte`) or `/blog/*` (to match `src/routes/blog/[slug].svelte`).
225
+ *
226
+ * Unlike prefetch, this won't call load for individual pages.
227
+ * Returns a Promise that resolves when the routes have been prefetched.
228
+ */
229
+ export function prefetchRoutes(routes?: string[]): Promise<void>;
230
+
231
+ /**
232
+ * 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.
233
+ * Calling `cancel()` will prevent the navigation from completing.
234
+ *
235
+ * When navigating to an external URL, `navigation.to` will be `null`.
236
+ *
237
+ * `beforeNavigate` must be called during a component initialization. It remains active as long as the component is mounted.
238
+ */
239
+ export function beforeNavigate(
240
+ callback: (navigation: Navigation & { cancel: () => void }) => void
241
+ ): void;
242
+
243
+ /**
244
+ * A lifecycle function that runs the supplied `callback` when the current component mounts, and also whenever we navigate to a new URL.
245
+ *
246
+ * `afterNavigate` must be called during a component initialization. It remains active as long as the component is mounted.
247
+ */
248
+ export function afterNavigate(callback: (navigation: Navigation) => void): void;
249
+ }
250
+
251
+ /**
252
+ * ```ts
253
+ * import { base, assets } from '$app/paths';
254
+ * ```
255
+ */
256
+ declare module '$app/paths' {
257
+ /**
258
+ * A string that matches [`config.kit.paths.base`](https://kit.svelte.dev/docs/configuration#paths). It must start, but not end with `/` (e.g. `/base-path`), unless it is the empty string.
259
+ */
260
+ export const base: `/${string}`;
261
+ /**
262
+ * An absolute path that matches [`config.kit.paths.assets`](https://kit.svelte.dev/docs/configuration#paths).
263
+ *
264
+ * > 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.
265
+ */
266
+ export const assets: `https://${string}` | `http://${string}`;
267
+ }
268
+
269
+ /**
270
+ * ```ts
271
+ * import { getStores, navigating, page, updated } from '$app/stores';
272
+ * ```
273
+ *
274
+ * 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.
275
+ *
276
+ * 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.
277
+ *
278
+ * 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.
279
+ */
280
+ declare module '$app/stores' {
281
+ import { Readable } from 'svelte/store';
282
+ import { Navigation, Page } from '@sveltejs/kit';
283
+
284
+ /**
285
+ * A readable store whose value contains page data.
286
+ */
287
+ export const page: Readable<Page>;
288
+ /**
289
+ * A readable store.
290
+ * When navigating starts, its value is a `Navigation` object with `from`, `to`, `type` and (if `type === 'popstate'`) `delta` properties.
291
+ * When navigating finishes, its value reverts to `null`.
292
+ */
293
+ export const navigating: Readable<Navigation | null>;
294
+ /**
295
+ * 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.
296
+ */
297
+ export const updated: Readable<boolean> & { check: () => boolean };
298
+
299
+ /**
300
+ * A function that returns all of the contextual stores. On the server, this must be called during component initialization.
301
+ * Only use this if you need to defer store subscription until after the component has mounted, for some reason.
302
+ */
303
+ export function getStores(): {
304
+ navigating: typeof navigating;
305
+ page: typeof page;
306
+ updated: typeof updated;
307
+ };
308
+ }
309
+
310
+ /**
311
+ * ```ts
312
+ * import { build, files, prerendered, version } from '$service-worker';
313
+ * ```
314
+ *
315
+ * This module is only available to [service workers](https://kit.svelte.dev/docs/service-workers).
316
+ */
317
+ declare module '$service-worker' {
318
+ /**
319
+ * An array of URL strings representing the files generated by Vite, suitable for caching with `cache.addAll(build)`.
320
+ */
321
+ export const build: string[];
322
+ /**
323
+ * 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)
324
+ */
325
+ export const files: string[];
326
+ /**
327
+ * An array of pathnames corresponding to prerendered pages and endpoints.
328
+ */
329
+ export const prerendered: string[];
330
+ /**
331
+ * 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.
332
+ */
333
+ export const version: string;
334
+ }
335
+
336
+ declare module '@sveltejs/kit/hooks' {
337
+ import { Handle } from '@sveltejs/kit';
338
+
339
+ /**
340
+ * A helper function for sequencing multiple `handle` calls in a middleware-like manner.
341
+ *
342
+ * ```js
343
+ * /// file: src/hooks.js
344
+ * import { sequence } from '@sveltejs/kit/hooks';
345
+ *
346
+ * /** @type {import('@sveltejs/kit').Handle} *\/
347
+ * async function first({ event, resolve }) {
348
+ * console.log('first pre-processing');
349
+ * const result = await resolve(event, {
350
+ * transformPageChunk: ({ html }) => {
351
+ * // transforms are applied in reverse order
352
+ * console.log('first transform');
353
+ * return html;
354
+ * }
355
+ * });
356
+ * console.log('first post-processing');
357
+ * return result;
358
+ * }
359
+ *
360
+ * /** @type {import('@sveltejs/kit').Handle} *\/
361
+ * async function second({ event, resolve }) {
362
+ * console.log('second pre-processing');
363
+ * const result = await resolve(event, {
364
+ * transformPageChunk: ({ html }) => {
365
+ * console.log('second transform');
366
+ * return html;
367
+ * }
368
+ * });
369
+ * console.log('second post-processing');
370
+ * return result;
371
+ * }
372
+ *
373
+ * export const handle = sequence(first, second);
374
+ * ```
375
+ *
376
+ * The example above would print:
377
+ *
378
+ * ```
379
+ * first pre-processing
380
+ * second pre-processing
381
+ * second transform
382
+ * first transform
383
+ * second post-processing
384
+ * first post-processing
385
+ * ```
386
+ *
387
+ * @param handlers The chain of `handle` functions
388
+ */
389
+ export function sequence(...handlers: Handle[]): Handle;
390
+ }
391
+
392
+ /**
393
+ * A polyfill for `fetch` and its related interfaces, used by adapters for environments that don't provide a native implementation.
394
+ */
395
+ declare module '@sveltejs/kit/node/polyfills' {
396
+ /**
397
+ * Make various web APIs available as globals:
398
+ * - `crypto`
399
+ * - `fetch`
400
+ * - `Headers`
401
+ * - `Request`
402
+ * - `Response`
403
+ */
404
+ export function installPolyfills(): void;
405
+ }
406
+
407
+ /**
408
+ * Utilities used by adapters for Node-like environments.
409
+ */
410
+ declare module '@sveltejs/kit/node' {
411
+ export function getRequest(opts: {
412
+ base: string;
413
+ request: import('http').IncomingMessage;
414
+ bodySizeLimit?: number;
415
+ }): Promise<Request>;
416
+ export function setResponse(res: import('http').ServerResponse, response: Response): void;
417
+ }
418
+
419
+ declare module '@sveltejs/kit/vite' {
420
+ import { Plugin } from 'vite';
421
+
422
+ /**
423
+ * Returns the SvelteKit Vite plugins.
424
+ */
425
+ export function sveltekit(): Plugin[];
426
+ }