File size: 816 Bytes
ec3efd7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import { client } from '../client/singletons.js';

/**
 * @param {string} name
 */
function guard(name) {
	return () => {
		throw new Error(`Cannot call ${name}(...) on the server`);
	};
}

const ssr = import.meta.env.SSR;

const disableScrollHandling = ssr
	? guard('disableScrollHandling')
	: client.disable_scroll_handling;
const goto = ssr ? guard('goto') : client.goto;
const invalidate = ssr ? guard('invalidate') : client.invalidate;
const prefetch = ssr ? guard('prefetch') : client.prefetch;
const prefetchRoutes = ssr ? guard('prefetchRoutes') : client.prefetch_routes;
const beforeNavigate = ssr ? () => {} : client.before_navigate;
const afterNavigate = ssr ? () => {} : client.after_navigate;

export { afterNavigate, beforeNavigate, disableScrollHandling, goto, invalidate, prefetch, prefetchRoutes };