stream-monaco 0.0.40 → 0.0.41
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-DoDO6Bui.cjs → preloadMonacoWorkers.shared-BT4GsCRM.cjs} +196 -90
- package/dist/{preloadMonacoWorkers.shared-f9Ole_8P.js → preloadMonacoWorkers.shared-CtSx-xKA.js} +196 -90
- package/package.json +29 -30
package/dist/{preloadMonacoWorkers.shared-DoDO6Bui.cjs → preloadMonacoWorkers.shared-BT4GsCRM.cjs}
RENAMED
|
@@ -269,32 +269,45 @@ function error(tag, ...args) {
|
|
|
269
269
|
|
|
270
270
|
//#endregion
|
|
271
271
|
//#region src/utils/height.ts
|
|
272
|
-
|
|
272
|
+
const DEFAULT_TRANSITION_MS = 120;
|
|
273
|
+
const DEFAULT_TRANSITION_EASING = "cubic-bezier(0.4, 0, 0.2, 1)";
|
|
274
|
+
const DEFAULT_HYSTERESIS_PX = 12;
|
|
275
|
+
const DEFAULT_DEBOUNCE_MS = 0;
|
|
276
|
+
function prefersReducedMotion() {
|
|
277
|
+
return typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
278
|
+
}
|
|
279
|
+
function createHeightManager(container, computeNext, options = {}) {
|
|
280
|
+
const transitionMs = Math.max(0, options.transitionMs ?? DEFAULT_TRANSITION_MS);
|
|
281
|
+
const transitionEasing = options.transitionEasing ?? DEFAULT_TRANSITION_EASING;
|
|
282
|
+
const hysteresisPx = Math.max(0, options.hysteresisPx ?? DEFAULT_HYSTERESIS_PX);
|
|
283
|
+
const debounceMs = Math.max(0, options.debounceMs ?? DEFAULT_DEBOUNCE_MS);
|
|
284
|
+
const transitionEnabled = options.smooth === true && transitionMs > 0 && !prefersReducedMotion();
|
|
285
|
+
const previousTransition = container.style.transition || "";
|
|
286
|
+
const heightTransition = `height ${transitionMs}ms ${transitionEasing}`;
|
|
287
|
+
if (transitionEnabled) container.style.transition = previousTransition ? `${previousTransition}, ${heightTransition}` : heightTransition;
|
|
273
288
|
let raf = null;
|
|
274
289
|
let debounceTimer = null;
|
|
275
290
|
let lastApplied = -1;
|
|
276
291
|
let suppressed = false;
|
|
277
|
-
const HYSTERESIS_PX = 12;
|
|
278
|
-
const DEBOUNCE_MS = 0;
|
|
279
292
|
function apply() {
|
|
280
293
|
var _container$getBoundin;
|
|
281
294
|
const next = computeNext();
|
|
282
|
-
if (next == null) return;
|
|
295
|
+
if (next == null) return null;
|
|
283
296
|
log("heightManager", "computeNext ->", {
|
|
284
297
|
next,
|
|
285
298
|
lastApplied
|
|
286
299
|
});
|
|
287
300
|
if (!Number.isFinite(next) || next <= 0) {
|
|
288
301
|
log("heightManager", "invalid next height, ignoring", next);
|
|
289
|
-
return;
|
|
302
|
+
return null;
|
|
290
303
|
}
|
|
291
304
|
const currentHeight = Number.parseFloat(container.style.height || "") || ((_container$getBoundin = container.getBoundingClientRect) === null || _container$getBoundin === void 0 ? void 0 : _container$getBoundin.call(container).height) || 0;
|
|
292
|
-
if (currentHeight > 0 && Math.abs(next - currentHeight) <=
|
|
305
|
+
if (currentHeight > 0 && Math.abs(next - currentHeight) <= hysteresisPx) {
|
|
293
306
|
lastApplied = next;
|
|
294
|
-
return;
|
|
307
|
+
return next;
|
|
295
308
|
}
|
|
296
|
-
if (lastApplied !== -1 && Math.abs(next - lastApplied) <=
|
|
297
|
-
if (next === lastApplied) return;
|
|
309
|
+
if (lastApplied !== -1 && Math.abs(next - lastApplied) <= hysteresisPx) return next;
|
|
310
|
+
if (next === lastApplied) return next;
|
|
298
311
|
suppressed = true;
|
|
299
312
|
container.style.height = `${next}px`;
|
|
300
313
|
lastApplied = next;
|
|
@@ -302,13 +315,14 @@ function createHeightManager(container, computeNext) {
|
|
|
302
315
|
queueMicrotask(() => {
|
|
303
316
|
suppressed = false;
|
|
304
317
|
});
|
|
318
|
+
return next;
|
|
305
319
|
}
|
|
306
320
|
function scheduleApply() {
|
|
307
321
|
if (debounceTimer != null) {
|
|
308
322
|
clearTimeout(debounceTimer);
|
|
309
323
|
debounceTimer = null;
|
|
310
324
|
}
|
|
311
|
-
if (
|
|
325
|
+
if (debounceMs === 0) {
|
|
312
326
|
if (raf != null) return;
|
|
313
327
|
raf = requestAnimationFrame(() => {
|
|
314
328
|
raf = null;
|
|
@@ -323,11 +337,22 @@ function createHeightManager(container, computeNext) {
|
|
|
323
337
|
raf = null;
|
|
324
338
|
apply();
|
|
325
339
|
});
|
|
326
|
-
},
|
|
340
|
+
}, debounceMs);
|
|
327
341
|
}
|
|
328
342
|
function update() {
|
|
329
343
|
scheduleApply();
|
|
330
344
|
}
|
|
345
|
+
function updateNow() {
|
|
346
|
+
if (raf != null) {
|
|
347
|
+
cancelAnimationFrame(raf);
|
|
348
|
+
raf = null;
|
|
349
|
+
}
|
|
350
|
+
if (debounceTimer != null) {
|
|
351
|
+
clearTimeout(debounceTimer);
|
|
352
|
+
debounceTimer = null;
|
|
353
|
+
}
|
|
354
|
+
return apply();
|
|
355
|
+
}
|
|
331
356
|
function dispose() {
|
|
332
357
|
if (raf != null) {
|
|
333
358
|
cancelAnimationFrame(raf);
|
|
@@ -337,6 +362,10 @@ function createHeightManager(container, computeNext) {
|
|
|
337
362
|
clearTimeout(debounceTimer);
|
|
338
363
|
debounceTimer = null;
|
|
339
364
|
}
|
|
365
|
+
if (transitionEnabled) {
|
|
366
|
+
const currentTransition = container.style.transition || "";
|
|
367
|
+
if (currentTransition.includes(heightTransition)) container.style.transition = currentTransition.replace(heightTransition, "").replace(/\s*,\s*,\s*/g, ", ").replace(/^\s*,\s*|\s*,\s*$/g, "").trim();
|
|
368
|
+
}
|
|
340
369
|
}
|
|
341
370
|
function isSuppressed() {
|
|
342
371
|
return suppressed;
|
|
@@ -344,11 +373,16 @@ function createHeightManager(container, computeNext) {
|
|
|
344
373
|
function getLastApplied() {
|
|
345
374
|
return lastApplied;
|
|
346
375
|
}
|
|
376
|
+
function getTransitionMs() {
|
|
377
|
+
return transitionEnabled ? transitionMs : 0;
|
|
378
|
+
}
|
|
347
379
|
return {
|
|
348
380
|
update,
|
|
381
|
+
updateNow,
|
|
349
382
|
dispose,
|
|
350
383
|
isSuppressed,
|
|
351
|
-
getLastApplied
|
|
384
|
+
getLastApplied,
|
|
385
|
+
getTransitionMs
|
|
352
386
|
};
|
|
353
387
|
}
|
|
354
388
|
|
|
@@ -1439,6 +1473,7 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
1439
1473
|
}
|
|
1440
1474
|
}
|
|
1441
1475
|
clearAsyncWork() {
|
|
1476
|
+
this.revealTicketDiff += 1;
|
|
1442
1477
|
this.cancelRafs();
|
|
1443
1478
|
this.pendingDiffUpdate = null;
|
|
1444
1479
|
this.lastKnownModifiedDirty = false;
|
|
@@ -4976,7 +5011,6 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
4976
5011
|
this.lastContainer.innerHTML = "";
|
|
4977
5012
|
this.lastContainer = null;
|
|
4978
5013
|
}
|
|
4979
|
-
this.revealTicketDiff = 0;
|
|
4980
5014
|
this.lastRevealLineDiff = null;
|
|
4981
5015
|
this.diffPersistedUnchangedModelState = null;
|
|
4982
5016
|
this.diffPreviousUnchangedModelState = null;
|
|
@@ -5004,7 +5038,6 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
5004
5038
|
this.diffHeightManager.dispose();
|
|
5005
5039
|
this.diffHeightManager = null;
|
|
5006
5040
|
}
|
|
5007
|
-
this.revealTicketDiff = 0;
|
|
5008
5041
|
this.lastRevealLineDiff = null;
|
|
5009
5042
|
this.diffPersistedUnchangedModelState = null;
|
|
5010
5043
|
this.diffPreviousUnchangedModelState = null;
|
|
@@ -5283,6 +5316,12 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
5283
5316
|
|
|
5284
5317
|
//#endregion
|
|
5285
5318
|
//#region src/core/EditorManager.ts
|
|
5319
|
+
const defaultHeightTransitionMs = 120;
|
|
5320
|
+
const defaultHeightTransitionEasing = "cubic-bezier(0.4, 0, 0.2, 1)";
|
|
5321
|
+
const smoothHeightTolerancePx = 1;
|
|
5322
|
+
const legacyHeightTolerancePx = 12;
|
|
5323
|
+
const smoothHeightDebounceMs = 16;
|
|
5324
|
+
const legacyHeightDebounceMs = 0;
|
|
5286
5325
|
var EditorManager = class {
|
|
5287
5326
|
editorView = null;
|
|
5288
5327
|
lastContainer = null;
|
|
@@ -5329,10 +5368,12 @@ var EditorManager = class {
|
|
|
5329
5368
|
appendBufferScheduled = false;
|
|
5330
5369
|
rafScheduler = createRafScheduler();
|
|
5331
5370
|
editorHeightManager = null;
|
|
5371
|
+
previousScrollbarGutter = null;
|
|
5332
5372
|
revealDebounceId = null;
|
|
5333
5373
|
revealDebounceMs = defaultRevealDebounceMs;
|
|
5334
5374
|
revealIdleTimerId = null;
|
|
5335
5375
|
revealTicket = 0;
|
|
5376
|
+
layoutTicket = 0;
|
|
5336
5377
|
revealStrategyOption;
|
|
5337
5378
|
revealBatchOnIdleMsOption;
|
|
5338
5379
|
scrollWatcherSuppressionMs = 500;
|
|
@@ -5357,6 +5398,7 @@ var EditorManager = class {
|
|
|
5357
5398
|
this.rafScheduler.cancel("maybe-scroll");
|
|
5358
5399
|
this.rafScheduler.cancel("reveal");
|
|
5359
5400
|
this.rafScheduler.cancel("immediate-reveal");
|
|
5401
|
+
this.rafScheduler.cancel("layout-after-height");
|
|
5360
5402
|
this.rafScheduler.cancel("maybe-resume");
|
|
5361
5403
|
this.rafScheduler.cancel("append");
|
|
5362
5404
|
}
|
|
@@ -5375,6 +5417,8 @@ var EditorManager = class {
|
|
|
5375
5417
|
this.appendBuffer.length = 0;
|
|
5376
5418
|
}
|
|
5377
5419
|
clearAsyncWork() {
|
|
5420
|
+
this.revealTicket += 1;
|
|
5421
|
+
this.layoutTicket += 1;
|
|
5378
5422
|
this.cancelRafs();
|
|
5379
5423
|
this.pendingUpdate = null;
|
|
5380
5424
|
this.lastKnownCodeDirty = false;
|
|
@@ -5419,6 +5463,37 @@ var EditorManager = class {
|
|
|
5419
5463
|
if (!m) return false;
|
|
5420
5464
|
return this._hasScrollBar = m.scrollHeight > m.computedHeight + padding / 2;
|
|
5421
5465
|
}
|
|
5466
|
+
isSmoothHeightTransitionEnabled() {
|
|
5467
|
+
return this.options.smoothHeightTransition ?? false;
|
|
5468
|
+
}
|
|
5469
|
+
isAutomaticLayoutEnabled() {
|
|
5470
|
+
return this.options.automaticLayout !== false;
|
|
5471
|
+
}
|
|
5472
|
+
getHeightChangeTolerancePx() {
|
|
5473
|
+
return this.options.heightChangeTolerancePx ?? (this.isSmoothHeightTransitionEnabled() ? smoothHeightTolerancePx : legacyHeightTolerancePx);
|
|
5474
|
+
}
|
|
5475
|
+
getHeightManagerOptions() {
|
|
5476
|
+
const smooth = this.isSmoothHeightTransitionEnabled();
|
|
5477
|
+
return {
|
|
5478
|
+
smooth,
|
|
5479
|
+
transitionMs: this.options.heightTransitionMs ?? defaultHeightTransitionMs,
|
|
5480
|
+
transitionEasing: this.options.heightTransitionEasing ?? defaultHeightTransitionEasing,
|
|
5481
|
+
debounceMs: this.options.heightUpdateDebounceMs ?? (smooth ? smoothHeightDebounceMs : legacyHeightDebounceMs),
|
|
5482
|
+
hysteresisPx: this.getHeightChangeTolerancePx()
|
|
5483
|
+
};
|
|
5484
|
+
}
|
|
5485
|
+
setOverflowForHeight(computed$1) {
|
|
5486
|
+
if (!this.lastContainer) return null;
|
|
5487
|
+
const next = computed$1 >= this.maxHeightValue - 1 ? "auto" : "hidden";
|
|
5488
|
+
const prev = this.lastContainer.style.overflow;
|
|
5489
|
+
if (prev !== next) this.lastContainer.style.overflow = next;
|
|
5490
|
+
if (next === "hidden") this._hasScrollBar = false;
|
|
5491
|
+
return {
|
|
5492
|
+
prev,
|
|
5493
|
+
next,
|
|
5494
|
+
changed: prev !== next
|
|
5495
|
+
};
|
|
5496
|
+
}
|
|
5422
5497
|
userIsNearBottom() {
|
|
5423
5498
|
if (!this.editorView) return true;
|
|
5424
5499
|
const m = this.measureViewport();
|
|
@@ -5553,46 +5628,89 @@ var EditorManager = class {
|
|
|
5553
5628
|
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;
|
|
5554
5629
|
} catch {}
|
|
5555
5630
|
}
|
|
5556
|
-
|
|
5557
|
-
|
|
5558
|
-
|
|
5559
|
-
|
|
5560
|
-
|
|
5561
|
-
|
|
5562
|
-
|
|
5563
|
-
|
|
5564
|
-
|
|
5631
|
+
shouldRevealAfterLayout() {
|
|
5632
|
+
return this.autoScrollOnUpdate && this.shouldAutoScroll;
|
|
5633
|
+
}
|
|
5634
|
+
getRevealSuppressionMs() {
|
|
5635
|
+
var _this$editorHeightMan, _this$editorHeightMan2;
|
|
5636
|
+
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;
|
|
5637
|
+
return Math.max(this.scrollWatcherSuppressionMs, transitionMs + 100);
|
|
5638
|
+
}
|
|
5639
|
+
syncHeightAndRevealAfterContentChange(targetLine) {
|
|
5640
|
+
const shouldReveal = this.shouldRevealAfterLayout();
|
|
5641
|
+
const willReveal = !!(shouldReveal && this.editorView && this.computedHeight(this.editorView) >= this.maxHeightValue - 1);
|
|
5642
|
+
if (willReveal) this.suppressScrollWatcher(this.getRevealSuppressionMs());
|
|
5643
|
+
const computed$1 = this.syncNonOverflowingLayout();
|
|
5644
|
+
if (computed$1 != null && computed$1 >= this.maxHeightValue - 1 && shouldReveal) {
|
|
5645
|
+
var _this$editorView5;
|
|
5646
|
+
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;
|
|
5647
|
+
if (this.isSmoothHeightTransitionEnabled()) this.scheduleImmediateRevealAfterLayout(line);
|
|
5648
|
+
else this.forceReveal(line);
|
|
5649
|
+
} else if (!shouldReveal && targetLine != null) this.maybeScrollToBottom(targetLine);
|
|
5650
|
+
return computed$1;
|
|
5565
5651
|
}
|
|
5566
5652
|
syncNonOverflowingLayout() {
|
|
5567
|
-
var _this$
|
|
5653
|
+
var _this$editorHeightMan3, _this$editorHeightMan4;
|
|
5568
5654
|
if (!this.editorView || !this.lastContainer) return null;
|
|
5569
5655
|
const computed$1 = this.computedHeight(this.editorView);
|
|
5656
|
+
const needsRevealSync = computed$1 >= this.maxHeightValue - 1 && this.shouldRevealAfterLayout();
|
|
5657
|
+
const useSmoothHeightTransition = this.isSmoothHeightTransitionEnabled();
|
|
5658
|
+
if (needsRevealSync || !useSmoothHeightTransition) (_this$editorHeightMan3 = this.editorHeightManager) === null || _this$editorHeightMan3 === void 0 || _this$editorHeightMan3.updateNow();
|
|
5659
|
+
else (_this$editorHeightMan4 = this.editorHeightManager) === null || _this$editorHeightMan4 === void 0 || _this$editorHeightMan4.update();
|
|
5660
|
+
this.setOverflowForHeight(computed$1);
|
|
5570
5661
|
if (computed$1 >= this.maxHeightValue - 1) {
|
|
5571
|
-
|
|
5662
|
+
if (useSmoothHeightTransition) this.scheduleLayoutAfterHeightApplied(computed$1);
|
|
5572
5663
|
return computed$1;
|
|
5573
5664
|
}
|
|
5574
|
-
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;
|
|
5575
|
-
if (currentHeight <= 0 || Math.abs(computed$1 - currentHeight) > 12) this.lastContainer.style.height = `${computed$1}px`;
|
|
5576
|
-
this.lastContainer.style.overflow = "hidden";
|
|
5577
5665
|
this._hasScrollBar = false;
|
|
5666
|
+
if (useSmoothHeightTransition) {
|
|
5667
|
+
this.scheduleLayoutAfterHeightApplied(computed$1);
|
|
5668
|
+
try {
|
|
5669
|
+
var _this$editorView$getS3, _this$editorView6, _this$editorView$setS, _this$editorView7;
|
|
5670
|
+
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);
|
|
5671
|
+
this.lastScrollTop = 0;
|
|
5672
|
+
} catch {}
|
|
5673
|
+
return computed$1;
|
|
5674
|
+
}
|
|
5578
5675
|
try {
|
|
5579
|
-
var _this$editorView$layo, _this$
|
|
5580
|
-
(_this$editorView$layo = (_this$
|
|
5676
|
+
var _this$editorView$layo, _this$editorView8;
|
|
5677
|
+
(_this$editorView$layo = (_this$editorView8 = this.editorView).layout) === null || _this$editorView$layo === void 0 || _this$editorView$layo.call(_this$editorView8);
|
|
5581
5678
|
} catch {}
|
|
5582
5679
|
try {
|
|
5583
|
-
var _this$editorView$
|
|
5584
|
-
if ((((_this$editorView$
|
|
5680
|
+
var _this$editorView$getS4, _this$editorView9, _this$editorView$setS2, _this$editorView10;
|
|
5681
|
+
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);
|
|
5585
5682
|
this.lastScrollTop = 0;
|
|
5586
5683
|
} catch {}
|
|
5587
5684
|
return computed$1;
|
|
5588
5685
|
}
|
|
5686
|
+
scheduleLayoutAfterHeightApplied(target) {
|
|
5687
|
+
if (this.isAutomaticLayoutEnabled() || !this.editorView) return;
|
|
5688
|
+
const editor = this.editorView;
|
|
5689
|
+
const ticket = ++this.layoutTicket;
|
|
5690
|
+
this.rafScheduler.schedule("layout-after-height", async () => {
|
|
5691
|
+
try {
|
|
5692
|
+
var _editor$layout;
|
|
5693
|
+
await this.waitForHeightApplied(target, 500);
|
|
5694
|
+
if (ticket !== this.layoutTicket || this.editorView !== editor) return;
|
|
5695
|
+
(_editor$layout = editor.layout) === null || _editor$layout === void 0 || _editor$layout.call(editor);
|
|
5696
|
+
this.measureViewport();
|
|
5697
|
+
} catch (err) {
|
|
5698
|
+
error("EditorManager", "scheduleLayoutAfterHeightApplied error", err);
|
|
5699
|
+
}
|
|
5700
|
+
});
|
|
5701
|
+
}
|
|
5589
5702
|
async createEditor(container, code, language, currentTheme) {
|
|
5590
|
-
var _this$editorView$
|
|
5703
|
+
var _this$editorView$getS5, _this$editorView11, _this$editorView$getO, _this$editorView12, _this$editorView$getM, _this$editorView$onDi, _this$editorView13;
|
|
5591
5704
|
this.cleanup();
|
|
5592
5705
|
this.lastContainer = container;
|
|
5593
5706
|
this.initDebugFlag();
|
|
5594
5707
|
this.dlog("createEditor container, maxHeight", this.maxHeightValue);
|
|
5595
5708
|
container.style.overflow = "hidden";
|
|
5709
|
+
this.previousScrollbarGutter = null;
|
|
5710
|
+
if (this.isSmoothHeightTransitionEnabled()) {
|
|
5711
|
+
this.previousScrollbarGutter = container.style.scrollbarGutter || "";
|
|
5712
|
+
container.style.scrollbarGutter = "stable";
|
|
5713
|
+
}
|
|
5596
5714
|
container.style.maxHeight = this.maxHeightCSS;
|
|
5597
5715
|
this.editorView = monaco_shim_exports.editor.create(container, {
|
|
5598
5716
|
value: code,
|
|
@@ -5626,43 +5744,29 @@ var EditorManager = class {
|
|
|
5626
5744
|
this.editorHeightManager = createHeightManager(container, () => {
|
|
5627
5745
|
const computed$1 = this.computedHeight(this.editorView);
|
|
5628
5746
|
return Math.min(computed$1, this.maxHeightValue);
|
|
5629
|
-
});
|
|
5630
|
-
this.editorHeightManager.
|
|
5631
|
-
|
|
5632
|
-
|
|
5633
|
-
|
|
5634
|
-
container.style.overflow = "auto";
|
|
5635
|
-
this.dlog("applied immediate maxHeight on createEditor", this.maxHeightValue);
|
|
5636
|
-
}
|
|
5637
|
-
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;
|
|
5638
|
-
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;
|
|
5747
|
+
}, this.getHeightManagerOptions());
|
|
5748
|
+
const initialComputed = this.editorHeightManager.updateNow();
|
|
5749
|
+
if (initialComputed != null) this.setOverflowForHeight(initialComputed);
|
|
5750
|
+
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;
|
|
5751
|
+
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;
|
|
5639
5752
|
this.cachedComputedHeight = this.computedHeight(this.editorView);
|
|
5640
5753
|
this.cachedLineCount = ((_this$editorView$getM = this.editorView.getModel()) === null || _this$editorView$getM === void 0 ? void 0 : _this$editorView$getM.getLineCount()) ?? null;
|
|
5641
|
-
(_this$editorView$onDi = (_this$
|
|
5754
|
+
(_this$editorView$onDi = (_this$editorView13 = this.editorView).onDidContentSizeChange) === null || _this$editorView$onDi === void 0 || _this$editorView$onDi.call(_this$editorView13, () => {
|
|
5642
5755
|
this._hasScrollBar = false;
|
|
5643
5756
|
this.rafScheduler.schedule("content-size-change", () => {
|
|
5644
5757
|
try {
|
|
5645
|
-
var _this$
|
|
5758
|
+
var _this$editorView14, _this$editorHeightMan5;
|
|
5646
5759
|
this.dlog("content-size-change frame");
|
|
5647
|
-
this.cachedLineCount = ((_this$
|
|
5760
|
+
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;
|
|
5648
5761
|
this.cachedComputedHeight = null;
|
|
5649
5762
|
const m = this.measureViewport();
|
|
5650
5763
|
this.dlog("content-size-change measure", m);
|
|
5651
|
-
if ((_this$
|
|
5764
|
+
if ((_this$editorHeightMan5 = this.editorHeightManager) === null || _this$editorHeightMan5 === void 0 ? void 0 : _this$editorHeightMan5.isSuppressed()) {
|
|
5652
5765
|
this.dlog("content-size-change skipped height update (suppressed)");
|
|
5653
5766
|
return;
|
|
5654
5767
|
}
|
|
5655
|
-
this.dlog("content-size-change
|
|
5656
|
-
|
|
5657
|
-
const computed$1 = this.computedHeight(this.editorView);
|
|
5658
|
-
if (this.lastContainer) {
|
|
5659
|
-
const prevOverflow = this.lastContainer.style.overflow;
|
|
5660
|
-
const newOverflow = computed$1 >= this.maxHeightValue - 1 ? "auto" : "hidden";
|
|
5661
|
-
if (prevOverflow !== newOverflow) {
|
|
5662
|
-
this.lastContainer.style.overflow = newOverflow;
|
|
5663
|
-
if (newOverflow === "auto" && this.shouldAutoScroll) this.maybeScrollToBottom();
|
|
5664
|
-
}
|
|
5665
|
-
}
|
|
5768
|
+
this.dlog("content-size-change syncing height/reveal");
|
|
5769
|
+
this.syncHeightAndRevealAfterContentChange();
|
|
5666
5770
|
} catch (err) {
|
|
5667
5771
|
error("EditorManager", "content-size-change error", err);
|
|
5668
5772
|
}
|
|
@@ -5730,6 +5834,11 @@ var EditorManager = class {
|
|
|
5730
5834
|
if (target !== -1 && this.editorHeightManager) await this.waitForHeightApplied(target, 500);
|
|
5731
5835
|
else await new Promise((r) => requestAnimationFrame(() => requestAnimationFrame(() => r())));
|
|
5732
5836
|
this.dlog("running delayed immediate reveal", "ticket=", ticket, "line=", line);
|
|
5837
|
+
if (ticket !== this.revealTicket) {
|
|
5838
|
+
this.dlog("delayed immediate reveal skipped, stale ticket", ticket, "current", this.revealTicket);
|
|
5839
|
+
return;
|
|
5840
|
+
}
|
|
5841
|
+
this.suppressScrollWatcher(this.scrollWatcherSuppressionMs);
|
|
5733
5842
|
this.performImmediateReveal(line, ticket);
|
|
5734
5843
|
} catch (err) {
|
|
5735
5844
|
error("EditorManager", "scheduleImmediateRevealAfterLayout error", err);
|
|
@@ -5738,20 +5847,33 @@ var EditorManager = class {
|
|
|
5738
5847
|
}
|
|
5739
5848
|
waitForHeightApplied(target, timeoutMs = 500) {
|
|
5740
5849
|
return new Promise((resolve) => {
|
|
5850
|
+
var _this$editorHeightMan6, _this$editorHeightMan7;
|
|
5741
5851
|
const start = typeof performance !== "undefined" && performance.now ? performance.now() : Date.now();
|
|
5852
|
+
const tolerance = this.getHeightChangeTolerancePx();
|
|
5853
|
+
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;
|
|
5854
|
+
let settled = false;
|
|
5855
|
+
const resolveAfterSettle = () => {
|
|
5856
|
+
if (settled) return;
|
|
5857
|
+
settled = true;
|
|
5858
|
+
if (transitionMs > 0) {
|
|
5859
|
+
setTimeout(resolve, transitionMs);
|
|
5860
|
+
return;
|
|
5861
|
+
}
|
|
5862
|
+
requestAnimationFrame(() => requestAnimationFrame(() => resolve()));
|
|
5863
|
+
};
|
|
5742
5864
|
const check = () => {
|
|
5743
5865
|
try {
|
|
5744
|
-
var _this$
|
|
5745
|
-
const last = ((_this$
|
|
5746
|
-
if (last !== -1 && Math.abs(last - target) <=
|
|
5866
|
+
var _this$editorHeightMan8, _this$editorHeightMan9;
|
|
5867
|
+
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;
|
|
5868
|
+
if (last !== -1 && Math.abs(last - target) <= tolerance) {
|
|
5747
5869
|
this.dlog("waitForHeightApplied satisfied", last, "target=", target);
|
|
5748
|
-
|
|
5870
|
+
resolveAfterSettle();
|
|
5749
5871
|
return;
|
|
5750
5872
|
}
|
|
5751
5873
|
const now = typeof performance !== "undefined" && performance.now ? performance.now() : Date.now();
|
|
5752
5874
|
if (now - start > timeoutMs) {
|
|
5753
5875
|
log("EditorManager", "waitForHeightApplied timeout", last, "target=", target);
|
|
5754
|
-
|
|
5876
|
+
resolveAfterSettle();
|
|
5755
5877
|
return;
|
|
5756
5878
|
}
|
|
5757
5879
|
} catch {}
|
|
@@ -5803,12 +5925,7 @@ var EditorManager = class {
|
|
|
5803
5925
|
const newLineCount$1 = model.getLineCount();
|
|
5804
5926
|
this.cachedLineCount = newLineCount$1;
|
|
5805
5927
|
this.cachedComputedHeight = null;
|
|
5806
|
-
if (newLineCount$1 !== prevLineCount$1)
|
|
5807
|
-
const shouldImmediate = this.shouldPerformImmediateReveal();
|
|
5808
|
-
if (shouldImmediate) this.suppressScrollWatcher(this.scrollWatcherSuppressionMs);
|
|
5809
|
-
const computed$1 = this.syncNonOverflowingLayout();
|
|
5810
|
-
if (computed$1 != null && computed$1 >= this.maxHeightValue - 1) this.forceReveal(newLineCount$1);
|
|
5811
|
-
}
|
|
5928
|
+
if (newLineCount$1 !== prevLineCount$1) this.syncHeightAndRevealAfterContentChange(newLineCount$1);
|
|
5812
5929
|
return;
|
|
5813
5930
|
}
|
|
5814
5931
|
let prevCode;
|
|
@@ -5838,13 +5955,7 @@ var EditorManager = class {
|
|
|
5838
5955
|
const newLineCount = model.getLineCount();
|
|
5839
5956
|
this.cachedLineCount = newLineCount;
|
|
5840
5957
|
this.cachedComputedHeight = null;
|
|
5841
|
-
if (newLineCount !== prevLineCount)
|
|
5842
|
-
const shouldImmediate = this.shouldPerformImmediateReveal();
|
|
5843
|
-
if (shouldImmediate) this.suppressScrollWatcher(this.scrollWatcherSuppressionMs);
|
|
5844
|
-
this.syncNonOverflowingLayout();
|
|
5845
|
-
if (shouldImmediate) this.scheduleImmediateRevealAfterLayout(newLineCount);
|
|
5846
|
-
else this.maybeScrollToBottom(newLineCount);
|
|
5847
|
-
}
|
|
5958
|
+
if (newLineCount !== prevLineCount) this.syncHeightAndRevealAfterContentChange(newLineCount);
|
|
5848
5959
|
}
|
|
5849
5960
|
appendCode(appendText, codeLanguage) {
|
|
5850
5961
|
if (!this.editorView) return;
|
|
@@ -5876,10 +5987,7 @@ var EditorManager = class {
|
|
|
5876
5987
|
this.lastKnownCode = next;
|
|
5877
5988
|
const newLineCount = model.getLineCount();
|
|
5878
5989
|
this.cachedLineCount = newLineCount;
|
|
5879
|
-
if (newLineCount !== prevLineCount)
|
|
5880
|
-
this.syncNonOverflowingLayout();
|
|
5881
|
-
this.maybeScrollToBottom(newLineCount);
|
|
5882
|
-
}
|
|
5990
|
+
if (newLineCount !== prevLineCount) this.syncHeightAndRevealAfterContentChange(newLineCount);
|
|
5883
5991
|
return;
|
|
5884
5992
|
}
|
|
5885
5993
|
const res = computeMinimalEdit(prev, next);
|
|
@@ -5932,13 +6040,7 @@ var EditorManager = class {
|
|
|
5932
6040
|
if (lastLine !== newLineCount) {
|
|
5933
6041
|
this.cachedLineCount = newLineCount;
|
|
5934
6042
|
this.cachedComputedHeight = null;
|
|
5935
|
-
|
|
5936
|
-
if (shouldImmediate) this.suppressScrollWatcher(this.scrollWatcherSuppressionMs);
|
|
5937
|
-
this.syncNonOverflowingLayout();
|
|
5938
|
-
if (shouldImmediate) try {
|
|
5939
|
-
this.forceReveal(newLineCount);
|
|
5940
|
-
} catch {}
|
|
5941
|
-
else this.maybeScrollToBottom(newLineCount);
|
|
6043
|
+
this.syncHeightAndRevealAfterContentChange(newLineCount);
|
|
5942
6044
|
}
|
|
5943
6045
|
}
|
|
5944
6046
|
setLanguage(language, languages$1) {
|
|
@@ -5953,8 +6055,8 @@ var EditorManager = class {
|
|
|
5953
6055
|
return this.editorView;
|
|
5954
6056
|
}
|
|
5955
6057
|
getCode() {
|
|
5956
|
-
var _this$
|
|
5957
|
-
return ((_this$
|
|
6058
|
+
var _this$editorView15;
|
|
6059
|
+
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;
|
|
5958
6060
|
}
|
|
5959
6061
|
setUpdateThrottleMs(ms) {
|
|
5960
6062
|
this.updateThrottleMs = ms;
|
|
@@ -5975,6 +6077,8 @@ var EditorManager = class {
|
|
|
5975
6077
|
}
|
|
5976
6078
|
this.lastKnownCode = null;
|
|
5977
6079
|
if (this.lastContainer) {
|
|
6080
|
+
if (this.previousScrollbarGutter != null) this.lastContainer.style.scrollbarGutter = this.previousScrollbarGutter;
|
|
6081
|
+
this.previousScrollbarGutter = null;
|
|
5978
6082
|
this.lastContainer.style.minHeight = "";
|
|
5979
6083
|
this.lastContainer.innerHTML = "";
|
|
5980
6084
|
this.lastContainer = null;
|
|
@@ -5999,6 +6103,8 @@ var EditorManager = class {
|
|
|
5999
6103
|
this._hasScrollBar = false;
|
|
6000
6104
|
this.shouldAutoScroll = !!this.autoScrollInitial;
|
|
6001
6105
|
this.lastScrollTop = 0;
|
|
6106
|
+
if (this.lastContainer && this.previousScrollbarGutter != null) this.lastContainer.style.scrollbarGutter = this.previousScrollbarGutter;
|
|
6107
|
+
this.previousScrollbarGutter = null;
|
|
6002
6108
|
if (this.editorHeightManager) {
|
|
6003
6109
|
this.editorHeightManager.dispose();
|
|
6004
6110
|
this.editorHeightManager = null;
|
|
@@ -6305,7 +6411,7 @@ let globalAppliedThemeName = null;
|
|
|
6305
6411
|
* @param {MonacoLanguage[]} [monacoOptions.languages] - 支持的编程语言数组
|
|
6306
6412
|
* @param {string} [monacoOptions.theme] - 初始主题名称
|
|
6307
6413
|
* @param {boolean} [monacoOptions.isCleanOnBeforeCreate] - 是否在创建前清理之前注册的资源, 默认为 true
|
|
6308
|
-
* @param {(monaco: typeof import('monaco-editor')) => monaco.IDisposable[]} [monacoOptions.onBeforeCreate] - 编辑器创建前的钩子函数
|
|
6414
|
+
* @param {(monaco: typeof import('monaco-editor/esm/vs/editor/editor.api')) => monaco.IDisposable[]} [monacoOptions.onBeforeCreate] - 编辑器创建前的钩子函数
|
|
6309
6415
|
*
|
|
6310
6416
|
* @returns {{
|
|
6311
6417
|
* createEditor: (container: HTMLElement, code: string, language: string) => Promise<monaco.editor.IStandaloneCodeEditor>,
|