mirror of
https://github.com/reduxjs/redux-devtools.git
synced 2025-07-27 08:30:02 +03:00
More work on types
This commit is contained in:
parent
3cc1a62177
commit
b1a71b4a72
|
@ -325,7 +325,7 @@ interface StateMessage<S, A extends Action<unknown>> {
|
||||||
|
|
||||||
export interface ErrorMessage {
|
export interface ErrorMessage {
|
||||||
readonly type: 'ERROR';
|
readonly type: 'ERROR';
|
||||||
readonly payload: unknown;
|
readonly payload: string;
|
||||||
readonly source: typeof source;
|
readonly source: typeof source;
|
||||||
readonly instanceId: number;
|
readonly instanceId: number;
|
||||||
}
|
}
|
||||||
|
@ -607,7 +607,7 @@ export function connect(preConfig: Config) {
|
||||||
post(message);
|
post(message);
|
||||||
};
|
};
|
||||||
|
|
||||||
const error = (payload: unknown) => {
|
const error = (payload: string) => {
|
||||||
post({ type: 'ERROR', payload, instanceId: id, source });
|
post({ type: 'ERROR', payload, instanceId: id, source });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -157,10 +157,14 @@ type UpdateStateRequest<S, A extends Action<unknown>> =
|
||||||
| SerializedActionMessage
|
| SerializedActionMessage
|
||||||
| SerializedStateMessage<S, A>;
|
| SerializedStateMessage<S, A>;
|
||||||
|
|
||||||
|
interface EmptyUpdateStateAction {
|
||||||
|
readonly type: typeof UPDATE_STATE;
|
||||||
|
}
|
||||||
|
|
||||||
interface UpdateStateAction<S, A extends Action<unknown>> {
|
interface UpdateStateAction<S, A extends Action<unknown>> {
|
||||||
readonly type: typeof UPDATE_STATE;
|
readonly type: typeof UPDATE_STATE;
|
||||||
readonly request?: UpdateStateRequest<S, A>;
|
readonly request: UpdateStateRequest<S, A>;
|
||||||
readonly id?: string | number;
|
readonly id: string | number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type TabMessage =
|
export type TabMessage =
|
||||||
|
@ -171,14 +175,11 @@ export type TabMessage =
|
||||||
| ImportAction
|
| ImportAction
|
||||||
| ActionAction
|
| ActionAction
|
||||||
| ExportAction;
|
| ExportAction;
|
||||||
type PanelMessage<S, A extends Action<unknown>> =
|
export type PanelMessage<S, A extends Action<unknown>> =
|
||||||
| NAAction
|
|
||||||
| ErrorMessage
|
|
||||||
| UpdateStateAction<S, A>;
|
|
||||||
type MonitorMessage<S, A extends Action<unknown>> =
|
|
||||||
| NAAction
|
| NAAction
|
||||||
| ErrorMessage
|
| ErrorMessage
|
||||||
| UpdateStateAction<S, A>;
|
| UpdateStateAction<S, A>;
|
||||||
|
export type MonitorMessage = NAAction | ErrorMessage | EmptyUpdateStateAction;
|
||||||
|
|
||||||
type TabPort = Omit<chrome.runtime.Port, 'postMessage'> & {
|
type TabPort = Omit<chrome.runtime.Port, 'postMessage'> & {
|
||||||
postMessage: (message: TabMessage) => void;
|
postMessage: (message: TabMessage) => void;
|
||||||
|
@ -189,9 +190,7 @@ type PanelPort = Omit<chrome.runtime.Port, 'postMessage'> & {
|
||||||
) => void;
|
) => void;
|
||||||
};
|
};
|
||||||
type MonitorPort = Omit<chrome.runtime.Port, 'postMessage'> & {
|
type MonitorPort = Omit<chrome.runtime.Port, 'postMessage'> & {
|
||||||
postMessage: <S, A extends Action<unknown>>(
|
postMessage: (message: MonitorMessage) => void;
|
||||||
message: MonitorMessage<S, A>
|
|
||||||
) => void;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const CONNECTED = 'socket/CONNECTED';
|
const CONNECTED = 'socket/CONNECTED';
|
||||||
|
|
|
@ -7,9 +7,10 @@ import configureStore from '../../../app/stores/panelStore';
|
||||||
import getPreloadedState from '../background/getPreloadedState';
|
import getPreloadedState from '../background/getPreloadedState';
|
||||||
|
|
||||||
import '../../views/devpanel.pug';
|
import '../../views/devpanel.pug';
|
||||||
import { PreloadedState, Store } from 'redux';
|
import { Action, PreloadedState, Store } 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 { StoreAction } from '@redux-devtools/app/lib/actions';
|
||||||
|
import { PanelMessage } from '../../../app/middlewares/api';
|
||||||
|
|
||||||
const position = location.hash;
|
const position = location.hash;
|
||||||
const messageStyle: CSSProperties = {
|
const messageStyle: CSSProperties = {
|
||||||
|
@ -96,7 +97,8 @@ function init(id: number) {
|
||||||
bgConnection = chrome.runtime.connect({
|
bgConnection = chrome.runtime.connect({
|
||||||
name: id ? id.toString() : undefined,
|
name: id ? id.toString() : undefined,
|
||||||
});
|
});
|
||||||
bgConnection.onMessage.addListener((message) => {
|
bgConnection.onMessage.addListener(
|
||||||
|
<S, A extends Action<unknown>>(message: PanelMessage<S, A>) => {
|
||||||
if (message.type === 'NA') {
|
if (message.type === 'NA') {
|
||||||
if (message.id === id) renderNA();
|
if (message.id === id) renderNA();
|
||||||
else store!.dispatch({ type: REMOVE_INSTANCE, id: message.id });
|
else store!.dispatch({ type: REMOVE_INSTANCE, id: message.id });
|
||||||
|
@ -104,7 +106,8 @@ function init(id: number) {
|
||||||
if (!rendered) renderDevTools();
|
if (!rendered) renderDevTools();
|
||||||
store!.dispatch(message);
|
store!.dispatch(message);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
init(chrome.devtools.inspectedWindow.tabId);
|
init(chrome.devtools.inspectedWindow.tabId);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user