@singapore-editor/minimap 0.1.1
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/README.md +29 -0
- package/dist/assets/minimap.worker-i4S59IOV.js +1616 -0
- package/dist/assets/minimap.worker-i4S59IOV.js.map +1 -0
- package/dist/color.d.ts +11 -0
- package/dist/color.d.ts.map +1 -0
- package/dist/color.js +83 -0
- package/dist/color.js.map +1 -0
- package/dist/decorationMerge.d.ts +10 -0
- package/dist/decorationMerge.d.ts.map +1 -0
- package/dist/decorationMerge.js +65 -0
- package/dist/decorationMerge.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/layout.d.ts +43 -0
- package/dist/layout.d.ts.map +1 -0
- package/dist/layout.js +137 -0
- package/dist/layout.js.map +1 -0
- package/dist/minimap.worker.d.ts +2 -0
- package/dist/minimap.worker.d.ts.map +1 -0
- package/dist/minimapCharRenderer.d.ts +13 -0
- package/dist/minimapCharRenderer.d.ts.map +1 -0
- package/dist/minimapCharRendererFactory.d.ts +14 -0
- package/dist/minimapCharRendererFactory.d.ts.map +1 -0
- package/dist/minimapCharSheet.d.ts +15 -0
- package/dist/minimapCharSheet.d.ts.map +1 -0
- package/dist/minimapCharSheet.js +24 -0
- package/dist/minimapCharSheet.js.map +1 -0
- package/dist/options.d.ts +3 -0
- package/dist/options.d.ts.map +1 -0
- package/dist/options.js +65 -0
- package/dist/options.js.map +1 -0
- package/dist/plugin.d.ts +4 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +415 -0
- package/dist/plugin.js.map +1 -0
- package/dist/raster.d.ts +10 -0
- package/dist/raster.d.ts.map +1 -0
- package/dist/renderer.d.ts +58 -0
- package/dist/renderer.d.ts.map +1 -0
- package/dist/sectionHeaders.d.ts +13 -0
- package/dist/sectionHeaders.d.ts.map +1 -0
- package/dist/style.css +97 -0
- package/dist/types.d.ts +211 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +11 -0
- package/dist/types.js.map +1 -0
- package/dist/viewportGeometry.d.ts +28 -0
- package/dist/viewportGeometry.d.ts.map +1 -0
- package/dist/viewportGeometry.js +22 -0
- package/dist/viewportGeometry.js.map +1 -0
- package/dist/workerClient.d.ts +131 -0
- package/dist/workerClient.d.ts.map +1 -0
- package/dist/workerClient.js +1337 -0
- package/dist/workerClient.js.map +1 -0
- package/package.json +50 -0
package/dist/plugin.js
ADDED
|
@@ -0,0 +1,415 @@
|
|
|
1
|
+
import { mergeDenseDecorations } from "./decorationMerge.js";
|
|
2
|
+
import { computeRenderLayout, documentLineForSliderY, visibleDocumentLineRange } from "./layout.js";
|
|
3
|
+
import { resolveMinimapOptions } from "./options.js";
|
|
4
|
+
import { minimapViewportGeometry } from "./viewportGeometry.js";
|
|
5
|
+
import { MinimapWorkerClient, canUseMinimapWorker } from "./workerClient.js";
|
|
6
|
+
import { EDITOR_MINIMAP_FEATURE, registerWheelScrollTarget } from "@singapore-editor/core/extensions";
|
|
7
|
+
//#region src/plugin.ts
|
|
8
|
+
function createMinimapPlugin(options = {}) {
|
|
9
|
+
const resolved = resolveMinimapOptions(options);
|
|
10
|
+
const decorations = new MinimapDecorationRegistry();
|
|
11
|
+
return {
|
|
12
|
+
name: "minimap",
|
|
13
|
+
activate(context) {
|
|
14
|
+
return [context.registerCapabilityContribution({ createContribution: (contributionContext) => createMinimapFeatureContribution(contributionContext, decorations) }), context.registerViewContribution({ createContribution: (contributionContext) => createMinimapContribution(contributionContext, resolved, decorations) })];
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function createMinimapFeatureContribution(context, decorations) {
|
|
19
|
+
const registration = context.registerFeature(EDITOR_MINIMAP_FEATURE, decorations);
|
|
20
|
+
return { dispose: () => registration.dispose() };
|
|
21
|
+
}
|
|
22
|
+
function createMinimapContribution(context, options, decorations) {
|
|
23
|
+
if (!options.enabled) return null;
|
|
24
|
+
if (!canUseMinimapWorker()) return null;
|
|
25
|
+
return new MinimapContribution(context, options, decorations);
|
|
26
|
+
}
|
|
27
|
+
var MinimapContribution = class {
|
|
28
|
+
decorations;
|
|
29
|
+
snapshotKey;
|
|
30
|
+
context;
|
|
31
|
+
options;
|
|
32
|
+
host;
|
|
33
|
+
client;
|
|
34
|
+
decorationSubscription;
|
|
35
|
+
wheelScrollRegistration;
|
|
36
|
+
latestSnapshot;
|
|
37
|
+
latestViewport;
|
|
38
|
+
activeSliderDrag = null;
|
|
39
|
+
appliedReservedWidth = 0;
|
|
40
|
+
layoutSignature = "";
|
|
41
|
+
scrollBox = null;
|
|
42
|
+
pendingSliderLine = null;
|
|
43
|
+
sliderScrollFrame = 0;
|
|
44
|
+
disposed = false;
|
|
45
|
+
constructor(context, options, decorations) {
|
|
46
|
+
this.decorations = decorations;
|
|
47
|
+
this.context = context;
|
|
48
|
+
this.options = options;
|
|
49
|
+
this.snapshotKey = `minimap:${JSON.stringify(options)}`;
|
|
50
|
+
this.latestSnapshot = context.getSnapshot();
|
|
51
|
+
this.latestViewport = this.latestSnapshot.viewport;
|
|
52
|
+
this.host = createHost(context, options);
|
|
53
|
+
if (this.latestSnapshot.geometryCommitted !== false) this.synchronizeLayoutReservation();
|
|
54
|
+
this.client = new MinimapWorkerClient({
|
|
55
|
+
host: this.host,
|
|
56
|
+
options,
|
|
57
|
+
snapshot: this.latestSnapshot,
|
|
58
|
+
decorations: this.collectDecorations(),
|
|
59
|
+
onLayoutWidth: this.reserveWidth,
|
|
60
|
+
reservedLane: () => this.appliedReservedWidth
|
|
61
|
+
});
|
|
62
|
+
this.decorationSubscription = decorations.subscribe(this.handleDecorationsChanged);
|
|
63
|
+
this.wheelScrollRegistration = registerWheelScrollTarget(context, this.host.root);
|
|
64
|
+
this.installPointerHandlers();
|
|
65
|
+
this.client.update(this.latestSnapshot, "document");
|
|
66
|
+
}
|
|
67
|
+
update(snapshot, kind, change) {
|
|
68
|
+
if (this.disposed) return;
|
|
69
|
+
this.latestSnapshot = snapshot;
|
|
70
|
+
this.latestViewport = snapshot.viewport;
|
|
71
|
+
if (snapshot.geometryCommitted === false) return;
|
|
72
|
+
if (kind === "document" || kind === "layout") this.scrollBox = null;
|
|
73
|
+
if (kind === "document" || kind === "layout" || kind === "viewport") this.synchronizeLayoutReservation();
|
|
74
|
+
this.client.update(snapshot, kind, change);
|
|
75
|
+
}
|
|
76
|
+
updateViewport(viewport) {
|
|
77
|
+
if (this.disposed || this.latestSnapshot.geometryCommitted === false) return;
|
|
78
|
+
this.latestViewport = viewport;
|
|
79
|
+
this.client.updateViewport(viewport);
|
|
80
|
+
}
|
|
81
|
+
dispose() {
|
|
82
|
+
if (this.disposed) return;
|
|
83
|
+
this.disposed = true;
|
|
84
|
+
this.stopSliderDrag();
|
|
85
|
+
this.wheelScrollRegistration.dispose();
|
|
86
|
+
this.decorationSubscription.dispose();
|
|
87
|
+
this.client.dispose();
|
|
88
|
+
this.context.reserveOverlayWidth(this.options.side, 0);
|
|
89
|
+
this.host.root.remove();
|
|
90
|
+
}
|
|
91
|
+
installPointerHandlers() {
|
|
92
|
+
this.host.root.addEventListener("pointerdown", this.handlePointerDown);
|
|
93
|
+
this.host.slider.addEventListener("pointerdown", this.handleSliderPointerDown);
|
|
94
|
+
}
|
|
95
|
+
reserveWidth = (_width) => {
|
|
96
|
+
if (this.context.getSnapshot().geometryCommitted === false) return;
|
|
97
|
+
this.scrollBox = null;
|
|
98
|
+
this.layoutSignature = "";
|
|
99
|
+
this.synchronizeLayoutReservation();
|
|
100
|
+
};
|
|
101
|
+
synchronizeLayoutReservation() {
|
|
102
|
+
const snapshot = this.latestSnapshot;
|
|
103
|
+
const scroll = this.measureScrollGeometry();
|
|
104
|
+
const { clientWidth, clientHeight } = scroll;
|
|
105
|
+
const signature = [
|
|
106
|
+
scroll.width,
|
|
107
|
+
scroll.height,
|
|
108
|
+
clientWidth,
|
|
109
|
+
clientHeight,
|
|
110
|
+
scroll.overflowsX,
|
|
111
|
+
scroll.overflowsY,
|
|
112
|
+
scroll.borders.left,
|
|
113
|
+
scroll.borders.right,
|
|
114
|
+
scroll.borders.top,
|
|
115
|
+
scroll.borders.bottom,
|
|
116
|
+
scroll.overlayScrollbars.vertical,
|
|
117
|
+
scroll.overlayScrollbars.horizontal,
|
|
118
|
+
snapshot.metrics.characterWidth,
|
|
119
|
+
snapshot.metrics.rowHeight,
|
|
120
|
+
this.context.scrollElement.ownerDocument.defaultView?.devicePixelRatio ?? 1,
|
|
121
|
+
this.options.size === "proportional" ? 0 : snapshot.lineCount
|
|
122
|
+
].join(":");
|
|
123
|
+
if (signature === this.layoutSignature) return;
|
|
124
|
+
this.layoutSignature = signature;
|
|
125
|
+
const minimapHeight = minimapViewportGeometry(this.options.side, 0, scroll).height;
|
|
126
|
+
const minimapWidth = Math.ceil(this.currentLayoutWidth(clientWidth, clientHeight, minimapHeight));
|
|
127
|
+
const geometry = minimapViewportGeometry(this.options.side, minimapWidth, scroll);
|
|
128
|
+
this.host.root.style.width = `${minimapWidth}px`;
|
|
129
|
+
this.host.root.style.top = `${geometry.top}px`;
|
|
130
|
+
this.host.root.style.height = `${geometry.height}px`;
|
|
131
|
+
const side = this.options.side;
|
|
132
|
+
this.host.root.style[side] = `${geometry[side]}px`;
|
|
133
|
+
const nextWidth = geometry.reservedWidth;
|
|
134
|
+
if (nextWidth === this.appliedReservedWidth) return;
|
|
135
|
+
const previousWidth = this.appliedReservedWidth;
|
|
136
|
+
this.appliedReservedWidth = nextWidth;
|
|
137
|
+
this.logLane(previousWidth, scroll, geometry);
|
|
138
|
+
this.context.reserveOverlayWidth(this.options.side, nextWidth);
|
|
139
|
+
}
|
|
140
|
+
measureScrollGeometry() {
|
|
141
|
+
const viewport = this.latestViewport;
|
|
142
|
+
const box = this.currentScrollBox();
|
|
143
|
+
return {
|
|
144
|
+
...box,
|
|
145
|
+
overflowsX: viewport.clientWidth > 0 && viewport.scrollWidth > viewport.clientWidth,
|
|
146
|
+
overflowsY: box.clientHeight > 0 && Math.max(viewport.scrollHeight, this.latestSnapshot.totalHeight) > box.clientHeight
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
currentScrollBox() {
|
|
150
|
+
const viewport = this.latestViewport;
|
|
151
|
+
const cached = this.scrollBox;
|
|
152
|
+
if (cached && scrollBoxMatchesViewport(cached, viewport)) return cached;
|
|
153
|
+
const element = this.context.scrollElement;
|
|
154
|
+
const style = element.ownerDocument.defaultView?.getComputedStyle(element);
|
|
155
|
+
const clientWidth = element.clientWidth || (viewport.clientWidth > 0 ? viewport.clientWidth + this.appliedReservedWidth : 0);
|
|
156
|
+
const clientHeight = element.clientHeight || viewport.clientHeight;
|
|
157
|
+
const box = {
|
|
158
|
+
width: element.offsetWidth || viewport.borderBoxWidth || clientWidth,
|
|
159
|
+
height: element.offsetHeight || viewport.borderBoxHeight || clientHeight,
|
|
160
|
+
clientWidth,
|
|
161
|
+
clientHeight,
|
|
162
|
+
borders: {
|
|
163
|
+
left: cssPixels(style?.borderLeftWidth),
|
|
164
|
+
right: cssPixels(style?.borderRightWidth),
|
|
165
|
+
top: cssPixels(style?.borderTopWidth),
|
|
166
|
+
bottom: cssPixels(style?.borderBottomWidth)
|
|
167
|
+
},
|
|
168
|
+
overlayScrollbars: overlayScrollbarDimensions(element, style)
|
|
169
|
+
};
|
|
170
|
+
this.scrollBox = box;
|
|
171
|
+
return box;
|
|
172
|
+
}
|
|
173
|
+
currentLayoutWidth(clientWidth, clientHeight, minimapHeight) {
|
|
174
|
+
const snapshot = this.latestSnapshot;
|
|
175
|
+
const element = this.context.scrollElement;
|
|
176
|
+
const range = visibleDocumentLineRange(snapshot, this.latestViewport);
|
|
177
|
+
return computeRenderLayout({
|
|
178
|
+
minimap: this.options,
|
|
179
|
+
lineCount: snapshot.lineCount,
|
|
180
|
+
metrics: {
|
|
181
|
+
...snapshot.metrics,
|
|
182
|
+
devicePixelRatio: element.ownerDocument.defaultView?.devicePixelRatio ?? 1
|
|
183
|
+
},
|
|
184
|
+
viewport: {
|
|
185
|
+
...this.latestViewport,
|
|
186
|
+
clientWidth,
|
|
187
|
+
clientHeight,
|
|
188
|
+
minimapHeight,
|
|
189
|
+
reservedWidth: 0,
|
|
190
|
+
visibleStart: range.start,
|
|
191
|
+
visibleEnd: range.end
|
|
192
|
+
}
|
|
193
|
+
}).width;
|
|
194
|
+
}
|
|
195
|
+
handlePointerDown = (event) => {
|
|
196
|
+
if (event.button !== 0) return;
|
|
197
|
+
if (this.context.getSnapshot().geometryCommitted === false) return;
|
|
198
|
+
if (event.target === this.host.slider || this.host.slider.contains(event.target)) return;
|
|
199
|
+
event.preventDefault();
|
|
200
|
+
const frame = this.client.frameLayout();
|
|
201
|
+
const y = event.clientY - this.host.root.getBoundingClientRect().top;
|
|
202
|
+
if (y >= frame.sliderTop && y <= frame.sliderTop + frame.sliderHeight) return;
|
|
203
|
+
const line = documentLineForSliderY(frame, y - frame.sliderHeight / 2);
|
|
204
|
+
this.revealDocumentLine(line);
|
|
205
|
+
};
|
|
206
|
+
handleSliderPointerDown = (event) => {
|
|
207
|
+
if (event.button !== 0) return;
|
|
208
|
+
if (this.context.getSnapshot().geometryCommitted === false) return;
|
|
209
|
+
event.preventDefault();
|
|
210
|
+
this.stopSliderDrag();
|
|
211
|
+
const startY = event.clientY;
|
|
212
|
+
const frame = this.client.frameLayout();
|
|
213
|
+
const startLine = documentLineForSliderY(frame, frame.sliderTop);
|
|
214
|
+
let moved = false;
|
|
215
|
+
const onMove = (move) => {
|
|
216
|
+
if (this.context.getSnapshot().geometryCommitted === false) {
|
|
217
|
+
this.stopSliderDrag();
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
if (!moved && move.clientY === startY) return;
|
|
221
|
+
if (frame.sliderLineHeight <= 0) return;
|
|
222
|
+
moved = true;
|
|
223
|
+
const line = startLine + (move.clientY - startY) / frame.sliderLineHeight;
|
|
224
|
+
this.scheduleSliderScroll(line);
|
|
225
|
+
};
|
|
226
|
+
const onEnd = () => this.stopSliderDrag();
|
|
227
|
+
this.captureSliderPointer(event.pointerId);
|
|
228
|
+
this.host.slider.classList.add("active");
|
|
229
|
+
this.activeSliderDrag = {
|
|
230
|
+
pointerId: event.pointerId,
|
|
231
|
+
onMove,
|
|
232
|
+
onEnd
|
|
233
|
+
};
|
|
234
|
+
this.host.slider.ownerDocument.addEventListener("pointermove", onMove);
|
|
235
|
+
this.host.slider.ownerDocument.addEventListener("pointerup", onEnd, { once: true });
|
|
236
|
+
this.host.slider.ownerDocument.addEventListener("pointercancel", onEnd, { once: true });
|
|
237
|
+
this.host.slider.addEventListener("lostpointercapture", onEnd, { once: true });
|
|
238
|
+
};
|
|
239
|
+
captureSliderPointer(pointerId) {
|
|
240
|
+
try {
|
|
241
|
+
this.host.slider.setPointerCapture(pointerId);
|
|
242
|
+
} catch {
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
stopSliderDrag() {
|
|
247
|
+
const drag = this.activeSliderDrag;
|
|
248
|
+
if (!drag) return;
|
|
249
|
+
this.activeSliderDrag = null;
|
|
250
|
+
this.cancelSliderScroll();
|
|
251
|
+
this.flushSliderScroll();
|
|
252
|
+
this.host.slider.ownerDocument.removeEventListener("pointermove", drag.onMove);
|
|
253
|
+
this.host.slider.ownerDocument.removeEventListener("pointerup", drag.onEnd);
|
|
254
|
+
this.host.slider.ownerDocument.removeEventListener("pointercancel", drag.onEnd);
|
|
255
|
+
this.host.slider.removeEventListener("lostpointercapture", drag.onEnd);
|
|
256
|
+
this.releaseSliderPointer(drag.pointerId);
|
|
257
|
+
this.host.slider.classList.remove("active");
|
|
258
|
+
}
|
|
259
|
+
scheduleSliderScroll(line) {
|
|
260
|
+
this.pendingSliderLine = line;
|
|
261
|
+
if (this.sliderScrollFrame !== 0) return;
|
|
262
|
+
this.sliderScrollFrame = requestFrame(() => {
|
|
263
|
+
this.sliderScrollFrame = 0;
|
|
264
|
+
this.flushSliderScroll();
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
flushSliderScroll() {
|
|
268
|
+
const line = this.pendingSliderLine;
|
|
269
|
+
this.pendingSliderLine = null;
|
|
270
|
+
if (line === null) return;
|
|
271
|
+
if (this.context.getSnapshot().geometryCommitted === false) return;
|
|
272
|
+
this.revealDocumentLine(line);
|
|
273
|
+
}
|
|
274
|
+
cancelSliderScroll() {
|
|
275
|
+
if (this.sliderScrollFrame === 0) return;
|
|
276
|
+
cancelFrame(this.sliderScrollFrame);
|
|
277
|
+
this.sliderScrollFrame = 0;
|
|
278
|
+
}
|
|
279
|
+
releaseSliderPointer(pointerId) {
|
|
280
|
+
if (!this.host.slider.hasPointerCapture(pointerId)) return;
|
|
281
|
+
try {
|
|
282
|
+
this.host.slider.releasePointerCapture(pointerId);
|
|
283
|
+
} catch {
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
revealDocumentLine(line) {
|
|
288
|
+
this.context.revealLine(clamp(Math.floor(line), 0, this.latestSnapshot.lineCount - 1));
|
|
289
|
+
}
|
|
290
|
+
logLane(previousWidth, scroll, geometry) {
|
|
291
|
+
const viewport = this.latestViewport;
|
|
292
|
+
this.context.log({
|
|
293
|
+
action: "editor.minimap.lane_changed",
|
|
294
|
+
level: "info",
|
|
295
|
+
minimap: {
|
|
296
|
+
documentId: this.latestSnapshot.documentId,
|
|
297
|
+
scrollElementClass: this.context.scrollElement.className,
|
|
298
|
+
containerClass: this.context.container.className,
|
|
299
|
+
appliedOverlayWidth: this.appliedReservedWidth,
|
|
300
|
+
availableWidth: scroll.clientWidth,
|
|
301
|
+
borderBoxWidth: viewport.borderBoxWidth ?? null,
|
|
302
|
+
clientWidth: viewport.clientWidth,
|
|
303
|
+
previousOverlayWidth: previousWidth,
|
|
304
|
+
side: this.options.side,
|
|
305
|
+
horizontalScrollbar: geometry.horizontalScrollbar,
|
|
306
|
+
verticalScrollbar: geometry.verticalScrollbar
|
|
307
|
+
}
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
handleDecorationsChanged = () => {
|
|
311
|
+
this.client.setExternalDecorations(this.collectDecorations());
|
|
312
|
+
};
|
|
313
|
+
collectDecorations() {
|
|
314
|
+
return mergeDenseDecorations(this.decorations.getDecorations(), this.latestViewport.clientHeight, this.latestSnapshot.lineCount);
|
|
315
|
+
}
|
|
316
|
+
};
|
|
317
|
+
var MinimapDecorationRegistry = class {
|
|
318
|
+
decorationsBySource = /* @__PURE__ */ new Map();
|
|
319
|
+
listeners = /* @__PURE__ */ new Set();
|
|
320
|
+
setDecorations(sourceId, decorations) {
|
|
321
|
+
this.decorationsBySource.set(sourceId, decorations);
|
|
322
|
+
this.notify();
|
|
323
|
+
}
|
|
324
|
+
clearDecorations(sourceId) {
|
|
325
|
+
if (!this.decorationsBySource.delete(sourceId)) return;
|
|
326
|
+
this.notify();
|
|
327
|
+
}
|
|
328
|
+
getDecorations() {
|
|
329
|
+
return Array.from(this.decorationsBySource.values()).flat();
|
|
330
|
+
}
|
|
331
|
+
subscribe(listener) {
|
|
332
|
+
this.listeners.add(listener);
|
|
333
|
+
return { dispose: () => this.listeners.delete(listener) };
|
|
334
|
+
}
|
|
335
|
+
notify() {
|
|
336
|
+
for (const listener of this.listeners) listener();
|
|
337
|
+
}
|
|
338
|
+
};
|
|
339
|
+
function createHost(context, options) {
|
|
340
|
+
const document = context.container.ownerDocument;
|
|
341
|
+
const root = document.createElement("div");
|
|
342
|
+
const shadow = document.createElement("div");
|
|
343
|
+
const mainCanvas = document.createElement("canvas");
|
|
344
|
+
const decorationsCanvas = document.createElement("canvas");
|
|
345
|
+
const slider = document.createElement("div");
|
|
346
|
+
const sliderHorizontal = document.createElement("div");
|
|
347
|
+
root.className = hostClassName(options);
|
|
348
|
+
shadow.className = "editor-minimap-shadow editor-minimap-shadow-hidden";
|
|
349
|
+
mainCanvas.className = "editor-minimap-canvas";
|
|
350
|
+
decorationsCanvas.className = "editor-minimap-canvas editor-minimap-decorations";
|
|
351
|
+
slider.className = "editor-minimap-slider";
|
|
352
|
+
sliderHorizontal.className = "editor-minimap-slider-horizontal";
|
|
353
|
+
slider.appendChild(sliderHorizontal);
|
|
354
|
+
root.append(shadow, mainCanvas, decorationsCanvas, slider);
|
|
355
|
+
if (getComputedStyle(context.container).position === "static") context.container.style.position = "relative";
|
|
356
|
+
context.container.appendChild(root);
|
|
357
|
+
return {
|
|
358
|
+
root,
|
|
359
|
+
colorScope: context.scrollElement,
|
|
360
|
+
shadow,
|
|
361
|
+
mainCanvas,
|
|
362
|
+
decorationsCanvas,
|
|
363
|
+
slider,
|
|
364
|
+
sliderHorizontal
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
function scrollBoxMatchesViewport(box, viewport) {
|
|
368
|
+
if (viewport.borderBoxWidth !== void 0 && viewport.borderBoxHeight !== void 0) return Math.round(viewport.borderBoxWidth) === box.width && Math.round(viewport.borderBoxHeight) === box.height;
|
|
369
|
+
return viewport.clientHeight <= 0 || viewport.clientHeight === box.clientHeight;
|
|
370
|
+
}
|
|
371
|
+
function hostClassName(options) {
|
|
372
|
+
const classes = ["editor-minimap", `editor-minimap-${options.side}`];
|
|
373
|
+
if (options.showSlider === "always") classes.push("slider-always");
|
|
374
|
+
if (options.showSlider === "mouseover") classes.push("slider-mouseover");
|
|
375
|
+
if (options.autohide !== "none") classes.push(`editor-minimap-autohide-${options.autohide}`);
|
|
376
|
+
return classes.join(" ");
|
|
377
|
+
}
|
|
378
|
+
function clamp(value, min, max) {
|
|
379
|
+
return Math.min(max, Math.max(min, value));
|
|
380
|
+
}
|
|
381
|
+
function requestFrame(callback) {
|
|
382
|
+
if (typeof requestAnimationFrame === "function") return requestAnimationFrame(callback);
|
|
383
|
+
return setTimeout(callback, 16);
|
|
384
|
+
}
|
|
385
|
+
function cancelFrame(handle) {
|
|
386
|
+
if (typeof cancelAnimationFrame === "function") {
|
|
387
|
+
cancelAnimationFrame(handle);
|
|
388
|
+
return;
|
|
389
|
+
}
|
|
390
|
+
clearTimeout(handle);
|
|
391
|
+
}
|
|
392
|
+
function overlayScrollbarDimensions(element, style) {
|
|
393
|
+
const keyword = style?.getPropertyValue("scrollbar-width").trim();
|
|
394
|
+
if (keyword === "none") return {
|
|
395
|
+
vertical: 0,
|
|
396
|
+
horizontal: 0
|
|
397
|
+
};
|
|
398
|
+
if (keyword === "thin") return {
|
|
399
|
+
vertical: 7,
|
|
400
|
+
horizontal: 7
|
|
401
|
+
};
|
|
402
|
+
const pseudo = element.ownerDocument.defaultView?.getComputedStyle(element, "::-webkit-scrollbar");
|
|
403
|
+
return {
|
|
404
|
+
vertical: cssPixels(pseudo?.width, 15),
|
|
405
|
+
horizontal: cssPixels(pseudo?.height, 15)
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
function cssPixels(value, fallback = 0) {
|
|
409
|
+
const parsed = Number.parseFloat(value ?? "");
|
|
410
|
+
return Number.isFinite(parsed) ? Math.max(0, parsed) : fallback;
|
|
411
|
+
}
|
|
412
|
+
//#endregion
|
|
413
|
+
export { createMinimapPlugin };
|
|
414
|
+
|
|
415
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","names":[],"sources":["../src/plugin.ts"],"sourcesContent":["import type {\n EditorContributionChange,\n EditorDisposable,\n EditorCapabilityContribution,\n EditorCapabilityContributionContext,\n EditorMinimapDecoration,\n EditorMinimapFeature,\n EditorPlugin,\n EditorViewContribution,\n EditorViewContributionContext,\n EditorViewContributionUpdateKind,\n EditorViewSnapshot,\n EditorViewportSnapshot,\n} from '@singapore-editor/core/extensions'\nimport {\n EDITOR_MINIMAP_FEATURE,\n registerWheelScrollTarget,\n} from '@singapore-editor/core/extensions'\nimport { mergeDenseDecorations } from './decorationMerge'\nimport { computeRenderLayout, documentLineForSliderY, visibleDocumentLineRange } from './layout'\nimport { resolveMinimapOptions } from './options'\nimport type { EditorMinimapOptions, ResolvedMinimapOptions } from './types'\nimport { minimapViewportGeometry, type MinimapScrollGeometry } from './viewportGeometry'\nimport { canUseMinimapWorker, MinimapWorkerClient, type MinimapHost } from './workerClient'\n\nexport function createMinimapPlugin(options: EditorMinimapOptions = {}): EditorPlugin {\n const resolved = resolveMinimapOptions(options)\n const decorations = new MinimapDecorationRegistry()\n\n return {\n name: 'minimap',\n activate(context) {\n return [\n context.registerCapabilityContribution({\n createContribution: (contributionContext) =>\n createMinimapFeatureContribution(contributionContext, decorations),\n }),\n context.registerViewContribution({\n createContribution: (contributionContext) =>\n createMinimapContribution(contributionContext, resolved, decorations),\n }),\n ]\n },\n }\n}\n\nfunction createMinimapFeatureContribution(\n context: EditorCapabilityContributionContext,\n decorations: MinimapDecorationRegistry,\n): EditorCapabilityContribution {\n const registration = context.registerFeature(EDITOR_MINIMAP_FEATURE, decorations)\n\n return {\n dispose: () => registration.dispose(),\n }\n}\n\nfunction createMinimapContribution(\n context: EditorViewContributionContext,\n options: ResolvedMinimapOptions,\n decorations: MinimapDecorationRegistry,\n): EditorViewContribution | null {\n if (!options.enabled) return null\n if (!canUseMinimapWorker()) return null\n\n return new MinimapContribution(context, options, decorations)\n}\n\nclass MinimapContribution implements EditorViewContribution {\n public readonly snapshotKey: string\n private readonly context: EditorViewContributionContext\n private readonly options: ResolvedMinimapOptions\n private readonly host: MinimapHost\n private readonly client: MinimapWorkerClient\n private readonly decorationSubscription: EditorDisposable\n private readonly wheelScrollRegistration: EditorDisposable\n private latestSnapshot: EditorViewSnapshot\n private latestViewport: EditorViewportSnapshot\n private activeSliderDrag: SliderDrag | null = null\n private appliedReservedWidth = 0\n private layoutSignature = ''\n private scrollBox: MinimapScrollBox | null = null\n private pendingSliderLine: number | null = null\n private sliderScrollFrame = 0\n private disposed = false\n\n public constructor(\n context: EditorViewContributionContext,\n options: ResolvedMinimapOptions,\n private readonly decorations: MinimapDecorationRegistry,\n ) {\n this.context = context\n this.options = options\n this.snapshotKey = `minimap:${JSON.stringify(options)}`\n this.latestSnapshot = context.getSnapshot()\n this.latestViewport = this.latestSnapshot.viewport\n this.host = createHost(context, options)\n if (this.latestSnapshot.geometryCommitted !== false) this.synchronizeLayoutReservation()\n this.client = new MinimapWorkerClient({\n host: this.host,\n options,\n snapshot: this.latestSnapshot,\n decorations: this.collectDecorations(),\n onLayoutWidth: this.reserveWidth,\n reservedLane: () => this.appliedReservedWidth,\n })\n this.decorationSubscription = decorations.subscribe(this.handleDecorationsChanged)\n this.wheelScrollRegistration = registerWheelScrollTarget(context, this.host.root)\n this.installPointerHandlers()\n this.client.update(this.latestSnapshot, 'document')\n }\n\n public update(\n snapshot: EditorViewSnapshot,\n kind: EditorViewContributionUpdateKind,\n change?: EditorContributionChange | null,\n ): void {\n if (this.disposed) return\n\n this.latestSnapshot = snapshot\n this.latestViewport = snapshot.viewport\n if (snapshot.geometryCommitted === false) return\n if (kind === 'document' || kind === 'layout') this.scrollBox = null\n if (kind === 'document' || kind === 'layout' || kind === 'viewport') {\n this.synchronizeLayoutReservation()\n }\n this.client.update(snapshot, kind, change)\n }\n\n public updateViewport(viewport: EditorViewportSnapshot): void {\n if (this.disposed || this.latestSnapshot.geometryCommitted === false) return\n this.latestViewport = viewport\n this.client.updateViewport(viewport)\n }\n\n public dispose(): void {\n if (this.disposed) return\n\n this.disposed = true\n this.stopSliderDrag()\n this.wheelScrollRegistration.dispose()\n this.decorationSubscription.dispose()\n this.client.dispose()\n this.context.reserveOverlayWidth(this.options.side, 0)\n this.host.root.remove()\n }\n\n private installPointerHandlers(): void {\n this.host.root.addEventListener('pointerdown', this.handlePointerDown)\n this.host.slider.addEventListener('pointerdown', this.handleSliderPointerDown)\n }\n\n private readonly reserveWidth = (_width: number): void => {\n if (this.context.getSnapshot().geometryCommitted === false) return\n this.scrollBox = null\n this.layoutSignature = ''\n this.synchronizeLayoutReservation()\n }\n\n private synchronizeLayoutReservation(): void {\n const snapshot = this.latestSnapshot\n const scroll = this.measureScrollGeometry()\n const { clientWidth, clientHeight } = scroll\n const signature = [\n scroll.width,\n scroll.height,\n clientWidth,\n clientHeight,\n scroll.overflowsX,\n scroll.overflowsY,\n scroll.borders.left,\n scroll.borders.right,\n scroll.borders.top,\n scroll.borders.bottom,\n scroll.overlayScrollbars.vertical,\n scroll.overlayScrollbars.horizontal,\n snapshot.metrics.characterWidth,\n snapshot.metrics.rowHeight,\n this.context.scrollElement.ownerDocument.defaultView?.devicePixelRatio ?? 1,\n this.options.size === 'proportional' ? 0 : snapshot.lineCount,\n ].join(':')\n if (signature === this.layoutSignature) return\n this.layoutSignature = signature\n const minimapHeight = minimapViewportGeometry(this.options.side, 0, scroll).height\n const minimapWidth = Math.ceil(\n this.currentLayoutWidth(clientWidth, clientHeight, minimapHeight),\n )\n const geometry = minimapViewportGeometry(this.options.side, minimapWidth, scroll)\n this.host.root.style.width = `${minimapWidth}px`\n this.host.root.style.top = `${geometry.top}px`\n this.host.root.style.height = `${geometry.height}px`\n const side = this.options.side\n this.host.root.style[side] = `${geometry[side]}px`\n const nextWidth = geometry.reservedWidth\n if (nextWidth === this.appliedReservedWidth) return\n\n const previousWidth = this.appliedReservedWidth\n this.appliedReservedWidth = nextWidth\n this.logLane(previousWidth, scroll, geometry)\n this.context.reserveOverlayWidth(this.options.side, nextWidth)\n }\n\n private measureScrollGeometry(): MinimapScrollGeometry {\n const viewport = this.latestViewport\n const box = this.currentScrollBox()\n return {\n ...box,\n overflowsX: viewport.clientWidth > 0 && viewport.scrollWidth > viewport.clientWidth,\n overflowsY:\n box.clientHeight > 0 &&\n Math.max(viewport.scrollHeight, this.latestSnapshot.totalHeight) > box.clientHeight,\n }\n }\n\n // The box is read from the DOM (computed style and a forced layout) only when something could\n // have changed it: a document or layout update, a lane change, or a viewport whose height or\n // border box no longer matches. A scroll reuses the last measurement.\n private currentScrollBox(): MinimapScrollBox {\n const viewport = this.latestViewport\n const cached = this.scrollBox\n if (cached && scrollBoxMatchesViewport(cached, viewport)) return cached\n\n const element = this.context.scrollElement\n const style = element.ownerDocument.defaultView?.getComputedStyle(element)\n const clientWidth =\n element.clientWidth ||\n (viewport.clientWidth > 0 ? viewport.clientWidth + this.appliedReservedWidth : 0)\n const clientHeight = element.clientHeight || viewport.clientHeight\n const box: MinimapScrollBox = {\n width: element.offsetWidth || viewport.borderBoxWidth || clientWidth,\n height: element.offsetHeight || viewport.borderBoxHeight || clientHeight,\n clientWidth,\n clientHeight,\n borders: {\n left: cssPixels(style?.borderLeftWidth),\n right: cssPixels(style?.borderRightWidth),\n top: cssPixels(style?.borderTopWidth),\n bottom: cssPixels(style?.borderBottomWidth),\n },\n overlayScrollbars: overlayScrollbarDimensions(element, style),\n }\n this.scrollBox = box\n return box\n }\n\n private currentLayoutWidth(\n clientWidth: number,\n clientHeight: number,\n minimapHeight: number,\n ): number {\n const snapshot = this.latestSnapshot\n const element = this.context.scrollElement\n const range = visibleDocumentLineRange(snapshot, this.latestViewport)\n return computeRenderLayout({\n minimap: this.options,\n lineCount: snapshot.lineCount,\n metrics: {\n ...snapshot.metrics,\n devicePixelRatio: element.ownerDocument.defaultView?.devicePixelRatio ?? 1,\n },\n viewport: {\n ...this.latestViewport,\n clientWidth,\n clientHeight,\n minimapHeight,\n reservedWidth: 0,\n visibleStart: range.start,\n visibleEnd: range.end,\n },\n }).width\n }\n\n private readonly handlePointerDown = (event: PointerEvent): void => {\n if (event.button !== 0) return\n if (this.context.getSnapshot().geometryCommitted === false) return\n if (event.target === this.host.slider || this.host.slider.contains(event.target as Node)) return\n\n event.preventDefault()\n const frame = this.client.frameLayout()\n const y = event.clientY - this.host.root.getBoundingClientRect().top\n if (y >= frame.sliderTop && y <= frame.sliderTop + frame.sliderHeight) return\n const line = documentLineForSliderY(frame, y - frame.sliderHeight / 2)\n this.revealDocumentLine(line)\n }\n\n private readonly handleSliderPointerDown = (event: PointerEvent): void => {\n if (event.button !== 0) return\n if (this.context.getSnapshot().geometryCommitted === false) return\n\n event.preventDefault()\n this.stopSliderDrag()\n const startY = event.clientY\n const frame = this.client.frameLayout()\n const startLine = documentLineForSliderY(frame, frame.sliderTop)\n\n let moved = false\n const onMove = (move: PointerEvent): void => {\n if (this.context.getSnapshot().geometryCommitted === false) {\n this.stopSliderDrag()\n return\n }\n if (!moved && move.clientY === startY) return\n if (frame.sliderLineHeight <= 0) return\n moved = true\n const line = startLine + (move.clientY - startY) / frame.sliderLineHeight\n this.scheduleSliderScroll(line)\n }\n const onEnd = (): void => this.stopSliderDrag()\n\n this.captureSliderPointer(event.pointerId)\n this.host.slider.classList.add('active')\n this.activeSliderDrag = { pointerId: event.pointerId, onMove, onEnd }\n this.host.slider.ownerDocument.addEventListener('pointermove', onMove)\n this.host.slider.ownerDocument.addEventListener('pointerup', onEnd, { once: true })\n this.host.slider.ownerDocument.addEventListener('pointercancel', onEnd, { once: true })\n this.host.slider.addEventListener('lostpointercapture', onEnd, { once: true })\n }\n\n private captureSliderPointer(pointerId: number): void {\n try {\n this.host.slider.setPointerCapture(pointerId)\n } catch {\n return\n }\n }\n\n private stopSliderDrag(): void {\n const drag = this.activeSliderDrag\n if (!drag) return\n\n this.activeSliderDrag = null\n this.cancelSliderScroll()\n this.flushSliderScroll()\n this.host.slider.ownerDocument.removeEventListener('pointermove', drag.onMove)\n this.host.slider.ownerDocument.removeEventListener('pointerup', drag.onEnd)\n this.host.slider.ownerDocument.removeEventListener('pointercancel', drag.onEnd)\n this.host.slider.removeEventListener('lostpointercapture', drag.onEnd)\n this.releaseSliderPointer(drag.pointerId)\n this.host.slider.classList.remove('active')\n }\n\n private scheduleSliderScroll(line: number): void {\n this.pendingSliderLine = line\n if (this.sliderScrollFrame !== 0) return\n\n this.sliderScrollFrame = requestFrame(() => {\n this.sliderScrollFrame = 0\n this.flushSliderScroll()\n })\n }\n\n private flushSliderScroll(): void {\n const line = this.pendingSliderLine\n this.pendingSliderLine = null\n if (line === null) return\n if (this.context.getSnapshot().geometryCommitted === false) return\n\n this.revealDocumentLine(line)\n }\n\n private cancelSliderScroll(): void {\n if (this.sliderScrollFrame === 0) return\n\n cancelFrame(this.sliderScrollFrame)\n this.sliderScrollFrame = 0\n }\n\n private releaseSliderPointer(pointerId: number): void {\n if (!this.host.slider.hasPointerCapture(pointerId)) return\n\n try {\n this.host.slider.releasePointerCapture(pointerId)\n } catch {\n return\n }\n }\n\n private revealDocumentLine(line: number): void {\n this.context.revealLine(clamp(Math.floor(line), 0, this.latestSnapshot.lineCount - 1))\n }\n\n private logLane(\n previousWidth: number,\n scroll: MinimapScrollGeometry,\n geometry: ReturnType<typeof minimapViewportGeometry>,\n ): void {\n const viewport = this.latestViewport\n this.context.log({\n action: 'editor.minimap.lane_changed',\n level: 'info',\n minimap: {\n documentId: this.latestSnapshot.documentId,\n scrollElementClass: this.context.scrollElement.className,\n containerClass: this.context.container.className,\n appliedOverlayWidth: this.appliedReservedWidth,\n availableWidth: scroll.clientWidth,\n borderBoxWidth: viewport.borderBoxWidth ?? null,\n clientWidth: viewport.clientWidth,\n previousOverlayWidth: previousWidth,\n side: this.options.side,\n horizontalScrollbar: geometry.horizontalScrollbar,\n verticalScrollbar: geometry.verticalScrollbar,\n },\n })\n }\n\n private readonly handleDecorationsChanged = (): void => {\n this.client.setExternalDecorations(this.collectDecorations())\n }\n\n // The height a whole document is projected onto is the editor's own, so how\n // dense a source is on screen is answerable from the snapshot, without\n // waiting on the worker that owns the render layout.\n private collectDecorations(): readonly EditorMinimapDecoration[] {\n return mergeDenseDecorations(\n this.decorations.getDecorations(),\n this.latestViewport.clientHeight,\n this.latestSnapshot.lineCount,\n )\n }\n}\n\nclass MinimapDecorationRegistry implements EditorMinimapFeature {\n private readonly decorationsBySource = new Map<string, readonly EditorMinimapDecoration[]>()\n private readonly listeners = new Set<() => void>()\n\n public setDecorations(sourceId: string, decorations: readonly EditorMinimapDecoration[]): void {\n this.decorationsBySource.set(sourceId, decorations)\n this.notify()\n }\n\n public clearDecorations(sourceId: string): void {\n if (!this.decorationsBySource.delete(sourceId)) return\n\n this.notify()\n }\n\n public getDecorations(): readonly EditorMinimapDecoration[] {\n return Array.from(this.decorationsBySource.values()).flat()\n }\n\n public subscribe(listener: () => void): EditorDisposable {\n this.listeners.add(listener)\n return {\n dispose: () => this.listeners.delete(listener),\n }\n }\n\n private notify(): void {\n for (const listener of this.listeners) listener()\n }\n}\n\ntype SliderDrag = {\n readonly pointerId: number\n readonly onMove: (event: PointerEvent) => void\n readonly onEnd: () => void\n}\n\nfunction createHost(\n context: EditorViewContributionContext,\n options: ResolvedMinimapOptions,\n): MinimapHost {\n const document = context.container.ownerDocument\n const root = document.createElement('div')\n const shadow = document.createElement('div')\n const mainCanvas = document.createElement('canvas')\n const decorationsCanvas = document.createElement('canvas')\n const slider = document.createElement('div')\n const sliderHorizontal = document.createElement('div')\n\n root.className = hostClassName(options)\n shadow.className = 'editor-minimap-shadow editor-minimap-shadow-hidden'\n mainCanvas.className = 'editor-minimap-canvas'\n decorationsCanvas.className = 'editor-minimap-canvas editor-minimap-decorations'\n slider.className = 'editor-minimap-slider'\n sliderHorizontal.className = 'editor-minimap-slider-horizontal'\n slider.appendChild(sliderHorizontal)\n root.append(shadow, mainCanvas, decorationsCanvas, slider)\n if (getComputedStyle(context.container).position === 'static') {\n context.container.style.position = 'relative'\n }\n context.container.appendChild(root)\n\n return {\n root,\n colorScope: context.scrollElement,\n shadow,\n mainCanvas,\n decorationsCanvas,\n slider,\n sliderHorizontal,\n }\n}\n\ntype MinimapScrollBox = Omit<MinimapScrollGeometry, 'overflowsX' | 'overflowsY'>\n\nfunction scrollBoxMatchesViewport(\n box: MinimapScrollBox,\n viewport: EditorViewportSnapshot,\n): boolean {\n // ResizeObserver retains fractional pixels; offsetWidth/Height round them to integers.\n if (viewport.borderBoxWidth !== undefined && viewport.borderBoxHeight !== undefined) {\n return (\n Math.round(viewport.borderBoxWidth) === box.width &&\n Math.round(viewport.borderBoxHeight) === box.height\n )\n }\n return viewport.clientHeight <= 0 || viewport.clientHeight === box.clientHeight\n}\n\nfunction hostClassName(options: ResolvedMinimapOptions): string {\n const classes = ['editor-minimap', `editor-minimap-${options.side}`]\n if (options.showSlider === 'always') classes.push('slider-always')\n if (options.showSlider === 'mouseover') classes.push('slider-mouseover')\n if (options.autohide !== 'none') classes.push(`editor-minimap-autohide-${options.autohide}`)\n return classes.join(' ')\n}\n\nfunction clamp(value: number, min: number, max: number): number {\n return Math.min(max, Math.max(min, value))\n}\n\nfunction requestFrame(callback: () => void): number {\n if (typeof requestAnimationFrame === 'function') return requestAnimationFrame(callback)\n return setTimeout(callback, 16) as unknown as number\n}\n\nfunction cancelFrame(handle: number): void {\n if (typeof cancelAnimationFrame === 'function') {\n cancelAnimationFrame(handle)\n return\n }\n\n clearTimeout(handle)\n}\n\nfunction overlayScrollbarDimensions(\n element: HTMLElement,\n style: CSSStyleDeclaration | undefined,\n): MinimapScrollGeometry['overlayScrollbars'] {\n const keyword = style?.getPropertyValue('scrollbar-width').trim()\n if (keyword === 'none') return { vertical: 0, horizontal: 0 }\n if (keyword === 'thin') return { vertical: 7, horizontal: 7 }\n\n const pseudo = element.ownerDocument.defaultView?.getComputedStyle(element, '::-webkit-scrollbar')\n return {\n vertical: cssPixels(pseudo?.width, 15),\n horizontal: cssPixels(pseudo?.height, 15),\n }\n}\n\nfunction cssPixels(value: string | undefined, fallback = 0): number {\n const parsed = Number.parseFloat(value ?? '')\n return Number.isFinite(parsed) ? Math.max(0, parsed) : fallback\n}\n"],"mappings":";;;;;;;AAyBA,SAAgB,oBAAoB,UAAgC,CAAC,GAAiB;CACpF,MAAM,WAAW,sBAAsB,OAAO;CAC9C,MAAM,cAAc,IAAI,0BAA0B;CAElD,OAAO;EACL,MAAM;EACN,SAAS,SAAS;GAChB,OAAO,CACL,QAAQ,+BAA+B,EACrC,qBAAqB,wBACnB,iCAAiC,qBAAqB,WAAW,EACrE,CAAC,GACD,QAAQ,yBAAyB,EAC/B,qBAAqB,wBACnB,0BAA0B,qBAAqB,UAAU,WAAW,EACxE,CAAC,CACH;EACF;CACF;AACF;AAEA,SAAS,iCACP,SACA,aAC8B;CAC9B,MAAM,eAAe,QAAQ,gBAAgB,w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QAAQ,OAAO;EAAE,UAAU;EAAG,YAAY;CAAE;CAC5D,IAAI,YAAY,QAAQ,OAAO;EAAE,UAAU;EAAG,YAAY;CAAE;CAE5D,MAAM,SAAS,QAAQ,cAAc,aAAa,iBAAiB,SAAS,qBAAqB;CACjG,OAAO;EACL,UAAU,UAAU,QAAQ,OAAO,EAAE;EACrC,YAAY,UAAU,QAAQ,QAAQ,EAAE;CAC1C;AACF;AAEA,SAAS,UAAU,OAA2B,WAAW,GAAW;CAClE,MAAM,SAAS,OAAO,WAAW,SAAS,EAAE;CAC5C,OAAO,OAAO,SAAS,MAAM,IAAI,KAAK,IAAI,GAAG,MAAM,IAAI;AACzD"}
|
package/dist/raster.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { RGBA8 } from './types';
|
|
2
|
+
export declare class RasterBuffer {
|
|
3
|
+
readonly imageData: ImageData;
|
|
4
|
+
private readonly pixels;
|
|
5
|
+
private readonly background;
|
|
6
|
+
constructor(context: OffscreenCanvasRenderingContext2D, width: number, height: number, background: RGBA8);
|
|
7
|
+
clearRows(start: number, end: number): void;
|
|
8
|
+
copyRows(source: number, destination: number, count: number): void;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=raster.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"raster.d.ts","sourceRoot":"","sources":["../src/raster.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAEpC,qBAAa,YAAY;IACvB,SAAgB,SAAS,EAAE,SAAS,CAAA;IACpC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAa;IACpC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAQ;gBAGjC,OAAO,EAAE,iCAAiC,EAC1C,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,KAAK;IAQZ,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI;IAI3C,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;CAI1E"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { TextEdit } from '@singapore-editor/core/document';
|
|
2
|
+
import type { EditorMinimapDecoration, MinimapBaseStyles, MinimapDocumentEditPayload, MinimapDocumentPayload, MinimapMetrics, MinimapRenderLayout, MinimapSelection, MinimapToken, MinimapTokenPatch, MinimapViewport, ResolvedMinimapOptions } from './types';
|
|
3
|
+
export declare class MinimapWorkerRenderer {
|
|
4
|
+
private state;
|
|
5
|
+
init(options: {
|
|
6
|
+
readonly mainCanvas: OffscreenCanvas;
|
|
7
|
+
readonly decorationsCanvas: OffscreenCanvas;
|
|
8
|
+
readonly options: ResolvedMinimapOptions;
|
|
9
|
+
readonly styles: MinimapBaseStyles;
|
|
10
|
+
}): void;
|
|
11
|
+
setDocument(document: MinimapDocumentPayload): void;
|
|
12
|
+
applyEdit(edit: TextEdit, document: MinimapDocumentEditPayload): void;
|
|
13
|
+
applyEdits(edits: readonly TextEdit[], document: MinimapDocumentEditPayload): void;
|
|
14
|
+
setExternalDecorations(decorations: readonly EditorMinimapDecoration[]): void;
|
|
15
|
+
private setEditedDocument;
|
|
16
|
+
setBaseStyles(styles: MinimapBaseStyles): void;
|
|
17
|
+
setTokens(tokens: readonly MinimapToken[]): void;
|
|
18
|
+
updateTokenRange(patch: MinimapTokenPatch): void;
|
|
19
|
+
setSelections(selections: readonly MinimapSelection[]): void;
|
|
20
|
+
setDecorations(decorations: readonly EditorMinimapDecoration[]): void;
|
|
21
|
+
updateLayout(metrics: MinimapMetrics, viewport: MinimapViewport): MinimapRenderLayout | null;
|
|
22
|
+
updateViewport(viewport: MinimapViewport): MinimapRenderLayout | null;
|
|
23
|
+
render(): RenderResult | null;
|
|
24
|
+
dispose(): void;
|
|
25
|
+
private createRenderLayout;
|
|
26
|
+
private renderLines;
|
|
27
|
+
private rasterForLayout;
|
|
28
|
+
private renderLineRange;
|
|
29
|
+
private tokenCursorForOffset;
|
|
30
|
+
private renderLine;
|
|
31
|
+
private renderDecorations;
|
|
32
|
+
private renderSelectionHighlights;
|
|
33
|
+
private renderMinimapDecorations;
|
|
34
|
+
private renderSectionHeaders;
|
|
35
|
+
private minimapLineCount;
|
|
36
|
+
private documentLineForRasterLine;
|
|
37
|
+
private lineText;
|
|
38
|
+
private lineStartOffset;
|
|
39
|
+
private offsetRangeToLineRange;
|
|
40
|
+
private lineNumberForOffset;
|
|
41
|
+
private resizeCanvases;
|
|
42
|
+
private surfaceForLayout;
|
|
43
|
+
private presentSurface;
|
|
44
|
+
private requireState;
|
|
45
|
+
}
|
|
46
|
+
type RenderResult = {
|
|
47
|
+
readonly sliderNeeded: boolean;
|
|
48
|
+
readonly sliderTop: number;
|
|
49
|
+
readonly sliderHeight: number;
|
|
50
|
+
readonly shadowVisible: boolean;
|
|
51
|
+
};
|
|
52
|
+
export declare function projectMinimapTokensThroughEdit(tokens: readonly MinimapToken[], edit: TextEdit, previousText: MinimapTokenProjectionText): readonly MinimapToken[];
|
|
53
|
+
type MinimapTokenProjectionText = string | {
|
|
54
|
+
isWordBeforeOffset(offset: number): boolean;
|
|
55
|
+
isWordCodePointAt(offset: number): boolean;
|
|
56
|
+
};
|
|
57
|
+
export {};
|
|
58
|
+
//# sourceMappingURL=renderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../src/renderer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAA;AAc/D,OAAO,KAAK,EACV,uBAAuB,EACvB,iBAAiB,EACjB,0BAA0B,EAC1B,sBAAsB,EAGtB,cAAc,EACd,mBAAmB,EACnB,gBAAgB,EAChB,YAAY,EACZ,iBAAiB,EACjB,eAAe,EACf,sBAAsB,EAEvB,MAAM,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IA+CvB,OAAO,CAAC,oBAAoB;IAS5B,OAAO,CAAC,UAAU;IAqBlB,OAAO,CAAC,iBAAiB;IAgBzB,OAAO,CAAC,yBAAyB;IAejC,OAAO,CAAC,wBAAwB;IAiBhC,OAAO,CAAC,oBAAoB;IAkB5B,OAAO,CAAC,gBAAgB;IAMxB,OAAO,CAAC,yBAAyB;IAMjC,OAAO,CAAC,QAAQ;IAKhB,OAAO,CAAC,eAAe;IAKvB,OAAO,CAAC,sBAAsB;IAO9B,OAAO,CAAC,mBAAmB;IAkB3B,OAAO,CAAC,cAAc;IAMtB,OAAO,CAAC,gBAAgB;IAQxB,OAAO,CAAC,cAAc;IAiBtB,OAAO,CAAC,YAAY;CAIrB;AAED,KAAK,YAAY,GAAG;IAClB,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAA;IAC9B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;IAC7B,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAA;CAChC,CAAA;AAonBD,wBAAgB,+BAA+B,CAC7C,MAAM,EAAE,SAAS,YAAY,EAAE,EAC/B,IAAI,EAAE,QAAQ,EACd,YAAY,EAAE,0BAA0B,GACvC,SAAS,YAAY,EAAE,CAQzB;AAuED,KAAK,0BAA0B,GAC3B,MAAM,GACN;IACE,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAA;IAC3C,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAA;CAC3C,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { EditorMinimapDecoration, ResolvedMinimapOptions } from './types';
|
|
2
|
+
export type SectionHeader = {
|
|
3
|
+
readonly startLineNumber: number;
|
|
4
|
+
readonly startColumn: number;
|
|
5
|
+
readonly endLineNumber: number;
|
|
6
|
+
readonly endColumn: number;
|
|
7
|
+
readonly text: string;
|
|
8
|
+
readonly hasSeparatorLine: boolean;
|
|
9
|
+
};
|
|
10
|
+
export declare function findSectionHeaderDecorations(lines: readonly string[], options: ResolvedMinimapOptions): EditorMinimapDecoration[];
|
|
11
|
+
export declare function findSectionHeaderDecorationsInRange(lines: readonly string[], startLineNumber: number, options: ResolvedMinimapOptions): EditorMinimapDecoration[];
|
|
12
|
+
export declare function collectMarkHeaders(lines: readonly string[], markSectionHeaderRegex: string): SectionHeader[];
|
|
13
|
+
//# sourceMappingURL=sectionHeaders.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sectionHeaders.d.ts","sourceRoot":"","sources":["../src/sectionHeaders.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,uBAAuB,EAEvB,sBAAsB,EACvB,MAAM,SAAS,CAAA;AAEhB,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAA;IAChC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAA;IAC9B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAA;CACnC,CAAA;AAKD,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,OAAO,EAAE,sBAAsB,GAC9B,uBAAuB,EAAE,CAI3B;AAED,wBAAgB,mCAAmC,CACjD,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,eAAe,EAAE,MAAM,EACvB,OAAO,EAAE,sBAAsB,GAC9B,uBAAuB,EAAE,CAI3B;AAED,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,sBAAsB,EAAE,MAAM,GAC7B,aAAa,EAAE,CAYjB"}
|
package/dist/style.css
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
.editor-minimap {
|
|
2
|
+
--editor-minimap-background: #1e1e1e;
|
|
3
|
+
--editor-minimap-background-opacity: 0.5;
|
|
4
|
+
--editor-minimap-selection-highlight: rgba(56, 189, 248, 0.5);
|
|
5
|
+
--editor-minimap-slider-background: rgba(121, 121, 121, 0.12);
|
|
6
|
+
--editor-minimap-slider-hover-background: rgba(121, 121, 121, 0.2);
|
|
7
|
+
--editor-minimap-slider-active-background: rgba(121, 121, 121, 0.3);
|
|
8
|
+
|
|
9
|
+
bottom: 0;
|
|
10
|
+
overflow: hidden;
|
|
11
|
+
position: absolute;
|
|
12
|
+
top: 0;
|
|
13
|
+
z-index: 5;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.editor-minimap-right {
|
|
17
|
+
right: 0;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.editor-minimap-left {
|
|
21
|
+
left: 0;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.editor[data-editor-presentation='provisional'] ~ .editor-minimap {
|
|
25
|
+
visibility: hidden;
|
|
26
|
+
pointer-events: none;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.editor-minimap-canvas,
|
|
30
|
+
.editor-minimap-slider,
|
|
31
|
+
.editor-minimap-shadow {
|
|
32
|
+
left: 0;
|
|
33
|
+
position: absolute;
|
|
34
|
+
top: 0;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.editor-minimap-decorations {
|
|
38
|
+
pointer-events: none;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.editor-minimap-slider {
|
|
42
|
+
contain: strict;
|
|
43
|
+
cursor: default;
|
|
44
|
+
width: 100%;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.editor-minimap-slider-horizontal {
|
|
48
|
+
background: var(--editor-minimap-slider-background);
|
|
49
|
+
height: 100%;
|
|
50
|
+
width: 100%;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.editor-minimap-slider:hover .editor-minimap-slider-horizontal {
|
|
54
|
+
background: var(--editor-minimap-slider-hover-background);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.editor-minimap-slider.active .editor-minimap-slider-horizontal {
|
|
58
|
+
background: var(--editor-minimap-slider-active-background);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.editor-minimap.slider-mouseover .editor-minimap-slider {
|
|
62
|
+
opacity: 0;
|
|
63
|
+
transition: opacity 100ms linear;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.editor-minimap.slider-mouseover:hover .editor-minimap-slider,
|
|
67
|
+
.editor-minimap.slider-mouseover .editor-minimap-slider.active {
|
|
68
|
+
opacity: 1;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.editor-minimap-shadow-hidden {
|
|
72
|
+
width: 0;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.editor-minimap-shadow-visible {
|
|
76
|
+
box-shadow: -6px 0 6px rgba(0, 0, 0, 0.35);
|
|
77
|
+
height: 100%;
|
|
78
|
+
left: -6px;
|
|
79
|
+
pointer-events: none;
|
|
80
|
+
width: 6px;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.editor-minimap-autohide-mouseover,
|
|
84
|
+
.editor-minimap-autohide-scroll {
|
|
85
|
+
opacity: 0;
|
|
86
|
+
transition: opacity 0.5s;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.editor-minimap-autohide-scroll {
|
|
90
|
+
pointer-events: none;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.editor-minimap-autohide-mouseover:hover,
|
|
94
|
+
.editor-minimap-autohide-scroll.active {
|
|
95
|
+
opacity: 1;
|
|
96
|
+
pointer-events: auto;
|
|
97
|
+
}
|