Split renderer safe vs unsafe api on activate

This commit is contained in:
Daniel Imms
2022-10-09 10:12:19 -07:00
parent e47296c1b9
commit 8d7137417b
2 changed files with 28 additions and 19 deletions
+14 -7
View File
@@ -4,10 +4,12 @@
*/
import { ICharacterJoinerService, ICoreBrowserService, IRenderService, IThemeService } from 'browser/services/Services';
import { ITerminal } from 'browser/Types';
import { EventEmitter, forwardEvent } from 'common/EventEmitter';
import { Disposable, toDisposable } from 'common/Lifecycle';
import { isSafari } from 'common/Platform';
import { ICoreService, IDecorationService, IOptionsService } from 'common/services/Services';
import { ICoreTerminal } from 'common/Types';
import { ITerminalAddon, Terminal } from 'xterm';
import { WebglRenderer } from './WebglRenderer';
@@ -30,19 +32,24 @@ export class WebglAddon extends Disposable implements ITerminalAddon {
if (isSafari) {
throw new Error('Webgl is not currently supported on Safari');
}
const core = (terminal as any)._core;
const core = (terminal as any)._core as ITerminal;
const unsafeCore = core as any;
if (!terminal.element) {
this.register(core.onWillOpen(() => this.activate(terminal)));
this.register(unsafeCore.onWillOpen(() => this.activate(terminal)));
return;
}
this._terminal = terminal;
const renderService: IRenderService = core._renderService;
const characterJoinerService: ICharacterJoinerService = core._characterJoinerService;
const coreBrowserService: ICoreBrowserService = core._coreBrowserService;
const coreService: ICoreService = core.coreService;
const decorationService: IDecorationService = core._decorationService;
const themeService: IThemeService = core._themeService;
const optionsService: IOptionsService = core.optionsService;
const renderService: IRenderService = unsafeCore._renderService;
const characterJoinerService: ICharacterJoinerService = unsafeCore._characterJoinerService;
const coreBrowserService: ICoreBrowserService = unsafeCore._coreBrowserService;
const decorationService: IDecorationService = unsafeCore._decorationService;
const themeService: IThemeService = unsafeCore._themeService;
this._renderer = this.register(new WebglRenderer(terminal, themeService, characterJoinerService, coreBrowserService, optionsService, coreService, decorationService, this._preserveDrawingBuffer));
this.register(forwardEvent(this._renderer.onContextLoss, this._onContextLoss));
this.register(forwardEvent(this._renderer.onChangeTextureAtlas, this._onChangeTextureAtlas));