@sveltejs/kit 2.6.4 → 2.7.0
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/exports/public.d.ts +3 -1
- package/src/exports/vite/dev/index.js +11 -2
- package/src/exports/vite/preview/index.js +7 -1
- package/src/runtime/client/client.js +18 -1
- package/src/runtime/server/fetch.js +14 -2
- package/src/runtime/server/page/render.js +7 -5
- package/src/version.js +1 -1
- package/types/index.d.ts +3 -1
- package/types/index.d.ts.map +1 -1
package/package.json
CHANGED
package/src/exports/public.d.ts
CHANGED
|
@@ -332,8 +332,10 @@ export interface KitConfig {
|
|
|
332
332
|
* directives: {
|
|
333
333
|
* 'script-src': ['self']
|
|
334
334
|
* },
|
|
335
|
+
* // must be specified with either the `report-uri` or `report-to` directives, or both
|
|
335
336
|
* reportOnly: {
|
|
336
|
-
* 'script-src': ['self']
|
|
337
|
+
* 'script-src': ['self'],
|
|
338
|
+
* 'report-uri': ['/']
|
|
337
339
|
* }
|
|
338
340
|
* }
|
|
339
341
|
* }
|
|
@@ -272,7 +272,10 @@ export async function dev(vite, vite_config, svelte_config) {
|
|
|
272
272
|
function fix_stack_trace(error) {
|
|
273
273
|
try {
|
|
274
274
|
vite.ssrFixStacktrace(error);
|
|
275
|
-
} catch {
|
|
275
|
+
} catch {
|
|
276
|
+
// ssrFixStacktrace can fail on StackBlitz web containers and we don't know why
|
|
277
|
+
// by ignoring it the line numbers are wrong, but at least we can show the error
|
|
278
|
+
}
|
|
276
279
|
return error.stack;
|
|
277
280
|
}
|
|
278
281
|
|
|
@@ -524,7 +527,13 @@ export async function dev(vite, vite_config, svelte_config) {
|
|
|
524
527
|
if (remoteAddress) return remoteAddress;
|
|
525
528
|
throw new Error('Could not determine clientAddress');
|
|
526
529
|
},
|
|
527
|
-
read: (file) =>
|
|
530
|
+
read: (file) => {
|
|
531
|
+
if (file in manifest._.server_assets) {
|
|
532
|
+
return fs.readFileSync(from_fs(file));
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
return fs.readFileSync(path.join(svelte_config.kit.files.assets, file));
|
|
536
|
+
},
|
|
528
537
|
before_handle: (event, config, prerender) => {
|
|
529
538
|
async_local_storage.enterWith({ event, config, prerender });
|
|
530
539
|
},
|
|
@@ -193,7 +193,13 @@ export async function preview(vite, vite_config, svelte_config) {
|
|
|
193
193
|
if (remoteAddress) return remoteAddress;
|
|
194
194
|
throw new Error('Could not determine clientAddress');
|
|
195
195
|
},
|
|
196
|
-
read: (file) =>
|
|
196
|
+
read: (file) => {
|
|
197
|
+
if (file in manifest._.server_assets) {
|
|
198
|
+
return fs.readFileSync(join(dir, file));
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
return fs.readFileSync(join(svelte_config.kit.files.assets, file));
|
|
202
|
+
},
|
|
197
203
|
emulator
|
|
198
204
|
})
|
|
199
205
|
);
|
|
@@ -146,6 +146,19 @@ function native_navigation(url) {
|
|
|
146
146
|
return new Promise(() => {});
|
|
147
147
|
}
|
|
148
148
|
|
|
149
|
+
/**
|
|
150
|
+
* Checks whether a service worker is registered, and if it is,
|
|
151
|
+
* tries to update it.
|
|
152
|
+
*/
|
|
153
|
+
async function update_service_worker() {
|
|
154
|
+
if ('serviceWorker' in navigator) {
|
|
155
|
+
const registration = await navigator.serviceWorker.getRegistration(base || '/');
|
|
156
|
+
if (registration) {
|
|
157
|
+
await registration.update();
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
149
162
|
function noop() {}
|
|
150
163
|
|
|
151
164
|
/** @type {import('types').CSRRoute[]} */
|
|
@@ -1003,6 +1016,8 @@ async function load_route({ id, invalidating, url, params, route, preload }) {
|
|
|
1003
1016
|
// Referenced node could have been removed due to redeploy, check
|
|
1004
1017
|
const updated = await stores.updated.check();
|
|
1005
1018
|
if (updated) {
|
|
1019
|
+
// Before reloading, try to update the service worker if it exists
|
|
1020
|
+
await update_service_worker();
|
|
1006
1021
|
return await native_navigation(url);
|
|
1007
1022
|
}
|
|
1008
1023
|
|
|
@@ -1327,6 +1342,8 @@ async function navigate({
|
|
|
1327
1342
|
} else if (/** @type {number} */ (navigation_result.props.page.status) >= 400) {
|
|
1328
1343
|
const updated = await stores.updated.check();
|
|
1329
1344
|
if (updated) {
|
|
1345
|
+
// Before reloading, try to update the service worker if it exists
|
|
1346
|
+
await update_service_worker();
|
|
1330
1347
|
await native_navigation(url);
|
|
1331
1348
|
}
|
|
1332
1349
|
}
|
|
@@ -2104,7 +2121,7 @@ function _start_router() {
|
|
|
2104
2121
|
if (hash === '' || (hash === 'top' && a.ownerDocument.getElementById('top') === null)) {
|
|
2105
2122
|
window.scrollTo({ top: 0 });
|
|
2106
2123
|
} else {
|
|
2107
|
-
a.ownerDocument.getElementById(hash)?.scrollIntoView();
|
|
2124
|
+
a.ownerDocument.getElementById(decodeURIComponent(hash))?.scrollIntoView();
|
|
2108
2125
|
}
|
|
2109
2126
|
|
|
2110
2127
|
return;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as set_cookie_parser from 'set-cookie-parser';
|
|
2
2
|
import { respond } from './respond.js';
|
|
3
3
|
import * as paths from '__sveltekit/paths';
|
|
4
|
+
import { read_implementation } from '__sveltekit/server';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* @param {{
|
|
@@ -81,8 +82,9 @@ export function create_fetch({ event, options, manifest, state, get_cookie_heade
|
|
|
81
82
|
).slice(1);
|
|
82
83
|
const filename_html = `${filename}/index.html`; // path may also match path/index.html
|
|
83
84
|
|
|
84
|
-
const is_asset = manifest.assets.has(filename);
|
|
85
|
-
const is_asset_html =
|
|
85
|
+
const is_asset = manifest.assets.has(filename) || filename in manifest._.server_assets;
|
|
86
|
+
const is_asset_html =
|
|
87
|
+
manifest.assets.has(filename_html) || filename_html in manifest._.server_assets;
|
|
86
88
|
|
|
87
89
|
if (is_asset || is_asset_html) {
|
|
88
90
|
const file = is_asset ? filename : filename_html;
|
|
@@ -95,6 +97,16 @@ export function create_fetch({ event, options, manifest, state, get_cookie_heade
|
|
|
95
97
|
return new Response(state.read(file), {
|
|
96
98
|
headers: type ? { 'content-type': type } : {}
|
|
97
99
|
});
|
|
100
|
+
} else if (read_implementation) {
|
|
101
|
+
const length = manifest._.server_assets[file];
|
|
102
|
+
const type = manifest.mimeTypes[file.slice(file.lastIndexOf('.'))];
|
|
103
|
+
|
|
104
|
+
return new Response(read_implementation(file), {
|
|
105
|
+
headers: {
|
|
106
|
+
'Content-Length': '' + length,
|
|
107
|
+
'Content-Type': type
|
|
108
|
+
}
|
|
109
|
+
});
|
|
98
110
|
}
|
|
99
111
|
|
|
100
112
|
return await fetch(request);
|
|
@@ -265,6 +265,7 @@ export async function render_response({
|
|
|
265
265
|
event,
|
|
266
266
|
options,
|
|
267
267
|
branch.map((b) => b.server_data),
|
|
268
|
+
csp,
|
|
268
269
|
global
|
|
269
270
|
);
|
|
270
271
|
|
|
@@ -511,9 +512,7 @@ export async function render_response({
|
|
|
511
512
|
type: 'bytes'
|
|
512
513
|
}),
|
|
513
514
|
{
|
|
514
|
-
headers
|
|
515
|
-
'content-type': 'text/html'
|
|
516
|
-
}
|
|
515
|
+
headers
|
|
517
516
|
}
|
|
518
517
|
);
|
|
519
518
|
}
|
|
@@ -524,10 +523,11 @@ export async function render_response({
|
|
|
524
523
|
* @param {import('@sveltejs/kit').RequestEvent} event
|
|
525
524
|
* @param {import('types').SSROptions} options
|
|
526
525
|
* @param {Array<import('types').ServerDataNode | null>} nodes
|
|
526
|
+
* @param {import('./csp.js').Csp} csp
|
|
527
527
|
* @param {string} global
|
|
528
528
|
* @returns {{ data: string, chunks: AsyncIterable<string> | null }}
|
|
529
529
|
*/
|
|
530
|
-
function get_data(event, options, nodes, global) {
|
|
530
|
+
function get_data(event, options, nodes, csp, global) {
|
|
531
531
|
let promise_id = 1;
|
|
532
532
|
let count = 0;
|
|
533
533
|
|
|
@@ -566,7 +566,9 @@ function get_data(event, options, nodes, global) {
|
|
|
566
566
|
str = devalue.uneval({ id, data, error }, replacer);
|
|
567
567
|
}
|
|
568
568
|
|
|
569
|
-
push(
|
|
569
|
+
push(
|
|
570
|
+
`<script${csp.script_needs_nonce ? ` nonce="${csp.nonce}"` : ''}>${global}.resolve(${str})</script>\n`
|
|
571
|
+
);
|
|
570
572
|
if (count === 0) done();
|
|
571
573
|
}
|
|
572
574
|
);
|
package/src/version.js
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -314,8 +314,10 @@ declare module '@sveltejs/kit' {
|
|
|
314
314
|
* directives: {
|
|
315
315
|
* 'script-src': ['self']
|
|
316
316
|
* },
|
|
317
|
+
* // must be specified with either the `report-uri` or `report-to` directives, or both
|
|
317
318
|
* reportOnly: {
|
|
318
|
-
* 'script-src': ['self']
|
|
319
|
+
* 'script-src': ['self'],
|
|
320
|
+
* 'report-uri': ['/']
|
|
319
321
|
* }
|
|
320
322
|
* }
|
|
321
323
|
* }
|
package/types/index.d.ts.map
CHANGED
|
@@ -154,6 +154,6 @@
|
|
|
154
154
|
null,
|
|
155
155
|
null
|
|
156
156
|
],
|
|
157
|
-
"mappings": ";;;;;;;;;kBA2BiBA,OAAOA;;;;;;;;;;;;;;;;;;;;;;;;;;;aA2BZC,cAAcA;;;;;;aAMdC,cAAcA;;;;;;;;;;;;;;;kBAeTC,aAAaA;;;;;;;;;;;;;;;;;kBAiBbC,OAAOA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAkGPC,MAAMA;;;;;;;;;;;;;;;;;;;;;kBAqBNC,OAAOA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBA4DPC,QAAQA;;;;;;;;kBAQRC,SAASA
|
|
157
|
+
"mappings": ";;;;;;;;;kBA2BiBA,OAAOA;;;;;;;;;;;;;;;;;;;;;;;;;;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