@sveltejs/kit 2.50.2 → 2.52.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 +2 -2
- package/src/core/postbuild/analyse.js +2 -15
- package/src/core/sync/create_manifest_data/index.js +18 -1
- package/src/core/sync/sync.js +17 -0
- package/src/core/sync/write_non_ambient.js +38 -9
- package/src/core/sync/write_tsconfig.js +7 -5
- package/src/exports/public.d.ts +14 -1
- package/src/exports/vite/build/build_server.js +5 -47
- package/src/exports/vite/dev/index.js +4 -21
- package/src/exports/vite/index.js +5 -8
- package/src/exports/vite/static_analysis/index.js +61 -42
- package/src/exports/vite/static_analysis/utils.js +17 -0
- package/src/runtime/app/paths/client.js +38 -0
- package/src/runtime/app/paths/public.d.ts +1 -1
- package/src/runtime/app/paths/server.js +42 -1
- package/src/runtime/client/client.js +36 -38
- package/src/runtime/server/fetch.js +6 -2
- package/src/runtime/server/page/csp.js +54 -22
- package/src/runtime/server/page/index.js +7 -2
- package/src/runtime/server/page/render.js +104 -43
- package/src/runtime/server/page/server_routing.js +4 -20
- package/src/runtime/server/respond.js +7 -13
- package/src/types/internal.d.ts +13 -4
- package/src/types/private.d.ts +1 -0
- package/src/utils/routing.js +25 -0
- package/src/version.js +1 -1
- package/types/index.d.ts +49 -2
- package/types/index.d.ts.map +7 -1
|
@@ -80,17 +80,11 @@ export async function render_response({
|
|
|
80
80
|
*/
|
|
81
81
|
const link_headers = new Set();
|
|
82
82
|
|
|
83
|
-
/**
|
|
84
|
-
* `<link>` tags that are added to prerendered responses
|
|
85
|
-
* (note that stylesheets are always added, prerendered or not)
|
|
86
|
-
* @type {Set<string>}
|
|
87
|
-
*/
|
|
88
|
-
const link_tags = new Set();
|
|
89
|
-
|
|
90
83
|
/** @type {Map<string, string>} */
|
|
91
84
|
// TODO if we add a client entry point one day, we will need to include inline_styles with the entry, otherwise stylesheets will be linked even if they are below inlineStyleThreshold
|
|
92
85
|
const inline_styles = new Map();
|
|
93
86
|
|
|
87
|
+
/** @type {ReturnType<typeof options.root.render>} */
|
|
94
88
|
let rendered;
|
|
95
89
|
|
|
96
90
|
const form_value =
|
|
@@ -110,6 +104,10 @@ export async function render_response({
|
|
|
110
104
|
*/
|
|
111
105
|
let base_expression = s(paths.base);
|
|
112
106
|
|
|
107
|
+
const csp = new Csp(options.csp, {
|
|
108
|
+
prerender: !!state.prerendering
|
|
109
|
+
});
|
|
110
|
+
|
|
113
111
|
// if appropriate, use relative paths for greater portability
|
|
114
112
|
if (paths.relative) {
|
|
115
113
|
if (!state.prerendering?.fallback) {
|
|
@@ -177,7 +175,8 @@ export async function render_response({
|
|
|
177
175
|
page: props.page
|
|
178
176
|
}
|
|
179
177
|
]
|
|
180
|
-
])
|
|
178
|
+
]),
|
|
179
|
+
csp: csp.script_needs_nonce ? { nonce: csp.nonce } : { hash: csp.script_needs_hash }
|
|
181
180
|
};
|
|
182
181
|
|
|
183
182
|
const fetch = globalThis.fetch;
|
|
@@ -227,9 +226,15 @@ export async function render_response({
|
|
|
227
226
|
paths.reset();
|
|
228
227
|
}
|
|
229
228
|
|
|
230
|
-
const { head, html, css } =
|
|
229
|
+
const { head, html, css, hashes } = /** @type {ReturnType<typeof options.root.render>} */ (
|
|
230
|
+
options.async ? await rendered : rendered
|
|
231
|
+
);
|
|
232
|
+
|
|
233
|
+
if (hashes) {
|
|
234
|
+
csp.add_script_hashes(hashes.script);
|
|
235
|
+
}
|
|
231
236
|
|
|
232
|
-
return { head, html, css };
|
|
237
|
+
return { head, html, css, hashes };
|
|
233
238
|
});
|
|
234
239
|
} finally {
|
|
235
240
|
if (DEV) {
|
|
@@ -256,16 +261,12 @@ export async function render_response({
|
|
|
256
261
|
}
|
|
257
262
|
}
|
|
258
263
|
} else {
|
|
259
|
-
rendered = { head: '', html: '', css: { code: '', map: null } };
|
|
264
|
+
rendered = { head: '', html: '', css: { code: '', map: null }, hashes: { script: [] } };
|
|
260
265
|
}
|
|
261
266
|
|
|
262
|
-
|
|
267
|
+
const head = new Head(rendered.head, !!state.prerendering);
|
|
263
268
|
let body = rendered.html;
|
|
264
269
|
|
|
265
|
-
const csp = new Csp(options.csp, {
|
|
266
|
-
prerender: !!state.prerendering
|
|
267
|
-
});
|
|
268
|
-
|
|
269
270
|
/** @param {string} path */
|
|
270
271
|
const prefixed = (path) => {
|
|
271
272
|
if (path.startsWith('/')) {
|
|
@@ -283,12 +284,10 @@ export async function render_response({
|
|
|
283
284
|
: Array.from(inline_styles.values()).join('\n');
|
|
284
285
|
|
|
285
286
|
if (style) {
|
|
286
|
-
const attributes = DEV ? ['
|
|
287
|
-
if (csp.style_needs_nonce) attributes.push(`
|
|
288
|
-
|
|
287
|
+
const attributes = DEV ? ['data-sveltekit'] : [];
|
|
288
|
+
if (csp.style_needs_nonce) attributes.push(`nonce="${csp.nonce}"`);
|
|
289
289
|
csp.add_style(style);
|
|
290
|
-
|
|
291
|
-
head += `\n\t<style${attributes.join('')}>${style}</style>`;
|
|
290
|
+
head.add_style(style, attributes);
|
|
292
291
|
}
|
|
293
292
|
|
|
294
293
|
for (const dep of stylesheets) {
|
|
@@ -306,7 +305,7 @@ export async function render_response({
|
|
|
306
305
|
}
|
|
307
306
|
}
|
|
308
307
|
|
|
309
|
-
head
|
|
308
|
+
head.add_stylesheet(path, attributes);
|
|
310
309
|
}
|
|
311
310
|
|
|
312
311
|
for (const dep of fonts) {
|
|
@@ -315,7 +314,7 @@ export async function render_response({
|
|
|
315
314
|
if (resolve_opts.preload({ type: 'font', path })) {
|
|
316
315
|
const ext = dep.slice(dep.lastIndexOf('.') + 1);
|
|
317
316
|
|
|
318
|
-
|
|
317
|
+
head.add_link_tag(path, ['rel="preload"', 'as="font"', `type="font/${ext}"`, 'crossorigin']);
|
|
319
318
|
|
|
320
319
|
link_headers.add(
|
|
321
320
|
`<${encodeURI(path)}>; rel="preload"; as="font"; type="font/${ext}"; crossorigin; nopush`
|
|
@@ -351,19 +350,13 @@ export async function render_response({
|
|
|
351
350
|
link_headers.add(`<${encodeURI(path)}>; rel="modulepreload"; nopush`);
|
|
352
351
|
|
|
353
352
|
if (options.preload_strategy !== 'modulepreload') {
|
|
354
|
-
head
|
|
353
|
+
head.add_script_preload(path);
|
|
355
354
|
} else {
|
|
356
|
-
|
|
355
|
+
head.add_link_tag(path, ['rel="modulepreload"']);
|
|
357
356
|
}
|
|
358
357
|
}
|
|
359
358
|
}
|
|
360
359
|
|
|
361
|
-
if (state.prerendering && link_tags.size > 0) {
|
|
362
|
-
head += Array.from(link_tags)
|
|
363
|
-
.map((tag) => `\n\t\t${tag}`)
|
|
364
|
-
.join('');
|
|
365
|
-
}
|
|
366
|
-
|
|
367
360
|
// prerender a `/path/to/page/__route.js` module
|
|
368
361
|
if (manifest._.client.routes && state.prerendering && !state.prerendering.fallback) {
|
|
369
362
|
const pathname = add_resolution_suffix(event.url.pathname);
|
|
@@ -581,19 +574,15 @@ export async function render_response({
|
|
|
581
574
|
|
|
582
575
|
if (state.prerendering) {
|
|
583
576
|
// TODO read headers set with setHeaders and convert into http-equiv where possible
|
|
584
|
-
const http_equiv = [];
|
|
585
|
-
|
|
586
577
|
const csp_headers = csp.csp_provider.get_meta();
|
|
587
578
|
if (csp_headers) {
|
|
588
|
-
|
|
579
|
+
head.add_http_equiv(csp_headers);
|
|
589
580
|
}
|
|
590
581
|
|
|
591
582
|
if (state.prerendering.cache) {
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
if (http_equiv.length > 0) {
|
|
596
|
-
head = http_equiv.join('\n') + head;
|
|
583
|
+
head.add_http_equiv(
|
|
584
|
+
`<meta http-equiv="cache-control" content="${state.prerendering.cache}">`
|
|
585
|
+
);
|
|
597
586
|
}
|
|
598
587
|
} else {
|
|
599
588
|
const csp_header = csp.csp_provider.get_header();
|
|
@@ -610,11 +599,8 @@ export async function render_response({
|
|
|
610
599
|
}
|
|
611
600
|
}
|
|
612
601
|
|
|
613
|
-
// add the content after the script/css links so the link elements are parsed first
|
|
614
|
-
head += rendered.head;
|
|
615
|
-
|
|
616
602
|
const html = options.templates.app({
|
|
617
|
-
head,
|
|
603
|
+
head: head.build(),
|
|
618
604
|
body,
|
|
619
605
|
assets,
|
|
620
606
|
nonce: /** @type {string} */ (csp.nonce),
|
|
@@ -672,3 +658,78 @@ export async function render_response({
|
|
|
672
658
|
}
|
|
673
659
|
);
|
|
674
660
|
}
|
|
661
|
+
|
|
662
|
+
class Head {
|
|
663
|
+
#rendered;
|
|
664
|
+
#prerendering;
|
|
665
|
+
/** @type {string[]} */
|
|
666
|
+
#http_equiv = [];
|
|
667
|
+
/** @type {string[]} */
|
|
668
|
+
#link_tags = [];
|
|
669
|
+
/** @type {string[]} */
|
|
670
|
+
#script_preloads = [];
|
|
671
|
+
/** @type {string[]} */
|
|
672
|
+
#style_tags = [];
|
|
673
|
+
/** @type {string[]} */
|
|
674
|
+
#stylesheet_links = [];
|
|
675
|
+
|
|
676
|
+
/**
|
|
677
|
+
* @param {string} rendered
|
|
678
|
+
* @param {boolean} prerendering
|
|
679
|
+
*/
|
|
680
|
+
constructor(rendered, prerendering) {
|
|
681
|
+
this.#rendered = rendered;
|
|
682
|
+
this.#prerendering = prerendering;
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
build() {
|
|
686
|
+
return [
|
|
687
|
+
...this.#http_equiv,
|
|
688
|
+
...this.#link_tags,
|
|
689
|
+
...this.#script_preloads,
|
|
690
|
+
this.#rendered,
|
|
691
|
+
...this.#style_tags,
|
|
692
|
+
...this.#stylesheet_links
|
|
693
|
+
].join('\n\t\t');
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
/**
|
|
697
|
+
* @param {string} style
|
|
698
|
+
* @param {string[]} attributes
|
|
699
|
+
*/
|
|
700
|
+
add_style(style, attributes) {
|
|
701
|
+
this.#style_tags.push(
|
|
702
|
+
`<style${attributes.length ? ' ' + attributes.join(' ') : ''}>${style}</style>`
|
|
703
|
+
);
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
/**
|
|
707
|
+
* @param {string} href
|
|
708
|
+
* @param {string[]} attributes
|
|
709
|
+
*/
|
|
710
|
+
add_stylesheet(href, attributes) {
|
|
711
|
+
this.#stylesheet_links.push(`<link href="${href}" ${attributes.join(' ')}>`);
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
/** @param {string} href */
|
|
715
|
+
add_script_preload(href) {
|
|
716
|
+
this.#script_preloads.push(
|
|
717
|
+
`<link rel="preload" as="script" crossorigin="anonymous" href="${href}">`
|
|
718
|
+
);
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
/**
|
|
722
|
+
* @param {string} href
|
|
723
|
+
* @param {string[]} attributes
|
|
724
|
+
*/
|
|
725
|
+
add_link_tag(href, attributes) {
|
|
726
|
+
if (!this.#prerendering) return;
|
|
727
|
+
this.#link_tags.push(`<link href="${href}" ${attributes.join(' ')}>`);
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
/** @param {string} tag */
|
|
731
|
+
add_http_equiv(tag) {
|
|
732
|
+
if (!this.#prerendering) return;
|
|
733
|
+
this.#http_equiv.push(tag);
|
|
734
|
+
}
|
|
735
|
+
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { base, assets, relative } from '$app/paths/internal/server';
|
|
2
2
|
import { text } from '@sveltejs/kit';
|
|
3
3
|
import { s } from '../../../utils/misc.js';
|
|
4
|
-
import {
|
|
5
|
-
import { decode_params } from '../../../utils/url.js';
|
|
4
|
+
import { find_route } from '../../../utils/routing.js';
|
|
6
5
|
import { get_relative_path } from '../../utils.js';
|
|
7
6
|
|
|
8
7
|
/**
|
|
@@ -69,26 +68,11 @@ export async function resolve_route(resolved_path, url, manifest) {
|
|
|
69
68
|
return text('Server-side route resolution disabled', { status: 400 });
|
|
70
69
|
}
|
|
71
70
|
|
|
72
|
-
/** @type {import('types').SSRClientRoute | null} */
|
|
73
|
-
let route = null;
|
|
74
|
-
/** @type {Record<string, string>} */
|
|
75
|
-
let params = {};
|
|
76
|
-
|
|
77
71
|
const matchers = await manifest._.matchers();
|
|
72
|
+
const result = find_route(resolved_path, manifest._.client.routes, matchers);
|
|
78
73
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
if (!match) continue;
|
|
82
|
-
|
|
83
|
-
const matched = exec(match, candidate.params, matchers);
|
|
84
|
-
if (matched) {
|
|
85
|
-
route = candidate;
|
|
86
|
-
params = decode_params(matched);
|
|
87
|
-
break;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
return create_server_routing_response(route, params, url, manifest).response;
|
|
74
|
+
return create_server_routing_response(result?.route ?? null, result?.params ?? {}, url, manifest)
|
|
75
|
+
.response;
|
|
92
76
|
}
|
|
93
77
|
|
|
94
78
|
/**
|
|
@@ -15,8 +15,8 @@ import {
|
|
|
15
15
|
method_not_allowed,
|
|
16
16
|
redirect_response
|
|
17
17
|
} from './utils.js';
|
|
18
|
-
import { decode_pathname,
|
|
19
|
-
import {
|
|
18
|
+
import { decode_pathname, disable_search, normalize_path } from '../../utils/url.js';
|
|
19
|
+
import { find_route } from '../../utils/routing.js';
|
|
20
20
|
import { redirect_json_response, render_data } from './data/index.js';
|
|
21
21
|
import { add_cookies_to_headers, get_cookies } from './cookie.js';
|
|
22
22
|
import { create_fetch } from './fetch.js';
|
|
@@ -309,18 +309,12 @@ export async function internal_respond(request, options, manifest, state) {
|
|
|
309
309
|
if (!state.prerendering?.fallback) {
|
|
310
310
|
// TODO this could theoretically break — should probably be inside a try-catch
|
|
311
311
|
const matchers = await manifest._.matchers();
|
|
312
|
+
const result = find_route(resolved_path, manifest._.routes, matchers);
|
|
312
313
|
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
const matched = exec(match, candidate.params, matchers);
|
|
318
|
-
if (matched) {
|
|
319
|
-
route = candidate;
|
|
320
|
-
event.route = { id: route.id };
|
|
321
|
-
event.params = decode_params(matched);
|
|
322
|
-
break;
|
|
323
|
-
}
|
|
314
|
+
if (result) {
|
|
315
|
+
route = result.route;
|
|
316
|
+
event.route = { id: route.id };
|
|
317
|
+
event.params = result.params;
|
|
324
318
|
}
|
|
325
319
|
}
|
|
326
320
|
|
package/src/types/internal.d.ts
CHANGED
|
@@ -32,6 +32,7 @@ import {
|
|
|
32
32
|
TrailingSlash
|
|
33
33
|
} from './private.js';
|
|
34
34
|
import { Span } from '@opentelemetry/api';
|
|
35
|
+
import type { PageOptions } from '../exports/vite/static_analysis/index.js';
|
|
35
36
|
|
|
36
37
|
export interface ServerModule {
|
|
37
38
|
Server: typeof InternalServer;
|
|
@@ -176,7 +177,7 @@ export class InternalServer extends Server {
|
|
|
176
177
|
request: Request,
|
|
177
178
|
options: RequestOptions & {
|
|
178
179
|
prerendering?: PrerenderOptions;
|
|
179
|
-
read: (file: string) =>
|
|
180
|
+
read: (file: string) => NonSharedBuffer;
|
|
180
181
|
/** A hook called before `handle` during dev, so that `AsyncLocalStorage` can be populated. */
|
|
181
182
|
before_handle?: (event: RequestEvent, config: any, prerender: PrerenderOption) => void;
|
|
182
183
|
emulator?: Emulator;
|
|
@@ -214,6 +215,8 @@ export interface PageNode {
|
|
|
214
215
|
parent?: PageNode;
|
|
215
216
|
/** Filled with the pages that reference this layout (if this is a layout). */
|
|
216
217
|
child_pages?: PageNode[];
|
|
218
|
+
/** The final page options for a node if it was statically analysable */
|
|
219
|
+
page_options?: PageOptions | null;
|
|
217
220
|
}
|
|
218
221
|
|
|
219
222
|
export interface PrerenderDependency {
|
|
@@ -278,6 +281,8 @@ export interface RouteData {
|
|
|
278
281
|
|
|
279
282
|
endpoint: {
|
|
280
283
|
file: string;
|
|
284
|
+
/** The final page options for the endpoint if it was statically analysable */
|
|
285
|
+
page_options: PageOptions | null;
|
|
281
286
|
} | null;
|
|
282
287
|
}
|
|
283
288
|
|
|
@@ -381,7 +386,7 @@ export interface SSRComponent {
|
|
|
381
386
|
default: {
|
|
382
387
|
render(
|
|
383
388
|
props: Record<string, any>,
|
|
384
|
-
opts: { context: Map<any, any
|
|
389
|
+
opts: { context: Map<any, any>; csp?: { nonce?: string; hash?: boolean } }
|
|
385
390
|
): {
|
|
386
391
|
html: string;
|
|
387
392
|
head: string;
|
|
@@ -389,6 +394,10 @@ export interface SSRComponent {
|
|
|
389
394
|
code: string;
|
|
390
395
|
map: any; // TODO
|
|
391
396
|
};
|
|
397
|
+
/** Until we require all Svelte versions that support hashes, this might not be defined */
|
|
398
|
+
hashes?: {
|
|
399
|
+
script: Array<`sha256-${string}`>;
|
|
400
|
+
};
|
|
392
401
|
};
|
|
393
402
|
};
|
|
394
403
|
}
|
|
@@ -525,9 +534,9 @@ export interface SSRState {
|
|
|
525
534
|
* prerender option is inherited by the endpoint, unless overridden.
|
|
526
535
|
*/
|
|
527
536
|
prerender_default?: PrerenderOption;
|
|
528
|
-
read?: (file: string) =>
|
|
537
|
+
read?: (file: string) => NonSharedBuffer;
|
|
529
538
|
/**
|
|
530
|
-
* Used to
|
|
539
|
+
* Used to set up `__SVELTEKIT_TRACK__` which checks if a used feature is supported.
|
|
531
540
|
* E.g. if `read` from `$app/server` is used, it checks whether the route's config is compatible.
|
|
532
541
|
*/
|
|
533
542
|
before_handle?: (event: RequestEvent, config: any, prerender: PrerenderOption) => void;
|
package/src/types/private.d.ts
CHANGED
package/src/utils/routing.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { BROWSER } from 'esm-env';
|
|
2
|
+
import { decode_params } from './url.js';
|
|
2
3
|
|
|
3
4
|
const param_pattern = /^(\[)?(\.\.\.)?(\w+)(?:=(\w+))?(\])?$/;
|
|
4
5
|
|
|
@@ -280,3 +281,27 @@ export function resolve_route(id, params) {
|
|
|
280
281
|
export function has_server_load(node) {
|
|
281
282
|
return node.server?.load !== undefined || node.server?.trailingSlash !== undefined;
|
|
282
283
|
}
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Find the first route that matches the given path
|
|
287
|
+
* @template {{pattern: RegExp, params: import('types').RouteParam[]}} Route
|
|
288
|
+
* @param {string} path - The decoded pathname to match
|
|
289
|
+
* @param {Route[]} routes
|
|
290
|
+
* @param {Record<string, import('@sveltejs/kit').ParamMatcher>} matchers
|
|
291
|
+
* @returns {{ route: Route, params: Record<string, string> } | null}
|
|
292
|
+
*/
|
|
293
|
+
export function find_route(path, routes, matchers) {
|
|
294
|
+
for (const route of routes) {
|
|
295
|
+
const match = route.pattern.exec(path);
|
|
296
|
+
if (!match) continue;
|
|
297
|
+
|
|
298
|
+
const matched = exec(match, route.params, matchers);
|
|
299
|
+
if (matched) {
|
|
300
|
+
return {
|
|
301
|
+
route,
|
|
302
|
+
params: decode_params(matched)
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
return null;
|
|
307
|
+
}
|
package/src/version.js
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -1175,6 +1175,19 @@ declare module '@sveltejs/kit' {
|
|
|
1175
1175
|
* The URL that is navigated to
|
|
1176
1176
|
*/
|
|
1177
1177
|
url: URL;
|
|
1178
|
+
/**
|
|
1179
|
+
* The scroll position associated with this navigation.
|
|
1180
|
+
*
|
|
1181
|
+
* For the `from` target, this is the scroll position at the moment of navigation.
|
|
1182
|
+
*
|
|
1183
|
+
* For the `to` target, this represents the scroll position that will be or was restored:
|
|
1184
|
+
* - In `beforeNavigate` and `onNavigate`, this is only available for `popstate` navigations (back/forward button)
|
|
1185
|
+
* and will be `null` for other navigation types, since the final scroll position isn't known
|
|
1186
|
+
* ahead of time.
|
|
1187
|
+
* - In `afterNavigate`, this is always the scroll position that was applied after the navigation
|
|
1188
|
+
* completed.
|
|
1189
|
+
*/
|
|
1190
|
+
scroll: { x: number; y: number } | null;
|
|
1178
1191
|
}
|
|
1179
1192
|
|
|
1180
1193
|
/**
|
|
@@ -1224,7 +1237,7 @@ declare module '@sveltejs/kit' {
|
|
|
1224
1237
|
delta?: undefined;
|
|
1225
1238
|
|
|
1226
1239
|
/**
|
|
1227
|
-
* Dispatched `Event` object when navigation
|
|
1240
|
+
* Dispatched `Event` object when navigation occurred by `popstate` or `link`.
|
|
1228
1241
|
*/
|
|
1229
1242
|
event?: undefined;
|
|
1230
1243
|
}
|
|
@@ -2382,6 +2395,7 @@ declare module '@sveltejs/kit' {
|
|
|
2382
2395
|
rest: boolean;
|
|
2383
2396
|
}
|
|
2384
2397
|
|
|
2398
|
+
/** @default 'never' */
|
|
2385
2399
|
type TrailingSlash = 'never' | 'always' | 'ignore';
|
|
2386
2400
|
|
|
2387
2401
|
type IsAny<T> = 0 extends 1 & T ? true : false;
|
|
@@ -2459,6 +2473,8 @@ declare module '@sveltejs/kit' {
|
|
|
2459
2473
|
parent?: PageNode;
|
|
2460
2474
|
/** Filled with the pages that reference this layout (if this is a layout). */
|
|
2461
2475
|
child_pages?: PageNode[];
|
|
2476
|
+
/** The final page options for a node if it was statically analysable */
|
|
2477
|
+
page_options?: PageOptions | null;
|
|
2462
2478
|
}
|
|
2463
2479
|
|
|
2464
2480
|
type RecursiveRequired<T> = {
|
|
@@ -2503,6 +2519,8 @@ declare module '@sveltejs/kit' {
|
|
|
2503
2519
|
|
|
2504
2520
|
endpoint: {
|
|
2505
2521
|
file: string;
|
|
2522
|
+
/** The final page options for the endpoint if it was statically analysable */
|
|
2523
|
+
page_options: PageOptions | null;
|
|
2506
2524
|
} | null;
|
|
2507
2525
|
}
|
|
2508
2526
|
|
|
@@ -2510,7 +2528,7 @@ declare module '@sveltejs/kit' {
|
|
|
2510
2528
|
default: {
|
|
2511
2529
|
render(
|
|
2512
2530
|
props: Record<string, any>,
|
|
2513
|
-
opts: { context: Map<any, any
|
|
2531
|
+
opts: { context: Map<any, any>; csp?: { nonce?: string; hash?: boolean } }
|
|
2514
2532
|
): {
|
|
2515
2533
|
html: string;
|
|
2516
2534
|
head: string;
|
|
@@ -2518,6 +2536,10 @@ declare module '@sveltejs/kit' {
|
|
|
2518
2536
|
code: string;
|
|
2519
2537
|
map: any; // TODO
|
|
2520
2538
|
};
|
|
2539
|
+
/** Until we require all Svelte versions that support hashes, this might not be defined */
|
|
2540
|
+
hashes?: {
|
|
2541
|
+
script: Array<`sha256-${string}`>;
|
|
2542
|
+
};
|
|
2521
2543
|
};
|
|
2522
2544
|
};
|
|
2523
2545
|
}
|
|
@@ -2748,6 +2770,9 @@ declare module '@sveltejs/kit' {
|
|
|
2748
2770
|
};
|
|
2749
2771
|
export type LessThan<TNumber extends number, TArray extends any[] = []> = TNumber extends TArray["length"] ? TArray[number] : LessThan<TNumber, [...TArray, TArray["length"]]>;
|
|
2750
2772
|
export type NumericRange<TStart extends number, TEnd extends number> = Exclude<TEnd | LessThan<TEnd>, LessThan<TStart>>;
|
|
2773
|
+
type ValidPageOption = (typeof valid_page_options_array)[number];
|
|
2774
|
+
type PageOptions = Partial<Record<ValidPageOption, any>>;
|
|
2775
|
+
const valid_page_options_array: readonly ["ssr", "prerender", "csr", "trailingSlash", "config", "entries", "load"];
|
|
2751
2776
|
export const VERSION: string;
|
|
2752
2777
|
class HttpError_1 {
|
|
2753
2778
|
|
|
@@ -3155,6 +3180,28 @@ declare module '$app/paths' {
|
|
|
3155
3180
|
*
|
|
3156
3181
|
* */
|
|
3157
3182
|
export function resolve<T extends RouteId | Pathname>(...args: ResolveArgs<T>): ResolvedPathname;
|
|
3183
|
+
/**
|
|
3184
|
+
* Match a path or URL to a route ID and extracts any parameters.
|
|
3185
|
+
*
|
|
3186
|
+
* @example
|
|
3187
|
+
* ```js
|
|
3188
|
+
* import { match } from '$app/paths';
|
|
3189
|
+
*
|
|
3190
|
+
* const route = await match('/blog/hello-world');
|
|
3191
|
+
*
|
|
3192
|
+
* if (route?.id === '/blog/[slug]') {
|
|
3193
|
+
* const slug = route.params.slug;
|
|
3194
|
+
* const response = await fetch(`/api/posts/${slug}`);
|
|
3195
|
+
* const post = await response.json();
|
|
3196
|
+
* }
|
|
3197
|
+
* ```
|
|
3198
|
+
* @since 2.52.0
|
|
3199
|
+
*
|
|
3200
|
+
* */
|
|
3201
|
+
export function match(url: Pathname | URL | (string & {})): Promise<{
|
|
3202
|
+
id: RouteId;
|
|
3203
|
+
params: Record<string, string>;
|
|
3204
|
+
} | null>;
|
|
3158
3205
|
|
|
3159
3206
|
export {};
|
|
3160
3207
|
}
|
package/types/index.d.ts.map
CHANGED
|
@@ -133,6 +133,9 @@
|
|
|
133
133
|
"invalid",
|
|
134
134
|
"isValidationError",
|
|
135
135
|
"normalizeUrl",
|
|
136
|
+
"ValidPageOption",
|
|
137
|
+
"PageOptions",
|
|
138
|
+
"valid_page_options_array",
|
|
136
139
|
"VERSION",
|
|
137
140
|
"sequence",
|
|
138
141
|
"getRequest",
|
|
@@ -165,6 +168,7 @@
|
|
|
165
168
|
"ResolveArgs",
|
|
166
169
|
"asset",
|
|
167
170
|
"resolve",
|
|
171
|
+
"match",
|
|
168
172
|
"read",
|
|
169
173
|
"getRequestEvent",
|
|
170
174
|
"RemotePrerenderInputsGenerator",
|
|
@@ -179,6 +183,7 @@
|
|
|
179
183
|
"../src/types/private.d.ts",
|
|
180
184
|
"../src/types/internal.d.ts",
|
|
181
185
|
"../src/exports/index.js",
|
|
186
|
+
"../src/exports/vite/static_analysis/index.js",
|
|
182
187
|
"../src/version.js",
|
|
183
188
|
"../src/exports/hooks/sequence.js",
|
|
184
189
|
"../src/exports/node/index.js",
|
|
@@ -215,8 +220,9 @@
|
|
|
215
220
|
null,
|
|
216
221
|
null,
|
|
217
222
|
null,
|
|
223
|
+
null,
|
|
218
224
|
null
|
|
219
225
|
],
|
|
220
|
-
"mappings": ";;;;;;;;MAgCKA,IAAIA;;;;;kBAKQC,OAAOA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAiCZC,cAAcA;;;;;;aAMdC,cAAcA;;;;;;;;MAQrBC,aAAaA;;;;;OAKJC,YAAYA;;kBAETC,aAAaA;;;;;;MAMzBC,qBAAqBA;;;;;;;;;;;kBAWTC,OAAOA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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