@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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sveltejs/kit",
|
|
3
|
-
"version": "1.0.0-next.
|
|
3
|
+
"version": "1.0.0-next.433",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/sveltejs/kit",
|
|
@@ -82,7 +82,6 @@
|
|
|
82
82
|
},
|
|
83
83
|
"scripts": {
|
|
84
84
|
"build": "npm run types",
|
|
85
|
-
"dev": "rollup -cw",
|
|
86
85
|
"lint": "prettier --check . --config ../../.prettierrc --ignore-path .gitignore",
|
|
87
86
|
"check": "tsc",
|
|
88
87
|
"check:all": "tsc && pnpm -r --filter=\"./**\" check",
|
|
@@ -23,7 +23,7 @@ export function create_builder({ config, build_data, prerendered, log }) {
|
|
|
23
23
|
/** @param {import('types').RouteData} route */
|
|
24
24
|
// TODO routes should come pre-filtered
|
|
25
25
|
function not_prerendered(route) {
|
|
26
|
-
const path = route.
|
|
26
|
+
const path = route.page && !route.id.includes('[') && `/${route.id}`;
|
|
27
27
|
if (path) {
|
|
28
28
|
return !prerendered_paths.has(path) && !prerendered_paths.has(path + '/');
|
|
29
29
|
}
|
|
@@ -68,17 +68,31 @@ export function create_builder({ config, build_data, prerendered, log }) {
|
|
|
68
68
|
const { routes } = build_data.manifest_data;
|
|
69
69
|
|
|
70
70
|
/** @type {import('types').RouteDefinition[]} */
|
|
71
|
-
const facades = routes.map((route) =>
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
71
|
+
const facades = routes.map((route) => {
|
|
72
|
+
const methods = new Set();
|
|
73
|
+
|
|
74
|
+
if (route.page) {
|
|
75
|
+
methods.add('SET');
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (route.endpoint) {
|
|
79
|
+
for (const method of build_data.server.methods[route.endpoint.file]) {
|
|
80
|
+
methods.add(method);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return {
|
|
85
|
+
id: route.id,
|
|
86
|
+
type: route.page ? 'page' : 'endpoint', // TODO change this if support pages+endpoints
|
|
87
|
+
segments: route.id.split('/').map((segment) => ({
|
|
88
|
+
dynamic: segment.includes('['),
|
|
89
|
+
rest: segment.includes('[...'),
|
|
90
|
+
content: segment
|
|
91
|
+
})),
|
|
92
|
+
pattern: route.pattern,
|
|
93
|
+
methods: Array.from(methods)
|
|
94
|
+
};
|
|
95
|
+
});
|
|
82
96
|
|
|
83
97
|
const seen = new Set();
|
|
84
98
|
|
|
@@ -102,8 +116,9 @@ export function create_builder({ config, build_data, prerendered, log }) {
|
|
|
102
116
|
|
|
103
117
|
// heuristic: if /foo/[bar] is included, /foo/[bar].json should
|
|
104
118
|
// also be included, since the page likely needs the endpoint
|
|
119
|
+
// TODO is this still necessary, given the new way of doing things?
|
|
105
120
|
filtered.forEach((route) => {
|
|
106
|
-
if (route.
|
|
121
|
+
if (route.page) {
|
|
107
122
|
const endpoint = routes.find((candidate) => candidate.id === route.id + '.json');
|
|
108
123
|
|
|
109
124
|
if (endpoint) {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { s } from '../../utils/misc.js';
|
|
2
|
-
import { parse_route_id } from '../../utils/routing.js';
|
|
3
2
|
import { get_mime_lookup } from '../utils.js';
|
|
4
3
|
|
|
5
4
|
/**
|
|
@@ -38,12 +37,11 @@ export function generate_manifest({ build_data, relative_path, routes, format =
|
|
|
38
37
|
assets.push(build_data.service_worker);
|
|
39
38
|
}
|
|
40
39
|
|
|
41
|
-
/** @param {import('types').PageNode | undefined} id */
|
|
42
|
-
const get_index = (id) => id && /** @type {LookupEntry} */ (bundled_nodes.get(id)).index;
|
|
43
|
-
|
|
44
40
|
const matchers = new Set();
|
|
45
41
|
|
|
46
42
|
// prettier-ignore
|
|
43
|
+
// String representation of
|
|
44
|
+
/** @type {import('types').SSRManifest} */
|
|
47
45
|
return `{
|
|
48
46
|
appDir: ${s(build_data.app_dir)},
|
|
49
47
|
assets: new Set(${s(assets)}),
|
|
@@ -55,39 +53,20 @@ export function generate_manifest({ build_data, relative_path, routes, format =
|
|
|
55
53
|
],
|
|
56
54
|
routes: [
|
|
57
55
|
${routes.map(route => {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
types.forEach(type => {
|
|
56
|
+
route.types.forEach(type => {
|
|
61
57
|
if (type) matchers.add(type);
|
|
62
58
|
});
|
|
63
59
|
|
|
64
|
-
if (route.
|
|
65
|
-
return `{
|
|
66
|
-
type: 'page',
|
|
67
|
-
id: ${s(route.id)},
|
|
68
|
-
pattern: ${pattern},
|
|
69
|
-
names: ${s(names)},
|
|
70
|
-
types: ${s(types)},
|
|
71
|
-
errors: ${s(route.errors.map(get_index))},
|
|
72
|
-
layouts: ${s(route.layouts.map(get_index))},
|
|
73
|
-
leaf: ${s(get_index(route.leaf))}
|
|
74
|
-
}`.replace(/^\t\t/gm, '');
|
|
75
|
-
} else {
|
|
76
|
-
if (!build_data.server.vite_manifest[route.file]) {
|
|
77
|
-
// this is necessary in cases where a .css file snuck in —
|
|
78
|
-
// perhaps it would be better to disallow these (and others?)
|
|
79
|
-
return null;
|
|
80
|
-
}
|
|
60
|
+
if (!route.page && !route.endpoint) return;
|
|
81
61
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
62
|
+
return `{
|
|
63
|
+
id: ${s(route.id)},
|
|
64
|
+
pattern: ${route.pattern},
|
|
65
|
+
names: ${s(route.names)},
|
|
66
|
+
types: ${s(route.types)},
|
|
67
|
+
page: ${s(route.page)},
|
|
68
|
+
endpoint: ${route.endpoint ? loader(`${relative_path}/${build_data.server.vite_manifest[route.endpoint.file].file}`) : 'null'}
|
|
69
|
+
}`;
|
|
91
70
|
}).filter(Boolean).join(',\n\t\t\t\t')}
|
|
92
71
|
],
|
|
93
72
|
matchers: async () => {
|
|
@@ -15,7 +15,7 @@ import { load_config } from '../config/index.js';
|
|
|
15
15
|
* @typedef {import('types').Logger} Logger
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
const [, , client_out_dir, results_path, manifest_path, verbose] = process.argv;
|
|
18
|
+
const [, , client_out_dir, results_path, manifest_path, verbose, env] = process.argv;
|
|
19
19
|
|
|
20
20
|
prerender();
|
|
21
21
|
|
|
@@ -159,6 +159,7 @@ export async function prerender() {
|
|
|
159
159
|
});
|
|
160
160
|
|
|
161
161
|
const server = new Server(manifest);
|
|
162
|
+
await server.init({ env: JSON.parse(env) });
|
|
162
163
|
|
|
163
164
|
const error = normalise_error_handler(log, config);
|
|
164
165
|
|
|
@@ -343,7 +344,7 @@ export async function prerender() {
|
|
|
343
344
|
/** @type {import('types').ManifestData} */
|
|
344
345
|
const { routes } = (await import(pathToFileURL(manifest_path).href)).manifest._;
|
|
345
346
|
const entries = routes
|
|
346
|
-
.map((route) => (route.
|
|
347
|
+
.map((route) => (route.page && !route.id.includes('[') ? `/${route.id}` : ''))
|
|
347
348
|
.filter(Boolean);
|
|
348
349
|
|
|
349
350
|
for (const entry of entries) {
|