@sveltejs/kit 1.0.0-next.430 → 1.0.0-next.433
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 -2
- package/src/core/adapt/builder.js +28 -13
- package/src/core/generate_manifest/index.js +12 -33
- package/src/core/prerender/prerender.js +3 -2
- package/src/core/sync/create_manifest_data/index.js +273 -333
- package/src/core/sync/create_manifest_data/types.d.ts +1 -4
- package/src/core/sync/sync.js +3 -3
- package/src/core/sync/utils.js +0 -11
- package/src/core/sync/write_client_manifest.js +27 -13
- package/src/core/sync/write_root.js +1 -1
- package/src/core/sync/write_types.js +156 -384
- package/src/runtime/client/ambient.d.ts +4 -3
- package/src/runtime/client/client.js +208 -132
- package/src/runtime/client/parse.js +10 -5
- package/src/runtime/client/types.d.ts +10 -29
- package/src/runtime/server/endpoint.js +2 -10
- package/src/runtime/server/index.js +87 -44
- package/src/runtime/server/page/fetch.js +1 -1
- package/src/runtime/server/page/index.js +13 -25
- package/src/runtime/server/page/load_data.js +47 -10
- package/src/utils/array.js +9 -0
- package/src/utils/functions.js +16 -0
- package/src/utils/routing.js +30 -1
- package/src/vite/build/build_server.js +23 -12
- package/src/vite/dev/index.js +22 -30
- package/src/vite/index.js +7 -1
- package/src/vite/preview/index.js +1 -1
- package/types/index.d.ts +1 -1
- package/types/internal.d.ts +103 -41
|
@@ -9,7 +9,7 @@ interface Part {
|
|
|
9
9
|
|
|
10
10
|
interface RouteTreeNode {
|
|
11
11
|
error: PageNode | undefined;
|
|
12
|
-
|
|
12
|
+
layout: PageNode | undefined;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
export type RouteTree = Map<string, RouteTreeNode>;
|
|
@@ -20,21 +20,18 @@ interface RouteComponent {
|
|
|
20
20
|
is_layout: boolean;
|
|
21
21
|
is_error: boolean;
|
|
22
22
|
uses_layout: string | undefined;
|
|
23
|
-
declares_layout: string | undefined;
|
|
24
23
|
}
|
|
25
24
|
|
|
26
25
|
interface RouteSharedModule {
|
|
27
26
|
kind: 'shared';
|
|
28
27
|
is_page: boolean;
|
|
29
28
|
is_layout: boolean;
|
|
30
|
-
declares_layout: string | undefined;
|
|
31
29
|
}
|
|
32
30
|
|
|
33
31
|
interface RouteServerModule {
|
|
34
32
|
kind: 'server';
|
|
35
33
|
is_page: boolean;
|
|
36
34
|
is_layout: boolean;
|
|
37
|
-
declares_layout: string | undefined;
|
|
38
35
|
}
|
|
39
36
|
|
|
40
37
|
export type RouteFile = RouteComponent | RouteSharedModule | RouteServerModule;
|
package/src/core/sync/sync.js
CHANGED
|
@@ -4,7 +4,7 @@ import { write_client_manifest } from './write_client_manifest.js';
|
|
|
4
4
|
import { write_matchers } from './write_matchers.js';
|
|
5
5
|
import { write_root } from './write_root.js';
|
|
6
6
|
import { write_tsconfig } from './write_tsconfig.js';
|
|
7
|
-
import {
|
|
7
|
+
import { write_types, write_all_types } from './write_types.js';
|
|
8
8
|
import { write_ambient } from './write_ambient.js';
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -29,7 +29,7 @@ export async function create(config) {
|
|
|
29
29
|
write_client_manifest(manifest_data, output);
|
|
30
30
|
write_root(manifest_data, output);
|
|
31
31
|
write_matchers(manifest_data, output);
|
|
32
|
-
await
|
|
32
|
+
await write_all_types(config, manifest_data);
|
|
33
33
|
|
|
34
34
|
return { manifest_data };
|
|
35
35
|
}
|
|
@@ -43,7 +43,7 @@ export async function create(config) {
|
|
|
43
43
|
* @param {string} file
|
|
44
44
|
*/
|
|
45
45
|
export async function update(config, manifest_data, file) {
|
|
46
|
-
await
|
|
46
|
+
await write_types(config, manifest_data, file);
|
|
47
47
|
|
|
48
48
|
return { manifest_data };
|
|
49
49
|
}
|
package/src/core/sync/utils.js
CHANGED
|
@@ -25,17 +25,6 @@ export function write(file, code) {
|
|
|
25
25
|
fs.writeFileSync(file, code);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
/**
|
|
29
|
-
* @param {(file: string) => boolean} should_remove
|
|
30
|
-
*/
|
|
31
|
-
export function remove_from_previous(should_remove) {
|
|
32
|
-
for (const key of previous_contents.keys()) {
|
|
33
|
-
if (should_remove(key)) {
|
|
34
|
-
previous_contents.delete(key);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
28
|
/** @param {string} str */
|
|
40
29
|
export function trim(str) {
|
|
41
30
|
const indentation = /** @type {RegExpExecArray} */ (/\n?(\s*)/.exec(str))[1];
|
|
@@ -9,9 +9,6 @@ import { trim, write_if_changed } from './utils.js';
|
|
|
9
9
|
* @param {string} output
|
|
10
10
|
*/
|
|
11
11
|
export function write_client_manifest(manifest_data, output) {
|
|
12
|
-
/** @type {Map<import('types').PageNode, number>} */
|
|
13
|
-
const node_indexes = new Map();
|
|
14
|
-
|
|
15
12
|
/**
|
|
16
13
|
* Creates a module that exports a `CSRPageNode`
|
|
17
14
|
* @param {import('types').PageNode} node
|
|
@@ -41,7 +38,6 @@ export function write_client_manifest(manifest_data, output) {
|
|
|
41
38
|
|
|
42
39
|
const nodes = manifest_data.nodes
|
|
43
40
|
.map((node, i) => {
|
|
44
|
-
node_indexes.set(node, i);
|
|
45
41
|
write_if_changed(`${output}/nodes/${i}.js`, generate_node(node));
|
|
46
42
|
return `() => import('./nodes/${i}')`;
|
|
47
43
|
})
|
|
@@ -50,17 +46,35 @@ export function write_client_manifest(manifest_data, output) {
|
|
|
50
46
|
const dictionary = `{
|
|
51
47
|
${manifest_data.routes
|
|
52
48
|
.map((route) => {
|
|
53
|
-
if (route.
|
|
54
|
-
const errors = route.errors.map((
|
|
55
|
-
const layouts = route.layouts
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
49
|
+
if (route.page) {
|
|
50
|
+
const errors = route.page.errors.slice(1).map((n) => n ?? '');
|
|
51
|
+
const layouts = route.page.layouts.slice(1).map((n) => n ?? '');
|
|
52
|
+
|
|
53
|
+
while (layouts.at(-1) === '') layouts.pop();
|
|
54
|
+
while (errors.at(-1) === '') errors.pop();
|
|
55
|
+
|
|
56
|
+
/** @type {import('types').RouteData | null} */
|
|
57
|
+
let current_route = route;
|
|
58
|
+
|
|
59
|
+
/** @type {import('types').PageNode | null} */
|
|
60
|
+
let current_node = route.leaf;
|
|
61
|
+
|
|
62
|
+
let uses_server_data = false;
|
|
63
|
+
while (current_route && !uses_server_data) {
|
|
64
|
+
uses_server_data = !!current_node?.server;
|
|
65
|
+
current_route = current_route.parent;
|
|
66
|
+
current_node = current_route?.layout ?? null;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// encode whether or not the route uses the server data
|
|
70
|
+
// using the ones' complement, to save space
|
|
71
|
+
const array = [`${uses_server_data ? '~' : ''}${route.page.leaf}`];
|
|
59
72
|
|
|
60
|
-
|
|
61
|
-
|
|
73
|
+
// only include non-root layout/error nodes if they exist
|
|
74
|
+
if (layouts.length > 0 || errors.length > 0) array.push(`[${layouts.join(',')}]`);
|
|
75
|
+
if (errors.length > 0) array.push(`[${errors.join(',')}]`);
|
|
62
76
|
|
|
63
|
-
return `${s(route.id)}: [
|
|
77
|
+
return `${s(route.id)}: [${array.join(',')}]`;
|
|
64
78
|
}
|
|
65
79
|
})
|
|
66
80
|
.filter(Boolean)
|
|
@@ -9,7 +9,7 @@ export function write_root(manifest_data, output) {
|
|
|
9
9
|
|
|
10
10
|
const max_depth = Math.max(
|
|
11
11
|
...manifest_data.routes.map((route) =>
|
|
12
|
-
route.
|
|
12
|
+
route.page ? route.page.layouts.filter(Boolean).length + 1 : 0
|
|
13
13
|
),
|
|
14
14
|
1
|
|
15
15
|
);
|