@sveltejs/kit 2.6.3 → 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/constants.js +0 -12
- package/src/core/postbuild/prerender.js +7 -1
- package/src/exports/public.d.ts +9 -7
- package/src/exports/vite/dev/index.js +27 -22
- package/src/exports/vite/index.js +6 -60
- package/src/exports/vite/preview/index.js +7 -1
- package/src/runtime/client/client.js +22 -2
- package/src/runtime/server/fetch.js +14 -2
- package/src/runtime/server/page/render.js +7 -5
- package/src/runtime/server/utils.js +0 -14
- package/src/types/synthetic/$lib.md +1 -1
- package/src/version.js +1 -1
- package/types/index.d.ts +9 -7
- package/types/index.d.ts.map +1 -1
package/package.json
CHANGED
package/src/constants.js
CHANGED
|
@@ -9,15 +9,3 @@ export const GENERATED_COMMENT = '// this file is generated — do not edit it\n
|
|
|
9
9
|
export const ENDPOINT_METHODS = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS', 'HEAD'];
|
|
10
10
|
|
|
11
11
|
export const PAGE_METHODS = ['GET', 'POST', 'HEAD'];
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Placeholders for the hash of the app version.
|
|
15
|
-
* Later replaced in the generateBundle hook to avoid affecting the chunk hash.
|
|
16
|
-
*/
|
|
17
|
-
export const APP_VERSION_HASH_PLACEHOLDER_BASE = '__SVELTEKIT_APP_VERSION_HASH__';
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Placeholder for the app version.
|
|
21
|
-
* Later replaced in the generateBundle hook to avoid affecting the chunk hash.
|
|
22
|
-
*/
|
|
23
|
-
export const APP_VERSION_PLACEHOLDER_BASE = '__SVELTEKIT_APP_VERSION__';
|
|
@@ -16,6 +16,12 @@ import { createReadableStream } from '@sveltejs/kit/node';
|
|
|
16
16
|
|
|
17
17
|
export default forked(import.meta.url, prerender);
|
|
18
18
|
|
|
19
|
+
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#scrolling-to-a-fragment
|
|
20
|
+
// "If fragment is the empty string, then return the special value top of the document."
|
|
21
|
+
// ...and
|
|
22
|
+
// "If decodedFragment is an ASCII case-insensitive match for the string 'top', then return the top of the document."
|
|
23
|
+
const SPECIAL_HASHLINKS = new Set(['', 'top']);
|
|
24
|
+
|
|
19
25
|
/**
|
|
20
26
|
* @param {{
|
|
21
27
|
* out: string;
|
|
@@ -485,7 +491,7 @@ async function prerender({ out, manifest_path, metadata, verbose, env }) {
|
|
|
485
491
|
// ignore fragment links to pages that were not prerendered
|
|
486
492
|
if (!hashlinks) continue;
|
|
487
493
|
|
|
488
|
-
if (!hashlinks.includes(id)) {
|
|
494
|
+
if (!hashlinks.includes(id) && !SPECIAL_HASHLINKS.has(id)) {
|
|
489
495
|
handle_missing_id({ id, path, referrers: Array.from(referrers) });
|
|
490
496
|
}
|
|
491
497
|
}
|
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
|
* }
|
|
@@ -396,12 +398,12 @@ export interface KitConfig {
|
|
|
396
398
|
*/
|
|
397
399
|
dir?: string;
|
|
398
400
|
/**
|
|
399
|
-
* A prefix that signals that an environment variable is safe to expose to client-side code. See [`$env/static/public`](/docs/modules#$env-static-public) and [`$env/dynamic/public`](/docs/modules#$env-dynamic-public). Note that Vite's [`envPrefix`](https://vitejs.dev/config/shared-options.html#envprefix) must be set separately if you are using Vite's environment variable handling - though use of that feature should generally be unnecessary.
|
|
401
|
+
* A prefix that signals that an environment variable is safe to expose to client-side code. See [`$env/static/public`](https://kit.svelte.dev/docs/modules#$env-static-public) and [`$env/dynamic/public`](https://kit.svelte.dev/docs/modules#$env-dynamic-public). Note that Vite's [`envPrefix`](https://vitejs.dev/config/shared-options.html#envprefix) must be set separately if you are using Vite's environment variable handling - though use of that feature should generally be unnecessary.
|
|
400
402
|
* @default "PUBLIC_"
|
|
401
403
|
*/
|
|
402
404
|
publicPrefix?: string;
|
|
403
405
|
/**
|
|
404
|
-
* A prefix that signals that an environment variable is unsafe to expose to client-side code. Environment variables matching neither the public nor the private prefix will be discarded completely. See [`$env/static/private`](/docs/modules#$env-static-private) and [`$env/dynamic/private`](/docs/modules#$env-dynamic-private).
|
|
406
|
+
* A prefix that signals that an environment variable is unsafe to expose to client-side code. Environment variables matching neither the public nor the private prefix will be discarded completely. See [`$env/static/private`](https://kit.svelte.dev/docs/modules#$env-static-private) and [`$env/dynamic/private`](https://kit.svelte.dev/docs/modules#$env-dynamic-private).
|
|
405
407
|
* @default ""
|
|
406
408
|
* @since 1.21.0
|
|
407
409
|
*/
|
|
@@ -504,7 +506,7 @@ export interface KitConfig {
|
|
|
504
506
|
*/
|
|
505
507
|
assets?: '' | `http://${string}` | `https://${string}`;
|
|
506
508
|
/**
|
|
507
|
-
* A root-relative path that must start, but not end with `/` (e.g. `/base-path`), unless it is the empty string. This specifies where your app is served from and allows the app to live on a non-root path. Note that you need to prepend all your root-relative links with the base value or they will point to the root of your domain, not your `base` (this is how the browser works). You can use [`base` from `$app/paths`](/docs/modules#$app-paths-base) for that: `<a href="{base}/your-page">Link</a>`. If you find yourself writing this often, it may make sense to extract this into a reusable component.
|
|
509
|
+
* A root-relative path that must start, but not end with `/` (e.g. `/base-path`), unless it is the empty string. This specifies where your app is served from and allows the app to live on a non-root path. Note that you need to prepend all your root-relative links with the base value or they will point to the root of your domain, not your `base` (this is how the browser works). You can use [`base` from `$app/paths`](https://kit.svelte.dev/docs/modules#$app-paths-base) for that: `<a href="{base}/your-page">Link</a>`. If you find yourself writing this often, it may make sense to extract this into a reusable component.
|
|
508
510
|
* @default ""
|
|
509
511
|
*/
|
|
510
512
|
base?: '' | `/${string}`;
|
|
@@ -646,7 +648,7 @@ export interface KitConfig {
|
|
|
646
648
|
* </script>
|
|
647
649
|
* ```
|
|
648
650
|
*
|
|
649
|
-
* If you set `pollInterval` to a non-zero value, SvelteKit will poll for new versions in the background and set the value of the [`updated`](/docs/modules#$app-stores-updated) store to `true` when it detects one.
|
|
651
|
+
* If you set `pollInterval` to a non-zero value, SvelteKit will poll for new versions in the background and set the value of the [`updated`](https://kit.svelte.dev/docs/modules#$app-stores-updated) store to `true` when it detects one.
|
|
650
652
|
*/
|
|
651
653
|
version?: {
|
|
652
654
|
/**
|
|
@@ -799,7 +801,7 @@ export interface LoadEvent<
|
|
|
799
801
|
*/
|
|
800
802
|
parent(): Promise<ParentData>;
|
|
801
803
|
/**
|
|
802
|
-
* This function declares that the `load` function has a _dependency_ on one or more URLs or custom identifiers, which can subsequently be used with [`invalidate()`](/docs/modules#$app-navigation-invalidate) to cause `load` to rerun.
|
|
804
|
+
* This function declares that the `load` function has a _dependency_ on one or more URLs or custom identifiers, which can subsequently be used with [`invalidate()`](https://kit.svelte.dev/docs/modules#$app-navigation-invalidate) to cause `load` to rerun.
|
|
803
805
|
*
|
|
804
806
|
* Most of the time you won't need this, as `fetch` calls `depends` on your behalf — it's only necessary if you're using a custom API client that bypasses `fetch`.
|
|
805
807
|
*
|
|
@@ -1223,7 +1225,7 @@ export interface ServerLoadEvent<
|
|
|
1223
1225
|
*/
|
|
1224
1226
|
parent(): Promise<ParentData>;
|
|
1225
1227
|
/**
|
|
1226
|
-
* This function declares that the `load` function has a _dependency_ on one or more URLs or custom identifiers, which can subsequently be used with [`invalidate()`](/docs/modules#$app-navigation-invalidate) to cause `load` to rerun.
|
|
1228
|
+
* This function declares that the `load` function has a _dependency_ on one or more URLs or custom identifiers, which can subsequently be used with [`invalidate()`](https://kit.svelte.dev/docs/modules#$app-navigation-invalidate) to cause `load` to rerun.
|
|
1227
1229
|
*
|
|
1228
1230
|
* Most of the time you won't need this, as `fetch` calls `depends` on your behalf — it's only necessary if you're using a custom API client that bypasses `fetch`.
|
|
1229
1231
|
*
|
|
@@ -270,7 +270,12 @@ export async function dev(vite, vite_config, svelte_config) {
|
|
|
270
270
|
|
|
271
271
|
/** @param {Error} error */
|
|
272
272
|
function fix_stack_trace(error) {
|
|
273
|
-
|
|
273
|
+
try {
|
|
274
|
+
vite.ssrFixStacktrace(error);
|
|
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
|
+
}
|
|
274
279
|
return error.stack;
|
|
275
280
|
}
|
|
276
281
|
|
|
@@ -391,32 +396,26 @@ export async function dev(vite, vite_config, svelte_config) {
|
|
|
391
396
|
};
|
|
392
397
|
|
|
393
398
|
vite.middlewares.use((req, res, next) => {
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
}`;
|
|
399
|
+
const base = `${vite.config.server.https ? 'https' : 'http'}://${
|
|
400
|
+
req.headers[':authority'] || req.headers.host
|
|
401
|
+
}`;
|
|
398
402
|
|
|
399
|
-
|
|
403
|
+
const decoded = decodeURI(new URL(base + req.url).pathname);
|
|
400
404
|
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
405
|
+
if (decoded.startsWith(assets)) {
|
|
406
|
+
const pathname = decoded.slice(assets.length);
|
|
407
|
+
const file = svelte_config.kit.files.assets + pathname;
|
|
404
408
|
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
}
|
|
409
|
+
if (fs.existsSync(file) && !fs.statSync(file).isDirectory()) {
|
|
410
|
+
if (has_correct_case(file, svelte_config.kit.files.assets)) {
|
|
411
|
+
req.url = encodeURI(pathname); // don't need query/hash
|
|
412
|
+
asset_server(req, res);
|
|
413
|
+
return;
|
|
411
414
|
}
|
|
412
415
|
}
|
|
413
|
-
|
|
414
|
-
next();
|
|
415
|
-
} catch (e) {
|
|
416
|
-
const error = coalesce_to_error(e);
|
|
417
|
-
res.statusCode = 500;
|
|
418
|
-
res.end(fix_stack_trace(error));
|
|
419
416
|
}
|
|
417
|
+
|
|
418
|
+
next();
|
|
420
419
|
});
|
|
421
420
|
|
|
422
421
|
const env = loadEnv(vite_config.mode, svelte_config.kit.env.dir, '');
|
|
@@ -528,7 +527,13 @@ export async function dev(vite, vite_config, svelte_config) {
|
|
|
528
527
|
if (remoteAddress) return remoteAddress;
|
|
529
528
|
throw new Error('Could not determine clientAddress');
|
|
530
529
|
},
|
|
531
|
-
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
|
+
},
|
|
532
537
|
before_handle: (event, config, prerender) => {
|
|
533
538
|
async_local_storage.enterWith({ event, config, prerender });
|
|
534
539
|
},
|
|
@@ -35,10 +35,6 @@ import {
|
|
|
35
35
|
sveltekit_server
|
|
36
36
|
} from './module_ids.js';
|
|
37
37
|
import { resolve_peer_dependency } from '../../utils/import.js';
|
|
38
|
-
import {
|
|
39
|
-
APP_VERSION_PLACEHOLDER_BASE,
|
|
40
|
-
APP_VERSION_HASH_PLACEHOLDER_BASE
|
|
41
|
-
} from '../../constants.js';
|
|
42
38
|
|
|
43
39
|
const cwd = process.cwd();
|
|
44
40
|
|
|
@@ -188,16 +184,7 @@ async function kit({ svelte_config }) {
|
|
|
188
184
|
const { kit } = svelte_config;
|
|
189
185
|
const out = `${kit.outDir}/output`;
|
|
190
186
|
|
|
191
|
-
const
|
|
192
|
-
const version_hash = hash(app_version);
|
|
193
|
-
|
|
194
|
-
// if the app version or hash is longer than the placeholder, we need to pad it to avoid
|
|
195
|
-
// source map damage
|
|
196
|
-
const app_version_placeholder = APP_VERSION_PLACEHOLDER_BASE.padEnd(app_version.length, '_');
|
|
197
|
-
const app_version_hash_placeholder = APP_VERSION_HASH_PLACEHOLDER_BASE.padEnd(
|
|
198
|
-
version_hash.length,
|
|
199
|
-
'_'
|
|
200
|
-
);
|
|
187
|
+
const version_hash = hash(kit.version.name);
|
|
201
188
|
|
|
202
189
|
/** @type {import('vite').ResolvedConfig} */
|
|
203
190
|
let vite_config;
|
|
@@ -397,7 +384,7 @@ async function kit({ svelte_config }) {
|
|
|
397
384
|
const browser = !options?.ssr;
|
|
398
385
|
|
|
399
386
|
const global = is_build
|
|
400
|
-
? `globalThis.__sveltekit_${
|
|
387
|
+
? `globalThis.__sveltekit_${version_hash}`
|
|
401
388
|
: 'globalThis.__sveltekit_dev';
|
|
402
389
|
|
|
403
390
|
if (options?.ssr === false && process.env.TEST !== 'true') {
|
|
@@ -483,8 +470,10 @@ async function kit({ svelte_config }) {
|
|
|
483
470
|
}
|
|
484
471
|
|
|
485
472
|
case sveltekit_environment: {
|
|
473
|
+
const { version } = svelte_config.kit;
|
|
474
|
+
|
|
486
475
|
return dedent`
|
|
487
|
-
export const version = ${
|
|
476
|
+
export const version = ${s(version.name)};
|
|
488
477
|
export let building = false;
|
|
489
478
|
export let prerendering = false;
|
|
490
479
|
|
|
@@ -934,50 +923,7 @@ async function kit({ svelte_config }) {
|
|
|
934
923
|
}
|
|
935
924
|
};
|
|
936
925
|
|
|
937
|
-
|
|
938
|
-
const plugin_replace_version_and_hash = {
|
|
939
|
-
name: 'vite-plugin-svelte-replace-version-and-hash',
|
|
940
|
-
enforce: 'post',
|
|
941
|
-
|
|
942
|
-
generateBundle(_, bundle, __) {
|
|
943
|
-
if (vite_config.build.ssr) return;
|
|
944
|
-
|
|
945
|
-
for (const file in bundle) {
|
|
946
|
-
if (bundle[file].type !== 'chunk') continue;
|
|
947
|
-
const chunk = /** @type {import('rollup').OutputChunk} */ (bundle[file]);
|
|
948
|
-
let code = chunk.code;
|
|
949
|
-
if (
|
|
950
|
-
!(code.includes(app_version_placeholder) || code.includes(app_version_hash_placeholder))
|
|
951
|
-
)
|
|
952
|
-
continue;
|
|
953
|
-
|
|
954
|
-
// replace the version and version after the chunk hash has already been calculated
|
|
955
|
-
// to avoid affecting the chunk hash
|
|
956
|
-
const substitutions = [
|
|
957
|
-
[app_version_hash_placeholder, version_hash],
|
|
958
|
-
[app_version_placeholder, JSON.stringify(kit.version.name)]
|
|
959
|
-
];
|
|
960
|
-
|
|
961
|
-
for (const [placeholder, replacement] of substitutions) {
|
|
962
|
-
code = code.replaceAll(
|
|
963
|
-
placeholder,
|
|
964
|
-
// pad the replacement to mitigate source map changes
|
|
965
|
-
replacement.padEnd(placeholder.length, ' ')
|
|
966
|
-
);
|
|
967
|
-
}
|
|
968
|
-
|
|
969
|
-
chunk.code = code;
|
|
970
|
-
}
|
|
971
|
-
}
|
|
972
|
-
};
|
|
973
|
-
|
|
974
|
-
return [
|
|
975
|
-
plugin_setup,
|
|
976
|
-
plugin_virtual_modules,
|
|
977
|
-
plugin_guard,
|
|
978
|
-
plugin_compile,
|
|
979
|
-
plugin_replace_version_and_hash
|
|
980
|
-
];
|
|
926
|
+
return [plugin_setup, plugin_virtual_modules, plugin_guard, plugin_compile];
|
|
981
927
|
}
|
|
982
928
|
|
|
983
929
|
/**
|
|
@@ -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
|
}
|
|
@@ -1543,7 +1560,10 @@ function setup_preload() {
|
|
|
1543
1560
|
|
|
1544
1561
|
const options = get_router_options(a);
|
|
1545
1562
|
|
|
1546
|
-
|
|
1563
|
+
// we don't want to preload data for a page we're already on
|
|
1564
|
+
const same_url = url && current.url.pathname + current.url.search === url.pathname + url.search;
|
|
1565
|
+
|
|
1566
|
+
if (!options.reload && !same_url) {
|
|
1547
1567
|
if (priority <= options.preload_data) {
|
|
1548
1568
|
const intent = get_navigation_intent(url, false);
|
|
1549
1569
|
if (intent) {
|
|
@@ -2101,7 +2121,7 @@ function _start_router() {
|
|
|
2101
2121
|
if (hash === '' || (hash === 'top' && a.ownerDocument.getElementById('top') === null)) {
|
|
2102
2122
|
window.scrollTo({ top: 0 });
|
|
2103
2123
|
} else {
|
|
2104
|
-
a.ownerDocument.getElementById(hash)?.scrollIntoView();
|
|
2124
|
+
a.ownerDocument.getElementById(decodeURIComponent(hash))?.scrollIntoView();
|
|
2105
2125
|
}
|
|
2106
2126
|
|
|
2107
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
|
);
|
|
@@ -162,17 +162,3 @@ export function stringify_uses(node) {
|
|
|
162
162
|
|
|
163
163
|
return `"uses":{${uses.join(',')}}`;
|
|
164
164
|
}
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* @param {string} message
|
|
168
|
-
* @param {number} offset
|
|
169
|
-
*/
|
|
170
|
-
export function warn_with_callsite(message, offset = 0) {
|
|
171
|
-
if (DEV) {
|
|
172
|
-
const stack = fix_stack_trace(new Error()).split('\n');
|
|
173
|
-
const line = stack.at(3 + offset);
|
|
174
|
-
message += `\n${line}`;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
console.warn(message);
|
|
178
|
-
}
|
|
@@ -2,4 +2,4 @@ This is a simple alias to `src/lib`, or whatever directory is specified as [`con
|
|
|
2
2
|
|
|
3
3
|
### `$lib/server`
|
|
4
4
|
|
|
5
|
-
A subdirectory of `$lib`. SvelteKit will prevent you from importing any modules in `$lib/server` into client-side code. See [server-only modules](/docs/server-only-modules).
|
|
5
|
+
A subdirectory of `$lib`. SvelteKit will prevent you from importing any modules in `$lib/server` into client-side code. See [server-only modules](https://kit.svelte.dev/docs/server-only-modules).
|
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
|
* }
|
|
@@ -378,12 +380,12 @@ declare module '@sveltejs/kit' {
|
|
|
378
380
|
*/
|
|
379
381
|
dir?: string;
|
|
380
382
|
/**
|
|
381
|
-
* A prefix that signals that an environment variable is safe to expose to client-side code. See [`$env/static/public`](/docs/modules#$env-static-public) and [`$env/dynamic/public`](/docs/modules#$env-dynamic-public). Note that Vite's [`envPrefix`](https://vitejs.dev/config/shared-options.html#envprefix) must be set separately if you are using Vite's environment variable handling - though use of that feature should generally be unnecessary.
|
|
383
|
+
* A prefix that signals that an environment variable is safe to expose to client-side code. See [`$env/static/public`](https://kit.svelte.dev/docs/modules#$env-static-public) and [`$env/dynamic/public`](https://kit.svelte.dev/docs/modules#$env-dynamic-public). Note that Vite's [`envPrefix`](https://vitejs.dev/config/shared-options.html#envprefix) must be set separately if you are using Vite's environment variable handling - though use of that feature should generally be unnecessary.
|
|
382
384
|
* @default "PUBLIC_"
|
|
383
385
|
*/
|
|
384
386
|
publicPrefix?: string;
|
|
385
387
|
/**
|
|
386
|
-
* A prefix that signals that an environment variable is unsafe to expose to client-side code. Environment variables matching neither the public nor the private prefix will be discarded completely. See [`$env/static/private`](/docs/modules#$env-static-private) and [`$env/dynamic/private`](/docs/modules#$env-dynamic-private).
|
|
388
|
+
* A prefix that signals that an environment variable is unsafe to expose to client-side code. Environment variables matching neither the public nor the private prefix will be discarded completely. See [`$env/static/private`](https://kit.svelte.dev/docs/modules#$env-static-private) and [`$env/dynamic/private`](https://kit.svelte.dev/docs/modules#$env-dynamic-private).
|
|
387
389
|
* @default ""
|
|
388
390
|
* @since 1.21.0
|
|
389
391
|
*/
|
|
@@ -486,7 +488,7 @@ declare module '@sveltejs/kit' {
|
|
|
486
488
|
*/
|
|
487
489
|
assets?: '' | `http://${string}` | `https://${string}`;
|
|
488
490
|
/**
|
|
489
|
-
* A root-relative path that must start, but not end with `/` (e.g. `/base-path`), unless it is the empty string. This specifies where your app is served from and allows the app to live on a non-root path. Note that you need to prepend all your root-relative links with the base value or they will point to the root of your domain, not your `base` (this is how the browser works). You can use [`base` from `$app/paths`](/docs/modules#$app-paths-base) for that: `<a href="{base}/your-page">Link</a>`. If you find yourself writing this often, it may make sense to extract this into a reusable component.
|
|
491
|
+
* A root-relative path that must start, but not end with `/` (e.g. `/base-path`), unless it is the empty string. This specifies where your app is served from and allows the app to live on a non-root path. Note that you need to prepend all your root-relative links with the base value or they will point to the root of your domain, not your `base` (this is how the browser works). You can use [`base` from `$app/paths`](https://kit.svelte.dev/docs/modules#$app-paths-base) for that: `<a href="{base}/your-page">Link</a>`. If you find yourself writing this often, it may make sense to extract this into a reusable component.
|
|
490
492
|
* @default ""
|
|
491
493
|
*/
|
|
492
494
|
base?: '' | `/${string}`;
|
|
@@ -628,7 +630,7 @@ declare module '@sveltejs/kit' {
|
|
|
628
630
|
* </script>
|
|
629
631
|
* ```
|
|
630
632
|
*
|
|
631
|
-
* If you set `pollInterval` to a non-zero value, SvelteKit will poll for new versions in the background and set the value of the [`updated`](/docs/modules#$app-stores-updated) store to `true` when it detects one.
|
|
633
|
+
* If you set `pollInterval` to a non-zero value, SvelteKit will poll for new versions in the background and set the value of the [`updated`](https://kit.svelte.dev/docs/modules#$app-stores-updated) store to `true` when it detects one.
|
|
632
634
|
*/
|
|
633
635
|
version?: {
|
|
634
636
|
/**
|
|
@@ -781,7 +783,7 @@ declare module '@sveltejs/kit' {
|
|
|
781
783
|
*/
|
|
782
784
|
parent(): Promise<ParentData>;
|
|
783
785
|
/**
|
|
784
|
-
* This function declares that the `load` function has a _dependency_ on one or more URLs or custom identifiers, which can subsequently be used with [`invalidate()`](/docs/modules#$app-navigation-invalidate) to cause `load` to rerun.
|
|
786
|
+
* This function declares that the `load` function has a _dependency_ on one or more URLs or custom identifiers, which can subsequently be used with [`invalidate()`](https://kit.svelte.dev/docs/modules#$app-navigation-invalidate) to cause `load` to rerun.
|
|
785
787
|
*
|
|
786
788
|
* Most of the time you won't need this, as `fetch` calls `depends` on your behalf — it's only necessary if you're using a custom API client that bypasses `fetch`.
|
|
787
789
|
*
|
|
@@ -1205,7 +1207,7 @@ declare module '@sveltejs/kit' {
|
|
|
1205
1207
|
*/
|
|
1206
1208
|
parent(): Promise<ParentData>;
|
|
1207
1209
|
/**
|
|
1208
|
-
* This function declares that the `load` function has a _dependency_ on one or more URLs or custom identifiers, which can subsequently be used with [`invalidate()`](/docs/modules#$app-navigation-invalidate) to cause `load` to rerun.
|
|
1210
|
+
* This function declares that the `load` function has a _dependency_ on one or more URLs or custom identifiers, which can subsequently be used with [`invalidate()`](https://kit.svelte.dev/docs/modules#$app-navigation-invalidate) to cause `load` to rerun.
|
|
1209
1211
|
*
|
|
1210
1212
|
* Most of the time you won't need this, as `fetch` calls `depends` on your behalf — it's only necessary if you're using a custom API client that bypasses `fetch`.
|
|
1211
1213
|
*
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;aA2BZC,cAAcA;;;;;;aAMdC,cAAcA;;;;;;;;;;;;;;;kBAeTC,aAAaA;;;;;;;;;;;;;;;;;kBAiBbC,OAAOA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAkGPC,MAAMA;;;;;;;;;;;;;;;;;;;;;kBAqBNC,OAAOA;;;;;;;;;;;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