@sveltejs/kit 2.29.1 → 2.30.1
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/package.json +1 -1
- package/src/core/config/options.js +3 -0
- package/src/core/sync/sync.js +3 -2
- package/src/core/sync/write_non_ambient.js +78 -2
- package/src/core/sync/write_server.js +1 -0
- package/src/core/sync/write_types/index.js +0 -72
- package/src/exports/public.d.ts +24 -8
- package/src/runtime/app/paths/index.js +3 -1
- package/src/runtime/app/paths/types.d.ts +0 -1
- package/src/runtime/app/server/remote/shared.js +1 -1
- package/src/runtime/client/remote-functions/form.svelte.js +1 -1
- package/src/runtime/server/page/render.js +8 -1
- package/src/types/ambient.d.ts +54 -0
- package/src/types/internal.d.ts +1 -0
- package/src/version.js +1 -1
- package/types/index.d.ts +78 -7
- package/types/index.d.ts.map +1 -1
package/package.json
CHANGED
|
@@ -271,6 +271,9 @@ const options = object(
|
|
|
271
271
|
|
|
272
272
|
serviceWorker: object({
|
|
273
273
|
register: boolean(true),
|
|
274
|
+
// options could be undefined but if it is defined we only validate that
|
|
275
|
+
// it's an object since the type comes from the browser itself
|
|
276
|
+
options: validate(undefined, object({}, true)),
|
|
274
277
|
files: fun((filename) => !/\.DS_Store/.test(filename))
|
|
275
278
|
}),
|
|
276
279
|
|
package/src/core/sync/sync.js
CHANGED
|
@@ -9,14 +9,13 @@ import { write_non_ambient } from './write_non_ambient.js';
|
|
|
9
9
|
import { write_server } from './write_server.js';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
|
-
* Initialize SvelteKit's generated files.
|
|
12
|
+
* Initialize SvelteKit's generated files that only depend on the config and mode.
|
|
13
13
|
* @param {import('types').ValidatedConfig} config
|
|
14
14
|
* @param {string} mode
|
|
15
15
|
*/
|
|
16
16
|
export function init(config, mode) {
|
|
17
17
|
write_tsconfig(config.kit);
|
|
18
18
|
write_ambient(config.kit, mode);
|
|
19
|
-
write_non_ambient(config.kit);
|
|
20
19
|
}
|
|
21
20
|
|
|
22
21
|
/**
|
|
@@ -32,6 +31,7 @@ export function create(config) {
|
|
|
32
31
|
write_server(config, output);
|
|
33
32
|
write_root(manifest_data, output);
|
|
34
33
|
write_all_types(config, manifest_data);
|
|
34
|
+
write_non_ambient(config.kit, manifest_data);
|
|
35
35
|
|
|
36
36
|
return { manifest_data };
|
|
37
37
|
}
|
|
@@ -67,6 +67,7 @@ export function all_types(config, mode) {
|
|
|
67
67
|
init(config, mode);
|
|
68
68
|
const manifest_data = create_manifest_data({ config });
|
|
69
69
|
write_all_types(config, manifest_data);
|
|
70
|
+
write_non_ambient(config.kit, manifest_data);
|
|
70
71
|
}
|
|
71
72
|
|
|
72
73
|
/**
|
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
import { GENERATED_COMMENT } from '../../constants.js';
|
|
3
3
|
import { write_if_changed } from './utils.js';
|
|
4
|
+
import { s } from '../../utils/misc.js';
|
|
5
|
+
import { get_route_segments } from '../../utils/routing.js';
|
|
6
|
+
|
|
7
|
+
const replace_optional_params = (/** @type {string} */ id) =>
|
|
8
|
+
id.replace(/\/\[\[[^\]]+\]\]/g, '${string}');
|
|
9
|
+
const replace_required_params = (/** @type {string} */ id) =>
|
|
10
|
+
id.replace(/\/\[[^\]]+\]/g, '/${string}');
|
|
11
|
+
/** Convert route ID to pathname by removing layout groups */
|
|
12
|
+
const remove_group_segments = (/** @type {string} */ id) => {
|
|
13
|
+
return '/' + get_route_segments(id).join('/');
|
|
14
|
+
};
|
|
4
15
|
|
|
5
16
|
// `declare module "svelte/elements"` needs to happen in a non-ambient module, and dts-buddy generates one big ambient module,
|
|
6
17
|
// so we can't add it there - therefore generate the typings ourselves here.
|
|
@@ -33,10 +44,75 @@ declare module "svelte/elements" {
|
|
|
33
44
|
export {};
|
|
34
45
|
`;
|
|
35
46
|
|
|
47
|
+
/**
|
|
48
|
+
* Generate app types interface extension
|
|
49
|
+
* @param {import('types').ManifestData} manifest_data
|
|
50
|
+
*/
|
|
51
|
+
function generate_app_types(manifest_data) {
|
|
52
|
+
/** @type {Set<string>} */
|
|
53
|
+
const pathnames = new Set();
|
|
54
|
+
|
|
55
|
+
/** @type {string[]} */
|
|
56
|
+
const dynamic_routes = [];
|
|
57
|
+
|
|
58
|
+
/** @type {string[]} */
|
|
59
|
+
const layouts = [];
|
|
60
|
+
|
|
61
|
+
for (const route of manifest_data.routes) {
|
|
62
|
+
if (route.params.length > 0) {
|
|
63
|
+
const params = route.params.map((p) => `${p.name}${p.optional ? '?:' : ':'} string`);
|
|
64
|
+
const route_type = `${s(route.id)}: { ${params.join('; ')} }`;
|
|
65
|
+
|
|
66
|
+
dynamic_routes.push(route_type);
|
|
67
|
+
|
|
68
|
+
const pathname = remove_group_segments(route.id);
|
|
69
|
+
pathnames.add(`\`${replace_required_params(replace_optional_params(pathname))}\` & {}`);
|
|
70
|
+
} else {
|
|
71
|
+
const pathname = remove_group_segments(route.id);
|
|
72
|
+
pathnames.add(s(pathname));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** @type {Map<string, boolean>} */
|
|
76
|
+
const child_params = new Map(route.params.map((p) => [p.name, p.optional]));
|
|
77
|
+
|
|
78
|
+
for (const child of manifest_data.routes.filter((r) => r.id.startsWith(route.id))) {
|
|
79
|
+
for (const p of child.params) {
|
|
80
|
+
if (!child_params.has(p.name)) {
|
|
81
|
+
child_params.set(p.name, true); // always optional
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const layout_params = Array.from(child_params)
|
|
87
|
+
.map(([name, optional]) => `${name}${optional ? '?:' : ':'} string`)
|
|
88
|
+
.join('; ');
|
|
89
|
+
|
|
90
|
+
const layout_type = `${s(route.id)}: ${layout_params.length > 0 ? `{ ${layout_params} }` : 'Record<string, never>'}`;
|
|
91
|
+
layouts.push(layout_type);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return [
|
|
95
|
+
'declare module "$app/types" {',
|
|
96
|
+
'\texport interface AppTypes {',
|
|
97
|
+
`\t\tRouteId(): ${manifest_data.routes.map((r) => s(r.id)).join(' | ')};`,
|
|
98
|
+
`\t\tRouteParams(): {\n\t\t\t${dynamic_routes.join(';\n\t\t\t')}\n\t\t};`,
|
|
99
|
+
`\t\tLayoutParams(): {\n\t\t\t${layouts.join(';\n\t\t\t')}\n\t\t};`,
|
|
100
|
+
`\t\tPathname(): ${Array.from(pathnames).join(' | ')};`,
|
|
101
|
+
'\t\tResolvedPathname(): `${"" | `/${string}`}${ReturnType<AppTypes[\'Pathname\']>}`;',
|
|
102
|
+
`\t\tAsset(): ${manifest_data.assets.map((asset) => s('/' + asset.file)).join(' | ') || 'never'};`,
|
|
103
|
+
'\t}',
|
|
104
|
+
'}'
|
|
105
|
+
].join('\n');
|
|
106
|
+
}
|
|
107
|
+
|
|
36
108
|
/**
|
|
37
109
|
* Writes non-ambient declarations to the output directory
|
|
38
110
|
* @param {import('types').ValidatedKitConfig} config
|
|
111
|
+
* @param {import('types').ManifestData} manifest_data
|
|
39
112
|
*/
|
|
40
|
-
export function write_non_ambient(config) {
|
|
41
|
-
|
|
113
|
+
export function write_non_ambient(config, manifest_data) {
|
|
114
|
+
const app_types = generate_app_types(manifest_data);
|
|
115
|
+
const content = [template, app_types].join('\n\n');
|
|
116
|
+
|
|
117
|
+
write_if_changed(path.join(config.outDir, 'non-ambient.d.ts'), content);
|
|
42
118
|
}
|
|
@@ -46,6 +46,7 @@ export const options = {
|
|
|
46
46
|
preload_strategy: ${s(config.kit.output.preloadStrategy)},
|
|
47
47
|
root,
|
|
48
48
|
service_worker: ${has_service_worker},
|
|
49
|
+
service_worker_options: ${config.kit.serviceWorker.register ? s(config.kit.serviceWorker.options) : 'null'},
|
|
49
50
|
templates: {
|
|
50
51
|
app: ({ head, body, assets, nonce, env }) => ${s(template)
|
|
51
52
|
.replace('%sveltekit.head%', '" + head + "')
|
|
@@ -5,19 +5,8 @@ import MagicString from 'magic-string';
|
|
|
5
5
|
import { posixify, rimraf, walk } from '../../../utils/filesystem.js';
|
|
6
6
|
import { compact } from '../../../utils/array.js';
|
|
7
7
|
import { ts } from '../ts.js';
|
|
8
|
-
import { s } from '../../../utils/misc.js';
|
|
9
|
-
import { get_route_segments } from '../../../utils/routing.js';
|
|
10
|
-
|
|
11
8
|
const remove_relative_parent_traversals = (/** @type {string} */ path) =>
|
|
12
9
|
path.replace(/\.\.\//g, '');
|
|
13
|
-
const replace_optional_params = (/** @type {string} */ id) =>
|
|
14
|
-
id.replace(/\/\[\[[^\]]+\]\]/g, '${string}');
|
|
15
|
-
const replace_required_params = (/** @type {string} */ id) =>
|
|
16
|
-
id.replace(/\/\[[^\]]+\]/g, '/${string}');
|
|
17
|
-
/** Convert route ID to pathname by removing layout groups */
|
|
18
|
-
const remove_group_segments = (/** @type {string} */ id) => {
|
|
19
|
-
return '/' + get_route_segments(id).join('/');
|
|
20
|
-
};
|
|
21
10
|
const is_whitespace = (/** @type {string} */ char) => /\s/.test(char);
|
|
22
11
|
|
|
23
12
|
/**
|
|
@@ -65,67 +54,6 @@ export function write_all_types(config, manifest_data) {
|
|
|
65
54
|
}
|
|
66
55
|
}
|
|
67
56
|
|
|
68
|
-
/** @type {Set<string>} */
|
|
69
|
-
const pathnames = new Set();
|
|
70
|
-
|
|
71
|
-
/** @type {string[]} */
|
|
72
|
-
const dynamic_routes = [];
|
|
73
|
-
|
|
74
|
-
/** @type {string[]} */
|
|
75
|
-
const layouts = [];
|
|
76
|
-
|
|
77
|
-
for (const route of manifest_data.routes) {
|
|
78
|
-
if (route.params.length > 0) {
|
|
79
|
-
const params = route.params.map((p) => `${p.name}${p.optional ? '?:' : ':'} string`);
|
|
80
|
-
const route_type = `${s(route.id)}: { ${params.join('; ')} }`;
|
|
81
|
-
|
|
82
|
-
dynamic_routes.push(route_type);
|
|
83
|
-
|
|
84
|
-
const pathname = remove_group_segments(route.id);
|
|
85
|
-
pathnames.add(`\`${replace_required_params(replace_optional_params(pathname))}\` & {}`);
|
|
86
|
-
} else {
|
|
87
|
-
const pathname = remove_group_segments(route.id);
|
|
88
|
-
pathnames.add(s(pathname));
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/** @type {Map<string, boolean>} */
|
|
92
|
-
const child_params = new Map(route.params.map((p) => [p.name, p.optional]));
|
|
93
|
-
|
|
94
|
-
for (const child of manifest_data.routes.filter((r) => r.id.startsWith(route.id))) {
|
|
95
|
-
for (const p of child.params) {
|
|
96
|
-
if (!child_params.has(p.name)) {
|
|
97
|
-
child_params.set(p.name, true); // always optional
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
const layout_params = Array.from(child_params)
|
|
103
|
-
.map(([name, optional]) => `${name}${optional ? '?:' : ':'} string`)
|
|
104
|
-
.join('; ');
|
|
105
|
-
|
|
106
|
-
const layout_type = `${s(route.id)}: ${layout_params.length > 0 ? `{ ${layout_params} }` : 'undefined'}`;
|
|
107
|
-
layouts.push(layout_type);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
try {
|
|
111
|
-
fs.mkdirSync(types_dir, { recursive: true });
|
|
112
|
-
} catch {}
|
|
113
|
-
|
|
114
|
-
fs.writeFileSync(
|
|
115
|
-
`${types_dir}/index.d.ts`,
|
|
116
|
-
[
|
|
117
|
-
`type DynamicRoutes = {\n\t${dynamic_routes.join(';\n\t')}\n};`,
|
|
118
|
-
`type Layouts = {\n\t${layouts.join(';\n\t')}\n};`,
|
|
119
|
-
// we enumerate these rather than doing `keyof Routes` so that the list is visible on hover
|
|
120
|
-
`export type RouteId = ${manifest_data.routes.map((r) => s(r.id)).join(' | ')};`,
|
|
121
|
-
'export type RouteParams<T extends RouteId> = T extends keyof DynamicRoutes ? DynamicRoutes[T] : Record<string, never>;',
|
|
122
|
-
'export type LayoutParams<T extends RouteId> = Layouts[T] | Record<string, never>;',
|
|
123
|
-
`export type Pathname = ${Array.from(pathnames).join(' | ')};`,
|
|
124
|
-
'export type ResolvedPathname = `${"" | `/${string}`}${Pathname}`;',
|
|
125
|
-
`export type Asset = ${manifest_data.assets.map((asset) => s('/' + asset.file)).join(' | ') || 'never'};`
|
|
126
|
-
].join('\n\n')
|
|
127
|
-
);
|
|
128
|
-
|
|
129
57
|
// Read/write meta data on each invocation, not once per node process,
|
|
130
58
|
// it could be invoked by another process in the meantime.
|
|
131
59
|
const meta_data_file = `${types_dir}/route_meta_data.json`;
|
package/src/exports/public.d.ts
CHANGED
|
@@ -23,7 +23,6 @@ import {
|
|
|
23
23
|
RouteId as AppRouteId,
|
|
24
24
|
LayoutParams as AppLayoutParams,
|
|
25
25
|
ResolvedPathname
|
|
26
|
-
// @ts-ignore
|
|
27
26
|
} from '$app/types';
|
|
28
27
|
|
|
29
28
|
export { PrerenderOption } from '../types/private.js';
|
|
@@ -710,21 +709,38 @@ export interface KitConfig {
|
|
|
710
709
|
resolution?: 'client' | 'server';
|
|
711
710
|
};
|
|
712
711
|
serviceWorker?: {
|
|
713
|
-
/**
|
|
714
|
-
* Whether to automatically register the service worker, if it exists.
|
|
715
|
-
* @default true
|
|
716
|
-
*/
|
|
717
|
-
register?: boolean;
|
|
718
712
|
/**
|
|
719
713
|
* Determine which files in your `static` directory will be available in `$service-worker.files`.
|
|
720
714
|
* @default (filename) => !/\.DS_Store/.test(filename)
|
|
721
715
|
*/
|
|
722
|
-
files
|
|
723
|
-
}
|
|
716
|
+
files?: (file: string) => boolean;
|
|
717
|
+
} & (
|
|
718
|
+
| {
|
|
719
|
+
/**
|
|
720
|
+
* Whether to automatically register the service worker, if it exists.
|
|
721
|
+
* @default true
|
|
722
|
+
*/
|
|
723
|
+
register: true;
|
|
724
|
+
/**
|
|
725
|
+
* Options for serviceWorker.register("...", options);
|
|
726
|
+
*/
|
|
727
|
+
options?: RegistrationOptions;
|
|
728
|
+
}
|
|
729
|
+
| {
|
|
730
|
+
/**
|
|
731
|
+
* Whether to automatically register the service worker, if it exists.
|
|
732
|
+
* @default true
|
|
733
|
+
*/
|
|
734
|
+
register?: false;
|
|
735
|
+
}
|
|
736
|
+
);
|
|
724
737
|
typescript?: {
|
|
725
738
|
/**
|
|
726
739
|
* A function that allows you to edit the generated `tsconfig.json`. You can mutate the config (recommended) or return a new one.
|
|
727
740
|
* This is useful for extending a shared `tsconfig.json` in a monorepo root, for example.
|
|
741
|
+
*
|
|
742
|
+
* Note that any paths configured here should be relative to the generated config file, which is written to `.svelte-kit/tsconfig.json`.
|
|
743
|
+
*
|
|
728
744
|
* @default (config) => config
|
|
729
745
|
* @since 1.3.0
|
|
730
746
|
*/
|
|
@@ -8,7 +8,9 @@ export function asset(file) {
|
|
|
8
8
|
|
|
9
9
|
/** @type {import('./types.d.ts').resolve} */
|
|
10
10
|
export function resolve(id, params) {
|
|
11
|
-
|
|
11
|
+
// The type error is correct here, and if someone doesn't pass params when they should there's a runtime error,
|
|
12
|
+
// but we don't want to adjust the internal resolve_route function to accept `undefined`, hence the type cast.
|
|
13
|
+
return base + resolve_route(id, /** @type {Record<string, string>} */ (params));
|
|
12
14
|
}
|
|
13
15
|
|
|
14
16
|
export { base, assets, resolve as resolveRoute };
|
|
@@ -216,7 +216,7 @@ export function form(id) {
|
|
|
216
216
|
const form_action_onclick = (callback) => {
|
|
217
217
|
/** @param {Event} event */
|
|
218
218
|
return async (event) => {
|
|
219
|
-
const target = /** @type {HTMLButtonElement} */ (event.
|
|
219
|
+
const target = /** @type {HTMLButtonElement} */ (event.currentTarget);
|
|
220
220
|
const form = target.form;
|
|
221
221
|
if (!form) return;
|
|
222
222
|
|
|
@@ -478,7 +478,14 @@ export async function render_response({
|
|
|
478
478
|
}
|
|
479
479
|
|
|
480
480
|
if (options.service_worker) {
|
|
481
|
-
|
|
481
|
+
let opts = __SVELTEKIT_DEV__ ? ", { type: 'module' }" : '';
|
|
482
|
+
if (options.service_worker_options != null) {
|
|
483
|
+
const service_worker_options = { ...options.service_worker_options };
|
|
484
|
+
if (__SVELTEKIT_DEV__) {
|
|
485
|
+
service_worker_options.type = 'module';
|
|
486
|
+
}
|
|
487
|
+
opts = `, ${s(service_worker_options)}`;
|
|
488
|
+
}
|
|
482
489
|
|
|
483
490
|
// we use an anonymous function instead of an arrow function to support
|
|
484
491
|
// older browsers (https://github.com/sveltejs/kit/pull/5417)
|
package/src/types/ambient.d.ts
CHANGED
|
@@ -79,3 +79,57 @@ declare module '$service-worker' {
|
|
|
79
79
|
*/
|
|
80
80
|
export const version: string;
|
|
81
81
|
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* This module contains generated types for the routes in your app.
|
|
85
|
+
*/
|
|
86
|
+
declare module '$app/types' {
|
|
87
|
+
/**
|
|
88
|
+
* Interface for all generated app types. This gets extended via declaration merging. DO NOT USE THIS INTERFACE DIRECTLY.
|
|
89
|
+
*/
|
|
90
|
+
export interface AppTypes {
|
|
91
|
+
// These are all functions so that we can leverage function overloads to get the correct type.
|
|
92
|
+
// Using the return types directly would error with a "not the same type" error.
|
|
93
|
+
// https://www.typescriptlang.org/docs/handbook/declaration-merging.html#merging-interfaces
|
|
94
|
+
RouteId(): string;
|
|
95
|
+
RouteParams(): Record<string, Record<string, string>>;
|
|
96
|
+
LayoutParams(): Record<string, Record<string, string>>;
|
|
97
|
+
Pathname(): string;
|
|
98
|
+
ResolvedPathname(): string;
|
|
99
|
+
Asset(): string;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* A union of all the route IDs in your app. Used for `page.route.id` and `event.route.id`.
|
|
104
|
+
*/
|
|
105
|
+
export type RouteId = ReturnType<AppTypes['RouteId']>;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* A utility for getting the parameters associated with a given route.
|
|
109
|
+
*/
|
|
110
|
+
export type RouteParams<T extends RouteId> = T extends keyof ReturnType<AppTypes['RouteParams']>
|
|
111
|
+
? ReturnType<AppTypes['RouteParams']>[T]
|
|
112
|
+
: Record<string, never>;
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* A utility for getting the parameters associated with a given layout, which is similar to `RouteParams` but also includes optional parameters for any child route.
|
|
116
|
+
*/
|
|
117
|
+
export type LayoutParams<T extends RouteId> = T extends keyof ReturnType<AppTypes['LayoutParams']>
|
|
118
|
+
? ReturnType<AppTypes['LayoutParams']>[T]
|
|
119
|
+
: Record<string, never>;
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* A union of all valid pathnames in your app.
|
|
123
|
+
*/
|
|
124
|
+
export type Pathname = ReturnType<AppTypes['Pathname']>;
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* `Pathname`, but possibly prefixed with a base path. Used for `page.url.pathname`.
|
|
128
|
+
*/
|
|
129
|
+
export type ResolvedPathname = ReturnType<AppTypes['ResolvedPathname']>;
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* A union of all the filenames of assets contained in your `static` directory.
|
|
133
|
+
*/
|
|
134
|
+
export type Asset = ReturnType<AppTypes['Asset']>;
|
|
135
|
+
}
|
package/src/types/internal.d.ts
CHANGED
|
@@ -450,6 +450,7 @@ export interface SSROptions {
|
|
|
450
450
|
preload_strategy: ValidatedConfig['kit']['output']['preloadStrategy'];
|
|
451
451
|
root: SSRComponent['default'];
|
|
452
452
|
service_worker: boolean;
|
|
453
|
+
service_worker_options: RegistrationOptions;
|
|
453
454
|
templates: {
|
|
454
455
|
app(values: {
|
|
455
456
|
head: string;
|
package/src/version.js
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -687,21 +687,38 @@ declare module '@sveltejs/kit' {
|
|
|
687
687
|
resolution?: 'client' | 'server';
|
|
688
688
|
};
|
|
689
689
|
serviceWorker?: {
|
|
690
|
-
/**
|
|
691
|
-
* Whether to automatically register the service worker, if it exists.
|
|
692
|
-
* @default true
|
|
693
|
-
*/
|
|
694
|
-
register?: boolean;
|
|
695
690
|
/**
|
|
696
691
|
* Determine which files in your `static` directory will be available in `$service-worker.files`.
|
|
697
692
|
* @default (filename) => !/\.DS_Store/.test(filename)
|
|
698
693
|
*/
|
|
699
|
-
files
|
|
700
|
-
}
|
|
694
|
+
files?: (file: string) => boolean;
|
|
695
|
+
} & (
|
|
696
|
+
| {
|
|
697
|
+
/**
|
|
698
|
+
* Whether to automatically register the service worker, if it exists.
|
|
699
|
+
* @default true
|
|
700
|
+
*/
|
|
701
|
+
register: true;
|
|
702
|
+
/**
|
|
703
|
+
* Options for serviceWorker.register("...", options);
|
|
704
|
+
*/
|
|
705
|
+
options?: RegistrationOptions;
|
|
706
|
+
}
|
|
707
|
+
| {
|
|
708
|
+
/**
|
|
709
|
+
* Whether to automatically register the service worker, if it exists.
|
|
710
|
+
* @default true
|
|
711
|
+
*/
|
|
712
|
+
register?: false;
|
|
713
|
+
}
|
|
714
|
+
);
|
|
701
715
|
typescript?: {
|
|
702
716
|
/**
|
|
703
717
|
* A function that allows you to edit the generated `tsconfig.json`. You can mutate the config (recommended) or return a new one.
|
|
704
718
|
* This is useful for extending a shared `tsconfig.json` in a monorepo root, for example.
|
|
719
|
+
*
|
|
720
|
+
* Note that any paths configured here should be relative to the generated config file, which is written to `.svelte-kit/tsconfig.json`.
|
|
721
|
+
*
|
|
705
722
|
* @default (config) => config
|
|
706
723
|
* @since 1.3.0
|
|
707
724
|
*/
|
|
@@ -2933,4 +2950,58 @@ declare module '$service-worker' {
|
|
|
2933
2950
|
export const version: string;
|
|
2934
2951
|
}
|
|
2935
2952
|
|
|
2953
|
+
/**
|
|
2954
|
+
* This module contains generated types for the routes in your app.
|
|
2955
|
+
*/
|
|
2956
|
+
declare module '$app/types' {
|
|
2957
|
+
/**
|
|
2958
|
+
* Interface for all generated app types. This gets extended via declaration merging. DO NOT USE THIS INTERFACE DIRECTLY.
|
|
2959
|
+
*/
|
|
2960
|
+
export interface AppTypes {
|
|
2961
|
+
// These are all functions so that we can leverage function overloads to get the correct type.
|
|
2962
|
+
// Using the return types directly would error with a "not the same type" error.
|
|
2963
|
+
// https://www.typescriptlang.org/docs/handbook/declaration-merging.html#merging-interfaces
|
|
2964
|
+
RouteId(): string;
|
|
2965
|
+
RouteParams(): Record<string, Record<string, string>>;
|
|
2966
|
+
LayoutParams(): Record<string, Record<string, string>>;
|
|
2967
|
+
Pathname(): string;
|
|
2968
|
+
ResolvedPathname(): string;
|
|
2969
|
+
Asset(): string;
|
|
2970
|
+
}
|
|
2971
|
+
|
|
2972
|
+
/**
|
|
2973
|
+
* A union of all the route IDs in your app. Used for `page.route.id` and `event.route.id`.
|
|
2974
|
+
*/
|
|
2975
|
+
export type RouteId = ReturnType<AppTypes['RouteId']>;
|
|
2976
|
+
|
|
2977
|
+
/**
|
|
2978
|
+
* A utility for getting the parameters associated with a given route.
|
|
2979
|
+
*/
|
|
2980
|
+
export type RouteParams<T extends RouteId> = T extends keyof ReturnType<AppTypes['RouteParams']>
|
|
2981
|
+
? ReturnType<AppTypes['RouteParams']>[T]
|
|
2982
|
+
: Record<string, never>;
|
|
2983
|
+
|
|
2984
|
+
/**
|
|
2985
|
+
* A utility for getting the parameters associated with a given layout, which is similar to `RouteParams` but also includes optional parameters for any child route.
|
|
2986
|
+
*/
|
|
2987
|
+
export type LayoutParams<T extends RouteId> = T extends keyof ReturnType<AppTypes['LayoutParams']>
|
|
2988
|
+
? ReturnType<AppTypes['LayoutParams']>[T]
|
|
2989
|
+
: Record<string, never>;
|
|
2990
|
+
|
|
2991
|
+
/**
|
|
2992
|
+
* A union of all valid pathnames in your app.
|
|
2993
|
+
*/
|
|
2994
|
+
export type Pathname = ReturnType<AppTypes['Pathname']>;
|
|
2995
|
+
|
|
2996
|
+
/**
|
|
2997
|
+
* `Pathname`, but possibly prefixed with a base path. Used for `page.url.pathname`.
|
|
2998
|
+
*/
|
|
2999
|
+
export type ResolvedPathname = ReturnType<AppTypes['ResolvedPathname']>;
|
|
3000
|
+
|
|
3001
|
+
/**
|
|
3002
|
+
* A union of all the filenames of assets contained in your `static` directory.
|
|
3003
|
+
*/
|
|
3004
|
+
export type Asset = ReturnType<AppTypes['Asset']>;
|
|
3005
|
+
}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