@sveltejs/kit 2.53.3 → 2.54.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/config/options.js +13 -12
- package/src/core/sync/sync.js +1 -1
- package/src/core/sync/write_root.js +41 -6
- package/src/core/sync/write_server.js +1 -0
- package/src/exports/index.js +1 -1
- package/src/exports/public.d.ts +50 -59
- package/src/exports/vite/build/build_server.js +2 -2
- package/src/exports/vite/build/build_service_worker.js +1 -0
- package/src/exports/vite/index.js +11 -5
- package/src/runtime/app/paths/client.js +2 -2
- package/src/runtime/app/paths/public.d.ts +2 -2
- package/src/runtime/app/paths/server.js +1 -1
- package/src/runtime/app/paths/types.d.ts +22 -6
- package/src/runtime/client/client.js +100 -13
- package/src/runtime/client/remote-functions/form.svelte.js +8 -0
- package/src/runtime/client/state.svelte.js +4 -2
- package/src/runtime/client/types.d.ts +2 -0
- package/src/runtime/server/page/index.js +57 -8
- package/src/runtime/server/page/render.js +46 -5
- package/src/runtime/server/page/respond_with_error.js +1 -0
- package/src/runtime/server/page/serialize_data.js +1 -1
- package/src/types/ambient.d.ts +13 -0
- package/src/types/global-private.d.ts +1 -0
- package/src/types/internal.d.ts +1 -0
- package/src/version.js +1 -1
- package/types/index.d.ts +83 -68
- package/types/index.d.ts.map +4 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sveltejs/kit",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.54.0",
|
|
4
4
|
"description": "SvelteKit is the fastest way to build Svelte apps",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"framework",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"@types/cookie": "^0.6.0",
|
|
24
24
|
"acorn": "^8.14.1",
|
|
25
25
|
"cookie": "^0.6.0",
|
|
26
|
-
"devalue": "^5.6.
|
|
26
|
+
"devalue": "^5.6.4",
|
|
27
27
|
"esm-env": "^1.2.2",
|
|
28
28
|
"kleur": "^4.1.5",
|
|
29
29
|
"magic-string": "^0.30.5",
|
|
@@ -133,23 +133,24 @@ const options = object(
|
|
|
133
133
|
server: boolean(false)
|
|
134
134
|
}),
|
|
135
135
|
remoteFunctions: boolean(false),
|
|
136
|
-
forkPreloads: boolean(false)
|
|
136
|
+
forkPreloads: boolean(false),
|
|
137
|
+
handleRenderingErrors: boolean(false)
|
|
137
138
|
}),
|
|
138
139
|
|
|
139
140
|
files: object({
|
|
140
|
-
src:
|
|
141
|
-
assets:
|
|
141
|
+
src: string('src'),
|
|
142
|
+
assets: string('static'),
|
|
142
143
|
hooks: object({
|
|
143
|
-
client:
|
|
144
|
-
server:
|
|
145
|
-
universal:
|
|
144
|
+
client: string(null),
|
|
145
|
+
server: string(null),
|
|
146
|
+
universal: string(null)
|
|
146
147
|
}),
|
|
147
|
-
lib:
|
|
148
|
-
params:
|
|
149
|
-
routes:
|
|
150
|
-
serviceWorker:
|
|
151
|
-
appTemplate:
|
|
152
|
-
errorTemplate:
|
|
148
|
+
lib: string(null),
|
|
149
|
+
params: string(null),
|
|
150
|
+
routes: string(null),
|
|
151
|
+
serviceWorker: string(null),
|
|
152
|
+
appTemplate: string(null),
|
|
153
|
+
errorTemplate: string(null)
|
|
153
154
|
}),
|
|
154
155
|
|
|
155
156
|
inlineStyleThreshold: number(0),
|
package/src/core/sync/sync.js
CHANGED
|
@@ -33,7 +33,7 @@ export function create(config) {
|
|
|
33
33
|
|
|
34
34
|
write_client_manifest(config.kit, manifest_data, `${output}/client`);
|
|
35
35
|
write_server(config, output);
|
|
36
|
-
write_root(manifest_data, output);
|
|
36
|
+
write_root(manifest_data, config, output);
|
|
37
37
|
write_all_types(config, manifest_data);
|
|
38
38
|
write_non_ambient(config.kit, manifest_data);
|
|
39
39
|
|
|
@@ -2,11 +2,14 @@ import { dedent, isSvelte5Plus, write_if_changed } from './utils.js';
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @param {import('types').ManifestData} manifest_data
|
|
5
|
+
* @param {import('types').ValidatedConfig} config
|
|
5
6
|
* @param {string} output
|
|
6
7
|
*/
|
|
7
|
-
export function write_root(manifest_data, output) {
|
|
8
|
+
export function write_root(manifest_data, config, output) {
|
|
8
9
|
// TODO remove default layout altogether
|
|
9
10
|
|
|
11
|
+
const use_boundaries = config.kit.experimental.handleRenderingErrors && isSvelte5Plus();
|
|
12
|
+
|
|
10
13
|
const max_depth = Math.max(
|
|
11
14
|
...manifest_data.routes.map((route) =>
|
|
12
15
|
route.page ? route.page.layouts.filter(Boolean).length + 1 : 0
|
|
@@ -20,8 +23,38 @@ export function write_root(manifest_data, output) {
|
|
|
20
23
|
}
|
|
21
24
|
|
|
22
25
|
let l = max_depth;
|
|
26
|
+
/** @type {string} */
|
|
27
|
+
let pyramid;
|
|
23
28
|
|
|
24
|
-
|
|
29
|
+
if (isSvelte5Plus() && use_boundaries) {
|
|
30
|
+
// with the @const we force the data[depth] access to be derived, which is important to not fire updates needlessly
|
|
31
|
+
// TODO in Svelte 5 we should rethink the client.js side, we can likely make data a $state and only update indexes that changed there, simplifying this a lot
|
|
32
|
+
pyramid = dedent`
|
|
33
|
+
{#snippet pyramid(depth)}
|
|
34
|
+
{@const Pyramid = constructors[depth]}
|
|
35
|
+
{#snippet failed(error)}
|
|
36
|
+
{@const ErrorPage = errors[depth]}
|
|
37
|
+
<ErrorPage {error} />
|
|
38
|
+
{/snippet}
|
|
39
|
+
<svelte:boundary failed={errors[depth] ? failed : undefined}>
|
|
40
|
+
{#if constructors[depth + 1]}
|
|
41
|
+
{@const d = data[depth]}
|
|
42
|
+
<!-- svelte-ignore binding_property_non_reactive -->
|
|
43
|
+
<Pyramid bind:this={components[depth]} data={d} {form} params={page.params}>
|
|
44
|
+
{@render pyramid(depth + 1)}
|
|
45
|
+
</Pyramid>
|
|
46
|
+
{:else}
|
|
47
|
+
{@const d = data[depth]}
|
|
48
|
+
<!-- svelte-ignore binding_property_non_reactive -->
|
|
49
|
+
<Pyramid bind:this={components[depth]} data={d} {form} params={page.params} {error} />
|
|
50
|
+
{/if}
|
|
51
|
+
</svelte:boundary>
|
|
52
|
+
{/snippet}
|
|
53
|
+
|
|
54
|
+
{@render pyramid(0)}
|
|
55
|
+
`;
|
|
56
|
+
} else {
|
|
57
|
+
pyramid = dedent`
|
|
25
58
|
${
|
|
26
59
|
isSvelte5Plus()
|
|
27
60
|
? `<!-- svelte-ignore binding_property_non_reactive -->
|
|
@@ -29,8 +62,8 @@ export function write_root(manifest_data, output) {
|
|
|
29
62
|
: `<svelte:component this={constructors[${l}]} bind:this={components[${l}]} data={data_${l}} {form} params={page.params} />`
|
|
30
63
|
}`;
|
|
31
64
|
|
|
32
|
-
|
|
33
|
-
|
|
65
|
+
while (l--) {
|
|
66
|
+
pyramid = dedent`
|
|
34
67
|
{#if constructors[${l + 1}]}
|
|
35
68
|
${
|
|
36
69
|
isSvelte5Plus()
|
|
@@ -57,6 +90,7 @@ export function write_root(manifest_data, output) {
|
|
|
57
90
|
|
|
58
91
|
{/if}
|
|
59
92
|
`;
|
|
93
|
+
}
|
|
60
94
|
}
|
|
61
95
|
|
|
62
96
|
write_if_changed(
|
|
@@ -72,9 +106,10 @@ export function write_root(manifest_data, output) {
|
|
|
72
106
|
${
|
|
73
107
|
isSvelte5Plus()
|
|
74
108
|
? dedent`
|
|
75
|
-
let { stores, page, constructors, components = [], form, ${levels
|
|
109
|
+
let { stores, page, constructors, components = [], form, ${use_boundaries ? 'errors = [], error, ' : ''}${levels
|
|
76
110
|
.map((l) => `data_${l} = null`)
|
|
77
111
|
.join(', ')} } = $props();
|
|
112
|
+
${use_boundaries ? `let data = $derived({${levels.map((l) => `'${l}': data_${l}`).join(', ')}})` : ''}
|
|
78
113
|
`
|
|
79
114
|
: dedent`
|
|
80
115
|
export let stores;
|
|
@@ -108,7 +143,7 @@ export function write_root(manifest_data, output) {
|
|
|
108
143
|
isSvelte5Plus()
|
|
109
144
|
? dedent`
|
|
110
145
|
$effect(() => {
|
|
111
|
-
stores;page;constructors;components;form;${levels.map((l) => `data_${l}`).join(';')};
|
|
146
|
+
stores;page;constructors;components;form;${use_boundaries ? 'errors;error;' : ''}${levels.map((l) => `data_${l}`).join(';')};
|
|
112
147
|
stores.page.notify();
|
|
113
148
|
});
|
|
114
149
|
`
|
|
@@ -50,6 +50,7 @@ export const options = {
|
|
|
50
50
|
root,
|
|
51
51
|
service_worker: ${has_service_worker},
|
|
52
52
|
service_worker_options: ${config.kit.serviceWorker.register ? s(config.kit.serviceWorker.options) : 'null'},
|
|
53
|
+
server_error_boundaries: ${s(!!config.kit.experimental.handleRenderingErrors)},
|
|
53
54
|
templates: {
|
|
54
55
|
app: ({ head, body, assets, nonce, env }) => ${s(template)
|
|
55
56
|
.replace('%sveltekit.head%', '" + head + "')
|
package/src/exports/index.js
CHANGED
|
@@ -276,7 +276,7 @@ export function isValidationError(e) {
|
|
|
276
276
|
* @since 2.18.0
|
|
277
277
|
*/
|
|
278
278
|
export function normalizeUrl(url) {
|
|
279
|
-
url = new URL(url, '
|
|
279
|
+
url = new URL(url, 'a://a');
|
|
280
280
|
|
|
281
281
|
const is_route_resolution = has_resolution_suffix(url.pathname);
|
|
282
282
|
const is_data_request = has_data_suffix(url.pathname);
|
package/src/exports/public.d.ts
CHANGED
|
@@ -513,79 +513,88 @@ export interface KitConfig {
|
|
|
513
513
|
* @default false
|
|
514
514
|
*/
|
|
515
515
|
forkPreloads?: boolean;
|
|
516
|
+
|
|
517
|
+
/**
|
|
518
|
+
* Whether to enable the experimental handling of rendering errors.
|
|
519
|
+
* When enabled, `<svelte:boundary>` is used to wrap components at each level
|
|
520
|
+
* where there's an `+error.svelte`, rendering the error page if the component fails.
|
|
521
|
+
* In addition, error boundaries also work on the server and the error object goes through `handleError`.
|
|
522
|
+
* @default false
|
|
523
|
+
*/
|
|
524
|
+
handleRenderingErrors?: boolean;
|
|
516
525
|
};
|
|
517
526
|
/**
|
|
518
527
|
* Where to find various files within your project.
|
|
519
|
-
* @deprecated
|
|
528
|
+
* @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead
|
|
520
529
|
*/
|
|
521
530
|
files?: {
|
|
522
531
|
/**
|
|
523
|
-
*
|
|
524
|
-
* @deprecated
|
|
532
|
+
* The location of your source code.
|
|
533
|
+
* @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead
|
|
525
534
|
* @default "src"
|
|
526
535
|
* @since 2.28
|
|
527
536
|
*/
|
|
528
537
|
src?: string;
|
|
529
538
|
/**
|
|
530
|
-
*
|
|
531
|
-
* @deprecated
|
|
539
|
+
* A place to put static files that should have stable URLs and undergo no processing, such as `favicon.ico` or `manifest.json`.
|
|
540
|
+
* @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead
|
|
532
541
|
* @default "static"
|
|
533
542
|
*/
|
|
534
543
|
assets?: string;
|
|
535
544
|
hooks?: {
|
|
536
545
|
/**
|
|
537
546
|
* The location of your client [hooks](https://svelte.dev/docs/kit/hooks).
|
|
538
|
-
* @deprecated
|
|
547
|
+
* @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead
|
|
539
548
|
* @default "src/hooks.client"
|
|
540
549
|
*/
|
|
541
550
|
client?: string;
|
|
542
551
|
/**
|
|
543
552
|
* The location of your server [hooks](https://svelte.dev/docs/kit/hooks).
|
|
544
|
-
* @deprecated
|
|
553
|
+
* @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead
|
|
545
554
|
* @default "src/hooks.server"
|
|
546
555
|
*/
|
|
547
556
|
server?: string;
|
|
548
557
|
/**
|
|
549
558
|
* The location of your universal [hooks](https://svelte.dev/docs/kit/hooks).
|
|
550
|
-
* @deprecated
|
|
559
|
+
* @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead
|
|
551
560
|
* @default "src/hooks"
|
|
552
561
|
* @since 2.3.0
|
|
553
562
|
*/
|
|
554
563
|
universal?: string;
|
|
555
564
|
};
|
|
556
565
|
/**
|
|
557
|
-
*
|
|
558
|
-
* @deprecated
|
|
566
|
+
* Your app's internal library, accessible throughout the codebase as `$lib`.
|
|
567
|
+
* @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead
|
|
559
568
|
* @default "src/lib"
|
|
560
569
|
*/
|
|
561
570
|
lib?: string;
|
|
562
571
|
/**
|
|
563
|
-
*
|
|
564
|
-
* @deprecated
|
|
572
|
+
* A directory containing [parameter matchers](https://svelte.dev/docs/kit/advanced-routing#Matching).
|
|
573
|
+
* @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead
|
|
565
574
|
* @default "src/params"
|
|
566
575
|
*/
|
|
567
576
|
params?: string;
|
|
568
577
|
/**
|
|
569
|
-
*
|
|
570
|
-
* @deprecated
|
|
578
|
+
* The files that define the structure of your app (see [Routing](https://svelte.dev/docs/kit/routing)).
|
|
579
|
+
* @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead
|
|
571
580
|
* @default "src/routes"
|
|
572
581
|
*/
|
|
573
582
|
routes?: string;
|
|
574
583
|
/**
|
|
575
|
-
*
|
|
576
|
-
* @deprecated
|
|
584
|
+
* The location of your service worker's entry point (see [Service workers](https://svelte.dev/docs/kit/service-workers)).
|
|
585
|
+
* @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead
|
|
577
586
|
* @default "src/service-worker"
|
|
578
587
|
*/
|
|
579
588
|
serviceWorker?: string;
|
|
580
589
|
/**
|
|
581
|
-
*
|
|
582
|
-
* @deprecated
|
|
590
|
+
* The location of the template for HTML responses.
|
|
591
|
+
* @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead
|
|
583
592
|
* @default "src/app.html"
|
|
584
593
|
*/
|
|
585
594
|
appTemplate?: string;
|
|
586
595
|
/**
|
|
587
|
-
*
|
|
588
|
-
* @deprecated
|
|
596
|
+
* The location of the template for fallback error responses.
|
|
597
|
+
* @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead
|
|
589
598
|
* @default "src/error.html"
|
|
590
599
|
*/
|
|
591
600
|
errorTemplate?: string;
|
|
@@ -1236,7 +1245,7 @@ export interface NavigationBase {
|
|
|
1236
1245
|
*/
|
|
1237
1246
|
to: NavigationTarget | null;
|
|
1238
1247
|
/**
|
|
1239
|
-
* Whether or not the navigation will result in the page being unloaded (i.e. not a client-side navigation)
|
|
1248
|
+
* Whether or not the navigation will result in the page being unloaded (i.e. not a client-side navigation).
|
|
1240
1249
|
*/
|
|
1241
1250
|
willUnload: boolean;
|
|
1242
1251
|
/**
|
|
@@ -1249,11 +1258,7 @@ export interface NavigationBase {
|
|
|
1249
1258
|
export interface NavigationEnter extends NavigationBase {
|
|
1250
1259
|
/**
|
|
1251
1260
|
* The type of navigation:
|
|
1252
|
-
* - `
|
|
1253
|
-
* - `leave`: The app is being left either because the tab is being closed or a navigation to a different document is occurring
|
|
1254
|
-
* - `link`: Navigation was triggered by a link click
|
|
1255
|
-
* - `goto`: Navigation was triggered by a `goto(...)` call or a redirect
|
|
1256
|
-
* - `popstate`: Navigation was triggered by back/forward navigation
|
|
1261
|
+
* - `enter`: The app has hydrated/started
|
|
1257
1262
|
*/
|
|
1258
1263
|
type: 'enter';
|
|
1259
1264
|
|
|
@@ -1268,16 +1273,29 @@ export interface NavigationEnter extends NavigationBase {
|
|
|
1268
1273
|
event?: undefined;
|
|
1269
1274
|
}
|
|
1270
1275
|
|
|
1271
|
-
export
|
|
1276
|
+
export type NavigationExternal = NavigationGoto | NavigationLeave;
|
|
1277
|
+
|
|
1278
|
+
export interface NavigationGoto extends NavigationBase {
|
|
1272
1279
|
/**
|
|
1273
1280
|
* The type of navigation:
|
|
1274
|
-
* - `form`: The user submitted a `<form method="GET">`
|
|
1275
|
-
* - `leave`: The app is being left either because the tab is being closed or a navigation to a different document is occurring
|
|
1276
|
-
* - `link`: Navigation was triggered by a link click
|
|
1277
1281
|
* - `goto`: Navigation was triggered by a `goto(...)` call or a redirect
|
|
1278
|
-
* - `popstate`: Navigation was triggered by back/forward navigation
|
|
1279
1282
|
*/
|
|
1280
|
-
type:
|
|
1283
|
+
type: 'goto';
|
|
1284
|
+
|
|
1285
|
+
// TODO 3.0 remove this property, so that it only exists when type is 'popstate'
|
|
1286
|
+
// (would possibly be a breaking change to do it prior to that)
|
|
1287
|
+
/**
|
|
1288
|
+
* In case of a history back/forward navigation, the number of steps to go back/forward
|
|
1289
|
+
*/
|
|
1290
|
+
delta?: undefined;
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1293
|
+
export interface NavigationLeave extends NavigationBase {
|
|
1294
|
+
/**
|
|
1295
|
+
* The type of navigation:
|
|
1296
|
+
* - `leave`: The app is being left either because the tab is being closed or a navigation to a different document is occurring
|
|
1297
|
+
*/
|
|
1298
|
+
type: 'leave';
|
|
1281
1299
|
|
|
1282
1300
|
// TODO 3.0 remove this property, so that it only exists when type is 'popstate'
|
|
1283
1301
|
// (would possibly be a breaking change to do it prior to that)
|
|
@@ -1291,10 +1309,6 @@ export interface NavigationFormSubmit extends NavigationBase {
|
|
|
1291
1309
|
/**
|
|
1292
1310
|
* The type of navigation:
|
|
1293
1311
|
* - `form`: The user submitted a `<form method="GET">`
|
|
1294
|
-
* - `leave`: The app is being left either because the tab is being closed or a navigation to a different document is occurring
|
|
1295
|
-
* - `link`: Navigation was triggered by a link click
|
|
1296
|
-
* - `goto`: Navigation was triggered by a `goto(...)` call or a redirect
|
|
1297
|
-
* - `popstate`: Navigation was triggered by back/forward navigation
|
|
1298
1312
|
*/
|
|
1299
1313
|
type: 'form';
|
|
1300
1314
|
|
|
@@ -1314,10 +1328,6 @@ export interface NavigationFormSubmit extends NavigationBase {
|
|
|
1314
1328
|
export interface NavigationPopState extends NavigationBase {
|
|
1315
1329
|
/**
|
|
1316
1330
|
* The type of navigation:
|
|
1317
|
-
* - `form`: The user submitted a `<form method="GET">`
|
|
1318
|
-
* - `leave`: The app is being left either because the tab is being closed or a navigation to a different document is occurring
|
|
1319
|
-
* - `link`: Navigation was triggered by a link click
|
|
1320
|
-
* - `goto`: Navigation was triggered by a `goto(...)` call or a redirect
|
|
1321
1331
|
* - `popstate`: Navigation was triggered by back/forward navigation
|
|
1322
1332
|
*/
|
|
1323
1333
|
type: 'popstate';
|
|
@@ -1336,11 +1346,7 @@ export interface NavigationPopState extends NavigationBase {
|
|
|
1336
1346
|
export interface NavigationLink extends NavigationBase {
|
|
1337
1347
|
/**
|
|
1338
1348
|
* The type of navigation:
|
|
1339
|
-
* - `form`: The user submitted a `<form method="GET">`
|
|
1340
|
-
* - `leave`: The app is being left either because the tab is being closed or a navigation to a different document is occurring
|
|
1341
1349
|
* - `link`: Navigation was triggered by a link click
|
|
1342
|
-
* - `goto`: Navigation was triggered by a `goto(...)` call or a redirect
|
|
1343
|
-
* - `popstate`: Navigation was triggered by back/forward navigation
|
|
1344
1350
|
*/
|
|
1345
1351
|
type: 'link';
|
|
1346
1352
|
|
|
@@ -1377,13 +1383,6 @@ export type BeforeNavigate = Navigation & {
|
|
|
1377
1383
|
* The argument passed to [`onNavigate`](https://svelte.dev/docs/kit/$app-navigation#onNavigate) callbacks.
|
|
1378
1384
|
*/
|
|
1379
1385
|
export type OnNavigate = Navigation & {
|
|
1380
|
-
/**
|
|
1381
|
-
* The type of navigation:
|
|
1382
|
-
* - `form`: The user submitted a `<form method="GET">`
|
|
1383
|
-
* - `link`: Navigation was triggered by a link click
|
|
1384
|
-
* - `goto`: Navigation was triggered by a `goto(...)` call or a redirect
|
|
1385
|
-
* - `popstate`: Navigation was triggered by back/forward navigation
|
|
1386
|
-
*/
|
|
1387
1386
|
type: Exclude<NavigationType, 'enter' | 'leave'>;
|
|
1388
1387
|
/**
|
|
1389
1388
|
* Since `onNavigate` callbacks are called immediately before a client-side navigation, they will never be called with a navigation that unloads the page.
|
|
@@ -1395,14 +1394,6 @@ export type OnNavigate = Navigation & {
|
|
|
1395
1394
|
* The argument passed to [`afterNavigate`](https://svelte.dev/docs/kit/$app-navigation#afterNavigate) callbacks.
|
|
1396
1395
|
*/
|
|
1397
1396
|
export type AfterNavigate = (Navigation | NavigationEnter) & {
|
|
1398
|
-
/**
|
|
1399
|
-
* The type of navigation:
|
|
1400
|
-
* - `enter`: The app has hydrated/started
|
|
1401
|
-
* - `form`: The user submitted a `<form method="GET">`
|
|
1402
|
-
* - `link`: Navigation was triggered by a link click
|
|
1403
|
-
* - `goto`: Navigation was triggered by a `goto(...)` call or a redirect
|
|
1404
|
-
* - `popstate`: Navigation was triggered by back/forward navigation
|
|
1405
|
-
*/
|
|
1406
1397
|
type: Exclude<NavigationType, 'leave'>;
|
|
1407
1398
|
/**
|
|
1408
1399
|
* Since `afterNavigate` callbacks are called after a navigation completes, they will never be called with a navigation that unloads the page.
|
|
@@ -107,7 +107,7 @@ export function build_server_nodes(
|
|
|
107
107
|
let fonts = [];
|
|
108
108
|
|
|
109
109
|
/** @type {Set<string>} */
|
|
110
|
-
|
|
110
|
+
const eager_assets = new Set();
|
|
111
111
|
|
|
112
112
|
if (node.component && client_manifest) {
|
|
113
113
|
exports.push(
|
|
@@ -215,7 +215,7 @@ export function build_server_nodes(
|
|
|
215
215
|
const filename = basename(file);
|
|
216
216
|
const dest = `${out}/server/stylesheets/${filename}.js`;
|
|
217
217
|
|
|
218
|
-
|
|
218
|
+
const css = /** @type {string} */ (stylesheets_to_inline.get(file));
|
|
219
219
|
|
|
220
220
|
fs.writeFileSync(
|
|
221
221
|
dest,
|
|
@@ -367,7 +367,8 @@ async function kit({ svelte_config }) {
|
|
|
367
367
|
__SVELTEKIT_PATHS_RELATIVE__: s(kit.paths.relative),
|
|
368
368
|
__SVELTEKIT_CLIENT_ROUTING__: s(kit.router.resolution === 'client'),
|
|
369
369
|
__SVELTEKIT_HASH_ROUTING__: s(kit.router.type === 'hash'),
|
|
370
|
-
__SVELTEKIT_SERVER_TRACING_ENABLED__: s(kit.experimental.tracing.server)
|
|
370
|
+
__SVELTEKIT_SERVER_TRACING_ENABLED__: s(kit.experimental.tracing.server),
|
|
371
|
+
__SVELTEKIT_EXPERIMENTAL_USE_TRANSFORM_ERROR__: s(kit.experimental.handleRenderingErrors)
|
|
371
372
|
};
|
|
372
373
|
|
|
373
374
|
if (is_build) {
|
|
@@ -932,9 +933,7 @@ async function kit({ svelte_config }) {
|
|
|
932
933
|
assetFileNames: `${prefix}/assets/[name].[hash][extname]`,
|
|
933
934
|
hoistTransitiveImports: false,
|
|
934
935
|
sourcemapIgnoreList,
|
|
935
|
-
inlineDynamicImports: is_rolldown ? undefined : !split
|
|
936
|
-
// @ts-ignore: only available in Vite 8
|
|
937
|
-
codeSplitting: is_rolldown ? split : undefined
|
|
936
|
+
inlineDynamicImports: is_rolldown ? undefined : !split
|
|
938
937
|
},
|
|
939
938
|
preserveEntrySignatures: 'strict',
|
|
940
939
|
onwarn(warning, handler) {
|
|
@@ -967,6 +966,13 @@ async function kit({ svelte_config }) {
|
|
|
967
966
|
}
|
|
968
967
|
}
|
|
969
968
|
};
|
|
969
|
+
|
|
970
|
+
// we must reference Vite 8 options conditionally. Otherwise, older Vite
|
|
971
|
+
// versions throw an error about unknown config options
|
|
972
|
+
if (is_rolldown && new_config?.build?.rollupOptions?.output) {
|
|
973
|
+
// @ts-ignore only available in Vite 8
|
|
974
|
+
new_config.build.rollupOptions.output.codeSplitting = split;
|
|
975
|
+
}
|
|
970
976
|
} else {
|
|
971
977
|
new_config = {
|
|
972
978
|
appType: 'custom',
|
|
@@ -974,7 +980,7 @@ async function kit({ svelte_config }) {
|
|
|
974
980
|
build: {
|
|
975
981
|
rollupOptions: {
|
|
976
982
|
// Vite dependency crawler needs an explicit JS entry point
|
|
977
|
-
//
|
|
983
|
+
// even though server otherwise works without it
|
|
978
984
|
input: `${runtime_directory}/client/entry.js`
|
|
979
985
|
}
|
|
980
986
|
},
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @import { Asset, RouteId, Pathname, ResolvedPathname } from '$app/types' */
|
|
1
|
+
/** @import { Asset, RouteId, RouteIdWithSearchOrHash, Pathname, PathnameWithSearchOrHash, ResolvedPathname } from '$app/types' */
|
|
2
2
|
/** @import { ResolveArgs } from './types.js' */
|
|
3
3
|
import { base, assets, hash_routing } from './internal/client.js';
|
|
4
4
|
import { resolve_route } from '../../../utils/routing.js';
|
|
@@ -47,7 +47,7 @@ const pathname_prefix = hash_routing ? '#' : '';
|
|
|
47
47
|
* ```
|
|
48
48
|
* @since 2.26
|
|
49
49
|
*
|
|
50
|
-
* @template {
|
|
50
|
+
* @template {RouteIdWithSearchOrHash | PathnameWithSearchOrHash} T
|
|
51
51
|
* @param {ResolveArgs<T>} args
|
|
52
52
|
* @returns {ResolvedPathname}
|
|
53
53
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RouteIdWithSearchOrHash, PathnameWithSearchOrHash, ResolvedPathname } from '$app/types';
|
|
2
2
|
import { ResolveArgs } from './types.js';
|
|
3
3
|
|
|
4
4
|
export { resolve, asset, match } from './client.js';
|
|
@@ -24,6 +24,6 @@ export let assets: '' | `https://${string}` | `http://${string}` | '/_svelte_kit
|
|
|
24
24
|
/**
|
|
25
25
|
* @deprecated Use [`resolve(...)`](https://svelte.dev/docs/kit/$app-paths#resolve) instead
|
|
26
26
|
*/
|
|
27
|
-
export function resolveRoute<T extends
|
|
27
|
+
export function resolveRoute<T extends RouteIdWithSearchOrHash | PathnameWithSearchOrHash>(
|
|
28
28
|
...args: ResolveArgs<T>
|
|
29
29
|
): ResolvedPathname;
|
|
@@ -35,7 +35,7 @@ export async function match(url) {
|
|
|
35
35
|
const store = try_get_request_store();
|
|
36
36
|
|
|
37
37
|
if (typeof url === 'string') {
|
|
38
|
-
const origin = store?.event.url.origin ?? '
|
|
38
|
+
const origin = store?.event.url.origin ?? 'a://a';
|
|
39
39
|
url = new URL(url, origin);
|
|
40
40
|
}
|
|
41
41
|
|
|
@@ -1,7 +1,23 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
PathnameWithSearchOrHash,
|
|
3
|
+
RouteId,
|
|
4
|
+
RouteIdWithSearchOrHash,
|
|
5
|
+
RouteParams
|
|
6
|
+
} from '$app/types';
|
|
2
7
|
|
|
3
|
-
|
|
4
|
-
?
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
+
type StripSearchOrHash<T extends string> = T extends `${infer Pathname}?${string}`
|
|
9
|
+
? Pathname
|
|
10
|
+
: T extends `${infer Pathname}#${string}`
|
|
11
|
+
? Pathname
|
|
12
|
+
: T;
|
|
13
|
+
|
|
14
|
+
export type ResolveArgs<T extends RouteIdWithSearchOrHash | PathnameWithSearchOrHash> =
|
|
15
|
+
T extends RouteId
|
|
16
|
+
? RouteParams<T> extends Record<string, never>
|
|
17
|
+
? [route: T]
|
|
18
|
+
: [route: T, params: RouteParams<T>]
|
|
19
|
+
: StripSearchOrHash<T> extends infer U extends RouteId
|
|
20
|
+
? RouteParams<U> extends Record<string, never>
|
|
21
|
+
? [route: T]
|
|
22
|
+
: [route: T, params: RouteParams<U>]
|
|
23
|
+
: [route: T];
|