@tempots/ui
Version:
Provides a higher level of renderables to help fast development with Tempo.
46 lines (45 loc) • 1.33 kB
TypeScript
import { ExtractParams, Route } from './route-info';
/**
* The result of a route match.
*
* @public
*/
export type MatchResult<P extends string> = {
params: ExtractParams<P>;
path: P;
} | null;
/**
* The result of a route match with the matched route.
*
* @public
*/
export type MatchResultWithRoute<P extends string, R extends string> = {
params: ExtractParams<P>;
route: R;
path: P;
} | null;
/**
* Matches a path against a route.
*
* @param route - The route to match against.
* @param path - The path to match.
* @returns The match result.
* @public
*/
export declare const matchesRoute: <P extends string>(route: Route, path: P) => MatchResult<P>;
/**
* Parses a route string into an array of route segments.
*
* @param route - The route string to parse.
* @returns An array of route segments.
* @internal
*/
export declare const _parseRouteSegments: (route: string) => Route;
/**
* Creates a route matcher function that can be used to match paths against a list of routes.
*
* @param routes - An array of route strings.
* @returns A function that can be used to match paths against the provided routes.
* @internal
*/
export declare const _makeRouteMatcher: <Routes extends string[]>(routes: Routes) => <S extends string>(path: S) => MatchResultWithRoute<S, Routes[number]>;