webdriver 8.0.0-alpha.330 → 8.0.0-alpha.365

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/build/bidi.js CHANGED
@@ -1,49 +1,37 @@
1
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
- if (kind === "m") throw new TypeError("Private method is not writable");
3
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
- };
7
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
- };
12
- var _BidiHandler_id, _BidiHandler_ws, _BidiHandler_isConnected;
13
1
  import { EventEmitter } from 'node:events';
14
2
  import WebSocket from 'ws';
15
3
  import logger from '@wdio/logger';
16
4
  const log = logger('webdriver:BidiHandler');
17
5
  const RESPONSE_TIMEOUT = 1000 * 60;
18
6
  export class BidiHandler extends EventEmitter {
7
+ _webSocketUrl;
8
+ #id = 0;
9
+ #ws;
10
+ #isConnected = false;
19
11
  constructor(_webSocketUrl) {
20
12
  super();
21
13
  this._webSocketUrl = _webSocketUrl;
22
- _BidiHandler_id.set(this, 0);
23
- _BidiHandler_ws.set(this, void 0);
24
- _BidiHandler_isConnected.set(this, false);
25
14
  log.info(`Connect to webSocketUrl ${this._webSocketUrl}`);
26
- __classPrivateFieldSet(this, _BidiHandler_ws, new WebSocket(this._webSocketUrl), "f");
15
+ this.#ws = new WebSocket(this._webSocketUrl);
27
16
  }
28
17
  connect() {
29
- return new Promise((resolve) => __classPrivateFieldGet(this, _BidiHandler_ws, "f").on('open', () => {
30
- __classPrivateFieldSet(this, _BidiHandler_isConnected, true, "f");
18
+ return new Promise((resolve) => this.#ws.on('open', () => {
19
+ this.#isConnected = true;
31
20
  resolve();
32
21
  }));
33
22
  }
34
23
  get socket() {
35
- return __classPrivateFieldGet(this, _BidiHandler_ws, "f");
24
+ return this.#ws;
36
25
  }
37
26
  get isConnected() {
38
- return __classPrivateFieldGet(this, _BidiHandler_isConnected, "f");
27
+ return this.#isConnected;
39
28
  }
40
29
  send(params) {
41
- var _a;
42
- if (!__classPrivateFieldGet(this, _BidiHandler_isConnected, "f")) {
30
+ if (!this.#isConnected) {
43
31
  throw new Error('No connection to WebDriver Bidi was established');
44
32
  }
45
- const id = __classPrivateFieldSet(this, _BidiHandler_id, (_a = __classPrivateFieldGet(this, _BidiHandler_id, "f"), ++_a), "f");
46
- __classPrivateFieldGet(this, _BidiHandler_ws, "f").send(JSON.stringify({ id, ...params }));
33
+ const id = ++this.#id;
34
+ this.#ws.send(JSON.stringify({ id, ...params }));
47
35
  return new Promise((resolve, reject) => {
48
36
  const t = setTimeout(() => {
49
37
  reject(new Error(`Request with id ${id} timed out`));
@@ -62,16 +50,14 @@ export class BidiHandler extends EventEmitter {
62
50
  log.error(`Failed parse message: ${err.message}`);
63
51
  }
64
52
  };
65
- const h = __classPrivateFieldGet(this, _BidiHandler_ws, "f").on('message', listener);
53
+ const h = this.#ws.on('message', listener);
66
54
  });
67
55
  }
68
56
  sendAsync(params) {
69
- var _a;
70
- if (!__classPrivateFieldGet(this, _BidiHandler_isConnected, "f")) {
57
+ if (!this.#isConnected) {
71
58
  throw new Error('No connection to WebDriver Bidi was established');
72
59
  }
73
- const id = __classPrivateFieldSet(this, _BidiHandler_id, (_a = __classPrivateFieldGet(this, _BidiHandler_id, "f"), ++_a), "f");
74
- __classPrivateFieldGet(this, _BidiHandler_ws, "f").send(JSON.stringify({ id, ...params }));
60
+ const id = ++this.#id;
61
+ this.#ws.send(JSON.stringify({ id, ...params }));
75
62
  }
76
63
  }
77
- _BidiHandler_id = new WeakMap(), _BidiHandler_ws = new WeakMap(), _BidiHandler_isConnected = new WeakMap();
@@ -8,6 +8,9 @@ import { isSuccessfulResponse, getErrorFromResponseBody, getTimeoutError } from
8
8
  const require = createRequire(import.meta.url);
9
9
  const pkg = require('../../package.json');
10
10
  export class RequestLibError extends Error {
11
+ statusCode;
12
+ body;
13
+ code;
11
14
  }
12
15
  const DEFAULT_HEADERS = {
13
16
  'Content-Type': 'application/json; charset=utf-8',
@@ -17,14 +20,20 @@ const DEFAULT_HEADERS = {
17
20
  };
18
21
  const log = logger('webdriver');
19
22
  export default class WebDriverRequest extends EventEmitter {
23
+ body;
24
+ method;
25
+ endpoint;
26
+ isHubCommand;
27
+ requiresSessionId;
28
+ defaultAgents;
29
+ defaultOptions = {
30
+ retry: { limit: 0 },
31
+ followRedirect: true,
32
+ responseType: 'json',
33
+ throwHttpErrors: false
34
+ };
20
35
  constructor(method, endpoint, body, isHubCommand = false) {
21
36
  super();
22
- this.defaultOptions = {
23
- retry: { limit: 0 },
24
- followRedirect: true,
25
- responseType: 'json',
26
- throwHttpErrors: false
27
- };
28
37
  this.body = body;
29
38
  this.method = method;
30
39
  this.endpoint = endpoint;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webdriver",
3
- "version": "8.0.0-alpha.330+ea33c6a97",
3
+ "version": "8.0.0-alpha.365+ea5d90e26",
4
4
  "description": "A Node.js bindings implementation for the W3C WebDriver and Mobile JSONWire Protocol",
5
5
  "author": "Christian Bromann <mail@bromann.dev>",
6
6
  "homepage": "https://github.com/webdriverio/webdriverio/tree/main/packages/webdriver",
@@ -39,15 +39,15 @@
39
39
  "dependencies": {
40
40
  "@types/node": "^18.0.0",
41
41
  "@types/ws": "^8.5.3",
42
- "@wdio/config": "8.0.0-alpha.330+ea33c6a97",
43
- "@wdio/logger": "8.0.0-alpha.330+ea33c6a97",
44
- "@wdio/protocols": "8.0.0-alpha.330+ea33c6a97",
45
- "@wdio/types": "8.0.0-alpha.330+ea33c6a97",
46
- "@wdio/utils": "8.0.0-alpha.330+ea33c6a97",
42
+ "@wdio/config": "8.0.0-alpha.365+ea5d90e26",
43
+ "@wdio/logger": "8.0.0-alpha.365+ea5d90e26",
44
+ "@wdio/protocols": "8.0.0-alpha.365+ea5d90e26",
45
+ "@wdio/types": "8.0.0-alpha.365+ea5d90e26",
46
+ "@wdio/utils": "8.0.0-alpha.365+ea5d90e26",
47
47
  "got": "^12.1.0",
48
48
  "ky": "^0.31.1",
49
49
  "lodash.merge": "^4.6.2",
50
50
  "ws": "^8.8.0"
51
51
  },
52
- "gitHead": "ea33c6a97523a726882fd93515f3de5eceb914ff"
52
+ "gitHead": "ea5d90e263106af626e420bab7825bac4beb1dfe"
53
53
  }