appium-xcuitest-driver 7.21.0 → 7.21.2

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 (54) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/build/lib/commands/context.d.ts.map +1 -1
  3. package/build/lib/commands/context.js +4 -1
  4. package/build/lib/commands/context.js.map +1 -1
  5. package/build/lib/commands/log.d.ts +0 -8
  6. package/build/lib/commands/log.d.ts.map +1 -1
  7. package/build/lib/commands/log.js +7 -15
  8. package/build/lib/commands/log.js.map +1 -1
  9. package/build/lib/commands/types.d.ts +5 -0
  10. package/build/lib/commands/types.d.ts.map +1 -1
  11. package/build/lib/device-log/helpers.d.ts +3 -0
  12. package/build/lib/device-log/helpers.d.ts.map +1 -0
  13. package/build/lib/device-log/helpers.js +11 -0
  14. package/build/lib/device-log/helpers.js.map +1 -0
  15. package/build/lib/device-log/ios-crash-log.d.ts +6 -17
  16. package/build/lib/device-log/ios-crash-log.d.ts.map +1 -1
  17. package/build/lib/device-log/ios-crash-log.js +4 -10
  18. package/build/lib/device-log/ios-crash-log.js.map +1 -1
  19. package/build/lib/device-log/ios-device-log.d.ts +17 -8
  20. package/build/lib/device-log/ios-device-log.d.ts.map +1 -1
  21. package/build/lib/device-log/ios-device-log.js +9 -21
  22. package/build/lib/device-log/ios-device-log.js.map +1 -1
  23. package/build/lib/device-log/ios-log.d.ts +24 -16
  24. package/build/lib/device-log/ios-log.d.ts.map +1 -1
  25. package/build/lib/device-log/ios-log.js +40 -38
  26. package/build/lib/device-log/ios-log.js.map +1 -1
  27. package/build/lib/device-log/ios-performance-log.d.ts +19 -10
  28. package/build/lib/device-log/ios-performance-log.d.ts.map +1 -1
  29. package/build/lib/device-log/ios-performance-log.js +28 -30
  30. package/build/lib/device-log/ios-performance-log.js.map +1 -1
  31. package/build/lib/device-log/ios-simulator-log.d.ts +22 -18
  32. package/build/lib/device-log/ios-simulator-log.d.ts.map +1 -1
  33. package/build/lib/device-log/ios-simulator-log.js +39 -61
  34. package/build/lib/device-log/ios-simulator-log.js.map +1 -1
  35. package/build/lib/device-log/line-consuming-log.d.ts +9 -0
  36. package/build/lib/device-log/line-consuming-log.d.ts.map +1 -0
  37. package/build/lib/device-log/line-consuming-log.js +16 -0
  38. package/build/lib/device-log/line-consuming-log.js.map +1 -0
  39. package/lib/commands/context.js +4 -1
  40. package/lib/commands/log.js +9 -16
  41. package/lib/commands/types.ts +6 -0
  42. package/lib/device-log/helpers.ts +9 -0
  43. package/lib/device-log/ios-crash-log.js +4 -11
  44. package/lib/device-log/ios-device-log.ts +52 -0
  45. package/lib/device-log/ios-log.ts +87 -0
  46. package/lib/device-log/ios-performance-log.ts +61 -0
  47. package/lib/device-log/ios-simulator-log.ts +119 -0
  48. package/lib/device-log/line-consuming-log.ts +16 -0
  49. package/npm-shrinkwrap.json +52 -27
  50. package/package.json +2 -2
  51. package/lib/device-log/ios-device-log.js +0 -54
  52. package/lib/device-log/ios-log.js +0 -65
  53. package/lib/device-log/ios-performance-log.js +0 -57
  54. package/lib/device-log/ios-simulator-log.js +0 -124
@@ -2,57 +2,59 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.IOSLog = void 0;
4
4
  const events_1 = require("events");
5
+ const lru_cache_1 = require("lru-cache");
6
+ const support_1 = require("appium/support");
5
7
  // We keep only the most recent log entries to avoid out of memory error
6
8
  const MAX_LOG_ENTRIES_COUNT = 10000;
7
9
  class IOSLog extends events_1.EventEmitter {
8
- constructor() {
10
+ constructor(opts = {}) {
9
11
  super();
10
- this.logs = [];
11
- this.logIdxSinceLastRequest = -1;
12
- this.maxBufferSize = MAX_LOG_ENTRIES_COUNT;
12
+ this.maxBufferSize = opts.maxBufferSize ?? MAX_LOG_ENTRIES_COUNT;
13
+ this.logs = new lru_cache_1.LRUCache({
14
+ max: this.maxBufferSize,
15
+ });
16
+ this.logIndexSinceLastRequest = null;
17
+ this._log = opts.log ?? support_1.logger.getLogger(this.constructor.name);
13
18
  }
14
- /** @returns {Promise<void>} */
15
- // eslint-disable-next-line require-await
16
- async startCapture() {
17
- throw new Error(`Sub-classes need to implement a 'startCapture' function`);
19
+ get log() {
20
+ return this._log;
18
21
  }
19
- /** @returns {Promise<void>} */
20
- // eslint-disable-next-line require-await
21
- async stopCapture() {
22
- throw new Error(`Sub-classes need to implement a 'stopCapture' function`);
23
- }
24
- /** @returns {boolean} */
25
- get isCapturing() {
26
- throw new Error(`Sub-classes need to implement a 'isCapturing' function`);
27
- }
28
- broadcast(logLine) {
29
- const logObj = {
30
- timestamp: Date.now(),
31
- level: 'ALL',
32
- message: logLine,
33
- };
34
- this.logs.push(logObj);
35
- this.emit('output', logObj);
36
- if (this.logs.length > this.maxBufferSize) {
37
- this.logs.shift();
38
- if (this.logIdxSinceLastRequest > 0) {
39
- --this.logIdxSinceLastRequest;
40
- }
22
+ broadcast(entry) {
23
+ let recentIndex = -1;
24
+ for (const key of this.logs.rkeys()) {
25
+ recentIndex = key;
26
+ break;
27
+ }
28
+ const serializedEntry = this._serializeEntry(entry);
29
+ this.logs.set(++recentIndex, serializedEntry);
30
+ if (this.listenerCount('output')) {
31
+ this.emit('output', this._deserializeEntry(serializedEntry));
41
32
  }
42
33
  }
43
34
  getLogs() {
44
- if (this.logs.length && this.logIdxSinceLastRequest < this.logs.length) {
45
- let result = this.logs;
46
- if (this.logIdxSinceLastRequest > 0) {
47
- result = result.slice(this.logIdxSinceLastRequest);
35
+ const result = [];
36
+ let recentLogIndex = null;
37
+ for (const [index, value] of this.logs.entries()) {
38
+ if (this.logIndexSinceLastRequest && index > this.logIndexSinceLastRequest
39
+ || !this.logIndexSinceLastRequest) {
40
+ recentLogIndex = index;
41
+ result.push(this._deserializeEntry(value));
48
42
  }
49
- this.logIdxSinceLastRequest = this.logs.length;
50
- return result;
51
43
  }
52
- return [];
44
+ if (recentLogIndex !== null) {
45
+ this.logIndexSinceLastRequest = recentLogIndex;
46
+ }
47
+ return result;
53
48
  }
54
49
  getAllLogs() {
55
- return this.logs;
50
+ const result = [];
51
+ for (const value of this.logs.values()) {
52
+ result.push(this._deserializeEntry(value));
53
+ }
54
+ return result;
55
+ }
56
+ _clearEntries() {
57
+ this.logs.clear();
56
58
  }
57
59
  }
58
60
  exports.IOSLog = IOSLog;
@@ -1 +1 @@
1
- {"version":3,"file":"ios-log.js","sourceRoot":"","sources":["../../../lib/device-log/ios-log.js"],"names":[],"mappings":";;;AAAA,mCAAoC;AAEpC,wEAAwE;AACxE,MAAM,qBAAqB,GAAG,KAAK,CAAC;AAEpC,MAAM,MAAO,SAAQ,qBAAY;IAC/B;QACE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC;QACf,IAAI,CAAC,sBAAsB,GAAG,CAAC,CAAC,CAAC;QACjC,IAAI,CAAC,aAAa,GAAG,qBAAqB,CAAC;IAC7C,CAAC;IAED,+BAA+B;IAC/B,yCAAyC;IACzC,KAAK,CAAC,YAAY;QAChB,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC;IAC7E,CAAC;IAED,+BAA+B;IAC/B,yCAAyC;IACzC,KAAK,CAAC,WAAW;QACf,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAC;IAC5E,CAAC;IAED,yBAAyB;IACzB,IAAI,WAAW;QACb,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAC;IAC5E,CAAC;IAED,SAAS,CAAC,OAAO;QACf,MAAM,MAAM,GAAG;YACb,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;YACrB,KAAK,EAAE,KAAK;YACZ,OAAO,EAAE,OAAO;SACjB,CAAC;QACF,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACvB,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAC5B,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;YAC1C,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,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,UAAU;QACR,MAAM,MAAM,GAAe,EAAE,CAAC;QAC9B,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;YACvC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC;QAC7C,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAKS,aAAa;QACrB,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;IACpB,CAAC;CACF;AAtED,wBAsEC;AAED,kBAAe,MAAM,CAAC"}
@@ -1,13 +1,22 @@
1
- export default IOSPerformanceLog;
2
- export class IOSPerformanceLog {
3
- constructor(remoteDebugger: any, maxEvents?: number);
1
+ import { IOSLog } from './ios-log';
2
+ import type { LogEntry } from '../commands/types';
3
+ import type { AppiumLogger } from '@appium/types';
4
+ type PerformanceLogEntry = object;
5
+ export interface IOSPerformanceLogOptions {
4
6
  remoteDebugger: any;
5
- maxEvents: number;
6
- timelineEvents: any[];
7
- startCapture(): Promise<any>;
8
- stopCapture(): Promise<any>;
9
- onTimelineEvent(event: any): void;
10
- getLogs(): Promise<any[]>;
11
- getAllLogs(): Promise<any[]>;
7
+ maxEvents?: number;
8
+ log?: AppiumLogger;
9
+ }
10
+ export declare class IOSPerformanceLog extends IOSLog<PerformanceLogEntry, PerformanceLogEntry> {
11
+ private remoteDebugger;
12
+ private _started;
13
+ constructor(opts: IOSPerformanceLogOptions);
14
+ startCapture(): Promise<void>;
15
+ stopCapture(): Promise<void>;
16
+ get isCapturing(): boolean;
17
+ protected _serializeEntry(value: PerformanceLogEntry): PerformanceLogEntry;
18
+ protected _deserializeEntry(value: PerformanceLogEntry): LogEntry;
19
+ private onTimelineEvent;
12
20
  }
21
+ export default IOSPerformanceLog;
13
22
  //# sourceMappingURL=ios-performance-log.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ios-performance-log.d.ts","sourceRoot":"","sources":["../../../lib/device-log/ios-performance-log.js"],"names":[],"mappings":";AAMA;IACE,qDAKC;IAJC,oBAAoC;IACpC,kBAAgD;IAEhD,sBAAwB;IAG1B,6BAIC;IAED,4BAGC;IAED,kCAWC;IAGD,0BAQC;IAGD,6BAEC;CACF"}
1
+ {"version":3,"file":"ios-performance-log.d.ts","sourceRoot":"","sources":["../../../lib/device-log/ios-performance-log.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAIlD,KAAK,mBAAmB,GAAG,MAAM,CAAC;AAClC,MAAM,WAAW,wBAAwB;IACvC,cAAc,EAAE,GAAG,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,GAAG,CAAC,EAAE,YAAY,CAAC;CACpB;AAED,qBAAa,iBAAkB,SAAQ,MAAM,CAAC,mBAAmB,EAAE,mBAAmB,CAAC;IACrF,OAAO,CAAC,cAAc,CAAM;IAC5B,OAAO,CAAC,QAAQ,CAAU;gBAEd,IAAI,EAAE,wBAAwB;IAS3B,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAQ7B,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;IAO3C,IAAa,WAAW,IAAI,OAAO,CAElC;cAEkB,eAAe,CAAC,KAAK,EAAE,mBAAmB,GAAG,mBAAmB;cAIhE,iBAAiB,CAAC,KAAK,EAAE,mBAAmB,GAAG,QAAQ;IAI1E,OAAO,CAAC,eAAe;CAIxB;AAED,eAAe,iBAAiB,CAAC"}
@@ -4,45 +4,43 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.IOSPerformanceLog = void 0;
7
- const support_1 = require("appium/support");
8
7
  const lodash_1 = __importDefault(require("lodash"));
9
- const log = support_1.logger.getLogger('IOSPerformanceLog');
8
+ const ios_log_1 = require("./ios-log");
10
9
  const MAX_EVENTS = 5000;
11
- class IOSPerformanceLog {
12
- constructor(remoteDebugger, maxEvents = MAX_EVENTS) {
13
- this.remoteDebugger = remoteDebugger;
14
- this.maxEvents = parseInt(String(maxEvents), 10);
15
- this.timelineEvents = [];
10
+ class IOSPerformanceLog extends ios_log_1.IOSLog {
11
+ constructor(opts) {
12
+ super({
13
+ maxBufferSize: opts.maxEvents ?? MAX_EVENTS,
14
+ log: opts.log,
15
+ });
16
+ this.remoteDebugger = opts.remoteDebugger;
17
+ this._started = false;
16
18
  }
17
19
  async startCapture() {
18
- log.debug('Starting performance (Timeline) log capture');
19
- this.timelineEvents = [];
20
- return await this.remoteDebugger.startTimeline(this.onTimelineEvent.bind(this));
20
+ this.log.debug('Starting performance (Timeline) log capture');
21
+ this._clearEntries();
22
+ const result = await this.remoteDebugger.startTimeline(this.onTimelineEvent.bind(this));
23
+ this._started = true;
24
+ return result;
21
25
  }
22
26
  async stopCapture() {
23
- log.debug('Stopping performance (Timeline) log capture');
24
- return await this.remoteDebugger.stopTimeline();
27
+ this.log.debug('Stopping performance (Timeline) log capture');
28
+ const result = await this.remoteDebugger.stopTimeline();
29
+ this._started = false;
30
+ return result;
25
31
  }
26
- onTimelineEvent(event) {
27
- log.debug(`Received Timeline event: ${lodash_1.default.truncate(JSON.stringify(event))}`);
28
- this.timelineEvents.push(event);
29
- // if we have too many, get rid of the oldest log line
30
- if (this.timelineEvents.length > this.maxEvents) {
31
- let removedEvent = this.timelineEvents.shift();
32
- log.warn(`Too many Timeline events, removing earliest: ${lodash_1.default.truncate(JSON.stringify(removedEvent))}`);
33
- }
32
+ get isCapturing() {
33
+ return this._started;
34
+ }
35
+ _serializeEntry(value) {
36
+ return value;
34
37
  }
35
- // eslint-disable-next-line require-await
36
- async getLogs() {
37
- let events = this.timelineEvents;
38
- // flush events
39
- log.debug('Flushing Timeline events');
40
- this.timelineEvents = [];
41
- return events;
38
+ _deserializeEntry(value) {
39
+ return value;
42
40
  }
43
- // eslint-disable-next-line require-await
44
- async getAllLogs() {
45
- return this.getLogs();
41
+ onTimelineEvent(event) {
42
+ this.log.debug(`Received Timeline event: ${lodash_1.default.truncate(JSON.stringify(event))}`);
43
+ this.broadcast(event);
46
44
  }
47
45
  }
48
46
  exports.IOSPerformanceLog = IOSPerformanceLog;
@@ -1 +1 @@
1
- {"version":3,"file":"ios-performance-log.js","sourceRoot":"","sources":["../../../lib/device-log/ios-performance-log.js"],"names":[],"mappings":";;;;;;AAAA,4CAAsC;AACtC,oDAAuB;AAEvB,MAAM,GAAG,GAAG,gBAAM,CAAC,SAAS,CAAC,mBAAmB,CAAC,CAAC;AAClD,MAAM,UAAU,GAAG,IAAI,CAAC;AAExB,MAAM,iBAAiB;IACrB,YAAY,cAAc,EAAE,SAAS,GAAG,UAAU;QAChD,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,EAAE,CAAC,CAAC;QAEjD,IAAI,CAAC,cAAc,GAAG,EAAE,CAAC;IAC3B,CAAC;IAED,KAAK,CAAC,YAAY;QAChB,GAAG,CAAC,KAAK,CAAC,6CAA6C,CAAC,CAAC;QACzD,IAAI,CAAC,cAAc,GAAG,EAAE,CAAC;QACzB,OAAO,MAAM,IAAI,CAAC,cAAc,CAAC,aAAa,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAClF,CAAC;IAED,KAAK,CAAC,WAAW;QACf,GAAG,CAAC,KAAK,CAAC,6CAA6C,CAAC,CAAC;QACzD,OAAO,MAAM,IAAI,CAAC,cAAc,CAAC,YAAY,EAAE,CAAC;IAClD,CAAC;IAED,eAAe,CAAC,KAAK;QACnB,GAAG,CAAC,KAAK,CAAC,4BAA4B,gBAAC,CAAC,QAAQ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C;IACxB,CAAC;IAEQ,KAAK,CAAC,YAAY;QACzB,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,6CAA6C,CAAC,CAAC;QAC9D,IAAI,CAAC,aAAa,EAAE,CAAC;QACrB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,aAAa,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QACxF,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACrB,OAAO,MAAM,CAAC;IAChB,CAAC;IAEQ,KAAK,CAAC,WAAW;QACxB,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,6CAA6C,CAAC,CAAC;QAC9D,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,YAAY,EAAE,CAAC;QACxD,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;QACtB,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,IAAa,WAAW;QACtB,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAEkB,eAAe,CAAC,KAA0B;QAC3D,OAAO,KAAK,CAAC;IACf,CAAC;IAEkB,iBAAiB,CAAC,KAA0B;QAC7D,OAAO,KAAiB,CAAC;IAC3B,CAAC;IAEO,eAAe,CAAC,KAA0B;QAChD,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,4BAA4B,gBAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;QAChF,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACxB,CAAC;CACF;AA5CD,8CA4CC;AAED,kBAAe,iBAAiB,CAAC"}
@@ -1,20 +1,24 @@
1
- export default IOSSimulatorLog;
2
- export class IOSSimulatorLog extends IOSLog {
3
- constructor({ sim, showLogs, xcodeVersion, iosSimulatorLogsPredicate }: {
4
- sim: any;
5
- showLogs: any;
6
- xcodeVersion: any;
7
- iosSimulatorLogsPredicate: any;
8
- });
9
- sim: any;
10
- showLogs: boolean;
11
- xcodeVersion: any;
12
- predicate: any;
13
- proc: any;
14
- finishStartingLogCapture(): Promise<void>;
15
- killLogSubProcess(): Promise<void>;
16
- get isCapturing(): any;
17
- onOutput(logRow: any, prefix?: string): void;
1
+ import { LineConsumingLog } from './line-consuming-log';
2
+ import type { Simulator } from 'appium-ios-simulator';
3
+ import type { AppiumLogger } from '@appium/types';
4
+ export interface IOSSimulatorLogOptions {
5
+ sim: Simulator;
6
+ showLogs?: boolean;
7
+ iosSimulatorLogsPredicate?: string;
8
+ log?: AppiumLogger;
9
+ }
10
+ export declare class IOSSimulatorLog extends LineConsumingLog {
11
+ private sim;
12
+ private showLogs;
13
+ private predicate?;
14
+ private proc;
15
+ constructor(opts: IOSSimulatorLogOptions);
16
+ startCapture(): Promise<void>;
17
+ stopCapture(): Promise<void>;
18
+ get isCapturing(): boolean;
19
+ private onOutput;
20
+ private killLogSubProcess;
21
+ private finishStartingLogCapture;
18
22
  }
19
- import { IOSLog } from './ios-log';
23
+ export default IOSSimulatorLog;
20
24
  //# sourceMappingURL=ios-simulator-log.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ios-simulator-log.d.ts","sourceRoot":"","sources":["../../../lib/device-log/ios-simulator-log.js"],"names":[],"mappings":";AASA;IACE;;;;;OAOC;IALC,SAAc;IACd,kBAA0B;IAC1B,kBAAgC;IAChC,eAA0C;IAC1C,UAAgB;IA8BlB,0CAiCC;IAUD,mCAcC;IAED,uBAEC;IAED,6CAUC;CACF;uBAvHoB,WAAW"}
1
+ {"version":3,"file":"ios-simulator-log.d.ts","sourceRoot":"","sources":["../../../lib/device-log/ios-simulator-log.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAMlD,MAAM,WAAW,sBAAsB;IACrC,GAAG,EAAE,SAAS,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,yBAAyB,CAAC,EAAE,MAAM,CAAC;IACnC,GAAG,CAAC,EAAE,YAAY,CAAC;CACpB;AAED,qBAAa,eAAgB,SAAQ,gBAAgB;IACnD,OAAO,CAAC,GAAG,CAAY;IACvB,OAAO,CAAC,QAAQ,CAAU;IAC1B,OAAO,CAAC,SAAS,CAAC,CAAS;IAC3B,OAAO,CAAC,IAAI,CAAoB;gBAEpB,IAAI,EAAE,sBAAsB;IAQzB,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IA2B7B,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;IAQ3C,IAAa,WAAW,IAAI,OAAO,CAElC;IAED,OAAO,CAAC,QAAQ;YAQF,iBAAiB;YAiBjB,wBAAwB;CAqBvC;AAED,eAAe,eAAe,CAAC"}
@@ -5,18 +5,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.IOSSimulatorLog = void 0;
7
7
  const lodash_1 = __importDefault(require("lodash"));
8
- const ios_log_1 = require("./ios-log");
9
- const support_1 = require("appium/support");
10
8
  const teen_process_1 = require("teen_process");
11
- const log = support_1.logger.getLogger('IOSSimulatorLog');
9
+ const line_consuming_log_1 = require("./line-consuming-log");
10
+ const EXECVP_ERROR_PATTERN = /execvp\(\)/;
12
11
  const START_TIMEOUT = 10000;
13
- class IOSSimulatorLog extends ios_log_1.IOSLog {
14
- constructor({ sim, showLogs, xcodeVersion, iosSimulatorLogsPredicate }) {
15
- super();
16
- this.sim = sim;
17
- this.showLogs = !!showLogs;
18
- this.xcodeVersion = xcodeVersion;
19
- this.predicate = iosSimulatorLogsPredicate;
12
+ class IOSSimulatorLog extends line_consuming_log_1.LineConsumingLog {
13
+ constructor(opts) {
14
+ super({ log: opts.log });
15
+ this.sim = opts.sim;
16
+ this.showLogs = !!opts.showLogs;
17
+ this.predicate = opts.iosSimulatorLogsPredicate;
20
18
  this.proc = null;
21
19
  }
22
20
  async startCapture() {
@@ -30,7 +28,7 @@ class IOSSimulatorLog extends ios_log_1.IOSLog {
30
28
  if (this.predicate) {
31
29
  spawnArgs.push('--predicate', this.predicate);
32
30
  }
33
- log.debug(`Starting log capture for iOS Simulator with udid '${this.sim.udid}' ` + `using simctl`);
31
+ this.log.debug(`Starting log capture for iOS Simulator with udid '${this.sim.udid}' ` + `using simctl`);
34
32
  try {
35
33
  // cleanup existing listeners if the previous session has not been terminated properly
36
34
  await (0, teen_process_1.exec)('pkill', ['-f', [this.sim.udid, ...spawnArgs].join(' ')]);
@@ -44,40 +42,6 @@ class IOSSimulatorLog extends ios_log_1.IOSLog {
44
42
  throw new Error(`Simulator log capture failed. Original error: ${e.message}`);
45
43
  }
46
44
  }
47
- async finishStartingLogCapture() {
48
- if (!this.proc) {
49
- log.errorAndThrow('Could not capture simulator log');
50
- }
51
- let firstLine = true;
52
- let logRow = '';
53
- this.proc.on('output', (stdout, stderr) => {
54
- if (stdout) {
55
- if (firstLine) {
56
- if (stdout.endsWith('\n')) {
57
- // don't store the first line of the log because it came before the sim was launched
58
- firstLine = false;
59
- }
60
- }
61
- else {
62
- logRow += stdout;
63
- if (stdout.endsWith('\n')) {
64
- this.onOutput(logRow);
65
- logRow = '';
66
- }
67
- }
68
- }
69
- if (stderr) {
70
- this.onOutput(logRow, 'STDERR');
71
- }
72
- });
73
- let sd = (stdout, stderr) => {
74
- if (/execvp\(\)/.test(stderr)) {
75
- throw new Error('iOS log capture process failed to start');
76
- }
77
- return stdout || stderr;
78
- };
79
- await this.proc.start(sd, START_TIMEOUT);
80
- }
81
45
  async stopCapture() {
82
46
  if (!this.proc) {
83
47
  return;
@@ -85,11 +49,21 @@ class IOSSimulatorLog extends ios_log_1.IOSLog {
85
49
  await this.killLogSubProcess();
86
50
  this.proc = null;
87
51
  }
52
+ get isCapturing() {
53
+ return Boolean(this.proc && this.proc.isRunning);
54
+ }
55
+ onOutput(logRow, prefix = '') {
56
+ this.broadcast(logRow);
57
+ if (this.showLogs) {
58
+ const space = prefix.length > 0 ? ' ' : '';
59
+ this.log.info(`[IOS_SYSLOG_ROW${space}${prefix}] ${logRow}`);
60
+ }
61
+ }
88
62
  async killLogSubProcess() {
89
- if (!this.proc.isRunning) {
63
+ if (!this.proc?.isRunning) {
90
64
  return;
91
65
  }
92
- log.debug('Stopping iOS log capture');
66
+ this.log.debug('Stopping iOS log capture');
93
67
  try {
94
68
  await this.proc.stop('SIGTERM', 1000);
95
69
  }
@@ -97,24 +71,28 @@ class IOSSimulatorLog extends ios_log_1.IOSLog {
97
71
  if (!this.proc.isRunning) {
98
72
  return;
99
73
  }
100
- log.warn('Cannot stop log capture process. Sending SIGKILL');
74
+ this.log.warn('Cannot stop log capture process. Sending SIGKILL');
101
75
  await this.proc.stop('SIGKILL');
102
76
  }
103
77
  }
104
- get isCapturing() {
105
- return this.proc && this.proc.isRunning;
106
- }
107
- onOutput(logRow, prefix = '') {
108
- const logs = lodash_1.default.cloneDeep(logRow.split('\n'));
109
- for (const logLine of logs) {
110
- if (!logLine)
111
- continue; // eslint-disable-line curly
112
- this.broadcast(logLine);
113
- if (this.showLogs) {
114
- const space = prefix.length > 0 ? ' ' : '';
115
- log.info(`[IOS_SYSLOG_ROW${space}${prefix}] ${logLine}`);
116
- }
78
+ async finishStartingLogCapture() {
79
+ if (!this.proc) {
80
+ throw this.log.errorWithException('Could not capture simulator log');
81
+ }
82
+ for (const streamName of ['stdout', 'stderr']) {
83
+ this.proc.on(`lines-${streamName}`, (/** @type {string[]} */ lines) => {
84
+ for (const line of lines) {
85
+ this.onOutput(line, ...(streamName === 'stderr' ? ['STDERR'] : []));
86
+ }
87
+ });
117
88
  }
89
+ const startDetector = (/** @type {string} */ stdout, /** @type {string} */ stderr) => {
90
+ if (EXECVP_ERROR_PATTERN.test(stderr)) {
91
+ throw new Error('iOS log capture process failed to start');
92
+ }
93
+ return stdout || stderr;
94
+ };
95
+ await this.proc.start(startDetector, START_TIMEOUT);
118
96
  }
119
97
  }
120
98
  exports.IOSSimulatorLog = IOSSimulatorLog;
@@ -1 +1 @@
1
- {"version":3,"file":"ios-simulator-log.js","sourceRoot":"","sources":["../../../lib/device-log/ios-simulator-log.js"],"names":[],"mappings":";;;;;;AAAA,oDAAuB;AACvB,uCAAiC;AACjC,4CAAsC;AACtC,+CAAkC;AAElC,MAAM,GAAG,GAAG,gBAAM,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC;AAEhD,MAAM,aAAa,GAAG,KAAK,CAAC;AAE5B,MAAM,eAAgB,SAAQ,gBAAM;IAClC,YAAY,EAAC,GAAG,EAAE,QAAQ,EAAE,YAAY,EAAE,yBAAyB,EAAC;QAClE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC,QAAQ,CAAC;QAC3B,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,SAAS,GAAG,yBAAyB,CAAC;QAC3C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED,KAAK,CAAC,YAAY;QAChB,IAAI,gBAAC,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YACjC,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;QACrD,CAAC;QAED,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC,EAAE,CAAC;YAClC,MAAM,IAAI,KAAK,CAAC,4BAA4B,IAAI,CAAC,GAAG,CAAC,IAAI,kBAAkB,CAAC,CAAC;QAC/E,CAAC;QACD,MAAM,SAAS,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;QAC1D,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC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
1
+ import { IOSLog } from './ios-log';
2
+ import type { LogEntry } from '../commands/types';
3
+ type TSerializedEntry = [string, number];
4
+ export declare abstract class LineConsumingLog extends IOSLog<string, TSerializedEntry> {
5
+ protected _serializeEntry(value: string): TSerializedEntry;
6
+ protected _deserializeEntry(value: TSerializedEntry): LogEntry;
7
+ }
8
+ export {};
9
+ //# sourceMappingURL=line-consuming-log.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"line-consuming-log.d.ts","sourceRoot":"","sources":["../../../lib/device-log/line-consuming-log.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,WAAW,CAAC;AAEjC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAElD,KAAK,gBAAgB,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAEzC,8BAAsB,gBAAiB,SAAQ,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC;cAC1D,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,gBAAgB;cAIhD,iBAAiB,CAAC,KAAK,EAAE,gBAAgB,GAAG,QAAQ;CAIxE"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LineConsumingLog = void 0;
4
+ const ios_log_1 = require("./ios-log");
5
+ const helpers_1 = require("./helpers");
6
+ class LineConsumingLog extends ios_log_1.IOSLog {
7
+ _serializeEntry(value) {
8
+ return [value, Date.now()];
9
+ }
10
+ _deserializeEntry(value) {
11
+ const [message, timestamp] = value;
12
+ return (0, helpers_1.toLogEntry)(message, timestamp);
13
+ }
14
+ }
15
+ exports.LineConsumingLog = LineConsumingLog;
16
+ //# sourceMappingURL=line-consuming-log.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"line-consuming-log.js","sourceRoot":"","sources":["../../../lib/device-log/line-consuming-log.ts"],"names":[],"mappings":";;;AAAA,uCAAiC;AACjC,uCAAuC;AAKvC,MAAsB,gBAAiB,SAAQ,gBAAgC;IAC1D,eAAe,CAAC,KAAa;QAC9C,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;IAC7B,CAAC;IAEkB,iBAAiB,CAAC,KAAuB;QAC1D,MAAM,CAAC,OAAO,EAAE,SAAS,CAAC,GAAG,KAAK,CAAC;QACnC,OAAO,IAAA,oBAAU,EAAC,OAAO,EAAE,SAAS,CAAC,CAAC;IACxC,CAAC;CACF;AATD,4CASC"}
@@ -558,7 +558,10 @@ const commands = {
558
558
  // attempt to start performance logging, if requested
559
559
  if (this.opts.enablePerformanceLogging && this.remote) {
560
560
  this.log.debug(`Starting performance log on '${this.curContext}'`);
561
- this.logs.performance = new IOSPerformanceLog(this.remote);
561
+ this.logs.performance = new IOSPerformanceLog({
562
+ remoteDebugger: this.remote,
563
+ log: this.log,
564
+ });
562
565
  await this.logs.performance.startCapture();
563
566
  }
564
567
 
@@ -8,6 +8,7 @@ import log from '../logger';
8
8
  import WebSocket from 'ws';
9
9
  import SafariConsoleLog from '../device-log/safari-console-log';
10
10
  import SafariNetworkLog from '../device-log/safari-network-log';
11
+ import { toLogEntry } from '../device-log/helpers';
11
12
 
12
13
  /**
13
14
  * Determines the websocket endpoint based on the `sessionId`
@@ -47,27 +48,18 @@ const SUPPORTED_LOG_TYPES = {
47
48
  server: {
48
49
  description: 'Appium server logs',
49
50
  /**
50
- * @returns {AppiumServerLogEntry[]}
51
+ * @returns {import('./types').LogEntry[]}
51
52
  */
52
53
  getter: (self) => {
53
54
  self.assertFeatureEnabled(GET_SERVER_LOGS_FEATURE);
54
- return log.unwrap().record.map((x) => ({
55
- timestamp: /** @type {any} */ (x).timestamp ?? Date.now(),
56
- level: 'ALL',
57
- message: _.isEmpty(x.prefix) ? x.message : `[${x.prefix}] ${x.message}`,
58
- }));
55
+ return log.unwrap().record.map((x) => toLogEntry(
56
+ _.isEmpty(x.prefix) ? x.message : `[${x.prefix}] ${x.message}`,
57
+ /** @type {any} */ (x).timestamp ?? Date.now()
58
+ ));
59
59
  },
60
60
  },
61
61
  };
62
62
 
63
- /**
64
- * Log entry in the array returned by `getLogs('server')`
65
- * @typedef AppiumServerLogEntry
66
- * @property {number} timestamp
67
- * @property {'ALL'} level
68
- * @property {string} message
69
- */
70
-
71
63
  export default {
72
64
  supportedLogTypes: SUPPORTED_LOG_TYPES,
73
65
  /**
@@ -111,13 +103,14 @@ export default {
111
103
  this.logs.syslog = new IOSDeviceLog({
112
104
  udid: this.opts.udid,
113
105
  showLogs: this.opts.showIOSLog,
106
+ log: this.log,
114
107
  });
115
108
  } else {
116
109
  this.logs.syslog = new IOSSimulatorLog({
117
- sim: this.device,
110
+ sim: /** @type {import('appium-ios-simulator').Simulator} */ (this.device),
118
111
  showLogs: this.opts.showIOSLog,
119
- xcodeVersion: this.xcodeVersion,
120
112
  iosSimulatorLogsPredicate: this.opts.iosSimulatorLogsPredicate,
113
+ log: this.log,
121
114
  });
122
115
  }
123
116
  this.logs.safariConsole = new SafariConsoleLog(!!this.opts.showSafariConsoleLog);
@@ -566,3 +566,9 @@ export interface KeyboardKey {
566
566
  */
567
567
  modifierFlags?: number;
568
568
  }
569
+
570
+ export interface LogEntry {
571
+ timestamp: number;
572
+ level: string,
573
+ message: string;
574
+ }
@@ -0,0 +1,9 @@
1
+ import type { LogEntry } from '../commands/types';
2
+
3
+ export function toLogEntry(message: string, timestamp: number): LogEntry {
4
+ return {
5
+ timestamp,
6
+ level: 'ALL',
7
+ message,
8
+ };
9
+ }