@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.
@@ -84,7 +84,7 @@ function __classPrivateFieldGet(receiver, state, kind, f) {
84
84
  }
85
85
 
86
86
  function __classPrivateFieldSet(receiver, state, value, kind, f) {
87
- 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");
87
+ 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");
88
88
  return (state.set(receiver, value)), value;
89
89
  }
90
90
 
@@ -207,7 +207,7 @@ const syncScroll = (left, right) => {
207
207
  const diffFontSizeName = "--diff-font-size--";
208
208
  const diffAsideWidthName = "--diff-aside-width--";
209
209
 
210
- // eslint-disable-next-line @typescript-eslint/ban-types
210
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
211
211
  const memoFunc = (func) => {
212
212
  const cache = {};
213
213
  return ((key) => {
@@ -233,6 +233,14 @@ const getSymbol = (symbol) => {
233
233
  }
234
234
  };
235
235
 
236
+ const useIsMounted = () => {
237
+ const [isMounted, setIsMounted] = React.useState(false);
238
+ React.useEffect(() => {
239
+ setIsMounted(true);
240
+ }, []);
241
+ return isMounted;
242
+ };
243
+
236
244
  const useUnmount = (cb, deps) => {
237
245
  const ref = React.useRef(cb);
238
246
  ref.current = cb;
@@ -409,11 +417,15 @@ const DiffContent = ({ diffLine, rawLine, syntaxLine, enableWrap, enableHighligh
409
417
  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 }))));
410
418
  };
411
419
 
420
+ const DiffViewContext = React.createContext(null);
421
+ DiffViewContext.displayName = "DiffViewContext";
422
+ const useDiffViewContext = () => React.useContext(DiffViewContext);
423
+
412
424
  const DiffWidgetContext = React.createContext(null);
413
425
  DiffWidgetContext.displayName = "DiffWidgetContext";
414
426
  const useDiffWidgetContext = () => React.useContext(DiffWidgetContext);
415
427
 
416
- const _DiffSplitLine$1 = ({ index, diffFile, lineNumber, side, }) => {
428
+ const InternalDiffSplitLine$1 = ({ index, diffFile, lineNumber, side, }) => {
417
429
  var _a, _b;
418
430
  const getCurrentSyntaxLine = side === exports.SplitSide.old ? diffFile.getOldSyntaxLine : diffFile.getNewSyntaxLine;
419
431
  const oldLine = diffFile.getSplitLeftLine(index);
@@ -454,13 +466,13 @@ const DiffSplitContentLine$1 = ({ index, diffFile, lineNumber, side, }) => {
454
466
  const currentLine = getCurrentLine(index);
455
467
  if (currentLine === null || currentLine === void 0 ? void 0 : currentLine.isHidden)
456
468
  return null;
457
- return React__namespace.createElement(_DiffSplitLine$1, { index: index, diffFile: diffFile, lineNumber: lineNumber, side: side });
469
+ return React__namespace.createElement(InternalDiffSplitLine$1, { index: index, diffFile: diffFile, lineNumber: lineNumber, side: side });
458
470
  };
459
471
 
460
472
  const useDomWidth = ({ selector, enable }) => {
461
473
  const [width, setWidth] = React.useState(0);
462
474
  const { useDiffContext } = useDiffViewContext();
463
- const id = useDiffContext(React.useCallback((s) => s.id, []));
475
+ const { id, mounted } = useDiffContext.useShallowStableSelector((s) => ({ id: s.id, mounted: s.mounted }));
464
476
  React.useEffect(() => {
465
477
  if (enable) {
466
478
  const container = document.querySelector(`#diff-root${id}`);
@@ -496,99 +508,95 @@ const useDomWidth = ({ selector, enable }) => {
496
508
  typedWrapper.setAttribute("data-observe", "height");
497
509
  return () => cleanCb();
498
510
  }
499
- }, [selector, enable, id]);
511
+ }, [selector, enable, id, mounted]);
500
512
  return width;
501
513
  };
502
514
 
503
- exports.DiffModeEnum = void 0;
504
- (function (DiffModeEnum) {
505
- // github like
506
- DiffModeEnum[DiffModeEnum["SplitGitHub"] = 1] = "SplitGitHub";
507
- // gitlab like
508
- DiffModeEnum[DiffModeEnum["SplitGitLab"] = 2] = "SplitGitLab";
509
- DiffModeEnum[DiffModeEnum["Split"] = 3] = "Split";
510
- DiffModeEnum[DiffModeEnum["Unified"] = 4] = "Unified";
511
- })(exports.DiffModeEnum || (exports.DiffModeEnum = {}));
512
- const DiffViewContext = React.createContext(null);
513
- DiffViewContext.displayName = "DiffViewContext";
514
- const useDiffViewContext = () => React.useContext(DiffViewContext);
515
-
516
- // TODO
517
515
  const useSyncHeight = ({ selector, wrapper, side, enable, }) => {
518
516
  const { useDiffContext } = useDiffViewContext();
519
- const id = useDiffContext(React.useCallback((s) => s.id, []));
517
+ const { id, mounted } = useDiffContext.useShallowStableSelector((s) => ({ id: s.id, mounted: s.mounted }));
520
518
  React.useEffect(() => {
521
519
  if (enable) {
522
- let clean = () => { };
523
- // fix the dom delay update
524
- const timer = setTimeout(() => {
525
- const container = document.querySelector(`#diff-root${id}`);
526
- const elements = Array.from((container === null || container === void 0 ? void 0 : container.querySelectorAll(selector)) || []);
527
- const wrappers = wrapper ? Array.from((container === null || container === void 0 ? void 0 : container.querySelectorAll(wrapper)) || []) : elements;
528
- if (elements.length === 2 && wrappers.length === 2) {
529
- const ele1 = elements[0];
530
- const ele2 = elements[1];
531
- const wrapper1 = wrappers[0];
532
- const wrapper2 = wrappers[1];
533
- const target = ele1.getAttribute("data-side") === side ? ele1 : ele2;
534
- const cb = () => {
535
- ele1.style.height = "auto";
536
- ele2.style.height = "auto";
537
- const rect1 = ele1.getBoundingClientRect();
538
- const rect2 = ele2.getBoundingClientRect();
539
- const maxHeight = Math.max(rect1.height, rect2.height);
540
- wrapper1.style.height = maxHeight + "px";
541
- wrapper2.style.height = maxHeight + "px";
542
- wrapper1.setAttribute("data-sync-height", String(maxHeight));
543
- wrapper2.setAttribute("data-sync-height", String(maxHeight));
544
- };
545
- cb();
546
- const observer = new ResizeObserver(cb);
547
- observer.observe(target);
548
- target.setAttribute("data-observe", "height");
549
- clean = () => {
550
- observer.disconnect();
551
- target === null || target === void 0 ? void 0 : target.removeAttribute("data-observe");
552
- };
520
+ const container = document.querySelector(`#diff-root${id}`);
521
+ const elements = Array.from((container === null || container === void 0 ? void 0 : container.querySelectorAll(selector)) || []);
522
+ const wrappers = wrapper ? Array.from((container === null || container === void 0 ? void 0 : container.querySelectorAll(wrapper)) || []) : elements;
523
+ if (elements.length === 2 && wrappers.length === 2) {
524
+ const ele1 = elements[0];
525
+ const ele2 = elements[1];
526
+ const wrapper1 = wrappers[0];
527
+ const wrapper2 = wrappers[1];
528
+ const target = ele1.getAttribute("data-side") === side ? ele1 : ele2;
529
+ const typedTarget = target;
530
+ const cb = () => {
531
+ ele1.style.height = "auto";
532
+ ele2.style.height = "auto";
533
+ const rect1 = ele1.getBoundingClientRect();
534
+ const rect2 = ele2.getBoundingClientRect();
535
+ const maxHeight = Math.max(rect1.height, rect2.height);
536
+ wrapper1.style.height = maxHeight + "px";
537
+ wrapper2.style.height = maxHeight + "px";
538
+ wrapper1.setAttribute("data-sync-height", String(maxHeight));
539
+ wrapper2.setAttribute("data-sync-height", String(maxHeight));
540
+ };
541
+ cb();
542
+ const cleanCb = () => {
543
+ var _a;
544
+ typedTarget.__observeCallback.delete(cb);
545
+ if (typedTarget.__observeCallback.size === 0) {
546
+ (_a = typedTarget.__observeInstance) === null || _a === void 0 ? void 0 : _a.disconnect();
547
+ typedTarget.removeAttribute("data-observe");
548
+ delete typedTarget.__observeCallback;
549
+ delete typedTarget.__observeInstance;
550
+ }
551
+ };
552
+ if (typedTarget.__observeCallback) {
553
+ typedTarget.__observeCallback.add(cb);
554
+ return () => cleanCb();
553
555
  }
554
- });
555
- return () => {
556
- clean();
557
- clearTimeout(timer);
558
- };
556
+ typedTarget.__observeCallback = new Set();
557
+ typedTarget.__observeCallback.add(cb);
558
+ const observer = new ResizeObserver(() => typedTarget.__observeCallback.forEach((cb) => cb()));
559
+ typedTarget.__observeInstance = observer;
560
+ observer.observe(target);
561
+ target.setAttribute("data-observe", "height");
562
+ return () => cleanCb();
563
+ }
559
564
  }
560
- }, [selector, enable, side, id, wrapper]);
565
+ }, [selector, enable, side, id, wrapper, mounted]);
561
566
  };
562
567
 
563
- const _DiffSplitExtendLine$1 = ({ index, diffFile, oldLineExtend, newLineExtend, side, lineNumber, }) => {
568
+ const InternalDiffSplitExtendLine$1 = ({ index, diffFile, oldLineExtend, newLineExtend, side, lineNumber, }) => {
564
569
  const { useDiffContext } = useDiffViewContext();
565
570
  const oldLine = diffFile.getSplitLeftLine(index);
566
571
  const newLine = diffFile.getSplitRightLine(index);
567
572
  const renderExtendLine = useDiffContext.useShallowStableSelector((s) => s.renderExtendLine);
568
573
  const currentExtend = side === exports.SplitSide.old ? oldLineExtend : newLineExtend;
574
+ const otherSide = side === exports.SplitSide.old ? exports.SplitSide.new : exports.SplitSide.old;
569
575
  const currentLineNumber = side === exports.SplitSide.old ? oldLine.lineNumber : newLine.lineNumber;
570
- const hasExtend = (currentExtend === null || currentExtend === void 0 ? void 0 : currentExtend.data) !== undefined && (currentExtend === null || currentExtend === void 0 ? void 0 : currentExtend.data) !== null;
576
+ const currentSideHasExtend = (currentExtend === null || currentExtend === void 0 ? void 0 : currentExtend.data) !== undefined && (currentExtend === null || currentExtend === void 0 ? void 0 : currentExtend.data) !== null;
577
+ const hasExtend = ((oldLineExtend === null || oldLineExtend === void 0 ? void 0 : oldLineExtend.data) !== undefined && (oldLineExtend === null || oldLineExtend === void 0 ? void 0 : oldLineExtend.data) !== null) ||
578
+ ((newLineExtend === null || newLineExtend === void 0 ? void 0 : newLineExtend.data) !== undefined && (newLineExtend === null || newLineExtend === void 0 ? void 0 : newLineExtend.data) !== null);
571
579
  const currentExtendRendered = hasExtend &&
572
580
  (renderExtendLine === null || renderExtendLine === void 0 ? void 0 : renderExtendLine({
573
581
  diffFile,
574
582
  side,
575
583
  lineNumber: currentLineNumber,
576
- data: currentExtend.data,
584
+ data: currentExtend === null || currentExtend === void 0 ? void 0 : currentExtend.data,
577
585
  onUpdate: diffFile.notifyAll,
578
586
  }));
579
587
  useSyncHeight({
580
588
  selector: `div[data-line="${lineNumber}-extend-content"]`,
581
589
  wrapper: `tr[data-line="${lineNumber}-extend"]`,
582
- side: exports.SplitSide[side],
590
+ side: exports.SplitSide[currentSideHasExtend ? side : otherSide],
583
591
  enable: hasExtend && typeof renderExtendLine === "function",
584
592
  });
585
593
  const width = useDomWidth({
586
594
  selector: side === exports.SplitSide.old ? ".old-diff-table-wrapper" : ".new-diff-table-wrapper",
587
- enable: hasExtend && typeof renderExtendLine === "function",
595
+ enable: currentSideHasExtend && typeof renderExtendLine === "function",
588
596
  });
589
597
  if (!renderExtendLine)
590
598
  return null;
591
- return (React__namespace.createElement("tr", { "data-line": `${lineNumber}-extend`, "data-state": "extend", "data-side": exports.SplitSide[side], className: "diff-line diff-line-extend" }, hasExtend ? (React__namespace.createElement("td", { className: `diff-line-extend-${exports.SplitSide[side]}-content p-0`, colSpan: 2 },
599
+ return (React__namespace.createElement("tr", { "data-line": `${lineNumber}-extend`, "data-state": "extend", "data-side": exports.SplitSide[side], className: "diff-line diff-line-extend" }, currentSideHasExtend ? (React__namespace.createElement("td", { className: `diff-line-extend-${exports.SplitSide[side]}-content p-0`, colSpan: 2 },
592
600
  React__namespace.createElement("div", { "data-line": `${lineNumber}-extend-content`, "data-side": exports.SplitSide[side], className: "diff-line-extend-wrapper sticky left-0", style: { width } }, width > 0 && currentExtendRendered))) : (React__namespace.createElement("td", { className: `diff-line-extend-${exports.SplitSide[side]}-placeholder select-none p-0`, style: { backgroundColor: `var(${emptyBGName})` }, colSpan: 2 },
593
601
  React__namespace.createElement("div", { "data-line": `${lineNumber}-extend-content`, "data-side": exports.SplitSide[side] })))));
594
602
  };
@@ -610,7 +618,7 @@ const DiffSplitExtendLine$1 = ({ index, diffFile, side, lineNumber, }) => {
610
618
  const currentIsShow = hasExtend && (!currentLine.isHidden || !enableExpand);
611
619
  if (!currentIsShow)
612
620
  return null;
613
- return (React__namespace.createElement(_DiffSplitExtendLine$1, { side: side, index: index, diffFile: diffFile, lineNumber: lineNumber, oldLineExtend: oldLineExtend, newLineExtend: newLineExtend }));
621
+ return (React__namespace.createElement(InternalDiffSplitExtendLine$1, { side: side, index: index, diffFile: diffFile, lineNumber: lineNumber, oldLineExtend: oldLineExtend, newLineExtend: newLineExtend }));
614
622
  };
615
623
 
616
624
  const ExpandDown = ({ className }) => {
@@ -626,7 +634,7 @@ const ExpandAll = ({ className }) => {
626
634
  React__namespace.createElement("path", { d: "m8.177.677 2.896 2.896a.25.25 0 0 1-.177.427H8.75v1.25a.75.75 0 0 1-1.5 0V4H5.104a.25.25 0 0 1-.177-.427L7.823.677a.25.25 0 0 1 .354 0ZM7.25 10.75a.75.75 0 0 1 1.5 0V12h2.146a.25.25 0 0 1 .177.427l-2.896 2.896a.25.25 0 0 1-.354 0l-2.896-2.896A.25.25 0 0 1 5.104 12H7.25v-1.25Zm-5-2a.75.75 0 0 0 0-1.5h-.5a.75.75 0 0 0 0 1.5h.5ZM6 8a.75.75 0 0 1-.75.75h-.5a.75.75 0 0 1 0-1.5h.5A.75.75 0 0 1 6 8Zm2.25.75a.75.75 0 0 0 0-1.5h-.5a.75.75 0 0 0 0 1.5h.5ZM12 8a.75.75 0 0 1-.75.75h-.5a.75.75 0 0 1 0-1.5h.5A.75.75 0 0 1 12 8Zm2.25.75a.75.75 0 0 0 0-1.5h-.5a.75.75 0 0 0 0 1.5h.5Z" })));
627
635
  };
628
636
 
629
- const _DiffSplitHunkLineGitHub = ({ index, diffFile, side, lineNumber, }) => {
637
+ const InternalDiffSplitHunkLineGitHub = ({ index, diffFile, side, lineNumber, }) => {
630
638
  var _a;
631
639
  const currentHunk = diffFile.getSplitHunkLine(index);
632
640
  const expandEnabled = diffFile.getExpandEnabled();
@@ -650,9 +658,7 @@ const _DiffSplitHunkLineGitHub = ({ index, diffFile, side, lineNumber, }) => {
650
658
  minWidth: `var(${diffAsideWidthName})`,
651
659
  maxWidth: `var(${diffAsideWidthName})`,
652
660
  } }, couldExpand ? (isFirstLine ? (React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index) },
653
- 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]", title: "Expand Down", "data-title": "Expand Down", onClick: () => {
654
- diffFile.onSplitHunkExpand("down", index);
655
- } },
661
+ 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]", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onSplitHunkExpand("down", index) },
656
662
  React__namespace.createElement(ExpandDown, { className: "fill-current" }))) : isExpandAll ? (React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]", title: "Expand All", "data-title": "Expand All", onClick: () => diffFile.onSplitHunkExpand("all", index) },
657
663
  React__namespace.createElement(ExpandAll, { className: "fill-current" }))) : (React__namespace.createElement(React__namespace.Fragment, null,
658
664
  React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onSplitHunkExpand("down", index) },
@@ -665,7 +671,7 @@ const _DiffSplitHunkLineGitHub = ({ index, diffFile, side, lineNumber, }) => {
665
671
  } }, ((_a = currentHunk.splitInfo) === null || _a === void 0 ? void 0 : _a.plainText) || currentHunk.text)))) : (React__namespace.createElement("td", { className: "diff-line-hunk-placeholder select-none", colSpan: 2, style: { backgroundColor: `var(${hunkContentBGName})` } },
666
672
  React__namespace.createElement("div", { className: "min-h-[28px]" }, "\u2002")))));
667
673
  };
668
- const _DiffSplitHunkLineGitLab = ({ index, diffFile, side, lineNumber, }) => {
674
+ const InternalDiffSplitHunkLineGitLab = ({ index, diffFile, side, lineNumber, }) => {
669
675
  var _a;
670
676
  const currentHunk = diffFile.getSplitHunkLine(index);
671
677
  const expandEnabled = diffFile.getExpandEnabled();
@@ -688,9 +694,7 @@ const _DiffSplitHunkLineGitLab = ({ index, diffFile, side, lineNumber, }) => {
688
694
  minWidth: `var(${diffAsideWidthName})`,
689
695
  maxWidth: `var(${diffAsideWidthName})`,
690
696
  } }, couldExpand ? (isFirstLine ? (React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index) },
691
- 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]", title: "Expand Down", "data-title": "Expand Down", onClick: () => {
692
- diffFile.onSplitHunkExpand("down", index);
693
- } },
697
+ 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]", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onSplitHunkExpand("down", index) },
694
698
  React__namespace.createElement(ExpandDown, { className: "fill-current" }))) : isExpandAll ? (React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]", title: "Expand All", "data-title": "Expand All", onClick: () => diffFile.onSplitHunkExpand("all", index) },
695
699
  React__namespace.createElement(ExpandAll, { className: "fill-current" }))) : (React__namespace.createElement(React__namespace.Fragment, null,
696
700
  React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onSplitHunkExpand("down", index) },
@@ -702,16 +706,16 @@ const _DiffSplitHunkLineGitLab = ({ index, diffFile, side, lineNumber, }) => {
702
706
  color: `var(${hunkContentColorName})`,
703
707
  } }, ((_a = currentHunk.splitInfo) === null || _a === void 0 ? void 0 : _a.plainText) || currentHunk.text))));
704
708
  };
705
- const _DiffSplitHunkLine$1 = ({ index, diffFile, side, lineNumber, }) => {
709
+ const InternalDiffSplitHunkLine$1 = ({ index, diffFile, side, lineNumber, }) => {
706
710
  const { useDiffContext } = useDiffViewContext();
707
711
  const diffViewMode = useDiffContext.useShallowStableSelector((s) => s.mode);
708
712
  if (diffViewMode === exports.DiffModeEnum.SplitGitHub ||
709
713
  diffViewMode === exports.DiffModeEnum.Split ||
710
714
  diffViewMode === exports.DiffModeEnum.Unified) {
711
- return React__namespace.createElement(_DiffSplitHunkLineGitHub, { index: index, diffFile: diffFile, side: side, lineNumber: lineNumber });
715
+ return React__namespace.createElement(InternalDiffSplitHunkLineGitHub, { index: index, diffFile: diffFile, side: side, lineNumber: lineNumber });
712
716
  }
713
717
  else {
714
- return React__namespace.createElement(_DiffSplitHunkLineGitLab, { index: index, diffFile: diffFile, side: side, lineNumber: lineNumber });
718
+ return React__namespace.createElement(InternalDiffSplitHunkLineGitLab, { index: index, diffFile: diffFile, side: side, lineNumber: lineNumber });
715
719
  }
716
720
  };
717
721
  const DiffSplitHunkLine$1 = ({ index, diffFile, side, lineNumber, }) => {
@@ -722,10 +726,10 @@ const DiffSplitHunkLine$1 = ({ index, diffFile, side, lineNumber, }) => {
722
726
  const currentIsPureHunk = currentHunk && diffFile._getIsPureDiffRender() && !currentHunk.splitInfo;
723
727
  if (!currentIsShow && !currentIsPureHunk)
724
728
  return null;
725
- return React__namespace.createElement(_DiffSplitHunkLine$1, { index: index, diffFile: diffFile, side: side, lineNumber: lineNumber });
729
+ return React__namespace.createElement(InternalDiffSplitHunkLine$1, { index: index, diffFile: diffFile, side: side, lineNumber: lineNumber });
726
730
  };
727
731
 
728
- const _DiffSplitWidgetLine$1 = ({ index, side, diffFile, lineNumber, }) => {
732
+ const InternalDiffSplitWidgetLine$1 = ({ index, side, diffFile, lineNumber, }) => {
729
733
  const { useWidget } = useDiffWidgetContext();
730
734
  const { useDiffContext } = useDiffViewContext();
731
735
  const oldLine = diffFile.getSplitLeftLine(index);
@@ -736,9 +740,11 @@ const _DiffSplitWidgetLine$1 = ({ index, side, diffFile, lineNumber, }) => {
736
740
  const oldLineWidget = oldLine.lineNumber && widgetSide === exports.SplitSide.old && widgetLineNumber === oldLine.lineNumber;
737
741
  const newLineWidget = newLine.lineNumber && widgetSide === exports.SplitSide.new && widgetLineNumber === newLine.lineNumber;
738
742
  const currentLine = side === exports.SplitSide.old ? oldLine : newLine;
739
- const currentWidget = side === exports.SplitSide.old ? oldLineWidget : newLineWidget;
743
+ const otherSide = side === exports.SplitSide.old ? exports.SplitSide.new : exports.SplitSide.old;
744
+ const currentHasWidget = side === exports.SplitSide.old ? oldLineWidget : newLineWidget;
745
+ const hasWidget = oldLineWidget || newLineWidget;
740
746
  const renderWidgetLine = useDiffContext.useShallowStableSelector((s) => s.renderWidgetLine);
741
- const currentWidgetRendered = currentWidget &&
747
+ const currentWidgetRendered = currentHasWidget &&
742
748
  (renderWidgetLine === null || renderWidgetLine === void 0 ? void 0 : renderWidgetLine({
743
749
  diffFile,
744
750
  side,
@@ -748,16 +754,16 @@ const _DiffSplitWidgetLine$1 = ({ index, side, diffFile, lineNumber, }) => {
748
754
  useSyncHeight({
749
755
  selector: `div[data-line="${lineNumber}-widget-content"]`,
750
756
  wrapper: `tr[data-line="${lineNumber}-widget"]`,
751
- side: exports.SplitSide[side],
752
- enable: !!currentWidget && typeof renderWidgetLine === "function",
757
+ side: exports.SplitSide[currentHasWidget ? side : otherSide],
758
+ enable: hasWidget && typeof renderWidgetLine === "function",
753
759
  });
754
760
  const width = useDomWidth({
755
761
  selector: side === exports.SplitSide.old ? ".old-diff-table-wrapper" : ".new-diff-table-wrapper",
756
- enable: !!currentWidget && typeof renderWidgetLine === "function",
762
+ enable: !!currentHasWidget && typeof renderWidgetLine === "function",
757
763
  });
758
764
  if (!renderWidgetLine)
759
765
  return null;
760
- return (React__namespace.createElement("tr", { "data-line": `${lineNumber}-widget`, "data-state": "widget", "data-side": exports.SplitSide[side], className: "diff-line diff-line-widget" }, currentWidget ? (React__namespace.createElement("td", { className: `diff-line-widget-${exports.SplitSide[side]}-content p-0`, colSpan: 2 },
766
+ return (React__namespace.createElement("tr", { "data-line": `${lineNumber}-widget`, "data-state": "widget", "data-side": exports.SplitSide[side], className: "diff-line diff-line-widget" }, currentHasWidget ? (React__namespace.createElement("td", { className: `diff-line-widget-${exports.SplitSide[side]}-content p-0`, colSpan: 2 },
761
767
  React__namespace.createElement("div", { "data-line": `${lineNumber}-widget-content`, "data-side": exports.SplitSide[side], className: "diff-line-widget-wrapper sticky left-0", style: { width } }, width > 0 && currentWidgetRendered))) : (React__namespace.createElement("td", { className: `diff-line-widget-${exports.SplitSide[side]}-placeholder p-0`, style: { backgroundColor: `var(${emptyBGName})` }, colSpan: 2 },
762
768
  React__namespace.createElement("div", { "data-line": `${lineNumber}-widget-content`, "data-side": exports.SplitSide[side] })))));
763
769
  };
@@ -776,7 +782,7 @@ const DiffSplitWidgetLine$1 = ({ index, side, diffFile, lineNumber, }) => {
776
782
  }, [diffFile, index]), (p, c) => p === c);
777
783
  if (!currentIsShow)
778
784
  return null;
779
- return React__namespace.createElement(_DiffSplitWidgetLine$1, { index: index, side: side, diffFile: diffFile, lineNumber: lineNumber });
785
+ return React__namespace.createElement(InternalDiffSplitWidgetLine$1, { index: index, side: side, diffFile: diffFile, lineNumber: lineNumber });
780
786
  };
781
787
 
782
788
  /* eslint-disable @typescript-eslint/ban-ts-comment */
@@ -852,7 +858,7 @@ const DiffSplitViewNormal = React.memo(({ diffFile }) => {
852
858
  });
853
859
  DiffSplitViewNormal.displayName = "DiffSplitViewNormal";
854
860
 
855
- const _DiffSplitLine = ({ index, diffFile, lineNumber }) => {
861
+ const InternalDiffSplitLine = ({ index, diffFile, lineNumber, }) => {
856
862
  var _a, _b;
857
863
  const oldLine = diffFile.getSplitLeftLine(index);
858
864
  const newLine = diffFile.getSplitRightLine(index);
@@ -890,12 +896,17 @@ const _DiffSplitLine = ({ index, diffFile, lineNumber }) => {
890
896
  backgroundColor: newLineNumberBG,
891
897
  color: `var(${plainLineNumberColorName})`,
892
898
  borderLeftColor: `var(${borderColorName})`,
899
+ borderLeftStyle: "solid",
893
900
  } },
894
901
  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 }) })),
895
902
  React__namespace.createElement("span", { "data-line-num": newLine.lineNumber, style: { opacity: hasChange ? undefined : 0.5 } }, newLine.lineNumber)),
896
903
  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 } },
897
904
  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 }) })),
898
- 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]", style: { backgroundColor: `var(${emptyBGName})`, borderLeftColor: `var(${borderColorName})` }, "data-side": exports.SplitSide[exports.SplitSide.new], colSpan: 2 },
905
+ 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]", style: {
906
+ backgroundColor: `var(${emptyBGName})`,
907
+ borderLeftColor: `var(${borderColorName})`,
908
+ borderLeftStyle: "solid",
909
+ }, "data-side": exports.SplitSide[exports.SplitSide.new], colSpan: 2 },
899
910
  React__namespace.createElement("span", null, "\u2002")))));
900
911
  };
901
912
  const DiffSplitContentLine = ({ index, diffFile, lineNumber, }) => {
@@ -903,10 +914,10 @@ const DiffSplitContentLine = ({ index, diffFile, lineNumber, }) => {
903
914
  const newLine = diffFile.getSplitRightLine(index);
904
915
  if ((oldLine === null || oldLine === void 0 ? void 0 : oldLine.isHidden) && (newLine === null || newLine === void 0 ? void 0 : newLine.isHidden))
905
916
  return null;
906
- return React__namespace.createElement(_DiffSplitLine, { index: index, diffFile: diffFile, lineNumber: lineNumber });
917
+ return React__namespace.createElement(InternalDiffSplitLine, { index: index, diffFile: diffFile, lineNumber: lineNumber });
907
918
  };
908
919
 
909
- const _DiffSplitExtendLine = ({ index, diffFile, lineNumber, oldLineExtend, newLineExtend, }) => {
920
+ const InternalDiffSplitExtendLine = ({ index, diffFile, lineNumber, oldLineExtend, newLineExtend, }) => {
910
921
  const { useDiffContext } = useDiffViewContext();
911
922
  const oldLine = diffFile.getSplitLeftLine(index);
912
923
  const newLine = diffFile.getSplitRightLine(index);
@@ -933,8 +944,12 @@ const _DiffSplitExtendLine = ({ index, diffFile, lineNumber, oldLineExtend, newL
933
944
  return (React__namespace.createElement("tr", { "data-line": `${lineNumber}-extend`, "data-state": "extend", className: "diff-line diff-line-extend" },
934
945
  oldExtendRendered ? (React__namespace.createElement("td", { className: "diff-line-extend-old-content p-0", colSpan: 2 },
935
946
  React__namespace.createElement("div", { className: "diff-line-extend-wrapper" }, oldExtendRendered))) : (React__namespace.createElement("td", { className: "diff-line-extend-old-placeholder select-none p-0", style: { backgroundColor: `var(${emptyBGName})` }, colSpan: 2 }, newExtendRendered && React__namespace.createElement("span", null, "\u2002"))),
936
- newExtendRendered ? (React__namespace.createElement("td", { className: "diff-line-extend-new-content border-l-[1px] p-0", style: { borderLeftColor: `var(${borderColorName})` }, colSpan: 2 },
937
- React__namespace.createElement("div", { className: "diff-line-extend-wrapper" }, newExtendRendered))) : (React__namespace.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__namespace.createElement("span", null, "\u2002")))));
947
+ newExtendRendered ? (React__namespace.createElement("td", { className: "diff-line-extend-new-content border-l-[1px] p-0", style: { borderLeftColor: `var(${borderColorName})`, borderLeftStyle: "solid" }, colSpan: 2 },
948
+ React__namespace.createElement("div", { className: "diff-line-extend-wrapper" }, newExtendRendered))) : (React__namespace.createElement("td", { className: "diff-line-extend-new-placeholder select-none border-l-[1px] p-0", style: {
949
+ backgroundColor: `var(${emptyBGName})`,
950
+ borderLeftColor: `var(${borderColorName})`,
951
+ borderLeftStyle: "solid",
952
+ }, colSpan: 2 }, oldExtendRendered && React__namespace.createElement("span", null, "\u2002")))));
938
953
  };
939
954
  const DiffSplitExtendLine = ({ index, diffFile, lineNumber, }) => {
940
955
  const { useDiffContext } = useDiffViewContext();
@@ -953,7 +968,7 @@ const DiffSplitExtendLine = ({ index, diffFile, lineNumber, }) => {
953
968
  const currentIsShow = hasExtend && ((!(oldLine === null || oldLine === void 0 ? void 0 : oldLine.isHidden) && !(newLine === null || newLine === void 0 ? void 0 : newLine.isHidden)) || !enableExpand);
954
969
  if (!currentIsShow)
955
970
  return null;
956
- return (React__namespace.createElement(_DiffSplitExtendLine, { index: index, diffFile: diffFile, lineNumber: lineNumber, oldLineExtend: oldLineExtend, newLineExtend: newLineExtend }));
971
+ return (React__namespace.createElement(InternalDiffSplitExtendLine, { index: index, diffFile: diffFile, lineNumber: lineNumber, oldLineExtend: oldLineExtend, newLineExtend: newLineExtend }));
957
972
  };
958
973
 
959
974
  const DiffSplitHunkLineGitHub = ({ index, diffFile, lineNumber, }) => {
@@ -1009,10 +1024,11 @@ const DiffSplitHunkLineGitLab = ({ index, diffFile, lineNumber, }) => {
1009
1024
  React__namespace.createElement("div", { className: "pl-[1.5em]", style: {
1010
1025
  color: `var(${hunkContentColorName})`,
1011
1026
  } }, ((_a = currentHunk.splitInfo) === null || _a === void 0 ? void 0 : _a.plainText) || currentHunk.text)),
1012
- React__namespace.createElement("td", { className: "diff-line-hunk-action relative w-[1%] min-w-[40px] select-none border-l-[1px] p-[1px]", style: {
1027
+ React__namespace.createElement("td", { className: "diff-line-hunk-action relative z-[1] w-[1%] min-w-[40px] select-none border-l-[1px] p-[1px]", style: {
1013
1028
  backgroundColor: `var(${hunkLineNumberBGName})`,
1014
1029
  color: `var(${plainLineNumberColorName})`,
1015
1030
  borderLeftColor: `var(${borderColorName})`,
1031
+ borderLeftStyle: "solid",
1016
1032
  } }, couldExpand ? (isFirstLine ? (React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index) },
1017
1033
  React__namespace.createElement(ExpandUp, { className: "fill-current" }))) : isLastLine ? (React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onSplitHunkExpand("down", index) },
1018
1034
  React__namespace.createElement(ExpandDown, { className: "fill-current" }))) : isExpandAll ? (React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]", title: "Expand All", "data-title": "Expand All", onClick: () => diffFile.onSplitHunkExpand("all", index) },
@@ -1026,7 +1042,7 @@ const DiffSplitHunkLineGitLab = ({ index, diffFile, lineNumber, }) => {
1026
1042
  color: `var(${hunkContentColorName})`,
1027
1043
  } }, ((_b = currentHunk.splitInfo) === null || _b === void 0 ? void 0 : _b.plainText) || currentHunk.text))));
1028
1044
  };
1029
- const _DiffSplitHunkLine = ({ index, diffFile, lineNumber, }) => {
1045
+ const InternalDiffSplitHunkLine = ({ index, diffFile, lineNumber, }) => {
1030
1046
  const { useDiffContext } = useDiffViewContext();
1031
1047
  const diffViewMode = useDiffContext.useShallowStableSelector((s) => s.mode);
1032
1048
  if (diffViewMode === exports.DiffModeEnum.SplitGitHub ||
@@ -1046,10 +1062,10 @@ const DiffSplitHunkLine = ({ index, diffFile, lineNumber, }) => {
1046
1062
  const currentIsPureHunk = currentHunk && diffFile._getIsPureDiffRender() && !currentHunk.splitInfo;
1047
1063
  if (!currentIsShow && !currentIsPureHunk)
1048
1064
  return null;
1049
- return React__namespace.createElement(_DiffSplitHunkLine, { index: index, diffFile: diffFile, lineNumber: lineNumber });
1065
+ return React__namespace.createElement(InternalDiffSplitHunkLine, { index: index, diffFile: diffFile, lineNumber: lineNumber });
1050
1066
  };
1051
1067
 
1052
- const _DiffSplitWidgetLine = ({ index, diffFile, lineNumber, }) => {
1068
+ const InternalDiffSplitWidgetLine = ({ index, diffFile, lineNumber, }) => {
1053
1069
  const { useWidget } = useDiffWidgetContext();
1054
1070
  const setWidget = useWidget.getReadonlyState().setWidget;
1055
1071
  const { useDiffContext } = useDiffViewContext();
@@ -1069,8 +1085,12 @@ const _DiffSplitWidgetLine = ({ index, diffFile, lineNumber, }) => {
1069
1085
  return (React__namespace.createElement("tr", { "data-line": `${lineNumber}-widget`, "data-state": "widget", className: "diff-line diff-line-widget" },
1070
1086
  oldWidgetRendered ? (React__namespace.createElement("td", { className: "diff-line-widget-old-content p-0", colSpan: 2 },
1071
1087
  React__namespace.createElement("div", { className: "diff-line-widget-wrapper" }, oldWidgetRendered))) : (React__namespace.createElement("td", { className: "diff-line-widget-old-placeholder select-none p-0", style: { backgroundColor: `var(${emptyBGName})` }, colSpan: 2 }, newWidgetRendered && React__namespace.createElement("span", null, "\u2002"))),
1072
- newWidgetRendered ? (React__namespace.createElement("td", { className: "diff-line-widget-new-content border-l-[1px] p-0", colSpan: 2, style: { borderLeftColor: `var(${borderColorName})` } },
1073
- React__namespace.createElement("div", { className: "diff-line-widget-wrapper" }, newWidgetRendered))) : (React__namespace.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__namespace.createElement("span", null, "\u2002")))));
1088
+ newWidgetRendered ? (React__namespace.createElement("td", { className: "diff-line-widget-new-content border-l-[1px] p-0", colSpan: 2, style: { borderLeftColor: `var(${borderColorName})`, borderLeftStyle: "solid" } },
1089
+ React__namespace.createElement("div", { className: "diff-line-widget-wrapper" }, newWidgetRendered))) : (React__namespace.createElement("td", { className: "diff-line-widget-new-placeholder select-none border-l-[1px] p-0", style: {
1090
+ backgroundColor: `var(${emptyBGName})`,
1091
+ borderLeftColor: `var(${borderColorName})`,
1092
+ borderLeftStyle: "solid",
1093
+ }, colSpan: 2 }, oldWidgetRendered && React__namespace.createElement("span", null, "\u2002")))));
1074
1094
  };
1075
1095
  // TODO! improve performance
1076
1096
  const DiffSplitWidgetLine = ({ index, diffFile, lineNumber, }) => {
@@ -1087,7 +1107,7 @@ const DiffSplitWidgetLine = ({ index, diffFile, lineNumber, }) => {
1087
1107
  }, [diffFile, index]), (p, c) => p === c);
1088
1108
  if (!currentIsShow)
1089
1109
  return null;
1090
- return React__namespace.createElement(_DiffSplitWidgetLine, { index: index, diffFile: diffFile, lineNumber: lineNumber });
1110
+ return React__namespace.createElement(InternalDiffSplitWidgetLine, { index: index, diffFile: diffFile, lineNumber: lineNumber });
1091
1111
  };
1092
1112
 
1093
1113
  const createDiffConfigStore = (props, diffFileId) => {
@@ -1097,6 +1117,8 @@ const createDiffConfigStore = (props, diffFileId) => {
1097
1117
  const setId = (_id) => (id.value = _id);
1098
1118
  const mode = reactivityStore.ref(props.diffViewMode);
1099
1119
  const setMode = (_mode) => (mode.value = _mode);
1120
+ const mounted = reactivityStore.ref(props.isMounted);
1121
+ const setMounted = (_mounted) => (mounted.value = _mounted);
1100
1122
  const enableWrap = reactivityStore.ref(props.diffViewWrap);
1101
1123
  const setEnableWrap = (_enableWrap) => (enableWrap.value = _enableWrap);
1102
1124
  const enableAddWidget = reactivityStore.ref(props.diffViewAddWidget);
@@ -1143,6 +1165,8 @@ const createDiffConfigStore = (props, diffFileId) => {
1143
1165
  setId,
1144
1166
  mode,
1145
1167
  setMode,
1168
+ mounted,
1169
+ setMounted,
1146
1170
  enableWrap,
1147
1171
  setEnableWrap,
1148
1172
  enableAddWidget,
@@ -1369,7 +1393,7 @@ const DiffUnifiedContentLine = ({ index, diffFile, lineNumber, }) => {
1369
1393
  return React__namespace.createElement(_DiffUnifiedLine, { index: index, diffFile: diffFile, lineNumber: lineNumber });
1370
1394
  };
1371
1395
 
1372
- const _DiffUnifiedExtendLine = ({ index, diffFile, lineNumber, oldLineExtend, newLineExtend, }) => {
1396
+ const InternalDiffUnifiedExtendLine = ({ index, diffFile, lineNumber, oldLineExtend, newLineExtend, }) => {
1373
1397
  const { useDiffContext } = useDiffViewContext();
1374
1398
  const renderExtendLine = useDiffContext.useShallowStableSelector((s) => s.renderExtendLine);
1375
1399
  const unifiedItem = diffFile.getUnifiedLine(index);
@@ -1414,12 +1438,12 @@ const DiffUnifiedExtendLine = ({ index, diffFile, lineNumber, }) => {
1414
1438
  });
1415
1439
  }, [unifiedItem.oldLineNumber, unifiedItem.newLineNumber]));
1416
1440
  const hasExtend = (oldLineExtend === null || oldLineExtend === void 0 ? void 0 : oldLineExtend.data) || (newLineExtend === null || newLineExtend === void 0 ? void 0 : newLineExtend.data);
1417
- if (!hasExtend || !unifiedItem || unifiedItem.isHidden || !unifiedItem.diff)
1441
+ if (!hasExtend || !unifiedItem || unifiedItem.isHidden)
1418
1442
  return null;
1419
- return (React__namespace.createElement(_DiffUnifiedExtendLine, { index: index, diffFile: diffFile, lineNumber: lineNumber, oldLineExtend: oldLineExtend, newLineExtend: newLineExtend }));
1443
+ return (React__namespace.createElement(InternalDiffUnifiedExtendLine, { index: index, diffFile: diffFile, lineNumber: lineNumber, oldLineExtend: oldLineExtend, newLineExtend: newLineExtend }));
1420
1444
  };
1421
1445
 
1422
- const _DiffUnifiedHunkLine = ({ index, diffFile, lineNumber, }) => {
1446
+ const InternalDiffUnifiedHunkLine = ({ index, diffFile, lineNumber, }) => {
1423
1447
  var _a;
1424
1448
  const currentHunk = diffFile.getUnifiedHunkLine(index);
1425
1449
  const expandEnabled = diffFile.getExpandEnabled();
@@ -1438,13 +1462,13 @@ const _DiffUnifiedHunkLine = ({ index, diffFile, lineNumber, }) => {
1438
1462
  width: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
1439
1463
  maxWidth: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
1440
1464
  minWidth: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
1441
- } }, 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) },
1442
- 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) },
1443
- 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) },
1465
+ } }, couldExpand ? (isFirstLine ? (React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onUnifiedHunkExpand("up", index) },
1466
+ React__namespace.createElement(ExpandUp, { className: "fill-current" }))) : isLastLine ? (React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onUnifiedHunkExpand("down", index) },
1467
+ React__namespace.createElement(ExpandDown, { className: "fill-current" }))) : isExpandAll ? (React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]", title: "Expand All", "data-title": "Expand All", onClick: () => diffFile.onUnifiedHunkExpand("all", index) },
1444
1468
  React__namespace.createElement(ExpandAll, { className: "fill-current" }))) : (React__namespace.createElement(React__namespace.Fragment, null,
1445
- 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) },
1469
+ React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onUnifiedHunkExpand("down", index) },
1446
1470
  React__namespace.createElement(ExpandDown, { className: "fill-current" })),
1447
- 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) },
1471
+ React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onUnifiedHunkExpand("up", index) },
1448
1472
  React__namespace.createElement(ExpandUp, { className: "fill-current" }))))) : (React__namespace.createElement("div", { className: "min-h-[28px]" }, "\u2002"))),
1449
1473
  React__namespace.createElement("td", { className: "diff-line-hunk-content pr-[10px] align-middle", style: { backgroundColor: `var(${hunkContentBGName})` } },
1450
1474
  React__namespace.createElement("div", { className: "pl-[1.5em]", style: {
@@ -1461,10 +1485,10 @@ const DiffUnifiedHunkLine = ({ index, diffFile, lineNumber, }) => {
1461
1485
  const currentIsPureHunk = currentHunk && diffFile._getIsPureDiffRender() && !currentHunk.unifiedInfo;
1462
1486
  if (!currentIsShow && !currentIsPureHunk)
1463
1487
  return null;
1464
- return React__namespace.createElement(_DiffUnifiedHunkLine, { index: index, diffFile: diffFile, lineNumber: lineNumber });
1488
+ return React__namespace.createElement(InternalDiffUnifiedHunkLine, { index: index, diffFile: diffFile, lineNumber: lineNumber });
1465
1489
  };
1466
1490
 
1467
- const _DiffUnifiedWidgetLine = ({ index, diffFile, lineNumber, }) => {
1491
+ const InternalDiffUnifiedWidgetLine = ({ index, diffFile, lineNumber, }) => {
1468
1492
  const { useWidget } = useDiffWidgetContext();
1469
1493
  const setWidget = useWidget.getReadonlyState().setWidget;
1470
1494
  const unifiedItem = diffFile.getUnifiedLine(index);
@@ -1505,7 +1529,7 @@ const DiffUnifiedWidgetLine = ({ index, diffFile, lineNumber, }) => {
1505
1529
  }, [diffFile, index]), (p, c) => p === c);
1506
1530
  if (!currentIsShow)
1507
1531
  return null;
1508
- return React__namespace.createElement(_DiffUnifiedWidgetLine, { index: index, diffFile: diffFile, lineNumber: lineNumber });
1532
+ return React__namespace.createElement(InternalDiffUnifiedWidgetLine, { index: index, diffFile: diffFile, lineNumber: lineNumber });
1509
1533
  };
1510
1534
 
1511
1535
  /* eslint-disable @typescript-eslint/ban-ts-comment */
@@ -1572,8 +1596,17 @@ exports.SplitSide = void 0;
1572
1596
  SplitSide[SplitSide["old"] = 1] = "old";
1573
1597
  SplitSide[SplitSide["new"] = 2] = "new";
1574
1598
  })(exports.SplitSide || (exports.SplitSide = {}));
1575
- const _InternalDiffView = (props) => {
1576
- const { diffFile, className, style, diffViewMode, diffViewWrap, diffViewFontSize, diffViewHighlight, renderWidgetLine, renderExtendLine, extendData, diffViewAddWidget, onAddWidgetClick, } = props;
1599
+ exports.DiffModeEnum = void 0;
1600
+ (function (DiffModeEnum) {
1601
+ // github like
1602
+ DiffModeEnum[DiffModeEnum["SplitGitHub"] = 1] = "SplitGitHub";
1603
+ // gitlab like
1604
+ DiffModeEnum[DiffModeEnum["SplitGitLab"] = 2] = "SplitGitLab";
1605
+ DiffModeEnum[DiffModeEnum["Split"] = 3] = "Split";
1606
+ DiffModeEnum[DiffModeEnum["Unified"] = 4] = "Unified";
1607
+ })(exports.DiffModeEnum || (exports.DiffModeEnum = {}));
1608
+ const InternalDiffView = (props) => {
1609
+ const { diffFile, className, style, diffViewMode, diffViewWrap, diffViewFontSize, diffViewHighlight, renderWidgetLine, renderExtendLine, extendData, diffViewAddWidget, onAddWidgetClick, isMounted, } = props;
1577
1610
  const diffFileId = React.useMemo(() => diffFile.getId(), [diffFile]);
1578
1611
  const wrapperRef = React.useRef();
1579
1612
  // performance optimization
@@ -1581,17 +1614,40 @@ const _InternalDiffView = (props) => {
1581
1614
  // eslint-disable-next-line react-hooks/exhaustive-deps
1582
1615
  []);
1583
1616
  React.useEffect(() => {
1584
- 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();
1585
- diffFileId && diffFileId !== id && setId(diffFileId);
1586
- diffViewMode && diffViewMode !== mode && setMode(diffViewMode);
1587
- diffViewAddWidget !== enableAddWidget && setEnableAddWidget(diffViewAddWidget);
1588
- diffViewHighlight !== enableHighlight && setEnableHighlight(diffViewHighlight);
1589
- diffViewWrap !== enableWrap && setEnableWrap(diffViewWrap);
1590
- extendData && setExtendData(extendData);
1591
- diffViewFontSize && diffViewFontSize !== fontSize && setFontSize(diffViewFontSize);
1592
- onAddWidgetClick !== _onAddWidgetClick.current && setOnAddWidgetClick({ current: onAddWidgetClick });
1593
- renderExtendLine !== _renderExtendLine && setRenderExtendLine(renderExtendLine);
1594
- renderWidgetLine !== _renderWidgetLine && setRenderWidgetLine(renderWidgetLine);
1617
+ 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();
1618
+ if (diffFileId && diffFileId !== id) {
1619
+ setId(diffFileId);
1620
+ }
1621
+ if (diffViewMode && diffViewMode !== mode) {
1622
+ setMode(diffViewMode);
1623
+ }
1624
+ if (mounted !== isMounted) {
1625
+ setMounted(isMounted);
1626
+ }
1627
+ if (diffViewAddWidget !== enableAddWidget) {
1628
+ setEnableAddWidget(diffViewAddWidget);
1629
+ }
1630
+ if (diffViewHighlight !== enableHighlight) {
1631
+ setEnableHighlight(diffViewHighlight);
1632
+ }
1633
+ if (diffViewWrap !== enableWrap) {
1634
+ setEnableWrap(diffViewWrap);
1635
+ }
1636
+ if (extendData) {
1637
+ setExtendData(extendData);
1638
+ }
1639
+ if (diffViewFontSize && diffViewFontSize !== fontSize) {
1640
+ setFontSize(diffViewFontSize);
1641
+ }
1642
+ if (onAddWidgetClick !== _onAddWidgetClick.current) {
1643
+ setOnAddWidgetClick({ current: onAddWidgetClick });
1644
+ }
1645
+ if (renderExtendLine !== _renderExtendLine) {
1646
+ setRenderExtendLine(renderExtendLine);
1647
+ }
1648
+ if (renderWidgetLine !== _renderWidgetLine) {
1649
+ setRenderWidgetLine(renderWidgetLine);
1650
+ }
1595
1651
  }, [
1596
1652
  useDiffContext,
1597
1653
  diffViewFontSize,
@@ -1600,6 +1656,7 @@ const _InternalDiffView = (props) => {
1600
1656
  diffViewWrap,
1601
1657
  diffViewAddWidget,
1602
1658
  diffFileId,
1659
+ isMounted,
1603
1660
  renderWidgetLine,
1604
1661
  renderExtendLine,
1605
1662
  extendData,
@@ -1615,14 +1672,14 @@ const _InternalDiffView = (props) => {
1615
1672
  }, [diffFile]);
1616
1673
  const value = React.useMemo(() => ({ useDiffContext }), [useDiffContext]);
1617
1674
  return (React__namespace.createElement(DiffViewContext.Provider, { value: value },
1618
- React__namespace.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 },
1675
+ React__namespace.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 },
1619
1676
  React__namespace.createElement("div", { className: "diff-style-root", style: {
1620
1677
  // @ts-ignore
1621
1678
  [diffFontSizeName]: diffViewFontSize + "px",
1622
1679
  } },
1623
- React__namespace.createElement("div", { suppressHydrationWarning: true, id: `diff-root${diffFileId}`, className: "diff-view-wrapper" + (className ? ` ${className}` : ""), style: style }, diffViewMode & exports.DiffModeEnum.Split ? (React__namespace.createElement(DiffSplitView, { diffFile: diffFile })) : (React__namespace.createElement(DiffUnifiedView, { diffFile: diffFile })))))));
1680
+ React__namespace.createElement("div", { id: isMounted ? `diff-root${diffFileId}` : undefined, className: "diff-view-wrapper" + (className ? ` ${className}` : ""), style: style }, diffViewMode & exports.DiffModeEnum.Split ? (React__namespace.createElement(DiffSplitView, { diffFile: diffFile })) : (React__namespace.createElement(DiffUnifiedView, { diffFile: diffFile })))))));
1624
1681
  };
1625
- const InternalDiffView = React.memo(_InternalDiffView);
1682
+ const MemoedInternalDiffView = React.memo(InternalDiffView);
1626
1683
  const DiffViewWithRef = (props, ref) => {
1627
1684
  var _a, _b;
1628
1685
  const { registerHighlighter, data, diffViewTheme, diffFile: _diffFile } = props, restProps = __rest(props, ["registerHighlighter", "data", "diffViewTheme", "diffFile"]);
@@ -1646,6 +1703,7 @@ const DiffViewWithRef = (props, ref) => {
1646
1703
  (_b = (_a = diffFileRef.current).clear) === null || _b === void 0 ? void 0 : _b.call(_a);
1647
1704
  diffFileRef.current = diffFile;
1648
1705
  }
1706
+ const isMounted = useIsMounted();
1649
1707
  React.useEffect(() => {
1650
1708
  if (_diffFile && diffFile) {
1651
1709
  _diffFile._addClonedInstance(diffFile);
@@ -1675,16 +1733,14 @@ const DiffViewWithRef = (props, ref) => {
1675
1733
  React.useImperativeHandle(ref, () => ({ getDiffFileInstance: () => diffFile }), [diffFile]);
1676
1734
  if (!diffFile)
1677
1735
  return null;
1678
- return (React__namespace.createElement(InternalDiffView, Object.assign({ key: diffFile.getId() }, restProps, { diffFile: diffFile, diffViewMode: restProps.diffViewMode || exports.DiffModeEnum.SplitGitHub, diffViewFontSize: restProps.diffViewFontSize || 14 })));
1736
+ return (React__namespace.createElement(MemoedInternalDiffView, Object.assign({ key: diffFile.getId() }, restProps, { diffFile: diffFile, isMounted: isMounted, diffViewMode: restProps.diffViewMode || exports.DiffModeEnum.SplitGitHub, diffViewFontSize: restProps.diffViewFontSize || 14 })));
1679
1737
  };
1680
1738
  const InnerDiffView = React.forwardRef(DiffViewWithRef);
1681
1739
  InnerDiffView.displayName = "DiffView";
1682
1740
  const DiffView = InnerDiffView;
1683
- const version = "0.0.24";
1741
+ const version = "0.0.26";
1684
1742
 
1685
1743
  exports.DiffView = DiffView;
1686
- exports.DiffViewContext = DiffViewContext;
1687
- exports.useDiffViewContext = useDiffViewContext;
1688
1744
  exports.version = version;
1689
1745
  Object.keys(core).forEach(function (k) {
1690
1746
  if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {