import type { Dict, EmptyObjectPatch } from 'tslang'; import type { HistoryChangeCallbackRemovalHandler, HistorySnapshot, IHistory } from './history'; import { RouteBuilder } from './route-builder'; import type { RouteMatchShared, RouteMatchSharedToParamDict } from './route-match'; import { NextRouteMatch, RouteMatch } from './route-match'; import type { RootRouteSchema } from './schema'; export type SegmentMatcherCallback = (key: string) => string; type RouteQuerySchemaType = TRouteSchema extends { $query: infer TQuerySchema; } ? TQuerySchema : {}; type FilterRouteMatchNonStringSegment = TRouteSchema extends { $match: infer TMatch; } ? TMatch extends string ? never : T : never; interface RouteSchemaChildrenSection { $children: TRouteSchemaDict; } type NestedRouteSchemaDictType = TRouteSchema extends RouteSchemaChildrenSection ? TNestedRouteSchemaDict : {}; interface RouteSchemaExtensionSection { $extension: TRouteMatchExtension; } interface RouteSchemaMetadataSection { $metadata: TMetadata; } type RouteMatchMetadataType = TRouteSchema extends RouteSchemaMetadataSection ? TMetadata & TUpperMetadata : TUpperMetadata; type RouteMatchExtensionType = TRouteSchema extends RouteSchemaExtensionSection ? TRouteMatchExtension : {}; type RouteMatchSegmentType = { [K in Extract]: RouteMatchType, TQueryKey | Extract, string>, TSpecificGroupName, TGroupName, TMetadata>; }; type __RouteMatchType, TMetadata extends object> = RouteMatch, TSpecificGroupName, TGroupName, RouteMatchMetadataType> & RouteMatchSegmentType, TSegmentKey, TQueryKey, TSpecificGroupName, TGroupName, RouteMatchMetadataType> & RouteMatchExtensionType; export type RouteMatchType = __RouteMatchType & Record, TMetadata>; type NextRouteMatchSegmentType = { [K in Extract]: NextRouteMatchType, TQueryKey | Extract, string>, TSpecificGroupName, TGroupName, TMetadata>; }; type __NextRouteMatchType, TMetadata extends object> = NextRouteMatch> & NextRouteMatchSegmentType, TSegmentKey, TQueryKey, TSpecificGroupName, TGroupName, RouteMatchMetadataType>; type NextRouteMatchType = __NextRouteMatchType & Record, TMetadata>; export type RootRouteMatchType = RouteMatchType, string>, TSpecificGroupName, TGroupName, TMetadata>; export type RouterOnLeave = (path: string) => void; export type RouterOnNavigateComplete = () => void; export interface RouterHistoryEntryData { navigateCompleteListener?: RouterOnNavigateComplete; } export interface RouterOptions { readOnly?: boolean; /** * Start listen automatically, defaults to true unless `readOnly` is true. */ listen?: boolean; /** * A function to perform default schema field name to segment string * transformation. */ segmentMatcher?: SegmentMatcherCallback; } export interface RouterNavigateOptions { /** * The callback that will be called after a route completed (after all the hooks). */ onComplete?: RouterOnNavigateComplete; } export type RouterHistory = IHistory; export type RouterHistorySnapshot = HistorySnapshot; export declare class Router { readonly $readOnly: boolean; constructor(history: RouterHistory, { readOnly, listen, segmentMatcher, }?: RouterOptions); get $routing(): boolean; get $snapshot(): RouterHistorySnapshot | undefined; get $nextSnapshot(): RouterHistorySnapshot | undefined; get $current(): RouteBuilder; get $next(): RouteBuilder; get $groups(): TGroupName[]; $route(schema: TPrimaryRouteSchema): RootRouteMatchType; $route(group: TSpecificGroupName, schema: TRouteSchema): RootRouteMatchType; $listen(): HistoryChangeCallbackRemovalHandler; $ref(): string; $href(): string; $(route: TRouteMatchShared, params?: Partial> & EmptyObjectPatch): RouteBuilder; $(part: string): RouteBuilder; $scratch(): RouteBuilder; $push(ref: string, options?: RouterNavigateOptions): void; $replace(ref: string, options?: RouterNavigateOptions): void; } export {};