move safari check to WebglAddon ctor

This commit is contained in:
Jörg Breitbart
2022-12-07 23:56:43 +01:00
parent 0b56b56c06
commit d2298d84a0
2 changed files with 24 additions and 18 deletions
+3 -5
View File
@@ -9,7 +9,6 @@ import { EventEmitter, forwardEvent } from 'common/EventEmitter';
import { Disposable, toDisposable } from 'common/Lifecycle';
import { getSafariVersion, 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';
@@ -29,14 +28,13 @@ export class WebglAddon extends Disposable implements ITerminalAddon {
constructor(
private _preserveDrawingBuffer?: boolean
) {
if (isSafari && getSafariVersion() < 16) {
throw new Error('Webgl2 is only supported on Safari 16 and above');
}
super();
}
public activate(terminal: Terminal): void {
if (isSafari && getSafariVersion() < 16) {
throw new Error('Webgl2 is only supported on Safari 16 and above');
}
const core = (terminal as any)._core as ITerminal;
if (!terminal.element) {
this.register(core.onWillOpen(() => this.activate(terminal)));