1 | {"version":3,"file":"Base.js","sourceRoot":"","sources":["../../../../src/lib/channels/Base.ts"],"names":[],"mappings":";;;;;;;;;;;;IAGA;QAIE,qBAAY,OAAuB;YACjC,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;YACvB,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;QACrC,CAAC;QAMD,iCAAW,GAAX,UAAY,IAAwB,EAAE,IAAS;YAC7C,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QACpC,CAAC;QAMH,kBAAC;IAAD,CAAC,AArBD,IAqBC;;IAeD,SAAgB,SAAS,CAAC,KAAU;QAClC,OAAO,CACL,KAAK;YACL,OAAO,KAAK,KAAK,QAAQ;YACzB,OAAO,KAAK,CAAC,WAAW,KAAK,UAAU,CACxC,CAAC;IACJ,CAAC;IAND,8BAMC","sourcesContent":["import { CancellablePromise } from '@theintern/common';\nimport { RemoteEvents } from '../RemoteSuite';\n\nexport default abstract class BaseChannel {\n readonly url: string;\n readonly sessionId: string;\n\n constructor(options: ChannelOptions) {\n this.url = options.url;\n this.sessionId = options.sessionId;\n }\n\n /**\n * Send a message, or schedule it to be sent. Return a promise that resolves\n * when the message has been sent.\n */\n sendMessage(name: keyof RemoteEvents, data: any) {\n return this._sendData(name, data);\n }\n\n protected abstract _sendData(\n name: keyof RemoteEvents,\n data: any\n ): CancellablePromise<any>;\n}\n\nexport interface ChannelOptions {\n sessionId: string;\n\n /** An HTTP URL that the testing host can be reached at */\n url: string;\n\n /** A websocket port */\n port?: number;\n\n /** A timeout for websocket responses */\n timeout?: number;\n}\n\nexport function isChannel(value: any): value is BaseChannel {\n return (\n value &&\n typeof value === 'object' &&\n typeof value.sendMessage === 'function'\n );\n}\n\nexport interface ChannelOptions {\n sessionId: string;\n url: string;\n\n /** A WebSocket port */\n port?: number;\n\n /** A timeout for WebSocket responses */\n timeout?: number;\n}\n\nexport interface Message {\n sessionId: string;\n id: string;\n name: string;\n data: any;\n}\n"]} |