/** * Base for all valid paths type parameters. * * @category Internal */ export type ValidPathsBase = ReadonlyArray; /** * Base for all valid search type parameters. * * @category Internal */ export type ValidSearchBase = Readonly>>; /** * Base for all valid hash type parameters. * * @category Internal */ export type ValidHashBase = string; /** * {@link SpaRoute} but with all properties required. * * @category Main */ export type FullSpaRoute = Required>; /** * A type that contains all route information for a single URL. * * @category Main */ export type SpaRoute = { /** An array of the URL's paths. */ paths: ValidPaths; /** An object of the URL's search params. */ search?: ValidSearch; /** The URL's hash string, excluding the `#` character. */ hash?: ValidHash; }; /** * Detects if the input is a `SpaRoute`. Note that this cannot check for type safety for _your_ * specific route type, use the `sanitizeRoute` constructor param in `SpaRouter` for that purpose. * * @category Internal */ export declare function isSpaRoute(input: unknown): input is SpaRoute; /** * Narrow a route to a specific path. * * @category Main * @example * * ```ts * import {PathTree, FullSpaRoute, SpaRouteByPath} from 'spa-router-vir'; * * const myAppPathTree = new PathTree({ * allowBare: true, * children: { * myRoute: {}, * }, * }); * * export type MyAppFullRoute = Readonly< * FullSpaRoute * >; * * export type MySpecificRoute = Readonly< * SpaRouteByPath * >; * * function handleSpecificRoute( * specificRoute: MySpecificRoute, * ) {} * ``` */ export type SpaRouteByPath, OriginalFullSpaRoute extends Readonly>> = OriginalFullSpaRoute & { paths: Extract>; }; /** * Narrow a path to only the valid children paths of the given path. * * @category Main */ export type ChildPaths = SpaRouteByPath['paths'] extends Readonly<[ ...Paths, ...infer ChildPaths ]> ? Readonly : never;