@git-diff-view/react 0.0.20 → 0.0.21
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 +44 -31
- package/dist/cjs/index.development.js.map +1 -1
- package/dist/cjs/index.production.js +44 -31
- package/dist/cjs/index.production.js.map +1 -1
- package/dist/css/diff-view.css +1 -1
- package/dist/esm/index.mjs +44 -31
- package/dist/esm/index.mjs.map +1 -1
- package/index.d.ts +72 -15
- package/package.json +7 -5
- package/readme.md +10 -2
package/index.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ declare class Cache$1<K, V> extends Map<K, V> {
|
|
|
9
9
|
}
|
|
10
10
|
declare class File$1 {
|
|
11
11
|
readonly raw: string;
|
|
12
|
-
readonly lang: string;
|
|
12
|
+
readonly lang: DiffHighlighterLang | string;
|
|
13
13
|
readonly fileName?: string;
|
|
14
14
|
ast?: DiffAST;
|
|
15
15
|
rawFile: Record<number, string>;
|
|
@@ -22,7 +22,8 @@ declare class File$1 {
|
|
|
22
22
|
highlighterType?: DiffHighlighter["type"];
|
|
23
23
|
maxLineNumber: number;
|
|
24
24
|
static createInstance(data: File$1): File$1;
|
|
25
|
-
constructor(
|
|
25
|
+
constructor(row: string, lang: DiffHighlighterLang, fileName?: string);
|
|
26
|
+
constructor(row: string, lang: string, fileName?: string);
|
|
26
27
|
doSyntax({ registerHighlighter, theme, }: {
|
|
27
28
|
registerHighlighter?: Omit<DiffHighlighter, "getHighlighterEngine">;
|
|
28
29
|
theme?: "light" | "dark";
|
|
@@ -48,10 +49,10 @@ export declare class DiffFile {
|
|
|
48
49
|
_version_: string;
|
|
49
50
|
_oldFileName: string;
|
|
50
51
|
_oldFileContent: string;
|
|
51
|
-
_oldFileLang: string;
|
|
52
|
+
_oldFileLang: DiffHighlighterLang | string;
|
|
52
53
|
_newFileName: string;
|
|
53
54
|
_newFileContent: string;
|
|
54
|
-
_newFileLang: string;
|
|
55
|
+
_newFileLang: DiffHighlighterLang | string;
|
|
55
56
|
_diffList: string[];
|
|
56
57
|
diffLineLength: number;
|
|
57
58
|
splitLineLength: number;
|
|
@@ -60,7 +61,9 @@ export declare class DiffFile {
|
|
|
60
61
|
hasExpandSplitAll: boolean;
|
|
61
62
|
hasExpandUnifiedAll: boolean;
|
|
62
63
|
hasSomeLineCollapsed: boolean;
|
|
63
|
-
static createInstance(data:
|
|
64
|
+
static createInstance(data: FileData_1, bundle?: ReturnType<DiffFile["getBundle"] | DiffFile["_getFullBundle"]>): DiffFile;
|
|
65
|
+
static createInstance(data: FileData_2, bundle?: ReturnType<DiffFile["getBundle"] | DiffFile["_getFullBundle"]>): DiffFile;
|
|
66
|
+
constructor(_oldFileName: string, _oldFileContent: string, _newFileName: string, _newFileContent: string, _diffList: string[], _oldFileLang?: DiffHighlighterLang, _newFileLang?: DiffHighlighterLang, uuid?: string);
|
|
64
67
|
constructor(_oldFileName: string, _oldFileContent: string, _newFileName: string, _newFileContent: string, _diffList: string[], _oldFileLang?: string, _newFileLang?: string, uuid?: string);
|
|
65
68
|
initId(): void;
|
|
66
69
|
getId(): string;
|
|
@@ -352,7 +355,6 @@ export declare const getDiffRange: (additions: DiffLine[], deletions: DiffLine[]
|
|
|
352
355
|
getAdditionRaw: (lineNumber: number) => string;
|
|
353
356
|
getDeletionRaw: (lineNumber: number) => string;
|
|
354
357
|
}) => void;
|
|
355
|
-
export declare const getFile: (raw: string, lang: string, theme: "light" | "dark", fileName?: string, uuid?: string) => File$1;
|
|
356
358
|
export declare const getLang: (fileName: string) => string;
|
|
357
359
|
export declare const getSplitContentLines: (diffFile: DiffFile) => DiffSplitContentLineItem[];
|
|
358
360
|
export declare const getSplitLines: (diffFile: DiffFile) => DiffSplitLineItem[];
|
|
@@ -405,13 +407,18 @@ export declare enum NewLineSymbol {
|
|
|
405
407
|
CR = 2,
|
|
406
408
|
LF = 3,
|
|
407
409
|
NEWLINE = 4,
|
|
408
|
-
NORMAL = 5
|
|
410
|
+
NORMAL = 5,
|
|
411
|
+
NULL = 6
|
|
409
412
|
}
|
|
413
|
+
export declare function _getAST(raw: string, fileName?: string, lang?: DiffHighlighterLang, theme?: "light" | "dark"): DiffAST;
|
|
414
|
+
export declare function _getAST(raw: string, fileName?: string, lang?: string, theme?: "light" | "dark"): DiffAST;
|
|
410
415
|
export declare function assertNever(_: never, message: string): never;
|
|
411
416
|
export declare function diffChanges(addition: DiffLine, deletion: DiffLine): {
|
|
412
417
|
addRange: DiffRange;
|
|
413
418
|
delRange: DiffRange;
|
|
414
419
|
};
|
|
420
|
+
export declare function getFile(raw: string, lang: DiffHighlighterLang, theme: "light" | "dark", fileName?: string, uuid?: string): File$1;
|
|
421
|
+
export declare function getFile(raw: string, lang: string, theme: "light" | "dark", fileName?: string, uuid?: string): File$1;
|
|
415
422
|
/**
|
|
416
423
|
* Calculates whether or not a hunk header can be expanded up, down, both, or if
|
|
417
424
|
* the space represented by the hunk header is short and expansion there would
|
|
@@ -518,7 +525,7 @@ export type DiffHighlighter = {
|
|
|
518
525
|
setMaxLineToIgnoreSyntax: (v: number) => void;
|
|
519
526
|
ignoreSyntaxHighlightList: (string | RegExp)[];
|
|
520
527
|
setIgnoreSyntaxHighlightList: (v: (string | RegExp)[]) => void;
|
|
521
|
-
getAST:
|
|
528
|
+
getAST: typeof _getAST;
|
|
522
529
|
processAST: (ast: DiffAST) => {
|
|
523
530
|
syntaxFileObject: Record<number, SyntaxLine>;
|
|
524
531
|
syntaxFileLineNumber: number;
|
|
@@ -526,6 +533,7 @@ export type DiffHighlighter = {
|
|
|
526
533
|
hasRegisteredCurrentLang: (lang: string) => boolean;
|
|
527
534
|
getHighlighterEngine: () => typeof lowlight;
|
|
528
535
|
};
|
|
536
|
+
export type DiffHighlighterLang = "arduino" | "bash" | "c" | "cpp" | "csharp" | "css" | "diff" | "go" | "graphql" | "ini" | "java" | "javascript" | "js" | "jsx" | "json" | "kotlin" | "less" | "lua" | "makefile" | "markdown" | "objectivec" | "perl" | "php" | "php-template" | "plaintext" | "python" | "python-repl" | "r" | "ruby" | "rust" | "scss" | "shell" | "sql" | "swift" | "typescript" | "ts" | "tsx" | "vbnet" | "wasm" | "xml" | "yaml" | "abnf" | "accesslog" | "actionscript" | "ada" | "angelscript" | "apache" | "applescript" | "arcade" | "armasm" | "asciidoc" | "aspectj" | "autohotkey" | "autoit" | "avrasm" | "awk" | "axapta" | "basic" | "bnf" | "brainfuck" | "cal" | "capnproto" | "ceylon" | "clean" | "clojure" | "clojure-repl" | "cmake" | "coffeescript" | "coq" | "cos" | "crmsh" | "crystal" | "csp" | "d" | "dart" | "delphi" | "django" | "dns" | "dockerfile" | "dos" | "dsconfig" | "dts" | "dust" | "ebnf" | "elixir" | "elm" | "erb" | "erlang" | "erlang-repl" | "excel" | "fix" | "flix" | "fortran" | "fsharp" | "gams" | "gauss" | "gcode" | "gherkin" | "glsl" | "gml" | "golo" | "gradle" | "groovy" | "haml" | "handlebars" | "haskell" | "haxe" | "hsp" | "http" | "hy" | "inform7" | "irpf90" | "isbl" | "jboss-cli" | "julia" | "julia-repl" | "lasso" | "latex" | "ldif" | "leaf" | "lisp" | "livecodeserver" | "livescript" | "llvm" | "lsl" | "mathematica" | "matlab" | "maxima" | "mel" | "mercury" | "mipsasm" | "mizar" | "mojolicious" | "monkey" | "moonscript" | "n1ql" | "nestedtext" | "nginx" | "nim" | "nix" | "node-repl" | "nsis" | "ocaml" | "openscad" | "oxygene" | "parser3" | "pf" | "pgsql" | "pony" | "powershell" | "processing" | "profile" | "prolog" | "properties" | "protobuf" | "puppet" | "purebasic" | "q" | "qml" | "reasonml" | "rib" | "roboconf" | "routeros" | "rsl" | "ruleslanguage" | "sas" | "scala" | "scheme" | "scilab" | "smali" | "smalltalk" | "sml" | "sqf" | "stan" | "stata" | "step21" | "stylus" | "subunit" | "taggerscript" | "tap" | "tcl" | "thrift" | "tp" | "twig" | "vala" | "vbscript" | "vbscript-html" | "verilog" | "vhdl" | "vim" | "wren" | "x86asm" | "xl" | "xquery" | "zephi" | "vue" | "vue-html";
|
|
529
537
|
export type DiffSplitContentLineItem = {
|
|
530
538
|
type: DiffFileLineType.content;
|
|
531
539
|
index: number;
|
|
@@ -551,7 +559,20 @@ export type DiffUnifiedLineItem = {
|
|
|
551
559
|
index: number;
|
|
552
560
|
lineNumber: number;
|
|
553
561
|
};
|
|
554
|
-
export type
|
|
562
|
+
export type FileData_1 = {
|
|
563
|
+
oldFile?: {
|
|
564
|
+
fileName?: string | null;
|
|
565
|
+
fileLang?: DiffHighlighterLang | null;
|
|
566
|
+
content?: string | null;
|
|
567
|
+
};
|
|
568
|
+
newFile?: {
|
|
569
|
+
fileName?: string | null;
|
|
570
|
+
fileLang?: DiffHighlighterLang | null;
|
|
571
|
+
content?: string | null;
|
|
572
|
+
};
|
|
573
|
+
hunks?: string[];
|
|
574
|
+
};
|
|
575
|
+
export type FileData_2 = {
|
|
555
576
|
oldFile?: {
|
|
556
577
|
fileName?: string | null;
|
|
557
578
|
fileLang?: string | null;
|
|
@@ -727,12 +748,12 @@ export type DiffViewProps<T> = {
|
|
|
727
748
|
data?: {
|
|
728
749
|
oldFile?: {
|
|
729
750
|
fileName?: string | null;
|
|
730
|
-
fileLang?: string | null;
|
|
751
|
+
fileLang?: DiffHighlighterLang | string | null;
|
|
731
752
|
content?: string | null;
|
|
732
753
|
};
|
|
733
754
|
newFile?: {
|
|
734
755
|
fileName?: string | null;
|
|
735
|
-
fileLang?: string | null;
|
|
756
|
+
fileLang?: DiffHighlighterLang | string | null;
|
|
736
757
|
content?: string | null;
|
|
737
758
|
};
|
|
738
759
|
hunks: string[];
|
|
@@ -774,13 +795,49 @@ export type DiffViewProps<T> = {
|
|
|
774
795
|
}) => ReactNode;
|
|
775
796
|
onAddWidgetClick?: (lineNumber: number, side: SplitSide) => void;
|
|
776
797
|
};
|
|
777
|
-
export
|
|
798
|
+
export type DiffViewProps_1<T> = Omit<DiffViewProps<T>, "data"> & {
|
|
799
|
+
data?: {
|
|
800
|
+
oldFile?: {
|
|
801
|
+
fileName?: string | null;
|
|
802
|
+
fileLang?: DiffHighlighterLang | null;
|
|
803
|
+
content?: string | null;
|
|
804
|
+
};
|
|
805
|
+
newFile?: {
|
|
806
|
+
fileName?: string | null;
|
|
807
|
+
fileLang?: DiffHighlighterLang | null;
|
|
808
|
+
content?: string | null;
|
|
809
|
+
};
|
|
810
|
+
hunks: string[];
|
|
811
|
+
};
|
|
812
|
+
};
|
|
813
|
+
export type DiffViewProps_2<T> = Omit<DiffViewProps<T>, "data"> & {
|
|
814
|
+
data?: {
|
|
815
|
+
oldFile?: {
|
|
816
|
+
fileName?: string | null;
|
|
817
|
+
fileLang?: string | null;
|
|
818
|
+
content?: string | null;
|
|
819
|
+
};
|
|
820
|
+
newFile?: {
|
|
821
|
+
fileName?: string | null;
|
|
822
|
+
fileLang?: string | null;
|
|
823
|
+
content?: string | null;
|
|
824
|
+
};
|
|
825
|
+
hunks: string[];
|
|
826
|
+
};
|
|
827
|
+
};
|
|
828
|
+
export declare function DiffView<T>(props: DiffViewProps_1<T> & {
|
|
778
829
|
ref?: ForwardedRef<{
|
|
779
830
|
getDiffFileInstance: () => DiffFile;
|
|
780
831
|
}>;
|
|
781
|
-
})
|
|
782
|
-
|
|
783
|
-
|
|
832
|
+
}): ReactNode;
|
|
833
|
+
export declare function DiffView<T>(props: DiffViewProps_2<T> & {
|
|
834
|
+
ref?: ForwardedRef<{
|
|
835
|
+
getDiffFileInstance: () => DiffFile;
|
|
836
|
+
}>;
|
|
837
|
+
}): ReactNode;
|
|
838
|
+
export declare namespace DiffView {
|
|
839
|
+
var displayName: string;
|
|
840
|
+
}
|
|
784
841
|
export declare const version: string;
|
|
785
842
|
|
|
786
843
|
export {
|
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.21",
|
|
7
7
|
"main": "index.js",
|
|
8
8
|
"types": "index.d.ts",
|
|
9
9
|
"files": [
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
{
|
|
34
34
|
"dir": "./dist",
|
|
35
35
|
"entryFileNames": "esm/index.mjs",
|
|
36
|
+
"banner": "'use client';",
|
|
36
37
|
"format": "esm",
|
|
37
38
|
"sourcemap": true
|
|
38
39
|
}
|
|
@@ -46,6 +47,7 @@
|
|
|
46
47
|
"entryFileNames": "cjs/index.js",
|
|
47
48
|
"format": "cjs",
|
|
48
49
|
"type": true,
|
|
50
|
+
"banner": "'use client';",
|
|
49
51
|
"multiple": true,
|
|
50
52
|
"sourcemap": true
|
|
51
53
|
}
|
|
@@ -57,12 +59,12 @@
|
|
|
57
59
|
"react diff component"
|
|
58
60
|
],
|
|
59
61
|
"dependencies": {
|
|
60
|
-
"@git-diff-view/core": "^0.0.
|
|
62
|
+
"@git-diff-view/core": "^0.0.21",
|
|
61
63
|
"@types/hast": "^3.0.0",
|
|
62
64
|
"fast-diff": "^1.3.0",
|
|
63
|
-
"highlight.js": "^11.
|
|
64
|
-
"lowlight": "^3.
|
|
65
|
-
"reactivity-store": "^0.3.
|
|
65
|
+
"highlight.js": "^11.10.0",
|
|
66
|
+
"lowlight": "^3.2.0",
|
|
67
|
+
"reactivity-store": "^0.3.8",
|
|
66
68
|
"use-sync-external-store": "^1.2.2"
|
|
67
69
|
},
|
|
68
70
|
"devDependencies": {
|
package/readme.md
CHANGED
|
@@ -73,6 +73,12 @@ const diffFile = DiffFile.createInstance(data || {}, bundle);
|
|
|
73
73
|
<DiffView diffFile={diffFile} {...props} />;
|
|
74
74
|
```
|
|
75
75
|
|
|
76
|
+
### Screen Shot
|
|
77
|
+
|
|
78
|
+

|
|
79
|
+

|
|
80
|
+

|
|
81
|
+
|
|
76
82
|
### Props
|
|
77
83
|
|
|
78
84
|
| Props | Description |
|
|
@@ -90,6 +96,8 @@ const diffFile = DiffFile.createInstance(data || {}, bundle);
|
|
|
90
96
|
| diffViewAddWidget| enable `addWidget` button, type: boolean |
|
|
91
97
|
| onAddWidgetClick | when the `addWidget` button clicked, type: `({ side: "old" | "new", lineNumber: number }) => void` |
|
|
92
98
|
|
|
93
|
-
### example
|
|
99
|
+
### example
|
|
94
100
|
|
|
95
|
-
[react-example](https://github.com/MrWangJustToDo/git-diff-view/tree/main/ui/react-example)
|
|
101
|
+
#### [react-example](https://github.com/MrWangJustToDo/git-diff-view/tree/main/ui/react-example)
|
|
102
|
+
#### [react-ssr-example](https://github.com/MrWangJustToDo/git-diff-view/tree/main/ui/next-page-example)
|
|
103
|
+
#### [react-rsc-example](https://github.com/MrWangJustToDo/git-diff-view/tree/main/ui/next-app-example)
|