@git-diff-view/react 0.0.24 → 0.0.26

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.
@@ -2,7 +2,7 @@
2
2
  import { NewLineSymbol, DiffLineType, checkDiffLineIncludeChange, composeLen, getSplitContentLines, getUnifiedContentLine, _cacheMap, DiffFile } from '@git-diff-view/core';
3
3
  export * from '@git-diff-view/core';
4
4
  import * as React from 'react';
5
- import { useRef, useEffect, createContext, useContext, useLayoutEffect, useState, useCallback, memo, Fragment, useMemo, forwardRef, useImperativeHandle } from 'react';
5
+ import { useState, useEffect, useRef, useLayoutEffect, createContext, useContext, memo, Fragment, useMemo, useCallback, forwardRef, useImperativeHandle } from 'react';
6
6
  import { useSyncExternalStore } from 'use-sync-external-store/shim/index.js';
7
7
  import { flushSync } from 'react-dom';
8
8
  import { createStore, ref } from 'reactivity-store';
@@ -65,7 +65,7 @@ function __classPrivateFieldGet(receiver, state, kind, f) {
65
65
  }
66
66
 
67
67
  function __classPrivateFieldSet(receiver, state, value, kind, f) {
68
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
68
+ if (typeof state === "function" ? receiver !== state || true : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
69
69
  return (state.set(receiver, value)), value;
70
70
  }
71
71
 
@@ -188,7 +188,7 @@ const syncScroll = (left, right) => {
188
188
  const diffFontSizeName = "--diff-font-size--";
189
189
  const diffAsideWidthName = "--diff-aside-width--";
190
190
 
191
- // eslint-disable-next-line @typescript-eslint/ban-types
191
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
192
192
  const memoFunc = (func) => {
193
193
  const cache = {};
194
194
  return ((key) => {
@@ -214,6 +214,14 @@ const getSymbol = (symbol) => {
214
214
  }
215
215
  };
216
216
 
217
+ const useIsMounted = () => {
218
+ const [isMounted, setIsMounted] = useState(false);
219
+ useEffect(() => {
220
+ setIsMounted(true);
221
+ }, []);
222
+ return isMounted;
223
+ };
224
+
217
225
  const useUnmount = (cb, deps) => {
218
226
  const ref = useRef(cb);
219
227
  ref.current = cb;
@@ -221,19 +229,6 @@ const useUnmount = (cb, deps) => {
221
229
  useEffect(() => ref.current, deps);
222
230
  };
223
231
 
224
- var DiffModeEnum;
225
- (function (DiffModeEnum) {
226
- // github like
227
- DiffModeEnum[DiffModeEnum["SplitGitHub"] = 1] = "SplitGitHub";
228
- // gitlab like
229
- DiffModeEnum[DiffModeEnum["SplitGitLab"] = 2] = "SplitGitLab";
230
- DiffModeEnum[DiffModeEnum["Split"] = 3] = "Split";
231
- DiffModeEnum[DiffModeEnum["Unified"] = 4] = "Unified";
232
- })(DiffModeEnum || (DiffModeEnum = {}));
233
- const DiffViewContext = createContext(null);
234
- DiffViewContext.displayName = "DiffViewContext";
235
- const useDiffViewContext = () => useContext(DiffViewContext);
236
-
237
232
  const isClient = typeof window !== "undefined";
238
233
  const useSafeLayout = isClient ? useLayoutEffect : useEffect;
239
234
 
@@ -403,11 +398,15 @@ const DiffContent = ({ diffLine, rawLine, syntaxLine, enableWrap, enableHighligh
403
398
  enableHighlight && syntaxLine && !isMaxLineLengthToIgnoreSyntax ? (React.createElement(DiffSyntax, { operator: isAdded ? "add" : isDelete ? "del" : undefined, rawLine: rawLine, diffLine: diffLine, syntaxLine: syntaxLine, enableWrap: enableWrap })) : (React.createElement(DiffString, { operator: isAdded ? "add" : isDelete ? "del" : undefined, rawLine: rawLine, diffLine: diffLine, enableWrap: enableWrap }))));
404
399
  };
405
400
 
401
+ const DiffViewContext = createContext(null);
402
+ DiffViewContext.displayName = "DiffViewContext";
403
+ const useDiffViewContext = () => useContext(DiffViewContext);
404
+
406
405
  const DiffWidgetContext = createContext(null);
407
406
  DiffWidgetContext.displayName = "DiffWidgetContext";
408
407
  const useDiffWidgetContext = () => useContext(DiffWidgetContext);
409
408
 
410
- const _DiffSplitLine$1 = ({ index, diffFile, lineNumber, side, }) => {
409
+ const InternalDiffSplitLine$1 = ({ index, diffFile, lineNumber, side, }) => {
411
410
  var _a, _b;
412
411
  const getCurrentSyntaxLine = side === SplitSide.old ? diffFile.getOldSyntaxLine : diffFile.getNewSyntaxLine;
413
412
  const oldLine = diffFile.getSplitLeftLine(index);
@@ -448,13 +447,13 @@ const DiffSplitContentLine$1 = ({ index, diffFile, lineNumber, side, }) => {
448
447
  const currentLine = getCurrentLine(index);
449
448
  if (currentLine === null || currentLine === void 0 ? void 0 : currentLine.isHidden)
450
449
  return null;
451
- return React.createElement(_DiffSplitLine$1, { index: index, diffFile: diffFile, lineNumber: lineNumber, side: side });
450
+ return React.createElement(InternalDiffSplitLine$1, { index: index, diffFile: diffFile, lineNumber: lineNumber, side: side });
452
451
  };
453
452
 
454
453
  const useDomWidth = ({ selector, enable }) => {
455
454
  const [width, setWidth] = useState(0);
456
455
  const { useDiffContext } = useDiffViewContext();
457
- const id = useDiffContext(useCallback((s) => s.id, []));
456
+ const { id, mounted } = useDiffContext.useShallowStableSelector((s) => ({ id: s.id, mounted: s.mounted }));
458
457
  useEffect(() => {
459
458
  if (enable) {
460
459
  const container = document.querySelector(`#diff-root${id}`);
@@ -490,86 +489,95 @@ const useDomWidth = ({ selector, enable }) => {
490
489
  typedWrapper.setAttribute("data-observe", "height");
491
490
  return () => cleanCb();
492
491
  }
493
- }, [selector, enable, id]);
492
+ }, [selector, enable, id, mounted]);
494
493
  return width;
495
494
  };
496
495
 
497
- // TODO
498
496
  const useSyncHeight = ({ selector, wrapper, side, enable, }) => {
499
497
  const { useDiffContext } = useDiffViewContext();
500
- const id = useDiffContext(useCallback((s) => s.id, []));
498
+ const { id, mounted } = useDiffContext.useShallowStableSelector((s) => ({ id: s.id, mounted: s.mounted }));
501
499
  useEffect(() => {
502
500
  if (enable) {
503
- let clean = () => { };
504
- // fix the dom delay update
505
- const timer = setTimeout(() => {
506
- const container = document.querySelector(`#diff-root${id}`);
507
- const elements = Array.from((container === null || container === void 0 ? void 0 : container.querySelectorAll(selector)) || []);
508
- const wrappers = wrapper ? Array.from((container === null || container === void 0 ? void 0 : container.querySelectorAll(wrapper)) || []) : elements;
509
- if (elements.length === 2 && wrappers.length === 2) {
510
- const ele1 = elements[0];
511
- const ele2 = elements[1];
512
- const wrapper1 = wrappers[0];
513
- const wrapper2 = wrappers[1];
514
- const target = ele1.getAttribute("data-side") === side ? ele1 : ele2;
515
- const cb = () => {
516
- ele1.style.height = "auto";
517
- ele2.style.height = "auto";
518
- const rect1 = ele1.getBoundingClientRect();
519
- const rect2 = ele2.getBoundingClientRect();
520
- const maxHeight = Math.max(rect1.height, rect2.height);
521
- wrapper1.style.height = maxHeight + "px";
522
- wrapper2.style.height = maxHeight + "px";
523
- wrapper1.setAttribute("data-sync-height", String(maxHeight));
524
- wrapper2.setAttribute("data-sync-height", String(maxHeight));
525
- };
526
- cb();
527
- const observer = new ResizeObserver(cb);
528
- observer.observe(target);
529
- target.setAttribute("data-observe", "height");
530
- clean = () => {
531
- observer.disconnect();
532
- target === null || target === void 0 ? void 0 : target.removeAttribute("data-observe");
533
- };
501
+ const container = document.querySelector(`#diff-root${id}`);
502
+ const elements = Array.from((container === null || container === void 0 ? void 0 : container.querySelectorAll(selector)) || []);
503
+ const wrappers = wrapper ? Array.from((container === null || container === void 0 ? void 0 : container.querySelectorAll(wrapper)) || []) : elements;
504
+ if (elements.length === 2 && wrappers.length === 2) {
505
+ const ele1 = elements[0];
506
+ const ele2 = elements[1];
507
+ const wrapper1 = wrappers[0];
508
+ const wrapper2 = wrappers[1];
509
+ const target = ele1.getAttribute("data-side") === side ? ele1 : ele2;
510
+ const typedTarget = target;
511
+ const cb = () => {
512
+ ele1.style.height = "auto";
513
+ ele2.style.height = "auto";
514
+ const rect1 = ele1.getBoundingClientRect();
515
+ const rect2 = ele2.getBoundingClientRect();
516
+ const maxHeight = Math.max(rect1.height, rect2.height);
517
+ wrapper1.style.height = maxHeight + "px";
518
+ wrapper2.style.height = maxHeight + "px";
519
+ wrapper1.setAttribute("data-sync-height", String(maxHeight));
520
+ wrapper2.setAttribute("data-sync-height", String(maxHeight));
521
+ };
522
+ cb();
523
+ const cleanCb = () => {
524
+ var _a;
525
+ typedTarget.__observeCallback.delete(cb);
526
+ if (typedTarget.__observeCallback.size === 0) {
527
+ (_a = typedTarget.__observeInstance) === null || _a === void 0 ? void 0 : _a.disconnect();
528
+ typedTarget.removeAttribute("data-observe");
529
+ delete typedTarget.__observeCallback;
530
+ delete typedTarget.__observeInstance;
531
+ }
532
+ };
533
+ if (typedTarget.__observeCallback) {
534
+ typedTarget.__observeCallback.add(cb);
535
+ return () => cleanCb();
534
536
  }
535
- });
536
- return () => {
537
- clean();
538
- clearTimeout(timer);
539
- };
537
+ typedTarget.__observeCallback = new Set();
538
+ typedTarget.__observeCallback.add(cb);
539
+ const observer = new ResizeObserver(() => typedTarget.__observeCallback.forEach((cb) => cb()));
540
+ typedTarget.__observeInstance = observer;
541
+ observer.observe(target);
542
+ target.setAttribute("data-observe", "height");
543
+ return () => cleanCb();
544
+ }
540
545
  }
541
- }, [selector, enable, side, id, wrapper]);
546
+ }, [selector, enable, side, id, wrapper, mounted]);
542
547
  };
543
548
 
544
- const _DiffSplitExtendLine$1 = ({ index, diffFile, oldLineExtend, newLineExtend, side, lineNumber, }) => {
549
+ const InternalDiffSplitExtendLine$1 = ({ index, diffFile, oldLineExtend, newLineExtend, side, lineNumber, }) => {
545
550
  const { useDiffContext } = useDiffViewContext();
546
551
  const oldLine = diffFile.getSplitLeftLine(index);
547
552
  const newLine = diffFile.getSplitRightLine(index);
548
553
  const renderExtendLine = useDiffContext.useShallowStableSelector((s) => s.renderExtendLine);
549
554
  const currentExtend = side === SplitSide.old ? oldLineExtend : newLineExtend;
555
+ const otherSide = side === SplitSide.old ? SplitSide.new : SplitSide.old;
550
556
  const currentLineNumber = side === SplitSide.old ? oldLine.lineNumber : newLine.lineNumber;
551
- const hasExtend = (currentExtend === null || currentExtend === void 0 ? void 0 : currentExtend.data) !== undefined && (currentExtend === null || currentExtend === void 0 ? void 0 : currentExtend.data) !== null;
557
+ const currentSideHasExtend = (currentExtend === null || currentExtend === void 0 ? void 0 : currentExtend.data) !== undefined && (currentExtend === null || currentExtend === void 0 ? void 0 : currentExtend.data) !== null;
558
+ const hasExtend = ((oldLineExtend === null || oldLineExtend === void 0 ? void 0 : oldLineExtend.data) !== undefined && (oldLineExtend === null || oldLineExtend === void 0 ? void 0 : oldLineExtend.data) !== null) ||
559
+ ((newLineExtend === null || newLineExtend === void 0 ? void 0 : newLineExtend.data) !== undefined && (newLineExtend === null || newLineExtend === void 0 ? void 0 : newLineExtend.data) !== null);
552
560
  const currentExtendRendered = hasExtend &&
553
561
  (renderExtendLine === null || renderExtendLine === void 0 ? void 0 : renderExtendLine({
554
562
  diffFile,
555
563
  side,
556
564
  lineNumber: currentLineNumber,
557
- data: currentExtend.data,
565
+ data: currentExtend === null || currentExtend === void 0 ? void 0 : currentExtend.data,
558
566
  onUpdate: diffFile.notifyAll,
559
567
  }));
560
568
  useSyncHeight({
561
569
  selector: `div[data-line="${lineNumber}-extend-content"]`,
562
570
  wrapper: `tr[data-line="${lineNumber}-extend"]`,
563
- side: SplitSide[side],
571
+ side: SplitSide[currentSideHasExtend ? side : otherSide],
564
572
  enable: hasExtend && typeof renderExtendLine === "function",
565
573
  });
566
574
  const width = useDomWidth({
567
575
  selector: side === SplitSide.old ? ".old-diff-table-wrapper" : ".new-diff-table-wrapper",
568
- enable: hasExtend && typeof renderExtendLine === "function",
576
+ enable: currentSideHasExtend && typeof renderExtendLine === "function",
569
577
  });
570
578
  if (!renderExtendLine)
571
579
  return null;
572
- return (React.createElement("tr", { "data-line": `${lineNumber}-extend`, "data-state": "extend", "data-side": SplitSide[side], className: "diff-line diff-line-extend" }, hasExtend ? (React.createElement("td", { className: `diff-line-extend-${SplitSide[side]}-content p-0`, colSpan: 2 },
580
+ return (React.createElement("tr", { "data-line": `${lineNumber}-extend`, "data-state": "extend", "data-side": SplitSide[side], className: "diff-line diff-line-extend" }, currentSideHasExtend ? (React.createElement("td", { className: `diff-line-extend-${SplitSide[side]}-content p-0`, colSpan: 2 },
573
581
  React.createElement("div", { "data-line": `${lineNumber}-extend-content`, "data-side": SplitSide[side], className: "diff-line-extend-wrapper sticky left-0", style: { width } }, width > 0 && currentExtendRendered))) : (React.createElement("td", { className: `diff-line-extend-${SplitSide[side]}-placeholder select-none p-0`, style: { backgroundColor: `var(${emptyBGName})` }, colSpan: 2 },
574
582
  React.createElement("div", { "data-line": `${lineNumber}-extend-content`, "data-side": SplitSide[side] })))));
575
583
  };
@@ -591,7 +599,7 @@ const DiffSplitExtendLine$1 = ({ index, diffFile, side, lineNumber, }) => {
591
599
  const currentIsShow = hasExtend && (!currentLine.isHidden || !enableExpand);
592
600
  if (!currentIsShow)
593
601
  return null;
594
- return (React.createElement(_DiffSplitExtendLine$1, { side: side, index: index, diffFile: diffFile, lineNumber: lineNumber, oldLineExtend: oldLineExtend, newLineExtend: newLineExtend }));
602
+ return (React.createElement(InternalDiffSplitExtendLine$1, { side: side, index: index, diffFile: diffFile, lineNumber: lineNumber, oldLineExtend: oldLineExtend, newLineExtend: newLineExtend }));
595
603
  };
596
604
 
597
605
  const ExpandDown = ({ className }) => {
@@ -607,7 +615,7 @@ const ExpandAll = ({ className }) => {
607
615
  React.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" })));
608
616
  };
609
617
 
610
- const _DiffSplitHunkLineGitHub = ({ index, diffFile, side, lineNumber, }) => {
618
+ const InternalDiffSplitHunkLineGitHub = ({ index, diffFile, side, lineNumber, }) => {
611
619
  var _a;
612
620
  const currentHunk = diffFile.getSplitHunkLine(index);
613
621
  const expandEnabled = diffFile.getExpandEnabled();
@@ -631,9 +639,7 @@ const _DiffSplitHunkLineGitHub = ({ index, diffFile, side, lineNumber, }) => {
631
639
  minWidth: `var(${diffAsideWidthName})`,
632
640
  maxWidth: `var(${diffAsideWidthName})`,
633
641
  } }, couldExpand ? (isFirstLine ? (React.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) },
634
- React.createElement(ExpandUp, { className: "fill-current" }))) : isLastLine ? (React.createElement("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: () => {
635
- diffFile.onSplitHunkExpand("down", index);
636
- } },
642
+ React.createElement(ExpandUp, { className: "fill-current" }))) : isLastLine ? (React.createElement("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) },
637
643
  React.createElement(ExpandDown, { className: "fill-current" }))) : isExpandAll ? (React.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) },
638
644
  React.createElement(ExpandAll, { className: "fill-current" }))) : (React.createElement(React.Fragment, null,
639
645
  React.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) },
@@ -646,7 +652,7 @@ const _DiffSplitHunkLineGitHub = ({ index, diffFile, side, lineNumber, }) => {
646
652
  } }, ((_a = currentHunk.splitInfo) === null || _a === void 0 ? void 0 : _a.plainText) || currentHunk.text)))) : (React.createElement("td", { className: "diff-line-hunk-placeholder select-none", colSpan: 2, style: { backgroundColor: `var(${hunkContentBGName})` } },
647
653
  React.createElement("div", { className: "min-h-[28px]" }, "\u2002")))));
648
654
  };
649
- const _DiffSplitHunkLineGitLab = ({ index, diffFile, side, lineNumber, }) => {
655
+ const InternalDiffSplitHunkLineGitLab = ({ index, diffFile, side, lineNumber, }) => {
650
656
  var _a;
651
657
  const currentHunk = diffFile.getSplitHunkLine(index);
652
658
  const expandEnabled = diffFile.getExpandEnabled();
@@ -669,9 +675,7 @@ const _DiffSplitHunkLineGitLab = ({ index, diffFile, side, lineNumber, }) => {
669
675
  minWidth: `var(${diffAsideWidthName})`,
670
676
  maxWidth: `var(${diffAsideWidthName})`,
671
677
  } }, couldExpand ? (isFirstLine ? (React.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) },
672
- React.createElement(ExpandUp, { className: "fill-current" }))) : isLastLine ? (React.createElement("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: () => {
673
- diffFile.onSplitHunkExpand("down", index);
674
- } },
678
+ React.createElement(ExpandUp, { className: "fill-current" }))) : isLastLine ? (React.createElement("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) },
675
679
  React.createElement(ExpandDown, { className: "fill-current" }))) : isExpandAll ? (React.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) },
676
680
  React.createElement(ExpandAll, { className: "fill-current" }))) : (React.createElement(React.Fragment, null,
677
681
  React.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) },
@@ -683,16 +687,16 @@ const _DiffSplitHunkLineGitLab = ({ index, diffFile, side, lineNumber, }) => {
683
687
  color: `var(${hunkContentColorName})`,
684
688
  } }, ((_a = currentHunk.splitInfo) === null || _a === void 0 ? void 0 : _a.plainText) || currentHunk.text))));
685
689
  };
686
- const _DiffSplitHunkLine$1 = ({ index, diffFile, side, lineNumber, }) => {
690
+ const InternalDiffSplitHunkLine$1 = ({ index, diffFile, side, lineNumber, }) => {
687
691
  const { useDiffContext } = useDiffViewContext();
688
692
  const diffViewMode = useDiffContext.useShallowStableSelector((s) => s.mode);
689
693
  if (diffViewMode === DiffModeEnum.SplitGitHub ||
690
694
  diffViewMode === DiffModeEnum.Split ||
691
695
  diffViewMode === DiffModeEnum.Unified) {
692
- return React.createElement(_DiffSplitHunkLineGitHub, { index: index, diffFile: diffFile, side: side, lineNumber: lineNumber });
696
+ return React.createElement(InternalDiffSplitHunkLineGitHub, { index: index, diffFile: diffFile, side: side, lineNumber: lineNumber });
693
697
  }
694
698
  else {
695
- return React.createElement(_DiffSplitHunkLineGitLab, { index: index, diffFile: diffFile, side: side, lineNumber: lineNumber });
699
+ return React.createElement(InternalDiffSplitHunkLineGitLab, { index: index, diffFile: diffFile, side: side, lineNumber: lineNumber });
696
700
  }
697
701
  };
698
702
  const DiffSplitHunkLine$1 = ({ index, diffFile, side, lineNumber, }) => {
@@ -703,10 +707,10 @@ const DiffSplitHunkLine$1 = ({ index, diffFile, side, lineNumber, }) => {
703
707
  const currentIsPureHunk = currentHunk && diffFile._getIsPureDiffRender() && !currentHunk.splitInfo;
704
708
  if (!currentIsShow && !currentIsPureHunk)
705
709
  return null;
706
- return React.createElement(_DiffSplitHunkLine$1, { index: index, diffFile: diffFile, side: side, lineNumber: lineNumber });
710
+ return React.createElement(InternalDiffSplitHunkLine$1, { index: index, diffFile: diffFile, side: side, lineNumber: lineNumber });
707
711
  };
708
712
 
709
- const _DiffSplitWidgetLine$1 = ({ index, side, diffFile, lineNumber, }) => {
713
+ const InternalDiffSplitWidgetLine$1 = ({ index, side, diffFile, lineNumber, }) => {
710
714
  const { useWidget } = useDiffWidgetContext();
711
715
  const { useDiffContext } = useDiffViewContext();
712
716
  const oldLine = diffFile.getSplitLeftLine(index);
@@ -717,9 +721,11 @@ const _DiffSplitWidgetLine$1 = ({ index, side, diffFile, lineNumber, }) => {
717
721
  const oldLineWidget = oldLine.lineNumber && widgetSide === SplitSide.old && widgetLineNumber === oldLine.lineNumber;
718
722
  const newLineWidget = newLine.lineNumber && widgetSide === SplitSide.new && widgetLineNumber === newLine.lineNumber;
719
723
  const currentLine = side === SplitSide.old ? oldLine : newLine;
720
- const currentWidget = side === SplitSide.old ? oldLineWidget : newLineWidget;
724
+ const otherSide = side === SplitSide.old ? SplitSide.new : SplitSide.old;
725
+ const currentHasWidget = side === SplitSide.old ? oldLineWidget : newLineWidget;
726
+ const hasWidget = oldLineWidget || newLineWidget;
721
727
  const renderWidgetLine = useDiffContext.useShallowStableSelector((s) => s.renderWidgetLine);
722
- const currentWidgetRendered = currentWidget &&
728
+ const currentWidgetRendered = currentHasWidget &&
723
729
  (renderWidgetLine === null || renderWidgetLine === void 0 ? void 0 : renderWidgetLine({
724
730
  diffFile,
725
731
  side,
@@ -729,16 +735,16 @@ const _DiffSplitWidgetLine$1 = ({ index, side, diffFile, lineNumber, }) => {
729
735
  useSyncHeight({
730
736
  selector: `div[data-line="${lineNumber}-widget-content"]`,
731
737
  wrapper: `tr[data-line="${lineNumber}-widget"]`,
732
- side: SplitSide[side],
733
- enable: !!currentWidget && typeof renderWidgetLine === "function",
738
+ side: SplitSide[currentHasWidget ? side : otherSide],
739
+ enable: hasWidget && typeof renderWidgetLine === "function",
734
740
  });
735
741
  const width = useDomWidth({
736
742
  selector: side === SplitSide.old ? ".old-diff-table-wrapper" : ".new-diff-table-wrapper",
737
- enable: !!currentWidget && typeof renderWidgetLine === "function",
743
+ enable: !!currentHasWidget && typeof renderWidgetLine === "function",
738
744
  });
739
745
  if (!renderWidgetLine)
740
746
  return null;
741
- return (React.createElement("tr", { "data-line": `${lineNumber}-widget`, "data-state": "widget", "data-side": SplitSide[side], className: "diff-line diff-line-widget" }, currentWidget ? (React.createElement("td", { className: `diff-line-widget-${SplitSide[side]}-content p-0`, colSpan: 2 },
747
+ return (React.createElement("tr", { "data-line": `${lineNumber}-widget`, "data-state": "widget", "data-side": SplitSide[side], className: "diff-line diff-line-widget" }, currentHasWidget ? (React.createElement("td", { className: `diff-line-widget-${SplitSide[side]}-content p-0`, colSpan: 2 },
742
748
  React.createElement("div", { "data-line": `${lineNumber}-widget-content`, "data-side": SplitSide[side], className: "diff-line-widget-wrapper sticky left-0", style: { width } }, width > 0 && currentWidgetRendered))) : (React.createElement("td", { className: `diff-line-widget-${SplitSide[side]}-placeholder p-0`, style: { backgroundColor: `var(${emptyBGName})` }, colSpan: 2 },
743
749
  React.createElement("div", { "data-line": `${lineNumber}-widget-content`, "data-side": SplitSide[side] })))));
744
750
  };
@@ -757,7 +763,7 @@ const DiffSplitWidgetLine$1 = ({ index, side, diffFile, lineNumber, }) => {
757
763
  }, [diffFile, index]), (p, c) => p === c);
758
764
  if (!currentIsShow)
759
765
  return null;
760
- return React.createElement(_DiffSplitWidgetLine$1, { index: index, side: side, diffFile: diffFile, lineNumber: lineNumber });
766
+ return React.createElement(InternalDiffSplitWidgetLine$1, { index: index, side: side, diffFile: diffFile, lineNumber: lineNumber });
761
767
  };
762
768
 
763
769
  /* eslint-disable @typescript-eslint/ban-ts-comment */
@@ -833,7 +839,7 @@ const DiffSplitViewNormal = memo(({ diffFile }) => {
833
839
  });
834
840
  DiffSplitViewNormal.displayName = "DiffSplitViewNormal";
835
841
 
836
- const _DiffSplitLine = ({ index, diffFile, lineNumber }) => {
842
+ const InternalDiffSplitLine = ({ index, diffFile, lineNumber, }) => {
837
843
  var _a, _b;
838
844
  const oldLine = diffFile.getSplitLeftLine(index);
839
845
  const newLine = diffFile.getSplitRightLine(index);
@@ -871,12 +877,17 @@ const _DiffSplitLine = ({ index, diffFile, lineNumber }) => {
871
877
  backgroundColor: newLineNumberBG,
872
878
  color: `var(${plainLineNumberColorName})`,
873
879
  borderLeftColor: `var(${borderColorName})`,
880
+ borderLeftStyle: "solid",
874
881
  } },
875
882
  hasDiff && enableAddWidget && (React.createElement(DiffSplitAddWidget, { index: index, lineNumber: newLine.lineNumber, side: 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 }) })),
876
883
  React.createElement("span", { "data-line-num": newLine.lineNumber, style: { opacity: hasChange ? undefined : 0.5 } }, newLine.lineNumber)),
877
884
  React.createElement("td", { className: "diff-line-new-content group relative pr-[10px] align-top", "data-side": SplitSide[SplitSide.new], style: { backgroundColor: newLineContentBG } },
878
885
  hasDiff && enableAddWidget && (React.createElement(DiffSplitAddWidget, { index: index, lineNumber: newLine.lineNumber, side: 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 }) })),
879
- React.createElement(DiffContent, { enableWrap: true, diffFile: diffFile, rawLine: newLine.value || "", diffLine: newLine.diff, syntaxLine: newSyntaxLine, enableHighlight: enableHighlight })))) : (React.createElement("td", { className: "diff-line-new-placeholder select-none border-l-[1px]", style: { backgroundColor: `var(${emptyBGName})`, borderLeftColor: `var(${borderColorName})` }, "data-side": SplitSide[SplitSide.new], colSpan: 2 },
886
+ React.createElement(DiffContent, { enableWrap: true, diffFile: diffFile, rawLine: newLine.value || "", diffLine: newLine.diff, syntaxLine: newSyntaxLine, enableHighlight: enableHighlight })))) : (React.createElement("td", { className: "diff-line-new-placeholder select-none border-l-[1px]", style: {
887
+ backgroundColor: `var(${emptyBGName})`,
888
+ borderLeftColor: `var(${borderColorName})`,
889
+ borderLeftStyle: "solid",
890
+ }, "data-side": SplitSide[SplitSide.new], colSpan: 2 },
880
891
  React.createElement("span", null, "\u2002")))));
881
892
  };
882
893
  const DiffSplitContentLine = ({ index, diffFile, lineNumber, }) => {
@@ -884,10 +895,10 @@ const DiffSplitContentLine = ({ index, diffFile, lineNumber, }) => {
884
895
  const newLine = diffFile.getSplitRightLine(index);
885
896
  if ((oldLine === null || oldLine === void 0 ? void 0 : oldLine.isHidden) && (newLine === null || newLine === void 0 ? void 0 : newLine.isHidden))
886
897
  return null;
887
- return React.createElement(_DiffSplitLine, { index: index, diffFile: diffFile, lineNumber: lineNumber });
898
+ return React.createElement(InternalDiffSplitLine, { index: index, diffFile: diffFile, lineNumber: lineNumber });
888
899
  };
889
900
 
890
- const _DiffSplitExtendLine = ({ index, diffFile, lineNumber, oldLineExtend, newLineExtend, }) => {
901
+ const InternalDiffSplitExtendLine = ({ index, diffFile, lineNumber, oldLineExtend, newLineExtend, }) => {
891
902
  const { useDiffContext } = useDiffViewContext();
892
903
  const oldLine = diffFile.getSplitLeftLine(index);
893
904
  const newLine = diffFile.getSplitRightLine(index);
@@ -914,8 +925,12 @@ const _DiffSplitExtendLine = ({ index, diffFile, lineNumber, oldLineExtend, newL
914
925
  return (React.createElement("tr", { "data-line": `${lineNumber}-extend`, "data-state": "extend", className: "diff-line diff-line-extend" },
915
926
  oldExtendRendered ? (React.createElement("td", { className: "diff-line-extend-old-content p-0", colSpan: 2 },
916
927
  React.createElement("div", { className: "diff-line-extend-wrapper" }, oldExtendRendered))) : (React.createElement("td", { className: "diff-line-extend-old-placeholder select-none p-0", style: { backgroundColor: `var(${emptyBGName})` }, colSpan: 2 }, newExtendRendered && React.createElement("span", null, "\u2002"))),
917
- newExtendRendered ? (React.createElement("td", { className: "diff-line-extend-new-content border-l-[1px] p-0", style: { borderLeftColor: `var(${borderColorName})` }, colSpan: 2 },
918
- React.createElement("div", { className: "diff-line-extend-wrapper" }, newExtendRendered))) : (React.createElement("td", { className: "diff-line-extend-new-placeholder select-none border-l-[1px] p-0", style: { backgroundColor: `var(${emptyBGName})`, borderLeftColor: `var(${borderColorName})` }, colSpan: 2 }, oldExtendRendered && React.createElement("span", null, "\u2002")))));
928
+ newExtendRendered ? (React.createElement("td", { className: "diff-line-extend-new-content border-l-[1px] p-0", style: { borderLeftColor: `var(${borderColorName})`, borderLeftStyle: "solid" }, colSpan: 2 },
929
+ React.createElement("div", { className: "diff-line-extend-wrapper" }, newExtendRendered))) : (React.createElement("td", { className: "diff-line-extend-new-placeholder select-none border-l-[1px] p-0", style: {
930
+ backgroundColor: `var(${emptyBGName})`,
931
+ borderLeftColor: `var(${borderColorName})`,
932
+ borderLeftStyle: "solid",
933
+ }, colSpan: 2 }, oldExtendRendered && React.createElement("span", null, "\u2002")))));
919
934
  };
920
935
  const DiffSplitExtendLine = ({ index, diffFile, lineNumber, }) => {
921
936
  const { useDiffContext } = useDiffViewContext();
@@ -934,7 +949,7 @@ const DiffSplitExtendLine = ({ index, diffFile, lineNumber, }) => {
934
949
  const currentIsShow = hasExtend && ((!(oldLine === null || oldLine === void 0 ? void 0 : oldLine.isHidden) && !(newLine === null || newLine === void 0 ? void 0 : newLine.isHidden)) || !enableExpand);
935
950
  if (!currentIsShow)
936
951
  return null;
937
- return (React.createElement(_DiffSplitExtendLine, { index: index, diffFile: diffFile, lineNumber: lineNumber, oldLineExtend: oldLineExtend, newLineExtend: newLineExtend }));
952
+ return (React.createElement(InternalDiffSplitExtendLine, { index: index, diffFile: diffFile, lineNumber: lineNumber, oldLineExtend: oldLineExtend, newLineExtend: newLineExtend }));
938
953
  };
939
954
 
940
955
  const DiffSplitHunkLineGitHub = ({ index, diffFile, lineNumber, }) => {
@@ -990,10 +1005,11 @@ const DiffSplitHunkLineGitLab = ({ index, diffFile, lineNumber, }) => {
990
1005
  React.createElement("div", { className: "pl-[1.5em]", style: {
991
1006
  color: `var(${hunkContentColorName})`,
992
1007
  } }, ((_a = currentHunk.splitInfo) === null || _a === void 0 ? void 0 : _a.plainText) || currentHunk.text)),
993
- React.createElement("td", { className: "diff-line-hunk-action relative w-[1%] min-w-[40px] select-none border-l-[1px] p-[1px]", style: {
1008
+ React.createElement("td", { className: "diff-line-hunk-action relative z-[1] w-[1%] min-w-[40px] select-none border-l-[1px] p-[1px]", style: {
994
1009
  backgroundColor: `var(${hunkLineNumberBGName})`,
995
1010
  color: `var(${plainLineNumberColorName})`,
996
1011
  borderLeftColor: `var(${borderColorName})`,
1012
+ borderLeftStyle: "solid",
997
1013
  } }, couldExpand ? (isFirstLine ? (React.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) },
998
1014
  React.createElement(ExpandUp, { className: "fill-current" }))) : isLastLine ? (React.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) },
999
1015
  React.createElement(ExpandDown, { className: "fill-current" }))) : isExpandAll ? (React.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) },
@@ -1007,7 +1023,7 @@ const DiffSplitHunkLineGitLab = ({ index, diffFile, lineNumber, }) => {
1007
1023
  color: `var(${hunkContentColorName})`,
1008
1024
  } }, ((_b = currentHunk.splitInfo) === null || _b === void 0 ? void 0 : _b.plainText) || currentHunk.text))));
1009
1025
  };
1010
- const _DiffSplitHunkLine = ({ index, diffFile, lineNumber, }) => {
1026
+ const InternalDiffSplitHunkLine = ({ index, diffFile, lineNumber, }) => {
1011
1027
  const { useDiffContext } = useDiffViewContext();
1012
1028
  const diffViewMode = useDiffContext.useShallowStableSelector((s) => s.mode);
1013
1029
  if (diffViewMode === DiffModeEnum.SplitGitHub ||
@@ -1027,10 +1043,10 @@ const DiffSplitHunkLine = ({ index, diffFile, lineNumber, }) => {
1027
1043
  const currentIsPureHunk = currentHunk && diffFile._getIsPureDiffRender() && !currentHunk.splitInfo;
1028
1044
  if (!currentIsShow && !currentIsPureHunk)
1029
1045
  return null;
1030
- return React.createElement(_DiffSplitHunkLine, { index: index, diffFile: diffFile, lineNumber: lineNumber });
1046
+ return React.createElement(InternalDiffSplitHunkLine, { index: index, diffFile: diffFile, lineNumber: lineNumber });
1031
1047
  };
1032
1048
 
1033
- const _DiffSplitWidgetLine = ({ index, diffFile, lineNumber, }) => {
1049
+ const InternalDiffSplitWidgetLine = ({ index, diffFile, lineNumber, }) => {
1034
1050
  const { useWidget } = useDiffWidgetContext();
1035
1051
  const setWidget = useWidget.getReadonlyState().setWidget;
1036
1052
  const { useDiffContext } = useDiffViewContext();
@@ -1050,8 +1066,12 @@ const _DiffSplitWidgetLine = ({ index, diffFile, lineNumber, }) => {
1050
1066
  return (React.createElement("tr", { "data-line": `${lineNumber}-widget`, "data-state": "widget", className: "diff-line diff-line-widget" },
1051
1067
  oldWidgetRendered ? (React.createElement("td", { className: "diff-line-widget-old-content p-0", colSpan: 2 },
1052
1068
  React.createElement("div", { className: "diff-line-widget-wrapper" }, oldWidgetRendered))) : (React.createElement("td", { className: "diff-line-widget-old-placeholder select-none p-0", style: { backgroundColor: `var(${emptyBGName})` }, colSpan: 2 }, newWidgetRendered && React.createElement("span", null, "\u2002"))),
1053
- newWidgetRendered ? (React.createElement("td", { className: "diff-line-widget-new-content border-l-[1px] p-0", colSpan: 2, style: { borderLeftColor: `var(${borderColorName})` } },
1054
- React.createElement("div", { className: "diff-line-widget-wrapper" }, newWidgetRendered))) : (React.createElement("td", { className: "diff-line-widget-new-placeholder select-none border-l-[1px] p-0", style: { backgroundColor: `var(${emptyBGName})`, borderLeftColor: `var(${borderColorName})` }, colSpan: 2 }, oldWidgetRendered && React.createElement("span", null, "\u2002")))));
1069
+ newWidgetRendered ? (React.createElement("td", { className: "diff-line-widget-new-content border-l-[1px] p-0", colSpan: 2, style: { borderLeftColor: `var(${borderColorName})`, borderLeftStyle: "solid" } },
1070
+ React.createElement("div", { className: "diff-line-widget-wrapper" }, newWidgetRendered))) : (React.createElement("td", { className: "diff-line-widget-new-placeholder select-none border-l-[1px] p-0", style: {
1071
+ backgroundColor: `var(${emptyBGName})`,
1072
+ borderLeftColor: `var(${borderColorName})`,
1073
+ borderLeftStyle: "solid",
1074
+ }, colSpan: 2 }, oldWidgetRendered && React.createElement("span", null, "\u2002")))));
1055
1075
  };
1056
1076
  // TODO! improve performance
1057
1077
  const DiffSplitWidgetLine = ({ index, diffFile, lineNumber, }) => {
@@ -1068,7 +1088,7 @@ const DiffSplitWidgetLine = ({ index, diffFile, lineNumber, }) => {
1068
1088
  }, [diffFile, index]), (p, c) => p === c);
1069
1089
  if (!currentIsShow)
1070
1090
  return null;
1071
- return React.createElement(_DiffSplitWidgetLine, { index: index, diffFile: diffFile, lineNumber: lineNumber });
1091
+ return React.createElement(InternalDiffSplitWidgetLine, { index: index, diffFile: diffFile, lineNumber: lineNumber });
1072
1092
  };
1073
1093
 
1074
1094
  const createDiffConfigStore = (props, diffFileId) => {
@@ -1078,6 +1098,8 @@ const createDiffConfigStore = (props, diffFileId) => {
1078
1098
  const setId = (_id) => (id.value = _id);
1079
1099
  const mode = ref(props.diffViewMode);
1080
1100
  const setMode = (_mode) => (mode.value = _mode);
1101
+ const mounted = ref(props.isMounted);
1102
+ const setMounted = (_mounted) => (mounted.value = _mounted);
1081
1103
  const enableWrap = ref(props.diffViewWrap);
1082
1104
  const setEnableWrap = (_enableWrap) => (enableWrap.value = _enableWrap);
1083
1105
  const enableAddWidget = ref(props.diffViewAddWidget);
@@ -1124,6 +1146,8 @@ const createDiffConfigStore = (props, diffFileId) => {
1124
1146
  setId,
1125
1147
  mode,
1126
1148
  setMode,
1149
+ mounted,
1150
+ setMounted,
1127
1151
  enableWrap,
1128
1152
  setEnableWrap,
1129
1153
  enableAddWidget,
@@ -1350,7 +1374,7 @@ const DiffUnifiedContentLine = ({ index, diffFile, lineNumber, }) => {
1350
1374
  return React.createElement(_DiffUnifiedLine, { index: index, diffFile: diffFile, lineNumber: lineNumber });
1351
1375
  };
1352
1376
 
1353
- const _DiffUnifiedExtendLine = ({ index, diffFile, lineNumber, oldLineExtend, newLineExtend, }) => {
1377
+ const InternalDiffUnifiedExtendLine = ({ index, diffFile, lineNumber, oldLineExtend, newLineExtend, }) => {
1354
1378
  const { useDiffContext } = useDiffViewContext();
1355
1379
  const renderExtendLine = useDiffContext.useShallowStableSelector((s) => s.renderExtendLine);
1356
1380
  const unifiedItem = diffFile.getUnifiedLine(index);
@@ -1395,12 +1419,12 @@ const DiffUnifiedExtendLine = ({ index, diffFile, lineNumber, }) => {
1395
1419
  });
1396
1420
  }, [unifiedItem.oldLineNumber, unifiedItem.newLineNumber]));
1397
1421
  const hasExtend = (oldLineExtend === null || oldLineExtend === void 0 ? void 0 : oldLineExtend.data) || (newLineExtend === null || newLineExtend === void 0 ? void 0 : newLineExtend.data);
1398
- if (!hasExtend || !unifiedItem || unifiedItem.isHidden || !unifiedItem.diff)
1422
+ if (!hasExtend || !unifiedItem || unifiedItem.isHidden)
1399
1423
  return null;
1400
- return (React.createElement(_DiffUnifiedExtendLine, { index: index, diffFile: diffFile, lineNumber: lineNumber, oldLineExtend: oldLineExtend, newLineExtend: newLineExtend }));
1424
+ return (React.createElement(InternalDiffUnifiedExtendLine, { index: index, diffFile: diffFile, lineNumber: lineNumber, oldLineExtend: oldLineExtend, newLineExtend: newLineExtend }));
1401
1425
  };
1402
1426
 
1403
- const _DiffUnifiedHunkLine = ({ index, diffFile, lineNumber, }) => {
1427
+ const InternalDiffUnifiedHunkLine = ({ index, diffFile, lineNumber, }) => {
1404
1428
  var _a;
1405
1429
  const currentHunk = diffFile.getUnifiedHunkLine(index);
1406
1430
  const expandEnabled = diffFile.getExpandEnabled();
@@ -1419,13 +1443,13 @@ const _DiffUnifiedHunkLine = ({ index, diffFile, lineNumber, }) => {
1419
1443
  width: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
1420
1444
  maxWidth: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
1421
1445
  minWidth: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
1422
- } }, couldExpand ? (isFirstLine ? (React.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) },
1423
- React.createElement(ExpandUp, { className: "fill-current" }))) : isLastLine ? (React.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) },
1424
- React.createElement(ExpandDown, { className: "fill-current" }))) : isExpandAll ? (React.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) },
1446
+ } }, couldExpand ? (isFirstLine ? (React.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.onUnifiedHunkExpand("up", index) },
1447
+ React.createElement(ExpandUp, { className: "fill-current" }))) : isLastLine ? (React.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.onUnifiedHunkExpand("down", index) },
1448
+ React.createElement(ExpandDown, { className: "fill-current" }))) : isExpandAll ? (React.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.onUnifiedHunkExpand("all", index) },
1425
1449
  React.createElement(ExpandAll, { className: "fill-current" }))) : (React.createElement(React.Fragment, null,
1426
- React.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) },
1450
+ React.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) },
1427
1451
  React.createElement(ExpandDown, { className: "fill-current" })),
1428
- React.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) },
1452
+ React.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) },
1429
1453
  React.createElement(ExpandUp, { className: "fill-current" }))))) : (React.createElement("div", { className: "min-h-[28px]" }, "\u2002"))),
1430
1454
  React.createElement("td", { className: "diff-line-hunk-content pr-[10px] align-middle", style: { backgroundColor: `var(${hunkContentBGName})` } },
1431
1455
  React.createElement("div", { className: "pl-[1.5em]", style: {
@@ -1442,10 +1466,10 @@ const DiffUnifiedHunkLine = ({ index, diffFile, lineNumber, }) => {
1442
1466
  const currentIsPureHunk = currentHunk && diffFile._getIsPureDiffRender() && !currentHunk.unifiedInfo;
1443
1467
  if (!currentIsShow && !currentIsPureHunk)
1444
1468
  return null;
1445
- return React.createElement(_DiffUnifiedHunkLine, { index: index, diffFile: diffFile, lineNumber: lineNumber });
1469
+ return React.createElement(InternalDiffUnifiedHunkLine, { index: index, diffFile: diffFile, lineNumber: lineNumber });
1446
1470
  };
1447
1471
 
1448
- const _DiffUnifiedWidgetLine = ({ index, diffFile, lineNumber, }) => {
1472
+ const InternalDiffUnifiedWidgetLine = ({ index, diffFile, lineNumber, }) => {
1449
1473
  const { useWidget } = useDiffWidgetContext();
1450
1474
  const setWidget = useWidget.getReadonlyState().setWidget;
1451
1475
  const unifiedItem = diffFile.getUnifiedLine(index);
@@ -1486,7 +1510,7 @@ const DiffUnifiedWidgetLine = ({ index, diffFile, lineNumber, }) => {
1486
1510
  }, [diffFile, index]), (p, c) => p === c);
1487
1511
  if (!currentIsShow)
1488
1512
  return null;
1489
- return React.createElement(_DiffUnifiedWidgetLine, { index: index, diffFile: diffFile, lineNumber: lineNumber });
1513
+ return React.createElement(InternalDiffUnifiedWidgetLine, { index: index, diffFile: diffFile, lineNumber: lineNumber });
1490
1514
  };
1491
1515
 
1492
1516
  /* eslint-disable @typescript-eslint/ban-ts-comment */
@@ -1553,8 +1577,17 @@ var SplitSide;
1553
1577
  SplitSide[SplitSide["old"] = 1] = "old";
1554
1578
  SplitSide[SplitSide["new"] = 2] = "new";
1555
1579
  })(SplitSide || (SplitSide = {}));
1556
- const _InternalDiffView = (props) => {
1557
- const { diffFile, className, style, diffViewMode, diffViewWrap, diffViewFontSize, diffViewHighlight, renderWidgetLine, renderExtendLine, extendData, diffViewAddWidget, onAddWidgetClick, } = props;
1580
+ var DiffModeEnum;
1581
+ (function (DiffModeEnum) {
1582
+ // github like
1583
+ DiffModeEnum[DiffModeEnum["SplitGitHub"] = 1] = "SplitGitHub";
1584
+ // gitlab like
1585
+ DiffModeEnum[DiffModeEnum["SplitGitLab"] = 2] = "SplitGitLab";
1586
+ DiffModeEnum[DiffModeEnum["Split"] = 3] = "Split";
1587
+ DiffModeEnum[DiffModeEnum["Unified"] = 4] = "Unified";
1588
+ })(DiffModeEnum || (DiffModeEnum = {}));
1589
+ const InternalDiffView = (props) => {
1590
+ const { diffFile, className, style, diffViewMode, diffViewWrap, diffViewFontSize, diffViewHighlight, renderWidgetLine, renderExtendLine, extendData, diffViewAddWidget, onAddWidgetClick, isMounted, } = props;
1558
1591
  const diffFileId = useMemo(() => diffFile.getId(), [diffFile]);
1559
1592
  const wrapperRef = useRef();
1560
1593
  // performance optimization
@@ -1562,17 +1595,40 @@ const _InternalDiffView = (props) => {
1562
1595
  // eslint-disable-next-line react-hooks/exhaustive-deps
1563
1596
  []);
1564
1597
  useEffect(() => {
1565
- const { id, setId, mode, setMode, enableAddWidget, setEnableAddWidget, enableHighlight, setEnableHighlight, enableWrap, setEnableWrap, setExtendData, fontSize, setFontSize, onAddWidgetClick: _onAddWidgetClick, setOnAddWidgetClick, renderExtendLine: _renderExtendLine, setRenderExtendLine, renderWidgetLine: _renderWidgetLine, setRenderWidgetLine, } = useDiffContext.getReadonlyState();
1566
- diffFileId && diffFileId !== id && setId(diffFileId);
1567
- diffViewMode && diffViewMode !== mode && setMode(diffViewMode);
1568
- diffViewAddWidget !== enableAddWidget && setEnableAddWidget(diffViewAddWidget);
1569
- diffViewHighlight !== enableHighlight && setEnableHighlight(diffViewHighlight);
1570
- diffViewWrap !== enableWrap && setEnableWrap(diffViewWrap);
1571
- extendData && setExtendData(extendData);
1572
- diffViewFontSize && diffViewFontSize !== fontSize && setFontSize(diffViewFontSize);
1573
- onAddWidgetClick !== _onAddWidgetClick.current && setOnAddWidgetClick({ current: onAddWidgetClick });
1574
- renderExtendLine !== _renderExtendLine && setRenderExtendLine(renderExtendLine);
1575
- renderWidgetLine !== _renderWidgetLine && setRenderWidgetLine(renderWidgetLine);
1598
+ const { id, setId, mode, setMode, mounted, setMounted, enableAddWidget, setEnableAddWidget, enableHighlight, setEnableHighlight, enableWrap, setEnableWrap, setExtendData, fontSize, setFontSize, onAddWidgetClick: _onAddWidgetClick, setOnAddWidgetClick, renderExtendLine: _renderExtendLine, setRenderExtendLine, renderWidgetLine: _renderWidgetLine, setRenderWidgetLine, } = useDiffContext.getReadonlyState();
1599
+ if (diffFileId && diffFileId !== id) {
1600
+ setId(diffFileId);
1601
+ }
1602
+ if (diffViewMode && diffViewMode !== mode) {
1603
+ setMode(diffViewMode);
1604
+ }
1605
+ if (mounted !== isMounted) {
1606
+ setMounted(isMounted);
1607
+ }
1608
+ if (diffViewAddWidget !== enableAddWidget) {
1609
+ setEnableAddWidget(diffViewAddWidget);
1610
+ }
1611
+ if (diffViewHighlight !== enableHighlight) {
1612
+ setEnableHighlight(diffViewHighlight);
1613
+ }
1614
+ if (diffViewWrap !== enableWrap) {
1615
+ setEnableWrap(diffViewWrap);
1616
+ }
1617
+ if (extendData) {
1618
+ setExtendData(extendData);
1619
+ }
1620
+ if (diffViewFontSize && diffViewFontSize !== fontSize) {
1621
+ setFontSize(diffViewFontSize);
1622
+ }
1623
+ if (onAddWidgetClick !== _onAddWidgetClick.current) {
1624
+ setOnAddWidgetClick({ current: onAddWidgetClick });
1625
+ }
1626
+ if (renderExtendLine !== _renderExtendLine) {
1627
+ setRenderExtendLine(renderExtendLine);
1628
+ }
1629
+ if (renderWidgetLine !== _renderWidgetLine) {
1630
+ setRenderWidgetLine(renderWidgetLine);
1631
+ }
1576
1632
  }, [
1577
1633
  useDiffContext,
1578
1634
  diffViewFontSize,
@@ -1581,6 +1637,7 @@ const _InternalDiffView = (props) => {
1581
1637
  diffViewWrap,
1582
1638
  diffViewAddWidget,
1583
1639
  diffFileId,
1640
+ isMounted,
1584
1641
  renderWidgetLine,
1585
1642
  renderExtendLine,
1586
1643
  extendData,
@@ -1596,14 +1653,14 @@ const _InternalDiffView = (props) => {
1596
1653
  }, [diffFile]);
1597
1654
  const value = useMemo(() => ({ useDiffContext }), [useDiffContext]);
1598
1655
  return (React.createElement(DiffViewContext.Provider, { value: value },
1599
- React.createElement("div", { className: "diff-tailwindcss-wrapper", "data-component": "git-diff-view", "data-theme": diffFile._getTheme() || "light", "data-version": "0.0.24", "data-highlighter": diffFile._getHighlighterName(), ref: wrapperRef },
1656
+ React.createElement("div", { className: "diff-tailwindcss-wrapper", "data-component": "git-diff-view", "data-theme": diffFile._getTheme() || "light", "data-version": "0.0.26", "data-highlighter": diffFile._getHighlighterName(), ref: wrapperRef },
1600
1657
  React.createElement("div", { className: "diff-style-root", style: {
1601
1658
  // @ts-ignore
1602
1659
  [diffFontSizeName]: diffViewFontSize + "px",
1603
1660
  } },
1604
- React.createElement("div", { suppressHydrationWarning: true, id: `diff-root${diffFileId}`, className: "diff-view-wrapper" + (className ? ` ${className}` : ""), style: style }, diffViewMode & DiffModeEnum.Split ? (React.createElement(DiffSplitView, { diffFile: diffFile })) : (React.createElement(DiffUnifiedView, { diffFile: diffFile })))))));
1661
+ React.createElement("div", { id: isMounted ? `diff-root${diffFileId}` : undefined, className: "diff-view-wrapper" + (className ? ` ${className}` : ""), style: style }, diffViewMode & DiffModeEnum.Split ? (React.createElement(DiffSplitView, { diffFile: diffFile })) : (React.createElement(DiffUnifiedView, { diffFile: diffFile })))))));
1605
1662
  };
1606
- const InternalDiffView = memo(_InternalDiffView);
1663
+ const MemoedInternalDiffView = memo(InternalDiffView);
1607
1664
  const DiffViewWithRef = (props, ref) => {
1608
1665
  var _a, _b;
1609
1666
  const { registerHighlighter, data, diffViewTheme, diffFile: _diffFile } = props, restProps = __rest(props, ["registerHighlighter", "data", "diffViewTheme", "diffFile"]);
@@ -1627,6 +1684,7 @@ const DiffViewWithRef = (props, ref) => {
1627
1684
  (_b = (_a = diffFileRef.current).clear) === null || _b === void 0 ? void 0 : _b.call(_a);
1628
1685
  diffFileRef.current = diffFile;
1629
1686
  }
1687
+ const isMounted = useIsMounted();
1630
1688
  useEffect(() => {
1631
1689
  if (_diffFile && diffFile) {
1632
1690
  _diffFile._addClonedInstance(diffFile);
@@ -1656,12 +1714,12 @@ const DiffViewWithRef = (props, ref) => {
1656
1714
  useImperativeHandle(ref, () => ({ getDiffFileInstance: () => diffFile }), [diffFile]);
1657
1715
  if (!diffFile)
1658
1716
  return null;
1659
- return (React.createElement(InternalDiffView, Object.assign({ key: diffFile.getId() }, restProps, { diffFile: diffFile, diffViewMode: restProps.diffViewMode || DiffModeEnum.SplitGitHub, diffViewFontSize: restProps.diffViewFontSize || 14 })));
1717
+ return (React.createElement(MemoedInternalDiffView, Object.assign({ key: diffFile.getId() }, restProps, { diffFile: diffFile, isMounted: isMounted, diffViewMode: restProps.diffViewMode || DiffModeEnum.SplitGitHub, diffViewFontSize: restProps.diffViewFontSize || 14 })));
1660
1718
  };
1661
1719
  const InnerDiffView = forwardRef(DiffViewWithRef);
1662
1720
  InnerDiffView.displayName = "DiffView";
1663
1721
  const DiffView = InnerDiffView;
1664
- const version = "0.0.24";
1722
+ const version = "0.0.26";
1665
1723
 
1666
- export { DiffModeEnum, DiffView, DiffViewContext, SplitSide, useDiffViewContext, version };
1724
+ export { DiffModeEnum, DiffView, SplitSide, version };
1667
1725
  //# sourceMappingURL=index.mjs.map