import type FSNetwork from '@brandingbrand/fsnetwork' ; import type { Analytics } from '@brandingbrand/fsengage' ; import type { Dictionary } from '@brandingbrand/fsfoundation' ; import type { OptionsBottomTab , OptionsStatusBar , OptionsTopBar , OptionsTopBarButton , OptionsTopBarTitle } from 'react-native-navigation' ; import type { ParsedQs } from 'qs' ; import type { ShellConfig } from '../shell.web' ; import { Component , ComponentType , FC } from 'react' ; export type ActionButton = OptionsTopBarButton & { onPress ? : ( ) => void ; } ; export interface ScreenOptions { buttons ? : { rightButtons ? : ActionButton [ ] ; leftButtons ? : ActionButton [ ] ; } ; } note see useNavigator see useActivatedRoute see useRouteParams see useRouteQuery see useRouteData export type ScreenFC = FC < { componentId : string ; } > & ScreenOptions ; export abstract class ScreenComponent < State = { } > extends Component < { componentId : string ; } , State > { static buttons ? : ScreenOptions [ 'buttons' ] ; } export type ScreenComponentType = ScreenFC | typeof ScreenComponent ; export type Tab = ( OptionsBottomTab & { id : string ; } ) ; export type RouteData = Dictionary < unknown | undefined > ; export type RouteParams = Dictionary < string | undefined > ; export type RouteQuery = ParsedQs ; export interface ActivatedRoute { readonly path : string | undefined ; readonly loading : boolean ; readonly data : RouteData ; readonly params : RouteParams ; readonly query : RouteQuery ; } export interface Resolver < Data = unknown > { resolve ( ) : Data | Promise < Data > ; } export type ResolverConstructor < Data = unknown > = new ( route ) => Resolver < Data > ; export type ResolverFunction < Data = unknown > = ( route : ActivatedRoute ) => Data | Promise < Data > ; export interface Activator { activate ( ) : boolean | Promise < boolean > ; } export type ActivatorConstructor = new ( route ) => Activator ; export type ActivatorFunction = ( route : Pick < ActivatedRoute , 'params' | 'query' | 'path' > ) => boolean | Promise < boolean > ; export interface BaseRoute { readonly path ? : string ; readonly exact ? : true ; readonly quickDevMenu ? : true ; readonly canActivate ? : ActivatorConstructor | ActivatorFunction ; } export type TopBarStyle = Omit < OptionsTopBar , 'title' > & { title ? : Omit < OptionsTopBarTitle , 'text' > ; leftButtons ? : never ; rightButtons ? : never ; } ; export interface ComponentRoute extends BaseRoute { readonly component : ScreenComponentType ; readonly title ? : string | ( ( activatedRoute : ActivatedRoute ) => string | Promise < string > ) ; readonly topBarStyle ? : TopBarStyle ; readonly statusBarStyle ? : OptionsStatusBar ; readonly data ? : RouteData ; readonly resolve ? : Dictionary < ResolverConstructor | ResolverFunction > ; readonly disableTracking ? : true ; } export interface LazyComponentRoute extends Omit < ComponentRoute , 'component' > { readonly loadComponent : ( activatedRoute : ActivatedRoute ) => Promise < ScreenComponentType > ; } export interface ParentRoute extends BaseRoute { readonly children : Route [ ] ; } param { Exclude < string , '' > } initialPath param { Tab } tab param { Route [ ] } children export interface RouteCollection { readonly initialPath : Exclude < string , '' > ; readonly tab : Tab ; readonly children : Route [ ] ; readonly topBarStyle ? : TopBarStyle ; readonly statusBarStyle ? : OptionsStatusBar ; } export interface RedirectRoute extends BaseRoute { readonly redirect : ( ( route : Pick < ActivatedRoute , 'params' | 'query' | 'path' > ) => string ) | string ; } description see ComponentRoute see LazyComponentRoute see ParentRoute see RedirectRoute example note example export type Route = ComponentRoute | LazyComponentRoute | RedirectRoute | ParentRoute ; see Route export type Routes = readonly ( Route | RouteCollection ) [ ] ; export type ExternalRoute = Route & { readonly tabAffinity ? : string ; } ; export type ExternalRoutes = readonly ExternalRoute [ ] ; /**
 * Routes that will be loaded asynchronously at the start of
 * the application
 */ export type ExternalRouteFactory = Promise < ExternalRoutes > | ( ( api ? : FSNetwork ) => Routes | Promise < ExternalRoutes > ) ; export type IndexedComponentRoute = ( ComponentRoute & { readonly id : string ; } ) | ( LazyComponentRoute & { readonly id : string ; } ) ; export type MatchingRoute = IndexedComponentRoute & { readonly params : RouteParams ; readonly query : RouteQuery ; readonly matchedPath : string ; readonly tabAffinity ? : string ; } ; export interface RouterConfig { readonly routes : Routes ; readonly externalRoutes ? : ExternalRouteFactory ; readonly loading ? : JSX . Element ; } export interface InternalRouterConfig { readonly api ? : FSNetwork ; readonly analytics ? : Analytics ; readonly screenWrap ? : ComponentType ; readonly shell ? : ShellConfig ; } export interface FSRouter { readonly routes : Routes ; open ( url ) : Promise < void > ; } export interface FSRouterConstructor < T extends FSRouter = FSRouter > { new ( routes , options ) : T ; register ( options ) : Promise < FSRouter > ; }