stream-monaco 0.0.40 → 0.0.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{index.base-BB334pQY.d.ts → index.base-CGq2Nep1.d.ts} +29 -4
- package/dist/{index.base-uTGkC8S0.d.cts → index.base-CovAkDA-.d.cts} +29 -4
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.legacy.cjs +1 -1
- package/dist/index.legacy.d.cts +1 -1
- package/dist/index.legacy.d.ts +1 -1
- package/dist/index.legacy.js +1 -1
- package/dist/{preloadMonacoWorkers.shared-f9Ole_8P.js → preloadMonacoWorkers.shared-C6J5pk0l.js} +209 -90
- package/dist/{preloadMonacoWorkers.shared-DoDO6Bui.cjs → preloadMonacoWorkers.shared-CASMnPWz.cjs} +209 -90
- package/package.json +29 -30
package/dist/{preloadMonacoWorkers.shared-f9Ole_8P.js → preloadMonacoWorkers.shared-C6J5pk0l.js}
RENAMED
|
@@ -264,32 +264,45 @@ function error(tag, ...args) {
|
|
|
264
264
|
|
|
265
265
|
//#endregion
|
|
266
266
|
//#region src/utils/height.ts
|
|
267
|
-
|
|
267
|
+
const DEFAULT_TRANSITION_MS = 120;
|
|
268
|
+
const DEFAULT_TRANSITION_EASING = "cubic-bezier(0.4, 0, 0.2, 1)";
|
|
269
|
+
const DEFAULT_HYSTERESIS_PX = 12;
|
|
270
|
+
const DEFAULT_DEBOUNCE_MS = 0;
|
|
271
|
+
function prefersReducedMotion() {
|
|
272
|
+
return typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
273
|
+
}
|
|
274
|
+
function createHeightManager(container, computeNext, options = {}) {
|
|
275
|
+
const transitionMs = Math.max(0, options.transitionMs ?? DEFAULT_TRANSITION_MS);
|
|
276
|
+
const transitionEasing = options.transitionEasing ?? DEFAULT_TRANSITION_EASING;
|
|
277
|
+
const hysteresisPx = Math.max(0, options.hysteresisPx ?? DEFAULT_HYSTERESIS_PX);
|
|
278
|
+
const debounceMs = Math.max(0, options.debounceMs ?? DEFAULT_DEBOUNCE_MS);
|
|
279
|
+
const transitionEnabled = options.smooth === true && transitionMs > 0 && !prefersReducedMotion();
|
|
280
|
+
const previousTransition = container.style.transition || "";
|
|
281
|
+
const heightTransition = `height ${transitionMs}ms ${transitionEasing}`;
|
|
282
|
+
if (transitionEnabled) container.style.transition = previousTransition ? `${previousTransition}, ${heightTransition}` : heightTransition;
|
|
268
283
|
let raf = null;
|
|
269
284
|
let debounceTimer = null;
|
|
270
285
|
let lastApplied = -1;
|
|
271
286
|
let suppressed = false;
|
|
272
|
-
const HYSTERESIS_PX = 12;
|
|
273
|
-
const DEBOUNCE_MS = 0;
|
|
274
287
|
function apply() {
|
|
275
288
|
var _container$getBoundin;
|
|
276
289
|
const next = computeNext();
|
|
277
|
-
if (next == null) return;
|
|
290
|
+
if (next == null) return null;
|
|
278
291
|
log("heightManager", "computeNext ->", {
|
|
279
292
|
next,
|
|
280
293
|
lastApplied
|
|
281
294
|
});
|
|
282
295
|
if (!Number.isFinite(next) || next <= 0) {
|
|
283
296
|
log("heightManager", "invalid next height, ignoring", next);
|
|
284
|
-
return;
|
|
297
|
+
return null;
|
|
285
298
|
}
|
|
286
299
|
const currentHeight = Number.parseFloat(container.style.height || "") || ((_container$getBoundin = container.getBoundingClientRect) === null || _container$getBoundin === void 0 ? void 0 : _container$getBoundin.call(container).height) || 0;
|
|
287
|
-
if (currentHeight > 0 && Math.abs(next - currentHeight) <=
|
|
300
|
+
if (currentHeight > 0 && Math.abs(next - currentHeight) <= hysteresisPx) {
|
|
288
301
|
lastApplied = next;
|
|
289
|
-
return;
|
|
302
|
+
return next;
|
|
290
303
|
}
|
|
291
|
-
if (lastApplied !== -1 && Math.abs(next - lastApplied) <=
|
|
292
|
-
if (next === lastApplied) return;
|
|
304
|
+
if (lastApplied !== -1 && Math.abs(next - lastApplied) <= hysteresisPx) return next;
|
|
305
|
+
if (next === lastApplied) return next;
|
|
293
306
|
suppressed = true;
|
|
294
307
|
container.style.height = `${next}px`;
|
|
295
308
|
lastApplied = next;
|
|
@@ -297,13 +310,14 @@ function createHeightManager(container, computeNext) {
|
|
|
297
310
|
queueMicrotask(() => {
|
|
298
311
|
suppressed = false;
|
|
299
312
|
});
|
|
313
|
+
return next;
|
|
300
314
|
}
|
|
301
315
|
function scheduleApply() {
|
|
302
316
|
if (debounceTimer != null) {
|
|
303
317
|
clearTimeout(debounceTimer);
|
|
304
318
|
debounceTimer = null;
|
|
305
319
|
}
|
|
306
|
-
if (
|
|
320
|
+
if (debounceMs === 0) {
|
|
307
321
|
if (raf != null) return;
|
|
308
322
|
raf = requestAnimationFrame(() => {
|
|
309
323
|
raf = null;
|
|
@@ -318,11 +332,22 @@ function createHeightManager(container, computeNext) {
|
|
|
318
332
|
raf = null;
|
|
319
333
|
apply();
|
|
320
334
|
});
|
|
321
|
-
},
|
|
335
|
+
}, debounceMs);
|
|
322
336
|
}
|
|
323
337
|
function update() {
|
|
324
338
|
scheduleApply();
|
|
325
339
|
}
|
|
340
|
+
function updateNow() {
|
|
341
|
+
if (raf != null) {
|
|
342
|
+
cancelAnimationFrame(raf);
|
|
343
|
+
raf = null;
|
|
344
|
+
}
|
|
345
|
+
if (debounceTimer != null) {
|
|
346
|
+
clearTimeout(debounceTimer);
|
|
347
|
+
debounceTimer = null;
|
|
348
|
+
}
|
|
349
|
+
return apply();
|
|
350
|
+
}
|
|
326
351
|
function dispose() {
|
|
327
352
|
if (raf != null) {
|
|
328
353
|
cancelAnimationFrame(raf);
|
|
@@ -332,6 +357,10 @@ function createHeightManager(container, computeNext) {
|
|
|
332
357
|
clearTimeout(debounceTimer);
|
|
333
358
|
debounceTimer = null;
|
|
334
359
|
}
|
|
360
|
+
if (transitionEnabled) {
|
|
361
|
+
const currentTransition = container.style.transition || "";
|
|
362
|
+
if (currentTransition.includes(heightTransition)) container.style.transition = currentTransition.replace(heightTransition, "").replace(/\s*,\s*,\s*/g, ", ").replace(/^\s*,\s*|\s*,\s*$/g, "").trim();
|
|
363
|
+
}
|
|
335
364
|
}
|
|
336
365
|
function isSuppressed() {
|
|
337
366
|
return suppressed;
|
|
@@ -339,11 +368,16 @@ function createHeightManager(container, computeNext) {
|
|
|
339
368
|
function getLastApplied() {
|
|
340
369
|
return lastApplied;
|
|
341
370
|
}
|
|
371
|
+
function getTransitionMs() {
|
|
372
|
+
return transitionEnabled ? transitionMs : 0;
|
|
373
|
+
}
|
|
342
374
|
return {
|
|
343
375
|
update,
|
|
376
|
+
updateNow,
|
|
344
377
|
dispose,
|
|
345
378
|
isSuppressed,
|
|
346
|
-
getLastApplied
|
|
379
|
+
getLastApplied,
|
|
380
|
+
getTransitionMs
|
|
347
381
|
};
|
|
348
382
|
}
|
|
349
383
|
|
|
@@ -1434,6 +1468,7 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
1434
1468
|
}
|
|
1435
1469
|
}
|
|
1436
1470
|
clearAsyncWork() {
|
|
1471
|
+
this.revealTicketDiff += 1;
|
|
1437
1472
|
this.cancelRafs();
|
|
1438
1473
|
this.pendingDiffUpdate = null;
|
|
1439
1474
|
this.lastKnownModifiedDirty = false;
|
|
@@ -4076,6 +4111,8 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
4076
4111
|
this.createDomDisposable(this.diffHunkDisposables, this.diffHunkUpperNode, "mouseleave", () => this.scheduleHideDiffHunkActions());
|
|
4077
4112
|
this.createDomDisposable(this.diffHunkDisposables, this.diffHunkLowerNode, "mouseenter", () => this.cancelScheduledHideDiffHunkActions());
|
|
4078
4113
|
this.createDomDisposable(this.diffHunkDisposables, this.diffHunkLowerNode, "mouseleave", () => this.scheduleHideDiffHunkActions());
|
|
4114
|
+
this.createDomDisposable(this.diffHunkDisposables, this.diffHunkUpperNode, "wheel", (event) => this.handleDiffHunkWheel(event, "upper"));
|
|
4115
|
+
this.createDomDisposable(this.diffHunkDisposables, this.diffHunkLowerNode, "wheel", (event) => this.handleDiffHunkWheel(event, "lower"));
|
|
4079
4116
|
overlay.append(this.diffHunkUpperNode, this.diffHunkLowerNode);
|
|
4080
4117
|
const originalEditor = this.diffEditorView.getOriginalEditor();
|
|
4081
4118
|
const modifiedEditor = this.diffEditorView.getModifiedEditor();
|
|
@@ -4099,6 +4136,17 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
4099
4136
|
}));
|
|
4100
4137
|
this.diffHunkLineChanges = this.getEffectiveLineChanges();
|
|
4101
4138
|
}
|
|
4139
|
+
handleDiffHunkWheel(event, side) {
|
|
4140
|
+
var _editor$setScrollLeft, _editor$getScrollLeft, _editor$setScrollTop, _editor$getScrollTop2;
|
|
4141
|
+
if (Math.abs(event.deltaX) < .5 && Math.abs(event.deltaY) < .5) return;
|
|
4142
|
+
if (!this.diffEditorView) return;
|
|
4143
|
+
const editor = this.isDiffInlineMode() || side === "lower" ? this.diffEditorView.getModifiedEditor() : this.diffEditorView.getOriginalEditor();
|
|
4144
|
+
event.preventDefault();
|
|
4145
|
+
event.stopPropagation();
|
|
4146
|
+
(_editor$setScrollLeft = editor.setScrollLeft) === null || _editor$setScrollLeft === void 0 || _editor$setScrollLeft.call(editor, (((_editor$getScrollLeft = editor.getScrollLeft) === null || _editor$getScrollLeft === void 0 ? void 0 : _editor$getScrollLeft.call(editor)) ?? 0) + event.deltaX);
|
|
4147
|
+
(_editor$setScrollTop = editor.setScrollTop) === null || _editor$setScrollTop === void 0 || _editor$setScrollTop.call(editor, (((_editor$getScrollTop2 = editor.getScrollTop) === null || _editor$getScrollTop2 === void 0 ? void 0 : _editor$getScrollTop2.call(editor)) ?? 0) + event.deltaY);
|
|
4148
|
+
this.hideDiffHunkActions();
|
|
4149
|
+
}
|
|
4102
4150
|
cancelScheduledHideDiffHunkActions() {
|
|
4103
4151
|
if (this.diffHunkHideTimer != null) {
|
|
4104
4152
|
clearTimeout(this.diffHunkHideTimer);
|
|
@@ -4971,7 +5019,6 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
4971
5019
|
this.lastContainer.innerHTML = "";
|
|
4972
5020
|
this.lastContainer = null;
|
|
4973
5021
|
}
|
|
4974
|
-
this.revealTicketDiff = 0;
|
|
4975
5022
|
this.lastRevealLineDiff = null;
|
|
4976
5023
|
this.diffPersistedUnchangedModelState = null;
|
|
4977
5024
|
this.diffPreviousUnchangedModelState = null;
|
|
@@ -4999,7 +5046,6 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
4999
5046
|
this.diffHeightManager.dispose();
|
|
5000
5047
|
this.diffHeightManager = null;
|
|
5001
5048
|
}
|
|
5002
|
-
this.revealTicketDiff = 0;
|
|
5003
5049
|
this.lastRevealLineDiff = null;
|
|
5004
5050
|
this.diffPersistedUnchangedModelState = null;
|
|
5005
5051
|
this.diffPreviousUnchangedModelState = null;
|
|
@@ -5278,6 +5324,12 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
5278
5324
|
|
|
5279
5325
|
//#endregion
|
|
5280
5326
|
//#region src/core/EditorManager.ts
|
|
5327
|
+
const defaultHeightTransitionMs = 120;
|
|
5328
|
+
const defaultHeightTransitionEasing = "cubic-bezier(0.4, 0, 0.2, 1)";
|
|
5329
|
+
const smoothHeightTolerancePx = 1;
|
|
5330
|
+
const legacyHeightTolerancePx = 12;
|
|
5331
|
+
const smoothHeightDebounceMs = 16;
|
|
5332
|
+
const legacyHeightDebounceMs = 0;
|
|
5281
5333
|
var EditorManager = class {
|
|
5282
5334
|
editorView = null;
|
|
5283
5335
|
lastContainer = null;
|
|
@@ -5324,10 +5376,12 @@ var EditorManager = class {
|
|
|
5324
5376
|
appendBufferScheduled = false;
|
|
5325
5377
|
rafScheduler = createRafScheduler();
|
|
5326
5378
|
editorHeightManager = null;
|
|
5379
|
+
previousScrollbarGutter = null;
|
|
5327
5380
|
revealDebounceId = null;
|
|
5328
5381
|
revealDebounceMs = defaultRevealDebounceMs;
|
|
5329
5382
|
revealIdleTimerId = null;
|
|
5330
5383
|
revealTicket = 0;
|
|
5384
|
+
layoutTicket = 0;
|
|
5331
5385
|
revealStrategyOption;
|
|
5332
5386
|
revealBatchOnIdleMsOption;
|
|
5333
5387
|
scrollWatcherSuppressionMs = 500;
|
|
@@ -5352,6 +5406,7 @@ var EditorManager = class {
|
|
|
5352
5406
|
this.rafScheduler.cancel("maybe-scroll");
|
|
5353
5407
|
this.rafScheduler.cancel("reveal");
|
|
5354
5408
|
this.rafScheduler.cancel("immediate-reveal");
|
|
5409
|
+
this.rafScheduler.cancel("layout-after-height");
|
|
5355
5410
|
this.rafScheduler.cancel("maybe-resume");
|
|
5356
5411
|
this.rafScheduler.cancel("append");
|
|
5357
5412
|
}
|
|
@@ -5370,6 +5425,8 @@ var EditorManager = class {
|
|
|
5370
5425
|
this.appendBuffer.length = 0;
|
|
5371
5426
|
}
|
|
5372
5427
|
clearAsyncWork() {
|
|
5428
|
+
this.revealTicket += 1;
|
|
5429
|
+
this.layoutTicket += 1;
|
|
5373
5430
|
this.cancelRafs();
|
|
5374
5431
|
this.pendingUpdate = null;
|
|
5375
5432
|
this.lastKnownCodeDirty = false;
|
|
@@ -5414,6 +5471,37 @@ var EditorManager = class {
|
|
|
5414
5471
|
if (!m) return false;
|
|
5415
5472
|
return this._hasScrollBar = m.scrollHeight > m.computedHeight + padding / 2;
|
|
5416
5473
|
}
|
|
5474
|
+
isSmoothHeightTransitionEnabled() {
|
|
5475
|
+
return this.options.smoothHeightTransition ?? false;
|
|
5476
|
+
}
|
|
5477
|
+
isAutomaticLayoutEnabled() {
|
|
5478
|
+
return this.options.automaticLayout !== false;
|
|
5479
|
+
}
|
|
5480
|
+
getHeightChangeTolerancePx() {
|
|
5481
|
+
return this.options.heightChangeTolerancePx ?? (this.isSmoothHeightTransitionEnabled() ? smoothHeightTolerancePx : legacyHeightTolerancePx);
|
|
5482
|
+
}
|
|
5483
|
+
getHeightManagerOptions() {
|
|
5484
|
+
const smooth = this.isSmoothHeightTransitionEnabled();
|
|
5485
|
+
return {
|
|
5486
|
+
smooth,
|
|
5487
|
+
transitionMs: this.options.heightTransitionMs ?? defaultHeightTransitionMs,
|
|
5488
|
+
transitionEasing: this.options.heightTransitionEasing ?? defaultHeightTransitionEasing,
|
|
5489
|
+
debounceMs: this.options.heightUpdateDebounceMs ?? (smooth ? smoothHeightDebounceMs : legacyHeightDebounceMs),
|
|
5490
|
+
hysteresisPx: this.getHeightChangeTolerancePx()
|
|
5491
|
+
};
|
|
5492
|
+
}
|
|
5493
|
+
setOverflowForHeight(computed$2) {
|
|
5494
|
+
if (!this.lastContainer) return null;
|
|
5495
|
+
const next = computed$2 >= this.maxHeightValue - 1 ? "auto" : "hidden";
|
|
5496
|
+
const prev = this.lastContainer.style.overflow;
|
|
5497
|
+
if (prev !== next) this.lastContainer.style.overflow = next;
|
|
5498
|
+
if (next === "hidden") this._hasScrollBar = false;
|
|
5499
|
+
return {
|
|
5500
|
+
prev,
|
|
5501
|
+
next,
|
|
5502
|
+
changed: prev !== next
|
|
5503
|
+
};
|
|
5504
|
+
}
|
|
5417
5505
|
userIsNearBottom() {
|
|
5418
5506
|
if (!this.editorView) return true;
|
|
5419
5507
|
const m = this.measureViewport();
|
|
@@ -5548,46 +5636,89 @@ var EditorManager = class {
|
|
|
5548
5636
|
this.lastScrollTop = ((_this$editorView4 = this.editorView) === null || _this$editorView4 === void 0 || (_this$editorView4$get = _this$editorView4.getScrollTop) === null || _this$editorView4$get === void 0 ? void 0 : _this$editorView4$get.call(_this$editorView4)) ?? this.lastScrollTop;
|
|
5549
5637
|
} catch {}
|
|
5550
5638
|
}
|
|
5551
|
-
|
|
5552
|
-
|
|
5553
|
-
|
|
5554
|
-
|
|
5555
|
-
|
|
5556
|
-
|
|
5557
|
-
|
|
5558
|
-
|
|
5559
|
-
|
|
5639
|
+
shouldRevealAfterLayout() {
|
|
5640
|
+
return this.autoScrollOnUpdate && this.shouldAutoScroll;
|
|
5641
|
+
}
|
|
5642
|
+
getRevealSuppressionMs() {
|
|
5643
|
+
var _this$editorHeightMan, _this$editorHeightMan2;
|
|
5644
|
+
const transitionMs = ((_this$editorHeightMan = this.editorHeightManager) === null || _this$editorHeightMan === void 0 || (_this$editorHeightMan2 = _this$editorHeightMan.getTransitionMs) === null || _this$editorHeightMan2 === void 0 ? void 0 : _this$editorHeightMan2.call(_this$editorHeightMan)) ?? 0;
|
|
5645
|
+
return Math.max(this.scrollWatcherSuppressionMs, transitionMs + 100);
|
|
5646
|
+
}
|
|
5647
|
+
syncHeightAndRevealAfterContentChange(targetLine) {
|
|
5648
|
+
const shouldReveal = this.shouldRevealAfterLayout();
|
|
5649
|
+
const willReveal = !!(shouldReveal && this.editorView && this.computedHeight(this.editorView) >= this.maxHeightValue - 1);
|
|
5650
|
+
if (willReveal) this.suppressScrollWatcher(this.getRevealSuppressionMs());
|
|
5651
|
+
const computed$2 = this.syncNonOverflowingLayout();
|
|
5652
|
+
if (computed$2 != null && computed$2 >= this.maxHeightValue - 1 && shouldReveal) {
|
|
5653
|
+
var _this$editorView5;
|
|
5654
|
+
const line = targetLine ?? ((_this$editorView5 = this.editorView) === null || _this$editorView5 === void 0 || (_this$editorView5 = _this$editorView5.getModel()) === null || _this$editorView5 === void 0 ? void 0 : _this$editorView5.getLineCount()) ?? 1;
|
|
5655
|
+
if (this.isSmoothHeightTransitionEnabled()) this.scheduleImmediateRevealAfterLayout(line);
|
|
5656
|
+
else this.forceReveal(line);
|
|
5657
|
+
} else if (!shouldReveal && targetLine != null) this.maybeScrollToBottom(targetLine);
|
|
5658
|
+
return computed$2;
|
|
5560
5659
|
}
|
|
5561
5660
|
syncNonOverflowingLayout() {
|
|
5562
|
-
var _this$
|
|
5661
|
+
var _this$editorHeightMan3, _this$editorHeightMan4;
|
|
5563
5662
|
if (!this.editorView || !this.lastContainer) return null;
|
|
5564
5663
|
const computed$2 = this.computedHeight(this.editorView);
|
|
5664
|
+
const needsRevealSync = computed$2 >= this.maxHeightValue - 1 && this.shouldRevealAfterLayout();
|
|
5665
|
+
const useSmoothHeightTransition = this.isSmoothHeightTransitionEnabled();
|
|
5666
|
+
if (needsRevealSync || !useSmoothHeightTransition) (_this$editorHeightMan3 = this.editorHeightManager) === null || _this$editorHeightMan3 === void 0 || _this$editorHeightMan3.updateNow();
|
|
5667
|
+
else (_this$editorHeightMan4 = this.editorHeightManager) === null || _this$editorHeightMan4 === void 0 || _this$editorHeightMan4.update();
|
|
5668
|
+
this.setOverflowForHeight(computed$2);
|
|
5565
5669
|
if (computed$2 >= this.maxHeightValue - 1) {
|
|
5566
|
-
|
|
5670
|
+
if (useSmoothHeightTransition) this.scheduleLayoutAfterHeightApplied(computed$2);
|
|
5567
5671
|
return computed$2;
|
|
5568
5672
|
}
|
|
5569
|
-
const currentHeight = Number.parseFloat(this.lastContainer.style.height || "") || ((_this$lastContainer$g = (_this$lastContainer = this.lastContainer).getBoundingClientRect) === null || _this$lastContainer$g === void 0 ? void 0 : _this$lastContainer$g.call(_this$lastContainer).height) || 0;
|
|
5570
|
-
if (currentHeight <= 0 || Math.abs(computed$2 - currentHeight) > 12) this.lastContainer.style.height = `${computed$2}px`;
|
|
5571
|
-
this.lastContainer.style.overflow = "hidden";
|
|
5572
5673
|
this._hasScrollBar = false;
|
|
5674
|
+
if (useSmoothHeightTransition) {
|
|
5675
|
+
this.scheduleLayoutAfterHeightApplied(computed$2);
|
|
5676
|
+
try {
|
|
5677
|
+
var _this$editorView$getS3, _this$editorView6, _this$editorView$setS, _this$editorView7;
|
|
5678
|
+
if ((((_this$editorView$getS3 = (_this$editorView6 = this.editorView).getScrollTop) === null || _this$editorView$getS3 === void 0 ? void 0 : _this$editorView$getS3.call(_this$editorView6)) ?? 0) !== 0) (_this$editorView$setS = (_this$editorView7 = this.editorView).setScrollTop) === null || _this$editorView$setS === void 0 || _this$editorView$setS.call(_this$editorView7, 0);
|
|
5679
|
+
this.lastScrollTop = 0;
|
|
5680
|
+
} catch {}
|
|
5681
|
+
return computed$2;
|
|
5682
|
+
}
|
|
5573
5683
|
try {
|
|
5574
|
-
var _this$editorView$layo, _this$
|
|
5575
|
-
(_this$editorView$layo = (_this$
|
|
5684
|
+
var _this$editorView$layo, _this$editorView8;
|
|
5685
|
+
(_this$editorView$layo = (_this$editorView8 = this.editorView).layout) === null || _this$editorView$layo === void 0 || _this$editorView$layo.call(_this$editorView8);
|
|
5576
5686
|
} catch {}
|
|
5577
5687
|
try {
|
|
5578
|
-
var _this$editorView$
|
|
5579
|
-
if ((((_this$editorView$
|
|
5688
|
+
var _this$editorView$getS4, _this$editorView9, _this$editorView$setS2, _this$editorView10;
|
|
5689
|
+
if ((((_this$editorView$getS4 = (_this$editorView9 = this.editorView).getScrollTop) === null || _this$editorView$getS4 === void 0 ? void 0 : _this$editorView$getS4.call(_this$editorView9)) ?? 0) !== 0) (_this$editorView$setS2 = (_this$editorView10 = this.editorView).setScrollTop) === null || _this$editorView$setS2 === void 0 || _this$editorView$setS2.call(_this$editorView10, 0);
|
|
5580
5690
|
this.lastScrollTop = 0;
|
|
5581
5691
|
} catch {}
|
|
5582
5692
|
return computed$2;
|
|
5583
5693
|
}
|
|
5694
|
+
scheduleLayoutAfterHeightApplied(target) {
|
|
5695
|
+
if (this.isAutomaticLayoutEnabled() || !this.editorView) return;
|
|
5696
|
+
const editor = this.editorView;
|
|
5697
|
+
const ticket = ++this.layoutTicket;
|
|
5698
|
+
this.rafScheduler.schedule("layout-after-height", async () => {
|
|
5699
|
+
try {
|
|
5700
|
+
var _editor$layout;
|
|
5701
|
+
await this.waitForHeightApplied(target, 500);
|
|
5702
|
+
if (ticket !== this.layoutTicket || this.editorView !== editor) return;
|
|
5703
|
+
(_editor$layout = editor.layout) === null || _editor$layout === void 0 || _editor$layout.call(editor);
|
|
5704
|
+
this.measureViewport();
|
|
5705
|
+
} catch (err) {
|
|
5706
|
+
error("EditorManager", "scheduleLayoutAfterHeightApplied error", err);
|
|
5707
|
+
}
|
|
5708
|
+
});
|
|
5709
|
+
}
|
|
5584
5710
|
async createEditor(container, code, language, currentTheme) {
|
|
5585
|
-
var _this$editorView$
|
|
5711
|
+
var _this$editorView$getS5, _this$editorView11, _this$editorView$getO, _this$editorView12, _this$editorView$getM, _this$editorView$onDi, _this$editorView13;
|
|
5586
5712
|
this.cleanup();
|
|
5587
5713
|
this.lastContainer = container;
|
|
5588
5714
|
this.initDebugFlag();
|
|
5589
5715
|
this.dlog("createEditor container, maxHeight", this.maxHeightValue);
|
|
5590
5716
|
container.style.overflow = "hidden";
|
|
5717
|
+
this.previousScrollbarGutter = null;
|
|
5718
|
+
if (this.isSmoothHeightTransitionEnabled()) {
|
|
5719
|
+
this.previousScrollbarGutter = container.style.scrollbarGutter || "";
|
|
5720
|
+
container.style.scrollbarGutter = "stable";
|
|
5721
|
+
}
|
|
5591
5722
|
container.style.maxHeight = this.maxHeightCSS;
|
|
5592
5723
|
this.editorView = monaco_shim_exports.editor.create(container, {
|
|
5593
5724
|
value: code,
|
|
@@ -5621,43 +5752,29 @@ var EditorManager = class {
|
|
|
5621
5752
|
this.editorHeightManager = createHeightManager(container, () => {
|
|
5622
5753
|
const computed$2 = this.computedHeight(this.editorView);
|
|
5623
5754
|
return Math.min(computed$2, this.maxHeightValue);
|
|
5624
|
-
});
|
|
5625
|
-
this.editorHeightManager.
|
|
5626
|
-
|
|
5627
|
-
|
|
5628
|
-
|
|
5629
|
-
container.style.overflow = "auto";
|
|
5630
|
-
this.dlog("applied immediate maxHeight on createEditor", this.maxHeightValue);
|
|
5631
|
-
}
|
|
5632
|
-
this.cachedScrollHeight = ((_this$editorView$getS4 = (_this$editorView8 = this.editorView).getScrollHeight) === null || _this$editorView$getS4 === void 0 ? void 0 : _this$editorView$getS4.call(_this$editorView8)) ?? null;
|
|
5633
|
-
this.cachedLineHeight = ((_this$editorView$getO = (_this$editorView9 = this.editorView).getOption) === null || _this$editorView$getO === void 0 ? void 0 : _this$editorView$getO.call(_this$editorView9, monaco_shim_exports.editor.EditorOption.lineHeight)) ?? null;
|
|
5755
|
+
}, this.getHeightManagerOptions());
|
|
5756
|
+
const initialComputed = this.editorHeightManager.updateNow();
|
|
5757
|
+
if (initialComputed != null) this.setOverflowForHeight(initialComputed);
|
|
5758
|
+
this.cachedScrollHeight = ((_this$editorView$getS5 = (_this$editorView11 = this.editorView).getScrollHeight) === null || _this$editorView$getS5 === void 0 ? void 0 : _this$editorView$getS5.call(_this$editorView11)) ?? null;
|
|
5759
|
+
this.cachedLineHeight = ((_this$editorView$getO = (_this$editorView12 = this.editorView).getOption) === null || _this$editorView$getO === void 0 ? void 0 : _this$editorView$getO.call(_this$editorView12, monaco_shim_exports.editor.EditorOption.lineHeight)) ?? null;
|
|
5634
5760
|
this.cachedComputedHeight = this.computedHeight(this.editorView);
|
|
5635
5761
|
this.cachedLineCount = ((_this$editorView$getM = this.editorView.getModel()) === null || _this$editorView$getM === void 0 ? void 0 : _this$editorView$getM.getLineCount()) ?? null;
|
|
5636
|
-
(_this$editorView$onDi = (_this$
|
|
5762
|
+
(_this$editorView$onDi = (_this$editorView13 = this.editorView).onDidContentSizeChange) === null || _this$editorView$onDi === void 0 || _this$editorView$onDi.call(_this$editorView13, () => {
|
|
5637
5763
|
this._hasScrollBar = false;
|
|
5638
5764
|
this.rafScheduler.schedule("content-size-change", () => {
|
|
5639
5765
|
try {
|
|
5640
|
-
var _this$
|
|
5766
|
+
var _this$editorView14, _this$editorHeightMan5;
|
|
5641
5767
|
this.dlog("content-size-change frame");
|
|
5642
|
-
this.cachedLineCount = ((_this$
|
|
5768
|
+
this.cachedLineCount = ((_this$editorView14 = this.editorView) === null || _this$editorView14 === void 0 || (_this$editorView14 = _this$editorView14.getModel()) === null || _this$editorView14 === void 0 ? void 0 : _this$editorView14.getLineCount()) ?? this.cachedLineCount;
|
|
5643
5769
|
this.cachedComputedHeight = null;
|
|
5644
5770
|
const m = this.measureViewport();
|
|
5645
5771
|
this.dlog("content-size-change measure", m);
|
|
5646
|
-
if ((_this$
|
|
5772
|
+
if ((_this$editorHeightMan5 = this.editorHeightManager) === null || _this$editorHeightMan5 === void 0 ? void 0 : _this$editorHeightMan5.isSuppressed()) {
|
|
5647
5773
|
this.dlog("content-size-change skipped height update (suppressed)");
|
|
5648
5774
|
return;
|
|
5649
5775
|
}
|
|
5650
|
-
this.dlog("content-size-change
|
|
5651
|
-
|
|
5652
|
-
const computed$2 = this.computedHeight(this.editorView);
|
|
5653
|
-
if (this.lastContainer) {
|
|
5654
|
-
const prevOverflow = this.lastContainer.style.overflow;
|
|
5655
|
-
const newOverflow = computed$2 >= this.maxHeightValue - 1 ? "auto" : "hidden";
|
|
5656
|
-
if (prevOverflow !== newOverflow) {
|
|
5657
|
-
this.lastContainer.style.overflow = newOverflow;
|
|
5658
|
-
if (newOverflow === "auto" && this.shouldAutoScroll) this.maybeScrollToBottom();
|
|
5659
|
-
}
|
|
5660
|
-
}
|
|
5776
|
+
this.dlog("content-size-change syncing height/reveal");
|
|
5777
|
+
this.syncHeightAndRevealAfterContentChange();
|
|
5661
5778
|
} catch (err) {
|
|
5662
5779
|
error("EditorManager", "content-size-change error", err);
|
|
5663
5780
|
}
|
|
@@ -5725,6 +5842,11 @@ var EditorManager = class {
|
|
|
5725
5842
|
if (target !== -1 && this.editorHeightManager) await this.waitForHeightApplied(target, 500);
|
|
5726
5843
|
else await new Promise((r) => requestAnimationFrame(() => requestAnimationFrame(() => r())));
|
|
5727
5844
|
this.dlog("running delayed immediate reveal", "ticket=", ticket, "line=", line);
|
|
5845
|
+
if (ticket !== this.revealTicket) {
|
|
5846
|
+
this.dlog("delayed immediate reveal skipped, stale ticket", ticket, "current", this.revealTicket);
|
|
5847
|
+
return;
|
|
5848
|
+
}
|
|
5849
|
+
this.suppressScrollWatcher(this.scrollWatcherSuppressionMs);
|
|
5728
5850
|
this.performImmediateReveal(line, ticket);
|
|
5729
5851
|
} catch (err) {
|
|
5730
5852
|
error("EditorManager", "scheduleImmediateRevealAfterLayout error", err);
|
|
@@ -5733,20 +5855,33 @@ var EditorManager = class {
|
|
|
5733
5855
|
}
|
|
5734
5856
|
waitForHeightApplied(target, timeoutMs = 500) {
|
|
5735
5857
|
return new Promise((resolve) => {
|
|
5858
|
+
var _this$editorHeightMan6, _this$editorHeightMan7;
|
|
5736
5859
|
const start = typeof performance !== "undefined" && performance.now ? performance.now() : Date.now();
|
|
5860
|
+
const tolerance = this.getHeightChangeTolerancePx();
|
|
5861
|
+
const transitionMs = ((_this$editorHeightMan6 = this.editorHeightManager) === null || _this$editorHeightMan6 === void 0 || (_this$editorHeightMan7 = _this$editorHeightMan6.getTransitionMs) === null || _this$editorHeightMan7 === void 0 ? void 0 : _this$editorHeightMan7.call(_this$editorHeightMan6)) ?? 0;
|
|
5862
|
+
let settled = false;
|
|
5863
|
+
const resolveAfterSettle = () => {
|
|
5864
|
+
if (settled) return;
|
|
5865
|
+
settled = true;
|
|
5866
|
+
if (transitionMs > 0) {
|
|
5867
|
+
setTimeout(resolve, transitionMs);
|
|
5868
|
+
return;
|
|
5869
|
+
}
|
|
5870
|
+
requestAnimationFrame(() => requestAnimationFrame(() => resolve()));
|
|
5871
|
+
};
|
|
5737
5872
|
const check = () => {
|
|
5738
5873
|
try {
|
|
5739
|
-
var _this$
|
|
5740
|
-
const last = ((_this$
|
|
5741
|
-
if (last !== -1 && Math.abs(last - target) <=
|
|
5874
|
+
var _this$editorHeightMan8, _this$editorHeightMan9;
|
|
5875
|
+
const last = ((_this$editorHeightMan8 = this.editorHeightManager) === null || _this$editorHeightMan8 === void 0 || (_this$editorHeightMan9 = _this$editorHeightMan8.getLastApplied) === null || _this$editorHeightMan9 === void 0 ? void 0 : _this$editorHeightMan9.call(_this$editorHeightMan8)) ?? -1;
|
|
5876
|
+
if (last !== -1 && Math.abs(last - target) <= tolerance) {
|
|
5742
5877
|
this.dlog("waitForHeightApplied satisfied", last, "target=", target);
|
|
5743
|
-
|
|
5878
|
+
resolveAfterSettle();
|
|
5744
5879
|
return;
|
|
5745
5880
|
}
|
|
5746
5881
|
const now = typeof performance !== "undefined" && performance.now ? performance.now() : Date.now();
|
|
5747
5882
|
if (now - start > timeoutMs) {
|
|
5748
5883
|
log("EditorManager", "waitForHeightApplied timeout", last, "target=", target);
|
|
5749
|
-
|
|
5884
|
+
resolveAfterSettle();
|
|
5750
5885
|
return;
|
|
5751
5886
|
}
|
|
5752
5887
|
} catch {}
|
|
@@ -5798,12 +5933,7 @@ var EditorManager = class {
|
|
|
5798
5933
|
const newLineCount$1 = model.getLineCount();
|
|
5799
5934
|
this.cachedLineCount = newLineCount$1;
|
|
5800
5935
|
this.cachedComputedHeight = null;
|
|
5801
|
-
if (newLineCount$1 !== prevLineCount$1)
|
|
5802
|
-
const shouldImmediate = this.shouldPerformImmediateReveal();
|
|
5803
|
-
if (shouldImmediate) this.suppressScrollWatcher(this.scrollWatcherSuppressionMs);
|
|
5804
|
-
const computed$2 = this.syncNonOverflowingLayout();
|
|
5805
|
-
if (computed$2 != null && computed$2 >= this.maxHeightValue - 1) this.forceReveal(newLineCount$1);
|
|
5806
|
-
}
|
|
5936
|
+
if (newLineCount$1 !== prevLineCount$1) this.syncHeightAndRevealAfterContentChange(newLineCount$1);
|
|
5807
5937
|
return;
|
|
5808
5938
|
}
|
|
5809
5939
|
let prevCode;
|
|
@@ -5833,13 +5963,7 @@ var EditorManager = class {
|
|
|
5833
5963
|
const newLineCount = model.getLineCount();
|
|
5834
5964
|
this.cachedLineCount = newLineCount;
|
|
5835
5965
|
this.cachedComputedHeight = null;
|
|
5836
|
-
if (newLineCount !== prevLineCount)
|
|
5837
|
-
const shouldImmediate = this.shouldPerformImmediateReveal();
|
|
5838
|
-
if (shouldImmediate) this.suppressScrollWatcher(this.scrollWatcherSuppressionMs);
|
|
5839
|
-
this.syncNonOverflowingLayout();
|
|
5840
|
-
if (shouldImmediate) this.scheduleImmediateRevealAfterLayout(newLineCount);
|
|
5841
|
-
else this.maybeScrollToBottom(newLineCount);
|
|
5842
|
-
}
|
|
5966
|
+
if (newLineCount !== prevLineCount) this.syncHeightAndRevealAfterContentChange(newLineCount);
|
|
5843
5967
|
}
|
|
5844
5968
|
appendCode(appendText, codeLanguage) {
|
|
5845
5969
|
if (!this.editorView) return;
|
|
@@ -5871,10 +5995,7 @@ var EditorManager = class {
|
|
|
5871
5995
|
this.lastKnownCode = next;
|
|
5872
5996
|
const newLineCount = model.getLineCount();
|
|
5873
5997
|
this.cachedLineCount = newLineCount;
|
|
5874
|
-
if (newLineCount !== prevLineCount)
|
|
5875
|
-
this.syncNonOverflowingLayout();
|
|
5876
|
-
this.maybeScrollToBottom(newLineCount);
|
|
5877
|
-
}
|
|
5998
|
+
if (newLineCount !== prevLineCount) this.syncHeightAndRevealAfterContentChange(newLineCount);
|
|
5878
5999
|
return;
|
|
5879
6000
|
}
|
|
5880
6001
|
const res = computeMinimalEdit(prev, next);
|
|
@@ -5927,13 +6048,7 @@ var EditorManager = class {
|
|
|
5927
6048
|
if (lastLine !== newLineCount) {
|
|
5928
6049
|
this.cachedLineCount = newLineCount;
|
|
5929
6050
|
this.cachedComputedHeight = null;
|
|
5930
|
-
|
|
5931
|
-
if (shouldImmediate) this.suppressScrollWatcher(this.scrollWatcherSuppressionMs);
|
|
5932
|
-
this.syncNonOverflowingLayout();
|
|
5933
|
-
if (shouldImmediate) try {
|
|
5934
|
-
this.forceReveal(newLineCount);
|
|
5935
|
-
} catch {}
|
|
5936
|
-
else this.maybeScrollToBottom(newLineCount);
|
|
6051
|
+
this.syncHeightAndRevealAfterContentChange(newLineCount);
|
|
5937
6052
|
}
|
|
5938
6053
|
}
|
|
5939
6054
|
setLanguage(language, languages$1) {
|
|
@@ -5948,8 +6063,8 @@ var EditorManager = class {
|
|
|
5948
6063
|
return this.editorView;
|
|
5949
6064
|
}
|
|
5950
6065
|
getCode() {
|
|
5951
|
-
var _this$
|
|
5952
|
-
return ((_this$
|
|
6066
|
+
var _this$editorView15;
|
|
6067
|
+
return ((_this$editorView15 = this.editorView) === null || _this$editorView15 === void 0 || (_this$editorView15 = _this$editorView15.getModel()) === null || _this$editorView15 === void 0 ? void 0 : _this$editorView15.getValue()) ?? null;
|
|
5953
6068
|
}
|
|
5954
6069
|
setUpdateThrottleMs(ms) {
|
|
5955
6070
|
this.updateThrottleMs = ms;
|
|
@@ -5970,6 +6085,8 @@ var EditorManager = class {
|
|
|
5970
6085
|
}
|
|
5971
6086
|
this.lastKnownCode = null;
|
|
5972
6087
|
if (this.lastContainer) {
|
|
6088
|
+
if (this.previousScrollbarGutter != null) this.lastContainer.style.scrollbarGutter = this.previousScrollbarGutter;
|
|
6089
|
+
this.previousScrollbarGutter = null;
|
|
5973
6090
|
this.lastContainer.style.minHeight = "";
|
|
5974
6091
|
this.lastContainer.innerHTML = "";
|
|
5975
6092
|
this.lastContainer = null;
|
|
@@ -5994,6 +6111,8 @@ var EditorManager = class {
|
|
|
5994
6111
|
this._hasScrollBar = false;
|
|
5995
6112
|
this.shouldAutoScroll = !!this.autoScrollInitial;
|
|
5996
6113
|
this.lastScrollTop = 0;
|
|
6114
|
+
if (this.lastContainer && this.previousScrollbarGutter != null) this.lastContainer.style.scrollbarGutter = this.previousScrollbarGutter;
|
|
6115
|
+
this.previousScrollbarGutter = null;
|
|
5997
6116
|
if (this.editorHeightManager) {
|
|
5998
6117
|
this.editorHeightManager.dispose();
|
|
5999
6118
|
this.editorHeightManager = null;
|
|
@@ -6300,7 +6419,7 @@ let globalAppliedThemeName = null;
|
|
|
6300
6419
|
* @param {MonacoLanguage[]} [monacoOptions.languages] - 支持的编程语言数组
|
|
6301
6420
|
* @param {string} [monacoOptions.theme] - 初始主题名称
|
|
6302
6421
|
* @param {boolean} [monacoOptions.isCleanOnBeforeCreate] - 是否在创建前清理之前注册的资源, 默认为 true
|
|
6303
|
-
* @param {(monaco: typeof import('monaco-editor')) => monaco.IDisposable[]} [monacoOptions.onBeforeCreate] - 编辑器创建前的钩子函数
|
|
6422
|
+
* @param {(monaco: typeof import('monaco-editor/esm/vs/editor/editor.api')) => monaco.IDisposable[]} [monacoOptions.onBeforeCreate] - 编辑器创建前的钩子函数
|
|
6304
6423
|
*
|
|
6305
6424
|
* @returns {{
|
|
6306
6425
|
* createEditor: (container: HTMLElement, code: string, language: string) => Promise<monaco.editor.IStandaloneCodeEditor>,
|