@git-diff-view/react 0.0.8 → 0.0.9
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 +294 -225
- package/dist/cjs/index.development.js.map +1 -1
- package/dist/cjs/index.production.js +286 -218
- package/dist/cjs/index.production.js.map +1 -1
- package/dist/css/diff-view.css +1 -1
- package/dist/esm/index.mjs +296 -228
- package/dist/esm/index.mjs.map +1 -1
- package/dist/types/components/DiffContent.d.ts.map +1 -1
- package/dist/types/components/DiffSplitExtendLineNormal.d.ts.map +1 -1
- package/dist/types/components/DiffSplitExtendLineWrap.d.ts.map +1 -1
- package/dist/types/components/DiffSplitView.d.ts.map +1 -1
- package/dist/types/components/DiffSplitViewNormal.d.ts.map +1 -1
- package/dist/types/components/DiffSplitViewWrap.d.ts.map +1 -1
- package/dist/types/components/DiffSplitWidgetLineWrap.d.ts.map +1 -1
- package/dist/types/components/DiffUnifiedExtendLine.d.ts.map +1 -1
- package/dist/types/components/DiffView.d.ts +0 -1
- package/dist/types/components/DiffView.d.ts.map +1 -1
- package/dist/types/components/DiffViewContext.d.ts +6 -2
- package/dist/types/components/DiffViewContext.d.ts.map +1 -1
- package/dist/types/components/tools.d.ts +1 -0
- package/dist/types/components/tools.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -107,34 +107,83 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
107
107
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
108
108
|
};
|
|
109
109
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
}
|
|
135
|
-
|
|
110
|
+
const processAST = (ast) => {
|
|
111
|
+
let lineNumber = 1;
|
|
112
|
+
const syntaxObj = {};
|
|
113
|
+
const loopAST = (nodes, wrapper) => {
|
|
114
|
+
nodes.forEach((node) => {
|
|
115
|
+
if (node.type === "text") {
|
|
116
|
+
if (node.value.indexOf("\n") === -1) {
|
|
117
|
+
const valueLength = node.value.length;
|
|
118
|
+
if (!syntaxObj[lineNumber]) {
|
|
119
|
+
node.startIndex = 0;
|
|
120
|
+
node.endIndex = valueLength - 1;
|
|
121
|
+
const item = {
|
|
122
|
+
value: node.value,
|
|
123
|
+
lineNumber,
|
|
124
|
+
valueLength,
|
|
125
|
+
nodeList: [{ node, wrapper }],
|
|
126
|
+
};
|
|
127
|
+
syntaxObj[lineNumber] = item;
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
node.startIndex = syntaxObj[lineNumber].valueLength;
|
|
131
|
+
node.endIndex = node.startIndex + valueLength - 1;
|
|
132
|
+
syntaxObj[lineNumber].value += node.value;
|
|
133
|
+
syntaxObj[lineNumber].valueLength += valueLength;
|
|
134
|
+
syntaxObj[lineNumber].nodeList.push({ node, wrapper });
|
|
135
|
+
}
|
|
136
|
+
node.lineNumber = lineNumber;
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
const lines = node.value.split("\n");
|
|
140
|
+
node.children = node.children || [];
|
|
141
|
+
for (let i = 0; i < lines.length; i++) {
|
|
142
|
+
const _value = i === lines.length - 1 ? lines[i] : lines[i] + "\n";
|
|
143
|
+
const _lineNumber = i === 0 ? lineNumber : ++lineNumber;
|
|
144
|
+
const _valueLength = _value.length;
|
|
145
|
+
const _node = {
|
|
146
|
+
type: "text",
|
|
147
|
+
value: _value,
|
|
148
|
+
startIndex: Infinity,
|
|
149
|
+
endIndex: Infinity,
|
|
150
|
+
lineNumber: _lineNumber,
|
|
151
|
+
};
|
|
152
|
+
if (!syntaxObj[_lineNumber]) {
|
|
153
|
+
_node.startIndex = 0;
|
|
154
|
+
_node.endIndex = _valueLength - 1;
|
|
155
|
+
const item = {
|
|
156
|
+
value: _value,
|
|
157
|
+
lineNumber: _lineNumber,
|
|
158
|
+
valueLength: _valueLength,
|
|
159
|
+
nodeList: [{ node: _node, wrapper }],
|
|
160
|
+
};
|
|
161
|
+
syntaxObj[_lineNumber] = item;
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
_node.startIndex = syntaxObj[_lineNumber].valueLength;
|
|
165
|
+
_node.endIndex = _node.startIndex + _valueLength - 1;
|
|
166
|
+
syntaxObj[_lineNumber].value += _value;
|
|
167
|
+
syntaxObj[_lineNumber].valueLength += _valueLength;
|
|
168
|
+
syntaxObj[_lineNumber].nodeList.push({ node: _node, wrapper });
|
|
169
|
+
}
|
|
170
|
+
node.children.push(_node);
|
|
171
|
+
}
|
|
172
|
+
node.lineNumber = lineNumber;
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
if (node.children) {
|
|
176
|
+
loopAST(node.children, node);
|
|
177
|
+
node.lineNumber = lineNumber;
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
};
|
|
181
|
+
loopAST(ast.children);
|
|
182
|
+
return { syntaxFileObject: syntaxObj, syntaxFileLineNumber: lineNumber };
|
|
183
|
+
};
|
|
136
184
|
|
|
137
185
|
const lowlight = lowlight$1.createLowlight(lowlight$1.all);
|
|
186
|
+
// !SEE https://github.com/highlightjs/highlightjs-vue
|
|
138
187
|
lowlight.register("vue", function hljsDefineVue(hljs) {
|
|
139
188
|
return {
|
|
140
189
|
subLanguage: "xml",
|
|
@@ -180,50 +229,95 @@ lowlight.register("vue", function hljsDefineVue(hljs) {
|
|
|
180
229
|
],
|
|
181
230
|
};
|
|
182
231
|
});
|
|
183
|
-
const
|
|
184
|
-
let _autoDetectLang = true;
|
|
232
|
+
const instance = { name: "lowlight" };
|
|
185
233
|
let _maxLineToIgnoreSyntax = 2000;
|
|
186
234
|
const _ignoreSyntaxHighlightList = [];
|
|
187
|
-
Object.defineProperty(
|
|
235
|
+
Object.defineProperty(instance, "maxLineToIgnoreSyntax", {
|
|
188
236
|
get: () => _maxLineToIgnoreSyntax,
|
|
189
237
|
});
|
|
190
|
-
Object.defineProperty(
|
|
238
|
+
Object.defineProperty(instance, "setMaxLineToIgnoreSyntax", {
|
|
191
239
|
value: (v) => {
|
|
192
240
|
_maxLineToIgnoreSyntax = v;
|
|
193
241
|
},
|
|
194
242
|
});
|
|
195
|
-
Object.defineProperty(
|
|
196
|
-
get: () => _autoDetectLang,
|
|
197
|
-
});
|
|
198
|
-
Object.defineProperty(highlighter, "setAutoDetectLang", {
|
|
199
|
-
value: (v) => {
|
|
200
|
-
_autoDetectLang = v;
|
|
201
|
-
},
|
|
202
|
-
});
|
|
203
|
-
Object.defineProperty(highlighter, "ignoreSyntaxHighlightList", {
|
|
243
|
+
Object.defineProperty(instance, "ignoreSyntaxHighlightList", {
|
|
204
244
|
get: () => _ignoreSyntaxHighlightList,
|
|
205
245
|
});
|
|
206
|
-
Object.defineProperty(
|
|
246
|
+
Object.defineProperty(instance, "setIgnoreSyntaxHighlightList", {
|
|
207
247
|
value: (v) => {
|
|
208
248
|
_ignoreSyntaxHighlightList.length = 0;
|
|
209
249
|
_ignoreSyntaxHighlightList.push(...v);
|
|
210
250
|
},
|
|
211
251
|
});
|
|
252
|
+
Object.defineProperty(instance, "getAST", {
|
|
253
|
+
value: (raw, fileName, lang) => {
|
|
254
|
+
let hasRegisteredLang = true;
|
|
255
|
+
if (!lowlight.registered(lang)) {
|
|
256
|
+
console.warn(`not support current lang: ${lang} yet`);
|
|
257
|
+
hasRegisteredLang = false;
|
|
258
|
+
}
|
|
259
|
+
if (fileName &&
|
|
260
|
+
highlighter.ignoreSyntaxHighlightList.some((item) => item instanceof RegExp ? item.test(fileName) : fileName === item)) {
|
|
261
|
+
console.warn(`ignore syntax for current file, because the fileName is in the ignoreSyntaxHighlightList: ${fileName}`);
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
if (hasRegisteredLang) {
|
|
265
|
+
return lowlight.highlight(lang, raw);
|
|
266
|
+
}
|
|
267
|
+
else {
|
|
268
|
+
return lowlight.highlightAuto(raw);
|
|
269
|
+
}
|
|
270
|
+
},
|
|
271
|
+
});
|
|
272
|
+
Object.defineProperty(instance, "processAST", {
|
|
273
|
+
value: (ast) => {
|
|
274
|
+
return processAST(ast);
|
|
275
|
+
},
|
|
276
|
+
});
|
|
277
|
+
const highlighter = instance;
|
|
212
278
|
|
|
213
|
-
var
|
|
279
|
+
var _Cache_keyArray, _Cache_maxLength;
|
|
280
|
+
class Cache extends Map {
|
|
281
|
+
constructor() {
|
|
282
|
+
super(...arguments);
|
|
283
|
+
_Cache_keyArray.set(this, []);
|
|
284
|
+
_Cache_maxLength.set(this, 30);
|
|
285
|
+
}
|
|
286
|
+
setMaxLength(length) {
|
|
287
|
+
__classPrivateFieldSet(this, _Cache_maxLength, length, "f");
|
|
288
|
+
this._checkLength();
|
|
289
|
+
}
|
|
290
|
+
set(key, value) {
|
|
291
|
+
if (this.has(key))
|
|
292
|
+
return this;
|
|
293
|
+
__classPrivateFieldGet(this, _Cache_keyArray, "f").push(key);
|
|
294
|
+
this._checkLength();
|
|
295
|
+
return super.set(key, value);
|
|
296
|
+
}
|
|
297
|
+
_checkLength() {
|
|
298
|
+
while (__classPrivateFieldGet(this, _Cache_keyArray, "f").length > __classPrivateFieldGet(this, _Cache_maxLength, "f")) {
|
|
299
|
+
const key = __classPrivateFieldGet(this, _Cache_keyArray, "f").shift();
|
|
300
|
+
this.delete(key);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
_Cache_keyArray = new WeakMap(), _Cache_maxLength = new WeakMap();
|
|
305
|
+
|
|
306
|
+
var _File_instances, _File_doCheck;
|
|
214
307
|
const map = new Cache();
|
|
308
|
+
const devKey = "@git-diff-cache";
|
|
215
309
|
map.setMaxLength(50);
|
|
216
310
|
map.name = "@git-diff-view/core";
|
|
217
311
|
if (typeof globalThis !== "undefined") {
|
|
218
|
-
if (Array.isArray(globalThis
|
|
219
|
-
globalThis
|
|
220
|
-
if (globalThis.
|
|
312
|
+
if (Array.isArray(globalThis[devKey])) {
|
|
313
|
+
globalThis[devKey] = globalThis[devKey].filter((i) => i !== map);
|
|
314
|
+
if (globalThis[devKey].length > 0) {
|
|
221
315
|
console.warn("there are multiple instance of @git-diff-view/core in the one environment!");
|
|
222
316
|
}
|
|
223
|
-
globalThis.
|
|
317
|
+
globalThis[devKey].push(map);
|
|
224
318
|
}
|
|
225
319
|
else {
|
|
226
|
-
globalThis
|
|
320
|
+
globalThis[devKey] = [map];
|
|
227
321
|
}
|
|
228
322
|
}
|
|
229
323
|
class File {
|
|
@@ -239,38 +333,25 @@ class File {
|
|
|
239
333
|
this.maxLineNumber = 0;
|
|
240
334
|
Object.defineProperty(this, "__v_skip", { value: true });
|
|
241
335
|
}
|
|
242
|
-
doSyntax({
|
|
336
|
+
doSyntax({ registerHighlighter }) {
|
|
243
337
|
if (!this.raw || this.hasDoSyntax)
|
|
244
338
|
return;
|
|
245
|
-
let hasRegisteredLang = true;
|
|
246
339
|
const _highlighter = registerHighlighter || highlighter;
|
|
247
340
|
if (this.syntaxLength) {
|
|
248
341
|
console.error("current file already doSyntax before!");
|
|
249
342
|
return;
|
|
250
343
|
}
|
|
251
|
-
if (!_highlighter.registered(this.lang)) {
|
|
252
|
-
hasRegisteredLang = false;
|
|
253
|
-
if (!autoDetectLang) {
|
|
254
|
-
console.warn(`not support current lang: ${this.lang} yet`);
|
|
255
|
-
return;
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
344
|
if (this.rawLength > _highlighter.maxLineToIgnoreSyntax) {
|
|
259
345
|
console.warn(`ignore syntax for current file, because the rawLength is too long: ${this.rawLength}`);
|
|
260
346
|
return;
|
|
261
347
|
}
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
console.warn(`ignore syntax for current file, because the fileName is in the ignoreSyntaxHighlightList: ${this.fileName}`);
|
|
348
|
+
this.ast = _highlighter.getAST(this.raw, this.fileName, this.lang);
|
|
349
|
+
if (!this.ast)
|
|
265
350
|
return;
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
else {
|
|
271
|
-
this.ast = _highlighter.highlightAuto(this.raw);
|
|
272
|
-
}
|
|
273
|
-
__classPrivateFieldGet(this, _File_instances, "m", _File_doAST).call(this);
|
|
351
|
+
const { syntaxFileObject, syntaxFileLineNumber } = _highlighter.processAST(this.ast);
|
|
352
|
+
this.syntaxFile = syntaxFileObject;
|
|
353
|
+
this.syntaxLength = syntaxFileLineNumber;
|
|
354
|
+
this.highlighterName = _highlighter.name;
|
|
274
355
|
{
|
|
275
356
|
__classPrivateFieldGet(this, _File_instances, "m", _File_doCheck).call(this);
|
|
276
357
|
}
|
|
@@ -298,81 +379,7 @@ class File {
|
|
|
298
379
|
this.hasDoRaw = true;
|
|
299
380
|
}
|
|
300
381
|
}
|
|
301
|
-
_File_instances = new WeakSet(),
|
|
302
|
-
const ast = this.ast;
|
|
303
|
-
let lineNumber = 1;
|
|
304
|
-
const syntaxObj = this.syntaxFile;
|
|
305
|
-
const loopAST = (nodes, wrapper) => {
|
|
306
|
-
nodes.forEach((node) => {
|
|
307
|
-
if (node.type === "text") {
|
|
308
|
-
if (node.value.indexOf("\n") === -1) {
|
|
309
|
-
const valueLength = node.value.length;
|
|
310
|
-
if (!syntaxObj[lineNumber]) {
|
|
311
|
-
node.startIndex = 0;
|
|
312
|
-
node.endIndex = valueLength - 1;
|
|
313
|
-
const item = {
|
|
314
|
-
value: node.value,
|
|
315
|
-
lineNumber,
|
|
316
|
-
valueLength,
|
|
317
|
-
nodeList: [{ node, wrapper }],
|
|
318
|
-
};
|
|
319
|
-
syntaxObj[lineNumber] = item;
|
|
320
|
-
}
|
|
321
|
-
else {
|
|
322
|
-
node.startIndex = syntaxObj[lineNumber].valueLength;
|
|
323
|
-
node.endIndex = node.startIndex + valueLength - 1;
|
|
324
|
-
syntaxObj[lineNumber].value += node.value;
|
|
325
|
-
syntaxObj[lineNumber].valueLength += valueLength;
|
|
326
|
-
syntaxObj[lineNumber].nodeList.push({ node, wrapper });
|
|
327
|
-
}
|
|
328
|
-
node.lineNumber = lineNumber;
|
|
329
|
-
return;
|
|
330
|
-
}
|
|
331
|
-
const lines = node.value.split("\n");
|
|
332
|
-
node.children = node.children || [];
|
|
333
|
-
for (let i = 0; i < lines.length; i++) {
|
|
334
|
-
const _value = i === lines.length - 1 ? lines[i] : lines[i] + "\n";
|
|
335
|
-
const _lineNumber = i === 0 ? lineNumber : ++lineNumber;
|
|
336
|
-
const _valueLength = _value.length;
|
|
337
|
-
const _node = {
|
|
338
|
-
type: "text",
|
|
339
|
-
value: _value,
|
|
340
|
-
startIndex: Infinity,
|
|
341
|
-
endIndex: Infinity,
|
|
342
|
-
lineNumber: _lineNumber,
|
|
343
|
-
};
|
|
344
|
-
if (!syntaxObj[_lineNumber]) {
|
|
345
|
-
_node.startIndex = 0;
|
|
346
|
-
_node.endIndex = _valueLength - 1;
|
|
347
|
-
const item = {
|
|
348
|
-
value: _value,
|
|
349
|
-
lineNumber: _lineNumber,
|
|
350
|
-
valueLength: _valueLength,
|
|
351
|
-
nodeList: [{ node: _node, wrapper }],
|
|
352
|
-
};
|
|
353
|
-
syntaxObj[_lineNumber] = item;
|
|
354
|
-
}
|
|
355
|
-
else {
|
|
356
|
-
_node.startIndex = syntaxObj[_lineNumber].valueLength;
|
|
357
|
-
_node.endIndex = _node.startIndex + _valueLength - 1;
|
|
358
|
-
syntaxObj[_lineNumber].value += _value;
|
|
359
|
-
syntaxObj[_lineNumber].valueLength += _valueLength;
|
|
360
|
-
syntaxObj[_lineNumber].nodeList.push({ node: _node, wrapper });
|
|
361
|
-
}
|
|
362
|
-
node.children.push(_node);
|
|
363
|
-
}
|
|
364
|
-
node.lineNumber = lineNumber;
|
|
365
|
-
return;
|
|
366
|
-
}
|
|
367
|
-
if (node.children) {
|
|
368
|
-
loopAST(node.children, node);
|
|
369
|
-
node.lineNumber = lineNumber;
|
|
370
|
-
}
|
|
371
|
-
});
|
|
372
|
-
};
|
|
373
|
-
loopAST(ast.children);
|
|
374
|
-
this.syntaxLength = lineNumber;
|
|
375
|
-
}, _File_doCheck = function _File_doCheck() {
|
|
382
|
+
_File_instances = new WeakSet(), _File_doCheck = function _File_doCheck() {
|
|
376
383
|
if (this.rawLength && this.syntaxLength) {
|
|
377
384
|
if (this.rawLength !== this.syntaxLength) {
|
|
378
385
|
console.warn("the rawLength not match for the syntaxLength");
|
|
@@ -385,7 +392,7 @@ _File_instances = new WeakSet(), _File_doAST = function _File_doAST() {
|
|
|
385
392
|
}
|
|
386
393
|
};
|
|
387
394
|
const getFile = (raw, lang, fileName) => {
|
|
388
|
-
const key = raw + "--" + "0.0.
|
|
395
|
+
const key = raw + "--" + "0.0.9" + "--" + lang;
|
|
389
396
|
if (map.has(key))
|
|
390
397
|
return map.get(key);
|
|
391
398
|
const file = new File(raw, lang, fileName);
|
|
@@ -683,7 +690,7 @@ const getDiffRange = (additions, deletions) => {
|
|
|
683
690
|
};
|
|
684
691
|
|
|
685
692
|
/* eslint-disable max-lines */
|
|
686
|
-
//
|
|
693
|
+
// !NOTE: ALL of the diff parse logic copy from desktop, SEE https://github.com/desktop/desktop
|
|
687
694
|
// https://en.wikipedia.org/wiki/Diff_utility
|
|
688
695
|
//
|
|
689
696
|
// @@ -l,s +l,s @@ optional section heading
|
|
@@ -1013,7 +1020,9 @@ class DiffParser {
|
|
|
1013
1020
|
}
|
|
1014
1021
|
const parseInstance = new DiffParser();
|
|
1015
1022
|
|
|
1016
|
-
|
|
1023
|
+
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
1024
|
+
/* eslint-disable max-lines */
|
|
1025
|
+
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_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;
|
|
1017
1026
|
const composeLen = 40;
|
|
1018
1027
|
const idSet = new Set();
|
|
1019
1028
|
class DiffFile {
|
|
@@ -1054,7 +1063,8 @@ class DiffFile {
|
|
|
1054
1063
|
_DiffFile_hasBuildUnified.set(this, false);
|
|
1055
1064
|
_DiffFile_updateCount.set(this, 0);
|
|
1056
1065
|
_DiffFile_composeByDiff.set(this, false);
|
|
1057
|
-
this
|
|
1066
|
+
_DiffFile_highlighterName.set(this, void 0);
|
|
1067
|
+
this._version_ = "0.0.9";
|
|
1058
1068
|
this._oldFileContent = "";
|
|
1059
1069
|
this._oldFileLang = "";
|
|
1060
1070
|
this._newFileContent = "";
|
|
@@ -1314,6 +1324,7 @@ class DiffFile {
|
|
|
1314
1324
|
const splitLineLength = this.splitLineLength;
|
|
1315
1325
|
const unifiedLineLength = this.unifiedLineLength;
|
|
1316
1326
|
const composeByDiff = __classPrivateFieldGet(this, _DiffFile_composeByDiff, "f");
|
|
1327
|
+
const highlighterName = __classPrivateFieldGet(this, _DiffFile_highlighterName, "f");
|
|
1317
1328
|
const hasCollapsed = this.hasCollapsed;
|
|
1318
1329
|
// split
|
|
1319
1330
|
const splitLeftLines = __classPrivateFieldGet(this, _DiffFile_splitLeftLines, "f");
|
|
@@ -1343,6 +1354,7 @@ class DiffFile {
|
|
|
1343
1354
|
splitHunkLines,
|
|
1344
1355
|
unifiedLines,
|
|
1345
1356
|
unifiedHunkLines,
|
|
1357
|
+
highlighterName,
|
|
1346
1358
|
composeByDiff,
|
|
1347
1359
|
hasCollapsed,
|
|
1348
1360
|
version,
|
|
@@ -1354,6 +1366,7 @@ class DiffFile {
|
|
|
1354
1366
|
__classPrivateFieldSet(this, _DiffFile_hasBuildSplit, data.hasBuildSplit, "f");
|
|
1355
1367
|
__classPrivateFieldSet(this, _DiffFile_hasBuildUnified, data.hasBuildUnified, "f");
|
|
1356
1368
|
__classPrivateFieldSet(this, _DiffFile_composeByDiff, data.composeByDiff, "f");
|
|
1369
|
+
__classPrivateFieldSet(this, _DiffFile_highlighterName, data.highlighterName, "f");
|
|
1357
1370
|
__classPrivateFieldSet(this, _DiffFile_oldFileLines, data.oldFileLines, "f");
|
|
1358
1371
|
__classPrivateFieldSet(this, _DiffFile_oldFileDiffLines, data.oldFileDiffLines, "f");
|
|
1359
1372
|
__classPrivateFieldSet(this, _DiffFile_oldFileSyntaxLines, data.oldFileSyntaxLines, "f");
|
|
@@ -1375,6 +1388,7 @@ class DiffFile {
|
|
|
1375
1388
|
}
|
|
1376
1389
|
this.notifyAll();
|
|
1377
1390
|
};
|
|
1391
|
+
this._getHighlighterName = () => __classPrivateFieldGet(this, _DiffFile_highlighterName, "f");
|
|
1378
1392
|
this._getIsPureDiffRender = () => __classPrivateFieldGet(this, _DiffFile_composeByDiff, "f");
|
|
1379
1393
|
this._addClonedInstance = (instance) => {
|
|
1380
1394
|
const updateFunc = () => {
|
|
@@ -1483,10 +1497,12 @@ class DiffFile {
|
|
|
1483
1497
|
__classPrivateFieldGet(this, _DiffFile_instances, "m", _DiffFile_composeFile).call(this);
|
|
1484
1498
|
__classPrivateFieldSet(this, _DiffFile_hasInitRaw, true, "f");
|
|
1485
1499
|
}
|
|
1486
|
-
initSyntax({
|
|
1500
|
+
initSyntax({ registerHighlighter } = {}) {
|
|
1501
|
+
var _a, _b;
|
|
1487
1502
|
if (__classPrivateFieldGet(this, _DiffFile_hasInitSyntax, "f"))
|
|
1488
1503
|
return;
|
|
1489
|
-
__classPrivateFieldGet(this, _DiffFile_instances, "m", _DiffFile_composeSyntax).call(this, { registerHighlighter
|
|
1504
|
+
__classPrivateFieldGet(this, _DiffFile_instances, "m", _DiffFile_composeSyntax).call(this, { registerHighlighter });
|
|
1505
|
+
__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"), "f");
|
|
1490
1506
|
__classPrivateFieldSet(this, _DiffFile_hasInitSyntax, true, "f");
|
|
1491
1507
|
}
|
|
1492
1508
|
init() {
|
|
@@ -1764,7 +1780,7 @@ class DiffFile {
|
|
|
1764
1780
|
this.notifyAll();
|
|
1765
1781
|
}
|
|
1766
1782
|
}
|
|
1767
|
-
_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_id = new WeakMap(), _DiffFile_clonedInstance = new WeakMap(), _DiffFile_instances = new WeakSet(), _DiffFile_doDiff = function _DiffFile_doDiff() {
|
|
1783
|
+
_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_highlighterName = new WeakMap(), _DiffFile_id = new WeakMap(), _DiffFile_clonedInstance = new WeakMap(), _DiffFile_instances = new WeakSet(), _DiffFile_doDiff = function _DiffFile_doDiff() {
|
|
1768
1784
|
if (!this._diffList)
|
|
1769
1785
|
return;
|
|
1770
1786
|
__classPrivateFieldSet(this, _DiffFile_diffListResults, this._diffList.map((s) => parseInstance.parse(s)), "f");
|
|
@@ -1959,11 +1975,11 @@ _DiffFile_oldFileResult = new WeakMap(), _DiffFile_newFileResult = new WeakMap()
|
|
|
1959
1975
|
__classPrivateFieldGet(this, _DiffFile_newFileDiffLines, "f")[item.newLineNumber] = item;
|
|
1960
1976
|
}
|
|
1961
1977
|
});
|
|
1962
|
-
}, _DiffFile_composeSyntax = function _DiffFile_composeSyntax({
|
|
1978
|
+
}, _DiffFile_composeSyntax = function _DiffFile_composeSyntax({ registerHighlighter }) {
|
|
1963
1979
|
var _a, _b, _c, _d;
|
|
1964
|
-
(_a = __classPrivateFieldGet(this, _DiffFile_oldFileResult, "f")) === null || _a === void 0 ? void 0 : _a.doSyntax({
|
|
1980
|
+
(_a = __classPrivateFieldGet(this, _DiffFile_oldFileResult, "f")) === null || _a === void 0 ? void 0 : _a.doSyntax({ registerHighlighter });
|
|
1965
1981
|
__classPrivateFieldSet(this, _DiffFile_oldFileSyntaxLines, (_b = __classPrivateFieldGet(this, _DiffFile_oldFileResult, "f")) === null || _b === void 0 ? void 0 : _b.syntaxFile, "f");
|
|
1966
|
-
(_c = __classPrivateFieldGet(this, _DiffFile_newFileResult, "f")) === null || _c === void 0 ? void 0 : _c.doSyntax({
|
|
1982
|
+
(_c = __classPrivateFieldGet(this, _DiffFile_newFileResult, "f")) === null || _c === void 0 ? void 0 : _c.doSyntax({ registerHighlighter });
|
|
1967
1983
|
__classPrivateFieldSet(this, _DiffFile_newFileSyntaxLines, (_d = __classPrivateFieldGet(this, _DiffFile_newFileResult, "f")) === null || _d === void 0 ? void 0 : _d.syntaxFile, "f");
|
|
1968
1984
|
}, _DiffFile_getOldDiffLine = function _DiffFile_getOldDiffLine(lineNumber) {
|
|
1969
1985
|
var _a;
|
|
@@ -2060,7 +2076,7 @@ const getUnifiedContentLine = (diffFile) => {
|
|
|
2060
2076
|
return lines.filter((line) => line.type === exports.DiffFileLineType.content);
|
|
2061
2077
|
};
|
|
2062
2078
|
|
|
2063
|
-
const versions = "0.0.
|
|
2079
|
+
const versions = "0.0.9";
|
|
2064
2080
|
|
|
2065
2081
|
const useUnmount = (cb, deps) => {
|
|
2066
2082
|
const ref = React.useRef(cb);
|
|
@@ -2241,14 +2257,11 @@ const getLineNumberBG = (isAdded, isDelete, hasDiff) => {
|
|
|
2241
2257
|
: `var(${expandContentBGName})`;
|
|
2242
2258
|
};
|
|
2243
2259
|
|
|
2244
|
-
const _DiffSplitExtendLine$1 = ({ index, diffFile, side, lineNumber, }) => {
|
|
2245
|
-
var _a, _b;
|
|
2260
|
+
const _DiffSplitExtendLine$1 = ({ index, diffFile, oldLineExtend, newLineExtend, side, lineNumber, }) => {
|
|
2246
2261
|
const { useDiffContext } = useDiffViewContext();
|
|
2247
|
-
const { extendData, renderExtendLine } = useDiffContext(React__namespace.useCallback((s) => ({ extendData: s.extendData, renderExtendLine: s.renderExtendLine }), []));
|
|
2248
2262
|
const oldLine = diffFile.getSplitLeftLine(index);
|
|
2249
2263
|
const newLine = diffFile.getSplitRightLine(index);
|
|
2250
|
-
const
|
|
2251
|
-
const newLineExtend = (_b = extendData === null || extendData === void 0 ? void 0 : extendData.newFile) === null || _b === void 0 ? void 0 : _b[newLine === null || newLine === void 0 ? void 0 : newLine.lineNumber];
|
|
2264
|
+
const renderExtendLine = useDiffContext(React__namespace.useCallback((s) => s.renderExtendLine, []));
|
|
2252
2265
|
const currentExtend = side === exports.SplitSide.old ? oldLineExtend : newLineExtend;
|
|
2253
2266
|
const currentLineNumber = side === exports.SplitSide.old ? oldLine.lineNumber : newLine.lineNumber;
|
|
2254
2267
|
const otherSide = side === exports.SplitSide.old ? exports.SplitSide.new : exports.SplitSide.old;
|
|
@@ -2265,6 +2278,7 @@ const _DiffSplitExtendLine$1 = ({ index, diffFile, side, lineNumber, }) => {
|
|
|
2265
2278
|
return null;
|
|
2266
2279
|
return (React__namespace.createElement("tr", { "data-line": `${lineNumber}-extend`, "data-state": "extend", "data-side": exports.SplitSide[side], className: "diff-line diff-line-extend" }, currentExtend ? (React__namespace.createElement("td", { className: `diff-line-extend-${exports.SplitSide[side]}-content p-0`, colSpan: 2 },
|
|
2267
2280
|
React__namespace.createElement("div", { className: "diff-line-extend-wrapper sticky left-0", style: { width } }, width > 0 &&
|
|
2281
|
+
(currentExtend === null || currentExtend === void 0 ? void 0 : currentExtend.data) &&
|
|
2268
2282
|
(renderExtendLine === null || renderExtendLine === void 0 ? void 0 : renderExtendLine({
|
|
2269
2283
|
diffFile,
|
|
2270
2284
|
side,
|
|
@@ -2278,14 +2292,21 @@ const DiffSplitExtendLine$1 = ({ index, diffFile, side, lineNumber, }) => {
|
|
|
2278
2292
|
const { useDiffContext } = useDiffViewContext();
|
|
2279
2293
|
const oldLine = diffFile.getSplitLeftLine(index);
|
|
2280
2294
|
const newLine = diffFile.getSplitRightLine(index);
|
|
2281
|
-
const
|
|
2295
|
+
const { oldLineExtend, newLineExtend } = useDiffContext(React__namespace.useCallback((s) => {
|
|
2296
|
+
var _a, _b, _c, _d;
|
|
2297
|
+
return ({
|
|
2298
|
+
oldLineExtend: (_b = (_a = s.extendData) === null || _a === void 0 ? void 0 : _a.oldFile) === null || _b === void 0 ? void 0 : _b[oldLine === null || oldLine === void 0 ? void 0 : oldLine.lineNumber],
|
|
2299
|
+
newLineExtend: (_d = (_c = s.extendData) === null || _c === void 0 ? void 0 : _c.newFile) === null || _d === void 0 ? void 0 : _d[newLine === null || newLine === void 0 ? void 0 : newLine.lineNumber],
|
|
2300
|
+
});
|
|
2301
|
+
}, [oldLine === null || oldLine === void 0 ? void 0 : oldLine.lineNumber, newLine === null || newLine === void 0 ? void 0 : newLine.lineNumber]));
|
|
2302
|
+
const hasExtend = (oldLineExtend === null || oldLineExtend === void 0 ? void 0 : oldLineExtend.data) || (newLineExtend === null || newLineExtend === void 0 ? void 0 : newLineExtend.data);
|
|
2282
2303
|
// if the expand action not enabled, the `isHidden` property will never change
|
|
2283
2304
|
const enableExpand = diffFile.getExpandEnabled();
|
|
2284
2305
|
const currentLine = side === exports.SplitSide.old ? oldLine : newLine;
|
|
2285
2306
|
const currentIsShow = hasExtend && (!currentLine.isHidden || !enableExpand);
|
|
2286
2307
|
if (!currentIsShow)
|
|
2287
2308
|
return null;
|
|
2288
|
-
return React__namespace.createElement(_DiffSplitExtendLine$1, { index: index, diffFile: diffFile,
|
|
2309
|
+
return (React__namespace.createElement(_DiffSplitExtendLine$1, { side: side, index: index, diffFile: diffFile, lineNumber: lineNumber, oldLineExtend: oldLineExtend, newLineExtend: newLineExtend }));
|
|
2289
2310
|
};
|
|
2290
2311
|
|
|
2291
2312
|
const ExpandDown = ({ className }) => {
|
|
@@ -2331,6 +2352,18 @@ const syncScroll = (left, right) => {
|
|
|
2331
2352
|
right.onscroll = null;
|
|
2332
2353
|
};
|
|
2333
2354
|
};
|
|
2355
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
2356
|
+
const memoFunc = (func) => {
|
|
2357
|
+
const cache = {};
|
|
2358
|
+
return ((key) => {
|
|
2359
|
+
if (cache[key]) {
|
|
2360
|
+
return cache[key];
|
|
2361
|
+
}
|
|
2362
|
+
const result = func(key);
|
|
2363
|
+
cache[key] = result;
|
|
2364
|
+
return result;
|
|
2365
|
+
});
|
|
2366
|
+
};
|
|
2334
2367
|
const asideWidth = "--diff-aside-width--";
|
|
2335
2368
|
|
|
2336
2369
|
const _DiffSplitHunkLine = ({ index, diffFile, side, lineNumber, }) => {
|
|
@@ -2388,7 +2421,7 @@ const DiffSplitAddWidget = ({ side, className, lineNumber, onWidgetClick, onOpen
|
|
|
2388
2421
|
width: "calc(var(--diff-font-size--) * 1.4)",
|
|
2389
2422
|
height: "calc(var(--diff-font-size--) * 1.4)",
|
|
2390
2423
|
} },
|
|
2391
|
-
React__namespace.createElement("button", { className: "diff-add-widget w-
|
|
2424
|
+
React__namespace.createElement("button", { className: "diff-add-widget w-full h-full invisible cursor-pointer rounded-md flex items-center justify-center transition-transform origin-center group-hover:visible hover:scale-110", style: {
|
|
2392
2425
|
color: `var(${addWidgetColorName})`,
|
|
2393
2426
|
zIndex: 1,
|
|
2394
2427
|
fontSize: `1.2em`,
|
|
@@ -2403,7 +2436,7 @@ const DiffUnifiedAddWidget = ({ lineNumber, side, onWidgetClick, onOpenAddWidget
|
|
|
2403
2436
|
width: "calc(var(--diff-font-size--) * 1.4)",
|
|
2404
2437
|
height: "calc(var(--diff-font-size--) * 1.4)",
|
|
2405
2438
|
} },
|
|
2406
|
-
React__namespace.createElement("button", { className: "diff-add-widget
|
|
2439
|
+
React__namespace.createElement("button", { className: "diff-add-widget w-full h-full invisible cursor-pointer rounded-md flex items-center justify-center transition-transform origin-center group-hover:visible hover:scale-110", style: {
|
|
2407
2440
|
color: `var(${addWidgetColorName})`,
|
|
2408
2441
|
zIndex: 1,
|
|
2409
2442
|
fontSize: `1.2em`,
|
|
@@ -2414,6 +2447,30 @@ const DiffUnifiedAddWidget = ({ lineNumber, side, onWidgetClick, onOpenAddWidget
|
|
|
2414
2447
|
} }, "+")));
|
|
2415
2448
|
};
|
|
2416
2449
|
|
|
2450
|
+
const temp = {};
|
|
2451
|
+
const formatStringToCamelCase = (str) => {
|
|
2452
|
+
const splitted = str.split("-");
|
|
2453
|
+
if (splitted.length === 1)
|
|
2454
|
+
return splitted[0];
|
|
2455
|
+
return (splitted[0] +
|
|
2456
|
+
splitted
|
|
2457
|
+
.slice(1)
|
|
2458
|
+
.map((word) => word[0].toUpperCase() + word.slice(1))
|
|
2459
|
+
.join(""));
|
|
2460
|
+
};
|
|
2461
|
+
const getStyleObjectFromString = memoFunc((str) => {
|
|
2462
|
+
if (!str)
|
|
2463
|
+
return temp;
|
|
2464
|
+
const style = {};
|
|
2465
|
+
str.split(";").forEach((el) => {
|
|
2466
|
+
const [property, value] = el.split(":");
|
|
2467
|
+
if (!property)
|
|
2468
|
+
return;
|
|
2469
|
+
const formattedProperty = formatStringToCamelCase(property.trim());
|
|
2470
|
+
style[formattedProperty] = value.trim();
|
|
2471
|
+
});
|
|
2472
|
+
return style;
|
|
2473
|
+
});
|
|
2417
2474
|
const DiffString = ({ rawLine, diffLine, operator, }) => {
|
|
2418
2475
|
const range = diffLine === null || diffLine === void 0 ? void 0 : diffLine.range;
|
|
2419
2476
|
if (range) {
|
|
@@ -2448,9 +2505,9 @@ const DiffSyntax = ({ rawLine, diffLine, operator, syntaxLine, }) => {
|
|
|
2448
2505
|
if (range) {
|
|
2449
2506
|
return (React__namespace.createElement("span", { className: "diff-line-syntax-raw" },
|
|
2450
2507
|
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) => {
|
|
2451
|
-
var _a, _b, _c, _d;
|
|
2508
|
+
var _a, _b, _c, _d, _e, _f;
|
|
2452
2509
|
if (node.endIndex < range.location || range.location + range.length < node.startIndex) {
|
|
2453
|
-
return (React__namespace.createElement("span", { key: index, "data-start": node.startIndex, "data-end": node.endIndex, className: (_b = (_a = wrapper === null || wrapper === void 0 ? void 0 : wrapper.properties) === null || _a === void 0 ? void 0 : _a.className) === null || _b === void 0 ? void 0 : _b.join(" ") }, node.value));
|
|
2510
|
+
return (React__namespace.createElement("span", { key: index, "data-start": node.startIndex, "data-end": node.endIndex, className: (_b = (_a = wrapper === null || wrapper === void 0 ? void 0 : wrapper.properties) === null || _a === void 0 ? void 0 : _a.className) === null || _b === void 0 ? void 0 : _b.join(" "), style: getStyleObjectFromString(((_c = wrapper === null || wrapper === void 0 ? void 0 : wrapper.properties) === null || _c === void 0 ? void 0 : _c.style) || "") }, node.value));
|
|
2454
2511
|
}
|
|
2455
2512
|
else {
|
|
2456
2513
|
const index1 = range.location - node.startIndex;
|
|
@@ -2461,7 +2518,7 @@ const DiffSyntax = ({ rawLine, diffLine, operator, syntaxLine, }) => {
|
|
|
2461
2518
|
const isStart = str1.length || range.location === node.startIndex;
|
|
2462
2519
|
const isEnd = str3.length || node.endIndex === range.location + range.length - 1;
|
|
2463
2520
|
const isNewLineSymbolChanged = range.isNewLineSymbolChanged;
|
|
2464
|
-
return (React__namespace.createElement("span", { key: index, "data-start": node.startIndex, "data-end": node.endIndex, className: (
|
|
2521
|
+
return (React__namespace.createElement("span", { key: index, "data-start": node.startIndex, "data-end": node.endIndex, className: (_e = (_d = wrapper === null || wrapper === void 0 ? void 0 : wrapper.properties) === null || _d === void 0 ? void 0 : _d.className) === null || _e === void 0 ? void 0 : _e.join(" "), style: getStyleObjectFromString(((_f = wrapper === null || wrapper === void 0 ? void 0 : wrapper.properties) === null || _f === void 0 ? void 0 : _f.style) || "") },
|
|
2465
2522
|
str1,
|
|
2466
2523
|
React__namespace.createElement("span", { "data-diff-highlight": true, style: {
|
|
2467
2524
|
backgroundColor: operator === "add" ? `var(${addContentHighlightBGName})` : `var(${delContentHighlightBGName})`,
|
|
@@ -2483,8 +2540,8 @@ const DiffSyntax = ({ rawLine, diffLine, operator, syntaxLine, }) => {
|
|
|
2483
2540
|
}))));
|
|
2484
2541
|
}
|
|
2485
2542
|
return (React__namespace.createElement("span", { className: "diff-line-syntax-raw" }, (_b = syntaxLine === null || syntaxLine === void 0 ? void 0 : syntaxLine.nodeList) === null || _b === void 0 ? void 0 : _b.map(({ node, wrapper }, index) => {
|
|
2486
|
-
var _a, _b;
|
|
2487
|
-
return (React__namespace.createElement("span", { key: index, "data-start": node.startIndex, "data-end": node.endIndex, className: (_b = (_a = wrapper === null || wrapper === void 0 ? void 0 : wrapper.properties) === null || _a === void 0 ? void 0 : _a.className) === null || _b === void 0 ? void 0 : _b.join(" ") }, node.value));
|
|
2543
|
+
var _a, _b, _c;
|
|
2544
|
+
return (React__namespace.createElement("span", { key: index, "data-start": node.startIndex, "data-end": node.endIndex, className: (_b = (_a = wrapper === null || wrapper === void 0 ? void 0 : wrapper.properties) === null || _a === void 0 ? void 0 : _a.className) === null || _b === void 0 ? void 0 : _b.join(" "), style: getStyleObjectFromString(((_c = wrapper === null || wrapper === void 0 ? void 0 : wrapper.properties) === null || _c === void 0 ? void 0 : _c.style) || "") }, node.value));
|
|
2488
2545
|
})));
|
|
2489
2546
|
};
|
|
2490
2547
|
const DiffContent = ({ diffLine, rawLine, syntaxLine, enableWrap, enableHighlight, }) => {
|
|
@@ -2522,7 +2579,7 @@ const _DiffSplitLine$1 = ({ index, diffFile, lineNumber, side, }) => {
|
|
|
2522
2579
|
onAddWidgetClick: s.onAddWidgetClick,
|
|
2523
2580
|
}), []));
|
|
2524
2581
|
const { useWidget } = useDiffWidgetContext();
|
|
2525
|
-
const
|
|
2582
|
+
const setWidget = useWidget.getReadonlyState().setWidget;
|
|
2526
2583
|
const contentBG = getContentBG(isAdded, isDelete, hasDiff);
|
|
2527
2584
|
const lineNumberBG = getLineNumberBG(isAdded, isDelete, hasDiff);
|
|
2528
2585
|
const syntaxLine = getCurrentSyntaxLine(currentLine.lineNumber);
|
|
@@ -2534,7 +2591,7 @@ const _DiffSplitLine$1 = ({ index, diffFile, lineNumber, side, }) => {
|
|
|
2534
2591
|
minWidth: `var(${asideWidth})`,
|
|
2535
2592
|
maxWidth: `var(${asideWidth})`,
|
|
2536
2593
|
} },
|
|
2537
|
-
hasDiff && enableAddWidget && (React__namespace.createElement(DiffSplitAddWidget, { index: index, lineNumber: currentLine.lineNumber, side: side, diffFile: diffFile, onWidgetClick: onAddWidgetClick, className: "absolute left-[100%] translate-x-[-50%] z-[1]", onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber: lineNumber, side: side }) })),
|
|
2594
|
+
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%] z-[1]", onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber: lineNumber, side: side }) })),
|
|
2538
2595
|
React__namespace.createElement("span", { "data-line-num": currentLine.lineNumber, style: { opacity: hasChange ? undefined : 0.5 } }, currentLine.lineNumber)),
|
|
2539
2596
|
React__namespace.createElement("td", { className: `diff-line-${exports.SplitSide[side]}-content pr-[10px] align-top`, style: { backgroundColor: contentBG } },
|
|
2540
2597
|
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 },
|
|
@@ -2634,9 +2691,10 @@ const DiffSplitViewNormal = React.memo(({ diffFile }) => {
|
|
|
2634
2691
|
return;
|
|
2635
2692
|
return syncScroll(left, right);
|
|
2636
2693
|
}, []);
|
|
2694
|
+
const font = React__namespace.useMemo(() => ({ fontSize: fontSize + "px", fontFamily: "Menlo, Consolas, monospace" }), [fontSize]);
|
|
2637
2695
|
const _width = useTextWidth({
|
|
2638
2696
|
text: splitLineLength.toString(),
|
|
2639
|
-
font
|
|
2697
|
+
font,
|
|
2640
2698
|
});
|
|
2641
2699
|
const width = Math.max(40, _width + 25);
|
|
2642
2700
|
return (React__namespace.createElement("div", { className: "split-diff-view split-diff-view-wrap w-full flex basis-[50%]" },
|
|
@@ -2660,48 +2718,54 @@ const DiffSplitViewNormal = React.memo(({ diffFile }) => {
|
|
|
2660
2718
|
});
|
|
2661
2719
|
DiffSplitViewNormal.displayName = "DiffSplitViewNormal";
|
|
2662
2720
|
|
|
2663
|
-
const _DiffSplitExtendLine = ({ index, diffFile, lineNumber, }) => {
|
|
2664
|
-
var _a, _b;
|
|
2721
|
+
const _DiffSplitExtendLine = ({ index, diffFile, lineNumber, oldLineExtend, newLineExtend, }) => {
|
|
2665
2722
|
const { useDiffContext } = useDiffViewContext();
|
|
2666
|
-
// 需要显示的时候才进行方法订阅,可以大幅度提高性能
|
|
2667
|
-
const { extendData, renderExtendLine } = useDiffContext(React__namespace.useCallback((s) => ({ extendData: s.extendData, renderExtendLine: s.renderExtendLine }), []));
|
|
2668
2723
|
const oldLine = diffFile.getSplitLeftLine(index);
|
|
2669
2724
|
const newLine = diffFile.getSplitRightLine(index);
|
|
2670
|
-
|
|
2671
|
-
const
|
|
2725
|
+
// 需要显示的时候才进行方法订阅,可以大幅度提高性能
|
|
2726
|
+
const renderExtendLine = useDiffContext(React__namespace.useCallback((s) => s.renderExtendLine, []));
|
|
2672
2727
|
if (!renderExtendLine)
|
|
2673
2728
|
return null;
|
|
2674
2729
|
return (React__namespace.createElement("tr", { "data-line": `${lineNumber}-extend`, "data-state": "extend", className: "diff-line diff-line-extend" },
|
|
2675
2730
|
oldLineExtend ? (React__namespace.createElement("td", { className: "diff-line-extend-old-content p-0", colSpan: 2 },
|
|
2676
|
-
React__namespace.createElement("div", { className: "diff-line-extend-wrapper" },
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2731
|
+
React__namespace.createElement("div", { className: "diff-line-extend-wrapper" }, (oldLineExtend === null || oldLineExtend === void 0 ? void 0 : oldLineExtend.data) &&
|
|
2732
|
+
(renderExtendLine === null || renderExtendLine === void 0 ? void 0 : renderExtendLine({
|
|
2733
|
+
diffFile,
|
|
2734
|
+
side: exports.SplitSide.old,
|
|
2735
|
+
lineNumber: oldLine.lineNumber,
|
|
2736
|
+
data: oldLineExtend.data,
|
|
2737
|
+
onUpdate: diffFile.notifyAll,
|
|
2738
|
+
}))))) : (React__namespace.createElement("td", { className: "diff-line-extend-old-placeholder p-0 select-none", style: { backgroundColor: `var(${emptyBGName})` }, colSpan: 2 },
|
|
2683
2739
|
React__namespace.createElement("span", null, "\u2002"))),
|
|
2684
2740
|
newLineExtend ? (React__namespace.createElement("td", { className: "diff-line-extend-new-content p-0 border-l-[1px] border-l-[#ccc]", colSpan: 2 },
|
|
2685
|
-
React__namespace.createElement("div", { className: "diff-line-extend-wrapper" },
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2741
|
+
React__namespace.createElement("div", { className: "diff-line-extend-wrapper" }, (newLineExtend === null || newLineExtend === void 0 ? void 0 : newLineExtend.data) &&
|
|
2742
|
+
(renderExtendLine === null || renderExtendLine === void 0 ? void 0 : renderExtendLine({
|
|
2743
|
+
diffFile,
|
|
2744
|
+
side: exports.SplitSide.new,
|
|
2745
|
+
lineNumber: newLine.lineNumber,
|
|
2746
|
+
data: newLineExtend.data,
|
|
2747
|
+
onUpdate: diffFile.notifyAll,
|
|
2748
|
+
}))))) : (React__namespace.createElement("td", { className: "diff-line-extend-new-placeholder p-0 border-l-[1px] border-l-[#ccc] select-none", style: { backgroundColor: `var(${emptyBGName})` }, colSpan: 2 },
|
|
2692
2749
|
React__namespace.createElement("span", null, "\u2002")))));
|
|
2693
2750
|
};
|
|
2694
2751
|
const DiffSplitExtendLine = ({ index, diffFile, lineNumber, }) => {
|
|
2695
2752
|
const { useDiffContext } = useDiffViewContext();
|
|
2696
2753
|
const oldLine = diffFile.getSplitLeftLine(index);
|
|
2697
2754
|
const newLine = diffFile.getSplitRightLine(index);
|
|
2698
|
-
const
|
|
2755
|
+
const { oldLineExtend, newLineExtend } = useDiffContext(React__namespace.useCallback((s) => {
|
|
2756
|
+
var _a, _b, _c, _d;
|
|
2757
|
+
return ({
|
|
2758
|
+
oldLineExtend: (_b = (_a = s.extendData) === null || _a === void 0 ? void 0 : _a.oldFile) === null || _b === void 0 ? void 0 : _b[oldLine === null || oldLine === void 0 ? void 0 : oldLine.lineNumber],
|
|
2759
|
+
newLineExtend: (_d = (_c = s.extendData) === null || _c === void 0 ? void 0 : _c.newFile) === null || _d === void 0 ? void 0 : _d[newLine === null || newLine === void 0 ? void 0 : newLine.lineNumber],
|
|
2760
|
+
});
|
|
2761
|
+
}, [oldLine === null || oldLine === void 0 ? void 0 : oldLine.lineNumber, newLine === null || newLine === void 0 ? void 0 : newLine.lineNumber]));
|
|
2762
|
+
const hasExtend = (oldLineExtend === null || oldLineExtend === void 0 ? void 0 : oldLineExtend.data) || (newLineExtend === null || newLineExtend === void 0 ? void 0 : newLineExtend.data);
|
|
2699
2763
|
// if the expand action not enabled, the `isHidden` property will never change
|
|
2700
2764
|
const enableExpand = diffFile.getExpandEnabled();
|
|
2701
2765
|
const currentIsShow = hasExtend && ((!(oldLine === null || oldLine === void 0 ? void 0 : oldLine.isHidden) && !(newLine === null || newLine === void 0 ? void 0 : newLine.isHidden)) || !enableExpand);
|
|
2702
2766
|
if (!currentIsShow)
|
|
2703
2767
|
return null;
|
|
2704
|
-
return React__namespace.createElement(_DiffSplitExtendLine, { index: index, diffFile: diffFile, lineNumber: lineNumber });
|
|
2768
|
+
return (React__namespace.createElement(_DiffSplitExtendLine, { index: index, diffFile: diffFile, lineNumber: lineNumber, oldLineExtend: oldLineExtend, newLineExtend: newLineExtend }));
|
|
2705
2769
|
};
|
|
2706
2770
|
|
|
2707
2771
|
const DiffSplitHunkLine = ({ index, diffFile, lineNumber, }) => {
|
|
@@ -2721,7 +2785,7 @@ const DiffSplitHunkLine = ({ index, diffFile, lineNumber, }) => {
|
|
|
2721
2785
|
if (!currentIsShow && !currentIsPureHunk)
|
|
2722
2786
|
return null;
|
|
2723
2787
|
return (React__namespace.createElement("tr", { "data-line": `${lineNumber}-hunk`, "data-state": "hunk", className: "diff-line diff-line-hunk" },
|
|
2724
|
-
React__namespace.createElement("td", { className: "diff-line-hunk-action p-[1px] w-[1%] min-w-[40px] select-none", style: {
|
|
2788
|
+
React__namespace.createElement("td", { className: "diff-line-hunk-action p-[1px] w-[1%] min-w-[40px] select-none relative", style: {
|
|
2725
2789
|
backgroundColor: `var(${hunkLineNumberBGName})`,
|
|
2726
2790
|
color: `var(${plainLineNumberColorName})`,
|
|
2727
2791
|
} }, couldExpand ? (isFirstLine ? (React__namespace.createElement("button", { className: "w-full diff-widget-tooltip hover:bg-blue-300 flex justify-center items-center py-[6px] cursor-pointer rounded-[2px]", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index) },
|
|
@@ -2755,7 +2819,7 @@ const _DiffSplitLine = ({ index, diffFile, lineNumber }) => {
|
|
|
2755
2819
|
onAddWidgetClick: s.onAddWidgetClick,
|
|
2756
2820
|
}), []));
|
|
2757
2821
|
const { useWidget } = useDiffWidgetContext();
|
|
2758
|
-
const
|
|
2822
|
+
const setWidget = useWidget.getReadonlyState().setWidget;
|
|
2759
2823
|
const hasOldLine = !!oldLine.lineNumber;
|
|
2760
2824
|
const hasNewLine = !!newLine.lineNumber;
|
|
2761
2825
|
const oldLineContentBG = getContentBG(false, oldLineIsDelete, hasDiff);
|
|
@@ -2765,18 +2829,18 @@ const _DiffSplitLine = ({ index, diffFile, lineNumber }) => {
|
|
|
2765
2829
|
return (React__namespace.createElement("tr", { "data-line": lineNumber, "data-state": hasDiff ? "diff" : "plain", className: "diff-line" },
|
|
2766
2830
|
hasOldLine ? (React__namespace.createElement(React__namespace.Fragment, null,
|
|
2767
2831
|
React__namespace.createElement("td", { className: "diff-line-old-num group relative pl-[10px] pr-[10px] text-right align-top select-none w-[1%] min-w-[40px]", "data-side": exports.SplitSide[exports.SplitSide.old], style: { backgroundColor: oldLineNumberBG, color: `var(${plainLineNumberColorName})` } },
|
|
2768
|
-
hasDiff && enableAddWidget && (React__namespace.createElement(DiffSplitAddWidget, { index: index, lineNumber: oldLine.lineNumber, side: exports.SplitSide.old, diffFile: diffFile, onWidgetClick: onAddWidgetClick, className: "absolute left-[100%] translate-x-[-50%] z-[1]", onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber: lineNumber, side: side }) })),
|
|
2832
|
+
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%] z-[1]", onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber: lineNumber, side: side }) })),
|
|
2769
2833
|
React__namespace.createElement("span", { "data-line-num": oldLine.lineNumber, style: { opacity: hasChange ? undefined : 0.5 } }, oldLine.lineNumber)),
|
|
2770
2834
|
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 } },
|
|
2771
|
-
hasDiff && enableAddWidget && (React__namespace.createElement(DiffSplitAddWidget, { index: index, lineNumber: oldLine.lineNumber, side: exports.SplitSide.old, diffFile: diffFile, onWidgetClick: onAddWidgetClick, className: "absolute right-[100%] translate-x-[50%] z-[1] select-none", onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber: lineNumber, side: side }) })),
|
|
2835
|
+
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%] z-[1] select-none", onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber: lineNumber, side: side }) })),
|
|
2772
2836
|
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 },
|
|
2773
2837
|
React__namespace.createElement("span", null, "\u2002"))),
|
|
2774
2838
|
hasNewLine ? (React__namespace.createElement(React__namespace.Fragment, null,
|
|
2775
2839
|
React__namespace.createElement("td", { className: "diff-line-new-num group relative pl-[10px] pr-[10px] text-right align-top select-none w-[1%] min-w-[40px] border-l-[1px] border-l-[#ccc]", "data-side": exports.SplitSide[exports.SplitSide.new], style: { backgroundColor: newLineNumberBG, color: `var(${plainLineNumberColorName})` } },
|
|
2776
|
-
hasDiff && enableAddWidget && (React__namespace.createElement(DiffSplitAddWidget, { index: index, lineNumber: newLine.lineNumber, side: exports.SplitSide.new, diffFile: diffFile, onWidgetClick: onAddWidgetClick, className: "absolute left-[100%] translate-x-[-50%] z-[1]", onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber: lineNumber, side: side }) })),
|
|
2840
|
+
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%] z-[1]", onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber: lineNumber, side: side }) })),
|
|
2777
2841
|
React__namespace.createElement("span", { "data-line-num": newLine.lineNumber, style: { opacity: hasChange ? undefined : 0.5 } }, newLine.lineNumber)),
|
|
2778
2842
|
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 } },
|
|
2779
|
-
hasDiff && enableAddWidget && (React__namespace.createElement(DiffSplitAddWidget, { index: index, lineNumber: newLine.lineNumber, side: exports.SplitSide.new, diffFile: diffFile, onWidgetClick: onAddWidgetClick, className: "absolute right-[100%] translate-x-[50%] z-[1] select-none", onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber: lineNumber, side: side }) })),
|
|
2843
|
+
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%] z-[1] select-none", onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber: lineNumber, side: side }) })),
|
|
2780
2844
|
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-[#ccc]", style: { backgroundColor: `var(${emptyBGName})` }, "data-side": exports.SplitSide[exports.SplitSide.new], colSpan: 2 },
|
|
2781
2845
|
React__namespace.createElement("span", null, "\u2002")))));
|
|
2782
2846
|
};
|
|
@@ -2788,15 +2852,13 @@ const DiffSplitLine = ({ index, diffFile, lineNumber, }) => {
|
|
|
2788
2852
|
return React__namespace.createElement(_DiffSplitLine, { index: index, diffFile: diffFile, lineNumber: lineNumber });
|
|
2789
2853
|
};
|
|
2790
2854
|
|
|
2791
|
-
const _DiffSplitWidgetLine = ({ index, diffFile, lineNumber, }) => {
|
|
2855
|
+
const _DiffSplitWidgetLine = ({ index, diffFile, lineNumber, oldLineWidget, newLineWidget, }) => {
|
|
2792
2856
|
const { useWidget } = useDiffWidgetContext();
|
|
2793
|
-
const
|
|
2857
|
+
const setWidget = useWidget.getReadonlyState().setWidget;
|
|
2794
2858
|
const { useDiffContext } = useDiffViewContext();
|
|
2795
2859
|
const renderWidgetLine = useDiffContext(React__namespace.useCallback((s) => s.renderWidgetLine, []));
|
|
2796
2860
|
const oldLine = diffFile.getSplitLeftLine(index);
|
|
2797
2861
|
const newLine = diffFile.getSplitRightLine(index);
|
|
2798
|
-
const oldLineWidget = oldLine.lineNumber && widgetSide === exports.SplitSide.old && widgetLineNumber === oldLine.lineNumber;
|
|
2799
|
-
const newLineWidget = newLine.lineNumber && widgetSide === exports.SplitSide.new && widgetLineNumber === newLine.lineNumber;
|
|
2800
2862
|
if (!renderWidgetLine)
|
|
2801
2863
|
return null;
|
|
2802
2864
|
return (React__namespace.createElement("tr", { "data-line": `${lineNumber}-widget`, "data-state": "widget", className: "diff-line diff-line-widget" },
|
|
@@ -2827,7 +2889,7 @@ const DiffSplitWidgetLine = ({ index, diffFile, lineNumber, }) => {
|
|
|
2827
2889
|
const currentIsShow = oldLineWidget || newLineWidget;
|
|
2828
2890
|
if (!currentIsShow)
|
|
2829
2891
|
return null;
|
|
2830
|
-
return React__namespace.createElement(_DiffSplitWidgetLine, { index: index, diffFile: diffFile, lineNumber: lineNumber });
|
|
2892
|
+
return (React__namespace.createElement(_DiffSplitWidgetLine, { index: index, diffFile: diffFile, lineNumber: lineNumber, oldLineWidget: oldLineWidget, newLineWidget: newLineWidget }));
|
|
2831
2893
|
};
|
|
2832
2894
|
|
|
2833
2895
|
const Style = ({ useSelector, id, }) => {
|
|
@@ -2871,9 +2933,10 @@ const DiffSplitViewWrap = React.memo(({ diffFile }) => {
|
|
|
2871
2933
|
}
|
|
2872
2934
|
}
|
|
2873
2935
|
}, [setSelectSide]);
|
|
2936
|
+
const font = React.useMemo(() => ({ fontSize: fontSize + "px", fontFamily: "Menlo, Consolas, monospace" }), [fontSize]);
|
|
2874
2937
|
const _width = useTextWidth({
|
|
2875
2938
|
text: splitLineLength.toString(),
|
|
2876
|
-
font
|
|
2939
|
+
font,
|
|
2877
2940
|
});
|
|
2878
2941
|
const width = Math.max(40, _width + 25);
|
|
2879
2942
|
const lines = getSplitContentLines(diffFile);
|
|
@@ -2922,7 +2985,6 @@ const DiffSplitView = React.memo(({ diffFile }) => {
|
|
|
2922
2985
|
return { widgetSide, widgetLineNumber, setWidget };
|
|
2923
2986
|
}), [useDiffContext]);
|
|
2924
2987
|
const contextValue = React.useMemo(() => ({ useWidget }), [useWidget]);
|
|
2925
|
-
shim.useSyncExternalStore(diffFile.subscribe, diffFile.getUpdateCount);
|
|
2926
2988
|
React.useEffect(() => {
|
|
2927
2989
|
const { setWidget } = useWidget.getReadonlyState();
|
|
2928
2990
|
setWidget({});
|
|
@@ -2931,12 +2993,10 @@ const DiffSplitView = React.memo(({ diffFile }) => {
|
|
|
2931
2993
|
});
|
|
2932
2994
|
DiffSplitView.displayName = "DiffSplitView";
|
|
2933
2995
|
|
|
2934
|
-
const _DiffUnifiedExtendLine = ({ index, diffFile, lineNumber, }) => {
|
|
2996
|
+
const _DiffUnifiedExtendLine = ({ index, diffFile, lineNumber, oldLineExtend, newLineExtend, }) => {
|
|
2935
2997
|
const { useDiffContext } = useDiffViewContext();
|
|
2936
2998
|
const renderExtendLine = useDiffContext(React.useCallback((s) => s.renderExtendLine, []));
|
|
2937
2999
|
const unifiedItem = diffFile.getUnifiedLine(index);
|
|
2938
|
-
const oldExtend = useDiffContext(React.useCallback((s) => { var _a, _b; return (_b = (_a = s.extendData) === null || _a === void 0 ? void 0 : _a.oldFile) === null || _b === void 0 ? void 0 : _b[unifiedItem === null || unifiedItem === void 0 ? void 0 : unifiedItem.oldLineNumber]; }, [unifiedItem === null || unifiedItem === void 0 ? void 0 : unifiedItem.oldLineNumber]));
|
|
2939
|
-
const newExtend = useDiffContext(React.useCallback((s) => { var _a, _b; return (_b = (_a = s.extendData) === null || _a === void 0 ? void 0 : _a.newFile) === null || _b === void 0 ? void 0 : _b[unifiedItem === null || unifiedItem === void 0 ? void 0 : unifiedItem.newLineNumber]; }, [unifiedItem === null || unifiedItem === void 0 ? void 0 : unifiedItem.newLineNumber]));
|
|
2940
3000
|
const width = useDomWidth({
|
|
2941
3001
|
selector: ".unified-diff-table-wrapper",
|
|
2942
3002
|
enable: typeof renderExtendLine === "function",
|
|
@@ -2947,31 +3007,38 @@ const _DiffUnifiedExtendLine = ({ index, diffFile, lineNumber, }) => {
|
|
|
2947
3007
|
React__namespace.createElement("td", { className: "diff-line-extend-content align-top p-0", colSpan: 2 },
|
|
2948
3008
|
React__namespace.createElement("div", { className: "diff-line-extend-wrapper sticky left-0", style: { width } },
|
|
2949
3009
|
width > 0 &&
|
|
2950
|
-
|
|
3010
|
+
(oldLineExtend === null || oldLineExtend === void 0 ? void 0 : oldLineExtend.data) &&
|
|
2951
3011
|
(renderExtendLine === null || renderExtendLine === void 0 ? void 0 : renderExtendLine({
|
|
2952
3012
|
diffFile,
|
|
2953
3013
|
side: exports.SplitSide.old,
|
|
2954
3014
|
lineNumber: unifiedItem.oldLineNumber,
|
|
2955
|
-
data:
|
|
3015
|
+
data: oldLineExtend.data,
|
|
2956
3016
|
onUpdate: diffFile.notifyAll,
|
|
2957
3017
|
})),
|
|
2958
3018
|
width > 0 &&
|
|
2959
|
-
|
|
3019
|
+
(newLineExtend === null || newLineExtend === void 0 ? void 0 : newLineExtend.data) &&
|
|
2960
3020
|
(renderExtendLine === null || renderExtendLine === void 0 ? void 0 : renderExtendLine({
|
|
2961
3021
|
diffFile,
|
|
2962
3022
|
side: exports.SplitSide.new,
|
|
2963
3023
|
lineNumber: unifiedItem.newLineNumber,
|
|
2964
|
-
data:
|
|
3024
|
+
data: newLineExtend.data,
|
|
2965
3025
|
onUpdate: diffFile.notifyAll,
|
|
2966
3026
|
}))))));
|
|
2967
3027
|
};
|
|
2968
3028
|
const DiffUnifiedExtendLine = ({ index, diffFile, lineNumber, }) => {
|
|
2969
3029
|
const { useDiffContext } = useDiffViewContext();
|
|
2970
3030
|
const unifiedItem = diffFile.getUnifiedLine(index);
|
|
2971
|
-
const
|
|
3031
|
+
const { oldLineExtend, newLineExtend } = useDiffContext(React.useCallback((s) => {
|
|
3032
|
+
var _a, _b, _c, _d;
|
|
3033
|
+
return ({
|
|
3034
|
+
oldLineExtend: (_b = (_a = s.extendData) === null || _a === void 0 ? void 0 : _a.oldFile) === null || _b === void 0 ? void 0 : _b[unifiedItem === null || unifiedItem === void 0 ? void 0 : unifiedItem.oldLineNumber],
|
|
3035
|
+
newLineExtend: (_d = (_c = s.extendData) === null || _c === void 0 ? void 0 : _c.newFile) === null || _d === void 0 ? void 0 : _d[unifiedItem === null || unifiedItem === void 0 ? void 0 : unifiedItem.newLineNumber],
|
|
3036
|
+
});
|
|
3037
|
+
}, [unifiedItem.oldLineNumber, unifiedItem.newLineNumber]));
|
|
3038
|
+
const hasExtend = (oldLineExtend === null || oldLineExtend === void 0 ? void 0 : oldLineExtend.data) || (newLineExtend === null || newLineExtend === void 0 ? void 0 : newLineExtend.data);
|
|
2972
3039
|
if (!hasExtend || !unifiedItem || unifiedItem.isHidden || !unifiedItem.diff)
|
|
2973
3040
|
return null;
|
|
2974
|
-
return React__namespace.createElement(_DiffUnifiedExtendLine, { index: index, diffFile: diffFile, lineNumber: lineNumber });
|
|
3041
|
+
return (React__namespace.createElement(_DiffUnifiedExtendLine, { index: index, diffFile: diffFile, lineNumber: lineNumber, oldLineExtend: oldLineExtend, newLineExtend: newLineExtend }));
|
|
2975
3042
|
};
|
|
2976
3043
|
|
|
2977
3044
|
const _DiffUnifiedHunkLine = ({ index, diffFile, lineNumber, }) => {
|
|
@@ -3063,7 +3130,7 @@ const _DiffUnifiedLine = React.memo(({ index, diffFile, lineNumber }) => {
|
|
|
3063
3130
|
onAddWidgetClick: s.onAddWidgetClick,
|
|
3064
3131
|
}), []));
|
|
3065
3132
|
const { useWidget } = useDiffWidgetContext();
|
|
3066
|
-
const
|
|
3133
|
+
const setWidget = useWidget.getReadonlyState().setWidget;
|
|
3067
3134
|
const hasDiff = unifiedLine.diff;
|
|
3068
3135
|
const hasChange = checkDiffLineIncludeChange(unifiedLine.diff);
|
|
3069
3136
|
const rawLine = unifiedLine.value || "";
|
|
@@ -3077,10 +3144,10 @@ const _DiffUnifiedLine = React.memo(({ index, diffFile, lineNumber }) => {
|
|
|
3077
3144
|
: undefined;
|
|
3078
3145
|
if (hasChange) {
|
|
3079
3146
|
if (unifiedLine.oldLineNumber) {
|
|
3080
|
-
return (React__namespace.createElement(DiffUnifiedOldLine, { index: lineNumber, enableWrap: enableWrap, diffFile: diffFile, rawLine: rawLine, diffLine: diffLine, setWidget: setWidget, syntaxLine: syntaxLine, enableHighlight: enableHighlight, enableAddWidget: enableAddWidget, onAddWidgetClick: onAddWidgetClick
|
|
3147
|
+
return (React__namespace.createElement(DiffUnifiedOldLine, { index: lineNumber, enableWrap: enableWrap, diffFile: diffFile, rawLine: rawLine, diffLine: diffLine, setWidget: setWidget, syntaxLine: syntaxLine, enableHighlight: enableHighlight, enableAddWidget: enableAddWidget, lineNumber: unifiedLine.oldLineNumber, onAddWidgetClick: (...props) => { var _a; return (_a = onAddWidgetClick.current) === null || _a === void 0 ? void 0 : _a.call(onAddWidgetClick, ...props); } }));
|
|
3081
3148
|
}
|
|
3082
3149
|
else {
|
|
3083
|
-
return (React__namespace.createElement(DiffUnifiedNewLine, { index: lineNumber, enableWrap: enableWrap, rawLine: rawLine, diffLine: diffLine, diffFile: diffFile, setWidget: setWidget, syntaxLine: syntaxLine, enableHighlight: enableHighlight, enableAddWidget: enableAddWidget, onAddWidgetClick: onAddWidgetClick
|
|
3150
|
+
return (React__namespace.createElement(DiffUnifiedNewLine, { index: lineNumber, enableWrap: enableWrap, rawLine: rawLine, diffLine: diffLine, diffFile: diffFile, setWidget: setWidget, syntaxLine: syntaxLine, enableHighlight: enableHighlight, enableAddWidget: enableAddWidget, lineNumber: unifiedLine.newLineNumber, onAddWidgetClick: (...props) => { var _a; return (_a = onAddWidgetClick.current) === null || _a === void 0 ? void 0 : _a.call(onAddWidgetClick, ...props); } }));
|
|
3084
3151
|
}
|
|
3085
3152
|
}
|
|
3086
3153
|
else {
|
|
@@ -3092,7 +3159,7 @@ const _DiffUnifiedLine = React.memo(({ index, diffFile, lineNumber }) => {
|
|
|
3092
3159
|
minWidth: `calc(calc(var(${asideWidth}) + 5px) * 2)`,
|
|
3093
3160
|
backgroundColor: hasDiff ? `var(${plainLineNumberBGName})` : `var(${expandContentBGName})`,
|
|
3094
3161
|
} },
|
|
3095
|
-
enableAddWidget && hasDiff && (React__namespace.createElement(DiffUnifiedAddWidget, { index: index, diffFile: diffFile, lineNumber: unifiedLine.newLineNumber, side: exports.SplitSide.new, onWidgetClick: onAddWidgetClick, onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber, side }) })),
|
|
3162
|
+
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 }) })),
|
|
3096
3163
|
React__namespace.createElement("div", { className: "flex opacity-[0.5]" },
|
|
3097
3164
|
React__namespace.createElement("span", { "data-line-old-num": unifiedLine.oldLineNumber, className: "inline-block w-[50%]" }, unifiedLine.oldLineNumber),
|
|
3098
3165
|
React__namespace.createElement("span", { className: "w-[10px] shrink-0" }),
|
|
@@ -3264,8 +3331,9 @@ const _InternalDiffView = (props) => {
|
|
|
3264
3331
|
const setRenderWidgetLine = (_renderWidgetLine) => (renderWidgetLine.value = _renderWidgetLine);
|
|
3265
3332
|
const renderExtendLine = reactivityStore.ref(props.renderExtendLine);
|
|
3266
3333
|
const setRenderExtendLine = (_renderExtendLine) => (renderExtendLine.value = _renderExtendLine);
|
|
3267
|
-
|
|
3268
|
-
const
|
|
3334
|
+
// 避免无意义的订阅
|
|
3335
|
+
const onAddWidgetClick = reactivityStore.ref(reactivityStore.markRaw({ current: props.onAddWidgetClick }));
|
|
3336
|
+
const setOnAddWidgetClick = (_onAddWidgetClick) => (onAddWidgetClick.value.current = _onAddWidgetClick.current);
|
|
3269
3337
|
return {
|
|
3270
3338
|
id,
|
|
3271
3339
|
setId,
|
|
@@ -3300,7 +3368,7 @@ const _InternalDiffView = (props) => {
|
|
|
3300
3368
|
diffViewWrap !== enableWrap && setEnableWrap(diffViewWrap);
|
|
3301
3369
|
extendData && setExtendData(extendData);
|
|
3302
3370
|
diffViewFontSize && diffViewFontSize !== fontSize && setFontSize(diffViewFontSize);
|
|
3303
|
-
onAddWidgetClick !== _onAddWidgetClick && setOnAddWidgetClick(onAddWidgetClick);
|
|
3371
|
+
onAddWidgetClick !== _onAddWidgetClick.current && setOnAddWidgetClick({ current: onAddWidgetClick });
|
|
3304
3372
|
renderExtendLine !== _renderExtendLine && setRenderExtendLine(renderExtendLine);
|
|
3305
3373
|
renderWidgetLine !== _renderWidgetLine && setRenderWidgetLine(renderWidgetLine);
|
|
3306
3374
|
}, [
|
|
@@ -3318,7 +3386,7 @@ const _InternalDiffView = (props) => {
|
|
|
3318
3386
|
]);
|
|
3319
3387
|
const value = React.useMemo(() => ({ useDiffContext }), [useDiffContext]);
|
|
3320
3388
|
return (React__namespace.createElement(DiffViewContext.Provider, { value: value },
|
|
3321
|
-
React__namespace.createElement("div", { className: "diff-tailwindcss-wrapper", "data-component": "git-diff-view", "data-version": `${"0.0.
|
|
3389
|
+
React__namespace.createElement("div", { className: "diff-tailwindcss-wrapper", "data-component": "git-diff-view", "data-version": `${"0.0.9"}`, "data-highlighter": diffFile._getHighlighterName() },
|
|
3322
3390
|
React__namespace.createElement("div", { className: "diff-style-root", style: {
|
|
3323
3391
|
// @ts-ignore
|
|
3324
3392
|
[diffFontSizeName]: diffViewFontSize + "px",
|
|
@@ -3327,7 +3395,7 @@ const _InternalDiffView = (props) => {
|
|
|
3327
3395
|
};
|
|
3328
3396
|
const InternalDiffView = React.memo(_InternalDiffView);
|
|
3329
3397
|
const DiffViewWithRef = (props, ref) => {
|
|
3330
|
-
const { registerHighlighter,
|
|
3398
|
+
const { registerHighlighter, data, diffFile: _diffFile } = props, restProps = __rest(props, ["registerHighlighter", "data", "diffFile"]);
|
|
3331
3399
|
const diffFile = React.useMemo(() => {
|
|
3332
3400
|
var _a, _b, _c, _d, _e, _f;
|
|
3333
3401
|
if (_diffFile) {
|
|
@@ -3351,10 +3419,10 @@ const DiffViewWithRef = (props, ref) => {
|
|
|
3351
3419
|
if (!diffFile)
|
|
3352
3420
|
return;
|
|
3353
3421
|
if (props.diffViewHighlight) {
|
|
3354
|
-
diffFile.initSyntax({
|
|
3422
|
+
diffFile.initSyntax({ registerHighlighter });
|
|
3355
3423
|
diffFile.notifyAll();
|
|
3356
3424
|
}
|
|
3357
|
-
}, [diffFile, props.diffViewHighlight,
|
|
3425
|
+
}, [diffFile, props.diffViewHighlight, registerHighlighter]);
|
|
3358
3426
|
React.useEffect(() => {
|
|
3359
3427
|
if (_diffFile && diffFile) {
|
|
3360
3428
|
_diffFile._addClonedInstance(diffFile);
|
|
@@ -3371,7 +3439,7 @@ const DiffViewWithRef = (props, ref) => {
|
|
|
3371
3439
|
};
|
|
3372
3440
|
const DiffView = React.forwardRef(DiffViewWithRef);
|
|
3373
3441
|
DiffView.displayName = "DiffView";
|
|
3374
|
-
const version = "0.0.
|
|
3442
|
+
const version = "0.0.9";
|
|
3375
3443
|
|
|
3376
3444
|
exports.DefaultDiffExpansionStep = DefaultDiffExpansionStep;
|
|
3377
3445
|
exports.DiffFile = DiffFile;
|
|
@@ -3395,6 +3463,7 @@ exports.getUnifiedLines = getUnifiedLines;
|
|
|
3395
3463
|
exports.hasRelativeChange = hasRelativeChange;
|
|
3396
3464
|
exports.highlighter = highlighter;
|
|
3397
3465
|
exports.numIterator = numIterator;
|
|
3466
|
+
exports.processAST = processAST;
|
|
3398
3467
|
exports.relativeChanges = relativeChanges;
|
|
3399
3468
|
exports.useDiffViewContext = useDiffViewContext;
|
|
3400
3469
|
exports.version = version;
|