@pierre/diffs 1.3.1 → 1.3.2
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 +60 -26
- 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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BAAA;EAAA,QA4CA,qBAAA;EAAA,QASA,iBAAA;EAAA,QAOA,qBAAA;EAAA,QAOA,mBAAA;EAAA,QA6CA,qBAAA;EAp2E8B;AAAA;AAAA;;EAAA,QAy5E9B,sBAAA;EAt5EiC;AAAA;;;;EAAA,QA89EjC,4BAAA;EAAA,QA0BA,qBAAA;EAAA,QAWA,sBAAA;EA96EqD;;;;;;;;;AAEvD;EAFuD,QAs9ErD,8BAAA;EAh9E2B;;;;;;;EAAA,QA0+E3B,iBAAA;EA1+E4B;;;;;;;EAAA,QAigF5B,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;EAp9F0B;;;;EAAA,QAwjG1B,0BAAA;EA1iGL;;;;;;;EAAA,QA0jGK,eAAA;EAhiGa;;;;;;;EAAA,QA2pGb,wBAAA;EA5oGiB;;;;EAAA,QAuqGjB,cAAA;EAruG0B;;;;EAAA,QAsxG1B,sBAAA;EAQD,YAAA;EAUA,SAAA;EASA,eAAA;EAAA,QAIC,oBAAA;EAAA,QAcA,YAAA;EAl0GiB;;;;;EAAA,QAk1GjB,qBAAA;EA/0Ge;;;;;EAAA,QA22Gf,oBAAA;EAv2GR;;;;;;EAAA,QAo4GQ,eAAA;EAAA,QA8DA,gBAAA;EAAA,QAcA,yBAAA;AAAA"}
|
|
@@ -599,8 +599,8 @@ var CodeView = class CodeView {
|
|
|
599
599
|
this.markItemLayoutDirty(item);
|
|
600
600
|
this.scrollDirty = true;
|
|
601
601
|
this.render();
|
|
602
|
-
this.syncSelection();
|
|
603
602
|
this.syncItemEditors();
|
|
603
|
+
this.syncSelection();
|
|
604
604
|
return true;
|
|
605
605
|
}
|
|
606
606
|
updateItemId(oldId, newId) {
|
|
@@ -642,22 +642,26 @@ var CodeView = class CodeView {
|
|
|
642
642
|
}
|
|
643
643
|
addItems(inputs) {
|
|
644
644
|
this.appendItemsInternal(inputs);
|
|
645
|
-
this.syncSelection();
|
|
646
645
|
this.syncItemEditors();
|
|
646
|
+
this.syncSelection();
|
|
647
|
+
}
|
|
648
|
+
removeItem(itemId) {
|
|
649
|
+
const item = this.idToItem.get(itemId);
|
|
650
|
+
if (item == null) {
|
|
651
|
+
console.error(`CodeView.removeItem: unknown item id "${itemId}"`);
|
|
652
|
+
return false;
|
|
653
|
+
}
|
|
654
|
+
const nextItems = [];
|
|
655
|
+
for (const current of this.items) if (current !== item) nextItems.push(current.item);
|
|
656
|
+
this.setItems(nextItems);
|
|
657
|
+
return true;
|
|
647
658
|
}
|
|
648
659
|
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);
|
|
660
|
+
let removedItemsById;
|
|
661
|
+
if (this.items.length === 0) this.appendItemsInternal(items);
|
|
662
|
+
else if (!this.tryAppendItems(items)) removedItemsById = this.reconcileItems(items);
|
|
663
|
+
this.syncItemEditors(removedItemsById);
|
|
659
664
|
this.syncSelection();
|
|
660
|
-
this.syncItemEditors();
|
|
661
665
|
}
|
|
662
666
|
/**
|
|
663
667
|
* Append new records to the viewer while preserving existing layout state.
|
|
@@ -723,9 +727,9 @@ var CodeView = class CodeView {
|
|
|
723
727
|
const headerFooterChanged = prevOptions.renderCodeViewHeader !== options.renderCodeViewHeader || prevOptions.renderCodeViewFooter !== options.renderCodeViewFooter;
|
|
724
728
|
if (!this.isContainerManaged && (this.items.length > 0 || headerFooterChanged)) this.render();
|
|
725
729
|
}
|
|
726
|
-
capturePendingLayoutAnchor() {
|
|
727
|
-
if (this.
|
|
728
|
-
this.pendingLayoutAnchor = this.getScrollAnchor(this.getScrollTop());
|
|
730
|
+
capturePendingLayoutAnchor(nextItems = this.idToItem) {
|
|
731
|
+
if (this.root == null || this.items.length === 0 || this.pendingScrollTarget != null) return;
|
|
732
|
+
this.pendingLayoutAnchor = this.getScrollAnchor(this.getScrollTop(), nextItems);
|
|
729
733
|
}
|
|
730
734
|
render(immediate = false) {
|
|
731
735
|
if (CodeView.__STOP) return;
|
|
@@ -874,6 +878,7 @@ var CodeView = class CodeView {
|
|
|
874
878
|
const item = this.idToItem.get(this.selectedLines.id);
|
|
875
879
|
if (item == null) {
|
|
876
880
|
this.selectedLines = null;
|
|
881
|
+
this.options.onSelectedLinesChange?.(null);
|
|
877
882
|
return;
|
|
878
883
|
}
|
|
879
884
|
item.instance.setSelectedLines(this.selectedLines.range, { notify: false });
|
|
@@ -935,25 +940,26 @@ var CodeView = class CodeView {
|
|
|
935
940
|
* attachItemEditor, so this only reconciles editors CodeView is already
|
|
936
941
|
* holding.
|
|
937
942
|
*/
|
|
938
|
-
syncItemEditors() {
|
|
943
|
+
syncItemEditors(removedItems) {
|
|
939
944
|
if (this.itemEditors.size === 0) return;
|
|
940
945
|
const completions = [];
|
|
941
946
|
for (const [id, record] of this.itemEditors) {
|
|
942
947
|
const item = this.idToItem.get(id);
|
|
943
|
-
|
|
948
|
+
const removedItem = removedItems?.get(id);
|
|
949
|
+
if (removedItem == null && item != null && this.isItemInEditMode(item)) continue;
|
|
944
950
|
record.editor.cleanUp();
|
|
945
951
|
this.itemEditors.delete(id);
|
|
946
952
|
this.attachedEditors.delete(id);
|
|
947
|
-
const
|
|
953
|
+
const { lastChange } = record.state;
|
|
954
|
+
const itemSnapshot = removedItem == null ? item?.item ?? lastChange?.item : lastChange?.item ?? removedItem.item;
|
|
948
955
|
if (itemSnapshot?.type === "diff") {
|
|
949
|
-
if (item != null && item.type === "diff" && item.instance.completeEditSession()) {
|
|
956
|
+
if (removedItem == null && item != null && item.type === "diff" && item.instance.completeEditSession()) {
|
|
950
957
|
this.markItemLayoutDirty(item);
|
|
951
958
|
this.render();
|
|
952
959
|
}
|
|
953
960
|
finishEditSessionForDiff(itemSnapshot.fileDiff);
|
|
954
961
|
}
|
|
955
|
-
|
|
956
|
-
if (lastChange != null) completions.push(item == null ? lastChange : {
|
|
962
|
+
if (lastChange != null) completions.push(removedItem != null || item == null ? lastChange : {
|
|
957
963
|
...lastChange,
|
|
958
964
|
item: item.item
|
|
959
965
|
});
|
|
@@ -1118,6 +1124,7 @@ var CodeView = class CodeView {
|
|
|
1118
1124
|
const nextItems = [];
|
|
1119
1125
|
const nextIdToItem = /* @__PURE__ */ new Map();
|
|
1120
1126
|
const nextInstanceToItem = /* @__PURE__ */ new Map();
|
|
1127
|
+
const removedItemsById = /* @__PURE__ */ new Map();
|
|
1121
1128
|
let firstDirtyIndex;
|
|
1122
1129
|
for (let index = 0; index < items.length; index++) {
|
|
1123
1130
|
const input = items[index];
|
|
@@ -1135,14 +1142,19 @@ var CodeView = class CodeView {
|
|
|
1135
1142
|
nextIdToItem.set(input.id, item);
|
|
1136
1143
|
nextInstanceToItem.set(item.instance, item);
|
|
1137
1144
|
}
|
|
1145
|
+
if (firstDirtyIndex == null) {
|
|
1146
|
+
if (removedItems.size === 0) return;
|
|
1147
|
+
firstDirtyIndex = Math.max(nextItems.length - 1, 0);
|
|
1148
|
+
}
|
|
1149
|
+
this.capturePendingLayoutAnchor(nextIdToItem);
|
|
1138
1150
|
for (let index = 0; index < previousItems.length; index++) {
|
|
1139
1151
|
const removedItem = previousItems[index];
|
|
1140
1152
|
if (removedItem == null || !removedItems.has(removedItem)) continue;
|
|
1153
|
+
removedItemsById.set(removedItem.item.id, removedItem);
|
|
1141
1154
|
this.releaseRenderedItem(removedItem);
|
|
1142
1155
|
const dirtyIndex = Math.max(nextItems.length - 1, 0);
|
|
1143
1156
|
firstDirtyIndex = Math.min(firstDirtyIndex ?? dirtyIndex, dirtyIndex);
|
|
1144
1157
|
}
|
|
1145
|
-
if (firstDirtyIndex == null) return;
|
|
1146
1158
|
this.items = nextItems;
|
|
1147
1159
|
this.idToItem = nextIdToItem;
|
|
1148
1160
|
this.instanceToItem = nextInstanceToItem;
|
|
@@ -1151,6 +1163,7 @@ var CodeView = class CodeView {
|
|
|
1151
1163
|
this.markLayoutDirtyFromIndex(firstDirtyIndex);
|
|
1152
1164
|
this.scrollDirty = true;
|
|
1153
1165
|
this.render();
|
|
1166
|
+
return removedItemsById.size > 0 ? removedItemsById : void 0;
|
|
1154
1167
|
}
|
|
1155
1168
|
/**
|
|
1156
1169
|
* Update a reused record from the latest controlled item only when its item
|
|
@@ -1619,7 +1632,10 @@ var CodeView = class CodeView {
|
|
|
1619
1632
|
}
|
|
1620
1633
|
updateStickyPositioning() {
|
|
1621
1634
|
const stickyBounds = this.getStickyBounds();
|
|
1622
|
-
if (stickyBounds == null)
|
|
1635
|
+
if (stickyBounds == null) {
|
|
1636
|
+
if (this.renderState.firstIndex === -1) this.stickyOffset.style.height = "";
|
|
1637
|
+
return;
|
|
1638
|
+
}
|
|
1623
1639
|
const { stickyTop, stickyBottom } = stickyBounds;
|
|
1624
1640
|
if (stickyBottom - stickyTop === this.renderState.stickyHeight && stickyTop === this.renderState.stickyTop && stickyBottom === this.renderState.stickyBottom) return;
|
|
1625
1641
|
this.applyStickyPositioning(stickyBounds);
|
|
@@ -1693,8 +1709,14 @@ var CodeView = class CodeView {
|
|
|
1693
1709
|
* A scroll anchor represents the first fully visible element (in other
|
|
1694
1710
|
* words, the first file or first line who's top is fully in the viewport).
|
|
1695
1711
|
*/
|
|
1696
|
-
getScrollAnchor(scrollTop) {
|
|
1697
|
-
|
|
1712
|
+
getScrollAnchor(scrollTop, availableItems = this.idToItem) {
|
|
1713
|
+
let skippedItem;
|
|
1714
|
+
const { pendingLayoutAnchor } = this;
|
|
1715
|
+
if (pendingLayoutAnchor != null) {
|
|
1716
|
+
const pendingItem = this.idToItem.get(pendingLayoutAnchor.id);
|
|
1717
|
+
if (pendingItem != null && availableItems.get(pendingLayoutAnchor.id) === pendingItem) return pendingLayoutAnchor;
|
|
1718
|
+
if (pendingItem != null) skippedItem = pendingItem;
|
|
1719
|
+
}
|
|
1698
1720
|
if (scrollTop <= 0) return;
|
|
1699
1721
|
const { firstIndex, lastIndex, stickyTop, stickyBottom } = this.renderState;
|
|
1700
1722
|
if (firstIndex === -1 || lastIndex === -1) return;
|
|
@@ -1706,6 +1728,10 @@ var CodeView = class CodeView {
|
|
|
1706
1728
|
const absoluteItemTop = this.getItemTopOffset() + item.top;
|
|
1707
1729
|
if (absoluteItemTop + item.height <= scrollTop) continue;
|
|
1708
1730
|
if (absoluteItemTop >= scrollTop + viewportHeight) break;
|
|
1731
|
+
if (!(availableItems.get(item.item.id) === item)) {
|
|
1732
|
+
skippedItem ??= item;
|
|
1733
|
+
continue;
|
|
1734
|
+
}
|
|
1709
1735
|
if (absoluteItemTop >= scrollTop) return {
|
|
1710
1736
|
type: "item",
|
|
1711
1737
|
id: item.item.id,
|
|
@@ -1724,6 +1750,14 @@ var CodeView = class CodeView {
|
|
|
1724
1750
|
};
|
|
1725
1751
|
}
|
|
1726
1752
|
}
|
|
1753
|
+
if (skippedItem != null) for (let index = skippedItem.index + 1; index < this.items.length; index++) {
|
|
1754
|
+
const candidate = this.items[index];
|
|
1755
|
+
if (candidate != null && availableItems.get(candidate.item.id) === candidate) return {
|
|
1756
|
+
type: "item",
|
|
1757
|
+
id: candidate.item.id,
|
|
1758
|
+
viewportOffset: 0
|
|
1759
|
+
};
|
|
1760
|
+
}
|
|
1727
1761
|
}
|
|
1728
1762
|
/**
|
|
1729
1763
|
* Given a scroll anchor, attempt to resolve a newly updated (and clamped)
|