@xterm/xterm 5.4.0-beta.16 → 5.4.0-beta.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@xterm/xterm",
3
3
  "description": "Full xterm terminal, in your browser",
4
- "version": "5.4.0-beta.16",
4
+ "version": "5.4.0-beta.17",
5
5
  "main": "lib/xterm.js",
6
6
  "style": "css/xterm.css",
7
7
  "types": "typings/xterm.d.ts",
@@ -4,6 +4,7 @@
4
4
  */
5
5
 
6
6
  import { IRenderDebouncerWithCallback } from 'browser/Types';
7
+ import { ICoreBrowserService } from 'browser/services/Services';
7
8
 
8
9
  /**
9
10
  * Debounces calls to render terminal rows using animation frames.
@@ -16,14 +17,14 @@ export class RenderDebouncer implements IRenderDebouncerWithCallback {
16
17
  private _refreshCallbacks: FrameRequestCallback[] = [];
17
18
 
18
19
  constructor(
19
- private _parentWindow: Window,
20
- private _renderCallback: (start: number, end: number) => void
20
+ private _renderCallback: (start: number, end: number) => void,
21
+ private readonly _coreBrowserService: ICoreBrowserService
21
22
  ) {
22
23
  }
23
24
 
24
25
  public dispose(): void {
25
26
  if (this._animationFrame) {
26
- this._parentWindow.cancelAnimationFrame(this._animationFrame);
27
+ this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame);
27
28
  this._animationFrame = undefined;
28
29
  }
29
30
  }
@@ -31,7 +32,7 @@ export class RenderDebouncer implements IRenderDebouncerWithCallback {
31
32
  public addRefreshCallback(callback: FrameRequestCallback): number {
32
33
  this._refreshCallbacks.push(callback);
33
34
  if (!this._animationFrame) {
34
- this._animationFrame = this._parentWindow.requestAnimationFrame(() => this._innerRefresh());
35
+ this._animationFrame = this._coreBrowserService.window.requestAnimationFrame(() => this._innerRefresh());
35
36
  }
36
37
  return this._animationFrame;
37
38
  }
@@ -49,7 +50,7 @@ export class RenderDebouncer implements IRenderDebouncerWithCallback {
49
50
  return;
50
51
  }
51
52
 
52
- this._animationFrame = this._parentWindow.requestAnimationFrame(() => this._innerRefresh());
53
+ this._animationFrame = this._coreBrowserService.window.requestAnimationFrame(() => this._innerRefresh());
53
54
  }
54
55
 
55
56
  private _innerRefresh(): void {
@@ -8,9 +8,9 @@ import { IRenderDebouncerWithCallback } from 'browser/Types';
8
8
  import { IRenderDimensions, IRenderer } from 'browser/renderer/shared/Types';
9
9
  import { ICharSizeService, ICoreBrowserService, IRenderService, IThemeService } from 'browser/services/Services';
10
10
  import { EventEmitter } from 'common/EventEmitter';
11
- import { Disposable, MutableDisposable } from 'common/Lifecycle';
11
+ import { Disposable, MutableDisposable, toDisposable } from 'common/Lifecycle';
12
12
  import { DebouncedIdleTask } from 'common/TaskQueue';
13
- import { IBufferService, IDecorationService, IInstantiationService, IOptionsService } from 'common/services/Services';
13
+ import { IBufferService, IDecorationService, IOptionsService } from 'common/services/Services';
14
14
 
15
15
  interface ISelectionState {
16
16
  start: [number, number] | undefined;
@@ -24,6 +24,7 @@ export class RenderService extends Disposable implements IRenderService {
24
24
  private _renderer: MutableDisposable<IRenderer> = this.register(new MutableDisposable());
25
25
  private _renderDebouncer: IRenderDebouncerWithCallback;
26
26
  private _pausedResizeTask = new DebouncedIdleTask();
27
+ private _observerDisposable = this.register(new MutableDisposable());
27
28
 
28
29
  private _isPaused: boolean = false;
29
30
  private _needsFullRefresh: boolean = false;
@@ -38,7 +39,7 @@ export class RenderService extends Disposable implements IRenderService {
38
39
  };
39
40
 
40
41
  private readonly _onDimensionsChange = this.register(new EventEmitter<IRenderDimensions>());
41
- public readonly onDimensionsChange = this._onDimensionsChange.event;
42
+ public readonly onDimensionsChange = this._onDimensionsChange.event;
42
43
  private readonly _onRenderedViewportChange = this.register(new EventEmitter<{ start: number, end: number }>());
43
44
  public readonly onRenderedViewportChange = this._onRenderedViewportChange.event;
44
45
  private readonly _onRender = this.register(new EventEmitter<{ start: number, end: number }>());
@@ -56,12 +57,11 @@ export class RenderService extends Disposable implements IRenderService {
56
57
  @IDecorationService decorationService: IDecorationService,
57
58
  @IBufferService bufferService: IBufferService,
58
59
  @ICoreBrowserService coreBrowserService: ICoreBrowserService,
59
- @IInstantiationService instantiationService: IInstantiationService,
60
60
  @IThemeService themeService: IThemeService
61
61
  ) {
62
62
  super();
63
63
 
64
- this._renderDebouncer = new RenderDebouncer(coreBrowserService.window, (start, end) => this._renderRows(start, end));
64
+ this._renderDebouncer = new RenderDebouncer((start, end) => this._renderRows(start, end), coreBrowserService);
65
65
  this.register(this._renderDebouncer);
66
66
 
67
67
  this.register(coreBrowserService.onDprChange(() => this.handleDevicePixelRatioChange()));
@@ -102,12 +102,17 @@ export class RenderService extends Disposable implements IRenderService {
102
102
 
103
103
  this.register(themeService.onChangeColors(() => this._fullRefresh()));
104
104
 
105
+ this._registerIntersectionObserver(coreBrowserService.window, screenElement);
106
+ this.register(coreBrowserService.onWindowChange((w) => this._registerIntersectionObserver(w, screenElement)));
107
+ }
108
+
109
+ private _registerIntersectionObserver(w: Window & typeof globalThis, screenElement: HTMLElement): void {
105
110
  // Detect whether IntersectionObserver is detected and enable renderer pause
106
111
  // and resume based on terminal visibility if so
107
- if ('IntersectionObserver' in coreBrowserService.window) {
108
- const observer = new coreBrowserService.window.IntersectionObserver(e => this._handleIntersectionChange(e[e.length - 1]), { threshold: 0 });
112
+ if ('IntersectionObserver' in w) {
113
+ const observer = new w.IntersectionObserver(e => this._handleIntersectionChange(e[e.length - 1]), { threshold: 0 });
109
114
  observer.observe(screenElement);
110
- this.register({ dispose: () => observer.disconnect() });
115
+ this._observerDisposable.value = toDisposable(() => observer.disconnect());
111
116
  }
112
117
  }
113
118