@git-diff-view/react 0.0.18 → 0.0.19
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.
- package/dist/cjs/index.development.js +108 -100
- package/dist/cjs/index.development.js.map +1 -1
- package/dist/cjs/index.production.js +108 -100
- package/dist/cjs/index.production.js.map +1 -1
- package/dist/css/diff-view.css +5 -6
- package/dist/esm/index.mjs +108 -100
- package/dist/esm/index.mjs.map +1 -1
- package/index.d.ts +23 -19
- package/package.json +3 -3
- package/readme.md +4 -0
package/index.d.ts
CHANGED
|
@@ -44,15 +44,15 @@ declare const lowlight: {
|
|
|
44
44
|
registered: (aliasOrName: string) => boolean;
|
|
45
45
|
};
|
|
46
46
|
export declare class DiffFile {
|
|
47
|
-
readonly _oldFileName: string;
|
|
48
|
-
readonly _newFileName: string;
|
|
49
|
-
readonly _diffList: string[];
|
|
50
47
|
readonly uuid?: string;
|
|
51
48
|
_version_: string;
|
|
49
|
+
_oldFileName: string;
|
|
52
50
|
_oldFileContent: string;
|
|
53
51
|
_oldFileLang: string;
|
|
52
|
+
_newFileName: string;
|
|
54
53
|
_newFileContent: string;
|
|
55
54
|
_newFileLang: string;
|
|
55
|
+
_diffList: string[];
|
|
56
56
|
diffLineLength: number;
|
|
57
57
|
splitLineLength: number;
|
|
58
58
|
unifiedLineLength: number;
|
|
@@ -60,19 +60,7 @@ export declare class DiffFile {
|
|
|
60
60
|
hasExpandSplitAll: boolean;
|
|
61
61
|
hasExpandUnifiedAll: boolean;
|
|
62
62
|
hasSomeLineCollapsed: boolean;
|
|
63
|
-
static createInstance(data:
|
|
64
|
-
oldFile?: {
|
|
65
|
-
fileName?: string | null;
|
|
66
|
-
fileLang?: string | null;
|
|
67
|
-
content?: string | null;
|
|
68
|
-
};
|
|
69
|
-
newFile?: {
|
|
70
|
-
fileName?: string | null;
|
|
71
|
-
fileLang?: string | null;
|
|
72
|
-
content?: string | null;
|
|
73
|
-
};
|
|
74
|
-
hunks?: string[];
|
|
75
|
-
}, bundle?: ReturnType<DiffFile["getBundle"] | DiffFile["_getFullBundle"]>): DiffFile;
|
|
63
|
+
static createInstance(data: FileData, bundle?: ReturnType<DiffFile["getBundle"] | DiffFile["_getFullBundle"]>): DiffFile;
|
|
76
64
|
constructor(_oldFileName: string, _oldFileContent: string, _newFileName: string, _newFileContent: string, _diffList: string[], _oldFileLang?: string, _newFileLang?: string, uuid?: string);
|
|
77
65
|
initId(): void;
|
|
78
66
|
getId(): string;
|
|
@@ -130,7 +118,7 @@ export declare class DiffFile {
|
|
|
130
118
|
theme: "light" | "dark";
|
|
131
119
|
isFullMerge: boolean;
|
|
132
120
|
};
|
|
133
|
-
mergeBundle: (data: ReturnType<DiffFile["getBundle"]
|
|
121
|
+
mergeBundle: (data: ReturnType<DiffFile["getBundle"]>, notifyUpdate?: boolean) => void;
|
|
134
122
|
_getHighlighterName: () => string;
|
|
135
123
|
_getIsPureDiffRender: () => boolean;
|
|
136
124
|
_getTheme: () => "light" | "dark";
|
|
@@ -169,7 +157,7 @@ export declare class DiffFile {
|
|
|
169
157
|
version: string;
|
|
170
158
|
theme: "light" | "dark";
|
|
171
159
|
};
|
|
172
|
-
_mergeFullBundle: (data: ReturnType<DiffFile["_getFullBundle"]
|
|
160
|
+
_mergeFullBundle: (data: ReturnType<DiffFile["_getFullBundle"]>, notifyUpdate?: boolean) => void;
|
|
173
161
|
_destroy: () => void;
|
|
174
162
|
clear: () => void;
|
|
175
163
|
}
|
|
@@ -360,7 +348,10 @@ export declare const HiddenBidiCharsRegex: RegExp;
|
|
|
360
348
|
export declare const _cacheMap: Cache$1<string, File$1>;
|
|
361
349
|
export declare const checkDiffLineIncludeChange: (diffLine?: DiffLine) => boolean;
|
|
362
350
|
export declare const composeLen = 40;
|
|
363
|
-
export declare const getDiffRange: (additions: DiffLine[], deletions: DiffLine[]
|
|
351
|
+
export declare const getDiffRange: (additions: DiffLine[], deletions: DiffLine[], { getAdditionRaw, getDeletionRaw, }: {
|
|
352
|
+
getAdditionRaw: (lineNumber: number) => string;
|
|
353
|
+
getDeletionRaw: (lineNumber: number) => string;
|
|
354
|
+
}) => void;
|
|
364
355
|
export declare const getFile: (raw: string, lang: string, theme: "light" | "dark", fileName?: string, uuid?: string) => File$1;
|
|
365
356
|
export declare const getLang: (fileName: string) => string;
|
|
366
357
|
export declare const getSplitContentLines: (diffFile: DiffFile) => DiffSplitContentLineItem[];
|
|
@@ -560,6 +551,19 @@ export type DiffUnifiedLineItem = {
|
|
|
560
551
|
index: number;
|
|
561
552
|
lineNumber: number;
|
|
562
553
|
};
|
|
554
|
+
export type FileData = {
|
|
555
|
+
oldFile?: {
|
|
556
|
+
fileName?: string | null;
|
|
557
|
+
fileLang?: string | null;
|
|
558
|
+
content?: string | null;
|
|
559
|
+
};
|
|
560
|
+
newFile?: {
|
|
561
|
+
fileName?: string | null;
|
|
562
|
+
fileLang?: string | null;
|
|
563
|
+
content?: string | null;
|
|
564
|
+
};
|
|
565
|
+
hunks?: string[];
|
|
566
|
+
};
|
|
563
567
|
export type HunkInfo = {
|
|
564
568
|
oldStartIndex: number;
|
|
565
569
|
newStartIndex: number;
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "@git-diff-view/react",
|
|
4
4
|
"author": "MrWangJustToDo",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"version": "0.0.
|
|
6
|
+
"version": "0.0.19",
|
|
7
7
|
"main": "index.js",
|
|
8
8
|
"types": "index.d.ts",
|
|
9
9
|
"files": [
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"react diff component"
|
|
58
58
|
],
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@git-diff-view/core": "^0.0.
|
|
60
|
+
"@git-diff-view/core": "^0.0.19",
|
|
61
61
|
"@types/hast": "^3.0.0",
|
|
62
62
|
"fast-diff": "^1.3.0",
|
|
63
63
|
"highlight.js": "^11.9.0",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"postcss-cli": "^11.0.0",
|
|
73
73
|
"postcss-import": "^16.1.0",
|
|
74
74
|
"react": "^18.0.0",
|
|
75
|
-
"tailwindcss": "^3.4.
|
|
75
|
+
"tailwindcss": "^3.4.14"
|
|
76
76
|
},
|
|
77
77
|
"peerDependencies": {
|
|
78
78
|
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
|
package/readme.md
CHANGED
|
@@ -23,6 +23,7 @@ import "@git-diff-view/react/styles/diff-view.css";
|
|
|
23
23
|
diffViewHighlight={boolean}
|
|
24
24
|
diffViewMode={DiffModeEnum.Split | DiffModeEnum.Unified}
|
|
25
25
|
diffViewWrap={boolean}
|
|
26
|
+
diffViewTheme={'light' | 'dark'}
|
|
26
27
|
diffViewAddWidget
|
|
27
28
|
onAddWidgetClick={({ side, lineNumber }) => void}
|
|
28
29
|
renderWidgetLine={({ onClose, side, lineNumber }) => ReactNode}
|
|
@@ -43,6 +44,7 @@ const file = generateDiffFile(
|
|
|
43
44
|
data?.oldFile?.fileLang || "",
|
|
44
45
|
data?.newFile?.fileLang || ""
|
|
45
46
|
);
|
|
47
|
+
file.initTheme('light' / 'dark');
|
|
46
48
|
file.init();
|
|
47
49
|
file.buildSplitDiffLines();
|
|
48
50
|
file.buildUnifiedDiffLines();
|
|
@@ -58,6 +60,7 @@ const file = new DiffFile(
|
|
|
58
60
|
data?.oldFile?.fileLang || "",
|
|
59
61
|
data?.newFile?.fileLang || ""
|
|
60
62
|
);
|
|
63
|
+
file.initTheme('light' / 'dark');
|
|
61
64
|
file.init();
|
|
62
65
|
file.buildSplitDiffLines();
|
|
63
66
|
file.buildUnifiedDiffLines();
|
|
@@ -83,6 +86,7 @@ const diffFile = DiffFile.createInstance(data || {}, bundle);
|
|
|
83
86
|
| diffViewHighlight | enable syntax highlight, type: boolean |
|
|
84
87
|
| diffViewMode | the mode for the DiffView component, type: `DiffModeEnum.Split` or `DiffModeEnum.Unified` |
|
|
85
88
|
| diffViewWrap | enable code line auto wrap, type: boolean |
|
|
89
|
+
| diffViewTheme | the theme for the DiffView component, type: `light` or `dark` |
|
|
86
90
|
| diffViewAddWidget| enable `addWidget` button, type: boolean |
|
|
87
91
|
| onAddWidgetClick | when the `addWidget` button clicked, type: `({ side: "old" | "new", lineNumber: number }) => void` |
|
|
88
92
|
|