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.
- package/CHANGELOG.md +12 -0
- package/build/lib/atoms.d.ts.map +1 -1
- package/build/lib/atoms.js +2 -2
- package/build/lib/atoms.js.map +1 -1
- package/build/lib/index.d.ts +2 -1
- package/build/lib/index.d.ts.map +1 -1
- package/build/lib/index.js +0 -1
- package/build/lib/index.js.map +1 -1
- package/build/lib/logger.js.map +1 -1
- package/build/lib/mixins/connect.d.ts.map +1 -1
- package/build/lib/mixins/connect.js +11 -8
- package/build/lib/mixins/connect.js.map +1 -1
- package/build/lib/mixins/cookies.d.ts.map +1 -1
- package/build/lib/mixins/cookies.js.map +1 -1
- package/build/lib/mixins/events.d.ts.map +1 -1
- package/build/lib/mixins/events.js +1 -1
- package/build/lib/mixins/events.js.map +1 -1
- package/build/lib/mixins/execute.d.ts.map +1 -1
- package/build/lib/mixins/execute.js +2 -2
- package/build/lib/mixins/execute.js.map +1 -1
- package/build/lib/mixins/message-handlers.d.ts.map +1 -1
- package/build/lib/mixins/message-handlers.js.map +1 -1
- package/build/lib/mixins/misc.d.ts.map +1 -1
- package/build/lib/mixins/misc.js +1 -1
- package/build/lib/mixins/misc.js.map +1 -1
- package/build/lib/mixins/navigate.d.ts.map +1 -1
- package/build/lib/mixins/navigate.js +2 -3
- package/build/lib/mixins/navigate.js.map +1 -1
- package/build/lib/mixins/property-accessors.d.ts +20 -20
- package/build/lib/mixins/property-accessors.d.ts.map +1 -1
- package/build/lib/mixins/property-accessors.js.map +1 -1
- package/build/lib/mixins/screenshot.d.ts.map +1 -1
- package/build/lib/mixins/screenshot.js +5 -1
- package/build/lib/mixins/screenshot.js.map +1 -1
- package/build/lib/protocol/index.d.ts.map +1 -1
- package/build/lib/protocol/index.js +2 -3
- package/build/lib/protocol/index.js.map +1 -1
- package/build/lib/remote-debugger-real-device.d.ts.map +1 -1
- package/build/lib/remote-debugger-real-device.js.map +1 -1
- package/build/lib/remote-debugger.d.ts.map +1 -1
- package/build/lib/remote-debugger.js +3 -1
- package/build/lib/remote-debugger.js.map +1 -1
- package/build/lib/rpc/index.d.ts.map +1 -1
- package/build/lib/rpc/index.js.map +1 -1
- package/build/lib/rpc/remote-messages.d.ts.map +1 -1
- package/build/lib/rpc/remote-messages.js +16 -15
- package/build/lib/rpc/remote-messages.js.map +1 -1
- package/build/lib/rpc/rpc-client-real-device.d.ts.map +1 -1
- package/build/lib/rpc/rpc-client-real-device.js.map +1 -1
- package/build/lib/rpc/rpc-client-simulator.d.ts.map +1 -1
- package/build/lib/rpc/rpc-client-simulator.js +3 -4
- package/build/lib/rpc/rpc-client-simulator.js.map +1 -1
- package/build/lib/rpc/rpc-client.d.ts.map +1 -1
- package/build/lib/rpc/rpc-client.js +6 -6
- package/build/lib/rpc/rpc-client.js.map +1 -1
- package/build/lib/rpc/rpc-message-handler.d.ts.map +1 -1
- package/build/lib/rpc/rpc-message-handler.js +3 -4
- package/build/lib/rpc/rpc-message-handler.js.map +1 -1
- package/build/lib/types.d.ts.map +1 -1
- package/build/lib/utils.d.ts.map +1 -1
- package/build/lib/utils.js +6 -5
- package/build/lib/utils.js.map +1 -1
- package/lib/atoms.ts +8 -6
- package/lib/index.ts +18 -11
- package/lib/logger.ts +1 -1
- package/lib/mixins/connect.ts +63 -47
- package/lib/mixins/cookies.ts +5 -11
- package/lib/mixins/events.ts +8 -19
- package/lib/mixins/execute.ts +43 -35
- package/lib/mixins/message-handlers.ts +21 -20
- package/lib/mixins/misc.ts +12 -15
- package/lib/mixins/navigate.ts +68 -61
- package/lib/mixins/property-accessors.ts +48 -23
- package/lib/mixins/screenshot.ts +10 -11
- package/lib/protocol/index.ts +11 -9
- package/lib/remote-debugger-real-device.ts +5 -5
- package/lib/remote-debugger.ts +22 -28
- package/lib/rpc/index.ts +2 -2
- package/lib/rpc/remote-messages.ts +48 -48
- package/lib/rpc/rpc-client-real-device.ts +4 -4
- package/lib/rpc/rpc-client-simulator.ts +23 -20
- package/lib/rpc/rpc-client.ts +161 -108
- package/lib/rpc/rpc-message-handler.ts +34 -24
- package/lib/types.ts +3 -3
- package/lib/utils.ts +24 -17
- package/package.json +3 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import {EventEmitter} from 'node:events';
|
|
2
|
+
import {log} from '../logger';
|
|
3
3
|
import _ from 'lodash';
|
|
4
|
-
import {
|
|
5
|
-
import type {
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
137
|
-
`
|
|
138
|
-
|
|
139
|
-
|
|
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 =
|
|
204
|
-
|
|
205
|
-
|
|
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 =
|
|
228
|
-
|
|
229
|
-
|
|
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(
|
|
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 {
|
|
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 &
|
|
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 {
|
|
3
|
-
import {
|
|
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 {
|
|
7
|
-
import type {
|
|
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 =
|
|
39
|
-
|
|
40
|
-
|
|
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
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
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(
|
|
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.
|
|
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\"",
|