Fix more type errors

This commit is contained in:
Nathan Bierema 2021-07-20 23:32:54 -04:00
parent fcfe18c1db
commit 386d7ee786
15 changed files with 203 additions and 97 deletions

View File

@ -16,8 +16,6 @@ import {
CustomAction, CustomAction,
DispatchAction as AppDispatchAction, DispatchAction as AppDispatchAction,
LibConfig, LibConfig,
LiftedActionAction,
StoreAction,
} from '@redux-devtools/app/lib/actions'; } from '@redux-devtools/app/lib/actions';
import { Action, Dispatch } from 'redux'; import { Action, Dispatch } from 'redux';
import { import {
@ -30,6 +28,10 @@ import {
PageScriptToContentScriptMessageWithoutDisconnectOrInitInstance, PageScriptToContentScriptMessageWithoutDisconnectOrInitInstance,
} from '../api'; } from '../api';
import { LiftedState } from '@redux-devtools/instrument'; import { LiftedState } from '@redux-devtools/instrument';
import {
BackgroundAction,
LiftedActionAction,
} from '../stores/backgroundStore';
interface TabMessageBase { interface TabMessageBase {
readonly type: string; readonly type: string;
@ -241,6 +243,7 @@ interface ImportMessage {
readonly id: string | number; readonly id: string | number;
readonly instanceId: string; readonly instanceId: string;
readonly state: string; readonly state: string;
readonly action?: never;
} }
type ToContentScriptMessage = ImportMessage | LiftedActionAction; type ToContentScriptMessage = ImportMessage | LiftedActionAction;
@ -252,7 +255,7 @@ function toContentScript({
instanceId, instanceId,
state, state,
}: ToContentScriptMessage) { }: ToContentScriptMessage) {
connections.tab[id].postMessage({ connections.tab[id!].postMessage({
type: message, type: message,
action, action,
state: nonReduxDispatch(window.store, message, instanceId, action, state), state: nonReduxDispatch(window.store, message, instanceId, action, state),
@ -471,7 +474,7 @@ function onConnect<S, A extends Action<unknown>>(port: chrome.runtime.Port) {
connections.panel[id] = port; connections.panel[id] = port;
monitorInstances(true, port.name); monitorInstances(true, port.name);
monitors++; monitors++;
listener = (msg: StoreAction) => { listener = (msg: BackgroundAction) => {
window.store.dispatch(msg); window.store.dispatch(msg);
}; };
port.onMessage.addListener(listener); port.onMessage.addListener(listener);
@ -498,7 +501,7 @@ declare global {
window.syncOptions = syncOptions(toAllTabs); // Expose to the options page window.syncOptions = syncOptions(toAllTabs); // Expose to the options page
export default function api() { export default function api() {
return (next: Dispatch<StoreAction>) => (action: StoreAction) => { return (next: Dispatch<BackgroundAction>) => (action: BackgroundAction) => {
if (action.type === LIFTED_ACTION) toContentScript(action); if (action.type === LIFTED_ACTION) toContentScript(action);
else if (action.type === 'TOGGLE_PERSIST') togglePersist(); else if (action.type === 'TOGGLE_PERSIST') togglePersist();
return next(action); return next(action);

View File

@ -6,15 +6,17 @@ import {
import { getActiveInstance } from '@redux-devtools/app/lib/reducers/instances'; import { getActiveInstance } from '@redux-devtools/app/lib/reducers/instances';
import { Dispatch, MiddlewareAPI } from 'redux'; import { Dispatch, MiddlewareAPI } from 'redux';
import { StoreState } from '@redux-devtools/app/lib/reducers'; import { StoreState } from '@redux-devtools/app/lib/reducers';
import { StoreAction } from '@redux-devtools/app/lib/actions'; import { StoreActionWithTogglePersist } from '../stores/windowStore';
function panelDispatcher(bgConnection: chrome.runtime.Port) { function panelDispatcher(bgConnection: chrome.runtime.Port) {
let autoselected = false; let autoselected = false;
const tabId = chrome.devtools.inspectedWindow.tabId; const tabId = chrome.devtools.inspectedWindow.tabId;
return (store: MiddlewareAPI<Dispatch<StoreAction>, StoreState>) => return (
(next: Dispatch<StoreAction>) => store: MiddlewareAPI<Dispatch<StoreActionWithTogglePersist>, StoreState>
(action: StoreAction) => { ) =>
(next: Dispatch<StoreActionWithTogglePersist>) =>
(action: StoreActionWithTogglePersist) => {
const result = next(action); const result = next(action);
if (!autoselected && action.type === UPDATE_STATE && tabId) { if (!autoselected && action.type === UPDATE_STATE && tabId) {
autoselected = true; autoselected = true;

View File

@ -6,12 +6,18 @@ import { getActiveInstance } from '@redux-devtools/app/lib/reducers/instances';
import { Dispatch, MiddlewareAPI, Store } from 'redux'; import { Dispatch, MiddlewareAPI, Store } from 'redux';
import { BackgroundState } from '../reducers/background'; import { BackgroundState } from '../reducers/background';
import { StoreAction } from '@redux-devtools/app/lib/actions'; import { StoreAction } from '@redux-devtools/app/lib/actions';
import {
WindowStoreAction,
StoreActionWithTogglePersist,
} from '../stores/windowStore';
import { StoreState } from '@redux-devtools/app/lib/reducers';
import { BackgroundAction } from '../stores/backgroundStore';
const syncStores = const syncStores =
(baseStore: Store<BackgroundState, StoreAction>) => (baseStore: Store<BackgroundState, BackgroundAction>) =>
(store: MiddlewareAPI<Dispatch<StoreAction>>) => (store: MiddlewareAPI<Dispatch<StoreAction>, StoreState>) =>
(next: Dispatch<StoreAction>) => (next: Dispatch<WindowStoreAction>) =>
(action: StoreAction) => { (action: StoreActionWithTogglePersist) => {
if (action.type === UPDATE_STATE) { if (action.type === UPDATE_STATE) {
return next({ return next({
...action, ...action,

View File

@ -1,17 +1,19 @@
import { combineReducers } from 'redux'; import { combineReducers, Reducer } from 'redux';
import instances, { import instances, {
InstancesState, InstancesState,
} from '@redux-devtools/app/lib/reducers/instances'; } from '@redux-devtools/app/lib/reducers/instances';
import persistStates from './persistStates'; import persistStates from './persistStates';
import { BackgroundAction } from '../../stores/backgroundStore';
export interface BackgroundState { export interface BackgroundState {
readonly instances: InstancesState; readonly instances: InstancesState;
readonly persistStates: boolean; readonly persistStates: boolean;
} }
const rootReducer = combineReducers({ const rootReducer: Reducer<BackgroundState, BackgroundAction> =
combineReducers<BackgroundState>({
instances, instances,
persistStates, persistStates,
}); });
export default rootReducer; export default rootReducer;

View File

@ -1,6 +1,6 @@
import { StoreAction } from '@redux-devtools/app/lib/actions'; import { BackgroundAction } from '../../stores/backgroundStore';
export default function persistStates(state = false, action: StoreAction) { export default function persistStates(state = false, action: BackgroundAction) {
if (action.type === 'TOGGLE_PERSIST') return !state; if (action.type === 'TOGGLE_PERSIST') return !state;
return state; return state;
} }

View File

@ -1,4 +1,4 @@
import { combineReducers } from 'redux'; import { combineReducers, Reducer } from 'redux';
import instances from '@redux-devtools/app/lib/reducers/instances'; import instances from '@redux-devtools/app/lib/reducers/instances';
import monitor from '@redux-devtools/app/lib/reducers/monitor'; import monitor from '@redux-devtools/app/lib/reducers/monitor';
import notification from '@redux-devtools/app/lib/reducers/notification'; import notification from '@redux-devtools/app/lib/reducers/notification';
@ -8,9 +8,10 @@ import theme from '@redux-devtools/app/lib/reducers/theme';
import connection from '@redux-devtools/app/lib/reducers/connection'; import connection from '@redux-devtools/app/lib/reducers/connection';
import socket from '@redux-devtools/app/lib/reducers/socket'; import socket from '@redux-devtools/app/lib/reducers/socket';
import { StoreState } from '@redux-devtools/app/lib/reducers'; import { StoreState } from '@redux-devtools/app/lib/reducers';
import { StoreAction } from '@redux-devtools/app/lib/actions'; import { StoreActionWithTogglePersist } from '../../stores/windowStore';
const rootReducer = combineReducers<StoreState, StoreAction>({ const rootReducer: Reducer<StoreState, StoreActionWithTogglePersist> =
combineReducers<StoreState>({
instances, instances,
monitor, monitor,
reports, reports,
@ -19,6 +20,6 @@ const rootReducer = combineReducers<StoreState, StoreAction>({
theme, theme,
connection, connection,
socket, socket,
}); });
export default rootReducer; export default rootReducer;

View File

@ -1,4 +1,4 @@
import { combineReducers } from 'redux'; import { combineReducers, Reducer } from 'redux';
import instances from './instances'; import instances from './instances';
import monitor from '@redux-devtools/app/lib/reducers/monitor'; import monitor from '@redux-devtools/app/lib/reducers/monitor';
import notification from '@redux-devtools/app/lib/reducers/notification'; import notification from '@redux-devtools/app/lib/reducers/notification';
@ -8,9 +8,10 @@ import section from '@redux-devtools/app/lib/reducers/section';
import theme from '@redux-devtools/app/lib/reducers/theme'; import theme from '@redux-devtools/app/lib/reducers/theme';
import connection from '@redux-devtools/app/lib/reducers/connection'; import connection from '@redux-devtools/app/lib/reducers/connection';
import { StoreState } from '@redux-devtools/app/lib/reducers'; import { StoreState } from '@redux-devtools/app/lib/reducers';
import { StoreAction } from '@redux-devtools/app/lib/actions'; import { WindowStoreAction } from '../../stores/windowStore';
const rootReducer = combineReducers<StoreState, StoreAction>({ const rootReducer: Reducer<StoreState, WindowStoreAction> =
combineReducers<StoreState>({
instances, instances,
monitor, monitor,
socket, socket,
@ -19,6 +20,6 @@ const rootReducer = combineReducers<StoreState, StoreAction>({
section, section,
theme, theme,
connection, connection,
}); });
export default rootReducer; export default rootReducer;

View File

@ -7,9 +7,12 @@ import {
SELECT_INSTANCE, SELECT_INSTANCE,
LIFTED_ACTION, LIFTED_ACTION,
} from '@redux-devtools/app/lib/constants/actionTypes'; } from '@redux-devtools/app/lib/constants/actionTypes';
import { StoreAction } from '@redux-devtools/app/lib/actions'; import { WindowStoreAction } from '../../stores/windowStore';
export default function instances(state = initialState, action: StoreAction) { export default function instances(
state = initialState,
action: WindowStoreAction
) {
switch (action.type) { switch (action.type) {
case UPDATE_STATE: case UPDATE_STATE:
return { ...action.instances, selected: state.selected }; return { ...action.instances, selected: state.selected };

View File

@ -1,6 +1,6 @@
import { Action } from 'redux'; import { Action } from 'redux';
import { LiftedState } from '@redux-devtools/instrument'; import { LiftedState } from '@redux-devtools/instrument';
import { LibConfig, StoreAction } from '@redux-devtools/app/lib/actions'; import { DispatchAction, LibConfig } from '@redux-devtools/app/lib/actions';
declare global { declare global {
interface Window { interface Window {
@ -15,6 +15,8 @@ export default class Monitor<S, A extends Action<unknown>> {
) => void; ) => void;
active?: boolean; active?: boolean;
paused?: boolean; paused?: boolean;
lastAction?: string;
waitingTimeout?: number;
constructor( constructor(
update: ( update: (
@ -24,7 +26,7 @@ export default class Monitor<S, A extends Action<unknown>> {
) { ) {
this.update = update; this.update = update;
} }
reducer = (state = {}, action: StoreAction) => { reducer = (state = {}, action: DispatchAction) => {
if (!this.active) return state; if (!this.active) return state;
this.lastAction = action.type; this.lastAction = action.type;
if (action.type === 'LOCK_CHANGES') { if (action.type === 'LOCK_CHANGES') {

View File

@ -1,6 +1,58 @@
import { createStore, applyMiddleware, PreloadedState } from 'redux'; import { createStore, applyMiddleware, PreloadedState } from 'redux';
import rootReducer, { BackgroundState } from '../reducers/background'; import rootReducer, { BackgroundState } from '../reducers/background';
import api from '../middlewares/api'; import api from '../middlewares/api';
import { LIFTED_ACTION } from '@redux-devtools/app/lib/constants/actionTypes';
import {
CustomAction,
DispatchAction,
StoreActionWithoutLiftedAction,
} from '@redux-devtools/app/lib/actions';
interface LiftedActionActionBase {
action?: DispatchAction | string | CustomAction;
state?: string;
toAll?: boolean;
readonly instanceId: string | number;
readonly id: string | number | undefined;
}
interface LiftedActionDispatchAction extends LiftedActionActionBase {
type: typeof LIFTED_ACTION;
message: 'DISPATCH';
action: DispatchAction;
toAll?: boolean;
}
interface LiftedActionImportAction extends LiftedActionActionBase {
type: typeof LIFTED_ACTION;
message: 'IMPORT';
state: string;
preloadedState?: unknown | undefined;
}
interface LiftedActionActionAction extends LiftedActionActionBase {
type: typeof LIFTED_ACTION;
message: 'ACTION';
action: string | CustomAction;
}
interface LiftedActionExportAction extends LiftedActionActionBase {
type: typeof LIFTED_ACTION;
message: 'EXPORT';
toExport: boolean;
}
export type LiftedActionAction =
| LiftedActionDispatchAction
| LiftedActionImportAction
| LiftedActionActionAction
| LiftedActionExportAction;
interface TogglePersistAction {
readonly type: 'TOGGLE_PERSIST';
readonly instanceId: string | number;
readonly id: string | number | undefined;
}
export type BackgroundAction =
| StoreActionWithoutLiftedAction
| LiftedActionAction
| TogglePersistAction;
export default function configureStore( export default function configureStore(
preloadedState?: PreloadedState<BackgroundState> preloadedState?: PreloadedState<BackgroundState>

View File

@ -4,23 +4,45 @@ import {
applyMiddleware, applyMiddleware,
Store, Store,
PreloadedState, PreloadedState,
StoreEnhancer,
} from 'redux'; } from 'redux';
import exportState from '@redux-devtools/app/lib/middlewares/exportState'; import exportState from '@redux-devtools/app/lib/middlewares/exportState';
import api from '@redux-devtools/app/lib/middlewares/api'; import api from '@redux-devtools/app/lib/middlewares/api';
import { CONNECT_REQUEST } from '@redux-devtools/app/lib/constants/socketActionTypes'; import { CONNECT_REQUEST } from '@redux-devtools/app/lib/constants/socketActionTypes';
import { StoreState } from '@redux-devtools/app/lib/reducers'; import { StoreState } from '@redux-devtools/app/lib/reducers';
import { StoreAction } from '@redux-devtools/app/lib/actions'; import {
StoreAction,
StoreActionWithoutUpdateState,
UpdateStateAction,
} from '@redux-devtools/app/lib/actions';
import { InstancesState } from '@redux-devtools/app/lib/reducers/instances';
import syncStores from '../middlewares/windowSync'; import syncStores from '../middlewares/windowSync';
import instanceSelector from '../middlewares/instanceSelector'; import instanceSelector from '../middlewares/instanceSelector';
import rootReducer from '../reducers/window'; import rootReducer from '../reducers/window';
import { BackgroundState } from '../reducers/background'; import { BackgroundState } from '../reducers/background';
import { BackgroundAction } from './backgroundStore';
export interface TogglePersistAction {
readonly type: 'TOGGLE_PERSIST';
}
export type StoreActionWithTogglePersist = StoreAction | TogglePersistAction;
interface ExpandedUpdateStateAction extends UpdateStateAction {
readonly instances: InstancesState;
}
export type WindowStoreAction =
| StoreActionWithoutUpdateState
| TogglePersistAction
| ExpandedUpdateStateAction;
export default function configureStore( export default function configureStore(
baseStore: Store<BackgroundState, StoreAction>, baseStore: Store<BackgroundState, BackgroundAction>,
position: string, position: string,
preloadedState: PreloadedState<StoreState> preloadedState: PreloadedState<StoreState>
) { ) {
let enhancer; let enhancer: StoreEnhancer;
const middlewares = [exportState, api, syncStores(baseStore)]; const middlewares = [exportState, api, syncStores(baseStore)];
if (!position || position === '#popup') { if (!position || position === '#popup') {
// select current tab instance for devPanel and pageAction // select current tab instance for devPanel and pageAction
@ -33,7 +55,7 @@ export default function configureStore(
applyMiddleware(...middlewares), applyMiddleware(...middlewares),
window.__REDUX_DEVTOOLS_EXTENSION__ window.__REDUX_DEVTOOLS_EXTENSION__
? window.__REDUX_DEVTOOLS_EXTENSION__() ? window.__REDUX_DEVTOOLS_EXTENSION__()
: (noop) => noop : (noop: unknown) => noop
); );
} }
const store = createStore(rootReducer, preloadedState, enhancer); const store = createStore(rootReducer, preloadedState, enhancer);

View File

@ -1,6 +1,7 @@
import { Store } from 'redux'; import { Store } from 'redux';
import { StoreAction } from '@redux-devtools/app/lib/actions'; import configureStore, {
import configureStore from '../../../app/stores/backgroundStore'; BackgroundAction,
} from '../../../app/stores/backgroundStore';
import openDevToolsWindow, { DevToolsPosition } from './openWindow'; import openDevToolsWindow, { DevToolsPosition } from './openWindow';
import { createMenu, removeMenu } from './contextMenus'; import { createMenu, removeMenu } from './contextMenus';
import syncOptions from '../options/syncOptions'; import syncOptions from '../options/syncOptions';
@ -8,7 +9,7 @@ import { BackgroundState } from '../../../app/reducers/background';
declare global { declare global {
interface Window { interface Window {
store: Store<BackgroundState, StoreAction>; store: Store<BackgroundState, BackgroundAction>;
} }
} }

View File

@ -54,7 +54,7 @@ let monitorReducer: (
) => unknown; ) => unknown;
let monitorProps: unknown = {}; let monitorProps: unknown = {};
interface ChangeSectionAction { export interface ChangeSectionAction {
readonly type: typeof CHANGE_SECTION; readonly type: typeof CHANGE_SECTION;
readonly section: string; readonly section: string;
} }
@ -70,7 +70,7 @@ interface ChangeThemeFormData {
interface ChangeThemeData { interface ChangeThemeData {
readonly formData: ChangeThemeFormData; readonly formData: ChangeThemeFormData;
} }
interface ChangeThemeAction { export interface ChangeThemeAction {
readonly type: typeof CHANGE_THEME; readonly type: typeof CHANGE_THEME;
readonly theme: Theme; readonly theme: Theme;
readonly scheme: Scheme; readonly scheme: Scheme;
@ -163,19 +163,18 @@ export interface LiftedActionDispatchAction extends LiftedActionActionBase {
action: DispatchAction; action: DispatchAction;
toAll?: boolean; toAll?: boolean;
} }
interface LiftedActionImportAction extends LiftedActionActionBase { export interface LiftedActionImportAction extends LiftedActionActionBase {
type: typeof LIFTED_ACTION; type: typeof LIFTED_ACTION;
message: 'IMPORT'; message: 'IMPORT';
state: string; state: string;
preloadedState: unknown | undefined; preloadedState: unknown | undefined;
id?: string | number;
} }
interface LiftedActionActionAction extends LiftedActionActionBase { export interface LiftedActionActionAction extends LiftedActionActionBase {
type: typeof LIFTED_ACTION; type: typeof LIFTED_ACTION;
message: 'ACTION'; message: 'ACTION';
action: string | CustomAction; action: string | CustomAction;
} }
interface LiftedActionExportAction extends LiftedActionActionBase { export interface LiftedActionExportAction extends LiftedActionActionBase {
type: typeof LIFTED_ACTION; type: typeof LIFTED_ACTION;
message: 'EXPORT'; message: 'EXPORT';
toExport: boolean; toExport: boolean;
@ -211,15 +210,15 @@ export function liftedDispatch(
} as LiftedActionDispatchAction; } as LiftedActionDispatchAction;
} }
interface SelectInstanceAction { export interface SelectInstanceAction {
type: typeof SELECT_INSTANCE; type: typeof SELECT_INSTANCE;
selected: string; selected: string | number;
} }
export function selectInstance(selected: string): SelectInstanceAction { export function selectInstance(selected: string): SelectInstanceAction {
return { type: SELECT_INSTANCE, selected }; return { type: SELECT_INSTANCE, selected };
} }
interface SelectMonitorAction { export interface SelectMonitorAction {
type: typeof SELECT_MONITOR; type: typeof SELECT_MONITOR;
monitor: string; monitor: string;
monitorState?: MonitorStateMonitorState; monitorState?: MonitorStateMonitorState;
@ -238,7 +237,7 @@ interface NextState {
subTabName: string; subTabName: string;
inspectedStatePath?: string[]; inspectedStatePath?: string[];
} }
interface UpdateMonitorStateAction { export interface UpdateMonitorStateAction {
type: typeof UPDATE_MONITOR_STATE; type: typeof UPDATE_MONITOR_STATE;
nextState: NextState; nextState: NextState;
} }
@ -259,7 +258,7 @@ export function importState(
return { type: LIFTED_ACTION, message: 'IMPORT', state, preloadedState }; return { type: LIFTED_ACTION, message: 'IMPORT', state, preloadedState };
} }
interface ExportAction { export interface ExportAction {
type: typeof EXPORT; type: typeof EXPORT;
} }
export function exportState(): ExportAction { export function exportState(): ExportAction {
@ -296,28 +295,28 @@ export function dispatchRemotely(
return { type: LIFTED_ACTION, message: 'ACTION', action }; return { type: LIFTED_ACTION, message: 'ACTION', action };
} }
interface TogglePersistAction { export interface TogglePersistAction {
type: typeof TOGGLE_PERSIST; type: typeof TOGGLE_PERSIST;
} }
export function togglePersist(): TogglePersistAction { export function togglePersist(): TogglePersistAction {
return { type: TOGGLE_PERSIST }; return { type: TOGGLE_PERSIST };
} }
interface ToggleSyncAction { export interface ToggleSyncAction {
type: typeof TOGGLE_SYNC; type: typeof TOGGLE_SYNC;
} }
export function toggleSync(): ToggleSyncAction { export function toggleSync(): ToggleSyncAction {
return { type: TOGGLE_SYNC }; return { type: TOGGLE_SYNC };
} }
interface ToggleSliderAction { export interface ToggleSliderAction {
type: typeof TOGGLE_SLIDER; type: typeof TOGGLE_SLIDER;
} }
export function toggleSlider(): ToggleSliderAction { export function toggleSlider(): ToggleSliderAction {
return { type: TOGGLE_SLIDER }; return { type: TOGGLE_SLIDER };
} }
interface ToggleDispatcherAction { export interface ToggleDispatcherAction {
type: typeof TOGGLE_DISPATCHER; type: typeof TOGGLE_DISPATCHER;
} }
export function toggleDispatcher(): ToggleDispatcherAction { export function toggleDispatcher(): ToggleDispatcherAction {
@ -331,7 +330,7 @@ export interface ConnectionOptions {
readonly port: number; readonly port: number;
readonly secure: boolean; readonly secure: boolean;
} }
interface ReconnectAction { export interface ReconnectAction {
readonly type: typeof RECONNECT; readonly type: typeof RECONNECT;
readonly options: ConnectionOptions; readonly options: ConnectionOptions;
} }
@ -345,7 +344,7 @@ interface Notification {
readonly type: 'error'; readonly type: 'error';
readonly message: string; readonly message: string;
} }
interface ShowNotificationAction { export interface ShowNotificationAction {
readonly type: typeof SHOW_NOTIFICATION; readonly type: typeof SHOW_NOTIFICATION;
readonly notification: Notification; readonly notification: Notification;
} }
@ -353,14 +352,14 @@ export function showNotification(message: string): ShowNotificationAction {
return { type: SHOW_NOTIFICATION, notification: { type: 'error', message } }; return { type: SHOW_NOTIFICATION, notification: { type: 'error', message } };
} }
interface ClearNotificationAction { export interface ClearNotificationAction {
readonly type: typeof CLEAR_NOTIFICATION; readonly type: typeof CLEAR_NOTIFICATION;
} }
export function clearNotification(): ClearNotificationAction { export function clearNotification(): ClearNotificationAction {
return { type: CLEAR_NOTIFICATION }; return { type: CLEAR_NOTIFICATION };
} }
interface GetReportRequest { export interface GetReportRequest {
readonly type: typeof GET_REPORT_REQUEST; readonly type: typeof GET_REPORT_REQUEST;
readonly report: unknown; readonly report: unknown;
} }
@ -429,23 +428,23 @@ export type Request =
| LiftedRequest | LiftedRequest
| ExportRequest; | ExportRequest;
interface UpdateStateAction { export interface UpdateStateAction {
type: typeof UPDATE_STATE; type: typeof UPDATE_STATE;
request?: Request; request?: Request;
id?: string | number; id?: string | number;
} }
interface SetStateAction { export interface SetStateAction {
type: typeof SET_STATE; type: typeof SET_STATE;
newState: State; newState: State;
} }
interface RemoveInstanceAction { export interface RemoveInstanceAction {
type: typeof REMOVE_INSTANCE; type: typeof REMOVE_INSTANCE;
id: string; id: string;
} }
interface ConnectRequestAction { export interface ConnectRequestAction {
type: typeof CONNECT_REQUEST; type: typeof CONNECT_REQUEST;
options: ConnectionOptions; options: ConnectionOptions;
} }
@ -455,58 +454,58 @@ interface ConnectSuccessPayload {
authState: AuthStates; authState: AuthStates;
socketState: States; socketState: States;
} }
interface ConnectSuccessAction { export interface ConnectSuccessAction {
type: typeof CONNECT_SUCCESS; type: typeof CONNECT_SUCCESS;
payload: ConnectSuccessPayload; payload: ConnectSuccessPayload;
error: Error | undefined; error: Error | undefined;
} }
interface ConnectErrorAction { export interface ConnectErrorAction {
type: typeof CONNECT_ERROR; type: typeof CONNECT_ERROR;
error: Error | undefined; error: Error | undefined;
} }
interface AuthRequestAction { export interface AuthRequestAction {
type: typeof AUTH_REQUEST; type: typeof AUTH_REQUEST;
} }
interface AuthSuccessAction { export interface AuthSuccessAction {
type: typeof AUTH_SUCCESS; type: typeof AUTH_SUCCESS;
baseChannel: string; baseChannel: string;
} }
interface AuthErrorAction { export interface AuthErrorAction {
type: typeof AUTH_ERROR; type: typeof AUTH_ERROR;
error: Error; error: Error;
} }
interface DisconnectedAction { export interface DisconnectedAction {
type: typeof DISCONNECTED; type: typeof DISCONNECTED;
code: number; code: number;
} }
interface DeauthenticateAction { export interface DeauthenticateAction {
type: typeof DEAUTHENTICATE; type: typeof DEAUTHENTICATE;
} }
interface SubscribeRequestAction { export interface SubscribeRequestAction {
type: typeof SUBSCRIBE_REQUEST; type: typeof SUBSCRIBE_REQUEST;
channel: string; channel: string;
subscription: typeof UPDATE_STATE | typeof UPDATE_REPORTS; subscription: typeof UPDATE_STATE | typeof UPDATE_REPORTS;
} }
interface SubscribeSuccessAction { export interface SubscribeSuccessAction {
type: typeof SUBSCRIBE_SUCCESS; type: typeof SUBSCRIBE_SUCCESS;
channel: string; channel: string;
} }
interface SubscribeErrorAction { export interface SubscribeErrorAction {
type: typeof SUBSCRIBE_ERROR; type: typeof SUBSCRIBE_ERROR;
error: Error; error: Error;
status: string; status: string;
} }
interface UnsubscribeAction { export interface UnsubscribeAction {
type: typeof UNSUBSCRIBE; type: typeof UNSUBSCRIBE;
channel: string; channel: string;
} }
@ -534,27 +533,27 @@ interface RemoveRequest {
id: unknown; id: unknown;
} }
export type UpdateReportsRequest = ListRequest | AddRequest | RemoveRequest; export type UpdateReportsRequest = ListRequest | AddRequest | RemoveRequest;
interface UpdateReportsAction { export interface UpdateReportsAction {
type: typeof UPDATE_REPORTS; type: typeof UPDATE_REPORTS;
request: UpdateReportsRequest; request: UpdateReportsRequest;
} }
interface GetReportError { export interface GetReportError {
type: typeof GET_REPORT_ERROR; type: typeof GET_REPORT_ERROR;
error: Error; error: Error;
} }
interface GetReportSuccess { export interface GetReportSuccess {
type: typeof GET_REPORT_SUCCESS; type: typeof GET_REPORT_SUCCESS;
data: { payload: string }; data: { payload: string };
} }
interface ErrorAction { export interface ErrorAction {
type: typeof ERROR; type: typeof ERROR;
payload: string; payload: string;
} }
export type StoreAction = export type StoreActionWithoutUpdateStateOrLiftedAction =
| ChangeSectionAction | ChangeSectionAction
| ChangeThemeAction | ChangeThemeAction
| MonitorActionAction | MonitorActionAction
@ -572,7 +571,6 @@ export type StoreAction =
| ClearNotificationAction | ClearNotificationAction
| GetReportRequest | GetReportRequest
| SetStateAction | SetStateAction
| UpdateStateAction
| RemoveInstanceAction | RemoveInstanceAction
| ConnectRequestAction | ConnectRequestAction
| ConnectSuccessAction | ConnectSuccessAction
@ -591,3 +589,13 @@ export type StoreAction =
| GetReportError | GetReportError
| GetReportSuccess | GetReportSuccess
| ErrorAction; | ErrorAction;
export type StoreActionWithoutUpdateState =
| StoreActionWithoutUpdateStateOrLiftedAction
| LiftedActionAction;
export type StoreActionWithoutLiftedAction =
| StoreActionWithoutUpdateStateOrLiftedAction
| UpdateStateAction;
export type StoreAction = StoreActionWithoutUpdateState | UpdateStateAction;

View File

@ -56,7 +56,7 @@ export interface State {
} }
export interface InstancesState { export interface InstancesState {
selected: string | null; selected: string | number | null;
current: string | number; current: string | number;
sync: boolean; sync: boolean;
connections: { [id: string]: (string | number)[] }; connections: { [id: string]: (string | number)[] };

View File

@ -21,7 +21,10 @@ export function sweep(state: State): State {
} }
export function nonReduxDispatch( export function nonReduxDispatch(
store: MiddlewareAPI<Dispatch<StoreAction>, StoreState>, store: MiddlewareAPI<
Dispatch<StoreAction>,
{ readonly instances: InstancesState }
>,
message: string, message: string,
instanceId: string | number, instanceId: string | number,
action: DispatchAction, action: DispatchAction,