@git-diff-view/react 0.0.17 → 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 +111 -104
- package/dist/cjs/index.development.js.map +1 -1
- package/dist/cjs/index.production.js +111 -104
- package/dist/cjs/index.production.js.map +1 -1
- package/dist/css/diff-view.css +5 -6
- package/dist/esm/index.mjs +111 -104
- package/dist/esm/index.mjs.map +1 -1
- package/index.d.ts +26 -20
- package/package.json +3 -3
- package/readme.md +4 -0
package/index.d.ts
CHANGED
|
@@ -18,7 +18,8 @@ declare class File$1 {
|
|
|
18
18
|
syntaxFile: Record<number, SyntaxLine>;
|
|
19
19
|
hasDoSyntax: boolean;
|
|
20
20
|
syntaxLength?: number;
|
|
21
|
-
highlighterName?:
|
|
21
|
+
highlighterName?: DiffHighlighter["name"];
|
|
22
|
+
highlighterType?: DiffHighlighter["type"];
|
|
22
23
|
maxLineNumber: number;
|
|
23
24
|
static createInstance(data: File$1): File$1;
|
|
24
25
|
constructor(raw: string, lang: string, fileName?: string);
|
|
@@ -43,15 +44,15 @@ declare const lowlight: {
|
|
|
43
44
|
registered: (aliasOrName: string) => boolean;
|
|
44
45
|
};
|
|
45
46
|
export declare class DiffFile {
|
|
46
|
-
readonly _oldFileName: string;
|
|
47
|
-
readonly _newFileName: string;
|
|
48
|
-
readonly _diffList: string[];
|
|
49
47
|
readonly uuid?: string;
|
|
50
48
|
_version_: string;
|
|
49
|
+
_oldFileName: string;
|
|
51
50
|
_oldFileContent: string;
|
|
52
51
|
_oldFileLang: string;
|
|
52
|
+
_newFileName: string;
|
|
53
53
|
_newFileContent: string;
|
|
54
54
|
_newFileLang: string;
|
|
55
|
+
_diffList: string[];
|
|
55
56
|
diffLineLength: number;
|
|
56
57
|
splitLineLength: number;
|
|
57
58
|
unifiedLineLength: number;
|
|
@@ -59,19 +60,7 @@ export declare class DiffFile {
|
|
|
59
60
|
hasExpandSplitAll: boolean;
|
|
60
61
|
hasExpandUnifiedAll: boolean;
|
|
61
62
|
hasSomeLineCollapsed: boolean;
|
|
62
|
-
static createInstance(data:
|
|
63
|
-
oldFile?: {
|
|
64
|
-
fileName?: string | null;
|
|
65
|
-
fileLang?: string | null;
|
|
66
|
-
content?: string | null;
|
|
67
|
-
};
|
|
68
|
-
newFile?: {
|
|
69
|
-
fileName?: string | null;
|
|
70
|
-
fileLang?: string | null;
|
|
71
|
-
content?: string | null;
|
|
72
|
-
};
|
|
73
|
-
hunks?: string[];
|
|
74
|
-
}, bundle?: ReturnType<DiffFile["getBundle"] | DiffFile["_getFullBundle"]>): DiffFile;
|
|
63
|
+
static createInstance(data: FileData, bundle?: ReturnType<DiffFile["getBundle"] | DiffFile["_getFullBundle"]>): DiffFile;
|
|
75
64
|
constructor(_oldFileName: string, _oldFileContent: string, _newFileName: string, _newFileContent: string, _diffList: string[], _oldFileLang?: string, _newFileLang?: string, uuid?: string);
|
|
76
65
|
initId(): void;
|
|
77
66
|
getId(): string;
|
|
@@ -129,7 +118,7 @@ export declare class DiffFile {
|
|
|
129
118
|
theme: "light" | "dark";
|
|
130
119
|
isFullMerge: boolean;
|
|
131
120
|
};
|
|
132
|
-
mergeBundle: (data: ReturnType<DiffFile["getBundle"]
|
|
121
|
+
mergeBundle: (data: ReturnType<DiffFile["getBundle"]>, notifyUpdate?: boolean) => void;
|
|
133
122
|
_getHighlighterName: () => string;
|
|
134
123
|
_getIsPureDiffRender: () => boolean;
|
|
135
124
|
_getTheme: () => "light" | "dark";
|
|
@@ -168,7 +157,7 @@ export declare class DiffFile {
|
|
|
168
157
|
version: string;
|
|
169
158
|
theme: "light" | "dark";
|
|
170
159
|
};
|
|
171
|
-
_mergeFullBundle: (data: ReturnType<DiffFile["_getFullBundle"]
|
|
160
|
+
_mergeFullBundle: (data: ReturnType<DiffFile["_getFullBundle"]>, notifyUpdate?: boolean) => void;
|
|
172
161
|
_destroy: () => void;
|
|
173
162
|
clear: () => void;
|
|
174
163
|
}
|
|
@@ -359,7 +348,10 @@ export declare const HiddenBidiCharsRegex: RegExp;
|
|
|
359
348
|
export declare const _cacheMap: Cache$1<string, File$1>;
|
|
360
349
|
export declare const checkDiffLineIncludeChange: (diffLine?: DiffLine) => boolean;
|
|
361
350
|
export declare const composeLen = 40;
|
|
362
|
-
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;
|
|
363
355
|
export declare const getFile: (raw: string, lang: string, theme: "light" | "dark", fileName?: string, uuid?: string) => File$1;
|
|
364
356
|
export declare const getLang: (fileName: string) => string;
|
|
365
357
|
export declare const getSplitContentLines: (diffFile: DiffFile) => DiffSplitContentLineItem[];
|
|
@@ -521,6 +513,7 @@ export interface UnifiedLineItem {
|
|
|
521
513
|
export type DiffAST = ReturnType<typeof lowlight.highlight>;
|
|
522
514
|
export type DiffHighlighter = {
|
|
523
515
|
name: string;
|
|
516
|
+
type: "class" | "style" | string;
|
|
524
517
|
maxLineToIgnoreSyntax: number;
|
|
525
518
|
setMaxLineToIgnoreSyntax: (v: number) => void;
|
|
526
519
|
ignoreSyntaxHighlightList: (string | RegExp)[];
|
|
@@ -558,6 +551,19 @@ export type DiffUnifiedLineItem = {
|
|
|
558
551
|
index: number;
|
|
559
552
|
lineNumber: number;
|
|
560
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
|
+
};
|
|
561
567
|
export type HunkInfo = {
|
|
562
568
|
oldStartIndex: number;
|
|
563
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
|
|