(_app, _target, hydrate)
| 273 | * @param {Parameters<typeof _hydrate>[1]} [hydrate] |
| 274 | */ |
| 275 | export async function start(_app, _target, hydrate) { |
| 276 | if (DEV && _target === document.body) { |
| 277 | console.warn( |
| 278 | 'Placing %sveltekit.body% directly inside <body> is not recommended, as your app may break for users who have certain browser extensions installed.\n\nConsider wrapping it in an element:\n\n<div style="display: contents">\n %sveltekit.body%\n</div>' |
| 279 | ); |
| 280 | } |
| 281 | |
| 282 | // detect basic auth credentials in the current URL |
| 283 | // https://github.com/sveltejs/kit/pull/11179 |
| 284 | // if so, refresh the page without credentials |
| 285 | if (document.URL !== location.href) { |
| 286 | // eslint-disable-next-line no-self-assign |
| 287 | location.href = location.href; |
| 288 | } |
| 289 | |
| 290 | app = _app; |
| 291 | |
| 292 | await _app.hooks.init?.(); |
| 293 | |
| 294 | routes = __SVELTEKIT_CLIENT_ROUTING__ ? parse(_app) : []; |
| 295 | container = __SVELTEKIT_EMBEDDED__ ? _target : document.documentElement; |
| 296 | target = _target; |
| 297 | |
| 298 | // we import the root layout/error nodes eagerly, so that |
| 299 | // connectivity errors after initialisation don't nuke the app |
| 300 | default_layout_loader = _app.nodes[0]; |
| 301 | default_error_loader = _app.nodes[1]; |
| 302 | void default_layout_loader(); |
| 303 | void default_error_loader(); |
| 304 | |
| 305 | current_history_index = history.state?.[HISTORY_INDEX]; |
| 306 | current_navigation_index = history.state?.[NAVIGATION_INDEX]; |
| 307 | |
| 308 | if (!current_history_index) { |
| 309 | // we use Date.now() as an offset so that cross-document navigations |
| 310 | // within the app don't result in data loss |
| 311 | current_history_index = current_navigation_index = Date.now(); |
| 312 | |
| 313 | // create initial history entry, so we can return here |
| 314 | history.replaceState( |
| 315 | { |
| 316 | ...history.state, |
| 317 | [HISTORY_INDEX]: current_history_index, |
| 318 | [NAVIGATION_INDEX]: current_navigation_index |
| 319 | }, |
| 320 | '' |
| 321 | ); |
| 322 | } |
| 323 | |
| 324 | // if we reload the page, or Cmd-Shift-T back to it, |
| 325 | // recover scroll position |
| 326 | const scroll = scroll_positions[current_history_index]; |
| 327 | function restore_scroll() { |
| 328 | if (scroll) { |
| 329 | history.scrollRestoration = 'manual'; |
| 330 | scrollTo(scroll.x, scroll.y); |
| 331 | } |
| 332 | } |
nothing calls this directly
no test coverage detected