@git-diff-view/react 0.0.13 → 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/dist/cjs/index.development.js +335 -2431
- package/dist/cjs/index.development.js.map +1 -1
- package/dist/cjs/index.production.js +335 -2394
- package/dist/cjs/index.production.js.map +1 -1
- package/dist/css/diff-view.css +2 -2
- package/dist/esm/index.mjs +266 -2340
- package/dist/esm/index.mjs.map +1 -1
- package/index.d.ts +746 -1
- package/package.json +11 -7
- package/readme.md +1 -1
- package/dist/types/components/DiffAddWidget.d.ts +0 -21
- package/dist/types/components/DiffAddWidget.d.ts.map +0 -1
- package/dist/types/components/DiffContent.d.ts +0 -11
- package/dist/types/components/DiffContent.d.ts.map +0 -1
- package/dist/types/components/DiffExpand.d.ts +0 -11
- package/dist/types/components/DiffExpand.d.ts.map +0 -1
- package/dist/types/components/DiffNoNewLine.d.ts +0 -3
- package/dist/types/components/DiffNoNewLine.d.ts.map +0 -1
- package/dist/types/components/DiffSplitExtendLineNormal.d.ts +0 -10
- package/dist/types/components/DiffSplitExtendLineNormal.d.ts.map +0 -1
- package/dist/types/components/DiffSplitExtendLineWrap.d.ts +0 -8
- package/dist/types/components/DiffSplitExtendLineWrap.d.ts.map +0 -1
- package/dist/types/components/DiffSplitHunkLineNormal.d.ts +0 -10
- package/dist/types/components/DiffSplitHunkLineNormal.d.ts.map +0 -1
- package/dist/types/components/DiffSplitHunkLineWrap.d.ts +0 -8
- package/dist/types/components/DiffSplitHunkLineWrap.d.ts.map +0 -1
- package/dist/types/components/DiffSplitLineNormal.d.ts +0 -10
- package/dist/types/components/DiffSplitLineNormal.d.ts.map +0 -1
- package/dist/types/components/DiffSplitLineWrap.d.ts +0 -8
- package/dist/types/components/DiffSplitLineWrap.d.ts.map +0 -1
- package/dist/types/components/DiffSplitView.d.ts +0 -6
- package/dist/types/components/DiffSplitView.d.ts.map +0 -1
- package/dist/types/components/DiffSplitViewLineNormal.d.ts +0 -9
- package/dist/types/components/DiffSplitViewLineNormal.d.ts.map +0 -1
- package/dist/types/components/DiffSplitViewLineWrap.d.ts +0 -7
- package/dist/types/components/DiffSplitViewLineWrap.d.ts.map +0 -1
- package/dist/types/components/DiffSplitViewNormal.d.ts +0 -6
- package/dist/types/components/DiffSplitViewNormal.d.ts.map +0 -1
- package/dist/types/components/DiffSplitViewWrap.d.ts +0 -6
- package/dist/types/components/DiffSplitViewWrap.d.ts.map +0 -1
- package/dist/types/components/DiffSplitWidgetLineNormal.d.ts +0 -10
- package/dist/types/components/DiffSplitWidgetLineNormal.d.ts.map +0 -1
- package/dist/types/components/DiffSplitWidgetLineWrap.d.ts +0 -8
- package/dist/types/components/DiffSplitWidgetLineWrap.d.ts.map +0 -1
- package/dist/types/components/DiffUnifiedExtendLine.d.ts +0 -8
- package/dist/types/components/DiffUnifiedExtendLine.d.ts.map +0 -1
- package/dist/types/components/DiffUnifiedHunkLine.d.ts +0 -8
- package/dist/types/components/DiffUnifiedHunkLine.d.ts.map +0 -1
- package/dist/types/components/DiffUnifiedLine.d.ts +0 -8
- package/dist/types/components/DiffUnifiedLine.d.ts.map +0 -1
- package/dist/types/components/DiffUnifiedView.d.ts +0 -6
- package/dist/types/components/DiffUnifiedView.d.ts.map +0 -1
- package/dist/types/components/DiffUnifiedWidgetLine.d.ts +0 -8
- package/dist/types/components/DiffUnifiedWidgetLine.d.ts.map +0 -1
- package/dist/types/components/DiffView.d.ts +0 -69
- package/dist/types/components/DiffView.d.ts.map +0 -1
- package/dist/types/components/DiffViewContext.d.ts +0 -42
- package/dist/types/components/DiffViewContext.d.ts.map +0 -1
- package/dist/types/components/DiffWidgetContext.d.ts +0 -24
- package/dist/types/components/DiffWidgetContext.d.ts.map +0 -1
- package/dist/types/components/color.d.ts +0 -35
- package/dist/types/components/color.d.ts.map +0 -1
- package/dist/types/components/tools.d.ts +0 -5
- package/dist/types/components/tools.d.ts.map +0 -1
- package/dist/types/hooks/useCallbackRef.d.ts +0 -2
- package/dist/types/hooks/useCallbackRef.d.ts.map +0 -1
- package/dist/types/hooks/useDomWidth.d.ts +0 -5
- package/dist/types/hooks/useDomWidth.d.ts.map +0 -1
- package/dist/types/hooks/useSafeLayout.d.ts +0 -3
- package/dist/types/hooks/useSafeLayout.d.ts.map +0 -1
- package/dist/types/hooks/useSyncHeight.d.ts +0 -6
- package/dist/types/hooks/useSyncHeight.d.ts.map +0 -1
- package/dist/types/hooks/useTextWidth.d.ts +0 -17
- package/dist/types/hooks/useTextWidth.d.ts.map +0 -1
- package/dist/types/hooks/useUnmount.d.ts +0 -2
- package/dist/types/hooks/useUnmount.d.ts.map +0 -1
- package/dist/types/index.d.ts +0 -4
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.withStyle.d.ts +0 -6
- package/dist/types/index.withStyle.d.ts.map +0 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var core = require('@git-diff-view/core');
|
|
4
4
|
var React = require('react');
|
|
5
|
-
var
|
|
6
|
-
var shim = require('use-sync-external-store/shim');
|
|
5
|
+
var index_js = require('use-sync-external-store/shim/index.js');
|
|
7
6
|
var reactDom = require('react-dom');
|
|
7
|
+
var reactivityStore = require('reactivity-store');
|
|
8
8
|
|
|
9
9
|
function _interopNamespaceDefault(e) {
|
|
10
10
|
var n = Object.create(null);
|
|
@@ -16,2151 +16,66 @@ function _interopNamespaceDefault(e) {
|
|
|
16
16
|
enumerable: true,
|
|
17
17
|
get: function () { return e[k]; }
|
|
18
18
|
});
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
n.default = e;
|
|
23
|
-
return Object.freeze(n);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
27
|
-
|
|
28
|
-
/******************************************************************************
|
|
29
|
-
Copyright (c) Microsoft Corporation.
|
|
30
|
-
|
|
31
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
32
|
-
purpose with or without fee is hereby granted.
|
|
33
|
-
|
|
34
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
35
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
36
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
37
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
38
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
39
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
40
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
41
|
-
***************************************************************************** */
|
|
42
|
-
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
function __rest(s, e) {
|
|
46
|
-
var t = {};
|
|
47
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
48
|
-
t[p] = s[p];
|
|
49
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
50
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
51
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
52
|
-
t[p[i]] = s[p[i]];
|
|
53
|
-
}
|
|
54
|
-
return t;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function __classPrivateFieldGet$1(receiver, state, kind, f) {
|
|
58
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
59
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
60
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
function __classPrivateFieldSet$1(receiver, state, value, kind, f) {
|
|
64
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
65
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
66
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
67
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
71
|
-
var e = new Error(message);
|
|
72
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
exports.DiffHunkExpansionType = void 0;
|
|
76
|
-
(function (DiffHunkExpansionType) {
|
|
77
|
-
/** The hunk header cannot be expanded at all. */
|
|
78
|
-
DiffHunkExpansionType["None"] = "None";
|
|
79
|
-
/**
|
|
80
|
-
* The hunk header can be expanded up exclusively. Only the first hunk can be
|
|
81
|
-
* expanded up exclusively.
|
|
82
|
-
*/
|
|
83
|
-
DiffHunkExpansionType["Up"] = "Up";
|
|
84
|
-
/**
|
|
85
|
-
* The hunk header can be expanded down exclusively. Only the last hunk (if
|
|
86
|
-
* it's the dummy hunk with only one line) can be expanded down exclusively.
|
|
87
|
-
*/
|
|
88
|
-
DiffHunkExpansionType["Down"] = "Down";
|
|
89
|
-
/** The hunk header can be expanded both up and down. */
|
|
90
|
-
DiffHunkExpansionType["Both"] = "Both";
|
|
91
|
-
/**
|
|
92
|
-
* The hunk header represents a short gap that, when expanded, will
|
|
93
|
-
* result in merging this hunk and the hunk above.
|
|
94
|
-
*/
|
|
95
|
-
DiffHunkExpansionType["Short"] = "Short";
|
|
96
|
-
})(exports.DiffHunkExpansionType || (exports.DiffHunkExpansionType = {}));
|
|
97
|
-
/** each diff is made up of a number of hunks */
|
|
98
|
-
class DiffHunk {
|
|
99
|
-
/**
|
|
100
|
-
* @param header The details from the diff hunk header about the line start and patch length.
|
|
101
|
-
* @param lines The contents - context and changes - of the diff section.
|
|
102
|
-
* @param unifiedDiffStart The diff hunk's start position in the overall file diff.
|
|
103
|
-
* @param unifiedDiffEnd The diff hunk's end position in the overall file diff.
|
|
104
|
-
*/
|
|
105
|
-
constructor(header, lines, unifiedDiffStart, unifiedDiffEnd, expansionType) {
|
|
106
|
-
this.header = header;
|
|
107
|
-
this.lines = lines;
|
|
108
|
-
this.unifiedDiffStart = unifiedDiffStart;
|
|
109
|
-
this.unifiedDiffEnd = unifiedDiffEnd;
|
|
110
|
-
this.expansionType = expansionType;
|
|
111
|
-
}
|
|
112
|
-
equals(other) {
|
|
113
|
-
if (this === other) {
|
|
114
|
-
return true;
|
|
115
|
-
}
|
|
116
|
-
return (this.header.equals(other.header) &&
|
|
117
|
-
this.unifiedDiffStart === other.unifiedDiffStart &&
|
|
118
|
-
this.unifiedDiffEnd === other.unifiedDiffEnd &&
|
|
119
|
-
this.expansionType === other.expansionType &&
|
|
120
|
-
this.lines.length === other.lines.length &&
|
|
121
|
-
this.lines.every((xLine, ix) => xLine.equals(other.lines[ix])));
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
/** details about the start and end of a diff hunk */
|
|
125
|
-
class DiffHunkHeader {
|
|
126
|
-
/**
|
|
127
|
-
* @param oldStartLine The line in the old (or original) file where this diff hunk starts.
|
|
128
|
-
* @param oldLineCount The number of lines in the old (or original) file that this diff hunk covers
|
|
129
|
-
* @param newStartLine The line in the new file where this diff hunk starts.
|
|
130
|
-
* @param newLineCount The number of lines in the new file that this diff hunk covers.
|
|
131
|
-
*/
|
|
132
|
-
constructor(oldStartLine, oldLineCount, newStartLine, newLineCount) {
|
|
133
|
-
this.oldStartLine = oldStartLine;
|
|
134
|
-
this.oldLineCount = oldLineCount;
|
|
135
|
-
this.newStartLine = newStartLine;
|
|
136
|
-
this.newLineCount = newLineCount;
|
|
137
|
-
}
|
|
138
|
-
toDiffLineRepresentation() {
|
|
139
|
-
return `@@ -${this.oldStartLine},${this.oldLineCount} +${this.newStartLine},${this.newLineCount} @@`;
|
|
140
|
-
}
|
|
141
|
-
equals(other) {
|
|
142
|
-
return (this.oldStartLine === other.oldStartLine &&
|
|
143
|
-
this.oldLineCount === other.oldLineCount &&
|
|
144
|
-
this.newStartLine === other.newStartLine &&
|
|
145
|
-
this.oldStartLine === other.oldStartLine);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
exports.NewLineSymbol = void 0;
|
|
150
|
-
(function (NewLineSymbol) {
|
|
151
|
-
NewLineSymbol[NewLineSymbol["CRLF"] = 1] = "CRLF";
|
|
152
|
-
NewLineSymbol[NewLineSymbol["CR"] = 2] = "CR";
|
|
153
|
-
NewLineSymbol[NewLineSymbol["LF"] = 3] = "LF";
|
|
154
|
-
NewLineSymbol[NewLineSymbol["NEWLINE"] = 4] = "NEWLINE";
|
|
155
|
-
})(exports.NewLineSymbol || (exports.NewLineSymbol = {}));
|
|
156
|
-
const maxLength = 1000;
|
|
157
|
-
/** Get the maximum position in the range. */
|
|
158
|
-
function rangeMax(range) {
|
|
159
|
-
return range.location + range.length;
|
|
160
|
-
}
|
|
161
|
-
/** Get the length of the common substring between the two strings. */
|
|
162
|
-
function commonLength(stringA, rangeA, stringB, rangeB, reverse) {
|
|
163
|
-
const max = Math.min(rangeA.length, rangeB.length);
|
|
164
|
-
const startA = reverse ? rangeMax(rangeA) - 1 : rangeA.location;
|
|
165
|
-
const startB = reverse ? rangeMax(rangeB) - 1 : rangeB.location;
|
|
166
|
-
const stride = reverse ? -1 : 1;
|
|
167
|
-
let length = 0;
|
|
168
|
-
while (Math.abs(length) < max) {
|
|
169
|
-
if (stringA[startA + length] !== stringB[startB + length]) {
|
|
170
|
-
break;
|
|
171
|
-
}
|
|
172
|
-
length += stride;
|
|
173
|
-
}
|
|
174
|
-
return Math.abs(length);
|
|
175
|
-
}
|
|
176
|
-
function isInValidString(s) {
|
|
177
|
-
return s.trim().length === 0 || s.length >= maxLength;
|
|
178
|
-
}
|
|
179
|
-
// TODO maybe could use the original content line
|
|
180
|
-
/** Get the changed ranges in the strings, relative to each other. */
|
|
181
|
-
function relativeChanges(addition, deletion) {
|
|
182
|
-
const stringA = addition.text;
|
|
183
|
-
const stringB = deletion.text;
|
|
184
|
-
let bRange = { location: 0, length: stringB.length };
|
|
185
|
-
let aRange = { location: 0, length: stringA.length };
|
|
186
|
-
const _stringA = stringA.trimEnd();
|
|
187
|
-
const _stringB = stringB.trimEnd();
|
|
188
|
-
const aEndStr = stringA.slice(-2);
|
|
189
|
-
const bEndStr = stringB.slice(-2);
|
|
190
|
-
const hasNewLineChanged = addition.noTrailingNewLine !== deletion.noTrailingNewLine;
|
|
191
|
-
const aSymbol = aEndStr === "\r\n" ? exports.NewLineSymbol.CRLF : aEndStr.endsWith("\r") ? exports.NewLineSymbol.CR : exports.NewLineSymbol.LF;
|
|
192
|
-
const bSymbol = bEndStr === "\r\n" ? exports.NewLineSymbol.CRLF : bEndStr.endsWith("\r") ? exports.NewLineSymbol.CR : exports.NewLineSymbol.LF;
|
|
193
|
-
if (_stringA === _stringB && (hasNewLineChanged || aSymbol !== bSymbol)) {
|
|
194
|
-
return {
|
|
195
|
-
stringARange: {
|
|
196
|
-
location: _stringA.length,
|
|
197
|
-
length: stringA.length - _stringA.length,
|
|
198
|
-
newLineSymbol: hasNewLineChanged ? exports.NewLineSymbol.NEWLINE : aSymbol,
|
|
199
|
-
},
|
|
200
|
-
stringBRange: {
|
|
201
|
-
location: _stringB.length,
|
|
202
|
-
length: stringB.length - _stringB.length,
|
|
203
|
-
newLineSymbol: hasNewLineChanged ? exports.NewLineSymbol.NEWLINE : bSymbol,
|
|
204
|
-
},
|
|
205
|
-
};
|
|
206
|
-
}
|
|
207
|
-
if (isInValidString(stringA) || isInValidString(stringB)) {
|
|
208
|
-
aRange.length = 0;
|
|
209
|
-
bRange.length = 0;
|
|
210
|
-
return { stringARange: aRange, stringBRange: bRange };
|
|
211
|
-
}
|
|
212
|
-
const prefixLength = commonLength(stringB, bRange, stringA, aRange, false);
|
|
213
|
-
bRange = {
|
|
214
|
-
location: bRange.location + prefixLength,
|
|
215
|
-
length: bRange.length - prefixLength,
|
|
216
|
-
};
|
|
217
|
-
aRange = {
|
|
218
|
-
location: aRange.location + prefixLength,
|
|
219
|
-
length: aRange.length - prefixLength,
|
|
220
|
-
};
|
|
221
|
-
const suffixLength = commonLength(stringB, bRange, stringA, aRange, true);
|
|
222
|
-
bRange.length -= suffixLength;
|
|
223
|
-
aRange.length -= suffixLength;
|
|
224
|
-
return { stringARange: aRange, stringBRange: bRange };
|
|
225
|
-
}
|
|
226
|
-
/** Check two string have a diff range */
|
|
227
|
-
function hasRelativeChange(addition, deletion) {
|
|
228
|
-
const _stringA = addition.text.trim();
|
|
229
|
-
const _stringB = deletion.text.trim();
|
|
230
|
-
const _addition = addition.clone(_stringA);
|
|
231
|
-
const _deletion = deletion.clone(_stringB);
|
|
232
|
-
const { stringARange, stringBRange } = relativeChanges(_addition, _deletion);
|
|
233
|
-
return (stringARange.location > 0 ||
|
|
234
|
-
stringBRange.location > 0 ||
|
|
235
|
-
stringARange.length < _stringA.length ||
|
|
236
|
-
stringBRange.length < _stringB.length);
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
/** indicate what a line in the diff represents */
|
|
240
|
-
exports.DiffLineType = void 0;
|
|
241
|
-
(function (DiffLineType) {
|
|
242
|
-
DiffLineType[DiffLineType["Context"] = 0] = "Context";
|
|
243
|
-
DiffLineType[DiffLineType["Add"] = 1] = "Add";
|
|
244
|
-
DiffLineType[DiffLineType["Delete"] = 2] = "Delete";
|
|
245
|
-
DiffLineType[DiffLineType["Hunk"] = 3] = "Hunk";
|
|
246
|
-
})(exports.DiffLineType || (exports.DiffLineType = {}));
|
|
247
|
-
/** track details related to each line in the diff */
|
|
248
|
-
class DiffLine {
|
|
249
|
-
constructor(text, type,
|
|
250
|
-
// Line number in the original diff patch (before expanding it), or null if
|
|
251
|
-
// it was added as part of a diff expansion action.
|
|
252
|
-
originalLineNumber, oldLineNumber, newLineNumber, noTrailingNewLine = false, needRematch = false, range) {
|
|
253
|
-
this.text = text;
|
|
254
|
-
this.type = type;
|
|
255
|
-
this.originalLineNumber = originalLineNumber;
|
|
256
|
-
this.oldLineNumber = oldLineNumber;
|
|
257
|
-
this.newLineNumber = newLineNumber;
|
|
258
|
-
this.noTrailingNewLine = noTrailingNewLine;
|
|
259
|
-
this.needRematch = needRematch;
|
|
260
|
-
this.range = range;
|
|
261
|
-
}
|
|
262
|
-
withNoTrailingNewLine(noTrailingNewLine) {
|
|
263
|
-
return new DiffLine(this.text, this.type, this.originalLineNumber, this.oldLineNumber, this.newLineNumber, noTrailingNewLine);
|
|
264
|
-
}
|
|
265
|
-
isIncludeableLine() {
|
|
266
|
-
return this.type === exports.DiffLineType.Add || this.type === exports.DiffLineType.Delete;
|
|
267
|
-
}
|
|
268
|
-
/** The content of the line, i.e., without the line type marker. */
|
|
269
|
-
get content() {
|
|
270
|
-
return this.text.substring(1);
|
|
271
|
-
}
|
|
272
|
-
equals(other) {
|
|
273
|
-
return (this.text === other.text &&
|
|
274
|
-
this.type === other.type &&
|
|
275
|
-
this.originalLineNumber === other.originalLineNumber &&
|
|
276
|
-
this.oldLineNumber === other.oldLineNumber &&
|
|
277
|
-
this.newLineNumber === other.newLineNumber &&
|
|
278
|
-
this.noTrailingNewLine === other.noTrailingNewLine);
|
|
279
|
-
}
|
|
280
|
-
clone(text) {
|
|
281
|
-
return new DiffLine(text, this.type, this.originalLineNumber, this.oldLineNumber, this.newLineNumber);
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
const checkDiffLineIncludeChange = (diffLine) => {
|
|
285
|
-
if (!diffLine)
|
|
286
|
-
return false;
|
|
287
|
-
return diffLine.type === exports.DiffLineType.Add || diffLine.type === exports.DiffLineType.Delete;
|
|
288
|
-
};
|
|
289
|
-
|
|
290
|
-
/** How many new lines will be added to a diff hunk by default. */
|
|
291
|
-
const DefaultDiffExpansionStep = 40;
|
|
292
|
-
function assertNever(_, message) {
|
|
293
|
-
throw new Error(message);
|
|
294
|
-
}
|
|
295
|
-
/** Utility function for getting the digit count of the largest line number in an array of diff hunks */
|
|
296
|
-
function getLargestLineNumber(hunks) {
|
|
297
|
-
var _a, _b;
|
|
298
|
-
if (hunks.length === 0) {
|
|
299
|
-
return 0;
|
|
300
|
-
}
|
|
301
|
-
for (let i = hunks.length - 1; i >= 0; i--) {
|
|
302
|
-
const hunk = hunks[i];
|
|
303
|
-
for (let j = hunk.lines.length - 1; j >= 0; j--) {
|
|
304
|
-
const line = hunk.lines[j];
|
|
305
|
-
if (line.type === exports.DiffLineType.Hunk) {
|
|
306
|
-
continue;
|
|
307
|
-
}
|
|
308
|
-
const newLineNumber = (_a = line.newLineNumber) !== null && _a !== void 0 ? _a : 0;
|
|
309
|
-
const oldLineNumber = (_b = line.oldLineNumber) !== null && _b !== void 0 ? _b : 0;
|
|
310
|
-
return newLineNumber > oldLineNumber ? newLineNumber : oldLineNumber;
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
return 0;
|
|
314
|
-
}
|
|
315
|
-
/**
|
|
316
|
-
* Calculates whether or not a hunk header can be expanded up, down, both, or if
|
|
317
|
-
* the space represented by the hunk header is short and expansion there would
|
|
318
|
-
* mean merging with the hunk above.
|
|
319
|
-
*
|
|
320
|
-
* @param hunkIndex Index of the hunk to evaluate within the whole diff.
|
|
321
|
-
* @param hunkHeader Header of the hunk to evaluate.
|
|
322
|
-
* @param previousHunk Hunk previous to the one to evaluate. Null if the
|
|
323
|
-
* evaluated hunk is the first one.
|
|
324
|
-
*/
|
|
325
|
-
function getHunkHeaderExpansionType(hunkIndex, hunkHeader, previousHunk) {
|
|
326
|
-
const distanceToPrevious = previousHunk === null
|
|
327
|
-
? Infinity
|
|
328
|
-
: hunkHeader.oldStartLine - previousHunk.header.oldStartLine - previousHunk.header.oldLineCount;
|
|
329
|
-
// In order to simplify the whole logic around expansion, only the hunk at the
|
|
330
|
-
// top can be expanded up exclusively, and only the hunk at the bottom (the
|
|
331
|
-
// dummy one, see getTextDiffWithBottomDummyHunk) can be expanded down
|
|
332
|
-
// exclusively.
|
|
333
|
-
// The rest of the hunks can be expanded both ways, except those which are too
|
|
334
|
-
// short and therefore the direction of expansion doesn't matter.
|
|
335
|
-
if (hunkIndex === 0) {
|
|
336
|
-
// The top hunk can only be expanded if there is content above it
|
|
337
|
-
if (hunkHeader.oldStartLine > 1 && hunkHeader.newStartLine > 1) {
|
|
338
|
-
return exports.DiffHunkExpansionType.Up;
|
|
339
|
-
}
|
|
340
|
-
else {
|
|
341
|
-
return exports.DiffHunkExpansionType.None;
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
else if (distanceToPrevious <= DefaultDiffExpansionStep) {
|
|
345
|
-
return exports.DiffHunkExpansionType.Short;
|
|
346
|
-
}
|
|
347
|
-
else {
|
|
348
|
-
return exports.DiffHunkExpansionType.Both;
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
const numIterator = (num, cb) => {
|
|
352
|
-
const re = [];
|
|
353
|
-
for (let i = 0; i < num; i++) {
|
|
354
|
-
re.push(cb(i));
|
|
355
|
-
}
|
|
356
|
-
return re;
|
|
357
|
-
};
|
|
358
|
-
const getLang = (fileName) => {
|
|
359
|
-
const dotIndex = fileName.lastIndexOf(".");
|
|
360
|
-
const extension = fileName.slice(dotIndex + 1);
|
|
361
|
-
return extension;
|
|
362
|
-
};
|
|
363
|
-
const getDiffRange = (additions, deletions) => {
|
|
364
|
-
if (additions.length === deletions.length) {
|
|
365
|
-
const len = additions.length;
|
|
366
|
-
for (let i = 0; i < len; i++) {
|
|
367
|
-
const addition = additions[i];
|
|
368
|
-
const deletion = deletions[i];
|
|
369
|
-
const hasDiffRange = hasRelativeChange(addition, deletion);
|
|
370
|
-
if (hasDiffRange) {
|
|
371
|
-
const { stringARange, stringBRange } = relativeChanges(addition, deletion);
|
|
372
|
-
addition.needRematch = true;
|
|
373
|
-
addition.range = stringARange;
|
|
374
|
-
deletion.needRematch = true;
|
|
375
|
-
deletion.range = stringBRange;
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
};
|
|
380
|
-
|
|
381
|
-
/* eslint-disable max-lines */
|
|
382
|
-
// !NOTE: ALL of the diff parse logic copy from desktop, SEE https://github.com/desktop/desktop
|
|
383
|
-
// https://en.wikipedia.org/wiki/Diff_utility
|
|
384
|
-
//
|
|
385
|
-
// @@ -l,s +l,s @@ optional section heading
|
|
386
|
-
//
|
|
387
|
-
// The hunk range information contains two hunk ranges. The range for the hunk of the original
|
|
388
|
-
// file is preceded by a minus symbol, and the range for the new file is preceded by a plus
|
|
389
|
-
// symbol. Each hunk range is of the format l,s where l is the starting line number and s is
|
|
390
|
-
// the number of lines the change hunk applies to for each respective file.
|
|
391
|
-
//
|
|
392
|
-
// In many versions of GNU diff, each range can omit the comma and trailing value s,
|
|
393
|
-
// in which case s defaults to 1
|
|
394
|
-
const diffHeaderRe = /^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/;
|
|
395
|
-
/**
|
|
396
|
-
* Regular expression matching invisible bidirectional Unicode characters that
|
|
397
|
-
* may be interpreted or compiled differently than what it appears. More info:
|
|
398
|
-
* https://github.co/hiddenchars
|
|
399
|
-
*/
|
|
400
|
-
const HiddenBidiCharsRegex = /[\u202A-\u202E]|[\u2066-\u2069]/;
|
|
401
|
-
const DiffPrefixAdd = "+";
|
|
402
|
-
const DiffPrefixDelete = "-";
|
|
403
|
-
const DiffPrefixContext = " ";
|
|
404
|
-
const DiffPrefixNoNewline = "\\";
|
|
405
|
-
const DiffLinePrefixChars = new Set([
|
|
406
|
-
DiffPrefixAdd,
|
|
407
|
-
DiffPrefixDelete,
|
|
408
|
-
DiffPrefixContext,
|
|
409
|
-
DiffPrefixNoNewline,
|
|
410
|
-
]);
|
|
411
|
-
/**
|
|
412
|
-
* A parser for the GNU unified diff format
|
|
413
|
-
*
|
|
414
|
-
* See https://www.gnu.org/software/diffutils/manual/html_node/Detailed-Unified.html
|
|
415
|
-
*/
|
|
416
|
-
class DiffParser {
|
|
417
|
-
constructor() {
|
|
418
|
-
Object.defineProperty(this, "__v_skip", { value: true });
|
|
419
|
-
this.reset();
|
|
420
|
-
}
|
|
421
|
-
/**
|
|
422
|
-
* Resets the internal parser state so that it can be reused.
|
|
423
|
-
*
|
|
424
|
-
* This is done automatically at the end of each parse run.
|
|
425
|
-
*/
|
|
426
|
-
reset() {
|
|
427
|
-
this.ls = 0;
|
|
428
|
-
this.le = -1;
|
|
429
|
-
this.text = "";
|
|
430
|
-
}
|
|
431
|
-
/**
|
|
432
|
-
* Aligns the internal character pointers at the boundaries of
|
|
433
|
-
* the next line.
|
|
434
|
-
*
|
|
435
|
-
* Returns true if successful or false if the end of the diff
|
|
436
|
-
* has been reached.
|
|
437
|
-
*/
|
|
438
|
-
nextLine() {
|
|
439
|
-
this.ls = this.le + 1;
|
|
440
|
-
// We've reached the end of the diff
|
|
441
|
-
if (this.ls >= this.text.length) {
|
|
442
|
-
return false;
|
|
443
|
-
}
|
|
444
|
-
this.le = this.text.indexOf("\n", this.ls);
|
|
445
|
-
// If we can't find the next newline character we'll put our
|
|
446
|
-
// end pointer at the end of the diff string
|
|
447
|
-
if (this.le === -1) {
|
|
448
|
-
this.le = this.text.length;
|
|
449
|
-
}
|
|
450
|
-
// We've succeeded if there's anything to read in between the
|
|
451
|
-
// start and the end
|
|
452
|
-
return this.ls !== this.le;
|
|
453
|
-
}
|
|
454
|
-
/**
|
|
455
|
-
* Advances to the next line and returns it as a substring
|
|
456
|
-
* of the raw diff text. Returns null if end of diff was
|
|
457
|
-
* reached.
|
|
458
|
-
*/
|
|
459
|
-
readLine(header) {
|
|
460
|
-
if (header) {
|
|
461
|
-
return this.nextLine() ? this.text.substring(this.ls, this.le) : null;
|
|
462
|
-
}
|
|
463
|
-
else {
|
|
464
|
-
return this.nextLine() ? this.text.substring(this.ls + 1, this.le + 1) : null;
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
/** Tests if the current line starts with the given search text */
|
|
468
|
-
lineStartsWith(searchString) {
|
|
469
|
-
return this.text.startsWith(searchString, this.ls);
|
|
470
|
-
}
|
|
471
|
-
/** Tests if the current line ends with the given search text */
|
|
472
|
-
lineEndsWith(searchString) {
|
|
473
|
-
return this.text.endsWith(searchString, this.le);
|
|
474
|
-
}
|
|
475
|
-
/**
|
|
476
|
-
* Returns the starting character of the next line without
|
|
477
|
-
* advancing the internal state. Returns null if advancing
|
|
478
|
-
* would mean reaching the end of the diff.
|
|
479
|
-
*/
|
|
480
|
-
peek() {
|
|
481
|
-
const p = this.le + 1;
|
|
482
|
-
return p < this.text.length ? this.text[p] : null;
|
|
483
|
-
}
|
|
484
|
-
/**
|
|
485
|
-
* Parse the diff header, meaning everything from the
|
|
486
|
-
* start of the diff output to the end of the line beginning
|
|
487
|
-
* with +++
|
|
488
|
-
*
|
|
489
|
-
* Example diff header:
|
|
490
|
-
*
|
|
491
|
-
* diff --git a/app/src/lib/diff-parser.ts b/app/src/lib/diff-parser.ts
|
|
492
|
-
* index e1d4871..3bd3ee0 100644
|
|
493
|
-
* --- a/app/src/lib/diff-parser.ts
|
|
494
|
-
* +++ b/app/src/lib/diff-parser.ts
|
|
495
|
-
*
|
|
496
|
-
* Returns an object with information extracted from the diff
|
|
497
|
-
* header (currently whether it's a binary patch) or null if
|
|
498
|
-
* the end of the diff was reached before the +++ line could be
|
|
499
|
-
* found (which is a valid state).
|
|
500
|
-
*/
|
|
501
|
-
parseDiffHeader() {
|
|
502
|
-
// TODO: There's information in here that we might want to
|
|
503
|
-
// capture, such as mode changes
|
|
504
|
-
while (this.nextLine()) {
|
|
505
|
-
if (this.lineStartsWith("Binary files ") && this.lineEndsWith("differ")) {
|
|
506
|
-
return { isBinary: true };
|
|
507
|
-
}
|
|
508
|
-
if (this.lineStartsWith("+++")) {
|
|
509
|
-
return { isBinary: false };
|
|
510
|
-
}
|
|
511
|
-
}
|
|
512
|
-
// It's not an error to not find the +++ line, see the
|
|
513
|
-
// 'parses diff of empty file' test in diff-parser-tests.ts
|
|
514
|
-
return null;
|
|
515
|
-
}
|
|
516
|
-
/**
|
|
517
|
-
* Attempts to convert a RegExp capture group into a number.
|
|
518
|
-
* If the group doesn't exist or wasn't captured the function
|
|
519
|
-
* will return the value of the defaultValue parameter or throw
|
|
520
|
-
* an error if no default value was provided. If the captured
|
|
521
|
-
* string can't be converted to a number an error will be thrown.
|
|
522
|
-
*/
|
|
523
|
-
numberFromGroup(m, group, defaultValue = null) {
|
|
524
|
-
const str = m[group];
|
|
525
|
-
if (!str) {
|
|
526
|
-
if (!defaultValue) {
|
|
527
|
-
throw new Error(`Group ${group} missing from regexp match and no defaultValue was provided`);
|
|
528
|
-
}
|
|
529
|
-
return defaultValue;
|
|
530
|
-
}
|
|
531
|
-
const num = parseInt(str, 10);
|
|
532
|
-
if (isNaN(num)) {
|
|
533
|
-
throw new Error(`Could not parse capture group ${group} into number: ${str}`);
|
|
534
|
-
}
|
|
535
|
-
return num;
|
|
536
|
-
}
|
|
537
|
-
/**
|
|
538
|
-
* Parses a hunk header or throws an error if the given line isn't
|
|
539
|
-
* a well-formed hunk header.
|
|
540
|
-
*
|
|
541
|
-
* We currently only extract the line number information and
|
|
542
|
-
* ignore any hunk headings.
|
|
543
|
-
*
|
|
544
|
-
* Example hunk header (text within ``):
|
|
545
|
-
*
|
|
546
|
-
* `@@ -84,10 +82,8 @@ export function parseRawDiff(lines: ReadonlyArray<string>): Diff {`
|
|
547
|
-
*
|
|
548
|
-
* Where everything after the last @@ is what's known as the hunk, or section, heading
|
|
549
|
-
*/
|
|
550
|
-
parseHunkHeader(line) {
|
|
551
|
-
const m = diffHeaderRe.exec(line);
|
|
552
|
-
if (!m) {
|
|
553
|
-
throw new Error(`Invalid hunk header format`);
|
|
554
|
-
}
|
|
555
|
-
// If endLines are missing default to 1, see diffHeaderRe docs
|
|
556
|
-
const oldStartLine = this.numberFromGroup(m, 1);
|
|
557
|
-
const oldLineCount = this.numberFromGroup(m, 2, 1);
|
|
558
|
-
const newStartLine = this.numberFromGroup(m, 3);
|
|
559
|
-
const newLineCount = this.numberFromGroup(m, 4, 1);
|
|
560
|
-
return new DiffHunkHeader(oldStartLine, oldLineCount, newStartLine, newLineCount);
|
|
561
|
-
}
|
|
562
|
-
/**
|
|
563
|
-
* Convenience function which lets us leverage the type system to
|
|
564
|
-
* prove exhaustive checks in parseHunk.
|
|
565
|
-
*
|
|
566
|
-
* Takes an arbitrary string and checks to see if the first character
|
|
567
|
-
* of that string is one of the allowed prefix characters for diff
|
|
568
|
-
* lines (ie lines in between hunk headers).
|
|
569
|
-
*/
|
|
570
|
-
parseLinePrefix(c) {
|
|
571
|
-
// Since we know that DiffLinePrefixChars and the DiffLinePrefix type
|
|
572
|
-
// include the same characters we can tell the type system that we
|
|
573
|
-
// now know that c[0] is one of the characters in the DifflinePrefix set
|
|
574
|
-
if (c && c.length && DiffLinePrefixChars.has(c[0])) {
|
|
575
|
-
return c[0];
|
|
576
|
-
}
|
|
577
|
-
return null;
|
|
578
|
-
}
|
|
579
|
-
/**
|
|
580
|
-
* Parses a hunk, including its header or throws an error if the diff doesn't
|
|
581
|
-
* contain a well-formed diff hunk at the current position.
|
|
582
|
-
*
|
|
583
|
-
* Expects that the position has been advanced to the beginning of a presumed
|
|
584
|
-
* diff hunk header.
|
|
585
|
-
*
|
|
586
|
-
* @param linesConsumed The number of unified diff lines consumed up until
|
|
587
|
-
* this point by the diff parser. Used to give the
|
|
588
|
-
* position and length (in lines) of the parsed hunk
|
|
589
|
-
* relative to the overall parsed diff. These numbers
|
|
590
|
-
* have no real meaning in the context of a diff and
|
|
591
|
-
* are only used to aid the app in line-selections.
|
|
592
|
-
*/
|
|
593
|
-
parseHunk(linesConsumed, hunkIndex, previousHunk) {
|
|
594
|
-
const headerLine = this.readLine(true);
|
|
595
|
-
if (!headerLine) {
|
|
596
|
-
throw new Error("Expected hunk header but reached end of diff");
|
|
597
|
-
}
|
|
598
|
-
const header = this.parseHunkHeader(headerLine);
|
|
599
|
-
const lines = new Array();
|
|
600
|
-
lines.push(new DiffLine(headerLine, exports.DiffLineType.Hunk, 1, null, null));
|
|
601
|
-
let c;
|
|
602
|
-
let rollingDiffBeforeCounter = header.oldStartLine;
|
|
603
|
-
let rollingDiffAfterCounter = header.newStartLine;
|
|
604
|
-
let diffLineNumber = linesConsumed;
|
|
605
|
-
while ((c = this.parseLinePrefix(this.peek()))) {
|
|
606
|
-
const line = this.readLine(false);
|
|
607
|
-
diffLineNumber++;
|
|
608
|
-
if (!line) {
|
|
609
|
-
throw new Error("Expected unified diff line but reached end of diff");
|
|
610
|
-
}
|
|
611
|
-
// A marker indicating that the last line in the original or the new file
|
|
612
|
-
// is missing a trailing newline. In other words, the presence of this marker
|
|
613
|
-
// means that the new and/or original file lacks a trailing newline.
|
|
614
|
-
//
|
|
615
|
-
// When we find it we have to look up the previous line and set the
|
|
616
|
-
// noTrailingNewLine flag
|
|
617
|
-
if (c === DiffPrefixNoNewline) {
|
|
618
|
-
// See https://github.com/git/git/blob/21f862b498925194f8f1ebe8203b7a7df756555b/apply.c#L1725-L1732
|
|
619
|
-
if (line.length < 12) {
|
|
620
|
-
throw new Error(`Expected "no newline at end of file" marker to be at least 12 bytes long`);
|
|
621
|
-
}
|
|
622
|
-
const previousLineIndex = lines.length - 1;
|
|
623
|
-
const previousLine = lines[previousLineIndex];
|
|
624
|
-
lines[previousLineIndex] = previousLine.withNoTrailingNewLine(true);
|
|
625
|
-
continue;
|
|
626
|
-
}
|
|
627
|
-
let diffLine;
|
|
628
|
-
if (c === DiffPrefixAdd) {
|
|
629
|
-
diffLine = new DiffLine(line, exports.DiffLineType.Add, diffLineNumber, null, rollingDiffAfterCounter++);
|
|
630
|
-
}
|
|
631
|
-
else if (c === DiffPrefixDelete) {
|
|
632
|
-
diffLine = new DiffLine(line, exports.DiffLineType.Delete, diffLineNumber, rollingDiffBeforeCounter++, null);
|
|
633
|
-
}
|
|
634
|
-
else if (c === DiffPrefixContext) {
|
|
635
|
-
diffLine = new DiffLine(line, exports.DiffLineType.Context, diffLineNumber, rollingDiffBeforeCounter++, rollingDiffAfterCounter++);
|
|
636
|
-
}
|
|
637
|
-
else {
|
|
638
|
-
return assertNever(c, `Unknown DiffLinePrefix: ${c}`);
|
|
639
|
-
}
|
|
640
|
-
lines.push(diffLine);
|
|
641
|
-
}
|
|
642
|
-
if (lines.length === 1) {
|
|
643
|
-
throw new Error("Malformed diff, empty hunk");
|
|
644
|
-
}
|
|
645
|
-
return new DiffHunk(header, lines, linesConsumed, linesConsumed + lines.length - 1, getHunkHeaderExpansionType(hunkIndex, header, previousHunk));
|
|
646
|
-
}
|
|
647
|
-
/**
|
|
648
|
-
* Parse a well-formed unified diff into hunks and lines.
|
|
649
|
-
*
|
|
650
|
-
* @param text A unified diff produced by git diff, git log --patch
|
|
651
|
-
* or any other git plumbing command that produces unified
|
|
652
|
-
* diffs.
|
|
653
|
-
*/
|
|
654
|
-
parse(text) {
|
|
655
|
-
this.text = text;
|
|
656
|
-
try {
|
|
657
|
-
const headerInfo = this.parseDiffHeader();
|
|
658
|
-
const headerEnd = this.le;
|
|
659
|
-
const header = this.text.substring(0, headerEnd);
|
|
660
|
-
// empty diff
|
|
661
|
-
if (!headerInfo) {
|
|
662
|
-
return {
|
|
663
|
-
header,
|
|
664
|
-
contents: "",
|
|
665
|
-
hunks: [],
|
|
666
|
-
isBinary: false,
|
|
667
|
-
maxLineNumber: 0,
|
|
668
|
-
hasHiddenBidiChars: false,
|
|
669
|
-
};
|
|
670
|
-
}
|
|
671
|
-
if (headerInfo.isBinary) {
|
|
672
|
-
return {
|
|
673
|
-
header,
|
|
674
|
-
contents: "",
|
|
675
|
-
hunks: [],
|
|
676
|
-
isBinary: true,
|
|
677
|
-
maxLineNumber: 0,
|
|
678
|
-
hasHiddenBidiChars: false,
|
|
679
|
-
};
|
|
680
|
-
}
|
|
681
|
-
const hunks = new Array();
|
|
682
|
-
let linesConsumed = 0;
|
|
683
|
-
let previousHunk = null;
|
|
684
|
-
do {
|
|
685
|
-
const hunk = this.parseHunk(linesConsumed, hunks.length, previousHunk);
|
|
686
|
-
hunks.push(hunk);
|
|
687
|
-
previousHunk = hunk;
|
|
688
|
-
linesConsumed += hunk.lines.length;
|
|
689
|
-
} while (this.peek());
|
|
690
|
-
const contents = this.text
|
|
691
|
-
.substring(headerEnd + 1, this.le)
|
|
692
|
-
// Note that this simply returns a reference to the
|
|
693
|
-
// substring if no match is found, it does not create
|
|
694
|
-
// a new string instance.
|
|
695
|
-
.replace(/\n\/g, "");
|
|
696
|
-
return {
|
|
697
|
-
header,
|
|
698
|
-
contents,
|
|
699
|
-
hunks,
|
|
700
|
-
isBinary: headerInfo.isBinary,
|
|
701
|
-
maxLineNumber: getLargestLineNumber(hunks),
|
|
702
|
-
hasHiddenBidiChars: HiddenBidiCharsRegex.test(text),
|
|
703
|
-
};
|
|
704
|
-
}
|
|
705
|
-
finally {
|
|
706
|
-
this.reset();
|
|
707
|
-
}
|
|
708
|
-
}
|
|
709
|
-
}
|
|
710
|
-
const parseInstance = new DiffParser();
|
|
711
|
-
|
|
712
|
-
/******************************************************************************
|
|
713
|
-
Copyright (c) Microsoft Corporation.
|
|
714
|
-
|
|
715
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
716
|
-
purpose with or without fee is hereby granted.
|
|
717
|
-
|
|
718
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
719
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
720
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
721
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
722
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
723
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
724
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
725
|
-
***************************************************************************** */
|
|
726
|
-
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
function __classPrivateFieldGet(receiver, state, kind, f) {
|
|
730
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
731
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
732
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
733
|
-
}
|
|
734
|
-
|
|
735
|
-
function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
|
736
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
737
|
-
return (state.set(receiver, value)), value;
|
|
738
|
-
}
|
|
739
|
-
|
|
740
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
741
|
-
var e = new Error(message);
|
|
742
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
743
|
-
};
|
|
744
|
-
|
|
745
|
-
const processAST = (ast) => {
|
|
746
|
-
let lineNumber = 1;
|
|
747
|
-
const syntaxObj = {};
|
|
748
|
-
const loopAST = (nodes, wrapper) => {
|
|
749
|
-
nodes.forEach((node) => {
|
|
750
|
-
if (node.type === "text") {
|
|
751
|
-
if (node.value.indexOf("\n") === -1) {
|
|
752
|
-
const valueLength = node.value.length;
|
|
753
|
-
if (!syntaxObj[lineNumber]) {
|
|
754
|
-
node.startIndex = 0;
|
|
755
|
-
node.endIndex = valueLength - 1;
|
|
756
|
-
const item = {
|
|
757
|
-
value: node.value,
|
|
758
|
-
lineNumber,
|
|
759
|
-
valueLength,
|
|
760
|
-
nodeList: [{ node, wrapper }],
|
|
761
|
-
};
|
|
762
|
-
syntaxObj[lineNumber] = item;
|
|
763
|
-
}
|
|
764
|
-
else {
|
|
765
|
-
node.startIndex = syntaxObj[lineNumber].valueLength;
|
|
766
|
-
node.endIndex = node.startIndex + valueLength - 1;
|
|
767
|
-
syntaxObj[lineNumber].value += node.value;
|
|
768
|
-
syntaxObj[lineNumber].valueLength += valueLength;
|
|
769
|
-
syntaxObj[lineNumber].nodeList.push({ node, wrapper });
|
|
770
|
-
}
|
|
771
|
-
node.lineNumber = lineNumber;
|
|
772
|
-
return;
|
|
773
|
-
}
|
|
774
|
-
const lines = node.value.split("\n");
|
|
775
|
-
node.children = node.children || [];
|
|
776
|
-
for (let i = 0; i < lines.length; i++) {
|
|
777
|
-
const _value = i === lines.length - 1 ? lines[i] : lines[i] + "\n";
|
|
778
|
-
const _lineNumber = i === 0 ? lineNumber : ++lineNumber;
|
|
779
|
-
const _valueLength = _value.length;
|
|
780
|
-
const _node = {
|
|
781
|
-
type: "text",
|
|
782
|
-
value: _value,
|
|
783
|
-
startIndex: Infinity,
|
|
784
|
-
endIndex: Infinity,
|
|
785
|
-
lineNumber: _lineNumber,
|
|
786
|
-
};
|
|
787
|
-
if (!syntaxObj[_lineNumber]) {
|
|
788
|
-
_node.startIndex = 0;
|
|
789
|
-
_node.endIndex = _valueLength - 1;
|
|
790
|
-
const item = {
|
|
791
|
-
value: _value,
|
|
792
|
-
lineNumber: _lineNumber,
|
|
793
|
-
valueLength: _valueLength,
|
|
794
|
-
nodeList: [{ node: _node, wrapper }],
|
|
795
|
-
};
|
|
796
|
-
syntaxObj[_lineNumber] = item;
|
|
797
|
-
}
|
|
798
|
-
else {
|
|
799
|
-
_node.startIndex = syntaxObj[_lineNumber].valueLength;
|
|
800
|
-
_node.endIndex = _node.startIndex + _valueLength - 1;
|
|
801
|
-
syntaxObj[_lineNumber].value += _value;
|
|
802
|
-
syntaxObj[_lineNumber].valueLength += _valueLength;
|
|
803
|
-
syntaxObj[_lineNumber].nodeList.push({ node: _node, wrapper });
|
|
804
|
-
}
|
|
805
|
-
node.children.push(_node);
|
|
806
|
-
}
|
|
807
|
-
node.lineNumber = lineNumber;
|
|
808
|
-
return;
|
|
809
|
-
}
|
|
810
|
-
if (node.children) {
|
|
811
|
-
loopAST(node.children, node);
|
|
812
|
-
node.lineNumber = lineNumber;
|
|
813
|
-
}
|
|
814
|
-
});
|
|
815
|
-
};
|
|
816
|
-
loopAST(ast.children);
|
|
817
|
-
return { syntaxFileObject: syntaxObj, syntaxFileLineNumber: lineNumber };
|
|
818
|
-
};
|
|
819
|
-
|
|
820
|
-
const lowlight = lowlight$1.createLowlight(lowlight$1.all);
|
|
821
|
-
// !SEE https://github.com/highlightjs/highlightjs-vue
|
|
822
|
-
lowlight.register("vue", function hljsDefineVue(hljs) {
|
|
823
|
-
return {
|
|
824
|
-
subLanguage: "xml",
|
|
825
|
-
contains: [
|
|
826
|
-
hljs.COMMENT("<!--", "-->", {
|
|
827
|
-
relevance: 10,
|
|
828
|
-
}),
|
|
829
|
-
{
|
|
830
|
-
begin: /^(\s*)(<script>)/gm,
|
|
831
|
-
end: /^(\s*)(<\/script>)/gm,
|
|
832
|
-
subLanguage: "javascript",
|
|
833
|
-
excludeBegin: true,
|
|
834
|
-
excludeEnd: true,
|
|
835
|
-
},
|
|
836
|
-
{
|
|
837
|
-
begin: /^(?:\s*)(?:<script\s+lang=(["'])ts\1>)/gm,
|
|
838
|
-
end: /^(\s*)(<\/script>)/gm,
|
|
839
|
-
subLanguage: "typescript",
|
|
840
|
-
excludeBegin: true,
|
|
841
|
-
excludeEnd: true,
|
|
842
|
-
},
|
|
843
|
-
{
|
|
844
|
-
begin: /^(\s*)(<style(\s+scoped)?>)/gm,
|
|
845
|
-
end: /^(\s*)(<\/style>)/gm,
|
|
846
|
-
subLanguage: "css",
|
|
847
|
-
excludeBegin: true,
|
|
848
|
-
excludeEnd: true,
|
|
849
|
-
},
|
|
850
|
-
{
|
|
851
|
-
begin: /^(?:\s*)(?:<style(?:\s+scoped)?\s+lang=(["'])(?:s[ca]ss)\1(?:\s+scoped)?>)/gm,
|
|
852
|
-
end: /^(\s*)(<\/style>)/gm,
|
|
853
|
-
subLanguage: "scss",
|
|
854
|
-
excludeBegin: true,
|
|
855
|
-
excludeEnd: true,
|
|
856
|
-
},
|
|
857
|
-
{
|
|
858
|
-
begin: /^(?:\s*)(?:<style(?:\s+scoped)?\s+lang=(["'])stylus\1(?:\s+scoped)?>)/gm,
|
|
859
|
-
end: /^(\s*)(<\/style>)/gm,
|
|
860
|
-
subLanguage: "stylus",
|
|
861
|
-
excludeBegin: true,
|
|
862
|
-
excludeEnd: true,
|
|
863
|
-
},
|
|
864
|
-
],
|
|
865
|
-
};
|
|
866
|
-
});
|
|
867
|
-
const instance = { name: "lowlight" };
|
|
868
|
-
let _maxLineToIgnoreSyntax = 2000;
|
|
869
|
-
const _ignoreSyntaxHighlightList = [];
|
|
870
|
-
Object.defineProperty(instance, "maxLineToIgnoreSyntax", {
|
|
871
|
-
get: () => _maxLineToIgnoreSyntax,
|
|
872
|
-
});
|
|
873
|
-
Object.defineProperty(instance, "setMaxLineToIgnoreSyntax", {
|
|
874
|
-
value: (v) => {
|
|
875
|
-
_maxLineToIgnoreSyntax = v;
|
|
876
|
-
},
|
|
877
|
-
});
|
|
878
|
-
Object.defineProperty(instance, "ignoreSyntaxHighlightList", {
|
|
879
|
-
get: () => _ignoreSyntaxHighlightList,
|
|
880
|
-
});
|
|
881
|
-
Object.defineProperty(instance, "setIgnoreSyntaxHighlightList", {
|
|
882
|
-
value: (v) => {
|
|
883
|
-
_ignoreSyntaxHighlightList.length = 0;
|
|
884
|
-
_ignoreSyntaxHighlightList.push(...v);
|
|
885
|
-
},
|
|
886
|
-
});
|
|
887
|
-
Object.defineProperty(instance, "getAST", {
|
|
888
|
-
value: (raw, fileName, lang) => {
|
|
889
|
-
let hasRegisteredLang = true;
|
|
890
|
-
if (!lowlight.registered(lang)) {
|
|
891
|
-
console.warn(`not support current lang: ${lang} yet`);
|
|
892
|
-
hasRegisteredLang = false;
|
|
893
|
-
}
|
|
894
|
-
if (fileName &&
|
|
895
|
-
highlighter.ignoreSyntaxHighlightList.some((item) => item instanceof RegExp ? item.test(fileName) : fileName === item)) {
|
|
896
|
-
console.warn(`ignore syntax for current file, because the fileName is in the ignoreSyntaxHighlightList: ${fileName}`);
|
|
897
|
-
return;
|
|
898
|
-
}
|
|
899
|
-
if (hasRegisteredLang) {
|
|
900
|
-
return lowlight.highlight(lang, raw);
|
|
901
|
-
}
|
|
902
|
-
else {
|
|
903
|
-
return lowlight.highlightAuto(raw);
|
|
904
|
-
}
|
|
905
|
-
},
|
|
906
|
-
});
|
|
907
|
-
Object.defineProperty(instance, "processAST", {
|
|
908
|
-
value: (ast) => {
|
|
909
|
-
return processAST(ast);
|
|
910
|
-
},
|
|
911
|
-
});
|
|
912
|
-
Object.defineProperty(instance, "hasRegisteredCurrentLang", {
|
|
913
|
-
value: (lang) => {
|
|
914
|
-
return lowlight.registered(lang);
|
|
915
|
-
},
|
|
916
|
-
});
|
|
917
|
-
const highlighter = instance;
|
|
918
|
-
|
|
919
|
-
var _Cache_keyArray, _Cache_maxLength;
|
|
920
|
-
class Cache extends Map {
|
|
921
|
-
constructor() {
|
|
922
|
-
super(...arguments);
|
|
923
|
-
_Cache_keyArray.set(this, []);
|
|
924
|
-
_Cache_maxLength.set(this, 30);
|
|
925
|
-
}
|
|
926
|
-
setMaxLength(length) {
|
|
927
|
-
__classPrivateFieldSet(this, _Cache_maxLength, length);
|
|
928
|
-
this._checkLength();
|
|
929
|
-
}
|
|
930
|
-
set(key, value) {
|
|
931
|
-
if (this.has(key))
|
|
932
|
-
return this;
|
|
933
|
-
__classPrivateFieldGet(this, _Cache_keyArray, "f").push(key);
|
|
934
|
-
this._checkLength();
|
|
935
|
-
return super.set(key, value);
|
|
936
|
-
}
|
|
937
|
-
_checkLength() {
|
|
938
|
-
while (__classPrivateFieldGet(this, _Cache_keyArray, "f").length > __classPrivateFieldGet(this, _Cache_maxLength, "f")) {
|
|
939
|
-
const key = __classPrivateFieldGet(this, _Cache_keyArray, "f").shift();
|
|
940
|
-
this.delete(key);
|
|
941
|
-
}
|
|
942
|
-
}
|
|
943
|
-
}
|
|
944
|
-
_Cache_keyArray = new WeakMap(), _Cache_maxLength = new WeakMap();
|
|
945
|
-
|
|
946
|
-
var _File_instances, _File_doCheck;
|
|
947
|
-
const map = new Cache();
|
|
948
|
-
const devKey = "@git-diff-cache";
|
|
949
|
-
map.setMaxLength(50);
|
|
950
|
-
map.name = "@git-diff-view/core";
|
|
951
|
-
if (typeof globalThis !== "undefined") {
|
|
952
|
-
if (Array.isArray(globalThis[devKey])) {
|
|
953
|
-
globalThis[devKey] = globalThis[devKey].filter((i) => i !== map);
|
|
954
|
-
if (globalThis[devKey].length > 0) {
|
|
955
|
-
console.warn("there are multiple instance of @git-diff-view/core in the one environment!");
|
|
956
|
-
}
|
|
957
|
-
globalThis[devKey].push(map);
|
|
958
|
-
}
|
|
959
|
-
else {
|
|
960
|
-
globalThis[devKey] = [map];
|
|
961
|
-
}
|
|
962
|
-
}
|
|
963
|
-
class File {
|
|
964
|
-
static createInstance(data) {
|
|
965
|
-
const file = new File(data === null || data === void 0 ? void 0 : data.raw, data === null || data === void 0 ? void 0 : data.lang, data === null || data === void 0 ? void 0 : data.fileName);
|
|
966
|
-
file.ast = data === null || data === void 0 ? void 0 : data.ast;
|
|
967
|
-
file.rawFile = data === null || data === void 0 ? void 0 : data.rawFile;
|
|
968
|
-
file.hasDoRaw = data === null || data === void 0 ? void 0 : data.hasDoRaw;
|
|
969
|
-
file.rawLength = data === null || data === void 0 ? void 0 : data.rawLength;
|
|
970
|
-
file.syntaxFile = data === null || data === void 0 ? void 0 : data.syntaxFile;
|
|
971
|
-
file.hasDoSyntax = data === null || data === void 0 ? void 0 : data.hasDoSyntax;
|
|
972
|
-
file.syntaxLength = data === null || data === void 0 ? void 0 : data.syntaxLength;
|
|
973
|
-
file.highlighterName = data === null || data === void 0 ? void 0 : data.highlighterName;
|
|
974
|
-
file.maxLineNumber = data === null || data === void 0 ? void 0 : data.maxLineNumber;
|
|
975
|
-
return file;
|
|
976
|
-
}
|
|
977
|
-
constructor(raw, lang, fileName) {
|
|
978
|
-
_File_instances.add(this);
|
|
979
|
-
this.raw = raw;
|
|
980
|
-
this.lang = lang;
|
|
981
|
-
this.fileName = fileName;
|
|
982
|
-
this.rawFile = {};
|
|
983
|
-
this.hasDoRaw = false;
|
|
984
|
-
this.syntaxFile = {};
|
|
985
|
-
this.hasDoSyntax = false;
|
|
986
|
-
this.maxLineNumber = 0;
|
|
987
|
-
Object.defineProperty(this, "__v_skip", { value: true });
|
|
988
|
-
}
|
|
989
|
-
doSyntax({ registerHighlighter }) {
|
|
990
|
-
if (!this.raw || this.hasDoSyntax)
|
|
991
|
-
return;
|
|
992
|
-
const _highlighter = registerHighlighter || highlighter;
|
|
993
|
-
if (this.syntaxLength) {
|
|
994
|
-
console.error("current file already doSyntax before!");
|
|
995
|
-
return;
|
|
996
|
-
}
|
|
997
|
-
if (this.rawLength > _highlighter.maxLineToIgnoreSyntax) {
|
|
998
|
-
console.warn(`ignore syntax for current file, because the rawLength is too long: ${this.rawLength}`);
|
|
999
|
-
return;
|
|
1000
|
-
}
|
|
1001
|
-
this.ast = _highlighter.getAST(this.raw, this.fileName, this.lang);
|
|
1002
|
-
if (!this.ast)
|
|
1003
|
-
return;
|
|
1004
|
-
const { syntaxFileObject, syntaxFileLineNumber } = _highlighter.processAST(this.ast);
|
|
1005
|
-
this.syntaxFile = syntaxFileObject;
|
|
1006
|
-
this.syntaxLength = syntaxFileLineNumber;
|
|
1007
|
-
this.highlighterName = _highlighter.name;
|
|
1008
|
-
{
|
|
1009
|
-
__classPrivateFieldGet(this, _File_instances, "m", _File_doCheck).call(this);
|
|
1010
|
-
}
|
|
1011
|
-
this.hasDoSyntax = true;
|
|
1012
|
-
}
|
|
1013
|
-
doRaw() {
|
|
1014
|
-
if (!this.raw || this.hasDoRaw)
|
|
1015
|
-
return;
|
|
1016
|
-
const rawString = this.raw;
|
|
1017
|
-
const rawArray = rawString.split("\n");
|
|
1018
|
-
this.rawLength = rawArray.length;
|
|
1019
|
-
this.maxLineNumber = rawArray.length;
|
|
1020
|
-
this.rawFile = {};
|
|
1021
|
-
for (let i = 0; i < rawArray.length; i++) {
|
|
1022
|
-
this.rawFile[i + 1] = i < rawArray.length - 1 ? rawArray[i] + "\n" : rawArray[i];
|
|
1023
|
-
}
|
|
1024
|
-
// reduce 对于大数组性能很差
|
|
1025
|
-
// this.rawFile = rawArray.reduce(
|
|
1026
|
-
// (p, item, index) => ({
|
|
1027
|
-
// ...p,
|
|
1028
|
-
// [index + 1]: index < rawArray.length - 1 ? item + "\n" : item,
|
|
1029
|
-
// }),
|
|
1030
|
-
// {}
|
|
1031
|
-
// );
|
|
1032
|
-
this.hasDoRaw = true;
|
|
1033
|
-
}
|
|
1034
|
-
}
|
|
1035
|
-
_File_instances = new WeakSet(), _File_doCheck = function _File_doCheck() {
|
|
1036
|
-
if (this.rawLength && this.syntaxLength) {
|
|
1037
|
-
if (this.rawLength !== this.syntaxLength) {
|
|
1038
|
-
console.warn("the rawLength not match for the syntaxLength");
|
|
1039
|
-
}
|
|
1040
|
-
Object.values(this.syntaxFile).forEach(({ value, lineNumber }) => {
|
|
1041
|
-
if (value !== this.rawFile[lineNumber]) {
|
|
1042
|
-
console.log("some line not match:" + value + " __ " + this.rawFile[lineNumber] + " __ at: " + lineNumber + " lineNumber");
|
|
1043
|
-
}
|
|
1044
|
-
});
|
|
1045
|
-
}
|
|
1046
|
-
};
|
|
1047
|
-
const getFile = (raw, lang, fileName) => {
|
|
1048
|
-
const key = raw + "--" + "0.0.13" + "--" + lang;
|
|
1049
|
-
if (map.has(key))
|
|
1050
|
-
return map.get(key);
|
|
1051
|
-
const file = new File(raw, lang, fileName);
|
|
1052
|
-
map.set(key, file);
|
|
1053
|
-
return file;
|
|
1054
|
-
};
|
|
1055
|
-
const _cacheMap = map;
|
|
1056
|
-
|
|
1057
|
-
var _DiffFile_instances, _DiffFile_oldFileResult, _DiffFile_newFileResult, _DiffFile_diffListResults, _DiffFile_diffLines, _DiffFile_oldFileDiffLines, _DiffFile_newFileDiffLines, _DiffFile_oldFileLines, _DiffFile_newFileLines, _DiffFile_oldFileSyntaxLines, _DiffFile_newFileSyntaxLines, _DiffFile_oldFilePlaceholderLines, _DiffFile_newFilePlaceholderLines, _DiffFile_splitLeftLines, _DiffFile_splitRightLines, _DiffFile_splitHunksLines, _DiffFile_unifiedLines, _DiffFile_unifiedHunksLines, _DiffFile_listeners, _DiffFile_hasInitRaw, _DiffFile_hasInitSyntax, _DiffFile_hasBuildSplit, _DiffFile_hasBuildUnified, _DiffFile_updateCount, _DiffFile_composeByDiff, _DiffFile_composeByMerge, _DiffFile_composeByFullMerge, _DiffFile_highlighterName, _DiffFile_id, _DiffFile_clonedInstance, _DiffFile_doDiff, _DiffFile_doFile, _DiffFile_composeRaw, _DiffFile_composeFile, _DiffFile_composeDiff, _DiffFile_composeSyntax, _DiffFile_getOldDiffLine, _DiffFile_getNewDiffLine, _DiffFile_getOldRawLine, _DiffFile_getNewRawLine;
|
|
1058
|
-
const composeLen = 40;
|
|
1059
|
-
const idSet = new Set();
|
|
1060
|
-
class DiffFile {
|
|
1061
|
-
static createInstance(data, bundle) {
|
|
1062
|
-
var _a, _b, _c, _d, _e, _f;
|
|
1063
|
-
const instance = new DiffFile(((_a = data === null || data === void 0 ? void 0 : data.oldFile) === null || _a === void 0 ? void 0 : _a.fileName) || "", ((_b = data === null || data === void 0 ? void 0 : data.oldFile) === null || _b === void 0 ? void 0 : _b.content) || "", ((_c = data === null || data === void 0 ? void 0 : data.newFile) === null || _c === void 0 ? void 0 : _c.fileName) || "", ((_d = data === null || data === void 0 ? void 0 : data.newFile) === null || _d === void 0 ? void 0 : _d.content) || "", (data === null || data === void 0 ? void 0 : data.hunks) || [], ((_e = data === null || data === void 0 ? void 0 : data.oldFile) === null || _e === void 0 ? void 0 : _e.fileLang) || "", ((_f = data === null || data === void 0 ? void 0 : data.newFile) === null || _f === void 0 ? void 0 : _f.fileLang) || "");
|
|
1064
|
-
if (bundle) {
|
|
1065
|
-
if (bundle.isFullMerge) {
|
|
1066
|
-
instance._mergeFullBundle(bundle);
|
|
1067
|
-
}
|
|
1068
|
-
else {
|
|
1069
|
-
instance.mergeBundle(bundle);
|
|
1070
|
-
}
|
|
1071
|
-
}
|
|
1072
|
-
return instance;
|
|
1073
|
-
}
|
|
1074
|
-
constructor(_oldFileName, _oldFileContent, _newFileName, _newFileContent, _diffList, _oldFileLang, _newFileLang) {
|
|
1075
|
-
_DiffFile_instances.add(this);
|
|
1076
|
-
this._oldFileName = _oldFileName;
|
|
1077
|
-
this._newFileName = _newFileName;
|
|
1078
|
-
this._diffList = _diffList;
|
|
1079
|
-
_DiffFile_oldFileResult.set(this, void 0);
|
|
1080
|
-
_DiffFile_newFileResult.set(this, void 0);
|
|
1081
|
-
_DiffFile_diffListResults.set(this, void 0);
|
|
1082
|
-
_DiffFile_diffLines.set(this, void 0);
|
|
1083
|
-
_DiffFile_oldFileDiffLines.set(this, void 0);
|
|
1084
|
-
_DiffFile_newFileDiffLines.set(this, void 0);
|
|
1085
|
-
_DiffFile_oldFileLines.set(this, void 0);
|
|
1086
|
-
_DiffFile_newFileLines.set(this, void 0);
|
|
1087
|
-
_DiffFile_oldFileSyntaxLines.set(this, void 0);
|
|
1088
|
-
_DiffFile_newFileSyntaxLines.set(this, void 0);
|
|
1089
|
-
_DiffFile_oldFilePlaceholderLines.set(this, void 0);
|
|
1090
|
-
_DiffFile_newFilePlaceholderLines.set(this, void 0);
|
|
1091
|
-
_DiffFile_splitLeftLines.set(this, []);
|
|
1092
|
-
_DiffFile_splitRightLines.set(this, []);
|
|
1093
|
-
_DiffFile_splitHunksLines.set(this, void 0);
|
|
1094
|
-
_DiffFile_unifiedLines.set(this, []);
|
|
1095
|
-
_DiffFile_unifiedHunksLines.set(this, void 0);
|
|
1096
|
-
_DiffFile_listeners.set(this, []);
|
|
1097
|
-
_DiffFile_hasInitRaw.set(this, false);
|
|
1098
|
-
_DiffFile_hasInitSyntax.set(this, false);
|
|
1099
|
-
_DiffFile_hasBuildSplit.set(this, false);
|
|
1100
|
-
_DiffFile_hasBuildUnified.set(this, false);
|
|
1101
|
-
_DiffFile_updateCount.set(this, 0);
|
|
1102
|
-
_DiffFile_composeByDiff.set(this, false);
|
|
1103
|
-
_DiffFile_composeByMerge.set(this, false);
|
|
1104
|
-
_DiffFile_composeByFullMerge.set(this, false);
|
|
1105
|
-
_DiffFile_highlighterName.set(this, void 0);
|
|
1106
|
-
this._version_ = "0.0.13";
|
|
1107
|
-
this._oldFileContent = "";
|
|
1108
|
-
this._oldFileLang = "";
|
|
1109
|
-
this._newFileContent = "";
|
|
1110
|
-
this._newFileLang = "";
|
|
1111
|
-
this.diffLineLength = 0;
|
|
1112
|
-
this.splitLineLength = 0;
|
|
1113
|
-
this.unifiedLineLength = 0;
|
|
1114
|
-
this.fileLineLength = 0;
|
|
1115
|
-
this.hasExpandSplitAll = false;
|
|
1116
|
-
this.hasExpandUnifiedAll = false;
|
|
1117
|
-
this.hasSomeLineCollapsed = false;
|
|
1118
|
-
_DiffFile_id.set(this, "");
|
|
1119
|
-
_DiffFile_clonedInstance.set(this, new Map());
|
|
1120
|
-
this.getSplitLeftLine = (index) => {
|
|
1121
|
-
return __classPrivateFieldGet(this, _DiffFile_splitLeftLines, "f")[index];
|
|
1122
|
-
};
|
|
1123
|
-
this.getSplitRightLine = (index) => {
|
|
1124
|
-
return __classPrivateFieldGet(this, _DiffFile_splitRightLines, "f")[index];
|
|
1125
|
-
};
|
|
1126
|
-
this.getSplitHunkLine = (index) => {
|
|
1127
|
-
var _a;
|
|
1128
|
-
return (_a = __classPrivateFieldGet(this, _DiffFile_splitHunksLines, "f")) === null || _a === void 0 ? void 0 : _a[index];
|
|
1129
|
-
};
|
|
1130
|
-
this.onSplitHunkExpand = (dir, index, needTrigger = true) => {
|
|
1131
|
-
var _a, _b;
|
|
1132
|
-
const current = (_a = __classPrivateFieldGet(this, _DiffFile_splitHunksLines, "f")) === null || _a === void 0 ? void 0 : _a[index];
|
|
1133
|
-
if (!current || !current.splitInfo)
|
|
1134
|
-
return;
|
|
1135
|
-
if (__classPrivateFieldGet(this, _DiffFile_composeByDiff, "f"))
|
|
1136
|
-
return;
|
|
1137
|
-
if (dir === "all") {
|
|
1138
|
-
for (let i = current.splitInfo.startHiddenIndex; i < current.splitInfo.endHiddenIndex; i++) {
|
|
1139
|
-
const leftLine = __classPrivateFieldGet(this, _DiffFile_splitLeftLines, "f")[i];
|
|
1140
|
-
const rightLine = __classPrivateFieldGet(this, _DiffFile_splitRightLines, "f")[i];
|
|
1141
|
-
if (leftLine === null || leftLine === void 0 ? void 0 : leftLine.isHidden)
|
|
1142
|
-
leftLine.isHidden = false;
|
|
1143
|
-
if (rightLine === null || rightLine === void 0 ? void 0 : rightLine.isHidden)
|
|
1144
|
-
rightLine.isHidden = false;
|
|
1145
|
-
}
|
|
1146
|
-
current.splitInfo = Object.assign(Object.assign(Object.assign({}, current.splitInfo), current.hunkInfo), { plainText: current.text, startHiddenIndex: current.splitInfo.endHiddenIndex });
|
|
1147
|
-
}
|
|
1148
|
-
else if (dir === "down") {
|
|
1149
|
-
for (let i = current.splitInfo.startHiddenIndex; i < current.splitInfo.startHiddenIndex + composeLen; i++) {
|
|
1150
|
-
const leftLine = __classPrivateFieldGet(this, _DiffFile_splitLeftLines, "f")[i];
|
|
1151
|
-
const rightLine = __classPrivateFieldGet(this, _DiffFile_splitRightLines, "f")[i];
|
|
1152
|
-
if (leftLine === null || leftLine === void 0 ? void 0 : leftLine.isHidden)
|
|
1153
|
-
leftLine.isHidden = false;
|
|
1154
|
-
if (rightLine === null || rightLine === void 0 ? void 0 : rightLine.isHidden)
|
|
1155
|
-
rightLine.isHidden = false;
|
|
1156
|
-
}
|
|
1157
|
-
if (current.isLast) {
|
|
1158
|
-
current.splitInfo = Object.assign(Object.assign({}, current.splitInfo), { startHiddenIndex: current.splitInfo.startHiddenIndex + composeLen });
|
|
1159
|
-
}
|
|
1160
|
-
else {
|
|
1161
|
-
current.splitInfo = Object.assign(Object.assign({}, current.splitInfo), { startHiddenIndex: current.splitInfo.startHiddenIndex + composeLen, plainText: `@@ -${current.splitInfo.oldStartIndex},${current.splitInfo.oldLength} +${current.splitInfo.newStartIndex},${current.splitInfo.newLength}` });
|
|
1162
|
-
}
|
|
1163
|
-
}
|
|
1164
|
-
else {
|
|
1165
|
-
if (current.isLast) {
|
|
1166
|
-
console.error("the last hunk can not expand up!");
|
|
1167
|
-
return;
|
|
1168
|
-
}
|
|
1169
|
-
for (let i = current.splitInfo.endHiddenIndex - composeLen; i < current.splitInfo.endHiddenIndex; i++) {
|
|
1170
|
-
const leftLine = __classPrivateFieldGet(this, _DiffFile_splitLeftLines, "f")[i];
|
|
1171
|
-
const rightLine = __classPrivateFieldGet(this, _DiffFile_splitRightLines, "f")[i];
|
|
1172
|
-
if (leftLine === null || leftLine === void 0 ? void 0 : leftLine.isHidden)
|
|
1173
|
-
leftLine.isHidden = false;
|
|
1174
|
-
if (rightLine === null || rightLine === void 0 ? void 0 : rightLine.isHidden)
|
|
1175
|
-
rightLine.isHidden = false;
|
|
1176
|
-
}
|
|
1177
|
-
const oldStartIndex = current.splitInfo.oldStartIndex - composeLen;
|
|
1178
|
-
const oldLength = current.splitInfo.oldLength + composeLen;
|
|
1179
|
-
const newStartIndex = current.splitInfo.newStartIndex - composeLen;
|
|
1180
|
-
const newLength = current.splitInfo.newLength + composeLen;
|
|
1181
|
-
current.splitInfo = Object.assign(Object.assign({}, current.splitInfo), { endHiddenIndex: current.splitInfo.endHiddenIndex - composeLen, oldStartIndex,
|
|
1182
|
-
oldLength,
|
|
1183
|
-
newStartIndex,
|
|
1184
|
-
newLength, plainText: `@@ -${oldStartIndex},${oldLength} +${newStartIndex},${newLength}` });
|
|
1185
|
-
(_b = __classPrivateFieldGet(this, _DiffFile_splitHunksLines, "f")) === null || _b === void 0 ? true : delete _b[index];
|
|
1186
|
-
__classPrivateFieldGet(this, _DiffFile_splitHunksLines, "f")[current.splitInfo.endHiddenIndex] = current;
|
|
1187
|
-
}
|
|
1188
|
-
needTrigger && this.notifyAll();
|
|
1189
|
-
};
|
|
1190
|
-
this.getUnifiedLine = (index) => {
|
|
1191
|
-
return __classPrivateFieldGet(this, _DiffFile_unifiedLines, "f")[index];
|
|
1192
|
-
};
|
|
1193
|
-
this.getUnifiedHunkLine = (index) => {
|
|
1194
|
-
var _a;
|
|
1195
|
-
return (_a = __classPrivateFieldGet(this, _DiffFile_unifiedHunksLines, "f")) === null || _a === void 0 ? void 0 : _a[index];
|
|
1196
|
-
};
|
|
1197
|
-
this.onUnifiedHunkExpand = (dir, index, needTrigger = true) => {
|
|
1198
|
-
var _a, _b, _c;
|
|
1199
|
-
const current = (_a = __classPrivateFieldGet(this, _DiffFile_unifiedHunksLines, "f")) === null || _a === void 0 ? void 0 : _a[index];
|
|
1200
|
-
if (!current || !current.unifiedInfo)
|
|
1201
|
-
return;
|
|
1202
|
-
if (__classPrivateFieldGet(this, _DiffFile_composeByDiff, "f"))
|
|
1203
|
-
return;
|
|
1204
|
-
if (dir === "all") {
|
|
1205
|
-
for (let i = current.unifiedInfo.startHiddenIndex; i < current.unifiedInfo.endHiddenIndex; i++) {
|
|
1206
|
-
const unifiedLine = (_b = __classPrivateFieldGet(this, _DiffFile_unifiedLines, "f")) === null || _b === void 0 ? void 0 : _b[i];
|
|
1207
|
-
if (unifiedLine === null || unifiedLine === void 0 ? void 0 : unifiedLine.isHidden) {
|
|
1208
|
-
unifiedLine.isHidden = false;
|
|
1209
|
-
}
|
|
1210
|
-
}
|
|
1211
|
-
current.unifiedInfo = Object.assign(Object.assign(Object.assign({}, current.unifiedInfo), current.hunkInfo), { plainText: current.text, startHiddenIndex: current.unifiedInfo.endHiddenIndex });
|
|
1212
|
-
}
|
|
1213
|
-
else if (dir === "down") {
|
|
1214
|
-
for (let i = current.unifiedInfo.startHiddenIndex; i < current.unifiedInfo.startHiddenIndex + composeLen; i++) {
|
|
1215
|
-
const unifiedLine = __classPrivateFieldGet(this, _DiffFile_unifiedLines, "f")[i];
|
|
1216
|
-
if (unifiedLine === null || unifiedLine === void 0 ? void 0 : unifiedLine.isHidden)
|
|
1217
|
-
unifiedLine.isHidden = false;
|
|
1218
|
-
}
|
|
1219
|
-
if (current.isLast) {
|
|
1220
|
-
current.unifiedInfo = Object.assign(Object.assign({}, current.unifiedInfo), { startHiddenIndex: current.unifiedInfo.startHiddenIndex + composeLen });
|
|
1221
|
-
}
|
|
1222
|
-
else {
|
|
1223
|
-
current.unifiedInfo = Object.assign(Object.assign({}, current.unifiedInfo), { startHiddenIndex: current.unifiedInfo.startHiddenIndex + composeLen, plainText: `@@ -${current.unifiedInfo.oldStartIndex},${current.unifiedInfo.oldLength} +${current.unifiedInfo.newStartIndex},${current.unifiedInfo.newLength}` });
|
|
1224
|
-
}
|
|
1225
|
-
}
|
|
1226
|
-
else {
|
|
1227
|
-
if (current.isLast) {
|
|
1228
|
-
console.error("the last hunk can not expand up!");
|
|
1229
|
-
return;
|
|
1230
|
-
}
|
|
1231
|
-
for (let i = current.unifiedInfo.endHiddenIndex - composeLen; i < current.unifiedInfo.endHiddenIndex; i++) {
|
|
1232
|
-
const unifiedLine = __classPrivateFieldGet(this, _DiffFile_unifiedLines, "f")[i];
|
|
1233
|
-
if (unifiedLine === null || unifiedLine === void 0 ? void 0 : unifiedLine.isHidden)
|
|
1234
|
-
unifiedLine.isHidden = false;
|
|
1235
|
-
}
|
|
1236
|
-
const oldStartIndex = current.unifiedInfo.oldStartIndex - composeLen;
|
|
1237
|
-
const oldLength = current.unifiedInfo.oldLength + composeLen;
|
|
1238
|
-
const newStartIndex = current.unifiedInfo.newStartIndex - composeLen;
|
|
1239
|
-
const newLength = current.unifiedInfo.newLength + composeLen;
|
|
1240
|
-
current.unifiedInfo = Object.assign(Object.assign({}, current.unifiedInfo), { endHiddenIndex: current.unifiedInfo.endHiddenIndex - composeLen, oldStartIndex,
|
|
1241
|
-
oldLength,
|
|
1242
|
-
newStartIndex,
|
|
1243
|
-
newLength, plainText: `@@ -${oldStartIndex},${oldLength} +${newStartIndex},${newLength}` });
|
|
1244
|
-
(_c = __classPrivateFieldGet(this, _DiffFile_unifiedHunksLines, "f")) === null || _c === void 0 ? true : delete _c[index];
|
|
1245
|
-
__classPrivateFieldGet(this, _DiffFile_unifiedHunksLines, "f")[current.unifiedInfo.endHiddenIndex] = current;
|
|
1246
|
-
}
|
|
1247
|
-
needTrigger && this.notifyAll();
|
|
1248
|
-
};
|
|
1249
|
-
this.onAllExpand = (mode) => {
|
|
1250
|
-
if (__classPrivateFieldGet(this, _DiffFile_composeByDiff, "f"))
|
|
1251
|
-
return;
|
|
1252
|
-
if (mode === "split") {
|
|
1253
|
-
Object.keys(__classPrivateFieldGet(this, _DiffFile_splitHunksLines, "f") || {}).forEach((key) => {
|
|
1254
|
-
this.onSplitHunkExpand("all", +key, false);
|
|
1255
|
-
});
|
|
1256
|
-
this.hasExpandSplitAll = true;
|
|
1257
|
-
}
|
|
1258
|
-
else {
|
|
1259
|
-
Object.keys(__classPrivateFieldGet(this, _DiffFile_unifiedHunksLines, "f") || {}).forEach((key) => {
|
|
1260
|
-
this.onUnifiedHunkExpand("all", +key, false);
|
|
1261
|
-
});
|
|
1262
|
-
this.hasExpandUnifiedAll = true;
|
|
1263
|
-
}
|
|
1264
|
-
this.notifyAll();
|
|
1265
|
-
};
|
|
1266
|
-
this.onAllCollapse = (mode) => {
|
|
1267
|
-
if (__classPrivateFieldGet(this, _DiffFile_composeByDiff, "f"))
|
|
1268
|
-
return;
|
|
1269
|
-
if (mode === "split") {
|
|
1270
|
-
Object.values(__classPrivateFieldGet(this, _DiffFile_splitLeftLines, "f") || {}).forEach((item) => {
|
|
1271
|
-
if (!item.isHidden && item._isHidden) {
|
|
1272
|
-
item.isHidden = item._isHidden;
|
|
1273
|
-
}
|
|
1274
|
-
});
|
|
1275
|
-
Object.values(__classPrivateFieldGet(this, _DiffFile_splitRightLines, "f") || {}).forEach((item) => {
|
|
1276
|
-
if (!item.isHidden && item._isHidden) {
|
|
1277
|
-
item.isHidden = item._isHidden;
|
|
1278
|
-
}
|
|
1279
|
-
});
|
|
1280
|
-
Object.values(__classPrivateFieldGet(this, _DiffFile_splitHunksLines, "f") || {}).forEach((item) => {
|
|
1281
|
-
if (!item.splitInfo)
|
|
1282
|
-
return;
|
|
1283
|
-
item.splitInfo = Object.assign(Object.assign({}, item.splitInfo), { oldStartIndex: item.splitInfo._oldStartIndex, oldLength: item.splitInfo._oldLength, newStartIndex: item.splitInfo._newStartIndex, newLength: item.splitInfo._newLength, startHiddenIndex: item.splitInfo._startHiddenIndex, endHiddenIndex: item.splitInfo._endHiddenIndex, plainText: item.splitInfo._plainText });
|
|
1284
|
-
});
|
|
1285
|
-
Object.keys(__classPrivateFieldGet(this, _DiffFile_splitHunksLines, "f") || {}).forEach((key) => {
|
|
1286
|
-
const item = __classPrivateFieldGet(this, _DiffFile_splitHunksLines, "f")[key];
|
|
1287
|
-
if (!item.splitInfo)
|
|
1288
|
-
return;
|
|
1289
|
-
if (item.splitInfo.endHiddenIndex !== +key) {
|
|
1290
|
-
delete __classPrivateFieldGet(this, _DiffFile_splitHunksLines, "f")[key];
|
|
1291
|
-
__classPrivateFieldGet(this, _DiffFile_splitHunksLines, "f")[item.splitInfo.endHiddenIndex] = item;
|
|
1292
|
-
}
|
|
1293
|
-
});
|
|
1294
|
-
this.hasExpandSplitAll = false;
|
|
1295
|
-
}
|
|
1296
|
-
else {
|
|
1297
|
-
Object.values(__classPrivateFieldGet(this, _DiffFile_unifiedLines, "f") || {}).forEach((item) => {
|
|
1298
|
-
if (!item.isHidden && item._isHidden) {
|
|
1299
|
-
item.isHidden = item._isHidden;
|
|
1300
|
-
}
|
|
1301
|
-
});
|
|
1302
|
-
Object.values(__classPrivateFieldGet(this, _DiffFile_unifiedHunksLines, "f") || {}).forEach((item) => {
|
|
1303
|
-
if (!item.unifiedInfo)
|
|
1304
|
-
return;
|
|
1305
|
-
item.unifiedInfo = Object.assign(Object.assign({}, item.unifiedInfo), { oldStartIndex: item.unifiedInfo._oldStartIndex, oldLength: item.unifiedInfo._oldLength, newStartIndex: item.unifiedInfo._newStartIndex, newLength: item.unifiedInfo._newLength, startHiddenIndex: item.unifiedInfo._startHiddenIndex, endHiddenIndex: item.unifiedInfo._endHiddenIndex, plainText: item.unifiedInfo._plainText });
|
|
1306
|
-
});
|
|
1307
|
-
Object.keys(__classPrivateFieldGet(this, _DiffFile_unifiedHunksLines, "f") || {}).forEach((key) => {
|
|
1308
|
-
const item = __classPrivateFieldGet(this, _DiffFile_unifiedHunksLines, "f")[key];
|
|
1309
|
-
if (!item.unifiedInfo)
|
|
1310
|
-
return;
|
|
1311
|
-
if (item.unifiedInfo.endHiddenIndex !== +key) {
|
|
1312
|
-
delete __classPrivateFieldGet(this, _DiffFile_unifiedHunksLines, "f")[key];
|
|
1313
|
-
__classPrivateFieldGet(this, _DiffFile_unifiedHunksLines, "f")[item.unifiedInfo.endHiddenIndex] = item;
|
|
1314
|
-
}
|
|
1315
|
-
});
|
|
1316
|
-
this.hasExpandUnifiedAll = false;
|
|
1317
|
-
}
|
|
1318
|
-
this.notifyAll();
|
|
1319
|
-
};
|
|
1320
|
-
this.getOldSyntaxLine = (lineNumber) => {
|
|
1321
|
-
var _a;
|
|
1322
|
-
return (_a = __classPrivateFieldGet(this, _DiffFile_oldFileSyntaxLines, "f")) === null || _a === void 0 ? void 0 : _a[lineNumber];
|
|
1323
|
-
};
|
|
1324
|
-
this.getNewSyntaxLine = (lineNumber) => {
|
|
1325
|
-
var _a;
|
|
1326
|
-
return (_a = __classPrivateFieldGet(this, _DiffFile_newFileSyntaxLines, "f")) === null || _a === void 0 ? void 0 : _a[lineNumber];
|
|
1327
|
-
};
|
|
1328
|
-
this.subscribe = (listener) => {
|
|
1329
|
-
__classPrivateFieldGet(this, _DiffFile_listeners, "f").push(listener);
|
|
1330
|
-
return () => {
|
|
1331
|
-
__classPrivateFieldGet(this, _DiffFile_listeners, "f").filter((i) => i !== listener);
|
|
1332
|
-
};
|
|
1333
|
-
};
|
|
1334
|
-
this.notifyAll = (skipSyncExternal) => {
|
|
1335
|
-
var _a;
|
|
1336
|
-
__classPrivateFieldSet(this, _DiffFile_updateCount, (_a = __classPrivateFieldGet(this, _DiffFile_updateCount, "f"), _a++, _a));
|
|
1337
|
-
__classPrivateFieldGet(this, _DiffFile_listeners, "f").forEach((f) => {
|
|
1338
|
-
if (skipSyncExternal && f.isSyncExternal) {
|
|
1339
|
-
return;
|
|
1340
|
-
}
|
|
1341
|
-
f();
|
|
1342
|
-
});
|
|
1343
|
-
// support update from outside instance
|
|
1344
|
-
__classPrivateFieldGet(this, _DiffFile_clonedInstance, "f").forEach((_, instance) => {
|
|
1345
|
-
instance.notifyAll(true);
|
|
1346
|
-
});
|
|
1347
|
-
};
|
|
1348
|
-
this.getUpdateCount = () => __classPrivateFieldGet(this, _DiffFile_updateCount, "f");
|
|
1349
|
-
this.getExpandEnabled = () => !__classPrivateFieldGet(this, _DiffFile_composeByDiff, "f");
|
|
1350
|
-
this.getBundle = () => {
|
|
1351
|
-
// common
|
|
1352
|
-
const hasInitRaw = __classPrivateFieldGet(this, _DiffFile_hasInitRaw, "f");
|
|
1353
|
-
const hasInitSyntax = __classPrivateFieldGet(this, _DiffFile_hasInitSyntax, "f");
|
|
1354
|
-
const hasBuildSplit = __classPrivateFieldGet(this, _DiffFile_hasBuildSplit, "f");
|
|
1355
|
-
const hasBuildUnified = __classPrivateFieldGet(this, _DiffFile_hasBuildUnified, "f");
|
|
1356
|
-
const oldFileLines = __classPrivateFieldGet(this, _DiffFile_oldFileLines, "f");
|
|
1357
|
-
const oldFileDiffLines = __classPrivateFieldGet(this, _DiffFile_oldFileDiffLines, "f");
|
|
1358
|
-
const oldFileSyntaxLines = __classPrivateFieldGet(this, _DiffFile_oldFileSyntaxLines, "f");
|
|
1359
|
-
const oldFilePlaceholderLines = __classPrivateFieldGet(this, _DiffFile_oldFilePlaceholderLines, "f");
|
|
1360
|
-
const newFileLines = __classPrivateFieldGet(this, _DiffFile_newFileLines, "f");
|
|
1361
|
-
const newFileDiffLines = __classPrivateFieldGet(this, _DiffFile_newFileDiffLines, "f");
|
|
1362
|
-
const newFileSyntaxLines = __classPrivateFieldGet(this, _DiffFile_newFileSyntaxLines, "f");
|
|
1363
|
-
const newFilePlaceholderLines = __classPrivateFieldGet(this, _DiffFile_newFilePlaceholderLines, "f");
|
|
1364
|
-
const splitLineLength = this.splitLineLength;
|
|
1365
|
-
const unifiedLineLength = this.unifiedLineLength;
|
|
1366
|
-
const fileLineLength = this.fileLineLength;
|
|
1367
|
-
const composeByDiff = __classPrivateFieldGet(this, _DiffFile_composeByDiff, "f");
|
|
1368
|
-
const highlighterName = __classPrivateFieldGet(this, _DiffFile_highlighterName, "f");
|
|
1369
|
-
const hasSomeLineCollapsed = this.hasSomeLineCollapsed;
|
|
1370
|
-
// split
|
|
1371
|
-
const splitLeftLines = __classPrivateFieldGet(this, _DiffFile_splitLeftLines, "f");
|
|
1372
|
-
const splitRightLines = __classPrivateFieldGet(this, _DiffFile_splitRightLines, "f");
|
|
1373
|
-
const splitHunkLines = __classPrivateFieldGet(this, _DiffFile_splitHunksLines, "f");
|
|
1374
|
-
// unified
|
|
1375
|
-
const unifiedLines = __classPrivateFieldGet(this, _DiffFile_unifiedLines, "f");
|
|
1376
|
-
const unifiedHunkLines = __classPrivateFieldGet(this, _DiffFile_unifiedHunksLines, "f");
|
|
1377
|
-
const version = this._version_;
|
|
1378
|
-
return {
|
|
1379
|
-
hasInitRaw,
|
|
1380
|
-
hasInitSyntax,
|
|
1381
|
-
hasBuildSplit,
|
|
1382
|
-
hasBuildUnified,
|
|
1383
|
-
oldFileLines,
|
|
1384
|
-
oldFileDiffLines,
|
|
1385
|
-
oldFileSyntaxLines,
|
|
1386
|
-
oldFilePlaceholderLines,
|
|
1387
|
-
newFileLines,
|
|
1388
|
-
newFileDiffLines,
|
|
1389
|
-
newFileSyntaxLines,
|
|
1390
|
-
newFilePlaceholderLines,
|
|
1391
|
-
splitLineLength,
|
|
1392
|
-
unifiedLineLength,
|
|
1393
|
-
fileLineLength,
|
|
1394
|
-
splitLeftLines,
|
|
1395
|
-
splitRightLines,
|
|
1396
|
-
splitHunkLines,
|
|
1397
|
-
unifiedLines,
|
|
1398
|
-
unifiedHunkLines,
|
|
1399
|
-
highlighterName,
|
|
1400
|
-
composeByDiff,
|
|
1401
|
-
hasSomeLineCollapsed,
|
|
1402
|
-
version,
|
|
1403
|
-
isFullMerge: false,
|
|
1404
|
-
};
|
|
1405
|
-
};
|
|
1406
|
-
this.mergeBundle = (data) => {
|
|
1407
|
-
__classPrivateFieldSet(this, _DiffFile_hasInitRaw, data.hasInitRaw);
|
|
1408
|
-
__classPrivateFieldSet(this, _DiffFile_hasInitSyntax, data.hasInitSyntax);
|
|
1409
|
-
__classPrivateFieldSet(this, _DiffFile_hasBuildSplit, data.hasBuildSplit);
|
|
1410
|
-
__classPrivateFieldSet(this, _DiffFile_hasBuildUnified, data.hasBuildUnified);
|
|
1411
|
-
__classPrivateFieldSet(this, _DiffFile_composeByDiff, data.composeByDiff);
|
|
1412
|
-
__classPrivateFieldSet(this, _DiffFile_highlighterName, data.highlighterName);
|
|
1413
|
-
__classPrivateFieldSet(this, _DiffFile_oldFileLines, data.oldFileLines);
|
|
1414
|
-
__classPrivateFieldSet(this, _DiffFile_oldFileDiffLines, data.oldFileDiffLines);
|
|
1415
|
-
__classPrivateFieldSet(this, _DiffFile_oldFileSyntaxLines, data.oldFileSyntaxLines);
|
|
1416
|
-
__classPrivateFieldSet(this, _DiffFile_oldFilePlaceholderLines, data.oldFilePlaceholderLines);
|
|
1417
|
-
__classPrivateFieldSet(this, _DiffFile_newFileLines, data.newFileLines);
|
|
1418
|
-
__classPrivateFieldSet(this, _DiffFile_newFileDiffLines, data.newFileDiffLines);
|
|
1419
|
-
__classPrivateFieldSet(this, _DiffFile_newFileSyntaxLines, data.newFileSyntaxLines);
|
|
1420
|
-
__classPrivateFieldSet(this, _DiffFile_newFilePlaceholderLines, data.newFilePlaceholderLines);
|
|
1421
|
-
this.splitLineLength = data.splitLineLength;
|
|
1422
|
-
this.unifiedLineLength = data.unifiedLineLength;
|
|
1423
|
-
this.fileLineLength = data.fileLineLength;
|
|
1424
|
-
this.hasSomeLineCollapsed = data.hasSomeLineCollapsed;
|
|
1425
|
-
__classPrivateFieldSet(this, _DiffFile_splitLeftLines, data.splitLeftLines);
|
|
1426
|
-
__classPrivateFieldSet(this, _DiffFile_splitRightLines, data.splitRightLines);
|
|
1427
|
-
__classPrivateFieldSet(this, _DiffFile_splitHunksLines, data.splitHunkLines);
|
|
1428
|
-
__classPrivateFieldSet(this, _DiffFile_unifiedLines, data.unifiedLines);
|
|
1429
|
-
__classPrivateFieldSet(this, _DiffFile_unifiedHunksLines, data.unifiedHunkLines);
|
|
1430
|
-
// mark this instance as a merged instance
|
|
1431
|
-
__classPrivateFieldSet(this, _DiffFile_composeByMerge, true);
|
|
1432
|
-
if (this._version_ !== data.version) {
|
|
1433
|
-
console.error("the version of the `diffInstance` is not match, some error may happen!");
|
|
1434
|
-
}
|
|
1435
|
-
this.notifyAll();
|
|
1436
|
-
};
|
|
1437
|
-
this._getHighlighterName = () => __classPrivateFieldGet(this, _DiffFile_highlighterName, "f");
|
|
1438
|
-
this._getIsPureDiffRender = () => __classPrivateFieldGet(this, _DiffFile_composeByDiff, "f");
|
|
1439
|
-
this._addClonedInstance = (instance) => {
|
|
1440
|
-
const updateFunc = () => {
|
|
1441
|
-
this._notifyOthers(instance);
|
|
1442
|
-
};
|
|
1443
|
-
updateFunc.isSyncExternal = true;
|
|
1444
|
-
const unsubscribe = instance.subscribe(updateFunc);
|
|
1445
|
-
__classPrivateFieldGet(this, _DiffFile_clonedInstance, "f").set(instance, unsubscribe);
|
|
1446
|
-
};
|
|
1447
|
-
this._notifyOthers = (instance) => {
|
|
1448
|
-
__classPrivateFieldGet(this, _DiffFile_clonedInstance, "f").forEach((_, i) => {
|
|
1449
|
-
if (i !== instance) {
|
|
1450
|
-
i.notifyAll(true);
|
|
1451
|
-
}
|
|
1452
|
-
});
|
|
1453
|
-
};
|
|
1454
|
-
this._delClonedInstance = (instance) => {
|
|
1455
|
-
const unsubscribe = __classPrivateFieldGet(this, _DiffFile_clonedInstance, "f").get(instance);
|
|
1456
|
-
unsubscribe && unsubscribe();
|
|
1457
|
-
__classPrivateFieldGet(this, _DiffFile_clonedInstance, "f").delete(instance);
|
|
1458
|
-
};
|
|
1459
|
-
this._getFullBundle = () => {
|
|
1460
|
-
const bundle = this.getBundle();
|
|
1461
|
-
const oldFileResult = __classPrivateFieldGet(this, _DiffFile_oldFileResult, "f");
|
|
1462
|
-
const newFileResult = __classPrivateFieldGet(this, _DiffFile_newFileResult, "f");
|
|
1463
|
-
const diffLines = __classPrivateFieldGet(this, _DiffFile_diffLines, "f");
|
|
1464
|
-
const diffListResults = __classPrivateFieldGet(this, _DiffFile_diffListResults, "f");
|
|
1465
|
-
return Object.assign(Object.assign({}, bundle), { oldFileResult,
|
|
1466
|
-
newFileResult,
|
|
1467
|
-
diffLines,
|
|
1468
|
-
diffListResults,
|
|
1469
|
-
// get current instance is a fullMerge instance or not
|
|
1470
|
-
isFullMerge: __classPrivateFieldGet(this, _DiffFile_composeByMerge, "f") ? __classPrivateFieldGet(this, _DiffFile_composeByFullMerge, "f") : true });
|
|
1471
|
-
};
|
|
1472
|
-
this._mergeFullBundle = (data) => {
|
|
1473
|
-
this.mergeBundle(data);
|
|
1474
|
-
try {
|
|
1475
|
-
__classPrivateFieldSet(this, _DiffFile_oldFileResult, File.createInstance(data.oldFileResult), "f");
|
|
1476
|
-
__classPrivateFieldSet(this, _DiffFile_newFileResult, File.createInstance(data.newFileResult), "f");
|
|
1477
|
-
__classPrivateFieldSet(this, _DiffFile_diffLines, data.diffLines, "f");
|
|
1478
|
-
__classPrivateFieldSet(this, _DiffFile_diffListResults, data.diffListResults, "f");
|
|
1479
|
-
__classPrivateFieldSet(this, _DiffFile_composeByFullMerge, data.isFullMerge, "f");
|
|
1480
|
-
}
|
|
1481
|
-
catch (_a) {
|
|
1482
|
-
}
|
|
1483
|
-
};
|
|
1484
|
-
this._destroy = () => {
|
|
1485
|
-
this.clearId();
|
|
1486
|
-
__classPrivateFieldGet(this, _DiffFile_listeners, "f").splice(0, __classPrivateFieldGet(this, _DiffFile_listeners, "f").length);
|
|
1487
|
-
__classPrivateFieldGet(this, _DiffFile_clonedInstance, "f").forEach((v) => v());
|
|
1488
|
-
__classPrivateFieldGet(this, _DiffFile_clonedInstance, "f").clear();
|
|
1489
|
-
};
|
|
1490
|
-
this.clear = () => {
|
|
1491
|
-
this._destroy();
|
|
1492
|
-
__classPrivateFieldSet(this, _DiffFile_oldFileResult, null);
|
|
1493
|
-
__classPrivateFieldSet(this, _DiffFile_newFileResult, null);
|
|
1494
|
-
__classPrivateFieldSet(this, _DiffFile_diffLines, null);
|
|
1495
|
-
__classPrivateFieldSet(this, _DiffFile_diffListResults, null);
|
|
1496
|
-
__classPrivateFieldSet(this, _DiffFile_newFileDiffLines, null);
|
|
1497
|
-
__classPrivateFieldSet(this, _DiffFile_oldFileDiffLines, null);
|
|
1498
|
-
__classPrivateFieldSet(this, _DiffFile_newFileLines, null);
|
|
1499
|
-
__classPrivateFieldSet(this, _DiffFile_oldFileLines, null);
|
|
1500
|
-
__classPrivateFieldSet(this, _DiffFile_newFileSyntaxLines, null);
|
|
1501
|
-
__classPrivateFieldSet(this, _DiffFile_oldFileSyntaxLines, null);
|
|
1502
|
-
__classPrivateFieldSet(this, _DiffFile_splitHunksLines, null);
|
|
1503
|
-
__classPrivateFieldSet(this, _DiffFile_splitLeftLines, null);
|
|
1504
|
-
__classPrivateFieldSet(this, _DiffFile_splitRightLines, null);
|
|
1505
|
-
__classPrivateFieldSet(this, _DiffFile_unifiedHunksLines, null);
|
|
1506
|
-
__classPrivateFieldSet(this, _DiffFile_unifiedLines, null);
|
|
1507
|
-
};
|
|
1508
|
-
Object.defineProperty(this, "__v_skip", { value: true });
|
|
1509
|
-
let oldContent = _oldFileContent;
|
|
1510
|
-
let newContent = _newFileContent;
|
|
1511
|
-
const diffList = Array.from(new Set(_diffList));
|
|
1512
|
-
Object.defineProperties(this, {
|
|
1513
|
-
_oldFileName: { get: () => _oldFileName },
|
|
1514
|
-
_newFileName: { get: () => _newFileName },
|
|
1515
|
-
_oldFileLang: { get: () => getLang(_oldFileLang || _oldFileName || _newFileLang || _newFileName) || "txt" },
|
|
1516
|
-
_newFileLang: { get: () => getLang(_newFileLang || _newFileName || _oldFileLang || _oldFileName) || "txt" },
|
|
1517
|
-
_oldFileContent: {
|
|
1518
|
-
get: () => oldContent,
|
|
1519
|
-
set: (v) => (oldContent = v),
|
|
1520
|
-
},
|
|
1521
|
-
_newFileContent: {
|
|
1522
|
-
get: () => newContent,
|
|
1523
|
-
set: (v) => (newContent = v),
|
|
1524
|
-
},
|
|
1525
|
-
_diffList: { get: () => diffList },
|
|
1526
|
-
});
|
|
1527
|
-
this.initId();
|
|
1528
|
-
}
|
|
1529
|
-
initId() {
|
|
1530
|
-
let id = "--" + Math.random().toString().slice(2);
|
|
1531
|
-
while (idSet.has(id)) {
|
|
1532
|
-
id = "--" + Math.random().toString().slice(2);
|
|
1533
|
-
}
|
|
1534
|
-
idSet.add(id);
|
|
1535
|
-
__classPrivateFieldSet(this, _DiffFile_id, id);
|
|
1536
|
-
}
|
|
1537
|
-
getId() {
|
|
1538
|
-
return __classPrivateFieldGet(this, _DiffFile_id, "f");
|
|
1539
|
-
}
|
|
1540
|
-
clearId() {
|
|
1541
|
-
idSet.delete(__classPrivateFieldGet(this, _DiffFile_id, "f"));
|
|
1542
|
-
}
|
|
1543
|
-
initRaw() {
|
|
1544
|
-
if (__classPrivateFieldGet(this, _DiffFile_hasInitRaw, "f"))
|
|
1545
|
-
return;
|
|
1546
|
-
__classPrivateFieldGet(this, _DiffFile_instances, "m", _DiffFile_doDiff).call(this);
|
|
1547
|
-
__classPrivateFieldGet(this, _DiffFile_instances, "m", _DiffFile_composeDiff).call(this);
|
|
1548
|
-
__classPrivateFieldGet(this, _DiffFile_instances, "m", _DiffFile_doFile).call(this);
|
|
1549
|
-
__classPrivateFieldGet(this, _DiffFile_instances, "m", _DiffFile_composeRaw).call(this);
|
|
1550
|
-
__classPrivateFieldGet(this, _DiffFile_instances, "m", _DiffFile_composeFile).call(this);
|
|
1551
|
-
__classPrivateFieldSet(this, _DiffFile_hasInitRaw, true);
|
|
1552
|
-
}
|
|
1553
|
-
initSyntax({ registerHighlighter } = {}) {
|
|
1554
|
-
var _a, _b;
|
|
1555
|
-
if (__classPrivateFieldGet(this, _DiffFile_hasInitSyntax, "f"))
|
|
1556
|
-
return;
|
|
1557
|
-
if (__classPrivateFieldGet(this, _DiffFile_composeByMerge, "f") && !__classPrivateFieldGet(this, _DiffFile_composeByFullMerge, "f")) {
|
|
1558
|
-
console.error(`this instance can not do syntax because of the data missing, try to use '_getFullBundle' & '_mergeFullBundle' instead of 'getBundle' & 'mergeBundle'`);
|
|
1559
|
-
return;
|
|
1560
|
-
}
|
|
1561
|
-
__classPrivateFieldGet(this, _DiffFile_instances, "m", _DiffFile_composeSyntax).call(this, { registerHighlighter });
|
|
1562
|
-
__classPrivateFieldSet(this, _DiffFile_highlighterName, ((_a = __classPrivateFieldGet(this, _DiffFile_oldFileResult, "f")) === null || _a === void 0 ? void 0 : _a.highlighterName) || ((_b = __classPrivateFieldGet(this, _DiffFile_newFileResult, "f")) === null || _b === void 0 ? void 0 : _b.highlighterName) || __classPrivateFieldGet(this, _DiffFile_highlighterName, "f"));
|
|
1563
|
-
__classPrivateFieldSet(this, _DiffFile_hasInitSyntax, true);
|
|
1564
|
-
}
|
|
1565
|
-
init() {
|
|
1566
|
-
this.initRaw();
|
|
1567
|
-
this.initSyntax();
|
|
1568
|
-
}
|
|
1569
|
-
buildSplitDiffLines() {
|
|
1570
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
1571
|
-
if (__classPrivateFieldGet(this, _DiffFile_hasBuildSplit, "f"))
|
|
1572
|
-
return;
|
|
1573
|
-
let oldFileLineNumber = 1;
|
|
1574
|
-
let newFileLineNumber = 1;
|
|
1575
|
-
let prevIsHidden = false;
|
|
1576
|
-
let hideStart = Infinity;
|
|
1577
|
-
const maxOldFileLineNumber = ((_a = __classPrivateFieldGet(this, _DiffFile_oldFileResult, "f")) === null || _a === void 0 ? void 0 : _a.maxLineNumber) || 0;
|
|
1578
|
-
const maxNewFileLineNumber = ((_b = __classPrivateFieldGet(this, _DiffFile_newFileResult, "f")) === null || _b === void 0 ? void 0 : _b.maxLineNumber) || 0;
|
|
1579
|
-
while (oldFileLineNumber <= maxOldFileLineNumber || newFileLineNumber <= maxNewFileLineNumber) {
|
|
1580
|
-
const oldDiffLine = __classPrivateFieldGet(this, _DiffFile_instances, "m", _DiffFile_getOldDiffLine).call(this, oldFileLineNumber);
|
|
1581
|
-
const newDiffLine = __classPrivateFieldGet(this, _DiffFile_instances, "m", _DiffFile_getNewDiffLine).call(this, newFileLineNumber);
|
|
1582
|
-
const oldRawLine = __classPrivateFieldGet(this, _DiffFile_instances, "m", _DiffFile_getOldRawLine).call(this, oldFileLineNumber);
|
|
1583
|
-
const newRawLine = __classPrivateFieldGet(this, _DiffFile_instances, "m", _DiffFile_getNewRawLine).call(this, newFileLineNumber);
|
|
1584
|
-
const oldLineHasChange = oldDiffLine === null || oldDiffLine === void 0 ? void 0 : oldDiffLine.isIncludeableLine();
|
|
1585
|
-
const newLineHasChange = newDiffLine === null || newDiffLine === void 0 ? void 0 : newDiffLine.isIncludeableLine();
|
|
1586
|
-
const len = __classPrivateFieldGet(this, _DiffFile_splitRightLines, "f").length;
|
|
1587
|
-
const isHidden = !oldDiffLine && !newDiffLine;
|
|
1588
|
-
if (oldDiffLine && !newDiffLine) {
|
|
1589
|
-
if (oldDiffLine.newLineNumber && oldDiffLine.newLineNumber > newFileLineNumber) {
|
|
1590
|
-
newFileLineNumber++;
|
|
1591
|
-
continue;
|
|
1592
|
-
}
|
|
1593
|
-
if (oldDiffLine.newLineNumber === null || oldDiffLine.newLineNumber === undefined) {
|
|
1594
|
-
newFileLineNumber++;
|
|
1595
|
-
}
|
|
1596
|
-
}
|
|
1597
|
-
if (newDiffLine && !oldDiffLine) {
|
|
1598
|
-
if (newDiffLine.oldLineNumber && newDiffLine.oldLineNumber > oldFileLineNumber) {
|
|
1599
|
-
oldFileLineNumber++;
|
|
1600
|
-
continue;
|
|
1601
|
-
}
|
|
1602
|
-
if (newDiffLine.oldLineNumber === null || newDiffLine.oldLineNumber === undefined) {
|
|
1603
|
-
oldFileLineNumber++;
|
|
1604
|
-
}
|
|
1605
|
-
}
|
|
1606
|
-
if (!oldDiffLine && !oldRawLine && !newDiffLine && !newRawLine)
|
|
1607
|
-
break;
|
|
1608
|
-
if (!oldDiffLine && !newDiffLine) {
|
|
1609
|
-
if (((_c = __classPrivateFieldGet(this, _DiffFile_oldFilePlaceholderLines, "f")) === null || _c === void 0 ? void 0 : _c[oldFileLineNumber]) && ((_d = __classPrivateFieldGet(this, _DiffFile_newFilePlaceholderLines, "f")) === null || _d === void 0 ? void 0 : _d[newFileLineNumber])) {
|
|
1610
|
-
oldFileLineNumber++;
|
|
1611
|
-
newFileLineNumber++;
|
|
1612
|
-
continue;
|
|
1613
|
-
}
|
|
1614
|
-
if (!oldRawLine && ((_e = __classPrivateFieldGet(this, _DiffFile_newFilePlaceholderLines, "f")) === null || _e === void 0 ? void 0 : _e[newFileLineNumber])) {
|
|
1615
|
-
newFileLineNumber++;
|
|
1616
|
-
continue;
|
|
1617
|
-
}
|
|
1618
|
-
if (!newRawLine && ((_f = __classPrivateFieldGet(this, _DiffFile_oldFilePlaceholderLines, "f")) === null || _f === void 0 ? void 0 : _f[oldFileLineNumber])) {
|
|
1619
|
-
oldFileLineNumber++;
|
|
1620
|
-
continue;
|
|
1621
|
-
}
|
|
1622
|
-
}
|
|
1623
|
-
if ((oldLineHasChange && newLineHasChange) || (!oldLineHasChange && !newLineHasChange)) {
|
|
1624
|
-
__classPrivateFieldGet(this, _DiffFile_splitLeftLines, "f").push({
|
|
1625
|
-
lineNumber: oldFileLineNumber++,
|
|
1626
|
-
value: oldRawLine,
|
|
1627
|
-
diff: oldDiffLine,
|
|
1628
|
-
isHidden,
|
|
1629
|
-
_isHidden: isHidden,
|
|
1630
|
-
});
|
|
1631
|
-
__classPrivateFieldGet(this, _DiffFile_splitRightLines, "f").push({
|
|
1632
|
-
lineNumber: newFileLineNumber++,
|
|
1633
|
-
value: newRawLine,
|
|
1634
|
-
diff: newDiffLine,
|
|
1635
|
-
isHidden,
|
|
1636
|
-
_isHidden: isHidden,
|
|
1637
|
-
});
|
|
1638
|
-
}
|
|
1639
|
-
else if (oldLineHasChange) {
|
|
1640
|
-
__classPrivateFieldGet(this, _DiffFile_splitLeftLines, "f").push({
|
|
1641
|
-
lineNumber: oldFileLineNumber++,
|
|
1642
|
-
value: oldRawLine,
|
|
1643
|
-
diff: oldDiffLine,
|
|
1644
|
-
isHidden,
|
|
1645
|
-
_isHidden: isHidden,
|
|
1646
|
-
});
|
|
1647
|
-
__classPrivateFieldGet(this, _DiffFile_splitRightLines, "f").push({});
|
|
1648
|
-
}
|
|
1649
|
-
else if (newLineHasChange) {
|
|
1650
|
-
__classPrivateFieldGet(this, _DiffFile_splitLeftLines, "f").push({});
|
|
1651
|
-
__classPrivateFieldGet(this, _DiffFile_splitRightLines, "f").push({
|
|
1652
|
-
lineNumber: newFileLineNumber++,
|
|
1653
|
-
value: newRawLine,
|
|
1654
|
-
diff: newDiffLine,
|
|
1655
|
-
isHidden,
|
|
1656
|
-
_isHidden: isHidden,
|
|
1657
|
-
});
|
|
1658
|
-
}
|
|
1659
|
-
if (!prevIsHidden && isHidden) {
|
|
1660
|
-
hideStart = len;
|
|
1661
|
-
}
|
|
1662
|
-
if (isHidden) {
|
|
1663
|
-
this.hasSomeLineCollapsed = true;
|
|
1664
|
-
}
|
|
1665
|
-
prevIsHidden = isHidden;
|
|
1666
|
-
if (oldDiffLine && newDiffLine && !oldLineHasChange && !newLineHasChange) {
|
|
1667
|
-
const current = newDiffLine;
|
|
1668
|
-
const previous = newDiffLine.index ? (_g = __classPrivateFieldGet(this, _DiffFile_diffLines, "f")) === null || _g === void 0 ? void 0 : _g[current.index - 1] : undefined;
|
|
1669
|
-
if (previous && previous.type === exports.DiffLineType.Hunk) {
|
|
1670
|
-
const typedPrevious = previous;
|
|
1671
|
-
if (Number.isFinite(hideStart)) {
|
|
1672
|
-
typedPrevious.splitInfo = Object.assign(Object.assign({}, typedPrevious.hunkInfo), { startHiddenIndex: hideStart, endHiddenIndex: len, plainText: typedPrevious.text, _startHiddenIndex: hideStart, _endHiddenIndex: len, _plainText: typedPrevious.text });
|
|
1673
|
-
hideStart = Infinity;
|
|
1674
|
-
}
|
|
1675
|
-
__classPrivateFieldSet(this, _DiffFile_splitHunksLines, Object.assign(Object.assign({}, __classPrivateFieldGet(this, _DiffFile_splitHunksLines, "f")), { [len]: typedPrevious }));
|
|
1676
|
-
}
|
|
1677
|
-
}
|
|
1678
|
-
}
|
|
1679
|
-
// have last hunk
|
|
1680
|
-
if (Number.isFinite(hideStart)) {
|
|
1681
|
-
const lastDiff = new DiffLine("", exports.DiffLineType.Hunk, null, null, null);
|
|
1682
|
-
const lastHunk = lastDiff;
|
|
1683
|
-
lastHunk.isLast = true;
|
|
1684
|
-
lastHunk.splitInfo = {
|
|
1685
|
-
startHiddenIndex: hideStart,
|
|
1686
|
-
endHiddenIndex: __classPrivateFieldGet(this, _DiffFile_splitRightLines, "f").length,
|
|
1687
|
-
_startHiddenIndex: hideStart,
|
|
1688
|
-
_endHiddenIndex: __classPrivateFieldGet(this, _DiffFile_splitRightLines, "f").length,
|
|
1689
|
-
// just for placeholder
|
|
1690
|
-
plainText: "",
|
|
1691
|
-
oldStartIndex: 0,
|
|
1692
|
-
newStartIndex: 0,
|
|
1693
|
-
oldLength: 0,
|
|
1694
|
-
newLength: 0,
|
|
1695
|
-
_plainText: "",
|
|
1696
|
-
_oldStartIndex: 0,
|
|
1697
|
-
_newStartIndex: 0,
|
|
1698
|
-
_oldLength: 0,
|
|
1699
|
-
_newLength: 0,
|
|
1700
|
-
};
|
|
1701
|
-
__classPrivateFieldSet(this, _DiffFile_splitHunksLines, Object.assign(Object.assign({}, __classPrivateFieldGet(this, _DiffFile_splitHunksLines, "f")), { [__classPrivateFieldGet(this, _DiffFile_splitRightLines, "f").length]: lastHunk }));
|
|
1702
|
-
hideStart = Infinity;
|
|
1703
|
-
}
|
|
1704
|
-
this.splitLineLength = __classPrivateFieldGet(this, _DiffFile_splitRightLines, "f").length;
|
|
1705
|
-
__classPrivateFieldSet(this, _DiffFile_hasBuildSplit, true);
|
|
1706
|
-
this.notifyAll();
|
|
1707
|
-
}
|
|
1708
|
-
buildUnifiedDiffLines() {
|
|
1709
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
1710
|
-
if (__classPrivateFieldGet(this, _DiffFile_hasBuildUnified, "f"))
|
|
1711
|
-
return;
|
|
1712
|
-
let oldFileLineNumber = 1;
|
|
1713
|
-
let newFileLineNumber = 1;
|
|
1714
|
-
let prevIsHidden = false;
|
|
1715
|
-
let hideStart = Infinity;
|
|
1716
|
-
const maxOldFileLineNumber = ((_a = __classPrivateFieldGet(this, _DiffFile_oldFileResult, "f")) === null || _a === void 0 ? void 0 : _a.maxLineNumber) || 0;
|
|
1717
|
-
const maxNewFileLineNumber = ((_b = __classPrivateFieldGet(this, _DiffFile_newFileResult, "f")) === null || _b === void 0 ? void 0 : _b.maxLineNumber) || 0;
|
|
1718
|
-
while (oldFileLineNumber <= maxOldFileLineNumber || newFileLineNumber <= maxNewFileLineNumber) {
|
|
1719
|
-
const oldRawLine = __classPrivateFieldGet(this, _DiffFile_instances, "m", _DiffFile_getOldRawLine).call(this, oldFileLineNumber);
|
|
1720
|
-
const oldDiffLine = __classPrivateFieldGet(this, _DiffFile_instances, "m", _DiffFile_getOldDiffLine).call(this, oldFileLineNumber);
|
|
1721
|
-
const newRawLine = __classPrivateFieldGet(this, _DiffFile_instances, "m", _DiffFile_getNewRawLine).call(this, newFileLineNumber);
|
|
1722
|
-
const newDiffLine = __classPrivateFieldGet(this, _DiffFile_instances, "m", _DiffFile_getNewDiffLine).call(this, newFileLineNumber);
|
|
1723
|
-
const oldLineHasChange = oldDiffLine === null || oldDiffLine === void 0 ? void 0 : oldDiffLine.isIncludeableLine();
|
|
1724
|
-
const newLineHasChange = newDiffLine === null || newDiffLine === void 0 ? void 0 : newDiffLine.isIncludeableLine();
|
|
1725
|
-
const len = __classPrivateFieldGet(this, _DiffFile_unifiedLines, "f").length;
|
|
1726
|
-
const isHidden = !oldDiffLine && !newDiffLine;
|
|
1727
|
-
if (oldDiffLine && !newDiffLine) {
|
|
1728
|
-
if (oldDiffLine.newLineNumber && oldDiffLine.newLineNumber > newFileLineNumber) {
|
|
1729
|
-
newFileLineNumber++;
|
|
1730
|
-
continue;
|
|
1731
|
-
}
|
|
1732
|
-
if (oldDiffLine.newLineNumber === null || oldDiffLine.newLineNumber === undefined) {
|
|
1733
|
-
newFileLineNumber++;
|
|
1734
|
-
}
|
|
1735
|
-
}
|
|
1736
|
-
if (newDiffLine && !oldDiffLine) {
|
|
1737
|
-
if (newDiffLine.oldLineNumber && newDiffLine.oldLineNumber > oldFileLineNumber) {
|
|
1738
|
-
oldFileLineNumber++;
|
|
1739
|
-
continue;
|
|
1740
|
-
}
|
|
1741
|
-
if (newDiffLine.oldLineNumber === null || newDiffLine.oldLineNumber === undefined) {
|
|
1742
|
-
oldFileLineNumber++;
|
|
1743
|
-
}
|
|
1744
|
-
}
|
|
1745
|
-
if (!oldRawLine && !newRawLine && !newDiffLine && !oldDiffLine)
|
|
1746
|
-
break;
|
|
1747
|
-
if (!oldDiffLine && !newDiffLine) {
|
|
1748
|
-
if (((_c = __classPrivateFieldGet(this, _DiffFile_oldFilePlaceholderLines, "f")) === null || _c === void 0 ? void 0 : _c[oldFileLineNumber]) && ((_d = __classPrivateFieldGet(this, _DiffFile_newFilePlaceholderLines, "f")) === null || _d === void 0 ? void 0 : _d[newFileLineNumber])) {
|
|
1749
|
-
oldFileLineNumber++;
|
|
1750
|
-
newFileLineNumber++;
|
|
1751
|
-
continue;
|
|
1752
|
-
}
|
|
1753
|
-
if (!oldRawLine && ((_e = __classPrivateFieldGet(this, _DiffFile_newFilePlaceholderLines, "f")) === null || _e === void 0 ? void 0 : _e[newFileLineNumber])) {
|
|
1754
|
-
newFileLineNumber++;
|
|
1755
|
-
continue;
|
|
1756
|
-
}
|
|
1757
|
-
if (!newRawLine && ((_f = __classPrivateFieldGet(this, _DiffFile_oldFilePlaceholderLines, "f")) === null || _f === void 0 ? void 0 : _f[oldFileLineNumber])) {
|
|
1758
|
-
oldFileLineNumber++;
|
|
1759
|
-
continue;
|
|
1760
|
-
}
|
|
1761
|
-
}
|
|
1762
|
-
if (!oldLineHasChange && !newLineHasChange) {
|
|
1763
|
-
__classPrivateFieldGet(this, _DiffFile_unifiedLines, "f").push({
|
|
1764
|
-
oldLineNumber: oldFileLineNumber++,
|
|
1765
|
-
newLineNumber: newFileLineNumber++,
|
|
1766
|
-
value: newRawLine,
|
|
1767
|
-
diff: newDiffLine,
|
|
1768
|
-
isHidden,
|
|
1769
|
-
_isHidden: isHidden,
|
|
1770
|
-
});
|
|
1771
|
-
}
|
|
1772
|
-
else if (oldLineHasChange) {
|
|
1773
|
-
__classPrivateFieldGet(this, _DiffFile_unifiedLines, "f").push({
|
|
1774
|
-
oldLineNumber: oldFileLineNumber++,
|
|
1775
|
-
value: oldRawLine,
|
|
1776
|
-
diff: oldDiffLine,
|
|
1777
|
-
isHidden,
|
|
1778
|
-
_isHidden: isHidden,
|
|
1779
|
-
});
|
|
1780
|
-
}
|
|
1781
|
-
else if (newLineHasChange) {
|
|
1782
|
-
__classPrivateFieldGet(this, _DiffFile_unifiedLines, "f").push({
|
|
1783
|
-
newLineNumber: newFileLineNumber++,
|
|
1784
|
-
value: newRawLine,
|
|
1785
|
-
diff: newDiffLine,
|
|
1786
|
-
isHidden,
|
|
1787
|
-
_isHidden: isHidden,
|
|
1788
|
-
});
|
|
1789
|
-
}
|
|
1790
|
-
if (!prevIsHidden && isHidden) {
|
|
1791
|
-
hideStart = len;
|
|
1792
|
-
}
|
|
1793
|
-
if (isHidden) {
|
|
1794
|
-
this.hasSomeLineCollapsed = true;
|
|
1795
|
-
}
|
|
1796
|
-
prevIsHidden = isHidden;
|
|
1797
|
-
if (oldDiffLine && newDiffLine && !oldLineHasChange && !newLineHasChange) {
|
|
1798
|
-
const current = newDiffLine;
|
|
1799
|
-
const previous = current.index ? (_g = __classPrivateFieldGet(this, _DiffFile_diffLines, "f")) === null || _g === void 0 ? void 0 : _g[current.index - 1] : undefined;
|
|
1800
|
-
if (previous && previous.type === exports.DiffLineType.Hunk) {
|
|
1801
|
-
const typedPrevious = previous;
|
|
1802
|
-
if (Number.isFinite(hideStart)) {
|
|
1803
|
-
typedPrevious.unifiedInfo = Object.assign(Object.assign({}, typedPrevious.hunkInfo), { startHiddenIndex: hideStart, endHiddenIndex: len, plainText: typedPrevious.text, _startHiddenIndex: hideStart, _endHiddenIndex: len, _plainText: typedPrevious.text });
|
|
1804
|
-
hideStart = Infinity;
|
|
1805
|
-
}
|
|
1806
|
-
__classPrivateFieldSet(this, _DiffFile_unifiedHunksLines, Object.assign(Object.assign({}, __classPrivateFieldGet(this, _DiffFile_unifiedHunksLines, "f")), { [len]: typedPrevious }));
|
|
1807
|
-
}
|
|
1808
|
-
}
|
|
1809
|
-
}
|
|
1810
|
-
// have last hunk
|
|
1811
|
-
if (Number.isFinite(hideStart)) {
|
|
1812
|
-
const lastDiff = new DiffLine("", exports.DiffLineType.Hunk, null, null, null);
|
|
1813
|
-
const lastHunk = lastDiff;
|
|
1814
|
-
lastHunk.isLast = true;
|
|
1815
|
-
lastHunk.unifiedInfo = {
|
|
1816
|
-
startHiddenIndex: hideStart,
|
|
1817
|
-
endHiddenIndex: __classPrivateFieldGet(this, _DiffFile_unifiedLines, "f").length,
|
|
1818
|
-
_startHiddenIndex: hideStart,
|
|
1819
|
-
_endHiddenIndex: __classPrivateFieldGet(this, _DiffFile_unifiedLines, "f").length,
|
|
1820
|
-
// just for placeholder
|
|
1821
|
-
plainText: "",
|
|
1822
|
-
oldStartIndex: 0,
|
|
1823
|
-
newStartIndex: 0,
|
|
1824
|
-
oldLength: 0,
|
|
1825
|
-
newLength: 0,
|
|
1826
|
-
_plainText: "",
|
|
1827
|
-
_oldStartIndex: 0,
|
|
1828
|
-
_newStartIndex: 0,
|
|
1829
|
-
_oldLength: 0,
|
|
1830
|
-
_newLength: 0,
|
|
1831
|
-
};
|
|
1832
|
-
__classPrivateFieldSet(this, _DiffFile_unifiedHunksLines, Object.assign(Object.assign({}, __classPrivateFieldGet(this, _DiffFile_unifiedHunksLines, "f")), { [__classPrivateFieldGet(this, _DiffFile_unifiedLines, "f").length]: lastHunk }));
|
|
1833
|
-
hideStart = Infinity;
|
|
1834
|
-
}
|
|
1835
|
-
this.unifiedLineLength = __classPrivateFieldGet(this, _DiffFile_unifiedLines, "f").length;
|
|
1836
|
-
__classPrivateFieldSet(this, _DiffFile_hasBuildUnified, true);
|
|
1837
|
-
this.notifyAll();
|
|
1838
|
-
}
|
|
1839
|
-
}
|
|
1840
|
-
_DiffFile_oldFileResult = new WeakMap(), _DiffFile_newFileResult = new WeakMap(), _DiffFile_diffListResults = new WeakMap(), _DiffFile_diffLines = new WeakMap(), _DiffFile_oldFileDiffLines = new WeakMap(), _DiffFile_newFileDiffLines = new WeakMap(), _DiffFile_oldFileLines = new WeakMap(), _DiffFile_newFileLines = new WeakMap(), _DiffFile_oldFileSyntaxLines = new WeakMap(), _DiffFile_newFileSyntaxLines = new WeakMap(), _DiffFile_oldFilePlaceholderLines = new WeakMap(), _DiffFile_newFilePlaceholderLines = new WeakMap(), _DiffFile_splitLeftLines = new WeakMap(), _DiffFile_splitRightLines = new WeakMap(), _DiffFile_splitHunksLines = new WeakMap(), _DiffFile_unifiedLines = new WeakMap(), _DiffFile_unifiedHunksLines = new WeakMap(), _DiffFile_listeners = new WeakMap(), _DiffFile_hasInitRaw = new WeakMap(), _DiffFile_hasInitSyntax = new WeakMap(), _DiffFile_hasBuildSplit = new WeakMap(), _DiffFile_hasBuildUnified = new WeakMap(), _DiffFile_updateCount = new WeakMap(), _DiffFile_composeByDiff = new WeakMap(), _DiffFile_composeByMerge = new WeakMap(), _DiffFile_composeByFullMerge = new WeakMap(), _DiffFile_highlighterName = new WeakMap(), _DiffFile_id = new WeakMap(), _DiffFile_clonedInstance = new WeakMap(), _DiffFile_instances = new WeakSet(), _DiffFile_doDiff = function _DiffFile_doDiff() {
|
|
1841
|
-
if (!this._diffList)
|
|
1842
|
-
return;
|
|
1843
|
-
__classPrivateFieldSet(this, _DiffFile_diffListResults, this._diffList.map((s) => parseInstance.parse(s)));
|
|
1844
|
-
}, _DiffFile_doFile = function _DiffFile_doFile() {
|
|
1845
|
-
if (!this._oldFileContent && !this._newFileContent)
|
|
1846
|
-
return;
|
|
1847
|
-
if (this._oldFileContent) {
|
|
1848
|
-
__classPrivateFieldSet(this, _DiffFile_oldFileResult, getFile(this._oldFileContent, this._oldFileLang, this._oldFileName));
|
|
1849
|
-
this.fileLineLength = Math.max(this.fileLineLength, __classPrivateFieldGet(this, _DiffFile_oldFileResult, "f").maxLineNumber);
|
|
1850
|
-
}
|
|
1851
|
-
if (this._newFileContent) {
|
|
1852
|
-
__classPrivateFieldSet(this, _DiffFile_newFileResult, getFile(this._newFileContent, this._newFileLang, this._newFileName));
|
|
1853
|
-
this.fileLineLength = Math.max(this.fileLineLength, __classPrivateFieldGet(this, _DiffFile_newFileResult, "f").maxLineNumber);
|
|
1854
|
-
}
|
|
1855
|
-
}, _DiffFile_composeRaw = function _DiffFile_composeRaw() {
|
|
1856
|
-
var _a, _b, _c, _d;
|
|
1857
|
-
(_a = __classPrivateFieldGet(this, _DiffFile_oldFileResult, "f")) === null || _a === void 0 ? void 0 : _a.doRaw();
|
|
1858
|
-
__classPrivateFieldSet(this, _DiffFile_oldFileLines, (_b = __classPrivateFieldGet(this, _DiffFile_oldFileResult, "f")) === null || _b === void 0 ? void 0 : _b.rawFile);
|
|
1859
|
-
(_c = __classPrivateFieldGet(this, _DiffFile_newFileResult, "f")) === null || _c === void 0 ? void 0 : _c.doRaw();
|
|
1860
|
-
__classPrivateFieldSet(this, _DiffFile_newFileLines, (_d = __classPrivateFieldGet(this, _DiffFile_newFileResult, "f")) === null || _d === void 0 ? void 0 : _d.rawFile);
|
|
1861
|
-
}, _DiffFile_composeFile = function _DiffFile_composeFile() {
|
|
1862
|
-
if (this._oldFileContent && this._newFileContent)
|
|
1863
|
-
return;
|
|
1864
|
-
const oldFilePlaceholderLines = {};
|
|
1865
|
-
const newFilePlaceholderLines = {};
|
|
1866
|
-
// all of the file content not exist, try to use diff result to compose
|
|
1867
|
-
if (!this._oldFileContent && !this._newFileContent) {
|
|
1868
|
-
let newLineNumber = 1;
|
|
1869
|
-
let oldLineNumber = 1;
|
|
1870
|
-
let oldFileContent = "";
|
|
1871
|
-
let newFileContent = "";
|
|
1872
|
-
let hasSymbolChanged = false;
|
|
1873
|
-
while (oldLineNumber <= this.diffLineLength || newLineNumber <= this.diffLineLength) {
|
|
1874
|
-
const oldIndex = oldLineNumber++;
|
|
1875
|
-
const newIndex = newLineNumber++;
|
|
1876
|
-
const oldDiffLine = __classPrivateFieldGet(this, _DiffFile_instances, "m", _DiffFile_getOldDiffLine).call(this, oldIndex);
|
|
1877
|
-
const newDiffLine = __classPrivateFieldGet(this, _DiffFile_instances, "m", _DiffFile_getNewDiffLine).call(this, newIndex);
|
|
1878
|
-
if (oldDiffLine) {
|
|
1879
|
-
oldFileContent += oldDiffLine.text;
|
|
1880
|
-
}
|
|
1881
|
-
else {
|
|
1882
|
-
// empty line for placeholder
|
|
1883
|
-
oldFileContent += "\n";
|
|
1884
|
-
oldFilePlaceholderLines[oldIndex] = true;
|
|
1885
|
-
}
|
|
1886
|
-
if (newDiffLine) {
|
|
1887
|
-
newFileContent += newDiffLine.text;
|
|
1888
|
-
}
|
|
1889
|
-
else {
|
|
1890
|
-
// empty line for placeholder
|
|
1891
|
-
newFileContent += "\n";
|
|
1892
|
-
newFilePlaceholderLines[newIndex] = true;
|
|
1893
|
-
}
|
|
1894
|
-
if (!hasSymbolChanged && oldDiffLine && newDiffLine) {
|
|
1895
|
-
hasSymbolChanged = hasSymbolChanged || oldDiffLine.noTrailingNewLine !== newDiffLine.noTrailingNewLine;
|
|
1896
|
-
}
|
|
1897
|
-
}
|
|
1898
|
-
if (!hasSymbolChanged && oldFileContent === newFileContent)
|
|
1899
|
-
return;
|
|
1900
|
-
this._oldFileContent = oldFileContent;
|
|
1901
|
-
this._newFileContent = newFileContent;
|
|
1902
|
-
__classPrivateFieldSet(this, _DiffFile_oldFileResult, getFile(this._oldFileContent, this._oldFileLang, this._oldFileName));
|
|
1903
|
-
__classPrivateFieldSet(this, _DiffFile_newFileResult, getFile(this._newFileContent, this._newFileLang, this._newFileName));
|
|
1904
|
-
__classPrivateFieldSet(this, _DiffFile_oldFilePlaceholderLines, oldFilePlaceholderLines);
|
|
1905
|
-
__classPrivateFieldSet(this, _DiffFile_newFilePlaceholderLines, newFilePlaceholderLines);
|
|
1906
|
-
this.fileLineLength = Math.max(this.fileLineLength, __classPrivateFieldGet(this, _DiffFile_oldFileResult, "f").maxLineNumber, __classPrivateFieldGet(this, _DiffFile_newFileResult, "f").maxLineNumber);
|
|
1907
|
-
// all of the file just compose by diff, so we can not do the expand action
|
|
1908
|
-
__classPrivateFieldSet(this, _DiffFile_composeByDiff, true);
|
|
1909
|
-
}
|
|
1910
|
-
else if (__classPrivateFieldGet(this, _DiffFile_oldFileResult, "f")) {
|
|
1911
|
-
let newLineNumber = 1;
|
|
1912
|
-
let oldLineNumber = 1;
|
|
1913
|
-
let newFileContent = "";
|
|
1914
|
-
let hasSymbolChanged = false;
|
|
1915
|
-
while (oldLineNumber <= __classPrivateFieldGet(this, _DiffFile_oldFileResult, "f").maxLineNumber) {
|
|
1916
|
-
const newDiffLine = __classPrivateFieldGet(this, _DiffFile_instances, "m", _DiffFile_getNewDiffLine).call(this, newLineNumber++);
|
|
1917
|
-
const oldDiffLine = __classPrivateFieldGet(this, _DiffFile_instances, "m", _DiffFile_getOldDiffLine).call(this, oldLineNumber);
|
|
1918
|
-
if (newDiffLine) {
|
|
1919
|
-
newFileContent += newDiffLine.text;
|
|
1920
|
-
oldLineNumber = newDiffLine.oldLineNumber ? newDiffLine.oldLineNumber + 1 : oldLineNumber;
|
|
1921
|
-
}
|
|
1922
|
-
else {
|
|
1923
|
-
if (!oldDiffLine) {
|
|
1924
|
-
newFileContent += __classPrivateFieldGet(this, _DiffFile_instances, "m", _DiffFile_getOldRawLine).call(this, oldLineNumber);
|
|
1925
|
-
}
|
|
1926
|
-
oldLineNumber++;
|
|
1927
|
-
}
|
|
1928
|
-
if (!hasSymbolChanged && newDiffLine && oldDiffLine) {
|
|
1929
|
-
hasSymbolChanged = hasSymbolChanged || newDiffLine.noTrailingNewLine !== oldDiffLine.noTrailingNewLine;
|
|
1930
|
-
}
|
|
1931
|
-
}
|
|
1932
|
-
if (!hasSymbolChanged && newFileContent === this._oldFileContent)
|
|
1933
|
-
return;
|
|
1934
|
-
this._newFileContent = newFileContent;
|
|
1935
|
-
__classPrivateFieldSet(this, _DiffFile_newFileResult, getFile(this._newFileContent, this._newFileLang, this._newFileName));
|
|
1936
|
-
this.fileLineLength = Math.max(this.fileLineLength, __classPrivateFieldGet(this, _DiffFile_newFileResult, "f").maxLineNumber);
|
|
1937
|
-
}
|
|
1938
|
-
else if (__classPrivateFieldGet(this, _DiffFile_newFileResult, "f")) {
|
|
1939
|
-
let oldLineNumber = 1;
|
|
1940
|
-
let newLineNumber = 1;
|
|
1941
|
-
let oldFileContent = "";
|
|
1942
|
-
let hasSymbolChanged = false;
|
|
1943
|
-
while (newLineNumber <= __classPrivateFieldGet(this, _DiffFile_newFileResult, "f").maxLineNumber) {
|
|
1944
|
-
const oldDiffLine = __classPrivateFieldGet(this, _DiffFile_instances, "m", _DiffFile_getOldDiffLine).call(this, oldLineNumber++);
|
|
1945
|
-
const newDiffLine = __classPrivateFieldGet(this, _DiffFile_instances, "m", _DiffFile_getNewDiffLine).call(this, newLineNumber);
|
|
1946
|
-
if (oldDiffLine) {
|
|
1947
|
-
oldFileContent += oldDiffLine.text;
|
|
1948
|
-
newLineNumber = oldDiffLine.newLineNumber ? oldDiffLine.newLineNumber + 1 : newLineNumber;
|
|
1949
|
-
}
|
|
1950
|
-
else {
|
|
1951
|
-
if (!newDiffLine) {
|
|
1952
|
-
oldFileContent += __classPrivateFieldGet(this, _DiffFile_instances, "m", _DiffFile_getNewRawLine).call(this, newLineNumber);
|
|
1953
|
-
}
|
|
1954
|
-
newLineNumber++;
|
|
1955
|
-
}
|
|
1956
|
-
if (!hasSymbolChanged && newDiffLine && oldDiffLine) {
|
|
1957
|
-
hasSymbolChanged = hasSymbolChanged || newDiffLine.noTrailingNewLine !== oldDiffLine.noTrailingNewLine;
|
|
1958
|
-
}
|
|
1959
|
-
}
|
|
1960
|
-
if (!hasSymbolChanged && oldFileContent === this._newFileContent)
|
|
1961
|
-
return;
|
|
1962
|
-
this._oldFileContent = oldFileContent;
|
|
1963
|
-
__classPrivateFieldSet(this, _DiffFile_oldFileResult, getFile(this._oldFileContent, this._oldFileLang, this._oldFileName));
|
|
1964
|
-
this.fileLineLength = Math.max(this.fileLineLength, __classPrivateFieldGet(this, _DiffFile_oldFileResult, "f").maxLineNumber);
|
|
1965
|
-
}
|
|
1966
|
-
__classPrivateFieldGet(this, _DiffFile_instances, "m", _DiffFile_composeRaw).call(this);
|
|
1967
|
-
}, _DiffFile_composeDiff = function _DiffFile_composeDiff() {
|
|
1968
|
-
var _a;
|
|
1969
|
-
if (!((_a = __classPrivateFieldGet(this, _DiffFile_diffListResults, "f")) === null || _a === void 0 ? void 0 : _a.length))
|
|
1970
|
-
return;
|
|
1971
|
-
__classPrivateFieldGet(this, _DiffFile_diffListResults, "f").forEach((item) => {
|
|
1972
|
-
const hunks = item.hunks;
|
|
1973
|
-
hunks.forEach((hunk) => {
|
|
1974
|
-
let additions = [];
|
|
1975
|
-
let deletions = [];
|
|
1976
|
-
hunk.lines.forEach((line) => {
|
|
1977
|
-
if (line.type === exports.DiffLineType.Add) {
|
|
1978
|
-
additions.push(line);
|
|
1979
|
-
}
|
|
1980
|
-
else if (line.type === exports.DiffLineType.Delete) {
|
|
1981
|
-
deletions.push(line);
|
|
1982
|
-
}
|
|
1983
|
-
else {
|
|
1984
|
-
getDiffRange(additions, deletions);
|
|
1985
|
-
additions = [];
|
|
1986
|
-
deletions = [];
|
|
1987
|
-
}
|
|
1988
|
-
});
|
|
1989
|
-
getDiffRange(additions, deletions);
|
|
1990
|
-
});
|
|
1991
|
-
});
|
|
1992
|
-
__classPrivateFieldSet(this, _DiffFile_diffLines, []);
|
|
1993
|
-
const tmp = [];
|
|
1994
|
-
__classPrivateFieldGet(this, _DiffFile_diffListResults, "f").forEach((item) => {
|
|
1995
|
-
item.hunks.forEach((_item) => {
|
|
1996
|
-
tmp.push(..._item.lines);
|
|
1997
|
-
});
|
|
1998
|
-
});
|
|
1999
|
-
__classPrivateFieldSet(this, _DiffFile_diffLines, tmp.map((i, index) => {
|
|
2000
|
-
var _a;
|
|
2001
|
-
const typedI = i;
|
|
2002
|
-
typedI.index = index;
|
|
2003
|
-
if (typedI.type === exports.DiffLineType.Hunk) {
|
|
2004
|
-
const numInfo = (_a = typedI.text.split("@@")) === null || _a === void 0 ? void 0 : _a[1].split(" ").filter(Boolean);
|
|
2005
|
-
const oldNumInfo = (numInfo === null || numInfo === void 0 ? void 0 : numInfo[0]) || "";
|
|
2006
|
-
const newNumInfo = (numInfo === null || numInfo === void 0 ? void 0 : numInfo[1]) || "";
|
|
2007
|
-
const [oldNumStartIndex, oldNumLength] = oldNumInfo.split(",");
|
|
2008
|
-
const [newNumStartIndex, newNumLength] = newNumInfo.split(",");
|
|
2009
|
-
const typedTypeI = typedI;
|
|
2010
|
-
typedTypeI.hunkInfo = {
|
|
2011
|
-
oldStartIndex: -Number(oldNumStartIndex),
|
|
2012
|
-
oldLength: Number(oldNumLength),
|
|
2013
|
-
newStartIndex: +Number(newNumStartIndex),
|
|
2014
|
-
newLength: Number(newNumLength),
|
|
2015
|
-
_oldStartIndex: -Number(oldNumStartIndex),
|
|
2016
|
-
_oldLength: Number(oldNumLength),
|
|
2017
|
-
_newStartIndex: +Number(newNumStartIndex),
|
|
2018
|
-
_newLength: Number(newNumLength),
|
|
2019
|
-
};
|
|
2020
|
-
}
|
|
2021
|
-
return typedI;
|
|
2022
|
-
}));
|
|
2023
|
-
// this.#diffLines = this.#diffListResults
|
|
2024
|
-
// .reduce<DiffLine[]>((p, c) => p.concat(...c.hunks.reduce<DiffLine[]>((_p, _c) => _p.concat(..._c.lines), [])), [])
|
|
2025
|
-
// .map<DiffLineItem>((i, index) => {
|
|
2026
|
-
// const typedI = i as DiffLineItem;
|
|
2027
|
-
// typedI.index = index;
|
|
2028
|
-
// if (typedI.type === DiffLineType.Hunk) {
|
|
2029
|
-
// const numInfo = typedI.text.split("@@")?.[1].split(" ").filter(Boolean);
|
|
2030
|
-
// const oldNumInfo = numInfo?.[0] || "";
|
|
2031
|
-
// const newNumInfo = numInfo?.[1] || "";
|
|
2032
|
-
// const [oldNumStartIndex, oldNumLength] = oldNumInfo.split(",");
|
|
2033
|
-
// const [newNumStartIndex, newNumLength] = newNumInfo.split(",");
|
|
2034
|
-
// const typedTypeI = typedI as DiffHunkItem;
|
|
2035
|
-
// typedTypeI.hunkInfo = {
|
|
2036
|
-
// oldStartIndex: -Number(oldNumStartIndex),
|
|
2037
|
-
// oldLength: Number(oldNumLength),
|
|
2038
|
-
// newStartIndex: +Number(newNumStartIndex),
|
|
2039
|
-
// newLength: Number(newNumLength),
|
|
2040
|
-
// };
|
|
2041
|
-
// }
|
|
2042
|
-
// return typedI;
|
|
2043
|
-
// });
|
|
2044
|
-
__classPrivateFieldSet(this, _DiffFile_oldFileDiffLines, {});
|
|
2045
|
-
__classPrivateFieldGet(this, _DiffFile_diffLines, "f").forEach((item) => {
|
|
2046
|
-
if (item.oldLineNumber) {
|
|
2047
|
-
this.diffLineLength = Math.max(this.diffLineLength, item.oldLineNumber);
|
|
2048
|
-
__classPrivateFieldGet(this, _DiffFile_oldFileDiffLines, "f")[item.oldLineNumber] = item;
|
|
2049
|
-
}
|
|
2050
|
-
});
|
|
2051
|
-
__classPrivateFieldSet(this, _DiffFile_newFileDiffLines, {});
|
|
2052
|
-
__classPrivateFieldGet(this, _DiffFile_diffLines, "f").forEach((item) => {
|
|
2053
|
-
if (item.newLineNumber) {
|
|
2054
|
-
this.diffLineLength = Math.max(this.diffLineLength, item.newLineNumber);
|
|
2055
|
-
__classPrivateFieldGet(this, _DiffFile_newFileDiffLines, "f")[item.newLineNumber] = item;
|
|
2056
|
-
}
|
|
2057
|
-
});
|
|
2058
|
-
}, _DiffFile_composeSyntax = function _DiffFile_composeSyntax({ registerHighlighter }) {
|
|
2059
|
-
var _a, _b, _c, _d;
|
|
2060
|
-
(_a = __classPrivateFieldGet(this, _DiffFile_oldFileResult, "f")) === null || _a === void 0 ? void 0 : _a.doSyntax({ registerHighlighter });
|
|
2061
|
-
__classPrivateFieldSet(this, _DiffFile_oldFileSyntaxLines, (_b = __classPrivateFieldGet(this, _DiffFile_oldFileResult, "f")) === null || _b === void 0 ? void 0 : _b.syntaxFile);
|
|
2062
|
-
(_c = __classPrivateFieldGet(this, _DiffFile_newFileResult, "f")) === null || _c === void 0 ? void 0 : _c.doSyntax({ registerHighlighter });
|
|
2063
|
-
__classPrivateFieldSet(this, _DiffFile_newFileSyntaxLines, (_d = __classPrivateFieldGet(this, _DiffFile_newFileResult, "f")) === null || _d === void 0 ? void 0 : _d.syntaxFile);
|
|
2064
|
-
}, _DiffFile_getOldDiffLine = function _DiffFile_getOldDiffLine(lineNumber) {
|
|
2065
|
-
var _a;
|
|
2066
|
-
if (!lineNumber)
|
|
2067
|
-
return;
|
|
2068
|
-
return (_a = __classPrivateFieldGet(this, _DiffFile_oldFileDiffLines, "f")) === null || _a === void 0 ? void 0 : _a[lineNumber];
|
|
2069
|
-
}, _DiffFile_getNewDiffLine = function _DiffFile_getNewDiffLine(lineNumber) {
|
|
2070
|
-
var _a;
|
|
2071
|
-
if (!lineNumber)
|
|
2072
|
-
return;
|
|
2073
|
-
return (_a = __classPrivateFieldGet(this, _DiffFile_newFileDiffLines, "f")) === null || _a === void 0 ? void 0 : _a[lineNumber];
|
|
2074
|
-
}, _DiffFile_getOldRawLine = function _DiffFile_getOldRawLine(lineNumber) {
|
|
2075
|
-
var _a;
|
|
2076
|
-
return (_a = __classPrivateFieldGet(this, _DiffFile_oldFileLines, "f")) === null || _a === void 0 ? void 0 : _a[lineNumber];
|
|
2077
|
-
}, _DiffFile_getNewRawLine = function _DiffFile_getNewRawLine(lineNumber) {
|
|
2078
|
-
var _a;
|
|
2079
|
-
return (_a = __classPrivateFieldGet(this, _DiffFile_newFileLines, "f")) === null || _a === void 0 ? void 0 : _a[lineNumber];
|
|
2080
|
-
};
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
n.default = e;
|
|
23
|
+
return Object.freeze(n);
|
|
24
|
+
}
|
|
2081
25
|
|
|
2082
|
-
|
|
2083
|
-
(function (DiffFileLineType) {
|
|
2084
|
-
DiffFileLineType[DiffFileLineType["hunk"] = 1] = "hunk";
|
|
2085
|
-
DiffFileLineType[DiffFileLineType["content"] = 2] = "content";
|
|
2086
|
-
DiffFileLineType[DiffFileLineType["widget"] = 3] = "widget";
|
|
2087
|
-
DiffFileLineType[DiffFileLineType["extend"] = 4] = "extend";
|
|
2088
|
-
})(exports.DiffFileLineType || (exports.DiffFileLineType = {}));
|
|
2089
|
-
const getSplitLines = (diffFile, options) => {
|
|
2090
|
-
const splitLineLength = diffFile.splitLineLength;
|
|
2091
|
-
const splitLines = [];
|
|
2092
|
-
numIterator(splitLineLength, (index) => {
|
|
2093
|
-
var _a, _b;
|
|
2094
|
-
const hunkLine = diffFile.getSplitHunkLine(index);
|
|
2095
|
-
const splitLeftLine = diffFile.getSplitLeftLine(index);
|
|
2096
|
-
const splitRightLine = diffFile.getSplitRightLine(index);
|
|
2097
|
-
const widgetLine = (options === null || options === void 0 ? void 0 : options.hasRenderWidget) && ((_a = options.widgetData) === null || _a === void 0 ? void 0 : _a[index + 1]);
|
|
2098
|
-
const extendLine = (options === null || options === void 0 ? void 0 : options.hasRenderExtend) && ((_b = options.extendData) === null || _b === void 0 ? void 0 : _b[index + 1]);
|
|
2099
|
-
hunkLine &&
|
|
2100
|
-
hunkLine.splitInfo &&
|
|
2101
|
-
hunkLine.splitInfo.startHiddenIndex < hunkLine.splitInfo.endHiddenIndex &&
|
|
2102
|
-
splitLines.push({ type: exports.DiffFileLineType.hunk, index, lineNumber: index + 1, hunkLine: hunkLine });
|
|
2103
|
-
hunkLine &&
|
|
2104
|
-
!hunkLine.splitInfo &&
|
|
2105
|
-
!hunkLine.unifiedInfo &&
|
|
2106
|
-
hunkLine.type === exports.DiffLineType.Hunk &&
|
|
2107
|
-
splitLines.push({ type: exports.DiffFileLineType.hunk, index, lineNumber: index + 1, hunkLine: hunkLine });
|
|
2108
|
-
!(splitLeftLine === null || splitLeftLine === void 0 ? void 0 : splitLeftLine.isHidden) &&
|
|
2109
|
-
!(splitRightLine === null || splitRightLine === void 0 ? void 0 : splitRightLine.isHidden) &&
|
|
2110
|
-
splitLines.push({
|
|
2111
|
-
type: exports.DiffFileLineType.content,
|
|
2112
|
-
index,
|
|
2113
|
-
lineNumber: index + 1,
|
|
2114
|
-
splitLine: { left: splitLeftLine, right: splitRightLine },
|
|
2115
|
-
});
|
|
2116
|
-
widgetLine &&
|
|
2117
|
-
splitLines.push({ type: exports.DiffFileLineType.widget, index, lineNumber: index + 1, widgetLine: widgetLine });
|
|
2118
|
-
extendLine &&
|
|
2119
|
-
splitLines.push({ type: exports.DiffFileLineType.extend, index, lineNumber: index + 1, extendLine: extendLine });
|
|
2120
|
-
});
|
|
2121
|
-
return splitLines;
|
|
2122
|
-
};
|
|
2123
|
-
const getSplitContentLines = (diffFile) => {
|
|
2124
|
-
const lines = getSplitLines(diffFile, {});
|
|
2125
|
-
return lines.filter((line) => line.type === exports.DiffFileLineType.content);
|
|
2126
|
-
};
|
|
2127
|
-
const getUnifiedLines = (diffFile, options) => {
|
|
2128
|
-
const unifiedLineLength = diffFile.unifiedLineLength;
|
|
2129
|
-
const unifiedLines = [];
|
|
2130
|
-
numIterator(unifiedLineLength, (index) => {
|
|
2131
|
-
var _a, _b;
|
|
2132
|
-
const hunkLine = diffFile.getUnifiedHunkLine(index);
|
|
2133
|
-
const unifiedLine = diffFile.getUnifiedLine(index);
|
|
2134
|
-
const widgetLine = (options === null || options === void 0 ? void 0 : options.hasRenderWidget) && ((_a = options.widgetData) === null || _a === void 0 ? void 0 : _a[index + 1]);
|
|
2135
|
-
const extendLine = (options === null || options === void 0 ? void 0 : options.hasRenderExtend) && ((_b = options.extendData) === null || _b === void 0 ? void 0 : _b[index + 1]);
|
|
2136
|
-
hunkLine &&
|
|
2137
|
-
hunkLine.unifiedInfo &&
|
|
2138
|
-
hunkLine.unifiedInfo.startHiddenIndex < hunkLine.unifiedInfo.endHiddenIndex &&
|
|
2139
|
-
unifiedLines.push({ type: exports.DiffFileLineType.hunk, index, lineNumber: index + 1, hunkLine: hunkLine });
|
|
2140
|
-
hunkLine &&
|
|
2141
|
-
!hunkLine.splitInfo &&
|
|
2142
|
-
!hunkLine.unifiedInfo &&
|
|
2143
|
-
hunkLine.type === exports.DiffLineType.Hunk &&
|
|
2144
|
-
unifiedLines.push({ type: exports.DiffFileLineType.hunk, index, lineNumber: index + 1, hunkLine: hunkLine });
|
|
2145
|
-
!unifiedLine.isHidden &&
|
|
2146
|
-
unifiedLines.push({ type: exports.DiffFileLineType.content, index, lineNumber: index + 1, unifiedLine: unifiedLine });
|
|
2147
|
-
widgetLine &&
|
|
2148
|
-
unifiedLines.push({ type: exports.DiffFileLineType.widget, index, lineNumber: index + 1, widgetLine: widgetLine });
|
|
2149
|
-
extendLine &&
|
|
2150
|
-
unifiedLines.push({ type: exports.DiffFileLineType.extend, index, lineNumber: index + 1, extendLine: extendLine });
|
|
2151
|
-
});
|
|
2152
|
-
return unifiedLines;
|
|
2153
|
-
};
|
|
2154
|
-
const getUnifiedContentLine = (diffFile) => {
|
|
2155
|
-
const lines = getUnifiedLines(diffFile, {});
|
|
2156
|
-
return lines.filter((line) => line.type === exports.DiffFileLineType.content);
|
|
2157
|
-
};
|
|
26
|
+
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
2158
27
|
|
|
2159
|
-
|
|
28
|
+
/******************************************************************************
|
|
29
|
+
Copyright (c) Microsoft Corporation.
|
|
30
|
+
|
|
31
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
32
|
+
purpose with or without fee is hereby granted.
|
|
33
|
+
|
|
34
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
35
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
36
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
37
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
38
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
39
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
40
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
41
|
+
***************************************************************************** */
|
|
42
|
+
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
function __rest(s, e) {
|
|
46
|
+
var t = {};
|
|
47
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
48
|
+
t[p] = s[p];
|
|
49
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
50
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
51
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
52
|
+
t[p[i]] = s[p[i]];
|
|
53
|
+
}
|
|
54
|
+
return t;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function __classPrivateFieldGet(receiver, state, kind, f) {
|
|
58
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
59
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
60
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
|
64
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
65
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
66
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
67
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
71
|
+
var e = new Error(message);
|
|
72
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
73
|
+
};
|
|
2160
74
|
|
|
2161
75
|
const useUnmount = (cb, deps) => {
|
|
2162
76
|
const ref = React.useRef(cb);
|
|
2163
77
|
ref.current = cb;
|
|
78
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2164
79
|
React.useEffect(() => ref.current, deps);
|
|
2165
80
|
};
|
|
2166
81
|
|
|
@@ -2177,14 +92,14 @@ class TextMeasure {
|
|
|
2177
92
|
}
|
|
2178
93
|
measure(text, font) {
|
|
2179
94
|
const currentKey = `${font === null || font === void 0 ? void 0 : font.fontFamily}-${font === null || font === void 0 ? void 0 : font.fontStyle}-${font === null || font === void 0 ? void 0 : font.fontSize}-${text}`;
|
|
2180
|
-
if (__classPrivateFieldGet
|
|
2181
|
-
return __classPrivateFieldGet
|
|
95
|
+
if (__classPrivateFieldGet(this, _TextMeasure_map, "f")[currentKey]) {
|
|
96
|
+
return __classPrivateFieldGet(this, _TextMeasure_map, "f")[currentKey];
|
|
2182
97
|
}
|
|
2183
|
-
const instance = __classPrivateFieldGet
|
|
98
|
+
const instance = __classPrivateFieldGet(this, _TextMeasure_instances, "m", _TextMeasure_getInstance).call(this);
|
|
2184
99
|
if (font) {
|
|
2185
100
|
const currentFontKey = `${font.fontFamily}-${font.fontStyle}-${font.fontSize}`;
|
|
2186
|
-
if (__classPrivateFieldGet
|
|
2187
|
-
__classPrivateFieldSet
|
|
101
|
+
if (__classPrivateFieldGet(this, _TextMeasure_key, "f") !== currentFontKey) {
|
|
102
|
+
__classPrivateFieldSet(this, _TextMeasure_key, currentFontKey, "f");
|
|
2188
103
|
instance.font = `${font.fontStyle || ""} ${font.fontSize || ""} ${font.fontFamily || ""}`;
|
|
2189
104
|
}
|
|
2190
105
|
}
|
|
@@ -2275,6 +190,8 @@ const useSyncHeight = ({ selector, side, enable }) => {
|
|
|
2275
190
|
if (elements.length === 2) {
|
|
2276
191
|
const ele1 = elements[0];
|
|
2277
192
|
const ele2 = elements[1];
|
|
193
|
+
const target = ele1.getAttribute("data-side") === side ? ele1 : ele2;
|
|
194
|
+
const synced = ele1.getAttribute("data-side") !== side ? ele1 : ele2;
|
|
2278
195
|
const cb = () => {
|
|
2279
196
|
ele1.style.height = "auto";
|
|
2280
197
|
ele2.style.height = "auto";
|
|
@@ -2282,8 +199,7 @@ const useSyncHeight = ({ selector, side, enable }) => {
|
|
|
2282
199
|
const rect2 = ele2.getBoundingClientRect();
|
|
2283
200
|
if (rect1.height !== rect2.height) {
|
|
2284
201
|
const maxHeight = Math.max(rect1.height, rect2.height);
|
|
2285
|
-
|
|
2286
|
-
ele2.style.height = maxHeight + "px";
|
|
202
|
+
synced.style.height = maxHeight + "px";
|
|
2287
203
|
ele1.setAttribute("data-sync-height", String(maxHeight));
|
|
2288
204
|
ele2.setAttribute("data-sync-height", String(maxHeight));
|
|
2289
205
|
}
|
|
@@ -2294,7 +210,6 @@ const useSyncHeight = ({ selector, side, enable }) => {
|
|
|
2294
210
|
};
|
|
2295
211
|
cb();
|
|
2296
212
|
const observer = new ResizeObserver(cb);
|
|
2297
|
-
const target = ele1.getAttribute("data-side") === side ? ele1 : ele2;
|
|
2298
213
|
observer.observe(target);
|
|
2299
214
|
target.setAttribute("data-observe", "height");
|
|
2300
215
|
return () => {
|
|
@@ -2369,7 +284,7 @@ const _DiffSplitExtendLine$1 = ({ index, diffFile, oldLineExtend, newLineExtend,
|
|
|
2369
284
|
lineNumber: currentLineNumber,
|
|
2370
285
|
data: currentExtend.data,
|
|
2371
286
|
onUpdate: diffFile.notifyAll,
|
|
2372
|
-
}))))) : (React__namespace.createElement("td", { className: `diff-line-extend-${exports.SplitSide[side]}-placeholder p-0
|
|
287
|
+
}))))) : (React__namespace.createElement("td", { className: `diff-line-extend-${exports.SplitSide[side]}-placeholder select-none p-0`, style: { backgroundColor: `var(${emptyBGName})` }, colSpan: 2 },
|
|
2373
288
|
React__namespace.createElement("span", null, "\u2002")))));
|
|
2374
289
|
};
|
|
2375
290
|
const DiffSplitExtendLine$1 = ({ index, diffFile, side, lineNumber, }) => {
|
|
@@ -2448,7 +363,106 @@ const memoFunc = (func) => {
|
|
|
2448
363
|
return result;
|
|
2449
364
|
});
|
|
2450
365
|
};
|
|
2451
|
-
const
|
|
366
|
+
const createDiffConfigStore = (props, diffFileId) => {
|
|
367
|
+
return reactivityStore.createStore(() => {
|
|
368
|
+
var _a, _b;
|
|
369
|
+
const id = reactivityStore.ref(diffFileId);
|
|
370
|
+
const setId = (_id) => (id.value = _id);
|
|
371
|
+
const mode = reactivityStore.ref(props.diffViewMode);
|
|
372
|
+
const setMode = (_mode) => (mode.value = _mode);
|
|
373
|
+
const enableWrap = reactivityStore.ref(props.diffViewWrap);
|
|
374
|
+
const setEnableWrap = (_enableWrap) => (enableWrap.value = _enableWrap);
|
|
375
|
+
const enableAddWidget = reactivityStore.ref(props.diffViewAddWidget);
|
|
376
|
+
const setEnableAddWidget = (_enableAddWidget) => (enableAddWidget.value = _enableAddWidget);
|
|
377
|
+
const enableHighlight = reactivityStore.ref(props.diffViewHighlight);
|
|
378
|
+
const setEnableHighlight = (_enableHighlight) => (enableHighlight.value = _enableHighlight);
|
|
379
|
+
const fontSize = reactivityStore.ref(props.diffViewFontSize);
|
|
380
|
+
const setFontSize = (_fontSize) => (fontSize.value = _fontSize);
|
|
381
|
+
const extendData = reactivityStore.ref({
|
|
382
|
+
oldFile: Object.assign({}, (_a = props.extendData) === null || _a === void 0 ? void 0 : _a.oldFile),
|
|
383
|
+
newFile: Object.assign({}, (_b = props.extendData) === null || _b === void 0 ? void 0 : _b.newFile),
|
|
384
|
+
});
|
|
385
|
+
const setExtendData = (_extendData) => {
|
|
386
|
+
const existOldKeys = Object.keys(extendData.value.oldFile || {});
|
|
387
|
+
const inComingOldKeys = Object.keys(_extendData.oldFile || {});
|
|
388
|
+
for (const key of existOldKeys) {
|
|
389
|
+
if (!inComingOldKeys.includes(key)) {
|
|
390
|
+
delete extendData.value.oldFile[key];
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
for (const key of inComingOldKeys) {
|
|
394
|
+
extendData.value.oldFile[key] = _extendData.oldFile[key];
|
|
395
|
+
}
|
|
396
|
+
const existNewKeys = Object.keys(extendData.value.newFile || {});
|
|
397
|
+
const inComingNewKeys = Object.keys(_extendData.newFile || {});
|
|
398
|
+
for (const key of existNewKeys) {
|
|
399
|
+
if (!inComingNewKeys.includes(key)) {
|
|
400
|
+
delete extendData.value.newFile[key];
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
for (const key of inComingNewKeys) {
|
|
404
|
+
extendData.value.newFile[key] = _extendData.newFile[key];
|
|
405
|
+
}
|
|
406
|
+
};
|
|
407
|
+
const renderWidgetLine = reactivityStore.ref(props.renderWidgetLine);
|
|
408
|
+
const setRenderWidgetLine = (_renderWidgetLine) => (renderWidgetLine.value = _renderWidgetLine);
|
|
409
|
+
const renderExtendLine = reactivityStore.ref(props.renderExtendLine);
|
|
410
|
+
const setRenderExtendLine = (_renderExtendLine) => (renderExtendLine.value = _renderExtendLine);
|
|
411
|
+
// 避免无意义的订阅
|
|
412
|
+
const onAddWidgetClick = { current: props.onAddWidgetClick };
|
|
413
|
+
const setOnAddWidgetClick = (_onAddWidgetClick) => (onAddWidgetClick.current = _onAddWidgetClick.current);
|
|
414
|
+
return {
|
|
415
|
+
id,
|
|
416
|
+
setId,
|
|
417
|
+
mode,
|
|
418
|
+
setMode,
|
|
419
|
+
enableWrap,
|
|
420
|
+
setEnableWrap,
|
|
421
|
+
enableAddWidget,
|
|
422
|
+
setEnableAddWidget,
|
|
423
|
+
enableHighlight,
|
|
424
|
+
setEnableHighlight,
|
|
425
|
+
fontSize,
|
|
426
|
+
setFontSize,
|
|
427
|
+
extendData,
|
|
428
|
+
setExtendData,
|
|
429
|
+
renderWidgetLine,
|
|
430
|
+
setRenderWidgetLine,
|
|
431
|
+
renderExtendLine,
|
|
432
|
+
setRenderExtendLine,
|
|
433
|
+
onAddWidgetClick,
|
|
434
|
+
setOnAddWidgetClick,
|
|
435
|
+
};
|
|
436
|
+
});
|
|
437
|
+
};
|
|
438
|
+
const createDiffWidgetStore = (useDiffContextRef) => {
|
|
439
|
+
return reactivityStore.createStore(() => {
|
|
440
|
+
const widgetSide = reactivityStore.ref(undefined);
|
|
441
|
+
const widgetLineNumber = reactivityStore.ref(undefined);
|
|
442
|
+
const setWidget = ({ side, lineNumber }) => {
|
|
443
|
+
var _a, _b;
|
|
444
|
+
const { renderWidgetLine } = ((_b = (_a = useDiffContextRef.current) === null || _a === void 0 ? void 0 : _a.getReadonlyState) === null || _b === void 0 ? void 0 : _b.call(_a)) || {};
|
|
445
|
+
if (typeof renderWidgetLine !== "function")
|
|
446
|
+
return;
|
|
447
|
+
widgetSide.value = side;
|
|
448
|
+
widgetLineNumber.value = lineNumber;
|
|
449
|
+
};
|
|
450
|
+
return { widgetSide, widgetLineNumber, setWidget };
|
|
451
|
+
});
|
|
452
|
+
};
|
|
453
|
+
const createDiffSplitConfigStore = () => {
|
|
454
|
+
return reactivityStore.createStore(() => {
|
|
455
|
+
const splitRef = reactivityStore.ref(undefined);
|
|
456
|
+
const setSplit = (side) => {
|
|
457
|
+
reactDom.flushSync(() => {
|
|
458
|
+
splitRef.value = side;
|
|
459
|
+
});
|
|
460
|
+
};
|
|
461
|
+
return { splitRef, setSplit };
|
|
462
|
+
});
|
|
463
|
+
};
|
|
464
|
+
const diffAsideWidthName = "--diff-aside-width--";
|
|
465
|
+
const diffFontSizeName = "--diff-font-size--";
|
|
2452
466
|
|
|
2453
467
|
const _DiffSplitHunkLineGitHub = ({ index, diffFile, side, lineNumber, }) => {
|
|
2454
468
|
var _a;
|
|
@@ -2463,25 +477,25 @@ const _DiffSplitHunkLineGitHub = ({ index, diffFile, side, lineNumber, }) => {
|
|
|
2463
477
|
const couldExpand = expandEnabled && currentHunk && currentHunk.splitInfo;
|
|
2464
478
|
const isExpandAll = currentHunk &&
|
|
2465
479
|
currentHunk.splitInfo &&
|
|
2466
|
-
currentHunk.splitInfo.endHiddenIndex - currentHunk.splitInfo.startHiddenIndex < composeLen;
|
|
2467
|
-
const isFirstLine = currentHunk && currentHunk.
|
|
480
|
+
currentHunk.splitInfo.endHiddenIndex - currentHunk.splitInfo.startHiddenIndex < core.composeLen;
|
|
481
|
+
const isFirstLine = currentHunk && currentHunk.isFirst;
|
|
2468
482
|
const isLastLine = currentHunk && currentHunk.isLast;
|
|
2469
483
|
return (React__namespace.createElement("tr", { "data-line": `${lineNumber}-hunk`, "data-state": "hunk", "data-side": exports.SplitSide[side], className: "diff-line diff-line-hunk" }, enableHunkAction ? (React__namespace.createElement(React__namespace.Fragment, null,
|
|
2470
|
-
React__namespace.createElement("td", { className: "diff-line-hunk-action sticky left-0
|
|
484
|
+
React__namespace.createElement("td", { className: "diff-line-hunk-action sticky left-0 w-[1%] min-w-[40px] select-none p-[1px]", style: {
|
|
2471
485
|
backgroundColor: `var(${hunkLineNumberBGName})`,
|
|
2472
486
|
color: `var(${plainLineNumberColorName})`,
|
|
2473
|
-
width: `var(${
|
|
2474
|
-
minWidth: `var(${
|
|
2475
|
-
maxWidth: `var(${
|
|
2476
|
-
} }, couldExpand ? (isFirstLine ? (React__namespace.createElement("button", { className: "
|
|
2477
|
-
React__namespace.createElement(ExpandUp, { className: "fill-current" }))) : isLastLine ? (React__namespace.createElement("button", { className: "
|
|
487
|
+
width: `var(${diffAsideWidthName})`,
|
|
488
|
+
minWidth: `var(${diffAsideWidthName})`,
|
|
489
|
+
maxWidth: `var(${diffAsideWidthName})`,
|
|
490
|
+
} }, couldExpand ? (isFirstLine ? (React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px] hover:bg-blue-300", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index) },
|
|
491
|
+
React__namespace.createElement(ExpandUp, { className: "fill-current" }))) : isLastLine ? (React__namespace.createElement("button", { className: "diff-widget-tooltip relative flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px] hover:bg-blue-300", title: "Expand Down", "data-title": "Expand Down", onClick: () => {
|
|
2478
492
|
diffFile.onSplitHunkExpand("down", index);
|
|
2479
493
|
} },
|
|
2480
|
-
React__namespace.createElement(ExpandDown, { className: "fill-current" }))) : isExpandAll ? (React__namespace.createElement("button", { className: "
|
|
494
|
+
React__namespace.createElement(ExpandDown, { className: "fill-current" }))) : isExpandAll ? (React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px] hover:bg-blue-300", title: "Expand All", "data-title": "Expand All", onClick: () => diffFile.onSplitHunkExpand("all", index) },
|
|
2481
495
|
React__namespace.createElement(ExpandAll, { className: "fill-current" }))) : (React__namespace.createElement(React__namespace.Fragment, null,
|
|
2482
|
-
React__namespace.createElement("button", { className: "
|
|
496
|
+
React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px] hover:bg-blue-300", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onSplitHunkExpand("down", index) },
|
|
2483
497
|
React__namespace.createElement(ExpandDown, { className: "fill-current" })),
|
|
2484
|
-
React__namespace.createElement("button", { className: "
|
|
498
|
+
React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px] hover:bg-blue-300", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index) },
|
|
2485
499
|
React__namespace.createElement(ExpandUp, { className: "fill-current" }))))) : (React__namespace.createElement("div", { className: "min-h-[28px]" }, "\u2002"))),
|
|
2486
500
|
React__namespace.createElement("td", { className: "diff-line-hunk-content pr-[10px] align-middle", style: { backgroundColor: `var(${hunkContentBGName})` } },
|
|
2487
501
|
React__namespace.createElement("div", { className: "pl-[1.5em]", style: {
|
|
@@ -2501,25 +515,25 @@ const _DiffSplitHunkLineGitLab = ({ index, diffFile, side, lineNumber, }) => {
|
|
|
2501
515
|
const couldExpand = expandEnabled && currentHunk && currentHunk.splitInfo;
|
|
2502
516
|
const isExpandAll = currentHunk &&
|
|
2503
517
|
currentHunk.splitInfo &&
|
|
2504
|
-
currentHunk.splitInfo.endHiddenIndex - currentHunk.splitInfo.startHiddenIndex < composeLen;
|
|
2505
|
-
const isFirstLine = currentHunk && currentHunk.
|
|
518
|
+
currentHunk.splitInfo.endHiddenIndex - currentHunk.splitInfo.startHiddenIndex < core.composeLen;
|
|
519
|
+
const isFirstLine = currentHunk && currentHunk.isFirst;
|
|
2506
520
|
const isLastLine = currentHunk && currentHunk.isLast;
|
|
2507
521
|
return (React__namespace.createElement("tr", { "data-line": `${lineNumber}-hunk`, "data-state": "hunk", "data-side": exports.SplitSide[side], className: "diff-line diff-line-hunk" },
|
|
2508
|
-
React__namespace.createElement("td", { className: "diff-line-hunk-action sticky left-0
|
|
522
|
+
React__namespace.createElement("td", { className: "diff-line-hunk-action sticky left-0 w-[1%] min-w-[40px] select-none p-[1px]", style: {
|
|
2509
523
|
backgroundColor: `var(${hunkLineNumberBGName})`,
|
|
2510
524
|
color: `var(${plainLineNumberColorName})`,
|
|
2511
|
-
width: `var(${
|
|
2512
|
-
minWidth: `var(${
|
|
2513
|
-
maxWidth: `var(${
|
|
2514
|
-
} }, couldExpand ? (isFirstLine ? (React__namespace.createElement("button", { className: "
|
|
2515
|
-
React__namespace.createElement(ExpandUp, { className: "fill-current" }))) : isLastLine ? (React__namespace.createElement("button", { className: "
|
|
525
|
+
width: `var(${diffAsideWidthName})`,
|
|
526
|
+
minWidth: `var(${diffAsideWidthName})`,
|
|
527
|
+
maxWidth: `var(${diffAsideWidthName})`,
|
|
528
|
+
} }, couldExpand ? (isFirstLine ? (React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px] hover:bg-blue-300", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index) },
|
|
529
|
+
React__namespace.createElement(ExpandUp, { className: "fill-current" }))) : isLastLine ? (React__namespace.createElement("button", { className: "diff-widget-tooltip relative flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px] hover:bg-blue-300", title: "Expand Down", "data-title": "Expand Down", onClick: () => {
|
|
2516
530
|
diffFile.onSplitHunkExpand("down", index);
|
|
2517
531
|
} },
|
|
2518
|
-
React__namespace.createElement(ExpandDown, { className: "fill-current" }))) : isExpandAll ? (React__namespace.createElement("button", { className: "
|
|
532
|
+
React__namespace.createElement(ExpandDown, { className: "fill-current" }))) : isExpandAll ? (React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px] hover:bg-blue-300", title: "Expand All", "data-title": "Expand All", onClick: () => diffFile.onSplitHunkExpand("all", index) },
|
|
2519
533
|
React__namespace.createElement(ExpandAll, { className: "fill-current" }))) : (React__namespace.createElement(React__namespace.Fragment, null,
|
|
2520
|
-
React__namespace.createElement("button", { className: "
|
|
534
|
+
React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px] hover:bg-blue-300", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onSplitHunkExpand("down", index) },
|
|
2521
535
|
React__namespace.createElement(ExpandDown, { className: "fill-current" })),
|
|
2522
|
-
React__namespace.createElement("button", { className: "
|
|
536
|
+
React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px] hover:bg-blue-300", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index) },
|
|
2523
537
|
React__namespace.createElement(ExpandUp, { className: "fill-current" }))))) : (React__namespace.createElement("div", { className: "min-h-[28px]" }, "\u2002"))),
|
|
2524
538
|
React__namespace.createElement("td", { className: "diff-line-hunk-content pr-[10px] align-middle", style: { backgroundColor: `var(${hunkContentBGName})` } },
|
|
2525
539
|
React__namespace.createElement("div", { className: "pl-[1.5em]", style: {
|
|
@@ -2550,14 +564,13 @@ const DiffSplitHunkLine$1 = ({ index, diffFile, side, lineNumber, }) => {
|
|
|
2550
564
|
};
|
|
2551
565
|
|
|
2552
566
|
const DiffSplitAddWidget = ({ side, className, lineNumber, onWidgetClick, onOpenAddWidget, }) => {
|
|
2553
|
-
return (React__namespace.createElement("div", { className: "diff-add-widget-wrapper
|
|
567
|
+
return (React__namespace.createElement("div", { className: "diff-add-widget-wrapper invisible select-none transition-transform hover:scale-110 group-hover:visible" +
|
|
568
|
+
(className ? " " + className : ""), style: {
|
|
2554
569
|
width: `calc(var(${diffFontSizeName}) * 1.4)`,
|
|
2555
570
|
height: `calc(var(${diffFontSizeName}) * 1.4)`,
|
|
2556
571
|
} },
|
|
2557
|
-
React__namespace.createElement("button", { className: "diff-add-widget
|
|
572
|
+
React__namespace.createElement("button", { className: "diff-add-widget z-[1] flex h-full w-full origin-center cursor-pointer items-center justify-center rounded-md text-[1.2em]", style: {
|
|
2558
573
|
color: `var(${addWidgetColorName})`,
|
|
2559
|
-
zIndex: 1,
|
|
2560
|
-
fontSize: `1.2em`,
|
|
2561
574
|
backgroundColor: `var(${addWidgetBGName})`,
|
|
2562
575
|
}, onClick: () => {
|
|
2563
576
|
onOpenAddWidget(lineNumber, side);
|
|
@@ -2565,14 +578,12 @@ const DiffSplitAddWidget = ({ side, className, lineNumber, onWidgetClick, onOpen
|
|
|
2565
578
|
} }, "+")));
|
|
2566
579
|
};
|
|
2567
580
|
const DiffUnifiedAddWidget = ({ lineNumber, side, onWidgetClick, onOpenAddWidget, }) => {
|
|
2568
|
-
return (React__namespace.createElement("div", { className: "diff-add-widget-wrapper absolute left-[100%] top-[1px] translate-x-[-50%]", style: {
|
|
581
|
+
return (React__namespace.createElement("div", { className: "diff-add-widget-wrapper invisible absolute left-[100%] top-[1px] translate-x-[-50%] select-none transition-transform hover:scale-110 group-hover:visible", style: {
|
|
2569
582
|
width: `calc(var(${diffFontSizeName}) * 1.4)`,
|
|
2570
583
|
height: `calc(var(${diffFontSizeName}) * 1.4)`,
|
|
2571
584
|
} },
|
|
2572
|
-
React__namespace.createElement("button", { className: "diff-add-widget
|
|
585
|
+
React__namespace.createElement("button", { className: "diff-add-widget z-[1] flex h-full w-full origin-center cursor-pointer items-center justify-center rounded-md text-[1.2em]", style: {
|
|
2573
586
|
color: `var(${addWidgetColorName})`,
|
|
2574
|
-
zIndex: 1,
|
|
2575
|
-
fontSize: `1.2em`,
|
|
2576
587
|
backgroundColor: `var(${addWidgetBGName})`,
|
|
2577
588
|
}, onClick: () => {
|
|
2578
589
|
onOpenAddWidget(lineNumber, side);
|
|
@@ -2611,30 +622,31 @@ const getStyleObjectFromString = memoFunc((str) => {
|
|
|
2611
622
|
return style;
|
|
2612
623
|
});
|
|
2613
624
|
const DiffString = ({ rawLine, diffLine, operator, enableWrap, }) => {
|
|
2614
|
-
const
|
|
2615
|
-
if (
|
|
625
|
+
const changes = diffLine === null || diffLine === void 0 ? void 0 : diffLine.changes;
|
|
626
|
+
if (changes === null || changes === void 0 ? void 0 : changes.hasLineChange) {
|
|
627
|
+
const range = changes.range;
|
|
2616
628
|
const str1 = rawLine.slice(0, range.location);
|
|
2617
629
|
const str2 = rawLine.slice(range.location, range.location + range.length);
|
|
2618
630
|
const str3 = rawLine.slice(range.location + range.length);
|
|
2619
631
|
const isLast = str2.includes("\n");
|
|
2620
632
|
const _str2 = isLast ? str2.replace("\n", "") : str2;
|
|
2621
|
-
const isNewLineSymbolChanged =
|
|
633
|
+
const isNewLineSymbolChanged = changes.newLineSymbol;
|
|
2622
634
|
return (React__namespace.createElement("span", { className: "diff-line-content-raw" },
|
|
2623
635
|
React__namespace.createElement("span", { "data-range-start": range.location, "data-range-end": range.location + range.length },
|
|
2624
636
|
str1,
|
|
2625
637
|
React__namespace.createElement("span", { "data-diff-highlight": true, className: "rounded-[0.2em]", style: {
|
|
2626
638
|
backgroundColor: operator === "add" ? `var(${addContentHighlightBGName})` : `var(${delContentHighlightBGName})`,
|
|
2627
639
|
} }, isLast
|
|
2628
|
-
? `${_str2}${isNewLineSymbolChanged ===
|
|
640
|
+
? `${_str2}${isNewLineSymbolChanged === core.NewLineSymbol.LF
|
|
2629
641
|
? "␊"
|
|
2630
|
-
: isNewLineSymbolChanged ===
|
|
642
|
+
: isNewLineSymbolChanged === core.NewLineSymbol.CR
|
|
2631
643
|
? "␍"
|
|
2632
|
-
: isNewLineSymbolChanged ===
|
|
644
|
+
: isNewLineSymbolChanged === core.NewLineSymbol.CRLF
|
|
2633
645
|
? "␍␊"
|
|
2634
646
|
: ""}`
|
|
2635
647
|
: str2),
|
|
2636
648
|
str3),
|
|
2637
|
-
isNewLineSymbolChanged ===
|
|
649
|
+
isNewLineSymbolChanged === core.NewLineSymbol.NEWLINE && (React__namespace.createElement("span", { "data-no-newline-at-end-of-file-symbol": true, className: enableWrap ? "block text-red-500" : "inline-block align-middle text-red-500", style: {
|
|
2638
650
|
width: `var(${diffFontSizeName})`,
|
|
2639
651
|
height: `var(${diffFontSizeName})`,
|
|
2640
652
|
} },
|
|
@@ -2647,9 +659,10 @@ const DiffSyntax = ({ rawLine, diffLine, operator, syntaxLine, enableWrap, }) =>
|
|
|
2647
659
|
if (!syntaxLine) {
|
|
2648
660
|
return React__namespace.createElement(DiffString, { rawLine: rawLine, diffLine: diffLine, operator: operator });
|
|
2649
661
|
}
|
|
2650
|
-
const
|
|
2651
|
-
if (
|
|
2652
|
-
const isNewLineSymbolChanged =
|
|
662
|
+
const changes = diffLine === null || diffLine === void 0 ? void 0 : diffLine.changes;
|
|
663
|
+
if (changes === null || changes === void 0 ? void 0 : changes.hasLineChange) {
|
|
664
|
+
const isNewLineSymbolChanged = changes.newLineSymbol;
|
|
665
|
+
const range = changes.range;
|
|
2653
666
|
return (React__namespace.createElement("span", { className: "diff-line-syntax-raw" },
|
|
2654
667
|
React__namespace.createElement("span", { "data-range-start": range.location, "data-range-end": range.location + range.length }, (_a = syntaxLine.nodeList) === null || _a === void 0 ? void 0 : _a.map(({ node, wrapper }, index) => {
|
|
2655
668
|
var _a, _b, _c, _d, _e, _f;
|
|
@@ -2675,18 +688,18 @@ const DiffSyntax = ({ rawLine, diffLine, operator, syntaxLine, enableWrap, }) =>
|
|
|
2675
688
|
borderTopRightRadius: isEnd || isLast ? "0.2em" : undefined,
|
|
2676
689
|
borderBottomRightRadius: isEnd || isLast ? "0.2em" : undefined,
|
|
2677
690
|
} }, isLast
|
|
2678
|
-
? `${_str2}${isNewLineSymbolChanged ===
|
|
691
|
+
? `${_str2}${isNewLineSymbolChanged === core.NewLineSymbol.LF
|
|
2679
692
|
? "␊"
|
|
2680
|
-
: isNewLineSymbolChanged ===
|
|
693
|
+
: isNewLineSymbolChanged === core.NewLineSymbol.CR
|
|
2681
694
|
? "␍"
|
|
2682
|
-
: isNewLineSymbolChanged ===
|
|
695
|
+
: isNewLineSymbolChanged === core.NewLineSymbol.CRLF
|
|
2683
696
|
? "␍␊"
|
|
2684
697
|
: ""}`
|
|
2685
698
|
: str2),
|
|
2686
699
|
str3));
|
|
2687
700
|
}
|
|
2688
701
|
})),
|
|
2689
|
-
isNewLineSymbolChanged ===
|
|
702
|
+
isNewLineSymbolChanged === core.NewLineSymbol.NEWLINE && (React__namespace.createElement("span", { "data-no-newline-at-end-of-file-symbol": true, className: enableWrap ? "block text-red-500" : "inline-block align-middle text-red-500", style: {
|
|
2690
703
|
width: `var(${diffFontSizeName})`,
|
|
2691
704
|
height: `var(${diffFontSizeName})`,
|
|
2692
705
|
} },
|
|
@@ -2699,14 +712,14 @@ const DiffSyntax = ({ rawLine, diffLine, operator, syntaxLine, enableWrap, }) =>
|
|
|
2699
712
|
};
|
|
2700
713
|
const DiffContent = ({ diffLine, rawLine, syntaxLine, enableWrap, enableHighlight, }) => {
|
|
2701
714
|
var _a;
|
|
2702
|
-
const isAdded = (diffLine === null || diffLine === void 0 ? void 0 : diffLine.type) ===
|
|
2703
|
-
const isDelete = (diffLine === null || diffLine === void 0 ? void 0 : diffLine.type) ===
|
|
715
|
+
const isAdded = (diffLine === null || diffLine === void 0 ? void 0 : diffLine.type) === core.DiffLineType.Add;
|
|
716
|
+
const isDelete = (diffLine === null || diffLine === void 0 ? void 0 : diffLine.type) === core.DiffLineType.Delete;
|
|
2704
717
|
const isMaxLineLengthToIgnoreSyntax = ((_a = syntaxLine === null || syntaxLine === void 0 ? void 0 : syntaxLine.nodeList) === null || _a === void 0 ? void 0 : _a.length) > 150;
|
|
2705
718
|
return (React__namespace.createElement("div", { className: "diff-line-content-item pl-[2.0em]", "data-val": rawLine, style: {
|
|
2706
719
|
whiteSpace: enableWrap ? "pre-wrap" : "pre",
|
|
2707
720
|
wordBreak: enableWrap ? "break-all" : "initial",
|
|
2708
721
|
} },
|
|
2709
|
-
React__namespace.createElement("span", { "data-operator": isAdded ? "+" : isDelete ? "-" : undefined, className: "diff-line-content-operator
|
|
722
|
+
React__namespace.createElement("span", { "data-operator": isAdded ? "+" : isDelete ? "-" : undefined, className: "diff-line-content-operator ml-[-1.5em] inline-block w-[1.5em] select-none indent-[0.2em]" }, isAdded ? "+" : isDelete ? "-" : " "),
|
|
2710
723
|
enableHighlight && syntaxLine && !isMaxLineLengthToIgnoreSyntax ? (React__namespace.createElement(DiffSyntax, { operator: isAdded ? "add" : isDelete ? "del" : undefined, rawLine: rawLine, diffLine: diffLine, syntaxLine: syntaxLine, enableWrap: enableWrap })) : (React__namespace.createElement(DiffString, { operator: isAdded ? "add" : isDelete ? "del" : undefined, rawLine: rawLine, diffLine: diffLine, enableWrap: enableWrap }))));
|
|
2711
724
|
};
|
|
2712
725
|
|
|
@@ -2722,9 +735,9 @@ const _DiffSplitLine$1 = ({ index, diffFile, lineNumber, side, }) => {
|
|
|
2722
735
|
const currentLine = side === exports.SplitSide.old ? oldLine : newLine;
|
|
2723
736
|
const hasDiff = !!(currentLine === null || currentLine === void 0 ? void 0 : currentLine.diff);
|
|
2724
737
|
const hasContent = !!currentLine.lineNumber;
|
|
2725
|
-
const hasChange = checkDiffLineIncludeChange(currentLine === null || currentLine === void 0 ? void 0 : currentLine.diff);
|
|
2726
|
-
const isAdded = ((_a = currentLine === null || currentLine === void 0 ? void 0 : currentLine.diff) === null || _a === void 0 ? void 0 : _a.type) ===
|
|
2727
|
-
const isDelete = ((_b = currentLine === null || currentLine === void 0 ? void 0 : currentLine.diff) === null || _b === void 0 ? void 0 : _b.type) ===
|
|
738
|
+
const hasChange = core.checkDiffLineIncludeChange(currentLine === null || currentLine === void 0 ? void 0 : currentLine.diff);
|
|
739
|
+
const isAdded = ((_a = currentLine === null || currentLine === void 0 ? void 0 : currentLine.diff) === null || _a === void 0 ? void 0 : _a.type) === core.DiffLineType.Add;
|
|
740
|
+
const isDelete = ((_b = currentLine === null || currentLine === void 0 ? void 0 : currentLine.diff) === null || _b === void 0 ? void 0 : _b.type) === core.DiffLineType.Delete;
|
|
2728
741
|
const { useDiffContext } = useDiffViewContext();
|
|
2729
742
|
const { enableHighlight, enableAddWidget, onAddWidgetClick } = useDiffContext(React__namespace.useCallback((s) => ({
|
|
2730
743
|
enableHighlight: s.enableHighlight,
|
|
@@ -2737,14 +750,14 @@ const _DiffSplitLine$1 = ({ index, diffFile, lineNumber, side, }) => {
|
|
|
2737
750
|
const lineNumberBG = getLineNumberBG(isAdded, isDelete, hasDiff);
|
|
2738
751
|
const syntaxLine = getCurrentSyntaxLine(currentLine.lineNumber);
|
|
2739
752
|
return (React__namespace.createElement("tr", { "data-line": lineNumber, "data-state": hasDiff || !hasContent ? "diff" : "plain", "data-side": exports.SplitSide[side], className: "diff-line" + (hasContent ? " group" : "") }, hasContent ? (React__namespace.createElement(React__namespace.Fragment, null,
|
|
2740
|
-
React__namespace.createElement("td", { className: `diff-line-${exports.SplitSide[side]}-num sticky left-0 pl-[10px] pr-[10px] text-right align-top
|
|
753
|
+
React__namespace.createElement("td", { className: `diff-line-${exports.SplitSide[side]}-num sticky left-0 w-[1%] min-w-[40px] select-none pl-[10px] pr-[10px] text-right align-top`, style: {
|
|
2741
754
|
backgroundColor: lineNumberBG,
|
|
2742
755
|
color: `var(${plainLineNumberColorName})`,
|
|
2743
|
-
width: `var(${
|
|
2744
|
-
minWidth: `var(${
|
|
2745
|
-
maxWidth: `var(${
|
|
756
|
+
width: `var(${diffAsideWidthName})`,
|
|
757
|
+
minWidth: `var(${diffAsideWidthName})`,
|
|
758
|
+
maxWidth: `var(${diffAsideWidthName})`,
|
|
2746
759
|
} },
|
|
2747
|
-
hasDiff && enableAddWidget && (React__namespace.createElement(DiffSplitAddWidget, { index: index, lineNumber: currentLine.lineNumber, side: side, diffFile: diffFile, onWidgetClick: (...props) => { var _a; return (_a = onAddWidgetClick.current) === null || _a === void 0 ? void 0 : _a.call(onAddWidgetClick, ...props); }, className: "absolute left-[100%] translate-x-[-50%]
|
|
760
|
+
hasDiff && enableAddWidget && (React__namespace.createElement(DiffSplitAddWidget, { index: index, lineNumber: currentLine.lineNumber, side: side, diffFile: diffFile, onWidgetClick: (...props) => { var _a; return (_a = onAddWidgetClick.current) === null || _a === void 0 ? void 0 : _a.call(onAddWidgetClick, ...props); }, className: "absolute left-[100%] z-[1] translate-x-[-50%]", onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber: lineNumber, side: side }) })),
|
|
2748
761
|
React__namespace.createElement("span", { "data-line-num": currentLine.lineNumber, style: { opacity: hasChange ? undefined : 0.5 } }, currentLine.lineNumber)),
|
|
2749
762
|
React__namespace.createElement("td", { className: `diff-line-${exports.SplitSide[side]}-content pr-[10px] align-top`, style: { backgroundColor: contentBG } },
|
|
2750
763
|
React__namespace.createElement(DiffContent, { enableWrap: false, diffFile: diffFile, rawLine: currentLine.value, diffLine: currentLine.diff, syntaxLine: syntaxLine, enableHighlight: enableHighlight })))) : (React__namespace.createElement("td", { className: `diff-line-${exports.SplitSide[side]}-placeholder select-none`, style: { backgroundColor: `var(${emptyBGName})` }, colSpan: 2 },
|
|
@@ -2809,8 +822,8 @@ const onMouseDown$1 = (e) => {
|
|
|
2809
822
|
};
|
|
2810
823
|
const DiffSplitViewTable = ({ side, diffFile }) => {
|
|
2811
824
|
const className = side === exports.SplitSide.new ? "new-diff-table" : "old-diff-table";
|
|
2812
|
-
const lines = getSplitContentLines(diffFile);
|
|
2813
|
-
return (React__namespace.createElement("table", { className: className + " border-collapse
|
|
825
|
+
const lines = core.getSplitContentLines(diffFile);
|
|
826
|
+
return (React__namespace.createElement("table", { className: className + " w-full border-collapse", "data-mode": exports.SplitSide[side] },
|
|
2814
827
|
React__namespace.createElement("colgroup", null,
|
|
2815
828
|
React__namespace.createElement("col", { className: `diff-table-${exports.SplitSide[side]}-num-col` }),
|
|
2816
829
|
React__namespace.createElement("col", { className: `diff-table-${exports.SplitSide[side]}-content-col` })),
|
|
@@ -2836,7 +849,7 @@ const DiffSplitViewNormal = React.memo(({ diffFile }) => {
|
|
|
2836
849
|
const splitLineLength = Math.max(diffFile.splitLineLength, diffFile.fileLineLength);
|
|
2837
850
|
const { useDiffContext } = useDiffViewContext();
|
|
2838
851
|
const fontSize = useDiffContext(React.useCallback((s) => s.fontSize, []));
|
|
2839
|
-
|
|
852
|
+
index_js.useSyncExternalStore(diffFile.subscribe, diffFile.getUpdateCount);
|
|
2840
853
|
React.useEffect(() => {
|
|
2841
854
|
const left = ref1.current;
|
|
2842
855
|
const right = ref2.current;
|
|
@@ -2850,19 +863,19 @@ const DiffSplitViewNormal = React.memo(({ diffFile }) => {
|
|
|
2850
863
|
font,
|
|
2851
864
|
});
|
|
2852
865
|
const width = Math.max(40, _width + 25);
|
|
2853
|
-
return (React__namespace.createElement("div", { className: "split-diff-view split-diff-view-wrap w-full
|
|
2854
|
-
React__namespace.createElement("div", { className: "old-diff-table-wrapper overflow-x-auto overflow-y-hidden
|
|
866
|
+
return (React__namespace.createElement("div", { className: "split-diff-view split-diff-view-wrap flex w-full basis-[50%]" },
|
|
867
|
+
React__namespace.createElement("div", { className: "old-diff-table-wrapper scrollbar-hide scrollbar-disable w-full overflow-x-auto overflow-y-hidden", ref: ref1, style: {
|
|
2855
868
|
// @ts-ignore
|
|
2856
|
-
[
|
|
869
|
+
[diffAsideWidthName]: `${Math.round(width)}px`,
|
|
2857
870
|
overscrollBehaviorX: "none",
|
|
2858
871
|
fontFamily: "Menlo, Consolas, monospace",
|
|
2859
872
|
fontSize: `var(${diffFontSizeName})`,
|
|
2860
873
|
} },
|
|
2861
874
|
React__namespace.createElement(DiffSplitViewTable, { side: exports.SplitSide.old, diffFile: diffFile })),
|
|
2862
875
|
React__namespace.createElement("div", { className: "diff-split-line w-[1.5px] bg-[rgb(222,222,222)]" }),
|
|
2863
|
-
React__namespace.createElement("div", { className: "new-diff-table-wrapper overflow-x-auto overflow-y-hidden
|
|
876
|
+
React__namespace.createElement("div", { className: "new-diff-table-wrapper scrollbar-hide scrollbar-disable w-full overflow-x-auto overflow-y-hidden", ref: ref2, style: {
|
|
2864
877
|
// @ts-ignore
|
|
2865
|
-
[
|
|
878
|
+
[diffAsideWidthName]: `${Math.round(width)}px`,
|
|
2866
879
|
overscrollBehaviorX: "none",
|
|
2867
880
|
fontFamily: "Menlo, Consolas, monospace",
|
|
2868
881
|
fontSize: `var(${diffFontSizeName})`,
|
|
@@ -2888,9 +901,9 @@ const _DiffSplitExtendLine = ({ index, diffFile, lineNumber, oldLineExtend, newL
|
|
|
2888
901
|
lineNumber: oldLine.lineNumber,
|
|
2889
902
|
data: oldLineExtend.data,
|
|
2890
903
|
onUpdate: diffFile.notifyAll,
|
|
2891
|
-
}))))) : (React__namespace.createElement("td", { className: "diff-line-extend-old-placeholder p-0
|
|
904
|
+
}))))) : (React__namespace.createElement("td", { className: "diff-line-extend-old-placeholder select-none p-0", style: { backgroundColor: `var(${emptyBGName})` }, colSpan: 2 },
|
|
2892
905
|
React__namespace.createElement("span", null, "\u2002"))),
|
|
2893
|
-
newLineExtend ? (React__namespace.createElement("td", { className: "diff-line-extend-new-content
|
|
906
|
+
newLineExtend ? (React__namespace.createElement("td", { className: "diff-line-extend-new-content border-l-[1px] border-l-[rgb(222,222,222)] p-0", colSpan: 2 },
|
|
2894
907
|
React__namespace.createElement("div", { className: "diff-line-extend-wrapper" }, (newLineExtend === null || newLineExtend === void 0 ? void 0 : newLineExtend.data) &&
|
|
2895
908
|
(renderExtendLine === null || renderExtendLine === void 0 ? void 0 : renderExtendLine({
|
|
2896
909
|
diffFile,
|
|
@@ -2898,7 +911,7 @@ const _DiffSplitExtendLine = ({ index, diffFile, lineNumber, oldLineExtend, newL
|
|
|
2898
911
|
lineNumber: newLine.lineNumber,
|
|
2899
912
|
data: newLineExtend.data,
|
|
2900
913
|
onUpdate: diffFile.notifyAll,
|
|
2901
|
-
}))))) : (React__namespace.createElement("td", { className: "diff-line-extend-new-placeholder
|
|
914
|
+
}))))) : (React__namespace.createElement("td", { className: "diff-line-extend-new-placeholder select-none border-l-[1px] border-l-[rgb(222,222,222)] p-0", style: { backgroundColor: `var(${emptyBGName})` }, colSpan: 2 },
|
|
2902
915
|
React__namespace.createElement("span", null, "\u2002")))));
|
|
2903
916
|
};
|
|
2904
917
|
const DiffSplitExtendLine = ({ index, diffFile, lineNumber, }) => {
|
|
@@ -2928,26 +941,26 @@ const DiffSplitHunkLineGitHub = ({ index, diffFile, lineNumber, }) => {
|
|
|
2928
941
|
const couldExpand = expandEnabled && currentHunk && currentHunk.splitInfo;
|
|
2929
942
|
const isExpandAll = currentHunk &&
|
|
2930
943
|
currentHunk.splitInfo &&
|
|
2931
|
-
currentHunk.splitInfo.endHiddenIndex - currentHunk.splitInfo.startHiddenIndex < composeLen;
|
|
944
|
+
currentHunk.splitInfo.endHiddenIndex - currentHunk.splitInfo.startHiddenIndex < core.composeLen;
|
|
2932
945
|
const currentIsShow = currentHunk &&
|
|
2933
946
|
currentHunk.splitInfo &&
|
|
2934
947
|
currentHunk.splitInfo.startHiddenIndex < currentHunk.splitInfo.endHiddenIndex;
|
|
2935
948
|
const currentIsPureHunk = currentHunk && diffFile._getIsPureDiffRender() && !currentHunk.splitInfo;
|
|
2936
|
-
const isFirstLine = currentHunk && currentHunk.
|
|
949
|
+
const isFirstLine = currentHunk && currentHunk.isFirst;
|
|
2937
950
|
const isLastLine = currentHunk && currentHunk.isLast;
|
|
2938
951
|
if (!currentIsShow && !currentIsPureHunk)
|
|
2939
952
|
return null;
|
|
2940
953
|
return (React__namespace.createElement("tr", { "data-line": `${lineNumber}-hunk`, "data-state": "hunk", className: "diff-line diff-line-hunk" },
|
|
2941
|
-
React__namespace.createElement("td", { className: "diff-line-hunk-action
|
|
954
|
+
React__namespace.createElement("td", { className: "diff-line-hunk-action relative w-[1%] min-w-[40px] select-none p-[1px]", style: {
|
|
2942
955
|
backgroundColor: `var(${hunkLineNumberBGName})`,
|
|
2943
956
|
color: `var(${plainLineNumberColorName})`,
|
|
2944
|
-
} }, couldExpand ? (isFirstLine ? (React__namespace.createElement("button", { className: "
|
|
2945
|
-
React__namespace.createElement(ExpandUp, { className: "fill-current" }))) : isLastLine ? (React__namespace.createElement("button", { className: "
|
|
2946
|
-
React__namespace.createElement(ExpandDown, { className: "fill-current" }))) : isExpandAll ? (React__namespace.createElement("button", { className: "
|
|
957
|
+
} }, couldExpand ? (isFirstLine ? (React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px] hover:bg-blue-300", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index) },
|
|
958
|
+
React__namespace.createElement(ExpandUp, { className: "fill-current" }))) : isLastLine ? (React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px] hover:bg-blue-300", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onSplitHunkExpand("down", index) },
|
|
959
|
+
React__namespace.createElement(ExpandDown, { className: "fill-current" }))) : isExpandAll ? (React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px] hover:bg-blue-300", title: "Expand All", "data-title": "Expand All", onClick: () => diffFile.onSplitHunkExpand("all", index) },
|
|
2947
960
|
React__namespace.createElement(ExpandAll, { className: "fill-current" }))) : (React__namespace.createElement(React__namespace.Fragment, null,
|
|
2948
|
-
React__namespace.createElement("button", { className: "
|
|
961
|
+
React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px] hover:bg-blue-300", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onSplitHunkExpand("down", index) },
|
|
2949
962
|
React__namespace.createElement(ExpandDown, { className: "fill-current" })),
|
|
2950
|
-
React__namespace.createElement("button", { className: "
|
|
963
|
+
React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px] hover:bg-blue-300", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index) },
|
|
2951
964
|
React__namespace.createElement(ExpandUp, { className: "fill-current" }))))) : (React__namespace.createElement("div", { className: "min-h-[28px]" }, "\u2002"))),
|
|
2952
965
|
React__namespace.createElement("td", { className: "diff-line-hunk-content pr-[10px] align-middle", style: { backgroundColor: `var(${hunkContentBGName})` }, colSpan: 3 },
|
|
2953
966
|
React__namespace.createElement("div", { className: "pl-[1.5em]", style: {
|
|
@@ -2961,41 +974,41 @@ const DiffSplitHunkLineGitLab = ({ index, diffFile, lineNumber, }) => {
|
|
|
2961
974
|
const couldExpand = expandEnabled && currentHunk && currentHunk.splitInfo;
|
|
2962
975
|
const isExpandAll = currentHunk &&
|
|
2963
976
|
currentHunk.splitInfo &&
|
|
2964
|
-
currentHunk.splitInfo.endHiddenIndex - currentHunk.splitInfo.startHiddenIndex < composeLen;
|
|
977
|
+
currentHunk.splitInfo.endHiddenIndex - currentHunk.splitInfo.startHiddenIndex < core.composeLen;
|
|
2965
978
|
const currentIsShow = currentHunk &&
|
|
2966
979
|
currentHunk.splitInfo &&
|
|
2967
980
|
currentHunk.splitInfo.startHiddenIndex < currentHunk.splitInfo.endHiddenIndex;
|
|
2968
981
|
const currentIsPureHunk = currentHunk && diffFile._getIsPureDiffRender() && !currentHunk.splitInfo;
|
|
2969
|
-
const isFirstLine = currentHunk && currentHunk.
|
|
982
|
+
const isFirstLine = currentHunk && currentHunk.isFirst;
|
|
2970
983
|
const isLastLine = currentHunk && currentHunk.isLast;
|
|
2971
984
|
if (!currentIsShow && !currentIsPureHunk)
|
|
2972
985
|
return null;
|
|
2973
986
|
return (React__namespace.createElement("tr", { "data-line": `${lineNumber}-hunk`, "data-state": "hunk", className: "diff-line diff-line-hunk" },
|
|
2974
|
-
React__namespace.createElement("td", { className: "diff-line-hunk-action
|
|
987
|
+
React__namespace.createElement("td", { className: "diff-line-hunk-action relative w-[1%] min-w-[40px] select-none p-[1px]", style: {
|
|
2975
988
|
backgroundColor: `var(${hunkLineNumberBGName})`,
|
|
2976
989
|
color: `var(${plainLineNumberColorName})`,
|
|
2977
|
-
} }, couldExpand ? (isFirstLine ? (React__namespace.createElement("button", { className: "
|
|
2978
|
-
React__namespace.createElement(ExpandUp, { className: "fill-current" }))) : isLastLine ? (React__namespace.createElement("button", { className: "
|
|
2979
|
-
React__namespace.createElement(ExpandDown, { className: "fill-current" }))) : isExpandAll ? (React__namespace.createElement("button", { className: "
|
|
990
|
+
} }, couldExpand ? (isFirstLine ? (React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px] hover:bg-blue-300", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index) },
|
|
991
|
+
React__namespace.createElement(ExpandUp, { className: "fill-current" }))) : isLastLine ? (React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px] hover:bg-blue-300", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onSplitHunkExpand("down", index) },
|
|
992
|
+
React__namespace.createElement(ExpandDown, { className: "fill-current" }))) : isExpandAll ? (React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px] hover:bg-blue-300", title: "Expand All", "data-title": "Expand All", onClick: () => diffFile.onSplitHunkExpand("all", index) },
|
|
2980
993
|
React__namespace.createElement(ExpandAll, { className: "fill-current" }))) : (React__namespace.createElement(React__namespace.Fragment, null,
|
|
2981
|
-
React__namespace.createElement("button", { className: "
|
|
994
|
+
React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px] hover:bg-blue-300", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onSplitHunkExpand("down", index) },
|
|
2982
995
|
React__namespace.createElement(ExpandDown, { className: "fill-current" })),
|
|
2983
|
-
React__namespace.createElement("button", { className: "
|
|
996
|
+
React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px] hover:bg-blue-300", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index) },
|
|
2984
997
|
React__namespace.createElement(ExpandUp, { className: "fill-current" }))))) : (React__namespace.createElement("div", { className: "min-h-[28px]" }, "\u2002"))),
|
|
2985
998
|
React__namespace.createElement("td", { className: "diff-line-hunk-content pr-[10px] align-middle", style: { backgroundColor: `var(${hunkContentBGName})` } },
|
|
2986
999
|
React__namespace.createElement("div", { className: "pl-[1.5em]", style: {
|
|
2987
1000
|
color: `var(${hunkContentColorName})`,
|
|
2988
1001
|
} }, ((_a = currentHunk.splitInfo) === null || _a === void 0 ? void 0 : _a.plainText) || currentHunk.text)),
|
|
2989
|
-
React__namespace.createElement("td", { className: "diff-line-hunk-action
|
|
1002
|
+
React__namespace.createElement("td", { className: "diff-line-hunk-action relative w-[1%] min-w-[40px] select-none border-l-[1px] border-l-[rgb(222,222,222)] p-[1px]", style: {
|
|
2990
1003
|
backgroundColor: `var(${hunkLineNumberBGName})`,
|
|
2991
1004
|
color: `var(${plainLineNumberColorName})`,
|
|
2992
|
-
} }, couldExpand ? (isFirstLine ? (React__namespace.createElement("button", { className: "
|
|
2993
|
-
React__namespace.createElement(ExpandUp, { className: "fill-current" }))) : isLastLine ? (React__namespace.createElement("button", { className: "
|
|
2994
|
-
React__namespace.createElement(ExpandDown, { className: "fill-current" }))) : isExpandAll ? (React__namespace.createElement("button", { className: "
|
|
1005
|
+
} }, couldExpand ? (isFirstLine ? (React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px] hover:bg-blue-300", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index) },
|
|
1006
|
+
React__namespace.createElement(ExpandUp, { className: "fill-current" }))) : isLastLine ? (React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px] hover:bg-blue-300", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onSplitHunkExpand("down", index) },
|
|
1007
|
+
React__namespace.createElement(ExpandDown, { className: "fill-current" }))) : isExpandAll ? (React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px] hover:bg-blue-300", title: "Expand All", "data-title": "Expand All", onClick: () => diffFile.onSplitHunkExpand("all", index) },
|
|
2995
1008
|
React__namespace.createElement(ExpandAll, { className: "fill-current" }))) : (React__namespace.createElement(React__namespace.Fragment, null,
|
|
2996
|
-
React__namespace.createElement("button", { className: "
|
|
1009
|
+
React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px] hover:bg-blue-300", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onSplitHunkExpand("down", index) },
|
|
2997
1010
|
React__namespace.createElement(ExpandDown, { className: "fill-current" })),
|
|
2998
|
-
React__namespace.createElement("button", { className: "
|
|
1011
|
+
React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px] hover:bg-blue-300", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index) },
|
|
2999
1012
|
React__namespace.createElement(ExpandUp, { className: "fill-current" }))))) : (React__namespace.createElement("div", { className: "min-h-[28px]" }, "\u2002"))),
|
|
3000
1013
|
React__namespace.createElement("td", { className: "diff-line-hunk-content pr-[10px] align-middle", style: { backgroundColor: `var(${hunkContentBGName})` } },
|
|
3001
1014
|
React__namespace.createElement("div", { className: "pl-[1.5em]", style: {
|
|
@@ -3022,9 +1035,9 @@ const _DiffSplitLine = ({ index, diffFile, lineNumber }) => {
|
|
|
3022
1035
|
const oldSyntaxLine = diffFile.getOldSyntaxLine(oldLine === null || oldLine === void 0 ? void 0 : oldLine.lineNumber);
|
|
3023
1036
|
const newSyntaxLine = diffFile.getNewSyntaxLine(newLine === null || newLine === void 0 ? void 0 : newLine.lineNumber);
|
|
3024
1037
|
const hasDiff = !!(oldLine === null || oldLine === void 0 ? void 0 : oldLine.diff) || !!(newLine === null || newLine === void 0 ? void 0 : newLine.diff);
|
|
3025
|
-
const hasChange = checkDiffLineIncludeChange(oldLine === null || oldLine === void 0 ? void 0 : oldLine.diff) || checkDiffLineIncludeChange(newLine === null || newLine === void 0 ? void 0 : newLine.diff);
|
|
3026
|
-
const oldLineIsDelete = ((_a = oldLine === null || oldLine === void 0 ? void 0 : oldLine.diff) === null || _a === void 0 ? void 0 : _a.type) ===
|
|
3027
|
-
const newLineIsAdded = ((_b = newLine === null || newLine === void 0 ? void 0 : newLine.diff) === null || _b === void 0 ? void 0 : _b.type) ===
|
|
1038
|
+
const hasChange = core.checkDiffLineIncludeChange(oldLine === null || oldLine === void 0 ? void 0 : oldLine.diff) || core.checkDiffLineIncludeChange(newLine === null || newLine === void 0 ? void 0 : newLine.diff);
|
|
1039
|
+
const oldLineIsDelete = ((_a = oldLine === null || oldLine === void 0 ? void 0 : oldLine.diff) === null || _a === void 0 ? void 0 : _a.type) === core.DiffLineType.Delete;
|
|
1040
|
+
const newLineIsAdded = ((_b = newLine === null || newLine === void 0 ? void 0 : newLine.diff) === null || _b === void 0 ? void 0 : _b.type) === core.DiffLineType.Add;
|
|
3028
1041
|
const { useDiffContext } = useDiffViewContext();
|
|
3029
1042
|
const { enableHighlight, enableAddWidget, onAddWidgetClick } = useDiffContext(React__namespace.useCallback((s) => ({
|
|
3030
1043
|
enableHighlight: s.enableHighlight,
|
|
@@ -3041,19 +1054,19 @@ const _DiffSplitLine = ({ index, diffFile, lineNumber }) => {
|
|
|
3041
1054
|
const newLineNumberBG = getLineNumberBG(newLineIsAdded, false, hasDiff);
|
|
3042
1055
|
return (React__namespace.createElement("tr", { "data-line": lineNumber, "data-state": hasDiff ? "diff" : "plain", className: "diff-line" },
|
|
3043
1056
|
hasOldLine ? (React__namespace.createElement(React__namespace.Fragment, null,
|
|
3044
|
-
React__namespace.createElement("td", { className: "diff-line-old-num group relative pl-[10px] pr-[10px] text-right align-top
|
|
3045
|
-
hasDiff && enableAddWidget && (React__namespace.createElement(DiffSplitAddWidget, { index: index, lineNumber: oldLine.lineNumber, side: exports.SplitSide.old, diffFile: diffFile, onWidgetClick: (...props) => { var _a; return (_a = onAddWidgetClick.current) === null || _a === void 0 ? void 0 : _a.call(onAddWidgetClick, ...props); }, className: "absolute left-[100%] translate-x-[-50%]
|
|
1057
|
+
React__namespace.createElement("td", { className: "diff-line-old-num group relative w-[1%] min-w-[40px] select-none pl-[10px] pr-[10px] text-right align-top", "data-side": exports.SplitSide[exports.SplitSide.old], style: { backgroundColor: oldLineNumberBG, color: `var(${plainLineNumberColorName})` } },
|
|
1058
|
+
hasDiff && enableAddWidget && (React__namespace.createElement(DiffSplitAddWidget, { index: index, lineNumber: oldLine.lineNumber, side: exports.SplitSide.old, diffFile: diffFile, onWidgetClick: (...props) => { var _a; return (_a = onAddWidgetClick.current) === null || _a === void 0 ? void 0 : _a.call(onAddWidgetClick, ...props); }, className: "absolute left-[100%] z-[1] translate-x-[-50%]", onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber: lineNumber, side: side }) })),
|
|
3046
1059
|
React__namespace.createElement("span", { "data-line-num": oldLine.lineNumber, style: { opacity: hasChange ? undefined : 0.5 } }, oldLine.lineNumber)),
|
|
3047
1060
|
React__namespace.createElement("td", { className: "diff-line-old-content group relative pr-[10px] align-top", "data-side": exports.SplitSide[exports.SplitSide.old], style: { backgroundColor: oldLineContentBG } },
|
|
3048
|
-
hasDiff && enableAddWidget && (React__namespace.createElement(DiffSplitAddWidget, { index: index, lineNumber: oldLine.lineNumber, side: exports.SplitSide.old, diffFile: diffFile, onWidgetClick: (...props) => { var _a; return (_a = onAddWidgetClick.current) === null || _a === void 0 ? void 0 : _a.call(onAddWidgetClick, ...props); }, className: "absolute right-[100%] translate-x-[50%]
|
|
1061
|
+
hasDiff && enableAddWidget && (React__namespace.createElement(DiffSplitAddWidget, { index: index, lineNumber: oldLine.lineNumber, side: exports.SplitSide.old, diffFile: diffFile, onWidgetClick: (...props) => { var _a; return (_a = onAddWidgetClick.current) === null || _a === void 0 ? void 0 : _a.call(onAddWidgetClick, ...props); }, className: "absolute right-[100%] z-[1] translate-x-[50%]", onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber: lineNumber, side: side }) })),
|
|
3049
1062
|
React__namespace.createElement(DiffContent, { enableWrap: true, diffFile: diffFile, rawLine: oldLine.value, diffLine: oldLine.diff, syntaxLine: oldSyntaxLine, enableHighlight: enableHighlight })))) : (React__namespace.createElement("td", { className: "diff-line-old-placeholder select-none", "data-side": exports.SplitSide[exports.SplitSide.old], style: { backgroundColor: `var(${emptyBGName})` }, colSpan: 2 },
|
|
3050
1063
|
React__namespace.createElement("span", null, "\u2002"))),
|
|
3051
1064
|
hasNewLine ? (React__namespace.createElement(React__namespace.Fragment, null,
|
|
3052
|
-
React__namespace.createElement("td", { className: "diff-line-new-num group relative
|
|
3053
|
-
hasDiff && enableAddWidget && (React__namespace.createElement(DiffSplitAddWidget, { index: index, lineNumber: newLine.lineNumber, side: exports.SplitSide.new, diffFile: diffFile, onWidgetClick: (...props) => { var _a; return (_a = onAddWidgetClick.current) === null || _a === void 0 ? void 0 : _a.call(onAddWidgetClick, ...props); }, className: "absolute left-[100%] translate-x-[-50%]
|
|
1065
|
+
React__namespace.createElement("td", { className: "diff-line-new-num group relative w-[1%] min-w-[40px] select-none border-l-[1px] border-l-[rgb(222,222,222)] pl-[10px] pr-[10px] text-right align-top", "data-side": exports.SplitSide[exports.SplitSide.new], style: { backgroundColor: newLineNumberBG, color: `var(${plainLineNumberColorName})` } },
|
|
1066
|
+
hasDiff && enableAddWidget && (React__namespace.createElement(DiffSplitAddWidget, { index: index, lineNumber: newLine.lineNumber, side: exports.SplitSide.new, diffFile: diffFile, onWidgetClick: (...props) => { var _a; return (_a = onAddWidgetClick.current) === null || _a === void 0 ? void 0 : _a.call(onAddWidgetClick, ...props); }, className: "absolute left-[100%] z-[1] translate-x-[-50%]", onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber: lineNumber, side: side }) })),
|
|
3054
1067
|
React__namespace.createElement("span", { "data-line-num": newLine.lineNumber, style: { opacity: hasChange ? undefined : 0.5 } }, newLine.lineNumber)),
|
|
3055
1068
|
React__namespace.createElement("td", { className: "diff-line-new-content group relative pr-[10px] align-top", "data-side": exports.SplitSide[exports.SplitSide.new], style: { backgroundColor: newLineContentBG } },
|
|
3056
|
-
hasDiff && enableAddWidget && (React__namespace.createElement(DiffSplitAddWidget, { index: index, lineNumber: newLine.lineNumber, side: exports.SplitSide.new, diffFile: diffFile, onWidgetClick: (...props) => { var _a; return (_a = onAddWidgetClick.current) === null || _a === void 0 ? void 0 : _a.call(onAddWidgetClick, ...props); }, className: "absolute right-[100%] translate-x-[50%]
|
|
1069
|
+
hasDiff && enableAddWidget && (React__namespace.createElement(DiffSplitAddWidget, { index: index, lineNumber: newLine.lineNumber, side: exports.SplitSide.new, diffFile: diffFile, onWidgetClick: (...props) => { var _a; return (_a = onAddWidgetClick.current) === null || _a === void 0 ? void 0 : _a.call(onAddWidgetClick, ...props); }, className: "absolute right-[100%] z-[1] translate-x-[50%]", onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber: lineNumber, side: side }) })),
|
|
3057
1070
|
React__namespace.createElement(DiffContent, { enableWrap: true, diffFile: diffFile, rawLine: newLine.value || "", diffLine: newLine.diff, syntaxLine: newSyntaxLine, enableHighlight: enableHighlight })))) : (React__namespace.createElement("td", { className: "diff-line-new-placeholder select-none border-l-[1px] border-l-[rgb(222,222,222)]", style: { backgroundColor: `var(${emptyBGName})` }, "data-side": exports.SplitSide[exports.SplitSide.new], colSpan: 2 },
|
|
3058
1071
|
React__namespace.createElement("span", null, "\u2002")))));
|
|
3059
1072
|
};
|
|
@@ -3081,15 +1094,15 @@ const _DiffSplitWidgetLine = ({ index, diffFile, lineNumber, oldLineWidget, newL
|
|
|
3081
1094
|
side: exports.SplitSide.old,
|
|
3082
1095
|
lineNumber: oldLine.lineNumber,
|
|
3083
1096
|
onClose: () => setWidget({}),
|
|
3084
|
-
})))) : (React__namespace.createElement("td", { className: "diff-line-widget-old-placeholder p-0
|
|
1097
|
+
})))) : (React__namespace.createElement("td", { className: "diff-line-widget-old-placeholder select-none p-0", style: { backgroundColor: `var(${emptyBGName})` }, colSpan: 2 },
|
|
3085
1098
|
React__namespace.createElement("span", null, "\u2002"))),
|
|
3086
|
-
newLineWidget ? (React__namespace.createElement("td", { className: "diff-line-widget-new-content
|
|
1099
|
+
newLineWidget ? (React__namespace.createElement("td", { className: "diff-line-widget-new-content border-l-[1px] border-l-[rgb(222,222,222)] p-0", colSpan: 2 },
|
|
3087
1100
|
React__namespace.createElement("div", { className: "diff-line-widget-wrapper" }, renderWidgetLine === null || renderWidgetLine === void 0 ? void 0 : renderWidgetLine({
|
|
3088
1101
|
diffFile,
|
|
3089
1102
|
side: exports.SplitSide.new,
|
|
3090
1103
|
lineNumber: newLine.lineNumber,
|
|
3091
1104
|
onClose: () => setWidget({}),
|
|
3092
|
-
})))) : (React__namespace.createElement("td", { className: "diff-line-widget-new-placeholder
|
|
1105
|
+
})))) : (React__namespace.createElement("td", { className: "diff-line-widget-new-placeholder select-none border-l-[1px] border-l-[rgb(222,222,222)] p-0", style: { backgroundColor: `var(${emptyBGName})` }, colSpan: 2 },
|
|
3093
1106
|
React__namespace.createElement("span", null, "\u2002")))));
|
|
3094
1107
|
};
|
|
3095
1108
|
const DiffSplitWidgetLine = ({ index, diffFile, lineNumber, }) => {
|
|
@@ -3105,6 +1118,7 @@ const DiffSplitWidgetLine = ({ index, diffFile, lineNumber, }) => {
|
|
|
3105
1118
|
return (React__namespace.createElement(_DiffSplitWidgetLine, { index: index, diffFile: diffFile, lineNumber: lineNumber, oldLineWidget: oldLineWidget, newLineWidget: newLineWidget }));
|
|
3106
1119
|
};
|
|
3107
1120
|
|
|
1121
|
+
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
3108
1122
|
const Style = ({ useSelector, id, }) => {
|
|
3109
1123
|
const splitRef = useSelector((s) => s.splitRef);
|
|
3110
1124
|
return (React__namespace.createElement("style", { "data-select-style": true }, splitRef === exports.SplitSide.old
|
|
@@ -3116,20 +1130,12 @@ const Style = ({ useSelector, id, }) => {
|
|
|
3116
1130
|
const DiffSplitViewWrap = React.memo(({ diffFile }) => {
|
|
3117
1131
|
const splitLineLength = Math.max(diffFile.splitLineLength, diffFile.fileLineLength);
|
|
3118
1132
|
const { useDiffContext } = useDiffViewContext();
|
|
3119
|
-
const
|
|
3120
|
-
const splitRef = reactivityStore.ref(undefined);
|
|
3121
|
-
const setSplit = (side) => {
|
|
3122
|
-
reactDom.flushSync(() => {
|
|
3123
|
-
splitRef.value = side;
|
|
3124
|
-
});
|
|
3125
|
-
};
|
|
3126
|
-
return { splitRef, setSplit };
|
|
3127
|
-
}), []);
|
|
3128
|
-
const setSelectSide = splitSideInfo.getReadonlyState().setSplit;
|
|
1133
|
+
const useSplitConfig = React.useMemo(() => createDiffSplitConfigStore(), []);
|
|
3129
1134
|
const fontSize = useDiffContext(React.useCallback((s) => s.fontSize, []));
|
|
3130
|
-
|
|
1135
|
+
index_js.useSyncExternalStore(diffFile.subscribe, diffFile.getUpdateCount);
|
|
3131
1136
|
const onMouseDown = React.useCallback((e) => {
|
|
3132
1137
|
let ele = e.target;
|
|
1138
|
+
const setSelectSide = useSplitConfig.getReadonlyState().setSplit;
|
|
3133
1139
|
// need remove all the selection
|
|
3134
1140
|
if (ele && ele instanceof HTMLElement && ele.nodeName === "BUTTON") {
|
|
3135
1141
|
removeAllSelection();
|
|
@@ -3145,21 +1151,24 @@ const DiffSplitViewWrap = React.memo(({ diffFile }) => {
|
|
|
3145
1151
|
removeAllSelection();
|
|
3146
1152
|
}
|
|
3147
1153
|
}
|
|
3148
|
-
|
|
1154
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1155
|
+
}, []);
|
|
3149
1156
|
const font = React.useMemo(() => ({ fontSize: fontSize + "px", fontFamily: "Menlo, Consolas, monospace" }), [fontSize]);
|
|
3150
1157
|
const _width = useTextWidth({
|
|
3151
1158
|
text: splitLineLength.toString(),
|
|
3152
1159
|
font,
|
|
3153
1160
|
});
|
|
3154
1161
|
const width = Math.max(40, _width + 25);
|
|
3155
|
-
const lines = getSplitContentLines(diffFile);
|
|
1162
|
+
const lines = core.getSplitContentLines(diffFile);
|
|
3156
1163
|
return (React__namespace.createElement("div", { className: "split-diff-view split-diff-view-normal w-full" },
|
|
3157
1164
|
React__namespace.createElement("div", { className: "diff-table-wrapper w-full", style: {
|
|
1165
|
+
// @ts-ignore
|
|
1166
|
+
[diffAsideWidthName]: `${Math.round(width)}px`,
|
|
3158
1167
|
fontFamily: "Menlo, Consolas, monospace",
|
|
3159
1168
|
fontSize: `var(${diffFontSizeName})`,
|
|
3160
1169
|
} },
|
|
3161
|
-
React__namespace.createElement(Style, { useSelector:
|
|
3162
|
-
React__namespace.createElement("table", { className: "diff-table
|
|
1170
|
+
React__namespace.createElement(Style, { useSelector: useSplitConfig, id: `diff-root${diffFile.getId()}` }),
|
|
1171
|
+
React__namespace.createElement("table", { className: "diff-table w-full table-fixed border-collapse" },
|
|
3163
1172
|
React__namespace.createElement("colgroup", null,
|
|
3164
1173
|
React__namespace.createElement("col", { className: "diff-table-old-num-col", width: Math.round(width) }),
|
|
3165
1174
|
React__namespace.createElement("col", { className: "diff-table-old-content-col" }),
|
|
@@ -3183,20 +1192,11 @@ DiffSplitViewWrap.displayName = "DiffSplitViewWrap";
|
|
|
3183
1192
|
|
|
3184
1193
|
const DiffSplitView = React.memo(({ diffFile }) => {
|
|
3185
1194
|
const { useDiffContext } = useDiffViewContext();
|
|
3186
|
-
const
|
|
1195
|
+
const useDiffContextRef = React.useRef(useDiffContext);
|
|
1196
|
+
useDiffContextRef.current = useDiffContext;
|
|
1197
|
+
const enableWrap = useDiffContext(React.useCallback((s) => s.enableWrap, []));
|
|
3187
1198
|
// performance optimization
|
|
3188
|
-
const useWidget = React.useMemo(() =>
|
|
3189
|
-
const widgetSide = reactivityStore.ref(undefined);
|
|
3190
|
-
const widgetLineNumber = reactivityStore.ref(undefined);
|
|
3191
|
-
const setWidget = ({ side, lineNumber }) => {
|
|
3192
|
-
const { renderWidgetLine } = useDiffContext.getReadonlyState();
|
|
3193
|
-
if (typeof renderWidgetLine !== "function")
|
|
3194
|
-
return;
|
|
3195
|
-
widgetSide.value = side;
|
|
3196
|
-
widgetLineNumber.value = lineNumber;
|
|
3197
|
-
};
|
|
3198
|
-
return { widgetSide, widgetLineNumber, setWidget };
|
|
3199
|
-
}), [useDiffContext]);
|
|
1199
|
+
const useWidget = React.useMemo(() => createDiffWidgetStore(useDiffContextRef), []);
|
|
3200
1200
|
const contextValue = React.useMemo(() => ({ useWidget }), [useWidget]);
|
|
3201
1201
|
React.useEffect(() => {
|
|
3202
1202
|
const { setWidget } = useWidget.getReadonlyState();
|
|
@@ -3217,7 +1217,7 @@ const _DiffUnifiedExtendLine = ({ index, diffFile, lineNumber, oldLineExtend, ne
|
|
|
3217
1217
|
if (!renderExtendLine)
|
|
3218
1218
|
return null;
|
|
3219
1219
|
return (React__namespace.createElement("tr", { "data-line": `${lineNumber}-extend`, "data-state": "extend", className: "diff-line diff-line-extend" },
|
|
3220
|
-
React__namespace.createElement("td", { className: "diff-line-extend-content align-top
|
|
1220
|
+
React__namespace.createElement("td", { className: "diff-line-extend-content p-0 align-top", colSpan: 2 },
|
|
3221
1221
|
React__namespace.createElement("div", { className: "diff-line-extend-wrapper sticky left-0", style: { width } },
|
|
3222
1222
|
width > 0 &&
|
|
3223
1223
|
(oldLineExtend === null || oldLineExtend === void 0 ? void 0 : oldLineExtend.data) &&
|
|
@@ -3263,23 +1263,23 @@ const _DiffUnifiedHunkLine = ({ index, diffFile, lineNumber, }) => {
|
|
|
3263
1263
|
const couldExpand = expandEnabled && currentHunk && currentHunk.unifiedInfo;
|
|
3264
1264
|
const isExpandAll = currentHunk &&
|
|
3265
1265
|
currentHunk.unifiedInfo &&
|
|
3266
|
-
currentHunk.unifiedInfo.endHiddenIndex - currentHunk.unifiedInfo.startHiddenIndex < composeLen;
|
|
3267
|
-
const isFirstLine = currentHunk && currentHunk.
|
|
1266
|
+
currentHunk.unifiedInfo.endHiddenIndex - currentHunk.unifiedInfo.startHiddenIndex < core.composeLen;
|
|
1267
|
+
const isFirstLine = currentHunk && currentHunk.isFirst;
|
|
3268
1268
|
const isLastLine = currentHunk && currentHunk.isLast;
|
|
3269
1269
|
return (React__namespace.createElement("tr", { "data-line": `${lineNumber}-hunk`, "data-state": "hunk", className: "diff-line diff-line-hunk" },
|
|
3270
|
-
React__namespace.createElement("td", { className: "diff-line-hunk-action sticky left-0
|
|
1270
|
+
React__namespace.createElement("td", { className: "diff-line-hunk-action sticky left-0 w-[1%] min-w-[100px] select-none p-[1px]", style: {
|
|
3271
1271
|
backgroundColor: `var(${hunkLineNumberBGName})`,
|
|
3272
1272
|
color: `var(${plainLineNumberColorName})`,
|
|
3273
|
-
width: `calc(calc(var(${
|
|
3274
|
-
maxWidth: `calc(calc(var(${
|
|
3275
|
-
minWidth: `calc(calc(var(${
|
|
3276
|
-
} }, couldExpand ? (isFirstLine ? (React__namespace.createElement("button", { className: "
|
|
3277
|
-
React__namespace.createElement(ExpandUp, { className: "fill-current" }))) : isLastLine ? (React__namespace.createElement("button", { className: "
|
|
3278
|
-
React__namespace.createElement(ExpandDown, { className: "fill-current" }))) : isExpandAll ? (React__namespace.createElement("button", { className: "
|
|
1273
|
+
width: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
|
|
1274
|
+
maxWidth: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
|
|
1275
|
+
minWidth: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
|
|
1276
|
+
} }, couldExpand ? (isFirstLine ? (React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px] hover:bg-blue-300", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onUnifiedHunkExpand("up", index) },
|
|
1277
|
+
React__namespace.createElement(ExpandUp, { className: "fill-current" }))) : isLastLine ? (React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px] hover:bg-blue-300", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onUnifiedHunkExpand("down", index) },
|
|
1278
|
+
React__namespace.createElement(ExpandDown, { className: "fill-current" }))) : isExpandAll ? (React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px] hover:bg-blue-300", title: "Expand All", "data-title": "Expand All", onClick: () => diffFile.onUnifiedHunkExpand("all", index) },
|
|
3279
1279
|
React__namespace.createElement(ExpandAll, { className: "fill-current" }))) : (React__namespace.createElement(React__namespace.Fragment, null,
|
|
3280
|
-
React__namespace.createElement("button", { className: "
|
|
1280
|
+
React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px] hover:bg-blue-300", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onUnifiedHunkExpand("down", index) },
|
|
3281
1281
|
React__namespace.createElement(ExpandDown, { className: "fill-current" })),
|
|
3282
|
-
React__namespace.createElement("button", { className: "
|
|
1282
|
+
React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px] hover:bg-blue-300", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onUnifiedHunkExpand("up", index) },
|
|
3283
1283
|
React__namespace.createElement(ExpandUp, { className: "fill-current" }))))) : (React__namespace.createElement("div", { className: "min-h-[28px]" }, "\u2002"))),
|
|
3284
1284
|
React__namespace.createElement("td", { className: "diff-line-hunk-content pr-[10px] align-middle", style: { backgroundColor: `var(${hunkContentBGName})` } },
|
|
3285
1285
|
React__namespace.createElement("div", { className: "pl-[1.5em]", style: {
|
|
@@ -3301,12 +1301,12 @@ const DiffUnifiedHunkLine = ({ index, diffFile, lineNumber, }) => {
|
|
|
3301
1301
|
|
|
3302
1302
|
const DiffUnifiedOldLine = ({ index, diffLine, rawLine, syntaxLine, lineNumber, diffFile, setWidget, enableWrap, enableAddWidget, enableHighlight, onAddWidgetClick, }) => {
|
|
3303
1303
|
return (React__namespace.createElement("tr", { "data-line": index, "data-state": "diff", className: "diff-line group" },
|
|
3304
|
-
React__namespace.createElement("td", { className: "diff-line-num sticky left-0
|
|
1304
|
+
React__namespace.createElement("td", { className: "diff-line-num sticky left-0 w-[1%] min-w-[100px] select-none whitespace-nowrap pl-[10px] pr-[10px] text-right align-top", style: {
|
|
3305
1305
|
color: `var(${plainLineNumberColorName})`,
|
|
3306
1306
|
backgroundColor: `var(${delLineNumberBGName})`,
|
|
3307
|
-
width: `calc(calc(var(${
|
|
3308
|
-
maxWidth: `calc(calc(var(${
|
|
3309
|
-
minWidth: `calc(calc(var(${
|
|
1307
|
+
width: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
|
|
1308
|
+
maxWidth: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
|
|
1309
|
+
minWidth: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
|
|
3310
1310
|
} },
|
|
3311
1311
|
enableAddWidget && (React__namespace.createElement(DiffUnifiedAddWidget, { index: index - 1, lineNumber: lineNumber, diffFile: diffFile, side: exports.SplitSide.old, onWidgetClick: onAddWidgetClick, onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber, side }) })),
|
|
3312
1312
|
React__namespace.createElement("div", { className: "flex" },
|
|
@@ -3318,17 +1318,17 @@ const DiffUnifiedOldLine = ({ index, diffLine, rawLine, syntaxLine, lineNumber,
|
|
|
3318
1318
|
};
|
|
3319
1319
|
const DiffUnifiedNewLine = ({ index, diffLine, rawLine, syntaxLine, lineNumber, diffFile, setWidget, enableWrap, enableAddWidget, enableHighlight, onAddWidgetClick, }) => {
|
|
3320
1320
|
return (React__namespace.createElement("tr", { "data-line": index, "data-state": "diff", className: "diff-line group" },
|
|
3321
|
-
React__namespace.createElement("td", { className: "diff-line-num sticky left-0
|
|
1321
|
+
React__namespace.createElement("td", { className: "diff-line-num sticky left-0 w-[1%] min-w-[100px] select-none whitespace-nowrap pl-[10px] pr-[10px] text-right align-top", style: {
|
|
3322
1322
|
color: `var(${plainLineNumberColorName})`,
|
|
3323
1323
|
backgroundColor: `var(${addLineNumberBGName})`,
|
|
3324
|
-
width: `calc(calc(var(${
|
|
3325
|
-
maxWidth: `calc(calc(var(${
|
|
3326
|
-
minWidth: `calc(calc(var(${
|
|
1324
|
+
width: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
|
|
1325
|
+
maxWidth: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
|
|
1326
|
+
minWidth: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
|
|
3327
1327
|
} },
|
|
3328
1328
|
enableAddWidget && (React__namespace.createElement(DiffUnifiedAddWidget, { index: index - 1, lineNumber: lineNumber, diffFile: diffFile, side: exports.SplitSide.new, onWidgetClick: onAddWidgetClick, onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber, side }) })),
|
|
3329
1329
|
React__namespace.createElement("div", { className: "flex" },
|
|
3330
1330
|
React__namespace.createElement("span", { className: "inline-block w-[50%]" }),
|
|
3331
|
-
React__namespace.createElement("span", { className: "
|
|
1331
|
+
React__namespace.createElement("span", { className: "w-[10px] shrink-0" }),
|
|
3332
1332
|
React__namespace.createElement("span", { "data-line-new-num": lineNumber, className: "inline-block w-[50%]" }, lineNumber))),
|
|
3333
1333
|
React__namespace.createElement("td", { className: "diff-line-content pr-[10px] align-top", style: { backgroundColor: `var(${addContentBGName})` } },
|
|
3334
1334
|
React__namespace.createElement(DiffContent, { enableWrap: enableWrap, diffFile: diffFile, enableHighlight: enableHighlight, rawLine: rawLine, diffLine: diffLine, syntaxLine: syntaxLine }))));
|
|
@@ -3345,7 +1345,7 @@ const _DiffUnifiedLine = React.memo(({ index, diffFile, lineNumber }) => {
|
|
|
3345
1345
|
const { useWidget } = useDiffWidgetContext();
|
|
3346
1346
|
const setWidget = useWidget.getReadonlyState().setWidget;
|
|
3347
1347
|
const hasDiff = unifiedLine.diff;
|
|
3348
|
-
const hasChange = checkDiffLineIncludeChange(unifiedLine.diff);
|
|
1348
|
+
const hasChange = core.checkDiffLineIncludeChange(unifiedLine.diff);
|
|
3349
1349
|
const rawLine = unifiedLine.value || "";
|
|
3350
1350
|
const diffLine = unifiedLine.diff;
|
|
3351
1351
|
const newLineNumber = unifiedLine.newLineNumber;
|
|
@@ -3365,11 +1365,11 @@ const _DiffUnifiedLine = React.memo(({ index, diffFile, lineNumber }) => {
|
|
|
3365
1365
|
}
|
|
3366
1366
|
else {
|
|
3367
1367
|
return (React__namespace.createElement("tr", { "data-line": lineNumber, "data-state": unifiedLine.diff ? "diff" : "plain", className: "diff-line group" },
|
|
3368
|
-
React__namespace.createElement("td", { className: "diff-line-num sticky left-0
|
|
1368
|
+
React__namespace.createElement("td", { className: "diff-line-num sticky left-0 w-[1%] min-w-[100px] select-none whitespace-nowrap pl-[10px] pr-[10px] text-right align-top", style: {
|
|
3369
1369
|
color: `var(${plainLineNumberColorName})`,
|
|
3370
|
-
width: `calc(calc(var(${
|
|
3371
|
-
maxWidth: `calc(calc(var(${
|
|
3372
|
-
minWidth: `calc(calc(var(${
|
|
1370
|
+
width: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
|
|
1371
|
+
maxWidth: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
|
|
1372
|
+
minWidth: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
|
|
3373
1373
|
backgroundColor: hasDiff ? `var(${plainLineNumberBGName})` : `var(${expandContentBGName})`,
|
|
3374
1374
|
} },
|
|
3375
1375
|
enableAddWidget && hasDiff && (React__namespace.createElement(DiffUnifiedAddWidget, { index: index, diffFile: diffFile, lineNumber: unifiedLine.newLineNumber, side: exports.SplitSide.new, onWidgetClick: (...props) => { var _a; return (_a = onAddWidgetClick.current) === null || _a === void 0 ? void 0 : _a.call(onAddWidgetClick, ...props); }, onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber, side }) })),
|
|
@@ -3436,22 +1436,13 @@ const onMouseDown = (e) => {
|
|
|
3436
1436
|
};
|
|
3437
1437
|
const DiffUnifiedView = React.memo(({ diffFile }) => {
|
|
3438
1438
|
const { useDiffContext } = useDiffViewContext();
|
|
1439
|
+
const useDiffContextRef = React.useRef(useDiffContext);
|
|
1440
|
+
useDiffContextRef.current = useDiffContext;
|
|
3439
1441
|
// performance optimization
|
|
3440
|
-
const useWidget = React.useMemo(() =>
|
|
3441
|
-
const widgetSide = reactivityStore.ref(undefined);
|
|
3442
|
-
const widgetLineNumber = reactivityStore.ref(undefined);
|
|
3443
|
-
const setWidget = ({ side, lineNumber }) => {
|
|
3444
|
-
const { renderWidgetLine } = useDiffContext.getReadonlyState();
|
|
3445
|
-
if (typeof renderWidgetLine !== "function")
|
|
3446
|
-
return;
|
|
3447
|
-
widgetSide.value = side;
|
|
3448
|
-
widgetLineNumber.value = lineNumber;
|
|
3449
|
-
};
|
|
3450
|
-
return { widgetSide, widgetLineNumber, setWidget };
|
|
3451
|
-
}), [useDiffContext]);
|
|
1442
|
+
const useWidget = React.useMemo(() => createDiffWidgetStore(useDiffContextRef), []);
|
|
3452
1443
|
const contextValue = React.useMemo(() => ({ useWidget }), [useWidget]);
|
|
3453
1444
|
const fontSize = useDiffContext(React.useCallback((s) => s.fontSize, []));
|
|
3454
|
-
|
|
1445
|
+
index_js.useSyncExternalStore(diffFile.subscribe, diffFile.getUpdateCount);
|
|
3455
1446
|
React.useEffect(() => {
|
|
3456
1447
|
const { setWidget } = useWidget.getReadonlyState();
|
|
3457
1448
|
setWidget({});
|
|
@@ -3459,19 +1450,19 @@ const DiffUnifiedView = React.memo(({ diffFile }) => {
|
|
|
3459
1450
|
const unifiedLineLength = Math.max(diffFile.unifiedLineLength, diffFile.fileLineLength);
|
|
3460
1451
|
const _width = useTextWidth({
|
|
3461
1452
|
text: unifiedLineLength.toString(),
|
|
3462
|
-
font: { fontSize: fontSize + "px", fontFamily: "Menlo, Consolas, monospace" },
|
|
1453
|
+
font: React.useMemo(() => ({ fontSize: fontSize + "px", fontFamily: "Menlo, Consolas, monospace" }), [fontSize]),
|
|
3463
1454
|
});
|
|
3464
|
-
const width = Math.max(40, _width +
|
|
3465
|
-
const lines = getUnifiedContentLine(diffFile);
|
|
1455
|
+
const width = Math.max(40, _width + 10);
|
|
1456
|
+
const lines = core.getUnifiedContentLine(diffFile);
|
|
3466
1457
|
return (React__namespace.createElement(DiffWidgetContext.Provider, { value: contextValue },
|
|
3467
1458
|
React__namespace.createElement("div", { className: "unified-diff-view w-full" },
|
|
3468
|
-
React__namespace.createElement("div", { className: "unified-diff-table-wrapper overflow-x-auto overflow-y-hidden
|
|
1459
|
+
React__namespace.createElement("div", { className: "unified-diff-table-wrapper scrollbar-hide scrollbar-disable w-full overflow-x-auto overflow-y-hidden", style: {
|
|
3469
1460
|
// @ts-ignore
|
|
3470
|
-
[
|
|
1461
|
+
[diffAsideWidthName]: `${Math.round(width)}px`,
|
|
3471
1462
|
fontFamily: "Menlo, Consolas, monospace",
|
|
3472
1463
|
fontSize: `var(${diffFontSizeName})`,
|
|
3473
1464
|
} },
|
|
3474
|
-
React__namespace.createElement("table", { className: "unified-diff-table border-collapse
|
|
1465
|
+
React__namespace.createElement("table", { className: "unified-diff-table w-full border-collapse" },
|
|
3475
1466
|
React__namespace.createElement("colgroup", null,
|
|
3476
1467
|
React__namespace.createElement("col", { className: "unified-diff-table-num-col" }),
|
|
3477
1468
|
React__namespace.createElement("col", { className: "unified-diff-table-content-col" })),
|
|
@@ -3489,8 +1480,7 @@ const DiffUnifiedView = React.memo(({ diffFile }) => {
|
|
|
3489
1480
|
});
|
|
3490
1481
|
DiffUnifiedView.displayName = "DiffUnifiedView";
|
|
3491
1482
|
|
|
3492
|
-
|
|
3493
|
-
_cacheMap.name = "@git-diff-view/react";
|
|
1483
|
+
core._cacheMap.name = "@git-diff-view/react";
|
|
3494
1484
|
exports.SplitSide = void 0;
|
|
3495
1485
|
(function (SplitSide) {
|
|
3496
1486
|
SplitSide[SplitSide["old"] = 1] = "old";
|
|
@@ -3500,76 +1490,7 @@ const _InternalDiffView = (props) => {
|
|
|
3500
1490
|
const { diffFile, className, style, diffViewMode, diffViewWrap, diffViewFontSize, diffViewHighlight, renderWidgetLine, renderExtendLine, extendData, diffViewAddWidget, onAddWidgetClick, } = props;
|
|
3501
1491
|
const diffFileId = React.useMemo(() => diffFile.getId(), [diffFile]);
|
|
3502
1492
|
// performance optimization
|
|
3503
|
-
const useDiffContext = React.useMemo(() =>
|
|
3504
|
-
var _a, _b;
|
|
3505
|
-
const id = reactivityStore.ref(diffFileId);
|
|
3506
|
-
const setId = (_id) => (id.value = _id);
|
|
3507
|
-
const mode = reactivityStore.ref(props.diffViewMode);
|
|
3508
|
-
const setMode = (_mode) => (mode.value = _mode);
|
|
3509
|
-
const enableWrap = reactivityStore.ref(props.diffViewWrap);
|
|
3510
|
-
const setEnableWrap = (_enableWrap) => (enableWrap.value = _enableWrap);
|
|
3511
|
-
const enableAddWidget = reactivityStore.ref(props.diffViewAddWidget);
|
|
3512
|
-
const setEnableAddWidget = (_enableAddWidget) => (enableAddWidget.value = _enableAddWidget);
|
|
3513
|
-
const enableHighlight = reactivityStore.ref(props.diffViewHighlight);
|
|
3514
|
-
const setEnableHighlight = (_enableHighlight) => (enableHighlight.value = _enableHighlight);
|
|
3515
|
-
const fontSize = reactivityStore.ref(props.diffViewFontSize);
|
|
3516
|
-
const setFontSize = (_fontSize) => (fontSize.value = _fontSize);
|
|
3517
|
-
const extendData = reactivityStore.ref({
|
|
3518
|
-
oldFile: Object.assign({}, (_a = props.extendData) === null || _a === void 0 ? void 0 : _a.oldFile),
|
|
3519
|
-
newFile: Object.assign({}, (_b = props.extendData) === null || _b === void 0 ? void 0 : _b.newFile),
|
|
3520
|
-
});
|
|
3521
|
-
const setExtendData = (_extendData) => {
|
|
3522
|
-
const existOldKeys = Object.keys(extendData.value.oldFile || {});
|
|
3523
|
-
const inComingOldKeys = Object.keys(_extendData.oldFile || {});
|
|
3524
|
-
for (const key of existOldKeys) {
|
|
3525
|
-
if (!inComingOldKeys.includes(key)) {
|
|
3526
|
-
delete extendData.value.oldFile[key];
|
|
3527
|
-
}
|
|
3528
|
-
}
|
|
3529
|
-
for (const key of inComingOldKeys) {
|
|
3530
|
-
extendData.value.oldFile[key] = _extendData.oldFile[key];
|
|
3531
|
-
}
|
|
3532
|
-
const existNewKeys = Object.keys(extendData.value.newFile || {});
|
|
3533
|
-
const inComingNewKeys = Object.keys(_extendData.newFile || {});
|
|
3534
|
-
for (const key of existNewKeys) {
|
|
3535
|
-
if (!inComingNewKeys.includes(key)) {
|
|
3536
|
-
delete extendData.value.newFile[key];
|
|
3537
|
-
}
|
|
3538
|
-
}
|
|
3539
|
-
for (const key of inComingNewKeys) {
|
|
3540
|
-
extendData.value.newFile[key] = _extendData.newFile[key];
|
|
3541
|
-
}
|
|
3542
|
-
};
|
|
3543
|
-
const renderWidgetLine = reactivityStore.ref(props.renderWidgetLine);
|
|
3544
|
-
const setRenderWidgetLine = (_renderWidgetLine) => (renderWidgetLine.value = _renderWidgetLine);
|
|
3545
|
-
const renderExtendLine = reactivityStore.ref(props.renderExtendLine);
|
|
3546
|
-
const setRenderExtendLine = (_renderExtendLine) => (renderExtendLine.value = _renderExtendLine);
|
|
3547
|
-
// 避免无意义的订阅
|
|
3548
|
-
const onAddWidgetClick = reactivityStore.ref(reactivityStore.markRaw({ current: props.onAddWidgetClick }));
|
|
3549
|
-
const setOnAddWidgetClick = (_onAddWidgetClick) => (onAddWidgetClick.value.current = _onAddWidgetClick.current);
|
|
3550
|
-
return {
|
|
3551
|
-
id,
|
|
3552
|
-
setId,
|
|
3553
|
-
mode,
|
|
3554
|
-
setMode,
|
|
3555
|
-
enableWrap,
|
|
3556
|
-
setEnableWrap,
|
|
3557
|
-
enableAddWidget,
|
|
3558
|
-
setEnableAddWidget,
|
|
3559
|
-
enableHighlight,
|
|
3560
|
-
setEnableHighlight,
|
|
3561
|
-
fontSize,
|
|
3562
|
-
setFontSize,
|
|
3563
|
-
extendData,
|
|
3564
|
-
setExtendData,
|
|
3565
|
-
renderWidgetLine,
|
|
3566
|
-
setRenderWidgetLine,
|
|
3567
|
-
renderExtendLine,
|
|
3568
|
-
setRenderExtendLine,
|
|
3569
|
-
onAddWidgetClick,
|
|
3570
|
-
setOnAddWidgetClick,
|
|
3571
|
-
};
|
|
3572
|
-
}),
|
|
1493
|
+
const useDiffContext = React.useMemo(() => createDiffConfigStore(props, diffFileId),
|
|
3573
1494
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3574
1495
|
[]);
|
|
3575
1496
|
React.useEffect(() => {
|
|
@@ -3599,7 +1520,7 @@ const _InternalDiffView = (props) => {
|
|
|
3599
1520
|
]);
|
|
3600
1521
|
const value = React.useMemo(() => ({ useDiffContext }), [useDiffContext]);
|
|
3601
1522
|
return (React__namespace.createElement(DiffViewContext.Provider, { value: value },
|
|
3602
|
-
React__namespace.createElement("div", { className: "diff-tailwindcss-wrapper", "data-component": "git-diff-view", "data-version": `${"0.0.
|
|
1523
|
+
React__namespace.createElement("div", { className: "diff-tailwindcss-wrapper", "data-component": "git-diff-view", "data-version": `${"0.0.15"}`, "data-highlighter": diffFile._getHighlighterName() },
|
|
3603
1524
|
React__namespace.createElement("div", { className: "diff-style-root", style: {
|
|
3604
1525
|
// @ts-ignore
|
|
3605
1526
|
[diffFontSizeName]: diffViewFontSize + "px",
|
|
@@ -3608,19 +1529,25 @@ const _InternalDiffView = (props) => {
|
|
|
3608
1529
|
};
|
|
3609
1530
|
const InternalDiffView = React.memo(_InternalDiffView);
|
|
3610
1531
|
const DiffViewWithRef = (props, ref) => {
|
|
1532
|
+
var _a, _b;
|
|
3611
1533
|
const { registerHighlighter, data, diffFile: _diffFile } = props, restProps = __rest(props, ["registerHighlighter", "data", "diffFile"]);
|
|
3612
1534
|
const diffFile = React.useMemo(() => {
|
|
3613
1535
|
var _a, _b, _c, _d, _e, _f;
|
|
3614
1536
|
if (_diffFile) {
|
|
3615
|
-
const diffFile = DiffFile.createInstance({});
|
|
1537
|
+
const diffFile = core.DiffFile.createInstance({});
|
|
3616
1538
|
diffFile._mergeFullBundle(_diffFile._getFullBundle());
|
|
3617
1539
|
return diffFile;
|
|
3618
1540
|
}
|
|
3619
1541
|
else if (data) {
|
|
3620
|
-
return new DiffFile(((_a = data === null || data === void 0 ? void 0 : data.oldFile) === null || _a === void 0 ? void 0 : _a.fileName) || "", ((_b = data === null || data === void 0 ? void 0 : data.oldFile) === null || _b === void 0 ? void 0 : _b.content) || "", ((_c = data === null || data === void 0 ? void 0 : data.newFile) === null || _c === void 0 ? void 0 : _c.fileName) || "", ((_d = data === null || data === void 0 ? void 0 : data.newFile) === null || _d === void 0 ? void 0 : _d.content) || "", (data === null || data === void 0 ? void 0 : data.hunks) || [], ((_e = data === null || data === void 0 ? void 0 : data.oldFile) === null || _e === void 0 ? void 0 : _e.fileLang) || "", ((_f = data === null || data === void 0 ? void 0 : data.newFile) === null || _f === void 0 ? void 0 : _f.fileLang) || "");
|
|
1542
|
+
return new core.DiffFile(((_a = data === null || data === void 0 ? void 0 : data.oldFile) === null || _a === void 0 ? void 0 : _a.fileName) || "", ((_b = data === null || data === void 0 ? void 0 : data.oldFile) === null || _b === void 0 ? void 0 : _b.content) || "", ((_c = data === null || data === void 0 ? void 0 : data.newFile) === null || _c === void 0 ? void 0 : _c.fileName) || "", ((_d = data === null || data === void 0 ? void 0 : data.newFile) === null || _d === void 0 ? void 0 : _d.content) || "", (data === null || data === void 0 ? void 0 : data.hunks) || [], ((_e = data === null || data === void 0 ? void 0 : data.oldFile) === null || _e === void 0 ? void 0 : _e.fileLang) || "", ((_f = data === null || data === void 0 ? void 0 : data.newFile) === null || _f === void 0 ? void 0 : _f.fileLang) || "");
|
|
3621
1543
|
}
|
|
3622
1544
|
return null;
|
|
3623
1545
|
}, [data, _diffFile]);
|
|
1546
|
+
const diffFileRef = React.useRef(diffFile);
|
|
1547
|
+
if (diffFileRef.current && diffFileRef.current !== diffFile) {
|
|
1548
|
+
(_b = (_a = diffFileRef.current)._destroy) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
1549
|
+
diffFileRef.current = diffFile;
|
|
1550
|
+
}
|
|
3624
1551
|
React.useEffect(() => {
|
|
3625
1552
|
if (!diffFile)
|
|
3626
1553
|
return;
|
|
@@ -3644,7 +1571,7 @@ const DiffViewWithRef = (props, ref) => {
|
|
|
3644
1571
|
};
|
|
3645
1572
|
}
|
|
3646
1573
|
}, [diffFile, _diffFile]);
|
|
3647
|
-
useUnmount(() => diffFile._destroy(), [diffFile]);
|
|
1574
|
+
useUnmount(() => { var _a; return (_a = diffFile === null || diffFile === void 0 ? void 0 : diffFile._destroy) === null || _a === void 0 ? void 0 : _a.call(diffFile); }, [diffFile]);
|
|
3648
1575
|
React.useImperativeHandle(ref, () => ({ getDiffFileInstance: () => diffFile }), [diffFile]);
|
|
3649
1576
|
if (!diffFile)
|
|
3650
1577
|
return null;
|
|
@@ -3652,39 +1579,16 @@ const DiffViewWithRef = (props, ref) => {
|
|
|
3652
1579
|
};
|
|
3653
1580
|
const DiffView = React.forwardRef(DiffViewWithRef);
|
|
3654
1581
|
DiffView.displayName = "DiffView";
|
|
3655
|
-
const version = "0.0.
|
|
1582
|
+
const version = "0.0.15";
|
|
3656
1583
|
|
|
3657
|
-
exports.DefaultDiffExpansionStep = DefaultDiffExpansionStep;
|
|
3658
|
-
exports.DiffFile = DiffFile;
|
|
3659
|
-
exports.DiffHunk = DiffHunk;
|
|
3660
|
-
exports.DiffHunkHeader = DiffHunkHeader;
|
|
3661
|
-
exports.DiffLine = DiffLine;
|
|
3662
|
-
exports.DiffParser = DiffParser;
|
|
3663
1584
|
exports.DiffView = DiffView;
|
|
3664
1585
|
exports.DiffViewContext = DiffViewContext;
|
|
3665
|
-
exports.File = File;
|
|
3666
|
-
exports.HiddenBidiCharsRegex = HiddenBidiCharsRegex;
|
|
3667
|
-
exports._cacheMap = _cacheMap;
|
|
3668
|
-
exports.assertNever = assertNever;
|
|
3669
|
-
exports.checkDiffLineIncludeChange = checkDiffLineIncludeChange;
|
|
3670
|
-
exports.composeLen = composeLen;
|
|
3671
|
-
exports.diffFontSizeName = diffFontSizeName;
|
|
3672
|
-
exports.getDiffRange = getDiffRange;
|
|
3673
|
-
exports.getFile = getFile;
|
|
3674
|
-
exports.getHunkHeaderExpansionType = getHunkHeaderExpansionType;
|
|
3675
|
-
exports.getLang = getLang;
|
|
3676
|
-
exports.getLargestLineNumber = getLargestLineNumber;
|
|
3677
|
-
exports.getSplitContentLines = getSplitContentLines;
|
|
3678
|
-
exports.getSplitLines = getSplitLines;
|
|
3679
|
-
exports.getUnifiedContentLine = getUnifiedContentLine;
|
|
3680
|
-
exports.getUnifiedLines = getUnifiedLines;
|
|
3681
|
-
exports.hasRelativeChange = hasRelativeChange;
|
|
3682
|
-
exports.highlighter = highlighter;
|
|
3683
|
-
exports.numIterator = numIterator;
|
|
3684
|
-
exports.parseInstance = parseInstance;
|
|
3685
|
-
exports.processAST = processAST;
|
|
3686
|
-
exports.relativeChanges = relativeChanges;
|
|
3687
1586
|
exports.useDiffViewContext = useDiffViewContext;
|
|
3688
1587
|
exports.version = version;
|
|
3689
|
-
|
|
1588
|
+
Object.keys(core).forEach(function (k) {
|
|
1589
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
1590
|
+
enumerable: true,
|
|
1591
|
+
get: function () { return core[k]; }
|
|
1592
|
+
});
|
|
1593
|
+
});
|
|
3690
1594
|
//# sourceMappingURL=index.development.js.map
|