UNPKG

one

Version:

One is a new React Framework that makes Vite serve both native and web.

32 lines (24 loc) 686 B
import { getPathFromState } from '../fork/getPathFromState' import { getStateFromPath } from '../fork/getStateFromPath' export function getInitialURL(): string { if (typeof window === 'undefined') { return '' } return window.location?.href || '' } export function getRootURL(): string { return '/' } export function addEventListener(listener: (url: string) => void) { if (typeof window === 'undefined') { return () => {} } const callback = () => { listener(window.location.href) } window.addEventListener('popstate', callback) return () => { window.removeEventListener('popstate', callback) } } export { getStateFromPath, getPathFromState }