@git-diff-view/react 0.0.14 → 0.0.15

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/index.d.ts CHANGED
@@ -1,75 +1,172 @@
1
1
  // Generated by dts-bundle-generator v9.5.1
2
2
 
3
3
  import { CSSProperties, ForwardedRef, ReactNode } from 'react';
4
- import { Ref, UseSelectorWithStore } from 'reactivity-store';
5
4
 
6
- // Generated by dts-bundle-generator v9.5.1
7
- export declare enum NewLineSymbol {
8
- CRLF = 1,
9
- CR = 2,
10
- LF = 3,
11
- NEWLINE = 4
5
+ declare class Cache$1<K, V> extends Map<K, V> {
6
+ name: string;
7
+ setMaxLength(length: number): void;
8
+ set(key: K, value: V): this;
9
+ _checkLength(): void;
12
10
  }
13
- export interface IRange {
14
- /** The starting location for the range. */
15
- readonly location: number;
16
- /** The length of the range. */
17
- readonly length: number;
18
- readonly newLineSymbol?: NewLineSymbol;
11
+ declare class File$1 {
12
+ readonly raw: string;
13
+ readonly lang: string;
14
+ readonly fileName?: string;
15
+ ast?: DiffAST;
16
+ rawFile: Record<number, string>;
17
+ hasDoRaw: boolean;
18
+ rawLength?: number;
19
+ syntaxFile: Record<number, SyntaxLine>;
20
+ hasDoSyntax: boolean;
21
+ syntaxLength?: number;
22
+ highlighterName?: string;
23
+ maxLineNumber: number;
24
+ static createInstance(data: File$1): File$1;
25
+ constructor(raw: string, lang: string, fileName?: string);
26
+ doSyntax({ registerHighlighter }: {
27
+ registerHighlighter?: Omit<DiffHighlighter, "getHighlighterEngine">;
28
+ }): void;
29
+ doRaw(): void;
19
30
  }
20
- /** Get the changed ranges in the strings, relative to each other. */
21
- export declare function relativeChanges(addition: DiffLine, deletion: DiffLine): {
22
- stringARange: IRange;
23
- stringBRange: IRange;
31
+ declare const lowlight: {
32
+ highlight: (language: string, value: string, options?: Readonly<import("lowlight").Options>) => import("hast").Root;
33
+ highlightAuto: (value: string, options?: Readonly<import("lowlight").AutoOptions>) => import("hast").Root;
34
+ listLanguages: () => string[];
35
+ register: {
36
+ (grammars: Readonly<Record<string, import("highlight.js").LanguageFn>>): undefined;
37
+ (name: string, grammar: import("highlight.js").LanguageFn): undefined;
38
+ };
39
+ registerAlias: {
40
+ (aliases: Readonly<Record<string, string | readonly string[]>>): undefined;
41
+ (language: string, alias: string | readonly string[]): undefined;
42
+ };
43
+ registered: (aliasOrName: string) => boolean;
24
44
  };
25
- /** Check two string have a diff range */
26
- export declare function hasRelativeChange(addition: DiffLine, deletion: DiffLine): boolean;
27
- /** indicate what a line in the diff represents */
28
- export declare enum DiffLineType {
29
- Context = 0,
30
- Add = 1,
31
- Delete = 2,
32
- Hunk = 3
33
- }
34
- /** track details related to each line in the diff */
35
- export declare class DiffLine {
36
- readonly text: string;
37
- readonly type: DiffLineType;
38
- readonly originalLineNumber: number | null;
39
- readonly oldLineNumber: number | null;
40
- readonly newLineNumber: number | null;
41
- readonly noTrailingNewLine: boolean;
42
- needRematch: boolean;
43
- range?: IRange;
44
- constructor(text: string, type: DiffLineType, originalLineNumber: number | null, oldLineNumber: number | null, newLineNumber: number | null, noTrailingNewLine?: boolean, needRematch?: boolean, range?: IRange);
45
- withNoTrailingNewLine(noTrailingNewLine: boolean): DiffLine;
46
- isIncludeableLine(): boolean;
47
- /** The content of the line, i.e., without the line type marker. */
48
- get content(): string;
49
- equals(other: DiffLine): boolean;
50
- clone(text: string): DiffLine;
51
- }
52
- export declare const checkDiffLineIncludeChange: (diffLine?: DiffLine) => boolean;
53
- export declare enum DiffHunkExpansionType {
54
- /** The hunk header cannot be expanded at all. */
55
- None = "None",
56
- /**
57
- * The hunk header can be expanded up exclusively. Only the first hunk can be
58
- * expanded up exclusively.
59
- */
60
- Up = "Up",
61
- /**
62
- * The hunk header can be expanded down exclusively. Only the last hunk (if
63
- * it's the dummy hunk with only one line) can be expanded down exclusively.
64
- */
65
- Down = "Down",
66
- /** The hunk header can be expanded both up and down. */
67
- Both = "Both",
68
- /**
69
- * The hunk header represents a short gap that, when expanded, will
70
- * result in merging this hunk and the hunk above.
71
- */
72
- Short = "Short"
45
+ export declare class DiffFile {
46
+ readonly _oldFileName: string;
47
+ readonly _newFileName: string;
48
+ readonly _diffList: string[];
49
+ readonly uuid?: string;
50
+ _version_: string;
51
+ _oldFileContent: string;
52
+ _oldFileLang: string;
53
+ _newFileContent: string;
54
+ _newFileLang: string;
55
+ diffLineLength: number;
56
+ splitLineLength: number;
57
+ unifiedLineLength: number;
58
+ fileLineLength: number;
59
+ hasExpandSplitAll: boolean;
60
+ hasExpandUnifiedAll: boolean;
61
+ hasSomeLineCollapsed: boolean;
62
+ static createInstance(data: {
63
+ oldFile?: {
64
+ fileName?: string | null;
65
+ fileLang?: string | null;
66
+ content?: string | null;
67
+ };
68
+ newFile?: {
69
+ fileName?: string | null;
70
+ fileLang?: string | null;
71
+ content?: string | null;
72
+ };
73
+ hunks?: string[];
74
+ }, bundle?: ReturnType<DiffFile["getBundle"] | DiffFile["_getFullBundle"]>): DiffFile;
75
+ constructor(_oldFileName: string, _oldFileContent: string, _newFileName: string, _newFileContent: string, _diffList: string[], _oldFileLang?: string, _newFileLang?: string, uuid?: string);
76
+ initId(): void;
77
+ getId(): string;
78
+ clearId(): void;
79
+ initRaw(): void;
80
+ initSyntax({ registerHighlighter }?: {
81
+ registerHighlighter?: Omit<DiffHighlighter, "getHighlighterEngine">;
82
+ }): void;
83
+ init(): void;
84
+ buildSplitDiffLines(): void;
85
+ buildUnifiedDiffLines(): void;
86
+ getSplitLeftLine: (index: number) => SplitLineItem;
87
+ getSplitRightLine: (index: number) => SplitLineItem;
88
+ getSplitHunkLine: (index: number) => DiffHunkItem;
89
+ onSplitHunkExpand: (dir: "up" | "down" | "all", index: number, needTrigger?: boolean) => void;
90
+ getUnifiedLine: (index: number) => UnifiedLineItem;
91
+ getUnifiedHunkLine: (index: number) => DiffHunkItem;
92
+ onUnifiedHunkExpand: (dir: "up" | "down" | "all", index: number, needTrigger?: boolean) => void;
93
+ onAllExpand: (mode: "split" | "unified") => void;
94
+ onAllCollapse: (mode: "split" | "unified") => void;
95
+ getOldSyntaxLine: (lineNumber: number) => SyntaxLine;
96
+ getNewSyntaxLine: (lineNumber: number) => SyntaxLine;
97
+ subscribe: (listener: (() => void) & {
98
+ isSyncExternal?: boolean;
99
+ }) => () => void;
100
+ notifyAll: (skipSyncExternal?: boolean) => void;
101
+ getUpdateCount: () => number;
102
+ getExpandEnabled: () => boolean;
103
+ getBundle: () => {
104
+ hasInitRaw: boolean;
105
+ hasInitSyntax: boolean;
106
+ hasBuildSplit: boolean;
107
+ hasBuildUnified: boolean;
108
+ oldFileLines: Record<number, string>;
109
+ oldFileDiffLines: Record<string, DiffLineItem>;
110
+ oldFileSyntaxLines: Record<number, SyntaxLine>;
111
+ oldFilePlaceholderLines: Record<string, boolean>;
112
+ newFileLines: Record<number, string>;
113
+ newFileDiffLines: Record<string, DiffLineItem>;
114
+ newFileSyntaxLines: Record<number, SyntaxLine>;
115
+ newFilePlaceholderLines: Record<string, boolean>;
116
+ splitLineLength: number;
117
+ unifiedLineLength: number;
118
+ fileLineLength: number;
119
+ splitLeftLines: SplitLineItem[];
120
+ splitRightLines: SplitLineItem[];
121
+ splitHunkLines: Record<string, DiffHunkItem>;
122
+ unifiedLines: UnifiedLineItem[];
123
+ unifiedHunkLines: Record<string, DiffHunkItem>;
124
+ highlighterName: string;
125
+ composeByDiff: boolean;
126
+ hasSomeLineCollapsed: boolean;
127
+ version: string;
128
+ isFullMerge: boolean;
129
+ };
130
+ mergeBundle: (data: ReturnType<DiffFile["getBundle"]>) => void;
131
+ _getHighlighterName: () => string;
132
+ _getIsPureDiffRender: () => boolean;
133
+ _addClonedInstance: (instance: DiffFile) => void;
134
+ _notifyOthers: (instance: DiffFile) => void;
135
+ _delClonedInstance: (instance: DiffFile) => void;
136
+ _getFullBundle: () => {
137
+ oldFileResult: File$1;
138
+ newFileResult: File$1;
139
+ diffLines: DiffLineItem[];
140
+ diffListResults: IRawDiff[];
141
+ isFullMerge: boolean;
142
+ hasInitRaw: boolean;
143
+ hasInitSyntax: boolean;
144
+ hasBuildSplit: boolean;
145
+ hasBuildUnified: boolean;
146
+ oldFileLines: Record<number, string>;
147
+ oldFileDiffLines: Record<string, DiffLineItem>;
148
+ oldFileSyntaxLines: Record<number, SyntaxLine>;
149
+ oldFilePlaceholderLines: Record<string, boolean>;
150
+ newFileLines: Record<number, string>;
151
+ newFileDiffLines: Record<string, DiffLineItem>;
152
+ newFileSyntaxLines: Record<number, SyntaxLine>;
153
+ newFilePlaceholderLines: Record<string, boolean>;
154
+ splitLineLength: number;
155
+ unifiedLineLength: number;
156
+ fileLineLength: number;
157
+ splitLeftLines: SplitLineItem[];
158
+ splitRightLines: SplitLineItem[];
159
+ splitHunkLines: Record<string, DiffHunkItem>;
160
+ unifiedLines: UnifiedLineItem[];
161
+ unifiedHunkLines: Record<string, DiffHunkItem>;
162
+ highlighterName: string;
163
+ composeByDiff: boolean;
164
+ hasSomeLineCollapsed: boolean;
165
+ version: string;
166
+ };
167
+ _mergeFullBundle: (data: ReturnType<DiffFile["_getFullBundle"]>) => void;
168
+ _destroy: () => void;
169
+ clear: () => void;
73
170
  }
74
171
  /** each diff is made up of a number of hunks */
75
172
  export declare class DiffHunk {
@@ -103,87 +200,44 @@ export declare class DiffHunkHeader {
103
200
  toDiffLineRepresentation(): string;
104
201
  equals(other: DiffHunkHeader): boolean;
105
202
  }
106
- /** the contents of a diff generated by Git */
107
- export interface IRawDiff {
203
+ /** track details related to each line in the diff */
204
+ export declare class DiffLine {
205
+ readonly text: string;
206
+ readonly type: DiffLineType;
207
+ readonly originalLineNumber: number | null;
208
+ readonly oldLineNumber: number | null;
209
+ readonly newLineNumber: number | null;
210
+ readonly noTrailingNewLine: boolean;
211
+ changes?: IRange;
212
+ diffChanges?: DiffRange;
213
+ constructor(text: string, type: DiffLineType, originalLineNumber: number | null, oldLineNumber: number | null, newLineNumber: number | null, noTrailingNewLine?: boolean, changes?: IRange, diffChanges?: DiffRange);
214
+ withNoTrailingNewLine(noTrailingNewLine: boolean): DiffLine;
215
+ isIncludeableLine(): boolean;
216
+ equals(other: DiffLine): boolean;
217
+ clone(text: string): DiffLine;
218
+ }
219
+ /**
220
+ * A parser for the GNU unified diff format
221
+ *
222
+ * See https://www.gnu.org/software/diffutils/manual/html_node/Detailed-Unified.html
223
+ */
224
+ export declare class DiffParser {
108
225
  /**
109
- * The plain text contents of the diff header. This contains
110
- * everything from the start of the diff up until the first
111
- * hunk header starts. Note that this does not include a trailing
112
- * newline.
226
+ * Line start pointer.
227
+ *
228
+ * The offset into the text property where the current line starts (ie either zero
229
+ * or one character ahead of the last newline character).
113
230
  */
114
- readonly header: string;
231
+ private ls;
115
232
  /**
116
- * The plain text contents of the diff. This contains everything
117
- * after the diff header until the last character in the diff.
233
+ * Line end pointer.
118
234
  *
119
- * Note that this does not include a trailing newline nor does
120
- * it include diff 'no newline at end of file' comments. For
121
- * no-newline information, consult the DiffLine noTrailingNewLine
122
- * property.
235
+ * The offset into the text property where the current line ends (ie it points to
236
+ * the newline character) or -1 if the line boundary hasn't been determined yet
123
237
  */
124
- readonly contents: string;
238
+ private le;
125
239
  /**
126
- * Each hunk in the diff with information about start, and end
127
- * positions, lines and line statuses.
128
- */
129
- readonly hunks: ReadonlyArray<DiffHunk>;
130
- /**
131
- * Whether or not the unified diff indicates that the contents
132
- * could not be diffed due to one of the versions being binary.
133
- */
134
- readonly isBinary: boolean;
135
- /** The largest line number in the diff */
136
- readonly maxLineNumber: number;
137
- /** Whether or not the diff has invisible bidi characters */
138
- readonly hasHiddenBidiChars: boolean;
139
- }
140
- /** How many new lines will be added to a diff hunk by default. */
141
- export declare const DefaultDiffExpansionStep = 40;
142
- export declare function assertNever(_: never, message: string): never;
143
- /** Utility function for getting the digit count of the largest line number in an array of diff hunks */
144
- export declare function getLargestLineNumber(hunks: DiffHunk[]): number;
145
- /**
146
- * Calculates whether or not a hunk header can be expanded up, down, both, or if
147
- * the space represented by the hunk header is short and expansion there would
148
- * mean merging with the hunk above.
149
- *
150
- * @param hunkIndex Index of the hunk to evaluate within the whole diff.
151
- * @param hunkHeader Header of the hunk to evaluate.
152
- * @param previousHunk Hunk previous to the one to evaluate. Null if the
153
- * evaluated hunk is the first one.
154
- */
155
- export declare function getHunkHeaderExpansionType(hunkIndex: number, hunkHeader: DiffHunkHeader, previousHunk: DiffHunk | null): DiffHunkExpansionType;
156
- export declare const numIterator: <T>(num: number, cb: (index: number) => T) => T[];
157
- export declare const getLang: (fileName: string) => string;
158
- export declare const getDiffRange: (additions: DiffLine[], deletions: DiffLine[]) => void;
159
- /**
160
- * Regular expression matching invisible bidirectional Unicode characters that
161
- * may be interpreted or compiled differently than what it appears. More info:
162
- * https://github.co/hiddenchars
163
- */
164
- export declare const HiddenBidiCharsRegex: RegExp;
165
- /**
166
- * A parser for the GNU unified diff format
167
- *
168
- * See https://www.gnu.org/software/diffutils/manual/html_node/Detailed-Unified.html
169
- */
170
- export declare class DiffParser {
171
- /**
172
- * Line start pointer.
173
- *
174
- * The offset into the text property where the current line starts (ie either zero
175
- * or one character ahead of the last newline character).
176
- */
177
- private ls;
178
- /**
179
- * Line end pointer.
180
- *
181
- * The offset into the text property where the current line ends (ie it points to
182
- * the newline character) or -1 if the line boundary hasn't been determined yet
183
- */
184
- private le;
185
- /**
186
- * The text buffer containing the raw, unified diff output to be parsed
240
+ * The text buffer containing the raw, unified diff output to be parsed
187
241
  */
188
242
  private text;
189
243
  constructor();
@@ -290,53 +344,176 @@ export declare class DiffParser {
290
344
  */
291
345
  parse(text: string): IRawDiff;
292
346
  }
347
+ /** How many new lines will be added to a diff hunk by default. */
348
+ export declare const DefaultDiffExpansionStep = 40;
349
+ /**
350
+ * Regular expression matching invisible bidirectional Unicode characters that
351
+ * may be interpreted or compiled differently than what it appears. More info:
352
+ * https://github.co/hiddenchars
353
+ */
354
+ export declare const HiddenBidiCharsRegex: RegExp;
355
+ export declare const _cacheMap: Cache$1<string, File$1>;
356
+ export declare const checkDiffLineIncludeChange: (diffLine?: DiffLine) => boolean;
357
+ export declare const composeLen = 40;
358
+ export declare const getDiffRange: (additions: DiffLine[], deletions: DiffLine[]) => void;
359
+ export declare const getFile: (raw: string, lang: string, fileName?: string, uuid?: string) => File$1;
360
+ export declare const getLang: (fileName: string) => string;
361
+ export declare const getSplitContentLines: (diffFile: DiffFile) => DiffSplitContentLineItem[];
362
+ export declare const getSplitLines: (diffFile: DiffFile) => DiffSplitLineItem[];
363
+ export declare const getUnifiedContentLine: (diffFile: DiffFile) => DiffUnifiedContentLineItem[];
364
+ export declare const getUnifiedLines: (diffFile: DiffFile) => DiffUnifiedLineItem[];
365
+ export declare const highlighter: DiffHighlighter;
366
+ export declare const numIterator: <T>(num: number, cb: (index: number) => T) => T[];
293
367
  export declare const parseInstance: DiffParser;
294
- declare class Cache$1<K, V> extends Map<K, V> {
295
- name: string;
296
- setMaxLength(length: number): void;
297
- set(key: K, value: V): this;
298
- _checkLength(): void;
299
- }
300
- // Generated by dts-bundle-generator v9.5.1
301
- export type SyntaxNode = {
302
- type: string;
303
- value: string;
304
- lineNumber: number;
305
- startIndex: number;
306
- endIndex: number;
307
- properties?: {
308
- className?: string[];
309
- [key: string]: any;
310
- };
311
- children?: SyntaxNode[];
312
- };
313
- export type SyntaxLine = {
314
- value: string;
315
- lineNumber: number;
316
- valueLength: number;
317
- nodeList: {
318
- node: SyntaxNode;
319
- wrapper?: SyntaxNode;
320
- }[];
321
- };
322
368
  export declare const processAST: (ast: DiffAST) => {
323
369
  syntaxFileObject: Record<number, SyntaxLine>;
324
370
  syntaxFileLineNumber: number;
325
371
  };
326
- declare const lowlight: {
327
- highlight: (language: string, value: string, options?: Readonly<import("lowlight").Options>) => import("hast").Root;
328
- highlightAuto: (value: string, options?: Readonly<import("lowlight").AutoOptions>) => import("hast").Root;
329
- listLanguages: () => string[];
330
- register: {
331
- (grammars: Readonly<Record<string, import("highlight.js").LanguageFn>>): undefined;
332
- (name: string, grammar: import("highlight.js").LanguageFn): undefined;
333
- };
334
- registerAlias: {
335
- (aliases: Readonly<Record<string, string | readonly string[]>>): undefined;
336
- (language: string, alias: string | readonly string[]): undefined;
337
- };
338
- registered: (aliasOrName: string) => boolean;
372
+ export declare const versions: string;
373
+ export declare enum DiffFileLineType {
374
+ hunk = 1,
375
+ content = 2,
376
+ widget = 3,
377
+ extend = 4
378
+ }
379
+ export declare enum DiffHunkExpansionType {
380
+ /** The hunk header cannot be expanded at all. */
381
+ None = "None",
382
+ /**
383
+ * The hunk header can be expanded up exclusively. Only the first hunk can be
384
+ * expanded up exclusively.
385
+ */
386
+ Up = "Up",
387
+ /**
388
+ * The hunk header can be expanded down exclusively. Only the last hunk (if
389
+ * it's the dummy hunk with only one line) can be expanded down exclusively.
390
+ */
391
+ Down = "Down",
392
+ /** The hunk header can be expanded both up and down. */
393
+ Both = "Both",
394
+ /**
395
+ * The hunk header represents a short gap that, when expanded, will
396
+ * result in merging this hunk and the hunk above.
397
+ */
398
+ Short = "Short"
399
+ }
400
+ /** indicate what a line in the diff represents */
401
+ export declare enum DiffLineType {
402
+ Context = 0,
403
+ Add = 1,
404
+ Delete = 2,
405
+ Hunk = 3
406
+ }
407
+ export declare enum NewLineSymbol {
408
+ CRLF = 1,
409
+ CR = 2,
410
+ LF = 3,
411
+ NEWLINE = 4,
412
+ NORMAL = 5
413
+ }
414
+ export declare function assertNever(_: never, message: string): never;
415
+ export declare function diffChanges(addition: DiffLine, deletion: DiffLine): {
416
+ addRange: DiffRange;
417
+ delRange: DiffRange;
418
+ };
419
+ /**
420
+ * Calculates whether or not a hunk header can be expanded up, down, both, or if
421
+ * the space represented by the hunk header is short and expansion there would
422
+ * mean merging with the hunk above.
423
+ *
424
+ * @param hunkIndex Index of the hunk to evaluate within the whole diff.
425
+ * @param hunkHeader Header of the hunk to evaluate.
426
+ * @param previousHunk Hunk previous to the one to evaluate. Null if the
427
+ * evaluated hunk is the first one.
428
+ */
429
+ export declare function getHunkHeaderExpansionType(hunkIndex: number, hunkHeader: DiffHunkHeader, previousHunk: DiffHunk | null): DiffHunkExpansionType;
430
+ /** Utility function for getting the digit count of the largest line number in an array of diff hunks */
431
+ export declare function getLargestLineNumber(hunks: DiffHunk[]): number;
432
+ /** Get the changed ranges in the strings, relative to each other. */
433
+ export declare function relativeChanges(addition: DiffLine, deletion: DiffLine): {
434
+ addRange: IRange;
435
+ delRange: IRange;
339
436
  };
437
+ export interface DiffHunkItem extends DiffLineItem {
438
+ isFirst: boolean;
439
+ isLast: boolean;
440
+ hunkInfo: HunkInfo;
441
+ splitInfo?: HunkLineInfo & HunkInfo;
442
+ unifiedInfo?: HunkLineInfo & HunkInfo;
443
+ }
444
+ export interface DiffLineItem extends DiffLine {
445
+ index: number;
446
+ prevHunkLine?: DiffHunkItem;
447
+ }
448
+ export interface DiffRange {
449
+ readonly range: {
450
+ type: 1 | -1 | 0;
451
+ str: string;
452
+ location: number;
453
+ length: number;
454
+ }[];
455
+ readonly hasLineChange?: boolean;
456
+ readonly newLineSymbol?: NewLineSymbol;
457
+ }
458
+ export interface IRange {
459
+ readonly range: {
460
+ /** The starting location for the range. */
461
+ readonly location: number;
462
+ /** The length of the range. */
463
+ readonly length: number;
464
+ };
465
+ readonly hasLineChange?: boolean;
466
+ readonly newLineSymbol?: NewLineSymbol;
467
+ }
468
+ /** the contents of a diff generated by Git */
469
+ export interface IRawDiff {
470
+ /**
471
+ * The plain text contents of the diff header. This contains
472
+ * everything from the start of the diff up until the first
473
+ * hunk header starts. Note that this does not include a trailing
474
+ * newline.
475
+ */
476
+ readonly header: string;
477
+ /**
478
+ * The plain text contents of the diff. This contains everything
479
+ * after the diff header until the last character in the diff.
480
+ *
481
+ * Note that this does not include a trailing newline nor does
482
+ * it include diff 'no newline at end of file' comments. For
483
+ * no-newline information, consult the DiffLine noTrailingNewLine
484
+ * property.
485
+ */
486
+ readonly contents: string;
487
+ /**
488
+ * Each hunk in the diff with information about start, and end
489
+ * positions, lines and line statuses.
490
+ */
491
+ readonly hunks: ReadonlyArray<DiffHunk>;
492
+ /**
493
+ * Whether or not the unified diff indicates that the contents
494
+ * could not be diffed due to one of the versions being binary.
495
+ */
496
+ readonly isBinary: boolean;
497
+ /** The largest line number in the diff */
498
+ readonly maxLineNumber: number;
499
+ /** Whether or not the diff has invisible bidi characters */
500
+ readonly hasHiddenBidiChars: boolean;
501
+ }
502
+ export interface SplitLineItem {
503
+ lineNumber?: number;
504
+ value?: string;
505
+ diff?: DiffLineItem;
506
+ isHidden?: boolean;
507
+ _isHidden?: boolean;
508
+ }
509
+ export interface UnifiedLineItem {
510
+ oldLineNumber?: number;
511
+ newLineNumber?: number;
512
+ value?: string;
513
+ diff?: DiffLineItem;
514
+ isHidden?: boolean;
515
+ _isHidden?: boolean;
516
+ }
340
517
  export type DiffAST = ReturnType<typeof lowlight.highlight>;
341
518
  export type DiffHighlighter = {
342
519
  name: string;
@@ -352,45 +529,31 @@ export type DiffHighlighter = {
352
529
  hasRegisteredCurrentLang: (lang: string) => boolean;
353
530
  getHighlighterEngine: () => typeof lowlight;
354
531
  };
355
- export declare const highlighter: DiffHighlighter;
356
- declare class File$1 {
357
- readonly raw: string;
358
- readonly lang: string;
359
- readonly fileName?: string;
360
- ast?: DiffAST;
361
- rawFile: Record<number, string>;
362
- hasDoRaw: boolean;
363
- rawLength?: number;
364
- syntaxFile: Record<number, SyntaxLine>;
365
- hasDoSyntax: boolean;
366
- syntaxLength?: number;
367
- highlighterName?: string;
368
- maxLineNumber: number;
369
- static createInstance(data: File$1): File$1;
370
- constructor(raw: string, lang: string, fileName?: string);
371
- doSyntax({ registerHighlighter }: {
372
- registerHighlighter?: Omit<DiffHighlighter, "getHighlighterEngine">;
373
- }): void;
374
- doRaw(): void;
375
- }
376
- export declare const getFile: (raw: string, lang: string, fileName?: string) => File$1;
377
- export declare const _cacheMap: Cache$1<string, File$1>;
378
- export declare const composeLen = 40;
379
- export interface SplitLineItem {
380
- lineNumber?: number;
381
- value?: string;
382
- diff?: DiffLineItem;
383
- isHidden?: boolean;
384
- _isHidden?: boolean;
385
- }
386
- export interface UnifiedLineItem {
387
- oldLineNumber?: number;
388
- newLineNumber?: number;
389
- value?: string;
390
- diff?: DiffLineItem;
391
- isHidden?: boolean;
392
- _isHidden?: boolean;
393
- }
532
+ export type DiffSplitContentLineItem = {
533
+ type: DiffFileLineType.content;
534
+ index: number;
535
+ lineNumber: number;
536
+ splitLine: {
537
+ left: SplitLineItem;
538
+ right: SplitLineItem;
539
+ };
540
+ };
541
+ export type DiffSplitLineItem = {
542
+ type: DiffFileLineType;
543
+ index: number;
544
+ lineNumber: number;
545
+ };
546
+ export type DiffUnifiedContentLineItem = {
547
+ type: DiffFileLineType.content;
548
+ index: number;
549
+ lineNumber: number;
550
+ unifiedLine: UnifiedLineItem;
551
+ };
552
+ export type DiffUnifiedLineItem = {
553
+ type: DiffFileLineType;
554
+ index: number;
555
+ lineNumber: number;
556
+ };
394
557
  export type HunkInfo = {
395
558
  oldStartIndex: number;
396
559
  newStartIndex: number;
@@ -409,214 +572,98 @@ export type HunkLineInfo = {
409
572
  _endHiddenIndex: number;
410
573
  _plainText: string;
411
574
  };
412
- export interface DiffLineItem extends DiffLine {
413
- index: number;
414
- prevHunkLine?: DiffHunkItem;
415
- }
416
- export interface DiffHunkItem extends DiffLineItem {
417
- isFirst: boolean;
418
- isLast: boolean;
419
- hunkInfo: HunkInfo;
420
- splitInfo?: HunkLineInfo & HunkInfo;
421
- unifiedInfo?: HunkLineInfo & HunkInfo;
422
- }
423
- export declare class DiffFile {
424
- readonly _oldFileName: string;
425
- readonly _newFileName: string;
426
- readonly _diffList: string[];
427
- _version_: string;
428
- _oldFileContent: string;
429
- _oldFileLang: string;
430
- _newFileContent: string;
431
- _newFileLang: string;
432
- diffLineLength: number;
433
- splitLineLength: number;
434
- unifiedLineLength: number;
435
- fileLineLength: number;
436
- hasExpandSplitAll: boolean;
437
- hasExpandUnifiedAll: boolean;
438
- hasSomeLineCollapsed: boolean;
439
- static createInstance(data: {
440
- oldFile?: {
441
- fileName?: string | null;
442
- fileLang?: string | null;
443
- content?: string | null;
444
- };
445
- newFile?: {
446
- fileName?: string | null;
447
- fileLang?: string | null;
448
- content?: string | null;
449
- };
450
- hunks?: string[];
451
- }, bundle?: ReturnType<DiffFile["getBundle"] | DiffFile["_getFullBundle"]>): DiffFile;
452
- constructor(_oldFileName: string, _oldFileContent: string, _newFileName: string, _newFileContent: string, _diffList: string[], _oldFileLang?: string, _newFileLang?: string);
453
- initId(): void;
454
- getId(): string;
455
- clearId(): void;
456
- initRaw(): void;
457
- initSyntax({ registerHighlighter }?: {
458
- registerHighlighter?: Omit<DiffHighlighter, "getHighlighterEngine">;
459
- }): void;
460
- init(): void;
461
- buildSplitDiffLines(): void;
462
- buildUnifiedDiffLines(): void;
463
- getSplitLeftLine: (index: number) => SplitLineItem;
464
- getSplitRightLine: (index: number) => SplitLineItem;
465
- getSplitHunkLine: (index: number) => DiffHunkItem;
466
- onSplitHunkExpand: (dir: "up" | "down" | "all", index: number, needTrigger?: boolean) => void;
467
- getUnifiedLine: (index: number) => UnifiedLineItem;
468
- getUnifiedHunkLine: (index: number) => DiffHunkItem;
469
- onUnifiedHunkExpand: (dir: "up" | "down" | "all", index: number, needTrigger?: boolean) => void;
470
- onAllExpand: (mode: "split" | "unified") => void;
471
- onAllCollapse: (mode: "split" | "unified") => void;
472
- getOldSyntaxLine: (lineNumber: number) => SyntaxLine;
473
- getNewSyntaxLine: (lineNumber: number) => SyntaxLine;
474
- subscribe: (listener: (() => void) & {
475
- isSyncExternal?: boolean;
476
- }) => () => void;
477
- notifyAll: (skipSyncExternal?: boolean) => void;
478
- getUpdateCount: () => number;
479
- getExpandEnabled: () => boolean;
480
- getBundle: () => {
481
- hasInitRaw: boolean;
482
- hasInitSyntax: boolean;
483
- hasBuildSplit: boolean;
484
- hasBuildUnified: boolean;
485
- oldFileLines: Record<number, string>;
486
- oldFileDiffLines: Record<string, DiffLineItem>;
487
- oldFileSyntaxLines: Record<number, SyntaxLine>;
488
- oldFilePlaceholderLines: Record<string, boolean>;
489
- newFileLines: Record<number, string>;
490
- newFileDiffLines: Record<string, DiffLineItem>;
491
- newFileSyntaxLines: Record<number, SyntaxLine>;
492
- newFilePlaceholderLines: Record<string, boolean>;
493
- splitLineLength: number;
494
- unifiedLineLength: number;
495
- fileLineLength: number;
496
- splitLeftLines: SplitLineItem[];
497
- splitRightLines: SplitLineItem[];
498
- splitHunkLines: Record<string, DiffHunkItem>;
499
- unifiedLines: UnifiedLineItem[];
500
- unifiedHunkLines: Record<string, DiffHunkItem>;
501
- highlighterName: string;
502
- composeByDiff: boolean;
503
- hasSomeLineCollapsed: boolean;
504
- version: string;
505
- isFullMerge: boolean;
506
- };
507
- mergeBundle: (data: ReturnType<DiffFile["getBundle"]>) => void;
508
- _getHighlighterName: () => string;
509
- _getIsPureDiffRender: () => boolean;
510
- _addClonedInstance: (instance: DiffFile) => void;
511
- _notifyOthers: (instance: DiffFile) => void;
512
- _delClonedInstance: (instance: DiffFile) => void;
513
- _getFullBundle: () => {
514
- oldFileResult: File$1;
515
- newFileResult: File$1;
516
- diffLines: DiffLineItem[];
517
- diffListResults: IRawDiff[];
518
- isFullMerge: boolean;
519
- hasInitRaw: boolean;
520
- hasInitSyntax: boolean;
521
- hasBuildSplit: boolean;
522
- hasBuildUnified: boolean;
523
- oldFileLines: Record<number, string>;
524
- oldFileDiffLines: Record<string, DiffLineItem>;
525
- oldFileSyntaxLines: Record<number, SyntaxLine>;
526
- oldFilePlaceholderLines: Record<string, boolean>;
527
- newFileLines: Record<number, string>;
528
- newFileDiffLines: Record<string, DiffLineItem>;
529
- newFileSyntaxLines: Record<number, SyntaxLine>;
530
- newFilePlaceholderLines: Record<string, boolean>;
531
- splitLineLength: number;
532
- unifiedLineLength: number;
533
- fileLineLength: number;
534
- splitLeftLines: SplitLineItem[];
535
- splitRightLines: SplitLineItem[];
536
- splitHunkLines: Record<string, DiffHunkItem>;
537
- unifiedLines: UnifiedLineItem[];
538
- unifiedHunkLines: Record<string, DiffHunkItem>;
539
- highlighterName: string;
540
- composeByDiff: boolean;
541
- hasSomeLineCollapsed: boolean;
542
- version: string;
543
- };
544
- _mergeFullBundle: (data: ReturnType<DiffFile["_getFullBundle"]>) => void;
545
- _destroy: () => void;
546
- clear: () => void;
547
- }
548
- export declare enum DiffFileLineType {
549
- hunk = 1,
550
- content = 2,
551
- widget = 3,
552
- extend = 4
553
- }
554
- export type DiffSplitContentLineItem = {
555
- type: DiffFileLineType.content;
556
- index: number;
557
- lineNumber: number;
558
- splitLine: {
559
- left: SplitLineItem;
560
- right: SplitLineItem;
561
- };
562
- };
563
- export type DiffUnifiedContentLineItem = {
564
- type: DiffFileLineType.content;
565
- index: number;
566
- lineNumber: number;
567
- unifiedLine: UnifiedLineItem;
568
- };
569
- export type DiffSplitLineItem = {
570
- type: DiffFileLineType;
571
- index: number;
575
+ export type SyntaxLine = {
576
+ value: string;
572
577
  lineNumber: number;
573
- splitLine?: {
574
- left: SplitLineItem;
575
- right: SplitLineItem;
576
- };
577
- widgetLine?: {
578
- side: "left" | "right";
579
- };
580
- extendLine?: {
581
- side: "left" | "right";
582
- data?: any;
583
- };
584
- hunkLine?: DiffHunkItem;
578
+ valueLength: number;
579
+ nodeList: {
580
+ node: SyntaxNode;
581
+ wrapper?: SyntaxNode;
582
+ }[];
585
583
  };
586
- export type DiffUnifiedLineItem = {
587
- type: DiffFileLineType;
588
- index: number;
584
+ // Generated by dts-bundle-generator v9.5.1
585
+ export type SyntaxNode = {
586
+ type: string;
587
+ value: string;
589
588
  lineNumber: number;
590
- unifiedLine?: UnifiedLineItem;
591
- widgetLine?: {
592
- side: "left" | "right";
593
- };
594
- extendLine?: {
595
- side: "left" | "right";
596
- data?: any;
589
+ startIndex: number;
590
+ endIndex: number;
591
+ properties?: {
592
+ className?: string[];
593
+ [key: string]: any;
597
594
  };
598
- hunkLine?: DiffHunkItem;
595
+ children?: SyntaxNode[];
599
596
  };
600
- export type Options = {
601
- hasRenderWidget?: boolean;
602
- hasRenderExtend?: boolean;
603
- widgetData?: {
604
- [lineNumber: number]: {
605
- side: "left" | "right";
597
+ declare const createDiffConfigStore: (props: DiffViewProps<any>, diffFileId: string) => import("reactivity-store").UseSelectorWithStore<{
598
+ id: import("reactivity-store").Ref<string>;
599
+ setId: (_id: string) => string;
600
+ mode: import("reactivity-store").Ref<DiffModeEnum>;
601
+ setMode: (_mode: DiffModeEnum) => DiffModeEnum;
602
+ enableWrap: import("reactivity-store").Ref<boolean>;
603
+ setEnableWrap: (_enableWrap: boolean) => boolean;
604
+ enableAddWidget: import("reactivity-store").Ref<boolean>;
605
+ setEnableAddWidget: (_enableAddWidget: boolean) => boolean;
606
+ enableHighlight: import("reactivity-store").Ref<boolean>;
607
+ setEnableHighlight: (_enableHighlight: boolean) => boolean;
608
+ fontSize: import("reactivity-store").Ref<number>;
609
+ setFontSize: (_fontSize: number) => number;
610
+ extendData: import("reactivity-store").Ref<{
611
+ oldFile: {
612
+ [x: string]: {
613
+ data: any;
614
+ };
606
615
  };
607
- };
608
- extendData?: {
609
- [lineNumber: number]: {
610
- side: "left" | "right";
611
- data: any;
616
+ newFile: {
617
+ [x: string]: {
618
+ data: any;
619
+ };
612
620
  };
621
+ }>;
622
+ setExtendData: (_extendData: DiffViewProps<any>["extendData"]) => void;
623
+ renderWidgetLine: import("reactivity-store").Ref<({ diffFile, side, lineNumber, onClose, }: {
624
+ lineNumber: number;
625
+ side: SplitSide;
626
+ diffFile: DiffFile;
627
+ onClose: () => void;
628
+ }) => import("react").ReactNode>;
629
+ setRenderWidgetLine: (_renderWidgetLine: ({ diffFile, side, lineNumber, onClose, }: {
630
+ lineNumber: number;
631
+ side: SplitSide;
632
+ diffFile: DiffFile;
633
+ onClose: () => void;
634
+ }) => import("react").ReactNode) => ({ diffFile, side, lineNumber, onClose, }: {
635
+ lineNumber: number;
636
+ side: SplitSide;
637
+ diffFile: DiffFile;
638
+ onClose: () => void;
639
+ }) => import("react").ReactNode;
640
+ renderExtendLine: import("reactivity-store").Ref<({ diffFile, side, data, lineNumber, onUpdate, }: {
641
+ lineNumber: number;
642
+ side: SplitSide;
643
+ data: any;
644
+ diffFile: DiffFile;
645
+ onUpdate: () => void;
646
+ }) => import("react").ReactNode>;
647
+ setRenderExtendLine: (_renderExtendLine: ({ diffFile, side, data, lineNumber, onUpdate, }: {
648
+ lineNumber: number;
649
+ side: SplitSide;
650
+ data: any;
651
+ diffFile: DiffFile;
652
+ onUpdate: () => void;
653
+ }) => import("react").ReactNode) => ({ diffFile, side, data, lineNumber, onUpdate, }: {
654
+ lineNumber: number;
655
+ side: SplitSide;
656
+ data: any;
657
+ diffFile: DiffFile;
658
+ onUpdate: () => void;
659
+ }) => import("react").ReactNode;
660
+ onAddWidgetClick: {
661
+ current: (lineNumber: number, side: SplitSide) => void;
613
662
  };
614
- };
615
- export declare const getSplitLines: (diffFile: DiffFile, options: Options) => DiffSplitLineItem[];
616
- export declare const getSplitContentLines: (diffFile: DiffFile) => DiffSplitContentLineItem[];
617
- export declare const getUnifiedLines: (diffFile: DiffFile, options: Options) => DiffUnifiedLineItem[];
618
- export declare const getUnifiedContentLine: (diffFile: DiffFile) => DiffUnifiedContentLineItem[];
619
- export declare const versions: string;
663
+ setOnAddWidgetClick: (_onAddWidgetClick: {
664
+ current: (lineNumber: number, side: SplitSide) => void;
665
+ }) => (lineNumber: number, side: SplitSide) => void;
666
+ }>;
620
667
  export declare enum DiffModeEnum {
621
668
  SplitGitHub = 1,
622
669
  SplitGitLab = 2,
@@ -624,38 +671,11 @@ export declare enum DiffModeEnum {
624
671
  Unified = 4
625
672
  }
626
673
  export declare const DiffViewContext: import("react").Context<{
627
- useDiffContext: UseSelectorWithStore<{
628
- id: Ref<string>;
629
- mode: Ref<DiffModeEnum>;
630
- enableWrap: Ref<boolean>;
631
- enableAddWidget: Ref<boolean>;
632
- enableHighlight: Ref<boolean>;
633
- fontSize: Ref<number>;
634
- renderWidgetLine: Ref<DiffViewProps<any>["renderWidgetLine"]>;
635
- extendData: Ref<DiffViewProps<any>["extendData"]>;
636
- renderExtendLine: Ref<DiffViewProps<any>["renderExtendLine"]>;
637
- onAddWidgetClick: {
638
- current: DiffViewProps<any>["onAddWidgetClick"];
639
- };
640
- }>;
674
+ useDiffContext: ReturnType<typeof createDiffConfigStore>;
641
675
  }>;
642
676
  export declare const useDiffViewContext: () => {
643
- useDiffContext: UseSelectorWithStore<{
644
- id: Ref<string>;
645
- mode: Ref<DiffModeEnum>;
646
- enableWrap: Ref<boolean>;
647
- enableAddWidget: Ref<boolean>;
648
- enableHighlight: Ref<boolean>;
649
- fontSize: Ref<number>;
650
- renderWidgetLine: Ref<DiffViewProps<any>["renderWidgetLine"]>;
651
- extendData: Ref<DiffViewProps<any>["extendData"]>;
652
- renderExtendLine: Ref<DiffViewProps<any>["renderExtendLine"]>;
653
- onAddWidgetClick: {
654
- current: DiffViewProps<any>["onAddWidgetClick"];
655
- };
656
- }>;
677
+ useDiffContext: ReturnType<typeof createDiffConfigStore>;
657
678
  };
658
- export declare const diffFontSizeName = "--diff-font-size--";
659
679
  export declare enum SplitSide {
660
680
  old = 1,
661
681
  new = 2