@singapore-editor/minimap 0.1.1 → 0.2.11

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.
Files changed (53) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +27 -10
  3. package/dist/assets/{minimap.worker-i4S59IOV.js → minimap.worker-C_eNmhCg.js} +114 -35
  4. package/dist/assets/minimap.worker-C_eNmhCg.js.map +1 -0
  5. package/dist/color.js +1 -2
  6. package/dist/decorationMerge.js +2 -3
  7. package/dist/decorationMerge.js.map +1 -1
  8. package/dist/documentSource.d.ts +42 -0
  9. package/dist/documentSource.d.ts.map +1 -0
  10. package/dist/documentSource.js +170 -0
  11. package/dist/documentSource.js.map +1 -0
  12. package/dist/index.d.ts +0 -1
  13. package/dist/index.d.ts.map +1 -1
  14. package/dist/index.js +1 -3
  15. package/dist/layout.js +0 -1
  16. package/dist/minimapCharRenderer.d.ts.map +1 -1
  17. package/dist/minimapCharRendererFactory.d.ts.map +1 -1
  18. package/dist/minimapCharSheet.d.ts.map +1 -1
  19. package/dist/minimapCharSheet.js +1 -2
  20. package/dist/options.js +1 -2
  21. package/dist/plugin.d.ts +1 -0
  22. package/dist/plugin.d.ts.map +1 -1
  23. package/dist/plugin.js +18 -5
  24. package/dist/plugin.js.map +1 -1
  25. package/dist/raster.d.ts.map +1 -1
  26. package/dist/renderer.d.ts +4 -1
  27. package/dist/renderer.d.ts.map +1 -1
  28. package/dist/sourceIdentity.d.ts +4 -0
  29. package/dist/sourceIdentity.d.ts.map +1 -0
  30. package/dist/sourceIdentity.js +10 -0
  31. package/dist/sourceIdentity.js.map +1 -0
  32. package/dist/sourceProtocol.d.ts +16 -0
  33. package/dist/sourceProtocol.d.ts.map +1 -0
  34. package/dist/style.css +1 -1
  35. package/dist/summary.d.ts +21 -0
  36. package/dist/summary.d.ts.map +1 -0
  37. package/dist/summary.js +174 -0
  38. package/dist/summary.js.map +1 -0
  39. package/dist/types.d.ts +27 -17
  40. package/dist/types.d.ts.map +1 -1
  41. package/dist/types.js +1 -2
  42. package/dist/types.js.map +1 -1
  43. package/dist/viewportGeometry.js +1 -2
  44. package/dist/workerClient.d.ts +21 -50
  45. package/dist/workerClient.d.ts.map +1 -1
  46. package/dist/workerClient.js +175 -680
  47. package/dist/workerClient.js.map +1 -1
  48. package/dist/workerOwner.d.ts +34 -0
  49. package/dist/workerOwner.d.ts.map +1 -0
  50. package/dist/workerOwner.js +168 -0
  51. package/dist/workerOwner.js.map +1 -0
  52. package/package.json +26 -8
  53. package/dist/assets/minimap.worker-i4S59IOV.js.map +0 -1
@@ -1,127 +1,27 @@
1
1
  import { computeFrameLayout, computeRenderLayout, visibleDocumentLineRange } from "./layout.js";
2
+ import { sourceIdentitiesEqual, sourcePointsEqual } from "./sourceIdentity.js";
3
+ import { retainMinimapDocumentSource } from "./documentSource.js";
2
4
  import { RGBA_BLACK, RGBA_WHITE, parseCssColor, transparent } from "./color.js";
3
- import { createError } from "@singapore-editor/core/logging/evlog";
4
- import { EditorSecondaryViewScheduler, createEditorSecondaryViewProjection } from "@singapore-editor/core/secondary-views";
5
- //#region src/workerClient.ts
5
+ import { EditorSecondaryViewScheduler } from "@singapore-editor/core/secondary-views";
6
+ // src/workerClient.ts
6
7
  var MINIMAP_UPDATE_QUIET_DELAY_MS = 120;
7
8
  var MINIMAP_UPDATE_MAX_DELAY_MS = 300;
8
9
  var MINIMAP_FRAME_FLUSH_KEY = "minimap.flush.frame";
9
10
  var MINIMAP_QUIET_FLUSH_KEY = "minimap.flush.quiet";
10
11
  var MINIMAP_RENDER_KEY = "minimap.render";
11
- var MinimapWorkerOwner = class {
12
- options;
13
- worker = null;
14
- lifecycle = "ready";
15
- postedRequests = 0;
16
- disposalAcknowledged = false;
17
- lastError = null;
18
- disposalPromise = null;
19
- resolveDisposal = null;
20
- rejectDisposal = null;
21
- constructor(options) {
22
- this.options = options;
23
- this.worker = this.createWorker();
24
- }
25
- inspect() {
26
- return {
27
- lifecycle: this.lifecycle,
28
- postedRequests: this.postedRequests,
29
- disposalAcknowledged: this.disposalAcknowledged,
30
- lastError: this.lastError?.message ?? null
31
- };
32
- }
33
- post(request, transfer) {
34
- const handle = this.worker;
35
- if (!this.canPost(handle)) return false;
36
- this.postedRequests += 1;
37
- try {
38
- this.postToWorker(handle, request, transfer);
39
- return true;
40
- } catch (error) {
41
- this.fail(workerRequestError(error));
42
- return false;
43
- }
44
- }
45
- dispose() {
46
- if (this.lifecycle === "disposed") return Promise.resolve();
47
- if (this.disposalPromise) return this.disposalPromise;
48
- if (!this.worker) {
49
- this.finishDisposal();
50
- return Promise.resolve();
51
- }
52
- this.lifecycle = "disposing";
53
- this.disposalPromise = new Promise((resolve, reject) => {
54
- this.resolveDisposal = resolve;
55
- this.rejectDisposal = reject;
56
- });
57
- if (!this.post({ type: "dispose" })) this.rejectDisposal?.(this.lastError ?? workerDisposedError());
58
- return this.disposalPromise;
59
- }
60
- createWorker() {
61
- const handle = this.options.workerFactory?.() ?? new Worker(new URL("./assets/minimap.worker-i4S59IOV.js", import.meta.url), { type: "module" });
62
- handle.onmessage = this.handleWorkerMessage;
63
- handle.onerror = this.handleWorkerError;
64
- return handle;
65
- }
66
- canPost(handle) {
67
- if (!handle) return false;
68
- if (this.lifecycle === "disposed") return false;
69
- return this.lifecycle !== "crashed";
70
- }
71
- postToWorker(handle, request, transfer) {
72
- if (transfer) {
73
- handle.postMessage(request, transfer);
74
- return;
75
- }
76
- handle.postMessage(request);
77
- }
78
- handleWorkerMessage = (event) => {
79
- const response = event.data;
80
- if (response.type === "disposed") {
81
- this.disposalAcknowledged = true;
82
- this.finishDisposal();
83
- return;
84
- }
85
- if (response.type === "error") {
86
- this.recordError(createWorkerResponseError(response));
87
- return;
88
- }
89
- this.options.onMessage(response);
90
- };
91
- handleWorkerError = (event) => {
92
- this.fail(createNativeWorkerError(event));
93
- };
94
- recordError(error) {
95
- this.lastError = error;
96
- this.options.onError?.(error);
97
- }
98
- fail(error) {
99
- this.lastError = error;
100
- this.lifecycle = "crashed";
101
- this.terminateWorker();
102
- this.rejectDisposal?.(error);
103
- this.clearDisposalHandlers();
104
- this.options.onError?.(error);
105
- }
106
- finishDisposal() {
107
- this.lifecycle = "disposed";
108
- this.terminateWorker();
109
- this.resolveDisposal?.();
110
- this.clearDisposalHandlers();
111
- }
112
- terminateWorker() {
113
- this.worker?.terminate();
114
- this.worker = null;
115
- }
116
- clearDisposalHandlers() {
117
- this.resolveDisposal = null;
118
- this.rejectDisposal = null;
119
- }
120
- };
121
12
  var MinimapWorkerClient = class {
122
13
  host;
123
14
  options;
124
- workerOwner;
15
+ contributions = null;
16
+ documentSource = null;
17
+ sourceResult = null;
18
+ sourceWait = false;
19
+ canvasesTransferred = false;
20
+ lastWorker = {
21
+ lifecycle: "disposed",
22
+ postedRequests: 0,
23
+ lastError: null
24
+ };
125
25
  colorResolver;
126
26
  scheduler = new EditorSecondaryViewScheduler();
127
27
  onLayoutWidth;
@@ -131,6 +31,7 @@ var MinimapWorkerClient = class {
131
31
  pendingUpdateReady = false;
132
32
  pendingRender = false;
133
33
  activeRenderToken = 0;
34
+ activeRenderSource = null;
134
35
  renderInFlight = false;
135
36
  latestBaseStyles = null;
136
37
  latestBaseStylesSignature = "";
@@ -139,8 +40,6 @@ var MinimapWorkerClient = class {
139
40
  latestSnapshot;
140
41
  latestViewport;
141
42
  postedViewport = null;
142
- latestFullDocumentSnapshot = null;
143
- workerDocumentState = null;
144
43
  latestTokenSource;
145
44
  disposed = false;
146
45
  constructor(options) {
@@ -153,22 +52,28 @@ var MinimapWorkerClient = class {
153
52
  this.latestViewport = options.snapshot.viewport;
154
53
  this.latestTokenSource = options.snapshot.tokens;
155
54
  this.colorResolver = new ColorResolver(options.host.colorScope);
156
- this.workerOwner = new MinimapWorkerOwner({
55
+ this.setDocumentContributions(options.contributions, options.snapshot);
56
+ }
57
+ inspectWorker() {
58
+ return this.documentSource?.source.inspect() ?? this.lastWorker;
59
+ }
60
+ setDocumentContributions(contributions, snapshot) {
61
+ if (this.disposed || this.contributions === contributions) return;
62
+ this.releaseDocumentSource();
63
+ this.contributions = contributions;
64
+ this.latestSnapshot = snapshot;
65
+ this.replaceTransferredCanvases();
66
+ if (!contributions) return;
67
+ this.documentSource = retainMinimapDocumentSource(contributions, {
68
+ maxColumn: this.options.maxColumn,
157
69
  onError: this.handleWorkerError,
158
70
  onMessage: this.handleWorkerMessage
159
71
  });
160
- this.init(options.snapshot);
72
+ if (!this.documentSource) return;
73
+ this.init(snapshot);
161
74
  }
162
- inspectWorker() {
163
- return this.workerOwner.inspect();
164
- }
165
- update(snapshot, kind, change) {
75
+ update(snapshot, kind) {
166
76
  if (this.disposed) return;
167
- if (this.shouldSkipDocumentUpdate(snapshot, kind)) {
168
- this.latestSnapshot = snapshot;
169
- return;
170
- }
171
- const previousSnapshot = this.latestSnapshot;
172
77
  this.latestSnapshot = snapshot;
173
78
  if (kind === "viewport") {
174
79
  this.latestViewport = snapshot.viewport;
@@ -177,7 +82,7 @@ var MinimapWorkerClient = class {
177
82
  if (layoutUpdated) this.requestRender();
178
83
  return;
179
84
  }
180
- const update = createPendingUpdate(snapshot, kind, change, previousSnapshot);
85
+ const update = createPendingUpdate(snapshot, kind);
181
86
  this.latestViewport = snapshot.viewport;
182
87
  this.applyImmediateViewport();
183
88
  this.queueUpdate(update);
@@ -221,16 +126,39 @@ var MinimapWorkerClient = class {
221
126
  setExternalDecorations(decorations) {
222
127
  if (this.disposed) return;
223
128
  this.externalDecorations = decorations;
224
- this.queueUpdate(createPendingUpdate(this.latestSnapshot, "decorations", null, this.latestSnapshot));
129
+ this.queueUpdate(createPendingUpdate(this.latestSnapshot, "decorations"));
225
130
  }
226
131
  dispose() {
227
132
  if (this.disposed) return;
228
133
  this.disposed = true;
229
134
  this.cancelScheduledFlush();
230
135
  this.scheduler.dispose();
231
- this.workerOwner.dispose().catch(() => void 0);
136
+ this.releaseDocumentSource();
232
137
  this.colorResolver.dispose();
233
138
  }
139
+ releaseDocumentSource() {
140
+ const binding = this.documentSource;
141
+ binding?.lease.dispose();
142
+ if (binding) this.lastWorker = binding.source.inspect();
143
+ this.documentSource = null;
144
+ this.sourceResult = null;
145
+ this.sourceWait = false;
146
+ this.pendingUpdate = null;
147
+ this.pendingUpdateReady = false;
148
+ this.pendingRender = false;
149
+ this.renderInFlight = false;
150
+ this.activeRenderToken = 0;
151
+ this.activeRenderSource = null;
152
+ this.latestTokenSource = null;
153
+ this.cancelScheduledFlush();
154
+ this.scheduler.cancel(MINIMAP_RENDER_KEY);
155
+ }
156
+ replaceTransferredCanvases() {
157
+ if (!this.canvasesTransferred) return;
158
+ this.host.mainCanvas = replaceCanvas(this.host.mainCanvas);
159
+ this.host.decorationsCanvas = replaceCanvas(this.host.decorationsCanvas);
160
+ this.canvasesTransferred = false;
161
+ }
234
162
  init(snapshot) {
235
163
  const mainCanvas = this.host.mainCanvas.transferControlToOffscreen();
236
164
  const decorationsCanvas = this.host.decorationsCanvas.transferControlToOffscreen();
@@ -246,11 +174,6 @@ var MinimapWorkerClient = class {
246
174
  decorationsCanvas
247
175
  };
248
176
  this.post(request, [mainCanvas, decorationsCanvas]);
249
- this.post({
250
- type: "openDocument",
251
- document: this.trackedDocumentPayload(snapshot)
252
- });
253
- this.latestFullDocumentSnapshot = snapshot;
254
177
  this.postedViewport = this.viewport(snapshot);
255
178
  this.post({
256
179
  type: "updateLayout",
@@ -258,7 +181,8 @@ var MinimapWorkerClient = class {
258
181
  viewport: this.postedViewport
259
182
  });
260
183
  this.latestLayoutSignature = layoutSignature(snapshot, this.minimapHeight(snapshot));
261
- this.postRender(snapshot);
184
+ this.canvasesTransferred = true;
185
+ this.queueUpdate(createPendingUpdate(snapshot, "document"));
262
186
  }
263
187
  scheduleFlush() {
264
188
  const pending = this.pendingUpdate;
@@ -291,6 +215,7 @@ var MinimapWorkerClient = class {
291
215
  key: MINIMAP_QUIET_FLUSH_KEY,
292
216
  taskClass: "background-derived",
293
217
  priority: "low",
218
+ defer: true,
294
219
  delayMs: MINIMAP_UPDATE_QUIET_DELAY_MS,
295
220
  maxDelayMs: MINIMAP_UPDATE_MAX_DELAY_MS,
296
221
  tags: {
@@ -307,18 +232,44 @@ var MinimapWorkerClient = class {
307
232
  };
308
233
  flushPendingUpdate() {
309
234
  if (this.disposed) return;
310
- if (this.renderInFlight) return;
235
+ if (this.renderInFlight || this.sourceWait) return;
311
236
  const pending = this.pendingUpdate;
312
237
  if (!pending) return;
313
238
  measureMinimapPerformance("minimap.flushPendingUpdate", () => this.flushPendingUpdateNow(pending), () => pendingUpdateDiagnostics(pending));
314
239
  }
315
- flushPendingUpdateNow(pending) {
240
+ async flushPendingUpdateNow(pending) {
241
+ const binding = this.documentSource;
316
242
  this.pendingUpdate = null;
317
243
  this.pendingUpdateReady = false;
318
- measureMinimapPerformance("minimap.postUpdate", () => this.postUpdate(pending), () => pendingUpdateDiagnostics(pending));
319
- const layoutUpdated = this.postLayoutIfNeeded(pending.snapshot);
320
- this.postViewportIfNeeded(pending.snapshot, pending.syncViewport, layoutUpdated);
321
- this.postRender(pending.snapshot);
244
+ this.sourceWait = true;
245
+ try {
246
+ const result = await this.sourceFor(pending.snapshot);
247
+ if (!result) return;
248
+ this.postUpdate(pending, result);
249
+ const layoutUpdated = this.postLayoutIfNeeded(pending.snapshot);
250
+ this.postViewportIfNeeded(pending.snapshot, pending.syncViewport, layoutUpdated);
251
+ this.postRender(pending.snapshot);
252
+ } catch (error) {
253
+ this.reportSourceFailure(error);
254
+ } finally {
255
+ if (this.documentSource === binding) this.sourceWait = false;
256
+ if (this.pendingUpdate && !this.renderInFlight) this.scheduleFlush();
257
+ }
258
+ }
259
+ async sourceFor(snapshot) {
260
+ if (snapshot.geometryCommitted === false || snapshot.viewport.clientWidth <= 0 || snapshot.viewport.clientHeight <= 0) return null;
261
+ const binding = this.documentSource;
262
+ if (!binding) return null;
263
+ const result = await binding.lease.request();
264
+ if (this.disposed || this.documentSource !== binding) return null;
265
+ if (!result) return null;
266
+ const expected = snapshot.documentSyncPoint;
267
+ if (result.point.segment !== expected.segment || result.point.revision !== expected.revision || result.point.textVersion !== expected.textVersion) return null;
268
+ return result;
269
+ }
270
+ reportSourceFailure(error) {
271
+ if (error instanceof DOMException && error.name === "AbortError") return;
272
+ if (error instanceof Error) this.handleWorkerError(error);
322
273
  }
323
274
  postLayoutIfNeeded(snapshot) {
324
275
  const signature = layoutSignature(snapshot, this.minimapHeight(snapshot));
@@ -341,66 +292,28 @@ var MinimapWorkerClient = class {
341
292
  viewport: this.postedViewport
342
293
  });
343
294
  }
344
- postUpdate(update) {
295
+ postUpdate(update, result) {
345
296
  const snapshot = update.snapshot;
346
- let tokenColorsInvalidated = false;
297
+ let colorsInvalidated = false;
347
298
  if (update.syncBaseStyles) {
348
- tokenColorsInvalidated = this.refreshThemeColorCache(snapshot);
349
- tokenColorsInvalidated = this.syncBaseStyles() || tokenColorsInvalidated;
350
- }
351
- if (update.replaceDocument) {
352
- this.post({
353
- type: "replaceDocument",
354
- document: this.trackedDocumentPayload(snapshot)
355
- });
356
- this.latestFullDocumentSnapshot = snapshot;
357
- this.latestTokenSource = snapshot.tokens;
358
- return;
299
+ colorsInvalidated = this.refreshThemeColorCache(snapshot);
300
+ colorsInvalidated = this.syncBaseStyles() || colorsInvalidated;
359
301
  }
360
- if (update.edits.length > 0) {
361
- this.latestFullDocumentSnapshot = null;
362
- this.postEditUpdate(update);
363
- this.latestTokenSource = update.tokenSourceAfterEdits;
364
- }
365
- if (update.syncTokens) this.postTokenUpdate(snapshot, tokenColorsInvalidated);
366
- if (update.syncSelection && update.edits.length === 0) this.post({
302
+ const sourceAdvanced = this.sourceResult?.receipt !== result.receipt;
303
+ if (sourceAdvanced) {
304
+ if (result.tokensRebased && this.latestTokenSource && !update.syncTokens && !colorsInvalidated) this.latestTokenSource = snapshot.tokens;
305
+ else this.postFullTokenUpdate(snapshot);
306
+ } else if (update.syncTokens) this.postTokenUpdate(snapshot, colorsInvalidated);
307
+ this.sourceResult = result;
308
+ if (sourceAdvanced || update.syncSelection) this.post({
367
309
  type: "updateSelection",
368
310
  selections: selections(snapshot.selections)
369
311
  });
370
- if (update.syncExternalDecorations) this.post({
312
+ if (sourceAdvanced || update.syncExternalDecorations) this.post({
371
313
  type: "updateExternalDecorations",
372
314
  decorations: this.externalDecorations
373
315
  });
374
316
  }
375
- postEditUpdate(update) {
376
- const document = this.documentEditPayload(update, this.workerDocumentState);
377
- const patch = document.summaryPatch;
378
- if (this.workerDocumentState) this.workerDocumentState = {
379
- textLength: patch.textLength,
380
- lineCount: this.workerDocumentState.lineCount - patch.deleteCount + patch.lines.length
381
- };
382
- if (update.edits.length === 1) {
383
- this.post({
384
- type: "applyEdit",
385
- edit: update.edits[0],
386
- document
387
- });
388
- return;
389
- }
390
- this.post({
391
- type: "applyEdits",
392
- edits: update.edits,
393
- document
394
- });
395
- }
396
- trackedDocumentPayload(snapshot) {
397
- const document = this.documentPayload(snapshot);
398
- this.workerDocumentState = {
399
- textLength: document.textLength,
400
- lineCount: document.lines.length
401
- };
402
- return document;
403
- }
404
317
  postTokenUpdate(snapshot, forceFullUpdate) {
405
318
  const sourceTokens = this.latestTokenSource;
406
319
  if (forceFullUpdate || !sourceTokens) {
@@ -450,12 +363,6 @@ var MinimapWorkerClient = class {
450
363
  this.colorResolver.clear();
451
364
  return true;
452
365
  }
453
- shouldSkipDocumentUpdate(snapshot, kind) {
454
- if (kind !== "document") return false;
455
- const latest = this.latestFullDocumentSnapshot;
456
- if (!latest) return false;
457
- return latest === snapshot;
458
- }
459
366
  requestRender() {
460
367
  if (this.renderInFlight) {
461
368
  this.pendingRender = true;
@@ -483,20 +390,43 @@ var MinimapWorkerClient = class {
483
390
  this.activeRenderToken = handle.token;
484
391
  this.renderInFlight = true;
485
392
  }
486
- postScheduledRender(snapshot, token) {
487
- if (token !== this.activeRenderToken) return;
488
- this.pendingRender = false;
489
- this.sizeCanvasElements(snapshot);
490
- this.post({
491
- type: "render",
492
- sequence: token
493
- });
393
+ async postScheduledRender(snapshot, token) {
394
+ try {
395
+ const result = await this.sourceFor(snapshot);
396
+ if (token !== this.activeRenderToken) return;
397
+ if (!result) {
398
+ this.finishSourceWait(token);
399
+ return;
400
+ }
401
+ if (this.sourceResult?.receipt !== result.receipt) this.postUpdate(createPendingUpdate(snapshot, "content"), result);
402
+ this.pendingRender = false;
403
+ this.activeRenderSource = result.receipt;
404
+ this.sizeCanvasElements(snapshot);
405
+ this.post({
406
+ type: "render",
407
+ sequence: token,
408
+ source: result.receipt
409
+ });
410
+ } catch (error) {
411
+ this.finishSourceWait(token);
412
+ this.reportSourceFailure(error);
413
+ }
494
414
  }
495
415
  cancelScheduledRender(token) {
496
416
  if (token !== this.activeRenderToken) return;
497
417
  this.activeRenderToken = 0;
418
+ this.activeRenderSource = null;
498
419
  this.renderInFlight = false;
499
420
  }
421
+ finishSourceWait(token) {
422
+ this.cancelScheduledRender(token);
423
+ if (this.renderInFlight) return;
424
+ if (this.pendingUpdate) {
425
+ this.scheduleFlush();
426
+ return;
427
+ }
428
+ if (this.pendingRender) this.requestRender();
429
+ }
500
430
  applyImmediateViewport() {
501
431
  const frame = this.frameLayout();
502
432
  setStyleValue(this.host.slider, "display", frame.sliderNeeded ? "block" : "none");
@@ -505,32 +435,6 @@ var MinimapWorkerClient = class {
505
435
  setStyleValue(this.host.sliderHorizontal, "height", `${frame.sliderHeight}px`);
506
436
  setClassName(this.host.shadow, shadowVisible(this.latestViewport) ? "editor-minimap-shadow editor-minimap-shadow-visible" : "editor-minimap-shadow editor-minimap-shadow-hidden");
507
437
  }
508
- documentPayload(snapshot) {
509
- const projection = createEditorSecondaryViewProjection(snapshot);
510
- let payload = null;
511
- return measureMinimapPerformance("minimap.documentPayload", () => {
512
- payload = {
513
- ...documentSummaryPayload(projection.text, this.options.maxColumn),
514
- tokens: this.tokens(projection.syntaxColors.tokens),
515
- selections: selections(projection.selections),
516
- decorations: this.externalDecorations,
517
- externalDecorations: this.externalDecorations
518
- };
519
- return payload;
520
- }, () => documentPayloadDiagnostics(payload));
521
- }
522
- documentEditPayload(update, workerDocument) {
523
- const snapshot = update.snapshot;
524
- const projection = createEditorSecondaryViewProjection(snapshot);
525
- let payload = null;
526
- return measureMinimapPerformance("minimap.documentEditPayload", () => {
527
- payload = {
528
- selections: selections(projection.selections),
529
- summaryPatch: documentSummaryPatchPayload(projection.text, previousDocumentSummary(update), update.edits, this.options.maxColumn, workerDocument)
530
- };
531
- return payload;
532
- }, () => documentEditPayloadDiagnostics(payload));
533
- }
534
438
  tokens(tokens, from = 0, to = tokens.length) {
535
439
  return measureMinimapPerformance("minimap.tokens", () => {
536
440
  const foreground = this.latestBaseStyles?.foreground ?? this.baseStyles().foreground;
@@ -617,11 +521,17 @@ var MinimapWorkerClient = class {
617
521
  this.applyLayout(response.layout.width, response.layout.canvasOuterWidth, response.layout.canvasOuterHeight);
618
522
  return;
619
523
  }
524
+ if (response.type === "renderSkipped") {
525
+ this.cancelScheduledRender(response.sequence);
526
+ if (this.pendingUpdate) this.scheduleFlush();
527
+ return;
528
+ }
620
529
  if (response.type === "rendered") {
621
530
  if (!this.isCurrentRenderResponse(response)) return;
622
531
  this.scheduler.cancel(MINIMAP_RENDER_KEY);
623
532
  this.renderInFlight = false;
624
533
  this.activeRenderToken = 0;
534
+ this.activeRenderSource = null;
625
535
  if (this.pendingUpdate) this.scheduleFlush();
626
536
  if (this.renderInFlight) return;
627
537
  if (this.pendingRender) this.requestRender();
@@ -642,7 +552,7 @@ var MinimapWorkerClient = class {
642
552
  };
643
553
  post(request, transfer) {
644
554
  measureMinimapPerformance("minimap.post", () => {
645
- this.workerOwner.post(request, transfer);
555
+ this.documentSource?.source.post(request, transfer);
646
556
  }, () => requestDiagnostics(request));
647
557
  }
648
558
  cancelScheduledFlush() {
@@ -656,7 +566,9 @@ var MinimapWorkerClient = class {
656
566
  this.scheduler.cancel(MINIMAP_QUIET_FLUSH_KEY);
657
567
  }
658
568
  isCurrentRenderResponse(response) {
659
- return response.sequence === this.activeRenderToken;
569
+ const expected = this.activeRenderSource;
570
+ const source = response.source;
571
+ return Boolean(response.sequence === this.activeRenderToken && expected && source && sourceIdentitiesEqual(source.identity, expected.identity) && sourcePointsEqual(source.target, expected.target));
660
572
  }
661
573
  };
662
574
  function canUseMinimapWorker() {
@@ -664,256 +576,22 @@ function canUseMinimapWorker() {
664
576
  if (typeof OffscreenCanvas === "undefined") return false;
665
577
  return typeof HTMLCanvasElement !== "undefined" && "transferControlToOffscreen" in HTMLCanvasElement.prototype;
666
578
  }
667
- function workerRequestError(error) {
668
- if (error instanceof Error) return error;
669
- return new Error(String(error));
670
- }
671
- function createWorkerResponseError(response) {
672
- const workerMessage = nonEmptyString(response.message);
673
- return createError({
674
- code: "minimap.WORKER_REQUEST_FAILED",
675
- message: messageWithDetail("Minimap worker request failed", workerMessage),
676
- why: workerMessage ?? "The minimap worker reported an error without details.",
677
- fix: "The editor keeps running; inspect the minimap worker request and renderer state if the minimap stops updating.",
678
- internal: {
679
- responseType: response.type,
680
- sequence: response.sequence ?? null,
681
- workerMessage: response.message
682
- }
683
- });
684
- }
685
- function createNativeWorkerError(event) {
686
- const browserMessage = nonEmptyString(event.message);
687
- return createError({
688
- code: "minimap.WORKER_CRASHED",
689
- message: messageWithDetail("Minimap worker crashed", browserMessage),
690
- why: nativeWorkerFailureReason(browserMessage),
691
- fix: "The editor keeps running without the minimap for this worker generation. Check the worker script request, CSP, MIME type, and browser worker support.",
692
- cause: event.error instanceof Error ? event.error : void 0,
693
- internal: workerErrorEventInternal(event)
694
- });
695
- }
696
- function nativeWorkerFailureReason(browserMessage) {
697
- if (browserMessage) return `The browser reported: ${browserMessage}`;
698
- return "The browser reported a native worker failure without an error message. This usually means the worker script failed to load or crashed before its own error handler ran.";
699
- }
700
- function workerErrorEventInternal(event) {
701
- const error = event.error;
702
- return {
703
- browserMessage: nonEmptyString(event.message),
704
- filename: nonEmptyString(event.filename),
705
- lineNumber: positiveNumberOrNull(event.lineno),
706
- columnNumber: positiveNumberOrNull(event.colno),
707
- errorName: error instanceof Error ? error.name : null,
708
- errorMessage: errorMessage(error),
709
- errorStack: error instanceof Error ? error.stack : null,
710
- rawErrorType: rawErrorType(error)
711
- };
712
- }
713
- function errorMessage(error) {
714
- if (error instanceof Error) return error.message;
715
- if (typeof error === "string") return error;
716
- return null;
717
- }
718
- function rawErrorType(error) {
719
- if (error === null || error === void 0) return null;
720
- if (error instanceof Error) return error.name;
721
- return Object.prototype.toString.call(error);
722
- }
723
- function messageWithDetail(summary, detail) {
724
- if (!detail) return summary;
725
- return `${summary}: ${detail}`;
726
- }
727
- function nonEmptyString(value) {
728
- const trimmed = value?.trim() ?? "";
729
- if (trimmed.length === 0) return null;
730
- return trimmed;
731
- }
732
- function positiveNumberOrNull(value) {
733
- if (value > 0) return value;
734
- return null;
735
- }
736
- function workerDisposedError() {
737
- return /* @__PURE__ */ new Error("Minimap worker is disposed");
738
- }
739
579
  function selections(selections) {
740
580
  return selections.map((selection) => minimapSelection(selection));
741
581
  }
582
+ function replaceCanvas(previous) {
583
+ const canvas = previous.ownerDocument.createElement("canvas");
584
+ canvas.className = previous.className;
585
+ canvas.style.cssText = previous.style.cssText;
586
+ previous.replaceWith(canvas);
587
+ return canvas;
588
+ }
742
589
  function minimapSelection(selection) {
743
590
  return {
744
591
  startOffset: selection.startOffset,
745
592
  endOffset: selection.endOffset
746
593
  };
747
594
  }
748
- function arrayLineStarts(lineStarts) {
749
- return {
750
- length: lineStarts.length,
751
- at: (index) => lineStarts[index],
752
- indexForOffset: (offset) => arrayLineIndexForOffset(lineStarts, offset),
753
- firstIndexAtOrAfter: (target) => arrayFirstLineStartAtOrAfter(lineStarts, target),
754
- toArray: () => lineStarts
755
- };
756
- }
757
- function documentSummaryPayload(text, maxColumn) {
758
- const textLength = text.length;
759
- const lineStarts = text.lineStartsView.toArray();
760
- return {
761
- textLength,
762
- lineStarts,
763
- lines: lineStarts.map((startOffset, index) => lineSummaryFromSnapshot(text, startOffset, lineEndOffset(arrayLineStarts(lineStarts), index, textLength), maxColumn))
764
- };
765
- }
766
- function documentSummaryPatchPayload(text, previous, edits, maxColumn, workerDocument) {
767
- const textLength = text.length;
768
- const lineStarts = text.lineStartsView;
769
- const range = documentSummaryPatchRange(previous, lineStarts, textLength, edits, workerDocument);
770
- const lines = [];
771
- for (let lineIndex = range.startLine; lineIndex < range.insertEndLine; lineIndex += 1) lines.push(lineSummaryFromSnapshot(text, lineStarts.at(lineIndex) ?? textLength, lineEndOffset(lineStarts, lineIndex, textLength), maxColumn));
772
- return {
773
- textLength,
774
- startLine: range.startLine,
775
- deleteCount: range.deleteCount,
776
- lines
777
- };
778
- }
779
- function lineSummaryFromSnapshot(text, startOffset, endOffset, maxColumn) {
780
- const length = Math.max(0, endOffset - startOffset);
781
- const clippedEnd = startOffset + Math.min(length, maxColumn);
782
- return {
783
- text: text.snapshot.readRange(startOffset, clippedEnd),
784
- length
785
- };
786
- }
787
- function lineEndOffset(lineStarts, index, textLength) {
788
- const startOffset = lineStarts.at(index) ?? textLength;
789
- const nextStart = lineStarts.at(index + 1);
790
- if (nextStart === void 0) return textLength;
791
- return Math.max(startOffset, nextStart - 1);
792
- }
793
- function documentSummaryPatchRange(previous, nextLineStarts, nextTextLength, edits, workerDocument) {
794
- const edited = editSummaryPatchRange(previous.lineStarts, nextLineStarts, edits);
795
- if (edited && workerDocument && editsExplainTransition(workerDocument, nextLineStarts, nextTextLength, edits)) return normalizeSummaryPatchRange(edited, previous.lineStarts.length, nextLineStarts.length);
796
- const changed = mergeSummaryPatchRanges(lineStartSummaryPatchRange(previous.lineStarts, previous.textLength, nextLineStarts, nextTextLength), edited);
797
- if (!changed) return {
798
- startLine: 0,
799
- deleteCount: 0,
800
- insertEndLine: 0
801
- };
802
- return normalizeSummaryPatchRange(changed, previous.lineStarts.length, nextLineStarts.length);
803
- }
804
- function editsExplainTransition(workerDocument, nextLineStarts, nextTextLength, edits) {
805
- if (nextLineStarts.length !== workerDocument.lineCount) return false;
806
- let textDelta = 0;
807
- for (const edit of edits) {
808
- if (edit.text.includes("\n")) return false;
809
- textDelta += edit.text.length - (Math.max(edit.from, edit.to) - Math.min(edit.from, edit.to));
810
- }
811
- return workerDocument.textLength + textDelta === nextTextLength;
812
- }
813
- function arrayFirstLineStartAtOrAfter(lineStarts, target) {
814
- let low = 0;
815
- let high = lineStarts.length;
816
- while (low < high) {
817
- const middle = low + high >> 1;
818
- if (lineStarts[middle] < target) low = middle + 1;
819
- else high = middle;
820
- }
821
- return low;
822
- }
823
- function lineStartSummaryPatchRange(previousLineStarts, previousTextLength, nextLineStarts, nextTextLength) {
824
- const prefix = commonLineSummaryPrefix(previousLineStarts, previousTextLength, nextLineStarts, nextTextLength);
825
- const suffix = commonLineSummarySuffix(previousLineStarts, previousTextLength, nextLineStarts, nextTextLength, prefix);
826
- if (prefix + suffix >= previousLineStarts.length && prefix + suffix >= nextLineStarts.length) return null;
827
- return {
828
- startLine: prefix,
829
- previousEndLine: previousLineStarts.length - suffix,
830
- nextEndLine: nextLineStarts.length - suffix
831
- };
832
- }
833
- function commonLineSummaryPrefix(previousLineStarts, previousTextLength, nextLineStarts, nextTextLength) {
834
- let count = 0;
835
- const limit = Math.min(previousLineStarts.length, nextLineStarts.length);
836
- while (count < limit && lineSummaryBoundariesMatch(previousLineStarts, previousTextLength, count, nextLineStarts, nextTextLength, count, 0)) count += 1;
837
- return count;
838
- }
839
- function commonLineSummarySuffix(previousLineStarts, previousTextLength, nextLineStarts, nextTextLength, prefix) {
840
- let count = 0;
841
- const delta = nextTextLength - previousTextLength;
842
- const previousLimit = previousLineStarts.length - prefix;
843
- const nextLimit = nextLineStarts.length - prefix;
844
- while (count < previousLimit && count < nextLimit) {
845
- if (!lineSummaryBoundariesMatch(previousLineStarts, previousTextLength, previousLineStarts.length - count - 1, nextLineStarts, nextTextLength, nextLineStarts.length - count - 1, delta)) return count;
846
- count += 1;
847
- }
848
- return count;
849
- }
850
- function lineSummaryBoundariesMatch(previousLineStarts, previousTextLength, previousIndex, nextLineStarts, nextTextLength, nextIndex, offsetDelta) {
851
- const previousStart = previousLineStarts.at(previousIndex) ?? previousTextLength;
852
- const nextStart = nextLineStarts.at(nextIndex) ?? nextTextLength;
853
- if (previousStart + offsetDelta !== nextStart) return false;
854
- return lineEndOffset(previousLineStarts, previousIndex, previousTextLength) + offsetDelta === lineEndOffset(nextLineStarts, nextIndex, nextTextLength);
855
- }
856
- function editSummaryPatchRange(previousLineStarts, nextLineStarts, edits) {
857
- let startLine = Number.POSITIVE_INFINITY;
858
- let previousEndLine = 0;
859
- let nextEndLine = 0;
860
- for (const edit of edits) {
861
- if (editIsEmpty(edit)) continue;
862
- const previousRange = previousLineRangeForEdit(previousLineStarts, nextLineStarts, edit);
863
- const nextRange = lineRangeForEdit(nextLineStarts, edit.from, edit.from + edit.text.length);
864
- startLine = Math.min(startLine, previousRange.startLine, nextRange.startLine);
865
- previousEndLine = Math.max(previousEndLine, previousRange.endLine);
866
- nextEndLine = Math.max(nextEndLine, nextRange.endLine);
867
- }
868
- if (startLine === Number.POSITIVE_INFINITY) return null;
869
- return {
870
- startLine,
871
- previousEndLine,
872
- nextEndLine
873
- };
874
- }
875
- function editIsEmpty(edit) {
876
- return edit.from === edit.to && edit.text.length === 0;
877
- }
878
- function previousLineRangeForEdit(previousLineStarts, nextLineStarts, edit) {
879
- if (edit.from !== edit.to || edit.text.includes("\n")) return lineRangeForEdit(previousLineStarts, edit.from, edit.to);
880
- const line = nextLineStarts.indexForOffset(edit.from);
881
- return {
882
- startLine: line,
883
- endLine: line + 1
884
- };
885
- }
886
- function lineRangeForEdit(lineStarts, from, to) {
887
- const startOffset = Math.min(from, to);
888
- const endOffset = Math.max(from, to);
889
- return {
890
- startLine: lineStarts.indexForOffset(startOffset),
891
- endLine: lineStarts.indexForOffset(endOffset) + 1
892
- };
893
- }
894
- function mergeSummaryPatchRanges(left, right) {
895
- if (!left) return right;
896
- if (!right) return left;
897
- return {
898
- startLine: Math.min(left.startLine, right.startLine),
899
- previousEndLine: Math.max(left.previousEndLine, right.previousEndLine),
900
- nextEndLine: Math.max(left.nextEndLine, right.nextEndLine)
901
- };
902
- }
903
- function normalizeSummaryPatchRange(range, previousLineCount, nextLineCount) {
904
- const startLine = Math.min(Math.max(0, range.startLine), Math.max(previousLineCount, nextLineCount));
905
- const previousEndLine = Math.min(Math.max(startLine, range.previousEndLine), previousLineCount);
906
- const nextEndLine = Math.min(Math.max(startLine, range.nextEndLine), nextLineCount);
907
- return {
908
- startLine,
909
- deleteCount: previousEndLine - startLine,
910
- insertEndLine: nextEndLine
911
- };
912
- }
913
- function incrementalTextEdits(change) {
914
- if (!change || change.edits.length === 0) return null;
915
- return sequentialTextEdits(change.edits.toSorted(compareTextEdits));
916
- }
917
595
  function sameViewport(previous, next) {
918
596
  if (!previous) return false;
919
597
  return previous.scrollTop === next.scrollTop && previous.scrollRow === next.scrollRow && previous.scrollLeft === next.scrollLeft && previous.scrollHeight === next.scrollHeight && previous.scrollWidth === next.scrollWidth && previous.clientHeight === next.clientHeight && previous.clientWidth === next.clientWidth && previous.minimapHeight === next.minimapHeight && previous.reservedWidth === next.reservedWidth && previous.visibleStart === next.visibleStart && previous.visibleEnd === next.visibleEnd;
@@ -939,118 +617,30 @@ function layoutSignature(snapshot, minimapHeight) {
939
617
  snapshot.lineCount
940
618
  ].join(":");
941
619
  }
942
- function createPendingUpdate(snapshot, kind, change, previousSnapshot) {
943
- const base = basePendingUpdate(snapshot, kind);
944
- if (kind === "content") return contentPendingUpdate(base, change, previousSnapshot);
945
- if (kind === "document" || kind === "clear") return {
946
- ...base,
947
- replaceDocument: true,
948
- reason: kind
949
- };
950
- if (kind === "tokens") return {
951
- ...base,
952
- syncTokens: true,
953
- reason: "tokens"
954
- };
955
- if (kind === "selection") return {
956
- ...base,
957
- syncSelection: true,
958
- reason: "selection"
959
- };
960
- if (kind === "decorations") return {
961
- ...base,
962
- syncExternalDecorations: true,
963
- reason: "decorations"
964
- };
620
+ function createPendingUpdate(snapshot, kind) {
621
+ const document = kind === "document" || kind === "clear";
965
622
  return {
966
- ...base,
623
+ snapshot,
624
+ syncTokens: document || kind === "tokens",
625
+ syncSelection: document || kind === "selection" || kind === "content",
626
+ syncExternalDecorations: document || kind === "decorations",
627
+ syncViewport: shouldSyncViewport(kind),
628
+ syncBaseStyles: document || kind === "tokens",
967
629
  reason: kind
968
630
  };
969
631
  }
970
632
  function mergePendingUpdate(current, next) {
971
633
  if (!current) return next;
972
- if (current.replaceDocument || next.replaceDocument) return mergeReplacementUpdate(current, next);
973
- const edits = current.edits.concat(next.edits);
974
- const contentChangedAfterTokens = next.edits.length > 0;
975
634
  return {
976
635
  snapshot: next.snapshot,
977
- replaceDocument: false,
978
- edits,
979
- previousDocumentSummary: current.previousDocumentSummary ?? next.previousDocumentSummary,
980
- syncTokens: contentChangedAfterTokens ? next.syncTokens : current.syncTokens || next.syncTokens,
636
+ syncTokens: current.syncTokens || next.syncTokens,
981
637
  syncSelection: current.syncSelection || next.syncSelection,
982
638
  syncExternalDecorations: current.syncExternalDecorations || next.syncExternalDecorations,
983
639
  syncViewport: current.syncViewport || next.syncViewport,
984
640
  syncBaseStyles: current.syncBaseStyles || next.syncBaseStyles,
985
- tokenSourceAfterEdits: mergedTokenSourceAfterEdits(current, next),
986
- reason: mergeReasons(current.reason, next.reason)
987
- };
988
- }
989
- function mergeReplacementUpdate(current, next) {
990
- return {
991
- snapshot: next.snapshot,
992
- replaceDocument: true,
993
- edits: [],
994
- previousDocumentSummary: null,
995
- syncTokens: false,
996
- syncSelection: false,
997
- syncExternalDecorations: false,
998
- syncViewport: current.syncViewport || next.syncViewport,
999
- syncBaseStyles: current.syncBaseStyles || next.syncBaseStyles,
1000
- tokenSourceAfterEdits: null,
1001
641
  reason: mergeReasons(current.reason, next.reason)
1002
642
  };
1003
643
  }
1004
- function mergedTokenSourceAfterEdits(current, next) {
1005
- if (next.edits.length === 0) return current.tokenSourceAfterEdits;
1006
- if (current.syncTokens) return null;
1007
- return next.tokenSourceAfterEdits;
1008
- }
1009
- function shouldSyncBaseStyles(kind) {
1010
- if (kind === "tokens") return true;
1011
- if (kind === "document") return true;
1012
- return kind === "clear";
1013
- }
1014
- function basePendingUpdate(snapshot, kind) {
1015
- return {
1016
- snapshot,
1017
- replaceDocument: false,
1018
- edits: [],
1019
- previousDocumentSummary: null,
1020
- syncTokens: false,
1021
- syncSelection: false,
1022
- syncExternalDecorations: false,
1023
- syncViewport: shouldSyncViewport(kind),
1024
- syncBaseStyles: shouldSyncBaseStyles(kind),
1025
- tokenSourceAfterEdits: null,
1026
- reason: "metadata"
1027
- };
1028
- }
1029
- function contentPendingUpdate(base, change, previousSnapshot) {
1030
- const edits = incrementalTextEdits(change);
1031
- if (!edits) return {
1032
- ...base,
1033
- replaceDocument: true,
1034
- reason: "content.replaceDocument"
1035
- };
1036
- return {
1037
- ...base,
1038
- edits,
1039
- previousDocumentSummary: snapshotSummaryBaseline(previousSnapshot),
1040
- syncSelection: true,
1041
- tokenSourceAfterEdits: tokenSourceAfterEdits(change, previousSnapshot, base.snapshot),
1042
- reason: edits.length === 1 ? "content.edit" : "content.edits"
1043
- };
1044
- }
1045
- function previousDocumentSummary(update) {
1046
- return update.previousDocumentSummary ?? snapshotSummaryBaseline(update.snapshot);
1047
- }
1048
- function snapshotSummaryBaseline(snapshot) {
1049
- return {
1050
- textLength: snapshot.textSnapshot.length,
1051
- lineStarts: snapshot.lineStartsView
1052
- };
1053
- }
1054
644
  function shouldSyncViewport(kind) {
1055
645
  if (kind === "content") return true;
1056
646
  if (kind === "document") return true;
@@ -1063,57 +653,6 @@ function shouldDeferMinimapUpdate(update) {
1063
653
  if (update.syncTokens) return true;
1064
654
  return update.syncExternalDecorations;
1065
655
  }
1066
- function sequentialTextEdits(edits) {
1067
- let delta = 0;
1068
- return edits.map((edit) => {
1069
- const from = edit.from + delta;
1070
- const to = edit.to + delta;
1071
- delta += edit.text.length - (edit.to - edit.from);
1072
- return {
1073
- from,
1074
- to,
1075
- text: edit.text
1076
- };
1077
- });
1078
- }
1079
- function compareTextEdits(left, right) {
1080
- return left.from - right.from || left.to - right.to;
1081
- }
1082
- function tokenSourceAfterEdits(change, previousSnapshot, nextSnapshot) {
1083
- if (!change) return null;
1084
- if (!editsPreserveLineStructure(change.edits, previousSnapshot.lineStartsView)) return null;
1085
- return nextSnapshot.tokens;
1086
- }
1087
- function editsPreserveLineStructure(edits, lineStarts) {
1088
- for (const edit of edits) {
1089
- if (edit.text.includes("\n")) return false;
1090
- if (!editRangeIsSingleLine(lineStarts, edit)) return false;
1091
- }
1092
- return true;
1093
- }
1094
- function editRangeIsSingleLine(lineStarts, edit) {
1095
- return lineStarts.indexForOffset(edit.from) === lineStarts.indexForOffset(edit.to);
1096
- }
1097
- function arrayLineIndexForOffset(lineStarts, offset) {
1098
- let low = 0;
1099
- let high = lineStarts.length - 1;
1100
- const clamped = Math.max(0, offset);
1101
- while (low <= high) {
1102
- const middle = Math.floor((low + high) / 2);
1103
- const start = lineStarts[middle] ?? 0;
1104
- const next = lineStarts[middle + 1] ?? Number.POSITIVE_INFINITY;
1105
- if (clamped < start) {
1106
- high = middle - 1;
1107
- continue;
1108
- }
1109
- if (clamped >= next) {
1110
- low = middle + 1;
1111
- continue;
1112
- }
1113
- return middle;
1114
- }
1115
- return Math.max(0, lineStarts.length - 1);
1116
- }
1117
656
  function mergeReasons(left, right) {
1118
657
  if (left === right) return left;
1119
658
  return `${left}+${right}`;
@@ -1176,36 +715,26 @@ function minimapPerformanceDiagnosticGlobal() {
1176
715
  }
1177
716
  function pendingUpdateDiagnostics(update) {
1178
717
  return {
1179
- editCount: update.edits.length,
1180
- incremental: !update.replaceDocument,
1181
718
  reason: update.reason,
1182
719
  syncBaseStyles: update.syncBaseStyles,
1183
720
  syncExternalDecorations: update.syncExternalDecorations,
1184
721
  syncSelection: update.syncSelection,
1185
722
  syncTokens: update.syncTokens,
1186
- syncViewport: update.syncViewport,
1187
- tokenSourceKnown: update.tokenSourceAfterEdits !== null || update.edits.length === 0,
1188
- type: update.replaceDocument ? "replaceDocument" : "incremental"
723
+ syncViewport: update.syncViewport
1189
724
  };
1190
725
  }
1191
726
  function requestDiagnostics(request) {
1192
727
  switch (request.type) {
1193
- case "openDocument":
1194
- case "replaceDocument": return {
1195
- request: request.type,
1196
- ...documentPayloadDiagnostics(request.document)
1197
- };
1198
- case "applyEdit": return {
1199
- request: request.type,
1200
- editTextLength: request.edit.text.length,
1201
- ...documentEditPayloadDiagnostics(request.document)
1202
- };
1203
- case "applyEdits": return {
1204
- request: request.type,
1205
- editCount: request.edits.length,
1206
- editTextLength: textLengthForEdits(request.edits),
1207
- ...documentEditPayloadDiagnostics(request.document)
1208
- };
728
+ case "projectSource": {
729
+ const projection = request.projection;
730
+ return {
731
+ request: request.type,
732
+ kind: projection.kind,
733
+ textLength: projection.summary.textLength,
734
+ lines: projection.summary.lines.length,
735
+ lineSummaryTextLength: lineSummaryTextLength(projection.summary.lines)
736
+ };
737
+ }
1209
738
  case "updateTokens": return {
1210
739
  request: request.type,
1211
740
  tokens: request.tokens.length
@@ -1228,42 +757,11 @@ function requestDiagnostics(request) {
1228
757
  default: return { request: "control" };
1229
758
  }
1230
759
  }
1231
- function documentPayloadDiagnostics(payload) {
1232
- return {
1233
- decorations: payload?.decorations.length ?? 0,
1234
- externalDecorations: payload?.externalDecorations?.length ?? 0,
1235
- lineSummaryTextLength: lineSummaryTextLength(payload?.lines ?? []),
1236
- lineStarts: payload?.lineStarts.length ?? 0,
1237
- lines: payload?.lines.length ?? 0,
1238
- selections: payload?.selections.length ?? 0,
1239
- textLength: payload?.textLength ?? 0,
1240
- tokens: payload?.tokens.length ?? 0,
1241
- type: "document"
1242
- };
1243
- }
1244
- function documentEditPayloadDiagnostics(payload) {
1245
- const patch = payload?.summaryPatch;
1246
- return {
1247
- deleteCount: patch?.deleteCount ?? 0,
1248
- lineSummaryTextLength: lineSummaryTextLength(patch?.lines ?? []),
1249
- lineStarts: patch?.lineStarts?.length ?? 0,
1250
- lines: patch?.lines.length ?? 0,
1251
- selections: payload?.selections.length ?? 0,
1252
- startLine: patch?.startLine ?? 0,
1253
- textLength: patch?.textLength ?? 0,
1254
- type: "edit"
1255
- };
1256
- }
1257
760
  function lineSummaryTextLength(lines) {
1258
761
  let length = 0;
1259
762
  for (const line of lines) length += line.text.length;
1260
763
  return length;
1261
764
  }
1262
- function textLengthForEdits(edits) {
1263
- let length = 0;
1264
- for (const edit of edits) length += edit.text.length;
1265
- return length;
1266
- }
1267
765
  function setStyleValue(element, property, value) {
1268
766
  if (element.style[property] === value) return;
1269
767
  element.style[property] = value;
@@ -1290,9 +788,7 @@ var ColorResolver = class {
1290
788
  constructor(root) {
1291
789
  this.probe = root.ownerDocument.createElement("span");
1292
790
  this.canvasContext = root.ownerDocument.createElement("canvas").getContext("2d", { willReadFrequently: true });
1293
- this.probe.style.position = "absolute";
1294
- this.probe.style.visibility = "hidden";
1295
- this.probe.textContent = ".";
791
+ this.probe.style.cssText = "position:absolute;top:0;left:0;width:0;height:0;overflow:hidden;visibility:hidden;pointer-events:none";
1296
792
  root.appendChild(this.probe);
1297
793
  }
1298
794
  resolve(value, fallback) {
@@ -1331,7 +827,6 @@ var ColorResolver = class {
1331
827
  };
1332
828
  }
1333
829
  };
1334
- //#endregion
1335
- export { MinimapWorkerClient, MinimapWorkerOwner, canUseMinimapWorker };
830
+ export { MinimapWorkerClient, canUseMinimapWorker };
1336
831
 
1337
832
  //# sourceMappingURL=workerClient.js.map