@git-diff-view/react 0.0.16 → 0.0.18

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: {
@@ -599,6 +339,8 @@ const DiffNoNewLine = () => {
599
339
 
600
340
  const temp = {};
601
341
  const formatStringToCamelCase = (str) => {
342
+ if (str.startsWith("--"))
343
+ return str;
602
344
  const splitted = str.split("-");
603
345
  if (splitted.length === 1)
604
346
  return splitted[0];
@@ -715,7 +457,9 @@ const DiffContent = ({ diffLine, rawLine, syntaxLine, enableWrap, enableHighligh
715
457
  const isAdded = (diffLine === null || diffLine === void 0 ? void 0 : diffLine.type) === core.DiffLineType.Add;
716
458
  const isDelete = (diffLine === null || diffLine === void 0 ? void 0 : diffLine.type) === core.DiffLineType.Delete;
717
459
  const isMaxLineLengthToIgnoreSyntax = ((_a = syntaxLine === null || syntaxLine === void 0 ? void 0 : syntaxLine.nodeList) === null || _a === void 0 ? void 0 : _a.length) > 150;
718
- return (React__namespace.createElement("div", { className: "diff-line-content-item pl-[2.0em]", "data-val": rawLine, style: {
460
+ return (React__namespace.createElement("div", { className: "diff-line-content-item pl-[2.0em]",
461
+ // data-val={rawLine}
462
+ style: {
719
463
  whiteSpace: enableWrap ? "pre-wrap" : "pre",
720
464
  wordBreak: enableWrap ? "break-all" : "initial",
721
465
  } },
@@ -739,11 +483,11 @@ const _DiffSplitLine$1 = ({ index, diffFile, lineNumber, side, }) => {
739
483
  const isAdded = ((_a = currentLine === null || currentLine === void 0 ? void 0 : currentLine.diff) === null || _a === void 0 ? void 0 : _a.type) === core.DiffLineType.Add;
740
484
  const isDelete = ((_b = currentLine === null || currentLine === void 0 ? void 0 : currentLine.diff) === null || _b === void 0 ? void 0 : _b.type) === core.DiffLineType.Delete;
741
485
  const { useDiffContext } = useDiffViewContext();
742
- const { enableHighlight, enableAddWidget, onAddWidgetClick } = useDiffContext(React__namespace.useCallback((s) => ({
486
+ const { enableHighlight, enableAddWidget, onAddWidgetClick } = useDiffContext.useShallowStableSelector((s) => ({
743
487
  enableHighlight: s.enableHighlight,
744
488
  enableAddWidget: s.enableAddWidget,
745
489
  onAddWidgetClick: s.onAddWidgetClick,
746
- }), []));
490
+ }));
747
491
  const { useWidget } = useDiffWidgetContext();
748
492
  const setWidget = useWidget.getReadonlyState().setWidget;
749
493
  const contentBG = getContentBG(isAdded, isDelete, hasDiff);
@@ -763,7 +507,7 @@ const _DiffSplitLine$1 = ({ index, diffFile, lineNumber, side, }) => {
763
507
  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
508
  React__namespace.createElement("span", null, "\u2002")))));
765
509
  };
766
- const DiffSplitLine$1 = ({ index, diffFile, lineNumber, side, }) => {
510
+ const DiffSplitContentLine$1 = ({ index, diffFile, lineNumber, side, }) => {
767
511
  const getCurrentLine = side === exports.SplitSide.old ? diffFile.getSplitLeftLine : diffFile.getSplitRightLine;
768
512
  const currentLine = getCurrentLine(index);
769
513
  if (currentLine === null || currentLine === void 0 ? void 0 : currentLine.isHidden)
@@ -771,11 +515,271 @@ const DiffSplitLine$1 = ({ index, diffFile, lineNumber, side, }) => {
771
515
  return React__namespace.createElement(_DiffSplitLine$1, { index: index, diffFile: diffFile, lineNumber: lineNumber, side: side });
772
516
  };
773
517
 
518
+ const useDomWidth = ({ selector, enable }) => {
519
+ const [width, setWidth] = React.useState(0);
520
+ const { useDiffContext } = useDiffViewContext();
521
+ const id = useDiffContext(React.useCallback((s) => s.id, []));
522
+ React.useEffect(() => {
523
+ if (enable) {
524
+ const container = document.querySelector(`#diff-root${id}`);
525
+ const wrapper = container === null || container === void 0 ? void 0 : container.querySelector(selector);
526
+ if (!wrapper)
527
+ return;
528
+ const typedWrapper = wrapper;
529
+ const cb = () => {
530
+ var _a;
531
+ const rect = wrapper === null || wrapper === void 0 ? void 0 : wrapper.getBoundingClientRect();
532
+ setWidth((_a = rect === null || rect === void 0 ? void 0 : rect.width) !== null && _a !== void 0 ? _a : 0);
533
+ };
534
+ cb();
535
+ const cleanCb = () => {
536
+ var _a;
537
+ typedWrapper.__observeCallback.delete(cb);
538
+ if (typedWrapper.__observeCallback.size === 0) {
539
+ (_a = typedWrapper.__observeInstance) === null || _a === void 0 ? void 0 : _a.disconnect();
540
+ typedWrapper.removeAttribute("data-observe");
541
+ delete typedWrapper.__observeCallback;
542
+ delete typedWrapper.__observeInstance;
543
+ }
544
+ };
545
+ if (typedWrapper.__observeCallback) {
546
+ typedWrapper.__observeCallback.add(cb);
547
+ return () => cleanCb();
548
+ }
549
+ typedWrapper.__observeCallback = new Set();
550
+ typedWrapper.__observeCallback.add(cb);
551
+ const observer = new ResizeObserver(() => typedWrapper.__observeCallback.forEach((cb) => cb()));
552
+ typedWrapper.__observeInstance = observer;
553
+ observer.observe(typedWrapper);
554
+ typedWrapper.setAttribute("data-observe", "height");
555
+ return () => cleanCb();
556
+ }
557
+ }, [selector, enable, id]);
558
+ return width;
559
+ };
560
+
561
+ exports.DiffModeEnum = void 0;
562
+ (function (DiffModeEnum) {
563
+ // github like
564
+ DiffModeEnum[DiffModeEnum["SplitGitHub"] = 1] = "SplitGitHub";
565
+ // gitlab like
566
+ DiffModeEnum[DiffModeEnum["SplitGitLab"] = 2] = "SplitGitLab";
567
+ DiffModeEnum[DiffModeEnum["Split"] = 3] = "Split";
568
+ DiffModeEnum[DiffModeEnum["Unified"] = 4] = "Unified";
569
+ })(exports.DiffModeEnum || (exports.DiffModeEnum = {}));
570
+ const DiffViewContext = React.createContext(null);
571
+ DiffViewContext.displayName = "DiffViewContext";
572
+ const useDiffViewContext = () => React.useContext(DiffViewContext);
573
+
574
+ // TODO
575
+ const useSyncHeight = ({ selector, wrapper, side, enable, }) => {
576
+ const { useDiffContext } = useDiffViewContext();
577
+ const id = useDiffContext(React.useCallback((s) => s.id, []));
578
+ useSafeLayout(() => {
579
+ if (enable) {
580
+ const container = document.querySelector(`#diff-root${id}`);
581
+ const elements = Array.from((container === null || container === void 0 ? void 0 : container.querySelectorAll(selector)) || []);
582
+ const wrappers = wrapper ? Array.from((container === null || container === void 0 ? void 0 : container.querySelectorAll(wrapper)) || []) : elements;
583
+ if (elements.length === 2 && wrappers.length === 2) {
584
+ const ele1 = elements[0];
585
+ const ele2 = elements[1];
586
+ const wrapper1 = wrappers[0];
587
+ const wrapper2 = wrappers[1];
588
+ const target = ele1.getAttribute("data-side") === side ? ele1 : ele2;
589
+ const cb = () => {
590
+ ele1.style.height = "auto";
591
+ ele2.style.height = "auto";
592
+ const rect1 = ele1.getBoundingClientRect();
593
+ const rect2 = ele2.getBoundingClientRect();
594
+ const maxHeight = Math.max(rect1.height, rect2.height);
595
+ wrapper1.style.height = maxHeight + "px";
596
+ wrapper2.style.height = maxHeight + "px";
597
+ wrapper1.setAttribute("data-sync-height", String(maxHeight));
598
+ wrapper2.setAttribute("data-sync-height", String(maxHeight));
599
+ };
600
+ cb();
601
+ const observer = new ResizeObserver(cb);
602
+ observer.observe(target);
603
+ target.setAttribute("data-observe", "height");
604
+ return () => {
605
+ observer.disconnect();
606
+ target === null || target === void 0 ? void 0 : target.removeAttribute("data-observe");
607
+ };
608
+ }
609
+ }
610
+ }, [selector, enable, side, id, wrapper]);
611
+ };
612
+
613
+ const _DiffSplitExtendLine$1 = ({ index, diffFile, oldLineExtend, newLineExtend, side, lineNumber, }) => {
614
+ const { useDiffContext } = useDiffViewContext();
615
+ const oldLine = diffFile.getSplitLeftLine(index);
616
+ const newLine = diffFile.getSplitRightLine(index);
617
+ const renderExtendLine = useDiffContext.useShallowStableSelector((s) => s.renderExtendLine);
618
+ const currentExtend = side === exports.SplitSide.old ? oldLineExtend : newLineExtend;
619
+ const currentLineNumber = side === exports.SplitSide.old ? oldLine.lineNumber : newLine.lineNumber;
620
+ useSyncHeight({
621
+ selector: `div[data-line="${lineNumber}-extend-content"]`,
622
+ wrapper: `tr[data-line="${lineNumber}-extend"]`,
623
+ side: exports.SplitSide[side],
624
+ enable: !!(currentExtend === null || currentExtend === void 0 ? void 0 : currentExtend.data) && typeof renderExtendLine === "function",
625
+ });
626
+ const width = useDomWidth({
627
+ selector: side === exports.SplitSide.old ? ".old-diff-table-wrapper" : ".new-diff-table-wrapper",
628
+ enable: !!(currentExtend === null || currentExtend === void 0 ? void 0 : currentExtend.data) && typeof renderExtendLine === "function",
629
+ });
630
+ if (!renderExtendLine)
631
+ return null;
632
+ return (React__namespace.createElement("tr", { "data-line": `${lineNumber}-extend`, "data-state": "extend", "data-side": exports.SplitSide[side], className: "diff-line diff-line-extend" }, currentExtend ? (React__namespace.createElement("td", { className: `diff-line-extend-${exports.SplitSide[side]}-content p-0`, colSpan: 2 },
633
+ React__namespace.createElement("div", { "data-line": `${lineNumber}-extend-content`, "data-side": exports.SplitSide[side], className: "diff-line-extend-wrapper sticky left-0", style: { width } }, width > 0 &&
634
+ (currentExtend === null || currentExtend === void 0 ? void 0 : currentExtend.data) &&
635
+ (renderExtendLine === null || renderExtendLine === void 0 ? void 0 : renderExtendLine({
636
+ diffFile,
637
+ side,
638
+ lineNumber: currentLineNumber,
639
+ data: currentExtend.data,
640
+ onUpdate: diffFile.notifyAll,
641
+ }))))) : (React__namespace.createElement("td", { className: `diff-line-extend-${exports.SplitSide[side]}-placeholder select-none p-0`, style: { backgroundColor: `var(${emptyBGName})` }, colSpan: 2 },
642
+ React__namespace.createElement("div", { "data-line": `${lineNumber}-extend-content`, "data-side": exports.SplitSide[side] })))));
643
+ };
644
+ const DiffSplitExtendLine$1 = ({ index, diffFile, side, lineNumber, }) => {
645
+ const { useDiffContext } = useDiffViewContext();
646
+ const oldLine = diffFile.getSplitLeftLine(index);
647
+ const newLine = diffFile.getSplitRightLine(index);
648
+ const { oldLineExtend, newLineExtend } = useDiffContext(React__namespace.useCallback((s) => {
649
+ var _a, _b, _c, _d;
650
+ return ({
651
+ 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],
652
+ 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],
653
+ });
654
+ }, [oldLine === null || oldLine === void 0 ? void 0 : oldLine.lineNumber, newLine === null || newLine === void 0 ? void 0 : newLine.lineNumber]));
655
+ const hasExtend = (oldLineExtend === null || oldLineExtend === void 0 ? void 0 : oldLineExtend.data) || (newLineExtend === null || newLineExtend === void 0 ? void 0 : newLineExtend.data);
656
+ // if the expand action not enabled, the `isHidden` property will never change
657
+ const enableExpand = diffFile.getExpandEnabled();
658
+ const currentLine = side === exports.SplitSide.old ? oldLine : newLine;
659
+ const currentIsShow = hasExtend && (!currentLine.isHidden || !enableExpand);
660
+ if (!currentIsShow)
661
+ return null;
662
+ return (React__namespace.createElement(_DiffSplitExtendLine$1, { side: side, index: index, diffFile: diffFile, lineNumber: lineNumber, oldLineExtend: oldLineExtend, newLineExtend: newLineExtend }));
663
+ };
664
+
665
+ const ExpandDown = ({ className }) => {
666
+ return (React__namespace.createElement("svg", { "aria-hidden": "true", height: "16", viewBox: "0 0 16 16", version: "1.1", width: "16", className: className },
667
+ 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" })));
668
+ };
669
+ const ExpandUp = ({ className }) => {
670
+ return (React__namespace.createElement("svg", { "aria-hidden": "true", height: "16", viewBox: "0 0 16 16", version: "1.1", width: "16", className: className },
671
+ 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" })));
672
+ };
673
+ const ExpandAll = ({ className }) => {
674
+ return (React__namespace.createElement("svg", { "aria-hidden": "true", height: "16", viewBox: "0 0 16 16", version: "1.1", width: "16", className: className },
675
+ 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" })));
676
+ };
677
+
678
+ const _DiffSplitHunkLineGitHub = ({ index, diffFile, side, lineNumber, }) => {
679
+ var _a;
680
+ const currentHunk = diffFile.getSplitHunkLine(index);
681
+ const expandEnabled = diffFile.getExpandEnabled();
682
+ useSyncHeight({
683
+ selector: `tr[data-line="${lineNumber}-hunk"]`,
684
+ side: exports.SplitSide[exports.SplitSide.old],
685
+ enable: side === exports.SplitSide.new,
686
+ });
687
+ const enableHunkAction = side === exports.SplitSide.old;
688
+ const couldExpand = expandEnabled && currentHunk && currentHunk.splitInfo;
689
+ const isExpandAll = currentHunk &&
690
+ currentHunk.splitInfo &&
691
+ currentHunk.splitInfo.endHiddenIndex - currentHunk.splitInfo.startHiddenIndex < core.composeLen;
692
+ const isFirstLine = currentHunk && currentHunk.isFirst;
693
+ const isLastLine = currentHunk && currentHunk.isLast;
694
+ 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,
695
+ React__namespace.createElement("td", { className: "diff-line-hunk-action sticky left-0 w-[1%] min-w-[40px] select-none p-[1px]", style: {
696
+ backgroundColor: `var(${hunkLineNumberBGName})`,
697
+ color: `var(${plainLineNumberColorName})`,
698
+ width: `var(${diffAsideWidthName})`,
699
+ minWidth: `var(${diffAsideWidthName})`,
700
+ maxWidth: `var(${diffAsideWidthName})`,
701
+ } }, 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) },
702
+ 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: () => {
703
+ diffFile.onSplitHunkExpand("down", index);
704
+ } },
705
+ 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) },
706
+ React__namespace.createElement(ExpandAll, { className: "fill-current" }))) : (React__namespace.createElement(React__namespace.Fragment, null,
707
+ 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) },
708
+ React__namespace.createElement(ExpandDown, { className: "fill-current" })),
709
+ 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) },
710
+ React__namespace.createElement(ExpandUp, { className: "fill-current" }))))) : (React__namespace.createElement("div", { className: "min-h-[28px]" }, "\u2002"))),
711
+ React__namespace.createElement("td", { className: "diff-line-hunk-content pr-[10px] align-middle", style: { backgroundColor: `var(${hunkContentBGName})` } },
712
+ React__namespace.createElement("div", { className: "pl-[1.5em]", style: {
713
+ color: `var(${hunkContentColorName})`,
714
+ } }, ((_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})` } },
715
+ React__namespace.createElement("div", { className: "min-h-[28px]" }, "\u2002")))));
716
+ };
717
+ const _DiffSplitHunkLineGitLab = ({ index, diffFile, side, lineNumber, }) => {
718
+ var _a;
719
+ const currentHunk = diffFile.getSplitHunkLine(index);
720
+ const expandEnabled = diffFile.getExpandEnabled();
721
+ useSyncHeight({
722
+ selector: `tr[data-line="${lineNumber}-hunk"]`,
723
+ side: exports.SplitSide[side],
724
+ enable: true,
725
+ });
726
+ const couldExpand = expandEnabled && currentHunk && currentHunk.splitInfo;
727
+ const isExpandAll = currentHunk &&
728
+ currentHunk.splitInfo &&
729
+ currentHunk.splitInfo.endHiddenIndex - currentHunk.splitInfo.startHiddenIndex < core.composeLen;
730
+ const isFirstLine = currentHunk && currentHunk.isFirst;
731
+ const isLastLine = currentHunk && currentHunk.isLast;
732
+ return (React__namespace.createElement("tr", { "data-line": `${lineNumber}-hunk`, "data-state": "hunk", "data-side": exports.SplitSide[side], className: "diff-line diff-line-hunk" },
733
+ React__namespace.createElement("td", { className: "diff-line-hunk-action sticky left-0 w-[1%] min-w-[40px] select-none p-[1px]", style: {
734
+ backgroundColor: `var(${hunkLineNumberBGName})`,
735
+ color: `var(${plainLineNumberColorName})`,
736
+ width: `var(${diffAsideWidthName})`,
737
+ minWidth: `var(${diffAsideWidthName})`,
738
+ maxWidth: `var(${diffAsideWidthName})`,
739
+ } }, 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) },
740
+ 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: () => {
741
+ diffFile.onSplitHunkExpand("down", index);
742
+ } },
743
+ 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) },
744
+ React__namespace.createElement(ExpandAll, { className: "fill-current" }))) : (React__namespace.createElement(React__namespace.Fragment, null,
745
+ 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) },
746
+ React__namespace.createElement(ExpandDown, { className: "fill-current" })),
747
+ 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) },
748
+ React__namespace.createElement(ExpandUp, { className: "fill-current" }))))) : (React__namespace.createElement("div", { className: "min-h-[28px]" }, "\u2002"))),
749
+ React__namespace.createElement("td", { className: "diff-line-hunk-content pr-[10px] align-middle", style: { backgroundColor: `var(${hunkContentBGName})` } },
750
+ React__namespace.createElement("div", { className: "pl-[1.5em]", style: {
751
+ color: `var(${hunkContentColorName})`,
752
+ } }, ((_a = currentHunk.splitInfo) === null || _a === void 0 ? void 0 : _a.plainText) || currentHunk.text))));
753
+ };
754
+ const _DiffSplitHunkLine$1 = ({ index, diffFile, side, lineNumber, }) => {
755
+ const { useDiffContext } = useDiffViewContext();
756
+ const diffViewMode = useDiffContext.useShallowStableSelector((s) => s.mode);
757
+ if (diffViewMode === exports.DiffModeEnum.SplitGitHub ||
758
+ diffViewMode === exports.DiffModeEnum.Split ||
759
+ diffViewMode === exports.DiffModeEnum.Unified) {
760
+ return React__namespace.createElement(_DiffSplitHunkLineGitHub, { index: index, diffFile: diffFile, side: side, lineNumber: lineNumber });
761
+ }
762
+ else {
763
+ return React__namespace.createElement(_DiffSplitHunkLineGitLab, { index: index, diffFile: diffFile, side: side, lineNumber: lineNumber });
764
+ }
765
+ };
766
+ const DiffSplitHunkLine$1 = ({ index, diffFile, side, lineNumber, }) => {
767
+ const currentHunk = diffFile.getSplitHunkLine(index);
768
+ const currentIsShow = currentHunk &&
769
+ currentHunk.splitInfo &&
770
+ currentHunk.splitInfo.startHiddenIndex < currentHunk.splitInfo.endHiddenIndex;
771
+ const currentIsPureHunk = currentHunk && diffFile._getIsPureDiffRender() && !currentHunk.splitInfo;
772
+ if (!currentIsShow && !currentIsPureHunk)
773
+ return null;
774
+ return React__namespace.createElement(_DiffSplitHunkLine$1, { index: index, diffFile: diffFile, side: side, lineNumber: lineNumber });
775
+ };
776
+
774
777
  const _DiffSplitWidgetLine$1 = ({ diffFile, side, lineNumber, currentLine, setWidget, currentWidget, }) => {
775
778
  const { useDiffContext } = useDiffViewContext();
776
- const renderWidgetLine = useDiffContext(React__namespace.useCallback((s) => s.renderWidgetLine, []));
779
+ const renderWidgetLine = useDiffContext.useShallowStableSelector((s) => s.renderWidgetLine);
777
780
  useSyncHeight({
778
- selector: `tr[data-line="${lineNumber}-widget"]`,
781
+ selector: `div[data-line="${lineNumber}-widget-content"]`,
782
+ wrapper: `tr[data-line="${lineNumber}-widget"]`,
779
783
  side: exports.SplitSide[side],
780
784
  enable: currentWidget && typeof renderWidgetLine === "function",
781
785
  });
@@ -786,18 +790,22 @@ const _DiffSplitWidgetLine$1 = ({ diffFile, side, lineNumber, currentLine, setWi
786
790
  if (!renderWidgetLine)
787
791
  return null;
788
792
  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 &&
793
+ React__namespace.createElement("div", { "data-line": `${lineNumber}-widget-content`, "data-side": exports.SplitSide[side], className: "diff-line-widget-wrapper sticky left-0", style: { width } }, width > 0 &&
790
794
  (renderWidgetLine === null || renderWidgetLine === void 0 ? void 0 : renderWidgetLine({
791
795
  diffFile,
792
796
  side,
793
797
  lineNumber: currentLine.lineNumber,
794
798
  onClose: () => setWidget({}),
795
799
  }))))) : (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")))));
800
+ React__namespace.createElement("div", { "data-line": `${lineNumber}-widget-content`, "data-side": exports.SplitSide[side] })))));
797
801
  };
798
802
  const DiffSplitWidgetLine$1 = ({ index, diffFile, side, lineNumber, }) => {
799
803
  const { useWidget } = useDiffWidgetContext();
800
- const { widgetLineNumber, widgetSide, setWidget } = useWidget(React__namespace.useCallback((s) => ({ widgetLineNumber: s.widgetLineNumber, widgetSide: s.widgetSide, setWidget: s.setWidget }), []));
804
+ const { widgetLineNumber, widgetSide, setWidget } = useWidget.useShallowStableSelector((s) => ({
805
+ widgetLineNumber: s.widgetLineNumber,
806
+ widgetSide: s.widgetSide,
807
+ setWidget: s.setWidget,
808
+ }));
801
809
  const oldLine = diffFile.getSplitLeftLine(index);
802
810
  const newLine = diffFile.getSplitRightLine(index);
803
811
  const oldLineWidget = oldLine.lineNumber && widgetSide === exports.SplitSide.old && widgetLineNumber === oldLine.lineNumber;
@@ -822,7 +830,7 @@ const onMouseDown$1 = (e) => {
822
830
  const DiffSplitViewTable = ({ side, diffFile }) => {
823
831
  const className = side === exports.SplitSide.new ? "new-diff-table" : "old-diff-table";
824
832
  const lines = core.getSplitContentLines(diffFile);
825
- return (React__namespace.createElement("table", { className: className + " w-full border-collapse", "data-mode": exports.SplitSide[side] },
833
+ return (React__namespace.createElement("table", { className: className + " w-full border-collapse border-spacing-0", "data-mode": exports.SplitSide[side] },
826
834
  React__namespace.createElement("colgroup", null,
827
835
  React__namespace.createElement("col", { className: `diff-table-${exports.SplitSide[side]}-num-col` }),
828
836
  React__namespace.createElement("col", { className: `diff-table-${exports.SplitSide[side]}-content-col` })),
@@ -837,7 +845,7 @@ const DiffSplitViewTable = ({ side, diffFile }) => {
837
845
  React__namespace.createElement("tbody", { className: "diff-table-body leading-[1.4]", onMouseDownCapture: onMouseDown$1 },
838
846
  lines.map((line) => (React__namespace.createElement(React.Fragment, { key: line.index },
839
847
  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 }),
848
+ React__namespace.createElement(DiffSplitContentLine$1, { index: line.index, side: side, lineNumber: line.lineNumber, diffFile: diffFile }),
841
849
  React__namespace.createElement(DiffSplitWidgetLine$1, { index: line.index, side: side, lineNumber: line.lineNumber, diffFile: diffFile }),
842
850
  React__namespace.createElement(DiffSplitExtendLine$1, { index: line.index, side: side, lineNumber: line.lineNumber, diffFile: diffFile })))),
843
851
  React__namespace.createElement(DiffSplitHunkLine$1, { side: side, index: diffFile.splitLineLength, lineNumber: diffFile.splitLineLength, diffFile: diffFile }))));
@@ -847,7 +855,7 @@ const DiffSplitViewNormal = React.memo(({ diffFile }) => {
847
855
  const ref2 = React.useRef(null);
848
856
  const splitLineLength = Math.max(diffFile.splitLineLength, diffFile.fileLineLength);
849
857
  const { useDiffContext } = useDiffViewContext();
850
- const fontSize = useDiffContext(React.useCallback((s) => s.fontSize, []));
858
+ const fontSize = useDiffContext.useShallowStableSelector((s) => s.fontSize);
851
859
  index_js.useSyncExternalStore(diffFile.subscribe, diffFile.getUpdateCount);
852
860
  React.useEffect(() => {
853
861
  const left = ref1.current;
@@ -862,8 +870,8 @@ const DiffSplitViewNormal = React.memo(({ diffFile }) => {
862
870
  font,
863
871
  });
864
872
  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: {
873
+ return (React__namespace.createElement("div", { className: "split-diff-view split-diff-view-normal flex w-full basis-[50%]" },
874
+ 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
875
  // @ts-ignore
868
876
  [diffAsideWidthName]: `${Math.round(width)}px`,
869
877
  overscrollBehaviorX: "none",
@@ -871,8 +879,8 @@ const DiffSplitViewNormal = React.memo(({ diffFile }) => {
871
879
  fontSize: `var(${diffFontSizeName})`,
872
880
  } },
873
881
  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: {
882
+ React__namespace.createElement("div", { className: "diff-split-line w-[1.5px]", style: { backgroundColor: `var(${borderColorName})` } }),
883
+ 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
884
  // @ts-ignore
877
885
  [diffAsideWidthName]: `${Math.round(width)}px`,
878
886
  overscrollBehaviorX: "none",
@@ -883,12 +891,66 @@ const DiffSplitViewNormal = React.memo(({ diffFile }) => {
883
891
  });
884
892
  DiffSplitViewNormal.displayName = "DiffSplitViewNormal";
885
893
 
894
+ const _DiffSplitLine = ({ index, diffFile, lineNumber }) => {
895
+ var _a, _b;
896
+ const oldLine = diffFile.getSplitLeftLine(index);
897
+ const newLine = diffFile.getSplitRightLine(index);
898
+ const oldSyntaxLine = diffFile.getOldSyntaxLine(oldLine === null || oldLine === void 0 ? void 0 : oldLine.lineNumber);
899
+ const newSyntaxLine = diffFile.getNewSyntaxLine(newLine === null || newLine === void 0 ? void 0 : newLine.lineNumber);
900
+ const hasDiff = !!(oldLine === null || oldLine === void 0 ? void 0 : oldLine.diff) || !!(newLine === null || newLine === void 0 ? void 0 : newLine.diff);
901
+ const hasChange = core.checkDiffLineIncludeChange(oldLine === null || oldLine === void 0 ? void 0 : oldLine.diff) || core.checkDiffLineIncludeChange(newLine === null || newLine === void 0 ? void 0 : newLine.diff);
902
+ const oldLineIsDelete = ((_a = oldLine === null || oldLine === void 0 ? void 0 : oldLine.diff) === null || _a === void 0 ? void 0 : _a.type) === core.DiffLineType.Delete;
903
+ const newLineIsAdded = ((_b = newLine === null || newLine === void 0 ? void 0 : newLine.diff) === null || _b === void 0 ? void 0 : _b.type) === core.DiffLineType.Add;
904
+ const { useDiffContext } = useDiffViewContext();
905
+ const { enableHighlight, enableAddWidget, onAddWidgetClick } = useDiffContext.useShallowStableSelector((s) => ({
906
+ enableHighlight: s.enableHighlight,
907
+ enableAddWidget: s.enableAddWidget,
908
+ onAddWidgetClick: s.onAddWidgetClick,
909
+ }));
910
+ const { useWidget } = useDiffWidgetContext();
911
+ const setWidget = useWidget.getReadonlyState().setWidget;
912
+ const hasOldLine = !!oldLine.lineNumber;
913
+ const hasNewLine = !!newLine.lineNumber;
914
+ const oldLineContentBG = getContentBG(false, oldLineIsDelete, hasDiff);
915
+ const oldLineNumberBG = getLineNumberBG(false, oldLineIsDelete, hasDiff);
916
+ const newLineContentBG = getContentBG(newLineIsAdded, false, hasDiff);
917
+ const newLineNumberBG = getLineNumberBG(newLineIsAdded, false, hasDiff);
918
+ return (React__namespace.createElement("tr", { "data-line": lineNumber, "data-state": hasDiff ? "diff" : "plain", className: "diff-line" },
919
+ hasOldLine ? (React__namespace.createElement(React__namespace.Fragment, null,
920
+ 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})` } },
921
+ 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 }) })),
922
+ React__namespace.createElement("span", { "data-line-num": oldLine.lineNumber, style: { opacity: hasChange ? undefined : 0.5 } }, oldLine.lineNumber)),
923
+ 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 } },
924
+ 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 }) })),
925
+ 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 },
926
+ React__namespace.createElement("span", null, "\u2002"))),
927
+ hasNewLine ? (React__namespace.createElement(React__namespace.Fragment, null,
928
+ 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: {
929
+ backgroundColor: newLineNumberBG,
930
+ color: `var(${plainLineNumberColorName})`,
931
+ borderLeftColor: `var(${borderColorName})`,
932
+ } },
933
+ 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 }) })),
934
+ React__namespace.createElement("span", { "data-line-num": newLine.lineNumber, style: { opacity: hasChange ? undefined : 0.5 } }, newLine.lineNumber)),
935
+ 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 } },
936
+ 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 }) })),
937
+ 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 },
938
+ React__namespace.createElement("span", null, "\u2002")))));
939
+ };
940
+ const DiffSplitContentLine = ({ index, diffFile, lineNumber, }) => {
941
+ const oldLine = diffFile.getSplitLeftLine(index);
942
+ const newLine = diffFile.getSplitRightLine(index);
943
+ if ((oldLine === null || oldLine === void 0 ? void 0 : oldLine.isHidden) && (newLine === null || newLine === void 0 ? void 0 : newLine.isHidden))
944
+ return null;
945
+ return React__namespace.createElement(_DiffSplitLine, { index: index, diffFile: diffFile, lineNumber: lineNumber });
946
+ };
947
+
886
948
  const _DiffSplitExtendLine = ({ index, diffFile, lineNumber, oldLineExtend, newLineExtend, }) => {
887
949
  const { useDiffContext } = useDiffViewContext();
888
950
  const oldLine = diffFile.getSplitLeftLine(index);
889
951
  const newLine = diffFile.getSplitRightLine(index);
890
952
  // 需要显示的时候才进行方法订阅,可以大幅度提高性能
891
- const renderExtendLine = useDiffContext(React__namespace.useCallback((s) => s.renderExtendLine, []));
953
+ const renderExtendLine = useDiffContext.useShallowStableSelector((s) => s.renderExtendLine);
892
954
  if (!renderExtendLine)
893
955
  return null;
894
956
  return (React__namespace.createElement("tr", { "data-line": `${lineNumber}-extend`, "data-state": "extend", className: "diff-line diff-line-extend" },
@@ -902,7 +964,7 @@ const _DiffSplitExtendLine = ({ index, diffFile, lineNumber, oldLineExtend, newL
902
964
  onUpdate: diffFile.notifyAll,
903
965
  }))))) : (React__namespace.createElement("td", { className: "diff-line-extend-old-placeholder select-none p-0", style: { backgroundColor: `var(${emptyBGName})` }, colSpan: 2 },
904
966
  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 },
967
+ newLineExtend ? (React__namespace.createElement("td", { className: "diff-line-extend-new-content border-l-[1px] p-0", style: { borderLeftColor: `var(${borderColorName})` }, colSpan: 2 },
906
968
  React__namespace.createElement("div", { className: "diff-line-extend-wrapper" }, (newLineExtend === null || newLineExtend === void 0 ? void 0 : newLineExtend.data) &&
907
969
  (renderExtendLine === null || renderExtendLine === void 0 ? void 0 : renderExtendLine({
908
970
  diffFile,
@@ -910,7 +972,7 @@ const _DiffSplitExtendLine = ({ index, diffFile, lineNumber, oldLineExtend, newL
910
972
  lineNumber: newLine.lineNumber,
911
973
  data: newLineExtend.data,
912
974
  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 },
975
+ }))))) : (React__namespace.createElement("td", { className: "diff-line-extend-new-placeholder select-none border-l-[1px] p-0", style: { backgroundColor: `var(${emptyBGName})`, borderLeftColor: `var(${borderColorName})` }, colSpan: 2 },
914
976
  React__namespace.createElement("span", null, "\u2002")))));
915
977
  };
916
978
  const DiffSplitExtendLine = ({ index, diffFile, lineNumber, }) => {
@@ -941,25 +1003,19 @@ const DiffSplitHunkLineGitHub = ({ index, diffFile, lineNumber, }) => {
941
1003
  const isExpandAll = currentHunk &&
942
1004
  currentHunk.splitInfo &&
943
1005
  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
1006
  const isFirstLine = currentHunk && currentHunk.isFirst;
949
1007
  const isLastLine = currentHunk && currentHunk.isLast;
950
- if (!currentIsShow && !currentIsPureHunk)
951
- return null;
952
1008
  return (React__namespace.createElement("tr", { "data-line": `${lineNumber}-hunk`, "data-state": "hunk", className: "diff-line diff-line-hunk" },
953
1009
  React__namespace.createElement("td", { className: "diff-line-hunk-action relative w-[1%] min-w-[40px] select-none p-[1px]", style: {
954
1010
  backgroundColor: `var(${hunkLineNumberBGName})`,
955
1011
  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) },
1012
+ } }, 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) },
1013
+ 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) },
1014
+ 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
1015
  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) },
1016
+ 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
1017
  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) },
1018
+ 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
1019
  React__namespace.createElement(ExpandUp, { className: "fill-current" }))))) : (React__namespace.createElement("div", { className: "min-h-[28px]" }, "\u2002"))),
964
1020
  React__namespace.createElement("td", { className: "diff-line-hunk-content pr-[10px] align-middle", style: { backgroundColor: `var(${hunkContentBGName})` }, colSpan: 3 },
965
1021
  React__namespace.createElement("div", { className: "pl-[1.5em]", style: {
@@ -974,49 +1030,44 @@ const DiffSplitHunkLineGitLab = ({ index, diffFile, lineNumber, }) => {
974
1030
  const isExpandAll = currentHunk &&
975
1031
  currentHunk.splitInfo &&
976
1032
  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
1033
  const isFirstLine = currentHunk && currentHunk.isFirst;
982
1034
  const isLastLine = currentHunk && currentHunk.isLast;
983
- if (!currentIsShow && !currentIsPureHunk)
984
- return null;
985
1035
  return (React__namespace.createElement("tr", { "data-line": `${lineNumber}-hunk`, "data-state": "hunk", className: "diff-line diff-line-hunk" },
986
1036
  React__namespace.createElement("td", { className: "diff-line-hunk-action relative w-[1%] min-w-[40px] select-none p-[1px]", style: {
987
1037
  backgroundColor: `var(${hunkLineNumberBGName})`,
988
1038
  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) },
1039
+ } }, 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) },
1040
+ 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) },
1041
+ 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
1042
  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) },
1043
+ 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
1044
  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) },
1045
+ 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
1046
  React__namespace.createElement(ExpandUp, { className: "fill-current" }))))) : (React__namespace.createElement("div", { className: "min-h-[28px]" }, "\u2002"))),
997
1047
  React__namespace.createElement("td", { className: "diff-line-hunk-content pr-[10px] align-middle", style: { backgroundColor: `var(${hunkContentBGName})` } },
998
1048
  React__namespace.createElement("div", { className: "pl-[1.5em]", style: {
999
1049
  color: `var(${hunkContentColorName})`,
1000
1050
  } }, ((_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: {
1051
+ React__namespace.createElement("td", { className: "diff-line-hunk-action relative w-[1%] min-w-[40px] select-none border-l-[1px] p-[1px]", style: {
1002
1052
  backgroundColor: `var(${hunkLineNumberBGName})`,
1003
1053
  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) },
1054
+ borderLeftColor: `var(${borderColorName})`,
1055
+ } }, 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) },
1056
+ 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) },
1057
+ 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
1058
  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) },
1059
+ 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
1060
  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) },
1061
+ 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
1062
  React__namespace.createElement(ExpandUp, { className: "fill-current" }))))) : (React__namespace.createElement("div", { className: "min-h-[28px]" }, "\u2002"))),
1012
1063
  React__namespace.createElement("td", { className: "diff-line-hunk-content pr-[10px] align-middle", style: { backgroundColor: `var(${hunkContentBGName})` } },
1013
1064
  React__namespace.createElement("div", { className: "pl-[1.5em]", style: {
1014
1065
  color: `var(${hunkContentColorName})`,
1015
1066
  } }, ((_b = currentHunk.splitInfo) === null || _b === void 0 ? void 0 : _b.plainText) || currentHunk.text))));
1016
1067
  };
1017
- const DiffSplitHunkLine = ({ index, diffFile, lineNumber, }) => {
1068
+ const _DiffSplitHunkLine = ({ index, diffFile, lineNumber, }) => {
1018
1069
  const { useDiffContext } = useDiffViewContext();
1019
- const diffViewMode = useDiffContext(React__namespace.useCallback((s) => s.mode, []));
1070
+ const diffViewMode = useDiffContext.useShallowStableSelector((s) => s.mode);
1020
1071
  if (diffViewMode === exports.DiffModeEnum.SplitGitHub ||
1021
1072
  diffViewMode === exports.DiffModeEnum.Split ||
1022
1073
  diffViewMode === exports.DiffModeEnum.Unified) {
@@ -1026,62 +1077,22 @@ const DiffSplitHunkLine = ({ index, diffFile, lineNumber, }) => {
1026
1077
  return React__namespace.createElement(DiffSplitHunkLineGitLab, { index: index, diffFile: diffFile, lineNumber: lineNumber });
1027
1078
  }
1028
1079
  };
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))
1080
+ const DiffSplitHunkLine = ({ index, diffFile, lineNumber, }) => {
1081
+ const currentHunk = diffFile.getSplitHunkLine(index);
1082
+ const currentIsShow = currentHunk &&
1083
+ currentHunk.splitInfo &&
1084
+ currentHunk.splitInfo.startHiddenIndex < currentHunk.splitInfo.endHiddenIndex;
1085
+ const currentIsPureHunk = currentHunk && diffFile._getIsPureDiffRender() && !currentHunk.splitInfo;
1086
+ if (!currentIsShow && !currentIsPureHunk)
1076
1087
  return null;
1077
- return React__namespace.createElement(_DiffSplitLine, { index: index, diffFile: diffFile, lineNumber: lineNumber });
1088
+ return React__namespace.createElement(_DiffSplitHunkLine, { index: index, diffFile: diffFile, lineNumber: lineNumber });
1078
1089
  };
1079
1090
 
1080
1091
  const _DiffSplitWidgetLine = ({ index, diffFile, lineNumber, oldLineWidget, newLineWidget, }) => {
1081
1092
  const { useWidget } = useDiffWidgetContext();
1082
1093
  const setWidget = useWidget.getReadonlyState().setWidget;
1083
1094
  const { useDiffContext } = useDiffViewContext();
1084
- const renderWidgetLine = useDiffContext(React__namespace.useCallback((s) => s.renderWidgetLine, []));
1095
+ const renderWidgetLine = useDiffContext.useShallowStableSelector((s) => s.renderWidgetLine);
1085
1096
  const oldLine = diffFile.getSplitLeftLine(index);
1086
1097
  const newLine = diffFile.getSplitRightLine(index);
1087
1098
  if (!renderWidgetLine)
@@ -1095,18 +1106,21 @@ const _DiffSplitWidgetLine = ({ index, diffFile, lineNumber, oldLineWidget, newL
1095
1106
  onClose: () => setWidget({}),
1096
1107
  })))) : (React__namespace.createElement("td", { className: "diff-line-widget-old-placeholder select-none p-0", style: { backgroundColor: `var(${emptyBGName})` }, colSpan: 2 },
1097
1108
  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 },
1109
+ newLineWidget ? (React__namespace.createElement("td", { className: "diff-line-widget-new-content border-l-[1px] p-0", colSpan: 2, style: { borderLeftColor: `var(${borderColorName})` } },
1099
1110
  React__namespace.createElement("div", { className: "diff-line-widget-wrapper" }, renderWidgetLine === null || renderWidgetLine === void 0 ? void 0 : renderWidgetLine({
1100
1111
  diffFile,
1101
1112
  side: exports.SplitSide.new,
1102
1113
  lineNumber: newLine.lineNumber,
1103
1114
  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 },
1115
+ })))) : (React__namespace.createElement("td", { className: "diff-line-widget-new-placeholder select-none border-l-[1px] p-0", style: { backgroundColor: `var(${emptyBGName})`, borderLeftColor: `var(${borderColorName})` }, colSpan: 2 },
1105
1116
  React__namespace.createElement("span", null, "\u2002")))));
1106
1117
  };
1107
1118
  const DiffSplitWidgetLine = ({ index, diffFile, lineNumber, }) => {
1108
1119
  const { useWidget } = useDiffWidgetContext();
1109
- const { widgetLineNumber, widgetSide } = useWidget(React__namespace.useCallback((s) => ({ widgetLineNumber: s.widgetLineNumber, widgetSide: s.widgetSide }), []));
1120
+ const { widgetLineNumber, widgetSide } = useWidget((s) => ({
1121
+ widgetLineNumber: s.widgetLineNumber,
1122
+ widgetSide: s.widgetSide,
1123
+ }));
1110
1124
  const oldLine = diffFile.getSplitLeftLine(index);
1111
1125
  const newLine = diffFile.getSplitRightLine(index);
1112
1126
  const oldLineWidget = oldLine.lineNumber && widgetSide === exports.SplitSide.old && widgetLineNumber === oldLine.lineNumber;
@@ -1130,7 +1144,7 @@ const DiffSplitViewWrap = React.memo(({ diffFile }) => {
1130
1144
  const splitLineLength = Math.max(diffFile.splitLineLength, diffFile.fileLineLength);
1131
1145
  const { useDiffContext } = useDiffViewContext();
1132
1146
  const useSplitConfig = React.useMemo(() => createDiffSplitConfigStore(), []);
1133
- const fontSize = useDiffContext(React.useCallback((s) => s.fontSize, []));
1147
+ const fontSize = useDiffContext.useShallowStableSelector((s) => s.fontSize);
1134
1148
  index_js.useSyncExternalStore(diffFile.subscribe, diffFile.getUpdateCount);
1135
1149
  const onMouseDown = React.useCallback((e) => {
1136
1150
  let ele = e.target;
@@ -1159,7 +1173,7 @@ const DiffSplitViewWrap = React.memo(({ diffFile }) => {
1159
1173
  });
1160
1174
  const width = Math.max(40, _width + 25);
1161
1175
  const lines = core.getSplitContentLines(diffFile);
1162
- return (React__namespace.createElement("div", { className: "split-diff-view split-diff-view-normal w-full" },
1176
+ return (React__namespace.createElement("div", { className: "split-diff-view split-diff-view-wrap w-full" },
1163
1177
  React__namespace.createElement("div", { className: "diff-table-wrapper w-full", style: {
1164
1178
  // @ts-ignore
1165
1179
  [diffAsideWidthName]: `${Math.round(width)}px`,
@@ -1167,7 +1181,7 @@ const DiffSplitViewWrap = React.memo(({ diffFile }) => {
1167
1181
  fontSize: `var(${diffFontSizeName})`,
1168
1182
  } },
1169
1183
  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" },
1184
+ React__namespace.createElement("table", { className: "diff-table w-full table-fixed border-collapse border-spacing-0" },
1171
1185
  React__namespace.createElement("colgroup", null,
1172
1186
  React__namespace.createElement("col", { className: "diff-table-old-num-col", width: Math.round(width) }),
1173
1187
  React__namespace.createElement("col", { className: "diff-table-old-content-col" }),
@@ -1182,7 +1196,7 @@ const DiffSplitViewWrap = React.memo(({ diffFile }) => {
1182
1196
  React__namespace.createElement("tbody", { className: "diff-table-body leading-[1.4]", onMouseDownCapture: onMouseDown },
1183
1197
  lines.map((line) => (React__namespace.createElement(React.Fragment, { key: line.index },
1184
1198
  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 }),
1199
+ React__namespace.createElement(DiffSplitContentLine, { index: line.index, lineNumber: line.lineNumber, diffFile: diffFile }),
1186
1200
  React__namespace.createElement(DiffSplitWidgetLine, { index: line.index, lineNumber: line.lineNumber, diffFile: diffFile }),
1187
1201
  React__namespace.createElement(DiffSplitExtendLine, { index: line.index, lineNumber: line.lineNumber, diffFile: diffFile })))),
1188
1202
  React__namespace.createElement(DiffSplitHunkLine, { index: diffFile.splitLineLength, lineNumber: diffFile.splitLineLength, diffFile: diffFile }))))));
@@ -1193,7 +1207,7 @@ const DiffSplitView = React.memo(({ diffFile }) => {
1193
1207
  const { useDiffContext } = useDiffViewContext();
1194
1208
  const useDiffContextRef = React.useRef(useDiffContext);
1195
1209
  useDiffContextRef.current = useDiffContext;
1196
- const enableWrap = useDiffContext(React.useCallback((s) => s.enableWrap, []));
1210
+ const enableWrap = useDiffContext.useShallowStableSelector((s) => s.enableWrap);
1197
1211
  // performance optimization
1198
1212
  const useWidget = React.useMemo(() => createDiffWidgetStore(useDiffContextRef), []);
1199
1213
  const contextValue = React.useMemo(() => ({ useWidget }), [useWidget]);
@@ -1205,9 +1219,101 @@ const DiffSplitView = React.memo(({ diffFile }) => {
1205
1219
  });
1206
1220
  DiffSplitView.displayName = "DiffSplitView";
1207
1221
 
1222
+ const DiffUnifiedOldLine = ({ index, diffLine, rawLine, syntaxLine, lineNumber, diffFile, setWidget, enableWrap, enableAddWidget, enableHighlight, onAddWidgetClick, }) => {
1223
+ return (React__namespace.createElement("tr", { "data-line": index, "data-state": "diff", className: "diff-line group" },
1224
+ 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: {
1225
+ color: `var(${plainLineNumberColorName})`,
1226
+ backgroundColor: `var(${delLineNumberBGName})`,
1227
+ width: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
1228
+ maxWidth: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
1229
+ minWidth: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
1230
+ } },
1231
+ enableAddWidget && (React__namespace.createElement(DiffUnifiedAddWidget, { index: index - 1, lineNumber: lineNumber, diffFile: diffFile, side: exports.SplitSide.old, onWidgetClick: onAddWidgetClick, onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber, side }) })),
1232
+ React__namespace.createElement("div", { className: "flex" },
1233
+ React__namespace.createElement("span", { "data-line-old-num": lineNumber, className: "inline-block w-[50%]" }, lineNumber),
1234
+ React__namespace.createElement("span", { className: "w-[10px] shrink-0" }),
1235
+ React__namespace.createElement("span", { className: "inline-block w-[50%]" }))),
1236
+ React__namespace.createElement("td", { className: "diff-line-content pr-[10px] align-top", style: { backgroundColor: `var(${delContentBGName})` } },
1237
+ React__namespace.createElement(DiffContent, { enableWrap: enableWrap, diffFile: diffFile, enableHighlight: enableHighlight, rawLine: rawLine, diffLine: diffLine, syntaxLine: syntaxLine }))));
1238
+ };
1239
+ const DiffUnifiedNewLine = ({ index, diffLine, rawLine, syntaxLine, lineNumber, diffFile, setWidget, enableWrap, enableAddWidget, enableHighlight, onAddWidgetClick, }) => {
1240
+ return (React__namespace.createElement("tr", { "data-line": index, "data-state": "diff", className: "diff-line group" },
1241
+ 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: {
1242
+ color: `var(${plainLineNumberColorName})`,
1243
+ backgroundColor: `var(${addLineNumberBGName})`,
1244
+ width: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
1245
+ maxWidth: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
1246
+ minWidth: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
1247
+ } },
1248
+ enableAddWidget && (React__namespace.createElement(DiffUnifiedAddWidget, { index: index - 1, lineNumber: lineNumber, diffFile: diffFile, side: exports.SplitSide.new, onWidgetClick: onAddWidgetClick, onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber, side }) })),
1249
+ React__namespace.createElement("div", { className: "flex" },
1250
+ React__namespace.createElement("span", { className: "inline-block w-[50%]" }),
1251
+ React__namespace.createElement("span", { className: "w-[10px] shrink-0" }),
1252
+ React__namespace.createElement("span", { "data-line-new-num": lineNumber, className: "inline-block w-[50%]" }, lineNumber))),
1253
+ React__namespace.createElement("td", { className: "diff-line-content pr-[10px] align-top", style: { backgroundColor: `var(${addContentBGName})` } },
1254
+ React__namespace.createElement(DiffContent, { enableWrap: enableWrap, diffFile: diffFile, enableHighlight: enableHighlight, rawLine: rawLine, diffLine: diffLine, syntaxLine: syntaxLine }))));
1255
+ };
1256
+ const _DiffUnifiedLine = React.memo(({ index, diffFile, lineNumber }) => {
1257
+ const unifiedLine = diffFile.getUnifiedLine(index);
1258
+ const { useDiffContext } = useDiffViewContext();
1259
+ const { enableWrap, enableHighlight, enableAddWidget, onAddWidgetClick } = useDiffContext.useShallowStableSelector((s) => ({
1260
+ enableWrap: s.enableWrap,
1261
+ enableHighlight: s.enableHighlight,
1262
+ enableAddWidget: s.enableAddWidget,
1263
+ onAddWidgetClick: s.onAddWidgetClick,
1264
+ }));
1265
+ const { useWidget } = useDiffWidgetContext();
1266
+ const setWidget = useWidget.getReadonlyState().setWidget;
1267
+ const hasDiff = unifiedLine.diff;
1268
+ const hasChange = core.checkDiffLineIncludeChange(unifiedLine.diff);
1269
+ const rawLine = unifiedLine.value || "";
1270
+ const diffLine = unifiedLine.diff;
1271
+ const newLineNumber = unifiedLine.newLineNumber;
1272
+ const oldLinenumber = unifiedLine.oldLineNumber;
1273
+ const syntaxLine = newLineNumber
1274
+ ? diffFile.getNewSyntaxLine(newLineNumber)
1275
+ : oldLinenumber
1276
+ ? diffFile.getOldSyntaxLine(oldLinenumber)
1277
+ : undefined;
1278
+ if (hasChange) {
1279
+ if (unifiedLine.oldLineNumber) {
1280
+ 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); } }));
1281
+ }
1282
+ else {
1283
+ 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); } }));
1284
+ }
1285
+ }
1286
+ else {
1287
+ return (React__namespace.createElement("tr", { "data-line": lineNumber, "data-state": unifiedLine.diff ? "diff" : "plain", className: "diff-line group" },
1288
+ 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: {
1289
+ color: `var(${plainLineNumberColorName})`,
1290
+ width: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
1291
+ maxWidth: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
1292
+ minWidth: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
1293
+ backgroundColor: hasDiff ? `var(${plainLineNumberBGName})` : `var(${expandContentBGName})`,
1294
+ } },
1295
+ 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 }) })),
1296
+ React__namespace.createElement("div", { className: "flex opacity-[0.5]" },
1297
+ React__namespace.createElement("span", { "data-line-old-num": unifiedLine.oldLineNumber, className: "inline-block w-[50%]" }, unifiedLine.oldLineNumber),
1298
+ React__namespace.createElement("span", { className: "w-[10px] shrink-0" }),
1299
+ React__namespace.createElement("span", { "data-line-new-num": unifiedLine.newLineNumber, className: "inline-block w-[50%]" }, unifiedLine.newLineNumber))),
1300
+ React__namespace.createElement("td", { className: "diff-line-content pr-[10px] align-top", style: {
1301
+ backgroundColor: hasDiff ? `var(${plainContentBGName})` : `var(${expandContentBGName})`,
1302
+ } },
1303
+ React__namespace.createElement(DiffContent, { enableWrap: enableWrap, diffFile: diffFile, enableHighlight: enableHighlight, rawLine: rawLine, diffLine: diffLine, syntaxLine: syntaxLine }))));
1304
+ }
1305
+ });
1306
+ _DiffUnifiedLine.displayName = "_DiffUnifiedLine";
1307
+ const DiffUnifiedContentLine = ({ index, diffFile, lineNumber, }) => {
1308
+ const unifiedLine = diffFile.getUnifiedLine(index);
1309
+ if (unifiedLine === null || unifiedLine === void 0 ? void 0 : unifiedLine.isHidden)
1310
+ return null;
1311
+ return React__namespace.createElement(_DiffUnifiedLine, { index: index, diffFile: diffFile, lineNumber: lineNumber });
1312
+ };
1313
+
1208
1314
  const _DiffUnifiedExtendLine = ({ index, diffFile, lineNumber, oldLineExtend, newLineExtend, }) => {
1209
1315
  const { useDiffContext } = useDiffViewContext();
1210
- const renderExtendLine = useDiffContext(React.useCallback((s) => s.renderExtendLine, []));
1316
+ const renderExtendLine = useDiffContext.useShallowStableSelector((s) => s.renderExtendLine);
1211
1317
  const unifiedItem = diffFile.getUnifiedLine(index);
1212
1318
  const width = useDomWidth({
1213
1319
  selector: ".unified-diff-table-wrapper",
@@ -1258,7 +1364,7 @@ const _DiffUnifiedHunkLine = ({ index, diffFile, lineNumber, }) => {
1258
1364
  const currentHunk = diffFile.getUnifiedHunkLine(index);
1259
1365
  const expandEnabled = diffFile.getExpandEnabled();
1260
1366
  const { useDiffContext } = useDiffViewContext();
1261
- const enableWrap = useDiffContext(React.useCallback((s) => s.enableWrap, []));
1367
+ const enableWrap = useDiffContext.useShallowStableSelector((s) => s.enableWrap);
1262
1368
  const couldExpand = expandEnabled && currentHunk && currentHunk.unifiedInfo;
1263
1369
  const isExpandAll = currentHunk &&
1264
1370
  currentHunk.unifiedInfo &&
@@ -1298,104 +1404,12 @@ const DiffUnifiedHunkLine = ({ index, diffFile, lineNumber, }) => {
1298
1404
  return React__namespace.createElement(_DiffUnifiedHunkLine, { index: index, diffFile: diffFile, lineNumber: lineNumber });
1299
1405
  };
1300
1406
 
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
1407
  const _DiffUnifiedWidgetLine = ({ index, diffFile, oldWidget, newWidget, lineNumber, setWidget, }) => {
1394
1408
  const unifiedItem = diffFile.getUnifiedLine(index);
1395
1409
  const onClose = () => setWidget({});
1396
1410
  const { useDiffContext } = useDiffViewContext();
1397
1411
  // 需要显示的时候才进行方法订阅,可以大幅度提高性能
1398
- const renderWidgetLine = useDiffContext(React.useCallback((s) => s.renderWidgetLine, []));
1412
+ const renderWidgetLine = useDiffContext.useShallowStableSelector((s) => s.renderWidgetLine);
1399
1413
  const width = useDomWidth({
1400
1414
  selector: ".unified-diff-table-wrapper",
1401
1415
  enable: typeof renderWidgetLine === "function",
@@ -1414,7 +1428,11 @@ const _DiffUnifiedWidgetLine = ({ index, diffFile, oldWidget, newWidget, lineNum
1414
1428
  };
1415
1429
  const DiffUnifiedWidgetLine = ({ index, diffFile, lineNumber, }) => {
1416
1430
  const { useWidget } = useDiffWidgetContext();
1417
- const { widgetSide, widgetLineNumber, setWidget } = useWidget(React__namespace.useCallback((s) => ({ widgetLineNumber: s.widgetLineNumber, widgetSide: s.widgetSide, setWidget: s.setWidget }), []));
1431
+ const { widgetSide, widgetLineNumber, setWidget } = useWidget.useShallowStableSelector((s) => ({
1432
+ widgetLineNumber: s.widgetLineNumber,
1433
+ widgetSide: s.widgetSide,
1434
+ setWidget: s.setWidget,
1435
+ }));
1418
1436
  const unifiedItem = diffFile.getUnifiedLine(index);
1419
1437
  const oldWidget = unifiedItem.oldLineNumber && widgetSide === exports.SplitSide.old && widgetLineNumber === unifiedItem.oldLineNumber;
1420
1438
  const newWidget = unifiedItem.newLineNumber && widgetSide === exports.SplitSide.new && widgetLineNumber === unifiedItem.newLineNumber;
@@ -1440,7 +1458,10 @@ const DiffUnifiedView = React.memo(({ diffFile }) => {
1440
1458
  // performance optimization
1441
1459
  const useWidget = React.useMemo(() => createDiffWidgetStore(useDiffContextRef), []);
1442
1460
  const contextValue = React.useMemo(() => ({ useWidget }), [useWidget]);
1443
- const fontSize = useDiffContext(React.useCallback((s) => s.fontSize, []));
1461
+ const { fontSize, enableWrap } = useDiffContext.useShallowStableSelector((s) => ({
1462
+ fontSize: s.fontSize,
1463
+ enableWrap: s.enableWrap,
1464
+ }));
1444
1465
  index_js.useSyncExternalStore(diffFile.subscribe, diffFile.getUpdateCount);
1445
1466
  React.useEffect(() => {
1446
1467
  const { setWidget } = useWidget.getReadonlyState();
@@ -1454,14 +1475,14 @@ const DiffUnifiedView = React.memo(({ diffFile }) => {
1454
1475
  const width = Math.max(40, _width + 10);
1455
1476
  const lines = core.getUnifiedContentLine(diffFile);
1456
1477
  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: {
1478
+ React__namespace.createElement("div", { className: `unified-diff-view ${enableWrap ? "unified-diff-view-wrap" : "unified-diff-view-normal"} w-full` },
1479
+ React__namespace.createElement("div", { className: "unified-diff-table-wrapper diff-table-scroll-container w-full overflow-x-auto overflow-y-hidden", style: {
1459
1480
  // @ts-ignore
1460
1481
  [diffAsideWidthName]: `${Math.round(width)}px`,
1461
1482
  fontFamily: "Menlo, Consolas, monospace",
1462
1483
  fontSize: `var(${diffFontSizeName})`,
1463
1484
  } },
1464
- React__namespace.createElement("table", { className: "unified-diff-table w-full border-collapse" },
1485
+ React__namespace.createElement("table", { className: `unified-diff-table w-full border-collapse border-spacing-0 ${enableWrap ? "table-fixed" : ""}` },
1465
1486
  React__namespace.createElement("colgroup", null,
1466
1487
  React__namespace.createElement("col", { className: "unified-diff-table-num-col" }),
1467
1488
  React__namespace.createElement("col", { className: "unified-diff-table-content-col" })),
@@ -1472,7 +1493,7 @@ const DiffUnifiedView = React.memo(({ diffFile }) => {
1472
1493
  React__namespace.createElement("tbody", { className: "diff-table-body leading-[1.4]", onMouseDownCapture: onMouseDown },
1473
1494
  lines.map((item) => (React__namespace.createElement(React.Fragment, { key: item.index },
1474
1495
  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 }),
1496
+ React__namespace.createElement(DiffUnifiedContentLine, { index: item.index, lineNumber: item.lineNumber, diffFile: diffFile }),
1476
1497
  React__namespace.createElement(DiffUnifiedWidgetLine, { index: item.index, lineNumber: item.lineNumber, diffFile: diffFile }),
1477
1498
  React__namespace.createElement(DiffUnifiedExtendLine, { index: item.index, lineNumber: item.lineNumber, diffFile: diffFile })))),
1478
1499
  React__namespace.createElement(DiffUnifiedHunkLine, { index: diffFile.unifiedLineLength, lineNumber: diffFile.unifiedLineLength, diffFile: diffFile })))))));
@@ -1488,6 +1509,7 @@ exports.SplitSide = void 0;
1488
1509
  const _InternalDiffView = (props) => {
1489
1510
  const { diffFile, className, style, diffViewMode, diffViewWrap, diffViewFontSize, diffViewHighlight, renderWidgetLine, renderExtendLine, extendData, diffViewAddWidget, onAddWidgetClick, } = props;
1490
1511
  const diffFileId = React.useMemo(() => diffFile.getId(), [diffFile]);
1512
+ const wrapperRef = React.useRef();
1491
1513
  // performance optimization
1492
1514
  const useDiffContext = React.useMemo(() => createDiffConfigStore(props, diffFileId),
1493
1515
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -1517,9 +1539,16 @@ const _InternalDiffView = (props) => {
1517
1539
  extendData,
1518
1540
  onAddWidgetClick,
1519
1541
  ]);
1542
+ React.useEffect(() => {
1543
+ const cb = diffFile.subscribe(() => {
1544
+ var _a;
1545
+ (_a = wrapperRef.current) === null || _a === void 0 ? void 0 : _a.setAttribute("data-theme", diffFile._getTheme() || "light");
1546
+ });
1547
+ return cb;
1548
+ }, [diffFile]);
1520
1549
  const value = React.useMemo(() => ({ useDiffContext }), [useDiffContext]);
1521
1550
  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() },
1551
+ React__namespace.createElement("div", { className: "diff-tailwindcss-wrapper", "data-component": "git-diff-view", "data-theme": diffFile._getTheme() || "light", "data-version": "0.0.18", "data-highlighter": diffFile._getHighlighterName(), ref: wrapperRef },
1523
1552
  React__namespace.createElement("div", { className: "diff-style-root", style: {
1524
1553
  // @ts-ignore
1525
1554
  [diffFontSizeName]: diffViewFontSize + "px",
@@ -1529,7 +1558,7 @@ const _InternalDiffView = (props) => {
1529
1558
  const InternalDiffView = React.memo(_InternalDiffView);
1530
1559
  const DiffViewWithRef = (props, ref) => {
1531
1560
  var _a, _b;
1532
- const { registerHighlighter, data, diffFile: _diffFile } = props, restProps = __rest(props, ["registerHighlighter", "data", "diffFile"]);
1561
+ const { registerHighlighter, data, diffViewTheme, diffFile: _diffFile } = props, restProps = __rest(props, ["registerHighlighter", "data", "diffViewTheme", "diffFile"]);
1533
1562
  const diffFile = React.useMemo(() => {
1534
1563
  var _a, _b, _c, _d, _e, _f;
1535
1564
  if (_diffFile) {
@@ -1544,16 +1573,17 @@ const DiffViewWithRef = (props, ref) => {
1544
1573
  }, [data, _diffFile]);
1545
1574
  const diffFileRef = React.useRef(diffFile);
1546
1575
  if (diffFileRef.current && diffFileRef.current !== diffFile) {
1547
- (_b = (_a = diffFileRef.current)._destroy) === null || _b === void 0 ? void 0 : _b.call(_a);
1576
+ (_b = (_a = diffFileRef.current).clear) === null || _b === void 0 ? void 0 : _b.call(_a);
1548
1577
  diffFileRef.current = diffFile;
1549
1578
  }
1550
1579
  React.useEffect(() => {
1551
1580
  if (!diffFile)
1552
1581
  return;
1582
+ diffFile.initTheme(diffViewTheme);
1553
1583
  diffFile.initRaw();
1554
1584
  diffFile.buildSplitDiffLines();
1555
1585
  diffFile.buildUnifiedDiffLines();
1556
- }, [diffFile]);
1586
+ }, [diffFile, diffViewTheme]);
1557
1587
  React.useEffect(() => {
1558
1588
  if (!diffFile)
1559
1589
  return;
@@ -1561,7 +1591,7 @@ const DiffViewWithRef = (props, ref) => {
1561
1591
  diffFile.initSyntax({ registerHighlighter });
1562
1592
  diffFile.notifyAll();
1563
1593
  }
1564
- }, [diffFile, props.diffViewHighlight, registerHighlighter]);
1594
+ }, [diffFile, props.diffViewHighlight, registerHighlighter, diffViewTheme]);
1565
1595
  React.useEffect(() => {
1566
1596
  if (_diffFile && diffFile) {
1567
1597
  _diffFile._addClonedInstance(diffFile);
@@ -1570,6 +1600,7 @@ const DiffViewWithRef = (props, ref) => {
1570
1600
  };
1571
1601
  }
1572
1602
  }, [diffFile, _diffFile]);
1603
+ // fix react strict mode error
1573
1604
  useUnmount(() => { var _a; return (_a = diffFile === null || diffFile === void 0 ? void 0 : diffFile._destroy) === null || _a === void 0 ? void 0 : _a.call(diffFile); }, [diffFile]);
1574
1605
  React.useImperativeHandle(ref, () => ({ getDiffFileInstance: () => diffFile }), [diffFile]);
1575
1606
  if (!diffFile)
@@ -1578,7 +1609,7 @@ const DiffViewWithRef = (props, ref) => {
1578
1609
  };
1579
1610
  const DiffView = React.forwardRef(DiffViewWithRef);
1580
1611
  DiffView.displayName = "DiffView";
1581
- const version = "0.0.16";
1612
+ const version = "0.0.18";
1582
1613
 
1583
1614
  exports.DiffView = DiffView;
1584
1615
  exports.DiffViewContext = DiffViewContext;