@git-diff-view/react 0.0.19 → 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 +111 -21
- package/package.json +8 -6
- 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;
|
|
@@ -605,17 +626,17 @@ export type SyntaxNode = {
|
|
|
605
626
|
children?: SyntaxNode[];
|
|
606
627
|
};
|
|
607
628
|
declare const createDiffConfigStore: (props: DiffViewProps<any>, diffFileId: string) => import("reactivity-store").UseSelectorWithStore<{
|
|
608
|
-
id: import("reactivity-store").Ref<string>;
|
|
629
|
+
id: import("reactivity-store").Ref<string, string>;
|
|
609
630
|
setId: (_id: string) => string;
|
|
610
|
-
mode: import("reactivity-store").Ref<DiffModeEnum>;
|
|
631
|
+
mode: import("reactivity-store").Ref<DiffModeEnum, DiffModeEnum>;
|
|
611
632
|
setMode: (_mode: DiffModeEnum) => DiffModeEnum;
|
|
612
|
-
enableWrap: import("reactivity-store").Ref<boolean>;
|
|
633
|
+
enableWrap: import("reactivity-store").Ref<boolean, boolean>;
|
|
613
634
|
setEnableWrap: (_enableWrap: boolean) => boolean;
|
|
614
|
-
enableAddWidget: import("reactivity-store").Ref<boolean>;
|
|
635
|
+
enableAddWidget: import("reactivity-store").Ref<boolean, boolean>;
|
|
615
636
|
setEnableAddWidget: (_enableAddWidget: boolean) => boolean;
|
|
616
|
-
enableHighlight: import("reactivity-store").Ref<boolean>;
|
|
637
|
+
enableHighlight: import("reactivity-store").Ref<boolean, boolean>;
|
|
617
638
|
setEnableHighlight: (_enableHighlight: boolean) => boolean;
|
|
618
|
-
fontSize: import("reactivity-store").Ref<number>;
|
|
639
|
+
fontSize: import("reactivity-store").Ref<number, number>;
|
|
619
640
|
setFontSize: (_fontSize: number) => number;
|
|
620
641
|
extendData: import("reactivity-store").Ref<{
|
|
621
642
|
oldFile: {
|
|
@@ -628,6 +649,28 @@ declare const createDiffConfigStore: (props: DiffViewProps<any>, diffFileId: str
|
|
|
628
649
|
data: any;
|
|
629
650
|
};
|
|
630
651
|
};
|
|
652
|
+
}, {
|
|
653
|
+
oldFile: {
|
|
654
|
+
[x: string]: {
|
|
655
|
+
data: any;
|
|
656
|
+
};
|
|
657
|
+
};
|
|
658
|
+
newFile: {
|
|
659
|
+
[x: string]: {
|
|
660
|
+
data: any;
|
|
661
|
+
};
|
|
662
|
+
};
|
|
663
|
+
} | {
|
|
664
|
+
oldFile: {
|
|
665
|
+
[x: string]: {
|
|
666
|
+
data: any;
|
|
667
|
+
};
|
|
668
|
+
};
|
|
669
|
+
newFile: {
|
|
670
|
+
[x: string]: {
|
|
671
|
+
data: any;
|
|
672
|
+
};
|
|
673
|
+
};
|
|
631
674
|
}>;
|
|
632
675
|
setExtendData: (_extendData: DiffViewProps<any>["extendData"]) => void;
|
|
633
676
|
renderWidgetLine: import("reactivity-store").Ref<({ diffFile, side, lineNumber, onClose, }: {
|
|
@@ -635,6 +678,11 @@ declare const createDiffConfigStore: (props: DiffViewProps<any>, diffFileId: str
|
|
|
635
678
|
side: SplitSide;
|
|
636
679
|
diffFile: DiffFile;
|
|
637
680
|
onClose: () => void;
|
|
681
|
+
}) => import("react").ReactNode, ({ diffFile, side, lineNumber, onClose, }: {
|
|
682
|
+
lineNumber: number;
|
|
683
|
+
side: SplitSide;
|
|
684
|
+
diffFile: DiffFile;
|
|
685
|
+
onClose: () => void;
|
|
638
686
|
}) => import("react").ReactNode>;
|
|
639
687
|
setRenderWidgetLine: (_renderWidgetLine: ({ diffFile, side, lineNumber, onClose, }: {
|
|
640
688
|
lineNumber: number;
|
|
@@ -653,6 +701,12 @@ declare const createDiffConfigStore: (props: DiffViewProps<any>, diffFileId: str
|
|
|
653
701
|
data: any;
|
|
654
702
|
diffFile: DiffFile;
|
|
655
703
|
onUpdate: () => void;
|
|
704
|
+
}) => import("react").ReactNode, ({ diffFile, side, data, lineNumber, onUpdate, }: {
|
|
705
|
+
lineNumber: number;
|
|
706
|
+
side: SplitSide;
|
|
707
|
+
data: any;
|
|
708
|
+
diffFile: DiffFile;
|
|
709
|
+
onUpdate: () => void;
|
|
656
710
|
}) => import("react").ReactNode>;
|
|
657
711
|
setRenderExtendLine: (_renderExtendLine: ({ diffFile, side, data, lineNumber, onUpdate, }: {
|
|
658
712
|
lineNumber: number;
|
|
@@ -694,12 +748,12 @@ export type DiffViewProps<T> = {
|
|
|
694
748
|
data?: {
|
|
695
749
|
oldFile?: {
|
|
696
750
|
fileName?: string | null;
|
|
697
|
-
fileLang?: string | null;
|
|
751
|
+
fileLang?: DiffHighlighterLang | string | null;
|
|
698
752
|
content?: string | null;
|
|
699
753
|
};
|
|
700
754
|
newFile?: {
|
|
701
755
|
fileName?: string | null;
|
|
702
|
-
fileLang?: string | null;
|
|
756
|
+
fileLang?: DiffHighlighterLang | string | null;
|
|
703
757
|
content?: string | null;
|
|
704
758
|
};
|
|
705
759
|
hunks: string[];
|
|
@@ -741,13 +795,49 @@ export type DiffViewProps<T> = {
|
|
|
741
795
|
}) => ReactNode;
|
|
742
796
|
onAddWidgetClick?: (lineNumber: number, side: SplitSide) => void;
|
|
743
797
|
};
|
|
744
|
-
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> & {
|
|
745
829
|
ref?: ForwardedRef<{
|
|
746
830
|
getDiffFileInstance: () => DiffFile;
|
|
747
831
|
}>;
|
|
748
|
-
})
|
|
749
|
-
|
|
750
|
-
|
|
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
|
+
}
|
|
751
841
|
export declare const version: string;
|
|
752
842
|
|
|
753
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,18 +59,18 @@
|
|
|
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": {
|
|
69
71
|
"@types/use-sync-external-store": "^0.0.3",
|
|
70
72
|
"autoprefixer": "^10.4.20",
|
|
71
|
-
"postcss": "^8.4.
|
|
73
|
+
"postcss": "^8.4.47",
|
|
72
74
|
"postcss-cli": "^11.0.0",
|
|
73
75
|
"postcss-import": "^16.1.0",
|
|
74
76
|
"react": "^18.0.0",
|
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)
|