@git-diff-view/react 0.1.3 → 0.1.4
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 +497 -503
- package/dist/cjs/index.development.js.map +1 -1
- package/dist/cjs/index.production.js +497 -503
- package/dist/cjs/index.production.js.map +1 -1
- package/dist/css/diff-view-pure.css +111 -0
- package/dist/css/diff-view.css +111 -0
- package/dist/esm/index.mjs +499 -506
- package/dist/esm/index.mjs.map +1 -1
- package/index.d.ts +236 -7
- package/package.json +2 -2
- package/src/_com.css +99 -0
- package/src/components/DiffAddWidget.tsx +4 -3
- package/src/components/DiffContent.tsx +6 -6
- package/src/components/DiffExpand.tsx +0 -2
- package/src/components/DiffNoNewLine.tsx +0 -2
- package/src/components/DiffSplitContentLineNormal.tsx +3 -4
- package/src/components/DiffSplitContentLineWrap.tsx +9 -10
- package/src/components/DiffSplitExtendLineNormal.tsx +3 -3
- package/src/components/DiffSplitExtendLineWrap.tsx +4 -4
- package/src/components/DiffSplitHunkLineNormal.tsx +0 -1
- package/src/components/DiffSplitHunkLineWrap.tsx +0 -1
- package/src/components/DiffSplitView.tsx +0 -1
- package/src/components/DiffSplitViewNormal.tsx +13 -12
- package/src/components/DiffSplitViewWrap.tsx +10 -10
- package/src/components/DiffSplitWidgetLineNormal.tsx +2 -2
- package/src/components/DiffSplitWidgetLineWrap.tsx +12 -2
- package/src/components/DiffUnifiedContentLine.tsx +1 -2
- package/src/components/DiffUnifiedExtendLine.tsx +4 -5
- package/src/components/DiffUnifiedHunkLine.tsx +0 -1
- package/src/components/DiffUnifiedView.tsx +9 -9
- package/src/components/DiffUnifiedWidgetLine.tsx +2 -2
- package/src/components/DiffView.tsx +26 -20
- package/src/components/DiffViewContext.ts +2 -0
- package/src/components/DiffViewWithMultiSelect.tsx +321 -0
- package/src/components/DiffWidgetContext.ts +4 -2
- package/src/components/tools.ts +6 -5
- package/src/components/v2/DiffSplitContentLineNormal_v2.tsx +4 -5
- package/src/components/v2/DiffSplitContentLineWrap_v2.tsx +11 -12
- package/src/components/v2/DiffSplitExtendLineNormal_v2.tsx +3 -3
- package/src/components/v2/DiffSplitExtendLineWrap_v2.tsx +4 -4
- package/src/components/v2/DiffSplitHunkLineNormal_v2.tsx +0 -1
- package/src/components/v2/DiffSplitHunkLineWrap_v2.tsx +0 -1
- package/src/components/v2/DiffSplitViewLineNormal_v2.tsx +0 -1
- package/src/components/v2/DiffSplitViewLineWrap_v2.tsx +0 -1
- package/src/components/v2/DiffSplitViewNormal_v2.tsx +9 -8
- package/src/components/v2/DiffSplitViewWrap_v2.tsx +5 -5
- package/src/components/v2/DiffSplitView_v2.tsx +0 -1
- package/src/components/v2/DiffSplitWidgetLineNormal_v2.tsx +2 -3
- package/src/components/v2/DiffSplitWidgetLineWrap_v2.tsx +4 -5
- package/src/hooks/useCallbackRef.ts +13 -0
- package/src/hooks/useDomWidth.ts +5 -5
- package/src/hooks/useIsMounted.ts +1 -0
- package/src/hooks/useSyncHeight.ts +3 -3
- package/src/hooks/useTextWidth.ts +1 -1
- package/src/hooks/useUnmount.ts +1 -0
- package/src/hooks/useUpdateEffect.ts +15 -0
- package/src/index.ts +1 -2
- package/styles/diff-view-pure.css +111 -0
- package/styles/diff-view.css +111 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
5
|
var core = require('@git-diff-view/core');
|
|
5
6
|
var React = require('react');
|
|
6
7
|
var index_js = require('use-sync-external-store/shim/index.js');
|
|
@@ -42,40 +43,6 @@ PERFORMANCE OF THIS SOFTWARE.
|
|
|
42
43
|
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
43
44
|
|
|
44
45
|
|
|
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
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
58
|
-
var e = new Error(message);
|
|
59
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
/******************************************************************************
|
|
63
|
-
Copyright (c) Microsoft Corporation.
|
|
64
|
-
|
|
65
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
66
|
-
purpose with or without fee is hereby granted.
|
|
67
|
-
|
|
68
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
69
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
70
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
71
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
72
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
73
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
74
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
75
|
-
***************************************************************************** */
|
|
76
|
-
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
77
|
-
|
|
78
|
-
|
|
79
46
|
function __classPrivateFieldGet(receiver, state, kind, f) {
|
|
80
47
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
81
48
|
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");
|
|
@@ -107,7 +74,7 @@ class TextMeasure {
|
|
|
107
74
|
_TextMeasure_map.set(this, {});
|
|
108
75
|
}
|
|
109
76
|
measure(text, font) {
|
|
110
|
-
const currentKey = getStableKey(font, text);
|
|
77
|
+
const currentKey = getStableKey(font || {}, text);
|
|
111
78
|
if (__classPrivateFieldGet(this, _TextMeasure_map, "f")[currentKey]) {
|
|
112
79
|
return __classPrivateFieldGet(this, _TextMeasure_map, "f")[currentKey];
|
|
113
80
|
}
|
|
@@ -223,7 +190,7 @@ const getDiffIdFromElement = (element) => {
|
|
|
223
190
|
while (el) {
|
|
224
191
|
if (el.getAttribute && el.getAttribute("data-component") === "git-diff-view") {
|
|
225
192
|
const ele = el.querySelector(".diff-view-wrapper");
|
|
226
|
-
return ele.getAttribute("id");
|
|
193
|
+
return ele === null || ele === void 0 ? void 0 : ele.getAttribute("id");
|
|
227
194
|
}
|
|
228
195
|
el = el.parentElement;
|
|
229
196
|
}
|
|
@@ -269,6 +236,7 @@ exports.DiffModeEnum = void 0;
|
|
|
269
236
|
const useIsMounted = () => {
|
|
270
237
|
const [isMounted, setIsMounted] = React.useState(false);
|
|
271
238
|
React.useEffect(() => {
|
|
239
|
+
// eslint-disable-next-line react-hooks/set-state-in-effect
|
|
272
240
|
setIsMounted(true);
|
|
273
241
|
}, []);
|
|
274
242
|
return isMounted;
|
|
@@ -276,6 +244,7 @@ const useIsMounted = () => {
|
|
|
276
244
|
|
|
277
245
|
const useUnmount = (cb, deps) => {
|
|
278
246
|
const ref = React.useRef(cb);
|
|
247
|
+
// eslint-disable-next-line react-hooks/refs
|
|
279
248
|
ref.current = cb;
|
|
280
249
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
281
250
|
React.useEffect(() => ref.current, deps);
|
|
@@ -286,7 +255,7 @@ const useSafeLayout = isClient ? React.useLayoutEffect : React.useEffect;
|
|
|
286
255
|
|
|
287
256
|
const useTextWidth = ({ text, font, }) => {
|
|
288
257
|
const [width, setWidth] = React.useState(() => {
|
|
289
|
-
const fontSize = parseInt(font.fontSize);
|
|
258
|
+
const fontSize = parseInt(font.fontSize || "13");
|
|
290
259
|
let baseSize = 6;
|
|
291
260
|
baseSize += fontSize > 10 ? (fontSize - 10) * 0.6 : 0;
|
|
292
261
|
return baseSize * text.length;
|
|
@@ -299,42 +268,39 @@ const useTextWidth = ({ text, font, }) => {
|
|
|
299
268
|
};
|
|
300
269
|
|
|
301
270
|
const DiffSplitAddWidget = ({ side, className, lineNumber, onWidgetClick, onOpenAddWidget, }) => {
|
|
302
|
-
return (
|
|
271
|
+
return (jsxRuntime.jsx("div", { "data-add-widget": core.SplitSide[side], className: "diff-add-widget-wrapper invisible select-none transition-transform hover:scale-110 group-hover:visible" +
|
|
303
272
|
(className ? " " + className : ""), style: {
|
|
304
273
|
width: `calc(var(${diffFontSizeName}) * 1.4)`,
|
|
305
274
|
height: `calc(var(${diffFontSizeName}) * 1.4)`,
|
|
306
275
|
top: `calc(var(${diffFontSizeName}) * 0.1)`,
|
|
307
|
-
}
|
|
308
|
-
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: {
|
|
276
|
+
}, children: jsxRuntime.jsx("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: {
|
|
309
277
|
color: `var(${addWidgetColorName})`,
|
|
310
278
|
backgroundColor: `var(${addWidgetBGName})`,
|
|
311
|
-
},
|
|
279
|
+
}, onMouseDown: (e) => {
|
|
280
|
+
e.stopPropagation();
|
|
312
281
|
onOpenAddWidget(lineNumber, side);
|
|
313
282
|
onWidgetClick === null || onWidgetClick === void 0 ? void 0 : onWidgetClick(lineNumber, side);
|
|
314
|
-
}
|
|
283
|
+
}, children: "+" }) }));
|
|
315
284
|
};
|
|
316
285
|
const DiffUnifiedAddWidget = ({ lineNumber, side, onWidgetClick, onOpenAddWidget, }) => {
|
|
317
|
-
return (
|
|
286
|
+
return (jsxRuntime.jsx("div", { "data-add-widget": core.SplitSide[side], className: "diff-add-widget-wrapper invisible absolute left-[100%] translate-x-[-50%] select-none transition-transform hover:scale-110 group-hover:visible", style: {
|
|
318
287
|
width: `calc(var(${diffFontSizeName}) * 1.4)`,
|
|
319
288
|
height: `calc(var(${diffFontSizeName}) * 1.4)`,
|
|
320
289
|
top: `calc(var(${diffFontSizeName}) * 0.1)`,
|
|
321
|
-
}
|
|
322
|
-
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: {
|
|
290
|
+
}, children: jsxRuntime.jsx("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: {
|
|
323
291
|
color: `var(${addWidgetColorName})`,
|
|
324
292
|
backgroundColor: `var(${addWidgetBGName})`,
|
|
325
|
-
},
|
|
293
|
+
}, onMouseDown: (e) => {
|
|
294
|
+
e.stopPropagation();
|
|
326
295
|
onOpenAddWidget(lineNumber, side);
|
|
327
296
|
onWidgetClick === null || onWidgetClick === void 0 ? void 0 : onWidgetClick(lineNumber, side);
|
|
328
|
-
}
|
|
297
|
+
}, children: "+" }) }));
|
|
329
298
|
};
|
|
330
299
|
|
|
331
300
|
const DiffNoNewLine = () => {
|
|
332
|
-
return (
|
|
333
|
-
React__namespace.createElement("path", { d: "M4.25 7.25a.75.75 0 0 0 0 1.5h7.5a.75.75 0 0 0 0-1.5h-7.5Z" }),
|
|
334
|
-
React__namespace.createElement("path", { d: "M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0Zm-1.5 0a6.5 6.5 0 1 0-13 0 6.5 6.5 0 0 0 13 0Z" })));
|
|
301
|
+
return (jsxRuntime.jsxs("svg", { "aria-label": "No newline at end of file", role: "img", viewBox: "0 0 16 16", version: "1.1", fill: "currentColor", children: [jsxRuntime.jsx("path", { d: "M4.25 7.25a.75.75 0 0 0 0 1.5h7.5a.75.75 0 0 0 0-1.5h-7.5Z" }), jsxRuntime.jsx("path", { d: "M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0Zm-1.5 0a6.5 6.5 0 1 0-13 0 6.5 6.5 0 0 0 13 0Z" })] }));
|
|
335
302
|
};
|
|
336
303
|
|
|
337
|
-
/* eslint-disable max-lines */
|
|
338
304
|
const temp = {};
|
|
339
305
|
const formatStringToCamelCase = (str) => {
|
|
340
306
|
if (str.startsWith("--"))
|
|
@@ -366,73 +332,65 @@ const DiffString = ({ rawLine, diffLine, operator, plainLine, enableWrap, }) =>
|
|
|
366
332
|
if (changes === null || changes === void 0 ? void 0 : changes.hasLineChange) {
|
|
367
333
|
const isNewLineSymbolChanged = changes.newLineSymbol;
|
|
368
334
|
if (!(diffLine === null || diffLine === void 0 ? void 0 : diffLine.plainTemplate) && typeof core.getPlainDiffTemplate === "function") {
|
|
369
|
-
core.getPlainDiffTemplate({ diffLine, rawLine, operator });
|
|
335
|
+
core.getPlainDiffTemplate({ diffLine: diffLine, rawLine, operator: operator });
|
|
370
336
|
}
|
|
371
337
|
if (diffLine === null || diffLine === void 0 ? void 0 : diffLine.plainTemplate) {
|
|
372
|
-
return (
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
height: `var(${diffFontSizeName})`,
|
|
377
|
-
} },
|
|
378
|
-
React__namespace.createElement(DiffNoNewLine, null)))));
|
|
338
|
+
return (jsxRuntime.jsxs("span", { className: "diff-line-content-raw", children: [jsxRuntime.jsx("span", { "data-template": true, dangerouslySetInnerHTML: { __html: diffLine.plainTemplate } }), isNewLineSymbolChanged === NewLineSymbol.NEWLINE && (jsxRuntime.jsx("span", { "data-no-newline-at-end-of-file-symbol": true, className: enableWrap ? "block !text-red-500" : "inline-block align-middle !text-red-500", style: {
|
|
339
|
+
width: `var(${diffFontSizeName})`,
|
|
340
|
+
height: `var(${diffFontSizeName})`,
|
|
341
|
+
}, children: jsxRuntime.jsx(DiffNoNewLine, {}) }))] }));
|
|
379
342
|
}
|
|
380
343
|
}
|
|
381
344
|
if (plainLine && !(plainLine === null || plainLine === void 0 ? void 0 : plainLine.template)) {
|
|
345
|
+
// eslint-disable-next-line react-hooks/immutability
|
|
382
346
|
plainLine.template = core.getPlainLineTemplate(plainLine.value);
|
|
383
347
|
}
|
|
384
348
|
if (plainLine === null || plainLine === void 0 ? void 0 : plainLine.template) {
|
|
385
|
-
return (
|
|
386
|
-
React__namespace.createElement("span", { "data-template": true, dangerouslySetInnerHTML: { __html: plainLine.template } })));
|
|
349
|
+
return (jsxRuntime.jsx("span", { className: "diff-line-content-raw", children: jsxRuntime.jsx("span", { "data-template": true, dangerouslySetInnerHTML: { __html: plainLine.template } }) }));
|
|
387
350
|
}
|
|
388
|
-
return
|
|
351
|
+
return jsxRuntime.jsx("span", { className: "diff-line-content-raw", children: rawLine });
|
|
389
352
|
};
|
|
390
353
|
const DiffSyntax = ({ rawLine, diffFile, diffLine, operator, syntaxLine, enableWrap, }) => {
|
|
391
354
|
var _a;
|
|
392
355
|
if (!syntaxLine) {
|
|
393
|
-
return
|
|
356
|
+
return jsxRuntime.jsx(DiffString, { rawLine: rawLine, diffLine: diffLine, operator: operator, enableWrap: enableWrap });
|
|
394
357
|
}
|
|
395
358
|
const changes = diffLine === null || diffLine === void 0 ? void 0 : diffLine.changes;
|
|
396
359
|
if (changes === null || changes === void 0 ? void 0 : changes.hasLineChange) {
|
|
397
360
|
const isNewLineSymbolChanged = changes.newLineSymbol;
|
|
398
361
|
if (!(diffLine === null || diffLine === void 0 ? void 0 : diffLine.syntaxTemplate) && typeof core.getSyntaxDiffTemplate === "function") {
|
|
399
|
-
core.getSyntaxDiffTemplate({ diffFile, diffLine, syntaxLine, operator });
|
|
362
|
+
core.getSyntaxDiffTemplate({ diffFile, diffLine: diffLine, syntaxLine, operator: operator });
|
|
400
363
|
}
|
|
401
364
|
if (diffLine === null || diffLine === void 0 ? void 0 : diffLine.syntaxTemplate) {
|
|
402
|
-
return (
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
height: `var(${diffFontSizeName})`,
|
|
407
|
-
} },
|
|
408
|
-
React__namespace.createElement(DiffNoNewLine, null)))));
|
|
365
|
+
return (jsxRuntime.jsxs("span", { className: "diff-line-syntax-raw", children: [jsxRuntime.jsx("span", { "data-template": true, dangerouslySetInnerHTML: { __html: diffLine.syntaxTemplate } }), isNewLineSymbolChanged === NewLineSymbol.NEWLINE && (jsxRuntime.jsx("span", { "data-no-newline-at-end-of-file-symbol": true, className: enableWrap ? "block !text-red-500" : "inline-block align-middle !text-red-500", style: {
|
|
366
|
+
width: `var(${diffFontSizeName})`,
|
|
367
|
+
height: `var(${diffFontSizeName})`,
|
|
368
|
+
}, children: jsxRuntime.jsx(DiffNoNewLine, {}) }))] }));
|
|
409
369
|
}
|
|
410
370
|
}
|
|
411
371
|
if (!syntaxLine.template) {
|
|
372
|
+
// eslint-disable-next-line react-hooks/immutability
|
|
412
373
|
syntaxLine.template = core.getSyntaxLineTemplate(syntaxLine);
|
|
413
374
|
}
|
|
414
375
|
if (syntaxLine === null || syntaxLine === void 0 ? void 0 : syntaxLine.template) {
|
|
415
|
-
return (
|
|
416
|
-
React__namespace.createElement("span", { "data-template": true, dangerouslySetInnerHTML: { __html: syntaxLine.template } })));
|
|
376
|
+
return (jsxRuntime.jsx("span", { className: "diff-line-syntax-raw", children: jsxRuntime.jsx("span", { "data-template": true, dangerouslySetInnerHTML: { __html: syntaxLine.template } }) }));
|
|
417
377
|
}
|
|
418
|
-
return (
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
378
|
+
return (jsxRuntime.jsx("span", { className: "diff-line-syntax-raw", children: (_a = syntaxLine === null || syntaxLine === void 0 ? void 0 : syntaxLine.nodeList) === null || _a === void 0 ? void 0 : _a.map(({ node, wrapper }, index) => {
|
|
379
|
+
var _a, _b, _c;
|
|
380
|
+
return (jsxRuntime.jsx("span", { "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) || ""), children: node.value }, index));
|
|
381
|
+
}) }));
|
|
422
382
|
};
|
|
423
383
|
const DiffContent = ({ diffFile, diffLine, rawLine, plainLine, syntaxLine, enableWrap, enableHighlight, }) => {
|
|
424
384
|
var _a;
|
|
425
385
|
const isAdded = (diffLine === null || diffLine === void 0 ? void 0 : diffLine.type) === core.DiffLineType.Add;
|
|
426
386
|
const isDelete = (diffLine === null || diffLine === void 0 ? void 0 : diffLine.type) === core.DiffLineType.Delete;
|
|
427
|
-
const isMaxLineLengthToIgnoreSyntax = ((_a = syntaxLine === null || syntaxLine === void 0 ? void 0 : syntaxLine.nodeList) === null || _a === void 0 ? void 0 : _a.length) > 150;
|
|
428
|
-
return (
|
|
387
|
+
const isMaxLineLengthToIgnoreSyntax = syntaxLine && ((_a = syntaxLine === null || syntaxLine === void 0 ? void 0 : syntaxLine.nodeList) === null || _a === void 0 ? void 0 : _a.length) > 150;
|
|
388
|
+
return (jsxRuntime.jsxs("div", { className: "diff-line-content-item pl-[2.0em]",
|
|
429
389
|
// data-val={rawLine}
|
|
430
390
|
style: {
|
|
431
391
|
whiteSpace: enableWrap ? "pre-wrap" : "pre",
|
|
432
392
|
wordBreak: enableWrap ? "break-all" : "initial",
|
|
433
|
-
} },
|
|
434
|
-
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 ? "-" : " "),
|
|
435
|
-
enableHighlight && syntaxLine && !isMaxLineLengthToIgnoreSyntax ? (React__namespace.createElement(DiffSyntax, { operator: isAdded ? "add" : isDelete ? "del" : undefined, rawLine: rawLine, diffFile: diffFile, diffLine: diffLine, syntaxLine: syntaxLine, enableWrap: enableWrap })) : (React__namespace.createElement(DiffString, { operator: isAdded ? "add" : isDelete ? "del" : undefined, rawLine: rawLine, diffLine: diffLine, plainLine: plainLine, enableWrap: enableWrap }))));
|
|
393
|
+
}, children: [jsxRuntime.jsx("span", { "data-operator": isAdded ? "+" : isDelete ? "-" : undefined, className: "diff-line-content-operator ml-[-1.5em] inline-block w-[1.5em] select-none indent-[0.2em]", children: isAdded ? "+" : isDelete ? "-" : " " }), enableHighlight && syntaxLine && !isMaxLineLengthToIgnoreSyntax ? (jsxRuntime.jsx(DiffSyntax, { operator: isAdded ? "add" : isDelete ? "del" : undefined, rawLine: rawLine, diffFile: diffFile, diffLine: diffLine, syntaxLine: syntaxLine, enableWrap: enableWrap })) : (jsxRuntime.jsx(DiffString, { operator: isAdded ? "add" : isDelete ? "del" : undefined, rawLine: rawLine, diffLine: diffLine, plainLine: plainLine, enableWrap: enableWrap }))] }));
|
|
436
394
|
};
|
|
437
395
|
|
|
438
396
|
const DiffViewContext = React.createContext(null);
|
|
@@ -444,7 +402,7 @@ DiffWidgetContext.displayName = "DiffWidgetContext";
|
|
|
444
402
|
const useDiffWidgetContext = () => React.useContext(DiffWidgetContext);
|
|
445
403
|
|
|
446
404
|
const InternalDiffSplitLine$1 = ({ index, diffFile, lineNumber, side, enableAddWidget, enableHighlight, }) => {
|
|
447
|
-
var _a, _b;
|
|
405
|
+
var _a, _b, _c, _d, _e;
|
|
448
406
|
const getCurrentSyntaxLine = side === core.SplitSide.old ? diffFile.getOldSyntaxLine : diffFile.getNewSyntaxLine;
|
|
449
407
|
const getCurrentPlainLine = side === core.SplitSide.old ? diffFile.getOldPlainLine : diffFile.getNewPlainLine;
|
|
450
408
|
const oldLine = diffFile.getSplitLeftLine(index);
|
|
@@ -461,28 +419,22 @@ const InternalDiffSplitLine$1 = ({ index, diffFile, lineNumber, side, enableAddW
|
|
|
461
419
|
const setWidget = useWidget.getReadonlyState().setWidget;
|
|
462
420
|
const contentBG = getContentBG(isAdded, isDelete, hasDiff);
|
|
463
421
|
const lineNumberBG = getLineNumberBG(isAdded, isDelete, hasDiff);
|
|
464
|
-
const syntaxLine = getCurrentSyntaxLine(currentLine.lineNumber);
|
|
465
|
-
const plainLine = getCurrentPlainLine(currentLine.lineNumber);
|
|
466
|
-
return (
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
} },
|
|
474
|
-
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 }) })),
|
|
475
|
-
React__namespace.createElement("span", { "data-line-num": currentLine.lineNumber, style: { opacity: hasChange ? undefined : 0.5 } }, currentLine.lineNumber)),
|
|
476
|
-
React__namespace.createElement("td", { className: `diff-line-${core.SplitSide[side]}-content pr-[10px] align-top`, style: { backgroundColor: contentBG } },
|
|
477
|
-
React__namespace.createElement(DiffContent, { enableWrap: false, diffFile: diffFile, rawLine: (currentLine === null || currentLine === void 0 ? void 0 : currentLine.value) || "", diffLine: currentLine === null || currentLine === void 0 ? void 0 : currentLine.diff, plainLine: plainLine, syntaxLine: syntaxLine, enableHighlight: enableHighlight })))) : (React__namespace.createElement("td", { className: `diff-line-${core.SplitSide[side]}-placeholder select-none`, style: { backgroundColor: `var(${emptyBGName})` }, colSpan: 2 },
|
|
478
|
-
React__namespace.createElement("span", null, "\u2002")))));
|
|
422
|
+
const syntaxLine = getCurrentSyntaxLine((_c = currentLine.lineNumber) !== null && _c !== void 0 ? _c : -1);
|
|
423
|
+
const plainLine = getCurrentPlainLine((_d = currentLine.lineNumber) !== null && _d !== void 0 ? _d : -1);
|
|
424
|
+
return (jsxRuntime.jsx("tr", { "data-line": lineNumber, "data-state": hasDiff || !hasContent ? "diff" : "plain", "data-side": core.SplitSide[side], className: "diff-line" + (hasContent ? " group" : ""), children: hasContent ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("td", { className: `diff-line-${core.SplitSide[side]}-num sticky left-0 z-[1] w-[1%] min-w-[40px] select-none pl-[10px] pr-[10px] text-right align-top`, style: {
|
|
425
|
+
backgroundColor: lineNumberBG,
|
|
426
|
+
color: `var(${hasDiff ? plainLineNumberColorName : expandLineNumberColorName})`,
|
|
427
|
+
width: `var(${diffAsideWidthName})`,
|
|
428
|
+
minWidth: `var(${diffAsideWidthName})`,
|
|
429
|
+
maxWidth: `var(${diffAsideWidthName})`,
|
|
430
|
+
}, children: [hasDiff && enableAddWidget && (jsxRuntime.jsx(DiffSplitAddWidget, { index: index, lineNumber: (_e = currentLine.lineNumber) !== null && _e !== void 0 ? _e : -1, 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 }) })), jsxRuntime.jsx("span", { "data-line-num": currentLine.lineNumber, style: { opacity: hasChange ? undefined : 0.5 }, children: currentLine.lineNumber })] }), jsxRuntime.jsx("td", { className: `diff-line-${core.SplitSide[side]}-content pr-[10px] align-top`, style: { backgroundColor: contentBG }, children: jsxRuntime.jsx(DiffContent, { enableWrap: false, diffFile: diffFile, rawLine: (currentLine === null || currentLine === void 0 ? void 0 : currentLine.value) || "", diffLine: currentLine === null || currentLine === void 0 ? void 0 : currentLine.diff, plainLine: plainLine, syntaxLine: syntaxLine, enableHighlight: enableHighlight }) })] })) : (jsxRuntime.jsx("td", { className: `diff-line-${core.SplitSide[side]}-placeholder select-none`, style: { backgroundColor: `var(${emptyBGName})` }, colSpan: 2, children: jsxRuntime.jsx("span", { children: "\u2002" }) })) }));
|
|
479
431
|
};
|
|
480
432
|
const DiffSplitContentLine$1 = ({ index, diffFile, lineNumber, side, enableAddWidget, enableHighlight, }) => {
|
|
481
433
|
const getCurrentLine = side === core.SplitSide.old ? diffFile.getSplitLeftLine : diffFile.getSplitRightLine;
|
|
482
434
|
const currentLine = getCurrentLine(index);
|
|
483
435
|
if (currentLine === null || currentLine === void 0 ? void 0 : currentLine.isHidden)
|
|
484
436
|
return null;
|
|
485
|
-
return (
|
|
437
|
+
return (jsxRuntime.jsx(InternalDiffSplitLine$1, { index: index, diffFile: diffFile, lineNumber: lineNumber, side: side, enableAddWidget: enableAddWidget, enableHighlight: enableHighlight }));
|
|
486
438
|
};
|
|
487
439
|
|
|
488
440
|
const useDomWidth = ({ selector, enable }) => {
|
|
@@ -508,10 +460,10 @@ const useDomWidth = ({ selector, enable }) => {
|
|
|
508
460
|
};
|
|
509
461
|
cb();
|
|
510
462
|
const cleanCb = () => {
|
|
511
|
-
var _a;
|
|
512
|
-
typedWrapper.__observeCallback.delete(cb);
|
|
513
|
-
if (typedWrapper.__observeCallback.size === 0) {
|
|
514
|
-
(
|
|
463
|
+
var _a, _b, _c;
|
|
464
|
+
(_a = typedWrapper === null || typedWrapper === void 0 ? void 0 : typedWrapper.__observeCallback) === null || _a === void 0 ? void 0 : _a.delete(cb);
|
|
465
|
+
if (((_b = typedWrapper === null || typedWrapper === void 0 ? void 0 : typedWrapper.__observeCallback) === null || _b === void 0 ? void 0 : _b.size) === 0) {
|
|
466
|
+
(_c = typedWrapper.__observeInstance) === null || _c === void 0 ? void 0 : _c.disconnect();
|
|
515
467
|
typedWrapper.removeAttribute("data-observe");
|
|
516
468
|
delete typedWrapper.__observeCallback;
|
|
517
469
|
delete typedWrapper.__observeInstance;
|
|
@@ -523,7 +475,7 @@ const useDomWidth = ({ selector, enable }) => {
|
|
|
523
475
|
}
|
|
524
476
|
typedWrapper.__observeCallback = new Set();
|
|
525
477
|
typedWrapper.__observeCallback.add(cb);
|
|
526
|
-
const observer = new ResizeObserver(() => typedWrapper.__observeCallback.forEach((cb) => cb()));
|
|
478
|
+
const observer = new ResizeObserver(() => { var _a; return (_a = typedWrapper === null || typedWrapper === void 0 ? void 0 : typedWrapper.__observeCallback) === null || _a === void 0 ? void 0 : _a.forEach((cb) => cb()); });
|
|
527
479
|
typedWrapper.__observeInstance = observer;
|
|
528
480
|
observer.observe(typedWrapper);
|
|
529
481
|
typedWrapper.setAttribute("data-observe", "height");
|
|
@@ -566,10 +518,10 @@ const useSyncHeight = ({ selector, wrapper, side, enable, }) => {
|
|
|
566
518
|
};
|
|
567
519
|
cb();
|
|
568
520
|
const cleanCb = () => {
|
|
569
|
-
var _a;
|
|
570
|
-
typedTarget.__observeCallback.delete(cb);
|
|
571
|
-
if (typedTarget.__observeCallback.size === 0) {
|
|
572
|
-
(
|
|
521
|
+
var _a, _b, _c;
|
|
522
|
+
(_a = typedTarget === null || typedTarget === void 0 ? void 0 : typedTarget.__observeCallback) === null || _a === void 0 ? void 0 : _a.delete(cb);
|
|
523
|
+
if (((_b = typedTarget === null || typedTarget === void 0 ? void 0 : typedTarget.__observeCallback) === null || _b === void 0 ? void 0 : _b.size) === 0) {
|
|
524
|
+
(_c = typedTarget.__observeInstance) === null || _c === void 0 ? void 0 : _c.disconnect();
|
|
573
525
|
typedTarget.removeAttribute("data-observe");
|
|
574
526
|
delete typedTarget.__observeCallback;
|
|
575
527
|
delete typedTarget.__observeInstance;
|
|
@@ -581,7 +533,7 @@ const useSyncHeight = ({ selector, wrapper, side, enable, }) => {
|
|
|
581
533
|
}
|
|
582
534
|
typedTarget.__observeCallback = new Set();
|
|
583
535
|
typedTarget.__observeCallback.add(cb);
|
|
584
|
-
const observer = new ResizeObserver(() => typedTarget.__observeCallback.forEach((cb) => cb()));
|
|
536
|
+
const observer = new ResizeObserver(() => { var _a; return (_a = typedTarget === null || typedTarget === void 0 ? void 0 : typedTarget.__observeCallback) === null || _a === void 0 ? void 0 : _a.forEach((cb) => cb()); });
|
|
585
537
|
typedTarget.__observeInstance = observer;
|
|
586
538
|
observer.observe(target);
|
|
587
539
|
target.setAttribute("data-observe", "height");
|
|
@@ -606,7 +558,7 @@ const InternalDiffSplitExtendLine$1 = ({ index, diffFile, oldLineExtend, newLine
|
|
|
606
558
|
(renderExtendLine === null || renderExtendLine === void 0 ? void 0 : renderExtendLine({
|
|
607
559
|
diffFile,
|
|
608
560
|
side,
|
|
609
|
-
lineNumber: currentLineNumber,
|
|
561
|
+
lineNumber: currentLineNumber !== null && currentLineNumber !== void 0 ? currentLineNumber : -1,
|
|
610
562
|
data: currentExtend === null || currentExtend === void 0 ? void 0 : currentExtend.data,
|
|
611
563
|
onUpdate: diffFile.notifyAll,
|
|
612
564
|
}));
|
|
@@ -622,19 +574,17 @@ const InternalDiffSplitExtendLine$1 = ({ index, diffFile, oldLineExtend, newLine
|
|
|
622
574
|
});
|
|
623
575
|
if (!renderExtendLine)
|
|
624
576
|
return null;
|
|
625
|
-
return (
|
|
626
|
-
React__namespace.createElement("div", { "data-line": `${lineNumber}-extend-content`, "data-side": core.SplitSide[side], className: "diff-line-extend-wrapper sticky left-0 z-[1]", style: { width } }, width > 0 && currentExtendRendered))) : (React__namespace.createElement("td", { className: `diff-line-extend-${core.SplitSide[side]}-placeholder select-none p-0`, style: { backgroundColor: `var(${emptyBGName})` }, colSpan: 2 },
|
|
627
|
-
React__namespace.createElement("div", { "data-line": `${lineNumber}-extend-content`, "data-side": core.SplitSide[side] })))));
|
|
577
|
+
return (jsxRuntime.jsx("tr", { "data-line": `${lineNumber}-extend`, "data-state": "extend", "data-side": core.SplitSide[side], className: "diff-line diff-line-extend", children: currentSideHasExtend ? (jsxRuntime.jsx("td", { className: `diff-line-extend-${core.SplitSide[side]}-content p-0`, colSpan: 2, children: jsxRuntime.jsx("div", { "data-line": `${lineNumber}-extend-content`, "data-side": core.SplitSide[side], className: "diff-line-extend-wrapper sticky left-0 z-[1]", style: { width }, children: width > 0 && currentExtendRendered }) })) : (jsxRuntime.jsx("td", { className: `diff-line-extend-${core.SplitSide[side]}-placeholder select-none p-0`, style: { backgroundColor: `var(${emptyBGName})` }, colSpan: 2, children: jsxRuntime.jsx("div", { "data-line": `${lineNumber}-extend-content`, "data-side": core.SplitSide[side] }) })) }));
|
|
628
578
|
};
|
|
629
579
|
const DiffSplitExtendLine$1 = ({ index, diffFile, side, lineNumber, }) => {
|
|
630
580
|
const { useDiffContext } = useDiffViewContext();
|
|
631
581
|
const oldLine = diffFile.getSplitLeftLine(index);
|
|
632
582
|
const newLine = diffFile.getSplitRightLine(index);
|
|
633
583
|
const { oldLineExtend, newLineExtend } = useDiffContext(React__namespace.useCallback((s) => {
|
|
634
|
-
var _a, _b, _c, _d;
|
|
584
|
+
var _a, _b, _c, _d, _e, _f;
|
|
635
585
|
return ({
|
|
636
|
-
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],
|
|
637
|
-
newLineExtend: (
|
|
586
|
+
oldLineExtend: (_b = (_a = s.extendData) === null || _a === void 0 ? void 0 : _a.oldFile) === null || _b === void 0 ? void 0 : _b[(_c = oldLine === null || oldLine === void 0 ? void 0 : oldLine.lineNumber) !== null && _c !== void 0 ? _c : -1],
|
|
587
|
+
newLineExtend: (_e = (_d = s.extendData) === null || _d === void 0 ? void 0 : _d.newFile) === null || _e === void 0 ? void 0 : _e[(_f = newLine === null || newLine === void 0 ? void 0 : newLine.lineNumber) !== null && _f !== void 0 ? _f : -1],
|
|
638
588
|
});
|
|
639
589
|
}, [oldLine === null || oldLine === void 0 ? void 0 : oldLine.lineNumber, newLine === null || newLine === void 0 ? void 0 : newLine.lineNumber]));
|
|
640
590
|
const hasExtend = (oldLineExtend === null || oldLineExtend === void 0 ? void 0 : oldLineExtend.data) || (newLineExtend === null || newLineExtend === void 0 ? void 0 : newLineExtend.data);
|
|
@@ -644,20 +594,17 @@ const DiffSplitExtendLine$1 = ({ index, diffFile, side, lineNumber, }) => {
|
|
|
644
594
|
const currentIsShow = hasExtend && (!currentLine.isHidden || !enableExpand);
|
|
645
595
|
if (!currentIsShow)
|
|
646
596
|
return null;
|
|
647
|
-
return (
|
|
597
|
+
return (jsxRuntime.jsx(InternalDiffSplitExtendLine$1, { side: side, index: index, diffFile: diffFile, lineNumber: lineNumber, oldLineExtend: oldLineExtend, newLineExtend: newLineExtend }));
|
|
648
598
|
};
|
|
649
599
|
|
|
650
600
|
const ExpandDown = ({ className }) => {
|
|
651
|
-
return (
|
|
652
|
-
React__namespace.createElement("path", { d: "m8.177 14.323 2.896-2.896a.25.25 0 0 0-.177-.427H8.75V7.764a.75.75 0 1 0-1.5 0V11H5.104a.25.25 0 0 0-.177.427l2.896 2.896a.25.25 0 0 0 .354 0ZM2.25 5a.75.75 0 0 0 0-1.5h-.5a.75.75 0 0 0 0 1.5h.5ZM6 4.25a.75.75 0 0 1-.75.75h-.5a.75.75 0 0 1 0-1.5h.5a.75.75 0 0 1 .75.75ZM8.25 5a.75.75 0 0 0 0-1.5h-.5a.75.75 0 0 0 0 1.5h.5ZM12 4.25a.75.75 0 0 1-.75.75h-.5a.75.75 0 0 1 0-1.5h.5a.75.75 0 0 1 .75.75Zm2.25.75a.75.75 0 0 0 0-1.5h-.5a.75.75 0 0 0 0 1.5h.5Z" })));
|
|
601
|
+
return (jsxRuntime.jsx("svg", { "aria-hidden": "true", height: "16", viewBox: "0 0 16 16", version: "1.1", width: "16", className: className, children: jsxRuntime.jsx("path", { d: "m8.177 14.323 2.896-2.896a.25.25 0 0 0-.177-.427H8.75V7.764a.75.75 0 1 0-1.5 0V11H5.104a.25.25 0 0 0-.177.427l2.896 2.896a.25.25 0 0 0 .354 0ZM2.25 5a.75.75 0 0 0 0-1.5h-.5a.75.75 0 0 0 0 1.5h.5ZM6 4.25a.75.75 0 0 1-.75.75h-.5a.75.75 0 0 1 0-1.5h.5a.75.75 0 0 1 .75.75ZM8.25 5a.75.75 0 0 0 0-1.5h-.5a.75.75 0 0 0 0 1.5h.5ZM12 4.25a.75.75 0 0 1-.75.75h-.5a.75.75 0 0 1 0-1.5h.5a.75.75 0 0 1 .75.75Zm2.25.75a.75.75 0 0 0 0-1.5h-.5a.75.75 0 0 0 0 1.5h.5Z" }) }));
|
|
653
602
|
};
|
|
654
603
|
const ExpandUp = ({ className }) => {
|
|
655
|
-
return (
|
|
656
|
-
React__namespace.createElement("path", { d: "M7.823 1.677 4.927 4.573A.25.25 0 0 0 5.104 5H7.25v3.236a.75.75 0 1 0 1.5 0V5h2.146a.25.25 0 0 0 .177-.427L8.177 1.677a.25.25 0 0 0-.354 0ZM13.75 11a.75.75 0 0 0 0 1.5h.5a.75.75 0 0 0 0-1.5h-.5Zm-3.75.75a.75.75 0 0 1 .75-.75h.5a.75.75 0 0 1 0 1.5h-.5a.75.75 0 0 1-.75-.75ZM7.75 11a.75.75 0 0 0 0 1.5h.5a.75.75 0 0 0 0-1.5h-.5ZM4 11.75a.75.75 0 0 1 .75-.75h.5a.75.75 0 0 1 0 1.5h-.5a.75.75 0 0 1-.75-.75ZM1.75 11a.75.75 0 0 0 0 1.5h.5a.75.75 0 0 0 0-1.5h-.5Z" })));
|
|
604
|
+
return (jsxRuntime.jsx("svg", { "aria-hidden": "true", height: "16", viewBox: "0 0 16 16", version: "1.1", width: "16", className: className, children: jsxRuntime.jsx("path", { d: "M7.823 1.677 4.927 4.573A.25.25 0 0 0 5.104 5H7.25v3.236a.75.75 0 1 0 1.5 0V5h2.146a.25.25 0 0 0 .177-.427L8.177 1.677a.25.25 0 0 0-.354 0ZM13.75 11a.75.75 0 0 0 0 1.5h.5a.75.75 0 0 0 0-1.5h-.5Zm-3.75.75a.75.75 0 0 1 .75-.75h.5a.75.75 0 0 1 0 1.5h-.5a.75.75 0 0 1-.75-.75ZM7.75 11a.75.75 0 0 0 0 1.5h.5a.75.75 0 0 0 0-1.5h-.5ZM4 11.75a.75.75 0 0 1 .75-.75h.5a.75.75 0 0 1 0 1.5h-.5a.75.75 0 0 1-.75-.75ZM1.75 11a.75.75 0 0 0 0 1.5h.5a.75.75 0 0 0 0-1.5h-.5Z" }) }));
|
|
657
605
|
};
|
|
658
606
|
const ExpandAll = ({ className }) => {
|
|
659
|
-
return (
|
|
660
|
-
React__namespace.createElement("path", { d: "m8.177.677 2.896 2.896a.25.25 0 0 1-.177.427H8.75v1.25a.75.75 0 0 1-1.5 0V4H5.104a.25.25 0 0 1-.177-.427L7.823.677a.25.25 0 0 1 .354 0ZM7.25 10.75a.75.75 0 0 1 1.5 0V12h2.146a.25.25 0 0 1 .177.427l-2.896 2.896a.25.25 0 0 1-.354 0l-2.896-2.896A.25.25 0 0 1 5.104 12H7.25v-1.25Zm-5-2a.75.75 0 0 0 0-1.5h-.5a.75.75 0 0 0 0 1.5h.5ZM6 8a.75.75 0 0 1-.75.75h-.5a.75.75 0 0 1 0-1.5h.5A.75.75 0 0 1 6 8Zm2.25.75a.75.75 0 0 0 0-1.5h-.5a.75.75 0 0 0 0 1.5h.5ZM12 8a.75.75 0 0 1-.75.75h-.5a.75.75 0 0 1 0-1.5h.5A.75.75 0 0 1 12 8Zm2.25.75a.75.75 0 0 0 0-1.5h-.5a.75.75 0 0 0 0 1.5h.5Z" })));
|
|
607
|
+
return (jsxRuntime.jsx("svg", { "aria-hidden": "true", height: "16", viewBox: "0 0 16 16", version: "1.1", width: "16", className: className, children: jsxRuntime.jsx("path", { d: "m8.177.677 2.896 2.896a.25.25 0 0 1-.177.427H8.75v1.25a.75.75 0 0 1-1.5 0V4H5.104a.25.25 0 0 1-.177-.427L7.823.677a.25.25 0 0 1 .354 0ZM7.25 10.75a.75.75 0 0 1 1.5 0V12h2.146a.25.25 0 0 1 .177.427l-2.896 2.896a.25.25 0 0 1-.354 0l-2.896-2.896A.25.25 0 0 1 5.104 12H7.25v-1.25Zm-5-2a.75.75 0 0 0 0-1.5h-.5a.75.75 0 0 0 0 1.5h.5ZM6 8a.75.75 0 0 1-.75.75h-.5a.75.75 0 0 1 0-1.5h.5A.75.75 0 0 1 6 8Zm2.25.75a.75.75 0 0 0 0-1.5h-.5a.75.75 0 0 0 0 1.5h.5ZM12 8a.75.75 0 0 1-.75.75h-.5a.75.75 0 0 1 0-1.5h.5A.75.75 0 0 1 12 8Zm2.25.75a.75.75 0 0 0 0-1.5h-.5a.75.75 0 0 0 0 1.5h.5Z" }) }));
|
|
661
608
|
};
|
|
662
609
|
|
|
663
610
|
const InternalDiffSplitHunkLineGitHub = ({ index, diffFile, side, lineNumber, }) => {
|
|
@@ -676,26 +623,15 @@ const InternalDiffSplitHunkLineGitHub = ({ index, diffFile, side, lineNumber, })
|
|
|
676
623
|
currentHunk.splitInfo.endHiddenIndex - currentHunk.splitInfo.startHiddenIndex < core.composeLen;
|
|
677
624
|
const isFirstLine = currentHunk && currentHunk.isFirst;
|
|
678
625
|
const isLastLine = currentHunk && currentHunk.isLast;
|
|
679
|
-
return (
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
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]", title: "Expand All", "data-title": "Expand All", onClick: () => diffFile.onSplitHunkExpand("all", index) },
|
|
689
|
-
React__namespace.createElement(ExpandAll, { className: "fill-current" }))) : (React__namespace.createElement(React__namespace.Fragment, null,
|
|
690
|
-
React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onSplitHunkExpand("down", index) },
|
|
691
|
-
React__namespace.createElement(ExpandDown, { className: "fill-current" })),
|
|
692
|
-
React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index) },
|
|
693
|
-
React__namespace.createElement(ExpandUp, { className: "fill-current" }))))) : (React__namespace.createElement("div", { className: "min-h-[28px]" }, "\u2002"))),
|
|
694
|
-
React__namespace.createElement("td", { className: "diff-line-hunk-content pr-[10px] align-middle", style: { backgroundColor: `var(${hunkContentBGName})` } },
|
|
695
|
-
React__namespace.createElement("div", { className: "pl-[1.5em]", style: {
|
|
696
|
-
color: `var(${hunkContentColorName})`,
|
|
697
|
-
} }, ((_a = currentHunk.splitInfo) === null || _a === void 0 ? void 0 : _a.plainText) || currentHunk.text)))) : (React__namespace.createElement("td", { className: "diff-line-hunk-placeholder select-none", colSpan: 2, style: { backgroundColor: `var(${hunkContentBGName})` } },
|
|
698
|
-
React__namespace.createElement("div", { className: "min-h-[28px]" }, "\u2002")))));
|
|
626
|
+
return (jsxRuntime.jsx("tr", { "data-line": `${lineNumber}-hunk`, "data-state": "hunk", "data-side": core.SplitSide[side], className: "diff-line diff-line-hunk", children: enableHunkAction ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("td", { className: "diff-line-hunk-action sticky left-0 w-[1%] min-w-[40px] select-none p-[1px]", style: {
|
|
627
|
+
backgroundColor: `var(${hunkLineNumberBGName})`,
|
|
628
|
+
color: `var(${plainLineNumberColorName})`,
|
|
629
|
+
width: `var(${diffAsideWidthName})`,
|
|
630
|
+
minWidth: `var(${diffAsideWidthName})`,
|
|
631
|
+
maxWidth: `var(${diffAsideWidthName})`,
|
|
632
|
+
}, children: couldExpand ? (isFirstLine ? (jsxRuntime.jsx("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index), children: jsxRuntime.jsx(ExpandUp, { className: "fill-current" }) })) : isLastLine ? (jsxRuntime.jsx("button", { className: "diff-widget-tooltip relative flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onSplitHunkExpand("down", index), children: jsxRuntime.jsx(ExpandDown, { className: "fill-current" }) })) : isExpandAll ? (jsxRuntime.jsx("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]", title: "Expand All", "data-title": "Expand All", onClick: () => diffFile.onSplitHunkExpand("all", index), children: jsxRuntime.jsx(ExpandAll, { className: "fill-current" }) })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onSplitHunkExpand("down", index), children: jsxRuntime.jsx(ExpandDown, { className: "fill-current" }) }), jsxRuntime.jsx("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index), children: jsxRuntime.jsx(ExpandUp, { className: "fill-current" }) })] }))) : (jsxRuntime.jsx("div", { className: "min-h-[28px]", children: "\u2002" })) }), jsxRuntime.jsx("td", { className: "diff-line-hunk-content pr-[10px] align-middle", style: { backgroundColor: `var(${hunkContentBGName})` }, children: jsxRuntime.jsx("div", { className: "pl-[1.5em]", style: {
|
|
633
|
+
color: `var(${hunkContentColorName})`,
|
|
634
|
+
}, children: ((_a = currentHunk.splitInfo) === null || _a === void 0 ? void 0 : _a.plainText) || currentHunk.text }) })] })) : (jsxRuntime.jsx("td", { className: "diff-line-hunk-placeholder select-none", colSpan: 2, style: { backgroundColor: `var(${hunkContentBGName})` }, children: jsxRuntime.jsx("div", { className: "min-h-[28px]", children: "\u2002" }) })) }));
|
|
699
635
|
};
|
|
700
636
|
const InternalDiffSplitHunkLineGitLab = ({ index, diffFile, side, lineNumber, }) => {
|
|
701
637
|
var _a;
|
|
@@ -712,25 +648,15 @@ const InternalDiffSplitHunkLineGitLab = ({ index, diffFile, side, lineNumber, })
|
|
|
712
648
|
currentHunk.splitInfo.endHiddenIndex - currentHunk.splitInfo.startHiddenIndex < core.composeLen;
|
|
713
649
|
const isFirstLine = currentHunk && currentHunk.isFirst;
|
|
714
650
|
const isLastLine = currentHunk && currentHunk.isLast;
|
|
715
|
-
return (
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
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]", title: "Expand All", "data-title": "Expand All", onClick: () => diffFile.onSplitHunkExpand("all", index) },
|
|
725
|
-
React__namespace.createElement(ExpandAll, { className: "fill-current" }))) : (React__namespace.createElement(React__namespace.Fragment, null,
|
|
726
|
-
React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onSplitHunkExpand("down", index) },
|
|
727
|
-
React__namespace.createElement(ExpandDown, { className: "fill-current" })),
|
|
728
|
-
React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index) },
|
|
729
|
-
React__namespace.createElement(ExpandUp, { className: "fill-current" }))))) : (React__namespace.createElement("div", { className: "min-h-[28px]" }, "\u2002"))),
|
|
730
|
-
React__namespace.createElement("td", { className: "diff-line-hunk-content pr-[10px] align-middle", style: { backgroundColor: `var(${hunkContentBGName})` } },
|
|
731
|
-
React__namespace.createElement("div", { className: "pl-[1.5em]", style: {
|
|
732
|
-
color: `var(${hunkContentColorName})`,
|
|
733
|
-
} }, ((_a = currentHunk.splitInfo) === null || _a === void 0 ? void 0 : _a.plainText) || currentHunk.text))));
|
|
651
|
+
return (jsxRuntime.jsxs("tr", { "data-line": `${lineNumber}-hunk`, "data-state": "hunk", "data-side": core.SplitSide[side], className: "diff-line diff-line-hunk", children: [jsxRuntime.jsx("td", { className: "diff-line-hunk-action sticky left-0 w-[1%] min-w-[40px] select-none p-[1px]", style: {
|
|
652
|
+
backgroundColor: `var(${hunkLineNumberBGName})`,
|
|
653
|
+
color: `var(${plainLineNumberColorName})`,
|
|
654
|
+
width: `var(${diffAsideWidthName})`,
|
|
655
|
+
minWidth: `var(${diffAsideWidthName})`,
|
|
656
|
+
maxWidth: `var(${diffAsideWidthName})`,
|
|
657
|
+
}, children: couldExpand ? (isFirstLine ? (jsxRuntime.jsx("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index), children: jsxRuntime.jsx(ExpandUp, { className: "fill-current" }) })) : isLastLine ? (jsxRuntime.jsx("button", { className: "diff-widget-tooltip relative flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onSplitHunkExpand("down", index), children: jsxRuntime.jsx(ExpandDown, { className: "fill-current" }) })) : isExpandAll ? (jsxRuntime.jsx("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]", title: "Expand All", "data-title": "Expand All", onClick: () => diffFile.onSplitHunkExpand("all", index), children: jsxRuntime.jsx(ExpandAll, { className: "fill-current" }) })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onSplitHunkExpand("down", index), children: jsxRuntime.jsx(ExpandDown, { className: "fill-current" }) }), jsxRuntime.jsx("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index), children: jsxRuntime.jsx(ExpandUp, { className: "fill-current" }) })] }))) : (jsxRuntime.jsx("div", { className: "min-h-[28px]", children: "\u2002" })) }), jsxRuntime.jsx("td", { className: "diff-line-hunk-content pr-[10px] align-middle", style: { backgroundColor: `var(${hunkContentBGName})` }, children: jsxRuntime.jsx("div", { className: "pl-[1.5em]", style: {
|
|
658
|
+
color: `var(${hunkContentColorName})`,
|
|
659
|
+
}, children: ((_a = currentHunk.splitInfo) === null || _a === void 0 ? void 0 : _a.plainText) || currentHunk.text }) })] }));
|
|
734
660
|
};
|
|
735
661
|
const InternalDiffSplitHunkLine$1 = ({ index, diffFile, side, lineNumber, }) => {
|
|
736
662
|
const { useDiffContext } = useDiffViewContext();
|
|
@@ -738,10 +664,10 @@ const InternalDiffSplitHunkLine$1 = ({ index, diffFile, side, lineNumber, }) =>
|
|
|
738
664
|
if (diffViewMode === exports.DiffModeEnum.SplitGitHub ||
|
|
739
665
|
diffViewMode === exports.DiffModeEnum.Split ||
|
|
740
666
|
diffViewMode === exports.DiffModeEnum.Unified) {
|
|
741
|
-
return
|
|
667
|
+
return jsxRuntime.jsx(InternalDiffSplitHunkLineGitHub, { index: index, diffFile: diffFile, side: side, lineNumber: lineNumber });
|
|
742
668
|
}
|
|
743
669
|
else {
|
|
744
|
-
return
|
|
670
|
+
return jsxRuntime.jsx(InternalDiffSplitHunkLineGitLab, { index: index, diffFile: diffFile, side: side, lineNumber: lineNumber });
|
|
745
671
|
}
|
|
746
672
|
};
|
|
747
673
|
const DiffSplitHunkLine$1 = ({ index, diffFile, side, lineNumber, }) => {
|
|
@@ -752,10 +678,11 @@ const DiffSplitHunkLine$1 = ({ index, diffFile, side, lineNumber, }) => {
|
|
|
752
678
|
const currentIsPureHunk = currentHunk && diffFile._getIsPureDiffRender() && !currentHunk.splitInfo;
|
|
753
679
|
if (!currentIsShow && !currentIsPureHunk)
|
|
754
680
|
return null;
|
|
755
|
-
return
|
|
681
|
+
return jsxRuntime.jsx(InternalDiffSplitHunkLine$1, { index: index, diffFile: diffFile, side: side, lineNumber: lineNumber });
|
|
756
682
|
};
|
|
757
683
|
|
|
758
684
|
const InternalDiffSplitWidgetLine$1 = ({ index, side, diffFile, lineNumber, }) => {
|
|
685
|
+
var _a;
|
|
759
686
|
const { useWidget } = useDiffWidgetContext();
|
|
760
687
|
const { useDiffContext } = useDiffViewContext();
|
|
761
688
|
const oldLine = diffFile.getSplitLeftLine(index);
|
|
@@ -774,14 +701,14 @@ const InternalDiffSplitWidgetLine$1 = ({ index, side, diffFile, lineNumber, }) =
|
|
|
774
701
|
(renderWidgetLine === null || renderWidgetLine === void 0 ? void 0 : renderWidgetLine({
|
|
775
702
|
diffFile,
|
|
776
703
|
side,
|
|
777
|
-
lineNumber: currentLine.lineNumber,
|
|
704
|
+
lineNumber: (_a = currentLine.lineNumber) !== null && _a !== void 0 ? _a : -1,
|
|
778
705
|
onClose: () => setWidget({}),
|
|
779
706
|
}));
|
|
780
707
|
useSyncHeight({
|
|
781
708
|
selector: `div[data-line="${lineNumber}-widget-content"]`,
|
|
782
709
|
wrapper: `tr[data-line="${lineNumber}-widget"]`,
|
|
783
710
|
side: core.SplitSide[currentHasWidget ? side : otherSide],
|
|
784
|
-
enable: hasWidget && typeof renderWidgetLine === "function",
|
|
711
|
+
enable: !!hasWidget && typeof renderWidgetLine === "function",
|
|
785
712
|
});
|
|
786
713
|
const width = useDomWidth({
|
|
787
714
|
selector: side === core.SplitSide.old ? ".old-diff-table-wrapper" : ".new-diff-table-wrapper",
|
|
@@ -789,9 +716,7 @@ const InternalDiffSplitWidgetLine$1 = ({ index, side, diffFile, lineNumber, }) =
|
|
|
789
716
|
});
|
|
790
717
|
if (!renderWidgetLine)
|
|
791
718
|
return null;
|
|
792
|
-
return (
|
|
793
|
-
React__namespace.createElement("div", { "data-line": `${lineNumber}-widget-content`, "data-side": core.SplitSide[side], className: "diff-line-widget-wrapper sticky left-0 z-[1]", style: { width } }, width > 0 && currentWidgetRendered))) : (React__namespace.createElement("td", { className: `diff-line-widget-${core.SplitSide[side]}-placeholder p-0`, style: { backgroundColor: `var(${emptyBGName})` }, colSpan: 2 },
|
|
794
|
-
React__namespace.createElement("div", { "data-line": `${lineNumber}-widget-content`, "data-side": core.SplitSide[side] })))));
|
|
719
|
+
return (jsxRuntime.jsx("tr", { "data-line": `${lineNumber}-widget`, "data-state": "widget", "data-side": core.SplitSide[side], className: "diff-line diff-line-widget", children: currentHasWidget ? (jsxRuntime.jsx("td", { className: `diff-line-widget-${core.SplitSide[side]}-content p-0`, colSpan: 2, children: jsxRuntime.jsx("div", { "data-line": `${lineNumber}-widget-content`, "data-side": core.SplitSide[side], className: "diff-line-widget-wrapper sticky left-0 z-[1]", style: { width }, children: width > 0 && currentWidgetRendered }) })) : (jsxRuntime.jsx("td", { className: `diff-line-widget-${core.SplitSide[side]}-placeholder p-0`, style: { backgroundColor: `var(${emptyBGName})` }, colSpan: 2, children: jsxRuntime.jsx("div", { "data-line": `${lineNumber}-widget-content`, "data-side": core.SplitSide[side] }) })) }));
|
|
795
720
|
};
|
|
796
721
|
// TODO! improve performance
|
|
797
722
|
const DiffSplitWidgetLine$1 = ({ index, side, diffFile, lineNumber, }) => {
|
|
@@ -808,38 +733,19 @@ const DiffSplitWidgetLine$1 = ({ index, side, diffFile, lineNumber, }) => {
|
|
|
808
733
|
}, [diffFile, index]), (p, c) => p === c);
|
|
809
734
|
if (!currentIsShow)
|
|
810
735
|
return null;
|
|
811
|
-
return
|
|
736
|
+
return jsxRuntime.jsx(InternalDiffSplitWidgetLine$1, { index: index, side: side, diffFile: diffFile, lineNumber: lineNumber });
|
|
812
737
|
};
|
|
813
738
|
|
|
814
|
-
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
815
739
|
const DiffSplitViewTable = ({ side, diffFile, enableAddWidget, enableHighlight, onMouseDown, }) => {
|
|
816
740
|
const className = side === core.SplitSide.new ? "new-diff-table" : "old-diff-table";
|
|
817
741
|
const lines = core.getSplitContentLines(diffFile);
|
|
818
|
-
return (
|
|
819
|
-
React__namespace.createElement("colgroup", null,
|
|
820
|
-
React__namespace.createElement("col", { className: `diff-table-${core.SplitSide[side]}-num-col` }),
|
|
821
|
-
React__namespace.createElement("col", { className: `diff-table-${core.SplitSide[side]}-content-col` })),
|
|
822
|
-
React__namespace.createElement("thead", { className: "hidden" },
|
|
823
|
-
React__namespace.createElement("tr", null,
|
|
824
|
-
React__namespace.createElement("th", { scope: "col" },
|
|
825
|
-
core.SplitSide[side],
|
|
826
|
-
" line number"),
|
|
827
|
-
React__namespace.createElement("th", { scope: "col" },
|
|
828
|
-
core.SplitSide[side],
|
|
829
|
-
" line content"))),
|
|
830
|
-
React__namespace.createElement("tbody", { className: "diff-table-body leading-[1.6]", onMouseDownCapture: onMouseDown },
|
|
831
|
-
lines.map((line) => (React__namespace.createElement(React.Fragment, { key: line.index },
|
|
832
|
-
React__namespace.createElement(DiffSplitHunkLine$1, { index: line.index, side: side, lineNumber: line.lineNumber, diffFile: diffFile }),
|
|
833
|
-
React__namespace.createElement(DiffSplitContentLine$1, { index: line.index, side: side, lineNumber: line.lineNumber, diffFile: diffFile, enableAddWidget: enableAddWidget, enableHighlight: enableHighlight }),
|
|
834
|
-
React__namespace.createElement(DiffSplitWidgetLine$1, { index: line.index, side: side, lineNumber: line.lineNumber, diffFile: diffFile }),
|
|
835
|
-
React__namespace.createElement(DiffSplitExtendLine$1, { index: line.index, side: side, lineNumber: line.lineNumber, diffFile: diffFile })))),
|
|
836
|
-
React__namespace.createElement(DiffSplitHunkLine$1, { side: side, index: diffFile.splitLineLength, lineNumber: diffFile.splitLineLength, diffFile: diffFile }))));
|
|
742
|
+
return (jsxRuntime.jsxs("table", { className: className + " w-full border-collapse border-spacing-0", "data-mode": core.SplitSide[side], children: [jsxRuntime.jsxs("colgroup", { children: [jsxRuntime.jsx("col", { className: `diff-table-${core.SplitSide[side]}-num-col` }), jsxRuntime.jsx("col", { className: `diff-table-${core.SplitSide[side]}-content-col` })] }), jsxRuntime.jsx("thead", { className: "hidden", children: jsxRuntime.jsxs("tr", { children: [jsxRuntime.jsxs("th", { scope: "col", children: [core.SplitSide[side], " line number"] }), jsxRuntime.jsxs("th", { scope: "col", children: [core.SplitSide[side], " line content"] })] }) }), jsxRuntime.jsxs("tbody", { className: "diff-table-body leading-[1.6]", onMouseDownCapture: onMouseDown, children: [lines.map((line) => (jsxRuntime.jsxs(React.Fragment, { children: [jsxRuntime.jsx(DiffSplitHunkLine$1, { index: line.index, side: side, lineNumber: line.lineNumber, diffFile: diffFile }), jsxRuntime.jsx(DiffSplitContentLine$1, { index: line.index, side: side, lineNumber: line.lineNumber, diffFile: diffFile, enableAddWidget: enableAddWidget, enableHighlight: enableHighlight }), jsxRuntime.jsx(DiffSplitWidgetLine$1, { index: line.index, side: side, lineNumber: line.lineNumber, diffFile: diffFile }), jsxRuntime.jsx(DiffSplitExtendLine$1, { index: line.index, side: side, lineNumber: line.lineNumber, diffFile: diffFile })] }, line.index))), jsxRuntime.jsx(DiffSplitHunkLine$1, { side: side, index: diffFile.splitLineLength, lineNumber: diffFile.splitLineLength, diffFile: diffFile })] })] }));
|
|
837
743
|
};
|
|
838
744
|
const DiffSplitViewNormal = React.memo(({ diffFile }) => {
|
|
839
745
|
const ref1 = React.useRef(null);
|
|
840
746
|
const ref2 = React.useRef(null);
|
|
841
|
-
const ref = React.useRef();
|
|
842
|
-
const tempRef = React.useRef();
|
|
747
|
+
const ref = React.useRef(null);
|
|
748
|
+
const tempRef = React.useRef(undefined);
|
|
843
749
|
const splitLineLength = Math.max(diffFile.splitLineLength, diffFile.fileLineLength);
|
|
844
750
|
const { useDiffContext } = useDiffViewContext();
|
|
845
751
|
const { fontSize, enableAddWidget, enableHighlight } = useDiffContext.useShallowStableSelector((s) => ({
|
|
@@ -909,40 +815,34 @@ const DiffSplitViewNormal = React.memo(({ diffFile }) => {
|
|
|
909
815
|
ele = ele.parentElement;
|
|
910
816
|
}
|
|
911
817
|
};
|
|
912
|
-
return (
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
[diffAsideWidthName]: `${Math.round(width)}px`,
|
|
926
|
-
overscrollBehaviorX: "none",
|
|
927
|
-
fontFamily: "Menlo, Consolas, monospace",
|
|
928
|
-
fontSize: `var(${diffFontSizeName})`,
|
|
929
|
-
} },
|
|
930
|
-
React__namespace.createElement(DiffSplitViewTable, { side: core.SplitSide.new, diffFile: diffFile, enableAddWidget: enableAddWidget, enableHighlight: enableHighlight, onMouseDown: onMouseDown }))));
|
|
818
|
+
return (jsxRuntime.jsxs("div", { className: "split-diff-view split-diff-view-normal flex w-full basis-[50%]", children: [jsxRuntime.jsx("style", { "data-select-style": true, ref: ref }), jsxRuntime.jsx("div", { className: "old-diff-table-wrapper diff-table-scroll-container w-full overflow-x-auto overflow-y-hidden", ref: ref1, style: {
|
|
819
|
+
// @ts-ignore
|
|
820
|
+
[diffAsideWidthName]: `${Math.round(width)}px`,
|
|
821
|
+
overscrollBehaviorX: "none",
|
|
822
|
+
fontFamily: "Menlo, Consolas, monospace",
|
|
823
|
+
fontSize: `var(${diffFontSizeName})`,
|
|
824
|
+
}, children: jsxRuntime.jsx(DiffSplitViewTable, { side: core.SplitSide.old, diffFile: diffFile, enableAddWidget: !!enableAddWidget, enableHighlight: !!enableHighlight, onMouseDown: onMouseDown }) }), jsxRuntime.jsx("div", { className: "diff-split-line w-[1.5px]", style: { backgroundColor: `var(${borderColorName})` } }), jsxRuntime.jsx("div", { className: "new-diff-table-wrapper diff-table-scroll-container w-full overflow-x-auto overflow-y-hidden", ref: ref2, style: {
|
|
825
|
+
// @ts-ignore
|
|
826
|
+
[diffAsideWidthName]: `${Math.round(width)}px`,
|
|
827
|
+
overscrollBehaviorX: "none",
|
|
828
|
+
fontFamily: "Menlo, Consolas, monospace",
|
|
829
|
+
fontSize: `var(${diffFontSizeName})`,
|
|
830
|
+
}, children: jsxRuntime.jsx(DiffSplitViewTable, { side: core.SplitSide.new, diffFile: diffFile, enableAddWidget: !!enableAddWidget, enableHighlight: !!enableHighlight, onMouseDown: onMouseDown }) })] }));
|
|
931
831
|
});
|
|
932
832
|
DiffSplitViewNormal.displayName = "DiffSplitViewNormal";
|
|
933
833
|
|
|
934
834
|
const InternalDiffSplitLine = ({ index, diffFile, lineNumber, enableAddWidget, enableHighlight, }) => {
|
|
935
|
-
var _a, _b;
|
|
835
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
936
836
|
const oldLine = diffFile.getSplitLeftLine(index);
|
|
937
837
|
const newLine = diffFile.getSplitRightLine(index);
|
|
938
|
-
const oldSyntaxLine = diffFile.getOldSyntaxLine(oldLine === null || oldLine === void 0 ? void 0 : oldLine.lineNumber);
|
|
939
|
-
const oldPlainLine = diffFile.getOldPlainLine(oldLine.lineNumber);
|
|
940
|
-
const newSyntaxLine = diffFile.getNewSyntaxLine(newLine === null || newLine === void 0 ? void 0 : newLine.lineNumber);
|
|
941
|
-
const newPlainLine = diffFile.getNewPlainLine(newLine.lineNumber);
|
|
838
|
+
const oldSyntaxLine = diffFile.getOldSyntaxLine((_a = oldLine === null || oldLine === void 0 ? void 0 : oldLine.lineNumber) !== null && _a !== void 0 ? _a : -1);
|
|
839
|
+
const oldPlainLine = diffFile.getOldPlainLine((_b = oldLine.lineNumber) !== null && _b !== void 0 ? _b : -1);
|
|
840
|
+
const newSyntaxLine = diffFile.getNewSyntaxLine((_c = newLine === null || newLine === void 0 ? void 0 : newLine.lineNumber) !== null && _c !== void 0 ? _c : -1);
|
|
841
|
+
const newPlainLine = diffFile.getNewPlainLine((_d = newLine.lineNumber) !== null && _d !== void 0 ? _d : -1);
|
|
942
842
|
const hasDiff = !!(oldLine === null || oldLine === void 0 ? void 0 : oldLine.diff) || !!(newLine === null || newLine === void 0 ? void 0 : newLine.diff);
|
|
943
843
|
const hasChange = core.checkDiffLineIncludeChange(oldLine === null || oldLine === void 0 ? void 0 : oldLine.diff) || core.checkDiffLineIncludeChange(newLine === null || newLine === void 0 ? void 0 : newLine.diff);
|
|
944
|
-
const oldLineIsDelete = ((
|
|
945
|
-
const newLineIsAdded = ((
|
|
844
|
+
const oldLineIsDelete = ((_e = oldLine === null || oldLine === void 0 ? void 0 : oldLine.diff) === null || _e === void 0 ? void 0 : _e.type) === core.DiffLineType.Delete;
|
|
845
|
+
const newLineIsAdded = ((_f = newLine === null || newLine === void 0 ? void 0 : newLine.diff) === null || _f === void 0 ? void 0 : _f.type) === core.DiffLineType.Add;
|
|
946
846
|
const { useDiffContext } = useDiffViewContext();
|
|
947
847
|
const onAddWidgetClick = useDiffContext.getReadonlyState().onAddWidgetClick;
|
|
948
848
|
const { useWidget } = useDiffWidgetContext();
|
|
@@ -953,45 +853,30 @@ const InternalDiffSplitLine = ({ index, diffFile, lineNumber, enableAddWidget, e
|
|
|
953
853
|
const oldLineNumberBG = getLineNumberBG(false, oldLineIsDelete, hasDiff);
|
|
954
854
|
const newLineContentBG = getContentBG(newLineIsAdded, false, hasDiff);
|
|
955
855
|
const newLineNumberBG = getLineNumberBG(newLineIsAdded, false, hasDiff);
|
|
956
|
-
return (
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
React__namespace.createElement(DiffContent, { enableWrap: true, diffFile: diffFile, rawLine: oldLine.value, diffLine: oldLine.diff, plainLine: oldPlainLine, syntaxLine: oldSyntaxLine, enableHighlight: enableHighlight })))) : (React__namespace.createElement("td", { className: "diff-line-old-placeholder select-none", "data-side": core.SplitSide[core.SplitSide.old], style: { backgroundColor: `var(${emptyBGName})` }, colSpan: 2 },
|
|
967
|
-
React__namespace.createElement("span", null, "\u2002"))),
|
|
968
|
-
hasNewLine ? (React__namespace.createElement(React__namespace.Fragment, null,
|
|
969
|
-
React__namespace.createElement("td", { className: "diff-line-new-num group relative w-[1%] min-w-[40px] select-none border-l-[1px] pl-[10px] pr-[10px] text-right align-top", "data-side": core.SplitSide[core.SplitSide.new], style: {
|
|
970
|
-
backgroundColor: newLineNumberBG,
|
|
971
|
-
color: `var(${hasDiff ? plainLineNumberColorName : expandLineNumberColorName})`,
|
|
856
|
+
return (jsxRuntime.jsxs("tr", { "data-line": lineNumber, "data-state": hasDiff ? "diff" : "plain", className: "diff-line", children: [hasOldLine ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("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": core.SplitSide[core.SplitSide.old], style: {
|
|
857
|
+
backgroundColor: oldLineNumberBG,
|
|
858
|
+
color: `var(${hasDiff ? plainLineNumberColorName : expandLineNumberColorName})`,
|
|
859
|
+
}, children: [hasDiff && enableAddWidget && (jsxRuntime.jsx(DiffSplitAddWidget, { index: index, lineNumber: (_g = oldLine.lineNumber) !== null && _g !== void 0 ? _g : -1, side: core.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 }) })), jsxRuntime.jsx("span", { "data-line-num": oldLine.lineNumber, style: { opacity: hasChange ? undefined : 0.5 }, children: oldLine.lineNumber })] }), jsxRuntime.jsxs("td", { className: "diff-line-old-content group relative pr-[10px] align-top", "data-side": core.SplitSide[core.SplitSide.old], style: { backgroundColor: oldLineContentBG }, children: [hasDiff && enableAddWidget && (jsxRuntime.jsx(DiffSplitAddWidget, { index: index, lineNumber: (_h = oldLine.lineNumber) !== null && _h !== void 0 ? _h : -1, side: core.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 }) })), jsxRuntime.jsx(DiffContent, { enableWrap: true, diffFile: diffFile, rawLine: oldLine.value || "", diffLine: oldLine.diff, plainLine: oldPlainLine, syntaxLine: oldSyntaxLine, enableHighlight: enableHighlight })] })] })) : (jsxRuntime.jsx("td", { className: "diff-line-old-placeholder select-none", "data-side": core.SplitSide[core.SplitSide.old], style: { backgroundColor: `var(${emptyBGName})` }, colSpan: 2, children: jsxRuntime.jsx("span", { children: "\u2002" }) })), hasNewLine ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("td", { className: "diff-line-new-num group relative w-[1%] min-w-[40px] select-none border-l-[1px] pl-[10px] pr-[10px] text-right align-top", "data-side": core.SplitSide[core.SplitSide.new], style: {
|
|
860
|
+
backgroundColor: newLineNumberBG,
|
|
861
|
+
color: `var(${hasDiff ? plainLineNumberColorName : expandLineNumberColorName})`,
|
|
862
|
+
borderLeftColor: `var(${borderColorName})`,
|
|
863
|
+
borderLeftStyle: "solid",
|
|
864
|
+
}, children: [hasDiff && enableAddWidget && (jsxRuntime.jsx(DiffSplitAddWidget, { index: index, lineNumber: (_j = newLine.lineNumber) !== null && _j !== void 0 ? _j : -1, side: core.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 }) })), jsxRuntime.jsx("span", { "data-line-num": newLine.lineNumber, style: { opacity: hasChange ? undefined : 0.5 }, children: newLine.lineNumber })] }), jsxRuntime.jsxs("td", { className: "diff-line-new-content group relative pr-[10px] align-top", "data-side": core.SplitSide[core.SplitSide.new], style: { backgroundColor: newLineContentBG }, children: [hasDiff && enableAddWidget && (jsxRuntime.jsx(DiffSplitAddWidget, { index: index, lineNumber: (_k = newLine.lineNumber) !== null && _k !== void 0 ? _k : -1, side: core.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 }) })), jsxRuntime.jsx(DiffContent, { enableWrap: true, diffFile: diffFile, rawLine: newLine.value || "", diffLine: newLine.diff, plainLine: newPlainLine, syntaxLine: newSyntaxLine, enableHighlight: enableHighlight })] })] })) : (jsxRuntime.jsx("td", { className: "diff-line-new-placeholder select-none border-l-[1px]", style: {
|
|
865
|
+
backgroundColor: `var(${emptyBGName})`,
|
|
972
866
|
borderLeftColor: `var(${borderColorName})`,
|
|
973
867
|
borderLeftStyle: "solid",
|
|
974
|
-
} }
|
|
975
|
-
hasDiff && enableAddWidget && (React__namespace.createElement(DiffSplitAddWidget, { index: index, lineNumber: newLine.lineNumber, side: core.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 }) })),
|
|
976
|
-
React__namespace.createElement("span", { "data-line-num": newLine.lineNumber, style: { opacity: hasChange ? undefined : 0.5 } }, newLine.lineNumber)),
|
|
977
|
-
React__namespace.createElement("td", { className: "diff-line-new-content group relative pr-[10px] align-top", "data-side": core.SplitSide[core.SplitSide.new], style: { backgroundColor: newLineContentBG } },
|
|
978
|
-
hasDiff && enableAddWidget && (React__namespace.createElement(DiffSplitAddWidget, { index: index, lineNumber: newLine.lineNumber, side: core.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 }) })),
|
|
979
|
-
React__namespace.createElement(DiffContent, { enableWrap: true, diffFile: diffFile, rawLine: newLine.value || "", diffLine: newLine.diff, plainLine: newPlainLine, syntaxLine: newSyntaxLine, enableHighlight: enableHighlight })))) : (React__namespace.createElement("td", { className: "diff-line-new-placeholder select-none border-l-[1px]", style: {
|
|
980
|
-
backgroundColor: `var(${emptyBGName})`,
|
|
981
|
-
borderLeftColor: `var(${borderColorName})`,
|
|
982
|
-
borderLeftStyle: "solid",
|
|
983
|
-
}, "data-side": core.SplitSide[core.SplitSide.new], colSpan: 2 },
|
|
984
|
-
React__namespace.createElement("span", null, "\u2002")))));
|
|
868
|
+
}, "data-side": core.SplitSide[core.SplitSide.new], colSpan: 2, children: jsxRuntime.jsx("span", { children: "\u2002" }) }))] }));
|
|
985
869
|
};
|
|
986
870
|
const DiffSplitContentLine = ({ index, diffFile, lineNumber, enableAddWidget, enableHighlight, }) => {
|
|
987
871
|
const oldLine = diffFile.getSplitLeftLine(index);
|
|
988
872
|
const newLine = diffFile.getSplitRightLine(index);
|
|
989
873
|
if ((oldLine === null || oldLine === void 0 ? void 0 : oldLine.isHidden) && (newLine === null || newLine === void 0 ? void 0 : newLine.isHidden))
|
|
990
874
|
return null;
|
|
991
|
-
return (
|
|
875
|
+
return (jsxRuntime.jsx(InternalDiffSplitLine, { index: index, diffFile: diffFile, lineNumber: lineNumber, enableAddWidget: enableAddWidget, enableHighlight: enableHighlight }));
|
|
992
876
|
};
|
|
993
877
|
|
|
994
878
|
const InternalDiffSplitExtendLine = ({ index, diffFile, lineNumber, oldLineExtend, newLineExtend, }) => {
|
|
879
|
+
var _a, _b;
|
|
995
880
|
const { useDiffContext } = useDiffViewContext();
|
|
996
881
|
const oldLine = diffFile.getSplitLeftLine(index);
|
|
997
882
|
const newLine = diffFile.getSplitRightLine(index);
|
|
@@ -1003,7 +888,7 @@ const InternalDiffSplitExtendLine = ({ index, diffFile, lineNumber, oldLineExten
|
|
|
1003
888
|
(renderExtendLine === null || renderExtendLine === void 0 ? void 0 : renderExtendLine({
|
|
1004
889
|
diffFile,
|
|
1005
890
|
side: core.SplitSide.old,
|
|
1006
|
-
lineNumber: oldLine.lineNumber,
|
|
891
|
+
lineNumber: (_a = oldLine.lineNumber) !== null && _a !== void 0 ? _a : -1,
|
|
1007
892
|
data: oldLineExtend.data,
|
|
1008
893
|
onUpdate: diffFile.notifyAll,
|
|
1009
894
|
}));
|
|
@@ -1011,29 +896,25 @@ const InternalDiffSplitExtendLine = ({ index, diffFile, lineNumber, oldLineExten
|
|
|
1011
896
|
(renderExtendLine === null || renderExtendLine === void 0 ? void 0 : renderExtendLine({
|
|
1012
897
|
diffFile,
|
|
1013
898
|
side: core.SplitSide.new,
|
|
1014
|
-
lineNumber: newLine.lineNumber,
|
|
899
|
+
lineNumber: (_b = newLine.lineNumber) !== null && _b !== void 0 ? _b : -1,
|
|
1015
900
|
data: newLineExtend.data,
|
|
1016
901
|
onUpdate: diffFile.notifyAll,
|
|
1017
902
|
}));
|
|
1018
|
-
return (
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
backgroundColor: `var(${emptyBGName})`,
|
|
1024
|
-
borderLeftColor: `var(${borderColorName})`,
|
|
1025
|
-
borderLeftStyle: "solid",
|
|
1026
|
-
}, colSpan: 2 }))));
|
|
903
|
+
return (jsxRuntime.jsxs("tr", { "data-line": `${lineNumber}-extend`, "data-state": "extend", className: "diff-line diff-line-extend", children: [oldExtendRendered ? (jsxRuntime.jsx("td", { className: "diff-line-extend-old-content p-0", colSpan: 2, children: jsxRuntime.jsx("div", { className: "diff-line-extend-wrapper", children: oldExtendRendered }) })) : (jsxRuntime.jsx("td", { className: "diff-line-extend-old-placeholder select-none p-0", style: { backgroundColor: `var(${emptyBGName})` }, colSpan: 2 })), newExtendRendered ? (jsxRuntime.jsx("td", { className: "diff-line-extend-new-content border-l-[1px] p-0", style: { borderLeftColor: `var(${borderColorName})`, borderLeftStyle: "solid" }, colSpan: 2, children: jsxRuntime.jsx("div", { className: "diff-line-extend-wrapper", children: newExtendRendered }) })) : (jsxRuntime.jsx("td", { className: "diff-line-extend-new-placeholder select-none border-l-[1px] p-0", style: {
|
|
904
|
+
backgroundColor: `var(${emptyBGName})`,
|
|
905
|
+
borderLeftColor: `var(${borderColorName})`,
|
|
906
|
+
borderLeftStyle: "solid",
|
|
907
|
+
}, colSpan: 2 }))] }));
|
|
1027
908
|
};
|
|
1028
909
|
const DiffSplitExtendLine = ({ index, diffFile, lineNumber, }) => {
|
|
1029
910
|
const { useDiffContext } = useDiffViewContext();
|
|
1030
911
|
const oldLine = diffFile.getSplitLeftLine(index);
|
|
1031
912
|
const newLine = diffFile.getSplitRightLine(index);
|
|
1032
913
|
const { oldLineExtend, newLineExtend } = useDiffContext(React__namespace.useCallback((s) => {
|
|
1033
|
-
var _a, _b, _c, _d;
|
|
914
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1034
915
|
return ({
|
|
1035
|
-
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],
|
|
1036
|
-
newLineExtend: (
|
|
916
|
+
oldLineExtend: (_b = (_a = s.extendData) === null || _a === void 0 ? void 0 : _a.oldFile) === null || _b === void 0 ? void 0 : _b[(_c = oldLine === null || oldLine === void 0 ? void 0 : oldLine.lineNumber) !== null && _c !== void 0 ? _c : -1],
|
|
917
|
+
newLineExtend: (_e = (_d = s.extendData) === null || _d === void 0 ? void 0 : _d.newFile) === null || _e === void 0 ? void 0 : _e[(_f = newLine === null || newLine === void 0 ? void 0 : newLine.lineNumber) !== null && _f !== void 0 ? _f : -1],
|
|
1037
918
|
});
|
|
1038
919
|
}, [oldLine === null || oldLine === void 0 ? void 0 : oldLine.lineNumber, newLine === null || newLine === void 0 ? void 0 : newLine.lineNumber]));
|
|
1039
920
|
const hasExtend = (oldLineExtend === null || oldLineExtend === void 0 ? void 0 : oldLineExtend.data) || (newLineExtend === null || newLineExtend === void 0 ? void 0 : newLineExtend.data);
|
|
@@ -1042,7 +923,7 @@ const DiffSplitExtendLine = ({ index, diffFile, lineNumber, }) => {
|
|
|
1042
923
|
const currentIsShow = hasExtend && ((!(oldLine === null || oldLine === void 0 ? void 0 : oldLine.isHidden) && !(newLine === null || newLine === void 0 ? void 0 : newLine.isHidden)) || !enableExpand);
|
|
1043
924
|
if (!currentIsShow)
|
|
1044
925
|
return null;
|
|
1045
|
-
return (
|
|
926
|
+
return (jsxRuntime.jsx(InternalDiffSplitExtendLine, { index: index, diffFile: diffFile, lineNumber: lineNumber, oldLineExtend: oldLineExtend, newLineExtend: newLineExtend }));
|
|
1046
927
|
};
|
|
1047
928
|
|
|
1048
929
|
const DiffSplitHunkLineGitHub = ({ index, diffFile, lineNumber, }) => {
|
|
@@ -1055,22 +936,12 @@ const DiffSplitHunkLineGitHub = ({ index, diffFile, lineNumber, }) => {
|
|
|
1055
936
|
currentHunk.splitInfo.endHiddenIndex - currentHunk.splitInfo.startHiddenIndex < core.composeLen;
|
|
1056
937
|
const isFirstLine = currentHunk && currentHunk.isFirst;
|
|
1057
938
|
const isLastLine = currentHunk && currentHunk.isLast;
|
|
1058
|
-
return (
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
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]", title: "Expand All", "data-title": "Expand All", onClick: () => diffFile.onSplitHunkExpand("all", index) },
|
|
1065
|
-
React__namespace.createElement(ExpandAll, { className: "fill-current" }))) : (React__namespace.createElement(React__namespace.Fragment, null,
|
|
1066
|
-
React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onSplitHunkExpand("down", index) },
|
|
1067
|
-
React__namespace.createElement(ExpandDown, { className: "fill-current" })),
|
|
1068
|
-
React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index) },
|
|
1069
|
-
React__namespace.createElement(ExpandUp, { className: "fill-current" }))))) : (React__namespace.createElement("div", { className: "min-h-[28px]" }, "\u2002"))),
|
|
1070
|
-
React__namespace.createElement("td", { className: "diff-line-hunk-content pr-[10px] align-middle", style: { backgroundColor: `var(${hunkContentBGName})` }, colSpan: 3 },
|
|
1071
|
-
React__namespace.createElement("div", { className: "pl-[1.5em]", style: {
|
|
1072
|
-
color: `var(${hunkContentColorName})`,
|
|
1073
|
-
} }, ((_a = currentHunk.splitInfo) === null || _a === void 0 ? void 0 : _a.plainText) || currentHunk.text))));
|
|
939
|
+
return (jsxRuntime.jsxs("tr", { "data-line": `${lineNumber}-hunk`, "data-state": "hunk", className: "diff-line diff-line-hunk", children: [jsxRuntime.jsx("td", { className: "diff-line-hunk-action relative w-[1%] min-w-[40px] select-none p-[1px]", style: {
|
|
940
|
+
backgroundColor: `var(${hunkLineNumberBGName})`,
|
|
941
|
+
color: `var(${plainLineNumberColorName})`,
|
|
942
|
+
}, children: couldExpand ? (isFirstLine ? (jsxRuntime.jsx("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index), children: jsxRuntime.jsx(ExpandUp, { className: "fill-current" }) })) : isLastLine ? (jsxRuntime.jsx("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onSplitHunkExpand("down", index), children: jsxRuntime.jsx(ExpandDown, { className: "fill-current" }) })) : isExpandAll ? (jsxRuntime.jsx("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]", title: "Expand All", "data-title": "Expand All", onClick: () => diffFile.onSplitHunkExpand("all", index), children: jsxRuntime.jsx(ExpandAll, { className: "fill-current" }) })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onSplitHunkExpand("down", index), children: jsxRuntime.jsx(ExpandDown, { className: "fill-current" }) }), jsxRuntime.jsx("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index), children: jsxRuntime.jsx(ExpandUp, { className: "fill-current" }) })] }))) : (jsxRuntime.jsx("div", { className: "min-h-[28px]", children: "\u2002" })) }), jsxRuntime.jsx("td", { className: "diff-line-hunk-content pr-[10px] align-middle", style: { backgroundColor: `var(${hunkContentBGName})` }, colSpan: 3, children: jsxRuntime.jsx("div", { className: "pl-[1.5em]", style: {
|
|
943
|
+
color: `var(${hunkContentColorName})`,
|
|
944
|
+
}, children: ((_a = currentHunk.splitInfo) === null || _a === void 0 ? void 0 : _a.plainText) || currentHunk.text }) })] }));
|
|
1074
945
|
};
|
|
1075
946
|
const DiffSplitHunkLineGitLab = ({ index, diffFile, lineNumber, }) => {
|
|
1076
947
|
var _a, _b;
|
|
@@ -1082,39 +953,19 @@ const DiffSplitHunkLineGitLab = ({ index, diffFile, lineNumber, }) => {
|
|
|
1082
953
|
currentHunk.splitInfo.endHiddenIndex - currentHunk.splitInfo.startHiddenIndex < core.composeLen;
|
|
1083
954
|
const isFirstLine = currentHunk && currentHunk.isFirst;
|
|
1084
955
|
const isLastLine = currentHunk && currentHunk.isLast;
|
|
1085
|
-
return (
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
React__namespace.createElement("div", { className: "pl-[1.5em]", style: {
|
|
1099
|
-
color: `var(${hunkContentColorName})`,
|
|
1100
|
-
} }, ((_a = currentHunk.splitInfo) === null || _a === void 0 ? void 0 : _a.plainText) || currentHunk.text)),
|
|
1101
|
-
React__namespace.createElement("td", { className: "diff-line-hunk-action relative z-[1] w-[1%] min-w-[40px] select-none border-l-[1px] p-[1px]", style: {
|
|
1102
|
-
backgroundColor: `var(${hunkLineNumberBGName})`,
|
|
1103
|
-
color: `var(${plainLineNumberColorName})`,
|
|
1104
|
-
borderLeftColor: `var(${borderColorName})`,
|
|
1105
|
-
borderLeftStyle: "solid",
|
|
1106
|
-
} }, couldExpand ? (isFirstLine ? (React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index) },
|
|
1107
|
-
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]", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onSplitHunkExpand("down", index) },
|
|
1108
|
-
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]", title: "Expand All", "data-title": "Expand All", onClick: () => diffFile.onSplitHunkExpand("all", index) },
|
|
1109
|
-
React__namespace.createElement(ExpandAll, { className: "fill-current" }))) : (React__namespace.createElement(React__namespace.Fragment, null,
|
|
1110
|
-
React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onSplitHunkExpand("down", index) },
|
|
1111
|
-
React__namespace.createElement(ExpandDown, { className: "fill-current" })),
|
|
1112
|
-
React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index) },
|
|
1113
|
-
React__namespace.createElement(ExpandUp, { className: "fill-current" }))))) : (React__namespace.createElement("div", { className: "min-h-[28px]" }, "\u2002"))),
|
|
1114
|
-
React__namespace.createElement("td", { className: "diff-line-hunk-content relative pr-[10px] align-middle", style: { backgroundColor: `var(${hunkContentBGName})` } },
|
|
1115
|
-
React__namespace.createElement("div", { className: "pl-[1.5em]", style: {
|
|
1116
|
-
color: `var(${hunkContentColorName})`,
|
|
1117
|
-
} }, ((_b = currentHunk.splitInfo) === null || _b === void 0 ? void 0 : _b.plainText) || currentHunk.text))));
|
|
956
|
+
return (jsxRuntime.jsxs("tr", { "data-line": `${lineNumber}-hunk`, "data-state": "hunk", className: "diff-line diff-line-hunk", children: [jsxRuntime.jsx("td", { className: "diff-line-hunk-action relative w-[1%] min-w-[40px] select-none p-[1px]", style: {
|
|
957
|
+
backgroundColor: `var(${hunkLineNumberBGName})`,
|
|
958
|
+
color: `var(${plainLineNumberColorName})`,
|
|
959
|
+
}, children: couldExpand ? (isFirstLine ? (jsxRuntime.jsx("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index), children: jsxRuntime.jsx(ExpandUp, { className: "fill-current" }) })) : isLastLine ? (jsxRuntime.jsx("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onSplitHunkExpand("down", index), children: jsxRuntime.jsx(ExpandDown, { className: "fill-current" }) })) : isExpandAll ? (jsxRuntime.jsx("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]", title: "Expand All", "data-title": "Expand All", onClick: () => diffFile.onSplitHunkExpand("all", index), children: jsxRuntime.jsx(ExpandAll, { className: "fill-current" }) })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onSplitHunkExpand("down", index), children: jsxRuntime.jsx(ExpandDown, { className: "fill-current" }) }), jsxRuntime.jsx("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index), children: jsxRuntime.jsx(ExpandUp, { className: "fill-current" }) })] }))) : (jsxRuntime.jsx("div", { className: "min-h-[28px]", children: "\u2002" })) }), jsxRuntime.jsx("td", { className: "diff-line-hunk-content pr-[10px] align-middle", style: { backgroundColor: `var(${hunkContentBGName})` }, children: jsxRuntime.jsx("div", { className: "pl-[1.5em]", style: {
|
|
960
|
+
color: `var(${hunkContentColorName})`,
|
|
961
|
+
}, children: ((_a = currentHunk.splitInfo) === null || _a === void 0 ? void 0 : _a.plainText) || currentHunk.text }) }), jsxRuntime.jsx("td", { className: "diff-line-hunk-action relative z-[1] w-[1%] min-w-[40px] select-none border-l-[1px] p-[1px]", style: {
|
|
962
|
+
backgroundColor: `var(${hunkLineNumberBGName})`,
|
|
963
|
+
color: `var(${plainLineNumberColorName})`,
|
|
964
|
+
borderLeftColor: `var(${borderColorName})`,
|
|
965
|
+
borderLeftStyle: "solid",
|
|
966
|
+
}, children: couldExpand ? (isFirstLine ? (jsxRuntime.jsx("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index), children: jsxRuntime.jsx(ExpandUp, { className: "fill-current" }) })) : isLastLine ? (jsxRuntime.jsx("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onSplitHunkExpand("down", index), children: jsxRuntime.jsx(ExpandDown, { className: "fill-current" }) })) : isExpandAll ? (jsxRuntime.jsx("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]", title: "Expand All", "data-title": "Expand All", onClick: () => diffFile.onSplitHunkExpand("all", index), children: jsxRuntime.jsx(ExpandAll, { className: "fill-current" }) })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onSplitHunkExpand("down", index), children: jsxRuntime.jsx(ExpandDown, { className: "fill-current" }) }), jsxRuntime.jsx("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index), children: jsxRuntime.jsx(ExpandUp, { className: "fill-current" }) })] }))) : (jsxRuntime.jsx("div", { className: "min-h-[28px]", children: "\u2002" })) }), jsxRuntime.jsx("td", { className: "diff-line-hunk-content relative pr-[10px] align-middle", style: { backgroundColor: `var(${hunkContentBGName})` }, children: jsxRuntime.jsx("div", { className: "pl-[1.5em]", style: {
|
|
967
|
+
color: `var(${hunkContentColorName})`,
|
|
968
|
+
}, children: ((_b = currentHunk.splitInfo) === null || _b === void 0 ? void 0 : _b.plainText) || currentHunk.text }) })] }));
|
|
1118
969
|
};
|
|
1119
970
|
const InternalDiffSplitHunkLine = ({ index, diffFile, lineNumber, }) => {
|
|
1120
971
|
const { useDiffContext } = useDiffViewContext();
|
|
@@ -1122,10 +973,10 @@ const InternalDiffSplitHunkLine = ({ index, diffFile, lineNumber, }) => {
|
|
|
1122
973
|
if (diffViewMode === exports.DiffModeEnum.SplitGitHub ||
|
|
1123
974
|
diffViewMode === exports.DiffModeEnum.Split ||
|
|
1124
975
|
diffViewMode === exports.DiffModeEnum.Unified) {
|
|
1125
|
-
return
|
|
976
|
+
return jsxRuntime.jsx(DiffSplitHunkLineGitHub, { index: index, diffFile: diffFile, lineNumber: lineNumber });
|
|
1126
977
|
}
|
|
1127
978
|
else {
|
|
1128
|
-
return
|
|
979
|
+
return jsxRuntime.jsx(DiffSplitHunkLineGitLab, { index: index, diffFile: diffFile, lineNumber: lineNumber });
|
|
1129
980
|
}
|
|
1130
981
|
};
|
|
1131
982
|
const DiffSplitHunkLine = ({ index, diffFile, lineNumber, }) => {
|
|
@@ -1136,10 +987,11 @@ const DiffSplitHunkLine = ({ index, diffFile, lineNumber, }) => {
|
|
|
1136
987
|
const currentIsPureHunk = currentHunk && diffFile._getIsPureDiffRender() && !currentHunk.splitInfo;
|
|
1137
988
|
if (!currentIsShow && !currentIsPureHunk)
|
|
1138
989
|
return null;
|
|
1139
|
-
return
|
|
990
|
+
return jsxRuntime.jsx(InternalDiffSplitHunkLine, { index: index, diffFile: diffFile, lineNumber: lineNumber });
|
|
1140
991
|
};
|
|
1141
992
|
|
|
1142
993
|
const InternalDiffSplitWidgetLine = ({ index, diffFile, lineNumber, }) => {
|
|
994
|
+
var _a, _b;
|
|
1143
995
|
const { useWidget } = useDiffWidgetContext();
|
|
1144
996
|
const setWidget = useWidget.getReadonlyState().setWidget;
|
|
1145
997
|
const { useDiffContext } = useDiffViewContext();
|
|
@@ -1151,20 +1003,26 @@ const InternalDiffSplitWidgetLine = ({ index, diffFile, lineNumber, }) => {
|
|
|
1151
1003
|
const oldLineWidget = oldLine.lineNumber && widgetSide === core.SplitSide.old && widgetLineNumber === oldLine.lineNumber;
|
|
1152
1004
|
const newLineWidget = newLine.lineNumber && widgetSide === core.SplitSide.new && widgetLineNumber === newLine.lineNumber;
|
|
1153
1005
|
const oldWidgetRendered = oldLineWidget &&
|
|
1154
|
-
(renderWidgetLine === null || renderWidgetLine === void 0 ? void 0 : renderWidgetLine({
|
|
1006
|
+
(renderWidgetLine === null || renderWidgetLine === void 0 ? void 0 : renderWidgetLine({
|
|
1007
|
+
diffFile,
|
|
1008
|
+
side: core.SplitSide.old,
|
|
1009
|
+
lineNumber: (_a = oldLine.lineNumber) !== null && _a !== void 0 ? _a : -1,
|
|
1010
|
+
onClose: () => setWidget({}),
|
|
1011
|
+
}));
|
|
1155
1012
|
const newWidgetRendered = newLineWidget &&
|
|
1156
|
-
(renderWidgetLine === null || renderWidgetLine === void 0 ? void 0 : renderWidgetLine({
|
|
1013
|
+
(renderWidgetLine === null || renderWidgetLine === void 0 ? void 0 : renderWidgetLine({
|
|
1014
|
+
diffFile,
|
|
1015
|
+
side: core.SplitSide.new,
|
|
1016
|
+
lineNumber: (_b = newLine.lineNumber) !== null && _b !== void 0 ? _b : -1,
|
|
1017
|
+
onClose: () => setWidget({}),
|
|
1018
|
+
}));
|
|
1157
1019
|
if (!renderWidgetLine)
|
|
1158
1020
|
return null;
|
|
1159
|
-
return (
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
backgroundColor: `var(${emptyBGName})`,
|
|
1165
|
-
borderLeftColor: `var(${borderColorName})`,
|
|
1166
|
-
borderLeftStyle: "solid",
|
|
1167
|
-
}, colSpan: 2 }))));
|
|
1021
|
+
return (jsxRuntime.jsxs("tr", { "data-line": `${lineNumber}-widget`, "data-state": "widget", className: "diff-line diff-line-widget", children: [oldWidgetRendered ? (jsxRuntime.jsx("td", { className: "diff-line-widget-old-content p-0", colSpan: 2, children: jsxRuntime.jsx("div", { className: "diff-line-widget-wrapper", children: oldWidgetRendered }) })) : (jsxRuntime.jsx("td", { className: "diff-line-widget-old-placeholder select-none p-0", style: { backgroundColor: `var(${emptyBGName})` }, colSpan: 2 })), newWidgetRendered ? (jsxRuntime.jsx("td", { className: "diff-line-widget-new-content border-l-[1px] p-0", colSpan: 2, style: { borderLeftColor: `var(${borderColorName})`, borderLeftStyle: "solid" }, children: jsxRuntime.jsx("div", { className: "diff-line-widget-wrapper", children: newWidgetRendered }) })) : (jsxRuntime.jsx("td", { className: "diff-line-widget-new-placeholder select-none border-l-[1px] p-0", style: {
|
|
1022
|
+
backgroundColor: `var(${emptyBGName})`,
|
|
1023
|
+
borderLeftColor: `var(${borderColorName})`,
|
|
1024
|
+
borderLeftStyle: "solid",
|
|
1025
|
+
}, colSpan: 2 }))] }));
|
|
1168
1026
|
};
|
|
1169
1027
|
// TODO! improve performance
|
|
1170
1028
|
const DiffSplitWidgetLine = ({ index, diffFile, lineNumber, }) => {
|
|
@@ -1181,15 +1039,14 @@ const DiffSplitWidgetLine = ({ index, diffFile, lineNumber, }) => {
|
|
|
1181
1039
|
}, [diffFile, index]), (p, c) => p === c);
|
|
1182
1040
|
if (!currentIsShow)
|
|
1183
1041
|
return null;
|
|
1184
|
-
return
|
|
1042
|
+
return jsxRuntime.jsx(InternalDiffSplitWidgetLine, { index: index, diffFile: diffFile, lineNumber: lineNumber });
|
|
1185
1043
|
};
|
|
1186
1044
|
|
|
1187
|
-
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
1188
1045
|
const DiffSplitViewWrap = React.memo(({ diffFile }) => {
|
|
1189
1046
|
const splitLineLength = Math.max(diffFile.splitLineLength, diffFile.fileLineLength);
|
|
1190
1047
|
const { useDiffContext } = useDiffViewContext();
|
|
1191
1048
|
const ref = React.useRef(null);
|
|
1192
|
-
const tempRef = React.useRef();
|
|
1049
|
+
const tempRef = React.useRef(undefined);
|
|
1193
1050
|
const { fontSize, enableAddWidget, enableHighlight } = useDiffContext.useShallowStableSelector((s) => ({
|
|
1194
1051
|
fontSize: s.fontSize,
|
|
1195
1052
|
enableAddWidget: s.enableAddWidget,
|
|
@@ -1252,33 +1109,12 @@ const DiffSplitViewWrap = React.memo(({ diffFile }) => {
|
|
|
1252
1109
|
ele = ele.parentElement;
|
|
1253
1110
|
}
|
|
1254
1111
|
};
|
|
1255
|
-
return (
|
|
1256
|
-
React__namespace.createElement("div", { className: "diff-table-wrapper w-full", style: {
|
|
1112
|
+
return (jsxRuntime.jsx("div", { className: "split-diff-view split-diff-view-wrap w-full", children: jsxRuntime.jsxs("div", { className: "diff-table-wrapper w-full", style: {
|
|
1257
1113
|
// @ts-ignore
|
|
1258
1114
|
[diffAsideWidthName]: `${Math.round(width)}px`,
|
|
1259
1115
|
fontFamily: "Menlo, Consolas, monospace",
|
|
1260
1116
|
fontSize: `var(${diffFontSizeName})`,
|
|
1261
|
-
} },
|
|
1262
|
-
React__namespace.createElement("style", { "data-select-style": true, ref: ref }),
|
|
1263
|
-
React__namespace.createElement("table", { className: "diff-table w-full table-fixed border-collapse border-spacing-0" },
|
|
1264
|
-
React__namespace.createElement("colgroup", null,
|
|
1265
|
-
React__namespace.createElement("col", { className: "diff-table-old-num-col", width: Math.round(width) }),
|
|
1266
|
-
React__namespace.createElement("col", { className: "diff-table-old-content-col" }),
|
|
1267
|
-
React__namespace.createElement("col", { className: "diff-table-new-num-col", width: Math.round(width) }),
|
|
1268
|
-
React__namespace.createElement("col", { className: "diff-table-new-content-col" })),
|
|
1269
|
-
React__namespace.createElement("thead", { className: "hidden" },
|
|
1270
|
-
React__namespace.createElement("tr", null,
|
|
1271
|
-
React__namespace.createElement("th", { scope: "col" }, "old line number"),
|
|
1272
|
-
React__namespace.createElement("th", { scope: "col" }, "old line content"),
|
|
1273
|
-
React__namespace.createElement("th", { scope: "col" }, "new line number"),
|
|
1274
|
-
React__namespace.createElement("th", { scope: "col" }, "new line content"))),
|
|
1275
|
-
React__namespace.createElement("tbody", { className: "diff-table-body leading-[1.6]", onMouseDownCapture: onMouseDown },
|
|
1276
|
-
lines.map((line) => (React__namespace.createElement(React.Fragment, { key: line.index },
|
|
1277
|
-
React__namespace.createElement(DiffSplitHunkLine, { index: line.index, lineNumber: line.lineNumber, diffFile: diffFile }),
|
|
1278
|
-
React__namespace.createElement(DiffSplitContentLine, { index: line.index, lineNumber: line.lineNumber, diffFile: diffFile, enableAddWidget: enableAddWidget, enableHighlight: enableHighlight }),
|
|
1279
|
-
React__namespace.createElement(DiffSplitWidgetLine, { index: line.index, lineNumber: line.lineNumber, diffFile: diffFile }),
|
|
1280
|
-
React__namespace.createElement(DiffSplitExtendLine, { index: line.index, lineNumber: line.lineNumber, diffFile: diffFile })))),
|
|
1281
|
-
React__namespace.createElement(DiffSplitHunkLine, { index: diffFile.splitLineLength, lineNumber: diffFile.splitLineLength, diffFile: diffFile }))))));
|
|
1117
|
+
}, children: [jsxRuntime.jsx("style", { "data-select-style": true, ref: ref }), jsxRuntime.jsxs("table", { className: "diff-table w-full table-fixed border-collapse border-spacing-0", children: [jsxRuntime.jsxs("colgroup", { children: [jsxRuntime.jsx("col", { className: "diff-table-old-num-col", width: Math.round(width) }), jsxRuntime.jsx("col", { className: "diff-table-old-content-col" }), jsxRuntime.jsx("col", { className: "diff-table-new-num-col", width: Math.round(width) }), jsxRuntime.jsx("col", { className: "diff-table-new-content-col" })] }), jsxRuntime.jsx("thead", { className: "hidden", children: jsxRuntime.jsxs("tr", { children: [jsxRuntime.jsx("th", { scope: "col", children: "old line number" }), jsxRuntime.jsx("th", { scope: "col", children: "old line content" }), jsxRuntime.jsx("th", { scope: "col", children: "new line number" }), jsxRuntime.jsx("th", { scope: "col", children: "new line content" })] }) }), jsxRuntime.jsxs("tbody", { className: "diff-table-body leading-[1.6]", onMouseDownCapture: onMouseDown, children: [lines.map((line) => (jsxRuntime.jsxs(React.Fragment, { children: [jsxRuntime.jsx(DiffSplitHunkLine, { index: line.index, lineNumber: line.lineNumber, diffFile: diffFile }), jsxRuntime.jsx(DiffSplitContentLine, { index: line.index, lineNumber: line.lineNumber, diffFile: diffFile, enableAddWidget: !!enableAddWidget, enableHighlight: !!enableHighlight }), jsxRuntime.jsx(DiffSplitWidgetLine, { index: line.index, lineNumber: line.lineNumber, diffFile: diffFile }), jsxRuntime.jsx(DiffSplitExtendLine, { index: line.index, lineNumber: line.lineNumber, diffFile: diffFile })] }, line.index))), jsxRuntime.jsx(DiffSplitHunkLine, { index: diffFile.splitLineLength, lineNumber: diffFile.splitLineLength, diffFile: diffFile })] })] })] }) }));
|
|
1282
1118
|
});
|
|
1283
1119
|
DiffSplitViewWrap.displayName = "DiffSplitViewWrap";
|
|
1284
1120
|
|
|
@@ -1302,10 +1138,11 @@ const createDiffConfigStore = (props, diffFileId) => {
|
|
|
1302
1138
|
const fontSize = reactivityStore.ref(props.diffViewFontSize);
|
|
1303
1139
|
const setFontSize = (_fontSize) => (fontSize.value = _fontSize);
|
|
1304
1140
|
const extendData = reactivityStore.ref({
|
|
1305
|
-
oldFile:
|
|
1306
|
-
newFile:
|
|
1141
|
+
oldFile: { ...(_a = props.extendData) === null || _a === void 0 ? void 0 : _a.oldFile },
|
|
1142
|
+
newFile: { ...(_b = props.extendData) === null || _b === void 0 ? void 0 : _b.newFile },
|
|
1307
1143
|
});
|
|
1308
|
-
const setExtendData = (
|
|
1144
|
+
const setExtendData = (__extendData) => {
|
|
1145
|
+
const _extendData = __extendData || {};
|
|
1309
1146
|
const existOldKeys = Object.keys(extendData.value.oldFile || {});
|
|
1310
1147
|
const inComingOldKeys = Object.keys(_extendData.oldFile || {});
|
|
1311
1148
|
for (const key of existOldKeys) {
|
|
@@ -1400,45 +1237,30 @@ const DiffSplitView = React.memo(({ diffFile }) => {
|
|
|
1400
1237
|
React.useEffect(() => {
|
|
1401
1238
|
onCreateUseWidgetHook === null || onCreateUseWidgetHook === void 0 ? void 0 : onCreateUseWidgetHook(useWidget);
|
|
1402
1239
|
}, [useWidget, onCreateUseWidgetHook]);
|
|
1403
|
-
return (
|
|
1240
|
+
return (jsxRuntime.jsx(DiffWidgetContext.Provider, { value: contextValue, children: enableWrap ? jsxRuntime.jsx(DiffSplitViewWrap, { diffFile: diffFile }) : jsxRuntime.jsx(DiffSplitViewNormal, { diffFile: diffFile }) }));
|
|
1404
1241
|
});
|
|
1405
1242
|
DiffSplitView.displayName = "DiffSplitView";
|
|
1406
1243
|
|
|
1407
1244
|
const DiffUnifiedOldLine = ({ index, diffLine, rawLine, plainLine, syntaxLine, lineNumber, diffFile, setWidget, enableWrap, enableAddWidget, enableHighlight, onAddWidgetClick, }) => {
|
|
1408
|
-
return (
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
} },
|
|
1416
|
-
enableAddWidget && (React__namespace.createElement(DiffUnifiedAddWidget, { index: index - 1, lineNumber: lineNumber, diffFile: diffFile, side: core.SplitSide.old, onWidgetClick: onAddWidgetClick, onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber, side }) })),
|
|
1417
|
-
React__namespace.createElement("div", { className: "flex" },
|
|
1418
|
-
React__namespace.createElement("span", { "data-line-old-num": lineNumber, className: "inline-block w-[50%]" }, lineNumber),
|
|
1419
|
-
React__namespace.createElement("span", { className: "w-[10px] shrink-0" }),
|
|
1420
|
-
React__namespace.createElement("span", { className: "inline-block w-[50%]" }))),
|
|
1421
|
-
React__namespace.createElement("td", { className: "diff-line-content pr-[10px] align-top", style: { backgroundColor: `var(${delContentBGName})` } },
|
|
1422
|
-
React__namespace.createElement(DiffContent, { enableWrap: enableWrap, diffFile: diffFile, enableHighlight: enableHighlight, rawLine: rawLine, diffLine: diffLine, plainLine: plainLine, syntaxLine: syntaxLine }))));
|
|
1245
|
+
return (jsxRuntime.jsxs("tr", { "data-line": index, "data-state": "diff", className: "diff-line group", children: [jsxRuntime.jsxs("td", { className: "diff-line-num sticky left-0 z-[1] w-[1%] min-w-[100px] select-none whitespace-nowrap pl-[10px] pr-[10px] text-right align-top", style: {
|
|
1246
|
+
color: `var(${plainLineNumberColorName})`,
|
|
1247
|
+
backgroundColor: `var(${delLineNumberBGName})`,
|
|
1248
|
+
width: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
|
|
1249
|
+
maxWidth: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
|
|
1250
|
+
minWidth: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
|
|
1251
|
+
}, children: [enableAddWidget && (jsxRuntime.jsx(DiffUnifiedAddWidget, { index: index - 1, lineNumber: lineNumber, diffFile: diffFile, side: core.SplitSide.old, onWidgetClick: onAddWidgetClick, onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber, side }) })), jsxRuntime.jsxs("div", { className: "flex", children: [jsxRuntime.jsx("span", { "data-line-old-num": lineNumber, className: "inline-block w-[50%]", children: lineNumber }), jsxRuntime.jsx("span", { className: "w-[10px] shrink-0" }), jsxRuntime.jsx("span", { className: "inline-block w-[50%]" })] })] }), jsxRuntime.jsx("td", { className: "diff-line-content pr-[10px] align-top", style: { backgroundColor: `var(${delContentBGName})` }, children: jsxRuntime.jsx(DiffContent, { enableWrap: enableWrap, diffFile: diffFile, enableHighlight: enableHighlight, rawLine: rawLine, diffLine: diffLine, plainLine: plainLine, syntaxLine: syntaxLine }) })] }));
|
|
1423
1252
|
};
|
|
1424
1253
|
const DiffUnifiedNewLine = ({ index, diffLine, rawLine, plainLine, syntaxLine, lineNumber, diffFile, setWidget, enableWrap, enableAddWidget, enableHighlight, onAddWidgetClick, }) => {
|
|
1425
|
-
return (
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
} },
|
|
1433
|
-
enableAddWidget && (React__namespace.createElement(DiffUnifiedAddWidget, { index: index - 1, lineNumber: lineNumber, diffFile: diffFile, side: core.SplitSide.new, onWidgetClick: onAddWidgetClick, onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber, side }) })),
|
|
1434
|
-
React__namespace.createElement("div", { className: "flex" },
|
|
1435
|
-
React__namespace.createElement("span", { className: "inline-block w-[50%]" }),
|
|
1436
|
-
React__namespace.createElement("span", { className: "w-[10px] shrink-0" }),
|
|
1437
|
-
React__namespace.createElement("span", { "data-line-new-num": lineNumber, className: "inline-block w-[50%]" }, lineNumber))),
|
|
1438
|
-
React__namespace.createElement("td", { className: "diff-line-content pr-[10px] align-top", style: { backgroundColor: `var(${addContentBGName})` } },
|
|
1439
|
-
React__namespace.createElement(DiffContent, { enableWrap: enableWrap, diffFile: diffFile, enableHighlight: enableHighlight, rawLine: rawLine, diffLine: diffLine, plainLine: plainLine, syntaxLine: syntaxLine }))));
|
|
1254
|
+
return (jsxRuntime.jsxs("tr", { "data-line": index, "data-state": "diff", className: "diff-line group", children: [jsxRuntime.jsxs("td", { className: "diff-line-num sticky left-0 z-[1] w-[1%] min-w-[100px] select-none whitespace-nowrap pl-[10px] pr-[10px] text-right align-top", style: {
|
|
1255
|
+
color: `var(${plainLineNumberColorName})`,
|
|
1256
|
+
backgroundColor: `var(${addLineNumberBGName})`,
|
|
1257
|
+
width: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
|
|
1258
|
+
maxWidth: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
|
|
1259
|
+
minWidth: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
|
|
1260
|
+
}, children: [enableAddWidget && (jsxRuntime.jsx(DiffUnifiedAddWidget, { index: index - 1, lineNumber: lineNumber, diffFile: diffFile, side: core.SplitSide.new, onWidgetClick: onAddWidgetClick, onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber, side }) })), jsxRuntime.jsxs("div", { className: "flex", children: [jsxRuntime.jsx("span", { className: "inline-block w-[50%]" }), jsxRuntime.jsx("span", { className: "w-[10px] shrink-0" }), jsxRuntime.jsx("span", { "data-line-new-num": lineNumber, className: "inline-block w-[50%]", children: lineNumber })] })] }), jsxRuntime.jsx("td", { className: "diff-line-content pr-[10px] align-top", style: { backgroundColor: `var(${addContentBGName})` }, children: jsxRuntime.jsx(DiffContent, { enableWrap: enableWrap, diffFile: diffFile, enableHighlight: enableHighlight, rawLine: rawLine, diffLine: diffLine, plainLine: plainLine, syntaxLine: syntaxLine }) })] }));
|
|
1440
1261
|
};
|
|
1441
1262
|
const InternalDiffUnifiedLine = ({ index, diffFile, lineNumber, enableWrap, enableAddWidget, enableHighlight, }) => {
|
|
1263
|
+
var _a;
|
|
1442
1264
|
const unifiedLine = diffFile.getUnifiedLine(index);
|
|
1443
1265
|
const { useDiffContext } = useDiffViewContext();
|
|
1444
1266
|
const onAddWidgetClick = useDiffContext.getReadonlyState().onAddWidgetClick;
|
|
@@ -1462,40 +1284,33 @@ const InternalDiffUnifiedLine = ({ index, diffFile, lineNumber, enableWrap, enab
|
|
|
1462
1284
|
: undefined;
|
|
1463
1285
|
if (hasChange) {
|
|
1464
1286
|
if (unifiedLine.oldLineNumber) {
|
|
1465
|
-
return (
|
|
1287
|
+
return (jsxRuntime.jsx(DiffUnifiedOldLine, { index: lineNumber, enableWrap: enableWrap, diffFile: diffFile, rawLine: rawLine, diffLine: diffLine, setWidget: setWidget, plainLine: plainLine, 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); } }));
|
|
1466
1288
|
}
|
|
1467
1289
|
else {
|
|
1468
|
-
return (
|
|
1290
|
+
return (jsxRuntime.jsx(DiffUnifiedNewLine, { index: lineNumber, enableWrap: enableWrap, rawLine: rawLine, diffLine: diffLine, diffFile: diffFile, setWidget: setWidget, plainLine: plainLine, 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); } }));
|
|
1469
1291
|
}
|
|
1470
1292
|
}
|
|
1471
1293
|
else {
|
|
1472
|
-
return (
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
React__namespace.createElement("div", { className: "flex opacity-[0.5]" },
|
|
1482
|
-
React__namespace.createElement("span", { "data-line-old-num": unifiedLine.oldLineNumber, className: "inline-block w-[50%]" }, unifiedLine.oldLineNumber),
|
|
1483
|
-
React__namespace.createElement("span", { className: "w-[10px] shrink-0" }),
|
|
1484
|
-
React__namespace.createElement("span", { "data-line-new-num": unifiedLine.newLineNumber, className: "inline-block w-[50%]" }, unifiedLine.newLineNumber))),
|
|
1485
|
-
React__namespace.createElement("td", { className: "diff-line-content pr-[10px] align-top", style: {
|
|
1486
|
-
backgroundColor: hasDiff ? `var(${plainContentBGName})` : `var(${expandContentBGName})`,
|
|
1487
|
-
} },
|
|
1488
|
-
React__namespace.createElement(DiffContent, { enableWrap: enableWrap, diffFile: diffFile, enableHighlight: enableHighlight, rawLine: rawLine, diffLine: diffLine, plainLine: plainLine, syntaxLine: syntaxLine }))));
|
|
1294
|
+
return (jsxRuntime.jsxs("tr", { "data-line": lineNumber, "data-state": unifiedLine.diff ? "diff" : "plain", className: "diff-line group", children: [jsxRuntime.jsxs("td", { className: "diff-line-num sticky left-0 z-[1] w-[1%] min-w-[100px] select-none whitespace-nowrap pl-[10px] pr-[10px] text-right align-top", style: {
|
|
1295
|
+
color: `var(${hasDiff ? plainLineNumberColorName : expandLineNumberColorName})`,
|
|
1296
|
+
width: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
|
|
1297
|
+
maxWidth: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
|
|
1298
|
+
minWidth: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
|
|
1299
|
+
backgroundColor: hasDiff ? `var(${plainLineNumberBGName})` : `var(${expandContentBGName})`,
|
|
1300
|
+
}, children: [enableAddWidget && hasDiff && (jsxRuntime.jsx(DiffUnifiedAddWidget, { index: index, diffFile: diffFile, lineNumber: (_a = unifiedLine.newLineNumber) !== null && _a !== void 0 ? _a : -1, side: core.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 }) })), jsxRuntime.jsxs("div", { className: "flex opacity-[0.5]", children: [jsxRuntime.jsx("span", { "data-line-old-num": unifiedLine.oldLineNumber, className: "inline-block w-[50%]", children: unifiedLine.oldLineNumber }), jsxRuntime.jsx("span", { className: "w-[10px] shrink-0" }), jsxRuntime.jsx("span", { "data-line-new-num": unifiedLine.newLineNumber, className: "inline-block w-[50%]", children: unifiedLine.newLineNumber })] })] }), jsxRuntime.jsx("td", { className: "diff-line-content pr-[10px] align-top", style: {
|
|
1301
|
+
backgroundColor: hasDiff ? `var(${plainContentBGName})` : `var(${expandContentBGName})`,
|
|
1302
|
+
}, children: jsxRuntime.jsx(DiffContent, { enableWrap: enableWrap, diffFile: diffFile, enableHighlight: enableHighlight, rawLine: rawLine, diffLine: diffLine, plainLine: plainLine, syntaxLine: syntaxLine }) })] }));
|
|
1489
1303
|
}
|
|
1490
1304
|
};
|
|
1491
1305
|
const DiffUnifiedContentLine = ({ index, diffFile, lineNumber, enableWrap, enableHighlight, enableAddWidget, }) => {
|
|
1492
1306
|
const unifiedLine = diffFile.getUnifiedLine(index);
|
|
1493
1307
|
if (unifiedLine === null || unifiedLine === void 0 ? void 0 : unifiedLine.isHidden)
|
|
1494
1308
|
return null;
|
|
1495
|
-
return (
|
|
1309
|
+
return (jsxRuntime.jsx(InternalDiffUnifiedLine, { index: index, diffFile: diffFile, lineNumber: lineNumber, enableWrap: enableWrap, enableHighlight: enableHighlight, enableAddWidget: enableAddWidget }));
|
|
1496
1310
|
};
|
|
1497
1311
|
|
|
1498
1312
|
const InternalDiffUnifiedExtendLine = ({ index, diffFile, lineNumber, enableWrap, oldLineExtend, newLineExtend, }) => {
|
|
1313
|
+
var _a, _b;
|
|
1499
1314
|
const { useDiffContext } = useDiffViewContext();
|
|
1500
1315
|
const renderExtendLine = useDiffContext.useShallowStableSelector((s) => s.renderExtendLine);
|
|
1501
1316
|
const unifiedItem = diffFile.getUnifiedLine(index);
|
|
@@ -1506,44 +1321,40 @@ const InternalDiffUnifiedExtendLine = ({ index, diffFile, lineNumber, enableWrap
|
|
|
1506
1321
|
});
|
|
1507
1322
|
if (!renderExtendLine)
|
|
1508
1323
|
return null;
|
|
1509
|
-
return (
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
lineNumber: unifiedItem.newLineNumber,
|
|
1529
|
-
data: newLineExtend.data,
|
|
1530
|
-
onUpdate: diffFile.notifyAll,
|
|
1531
|
-
}))))));
|
|
1324
|
+
return (jsxRuntime.jsx("tr", { "data-line": `${lineNumber}-extend`, "data-state": "extend", className: "diff-line diff-line-extend", children: jsxRuntime.jsx("td", { className: "diff-line-extend-content p-0 align-top", colSpan: 2, children: jsxRuntime.jsxs("div", { className: "diff-line-extend-wrapper sticky left-0 z-[1]", style: { width }, children: [(enableWrap ? true : width > 0) &&
|
|
1325
|
+
(oldLineExtend === null || oldLineExtend === void 0 ? void 0 : oldLineExtend.data) !== undefined &&
|
|
1326
|
+
(oldLineExtend === null || oldLineExtend === void 0 ? void 0 : oldLineExtend.data) !== null &&
|
|
1327
|
+
(renderExtendLine === null || renderExtendLine === void 0 ? void 0 : renderExtendLine({
|
|
1328
|
+
diffFile,
|
|
1329
|
+
side: core.SplitSide.old,
|
|
1330
|
+
lineNumber: (_a = unifiedItem.oldLineNumber) !== null && _a !== void 0 ? _a : -1,
|
|
1331
|
+
data: oldLineExtend.data,
|
|
1332
|
+
onUpdate: diffFile.notifyAll,
|
|
1333
|
+
})), (enableWrap ? true : width > 0) &&
|
|
1334
|
+
(newLineExtend === null || newLineExtend === void 0 ? void 0 : newLineExtend.data) !== undefined &&
|
|
1335
|
+
(newLineExtend === null || newLineExtend === void 0 ? void 0 : newLineExtend.data) !== null &&
|
|
1336
|
+
(renderExtendLine === null || renderExtendLine === void 0 ? void 0 : renderExtendLine({
|
|
1337
|
+
diffFile,
|
|
1338
|
+
side: core.SplitSide.new,
|
|
1339
|
+
lineNumber: (_b = unifiedItem.newLineNumber) !== null && _b !== void 0 ? _b : -1,
|
|
1340
|
+
data: newLineExtend.data,
|
|
1341
|
+
onUpdate: diffFile.notifyAll,
|
|
1342
|
+
}))] }) }) }));
|
|
1532
1343
|
};
|
|
1533
1344
|
const DiffUnifiedExtendLine = ({ index, diffFile, lineNumber, enableWrap, }) => {
|
|
1534
1345
|
const { useDiffContext } = useDiffViewContext();
|
|
1535
1346
|
const unifiedItem = diffFile.getUnifiedLine(index);
|
|
1536
1347
|
const { oldLineExtend, newLineExtend } = useDiffContext(React.useCallback((s) => {
|
|
1537
|
-
var _a, _b, _c, _d;
|
|
1348
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1538
1349
|
return ({
|
|
1539
|
-
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],
|
|
1540
|
-
newLineExtend: (
|
|
1350
|
+
oldLineExtend: (_b = (_a = s.extendData) === null || _a === void 0 ? void 0 : _a.oldFile) === null || _b === void 0 ? void 0 : _b[(_c = unifiedItem === null || unifiedItem === void 0 ? void 0 : unifiedItem.oldLineNumber) !== null && _c !== void 0 ? _c : -1],
|
|
1351
|
+
newLineExtend: (_e = (_d = s.extendData) === null || _d === void 0 ? void 0 : _d.newFile) === null || _e === void 0 ? void 0 : _e[(_f = unifiedItem === null || unifiedItem === void 0 ? void 0 : unifiedItem.newLineNumber) !== null && _f !== void 0 ? _f : -1],
|
|
1541
1352
|
});
|
|
1542
1353
|
}, [unifiedItem.oldLineNumber, unifiedItem.newLineNumber]));
|
|
1543
1354
|
const hasExtend = (oldLineExtend === null || oldLineExtend === void 0 ? void 0 : oldLineExtend.data) || (newLineExtend === null || newLineExtend === void 0 ? void 0 : newLineExtend.data);
|
|
1544
1355
|
if (!hasExtend || !unifiedItem || unifiedItem.isHidden)
|
|
1545
1356
|
return null;
|
|
1546
|
-
return (
|
|
1357
|
+
return (jsxRuntime.jsx(InternalDiffUnifiedExtendLine, { index: index, diffFile: diffFile, lineNumber: lineNumber, enableWrap: enableWrap, oldLineExtend: oldLineExtend, newLineExtend: newLineExtend }));
|
|
1547
1358
|
};
|
|
1548
1359
|
|
|
1549
1360
|
const InternalDiffUnifiedHunkLine = ({ index, diffFile, lineNumber, }) => {
|
|
@@ -1558,27 +1369,17 @@ const InternalDiffUnifiedHunkLine = ({ index, diffFile, lineNumber, }) => {
|
|
|
1558
1369
|
currentHunk.unifiedInfo.endHiddenIndex - currentHunk.unifiedInfo.startHiddenIndex < core.composeLen;
|
|
1559
1370
|
const isFirstLine = currentHunk && currentHunk.isFirst;
|
|
1560
1371
|
const isLastLine = currentHunk && currentHunk.isLast;
|
|
1561
|
-
return (
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onUnifiedHunkExpand("down", index) },
|
|
1573
|
-
React__namespace.createElement(ExpandDown, { className: "fill-current" })),
|
|
1574
|
-
React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onUnifiedHunkExpand("up", index) },
|
|
1575
|
-
React__namespace.createElement(ExpandUp, { className: "fill-current" }))))) : (React__namespace.createElement("div", { className: "min-h-[28px]" }, "\u2002"))),
|
|
1576
|
-
React__namespace.createElement("td", { className: "diff-line-hunk-content pr-[10px] align-middle", style: { backgroundColor: `var(${hunkContentBGName})` } },
|
|
1577
|
-
React__namespace.createElement("div", { className: "pl-[1.5em]", style: {
|
|
1578
|
-
whiteSpace: enableWrap ? "pre-wrap" : "pre",
|
|
1579
|
-
wordBreak: enableWrap ? "break-all" : "initial",
|
|
1580
|
-
color: `var(${hunkContentColorName})`,
|
|
1581
|
-
} }, ((_a = currentHunk.unifiedInfo) === null || _a === void 0 ? void 0 : _a.plainText) || currentHunk.text))));
|
|
1372
|
+
return (jsxRuntime.jsxs("tr", { "data-line": `${lineNumber}-hunk`, "data-state": "hunk", className: "diff-line diff-line-hunk", children: [jsxRuntime.jsx("td", { className: "diff-line-hunk-action sticky left-0 w-[1%] min-w-[100px] select-none p-[1px]", style: {
|
|
1373
|
+
backgroundColor: `var(${hunkLineNumberBGName})`,
|
|
1374
|
+
color: `var(${plainLineNumberColorName})`,
|
|
1375
|
+
width: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
|
|
1376
|
+
maxWidth: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
|
|
1377
|
+
minWidth: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
|
|
1378
|
+
}, children: couldExpand ? (isFirstLine ? (jsxRuntime.jsx("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onUnifiedHunkExpand("up", index), children: jsxRuntime.jsx(ExpandUp, { className: "fill-current" }) })) : isLastLine ? (jsxRuntime.jsx("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onUnifiedHunkExpand("down", index), children: jsxRuntime.jsx(ExpandDown, { className: "fill-current" }) })) : isExpandAll ? (jsxRuntime.jsx("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]", title: "Expand All", "data-title": "Expand All", onClick: () => diffFile.onUnifiedHunkExpand("all", index), children: jsxRuntime.jsx(ExpandAll, { className: "fill-current" }) })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onUnifiedHunkExpand("down", index), children: jsxRuntime.jsx(ExpandDown, { className: "fill-current" }) }), jsxRuntime.jsx("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onUnifiedHunkExpand("up", index), children: jsxRuntime.jsx(ExpandUp, { className: "fill-current" }) })] }))) : (jsxRuntime.jsx("div", { className: "min-h-[28px]", children: "\u2002" })) }), jsxRuntime.jsx("td", { className: "diff-line-hunk-content pr-[10px] align-middle", style: { backgroundColor: `var(${hunkContentBGName})` }, children: jsxRuntime.jsx("div", { className: "pl-[1.5em]", style: {
|
|
1379
|
+
whiteSpace: enableWrap ? "pre-wrap" : "pre",
|
|
1380
|
+
wordBreak: enableWrap ? "break-all" : "initial",
|
|
1381
|
+
color: `var(${hunkContentColorName})`,
|
|
1382
|
+
}, children: ((_a = currentHunk.unifiedInfo) === null || _a === void 0 ? void 0 : _a.plainText) || currentHunk.text }) })] }));
|
|
1582
1383
|
};
|
|
1583
1384
|
const DiffUnifiedHunkLine = ({ index, diffFile, lineNumber, }) => {
|
|
1584
1385
|
const currentHunk = diffFile.getUnifiedHunkLine(index);
|
|
@@ -1588,10 +1389,11 @@ const DiffUnifiedHunkLine = ({ index, diffFile, lineNumber, }) => {
|
|
|
1588
1389
|
const currentIsPureHunk = currentHunk && diffFile._getIsPureDiffRender() && !currentHunk.unifiedInfo;
|
|
1589
1390
|
if (!currentIsShow && !currentIsPureHunk)
|
|
1590
1391
|
return null;
|
|
1591
|
-
return
|
|
1392
|
+
return jsxRuntime.jsx(InternalDiffUnifiedHunkLine, { index: index, diffFile: diffFile, lineNumber: lineNumber });
|
|
1592
1393
|
};
|
|
1593
1394
|
|
|
1594
1395
|
const InternalDiffUnifiedWidgetLine = ({ index, diffFile, lineNumber, enableWrap, }) => {
|
|
1396
|
+
var _a, _b;
|
|
1595
1397
|
const { useWidget } = useDiffWidgetContext();
|
|
1596
1398
|
const setWidget = useWidget.getReadonlyState().setWidget;
|
|
1597
1399
|
const unifiedItem = diffFile.getUnifiedLine(index);
|
|
@@ -1609,15 +1411,11 @@ const InternalDiffUnifiedWidgetLine = ({ index, diffFile, lineNumber, enableWrap
|
|
|
1609
1411
|
});
|
|
1610
1412
|
if (!renderWidgetLine)
|
|
1611
1413
|
return null;
|
|
1612
|
-
return (
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
(renderWidgetLine === null || renderWidgetLine === void 0 ? void 0 : renderWidgetLine({ diffFile, side: core.SplitSide.old, lineNumber: unifiedItem.oldLineNumber, onClose })),
|
|
1618
|
-
(enableWrap ? true : width > 0) &&
|
|
1619
|
-
newWidget &&
|
|
1620
|
-
(renderWidgetLine === null || renderWidgetLine === void 0 ? void 0 : renderWidgetLine({ diffFile, side: core.SplitSide.new, lineNumber: unifiedItem.newLineNumber, onClose }))))));
|
|
1414
|
+
return (jsxRuntime.jsx("tr", { "data-line": `${lineNumber}-widget`, "data-state": "widget", className: "diff-line diff-line-widget", children: jsxRuntime.jsx("td", { className: "diff-line-widget-content p-0", colSpan: 2, children: jsxRuntime.jsxs("div", { className: "diff-line-widget-wrapper sticky left-0 z-[1]", style: { width }, children: [(enableWrap ? true : width > 0) &&
|
|
1415
|
+
oldWidget &&
|
|
1416
|
+
(renderWidgetLine === null || renderWidgetLine === void 0 ? void 0 : renderWidgetLine({ diffFile, side: core.SplitSide.old, lineNumber: (_a = unifiedItem.oldLineNumber) !== null && _a !== void 0 ? _a : -1, onClose })), (enableWrap ? true : width > 0) &&
|
|
1417
|
+
newWidget &&
|
|
1418
|
+
(renderWidgetLine === null || renderWidgetLine === void 0 ? void 0 : renderWidgetLine({ diffFile, side: core.SplitSide.new, lineNumber: (_b = unifiedItem.newLineNumber) !== null && _b !== void 0 ? _b : -1, onClose }))] }) }) }));
|
|
1621
1419
|
};
|
|
1622
1420
|
const DiffUnifiedWidgetLine = ({ index, diffFile, lineNumber, enableWrap, }) => {
|
|
1623
1421
|
const { useWidget } = useDiffWidgetContext();
|
|
@@ -1632,14 +1430,13 @@ const DiffUnifiedWidgetLine = ({ index, diffFile, lineNumber, enableWrap, }) =>
|
|
|
1632
1430
|
}, [diffFile, index]), (p, c) => p === c);
|
|
1633
1431
|
if (!currentIsShow)
|
|
1634
1432
|
return null;
|
|
1635
|
-
return (
|
|
1433
|
+
return (jsxRuntime.jsx(InternalDiffUnifiedWidgetLine, { index: index, diffFile: diffFile, lineNumber: lineNumber, enableWrap: enableWrap }));
|
|
1636
1434
|
};
|
|
1637
1435
|
|
|
1638
|
-
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
1639
1436
|
const DiffUnifiedView = React.memo(({ diffFile }) => {
|
|
1640
1437
|
const { useDiffContext } = useDiffViewContext();
|
|
1641
1438
|
const ref = React.useRef(null);
|
|
1642
|
-
const tempRef = React.useRef();
|
|
1439
|
+
const tempRef = React.useRef(undefined);
|
|
1643
1440
|
const useDiffContextRef = React.useRef(useDiffContext);
|
|
1644
1441
|
useDiffContextRef.current = useDiffContext;
|
|
1645
1442
|
// performance optimization
|
|
@@ -1712,30 +1509,12 @@ const DiffUnifiedView = React.memo(({ diffFile }) => {
|
|
|
1712
1509
|
ele = ele.parentElement;
|
|
1713
1510
|
}
|
|
1714
1511
|
};
|
|
1715
|
-
return (
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
[
|
|
1721
|
-
fontFamily: "Menlo, Consolas, monospace",
|
|
1722
|
-
fontSize: `var(${diffFontSizeName})`,
|
|
1723
|
-
} },
|
|
1724
|
-
React__namespace.createElement("table", { className: `unified-diff-table w-full border-collapse border-spacing-0 ${enableWrap ? "table-fixed" : ""}` },
|
|
1725
|
-
React__namespace.createElement("colgroup", null,
|
|
1726
|
-
React__namespace.createElement("col", { className: "unified-diff-table-num-col" }),
|
|
1727
|
-
React__namespace.createElement("col", { className: "unified-diff-table-content-col" })),
|
|
1728
|
-
React__namespace.createElement("thead", { className: "hidden" },
|
|
1729
|
-
React__namespace.createElement("tr", null,
|
|
1730
|
-
React__namespace.createElement("th", { scope: "col" }, "line number"),
|
|
1731
|
-
React__namespace.createElement("th", { scope: "col" }, "line content"))),
|
|
1732
|
-
React__namespace.createElement("tbody", { className: "diff-table-body leading-[1.6]", onMouseDownCapture: onMouseDown },
|
|
1733
|
-
lines.map((item) => (React__namespace.createElement(React.Fragment, { key: item.index },
|
|
1734
|
-
React__namespace.createElement(DiffUnifiedHunkLine, { index: item.index, lineNumber: item.lineNumber, diffFile: diffFile }),
|
|
1735
|
-
React__namespace.createElement(DiffUnifiedContentLine, { index: item.index, lineNumber: item.lineNumber, diffFile: diffFile, enableWrap: enableWrap, enableHighlight: enableHighlight, enableAddWidget: enableAddWidget }),
|
|
1736
|
-
React__namespace.createElement(DiffUnifiedWidgetLine, { index: item.index, lineNumber: item.lineNumber, diffFile: diffFile, enableWrap: enableWrap }),
|
|
1737
|
-
React__namespace.createElement(DiffUnifiedExtendLine, { index: item.index, lineNumber: item.lineNumber, diffFile: diffFile, enableWrap: enableWrap })))),
|
|
1738
|
-
React__namespace.createElement(DiffUnifiedHunkLine, { index: diffFile.unifiedLineLength, lineNumber: diffFile.unifiedLineLength, diffFile: diffFile })))))));
|
|
1512
|
+
return (jsxRuntime.jsx(DiffWidgetContext.Provider, { value: contextValue, children: jsxRuntime.jsxs("div", { className: `unified-diff-view ${enableWrap ? "unified-diff-view-wrap" : "unified-diff-view-normal"} w-full`, children: [jsxRuntime.jsx("style", { "data-select-style": true, ref: ref }), jsxRuntime.jsx("div", { className: "unified-diff-table-wrapper diff-table-scroll-container w-full overflow-x-auto overflow-y-hidden", style: {
|
|
1513
|
+
// @ts-ignore
|
|
1514
|
+
[diffAsideWidthName]: `${Math.round(width)}px`,
|
|
1515
|
+
fontFamily: "Menlo, Consolas, monospace",
|
|
1516
|
+
fontSize: `var(${diffFontSizeName})`,
|
|
1517
|
+
}, children: jsxRuntime.jsxs("table", { className: `unified-diff-table w-full border-collapse border-spacing-0 ${enableWrap ? "table-fixed" : ""}`, children: [jsxRuntime.jsxs("colgroup", { children: [jsxRuntime.jsx("col", { className: "unified-diff-table-num-col" }), jsxRuntime.jsx("col", { className: "unified-diff-table-content-col" })] }), jsxRuntime.jsx("thead", { className: "hidden", children: jsxRuntime.jsxs("tr", { children: [jsxRuntime.jsx("th", { scope: "col", children: "line number" }), jsxRuntime.jsx("th", { scope: "col", children: "line content" })] }) }), jsxRuntime.jsxs("tbody", { className: "diff-table-body leading-[1.6]", onMouseDownCapture: onMouseDown, children: [lines.map((item) => (jsxRuntime.jsxs(React.Fragment, { children: [jsxRuntime.jsx(DiffUnifiedHunkLine, { index: item.index, lineNumber: item.lineNumber, diffFile: diffFile }), jsxRuntime.jsx(DiffUnifiedContentLine, { index: item.index, lineNumber: item.lineNumber, diffFile: diffFile, enableWrap: !!enableWrap, enableHighlight: !!enableHighlight, enableAddWidget: !!enableAddWidget }), jsxRuntime.jsx(DiffUnifiedWidgetLine, { index: item.index, lineNumber: item.lineNumber, diffFile: diffFile, enableWrap: !!enableWrap }), jsxRuntime.jsx(DiffUnifiedExtendLine, { index: item.index, lineNumber: item.lineNumber, diffFile: diffFile, enableWrap: !!enableWrap })] }, item.index))), jsxRuntime.jsx(DiffUnifiedHunkLine, { index: diffFile.unifiedLineLength, lineNumber: diffFile.unifiedLineLength, diffFile: diffFile })] })] }) })] }) }));
|
|
1739
1518
|
});
|
|
1740
1519
|
DiffUnifiedView.displayName = "DiffUnifiedView";
|
|
1741
1520
|
|
|
@@ -1759,13 +1538,13 @@ const InternalDiffView = (props) => {
|
|
|
1759
1538
|
setMounted(isMounted);
|
|
1760
1539
|
}
|
|
1761
1540
|
if (diffViewAddWidget !== enableAddWidget) {
|
|
1762
|
-
setEnableAddWidget(diffViewAddWidget);
|
|
1541
|
+
setEnableAddWidget(!!diffViewAddWidget);
|
|
1763
1542
|
}
|
|
1764
1543
|
if (diffViewHighlight !== enableHighlight) {
|
|
1765
|
-
setEnableHighlight(diffViewHighlight);
|
|
1544
|
+
setEnableHighlight(!!diffViewHighlight);
|
|
1766
1545
|
}
|
|
1767
1546
|
if (diffViewWrap !== enableWrap) {
|
|
1768
|
-
setEnableWrap(diffViewWrap);
|
|
1547
|
+
setEnableWrap(!!diffViewWrap);
|
|
1769
1548
|
}
|
|
1770
1549
|
if (extendData) {
|
|
1771
1550
|
setExtendData(extendData);
|
|
@@ -1801,21 +1580,20 @@ const InternalDiffView = (props) => {
|
|
|
1801
1580
|
onCreateUseWidgetHook,
|
|
1802
1581
|
]);
|
|
1803
1582
|
React.useEffect(() => {
|
|
1804
|
-
|
|
1583
|
+
if (wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current) {
|
|
1584
|
+
useDiffContext.getReadonlyState().setDom(wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current);
|
|
1585
|
+
}
|
|
1805
1586
|
}, [useDiffContext, wrapperRef]);
|
|
1806
1587
|
const value = React.useMemo(() => ({ useDiffContext }), [useDiffContext]);
|
|
1807
|
-
return (
|
|
1808
|
-
React__namespace.createElement("div", { className: "diff-tailwindcss-wrapper", "data-component": "git-diff-view", "data-theme": diffFile._getTheme() || "light", "data-version": "0.1.3", "data-highlighter": diffFile._getHighlighterName(), ref: wrapperRef },
|
|
1809
|
-
React__namespace.createElement("div", { className: "diff-style-root", style: {
|
|
1588
|
+
return (jsxRuntime.jsx(DiffViewContext.Provider, { value: value, children: jsxRuntime.jsx("div", { className: "diff-tailwindcss-wrapper", "data-component": "git-diff-view", "data-theme": diffFile._getTheme() || "light", "data-version": "0.1.4", "data-highlighter": diffFile._getHighlighterName(), ref: wrapperRef, children: jsxRuntime.jsx("div", { className: "diff-style-root", style: {
|
|
1810
1589
|
// @ts-ignore
|
|
1811
1590
|
[diffFontSizeName]: diffViewFontSize + "px",
|
|
1812
|
-
} },
|
|
1813
|
-
React__namespace.createElement("div", { id: isMounted ? `diff-root${diffFileId}` : undefined, className: "diff-view-wrapper" + (className ? ` ${className}` : ""), style: style }, diffViewMode & exports.DiffModeEnum.Split ? (React__namespace.createElement(DiffSplitView, { diffFile: diffFile })) : (React__namespace.createElement(DiffUnifiedView, { diffFile: diffFile })))))));
|
|
1591
|
+
}, children: jsxRuntime.jsx("div", { id: isMounted ? `diff-root${diffFileId}` : undefined, className: "diff-view-wrapper" + (className ? ` ${className}` : ""), style: style, children: diffViewMode & exports.DiffModeEnum.Split ? (jsxRuntime.jsx(DiffSplitView, { diffFile: diffFile })) : (jsxRuntime.jsx(DiffUnifiedView, { diffFile: diffFile })) }) }) }) }));
|
|
1814
1592
|
};
|
|
1815
1593
|
const MemoedInternalDiffView = React.memo(InternalDiffView);
|
|
1816
1594
|
const DiffViewWithRef = (props, ref) => {
|
|
1817
1595
|
var _a, _b;
|
|
1818
|
-
const { registerHighlighter, data, diffViewTheme, diffFile: _diffFile
|
|
1596
|
+
const { registerHighlighter, data, diffViewTheme, diffFile: _diffFile, ...restProps } = props;
|
|
1819
1597
|
const diffFile = React.useMemo(() => {
|
|
1820
1598
|
var _a, _b, _c, _d, _e, _f;
|
|
1821
1599
|
if (_diffFile) {
|
|
@@ -1832,8 +1610,10 @@ const DiffViewWithRef = (props, ref) => {
|
|
|
1832
1610
|
return null;
|
|
1833
1611
|
}, [data, _diffFile]);
|
|
1834
1612
|
const diffFileRef = React.useRef(diffFile);
|
|
1835
|
-
const wrapperRef = React.useRef();
|
|
1613
|
+
const wrapperRef = React.useRef(null);
|
|
1614
|
+
// eslint-disable-next-line react-hooks/refs
|
|
1836
1615
|
if (diffFileRef.current && diffFileRef.current !== diffFile) {
|
|
1616
|
+
// eslint-disable-next-line react-hooks/refs
|
|
1837
1617
|
(_b = (_a = diffFileRef.current).clear) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
1838
1618
|
diffFileRef.current = diffFile;
|
|
1839
1619
|
}
|
|
@@ -1890,18 +1670,232 @@ const DiffViewWithRef = (props, ref) => {
|
|
|
1890
1670
|
React.useImperativeHandle(ref, () => ({ getDiffFileInstance: () => diffFile }), [diffFile]);
|
|
1891
1671
|
if (!diffFile)
|
|
1892
1672
|
return null;
|
|
1893
|
-
return (
|
|
1673
|
+
return (jsxRuntime.jsx(MemoedInternalDiffView, { ...restProps, diffFile: diffFile, isMounted: isMounted, wrapperRef: wrapperRef, diffViewTheme: diffViewTheme, diffViewMode: restProps.diffViewMode || exports.DiffModeEnum.SplitGitHub, diffViewFontSize: restProps.diffViewFontSize || 14 }, diffFile.getId()));
|
|
1894
1674
|
};
|
|
1895
1675
|
const InnerDiffView = React.forwardRef(DiffViewWithRef);
|
|
1896
1676
|
InnerDiffView.displayName = "DiffView";
|
|
1897
1677
|
const DiffView = InnerDiffView;
|
|
1898
|
-
const version = "0.1.
|
|
1678
|
+
const version = "0.1.4";
|
|
1679
|
+
|
|
1680
|
+
/* eslint-disable @typescript-eslint/no-unsafe-function-type */
|
|
1681
|
+
const useCallbackRef = (cb) => {
|
|
1682
|
+
const cbRef = React.useRef(cb);
|
|
1683
|
+
// eslint-disable-next-line react-hooks/refs
|
|
1684
|
+
cbRef.current = cb;
|
|
1685
|
+
return React.useCallback((...args) => {
|
|
1686
|
+
var _a;
|
|
1687
|
+
return (_a = cbRef.current) === null || _a === void 0 ? void 0 : _a.call(cbRef, ...args);
|
|
1688
|
+
}, []);
|
|
1689
|
+
};
|
|
1690
|
+
|
|
1691
|
+
const useUpdateEffect = (effect, deps) => {
|
|
1692
|
+
const isMounted = React.useRef(false);
|
|
1693
|
+
React.useEffect(() => {
|
|
1694
|
+
if (isMounted.current) {
|
|
1695
|
+
return effect();
|
|
1696
|
+
}
|
|
1697
|
+
isMounted.current = true;
|
|
1698
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1699
|
+
}, deps);
|
|
1700
|
+
};
|
|
1701
|
+
|
|
1702
|
+
/* eslint-disable @typescript-eslint/no-unnecessary-type-constraint */
|
|
1703
|
+
const InternalDiffViewWithMultiSelect = (props, ref) => {
|
|
1704
|
+
const { enableMultiSelect = true, extendData, onMultiSelectComplete, onMultiSelectChange, scopeMultiSelectToHunk, renderWidgetLine, onAddWidgetClick, diffViewMode = exports.DiffModeEnum.SplitGitHub, ...restProps } = props;
|
|
1705
|
+
const memoSelectChange = useCallbackRef(onMultiSelectChange);
|
|
1706
|
+
const memoSelectComplete = useCallbackRef(onMultiSelectComplete);
|
|
1707
|
+
const memoScopeSelectToHunk = useCallbackRef(scopeMultiSelectToHunk);
|
|
1708
|
+
const containerRef = React.useRef(null);
|
|
1709
|
+
const diffViewRef = React.useRef(null);
|
|
1710
|
+
const managerRef = React.useRef(null);
|
|
1711
|
+
const multiResultRef = React.useRef(undefined);
|
|
1712
|
+
const isUnifiedMode = !(diffViewMode & exports.DiffModeEnum.Split);
|
|
1713
|
+
const updateMultiResult = React.useCallback((result) => {
|
|
1714
|
+
var _a;
|
|
1715
|
+
multiResultRef.current = result;
|
|
1716
|
+
(_a = managerRef.current) === null || _a === void 0 ? void 0 : _a.setPreselectedLines(result || { old: [], new: [] });
|
|
1717
|
+
}, []);
|
|
1718
|
+
useUpdateEffect(() => {
|
|
1719
|
+
updateMultiResult(undefined);
|
|
1720
|
+
}, [props.diffViewWrap, diffViewMode]);
|
|
1721
|
+
const getDiffFile = React.useCallback(() => {
|
|
1722
|
+
var _a, _b;
|
|
1723
|
+
return (_b = (_a = diffViewRef.current) === null || _a === void 0 ? void 0 : _a.getDiffFileInstance()) !== null && _b !== void 0 ? _b : null;
|
|
1724
|
+
}, []);
|
|
1725
|
+
React.useEffect(() => {
|
|
1726
|
+
var _a;
|
|
1727
|
+
const container = containerRef.current;
|
|
1728
|
+
const diffFile = getDiffFile();
|
|
1729
|
+
if (!container || !diffFile || !enableMultiSelect) {
|
|
1730
|
+
(_a = managerRef.current) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
1731
|
+
managerRef.current = null;
|
|
1732
|
+
return;
|
|
1733
|
+
}
|
|
1734
|
+
const managerOptions = {
|
|
1735
|
+
enabled: enableMultiSelect,
|
|
1736
|
+
isUnifiedMode,
|
|
1737
|
+
selectedClassName: core.multiSelectClassNames.selected,
|
|
1738
|
+
onSelectionChange: (range, state) => {
|
|
1739
|
+
var _a, _b;
|
|
1740
|
+
if (state.isSelecting) {
|
|
1741
|
+
(_a = containerRef.current) === null || _a === void 0 ? void 0 : _a.classList.add(core.multiSelectClassNames.selecting);
|
|
1742
|
+
}
|
|
1743
|
+
else {
|
|
1744
|
+
(_b = containerRef.current) === null || _b === void 0 ? void 0 : _b.classList.remove(core.multiSelectClassNames.selecting);
|
|
1745
|
+
}
|
|
1746
|
+
if (state.isSelecting && multiResultRef.current) {
|
|
1747
|
+
updateMultiResult(undefined);
|
|
1748
|
+
}
|
|
1749
|
+
memoSelectChange === null || memoSelectChange === void 0 ? void 0 : memoSelectChange(range, state);
|
|
1750
|
+
},
|
|
1751
|
+
onSelectionComplete: (result) => {
|
|
1752
|
+
var _a;
|
|
1753
|
+
(_a = containerRef.current) === null || _a === void 0 ? void 0 : _a.classList.remove(core.multiSelectClassNames.selecting);
|
|
1754
|
+
if (result && result.lines.length > 0) {
|
|
1755
|
+
memoSelectComplete === null || memoSelectComplete === void 0 ? void 0 : memoSelectComplete(result);
|
|
1756
|
+
const finalResult = {
|
|
1757
|
+
[result.range.side]: [result.range.startLineNumber, result.range.endLineNumber],
|
|
1758
|
+
};
|
|
1759
|
+
updateMultiResult(finalResult);
|
|
1760
|
+
}
|
|
1761
|
+
else {
|
|
1762
|
+
updateMultiResult(undefined);
|
|
1763
|
+
}
|
|
1764
|
+
},
|
|
1765
|
+
scopeToHunk: memoScopeSelectToHunk,
|
|
1766
|
+
};
|
|
1767
|
+
if (managerRef.current) {
|
|
1768
|
+
managerRef.current.updateContainer(container);
|
|
1769
|
+
managerRef.current.updateDiffFile(diffFile);
|
|
1770
|
+
managerRef.current.updateOptions(managerOptions);
|
|
1771
|
+
}
|
|
1772
|
+
else {
|
|
1773
|
+
managerRef.current = core.createDiffMultiSelectManager(container, diffFile, managerOptions);
|
|
1774
|
+
}
|
|
1775
|
+
return () => {
|
|
1776
|
+
var _a;
|
|
1777
|
+
(_a = managerRef.current) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
1778
|
+
managerRef.current = null;
|
|
1779
|
+
};
|
|
1780
|
+
}, [
|
|
1781
|
+
enableMultiSelect,
|
|
1782
|
+
isUnifiedMode,
|
|
1783
|
+
memoScopeSelectToHunk,
|
|
1784
|
+
memoSelectChange,
|
|
1785
|
+
memoSelectComplete,
|
|
1786
|
+
getDiffFile,
|
|
1787
|
+
updateMultiResult,
|
|
1788
|
+
]);
|
|
1789
|
+
const convertedExtendData = React.useMemo(() => {
|
|
1790
|
+
if (!extendData)
|
|
1791
|
+
return undefined;
|
|
1792
|
+
const result = {};
|
|
1793
|
+
if (extendData.oldFile) {
|
|
1794
|
+
result.oldFile = {};
|
|
1795
|
+
for (const [key, value] of Object.entries(extendData.oldFile)) {
|
|
1796
|
+
result.oldFile[key] = { data: value.data };
|
|
1797
|
+
}
|
|
1798
|
+
}
|
|
1799
|
+
if (extendData.newFile) {
|
|
1800
|
+
result.newFile = {};
|
|
1801
|
+
for (const [key, value] of Object.entries(extendData.newFile)) {
|
|
1802
|
+
result.newFile[key] = { data: value.data };
|
|
1803
|
+
}
|
|
1804
|
+
}
|
|
1805
|
+
return result;
|
|
1806
|
+
}, [extendData]);
|
|
1807
|
+
const internalRenderWidgetLine = React.useCallback(({ lineNumber, side, diffFile, onClose, }) => {
|
|
1808
|
+
var _a;
|
|
1809
|
+
if (!renderWidgetLine)
|
|
1810
|
+
return null;
|
|
1811
|
+
const sideKey = side === core.SplitSide.old ? "old" : "new";
|
|
1812
|
+
const multiResultItem = (_a = multiResultRef.current) === null || _a === void 0 ? void 0 : _a[sideKey];
|
|
1813
|
+
const fromLineNumber = multiResultItem ? Math.min(...multiResultItem) : lineNumber;
|
|
1814
|
+
const toLineNumber = multiResultItem ? Math.max(...multiResultItem) : lineNumber;
|
|
1815
|
+
return renderWidgetLine({
|
|
1816
|
+
lineNumber: toLineNumber,
|
|
1817
|
+
fromLineNumber,
|
|
1818
|
+
side,
|
|
1819
|
+
diffFile,
|
|
1820
|
+
onClose,
|
|
1821
|
+
});
|
|
1822
|
+
}, [renderWidgetLine]);
|
|
1823
|
+
const getSelectionResult = React.useCallback(() => {
|
|
1824
|
+
var _a, _b;
|
|
1825
|
+
return (_b = (_a = managerRef.current) === null || _a === void 0 ? void 0 : _a.getSelectionResult()) !== null && _b !== void 0 ? _b : null;
|
|
1826
|
+
}, []);
|
|
1827
|
+
const getSelectionState = React.useCallback(() => {
|
|
1828
|
+
var _a, _b;
|
|
1829
|
+
return ((_b = (_a = managerRef.current) === null || _a === void 0 ? void 0 : _a.getState()) !== null && _b !== void 0 ? _b : {
|
|
1830
|
+
isSelecting: false,
|
|
1831
|
+
startInfo: null,
|
|
1832
|
+
currentRange: null,
|
|
1833
|
+
});
|
|
1834
|
+
}, []);
|
|
1835
|
+
const clearSelection = React.useCallback(() => {
|
|
1836
|
+
var _a;
|
|
1837
|
+
(_a = managerRef.current) === null || _a === void 0 ? void 0 : _a.clearSelection();
|
|
1838
|
+
}, []);
|
|
1839
|
+
const setPreselectedLines = updateMultiResult;
|
|
1840
|
+
React.useImperativeHandle(ref, () => ({
|
|
1841
|
+
getDiffFileInstance: getDiffFile,
|
|
1842
|
+
getSelectionResult,
|
|
1843
|
+
getSelectionState,
|
|
1844
|
+
clearSelection,
|
|
1845
|
+
setPreselectedLines,
|
|
1846
|
+
}), [getDiffFile, getSelectionResult, getSelectionState, clearSelection, setPreselectedLines]);
|
|
1847
|
+
return (jsxRuntime.jsx("div", { ref: containerRef, className: "diff-multiselect-wrapper", children: jsxRuntime.jsx(DiffView, { ref: diffViewRef, ...restProps, diffViewMode: diffViewMode, extendData: convertedExtendData, onAddWidgetClick: (lineNum, side) => {
|
|
1848
|
+
var _a;
|
|
1849
|
+
(_a = managerRef.current) === null || _a === void 0 ? void 0 : _a.clearSelection();
|
|
1850
|
+
const multiResult = multiResultRef.current;
|
|
1851
|
+
if (multiResult) {
|
|
1852
|
+
const currentSide = core.SplitSide[side];
|
|
1853
|
+
const currentMultiResult = multiResult[currentSide];
|
|
1854
|
+
const otherSide = currentSide === "new" ? "old" : "new";
|
|
1855
|
+
const otherMultiResult = multiResult[otherSide];
|
|
1856
|
+
if (currentMultiResult === null || currentMultiResult === void 0 ? void 0 : currentMultiResult.length) {
|
|
1857
|
+
const max = Math.max(...currentMultiResult);
|
|
1858
|
+
if (max === lineNum) {
|
|
1859
|
+
const finalResult = { [currentSide]: currentMultiResult };
|
|
1860
|
+
updateMultiResult(finalResult);
|
|
1861
|
+
onAddWidgetClick === null || onAddWidgetClick === void 0 ? void 0 : onAddWidgetClick({ lineNumber: max, fromLineNumber: Math.min(...currentMultiResult), side });
|
|
1862
|
+
return;
|
|
1863
|
+
}
|
|
1864
|
+
}
|
|
1865
|
+
if (isUnifiedMode && (otherMultiResult === null || otherMultiResult === void 0 ? void 0 : otherMultiResult.length)) {
|
|
1866
|
+
const max = Math.max(...otherMultiResult);
|
|
1867
|
+
const diffFile = getDiffFile();
|
|
1868
|
+
const index = diffFile.getUnifiedLineIndexByLineNumber(lineNum, side);
|
|
1869
|
+
const unifiedItem = diffFile.getUnifiedLine(index);
|
|
1870
|
+
const otherSideLineNum = side === core.SplitSide.old ? unifiedItem.newLineNumber : unifiedItem.oldLineNumber;
|
|
1871
|
+
if (max === otherSideLineNum) {
|
|
1872
|
+
const finalResult = { [otherSide]: otherMultiResult };
|
|
1873
|
+
updateMultiResult(finalResult);
|
|
1874
|
+
onAddWidgetClick === null || onAddWidgetClick === void 0 ? void 0 : onAddWidgetClick({
|
|
1875
|
+
lineNumber: max,
|
|
1876
|
+
fromLineNumber: Math.min(...otherMultiResult),
|
|
1877
|
+
side: otherSide === "old" ? core.SplitSide.old : core.SplitSide.new,
|
|
1878
|
+
});
|
|
1879
|
+
return;
|
|
1880
|
+
}
|
|
1881
|
+
}
|
|
1882
|
+
updateMultiResult(undefined);
|
|
1883
|
+
onAddWidgetClick === null || onAddWidgetClick === void 0 ? void 0 : onAddWidgetClick({ lineNumber: lineNum, fromLineNumber: lineNum, side });
|
|
1884
|
+
}
|
|
1885
|
+
else {
|
|
1886
|
+
updateMultiResult(undefined);
|
|
1887
|
+
onAddWidgetClick === null || onAddWidgetClick === void 0 ? void 0 : onAddWidgetClick({ lineNumber: lineNum, fromLineNumber: lineNum, side });
|
|
1888
|
+
}
|
|
1889
|
+
}, renderWidgetLine: renderWidgetLine ? internalRenderWidgetLine : undefined }) }));
|
|
1890
|
+
};
|
|
1891
|
+
const DiffViewWithMultiSelect = React.forwardRef(InternalDiffViewWithMultiSelect);
|
|
1899
1892
|
|
|
1900
1893
|
Object.defineProperty(exports, "SplitSide", {
|
|
1901
1894
|
enumerable: true,
|
|
1902
1895
|
get: function () { return core.SplitSide; }
|
|
1903
1896
|
});
|
|
1904
1897
|
exports.DiffView = DiffView;
|
|
1898
|
+
exports.DiffViewWithMultiSelect = DiffViewWithMultiSelect;
|
|
1905
1899
|
exports.version = version;
|
|
1906
1900
|
Object.keys(core).forEach(function (k) {
|
|
1907
1901
|
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|