redux-first-history
Advanced tools
Comparing version 5.1.1 to 5.2.0
import type { Location, Action, History } from 'history'; | ||
import type { AnyAction } from 'redux'; | ||
export declare const CALL_HISTORY_METHOD = "@@router/CALL_HISTORY_METHOD"; | ||
export declare const LOCATION_CHANGE = "@@router/LOCATION_CHANGE"; | ||
export declare type HistoryMethods = 'push' | 'replace' | 'go' | 'goBack' | 'goForward' | 'back' | 'forward'; | ||
export type HistoryMethods = 'push' | 'replace' | 'go' | 'goBack' | 'goForward' | 'back' | 'forward'; | ||
export declare const locationChangeAction: (location: Location, action: Action) => { | ||
@@ -16,3 +17,3 @@ type: "@@router/LOCATION_CHANGE"; | ||
} | ||
export interface CallHistoryMethodAction<A = unknown[]> { | ||
export interface CallHistoryMethodAction<A = unknown[]> extends AnyAction { | ||
type: typeof CALL_HISTORY_METHOD; | ||
@@ -28,2 +29,2 @@ payload: LocationActionPayload<A>; | ||
export declare const forward: () => CallHistoryMethodAction<Parameters<History['forward']>>; | ||
export declare type RouterActions = ReturnType<typeof push> | ReturnType<typeof replace> | ReturnType<typeof go> | ReturnType<typeof goBack> | ReturnType<typeof goForward> | ReturnType<typeof locationChangeAction> | ReturnType<typeof back> | ReturnType<typeof forward>; | ||
export type RouterActions = ReturnType<typeof push> | ReturnType<typeof replace> | ReturnType<typeof go> | ReturnType<typeof goBack> | ReturnType<typeof goForward> | ReturnType<typeof locationChangeAction> | ReturnType<typeof back> | ReturnType<typeof forward>; |
import { History } from 'history'; | ||
import { Middleware } from 'redux'; | ||
declare type CreateRouterMiddlewareArgs = { | ||
type CreateRouterMiddlewareArgs = { | ||
history: History; | ||
@@ -5,0 +5,0 @@ showHistoryAction: boolean; |
@@ -39,2 +39,3 @@ "use strict"; | ||
return function () { | ||
// @ts-ignore | ||
return function (next) { | ||
@@ -45,2 +46,3 @@ return function (action) { | ||
} | ||
// @ts-ignore | ||
var method = action.payload.method; | ||
@@ -47,0 +49,0 @@ // @ts-ignore |
@@ -12,5 +12,5 @@ /** | ||
} | ||
declare type WindowLocation<S = unknown> = Window['location'] & HLocation<S>; | ||
declare type HistoryActionType = 'PUSH' | 'POP'; | ||
declare type HistoryLocation = WindowLocation & { | ||
type WindowLocation<S = unknown> = Window['location'] & HLocation<S>; | ||
type HistoryActionType = 'PUSH' | 'POP'; | ||
type HistoryLocation = WindowLocation & { | ||
state?: any; | ||
@@ -22,4 +22,4 @@ }; | ||
} | ||
declare type HistoryListener = (parameter: HistoryListenerParameter) => void; | ||
declare type HistoryUnsubscribe = () => void; | ||
type HistoryListener = (parameter: HistoryListenerParameter) => void; | ||
type HistoryUnsubscribe = () => void; | ||
interface NavigateOptions<TState> { | ||
@@ -26,0 +26,0 @@ state?: TState | undefined; |
import { Action, Location } from 'history'; | ||
import { Reducer } from 'redux'; | ||
export declare type RouterState = { | ||
export type RouterState = { | ||
location?: Location | null; | ||
@@ -5,0 +5,0 @@ action?: Action | null; |
@@ -40,3 +40,3 @@ "use strict"; | ||
if (type === actions_1.LOCATION_CHANGE) { | ||
var _c = payload || {}, location_1 = _c.location, action = _c.action; | ||
var _c = (payload || {}), location_1 = _c.location, action = _c.action; | ||
var previousLocations = numLocationToTrack // @ts-ignore | ||
@@ -43,0 +43,0 @@ ? __spreadArray([{ location: location_1, action: action }], state.previousLocations.slice(0, numLocationToTrack), true) : undefined; |
import type { Location, Action, History } from 'history'; | ||
import type { AnyAction } from 'redux'; | ||
export declare const CALL_HISTORY_METHOD = "@@router/CALL_HISTORY_METHOD"; | ||
export declare const LOCATION_CHANGE = "@@router/LOCATION_CHANGE"; | ||
export declare type HistoryMethods = 'push' | 'replace' | 'go' | 'goBack' | 'goForward' | 'back' | 'forward'; | ||
export type HistoryMethods = 'push' | 'replace' | 'go' | 'goBack' | 'goForward' | 'back' | 'forward'; | ||
export declare const locationChangeAction: (location: Location, action: Action) => { | ||
@@ -16,3 +17,3 @@ type: "@@router/LOCATION_CHANGE"; | ||
} | ||
export interface CallHistoryMethodAction<A = unknown[]> { | ||
export interface CallHistoryMethodAction<A = unknown[]> extends AnyAction { | ||
type: typeof CALL_HISTORY_METHOD; | ||
@@ -28,2 +29,2 @@ payload: LocationActionPayload<A>; | ||
export declare const forward: () => CallHistoryMethodAction<Parameters<History['forward']>>; | ||
export declare type RouterActions = ReturnType<typeof push> | ReturnType<typeof replace> | ReturnType<typeof go> | ReturnType<typeof goBack> | ReturnType<typeof goForward> | ReturnType<typeof locationChangeAction> | ReturnType<typeof back> | ReturnType<typeof forward>; | ||
export type RouterActions = ReturnType<typeof push> | ReturnType<typeof replace> | ReturnType<typeof go> | ReturnType<typeof goBack> | ReturnType<typeof goForward> | ReturnType<typeof locationChangeAction> | ReturnType<typeof back> | ReturnType<typeof forward>; |
import { History } from 'history'; | ||
import { Middleware } from 'redux'; | ||
declare type CreateRouterMiddlewareArgs = { | ||
type CreateRouterMiddlewareArgs = { | ||
history: History; | ||
@@ -5,0 +5,0 @@ showHistoryAction: boolean; |
@@ -13,6 +13,9 @@ import { CALL_HISTORY_METHOD } from './actions'; | ||
} | ||
export const createRouterMiddleware = ({ history, showHistoryAction, basename }) => () => (next) => (action) => { | ||
export const createRouterMiddleware = ({ history, showHistoryAction, basename }) => () => | ||
// @ts-ignore | ||
(next) => (action) => { | ||
if (action.type !== CALL_HISTORY_METHOD) { | ||
return next(action); | ||
} | ||
// @ts-ignore | ||
const method = action.payload.method; | ||
@@ -19,0 +22,0 @@ // @ts-ignore |
@@ -12,5 +12,5 @@ /** | ||
} | ||
declare type WindowLocation<S = unknown> = Window['location'] & HLocation<S>; | ||
declare type HistoryActionType = 'PUSH' | 'POP'; | ||
declare type HistoryLocation = WindowLocation & { | ||
type WindowLocation<S = unknown> = Window['location'] & HLocation<S>; | ||
type HistoryActionType = 'PUSH' | 'POP'; | ||
type HistoryLocation = WindowLocation & { | ||
state?: any; | ||
@@ -22,4 +22,4 @@ }; | ||
} | ||
declare type HistoryListener = (parameter: HistoryListenerParameter) => void; | ||
declare type HistoryUnsubscribe = () => void; | ||
type HistoryListener = (parameter: HistoryListenerParameter) => void; | ||
type HistoryUnsubscribe = () => void; | ||
interface NavigateOptions<TState> { | ||
@@ -26,0 +26,0 @@ state?: TState | undefined; |
import { Action, Location } from 'history'; | ||
import { Reducer } from 'redux'; | ||
export declare type RouterState = { | ||
export type RouterState = { | ||
location?: Location | null; | ||
@@ -5,0 +5,0 @@ action?: Action | null; |
@@ -14,3 +14,3 @@ import { LOCATION_CHANGE } from './actions'; | ||
if (type === LOCATION_CHANGE) { | ||
const { location, action } = payload || {}; | ||
const { location, action } = (payload || {}); | ||
const previousLocations = numLocationToTrack // @ts-ignore | ||
@@ -17,0 +17,0 @@ ? [{ location, action }, ...state.previousLocations.slice(0, numLocationToTrack)] |
{ | ||
"name": "redux-first-history", | ||
"version": "5.1.1", | ||
"version": "5.2.0", | ||
"description": "Redux First History - Redux history binding support react-router - @reach/router - wouter", | ||
@@ -46,32 +46,34 @@ "main": "build/es5/index.js", | ||
"history": "^4.7.2 || ^5.0", | ||
"redux": "^3.6.0 || ^4.0.0" | ||
"redux": "^3.6.0 || ^4.0.0 || ^5.0.0" | ||
}, | ||
"devDependencies": { | ||
"@reach/router": "^1.3.4", | ||
"@testing-library/react": "^12.1.0", | ||
"@testing-library/react": "^14.1.2", | ||
"@types/history": "^4.7.9", | ||
"@types/jest": "^27.0.2", | ||
"@types/reach__router": "^1.3.10", | ||
"@types/react": "^17.0.24", | ||
"@typescript-eslint/eslint-plugin": "^4.31.2", | ||
"@typescript-eslint/parser": "^4.31.2", | ||
"eslint": "^7.32.0", | ||
"eslint-config-airbnb": "^18.2.1", | ||
"eslint-config-prettier": "^8.3.0", | ||
"eslint-plugin-import": "^2.24.2", | ||
"eslint-plugin-jsx-a11y": "^6.4.1", | ||
"eslint-plugin-prettier": "^4.0.0", | ||
"eslint-plugin-react": "^7.26.0", | ||
"eslint-plugin-react-hooks": "^4.2.0", | ||
"@types/node": "^20.10.4", | ||
"@types/jest": "^29.5.11", | ||
"@types/reach__router": "^1.3.14", | ||
"@types/react": "^18.2.45", | ||
"@typescript-eslint/eslint-plugin": "^6.14.0", | ||
"@typescript-eslint/parser": "^6.14.0", | ||
"eslint": "^8.55.0", | ||
"eslint-config-airbnb": "^19.0.4", | ||
"eslint-config-prettier": "^9.1.0", | ||
"eslint-plugin-import": "^2.29.0", | ||
"eslint-plugin-jsx-a11y": "^6.8.0", | ||
"eslint-plugin-prettier": "^5.0.1", | ||
"eslint-plugin-react": "^7.33.2", | ||
"eslint-plugin-react-hooks": "^4.6.0", | ||
"history": "^4.10.1", | ||
"jest": "^27.2.1", | ||
"prettier": "^2.4.1", | ||
"react": "^17.0.2", | ||
"react-dom": "^17.0.2", | ||
"redux": "^4.1.1", | ||
"rimraf": "^3.0.2", | ||
"ts-jest": "^27.0.5", | ||
"ts-node": "^10.2.1", | ||
"typescript": "^4.3.5" | ||
"jest": "^29.7.0", | ||
"jest-environment-jsdom": "^29.7.0", | ||
"prettier": "^3.1.1", | ||
"react": "^18.2.0", | ||
"react-dom": "^18.2.0", | ||
"redux": "^5.0.0", | ||
"rimraf": "^5.0.5", | ||
"ts-jest": "^29.1.1", | ||
"ts-node": "^10.9.2", | ||
"typescript": "^5.3.3" | ||
} | ||
} |
@@ -163,3 +163,3 @@ # redux-first-history | ||
}), | ||
middleware: [routerMiddleware] | ||
middleware: (getDefaultMiddleware) => getDefaultMiddleware().concat(routerMiddleware), | ||
}); | ||
@@ -166,0 +166,0 @@ |
import type { Location, Action, History } from 'history'; | ||
import type { AnyAction } from 'redux'; | ||
@@ -26,3 +27,3 @@ export const CALL_HISTORY_METHOD = '@@router/CALL_HISTORY_METHOD'; | ||
export interface CallHistoryMethodAction<A = unknown[]> { | ||
export interface CallHistoryMethodAction<A = unknown[]> extends AnyAction { | ||
type: typeof CALL_HISTORY_METHOD; | ||
@@ -29,0 +30,0 @@ payload: LocationActionPayload<A>; |
@@ -29,2 +29,3 @@ /* eslint-disable consistent-return,indent */ | ||
() => | ||
// @ts-ignore | ||
(next: Dispatch) => | ||
@@ -35,2 +36,3 @@ (action: ReduxAction) => { | ||
} | ||
// @ts-ignore | ||
const method = action.payload.method as HistoryMethods; | ||
@@ -37,0 +39,0 @@ // @ts-ignore |
@@ -31,3 +31,6 @@ import { Action, Location } from 'history'; | ||
if (type === LOCATION_CHANGE) { | ||
const { location, action } = payload || {}; | ||
const { location, action } = (payload || {}) as { | ||
location?: Location | null; | ||
action?: Action | null; | ||
}; | ||
const previousLocations = numLocationToTrack // @ts-ignore | ||
@@ -34,0 +37,0 @@ ? [{ location, action }, ...state.previousLocations.slice(0, numLocationToTrack)] |
@@ -24,3 +24,2 @@ { | ||
"traceResolution": false, | ||
"watch": false | ||
}, | ||
@@ -27,0 +26,0 @@ "include": ["./src"], |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
99265
1533
28