appium-remote-debugger 15.3.3 → 15.3.5

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 (86) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/build/lib/atoms.d.ts.map +1 -1
  3. package/build/lib/atoms.js +2 -2
  4. package/build/lib/atoms.js.map +1 -1
  5. package/build/lib/index.d.ts +2 -1
  6. package/build/lib/index.d.ts.map +1 -1
  7. package/build/lib/index.js +0 -1
  8. package/build/lib/index.js.map +1 -1
  9. package/build/lib/logger.js.map +1 -1
  10. package/build/lib/mixins/connect.d.ts.map +1 -1
  11. package/build/lib/mixins/connect.js +11 -8
  12. package/build/lib/mixins/connect.js.map +1 -1
  13. package/build/lib/mixins/cookies.d.ts.map +1 -1
  14. package/build/lib/mixins/cookies.js.map +1 -1
  15. package/build/lib/mixins/events.d.ts.map +1 -1
  16. package/build/lib/mixins/events.js +1 -1
  17. package/build/lib/mixins/events.js.map +1 -1
  18. package/build/lib/mixins/execute.d.ts.map +1 -1
  19. package/build/lib/mixins/execute.js +2 -2
  20. package/build/lib/mixins/execute.js.map +1 -1
  21. package/build/lib/mixins/message-handlers.d.ts.map +1 -1
  22. package/build/lib/mixins/message-handlers.js.map +1 -1
  23. package/build/lib/mixins/misc.d.ts.map +1 -1
  24. package/build/lib/mixins/misc.js +1 -1
  25. package/build/lib/mixins/misc.js.map +1 -1
  26. package/build/lib/mixins/navigate.d.ts.map +1 -1
  27. package/build/lib/mixins/navigate.js +2 -3
  28. package/build/lib/mixins/navigate.js.map +1 -1
  29. package/build/lib/mixins/property-accessors.d.ts +20 -20
  30. package/build/lib/mixins/property-accessors.d.ts.map +1 -1
  31. package/build/lib/mixins/property-accessors.js.map +1 -1
  32. package/build/lib/mixins/screenshot.d.ts.map +1 -1
  33. package/build/lib/mixins/screenshot.js +5 -1
  34. package/build/lib/mixins/screenshot.js.map +1 -1
  35. package/build/lib/protocol/index.d.ts.map +1 -1
  36. package/build/lib/protocol/index.js +2 -3
  37. package/build/lib/protocol/index.js.map +1 -1
  38. package/build/lib/remote-debugger-real-device.d.ts.map +1 -1
  39. package/build/lib/remote-debugger-real-device.js.map +1 -1
  40. package/build/lib/remote-debugger.d.ts.map +1 -1
  41. package/build/lib/remote-debugger.js +3 -1
  42. package/build/lib/remote-debugger.js.map +1 -1
  43. package/build/lib/rpc/index.d.ts.map +1 -1
  44. package/build/lib/rpc/index.js.map +1 -1
  45. package/build/lib/rpc/remote-messages.d.ts.map +1 -1
  46. package/build/lib/rpc/remote-messages.js +16 -15
  47. package/build/lib/rpc/remote-messages.js.map +1 -1
  48. package/build/lib/rpc/rpc-client-real-device.d.ts.map +1 -1
  49. package/build/lib/rpc/rpc-client-real-device.js.map +1 -1
  50. package/build/lib/rpc/rpc-client-simulator.d.ts.map +1 -1
  51. package/build/lib/rpc/rpc-client-simulator.js +3 -4
  52. package/build/lib/rpc/rpc-client-simulator.js.map +1 -1
  53. package/build/lib/rpc/rpc-client.d.ts.map +1 -1
  54. package/build/lib/rpc/rpc-client.js +6 -6
  55. package/build/lib/rpc/rpc-client.js.map +1 -1
  56. package/build/lib/rpc/rpc-message-handler.d.ts.map +1 -1
  57. package/build/lib/rpc/rpc-message-handler.js +3 -4
  58. package/build/lib/rpc/rpc-message-handler.js.map +1 -1
  59. package/build/lib/types.d.ts.map +1 -1
  60. package/build/lib/utils.d.ts.map +1 -1
  61. package/build/lib/utils.js +6 -5
  62. package/build/lib/utils.js.map +1 -1
  63. package/lib/atoms.ts +8 -6
  64. package/lib/index.ts +18 -11
  65. package/lib/logger.ts +1 -1
  66. package/lib/mixins/connect.ts +63 -47
  67. package/lib/mixins/cookies.ts +5 -11
  68. package/lib/mixins/events.ts +8 -19
  69. package/lib/mixins/execute.ts +43 -35
  70. package/lib/mixins/message-handlers.ts +21 -20
  71. package/lib/mixins/misc.ts +12 -15
  72. package/lib/mixins/navigate.ts +68 -61
  73. package/lib/mixins/property-accessors.ts +48 -23
  74. package/lib/mixins/screenshot.ts +10 -11
  75. package/lib/protocol/index.ts +11 -9
  76. package/lib/remote-debugger-real-device.ts +5 -5
  77. package/lib/remote-debugger.ts +22 -28
  78. package/lib/rpc/index.ts +2 -2
  79. package/lib/rpc/remote-messages.ts +48 -48
  80. package/lib/rpc/rpc-client-real-device.ts +4 -4
  81. package/lib/rpc/rpc-client-simulator.ts +23 -20
  82. package/lib/rpc/rpc-client.ts +161 -108
  83. package/lib/rpc/rpc-message-handler.ts +34 -24
  84. package/lib/types.ts +3 -3
  85. package/lib/utils.ts +24 -17
  86. package/package.json +3 -1
@@ -1,8 +1,8 @@
1
- import { EventEmitter } from 'node:events';
2
- import { log } from '../logger';
1
+ import {EventEmitter} from 'node:events';
2
+ import {log} from '../logger';
3
3
  import _ from 'lodash';
4
- import { util } from '@appium/support';
5
- import type { StringRecord } from '@appium/types';
4
+ import {util} from '@appium/support';
5
+ import type {StringRecord} from '@appium/types';
6
6
 
7
7
  /**
8
8
  * Represents a data message from the Web Inspector.
@@ -46,24 +46,27 @@ export default class RpcMessageHandler extends EventEmitter {
46
46
  const argument = plist.__argument;
47
47
  switch (selector) {
48
48
  case '_rpc_reportSetup:':
49
- this.emit('_rpc_reportSetup:',
49
+ this.emit(
50
+ '_rpc_reportSetup:',
50
51
  null,
51
52
  argument.WIRSimulatorNameKey,
52
53
  argument.WIRSimulatorBuildKey,
53
- argument.WIRSimulatorProductVersionKey
54
+ argument.WIRSimulatorProductVersionKey,
54
55
  );
55
56
  break;
56
57
  case '_rpc_reportConnectedApplicationList:':
57
- this.emit('_rpc_reportConnectedApplicationList:',
58
+ this.emit(
59
+ '_rpc_reportConnectedApplicationList:',
58
60
  null,
59
- argument.WIRApplicationDictionaryKey
61
+ argument.WIRApplicationDictionaryKey,
60
62
  );
61
63
  break;
62
64
  case '_rpc_applicationSentListing:':
63
- this.emit('_rpc_forwardGetListing:',
65
+ this.emit(
66
+ '_rpc_forwardGetListing:',
64
67
  null,
65
68
  argument.WIRApplicationIdentifierKey,
66
- argument.WIRListingKey
69
+ argument.WIRListingKey,
67
70
  );
68
71
  break;
69
72
  case '_rpc_applicationConnected:':
@@ -85,8 +88,9 @@ export default class RpcMessageHandler extends EventEmitter {
85
88
  await this.handleDataMessage(plist);
86
89
  break;
87
90
  default:
88
- log.debug(`Debugger got a message for '${selector}' and have no ` +
89
- `handler, doing nothing.`);
91
+ log.debug(
92
+ `Debugger got a message for '${selector}' and have no ` + `handler, doing nothing.`,
93
+ );
90
94
  }
91
95
  }
92
96
 
@@ -124,7 +128,7 @@ export default class RpcMessageHandler extends EventEmitter {
124
128
  method: string | undefined,
125
129
  params: StringRecord | undefined,
126
130
  result: any,
127
- error: Error | undefined
131
+ error: Error | undefined,
128
132
  ): Promise<void> {
129
133
  if (msgId) {
130
134
  if (this.listenerCount(msgId)) {
@@ -133,10 +137,12 @@ export default class RpcMessageHandler extends EventEmitter {
133
137
  }
134
138
  this.emit(msgId, error, result);
135
139
  } else {
136
- log.error(`Web Inspector returned data for message '${msgId}' ` +
137
- `but we were not waiting for that message! ` +
138
- `result: '${JSON.stringify(result)}'; ` +
139
- `error: '${JSON.stringify(error)}'`);
140
+ log.error(
141
+ `Web Inspector returned data for message '${msgId}' ` +
142
+ `but we were not waiting for that message! ` +
143
+ `result: '${JSON.stringify(result)}'; ` +
144
+ `error: '${JSON.stringify(error)}'`,
145
+ );
140
146
  }
141
147
  return;
142
148
  }
@@ -200,9 +206,10 @@ export default class RpcMessageHandler extends EventEmitter {
200
206
  const parseError = (): Error | undefined => {
201
207
  const defaultMessage = 'Error occurred in handling data message';
202
208
  if (result?.wasThrown) {
203
- const message = (result?.result?.value || result?.result?.description)
204
- ? (result?.result?.value || result?.result?.description)
205
- : (dataKey.error ?? defaultMessage);
209
+ const message =
210
+ result?.result?.value || result?.result?.description
211
+ ? result?.result?.value || result?.result?.description
212
+ : (dataKey.error ?? defaultMessage);
206
213
  return new Error(message);
207
214
  }
208
215
  if (dataKey.error) {
@@ -224,9 +231,10 @@ export default class RpcMessageHandler extends EventEmitter {
224
231
  case 'Target.targetDestroyed':
225
232
  case 'Target.didCommitProvisionalTarget': {
226
233
  const app = plist.__argument.WIRApplicationIdentifierKey;
227
- const args = method === 'Target.didCommitProvisionalTarget'
228
- ? params
229
- : (params.targetInfo ?? {targetId: params.targetId});
234
+ const args =
235
+ method === 'Target.didCommitProvisionalTarget'
236
+ ? params
237
+ : (params.targetInfo ?? {targetId: params.targetId});
230
238
  this.emit(method, null, app, args);
231
239
  return;
232
240
  }
@@ -241,7 +249,9 @@ export default class RpcMessageHandler extends EventEmitter {
241
249
  } catch (err: any) {
242
250
  // if this happens then some aspect of the protocol is missing to us
243
251
  // so print the entire message to get visibility into what is going on
244
- log.error(`Unexpected message format from Web Inspector: ${util.jsonStringify(plist, null)}`);
252
+ log.error(
253
+ `Unexpected message format from Web Inspector: ${util.jsonStringify(plist, null)}`,
254
+ );
245
255
  throw err;
246
256
  }
247
257
  }
package/lib/types.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { StringRecord, AppiumLogger } from '@appium/types';
1
+ import type {StringRecord, AppiumLogger} from '@appium/types';
2
2
 
3
3
  export interface AppInfo {
4
4
  id: string;
@@ -77,7 +77,8 @@ interface RemoteDebuggerRealDeviceSpecificOptions {
77
77
  udid: string;
78
78
  }
79
79
 
80
- export type RemoteDebuggerRealDeviceOptions = RemoteDebuggerRealDeviceSpecificOptions & RemoteDebuggerOptions;
80
+ export type RemoteDebuggerRealDeviceOptions = RemoteDebuggerRealDeviceSpecificOptions &
81
+ RemoteDebuggerOptions;
81
82
 
82
83
  /**
83
84
  * Options for configuring an RpcClient instance.
@@ -154,7 +155,6 @@ interface RemoteCommandTemplated<T extends SocketDataKey> {
154
155
  export type RawRemoteCommand = RemoteCommandTemplated<StringRecord>;
155
156
  export type RemoteCommand = RemoteCommandTemplated<Buffer>;
156
157
 
157
-
158
158
  /**
159
159
  * Target types.
160
160
  * 'frame' was added since iOS 26.2 beta.
package/lib/utils.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  import _ from 'lodash';
2
- import { errorFromMJSONWPStatusCode } from '@appium/base-driver';
3
- import { util, node } from '@appium/support';
2
+ import {errorFromMJSONWPStatusCode} from '@appium/base-driver';
3
+ import {util, node} from '@appium/support';
4
4
  import nodeFs from 'node:fs';
5
5
  import path from 'node:path';
6
- import type { StringRecord } from '@appium/types';
7
- import type { AppInfo, AppDict, Page } from './types';
6
+ import type {StringRecord} from '@appium/types';
7
+ import type {AppInfo, AppDict, Page} from './types';
8
8
 
9
9
  const MODULE_NAME = 'appium-remote-debugger';
10
10
  export const WEB_CONTENT_BUNDLE_ID = 'com.apple.WebKit.WebContent';
@@ -35,9 +35,10 @@ export function appInfoFromDict(dict: Record<string, any>): [string, AppInfo] {
35
35
  let isAutomationEnabled: boolean | string = !!dict.WIRRemoteAutomationEnabledKey;
36
36
  if (_.has(dict, 'WIRAutomationAvailabilityKey')) {
37
37
  if (_.isString(dict.WIRAutomationAvailabilityKey)) {
38
- isAutomationEnabled = dict.WIRAutomationAvailabilityKey === 'WIRAutomationAvailabilityUnknown'
39
- ? 'Unknown'
40
- : dict.WIRAutomationAvailabilityKey === 'WIRAutomationAvailabilityAvailable';
38
+ isAutomationEnabled =
39
+ dict.WIRAutomationAvailabilityKey === 'WIRAutomationAvailabilityUnknown'
40
+ ? 'Unknown'
41
+ : dict.WIRAutomationAvailabilityKey === 'WIRAutomationAvailabilityAvailable';
41
42
  } else {
42
43
  isAutomationEnabled = !!dict.WIRAutomationAvailabilityKey;
43
44
  }
@@ -63,15 +64,19 @@ export function appInfoFromDict(dict: Record<string, any>): [string, AppInfo] {
63
64
  * @returns An array of Page objects representing the available pages.
64
65
  */
65
66
  export function pageArrayFromDict(pageDict: StringRecord): Page[] {
66
- return _.values(pageDict)
67
- // count only WIRTypeWeb pages and ignore all others (WIRTypeJavaScript etc)
68
- .filter((dict) => _.isUndefined(dict.WIRTypeKey) || ACCEPTED_PAGE_TYPES.includes(dict.WIRTypeKey))
69
- .map((dict) => ({
70
- id: dict.WIRPageIdentifierKey,
71
- title: dict.WIRTitleKey,
72
- url: dict.WIRURLKey,
73
- isKey: !_.isUndefined(dict.WIRConnectionIdentifierKey),
74
- }));
67
+ return (
68
+ _.values(pageDict)
69
+ // count only WIRTypeWeb pages and ignore all others (WIRTypeJavaScript etc)
70
+ .filter(
71
+ (dict) => _.isUndefined(dict.WIRTypeKey) || ACCEPTED_PAGE_TYPES.includes(dict.WIRTypeKey),
72
+ )
73
+ .map((dict) => ({
74
+ id: dict.WIRPageIdentifierKey,
75
+ title: dict.WIRTitleKey,
76
+ url: dict.WIRURLKey,
77
+ isKey: !_.isUndefined(dict.WIRConnectionIdentifierKey),
78
+ }))
79
+ );
75
80
  }
76
81
 
77
82
  /**
@@ -145,7 +150,9 @@ export function simpleStringify(value: any, multiline: boolean = false): string
145
150
  */
146
151
  export function convertJavascriptEvaluationResult(res: any): any {
147
152
  if (_.isUndefined(res)) {
148
- throw new Error(`Did not get OK result from remote debugger. Result was: ${_.truncate(simpleStringify(res), {length: RESPONSE_LOG_LENGTH})}`);
153
+ throw new Error(
154
+ `Did not get OK result from remote debugger. Result was: ${_.truncate(simpleStringify(res), {length: RESPONSE_LOG_LENGTH})}`,
155
+ );
149
156
  } else if (_.isString(res)) {
150
157
  try {
151
158
  res = JSON.parse(res);
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "keywords": [
5
5
  "appium"
6
6
  ],
7
- "version": "15.3.3",
7
+ "version": "15.3.5",
8
8
  "author": "Appium Contributors",
9
9
  "license": "Apache-2.0",
10
10
  "repository": {
@@ -49,6 +49,8 @@
49
49
  "dev": "npm run build -- --watch",
50
50
  "lint": "eslint .",
51
51
  "lint:fix": "npm run lint -- --fix",
52
+ "format": "prettier -w ./lib ./test",
53
+ "format:check": "prettier --check ./lib ./test",
52
54
  "prepare": "npm run build",
53
55
  "test": "mocha --exit --timeout 1m \"./test/unit/**/*-specs.ts\"",
54
56
  "e2e-test": "mocha --exit --timeout 1m \"./test/functional/**/*-specs.ts\"",