appium-xcuitest-driver 7.31.0 → 7.32.0

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.
Files changed (38) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/build/lib/commands/bidi/constants.d.ts +4 -0
  3. package/build/lib/commands/bidi/constants.d.ts.map +1 -0
  4. package/build/lib/commands/bidi/constants.js +7 -0
  5. package/build/lib/commands/bidi/constants.js.map +1 -0
  6. package/build/lib/commands/bidi/models.d.ts +5 -0
  7. package/build/lib/commands/bidi/models.d.ts.map +1 -0
  8. package/build/lib/commands/bidi/models.js +31 -0
  9. package/build/lib/commands/bidi/models.js.map +1 -0
  10. package/build/lib/commands/bidi/types.d.ts +25 -0
  11. package/build/lib/commands/bidi/types.d.ts.map +1 -0
  12. package/build/lib/commands/bidi/types.js +4 -0
  13. package/build/lib/commands/bidi/types.js.map +1 -0
  14. package/build/lib/commands/context.d.ts +7 -0
  15. package/build/lib/commands/context.d.ts.map +1 -1
  16. package/build/lib/commands/context.js +19 -1
  17. package/build/lib/commands/context.js.map +1 -1
  18. package/build/lib/commands/log.d.ts +10 -10
  19. package/build/lib/commands/log.d.ts.map +1 -1
  20. package/build/lib/commands/log.js +25 -38
  21. package/build/lib/commands/log.js.map +1 -1
  22. package/build/lib/driver.d.ts +0 -2
  23. package/build/lib/driver.d.ts.map +1 -1
  24. package/build/lib/driver.js +5 -1
  25. package/build/lib/driver.js.map +1 -1
  26. package/build/lib/utils.d.ts +0 -1
  27. package/build/lib/utils.d.ts.map +1 -1
  28. package/build/lib/utils.js +1 -2
  29. package/build/lib/utils.js.map +1 -1
  30. package/lib/commands/bidi/constants.ts +3 -0
  31. package/lib/commands/bidi/models.ts +30 -0
  32. package/lib/commands/bidi/types.ts +29 -0
  33. package/lib/commands/context.js +19 -1
  34. package/lib/commands/log.js +30 -46
  35. package/lib/driver.js +4 -1
  36. package/lib/utils.js +0 -1
  37. package/npm-shrinkwrap.json +53 -17
  38. package/package.json +1 -1
@@ -8,7 +8,9 @@ import WebSocket from 'ws';
8
8
  import SafariConsoleLog from '../device-log/safari-console-log';
9
9
  import SafariNetworkLog from '../device-log/safari-network-log';
10
10
  import { toLogEntry } from '../device-log/helpers';
11
- import { NATIVE_WIN, BIDI_EVENT_NAME } from '../utils';
11
+ import { NATIVE_WIN } from '../utils';
12
+ import { BIDI_EVENT_NAME } from './bidi/constants';
13
+ import { makeLogEntryAddedEvent } from './bidi/models';
12
14
 
13
15
  /**
14
16
  * Determines the websocket endpoint based on the `sessionId`
@@ -107,42 +109,6 @@ export default {
107
109
  );
108
110
  },
109
111
 
110
- /**
111
- * https://w3c.github.io/webdriver-bidi/#event-log-entryAdded
112
- *
113
- * @template {import('node:events').EventEmitter} EE
114
- * @this {XCUITestDriver}
115
- * @param {EE} logEmitter
116
- * @param {BiDiListenerProperties} properties
117
- * @returns {[EE, import('./types').LogListener]}
118
- */
119
- assignBiDiLogListener (logEmitter, properties) {
120
- const {
121
- type,
122
- context = NATIVE_WIN,
123
- srcEventName = 'output',
124
- entryTransformer,
125
- } = properties;
126
- const listener = (/** @type {import('./types').LogEntry} */ logEntry) => {
127
- const finalEntry = entryTransformer ? entryTransformer(logEntry) : logEntry;
128
- this.eventEmitter.emit(BIDI_EVENT_NAME, {
129
- context,
130
- method: 'log.entryAdded',
131
- params: {
132
- type,
133
- level: finalEntry.level,
134
- source: {
135
- realm: '',
136
- },
137
- text: finalEntry.message,
138
- timestamp: finalEntry.timestamp,
139
- },
140
- });
141
- };
142
- logEmitter.on(srcEventName, listener);
143
- return [logEmitter, listener];
144
- },
145
-
146
112
  /**
147
113
  * @this {XCUITestDriver}
148
114
  */
@@ -154,7 +120,7 @@ export default {
154
120
  }
155
121
 
156
122
  if (_.isUndefined(this.logs.syslog)) {
157
- [this.logs.crashlog,] = this.assignBiDiLogListener(
123
+ [this.logs.crashlog,] = assignBiDiLogListener.bind(this)(
158
124
  new IOSCrashLog({
159
125
  sim: /** @type {import('appium-ios-simulator').Simulator} */ (this.device),
160
126
  udid: this.isRealDevice() ? this.opts.udid : undefined,
@@ -163,7 +129,7 @@ export default {
163
129
  type: 'crashlog',
164
130
  }
165
131
  );
166
- [this.logs.syslog,] = this.assignBiDiLogListener(
132
+ [this.logs.syslog,] = assignBiDiLogListener.bind(this)(
167
133
  this.isRealDevice()
168
134
  ? new IOSDeviceLog({
169
135
  udid: this.opts.udid,
@@ -182,7 +148,7 @@ export default {
182
148
  }
183
149
  );
184
150
  if (_.isBoolean(this.opts.showSafariConsoleLog)) {
185
- [this.logs.safariConsole,] = this.assignBiDiLogListener(
151
+ [this.logs.safariConsole,] = assignBiDiLogListener.bind(this)(
186
152
  new SafariConsoleLog({
187
153
  showLogs: this.opts.showSafariConsoleLog,
188
154
  log: this.log,
@@ -192,7 +158,7 @@ export default {
192
158
  );
193
159
  }
194
160
  if (_.isBoolean(this.opts.showSafariNetworkLog)) {
195
- [this.logs.safariNetwork,] = this.assignBiDiLogListener(
161
+ [this.logs.safariNetwork,] = assignBiDiLogListener.bind(this)(
196
162
  new SafariNetworkLog({
197
163
  showLogs: this.opts.showSafariNetworkLog,
198
164
  log: this.log,
@@ -202,7 +168,7 @@ export default {
202
168
  );
203
169
  }
204
170
  if (this.isFeatureEnabled(GET_SERVER_LOGS_FEATURE)) {
205
- [, this._bidiServerLogListener] = this.assignBiDiLogListener(
171
+ [, this._bidiServerLogListener] = assignBiDiLogListener.bind(this)(
206
172
  this.log.unwrap(), {
207
173
  type: 'server',
208
174
  srcEventName: 'log',
@@ -323,14 +289,32 @@ export default {
323
289
  };
324
290
 
325
291
  /**
326
- * @typedef {import('../driver').XCUITestDriver} XCUITestDriver
292
+ * https://w3c.github.io/webdriver-bidi/#event-log-entryAdded
293
+ *
294
+ * @template {import('node:events').EventEmitter} EE
295
+ * @this {XCUITestDriver}
296
+ * @param {EE} logEmitter
297
+ * @param {BiDiListenerProperties} properties
298
+ * @returns {[EE, import('./types').LogListener]}
327
299
  */
300
+ export function assignBiDiLogListener (logEmitter, properties) {
301
+ const {
302
+ type,
303
+ context = NATIVE_WIN,
304
+ srcEventName = 'output',
305
+ entryTransformer,
306
+ } = properties;
307
+ const listener = (/** @type {import('./types').LogEntry} */ logEntry) => {
308
+ const finalEntry = entryTransformer ? entryTransformer(logEntry) : logEntry;
309
+ this.eventEmitter.emit(BIDI_EVENT_NAME, makeLogEntryAddedEvent(finalEntry, context, type));
310
+ };
311
+ logEmitter.on(srcEventName, listener);
312
+ return [logEmitter, listener];
313
+ }
328
314
 
329
315
  /**
316
+ * @typedef {import('../driver').XCUITestDriver} XCUITestDriver
330
317
  * @typedef {keyof typeof SUPPORTED_LOG_TYPES} XCUITestDriverLogTypes
331
- */
332
-
333
- /**
334
318
  * @typedef {import('@appium/types').AppiumServer} AppiumServer
335
319
  */
336
320
 
package/lib/driver.js CHANGED
@@ -62,6 +62,7 @@ import {
62
62
  translateDeviceName,
63
63
  } from './utils';
64
64
  import { AppInfosCache } from './app-infos-cache';
65
+ import { notifyBiDiContextChange } from './commands/context';
65
66
 
66
67
  const SHUTDOWN_OTHER_FEAT_NAME = 'shutdown_other_sims';
67
68
  const CUSTOMIZE_RESULT_BUNDLE_PATH = 'customize_result_bundle_path';
@@ -660,6 +661,9 @@ export class XCUITestDriver extends BaseDriver {
660
661
 
661
662
  if (this.isSafari() || this.opts.autoWebview) {
662
663
  await this.activateRecentWebview();
664
+ } else {
665
+ // We want to always setup the initial context value upon session startup
666
+ await notifyBiDiContextChange.bind(this)();
663
667
  }
664
668
  if (this.isSafari()) {
665
669
  if (shouldSetInitialSafariUrl(this.opts)) {
@@ -2017,7 +2021,6 @@ export class XCUITestDriver extends BaseDriver {
2017
2021
  extractLogs = commands.logExtensions.extractLogs;
2018
2022
  supportedLogTypes = commands.logExtensions.supportedLogTypes;
2019
2023
  startLogCapture = commands.logExtensions.startLogCapture;
2020
- assignBiDiLogListener = commands.logExtensions.assignBiDiLogListener;
2021
2024
  mobileStartLogsBroadcast = commands.logExtensions.mobileStartLogsBroadcast;
2022
2025
  mobileStopLogsBroadcast = commands.logExtensions.mobileStopLogsBroadcast;
2023
2026
 
package/lib/utils.js CHANGED
@@ -21,7 +21,6 @@ const XCTEST_LOG_FILES_PATTERNS = [
21
21
  ];
22
22
  const XCTEST_LOGS_CACHE_FOLDER_PREFIX = 'com.apple.dt.XCTest';
23
23
  export const NATIVE_WIN = 'NATIVE_APP';
24
- export const BIDI_EVENT_NAME = 'bidiEvent';
25
24
 
26
25
  /**
27
26
  * @privateRemarks Is the minimum version really Xcode 7.3?
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "appium-xcuitest-driver",
3
- "version": "7.31.0",
3
+ "version": "7.32.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "appium-xcuitest-driver",
9
- "version": "7.31.0",
9
+ "version": "7.32.0",
10
10
  "license": "Apache-2.0",
11
11
  "dependencies": {
12
12
  "@colors/colors": "^1.6.0",
@@ -118,6 +118,18 @@
118
118
  "integrity": "sha512-sviUmCE8AYdaF/KIHLDJBQgeYzPBI0vf/17NaYehBJfYD1j6/L95Slh07NlyK2iNyBNaEkb3En2jRt+a8y3xZQ==",
119
119
  "license": "MIT"
120
120
  },
121
+ "node_modules/@appium/base-driver/node_modules/type-fest": {
122
+ "version": "4.26.1",
123
+ "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-4.26.1.tgz",
124
+ "integrity": "sha512-yOGpmOAL7CkKe/91I5O3gPICmJNLJ1G4zFYVAsRHg7M64biSnPtRj0WNQt++bRkjYOqjWXrhnUw1utzmVErAdg==",
125
+ "license": "(MIT OR CC0-1.0)",
126
+ "engines": {
127
+ "node": ">=16"
128
+ },
129
+ "funding": {
130
+ "url": "https://github.com/sponsors/sindresorhus"
131
+ }
132
+ },
121
133
  "node_modules/@appium/docutils": {
122
134
  "version": "1.0.23",
123
135
  "resolved": "https://registry.npmjs.org/@appium/docutils/-/docutils-1.0.23.tgz",
@@ -153,6 +165,18 @@
153
165
  "npm": ">=8"
154
166
  }
155
167
  },
168
+ "node_modules/@appium/docutils/node_modules/type-fest": {
169
+ "version": "4.26.1",
170
+ "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-4.26.1.tgz",
171
+ "integrity": "sha512-yOGpmOAL7CkKe/91I5O3gPICmJNLJ1G4zFYVAsRHg7M64biSnPtRj0WNQt++bRkjYOqjWXrhnUw1utzmVErAdg==",
172
+ "license": "(MIT OR CC0-1.0)",
173
+ "engines": {
174
+ "node": ">=16"
175
+ },
176
+ "funding": {
177
+ "url": "https://github.com/sponsors/sindresorhus"
178
+ }
179
+ },
156
180
  "node_modules/@appium/logger": {
157
181
  "version": "1.6.1",
158
182
  "resolved": "https://registry.npmjs.org/@appium/logger/-/logger-1.6.1.tgz",
@@ -265,6 +289,18 @@
265
289
  "sharp": "0.33.5"
266
290
  }
267
291
  },
292
+ "node_modules/@appium/support/node_modules/type-fest": {
293
+ "version": "4.26.1",
294
+ "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-4.26.1.tgz",
295
+ "integrity": "sha512-yOGpmOAL7CkKe/91I5O3gPICmJNLJ1G4zFYVAsRHg7M64biSnPtRj0WNQt++bRkjYOqjWXrhnUw1utzmVErAdg==",
296
+ "license": "(MIT OR CC0-1.0)",
297
+ "engines": {
298
+ "node": ">=16"
299
+ },
300
+ "funding": {
301
+ "url": "https://github.com/sponsors/sindresorhus"
302
+ }
303
+ },
268
304
  "node_modules/@appium/tsconfig": {
269
305
  "version": "0.3.3",
270
306
  "resolved": "https://registry.npmjs.org/@appium/tsconfig/-/tsconfig-0.3.3.tgz",
@@ -296,6 +332,18 @@
296
332
  "npm": ">=8"
297
333
  }
298
334
  },
335
+ "node_modules/@appium/types/node_modules/type-fest": {
336
+ "version": "4.26.1",
337
+ "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-4.26.1.tgz",
338
+ "integrity": "sha512-yOGpmOAL7CkKe/91I5O3gPICmJNLJ1G4zFYVAsRHg7M64biSnPtRj0WNQt++bRkjYOqjWXrhnUw1utzmVErAdg==",
339
+ "license": "(MIT OR CC0-1.0)",
340
+ "engines": {
341
+ "node": ">=16"
342
+ },
343
+ "funding": {
344
+ "url": "https://github.com/sponsors/sindresorhus"
345
+ }
346
+ },
299
347
  "node_modules/@babel/code-frame": {
300
348
  "version": "7.26.2",
301
349
  "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.26.2.tgz",
@@ -3833,9 +3881,9 @@
3833
3881
  }
3834
3882
  },
3835
3883
  "node_modules/streamx": {
3836
- "version": "2.20.1",
3837
- "resolved": "https://registry.npmjs.org/streamx/-/streamx-2.20.1.tgz",
3838
- "integrity": "sha512-uTa0mU6WUC65iUvzKH4X9hEdvSW7rbPxPtwfWiLMSj3qTdQbAiUboZTxauKfpFuGIGa1C2BYijZ7wgdUXICJhA==",
3884
+ "version": "2.20.2",
3885
+ "resolved": "https://registry.npmjs.org/streamx/-/streamx-2.20.2.tgz",
3886
+ "integrity": "sha512-aDGDLU+j9tJcUdPGOaHmVF1u/hhI+CsGkT02V3OKlHDV7IukOI+nTWAGkiZEKCO35rWN1wIr4tS7YFr1f4qSvA==",
3839
3887
  "license": "MIT",
3840
3888
  "dependencies": {
3841
3889
  "fast-fifo": "^1.3.2",
@@ -4041,18 +4089,6 @@
4041
4089
  "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==",
4042
4090
  "license": "0BSD"
4043
4091
  },
4044
- "node_modules/type-fest": {
4045
- "version": "4.26.1",
4046
- "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-4.26.1.tgz",
4047
- "integrity": "sha512-yOGpmOAL7CkKe/91I5O3gPICmJNLJ1G4zFYVAsRHg7M64biSnPtRj0WNQt++bRkjYOqjWXrhnUw1utzmVErAdg==",
4048
- "license": "(MIT OR CC0-1.0)",
4049
- "engines": {
4050
- "node": ">=16"
4051
- },
4052
- "funding": {
4053
- "url": "https://github.com/sponsors/sindresorhus"
4054
- }
4055
- },
4056
4092
  "node_modules/type-is": {
4057
4093
  "version": "1.6.18",
4058
4094
  "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz",
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "xcuitest",
9
9
  "xctest"
10
10
  ],
11
- "version": "7.31.0",
11
+ "version": "7.32.0",
12
12
  "author": "Appium Contributors",
13
13
  "license": "Apache-2.0",
14
14
  "repository": {