appium-safari-driver 3.5.21 → 3.5.22

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.
@@ -1,8 +1,12 @@
1
- const commands = {};
2
1
 
3
- commands.deleteCookies = async function deleteCookies () {
2
+ /**
3
+ * @this {SafariDriver}
4
+ * @returns {Promise<any>}
5
+ */
6
+ export async function deleteCookies () {
4
7
  return await this.safari.proxy.command('/cookie', 'DELETE');
5
- };
8
+ }
6
9
 
7
- export { commands };
8
- export default commands;
10
+ /**
11
+ * @typedef {import('../driver').SafariDriver} SafariDriver
12
+ */
@@ -1,19 +1,23 @@
1
1
  import { util } from 'appium/support';
2
2
 
3
-
4
- const commands = {};
5
-
6
3
  // This is needed to make lookup by image working
7
- commands.findElOrEls = async function findElOrEls (strategy, selector, mult, context) {
8
- context = util.unwrapElement(context);
9
- const endpoint = `/element${context ? `/${context}/element` : ''}${mult ? 's' : ''}`;
10
-
4
+ /**
5
+ *
6
+ * @this {SafariDriver}
7
+ * @param {string} strategy
8
+ * @param {string} selector
9
+ * @param {boolean} mult
10
+ * @param {string} [context]
11
+ * @returns {Promise<any>}
12
+ */
13
+ export async function findElOrEls (strategy, selector, mult, context) {
14
+ const endpoint = `/element${context ? `/${util.unwrapElement(context)}/element` : ''}${mult ? 's' : ''}`;
11
15
  return await this.safari.proxy.command(endpoint, 'POST', {
12
16
  using: strategy,
13
17
  value: selector,
14
18
  });
15
- };
16
-
19
+ }
17
20
 
18
- export { commands };
19
- export default commands;
21
+ /**
22
+ * @typedef {import('../driver').SafariDriver} SafariDriver
23
+ */
@@ -3,9 +3,6 @@ import { util, fs, net, tempDir } from 'appium/support';
3
3
  import { waitForCondition } from 'asyncbox';
4
4
  import { Simctl } from 'node-simctl';
5
5
 
6
-
7
- const commands = {};
8
-
9
6
  const STARTUP_INTERVAL_MS = 300;
10
7
  const STARTUP_TIMEOUT_MS = 10 * 1000;
11
8
  const DEFAULT_TIME_LIMIT_MS = 60 * 10 * 1000; // 10 minutes
@@ -235,11 +232,12 @@ async function extractSimulatorUdid (caps) {
235
232
  * This method uses `xcrun simctl io recordVideo` helper under the hood.
236
233
  * Check the output of `xcrun simctl io` command for more details.
237
234
  *
235
+ * @this {SafariDriver}
238
236
  * @param {StartRecordingOptions} options - The available options.
239
237
  * @this {import('../driver').SafariDriver}
240
238
  * @throws {Error} If screen recording has failed to start or is not supported for the destination device.
241
239
  */
242
- commands.startRecordingScreen = async function startRecordingScreen (options) {
240
+ export async function startRecordingScreen (options) {
243
241
  const {
244
242
  timeLimit,
245
243
  codec,
@@ -280,7 +278,7 @@ commands.startRecordingScreen = async function startRecordingScreen (options) {
280
278
  this._screenRecorder = null;
281
279
  throw e;
282
280
  }
283
- };
281
+ }
284
282
 
285
283
  /**
286
284
  * @typedef {Object} StopRecordingOptions
@@ -304,6 +302,7 @@ commands.startRecordingScreen = async function startRecordingScreen (options) {
304
302
  * Stop recording the screen.
305
303
  * If no screen recording has been started before then the method returns an empty string.
306
304
  *
305
+ * @this {SafariDriver}
307
306
  * @param {StopRecordingOptions} options - The available options.
308
307
  * @returns {Promise<string>} Base64-encoded content of the recorded media file if 'remotePath'
309
308
  * parameter is falsy or an empty string.
@@ -312,7 +311,7 @@ commands.startRecordingScreen = async function startRecordingScreen (options) {
312
311
  * or the file content cannot be uploaded to the remote location
313
312
  * or screen recording is not supported on the device under test.
314
313
  */
315
- commands.stopRecordingScreen = async function stopRecordingScreen (options) {
314
+ export async function stopRecordingScreen (options) {
316
315
  if (!this._screenRecorder) {
317
316
  this.log.info('No screen recording has been started. Doing nothing');
318
317
  return '';
@@ -329,6 +328,8 @@ commands.stopRecordingScreen = async function stopRecordingScreen (options) {
329
328
  this.log.debug(`The size of the resulting screen recording is ${util.toReadableSizeString(size)}`);
330
329
  }
331
330
  return await uploadRecordedMedia(videoPath, options?.remotePath, options);
332
- };
331
+ }
333
332
 
334
- export default commands;
333
+ /**
334
+ * @typedef {import('../driver').SafariDriver} SafariDriver
335
+ */
package/lib/driver.js CHANGED
@@ -1,8 +1,9 @@
1
- import _ from 'lodash';
2
1
  import { BaseDriver } from 'appium/driver';
3
- import SafariDriverServer from './safari';
2
+ import { SafariDriverServer } from './safari';
4
3
  import { desiredCapConstraints } from './desired-caps';
5
- import { commands } from './commands/index';
4
+ import * as cookieCommands from './commands/cookies';
5
+ import * as findCommands from './commands/find';
6
+ import * as recordScreenCommands from './commands/record-screen';
6
7
  import { formatCapsForServer } from './utils';
7
8
  import { newMethodMap } from './method-map';
8
9
 
@@ -20,6 +21,9 @@ export class SafariDriver extends BaseDriver {
20
21
  /** @type {boolean} */
21
22
  isProxyActive;
22
23
 
24
+ /** @type {SafariDriverServer} */
25
+ safari;
26
+
23
27
  static newMethodMap = newMethodMap;
24
28
 
25
29
  constructor (opts = {}) {
@@ -37,13 +41,10 @@ export class SafariDriver extends BaseDriver {
37
41
  'name',
38
42
  ];
39
43
  this.resetState();
40
-
41
- for (const [cmd, fn] of _.toPairs(commands)) {
42
- SafariDriver.prototype[cmd] = fn;
43
- }
44
44
  }
45
45
 
46
46
  resetState () {
47
+ // @ts-ignore That's ok
47
48
  this.safari = null;
48
49
  this.proxyReqRes = null;
49
50
  this.isProxyActive = false;
@@ -86,6 +87,13 @@ export class SafariDriver extends BaseDriver {
86
87
 
87
88
  await super.deleteSession();
88
89
  }
90
+
91
+ deleteCookies = cookieCommands.deleteCookies;
92
+
93
+ findElOrEls = findCommands.findElOrEls;
94
+
95
+ startRecordingScreen = recordScreenCommands.startRecordingScreen;
96
+ stopRecordingScreen = recordScreenCommands.stopRecordingScreen;
89
97
  }
90
98
 
91
99
  export default SafariDriver;
package/lib/safari.js CHANGED
@@ -98,9 +98,16 @@ process.once('exit', () => {
98
98
  }
99
99
  });
100
100
 
101
- class SafariDriverServer {
101
+ export class SafariDriverServer {
102
+ /** @type {SafariProxy} */
103
+ proxy;
104
+
105
+ /**
106
+ * @param {import('@appium/types').AppiumLogger} log
107
+ */
102
108
  constructor (log) {
103
109
  this.log = log;
110
+ // @ts-ignore That's ok
104
111
  this.proxy = null;
105
112
  }
106
113
 
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "appium-safari-driver",
3
- "version": "3.5.21",
3
+ "version": "3.5.22",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "appium-safari-driver",
9
- "version": "3.5.21",
9
+ "version": "3.5.22",
10
10
  "license": "Apache-2.0",
11
11
  "dependencies": {
12
12
  "asyncbox": "^3.0.0",
@@ -263,9 +263,9 @@
263
263
  "license": "MIT"
264
264
  },
265
265
  "node_modules/@types/node": {
266
- "version": "22.12.0",
267
- "resolved": "https://registry.npmjs.org/@types/node/-/node-22.12.0.tgz",
268
- "integrity": "sha512-Fll2FZ1riMjNmlmJOdAyY5pUbkftXslB5DgEzlIuNaiWhXd00FhWxVC/r4yV/4wBb9JfImTu+jiSvXTkJ7F/gA==",
266
+ "version": "22.13.0",
267
+ "resolved": "https://registry.npmjs.org/@types/node/-/node-22.13.0.tgz",
268
+ "integrity": "sha512-ClIbNe36lawluuvq3+YYhnIN2CELi+6q8NpnM7PYp4hBn/TatfboPgVSm2rwKRfnV2M+Ty9GWDFI64KEe+kysA==",
269
269
  "license": "MIT",
270
270
  "dependencies": {
271
271
  "undici-types": "~6.20.0"
@@ -1560,13 +1560,6 @@
1560
1560
  "extraneous": true,
1561
1561
  "license": "MIT"
1562
1562
  },
1563
- "node_modules/queue-tick": {
1564
- "version": "1.0.1",
1565
- "resolved": "https://registry.npmjs.org/queue-tick/-/queue-tick-1.0.1.tgz",
1566
- "integrity": "sha512-kJt5qhMxoszgU/62PLP1CJytzd2NKetjSRnyuj31fDd3Rlcz3fzlFdFLD1SItunPwyqEOkca6GbV612BWfaBag==",
1567
- "extraneous": true,
1568
- "license": "MIT"
1569
- },
1570
1563
  "node_modules/readable-stream": {
1571
1564
  "version": "4.7.0",
1572
1565
  "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-4.7.0.tgz",
@@ -1840,14 +1833,13 @@
1840
1833
  "license": "CC0-1.0"
1841
1834
  },
1842
1835
  "node_modules/streamx": {
1843
- "version": "2.21.1",
1844
- "resolved": "https://registry.npmjs.org/streamx/-/streamx-2.21.1.tgz",
1845
- "integrity": "sha512-PhP9wUnFLa+91CPy3N6tiQsK+gnYyUNuk15S3YG/zjYE7RuPeCjJngqnzpC31ow0lzBHQ+QGO4cNJnd0djYUsw==",
1836
+ "version": "2.22.0",
1837
+ "resolved": "https://registry.npmjs.org/streamx/-/streamx-2.22.0.tgz",
1838
+ "integrity": "sha512-sLh1evHOzBy/iWRiR6d1zRcLao4gGZr3C1kzNz4fopCOKJb6xD9ub8Mpi9Mr1R6id5o43S+d93fI48UC5uM9aw==",
1846
1839
  "extraneous": true,
1847
1840
  "license": "MIT",
1848
1841
  "dependencies": {
1849
1842
  "fast-fifo": "^1.3.2",
1850
- "queue-tick": "^1.0.1",
1851
1843
  "text-decoder": "^1.1.0"
1852
1844
  },
1853
1845
  "optionalDependencies": {
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "appium",
6
6
  "safari"
7
7
  ],
8
- "version": "3.5.21",
8
+ "version": "3.5.22",
9
9
  "author": "Appium Contributors",
10
10
  "license": "Apache-2.0",
11
11
  "repository": {
@@ -1,3 +0,0 @@
1
- export default commands;
2
- export const commands: {};
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/commands/index.js"],"names":[],"mappings":";AAIA,0BAAoB"}
@@ -1,14 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.commands = void 0;
7
- const find_1 = __importDefault(require("./find"));
8
- const cookies_1 = __importDefault(require("./cookies"));
9
- const record_screen_1 = __importDefault(require("./record-screen"));
10
- const commands = {};
11
- exports.commands = commands;
12
- Object.assign(commands, find_1.default, cookies_1.default, record_screen_1.default);
13
- exports.default = commands;
14
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/commands/index.js"],"names":[],"mappings":";;;;;;AAAA,kDAA8B;AAC9B,wDAAmC;AACnC,oEAAmD;AAEnD,MAAM,QAAQ,GAAG,EAAE,CAAC;AASX,4BAAQ;AARjB,MAAM,CAAC,MAAM,CACX,QAAQ,EACR,cAAQ,EACR,iBAAU,EACV,uBAAoB,CAErB,CAAC;AAGF,kBAAe,QAAQ,CAAC"}
@@ -1,15 +0,0 @@
1
- import findCmds from './find';
2
- import cookieCmds from './cookies';
3
- import recordScreenCommands from './record-screen';
4
-
5
- const commands = {};
6
- Object.assign(
7
- commands,
8
- findCmds,
9
- cookieCmds,
10
- recordScreenCommands,
11
- // add other command types here
12
- );
13
-
14
- export { commands };
15
- export default commands;