@sveltejs/kit 1.0.0-next.439 → 1.0.0-next.441
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/sync/create_manifest_data/index.js +18 -16
- package/src/core/sync/write_client_manifest.js +2 -6
- package/src/core/sync/write_root.js +1 -1
- package/src/core/sync/write_types/index.js +8 -14
- package/src/core/sync/write_types/test/layout/_expected/$types.d.ts +2 -2
- package/src/core/sync/write_types/test/layout-advanced/_expected/$types.d.ts +2 -2
- package/src/core/sync/write_types/test/layout-advanced/_expected/(main)/$types.d.ts +2 -2
- package/src/core/sync/write_types/test/layout-advanced/_expected/(main)/sub/$types.d.ts +1 -1
- package/src/core/sync/write_types/test/simple-page-server-and-shared/_expected/$types.d.ts +2 -2
- package/src/core/sync/write_types/test/simple-page-server-only/_expected/$types.d.ts +2 -2
- package/src/core/sync/write_types/test/simple-page-shared-only/_expected/$types.d.ts +2 -2
- package/src/core/sync/write_types/test/slugs/_expected/$types.d.ts +2 -5
- package/src/core/sync/write_types/test/slugs/_expected/[...rest]/$types.d.ts +1 -3
- package/src/core/sync/write_types/test/slugs/_expected/[slug]/$types.d.ts +1 -3
- package/src/core/sync/write_types/test/slugs-layout-not-all-pages-have-load/_expected/$types.d.ts +2 -5
- package/src/core/sync/write_types/test/slugs-layout-not-all-pages-have-load/_expected/nested/$types.d.ts +2 -4
- package/src/core/sync/write_types/test/slugs-layout-not-all-pages-have-load/_expected/nested/[...rest]/$types.d.ts +1 -3
- package/src/core/sync/write_types/test/slugs-layout-not-all-pages-have-load/_expected/nested/[slug]/$types.d.ts +1 -3
- package/types/index.d.ts +8 -6
package/package.json
CHANGED
|
@@ -109,23 +109,25 @@ function create_routes_and_nodes(cwd, config, fallback) {
|
|
|
109
109
|
|
|
110
110
|
segment_map.set(
|
|
111
111
|
id,
|
|
112
|
-
segments
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
112
|
+
segments
|
|
113
|
+
.filter((segment) => segment !== '' && affects_path(segment))
|
|
114
|
+
.map((segment) => {
|
|
115
|
+
/** @type {import('./types').Part[]} */
|
|
116
|
+
const parts = [];
|
|
117
|
+
segment.split(/\[(.+?)\]/).map((content, i) => {
|
|
118
|
+
const dynamic = !!(i % 2);
|
|
119
|
+
|
|
120
|
+
if (!content) return;
|
|
121
|
+
|
|
122
|
+
parts.push({
|
|
123
|
+
content,
|
|
124
|
+
dynamic,
|
|
125
|
+
rest: dynamic && content.startsWith('...'),
|
|
126
|
+
type: (dynamic && content.split('=')[1]) || null
|
|
127
|
+
});
|
|
125
128
|
});
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
})
|
|
129
|
+
return parts;
|
|
130
|
+
})
|
|
129
131
|
);
|
|
130
132
|
|
|
131
133
|
/** @type {import('types').RouteData} */
|
|
@@ -53,17 +53,13 @@ export function write_client_manifest(manifest_data, output) {
|
|
|
53
53
|
while (layouts.at(-1) === '') layouts.pop();
|
|
54
54
|
while (errors.at(-1) === '') errors.pop();
|
|
55
55
|
|
|
56
|
-
/** @type {import('types').RouteData | null} */
|
|
57
|
-
let current_route = route;
|
|
58
|
-
|
|
59
56
|
/** @type {import('types').PageNode | null} */
|
|
60
57
|
let current_node = route.leaf;
|
|
61
58
|
|
|
62
59
|
let uses_server_data = false;
|
|
63
|
-
while (
|
|
60
|
+
while (current_node && !uses_server_data) {
|
|
64
61
|
uses_server_data = !!current_node?.server;
|
|
65
|
-
|
|
66
|
-
current_node = current_route?.layout ?? null;
|
|
62
|
+
current_node = current_node?.parent ?? null;
|
|
67
63
|
}
|
|
68
64
|
|
|
69
65
|
// encode whether or not the route uses the server data
|
|
@@ -26,7 +26,7 @@ export function write_root(manifest_data, output) {
|
|
|
26
26
|
while (l--) {
|
|
27
27
|
pyramid = `
|
|
28
28
|
{#if components[${l + 1}]}
|
|
29
|
-
<svelte:component this={components[${l}]} data={data_${l}}>
|
|
29
|
+
<svelte:component this={components[${l}]} data={data_${l}} {errors}>
|
|
30
30
|
${pyramid.replace(/\n/g, '\n\t\t\t\t\t')}
|
|
31
31
|
</svelte:component>
|
|
32
32
|
{:else}
|
|
@@ -163,14 +163,9 @@ function update_types(config, routes, route) {
|
|
|
163
163
|
/** @type {string[]} */
|
|
164
164
|
const exports = [];
|
|
165
165
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
`interface RouteParams extends Partial<Record<string, string>> { ${params} }`
|
|
170
|
-
);
|
|
171
|
-
} else {
|
|
172
|
-
declarations.push(`interface RouteParams extends Partial<Record<string, string>> {}`);
|
|
173
|
-
}
|
|
166
|
+
declarations.push(
|
|
167
|
+
`type RouteParams = { ${route.names.map((param) => `${param}: string`).join('; ')} }`
|
|
168
|
+
);
|
|
174
169
|
|
|
175
170
|
if (route.layout || route.leaf) {
|
|
176
171
|
// These could also be placed in our public types, but it would bloat them unnecessarily and we may want to change these in the future
|
|
@@ -212,12 +207,11 @@ function update_types(config, routes, route) {
|
|
|
212
207
|
}
|
|
213
208
|
});
|
|
214
209
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
}
|
|
210
|
+
declarations.push(
|
|
211
|
+
`type LayoutParams = RouteParams & { ${Array.from(layout_params).map(
|
|
212
|
+
(param) => `${param}?: string`
|
|
213
|
+
)} }`
|
|
214
|
+
);
|
|
221
215
|
|
|
222
216
|
const {
|
|
223
217
|
exports: e,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type * as Kit from '@sveltejs/kit';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
type RouteParams = {};
|
|
4
4
|
type MaybeWithVoid<T> = {} extends T ? T | void : T;
|
|
5
5
|
export type RequiredKeys<T> = {
|
|
6
6
|
[K in keyof T]-?: {} extends { [P in K]: T[K] } ? never : K;
|
|
@@ -13,7 +13,7 @@ type OutputDataShape<T> = MaybeWithVoid<
|
|
|
13
13
|
type EnsureParentData<T> = NonNullable<T> extends never ? {} : T;
|
|
14
14
|
type PageServerParentData = EnsureParentData<LayoutServerData>;
|
|
15
15
|
type PageParentData = EnsureParentData<LayoutData>;
|
|
16
|
-
|
|
16
|
+
type LayoutParams = RouteParams & {};
|
|
17
17
|
type LayoutServerParentData = EnsureParentData<{}>;
|
|
18
18
|
type LayoutParentData = EnsureParentData<{}>;
|
|
19
19
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type * as Kit from '@sveltejs/kit';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
type RouteParams = {};
|
|
4
4
|
type MaybeWithVoid<T> = {} extends T ? T | void : T;
|
|
5
5
|
export type RequiredKeys<T> = {
|
|
6
6
|
[K in keyof T]-?: {} extends { [P in K]: T[K] } ? never : K;
|
|
@@ -11,7 +11,7 @@ type OutputDataShape<T> = MaybeWithVoid<
|
|
|
11
11
|
Record<string, any>
|
|
12
12
|
>;
|
|
13
13
|
type EnsureParentData<T> = NonNullable<T> extends never ? {} : T;
|
|
14
|
-
|
|
14
|
+
type LayoutParams = RouteParams & {};
|
|
15
15
|
type LayoutParentData = EnsureParentData<{}>;
|
|
16
16
|
|
|
17
17
|
export type LayoutServerData = null;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type * as Kit from '@sveltejs/kit';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
type RouteParams = {};
|
|
4
4
|
type MaybeWithVoid<T> = {} extends T ? T | void : T;
|
|
5
5
|
export type RequiredKeys<T> = {
|
|
6
6
|
[K in keyof T]-?: {} extends { [P in K]: T[K] } ? never : K;
|
|
@@ -12,7 +12,7 @@ type OutputDataShape<T> = MaybeWithVoid<
|
|
|
12
12
|
>;
|
|
13
13
|
type EnsureParentData<T> = NonNullable<T> extends never ? {} : T;
|
|
14
14
|
type PageParentData = EnsureParentData<import('../$types.js').LayoutData>;
|
|
15
|
-
|
|
15
|
+
type LayoutParams = RouteParams & {};
|
|
16
16
|
type LayoutServerParentData = EnsureParentData<import('../$types.js').LayoutServerData>;
|
|
17
17
|
type LayoutParentData = EnsureParentData<import('../$types.js').LayoutData>;
|
|
18
18
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type * as Kit from '@sveltejs/kit';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
type RouteParams = {};
|
|
4
4
|
type MaybeWithVoid<T> = {} extends T ? T | void : T;
|
|
5
5
|
export type RequiredKeys<T> = {
|
|
6
6
|
[K in keyof T]-?: {} extends { [P in K]: T[K] } ? never : K;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type * as Kit from '@sveltejs/kit';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
type RouteParams = {};
|
|
4
4
|
type MaybeWithVoid<T> = {} extends T ? T | void : T;
|
|
5
5
|
export type RequiredKeys<T> = {
|
|
6
6
|
[K in keyof T]-?: {} extends { [P in K]: T[K] } ? never : K;
|
|
@@ -13,7 +13,7 @@ type OutputDataShape<T> = MaybeWithVoid<
|
|
|
13
13
|
type EnsureParentData<T> = NonNullable<T> extends never ? {} : T;
|
|
14
14
|
type PageServerParentData = EnsureParentData<LayoutServerData>;
|
|
15
15
|
type PageParentData = EnsureParentData<LayoutData>;
|
|
16
|
-
|
|
16
|
+
type LayoutParams = RouteParams & {};
|
|
17
17
|
type LayoutParentData = EnsureParentData<{}>;
|
|
18
18
|
|
|
19
19
|
export type PageServerLoad<
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type * as Kit from '@sveltejs/kit';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
type RouteParams = {};
|
|
4
4
|
type MaybeWithVoid<T> = {} extends T ? T | void : T;
|
|
5
5
|
export type RequiredKeys<T> = {
|
|
6
6
|
[K in keyof T]-?: {} extends { [P in K]: T[K] } ? never : K;
|
|
@@ -13,7 +13,7 @@ type OutputDataShape<T> = MaybeWithVoid<
|
|
|
13
13
|
type EnsureParentData<T> = NonNullable<T> extends never ? {} : T;
|
|
14
14
|
type PageServerParentData = EnsureParentData<LayoutServerData>;
|
|
15
15
|
type PageParentData = EnsureParentData<LayoutData>;
|
|
16
|
-
|
|
16
|
+
type LayoutParams = RouteParams & {};
|
|
17
17
|
type LayoutParentData = EnsureParentData<{}>;
|
|
18
18
|
|
|
19
19
|
export type PageServerLoad<
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type * as Kit from '@sveltejs/kit';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
type RouteParams = {};
|
|
4
4
|
type MaybeWithVoid<T> = {} extends T ? T | void : T;
|
|
5
5
|
export type RequiredKeys<T> = {
|
|
6
6
|
[K in keyof T]-?: {} extends { [P in K]: T[K] } ? never : K;
|
|
@@ -12,7 +12,7 @@ type OutputDataShape<T> = MaybeWithVoid<
|
|
|
12
12
|
>;
|
|
13
13
|
type EnsureParentData<T> = NonNullable<T> extends never ? {} : T;
|
|
14
14
|
type PageParentData = EnsureParentData<LayoutData>;
|
|
15
|
-
|
|
15
|
+
type LayoutParams = RouteParams & {};
|
|
16
16
|
type LayoutParentData = EnsureParentData<{}>;
|
|
17
17
|
|
|
18
18
|
export type PageServerData = null;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type * as Kit from '@sveltejs/kit';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
type RouteParams = {};
|
|
4
4
|
type MaybeWithVoid<T> = {} extends T ? T | void : T;
|
|
5
5
|
export type RequiredKeys<T> = {
|
|
6
6
|
[K in keyof T]-?: {} extends { [P in K]: T[K] } ? never : K;
|
|
@@ -11,10 +11,7 @@ type OutputDataShape<T> = MaybeWithVoid<
|
|
|
11
11
|
Record<string, any>
|
|
12
12
|
>;
|
|
13
13
|
type EnsureParentData<T> = NonNullable<T> extends never ? {} : T;
|
|
14
|
-
|
|
15
|
-
rest?: string;
|
|
16
|
-
slug?: string;
|
|
17
|
-
}
|
|
14
|
+
type LayoutParams = RouteParams & { rest?: string; slug?: string };
|
|
18
15
|
type LayoutParentData = EnsureParentData<{}>;
|
|
19
16
|
|
|
20
17
|
export type LayoutServerData = null;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import type * as Kit from '@sveltejs/kit';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
rest: string;
|
|
5
|
-
}
|
|
3
|
+
type RouteParams = { rest: string };
|
|
6
4
|
type MaybeWithVoid<T> = {} extends T ? T | void : T;
|
|
7
5
|
export type RequiredKeys<T> = {
|
|
8
6
|
[K in keyof T]-?: {} extends { [P in K]: T[K] } ? never : K;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import type * as Kit from '@sveltejs/kit';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
slug: string;
|
|
5
|
-
}
|
|
3
|
+
type RouteParams = { slug: string };
|
|
6
4
|
type MaybeWithVoid<T> = {} extends T ? T | void : T;
|
|
7
5
|
export type RequiredKeys<T> = {
|
|
8
6
|
[K in keyof T]-?: {} extends { [P in K]: T[K] } ? never : K;
|
package/src/core/sync/write_types/test/slugs-layout-not-all-pages-have-load/_expected/$types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type * as Kit from '@sveltejs/kit';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
type RouteParams = {};
|
|
4
4
|
type MaybeWithVoid<T> = {} extends T ? T | void : T;
|
|
5
5
|
export type RequiredKeys<T> = {
|
|
6
6
|
[K in keyof T]-?: {} extends { [P in K]: T[K] } ? never : K;
|
|
@@ -11,10 +11,7 @@ type OutputDataShape<T> = MaybeWithVoid<
|
|
|
11
11
|
Record<string, any>
|
|
12
12
|
>;
|
|
13
13
|
type EnsureParentData<T> = NonNullable<T> extends never ? {} : T;
|
|
14
|
-
|
|
15
|
-
rest?: string;
|
|
16
|
-
slug?: string;
|
|
17
|
-
}
|
|
14
|
+
type LayoutParams = RouteParams & { rest?: string; slug?: string };
|
|
18
15
|
type LayoutParentData = EnsureParentData<{}>;
|
|
19
16
|
|
|
20
17
|
export type LayoutServerData = null;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type * as Kit from '@sveltejs/kit';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
type RouteParams = {};
|
|
4
4
|
type MaybeWithVoid<T> = {} extends T ? T | void : T;
|
|
5
5
|
export type RequiredKeys<T> = {
|
|
6
6
|
[K in keyof T]-?: {} extends { [P in K]: T[K] } ? never : K;
|
|
@@ -11,9 +11,7 @@ type OutputDataShape<T> = MaybeWithVoid<
|
|
|
11
11
|
Record<string, any>
|
|
12
12
|
>;
|
|
13
13
|
type EnsureParentData<T> = NonNullable<T> extends never ? {} : T;
|
|
14
|
-
|
|
15
|
-
rest?: string;
|
|
16
|
-
}
|
|
14
|
+
type LayoutParams = RouteParams & { rest?: string };
|
|
17
15
|
type LayoutParentData = EnsureParentData<import('../$types.js').LayoutData>;
|
|
18
16
|
|
|
19
17
|
export type LayoutServerData = null;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import type * as Kit from '@sveltejs/kit';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
rest: string;
|
|
5
|
-
}
|
|
3
|
+
type RouteParams = { rest: string };
|
|
6
4
|
type MaybeWithVoid<T> = {} extends T ? T | void : T;
|
|
7
5
|
export type RequiredKeys<T> = {
|
|
8
6
|
[K in keyof T]-?: {} extends { [P in K]: T[K] } ? never : K;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import type * as Kit from '@sveltejs/kit';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
slug: string;
|
|
5
|
-
}
|
|
3
|
+
type RouteParams = { slug: string };
|
|
6
4
|
type MaybeWithVoid<T> = {} extends T ? T | void : T;
|
|
7
5
|
export type RequiredKeys<T> = {
|
|
8
6
|
[K in keyof T]-?: {} extends { [P in K]: T[K] } ? never : K;
|
package/types/index.d.ts
CHANGED
|
@@ -195,17 +195,17 @@ export interface HandleError {
|
|
|
195
195
|
*/
|
|
196
196
|
export interface Load<
|
|
197
197
|
Params extends Partial<Record<string, string>> = Partial<Record<string, string>>,
|
|
198
|
-
InputData extends Record<string,
|
|
199
|
-
ParentData extends Record<string,
|
|
200
|
-
OutputData extends Record<string,
|
|
198
|
+
InputData extends Record<string, unknown> | null = Record<string, any> | null,
|
|
199
|
+
ParentData extends Record<string, unknown> = Record<string, any>,
|
|
200
|
+
OutputData extends Record<string, unknown> | void = Record<string, any> | void
|
|
201
201
|
> {
|
|
202
202
|
(event: LoadEvent<Params, InputData, ParentData>): MaybePromise<OutputData>;
|
|
203
203
|
}
|
|
204
204
|
|
|
205
205
|
export interface LoadEvent<
|
|
206
206
|
Params extends Partial<Record<string, string>> = Partial<Record<string, string>>,
|
|
207
|
-
Data extends Record<string,
|
|
208
|
-
ParentData extends Record<string,
|
|
207
|
+
Data extends Record<string, unknown> | null = Record<string, any> | null,
|
|
208
|
+
ParentData extends Record<string, unknown> = Record<string, any>
|
|
209
209
|
> {
|
|
210
210
|
fetch(info: RequestInfo, init?: RequestInit): Promise<Response>;
|
|
211
211
|
params: Params;
|
|
@@ -253,7 +253,9 @@ export interface RequestEvent<
|
|
|
253
253
|
*
|
|
254
254
|
* It receives `Params` as the first generic argument, which you can skip by using [generated types](/docs/types#generated-types) instead.
|
|
255
255
|
*/
|
|
256
|
-
export interface RequestHandler<
|
|
256
|
+
export interface RequestHandler<
|
|
257
|
+
Params extends Partial<Record<string, string>> = Partial<Record<string, string>>
|
|
258
|
+
> {
|
|
257
259
|
(event: RequestEvent<Params>): MaybePromise<Response>;
|
|
258
260
|
}
|
|
259
261
|
|