import type React from 'react'; import type { PlatformIcon, PlatformIconIOS } from 'react-native-screens'; export interface RouteConfig { component?: React.ComponentType; layout?: React.ComponentType<{ children: React.ReactNode; }>; navigator?: 'stack' | 'tabs'; children?: Record; /** Route metadata */ meta?: Record; /** Route guard */ guard?: () => boolean | Promise; /** Redirect path when guard fails */ guardRedirect?: string; /** Tab-specific options */ tabOptions?: { title?: string; icon?: PlatformIcon; selectedIcon?: PlatformIconIOS; badgeValue?: string; }; /** Custom tab bar renderer — replaces the native tab bar when provided */ customTabBar?: (props: TabBarRenderProps) => React.ReactNode; } export interface StackEntry { key: string; routeName: string; path: string; params: Record; nestedState?: NavigatorState; } export interface StackState { type: 'stack'; entries: StackEntry[]; } export interface TabEntry { key: string; path: string; params: Record; rendered: boolean; nestedState?: NavigatorState; tabOptions?: RouteConfig['tabOptions']; } export interface TabState { type: 'tabs'; activeKey: string; tabs: Record; } export type NavigatorState = StackState | TabState; export interface TabBarRenderProps { state: TabState; onTabPress: (tabKey: string) => void; } export interface RouterInstance { config: TConfig; /** Flattened route patterns for matching */ patterns: RoutePattern[]; } export interface RoutePattern { /** e.g. '/profile' */ path: string; segments: string[]; paramNames: string[]; routeName: string; routeConfig: RouteConfig; /** Path through navigators to reach this route */ navigatorPath: NavigatorSegment[]; } export interface NavigatorSegment { name: string; type: 'stack' | 'tabs'; childName: string; } export type Action = { type: 'NAVIGATE'; path: string; } | { type: 'REPLACE'; path: string; } | { type: 'GO_BACK'; } | { type: 'DISMISS'; key: string; } | { type: 'SWITCH_TAB'; tabKey: string; }; export interface Route { key: string; path: string; name: string; params?: Record; query?: Record; } export interface RouterContextValue { router: RouterInstance; state: NavigatorState; path: string; navigate: NavigateFn; goBack: GoBackFn; replace: ReplaceFn; } export interface ScreenContextValue { route: Route; params: Record; query: Record; meta?: Record; isFocused: boolean; } export type NavigationEventType = 'focus' | 'blur' | 'beforeNavigate' | 'afterNavigate'; export type NavigationListener = (event: { type: NavigationEventType; route?: Route; }) => void; /** * Users augment this interface to register their router for type inference: * * ```ts * declare module 'blaze-navigation' { * interface Register { * router: typeof router; * } * } * ``` */ export interface Register { } /** Extract router type from Register */ export type RegisteredRouter = Register extends { router: infer R; } ? R : RouterInstance; /** Helper: join path segments */ type JoinPath = A extends '' ? `/${B}` : `${A}/${B}`; /** Extract all paths from a route config tree */ export type ExtractPaths, Prefix extends string = ''> = { [K in keyof T & string]: JoinPath | (T[K] extends { children: infer C extends Record; } ? ExtractPaths> : never); }[keyof T & string]; /** Replace $param segments with string values */ export type ReplaceParams = T extends `${infer Before}/$${infer _Param}/${infer After}` ? `${Before}/${string}/${ReplaceParams}` : T extends `${infer Before}/$${infer _Param}` ? `${Before}/${string}` : T; /** Get all valid href paths from registered router */ export type ValidPaths = Register extends { router: { config: { children: infer C extends Record; }; }; } ? ReplaceParams> : string; export type NavigateFn = (path: ValidPaths) => void; export type ReplaceFn = (path: ValidPaths) => void; export type GoBackFn = () => void; /** Extract params from a path pattern */ export type ExtractParams = T extends `${infer _}/$${infer Param}/${infer Rest}` ? { [K in Param | keyof ExtractParams]: string; } : T extends `${infer _}/$${infer Param}` ? { [K in Param]: string; } : Record; export {}; //# sourceMappingURL=types.d.ts.map