@git-diff-view/react 0.0.14 → 0.0.15

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.
@@ -2,9 +2,9 @@
2
2
 
3
3
  var core = require('@git-diff-view/core');
4
4
  var React = require('react');
5
- var reactivityStore = require('reactivity-store');
6
5
  var index_js = require('use-sync-external-store/shim/index.js');
7
6
  var reactDom = require('react-dom');
7
+ var reactivityStore = require('reactivity-store');
8
8
 
9
9
  function _interopNamespaceDefault(e) {
10
10
  var n = Object.create(null);
@@ -39,7 +39,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
39
39
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
40
40
  PERFORMANCE OF THIS SOFTWARE.
41
41
  ***************************************************************************** */
42
- /* global Reflect, Promise, SuppressedError, Symbol */
42
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
43
43
 
44
44
 
45
45
  function __rest(s, e) {
@@ -75,6 +75,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
75
75
  const useUnmount = (cb, deps) => {
76
76
  const ref = React.useRef(cb);
77
77
  ref.current = cb;
78
+ // eslint-disable-next-line react-hooks/exhaustive-deps
78
79
  React.useEffect(() => ref.current, deps);
79
80
  };
80
81
 
@@ -189,6 +190,8 @@ const useSyncHeight = ({ selector, side, enable }) => {
189
190
  if (elements.length === 2) {
190
191
  const ele1 = elements[0];
191
192
  const ele2 = elements[1];
193
+ const target = ele1.getAttribute("data-side") === side ? ele1 : ele2;
194
+ const synced = ele1.getAttribute("data-side") !== side ? ele1 : ele2;
192
195
  const cb = () => {
193
196
  ele1.style.height = "auto";
194
197
  ele2.style.height = "auto";
@@ -196,8 +199,7 @@ const useSyncHeight = ({ selector, side, enable }) => {
196
199
  const rect2 = ele2.getBoundingClientRect();
197
200
  if (rect1.height !== rect2.height) {
198
201
  const maxHeight = Math.max(rect1.height, rect2.height);
199
- ele1.style.height = maxHeight + "px";
200
- ele2.style.height = maxHeight + "px";
202
+ synced.style.height = maxHeight + "px";
201
203
  ele1.setAttribute("data-sync-height", String(maxHeight));
202
204
  ele2.setAttribute("data-sync-height", String(maxHeight));
203
205
  }
@@ -208,7 +210,6 @@ const useSyncHeight = ({ selector, side, enable }) => {
208
210
  };
209
211
  cb();
210
212
  const observer = new ResizeObserver(cb);
211
- const target = ele1.getAttribute("data-side") === side ? ele1 : ele2;
212
213
  observer.observe(target);
213
214
  target.setAttribute("data-observe", "height");
214
215
  return () => {
@@ -283,7 +284,7 @@ const _DiffSplitExtendLine$1 = ({ index, diffFile, oldLineExtend, newLineExtend,
283
284
  lineNumber: currentLineNumber,
284
285
  data: currentExtend.data,
285
286
  onUpdate: diffFile.notifyAll,
286
- }))))) : (React__namespace.createElement("td", { className: `diff-line-extend-${exports.SplitSide[side]}-placeholder p-0 select-none`, style: { backgroundColor: `var(${emptyBGName})` }, colSpan: 2 },
287
+ }))))) : (React__namespace.createElement("td", { className: `diff-line-extend-${exports.SplitSide[side]}-placeholder select-none p-0`, style: { backgroundColor: `var(${emptyBGName})` }, colSpan: 2 },
287
288
  React__namespace.createElement("span", null, "\u2002")))));
288
289
  };
289
290
  const DiffSplitExtendLine$1 = ({ index, diffFile, side, lineNumber, }) => {
@@ -362,7 +363,106 @@ const memoFunc = (func) => {
362
363
  return result;
363
364
  });
364
365
  };
365
- const asideWidth = "--diff-aside-width--";
366
+ const createDiffConfigStore = (props, diffFileId) => {
367
+ return reactivityStore.createStore(() => {
368
+ var _a, _b;
369
+ const id = reactivityStore.ref(diffFileId);
370
+ const setId = (_id) => (id.value = _id);
371
+ const mode = reactivityStore.ref(props.diffViewMode);
372
+ const setMode = (_mode) => (mode.value = _mode);
373
+ const enableWrap = reactivityStore.ref(props.diffViewWrap);
374
+ const setEnableWrap = (_enableWrap) => (enableWrap.value = _enableWrap);
375
+ const enableAddWidget = reactivityStore.ref(props.diffViewAddWidget);
376
+ const setEnableAddWidget = (_enableAddWidget) => (enableAddWidget.value = _enableAddWidget);
377
+ const enableHighlight = reactivityStore.ref(props.diffViewHighlight);
378
+ const setEnableHighlight = (_enableHighlight) => (enableHighlight.value = _enableHighlight);
379
+ const fontSize = reactivityStore.ref(props.diffViewFontSize);
380
+ const setFontSize = (_fontSize) => (fontSize.value = _fontSize);
381
+ const extendData = reactivityStore.ref({
382
+ oldFile: Object.assign({}, (_a = props.extendData) === null || _a === void 0 ? void 0 : _a.oldFile),
383
+ newFile: Object.assign({}, (_b = props.extendData) === null || _b === void 0 ? void 0 : _b.newFile),
384
+ });
385
+ const setExtendData = (_extendData) => {
386
+ const existOldKeys = Object.keys(extendData.value.oldFile || {});
387
+ const inComingOldKeys = Object.keys(_extendData.oldFile || {});
388
+ for (const key of existOldKeys) {
389
+ if (!inComingOldKeys.includes(key)) {
390
+ delete extendData.value.oldFile[key];
391
+ }
392
+ }
393
+ for (const key of inComingOldKeys) {
394
+ extendData.value.oldFile[key] = _extendData.oldFile[key];
395
+ }
396
+ const existNewKeys = Object.keys(extendData.value.newFile || {});
397
+ const inComingNewKeys = Object.keys(_extendData.newFile || {});
398
+ for (const key of existNewKeys) {
399
+ if (!inComingNewKeys.includes(key)) {
400
+ delete extendData.value.newFile[key];
401
+ }
402
+ }
403
+ for (const key of inComingNewKeys) {
404
+ extendData.value.newFile[key] = _extendData.newFile[key];
405
+ }
406
+ };
407
+ const renderWidgetLine = reactivityStore.ref(props.renderWidgetLine);
408
+ const setRenderWidgetLine = (_renderWidgetLine) => (renderWidgetLine.value = _renderWidgetLine);
409
+ const renderExtendLine = reactivityStore.ref(props.renderExtendLine);
410
+ const setRenderExtendLine = (_renderExtendLine) => (renderExtendLine.value = _renderExtendLine);
411
+ // 避免无意义的订阅
412
+ const onAddWidgetClick = { current: props.onAddWidgetClick };
413
+ const setOnAddWidgetClick = (_onAddWidgetClick) => (onAddWidgetClick.current = _onAddWidgetClick.current);
414
+ return {
415
+ id,
416
+ setId,
417
+ mode,
418
+ setMode,
419
+ enableWrap,
420
+ setEnableWrap,
421
+ enableAddWidget,
422
+ setEnableAddWidget,
423
+ enableHighlight,
424
+ setEnableHighlight,
425
+ fontSize,
426
+ setFontSize,
427
+ extendData,
428
+ setExtendData,
429
+ renderWidgetLine,
430
+ setRenderWidgetLine,
431
+ renderExtendLine,
432
+ setRenderExtendLine,
433
+ onAddWidgetClick,
434
+ setOnAddWidgetClick,
435
+ };
436
+ });
437
+ };
438
+ const createDiffWidgetStore = (useDiffContextRef) => {
439
+ return reactivityStore.createStore(() => {
440
+ const widgetSide = reactivityStore.ref(undefined);
441
+ const widgetLineNumber = reactivityStore.ref(undefined);
442
+ const setWidget = ({ side, lineNumber }) => {
443
+ var _a, _b;
444
+ const { renderWidgetLine } = ((_b = (_a = useDiffContextRef.current) === null || _a === void 0 ? void 0 : _a.getReadonlyState) === null || _b === void 0 ? void 0 : _b.call(_a)) || {};
445
+ if (typeof renderWidgetLine !== "function")
446
+ return;
447
+ widgetSide.value = side;
448
+ widgetLineNumber.value = lineNumber;
449
+ };
450
+ return { widgetSide, widgetLineNumber, setWidget };
451
+ });
452
+ };
453
+ const createDiffSplitConfigStore = () => {
454
+ return reactivityStore.createStore(() => {
455
+ const splitRef = reactivityStore.ref(undefined);
456
+ const setSplit = (side) => {
457
+ reactDom.flushSync(() => {
458
+ splitRef.value = side;
459
+ });
460
+ };
461
+ return { splitRef, setSplit };
462
+ });
463
+ };
464
+ const diffAsideWidthName = "--diff-aside-width--";
465
+ const diffFontSizeName = "--diff-font-size--";
366
466
 
367
467
  const _DiffSplitHunkLineGitHub = ({ index, diffFile, side, lineNumber, }) => {
368
468
  var _a;
@@ -381,21 +481,21 @@ const _DiffSplitHunkLineGitHub = ({ index, diffFile, side, lineNumber, }) => {
381
481
  const isFirstLine = currentHunk && currentHunk.isFirst;
382
482
  const isLastLine = currentHunk && currentHunk.isLast;
383
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,
384
- React__namespace.createElement("td", { className: "diff-line-hunk-action sticky left-0 p-[1px] w-[1%] min-w-[40px] select-none", style: {
484
+ React__namespace.createElement("td", { className: "diff-line-hunk-action sticky left-0 w-[1%] min-w-[40px] select-none p-[1px]", style: {
385
485
  backgroundColor: `var(${hunkLineNumberBGName})`,
386
486
  color: `var(${plainLineNumberColorName})`,
387
- width: `var(${asideWidth})`,
388
- minWidth: `var(${asideWidth})`,
389
- maxWidth: `var(${asideWidth})`,
390
- } }, couldExpand ? (isFirstLine ? (React__namespace.createElement("button", { className: "w-full diff-widget-tooltip hover:bg-blue-300 flex justify-center items-center py-[6px] cursor-pointer rounded-[2px]", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index) },
391
- React__namespace.createElement(ExpandUp, { className: "fill-current" }))) : isLastLine ? (React__namespace.createElement("button", { className: "w-full diff-widget-tooltip hover:bg-blue-300 flex justify-center items-center py-[6px] cursor-pointer rounded-[2px] relative", title: "Expand Down", "data-title": "Expand Down", onClick: () => {
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: () => {
392
492
  diffFile.onSplitHunkExpand("down", index);
393
493
  } },
394
- React__namespace.createElement(ExpandDown, { className: "fill-current" }))) : isExpandAll ? (React__namespace.createElement("button", { className: "w-full diff-widget-tooltip hover:bg-blue-300 flex justify-center items-center py-[6px] cursor-pointer rounded-[2px]", title: "Expand All", "data-title": "Expand All", onClick: () => diffFile.onSplitHunkExpand("all", index) },
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) },
395
495
  React__namespace.createElement(ExpandAll, { className: "fill-current" }))) : (React__namespace.createElement(React__namespace.Fragment, null,
396
- React__namespace.createElement("button", { className: "w-full diff-widget-tooltip hover:bg-blue-300 flex justify-center items-center py-[2px] cursor-pointer rounded-[2px]", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onSplitHunkExpand("down", index) },
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) },
397
497
  React__namespace.createElement(ExpandDown, { className: "fill-current" })),
398
- React__namespace.createElement("button", { className: "w-full diff-widget-tooltip hover:bg-blue-300 flex justify-center items-center py-[2px] cursor-pointer rounded-[2px]", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index) },
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) },
399
499
  React__namespace.createElement(ExpandUp, { className: "fill-current" }))))) : (React__namespace.createElement("div", { className: "min-h-[28px]" }, "\u2002"))),
400
500
  React__namespace.createElement("td", { className: "diff-line-hunk-content pr-[10px] align-middle", style: { backgroundColor: `var(${hunkContentBGName})` } },
401
501
  React__namespace.createElement("div", { className: "pl-[1.5em]", style: {
@@ -419,21 +519,21 @@ const _DiffSplitHunkLineGitLab = ({ index, diffFile, side, lineNumber, }) => {
419
519
  const isFirstLine = currentHunk && currentHunk.isFirst;
420
520
  const isLastLine = currentHunk && currentHunk.isLast;
421
521
  return (React__namespace.createElement("tr", { "data-line": `${lineNumber}-hunk`, "data-state": "hunk", "data-side": exports.SplitSide[side], className: "diff-line diff-line-hunk" },
422
- React__namespace.createElement("td", { className: "diff-line-hunk-action sticky left-0 p-[1px] w-[1%] min-w-[40px] select-none", style: {
522
+ React__namespace.createElement("td", { className: "diff-line-hunk-action sticky left-0 w-[1%] min-w-[40px] select-none p-[1px]", style: {
423
523
  backgroundColor: `var(${hunkLineNumberBGName})`,
424
524
  color: `var(${plainLineNumberColorName})`,
425
- width: `var(${asideWidth})`,
426
- minWidth: `var(${asideWidth})`,
427
- maxWidth: `var(${asideWidth})`,
428
- } }, couldExpand ? (isFirstLine ? (React__namespace.createElement("button", { className: "w-full diff-widget-tooltip hover:bg-blue-300 flex justify-center items-center py-[6px] cursor-pointer rounded-[2px]", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index) },
429
- React__namespace.createElement(ExpandUp, { className: "fill-current" }))) : isLastLine ? (React__namespace.createElement("button", { className: "w-full diff-widget-tooltip hover:bg-blue-300 flex justify-center items-center py-[6px] cursor-pointer rounded-[2px] relative", title: "Expand Down", "data-title": "Expand Down", onClick: () => {
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: () => {
430
530
  diffFile.onSplitHunkExpand("down", index);
431
531
  } },
432
- React__namespace.createElement(ExpandDown, { className: "fill-current" }))) : isExpandAll ? (React__namespace.createElement("button", { className: "w-full diff-widget-tooltip hover:bg-blue-300 flex justify-center items-center py-[6px] cursor-pointer rounded-[2px]", title: "Expand All", "data-title": "Expand All", onClick: () => diffFile.onSplitHunkExpand("all", index) },
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) },
433
533
  React__namespace.createElement(ExpandAll, { className: "fill-current" }))) : (React__namespace.createElement(React__namespace.Fragment, null,
434
- React__namespace.createElement("button", { className: "w-full diff-widget-tooltip hover:bg-blue-300 flex justify-center items-center py-[2px] cursor-pointer rounded-[2px]", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onSplitHunkExpand("down", index) },
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) },
435
535
  React__namespace.createElement(ExpandDown, { className: "fill-current" })),
436
- React__namespace.createElement("button", { className: "w-full diff-widget-tooltip hover:bg-blue-300 flex justify-center items-center py-[2px] cursor-pointer rounded-[2px]", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index) },
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) },
437
537
  React__namespace.createElement(ExpandUp, { className: "fill-current" }))))) : (React__namespace.createElement("div", { className: "min-h-[28px]" }, "\u2002"))),
438
538
  React__namespace.createElement("td", { className: "diff-line-hunk-content pr-[10px] align-middle", style: { backgroundColor: `var(${hunkContentBGName})` } },
439
539
  React__namespace.createElement("div", { className: "pl-[1.5em]", style: {
@@ -464,14 +564,13 @@ const DiffSplitHunkLine$1 = ({ index, diffFile, side, lineNumber, }) => {
464
564
  };
465
565
 
466
566
  const DiffSplitAddWidget = ({ side, className, lineNumber, onWidgetClick, onOpenAddWidget, }) => {
467
- return (React__namespace.createElement("div", { className: "diff-add-widget-wrapper" + (className ? " " + className : ""), style: {
567
+ return (React__namespace.createElement("div", { className: "diff-add-widget-wrapper invisible select-none transition-transform hover:scale-110 group-hover:visible" +
568
+ (className ? " " + className : ""), style: {
468
569
  width: `calc(var(${diffFontSizeName}) * 1.4)`,
469
570
  height: `calc(var(${diffFontSizeName}) * 1.4)`,
470
571
  } },
471
- React__namespace.createElement("button", { className: "diff-add-widget w-full h-full invisible cursor-pointer rounded-md flex items-center justify-center transition-transform origin-center group-hover:visible hover:scale-110", style: {
572
+ React__namespace.createElement("button", { className: "diff-add-widget z-[1] flex h-full w-full origin-center cursor-pointer items-center justify-center rounded-md text-[1.2em]", style: {
472
573
  color: `var(${addWidgetColorName})`,
473
- zIndex: 1,
474
- fontSize: `1.2em`,
475
574
  backgroundColor: `var(${addWidgetBGName})`,
476
575
  }, onClick: () => {
477
576
  onOpenAddWidget(lineNumber, side);
@@ -479,14 +578,12 @@ const DiffSplitAddWidget = ({ side, className, lineNumber, onWidgetClick, onOpen
479
578
  } }, "+")));
480
579
  };
481
580
  const DiffUnifiedAddWidget = ({ lineNumber, side, onWidgetClick, onOpenAddWidget, }) => {
482
- return (React__namespace.createElement("div", { className: "diff-add-widget-wrapper absolute left-[100%] top-[1px] translate-x-[-50%]", style: {
581
+ return (React__namespace.createElement("div", { className: "diff-add-widget-wrapper invisible absolute left-[100%] top-[1px] translate-x-[-50%] select-none transition-transform hover:scale-110 group-hover:visible", style: {
483
582
  width: `calc(var(${diffFontSizeName}) * 1.4)`,
484
583
  height: `calc(var(${diffFontSizeName}) * 1.4)`,
485
584
  } },
486
- React__namespace.createElement("button", { className: "diff-add-widget w-full h-full invisible cursor-pointer rounded-md flex items-center justify-center transition-transform origin-center group-hover:visible hover:scale-110", style: {
585
+ React__namespace.createElement("button", { className: "diff-add-widget z-[1] flex h-full w-full origin-center cursor-pointer items-center justify-center rounded-md text-[1.2em]", style: {
487
586
  color: `var(${addWidgetColorName})`,
488
- zIndex: 1,
489
- fontSize: `1.2em`,
490
587
  backgroundColor: `var(${addWidgetBGName})`,
491
588
  }, onClick: () => {
492
589
  onOpenAddWidget(lineNumber, side);
@@ -525,14 +622,15 @@ const getStyleObjectFromString = memoFunc((str) => {
525
622
  return style;
526
623
  });
527
624
  const DiffString = ({ rawLine, diffLine, operator, enableWrap, }) => {
528
- const range = diffLine === null || diffLine === void 0 ? void 0 : diffLine.range;
529
- if (range) {
625
+ const changes = diffLine === null || diffLine === void 0 ? void 0 : diffLine.changes;
626
+ if (changes === null || changes === void 0 ? void 0 : changes.hasLineChange) {
627
+ const range = changes.range;
530
628
  const str1 = rawLine.slice(0, range.location);
531
629
  const str2 = rawLine.slice(range.location, range.location + range.length);
532
630
  const str3 = rawLine.slice(range.location + range.length);
533
631
  const isLast = str2.includes("\n");
534
632
  const _str2 = isLast ? str2.replace("\n", "") : str2;
535
- const isNewLineSymbolChanged = range.newLineSymbol;
633
+ const isNewLineSymbolChanged = changes.newLineSymbol;
536
634
  return (React__namespace.createElement("span", { className: "diff-line-content-raw" },
537
635
  React__namespace.createElement("span", { "data-range-start": range.location, "data-range-end": range.location + range.length },
538
636
  str1,
@@ -548,7 +646,7 @@ const DiffString = ({ rawLine, diffLine, operator, enableWrap, }) => {
548
646
  : ""}`
549
647
  : str2),
550
648
  str3),
551
- isNewLineSymbolChanged === core.NewLineSymbol.NEWLINE && diffLine.noTrailingNewLine && (React__namespace.createElement("span", { "data-no-newline-at-end-of-file": true, className: enableWrap ? "block text-red-500" : "inline-block align-middle text-red-500", style: {
649
+ isNewLineSymbolChanged === core.NewLineSymbol.NEWLINE && (React__namespace.createElement("span", { "data-no-newline-at-end-of-file-symbol": true, className: enableWrap ? "block text-red-500" : "inline-block align-middle text-red-500", style: {
552
650
  width: `var(${diffFontSizeName})`,
553
651
  height: `var(${diffFontSizeName})`,
554
652
  } },
@@ -561,9 +659,10 @@ const DiffSyntax = ({ rawLine, diffLine, operator, syntaxLine, enableWrap, }) =>
561
659
  if (!syntaxLine) {
562
660
  return React__namespace.createElement(DiffString, { rawLine: rawLine, diffLine: diffLine, operator: operator });
563
661
  }
564
- const range = diffLine === null || diffLine === void 0 ? void 0 : diffLine.range;
565
- if (range) {
566
- const isNewLineSymbolChanged = range.newLineSymbol;
662
+ const changes = diffLine === null || diffLine === void 0 ? void 0 : diffLine.changes;
663
+ if (changes === null || changes === void 0 ? void 0 : changes.hasLineChange) {
664
+ const isNewLineSymbolChanged = changes.newLineSymbol;
665
+ const range = changes.range;
567
666
  return (React__namespace.createElement("span", { className: "diff-line-syntax-raw" },
568
667
  React__namespace.createElement("span", { "data-range-start": range.location, "data-range-end": range.location + range.length }, (_a = syntaxLine.nodeList) === null || _a === void 0 ? void 0 : _a.map(({ node, wrapper }, index) => {
569
668
  var _a, _b, _c, _d, _e, _f;
@@ -600,7 +699,7 @@ const DiffSyntax = ({ rawLine, diffLine, operator, syntaxLine, enableWrap, }) =>
600
699
  str3));
601
700
  }
602
701
  })),
603
- isNewLineSymbolChanged === core.NewLineSymbol.NEWLINE && diffLine.noTrailingNewLine && (React__namespace.createElement("span", { "data-no-newline-at-end-of-file": true, className: enableWrap ? "block text-red-500" : "inline-block align-middle text-red-500", style: {
702
+ isNewLineSymbolChanged === core.NewLineSymbol.NEWLINE && (React__namespace.createElement("span", { "data-no-newline-at-end-of-file-symbol": true, className: enableWrap ? "block text-red-500" : "inline-block align-middle text-red-500", style: {
604
703
  width: `var(${diffFontSizeName})`,
605
704
  height: `var(${diffFontSizeName})`,
606
705
  } },
@@ -620,7 +719,7 @@ const DiffContent = ({ diffLine, rawLine, syntaxLine, enableWrap, enableHighligh
620
719
  whiteSpace: enableWrap ? "pre-wrap" : "pre",
621
720
  wordBreak: enableWrap ? "break-all" : "initial",
622
721
  } },
623
- React__namespace.createElement("span", { "data-operator": isAdded ? "+" : isDelete ? "-" : undefined, className: "diff-line-content-operator inline-block w-[1.5em] ml-[-1.5em] indent-[0.2em] select-none" }, isAdded ? "+" : isDelete ? "-" : " "),
722
+ React__namespace.createElement("span", { "data-operator": isAdded ? "+" : isDelete ? "-" : undefined, className: "diff-line-content-operator ml-[-1.5em] inline-block w-[1.5em] select-none indent-[0.2em]" }, isAdded ? "+" : isDelete ? "-" : " "),
624
723
  enableHighlight && syntaxLine && !isMaxLineLengthToIgnoreSyntax ? (React__namespace.createElement(DiffSyntax, { operator: isAdded ? "add" : isDelete ? "del" : undefined, rawLine: rawLine, diffLine: diffLine, syntaxLine: syntaxLine, enableWrap: enableWrap })) : (React__namespace.createElement(DiffString, { operator: isAdded ? "add" : isDelete ? "del" : undefined, rawLine: rawLine, diffLine: diffLine, enableWrap: enableWrap }))));
625
724
  };
626
725
 
@@ -651,14 +750,14 @@ const _DiffSplitLine$1 = ({ index, diffFile, lineNumber, side, }) => {
651
750
  const lineNumberBG = getLineNumberBG(isAdded, isDelete, hasDiff);
652
751
  const syntaxLine = getCurrentSyntaxLine(currentLine.lineNumber);
653
752
  return (React__namespace.createElement("tr", { "data-line": lineNumber, "data-state": hasDiff || !hasContent ? "diff" : "plain", "data-side": exports.SplitSide[side], className: "diff-line" + (hasContent ? " group" : "") }, hasContent ? (React__namespace.createElement(React__namespace.Fragment, null,
654
- React__namespace.createElement("td", { className: `diff-line-${exports.SplitSide[side]}-num sticky left-0 pl-[10px] pr-[10px] text-right align-top select-none w-[1%] min-w-[40px]`, style: {
753
+ React__namespace.createElement("td", { className: `diff-line-${exports.SplitSide[side]}-num sticky left-0 w-[1%] min-w-[40px] select-none pl-[10px] pr-[10px] text-right align-top`, style: {
655
754
  backgroundColor: lineNumberBG,
656
755
  color: `var(${plainLineNumberColorName})`,
657
- width: `var(${asideWidth})`,
658
- minWidth: `var(${asideWidth})`,
659
- maxWidth: `var(${asideWidth})`,
756
+ width: `var(${diffAsideWidthName})`,
757
+ minWidth: `var(${diffAsideWidthName})`,
758
+ maxWidth: `var(${diffAsideWidthName})`,
660
759
  } },
661
- hasDiff && enableAddWidget && (React__namespace.createElement(DiffSplitAddWidget, { index: index, lineNumber: currentLine.lineNumber, side: side, diffFile: diffFile, onWidgetClick: (...props) => { var _a; return (_a = onAddWidgetClick.current) === null || _a === void 0 ? void 0 : _a.call(onAddWidgetClick, ...props); }, className: "absolute left-[100%] translate-x-[-50%] z-[1]", onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber: lineNumber, side: side }) })),
760
+ hasDiff && enableAddWidget && (React__namespace.createElement(DiffSplitAddWidget, { index: index, lineNumber: currentLine.lineNumber, side: side, 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 }) })),
662
761
  React__namespace.createElement("span", { "data-line-num": currentLine.lineNumber, style: { opacity: hasChange ? undefined : 0.5 } }, currentLine.lineNumber)),
663
762
  React__namespace.createElement("td", { className: `diff-line-${exports.SplitSide[side]}-content pr-[10px] align-top`, style: { backgroundColor: contentBG } },
664
763
  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 },
@@ -724,7 +823,7 @@ const onMouseDown$1 = (e) => {
724
823
  const DiffSplitViewTable = ({ side, diffFile }) => {
725
824
  const className = side === exports.SplitSide.new ? "new-diff-table" : "old-diff-table";
726
825
  const lines = core.getSplitContentLines(diffFile);
727
- return (React__namespace.createElement("table", { className: className + " border-collapse w-full", "data-mode": exports.SplitSide[side] },
826
+ return (React__namespace.createElement("table", { className: className + " w-full border-collapse", "data-mode": exports.SplitSide[side] },
728
827
  React__namespace.createElement("colgroup", null,
729
828
  React__namespace.createElement("col", { className: `diff-table-${exports.SplitSide[side]}-num-col` }),
730
829
  React__namespace.createElement("col", { className: `diff-table-${exports.SplitSide[side]}-content-col` })),
@@ -764,19 +863,19 @@ const DiffSplitViewNormal = React.memo(({ diffFile }) => {
764
863
  font,
765
864
  });
766
865
  const width = Math.max(40, _width + 25);
767
- return (React__namespace.createElement("div", { className: "split-diff-view split-diff-view-wrap w-full flex basis-[50%]" },
768
- React__namespace.createElement("div", { className: "old-diff-table-wrapper overflow-x-auto overflow-y-hidden w-full scrollbar-hide scrollbar-disable", ref: ref1, style: {
866
+ return (React__namespace.createElement("div", { className: "split-diff-view split-diff-view-wrap flex w-full basis-[50%]" },
867
+ React__namespace.createElement("div", { className: "old-diff-table-wrapper scrollbar-hide scrollbar-disable w-full overflow-x-auto overflow-y-hidden", ref: ref1, style: {
769
868
  // @ts-ignore
770
- [asideWidth]: `${Math.round(width)}px`,
869
+ [diffAsideWidthName]: `${Math.round(width)}px`,
771
870
  overscrollBehaviorX: "none",
772
871
  fontFamily: "Menlo, Consolas, monospace",
773
872
  fontSize: `var(${diffFontSizeName})`,
774
873
  } },
775
874
  React__namespace.createElement(DiffSplitViewTable, { side: exports.SplitSide.old, diffFile: diffFile })),
776
875
  React__namespace.createElement("div", { className: "diff-split-line w-[1.5px] bg-[rgb(222,222,222)]" }),
777
- React__namespace.createElement("div", { className: "new-diff-table-wrapper overflow-x-auto overflow-y-hidden w-full scrollbar-hide scrollbar-disable", ref: ref2, style: {
876
+ React__namespace.createElement("div", { className: "new-diff-table-wrapper scrollbar-hide scrollbar-disable w-full overflow-x-auto overflow-y-hidden", ref: ref2, style: {
778
877
  // @ts-ignore
779
- [asideWidth]: `${Math.round(width)}px`,
878
+ [diffAsideWidthName]: `${Math.round(width)}px`,
780
879
  overscrollBehaviorX: "none",
781
880
  fontFamily: "Menlo, Consolas, monospace",
782
881
  fontSize: `var(${diffFontSizeName})`,
@@ -802,9 +901,9 @@ const _DiffSplitExtendLine = ({ index, diffFile, lineNumber, oldLineExtend, newL
802
901
  lineNumber: oldLine.lineNumber,
803
902
  data: oldLineExtend.data,
804
903
  onUpdate: diffFile.notifyAll,
805
- }))))) : (React__namespace.createElement("td", { className: "diff-line-extend-old-placeholder p-0 select-none", style: { backgroundColor: `var(${emptyBGName})` }, colSpan: 2 },
904
+ }))))) : (React__namespace.createElement("td", { className: "diff-line-extend-old-placeholder select-none p-0", style: { backgroundColor: `var(${emptyBGName})` }, colSpan: 2 },
806
905
  React__namespace.createElement("span", null, "\u2002"))),
807
- newLineExtend ? (React__namespace.createElement("td", { className: "diff-line-extend-new-content p-0 border-l-[1px] border-l-[rgb(222,222,222)]", colSpan: 2 },
906
+ newLineExtend ? (React__namespace.createElement("td", { className: "diff-line-extend-new-content border-l-[1px] border-l-[rgb(222,222,222)] p-0", colSpan: 2 },
808
907
  React__namespace.createElement("div", { className: "diff-line-extend-wrapper" }, (newLineExtend === null || newLineExtend === void 0 ? void 0 : newLineExtend.data) &&
809
908
  (renderExtendLine === null || renderExtendLine === void 0 ? void 0 : renderExtendLine({
810
909
  diffFile,
@@ -812,7 +911,7 @@ const _DiffSplitExtendLine = ({ index, diffFile, lineNumber, oldLineExtend, newL
812
911
  lineNumber: newLine.lineNumber,
813
912
  data: newLineExtend.data,
814
913
  onUpdate: diffFile.notifyAll,
815
- }))))) : (React__namespace.createElement("td", { className: "diff-line-extend-new-placeholder p-0 border-l-[1px] border-l-[rgb(222,222,222)] select-none", style: { backgroundColor: `var(${emptyBGName})` }, colSpan: 2 },
914
+ }))))) : (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 },
816
915
  React__namespace.createElement("span", null, "\u2002")))));
817
916
  };
818
917
  const DiffSplitExtendLine = ({ index, diffFile, lineNumber, }) => {
@@ -852,16 +951,16 @@ const DiffSplitHunkLineGitHub = ({ index, diffFile, lineNumber, }) => {
852
951
  if (!currentIsShow && !currentIsPureHunk)
853
952
  return null;
854
953
  return (React__namespace.createElement("tr", { "data-line": `${lineNumber}-hunk`, "data-state": "hunk", className: "diff-line diff-line-hunk" },
855
- React__namespace.createElement("td", { className: "diff-line-hunk-action p-[1px] w-[1%] min-w-[40px] select-none relative", style: {
954
+ React__namespace.createElement("td", { className: "diff-line-hunk-action relative w-[1%] min-w-[40px] select-none p-[1px]", style: {
856
955
  backgroundColor: `var(${hunkLineNumberBGName})`,
857
956
  color: `var(${plainLineNumberColorName})`,
858
- } }, couldExpand ? (isFirstLine ? (React__namespace.createElement("button", { className: "w-full diff-widget-tooltip hover:bg-blue-300 flex justify-center items-center py-[6px] cursor-pointer rounded-[2px]", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index) },
859
- React__namespace.createElement(ExpandUp, { className: "fill-current" }))) : isLastLine ? (React__namespace.createElement("button", { className: "w-full diff-widget-tooltip hover:bg-blue-300 flex justify-center items-center py-[6px] cursor-pointer rounded-[2px]", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onSplitHunkExpand("down", index) },
860
- React__namespace.createElement(ExpandDown, { className: "fill-current" }))) : isExpandAll ? (React__namespace.createElement("button", { className: "w-full diff-widget-tooltip hover:bg-blue-300 flex justify-center items-center py-[6px] cursor-pointer rounded-[2px]", title: "Expand All", "data-title": "Expand All", onClick: () => diffFile.onSplitHunkExpand("all", index) },
957
+ } }, 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) },
958
+ React__namespace.createElement(ExpandUp, { className: "fill-current" }))) : isLastLine ? (React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px] hover:bg-blue-300", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onSplitHunkExpand("down", index) },
959
+ React__namespace.createElement(ExpandDown, { className: "fill-current" }))) : isExpandAll ? (React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px] hover:bg-blue-300", title: "Expand All", "data-title": "Expand All", onClick: () => diffFile.onSplitHunkExpand("all", index) },
861
960
  React__namespace.createElement(ExpandAll, { className: "fill-current" }))) : (React__namespace.createElement(React__namespace.Fragment, null,
862
- React__namespace.createElement("button", { className: "w-full diff-widget-tooltip hover:bg-blue-300 flex justify-center items-center py-[2px] cursor-pointer rounded-[2px]", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onSplitHunkExpand("down", index) },
961
+ 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) },
863
962
  React__namespace.createElement(ExpandDown, { className: "fill-current" })),
864
- React__namespace.createElement("button", { className: "w-full diff-widget-tooltip hover:bg-blue-300 flex justify-center items-center py-[2px] cursor-pointer rounded-[2px]", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index) },
963
+ 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) },
865
964
  React__namespace.createElement(ExpandUp, { className: "fill-current" }))))) : (React__namespace.createElement("div", { className: "min-h-[28px]" }, "\u2002"))),
866
965
  React__namespace.createElement("td", { className: "diff-line-hunk-content pr-[10px] align-middle", style: { backgroundColor: `var(${hunkContentBGName})` }, colSpan: 3 },
867
966
  React__namespace.createElement("div", { className: "pl-[1.5em]", style: {
@@ -885,31 +984,31 @@ const DiffSplitHunkLineGitLab = ({ index, diffFile, lineNumber, }) => {
885
984
  if (!currentIsShow && !currentIsPureHunk)
886
985
  return null;
887
986
  return (React__namespace.createElement("tr", { "data-line": `${lineNumber}-hunk`, "data-state": "hunk", className: "diff-line diff-line-hunk" },
888
- React__namespace.createElement("td", { className: "diff-line-hunk-action p-[1px] w-[1%] min-w-[40px] select-none relative", style: {
987
+ React__namespace.createElement("td", { className: "diff-line-hunk-action relative w-[1%] min-w-[40px] select-none p-[1px]", style: {
889
988
  backgroundColor: `var(${hunkLineNumberBGName})`,
890
989
  color: `var(${plainLineNumberColorName})`,
891
- } }, couldExpand ? (isFirstLine ? (React__namespace.createElement("button", { className: "w-full diff-widget-tooltip hover:bg-blue-300 flex justify-center items-center py-[6px] cursor-pointer rounded-[2px]", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index) },
892
- React__namespace.createElement(ExpandUp, { className: "fill-current" }))) : isLastLine ? (React__namespace.createElement("button", { className: "w-full diff-widget-tooltip hover:bg-blue-300 flex justify-center items-center py-[6px] cursor-pointer rounded-[2px]", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onSplitHunkExpand("down", index) },
893
- React__namespace.createElement(ExpandDown, { className: "fill-current" }))) : isExpandAll ? (React__namespace.createElement("button", { className: "w-full diff-widget-tooltip hover:bg-blue-300 flex justify-center items-center py-[6px] cursor-pointer rounded-[2px]", title: "Expand All", "data-title": "Expand All", onClick: () => diffFile.onSplitHunkExpand("all", index) },
990
+ } }, 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) },
991
+ React__namespace.createElement(ExpandUp, { className: "fill-current" }))) : isLastLine ? (React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px] hover:bg-blue-300", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onSplitHunkExpand("down", index) },
992
+ React__namespace.createElement(ExpandDown, { className: "fill-current" }))) : isExpandAll ? (React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px] hover:bg-blue-300", title: "Expand All", "data-title": "Expand All", onClick: () => diffFile.onSplitHunkExpand("all", index) },
894
993
  React__namespace.createElement(ExpandAll, { className: "fill-current" }))) : (React__namespace.createElement(React__namespace.Fragment, null,
895
- React__namespace.createElement("button", { className: "w-full diff-widget-tooltip hover:bg-blue-300 flex justify-center items-center py-[2px] cursor-pointer rounded-[2px]", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onSplitHunkExpand("down", index) },
994
+ 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) },
896
995
  React__namespace.createElement(ExpandDown, { className: "fill-current" })),
897
- React__namespace.createElement("button", { className: "w-full diff-widget-tooltip hover:bg-blue-300 flex justify-center items-center py-[2px] cursor-pointer rounded-[2px]", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index) },
996
+ 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) },
898
997
  React__namespace.createElement(ExpandUp, { className: "fill-current" }))))) : (React__namespace.createElement("div", { className: "min-h-[28px]" }, "\u2002"))),
899
998
  React__namespace.createElement("td", { className: "diff-line-hunk-content pr-[10px] align-middle", style: { backgroundColor: `var(${hunkContentBGName})` } },
900
999
  React__namespace.createElement("div", { className: "pl-[1.5em]", style: {
901
1000
  color: `var(${hunkContentColorName})`,
902
1001
  } }, ((_a = currentHunk.splitInfo) === null || _a === void 0 ? void 0 : _a.plainText) || currentHunk.text)),
903
- React__namespace.createElement("td", { className: "diff-line-hunk-action p-[1px] w-[1%] min-w-[40px] select-none relative border-l-[1px] border-l-[rgb(222,222,222)]", style: {
1002
+ 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: {
904
1003
  backgroundColor: `var(${hunkLineNumberBGName})`,
905
1004
  color: `var(${plainLineNumberColorName})`,
906
- } }, couldExpand ? (isFirstLine ? (React__namespace.createElement("button", { className: "w-full diff-widget-tooltip hover:bg-blue-300 flex justify-center items-center py-[6px] cursor-pointer rounded-[2px]", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index) },
907
- React__namespace.createElement(ExpandUp, { className: "fill-current" }))) : isLastLine ? (React__namespace.createElement("button", { className: "w-full diff-widget-tooltip hover:bg-blue-300 flex justify-center items-center py-[6px] cursor-pointer rounded-[2px]", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onSplitHunkExpand("down", index) },
908
- React__namespace.createElement(ExpandDown, { className: "fill-current" }))) : isExpandAll ? (React__namespace.createElement("button", { className: "w-full diff-widget-tooltip hover:bg-blue-300 flex justify-center items-center py-[6px] cursor-pointer rounded-[2px]", title: "Expand All", "data-title": "Expand All", onClick: () => diffFile.onSplitHunkExpand("all", index) },
1005
+ } }, 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) },
1006
+ 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) },
1007
+ 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) },
909
1008
  React__namespace.createElement(ExpandAll, { className: "fill-current" }))) : (React__namespace.createElement(React__namespace.Fragment, null,
910
- React__namespace.createElement("button", { className: "w-full diff-widget-tooltip hover:bg-blue-300 flex justify-center items-center py-[2px] cursor-pointer rounded-[2px]", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onSplitHunkExpand("down", index) },
1009
+ 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) },
911
1010
  React__namespace.createElement(ExpandDown, { className: "fill-current" })),
912
- React__namespace.createElement("button", { className: "w-full diff-widget-tooltip hover:bg-blue-300 flex justify-center items-center py-[2px] cursor-pointer rounded-[2px]", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index) },
1011
+ 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) },
913
1012
  React__namespace.createElement(ExpandUp, { className: "fill-current" }))))) : (React__namespace.createElement("div", { className: "min-h-[28px]" }, "\u2002"))),
914
1013
  React__namespace.createElement("td", { className: "diff-line-hunk-content pr-[10px] align-middle", style: { backgroundColor: `var(${hunkContentBGName})` } },
915
1014
  React__namespace.createElement("div", { className: "pl-[1.5em]", style: {
@@ -955,19 +1054,19 @@ const _DiffSplitLine = ({ index, diffFile, lineNumber }) => {
955
1054
  const newLineNumberBG = getLineNumberBG(newLineIsAdded, false, hasDiff);
956
1055
  return (React__namespace.createElement("tr", { "data-line": lineNumber, "data-state": hasDiff ? "diff" : "plain", className: "diff-line" },
957
1056
  hasOldLine ? (React__namespace.createElement(React__namespace.Fragment, null,
958
- React__namespace.createElement("td", { className: "diff-line-old-num group relative pl-[10px] pr-[10px] text-right align-top select-none w-[1%] min-w-[40px]", "data-side": exports.SplitSide[exports.SplitSide.old], style: { backgroundColor: oldLineNumberBG, color: `var(${plainLineNumberColorName})` } },
959
- 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%] translate-x-[-50%] z-[1]", onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber: lineNumber, side: side }) })),
1057
+ React__namespace.createElement("td", { className: "diff-line-old-num group relative w-[1%] min-w-[40px] select-none pl-[10px] pr-[10px] text-right align-top", "data-side": exports.SplitSide[exports.SplitSide.old], style: { backgroundColor: oldLineNumberBG, color: `var(${plainLineNumberColorName})` } },
1058
+ hasDiff && enableAddWidget && (React__namespace.createElement(DiffSplitAddWidget, { index: index, lineNumber: oldLine.lineNumber, side: exports.SplitSide.old, diffFile: diffFile, onWidgetClick: (...props) => { var _a; return (_a = onAddWidgetClick.current) === null || _a === void 0 ? void 0 : _a.call(onAddWidgetClick, ...props); }, className: "absolute left-[100%] z-[1] translate-x-[-50%]", onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber: lineNumber, side: side }) })),
960
1059
  React__namespace.createElement("span", { "data-line-num": oldLine.lineNumber, style: { opacity: hasChange ? undefined : 0.5 } }, oldLine.lineNumber)),
961
1060
  React__namespace.createElement("td", { className: "diff-line-old-content group relative pr-[10px] align-top", "data-side": exports.SplitSide[exports.SplitSide.old], style: { backgroundColor: oldLineContentBG } },
962
- 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%] translate-x-[50%] z-[1] select-none", onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber: lineNumber, side: side }) })),
1061
+ hasDiff && enableAddWidget && (React__namespace.createElement(DiffSplitAddWidget, { index: index, lineNumber: oldLine.lineNumber, side: exports.SplitSide.old, diffFile: diffFile, onWidgetClick: (...props) => { var _a; return (_a = onAddWidgetClick.current) === null || _a === void 0 ? void 0 : _a.call(onAddWidgetClick, ...props); }, className: "absolute right-[100%] z-[1] translate-x-[50%]", onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber: lineNumber, side: side }) })),
963
1062
  React__namespace.createElement(DiffContent, { enableWrap: true, diffFile: diffFile, rawLine: oldLine.value, diffLine: oldLine.diff, syntaxLine: oldSyntaxLine, enableHighlight: enableHighlight })))) : (React__namespace.createElement("td", { className: "diff-line-old-placeholder select-none", "data-side": exports.SplitSide[exports.SplitSide.old], style: { backgroundColor: `var(${emptyBGName})` }, colSpan: 2 },
964
1063
  React__namespace.createElement("span", null, "\u2002"))),
965
1064
  hasNewLine ? (React__namespace.createElement(React__namespace.Fragment, null,
966
- React__namespace.createElement("td", { className: "diff-line-new-num group relative pl-[10px] pr-[10px] text-right align-top select-none w-[1%] min-w-[40px] border-l-[1px] border-l-[rgb(222,222,222)]", "data-side": exports.SplitSide[exports.SplitSide.new], style: { backgroundColor: newLineNumberBG, color: `var(${plainLineNumberColorName})` } },
967
- 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%] translate-x-[-50%] z-[1]", onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber: lineNumber, side: side }) })),
1065
+ React__namespace.createElement("td", { className: "diff-line-new-num group relative w-[1%] min-w-[40px] select-none border-l-[1px] border-l-[rgb(222,222,222)] pl-[10px] pr-[10px] text-right align-top", "data-side": exports.SplitSide[exports.SplitSide.new], style: { backgroundColor: newLineNumberBG, color: `var(${plainLineNumberColorName})` } },
1066
+ hasDiff && enableAddWidget && (React__namespace.createElement(DiffSplitAddWidget, { index: index, lineNumber: newLine.lineNumber, side: exports.SplitSide.new, diffFile: diffFile, onWidgetClick: (...props) => { var _a; return (_a = onAddWidgetClick.current) === null || _a === void 0 ? void 0 : _a.call(onAddWidgetClick, ...props); }, className: "absolute left-[100%] z-[1] translate-x-[-50%]", onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber: lineNumber, side: side }) })),
968
1067
  React__namespace.createElement("span", { "data-line-num": newLine.lineNumber, style: { opacity: hasChange ? undefined : 0.5 } }, newLine.lineNumber)),
969
1068
  React__namespace.createElement("td", { className: "diff-line-new-content group relative pr-[10px] align-top", "data-side": exports.SplitSide[exports.SplitSide.new], style: { backgroundColor: newLineContentBG } },
970
- 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%] translate-x-[50%] z-[1] select-none", onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber: lineNumber, side: side }) })),
1069
+ hasDiff && enableAddWidget && (React__namespace.createElement(DiffSplitAddWidget, { index: index, lineNumber: newLine.lineNumber, side: exports.SplitSide.new, diffFile: diffFile, onWidgetClick: (...props) => { var _a; return (_a = onAddWidgetClick.current) === null || _a === void 0 ? void 0 : _a.call(onAddWidgetClick, ...props); }, className: "absolute right-[100%] z-[1] translate-x-[50%]", onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber: lineNumber, side: side }) })),
971
1070
  React__namespace.createElement(DiffContent, { enableWrap: true, diffFile: diffFile, rawLine: newLine.value || "", diffLine: newLine.diff, syntaxLine: newSyntaxLine, enableHighlight: enableHighlight })))) : (React__namespace.createElement("td", { className: "diff-line-new-placeholder select-none border-l-[1px] border-l-[rgb(222,222,222)]", style: { backgroundColor: `var(${emptyBGName})` }, "data-side": exports.SplitSide[exports.SplitSide.new], colSpan: 2 },
972
1071
  React__namespace.createElement("span", null, "\u2002")))));
973
1072
  };
@@ -995,15 +1094,15 @@ const _DiffSplitWidgetLine = ({ index, diffFile, lineNumber, oldLineWidget, newL
995
1094
  side: exports.SplitSide.old,
996
1095
  lineNumber: oldLine.lineNumber,
997
1096
  onClose: () => setWidget({}),
998
- })))) : (React__namespace.createElement("td", { className: "diff-line-widget-old-placeholder p-0 select-none", style: { backgroundColor: `var(${emptyBGName})` }, colSpan: 2 },
1097
+ })))) : (React__namespace.createElement("td", { className: "diff-line-widget-old-placeholder select-none p-0", style: { backgroundColor: `var(${emptyBGName})` }, colSpan: 2 },
999
1098
  React__namespace.createElement("span", null, "\u2002"))),
1000
- newLineWidget ? (React__namespace.createElement("td", { className: "diff-line-widget-new-content p-0 border-l-[1px] border-l-[rgb(222,222,222)]", colSpan: 2 },
1099
+ newLineWidget ? (React__namespace.createElement("td", { className: "diff-line-widget-new-content border-l-[1px] border-l-[rgb(222,222,222)] p-0", colSpan: 2 },
1001
1100
  React__namespace.createElement("div", { className: "diff-line-widget-wrapper" }, renderWidgetLine === null || renderWidgetLine === void 0 ? void 0 : renderWidgetLine({
1002
1101
  diffFile,
1003
1102
  side: exports.SplitSide.new,
1004
1103
  lineNumber: newLine.lineNumber,
1005
1104
  onClose: () => setWidget({}),
1006
- })))) : (React__namespace.createElement("td", { className: "diff-line-widget-new-placeholder p-0 border-l-[1px] border-l-[rgb(222,222,222)] select-none", style: { backgroundColor: `var(${emptyBGName})` }, colSpan: 2 },
1105
+ })))) : (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 },
1007
1106
  React__namespace.createElement("span", null, "\u2002")))));
1008
1107
  };
1009
1108
  const DiffSplitWidgetLine = ({ index, diffFile, lineNumber, }) => {
@@ -1019,6 +1118,7 @@ const DiffSplitWidgetLine = ({ index, diffFile, lineNumber, }) => {
1019
1118
  return (React__namespace.createElement(_DiffSplitWidgetLine, { index: index, diffFile: diffFile, lineNumber: lineNumber, oldLineWidget: oldLineWidget, newLineWidget: newLineWidget }));
1020
1119
  };
1021
1120
 
1121
+ /* eslint-disable @typescript-eslint/ban-ts-comment */
1022
1122
  const Style = ({ useSelector, id, }) => {
1023
1123
  const splitRef = useSelector((s) => s.splitRef);
1024
1124
  return (React__namespace.createElement("style", { "data-select-style": true }, splitRef === exports.SplitSide.old
@@ -1030,20 +1130,12 @@ const Style = ({ useSelector, id, }) => {
1030
1130
  const DiffSplitViewWrap = React.memo(({ diffFile }) => {
1031
1131
  const splitLineLength = Math.max(diffFile.splitLineLength, diffFile.fileLineLength);
1032
1132
  const { useDiffContext } = useDiffViewContext();
1033
- const splitSideInfo = React.useMemo(() => reactivityStore.createStore(() => {
1034
- const splitRef = reactivityStore.ref(undefined);
1035
- const setSplit = (side) => {
1036
- reactDom.flushSync(() => {
1037
- splitRef.value = side;
1038
- });
1039
- };
1040
- return { splitRef, setSplit };
1041
- }), []);
1042
- const setSelectSide = splitSideInfo.getReadonlyState().setSplit;
1133
+ const useSplitConfig = React.useMemo(() => createDiffSplitConfigStore(), []);
1043
1134
  const fontSize = useDiffContext(React.useCallback((s) => s.fontSize, []));
1044
1135
  index_js.useSyncExternalStore(diffFile.subscribe, diffFile.getUpdateCount);
1045
1136
  const onMouseDown = React.useCallback((e) => {
1046
1137
  let ele = e.target;
1138
+ const setSelectSide = useSplitConfig.getReadonlyState().setSplit;
1047
1139
  // need remove all the selection
1048
1140
  if (ele && ele instanceof HTMLElement && ele.nodeName === "BUTTON") {
1049
1141
  removeAllSelection();
@@ -1059,7 +1151,8 @@ const DiffSplitViewWrap = React.memo(({ diffFile }) => {
1059
1151
  removeAllSelection();
1060
1152
  }
1061
1153
  }
1062
- }, [setSelectSide]);
1154
+ // eslint-disable-next-line react-hooks/exhaustive-deps
1155
+ }, []);
1063
1156
  const font = React.useMemo(() => ({ fontSize: fontSize + "px", fontFamily: "Menlo, Consolas, monospace" }), [fontSize]);
1064
1157
  const _width = useTextWidth({
1065
1158
  text: splitLineLength.toString(),
@@ -1069,11 +1162,13 @@ const DiffSplitViewWrap = React.memo(({ diffFile }) => {
1069
1162
  const lines = core.getSplitContentLines(diffFile);
1070
1163
  return (React__namespace.createElement("div", { className: "split-diff-view split-diff-view-normal w-full" },
1071
1164
  React__namespace.createElement("div", { className: "diff-table-wrapper w-full", style: {
1165
+ // @ts-ignore
1166
+ [diffAsideWidthName]: `${Math.round(width)}px`,
1072
1167
  fontFamily: "Menlo, Consolas, monospace",
1073
1168
  fontSize: `var(${diffFontSizeName})`,
1074
1169
  } },
1075
- React__namespace.createElement(Style, { useSelector: splitSideInfo, id: `diff-root${diffFile.getId()}` }),
1076
- React__namespace.createElement("table", { className: "diff-table border-collapse table-fixed w-full" },
1170
+ React__namespace.createElement(Style, { useSelector: useSplitConfig, id: `diff-root${diffFile.getId()}` }),
1171
+ React__namespace.createElement("table", { className: "diff-table w-full table-fixed border-collapse" },
1077
1172
  React__namespace.createElement("colgroup", null,
1078
1173
  React__namespace.createElement("col", { className: "diff-table-old-num-col", width: Math.round(width) }),
1079
1174
  React__namespace.createElement("col", { className: "diff-table-old-content-col" }),
@@ -1097,20 +1192,11 @@ DiffSplitViewWrap.displayName = "DiffSplitViewWrap";
1097
1192
 
1098
1193
  const DiffSplitView = React.memo(({ diffFile }) => {
1099
1194
  const { useDiffContext } = useDiffViewContext();
1100
- const enableWrap = useDiffContext(React__namespace.useCallback((s) => s.enableWrap, []));
1195
+ const useDiffContextRef = React.useRef(useDiffContext);
1196
+ useDiffContextRef.current = useDiffContext;
1197
+ const enableWrap = useDiffContext(React.useCallback((s) => s.enableWrap, []));
1101
1198
  // performance optimization
1102
- const useWidget = React.useMemo(() => reactivityStore.createStore(() => {
1103
- const widgetSide = reactivityStore.ref(undefined);
1104
- const widgetLineNumber = reactivityStore.ref(undefined);
1105
- const setWidget = ({ side, lineNumber }) => {
1106
- const { renderWidgetLine } = useDiffContext.getReadonlyState();
1107
- if (typeof renderWidgetLine !== "function")
1108
- return;
1109
- widgetSide.value = side;
1110
- widgetLineNumber.value = lineNumber;
1111
- };
1112
- return { widgetSide, widgetLineNumber, setWidget };
1113
- }), [useDiffContext]);
1199
+ const useWidget = React.useMemo(() => createDiffWidgetStore(useDiffContextRef), []);
1114
1200
  const contextValue = React.useMemo(() => ({ useWidget }), [useWidget]);
1115
1201
  React.useEffect(() => {
1116
1202
  const { setWidget } = useWidget.getReadonlyState();
@@ -1131,7 +1217,7 @@ const _DiffUnifiedExtendLine = ({ index, diffFile, lineNumber, oldLineExtend, ne
1131
1217
  if (!renderExtendLine)
1132
1218
  return null;
1133
1219
  return (React__namespace.createElement("tr", { "data-line": `${lineNumber}-extend`, "data-state": "extend", className: "diff-line diff-line-extend" },
1134
- React__namespace.createElement("td", { className: "diff-line-extend-content align-top p-0", colSpan: 2 },
1220
+ React__namespace.createElement("td", { className: "diff-line-extend-content p-0 align-top", colSpan: 2 },
1135
1221
  React__namespace.createElement("div", { className: "diff-line-extend-wrapper sticky left-0", style: { width } },
1136
1222
  width > 0 &&
1137
1223
  (oldLineExtend === null || oldLineExtend === void 0 ? void 0 : oldLineExtend.data) &&
@@ -1181,19 +1267,19 @@ const _DiffUnifiedHunkLine = ({ index, diffFile, lineNumber, }) => {
1181
1267
  const isFirstLine = currentHunk && currentHunk.isFirst;
1182
1268
  const isLastLine = currentHunk && currentHunk.isLast;
1183
1269
  return (React__namespace.createElement("tr", { "data-line": `${lineNumber}-hunk`, "data-state": "hunk", className: "diff-line diff-line-hunk" },
1184
- React__namespace.createElement("td", { className: "diff-line-hunk-action sticky left-0 p-[1px] w-[1%] min-w-[100px] select-none", style: {
1270
+ React__namespace.createElement("td", { className: "diff-line-hunk-action sticky left-0 w-[1%] min-w-[100px] select-none p-[1px]", style: {
1185
1271
  backgroundColor: `var(${hunkLineNumberBGName})`,
1186
1272
  color: `var(${plainLineNumberColorName})`,
1187
- width: `calc(calc(var(${asideWidth}) + 5px) * 2)`,
1188
- maxWidth: `calc(calc(var(${asideWidth}) + 5px) * 2)`,
1189
- minWidth: `calc(calc(var(${asideWidth}) + 5px) * 2)`,
1190
- } }, couldExpand ? (isFirstLine ? (React__namespace.createElement("button", { className: "w-full diff-widget-tooltip hover:bg-blue-300 flex justify-center items-center py-[6px] cursor-pointer rounded-[2px]", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onUnifiedHunkExpand("up", index) },
1191
- React__namespace.createElement(ExpandUp, { className: "fill-current" }))) : isLastLine ? (React__namespace.createElement("button", { className: "w-full diff-widget-tooltip hover:bg-blue-300 flex justify-center items-center py-[6px] cursor-pointer rounded-[2px]", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onUnifiedHunkExpand("down", index) },
1192
- React__namespace.createElement(ExpandDown, { className: "fill-current" }))) : isExpandAll ? (React__namespace.createElement("button", { className: "w-full diff-widget-tooltip hover:bg-blue-300 flex justify-center items-center py-[6px] cursor-pointer rounded-[2px]", title: "Expand All", "data-title": "Expand All", onClick: () => diffFile.onUnifiedHunkExpand("all", index) },
1273
+ width: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
1274
+ maxWidth: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
1275
+ minWidth: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
1276
+ } }, couldExpand ? (isFirstLine ? (React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px] hover:bg-blue-300", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onUnifiedHunkExpand("up", index) },
1277
+ React__namespace.createElement(ExpandUp, { className: "fill-current" }))) : isLastLine ? (React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px] hover:bg-blue-300", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onUnifiedHunkExpand("down", index) },
1278
+ React__namespace.createElement(ExpandDown, { className: "fill-current" }))) : isExpandAll ? (React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px] hover:bg-blue-300", title: "Expand All", "data-title": "Expand All", onClick: () => diffFile.onUnifiedHunkExpand("all", index) },
1193
1279
  React__namespace.createElement(ExpandAll, { className: "fill-current" }))) : (React__namespace.createElement(React__namespace.Fragment, null,
1194
- React__namespace.createElement("button", { className: "w-full diff-widget-tooltip hover:bg-blue-300 flex justify-center items-center py-[2px] cursor-pointer rounded-[2px]", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onUnifiedHunkExpand("down", index) },
1280
+ React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px] hover:bg-blue-300", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onUnifiedHunkExpand("down", index) },
1195
1281
  React__namespace.createElement(ExpandDown, { className: "fill-current" })),
1196
- React__namespace.createElement("button", { className: "w-full diff-widget-tooltip hover:bg-blue-300 flex justify-center items-center py-[2px] cursor-pointer rounded-[2px]", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onUnifiedHunkExpand("up", index) },
1282
+ React__namespace.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px] hover:bg-blue-300", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onUnifiedHunkExpand("up", index) },
1197
1283
  React__namespace.createElement(ExpandUp, { className: "fill-current" }))))) : (React__namespace.createElement("div", { className: "min-h-[28px]" }, "\u2002"))),
1198
1284
  React__namespace.createElement("td", { className: "diff-line-hunk-content pr-[10px] align-middle", style: { backgroundColor: `var(${hunkContentBGName})` } },
1199
1285
  React__namespace.createElement("div", { className: "pl-[1.5em]", style: {
@@ -1215,12 +1301,12 @@ const DiffUnifiedHunkLine = ({ index, diffFile, lineNumber, }) => {
1215
1301
 
1216
1302
  const DiffUnifiedOldLine = ({ index, diffLine, rawLine, syntaxLine, lineNumber, diffFile, setWidget, enableWrap, enableAddWidget, enableHighlight, onAddWidgetClick, }) => {
1217
1303
  return (React__namespace.createElement("tr", { "data-line": index, "data-state": "diff", className: "diff-line group" },
1218
- React__namespace.createElement("td", { className: "diff-line-num sticky left-0 pl-[10px] pr-[10px] text-right select-none w-[1%] min-w-[100px] whitespace-nowrap align-top", style: {
1304
+ React__namespace.createElement("td", { className: "diff-line-num sticky left-0 w-[1%] min-w-[100px] select-none whitespace-nowrap pl-[10px] pr-[10px] text-right align-top", style: {
1219
1305
  color: `var(${plainLineNumberColorName})`,
1220
1306
  backgroundColor: `var(${delLineNumberBGName})`,
1221
- width: `calc(calc(var(${asideWidth}) + 5px) * 2)`,
1222
- maxWidth: `calc(calc(var(${asideWidth}) + 5px) * 2)`,
1223
- minWidth: `calc(calc(var(${asideWidth}) + 5px) * 2)`,
1307
+ width: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
1308
+ maxWidth: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
1309
+ minWidth: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
1224
1310
  } },
1225
1311
  enableAddWidget && (React__namespace.createElement(DiffUnifiedAddWidget, { index: index - 1, lineNumber: lineNumber, diffFile: diffFile, side: exports.SplitSide.old, onWidgetClick: onAddWidgetClick, onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber, side }) })),
1226
1312
  React__namespace.createElement("div", { className: "flex" },
@@ -1232,17 +1318,17 @@ const DiffUnifiedOldLine = ({ index, diffLine, rawLine, syntaxLine, lineNumber,
1232
1318
  };
1233
1319
  const DiffUnifiedNewLine = ({ index, diffLine, rawLine, syntaxLine, lineNumber, diffFile, setWidget, enableWrap, enableAddWidget, enableHighlight, onAddWidgetClick, }) => {
1234
1320
  return (React__namespace.createElement("tr", { "data-line": index, "data-state": "diff", className: "diff-line group" },
1235
- React__namespace.createElement("td", { className: "diff-line-num sticky left-0 pl-[10px] pr-[10px] text-right select-none w-[1%] min-w-[100px] whitespace-nowrap align-top", style: {
1321
+ React__namespace.createElement("td", { className: "diff-line-num sticky left-0 w-[1%] min-w-[100px] select-none whitespace-nowrap pl-[10px] pr-[10px] text-right align-top", style: {
1236
1322
  color: `var(${plainLineNumberColorName})`,
1237
1323
  backgroundColor: `var(${addLineNumberBGName})`,
1238
- width: `calc(calc(var(${asideWidth}) + 5px) * 2)`,
1239
- maxWidth: `calc(calc(var(${asideWidth}) + 5px) * 2)`,
1240
- minWidth: `calc(calc(var(${asideWidth}) + 5px) * 2)`,
1324
+ width: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
1325
+ maxWidth: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
1326
+ minWidth: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
1241
1327
  } },
1242
1328
  enableAddWidget && (React__namespace.createElement(DiffUnifiedAddWidget, { index: index - 1, lineNumber: lineNumber, diffFile: diffFile, side: exports.SplitSide.new, onWidgetClick: onAddWidgetClick, onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber, side }) })),
1243
1329
  React__namespace.createElement("div", { className: "flex" },
1244
1330
  React__namespace.createElement("span", { className: "inline-block w-[50%]" }),
1245
- React__namespace.createElement("span", { className: "shrink-0 w-[10px]" }),
1331
+ React__namespace.createElement("span", { className: "w-[10px] shrink-0" }),
1246
1332
  React__namespace.createElement("span", { "data-line-new-num": lineNumber, className: "inline-block w-[50%]" }, lineNumber))),
1247
1333
  React__namespace.createElement("td", { className: "diff-line-content pr-[10px] align-top", style: { backgroundColor: `var(${addContentBGName})` } },
1248
1334
  React__namespace.createElement(DiffContent, { enableWrap: enableWrap, diffFile: diffFile, enableHighlight: enableHighlight, rawLine: rawLine, diffLine: diffLine, syntaxLine: syntaxLine }))));
@@ -1279,11 +1365,11 @@ const _DiffUnifiedLine = React.memo(({ index, diffFile, lineNumber }) => {
1279
1365
  }
1280
1366
  else {
1281
1367
  return (React__namespace.createElement("tr", { "data-line": lineNumber, "data-state": unifiedLine.diff ? "diff" : "plain", className: "diff-line group" },
1282
- React__namespace.createElement("td", { className: "diff-line-num sticky left-0 pl-[10px] pr-[10px] text-right select-none w-[1%] min-w-[100px] whitespace-nowrap align-top", style: {
1368
+ React__namespace.createElement("td", { className: "diff-line-num sticky left-0 w-[1%] min-w-[100px] select-none whitespace-nowrap pl-[10px] pr-[10px] text-right align-top", style: {
1283
1369
  color: `var(${plainLineNumberColorName})`,
1284
- width: `calc(calc(var(${asideWidth}) + 5px) * 2)`,
1285
- maxWidth: `calc(calc(var(${asideWidth}) + 5px) * 2)`,
1286
- minWidth: `calc(calc(var(${asideWidth}) + 5px) * 2)`,
1370
+ width: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
1371
+ maxWidth: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
1372
+ minWidth: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
1287
1373
  backgroundColor: hasDiff ? `var(${plainLineNumberBGName})` : `var(${expandContentBGName})`,
1288
1374
  } },
1289
1375
  enableAddWidget && hasDiff && (React__namespace.createElement(DiffUnifiedAddWidget, { index: index, diffFile: diffFile, lineNumber: unifiedLine.newLineNumber, side: exports.SplitSide.new, onWidgetClick: (...props) => { var _a; return (_a = onAddWidgetClick.current) === null || _a === void 0 ? void 0 : _a.call(onAddWidgetClick, ...props); }, onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber, side }) })),
@@ -1350,19 +1436,10 @@ const onMouseDown = (e) => {
1350
1436
  };
1351
1437
  const DiffUnifiedView = React.memo(({ diffFile }) => {
1352
1438
  const { useDiffContext } = useDiffViewContext();
1439
+ const useDiffContextRef = React.useRef(useDiffContext);
1440
+ useDiffContextRef.current = useDiffContext;
1353
1441
  // performance optimization
1354
- const useWidget = React.useMemo(() => reactivityStore.createStore(() => {
1355
- const widgetSide = reactivityStore.ref(undefined);
1356
- const widgetLineNumber = reactivityStore.ref(undefined);
1357
- const setWidget = ({ side, lineNumber }) => {
1358
- const { renderWidgetLine } = useDiffContext.getReadonlyState();
1359
- if (typeof renderWidgetLine !== "function")
1360
- return;
1361
- widgetSide.value = side;
1362
- widgetLineNumber.value = lineNumber;
1363
- };
1364
- return { widgetSide, widgetLineNumber, setWidget };
1365
- }), [useDiffContext]);
1442
+ const useWidget = React.useMemo(() => createDiffWidgetStore(useDiffContextRef), []);
1366
1443
  const contextValue = React.useMemo(() => ({ useWidget }), [useWidget]);
1367
1444
  const fontSize = useDiffContext(React.useCallback((s) => s.fontSize, []));
1368
1445
  index_js.useSyncExternalStore(diffFile.subscribe, diffFile.getUpdateCount);
@@ -1373,19 +1450,19 @@ const DiffUnifiedView = React.memo(({ diffFile }) => {
1373
1450
  const unifiedLineLength = Math.max(diffFile.unifiedLineLength, diffFile.fileLineLength);
1374
1451
  const _width = useTextWidth({
1375
1452
  text: unifiedLineLength.toString(),
1376
- font: { fontSize: fontSize + "px", fontFamily: "Menlo, Consolas, monospace" },
1453
+ font: React.useMemo(() => ({ fontSize: fontSize + "px", fontFamily: "Menlo, Consolas, monospace" }), [fontSize]),
1377
1454
  });
1378
- const width = Math.max(40, _width + 25);
1455
+ const width = Math.max(40, _width + 10);
1379
1456
  const lines = core.getUnifiedContentLine(diffFile);
1380
1457
  return (React__namespace.createElement(DiffWidgetContext.Provider, { value: contextValue },
1381
1458
  React__namespace.createElement("div", { className: "unified-diff-view w-full" },
1382
- React__namespace.createElement("div", { className: "unified-diff-table-wrapper overflow-x-auto overflow-y-hidden w-full scrollbar-hide scrollbar-disable", style: {
1459
+ React__namespace.createElement("div", { className: "unified-diff-table-wrapper scrollbar-hide scrollbar-disable w-full overflow-x-auto overflow-y-hidden", style: {
1383
1460
  // @ts-ignore
1384
- [asideWidth]: `${Math.round(width)}px`,
1461
+ [diffAsideWidthName]: `${Math.round(width)}px`,
1385
1462
  fontFamily: "Menlo, Consolas, monospace",
1386
1463
  fontSize: `var(${diffFontSizeName})`,
1387
1464
  } },
1388
- React__namespace.createElement("table", { className: "unified-diff-table border-collapse w-full" },
1465
+ React__namespace.createElement("table", { className: "unified-diff-table w-full border-collapse" },
1389
1466
  React__namespace.createElement("colgroup", null,
1390
1467
  React__namespace.createElement("col", { className: "unified-diff-table-num-col" }),
1391
1468
  React__namespace.createElement("col", { className: "unified-diff-table-content-col" })),
@@ -1403,7 +1480,6 @@ const DiffUnifiedView = React.memo(({ diffFile }) => {
1403
1480
  });
1404
1481
  DiffUnifiedView.displayName = "DiffUnifiedView";
1405
1482
 
1406
- const diffFontSizeName = "--diff-font-size--";
1407
1483
  core._cacheMap.name = "@git-diff-view/react";
1408
1484
  exports.SplitSide = void 0;
1409
1485
  (function (SplitSide) {
@@ -1414,76 +1490,7 @@ const _InternalDiffView = (props) => {
1414
1490
  const { diffFile, className, style, diffViewMode, diffViewWrap, diffViewFontSize, diffViewHighlight, renderWidgetLine, renderExtendLine, extendData, diffViewAddWidget, onAddWidgetClick, } = props;
1415
1491
  const diffFileId = React.useMemo(() => diffFile.getId(), [diffFile]);
1416
1492
  // performance optimization
1417
- const useDiffContext = React.useMemo(() => reactivityStore.createStore(() => {
1418
- var _a, _b;
1419
- const id = reactivityStore.ref(diffFileId);
1420
- const setId = (_id) => (id.value = _id);
1421
- const mode = reactivityStore.ref(props.diffViewMode);
1422
- const setMode = (_mode) => (mode.value = _mode);
1423
- const enableWrap = reactivityStore.ref(props.diffViewWrap);
1424
- const setEnableWrap = (_enableWrap) => (enableWrap.value = _enableWrap);
1425
- const enableAddWidget = reactivityStore.ref(props.diffViewAddWidget);
1426
- const setEnableAddWidget = (_enableAddWidget) => (enableAddWidget.value = _enableAddWidget);
1427
- const enableHighlight = reactivityStore.ref(props.diffViewHighlight);
1428
- const setEnableHighlight = (_enableHighlight) => (enableHighlight.value = _enableHighlight);
1429
- const fontSize = reactivityStore.ref(props.diffViewFontSize);
1430
- const setFontSize = (_fontSize) => (fontSize.value = _fontSize);
1431
- const extendData = reactivityStore.ref({
1432
- oldFile: Object.assign({}, (_a = props.extendData) === null || _a === void 0 ? void 0 : _a.oldFile),
1433
- newFile: Object.assign({}, (_b = props.extendData) === null || _b === void 0 ? void 0 : _b.newFile),
1434
- });
1435
- const setExtendData = (_extendData) => {
1436
- const existOldKeys = Object.keys(extendData.value.oldFile || {});
1437
- const inComingOldKeys = Object.keys(_extendData.oldFile || {});
1438
- for (const key of existOldKeys) {
1439
- if (!inComingOldKeys.includes(key)) {
1440
- delete extendData.value.oldFile[key];
1441
- }
1442
- }
1443
- for (const key of inComingOldKeys) {
1444
- extendData.value.oldFile[key] = _extendData.oldFile[key];
1445
- }
1446
- const existNewKeys = Object.keys(extendData.value.newFile || {});
1447
- const inComingNewKeys = Object.keys(_extendData.newFile || {});
1448
- for (const key of existNewKeys) {
1449
- if (!inComingNewKeys.includes(key)) {
1450
- delete extendData.value.newFile[key];
1451
- }
1452
- }
1453
- for (const key of inComingNewKeys) {
1454
- extendData.value.newFile[key] = _extendData.newFile[key];
1455
- }
1456
- };
1457
- const renderWidgetLine = reactivityStore.ref(props.renderWidgetLine);
1458
- const setRenderWidgetLine = (_renderWidgetLine) => (renderWidgetLine.value = _renderWidgetLine);
1459
- const renderExtendLine = reactivityStore.ref(props.renderExtendLine);
1460
- const setRenderExtendLine = (_renderExtendLine) => (renderExtendLine.value = _renderExtendLine);
1461
- // 避免无意义的订阅
1462
- const onAddWidgetClick = { current: props.onAddWidgetClick };
1463
- const setOnAddWidgetClick = (_onAddWidgetClick) => (onAddWidgetClick.current = _onAddWidgetClick.current);
1464
- return {
1465
- id,
1466
- setId,
1467
- mode,
1468
- setMode,
1469
- enableWrap,
1470
- setEnableWrap,
1471
- enableAddWidget,
1472
- setEnableAddWidget,
1473
- enableHighlight,
1474
- setEnableHighlight,
1475
- fontSize,
1476
- setFontSize,
1477
- extendData,
1478
- setExtendData,
1479
- renderWidgetLine,
1480
- setRenderWidgetLine,
1481
- renderExtendLine,
1482
- setRenderExtendLine,
1483
- onAddWidgetClick,
1484
- setOnAddWidgetClick,
1485
- };
1486
- }),
1493
+ const useDiffContext = React.useMemo(() => createDiffConfigStore(props, diffFileId),
1487
1494
  // eslint-disable-next-line react-hooks/exhaustive-deps
1488
1495
  []);
1489
1496
  React.useEffect(() => {
@@ -1513,7 +1520,7 @@ const _InternalDiffView = (props) => {
1513
1520
  ]);
1514
1521
  const value = React.useMemo(() => ({ useDiffContext }), [useDiffContext]);
1515
1522
  return (React__namespace.createElement(DiffViewContext.Provider, { value: value },
1516
- React__namespace.createElement("div", { className: "diff-tailwindcss-wrapper", "data-component": "git-diff-view", "data-version": `${"0.0.14"}`, "data-highlighter": diffFile._getHighlighterName() },
1523
+ React__namespace.createElement("div", { className: "diff-tailwindcss-wrapper", "data-component": "git-diff-view", "data-version": `${"0.0.15"}`, "data-highlighter": diffFile._getHighlighterName() },
1517
1524
  React__namespace.createElement("div", { className: "diff-style-root", style: {
1518
1525
  // @ts-ignore
1519
1526
  [diffFontSizeName]: diffViewFontSize + "px",
@@ -1522,6 +1529,7 @@ const _InternalDiffView = (props) => {
1522
1529
  };
1523
1530
  const InternalDiffView = React.memo(_InternalDiffView);
1524
1531
  const DiffViewWithRef = (props, ref) => {
1532
+ var _a, _b;
1525
1533
  const { registerHighlighter, data, diffFile: _diffFile } = props, restProps = __rest(props, ["registerHighlighter", "data", "diffFile"]);
1526
1534
  const diffFile = React.useMemo(() => {
1527
1535
  var _a, _b, _c, _d, _e, _f;
@@ -1535,6 +1543,11 @@ const DiffViewWithRef = (props, ref) => {
1535
1543
  }
1536
1544
  return null;
1537
1545
  }, [data, _diffFile]);
1546
+ const diffFileRef = React.useRef(diffFile);
1547
+ if (diffFileRef.current && diffFileRef.current !== diffFile) {
1548
+ (_b = (_a = diffFileRef.current)._destroy) === null || _b === void 0 ? void 0 : _b.call(_a);
1549
+ diffFileRef.current = diffFile;
1550
+ }
1538
1551
  React.useEffect(() => {
1539
1552
  if (!diffFile)
1540
1553
  return;
@@ -1566,11 +1579,10 @@ const DiffViewWithRef = (props, ref) => {
1566
1579
  };
1567
1580
  const DiffView = React.forwardRef(DiffViewWithRef);
1568
1581
  DiffView.displayName = "DiffView";
1569
- const version = "0.0.14";
1582
+ const version = "0.0.15";
1570
1583
 
1571
1584
  exports.DiffView = DiffView;
1572
1585
  exports.DiffViewContext = DiffViewContext;
1573
- exports.diffFontSizeName = diffFontSizeName;
1574
1586
  exports.useDiffViewContext = useDiffViewContext;
1575
1587
  exports.version = version;
1576
1588
  Object.keys(core).forEach(function (k) {