@@ -320,8 +320,10 @@ export async function start(_app, _target, hydrate) {
320320 if ( hydrate ) {
321321 await _hydrate ( target , hydrate ) ;
322322 } 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
325327 } ) ;
326328 }
327329
@@ -479,20 +481,22 @@ function initialize(result, target, hydrate) {
479481
480482 restore_snapshot ( current_navigation_index ) ;
481483
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+ } ;
494497
495- after_navigate_callbacks . forEach ( ( fn ) => fn ( navigation ) ) ;
498+ after_navigate_callbacks . forEach ( ( fn ) => fn ( navigation ) ) ;
499+ }
496500
497501 started = true ;
498502}
@@ -1373,7 +1377,7 @@ function _before_navigate({ url, type, intent, delta }) {
13731377
13741378/**
13751379 * @param {{
1376- * type: import('@sveltejs /kit').Navigation["type"] ;
1380+ * type: import('@sveltejs /kit').NavigationType ;
13771381 * url: URL;
13781382 * popped?: {
13791383 * state: Record<string, any>;
@@ -1407,7 +1411,10 @@ async function navigate({
14071411 token = nav_token ;
14081412
14091413 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 } ) ;
14111418
14121419 if ( ! nav ) {
14131420 block ( ) ;
@@ -1423,7 +1430,7 @@ async function navigate({
14231430
14241431 is_navigating = true ;
14251432
1426- if ( started ) {
1433+ if ( started && nav . navigation . type !== 'enter' ) {
14271434 stores . navigating . set ( ( navigating . current = nav . navigation ) ) ;
14281435 }
14291436
@@ -2847,10 +2854,11 @@ function reset_focus() {
28472854}
28482855
28492856/**
2857+ * @template {import('@sveltejs/kit').NavigationType } T
28502858 * @param {import('./types.js').NavigationState } current
28512859 * @param {import('./types.js').NavigationIntent | undefined } intent
28522860 * @param {URL | null } url
2853- * @param {Exclude<import('@sveltejs/kit').NavigationType, 'enter'> } type
2861+ * @param {T } type
28542862 */
28552863function create_navigation ( current , intent , url , type ) {
28562864 /** @type {(value: any) => void } */
@@ -2867,7 +2875,7 @@ function create_navigation(current, intent, url, type) {
28672875 // Handle any errors off-chain so that it doesn't show up as an unhandled rejection
28682876 complete . catch ( ( ) => { } ) ;
28692877
2870- /** @type {import('@sveltejs/kit').Navigation } */
2878+ /** @type {Omit< import('@sveltejs/kit').Navigation, 'type'> & { type: T } } */
28712879 const navigation = {
28722880 from : {
28732881 params : current . params ,
0 commit comments