diff --git a/extension/jest.config.js b/extension/jest.config.js index a5d16b18..691b3b04 100644 --- a/extension/jest.config.js +++ b/extension/jest.config.js @@ -6,6 +6,6 @@ module.exports = { '\\.css$': '/test/__mocks__/styleMock.ts', }, transformIgnorePatterns: [ - 'node_modules/(?!.pnpm|@babel/code-frame|@babel/highlight|@babel/helper-validator-identifier|chalk|d3|dateformat|delaunator|internmap|nanoid|robust-predicates|uuid)', + 'node_modules/(?!.pnpm|@babel/code-frame|@babel/highlight|@babel/helper-validator-identifier|chalk|d3|dateformat|delaunator|internmap|jsondiffpatch|nanoid|robust-predicates|uuid)', ], }; diff --git a/packages/redux-devtools-app/jest.config.js b/packages/redux-devtools-app/jest.config.js index 50a28875..064e6f6e 100644 --- a/packages/redux-devtools-app/jest.config.js +++ b/packages/redux-devtools-app/jest.config.js @@ -10,6 +10,6 @@ module.exports = { '^.+\\.tsx?$': ['ts-jest', { tsconfig: 'tsconfig.test.json' }], }, transformIgnorePatterns: [ - 'node_modules/(?!.pnpm|@babel/code-frame|@babel/highlight|@babel/helper-validator-identifier|chalk|d3|dateformat|delaunator|internmap|nanoid|robust-predicates|uuid)', + 'node_modules/(?!.pnpm|@babel/code-frame|@babel/highlight|@babel/helper-validator-identifier|chalk|d3|dateformat|delaunator|internmap|jsondiffpatch|nanoid|robust-predicates|uuid)', ], }; diff --git a/packages/redux-devtools-app/package.json b/packages/redux-devtools-app/package.json index b6244aee..350d7968 100644 --- a/packages/redux-devtools-app/package.json +++ b/packages/redux-devtools-app/package.json @@ -54,7 +54,7 @@ "d3-state-visualizer": "^2.0.0", "javascript-stringify": "^2.1.0", "jsan": "^3.1.14", - "jsondiffpatch": "^0.5.0", + "jsondiffpatch": "^0.6.0", "localforage": "^1.10.0", "lodash": "^4.17.21", "react-icons": "^5.0.1", diff --git a/packages/redux-devtools-app/src/containers/monitors/InspectorWrapper/SubTabs.tsx b/packages/redux-devtools-app/src/containers/monitors/InspectorWrapper/SubTabs.tsx index e5ae3c3d..6b1f0513 100644 --- a/packages/redux-devtools-app/src/containers/monitors/InspectorWrapper/SubTabs.tsx +++ b/packages/redux-devtools-app/src/containers/monitors/InspectorWrapper/SubTabs.tsx @@ -13,7 +13,7 @@ import RawTab from './RawTab'; import ChartTab from './ChartTab'; import VisualDiffTab from './VisualDiffTab'; import { StoreState } from '../../../reducers'; -import { Delta } from 'jsondiffpatch'; +import type { Delta } from 'jsondiffpatch'; type StateProps = ReturnType; type DispatchProps = ResolveThunks; diff --git a/packages/redux-devtools-app/src/containers/monitors/InspectorWrapper/VisualDiffTab.tsx b/packages/redux-devtools-app/src/containers/monitors/InspectorWrapper/VisualDiffTab.tsx index f9296bb9..8fe54ee6 100644 --- a/packages/redux-devtools-app/src/containers/monitors/InspectorWrapper/VisualDiffTab.tsx +++ b/packages/redux-devtools-app/src/containers/monitors/InspectorWrapper/VisualDiffTab.tsx @@ -1,5 +1,6 @@ import React, { Component } from 'react'; -import { Delta, formatters } from 'jsondiffpatch'; +import type { Delta } from 'jsondiffpatch'; +import * as htmlFormatter from 'jsondiffpatch/formatters/html'; import styled, { ThemedStyledProps } from 'styled-components'; import { effects, Theme } from '@redux-devtools/ui'; @@ -240,7 +241,7 @@ export default class VisualDiffTab extends Component { let __html: string | undefined; const data = this.props.data; if (data) { - __html = formatters.html.format(data, undefined); + __html = htmlFormatter.format(data, undefined); } return ; diff --git a/packages/redux-devtools-inspector-monitor/package.json b/packages/redux-devtools-inspector-monitor/package.json index fffc78ea..ae1c4566 100644 --- a/packages/redux-devtools-inspector-monitor/package.json +++ b/packages/redux-devtools-inspector-monitor/package.json @@ -46,7 +46,7 @@ "hex-rgba": "^1.0.2", "immutable": "^4.3.4", "javascript-stringify": "^2.1.0", - "jsondiffpatch": "^0.5.0", + "jsondiffpatch": "^0.6.0", "lodash.debounce": "^4.0.8", "react-base16-styling": "^0.9.1", "react-json-tree": "^0.18.0", diff --git a/packages/redux-devtools-inspector-monitor/src/ActionPreview.tsx b/packages/redux-devtools-inspector-monitor/src/ActionPreview.tsx index f233f0fa..3427fb2d 100644 --- a/packages/redux-devtools-inspector-monitor/src/ActionPreview.tsx +++ b/packages/redux-devtools-inspector-monitor/src/ActionPreview.tsx @@ -3,7 +3,7 @@ import { Base16Theme } from 'redux-devtools-themes'; import { Action } from 'redux'; import type { LabelRenderer } from 'react-json-tree'; import { PerformAction } from '@redux-devtools/core'; -import { Delta } from 'jsondiffpatch'; +import type { Delta } from 'jsondiffpatch'; import type { JSX } from '@emotion/react/jsx-runtime'; import { DEFAULT_STATE, DevtoolsInspectorState } from './redux'; import ActionPreviewHeader from './ActionPreviewHeader'; diff --git a/packages/redux-devtools-inspector-monitor/src/DevtoolsInspector.tsx b/packages/redux-devtools-inspector-monitor/src/DevtoolsInspector.tsx index a2914ec4..0ec2d40d 100644 --- a/packages/redux-devtools-inspector-monitor/src/DevtoolsInspector.tsx +++ b/packages/redux-devtools-inspector-monitor/src/DevtoolsInspector.tsx @@ -6,7 +6,7 @@ import { LiftedState, } from '@redux-devtools/core'; import { Action, Dispatch } from 'redux'; -import { Delta, DiffContext } from 'jsondiffpatch'; +import type { Delta, DiffContext } from 'jsondiffpatch'; import { createInspectorMonitorThemeFromBase16Theme, resolveBase16Theme, @@ -154,7 +154,7 @@ export interface DevtoolsInspectorProps> select: (state: S) => unknown; theme: Base16ThemeName | Base16Theme; supportImmutable: boolean; - diffObjectHash?: (item: unknown, index: number) => string; + diffObjectHash?: (item: unknown, index: number | undefined) => string; diffPropertyFilter?: (name: string, context: DiffContext) => boolean; hideMainButtons?: boolean; hideActionButtons?: boolean; diff --git a/packages/redux-devtools-inspector-monitor/src/createDiffPatcher.ts b/packages/redux-devtools-inspector-monitor/src/createDiffPatcher.ts index a98c342a..5e19352f 100644 --- a/packages/redux-devtools-inspector-monitor/src/createDiffPatcher.ts +++ b/packages/redux-devtools-inspector-monitor/src/createDiffPatcher.ts @@ -1,14 +1,19 @@ -import { DiffContext, DiffPatcher } from 'jsondiffpatch'; +import { DiffPatcher } from 'jsondiffpatch'; +import type { DiffContext } from 'jsondiffpatch'; -const defaultObjectHash = (o: any, idx: number) => - (o === null && '$$null') || - (o && (o.id || o.id === 0) && `$$id:${JSON.stringify(o.id)}`) || - (o && (o._id || o._id === 0) && `$$_id:${JSON.stringify(o._id)}`) || - `$$index:${idx}`; +const defaultObjectHash = (obj: object, idx: number | undefined) => { + const o = obj as Record; + return ( + (o === null && '$$null') || + (o && (o.id || o.id === 0) && `$$id:${JSON.stringify(o.id)}`) || + (o && (o._id || o._id === 0) && `$$_id:${JSON.stringify(o._id)}`) || + `$$index:${idx}` + ); +}; const defaultPropertyFilter = (name: string, context: DiffContext) => - typeof context.left[name] !== 'function' && - typeof context.right[name] !== 'function'; + typeof (context.left as Record)[name] !== 'function' && + typeof (context.right as Record)[name] !== 'function'; const defaultDiffPatcher = new DiffPatcher({ arrays: { detectMove: false } as { @@ -20,7 +25,9 @@ const defaultDiffPatcher = new DiffPatcher({ }); export default function createDiffPatcher( - objectHash: ((item: unknown, index: number) => string) | undefined, + objectHash: + | ((item: unknown, index: number | undefined) => string) + | undefined, propertyFilter: ((name: string, context: DiffContext) => boolean) | undefined, ) { if (!objectHash && !propertyFilter) { diff --git a/packages/redux-devtools-inspector-monitor/src/tabs/JSONDiff.tsx b/packages/redux-devtools-inspector-monitor/src/tabs/JSONDiff.tsx index aee6acdc..c229a336 100644 --- a/packages/redux-devtools-inspector-monitor/src/tabs/JSONDiff.tsx +++ b/packages/redux-devtools-inspector-monitor/src/tabs/JSONDiff.tsx @@ -2,7 +2,7 @@ import React, { Component } from 'react'; import { JSONTree } from 'react-json-tree'; import type { LabelRenderer, ShouldExpandNodeInitially } from 'react-json-tree'; import { stringify } from 'javascript-stringify'; -import { Delta } from 'jsondiffpatch'; +import type { Delta } from 'jsondiffpatch'; import { Base16Theme } from 'redux-devtools-themes'; import { css } from '@emotion/react'; import type { Interpolation, Theme } from '@emotion/react'; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a21bfe6c..ec2bc0e6 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1043,8 +1043,8 @@ importers: specifier: ^3.1.14 version: 3.1.14 jsondiffpatch: - specifier: ^0.5.0 - version: 0.5.0 + specifier: ^0.6.0 + version: 0.6.0 localforage: specifier: ^1.10.0 version: 1.10.0 @@ -1612,8 +1612,8 @@ importers: specifier: ^2.1.0 version: 2.1.0 jsondiffpatch: - specifier: ^0.5.0 - version: 0.5.0 + specifier: ^0.6.0 + version: 0.6.0 lodash.debounce: specifier: ^4.0.8 version: 4.0.8 @@ -10064,6 +10064,10 @@ packages: resolution: {integrity: sha512-Rf3/lB9WkDfIL9eEKaSYKc+1L/rNVYBjThk22JTqQw0YozXarX8YljFAz+HCoC6h4B4KwCMsBPZHaFezwT4BNA==} dev: true + /@types/diff-match-patch@1.0.36: + resolution: {integrity: sha512-xFdR6tkm0MWvBfO8xXCSsinYxHcqkQUlcHeSpMC2ukzOb6lwQAfDmW+Qt0AvlGd8HpsS28qKsB+oPeJn9I39jg==} + dev: false + /@types/doctrine@0.0.3: resolution: {integrity: sha512-w5jZ0ee+HaPOaX25X2/2oGR/7rgAQSYII7X7pp0m9KgBfMP7uKfMfTvcpl5Dj+eDBbpxKGiqE+flqDr6XTd2RA==} dev: true @@ -12019,6 +12023,7 @@ packages: dependencies: ansi-styles: 4.3.0 supports-color: 7.2.0 + dev: true /chalk@4.1.2: resolution: {integrity: sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==} @@ -16477,15 +16482,15 @@ packages: resolution: {integrity: sha512-gfFQZrcTc8CnKXp6Y4/CBT3fTc0OVuDofpre4aEeEpSBPV5X5v4+Vmx+8snU7RLPrNHPKSgLxGo9YuQzz20o+w==} dev: true - /jsondiffpatch@0.5.0: - resolution: {integrity: sha512-Quz3MvAwHxVYNXsOByL7xI5EB2WYOeFswqaHIA3qOK3isRWTxiplBEocmmru6XmxDB2L7jDNYtYA4FyimoAFEw==} - engines: {node: '>=8.17.0'} + /jsondiffpatch@0.6.0: + resolution: {integrity: sha512-3QItJOXp2AP1uv7waBkao5nCvhEv+QmJAd38Ybq7wNI74Q+BBmnLn4EDKz6yI9xGAIQoUF87qHt+kc1IVxB4zQ==} + engines: {node: ^18.0.0 || >=20.0.0} hasBin: true dependencies: - chalk: 3.0.0 + '@types/diff-match-patch': 1.0.36 + chalk: 5.3.0 diff-match-patch: 1.0.5 dev: false - bundledDependencies: [] /jsonfile@4.0.0: resolution: {integrity: sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==} diff --git a/renovate.json b/renovate.json index 3d4a4744..928efef8 100644 --- a/renovate.json +++ b/renovate.json @@ -22,11 +22,6 @@ "matchUpdateTypes": ["major", "minor"], "groupName": "source-map" }, - { - "matchPackageNames": ["jsondiffpatch"], - "matchUpdateTypes": ["major", "minor"], - "groupName": "jsondiffpatch" - }, { "matchPackageNames": ["msw"], "groupName": "msw" @@ -40,16 +35,6 @@ ], "matchUpdateTypes": ["major"], "groupName": "redux" - }, - { - "matchPackageNames": [ - "socketcluster-client", - "@types/socketcluster-client", - "socketcluster-server", - "@types/socketcluster-server" - ], - "matchUpdateTypes": ["major"], - "groupName": "socketcluster" } ] }