@sveltejs/kit 1.27.5 → 1.27.7
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 +5 -6
- package/src/core/config/default-error.html +13 -3
- package/src/core/sync/write_root.js +43 -13
- package/src/core/sync/write_tsconfig.js +4 -3
- package/src/exports/public.d.ts +8 -8
- package/src/exports/vite/preview/index.js +3 -1
- package/src/runtime/client/client.js +23 -17
- package/src/runtime/components/layout.svelte +1 -1
- package/src/runtime/server/page/index.js +1 -1
- package/src/runtime/server/page/load_data.js +4 -4
- package/src/runtime/server/respond.js +2 -2
- package/src/version.js +1 -1
- package/types/index.d.ts +8 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sveltejs/kit",
|
|
3
|
-
"version": "1.27.
|
|
3
|
+
"version": "1.27.7",
|
|
4
4
|
"description": "The fastest way to build Svelte apps",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -32,10 +32,9 @@
|
|
|
32
32
|
"@types/sade": "^1.7.4",
|
|
33
33
|
"@types/set-cookie-parser": "^2.4.2",
|
|
34
34
|
"dts-buddy": "^0.2.4",
|
|
35
|
-
"marked": "^9.0.0",
|
|
36
35
|
"rollup": "^3.29.4",
|
|
37
|
-
"svelte": "^4.2.
|
|
38
|
-
"svelte-preprocess": "^5.
|
|
36
|
+
"svelte": "^4.2.7",
|
|
37
|
+
"svelte-preprocess": "^5.1.1",
|
|
39
38
|
"typescript": "^4.9.4",
|
|
40
39
|
"vite": "^4.4.9",
|
|
41
40
|
"vitest": "^0.34.5"
|
|
@@ -84,10 +83,10 @@
|
|
|
84
83
|
"node": "^16.14 || >=18"
|
|
85
84
|
},
|
|
86
85
|
"scripts": {
|
|
87
|
-
"lint": "prettier --
|
|
86
|
+
"lint": "prettier --config ../../.prettierrc --check .",
|
|
88
87
|
"check": "tsc",
|
|
89
88
|
"check:all": "tsc && pnpm -r --filter=\"./**\" check",
|
|
90
|
-
"format": "prettier --
|
|
89
|
+
"format": "prettier --config ../../.prettierrc --write .",
|
|
91
90
|
"test": "pnpm test:unit && pnpm test:integration",
|
|
92
91
|
"test:integration": "pnpm -r --workspace-concurrency 1 --filter=\"./test/**\" test",
|
|
93
92
|
"test:cross-platform:dev": "pnpm -r --workspace-concurrency 1 --filter=\"./test/**\" test:cross-platform:dev",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<!
|
|
1
|
+
<!doctype html>
|
|
2
2
|
<html lang="en">
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="utf-8" />
|
|
@@ -11,8 +11,18 @@
|
|
|
11
11
|
--divider: #ccc;
|
|
12
12
|
background: var(--bg);
|
|
13
13
|
color: var(--fg);
|
|
14
|
-
font-family:
|
|
15
|
-
|
|
14
|
+
font-family:
|
|
15
|
+
system-ui,
|
|
16
|
+
-apple-system,
|
|
17
|
+
BlinkMacSystemFont,
|
|
18
|
+
'Segoe UI',
|
|
19
|
+
Roboto,
|
|
20
|
+
Oxygen,
|
|
21
|
+
Ubuntu,
|
|
22
|
+
Cantarell,
|
|
23
|
+
'Open Sans',
|
|
24
|
+
'Helvetica Neue',
|
|
25
|
+
sans-serif;
|
|
16
26
|
display: flex;
|
|
17
27
|
align-items: center;
|
|
18
28
|
justify-content: center;
|
|
@@ -39,29 +39,59 @@ export function write_root(manifest_data, output) {
|
|
|
39
39
|
`${output}/root.svelte`,
|
|
40
40
|
dedent`
|
|
41
41
|
<!-- This file is generated by @sveltejs/kit — do not edit it! -->
|
|
42
|
+
${isSvelte5Plus() ? '<svelte:options runes={true} />' : ''}
|
|
42
43
|
<script>
|
|
43
|
-
import { setContext, afterUpdate, onMount, tick } from 'svelte';
|
|
44
|
+
import { setContext, ${isSvelte5Plus() ? '' : 'afterUpdate, '}onMount, tick } from 'svelte';
|
|
44
45
|
import { browser } from '$app/environment';
|
|
45
46
|
|
|
46
47
|
// stores
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
48
|
+
${
|
|
49
|
+
isSvelte5Plus()
|
|
50
|
+
? dedent`
|
|
51
|
+
let { stores, page, constructors, components = [], form, ${levels
|
|
52
|
+
.map((l) => `data_${l} = null`)
|
|
53
|
+
.join(', ')} } = $props();
|
|
54
|
+
`
|
|
55
|
+
: dedent`
|
|
56
|
+
export let stores;
|
|
57
|
+
export let page;
|
|
58
|
+
|
|
59
|
+
export let constructors;
|
|
60
|
+
export let components = [];
|
|
61
|
+
export let form;
|
|
62
|
+
${levels.map((l) => `export let data_${l} = null;`).join('\n')}
|
|
63
|
+
`
|
|
64
|
+
}
|
|
54
65
|
|
|
55
66
|
if (!browser) {
|
|
56
67
|
setContext('__svelte__', stores);
|
|
57
68
|
}
|
|
58
69
|
|
|
59
|
-
|
|
60
|
-
|
|
70
|
+
${
|
|
71
|
+
isSvelte5Plus()
|
|
72
|
+
? dedent`
|
|
73
|
+
if (browser) {
|
|
74
|
+
$effect.pre(() => stores.page.set(page));
|
|
75
|
+
} else {
|
|
76
|
+
stores.page.set(page);
|
|
77
|
+
}
|
|
78
|
+
`
|
|
79
|
+
: '$: stores.page.set(page);'
|
|
80
|
+
}
|
|
81
|
+
${
|
|
82
|
+
isSvelte5Plus()
|
|
83
|
+
? dedent`
|
|
84
|
+
$effect(() => {
|
|
85
|
+
stores;page;constructors;components;form;${levels.map((l) => `data_${l}`).join(';')};
|
|
86
|
+
stores.page.notify();
|
|
87
|
+
});
|
|
88
|
+
`
|
|
89
|
+
: 'afterUpdate(stores.page.notify);'
|
|
90
|
+
}
|
|
61
91
|
|
|
62
|
-
let mounted = false;
|
|
63
|
-
let navigated = false;
|
|
64
|
-
let title = null;
|
|
92
|
+
let mounted = ${isSvelte5Plus() ? '$state(false)' : 'false'};
|
|
93
|
+
let navigated = ${isSvelte5Plus() ? '$state(false)' : 'false'};
|
|
94
|
+
let title = ${isSvelte5Plus() ? '$state(null)' : 'null'};
|
|
65
95
|
|
|
66
96
|
onMount(() => {
|
|
67
97
|
const unsubscribe = stores.page.subscribe(() => {
|
|
@@ -139,8 +139,9 @@ export function get_tsconfig(kit, include_base_url) {
|
|
|
139
139
|
// This is required for svelte-package to work as expected
|
|
140
140
|
// Can be overwritten
|
|
141
141
|
lib: ['esnext', 'DOM', 'DOM.Iterable'],
|
|
142
|
-
moduleResolution: 'node',
|
|
142
|
+
moduleResolution: 'node', // TODO change to "bundler" in SvelteKit v2
|
|
143
143
|
module: 'esnext',
|
|
144
|
+
noEmit: true, // prevent tsconfig error "overwriting input files" - Vite handles the build and ignores this
|
|
144
145
|
target: 'esnext',
|
|
145
146
|
|
|
146
147
|
// TODO(v2): use the new flag verbatimModuleSyntax instead (requires support by Vite/Esbuild)
|
|
@@ -181,8 +182,8 @@ function validate_user_config(kit, cwd, out, config) {
|
|
|
181
182
|
typeof extend === 'string'
|
|
182
183
|
? path.resolve(cwd, extend) === out
|
|
183
184
|
: Array.isArray(extend)
|
|
184
|
-
|
|
185
|
-
|
|
185
|
+
? extend.some((e) => path.resolve(cwd, e) === out)
|
|
186
|
+
: false;
|
|
186
187
|
|
|
187
188
|
const options = config.options.compilerOptions || {};
|
|
188
189
|
|
package/src/exports/public.d.ts
CHANGED
|
@@ -42,12 +42,12 @@ export interface Adapter {
|
|
|
42
42
|
type AwaitedPropertiesUnion<input extends Record<string, any> | void> = input extends void
|
|
43
43
|
? undefined // needs to be undefined, because void will break intellisense
|
|
44
44
|
: input extends Record<string, any>
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
45
|
+
? {
|
|
46
|
+
[key in keyof input]: Awaited<input[key]>;
|
|
47
|
+
}
|
|
48
|
+
: {} extends input // handles the any case
|
|
49
|
+
? input
|
|
50
|
+
: unknown;
|
|
51
51
|
|
|
52
52
|
export type AwaitedProperties<input extends Record<string, any> | void> =
|
|
53
53
|
AwaitedPropertiesUnion<input> extends Record<string, any>
|
|
@@ -70,8 +70,8 @@ type OptionalUnion<
|
|
|
70
70
|
type UnpackValidationError<T> = T extends ActionFailure<infer X>
|
|
71
71
|
? X
|
|
72
72
|
: T extends void
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
? undefined // needs to be undefined, because void will corrupt union type
|
|
74
|
+
: T;
|
|
75
75
|
|
|
76
76
|
/**
|
|
77
77
|
* This object is passed to the `adapt` function of adapters.
|
|
@@ -102,7 +102,7 @@ export async function preview(vite, vite_config, svelte_config) {
|
|
|
102
102
|
return;
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
const { pathname } = new URL(/** @type {string} */ (req.url), 'http://dummy');
|
|
105
|
+
const { pathname, search } = new URL(/** @type {string} */ (req.url), 'http://dummy');
|
|
106
106
|
|
|
107
107
|
let filename = normalizePath(
|
|
108
108
|
join(svelte_config.kit.outDir, 'output/prerendered/pages' + pathname)
|
|
@@ -113,6 +113,7 @@ export async function preview(vite, vite_config, svelte_config) {
|
|
|
113
113
|
const has_trailing_slash = pathname.endsWith('/');
|
|
114
114
|
const html_filename = `${filename}${has_trailing_slash ? 'index.html' : '.html'}`;
|
|
115
115
|
|
|
116
|
+
/** @type {string | undefined} */
|
|
116
117
|
let redirect;
|
|
117
118
|
|
|
118
119
|
if (is_file(html_filename)) {
|
|
@@ -127,6 +128,7 @@ export async function preview(vite, vite_config, svelte_config) {
|
|
|
127
128
|
}
|
|
128
129
|
|
|
129
130
|
if (redirect) {
|
|
131
|
+
if (search) redirect += search;
|
|
130
132
|
res.writeHead(307, {
|
|
131
133
|
location: redirect
|
|
132
134
|
});
|
|
@@ -55,6 +55,17 @@ function update_scroll_positions(index) {
|
|
|
55
55
|
scroll_positions[index] = scroll_state();
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
+
/**
|
|
59
|
+
* Loads `href` the old-fashioned way, with a full page reload.
|
|
60
|
+
* Returns a `Promise` that never resolves (to prevent any
|
|
61
|
+
* subsequent work, e.g. history manipulation, from happening)
|
|
62
|
+
* @param {URL} url
|
|
63
|
+
*/
|
|
64
|
+
function native_navigation(url) {
|
|
65
|
+
location.href = url.href;
|
|
66
|
+
return new Promise(() => {});
|
|
67
|
+
}
|
|
68
|
+
|
|
58
69
|
/**
|
|
59
70
|
* @param {import('./types.js').SvelteKitApp} app
|
|
60
71
|
* @param {HTMLElement} target
|
|
@@ -535,10 +546,10 @@ export function create_client(app, target) {
|
|
|
535
546
|
typeof data !== 'object'
|
|
536
547
|
? `a ${typeof data}`
|
|
537
548
|
: data instanceof Response
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
549
|
+
? 'a Response object'
|
|
550
|
+
: Array.isArray(data)
|
|
551
|
+
? 'an array'
|
|
552
|
+
: 'a non-plain object'
|
|
542
553
|
}, but must return a plain object at the top level (i.e. \`return {...}\`)`
|
|
543
554
|
);
|
|
544
555
|
}
|
|
@@ -1196,17 +1207,6 @@ export function create_client(app, target) {
|
|
|
1196
1207
|
return await native_navigation(url);
|
|
1197
1208
|
}
|
|
1198
1209
|
|
|
1199
|
-
/**
|
|
1200
|
-
* Loads `href` the old-fashioned way, with a full page reload.
|
|
1201
|
-
* Returns a `Promise` that never resolves (to prevent any
|
|
1202
|
-
* subsequent work, e.g. history manipulation, from happening)
|
|
1203
|
-
* @param {URL} url
|
|
1204
|
-
*/
|
|
1205
|
-
function native_navigation(url) {
|
|
1206
|
-
location.href = url.href;
|
|
1207
|
-
return new Promise(() => {});
|
|
1208
|
-
}
|
|
1209
|
-
|
|
1210
1210
|
if (import.meta.hot) {
|
|
1211
1211
|
import.meta.hot.on('vite:beforeUpdate', () => {
|
|
1212
1212
|
if (current.error) location.reload();
|
|
@@ -1842,7 +1842,7 @@ export function create_client(app, target) {
|
|
|
1842
1842
|
/**
|
|
1843
1843
|
* @param {URL} url
|
|
1844
1844
|
* @param {boolean[]} invalid
|
|
1845
|
-
* @returns {Promise<import('types').ServerNodesResponse |import('types').ServerRedirectNode>}
|
|
1845
|
+
* @returns {Promise<import('types').ServerNodesResponse | import('types').ServerRedirectNode>}
|
|
1846
1846
|
*/
|
|
1847
1847
|
async function load_data(url, invalid) {
|
|
1848
1848
|
const data_url = new URL(url);
|
|
@@ -1857,13 +1857,19 @@ async function load_data(url, invalid) {
|
|
|
1857
1857
|
|
|
1858
1858
|
const res = await native_fetch(data_url.href);
|
|
1859
1859
|
|
|
1860
|
+
// if `__data.json` doesn't exist or the server has an internal error,
|
|
1861
|
+
// fallback to native navigation so we avoid parsing the HTML error page as a JSON
|
|
1862
|
+
if (res.headers.get('content-type')?.includes('text/html')) {
|
|
1863
|
+
await native_navigation(url);
|
|
1864
|
+
}
|
|
1865
|
+
|
|
1860
1866
|
if (!res.ok) {
|
|
1861
1867
|
// error message is a JSON-stringified string which devalue can't handle at the top level
|
|
1862
1868
|
// turn it into a HttpError to not call handleError on the client again (was already handled on the server)
|
|
1863
1869
|
throw new HttpError(res.status, await res.json());
|
|
1864
1870
|
}
|
|
1865
1871
|
|
|
1866
|
-
// TODO: fix eslint error
|
|
1872
|
+
// TODO: fix eslint error / figure out if it actually applies to our situation
|
|
1867
1873
|
// eslint-disable-next-line
|
|
1868
1874
|
return new Promise(async (resolve) => {
|
|
1869
1875
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<slot
|
|
1
|
+
<slot />
|
|
@@ -291,7 +291,7 @@ export async function render_page(event, page, options, manifest, state, resolve
|
|
|
291
291
|
resolve_opts,
|
|
292
292
|
page_config: {
|
|
293
293
|
csr: get_option(nodes, 'csr') ?? true,
|
|
294
|
-
ssr: true
|
|
294
|
+
ssr: get_option(nodes, 'ssr') ?? true
|
|
295
295
|
},
|
|
296
296
|
status,
|
|
297
297
|
error: null,
|
|
@@ -359,10 +359,10 @@ function validate_load_response(data, routeId) {
|
|
|
359
359
|
typeof data !== 'object'
|
|
360
360
|
? `a ${typeof data}`
|
|
361
361
|
: data instanceof Response
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
362
|
+
? 'a Response object'
|
|
363
|
+
: Array.isArray(data)
|
|
364
|
+
? 'an array'
|
|
365
|
+
: 'a non-plain object'
|
|
366
366
|
}, but must return a plain object at the top level (i.e. \`return {...}\`)`
|
|
367
367
|
);
|
|
368
368
|
}
|
|
@@ -341,8 +341,8 @@ export async function respond(request, options, manifest, state) {
|
|
|
341
341
|
const response = is_data_request
|
|
342
342
|
? redirect_json_response(e)
|
|
343
343
|
: route?.page && is_action_json_request(event)
|
|
344
|
-
|
|
345
|
-
|
|
344
|
+
? action_json_redirect(e)
|
|
345
|
+
: redirect_response(e.status, e.location);
|
|
346
346
|
add_cookies_to_headers(response.headers, Object.values(cookies_to_add));
|
|
347
347
|
return response;
|
|
348
348
|
}
|
package/src/version.js
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -22,12 +22,12 @@ declare module '@sveltejs/kit' {
|
|
|
22
22
|
type AwaitedPropertiesUnion<input extends Record<string, any> | void> = input extends void
|
|
23
23
|
? undefined // needs to be undefined, because void will break intellisense
|
|
24
24
|
: input extends Record<string, any>
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
25
|
+
? {
|
|
26
|
+
[key in keyof input]: Awaited<input[key]>;
|
|
27
|
+
}
|
|
28
|
+
: {} extends input // handles the any case
|
|
29
|
+
? input
|
|
30
|
+
: unknown;
|
|
31
31
|
|
|
32
32
|
export type AwaitedProperties<input extends Record<string, any> | void> =
|
|
33
33
|
AwaitedPropertiesUnion<input> extends Record<string, any>
|
|
@@ -50,8 +50,8 @@ declare module '@sveltejs/kit' {
|
|
|
50
50
|
type UnpackValidationError<T> = T extends ActionFailure<infer X>
|
|
51
51
|
? X
|
|
52
52
|
: T extends void
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
? undefined // needs to be undefined, because void will corrupt union type
|
|
54
|
+
: T;
|
|
55
55
|
|
|
56
56
|
/**
|
|
57
57
|
* This object is passed to the `adapt` function of adapters.
|