@git-diff-view/react 0.0.15 → 0.0.17
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 +508 -477
- package/dist/cjs/index.development.js.map +1 -1
- package/dist/cjs/index.production.js +508 -477
- package/dist/cjs/index.production.js.map +1 -1
- package/dist/css/diff-view.css +13 -3
- package/dist/esm/index.mjs +496 -465
- package/dist/esm/index.mjs.map +1 -1
- package/index.d.ts +9 -4
- package/package.json +8 -5
|
@@ -124,105 +124,9 @@ const useTextWidth = ({ text, font, }) => {
|
|
|
124
124
|
return width;
|
|
125
125
|
};
|
|
126
126
|
|
|
127
|
-
const useDomWidth = ({ selector, enable }) => {
|
|
128
|
-
const [width, setWidth] = React.useState(0);
|
|
129
|
-
const { useDiffContext } = useDiffViewContext();
|
|
130
|
-
const id = useDiffContext(React.useCallback((s) => s.id, []));
|
|
131
|
-
React.useEffect(() => {
|
|
132
|
-
if (enable) {
|
|
133
|
-
const container = document.querySelector(`#diff-root${id}`);
|
|
134
|
-
const wrapper = container === null || container === void 0 ? void 0 : container.querySelector(selector);
|
|
135
|
-
if (!wrapper)
|
|
136
|
-
return;
|
|
137
|
-
const typedWrapper = wrapper;
|
|
138
|
-
const cb = () => {
|
|
139
|
-
var _a;
|
|
140
|
-
const rect = wrapper === null || wrapper === void 0 ? void 0 : wrapper.getBoundingClientRect();
|
|
141
|
-
setWidth((_a = rect === null || rect === void 0 ? void 0 : rect.width) !== null && _a !== void 0 ? _a : 0);
|
|
142
|
-
};
|
|
143
|
-
cb();
|
|
144
|
-
const cleanCb = () => {
|
|
145
|
-
var _a;
|
|
146
|
-
typedWrapper.__observeCallback.delete(cb);
|
|
147
|
-
if (typedWrapper.__observeCallback.size === 0) {
|
|
148
|
-
(_a = typedWrapper.__observeInstance) === null || _a === void 0 ? void 0 : _a.disconnect();
|
|
149
|
-
typedWrapper.removeAttribute("data-observe");
|
|
150
|
-
delete typedWrapper.__observeCallback;
|
|
151
|
-
delete typedWrapper.__observeInstance;
|
|
152
|
-
}
|
|
153
|
-
};
|
|
154
|
-
if (typedWrapper.__observeCallback) {
|
|
155
|
-
typedWrapper.__observeCallback.add(cb);
|
|
156
|
-
return () => cleanCb();
|
|
157
|
-
}
|
|
158
|
-
typedWrapper.__observeCallback = new Set();
|
|
159
|
-
typedWrapper.__observeCallback.add(cb);
|
|
160
|
-
const observer = new ResizeObserver(() => typedWrapper.__observeCallback.forEach((cb) => cb()));
|
|
161
|
-
typedWrapper.__observeInstance = observer;
|
|
162
|
-
observer.observe(typedWrapper);
|
|
163
|
-
typedWrapper.setAttribute("data-observe", "height");
|
|
164
|
-
return () => cleanCb();
|
|
165
|
-
}
|
|
166
|
-
}, [selector, enable, id]);
|
|
167
|
-
return width;
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
exports.DiffModeEnum = void 0;
|
|
171
|
-
(function (DiffModeEnum) {
|
|
172
|
-
// github like
|
|
173
|
-
DiffModeEnum[DiffModeEnum["SplitGitHub"] = 1] = "SplitGitHub";
|
|
174
|
-
// gitlab like
|
|
175
|
-
DiffModeEnum[DiffModeEnum["SplitGitLab"] = 2] = "SplitGitLab";
|
|
176
|
-
DiffModeEnum[DiffModeEnum["Split"] = 3] = "Split";
|
|
177
|
-
DiffModeEnum[DiffModeEnum["Unified"] = 4] = "Unified";
|
|
178
|
-
})(exports.DiffModeEnum || (exports.DiffModeEnum = {}));
|
|
179
|
-
const DiffViewContext = React.createContext(null);
|
|
180
|
-
DiffViewContext.displayName = "DiffViewContext";
|
|
181
|
-
const useDiffViewContext = () => React.useContext(DiffViewContext);
|
|
182
|
-
|
|
183
|
-
const useSyncHeight = ({ selector, side, enable }) => {
|
|
184
|
-
const { useDiffContext } = useDiffViewContext();
|
|
185
|
-
const id = useDiffContext(React.useCallback((s) => s.id, []));
|
|
186
|
-
useSafeLayout(() => {
|
|
187
|
-
if (enable) {
|
|
188
|
-
const container = document.querySelector(`#diff-root${id}`);
|
|
189
|
-
const elements = Array.from((container === null || container === void 0 ? void 0 : container.querySelectorAll(selector)) || []);
|
|
190
|
-
if (elements.length === 2) {
|
|
191
|
-
const ele1 = elements[0];
|
|
192
|
-
const ele2 = elements[1];
|
|
193
|
-
const target = ele1.getAttribute("data-side") === side ? ele1 : ele2;
|
|
194
|
-
const synced = ele1.getAttribute("data-side") !== side ? ele1 : ele2;
|
|
195
|
-
const cb = () => {
|
|
196
|
-
ele1.style.height = "auto";
|
|
197
|
-
ele2.style.height = "auto";
|
|
198
|
-
const rect1 = ele1.getBoundingClientRect();
|
|
199
|
-
const rect2 = ele2.getBoundingClientRect();
|
|
200
|
-
if (rect1.height !== rect2.height) {
|
|
201
|
-
const maxHeight = Math.max(rect1.height, rect2.height);
|
|
202
|
-
synced.style.height = maxHeight + "px";
|
|
203
|
-
ele1.setAttribute("data-sync-height", String(maxHeight));
|
|
204
|
-
ele2.setAttribute("data-sync-height", String(maxHeight));
|
|
205
|
-
}
|
|
206
|
-
else {
|
|
207
|
-
ele1.removeAttribute("data-sync-height");
|
|
208
|
-
ele2.removeAttribute("data-sync-height");
|
|
209
|
-
}
|
|
210
|
-
};
|
|
211
|
-
cb();
|
|
212
|
-
const observer = new ResizeObserver(cb);
|
|
213
|
-
observer.observe(target);
|
|
214
|
-
target.setAttribute("data-observe", "height");
|
|
215
|
-
return () => {
|
|
216
|
-
observer.disconnect();
|
|
217
|
-
target === null || target === void 0 ? void 0 : target.removeAttribute("data-observe");
|
|
218
|
-
};
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
}, [selector, enable, side, id]);
|
|
222
|
-
};
|
|
223
|
-
|
|
224
127
|
const addContentBGName = "--diff-add-content--";
|
|
225
128
|
const delContentBGName = "--diff-del-content--";
|
|
129
|
+
const borderColorName = "--diff-border--";
|
|
226
130
|
const addLineNumberBGName = "--diff-add-lineNumber--";
|
|
227
131
|
const delLineNumberBGName = "--diff-del-lineNumber--";
|
|
228
132
|
const plainContentBGName = "--diff-plain-content--";
|
|
@@ -256,71 +160,6 @@ const getLineNumberBG = (isAdded, isDelete, hasDiff) => {
|
|
|
256
160
|
: `var(${expandContentBGName})`;
|
|
257
161
|
};
|
|
258
162
|
|
|
259
|
-
const _DiffSplitExtendLine$1 = ({ index, diffFile, oldLineExtend, newLineExtend, side, lineNumber, }) => {
|
|
260
|
-
const { useDiffContext } = useDiffViewContext();
|
|
261
|
-
const oldLine = diffFile.getSplitLeftLine(index);
|
|
262
|
-
const newLine = diffFile.getSplitRightLine(index);
|
|
263
|
-
const renderExtendLine = useDiffContext(React__namespace.useCallback((s) => s.renderExtendLine, []));
|
|
264
|
-
const currentExtend = side === exports.SplitSide.old ? oldLineExtend : newLineExtend;
|
|
265
|
-
const currentLineNumber = side === exports.SplitSide.old ? oldLine.lineNumber : newLine.lineNumber;
|
|
266
|
-
const otherSide = side === exports.SplitSide.old ? exports.SplitSide.new : exports.SplitSide.old;
|
|
267
|
-
useSyncHeight({
|
|
268
|
-
selector: `tr[data-line="${lineNumber}-extend"]`,
|
|
269
|
-
side: currentExtend ? exports.SplitSide[side] : exports.SplitSide[otherSide],
|
|
270
|
-
enable: side === exports.SplitSide.new && typeof renderExtendLine === "function",
|
|
271
|
-
});
|
|
272
|
-
const width = useDomWidth({
|
|
273
|
-
selector: side === exports.SplitSide.old ? ".old-diff-table-wrapper" : ".new-diff-table-wrapper",
|
|
274
|
-
enable: !!currentExtend && typeof renderExtendLine === "function",
|
|
275
|
-
});
|
|
276
|
-
if (!renderExtendLine)
|
|
277
|
-
return null;
|
|
278
|
-
return (React__namespace.createElement("tr", { "data-line": `${lineNumber}-extend`, "data-state": "extend", "data-side": exports.SplitSide[side], className: "diff-line diff-line-extend" }, currentExtend ? (React__namespace.createElement("td", { className: `diff-line-extend-${exports.SplitSide[side]}-content p-0`, colSpan: 2 },
|
|
279
|
-
React__namespace.createElement("div", { className: "diff-line-extend-wrapper sticky left-0", style: { width } }, width > 0 &&
|
|
280
|
-
(currentExtend === null || currentExtend === void 0 ? void 0 : currentExtend.data) &&
|
|
281
|
-
(renderExtendLine === null || renderExtendLine === void 0 ? void 0 : renderExtendLine({
|
|
282
|
-
diffFile,
|
|
283
|
-
side,
|
|
284
|
-
lineNumber: currentLineNumber,
|
|
285
|
-
data: currentExtend.data,
|
|
286
|
-
onUpdate: diffFile.notifyAll,
|
|
287
|
-
}))))) : (React__namespace.createElement("td", { className: `diff-line-extend-${exports.SplitSide[side]}-placeholder select-none p-0`, style: { backgroundColor: `var(${emptyBGName})` }, colSpan: 2 },
|
|
288
|
-
React__namespace.createElement("span", null, "\u2002")))));
|
|
289
|
-
};
|
|
290
|
-
const DiffSplitExtendLine$1 = ({ index, diffFile, side, lineNumber, }) => {
|
|
291
|
-
const { useDiffContext } = useDiffViewContext();
|
|
292
|
-
const oldLine = diffFile.getSplitLeftLine(index);
|
|
293
|
-
const newLine = diffFile.getSplitRightLine(index);
|
|
294
|
-
const { oldLineExtend, newLineExtend } = useDiffContext(React__namespace.useCallback((s) => {
|
|
295
|
-
var _a, _b, _c, _d;
|
|
296
|
-
return ({
|
|
297
|
-
oldLineExtend: (_b = (_a = s.extendData) === null || _a === void 0 ? void 0 : _a.oldFile) === null || _b === void 0 ? void 0 : _b[oldLine === null || oldLine === void 0 ? void 0 : oldLine.lineNumber],
|
|
298
|
-
newLineExtend: (_d = (_c = s.extendData) === null || _c === void 0 ? void 0 : _c.newFile) === null || _d === void 0 ? void 0 : _d[newLine === null || newLine === void 0 ? void 0 : newLine.lineNumber],
|
|
299
|
-
});
|
|
300
|
-
}, [oldLine === null || oldLine === void 0 ? void 0 : oldLine.lineNumber, newLine === null || newLine === void 0 ? void 0 : newLine.lineNumber]));
|
|
301
|
-
const hasExtend = (oldLineExtend === null || oldLineExtend === void 0 ? void 0 : oldLineExtend.data) || (newLineExtend === null || newLineExtend === void 0 ? void 0 : newLineExtend.data);
|
|
302
|
-
// if the expand action not enabled, the `isHidden` property will never change
|
|
303
|
-
const enableExpand = diffFile.getExpandEnabled();
|
|
304
|
-
const currentLine = side === exports.SplitSide.old ? oldLine : newLine;
|
|
305
|
-
const currentIsShow = hasExtend && (!currentLine.isHidden || !enableExpand);
|
|
306
|
-
if (!currentIsShow)
|
|
307
|
-
return null;
|
|
308
|
-
return (React__namespace.createElement(_DiffSplitExtendLine$1, { side: side, index: index, diffFile: diffFile, lineNumber: lineNumber, oldLineExtend: oldLineExtend, newLineExtend: newLineExtend }));
|
|
309
|
-
};
|
|
310
|
-
|
|
311
|
-
const ExpandDown = ({ className }) => {
|
|
312
|
-
return (React__namespace.createElement("svg", { "aria-hidden": "true", height: "16", viewBox: "0 0 16 16", version: "1.1", width: "16", className: className },
|
|
313
|
-
React__namespace.createElement("path", { d: "m8.177 14.323 2.896-2.896a.25.25 0 0 0-.177-.427H8.75V7.764a.75.75 0 1 0-1.5 0V11H5.104a.25.25 0 0 0-.177.427l2.896 2.896a.25.25 0 0 0 .354 0ZM2.25 5a.75.75 0 0 0 0-1.5h-.5a.75.75 0 0 0 0 1.5h.5ZM6 4.25a.75.75 0 0 1-.75.75h-.5a.75.75 0 0 1 0-1.5h.5a.75.75 0 0 1 .75.75ZM8.25 5a.75.75 0 0 0 0-1.5h-.5a.75.75 0 0 0 0 1.5h.5ZM12 4.25a.75.75 0 0 1-.75.75h-.5a.75.75 0 0 1 0-1.5h.5a.75.75 0 0 1 .75.75Zm2.25.75a.75.75 0 0 0 0-1.5h-.5a.75.75 0 0 0 0 1.5h.5Z" })));
|
|
314
|
-
};
|
|
315
|
-
const ExpandUp = ({ className }) => {
|
|
316
|
-
return (React__namespace.createElement("svg", { "aria-hidden": "true", height: "16", viewBox: "0 0 16 16", version: "1.1", width: "16", className: className },
|
|
317
|
-
React__namespace.createElement("path", { d: "M7.823 1.677 4.927 4.573A.25.25 0 0 0 5.104 5H7.25v3.236a.75.75 0 1 0 1.5 0V5h2.146a.25.25 0 0 0 .177-.427L8.177 1.677a.25.25 0 0 0-.354 0ZM13.75 11a.75.75 0 0 0 0 1.5h.5a.75.75 0 0 0 0-1.5h-.5Zm-3.75.75a.75.75 0 0 1 .75-.75h.5a.75.75 0 0 1 0 1.5h-.5a.75.75 0 0 1-.75-.75ZM7.75 11a.75.75 0 0 0 0 1.5h.5a.75.75 0 0 0 0-1.5h-.5ZM4 11.75a.75.75 0 0 1 .75-.75h.5a.75.75 0 0 1 0 1.5h-.5a.75.75 0 0 1-.75-.75ZM1.75 11a.75.75 0 0 0 0 1.5h.5a.75.75 0 0 0 0-1.5h-.5Z" })));
|
|
318
|
-
};
|
|
319
|
-
const ExpandAll = ({ className }) => {
|
|
320
|
-
return (React__namespace.createElement("svg", { "aria-hidden": "true", height: "16", viewBox: "0 0 16 16", version: "1.1", width: "16", className: className },
|
|
321
|
-
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" })));
|
|
322
|
-
};
|
|
323
|
-
|
|
324
163
|
const removeAllSelection = () => {
|
|
325
164
|
const selection = window.getSelection();
|
|
326
165
|
for (let i = 0; i < selection.rangeCount; i++) {
|
|
@@ -464,105 +303,6 @@ const createDiffSplitConfigStore = () => {
|
|
|
464
303
|
const diffAsideWidthName = "--diff-aside-width--";
|
|
465
304
|
const diffFontSizeName = "--diff-font-size--";
|
|
466
305
|
|
|
467
|
-
const _DiffSplitHunkLineGitHub = ({ index, diffFile, side, lineNumber, }) => {
|
|
468
|
-
var _a;
|
|
469
|
-
const currentHunk = diffFile.getSplitHunkLine(index);
|
|
470
|
-
const expandEnabled = diffFile.getExpandEnabled();
|
|
471
|
-
useSyncHeight({
|
|
472
|
-
selector: `tr[data-line="${lineNumber}-hunk"]`,
|
|
473
|
-
side: exports.SplitSide[exports.SplitSide.old],
|
|
474
|
-
enable: side === exports.SplitSide.new,
|
|
475
|
-
});
|
|
476
|
-
const enableHunkAction = side === exports.SplitSide.old;
|
|
477
|
-
const couldExpand = expandEnabled && currentHunk && currentHunk.splitInfo;
|
|
478
|
-
const isExpandAll = currentHunk &&
|
|
479
|
-
currentHunk.splitInfo &&
|
|
480
|
-
currentHunk.splitInfo.endHiddenIndex - currentHunk.splitInfo.startHiddenIndex < core.composeLen;
|
|
481
|
-
const isFirstLine = currentHunk && currentHunk.isFirst;
|
|
482
|
-
const isLastLine = currentHunk && currentHunk.isLast;
|
|
483
|
-
return (React__namespace.createElement("tr", { "data-line": `${lineNumber}-hunk`, "data-state": "hunk", "data-side": exports.SplitSide[side], className: "diff-line diff-line-hunk" }, enableHunkAction ? (React__namespace.createElement(React__namespace.Fragment, null,
|
|
484
|
-
React__namespace.createElement("td", { className: "diff-line-hunk-action sticky left-0 w-[1%] min-w-[40px] select-none p-[1px]", style: {
|
|
485
|
-
backgroundColor: `var(${hunkLineNumberBGName})`,
|
|
486
|
-
color: `var(${plainLineNumberColorName})`,
|
|
487
|
-
width: `var(${diffAsideWidthName})`,
|
|
488
|
-
minWidth: `var(${diffAsideWidthName})`,
|
|
489
|
-
maxWidth: `var(${diffAsideWidthName})`,
|
|
490
|
-
} }, couldExpand ? (isFirstLine ? (React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px] hover:bg-blue-300", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index) },
|
|
491
|
-
React__namespace.createElement(ExpandUp, { className: "fill-current" }))) : isLastLine ? (React__namespace.createElement("button", { className: "diff-widget-tooltip relative flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px] hover:bg-blue-300", title: "Expand Down", "data-title": "Expand Down", onClick: () => {
|
|
492
|
-
diffFile.onSplitHunkExpand("down", index);
|
|
493
|
-
} },
|
|
494
|
-
React__namespace.createElement(ExpandDown, { className: "fill-current" }))) : isExpandAll ? (React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px] hover:bg-blue-300", title: "Expand All", "data-title": "Expand All", onClick: () => diffFile.onSplitHunkExpand("all", index) },
|
|
495
|
-
React__namespace.createElement(ExpandAll, { className: "fill-current" }))) : (React__namespace.createElement(React__namespace.Fragment, null,
|
|
496
|
-
React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px] hover:bg-blue-300", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onSplitHunkExpand("down", index) },
|
|
497
|
-
React__namespace.createElement(ExpandDown, { className: "fill-current" })),
|
|
498
|
-
React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px] hover:bg-blue-300", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index) },
|
|
499
|
-
React__namespace.createElement(ExpandUp, { className: "fill-current" }))))) : (React__namespace.createElement("div", { className: "min-h-[28px]" }, "\u2002"))),
|
|
500
|
-
React__namespace.createElement("td", { className: "diff-line-hunk-content pr-[10px] align-middle", style: { backgroundColor: `var(${hunkContentBGName})` } },
|
|
501
|
-
React__namespace.createElement("div", { className: "pl-[1.5em]", style: {
|
|
502
|
-
color: `var(${hunkContentColorName})`,
|
|
503
|
-
} }, ((_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})` } },
|
|
504
|
-
React__namespace.createElement("div", { className: "min-h-[28px]" }, "\u2002")))));
|
|
505
|
-
};
|
|
506
|
-
const _DiffSplitHunkLineGitLab = ({ index, diffFile, side, lineNumber, }) => {
|
|
507
|
-
var _a;
|
|
508
|
-
const currentHunk = diffFile.getSplitHunkLine(index);
|
|
509
|
-
const expandEnabled = diffFile.getExpandEnabled();
|
|
510
|
-
useSyncHeight({
|
|
511
|
-
selector: `tr[data-line="${lineNumber}-hunk"]`,
|
|
512
|
-
side: exports.SplitSide[exports.SplitSide.old],
|
|
513
|
-
enable: side === exports.SplitSide.new,
|
|
514
|
-
});
|
|
515
|
-
const couldExpand = expandEnabled && currentHunk && currentHunk.splitInfo;
|
|
516
|
-
const isExpandAll = currentHunk &&
|
|
517
|
-
currentHunk.splitInfo &&
|
|
518
|
-
currentHunk.splitInfo.endHiddenIndex - currentHunk.splitInfo.startHiddenIndex < core.composeLen;
|
|
519
|
-
const isFirstLine = currentHunk && currentHunk.isFirst;
|
|
520
|
-
const isLastLine = currentHunk && currentHunk.isLast;
|
|
521
|
-
return (React__namespace.createElement("tr", { "data-line": `${lineNumber}-hunk`, "data-state": "hunk", "data-side": exports.SplitSide[side], className: "diff-line diff-line-hunk" },
|
|
522
|
-
React__namespace.createElement("td", { className: "diff-line-hunk-action sticky left-0 w-[1%] min-w-[40px] select-none p-[1px]", style: {
|
|
523
|
-
backgroundColor: `var(${hunkLineNumberBGName})`,
|
|
524
|
-
color: `var(${plainLineNumberColorName})`,
|
|
525
|
-
width: `var(${diffAsideWidthName})`,
|
|
526
|
-
minWidth: `var(${diffAsideWidthName})`,
|
|
527
|
-
maxWidth: `var(${diffAsideWidthName})`,
|
|
528
|
-
} }, couldExpand ? (isFirstLine ? (React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px] hover:bg-blue-300", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index) },
|
|
529
|
-
React__namespace.createElement(ExpandUp, { className: "fill-current" }))) : isLastLine ? (React__namespace.createElement("button", { className: "diff-widget-tooltip relative flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px] hover:bg-blue-300", title: "Expand Down", "data-title": "Expand Down", onClick: () => {
|
|
530
|
-
diffFile.onSplitHunkExpand("down", index);
|
|
531
|
-
} },
|
|
532
|
-
React__namespace.createElement(ExpandDown, { className: "fill-current" }))) : isExpandAll ? (React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px] hover:bg-blue-300", title: "Expand All", "data-title": "Expand All", onClick: () => diffFile.onSplitHunkExpand("all", index) },
|
|
533
|
-
React__namespace.createElement(ExpandAll, { className: "fill-current" }))) : (React__namespace.createElement(React__namespace.Fragment, null,
|
|
534
|
-
React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px] hover:bg-blue-300", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onSplitHunkExpand("down", index) },
|
|
535
|
-
React__namespace.createElement(ExpandDown, { className: "fill-current" })),
|
|
536
|
-
React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px] hover:bg-blue-300", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index) },
|
|
537
|
-
React__namespace.createElement(ExpandUp, { className: "fill-current" }))))) : (React__namespace.createElement("div", { className: "min-h-[28px]" }, "\u2002"))),
|
|
538
|
-
React__namespace.createElement("td", { className: "diff-line-hunk-content pr-[10px] align-middle", style: { backgroundColor: `var(${hunkContentBGName})` } },
|
|
539
|
-
React__namespace.createElement("div", { className: "pl-[1.5em]", style: {
|
|
540
|
-
color: `var(${hunkContentColorName})`,
|
|
541
|
-
} }, ((_a = currentHunk.splitInfo) === null || _a === void 0 ? void 0 : _a.plainText) || currentHunk.text))));
|
|
542
|
-
};
|
|
543
|
-
const _DiffSplitHunkLine = ({ index, diffFile, side, lineNumber, }) => {
|
|
544
|
-
const { useDiffContext } = useDiffViewContext();
|
|
545
|
-
const diffViewMode = useDiffContext(React__namespace.useCallback((s) => s.mode, []));
|
|
546
|
-
if (diffViewMode === exports.DiffModeEnum.SplitGitHub ||
|
|
547
|
-
diffViewMode === exports.DiffModeEnum.Split ||
|
|
548
|
-
diffViewMode === exports.DiffModeEnum.Unified) {
|
|
549
|
-
return React__namespace.createElement(_DiffSplitHunkLineGitHub, { index: index, diffFile: diffFile, side: side, lineNumber: lineNumber });
|
|
550
|
-
}
|
|
551
|
-
else {
|
|
552
|
-
return React__namespace.createElement(_DiffSplitHunkLineGitLab, { index: index, diffFile: diffFile, side: side, lineNumber: lineNumber });
|
|
553
|
-
}
|
|
554
|
-
};
|
|
555
|
-
const DiffSplitHunkLine$1 = ({ index, diffFile, side, lineNumber, }) => {
|
|
556
|
-
const currentHunk = diffFile.getSplitHunkLine(index);
|
|
557
|
-
const currentIsShow = currentHunk &&
|
|
558
|
-
currentHunk.splitInfo &&
|
|
559
|
-
currentHunk.splitInfo.startHiddenIndex < currentHunk.splitInfo.endHiddenIndex;
|
|
560
|
-
const currentIsPureHunk = currentHunk && diffFile._getIsPureDiffRender() && !currentHunk.splitInfo;
|
|
561
|
-
if (!currentIsShow && !currentIsPureHunk)
|
|
562
|
-
return null;
|
|
563
|
-
return React__namespace.createElement(_DiffSplitHunkLine, { index: index, diffFile: diffFile, side: side, lineNumber: lineNumber });
|
|
564
|
-
};
|
|
565
|
-
|
|
566
306
|
const DiffSplitAddWidget = ({ side, className, lineNumber, onWidgetClick, onOpenAddWidget, }) => {
|
|
567
307
|
return (React__namespace.createElement("div", { className: "diff-add-widget-wrapper invisible select-none transition-transform hover:scale-110 group-hover:visible" +
|
|
568
308
|
(className ? " " + className : ""), style: {
|
|
@@ -739,11 +479,11 @@ const _DiffSplitLine$1 = ({ index, diffFile, lineNumber, side, }) => {
|
|
|
739
479
|
const isAdded = ((_a = currentLine === null || currentLine === void 0 ? void 0 : currentLine.diff) === null || _a === void 0 ? void 0 : _a.type) === core.DiffLineType.Add;
|
|
740
480
|
const isDelete = ((_b = currentLine === null || currentLine === void 0 ? void 0 : currentLine.diff) === null || _b === void 0 ? void 0 : _b.type) === core.DiffLineType.Delete;
|
|
741
481
|
const { useDiffContext } = useDiffViewContext();
|
|
742
|
-
const { enableHighlight, enableAddWidget, onAddWidgetClick } = useDiffContext
|
|
482
|
+
const { enableHighlight, enableAddWidget, onAddWidgetClick } = useDiffContext.useShallowStableSelector((s) => ({
|
|
743
483
|
enableHighlight: s.enableHighlight,
|
|
744
484
|
enableAddWidget: s.enableAddWidget,
|
|
745
485
|
onAddWidgetClick: s.onAddWidgetClick,
|
|
746
|
-
})
|
|
486
|
+
}));
|
|
747
487
|
const { useWidget } = useDiffWidgetContext();
|
|
748
488
|
const setWidget = useWidget.getReadonlyState().setWidget;
|
|
749
489
|
const contentBG = getContentBG(isAdded, isDelete, hasDiff);
|
|
@@ -763,7 +503,7 @@ const _DiffSplitLine$1 = ({ index, diffFile, lineNumber, side, }) => {
|
|
|
763
503
|
React__namespace.createElement(DiffContent, { enableWrap: false, diffFile: diffFile, rawLine: currentLine.value, diffLine: currentLine.diff, syntaxLine: syntaxLine, enableHighlight: enableHighlight })))) : (React__namespace.createElement("td", { className: `diff-line-${exports.SplitSide[side]}-placeholder select-none`, style: { backgroundColor: `var(${emptyBGName})` }, colSpan: 2 },
|
|
764
504
|
React__namespace.createElement("span", null, "\u2002")))));
|
|
765
505
|
};
|
|
766
|
-
const
|
|
506
|
+
const DiffSplitContentLine$1 = ({ index, diffFile, lineNumber, side, }) => {
|
|
767
507
|
const getCurrentLine = side === exports.SplitSide.old ? diffFile.getSplitLeftLine : diffFile.getSplitRightLine;
|
|
768
508
|
const currentLine = getCurrentLine(index);
|
|
769
509
|
if (currentLine === null || currentLine === void 0 ? void 0 : currentLine.isHidden)
|
|
@@ -771,14 +511,279 @@ const DiffSplitLine$1 = ({ index, diffFile, lineNumber, side, }) => {
|
|
|
771
511
|
return React__namespace.createElement(_DiffSplitLine$1, { index: index, diffFile: diffFile, lineNumber: lineNumber, side: side });
|
|
772
512
|
};
|
|
773
513
|
|
|
514
|
+
const useDomWidth = ({ selector, enable }) => {
|
|
515
|
+
const [width, setWidth] = React.useState(0);
|
|
516
|
+
const { useDiffContext } = useDiffViewContext();
|
|
517
|
+
const id = useDiffContext(React.useCallback((s) => s.id, []));
|
|
518
|
+
React.useEffect(() => {
|
|
519
|
+
if (enable) {
|
|
520
|
+
const container = document.querySelector(`#diff-root${id}`);
|
|
521
|
+
const wrapper = container === null || container === void 0 ? void 0 : container.querySelector(selector);
|
|
522
|
+
if (!wrapper)
|
|
523
|
+
return;
|
|
524
|
+
const typedWrapper = wrapper;
|
|
525
|
+
const cb = () => {
|
|
526
|
+
var _a;
|
|
527
|
+
const rect = wrapper === null || wrapper === void 0 ? void 0 : wrapper.getBoundingClientRect();
|
|
528
|
+
setWidth((_a = rect === null || rect === void 0 ? void 0 : rect.width) !== null && _a !== void 0 ? _a : 0);
|
|
529
|
+
};
|
|
530
|
+
cb();
|
|
531
|
+
const cleanCb = () => {
|
|
532
|
+
var _a;
|
|
533
|
+
typedWrapper.__observeCallback.delete(cb);
|
|
534
|
+
if (typedWrapper.__observeCallback.size === 0) {
|
|
535
|
+
(_a = typedWrapper.__observeInstance) === null || _a === void 0 ? void 0 : _a.disconnect();
|
|
536
|
+
typedWrapper.removeAttribute("data-observe");
|
|
537
|
+
delete typedWrapper.__observeCallback;
|
|
538
|
+
delete typedWrapper.__observeInstance;
|
|
539
|
+
}
|
|
540
|
+
};
|
|
541
|
+
if (typedWrapper.__observeCallback) {
|
|
542
|
+
typedWrapper.__observeCallback.add(cb);
|
|
543
|
+
return () => cleanCb();
|
|
544
|
+
}
|
|
545
|
+
typedWrapper.__observeCallback = new Set();
|
|
546
|
+
typedWrapper.__observeCallback.add(cb);
|
|
547
|
+
const observer = new ResizeObserver(() => typedWrapper.__observeCallback.forEach((cb) => cb()));
|
|
548
|
+
typedWrapper.__observeInstance = observer;
|
|
549
|
+
observer.observe(typedWrapper);
|
|
550
|
+
typedWrapper.setAttribute("data-observe", "height");
|
|
551
|
+
return () => cleanCb();
|
|
552
|
+
}
|
|
553
|
+
}, [selector, enable, id]);
|
|
554
|
+
return width;
|
|
555
|
+
};
|
|
556
|
+
|
|
557
|
+
exports.DiffModeEnum = void 0;
|
|
558
|
+
(function (DiffModeEnum) {
|
|
559
|
+
// github like
|
|
560
|
+
DiffModeEnum[DiffModeEnum["SplitGitHub"] = 1] = "SplitGitHub";
|
|
561
|
+
// gitlab like
|
|
562
|
+
DiffModeEnum[DiffModeEnum["SplitGitLab"] = 2] = "SplitGitLab";
|
|
563
|
+
DiffModeEnum[DiffModeEnum["Split"] = 3] = "Split";
|
|
564
|
+
DiffModeEnum[DiffModeEnum["Unified"] = 4] = "Unified";
|
|
565
|
+
})(exports.DiffModeEnum || (exports.DiffModeEnum = {}));
|
|
566
|
+
const DiffViewContext = React.createContext(null);
|
|
567
|
+
DiffViewContext.displayName = "DiffViewContext";
|
|
568
|
+
const useDiffViewContext = () => React.useContext(DiffViewContext);
|
|
569
|
+
|
|
570
|
+
// TODO
|
|
571
|
+
const useSyncHeight = ({ selector, wrapper, side, enable, }) => {
|
|
572
|
+
const { useDiffContext } = useDiffViewContext();
|
|
573
|
+
const id = useDiffContext(React.useCallback((s) => s.id, []));
|
|
574
|
+
useSafeLayout(() => {
|
|
575
|
+
if (enable) {
|
|
576
|
+
const container = document.querySelector(`#diff-root${id}`);
|
|
577
|
+
const elements = Array.from((container === null || container === void 0 ? void 0 : container.querySelectorAll(selector)) || []);
|
|
578
|
+
const wrappers = wrapper ? Array.from((container === null || container === void 0 ? void 0 : container.querySelectorAll(wrapper)) || []) : elements;
|
|
579
|
+
if (elements.length === 2 && wrappers.length === 2) {
|
|
580
|
+
const ele1 = elements[0];
|
|
581
|
+
const ele2 = elements[1];
|
|
582
|
+
const wrapper1 = wrappers[0];
|
|
583
|
+
const wrapper2 = wrappers[1];
|
|
584
|
+
const target = ele1.getAttribute("data-side") === side ? ele1 : ele2;
|
|
585
|
+
const cb = () => {
|
|
586
|
+
ele1.style.height = "auto";
|
|
587
|
+
ele2.style.height = "auto";
|
|
588
|
+
const rect1 = ele1.getBoundingClientRect();
|
|
589
|
+
const rect2 = ele2.getBoundingClientRect();
|
|
590
|
+
if (rect1.height !== rect2.height) {
|
|
591
|
+
const maxHeight = Math.max(rect1.height, rect2.height);
|
|
592
|
+
wrapper1.style.height = maxHeight + "px";
|
|
593
|
+
wrapper2.style.height = maxHeight + "px";
|
|
594
|
+
wrapper1.setAttribute("data-sync-height", String(maxHeight));
|
|
595
|
+
wrapper2.setAttribute("data-sync-height", String(maxHeight));
|
|
596
|
+
}
|
|
597
|
+
else {
|
|
598
|
+
wrapper1.removeAttribute("data-sync-height");
|
|
599
|
+
wrapper2.removeAttribute("data-sync-height");
|
|
600
|
+
}
|
|
601
|
+
};
|
|
602
|
+
cb();
|
|
603
|
+
const observer = new ResizeObserver(cb);
|
|
604
|
+
observer.observe(target);
|
|
605
|
+
target.setAttribute("data-observe", "height");
|
|
606
|
+
return () => {
|
|
607
|
+
observer.disconnect();
|
|
608
|
+
target === null || target === void 0 ? void 0 : target.removeAttribute("data-observe");
|
|
609
|
+
};
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
}, [selector, enable, side, id, wrapper]);
|
|
613
|
+
};
|
|
614
|
+
|
|
615
|
+
const _DiffSplitExtendLine$1 = ({ index, diffFile, oldLineExtend, newLineExtend, side, lineNumber, }) => {
|
|
616
|
+
const { useDiffContext } = useDiffViewContext();
|
|
617
|
+
const oldLine = diffFile.getSplitLeftLine(index);
|
|
618
|
+
const newLine = diffFile.getSplitRightLine(index);
|
|
619
|
+
const renderExtendLine = useDiffContext.useShallowStableSelector((s) => s.renderExtendLine);
|
|
620
|
+
const currentExtend = side === exports.SplitSide.old ? oldLineExtend : newLineExtend;
|
|
621
|
+
const currentLineNumber = side === exports.SplitSide.old ? oldLine.lineNumber : newLine.lineNumber;
|
|
622
|
+
useSyncHeight({
|
|
623
|
+
selector: `div[data-line="${lineNumber}-extend-content"]`,
|
|
624
|
+
wrapper: `tr[data-line="${lineNumber}-extend"]`,
|
|
625
|
+
side: exports.SplitSide[side],
|
|
626
|
+
enable: !!(currentExtend === null || currentExtend === void 0 ? void 0 : currentExtend.data) && typeof renderExtendLine === "function",
|
|
627
|
+
});
|
|
628
|
+
const width = useDomWidth({
|
|
629
|
+
selector: side === exports.SplitSide.old ? ".old-diff-table-wrapper" : ".new-diff-table-wrapper",
|
|
630
|
+
enable: !!(currentExtend === null || currentExtend === void 0 ? void 0 : currentExtend.data) && typeof renderExtendLine === "function",
|
|
631
|
+
});
|
|
632
|
+
if (!renderExtendLine)
|
|
633
|
+
return null;
|
|
634
|
+
return (React__namespace.createElement("tr", { "data-line": `${lineNumber}-extend`, "data-state": "extend", "data-side": exports.SplitSide[side], className: "diff-line diff-line-extend" }, currentExtend ? (React__namespace.createElement("td", { className: `diff-line-extend-${exports.SplitSide[side]}-content p-0`, colSpan: 2 },
|
|
635
|
+
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 &&
|
|
636
|
+
(currentExtend === null || currentExtend === void 0 ? void 0 : currentExtend.data) &&
|
|
637
|
+
(renderExtendLine === null || renderExtendLine === void 0 ? void 0 : renderExtendLine({
|
|
638
|
+
diffFile,
|
|
639
|
+
side,
|
|
640
|
+
lineNumber: currentLineNumber,
|
|
641
|
+
data: currentExtend.data,
|
|
642
|
+
onUpdate: diffFile.notifyAll,
|
|
643
|
+
}))))) : (React__namespace.createElement("td", { className: `diff-line-extend-${exports.SplitSide[side]}-placeholder select-none p-0`, style: { backgroundColor: `var(${emptyBGName})` }, colSpan: 2 },
|
|
644
|
+
React__namespace.createElement("div", { "data-line": `${lineNumber}-extend-content`, "data-side": exports.SplitSide[side] }, "\u2002")))));
|
|
645
|
+
};
|
|
646
|
+
const DiffSplitExtendLine$1 = ({ index, diffFile, side, lineNumber, }) => {
|
|
647
|
+
const { useDiffContext } = useDiffViewContext();
|
|
648
|
+
const oldLine = diffFile.getSplitLeftLine(index);
|
|
649
|
+
const newLine = diffFile.getSplitRightLine(index);
|
|
650
|
+
const { oldLineExtend, newLineExtend } = useDiffContext(React__namespace.useCallback((s) => {
|
|
651
|
+
var _a, _b, _c, _d;
|
|
652
|
+
return ({
|
|
653
|
+
oldLineExtend: (_b = (_a = s.extendData) === null || _a === void 0 ? void 0 : _a.oldFile) === null || _b === void 0 ? void 0 : _b[oldLine === null || oldLine === void 0 ? void 0 : oldLine.lineNumber],
|
|
654
|
+
newLineExtend: (_d = (_c = s.extendData) === null || _c === void 0 ? void 0 : _c.newFile) === null || _d === void 0 ? void 0 : _d[newLine === null || newLine === void 0 ? void 0 : newLine.lineNumber],
|
|
655
|
+
});
|
|
656
|
+
}, [oldLine === null || oldLine === void 0 ? void 0 : oldLine.lineNumber, newLine === null || newLine === void 0 ? void 0 : newLine.lineNumber]));
|
|
657
|
+
const hasExtend = (oldLineExtend === null || oldLineExtend === void 0 ? void 0 : oldLineExtend.data) || (newLineExtend === null || newLineExtend === void 0 ? void 0 : newLineExtend.data);
|
|
658
|
+
// if the expand action not enabled, the `isHidden` property will never change
|
|
659
|
+
const enableExpand = diffFile.getExpandEnabled();
|
|
660
|
+
const currentLine = side === exports.SplitSide.old ? oldLine : newLine;
|
|
661
|
+
const currentIsShow = hasExtend && (!currentLine.isHidden || !enableExpand);
|
|
662
|
+
if (!currentIsShow)
|
|
663
|
+
return null;
|
|
664
|
+
return (React__namespace.createElement(_DiffSplitExtendLine$1, { side: side, index: index, diffFile: diffFile, lineNumber: lineNumber, oldLineExtend: oldLineExtend, newLineExtend: newLineExtend }));
|
|
665
|
+
};
|
|
666
|
+
|
|
667
|
+
const ExpandDown = ({ className }) => {
|
|
668
|
+
return (React__namespace.createElement("svg", { "aria-hidden": "true", height: "16", viewBox: "0 0 16 16", version: "1.1", width: "16", className: className },
|
|
669
|
+
React__namespace.createElement("path", { d: "m8.177 14.323 2.896-2.896a.25.25 0 0 0-.177-.427H8.75V7.764a.75.75 0 1 0-1.5 0V11H5.104a.25.25 0 0 0-.177.427l2.896 2.896a.25.25 0 0 0 .354 0ZM2.25 5a.75.75 0 0 0 0-1.5h-.5a.75.75 0 0 0 0 1.5h.5ZM6 4.25a.75.75 0 0 1-.75.75h-.5a.75.75 0 0 1 0-1.5h.5a.75.75 0 0 1 .75.75ZM8.25 5a.75.75 0 0 0 0-1.5h-.5a.75.75 0 0 0 0 1.5h.5ZM12 4.25a.75.75 0 0 1-.75.75h-.5a.75.75 0 0 1 0-1.5h.5a.75.75 0 0 1 .75.75Zm2.25.75a.75.75 0 0 0 0-1.5h-.5a.75.75 0 0 0 0 1.5h.5Z" })));
|
|
670
|
+
};
|
|
671
|
+
const ExpandUp = ({ className }) => {
|
|
672
|
+
return (React__namespace.createElement("svg", { "aria-hidden": "true", height: "16", viewBox: "0 0 16 16", version: "1.1", width: "16", className: className },
|
|
673
|
+
React__namespace.createElement("path", { d: "M7.823 1.677 4.927 4.573A.25.25 0 0 0 5.104 5H7.25v3.236a.75.75 0 1 0 1.5 0V5h2.146a.25.25 0 0 0 .177-.427L8.177 1.677a.25.25 0 0 0-.354 0ZM13.75 11a.75.75 0 0 0 0 1.5h.5a.75.75 0 0 0 0-1.5h-.5Zm-3.75.75a.75.75 0 0 1 .75-.75h.5a.75.75 0 0 1 0 1.5h-.5a.75.75 0 0 1-.75-.75ZM7.75 11a.75.75 0 0 0 0 1.5h.5a.75.75 0 0 0 0-1.5h-.5ZM4 11.75a.75.75 0 0 1 .75-.75h.5a.75.75 0 0 1 0 1.5h-.5a.75.75 0 0 1-.75-.75ZM1.75 11a.75.75 0 0 0 0 1.5h.5a.75.75 0 0 0 0-1.5h-.5Z" })));
|
|
674
|
+
};
|
|
675
|
+
const ExpandAll = ({ className }) => {
|
|
676
|
+
return (React__namespace.createElement("svg", { "aria-hidden": "true", height: "16", viewBox: "0 0 16 16", version: "1.1", width: "16", className: className },
|
|
677
|
+
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" })));
|
|
678
|
+
};
|
|
679
|
+
|
|
680
|
+
const _DiffSplitHunkLineGitHub = ({ index, diffFile, side, lineNumber, }) => {
|
|
681
|
+
var _a;
|
|
682
|
+
const currentHunk = diffFile.getSplitHunkLine(index);
|
|
683
|
+
const expandEnabled = diffFile.getExpandEnabled();
|
|
684
|
+
useSyncHeight({
|
|
685
|
+
selector: `tr[data-line="${lineNumber}-hunk"]`,
|
|
686
|
+
side: exports.SplitSide[exports.SplitSide.old],
|
|
687
|
+
enable: side === exports.SplitSide.new,
|
|
688
|
+
});
|
|
689
|
+
const enableHunkAction = side === exports.SplitSide.old;
|
|
690
|
+
const couldExpand = expandEnabled && currentHunk && currentHunk.splitInfo;
|
|
691
|
+
const isExpandAll = currentHunk &&
|
|
692
|
+
currentHunk.splitInfo &&
|
|
693
|
+
currentHunk.splitInfo.endHiddenIndex - currentHunk.splitInfo.startHiddenIndex < core.composeLen;
|
|
694
|
+
const isFirstLine = currentHunk && currentHunk.isFirst;
|
|
695
|
+
const isLastLine = currentHunk && currentHunk.isLast;
|
|
696
|
+
return (React__namespace.createElement("tr", { "data-line": `${lineNumber}-hunk`, "data-state": "hunk", "data-side": exports.SplitSide[side], className: "diff-line diff-line-hunk" }, enableHunkAction ? (React__namespace.createElement(React__namespace.Fragment, null,
|
|
697
|
+
React__namespace.createElement("td", { className: "diff-line-hunk-action sticky left-0 w-[1%] min-w-[40px] select-none p-[1px]", style: {
|
|
698
|
+
backgroundColor: `var(${hunkLineNumberBGName})`,
|
|
699
|
+
color: `var(${plainLineNumberColorName})`,
|
|
700
|
+
width: `var(${diffAsideWidthName})`,
|
|
701
|
+
minWidth: `var(${diffAsideWidthName})`,
|
|
702
|
+
maxWidth: `var(${diffAsideWidthName})`,
|
|
703
|
+
} }, 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) },
|
|
704
|
+
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: () => {
|
|
705
|
+
diffFile.onSplitHunkExpand("down", index);
|
|
706
|
+
} },
|
|
707
|
+
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) },
|
|
708
|
+
React__namespace.createElement(ExpandAll, { className: "fill-current" }))) : (React__namespace.createElement(React__namespace.Fragment, null,
|
|
709
|
+
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) },
|
|
710
|
+
React__namespace.createElement(ExpandDown, { className: "fill-current" })),
|
|
711
|
+
React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index) },
|
|
712
|
+
React__namespace.createElement(ExpandUp, { className: "fill-current" }))))) : (React__namespace.createElement("div", { className: "min-h-[28px]" }, "\u2002"))),
|
|
713
|
+
React__namespace.createElement("td", { className: "diff-line-hunk-content pr-[10px] align-middle", style: { backgroundColor: `var(${hunkContentBGName})` } },
|
|
714
|
+
React__namespace.createElement("div", { className: "pl-[1.5em]", style: {
|
|
715
|
+
color: `var(${hunkContentColorName})`,
|
|
716
|
+
} }, ((_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})` } },
|
|
717
|
+
React__namespace.createElement("div", { className: "min-h-[28px]" }, "\u2002")))));
|
|
718
|
+
};
|
|
719
|
+
const _DiffSplitHunkLineGitLab = ({ index, diffFile, side, lineNumber, }) => {
|
|
720
|
+
var _a;
|
|
721
|
+
const currentHunk = diffFile.getSplitHunkLine(index);
|
|
722
|
+
const expandEnabled = diffFile.getExpandEnabled();
|
|
723
|
+
useSyncHeight({
|
|
724
|
+
selector: `tr[data-line="${lineNumber}-hunk"]`,
|
|
725
|
+
side: exports.SplitSide[side],
|
|
726
|
+
enable: true,
|
|
727
|
+
});
|
|
728
|
+
const couldExpand = expandEnabled && currentHunk && currentHunk.splitInfo;
|
|
729
|
+
const isExpandAll = currentHunk &&
|
|
730
|
+
currentHunk.splitInfo &&
|
|
731
|
+
currentHunk.splitInfo.endHiddenIndex - currentHunk.splitInfo.startHiddenIndex < core.composeLen;
|
|
732
|
+
const isFirstLine = currentHunk && currentHunk.isFirst;
|
|
733
|
+
const isLastLine = currentHunk && currentHunk.isLast;
|
|
734
|
+
return (React__namespace.createElement("tr", { "data-line": `${lineNumber}-hunk`, "data-state": "hunk", "data-side": exports.SplitSide[side], className: "diff-line diff-line-hunk" },
|
|
735
|
+
React__namespace.createElement("td", { className: "diff-line-hunk-action sticky left-0 w-[1%] min-w-[40px] select-none p-[1px]", style: {
|
|
736
|
+
backgroundColor: `var(${hunkLineNumberBGName})`,
|
|
737
|
+
color: `var(${plainLineNumberColorName})`,
|
|
738
|
+
width: `var(${diffAsideWidthName})`,
|
|
739
|
+
minWidth: `var(${diffAsideWidthName})`,
|
|
740
|
+
maxWidth: `var(${diffAsideWidthName})`,
|
|
741
|
+
} }, 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) },
|
|
742
|
+
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: () => {
|
|
743
|
+
diffFile.onSplitHunkExpand("down", index);
|
|
744
|
+
} },
|
|
745
|
+
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) },
|
|
746
|
+
React__namespace.createElement(ExpandAll, { className: "fill-current" }))) : (React__namespace.createElement(React__namespace.Fragment, null,
|
|
747
|
+
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) },
|
|
748
|
+
React__namespace.createElement(ExpandDown, { className: "fill-current" })),
|
|
749
|
+
React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index) },
|
|
750
|
+
React__namespace.createElement(ExpandUp, { className: "fill-current" }))))) : (React__namespace.createElement("div", { className: "min-h-[28px]" }, "\u2002"))),
|
|
751
|
+
React__namespace.createElement("td", { className: "diff-line-hunk-content pr-[10px] align-middle", style: { backgroundColor: `var(${hunkContentBGName})` } },
|
|
752
|
+
React__namespace.createElement("div", { className: "pl-[1.5em]", style: {
|
|
753
|
+
color: `var(${hunkContentColorName})`,
|
|
754
|
+
} }, ((_a = currentHunk.splitInfo) === null || _a === void 0 ? void 0 : _a.plainText) || currentHunk.text))));
|
|
755
|
+
};
|
|
756
|
+
const _DiffSplitHunkLine$1 = ({ index, diffFile, side, lineNumber, }) => {
|
|
757
|
+
const { useDiffContext } = useDiffViewContext();
|
|
758
|
+
const diffViewMode = useDiffContext.useShallowStableSelector((s) => s.mode);
|
|
759
|
+
if (diffViewMode === exports.DiffModeEnum.SplitGitHub ||
|
|
760
|
+
diffViewMode === exports.DiffModeEnum.Split ||
|
|
761
|
+
diffViewMode === exports.DiffModeEnum.Unified) {
|
|
762
|
+
return React__namespace.createElement(_DiffSplitHunkLineGitHub, { index: index, diffFile: diffFile, side: side, lineNumber: lineNumber });
|
|
763
|
+
}
|
|
764
|
+
else {
|
|
765
|
+
return React__namespace.createElement(_DiffSplitHunkLineGitLab, { index: index, diffFile: diffFile, side: side, lineNumber: lineNumber });
|
|
766
|
+
}
|
|
767
|
+
};
|
|
768
|
+
const DiffSplitHunkLine$1 = ({ index, diffFile, side, lineNumber, }) => {
|
|
769
|
+
const currentHunk = diffFile.getSplitHunkLine(index);
|
|
770
|
+
const currentIsShow = currentHunk &&
|
|
771
|
+
currentHunk.splitInfo &&
|
|
772
|
+
currentHunk.splitInfo.startHiddenIndex < currentHunk.splitInfo.endHiddenIndex;
|
|
773
|
+
const currentIsPureHunk = currentHunk && diffFile._getIsPureDiffRender() && !currentHunk.splitInfo;
|
|
774
|
+
if (!currentIsShow && !currentIsPureHunk)
|
|
775
|
+
return null;
|
|
776
|
+
return React__namespace.createElement(_DiffSplitHunkLine$1, { index: index, diffFile: diffFile, side: side, lineNumber: lineNumber });
|
|
777
|
+
};
|
|
778
|
+
|
|
774
779
|
const _DiffSplitWidgetLine$1 = ({ diffFile, side, lineNumber, currentLine, setWidget, currentWidget, }) => {
|
|
775
|
-
const otherSide = side === exports.SplitSide.old ? exports.SplitSide.new : exports.SplitSide.old;
|
|
776
780
|
const { useDiffContext } = useDiffViewContext();
|
|
777
|
-
const renderWidgetLine = useDiffContext
|
|
781
|
+
const renderWidgetLine = useDiffContext.useShallowStableSelector((s) => s.renderWidgetLine);
|
|
778
782
|
useSyncHeight({
|
|
779
|
-
selector: `
|
|
780
|
-
|
|
781
|
-
|
|
783
|
+
selector: `div[data-line="${lineNumber}-widget-content"]`,
|
|
784
|
+
wrapper: `tr[data-line="${lineNumber}-widget"]`,
|
|
785
|
+
side: exports.SplitSide[side],
|
|
786
|
+
enable: currentWidget && typeof renderWidgetLine === "function",
|
|
782
787
|
});
|
|
783
788
|
const width = useDomWidth({
|
|
784
789
|
selector: side === exports.SplitSide.old ? ".old-diff-table-wrapper" : ".new-diff-table-wrapper",
|
|
@@ -787,18 +792,22 @@ const _DiffSplitWidgetLine$1 = ({ diffFile, side, lineNumber, currentLine, setWi
|
|
|
787
792
|
if (!renderWidgetLine)
|
|
788
793
|
return null;
|
|
789
794
|
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 },
|
|
790
|
-
React__namespace.createElement("div", { className: "diff-line-widget-wrapper sticky left-0", style: { width } }, width > 0 &&
|
|
795
|
+
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 &&
|
|
791
796
|
(renderWidgetLine === null || renderWidgetLine === void 0 ? void 0 : renderWidgetLine({
|
|
792
797
|
diffFile,
|
|
793
798
|
side,
|
|
794
799
|
lineNumber: currentLine.lineNumber,
|
|
795
800
|
onClose: () => setWidget({}),
|
|
796
801
|
}))))) : (React__namespace.createElement("td", { className: `diff-line-widget-${exports.SplitSide[side]}-placeholder p-0`, style: { backgroundColor: `var(${emptyBGName})` }, colSpan: 2 },
|
|
797
|
-
React__namespace.createElement("
|
|
802
|
+
React__namespace.createElement("div", { "data-line": `${lineNumber}-widget-content`, "data-side": exports.SplitSide[side] }, "\u2002")))));
|
|
798
803
|
};
|
|
799
804
|
const DiffSplitWidgetLine$1 = ({ index, diffFile, side, lineNumber, }) => {
|
|
800
805
|
const { useWidget } = useDiffWidgetContext();
|
|
801
|
-
const { widgetLineNumber, widgetSide, setWidget } = useWidget
|
|
806
|
+
const { widgetLineNumber, widgetSide, setWidget } = useWidget.useShallowStableSelector((s) => ({
|
|
807
|
+
widgetLineNumber: s.widgetLineNumber,
|
|
808
|
+
widgetSide: s.widgetSide,
|
|
809
|
+
setWidget: s.setWidget,
|
|
810
|
+
}));
|
|
802
811
|
const oldLine = diffFile.getSplitLeftLine(index);
|
|
803
812
|
const newLine = diffFile.getSplitRightLine(index);
|
|
804
813
|
const oldLineWidget = oldLine.lineNumber && widgetSide === exports.SplitSide.old && widgetLineNumber === oldLine.lineNumber;
|
|
@@ -823,7 +832,7 @@ const onMouseDown$1 = (e) => {
|
|
|
823
832
|
const DiffSplitViewTable = ({ side, diffFile }) => {
|
|
824
833
|
const className = side === exports.SplitSide.new ? "new-diff-table" : "old-diff-table";
|
|
825
834
|
const lines = core.getSplitContentLines(diffFile);
|
|
826
|
-
return (React__namespace.createElement("table", { className: className + " w-full border-collapse", "data-mode": exports.SplitSide[side] },
|
|
835
|
+
return (React__namespace.createElement("table", { className: className + " w-full border-collapse border-spacing-0", "data-mode": exports.SplitSide[side] },
|
|
827
836
|
React__namespace.createElement("colgroup", null,
|
|
828
837
|
React__namespace.createElement("col", { className: `diff-table-${exports.SplitSide[side]}-num-col` }),
|
|
829
838
|
React__namespace.createElement("col", { className: `diff-table-${exports.SplitSide[side]}-content-col` })),
|
|
@@ -838,7 +847,7 @@ const DiffSplitViewTable = ({ side, diffFile }) => {
|
|
|
838
847
|
React__namespace.createElement("tbody", { className: "diff-table-body leading-[1.4]", onMouseDownCapture: onMouseDown$1 },
|
|
839
848
|
lines.map((line) => (React__namespace.createElement(React.Fragment, { key: line.index },
|
|
840
849
|
React__namespace.createElement(DiffSplitHunkLine$1, { index: line.index, side: side, lineNumber: line.lineNumber, diffFile: diffFile }),
|
|
841
|
-
React__namespace.createElement(
|
|
850
|
+
React__namespace.createElement(DiffSplitContentLine$1, { index: line.index, side: side, lineNumber: line.lineNumber, diffFile: diffFile }),
|
|
842
851
|
React__namespace.createElement(DiffSplitWidgetLine$1, { index: line.index, side: side, lineNumber: line.lineNumber, diffFile: diffFile }),
|
|
843
852
|
React__namespace.createElement(DiffSplitExtendLine$1, { index: line.index, side: side, lineNumber: line.lineNumber, diffFile: diffFile })))),
|
|
844
853
|
React__namespace.createElement(DiffSplitHunkLine$1, { side: side, index: diffFile.splitLineLength, lineNumber: diffFile.splitLineLength, diffFile: diffFile }))));
|
|
@@ -848,7 +857,7 @@ const DiffSplitViewNormal = React.memo(({ diffFile }) => {
|
|
|
848
857
|
const ref2 = React.useRef(null);
|
|
849
858
|
const splitLineLength = Math.max(diffFile.splitLineLength, diffFile.fileLineLength);
|
|
850
859
|
const { useDiffContext } = useDiffViewContext();
|
|
851
|
-
const fontSize = useDiffContext
|
|
860
|
+
const fontSize = useDiffContext.useShallowStableSelector((s) => s.fontSize);
|
|
852
861
|
index_js.useSyncExternalStore(diffFile.subscribe, diffFile.getUpdateCount);
|
|
853
862
|
React.useEffect(() => {
|
|
854
863
|
const left = ref1.current;
|
|
@@ -863,8 +872,8 @@ const DiffSplitViewNormal = React.memo(({ diffFile }) => {
|
|
|
863
872
|
font,
|
|
864
873
|
});
|
|
865
874
|
const width = Math.max(40, _width + 25);
|
|
866
|
-
return (React__namespace.createElement("div", { className: "split-diff-view split-diff-view-
|
|
867
|
-
React__namespace.createElement("div", { className: "old-diff-table-wrapper
|
|
875
|
+
return (React__namespace.createElement("div", { className: "split-diff-view split-diff-view-normal flex w-full basis-[50%]" },
|
|
876
|
+
React__namespace.createElement("div", { className: "old-diff-table-wrapper diff-table-scroll-container w-full overflow-x-auto overflow-y-hidden", ref: ref1, style: {
|
|
868
877
|
// @ts-ignore
|
|
869
878
|
[diffAsideWidthName]: `${Math.round(width)}px`,
|
|
870
879
|
overscrollBehaviorX: "none",
|
|
@@ -872,8 +881,8 @@ const DiffSplitViewNormal = React.memo(({ diffFile }) => {
|
|
|
872
881
|
fontSize: `var(${diffFontSizeName})`,
|
|
873
882
|
} },
|
|
874
883
|
React__namespace.createElement(DiffSplitViewTable, { side: exports.SplitSide.old, diffFile: diffFile })),
|
|
875
|
-
React__namespace.createElement("div", { className: "diff-split-line w-[1.5px]
|
|
876
|
-
React__namespace.createElement("div", { className: "new-diff-table-wrapper
|
|
884
|
+
React__namespace.createElement("div", { className: "diff-split-line w-[1.5px]", style: { backgroundColor: `var(${borderColorName})` } }),
|
|
885
|
+
React__namespace.createElement("div", { className: "new-diff-table-wrapper diff-table-scroll-container w-full overflow-x-auto overflow-y-hidden", ref: ref2, style: {
|
|
877
886
|
// @ts-ignore
|
|
878
887
|
[diffAsideWidthName]: `${Math.round(width)}px`,
|
|
879
888
|
overscrollBehaviorX: "none",
|
|
@@ -884,12 +893,66 @@ const DiffSplitViewNormal = React.memo(({ diffFile }) => {
|
|
|
884
893
|
});
|
|
885
894
|
DiffSplitViewNormal.displayName = "DiffSplitViewNormal";
|
|
886
895
|
|
|
896
|
+
const _DiffSplitLine = ({ index, diffFile, lineNumber }) => {
|
|
897
|
+
var _a, _b;
|
|
898
|
+
const oldLine = diffFile.getSplitLeftLine(index);
|
|
899
|
+
const newLine = diffFile.getSplitRightLine(index);
|
|
900
|
+
const oldSyntaxLine = diffFile.getOldSyntaxLine(oldLine === null || oldLine === void 0 ? void 0 : oldLine.lineNumber);
|
|
901
|
+
const newSyntaxLine = diffFile.getNewSyntaxLine(newLine === null || newLine === void 0 ? void 0 : newLine.lineNumber);
|
|
902
|
+
const hasDiff = !!(oldLine === null || oldLine === void 0 ? void 0 : oldLine.diff) || !!(newLine === null || newLine === void 0 ? void 0 : newLine.diff);
|
|
903
|
+
const hasChange = core.checkDiffLineIncludeChange(oldLine === null || oldLine === void 0 ? void 0 : oldLine.diff) || core.checkDiffLineIncludeChange(newLine === null || newLine === void 0 ? void 0 : newLine.diff);
|
|
904
|
+
const oldLineIsDelete = ((_a = oldLine === null || oldLine === void 0 ? void 0 : oldLine.diff) === null || _a === void 0 ? void 0 : _a.type) === core.DiffLineType.Delete;
|
|
905
|
+
const newLineIsAdded = ((_b = newLine === null || newLine === void 0 ? void 0 : newLine.diff) === null || _b === void 0 ? void 0 : _b.type) === core.DiffLineType.Add;
|
|
906
|
+
const { useDiffContext } = useDiffViewContext();
|
|
907
|
+
const { enableHighlight, enableAddWidget, onAddWidgetClick } = useDiffContext.useShallowStableSelector((s) => ({
|
|
908
|
+
enableHighlight: s.enableHighlight,
|
|
909
|
+
enableAddWidget: s.enableAddWidget,
|
|
910
|
+
onAddWidgetClick: s.onAddWidgetClick,
|
|
911
|
+
}));
|
|
912
|
+
const { useWidget } = useDiffWidgetContext();
|
|
913
|
+
const setWidget = useWidget.getReadonlyState().setWidget;
|
|
914
|
+
const hasOldLine = !!oldLine.lineNumber;
|
|
915
|
+
const hasNewLine = !!newLine.lineNumber;
|
|
916
|
+
const oldLineContentBG = getContentBG(false, oldLineIsDelete, hasDiff);
|
|
917
|
+
const oldLineNumberBG = getLineNumberBG(false, oldLineIsDelete, hasDiff);
|
|
918
|
+
const newLineContentBG = getContentBG(newLineIsAdded, false, hasDiff);
|
|
919
|
+
const newLineNumberBG = getLineNumberBG(newLineIsAdded, false, hasDiff);
|
|
920
|
+
return (React__namespace.createElement("tr", { "data-line": lineNumber, "data-state": hasDiff ? "diff" : "plain", className: "diff-line" },
|
|
921
|
+
hasOldLine ? (React__namespace.createElement(React__namespace.Fragment, null,
|
|
922
|
+
React__namespace.createElement("td", { className: "diff-line-old-num group relative w-[1%] min-w-[40px] select-none pl-[10px] pr-[10px] text-right align-top", "data-side": exports.SplitSide[exports.SplitSide.old], style: { backgroundColor: oldLineNumberBG, color: `var(${plainLineNumberColorName})` } },
|
|
923
|
+
hasDiff && enableAddWidget && (React__namespace.createElement(DiffSplitAddWidget, { index: index, lineNumber: oldLine.lineNumber, side: exports.SplitSide.old, diffFile: diffFile, onWidgetClick: (...props) => { var _a; return (_a = onAddWidgetClick.current) === null || _a === void 0 ? void 0 : _a.call(onAddWidgetClick, ...props); }, className: "absolute left-[100%] z-[1] translate-x-[-50%]", onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber: lineNumber, side: side }) })),
|
|
924
|
+
React__namespace.createElement("span", { "data-line-num": oldLine.lineNumber, style: { opacity: hasChange ? undefined : 0.5 } }, oldLine.lineNumber)),
|
|
925
|
+
React__namespace.createElement("td", { className: "diff-line-old-content group relative pr-[10px] align-top", "data-side": exports.SplitSide[exports.SplitSide.old], style: { backgroundColor: oldLineContentBG } },
|
|
926
|
+
hasDiff && enableAddWidget && (React__namespace.createElement(DiffSplitAddWidget, { index: index, lineNumber: oldLine.lineNumber, side: exports.SplitSide.old, diffFile: diffFile, onWidgetClick: (...props) => { var _a; return (_a = onAddWidgetClick.current) === null || _a === void 0 ? void 0 : _a.call(onAddWidgetClick, ...props); }, className: "absolute right-[100%] z-[1] translate-x-[50%]", onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber: lineNumber, side: side }) })),
|
|
927
|
+
React__namespace.createElement(DiffContent, { enableWrap: true, diffFile: diffFile, rawLine: oldLine.value, diffLine: oldLine.diff, syntaxLine: oldSyntaxLine, enableHighlight: enableHighlight })))) : (React__namespace.createElement("td", { className: "diff-line-old-placeholder select-none", "data-side": exports.SplitSide[exports.SplitSide.old], style: { backgroundColor: `var(${emptyBGName})` }, colSpan: 2 },
|
|
928
|
+
React__namespace.createElement("span", null, "\u2002"))),
|
|
929
|
+
hasNewLine ? (React__namespace.createElement(React__namespace.Fragment, null,
|
|
930
|
+
React__namespace.createElement("td", { className: "diff-line-new-num group relative w-[1%] min-w-[40px] select-none border-l-[1px] pl-[10px] pr-[10px] text-right align-top", "data-side": exports.SplitSide[exports.SplitSide.new], style: {
|
|
931
|
+
backgroundColor: newLineNumberBG,
|
|
932
|
+
color: `var(${plainLineNumberColorName})`,
|
|
933
|
+
borderLeftColor: `var(${borderColorName})`,
|
|
934
|
+
} },
|
|
935
|
+
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 }) })),
|
|
936
|
+
React__namespace.createElement("span", { "data-line-num": newLine.lineNumber, style: { opacity: hasChange ? undefined : 0.5 } }, newLine.lineNumber)),
|
|
937
|
+
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 } },
|
|
938
|
+
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 }) })),
|
|
939
|
+
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 },
|
|
940
|
+
React__namespace.createElement("span", null, "\u2002")))));
|
|
941
|
+
};
|
|
942
|
+
const DiffSplitContentLine = ({ index, diffFile, lineNumber, }) => {
|
|
943
|
+
const oldLine = diffFile.getSplitLeftLine(index);
|
|
944
|
+
const newLine = diffFile.getSplitRightLine(index);
|
|
945
|
+
if ((oldLine === null || oldLine === void 0 ? void 0 : oldLine.isHidden) && (newLine === null || newLine === void 0 ? void 0 : newLine.isHidden))
|
|
946
|
+
return null;
|
|
947
|
+
return React__namespace.createElement(_DiffSplitLine, { index: index, diffFile: diffFile, lineNumber: lineNumber });
|
|
948
|
+
};
|
|
949
|
+
|
|
887
950
|
const _DiffSplitExtendLine = ({ index, diffFile, lineNumber, oldLineExtend, newLineExtend, }) => {
|
|
888
951
|
const { useDiffContext } = useDiffViewContext();
|
|
889
952
|
const oldLine = diffFile.getSplitLeftLine(index);
|
|
890
953
|
const newLine = diffFile.getSplitRightLine(index);
|
|
891
954
|
// 需要显示的时候才进行方法订阅,可以大幅度提高性能
|
|
892
|
-
const renderExtendLine = useDiffContext
|
|
955
|
+
const renderExtendLine = useDiffContext.useShallowStableSelector((s) => s.renderExtendLine);
|
|
893
956
|
if (!renderExtendLine)
|
|
894
957
|
return null;
|
|
895
958
|
return (React__namespace.createElement("tr", { "data-line": `${lineNumber}-extend`, "data-state": "extend", className: "diff-line diff-line-extend" },
|
|
@@ -903,7 +966,7 @@ const _DiffSplitExtendLine = ({ index, diffFile, lineNumber, oldLineExtend, newL
|
|
|
903
966
|
onUpdate: diffFile.notifyAll,
|
|
904
967
|
}))))) : (React__namespace.createElement("td", { className: "diff-line-extend-old-placeholder select-none p-0", style: { backgroundColor: `var(${emptyBGName})` }, colSpan: 2 },
|
|
905
968
|
React__namespace.createElement("span", null, "\u2002"))),
|
|
906
|
-
newLineExtend ? (React__namespace.createElement("td", { className: "diff-line-extend-new-content border-l-[1px]
|
|
969
|
+
newLineExtend ? (React__namespace.createElement("td", { className: "diff-line-extend-new-content border-l-[1px] p-0", style: { borderLeftColor: `var(${borderColorName})` }, colSpan: 2 },
|
|
907
970
|
React__namespace.createElement("div", { className: "diff-line-extend-wrapper" }, (newLineExtend === null || newLineExtend === void 0 ? void 0 : newLineExtend.data) &&
|
|
908
971
|
(renderExtendLine === null || renderExtendLine === void 0 ? void 0 : renderExtendLine({
|
|
909
972
|
diffFile,
|
|
@@ -911,7 +974,7 @@ const _DiffSplitExtendLine = ({ index, diffFile, lineNumber, oldLineExtend, newL
|
|
|
911
974
|
lineNumber: newLine.lineNumber,
|
|
912
975
|
data: newLineExtend.data,
|
|
913
976
|
onUpdate: diffFile.notifyAll,
|
|
914
|
-
}))))) : (React__namespace.createElement("td", { className: "diff-line-extend-new-placeholder select-none border-l-[1px]
|
|
977
|
+
}))))) : (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 },
|
|
915
978
|
React__namespace.createElement("span", null, "\u2002")))));
|
|
916
979
|
};
|
|
917
980
|
const DiffSplitExtendLine = ({ index, diffFile, lineNumber, }) => {
|
|
@@ -942,25 +1005,19 @@ const DiffSplitHunkLineGitHub = ({ index, diffFile, lineNumber, }) => {
|
|
|
942
1005
|
const isExpandAll = currentHunk &&
|
|
943
1006
|
currentHunk.splitInfo &&
|
|
944
1007
|
currentHunk.splitInfo.endHiddenIndex - currentHunk.splitInfo.startHiddenIndex < core.composeLen;
|
|
945
|
-
const currentIsShow = currentHunk &&
|
|
946
|
-
currentHunk.splitInfo &&
|
|
947
|
-
currentHunk.splitInfo.startHiddenIndex < currentHunk.splitInfo.endHiddenIndex;
|
|
948
|
-
const currentIsPureHunk = currentHunk && diffFile._getIsPureDiffRender() && !currentHunk.splitInfo;
|
|
949
1008
|
const isFirstLine = currentHunk && currentHunk.isFirst;
|
|
950
1009
|
const isLastLine = currentHunk && currentHunk.isLast;
|
|
951
|
-
if (!currentIsShow && !currentIsPureHunk)
|
|
952
|
-
return null;
|
|
953
1010
|
return (React__namespace.createElement("tr", { "data-line": `${lineNumber}-hunk`, "data-state": "hunk", className: "diff-line diff-line-hunk" },
|
|
954
1011
|
React__namespace.createElement("td", { className: "diff-line-hunk-action relative w-[1%] min-w-[40px] select-none p-[1px]", style: {
|
|
955
1012
|
backgroundColor: `var(${hunkLineNumberBGName})`,
|
|
956
1013
|
color: `var(${plainLineNumberColorName})`,
|
|
957
|
-
} }, couldExpand ? (isFirstLine ? (React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]
|
|
958
|
-
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]
|
|
959
|
-
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]
|
|
1014
|
+
} }, 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) },
|
|
1015
|
+
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) },
|
|
1016
|
+
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) },
|
|
960
1017
|
React__namespace.createElement(ExpandAll, { className: "fill-current" }))) : (React__namespace.createElement(React__namespace.Fragment, null,
|
|
961
|
-
React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]
|
|
1018
|
+
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) },
|
|
962
1019
|
React__namespace.createElement(ExpandDown, { className: "fill-current" })),
|
|
963
|
-
React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]
|
|
1020
|
+
React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index) },
|
|
964
1021
|
React__namespace.createElement(ExpandUp, { className: "fill-current" }))))) : (React__namespace.createElement("div", { className: "min-h-[28px]" }, "\u2002"))),
|
|
965
1022
|
React__namespace.createElement("td", { className: "diff-line-hunk-content pr-[10px] align-middle", style: { backgroundColor: `var(${hunkContentBGName})` }, colSpan: 3 },
|
|
966
1023
|
React__namespace.createElement("div", { className: "pl-[1.5em]", style: {
|
|
@@ -975,49 +1032,44 @@ const DiffSplitHunkLineGitLab = ({ index, diffFile, lineNumber, }) => {
|
|
|
975
1032
|
const isExpandAll = currentHunk &&
|
|
976
1033
|
currentHunk.splitInfo &&
|
|
977
1034
|
currentHunk.splitInfo.endHiddenIndex - currentHunk.splitInfo.startHiddenIndex < core.composeLen;
|
|
978
|
-
const currentIsShow = currentHunk &&
|
|
979
|
-
currentHunk.splitInfo &&
|
|
980
|
-
currentHunk.splitInfo.startHiddenIndex < currentHunk.splitInfo.endHiddenIndex;
|
|
981
|
-
const currentIsPureHunk = currentHunk && diffFile._getIsPureDiffRender() && !currentHunk.splitInfo;
|
|
982
1035
|
const isFirstLine = currentHunk && currentHunk.isFirst;
|
|
983
1036
|
const isLastLine = currentHunk && currentHunk.isLast;
|
|
984
|
-
if (!currentIsShow && !currentIsPureHunk)
|
|
985
|
-
return null;
|
|
986
1037
|
return (React__namespace.createElement("tr", { "data-line": `${lineNumber}-hunk`, "data-state": "hunk", className: "diff-line diff-line-hunk" },
|
|
987
1038
|
React__namespace.createElement("td", { className: "diff-line-hunk-action relative w-[1%] min-w-[40px] select-none p-[1px]", style: {
|
|
988
1039
|
backgroundColor: `var(${hunkLineNumberBGName})`,
|
|
989
1040
|
color: `var(${plainLineNumberColorName})`,
|
|
990
|
-
} }, couldExpand ? (isFirstLine ? (React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]
|
|
991
|
-
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]
|
|
992
|
-
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]
|
|
1041
|
+
} }, 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) },
|
|
1042
|
+
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) },
|
|
1043
|
+
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) },
|
|
993
1044
|
React__namespace.createElement(ExpandAll, { className: "fill-current" }))) : (React__namespace.createElement(React__namespace.Fragment, null,
|
|
994
|
-
React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]
|
|
1045
|
+
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) },
|
|
995
1046
|
React__namespace.createElement(ExpandDown, { className: "fill-current" })),
|
|
996
|
-
React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]
|
|
1047
|
+
React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index) },
|
|
997
1048
|
React__namespace.createElement(ExpandUp, { className: "fill-current" }))))) : (React__namespace.createElement("div", { className: "min-h-[28px]" }, "\u2002"))),
|
|
998
1049
|
React__namespace.createElement("td", { className: "diff-line-hunk-content pr-[10px] align-middle", style: { backgroundColor: `var(${hunkContentBGName})` } },
|
|
999
1050
|
React__namespace.createElement("div", { className: "pl-[1.5em]", style: {
|
|
1000
1051
|
color: `var(${hunkContentColorName})`,
|
|
1001
1052
|
} }, ((_a = currentHunk.splitInfo) === null || _a === void 0 ? void 0 : _a.plainText) || currentHunk.text)),
|
|
1002
|
-
React__namespace.createElement("td", { className: "diff-line-hunk-action relative w-[1%] min-w-[40px] select-none border-l-[1px]
|
|
1053
|
+
React__namespace.createElement("td", { className: "diff-line-hunk-action relative w-[1%] min-w-[40px] select-none border-l-[1px] p-[1px]", style: {
|
|
1003
1054
|
backgroundColor: `var(${hunkLineNumberBGName})`,
|
|
1004
1055
|
color: `var(${plainLineNumberColorName})`,
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
React__namespace.createElement(
|
|
1056
|
+
borderLeftColor: `var(${borderColorName})`,
|
|
1057
|
+
} }, 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) },
|
|
1058
|
+
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) },
|
|
1059
|
+
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) },
|
|
1008
1060
|
React__namespace.createElement(ExpandAll, { className: "fill-current" }))) : (React__namespace.createElement(React__namespace.Fragment, null,
|
|
1009
|
-
React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]
|
|
1061
|
+
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) },
|
|
1010
1062
|
React__namespace.createElement(ExpandDown, { className: "fill-current" })),
|
|
1011
|
-
React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]
|
|
1063
|
+
React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index) },
|
|
1012
1064
|
React__namespace.createElement(ExpandUp, { className: "fill-current" }))))) : (React__namespace.createElement("div", { className: "min-h-[28px]" }, "\u2002"))),
|
|
1013
1065
|
React__namespace.createElement("td", { className: "diff-line-hunk-content pr-[10px] align-middle", style: { backgroundColor: `var(${hunkContentBGName})` } },
|
|
1014
1066
|
React__namespace.createElement("div", { className: "pl-[1.5em]", style: {
|
|
1015
1067
|
color: `var(${hunkContentColorName})`,
|
|
1016
1068
|
} }, ((_b = currentHunk.splitInfo) === null || _b === void 0 ? void 0 : _b.plainText) || currentHunk.text))));
|
|
1017
1069
|
};
|
|
1018
|
-
const
|
|
1070
|
+
const _DiffSplitHunkLine = ({ index, diffFile, lineNumber, }) => {
|
|
1019
1071
|
const { useDiffContext } = useDiffViewContext();
|
|
1020
|
-
const diffViewMode = useDiffContext
|
|
1072
|
+
const diffViewMode = useDiffContext.useShallowStableSelector((s) => s.mode);
|
|
1021
1073
|
if (diffViewMode === exports.DiffModeEnum.SplitGitHub ||
|
|
1022
1074
|
diffViewMode === exports.DiffModeEnum.Split ||
|
|
1023
1075
|
diffViewMode === exports.DiffModeEnum.Unified) {
|
|
@@ -1027,62 +1079,22 @@ const DiffSplitHunkLine = ({ index, diffFile, lineNumber, }) => {
|
|
|
1027
1079
|
return React__namespace.createElement(DiffSplitHunkLineGitLab, { index: index, diffFile: diffFile, lineNumber: lineNumber });
|
|
1028
1080
|
}
|
|
1029
1081
|
};
|
|
1030
|
-
|
|
1031
|
-
const
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
const
|
|
1036
|
-
|
|
1037
|
-
const hasDiff = !!(oldLine === null || oldLine === void 0 ? void 0 : oldLine.diff) || !!(newLine === null || newLine === void 0 ? void 0 : newLine.diff);
|
|
1038
|
-
const hasChange = core.checkDiffLineIncludeChange(oldLine === null || oldLine === void 0 ? void 0 : oldLine.diff) || core.checkDiffLineIncludeChange(newLine === null || newLine === void 0 ? void 0 : newLine.diff);
|
|
1039
|
-
const oldLineIsDelete = ((_a = oldLine === null || oldLine === void 0 ? void 0 : oldLine.diff) === null || _a === void 0 ? void 0 : _a.type) === core.DiffLineType.Delete;
|
|
1040
|
-
const newLineIsAdded = ((_b = newLine === null || newLine === void 0 ? void 0 : newLine.diff) === null || _b === void 0 ? void 0 : _b.type) === core.DiffLineType.Add;
|
|
1041
|
-
const { useDiffContext } = useDiffViewContext();
|
|
1042
|
-
const { enableHighlight, enableAddWidget, onAddWidgetClick } = useDiffContext(React__namespace.useCallback((s) => ({
|
|
1043
|
-
enableHighlight: s.enableHighlight,
|
|
1044
|
-
enableAddWidget: s.enableAddWidget,
|
|
1045
|
-
onAddWidgetClick: s.onAddWidgetClick,
|
|
1046
|
-
}), []));
|
|
1047
|
-
const { useWidget } = useDiffWidgetContext();
|
|
1048
|
-
const setWidget = useWidget.getReadonlyState().setWidget;
|
|
1049
|
-
const hasOldLine = !!oldLine.lineNumber;
|
|
1050
|
-
const hasNewLine = !!newLine.lineNumber;
|
|
1051
|
-
const oldLineContentBG = getContentBG(false, oldLineIsDelete, hasDiff);
|
|
1052
|
-
const oldLineNumberBG = getLineNumberBG(false, oldLineIsDelete, hasDiff);
|
|
1053
|
-
const newLineContentBG = getContentBG(newLineIsAdded, false, hasDiff);
|
|
1054
|
-
const newLineNumberBG = getLineNumberBG(newLineIsAdded, false, hasDiff);
|
|
1055
|
-
return (React__namespace.createElement("tr", { "data-line": lineNumber, "data-state": hasDiff ? "diff" : "plain", className: "diff-line" },
|
|
1056
|
-
hasOldLine ? (React__namespace.createElement(React__namespace.Fragment, null,
|
|
1057
|
-
React__namespace.createElement("td", { className: "diff-line-old-num group relative w-[1%] min-w-[40px] select-none pl-[10px] pr-[10px] text-right align-top", "data-side": exports.SplitSide[exports.SplitSide.old], style: { backgroundColor: oldLineNumberBG, color: `var(${plainLineNumberColorName})` } },
|
|
1058
|
-
hasDiff && enableAddWidget && (React__namespace.createElement(DiffSplitAddWidget, { index: index, lineNumber: oldLine.lineNumber, side: exports.SplitSide.old, diffFile: diffFile, onWidgetClick: (...props) => { var _a; return (_a = onAddWidgetClick.current) === null || _a === void 0 ? void 0 : _a.call(onAddWidgetClick, ...props); }, className: "absolute left-[100%] z-[1] translate-x-[-50%]", onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber: lineNumber, side: side }) })),
|
|
1059
|
-
React__namespace.createElement("span", { "data-line-num": oldLine.lineNumber, style: { opacity: hasChange ? undefined : 0.5 } }, oldLine.lineNumber)),
|
|
1060
|
-
React__namespace.createElement("td", { className: "diff-line-old-content group relative pr-[10px] align-top", "data-side": exports.SplitSide[exports.SplitSide.old], style: { backgroundColor: oldLineContentBG } },
|
|
1061
|
-
hasDiff && enableAddWidget && (React__namespace.createElement(DiffSplitAddWidget, { index: index, lineNumber: oldLine.lineNumber, side: exports.SplitSide.old, diffFile: diffFile, onWidgetClick: (...props) => { var _a; return (_a = onAddWidgetClick.current) === null || _a === void 0 ? void 0 : _a.call(onAddWidgetClick, ...props); }, className: "absolute right-[100%] z-[1] translate-x-[50%]", onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber: lineNumber, side: side }) })),
|
|
1062
|
-
React__namespace.createElement(DiffContent, { enableWrap: true, diffFile: diffFile, rawLine: oldLine.value, diffLine: oldLine.diff, syntaxLine: oldSyntaxLine, enableHighlight: enableHighlight })))) : (React__namespace.createElement("td", { className: "diff-line-old-placeholder select-none", "data-side": exports.SplitSide[exports.SplitSide.old], style: { backgroundColor: `var(${emptyBGName})` }, colSpan: 2 },
|
|
1063
|
-
React__namespace.createElement("span", null, "\u2002"))),
|
|
1064
|
-
hasNewLine ? (React__namespace.createElement(React__namespace.Fragment, null,
|
|
1065
|
-
React__namespace.createElement("td", { className: "diff-line-new-num group relative w-[1%] min-w-[40px] select-none border-l-[1px] border-l-[rgb(222,222,222)] pl-[10px] pr-[10px] text-right align-top", "data-side": exports.SplitSide[exports.SplitSide.new], style: { backgroundColor: newLineNumberBG, color: `var(${plainLineNumberColorName})` } },
|
|
1066
|
-
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 }) })),
|
|
1067
|
-
React__namespace.createElement("span", { "data-line-num": newLine.lineNumber, style: { opacity: hasChange ? undefined : 0.5 } }, newLine.lineNumber)),
|
|
1068
|
-
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 } },
|
|
1069
|
-
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 }) })),
|
|
1070
|
-
React__namespace.createElement(DiffContent, { enableWrap: true, diffFile: diffFile, rawLine: newLine.value || "", diffLine: newLine.diff, syntaxLine: newSyntaxLine, enableHighlight: enableHighlight })))) : (React__namespace.createElement("td", { className: "diff-line-new-placeholder select-none border-l-[1px] border-l-[rgb(222,222,222)]", style: { backgroundColor: `var(${emptyBGName})` }, "data-side": exports.SplitSide[exports.SplitSide.new], colSpan: 2 },
|
|
1071
|
-
React__namespace.createElement("span", null, "\u2002")))));
|
|
1072
|
-
};
|
|
1073
|
-
const DiffSplitLine = ({ index, diffFile, lineNumber, }) => {
|
|
1074
|
-
const oldLine = diffFile.getSplitLeftLine(index);
|
|
1075
|
-
const newLine = diffFile.getSplitRightLine(index);
|
|
1076
|
-
if ((oldLine === null || oldLine === void 0 ? void 0 : oldLine.isHidden) && (newLine === null || newLine === void 0 ? void 0 : newLine.isHidden))
|
|
1082
|
+
const DiffSplitHunkLine = ({ index, diffFile, lineNumber, }) => {
|
|
1083
|
+
const currentHunk = diffFile.getSplitHunkLine(index);
|
|
1084
|
+
const currentIsShow = currentHunk &&
|
|
1085
|
+
currentHunk.splitInfo &&
|
|
1086
|
+
currentHunk.splitInfo.startHiddenIndex < currentHunk.splitInfo.endHiddenIndex;
|
|
1087
|
+
const currentIsPureHunk = currentHunk && diffFile._getIsPureDiffRender() && !currentHunk.splitInfo;
|
|
1088
|
+
if (!currentIsShow && !currentIsPureHunk)
|
|
1077
1089
|
return null;
|
|
1078
|
-
return React__namespace.createElement(
|
|
1090
|
+
return React__namespace.createElement(_DiffSplitHunkLine, { index: index, diffFile: diffFile, lineNumber: lineNumber });
|
|
1079
1091
|
};
|
|
1080
1092
|
|
|
1081
1093
|
const _DiffSplitWidgetLine = ({ index, diffFile, lineNumber, oldLineWidget, newLineWidget, }) => {
|
|
1082
1094
|
const { useWidget } = useDiffWidgetContext();
|
|
1083
1095
|
const setWidget = useWidget.getReadonlyState().setWidget;
|
|
1084
1096
|
const { useDiffContext } = useDiffViewContext();
|
|
1085
|
-
const renderWidgetLine = useDiffContext
|
|
1097
|
+
const renderWidgetLine = useDiffContext.useShallowStableSelector((s) => s.renderWidgetLine);
|
|
1086
1098
|
const oldLine = diffFile.getSplitLeftLine(index);
|
|
1087
1099
|
const newLine = diffFile.getSplitRightLine(index);
|
|
1088
1100
|
if (!renderWidgetLine)
|
|
@@ -1096,18 +1108,21 @@ const _DiffSplitWidgetLine = ({ index, diffFile, lineNumber, oldLineWidget, newL
|
|
|
1096
1108
|
onClose: () => setWidget({}),
|
|
1097
1109
|
})))) : (React__namespace.createElement("td", { className: "diff-line-widget-old-placeholder select-none p-0", style: { backgroundColor: `var(${emptyBGName})` }, colSpan: 2 },
|
|
1098
1110
|
React__namespace.createElement("span", null, "\u2002"))),
|
|
1099
|
-
newLineWidget ? (React__namespace.createElement("td", { className: "diff-line-widget-new-content border-l-[1px]
|
|
1111
|
+
newLineWidget ? (React__namespace.createElement("td", { className: "diff-line-widget-new-content border-l-[1px] p-0", colSpan: 2, style: { borderLeftColor: `var(${borderColorName})` } },
|
|
1100
1112
|
React__namespace.createElement("div", { className: "diff-line-widget-wrapper" }, renderWidgetLine === null || renderWidgetLine === void 0 ? void 0 : renderWidgetLine({
|
|
1101
1113
|
diffFile,
|
|
1102
1114
|
side: exports.SplitSide.new,
|
|
1103
1115
|
lineNumber: newLine.lineNumber,
|
|
1104
1116
|
onClose: () => setWidget({}),
|
|
1105
|
-
})))) : (React__namespace.createElement("td", { className: "diff-line-widget-new-placeholder select-none border-l-[1px]
|
|
1117
|
+
})))) : (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 },
|
|
1106
1118
|
React__namespace.createElement("span", null, "\u2002")))));
|
|
1107
1119
|
};
|
|
1108
1120
|
const DiffSplitWidgetLine = ({ index, diffFile, lineNumber, }) => {
|
|
1109
1121
|
const { useWidget } = useDiffWidgetContext();
|
|
1110
|
-
const { widgetLineNumber, widgetSide } = useWidget(
|
|
1122
|
+
const { widgetLineNumber, widgetSide } = useWidget((s) => ({
|
|
1123
|
+
widgetLineNumber: s.widgetLineNumber,
|
|
1124
|
+
widgetSide: s.widgetSide,
|
|
1125
|
+
}));
|
|
1111
1126
|
const oldLine = diffFile.getSplitLeftLine(index);
|
|
1112
1127
|
const newLine = diffFile.getSplitRightLine(index);
|
|
1113
1128
|
const oldLineWidget = oldLine.lineNumber && widgetSide === exports.SplitSide.old && widgetLineNumber === oldLine.lineNumber;
|
|
@@ -1131,7 +1146,7 @@ const DiffSplitViewWrap = React.memo(({ diffFile }) => {
|
|
|
1131
1146
|
const splitLineLength = Math.max(diffFile.splitLineLength, diffFile.fileLineLength);
|
|
1132
1147
|
const { useDiffContext } = useDiffViewContext();
|
|
1133
1148
|
const useSplitConfig = React.useMemo(() => createDiffSplitConfigStore(), []);
|
|
1134
|
-
const fontSize = useDiffContext
|
|
1149
|
+
const fontSize = useDiffContext.useShallowStableSelector((s) => s.fontSize);
|
|
1135
1150
|
index_js.useSyncExternalStore(diffFile.subscribe, diffFile.getUpdateCount);
|
|
1136
1151
|
const onMouseDown = React.useCallback((e) => {
|
|
1137
1152
|
let ele = e.target;
|
|
@@ -1160,7 +1175,7 @@ const DiffSplitViewWrap = React.memo(({ diffFile }) => {
|
|
|
1160
1175
|
});
|
|
1161
1176
|
const width = Math.max(40, _width + 25);
|
|
1162
1177
|
const lines = core.getSplitContentLines(diffFile);
|
|
1163
|
-
return (React__namespace.createElement("div", { className: "split-diff-view split-diff-view-
|
|
1178
|
+
return (React__namespace.createElement("div", { className: "split-diff-view split-diff-view-wrap w-full" },
|
|
1164
1179
|
React__namespace.createElement("div", { className: "diff-table-wrapper w-full", style: {
|
|
1165
1180
|
// @ts-ignore
|
|
1166
1181
|
[diffAsideWidthName]: `${Math.round(width)}px`,
|
|
@@ -1168,7 +1183,7 @@ const DiffSplitViewWrap = React.memo(({ diffFile }) => {
|
|
|
1168
1183
|
fontSize: `var(${diffFontSizeName})`,
|
|
1169
1184
|
} },
|
|
1170
1185
|
React__namespace.createElement(Style, { useSelector: useSplitConfig, id: `diff-root${diffFile.getId()}` }),
|
|
1171
|
-
React__namespace.createElement("table", { className: "diff-table w-full table-fixed border-collapse" },
|
|
1186
|
+
React__namespace.createElement("table", { className: "diff-table w-full table-fixed border-collapse border-spacing-0" },
|
|
1172
1187
|
React__namespace.createElement("colgroup", null,
|
|
1173
1188
|
React__namespace.createElement("col", { className: "diff-table-old-num-col", width: Math.round(width) }),
|
|
1174
1189
|
React__namespace.createElement("col", { className: "diff-table-old-content-col" }),
|
|
@@ -1183,7 +1198,7 @@ const DiffSplitViewWrap = React.memo(({ diffFile }) => {
|
|
|
1183
1198
|
React__namespace.createElement("tbody", { className: "diff-table-body leading-[1.4]", onMouseDownCapture: onMouseDown },
|
|
1184
1199
|
lines.map((line) => (React__namespace.createElement(React.Fragment, { key: line.index },
|
|
1185
1200
|
React__namespace.createElement(DiffSplitHunkLine, { index: line.index, lineNumber: line.lineNumber, diffFile: diffFile }),
|
|
1186
|
-
React__namespace.createElement(
|
|
1201
|
+
React__namespace.createElement(DiffSplitContentLine, { index: line.index, lineNumber: line.lineNumber, diffFile: diffFile }),
|
|
1187
1202
|
React__namespace.createElement(DiffSplitWidgetLine, { index: line.index, lineNumber: line.lineNumber, diffFile: diffFile }),
|
|
1188
1203
|
React__namespace.createElement(DiffSplitExtendLine, { index: line.index, lineNumber: line.lineNumber, diffFile: diffFile })))),
|
|
1189
1204
|
React__namespace.createElement(DiffSplitHunkLine, { index: diffFile.splitLineLength, lineNumber: diffFile.splitLineLength, diffFile: diffFile }))))));
|
|
@@ -1194,7 +1209,7 @@ const DiffSplitView = React.memo(({ diffFile }) => {
|
|
|
1194
1209
|
const { useDiffContext } = useDiffViewContext();
|
|
1195
1210
|
const useDiffContextRef = React.useRef(useDiffContext);
|
|
1196
1211
|
useDiffContextRef.current = useDiffContext;
|
|
1197
|
-
const enableWrap = useDiffContext
|
|
1212
|
+
const enableWrap = useDiffContext.useShallowStableSelector((s) => s.enableWrap);
|
|
1198
1213
|
// performance optimization
|
|
1199
1214
|
const useWidget = React.useMemo(() => createDiffWidgetStore(useDiffContextRef), []);
|
|
1200
1215
|
const contextValue = React.useMemo(() => ({ useWidget }), [useWidget]);
|
|
@@ -1206,9 +1221,101 @@ const DiffSplitView = React.memo(({ diffFile }) => {
|
|
|
1206
1221
|
});
|
|
1207
1222
|
DiffSplitView.displayName = "DiffSplitView";
|
|
1208
1223
|
|
|
1224
|
+
const DiffUnifiedOldLine = ({ index, diffLine, rawLine, syntaxLine, lineNumber, diffFile, setWidget, enableWrap, enableAddWidget, enableHighlight, onAddWidgetClick, }) => {
|
|
1225
|
+
return (React__namespace.createElement("tr", { "data-line": index, "data-state": "diff", className: "diff-line group" },
|
|
1226
|
+
React__namespace.createElement("td", { className: "diff-line-num sticky left-0 w-[1%] min-w-[100px] select-none whitespace-nowrap pl-[10px] pr-[10px] text-right align-top", style: {
|
|
1227
|
+
color: `var(${plainLineNumberColorName})`,
|
|
1228
|
+
backgroundColor: `var(${delLineNumberBGName})`,
|
|
1229
|
+
width: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
|
|
1230
|
+
maxWidth: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
|
|
1231
|
+
minWidth: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
|
|
1232
|
+
} },
|
|
1233
|
+
enableAddWidget && (React__namespace.createElement(DiffUnifiedAddWidget, { index: index - 1, lineNumber: lineNumber, diffFile: diffFile, side: exports.SplitSide.old, onWidgetClick: onAddWidgetClick, onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber, side }) })),
|
|
1234
|
+
React__namespace.createElement("div", { className: "flex" },
|
|
1235
|
+
React__namespace.createElement("span", { "data-line-old-num": lineNumber, className: "inline-block w-[50%]" }, lineNumber),
|
|
1236
|
+
React__namespace.createElement("span", { className: "w-[10px] shrink-0" }),
|
|
1237
|
+
React__namespace.createElement("span", { className: "inline-block w-[50%]" }))),
|
|
1238
|
+
React__namespace.createElement("td", { className: "diff-line-content pr-[10px] align-top", style: { backgroundColor: `var(${delContentBGName})` } },
|
|
1239
|
+
React__namespace.createElement(DiffContent, { enableWrap: enableWrap, diffFile: diffFile, enableHighlight: enableHighlight, rawLine: rawLine, diffLine: diffLine, syntaxLine: syntaxLine }))));
|
|
1240
|
+
};
|
|
1241
|
+
const DiffUnifiedNewLine = ({ index, diffLine, rawLine, syntaxLine, lineNumber, diffFile, setWidget, enableWrap, enableAddWidget, enableHighlight, onAddWidgetClick, }) => {
|
|
1242
|
+
return (React__namespace.createElement("tr", { "data-line": index, "data-state": "diff", className: "diff-line group" },
|
|
1243
|
+
React__namespace.createElement("td", { className: "diff-line-num sticky left-0 w-[1%] min-w-[100px] select-none whitespace-nowrap pl-[10px] pr-[10px] text-right align-top", style: {
|
|
1244
|
+
color: `var(${plainLineNumberColorName})`,
|
|
1245
|
+
backgroundColor: `var(${addLineNumberBGName})`,
|
|
1246
|
+
width: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
|
|
1247
|
+
maxWidth: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
|
|
1248
|
+
minWidth: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
|
|
1249
|
+
} },
|
|
1250
|
+
enableAddWidget && (React__namespace.createElement(DiffUnifiedAddWidget, { index: index - 1, lineNumber: lineNumber, diffFile: diffFile, side: exports.SplitSide.new, onWidgetClick: onAddWidgetClick, onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber, side }) })),
|
|
1251
|
+
React__namespace.createElement("div", { className: "flex" },
|
|
1252
|
+
React__namespace.createElement("span", { className: "inline-block w-[50%]" }),
|
|
1253
|
+
React__namespace.createElement("span", { className: "w-[10px] shrink-0" }),
|
|
1254
|
+
React__namespace.createElement("span", { "data-line-new-num": lineNumber, className: "inline-block w-[50%]" }, lineNumber))),
|
|
1255
|
+
React__namespace.createElement("td", { className: "diff-line-content pr-[10px] align-top", style: { backgroundColor: `var(${addContentBGName})` } },
|
|
1256
|
+
React__namespace.createElement(DiffContent, { enableWrap: enableWrap, diffFile: diffFile, enableHighlight: enableHighlight, rawLine: rawLine, diffLine: diffLine, syntaxLine: syntaxLine }))));
|
|
1257
|
+
};
|
|
1258
|
+
const _DiffUnifiedLine = React.memo(({ index, diffFile, lineNumber }) => {
|
|
1259
|
+
const unifiedLine = diffFile.getUnifiedLine(index);
|
|
1260
|
+
const { useDiffContext } = useDiffViewContext();
|
|
1261
|
+
const { enableWrap, enableHighlight, enableAddWidget, onAddWidgetClick } = useDiffContext.useShallowStableSelector((s) => ({
|
|
1262
|
+
enableWrap: s.enableWrap,
|
|
1263
|
+
enableHighlight: s.enableHighlight,
|
|
1264
|
+
enableAddWidget: s.enableAddWidget,
|
|
1265
|
+
onAddWidgetClick: s.onAddWidgetClick,
|
|
1266
|
+
}));
|
|
1267
|
+
const { useWidget } = useDiffWidgetContext();
|
|
1268
|
+
const setWidget = useWidget.getReadonlyState().setWidget;
|
|
1269
|
+
const hasDiff = unifiedLine.diff;
|
|
1270
|
+
const hasChange = core.checkDiffLineIncludeChange(unifiedLine.diff);
|
|
1271
|
+
const rawLine = unifiedLine.value || "";
|
|
1272
|
+
const diffLine = unifiedLine.diff;
|
|
1273
|
+
const newLineNumber = unifiedLine.newLineNumber;
|
|
1274
|
+
const oldLinenumber = unifiedLine.oldLineNumber;
|
|
1275
|
+
const syntaxLine = newLineNumber
|
|
1276
|
+
? diffFile.getNewSyntaxLine(newLineNumber)
|
|
1277
|
+
: oldLinenumber
|
|
1278
|
+
? diffFile.getOldSyntaxLine(oldLinenumber)
|
|
1279
|
+
: undefined;
|
|
1280
|
+
if (hasChange) {
|
|
1281
|
+
if (unifiedLine.oldLineNumber) {
|
|
1282
|
+
return (React__namespace.createElement(DiffUnifiedOldLine, { index: lineNumber, enableWrap: enableWrap, diffFile: diffFile, rawLine: rawLine, diffLine: diffLine, setWidget: setWidget, syntaxLine: syntaxLine, enableHighlight: enableHighlight, enableAddWidget: enableAddWidget, lineNumber: unifiedLine.oldLineNumber, onAddWidgetClick: (...props) => { var _a; return (_a = onAddWidgetClick.current) === null || _a === void 0 ? void 0 : _a.call(onAddWidgetClick, ...props); } }));
|
|
1283
|
+
}
|
|
1284
|
+
else {
|
|
1285
|
+
return (React__namespace.createElement(DiffUnifiedNewLine, { index: lineNumber, enableWrap: enableWrap, rawLine: rawLine, diffLine: diffLine, diffFile: diffFile, setWidget: setWidget, syntaxLine: syntaxLine, enableHighlight: enableHighlight, enableAddWidget: enableAddWidget, lineNumber: unifiedLine.newLineNumber, onAddWidgetClick: (...props) => { var _a; return (_a = onAddWidgetClick.current) === null || _a === void 0 ? void 0 : _a.call(onAddWidgetClick, ...props); } }));
|
|
1286
|
+
}
|
|
1287
|
+
}
|
|
1288
|
+
else {
|
|
1289
|
+
return (React__namespace.createElement("tr", { "data-line": lineNumber, "data-state": unifiedLine.diff ? "diff" : "plain", className: "diff-line group" },
|
|
1290
|
+
React__namespace.createElement("td", { className: "diff-line-num sticky left-0 w-[1%] min-w-[100px] select-none whitespace-nowrap pl-[10px] pr-[10px] text-right align-top", style: {
|
|
1291
|
+
color: `var(${plainLineNumberColorName})`,
|
|
1292
|
+
width: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
|
|
1293
|
+
maxWidth: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
|
|
1294
|
+
minWidth: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
|
|
1295
|
+
backgroundColor: hasDiff ? `var(${plainLineNumberBGName})` : `var(${expandContentBGName})`,
|
|
1296
|
+
} },
|
|
1297
|
+
enableAddWidget && hasDiff && (React__namespace.createElement(DiffUnifiedAddWidget, { index: index, diffFile: diffFile, lineNumber: unifiedLine.newLineNumber, side: exports.SplitSide.new, onWidgetClick: (...props) => { var _a; return (_a = onAddWidgetClick.current) === null || _a === void 0 ? void 0 : _a.call(onAddWidgetClick, ...props); }, onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber, side }) })),
|
|
1298
|
+
React__namespace.createElement("div", { className: "flex opacity-[0.5]" },
|
|
1299
|
+
React__namespace.createElement("span", { "data-line-old-num": unifiedLine.oldLineNumber, className: "inline-block w-[50%]" }, unifiedLine.oldLineNumber),
|
|
1300
|
+
React__namespace.createElement("span", { className: "w-[10px] shrink-0" }),
|
|
1301
|
+
React__namespace.createElement("span", { "data-line-new-num": unifiedLine.newLineNumber, className: "inline-block w-[50%]" }, unifiedLine.newLineNumber))),
|
|
1302
|
+
React__namespace.createElement("td", { className: "diff-line-content pr-[10px] align-top", style: {
|
|
1303
|
+
backgroundColor: hasDiff ? `var(${plainContentBGName})` : `var(${expandContentBGName})`,
|
|
1304
|
+
} },
|
|
1305
|
+
React__namespace.createElement(DiffContent, { enableWrap: enableWrap, diffFile: diffFile, enableHighlight: enableHighlight, rawLine: rawLine, diffLine: diffLine, syntaxLine: syntaxLine }))));
|
|
1306
|
+
}
|
|
1307
|
+
});
|
|
1308
|
+
_DiffUnifiedLine.displayName = "_DiffUnifiedLine";
|
|
1309
|
+
const DiffUnifiedContentLine = ({ index, diffFile, lineNumber, }) => {
|
|
1310
|
+
const unifiedLine = diffFile.getUnifiedLine(index);
|
|
1311
|
+
if (unifiedLine === null || unifiedLine === void 0 ? void 0 : unifiedLine.isHidden)
|
|
1312
|
+
return null;
|
|
1313
|
+
return React__namespace.createElement(_DiffUnifiedLine, { index: index, diffFile: diffFile, lineNumber: lineNumber });
|
|
1314
|
+
};
|
|
1315
|
+
|
|
1209
1316
|
const _DiffUnifiedExtendLine = ({ index, diffFile, lineNumber, oldLineExtend, newLineExtend, }) => {
|
|
1210
1317
|
const { useDiffContext } = useDiffViewContext();
|
|
1211
|
-
const renderExtendLine = useDiffContext
|
|
1318
|
+
const renderExtendLine = useDiffContext.useShallowStableSelector((s) => s.renderExtendLine);
|
|
1212
1319
|
const unifiedItem = diffFile.getUnifiedLine(index);
|
|
1213
1320
|
const width = useDomWidth({
|
|
1214
1321
|
selector: ".unified-diff-table-wrapper",
|
|
@@ -1259,7 +1366,7 @@ const _DiffUnifiedHunkLine = ({ index, diffFile, lineNumber, }) => {
|
|
|
1259
1366
|
const currentHunk = diffFile.getUnifiedHunkLine(index);
|
|
1260
1367
|
const expandEnabled = diffFile.getExpandEnabled();
|
|
1261
1368
|
const { useDiffContext } = useDiffViewContext();
|
|
1262
|
-
const enableWrap = useDiffContext
|
|
1369
|
+
const enableWrap = useDiffContext.useShallowStableSelector((s) => s.enableWrap);
|
|
1263
1370
|
const couldExpand = expandEnabled && currentHunk && currentHunk.unifiedInfo;
|
|
1264
1371
|
const isExpandAll = currentHunk &&
|
|
1265
1372
|
currentHunk.unifiedInfo &&
|
|
@@ -1299,104 +1406,12 @@ const DiffUnifiedHunkLine = ({ index, diffFile, lineNumber, }) => {
|
|
|
1299
1406
|
return React__namespace.createElement(_DiffUnifiedHunkLine, { index: index, diffFile: diffFile, lineNumber: lineNumber });
|
|
1300
1407
|
};
|
|
1301
1408
|
|
|
1302
|
-
const DiffUnifiedOldLine = ({ index, diffLine, rawLine, syntaxLine, lineNumber, diffFile, setWidget, enableWrap, enableAddWidget, enableHighlight, onAddWidgetClick, }) => {
|
|
1303
|
-
return (React__namespace.createElement("tr", { "data-line": index, "data-state": "diff", className: "diff-line group" },
|
|
1304
|
-
React__namespace.createElement("td", { className: "diff-line-num sticky left-0 w-[1%] min-w-[100px] select-none whitespace-nowrap pl-[10px] pr-[10px] text-right align-top", style: {
|
|
1305
|
-
color: `var(${plainLineNumberColorName})`,
|
|
1306
|
-
backgroundColor: `var(${delLineNumberBGName})`,
|
|
1307
|
-
width: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
|
|
1308
|
-
maxWidth: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
|
|
1309
|
-
minWidth: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
|
|
1310
|
-
} },
|
|
1311
|
-
enableAddWidget && (React__namespace.createElement(DiffUnifiedAddWidget, { index: index - 1, lineNumber: lineNumber, diffFile: diffFile, side: exports.SplitSide.old, onWidgetClick: onAddWidgetClick, onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber, side }) })),
|
|
1312
|
-
React__namespace.createElement("div", { className: "flex" },
|
|
1313
|
-
React__namespace.createElement("span", { "data-line-old-num": lineNumber, className: "inline-block w-[50%]" }, lineNumber),
|
|
1314
|
-
React__namespace.createElement("span", { className: "w-[10px] shrink-0" }),
|
|
1315
|
-
React__namespace.createElement("span", { className: "inline-block w-[50%]" }))),
|
|
1316
|
-
React__namespace.createElement("td", { className: "diff-line-content pr-[10px] align-top", style: { backgroundColor: `var(${delContentBGName})` } },
|
|
1317
|
-
React__namespace.createElement(DiffContent, { enableWrap: enableWrap, diffFile: diffFile, enableHighlight: enableHighlight, rawLine: rawLine, diffLine: diffLine, syntaxLine: syntaxLine }))));
|
|
1318
|
-
};
|
|
1319
|
-
const DiffUnifiedNewLine = ({ index, diffLine, rawLine, syntaxLine, lineNumber, diffFile, setWidget, enableWrap, enableAddWidget, enableHighlight, onAddWidgetClick, }) => {
|
|
1320
|
-
return (React__namespace.createElement("tr", { "data-line": index, "data-state": "diff", className: "diff-line group" },
|
|
1321
|
-
React__namespace.createElement("td", { className: "diff-line-num sticky left-0 w-[1%] min-w-[100px] select-none whitespace-nowrap pl-[10px] pr-[10px] text-right align-top", style: {
|
|
1322
|
-
color: `var(${plainLineNumberColorName})`,
|
|
1323
|
-
backgroundColor: `var(${addLineNumberBGName})`,
|
|
1324
|
-
width: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
|
|
1325
|
-
maxWidth: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
|
|
1326
|
-
minWidth: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
|
|
1327
|
-
} },
|
|
1328
|
-
enableAddWidget && (React__namespace.createElement(DiffUnifiedAddWidget, { index: index - 1, lineNumber: lineNumber, diffFile: diffFile, side: exports.SplitSide.new, onWidgetClick: onAddWidgetClick, onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber, side }) })),
|
|
1329
|
-
React__namespace.createElement("div", { className: "flex" },
|
|
1330
|
-
React__namespace.createElement("span", { className: "inline-block w-[50%]" }),
|
|
1331
|
-
React__namespace.createElement("span", { className: "w-[10px] shrink-0" }),
|
|
1332
|
-
React__namespace.createElement("span", { "data-line-new-num": lineNumber, className: "inline-block w-[50%]" }, lineNumber))),
|
|
1333
|
-
React__namespace.createElement("td", { className: "diff-line-content pr-[10px] align-top", style: { backgroundColor: `var(${addContentBGName})` } },
|
|
1334
|
-
React__namespace.createElement(DiffContent, { enableWrap: enableWrap, diffFile: diffFile, enableHighlight: enableHighlight, rawLine: rawLine, diffLine: diffLine, syntaxLine: syntaxLine }))));
|
|
1335
|
-
};
|
|
1336
|
-
const _DiffUnifiedLine = React.memo(({ index, diffFile, lineNumber }) => {
|
|
1337
|
-
const unifiedLine = diffFile.getUnifiedLine(index);
|
|
1338
|
-
const { useDiffContext } = useDiffViewContext();
|
|
1339
|
-
const { enableWrap, enableHighlight, enableAddWidget, onAddWidgetClick } = useDiffContext(React__namespace.useCallback((s) => ({
|
|
1340
|
-
enableWrap: s.enableWrap,
|
|
1341
|
-
enableHighlight: s.enableHighlight,
|
|
1342
|
-
enableAddWidget: s.enableAddWidget,
|
|
1343
|
-
onAddWidgetClick: s.onAddWidgetClick,
|
|
1344
|
-
}), []));
|
|
1345
|
-
const { useWidget } = useDiffWidgetContext();
|
|
1346
|
-
const setWidget = useWidget.getReadonlyState().setWidget;
|
|
1347
|
-
const hasDiff = unifiedLine.diff;
|
|
1348
|
-
const hasChange = core.checkDiffLineIncludeChange(unifiedLine.diff);
|
|
1349
|
-
const rawLine = unifiedLine.value || "";
|
|
1350
|
-
const diffLine = unifiedLine.diff;
|
|
1351
|
-
const newLineNumber = unifiedLine.newLineNumber;
|
|
1352
|
-
const oldLinenumber = unifiedLine.oldLineNumber;
|
|
1353
|
-
const syntaxLine = newLineNumber
|
|
1354
|
-
? diffFile.getNewSyntaxLine(newLineNumber)
|
|
1355
|
-
: oldLinenumber
|
|
1356
|
-
? diffFile.getOldSyntaxLine(oldLinenumber)
|
|
1357
|
-
: undefined;
|
|
1358
|
-
if (hasChange) {
|
|
1359
|
-
if (unifiedLine.oldLineNumber) {
|
|
1360
|
-
return (React__namespace.createElement(DiffUnifiedOldLine, { index: lineNumber, enableWrap: enableWrap, diffFile: diffFile, rawLine: rawLine, diffLine: diffLine, setWidget: setWidget, syntaxLine: syntaxLine, enableHighlight: enableHighlight, enableAddWidget: enableAddWidget, lineNumber: unifiedLine.oldLineNumber, onAddWidgetClick: (...props) => { var _a; return (_a = onAddWidgetClick.current) === null || _a === void 0 ? void 0 : _a.call(onAddWidgetClick, ...props); } }));
|
|
1361
|
-
}
|
|
1362
|
-
else {
|
|
1363
|
-
return (React__namespace.createElement(DiffUnifiedNewLine, { index: lineNumber, enableWrap: enableWrap, rawLine: rawLine, diffLine: diffLine, diffFile: diffFile, setWidget: setWidget, syntaxLine: syntaxLine, enableHighlight: enableHighlight, enableAddWidget: enableAddWidget, lineNumber: unifiedLine.newLineNumber, onAddWidgetClick: (...props) => { var _a; return (_a = onAddWidgetClick.current) === null || _a === void 0 ? void 0 : _a.call(onAddWidgetClick, ...props); } }));
|
|
1364
|
-
}
|
|
1365
|
-
}
|
|
1366
|
-
else {
|
|
1367
|
-
return (React__namespace.createElement("tr", { "data-line": lineNumber, "data-state": unifiedLine.diff ? "diff" : "plain", className: "diff-line group" },
|
|
1368
|
-
React__namespace.createElement("td", { className: "diff-line-num sticky left-0 w-[1%] min-w-[100px] select-none whitespace-nowrap pl-[10px] pr-[10px] text-right align-top", style: {
|
|
1369
|
-
color: `var(${plainLineNumberColorName})`,
|
|
1370
|
-
width: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
|
|
1371
|
-
maxWidth: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
|
|
1372
|
-
minWidth: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
|
|
1373
|
-
backgroundColor: hasDiff ? `var(${plainLineNumberBGName})` : `var(${expandContentBGName})`,
|
|
1374
|
-
} },
|
|
1375
|
-
enableAddWidget && hasDiff && (React__namespace.createElement(DiffUnifiedAddWidget, { index: index, diffFile: diffFile, lineNumber: unifiedLine.newLineNumber, side: exports.SplitSide.new, onWidgetClick: (...props) => { var _a; return (_a = onAddWidgetClick.current) === null || _a === void 0 ? void 0 : _a.call(onAddWidgetClick, ...props); }, onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber, side }) })),
|
|
1376
|
-
React__namespace.createElement("div", { className: "flex opacity-[0.5]" },
|
|
1377
|
-
React__namespace.createElement("span", { "data-line-old-num": unifiedLine.oldLineNumber, className: "inline-block w-[50%]" }, unifiedLine.oldLineNumber),
|
|
1378
|
-
React__namespace.createElement("span", { className: "w-[10px] shrink-0" }),
|
|
1379
|
-
React__namespace.createElement("span", { "data-line-new-num": unifiedLine.newLineNumber, className: "inline-block w-[50%]" }, unifiedLine.newLineNumber))),
|
|
1380
|
-
React__namespace.createElement("td", { className: "diff-line-content pr-[10px] align-top", style: {
|
|
1381
|
-
backgroundColor: hasDiff ? `var(${plainContentBGName})` : `var(${expandContentBGName})`,
|
|
1382
|
-
} },
|
|
1383
|
-
React__namespace.createElement(DiffContent, { enableWrap: enableWrap, diffFile: diffFile, enableHighlight: enableHighlight, rawLine: rawLine, diffLine: diffLine, syntaxLine: syntaxLine }))));
|
|
1384
|
-
}
|
|
1385
|
-
});
|
|
1386
|
-
_DiffUnifiedLine.displayName = "_DiffUnifiedLine";
|
|
1387
|
-
const DiffUnifiedLine = ({ index, diffFile, lineNumber, }) => {
|
|
1388
|
-
const unifiedLine = diffFile.getUnifiedLine(index);
|
|
1389
|
-
if (unifiedLine === null || unifiedLine === void 0 ? void 0 : unifiedLine.isHidden)
|
|
1390
|
-
return null;
|
|
1391
|
-
return React__namespace.createElement(_DiffUnifiedLine, { index: index, diffFile: diffFile, lineNumber: lineNumber });
|
|
1392
|
-
};
|
|
1393
|
-
|
|
1394
1409
|
const _DiffUnifiedWidgetLine = ({ index, diffFile, oldWidget, newWidget, lineNumber, setWidget, }) => {
|
|
1395
1410
|
const unifiedItem = diffFile.getUnifiedLine(index);
|
|
1396
1411
|
const onClose = () => setWidget({});
|
|
1397
1412
|
const { useDiffContext } = useDiffViewContext();
|
|
1398
1413
|
// 需要显示的时候才进行方法订阅,可以大幅度提高性能
|
|
1399
|
-
const renderWidgetLine = useDiffContext
|
|
1414
|
+
const renderWidgetLine = useDiffContext.useShallowStableSelector((s) => s.renderWidgetLine);
|
|
1400
1415
|
const width = useDomWidth({
|
|
1401
1416
|
selector: ".unified-diff-table-wrapper",
|
|
1402
1417
|
enable: typeof renderWidgetLine === "function",
|
|
@@ -1415,7 +1430,11 @@ const _DiffUnifiedWidgetLine = ({ index, diffFile, oldWidget, newWidget, lineNum
|
|
|
1415
1430
|
};
|
|
1416
1431
|
const DiffUnifiedWidgetLine = ({ index, diffFile, lineNumber, }) => {
|
|
1417
1432
|
const { useWidget } = useDiffWidgetContext();
|
|
1418
|
-
const { widgetSide, widgetLineNumber, setWidget } = useWidget
|
|
1433
|
+
const { widgetSide, widgetLineNumber, setWidget } = useWidget.useShallowStableSelector((s) => ({
|
|
1434
|
+
widgetLineNumber: s.widgetLineNumber,
|
|
1435
|
+
widgetSide: s.widgetSide,
|
|
1436
|
+
setWidget: s.setWidget,
|
|
1437
|
+
}));
|
|
1419
1438
|
const unifiedItem = diffFile.getUnifiedLine(index);
|
|
1420
1439
|
const oldWidget = unifiedItem.oldLineNumber && widgetSide === exports.SplitSide.old && widgetLineNumber === unifiedItem.oldLineNumber;
|
|
1421
1440
|
const newWidget = unifiedItem.newLineNumber && widgetSide === exports.SplitSide.new && widgetLineNumber === unifiedItem.newLineNumber;
|
|
@@ -1441,7 +1460,10 @@ const DiffUnifiedView = React.memo(({ diffFile }) => {
|
|
|
1441
1460
|
// performance optimization
|
|
1442
1461
|
const useWidget = React.useMemo(() => createDiffWidgetStore(useDiffContextRef), []);
|
|
1443
1462
|
const contextValue = React.useMemo(() => ({ useWidget }), [useWidget]);
|
|
1444
|
-
const fontSize = useDiffContext
|
|
1463
|
+
const { fontSize, enableWrap } = useDiffContext.useShallowStableSelector((s) => ({
|
|
1464
|
+
fontSize: s.fontSize,
|
|
1465
|
+
enableWrap: s.enableWrap,
|
|
1466
|
+
}));
|
|
1445
1467
|
index_js.useSyncExternalStore(diffFile.subscribe, diffFile.getUpdateCount);
|
|
1446
1468
|
React.useEffect(() => {
|
|
1447
1469
|
const { setWidget } = useWidget.getReadonlyState();
|
|
@@ -1455,14 +1477,14 @@ const DiffUnifiedView = React.memo(({ diffFile }) => {
|
|
|
1455
1477
|
const width = Math.max(40, _width + 10);
|
|
1456
1478
|
const lines = core.getUnifiedContentLine(diffFile);
|
|
1457
1479
|
return (React__namespace.createElement(DiffWidgetContext.Provider, { value: contextValue },
|
|
1458
|
-
React__namespace.createElement("div", { className: "unified-diff-view w-full
|
|
1459
|
-
React__namespace.createElement("div", { className: "unified-diff-table-wrapper
|
|
1480
|
+
React__namespace.createElement("div", { className: `unified-diff-view ${enableWrap ? "unified-diff-view-wrap" : "unified-diff-view-normal"} w-full` },
|
|
1481
|
+
React__namespace.createElement("div", { className: "unified-diff-table-wrapper diff-table-scroll-container w-full overflow-x-auto overflow-y-hidden", style: {
|
|
1460
1482
|
// @ts-ignore
|
|
1461
1483
|
[diffAsideWidthName]: `${Math.round(width)}px`,
|
|
1462
1484
|
fontFamily: "Menlo, Consolas, monospace",
|
|
1463
1485
|
fontSize: `var(${diffFontSizeName})`,
|
|
1464
1486
|
} },
|
|
1465
|
-
React__namespace.createElement("table", { className:
|
|
1487
|
+
React__namespace.createElement("table", { className: `unified-diff-table w-full border-collapse border-spacing-0 ${enableWrap ? "table-fixed" : ""}` },
|
|
1466
1488
|
React__namespace.createElement("colgroup", null,
|
|
1467
1489
|
React__namespace.createElement("col", { className: "unified-diff-table-num-col" }),
|
|
1468
1490
|
React__namespace.createElement("col", { className: "unified-diff-table-content-col" })),
|
|
@@ -1473,7 +1495,7 @@ const DiffUnifiedView = React.memo(({ diffFile }) => {
|
|
|
1473
1495
|
React__namespace.createElement("tbody", { className: "diff-table-body leading-[1.4]", onMouseDownCapture: onMouseDown },
|
|
1474
1496
|
lines.map((item) => (React__namespace.createElement(React.Fragment, { key: item.index },
|
|
1475
1497
|
React__namespace.createElement(DiffUnifiedHunkLine, { index: item.index, lineNumber: item.lineNumber, diffFile: diffFile }),
|
|
1476
|
-
React__namespace.createElement(
|
|
1498
|
+
React__namespace.createElement(DiffUnifiedContentLine, { index: item.index, lineNumber: item.lineNumber, diffFile: diffFile }),
|
|
1477
1499
|
React__namespace.createElement(DiffUnifiedWidgetLine, { index: item.index, lineNumber: item.lineNumber, diffFile: diffFile }),
|
|
1478
1500
|
React__namespace.createElement(DiffUnifiedExtendLine, { index: item.index, lineNumber: item.lineNumber, diffFile: diffFile })))),
|
|
1479
1501
|
React__namespace.createElement(DiffUnifiedHunkLine, { index: diffFile.unifiedLineLength, lineNumber: diffFile.unifiedLineLength, diffFile: diffFile })))))));
|
|
@@ -1489,6 +1511,7 @@ exports.SplitSide = void 0;
|
|
|
1489
1511
|
const _InternalDiffView = (props) => {
|
|
1490
1512
|
const { diffFile, className, style, diffViewMode, diffViewWrap, diffViewFontSize, diffViewHighlight, renderWidgetLine, renderExtendLine, extendData, diffViewAddWidget, onAddWidgetClick, } = props;
|
|
1491
1513
|
const diffFileId = React.useMemo(() => diffFile.getId(), [diffFile]);
|
|
1514
|
+
const wrapperRef = React.useRef();
|
|
1492
1515
|
// performance optimization
|
|
1493
1516
|
const useDiffContext = React.useMemo(() => createDiffConfigStore(props, diffFileId),
|
|
1494
1517
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -1518,9 +1541,16 @@ const _InternalDiffView = (props) => {
|
|
|
1518
1541
|
extendData,
|
|
1519
1542
|
onAddWidgetClick,
|
|
1520
1543
|
]);
|
|
1544
|
+
React.useEffect(() => {
|
|
1545
|
+
const cb = diffFile.subscribe(() => {
|
|
1546
|
+
var _a;
|
|
1547
|
+
(_a = wrapperRef.current) === null || _a === void 0 ? void 0 : _a.setAttribute("data-theme", diffFile._getTheme() || "light");
|
|
1548
|
+
});
|
|
1549
|
+
return cb;
|
|
1550
|
+
}, [diffFile]);
|
|
1521
1551
|
const value = React.useMemo(() => ({ useDiffContext }), [useDiffContext]);
|
|
1522
1552
|
return (React__namespace.createElement(DiffViewContext.Provider, { value: value },
|
|
1523
|
-
React__namespace.createElement("div", { className: "diff-tailwindcss-wrapper", "data-component": "git-diff-view", "data-version":
|
|
1553
|
+
React__namespace.createElement("div", { className: "diff-tailwindcss-wrapper", "data-component": "git-diff-view", "data-theme": diffFile._getTheme() || "light", "data-version": "0.0.17", "data-highlighter": diffFile._getHighlighterName(), ref: wrapperRef },
|
|
1524
1554
|
React__namespace.createElement("div", { className: "diff-style-root", style: {
|
|
1525
1555
|
// @ts-ignore
|
|
1526
1556
|
[diffFontSizeName]: diffViewFontSize + "px",
|
|
@@ -1530,7 +1560,7 @@ const _InternalDiffView = (props) => {
|
|
|
1530
1560
|
const InternalDiffView = React.memo(_InternalDiffView);
|
|
1531
1561
|
const DiffViewWithRef = (props, ref) => {
|
|
1532
1562
|
var _a, _b;
|
|
1533
|
-
const { registerHighlighter, data, diffFile: _diffFile } = props, restProps = __rest(props, ["registerHighlighter", "data", "diffFile"]);
|
|
1563
|
+
const { registerHighlighter, data, diffViewTheme, diffFile: _diffFile } = props, restProps = __rest(props, ["registerHighlighter", "data", "diffViewTheme", "diffFile"]);
|
|
1534
1564
|
const diffFile = React.useMemo(() => {
|
|
1535
1565
|
var _a, _b, _c, _d, _e, _f;
|
|
1536
1566
|
if (_diffFile) {
|
|
@@ -1545,16 +1575,17 @@ const DiffViewWithRef = (props, ref) => {
|
|
|
1545
1575
|
}, [data, _diffFile]);
|
|
1546
1576
|
const diffFileRef = React.useRef(diffFile);
|
|
1547
1577
|
if (diffFileRef.current && diffFileRef.current !== diffFile) {
|
|
1548
|
-
(_b = (_a = diffFileRef.current).
|
|
1578
|
+
(_b = (_a = diffFileRef.current).clear) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
1549
1579
|
diffFileRef.current = diffFile;
|
|
1550
1580
|
}
|
|
1551
1581
|
React.useEffect(() => {
|
|
1552
1582
|
if (!diffFile)
|
|
1553
1583
|
return;
|
|
1584
|
+
diffFile.initTheme(diffViewTheme);
|
|
1554
1585
|
diffFile.initRaw();
|
|
1555
1586
|
diffFile.buildSplitDiffLines();
|
|
1556
1587
|
diffFile.buildUnifiedDiffLines();
|
|
1557
|
-
}, [diffFile]);
|
|
1588
|
+
}, [diffFile, diffViewTheme]);
|
|
1558
1589
|
React.useEffect(() => {
|
|
1559
1590
|
if (!diffFile)
|
|
1560
1591
|
return;
|
|
@@ -1562,7 +1593,7 @@ const DiffViewWithRef = (props, ref) => {
|
|
|
1562
1593
|
diffFile.initSyntax({ registerHighlighter });
|
|
1563
1594
|
diffFile.notifyAll();
|
|
1564
1595
|
}
|
|
1565
|
-
}, [diffFile, props.diffViewHighlight, registerHighlighter]);
|
|
1596
|
+
}, [diffFile, props.diffViewHighlight, registerHighlighter, diffViewTheme]);
|
|
1566
1597
|
React.useEffect(() => {
|
|
1567
1598
|
if (_diffFile && diffFile) {
|
|
1568
1599
|
_diffFile._addClonedInstance(diffFile);
|
|
@@ -1571,7 +1602,7 @@ const DiffViewWithRef = (props, ref) => {
|
|
|
1571
1602
|
};
|
|
1572
1603
|
}
|
|
1573
1604
|
}, [diffFile, _diffFile]);
|
|
1574
|
-
useUnmount(() => { var _a; return (_a = diffFile === null || diffFile === void 0 ? void 0 : diffFile.
|
|
1605
|
+
useUnmount(() => { var _a; return (_a = diffFile === null || diffFile === void 0 ? void 0 : diffFile.clear) === null || _a === void 0 ? void 0 : _a.call(diffFile); }, [diffFile]);
|
|
1575
1606
|
React.useImperativeHandle(ref, () => ({ getDiffFileInstance: () => diffFile }), [diffFile]);
|
|
1576
1607
|
if (!diffFile)
|
|
1577
1608
|
return null;
|
|
@@ -1579,7 +1610,7 @@ const DiffViewWithRef = (props, ref) => {
|
|
|
1579
1610
|
};
|
|
1580
1611
|
const DiffView = React.forwardRef(DiffViewWithRef);
|
|
1581
1612
|
DiffView.displayName = "DiffView";
|
|
1582
|
-
const version = "0.0.
|
|
1613
|
+
const version = "0.0.17";
|
|
1583
1614
|
|
|
1584
1615
|
exports.DiffView = DiffView;
|
|
1585
1616
|
exports.DiffViewContext = DiffViewContext;
|