mirror of
https://github.com/reduxjs/redux-devtools.git
synced 2025-07-27 00:19:55 +03:00
stash
This commit is contained in:
parent
2bfeb49b43
commit
5b6a0adbfd
|
@ -18,7 +18,7 @@ module.exports = {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
files: ['webpack.config.umd.ts'],
|
files: ['webpack.config.ts', 'webpack.config.umd.ts'],
|
||||||
extends: '../../eslintrc.ts.base.json',
|
extends: '../../eslintrc.ts.base.json',
|
||||||
parserOptions: {
|
parserOptions: {
|
||||||
tsconfigRootDir: __dirname,
|
tsconfigRootDir: __dirname,
|
||||||
|
|
|
@ -502,7 +502,7 @@ export interface EmitAction {
|
||||||
|
|
||||||
interface ListRequest {
|
interface ListRequest {
|
||||||
type: 'list';
|
type: 'list';
|
||||||
data: Data;
|
data: Data[];
|
||||||
}
|
}
|
||||||
interface AddRequest {
|
interface AddRequest {
|
||||||
type: 'add';
|
type: 'add';
|
||||||
|
@ -513,7 +513,7 @@ interface RemoveRequest {
|
||||||
data: Data;
|
data: Data;
|
||||||
id: unknown;
|
id: unknown;
|
||||||
}
|
}
|
||||||
type UpdateReportsRequest = ListRequest | AddRequest | RemoveRequest;
|
export type UpdateReportsRequest = ListRequest | AddRequest | RemoveRequest;
|
||||||
interface UpdateReportsAction {
|
interface UpdateReportsAction {
|
||||||
type: typeof UPDATE_REPORTS;
|
type: typeof UPDATE_REPORTS;
|
||||||
request: UpdateReportsRequest;
|
request: UpdateReportsRequest;
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
import { connect, ResolveThunks } from 'react-redux';
|
import { connect, ResolveThunks } from 'react-redux';
|
||||||
import { Select } from 'devui';
|
import { Select } from 'devui';
|
||||||
import { selectInstance } from '../actions';
|
import { selectInstance } from '../actions';
|
||||||
|
@ -10,12 +9,6 @@ type DispatchProps = ResolveThunks<typeof actionCreators>;
|
||||||
type Props = StateProps & DispatchProps;
|
type Props = StateProps & DispatchProps;
|
||||||
|
|
||||||
class InstanceSelector extends Component<Props> {
|
class InstanceSelector extends Component<Props> {
|
||||||
static propTypes = {
|
|
||||||
selected: PropTypes.string,
|
|
||||||
instances: PropTypes.object.isRequired,
|
|
||||||
onSelect: PropTypes.func.isRequired,
|
|
||||||
};
|
|
||||||
|
|
||||||
select?: { readonly value: string; readonly label: string }[];
|
select?: { readonly value: string; readonly label: string }[];
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
@ -24,8 +17,7 @@ class InstanceSelector extends Component<Props> {
|
||||||
let name;
|
let name;
|
||||||
Object.keys(instances).forEach((key) => {
|
Object.keys(instances).forEach((key) => {
|
||||||
name = instances[key].name;
|
name = instances[key].name;
|
||||||
if (name !== undefined)
|
if (name !== undefined) this.select!.push({ value: key, label: name });
|
||||||
this.select!.push({ value: key, label: instances[key].name });
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -23,8 +23,7 @@ class Settings extends Component<{}, State> {
|
||||||
return (
|
return (
|
||||||
// eslint-disable-next-line @typescript-eslint/ban-types
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||||
<Tabs<{}>
|
<Tabs<{}>
|
||||||
toRight
|
tabs={this.tabs as any}
|
||||||
tabs={this.tabs}
|
|
||||||
selected={this.state.selected}
|
selected={this.state.selected}
|
||||||
onClick={this.handleSelect}
|
onClick={this.handleSelect}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -21,7 +21,6 @@ class LockButton extends Component<Props> {
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<Button
|
<Button
|
||||||
toolbar
|
|
||||||
tooltipPosition="bottom"
|
tooltipPosition="bottom"
|
||||||
disabled={this.props.disabled}
|
disabled={this.props.disabled}
|
||||||
mark={this.props.persisted && 'base0D'}
|
mark={this.props.persisted && 'base0D'}
|
||||||
|
|
|
@ -21,6 +21,7 @@ import {
|
||||||
LiftedActionAction,
|
LiftedActionAction,
|
||||||
Request,
|
Request,
|
||||||
DispatchAction,
|
DispatchAction,
|
||||||
|
UpdateReportsRequest,
|
||||||
} from '../actions';
|
} from '../actions';
|
||||||
import { nonReduxDispatch } from '../utils/monitorActions';
|
import { nonReduxDispatch } from '../utils/monitorActions';
|
||||||
import { StoreState } from '../reducers';
|
import { StoreState } from '../reducers';
|
||||||
|
@ -136,7 +137,7 @@ function subscribe(
|
||||||
const channel = socket.subscribe(channelName);
|
const channel = socket.subscribe(channelName);
|
||||||
if (subscription === UPDATE_STATE) channel.watch(monitoring);
|
if (subscription === UPDATE_STATE) channel.watch(monitoring);
|
||||||
else {
|
else {
|
||||||
const watcher = (request: Request) => {
|
const watcher = (request: UpdateReportsRequest) => {
|
||||||
store.dispatch({ type: subscription, request });
|
store.dispatch({ type: subscription, request });
|
||||||
};
|
};
|
||||||
channel.watch(watcher);
|
channel.watch(watcher);
|
||||||
|
|
|
@ -107,13 +107,14 @@ function updateState(
|
||||||
|
|
||||||
let newState;
|
let newState;
|
||||||
const liftedState = state[id] || state.default;
|
const liftedState = state[id] || state.default;
|
||||||
const action = (request.action && parseJSON(request.action, serialize)) || {};
|
const action = ((request.action && parseJSON(request.action, serialize)) ||
|
||||||
|
{}) as PerformAction<Action<unknown>>;
|
||||||
|
|
||||||
switch (request.type) {
|
switch (request.type) {
|
||||||
case 'INIT':
|
case 'INIT':
|
||||||
newState = recompute(state.default, payload, {
|
newState = recompute(state.default, payload, {
|
||||||
action: { type: '@@INIT' },
|
action: { type: '@@INIT' },
|
||||||
timestamp: (action as { timestamp?: unknown }).timestamp || Date.now(),
|
timestamp: (action as { timestamp?: number }).timestamp || Date.now(),
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 'ACTION': {
|
case 'ACTION': {
|
||||||
|
@ -301,7 +302,10 @@ function init(
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function instances(state = initialState, action: StoreAction) {
|
export default function instances(
|
||||||
|
state = initialState,
|
||||||
|
action: StoreAction
|
||||||
|
): InstancesState {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case UPDATE_STATE: {
|
case UPDATE_STATE: {
|
||||||
const { request } = action;
|
const { request } = action;
|
||||||
|
@ -360,7 +364,7 @@ export default function instances(state = initialState, action: StoreAction) {
|
||||||
...state,
|
...state,
|
||||||
states: {
|
states: {
|
||||||
...state.states,
|
...state.states,
|
||||||
[id]: parseJSON(action.state),
|
[id]: parseJSON(action.state) as State,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,10 @@ const initialState: ReportsState = {
|
||||||
data: [],
|
data: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function reports(state = initialState, action: StoreAction) {
|
export default function reports(
|
||||||
|
state = initialState,
|
||||||
|
action: StoreAction
|
||||||
|
): ReportsState {
|
||||||
/* if (action.type === GET_REPORT_SUCCESS) {
|
/* if (action.type === GET_REPORT_SUCCESS) {
|
||||||
const id = action.data.id;
|
const id = action.data.id;
|
||||||
return {
|
return {
|
||||||
|
@ -28,17 +31,16 @@ export default function reports(state = initialState, action: StoreAction) {
|
||||||
return state;
|
return state;
|
||||||
|
|
||||||
const request = action.request;
|
const request = action.request;
|
||||||
const data = request.data;
|
|
||||||
switch (request.type) {
|
switch (request.type) {
|
||||||
case 'list':
|
case 'list':
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
data,
|
data: request.data,
|
||||||
};
|
};
|
||||||
case 'add':
|
case 'add':
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
data: [...state.data, data],
|
data: [...state.data, request.data],
|
||||||
};
|
};
|
||||||
case 'remove':
|
case 'remove':
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -14,7 +14,10 @@ function replacer(key: string, value: unknown) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function stringifyJSON(data: unknown, serialize: boolean) {
|
export default function stringifyJSON(
|
||||||
|
data: unknown,
|
||||||
|
serialize: boolean | undefined
|
||||||
|
) {
|
||||||
return serialize
|
return serialize
|
||||||
? jsan.stringify(data, replacer, (null as unknown) as undefined, true)
|
? jsan.stringify(data, replacer, (null as unknown) as undefined, true)
|
||||||
: jsan.stringify(data);
|
: jsan.stringify(data);
|
||||||
|
|
|
@ -6,7 +6,9 @@ import { PerformAction } from 'redux-devtools-instrument';
|
||||||
export function recompute(
|
export function recompute(
|
||||||
previousLiftedState: State,
|
previousLiftedState: State,
|
||||||
storeState: State,
|
storeState: State,
|
||||||
action: Action<unknown>,
|
action:
|
||||||
|
| PerformAction<Action<unknown>>
|
||||||
|
| { action: Action<unknown>; timestamp?: number; stack?: string },
|
||||||
nextActionId = 1,
|
nextActionId = 1,
|
||||||
maxAge?: number,
|
maxAge?: number,
|
||||||
isExcess?: boolean
|
isExcess?: boolean
|
||||||
|
@ -22,15 +24,15 @@ export function recompute(
|
||||||
}
|
}
|
||||||
liftedState.stagedActionIds = [...liftedState.stagedActionIds, actionId];
|
liftedState.stagedActionIds = [...liftedState.stagedActionIds, actionId];
|
||||||
liftedState.actionsById = { ...liftedState.actionsById };
|
liftedState.actionsById = { ...liftedState.actionsById };
|
||||||
if (action.type === 'PERFORM_ACTION') {
|
if ((action as PerformAction<Action<unknown>>).type === 'PERFORM_ACTION') {
|
||||||
liftedState.actionsById[actionId] = action as PerformAction<
|
liftedState.actionsById[actionId] = action as PerformAction<
|
||||||
Action<unknown>
|
Action<unknown>
|
||||||
>;
|
>;
|
||||||
} else {
|
} else {
|
||||||
liftedState.actionsById[actionId] = {
|
liftedState.actionsById[actionId] = {
|
||||||
action: (action as any).action || action,
|
action: action.action || action,
|
||||||
timestamp: (action as any).timestamp || Date.now(),
|
timestamp: action.timestamp || Date.now(),
|
||||||
stack: (action as any).stack,
|
stack: action.stack,
|
||||||
type: 'PERFORM_ACTION',
|
type: 'PERFORM_ACTION',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,15 @@
|
||||||
const path = require('path');
|
import * as path from 'path';
|
||||||
const webpack = require('webpack');
|
import * as webpack from 'webpack';
|
||||||
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
import HtmlWebpackPlugin from 'html-webpack-plugin';
|
||||||
|
import ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin';
|
||||||
|
|
||||||
module.exports = (env = {}) => ({
|
module.exports = (env: { development?: boolean; platform?: string } = {}) => ({
|
||||||
mode: env.development ? 'development' : 'production',
|
mode: env.development ? 'development' : 'production',
|
||||||
entry: {
|
entry: {
|
||||||
app: './index.js',
|
app: './index',
|
||||||
},
|
},
|
||||||
output: {
|
output: {
|
||||||
path: path.resolve(__dirname, 'build/' + env.platform),
|
path: path.resolve(__dirname, `build/${env.platform as string}`),
|
||||||
publicPath: '',
|
publicPath: '',
|
||||||
filename: 'js/[name].js',
|
filename: 'js/[name].js',
|
||||||
sourceMapFilename: 'js/[name].map',
|
sourceMapFilename: 'js/[name].map',
|
||||||
|
@ -16,7 +17,7 @@ module.exports = (env = {}) => ({
|
||||||
module: {
|
module: {
|
||||||
rules: [
|
rules: [
|
||||||
{
|
{
|
||||||
test: /\.js$/,
|
test: /\.(js|ts)x?$/,
|
||||||
loader: 'babel-loader',
|
loader: 'babel-loader',
|
||||||
exclude: /node_modules/,
|
exclude: /node_modules/,
|
||||||
},
|
},
|
||||||
|
@ -44,6 +45,9 @@ module.exports = (env = {}) => ({
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
resolve: {
|
||||||
|
extensions: ['.js', '.jsx', '.ts', '.tsx'],
|
||||||
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
new webpack.DefinePlugin({
|
new webpack.DefinePlugin({
|
||||||
'process.env': {
|
'process.env': {
|
||||||
|
@ -56,6 +60,11 @@ module.exports = (env = {}) => ({
|
||||||
new HtmlWebpackPlugin({
|
new HtmlWebpackPlugin({
|
||||||
template: 'assets/index.html',
|
template: 'assets/index.html',
|
||||||
}),
|
}),
|
||||||
|
new ForkTsCheckerWebpackPlugin({
|
||||||
|
typescript: {
|
||||||
|
configFile: 'tsconfig.json',
|
||||||
|
},
|
||||||
|
}),
|
||||||
],
|
],
|
||||||
optimization: {
|
optimization: {
|
||||||
minimize: false,
|
minimize: false,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user