UNPKG

@nimel/directorr-router

Version:
57 lines (56 loc) 1.63 kB
import { Location as LocationHistory, History as HistoryType } from 'history'; import { ParsedQuery } from 'query-string'; export declare const ACTION: { POP: 'POP'; PUSH: 'PUSH'; REPLACE: 'REPLACE'; }; export interface Params { [key: string]: string | number; } export declare type QueryObject = ParsedQuery; export declare type Action = keyof typeof ACTION; export declare type Location = LocationHistory; export declare type LocationState = Record<string, any> | null; export declare type Blocker = (...args: any[]) => any; export declare type History = HistoryType; export interface HistoryRouterTask { location: Location; action: Action; } export declare type HistoryRouterHandler = (rt: HistoryRouterTask) => void; export interface HistoryActionPayload { path: string; queryObject: QueryObject; state?: LocationState; action: Action; pattern?: string; } export interface HistoryChangeActionPayload extends HistoryActionPayload { match: boolean; } export interface RouterActionPayload { path: string; queryObject?: QueryObject; state?: LocationState; pattern?: string; } export interface RouterGoToActionPayload { index: number; } export interface RouterBlockActionPayload { blocker: Blocker; } export declare type BlockState = [Blocker, () => void]; export interface Options { exact?: boolean; strict?: boolean; } export interface RouterIsPatternActionPayload { pattern: string; store?: any; } export interface RouterIsPatternSuccessActionPayload extends RouterIsPatternActionPayload { path: string; queryObject: QueryObject; }