UNPKG

router-primitives

Version:

A cross-platform application router. Declarative routing by way of layout primitives

34 lines (33 loc) 3.85 kB
import { TracerSession } from '../tracer'; import { ActionWraperFnDecorator, IInputLocation, ILocationActionContext, IRouterCreationInfo, IRouterConfig, IRouterDeclaration, IRouterInitArgs, NarrowRouterTypeName, Root, ManagerRouterTypes, IManagerInit, IRouterTemplates, RouterInstance, AllTemplates, RouterCurrentStateFromTemplates, RouterCustomStateFromTemplates, IRouterActionOptions } from '../types'; import { IRouterCache } from './router_cache'; export interface IManager<CustomTemplates extends IRouterTemplates<unknown> = null> { actionFnDecorator?: ActionWraperFnDecorator<CustomTemplates, any>; tracerSession: TracerSession; rootRouter: Root<CustomTemplates>; serializedStateStore: IManagerInit<CustomTemplates>['serializedStateStore']; routerStateStore: IManagerInit<CustomTemplates>['routerStateStore']; routerTypes: ManagerRouterTypes<CustomTemplates>; templates: AllTemplates<CustomTemplates>; routers: Record<string, RouterInstance<CustomTemplates>>; routerCache: IRouterCache<RouterCustomStateFromTemplates<AllTemplates<CustomTemplates>>>; actionCount: number; cacheKey: string; removeCacheAfterRehydration: boolean; errorWhenMissingData: boolean; incrementActionCount: () => void; addRouters: (router: IRouterDeclaration<AllTemplates<CustomTemplates>>, type: NarrowRouterTypeName<keyof AllTemplates<CustomTemplates>>, parentName: string) => void; addRouter: (routerDeclaration: IRouterDeclaration<AllTemplates<CustomTemplates>>) => void; removeRouter: (name: string) => void; registerRouter: (name: string, router: RouterInstance<CustomTemplates>) => void; unregisterRouter: (name: string) => void; linkTo: (routerName: string, actionName: string, actionArgs?: Omit<IRouterActionOptions<RouterCustomStateFromTemplates<AllTemplates<CustomTemplates>>>, 'dryRun'>) => string; calcNewRouterState: <Name extends NarrowRouterTypeName<keyof AllTemplates<CustomTemplates>>>(location: IInputLocation, router: RouterInstance<CustomTemplates, Name>, ctx: Omit<ILocationActionContext<CustomTemplates, Name>, 'actionName'>, newState: Record<string, RouterCurrentStateFromTemplates<AllTemplates<CustomTemplates>>>) => Record<string, RouterCurrentStateFromTemplates<AllTemplates<CustomTemplates>>>; createRouterConfigArgs: <Name extends NarrowRouterTypeName<keyof AllTemplates<CustomTemplates>>>(routerDeclaration: IRouterDeclaration<AllTemplates<CustomTemplates>>, routerType: Name, parent: RouterInstance<CustomTemplates, Name>) => IRouterConfig<RouterCustomStateFromTemplates<AllTemplates<CustomTemplates>>>; validateNeighborsOfOtherTypesArentPathRouters: <Name extends NarrowRouterTypeName<keyof AllTemplates<CustomTemplates>>>(router: RouterInstance<CustomTemplates, Name>) => void; validateRouterCreationInfo: <Name extends NarrowRouterTypeName<keyof AllTemplates<CustomTemplates>>>(name: string, type: Name, config: IRouterConfig<RouterCustomStateFromTemplates<AllTemplates<CustomTemplates>>>) => void; createNewRouterInitArgs: <Name extends NarrowRouterTypeName<keyof AllTemplates<CustomTemplates>>>({ name, config, type, parentName }: IRouterCreationInfo<CustomTemplates, NarrowRouterTypeName<Name>>) => IRouterInitArgs<CustomTemplates, NarrowRouterTypeName<Name>>; createRouterFromInitArgs: <Name extends NarrowRouterTypeName<keyof AllTemplates<CustomTemplates>>>(initalArgs: IRouterInitArgs<CustomTemplates, NarrowRouterTypeName<Name>>) => RouterInstance<CustomTemplates, NarrowRouterTypeName<Name>>; setNewRouterState: (location: IInputLocation) => void; createRouter: <Name extends NarrowRouterTypeName<keyof AllTemplates<CustomTemplates>>>({ name, config, type, parentName }: IRouterCreationInfo<CustomTemplates, NarrowRouterTypeName<Name>>) => RouterInstance<CustomTemplates, Name>; }