virtual-react-json-diff 1.0.14 → 1.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- import "./App.css";
2
1
  import "ace-builds/src-noconflict/mode-json";
3
2
  import "ace-builds/src-noconflict/theme-github_dark";
4
3
  import "ace-builds/src-noconflict/ext-language_tools";
4
+ import "./App.css";
5
5
  export default function App(): import("react/jsx-runtime").JSX.Element;
@@ -1,4 +1,5 @@
1
1
  import type { DifferOptions } from "json-diff-kit";
2
+ import type { CompareStrategy } from "virtual-react-json-diff";
2
3
  export type Config = {
3
4
  className: string;
4
5
  leftTitle: string;
@@ -6,6 +7,8 @@ export type Config = {
6
7
  miniMapWidth: number;
7
8
  hideSearch: boolean;
8
9
  height: number;
10
+ showLineCount: boolean;
11
+ showObjectCountStats: boolean;
9
12
  detectCircular: boolean;
10
13
  maxDepth: number;
11
14
  showModifications: boolean;
@@ -16,4 +19,7 @@ export type Config = {
16
19
  recursiveEqual: boolean;
17
20
  preserveKeyOrder: DifferOptions["preserveKeyOrder"];
18
21
  inlineDiffMode: "word" | "char";
22
+ ignorePaths: string;
23
+ ignoreKeys: string;
24
+ compareStrategy: CompareStrategy;
19
25
  };
@@ -0,0 +1,7 @@
1
+ import React from "react";
2
+ import type { LineCountStats } from "../types";
3
+ type LineCountDisplayProps = {
4
+ stats: LineCountStats;
5
+ };
6
+ export declare const LineCountDisplay: React.FC<LineCountDisplayProps>;
7
+ export default LineCountDisplay;
@@ -0,0 +1,7 @@
1
+ import React from "react";
2
+ import type { ObjectCountStats } from "../types";
3
+ type ObjectCountDisplayProps = {
4
+ stats: ObjectCountStats;
5
+ };
6
+ export declare const ObjectCountDisplay: React.FC<ObjectCountDisplayProps>;
7
+ export default ObjectCountDisplay;
@@ -5,5 +5,5 @@ type Props = {
5
5
  navigateMatch: (direction: "next" | "prev") => void;
6
6
  hideSearch?: boolean;
7
7
  };
8
- declare function SearchboxHolder({ searchState, handleSearch, navigateMatch, hideSearch }: Props): import("react/jsx-runtime").JSX.Element | null;
8
+ declare const SearchboxHolder: React.FC<Props>;
9
9
  export default SearchboxHolder;
@@ -12,15 +12,15 @@ type ListDataType = {
12
12
  type VirtualDiffGridProps = {
13
13
  leftDiff: DiffRowOrCollapsed[];
14
14
  rightDiff: DiffRowOrCollapsed[];
15
- listRef: React.RefObject<List<ListDataType>>;
15
+ listRef: React.RefObject<List<ListDataType> | null>;
16
16
  height: number;
17
17
  inlineDiffOptions?: InlineDiffOptions;
18
18
  className?: string;
19
19
  setScrollTop: Dispatch<React.SetStateAction<number>>;
20
20
  onExpand: (segmentIndex: number) => void;
21
21
  overScanCount?: number;
22
- viewerRef?: React.RefObject<HTMLDivElement>;
23
- listContainerRef?: React.RefObject<HTMLDivElement>;
22
+ viewerRef?: React.RefObject<HTMLDivElement | null>;
23
+ listContainerRef?: React.RefObject<HTMLDivElement | null>;
24
24
  };
25
25
  declare const VirtualDiffGrid: React.FC<VirtualDiffGridProps>;
26
26
  export default VirtualDiffGrid;
@@ -1,4 +1,6 @@
1
1
  import type { Differ, DifferOptions, DiffResult, InlineDiffOptions } from "json-diff-kit";
2
+ import type { CompareStrategy, DiffComparisonOptions } from "../utils/diffComparisonOptions";
3
+ export type { CompareStrategy, DiffComparisonOptions };
2
4
  export type DiffRow = {
3
5
  originalIndex: number;
4
6
  } & DiffResult;
@@ -27,6 +29,18 @@ export type SearchState = {
27
29
  results: number[];
28
30
  currentIndex: number;
29
31
  };
32
+ export type LineCountStats = {
33
+ added: number;
34
+ removed: number;
35
+ modified: number;
36
+ total: number;
37
+ };
38
+ export type ObjectCountStats = {
39
+ added: number;
40
+ removed: number;
41
+ modified: number;
42
+ total: number;
43
+ };
30
44
  export type VirtualizedDiffViewerProps = {
31
45
  oldValue: object;
32
46
  newValue: object;
@@ -44,6 +58,9 @@ export type VirtualizedDiffViewerProps = {
44
58
  miniMapWidth?: number;
45
59
  inlineDiffOptions?: InlineDiffOptions;
46
60
  overScanCount?: number;
61
+ showLineCount?: boolean;
62
+ showObjectCountStats?: boolean;
63
+ comparisonOptions?: DiffComparisonOptions;
47
64
  };
48
65
  export type DiffMinimapProps = {
49
66
  leftDiff: DiffRowOrCollapsed[];
@@ -0,0 +1,16 @@
1
+ export type CompareStrategy = "strict" | "loose" | "type-aware";
2
+ export type DiffComparisonOptions = {
3
+ ignorePaths?: string[];
4
+ ignoreKeys?: string[];
5
+ /**
6
+ * strict: default strict equality (===)
7
+ * loose: loose equality where reasonable
8
+ * type-aware: allows number/string equality like "1" === 1
9
+ */
10
+ compareStrategy?: CompareStrategy;
11
+ };
12
+ export declare function normalizeValue(value: any, strategy?: CompareStrategy): any;
13
+ /**
14
+ * returning new object with ignored paths/keys removed and values normalized
15
+ */
16
+ export declare function preprocessObjectForDiff(obj: any, options: DiffComparisonOptions): any;
@@ -1,10 +1,10 @@
1
1
  import type { InlineDiffOptions } from "json-diff-kit";
2
2
  import type { ListChildComponentProps } from "react-window";
3
3
  import type { DiffRowOrCollapsed } from "../../types";
4
- declare function RowRendererGrid({ index, style, data }: ListChildComponentProps<{
4
+ declare const RowRendererGrid: React.FC<ListChildComponentProps<{
5
5
  leftDiff: DiffRowOrCollapsed[];
6
6
  rightDiff: DiffRowOrCollapsed[];
7
7
  onExpand: (segmentIndex: number) => void;
8
8
  inlineDiffOptions?: InlineDiffOptions;
9
- }>): import("react/jsx-runtime").JSX.Element;
9
+ }>>;
10
10
  export default RowRendererGrid;
@@ -0,0 +1,3 @@
1
+ import type { DiffResult } from "json-diff-kit";
2
+ import type { LineCountStats } from "../types";
3
+ export declare function calculateLineCountStats(diffData: [DiffResult[], DiffResult[]]): LineCountStats;
@@ -0,0 +1,5 @@
1
+ import type { ObjectCountStats } from "../types";
2
+ /**
3
+ * Calculates object count statistics for compare-key method
4
+ */
5
+ export declare function calculateObjectCountStats(oldValue: any, newValue: any, compareKey: string): ObjectCountStats;
@@ -1 +1 @@
1
- export declare function SearchIcon(): import("react/jsx-runtime").JSX.Element;
1
+ export declare const SearchIcon: React.FC;
@@ -1,2 +1,4 @@
1
1
  export { default as VirtualDiffViewer } from "./components/DiffViewer";
2
+ export type { CompareStrategy, DiffComparisonOptions, } from "./components/DiffViewer/types";
3
+ export { calculateObjectCountStats } from "./components/DiffViewer/utils/objectCountUtils";
2
4
  export { Differ, type DiffResult } from "json-diff-kit";
package/dist/index.d.ts CHANGED
@@ -2,6 +2,24 @@ import React from 'react';
2
2
  import { DiffResult, DifferOptions, Differ, InlineDiffOptions } from 'json-diff-kit';
3
3
  export { DiffResult, Differ } from 'json-diff-kit';
4
4
 
5
+ type CompareStrategy = "strict" | "loose" | "type-aware";
6
+ type DiffComparisonOptions = {
7
+ ignorePaths?: string[];
8
+ ignoreKeys?: string[];
9
+ /**
10
+ * strict: default strict equality (===)
11
+ * loose: loose equality where reasonable
12
+ * type-aware: allows number/string equality like "1" === 1
13
+ */
14
+ compareStrategy?: CompareStrategy;
15
+ };
16
+
17
+ type ObjectCountStats = {
18
+ added: number;
19
+ removed: number;
20
+ modified: number;
21
+ total: number;
22
+ };
5
23
  type VirtualizedDiffViewerProps = {
6
24
  oldValue: object;
7
25
  newValue: object;
@@ -19,8 +37,16 @@ type VirtualizedDiffViewerProps = {
19
37
  miniMapWidth?: number;
20
38
  inlineDiffOptions?: InlineDiffOptions;
21
39
  overScanCount?: number;
40
+ showLineCount?: boolean;
41
+ showObjectCountStats?: boolean;
42
+ comparisonOptions?: DiffComparisonOptions;
22
43
  };
23
44
 
24
45
  declare const VirtualizedDiffViewer: React.FC<VirtualizedDiffViewerProps>;
25
46
 
26
- export { VirtualizedDiffViewer as VirtualDiffViewer };
47
+ /**
48
+ * Calculates object count statistics for compare-key method
49
+ */
50
+ declare function calculateObjectCountStats(oldValue: any, newValue: any, compareKey: string): ObjectCountStats;
51
+
52
+ export { CompareStrategy, DiffComparisonOptions, VirtualizedDiffViewer as VirtualDiffViewer, calculateObjectCountStats };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "virtual-react-json-diff",
3
3
  "type": "module",
4
- "version": "1.0.14",
4
+ "version": "1.0.16",
5
5
  "description": "Fast, virtualized React component for visually comparing large JSON objects. Includes search, theming, and minimap.",
6
6
  "author": {
7
7
  "name": "Utku Akyüz"
@@ -50,6 +50,7 @@
50
50
  "react": ">=18.0.0"
51
51
  },
52
52
  "dependencies": {
53
+ "fast-myers-diff": "^3.2.0",
53
54
  "json-diff-kit": "^1.0.32",
54
55
  "react-window": "^1.8.11"
55
56
  },
@@ -85,6 +86,7 @@
85
86
  "pre-commit": "pnpm lint-staged"
86
87
  },
87
88
  "lint-staged": {
88
- "*.{js,jsx,ts,tsx,vue,html,md,json,yaml,css,scss}": "eslint --fix"
89
+ "*.{js,jsx,ts,tsx,vue,html,json,yaml,css,scss}": "eslint --fix",
90
+ "*.md": "echo 'Skipping markdown files in lint-staged'"
89
91
  }
90
92
  }
@@ -1,2 +0,0 @@
1
- declare const _default: import("vite").UserConfig;
2
- export default _default;
@@ -1,11 +0,0 @@
1
- import type { InlineDiffOptions } from "json-diff-kit";
2
- import type { ListChildComponentProps } from "react-window";
3
- import type { DiffRowOrCollapsed } from "../types";
4
- declare function ViewerRow({ index, style, data, }: ListChildComponentProps<{
5
- leftDiff: DiffRowOrCollapsed[];
6
- rightDiff: DiffRowOrCollapsed[];
7
- onExpand: (segmentIndex: number) => void;
8
- searchTerm?: string;
9
- inlineDiffOptions?: InlineDiffOptions;
10
- }>): import("react/jsx-runtime").JSX.Element;
11
- export default ViewerRow;
@@ -1,19 +0,0 @@
1
- import type { InlineDiffOptions } from "json-diff-kit";
2
- import type { Dispatch } from "react";
3
- import React from "react";
4
- import { VariableSizeList as List } from "react-window";
5
- import type { DiffRowOrCollapsed } from "../types";
6
- type VirtualDiffTableProps = {
7
- leftDiff: DiffRowOrCollapsed[];
8
- rightDiff: DiffRowOrCollapsed[];
9
- outerRef: React.RefObject<Node | null>;
10
- listRef: React.RefObject<List<any>>;
11
- height: number;
12
- inlineDiffOptions?: InlineDiffOptions;
13
- className?: string;
14
- style?: React.CSSProperties;
15
- setScrollTop: Dispatch<React.SetStateAction<number>>;
16
- onExpand: (segmentIndex: number) => void;
17
- };
18
- declare const VirtualDiffTable: React.FC<VirtualDiffTableProps>;
19
- export default VirtualDiffTable;
@@ -1,10 +0,0 @@
1
- import type { InlineDiffOptions } from "json-diff-kit";
2
- import type { ListChildComponentProps } from "react-window";
3
- import type { DiffRowOrCollapsed } from "../../types";
4
- declare function RowRenderer({ index, style, data }: ListChildComponentProps<{
5
- leftDiff: DiffRowOrCollapsed[];
6
- rightDiff: DiffRowOrCollapsed[];
7
- onExpand: (segmentIndex: number) => void;
8
- inlineDiffOptions?: InlineDiffOptions;
9
- }>): import("react/jsx-runtime").JSX.Element;
10
- export default RowRenderer;