From c2657568a6902b432bbef98a7709aeae3e7ecf12 Mon Sep 17 00:00:00 2001 From: Eugene Pankov Date: Sat, 17 Jul 2021 00:52:16 +0200 Subject: [PATCH] updated web demo for new profiles --- .../src/components/terminalTab.component.ts | 2 +- tabby-web-demo/src/session.ts | 47 ++++++++++++------- 2 files changed, 31 insertions(+), 18 deletions(-) diff --git a/tabby-web-demo/src/components/terminalTab.component.ts b/tabby-web-demo/src/components/terminalTab.component.ts index 848a3002..59a4d7f1 100644 --- a/tabby-web-demo/src/components/terminalTab.component.ts +++ b/tabby-web-demo/src/components/terminalTab.component.ts @@ -21,7 +21,7 @@ export class DemoTerminalTabComponent extends BaseTerminalTabComponent { ngOnInit (): void { this.logger = this.log.create('terminalTab') - this.session = new Session(this.logger) + this.session = new Session(this.injector, this.logger) super.ngOnInit() } diff --git a/tabby-web-demo/src/session.ts b/tabby-web-demo/src/session.ts index fbbaf9db..fd8b4d9b 100644 --- a/tabby-web-demo/src/session.ts +++ b/tabby-web-demo/src/session.ts @@ -1,14 +1,25 @@ /* eslint-disable @typescript-eslint/no-empty-function */ +import { Injector, NgZone } from '@angular/core' import * as path from 'path' import { BaseSession } from 'tabby-terminal' +import { Logger } from '../../tabby-core/typings' const currentScript: any = document.currentScript export class Session extends BaseSession { private dataPath = window['tabbyWebDemoDataPath'] ?? currentScript.src + '../../../data' private vm: any + private zone: NgZone static v86Loaded = false + constructor ( + injector: Injector, + logger: Logger, + ) { + super(logger) + this.zone = injector.get(NgZone) + } + async start (): Promise { this.open = true this.emitMessage('Hey\r\n') @@ -25,23 +36,25 @@ export class Session extends BaseSession { }) } - this.vm = new window['V86Starter']({ - bios: { - url: `${this.dataPath}/bios.bin`, - }, - vga_bios: { - url: `${this.dataPath}/vgabios.bin`, - }, - wasm_path: `${this.dataPath}/v86.wasm`, - cdrom: { - url: `${this.dataPath}/linux.iso`, - }, - initial_state: { - url: `${this.dataPath}/v86state.bin`, - }, - autostart: true, - disable_keyboard: true, - disable_speaker: true, + this.zone.runOutsideAngular(() => { + this.vm = new window['V86Starter']({ + bios: { + url: `${this.dataPath}/bios.bin`, + }, + vga_bios: { + url: `${this.dataPath}/vgabios.bin`, + }, + wasm_path: `${this.dataPath}/v86.wasm`, + cdrom: { + url: `${this.dataPath}/linux.iso`, + }, + initial_state: { + url: `${this.dataPath}/v86state.bin`, + }, + autostart: true, + disable_keyboard: true, + disable_speaker: true, + }) }) this.vm.add_listener('emulator-ready', () => { -- GitLab