@git-diff-view/react 0.0.26 → 0.0.27

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.
Files changed (65) hide show
  1. package/dist/cjs/index.development.js +419 -287
  2. package/dist/cjs/index.development.js.map +1 -1
  3. package/dist/cjs/index.production.js +419 -287
  4. package/dist/cjs/index.production.js.map +1 -1
  5. package/dist/css/diff-view-pure.css +4 -0
  6. package/dist/css/diff-view.css +4 -0
  7. package/dist/esm/index.mjs +353 -224
  8. package/dist/esm/index.mjs.map +1 -1
  9. package/index.d.ts +296 -16
  10. package/package.json +4 -3
  11. package/src/_base.css +3 -0
  12. package/src/_base_pure.css +2 -0
  13. package/src/_com.css +172 -0
  14. package/src/_theme.css +2 -0
  15. package/src/components/DiffAddWidget.tsx +86 -0
  16. package/src/components/DiffContent.tsx +367 -0
  17. package/src/components/DiffContent_v2.tsx +344 -0
  18. package/src/components/DiffExpand.tsx +25 -0
  19. package/src/components/DiffNoNewLine.tsx +10 -0
  20. package/src/components/DiffSplitContentLineNormal.tsx +164 -0
  21. package/src/components/DiffSplitContentLineWrap.tsx +234 -0
  22. package/src/components/DiffSplitExtendLineNormal.tsx +150 -0
  23. package/src/components/DiffSplitExtendLineWrap.tsx +133 -0
  24. package/src/components/DiffSplitHunkLineNormal.tsx +316 -0
  25. package/src/components/DiffSplitHunkLineWrap.tsx +340 -0
  26. package/src/components/DiffSplitView.tsx +46 -0
  27. package/src/components/DiffSplitViewNormal.tsx +205 -0
  28. package/src/components/DiffSplitViewWrap.tsx +141 -0
  29. package/src/components/DiffSplitWidgetLineNormal.tsx +149 -0
  30. package/src/components/DiffSplitWidgetLineWrap.tsx +127 -0
  31. package/src/components/DiffUnifiedContentLine.tsx +342 -0
  32. package/src/components/DiffUnifiedExtendLine.tsx +103 -0
  33. package/src/components/DiffUnifiedHunkLine.tsx +148 -0
  34. package/src/components/DiffUnifiedView.tsx +159 -0
  35. package/src/components/DiffUnifiedWidgetLine.tsx +104 -0
  36. package/src/components/DiffView.tsx +365 -0
  37. package/src/components/DiffViewContext.ts +11 -0
  38. package/src/components/DiffWidgetContext.ts +17 -0
  39. package/src/components/tools.ts +132 -0
  40. package/src/components/v2/DiffSplitContentLineNormal_v2.tsx +152 -0
  41. package/src/components/v2/DiffSplitContentLineWrap_v2.tsx +259 -0
  42. package/src/components/v2/DiffSplitExtendLineNormal_v2.tsx +146 -0
  43. package/src/components/v2/DiffSplitExtendLineWrap_v2.tsx +123 -0
  44. package/src/components/v2/DiffSplitHunkLineNormal_v2.tsx +302 -0
  45. package/src/components/v2/DiffSplitHunkLineWrap_v2.tsx +326 -0
  46. package/src/components/v2/DiffSplitViewLineNormal_v2.tsx +33 -0
  47. package/src/components/v2/DiffSplitViewLineWrap_v2.tsx +24 -0
  48. package/src/components/v2/DiffSplitViewNormal_v2.tsx +159 -0
  49. package/src/components/v2/DiffSplitViewWrap_v2.tsx +104 -0
  50. package/src/components/v2/DiffSplitView_v2.tsx +47 -0
  51. package/src/components/v2/DiffSplitWidgetLineNormal_v2.tsx +132 -0
  52. package/src/components/v2/DiffSplitWidgetLineWrap_v2.tsx +119 -0
  53. package/src/global.d.ts +12 -0
  54. package/src/hooks/useCallbackRef.ts +18 -0
  55. package/src/hooks/useDomWidth.ts +67 -0
  56. package/src/hooks/useIsMounted.ts +11 -0
  57. package/src/hooks/useSafeLayout.ts +5 -0
  58. package/src/hooks/useSyncHeight.ts +87 -0
  59. package/src/hooks/useTextWidth.ts +27 -0
  60. package/src/hooks/useUnmount.ts +10 -0
  61. package/src/index.ts +3 -0
  62. package/src/tailwind.css +3 -0
  63. package/src/tailwind_pure.css +3 -0
  64. package/styles/diff-view-pure.css +4 -0
  65. 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
- readonly raw: string;
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, SyntaxLine>;
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"];
@@ -78,10 +82,14 @@ export declare class DiffFile {
78
82
  buildSplitDiffLines(): void;
79
83
  buildUnifiedDiffLines(): void;
80
84
  getSplitLeftLine: (index: number) => SplitLineItem;
85
+ getSplitLineByLineNumber: (lineNumber: number, side: SplitSide) => SplitLineItem;
86
+ getSplitLineIndexByLineNumber: (lineNumber: number, side: SplitSide) => number;
81
87
  getSplitRightLine: (index: number) => SplitLineItem;
82
88
  getSplitHunkLine: (index: number) => DiffHunkItem;
83
89
  onSplitHunkExpand: (dir: "up" | "down" | "all", index: number, needTrigger?: boolean) => void;
84
90
  getUnifiedLine: (index: number) => UnifiedLineItem;
91
+ getUnifiedLineByLineNumber: (lienNumber: number, side: SplitSide) => UnifiedLineItem;
92
+ getUnifiedLineIndexByLineNumber: (lineNumber: number, side: SplitSide) => number;
85
93
  getUnifiedHunkLine: (index: number) => DiffHunkItem;
86
94
  onUnifiedHunkExpand: (dir: "up" | "down" | "all", index: number, needTrigger?: boolean) => void;
87
95
  onAllExpand: (mode: "split" | "unified") => void;
@@ -90,8 +98,16 @@ export declare class DiffFile {
90
98
  onAllCollapse: (mode: "split" | "unified") => void;
91
99
  getOldFileContent: () => string;
92
100
  getNewFileContent: () => string;
93
- getOldSyntaxLine: (lineNumber: number) => SyntaxLine;
94
- getNewSyntaxLine: (lineNumber: number) => SyntaxLine;
101
+ getOldPlainLine: (lineNumber: number) => {
102
+ value: string;
103
+ template?: string;
104
+ };
105
+ getOldSyntaxLine: (lineNumber: number) => SyntaxLineWithTemplate;
106
+ getNewPlainLine: (lineNumber: number) => {
107
+ value: string;
108
+ template?: string;
109
+ };
110
+ getNewSyntaxLine: (lineNumber: number) => SyntaxLineWithTemplate;
95
111
  subscribe: (listener: (() => void) & {
96
112
  isSyncExternal?: boolean;
97
113
  }) => () => void;
@@ -105,11 +121,19 @@ export declare class DiffFile {
105
121
  hasBuildUnified: boolean;
106
122
  oldFileLines: Record<number, string>;
107
123
  oldFileDiffLines: Record<string, DiffLineItem>;
108
- oldFileSyntaxLines: Record<number, SyntaxLine>;
124
+ oldFilePlainLines: Record<number, {
125
+ value: string;
126
+ template?: string;
127
+ }>;
128
+ oldFileSyntaxLines: Record<number, SyntaxLineWithTemplate>;
109
129
  oldFilePlaceholderLines: Record<string, boolean>;
110
130
  newFileLines: Record<number, string>;
111
131
  newFileDiffLines: Record<string, DiffLineItem>;
112
- newFileSyntaxLines: Record<number, SyntaxLine>;
132
+ newFilePlainLines: Record<number, {
133
+ value: string;
134
+ template?: string;
135
+ }>;
136
+ newFileSyntaxLines: Record<number, SyntaxLineWithTemplate>;
113
137
  newFilePlaceholderLines: Record<string, boolean>;
114
138
  splitLineLength: number;
115
139
  unifiedLineLength: number;
@@ -154,11 +178,19 @@ export declare class DiffFile {
154
178
  hasBuildUnified: boolean;
155
179
  oldFileLines: Record<number, string>;
156
180
  oldFileDiffLines: Record<string, DiffLineItem>;
157
- oldFileSyntaxLines: Record<number, SyntaxLine>;
181
+ oldFilePlainLines: Record<number, {
182
+ value: string;
183
+ template?: string;
184
+ }>;
185
+ oldFileSyntaxLines: Record<number, SyntaxLineWithTemplate>;
158
186
  oldFilePlaceholderLines: Record<string, boolean>;
159
187
  newFileLines: Record<number, string>;
160
188
  newFileDiffLines: Record<string, DiffLineItem>;
161
- newFileSyntaxLines: Record<number, SyntaxLine>;
189
+ newFilePlainLines: Record<number, {
190
+ value: string;
191
+ template?: string;
192
+ }>;
193
+ newFileSyntaxLines: Record<number, SyntaxLineWithTemplate>;
162
194
  newFilePlaceholderLines: Record<string, boolean>;
163
195
  splitLineLength: number;
164
196
  unifiedLineLength: number;
@@ -229,7 +261,9 @@ export declare class DiffLine {
229
261
  readonly noTrailingNewLine: boolean;
230
262
  changes?: IRange;
231
263
  diffChanges?: DiffRange;
232
- constructor(text: string, type: DiffLineType, originalLineNumber: number | null, oldLineNumber: number | null, newLineNumber: number | null, noTrailingNewLine?: boolean, changes?: IRange, diffChanges?: DiffRange);
264
+ plainTemplate?: string;
265
+ syntaxTemplate?: string;
266
+ 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
267
  withNoTrailingNewLine(noTrailingNewLine: boolean): DiffLine;
234
268
  isIncludeableLine(): boolean;
235
269
  equals(other: DiffLine): boolean;
@@ -372,25 +406,120 @@ export declare const DefaultDiffExpansionStep = 40;
372
406
  */
373
407
  export declare const HiddenBidiCharsRegex: RegExp;
374
408
  export declare const _cacheMap: Cache$1<string, File$1>;
409
+ export declare const changeDefaultComposeLength: (compose: number) => void;
410
+ export declare const checkCurrentLineIsHidden: (diffFile: DiffFile, lineNumber: number, side: SplitSide) => {
411
+ split: boolean;
412
+ unified: boolean;
413
+ };
375
414
  export declare const checkDiffLineIncludeChange: (diffLine?: DiffLine) => boolean;
376
- export declare const composeLen = 40;
377
415
  export declare const disableCache: () => void;
378
- export declare const getDiffRange: (additions: DiffLine[], deletions: DiffLine[], { getAdditionRaw, getDeletionRaw, }: {
416
+ export declare const getCurrentComposeLength: () => number;
417
+ export declare const getDiffRange: (additions: DiffLine[], deletions: DiffLine[], { getAdditionRaw, getDeletionRaw, getAdditionSyntax, getDeletionSyntax, }: {
379
418
  getAdditionRaw: (lineNumber: number) => string;
380
419
  getDeletionRaw: (lineNumber: number) => string;
420
+ getAdditionSyntax: (lineNumber: number) => SyntaxLineWithTemplate;
421
+ getDeletionSyntax: (lineNumber: number) => SyntaxLineWithTemplate;
381
422
  }) => void;
382
423
  export declare const getLang: (fileName: string) => string;
424
+ export declare const getPlainDiffTemplate: ({ diffLine, rawLine, operator, }: {
425
+ diffLine: DiffLine;
426
+ rawLine: string;
427
+ operator: "add" | "del";
428
+ }) => void;
429
+ export declare const getPlainLineTemplate: (line: string) => string;
383
430
  export declare const getSplitContentLines: (diffFile: DiffFile) => DiffSplitContentLineItem[];
384
431
  export declare const getSplitLines: (diffFile: DiffFile) => DiffSplitLineItem[];
432
+ export declare const getSyntaxDiffTemplate: ({ diffLine, syntaxLine, operator, }: {
433
+ diffLine: DiffLine;
434
+ syntaxLine: SyntaxLineWithTemplate;
435
+ operator: "add" | "del";
436
+ }) => void;
437
+ export declare const getSyntaxLineTemplate: (line: SyntaxLine) => string;
385
438
  export declare const getUnifiedContentLine: (diffFile: DiffFile) => DiffUnifiedContentLineItem[];
386
439
  export declare const getUnifiedLines: (diffFile: DiffFile) => DiffUnifiedLineItem[];
387
440
  export declare const highlighter: DiffHighlighter;
441
+ /**
442
+ * Checks whether content transformation is currently enabled.
443
+ *
444
+ * @returns {boolean} True if transformation is enabled, false otherwise
445
+ *
446
+ * @example
447
+ * ```typescript
448
+ * if (isTransformEnabled()) {
449
+ * console.log('Transformations are active');
450
+ * }
451
+ * ```
452
+ */
453
+ export declare const isTransformEnabled: () => boolean;
388
454
  export declare const numIterator: <T>(num: number, cb: (index: number) => T) => T[];
389
455
  export declare const parseInstance: DiffParser;
390
456
  export declare const processAST: (ast: DiffAST) => {
391
457
  syntaxFileObject: Record<number, SyntaxLine>;
392
458
  syntaxFileLineNumber: number;
393
459
  };
460
+ /**
461
+ * Applies the file transformation function to the provided content if transformation is enabled.
462
+ *
463
+ * @param content - The content string to transform
464
+ * @returns {string} The transformed content if transformation is enabled and configured, otherwise the original content
465
+ *
466
+ * @example
467
+ * ```typescript
468
+ * const transformed = doTransformFile('some file content');
469
+ * ```
470
+ */
471
+ export declare const processTransformForFile: (content: string) => string;
472
+ /**
473
+ * Applies the transformation function to the provided content if transformation is enabled.
474
+ *
475
+ * @param content - The content string to transform
476
+ * @returns {string} The transformed content if transformation is enabled and configured, otherwise the original content
477
+ *
478
+ * @example
479
+ * ```typescript
480
+ * const transformed = processTransformTemplateContent(' hello world ');
481
+ * ```
482
+ */
483
+ export declare const processTransformTemplateContent: (content: string) => string;
484
+ export declare const resetDefaultComposeLength: () => void;
485
+ /**
486
+ * Resets all transformation functions to their default state and disables transformation.
487
+ *
488
+ * @example
489
+ * ```typescript
490
+ * resetTransform(); // Clears all transformations
491
+ * ```
492
+ */
493
+ export declare const resetTransform: () => void;
494
+ /**
495
+ * ⚠️ **WARNING: DANGEROUS OPERATION** ⚠️
496
+ *
497
+ * @param fn - The transformation function to apply to file content
498
+ * @throws {Error} Throws an error if the provided parameter is not a function
499
+ *
500
+ * @example
501
+ * ```typescript
502
+ * // Use with caution - this affects global behavior
503
+ * setTransformFile((content) => content.toUpperCase());
504
+ * ```
505
+ */
506
+ export declare const setTransformForFile: (fn: (content: string) => string) => void;
507
+ /**
508
+ * ⚠️ **WARNING: DANGEROUS OPERATION** ⚠️
509
+ *
510
+ * This function modifies global state and may cause unexpected side effects.
511
+ * You may also need escapeHTML for the content.
512
+ *
513
+ * @param fn - The transformation function to help transform template content
514
+ * @throws {Error} Throws an error if the provided parameter is not a function
515
+ *
516
+ * @example
517
+ * ```typescript
518
+ * // Use with caution - this affects global behavior
519
+ * setTransformForTemplateContent((content) => content.trim());
520
+ * ```
521
+ */
522
+ export declare const setTransformForTemplateContent: (fn: (content: string) => string) => void;
394
523
  export declare const versions: string;
395
524
  export declare enum DiffFileLineType {
396
525
  hunk = 1,
@@ -434,6 +563,10 @@ export declare enum NewLineSymbol {
434
563
  NORMAL = 5,
435
564
  NULL = 6
436
565
  }
566
+ export declare enum SplitSide {
567
+ old = 1,
568
+ new = 2
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;
439
572
  export declare function assertNever(_: never, message: string): never;
@@ -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
- export declare enum SplitSide {
653
- old = 1,
654
- new = 2
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.26",
6
+ "version": "0.0.27",
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.26",
64
+ "@git-diff-view/core": "^0.0.27",
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.9",
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
@@ -0,0 +1,3 @@
1
+ @tailwind base;
2
+ @tailwind components;
3
+ @tailwind utilities;
@@ -0,0 +1,2 @@
1
+ @tailwind components;
2
+ @tailwind utilities;
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
@@ -0,0 +1,2 @@
1
+ @import url(highlight.js/styles/github.css);
2
+ @import url(highlight.js/styles/github-dark.css);