@git-diff-view/react 0.0.14 → 0.0.16
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 +241 -230
- package/dist/cjs/index.development.js.map +1 -1
- package/dist/cjs/index.production.js +241 -230
- package/dist/cjs/index.production.js.map +1 -1
- package/dist/css/diff-view.css +2 -2
- package/dist/esm/index.mjs +242 -230
- package/dist/esm/index.mjs.map +1 -1
- package/index.d.ts +469 -449
- package/package.json +7 -7
- package/readme.md +1 -1
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
var core = require('@git-diff-view/core');
|
|
4
4
|
var React = require('react');
|
|
5
|
-
var reactivityStore = require('reactivity-store');
|
|
6
5
|
var index_js = require('use-sync-external-store/shim/index.js');
|
|
7
6
|
var reactDom = require('react-dom');
|
|
7
|
+
var reactivityStore = require('reactivity-store');
|
|
8
8
|
|
|
9
9
|
function _interopNamespaceDefault(e) {
|
|
10
10
|
var n = Object.create(null);
|
|
@@ -39,7 +39,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
39
39
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
40
40
|
PERFORMANCE OF THIS SOFTWARE.
|
|
41
41
|
***************************************************************************** */
|
|
42
|
-
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
42
|
+
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
43
43
|
|
|
44
44
|
|
|
45
45
|
function __rest(s, e) {
|
|
@@ -75,6 +75,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
75
75
|
const useUnmount = (cb, deps) => {
|
|
76
76
|
const ref = React.useRef(cb);
|
|
77
77
|
ref.current = cb;
|
|
78
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
78
79
|
React.useEffect(() => ref.current, deps);
|
|
79
80
|
};
|
|
80
81
|
|
|
@@ -179,6 +180,7 @@ const DiffViewContext = React.createContext(null);
|
|
|
179
180
|
DiffViewContext.displayName = "DiffViewContext";
|
|
180
181
|
const useDiffViewContext = () => React.useContext(DiffViewContext);
|
|
181
182
|
|
|
183
|
+
// TODO
|
|
182
184
|
const useSyncHeight = ({ selector, side, enable }) => {
|
|
183
185
|
const { useDiffContext } = useDiffViewContext();
|
|
184
186
|
const id = useDiffContext(React.useCallback((s) => s.id, []));
|
|
@@ -189,6 +191,7 @@ const useSyncHeight = ({ selector, side, enable }) => {
|
|
|
189
191
|
if (elements.length === 2) {
|
|
190
192
|
const ele1 = elements[0];
|
|
191
193
|
const ele2 = elements[1];
|
|
194
|
+
const target = ele1.getAttribute("data-side") === side ? ele1 : ele2;
|
|
192
195
|
const cb = () => {
|
|
193
196
|
ele1.style.height = "auto";
|
|
194
197
|
ele2.style.height = "auto";
|
|
@@ -208,7 +211,6 @@ const useSyncHeight = ({ selector, side, enable }) => {
|
|
|
208
211
|
};
|
|
209
212
|
cb();
|
|
210
213
|
const observer = new ResizeObserver(cb);
|
|
211
|
-
const target = ele1.getAttribute("data-side") === side ? ele1 : ele2;
|
|
212
214
|
observer.observe(target);
|
|
213
215
|
target.setAttribute("data-observe", "height");
|
|
214
216
|
return () => {
|
|
@@ -262,15 +264,14 @@ const _DiffSplitExtendLine$1 = ({ index, diffFile, oldLineExtend, newLineExtend,
|
|
|
262
264
|
const renderExtendLine = useDiffContext(React__namespace.useCallback((s) => s.renderExtendLine, []));
|
|
263
265
|
const currentExtend = side === exports.SplitSide.old ? oldLineExtend : newLineExtend;
|
|
264
266
|
const currentLineNumber = side === exports.SplitSide.old ? oldLine.lineNumber : newLine.lineNumber;
|
|
265
|
-
const otherSide = side === exports.SplitSide.old ? exports.SplitSide.new : exports.SplitSide.old;
|
|
266
267
|
useSyncHeight({
|
|
267
268
|
selector: `tr[data-line="${lineNumber}-extend"]`,
|
|
268
|
-
side:
|
|
269
|
-
enable:
|
|
269
|
+
side: exports.SplitSide[side],
|
|
270
|
+
enable: !!(currentExtend === null || currentExtend === void 0 ? void 0 : currentExtend.data) && typeof renderExtendLine === "function",
|
|
270
271
|
});
|
|
271
272
|
const width = useDomWidth({
|
|
272
273
|
selector: side === exports.SplitSide.old ? ".old-diff-table-wrapper" : ".new-diff-table-wrapper",
|
|
273
|
-
enable: !!currentExtend && typeof renderExtendLine === "function",
|
|
274
|
+
enable: !!(currentExtend === null || currentExtend === void 0 ? void 0 : currentExtend.data) && typeof renderExtendLine === "function",
|
|
274
275
|
});
|
|
275
276
|
if (!renderExtendLine)
|
|
276
277
|
return null;
|
|
@@ -283,7 +284,7 @@ const _DiffSplitExtendLine$1 = ({ index, diffFile, oldLineExtend, newLineExtend,
|
|
|
283
284
|
lineNumber: currentLineNumber,
|
|
284
285
|
data: currentExtend.data,
|
|
285
286
|
onUpdate: diffFile.notifyAll,
|
|
286
|
-
}))))) : (React__namespace.createElement("td", { className: `diff-line-extend-${exports.SplitSide[side]}-placeholder p-0
|
|
287
|
+
}))))) : (React__namespace.createElement("td", { className: `diff-line-extend-${exports.SplitSide[side]}-placeholder select-none p-0`, style: { backgroundColor: `var(${emptyBGName})` }, colSpan: 2 },
|
|
287
288
|
React__namespace.createElement("span", null, "\u2002")))));
|
|
288
289
|
};
|
|
289
290
|
const DiffSplitExtendLine$1 = ({ index, diffFile, side, lineNumber, }) => {
|
|
@@ -362,7 +363,106 @@ const memoFunc = (func) => {
|
|
|
362
363
|
return result;
|
|
363
364
|
});
|
|
364
365
|
};
|
|
365
|
-
const
|
|
366
|
+
const createDiffConfigStore = (props, diffFileId) => {
|
|
367
|
+
return reactivityStore.createStore(() => {
|
|
368
|
+
var _a, _b;
|
|
369
|
+
const id = reactivityStore.ref(diffFileId);
|
|
370
|
+
const setId = (_id) => (id.value = _id);
|
|
371
|
+
const mode = reactivityStore.ref(props.diffViewMode);
|
|
372
|
+
const setMode = (_mode) => (mode.value = _mode);
|
|
373
|
+
const enableWrap = reactivityStore.ref(props.diffViewWrap);
|
|
374
|
+
const setEnableWrap = (_enableWrap) => (enableWrap.value = _enableWrap);
|
|
375
|
+
const enableAddWidget = reactivityStore.ref(props.diffViewAddWidget);
|
|
376
|
+
const setEnableAddWidget = (_enableAddWidget) => (enableAddWidget.value = _enableAddWidget);
|
|
377
|
+
const enableHighlight = reactivityStore.ref(props.diffViewHighlight);
|
|
378
|
+
const setEnableHighlight = (_enableHighlight) => (enableHighlight.value = _enableHighlight);
|
|
379
|
+
const fontSize = reactivityStore.ref(props.diffViewFontSize);
|
|
380
|
+
const setFontSize = (_fontSize) => (fontSize.value = _fontSize);
|
|
381
|
+
const extendData = reactivityStore.ref({
|
|
382
|
+
oldFile: Object.assign({}, (_a = props.extendData) === null || _a === void 0 ? void 0 : _a.oldFile),
|
|
383
|
+
newFile: Object.assign({}, (_b = props.extendData) === null || _b === void 0 ? void 0 : _b.newFile),
|
|
384
|
+
});
|
|
385
|
+
const setExtendData = (_extendData) => {
|
|
386
|
+
const existOldKeys = Object.keys(extendData.value.oldFile || {});
|
|
387
|
+
const inComingOldKeys = Object.keys(_extendData.oldFile || {});
|
|
388
|
+
for (const key of existOldKeys) {
|
|
389
|
+
if (!inComingOldKeys.includes(key)) {
|
|
390
|
+
delete extendData.value.oldFile[key];
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
for (const key of inComingOldKeys) {
|
|
394
|
+
extendData.value.oldFile[key] = _extendData.oldFile[key];
|
|
395
|
+
}
|
|
396
|
+
const existNewKeys = Object.keys(extendData.value.newFile || {});
|
|
397
|
+
const inComingNewKeys = Object.keys(_extendData.newFile || {});
|
|
398
|
+
for (const key of existNewKeys) {
|
|
399
|
+
if (!inComingNewKeys.includes(key)) {
|
|
400
|
+
delete extendData.value.newFile[key];
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
for (const key of inComingNewKeys) {
|
|
404
|
+
extendData.value.newFile[key] = _extendData.newFile[key];
|
|
405
|
+
}
|
|
406
|
+
};
|
|
407
|
+
const renderWidgetLine = reactivityStore.ref(props.renderWidgetLine);
|
|
408
|
+
const setRenderWidgetLine = (_renderWidgetLine) => (renderWidgetLine.value = _renderWidgetLine);
|
|
409
|
+
const renderExtendLine = reactivityStore.ref(props.renderExtendLine);
|
|
410
|
+
const setRenderExtendLine = (_renderExtendLine) => (renderExtendLine.value = _renderExtendLine);
|
|
411
|
+
// 避免无意义的订阅
|
|
412
|
+
const onAddWidgetClick = { current: props.onAddWidgetClick };
|
|
413
|
+
const setOnAddWidgetClick = (_onAddWidgetClick) => (onAddWidgetClick.current = _onAddWidgetClick.current);
|
|
414
|
+
return {
|
|
415
|
+
id,
|
|
416
|
+
setId,
|
|
417
|
+
mode,
|
|
418
|
+
setMode,
|
|
419
|
+
enableWrap,
|
|
420
|
+
setEnableWrap,
|
|
421
|
+
enableAddWidget,
|
|
422
|
+
setEnableAddWidget,
|
|
423
|
+
enableHighlight,
|
|
424
|
+
setEnableHighlight,
|
|
425
|
+
fontSize,
|
|
426
|
+
setFontSize,
|
|
427
|
+
extendData,
|
|
428
|
+
setExtendData,
|
|
429
|
+
renderWidgetLine,
|
|
430
|
+
setRenderWidgetLine,
|
|
431
|
+
renderExtendLine,
|
|
432
|
+
setRenderExtendLine,
|
|
433
|
+
onAddWidgetClick,
|
|
434
|
+
setOnAddWidgetClick,
|
|
435
|
+
};
|
|
436
|
+
});
|
|
437
|
+
};
|
|
438
|
+
const createDiffWidgetStore = (useDiffContextRef) => {
|
|
439
|
+
return reactivityStore.createStore(() => {
|
|
440
|
+
const widgetSide = reactivityStore.ref(undefined);
|
|
441
|
+
const widgetLineNumber = reactivityStore.ref(undefined);
|
|
442
|
+
const setWidget = ({ side, lineNumber }) => {
|
|
443
|
+
var _a, _b;
|
|
444
|
+
const { renderWidgetLine } = ((_b = (_a = useDiffContextRef.current) === null || _a === void 0 ? void 0 : _a.getReadonlyState) === null || _b === void 0 ? void 0 : _b.call(_a)) || {};
|
|
445
|
+
if (typeof renderWidgetLine !== "function")
|
|
446
|
+
return;
|
|
447
|
+
widgetSide.value = side;
|
|
448
|
+
widgetLineNumber.value = lineNumber;
|
|
449
|
+
};
|
|
450
|
+
return { widgetSide, widgetLineNumber, setWidget };
|
|
451
|
+
});
|
|
452
|
+
};
|
|
453
|
+
const createDiffSplitConfigStore = () => {
|
|
454
|
+
return reactivityStore.createStore(() => {
|
|
455
|
+
const splitRef = reactivityStore.ref(undefined);
|
|
456
|
+
const setSplit = (side) => {
|
|
457
|
+
reactDom.flushSync(() => {
|
|
458
|
+
splitRef.value = side;
|
|
459
|
+
});
|
|
460
|
+
};
|
|
461
|
+
return { splitRef, setSplit };
|
|
462
|
+
});
|
|
463
|
+
};
|
|
464
|
+
const diffAsideWidthName = "--diff-aside-width--";
|
|
465
|
+
const diffFontSizeName = "--diff-font-size--";
|
|
366
466
|
|
|
367
467
|
const _DiffSplitHunkLineGitHub = ({ index, diffFile, side, lineNumber, }) => {
|
|
368
468
|
var _a;
|
|
@@ -381,21 +481,21 @@ const _DiffSplitHunkLineGitHub = ({ index, diffFile, side, lineNumber, }) => {
|
|
|
381
481
|
const isFirstLine = currentHunk && currentHunk.isFirst;
|
|
382
482
|
const isLastLine = currentHunk && currentHunk.isLast;
|
|
383
483
|
return (React__namespace.createElement("tr", { "data-line": `${lineNumber}-hunk`, "data-state": "hunk", "data-side": exports.SplitSide[side], className: "diff-line diff-line-hunk" }, enableHunkAction ? (React__namespace.createElement(React__namespace.Fragment, null,
|
|
384
|
-
React__namespace.createElement("td", { className: "diff-line-hunk-action sticky left-0
|
|
484
|
+
React__namespace.createElement("td", { className: "diff-line-hunk-action sticky left-0 w-[1%] min-w-[40px] select-none p-[1px]", style: {
|
|
385
485
|
backgroundColor: `var(${hunkLineNumberBGName})`,
|
|
386
486
|
color: `var(${plainLineNumberColorName})`,
|
|
387
|
-
width: `var(${
|
|
388
|
-
minWidth: `var(${
|
|
389
|
-
maxWidth: `var(${
|
|
390
|
-
} }, couldExpand ? (isFirstLine ? (React__namespace.createElement("button", { className: "
|
|
391
|
-
React__namespace.createElement(ExpandUp, { className: "fill-current" }))) : isLastLine ? (React__namespace.createElement("button", { className: "
|
|
487
|
+
width: `var(${diffAsideWidthName})`,
|
|
488
|
+
minWidth: `var(${diffAsideWidthName})`,
|
|
489
|
+
maxWidth: `var(${diffAsideWidthName})`,
|
|
490
|
+
} }, couldExpand ? (isFirstLine ? (React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px] hover:bg-blue-300", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index) },
|
|
491
|
+
React__namespace.createElement(ExpandUp, { className: "fill-current" }))) : isLastLine ? (React__namespace.createElement("button", { className: "diff-widget-tooltip relative flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px] hover:bg-blue-300", title: "Expand Down", "data-title": "Expand Down", onClick: () => {
|
|
392
492
|
diffFile.onSplitHunkExpand("down", index);
|
|
393
493
|
} },
|
|
394
|
-
React__namespace.createElement(ExpandDown, { className: "fill-current" }))) : isExpandAll ? (React__namespace.createElement("button", { className: "
|
|
494
|
+
React__namespace.createElement(ExpandDown, { className: "fill-current" }))) : isExpandAll ? (React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px] hover:bg-blue-300", title: "Expand All", "data-title": "Expand All", onClick: () => diffFile.onSplitHunkExpand("all", index) },
|
|
395
495
|
React__namespace.createElement(ExpandAll, { className: "fill-current" }))) : (React__namespace.createElement(React__namespace.Fragment, null,
|
|
396
|
-
React__namespace.createElement("button", { className: "
|
|
496
|
+
React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px] hover:bg-blue-300", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onSplitHunkExpand("down", index) },
|
|
397
497
|
React__namespace.createElement(ExpandDown, { className: "fill-current" })),
|
|
398
|
-
React__namespace.createElement("button", { className: "
|
|
498
|
+
React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px] hover:bg-blue-300", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index) },
|
|
399
499
|
React__namespace.createElement(ExpandUp, { className: "fill-current" }))))) : (React__namespace.createElement("div", { className: "min-h-[28px]" }, "\u2002"))),
|
|
400
500
|
React__namespace.createElement("td", { className: "diff-line-hunk-content pr-[10px] align-middle", style: { backgroundColor: `var(${hunkContentBGName})` } },
|
|
401
501
|
React__namespace.createElement("div", { className: "pl-[1.5em]", style: {
|
|
@@ -409,8 +509,8 @@ const _DiffSplitHunkLineGitLab = ({ index, diffFile, side, lineNumber, }) => {
|
|
|
409
509
|
const expandEnabled = diffFile.getExpandEnabled();
|
|
410
510
|
useSyncHeight({
|
|
411
511
|
selector: `tr[data-line="${lineNumber}-hunk"]`,
|
|
412
|
-
side: exports.SplitSide[
|
|
413
|
-
enable:
|
|
512
|
+
side: exports.SplitSide[side],
|
|
513
|
+
enable: true,
|
|
414
514
|
});
|
|
415
515
|
const couldExpand = expandEnabled && currentHunk && currentHunk.splitInfo;
|
|
416
516
|
const isExpandAll = currentHunk &&
|
|
@@ -419,21 +519,21 @@ const _DiffSplitHunkLineGitLab = ({ index, diffFile, side, lineNumber, }) => {
|
|
|
419
519
|
const isFirstLine = currentHunk && currentHunk.isFirst;
|
|
420
520
|
const isLastLine = currentHunk && currentHunk.isLast;
|
|
421
521
|
return (React__namespace.createElement("tr", { "data-line": `${lineNumber}-hunk`, "data-state": "hunk", "data-side": exports.SplitSide[side], className: "diff-line diff-line-hunk" },
|
|
422
|
-
React__namespace.createElement("td", { className: "diff-line-hunk-action sticky left-0
|
|
522
|
+
React__namespace.createElement("td", { className: "diff-line-hunk-action sticky left-0 w-[1%] min-w-[40px] select-none p-[1px]", style: {
|
|
423
523
|
backgroundColor: `var(${hunkLineNumberBGName})`,
|
|
424
524
|
color: `var(${plainLineNumberColorName})`,
|
|
425
|
-
width: `var(${
|
|
426
|
-
minWidth: `var(${
|
|
427
|
-
maxWidth: `var(${
|
|
428
|
-
} }, couldExpand ? (isFirstLine ? (React__namespace.createElement("button", { className: "
|
|
429
|
-
React__namespace.createElement(ExpandUp, { className: "fill-current" }))) : isLastLine ? (React__namespace.createElement("button", { className: "
|
|
525
|
+
width: `var(${diffAsideWidthName})`,
|
|
526
|
+
minWidth: `var(${diffAsideWidthName})`,
|
|
527
|
+
maxWidth: `var(${diffAsideWidthName})`,
|
|
528
|
+
} }, couldExpand ? (isFirstLine ? (React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px] hover:bg-blue-300", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index) },
|
|
529
|
+
React__namespace.createElement(ExpandUp, { className: "fill-current" }))) : isLastLine ? (React__namespace.createElement("button", { className: "diff-widget-tooltip relative flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px] hover:bg-blue-300", title: "Expand Down", "data-title": "Expand Down", onClick: () => {
|
|
430
530
|
diffFile.onSplitHunkExpand("down", index);
|
|
431
531
|
} },
|
|
432
|
-
React__namespace.createElement(ExpandDown, { className: "fill-current" }))) : isExpandAll ? (React__namespace.createElement("button", { className: "
|
|
532
|
+
React__namespace.createElement(ExpandDown, { className: "fill-current" }))) : isExpandAll ? (React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px] hover:bg-blue-300", title: "Expand All", "data-title": "Expand All", onClick: () => diffFile.onSplitHunkExpand("all", index) },
|
|
433
533
|
React__namespace.createElement(ExpandAll, { className: "fill-current" }))) : (React__namespace.createElement(React__namespace.Fragment, null,
|
|
434
|
-
React__namespace.createElement("button", { className: "
|
|
534
|
+
React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px] hover:bg-blue-300", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onSplitHunkExpand("down", index) },
|
|
435
535
|
React__namespace.createElement(ExpandDown, { className: "fill-current" })),
|
|
436
|
-
React__namespace.createElement("button", { className: "
|
|
536
|
+
React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px] hover:bg-blue-300", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index) },
|
|
437
537
|
React__namespace.createElement(ExpandUp, { className: "fill-current" }))))) : (React__namespace.createElement("div", { className: "min-h-[28px]" }, "\u2002"))),
|
|
438
538
|
React__namespace.createElement("td", { className: "diff-line-hunk-content pr-[10px] align-middle", style: { backgroundColor: `var(${hunkContentBGName})` } },
|
|
439
539
|
React__namespace.createElement("div", { className: "pl-[1.5em]", style: {
|
|
@@ -464,14 +564,13 @@ const DiffSplitHunkLine$1 = ({ index, diffFile, side, lineNumber, }) => {
|
|
|
464
564
|
};
|
|
465
565
|
|
|
466
566
|
const DiffSplitAddWidget = ({ side, className, lineNumber, onWidgetClick, onOpenAddWidget, }) => {
|
|
467
|
-
return (React__namespace.createElement("div", { className: "diff-add-widget-wrapper
|
|
567
|
+
return (React__namespace.createElement("div", { className: "diff-add-widget-wrapper invisible select-none transition-transform hover:scale-110 group-hover:visible" +
|
|
568
|
+
(className ? " " + className : ""), style: {
|
|
468
569
|
width: `calc(var(${diffFontSizeName}) * 1.4)`,
|
|
469
570
|
height: `calc(var(${diffFontSizeName}) * 1.4)`,
|
|
470
571
|
} },
|
|
471
|
-
React__namespace.createElement("button", { className: "diff-add-widget
|
|
572
|
+
React__namespace.createElement("button", { className: "diff-add-widget z-[1] flex h-full w-full origin-center cursor-pointer items-center justify-center rounded-md text-[1.2em]", style: {
|
|
472
573
|
color: `var(${addWidgetColorName})`,
|
|
473
|
-
zIndex: 1,
|
|
474
|
-
fontSize: `1.2em`,
|
|
475
574
|
backgroundColor: `var(${addWidgetBGName})`,
|
|
476
575
|
}, onClick: () => {
|
|
477
576
|
onOpenAddWidget(lineNumber, side);
|
|
@@ -479,14 +578,12 @@ const DiffSplitAddWidget = ({ side, className, lineNumber, onWidgetClick, onOpen
|
|
|
479
578
|
} }, "+")));
|
|
480
579
|
};
|
|
481
580
|
const DiffUnifiedAddWidget = ({ lineNumber, side, onWidgetClick, onOpenAddWidget, }) => {
|
|
482
|
-
return (React__namespace.createElement("div", { className: "diff-add-widget-wrapper absolute left-[100%] top-[1px] translate-x-[-50%]", style: {
|
|
581
|
+
return (React__namespace.createElement("div", { className: "diff-add-widget-wrapper invisible absolute left-[100%] top-[1px] translate-x-[-50%] select-none transition-transform hover:scale-110 group-hover:visible", style: {
|
|
483
582
|
width: `calc(var(${diffFontSizeName}) * 1.4)`,
|
|
484
583
|
height: `calc(var(${diffFontSizeName}) * 1.4)`,
|
|
485
584
|
} },
|
|
486
|
-
React__namespace.createElement("button", { className: "diff-add-widget
|
|
585
|
+
React__namespace.createElement("button", { className: "diff-add-widget z-[1] flex h-full w-full origin-center cursor-pointer items-center justify-center rounded-md text-[1.2em]", style: {
|
|
487
586
|
color: `var(${addWidgetColorName})`,
|
|
488
|
-
zIndex: 1,
|
|
489
|
-
fontSize: `1.2em`,
|
|
490
587
|
backgroundColor: `var(${addWidgetBGName})`,
|
|
491
588
|
}, onClick: () => {
|
|
492
589
|
onOpenAddWidget(lineNumber, side);
|
|
@@ -525,14 +622,15 @@ const getStyleObjectFromString = memoFunc((str) => {
|
|
|
525
622
|
return style;
|
|
526
623
|
});
|
|
527
624
|
const DiffString = ({ rawLine, diffLine, operator, enableWrap, }) => {
|
|
528
|
-
const
|
|
529
|
-
if (
|
|
625
|
+
const changes = diffLine === null || diffLine === void 0 ? void 0 : diffLine.changes;
|
|
626
|
+
if (changes === null || changes === void 0 ? void 0 : changes.hasLineChange) {
|
|
627
|
+
const range = changes.range;
|
|
530
628
|
const str1 = rawLine.slice(0, range.location);
|
|
531
629
|
const str2 = rawLine.slice(range.location, range.location + range.length);
|
|
532
630
|
const str3 = rawLine.slice(range.location + range.length);
|
|
533
631
|
const isLast = str2.includes("\n");
|
|
534
632
|
const _str2 = isLast ? str2.replace("\n", "") : str2;
|
|
535
|
-
const isNewLineSymbolChanged =
|
|
633
|
+
const isNewLineSymbolChanged = changes.newLineSymbol;
|
|
536
634
|
return (React__namespace.createElement("span", { className: "diff-line-content-raw" },
|
|
537
635
|
React__namespace.createElement("span", { "data-range-start": range.location, "data-range-end": range.location + range.length },
|
|
538
636
|
str1,
|
|
@@ -548,7 +646,7 @@ const DiffString = ({ rawLine, diffLine, operator, enableWrap, }) => {
|
|
|
548
646
|
: ""}`
|
|
549
647
|
: str2),
|
|
550
648
|
str3),
|
|
551
|
-
isNewLineSymbolChanged === core.NewLineSymbol.NEWLINE &&
|
|
649
|
+
isNewLineSymbolChanged === core.NewLineSymbol.NEWLINE && (React__namespace.createElement("span", { "data-no-newline-at-end-of-file-symbol": true, className: enableWrap ? "block text-red-500" : "inline-block align-middle text-red-500", style: {
|
|
552
650
|
width: `var(${diffFontSizeName})`,
|
|
553
651
|
height: `var(${diffFontSizeName})`,
|
|
554
652
|
} },
|
|
@@ -561,9 +659,10 @@ const DiffSyntax = ({ rawLine, diffLine, operator, syntaxLine, enableWrap, }) =>
|
|
|
561
659
|
if (!syntaxLine) {
|
|
562
660
|
return React__namespace.createElement(DiffString, { rawLine: rawLine, diffLine: diffLine, operator: operator });
|
|
563
661
|
}
|
|
564
|
-
const
|
|
565
|
-
if (
|
|
566
|
-
const isNewLineSymbolChanged =
|
|
662
|
+
const changes = diffLine === null || diffLine === void 0 ? void 0 : diffLine.changes;
|
|
663
|
+
if (changes === null || changes === void 0 ? void 0 : changes.hasLineChange) {
|
|
664
|
+
const isNewLineSymbolChanged = changes.newLineSymbol;
|
|
665
|
+
const range = changes.range;
|
|
567
666
|
return (React__namespace.createElement("span", { className: "diff-line-syntax-raw" },
|
|
568
667
|
React__namespace.createElement("span", { "data-range-start": range.location, "data-range-end": range.location + range.length }, (_a = syntaxLine.nodeList) === null || _a === void 0 ? void 0 : _a.map(({ node, wrapper }, index) => {
|
|
569
668
|
var _a, _b, _c, _d, _e, _f;
|
|
@@ -600,7 +699,7 @@ const DiffSyntax = ({ rawLine, diffLine, operator, syntaxLine, enableWrap, }) =>
|
|
|
600
699
|
str3));
|
|
601
700
|
}
|
|
602
701
|
})),
|
|
603
|
-
isNewLineSymbolChanged === core.NewLineSymbol.NEWLINE &&
|
|
702
|
+
isNewLineSymbolChanged === core.NewLineSymbol.NEWLINE && (React__namespace.createElement("span", { "data-no-newline-at-end-of-file-symbol": true, className: enableWrap ? "block text-red-500" : "inline-block align-middle text-red-500", style: {
|
|
604
703
|
width: `var(${diffFontSizeName})`,
|
|
605
704
|
height: `var(${diffFontSizeName})`,
|
|
606
705
|
} },
|
|
@@ -620,7 +719,7 @@ const DiffContent = ({ diffLine, rawLine, syntaxLine, enableWrap, enableHighligh
|
|
|
620
719
|
whiteSpace: enableWrap ? "pre-wrap" : "pre",
|
|
621
720
|
wordBreak: enableWrap ? "break-all" : "initial",
|
|
622
721
|
} },
|
|
623
|
-
React__namespace.createElement("span", { "data-operator": isAdded ? "+" : isDelete ? "-" : undefined, className: "diff-line-content-operator
|
|
722
|
+
React__namespace.createElement("span", { "data-operator": isAdded ? "+" : isDelete ? "-" : undefined, className: "diff-line-content-operator ml-[-1.5em] inline-block w-[1.5em] select-none indent-[0.2em]" }, isAdded ? "+" : isDelete ? "-" : " "),
|
|
624
723
|
enableHighlight && syntaxLine && !isMaxLineLengthToIgnoreSyntax ? (React__namespace.createElement(DiffSyntax, { operator: isAdded ? "add" : isDelete ? "del" : undefined, rawLine: rawLine, diffLine: diffLine, syntaxLine: syntaxLine, enableWrap: enableWrap })) : (React__namespace.createElement(DiffString, { operator: isAdded ? "add" : isDelete ? "del" : undefined, rawLine: rawLine, diffLine: diffLine, enableWrap: enableWrap }))));
|
|
625
724
|
};
|
|
626
725
|
|
|
@@ -651,14 +750,14 @@ const _DiffSplitLine$1 = ({ index, diffFile, lineNumber, side, }) => {
|
|
|
651
750
|
const lineNumberBG = getLineNumberBG(isAdded, isDelete, hasDiff);
|
|
652
751
|
const syntaxLine = getCurrentSyntaxLine(currentLine.lineNumber);
|
|
653
752
|
return (React__namespace.createElement("tr", { "data-line": lineNumber, "data-state": hasDiff || !hasContent ? "diff" : "plain", "data-side": exports.SplitSide[side], className: "diff-line" + (hasContent ? " group" : "") }, hasContent ? (React__namespace.createElement(React__namespace.Fragment, null,
|
|
654
|
-
React__namespace.createElement("td", { className: `diff-line-${exports.SplitSide[side]}-num sticky left-0 pl-[10px] pr-[10px] text-right align-top
|
|
753
|
+
React__namespace.createElement("td", { className: `diff-line-${exports.SplitSide[side]}-num sticky left-0 w-[1%] min-w-[40px] select-none pl-[10px] pr-[10px] text-right align-top`, style: {
|
|
655
754
|
backgroundColor: lineNumberBG,
|
|
656
755
|
color: `var(${plainLineNumberColorName})`,
|
|
657
|
-
width: `var(${
|
|
658
|
-
minWidth: `var(${
|
|
659
|
-
maxWidth: `var(${
|
|
756
|
+
width: `var(${diffAsideWidthName})`,
|
|
757
|
+
minWidth: `var(${diffAsideWidthName})`,
|
|
758
|
+
maxWidth: `var(${diffAsideWidthName})`,
|
|
660
759
|
} },
|
|
661
|
-
hasDiff && enableAddWidget && (React__namespace.createElement(DiffSplitAddWidget, { index: index, lineNumber: currentLine.lineNumber, side: side, diffFile: diffFile, onWidgetClick: (...props) => { var _a; return (_a = onAddWidgetClick.current) === null || _a === void 0 ? void 0 : _a.call(onAddWidgetClick, ...props); }, className: "absolute left-[100%] translate-x-[-50%]
|
|
760
|
+
hasDiff && enableAddWidget && (React__namespace.createElement(DiffSplitAddWidget, { index: index, lineNumber: currentLine.lineNumber, side: side, diffFile: diffFile, onWidgetClick: (...props) => { var _a; return (_a = onAddWidgetClick.current) === null || _a === void 0 ? void 0 : _a.call(onAddWidgetClick, ...props); }, className: "absolute left-[100%] z-[1] translate-x-[-50%]", onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber: lineNumber, side: side }) })),
|
|
662
761
|
React__namespace.createElement("span", { "data-line-num": currentLine.lineNumber, style: { opacity: hasChange ? undefined : 0.5 } }, currentLine.lineNumber)),
|
|
663
762
|
React__namespace.createElement("td", { className: `diff-line-${exports.SplitSide[side]}-content pr-[10px] align-top`, style: { backgroundColor: contentBG } },
|
|
664
763
|
React__namespace.createElement(DiffContent, { enableWrap: false, diffFile: diffFile, rawLine: currentLine.value, diffLine: currentLine.diff, syntaxLine: syntaxLine, enableHighlight: enableHighlight })))) : (React__namespace.createElement("td", { className: `diff-line-${exports.SplitSide[side]}-placeholder select-none`, style: { backgroundColor: `var(${emptyBGName})` }, colSpan: 2 },
|
|
@@ -673,13 +772,12 @@ const DiffSplitLine$1 = ({ index, diffFile, lineNumber, side, }) => {
|
|
|
673
772
|
};
|
|
674
773
|
|
|
675
774
|
const _DiffSplitWidgetLine$1 = ({ diffFile, side, lineNumber, currentLine, setWidget, currentWidget, }) => {
|
|
676
|
-
const otherSide = side === exports.SplitSide.old ? exports.SplitSide.new : exports.SplitSide.old;
|
|
677
775
|
const { useDiffContext } = useDiffViewContext();
|
|
678
776
|
const renderWidgetLine = useDiffContext(React__namespace.useCallback((s) => s.renderWidgetLine, []));
|
|
679
777
|
useSyncHeight({
|
|
680
778
|
selector: `tr[data-line="${lineNumber}-widget"]`,
|
|
681
|
-
side:
|
|
682
|
-
enable:
|
|
779
|
+
side: exports.SplitSide[side],
|
|
780
|
+
enable: currentWidget && typeof renderWidgetLine === "function",
|
|
683
781
|
});
|
|
684
782
|
const width = useDomWidth({
|
|
685
783
|
selector: side === exports.SplitSide.old ? ".old-diff-table-wrapper" : ".new-diff-table-wrapper",
|
|
@@ -724,7 +822,7 @@ const onMouseDown$1 = (e) => {
|
|
|
724
822
|
const DiffSplitViewTable = ({ side, diffFile }) => {
|
|
725
823
|
const className = side === exports.SplitSide.new ? "new-diff-table" : "old-diff-table";
|
|
726
824
|
const lines = core.getSplitContentLines(diffFile);
|
|
727
|
-
return (React__namespace.createElement("table", { className: className + " border-collapse
|
|
825
|
+
return (React__namespace.createElement("table", { className: className + " w-full border-collapse", "data-mode": exports.SplitSide[side] },
|
|
728
826
|
React__namespace.createElement("colgroup", null,
|
|
729
827
|
React__namespace.createElement("col", { className: `diff-table-${exports.SplitSide[side]}-num-col` }),
|
|
730
828
|
React__namespace.createElement("col", { className: `diff-table-${exports.SplitSide[side]}-content-col` })),
|
|
@@ -764,19 +862,19 @@ const DiffSplitViewNormal = React.memo(({ diffFile }) => {
|
|
|
764
862
|
font,
|
|
765
863
|
});
|
|
766
864
|
const width = Math.max(40, _width + 25);
|
|
767
|
-
return (React__namespace.createElement("div", { className: "split-diff-view split-diff-view-wrap w-full
|
|
768
|
-
React__namespace.createElement("div", { className: "old-diff-table-wrapper overflow-x-auto overflow-y-hidden
|
|
865
|
+
return (React__namespace.createElement("div", { className: "split-diff-view split-diff-view-wrap flex w-full basis-[50%]" },
|
|
866
|
+
React__namespace.createElement("div", { className: "old-diff-table-wrapper scrollbar-hide scrollbar-disable w-full overflow-x-auto overflow-y-hidden", ref: ref1, style: {
|
|
769
867
|
// @ts-ignore
|
|
770
|
-
[
|
|
868
|
+
[diffAsideWidthName]: `${Math.round(width)}px`,
|
|
771
869
|
overscrollBehaviorX: "none",
|
|
772
870
|
fontFamily: "Menlo, Consolas, monospace",
|
|
773
871
|
fontSize: `var(${diffFontSizeName})`,
|
|
774
872
|
} },
|
|
775
873
|
React__namespace.createElement(DiffSplitViewTable, { side: exports.SplitSide.old, diffFile: diffFile })),
|
|
776
874
|
React__namespace.createElement("div", { className: "diff-split-line w-[1.5px] bg-[rgb(222,222,222)]" }),
|
|
777
|
-
React__namespace.createElement("div", { className: "new-diff-table-wrapper overflow-x-auto overflow-y-hidden
|
|
875
|
+
React__namespace.createElement("div", { className: "new-diff-table-wrapper scrollbar-hide scrollbar-disable w-full overflow-x-auto overflow-y-hidden", ref: ref2, style: {
|
|
778
876
|
// @ts-ignore
|
|
779
|
-
[
|
|
877
|
+
[diffAsideWidthName]: `${Math.round(width)}px`,
|
|
780
878
|
overscrollBehaviorX: "none",
|
|
781
879
|
fontFamily: "Menlo, Consolas, monospace",
|
|
782
880
|
fontSize: `var(${diffFontSizeName})`,
|
|
@@ -802,9 +900,9 @@ const _DiffSplitExtendLine = ({ index, diffFile, lineNumber, oldLineExtend, newL
|
|
|
802
900
|
lineNumber: oldLine.lineNumber,
|
|
803
901
|
data: oldLineExtend.data,
|
|
804
902
|
onUpdate: diffFile.notifyAll,
|
|
805
|
-
}))))) : (React__namespace.createElement("td", { className: "diff-line-extend-old-placeholder p-0
|
|
903
|
+
}))))) : (React__namespace.createElement("td", { className: "diff-line-extend-old-placeholder select-none p-0", style: { backgroundColor: `var(${emptyBGName})` }, colSpan: 2 },
|
|
806
904
|
React__namespace.createElement("span", null, "\u2002"))),
|
|
807
|
-
newLineExtend ? (React__namespace.createElement("td", { className: "diff-line-extend-new-content
|
|
905
|
+
newLineExtend ? (React__namespace.createElement("td", { className: "diff-line-extend-new-content border-l-[1px] border-l-[rgb(222,222,222)] p-0", colSpan: 2 },
|
|
808
906
|
React__namespace.createElement("div", { className: "diff-line-extend-wrapper" }, (newLineExtend === null || newLineExtend === void 0 ? void 0 : newLineExtend.data) &&
|
|
809
907
|
(renderExtendLine === null || renderExtendLine === void 0 ? void 0 : renderExtendLine({
|
|
810
908
|
diffFile,
|
|
@@ -812,7 +910,7 @@ const _DiffSplitExtendLine = ({ index, diffFile, lineNumber, oldLineExtend, newL
|
|
|
812
910
|
lineNumber: newLine.lineNumber,
|
|
813
911
|
data: newLineExtend.data,
|
|
814
912
|
onUpdate: diffFile.notifyAll,
|
|
815
|
-
}))))) : (React__namespace.createElement("td", { className: "diff-line-extend-new-placeholder
|
|
913
|
+
}))))) : (React__namespace.createElement("td", { className: "diff-line-extend-new-placeholder select-none border-l-[1px] border-l-[rgb(222,222,222)] p-0", style: { backgroundColor: `var(${emptyBGName})` }, colSpan: 2 },
|
|
816
914
|
React__namespace.createElement("span", null, "\u2002")))));
|
|
817
915
|
};
|
|
818
916
|
const DiffSplitExtendLine = ({ index, diffFile, lineNumber, }) => {
|
|
@@ -852,16 +950,16 @@ const DiffSplitHunkLineGitHub = ({ index, diffFile, lineNumber, }) => {
|
|
|
852
950
|
if (!currentIsShow && !currentIsPureHunk)
|
|
853
951
|
return null;
|
|
854
952
|
return (React__namespace.createElement("tr", { "data-line": `${lineNumber}-hunk`, "data-state": "hunk", className: "diff-line diff-line-hunk" },
|
|
855
|
-
React__namespace.createElement("td", { className: "diff-line-hunk-action
|
|
953
|
+
React__namespace.createElement("td", { className: "diff-line-hunk-action relative w-[1%] min-w-[40px] select-none p-[1px]", style: {
|
|
856
954
|
backgroundColor: `var(${hunkLineNumberBGName})`,
|
|
857
955
|
color: `var(${plainLineNumberColorName})`,
|
|
858
|
-
} }, couldExpand ? (isFirstLine ? (React__namespace.createElement("button", { className: "
|
|
859
|
-
React__namespace.createElement(ExpandUp, { className: "fill-current" }))) : isLastLine ? (React__namespace.createElement("button", { className: "
|
|
860
|
-
React__namespace.createElement(ExpandDown, { className: "fill-current" }))) : isExpandAll ? (React__namespace.createElement("button", { className: "
|
|
956
|
+
} }, couldExpand ? (isFirstLine ? (React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px] hover:bg-blue-300", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index) },
|
|
957
|
+
React__namespace.createElement(ExpandUp, { className: "fill-current" }))) : isLastLine ? (React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px] hover:bg-blue-300", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onSplitHunkExpand("down", index) },
|
|
958
|
+
React__namespace.createElement(ExpandDown, { className: "fill-current" }))) : isExpandAll ? (React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px] hover:bg-blue-300", title: "Expand All", "data-title": "Expand All", onClick: () => diffFile.onSplitHunkExpand("all", index) },
|
|
861
959
|
React__namespace.createElement(ExpandAll, { className: "fill-current" }))) : (React__namespace.createElement(React__namespace.Fragment, null,
|
|
862
|
-
React__namespace.createElement("button", { className: "
|
|
960
|
+
React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px] hover:bg-blue-300", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onSplitHunkExpand("down", index) },
|
|
863
961
|
React__namespace.createElement(ExpandDown, { className: "fill-current" })),
|
|
864
|
-
React__namespace.createElement("button", { className: "
|
|
962
|
+
React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px] hover:bg-blue-300", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index) },
|
|
865
963
|
React__namespace.createElement(ExpandUp, { className: "fill-current" }))))) : (React__namespace.createElement("div", { className: "min-h-[28px]" }, "\u2002"))),
|
|
866
964
|
React__namespace.createElement("td", { className: "diff-line-hunk-content pr-[10px] align-middle", style: { backgroundColor: `var(${hunkContentBGName})` }, colSpan: 3 },
|
|
867
965
|
React__namespace.createElement("div", { className: "pl-[1.5em]", style: {
|
|
@@ -885,31 +983,31 @@ const DiffSplitHunkLineGitLab = ({ index, diffFile, lineNumber, }) => {
|
|
|
885
983
|
if (!currentIsShow && !currentIsPureHunk)
|
|
886
984
|
return null;
|
|
887
985
|
return (React__namespace.createElement("tr", { "data-line": `${lineNumber}-hunk`, "data-state": "hunk", className: "diff-line diff-line-hunk" },
|
|
888
|
-
React__namespace.createElement("td", { className: "diff-line-hunk-action
|
|
986
|
+
React__namespace.createElement("td", { className: "diff-line-hunk-action relative w-[1%] min-w-[40px] select-none p-[1px]", style: {
|
|
889
987
|
backgroundColor: `var(${hunkLineNumberBGName})`,
|
|
890
988
|
color: `var(${plainLineNumberColorName})`,
|
|
891
|
-
} }, couldExpand ? (isFirstLine ? (React__namespace.createElement("button", { className: "
|
|
892
|
-
React__namespace.createElement(ExpandUp, { className: "fill-current" }))) : isLastLine ? (React__namespace.createElement("button", { className: "
|
|
893
|
-
React__namespace.createElement(ExpandDown, { className: "fill-current" }))) : isExpandAll ? (React__namespace.createElement("button", { className: "
|
|
989
|
+
} }, couldExpand ? (isFirstLine ? (React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px] hover:bg-blue-300", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index) },
|
|
990
|
+
React__namespace.createElement(ExpandUp, { className: "fill-current" }))) : isLastLine ? (React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px] hover:bg-blue-300", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onSplitHunkExpand("down", index) },
|
|
991
|
+
React__namespace.createElement(ExpandDown, { className: "fill-current" }))) : isExpandAll ? (React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px] hover:bg-blue-300", title: "Expand All", "data-title": "Expand All", onClick: () => diffFile.onSplitHunkExpand("all", index) },
|
|
894
992
|
React__namespace.createElement(ExpandAll, { className: "fill-current" }))) : (React__namespace.createElement(React__namespace.Fragment, null,
|
|
895
|
-
React__namespace.createElement("button", { className: "
|
|
993
|
+
React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px] hover:bg-blue-300", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onSplitHunkExpand("down", index) },
|
|
896
994
|
React__namespace.createElement(ExpandDown, { className: "fill-current" })),
|
|
897
|
-
React__namespace.createElement("button", { className: "
|
|
995
|
+
React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px] hover:bg-blue-300", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index) },
|
|
898
996
|
React__namespace.createElement(ExpandUp, { className: "fill-current" }))))) : (React__namespace.createElement("div", { className: "min-h-[28px]" }, "\u2002"))),
|
|
899
997
|
React__namespace.createElement("td", { className: "diff-line-hunk-content pr-[10px] align-middle", style: { backgroundColor: `var(${hunkContentBGName})` } },
|
|
900
998
|
React__namespace.createElement("div", { className: "pl-[1.5em]", style: {
|
|
901
999
|
color: `var(${hunkContentColorName})`,
|
|
902
1000
|
} }, ((_a = currentHunk.splitInfo) === null || _a === void 0 ? void 0 : _a.plainText) || currentHunk.text)),
|
|
903
|
-
React__namespace.createElement("td", { className: "diff-line-hunk-action
|
|
1001
|
+
React__namespace.createElement("td", { className: "diff-line-hunk-action relative w-[1%] min-w-[40px] select-none border-l-[1px] border-l-[rgb(222,222,222)] p-[1px]", style: {
|
|
904
1002
|
backgroundColor: `var(${hunkLineNumberBGName})`,
|
|
905
1003
|
color: `var(${plainLineNumberColorName})`,
|
|
906
|
-
} }, couldExpand ? (isFirstLine ? (React__namespace.createElement("button", { className: "
|
|
907
|
-
React__namespace.createElement(ExpandUp, { className: "fill-current" }))) : isLastLine ? (React__namespace.createElement("button", { className: "
|
|
908
|
-
React__namespace.createElement(ExpandDown, { className: "fill-current" }))) : isExpandAll ? (React__namespace.createElement("button", { className: "
|
|
1004
|
+
} }, couldExpand ? (isFirstLine ? (React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px] hover:bg-blue-300", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index) },
|
|
1005
|
+
React__namespace.createElement(ExpandUp, { className: "fill-current" }))) : isLastLine ? (React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px] hover:bg-blue-300", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onSplitHunkExpand("down", index) },
|
|
1006
|
+
React__namespace.createElement(ExpandDown, { className: "fill-current" }))) : isExpandAll ? (React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px] hover:bg-blue-300", title: "Expand All", "data-title": "Expand All", onClick: () => diffFile.onSplitHunkExpand("all", index) },
|
|
909
1007
|
React__namespace.createElement(ExpandAll, { className: "fill-current" }))) : (React__namespace.createElement(React__namespace.Fragment, null,
|
|
910
|
-
React__namespace.createElement("button", { className: "
|
|
1008
|
+
React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px] hover:bg-blue-300", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onSplitHunkExpand("down", index) },
|
|
911
1009
|
React__namespace.createElement(ExpandDown, { className: "fill-current" })),
|
|
912
|
-
React__namespace.createElement("button", { className: "
|
|
1010
|
+
React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px] hover:bg-blue-300", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index) },
|
|
913
1011
|
React__namespace.createElement(ExpandUp, { className: "fill-current" }))))) : (React__namespace.createElement("div", { className: "min-h-[28px]" }, "\u2002"))),
|
|
914
1012
|
React__namespace.createElement("td", { className: "diff-line-hunk-content pr-[10px] align-middle", style: { backgroundColor: `var(${hunkContentBGName})` } },
|
|
915
1013
|
React__namespace.createElement("div", { className: "pl-[1.5em]", style: {
|
|
@@ -955,19 +1053,19 @@ const _DiffSplitLine = ({ index, diffFile, lineNumber }) => {
|
|
|
955
1053
|
const newLineNumberBG = getLineNumberBG(newLineIsAdded, false, hasDiff);
|
|
956
1054
|
return (React__namespace.createElement("tr", { "data-line": lineNumber, "data-state": hasDiff ? "diff" : "plain", className: "diff-line" },
|
|
957
1055
|
hasOldLine ? (React__namespace.createElement(React__namespace.Fragment, null,
|
|
958
|
-
React__namespace.createElement("td", { className: "diff-line-old-num group relative pl-[10px] pr-[10px] text-right align-top
|
|
959
|
-
hasDiff && enableAddWidget && (React__namespace.createElement(DiffSplitAddWidget, { index: index, lineNumber: oldLine.lineNumber, side: exports.SplitSide.old, diffFile: diffFile, onWidgetClick: (...props) => { var _a; return (_a = onAddWidgetClick.current) === null || _a === void 0 ? void 0 : _a.call(onAddWidgetClick, ...props); }, className: "absolute left-[100%] translate-x-[-50%]
|
|
1056
|
+
React__namespace.createElement("td", { className: "diff-line-old-num group relative w-[1%] min-w-[40px] select-none pl-[10px] pr-[10px] text-right align-top", "data-side": exports.SplitSide[exports.SplitSide.old], style: { backgroundColor: oldLineNumberBG, color: `var(${plainLineNumberColorName})` } },
|
|
1057
|
+
hasDiff && enableAddWidget && (React__namespace.createElement(DiffSplitAddWidget, { index: index, lineNumber: oldLine.lineNumber, side: exports.SplitSide.old, diffFile: diffFile, onWidgetClick: (...props) => { var _a; return (_a = onAddWidgetClick.current) === null || _a === void 0 ? void 0 : _a.call(onAddWidgetClick, ...props); }, className: "absolute left-[100%] z-[1] translate-x-[-50%]", onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber: lineNumber, side: side }) })),
|
|
960
1058
|
React__namespace.createElement("span", { "data-line-num": oldLine.lineNumber, style: { opacity: hasChange ? undefined : 0.5 } }, oldLine.lineNumber)),
|
|
961
1059
|
React__namespace.createElement("td", { className: "diff-line-old-content group relative pr-[10px] align-top", "data-side": exports.SplitSide[exports.SplitSide.old], style: { backgroundColor: oldLineContentBG } },
|
|
962
|
-
hasDiff && enableAddWidget && (React__namespace.createElement(DiffSplitAddWidget, { index: index, lineNumber: oldLine.lineNumber, side: exports.SplitSide.old, diffFile: diffFile, onWidgetClick: (...props) => { var _a; return (_a = onAddWidgetClick.current) === null || _a === void 0 ? void 0 : _a.call(onAddWidgetClick, ...props); }, className: "absolute right-[100%] translate-x-[50%]
|
|
1060
|
+
hasDiff && enableAddWidget && (React__namespace.createElement(DiffSplitAddWidget, { index: index, lineNumber: oldLine.lineNumber, side: exports.SplitSide.old, diffFile: diffFile, onWidgetClick: (...props) => { var _a; return (_a = onAddWidgetClick.current) === null || _a === void 0 ? void 0 : _a.call(onAddWidgetClick, ...props); }, className: "absolute right-[100%] z-[1] translate-x-[50%]", onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber: lineNumber, side: side }) })),
|
|
963
1061
|
React__namespace.createElement(DiffContent, { enableWrap: true, diffFile: diffFile, rawLine: oldLine.value, diffLine: oldLine.diff, syntaxLine: oldSyntaxLine, enableHighlight: enableHighlight })))) : (React__namespace.createElement("td", { className: "diff-line-old-placeholder select-none", "data-side": exports.SplitSide[exports.SplitSide.old], style: { backgroundColor: `var(${emptyBGName})` }, colSpan: 2 },
|
|
964
1062
|
React__namespace.createElement("span", null, "\u2002"))),
|
|
965
1063
|
hasNewLine ? (React__namespace.createElement(React__namespace.Fragment, null,
|
|
966
|
-
React__namespace.createElement("td", { className: "diff-line-new-num group relative
|
|
967
|
-
hasDiff && enableAddWidget && (React__namespace.createElement(DiffSplitAddWidget, { index: index, lineNumber: newLine.lineNumber, side: exports.SplitSide.new, diffFile: diffFile, onWidgetClick: (...props) => { var _a; return (_a = onAddWidgetClick.current) === null || _a === void 0 ? void 0 : _a.call(onAddWidgetClick, ...props); }, className: "absolute left-[100%] translate-x-[-50%]
|
|
1064
|
+
React__namespace.createElement("td", { className: "diff-line-new-num group relative w-[1%] min-w-[40px] select-none border-l-[1px] border-l-[rgb(222,222,222)] pl-[10px] pr-[10px] text-right align-top", "data-side": exports.SplitSide[exports.SplitSide.new], style: { backgroundColor: newLineNumberBG, color: `var(${plainLineNumberColorName})` } },
|
|
1065
|
+
hasDiff && enableAddWidget && (React__namespace.createElement(DiffSplitAddWidget, { index: index, lineNumber: newLine.lineNumber, side: exports.SplitSide.new, diffFile: diffFile, onWidgetClick: (...props) => { var _a; return (_a = onAddWidgetClick.current) === null || _a === void 0 ? void 0 : _a.call(onAddWidgetClick, ...props); }, className: "absolute left-[100%] z-[1] translate-x-[-50%]", onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber: lineNumber, side: side }) })),
|
|
968
1066
|
React__namespace.createElement("span", { "data-line-num": newLine.lineNumber, style: { opacity: hasChange ? undefined : 0.5 } }, newLine.lineNumber)),
|
|
969
1067
|
React__namespace.createElement("td", { className: "diff-line-new-content group relative pr-[10px] align-top", "data-side": exports.SplitSide[exports.SplitSide.new], style: { backgroundColor: newLineContentBG } },
|
|
970
|
-
hasDiff && enableAddWidget && (React__namespace.createElement(DiffSplitAddWidget, { index: index, lineNumber: newLine.lineNumber, side: exports.SplitSide.new, diffFile: diffFile, onWidgetClick: (...props) => { var _a; return (_a = onAddWidgetClick.current) === null || _a === void 0 ? void 0 : _a.call(onAddWidgetClick, ...props); }, className: "absolute right-[100%] translate-x-[50%]
|
|
1068
|
+
hasDiff && enableAddWidget && (React__namespace.createElement(DiffSplitAddWidget, { index: index, lineNumber: newLine.lineNumber, side: exports.SplitSide.new, diffFile: diffFile, onWidgetClick: (...props) => { var _a; return (_a = onAddWidgetClick.current) === null || _a === void 0 ? void 0 : _a.call(onAddWidgetClick, ...props); }, className: "absolute right-[100%] z-[1] translate-x-[50%]", onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber: lineNumber, side: side }) })),
|
|
971
1069
|
React__namespace.createElement(DiffContent, { enableWrap: true, diffFile: diffFile, rawLine: newLine.value || "", diffLine: newLine.diff, syntaxLine: newSyntaxLine, enableHighlight: enableHighlight })))) : (React__namespace.createElement("td", { className: "diff-line-new-placeholder select-none border-l-[1px] border-l-[rgb(222,222,222)]", style: { backgroundColor: `var(${emptyBGName})` }, "data-side": exports.SplitSide[exports.SplitSide.new], colSpan: 2 },
|
|
972
1070
|
React__namespace.createElement("span", null, "\u2002")))));
|
|
973
1071
|
};
|
|
@@ -995,15 +1093,15 @@ const _DiffSplitWidgetLine = ({ index, diffFile, lineNumber, oldLineWidget, newL
|
|
|
995
1093
|
side: exports.SplitSide.old,
|
|
996
1094
|
lineNumber: oldLine.lineNumber,
|
|
997
1095
|
onClose: () => setWidget({}),
|
|
998
|
-
})))) : (React__namespace.createElement("td", { className: "diff-line-widget-old-placeholder p-0
|
|
1096
|
+
})))) : (React__namespace.createElement("td", { className: "diff-line-widget-old-placeholder select-none p-0", style: { backgroundColor: `var(${emptyBGName})` }, colSpan: 2 },
|
|
999
1097
|
React__namespace.createElement("span", null, "\u2002"))),
|
|
1000
|
-
newLineWidget ? (React__namespace.createElement("td", { className: "diff-line-widget-new-content
|
|
1098
|
+
newLineWidget ? (React__namespace.createElement("td", { className: "diff-line-widget-new-content border-l-[1px] border-l-[rgb(222,222,222)] p-0", colSpan: 2 },
|
|
1001
1099
|
React__namespace.createElement("div", { className: "diff-line-widget-wrapper" }, renderWidgetLine === null || renderWidgetLine === void 0 ? void 0 : renderWidgetLine({
|
|
1002
1100
|
diffFile,
|
|
1003
1101
|
side: exports.SplitSide.new,
|
|
1004
1102
|
lineNumber: newLine.lineNumber,
|
|
1005
1103
|
onClose: () => setWidget({}),
|
|
1006
|
-
})))) : (React__namespace.createElement("td", { className: "diff-line-widget-new-placeholder
|
|
1104
|
+
})))) : (React__namespace.createElement("td", { className: "diff-line-widget-new-placeholder select-none border-l-[1px] border-l-[rgb(222,222,222)] p-0", style: { backgroundColor: `var(${emptyBGName})` }, colSpan: 2 },
|
|
1007
1105
|
React__namespace.createElement("span", null, "\u2002")))));
|
|
1008
1106
|
};
|
|
1009
1107
|
const DiffSplitWidgetLine = ({ index, diffFile, lineNumber, }) => {
|
|
@@ -1019,6 +1117,7 @@ const DiffSplitWidgetLine = ({ index, diffFile, lineNumber, }) => {
|
|
|
1019
1117
|
return (React__namespace.createElement(_DiffSplitWidgetLine, { index: index, diffFile: diffFile, lineNumber: lineNumber, oldLineWidget: oldLineWidget, newLineWidget: newLineWidget }));
|
|
1020
1118
|
};
|
|
1021
1119
|
|
|
1120
|
+
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
1022
1121
|
const Style = ({ useSelector, id, }) => {
|
|
1023
1122
|
const splitRef = useSelector((s) => s.splitRef);
|
|
1024
1123
|
return (React__namespace.createElement("style", { "data-select-style": true }, splitRef === exports.SplitSide.old
|
|
@@ -1030,20 +1129,12 @@ const Style = ({ useSelector, id, }) => {
|
|
|
1030
1129
|
const DiffSplitViewWrap = React.memo(({ diffFile }) => {
|
|
1031
1130
|
const splitLineLength = Math.max(diffFile.splitLineLength, diffFile.fileLineLength);
|
|
1032
1131
|
const { useDiffContext } = useDiffViewContext();
|
|
1033
|
-
const
|
|
1034
|
-
const splitRef = reactivityStore.ref(undefined);
|
|
1035
|
-
const setSplit = (side) => {
|
|
1036
|
-
reactDom.flushSync(() => {
|
|
1037
|
-
splitRef.value = side;
|
|
1038
|
-
});
|
|
1039
|
-
};
|
|
1040
|
-
return { splitRef, setSplit };
|
|
1041
|
-
}), []);
|
|
1042
|
-
const setSelectSide = splitSideInfo.getReadonlyState().setSplit;
|
|
1132
|
+
const useSplitConfig = React.useMemo(() => createDiffSplitConfigStore(), []);
|
|
1043
1133
|
const fontSize = useDiffContext(React.useCallback((s) => s.fontSize, []));
|
|
1044
1134
|
index_js.useSyncExternalStore(diffFile.subscribe, diffFile.getUpdateCount);
|
|
1045
1135
|
const onMouseDown = React.useCallback((e) => {
|
|
1046
1136
|
let ele = e.target;
|
|
1137
|
+
const setSelectSide = useSplitConfig.getReadonlyState().setSplit;
|
|
1047
1138
|
// need remove all the selection
|
|
1048
1139
|
if (ele && ele instanceof HTMLElement && ele.nodeName === "BUTTON") {
|
|
1049
1140
|
removeAllSelection();
|
|
@@ -1059,7 +1150,8 @@ const DiffSplitViewWrap = React.memo(({ diffFile }) => {
|
|
|
1059
1150
|
removeAllSelection();
|
|
1060
1151
|
}
|
|
1061
1152
|
}
|
|
1062
|
-
|
|
1153
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1154
|
+
}, []);
|
|
1063
1155
|
const font = React.useMemo(() => ({ fontSize: fontSize + "px", fontFamily: "Menlo, Consolas, monospace" }), [fontSize]);
|
|
1064
1156
|
const _width = useTextWidth({
|
|
1065
1157
|
text: splitLineLength.toString(),
|
|
@@ -1069,11 +1161,13 @@ const DiffSplitViewWrap = React.memo(({ diffFile }) => {
|
|
|
1069
1161
|
const lines = core.getSplitContentLines(diffFile);
|
|
1070
1162
|
return (React__namespace.createElement("div", { className: "split-diff-view split-diff-view-normal w-full" },
|
|
1071
1163
|
React__namespace.createElement("div", { className: "diff-table-wrapper w-full", style: {
|
|
1164
|
+
// @ts-ignore
|
|
1165
|
+
[diffAsideWidthName]: `${Math.round(width)}px`,
|
|
1072
1166
|
fontFamily: "Menlo, Consolas, monospace",
|
|
1073
1167
|
fontSize: `var(${diffFontSizeName})`,
|
|
1074
1168
|
} },
|
|
1075
|
-
React__namespace.createElement(Style, { useSelector:
|
|
1076
|
-
React__namespace.createElement("table", { className: "diff-table
|
|
1169
|
+
React__namespace.createElement(Style, { useSelector: useSplitConfig, id: `diff-root${diffFile.getId()}` }),
|
|
1170
|
+
React__namespace.createElement("table", { className: "diff-table w-full table-fixed border-collapse" },
|
|
1077
1171
|
React__namespace.createElement("colgroup", null,
|
|
1078
1172
|
React__namespace.createElement("col", { className: "diff-table-old-num-col", width: Math.round(width) }),
|
|
1079
1173
|
React__namespace.createElement("col", { className: "diff-table-old-content-col" }),
|
|
@@ -1097,20 +1191,11 @@ DiffSplitViewWrap.displayName = "DiffSplitViewWrap";
|
|
|
1097
1191
|
|
|
1098
1192
|
const DiffSplitView = React.memo(({ diffFile }) => {
|
|
1099
1193
|
const { useDiffContext } = useDiffViewContext();
|
|
1100
|
-
const
|
|
1194
|
+
const useDiffContextRef = React.useRef(useDiffContext);
|
|
1195
|
+
useDiffContextRef.current = useDiffContext;
|
|
1196
|
+
const enableWrap = useDiffContext(React.useCallback((s) => s.enableWrap, []));
|
|
1101
1197
|
// performance optimization
|
|
1102
|
-
const useWidget = React.useMemo(() =>
|
|
1103
|
-
const widgetSide = reactivityStore.ref(undefined);
|
|
1104
|
-
const widgetLineNumber = reactivityStore.ref(undefined);
|
|
1105
|
-
const setWidget = ({ side, lineNumber }) => {
|
|
1106
|
-
const { renderWidgetLine } = useDiffContext.getReadonlyState();
|
|
1107
|
-
if (typeof renderWidgetLine !== "function")
|
|
1108
|
-
return;
|
|
1109
|
-
widgetSide.value = side;
|
|
1110
|
-
widgetLineNumber.value = lineNumber;
|
|
1111
|
-
};
|
|
1112
|
-
return { widgetSide, widgetLineNumber, setWidget };
|
|
1113
|
-
}), [useDiffContext]);
|
|
1198
|
+
const useWidget = React.useMemo(() => createDiffWidgetStore(useDiffContextRef), []);
|
|
1114
1199
|
const contextValue = React.useMemo(() => ({ useWidget }), [useWidget]);
|
|
1115
1200
|
React.useEffect(() => {
|
|
1116
1201
|
const { setWidget } = useWidget.getReadonlyState();
|
|
@@ -1131,7 +1216,7 @@ const _DiffUnifiedExtendLine = ({ index, diffFile, lineNumber, oldLineExtend, ne
|
|
|
1131
1216
|
if (!renderExtendLine)
|
|
1132
1217
|
return null;
|
|
1133
1218
|
return (React__namespace.createElement("tr", { "data-line": `${lineNumber}-extend`, "data-state": "extend", className: "diff-line diff-line-extend" },
|
|
1134
|
-
React__namespace.createElement("td", { className: "diff-line-extend-content align-top
|
|
1219
|
+
React__namespace.createElement("td", { className: "diff-line-extend-content p-0 align-top", colSpan: 2 },
|
|
1135
1220
|
React__namespace.createElement("div", { className: "diff-line-extend-wrapper sticky left-0", style: { width } },
|
|
1136
1221
|
width > 0 &&
|
|
1137
1222
|
(oldLineExtend === null || oldLineExtend === void 0 ? void 0 : oldLineExtend.data) &&
|
|
@@ -1181,19 +1266,19 @@ const _DiffUnifiedHunkLine = ({ index, diffFile, lineNumber, }) => {
|
|
|
1181
1266
|
const isFirstLine = currentHunk && currentHunk.isFirst;
|
|
1182
1267
|
const isLastLine = currentHunk && currentHunk.isLast;
|
|
1183
1268
|
return (React__namespace.createElement("tr", { "data-line": `${lineNumber}-hunk`, "data-state": "hunk", className: "diff-line diff-line-hunk" },
|
|
1184
|
-
React__namespace.createElement("td", { className: "diff-line-hunk-action sticky left-0
|
|
1269
|
+
React__namespace.createElement("td", { className: "diff-line-hunk-action sticky left-0 w-[1%] min-w-[100px] select-none p-[1px]", style: {
|
|
1185
1270
|
backgroundColor: `var(${hunkLineNumberBGName})`,
|
|
1186
1271
|
color: `var(${plainLineNumberColorName})`,
|
|
1187
|
-
width: `calc(calc(var(${
|
|
1188
|
-
maxWidth: `calc(calc(var(${
|
|
1189
|
-
minWidth: `calc(calc(var(${
|
|
1190
|
-
} }, couldExpand ? (isFirstLine ? (React__namespace.createElement("button", { className: "
|
|
1191
|
-
React__namespace.createElement(ExpandUp, { className: "fill-current" }))) : isLastLine ? (React__namespace.createElement("button", { className: "
|
|
1192
|
-
React__namespace.createElement(ExpandDown, { className: "fill-current" }))) : isExpandAll ? (React__namespace.createElement("button", { className: "
|
|
1272
|
+
width: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
|
|
1273
|
+
maxWidth: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
|
|
1274
|
+
minWidth: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
|
|
1275
|
+
} }, couldExpand ? (isFirstLine ? (React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px] hover:bg-blue-300", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onUnifiedHunkExpand("up", index) },
|
|
1276
|
+
React__namespace.createElement(ExpandUp, { className: "fill-current" }))) : isLastLine ? (React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px] hover:bg-blue-300", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onUnifiedHunkExpand("down", index) },
|
|
1277
|
+
React__namespace.createElement(ExpandDown, { className: "fill-current" }))) : isExpandAll ? (React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px] hover:bg-blue-300", title: "Expand All", "data-title": "Expand All", onClick: () => diffFile.onUnifiedHunkExpand("all", index) },
|
|
1193
1278
|
React__namespace.createElement(ExpandAll, { className: "fill-current" }))) : (React__namespace.createElement(React__namespace.Fragment, null,
|
|
1194
|
-
React__namespace.createElement("button", { className: "
|
|
1279
|
+
React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px] hover:bg-blue-300", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onUnifiedHunkExpand("down", index) },
|
|
1195
1280
|
React__namespace.createElement(ExpandDown, { className: "fill-current" })),
|
|
1196
|
-
React__namespace.createElement("button", { className: "
|
|
1281
|
+
React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px] hover:bg-blue-300", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onUnifiedHunkExpand("up", index) },
|
|
1197
1282
|
React__namespace.createElement(ExpandUp, { className: "fill-current" }))))) : (React__namespace.createElement("div", { className: "min-h-[28px]" }, "\u2002"))),
|
|
1198
1283
|
React__namespace.createElement("td", { className: "diff-line-hunk-content pr-[10px] align-middle", style: { backgroundColor: `var(${hunkContentBGName})` } },
|
|
1199
1284
|
React__namespace.createElement("div", { className: "pl-[1.5em]", style: {
|
|
@@ -1215,12 +1300,12 @@ const DiffUnifiedHunkLine = ({ index, diffFile, lineNumber, }) => {
|
|
|
1215
1300
|
|
|
1216
1301
|
const DiffUnifiedOldLine = ({ index, diffLine, rawLine, syntaxLine, lineNumber, diffFile, setWidget, enableWrap, enableAddWidget, enableHighlight, onAddWidgetClick, }) => {
|
|
1217
1302
|
return (React__namespace.createElement("tr", { "data-line": index, "data-state": "diff", className: "diff-line group" },
|
|
1218
|
-
React__namespace.createElement("td", { className: "diff-line-num sticky left-0
|
|
1303
|
+
React__namespace.createElement("td", { className: "diff-line-num sticky left-0 w-[1%] min-w-[100px] select-none whitespace-nowrap pl-[10px] pr-[10px] text-right align-top", style: {
|
|
1219
1304
|
color: `var(${plainLineNumberColorName})`,
|
|
1220
1305
|
backgroundColor: `var(${delLineNumberBGName})`,
|
|
1221
|
-
width: `calc(calc(var(${
|
|
1222
|
-
maxWidth: `calc(calc(var(${
|
|
1223
|
-
minWidth: `calc(calc(var(${
|
|
1306
|
+
width: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
|
|
1307
|
+
maxWidth: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
|
|
1308
|
+
minWidth: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
|
|
1224
1309
|
} },
|
|
1225
1310
|
enableAddWidget && (React__namespace.createElement(DiffUnifiedAddWidget, { index: index - 1, lineNumber: lineNumber, diffFile: diffFile, side: exports.SplitSide.old, onWidgetClick: onAddWidgetClick, onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber, side }) })),
|
|
1226
1311
|
React__namespace.createElement("div", { className: "flex" },
|
|
@@ -1232,17 +1317,17 @@ const DiffUnifiedOldLine = ({ index, diffLine, rawLine, syntaxLine, lineNumber,
|
|
|
1232
1317
|
};
|
|
1233
1318
|
const DiffUnifiedNewLine = ({ index, diffLine, rawLine, syntaxLine, lineNumber, diffFile, setWidget, enableWrap, enableAddWidget, enableHighlight, onAddWidgetClick, }) => {
|
|
1234
1319
|
return (React__namespace.createElement("tr", { "data-line": index, "data-state": "diff", className: "diff-line group" },
|
|
1235
|
-
React__namespace.createElement("td", { className: "diff-line-num sticky left-0
|
|
1320
|
+
React__namespace.createElement("td", { className: "diff-line-num sticky left-0 w-[1%] min-w-[100px] select-none whitespace-nowrap pl-[10px] pr-[10px] text-right align-top", style: {
|
|
1236
1321
|
color: `var(${plainLineNumberColorName})`,
|
|
1237
1322
|
backgroundColor: `var(${addLineNumberBGName})`,
|
|
1238
|
-
width: `calc(calc(var(${
|
|
1239
|
-
maxWidth: `calc(calc(var(${
|
|
1240
|
-
minWidth: `calc(calc(var(${
|
|
1323
|
+
width: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
|
|
1324
|
+
maxWidth: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
|
|
1325
|
+
minWidth: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
|
|
1241
1326
|
} },
|
|
1242
1327
|
enableAddWidget && (React__namespace.createElement(DiffUnifiedAddWidget, { index: index - 1, lineNumber: lineNumber, diffFile: diffFile, side: exports.SplitSide.new, onWidgetClick: onAddWidgetClick, onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber, side }) })),
|
|
1243
1328
|
React__namespace.createElement("div", { className: "flex" },
|
|
1244
1329
|
React__namespace.createElement("span", { className: "inline-block w-[50%]" }),
|
|
1245
|
-
React__namespace.createElement("span", { className: "
|
|
1330
|
+
React__namespace.createElement("span", { className: "w-[10px] shrink-0" }),
|
|
1246
1331
|
React__namespace.createElement("span", { "data-line-new-num": lineNumber, className: "inline-block w-[50%]" }, lineNumber))),
|
|
1247
1332
|
React__namespace.createElement("td", { className: "diff-line-content pr-[10px] align-top", style: { backgroundColor: `var(${addContentBGName})` } },
|
|
1248
1333
|
React__namespace.createElement(DiffContent, { enableWrap: enableWrap, diffFile: diffFile, enableHighlight: enableHighlight, rawLine: rawLine, diffLine: diffLine, syntaxLine: syntaxLine }))));
|
|
@@ -1279,11 +1364,11 @@ const _DiffUnifiedLine = React.memo(({ index, diffFile, lineNumber }) => {
|
|
|
1279
1364
|
}
|
|
1280
1365
|
else {
|
|
1281
1366
|
return (React__namespace.createElement("tr", { "data-line": lineNumber, "data-state": unifiedLine.diff ? "diff" : "plain", className: "diff-line group" },
|
|
1282
|
-
React__namespace.createElement("td", { className: "diff-line-num sticky left-0
|
|
1367
|
+
React__namespace.createElement("td", { className: "diff-line-num sticky left-0 w-[1%] min-w-[100px] select-none whitespace-nowrap pl-[10px] pr-[10px] text-right align-top", style: {
|
|
1283
1368
|
color: `var(${plainLineNumberColorName})`,
|
|
1284
|
-
width: `calc(calc(var(${
|
|
1285
|
-
maxWidth: `calc(calc(var(${
|
|
1286
|
-
minWidth: `calc(calc(var(${
|
|
1369
|
+
width: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
|
|
1370
|
+
maxWidth: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
|
|
1371
|
+
minWidth: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
|
|
1287
1372
|
backgroundColor: hasDiff ? `var(${plainLineNumberBGName})` : `var(${expandContentBGName})`,
|
|
1288
1373
|
} },
|
|
1289
1374
|
enableAddWidget && hasDiff && (React__namespace.createElement(DiffUnifiedAddWidget, { index: index, diffFile: diffFile, lineNumber: unifiedLine.newLineNumber, side: exports.SplitSide.new, onWidgetClick: (...props) => { var _a; return (_a = onAddWidgetClick.current) === null || _a === void 0 ? void 0 : _a.call(onAddWidgetClick, ...props); }, onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber, side }) })),
|
|
@@ -1350,19 +1435,10 @@ const onMouseDown = (e) => {
|
|
|
1350
1435
|
};
|
|
1351
1436
|
const DiffUnifiedView = React.memo(({ diffFile }) => {
|
|
1352
1437
|
const { useDiffContext } = useDiffViewContext();
|
|
1438
|
+
const useDiffContextRef = React.useRef(useDiffContext);
|
|
1439
|
+
useDiffContextRef.current = useDiffContext;
|
|
1353
1440
|
// performance optimization
|
|
1354
|
-
const useWidget = React.useMemo(() =>
|
|
1355
|
-
const widgetSide = reactivityStore.ref(undefined);
|
|
1356
|
-
const widgetLineNumber = reactivityStore.ref(undefined);
|
|
1357
|
-
const setWidget = ({ side, lineNumber }) => {
|
|
1358
|
-
const { renderWidgetLine } = useDiffContext.getReadonlyState();
|
|
1359
|
-
if (typeof renderWidgetLine !== "function")
|
|
1360
|
-
return;
|
|
1361
|
-
widgetSide.value = side;
|
|
1362
|
-
widgetLineNumber.value = lineNumber;
|
|
1363
|
-
};
|
|
1364
|
-
return { widgetSide, widgetLineNumber, setWidget };
|
|
1365
|
-
}), [useDiffContext]);
|
|
1441
|
+
const useWidget = React.useMemo(() => createDiffWidgetStore(useDiffContextRef), []);
|
|
1366
1442
|
const contextValue = React.useMemo(() => ({ useWidget }), [useWidget]);
|
|
1367
1443
|
const fontSize = useDiffContext(React.useCallback((s) => s.fontSize, []));
|
|
1368
1444
|
index_js.useSyncExternalStore(diffFile.subscribe, diffFile.getUpdateCount);
|
|
@@ -1373,19 +1449,19 @@ const DiffUnifiedView = React.memo(({ diffFile }) => {
|
|
|
1373
1449
|
const unifiedLineLength = Math.max(diffFile.unifiedLineLength, diffFile.fileLineLength);
|
|
1374
1450
|
const _width = useTextWidth({
|
|
1375
1451
|
text: unifiedLineLength.toString(),
|
|
1376
|
-
font: { fontSize: fontSize + "px", fontFamily: "Menlo, Consolas, monospace" },
|
|
1452
|
+
font: React.useMemo(() => ({ fontSize: fontSize + "px", fontFamily: "Menlo, Consolas, monospace" }), [fontSize]),
|
|
1377
1453
|
});
|
|
1378
|
-
const width = Math.max(40, _width +
|
|
1454
|
+
const width = Math.max(40, _width + 10);
|
|
1379
1455
|
const lines = core.getUnifiedContentLine(diffFile);
|
|
1380
1456
|
return (React__namespace.createElement(DiffWidgetContext.Provider, { value: contextValue },
|
|
1381
1457
|
React__namespace.createElement("div", { className: "unified-diff-view w-full" },
|
|
1382
|
-
React__namespace.createElement("div", { className: "unified-diff-table-wrapper overflow-x-auto overflow-y-hidden
|
|
1458
|
+
React__namespace.createElement("div", { className: "unified-diff-table-wrapper scrollbar-hide scrollbar-disable w-full overflow-x-auto overflow-y-hidden", style: {
|
|
1383
1459
|
// @ts-ignore
|
|
1384
|
-
[
|
|
1460
|
+
[diffAsideWidthName]: `${Math.round(width)}px`,
|
|
1385
1461
|
fontFamily: "Menlo, Consolas, monospace",
|
|
1386
1462
|
fontSize: `var(${diffFontSizeName})`,
|
|
1387
1463
|
} },
|
|
1388
|
-
React__namespace.createElement("table", { className: "unified-diff-table border-collapse
|
|
1464
|
+
React__namespace.createElement("table", { className: "unified-diff-table w-full border-collapse" },
|
|
1389
1465
|
React__namespace.createElement("colgroup", null,
|
|
1390
1466
|
React__namespace.createElement("col", { className: "unified-diff-table-num-col" }),
|
|
1391
1467
|
React__namespace.createElement("col", { className: "unified-diff-table-content-col" })),
|
|
@@ -1403,7 +1479,6 @@ const DiffUnifiedView = React.memo(({ diffFile }) => {
|
|
|
1403
1479
|
});
|
|
1404
1480
|
DiffUnifiedView.displayName = "DiffUnifiedView";
|
|
1405
1481
|
|
|
1406
|
-
const diffFontSizeName = "--diff-font-size--";
|
|
1407
1482
|
core._cacheMap.name = "@git-diff-view/react";
|
|
1408
1483
|
exports.SplitSide = void 0;
|
|
1409
1484
|
(function (SplitSide) {
|
|
@@ -1414,76 +1489,7 @@ const _InternalDiffView = (props) => {
|
|
|
1414
1489
|
const { diffFile, className, style, diffViewMode, diffViewWrap, diffViewFontSize, diffViewHighlight, renderWidgetLine, renderExtendLine, extendData, diffViewAddWidget, onAddWidgetClick, } = props;
|
|
1415
1490
|
const diffFileId = React.useMemo(() => diffFile.getId(), [diffFile]);
|
|
1416
1491
|
// performance optimization
|
|
1417
|
-
const useDiffContext = React.useMemo(() =>
|
|
1418
|
-
var _a, _b;
|
|
1419
|
-
const id = reactivityStore.ref(diffFileId);
|
|
1420
|
-
const setId = (_id) => (id.value = _id);
|
|
1421
|
-
const mode = reactivityStore.ref(props.diffViewMode);
|
|
1422
|
-
const setMode = (_mode) => (mode.value = _mode);
|
|
1423
|
-
const enableWrap = reactivityStore.ref(props.diffViewWrap);
|
|
1424
|
-
const setEnableWrap = (_enableWrap) => (enableWrap.value = _enableWrap);
|
|
1425
|
-
const enableAddWidget = reactivityStore.ref(props.diffViewAddWidget);
|
|
1426
|
-
const setEnableAddWidget = (_enableAddWidget) => (enableAddWidget.value = _enableAddWidget);
|
|
1427
|
-
const enableHighlight = reactivityStore.ref(props.diffViewHighlight);
|
|
1428
|
-
const setEnableHighlight = (_enableHighlight) => (enableHighlight.value = _enableHighlight);
|
|
1429
|
-
const fontSize = reactivityStore.ref(props.diffViewFontSize);
|
|
1430
|
-
const setFontSize = (_fontSize) => (fontSize.value = _fontSize);
|
|
1431
|
-
const extendData = reactivityStore.ref({
|
|
1432
|
-
oldFile: Object.assign({}, (_a = props.extendData) === null || _a === void 0 ? void 0 : _a.oldFile),
|
|
1433
|
-
newFile: Object.assign({}, (_b = props.extendData) === null || _b === void 0 ? void 0 : _b.newFile),
|
|
1434
|
-
});
|
|
1435
|
-
const setExtendData = (_extendData) => {
|
|
1436
|
-
const existOldKeys = Object.keys(extendData.value.oldFile || {});
|
|
1437
|
-
const inComingOldKeys = Object.keys(_extendData.oldFile || {});
|
|
1438
|
-
for (const key of existOldKeys) {
|
|
1439
|
-
if (!inComingOldKeys.includes(key)) {
|
|
1440
|
-
delete extendData.value.oldFile[key];
|
|
1441
|
-
}
|
|
1442
|
-
}
|
|
1443
|
-
for (const key of inComingOldKeys) {
|
|
1444
|
-
extendData.value.oldFile[key] = _extendData.oldFile[key];
|
|
1445
|
-
}
|
|
1446
|
-
const existNewKeys = Object.keys(extendData.value.newFile || {});
|
|
1447
|
-
const inComingNewKeys = Object.keys(_extendData.newFile || {});
|
|
1448
|
-
for (const key of existNewKeys) {
|
|
1449
|
-
if (!inComingNewKeys.includes(key)) {
|
|
1450
|
-
delete extendData.value.newFile[key];
|
|
1451
|
-
}
|
|
1452
|
-
}
|
|
1453
|
-
for (const key of inComingNewKeys) {
|
|
1454
|
-
extendData.value.newFile[key] = _extendData.newFile[key];
|
|
1455
|
-
}
|
|
1456
|
-
};
|
|
1457
|
-
const renderWidgetLine = reactivityStore.ref(props.renderWidgetLine);
|
|
1458
|
-
const setRenderWidgetLine = (_renderWidgetLine) => (renderWidgetLine.value = _renderWidgetLine);
|
|
1459
|
-
const renderExtendLine = reactivityStore.ref(props.renderExtendLine);
|
|
1460
|
-
const setRenderExtendLine = (_renderExtendLine) => (renderExtendLine.value = _renderExtendLine);
|
|
1461
|
-
// 避免无意义的订阅
|
|
1462
|
-
const onAddWidgetClick = { current: props.onAddWidgetClick };
|
|
1463
|
-
const setOnAddWidgetClick = (_onAddWidgetClick) => (onAddWidgetClick.current = _onAddWidgetClick.current);
|
|
1464
|
-
return {
|
|
1465
|
-
id,
|
|
1466
|
-
setId,
|
|
1467
|
-
mode,
|
|
1468
|
-
setMode,
|
|
1469
|
-
enableWrap,
|
|
1470
|
-
setEnableWrap,
|
|
1471
|
-
enableAddWidget,
|
|
1472
|
-
setEnableAddWidget,
|
|
1473
|
-
enableHighlight,
|
|
1474
|
-
setEnableHighlight,
|
|
1475
|
-
fontSize,
|
|
1476
|
-
setFontSize,
|
|
1477
|
-
extendData,
|
|
1478
|
-
setExtendData,
|
|
1479
|
-
renderWidgetLine,
|
|
1480
|
-
setRenderWidgetLine,
|
|
1481
|
-
renderExtendLine,
|
|
1482
|
-
setRenderExtendLine,
|
|
1483
|
-
onAddWidgetClick,
|
|
1484
|
-
setOnAddWidgetClick,
|
|
1485
|
-
};
|
|
1486
|
-
}),
|
|
1492
|
+
const useDiffContext = React.useMemo(() => createDiffConfigStore(props, diffFileId),
|
|
1487
1493
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1488
1494
|
[]);
|
|
1489
1495
|
React.useEffect(() => {
|
|
@@ -1513,7 +1519,7 @@ const _InternalDiffView = (props) => {
|
|
|
1513
1519
|
]);
|
|
1514
1520
|
const value = React.useMemo(() => ({ useDiffContext }), [useDiffContext]);
|
|
1515
1521
|
return (React__namespace.createElement(DiffViewContext.Provider, { value: value },
|
|
1516
|
-
React__namespace.createElement("div", { className: "diff-tailwindcss-wrapper", "data-component": "git-diff-view", "data-version": `${"0.0.
|
|
1522
|
+
React__namespace.createElement("div", { className: "diff-tailwindcss-wrapper", "data-component": "git-diff-view", "data-version": `${"0.0.16"}`, "data-highlighter": diffFile._getHighlighterName() },
|
|
1517
1523
|
React__namespace.createElement("div", { className: "diff-style-root", style: {
|
|
1518
1524
|
// @ts-ignore
|
|
1519
1525
|
[diffFontSizeName]: diffViewFontSize + "px",
|
|
@@ -1522,6 +1528,7 @@ const _InternalDiffView = (props) => {
|
|
|
1522
1528
|
};
|
|
1523
1529
|
const InternalDiffView = React.memo(_InternalDiffView);
|
|
1524
1530
|
const DiffViewWithRef = (props, ref) => {
|
|
1531
|
+
var _a, _b;
|
|
1525
1532
|
const { registerHighlighter, data, diffFile: _diffFile } = props, restProps = __rest(props, ["registerHighlighter", "data", "diffFile"]);
|
|
1526
1533
|
const diffFile = React.useMemo(() => {
|
|
1527
1534
|
var _a, _b, _c, _d, _e, _f;
|
|
@@ -1535,6 +1542,11 @@ const DiffViewWithRef = (props, ref) => {
|
|
|
1535
1542
|
}
|
|
1536
1543
|
return null;
|
|
1537
1544
|
}, [data, _diffFile]);
|
|
1545
|
+
const diffFileRef = React.useRef(diffFile);
|
|
1546
|
+
if (diffFileRef.current && diffFileRef.current !== diffFile) {
|
|
1547
|
+
(_b = (_a = diffFileRef.current)._destroy) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
1548
|
+
diffFileRef.current = diffFile;
|
|
1549
|
+
}
|
|
1538
1550
|
React.useEffect(() => {
|
|
1539
1551
|
if (!diffFile)
|
|
1540
1552
|
return;
|
|
@@ -1566,11 +1578,10 @@ const DiffViewWithRef = (props, ref) => {
|
|
|
1566
1578
|
};
|
|
1567
1579
|
const DiffView = React.forwardRef(DiffViewWithRef);
|
|
1568
1580
|
DiffView.displayName = "DiffView";
|
|
1569
|
-
const version = "0.0.
|
|
1581
|
+
const version = "0.0.16";
|
|
1570
1582
|
|
|
1571
1583
|
exports.DiffView = DiffView;
|
|
1572
1584
|
exports.DiffViewContext = DiffViewContext;
|
|
1573
|
-
exports.diffFontSizeName = diffFontSizeName;
|
|
1574
1585
|
exports.useDiffViewContext = useDiffViewContext;
|
|
1575
1586
|
exports.version = version;
|
|
1576
1587
|
Object.keys(core).forEach(function (k) {
|