import { TrailingSlashMode , QueryParamsMode , QueryParamsOptions , RouteNode , RouteNodeState , URLParamsEncodingType } from 'route-node' ; import { State , SimpleState , Params , DoneFn , NavigationOptions , Unsubscribe , CancelFn } from './base' ; export interface Route < Dependencies extends DefaultDependencies = DefaultDependencies > { name : string ; path : string ; canActivate ? : ActivationFnFactory < Dependencies > ; forwardTo ? : string ; children ? : Array < Route < Dependencies > > ; encodeParams ? ( stateParams ) : Params ; decodeParams ? ( pathParams ) : Params ; defaultParams ? : Params ; } export interface Options { defaultRoute ? : string ; defaultParams ? : Params ; strictTrailingSlash : boolean ; trailingSlashMode : TrailingSlashMode ; queryParamsMode : QueryParamsMode ; autoCleanUp : boolean ; allowNotFound : boolean ; strongMatching : boolean ; rewritePathOnMatch : boolean ; queryParams ? : QueryParamsOptions ; caseSensitive : boolean ; urlParamsEncoding ? : URLParamsEncodingType ; } export type ActivationFn = ( toState : State , fromState : State , done : DoneFn ) => boolean | Promise < boolean > | void ; export type ActivationFnFactory < Dependencies extends DefaultDependencies = DefaultDependencies > = ( router : Router , dependencies ? : Dependencies ) => ActivationFn ; export type DefaultDependencies = Record < string , any > ; export interface Config { decoders : Record < string , any > ; encoders : Record < string , any > ; defaultParams : Record < string , any > ; forwardMap : Record < string , any > ; } export interface Router < Dependencies extends DefaultDependencies = DefaultDependencies > { config : Config ; rootNode : RouteNode ; add ( routes , finalSort ? ) : Router < Dependencies > ; addNode ( name , path , canActivateHandler ? ) : Router < Dependencies > ; isActive ( name , params ? , strictEquality ? , ignoreQueryParams ? ) : boolean ; buildPath ( route , params ? ) : string ; matchPath ( path , source ? ) : State | null ; setRootPath ( rootPath ) : void ; getOptions ( ) : Options ; setOption ( option , value ) : Router < Dependencies > ; makeState ( name , params ? , path ? , meta ? , forceId ? ) : State ; makeNotFoundState ( path , options ? ) : State ; getState ( ) : State ; setState ( state ) : void ; areStatesEqual ( state1 , state2 , ignoreQueryParams ? ) : boolean ; areStatesDescendants ( parentState , childState ) : boolean ; forwardState ( routeName , routeParams ) : SimpleState ; buildState ( routeName , routeParams ) : RouteNodeState | null ; isStarted ( ) : boolean ; start ( startPathOrState , done ? ) : Router < Dependencies > ; start ( done ? ) : Router < Dependencies > ; stop ( ) : void ; canDeactivate ( name , canDeactivateHandler ) : Router < Dependencies > ; clearCanDeactivate ( name ) : Router ; canActivate ( name , canActivateHandler ) : Router < Dependencies > ; getLifecycleFactories ( ) : [ { [ key ] : ActivationFnFactory < Dependencies > ; } , { [ key ] : ActivationFnFactory < Dependencies > ; } ] ; getLifecycleFunctions ( ) : [ { [ key ] : ActivationFn ; } , { [ key ] : ActivationFn ; } ] ; usePlugin ( ... plugins ) : Unsubscribe ; addPlugin ( plugin ) : Router < Dependencies > ; getPlugins ( ) : Array < PluginFactory < Dependencies > > ; useMiddleware ( ... middlewares ) : Unsubscribe ; clearMiddleware ( ) : Router ; getMiddlewareFactories : ( ) => Array < MiddlewareFactory < Dependencies > > ; getMiddlewareFunctions : ( ) => Middleware [ ] ; setDependency ( dependencyName , dependency ) : Router ; setDependencies ( deps ) : Router ; getDependencies ( ) : Dependencies ; getInjectables ( ) : [ Router < Dependencies > , Dependencies ] ; executeFactory ( factory ) : any ; invokeEventListeners : ( eventName , ... args ) => void ; removeEventListener : ( eventName , cb ) => void ; addEventListener : ( eventName , cb ) => Unsubscribe ; cancel ( ) : Router < Dependencies > ; forward ( fromRoute , toRoute ) : Router < Dependencies > ; navigate ( routeName , routeParams , options , done ? ) : CancelFn ; navigate ( routeName , routeParams , done ? ) : CancelFn ; navigate ( routeName , done ? ) : CancelFn ; navigateToDefault ( opts , done ? ) : CancelFn ; navigateToDefault ( done ? ) : CancelFn ; transitionToState ( toState , fromState , opts , done ) ; subscribe ( listener ) : Unsubscribe | Subscription ; } export interface Plugin { onStart ? ( ) : void ; onStop ? ( ) : void ; onTransitionStart ? ( toState ? , fromState ? ) : void ; onTransitionCancel ? ( toState ? , fromState ? ) : void ; onTransitionError ? ( toState ? , fromState ? , err ? ) : void ; onTransitionSuccess ? ( toState ? , fromState ? , opts ? ) : void ; teardown ? ( ) : void ; } export type Middleware = ( toState : State , fromState : State , done : DoneFn ) => boolean | Promise < any > | void ; export type MiddlewareFactory < Dependencies extends DefaultDependencies = DefaultDependencies > = ( router : Router , dependencies : Dependencies ) => Middleware ; export type PluginFactory < Dependencies extends DefaultDependencies = DefaultDependencies > = ( router ? : Router , dependencies ? : Dependencies ) => Plugin ; export interface SubscribeState { route : State ; previousRoute : State ; } export type SubscribeFn = ( state : SubscribeState ) => void ; export interface Listener { next : ( val : any ) => { } ; [ key ] : any ; } export interface Subscription { unsubscribe : Unsubscribe ; }