@sveltejs/kit 1.23.1 → 1.24.1
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 +27 -4
- package/src/runtime/app/navigation.js +14 -0
- package/src/runtime/client/client.js +111 -37
- package/src/runtime/client/singletons.js +1 -1
- package/src/runtime/client/types.d.ts +2 -0
- package/src/types/internal.d.ts +1 -1
- package/src/version.js +1 -1
- package/types/index.d.ts +38 -4
- package/types/index.d.ts.map +3 -1
package/package.json
CHANGED
package/src/exports/public.d.ts
CHANGED
|
@@ -730,7 +730,7 @@ export interface LoadEvent<
|
|
|
730
730
|
*
|
|
731
731
|
* Setting the same header multiple times (even in separate `load` functions) is an error — you can only set a given header once.
|
|
732
732
|
*
|
|
733
|
-
* You cannot add a `set-cookie` header with `setHeaders` —
|
|
733
|
+
* You cannot add a `set-cookie` header with `setHeaders` — use the [`cookies`](https://kit.svelte.dev/docs/types#public-types-cookies) API in a server-only `load` function instead.
|
|
734
734
|
*
|
|
735
735
|
* `setHeaders` has no effect when a `load` function runs in the browser.
|
|
736
736
|
*/
|
|
@@ -860,6 +860,11 @@ export interface Navigation {
|
|
|
860
860
|
* In case of a history back/forward navigation, the number of steps to go back/forward
|
|
861
861
|
*/
|
|
862
862
|
delta?: number;
|
|
863
|
+
/**
|
|
864
|
+
* A promise that resolves once the navigation is complete, and rejects if the navigation
|
|
865
|
+
* fails or is aborted. In the case of a `willUnload` navigation, the promise will never resolve
|
|
866
|
+
*/
|
|
867
|
+
complete: Promise<void>;
|
|
863
868
|
}
|
|
864
869
|
|
|
865
870
|
/**
|
|
@@ -872,6 +877,24 @@ export interface BeforeNavigate extends Navigation {
|
|
|
872
877
|
cancel(): void;
|
|
873
878
|
}
|
|
874
879
|
|
|
880
|
+
/**
|
|
881
|
+
* The argument passed to [`onNavigate`](https://kit.svelte.dev/docs/modules#$app-navigation-onnavigate) callbacks.
|
|
882
|
+
*/
|
|
883
|
+
export interface OnNavigate extends Navigation {
|
|
884
|
+
/**
|
|
885
|
+
* The type of navigation:
|
|
886
|
+
* - `form`: The user submitted a `<form>`
|
|
887
|
+
* - `link`: Navigation was triggered by a link click
|
|
888
|
+
* - `goto`: Navigation was triggered by a `goto(...)` call or a redirect
|
|
889
|
+
* - `popstate`: Navigation was triggered by back/forward navigation
|
|
890
|
+
*/
|
|
891
|
+
type: Exclude<NavigationType, 'enter' | 'leave'>;
|
|
892
|
+
/**
|
|
893
|
+
* Since `onNavigate` callbacks are called immediately before a client-side navigation, they will never be called with a navigation that unloads the page.
|
|
894
|
+
*/
|
|
895
|
+
willUnload: false;
|
|
896
|
+
}
|
|
897
|
+
|
|
875
898
|
/**
|
|
876
899
|
* The argument passed to [`afterNavigate`](https://kit.svelte.dev/docs/modules#$app-navigation-afternavigate) callbacks.
|
|
877
900
|
*/
|
|
@@ -886,7 +909,7 @@ export interface AfterNavigate extends Omit<Navigation, 'type'> {
|
|
|
886
909
|
*/
|
|
887
910
|
type: Exclude<NavigationType, 'leave'>;
|
|
888
911
|
/**
|
|
889
|
-
* Since `afterNavigate`
|
|
912
|
+
* Since `afterNavigate` callbacks are called after a navigation completes, they will never be called with a navigation that unloads the page.
|
|
890
913
|
*/
|
|
891
914
|
willUnload: false;
|
|
892
915
|
}
|
|
@@ -1007,7 +1030,7 @@ export interface RequestEvent<
|
|
|
1007
1030
|
*
|
|
1008
1031
|
* Setting the same header multiple times (even in separate `load` functions) is an error — you can only set a given header once.
|
|
1009
1032
|
*
|
|
1010
|
-
* You cannot add a `set-cookie` header with `setHeaders` —
|
|
1033
|
+
* You cannot add a `set-cookie` header with `setHeaders` — use the [`cookies`](https://kit.svelte.dev/docs/types#public-types-cookies) API instead.
|
|
1011
1034
|
*/
|
|
1012
1035
|
setHeaders(headers: Record<string, string>): void;
|
|
1013
1036
|
/**
|
|
@@ -1064,7 +1087,7 @@ export interface RouteDefinition<Config = any> {
|
|
|
1064
1087
|
methods: HttpMethod[];
|
|
1065
1088
|
};
|
|
1066
1089
|
page: {
|
|
1067
|
-
methods: Extract<HttpMethod, 'GET' | 'POST'
|
|
1090
|
+
methods: Array<Extract<HttpMethod, 'GET' | 'POST'>>;
|
|
1068
1091
|
};
|
|
1069
1092
|
pattern: RegExp;
|
|
1070
1093
|
prerender: PrerenderOption;
|
|
@@ -101,6 +101,20 @@ export const preloadCode = /* @__PURE__ */ client_method('preload_code');
|
|
|
101
101
|
*/
|
|
102
102
|
export const beforeNavigate = /* @__PURE__ */ client_method('before_navigate');
|
|
103
103
|
|
|
104
|
+
/**
|
|
105
|
+
* A lifecycle function that runs the supplied `callback` immediately before we navigate to a new URL.
|
|
106
|
+
*
|
|
107
|
+
* If you return a `Promise`, SvelteKit will wait for it to resolve before completing the navigation. This allows you to — for example — use `document.startViewTransition`. Avoid promises that are slow to resolve, since navigation will appear stalled to the user.
|
|
108
|
+
*
|
|
109
|
+
* If a function (or a `Promise` that resolves to a function) is returned from the callback, it will be called once the DOM has updated.
|
|
110
|
+
*
|
|
111
|
+
* `onNavigate` must be called during a component initialization. It remains active as long as the component is mounted.
|
|
112
|
+
* @type {(callback: (navigation: import('@sveltejs/kit').OnNavigate) => import('../../types/internal.js').MaybePromise<(() => void) | void>) => void}
|
|
113
|
+
* @param {(navigation: import('@sveltejs/kit').OnNavigate) => void} callback
|
|
114
|
+
* @returns {void}
|
|
115
|
+
*/
|
|
116
|
+
export const onNavigate = /* @__PURE__ */ client_method('on_navigate');
|
|
117
|
+
|
|
104
118
|
/**
|
|
105
119
|
* A lifecycle function that runs the supplied `callback` when the current component mounts, and also whenever we navigate to a new URL.
|
|
106
120
|
*
|
|
@@ -89,6 +89,9 @@ export function create_client(app, target) {
|
|
|
89
89
|
/** @type {Array<(navigation: import('@sveltejs/kit').BeforeNavigate) => void>} */
|
|
90
90
|
before_navigate: [],
|
|
91
91
|
|
|
92
|
+
/** @type {Array<(navigation: import('@sveltejs/kit').OnNavigate) => import('types').MaybePromise<(() => void) | void>>} */
|
|
93
|
+
on_navigate: [],
|
|
94
|
+
|
|
92
95
|
/** @type {Array<(navigation: import('@sveltejs/kit').AfterNavigate) => void>} */
|
|
93
96
|
after_navigate: []
|
|
94
97
|
};
|
|
@@ -299,7 +302,8 @@ export function create_client(app, target) {
|
|
|
299
302
|
url: new URL(location.href)
|
|
300
303
|
},
|
|
301
304
|
willUnload: false,
|
|
302
|
-
type: 'enter'
|
|
305
|
+
type: 'enter',
|
|
306
|
+
complete: Promise.resolve()
|
|
303
307
|
};
|
|
304
308
|
callbacks.after_navigate.forEach((fn) => fn(navigation));
|
|
305
309
|
|
|
@@ -449,12 +453,12 @@ export function create_client(app, target) {
|
|
|
449
453
|
|
|
450
454
|
/** @type {import('@sveltejs/kit').LoadEvent} */
|
|
451
455
|
const load_input = {
|
|
452
|
-
route: {
|
|
453
|
-
get
|
|
456
|
+
route: new Proxy(route, {
|
|
457
|
+
get: (target, key) => {
|
|
454
458
|
uses.route = true;
|
|
455
|
-
return
|
|
459
|
+
return target[/** @type {'id'} */ (key)];
|
|
456
460
|
}
|
|
457
|
-
},
|
|
461
|
+
}),
|
|
458
462
|
params: new Proxy(params, {
|
|
459
463
|
get: (target, key) => {
|
|
460
464
|
uses.params.add(/** @type {string} */ (key));
|
|
@@ -910,30 +914,17 @@ export function create_client(app, target) {
|
|
|
910
914
|
function before_navigate({ url, type, intent, delta }) {
|
|
911
915
|
let should_block = false;
|
|
912
916
|
|
|
913
|
-
|
|
914
|
-
const navigation = {
|
|
915
|
-
from: {
|
|
916
|
-
params: current.params,
|
|
917
|
-
route: { id: current.route?.id ?? null },
|
|
918
|
-
url: current.url
|
|
919
|
-
},
|
|
920
|
-
to: {
|
|
921
|
-
params: intent?.params ?? null,
|
|
922
|
-
route: { id: intent?.route?.id ?? null },
|
|
923
|
-
url
|
|
924
|
-
},
|
|
925
|
-
willUnload: !intent,
|
|
926
|
-
type
|
|
927
|
-
};
|
|
917
|
+
const nav = create_navigation(current, intent, url, type);
|
|
928
918
|
|
|
929
919
|
if (delta !== undefined) {
|
|
930
|
-
navigation.delta = delta;
|
|
920
|
+
nav.navigation.delta = delta;
|
|
931
921
|
}
|
|
932
922
|
|
|
933
923
|
const cancellable = {
|
|
934
|
-
...navigation,
|
|
924
|
+
...nav.navigation,
|
|
935
925
|
cancel: () => {
|
|
936
926
|
should_block = true;
|
|
927
|
+
nav.reject(new Error('navigation was cancelled'));
|
|
937
928
|
}
|
|
938
929
|
};
|
|
939
930
|
|
|
@@ -942,7 +933,7 @@ export function create_client(app, target) {
|
|
|
942
933
|
callbacks.before_navigate.forEach((fn) => fn(cancellable));
|
|
943
934
|
}
|
|
944
935
|
|
|
945
|
-
return should_block ? null :
|
|
936
|
+
return should_block ? null : nav;
|
|
946
937
|
}
|
|
947
938
|
|
|
948
939
|
/**
|
|
@@ -975,9 +966,9 @@ export function create_client(app, target) {
|
|
|
975
966
|
blocked
|
|
976
967
|
}) {
|
|
977
968
|
const intent = get_navigation_intent(url, false);
|
|
978
|
-
const
|
|
969
|
+
const nav = before_navigate({ url, type, delta, intent });
|
|
979
970
|
|
|
980
|
-
if (!
|
|
971
|
+
if (!nav) {
|
|
981
972
|
blocked();
|
|
982
973
|
return;
|
|
983
974
|
}
|
|
@@ -990,7 +981,7 @@ export function create_client(app, target) {
|
|
|
990
981
|
navigating = true;
|
|
991
982
|
|
|
992
983
|
if (started) {
|
|
993
|
-
stores.navigating.set(navigation);
|
|
984
|
+
stores.navigating.set(nav.navigation);
|
|
994
985
|
}
|
|
995
986
|
|
|
996
987
|
token = nav_token;
|
|
@@ -1017,7 +1008,10 @@ export function create_client(app, target) {
|
|
|
1017
1008
|
url = intent?.url || url;
|
|
1018
1009
|
|
|
1019
1010
|
// abort if user navigated during update
|
|
1020
|
-
if (token !== nav_token)
|
|
1011
|
+
if (token !== nav_token) {
|
|
1012
|
+
nav.reject(new Error('navigation was aborted'));
|
|
1013
|
+
return false;
|
|
1014
|
+
}
|
|
1021
1015
|
|
|
1022
1016
|
if (navigation_result.type === 'redirect') {
|
|
1023
1017
|
if (redirect_chain.length > 10 || redirect_chain.includes(url.pathname)) {
|
|
@@ -1093,6 +1087,28 @@ export function create_client(app, target) {
|
|
|
1093
1087
|
navigation_result.props.page.url = url;
|
|
1094
1088
|
}
|
|
1095
1089
|
|
|
1090
|
+
const after_navigate = (
|
|
1091
|
+
await Promise.all(
|
|
1092
|
+
callbacks.on_navigate.map((fn) =>
|
|
1093
|
+
fn(/** @type {import('@sveltejs/kit').OnNavigate} */ (nav.navigation))
|
|
1094
|
+
)
|
|
1095
|
+
)
|
|
1096
|
+
).filter((value) => typeof value === 'function');
|
|
1097
|
+
|
|
1098
|
+
if (after_navigate.length > 0) {
|
|
1099
|
+
function cleanup() {
|
|
1100
|
+
callbacks.after_navigate = callbacks.after_navigate.filter(
|
|
1101
|
+
// @ts-ignore
|
|
1102
|
+
(fn) => !after_navigate.includes(fn)
|
|
1103
|
+
);
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1106
|
+
after_navigate.push(cleanup);
|
|
1107
|
+
|
|
1108
|
+
// @ts-ignore
|
|
1109
|
+
callbacks.after_navigate.push(...after_navigate);
|
|
1110
|
+
}
|
|
1111
|
+
|
|
1096
1112
|
root.$set(navigation_result.props);
|
|
1097
1113
|
} else {
|
|
1098
1114
|
initialize(navigation_result);
|
|
@@ -1142,8 +1158,10 @@ export function create_client(app, target) {
|
|
|
1142
1158
|
restore_snapshot(current_history_index);
|
|
1143
1159
|
}
|
|
1144
1160
|
|
|
1161
|
+
nav.fulfil(undefined);
|
|
1162
|
+
|
|
1145
1163
|
callbacks.after_navigate.forEach((fn) =>
|
|
1146
|
-
fn(/** @type {import('@sveltejs/kit').AfterNavigate} */ (navigation))
|
|
1164
|
+
fn(/** @type {import('@sveltejs/kit').AfterNavigate} */ (nav.navigation))
|
|
1147
1165
|
);
|
|
1148
1166
|
stores.navigating.set(null);
|
|
1149
1167
|
|
|
@@ -1339,6 +1357,17 @@ export function create_client(app, target) {
|
|
|
1339
1357
|
});
|
|
1340
1358
|
},
|
|
1341
1359
|
|
|
1360
|
+
on_navigate: (fn) => {
|
|
1361
|
+
onMount(() => {
|
|
1362
|
+
callbacks.on_navigate.push(fn);
|
|
1363
|
+
|
|
1364
|
+
return () => {
|
|
1365
|
+
const i = callbacks.on_navigate.indexOf(fn);
|
|
1366
|
+
callbacks.on_navigate.splice(i, 1);
|
|
1367
|
+
};
|
|
1368
|
+
});
|
|
1369
|
+
},
|
|
1370
|
+
|
|
1342
1371
|
disable_scroll_handling: () => {
|
|
1343
1372
|
if (DEV && started && !updating) {
|
|
1344
1373
|
throw new Error('Can only disable scroll handling during navigation');
|
|
@@ -1444,19 +1473,17 @@ export function create_client(app, target) {
|
|
|
1444
1473
|
persist_state();
|
|
1445
1474
|
|
|
1446
1475
|
if (!navigating) {
|
|
1476
|
+
const nav = create_navigation(current, undefined, null, 'leave');
|
|
1477
|
+
|
|
1447
1478
|
// If we're navigating, beforeNavigate was already called. If we end up in here during navigation,
|
|
1448
1479
|
// it's due to an external or full-page-reload link, for which we don't want to call the hook again.
|
|
1449
1480
|
/** @type {import('@sveltejs/kit').BeforeNavigate} */
|
|
1450
1481
|
const navigation = {
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
}
|
|
1456
|
-
to: null,
|
|
1457
|
-
willUnload: true,
|
|
1458
|
-
type: 'leave',
|
|
1459
|
-
cancel: () => (should_block = true)
|
|
1482
|
+
...nav.navigation,
|
|
1483
|
+
cancel: () => {
|
|
1484
|
+
should_block = true;
|
|
1485
|
+
nav.reject(new Error('navigation was cancelled'));
|
|
1486
|
+
}
|
|
1460
1487
|
};
|
|
1461
1488
|
|
|
1462
1489
|
callbacks.before_navigate.forEach((fn) => fn(navigation));
|
|
@@ -1990,6 +2017,53 @@ function reset_focus() {
|
|
|
1990
2017
|
}
|
|
1991
2018
|
}
|
|
1992
2019
|
|
|
2020
|
+
/**
|
|
2021
|
+
* @param {import('./types').NavigationState} current
|
|
2022
|
+
* @param {import('./types').NavigationIntent | undefined} intent
|
|
2023
|
+
* @param {URL | null} url
|
|
2024
|
+
* @param {Exclude<import('@sveltejs/kit').NavigationType, 'enter'>} type
|
|
2025
|
+
*/
|
|
2026
|
+
function create_navigation(current, intent, url, type) {
|
|
2027
|
+
/** @type {(value: any) => void} */
|
|
2028
|
+
let fulfil;
|
|
2029
|
+
|
|
2030
|
+
/** @type {(error: any) => void} */
|
|
2031
|
+
let reject;
|
|
2032
|
+
|
|
2033
|
+
const complete = new Promise((f, r) => {
|
|
2034
|
+
fulfil = f;
|
|
2035
|
+
reject = r;
|
|
2036
|
+
});
|
|
2037
|
+
|
|
2038
|
+
// Handle any errors off-chain so that it doesn't show up as an unhandled rejection
|
|
2039
|
+
complete.catch(() => {});
|
|
2040
|
+
|
|
2041
|
+
/** @type {import('@sveltejs/kit').Navigation} */
|
|
2042
|
+
const navigation = {
|
|
2043
|
+
from: {
|
|
2044
|
+
params: current.params,
|
|
2045
|
+
route: { id: current.route?.id ?? null },
|
|
2046
|
+
url: current.url
|
|
2047
|
+
},
|
|
2048
|
+
to: url && {
|
|
2049
|
+
params: intent?.params ?? null,
|
|
2050
|
+
route: { id: intent?.route?.id ?? null },
|
|
2051
|
+
url
|
|
2052
|
+
},
|
|
2053
|
+
willUnload: !intent,
|
|
2054
|
+
type,
|
|
2055
|
+
complete
|
|
2056
|
+
};
|
|
2057
|
+
|
|
2058
|
+
return {
|
|
2059
|
+
navigation,
|
|
2060
|
+
// @ts-expect-error
|
|
2061
|
+
fulfil,
|
|
2062
|
+
// @ts-expect-error
|
|
2063
|
+
reject
|
|
2064
|
+
};
|
|
2065
|
+
}
|
|
2066
|
+
|
|
1993
2067
|
if (DEV) {
|
|
1994
2068
|
// Nasty hack to silence harmless warnings the user can do nothing about
|
|
1995
2069
|
const console_warn = console.warn;
|
|
@@ -21,7 +21,7 @@ export function init(opts) {
|
|
|
21
21
|
*/
|
|
22
22
|
export function client_method(key) {
|
|
23
23
|
if (!BROWSER) {
|
|
24
|
-
if (key === 'before_navigate' || key === 'after_navigate') {
|
|
24
|
+
if (key === 'before_navigate' || key === 'after_navigate' || key === 'on_navigate') {
|
|
25
25
|
// @ts-expect-error doesn't recognize that both keys here return void so expects a async function
|
|
26
26
|
return () => {};
|
|
27
27
|
} else {
|
|
@@ -2,6 +2,7 @@ import { applyAction } from '../app/forms';
|
|
|
2
2
|
import {
|
|
3
3
|
afterNavigate,
|
|
4
4
|
beforeNavigate,
|
|
5
|
+
onNavigate,
|
|
5
6
|
goto,
|
|
6
7
|
invalidate,
|
|
7
8
|
invalidateAll,
|
|
@@ -43,6 +44,7 @@ export interface Client {
|
|
|
43
44
|
// public API, exposed via $app/navigation
|
|
44
45
|
after_navigate: typeof afterNavigate;
|
|
45
46
|
before_navigate: typeof beforeNavigate;
|
|
47
|
+
on_navigate: typeof onNavigate;
|
|
46
48
|
disable_scroll_handling(): void;
|
|
47
49
|
goto: typeof goto;
|
|
48
50
|
invalidate: typeof invalidate;
|
package/src/types/internal.d.ts
CHANGED
package/src/version.js
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -710,7 +710,7 @@ declare module '@sveltejs/kit' {
|
|
|
710
710
|
*
|
|
711
711
|
* Setting the same header multiple times (even in separate `load` functions) is an error — you can only set a given header once.
|
|
712
712
|
*
|
|
713
|
-
* You cannot add a `set-cookie` header with `setHeaders` —
|
|
713
|
+
* You cannot add a `set-cookie` header with `setHeaders` — use the [`cookies`](https://kit.svelte.dev/docs/types#public-types-cookies) API in a server-only `load` function instead.
|
|
714
714
|
*
|
|
715
715
|
* `setHeaders` has no effect when a `load` function runs in the browser.
|
|
716
716
|
*/
|
|
@@ -840,6 +840,11 @@ declare module '@sveltejs/kit' {
|
|
|
840
840
|
* In case of a history back/forward navigation, the number of steps to go back/forward
|
|
841
841
|
*/
|
|
842
842
|
delta?: number;
|
|
843
|
+
/**
|
|
844
|
+
* A promise that resolves once the navigation is complete, and rejects if the navigation
|
|
845
|
+
* fails or is aborted. In the case of a `willUnload` navigation, the promise will never resolve
|
|
846
|
+
*/
|
|
847
|
+
complete: Promise<void>;
|
|
843
848
|
}
|
|
844
849
|
|
|
845
850
|
/**
|
|
@@ -852,6 +857,24 @@ declare module '@sveltejs/kit' {
|
|
|
852
857
|
cancel(): void;
|
|
853
858
|
}
|
|
854
859
|
|
|
860
|
+
/**
|
|
861
|
+
* The argument passed to [`onNavigate`](https://kit.svelte.dev/docs/modules#$app-navigation-onnavigate) callbacks.
|
|
862
|
+
*/
|
|
863
|
+
export interface OnNavigate extends Navigation {
|
|
864
|
+
/**
|
|
865
|
+
* The type of navigation:
|
|
866
|
+
* - `form`: The user submitted a `<form>`
|
|
867
|
+
* - `link`: Navigation was triggered by a link click
|
|
868
|
+
* - `goto`: Navigation was triggered by a `goto(...)` call or a redirect
|
|
869
|
+
* - `popstate`: Navigation was triggered by back/forward navigation
|
|
870
|
+
*/
|
|
871
|
+
type: Exclude<NavigationType, 'enter' | 'leave'>;
|
|
872
|
+
/**
|
|
873
|
+
* Since `onNavigate` callbacks are called immediately before a client-side navigation, they will never be called with a navigation that unloads the page.
|
|
874
|
+
*/
|
|
875
|
+
willUnload: false;
|
|
876
|
+
}
|
|
877
|
+
|
|
855
878
|
/**
|
|
856
879
|
* The argument passed to [`afterNavigate`](https://kit.svelte.dev/docs/modules#$app-navigation-afternavigate) callbacks.
|
|
857
880
|
*/
|
|
@@ -866,7 +889,7 @@ declare module '@sveltejs/kit' {
|
|
|
866
889
|
*/
|
|
867
890
|
type: Exclude<NavigationType, 'leave'>;
|
|
868
891
|
/**
|
|
869
|
-
* Since `afterNavigate`
|
|
892
|
+
* Since `afterNavigate` callbacks are called after a navigation completes, they will never be called with a navigation that unloads the page.
|
|
870
893
|
*/
|
|
871
894
|
willUnload: false;
|
|
872
895
|
}
|
|
@@ -987,7 +1010,7 @@ declare module '@sveltejs/kit' {
|
|
|
987
1010
|
*
|
|
988
1011
|
* Setting the same header multiple times (even in separate `load` functions) is an error — you can only set a given header once.
|
|
989
1012
|
*
|
|
990
|
-
* You cannot add a `set-cookie` header with `setHeaders` —
|
|
1013
|
+
* You cannot add a `set-cookie` header with `setHeaders` — use the [`cookies`](https://kit.svelte.dev/docs/types#public-types-cookies) API instead.
|
|
991
1014
|
*/
|
|
992
1015
|
setHeaders(headers: Record<string, string>): void;
|
|
993
1016
|
/**
|
|
@@ -1044,7 +1067,7 @@ declare module '@sveltejs/kit' {
|
|
|
1044
1067
|
methods: HttpMethod[];
|
|
1045
1068
|
};
|
|
1046
1069
|
page: {
|
|
1047
|
-
methods: Extract<HttpMethod, 'GET' | 'POST'
|
|
1070
|
+
methods: Array<Extract<HttpMethod, 'GET' | 'POST'>>;
|
|
1048
1071
|
};
|
|
1049
1072
|
pattern: RegExp;
|
|
1050
1073
|
prerender: PrerenderOption;
|
|
@@ -1951,12 +1974,23 @@ declare module '$app/navigation' {
|
|
|
1951
1974
|
* `beforeNavigate` must be called during a component initialization. It remains active as long as the component is mounted.
|
|
1952
1975
|
* */
|
|
1953
1976
|
export const beforeNavigate: (callback: (navigation: import('@sveltejs/kit').BeforeNavigate) => void) => void;
|
|
1977
|
+
/**
|
|
1978
|
+
* A lifecycle function that runs the supplied `callback` immediately before we navigate to a new URL.
|
|
1979
|
+
*
|
|
1980
|
+
* If you return a `Promise`, SvelteKit will wait for it to resolve before completing the navigation. This allows you to — for example — use `document.startViewTransition`. Avoid promises that are slow to resolve, since navigation will appear stalled to the user.
|
|
1981
|
+
*
|
|
1982
|
+
* If a function (or a `Promise` that resolves to a function) is returned from the callback, it will be called once the DOM has updated.
|
|
1983
|
+
*
|
|
1984
|
+
* `onNavigate` must be called during a component initialization. It remains active as long as the component is mounted.
|
|
1985
|
+
* */
|
|
1986
|
+
export const onNavigate: (callback: (navigation: import('@sveltejs/kit').OnNavigate) => MaybePromise<(() => void) | void>) => void;
|
|
1954
1987
|
/**
|
|
1955
1988
|
* A lifecycle function that runs the supplied `callback` when the current component mounts, and also whenever we navigate to a new URL.
|
|
1956
1989
|
*
|
|
1957
1990
|
* `afterNavigate` must be called during a component initialization. It remains active as long as the component is mounted.
|
|
1958
1991
|
* */
|
|
1959
1992
|
export const afterNavigate: (callback: (navigation: import('@sveltejs/kit').AfterNavigate) => void) => void;
|
|
1993
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
1960
1994
|
}
|
|
1961
1995
|
|
|
1962
1996
|
declare module '$app/paths' {
|
package/types/index.d.ts.map
CHANGED
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"NavigationType",
|
|
21
21
|
"Navigation",
|
|
22
22
|
"BeforeNavigate",
|
|
23
|
+
"OnNavigate",
|
|
23
24
|
"AfterNavigate",
|
|
24
25
|
"Page",
|
|
25
26
|
"ParamMatcher",
|
|
@@ -96,6 +97,7 @@
|
|
|
96
97
|
"preloadData",
|
|
97
98
|
"preloadCode",
|
|
98
99
|
"beforeNavigate",
|
|
100
|
+
"onNavigate",
|
|
99
101
|
"afterNavigate",
|
|
100
102
|
"getStores",
|
|
101
103
|
"page",
|
|
@@ -134,5 +136,5 @@
|
|
|
134
136
|
null,
|
|
135
137
|
null
|
|
136
138
|
],
|
|
137
|
-
"mappings": ";;;;;;;;;kBA6BiBA,OAAOA;;;;;;;;;;;;;;;;;;;;;;aAsBZC,iBAAiBA;;;;;aAKjBC,cAAcA;;;;;;;;;;;;;;;;;;;;;;;kBAuBTC,OAAOA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAuFPC,MAAMA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBA6BNC,OAAOA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAiDPC,SAASA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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