import Debug from '../../conf/Debug'; import BrowserDetect from '../../conf/BrowserDetect'; import Logger from '../Logger'; import { browser } from 'webextension-polyfill-ts'; import Settings from '../Settings'; import EventBus from '../EventBus'; if (process.env.CHANNEL !== 'stable'){ console.info("Loading CommsClient"); } /** * Ultrawidify communication spans a few different "domains" that require a few different * means of communication. The four isolated domains are: * * > content script event bus (CS) * > player UI event bus (UI) * > UWServer event bus (BG) * > popup event bus * * It is our goal to route messages between various domains. It is our goal that eventBus * instances in different parts of our script are at least somewhat interoperable between * each other. As such, scripts sending commands should be unaware that Comms object even * exists. * * EventBus is started first. Other components (including commsClient) follow later. * * * fig 0. ULTRAWIDIFY COMMUNICATION MAP * * CS EVENT BUS * (accessible within tab scripts) * | NOT EVENT BUS * PageInfo x (accessible within popup) * x | * : : x UWServer * x CommsClient <---------------x CommsServer x * | (Connect to popup) * | * x eventBus.sendToTunnel() *