@tvlabs/wdio-service 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  <p align="center">
2
2
  <a href="https://tvlabs.ai">
3
- <img alt="TV Labs Logo" width="200" src="https://tvlabs.ai/images/tvlabs.svg">
3
+ <img alt="TV Labs Logo" width="200" src="https://tvlabs.ai/images/tvlabs.svg" />
4
4
  </a>
5
5
  </p>
6
6
 
@@ -39,7 +39,7 @@ yarn add @tvlabs/wdio-service
39
39
  To use this as a WebdriverIO test runner service, include the service in your WebdriverIO configuration file (e.g. `wdio.conf.ts`) with your TV Labs API key set in the options.
40
40
 
41
41
  ```javascript
42
- import TVLabsService from '@tvlabs/wdio-service';
42
+ import { TVLabsService } from '@tvlabs/wdio-service';
43
43
 
44
44
  export const config = {
45
45
  // ...
@@ -54,7 +54,7 @@ To use this with WebdriverIO remote but without the test runner, call the before
54
54
 
55
55
  ```javascript
56
56
  import { remote } from 'webdriverio';
57
- import TVLabsService from '@tvlabs/wdio-service';
57
+ import { TVLabsService } from '@tvlabs/wdio-service';
58
58
 
59
59
  const capabilities = { ... };
60
60
 
package/cjs/channel.d.ts CHANGED
@@ -9,7 +9,7 @@ export declare class TVLabsChannel {
9
9
  private requestTopic?;
10
10
  private log;
11
11
  private readonly events;
12
- constructor(endpoint: string, maxReconnectRetries: number, key: string, logLevel: LogLevel);
12
+ constructor(endpoint: string, maxReconnectRetries: number, key: string, logLevel?: LogLevel);
13
13
  disconnect(): Promise<void>;
14
14
  connect(): Promise<void>;
15
15
  newSession(capabilities: TVLabsCapabilities, maxRetries: number, retry?: number): Promise<string>;
@@ -21,7 +21,7 @@ export declare class TVLabsChannel {
21
21
  private push;
22
22
  private params;
23
23
  private reconnectAfterMs;
24
- private logSocketError;
25
24
  private tvlabsSessionLink;
25
+ private static logSocketError;
26
26
  }
27
27
  //# sourceMappingURL=channel.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../src/channel.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,kBAAkB,EAIlB,QAAQ,EACT,MAAM,YAAY,CAAC;AAGpB,qBAAa,aAAa;IAgBtB,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,mBAAmB;IAC3B,OAAO,CAAC,GAAG;IACX,OAAO,CAAC,QAAQ;IAlBlB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,UAAU,CAAU;IAC5B,OAAO,CAAC,YAAY,CAAC,CAAU;IAC/B,OAAO,CAAC,GAAG,CAAS;IAEpB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAOZ;gBAGD,QAAQ,EAAE,MAAM,EAChB,mBAAmB,EAAE,MAAM,EAC3B,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,QAAQ;IActB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAQ3B,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAiBxB,UAAU,CACd,YAAY,EAAE,kBAAkB,EAChC,UAAU,EAAE,MAAM,EAClB,KAAK,SAAI,GACR,OAAO,CAAC,MAAM,CAAC;YAWJ,WAAW;YAkBX,cAAc;IAsD5B,OAAO,CAAC,gBAAgB;YAUV,cAAc;YAuBd,IAAI;YAgBJ,IAAI;IAoBlB,OAAO,CAAC,MAAM;IAMd,OAAO,CAAC,gBAAgB;IAgBxB,OAAO,CAAC,cAAc;IAWtB,OAAO,CAAC,iBAAiB;CAG1B"}
1
+ {"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../src/channel.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,kBAAkB,EAIlB,QAAQ,EACT,MAAM,YAAY,CAAC;AAGpB,qBAAa,aAAa;IAgBtB,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,mBAAmB;IAC3B,OAAO,CAAC,GAAG;IACX,OAAO,CAAC,QAAQ;IAlBlB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,UAAU,CAAU;IAC5B,OAAO,CAAC,YAAY,CAAC,CAAU;IAC/B,OAAO,CAAC,GAAG,CAAS;IAEpB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAOZ;gBAGD,QAAQ,EAAE,MAAM,EAChB,mBAAmB,EAAE,MAAM,EAC3B,GAAG,EAAE,MAAM,EACX,QAAQ,GAAE,QAAiB;IAgB/B,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAQ3B,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAiBxB,UAAU,CACd,YAAY,EAAE,kBAAkB,EAChC,UAAU,EAAE,MAAM,EAClB,KAAK,SAAI,GACR,OAAO,CAAC,MAAM,CAAC;YAWJ,WAAW;YAkBX,cAAc;IAsD5B,OAAO,CAAC,gBAAgB;YAUV,cAAc;YAuBd,IAAI;YAgBJ,IAAI;IAoBlB,OAAO,CAAC,MAAM;IAWd,OAAO,CAAC,gBAAgB;IAgBxB,OAAO,CAAC,iBAAiB;IAIzB,OAAO,CAAC,MAAM,CAAC,cAAc;CAU9B"}
package/cjs/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import TVLabsService from './service.js';
2
+ export { TVLabsService };
2
3
  export default TVLabsService;
3
4
  export * from './types.js';
4
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,cAAc,CAAC;AAEzC,eAAe,aAAa,CAAC;AAC7B,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,aAAa,EAAE,CAAC;AACzB,eAAe,aAAa,CAAC;AAC7B,cAAc,YAAY,CAAC"}
package/cjs/index.js CHANGED
@@ -1,19 +1,356 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var webdriverio = require('webdriverio');
6
+ var crypto = require('crypto');
7
+ var ws = require('ws');
8
+ var phoenix = require('phoenix');
9
+
10
+ function _interopNamespaceDefault(e) {
11
+ var n = Object.create(null);
12
+ if (e) {
13
+ Object.keys(e).forEach(function (k) {
14
+ if (k !== 'default') {
15
+ var d = Object.getOwnPropertyDescriptor(e, k);
16
+ Object.defineProperty(n, k, d.get ? d : {
17
+ enumerable: true,
18
+ get: function () { return e[k]; }
19
+ });
20
+ }
21
+ });
22
+ }
23
+ n.default = e;
24
+ return Object.freeze(n);
25
+ }
26
+
27
+ var crypto__namespace = /*#__PURE__*/_interopNamespaceDefault(crypto);
28
+
29
+ const LOG_LEVELS = {
30
+ error: 0,
31
+ warn: 1,
32
+ info: 2,
33
+ debug: 3,
34
+ trace: 4,
35
+ silent: 5,
15
36
  };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- const service_js_1 = require("./service.js");
18
- exports.default = service_js_1.default;
19
- __exportStar(require("./types.js"), exports);
37
+ class Logger {
38
+ name;
39
+ logLevel;
40
+ constructor(name, logLevel = 'info') {
41
+ this.name = name;
42
+ this.logLevel = logLevel;
43
+ }
44
+ shouldLog(level) {
45
+ if (this.logLevel === 'silent') {
46
+ return false;
47
+ }
48
+ return LOG_LEVELS[level] <= LOG_LEVELS[this.logLevel];
49
+ }
50
+ formatMessage(level, ...args) {
51
+ const timestamp = new Date().toISOString();
52
+ return `${timestamp} ${level.toUpperCase()} ${this.name}: ${args
53
+ .map((arg) => typeof arg === 'object' ? JSON.stringify(arg) : String(arg))
54
+ .join(' ')}`;
55
+ }
56
+ debug(...args) {
57
+ if (this.shouldLog('debug')) {
58
+ console.log(this.formatMessage('debug', ...args));
59
+ }
60
+ }
61
+ info(...args) {
62
+ if (this.shouldLog('info')) {
63
+ console.log(this.formatMessage('info', ...args));
64
+ }
65
+ }
66
+ warn(...args) {
67
+ if (this.shouldLog('warn')) {
68
+ console.warn(this.formatMessage('warn', ...args));
69
+ }
70
+ }
71
+ error(...args) {
72
+ if (this.shouldLog('error')) {
73
+ console.error(this.formatMessage('error', ...args));
74
+ }
75
+ }
76
+ trace(...args) {
77
+ if (this.shouldLog('trace')) {
78
+ console.trace(this.formatMessage('trace', ...args));
79
+ }
80
+ }
81
+ }
82
+
83
+ var name = "@tvlabs/wdio-service";
84
+ var version = "0.1.4";
85
+ var packageJson = {
86
+ name: name,
87
+ version: version};
88
+
89
+ function getServiceInfo() {
90
+ return {
91
+ service_name: getServiceName(),
92
+ service_version: getServiceVersion(),
93
+ };
94
+ }
95
+ function getServiceVersion() {
96
+ return packageJson.version;
97
+ }
98
+ function getServiceName() {
99
+ return packageJson.name;
100
+ }
101
+
102
+ class TVLabsChannel {
103
+ endpoint;
104
+ maxReconnectRetries;
105
+ key;
106
+ logLevel;
107
+ socket;
108
+ lobbyTopic;
109
+ requestTopic;
110
+ log;
111
+ events = {
112
+ SESSION_READY: 'session:ready',
113
+ SESSION_FAILED: 'session:failed',
114
+ REQUEST_CANCELED: 'request:canceled',
115
+ REQUEST_FAILED: 'request:failed',
116
+ REQUEST_FILLED: 'request:filled',
117
+ REQUEST_MATCHING: 'request:matching',
118
+ };
119
+ constructor(endpoint, maxReconnectRetries, key, logLevel = 'info') {
120
+ this.endpoint = endpoint;
121
+ this.maxReconnectRetries = maxReconnectRetries;
122
+ this.key = key;
123
+ this.logLevel = logLevel;
124
+ this.log = new Logger('@tvlabs/wdio-channel', this.logLevel);
125
+ this.socket = new phoenix.Socket(this.endpoint, {
126
+ transport: ws.WebSocket,
127
+ params: this.params(),
128
+ reconnectAfterMs: this.reconnectAfterMs.bind(this),
129
+ });
130
+ this.socket.onError((...args) => TVLabsChannel.logSocketError(this.log, ...args));
131
+ this.lobbyTopic = this.socket.channel('requests:lobby');
132
+ }
133
+ async disconnect() {
134
+ return new Promise((res, _rej) => {
135
+ this.lobbyTopic.leave();
136
+ this.requestTopic?.leave();
137
+ this.socket.disconnect(() => res());
138
+ });
139
+ }
140
+ async connect() {
141
+ try {
142
+ this.log.debug('Connecting to TV Labs...');
143
+ this.socket.connect();
144
+ await this.join(this.lobbyTopic);
145
+ this.log.debug('Connected to TV Labs!');
146
+ }
147
+ catch (error) {
148
+ this.log.error('Error connecting to TV Labs:', error);
149
+ throw new webdriverio.SevereServiceError('Could not connect to TV Labs, please check your connection.');
150
+ }
151
+ }
152
+ async newSession(capabilities, maxRetries, retry = 0) {
153
+ try {
154
+ const requestId = await this.requestSession(capabilities);
155
+ const sessionId = await this.observeRequest(requestId);
156
+ return sessionId;
157
+ }
158
+ catch {
159
+ return this.handleRetry(capabilities, maxRetries, retry);
160
+ }
161
+ }
162
+ async handleRetry(capabilities, maxRetries, retry) {
163
+ if (retry < maxRetries) {
164
+ this.log.warn(`Could not create a session, retrying (${retry + 1}/${maxRetries})`);
165
+ return this.newSession(capabilities, maxRetries, retry + 1);
166
+ }
167
+ else {
168
+ throw new webdriverio.SevereServiceError(`Could not create a session after ${maxRetries} attempts.`);
169
+ }
170
+ }
171
+ async observeRequest(requestId) {
172
+ const cleanup = () => this.unobserveRequest();
173
+ return new Promise((res, rej) => {
174
+ this.requestTopic = this.socket.channel(`requests:${requestId}`);
175
+ const eventHandlers = {
176
+ [this.events.REQUEST_MATCHING]: ({ request_id }) => {
177
+ this.log.info(`Session request ${request_id} matching...`);
178
+ },
179
+ [this.events.REQUEST_FILLED]: ({ session_id, request_id }) => {
180
+ this.log.info(`Session request ${request_id} filled: ${this.tvlabsSessionLink(session_id)}`);
181
+ this.log.info('Waiting for device to be ready...');
182
+ },
183
+ [this.events.SESSION_FAILED]: ({ session_id, reason }) => {
184
+ this.log.error(`Session ${session_id} failed, reason: ${reason}`);
185
+ rej(reason);
186
+ },
187
+ [this.events.REQUEST_CANCELED]: ({ request_id, reason }) => {
188
+ this.log.info(`Session request ${request_id} canceled, reason: ${reason}`);
189
+ rej(reason);
190
+ },
191
+ [this.events.REQUEST_FAILED]: ({ request_id, reason }) => {
192
+ this.log.info(`Session request ${request_id} failed, reason: ${reason}`);
193
+ rej(reason);
194
+ },
195
+ [this.events.SESSION_READY]: ({ session_id }) => {
196
+ this.log.info(`Session ${session_id} ready!`);
197
+ res(session_id);
198
+ },
199
+ };
200
+ Object.entries(eventHandlers).forEach(([event, handler]) => {
201
+ this.requestTopic?.on(event, handler);
202
+ });
203
+ this.join(this.requestTopic).catch((err) => {
204
+ rej(err);
205
+ });
206
+ }).finally(cleanup);
207
+ }
208
+ unobserveRequest() {
209
+ Object.values(this.events).forEach((event) => {
210
+ this.requestTopic?.off(event);
211
+ });
212
+ this.requestTopic?.leave();
213
+ this.requestTopic = undefined;
214
+ }
215
+ async requestSession(capabilities) {
216
+ this.log.info('Requesting TV Labs session');
217
+ try {
218
+ const response = await this.push(this.lobbyTopic, 'requests:create', { capabilities });
219
+ this.log.info(`Received session request ID: ${response.request_id}. Waiting for a match...`);
220
+ return response.request_id;
221
+ }
222
+ catch (error) {
223
+ this.log.error('Error requesting session:', error);
224
+ throw error;
225
+ }
226
+ }
227
+ async join(topic) {
228
+ return new Promise((res, rej) => {
229
+ topic
230
+ .join()
231
+ .receive('ok', (_resp) => {
232
+ res();
233
+ })
234
+ .receive('error', ({ response }) => {
235
+ rej('Failed to join topic: ' + response);
236
+ })
237
+ .receive('timeout', () => {
238
+ rej('timeout');
239
+ });
240
+ });
241
+ }
242
+ async push(topic, event, payload) {
243
+ return new Promise((res, rej) => {
244
+ topic
245
+ .push(event, payload)
246
+ .receive('ok', (msg) => {
247
+ res(msg);
248
+ })
249
+ .receive('error', (reason) => {
250
+ rej(reason);
251
+ })
252
+ .receive('timeout', () => {
253
+ rej('timeout');
254
+ });
255
+ });
256
+ }
257
+ params() {
258
+ const serviceInfo = getServiceInfo();
259
+ this.log.debug('Info:', serviceInfo);
260
+ return {
261
+ ...serviceInfo,
262
+ api_key: this.key,
263
+ };
264
+ }
265
+ reconnectAfterMs(tries) {
266
+ if (tries > this.maxReconnectRetries) {
267
+ throw new webdriverio.SevereServiceError('Could not connect to TV Labs, please check your connection.');
268
+ }
269
+ const wait = [0, 1000, 3000, 5000][tries] || 10000;
270
+ this.log.info(`[${tries}/${this.maxReconnectRetries}] Waiting ${wait}ms before re-attempting to connect...`);
271
+ return wait;
272
+ }
273
+ tvlabsSessionLink(sessionId) {
274
+ return `https://tvlabs.ai/app/sessions/${sessionId}`;
275
+ }
276
+ static logSocketError(log, event, _transport, _establishedConnections) {
277
+ const error = event.error;
278
+ log.error('Socket error:', error || event);
279
+ }
280
+ }
281
+
282
+ class TVLabsService {
283
+ _options;
284
+ _capabilities;
285
+ _config;
286
+ log;
287
+ constructor(_options, _capabilities, _config) {
288
+ this._options = _options;
289
+ this._capabilities = _capabilities;
290
+ this._config = _config;
291
+ this.log = new Logger('@tvlabs/wdio-server', this._config.logLevel);
292
+ if (this.attachRequestId()) {
293
+ this.setupRequestId();
294
+ }
295
+ }
296
+ onPrepare(_config, param) {
297
+ if (!Array.isArray(param)) {
298
+ throw new webdriverio.SevereServiceError('Multi-remote capabilities are not implemented. Contact TV Labs support if you are interested in this feature.');
299
+ }
300
+ }
301
+ async beforeSession(_config, capabilities, _specs, _cid) {
302
+ const channel = new TVLabsChannel(this.endpoint(), this.reconnectRetries(), this.apiKey(), this.logLevel());
303
+ await channel.connect();
304
+ capabilities['tvlabs:session_id'] = await channel.newSession(capabilities, this.retries());
305
+ await channel.disconnect();
306
+ }
307
+ setupRequestId() {
308
+ const originalTransformRequest = this._config.transformRequest;
309
+ this._config.transformRequest = (requestOptions) => {
310
+ const requestId = crypto__namespace.randomUUID();
311
+ const originalRequestOptions = typeof originalTransformRequest === 'function'
312
+ ? originalTransformRequest(requestOptions)
313
+ : requestOptions;
314
+ if (typeof originalRequestOptions.headers === 'undefined') {
315
+ originalRequestOptions.headers = {};
316
+ }
317
+ this.setRequestHeader(originalRequestOptions.headers, 'x-request-id', requestId);
318
+ this.log.info('ATTACHED REQUEST ID', requestId);
319
+ return originalRequestOptions;
320
+ };
321
+ }
322
+ setRequestHeader(headers, header, value) {
323
+ if (headers instanceof Headers) {
324
+ headers.set(header, value);
325
+ }
326
+ else if (typeof headers === 'object') {
327
+ if (Array.isArray(headers)) {
328
+ headers.push([header, value]);
329
+ }
330
+ else {
331
+ headers[header] = value;
332
+ }
333
+ }
334
+ }
335
+ endpoint() {
336
+ return this._options.endpoint ?? 'wss://tvlabs.ai/appium';
337
+ }
338
+ retries() {
339
+ return this._options.retries ?? 3;
340
+ }
341
+ apiKey() {
342
+ return this._options.apiKey;
343
+ }
344
+ logLevel() {
345
+ return this._config.logLevel ?? 'info';
346
+ }
347
+ attachRequestId() {
348
+ return this._options.attachRequestId ?? true;
349
+ }
350
+ reconnectRetries() {
351
+ return this._options.reconnectRetries ?? 5;
352
+ }
353
+ }
354
+
355
+ exports.TVLabsService = TVLabsService;
356
+ exports.default = TVLabsService;
@@ -1 +1 @@
1
- {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAwB3C,qBAAa,MAAM;IAEf,OAAO,CAAC,IAAI;IACZ,OAAO,CAAC,QAAQ;gBADR,IAAI,EAAE,MAAM,EACZ,QAAQ,GAAE,QAAiB;IAGrC,OAAO,CAAC,SAAS;IAOjB,OAAO,CAAC,aAAa;IAUrB,KAAK,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAM/B,IAAI,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAM9B,IAAI,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAM9B,KAAK,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAM/B,KAAK,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;CAKhC"}
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAc3C,qBAAa,MAAM;IAEf,OAAO,CAAC,IAAI;IACZ,OAAO,CAAC,QAAQ;gBADR,IAAI,EAAE,MAAM,EACZ,QAAQ,GAAE,QAAiB;IAGrC,OAAO,CAAC,SAAS;IAOjB,OAAO,CAAC,aAAa;IASrB,KAAK,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAM/B,IAAI,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAM9B,IAAI,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAM9B,KAAK,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAM/B,KAAK,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;CAKhC"}
package/cjs/package.json CHANGED
@@ -1 +1,3 @@
1
- {"type": "commonjs"}
1
+ {
2
+ "type": "commonjs"
3
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACnE,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AAY,CAAC,8BAA8B,EAC1D,OAAO,EAAE,OAAO,CAAC,WAAW;IAQtC,SAAS,CACP,OAAO,EAAE,OAAO,CAAC,UAAU,EAC3B,KAAK,EAAE,YAAY,CAAC,sBAAsB;IAStC,aAAa,CACjB,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,cAAc,CAAC,EACjD,YAAY,EAAE,kBAAkB,EAChC,MAAM,EAAE,MAAM,EAAE,EAChB,IAAI,EAAE,MAAM;IAmBd,OAAO,CAAC,cAAc;IA0BtB,OAAO,CAAC,gBAAgB;IAgBxB,OAAO,CAAC,QAAQ;IAIhB,OAAO,CAAC,OAAO;IAIf,OAAO,CAAC,MAAM;IAId,OAAO,CAAC,QAAQ;IAIhB,OAAO,CAAC,eAAe;IAIvB,OAAO,CAAC,gBAAgB;CAGzB"}
package/cjs/types.d.ts CHANGED
@@ -31,7 +31,11 @@ export type TVLabsSessionRequestUpdate = {
31
31
  export type TVLabsSessionRequestResponse = {
32
32
  request_id: string;
33
33
  };
34
- export type TVLabsSessionChannelParams = {
34
+ export type TVLabsSocketParams = TVLabsServiceInfo & {
35
35
  api_key: string;
36
36
  };
37
+ export type TVLabsServiceInfo = {
38
+ service_version: string;
39
+ service_name: string;
40
+ };
37
41
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,GAAG,QAAQ,CAAC;AAEhF,MAAM,MAAM,oBAAoB,GAAG;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,e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getServiceInfo(): TVLabsServiceInfo;
3
+ export declare function getServiceVersion(): string;
4
+ export declare function getServiceName(): string;
5
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAG/C,wBAAgB,cAAc,IAAI,iBAAiB,CAKlD;AAED,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAED,wBAAgB,cAAc,IAAI,MAAM,CAEvC"}
package/esm/channel.d.ts CHANGED
@@ -9,7 +9,7 @@ export declare class TVLabsChannel {
9
9
  private requestTopic?;
10
10
  private log;
11
11
  private readonly events;
12
- constructor(endpoint: string, maxReconnectRetries: number, key: string, logLevel: LogLevel);
12
+ constructor(endpoint: string, maxReconnectRetries: number, key: string, logLevel?: LogLevel);
13
13
  disconnect(): Promise<void>;
14
14
  connect(): Promise<void>;
15
15
  newSession(capabilities: TVLabsCapabilities, maxRetries: number, retry?: number): Promise<string>;
@@ -21,7 +21,7 @@ export declare class TVLabsChannel {
21
21
  private push;
22
22
  private params;
23
23
  private reconnectAfterMs;
24
- private logSocketError;
25
24
  private tvlabsSessionLink;
25
+ private static logSocketError;
26
26
  }
27
27
  //# sourceMappingURL=channel.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../src/channel.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,kBAAkB,EAIlB,QAAQ,EACT,MAAM,YAAY,CAAC;AAGpB,qBAAa,aAAa;IAgBtB,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,mBAAmB;IAC3B,OAAO,CAAC,GAAG;IACX,OAAO,CAAC,QAAQ;IAlBlB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,UAAU,CAAU;IAC5B,OAAO,CAAC,YAAY,CAAC,CAAU;IAC/B,OAAO,CAAC,GAAG,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EAChC,UAAU,EAAE,MAAM,EAClB,KAAK,SAAI,GACR,OAAO,CAAC,MAAM,CAAC;YAWJ,WAAW;YAkBX,cAAc;IAsD5B,OAAO,CAAC,gBAAgB;YAUV,cAAc;YAuBd,IAAI;YAgBJ,IAAI;IAoBlB,OAAO,CAAC,MAAM;IAWd,OAAO,CAAC,gBAAgB;IAgBxB,OAAO,CAAC,iBAAiB;IAIzB,OAAO,CAAC,MAAM,CAAC,cAAc;CAU9B"}
package/esm/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import TVLabsService from './service.js';
2
+ export { TVLabsService };
2
3
  export default TVLabsService;
3
4
  export * from './types.js';
4
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,cAAc,CAAC;AAEzC,eAAe,aAAa,CAAC;AAC7B,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,aAAa,EAAE,CAAC;AACzB,eAAe,aAAa,CAAC;AAC7B,cAAc,YAAY,CAAC"}