@git-diff-view/react 0.0.26 → 0.0.28
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 +431 -290
- package/dist/cjs/index.development.js.map +1 -1
- package/dist/cjs/index.production.js +431 -290
- package/dist/cjs/index.production.js.map +1 -1
- package/dist/css/diff-view-pure.css +4 -0
- package/dist/css/diff-view.css +4 -0
- package/dist/esm/index.mjs +362 -224
- package/dist/esm/index.mjs.map +1 -1
- package/index.d.ts +303 -23
- package/package.json +4 -3
- package/src/_base.css +3 -0
- package/src/_base_pure.css +2 -0
- package/src/_com.css +172 -0
- package/src/_theme.css +2 -0
- package/src/components/DiffAddWidget.tsx +86 -0
- package/src/components/DiffContent.tsx +367 -0
- package/src/components/DiffContent_v2.tsx +344 -0
- package/src/components/DiffExpand.tsx +25 -0
- package/src/components/DiffNoNewLine.tsx +10 -0
- package/src/components/DiffSplitContentLineNormal.tsx +164 -0
- package/src/components/DiffSplitContentLineWrap.tsx +234 -0
- package/src/components/DiffSplitExtendLineNormal.tsx +150 -0
- package/src/components/DiffSplitExtendLineWrap.tsx +133 -0
- package/src/components/DiffSplitHunkLineNormal.tsx +316 -0
- package/src/components/DiffSplitHunkLineWrap.tsx +340 -0
- package/src/components/DiffSplitView.tsx +46 -0
- package/src/components/DiffSplitViewNormal.tsx +205 -0
- package/src/components/DiffSplitViewWrap.tsx +141 -0
- package/src/components/DiffSplitWidgetLineNormal.tsx +149 -0
- package/src/components/DiffSplitWidgetLineWrap.tsx +127 -0
- package/src/components/DiffUnifiedContentLine.tsx +342 -0
- package/src/components/DiffUnifiedExtendLine.tsx +103 -0
- package/src/components/DiffUnifiedHunkLine.tsx +148 -0
- package/src/components/DiffUnifiedView.tsx +159 -0
- package/src/components/DiffUnifiedWidgetLine.tsx +104 -0
- package/src/components/DiffView.tsx +365 -0
- package/src/components/DiffViewContext.ts +11 -0
- package/src/components/DiffWidgetContext.ts +17 -0
- package/src/components/tools.ts +132 -0
- package/src/components/v2/DiffSplitContentLineNormal_v2.tsx +152 -0
- package/src/components/v2/DiffSplitContentLineWrap_v2.tsx +259 -0
- package/src/components/v2/DiffSplitExtendLineNormal_v2.tsx +146 -0
- package/src/components/v2/DiffSplitExtendLineWrap_v2.tsx +123 -0
- package/src/components/v2/DiffSplitHunkLineNormal_v2.tsx +302 -0
- package/src/components/v2/DiffSplitHunkLineWrap_v2.tsx +326 -0
- package/src/components/v2/DiffSplitViewLineNormal_v2.tsx +33 -0
- package/src/components/v2/DiffSplitViewLineWrap_v2.tsx +24 -0
- package/src/components/v2/DiffSplitViewNormal_v2.tsx +159 -0
- package/src/components/v2/DiffSplitViewWrap_v2.tsx +104 -0
- package/src/components/v2/DiffSplitView_v2.tsx +47 -0
- package/src/components/v2/DiffSplitWidgetLineNormal_v2.tsx +132 -0
- package/src/components/v2/DiffSplitWidgetLineWrap_v2.tsx +119 -0
- package/src/global.d.ts +12 -0
- package/src/hooks/useCallbackRef.ts +18 -0
- package/src/hooks/useDomWidth.ts +67 -0
- package/src/hooks/useIsMounted.ts +11 -0
- package/src/hooks/useSafeLayout.ts +5 -0
- package/src/hooks/useSyncHeight.ts +87 -0
- package/src/hooks/useTextWidth.ts +27 -0
- package/src/hooks/useUnmount.ts +10 -0
- package/src/index.ts +3 -0
- package/src/tailwind.css +3 -0
- package/src/tailwind_pure.css +3 -0
- package/styles/diff-view-pure.css +4 -0
- package/styles/diff-view.css +4 -0
package/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Generated by dts-bundle-generator v9.5.1
|
|
2
2
|
|
|
3
|
-
import { CSSProperties, ForwardedRef, ReactNode } from 'react';
|
|
3
|
+
import { CSSProperties, ForwardedRef, ReactNode, RefObject } from 'react';
|
|
4
4
|
|
|
5
5
|
declare class Cache$1<K, V> extends Map<K, V> {
|
|
6
6
|
name: string;
|
|
@@ -9,14 +9,18 @@ declare class Cache$1<K, V> extends Map<K, V> {
|
|
|
9
9
|
set(key: K, value: V): this;
|
|
10
10
|
}
|
|
11
11
|
declare class File$1 {
|
|
12
|
-
|
|
12
|
+
raw: string;
|
|
13
13
|
readonly lang: DiffHighlighterLang | string;
|
|
14
14
|
readonly fileName?: string;
|
|
15
15
|
ast?: DiffAST;
|
|
16
16
|
rawFile: Record<number, string>;
|
|
17
17
|
hasDoRaw: boolean;
|
|
18
18
|
rawLength?: number;
|
|
19
|
-
syntaxFile: Record<number,
|
|
19
|
+
syntaxFile: Record<number, SyntaxLineWithTemplate>;
|
|
20
|
+
plainFile: Record<number, {
|
|
21
|
+
value: string;
|
|
22
|
+
template?: string;
|
|
23
|
+
}>;
|
|
20
24
|
hasDoSyntax: boolean;
|
|
21
25
|
syntaxLength?: number;
|
|
22
26
|
highlighterName?: DiffHighlighter["name"];
|
|
@@ -45,6 +49,14 @@ declare const lowlight: {
|
|
|
45
49
|
};
|
|
46
50
|
registered: (aliasOrName: string) => boolean;
|
|
47
51
|
};
|
|
52
|
+
declare enum NewLineSymbol {
|
|
53
|
+
CRLF = 1,
|
|
54
|
+
CR = 2,
|
|
55
|
+
LF = 3,
|
|
56
|
+
NEWLINE = 4,
|
|
57
|
+
NORMAL = 5,
|
|
58
|
+
NULL = 6
|
|
59
|
+
}
|
|
48
60
|
export declare class DiffFile {
|
|
49
61
|
readonly uuid?: string;
|
|
50
62
|
_version_: string;
|
|
@@ -78,10 +90,14 @@ export declare class DiffFile {
|
|
|
78
90
|
buildSplitDiffLines(): void;
|
|
79
91
|
buildUnifiedDiffLines(): void;
|
|
80
92
|
getSplitLeftLine: (index: number) => SplitLineItem;
|
|
93
|
+
getSplitLineByLineNumber: (lineNumber: number, side: SplitSide) => SplitLineItem;
|
|
94
|
+
getSplitLineIndexByLineNumber: (lineNumber: number, side: SplitSide) => number;
|
|
81
95
|
getSplitRightLine: (index: number) => SplitLineItem;
|
|
82
96
|
getSplitHunkLine: (index: number) => DiffHunkItem;
|
|
83
97
|
onSplitHunkExpand: (dir: "up" | "down" | "all", index: number, needTrigger?: boolean) => void;
|
|
84
98
|
getUnifiedLine: (index: number) => UnifiedLineItem;
|
|
99
|
+
getUnifiedLineByLineNumber: (lienNumber: number, side: SplitSide) => UnifiedLineItem;
|
|
100
|
+
getUnifiedLineIndexByLineNumber: (lineNumber: number, side: SplitSide) => number;
|
|
85
101
|
getUnifiedHunkLine: (index: number) => DiffHunkItem;
|
|
86
102
|
onUnifiedHunkExpand: (dir: "up" | "down" | "all", index: number, needTrigger?: boolean) => void;
|
|
87
103
|
onAllExpand: (mode: "split" | "unified") => void;
|
|
@@ -90,8 +106,16 @@ export declare class DiffFile {
|
|
|
90
106
|
onAllCollapse: (mode: "split" | "unified") => void;
|
|
91
107
|
getOldFileContent: () => string;
|
|
92
108
|
getNewFileContent: () => string;
|
|
93
|
-
|
|
94
|
-
|
|
109
|
+
getOldPlainLine: (lineNumber: number) => {
|
|
110
|
+
value: string;
|
|
111
|
+
template?: string;
|
|
112
|
+
};
|
|
113
|
+
getOldSyntaxLine: (lineNumber: number) => SyntaxLineWithTemplate;
|
|
114
|
+
getNewPlainLine: (lineNumber: number) => {
|
|
115
|
+
value: string;
|
|
116
|
+
template?: string;
|
|
117
|
+
};
|
|
118
|
+
getNewSyntaxLine: (lineNumber: number) => SyntaxLineWithTemplate;
|
|
95
119
|
subscribe: (listener: (() => void) & {
|
|
96
120
|
isSyncExternal?: boolean;
|
|
97
121
|
}) => () => void;
|
|
@@ -105,11 +129,19 @@ export declare class DiffFile {
|
|
|
105
129
|
hasBuildUnified: boolean;
|
|
106
130
|
oldFileLines: Record<number, string>;
|
|
107
131
|
oldFileDiffLines: Record<string, DiffLineItem>;
|
|
108
|
-
|
|
132
|
+
oldFilePlainLines: Record<number, {
|
|
133
|
+
value: string;
|
|
134
|
+
template?: string;
|
|
135
|
+
}>;
|
|
136
|
+
oldFileSyntaxLines: Record<number, SyntaxLineWithTemplate>;
|
|
109
137
|
oldFilePlaceholderLines: Record<string, boolean>;
|
|
110
138
|
newFileLines: Record<number, string>;
|
|
111
139
|
newFileDiffLines: Record<string, DiffLineItem>;
|
|
112
|
-
|
|
140
|
+
newFilePlainLines: Record<number, {
|
|
141
|
+
value: string;
|
|
142
|
+
template?: string;
|
|
143
|
+
}>;
|
|
144
|
+
newFileSyntaxLines: Record<number, SyntaxLineWithTemplate>;
|
|
113
145
|
newFilePlaceholderLines: Record<string, boolean>;
|
|
114
146
|
splitLineLength: number;
|
|
115
147
|
unifiedLineLength: number;
|
|
@@ -154,11 +186,19 @@ export declare class DiffFile {
|
|
|
154
186
|
hasBuildUnified: boolean;
|
|
155
187
|
oldFileLines: Record<number, string>;
|
|
156
188
|
oldFileDiffLines: Record<string, DiffLineItem>;
|
|
157
|
-
|
|
189
|
+
oldFilePlainLines: Record<number, {
|
|
190
|
+
value: string;
|
|
191
|
+
template?: string;
|
|
192
|
+
}>;
|
|
193
|
+
oldFileSyntaxLines: Record<number, SyntaxLineWithTemplate>;
|
|
158
194
|
oldFilePlaceholderLines: Record<string, boolean>;
|
|
159
195
|
newFileLines: Record<number, string>;
|
|
160
196
|
newFileDiffLines: Record<string, DiffLineItem>;
|
|
161
|
-
|
|
197
|
+
newFilePlainLines: Record<number, {
|
|
198
|
+
value: string;
|
|
199
|
+
template?: string;
|
|
200
|
+
}>;
|
|
201
|
+
newFileSyntaxLines: Record<number, SyntaxLineWithTemplate>;
|
|
162
202
|
newFilePlaceholderLines: Record<string, boolean>;
|
|
163
203
|
splitLineLength: number;
|
|
164
204
|
unifiedLineLength: number;
|
|
@@ -229,7 +269,9 @@ export declare class DiffLine {
|
|
|
229
269
|
readonly noTrailingNewLine: boolean;
|
|
230
270
|
changes?: IRange;
|
|
231
271
|
diffChanges?: DiffRange;
|
|
232
|
-
|
|
272
|
+
plainTemplate?: string;
|
|
273
|
+
syntaxTemplate?: string;
|
|
274
|
+
constructor(text: string, type: DiffLineType, originalLineNumber: number | null, oldLineNumber: number | null, newLineNumber: number | null, noTrailingNewLine?: boolean, changes?: IRange, diffChanges?: DiffRange, plainTemplate?: string, syntaxTemplate?: string);
|
|
233
275
|
withNoTrailingNewLine(noTrailingNewLine: boolean): DiffLine;
|
|
234
276
|
isIncludeableLine(): boolean;
|
|
235
277
|
equals(other: DiffLine): boolean;
|
|
@@ -372,25 +414,120 @@ export declare const DefaultDiffExpansionStep = 40;
|
|
|
372
414
|
*/
|
|
373
415
|
export declare const HiddenBidiCharsRegex: RegExp;
|
|
374
416
|
export declare const _cacheMap: Cache$1<string, File$1>;
|
|
417
|
+
export declare const changeDefaultComposeLength: (compose: number) => void;
|
|
418
|
+
export declare const checkCurrentLineIsHidden: (diffFile: DiffFile, lineNumber: number, side: SplitSide) => {
|
|
419
|
+
split: boolean;
|
|
420
|
+
unified: boolean;
|
|
421
|
+
};
|
|
375
422
|
export declare const checkDiffLineIncludeChange: (diffLine?: DiffLine) => boolean;
|
|
376
|
-
export declare const composeLen = 40;
|
|
377
423
|
export declare const disableCache: () => void;
|
|
378
|
-
export declare const
|
|
424
|
+
export declare const getCurrentComposeLength: () => number;
|
|
425
|
+
export declare const getDiffRange: (additions: DiffLine[], deletions: DiffLine[], { getAdditionRaw, getDeletionRaw, getAdditionSyntax, getDeletionSyntax, }: {
|
|
379
426
|
getAdditionRaw: (lineNumber: number) => string;
|
|
380
427
|
getDeletionRaw: (lineNumber: number) => string;
|
|
428
|
+
getAdditionSyntax: (lineNumber: number) => SyntaxLineWithTemplate;
|
|
429
|
+
getDeletionSyntax: (lineNumber: number) => SyntaxLineWithTemplate;
|
|
381
430
|
}) => void;
|
|
382
431
|
export declare const getLang: (fileName: string) => string;
|
|
432
|
+
export declare const getPlainDiffTemplate: ({ diffLine, rawLine, operator, }: {
|
|
433
|
+
diffLine: DiffLine;
|
|
434
|
+
rawLine: string;
|
|
435
|
+
operator: "add" | "del";
|
|
436
|
+
}) => void;
|
|
437
|
+
export declare const getPlainLineTemplate: (line: string) => string;
|
|
383
438
|
export declare const getSplitContentLines: (diffFile: DiffFile) => DiffSplitContentLineItem[];
|
|
384
439
|
export declare const getSplitLines: (diffFile: DiffFile) => DiffSplitLineItem[];
|
|
440
|
+
export declare const getSyntaxDiffTemplate: ({ diffLine, syntaxLine, operator, }: {
|
|
441
|
+
diffLine: DiffLine;
|
|
442
|
+
syntaxLine: SyntaxLineWithTemplate;
|
|
443
|
+
operator: "add" | "del";
|
|
444
|
+
}) => void;
|
|
445
|
+
export declare const getSyntaxLineTemplate: (line: SyntaxLine) => string;
|
|
385
446
|
export declare const getUnifiedContentLine: (diffFile: DiffFile) => DiffUnifiedContentLineItem[];
|
|
386
447
|
export declare const getUnifiedLines: (diffFile: DiffFile) => DiffUnifiedLineItem[];
|
|
387
448
|
export declare const highlighter: DiffHighlighter;
|
|
449
|
+
/**
|
|
450
|
+
* Checks whether content transformation is currently enabled.
|
|
451
|
+
*
|
|
452
|
+
* @returns {boolean} True if transformation is enabled, false otherwise
|
|
453
|
+
*
|
|
454
|
+
* @example
|
|
455
|
+
* ```typescript
|
|
456
|
+
* if (isTransformEnabled()) {
|
|
457
|
+
* console.log('Transformations are active');
|
|
458
|
+
* }
|
|
459
|
+
* ```
|
|
460
|
+
*/
|
|
461
|
+
export declare const isTransformEnabled: () => boolean;
|
|
388
462
|
export declare const numIterator: <T>(num: number, cb: (index: number) => T) => T[];
|
|
389
463
|
export declare const parseInstance: DiffParser;
|
|
390
464
|
export declare const processAST: (ast: DiffAST) => {
|
|
391
465
|
syntaxFileObject: Record<number, SyntaxLine>;
|
|
392
466
|
syntaxFileLineNumber: number;
|
|
393
467
|
};
|
|
468
|
+
/**
|
|
469
|
+
* Applies the file transformation function to the provided content if transformation is enabled.
|
|
470
|
+
*
|
|
471
|
+
* @param content - The content string to transform
|
|
472
|
+
* @returns {string} The transformed content if transformation is enabled and configured, otherwise the original content
|
|
473
|
+
*
|
|
474
|
+
* @example
|
|
475
|
+
* ```typescript
|
|
476
|
+
* const transformed = doTransformFile('some file content');
|
|
477
|
+
* ```
|
|
478
|
+
*/
|
|
479
|
+
export declare const processTransformForFile: (content: string) => string;
|
|
480
|
+
/**
|
|
481
|
+
* Applies the transformation function to the provided content if transformation is enabled.
|
|
482
|
+
*
|
|
483
|
+
* @param content - The content string to transform
|
|
484
|
+
* @returns {string} The transformed content if transformation is enabled and configured, otherwise the original content
|
|
485
|
+
*
|
|
486
|
+
* @example
|
|
487
|
+
* ```typescript
|
|
488
|
+
* const transformed = processTransformTemplateContent(' hello world ');
|
|
489
|
+
* ```
|
|
490
|
+
*/
|
|
491
|
+
export declare const processTransformTemplateContent: (content: string) => string;
|
|
492
|
+
export declare const resetDefaultComposeLength: () => void;
|
|
493
|
+
/**
|
|
494
|
+
* Resets all transformation functions to their default state and disables transformation.
|
|
495
|
+
*
|
|
496
|
+
* @example
|
|
497
|
+
* ```typescript
|
|
498
|
+
* resetTransform(); // Clears all transformations
|
|
499
|
+
* ```
|
|
500
|
+
*/
|
|
501
|
+
export declare const resetTransform: () => void;
|
|
502
|
+
/**
|
|
503
|
+
* ⚠️ **WARNING: DANGEROUS OPERATION** ⚠️
|
|
504
|
+
*
|
|
505
|
+
* @param fn - The transformation function to apply to file content
|
|
506
|
+
* @throws {Error} Throws an error if the provided parameter is not a function
|
|
507
|
+
*
|
|
508
|
+
* @example
|
|
509
|
+
* ```typescript
|
|
510
|
+
* // Use with caution - this affects global behavior
|
|
511
|
+
* setTransformFile((content) => content.toUpperCase());
|
|
512
|
+
* ```
|
|
513
|
+
*/
|
|
514
|
+
export declare const setTransformForFile: (fn: (content: string) => string) => void;
|
|
515
|
+
/**
|
|
516
|
+
* ⚠️ **WARNING: DANGEROUS OPERATION** ⚠️
|
|
517
|
+
*
|
|
518
|
+
* This function modifies global state and may cause unexpected side effects.
|
|
519
|
+
* You may also need escapeHTML for the content.
|
|
520
|
+
*
|
|
521
|
+
* @param fn - The transformation function to help transform template content
|
|
522
|
+
* @throws {Error} Throws an error if the provided parameter is not a function
|
|
523
|
+
*
|
|
524
|
+
* @example
|
|
525
|
+
* ```typescript
|
|
526
|
+
* // Use with caution - this affects global behavior
|
|
527
|
+
* setTransformForTemplateContent((content) => content.trim());
|
|
528
|
+
* ```
|
|
529
|
+
*/
|
|
530
|
+
export declare const setTransformForTemplateContent: (fn: (content: string) => string) => void;
|
|
394
531
|
export declare const versions: string;
|
|
395
532
|
export declare enum DiffFileLineType {
|
|
396
533
|
hunk = 1,
|
|
@@ -426,13 +563,9 @@ export declare enum DiffLineType {
|
|
|
426
563
|
Delete = 2,
|
|
427
564
|
Hunk = 3
|
|
428
565
|
}
|
|
429
|
-
export declare enum
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
LF = 3,
|
|
433
|
-
NEWLINE = 4,
|
|
434
|
-
NORMAL = 5,
|
|
435
|
-
NULL = 6
|
|
566
|
+
export declare enum SplitSide {
|
|
567
|
+
old = 1,
|
|
568
|
+
new = 2
|
|
436
569
|
}
|
|
437
570
|
export declare function _getAST(raw: string, fileName?: string, lang?: DiffHighlighterLang, theme?: "light" | "dark"): DiffAST;
|
|
438
571
|
export declare function _getAST(raw: string, fileName?: string, lang?: string, theme?: "light" | "dark"): DiffAST;
|
|
@@ -441,6 +574,7 @@ export declare function diffChanges(addition: DiffLine, deletion: DiffLine): {
|
|
|
441
574
|
addRange: DiffRange;
|
|
442
575
|
delRange: DiffRange;
|
|
443
576
|
};
|
|
577
|
+
export declare function escapeHtml(string: unknown): string;
|
|
444
578
|
export declare function getFile(raw: string, lang: DiffHighlighterLang, theme: "light" | "dark", fileName?: string, uuid?: string): File$1;
|
|
445
579
|
export declare function getFile(raw: string, lang: string, theme: "light" | "dark", fileName?: string, uuid?: string): File$1;
|
|
446
580
|
/**
|
|
@@ -461,6 +595,7 @@ export declare function relativeChanges(addition: DiffLine, deletion: DiffLine):
|
|
|
461
595
|
addRange: IRange;
|
|
462
596
|
delRange: IRange;
|
|
463
597
|
};
|
|
598
|
+
export declare let composeLen: number;
|
|
464
599
|
export interface DiffHunkItem extends DiffLineItem {
|
|
465
600
|
isFirst: boolean;
|
|
466
601
|
isLast: boolean;
|
|
@@ -636,6 +771,9 @@ export type SyntaxLine = {
|
|
|
636
771
|
wrapper?: SyntaxNode;
|
|
637
772
|
}[];
|
|
638
773
|
};
|
|
774
|
+
export type SyntaxLineWithTemplate = SyntaxLine & {
|
|
775
|
+
template?: string;
|
|
776
|
+
};
|
|
639
777
|
// Generated by dts-bundle-generator v9.5.1
|
|
640
778
|
export type SyntaxNode = {
|
|
641
779
|
type: string;
|
|
@@ -649,10 +787,151 @@ export type SyntaxNode = {
|
|
|
649
787
|
};
|
|
650
788
|
children?: SyntaxNode[];
|
|
651
789
|
};
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
790
|
+
declare const createDiffConfigStore: (props: DiffViewProps<any> & {
|
|
791
|
+
isMounted: boolean;
|
|
792
|
+
}, diffFileId: string) => import("reactivity-store").UseSelectorWithStore<{
|
|
793
|
+
id: import("reactivity-store").Ref<string, string>;
|
|
794
|
+
setId: (_id: string) => string;
|
|
795
|
+
mode: import("reactivity-store").Ref<DiffModeEnum, DiffModeEnum>;
|
|
796
|
+
setMode: (_mode: DiffModeEnum) => DiffModeEnum;
|
|
797
|
+
mounted: import("reactivity-store").Ref<boolean, boolean>;
|
|
798
|
+
setMounted: (_mounted: boolean) => boolean;
|
|
799
|
+
enableWrap: import("reactivity-store").Ref<boolean, boolean>;
|
|
800
|
+
setEnableWrap: (_enableWrap: boolean) => boolean;
|
|
801
|
+
enableAddWidget: import("reactivity-store").Ref<boolean, boolean>;
|
|
802
|
+
setEnableAddWidget: (_enableAddWidget: boolean) => boolean;
|
|
803
|
+
enableHighlight: import("reactivity-store").Ref<boolean, boolean>;
|
|
804
|
+
setEnableHighlight: (_enableHighlight: boolean) => boolean;
|
|
805
|
+
fontSize: import("reactivity-store").Ref<number, number>;
|
|
806
|
+
setFontSize: (_fontSize: number) => number;
|
|
807
|
+
extendData: import("reactivity-store").Ref<{
|
|
808
|
+
oldFile: {
|
|
809
|
+
[x: string]: {
|
|
810
|
+
data: any;
|
|
811
|
+
};
|
|
812
|
+
};
|
|
813
|
+
newFile: {
|
|
814
|
+
[x: string]: {
|
|
815
|
+
data: any;
|
|
816
|
+
};
|
|
817
|
+
};
|
|
818
|
+
}, {
|
|
819
|
+
oldFile: {
|
|
820
|
+
[x: string]: {
|
|
821
|
+
data: any;
|
|
822
|
+
};
|
|
823
|
+
};
|
|
824
|
+
newFile: {
|
|
825
|
+
[x: string]: {
|
|
826
|
+
data: any;
|
|
827
|
+
};
|
|
828
|
+
};
|
|
829
|
+
} | {
|
|
830
|
+
oldFile: {
|
|
831
|
+
[x: string]: {
|
|
832
|
+
data: any;
|
|
833
|
+
};
|
|
834
|
+
};
|
|
835
|
+
newFile: {
|
|
836
|
+
[x: string]: {
|
|
837
|
+
data: any;
|
|
838
|
+
};
|
|
839
|
+
};
|
|
840
|
+
}>;
|
|
841
|
+
setExtendData: (_extendData: DiffViewProps<any>["extendData"]) => void;
|
|
842
|
+
renderWidgetLine: import("reactivity-store").Ref<({ diffFile, side, lineNumber, onClose, }: {
|
|
843
|
+
lineNumber: number;
|
|
844
|
+
side: SplitSide;
|
|
845
|
+
diffFile: DiffFile;
|
|
846
|
+
onClose: () => void;
|
|
847
|
+
}) => import("react").ReactNode, ({ diffFile, side, lineNumber, onClose, }: {
|
|
848
|
+
lineNumber: number;
|
|
849
|
+
side: SplitSide;
|
|
850
|
+
diffFile: DiffFile;
|
|
851
|
+
onClose: () => void;
|
|
852
|
+
}) => import("react").ReactNode>;
|
|
853
|
+
setRenderWidgetLine: (_renderWidgetLine: ({ diffFile, side, lineNumber, onClose, }: {
|
|
854
|
+
lineNumber: number;
|
|
855
|
+
side: SplitSide;
|
|
856
|
+
diffFile: DiffFile;
|
|
857
|
+
onClose: () => void;
|
|
858
|
+
}) => import("react").ReactNode) => ({ diffFile, side, lineNumber, onClose, }: {
|
|
859
|
+
lineNumber: number;
|
|
860
|
+
side: SplitSide;
|
|
861
|
+
diffFile: DiffFile;
|
|
862
|
+
onClose: () => void;
|
|
863
|
+
}) => import("react").ReactNode;
|
|
864
|
+
renderExtendLine: import("reactivity-store").Ref<({ diffFile, side, data, lineNumber, onUpdate, }: {
|
|
865
|
+
lineNumber: number;
|
|
866
|
+
side: SplitSide;
|
|
867
|
+
data: any;
|
|
868
|
+
diffFile: DiffFile;
|
|
869
|
+
onUpdate: () => void;
|
|
870
|
+
}) => import("react").ReactNode, ({ diffFile, side, data, lineNumber, onUpdate, }: {
|
|
871
|
+
lineNumber: number;
|
|
872
|
+
side: SplitSide;
|
|
873
|
+
data: any;
|
|
874
|
+
diffFile: DiffFile;
|
|
875
|
+
onUpdate: () => void;
|
|
876
|
+
}) => import("react").ReactNode>;
|
|
877
|
+
setRenderExtendLine: (_renderExtendLine: ({ diffFile, side, data, lineNumber, onUpdate, }: {
|
|
878
|
+
lineNumber: number;
|
|
879
|
+
side: SplitSide;
|
|
880
|
+
data: any;
|
|
881
|
+
diffFile: DiffFile;
|
|
882
|
+
onUpdate: () => void;
|
|
883
|
+
}) => import("react").ReactNode) => ({ diffFile, side, data, lineNumber, onUpdate, }: {
|
|
884
|
+
lineNumber: number;
|
|
885
|
+
side: SplitSide;
|
|
886
|
+
data: any;
|
|
887
|
+
diffFile: DiffFile;
|
|
888
|
+
onUpdate: () => void;
|
|
889
|
+
}) => import("react").ReactNode;
|
|
890
|
+
onAddWidgetClick: {
|
|
891
|
+
current: (lineNumber: number, side: SplitSide) => void;
|
|
892
|
+
};
|
|
893
|
+
setOnAddWidgetClick: (_onAddWidgetClick: {
|
|
894
|
+
current: (lineNumber: number, side: SplitSide) => void;
|
|
895
|
+
}) => (lineNumber: number, side: SplitSide) => void;
|
|
896
|
+
onCreateUseWidgetHook: import("reactivity-store").Ref<(hook: import("reactivity-store").UseSelectorWithStore<{
|
|
897
|
+
widgetSide: import("reactivity-store").Ref<SplitSide, SplitSide>;
|
|
898
|
+
widgetLineNumber: import("reactivity-store").Ref<number, number>;
|
|
899
|
+
setWidget: ({ side, lineNumber }: {
|
|
900
|
+
side?: SplitSide;
|
|
901
|
+
lineNumber?: number;
|
|
902
|
+
}) => void;
|
|
903
|
+
}>) => void, (hook: import("reactivity-store").UseSelectorWithStore<{
|
|
904
|
+
widgetSide: import("reactivity-store").Ref<SplitSide, SplitSide>;
|
|
905
|
+
widgetLineNumber: import("reactivity-store").Ref<number, number>;
|
|
906
|
+
setWidget: ({ side, lineNumber }: {
|
|
907
|
+
side?: SplitSide;
|
|
908
|
+
lineNumber?: number;
|
|
909
|
+
}) => void;
|
|
910
|
+
}>) => void>;
|
|
911
|
+
setOnCreateUseWidgetHook: (_onCreateUseWidgetHook: (hook: import("reactivity-store").UseSelectorWithStore<{
|
|
912
|
+
widgetSide: import("reactivity-store").Ref<SplitSide, SplitSide>;
|
|
913
|
+
widgetLineNumber: import("reactivity-store").Ref<number, number>;
|
|
914
|
+
setWidget: ({ side, lineNumber }: {
|
|
915
|
+
side?: SplitSide;
|
|
916
|
+
lineNumber?: number;
|
|
917
|
+
}) => void;
|
|
918
|
+
}>) => void) => (hook: import("reactivity-store").UseSelectorWithStore<{
|
|
919
|
+
widgetSide: import("reactivity-store").Ref<SplitSide, SplitSide>;
|
|
920
|
+
widgetLineNumber: import("reactivity-store").Ref<number, number>;
|
|
921
|
+
setWidget: ({ side, lineNumber }: {
|
|
922
|
+
side?: SplitSide;
|
|
923
|
+
lineNumber?: number;
|
|
924
|
+
}) => void;
|
|
925
|
+
}>) => void;
|
|
926
|
+
}>;
|
|
927
|
+
declare const createDiffWidgetStore: (useDiffContextRef: RefObject<ReturnType<typeof createDiffConfigStore>>) => import("reactivity-store").UseSelectorWithStore<{
|
|
928
|
+
widgetSide: import("reactivity-store").Ref<SplitSide, SplitSide>;
|
|
929
|
+
widgetLineNumber: import("reactivity-store").Ref<number, number>;
|
|
930
|
+
setWidget: ({ side, lineNumber }: {
|
|
931
|
+
side?: SplitSide;
|
|
932
|
+
lineNumber?: number;
|
|
933
|
+
}) => void;
|
|
934
|
+
}>;
|
|
656
935
|
export declare enum DiffModeEnum {
|
|
657
936
|
SplitGitHub = 1,
|
|
658
937
|
SplitGitLab = 2,
|
|
@@ -709,6 +988,7 @@ export type DiffViewProps<T> = {
|
|
|
709
988
|
onUpdate: () => void;
|
|
710
989
|
}) => ReactNode;
|
|
711
990
|
onAddWidgetClick?: (lineNumber: number, side: SplitSide) => void;
|
|
991
|
+
onCreateUseWidgetHook?: (hook: ReturnType<typeof createDiffWidgetStore>) => void;
|
|
712
992
|
};
|
|
713
993
|
export type DiffViewProps_1<T> = Omit<DiffViewProps<T>, "data"> & {
|
|
714
994
|
data?: {
|
package/package.json
CHANGED
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
"description": "@git-diff-view/react",
|
|
4
4
|
"author": "MrWangJustToDo",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"version": "0.0.
|
|
6
|
+
"version": "0.0.28",
|
|
7
7
|
"main": "index.js",
|
|
8
8
|
"types": "index.d.ts",
|
|
9
9
|
"files": [
|
|
10
|
+
"src",
|
|
10
11
|
"dist",
|
|
11
12
|
"styles",
|
|
12
13
|
"index.js",
|
|
@@ -60,12 +61,12 @@
|
|
|
60
61
|
"react diff component"
|
|
61
62
|
],
|
|
62
63
|
"dependencies": {
|
|
63
|
-
"@git-diff-view/core": "^0.0.
|
|
64
|
+
"@git-diff-view/core": "^0.0.28",
|
|
64
65
|
"@types/hast": "^3.0.0",
|
|
65
66
|
"fast-diff": "^1.3.0",
|
|
66
67
|
"highlight.js": "^11.11.0",
|
|
67
68
|
"lowlight": "^3.3.0",
|
|
68
|
-
"reactivity-store": "^0.3.
|
|
69
|
+
"reactivity-store": "^0.3.10",
|
|
69
70
|
"use-sync-external-store": "^1.4.0"
|
|
70
71
|
},
|
|
71
72
|
"devDependencies": {
|
package/src/_base.css
ADDED
package/src/_com.css
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
* {
|
|
2
|
+
box-sizing: border-box;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
[data-theme="light"] .diff-style-root {
|
|
6
|
+
--diff-border--: #dedede;
|
|
7
|
+
--diff-add-content--: #e6ffec;
|
|
8
|
+
--diff-del-content--: #ffebe9;
|
|
9
|
+
--diff-add-lineNumber--: #ccffd8;
|
|
10
|
+
--diff-del-lineNumber--: #ffd7d5;
|
|
11
|
+
--diff-plain-content--: #ffffff;
|
|
12
|
+
--diff-expand-content--: #fafafa;
|
|
13
|
+
--diff-plain-lineNumber--: #fafafa;
|
|
14
|
+
--diff-expand-lineNumber--: #fafafa;
|
|
15
|
+
--diff-plain-lineNumber-color--: #555555;
|
|
16
|
+
--diff-expand-lineNumber-color--: #555555;
|
|
17
|
+
--diff-hunk-content--: #ddf4ff;
|
|
18
|
+
--diff-hunk-lineNumber--: #c7ecff;
|
|
19
|
+
--diff-hunk-lineNumber-hover--: #0969da;
|
|
20
|
+
--diff-add-content-highlight--: #abf2bc;
|
|
21
|
+
--diff-del-content-highlight--: #ffb3ad;
|
|
22
|
+
--diff-add-widget--: #0969d2;
|
|
23
|
+
--diff-add-widget-color--: #ffffff;
|
|
24
|
+
--diff-empty-content--: #fafafa;
|
|
25
|
+
--diff-hunk-content-color--: #777777;
|
|
26
|
+
|
|
27
|
+
color: black;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.diff-style-root .diff-line-syntax-raw *,
|
|
31
|
+
[data-theme="light"] .diff-line-syntax-raw * {
|
|
32
|
+
color: var(--diff-view-light, inherit);
|
|
33
|
+
font-weight: var(--diff-view-light-font-weight, inherit);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
[data-theme="dark"] .diff-style-root {
|
|
37
|
+
--diff-border--: #3d444d;
|
|
38
|
+
--diff-add-content--: #14261f;
|
|
39
|
+
--diff-del-content--: #311b1f;
|
|
40
|
+
--diff-add-lineNumber--: #1f4429;
|
|
41
|
+
--diff-del-lineNumber--: #552527;
|
|
42
|
+
--diff-plain-content--: #0d1117;
|
|
43
|
+
--diff-expand-content--: #161b22;
|
|
44
|
+
--diff-plain-lineNumber--: #161b22;
|
|
45
|
+
--diff-expand-lineNumber--: #161b22;
|
|
46
|
+
--diff-plain-lineNumber-color--: #a0aaab;
|
|
47
|
+
--diff-expand-lineNumber-color--: #a0aaab;
|
|
48
|
+
--diff-hunk-content--: #131d2e;
|
|
49
|
+
--diff-hunk-lineNumber--: #204274;
|
|
50
|
+
--diff-hunk-lineNumber-hover--: #1f6feb;
|
|
51
|
+
--diff-add-content-highlight--: #1f572d;
|
|
52
|
+
--diff-del-content-highlight--: #80312f;
|
|
53
|
+
--diff-add-widget--: #0969d2;
|
|
54
|
+
--diff-add-widget-color--: #ffffff;
|
|
55
|
+
--diff-empty-content--: #161b22;
|
|
56
|
+
--diff-hunk-content-color--: #9298a0;
|
|
57
|
+
|
|
58
|
+
color: white;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
[data-theme="dark"] .diff-line-syntax-raw * {
|
|
62
|
+
color: var(--diff-view-dark, inherit);
|
|
63
|
+
font-weight: var(--diff-view-dark-font-weight, inherit);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
table,
|
|
67
|
+
tr,
|
|
68
|
+
td {
|
|
69
|
+
border-color: transparent;
|
|
70
|
+
border-width: 0px;
|
|
71
|
+
text-align: left;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.diff-line-old-num,
|
|
75
|
+
.diff-line-new-num,
|
|
76
|
+
.diff-line-num {
|
|
77
|
+
text-align: right;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.diff-style-root tr {
|
|
81
|
+
content-visibility: auto;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.diff-add-widget-wrapper {
|
|
85
|
+
transform-origin: center;
|
|
86
|
+
transform: translateX(-50%) !important;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.diff-line-old-content .diff-add-widget-wrapper,
|
|
90
|
+
.diff-line-new-content .diff-add-widget-wrapper {
|
|
91
|
+
transform: translateX(50%) !important;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.diff-add-widget-wrapper:hover {
|
|
95
|
+
transform: translateX(-50%) scale(1.1) !important;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.diff-line-old-content .diff-add-widget-wrapper:hover,
|
|
99
|
+
.diff-line-new-content .diff-add-widget-wrapper:hover {
|
|
100
|
+
transform: translateX(50%) scale(1.1) !important;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.diff-widget-tooltip {
|
|
104
|
+
position: relative;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.diff-add-widget,
|
|
108
|
+
.diff-widget-tooltip {
|
|
109
|
+
font-family: inherit;
|
|
110
|
+
font-feature-settings: inherit;
|
|
111
|
+
font-variation-settings: inherit;
|
|
112
|
+
font-size: 100%;
|
|
113
|
+
font-weight: inherit;
|
|
114
|
+
line-height: inherit;
|
|
115
|
+
letter-spacing: inherit;
|
|
116
|
+
color: inherit;
|
|
117
|
+
margin: 0;
|
|
118
|
+
text-transform: none;
|
|
119
|
+
border-width: 0px;
|
|
120
|
+
background-color: transparent;
|
|
121
|
+
background-image: none;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.diff-widget-tooltip::after {
|
|
125
|
+
display: none;
|
|
126
|
+
box-sizing: border-box;
|
|
127
|
+
background-color: #555555;
|
|
128
|
+
position: absolute;
|
|
129
|
+
content: attr(data-title);
|
|
130
|
+
font-size: 11px;
|
|
131
|
+
padding: 1px 2px;
|
|
132
|
+
border-radius: 4px;
|
|
133
|
+
overflow: hidden;
|
|
134
|
+
top: 50%;
|
|
135
|
+
white-space: nowrap;
|
|
136
|
+
transform: translateY(-50%);
|
|
137
|
+
left: calc(100% + 8px);
|
|
138
|
+
color: #ffffff;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.diff-widget-tooltip::before {
|
|
142
|
+
display: none;
|
|
143
|
+
box-sizing: border-box;
|
|
144
|
+
content: "";
|
|
145
|
+
position: absolute;
|
|
146
|
+
top: 50%;
|
|
147
|
+
left: calc(100% - 2px);
|
|
148
|
+
transform: translateY(-50%);
|
|
149
|
+
border: 6px solid transparent;
|
|
150
|
+
border-right-color: #555555;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
.diff-widget-tooltip:hover {
|
|
154
|
+
background-color: var(--diff-hunk-lineNumber-hover--);
|
|
155
|
+
color: white;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
.diff-widget-tooltip:hover::before {
|
|
159
|
+
display: block;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
.diff-widget-tooltip:hover::after {
|
|
163
|
+
display: block;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.diff-line-extend-wrapper * {
|
|
167
|
+
color: initial;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
.diff-line-widget-wrapper * {
|
|
171
|
+
color: initial;
|
|
172
|
+
}
|
package/src/_theme.css
ADDED