/* IMPORT */ import type { JSX } from 'woby' import type { FunctionMaybe, Observable, ObservableReadonly, Resource } from 'woby' /* HELPERS */ type F = FunctionMaybe type O = Observable type OR = ObservableReadonly /* MAIN */ type RouterBackend = 'hash' | 'memory' | 'path' type RouterLoader = (ctx: RouterLoaderContext) => Promise type RouterLoaderContext = { pathname: RouterPath, search: string, hash: string, params: RouterParams, searchParams: URLSearchParams, route: RouterRoute } type RouterLocation = { pathname: OR, search: OR, hash: OR } type RouterNavigate = (path: RouterPath, options?: RouterNavigateOptions) => void type RouterNavigateOptions = { replace?: boolean, state?: any } type RouterParams = Record type RouterPath = `/${string}` type RouterRoute = { path: string, to: JSX.Child, loader?: RouterLoader, children?: RouterRoute[] } type RouterRouter = { route(path: string): { params: RouterParams, route: RouterRoute } | undefined } type RouterState = { pathname: OR, search: OR, hash: OR, navigate: RouterNavigate, params: OR, searchParams: OR, route: OR, loader: OR> } /* EXPORT */ export type { F, O, OR, Resource } export type { RouterBackend, RouterLoader, RouterLoaderContext, RouterLocation, RouterNavigate, RouterNavigateOptions, RouterParams, RouterPath, RouterRoute, RouterRouter, RouterState }