Urara-Blog/node_modules/.pnpm-store/v3/files/b5/244ff046ce407aee492e1b64458030500c9316aa35a3156bbaee2494c6912e6cb245205e2a0933f3fa5adea8535e6e5b83d1d8ef457a808a9e2c1eac18bdbd
2022-08-14 01:14:53 +08:00

24 lines
816 B
Text

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 };