@git-diff-view/react 0.0.25 → 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 +543 -376
  2. package/dist/cjs/index.development.js.map +1 -1
  3. package/dist/cjs/index.production.js +543 -376
  4. package/dist/cjs/index.production.js.map +1 -1
  5. package/dist/css/diff-view-pure.css +5 -1
  6. package/dist/css/diff-view.css +6 -2
  7. package/dist/esm/index.mjs +485 -321
  8. package/dist/esm/index.mjs.map +1 -1
  9. package/index.d.ts +317 -23
  10. package/package.json +8 -7
  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 +5 -1
  65. package/styles/diff-view.css +6 -2
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"];
@@ -61,8 +65,6 @@ export declare class DiffFile {
61
65
  fileLineLength: number;
62
66
  additionLength: number;
63
67
  deletionLength: number;
64
- hasExpandSplitAll: boolean;
65
- hasExpandUnifiedAll: boolean;
66
68
  hasSomeLineCollapsed: boolean;
67
69
  static createInstance(data: FileData_1, bundle?: ReturnType<DiffFile["getBundle"] | DiffFile["_getFullBundle"]>): DiffFile;
68
70
  static createInstance(data: FileData_2, bundle?: ReturnType<DiffFile["getBundle"] | DiffFile["_getFullBundle"]>): DiffFile;
@@ -80,16 +82,32 @@ export declare class DiffFile {
80
82
  buildSplitDiffLines(): void;
81
83
  buildUnifiedDiffLines(): void;
82
84
  getSplitLeftLine: (index: number) => SplitLineItem;
85
+ getSplitLineByLineNumber: (lineNumber: number, side: SplitSide) => SplitLineItem;
86
+ getSplitLineIndexByLineNumber: (lineNumber: number, side: SplitSide) => number;
83
87
  getSplitRightLine: (index: number) => SplitLineItem;
84
88
  getSplitHunkLine: (index: number) => DiffHunkItem;
85
89
  onSplitHunkExpand: (dir: "up" | "down" | "all", index: number, needTrigger?: boolean) => void;
86
90
  getUnifiedLine: (index: number) => UnifiedLineItem;
91
+ getUnifiedLineByLineNumber: (lienNumber: number, side: SplitSide) => UnifiedLineItem;
92
+ getUnifiedLineIndexByLineNumber: (lineNumber: number, side: SplitSide) => number;
87
93
  getUnifiedHunkLine: (index: number) => DiffHunkItem;
88
94
  onUnifiedHunkExpand: (dir: "up" | "down" | "all", index: number, needTrigger?: boolean) => void;
89
95
  onAllExpand: (mode: "split" | "unified") => void;
96
+ get hasExpandSplitAll(): boolean;
97
+ get hasExpandUnifiedAll(): boolean;
90
98
  onAllCollapse: (mode: "split" | "unified") => void;
91
- getOldSyntaxLine: (lineNumber: number) => SyntaxLine;
92
- getNewSyntaxLine: (lineNumber: number) => SyntaxLine;
99
+ getOldFileContent: () => string;
100
+ getNewFileContent: () => string;
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;
93
111
  subscribe: (listener: (() => void) & {
94
112
  isSyncExternal?: boolean;
95
113
  }) => () => void;
@@ -103,11 +121,19 @@ export declare class DiffFile {
103
121
  hasBuildUnified: boolean;
104
122
  oldFileLines: Record<number, string>;
105
123
  oldFileDiffLines: Record<string, DiffLineItem>;
106
- oldFileSyntaxLines: Record<number, SyntaxLine>;
124
+ oldFilePlainLines: Record<number, {
125
+ value: string;
126
+ template?: string;
127
+ }>;
128
+ oldFileSyntaxLines: Record<number, SyntaxLineWithTemplate>;
107
129
  oldFilePlaceholderLines: Record<string, boolean>;
108
130
  newFileLines: Record<number, string>;
109
131
  newFileDiffLines: Record<string, DiffLineItem>;
110
- newFileSyntaxLines: Record<number, SyntaxLine>;
132
+ newFilePlainLines: Record<number, {
133
+ value: string;
134
+ template?: string;
135
+ }>;
136
+ newFileSyntaxLines: Record<number, SyntaxLineWithTemplate>;
111
137
  newFilePlaceholderLines: Record<string, boolean>;
112
138
  splitLineLength: number;
113
139
  unifiedLineLength: number;
@@ -123,6 +149,12 @@ export declare class DiffFile {
123
149
  highlighterType: string;
124
150
  composeByDiff: boolean;
125
151
  hasSomeLineCollapsed: boolean;
152
+ hasExpandSplitAll: {
153
+ state: boolean;
154
+ };
155
+ hasExpandUnifiedAll: {
156
+ state: boolean;
157
+ };
126
158
  version: string;
127
159
  theme: "light" | "dark";
128
160
  isFullMerge: boolean;
@@ -146,11 +178,19 @@ export declare class DiffFile {
146
178
  hasBuildUnified: boolean;
147
179
  oldFileLines: Record<number, string>;
148
180
  oldFileDiffLines: Record<string, DiffLineItem>;
149
- oldFileSyntaxLines: Record<number, SyntaxLine>;
181
+ oldFilePlainLines: Record<number, {
182
+ value: string;
183
+ template?: string;
184
+ }>;
185
+ oldFileSyntaxLines: Record<number, SyntaxLineWithTemplate>;
150
186
  oldFilePlaceholderLines: Record<string, boolean>;
151
187
  newFileLines: Record<number, string>;
152
188
  newFileDiffLines: Record<string, DiffLineItem>;
153
- newFileSyntaxLines: Record<number, SyntaxLine>;
189
+ newFilePlainLines: Record<number, {
190
+ value: string;
191
+ template?: string;
192
+ }>;
193
+ newFileSyntaxLines: Record<number, SyntaxLineWithTemplate>;
154
194
  newFilePlaceholderLines: Record<string, boolean>;
155
195
  splitLineLength: number;
156
196
  unifiedLineLength: number;
@@ -166,6 +206,12 @@ export declare class DiffFile {
166
206
  highlighterType: string;
167
207
  composeByDiff: boolean;
168
208
  hasSomeLineCollapsed: boolean;
209
+ hasExpandSplitAll: {
210
+ state: boolean;
211
+ };
212
+ hasExpandUnifiedAll: {
213
+ state: boolean;
214
+ };
169
215
  version: string;
170
216
  theme: "light" | "dark";
171
217
  };
@@ -215,7 +261,9 @@ export declare class DiffLine {
215
261
  readonly noTrailingNewLine: boolean;
216
262
  changes?: IRange;
217
263
  diffChanges?: DiffRange;
218
- 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);
219
267
  withNoTrailingNewLine(noTrailingNewLine: boolean): DiffLine;
220
268
  isIncludeableLine(): boolean;
221
269
  equals(other: DiffLine): boolean;
@@ -358,25 +406,120 @@ export declare const DefaultDiffExpansionStep = 40;
358
406
  */
359
407
  export declare const HiddenBidiCharsRegex: RegExp;
360
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
+ };
361
414
  export declare const checkDiffLineIncludeChange: (diffLine?: DiffLine) => boolean;
362
- export declare const composeLen = 40;
363
415
  export declare const disableCache: () => void;
364
- 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, }: {
365
418
  getAdditionRaw: (lineNumber: number) => string;
366
419
  getDeletionRaw: (lineNumber: number) => string;
420
+ getAdditionSyntax: (lineNumber: number) => SyntaxLineWithTemplate;
421
+ getDeletionSyntax: (lineNumber: number) => SyntaxLineWithTemplate;
367
422
  }) => void;
368
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;
369
430
  export declare const getSplitContentLines: (diffFile: DiffFile) => DiffSplitContentLineItem[];
370
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;
371
438
  export declare const getUnifiedContentLine: (diffFile: DiffFile) => DiffUnifiedContentLineItem[];
372
439
  export declare const getUnifiedLines: (diffFile: DiffFile) => DiffUnifiedLineItem[];
373
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;
374
454
  export declare const numIterator: <T>(num: number, cb: (index: number) => T) => T[];
375
455
  export declare const parseInstance: DiffParser;
376
456
  export declare const processAST: (ast: DiffAST) => {
377
457
  syntaxFileObject: Record<number, SyntaxLine>;
378
458
  syntaxFileLineNumber: number;
379
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;
380
523
  export declare const versions: string;
381
524
  export declare enum DiffFileLineType {
382
525
  hunk = 1,
@@ -420,6 +563,10 @@ export declare enum NewLineSymbol {
420
563
  NORMAL = 5,
421
564
  NULL = 6
422
565
  }
566
+ export declare enum SplitSide {
567
+ old = 1,
568
+ new = 2
569
+ }
423
570
  export declare function _getAST(raw: string, fileName?: string, lang?: DiffHighlighterLang, theme?: "light" | "dark"): DiffAST;
424
571
  export declare function _getAST(raw: string, fileName?: string, lang?: string, theme?: "light" | "dark"): DiffAST;
425
572
  export declare function assertNever(_: never, message: string): never;
@@ -427,6 +574,7 @@ export declare function diffChanges(addition: DiffLine, deletion: DiffLine): {
427
574
  addRange: DiffRange;
428
575
  delRange: DiffRange;
429
576
  };
577
+ export declare function escapeHtml(string: unknown): string;
430
578
  export declare function getFile(raw: string, lang: DiffHighlighterLang, theme: "light" | "dark", fileName?: string, uuid?: string): File$1;
431
579
  export declare function getFile(raw: string, lang: string, theme: "light" | "dark", fileName?: string, uuid?: string): File$1;
432
580
  /**
@@ -447,6 +595,7 @@ export declare function relativeChanges(addition: DiffLine, deletion: DiffLine):
447
595
  addRange: IRange;
448
596
  delRange: IRange;
449
597
  };
598
+ export declare let composeLen: number;
450
599
  export interface DiffHunkItem extends DiffLineItem {
451
600
  isFirst: boolean;
452
601
  isLast: boolean;
@@ -622,6 +771,9 @@ export type SyntaxLine = {
622
771
  wrapper?: SyntaxNode;
623
772
  }[];
624
773
  };
774
+ export type SyntaxLineWithTemplate = SyntaxLine & {
775
+ template?: string;
776
+ };
625
777
  // Generated by dts-bundle-generator v9.5.1
626
778
  export type SyntaxNode = {
627
779
  type: string;
@@ -635,10 +787,151 @@ export type SyntaxNode = {
635
787
  };
636
788
  children?: SyntaxNode[];
637
789
  };
638
- export declare enum SplitSide {
639
- old = 1,
640
- new = 2
641
- }
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
+ }>;
642
935
  export declare enum DiffModeEnum {
643
936
  SplitGitHub = 1,
644
937
  SplitGitLab = 2,
@@ -695,6 +988,7 @@ export type DiffViewProps<T> = {
695
988
  onUpdate: () => void;
696
989
  }) => ReactNode;
697
990
  onAddWidgetClick?: (lineNumber: number, side: SplitSide) => void;
991
+ onCreateUseWidgetHook?: (hook: ReturnType<typeof createDiffWidgetStore>) => void;
698
992
  };
699
993
  export type DiffViewProps_1<T> = Omit<DiffViewProps<T>, "data"> & {
700
994
  data?: {
@@ -726,17 +1020,17 @@ export type DiffViewProps_2<T> = Omit<DiffViewProps<T>, "data"> & {
726
1020
  hunks: string[];
727
1021
  };
728
1022
  };
729
- declare function _DiffView<T>(props: DiffViewProps_1<T> & {
1023
+ declare function ReactDiffView<T>(props: DiffViewProps_1<T> & {
730
1024
  ref?: ForwardedRef<{
731
1025
  getDiffFileInstance: () => DiffFile;
732
1026
  }>;
733
- }): ReactNode;
734
- declare function _DiffView<T>(props: DiffViewProps_2<T> & {
1027
+ }): JSX.Element;
1028
+ declare function ReactDiffView<T>(props: DiffViewProps_2<T> & {
735
1029
  ref?: ForwardedRef<{
736
1030
  getDiffFileInstance: () => DiffFile;
737
1031
  }>;
738
- }): ReactNode;
739
- export declare const DiffView: typeof _DiffView;
1032
+ }): JSX.Element;
1033
+ export declare const DiffView: typeof ReactDiffView;
740
1034
  export declare const version: string;
741
1035
 
742
1036
  export {
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.25",
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,24 +61,24 @@
60
61
  "react diff component"
61
62
  ],
62
63
  "dependencies": {
63
- "@git-diff-view/core": "^0.0.25",
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": {
72
73
  "@types/use-sync-external-store": "^0.0.6",
73
74
  "autoprefixer": "^10.4.20",
74
- "postcss": "^8.4.47",
75
+ "postcss": "^8.5.1",
75
76
  "react": "^18.0.0",
76
- "tailwindcss": "^3.4.14"
77
+ "tailwindcss": "^3.4.17"
77
78
  },
78
79
  "peerDependencies": {
79
- "react": "^16.8.0 || ^17.0.0 || ^18.0.0",
80
- "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0"
80
+ "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
81
+ "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
81
82
  },
82
83
  "scripts": {
83
84
  "gen:type": "dts-bundle-generator -o index.d.ts dist/types/index.d.ts",
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;