import 'regenerator-runtime'; import { LSAClient } from '@lenovo-software/lsa-clients-common'; import { Storage } from './storage'; import { Logger } from '../common/logger'; import { AnyEventHandler, ClassroomEventHandler } from './eventHandlers'; import { CryptoSubtle } from './cryptoSubtle'; import { NetworkTransportOpts } from './networkTransportOpts'; import { LocaleHandlerClient } from './localeHandlerClient'; import { WebViewWindowController } from './webViewWindowController'; import { WebViewDispatcher } from './webViewDispatcher'; import { StatusLight } from './statusLight'; import { ConfigPolicy, Policy } from './policy'; import { UnverifiedOrgOption } from './unverifiedOrgOption'; import { BatteryInstrumentation } from './batteryInstrumentation'; import { LicenseWindowController } from 'background/licenseWindowController'; import { ThumbnailInstrumentation } from './thumbnailInstrumentation'; import { LimitingEventHandler } from './limiting/limitingEventHandler'; import Preferences from './preferences'; import { ConferenceDirectiveHandler } from './conferenceDirectiveHandler'; import { ScreenshotCaptureService } from './screenshotCaptureService'; export class Starter { public static policy: Policy; public static async start(): Promise { try { console.log('(1)'); const persistence = Preferences.getInstance(); await persistence.load(); console.log('(1.1)'); const configPolicy = new ConfigPolicy(persistence); this.policy = await configPolicy.loadPolicy(); await this.checkPlatform(this.policy); console.log('(1.2)'); const storage = new Storage(persistence, this.policy); await storage.init(); console.log('(2)'); const lsaClient = LSAClient.getInstance(); const wvc = new WebViewWindowController(); console.log('(3)'); await lsaClient.init(storage, new LocaleHandlerClient()); console.log('(4)'); lsaClient.logger = Logger.getInstance(); lsaClient.eventSubscribers.genericEventHandler = new AnyEventHandler(); //@ts-ignore lsaClient.cryptoSubtleCallback = new CryptoSubtle(); lsaClient.networkTransportOpts = new NetworkTransportOpts(); const wvd = new WebViewDispatcher(storage); lsaClient.statusLight = new StatusLight(lsaClient.logger, wvd); // Start screenshot capture service const screenShotService = new ScreenshotCaptureService(); // Set battery instrumentation to telemetry const batteryInstrumentation = new BatteryInstrumentation(); lsaClient.telemetryInstrumentation.batteryInstrumentation = batteryInstrumentation; // Set thumbnail instrumentation to telemetry const thumbnailInstrumentation = new ThumbnailInstrumentation(wvc); lsaClient.telemetryInstrumentation.screenCapture = thumbnailInstrumentation; const classroomEventHandler = new ClassroomEventHandler(wvd, screenShotService); lsaClient.eventSubscribers.classroomEventHandler = classroomEventHandler; lsaClient.unverifiedOrgOption = new UnverifiedOrgOption(); lsaClient.clientLimiting = LimitingEventHandler.getInstance(); lsaClient.conferenceDirectiveHandler = new ConferenceDirectiveHandler(); new LicenseWindowController(); console.log('(5)'); await lsaClient.connect(); console.log('(6)'); await wvc.loadChatWindow(); } catch (err) { console.log('err: ' + err); } } private static checkPlatform(toValidate: Policy): Promise { return new Promise((resolve, reject) => { // Check if Chromebook is required chrome.runtime.getPlatformInfo((info) => { if (!info) { reject('Cannot determine platform type.'); } if (toValidate.allowNonChromebook !== true && info.os !== 'cros') { reject('Policy requires this device to be a Chromebook and this is not a Chromebook.'); } resolve(); }); }); } } Starter.start();