@pierre/diffs 1.3.1 → 1.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/CodeView.d.ts +4 -1
- package/dist/components/CodeView.d.ts.map +1 -1
- package/dist/components/CodeView.js +69 -30
- package/dist/components/CodeView.js.map +1 -1
- package/dist/edit/index.d.ts +2 -1
- package/dist/editor/command.d.ts +10 -2
- package/dist/editor/command.d.ts.map +1 -1
- package/dist/editor/command.js +111 -38
- package/dist/editor/command.js.map +1 -1
- package/dist/editor/editor.d.ts +3 -0
- package/dist/editor/editor.d.ts.map +1 -1
- package/dist/editor/editor.js +23 -22
- package/dist/editor/editor.js.map +1 -1
- package/dist/editor/selectionAction.d.ts +2 -1
- package/dist/editor/selectionAction.d.ts.map +1 -1
- package/dist/editor/selectionAction.js +3 -1
- package/dist/editor/selectionAction.js.map +1 -1
- package/dist/react/CodeView.d.ts +1 -0
- package/dist/react/CodeView.d.ts.map +1 -1
- package/dist/react/CodeView.js +9 -0
- package/dist/react/CodeView.js.map +1 -1
- package/dist/utils/areManagedSnapshotsEqual.js +1 -1
- package/dist/utils/areManagedSnapshotsEqual.js.map +1 -1
- package/dist/worker/wasm-B9ZqxnKj.js.map +1 -1
- package/dist/worker/worker-portable.js +13 -12
- package/dist/worker/worker-portable.js.map +1 -1
- package/package.json +3 -3
|
@@ -37,6 +37,7 @@ interface CodeViewFileItemContext<LAnnotation> extends AdvancedVirtualizedBaseIt
|
|
|
37
37
|
/** Virtualized file instance responsible for rendering this item. */
|
|
38
38
|
instance: VirtualizedFile<LAnnotation>;
|
|
39
39
|
}
|
|
40
|
+
type CodeViewContextItem<LAnnotation> = CodeViewDiffItemContext<LAnnotation> | CodeViewFileItemContext<LAnnotation>;
|
|
40
41
|
interface CodeViewRenderedDiffItem<LAnnotation> {
|
|
41
42
|
id: string;
|
|
42
43
|
type: 'diff';
|
|
@@ -141,6 +142,7 @@ interface CodeViewOptions<LAnnotation> extends CodeViewPassThroughOptions<LAnnot
|
|
|
141
142
|
* performance fairly significantly */
|
|
142
143
|
__devOnlyValidateItemHeights?: boolean;
|
|
143
144
|
}
|
|
145
|
+
type CodeViewItemMap<LAnnotation> = Map<string, CodeViewContextItem<LAnnotation>>;
|
|
144
146
|
declare class CodeView<LAnnotation = undefined> {
|
|
145
147
|
static __STOP: boolean;
|
|
146
148
|
static __lastScrollPosition: number;
|
|
@@ -244,6 +246,7 @@ declare class CodeView<LAnnotation = undefined> {
|
|
|
244
246
|
updateItemId(oldId: string, newId: string): boolean;
|
|
245
247
|
addItem(input: CodeViewItem<LAnnotation>): void;
|
|
246
248
|
addItems(inputs: readonly CodeViewItem<LAnnotation>[]): void;
|
|
249
|
+
removeItem(itemId: string): boolean;
|
|
247
250
|
setItems(items: readonly CodeViewItem<LAnnotation>[]): void;
|
|
248
251
|
/**
|
|
249
252
|
* Append new records to the viewer while preserving existing layout state.
|
|
@@ -255,7 +258,7 @@ declare class CodeView<LAnnotation = undefined> {
|
|
|
255
258
|
private canSkipRenderForAppend;
|
|
256
259
|
onThemeChange(): void;
|
|
257
260
|
setOptions(options: CodeViewOptions<LAnnotation> | undefined): void;
|
|
258
|
-
capturePendingLayoutAnchor(): void;
|
|
261
|
+
capturePendingLayoutAnchor(nextItems?: Readonly<CodeViewItemMap<LAnnotation>>): void;
|
|
259
262
|
render(immediate?: boolean): void;
|
|
260
263
|
private isReady;
|
|
261
264
|
private clearReadySubscription;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeView.d.ts","names":[],"sources":["../../src/components/CodeView.ts"],"mappings":";;;;;;;;;;UA8GU,2BAAA;;EAER,KAAA;EAFQ;EAIR,GAAA;;EAEA,MAAA;EAJA;;EAOA,OAAA,EAAS,WAAW;EAApB;EAEA,OAAA;EAAA;EAEA,uBAAA;AAAA;AAAA,UAGQ,uBAAA,sBAEA,2BAAA;EACR,IAAA;EAH+B;EAK/B,IAAA,EAAM,gBAAA,CAAiB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0BAAA;EAAA,QA4CA,qBAAA;EAAA,QASA,iBAAA;EAAA,QAOA,qBAAA;EAAA,QAOA,mBAAA;EAAA,QA6CA,qBAAA;EAn2E8B;AAAA;AAAA;;EAAA,QAw5E9B,sBAAA;EAr5EiC;AAAA;;;;EAAA,QA69EjC,4BAAA;EAAA,QA0BA,qBAAA;EAAA,QAWA,sBAAA;EA76EqD;;;;;;;;;AAEvD;EAFuD,QAq9ErD,8BAAA;EA/8E2B;;;;;;;EAAA,QAy+E3B,iBAAA;EAz+E4B;;;;;;;EAAA,QAggF5B,sBAAA;EAAA,QA2CA,yBAAA;EAAA,QA0RA,aAAA;EAAA,QAQA,mBAAA;EAAA,QAUA,eAAA;EAAA,QAiCA,sBAAA;EAAA,QAuBA,0BAAA;EAAA,QASA,sBAAA;EAAA,QAkDA,uBAAA;EAAA,QAyBA,YAAA;EAAA,QAaA,kBAAA;EAAA,QAMA,YAAA;EAn9F0B;;;;EAAA,QAikG1B,0BAAA;EAnjGL;;;;;;;EAAA,QAmkGK,eAAA;EAziGa;;;;;;;EAAA,QAoqGb,wBAAA;EArpGiB;;;;EAAA,QAgrGjB,cAAA;EA9uG0B;;;;EAAA,QA+xG1B,sBAAA;EAQD,YAAA;EAUA,SAAA;EASA,eAAA;EAAA,QAIC,oBAAA;EAAA,QAcA,YAAA;EA30GiB;;;;;EAAA,QA21GjB,qBAAA;EAx1Ge;;;;;EAAA,QAo3Gf,oBAAA;EAh3GR;;;;;;EAAA,QA64GQ,eAAA;EAAA,QA8DA,gBAAA;EAAA,QAcA,yBAAA;AAAA"}
|
|
@@ -109,6 +109,7 @@ function defineItemOption(target, key, get) {
|
|
|
109
109
|
});
|
|
110
110
|
}
|
|
111
111
|
const DEFAULT_SCROLL_INTERACTION_RESTORE_DELAY_MS = 120;
|
|
112
|
+
const SUB_PIXEL_TOLERANCE = 1;
|
|
112
113
|
const SCROLLING_CODE_OVERFLOW_FIX_VARIABLE = "--diffs-overflow-override";
|
|
113
114
|
const SCROLL_REBASE_CONTAINER_HEIGHT = 12e6;
|
|
114
115
|
const SCROLL_REBASE_TRIGGER_TOP = 1e6;
|
|
@@ -269,7 +270,7 @@ var CodeView = class CodeView {
|
|
|
269
270
|
const { firstIndex, lastIndex, stickyHeight, stickyTop, stickyBottom } = this.renderState;
|
|
270
271
|
if (firstIndex === -1 || lastIndex === -1) return;
|
|
271
272
|
const actualHeight = this.stickyContainer.getBoundingClientRect().height;
|
|
272
|
-
if (Math.abs(actualHeight - stickyHeight) <
|
|
273
|
+
if (Math.abs(actualHeight - stickyHeight) < SUB_PIXEL_TOLERANCE) return;
|
|
273
274
|
console.error("CodeView: sticky container height does not match computed layout", {
|
|
274
275
|
computedStickyHeight: stickyHeight,
|
|
275
276
|
actualStickyHeight: actualHeight,
|
|
@@ -599,8 +600,8 @@ var CodeView = class CodeView {
|
|
|
599
600
|
this.markItemLayoutDirty(item);
|
|
600
601
|
this.scrollDirty = true;
|
|
601
602
|
this.render();
|
|
602
|
-
this.syncSelection();
|
|
603
603
|
this.syncItemEditors();
|
|
604
|
+
this.syncSelection();
|
|
604
605
|
return true;
|
|
605
606
|
}
|
|
606
607
|
updateItemId(oldId, newId) {
|
|
@@ -642,22 +643,26 @@ var CodeView = class CodeView {
|
|
|
642
643
|
}
|
|
643
644
|
addItems(inputs) {
|
|
644
645
|
this.appendItemsInternal(inputs);
|
|
645
|
-
this.syncSelection();
|
|
646
646
|
this.syncItemEditors();
|
|
647
|
+
this.syncSelection();
|
|
648
|
+
}
|
|
649
|
+
removeItem(itemId) {
|
|
650
|
+
const item = this.idToItem.get(itemId);
|
|
651
|
+
if (item == null) {
|
|
652
|
+
console.error(`CodeView.removeItem: unknown item id "${itemId}"`);
|
|
653
|
+
return false;
|
|
654
|
+
}
|
|
655
|
+
const nextItems = [];
|
|
656
|
+
for (const current of this.items) if (current !== item) nextItems.push(current.item);
|
|
657
|
+
this.setItems(nextItems);
|
|
658
|
+
return true;
|
|
647
659
|
}
|
|
648
660
|
setItems(items) {
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
if (lastChange != null) completions.push(lastChange);
|
|
654
|
-
}
|
|
655
|
-
this.reset();
|
|
656
|
-
for (const { item, file, lineAnnotations } of completions) this.options.onItemEditComplete?.(item, file, lineAnnotations);
|
|
657
|
-
} else if (this.items.length === 0) this.appendItemsInternal(items);
|
|
658
|
-
else if (!this.tryAppendItems(items)) this.reconcileItems(items);
|
|
661
|
+
let removedItemsById;
|
|
662
|
+
if (this.items.length === 0) this.appendItemsInternal(items);
|
|
663
|
+
else if (!this.tryAppendItems(items)) removedItemsById = this.reconcileItems(items);
|
|
664
|
+
this.syncItemEditors(removedItemsById);
|
|
659
665
|
this.syncSelection();
|
|
660
|
-
this.syncItemEditors();
|
|
661
666
|
}
|
|
662
667
|
/**
|
|
663
668
|
* Append new records to the viewer while preserving existing layout state.
|
|
@@ -723,9 +728,9 @@ var CodeView = class CodeView {
|
|
|
723
728
|
const headerFooterChanged = prevOptions.renderCodeViewHeader !== options.renderCodeViewHeader || prevOptions.renderCodeViewFooter !== options.renderCodeViewFooter;
|
|
724
729
|
if (!this.isContainerManaged && (this.items.length > 0 || headerFooterChanged)) this.render();
|
|
725
730
|
}
|
|
726
|
-
capturePendingLayoutAnchor() {
|
|
727
|
-
if (this.
|
|
728
|
-
this.pendingLayoutAnchor = this.getScrollAnchor(this.getScrollTop());
|
|
731
|
+
capturePendingLayoutAnchor(nextItems = this.idToItem) {
|
|
732
|
+
if (this.root == null || this.items.length === 0 || this.pendingScrollTarget != null) return;
|
|
733
|
+
this.pendingLayoutAnchor = this.getScrollAnchor(this.getScrollTop(), nextItems);
|
|
729
734
|
}
|
|
730
735
|
render(immediate = false) {
|
|
731
736
|
if (CodeView.__STOP) return;
|
|
@@ -874,6 +879,7 @@ var CodeView = class CodeView {
|
|
|
874
879
|
const item = this.idToItem.get(this.selectedLines.id);
|
|
875
880
|
if (item == null) {
|
|
876
881
|
this.selectedLines = null;
|
|
882
|
+
this.options.onSelectedLinesChange?.(null);
|
|
877
883
|
return;
|
|
878
884
|
}
|
|
879
885
|
item.instance.setSelectedLines(this.selectedLines.range, { notify: false });
|
|
@@ -935,25 +941,26 @@ var CodeView = class CodeView {
|
|
|
935
941
|
* attachItemEditor, so this only reconciles editors CodeView is already
|
|
936
942
|
* holding.
|
|
937
943
|
*/
|
|
938
|
-
syncItemEditors() {
|
|
944
|
+
syncItemEditors(removedItems) {
|
|
939
945
|
if (this.itemEditors.size === 0) return;
|
|
940
946
|
const completions = [];
|
|
941
947
|
for (const [id, record] of this.itemEditors) {
|
|
942
948
|
const item = this.idToItem.get(id);
|
|
943
|
-
|
|
949
|
+
const removedItem = removedItems?.get(id);
|
|
950
|
+
if (removedItem == null && item != null && this.isItemInEditMode(item)) continue;
|
|
944
951
|
record.editor.cleanUp();
|
|
945
952
|
this.itemEditors.delete(id);
|
|
946
953
|
this.attachedEditors.delete(id);
|
|
947
|
-
const
|
|
954
|
+
const { lastChange } = record.state;
|
|
955
|
+
const itemSnapshot = removedItem == null ? item?.item ?? lastChange?.item : lastChange?.item ?? removedItem.item;
|
|
948
956
|
if (itemSnapshot?.type === "diff") {
|
|
949
|
-
if (item != null && item.type === "diff" && item.instance.completeEditSession()) {
|
|
957
|
+
if (removedItem == null && item != null && item.type === "diff" && item.instance.completeEditSession()) {
|
|
950
958
|
this.markItemLayoutDirty(item);
|
|
951
959
|
this.render();
|
|
952
960
|
}
|
|
953
961
|
finishEditSessionForDiff(itemSnapshot.fileDiff);
|
|
954
962
|
}
|
|
955
|
-
|
|
956
|
-
if (lastChange != null) completions.push(item == null ? lastChange : {
|
|
963
|
+
if (lastChange != null) completions.push(removedItem != null || item == null ? lastChange : {
|
|
957
964
|
...lastChange,
|
|
958
965
|
item: item.item
|
|
959
966
|
});
|
|
@@ -1118,6 +1125,7 @@ var CodeView = class CodeView {
|
|
|
1118
1125
|
const nextItems = [];
|
|
1119
1126
|
const nextIdToItem = /* @__PURE__ */ new Map();
|
|
1120
1127
|
const nextInstanceToItem = /* @__PURE__ */ new Map();
|
|
1128
|
+
const removedItemsById = /* @__PURE__ */ new Map();
|
|
1121
1129
|
let firstDirtyIndex;
|
|
1122
1130
|
for (let index = 0; index < items.length; index++) {
|
|
1123
1131
|
const input = items[index];
|
|
@@ -1135,14 +1143,19 @@ var CodeView = class CodeView {
|
|
|
1135
1143
|
nextIdToItem.set(input.id, item);
|
|
1136
1144
|
nextInstanceToItem.set(item.instance, item);
|
|
1137
1145
|
}
|
|
1146
|
+
if (firstDirtyIndex == null) {
|
|
1147
|
+
if (removedItems.size === 0) return;
|
|
1148
|
+
firstDirtyIndex = Math.max(nextItems.length - 1, 0);
|
|
1149
|
+
}
|
|
1150
|
+
this.capturePendingLayoutAnchor(nextIdToItem);
|
|
1138
1151
|
for (let index = 0; index < previousItems.length; index++) {
|
|
1139
1152
|
const removedItem = previousItems[index];
|
|
1140
1153
|
if (removedItem == null || !removedItems.has(removedItem)) continue;
|
|
1154
|
+
removedItemsById.set(removedItem.item.id, removedItem);
|
|
1141
1155
|
this.releaseRenderedItem(removedItem);
|
|
1142
1156
|
const dirtyIndex = Math.max(nextItems.length - 1, 0);
|
|
1143
1157
|
firstDirtyIndex = Math.min(firstDirtyIndex ?? dirtyIndex, dirtyIndex);
|
|
1144
1158
|
}
|
|
1145
|
-
if (firstDirtyIndex == null) return;
|
|
1146
1159
|
this.items = nextItems;
|
|
1147
1160
|
this.idToItem = nextIdToItem;
|
|
1148
1161
|
this.instanceToItem = nextInstanceToItem;
|
|
@@ -1151,6 +1164,7 @@ var CodeView = class CodeView {
|
|
|
1151
1164
|
this.markLayoutDirtyFromIndex(firstDirtyIndex);
|
|
1152
1165
|
this.scrollDirty = true;
|
|
1153
1166
|
this.render();
|
|
1167
|
+
return removedItemsById.size > 0 ? removedItemsById : void 0;
|
|
1154
1168
|
}
|
|
1155
1169
|
/**
|
|
1156
1170
|
* Update a reused record from the latest controlled item only when its item
|
|
@@ -1619,7 +1633,10 @@ var CodeView = class CodeView {
|
|
|
1619
1633
|
}
|
|
1620
1634
|
updateStickyPositioning() {
|
|
1621
1635
|
const stickyBounds = this.getStickyBounds();
|
|
1622
|
-
if (stickyBounds == null)
|
|
1636
|
+
if (stickyBounds == null) {
|
|
1637
|
+
if (this.renderState.firstIndex === -1) this.stickyOffset.style.height = "";
|
|
1638
|
+
return;
|
|
1639
|
+
}
|
|
1623
1640
|
const { stickyTop, stickyBottom } = stickyBounds;
|
|
1624
1641
|
if (stickyBottom - stickyTop === this.renderState.stickyHeight && stickyTop === this.renderState.stickyTop && stickyBottom === this.renderState.stickyBottom) return;
|
|
1625
1642
|
this.applyStickyPositioning(stickyBounds);
|
|
@@ -1637,8 +1654,10 @@ var CodeView = class CodeView {
|
|
|
1637
1654
|
this.scrollAnimation = void 0;
|
|
1638
1655
|
};
|
|
1639
1656
|
handleResize = (entries) => {
|
|
1657
|
+
let shouldRender = false;
|
|
1640
1658
|
for (const entry of entries) if (entry.target === this.stickyContainer) {
|
|
1641
|
-
|
|
1659
|
+
const blockSize = entry.borderBoxSize[0].blockSize;
|
|
1660
|
+
if (Math.abs(blockSize - this.renderState.stickyHeight) >= SUB_PIXEL_TOLERANCE) {
|
|
1642
1661
|
const currentScrollTop = this.getScrollTop();
|
|
1643
1662
|
const anchor = this.getScrollAnchor(currentScrollTop);
|
|
1644
1663
|
this.reconcileRenderedItems();
|
|
@@ -1653,6 +1672,7 @@ var CodeView = class CodeView {
|
|
|
1653
1672
|
this.pendingScrollTarget = void 0;
|
|
1654
1673
|
this.scrollAnimation = void 0;
|
|
1655
1674
|
}
|
|
1675
|
+
shouldRender = true;
|
|
1656
1676
|
}
|
|
1657
1677
|
} else if (entry.target === this.header.element || entry.target === this.footer.element) {
|
|
1658
1678
|
const host = entry.target === this.header.element ? this.header : this.footer;
|
|
@@ -1671,13 +1691,14 @@ var CodeView = class CodeView {
|
|
|
1671
1691
|
this.pendingScrollTarget = void 0;
|
|
1672
1692
|
this.scrollAnimation = void 0;
|
|
1673
1693
|
}
|
|
1674
|
-
|
|
1694
|
+
shouldRender = true;
|
|
1675
1695
|
}
|
|
1676
1696
|
} else {
|
|
1677
1697
|
this.scrollDirty = true;
|
|
1678
1698
|
this.heightDirty = true;
|
|
1679
|
-
|
|
1699
|
+
shouldRender = true;
|
|
1680
1700
|
}
|
|
1701
|
+
if (shouldRender) this.render(true);
|
|
1681
1702
|
};
|
|
1682
1703
|
/**
|
|
1683
1704
|
* Figure out scrollTop accounting for sticky header if enabled and
|
|
@@ -1693,8 +1714,14 @@ var CodeView = class CodeView {
|
|
|
1693
1714
|
* A scroll anchor represents the first fully visible element (in other
|
|
1694
1715
|
* words, the first file or first line who's top is fully in the viewport).
|
|
1695
1716
|
*/
|
|
1696
|
-
getScrollAnchor(scrollTop) {
|
|
1697
|
-
|
|
1717
|
+
getScrollAnchor(scrollTop, availableItems = this.idToItem) {
|
|
1718
|
+
let skippedItem;
|
|
1719
|
+
const { pendingLayoutAnchor } = this;
|
|
1720
|
+
if (pendingLayoutAnchor != null) {
|
|
1721
|
+
const pendingItem = this.idToItem.get(pendingLayoutAnchor.id);
|
|
1722
|
+
if (pendingItem != null && availableItems.get(pendingLayoutAnchor.id) === pendingItem) return pendingLayoutAnchor;
|
|
1723
|
+
if (pendingItem != null) skippedItem = pendingItem;
|
|
1724
|
+
}
|
|
1698
1725
|
if (scrollTop <= 0) return;
|
|
1699
1726
|
const { firstIndex, lastIndex, stickyTop, stickyBottom } = this.renderState;
|
|
1700
1727
|
if (firstIndex === -1 || lastIndex === -1) return;
|
|
@@ -1706,6 +1733,10 @@ var CodeView = class CodeView {
|
|
|
1706
1733
|
const absoluteItemTop = this.getItemTopOffset() + item.top;
|
|
1707
1734
|
if (absoluteItemTop + item.height <= scrollTop) continue;
|
|
1708
1735
|
if (absoluteItemTop >= scrollTop + viewportHeight) break;
|
|
1736
|
+
if (!(availableItems.get(item.item.id) === item)) {
|
|
1737
|
+
skippedItem ??= item;
|
|
1738
|
+
continue;
|
|
1739
|
+
}
|
|
1709
1740
|
if (absoluteItemTop >= scrollTop) return {
|
|
1710
1741
|
type: "item",
|
|
1711
1742
|
id: item.item.id,
|
|
@@ -1724,6 +1755,14 @@ var CodeView = class CodeView {
|
|
|
1724
1755
|
};
|
|
1725
1756
|
}
|
|
1726
1757
|
}
|
|
1758
|
+
if (skippedItem != null) for (let index = skippedItem.index + 1; index < this.items.length; index++) {
|
|
1759
|
+
const candidate = this.items[index];
|
|
1760
|
+
if (candidate != null && availableItems.get(candidate.item.id) === candidate) return {
|
|
1761
|
+
type: "item",
|
|
1762
|
+
id: candidate.item.id,
|
|
1763
|
+
viewportOffset: 0
|
|
1764
|
+
};
|
|
1765
|
+
}
|
|
1727
1766
|
}
|
|
1728
1767
|
/**
|
|
1729
1768
|
* Given a scroll anchor, attempt to resolve a newly updated (and clamped)
|