@git-diff-view/react 0.0.16 → 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.
@@ -124,106 +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
- // TODO
184
- const useSyncHeight = ({ selector, side, enable }) => {
185
- const { useDiffContext } = useDiffViewContext();
186
- const id = useDiffContext(React.useCallback((s) => s.id, []));
187
- useSafeLayout(() => {
188
- if (enable) {
189
- const container = document.querySelector(`#diff-root${id}`);
190
- const elements = Array.from((container === null || container === void 0 ? void 0 : container.querySelectorAll(selector)) || []);
191
- if (elements.length === 2) {
192
- const ele1 = elements[0];
193
- const ele2 = elements[1];
194
- const target = 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
- ele1.style.height = maxHeight + "px";
203
- ele2.style.height = maxHeight + "px";
204
- ele1.setAttribute("data-sync-height", String(maxHeight));
205
- ele2.setAttribute("data-sync-height", String(maxHeight));
206
- }
207
- else {
208
- ele1.removeAttribute("data-sync-height");
209
- ele2.removeAttribute("data-sync-height");
210
- }
211
- };
212
- cb();
213
- const observer = new ResizeObserver(cb);
214
- observer.observe(target);
215
- target.setAttribute("data-observe", "height");
216
- return () => {
217
- observer.disconnect();
218
- target === null || target === void 0 ? void 0 : target.removeAttribute("data-observe");
219
- };
220
- }
221
- }
222
- }, [selector, enable, side, id]);
223
- };
224
-
225
127
  const addContentBGName = "--diff-add-content--";
226
128
  const delContentBGName = "--diff-del-content--";
129
+ const borderColorName = "--diff-border--";
227
130
  const addLineNumberBGName = "--diff-add-lineNumber--";
228
131
  const delLineNumberBGName = "--diff-del-lineNumber--";
229
132
  const plainContentBGName = "--diff-plain-content--";
@@ -257,70 +160,6 @@ const getLineNumberBG = (isAdded, isDelete, hasDiff) => {
257
160
  : `var(${expandContentBGName})`;
258
161
  };
259
162
 
260
- const _DiffSplitExtendLine$1 = ({ index, diffFile, oldLineExtend, newLineExtend, side, lineNumber, }) => {
261
- const { useDiffContext } = useDiffViewContext();
262
- const oldLine = diffFile.getSplitLeftLine(index);
263
- const newLine = diffFile.getSplitRightLine(index);
264
- const renderExtendLine = useDiffContext(React__namespace.useCallback((s) => s.renderExtendLine, []));
265
- const currentExtend = side === exports.SplitSide.old ? oldLineExtend : newLineExtend;
266
- const currentLineNumber = side === exports.SplitSide.old ? oldLine.lineNumber : newLine.lineNumber;
267
- useSyncHeight({
268
- selector: `tr[data-line="${lineNumber}-extend"]`,
269
- side: exports.SplitSide[side],
270
- enable: !!(currentExtend === null || currentExtend === void 0 ? void 0 : currentExtend.data) && 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 === null || currentExtend === void 0 ? void 0 : currentExtend.data) && 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[side],
513
- enable: true,
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(React__namespace.useCallback((s) => ({
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 DiffSplitLine$1 = ({ index, diffFile, lineNumber, side, }) => {
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,11 +511,277 @@ 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
780
  const { useDiffContext } = useDiffViewContext();
776
- const renderWidgetLine = useDiffContext(React__namespace.useCallback((s) => s.renderWidgetLine, []));
781
+ const renderWidgetLine = useDiffContext.useShallowStableSelector((s) => s.renderWidgetLine);
777
782
  useSyncHeight({
778
- selector: `tr[data-line="${lineNumber}-widget"]`,
783
+ selector: `div[data-line="${lineNumber}-widget-content"]`,
784
+ wrapper: `tr[data-line="${lineNumber}-widget"]`,
779
785
  side: exports.SplitSide[side],
780
786
  enable: currentWidget && typeof renderWidgetLine === "function",
781
787
  });
@@ -786,18 +792,22 @@ const _DiffSplitWidgetLine$1 = ({ diffFile, side, lineNumber, currentLine, setWi
786
792
  if (!renderWidgetLine)
787
793
  return null;
788
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 },
789
- 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 &&
790
796
  (renderWidgetLine === null || renderWidgetLine === void 0 ? void 0 : renderWidgetLine({
791
797
  diffFile,
792
798
  side,
793
799
  lineNumber: currentLine.lineNumber,
794
800
  onClose: () => setWidget({}),
795
801
  }))))) : (React__namespace.createElement("td", { className: `diff-line-widget-${exports.SplitSide[side]}-placeholder p-0`, style: { backgroundColor: `var(${emptyBGName})` }, colSpan: 2 },
796
- React__namespace.createElement("span", null, "\u2002")))));
802
+ React__namespace.createElement("div", { "data-line": `${lineNumber}-widget-content`, "data-side": exports.SplitSide[side] }, "\u2002")))));
797
803
  };
798
804
  const DiffSplitWidgetLine$1 = ({ index, diffFile, side, lineNumber, }) => {
799
805
  const { useWidget } = useDiffWidgetContext();
800
- const { widgetLineNumber, widgetSide, setWidget } = useWidget(React__namespace.useCallback((s) => ({ widgetLineNumber: s.widgetLineNumber, widgetSide: s.widgetSide, setWidget: s.setWidget }), []));
806
+ const { widgetLineNumber, widgetSide, setWidget } = useWidget.useShallowStableSelector((s) => ({
807
+ widgetLineNumber: s.widgetLineNumber,
808
+ widgetSide: s.widgetSide,
809
+ setWidget: s.setWidget,
810
+ }));
801
811
  const oldLine = diffFile.getSplitLeftLine(index);
802
812
  const newLine = diffFile.getSplitRightLine(index);
803
813
  const oldLineWidget = oldLine.lineNumber && widgetSide === exports.SplitSide.old && widgetLineNumber === oldLine.lineNumber;
@@ -822,7 +832,7 @@ const onMouseDown$1 = (e) => {
822
832
  const DiffSplitViewTable = ({ side, diffFile }) => {
823
833
  const className = side === exports.SplitSide.new ? "new-diff-table" : "old-diff-table";
824
834
  const lines = core.getSplitContentLines(diffFile);
825
- 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] },
826
836
  React__namespace.createElement("colgroup", null,
827
837
  React__namespace.createElement("col", { className: `diff-table-${exports.SplitSide[side]}-num-col` }),
828
838
  React__namespace.createElement("col", { className: `diff-table-${exports.SplitSide[side]}-content-col` })),
@@ -837,7 +847,7 @@ const DiffSplitViewTable = ({ side, diffFile }) => {
837
847
  React__namespace.createElement("tbody", { className: "diff-table-body leading-[1.4]", onMouseDownCapture: onMouseDown$1 },
838
848
  lines.map((line) => (React__namespace.createElement(React.Fragment, { key: line.index },
839
849
  React__namespace.createElement(DiffSplitHunkLine$1, { index: line.index, side: side, lineNumber: line.lineNumber, diffFile: diffFile }),
840
- React__namespace.createElement(DiffSplitLine$1, { index: line.index, side: side, lineNumber: line.lineNumber, diffFile: diffFile }),
850
+ React__namespace.createElement(DiffSplitContentLine$1, { index: line.index, side: side, lineNumber: line.lineNumber, diffFile: diffFile }),
841
851
  React__namespace.createElement(DiffSplitWidgetLine$1, { index: line.index, side: side, lineNumber: line.lineNumber, diffFile: diffFile }),
842
852
  React__namespace.createElement(DiffSplitExtendLine$1, { index: line.index, side: side, lineNumber: line.lineNumber, diffFile: diffFile })))),
843
853
  React__namespace.createElement(DiffSplitHunkLine$1, { side: side, index: diffFile.splitLineLength, lineNumber: diffFile.splitLineLength, diffFile: diffFile }))));
@@ -847,7 +857,7 @@ const DiffSplitViewNormal = React.memo(({ diffFile }) => {
847
857
  const ref2 = React.useRef(null);
848
858
  const splitLineLength = Math.max(diffFile.splitLineLength, diffFile.fileLineLength);
849
859
  const { useDiffContext } = useDiffViewContext();
850
- const fontSize = useDiffContext(React.useCallback((s) => s.fontSize, []));
860
+ const fontSize = useDiffContext.useShallowStableSelector((s) => s.fontSize);
851
861
  index_js.useSyncExternalStore(diffFile.subscribe, diffFile.getUpdateCount);
852
862
  React.useEffect(() => {
853
863
  const left = ref1.current;
@@ -862,8 +872,8 @@ const DiffSplitViewNormal = React.memo(({ diffFile }) => {
862
872
  font,
863
873
  });
864
874
  const width = Math.max(40, _width + 25);
865
- return (React__namespace.createElement("div", { className: "split-diff-view split-diff-view-wrap flex w-full basis-[50%]" },
866
- React__namespace.createElement("div", { className: "old-diff-table-wrapper scrollbar-hide scrollbar-disable w-full overflow-x-auto overflow-y-hidden", ref: ref1, style: {
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: {
867
877
  // @ts-ignore
868
878
  [diffAsideWidthName]: `${Math.round(width)}px`,
869
879
  overscrollBehaviorX: "none",
@@ -871,8 +881,8 @@ const DiffSplitViewNormal = React.memo(({ diffFile }) => {
871
881
  fontSize: `var(${diffFontSizeName})`,
872
882
  } },
873
883
  React__namespace.createElement(DiffSplitViewTable, { side: exports.SplitSide.old, diffFile: diffFile })),
874
- React__namespace.createElement("div", { className: "diff-split-line w-[1.5px] bg-[rgb(222,222,222)]" }),
875
- React__namespace.createElement("div", { className: "new-diff-table-wrapper scrollbar-hide scrollbar-disable w-full overflow-x-auto overflow-y-hidden", ref: ref2, style: {
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: {
876
886
  // @ts-ignore
877
887
  [diffAsideWidthName]: `${Math.round(width)}px`,
878
888
  overscrollBehaviorX: "none",
@@ -883,12 +893,66 @@ const DiffSplitViewNormal = React.memo(({ diffFile }) => {
883
893
  });
884
894
  DiffSplitViewNormal.displayName = "DiffSplitViewNormal";
885
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
+
886
950
  const _DiffSplitExtendLine = ({ index, diffFile, lineNumber, oldLineExtend, newLineExtend, }) => {
887
951
  const { useDiffContext } = useDiffViewContext();
888
952
  const oldLine = diffFile.getSplitLeftLine(index);
889
953
  const newLine = diffFile.getSplitRightLine(index);
890
954
  // 需要显示的时候才进行方法订阅,可以大幅度提高性能
891
- const renderExtendLine = useDiffContext(React__namespace.useCallback((s) => s.renderExtendLine, []));
955
+ const renderExtendLine = useDiffContext.useShallowStableSelector((s) => s.renderExtendLine);
892
956
  if (!renderExtendLine)
893
957
  return null;
894
958
  return (React__namespace.createElement("tr", { "data-line": `${lineNumber}-extend`, "data-state": "extend", className: "diff-line diff-line-extend" },
@@ -902,7 +966,7 @@ const _DiffSplitExtendLine = ({ index, diffFile, lineNumber, oldLineExtend, newL
902
966
  onUpdate: diffFile.notifyAll,
903
967
  }))))) : (React__namespace.createElement("td", { className: "diff-line-extend-old-placeholder select-none p-0", style: { backgroundColor: `var(${emptyBGName})` }, colSpan: 2 },
904
968
  React__namespace.createElement("span", null, "\u2002"))),
905
- newLineExtend ? (React__namespace.createElement("td", { className: "diff-line-extend-new-content border-l-[1px] border-l-[rgb(222,222,222)] p-0", colSpan: 2 },
969
+ newLineExtend ? (React__namespace.createElement("td", { className: "diff-line-extend-new-content border-l-[1px] p-0", style: { borderLeftColor: `var(${borderColorName})` }, colSpan: 2 },
906
970
  React__namespace.createElement("div", { className: "diff-line-extend-wrapper" }, (newLineExtend === null || newLineExtend === void 0 ? void 0 : newLineExtend.data) &&
907
971
  (renderExtendLine === null || renderExtendLine === void 0 ? void 0 : renderExtendLine({
908
972
  diffFile,
@@ -910,7 +974,7 @@ const _DiffSplitExtendLine = ({ index, diffFile, lineNumber, oldLineExtend, newL
910
974
  lineNumber: newLine.lineNumber,
911
975
  data: newLineExtend.data,
912
976
  onUpdate: diffFile.notifyAll,
913
- }))))) : (React__namespace.createElement("td", { className: "diff-line-extend-new-placeholder select-none border-l-[1px] border-l-[rgb(222,222,222)] p-0", style: { backgroundColor: `var(${emptyBGName})` }, colSpan: 2 },
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 },
914
978
  React__namespace.createElement("span", null, "\u2002")))));
915
979
  };
916
980
  const DiffSplitExtendLine = ({ index, diffFile, lineNumber, }) => {
@@ -941,25 +1005,19 @@ const DiffSplitHunkLineGitHub = ({ index, diffFile, lineNumber, }) => {
941
1005
  const isExpandAll = currentHunk &&
942
1006
  currentHunk.splitInfo &&
943
1007
  currentHunk.splitInfo.endHiddenIndex - currentHunk.splitInfo.startHiddenIndex < core.composeLen;
944
- const currentIsShow = currentHunk &&
945
- currentHunk.splitInfo &&
946
- currentHunk.splitInfo.startHiddenIndex < currentHunk.splitInfo.endHiddenIndex;
947
- const currentIsPureHunk = currentHunk && diffFile._getIsPureDiffRender() && !currentHunk.splitInfo;
948
1008
  const isFirstLine = currentHunk && currentHunk.isFirst;
949
1009
  const isLastLine = currentHunk && currentHunk.isLast;
950
- if (!currentIsShow && !currentIsPureHunk)
951
- return null;
952
1010
  return (React__namespace.createElement("tr", { "data-line": `${lineNumber}-hunk`, "data-state": "hunk", className: "diff-line diff-line-hunk" },
953
1011
  React__namespace.createElement("td", { className: "diff-line-hunk-action relative w-[1%] min-w-[40px] select-none p-[1px]", style: {
954
1012
  backgroundColor: `var(${hunkLineNumberBGName})`,
955
1013
  color: `var(${plainLineNumberColorName})`,
956
- } }, couldExpand ? (isFirstLine ? (React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px] hover:bg-blue-300", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index) },
957
- React__namespace.createElement(ExpandUp, { className: "fill-current" }))) : isLastLine ? (React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px] hover:bg-blue-300", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onSplitHunkExpand("down", index) },
958
- React__namespace.createElement(ExpandDown, { className: "fill-current" }))) : isExpandAll ? (React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px] hover:bg-blue-300", title: "Expand All", "data-title": "Expand All", onClick: () => diffFile.onSplitHunkExpand("all", index) },
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) },
959
1017
  React__namespace.createElement(ExpandAll, { className: "fill-current" }))) : (React__namespace.createElement(React__namespace.Fragment, null,
960
- React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px] hover:bg-blue-300", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onSplitHunkExpand("down", index) },
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) },
961
1019
  React__namespace.createElement(ExpandDown, { className: "fill-current" })),
962
- React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px] hover:bg-blue-300", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index) },
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) },
963
1021
  React__namespace.createElement(ExpandUp, { className: "fill-current" }))))) : (React__namespace.createElement("div", { className: "min-h-[28px]" }, "\u2002"))),
964
1022
  React__namespace.createElement("td", { className: "diff-line-hunk-content pr-[10px] align-middle", style: { backgroundColor: `var(${hunkContentBGName})` }, colSpan: 3 },
965
1023
  React__namespace.createElement("div", { className: "pl-[1.5em]", style: {
@@ -974,49 +1032,44 @@ const DiffSplitHunkLineGitLab = ({ index, diffFile, lineNumber, }) => {
974
1032
  const isExpandAll = currentHunk &&
975
1033
  currentHunk.splitInfo &&
976
1034
  currentHunk.splitInfo.endHiddenIndex - currentHunk.splitInfo.startHiddenIndex < core.composeLen;
977
- const currentIsShow = currentHunk &&
978
- currentHunk.splitInfo &&
979
- currentHunk.splitInfo.startHiddenIndex < currentHunk.splitInfo.endHiddenIndex;
980
- const currentIsPureHunk = currentHunk && diffFile._getIsPureDiffRender() && !currentHunk.splitInfo;
981
1035
  const isFirstLine = currentHunk && currentHunk.isFirst;
982
1036
  const isLastLine = currentHunk && currentHunk.isLast;
983
- if (!currentIsShow && !currentIsPureHunk)
984
- return null;
985
1037
  return (React__namespace.createElement("tr", { "data-line": `${lineNumber}-hunk`, "data-state": "hunk", className: "diff-line diff-line-hunk" },
986
1038
  React__namespace.createElement("td", { className: "diff-line-hunk-action relative w-[1%] min-w-[40px] select-none p-[1px]", style: {
987
1039
  backgroundColor: `var(${hunkLineNumberBGName})`,
988
1040
  color: `var(${plainLineNumberColorName})`,
989
- } }, couldExpand ? (isFirstLine ? (React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px] hover:bg-blue-300", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index) },
990
- React__namespace.createElement(ExpandUp, { className: "fill-current" }))) : isLastLine ? (React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px] hover:bg-blue-300", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onSplitHunkExpand("down", index) },
991
- React__namespace.createElement(ExpandDown, { className: "fill-current" }))) : isExpandAll ? (React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px] hover:bg-blue-300", title: "Expand All", "data-title": "Expand All", onClick: () => diffFile.onSplitHunkExpand("all", index) },
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) },
992
1044
  React__namespace.createElement(ExpandAll, { className: "fill-current" }))) : (React__namespace.createElement(React__namespace.Fragment, null,
993
- React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px] hover:bg-blue-300", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onSplitHunkExpand("down", index) },
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) },
994
1046
  React__namespace.createElement(ExpandDown, { className: "fill-current" })),
995
- React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px] hover:bg-blue-300", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index) },
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) },
996
1048
  React__namespace.createElement(ExpandUp, { className: "fill-current" }))))) : (React__namespace.createElement("div", { className: "min-h-[28px]" }, "\u2002"))),
997
1049
  React__namespace.createElement("td", { className: "diff-line-hunk-content pr-[10px] align-middle", style: { backgroundColor: `var(${hunkContentBGName})` } },
998
1050
  React__namespace.createElement("div", { className: "pl-[1.5em]", style: {
999
1051
  color: `var(${hunkContentColorName})`,
1000
1052
  } }, ((_a = currentHunk.splitInfo) === null || _a === void 0 ? void 0 : _a.plainText) || currentHunk.text)),
1001
- React__namespace.createElement("td", { className: "diff-line-hunk-action relative w-[1%] min-w-[40px] select-none border-l-[1px] border-l-[rgb(222,222,222)] p-[1px]", style: {
1053
+ React__namespace.createElement("td", { className: "diff-line-hunk-action relative w-[1%] min-w-[40px] select-none border-l-[1px] p-[1px]", style: {
1002
1054
  backgroundColor: `var(${hunkLineNumberBGName})`,
1003
1055
  color: `var(${plainLineNumberColorName})`,
1004
- } }, couldExpand ? (isFirstLine ? (React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px] hover:bg-blue-300", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index) },
1005
- React__namespace.createElement(ExpandUp, { className: "fill-current" }))) : isLastLine ? (React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px] hover:bg-blue-300", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onSplitHunkExpand("down", index) },
1006
- React__namespace.createElement(ExpandDown, { className: "fill-current" }))) : isExpandAll ? (React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px] hover:bg-blue-300", title: "Expand All", "data-title": "Expand All", onClick: () => diffFile.onSplitHunkExpand("all", index) },
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) },
1007
1060
  React__namespace.createElement(ExpandAll, { className: "fill-current" }))) : (React__namespace.createElement(React__namespace.Fragment, null,
1008
- React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px] hover:bg-blue-300", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onSplitHunkExpand("down", index) },
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) },
1009
1062
  React__namespace.createElement(ExpandDown, { className: "fill-current" })),
1010
- React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px] hover:bg-blue-300", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index) },
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) },
1011
1064
  React__namespace.createElement(ExpandUp, { className: "fill-current" }))))) : (React__namespace.createElement("div", { className: "min-h-[28px]" }, "\u2002"))),
1012
1065
  React__namespace.createElement("td", { className: "diff-line-hunk-content pr-[10px] align-middle", style: { backgroundColor: `var(${hunkContentBGName})` } },
1013
1066
  React__namespace.createElement("div", { className: "pl-[1.5em]", style: {
1014
1067
  color: `var(${hunkContentColorName})`,
1015
1068
  } }, ((_b = currentHunk.splitInfo) === null || _b === void 0 ? void 0 : _b.plainText) || currentHunk.text))));
1016
1069
  };
1017
- const DiffSplitHunkLine = ({ index, diffFile, lineNumber, }) => {
1070
+ const _DiffSplitHunkLine = ({ index, diffFile, lineNumber, }) => {
1018
1071
  const { useDiffContext } = useDiffViewContext();
1019
- const diffViewMode = useDiffContext(React__namespace.useCallback((s) => s.mode, []));
1072
+ const diffViewMode = useDiffContext.useShallowStableSelector((s) => s.mode);
1020
1073
  if (diffViewMode === exports.DiffModeEnum.SplitGitHub ||
1021
1074
  diffViewMode === exports.DiffModeEnum.Split ||
1022
1075
  diffViewMode === exports.DiffModeEnum.Unified) {
@@ -1026,62 +1079,22 @@ const DiffSplitHunkLine = ({ index, diffFile, lineNumber, }) => {
1026
1079
  return React__namespace.createElement(DiffSplitHunkLineGitLab, { index: index, diffFile: diffFile, lineNumber: lineNumber });
1027
1080
  }
1028
1081
  };
1029
-
1030
- const _DiffSplitLine = ({ index, diffFile, lineNumber }) => {
1031
- var _a, _b;
1032
- const oldLine = diffFile.getSplitLeftLine(index);
1033
- const newLine = diffFile.getSplitRightLine(index);
1034
- const oldSyntaxLine = diffFile.getOldSyntaxLine(oldLine === null || oldLine === void 0 ? void 0 : oldLine.lineNumber);
1035
- const newSyntaxLine = diffFile.getNewSyntaxLine(newLine === null || newLine === void 0 ? void 0 : newLine.lineNumber);
1036
- const hasDiff = !!(oldLine === null || oldLine === void 0 ? void 0 : oldLine.diff) || !!(newLine === null || newLine === void 0 ? void 0 : newLine.diff);
1037
- const hasChange = core.checkDiffLineIncludeChange(oldLine === null || oldLine === void 0 ? void 0 : oldLine.diff) || core.checkDiffLineIncludeChange(newLine === null || newLine === void 0 ? void 0 : newLine.diff);
1038
- const oldLineIsDelete = ((_a = oldLine === null || oldLine === void 0 ? void 0 : oldLine.diff) === null || _a === void 0 ? void 0 : _a.type) === core.DiffLineType.Delete;
1039
- const newLineIsAdded = ((_b = newLine === null || newLine === void 0 ? void 0 : newLine.diff) === null || _b === void 0 ? void 0 : _b.type) === core.DiffLineType.Add;
1040
- const { useDiffContext } = useDiffViewContext();
1041
- const { enableHighlight, enableAddWidget, onAddWidgetClick } = useDiffContext(React__namespace.useCallback((s) => ({
1042
- enableHighlight: s.enableHighlight,
1043
- enableAddWidget: s.enableAddWidget,
1044
- onAddWidgetClick: s.onAddWidgetClick,
1045
- }), []));
1046
- const { useWidget } = useDiffWidgetContext();
1047
- const setWidget = useWidget.getReadonlyState().setWidget;
1048
- const hasOldLine = !!oldLine.lineNumber;
1049
- const hasNewLine = !!newLine.lineNumber;
1050
- const oldLineContentBG = getContentBG(false, oldLineIsDelete, hasDiff);
1051
- const oldLineNumberBG = getLineNumberBG(false, oldLineIsDelete, hasDiff);
1052
- const newLineContentBG = getContentBG(newLineIsAdded, false, hasDiff);
1053
- const newLineNumberBG = getLineNumberBG(newLineIsAdded, false, hasDiff);
1054
- return (React__namespace.createElement("tr", { "data-line": lineNumber, "data-state": hasDiff ? "diff" : "plain", className: "diff-line" },
1055
- hasOldLine ? (React__namespace.createElement(React__namespace.Fragment, null,
1056
- React__namespace.createElement("td", { className: "diff-line-old-num group relative w-[1%] min-w-[40px] select-none pl-[10px] pr-[10px] text-right align-top", "data-side": exports.SplitSide[exports.SplitSide.old], style: { backgroundColor: oldLineNumberBG, color: `var(${plainLineNumberColorName})` } },
1057
- hasDiff && enableAddWidget && (React__namespace.createElement(DiffSplitAddWidget, { index: index, lineNumber: oldLine.lineNumber, side: exports.SplitSide.old, diffFile: diffFile, onWidgetClick: (...props) => { var _a; return (_a = onAddWidgetClick.current) === null || _a === void 0 ? void 0 : _a.call(onAddWidgetClick, ...props); }, className: "absolute left-[100%] z-[1] translate-x-[-50%]", onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber: lineNumber, side: side }) })),
1058
- React__namespace.createElement("span", { "data-line-num": oldLine.lineNumber, style: { opacity: hasChange ? undefined : 0.5 } }, oldLine.lineNumber)),
1059
- React__namespace.createElement("td", { className: "diff-line-old-content group relative pr-[10px] align-top", "data-side": exports.SplitSide[exports.SplitSide.old], style: { backgroundColor: oldLineContentBG } },
1060
- hasDiff && enableAddWidget && (React__namespace.createElement(DiffSplitAddWidget, { index: index, lineNumber: oldLine.lineNumber, side: exports.SplitSide.old, diffFile: diffFile, onWidgetClick: (...props) => { var _a; return (_a = onAddWidgetClick.current) === null || _a === void 0 ? void 0 : _a.call(onAddWidgetClick, ...props); }, className: "absolute right-[100%] z-[1] translate-x-[50%]", onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber: lineNumber, side: side }) })),
1061
- React__namespace.createElement(DiffContent, { enableWrap: true, diffFile: diffFile, rawLine: oldLine.value, diffLine: oldLine.diff, syntaxLine: oldSyntaxLine, enableHighlight: enableHighlight })))) : (React__namespace.createElement("td", { className: "diff-line-old-placeholder select-none", "data-side": exports.SplitSide[exports.SplitSide.old], style: { backgroundColor: `var(${emptyBGName})` }, colSpan: 2 },
1062
- React__namespace.createElement("span", null, "\u2002"))),
1063
- hasNewLine ? (React__namespace.createElement(React__namespace.Fragment, null,
1064
- React__namespace.createElement("td", { className: "diff-line-new-num group relative w-[1%] min-w-[40px] select-none border-l-[1px] border-l-[rgb(222,222,222)] pl-[10px] pr-[10px] text-right align-top", "data-side": exports.SplitSide[exports.SplitSide.new], style: { backgroundColor: newLineNumberBG, color: `var(${plainLineNumberColorName})` } },
1065
- hasDiff && enableAddWidget && (React__namespace.createElement(DiffSplitAddWidget, { index: index, lineNumber: newLine.lineNumber, side: exports.SplitSide.new, diffFile: diffFile, onWidgetClick: (...props) => { var _a; return (_a = onAddWidgetClick.current) === null || _a === void 0 ? void 0 : _a.call(onAddWidgetClick, ...props); }, className: "absolute left-[100%] z-[1] translate-x-[-50%]", onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber: lineNumber, side: side }) })),
1066
- React__namespace.createElement("span", { "data-line-num": newLine.lineNumber, style: { opacity: hasChange ? undefined : 0.5 } }, newLine.lineNumber)),
1067
- React__namespace.createElement("td", { className: "diff-line-new-content group relative pr-[10px] align-top", "data-side": exports.SplitSide[exports.SplitSide.new], style: { backgroundColor: newLineContentBG } },
1068
- hasDiff && enableAddWidget && (React__namespace.createElement(DiffSplitAddWidget, { index: index, lineNumber: newLine.lineNumber, side: exports.SplitSide.new, diffFile: diffFile, onWidgetClick: (...props) => { var _a; return (_a = onAddWidgetClick.current) === null || _a === void 0 ? void 0 : _a.call(onAddWidgetClick, ...props); }, className: "absolute right-[100%] z-[1] translate-x-[50%]", onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber: lineNumber, side: side }) })),
1069
- React__namespace.createElement(DiffContent, { enableWrap: true, diffFile: diffFile, rawLine: newLine.value || "", diffLine: newLine.diff, syntaxLine: newSyntaxLine, enableHighlight: enableHighlight })))) : (React__namespace.createElement("td", { className: "diff-line-new-placeholder select-none border-l-[1px] border-l-[rgb(222,222,222)]", style: { backgroundColor: `var(${emptyBGName})` }, "data-side": exports.SplitSide[exports.SplitSide.new], colSpan: 2 },
1070
- React__namespace.createElement("span", null, "\u2002")))));
1071
- };
1072
- const DiffSplitLine = ({ index, diffFile, lineNumber, }) => {
1073
- const oldLine = diffFile.getSplitLeftLine(index);
1074
- const newLine = diffFile.getSplitRightLine(index);
1075
- 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)
1076
1089
  return null;
1077
- return React__namespace.createElement(_DiffSplitLine, { index: index, diffFile: diffFile, lineNumber: lineNumber });
1090
+ return React__namespace.createElement(_DiffSplitHunkLine, { index: index, diffFile: diffFile, lineNumber: lineNumber });
1078
1091
  };
1079
1092
 
1080
1093
  const _DiffSplitWidgetLine = ({ index, diffFile, lineNumber, oldLineWidget, newLineWidget, }) => {
1081
1094
  const { useWidget } = useDiffWidgetContext();
1082
1095
  const setWidget = useWidget.getReadonlyState().setWidget;
1083
1096
  const { useDiffContext } = useDiffViewContext();
1084
- const renderWidgetLine = useDiffContext(React__namespace.useCallback((s) => s.renderWidgetLine, []));
1097
+ const renderWidgetLine = useDiffContext.useShallowStableSelector((s) => s.renderWidgetLine);
1085
1098
  const oldLine = diffFile.getSplitLeftLine(index);
1086
1099
  const newLine = diffFile.getSplitRightLine(index);
1087
1100
  if (!renderWidgetLine)
@@ -1095,18 +1108,21 @@ const _DiffSplitWidgetLine = ({ index, diffFile, lineNumber, oldLineWidget, newL
1095
1108
  onClose: () => setWidget({}),
1096
1109
  })))) : (React__namespace.createElement("td", { className: "diff-line-widget-old-placeholder select-none p-0", style: { backgroundColor: `var(${emptyBGName})` }, colSpan: 2 },
1097
1110
  React__namespace.createElement("span", null, "\u2002"))),
1098
- newLineWidget ? (React__namespace.createElement("td", { className: "diff-line-widget-new-content border-l-[1px] border-l-[rgb(222,222,222)] p-0", colSpan: 2 },
1111
+ newLineWidget ? (React__namespace.createElement("td", { className: "diff-line-widget-new-content border-l-[1px] p-0", colSpan: 2, style: { borderLeftColor: `var(${borderColorName})` } },
1099
1112
  React__namespace.createElement("div", { className: "diff-line-widget-wrapper" }, renderWidgetLine === null || renderWidgetLine === void 0 ? void 0 : renderWidgetLine({
1100
1113
  diffFile,
1101
1114
  side: exports.SplitSide.new,
1102
1115
  lineNumber: newLine.lineNumber,
1103
1116
  onClose: () => setWidget({}),
1104
- })))) : (React__namespace.createElement("td", { className: "diff-line-widget-new-placeholder select-none border-l-[1px] border-l-[rgb(222,222,222)] p-0", style: { backgroundColor: `var(${emptyBGName})` }, colSpan: 2 },
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 },
1105
1118
  React__namespace.createElement("span", null, "\u2002")))));
1106
1119
  };
1107
1120
  const DiffSplitWidgetLine = ({ index, diffFile, lineNumber, }) => {
1108
1121
  const { useWidget } = useDiffWidgetContext();
1109
- const { widgetLineNumber, widgetSide } = useWidget(React__namespace.useCallback((s) => ({ widgetLineNumber: s.widgetLineNumber, widgetSide: s.widgetSide }), []));
1122
+ const { widgetLineNumber, widgetSide } = useWidget((s) => ({
1123
+ widgetLineNumber: s.widgetLineNumber,
1124
+ widgetSide: s.widgetSide,
1125
+ }));
1110
1126
  const oldLine = diffFile.getSplitLeftLine(index);
1111
1127
  const newLine = diffFile.getSplitRightLine(index);
1112
1128
  const oldLineWidget = oldLine.lineNumber && widgetSide === exports.SplitSide.old && widgetLineNumber === oldLine.lineNumber;
@@ -1130,7 +1146,7 @@ const DiffSplitViewWrap = React.memo(({ diffFile }) => {
1130
1146
  const splitLineLength = Math.max(diffFile.splitLineLength, diffFile.fileLineLength);
1131
1147
  const { useDiffContext } = useDiffViewContext();
1132
1148
  const useSplitConfig = React.useMemo(() => createDiffSplitConfigStore(), []);
1133
- const fontSize = useDiffContext(React.useCallback((s) => s.fontSize, []));
1149
+ const fontSize = useDiffContext.useShallowStableSelector((s) => s.fontSize);
1134
1150
  index_js.useSyncExternalStore(diffFile.subscribe, diffFile.getUpdateCount);
1135
1151
  const onMouseDown = React.useCallback((e) => {
1136
1152
  let ele = e.target;
@@ -1159,7 +1175,7 @@ const DiffSplitViewWrap = React.memo(({ diffFile }) => {
1159
1175
  });
1160
1176
  const width = Math.max(40, _width + 25);
1161
1177
  const lines = core.getSplitContentLines(diffFile);
1162
- return (React__namespace.createElement("div", { className: "split-diff-view split-diff-view-normal w-full" },
1178
+ return (React__namespace.createElement("div", { className: "split-diff-view split-diff-view-wrap w-full" },
1163
1179
  React__namespace.createElement("div", { className: "diff-table-wrapper w-full", style: {
1164
1180
  // @ts-ignore
1165
1181
  [diffAsideWidthName]: `${Math.round(width)}px`,
@@ -1167,7 +1183,7 @@ const DiffSplitViewWrap = React.memo(({ diffFile }) => {
1167
1183
  fontSize: `var(${diffFontSizeName})`,
1168
1184
  } },
1169
1185
  React__namespace.createElement(Style, { useSelector: useSplitConfig, id: `diff-root${diffFile.getId()}` }),
1170
- React__namespace.createElement("table", { className: "diff-table w-full table-fixed border-collapse" },
1186
+ React__namespace.createElement("table", { className: "diff-table w-full table-fixed border-collapse border-spacing-0" },
1171
1187
  React__namespace.createElement("colgroup", null,
1172
1188
  React__namespace.createElement("col", { className: "diff-table-old-num-col", width: Math.round(width) }),
1173
1189
  React__namespace.createElement("col", { className: "diff-table-old-content-col" }),
@@ -1182,7 +1198,7 @@ const DiffSplitViewWrap = React.memo(({ diffFile }) => {
1182
1198
  React__namespace.createElement("tbody", { className: "diff-table-body leading-[1.4]", onMouseDownCapture: onMouseDown },
1183
1199
  lines.map((line) => (React__namespace.createElement(React.Fragment, { key: line.index },
1184
1200
  React__namespace.createElement(DiffSplitHunkLine, { index: line.index, lineNumber: line.lineNumber, diffFile: diffFile }),
1185
- React__namespace.createElement(DiffSplitLine, { index: line.index, lineNumber: line.lineNumber, diffFile: diffFile }),
1201
+ React__namespace.createElement(DiffSplitContentLine, { index: line.index, lineNumber: line.lineNumber, diffFile: diffFile }),
1186
1202
  React__namespace.createElement(DiffSplitWidgetLine, { index: line.index, lineNumber: line.lineNumber, diffFile: diffFile }),
1187
1203
  React__namespace.createElement(DiffSplitExtendLine, { index: line.index, lineNumber: line.lineNumber, diffFile: diffFile })))),
1188
1204
  React__namespace.createElement(DiffSplitHunkLine, { index: diffFile.splitLineLength, lineNumber: diffFile.splitLineLength, diffFile: diffFile }))))));
@@ -1193,7 +1209,7 @@ const DiffSplitView = React.memo(({ diffFile }) => {
1193
1209
  const { useDiffContext } = useDiffViewContext();
1194
1210
  const useDiffContextRef = React.useRef(useDiffContext);
1195
1211
  useDiffContextRef.current = useDiffContext;
1196
- const enableWrap = useDiffContext(React.useCallback((s) => s.enableWrap, []));
1212
+ const enableWrap = useDiffContext.useShallowStableSelector((s) => s.enableWrap);
1197
1213
  // performance optimization
1198
1214
  const useWidget = React.useMemo(() => createDiffWidgetStore(useDiffContextRef), []);
1199
1215
  const contextValue = React.useMemo(() => ({ useWidget }), [useWidget]);
@@ -1205,9 +1221,101 @@ const DiffSplitView = React.memo(({ diffFile }) => {
1205
1221
  });
1206
1222
  DiffSplitView.displayName = "DiffSplitView";
1207
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
+
1208
1316
  const _DiffUnifiedExtendLine = ({ index, diffFile, lineNumber, oldLineExtend, newLineExtend, }) => {
1209
1317
  const { useDiffContext } = useDiffViewContext();
1210
- const renderExtendLine = useDiffContext(React.useCallback((s) => s.renderExtendLine, []));
1318
+ const renderExtendLine = useDiffContext.useShallowStableSelector((s) => s.renderExtendLine);
1211
1319
  const unifiedItem = diffFile.getUnifiedLine(index);
1212
1320
  const width = useDomWidth({
1213
1321
  selector: ".unified-diff-table-wrapper",
@@ -1258,7 +1366,7 @@ const _DiffUnifiedHunkLine = ({ index, diffFile, lineNumber, }) => {
1258
1366
  const currentHunk = diffFile.getUnifiedHunkLine(index);
1259
1367
  const expandEnabled = diffFile.getExpandEnabled();
1260
1368
  const { useDiffContext } = useDiffViewContext();
1261
- const enableWrap = useDiffContext(React.useCallback((s) => s.enableWrap, []));
1369
+ const enableWrap = useDiffContext.useShallowStableSelector((s) => s.enableWrap);
1262
1370
  const couldExpand = expandEnabled && currentHunk && currentHunk.unifiedInfo;
1263
1371
  const isExpandAll = currentHunk &&
1264
1372
  currentHunk.unifiedInfo &&
@@ -1298,104 +1406,12 @@ const DiffUnifiedHunkLine = ({ index, diffFile, lineNumber, }) => {
1298
1406
  return React__namespace.createElement(_DiffUnifiedHunkLine, { index: index, diffFile: diffFile, lineNumber: lineNumber });
1299
1407
  };
1300
1408
 
1301
- const DiffUnifiedOldLine = ({ index, diffLine, rawLine, syntaxLine, lineNumber, diffFile, setWidget, enableWrap, enableAddWidget, enableHighlight, onAddWidgetClick, }) => {
1302
- return (React__namespace.createElement("tr", { "data-line": index, "data-state": "diff", className: "diff-line group" },
1303
- React__namespace.createElement("td", { className: "diff-line-num sticky left-0 w-[1%] min-w-[100px] select-none whitespace-nowrap pl-[10px] pr-[10px] text-right align-top", style: {
1304
- color: `var(${plainLineNumberColorName})`,
1305
- backgroundColor: `var(${delLineNumberBGName})`,
1306
- width: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
1307
- maxWidth: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
1308
- minWidth: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
1309
- } },
1310
- enableAddWidget && (React__namespace.createElement(DiffUnifiedAddWidget, { index: index - 1, lineNumber: lineNumber, diffFile: diffFile, side: exports.SplitSide.old, onWidgetClick: onAddWidgetClick, onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber, side }) })),
1311
- React__namespace.createElement("div", { className: "flex" },
1312
- React__namespace.createElement("span", { "data-line-old-num": lineNumber, className: "inline-block w-[50%]" }, lineNumber),
1313
- React__namespace.createElement("span", { className: "w-[10px] shrink-0" }),
1314
- React__namespace.createElement("span", { className: "inline-block w-[50%]" }))),
1315
- React__namespace.createElement("td", { className: "diff-line-content pr-[10px] align-top", style: { backgroundColor: `var(${delContentBGName})` } },
1316
- React__namespace.createElement(DiffContent, { enableWrap: enableWrap, diffFile: diffFile, enableHighlight: enableHighlight, rawLine: rawLine, diffLine: diffLine, syntaxLine: syntaxLine }))));
1317
- };
1318
- const DiffUnifiedNewLine = ({ index, diffLine, rawLine, syntaxLine, lineNumber, diffFile, setWidget, enableWrap, enableAddWidget, enableHighlight, onAddWidgetClick, }) => {
1319
- return (React__namespace.createElement("tr", { "data-line": index, "data-state": "diff", className: "diff-line group" },
1320
- React__namespace.createElement("td", { className: "diff-line-num sticky left-0 w-[1%] min-w-[100px] select-none whitespace-nowrap pl-[10px] pr-[10px] text-right align-top", style: {
1321
- color: `var(${plainLineNumberColorName})`,
1322
- backgroundColor: `var(${addLineNumberBGName})`,
1323
- width: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
1324
- maxWidth: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
1325
- minWidth: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
1326
- } },
1327
- enableAddWidget && (React__namespace.createElement(DiffUnifiedAddWidget, { index: index - 1, lineNumber: lineNumber, diffFile: diffFile, side: exports.SplitSide.new, onWidgetClick: onAddWidgetClick, onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber, side }) })),
1328
- React__namespace.createElement("div", { className: "flex" },
1329
- React__namespace.createElement("span", { className: "inline-block w-[50%]" }),
1330
- React__namespace.createElement("span", { className: "w-[10px] shrink-0" }),
1331
- React__namespace.createElement("span", { "data-line-new-num": lineNumber, className: "inline-block w-[50%]" }, lineNumber))),
1332
- React__namespace.createElement("td", { className: "diff-line-content pr-[10px] align-top", style: { backgroundColor: `var(${addContentBGName})` } },
1333
- React__namespace.createElement(DiffContent, { enableWrap: enableWrap, diffFile: diffFile, enableHighlight: enableHighlight, rawLine: rawLine, diffLine: diffLine, syntaxLine: syntaxLine }))));
1334
- };
1335
- const _DiffUnifiedLine = React.memo(({ index, diffFile, lineNumber }) => {
1336
- const unifiedLine = diffFile.getUnifiedLine(index);
1337
- const { useDiffContext } = useDiffViewContext();
1338
- const { enableWrap, enableHighlight, enableAddWidget, onAddWidgetClick } = useDiffContext(React__namespace.useCallback((s) => ({
1339
- enableWrap: s.enableWrap,
1340
- enableHighlight: s.enableHighlight,
1341
- enableAddWidget: s.enableAddWidget,
1342
- onAddWidgetClick: s.onAddWidgetClick,
1343
- }), []));
1344
- const { useWidget } = useDiffWidgetContext();
1345
- const setWidget = useWidget.getReadonlyState().setWidget;
1346
- const hasDiff = unifiedLine.diff;
1347
- const hasChange = core.checkDiffLineIncludeChange(unifiedLine.diff);
1348
- const rawLine = unifiedLine.value || "";
1349
- const diffLine = unifiedLine.diff;
1350
- const newLineNumber = unifiedLine.newLineNumber;
1351
- const oldLinenumber = unifiedLine.oldLineNumber;
1352
- const syntaxLine = newLineNumber
1353
- ? diffFile.getNewSyntaxLine(newLineNumber)
1354
- : oldLinenumber
1355
- ? diffFile.getOldSyntaxLine(oldLinenumber)
1356
- : undefined;
1357
- if (hasChange) {
1358
- if (unifiedLine.oldLineNumber) {
1359
- 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); } }));
1360
- }
1361
- else {
1362
- 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); } }));
1363
- }
1364
- }
1365
- else {
1366
- return (React__namespace.createElement("tr", { "data-line": lineNumber, "data-state": unifiedLine.diff ? "diff" : "plain", className: "diff-line group" },
1367
- React__namespace.createElement("td", { className: "diff-line-num sticky left-0 w-[1%] min-w-[100px] select-none whitespace-nowrap pl-[10px] pr-[10px] text-right align-top", style: {
1368
- color: `var(${plainLineNumberColorName})`,
1369
- width: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
1370
- maxWidth: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
1371
- minWidth: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
1372
- backgroundColor: hasDiff ? `var(${plainLineNumberBGName})` : `var(${expandContentBGName})`,
1373
- } },
1374
- enableAddWidget && hasDiff && (React__namespace.createElement(DiffUnifiedAddWidget, { index: index, diffFile: diffFile, lineNumber: unifiedLine.newLineNumber, side: exports.SplitSide.new, onWidgetClick: (...props) => { var _a; return (_a = onAddWidgetClick.current) === null || _a === void 0 ? void 0 : _a.call(onAddWidgetClick, ...props); }, onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber, side }) })),
1375
- React__namespace.createElement("div", { className: "flex opacity-[0.5]" },
1376
- React__namespace.createElement("span", { "data-line-old-num": unifiedLine.oldLineNumber, className: "inline-block w-[50%]" }, unifiedLine.oldLineNumber),
1377
- React__namespace.createElement("span", { className: "w-[10px] shrink-0" }),
1378
- React__namespace.createElement("span", { "data-line-new-num": unifiedLine.newLineNumber, className: "inline-block w-[50%]" }, unifiedLine.newLineNumber))),
1379
- React__namespace.createElement("td", { className: "diff-line-content pr-[10px] align-top", style: {
1380
- backgroundColor: hasDiff ? `var(${plainContentBGName})` : `var(${expandContentBGName})`,
1381
- } },
1382
- React__namespace.createElement(DiffContent, { enableWrap: enableWrap, diffFile: diffFile, enableHighlight: enableHighlight, rawLine: rawLine, diffLine: diffLine, syntaxLine: syntaxLine }))));
1383
- }
1384
- });
1385
- _DiffUnifiedLine.displayName = "_DiffUnifiedLine";
1386
- const DiffUnifiedLine = ({ index, diffFile, lineNumber, }) => {
1387
- const unifiedLine = diffFile.getUnifiedLine(index);
1388
- if (unifiedLine === null || unifiedLine === void 0 ? void 0 : unifiedLine.isHidden)
1389
- return null;
1390
- return React__namespace.createElement(_DiffUnifiedLine, { index: index, diffFile: diffFile, lineNumber: lineNumber });
1391
- };
1392
-
1393
1409
  const _DiffUnifiedWidgetLine = ({ index, diffFile, oldWidget, newWidget, lineNumber, setWidget, }) => {
1394
1410
  const unifiedItem = diffFile.getUnifiedLine(index);
1395
1411
  const onClose = () => setWidget({});
1396
1412
  const { useDiffContext } = useDiffViewContext();
1397
1413
  // 需要显示的时候才进行方法订阅,可以大幅度提高性能
1398
- const renderWidgetLine = useDiffContext(React.useCallback((s) => s.renderWidgetLine, []));
1414
+ const renderWidgetLine = useDiffContext.useShallowStableSelector((s) => s.renderWidgetLine);
1399
1415
  const width = useDomWidth({
1400
1416
  selector: ".unified-diff-table-wrapper",
1401
1417
  enable: typeof renderWidgetLine === "function",
@@ -1414,7 +1430,11 @@ const _DiffUnifiedWidgetLine = ({ index, diffFile, oldWidget, newWidget, lineNum
1414
1430
  };
1415
1431
  const DiffUnifiedWidgetLine = ({ index, diffFile, lineNumber, }) => {
1416
1432
  const { useWidget } = useDiffWidgetContext();
1417
- const { widgetSide, widgetLineNumber, setWidget } = useWidget(React__namespace.useCallback((s) => ({ widgetLineNumber: s.widgetLineNumber, widgetSide: s.widgetSide, setWidget: s.setWidget }), []));
1433
+ const { widgetSide, widgetLineNumber, setWidget } = useWidget.useShallowStableSelector((s) => ({
1434
+ widgetLineNumber: s.widgetLineNumber,
1435
+ widgetSide: s.widgetSide,
1436
+ setWidget: s.setWidget,
1437
+ }));
1418
1438
  const unifiedItem = diffFile.getUnifiedLine(index);
1419
1439
  const oldWidget = unifiedItem.oldLineNumber && widgetSide === exports.SplitSide.old && widgetLineNumber === unifiedItem.oldLineNumber;
1420
1440
  const newWidget = unifiedItem.newLineNumber && widgetSide === exports.SplitSide.new && widgetLineNumber === unifiedItem.newLineNumber;
@@ -1440,7 +1460,10 @@ const DiffUnifiedView = React.memo(({ diffFile }) => {
1440
1460
  // performance optimization
1441
1461
  const useWidget = React.useMemo(() => createDiffWidgetStore(useDiffContextRef), []);
1442
1462
  const contextValue = React.useMemo(() => ({ useWidget }), [useWidget]);
1443
- const fontSize = useDiffContext(React.useCallback((s) => s.fontSize, []));
1463
+ const { fontSize, enableWrap } = useDiffContext.useShallowStableSelector((s) => ({
1464
+ fontSize: s.fontSize,
1465
+ enableWrap: s.enableWrap,
1466
+ }));
1444
1467
  index_js.useSyncExternalStore(diffFile.subscribe, diffFile.getUpdateCount);
1445
1468
  React.useEffect(() => {
1446
1469
  const { setWidget } = useWidget.getReadonlyState();
@@ -1454,14 +1477,14 @@ const DiffUnifiedView = React.memo(({ diffFile }) => {
1454
1477
  const width = Math.max(40, _width + 10);
1455
1478
  const lines = core.getUnifiedContentLine(diffFile);
1456
1479
  return (React__namespace.createElement(DiffWidgetContext.Provider, { value: contextValue },
1457
- React__namespace.createElement("div", { className: "unified-diff-view w-full" },
1458
- React__namespace.createElement("div", { className: "unified-diff-table-wrapper scrollbar-hide scrollbar-disable w-full overflow-x-auto overflow-y-hidden", style: {
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: {
1459
1482
  // @ts-ignore
1460
1483
  [diffAsideWidthName]: `${Math.round(width)}px`,
1461
1484
  fontFamily: "Menlo, Consolas, monospace",
1462
1485
  fontSize: `var(${diffFontSizeName})`,
1463
1486
  } },
1464
- React__namespace.createElement("table", { className: "unified-diff-table w-full border-collapse" },
1487
+ React__namespace.createElement("table", { className: `unified-diff-table w-full border-collapse border-spacing-0 ${enableWrap ? "table-fixed" : ""}` },
1465
1488
  React__namespace.createElement("colgroup", null,
1466
1489
  React__namespace.createElement("col", { className: "unified-diff-table-num-col" }),
1467
1490
  React__namespace.createElement("col", { className: "unified-diff-table-content-col" })),
@@ -1472,7 +1495,7 @@ const DiffUnifiedView = React.memo(({ diffFile }) => {
1472
1495
  React__namespace.createElement("tbody", { className: "diff-table-body leading-[1.4]", onMouseDownCapture: onMouseDown },
1473
1496
  lines.map((item) => (React__namespace.createElement(React.Fragment, { key: item.index },
1474
1497
  React__namespace.createElement(DiffUnifiedHunkLine, { index: item.index, lineNumber: item.lineNumber, diffFile: diffFile }),
1475
- React__namespace.createElement(DiffUnifiedLine, { index: item.index, lineNumber: item.lineNumber, diffFile: diffFile }),
1498
+ React__namespace.createElement(DiffUnifiedContentLine, { index: item.index, lineNumber: item.lineNumber, diffFile: diffFile }),
1476
1499
  React__namespace.createElement(DiffUnifiedWidgetLine, { index: item.index, lineNumber: item.lineNumber, diffFile: diffFile }),
1477
1500
  React__namespace.createElement(DiffUnifiedExtendLine, { index: item.index, lineNumber: item.lineNumber, diffFile: diffFile })))),
1478
1501
  React__namespace.createElement(DiffUnifiedHunkLine, { index: diffFile.unifiedLineLength, lineNumber: diffFile.unifiedLineLength, diffFile: diffFile })))))));
@@ -1488,6 +1511,7 @@ exports.SplitSide = void 0;
1488
1511
  const _InternalDiffView = (props) => {
1489
1512
  const { diffFile, className, style, diffViewMode, diffViewWrap, diffViewFontSize, diffViewHighlight, renderWidgetLine, renderExtendLine, extendData, diffViewAddWidget, onAddWidgetClick, } = props;
1490
1513
  const diffFileId = React.useMemo(() => diffFile.getId(), [diffFile]);
1514
+ const wrapperRef = React.useRef();
1491
1515
  // performance optimization
1492
1516
  const useDiffContext = React.useMemo(() => createDiffConfigStore(props, diffFileId),
1493
1517
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -1517,9 +1541,16 @@ const _InternalDiffView = (props) => {
1517
1541
  extendData,
1518
1542
  onAddWidgetClick,
1519
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]);
1520
1551
  const value = React.useMemo(() => ({ useDiffContext }), [useDiffContext]);
1521
1552
  return (React__namespace.createElement(DiffViewContext.Provider, { value: value },
1522
- React__namespace.createElement("div", { className: "diff-tailwindcss-wrapper", "data-component": "git-diff-view", "data-version": `${"0.0.16"}`, "data-highlighter": diffFile._getHighlighterName() },
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 },
1523
1554
  React__namespace.createElement("div", { className: "diff-style-root", style: {
1524
1555
  // @ts-ignore
1525
1556
  [diffFontSizeName]: diffViewFontSize + "px",
@@ -1529,7 +1560,7 @@ const _InternalDiffView = (props) => {
1529
1560
  const InternalDiffView = React.memo(_InternalDiffView);
1530
1561
  const DiffViewWithRef = (props, ref) => {
1531
1562
  var _a, _b;
1532
- 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"]);
1533
1564
  const diffFile = React.useMemo(() => {
1534
1565
  var _a, _b, _c, _d, _e, _f;
1535
1566
  if (_diffFile) {
@@ -1544,16 +1575,17 @@ const DiffViewWithRef = (props, ref) => {
1544
1575
  }, [data, _diffFile]);
1545
1576
  const diffFileRef = React.useRef(diffFile);
1546
1577
  if (diffFileRef.current && diffFileRef.current !== diffFile) {
1547
- (_b = (_a = diffFileRef.current)._destroy) === null || _b === void 0 ? void 0 : _b.call(_a);
1578
+ (_b = (_a = diffFileRef.current).clear) === null || _b === void 0 ? void 0 : _b.call(_a);
1548
1579
  diffFileRef.current = diffFile;
1549
1580
  }
1550
1581
  React.useEffect(() => {
1551
1582
  if (!diffFile)
1552
1583
  return;
1584
+ diffFile.initTheme(diffViewTheme);
1553
1585
  diffFile.initRaw();
1554
1586
  diffFile.buildSplitDiffLines();
1555
1587
  diffFile.buildUnifiedDiffLines();
1556
- }, [diffFile]);
1588
+ }, [diffFile, diffViewTheme]);
1557
1589
  React.useEffect(() => {
1558
1590
  if (!diffFile)
1559
1591
  return;
@@ -1561,7 +1593,7 @@ const DiffViewWithRef = (props, ref) => {
1561
1593
  diffFile.initSyntax({ registerHighlighter });
1562
1594
  diffFile.notifyAll();
1563
1595
  }
1564
- }, [diffFile, props.diffViewHighlight, registerHighlighter]);
1596
+ }, [diffFile, props.diffViewHighlight, registerHighlighter, diffViewTheme]);
1565
1597
  React.useEffect(() => {
1566
1598
  if (_diffFile && diffFile) {
1567
1599
  _diffFile._addClonedInstance(diffFile);
@@ -1570,7 +1602,7 @@ const DiffViewWithRef = (props, ref) => {
1570
1602
  };
1571
1603
  }
1572
1604
  }, [diffFile, _diffFile]);
1573
- useUnmount(() => { var _a; return (_a = diffFile === null || diffFile === void 0 ? void 0 : diffFile._destroy) === null || _a === void 0 ? void 0 : _a.call(diffFile); }, [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]);
1574
1606
  React.useImperativeHandle(ref, () => ({ getDiffFileInstance: () => diffFile }), [diffFile]);
1575
1607
  if (!diffFile)
1576
1608
  return null;
@@ -1578,7 +1610,7 @@ const DiffViewWithRef = (props, ref) => {
1578
1610
  };
1579
1611
  const DiffView = React.forwardRef(DiffViewWithRef);
1580
1612
  DiffView.displayName = "DiffView";
1581
- const version = "0.0.16";
1613
+ const version = "0.0.17";
1582
1614
 
1583
1615
  exports.DiffView = DiffView;
1584
1616
  exports.DiffViewContext = DiffViewContext;