virtual-react-json-diff 1.0.15 → 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;
@@ -18,4 +19,7 @@ export type Config = {
18
19
  recursiveEqual: boolean;
19
20
  preserveKeyOrder: DifferOptions["preserveKeyOrder"];
20
21
  inlineDiffMode: "word" | "char";
22
+ ignorePaths: string;
23
+ ignoreKeys: string;
24
+ compareStrategy: CompareStrategy;
21
25
  };
@@ -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;
@@ -58,6 +60,7 @@ export type VirtualizedDiffViewerProps = {
58
60
  overScanCount?: number;
59
61
  showLineCount?: boolean;
60
62
  showObjectCountStats?: boolean;
63
+ comparisonOptions?: DiffComparisonOptions;
61
64
  };
62
65
  export type DiffMinimapProps = {
63
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;
@@ -1 +1 @@
1
- export declare function SearchIcon(): import("react/jsx-runtime").JSX.Element;
1
+ export declare const SearchIcon: React.FC;
@@ -1,3 +1,4 @@
1
1
  export { default as VirtualDiffViewer } from "./components/DiffViewer";
2
+ export type { CompareStrategy, DiffComparisonOptions, } from "./components/DiffViewer/types";
2
3
  export { calculateObjectCountStats } from "./components/DiffViewer/utils/objectCountUtils";
3
4
  export { Differ, type DiffResult } from "json-diff-kit";
package/dist/index.d.ts CHANGED
@@ -2,6 +2,18 @@ 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
+
5
17
  type ObjectCountStats = {
6
18
  added: number;
7
19
  removed: number;
@@ -27,6 +39,7 @@ type VirtualizedDiffViewerProps = {
27
39
  overScanCount?: number;
28
40
  showLineCount?: boolean;
29
41
  showObjectCountStats?: boolean;
42
+ comparisonOptions?: DiffComparisonOptions;
30
43
  };
31
44
 
32
45
  declare const VirtualizedDiffViewer: React.FC<VirtualizedDiffViewerProps>;
@@ -36,4 +49,4 @@ declare const VirtualizedDiffViewer: React.FC<VirtualizedDiffViewerProps>;
36
49
  */
37
50
  declare function calculateObjectCountStats(oldValue: any, newValue: any, compareKey: string): ObjectCountStats;
38
51
 
39
- export { VirtualizedDiffViewer as VirtualDiffViewer, calculateObjectCountStats };
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.15",
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
  },
@@ -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;