gitmaps 1.1.16 → 1.1.17
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/app/lib/viewport-culling.ts +48 -2
- package/package.json +1 -1
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
*/
|
|
24
24
|
import { measure } from 'measure-fn';
|
|
25
25
|
import type { CanvasContext } from './context';
|
|
26
|
-
import { estimatePreviewMaxScroll, getLowZoomScale, renderLowZoomPreviewCanvas } from './low-zoom-preview';
|
|
26
|
+
import { collectPreviewDiffMarkers, estimatePreviewMaxScroll, getLowZoomScale, getPreviewScrollMetrics, renderLowZoomPreviewCanvas } from './low-zoom-preview';
|
|
27
27
|
import { materializeViewport } from './xydraw-bridge';
|
|
28
28
|
|
|
29
29
|
// ── Culling state ──────────────────────────────────────────
|
|
@@ -204,6 +204,11 @@ function createPillCard(ctx: CanvasContext, file: any, path: string, x: number,
|
|
|
204
204
|
canvas.style.cssText = 'display:block;width:100%;height:100%;pointer-events:none;';
|
|
205
205
|
pill.appendChild(canvas);
|
|
206
206
|
|
|
207
|
+
const diffOverlay = document.createElement('div');
|
|
208
|
+
diffOverlay.className = 'file-pill-diff-overlay';
|
|
209
|
+
diffOverlay.style.cssText = 'position:absolute;top:10px;right:15px;bottom:10px;width:12px;pointer-events:none;z-index:2;';
|
|
210
|
+
pill.appendChild(diffOverlay);
|
|
211
|
+
|
|
207
212
|
(pill as any)._fileData = file;
|
|
208
213
|
updatePillCardLayout(ctx, pill, zoom, isChanged);
|
|
209
214
|
|
|
@@ -223,8 +228,10 @@ function updatePillCardLayout(ctx: CanvasContext, pill: HTMLElement, zoom: numbe
|
|
|
223
228
|
const scale = getLowZoomScale(zoom);
|
|
224
229
|
const path = pill.dataset.path || '';
|
|
225
230
|
const canvas = pill.querySelector('.file-pill-canvas') as HTMLCanvasElement | null;
|
|
231
|
+
const diffOverlay = pill.querySelector('.file-pill-diff-overlay') as HTMLElement | null;
|
|
226
232
|
const file = (pill as any)._fileData || ctx.allFilesData?.find(f => f.path === path) || ctx.commitFilesData?.find(f => f.path === path) || null;
|
|
227
233
|
const changed = isChanged ?? pill.dataset.changed === 'true';
|
|
234
|
+
const scrollTop = getSavedScrollTop(ctx, path);
|
|
228
235
|
pill.dataset.zoomBucket = zoom.toFixed(3);
|
|
229
236
|
pill.style.borderRadius = `${Math.max(6, scale.radius)}px`;
|
|
230
237
|
if (!canvas) return;
|
|
@@ -235,10 +242,49 @@ function updatePillCardLayout(ctx: CanvasContext, pill: HTMLElement, zoom: numbe
|
|
|
235
242
|
width: w,
|
|
236
243
|
height: h,
|
|
237
244
|
zoom,
|
|
238
|
-
scrollTop
|
|
245
|
+
scrollTop,
|
|
239
246
|
accentColor: getPillColor(path, changed),
|
|
240
247
|
isChanged: changed,
|
|
241
248
|
});
|
|
249
|
+
|
|
250
|
+
if (diffOverlay) {
|
|
251
|
+
const metrics = getPreviewScrollMetrics(file, h, zoom, scrollTop);
|
|
252
|
+
const markers = collectPreviewDiffMarkers(file, metrics.totalLines);
|
|
253
|
+
diffOverlay.innerHTML = '';
|
|
254
|
+
diffOverlay.style.top = `${metrics.trackPadding}px`;
|
|
255
|
+
diffOverlay.style.bottom = `${metrics.trackPadding}px`;
|
|
256
|
+
diffOverlay.style.right = '15px';
|
|
257
|
+
diffOverlay.style.width = '12px';
|
|
258
|
+
diffOverlay.style.pointerEvents = 'auto';
|
|
259
|
+
|
|
260
|
+
for (const marker of markers) {
|
|
261
|
+
const btn = document.createElement('button');
|
|
262
|
+
const markerHeight = marker.height === 1 ? metrics.trackHeight : 8;
|
|
263
|
+
const y = marker.height === 1 ? 0 : marker.ratio * Math.max(0, metrics.trackHeight - markerHeight);
|
|
264
|
+
btn.type = 'button';
|
|
265
|
+
btn.className = 'file-pill-diff-marker';
|
|
266
|
+
btn.title = marker.color === '#22c55e' ? 'Jump to added lines' : 'Jump to deleted lines';
|
|
267
|
+
btn.style.cssText = `position:absolute;left:0;width:12px;height:${markerHeight}px;top:${y}px;border:none;border-radius:3px;background:${marker.color};box-shadow:0 0 0 1px rgba(255,255,255,0.18),0 0 10px ${marker.color}66;cursor:pointer;padding:0;pointer-events:auto;`;
|
|
268
|
+
btn.addEventListener('mousedown', (e) => {
|
|
269
|
+
e.stopPropagation();
|
|
270
|
+
});
|
|
271
|
+
btn.addEventListener('click', (e) => {
|
|
272
|
+
e.preventDefault();
|
|
273
|
+
e.stopPropagation();
|
|
274
|
+
const maxScroll = estimatePreviewMaxScroll(file, h, zoom);
|
|
275
|
+
const next = marker.height === 1 ? 0 : Math.max(0, Math.min(maxScroll, marker.ratio * maxScroll));
|
|
276
|
+
const key = `scroll:${path}`;
|
|
277
|
+
const existing = ctx.positions.get(key) || {};
|
|
278
|
+
ctx.positions.set(key, { ...existing, x: next, y: existing.y || 0 });
|
|
279
|
+
try {
|
|
280
|
+
const { debounceSaveScroll } = require('./cards');
|
|
281
|
+
debounceSaveScroll(ctx, path, next);
|
|
282
|
+
} catch { }
|
|
283
|
+
updatePillCardLayout(ctx, pill, zoom, changed);
|
|
284
|
+
});
|
|
285
|
+
diffOverlay.appendChild(btn);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
242
288
|
}
|
|
243
289
|
|
|
244
290
|
/**
|