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 {
|
||||
readonly type: 'ERROR';
|
||||
readonly payload: unknown;
|
||||
readonly payload: string;
|
||||
readonly source: typeof source;
|
||||
readonly instanceId: number;
|
||||
}
|
||||
|
@ -607,7 +607,7 @@ export function connect(preConfig: Config) {
|
|||
post(message);
|
||||
};
|
||||
|
||||
const error = (payload: unknown) => {
|
||||
const error = (payload: string) => {
|
||||
post({ type: 'ERROR', payload, instanceId: id, source });
|
||||
};
|
||||
|
||||
|
|
|
@ -157,10 +157,14 @@ type UpdateStateRequest<S, A extends Action<unknown>> =
|
|||
| SerializedActionMessage
|
||||
| SerializedStateMessage<S, A>;
|
||||
|
||||
interface EmptyUpdateStateAction {
|
||||
readonly type: typeof UPDATE_STATE;
|
||||
}
|
||||
|
||||
interface UpdateStateAction<S, A extends Action<unknown>> {
|
||||
readonly type: typeof UPDATE_STATE;
|
||||
readonly request?: UpdateStateRequest<S, A>;
|
||||
readonly id?: string | number;
|
||||
readonly request: UpdateStateRequest<S, A>;
|
||||
readonly id: string | number;
|
||||
}
|
||||
|
||||
export type TabMessage =
|
||||
|
@ -171,14 +175,11 @@ export type TabMessage =
|
|||
| ImportAction
|
||||
| ActionAction
|
||||
| ExportAction;
|
||||
type PanelMessage<S, A extends Action<unknown>> =
|
||||
| NAAction
|
||||
| ErrorMessage
|
||||
| UpdateStateAction<S, A>;
|
||||
type MonitorMessage<S, A extends Action<unknown>> =
|
||||
export type PanelMessage<S, A extends Action<unknown>> =
|
||||
| NAAction
|
||||
| ErrorMessage
|
||||
| UpdateStateAction<S, A>;
|
||||
export type MonitorMessage = NAAction | ErrorMessage | EmptyUpdateStateAction;
|
||||
|
||||
type TabPort = Omit<chrome.runtime.Port, 'postMessage'> & {
|
||||
postMessage: (message: TabMessage) => void;
|
||||
|
@ -189,9 +190,7 @@ type PanelPort = Omit<chrome.runtime.Port, 'postMessage'> & {
|
|||
) => void;
|
||||
};
|
||||
type MonitorPort = Omit<chrome.runtime.Port, 'postMessage'> & {
|
||||
postMessage: <S, A extends Action<unknown>>(
|
||||
message: MonitorMessage<S, A>
|
||||
) => void;
|
||||
postMessage: (message: MonitorMessage) => void;
|
||||
};
|
||||
|
||||
const CONNECTED = 'socket/CONNECTED';
|
||||
|
|
|
@ -7,9 +7,10 @@ import configureStore from '../../../app/stores/panelStore';
|
|||
import getPreloadedState from '../background/getPreloadedState';
|
||||
|
||||
import '../../views/devpanel.pug';
|
||||
import { PreloadedState, Store } from 'redux';
|
||||
import { Action, PreloadedState, Store } from 'redux';
|
||||
import { StoreState } from '@redux-devtools/app/lib/reducers';
|
||||
import { StoreAction } from '@redux-devtools/app/lib/actions';
|
||||
import { PanelMessage } from '../../../app/middlewares/api';
|
||||
|
||||
const position = location.hash;
|
||||
const messageStyle: CSSProperties = {
|
||||
|
@ -96,7 +97,8 @@ function init(id: number) {
|
|||
bgConnection = chrome.runtime.connect({
|
||||
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.id === id) renderNA();
|
||||
else store!.dispatch({ type: REMOVE_INSTANCE, id: message.id });
|
||||
|
@ -104,7 +106,8 @@ function init(id: number) {
|
|||
if (!rendered) renderDevTools();
|
||||
store!.dispatch(message);
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
init(chrome.devtools.inspectedWindow.tabId);
|
||||
|
|
Loading…
Reference in New Issue
Block a user