@@ -320,8 +320,10 @@ export async function start(_app, _target, hydrate) {
320
320
if ( hydrate ) {
321
321
await _hydrate ( target , hydrate ) ;
322
322
} else {
323
- await goto ( app . hash ? decode_hash ( new URL ( location . href ) ) : location . href , {
324
- replaceState : true
323
+ await navigate ( {
324
+ type : 'enter' ,
325
+ url : resolve_url ( app . hash ? decode_hash ( new URL ( location . href ) ) : location . href ) ,
326
+ replace_state : true
325
327
} ) ;
326
328
}
327
329
@@ -479,20 +481,22 @@ function initialize(result, target, hydrate) {
479
481
480
482
restore_snapshot ( current_navigation_index ) ;
481
483
482
- /** @type {import('@sveltejs/kit').AfterNavigate } */
483
- const navigation = {
484
- from : null ,
485
- to : {
486
- params : current . params ,
487
- route : { id : current . route ?. id ?? null } ,
488
- url : new URL ( location . href )
489
- } ,
490
- willUnload : false ,
491
- type : 'enter' ,
492
- complete : Promise . resolve ( )
493
- } ;
484
+ if ( hydrate ) {
485
+ /** @type {import('@sveltejs/kit').AfterNavigate } */
486
+ const navigation = {
487
+ from : null ,
488
+ to : {
489
+ params : current . params ,
490
+ route : { id : current . route ?. id ?? null } ,
491
+ url : new URL ( location . href )
492
+ } ,
493
+ willUnload : false ,
494
+ type : 'enter' ,
495
+ complete : Promise . resolve ( )
496
+ } ;
494
497
495
- after_navigate_callbacks . forEach ( ( fn ) => fn ( navigation ) ) ;
498
+ after_navigate_callbacks . forEach ( ( fn ) => fn ( navigation ) ) ;
499
+ }
496
500
497
501
started = true ;
498
502
}
@@ -1373,7 +1377,7 @@ function _before_navigate({ url, type, intent, delta }) {
1373
1377
1374
1378
/**
1375
1379
* @param {{
1376
- * type: import('@sveltejs /kit').Navigation["type"] ;
1380
+ * type: import('@sveltejs /kit').NavigationType ;
1377
1381
* url: URL;
1378
1382
* popped?: {
1379
1383
* state: Record<string, any>;
@@ -1407,7 +1411,10 @@ async function navigate({
1407
1411
token = nav_token ;
1408
1412
1409
1413
const intent = await get_navigation_intent ( url , false ) ;
1410
- const nav = _before_navigate ( { url, type, delta : popped ?. delta , intent } ) ;
1414
+ const nav =
1415
+ type === 'enter'
1416
+ ? create_navigation ( current , intent , url , type )
1417
+ : _before_navigate ( { url, type, delta : popped ?. delta , intent } ) ;
1411
1418
1412
1419
if ( ! nav ) {
1413
1420
block ( ) ;
@@ -1423,7 +1430,7 @@ async function navigate({
1423
1430
1424
1431
is_navigating = true ;
1425
1432
1426
- if ( started ) {
1433
+ if ( started && nav . navigation . type !== 'enter' ) {
1427
1434
stores . navigating . set ( ( navigating . current = nav . navigation ) ) ;
1428
1435
}
1429
1436
@@ -2847,10 +2854,11 @@ function reset_focus() {
2847
2854
}
2848
2855
2849
2856
/**
2857
+ * @template {import('@sveltejs/kit').NavigationType } T
2850
2858
* @param {import('./types.js').NavigationState } current
2851
2859
* @param {import('./types.js').NavigationIntent | undefined } intent
2852
2860
* @param {URL | null } url
2853
- * @param {Exclude<import('@sveltejs/kit').NavigationType, 'enter'> } type
2861
+ * @param {T } type
2854
2862
*/
2855
2863
function create_navigation ( current , intent , url , type ) {
2856
2864
/** @type {(value: any) => void } */
@@ -2867,7 +2875,7 @@ function create_navigation(current, intent, url, type) {
2867
2875
// Handle any errors off-chain so that it doesn't show up as an unhandled rejection
2868
2876
complete . catch ( ( ) => { } ) ;
2869
2877
2870
- /** @type {import('@sveltejs/kit').Navigation } */
2878
+ /** @type {Omit< import('@sveltejs/kit').Navigation, 'type'> & { type: T } } */
2871
2879
const navigation = {
2872
2880
from : {
2873
2881
params : current . params ,
0 commit comments