@git-diff-view/react 0.0.18 → 0.0.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.development.js +108 -100
- package/dist/cjs/index.development.js.map +1 -1
- package/dist/cjs/index.production.js +108 -100
- package/dist/cjs/index.production.js.map +1 -1
- package/dist/css/diff-view.css +5 -6
- package/dist/esm/index.mjs +108 -100
- package/dist/esm/index.mjs.map +1 -1
- package/index.d.ts +23 -19
- package/package.json +3 -3
- package/readme.md +4 -0
|
@@ -575,37 +575,45 @@ const useDiffViewContext = () => React.useContext(DiffViewContext);
|
|
|
575
575
|
const useSyncHeight = ({ selector, wrapper, side, enable, }) => {
|
|
576
576
|
const { useDiffContext } = useDiffViewContext();
|
|
577
577
|
const id = useDiffContext(React.useCallback((s) => s.id, []));
|
|
578
|
-
|
|
578
|
+
React.useEffect(() => {
|
|
579
579
|
if (enable) {
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
const
|
|
583
|
-
|
|
584
|
-
const
|
|
585
|
-
const
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
const
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
observer.
|
|
606
|
-
target
|
|
607
|
-
|
|
608
|
-
|
|
580
|
+
let clean = () => { };
|
|
581
|
+
// fix the dom delay update
|
|
582
|
+
const timer = setTimeout(() => {
|
|
583
|
+
const container = document.querySelector(`#diff-root${id}`);
|
|
584
|
+
const elements = Array.from((container === null || container === void 0 ? void 0 : container.querySelectorAll(selector)) || []);
|
|
585
|
+
const wrappers = wrapper ? Array.from((container === null || container === void 0 ? void 0 : container.querySelectorAll(wrapper)) || []) : elements;
|
|
586
|
+
if (elements.length === 2 && wrappers.length === 2) {
|
|
587
|
+
const ele1 = elements[0];
|
|
588
|
+
const ele2 = elements[1];
|
|
589
|
+
const wrapper1 = wrappers[0];
|
|
590
|
+
const wrapper2 = wrappers[1];
|
|
591
|
+
const target = ele1.getAttribute("data-side") === side ? ele1 : ele2;
|
|
592
|
+
const cb = () => {
|
|
593
|
+
ele1.style.height = "auto";
|
|
594
|
+
ele2.style.height = "auto";
|
|
595
|
+
const rect1 = ele1.getBoundingClientRect();
|
|
596
|
+
const rect2 = ele2.getBoundingClientRect();
|
|
597
|
+
const maxHeight = Math.max(rect1.height, rect2.height);
|
|
598
|
+
wrapper1.style.height = maxHeight + "px";
|
|
599
|
+
wrapper2.style.height = maxHeight + "px";
|
|
600
|
+
wrapper1.setAttribute("data-sync-height", String(maxHeight));
|
|
601
|
+
wrapper2.setAttribute("data-sync-height", String(maxHeight));
|
|
602
|
+
};
|
|
603
|
+
cb();
|
|
604
|
+
const observer = new ResizeObserver(cb);
|
|
605
|
+
observer.observe(target);
|
|
606
|
+
target.setAttribute("data-observe", "height");
|
|
607
|
+
clean = () => {
|
|
608
|
+
observer.disconnect();
|
|
609
|
+
target === null || target === void 0 ? void 0 : target.removeAttribute("data-observe");
|
|
610
|
+
};
|
|
611
|
+
}
|
|
612
|
+
});
|
|
613
|
+
return () => {
|
|
614
|
+
clean();
|
|
615
|
+
clearTimeout(timer);
|
|
616
|
+
};
|
|
609
617
|
}
|
|
610
618
|
}, [selector, enable, side, id, wrapper]);
|
|
611
619
|
};
|
|
@@ -617,28 +625,29 @@ const _DiffSplitExtendLine$1 = ({ index, diffFile, oldLineExtend, newLineExtend,
|
|
|
617
625
|
const renderExtendLine = useDiffContext.useShallowStableSelector((s) => s.renderExtendLine);
|
|
618
626
|
const currentExtend = side === exports.SplitSide.old ? oldLineExtend : newLineExtend;
|
|
619
627
|
const currentLineNumber = side === exports.SplitSide.old ? oldLine.lineNumber : newLine.lineNumber;
|
|
628
|
+
const hasExtend = (currentExtend === null || currentExtend === void 0 ? void 0 : currentExtend.data) !== undefined && (currentExtend === null || currentExtend === void 0 ? void 0 : currentExtend.data) !== null;
|
|
629
|
+
const currentExtendRendered = hasExtend &&
|
|
630
|
+
(renderExtendLine === null || renderExtendLine === void 0 ? void 0 : renderExtendLine({
|
|
631
|
+
diffFile,
|
|
632
|
+
side,
|
|
633
|
+
lineNumber: currentLineNumber,
|
|
634
|
+
data: currentExtend.data,
|
|
635
|
+
onUpdate: diffFile.notifyAll,
|
|
636
|
+
}));
|
|
620
637
|
useSyncHeight({
|
|
621
638
|
selector: `div[data-line="${lineNumber}-extend-content"]`,
|
|
622
639
|
wrapper: `tr[data-line="${lineNumber}-extend"]`,
|
|
623
640
|
side: exports.SplitSide[side],
|
|
624
|
-
enable:
|
|
641
|
+
enable: hasExtend && typeof renderExtendLine === "function",
|
|
625
642
|
});
|
|
626
643
|
const width = useDomWidth({
|
|
627
644
|
selector: side === exports.SplitSide.old ? ".old-diff-table-wrapper" : ".new-diff-table-wrapper",
|
|
628
|
-
enable:
|
|
645
|
+
enable: hasExtend && typeof renderExtendLine === "function",
|
|
629
646
|
});
|
|
630
647
|
if (!renderExtendLine)
|
|
631
648
|
return null;
|
|
632
|
-
return (React__namespace.createElement("tr", { "data-line": `${lineNumber}-extend`, "data-state": "extend", "data-side": exports.SplitSide[side], className: "diff-line diff-line-extend" },
|
|
633
|
-
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 &&
|
|
634
|
-
(currentExtend === null || currentExtend === void 0 ? void 0 : currentExtend.data) &&
|
|
635
|
-
(renderExtendLine === null || renderExtendLine === void 0 ? void 0 : renderExtendLine({
|
|
636
|
-
diffFile,
|
|
637
|
-
side,
|
|
638
|
-
lineNumber: currentLineNumber,
|
|
639
|
-
data: currentExtend.data,
|
|
640
|
-
onUpdate: diffFile.notifyAll,
|
|
641
|
-
}))))) : (React__namespace.createElement("td", { className: `diff-line-extend-${exports.SplitSide[side]}-placeholder select-none p-0`, style: { backgroundColor: `var(${emptyBGName})` }, colSpan: 2 },
|
|
649
|
+
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 },
|
|
650
|
+
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 },
|
|
642
651
|
React__namespace.createElement("div", { "data-line": `${lineNumber}-extend-content`, "data-side": exports.SplitSide[side] })))));
|
|
643
652
|
};
|
|
644
653
|
const DiffSplitExtendLine$1 = ({ index, diffFile, side, lineNumber, }) => {
|
|
@@ -777,11 +786,18 @@ const DiffSplitHunkLine$1 = ({ index, diffFile, side, lineNumber, }) => {
|
|
|
777
786
|
const _DiffSplitWidgetLine$1 = ({ diffFile, side, lineNumber, currentLine, setWidget, currentWidget, }) => {
|
|
778
787
|
const { useDiffContext } = useDiffViewContext();
|
|
779
788
|
const renderWidgetLine = useDiffContext.useShallowStableSelector((s) => s.renderWidgetLine);
|
|
789
|
+
const currentWidgetRendered = currentWidget &&
|
|
790
|
+
(renderWidgetLine === null || renderWidgetLine === void 0 ? void 0 : renderWidgetLine({
|
|
791
|
+
diffFile,
|
|
792
|
+
side,
|
|
793
|
+
lineNumber: currentLine.lineNumber,
|
|
794
|
+
onClose: () => setWidget({}),
|
|
795
|
+
}));
|
|
780
796
|
useSyncHeight({
|
|
781
797
|
selector: `div[data-line="${lineNumber}-widget-content"]`,
|
|
782
798
|
wrapper: `tr[data-line="${lineNumber}-widget"]`,
|
|
783
799
|
side: exports.SplitSide[side],
|
|
784
|
-
enable: currentWidget && typeof renderWidgetLine === "function",
|
|
800
|
+
enable: !!currentWidget && typeof renderWidgetLine === "function",
|
|
785
801
|
});
|
|
786
802
|
const width = useDomWidth({
|
|
787
803
|
selector: side === exports.SplitSide.old ? ".old-diff-table-wrapper" : ".new-diff-table-wrapper",
|
|
@@ -790,13 +806,7 @@ const _DiffSplitWidgetLine$1 = ({ diffFile, side, lineNumber, currentLine, setWi
|
|
|
790
806
|
if (!renderWidgetLine)
|
|
791
807
|
return null;
|
|
792
808
|
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 },
|
|
793
|
-
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 &&
|
|
794
|
-
(renderWidgetLine === null || renderWidgetLine === void 0 ? void 0 : renderWidgetLine({
|
|
795
|
-
diffFile,
|
|
796
|
-
side,
|
|
797
|
-
lineNumber: currentLine.lineNumber,
|
|
798
|
-
onClose: () => setWidget({}),
|
|
799
|
-
}))))) : (React__namespace.createElement("td", { className: `diff-line-widget-${exports.SplitSide[side]}-placeholder p-0`, style: { backgroundColor: `var(${emptyBGName})` }, colSpan: 2 },
|
|
809
|
+
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 },
|
|
800
810
|
React__namespace.createElement("div", { "data-line": `${lineNumber}-widget-content`, "data-side": exports.SplitSide[side] })))));
|
|
801
811
|
};
|
|
802
812
|
const DiffSplitWidgetLine$1 = ({ index, diffFile, side, lineNumber, }) => {
|
|
@@ -953,27 +963,27 @@ const _DiffSplitExtendLine = ({ index, diffFile, lineNumber, oldLineExtend, newL
|
|
|
953
963
|
const renderExtendLine = useDiffContext.useShallowStableSelector((s) => s.renderExtendLine);
|
|
954
964
|
if (!renderExtendLine)
|
|
955
965
|
return null;
|
|
966
|
+
const oldExtendRendered = (oldLineExtend === null || oldLineExtend === void 0 ? void 0 : oldLineExtend.data) &&
|
|
967
|
+
(renderExtendLine === null || renderExtendLine === void 0 ? void 0 : renderExtendLine({
|
|
968
|
+
diffFile,
|
|
969
|
+
side: exports.SplitSide.old,
|
|
970
|
+
lineNumber: oldLine.lineNumber,
|
|
971
|
+
data: oldLineExtend.data,
|
|
972
|
+
onUpdate: diffFile.notifyAll,
|
|
973
|
+
}));
|
|
974
|
+
const newExtendRendered = (newLineExtend === null || newLineExtend === void 0 ? void 0 : newLineExtend.data) &&
|
|
975
|
+
(renderExtendLine === null || renderExtendLine === void 0 ? void 0 : renderExtendLine({
|
|
976
|
+
diffFile,
|
|
977
|
+
side: exports.SplitSide.new,
|
|
978
|
+
lineNumber: newLine.lineNumber,
|
|
979
|
+
data: newLineExtend.data,
|
|
980
|
+
onUpdate: diffFile.notifyAll,
|
|
981
|
+
}));
|
|
956
982
|
return (React__namespace.createElement("tr", { "data-line": `${lineNumber}-extend`, "data-state": "extend", className: "diff-line diff-line-extend" },
|
|
957
|
-
|
|
958
|
-
React__namespace.createElement("div", { className: "diff-line-extend-wrapper" },
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
side: exports.SplitSide.old,
|
|
962
|
-
lineNumber: oldLine.lineNumber,
|
|
963
|
-
data: oldLineExtend.data,
|
|
964
|
-
onUpdate: diffFile.notifyAll,
|
|
965
|
-
}))))) : (React__namespace.createElement("td", { className: "diff-line-extend-old-placeholder select-none p-0", style: { backgroundColor: `var(${emptyBGName})` }, colSpan: 2 },
|
|
966
|
-
React__namespace.createElement("span", null, "\u2002"))),
|
|
967
|
-
newLineExtend ? (React__namespace.createElement("td", { className: "diff-line-extend-new-content border-l-[1px] p-0", style: { borderLeftColor: `var(${borderColorName})` }, colSpan: 2 },
|
|
968
|
-
React__namespace.createElement("div", { className: "diff-line-extend-wrapper" }, (newLineExtend === null || newLineExtend === void 0 ? void 0 : newLineExtend.data) &&
|
|
969
|
-
(renderExtendLine === null || renderExtendLine === void 0 ? void 0 : renderExtendLine({
|
|
970
|
-
diffFile,
|
|
971
|
-
side: exports.SplitSide.new,
|
|
972
|
-
lineNumber: newLine.lineNumber,
|
|
973
|
-
data: newLineExtend.data,
|
|
974
|
-
onUpdate: diffFile.notifyAll,
|
|
975
|
-
}))))) : (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 },
|
|
976
|
-
React__namespace.createElement("span", null, "\u2002")))));
|
|
983
|
+
oldExtendRendered ? (React__namespace.createElement("td", { className: "diff-line-extend-old-content p-0", colSpan: 2 },
|
|
984
|
+
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"))),
|
|
985
|
+
newExtendRendered ? (React__namespace.createElement("td", { className: "diff-line-extend-new-content border-l-[1px] p-0", style: { borderLeftColor: `var(${borderColorName})` }, colSpan: 2 },
|
|
986
|
+
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")))));
|
|
977
987
|
};
|
|
978
988
|
const DiffSplitExtendLine = ({ index, diffFile, lineNumber, }) => {
|
|
979
989
|
const { useDiffContext } = useDiffViewContext();
|
|
@@ -1095,25 +1105,17 @@ const _DiffSplitWidgetLine = ({ index, diffFile, lineNumber, oldLineWidget, newL
|
|
|
1095
1105
|
const renderWidgetLine = useDiffContext.useShallowStableSelector((s) => s.renderWidgetLine);
|
|
1096
1106
|
const oldLine = diffFile.getSplitLeftLine(index);
|
|
1097
1107
|
const newLine = diffFile.getSplitRightLine(index);
|
|
1108
|
+
const oldWidgetRendered = oldLineWidget &&
|
|
1109
|
+
(renderWidgetLine === null || renderWidgetLine === void 0 ? void 0 : renderWidgetLine({ diffFile, side: exports.SplitSide.old, lineNumber: oldLine.lineNumber, onClose: () => setWidget({}) }));
|
|
1110
|
+
const newWidgetRendered = newLineWidget &&
|
|
1111
|
+
(renderWidgetLine === null || renderWidgetLine === void 0 ? void 0 : renderWidgetLine({ diffFile, side: exports.SplitSide.new, lineNumber: newLine.lineNumber, onClose: () => setWidget({}) }));
|
|
1098
1112
|
if (!renderWidgetLine)
|
|
1099
1113
|
return null;
|
|
1100
1114
|
return (React__namespace.createElement("tr", { "data-line": `${lineNumber}-widget`, "data-state": "widget", className: "diff-line diff-line-widget" },
|
|
1101
|
-
|
|
1102
|
-
React__namespace.createElement("div", { className: "diff-line-widget-wrapper" },
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
lineNumber: oldLine.lineNumber,
|
|
1106
|
-
onClose: () => setWidget({}),
|
|
1107
|
-
})))) : (React__namespace.createElement("td", { className: "diff-line-widget-old-placeholder select-none p-0", style: { backgroundColor: `var(${emptyBGName})` }, colSpan: 2 },
|
|
1108
|
-
React__namespace.createElement("span", null, "\u2002"))),
|
|
1109
|
-
newLineWidget ? (React__namespace.createElement("td", { className: "diff-line-widget-new-content border-l-[1px] p-0", colSpan: 2, style: { borderLeftColor: `var(${borderColorName})` } },
|
|
1110
|
-
React__namespace.createElement("div", { className: "diff-line-widget-wrapper" }, renderWidgetLine === null || renderWidgetLine === void 0 ? void 0 : renderWidgetLine({
|
|
1111
|
-
diffFile,
|
|
1112
|
-
side: exports.SplitSide.new,
|
|
1113
|
-
lineNumber: newLine.lineNumber,
|
|
1114
|
-
onClose: () => setWidget({}),
|
|
1115
|
-
})))) : (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 },
|
|
1116
|
-
React__namespace.createElement("span", null, "\u2002")))));
|
|
1115
|
+
oldWidgetRendered ? (React__namespace.createElement("td", { className: "diff-line-widget-old-content p-0", colSpan: 2 },
|
|
1116
|
+
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"))),
|
|
1117
|
+
newWidgetRendered ? (React__namespace.createElement("td", { className: "diff-line-widget-new-content border-l-[1px] p-0", colSpan: 2, style: { borderLeftColor: `var(${borderColorName})` } },
|
|
1118
|
+
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")))));
|
|
1117
1119
|
};
|
|
1118
1120
|
const DiffSplitWidgetLine = ({ index, diffFile, lineNumber, }) => {
|
|
1119
1121
|
const { useWidget } = useDiffWidgetContext();
|
|
@@ -1325,7 +1327,8 @@ const _DiffUnifiedExtendLine = ({ index, diffFile, lineNumber, oldLineExtend, ne
|
|
|
1325
1327
|
React__namespace.createElement("td", { className: "diff-line-extend-content p-0 align-top", colSpan: 2 },
|
|
1326
1328
|
React__namespace.createElement("div", { className: "diff-line-extend-wrapper sticky left-0", style: { width } },
|
|
1327
1329
|
width > 0 &&
|
|
1328
|
-
(oldLineExtend === null || oldLineExtend === void 0 ? void 0 : oldLineExtend.data) &&
|
|
1330
|
+
(oldLineExtend === null || oldLineExtend === void 0 ? void 0 : oldLineExtend.data) !== undefined &&
|
|
1331
|
+
(oldLineExtend === null || oldLineExtend === void 0 ? void 0 : oldLineExtend.data) !== null &&
|
|
1329
1332
|
(renderExtendLine === null || renderExtendLine === void 0 ? void 0 : renderExtendLine({
|
|
1330
1333
|
diffFile,
|
|
1331
1334
|
side: exports.SplitSide.old,
|
|
@@ -1334,7 +1337,8 @@ const _DiffUnifiedExtendLine = ({ index, diffFile, lineNumber, oldLineExtend, ne
|
|
|
1334
1337
|
onUpdate: diffFile.notifyAll,
|
|
1335
1338
|
})),
|
|
1336
1339
|
width > 0 &&
|
|
1337
|
-
(newLineExtend === null || newLineExtend === void 0 ? void 0 : newLineExtend.data) &&
|
|
1340
|
+
(newLineExtend === null || newLineExtend === void 0 ? void 0 : newLineExtend.data) !== undefined &&
|
|
1341
|
+
(newLineExtend === null || newLineExtend === void 0 ? void 0 : newLineExtend.data) !== null &&
|
|
1338
1342
|
(renderExtendLine === null || renderExtendLine === void 0 ? void 0 : renderExtendLine({
|
|
1339
1343
|
diffFile,
|
|
1340
1344
|
side: exports.SplitSide.new,
|
|
@@ -1541,14 +1545,15 @@ const _InternalDiffView = (props) => {
|
|
|
1541
1545
|
]);
|
|
1542
1546
|
React.useEffect(() => {
|
|
1543
1547
|
const cb = diffFile.subscribe(() => {
|
|
1544
|
-
var _a;
|
|
1548
|
+
var _a, _b;
|
|
1545
1549
|
(_a = wrapperRef.current) === null || _a === void 0 ? void 0 : _a.setAttribute("data-theme", diffFile._getTheme() || "light");
|
|
1550
|
+
(_b = wrapperRef.current) === null || _b === void 0 ? void 0 : _b.setAttribute("data-highlighter", diffFile._getHighlighterName());
|
|
1546
1551
|
});
|
|
1547
1552
|
return cb;
|
|
1548
1553
|
}, [diffFile]);
|
|
1549
1554
|
const value = React.useMemo(() => ({ useDiffContext }), [useDiffContext]);
|
|
1550
1555
|
return (React__namespace.createElement(DiffViewContext.Provider, { value: value },
|
|
1551
|
-
React__namespace.createElement("div", { className: "diff-tailwindcss-wrapper", "data-component": "git-diff-view", "data-theme": diffFile._getTheme() || "light", "data-version": "0.0.
|
|
1556
|
+
React__namespace.createElement("div", { className: "diff-tailwindcss-wrapper", "data-component": "git-diff-view", "data-theme": diffFile._getTheme() || "light", "data-version": "0.0.19", "data-highlighter": diffFile._getHighlighterName(), ref: wrapperRef },
|
|
1552
1557
|
React__namespace.createElement("div", { className: "diff-style-root", style: {
|
|
1553
1558
|
// @ts-ignore
|
|
1554
1559
|
[diffFontSizeName]: diffViewFontSize + "px",
|
|
@@ -1562,6 +1567,9 @@ const DiffViewWithRef = (props, ref) => {
|
|
|
1562
1567
|
const diffFile = React.useMemo(() => {
|
|
1563
1568
|
var _a, _b, _c, _d, _e, _f;
|
|
1564
1569
|
if (_diffFile) {
|
|
1570
|
+
// missing data for plain file render
|
|
1571
|
+
// TODO next release update ?
|
|
1572
|
+
// will cause more complex for diffFile flow control, keep current
|
|
1565
1573
|
const diffFile = core.DiffFile.createInstance({});
|
|
1566
1574
|
diffFile._mergeFullBundle(_diffFile._getFullBundle());
|
|
1567
1575
|
return diffFile;
|
|
@@ -1576,6 +1584,14 @@ const DiffViewWithRef = (props, ref) => {
|
|
|
1576
1584
|
(_b = (_a = diffFileRef.current).clear) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
1577
1585
|
diffFileRef.current = diffFile;
|
|
1578
1586
|
}
|
|
1587
|
+
React.useEffect(() => {
|
|
1588
|
+
if (_diffFile && diffFile) {
|
|
1589
|
+
_diffFile._addClonedInstance(diffFile);
|
|
1590
|
+
return () => {
|
|
1591
|
+
_diffFile._delClonedInstance(diffFile);
|
|
1592
|
+
};
|
|
1593
|
+
}
|
|
1594
|
+
}, [diffFile, _diffFile]);
|
|
1579
1595
|
React.useEffect(() => {
|
|
1580
1596
|
if (!diffFile)
|
|
1581
1597
|
return;
|
|
@@ -1592,16 +1608,8 @@ const DiffViewWithRef = (props, ref) => {
|
|
|
1592
1608
|
diffFile.notifyAll();
|
|
1593
1609
|
}
|
|
1594
1610
|
}, [diffFile, props.diffViewHighlight, registerHighlighter, diffViewTheme]);
|
|
1595
|
-
React.useEffect(() => {
|
|
1596
|
-
if (_diffFile && diffFile) {
|
|
1597
|
-
_diffFile._addClonedInstance(diffFile);
|
|
1598
|
-
return () => {
|
|
1599
|
-
_diffFile._delClonedInstance(diffFile);
|
|
1600
|
-
};
|
|
1601
|
-
}
|
|
1602
|
-
}, [diffFile, _diffFile]);
|
|
1603
1611
|
// fix react strict mode error
|
|
1604
|
-
useUnmount(() => { var
|
|
1612
|
+
useUnmount(() => { var _b; return ((_b = diffFile === null || diffFile === void 0 ? void 0 : diffFile.clear) === null || _b === void 0 ? void 0 : _b.call(diffFile)); }, [diffFile]);
|
|
1605
1613
|
React.useImperativeHandle(ref, () => ({ getDiffFileInstance: () => diffFile }), [diffFile]);
|
|
1606
1614
|
if (!diffFile)
|
|
1607
1615
|
return null;
|
|
@@ -1609,7 +1617,7 @@ const DiffViewWithRef = (props, ref) => {
|
|
|
1609
1617
|
};
|
|
1610
1618
|
const DiffView = React.forwardRef(DiffViewWithRef);
|
|
1611
1619
|
DiffView.displayName = "DiffView";
|
|
1612
|
-
const version = "0.0.
|
|
1620
|
+
const version = "0.0.19";
|
|
1613
1621
|
|
|
1614
1622
|
exports.DiffView = DiffView;
|
|
1615
1623
|
exports.DiffViewContext = DiffViewContext;
|